@simoncomputing/mui-bueno-v2 0.35.2 → 0.35.4

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/index.umd.js CHANGED
@@ -353,7 +353,7 @@ img.ProseMirror-separator {
353
353
  *
354
354
  * This source code is licensed under the MIT license found in the
355
355
  * LICENSE file in the root directory of this source tree.
356
- */var xO;function T9(){return xO||(xO=1,process.env.NODE_ENV!=="production"&&(function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var t=J,e=Xf;function n(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}var r=typeof Object.is=="function"?Object.is:n,o=e.useSyncExternalStore,i=t.useRef,s=t.useEffect,a=t.useMemo,l=t.useDebugValue;function u(f,p,m,b,v){var y=i(null),x;y.current===null?(x={hasValue:!1,value:null},y.current=x):x=y.current;var S=a(function(){var O=!1,I,N,L=function(H){if(!O){O=!0,I=H;var F=b(H);if(v!==void 0&&x.hasValue){var P=x.value;if(v(P,F))return N=P,P}return N=F,F}var _=I,D=N;if(r(_,H))return D;var R=b(H);return v!==void 0&&v(D,R)?D:(I=H,N=R,R)},V=m===void 0?null:m,M=function(){return L(p())},B=V===null?void 0:function(){return L(V())};return[M,B]},[p,m,b,v]),k=S[0],T=S[1],C=o(f,k,T);return s(function(){x.hasValue=!0,x.value=C},[C]),l(C),C}Eb.useSyncExternalStoreWithSelector=u,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)})()),Eb}process.env.NODE_ENV==="production"?Tb.exports=C9():Tb.exports=T9();var k9=Tb.exports;const E9=typeof window<"u"?J.useLayoutEffect:J.useEffect;class O9{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){const n=()=>{this.transactionNumber+=1,this.subscribers.forEach(o=>o())},r=this.editor;return r.on("transaction",n),()=>{r.off("transaction",n)}}}}function M9(t){var e;const[n]=J.useState(()=>new O9(t.editor)),r=k9.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!==null&&e!==void 0?e:S9);return E9(()=>n.watch(t.editor),[t.editor,n]),J.useDebugValue(r),r}const wO=process.env.NODE_ENV!=="production",Ob=typeof window>"u",_9=Ob||!!(typeof window<"u"&&window.next);class Mb{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0)return Ob||_9?(wO&&console.warn("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches."),null):this.createEditor();if(this.options.current.immediatelyRender&&Ob&&wO)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var o,i;return(i=(o=this.options.current).onBeforeCreate)===null||i===void 0?void 0:i.call(o,...r)},onBlur:(...r)=>{var o,i;return(i=(o=this.options.current).onBlur)===null||i===void 0?void 0:i.call(o,...r)},onCreate:(...r)=>{var o,i;return(i=(o=this.options.current).onCreate)===null||i===void 0?void 0:i.call(o,...r)},onDestroy:(...r)=>{var o,i;return(i=(o=this.options.current).onDestroy)===null||i===void 0?void 0:i.call(o,...r)},onFocus:(...r)=>{var o,i;return(i=(o=this.options.current).onFocus)===null||i===void 0?void 0:i.call(o,...r)},onSelectionUpdate:(...r)=>{var o,i;return(i=(o=this.options.current).onSelectionUpdate)===null||i===void 0?void 0:i.call(o,...r)},onTransaction:(...r)=>{var o,i;return(i=(o=this.options.current).onTransaction)===null||i===void 0?void 0:i.call(o,...r)},onUpdate:(...r)=>{var o,i;return(i=(o=this.options.current).onUpdate)===null||i===void 0?void 0:i.call(o,...r)},onContentError:(...r)=>{var o,i;return(i=(o=this.options.current).onContentError)===null||i===void 0?void 0:i.call(o,...r)},onDrop:(...r)=>{var o,i;return(i=(o=this.options.current).onDrop)===null||i===void 0?void 0:i.call(o,...r)},onPaste:(...r)=>{var o,i;return(i=(o=this.options.current).onPaste)===null||i===void 0?void 0:i.call(o,...r)}};return new l3(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((o,i)=>{var s;return o===((s=n.extensions)===null||s===void 0?void 0:s[i])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Mb.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,o)=>r===e[o]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}}function SO(t={},e=[]){const n=J.useRef(t);n.current=t;const[r]=J.useState(()=>new Mb(n)),o=Xf.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return J.useDebugValue(o),J.useEffect(r.onRender(e)),M9({editor:o,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1?null:t.immediatelyRender&&i===0?0:i+1}),o}J.createContext({editor:null}).Consumer;const CO=J.createContext({onDragStart:void 0}),TO=()=>J.useContext(CO),I9=t=>{const e=t.as||"div",{nodeViewContentRef:n}=TO();return J.createElement(e,{...t,ref:n,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...t.style}})},_b=J.forwardRef((t,e)=>{const{onDragStart:n}=TO(),r=t.as||"div";return J.createElement(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function kO(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function EO(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function D9(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function A9(t){if(kO(t)||EO(t))return!0;if(D9(t)){const e=t.type;if(e)return kO(e)||EO(e)}return!1}function P9(){try{if(J.version)return parseInt(J.version.split(".")[0],10)>=19}catch{}return!1}class OO{constructor(e,{editor:n,props:r={},as:o="div",className:i=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=e,this.editor=n,this.props=r,this.element=document.createElement(o),this.element.classList.add("react-renderer"),i&&this.element.classList.add(...i.split(" ")),this.editor.isInitialized?Ps.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var e;const n=this.component,r=this.props,o=this.editor,i=P9(),s=A9(n),a={...r};a.ref&&!(i||s)&&delete a.ref,!a.ref&&(i||s)&&(a.ref=l=>{this.ref=l}),this.reactElement=J.createElement(n,{...a}),(e=o==null?void 0:o.contentComponent)===null||e===void 0||e.setRenderer(this.id,this)}updateProps(e={}){this.props={...this.props,...e},this.render()}destroy(){var e;const n=this.editor;(e=n==null?void 0:n.contentComponent)===null||e===void 0||e.removeRenderer(this.id)}updateAttributes(e){Object.keys(e).forEach(n=>{this.element.setAttribute(n,e[n])})}}class N9 extends c3{constructor(e,n,r){if(super(e,n,r),!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const o=this.dom.querySelector("[data-node-view-content]");if(!o)return;o.appendChild(this.contentDOMElement)}}mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(u={})=>this.updateAttributes(u),deleteNode:()=>this.deleteNode(),ref:J.createRef()};if(!this.component.displayName){const u=f=>f.charAt(0).toUpperCase()+f.substring(1);this.component.displayName=u(this.extension.name)}const o={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:u=>{u&&this.contentDOMElement&&u.firstChild!==this.contentDOMElement&&(u.hasAttribute("data-node-view-wrapper")&&u.removeAttribute("data-node-view-wrapper"),u.appendChild(this.contentDOMElement))}},i=this.component,s=J.memo(u=>J.createElement(CO.Provider,{value:o},J.createElement(i,u)));s.displayName="ReactNodeView";let a=this.node.isInline?"span":"div";this.options.as&&(a=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new OO(s,{editor:this.editor,props:e,as:a,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var e;if(this.renderer.element.firstElementChild&&!(!((e=this.renderer.element.firstElementChild)===null||e===void 0)&&e.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){const{from:e,to:n}=this.editor.state.selection,r=this.getPos();if(typeof r=="number")if(e<=r&&n>=r+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(e,n,r){const o=i=>{this.renderer.updateProps(i),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const i=this.node,s=this.decorations,a=this.innerDecorations;return this.node=e,this.decorations=n,this.innerDecorations=r,this.options.update({oldNode:i,oldDecorations:s,newNode:e,newDecorations:n,oldInnerDecorations:a,innerDecorations:r,updateProps:()=>o({node:e,decorations:n,innerDecorations:r})})}return e===this.node&&this.decorations===n&&this.innerDecorations===r||(this.node=e,this.decorations=n,this.innerDecorations=r,o({node:e,decorations:n,innerDecorations:r})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let e={};if(typeof this.options.attrs=="function"){const n=this.editor.extensionManager.attributes,r=Zd(this.node,n);e=this.options.attrs({node:this.node,HTMLAttributes:r})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}}function Ib(t,e){return n=>n.editor.contentComponent?new N9(t,n,e):{}}const lu=Xt("HeadingWithAnchorComponent",["root","container","link","linkIcon"]),cu=Ut("HeadingWithAnchorComponent"),$9=oe(_b,{name:cu,slot:"root",overridesResolver:(t,e)=>e.root,shouldForwardProp:t=>t!=="ownerState"&&t!=="theme"&&t!=="sx"})({[`&:hover .${lu.link}`]:{opacity:100}}),L9=oe("span",{name:cu,slot:"container",overridesResolver:(t,e)=>e.container})({display:"inline-block",position:"relative"}),B9=oe("a",{name:cu,slot:"link",overridesResolver:(t,e)=>e.link})(({theme:t})=>({position:"absolute",left:-21,color:`${t.palette.text.secondary} !important`,opacity:0,transition:t.transitions.create("opacity"),textDecoration:"none",outline:"none",[t.breakpoints.down("sm")]:{left:-18},'.ProseMirror[contenteditable="true"] &':{display:"none"}})),F9=oe(Hf,{name:cu,slot:"linkIcon",overridesResolver:(t,e)=>e.linkIcon})(({theme:t})=>({transform:"rotate(-45deg)",fontSize:"1.25rem",[t.breakpoints.down("sm")]:{fontSize:"1.15rem"}}));function R9(t){const e=rt({props:t,name:cu}),{editor:n,node:r,extension:o,classes:i={},sx:s}=e,u=`h${o.options.levels.includes(r.attrs.level)?r.attrs.level:o.options.levels[0]}`,f=J.useMemo(()=>jg(n.schema),[n.schema]),p=I6(oT(r,{textSerializers:f}));return g.jsx($9,{as:u,id:p,...o.options.HTMLAttributes,className:ge([lu.root,i.root]),style:{textAlign:r.attrs.textAlign},sx:s,children:g.jsxs(L9,{className:ge([lu.container,i.container]),children:[g.jsx(B9,{href:`#${p}`,contentEditable:!1,className:ge([lu.link,i.link]),children:g.jsx(F9,{className:ge([lu.linkIcon,i.linkIcon])})}),g.jsx(I9,{as:"span"})]})})}const z9=ST.extend({addOptions(){var t;return{...(t=this.parent)===null||t===void 0?void 0:t.call(this),scrollToAnchorOnMount:!0}},onCreate(){this.options.scrollToAnchorOnMount&&setTimeout(()=>{V9(this.editor)})},addNodeView(){return Ib(R9)}});function V9(t){if(t.isDestroyed||!("heading"in t.storage))return;const n=window.location.hash.slice(1);if(!n)return;const r=window.document.getElementById(n);r&&t.view.dom.contains(r)&&r.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})}var fr;(function(t){t[t.HIDDEN=0]="HIDDEN",t[t.VIEW_LINK_DETAILS=1]="VIEW_LINK_DETAILS",t[t.EDIT_LINK=2]="EDIT_LINK"})(fr||(fr={}));const H9=cn.create({name:"linkBubbleMenuHandler",addStorage(){return{state:fr.HIDDEN,bubbleMenuOptions:void 0}},addCommands(){return{openLinkBubbleMenu:(t={})=>({editor:e,chain:n,dispatch:r})=>{const o=this.storage.state;let i;return e.isActive("link")?(o!==fr.VIEW_LINK_DETAILS&&n().extendMarkRange("link").focus().run(),i=fr.VIEW_LINK_DETAILS):i=fr.EDIT_LINK,r&&(this.storage.state=i,this.storage.bubbleMenuOptions=t),!0},editLinkInBubbleMenu:()=>({dispatch:t})=>{const e=this.storage.state,n=fr.EDIT_LINK;return e===n?!1:(t&&(this.storage.state=n),!0)},closeLinkBubbleMenu:()=>({commands:t,dispatch:e})=>this.storage.state===fr.HIDDEN?!1:(t.focus(),e&&(this.storage.state=fr.HIDDEN),!0)}},onSelectionUpdate(){this.storage.state===fr.EDIT_LINK?this.editor.commands.closeLinkBubbleMenu():this.storage.state===fr.VIEW_LINK_DETAILS&&!this.editor.isActive("link")&&this.editor.commands.closeLinkBubbleMenu()},addKeyboardShortcuts(){return{"Mod-Shift-u":()=>(this.editor.commands.openLinkBubbleMenu(),!0)}},addProseMirrorPlugins(){return[new en({key:new On("handleClickLinkForMenu"),props:{handleClick:(t,e,n)=>{const r=Yg(t.state,"link");return n.target.closest("a")&&r.href&&this.storage.state===fr.HIDDEN?this.editor.commands.openLinkBubbleMenu():this.editor.commands.closeLinkBubbleMenu(),!1}}})]}}),W9=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,j9=tn.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",Ct(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[cT({find:W9,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}});var Db={},MO;function U9(){return MO||(MO=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ME();function n(r,o=0,i={}){const{leading:s=!0,trailing:a=!0}=i;return e.debounce(r,o,{leading:s,maxWait:o,trailing:a})}t.throttle=n})(Db)),Db}var Ab,_O;function q9(){return _O||(_O=1,Ab=U9().throttle),Ab}var K9=q9();const Y9=Un(K9),Zf=Xt("ResizableImageComponent",["imageContainer","image","imageSelected","resizer"]),G9=Xt("ResizableImageResizer",["root"]),IO=Ut("ResizableImageResizer"),J9=oe("div",{name:IO,slot:"root",overridesResolver:(t,e)=>e.root})(({theme:t})=>({position:"absolute",bottom:-3,right:-3,width:12,height:12,background:t.palette.primary.main,cursor:"nwse-resize"}));function X9(t){const e=rt({props:t,name:IO}),{onResize:n,className:r,mouseDown:o,setMouseDown:i,classes:s={},sx:a}=e;J.useEffect(()=>{if(!o)return;const u=f=>{n(f)};return window.addEventListener("mousemove",u),()=>{window.removeEventListener("mousemove",u)}},[o,n]),J.useEffect(()=>{const u=()=>{i(!1)};return window.addEventListener("mouseup",u),()=>{window.removeEventListener("mouseup",u)}},[i]);const l=J.useCallback(u=>{u.preventDefault(),u.stopPropagation(),i(!0)},[i]);return g.jsx(J9,{className:ge([G9.root,r,s.root]),onMouseDown:l,sx:a})}const Z9=15,Qf=Ut("ResizableImageComponent"),Q9=oe("div",{name:Qf,slot:"imageContainer",overridesResolver:(t,e)=>e.imageContainer})(()=>({display:"inline-flex",position:"relative"})),e8=oe("img",{name:Qf,slot:"image",overridesResolver:(t,e)=>[e.image,t.ownerState.selectedOrResizing&&e.imageSelected]})(({theme:t,ownerState:e})=>({display:"block",...e.selectedOrResizing&&{outline:`3px solid ${t.palette.primary.main}`}})),t8=oe(X9,{name:Qf,slot:"resizer",overridesResolver:(t,e)=>e.resizer})(()=>({'.ProseMirror[contenteditable="false"] &':{display:"none"}}));function n8(t){var e,n,r;const o=rt({props:t,name:Qf}),{node:i,selected:s,updateAttributes:a,extension:l,classes:u={},sx:f}=o,{attrs:p}=i,m=J.useRef(null),[b,v]=J.useState(!1),y=s||b,x={selected:s,selectedOrResizing:y},S=J.useMemo(()=>Y9(T=>{if(!m.current)return;const C=m.current.getBoundingClientRect(),O=T.clientX-C.x,I=T.clientY-C.y,N=Math.max(O,C.width/C.height*I,Z9);a({width:Math.round(N)})},50,{trailing:!0}),[a]),k=l.options.ChildComponent;return g.jsx(_b,{style:{textAlign:p.textAlign,width:"100%"},as:l.options.inline?"span":"div",sx:f,children:g.jsxs(Q9,{className:ge([Zf.imageContainer,u.imageContainer]),children:[g.jsx(e8,{ref:m,src:p.src,height:"auto",width:p.width?p.width:void 0,alt:(e=p.alt)!==null&&e!==void 0?e:void 0,title:(n=p.title)!==null&&n!==void 0?n:void 0,className:ge([Zf.image,u.image,y&&"ProseMirror-selectednode",y&&[Zf.imageSelected,u.imageSelected]]),style:{maxWidth:p.width?void 0:"auto",aspectRatio:(r=p.aspectRatio)!==null&&r!==void 0?r:void 0},ownerState:x,"data-drag-handle":!0,onLoad:T=>{const C={};p.width||(C.width=T.currentTarget.naturalWidth),p.aspectRatio||(C.aspectRatio=String(T.currentTarget.naturalWidth/T.currentTarget.naturalHeight)),(C.width||C.aspectRatio)&&a(C)}}),y&&g.jsx(t8,{onResize:S,className:ge([Zf.resizer,u.resizer]),mouseDown:b,setMouseDown:v}),k&&g.jsx(k,{...o})]})})}const r8=j9.extend({addOptions(){var t;return{...(t=this.parent)===null||t===void 0?void 0:t.call(this),isAllowedImgSrc:e=>!!e}},addAttributes(){var t;return{...(t=this.parent)===null||t===void 0?void 0:t.call(this),width:{default:null,renderHTML:e=>({width:e.width}),parseHTML:e=>e.getAttribute("width")},aspectRatio:{default:null,renderHTML:e=>e.aspectRatio?{style:`aspect-ratio: ${e.aspectRatio}`}:{},parseHTML:e=>e.style.aspectRatio}}},renderHTML({HTMLAttributes:t}){return["img",Ct({height:"auto"},this.options.HTMLAttributes,t)]},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])',getAttrs:t=>{if(!(t instanceof Element))return!1;const e=t.getAttribute("src");return this.options.isAllowedImgSrc(e)&&null}}]},addInputRules(){var t;const e=(t=this.parent)===null||t===void 0?void 0:t.call(this);if(!e)return[];const n=r=>{const[,,o,i,s]=r;return{src:i,alt:o,title:s}};return e.map(r=>new Ec({find:r.find,handler:o=>{const i=n(o.match);if(this.options.isAllowedImgSrc(i.src))return r.handler(o)}}))},addNodeView(){return Ib(n8)}});let Pb,Nb;if(typeof WeakMap<"u"){let t=new WeakMap;Pb=e=>t.get(e),Nb=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;Pb=r=>{for(let o=0;o<t.length;o+=2)if(t[o]==r)return t[o+1]},Nb=(r,o)=>(n==10&&(n=0),t[n++]=r,t[n++]=o)}var fn=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,o=e/this.width|0;let i=r+1,s=o+1;for(let a=1;i<this.width&&this.map[e+a]==n;a++)i++;for(let a=1;s<this.height&&this.map[e+this.width*a]==n;a++)s++;return{left:r,top:o,right:i,bottom:s}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:o,top:i,bottom:s}=this.findCell(t);return e=="horiz"?(n<0?r==0:o==this.width)?null:this.map[i*this.width+(n<0?r-1:o)]:(n<0?i==0:s==this.height)?null:this.map[r+this.width*(n<0?i-1:s)]}rectBetween(t,e){const{left:n,right:r,top:o,bottom:i}=this.findCell(t),{left:s,right:a,top:l,bottom:u}=this.findCell(e);return{left:Math.min(n,s),top:Math.min(o,l),right:Math.max(r,a),bottom:Math.max(i,u)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let o=t.left;o<t.right;o++){const i=r*this.width+o,s=this.map[i];n[s]||(n[s]=!0,!(o==t.left&&o&&this.map[i-1]==s||r==t.top&&r&&this.map[i-this.width]==s)&&e.push(s))}return e}positionAt(t,e,n){for(let r=0,o=0;;r++){const i=o+n.child(r).nodeSize;if(r==t){let s=e+t*this.width;const a=(t+1)*this.width;for(;s<a&&this.map[s]<o;)s++;return s==a?i-1:this.map[s]}o=i}}static get(t){return Pb(t)||Nb(t,o8(t))}};function o8(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=i8(t),n=t.childCount,r=[];let o=0,i=null;const s=[];for(let u=0,f=e*n;u<f;u++)r[u]=0;for(let u=0,f=0;u<n;u++){const p=t.child(u);f++;for(let v=0;;v++){for(;o<r.length&&r[o]!=0;)o++;if(v==p.childCount)break;const y=p.child(v),{colspan:x,rowspan:S,colwidth:k}=y.attrs;for(let T=0;T<S;T++){if(T+u>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:f,n:S-T});break}const C=o+T*e;for(let O=0;O<x;O++){r[C+O]==0?r[C+O]=f:(i||(i=[])).push({type:"collision",row:u,pos:f,n:x-O});const I=k&&k[O];if(I){const N=(C+O)%e*2,L=s[N];L==null||L!=I&&s[N+1]==1?(s[N]=I,s[N+1]=1):L==I&&s[N+1]++}}}o+=x,f+=y.nodeSize}const m=(u+1)*e;let b=0;for(;o<m;)r[o++]==0&&b++;b&&(i||(i=[])).push({type:"missing",row:u,n:b}),f++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const a=new fn(e,n,r,i);let l=!1;for(let u=0;!l&&u<s.length;u+=2)s[u]!=null&&s[u+1]<n&&(l=!0);return l&&s8(a,s,t),a}function i8(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const o=t.child(r);let i=0;if(n)for(let s=0;s<r;s++){const a=t.child(s);for(let l=0;l<a.childCount;l++){const u=a.child(l);s+u.attrs.rowspan>r&&(i+=u.attrs.colspan)}}for(let s=0;s<o.childCount;s++){const a=o.child(s);i+=a.attrs.colspan,a.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function s8(t,e,n){t.problems||(t.problems=[]);const r={};for(let o=0;o<t.map.length;o++){const i=t.map[o];if(r[i])continue;r[i]=!0;const s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let a=null;const l=s.attrs;for(let u=0;u<l.colspan;u++){const f=e[(o+u)%t.width*2];f!=null&&(!l.colwidth||l.colwidth[u]!=f)&&((a||(a=a8(l)))[u]=f)}a&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:a})}}function a8(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function or(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],o=r.spec.tableRole;o&&(e[o]=r)}}return e}const ys=new On("selectingCells");function El(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function l8(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function Eo(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function ep(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=El(e.$head)||c8(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function c8(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function $b(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function u8(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Lb(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function DO(t,e,n){const r=t.node(-1),o=fn.get(r),i=t.start(-1),s=o.nextCell(t.pos-i,e,n);return s==null?null:t.node(0).resolve(i+s)}function pa(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function AO(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<n;o++)r.colwidth.splice(e,0,0)}return r}function d8(t,e,n){const r=or(e.type.schema).header_cell;for(let o=0;o<t.height;o++)if(e.nodeAt(t.map[n+o*t.width]).type!=r)return!1;return!0}var Wt=class Wi extends nt{constructor(e,n=e){const r=e.node(-1),o=fn.get(r),i=e.start(-1),s=o.rectBetween(e.pos-i,n.pos-i),a=e.node(0),l=o.cellsInRect(s).filter(f=>f!=n.pos-i);l.unshift(n.pos-i);const u=l.map(f=>{const p=r.nodeAt(f);if(!p)throw new RangeError(`No cell with offset ${f} found`);const m=i+f+1;return new aS(a.resolve(m),a.resolve(m+p.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),o=e.resolve(n.map(this.$headCell.pos));if($b(r)&&$b(o)&&Lb(r,o)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Wi.rowSelection(r,o):i&&this.isColSelection()?Wi.colSelection(r,o):new Wi(r,o)}return Xe.between(r,o)}content(){const e=this.$anchorCell.node(-1),n=fn.get(e),r=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},s=[];for(let l=o.top;l<o.bottom;l++){const u=[];for(let f=l*n.width+o.left,p=o.left;p<o.right;p++,f++){const m=n.map[f];if(i[m])continue;i[m]=!0;const b=n.findCell(m);let v=e.nodeAt(m);if(!v)throw new RangeError(`No cell with offset ${m} found`);const y=o.left-b.left,x=b.right-o.right;if(y>0||x>0){let S=v.attrs;if(y>0&&(S=pa(S,0,y)),x>0&&(S=pa(S,S.colspan-x,x)),b.left<o.left){if(v=v.type.createAndFill(S),!v)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(S)}`)}else v=v.type.create(S,v.content)}if(b.top<o.top||b.bottom>o.bottom){const S={...v.attrs,rowspan:Math.min(b.bottom,o.bottom)-Math.max(b.top,o.top)};b.top<o.top?v=v.type.createAndFill(S):v=v.type.create(S,v.content)}u.push(v)}s.push(e.child(l).copy(Oe.from(u)))}const a=this.isColSelection()&&this.isRowSelection()?e:s;return new Fe(Oe.from(a),1,1)}replace(e,n=Fe.empty){const r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){const{$from:a,$to:l}=o[s],u=e.mapping.slice(r);e.replace(u.map(a.pos),u.map(l.pos),s?Fe.empty:n)}const i=nt.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new Fe(Oe.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=fn.get(n),o=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let s=0;s<i.length;s++)e(n.nodeAt(i[s]),o+i[s])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),o=fn.get(r),i=e.start(-1),s=o.findCell(e.pos-i),a=o.findCell(n.pos-i),l=e.node(0);return s.top<=a.top?(s.top>0&&(e=l.resolve(i+o.map[s.left])),a.bottom<o.height&&(n=l.resolve(i+o.map[o.width*(o.height-1)+a.right-1]))):(a.top>0&&(n=l.resolve(i+o.map[a.left])),s.bottom<o.height&&(e=l.resolve(i+o.map[o.width*(o.height-1)+s.right-1]))),new Wi(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=fn.get(e),r=this.$anchorCell.start(-1),o=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(o,i)>0)return!1;const s=o+this.$anchorCell.nodeAfter.attrs.colspan,a=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,a)==n.width}eq(e){return e instanceof Wi&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),o=fn.get(r),i=e.start(-1),s=o.findCell(e.pos-i),a=o.findCell(n.pos-i),l=e.node(0);return s.left<=a.left?(s.left>0&&(e=l.resolve(i+o.map[s.top*o.width])),a.right<o.width&&(n=l.resolve(i+o.map[o.width*(a.top+1)-1]))):(a.left>0&&(n=l.resolve(i+o.map[a.top*o.width])),s.right<o.width&&(e=l.resolve(i+o.map[o.width*(s.top+1)-1]))),new Wi(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new Wi(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new Wi(e.resolve(n),e.resolve(r))}getBookmark(){return new f8(this.$anchorCell.pos,this.$headCell.pos)}};Wt.prototype.visible=!1,nt.jsonID("cell",Wt);var f8=class TP{constructor(e,n){this.anchor=e,this.head=n}map(e){return new TP(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.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&&Lb(n,r)?new Wt(n,r):nt.near(r,1)}};function p8(t){if(!(t.selection instanceof Wt))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(Yn.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Jt.create(t.doc,e)}function h8({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,o=t.depth;for(;o>=0&&!(t.after(o+1)<t.end(o));o--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(o).type.spec.tableRole)}function m8({$from:t,$to:e}){let n,r;for(let o=t.depth;o>0;o--){const i=t.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let o=e.depth;o>0;o--){const i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function g8(t,e,n){const r=(e||t).selection,o=(e||t).doc;let i,s;if(r instanceof Je&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")i=Wt.create(o,r.from);else if(s=="row"){const a=o.resolve(r.from+1);i=Wt.rowSelection(a,a)}else if(!n){const a=fn.get(r.node),l=r.from+1,u=l+a.map[a.width*a.height-1];i=Wt.create(o,l+1,u)}}else r instanceof Xe&&h8(r)?i=Xe.create(o,r.from):r instanceof Xe&&m8(r)&&(i=Xe.create(o,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const y8=new On("fix-tables");function PO(t,e,n,r){const o=t.childCount,i=e.childCount;e:for(let s=0,a=0;s<i;s++){const l=e.child(s);for(let u=a,f=Math.min(o,s+3);u<f;u++)if(t.child(u)==l){a=u+1,n+=l.nodeSize;continue e}r(l,n),a<o&&t.child(a).sameMarkup(l)?PO(t.child(a),l,n+1,r):l.nodesBetween(0,l.content.size,r,n+1),n+=l.nodeSize}}function NO(t,e){let n;const r=(o,i)=>{o.type.spec.tableRole=="table"&&(n=b8(t,o,i,n))};return e?e.doc!=t.doc&&PO(e.doc,t.doc,0,r):t.doc.descendants(r),n}function b8(t,e,n,r){const o=fn.get(e);if(!o.problems)return r;r||(r=t.tr);const i=[];for(let l=0;l<o.height;l++)i.push(0);for(let l=0;l<o.problems.length;l++){const u=o.problems[l];if(u.type=="collision"){const f=e.nodeAt(u.pos);if(!f)continue;const p=f.attrs;for(let m=0;m<p.rowspan;m++)i[u.row+m]+=u.n;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,pa(p,p.colspan-u.n,u.n))}else if(u.type=="missing")i[u.row]+=u.n;else if(u.type=="overlong_rowspan"){const f=e.nodeAt(u.pos);if(!f)continue;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,{...f.attrs,rowspan:f.attrs.rowspan-u.n})}else if(u.type=="colwidth mismatch"){const f=e.nodeAt(u.pos);if(!f)continue;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,{...f.attrs,colwidth:u.colwidth})}else if(u.type=="zero_sized"){const f=r.mapping.map(n);r.delete(f,f+e.nodeSize)}}let s,a;for(let l=0;l<i.length;l++)i[l]&&(s==null&&(s=l),a=l);for(let l=0,u=n+1;l<o.height;l++){const f=e.child(l),p=u+f.nodeSize,m=i[l];if(m>0){let b="cell";f.firstChild&&(b=f.firstChild.type.spec.tableRole);const v=[];for(let x=0;x<m;x++){const S=or(t.schema)[b].createAndFill();S&&v.push(S)}const y=(l==0||s==l-1)&&a==l?u+1:p-1;r.insert(r.mapping.map(y),v)}u=p}return r.setMeta(y8,{fixTables:!0})}function Ko(t){const e=t.selection,n=ep(t),r=n.node(-1),o=n.start(-1),i=fn.get(r);return{...e instanceof Wt?i.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):i.findCell(n.pos-o),tableStart:o,map:i,table:r}}function $O(t,{map:e,tableStart:n,table:r},o){let i=o>0?-1:0;d8(e,r,o+i)&&(i=o==0||o==e.width?null:0);for(let s=0;s<e.height;s++){const a=s*e.width+o;if(o>0&&o<e.width&&e.map[a-1]==e.map[a]){const l=e.map[a],u=r.nodeAt(l);t.setNodeMarkup(t.mapping.map(n+l),null,AO(u.attrs,o-e.colCount(l))),s+=u.attrs.rowspan-1}else{const l=i==null?or(r.type.schema).cell:r.nodeAt(e.map[a+i]).type,u=e.positionAt(s,o,r);t.insert(t.mapping.map(n+u),l.createAndFill())}}return t}function v8(t,e){if(!Eo(t))return!1;if(e){const n=Ko(t);e($O(t.tr,n,n.left))}return!0}function x8(t,e){if(!Eo(t))return!1;if(e){const n=Ko(t);e($O(t.tr,n,n.right))}return!0}function w8(t,{map:e,table:n,tableStart:r},o){const i=t.mapping.maps.length;for(let s=0;s<e.height;){const a=s*e.width+o,l=e.map[a],u=n.nodeAt(l),f=u.attrs;if(o>0&&e.map[a-1]==l||o<e.width-1&&e.map[a+1]==l)t.setNodeMarkup(t.mapping.slice(i).map(r+l),null,pa(f,o-e.colCount(l)));else{const p=t.mapping.slice(i).map(r+l);t.delete(p,p+u.nodeSize)}s+=f.rowspan}}function S8(t,e){if(!Eo(t))return!1;if(e){const n=Ko(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let o=n.right-1;w8(r,n,o),o!=n.left;o--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=fn.get(i)}e(r)}return!0}function C8(t,e,n){var r;const o=or(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))===null||r===void 0?void 0:r.type)!=o)return!1;return!0}function LO(t,{map:e,tableStart:n,table:r},o){let i=n;for(let u=0;u<o;u++)i+=r.child(u).nodeSize;const s=[];let a=o>0?-1:0;C8(e,r,o+a)&&(a=o==0||o==e.height?null:0);for(let u=0,f=e.width*o;u<e.width;u++,f++)if(o>0&&o<e.height&&e.map[f]==e.map[f-e.width]){const p=e.map[f],m=r.nodeAt(p).attrs;t.setNodeMarkup(n+p,null,{...m,rowspan:m.rowspan+1}),u+=m.colspan-1}else{var l;const p=a==null?or(r.type.schema).cell:(l=r.nodeAt(e.map[f+a*e.width]))===null||l===void 0?void 0:l.type,m=p==null?void 0:p.createAndFill();m&&s.push(m)}return t.insert(i,or(r.type.schema).row.create(null,s)),t}function T8(t,e){if(!Eo(t))return!1;if(e){const n=Ko(t);e(LO(t.tr,n,n.top))}return!0}function k8(t,e){if(!Eo(t))return!1;if(e){const n=Ko(t);e(LO(t.tr,n,n.bottom))}return!0}function E8(t,{map:e,table:n,tableStart:r},o){let i=0;for(let u=0;u<o;u++)i+=n.child(u).nodeSize;const s=i+n.child(o).nodeSize,a=t.mapping.maps.length;t.delete(i+r,s+r);const l=new Set;for(let u=0,f=o*e.width;u<e.width;u++,f++){const p=e.map[f];if(!l.has(p)){if(l.add(p),o>0&&p==e.map[f-e.width]){const m=n.nodeAt(p).attrs;t.setNodeMarkup(t.mapping.slice(a).map(p+r),null,{...m,rowspan:m.rowspan-1}),u+=m.colspan-1}else if(o<e.height&&p==e.map[f+e.width]){const m=n.nodeAt(p),b=m.attrs,v=m.type.create({...b,rowspan:m.attrs.rowspan-1},m.content),y=e.positionAt(o+1,u,n);t.insert(t.mapping.slice(a).map(r+y),v),u+=b.colspan-1}}}}function O8(t,e){if(!Eo(t))return!1;if(e){const n=Ko(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let o=n.bottom-1;E8(r,n,o),o!=n.top;o--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=fn.get(n.table)}e(r)}return!0}function BO(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function M8({width:t,height:e,map:n},r){let o=r.top*t+r.left,i=o,s=(r.bottom-1)*t+r.left,a=o+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[a]==n[a+1])return!0;i+=t,a+=t}for(let l=r.left;l<r.right;l++){if(r.top>0&&n[o]==n[o-t]||r.bottom<e&&n[s]==n[s+t])return!0;o++,s++}return!1}function FO(t,e){const n=t.selection;if(!(n instanceof Wt)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=Ko(t),{map:o}=r;if(M8(o,r))return!1;if(e){const i=t.tr,s={};let a=Oe.empty,l,u;for(let f=r.top;f<r.bottom;f++)for(let p=r.left;p<r.right;p++){const m=o.map[f*o.width+p],b=r.table.nodeAt(m);if(!(s[m]||!b))if(s[m]=!0,l==null)l=m,u=b;else{BO(b)||(a=a.append(b.content));const v=i.mapping.map(m+r.tableStart);i.delete(v,v+b.nodeSize)}}if(l==null||u==null)return!0;if(i.setNodeMarkup(l+r.tableStart,null,{...AO(u.attrs,u.attrs.colspan,r.right-r.left-u.attrs.colspan),rowspan:r.bottom-r.top}),a.size>0){const f=l+1+u.content.size,p=BO(u)?l+1:f;i.replaceWith(p+r.tableStart,f+r.tableStart,a)}i.setSelection(new Wt(i.doc.resolve(l+r.tableStart))),e(i)}return!0}function RO(t,e){const n=or(t.schema);return _8(({node:r})=>n[r.type.spec.tableRole])(t,e)}function _8(t){return(e,n)=>{const r=e.selection;let o,i;if(r instanceof Wt){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;o=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var s;if(o=l8(r.$from),!o)return!1;i=(s=El(r.$from))===null||s===void 0?void 0:s.pos}if(o==null||i==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(n){let a=o.attrs;const l=[],u=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});const f=Ko(e),p=e.tr;for(let b=0;b<f.right-f.left;b++)l.push(u?{...a,colwidth:u&&u[b]?[u[b]]:null}:a);let m;for(let b=f.top;b<f.bottom;b++){let v=f.map.positionAt(b,f.left,f.table);b==f.top&&(v+=o.nodeSize);for(let y=f.left,x=0;y<f.right;y++,x++)y==f.left&&b==f.top||p.insert(m=p.mapping.map(v+f.tableStart,1),t({node:o,row:b,col:y}).createAndFill(l[x]))}p.setNodeMarkup(i,t({node:o,row:f.top,col:f.left}),l[0]),r instanceof Wt&&p.setSelection(new Wt(p.doc.resolve(r.$anchorCell.pos),m?p.doc.resolve(m):void 0)),n(p)}return!0}}function I8(t,e){return function(n,r){if(!Eo(n))return!1;const o=ep(n);if(o.nodeAfter.attrs[t]===e)return!1;if(r){const i=n.tr;n.selection instanceof Wt?n.selection.forEachCell((s,a)=>{s.attrs[t]!==e&&i.setNodeMarkup(a,null,{...s.attrs,[t]:e})}):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function D8(t){return function(e,n){if(!Eo(e))return!1;if(n){const r=or(e.schema),o=Ko(e),i=e.tr,s=o.map.cellsInRect(t=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:t=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),a=s.map(l=>o.table.nodeAt(l));for(let l=0;l<s.length;l++)a[l].type==r.header_cell&&i.setNodeMarkup(o.tableStart+s[l],r.cell,a[l].attrs);if(i.steps.length===0)for(let l=0;l<s.length;l++)i.setNodeMarkup(o.tableStart+s[l],r.header_cell,a[l].attrs);n(i)}return!0}}function zO(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let o=0;o<r.length;o++){const i=e.table.nodeAt(r[o]);if(i&&i.type!==n.header_cell)return!1}return!0}function uu(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?D8(t):function(n,r){if(!Eo(n))return!1;if(r){const o=or(n.schema),i=Ko(n),s=n.tr,a=zO("row",i,o),l=zO("column",i,o),u=(t==="column"?a:t==="row"&&l)?1:0,f=t=="column"?{left:0,top:u,right:1,bottom:i.map.height}:t=="row"?{left:u,top:0,right:i.map.width,bottom:1}:i,p=t=="column"?l?o.cell:o.header_cell:t=="row"?a?o.cell:o.header_cell:o.cell;i.map.cellsInRect(f).forEach(m=>{const b=m+i.tableStart,v=s.doc.nodeAt(b);v&&s.setNodeMarkup(b,p,v.attrs)}),r(s)}return!0}}uu("row",{useDeprecatedLogic:!0}),uu("column",{useDeprecatedLogic:!0});const A8=uu("cell",{useDeprecatedLogic:!0});function P8(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,o=t.before();r>=0;r--){const i=t.node(-1).child(r),s=i.lastChild;if(s)return o-1-s.nodeSize;o-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),o=t.after();r<n.childCount;r++){const i=n.child(r);if(i.childCount)return o+1;o+=i.nodeSize}}return null}function VO(t){return function(e,n){if(!Eo(e))return!1;const r=P8(ep(e),t);if(r==null)return!1;if(n){const o=e.doc.resolve(r);n(e.tr.setSelection(Xe.between(o,u8(o))).scrollIntoView())}return!0}}function N8(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function tp(t,e){const n=t.selection;if(!(n instanceof Wt))return!1;if(e){const r=t.tr,o=or(t.schema).cell.createAndFill().content;n.forEachCell((i,s)=>{i.content.eq(o)||r.replace(r.mapping.map(s+1),r.mapping.map(s+i.nodeSize-1),new Fe(o,0,0))}),r.docChanged&&e(r)}return!0}function $8(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const o=e.child(0),i=o.type.spec.tableRole,s=o.type.schema,a=[];if(i=="row")for(let l=0;l<e.childCount;l++){let u=e.child(l).content;const f=l?0:Math.max(0,n-1),p=l<e.childCount-1?0:Math.max(0,r-1);(f||p)&&(u=Bb(or(s).row,new Fe(u,f,p)).content),a.push(u)}else if(i=="cell"||i=="header_cell")a.push(n||r?Bb(or(s).row,new Fe(e,n,r)).content:e);else return null;return L8(s,a)}function L8(t,e){const n=[];for(let o=0;o<e.length;o++){const i=e[o];for(let s=i.childCount-1;s>=0;s--){const{rowspan:a,colspan:l}=i.child(s).attrs;for(let u=o;u<o+a;u++)n[u]=(n[u]||0)+l}}let r=0;for(let o=0;o<n.length;o++)r=Math.max(r,n[o]);for(let o=0;o<n.length;o++)if(o>=e.length&&e.push(Oe.empty),n[o]<r){const i=or(t).cell.createAndFill(),s=[];for(let a=n[o];a<r;a++)s.push(i);e[o]=e[o].append(Oe.from(s))}return{height:e.length,width:r,rows:e}}function Bb(t,e){const n=t.createAndFill();return new og(n).replace(0,n.content.size,e).doc}function B8({width:t,height:e,rows:n},r,o){if(t!=r){const i=[],s=[];for(let a=0;a<n.length;a++){const l=n[a],u=[];for(let f=i[a]||0,p=0;f<r;p++){let m=l.child(p%l.childCount);f+m.attrs.colspan>r&&(m=m.type.createChecked(pa(m.attrs,m.attrs.colspan,f+m.attrs.colspan-r),m.content)),u.push(m),f+=m.attrs.colspan;for(let b=1;b<m.attrs.rowspan;b++)i[a+b]=(i[a+b]||0)+m.attrs.colspan}s.push(Oe.from(u))}n=s,t=r}if(e!=o){const i=[];for(let s=0,a=0;s<o;s++,a++){const l=[],u=n[a%e];for(let f=0;f<u.childCount;f++){let p=u.child(f);s+p.attrs.rowspan>o&&(p=p.type.create({...p.attrs,rowspan:Math.max(1,o-p.attrs.rowspan)},p.content)),l.push(p)}i.push(Oe.from(l))}n=i,e=o}return{width:t,height:e,rows:n}}function F8(t,e,n,r,o,i,s){const a=t.doc.type.schema,l=or(a);let u,f;if(o>e.width)for(let p=0,m=0;p<e.height;p++){const b=n.child(p);m+=b.nodeSize;const v=[];let y;b.lastChild==null||b.lastChild.type==l.cell?y=u||(u=l.cell.createAndFill()):y=f||(f=l.header_cell.createAndFill());for(let x=e.width;x<o;x++)v.push(y);t.insert(t.mapping.slice(s).map(m-1+r),v)}if(i>e.height){const p=[];for(let v=0,y=(e.height-1)*e.width;v<Math.max(e.width,o);v++){const x=v>=e.width?!1:n.nodeAt(e.map[y+v]).type==l.header_cell;p.push(x?f||(f=l.header_cell.createAndFill()):u||(u=l.cell.createAndFill()))}const m=l.row.create(null,Oe.from(p)),b=[];for(let v=e.height;v<i;v++)b.push(m);t.insert(t.mapping.slice(s).map(r+n.nodeSize-2),b)}return!!(u||f)}function HO(t,e,n,r,o,i,s,a){if(s==0||s==e.height)return!1;let l=!1;for(let u=o;u<i;u++){const f=s*e.width+u,p=e.map[f];if(e.map[f-e.width]==p){l=!0;const m=n.nodeAt(p),{top:b,left:v}=e.findCell(p);t.setNodeMarkup(t.mapping.slice(a).map(p+r),null,{...m.attrs,rowspan:s-b}),t.insert(t.mapping.slice(a).map(e.positionAt(s,v,n)),m.type.createAndFill({...m.attrs,rowspan:b+m.attrs.rowspan-s})),u+=m.attrs.colspan-1}}return l}function WO(t,e,n,r,o,i,s,a){if(s==0||s==e.width)return!1;let l=!1;for(let u=o;u<i;u++){const f=u*e.width+s,p=e.map[f];if(e.map[f-1]==p){l=!0;const m=n.nodeAt(p),b=e.colCount(p),v=t.mapping.slice(a).map(p+r);t.setNodeMarkup(v,null,pa(m.attrs,s-b,m.attrs.colspan-(s-b))),t.insert(v+m.nodeSize,m.type.createAndFill(pa(m.attrs,0,s-b))),u+=m.attrs.rowspan-1}}return l}function jO(t,e,n,r,o){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let s=fn.get(i);const{top:a,left:l}=r,u=l+o.width,f=a+o.height,p=t.tr;let m=0;function b(){if(i=n?p.doc.nodeAt(n-1):p.doc,!i)throw new Error("No table found");s=fn.get(i),m=p.mapping.maps.length}F8(p,s,i,n,u,f,m)&&b(),HO(p,s,i,n,l,u,a,m)&&b(),HO(p,s,i,n,l,u,f,m)&&b(),WO(p,s,i,n,a,f,l,m)&&b(),WO(p,s,i,n,a,f,u,m)&&b();for(let v=a;v<f;v++){const y=s.positionAt(v,l,i),x=s.positionAt(v,u,i);p.replace(p.mapping.slice(m).map(y+n),p.mapping.slice(m).map(x+n),new Fe(o.rows[v-a],0,0))}b(),p.setSelection(new Wt(p.doc.resolve(n+s.positionAt(a,l,i)),p.doc.resolve(n+s.positionAt(f-1,u-1,i)))),e(p)}const R8=$g({ArrowLeft:rp("horiz",-1),ArrowRight:rp("horiz",1),ArrowUp:rp("vert",-1),ArrowDown:rp("vert",1),"Shift-ArrowLeft":op("horiz",-1),"Shift-ArrowRight":op("horiz",1),"Shift-ArrowUp":op("vert",-1),"Shift-ArrowDown":op("vert",1),Backspace:tp,"Mod-Backspace":tp,Delete:tp,"Mod-Delete":tp});function np(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function rp(t,e){return(n,r,o)=>{if(!o)return!1;const i=n.selection;if(i instanceof Wt)return np(n,r,nt.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const s=UO(o,t,e);if(s==null)return!1;if(t=="horiz")return np(n,r,nt.near(n.doc.resolve(i.head+e),e));{const a=n.doc.resolve(s),l=DO(a,t,e);let u;return l?u=nt.near(l,1):e<0?u=nt.near(n.doc.resolve(a.before(-1)),-1):u=nt.near(n.doc.resolve(a.after(-1)),1),np(n,r,u)}}}function op(t,e){return(n,r,o)=>{if(!o)return!1;const i=n.selection;let s;if(i instanceof Wt)s=i;else{const l=UO(o,t,e);if(l==null)return!1;s=new Wt(n.doc.resolve(l))}const a=DO(s.$headCell,t,e);return a?np(n,r,new Wt(s.$anchorCell,a)):!1}}function z8(t,e){const n=t.state.doc,r=El(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new Wt(r))),!0):!1}function V8(t,e,n){if(!Eo(t.state))return!1;let r=$8(n);const o=t.state.selection;if(o instanceof Wt){r||(r={width:1,height:1,rows:[Oe.from(Bb(or(t.state.schema).cell,n))]});const i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),a=fn.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=B8(r,a.right-a.left,a.bottom-a.top),jO(t.state,t.dispatch,s,a,r),!0}else if(r){const i=ep(t.state),s=i.start(-1);return jO(t.state,t.dispatch,s,fn.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function H8(t,e){var n;if(e.ctrlKey||e.metaKey)return;const r=qO(t,e.target);let o;if(e.shiftKey&&t.state.selection instanceof Wt)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=El(t.state.selection.$anchor))!=null&&((n=Fb(t,e))===null||n===void 0?void 0:n.pos)!=o.pos)i(o,e),e.preventDefault();else if(!r)return;function i(l,u){let f=Fb(t,u);const p=ys.getState(t.state)==null;if(!f||!Lb(l,f))if(p)f=l;else return;const m=new Wt(l,f);if(p||!t.state.selection.eq(m)){const b=t.state.tr.setSelection(m);p&&b.setMeta(ys,l.pos),t.dispatch(b)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",a),ys.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(ys,-1))}function a(l){const u=l,f=ys.getState(t.state);let p;if(f!=null)p=t.state.doc.resolve(f);else if(qO(t,u.target)!=r&&(p=Fb(t,e),!p))return s();p&&i(p,u)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",a)}function UO(t,e,n){if(!(t.state.selection instanceof Xe))return null;const{$head:r}=t.state.selection;for(let o=r.depth-1;o>=0;o--){const i=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const s=r.before(o),a=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(a)?s:null}}return null}function qO(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Fb(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;const r=n.inside>=0?n.inside:n.pos;return El(t.state.doc.resolve(r))}var W8=class{constructor(e,n){this.node=e,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")),Rb(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Rb(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Rb(t,e,n,r,o,i){let s=0,a=!0,l=e.firstChild;const u=t.firstChild;if(u){for(let p=0,m=0;p<u.childCount;p++){const{colspan:b,colwidth:v}=u.child(p).attrs;for(let y=0;y<b;y++,m++){const x=o==m?i:v&&v[y],S=x?x+"px":"";if(s+=x||r,x||(a=!1),l)l.style.width!=S&&(l.style.width=S),l=l.nextSibling;else{const k=document.createElement("col");k.style.width=S,e.appendChild(k)}}}for(;l;){var f;const p=l.nextSibling;(f=l.parentNode)===null||f===void 0||f.removeChild(l),l=p}a?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}const Lr=new On("tableColumnResizing");function KO({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=W8,lastColumnResizable:o=!0}={}){const i=new en({key:Lr,state:{init(s,a){var l;const u=(l=i.spec)===null||l===void 0||(l=l.props)===null||l===void 0?void 0:l.nodeViews,f=or(a.schema).table.name;return r&&u&&(u[f]=(p,m)=>new r(p,n,m)),new j8(-1,!1)},apply(s,a){return a.apply(s)}},props:{attributes:s=>{const a=Lr.getState(s);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,a)=>{U8(s,a,t,o)},mouseleave:s=>{q8(s)},mousedown:(s,a)=>{K8(s,a,e,n)}},decorations:s=>{const a=Lr.getState(s);if(a&&a.activeHandle>-1)return Z8(s,a.activeHandle)},nodeViews:{}}});return i}var j8=class xm{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Lr);if(r&&r.setHandle!=null)return new xm(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new xm(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let o=e.mapping.map(n.activeHandle,-1);return $b(e.doc.resolve(o))||(o=-1),new xm(o,n.dragging)}return n}};function U8(t,e,n,r){if(!t.editable)return;const o=Lr.getState(t.state);if(o&&!o.dragging){const i=G8(e.target);let s=-1;if(i){const{left:a,right:l}=i.getBoundingClientRect();e.clientX-a<=n?s=YO(t,e,"left",n):l-e.clientX<=n&&(s=YO(t,e,"right",n))}if(s!=o.activeHandle){if(!r&&s!==-1){const a=t.state.doc.resolve(s),l=a.node(-1),u=fn.get(l),f=a.start(-1);if(u.colCount(a.pos-f)+a.nodeAfter.attrs.colspan-1==u.width-1)return}JO(t,s)}}}function q8(t){if(!t.editable)return;const e=Lr.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&JO(t,-1)}function K8(t,e,n,r){var o;if(!t.editable)return!1;const i=(o=t.dom.ownerDocument.defaultView)!==null&&o!==void 0?o:window,s=Lr.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const a=t.state.doc.nodeAt(s.activeHandle),l=Y8(t,s.activeHandle,a.attrs);t.dispatch(t.state.tr.setMeta(Lr,{setDragging:{startX:e.clientX,startWidth:l}}));function u(p){i.removeEventListener("mouseup",u),i.removeEventListener("mousemove",f);const m=Lr.getState(t.state);m!=null&&m.dragging&&(J8(t,m.activeHandle,GO(m.dragging,p,n)),t.dispatch(t.state.tr.setMeta(Lr,{setDragging:null})))}function f(p){if(!p.which)return u(p);const m=Lr.getState(t.state);if(m&&m.dragging){const b=GO(m.dragging,p,n);XO(t,m.activeHandle,b,r)}}return XO(t,s.activeHandle,l,r),i.addEventListener("mouseup",u),i.addEventListener("mousemove",f),e.preventDefault(),!0}function Y8(t,e,{colspan:n,colwidth:r}){const o=r&&r[r.length-1];if(o)return o;const i=t.domAtPos(e);let s=i.node.childNodes[i.offset].offsetWidth,a=n;if(r)for(let l=0;l<n;l++)r[l]&&(s-=r[l],a--);return s/a}function G8(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function YO(t,e,n,r){const o=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+o,top:e.clientY});if(!i)return-1;const{pos:s}=i,a=El(t.state.doc.resolve(s));if(!a)return-1;if(n=="right")return a.pos;const l=fn.get(a.node(-1)),u=a.start(-1),f=l.map.indexOf(a.pos-u);return f%l.width==0?-1:u+l.map[f-1]}function GO(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function JO(t,e){t.dispatch(t.state.tr.setMeta(Lr,{setHandle:e}))}function J8(t,e,n){const r=t.state.doc.resolve(e),o=r.node(-1),i=fn.get(o),s=r.start(-1),a=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,l=t.state.tr;for(let u=0;u<i.height;u++){const f=u*i.width+a;if(u&&i.map[f]==i.map[f-i.width])continue;const p=i.map[f],m=o.nodeAt(p).attrs,b=m.colspan==1?0:a-i.colCount(p);if(m.colwidth&&m.colwidth[b]==n)continue;const v=m.colwidth?m.colwidth.slice():X8(m.colspan);v[b]=n,l.setNodeMarkup(s+p,null,{...m,colwidth:v})}l.docChanged&&t.dispatch(l)}function XO(t,e,n,r){const o=t.state.doc.resolve(e),i=o.node(-1),s=o.start(-1),a=fn.get(i).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1;let l=t.domAtPos(o.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&Rb(i,l.firstChild,l,r,a,n)}function X8(t){return Array(t).fill(0)}function Z8(t,e){const n=[],r=t.doc.resolve(e),o=r.node(-1);if(!o)return Jt.empty;const i=fn.get(o),s=r.start(-1),a=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let u=0;u<i.height;u++){const f=a+u*i.width;if((a==i.width-1||i.map[f]!=i.map[f+1])&&(u==0||i.map[f]!=i.map[f-i.width])){var l;const p=i.map[f],m=s+p+o.nodeAt(p).nodeSize-1,b=document.createElement("div");b.className="column-resize-handle",!((l=Lr.getState(t))===null||l===void 0)&&l.dragging&&n.push(Yn.node(s+p,s+p+o.nodeAt(p).nodeSize,{class:"column-resize-dragging"})),n.push(Yn.widget(m,b))}}return Jt.create(t.doc,n)}function ZO({allowTableNodeSelection:t=!1}={}){return new en({key:ys,state:{init(){return null},apply(e,n){const r=e.getMeta(ys);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:o,pos:i}=e.mapping.mapResult(n);return o?null:i}},props:{decorations:p8,handleDOMEvents:{mousedown:H8},createSelectionBetween(e){return ys.getState(e.state)!=null?e.state.selection:null},handleTripleClick:z8,handleKeyDown:R8,handlePaste:V8},appendTransaction(e,n,r){return g8(r,NO(r,n),t)}})}function zb(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function QO(t,e,n,r,o,i){var s;let a=0,l=!0,u=e.firstChild;const f=t.firstChild;if(f!==null)for(let p=0,m=0;p<f.childCount;p+=1){const{colspan:b,colwidth:v}=f.child(p).attrs;for(let y=0;y<b;y+=1,m+=1){const x=o===m?i:v&&v[y],S=x?`${x}px`:"";if(a+=x||r,x||(l=!1),u){if(u.style.width!==S){const[k,T]=zb(r,x);u.style.setProperty(k,T)}u=u.nextSibling}else{const k=document.createElement("col"),[T,C]=zb(r,x);k.style.setProperty(T,C),e.appendChild(k)}}}for(;u;){const p=u.nextSibling;(s=u.parentNode)===null||s===void 0||s.removeChild(u),u=p}l?(n.style.width=`${a}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${a}px`)}class Q8{constructor(e,n){this.node=e,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")),QO(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,QO(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function e7(t,e,n,r){let o=0,i=!0;const s=[],a=t.firstChild;if(!a)return{};for(let p=0,m=0;p<a.childCount;p+=1){const{colspan:b,colwidth:v}=a.child(p).attrs;for(let y=0;y<b;y+=1,m+=1){const x=n===m?r:v&&v[y];o+=x||e,x||(i=!1);const[S,k]=zb(e,x);s.push(["col",{style:`${S}: ${k}`}])}}const l=i?`${o}px`:"",u=i?"":`${o}px`;return{colgroup:["colgroup",{},...s],tableWidth:l,tableMinWidth:u}}function eM(t,e){return t.createAndFill()}function t7(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function n7(t,e,n,r,o){const i=t7(t),s=[],a=[];for(let u=0;u<n;u+=1){const f=eM(i.cell);if(f&&a.push(f),r){const p=eM(i.header_cell);p&&s.push(p)}}const l=[];for(let u=0;u<e;u+=1)l.push(i.row.createChecked(null,r&&u===0?s:a));return i.table.createChecked(null,l)}function r7(t){return t instanceof Wt}const ip=({editor:t})=>{const{selection:e}=t.state;if(!r7(e))return!1;let n=0;const r=qg(e.ranges[0].$from,i=>i.type.name==="table");return r==null||r.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},o7=tn.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:Q8,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:o}=e7(t,this.options.cellMinWidth),i=["table",Ct(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${o}`}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},i]:i},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:o,editor:i})=>{const s=n7(i.schema,t,e,n);if(o){const a=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(Xe.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>v8(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>x8(t,e),deleteColumn:()=>({state:t,dispatch:e})=>S8(t,e),addRowBefore:()=>({state:t,dispatch:e})=>T8(t,e),addRowAfter:()=>({state:t,dispatch:e})=>k8(t,e),deleteRow:()=>({state:t,dispatch:e})=>O8(t,e),deleteTable:()=>({state:t,dispatch:e})=>N8(t,e),mergeCells:()=>({state:t,dispatch:e})=>FO(t,e),splitCell:()=>({state:t,dispatch:e})=>RO(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>uu("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>uu("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>A8(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>FO(t,e)?!0:RO(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>I8(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>VO(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>VO(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&NO(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=Wt.create(e.doc,t.anchorCell,t.headCell);e.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:ip,"Mod-Backspace":ip,Delete:ip,"Mod-Delete":ip}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[KO({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],ZO({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:ft(Ue(t,"tableRole",e))}}}).extend({addProseMirrorPlugins(){return[...this.options.resizable?[KO({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],ZO({allowTableNodeSelection:this.options.allowTableNodeSelection})]}}),ha=Xt("FieldContainer",["root","outlined","standard","focused","disabled","notchedOutline"]),Vb=Ut("FieldContainer"),i7=oe(ab,{name:Vb,slot:"root",overridesResolver:(t,e)=>[e.root,t.ownerState.variant==="outlined"&&e.outlined,t.ownerState.variant==="standard"&&e.standard,t.ownerState.focused&&e.focused,t.ownerState.disabled&&e.disabled]})(({theme:t,ownerState:e})=>({...e.variant==="outlined"&&{borderRadius:t.shape.borderRadius,padding:1,position:"relative",...!e.focused&&!e.disabled&&{[`&:hover .${ha.notchedOutline}`]:{borderColor:t.palette.text.primary}}}})),s7=oe("div",{name:Vb,slot:"notchedOutline",overridesResolver:(t,e)=>e.notchedOutline})(({theme:t,ownerState:e})=>({position:"absolute",inset:0,borderRadius:"inherit",borderColor:t.palette.mode==="light"?"rgba(0, 0, 0, 0.23)":"rgba(255, 255, 255, 0.23)",borderStyle:"solid",borderWidth:1,pointerEvents:"none",overflow:"hidden",zIndex:xf.NOTCHED_OUTLINE,...e.focused&&{borderColor:t.palette.primary.main,borderWidth:2},...e.disabled&&{borderColor:t.palette.action.disabled}}));function a7(t){const e=rt({props:t,name:Vb}),{variant:n="outlined",children:r,focused:o,disabled:i,classes:s={},className:a,sx:l,...u}=e,f={variant:n,focused:o,disabled:i};return g.jsxs(i7,{...u,className:ge([ha.root,a,s.root,n==="outlined"?[ha.outlined,s.outlined]:[ha.standard,s.standard],o&&[ha.focused,s.focused],i&&[ha.disabled,s.disabled]]),sx:l,ownerState:f,children:[r,n==="outlined"&&g.jsx(s7,{ownerState:f,className:ge([ha.notchedOutline,s.notchedOutline]),"aria-hidden":!0})]})}function tM({editor:t,wait:e=250}){const[n,r]=J.useState(!!(t!=null&&t.isFocused)),o=J.useMemo(()=>IE(i=>{r(i)},e),[e]);return J.useEffect(()=>{const i=!!(t!=null&&t.isFocused);return o(i),i&&o.flush(),()=>{o.cancel()}},[t==null?void 0:t.isFocused,o]),n}function nM(t,e){const n=J.useRef(e);J.useEffect(()=>{n.current=e},[e]),J.useEffect(()=>{function r(o){t===o.key&&n.current(o)}return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[t])}function l7(t){return Ke("MuiDialogActions",t)}je("MuiDialogActions",["root","spacing"]);const c7=t=>{const{classes:e,disableSpacing:n}=t;return qe({root:["root",!n&&"spacing"]},l7,e)},u7=oe("div",{name:"MuiDialogActions",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,!n.disableSpacing&&e.spacing]}})({display:"flex",alignItems:"center",padding:8,justifyContent:"flex-end",flex:"0 0 auto",variants:[{props:({ownerState:t})=>!t.disableSpacing,style:{"& > :not(style) ~ :not(style)":{marginLeft:8}}}]}),sp=A.forwardRef(function(e,n){const r=mt({props:e,name:"MuiDialogActions"}),{className:o,disableSpacing:i=!1,...s}=r,a={...r,disableSpacing:i},l=c7(a);return g.jsx(u7,{className:ge(l.root,o),ownerState:a,ref:n,...s})});process.env.NODE_ENV!=="production"&&(sp.propTypes={children:c.node,classes:c.object,className:c.string,disableSpacing:c.bool,sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object])});function d7({editor:t,onCancel:e,onSave:n,labels:r,formatHref:o=_6}){var i,s,a,l,u,f;const p=t.isActive("link")?t.getAttributes("link").href:"",m=Oc(t.state.selection.$from,So("link",t.schema)),b=m?t.state.doc.textBetween(m.from,m.to):"",v=t.state.doc.textBetween(t.state.selection.$from.pos,t.state.selection.$to.pos),y=b||v,[x,S]=J.useState(y),[k,T]=J.useState(p),C=J.useRef(null),O=J.useRef(null),I=!p,N=(i=r==null?void 0:r.editLinkAddTitle)!==null&&i!==void 0?i:"Add link",L=(s=r==null?void 0:r.editLinkEditTitle)!==null&&s!==void 0?s:"Edit link",V=I?N:L;J.useEffect(()=>{var F,P;!I||!y?(F=C.current)===null||F===void 0||F.focus({preventScroll:!0}):(P=O.current)===null||P===void 0||P.focus({preventScroll:!0})},[I,y]),nM("Escape",e);function M(){O.current&&T(o(O.current.value))}const[B,H]=J.useState(!1);return g.jsxs("form",{onSubmit:F=>{var P,_,D,R;F.preventDefault(),F.stopPropagation(),H(!0);const j=(_=(P=C.current)===null||P===void 0?void 0:P.value)!==null&&_!==void 0?_:"",K=(R=(D=O.current)===null||D===void 0?void 0:D.value)!==null&&R!==void 0?R:"";n({text:j,link:K}),H(!1)},autoComplete:"off",children:[g.jsx(ko,{variant:"h6",children:V}),g.jsx(Xc,{inputRef:C,value:x,disabled:B,onChange:F=>{S(F.target.value)},label:(a=r==null?void 0:r.editLinkTextInputLabel)!==null&&a!==void 0?a:"Text",margin:"normal",size:"small",fullWidth:!0,required:!0}),g.jsx(Xc,{inputRef:O,value:k,onChange:F=>{T(F.target.value)},disabled:B,label:(l=r==null?void 0:r.editLinkHrefInputLabel)!==null&&l!==void 0?l:"Link",margin:"dense",size:"small",type:"text",onBlur:M,onKeyDown:F=>{F.key==="Enter"&&M()},fullWidth:!0,required:!0}),g.jsxs(sp,{sx:{px:0},children:[g.jsx(no,{onClick:e,variant:"outlined",size:"small",children:(u=r==null?void 0:r.editLinkCancelButtonLabel)!==null&&u!==void 0?u:"Cancel"}),g.jsx(no,{type:"submit",color:"primary",variant:"outlined",size:"small",disabled:B,children:(f=r==null?void 0:r.editLinkSaveButtonLabel)!==null&&f!==void 0?f:"Save"})]})]})}const Hb=Xt("LinkBubbleMenu",["root","paper","content"]);function f7(t){return Ke("MuiLink",t)}const p7=je("MuiLink",["root","underlineNone","underlineHover","underlineAlways","button","focusVisible"]),h7=({theme:t,ownerState:e})=>{const n=e.color,r=qi(t,`palette.${n}.main`,!1)||qi(t,`palette.${n}`,!1)||e.color,o=qi(t,`palette.${n}.mainChannel`)||qi(t,`palette.${n}Channel`);return"vars"in t&&o?`rgba(${o} / 0.4)`:it(r,.4)},rM={primary:!0,secondary:!0,error:!0,info:!0,success:!0,warning:!0,textPrimary:!0,textSecondary:!0,textDisabled:!0},m7=t=>{const{classes:e,component:n,focusVisible:r,underline:o}=t,i={root:["root",`underline${Ne(o)}`,n==="button"&&"button",r&&"focusVisible"]};return qe(i,f7,e)},g7=oe(ko,{name:"MuiLink",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,e[`underline${Ne(n.underline)}`],n.component==="button"&&e.button]}})(bt(({theme:t})=>({variants:[{props:{underline:"none"},style:{textDecoration:"none"}},{props:{underline:"hover"},style:{textDecoration:"none","&:hover":{textDecoration:"underline"}}},{props:{underline:"always"},style:{textDecoration:"underline","&:hover":{textDecorationColor:"inherit"}}},{props:({underline:e,ownerState:n})=>e==="always"&&n.color!=="inherit",style:{textDecorationColor:"var(--Link-underlineColor)"}},...Object.entries(t.palette).filter(Hn()).map(([e])=>({props:{underline:"always",color:e},style:{"--Link-underlineColor":t.vars?`rgba(${t.vars.palette[e].mainChannel} / 0.4)`:it(t.palette[e].main,.4)}})),{props:{underline:"always",color:"textPrimary"},style:{"--Link-underlineColor":t.vars?`rgba(${t.vars.palette.text.primaryChannel} / 0.4)`:it(t.palette.text.primary,.4)}},{props:{underline:"always",color:"textSecondary"},style:{"--Link-underlineColor":t.vars?`rgba(${t.vars.palette.text.secondaryChannel} / 0.4)`:it(t.palette.text.secondary,.4)}},{props:{underline:"always",color:"textDisabled"},style:{"--Link-underlineColor":(t.vars||t).palette.text.disabled}},{props:{component:"button"},style:{position:"relative",WebkitTapHighlightColor:"transparent",backgroundColor:"transparent",outline:0,border:0,margin:0,borderRadius:0,padding:0,cursor:"pointer",userSelect:"none",verticalAlign:"middle",MozAppearance:"none",WebkitAppearance:"none","&::-moz-focus-inner":{borderStyle:"none"},[`&.${p7.focusVisible}`]:{outline:"auto"}}}]}))),oM=A.forwardRef(function(e,n){const r=mt({props:e,name:"MuiLink"}),o=wo(),{className:i,color:s="primary",component:a="a",onBlur:l,onFocus:u,TypographyClasses:f,underline:p="always",variant:m="inherit",sx:b,...v}=r,[y,x]=A.useState(!1),S=O=>{Fa(O.target)||x(!1),l&&l(O)},k=O=>{Fa(O.target)&&x(!0),u&&u(O)},T={...r,color:s,component:a,focusVisible:y,underline:p,variant:m},C=m7(T);return g.jsx(g7,{color:s,className:ge(C.root,i),classes:f,component:a,onBlur:S,onFocus:k,ref:n,ownerState:T,variant:m,...v,sx:[...rM[s]===void 0?[{color:s}]:[],...Array.isArray(b)?b:[b]],style:{...v.style,...p==="always"&&s!=="inherit"&&!rM[s]&&{"--Link-underlineColor":h7({theme:o,ownerState:T})}}})});process.env.NODE_ENV!=="production"&&(oM.propTypes={children:c.node,classes:c.object,className:c.string,color:c.oneOfType([c.oneOf(["primary","secondary","success","error","info","warning","textPrimary","textSecondary","textDisabled"]),c.string]),component:Ba,onBlur:c.func,onFocus:c.func,style:c.object,sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object]),TypographyClasses:c.object,underline:c.oneOf(["always","hover","none"]),variant:c.oneOfType([c.oneOf(["body1","body2","button","caption","h1","h2","h3","h4","h5","h6","inherit","overline","subtitle1","subtitle2"]),c.string])});var Wb={},jb={},iM;function y7(){return iM||(iM=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n!==null&&(typeof n=="object"||typeof n=="function")}t.isObject=e})(jb)),jb}var sM;function b7(){return sM||(sM=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=y7(),n=/[\u200d\ud800-\udfff\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff\ufe0e\ufe0f]/;function r(i,s){i=i!=null?`${i}`:"";let a=30,l="...";e.isObject(s)&&(a=o(s.length),l="omission"in s?`${s.omission}`:"...");let u=i.length;const f=Array.from(l).length,p=Math.max(a-f,0);let m;if(n.test(i)&&(m=Array.from(i),u=m.length),a>=u)return i;if(u<=f)return l;let v=m===void 0?i.slice(0,p):m==null?void 0:m.slice(0,p).join("");const y=s==null?void 0:s.separator;if(!y)return v+=l,v;const x=y instanceof RegExp?y.source:y,S="u"+(y instanceof RegExp?y.flags.replace("u",""):""),k=new RegExp(`(?<result>.*(?:(?!${x}).))(?:${x})`,S).exec(v);return(k!=null&&k.groups?k.groups.result:v)+l}function o(i){return i==null?30:i<=0?0:i}t.truncate=r})(Wb)),Wb}var Ub,aM;function v7(){return aM||(aM=1,Ub=b7().truncate),Ub}var x7=v7();const w7=Un(x7),qb=Xt("ViewLinkMenuContent",["root","linkPreviewText"]),Kb=Ut("ViewLinkMenuContent"),S7=oe("div",{name:Kb,slot:"root",overridesResolver:(t,e)=>e.root})({}),lM=oe("div",{name:Kb,slot:"linkPreviewText",overridesResolver:(t,e)=>e.linkPreviewText})({overflowWrap:"anywhere"});function C7(t){var e,n,r;const o=rt({props:t,name:Kb}),{editor:i,onCancel:s,onEdit:a,onRemove:l,labels:u,classes:f={},sx:p}=o,m=Oc(i.state.selection.$to,So("link",i.schema)),b=m?i.state.doc.textBetween(m.from,m.to):"",v=(e=i.getAttributes("link").href)!==null&&e!==void 0?e:"";return nM("Escape",s),g.jsxs(S7,{className:ge([qb.root,f.root]),sx:p,children:[g.jsx(lM,{className:ge([qb.linkPreviewText,f.linkPreviewText]),children:w7(b,{length:50,omission:"…"})}),g.jsx(lM,{className:ge([qb.linkPreviewText,f.linkPreviewText]),children:g.jsx(oM,{href:v,target:"_blank",rel:"noopener",children:D6(v,50)})}),g.jsxs(sp,{sx:{px:0},children:[g.jsx(no,{onClick:a,color:"primary",variant:"outlined",size:"small",children:(n=u==null?void 0:u.viewLinkEditButtonLabel)!==null&&n!==void 0?n:"Edit"}),g.jsx(no,{onClick:l,color:"error",variant:"outlined",size:"small",children:(r=u==null?void 0:u.viewLinkRemoveButtonLabel)!==null&&r!==void 0?r:"Remove"})]})]})}const cM=Ut("LinkBubbleMenu"),T7=oe("div",{name:cM,slot:"content",overridesResolver:(t,e)=>e.content})(({theme:t})=>({padding:t.spacing(1.5,2,.5)}));function k7(t){const e=rt({props:t,name:cM}),{labels:n,formatHref:r,classes:o={},sx:i,...s}=e,a=Tt();if(!(a!=null&&a.isEditable))return null;if(!("linkBubbleMenuHandler"in a.storage))throw new Error("You must add the LinkBubbleMenuHandler extension to the useEditor `extensions` array in order to use this component!");const l=a.storage.linkBubbleMenuHandler,u=l.state;let f=null;return u===fr.VIEW_LINK_DETAILS?f=g.jsx(C7,{editor:a,onCancel:a.commands.closeLinkBubbleMenu,onEdit:a.commands.editLinkInBubbleMenu,onRemove:()=>{a.chain().unsetLink().setTextSelection(a.state.selection.to).focus().run()},labels:n}):u===fr.EDIT_LINK&&(f=g.jsx(d7,{editor:a,onCancel:a.commands.closeLinkBubbleMenu,onSave:({text:p,link:m})=>{a.chain().extendMarkRange("link").insertContent({type:"text",marks:[{type:"link",attrs:{href:m}}],text:p}).setLink({href:m}).focus().run(),a.commands.closeLinkBubbleMenu()},labels:n,formatHref:r})),g.jsx(Sy,{editor:a,open:u!==fr.HIDDEN,...l.bubbleMenuOptions,...s,classes:{root:ge([Hb.root,o.root]),paper:ge([Hb.paper,o.paper])},sx:i,children:g.jsx(T7,{className:ge([Hb.content,o.content]),children:f})})}function E7(t){return Ke("MuiCollapse",t)}je("MuiCollapse",["root","horizontal","vertical","entered","hidden","wrapper","wrapperInner"]);const O7=t=>{const{orientation:e,classes:n}=t,r={root:["root",`${e}`],entered:["entered"],hidden:["hidden"],wrapper:["wrapper",`${e}`],wrapperInner:["wrapperInner",`${e}`]};return qe(r,E7,n)},M7=oe("div",{name:"MuiCollapse",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,e[n.orientation],n.state==="entered"&&e.entered,n.state==="exited"&&!n.in&&n.collapsedSize==="0px"&&e.hidden]}})(bt(({theme:t})=>({height:0,overflow:"hidden",transition:t.transitions.create("height"),variants:[{props:{orientation:"horizontal"},style:{height:"auto",width:0,transition:t.transitions.create("width")}},{props:{state:"entered"},style:{height:"auto",overflow:"visible"}},{props:{state:"entered",orientation:"horizontal"},style:{width:"auto"}},{props:({ownerState:e})=>e.state==="exited"&&!e.in&&e.collapsedSize==="0px",style:{visibility:"hidden"}}]}))),_7=oe("div",{name:"MuiCollapse",slot:"Wrapper",overridesResolver:(t,e)=>e.wrapper})({display:"flex",width:"100%",variants:[{props:{orientation:"horizontal"},style:{width:"auto",height:"100%"}}]}),I7=oe("div",{name:"MuiCollapse",slot:"WrapperInner",overridesResolver:(t,e)=>e.wrapperInner})({width:"100%",variants:[{props:{orientation:"horizontal"},style:{width:"auto",height:"100%"}}]}),ap=A.forwardRef(function(e,n){const r=mt({props:e,name:"MuiCollapse"}),{addEndListener:o,children:i,className:s,collapsedSize:a="0px",component:l,easing:u,in:f,onEnter:p,onEntered:m,onEntering:b,onExit:v,onExited:y,onExiting:x,orientation:S="vertical",style:k,timeout:T=nw.standard,TransitionComponent:C=Pr,...O}=r,I={...r,orientation:S,collapsedSize:a},N=O7(I),L=wo(),V=$s(),M=A.useRef(null),B=A.useRef(),H=typeof a=="number"?`${a}px`:a,F=S==="horizontal",P=F?"width":"height",_=A.useRef(null),D=Ot(n,_),R=te=>ce=>{if(te){const ne=_.current;ce===void 0?te(ne):te(ne,ce)}},j=()=>M.current?M.current[F?"clientWidth":"clientHeight"]:0,K=R((te,ce)=>{M.current&&F&&(M.current.style.position="absolute"),te.style[P]=H,p&&p(te,ce)}),U=R((te,ce)=>{const ne=j();M.current&&F&&(M.current.style.position="");const{duration:re,easing:le}=ul({style:k,timeout:T,easing:u},{mode:"enter"});if(T==="auto"){const ye=L.transitions.getAutoHeightDuration(ne);te.style.transitionDuration=`${ye}ms`,B.current=ye}else te.style.transitionDuration=typeof re=="string"?re:`${re}ms`;te.style[P]=`${ne}px`,te.style.transitionTimingFunction=le,b&&b(te,ce)}),Y=R((te,ce)=>{te.style[P]="auto",m&&m(te,ce)}),fe=R(te=>{te.style[P]=`${j()}px`,v&&v(te)}),ue=R(y),pe=R(te=>{const ce=j(),{duration:ne,easing:re}=ul({style:k,timeout:T,easing:u},{mode:"exit"});if(T==="auto"){const le=L.transitions.getAutoHeightDuration(ce);te.style.transitionDuration=`${le}ms`,B.current=le}else te.style.transitionDuration=typeof ne=="string"?ne:`${ne}ms`;te.style[P]=H,te.style.transitionTimingFunction=re,x&&x(te)}),Z=te=>{T==="auto"&&V.start(B.current||0,te),o&&o(_.current,te)};return g.jsx(C,{in:f,onEnter:K,onEntered:Y,onEntering:U,onExit:fe,onExited:ue,onExiting:pe,addEndListener:Z,nodeRef:_,timeout:T==="auto"?null:T,...O,children:(te,{ownerState:ce,...ne})=>g.jsx(M7,{as:l,className:ge(N.root,s,{entered:N.entered,exited:!f&&H==="0px"&&N.hidden}[te]),style:{[F?"minWidth":"minHeight"]:H,...k},ref:D,ownerState:{...I,state:te},...ne,children:g.jsx(_7,{ownerState:{...I,state:te},className:N.wrapper,ref:M,children:g.jsx(I7,{ownerState:{...I,state:te},className:N.wrapperInner,children:i})})})})});process.env.NODE_ENV!=="production"&&(ap.propTypes={addEndListener:c.func,children:c.node,classes:c.object,className:c.string,collapsedSize:c.oneOfType([c.number,c.string]),component:Ba,easing:c.oneOfType([c.shape({enter:c.string,exit:c.string}),c.string]),in:c.bool,onEnter:c.func,onEntered:c.func,onEntering:c.func,onExit:c.func,onExited:c.func,onExiting:c.func,orientation:c.oneOf(["horizontal","vertical"]),style:c.object,sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object]),timeout:c.oneOfType([c.oneOf(["auto"]),c.number,c.shape({appear:c.number,enter:c.number,exit:c.number})])}),ap&&(ap.muiSupportAuto=!0);const lp=Xt("MenuBar",["root","sticky","nonSticky","content"]),Yb=Ut("MenuBar"),D7=oe(ap,{name:Yb,slot:"root",overridesResolver:(t,e)=>[e.root,t.ownerState.disableSticky?e.nonSticky:e.sticky]})(({theme:t,ownerState:e})=>({borderBottomColor:t.palette.divider,borderBottomStyle:"solid",borderBottomWidth:1,...e.disableSticky?{}:{position:"sticky",top:e.stickyOffset,zIndex:xf.MENU_BAR,background:t.palette.background.default}})),A7=oe("div",{name:Yb,slot:"content",overridesResolver:(t,e)=>e.content})({});function P7(t){const e=rt({props:t,name:Yb}),{hide:n,disableSticky:r,stickyOffset:o=0,children:i,className:s,classes:a={},unmountOnExit:l=!0,sx:u,...f}=e,p={hide:n,disableSticky:r,stickyOffset:o,unmountOnExit:l};return g.jsx(D7,{...f,in:!n,unmountOnExit:l,className:ge([lp.root,a.root,r?[lp.nonSticky,a.nonSticky]:[lp.sticky,a.sticky],s]),ownerState:p,sx:u,children:g.jsx(A7,{className:ge([lp.content,a.content]),ownerState:p,children:i})})}const Gb=Xt("RichTextContent",["root","readonly","editable"]),uM=Ut("RichTextContent"),N7=oe(x9,{name:uM,slot:"root",overridesResolver:(t,e)=>[e.root,t.ownerState.editable?e.editable:e.readonly]})(({theme:t,ownerState:e})=>e.disableDefaultStyles?{}:{"& .ProseMirror":{...ca(t)}});function dM(t){const e=rt({props:t,name:uM}),{innerRef:n,className:r,classes:o={},disableDefaultStyles:i=!1,sx:s}=e,a=Tt(),l=!!(a!=null&&a.isEditable),u={editable:l,disableDefaultStyles:i},f=J.useMemo(()=>ge([Gb.root,r,o.root,l?[Gb.editable,o.editable]:[Gb.readonly,o.readonly]]),[r,o.root,o.editable,o.readonly,l]);return g.jsx(N7,{editor:a,...n?{innerRef:n}:{},ownerState:u,className:f,sx:s})}function fM({editor:t,children:e}){return g.jsx(qT.Provider,{value:t,children:e})}const Yo=Xt("RichTextField",["root","standard","outlined","menuBar","menuBarContent","content"]),pM=Ut("RichTextField"),$7=oe(a7,{name:pM,slot:"root",overridesResolver:(t,e)=>[e.root,t.ownerState.variant==="outlined"&&e.outlined,t.ownerState.variant==="standard"&&e.standard]})(({theme:t,ownerState:e})=>({...e.variant==="standard"&&{[`& .${Yo.content}`]:{padding:t.spacing(1.5,0)},[`& .${Yo.menuBarContent}`]:{padding:t.spacing(1,0)}},...e.variant==="outlined"&&{[`& .${Yo.content}`]:{padding:t.spacing(1.5)},[`& .${Yo.menuBarContent}`]:{padding:t.spacing(1,1.5)}}}));function L7(t){var e,n;const r=rt({props:t,name:pM}),{variant:o="outlined",controls:i,disableDebounceRenderControls:s=!1,disabled:a,className:l,classes:u={},footer:f,MenuBarProps:p,RichTextContentProps:m,sx:b,...v}=r,y=Tt(),x={variant:o,disabled:a,disableDebounceRenderControls:s},S=tM({editor:y});return g.jsxs($7,{...v,variant:o,focused:!a&&S,disabled:a,className:ge([Yo.root,u.root,o==="outlined"?[Yo.outlined,u.outlined]:[Yo.standard,u.standard],l]),ownerState:x,sx:b,children:[i&&g.jsx(P7,{...p,classes:{...p==null?void 0:p.classes,root:ge([Yo.menuBar,u.menuBar,(e=p==null?void 0:p.classes)===null||e===void 0?void 0:e.root]),content:ge([Yo.menuBarContent,u.menuBarContent,(n=p==null?void 0:p.classes)===null||n===void 0?void 0:n.content])},children:s?i:g.jsx(ob,{children:i})}),g.jsx(dM,{...m,className:ge([Yo.content,u.content,m==null?void 0:m.className])}),f]})}const hM=J.forwardRef(function({className:e,renderControls:n,RichTextFieldProps:r={},sx:o,children:i,editorDependencies:s=[],editable:a=!0,shouldRerenderOnTransaction:l=!0,...u},f){const p={editable:a,shouldRerenderOnTransaction:l,...u},m=SO(p,s);return J.useImperativeHandle(f,()=>({editor:m}),[m]),J.useEffect(()=>{!m||m.isDestroyed||m.isEditable===a||queueMicrotask(()=>{m.setEditable(a)})},[a,m]),g.jsxs(fM,{editor:m,children:[g.jsx(L7,{disabled:!a,controls:n==null?void 0:n(m),className:e,sx:o,...r}),i==null?void 0:i(m)]})});function B7({RichTextContentProps:t,sx:e,...n}){const r=SO({...n,editable:!1}),o=J.useRef(n.content);return J.useEffect(()=>{!r||r.isDestroyed||n.content===void 0||n.content===o.current||queueMicrotask(()=>{n.content!==void 0&&r.commands.setContent(n.content)})},[n.content,r]),J.useEffect(()=>{o.current=n.content},[n.content]),g.jsx(fM,{editor:r,children:g.jsx(dM,{sx:e,...t})})}function mM(t){return t.content?g.jsx(B7,{...t}):null}const Jb=Xt("TableBubbleMenu",["root","paper","content"]),gM=Ut("TableBubbleMenu"),F7=oe(Lj,{name:gM,slot:"content",overridesResolver:(t,e)=>e.content})(({theme:t})=>({maxWidth:"90vw",padding:t.spacing(.5,1)}));function R7(t){const e=rt({props:t,name:gM}),{disableDebounce:n=!1,DebounceProps:r,labels:o,classes:i={},...s}=e,a=Tt(),l=tM({editor:a}),u=J.useMemo(()=>a?{getBoundingClientRect:()=>{const p=a.isActive("table")?qg(a.state.selection.$anchor,y=>y.type.name==="table"):null;if(p){const y=a.view.nodeDOM(p.pos),x=y==null?void 0:y.querySelector("table");if(x)return x.getBoundingClientRect()}const{ranges:m}=a.state.selection,b=Math.min(...m.map(y=>y.$from.pos)),v=Math.max(...m.map(y=>y.$to.pos));return aT(a.view,b,v)}}:null,[a]);if(!(a!=null&&a.isEditable))return null;const f=g.jsx(F7,{className:ge([Jb.content,i.content]),labels:o});return g.jsx(Sy,{editor:a,open:l&&a.isActive("table"),anchorEl:u,placement:"top-start",fallbackPlacements:["bottom-start","top","bottom","top-end","bottom-end"],flipPadding:{top:35,left:8,right:8,bottom:-1/0},...s,classes:{root:ge([Jb.root,i.root]),paper:ge([Jb.paper,i.paper])},children:n?f:g.jsx(ob,{...r,children:f})})}const Xb=vr.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",Ct(this.options.HTMLAttributes,t),0]},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),yM=vr.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",Ct(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});var Zb,bM;function z7(){return bM||(bM=1,Zb=(function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(r,o,i){n.o(r,o)||Object.defineProperty(r,o,{configurable:!1,enumerable:!0,get:i})},n.r=function(r){Object.defineProperty(r,"__esModule",{value:!0})},n.n=function(r){var o=r&&r.__esModule?function(){return r.default}:function(){return r};return n.d(o,"a",o),o},n.o=function(r,o){return Object.prototype.hasOwnProperty.call(r,o)},n.p="/dist/",n(n.s=1)})([function(t,e,n){n.r(e);var r={equal:0,delete:1,insert:2,none:3,replace:4};class o{constructor(P,_,D){this.startInOld=P,this.startInNew=_,this.size=D}get endInOld(){return this.startInOld+this.size}get endInNew(){return this.startInNew+this.size}}class i{constructor(){this.blockSize=0,this.repeatingWordsAccuracy=0,this.ignoreWhitespaceDifferences=!1}}const s=/^\s*<\/?[^>]+>\s*$/,a=/<[^\s>]+/,l=/^(\s|&nbsp;)+$/,u=/[\w\#@]+/,f=["<img"];function p(F){return!f.some(P=>F!==null&&F.startsWith(P))&&s.test(F)}function m(F,P,_){return["<",P,' class="',_,'">',F,"</",P,">"].join("")}function b(F){return F==="<"}function v(F){return F==="&"}function y(F){return F===";"}function x(F){return l.test(F)}function S(F){return p(F)?(function(P){return P=a.exec(P)[0]+(P.endsWith("/>")?"/>":">")})(F):F}function k(F){return u.test(F)}function T(F,P,_){return F.push(P),F.length>_&&F.shift(),F.length!==_?null:F.join("")}class C{constructor(P,_,D,R,j,K,U){this.oldWords=P,this.newWords=_,this.startInOld=D,this.endInOld=R,this.startInNew=j,this.endInNew=K,this.options=U}indexNewWords(){this.wordIndices=new Map;let P=[];for(let _=this.startInNew;_<this.endInNew;_++){let D=T(P,this.normalizeForIndex(this.newWords[_]),this.options.blockSize);D!==null&&(this.wordIndices.has(D)?this.wordIndices.get(D).push(_):this.wordIndices.set(D,[_]))}}normalizeForIndex(P){return P=S(P),this.options.IgnoreWhiteSpaceDifferences&&x(P)?" ":P}findMatch(){if(this.indexNewWords(),this.removeRepeatingWords(),this.wordIndices.length===0)return null;let P=this.startInOld,_=this.startInNew,D=0,R=new Map;const j=this.options.blockSize;let K=[];for(let U=this.startInOld;U<this.endInOld;U++){let Y=T(K,this.normalizeForIndex(this.oldWords[U]),j);if(Y===null)continue;let fe=new Map;if(this.wordIndices.has(Y)){for(let ue of this.wordIndices.get(Y)){let pe=(R.has(ue-1)?R.get(ue-1):0)+1;fe.set(ue,pe),pe>D&&(P=U-pe-j+2,_=ue-pe-j+2,D=pe)}R=fe}else R=fe}return D!==0?new o(P,_,D+j-1):null}removeRepeatingWords(){let P=this.newWords.length+this.options.repeatingWordsAccuracy,_=Array.from(this.wordIndices.entries()).filter(D=>D[1].length>P).map(D=>D[0]);for(let D of _)this.wordIndices.delete(D)}}class O{constructor(P,_,D,R,j){this.action=P,this.startInOld=_,this.endInOld=D,this.startInNew=R,this.endInNew=j}}var I={character:0,tag:1,whitespace:2,entity:3};function N(F,P){let _={mode:I.character,currentWord:[],words:[]},D=(function(Y,fe){let ue=new Map;if(fe===null)return ue;for(let pe of fe){let Z;for(;(Z=pe.exec(Y))!==null;){if(ue.has(Z.index))throw new Error("One or more block expressions result in a text sequence that overlaps. Current expression: "+pe.toString());ue.set(Z.index,Z.index+Z[0].length)}}return ue})(F,P),R=!!D.size,j=!1,K=-1;for(let Y=0;Y<F.length;Y++){var U=F[Y];if(R&&(K===index&&(K=-1,j=!1),D.has(index)&&(j=!0,K=D.get(index)),j)){_.currentWord.push(U),_.mode=I.character;continue}switch(_.mode){case I.character:b(U)?L(_,"<",I.tag):v(U)?L(_,U,I.entity):x(U)?L(_,U,I.whitespace):k(U)&&(_.currentWord.length===0||k(_.currentWord[_.currentWord.length-1]))?_.currentWord.push(U):L(_,U,I.character);break;case I.tag:U===">"?(_.currentWord.push(U),_.words.push(_.currentWord.join("")),_.currentWord=[],_.mode=x(U)?I.whitespace:I.character):_.currentWord.push(U);break;case I.whitespace:b(U)?L(_,U,I.tag):v(U)?L(_,U,I.entity):x(U)?_.currentWord.push(U):L(_,U,I.character);break;case I.entity:if(b(U))L(_,U,I.tag);else if(x(U))L(_,U,I.whitespace);else if(y(U)){let fe=!0;if(_.currentWord.length!==0&&(_.currentWord.push(U),_.words.push(_.currentWord.join("")),_.words.length>2&&x(_.words[_.words.length-2])&&x(_.words[_.words.length-1]))){let ue=_.words[_.words.length-2],pe=_.words[_.words.length-1];_.words.splice(_.words.length-2,2),_.currentWord=[(ue+pe).split()],_.mode=I.whitespace,fe=!1}fe&&(_.currentWord=[],_.mode=I.character)}else k(U)?_.currentWord.push(U):L(_,U,I.character)}}return _.currentWord.length!==0&&_.words.push(_.currentWord.join("")),_.words}function L(F,P,_){F.currentWord.length!==0&&F.words.push(F.currentWord.join("")),F.currentWord=[P],F.mode=_}const V=4,M=new Map([["</strong>",0],["</em>",0],["</b>",0],["</i>",0],["</big>",0],["</small>",0],["</u>",0],["</sub>",0],["</strike>",0],["</s>",0]]),B=/<((strong)|(b)|(i)|(em)|(big)|(small)|(u)|(sub)|(sup)|(strike)|(s))[\>\s]+/gi;class H{constructor(P,_){this.content=[],this.newText=_,this.oldText=P,this.specialTagDiffStack=[],this.newWords=[],this.oldWords=[],this.matchGranularity=0,this.blockExpressions=[],this.repeatingWordsAccuracy=1,this.ignoreWhiteSpaceDifferences=!1,this.orphanMatchThreshold=0}build(){if(this.oldText===this.newText)return this.newText;this.splitInputsIntoWords(),this.matchGranularity=Math.min(V,this.oldWords.length,this.newWords.length);let P=this.operations();for(let _ of P)this.performOperation(_);return this.content.join("")}addBlockExpression(P){this.blockExpressions.push(P)}splitInputsIntoWords(){this.oldWords=N(this.oldText,this.blockExpressions),this.oldText=null,this.newWords=N(this.newText,this.blockExpressions),this.newText=null}performOperation(P){switch(P.action){case r.equal:this.processEqualOperation(P);break;case r.delete:this.processDeleteOperation(P,"diffdel");break;case r.insert:this.processInsertOperation(P,"diffins");break;case r.none:break;case r.replace:this.processReplaceOperation(P)}}processReplaceOperation(P){this.processDeleteOperation(P,"diffmod"),this.processInsertOperation(P,"diffmod")}processInsertOperation(P,_){let D=this.newWords.filter((R,j)=>j>=P.startInNew&&j<P.endInNew);this.insertTag("ins",_,D)}processDeleteOperation(P,_){let D=this.oldWords.filter((R,j)=>j>=P.startInOld&&j<P.endInOld);this.insertTag("del",_,D)}processEqualOperation(P){let _=this.newWords.filter((D,R)=>R>=P.startInNew&&R<P.endInNew);this.content.push(_.join(""))}insertTag(P,_,D){for(;D.length;){let R=this.extractConsecutiveWords(D,U=>!p(U)),j="",K=!1;if(R.length!==0){let U=m(R.join(""),P,_);this.content.push(U)}else{if(B.test(D[0])){if(this.specialTagDiffStack.push(D[0]),j='<ins class="mod">',P==="del")for(D.shift();D.length>0&&B.test(D[0]);)D.shift()}else if(M.has(D[0])){let U=this.specialTagDiffStack.length===0?null:this.specialTagDiffStack.pop();if(U!==null&&U===D[0].replace(/\//g,"")&&(j="</ins>",K=!0),P==="del")for(D.shift();D.length>0&&M.has(D[0]);)D.shift()}if(D.length===0&&j.length===0)break;K?this.content.push(j+this.extractConsecutiveWords(D,p).join("")):this.content.push(this.extractConsecutiveWords(D,p).join("")+j)}}}extractConsecutiveWords(P,_){let D=null;for(let R=0;R<P.length;R++){let j=P[R];if(R===0&&j===" "&&(P[R]="&nbsp;"),!_(j)){D=R;break}}if(D!==null){let R=P.filter((j,K)=>K>=0&&K<D);return D>0&&P.splice(0,D),R}{let R=P.filter((j,K)=>K>=0&&K<P.length);return P.splice(0,P.length),R}}operations(){let P=0,_=0,D=[],R=this.matchingBlocks();R.push(new o(this.oldWords.length,this.newWords.length,0));let j=this.removeOrphans(R);for(let K of j){let U,Y=P===K.startInOld,fe=_===K.startInNew;(U=Y||fe?Y&&!fe?r.insert:Y?r.none:r.delete:r.replace)!==r.none&&D.push(new O(U,P,K.startInOld,_,K.startInNew)),K.length!==0&&D.push(new O(r.equal,K.startInOld,K.endInOld,K.startInNew,K.endInNew)),P=K.endInOld,_=K.endInNew}return D}*removeOrphans(P){let _=null,D=null;for(let R of P){if(D===null){_=new o(0,0,0),D=R;continue}if(_.endInOld===D.startInOld&&_.endInNew===D.startInNew||D.endInOld===R.startInOld&&D.endInNew===R.startInNew){yield D,_=D,D=R;continue}let j=(Y,fe)=>Y+fe.length,K=this.oldWords.slice(_.endInOld,R.startInOld).reduce(j,0),U=this.newWords.slice(_.endInNew,R.startInNew).reduce(j,0);this.newWords.slice(D.startInNew,D.endInNew).reduce(j,0)>Math.max(K,U)*this.orphanMatchThreshold&&(yield D),_=D,D=R}yield D}matchingBlocks(){let P=[];return this.findMatchingBlocks(0,this.oldWords.length,0,this.newWords.length,P),P}findMatchingBlocks(P,_,D,R,j){let K=this.findMatch(P,_,D,R);K!==null&&(P<K.startInOld&&D<K.startInNew&&this.findMatchingBlocks(P,K.startInOld,D,K.startInNew,j),j.push(K),K.endInOld<_&&K.endInNew<R&&this.findMatchingBlocks(K.endInOld,_,K.endInNew,R,j))}findMatch(P,_,D,R){for(let j=this.matchGranularity;j>0;j--){let K=new i;K.blockSize=j,K.repeatingWordsAccuracy=this.repeatingWordsAccuracy,K.ignoreWhitespaceDifferences=this.ignoreWhiteSpaceDifferences;let U=new C(this.oldWords,this.newWords,P,_,D,R,K).findMatch();if(U!==null)return U}return null}}H.execute=function(F,P){return new H(F,P).build()},e.default=H},function(t,e,n){t.exports=n(0)}])),Zb}var V7=z7();const H7=Un(V7),cp="rgba(194, 249, 112, .5)",up="rgba(196, 77,86,0.3)",vM=t=>{const{beforeTxt:e="",afterTxt:n="",mode:r="sentence"}=t,o=W7(e,n,r);return g.jsx(mM,{content:o,extensions:[RT,Xb,UT.configure({multicolor:!0}),yM]})},W7=(t,e,n)=>{switch(n){case"sentence":return U7(t,e);case"word":return j7(t,e);case"html":return K7(t,e);case"comma":return q7(t,e)}},Qb=(t,e)=>{const n=Array.isArray(t.value)?t.value.join(", "):t.value;if(!t.added&&!t.removed)return n;const r=t.added?cp:up,o=t.added?"u":"s";return`<${o}><mark key={${e}} data-color="${r}" style={{ backgroundColor: ${r}, color: "inherit"}}>${n}</mark></${o}>`},xM=t=>t.split(",").map(e=>e.trim()),j7=(t,e)=>X3(t,e).map(Qb).join(""),U7=(t,e)=>t4(t,e).map(Qb).join(""),q7=(t,e)=>o4(xM(t),xM(e)).map(Qb).join(", "),K7=(t,e)=>{let n=H7.execute(t,e);return n=n.replaceAll(/<ins class="(diffmod|diffins)">/g,`<u><mark data-color="${cp}" style={{ backgroundColor: ${cp}, color: "inherit" }}>`),n=n.replaceAll("</ins>","</mark></u>"),n=n.replaceAll(/<del class="(diffmod|diffdel)">/g,`<s><mark data-color="${up}" style={{ backgroundColor: ${up}, color: "inherit" }}>`),n=n.replaceAll("</del>","</mark></s>"),n},Ti=t=>{const{label:e,value:n,readOnlyValue:r,staticLabel:o,staticLabelProps:i,showDiff:s=!1,diffSnapshot:a,diffMode:l,...u}=t,f=()=>s?g.jsx(vM,{beforeTxt:a,afterTxt:n,mode:l,...u}):r||g.jsx(z.Typography,{"data-testid":"read-only-value",children:n});return g.jsxs(z.Box,{width:"100%",mb:"8px",children:[o?g.jsx(z.Typography,{...i,children:e}):g.jsx(z.InputLabel,{children:e}),f()]})},wM=t=>{const{name:e,label:n=Ln(e),options:r=[],filterSelectedOptions:o=!0,variant:i="outlined",staticLabel:s=!1,staticLabelProps:a={fontSize:".9em",color:"#808080"},readOnly:l,margin:u="dense",fullWidth:f=!0,required:p,onChange:m,clearOnSelect:b=!1,onInputChange:v,getOptionLabel:y=R=>typeof R=="string"?R:String(R),isOptionEqualToValue:x=(R,j)=>JSON.stringify(R)===JSON.stringify(j),useFieldAsValue:S,errorMode:k="normal",...T}=t,[C,O,I]=Ht.useField(e),{setValue:N}=I,{error:L}=O,[V,M]=A.useState(""),B={...lr(T,["useFieldAsValue","errorMode"]),getOptionLabel:y,options:r,filterSelectedOptions:o,isOptionEqualToValue:x,renderInput:R=>g.jsx(z.TextField,{...R,variant:i,label:s?void 0:n,error:!!L,required:p}),onChange:(R,j,K,U)=>{b?(M(""),N(null)):N(S?j?j[S]:null:j),m&&m(R,j,K,U)},onInputChange:(R,j,K)=>{M(j),v&&v(R,j,K)},fullWidth:!0,inputValue:V,value:S?r.find(R=>R[S]===C.value)||null:C.value,slotProps:{paper:{elevation:8,sx:{borderRadius:2}}}},H=R=>{if(R==null)return"";if(S){const j=r.find(K=>K[S]===R);return j?y(j):""}return y(R)},F=Vs(),P=l??F,{showDiff:_,getPreviousValue:D}=Hs();return P||_?g.jsx(Ti,{label:n,value:H(C.value),staticLabel:s,staticLabelProps:a,showDiff:_,diffSnapshot:H(D(e))}):g.jsxs(z.FormControl,{margin:u,fullWidth:f,required:p,children:[s&&g.jsx(z.Typography,{...a,children:n}),g.jsxs(z.Box,{children:[g.jsx(z.Autocomplete,{...B}),g.jsx(yr,{name:e,id:`${e}-err`,errorMode:k})]})]})};var du={exports:{}};/**
356
+ */var xO;function T9(){return xO||(xO=1,process.env.NODE_ENV!=="production"&&(function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var t=J,e=Xf;function n(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}var r=typeof Object.is=="function"?Object.is:n,o=e.useSyncExternalStore,i=t.useRef,s=t.useEffect,a=t.useMemo,l=t.useDebugValue;function u(f,p,m,b,v){var y=i(null),x;y.current===null?(x={hasValue:!1,value:null},y.current=x):x=y.current;var S=a(function(){var O=!1,I,N,L=function(H){if(!O){O=!0,I=H;var F=b(H);if(v!==void 0&&x.hasValue){var P=x.value;if(v(P,F))return N=P,P}return N=F,F}var _=I,D=N;if(r(_,H))return D;var R=b(H);return v!==void 0&&v(D,R)?D:(I=H,N=R,R)},V=m===void 0?null:m,M=function(){return L(p())},B=V===null?void 0:function(){return L(V())};return[M,B]},[p,m,b,v]),k=S[0],T=S[1],C=o(f,k,T);return s(function(){x.hasValue=!0,x.value=C},[C]),l(C),C}Eb.useSyncExternalStoreWithSelector=u,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)})()),Eb}process.env.NODE_ENV==="production"?Tb.exports=C9():Tb.exports=T9();var k9=Tb.exports;const E9=typeof window<"u"?J.useLayoutEffect:J.useEffect;class O9{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){const n=()=>{this.transactionNumber+=1,this.subscribers.forEach(o=>o())},r=this.editor;return r.on("transaction",n),()=>{r.off("transaction",n)}}}}function M9(t){var e;const[n]=J.useState(()=>new O9(t.editor)),r=k9.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!==null&&e!==void 0?e:S9);return E9(()=>n.watch(t.editor),[t.editor,n]),J.useDebugValue(r),r}const wO=process.env.NODE_ENV!=="production",Ob=typeof window>"u",_9=Ob||!!(typeof window<"u"&&window.next);class Mb{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0)return Ob||_9?(wO&&console.warn("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches."),null):this.createEditor();if(this.options.current.immediatelyRender&&Ob&&wO)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var o,i;return(i=(o=this.options.current).onBeforeCreate)===null||i===void 0?void 0:i.call(o,...r)},onBlur:(...r)=>{var o,i;return(i=(o=this.options.current).onBlur)===null||i===void 0?void 0:i.call(o,...r)},onCreate:(...r)=>{var o,i;return(i=(o=this.options.current).onCreate)===null||i===void 0?void 0:i.call(o,...r)},onDestroy:(...r)=>{var o,i;return(i=(o=this.options.current).onDestroy)===null||i===void 0?void 0:i.call(o,...r)},onFocus:(...r)=>{var o,i;return(i=(o=this.options.current).onFocus)===null||i===void 0?void 0:i.call(o,...r)},onSelectionUpdate:(...r)=>{var o,i;return(i=(o=this.options.current).onSelectionUpdate)===null||i===void 0?void 0:i.call(o,...r)},onTransaction:(...r)=>{var o,i;return(i=(o=this.options.current).onTransaction)===null||i===void 0?void 0:i.call(o,...r)},onUpdate:(...r)=>{var o,i;return(i=(o=this.options.current).onUpdate)===null||i===void 0?void 0:i.call(o,...r)},onContentError:(...r)=>{var o,i;return(i=(o=this.options.current).onContentError)===null||i===void 0?void 0:i.call(o,...r)},onDrop:(...r)=>{var o,i;return(i=(o=this.options.current).onDrop)===null||i===void 0?void 0:i.call(o,...r)},onPaste:(...r)=>{var o,i;return(i=(o=this.options.current).onPaste)===null||i===void 0?void 0:i.call(o,...r)}};return new l3(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((o,i)=>{var s;return o===((s=n.extensions)===null||s===void 0?void 0:s[i])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Mb.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,o)=>r===e[o]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}}function SO(t={},e=[]){const n=J.useRef(t);n.current=t;const[r]=J.useState(()=>new Mb(n)),o=Xf.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return J.useDebugValue(o),J.useEffect(r.onRender(e)),M9({editor:o,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1?null:t.immediatelyRender&&i===0?0:i+1}),o}J.createContext({editor:null}).Consumer;const CO=J.createContext({onDragStart:void 0}),TO=()=>J.useContext(CO),I9=t=>{const e=t.as||"div",{nodeViewContentRef:n}=TO();return J.createElement(e,{...t,ref:n,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...t.style}})},_b=J.forwardRef((t,e)=>{const{onDragStart:n}=TO(),r=t.as||"div";return J.createElement(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function kO(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function EO(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function D9(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function A9(t){if(kO(t)||EO(t))return!0;if(D9(t)){const e=t.type;if(e)return kO(e)||EO(e)}return!1}function P9(){try{if(J.version)return parseInt(J.version.split(".")[0],10)>=19}catch{}return!1}class OO{constructor(e,{editor:n,props:r={},as:o="div",className:i=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=e,this.editor=n,this.props=r,this.element=document.createElement(o),this.element.classList.add("react-renderer"),i&&this.element.classList.add(...i.split(" ")),this.editor.isInitialized?Ps.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var e;const n=this.component,r=this.props,o=this.editor,i=P9(),s=A9(n),a={...r};a.ref&&!(i||s)&&delete a.ref,!a.ref&&(i||s)&&(a.ref=l=>{this.ref=l}),this.reactElement=J.createElement(n,{...a}),(e=o==null?void 0:o.contentComponent)===null||e===void 0||e.setRenderer(this.id,this)}updateProps(e={}){this.props={...this.props,...e},this.render()}destroy(){var e;const n=this.editor;(e=n==null?void 0:n.contentComponent)===null||e===void 0||e.removeRenderer(this.id)}updateAttributes(e){Object.keys(e).forEach(n=>{this.element.setAttribute(n,e[n])})}}class N9 extends c3{constructor(e,n,r){if(super(e,n,r),!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const o=this.dom.querySelector("[data-node-view-content]");if(!o)return;o.appendChild(this.contentDOMElement)}}mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(u={})=>this.updateAttributes(u),deleteNode:()=>this.deleteNode(),ref:J.createRef()};if(!this.component.displayName){const u=f=>f.charAt(0).toUpperCase()+f.substring(1);this.component.displayName=u(this.extension.name)}const o={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:u=>{u&&this.contentDOMElement&&u.firstChild!==this.contentDOMElement&&(u.hasAttribute("data-node-view-wrapper")&&u.removeAttribute("data-node-view-wrapper"),u.appendChild(this.contentDOMElement))}},i=this.component,s=J.memo(u=>J.createElement(CO.Provider,{value:o},J.createElement(i,u)));s.displayName="ReactNodeView";let a=this.node.isInline?"span":"div";this.options.as&&(a=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new OO(s,{editor:this.editor,props:e,as:a,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var e;if(this.renderer.element.firstElementChild&&!(!((e=this.renderer.element.firstElementChild)===null||e===void 0)&&e.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){const{from:e,to:n}=this.editor.state.selection,r=this.getPos();if(typeof r=="number")if(e<=r&&n>=r+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(e,n,r){const o=i=>{this.renderer.updateProps(i),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const i=this.node,s=this.decorations,a=this.innerDecorations;return this.node=e,this.decorations=n,this.innerDecorations=r,this.options.update({oldNode:i,oldDecorations:s,newNode:e,newDecorations:n,oldInnerDecorations:a,innerDecorations:r,updateProps:()=>o({node:e,decorations:n,innerDecorations:r})})}return e===this.node&&this.decorations===n&&this.innerDecorations===r||(this.node=e,this.decorations=n,this.innerDecorations=r,o({node:e,decorations:n,innerDecorations:r})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let e={};if(typeof this.options.attrs=="function"){const n=this.editor.extensionManager.attributes,r=Zd(this.node,n);e=this.options.attrs({node:this.node,HTMLAttributes:r})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}}function Ib(t,e){return n=>n.editor.contentComponent?new N9(t,n,e):{}}const lu=Xt("HeadingWithAnchorComponent",["root","container","link","linkIcon"]),cu=Ut("HeadingWithAnchorComponent"),$9=oe(_b,{name:cu,slot:"root",overridesResolver:(t,e)=>e.root,shouldForwardProp:t=>t!=="ownerState"&&t!=="theme"&&t!=="sx"})({[`&:hover .${lu.link}`]:{opacity:100}}),L9=oe("span",{name:cu,slot:"container",overridesResolver:(t,e)=>e.container})({display:"inline-block",position:"relative"}),B9=oe("a",{name:cu,slot:"link",overridesResolver:(t,e)=>e.link})(({theme:t})=>({position:"absolute",left:-21,color:`${t.palette.text.secondary} !important`,opacity:0,transition:t.transitions.create("opacity"),textDecoration:"none",outline:"none",[t.breakpoints.down("sm")]:{left:-18},'.ProseMirror[contenteditable="true"] &':{display:"none"}})),F9=oe(Hf,{name:cu,slot:"linkIcon",overridesResolver:(t,e)=>e.linkIcon})(({theme:t})=>({transform:"rotate(-45deg)",fontSize:"1.25rem",[t.breakpoints.down("sm")]:{fontSize:"1.15rem"}}));function R9(t){const e=rt({props:t,name:cu}),{editor:n,node:r,extension:o,classes:i={},sx:s}=e,u=`h${o.options.levels.includes(r.attrs.level)?r.attrs.level:o.options.levels[0]}`,f=J.useMemo(()=>jg(n.schema),[n.schema]),p=I6(oT(r,{textSerializers:f}));return g.jsx($9,{as:u,id:p,...o.options.HTMLAttributes,className:ge([lu.root,i.root]),style:{textAlign:r.attrs.textAlign},sx:s,children:g.jsxs(L9,{className:ge([lu.container,i.container]),children:[g.jsx(B9,{href:`#${p}`,contentEditable:!1,className:ge([lu.link,i.link]),children:g.jsx(F9,{className:ge([lu.linkIcon,i.linkIcon])})}),g.jsx(I9,{as:"span"})]})})}const z9=ST.extend({addOptions(){var t;return{...(t=this.parent)===null||t===void 0?void 0:t.call(this),scrollToAnchorOnMount:!0}},onCreate(){this.options.scrollToAnchorOnMount&&setTimeout(()=>{V9(this.editor)})},addNodeView(){return Ib(R9)}});function V9(t){if(t.isDestroyed||!("heading"in t.storage))return;const n=window.location.hash.slice(1);if(!n)return;const r=window.document.getElementById(n);r&&t.view.dom.contains(r)&&r.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})}var fr;(function(t){t[t.HIDDEN=0]="HIDDEN",t[t.VIEW_LINK_DETAILS=1]="VIEW_LINK_DETAILS",t[t.EDIT_LINK=2]="EDIT_LINK"})(fr||(fr={}));const H9=cn.create({name:"linkBubbleMenuHandler",addStorage(){return{state:fr.HIDDEN,bubbleMenuOptions:void 0}},addCommands(){return{openLinkBubbleMenu:(t={})=>({editor:e,chain:n,dispatch:r})=>{const o=this.storage.state;let i;return e.isActive("link")?(o!==fr.VIEW_LINK_DETAILS&&n().extendMarkRange("link").focus().run(),i=fr.VIEW_LINK_DETAILS):i=fr.EDIT_LINK,r&&(this.storage.state=i,this.storage.bubbleMenuOptions=t),!0},editLinkInBubbleMenu:()=>({dispatch:t})=>{const e=this.storage.state,n=fr.EDIT_LINK;return e===n?!1:(t&&(this.storage.state=n),!0)},closeLinkBubbleMenu:()=>({commands:t,dispatch:e})=>this.storage.state===fr.HIDDEN?!1:(t.focus(),e&&(this.storage.state=fr.HIDDEN),!0)}},onSelectionUpdate(){this.storage.state===fr.EDIT_LINK?this.editor.commands.closeLinkBubbleMenu():this.storage.state===fr.VIEW_LINK_DETAILS&&!this.editor.isActive("link")&&this.editor.commands.closeLinkBubbleMenu()},addKeyboardShortcuts(){return{"Mod-Shift-u":()=>(this.editor.commands.openLinkBubbleMenu(),!0)}},addProseMirrorPlugins(){return[new en({key:new On("handleClickLinkForMenu"),props:{handleClick:(t,e,n)=>{const r=Yg(t.state,"link");return n.target.closest("a")&&r.href&&this.storage.state===fr.HIDDEN?this.editor.commands.openLinkBubbleMenu():this.editor.commands.closeLinkBubbleMenu(),!1}}})]}}),W9=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,j9=tn.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",Ct(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[cT({find:W9,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}});var Db={},MO;function U9(){return MO||(MO=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ME();function n(r,o=0,i={}){const{leading:s=!0,trailing:a=!0}=i;return e.debounce(r,o,{leading:s,maxWait:o,trailing:a})}t.throttle=n})(Db)),Db}var Ab,_O;function q9(){return _O||(_O=1,Ab=U9().throttle),Ab}var K9=q9();const Y9=Un(K9),Zf=Xt("ResizableImageComponent",["imageContainer","image","imageSelected","resizer"]),G9=Xt("ResizableImageResizer",["root"]),IO=Ut("ResizableImageResizer"),J9=oe("div",{name:IO,slot:"root",overridesResolver:(t,e)=>e.root})(({theme:t})=>({position:"absolute",bottom:-3,right:-3,width:12,height:12,background:t.palette.primary.main,cursor:"nwse-resize"}));function X9(t){const e=rt({props:t,name:IO}),{onResize:n,className:r,mouseDown:o,setMouseDown:i,classes:s={},sx:a}=e;J.useEffect(()=>{if(!o)return;const u=f=>{n(f)};return window.addEventListener("mousemove",u),()=>{window.removeEventListener("mousemove",u)}},[o,n]),J.useEffect(()=>{const u=()=>{i(!1)};return window.addEventListener("mouseup",u),()=>{window.removeEventListener("mouseup",u)}},[i]);const l=J.useCallback(u=>{u.preventDefault(),u.stopPropagation(),i(!0)},[i]);return g.jsx(J9,{className:ge([G9.root,r,s.root]),onMouseDown:l,sx:a})}const Z9=15,Qf=Ut("ResizableImageComponent"),Q9=oe("div",{name:Qf,slot:"imageContainer",overridesResolver:(t,e)=>e.imageContainer})(()=>({display:"inline-flex",position:"relative"})),e8=oe("img",{name:Qf,slot:"image",overridesResolver:(t,e)=>[e.image,t.ownerState.selectedOrResizing&&e.imageSelected]})(({theme:t,ownerState:e})=>({display:"block",...e.selectedOrResizing&&{outline:`3px solid ${t.palette.primary.main}`}})),t8=oe(X9,{name:Qf,slot:"resizer",overridesResolver:(t,e)=>e.resizer})(()=>({'.ProseMirror[contenteditable="false"] &':{display:"none"}}));function n8(t){var e,n,r;const o=rt({props:t,name:Qf}),{node:i,selected:s,updateAttributes:a,extension:l,classes:u={},sx:f}=o,{attrs:p}=i,m=J.useRef(null),[b,v]=J.useState(!1),y=s||b,x={selected:s,selectedOrResizing:y},S=J.useMemo(()=>Y9(T=>{if(!m.current)return;const C=m.current.getBoundingClientRect(),O=T.clientX-C.x,I=T.clientY-C.y,N=Math.max(O,C.width/C.height*I,Z9);a({width:Math.round(N)})},50,{trailing:!0}),[a]),k=l.options.ChildComponent;return g.jsx(_b,{style:{textAlign:p.textAlign,width:"100%"},as:l.options.inline?"span":"div",sx:f,children:g.jsxs(Q9,{className:ge([Zf.imageContainer,u.imageContainer]),children:[g.jsx(e8,{ref:m,src:p.src,height:"auto",width:p.width?p.width:void 0,alt:(e=p.alt)!==null&&e!==void 0?e:void 0,title:(n=p.title)!==null&&n!==void 0?n:void 0,className:ge([Zf.image,u.image,y&&"ProseMirror-selectednode",y&&[Zf.imageSelected,u.imageSelected]]),style:{maxWidth:p.width?void 0:"auto",aspectRatio:(r=p.aspectRatio)!==null&&r!==void 0?r:void 0},ownerState:x,"data-drag-handle":!0,onLoad:T=>{const C={};p.width||(C.width=T.currentTarget.naturalWidth),p.aspectRatio||(C.aspectRatio=String(T.currentTarget.naturalWidth/T.currentTarget.naturalHeight)),(C.width||C.aspectRatio)&&a(C)}}),y&&g.jsx(t8,{onResize:S,className:ge([Zf.resizer,u.resizer]),mouseDown:b,setMouseDown:v}),k&&g.jsx(k,{...o})]})})}const r8=j9.extend({addOptions(){var t;return{...(t=this.parent)===null||t===void 0?void 0:t.call(this),isAllowedImgSrc:e=>!!e}},addAttributes(){var t;return{...(t=this.parent)===null||t===void 0?void 0:t.call(this),width:{default:null,renderHTML:e=>({width:e.width}),parseHTML:e=>e.getAttribute("width")},aspectRatio:{default:null,renderHTML:e=>e.aspectRatio?{style:`aspect-ratio: ${e.aspectRatio}`}:{},parseHTML:e=>e.style.aspectRatio}}},renderHTML({HTMLAttributes:t}){return["img",Ct({height:"auto"},this.options.HTMLAttributes,t)]},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])',getAttrs:t=>{if(!(t instanceof Element))return!1;const e=t.getAttribute("src");return this.options.isAllowedImgSrc(e)&&null}}]},addInputRules(){var t;const e=(t=this.parent)===null||t===void 0?void 0:t.call(this);if(!e)return[];const n=r=>{const[,,o,i,s]=r;return{src:i,alt:o,title:s}};return e.map(r=>new Ec({find:r.find,handler:o=>{const i=n(o.match);if(this.options.isAllowedImgSrc(i.src))return r.handler(o)}}))},addNodeView(){return Ib(n8)}});let Pb,Nb;if(typeof WeakMap<"u"){let t=new WeakMap;Pb=e=>t.get(e),Nb=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;Pb=r=>{for(let o=0;o<t.length;o+=2)if(t[o]==r)return t[o+1]},Nb=(r,o)=>(n==10&&(n=0),t[n++]=r,t[n++]=o)}var fn=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,o=e/this.width|0;let i=r+1,s=o+1;for(let a=1;i<this.width&&this.map[e+a]==n;a++)i++;for(let a=1;s<this.height&&this.map[e+this.width*a]==n;a++)s++;return{left:r,top:o,right:i,bottom:s}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:o,top:i,bottom:s}=this.findCell(t);return e=="horiz"?(n<0?r==0:o==this.width)?null:this.map[i*this.width+(n<0?r-1:o)]:(n<0?i==0:s==this.height)?null:this.map[r+this.width*(n<0?i-1:s)]}rectBetween(t,e){const{left:n,right:r,top:o,bottom:i}=this.findCell(t),{left:s,right:a,top:l,bottom:u}=this.findCell(e);return{left:Math.min(n,s),top:Math.min(o,l),right:Math.max(r,a),bottom:Math.max(i,u)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let o=t.left;o<t.right;o++){const i=r*this.width+o,s=this.map[i];n[s]||(n[s]=!0,!(o==t.left&&o&&this.map[i-1]==s||r==t.top&&r&&this.map[i-this.width]==s)&&e.push(s))}return e}positionAt(t,e,n){for(let r=0,o=0;;r++){const i=o+n.child(r).nodeSize;if(r==t){let s=e+t*this.width;const a=(t+1)*this.width;for(;s<a&&this.map[s]<o;)s++;return s==a?i-1:this.map[s]}o=i}}static get(t){return Pb(t)||Nb(t,o8(t))}};function o8(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=i8(t),n=t.childCount,r=[];let o=0,i=null;const s=[];for(let u=0,f=e*n;u<f;u++)r[u]=0;for(let u=0,f=0;u<n;u++){const p=t.child(u);f++;for(let v=0;;v++){for(;o<r.length&&r[o]!=0;)o++;if(v==p.childCount)break;const y=p.child(v),{colspan:x,rowspan:S,colwidth:k}=y.attrs;for(let T=0;T<S;T++){if(T+u>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:f,n:S-T});break}const C=o+T*e;for(let O=0;O<x;O++){r[C+O]==0?r[C+O]=f:(i||(i=[])).push({type:"collision",row:u,pos:f,n:x-O});const I=k&&k[O];if(I){const N=(C+O)%e*2,L=s[N];L==null||L!=I&&s[N+1]==1?(s[N]=I,s[N+1]=1):L==I&&s[N+1]++}}}o+=x,f+=y.nodeSize}const m=(u+1)*e;let b=0;for(;o<m;)r[o++]==0&&b++;b&&(i||(i=[])).push({type:"missing",row:u,n:b}),f++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const a=new fn(e,n,r,i);let l=!1;for(let u=0;!l&&u<s.length;u+=2)s[u]!=null&&s[u+1]<n&&(l=!0);return l&&s8(a,s,t),a}function i8(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const o=t.child(r);let i=0;if(n)for(let s=0;s<r;s++){const a=t.child(s);for(let l=0;l<a.childCount;l++){const u=a.child(l);s+u.attrs.rowspan>r&&(i+=u.attrs.colspan)}}for(let s=0;s<o.childCount;s++){const a=o.child(s);i+=a.attrs.colspan,a.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function s8(t,e,n){t.problems||(t.problems=[]);const r={};for(let o=0;o<t.map.length;o++){const i=t.map[o];if(r[i])continue;r[i]=!0;const s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let a=null;const l=s.attrs;for(let u=0;u<l.colspan;u++){const f=e[(o+u)%t.width*2];f!=null&&(!l.colwidth||l.colwidth[u]!=f)&&((a||(a=a8(l)))[u]=f)}a&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:a})}}function a8(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function or(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],o=r.spec.tableRole;o&&(e[o]=r)}}return e}const ys=new On("selectingCells");function El(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function l8(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function Eo(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function ep(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=El(e.$head)||c8(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function c8(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function $b(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function u8(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Lb(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function DO(t,e,n){const r=t.node(-1),o=fn.get(r),i=t.start(-1),s=o.nextCell(t.pos-i,e,n);return s==null?null:t.node(0).resolve(i+s)}function pa(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function AO(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<n;o++)r.colwidth.splice(e,0,0)}return r}function d8(t,e,n){const r=or(e.type.schema).header_cell;for(let o=0;o<t.height;o++)if(e.nodeAt(t.map[n+o*t.width]).type!=r)return!1;return!0}var Wt=class Wi extends nt{constructor(e,n=e){const r=e.node(-1),o=fn.get(r),i=e.start(-1),s=o.rectBetween(e.pos-i,n.pos-i),a=e.node(0),l=o.cellsInRect(s).filter(f=>f!=n.pos-i);l.unshift(n.pos-i);const u=l.map(f=>{const p=r.nodeAt(f);if(!p)throw new RangeError(`No cell with offset ${f} found`);const m=i+f+1;return new aS(a.resolve(m),a.resolve(m+p.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),o=e.resolve(n.map(this.$headCell.pos));if($b(r)&&$b(o)&&Lb(r,o)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Wi.rowSelection(r,o):i&&this.isColSelection()?Wi.colSelection(r,o):new Wi(r,o)}return Xe.between(r,o)}content(){const e=this.$anchorCell.node(-1),n=fn.get(e),r=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},s=[];for(let l=o.top;l<o.bottom;l++){const u=[];for(let f=l*n.width+o.left,p=o.left;p<o.right;p++,f++){const m=n.map[f];if(i[m])continue;i[m]=!0;const b=n.findCell(m);let v=e.nodeAt(m);if(!v)throw new RangeError(`No cell with offset ${m} found`);const y=o.left-b.left,x=b.right-o.right;if(y>0||x>0){let S=v.attrs;if(y>0&&(S=pa(S,0,y)),x>0&&(S=pa(S,S.colspan-x,x)),b.left<o.left){if(v=v.type.createAndFill(S),!v)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(S)}`)}else v=v.type.create(S,v.content)}if(b.top<o.top||b.bottom>o.bottom){const S={...v.attrs,rowspan:Math.min(b.bottom,o.bottom)-Math.max(b.top,o.top)};b.top<o.top?v=v.type.createAndFill(S):v=v.type.create(S,v.content)}u.push(v)}s.push(e.child(l).copy(Oe.from(u)))}const a=this.isColSelection()&&this.isRowSelection()?e:s;return new Fe(Oe.from(a),1,1)}replace(e,n=Fe.empty){const r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){const{$from:a,$to:l}=o[s],u=e.mapping.slice(r);e.replace(u.map(a.pos),u.map(l.pos),s?Fe.empty:n)}const i=nt.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new Fe(Oe.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=fn.get(n),o=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let s=0;s<i.length;s++)e(n.nodeAt(i[s]),o+i[s])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),o=fn.get(r),i=e.start(-1),s=o.findCell(e.pos-i),a=o.findCell(n.pos-i),l=e.node(0);return s.top<=a.top?(s.top>0&&(e=l.resolve(i+o.map[s.left])),a.bottom<o.height&&(n=l.resolve(i+o.map[o.width*(o.height-1)+a.right-1]))):(a.top>0&&(n=l.resolve(i+o.map[a.left])),s.bottom<o.height&&(e=l.resolve(i+o.map[o.width*(o.height-1)+s.right-1]))),new Wi(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=fn.get(e),r=this.$anchorCell.start(-1),o=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(o,i)>0)return!1;const s=o+this.$anchorCell.nodeAfter.attrs.colspan,a=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,a)==n.width}eq(e){return e instanceof Wi&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),o=fn.get(r),i=e.start(-1),s=o.findCell(e.pos-i),a=o.findCell(n.pos-i),l=e.node(0);return s.left<=a.left?(s.left>0&&(e=l.resolve(i+o.map[s.top*o.width])),a.right<o.width&&(n=l.resolve(i+o.map[o.width*(a.top+1)-1]))):(a.left>0&&(n=l.resolve(i+o.map[a.top*o.width])),s.right<o.width&&(e=l.resolve(i+o.map[o.width*(s.top+1)-1]))),new Wi(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new Wi(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new Wi(e.resolve(n),e.resolve(r))}getBookmark(){return new f8(this.$anchorCell.pos,this.$headCell.pos)}};Wt.prototype.visible=!1,nt.jsonID("cell",Wt);var f8=class TP{constructor(e,n){this.anchor=e,this.head=n}map(e){return new TP(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.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&&Lb(n,r)?new Wt(n,r):nt.near(r,1)}};function p8(t){if(!(t.selection instanceof Wt))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(Yn.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Jt.create(t.doc,e)}function h8({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,o=t.depth;for(;o>=0&&!(t.after(o+1)<t.end(o));o--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(o).type.spec.tableRole)}function m8({$from:t,$to:e}){let n,r;for(let o=t.depth;o>0;o--){const i=t.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let o=e.depth;o>0;o--){const i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function g8(t,e,n){const r=(e||t).selection,o=(e||t).doc;let i,s;if(r instanceof Je&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")i=Wt.create(o,r.from);else if(s=="row"){const a=o.resolve(r.from+1);i=Wt.rowSelection(a,a)}else if(!n){const a=fn.get(r.node),l=r.from+1,u=l+a.map[a.width*a.height-1];i=Wt.create(o,l+1,u)}}else r instanceof Xe&&h8(r)?i=Xe.create(o,r.from):r instanceof Xe&&m8(r)&&(i=Xe.create(o,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const y8=new On("fix-tables");function PO(t,e,n,r){const o=t.childCount,i=e.childCount;e:for(let s=0,a=0;s<i;s++){const l=e.child(s);for(let u=a,f=Math.min(o,s+3);u<f;u++)if(t.child(u)==l){a=u+1,n+=l.nodeSize;continue e}r(l,n),a<o&&t.child(a).sameMarkup(l)?PO(t.child(a),l,n+1,r):l.nodesBetween(0,l.content.size,r,n+1),n+=l.nodeSize}}function NO(t,e){let n;const r=(o,i)=>{o.type.spec.tableRole=="table"&&(n=b8(t,o,i,n))};return e?e.doc!=t.doc&&PO(e.doc,t.doc,0,r):t.doc.descendants(r),n}function b8(t,e,n,r){const o=fn.get(e);if(!o.problems)return r;r||(r=t.tr);const i=[];for(let l=0;l<o.height;l++)i.push(0);for(let l=0;l<o.problems.length;l++){const u=o.problems[l];if(u.type=="collision"){const f=e.nodeAt(u.pos);if(!f)continue;const p=f.attrs;for(let m=0;m<p.rowspan;m++)i[u.row+m]+=u.n;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,pa(p,p.colspan-u.n,u.n))}else if(u.type=="missing")i[u.row]+=u.n;else if(u.type=="overlong_rowspan"){const f=e.nodeAt(u.pos);if(!f)continue;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,{...f.attrs,rowspan:f.attrs.rowspan-u.n})}else if(u.type=="colwidth mismatch"){const f=e.nodeAt(u.pos);if(!f)continue;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,{...f.attrs,colwidth:u.colwidth})}else if(u.type=="zero_sized"){const f=r.mapping.map(n);r.delete(f,f+e.nodeSize)}}let s,a;for(let l=0;l<i.length;l++)i[l]&&(s==null&&(s=l),a=l);for(let l=0,u=n+1;l<o.height;l++){const f=e.child(l),p=u+f.nodeSize,m=i[l];if(m>0){let b="cell";f.firstChild&&(b=f.firstChild.type.spec.tableRole);const v=[];for(let x=0;x<m;x++){const S=or(t.schema)[b].createAndFill();S&&v.push(S)}const y=(l==0||s==l-1)&&a==l?u+1:p-1;r.insert(r.mapping.map(y),v)}u=p}return r.setMeta(y8,{fixTables:!0})}function Ko(t){const e=t.selection,n=ep(t),r=n.node(-1),o=n.start(-1),i=fn.get(r);return{...e instanceof Wt?i.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):i.findCell(n.pos-o),tableStart:o,map:i,table:r}}function $O(t,{map:e,tableStart:n,table:r},o){let i=o>0?-1:0;d8(e,r,o+i)&&(i=o==0||o==e.width?null:0);for(let s=0;s<e.height;s++){const a=s*e.width+o;if(o>0&&o<e.width&&e.map[a-1]==e.map[a]){const l=e.map[a],u=r.nodeAt(l);t.setNodeMarkup(t.mapping.map(n+l),null,AO(u.attrs,o-e.colCount(l))),s+=u.attrs.rowspan-1}else{const l=i==null?or(r.type.schema).cell:r.nodeAt(e.map[a+i]).type,u=e.positionAt(s,o,r);t.insert(t.mapping.map(n+u),l.createAndFill())}}return t}function v8(t,e){if(!Eo(t))return!1;if(e){const n=Ko(t);e($O(t.tr,n,n.left))}return!0}function x8(t,e){if(!Eo(t))return!1;if(e){const n=Ko(t);e($O(t.tr,n,n.right))}return!0}function w8(t,{map:e,table:n,tableStart:r},o){const i=t.mapping.maps.length;for(let s=0;s<e.height;){const a=s*e.width+o,l=e.map[a],u=n.nodeAt(l),f=u.attrs;if(o>0&&e.map[a-1]==l||o<e.width-1&&e.map[a+1]==l)t.setNodeMarkup(t.mapping.slice(i).map(r+l),null,pa(f,o-e.colCount(l)));else{const p=t.mapping.slice(i).map(r+l);t.delete(p,p+u.nodeSize)}s+=f.rowspan}}function S8(t,e){if(!Eo(t))return!1;if(e){const n=Ko(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let o=n.right-1;w8(r,n,o),o!=n.left;o--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=fn.get(i)}e(r)}return!0}function C8(t,e,n){var r;const o=or(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))===null||r===void 0?void 0:r.type)!=o)return!1;return!0}function LO(t,{map:e,tableStart:n,table:r},o){let i=n;for(let u=0;u<o;u++)i+=r.child(u).nodeSize;const s=[];let a=o>0?-1:0;C8(e,r,o+a)&&(a=o==0||o==e.height?null:0);for(let u=0,f=e.width*o;u<e.width;u++,f++)if(o>0&&o<e.height&&e.map[f]==e.map[f-e.width]){const p=e.map[f],m=r.nodeAt(p).attrs;t.setNodeMarkup(n+p,null,{...m,rowspan:m.rowspan+1}),u+=m.colspan-1}else{var l;const p=a==null?or(r.type.schema).cell:(l=r.nodeAt(e.map[f+a*e.width]))===null||l===void 0?void 0:l.type,m=p==null?void 0:p.createAndFill();m&&s.push(m)}return t.insert(i,or(r.type.schema).row.create(null,s)),t}function T8(t,e){if(!Eo(t))return!1;if(e){const n=Ko(t);e(LO(t.tr,n,n.top))}return!0}function k8(t,e){if(!Eo(t))return!1;if(e){const n=Ko(t);e(LO(t.tr,n,n.bottom))}return!0}function E8(t,{map:e,table:n,tableStart:r},o){let i=0;for(let u=0;u<o;u++)i+=n.child(u).nodeSize;const s=i+n.child(o).nodeSize,a=t.mapping.maps.length;t.delete(i+r,s+r);const l=new Set;for(let u=0,f=o*e.width;u<e.width;u++,f++){const p=e.map[f];if(!l.has(p)){if(l.add(p),o>0&&p==e.map[f-e.width]){const m=n.nodeAt(p).attrs;t.setNodeMarkup(t.mapping.slice(a).map(p+r),null,{...m,rowspan:m.rowspan-1}),u+=m.colspan-1}else if(o<e.height&&p==e.map[f+e.width]){const m=n.nodeAt(p),b=m.attrs,v=m.type.create({...b,rowspan:m.attrs.rowspan-1},m.content),y=e.positionAt(o+1,u,n);t.insert(t.mapping.slice(a).map(r+y),v),u+=b.colspan-1}}}}function O8(t,e){if(!Eo(t))return!1;if(e){const n=Ko(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let o=n.bottom-1;E8(r,n,o),o!=n.top;o--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=fn.get(n.table)}e(r)}return!0}function BO(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function M8({width:t,height:e,map:n},r){let o=r.top*t+r.left,i=o,s=(r.bottom-1)*t+r.left,a=o+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[a]==n[a+1])return!0;i+=t,a+=t}for(let l=r.left;l<r.right;l++){if(r.top>0&&n[o]==n[o-t]||r.bottom<e&&n[s]==n[s+t])return!0;o++,s++}return!1}function FO(t,e){const n=t.selection;if(!(n instanceof Wt)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=Ko(t),{map:o}=r;if(M8(o,r))return!1;if(e){const i=t.tr,s={};let a=Oe.empty,l,u;for(let f=r.top;f<r.bottom;f++)for(let p=r.left;p<r.right;p++){const m=o.map[f*o.width+p],b=r.table.nodeAt(m);if(!(s[m]||!b))if(s[m]=!0,l==null)l=m,u=b;else{BO(b)||(a=a.append(b.content));const v=i.mapping.map(m+r.tableStart);i.delete(v,v+b.nodeSize)}}if(l==null||u==null)return!0;if(i.setNodeMarkup(l+r.tableStart,null,{...AO(u.attrs,u.attrs.colspan,r.right-r.left-u.attrs.colspan),rowspan:r.bottom-r.top}),a.size>0){const f=l+1+u.content.size,p=BO(u)?l+1:f;i.replaceWith(p+r.tableStart,f+r.tableStart,a)}i.setSelection(new Wt(i.doc.resolve(l+r.tableStart))),e(i)}return!0}function RO(t,e){const n=or(t.schema);return _8(({node:r})=>n[r.type.spec.tableRole])(t,e)}function _8(t){return(e,n)=>{const r=e.selection;let o,i;if(r instanceof Wt){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;o=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var s;if(o=l8(r.$from),!o)return!1;i=(s=El(r.$from))===null||s===void 0?void 0:s.pos}if(o==null||i==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(n){let a=o.attrs;const l=[],u=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});const f=Ko(e),p=e.tr;for(let b=0;b<f.right-f.left;b++)l.push(u?{...a,colwidth:u&&u[b]?[u[b]]:null}:a);let m;for(let b=f.top;b<f.bottom;b++){let v=f.map.positionAt(b,f.left,f.table);b==f.top&&(v+=o.nodeSize);for(let y=f.left,x=0;y<f.right;y++,x++)y==f.left&&b==f.top||p.insert(m=p.mapping.map(v+f.tableStart,1),t({node:o,row:b,col:y}).createAndFill(l[x]))}p.setNodeMarkup(i,t({node:o,row:f.top,col:f.left}),l[0]),r instanceof Wt&&p.setSelection(new Wt(p.doc.resolve(r.$anchorCell.pos),m?p.doc.resolve(m):void 0)),n(p)}return!0}}function I8(t,e){return function(n,r){if(!Eo(n))return!1;const o=ep(n);if(o.nodeAfter.attrs[t]===e)return!1;if(r){const i=n.tr;n.selection instanceof Wt?n.selection.forEachCell((s,a)=>{s.attrs[t]!==e&&i.setNodeMarkup(a,null,{...s.attrs,[t]:e})}):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function D8(t){return function(e,n){if(!Eo(e))return!1;if(n){const r=or(e.schema),o=Ko(e),i=e.tr,s=o.map.cellsInRect(t=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:t=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),a=s.map(l=>o.table.nodeAt(l));for(let l=0;l<s.length;l++)a[l].type==r.header_cell&&i.setNodeMarkup(o.tableStart+s[l],r.cell,a[l].attrs);if(i.steps.length===0)for(let l=0;l<s.length;l++)i.setNodeMarkup(o.tableStart+s[l],r.header_cell,a[l].attrs);n(i)}return!0}}function zO(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let o=0;o<r.length;o++){const i=e.table.nodeAt(r[o]);if(i&&i.type!==n.header_cell)return!1}return!0}function uu(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?D8(t):function(n,r){if(!Eo(n))return!1;if(r){const o=or(n.schema),i=Ko(n),s=n.tr,a=zO("row",i,o),l=zO("column",i,o),u=(t==="column"?a:t==="row"&&l)?1:0,f=t=="column"?{left:0,top:u,right:1,bottom:i.map.height}:t=="row"?{left:u,top:0,right:i.map.width,bottom:1}:i,p=t=="column"?l?o.cell:o.header_cell:t=="row"?a?o.cell:o.header_cell:o.cell;i.map.cellsInRect(f).forEach(m=>{const b=m+i.tableStart,v=s.doc.nodeAt(b);v&&s.setNodeMarkup(b,p,v.attrs)}),r(s)}return!0}}uu("row",{useDeprecatedLogic:!0}),uu("column",{useDeprecatedLogic:!0});const A8=uu("cell",{useDeprecatedLogic:!0});function P8(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,o=t.before();r>=0;r--){const i=t.node(-1).child(r),s=i.lastChild;if(s)return o-1-s.nodeSize;o-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),o=t.after();r<n.childCount;r++){const i=n.child(r);if(i.childCount)return o+1;o+=i.nodeSize}}return null}function VO(t){return function(e,n){if(!Eo(e))return!1;const r=P8(ep(e),t);if(r==null)return!1;if(n){const o=e.doc.resolve(r);n(e.tr.setSelection(Xe.between(o,u8(o))).scrollIntoView())}return!0}}function N8(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function tp(t,e){const n=t.selection;if(!(n instanceof Wt))return!1;if(e){const r=t.tr,o=or(t.schema).cell.createAndFill().content;n.forEachCell((i,s)=>{i.content.eq(o)||r.replace(r.mapping.map(s+1),r.mapping.map(s+i.nodeSize-1),new Fe(o,0,0))}),r.docChanged&&e(r)}return!0}function $8(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const o=e.child(0),i=o.type.spec.tableRole,s=o.type.schema,a=[];if(i=="row")for(let l=0;l<e.childCount;l++){let u=e.child(l).content;const f=l?0:Math.max(0,n-1),p=l<e.childCount-1?0:Math.max(0,r-1);(f||p)&&(u=Bb(or(s).row,new Fe(u,f,p)).content),a.push(u)}else if(i=="cell"||i=="header_cell")a.push(n||r?Bb(or(s).row,new Fe(e,n,r)).content:e);else return null;return L8(s,a)}function L8(t,e){const n=[];for(let o=0;o<e.length;o++){const i=e[o];for(let s=i.childCount-1;s>=0;s--){const{rowspan:a,colspan:l}=i.child(s).attrs;for(let u=o;u<o+a;u++)n[u]=(n[u]||0)+l}}let r=0;for(let o=0;o<n.length;o++)r=Math.max(r,n[o]);for(let o=0;o<n.length;o++)if(o>=e.length&&e.push(Oe.empty),n[o]<r){const i=or(t).cell.createAndFill(),s=[];for(let a=n[o];a<r;a++)s.push(i);e[o]=e[o].append(Oe.from(s))}return{height:e.length,width:r,rows:e}}function Bb(t,e){const n=t.createAndFill();return new og(n).replace(0,n.content.size,e).doc}function B8({width:t,height:e,rows:n},r,o){if(t!=r){const i=[],s=[];for(let a=0;a<n.length;a++){const l=n[a],u=[];for(let f=i[a]||0,p=0;f<r;p++){let m=l.child(p%l.childCount);f+m.attrs.colspan>r&&(m=m.type.createChecked(pa(m.attrs,m.attrs.colspan,f+m.attrs.colspan-r),m.content)),u.push(m),f+=m.attrs.colspan;for(let b=1;b<m.attrs.rowspan;b++)i[a+b]=(i[a+b]||0)+m.attrs.colspan}s.push(Oe.from(u))}n=s,t=r}if(e!=o){const i=[];for(let s=0,a=0;s<o;s++,a++){const l=[],u=n[a%e];for(let f=0;f<u.childCount;f++){let p=u.child(f);s+p.attrs.rowspan>o&&(p=p.type.create({...p.attrs,rowspan:Math.max(1,o-p.attrs.rowspan)},p.content)),l.push(p)}i.push(Oe.from(l))}n=i,e=o}return{width:t,height:e,rows:n}}function F8(t,e,n,r,o,i,s){const a=t.doc.type.schema,l=or(a);let u,f;if(o>e.width)for(let p=0,m=0;p<e.height;p++){const b=n.child(p);m+=b.nodeSize;const v=[];let y;b.lastChild==null||b.lastChild.type==l.cell?y=u||(u=l.cell.createAndFill()):y=f||(f=l.header_cell.createAndFill());for(let x=e.width;x<o;x++)v.push(y);t.insert(t.mapping.slice(s).map(m-1+r),v)}if(i>e.height){const p=[];for(let v=0,y=(e.height-1)*e.width;v<Math.max(e.width,o);v++){const x=v>=e.width?!1:n.nodeAt(e.map[y+v]).type==l.header_cell;p.push(x?f||(f=l.header_cell.createAndFill()):u||(u=l.cell.createAndFill()))}const m=l.row.create(null,Oe.from(p)),b=[];for(let v=e.height;v<i;v++)b.push(m);t.insert(t.mapping.slice(s).map(r+n.nodeSize-2),b)}return!!(u||f)}function HO(t,e,n,r,o,i,s,a){if(s==0||s==e.height)return!1;let l=!1;for(let u=o;u<i;u++){const f=s*e.width+u,p=e.map[f];if(e.map[f-e.width]==p){l=!0;const m=n.nodeAt(p),{top:b,left:v}=e.findCell(p);t.setNodeMarkup(t.mapping.slice(a).map(p+r),null,{...m.attrs,rowspan:s-b}),t.insert(t.mapping.slice(a).map(e.positionAt(s,v,n)),m.type.createAndFill({...m.attrs,rowspan:b+m.attrs.rowspan-s})),u+=m.attrs.colspan-1}}return l}function WO(t,e,n,r,o,i,s,a){if(s==0||s==e.width)return!1;let l=!1;for(let u=o;u<i;u++){const f=u*e.width+s,p=e.map[f];if(e.map[f-1]==p){l=!0;const m=n.nodeAt(p),b=e.colCount(p),v=t.mapping.slice(a).map(p+r);t.setNodeMarkup(v,null,pa(m.attrs,s-b,m.attrs.colspan-(s-b))),t.insert(v+m.nodeSize,m.type.createAndFill(pa(m.attrs,0,s-b))),u+=m.attrs.rowspan-1}}return l}function jO(t,e,n,r,o){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let s=fn.get(i);const{top:a,left:l}=r,u=l+o.width,f=a+o.height,p=t.tr;let m=0;function b(){if(i=n?p.doc.nodeAt(n-1):p.doc,!i)throw new Error("No table found");s=fn.get(i),m=p.mapping.maps.length}F8(p,s,i,n,u,f,m)&&b(),HO(p,s,i,n,l,u,a,m)&&b(),HO(p,s,i,n,l,u,f,m)&&b(),WO(p,s,i,n,a,f,l,m)&&b(),WO(p,s,i,n,a,f,u,m)&&b();for(let v=a;v<f;v++){const y=s.positionAt(v,l,i),x=s.positionAt(v,u,i);p.replace(p.mapping.slice(m).map(y+n),p.mapping.slice(m).map(x+n),new Fe(o.rows[v-a],0,0))}b(),p.setSelection(new Wt(p.doc.resolve(n+s.positionAt(a,l,i)),p.doc.resolve(n+s.positionAt(f-1,u-1,i)))),e(p)}const R8=$g({ArrowLeft:rp("horiz",-1),ArrowRight:rp("horiz",1),ArrowUp:rp("vert",-1),ArrowDown:rp("vert",1),"Shift-ArrowLeft":op("horiz",-1),"Shift-ArrowRight":op("horiz",1),"Shift-ArrowUp":op("vert",-1),"Shift-ArrowDown":op("vert",1),Backspace:tp,"Mod-Backspace":tp,Delete:tp,"Mod-Delete":tp});function np(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function rp(t,e){return(n,r,o)=>{if(!o)return!1;const i=n.selection;if(i instanceof Wt)return np(n,r,nt.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const s=UO(o,t,e);if(s==null)return!1;if(t=="horiz")return np(n,r,nt.near(n.doc.resolve(i.head+e),e));{const a=n.doc.resolve(s),l=DO(a,t,e);let u;return l?u=nt.near(l,1):e<0?u=nt.near(n.doc.resolve(a.before(-1)),-1):u=nt.near(n.doc.resolve(a.after(-1)),1),np(n,r,u)}}}function op(t,e){return(n,r,o)=>{if(!o)return!1;const i=n.selection;let s;if(i instanceof Wt)s=i;else{const l=UO(o,t,e);if(l==null)return!1;s=new Wt(n.doc.resolve(l))}const a=DO(s.$headCell,t,e);return a?np(n,r,new Wt(s.$anchorCell,a)):!1}}function z8(t,e){const n=t.state.doc,r=El(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new Wt(r))),!0):!1}function V8(t,e,n){if(!Eo(t.state))return!1;let r=$8(n);const o=t.state.selection;if(o instanceof Wt){r||(r={width:1,height:1,rows:[Oe.from(Bb(or(t.state.schema).cell,n))]});const i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),a=fn.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=B8(r,a.right-a.left,a.bottom-a.top),jO(t.state,t.dispatch,s,a,r),!0}else if(r){const i=ep(t.state),s=i.start(-1);return jO(t.state,t.dispatch,s,fn.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function H8(t,e){var n;if(e.ctrlKey||e.metaKey)return;const r=qO(t,e.target);let o;if(e.shiftKey&&t.state.selection instanceof Wt)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=El(t.state.selection.$anchor))!=null&&((n=Fb(t,e))===null||n===void 0?void 0:n.pos)!=o.pos)i(o,e),e.preventDefault();else if(!r)return;function i(l,u){let f=Fb(t,u);const p=ys.getState(t.state)==null;if(!f||!Lb(l,f))if(p)f=l;else return;const m=new Wt(l,f);if(p||!t.state.selection.eq(m)){const b=t.state.tr.setSelection(m);p&&b.setMeta(ys,l.pos),t.dispatch(b)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",a),ys.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(ys,-1))}function a(l){const u=l,f=ys.getState(t.state);let p;if(f!=null)p=t.state.doc.resolve(f);else if(qO(t,u.target)!=r&&(p=Fb(t,e),!p))return s();p&&i(p,u)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",a)}function UO(t,e,n){if(!(t.state.selection instanceof Xe))return null;const{$head:r}=t.state.selection;for(let o=r.depth-1;o>=0;o--){const i=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const s=r.before(o),a=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(a)?s:null}}return null}function qO(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Fb(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;const r=n.inside>=0?n.inside:n.pos;return El(t.state.doc.resolve(r))}var W8=class{constructor(e,n){this.node=e,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")),Rb(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Rb(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Rb(t,e,n,r,o,i){let s=0,a=!0,l=e.firstChild;const u=t.firstChild;if(u){for(let p=0,m=0;p<u.childCount;p++){const{colspan:b,colwidth:v}=u.child(p).attrs;for(let y=0;y<b;y++,m++){const x=o==m?i:v&&v[y],S=x?x+"px":"";if(s+=x||r,x||(a=!1),l)l.style.width!=S&&(l.style.width=S),l=l.nextSibling;else{const k=document.createElement("col");k.style.width=S,e.appendChild(k)}}}for(;l;){var f;const p=l.nextSibling;(f=l.parentNode)===null||f===void 0||f.removeChild(l),l=p}a?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}const Lr=new On("tableColumnResizing");function KO({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=W8,lastColumnResizable:o=!0}={}){const i=new en({key:Lr,state:{init(s,a){var l;const u=(l=i.spec)===null||l===void 0||(l=l.props)===null||l===void 0?void 0:l.nodeViews,f=or(a.schema).table.name;return r&&u&&(u[f]=(p,m)=>new r(p,n,m)),new j8(-1,!1)},apply(s,a){return a.apply(s)}},props:{attributes:s=>{const a=Lr.getState(s);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,a)=>{U8(s,a,t,o)},mouseleave:s=>{q8(s)},mousedown:(s,a)=>{K8(s,a,e,n)}},decorations:s=>{const a=Lr.getState(s);if(a&&a.activeHandle>-1)return Z8(s,a.activeHandle)},nodeViews:{}}});return i}var j8=class xm{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Lr);if(r&&r.setHandle!=null)return new xm(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new xm(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let o=e.mapping.map(n.activeHandle,-1);return $b(e.doc.resolve(o))||(o=-1),new xm(o,n.dragging)}return n}};function U8(t,e,n,r){if(!t.editable)return;const o=Lr.getState(t.state);if(o&&!o.dragging){const i=G8(e.target);let s=-1;if(i){const{left:a,right:l}=i.getBoundingClientRect();e.clientX-a<=n?s=YO(t,e,"left",n):l-e.clientX<=n&&(s=YO(t,e,"right",n))}if(s!=o.activeHandle){if(!r&&s!==-1){const a=t.state.doc.resolve(s),l=a.node(-1),u=fn.get(l),f=a.start(-1);if(u.colCount(a.pos-f)+a.nodeAfter.attrs.colspan-1==u.width-1)return}JO(t,s)}}}function q8(t){if(!t.editable)return;const e=Lr.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&JO(t,-1)}function K8(t,e,n,r){var o;if(!t.editable)return!1;const i=(o=t.dom.ownerDocument.defaultView)!==null&&o!==void 0?o:window,s=Lr.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const a=t.state.doc.nodeAt(s.activeHandle),l=Y8(t,s.activeHandle,a.attrs);t.dispatch(t.state.tr.setMeta(Lr,{setDragging:{startX:e.clientX,startWidth:l}}));function u(p){i.removeEventListener("mouseup",u),i.removeEventListener("mousemove",f);const m=Lr.getState(t.state);m!=null&&m.dragging&&(J8(t,m.activeHandle,GO(m.dragging,p,n)),t.dispatch(t.state.tr.setMeta(Lr,{setDragging:null})))}function f(p){if(!p.which)return u(p);const m=Lr.getState(t.state);if(m&&m.dragging){const b=GO(m.dragging,p,n);XO(t,m.activeHandle,b,r)}}return XO(t,s.activeHandle,l,r),i.addEventListener("mouseup",u),i.addEventListener("mousemove",f),e.preventDefault(),!0}function Y8(t,e,{colspan:n,colwidth:r}){const o=r&&r[r.length-1];if(o)return o;const i=t.domAtPos(e);let s=i.node.childNodes[i.offset].offsetWidth,a=n;if(r)for(let l=0;l<n;l++)r[l]&&(s-=r[l],a--);return s/a}function G8(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function YO(t,e,n,r){const o=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+o,top:e.clientY});if(!i)return-1;const{pos:s}=i,a=El(t.state.doc.resolve(s));if(!a)return-1;if(n=="right")return a.pos;const l=fn.get(a.node(-1)),u=a.start(-1),f=l.map.indexOf(a.pos-u);return f%l.width==0?-1:u+l.map[f-1]}function GO(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function JO(t,e){t.dispatch(t.state.tr.setMeta(Lr,{setHandle:e}))}function J8(t,e,n){const r=t.state.doc.resolve(e),o=r.node(-1),i=fn.get(o),s=r.start(-1),a=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,l=t.state.tr;for(let u=0;u<i.height;u++){const f=u*i.width+a;if(u&&i.map[f]==i.map[f-i.width])continue;const p=i.map[f],m=o.nodeAt(p).attrs,b=m.colspan==1?0:a-i.colCount(p);if(m.colwidth&&m.colwidth[b]==n)continue;const v=m.colwidth?m.colwidth.slice():X8(m.colspan);v[b]=n,l.setNodeMarkup(s+p,null,{...m,colwidth:v})}l.docChanged&&t.dispatch(l)}function XO(t,e,n,r){const o=t.state.doc.resolve(e),i=o.node(-1),s=o.start(-1),a=fn.get(i).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1;let l=t.domAtPos(o.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&Rb(i,l.firstChild,l,r,a,n)}function X8(t){return Array(t).fill(0)}function Z8(t,e){const n=[],r=t.doc.resolve(e),o=r.node(-1);if(!o)return Jt.empty;const i=fn.get(o),s=r.start(-1),a=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let u=0;u<i.height;u++){const f=a+u*i.width;if((a==i.width-1||i.map[f]!=i.map[f+1])&&(u==0||i.map[f]!=i.map[f-i.width])){var l;const p=i.map[f],m=s+p+o.nodeAt(p).nodeSize-1,b=document.createElement("div");b.className="column-resize-handle",!((l=Lr.getState(t))===null||l===void 0)&&l.dragging&&n.push(Yn.node(s+p,s+p+o.nodeAt(p).nodeSize,{class:"column-resize-dragging"})),n.push(Yn.widget(m,b))}}return Jt.create(t.doc,n)}function ZO({allowTableNodeSelection:t=!1}={}){return new en({key:ys,state:{init(){return null},apply(e,n){const r=e.getMeta(ys);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:o,pos:i}=e.mapping.mapResult(n);return o?null:i}},props:{decorations:p8,handleDOMEvents:{mousedown:H8},createSelectionBetween(e){return ys.getState(e.state)!=null?e.state.selection:null},handleTripleClick:z8,handleKeyDown:R8,handlePaste:V8},appendTransaction(e,n,r){return g8(r,NO(r,n),t)}})}function zb(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function QO(t,e,n,r,o,i){var s;let a=0,l=!0,u=e.firstChild;const f=t.firstChild;if(f!==null)for(let p=0,m=0;p<f.childCount;p+=1){const{colspan:b,colwidth:v}=f.child(p).attrs;for(let y=0;y<b;y+=1,m+=1){const x=o===m?i:v&&v[y],S=x?`${x}px`:"";if(a+=x||r,x||(l=!1),u){if(u.style.width!==S){const[k,T]=zb(r,x);u.style.setProperty(k,T)}u=u.nextSibling}else{const k=document.createElement("col"),[T,C]=zb(r,x);k.style.setProperty(T,C),e.appendChild(k)}}}for(;u;){const p=u.nextSibling;(s=u.parentNode)===null||s===void 0||s.removeChild(u),u=p}l?(n.style.width=`${a}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${a}px`)}class Q8{constructor(e,n){this.node=e,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")),QO(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,QO(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function e7(t,e,n,r){let o=0,i=!0;const s=[],a=t.firstChild;if(!a)return{};for(let p=0,m=0;p<a.childCount;p+=1){const{colspan:b,colwidth:v}=a.child(p).attrs;for(let y=0;y<b;y+=1,m+=1){const x=n===m?r:v&&v[y];o+=x||e,x||(i=!1);const[S,k]=zb(e,x);s.push(["col",{style:`${S}: ${k}`}])}}const l=i?`${o}px`:"",u=i?"":`${o}px`;return{colgroup:["colgroup",{},...s],tableWidth:l,tableMinWidth:u}}function eM(t,e){return t.createAndFill()}function t7(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function n7(t,e,n,r,o){const i=t7(t),s=[],a=[];for(let u=0;u<n;u+=1){const f=eM(i.cell);if(f&&a.push(f),r){const p=eM(i.header_cell);p&&s.push(p)}}const l=[];for(let u=0;u<e;u+=1)l.push(i.row.createChecked(null,r&&u===0?s:a));return i.table.createChecked(null,l)}function r7(t){return t instanceof Wt}const ip=({editor:t})=>{const{selection:e}=t.state;if(!r7(e))return!1;let n=0;const r=qg(e.ranges[0].$from,i=>i.type.name==="table");return r==null||r.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},o7=tn.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:Q8,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:o}=e7(t,this.options.cellMinWidth),i=["table",Ct(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${o}`}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},i]:i},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:o,editor:i})=>{const s=n7(i.schema,t,e,n);if(o){const a=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(Xe.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>v8(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>x8(t,e),deleteColumn:()=>({state:t,dispatch:e})=>S8(t,e),addRowBefore:()=>({state:t,dispatch:e})=>T8(t,e),addRowAfter:()=>({state:t,dispatch:e})=>k8(t,e),deleteRow:()=>({state:t,dispatch:e})=>O8(t,e),deleteTable:()=>({state:t,dispatch:e})=>N8(t,e),mergeCells:()=>({state:t,dispatch:e})=>FO(t,e),splitCell:()=>({state:t,dispatch:e})=>RO(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>uu("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>uu("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>A8(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>FO(t,e)?!0:RO(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>I8(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>VO(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>VO(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&NO(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=Wt.create(e.doc,t.anchorCell,t.headCell);e.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:ip,"Mod-Backspace":ip,Delete:ip,"Mod-Delete":ip}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[KO({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],ZO({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:ft(Ue(t,"tableRole",e))}}}).extend({addProseMirrorPlugins(){return[...this.options.resizable?[KO({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],ZO({allowTableNodeSelection:this.options.allowTableNodeSelection})]}}),ha=Xt("FieldContainer",["root","outlined","standard","focused","disabled","notchedOutline"]),Vb=Ut("FieldContainer"),i7=oe(ab,{name:Vb,slot:"root",overridesResolver:(t,e)=>[e.root,t.ownerState.variant==="outlined"&&e.outlined,t.ownerState.variant==="standard"&&e.standard,t.ownerState.focused&&e.focused,t.ownerState.disabled&&e.disabled]})(({theme:t,ownerState:e})=>({...e.variant==="outlined"&&{borderRadius:t.shape.borderRadius,padding:1,position:"relative",...!e.focused&&!e.disabled&&{[`&:hover .${ha.notchedOutline}`]:{borderColor:t.palette.text.primary}}}})),s7=oe("div",{name:Vb,slot:"notchedOutline",overridesResolver:(t,e)=>e.notchedOutline})(({theme:t,ownerState:e})=>({position:"absolute",inset:0,borderRadius:"inherit",borderColor:t.palette.mode==="light"?"rgba(0, 0, 0, 0.23)":"rgba(255, 255, 255, 0.23)",borderStyle:"solid",borderWidth:1,pointerEvents:"none",overflow:"hidden",zIndex:xf.NOTCHED_OUTLINE,...e.focused&&{borderColor:t.palette.primary.main,borderWidth:2},...e.disabled&&{borderColor:t.palette.action.disabled}}));function a7(t){const e=rt({props:t,name:Vb}),{variant:n="outlined",children:r,focused:o,disabled:i,classes:s={},className:a,sx:l,...u}=e,f={variant:n,focused:o,disabled:i};return g.jsxs(i7,{...u,className:ge([ha.root,a,s.root,n==="outlined"?[ha.outlined,s.outlined]:[ha.standard,s.standard],o&&[ha.focused,s.focused],i&&[ha.disabled,s.disabled]]),sx:l,ownerState:f,children:[r,n==="outlined"&&g.jsx(s7,{ownerState:f,className:ge([ha.notchedOutline,s.notchedOutline]),"aria-hidden":!0})]})}function tM({editor:t,wait:e=250}){const[n,r]=J.useState(!!(t!=null&&t.isFocused)),o=J.useMemo(()=>IE(i=>{r(i)},e),[e]);return J.useEffect(()=>{const i=!!(t!=null&&t.isFocused);return o(i),i&&o.flush(),()=>{o.cancel()}},[t==null?void 0:t.isFocused,o]),n}function nM(t,e){const n=J.useRef(e);J.useEffect(()=>{n.current=e},[e]),J.useEffect(()=>{function r(o){t===o.key&&n.current(o)}return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[t])}function l7(t){return Ke("MuiDialogActions",t)}je("MuiDialogActions",["root","spacing"]);const c7=t=>{const{classes:e,disableSpacing:n}=t;return qe({root:["root",!n&&"spacing"]},l7,e)},u7=oe("div",{name:"MuiDialogActions",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,!n.disableSpacing&&e.spacing]}})({display:"flex",alignItems:"center",padding:8,justifyContent:"flex-end",flex:"0 0 auto",variants:[{props:({ownerState:t})=>!t.disableSpacing,style:{"& > :not(style) ~ :not(style)":{marginLeft:8}}}]}),sp=A.forwardRef(function(e,n){const r=mt({props:e,name:"MuiDialogActions"}),{className:o,disableSpacing:i=!1,...s}=r,a={...r,disableSpacing:i},l=c7(a);return g.jsx(u7,{className:ge(l.root,o),ownerState:a,ref:n,...s})});process.env.NODE_ENV!=="production"&&(sp.propTypes={children:c.node,classes:c.object,className:c.string,disableSpacing:c.bool,sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object])});function d7({editor:t,onCancel:e,onSave:n,labels:r,formatHref:o=_6}){var i,s,a,l,u,f;const p=t.isActive("link")?t.getAttributes("link").href:"",m=Oc(t.state.selection.$from,So("link",t.schema)),b=m?t.state.doc.textBetween(m.from,m.to):"",v=t.state.doc.textBetween(t.state.selection.$from.pos,t.state.selection.$to.pos),y=b||v,[x,S]=J.useState(y),[k,T]=J.useState(p),C=J.useRef(null),O=J.useRef(null),I=!p,N=(i=r==null?void 0:r.editLinkAddTitle)!==null&&i!==void 0?i:"Add link",L=(s=r==null?void 0:r.editLinkEditTitle)!==null&&s!==void 0?s:"Edit link",V=I?N:L;J.useEffect(()=>{var F,P;!I||!y?(F=C.current)===null||F===void 0||F.focus({preventScroll:!0}):(P=O.current)===null||P===void 0||P.focus({preventScroll:!0})},[I,y]),nM("Escape",e);function M(){O.current&&T(o(O.current.value))}const[B,H]=J.useState(!1);return g.jsxs("form",{onSubmit:F=>{var P,_,D,R;F.preventDefault(),F.stopPropagation(),H(!0);const j=(_=(P=C.current)===null||P===void 0?void 0:P.value)!==null&&_!==void 0?_:"",K=(R=(D=O.current)===null||D===void 0?void 0:D.value)!==null&&R!==void 0?R:"";n({text:j,link:K}),H(!1)},autoComplete:"off",children:[g.jsx(ko,{variant:"h6",children:V}),g.jsx(Xc,{inputRef:C,value:x,disabled:B,onChange:F=>{S(F.target.value)},label:(a=r==null?void 0:r.editLinkTextInputLabel)!==null&&a!==void 0?a:"Text",margin:"normal",size:"small",fullWidth:!0,required:!0}),g.jsx(Xc,{inputRef:O,value:k,onChange:F=>{T(F.target.value)},disabled:B,label:(l=r==null?void 0:r.editLinkHrefInputLabel)!==null&&l!==void 0?l:"Link",margin:"dense",size:"small",type:"text",onBlur:M,onKeyDown:F=>{F.key==="Enter"&&M()},fullWidth:!0,required:!0}),g.jsxs(sp,{sx:{px:0},children:[g.jsx(no,{onClick:e,variant:"outlined",size:"small",children:(u=r==null?void 0:r.editLinkCancelButtonLabel)!==null&&u!==void 0?u:"Cancel"}),g.jsx(no,{type:"submit",color:"primary",variant:"outlined",size:"small",disabled:B,children:(f=r==null?void 0:r.editLinkSaveButtonLabel)!==null&&f!==void 0?f:"Save"})]})]})}const Hb=Xt("LinkBubbleMenu",["root","paper","content"]);function f7(t){return Ke("MuiLink",t)}const p7=je("MuiLink",["root","underlineNone","underlineHover","underlineAlways","button","focusVisible"]),h7=({theme:t,ownerState:e})=>{const n=e.color,r=qi(t,`palette.${n}.main`,!1)||qi(t,`palette.${n}`,!1)||e.color,o=qi(t,`palette.${n}.mainChannel`)||qi(t,`palette.${n}Channel`);return"vars"in t&&o?`rgba(${o} / 0.4)`:it(r,.4)},rM={primary:!0,secondary:!0,error:!0,info:!0,success:!0,warning:!0,textPrimary:!0,textSecondary:!0,textDisabled:!0},m7=t=>{const{classes:e,component:n,focusVisible:r,underline:o}=t,i={root:["root",`underline${Ne(o)}`,n==="button"&&"button",r&&"focusVisible"]};return qe(i,f7,e)},g7=oe(ko,{name:"MuiLink",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,e[`underline${Ne(n.underline)}`],n.component==="button"&&e.button]}})(bt(({theme:t})=>({variants:[{props:{underline:"none"},style:{textDecoration:"none"}},{props:{underline:"hover"},style:{textDecoration:"none","&:hover":{textDecoration:"underline"}}},{props:{underline:"always"},style:{textDecoration:"underline","&:hover":{textDecorationColor:"inherit"}}},{props:({underline:e,ownerState:n})=>e==="always"&&n.color!=="inherit",style:{textDecorationColor:"var(--Link-underlineColor)"}},...Object.entries(t.palette).filter(Hn()).map(([e])=>({props:{underline:"always",color:e},style:{"--Link-underlineColor":t.vars?`rgba(${t.vars.palette[e].mainChannel} / 0.4)`:it(t.palette[e].main,.4)}})),{props:{underline:"always",color:"textPrimary"},style:{"--Link-underlineColor":t.vars?`rgba(${t.vars.palette.text.primaryChannel} / 0.4)`:it(t.palette.text.primary,.4)}},{props:{underline:"always",color:"textSecondary"},style:{"--Link-underlineColor":t.vars?`rgba(${t.vars.palette.text.secondaryChannel} / 0.4)`:it(t.palette.text.secondary,.4)}},{props:{underline:"always",color:"textDisabled"},style:{"--Link-underlineColor":(t.vars||t).palette.text.disabled}},{props:{component:"button"},style:{position:"relative",WebkitTapHighlightColor:"transparent",backgroundColor:"transparent",outline:0,border:0,margin:0,borderRadius:0,padding:0,cursor:"pointer",userSelect:"none",verticalAlign:"middle",MozAppearance:"none",WebkitAppearance:"none","&::-moz-focus-inner":{borderStyle:"none"},[`&.${p7.focusVisible}`]:{outline:"auto"}}}]}))),oM=A.forwardRef(function(e,n){const r=mt({props:e,name:"MuiLink"}),o=wo(),{className:i,color:s="primary",component:a="a",onBlur:l,onFocus:u,TypographyClasses:f,underline:p="always",variant:m="inherit",sx:b,...v}=r,[y,x]=A.useState(!1),S=O=>{Fa(O.target)||x(!1),l&&l(O)},k=O=>{Fa(O.target)&&x(!0),u&&u(O)},T={...r,color:s,component:a,focusVisible:y,underline:p,variant:m},C=m7(T);return g.jsx(g7,{color:s,className:ge(C.root,i),classes:f,component:a,onBlur:S,onFocus:k,ref:n,ownerState:T,variant:m,...v,sx:[...rM[s]===void 0?[{color:s}]:[],...Array.isArray(b)?b:[b]],style:{...v.style,...p==="always"&&s!=="inherit"&&!rM[s]&&{"--Link-underlineColor":h7({theme:o,ownerState:T})}}})});process.env.NODE_ENV!=="production"&&(oM.propTypes={children:c.node,classes:c.object,className:c.string,color:c.oneOfType([c.oneOf(["primary","secondary","success","error","info","warning","textPrimary","textSecondary","textDisabled"]),c.string]),component:Ba,onBlur:c.func,onFocus:c.func,style:c.object,sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object]),TypographyClasses:c.object,underline:c.oneOf(["always","hover","none"]),variant:c.oneOfType([c.oneOf(["body1","body2","button","caption","h1","h2","h3","h4","h5","h6","inherit","overline","subtitle1","subtitle2"]),c.string])});var Wb={},jb={},iM;function y7(){return iM||(iM=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n!==null&&(typeof n=="object"||typeof n=="function")}t.isObject=e})(jb)),jb}var sM;function b7(){return sM||(sM=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=y7(),n=/[\u200d\ud800-\udfff\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff\ufe0e\ufe0f]/;function r(i,s){i=i!=null?`${i}`:"";let a=30,l="...";e.isObject(s)&&(a=o(s.length),l="omission"in s?`${s.omission}`:"...");let u=i.length;const f=Array.from(l).length,p=Math.max(a-f,0);let m;if(n.test(i)&&(m=Array.from(i),u=m.length),a>=u)return i;if(u<=f)return l;let v=m===void 0?i.slice(0,p):m==null?void 0:m.slice(0,p).join("");const y=s==null?void 0:s.separator;if(!y)return v+=l,v;const x=y instanceof RegExp?y.source:y,S="u"+(y instanceof RegExp?y.flags.replace("u",""):""),k=new RegExp(`(?<result>.*(?:(?!${x}).))(?:${x})`,S).exec(v);return(k!=null&&k.groups?k.groups.result:v)+l}function o(i){return i==null?30:i<=0?0:i}t.truncate=r})(Wb)),Wb}var Ub,aM;function v7(){return aM||(aM=1,Ub=b7().truncate),Ub}var x7=v7();const w7=Un(x7),qb=Xt("ViewLinkMenuContent",["root","linkPreviewText"]),Kb=Ut("ViewLinkMenuContent"),S7=oe("div",{name:Kb,slot:"root",overridesResolver:(t,e)=>e.root})({}),lM=oe("div",{name:Kb,slot:"linkPreviewText",overridesResolver:(t,e)=>e.linkPreviewText})({overflowWrap:"anywhere"});function C7(t){var e,n,r;const o=rt({props:t,name:Kb}),{editor:i,onCancel:s,onEdit:a,onRemove:l,labels:u,classes:f={},sx:p}=o,m=Oc(i.state.selection.$to,So("link",i.schema)),b=m?i.state.doc.textBetween(m.from,m.to):"",v=(e=i.getAttributes("link").href)!==null&&e!==void 0?e:"";return nM("Escape",s),g.jsxs(S7,{className:ge([qb.root,f.root]),sx:p,children:[g.jsx(lM,{className:ge([qb.linkPreviewText,f.linkPreviewText]),children:w7(b,{length:50,omission:"…"})}),g.jsx(lM,{className:ge([qb.linkPreviewText,f.linkPreviewText]),children:g.jsx(oM,{href:v,target:"_blank",rel:"noopener",children:D6(v,50)})}),g.jsxs(sp,{sx:{px:0},children:[g.jsx(no,{onClick:a,color:"primary",variant:"outlined",size:"small",children:(n=u==null?void 0:u.viewLinkEditButtonLabel)!==null&&n!==void 0?n:"Edit"}),g.jsx(no,{onClick:l,color:"error",variant:"outlined",size:"small",children:(r=u==null?void 0:u.viewLinkRemoveButtonLabel)!==null&&r!==void 0?r:"Remove"})]})]})}const cM=Ut("LinkBubbleMenu"),T7=oe("div",{name:cM,slot:"content",overridesResolver:(t,e)=>e.content})(({theme:t})=>({padding:t.spacing(1.5,2,.5)}));function k7(t){const e=rt({props:t,name:cM}),{labels:n,formatHref:r,classes:o={},sx:i,...s}=e,a=Tt();if(!(a!=null&&a.isEditable))return null;if(!("linkBubbleMenuHandler"in a.storage))throw new Error("You must add the LinkBubbleMenuHandler extension to the useEditor `extensions` array in order to use this component!");const l=a.storage.linkBubbleMenuHandler,u=l.state;let f=null;return u===fr.VIEW_LINK_DETAILS?f=g.jsx(C7,{editor:a,onCancel:a.commands.closeLinkBubbleMenu,onEdit:a.commands.editLinkInBubbleMenu,onRemove:()=>{a.chain().unsetLink().setTextSelection(a.state.selection.to).focus().run()},labels:n}):u===fr.EDIT_LINK&&(f=g.jsx(d7,{editor:a,onCancel:a.commands.closeLinkBubbleMenu,onSave:({text:p,link:m})=>{a.chain().extendMarkRange("link").insertContent({type:"text",marks:[{type:"link",attrs:{href:m}}],text:p}).setLink({href:m}).focus().run(),a.commands.closeLinkBubbleMenu()},labels:n,formatHref:r})),g.jsx(Sy,{editor:a,open:u!==fr.HIDDEN,...l.bubbleMenuOptions,...s,classes:{root:ge([Hb.root,o.root]),paper:ge([Hb.paper,o.paper])},sx:i,children:g.jsx(T7,{className:ge([Hb.content,o.content]),children:f})})}function E7(t){return Ke("MuiCollapse",t)}je("MuiCollapse",["root","horizontal","vertical","entered","hidden","wrapper","wrapperInner"]);const O7=t=>{const{orientation:e,classes:n}=t,r={root:["root",`${e}`],entered:["entered"],hidden:["hidden"],wrapper:["wrapper",`${e}`],wrapperInner:["wrapperInner",`${e}`]};return qe(r,E7,n)},M7=oe("div",{name:"MuiCollapse",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,e[n.orientation],n.state==="entered"&&e.entered,n.state==="exited"&&!n.in&&n.collapsedSize==="0px"&&e.hidden]}})(bt(({theme:t})=>({height:0,overflow:"hidden",transition:t.transitions.create("height"),variants:[{props:{orientation:"horizontal"},style:{height:"auto",width:0,transition:t.transitions.create("width")}},{props:{state:"entered"},style:{height:"auto",overflow:"visible"}},{props:{state:"entered",orientation:"horizontal"},style:{width:"auto"}},{props:({ownerState:e})=>e.state==="exited"&&!e.in&&e.collapsedSize==="0px",style:{visibility:"hidden"}}]}))),_7=oe("div",{name:"MuiCollapse",slot:"Wrapper",overridesResolver:(t,e)=>e.wrapper})({display:"flex",width:"100%",variants:[{props:{orientation:"horizontal"},style:{width:"auto",height:"100%"}}]}),I7=oe("div",{name:"MuiCollapse",slot:"WrapperInner",overridesResolver:(t,e)=>e.wrapperInner})({width:"100%",variants:[{props:{orientation:"horizontal"},style:{width:"auto",height:"100%"}}]}),ap=A.forwardRef(function(e,n){const r=mt({props:e,name:"MuiCollapse"}),{addEndListener:o,children:i,className:s,collapsedSize:a="0px",component:l,easing:u,in:f,onEnter:p,onEntered:m,onEntering:b,onExit:v,onExited:y,onExiting:x,orientation:S="vertical",style:k,timeout:T=nw.standard,TransitionComponent:C=Pr,...O}=r,I={...r,orientation:S,collapsedSize:a},N=O7(I),L=wo(),V=$s(),M=A.useRef(null),B=A.useRef(),H=typeof a=="number"?`${a}px`:a,F=S==="horizontal",P=F?"width":"height",_=A.useRef(null),D=Ot(n,_),R=te=>ce=>{if(te){const ne=_.current;ce===void 0?te(ne):te(ne,ce)}},j=()=>M.current?M.current[F?"clientWidth":"clientHeight"]:0,K=R((te,ce)=>{M.current&&F&&(M.current.style.position="absolute"),te.style[P]=H,p&&p(te,ce)}),U=R((te,ce)=>{const ne=j();M.current&&F&&(M.current.style.position="");const{duration:re,easing:le}=ul({style:k,timeout:T,easing:u},{mode:"enter"});if(T==="auto"){const ye=L.transitions.getAutoHeightDuration(ne);te.style.transitionDuration=`${ye}ms`,B.current=ye}else te.style.transitionDuration=typeof re=="string"?re:`${re}ms`;te.style[P]=`${ne}px`,te.style.transitionTimingFunction=le,b&&b(te,ce)}),Y=R((te,ce)=>{te.style[P]="auto",m&&m(te,ce)}),fe=R(te=>{te.style[P]=`${j()}px`,v&&v(te)}),ue=R(y),pe=R(te=>{const ce=j(),{duration:ne,easing:re}=ul({style:k,timeout:T,easing:u},{mode:"exit"});if(T==="auto"){const le=L.transitions.getAutoHeightDuration(ce);te.style.transitionDuration=`${le}ms`,B.current=le}else te.style.transitionDuration=typeof ne=="string"?ne:`${ne}ms`;te.style[P]=H,te.style.transitionTimingFunction=re,x&&x(te)}),Z=te=>{T==="auto"&&V.start(B.current||0,te),o&&o(_.current,te)};return g.jsx(C,{in:f,onEnter:K,onEntered:Y,onEntering:U,onExit:fe,onExited:ue,onExiting:pe,addEndListener:Z,nodeRef:_,timeout:T==="auto"?null:T,...O,children:(te,{ownerState:ce,...ne})=>g.jsx(M7,{as:l,className:ge(N.root,s,{entered:N.entered,exited:!f&&H==="0px"&&N.hidden}[te]),style:{[F?"minWidth":"minHeight"]:H,...k},ref:D,ownerState:{...I,state:te},...ne,children:g.jsx(_7,{ownerState:{...I,state:te},className:N.wrapper,ref:M,children:g.jsx(I7,{ownerState:{...I,state:te},className:N.wrapperInner,children:i})})})})});process.env.NODE_ENV!=="production"&&(ap.propTypes={addEndListener:c.func,children:c.node,classes:c.object,className:c.string,collapsedSize:c.oneOfType([c.number,c.string]),component:Ba,easing:c.oneOfType([c.shape({enter:c.string,exit:c.string}),c.string]),in:c.bool,onEnter:c.func,onEntered:c.func,onEntering:c.func,onExit:c.func,onExited:c.func,onExiting:c.func,orientation:c.oneOf(["horizontal","vertical"]),style:c.object,sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object]),timeout:c.oneOfType([c.oneOf(["auto"]),c.number,c.shape({appear:c.number,enter:c.number,exit:c.number})])}),ap&&(ap.muiSupportAuto=!0);const lp=Xt("MenuBar",["root","sticky","nonSticky","content"]),Yb=Ut("MenuBar"),D7=oe(ap,{name:Yb,slot:"root",overridesResolver:(t,e)=>[e.root,t.ownerState.disableSticky?e.nonSticky:e.sticky]})(({theme:t,ownerState:e})=>({borderBottomColor:t.palette.divider,borderBottomStyle:"solid",borderBottomWidth:1,...e.disableSticky?{}:{position:"sticky",top:e.stickyOffset,zIndex:xf.MENU_BAR,background:t.palette.background.default}})),A7=oe("div",{name:Yb,slot:"content",overridesResolver:(t,e)=>e.content})({});function P7(t){const e=rt({props:t,name:Yb}),{hide:n,disableSticky:r,stickyOffset:o=0,children:i,className:s,classes:a={},unmountOnExit:l=!0,sx:u,...f}=e,p={hide:n,disableSticky:r,stickyOffset:o,unmountOnExit:l};return g.jsx(D7,{...f,in:!n,unmountOnExit:l,className:ge([lp.root,a.root,r?[lp.nonSticky,a.nonSticky]:[lp.sticky,a.sticky],s]),ownerState:p,sx:u,children:g.jsx(A7,{className:ge([lp.content,a.content]),ownerState:p,children:i})})}const Gb=Xt("RichTextContent",["root","readonly","editable"]),uM=Ut("RichTextContent"),N7=oe(x9,{name:uM,slot:"root",overridesResolver:(t,e)=>[e.root,t.ownerState.editable?e.editable:e.readonly]})(({theme:t,ownerState:e})=>e.disableDefaultStyles?{}:{"& .ProseMirror":{...ca(t)}});function dM(t){const e=rt({props:t,name:uM}),{innerRef:n,className:r,classes:o={},disableDefaultStyles:i=!1,sx:s}=e,a=Tt(),l=!!(a!=null&&a.isEditable),u={editable:l,disableDefaultStyles:i},f=J.useMemo(()=>ge([Gb.root,r,o.root,l?[Gb.editable,o.editable]:[Gb.readonly,o.readonly]]),[r,o.root,o.editable,o.readonly,l]);return g.jsx(N7,{editor:a,...n?{innerRef:n}:{},ownerState:u,className:f,sx:s})}function fM({editor:t,children:e}){return g.jsx(qT.Provider,{value:t,children:e})}const Yo=Xt("RichTextField",["root","standard","outlined","menuBar","menuBarContent","content"]),pM=Ut("RichTextField"),$7=oe(a7,{name:pM,slot:"root",overridesResolver:(t,e)=>[e.root,t.ownerState.variant==="outlined"&&e.outlined,t.ownerState.variant==="standard"&&e.standard]})(({theme:t,ownerState:e})=>({...e.variant==="standard"&&{[`& .${Yo.content}`]:{padding:t.spacing(1.5,0)},[`& .${Yo.menuBarContent}`]:{padding:t.spacing(1,0)}},...e.variant==="outlined"&&{[`& .${Yo.content}`]:{padding:t.spacing(1.5)},[`& .${Yo.menuBarContent}`]:{padding:t.spacing(1,1.5)}}}));function L7(t){var e,n;const r=rt({props:t,name:pM}),{variant:o="outlined",controls:i,disableDebounceRenderControls:s=!1,disabled:a,className:l,classes:u={},footer:f,MenuBarProps:p,RichTextContentProps:m,sx:b,...v}=r,y=Tt(),x={variant:o,disabled:a,disableDebounceRenderControls:s},S=tM({editor:y});return g.jsxs($7,{...v,variant:o,focused:!a&&S,disabled:a,className:ge([Yo.root,u.root,o==="outlined"?[Yo.outlined,u.outlined]:[Yo.standard,u.standard],l]),ownerState:x,sx:b,children:[i&&g.jsx(P7,{...p,classes:{...p==null?void 0:p.classes,root:ge([Yo.menuBar,u.menuBar,(e=p==null?void 0:p.classes)===null||e===void 0?void 0:e.root]),content:ge([Yo.menuBarContent,u.menuBarContent,(n=p==null?void 0:p.classes)===null||n===void 0?void 0:n.content])},children:s?i:g.jsx(ob,{children:i})}),g.jsx(dM,{...m,className:ge([Yo.content,u.content,m==null?void 0:m.className])}),f]})}const hM=J.forwardRef(function({className:e,renderControls:n,RichTextFieldProps:r={},sx:o,children:i,editorDependencies:s=[],editable:a=!0,shouldRerenderOnTransaction:l=!0,...u},f){const p={editable:a,shouldRerenderOnTransaction:l,...u},m=SO(p,s);return J.useImperativeHandle(f,()=>({editor:m}),[m]),J.useEffect(()=>{!m||m.isDestroyed||m.isEditable===a||queueMicrotask(()=>{m.setEditable(a)})},[a,m]),g.jsxs(fM,{editor:m,children:[g.jsx(L7,{disabled:!a,controls:n==null?void 0:n(m),className:e,sx:o,...r}),i==null?void 0:i(m)]})});function B7({RichTextContentProps:t,sx:e,...n}){const r=SO({...n,editable:!1}),o=J.useRef(n.content);return J.useEffect(()=>{!r||r.isDestroyed||n.content===void 0||n.content===o.current||queueMicrotask(()=>{n.content!==void 0&&r.commands.setContent(n.content)})},[n.content,r]),J.useEffect(()=>{o.current=n.content},[n.content]),g.jsx(fM,{editor:r,children:g.jsx(dM,{sx:e,...t})})}function mM(t){return t.content?g.jsx(B7,{...t}):null}const Jb=Xt("TableBubbleMenu",["root","paper","content"]),gM=Ut("TableBubbleMenu"),F7=oe(Lj,{name:gM,slot:"content",overridesResolver:(t,e)=>e.content})(({theme:t})=>({maxWidth:"90vw",padding:t.spacing(.5,1)}));function R7(t){const e=rt({props:t,name:gM}),{disableDebounce:n=!1,DebounceProps:r,labels:o,classes:i={},...s}=e,a=Tt(),l=tM({editor:a}),u=J.useMemo(()=>a?{getBoundingClientRect:()=>{const p=a.isActive("table")?qg(a.state.selection.$anchor,y=>y.type.name==="table"):null;if(p){const y=a.view.nodeDOM(p.pos),x=y==null?void 0:y.querySelector("table");if(x)return x.getBoundingClientRect()}const{ranges:m}=a.state.selection,b=Math.min(...m.map(y=>y.$from.pos)),v=Math.max(...m.map(y=>y.$to.pos));return aT(a.view,b,v)}}:null,[a]);if(!(a!=null&&a.isEditable))return null;const f=g.jsx(F7,{className:ge([Jb.content,i.content]),labels:o});return g.jsx(Sy,{editor:a,open:l&&a.isActive("table"),anchorEl:u,placement:"top-start",fallbackPlacements:["bottom-start","top","bottom","top-end","bottom-end"],flipPadding:{top:35,left:8,right:8,bottom:-1/0},...s,classes:{root:ge([Jb.root,i.root]),paper:ge([Jb.paper,i.paper])},children:n?f:g.jsx(ob,{...r,children:f})})}const Xb=vr.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",Ct(this.options.HTMLAttributes,t),0]},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),yM=vr.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",Ct(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});var Zb,bM;function z7(){return bM||(bM=1,Zb=(function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(r,o,i){n.o(r,o)||Object.defineProperty(r,o,{configurable:!1,enumerable:!0,get:i})},n.r=function(r){Object.defineProperty(r,"__esModule",{value:!0})},n.n=function(r){var o=r&&r.__esModule?function(){return r.default}:function(){return r};return n.d(o,"a",o),o},n.o=function(r,o){return Object.prototype.hasOwnProperty.call(r,o)},n.p="/dist/",n(n.s=1)})([function(t,e,n){n.r(e);var r={equal:0,delete:1,insert:2,none:3,replace:4};class o{constructor(P,_,D){this.startInOld=P,this.startInNew=_,this.size=D}get endInOld(){return this.startInOld+this.size}get endInNew(){return this.startInNew+this.size}}class i{constructor(){this.blockSize=0,this.repeatingWordsAccuracy=0,this.ignoreWhitespaceDifferences=!1}}const s=/^\s*<\/?[^>]+>\s*$/,a=/<[^\s>]+/,l=/^(\s|&nbsp;)+$/,u=/[\w\#@]+/,f=["<img"];function p(F){return!f.some(P=>F!==null&&F.startsWith(P))&&s.test(F)}function m(F,P,_){return["<",P,' class="',_,'">',F,"</",P,">"].join("")}function b(F){return F==="<"}function v(F){return F==="&"}function y(F){return F===";"}function x(F){return l.test(F)}function S(F){return p(F)?(function(P){return P=a.exec(P)[0]+(P.endsWith("/>")?"/>":">")})(F):F}function k(F){return u.test(F)}function T(F,P,_){return F.push(P),F.length>_&&F.shift(),F.length!==_?null:F.join("")}class C{constructor(P,_,D,R,j,K,U){this.oldWords=P,this.newWords=_,this.startInOld=D,this.endInOld=R,this.startInNew=j,this.endInNew=K,this.options=U}indexNewWords(){this.wordIndices=new Map;let P=[];for(let _=this.startInNew;_<this.endInNew;_++){let D=T(P,this.normalizeForIndex(this.newWords[_]),this.options.blockSize);D!==null&&(this.wordIndices.has(D)?this.wordIndices.get(D).push(_):this.wordIndices.set(D,[_]))}}normalizeForIndex(P){return P=S(P),this.options.IgnoreWhiteSpaceDifferences&&x(P)?" ":P}findMatch(){if(this.indexNewWords(),this.removeRepeatingWords(),this.wordIndices.length===0)return null;let P=this.startInOld,_=this.startInNew,D=0,R=new Map;const j=this.options.blockSize;let K=[];for(let U=this.startInOld;U<this.endInOld;U++){let Y=T(K,this.normalizeForIndex(this.oldWords[U]),j);if(Y===null)continue;let fe=new Map;if(this.wordIndices.has(Y)){for(let ue of this.wordIndices.get(Y)){let pe=(R.has(ue-1)?R.get(ue-1):0)+1;fe.set(ue,pe),pe>D&&(P=U-pe-j+2,_=ue-pe-j+2,D=pe)}R=fe}else R=fe}return D!==0?new o(P,_,D+j-1):null}removeRepeatingWords(){let P=this.newWords.length+this.options.repeatingWordsAccuracy,_=Array.from(this.wordIndices.entries()).filter(D=>D[1].length>P).map(D=>D[0]);for(let D of _)this.wordIndices.delete(D)}}class O{constructor(P,_,D,R,j){this.action=P,this.startInOld=_,this.endInOld=D,this.startInNew=R,this.endInNew=j}}var I={character:0,tag:1,whitespace:2,entity:3};function N(F,P){let _={mode:I.character,currentWord:[],words:[]},D=(function(Y,fe){let ue=new Map;if(fe===null)return ue;for(let pe of fe){let Z;for(;(Z=pe.exec(Y))!==null;){if(ue.has(Z.index))throw new Error("One or more block expressions result in a text sequence that overlaps. Current expression: "+pe.toString());ue.set(Z.index,Z.index+Z[0].length)}}return ue})(F,P),R=!!D.size,j=!1,K=-1;for(let Y=0;Y<F.length;Y++){var U=F[Y];if(R&&(K===index&&(K=-1,j=!1),D.has(index)&&(j=!0,K=D.get(index)),j)){_.currentWord.push(U),_.mode=I.character;continue}switch(_.mode){case I.character:b(U)?L(_,"<",I.tag):v(U)?L(_,U,I.entity):x(U)?L(_,U,I.whitespace):k(U)&&(_.currentWord.length===0||k(_.currentWord[_.currentWord.length-1]))?_.currentWord.push(U):L(_,U,I.character);break;case I.tag:U===">"?(_.currentWord.push(U),_.words.push(_.currentWord.join("")),_.currentWord=[],_.mode=x(U)?I.whitespace:I.character):_.currentWord.push(U);break;case I.whitespace:b(U)?L(_,U,I.tag):v(U)?L(_,U,I.entity):x(U)?_.currentWord.push(U):L(_,U,I.character);break;case I.entity:if(b(U))L(_,U,I.tag);else if(x(U))L(_,U,I.whitespace);else if(y(U)){let fe=!0;if(_.currentWord.length!==0&&(_.currentWord.push(U),_.words.push(_.currentWord.join("")),_.words.length>2&&x(_.words[_.words.length-2])&&x(_.words[_.words.length-1]))){let ue=_.words[_.words.length-2],pe=_.words[_.words.length-1];_.words.splice(_.words.length-2,2),_.currentWord=[(ue+pe).split()],_.mode=I.whitespace,fe=!1}fe&&(_.currentWord=[],_.mode=I.character)}else k(U)?_.currentWord.push(U):L(_,U,I.character)}}return _.currentWord.length!==0&&_.words.push(_.currentWord.join("")),_.words}function L(F,P,_){F.currentWord.length!==0&&F.words.push(F.currentWord.join("")),F.currentWord=[P],F.mode=_}const V=4,M=new Map([["</strong>",0],["</em>",0],["</b>",0],["</i>",0],["</big>",0],["</small>",0],["</u>",0],["</sub>",0],["</strike>",0],["</s>",0]]),B=/<((strong)|(b)|(i)|(em)|(big)|(small)|(u)|(sub)|(sup)|(strike)|(s))[\>\s]+/gi;class H{constructor(P,_){this.content=[],this.newText=_,this.oldText=P,this.specialTagDiffStack=[],this.newWords=[],this.oldWords=[],this.matchGranularity=0,this.blockExpressions=[],this.repeatingWordsAccuracy=1,this.ignoreWhiteSpaceDifferences=!1,this.orphanMatchThreshold=0}build(){if(this.oldText===this.newText)return this.newText;this.splitInputsIntoWords(),this.matchGranularity=Math.min(V,this.oldWords.length,this.newWords.length);let P=this.operations();for(let _ of P)this.performOperation(_);return this.content.join("")}addBlockExpression(P){this.blockExpressions.push(P)}splitInputsIntoWords(){this.oldWords=N(this.oldText,this.blockExpressions),this.oldText=null,this.newWords=N(this.newText,this.blockExpressions),this.newText=null}performOperation(P){switch(P.action){case r.equal:this.processEqualOperation(P);break;case r.delete:this.processDeleteOperation(P,"diffdel");break;case r.insert:this.processInsertOperation(P,"diffins");break;case r.none:break;case r.replace:this.processReplaceOperation(P)}}processReplaceOperation(P){this.processDeleteOperation(P,"diffmod"),this.processInsertOperation(P,"diffmod")}processInsertOperation(P,_){let D=this.newWords.filter((R,j)=>j>=P.startInNew&&j<P.endInNew);this.insertTag("ins",_,D)}processDeleteOperation(P,_){let D=this.oldWords.filter((R,j)=>j>=P.startInOld&&j<P.endInOld);this.insertTag("del",_,D)}processEqualOperation(P){let _=this.newWords.filter((D,R)=>R>=P.startInNew&&R<P.endInNew);this.content.push(_.join(""))}insertTag(P,_,D){for(;D.length;){let R=this.extractConsecutiveWords(D,U=>!p(U)),j="",K=!1;if(R.length!==0){let U=m(R.join(""),P,_);this.content.push(U)}else{if(B.test(D[0])){if(this.specialTagDiffStack.push(D[0]),j='<ins class="mod">',P==="del")for(D.shift();D.length>0&&B.test(D[0]);)D.shift()}else if(M.has(D[0])){let U=this.specialTagDiffStack.length===0?null:this.specialTagDiffStack.pop();if(U!==null&&U===D[0].replace(/\//g,"")&&(j="</ins>",K=!0),P==="del")for(D.shift();D.length>0&&M.has(D[0]);)D.shift()}if(D.length===0&&j.length===0)break;K?this.content.push(j+this.extractConsecutiveWords(D,p).join("")):this.content.push(this.extractConsecutiveWords(D,p).join("")+j)}}}extractConsecutiveWords(P,_){let D=null;for(let R=0;R<P.length;R++){let j=P[R];if(R===0&&j===" "&&(P[R]="&nbsp;"),!_(j)){D=R;break}}if(D!==null){let R=P.filter((j,K)=>K>=0&&K<D);return D>0&&P.splice(0,D),R}{let R=P.filter((j,K)=>K>=0&&K<P.length);return P.splice(0,P.length),R}}operations(){let P=0,_=0,D=[],R=this.matchingBlocks();R.push(new o(this.oldWords.length,this.newWords.length,0));let j=this.removeOrphans(R);for(let K of j){let U,Y=P===K.startInOld,fe=_===K.startInNew;(U=Y||fe?Y&&!fe?r.insert:Y?r.none:r.delete:r.replace)!==r.none&&D.push(new O(U,P,K.startInOld,_,K.startInNew)),K.length!==0&&D.push(new O(r.equal,K.startInOld,K.endInOld,K.startInNew,K.endInNew)),P=K.endInOld,_=K.endInNew}return D}*removeOrphans(P){let _=null,D=null;for(let R of P){if(D===null){_=new o(0,0,0),D=R;continue}if(_.endInOld===D.startInOld&&_.endInNew===D.startInNew||D.endInOld===R.startInOld&&D.endInNew===R.startInNew){yield D,_=D,D=R;continue}let j=(Y,fe)=>Y+fe.length,K=this.oldWords.slice(_.endInOld,R.startInOld).reduce(j,0),U=this.newWords.slice(_.endInNew,R.startInNew).reduce(j,0);this.newWords.slice(D.startInNew,D.endInNew).reduce(j,0)>Math.max(K,U)*this.orphanMatchThreshold&&(yield D),_=D,D=R}yield D}matchingBlocks(){let P=[];return this.findMatchingBlocks(0,this.oldWords.length,0,this.newWords.length,P),P}findMatchingBlocks(P,_,D,R,j){let K=this.findMatch(P,_,D,R);K!==null&&(P<K.startInOld&&D<K.startInNew&&this.findMatchingBlocks(P,K.startInOld,D,K.startInNew,j),j.push(K),K.endInOld<_&&K.endInNew<R&&this.findMatchingBlocks(K.endInOld,_,K.endInNew,R,j))}findMatch(P,_,D,R){for(let j=this.matchGranularity;j>0;j--){let K=new i;K.blockSize=j,K.repeatingWordsAccuracy=this.repeatingWordsAccuracy,K.ignoreWhitespaceDifferences=this.ignoreWhiteSpaceDifferences;let U=new C(this.oldWords,this.newWords,P,_,D,R,K).findMatch();if(U!==null)return U}return null}}H.execute=function(F,P){return new H(F,P).build()},e.default=H},function(t,e,n){t.exports=n(0)}])),Zb}var V7=z7();const H7=Un(V7),cp="rgba(194, 249, 112, .5)",up="rgba(196, 77,86,0.3)",vM=t=>{const{beforeTxt:e="",afterTxt:n="",mode:r="sentence"}=t,o=W7(e,n,r);return g.jsx(mM,{content:o,extensions:[RT,Xb,UT.configure({multicolor:!0}),yM]})},W7=(t,e,n)=>{switch(n){case"sentence":return U7(t,e);case"word":return j7(t,e);case"html":return K7(t,e);case"comma":return q7(t,e)}},Qb=(t,e)=>{const n=Array.isArray(t.value)?t.value.join(", "):t.value;if(!t.added&&!t.removed)return n;const r=t.added?cp:up,o=t.added?"u":"s";return`<${o}><mark key={${e}} data-color="${r}" style={{ backgroundColor: ${r}, color: "inherit"}}>${n}</mark></${o}>`},xM=t=>t.split(",").map(e=>e.trim()),j7=(t,e)=>X3(t,e).map(Qb).join(""),U7=(t,e)=>t4(t,e).map(Qb).join(""),q7=(t,e)=>o4(xM(t).filter(Boolean),xM(e).filter(Boolean)).map(Qb).join(", "),K7=(t,e)=>{let n=H7.execute(t,e);return n=n.replaceAll(/<ins class="(diffmod|diffins)">/g,`<u><mark data-color="${cp}" style={{ backgroundColor: ${cp}, color: "inherit" }}>`),n=n.replaceAll("</ins>","</mark></u>"),n=n.replaceAll(/<del class="(diffmod|diffdel)">/g,`<s><mark data-color="${up}" style={{ backgroundColor: ${up}, color: "inherit" }}>`),n=n.replaceAll("</del>","</mark></s>"),n},Ti=t=>{const{label:e,value:n,readOnlyValue:r,staticLabel:o,staticLabelProps:i,showDiff:s=!1,diffSnapshot:a,diffMode:l,...u}=t,f=()=>s?g.jsx(vM,{beforeTxt:a,afterTxt:n,mode:l,...u}):r||g.jsx(z.Typography,{"data-testid":"read-only-value",children:n});return g.jsxs(z.Box,{width:"100%",mb:"8px",children:[o?g.jsx(z.Typography,{...i,children:e}):g.jsx(z.InputLabel,{children:e}),f()]})},wM=t=>{const{name:e,label:n=Ln(e),options:r=[],filterSelectedOptions:o=!0,variant:i="outlined",staticLabel:s=!1,staticLabelProps:a={fontSize:".9em",color:"#808080"},readOnly:l,margin:u="dense",fullWidth:f=!0,required:p,onChange:m,clearOnSelect:b=!1,onInputChange:v,getOptionLabel:y=R=>typeof R=="string"?R:String(R),isOptionEqualToValue:x=(R,j)=>JSON.stringify(R)===JSON.stringify(j),useFieldAsValue:S,errorMode:k="normal",...T}=t,[C,O,I]=Ht.useField(e),{setValue:N}=I,{error:L}=O,[V,M]=A.useState(""),B={...lr(T,["useFieldAsValue","errorMode"]),getOptionLabel:y,options:r,filterSelectedOptions:o,isOptionEqualToValue:x,renderInput:R=>g.jsx(z.TextField,{...R,variant:i,label:s?void 0:n,error:!!L,required:p}),onChange:(R,j,K,U)=>{b?(M(""),N(null)):N(S?j?j[S]:null:j),m&&m(R,j,K,U)},onInputChange:(R,j,K)=>{M(j),v&&v(R,j,K)},fullWidth:!0,inputValue:V,value:S?r.find(R=>R[S]===C.value)||null:C.value,slotProps:{paper:{elevation:8,sx:{borderRadius:2}}}},H=R=>{if(R==null)return"";if(S){const j=r.find(K=>K[S]===R);return j?y(j):""}return y(R)},F=Vs(),P=l??F,{showDiff:_,getPreviousValue:D}=Hs();return P||_?g.jsx(Ti,{label:n,value:H(C.value),staticLabel:s,staticLabelProps:a,showDiff:_,diffSnapshot:H(D(e))}):g.jsxs(z.FormControl,{margin:u,fullWidth:f,required:p,children:[s&&g.jsx(z.Typography,{...a,children:n}),g.jsxs(z.Box,{children:[g.jsx(z.Autocomplete,{...B}),g.jsx(yr,{name:e,id:`${e}-err`,errorMode:k})]})]})};var du={exports:{}};/**
357
357
  * @license
358
358
  * Lodash <https://lodash.com/>
359
359
  * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
@@ -405,5 +405,5 @@ The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rg
405
405
  3. "-" cannot repeat`);Kt.customSchemes.push([t,e])}function qZ(){Kt.scanner=FZ(Kt.customSchemes);for(let t=0;t<Kt.tokenQueue.length;t++)Kt.tokenQueue[t][1]({scanner:Kt.scanner});Kt.parser=VZ(Kt.scanner.tokens);for(let t=0;t<Kt.pluginQueue.length;t++)Kt.pluginQueue[t][1]({scanner:Kt.scanner,parser:Kt.parser});return Kt.initialized=!0,Kt}function sv(t){return Kt.initialized||qZ(),HZ(Kt.parser.start,t,R2(Kt.scanner.start,t))}sv.scan=R2;function q2(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new ov(n),o=sv(t),i=[];for(let s=0;s<o.length;s++){const a=o[s];a.isLink&&(!e||a.t===e)&&r.check(a)&&i.push(a.toFormattedObject(r))}return i}const av="[\0-   ᠎ -\u2029  ]",KZ=new RegExp(av),YZ=new RegExp(`${av}$`),GZ=new RegExp(av,"g");function JZ(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function XZ(t){return new en({key:new On("autolink"),appendTransaction:(e,n,r)=>{const o=e.some(u=>u.docChanged)&&!n.doc.eq(r.doc),i=e.some(u=>u.getMeta("preventAutolink"));if(!o||i)return;const{tr:s}=r,a=NR(n.doc,[...e]);if(zR(a).forEach(({newRange:u})=>{const f=LR(r.doc,u,b=>b.isTextblock);let p,m;if(f.length>1)p=f[0],m=r.doc.textBetween(p.pos,p.pos+p.node.nodeSize,void 0," ");else if(f.length){const b=r.doc.textBetween(u.from,u.to," "," ");if(!YZ.test(b))return;p=f[0],m=r.doc.textBetween(p.pos,u.to,void 0," ")}if(p&&m){const b=m.split(KZ).filter(Boolean);if(b.length<=0)return!1;const v=b[b.length-1],y=p.pos+m.lastIndexOf(v);if(!v)return!1;const x=sv(v).map(S=>S.toObject(t.defaultProtocol));if(!JZ(x))return!1;x.filter(S=>S.isLink).map(S=>({...S,from:y+S.start+1,to:y+S.end+1})).filter(S=>r.schema.marks.code?!r.doc.rangeHasMark(S.from,S.to,r.schema.marks.code):!0).filter(S=>t.validate(S.value)).filter(S=>t.shouldAutoLink(S.value)).forEach(S=>{Gg(S.from,S.to,r.doc).some(k=>k.mark.type===t.type)||s.addMark(S.from,S.to,t.type.create({href:S.href}))})}}),!!s.steps.length)return s}})}function ZZ(t){return new en({key:new On("handleClickLink"),props:{handleClick:(e,n,r)=>{var o,i;if(r.button!==0||!e.editable)return!1;let s=r.target;const a=[];for(;s.nodeName!=="DIV";)a.push(s),s=s.parentNode;if(!a.find(m=>m.nodeName==="A"))return!1;const l=Yg(e.state,t.type.name),u=r.target,f=(o=u==null?void 0:u.href)!==null&&o!==void 0?o:l.href,p=(i=u==null?void 0:u.target)!==null&&i!==void 0?i:l.target;return u&&f?(window.open(f,p),!0):!1}}})}function QZ(t){return new en({key:new On("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{state:o}=e,{selection:i}=o,{empty:s}=i;if(s)return!1;let a="";r.content.forEach(u=>{a+=u.textContent});const l=q2(a,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!l?!1:t.editor.commands.setMark(t.type,{href:l.href})}}})}function Sa(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const o=typeof r=="string"?r:r.scheme;o&&n.push(o)}),!t||t.replace(GZ,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const eQ=vr.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){U2(t);return}U2(t.scheme,t.optionalSlashes)})},onDestroy(){UZ()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!Sa(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Sa(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Sa(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Ct(this.options.HTMLAttributes,t),0]:["a",Ct(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Sa(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Sa(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[cs({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,o=q2(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:s=>!!Sa(s,n),protocols:n,defaultProtocol:r}));o.length&&o.forEach(i=>e.push({text:i.value,data:{href:i.href},index:i.start}))}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(XZ({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!Sa(o,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(ZZ({type:this.type})),this.options.linkOnPaste&&t.push(QZ({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}});function tQ(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:i,startOfLine:s,$position:a}=t,l=r&&!o,u=d3(n),f=new RegExp(`\\s${u}$`),p=s?"^":"",m=o?"":u,b=l?new RegExp(`${p}${u}.*?(?=\\s${m}|$)`,"gm"):new RegExp(`${p}(?:^)?${u}[^\\s${m}]*`,"gm"),v=((e=a.nodeBefore)===null||e===void 0?void 0:e.isText)&&a.nodeBefore.text;if(!v)return null;const y=a.pos-v.length,x=Array.from(v.matchAll(b)).pop();if(!x||x.input===void 0||x.index===void 0)return null;const S=x.input.slice(Math.max(0,x.index-1),x.index),k=new RegExp(`^[${i==null?void 0:i.join("")}\0]?$`).test(S);if(i!==null&&!k)return null;const T=y+x.index;let C=T+x[0].length;return l&&f.test(v.slice(C-1,C+1))&&(x[0]+=" ",C+=1),T<a.pos&&C>=a.pos?{range:{from:T,to:C},query:x[0].slice(n.length),text:x[0]}:null}const nQ=new On("suggestion");function rQ({pluginKey:t=nQ,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:o=!1,allowedPrefixes:i=[" "],startOfLine:s=!1,decorationTag:a="span",decorationClass:l="suggestion",decorationContent:u="",decorationEmptyClass:f="is-empty",command:p=()=>null,items:m=()=>[],render:b=()=>({}),allow:v=()=>!0,findSuggestionMatch:y=tQ}){let x;const S=b==null?void 0:b(),k=new en({key:t,view(){return{update:async(T,C)=>{var O,I,N,L,V,M,B;const H=(O=this.key)===null||O===void 0?void 0:O.getState(C),F=(I=this.key)===null||I===void 0?void 0:I.getState(T.state),P=H.active&&F.active&&H.range.from!==F.range.from,_=!H.active&&F.active,D=H.active&&!F.active,R=!_&&!D&&H.query!==F.query,j=_||P&&R,K=R||P,U=D||P&&R;if(!j&&!K&&!U)return;const Y=U&&!j?H:F,fe=T.dom.querySelector(`[data-decoration-id="${Y.decorationId}"]`);x={editor:e,range:Y.range,query:Y.query,text:Y.text,items:[],command:ue=>p({editor:e,range:Y.range,props:ue}),decorationNode:fe,clientRect:fe?()=>{var ue;const{decorationId:pe}=(ue=this.key)===null||ue===void 0?void 0:ue.getState(e.state),Z=T.dom.querySelector(`[data-decoration-id="${pe}"]`);return(Z==null?void 0:Z.getBoundingClientRect())||null}:null},j&&((N=S==null?void 0:S.onBeforeStart)===null||N===void 0||N.call(S,x)),K&&((L=S==null?void 0:S.onBeforeUpdate)===null||L===void 0||L.call(S,x)),(K||j)&&(x.items=await m({editor:e,query:Y.query})),U&&((V=S==null?void 0:S.onExit)===null||V===void 0||V.call(S,x)),K&&((M=S==null?void 0:S.onUpdate)===null||M===void 0||M.call(S,x)),j&&((B=S==null?void 0:S.onStart)===null||B===void 0||B.call(S,x))},destroy:()=>{var T;x&&((T=S==null?void 0:S.onExit)===null||T===void 0||T.call(S,x))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(T,C,O,I){const{isEditable:N}=e,{composing:L}=e.view,{selection:V}=T,{empty:M,from:B}=V,H={...C};if(H.composing=L,N&&(M||e.view.composing)){(B<C.range.from||B>C.range.to)&&!L&&!C.composing&&(H.active=!1);const F=y({char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:i,startOfLine:s,$position:V.$from}),P=`id_${Math.floor(Math.random()*4294967295)}`;F&&v({editor:e,state:I,range:F.range,isActive:C.active})?(H.active=!0,H.decorationId=C.decorationId?C.decorationId:P,H.range=F.range,H.query=F.query,H.text=F.text):H.active=!1}else H.active=!1;return H.active||(H.decorationId=null,H.range={from:0,to:0},H.query=null,H.text=null),H}},props:{handleKeyDown(T,C){var O;const{active:I,range:N}=k.getState(T.state);return I&&((O=S==null?void 0:S.onKeyDown)===null||O===void 0?void 0:O.call(S,{view:T,event:C,range:N}))||!1},decorations(T){const{active:C,range:O,decorationId:I,query:N}=k.getState(T);if(!C)return null;const L=!(N!=null&&N.length),V=[l];return L&&V.push(f),Jt.create(T.doc,[Yn.inline(O.from,O.to,{nodeName:a,class:V.join(" "),"data-decoration-id":I,"data-decoration-content":u})])}}});return k}function oQ({editor:t,overrideSuggestionOptions:e,extensionName:n,char:r="@"}){const o=new On;return{editor:t,char:r,pluginKey:o,command:({editor:i,range:s,props:a})=>{var l,u,f;const p=i.view.state.selection.$to.nodeAfter;((l=p==null?void 0:p.text)===null||l===void 0?void 0:l.startsWith(" "))&&(s.to+=1),i.chain().focus().insertContentAt(s,[{type:n,attrs:{...a,mentionSuggestionChar:r}},{type:"text",text:" "}]).run(),(f=(u=i.view.dom.ownerDocument.defaultView)===null||u===void 0?void 0:u.getSelection())===null||f===void 0||f.collapseToEnd()},allow:({state:i,range:s})=>{const a=i.doc.resolve(s.from),l=i.schema.nodes[n];return!!a.parent.type.contentMatch.matchType(l)},...e}}function K2(t){return(t.options.suggestions.length?t.options.suggestions:[t.options.suggestion]).map(e=>oQ({editor:t.editor,overrideSuggestionOptions:e,extensionName:t.name,char:e.char}))}function Y2(t,e){const n=K2(t),r=n.find(o=>o.char===e);return r||(n.length?n[0]:null)}const iQ=tn.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:t,suggestion:e}){var n,r;return`${(n=e==null?void 0:e.char)!==null&&n!==void 0?n:"@"}${(r=t.attrs.label)!==null&&r!==void 0?r:t.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:t,node:e,suggestion:n}){var r,o;return["span",Ct(this.HTMLAttributes,t.HTMLAttributes),`${(r=n==null?void 0:n.char)!==null&&r!==void 0?r:"@"}${(o=e.attrs.label)!==null&&o!==void 0?o:e.attrs.id}`]},suggestions:[],suggestion:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}},label:{default:null,parseHTML:t=>t.getAttribute("data-label"),renderHTML:t=>t.label?{"data-label":t.label}:{}},mentionSuggestionChar:{default:"@",parseHTML:t=>t.getAttribute("data-mention-suggestion-char"),renderHTML:t=>({"data-mention-suggestion-char":t.mentionSuggestionChar})}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:t,HTMLAttributes:e}){const n=Y2(this,t.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",Ct({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:t,suggestion:n})];const r={...this.options};r.HTMLAttributes=Ct({"data-type":this.name},this.options.HTMLAttributes,e);const o=this.options.renderHTML({options:r,node:t,suggestion:n});return typeof o=="string"?["span",Ct({"data-type":this.name},this.options.HTMLAttributes,e),o]:o},renderText({node:t}){const e={options:this.options,node:t,suggestion:Y2(this,t.attrs.mentionSuggestionChar)};return this.options.renderLabel!==void 0?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),this.options.renderLabel(e)):this.options.renderText(e)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:t,state:e})=>{let n=!1;const{selection:r}=e,{empty:o,anchor:i}=r;if(!o)return!1;e.doc.nodesBetween(i-1,i,(l,u)=>{if(l.type.name===this.name)return n=!0,t.insertText(this.options.deleteTriggerWithBackspace?"":this.options.suggestion.char||"",u,u+l.nodeSize),!1});let s=new fi,a=0;return e.doc.nodesBetween(i-1,i,(l,u)=>{if(l.type.name===this.name)return n=!0,s=l,a=u,!1}),n&&t.insertText(this.options.deleteTriggerWithBackspace?"":s.attrs.mentionSuggestionChar,a,a+s.nodeSize),n})}},addProseMirrorPlugins(){return K2(this).map(rQ)}}),G2=cn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new en({key:new On("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,o=[];if(!n)return null;const i=this.editor.isEmpty;return t.descendants((s,a)=>{const l=r>=a&&r<=a+s.nodeSize,u=!s.isLeaf&&lf(s);if((l||!this.options.showOnlyCurrent)&&u){const f=[this.options.emptyNodeClass];i&&f.push(this.options.emptyEditorClass);const p=Yn.node(a,a+s.nodeSize,{class:f.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:a,hasAnchor:l}):this.options.placeholder});o.push(p)}return this.options.includeChildren}),Jt.create(t,o)}}})]}}),sQ=vr.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",Ct(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),aQ=tn.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",Ct(this.options.HTMLAttributes,t),0]}}),lQ=tn.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",Ct(this.options.HTMLAttributes,t),0]}}),cQ=tn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Ct(this.options.HTMLAttributes,t),0]}}),uQ=/^\s*(\[([( |x])?\])\s$/,dQ=tn.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",Ct(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const o=document.createElement("li"),i=document.createElement("label"),s=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div"),u=()=>{var f,p;a.ariaLabel=((p=(f=this.options.a11y)===null||f===void 0?void 0:f.checkboxLabel)===null||p===void 0?void 0:p.call(f,t,a.checked))||`Task item checkbox for ${t.textContent||"empty task item"}`};return u(),i.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",f=>f.preventDefault()),a.addEventListener("change",f=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}const{checked:p}=f.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:m})=>{const b=n();if(typeof b!="number")return!1;const v=m.doc.nodeAt(b);return m.setNodeMarkup(b,void 0,{...v==null?void 0:v.attrs,checked:p}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,p)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([f,p])=>{o.setAttribute(f,p)}),o.dataset.checked=t.attrs.checked,a.checked=t.attrs.checked,i.append(a,s),o.append(i,l),Object.entries(e).forEach(([f,p])=>{o.setAttribute(f,p)}),{dom:o,contentDOM:l,update:f=>f.type!==this.type?!1:(o.dataset.checked=f.attrs.checked,a.checked=f.attrs.checked,u(),!0)}}},addInputRules(){return[al({find:uQ,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),fQ=tn.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",Ct(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),pQ=cn.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).every(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).every(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),J2=J.forwardRef((t,e)=>{const[n,r]=J.useState(0),o=l=>{if(l>=t.items.length)return;const u=t.items[l],f={id:u.id,label:u.mentionLabel};t.command(f)},i=()=>{r((n+t.items.length-1)%t.items.length)},s=()=>{r((n+1)%t.items.length)},a=()=>{o(n)};return J.useEffect(()=>r(0),[t.items]),J.useImperativeHandle(e,()=>({onKeyDown:({event:l})=>l.key==="ArrowUp"?(i(),!0):l.key==="ArrowDown"?(s(),!0):l.key==="Enter"?(a(),!0):!1})),t.items.length>0?g.jsx(z.Paper,{elevation:5,children:g.jsx(z.List,{dense:!0,sx:{overflow:"hidden"},children:t.items.map((l,u)=>g.jsx(z.ListItem,{disablePadding:!0,children:g.jsx(z.ListItemButton,{selected:u===n,onClick:()=>o(u),children:l.mentionLabel})},l.id))})}):null});J2.displayName="SuggestionList";const X2={bottom:0,height:0,left:0,right:0,top:0,width:0,x:0,y:0,toJSON(){return{}}},hQ={items:async({query:t})=>Promise.resolve(["Lea Thompson","Cyndi Lauper","Tom Cruise","Madonna","Jerry Hall","Joan Collins","Winona Ryder","Christina Applegate","Alyssa Milano","Molly Ringwald","Ally Sheedy","Debbie Harry","Olivia Newton-John","Elton John","Michael J. Fox","Axl Rose","Emilio Estevez","Ralph Macchio","Rob Lowe","Jennifer Grey","Mickey Rourke","John Cusack","Matthew Broderick","Justine Bateman","Lisa Bonet","Benicio Monserrate Rafael del Toro Sánchez"].map((e,n)=>({mentionLabel:e,id:n.toString()})).filter(e=>e.mentionLabel.toLowerCase().startsWith(t.toLowerCase())).slice(0,5)),render:()=>{let t,e;return{onStart:n=>{t=new OO(J2,{props:n,editor:n.editor}),e=au("body",{getReferenceClientRect:()=>{var r;return((r=n.clientRect)==null?void 0:r.call(n))??X2},appendTo:()=>document.body,content:t.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start"})[0]},onUpdate(n){t==null||t.updateProps(n),e==null||e.setProps({getReferenceClientRect:()=>{var r;return((r=n.clientRect)==null?void 0:r.call(n))??X2}})},onKeyDown(n){return n.event.key==="Escape"?(e==null||e.hide(),!0):t!=null&&t.ref?t.ref.onKeyDown(n):!1},onExit(){e==null||e.destroy(),t==null||t.destroy(),e=void 0,t=void 0}}}},mQ=eQ.extend({inclusive:!1}),gQ=sQ.extend({excludes:"superscript"}),yQ=yM.extend({excludes:"subscript"});function bQ({placeholder:t}={}){return J.useMemo(()=>[o7.configure({resizable:!0}),cQ,lQ,aQ,hT,gT,yT,wT,AT,$T,LT,gQ,yQ,FT,dT,uT,mT,DT,Xb,BT,mQ.configure({autolink:!0,linkOnPaste:!0,openOnClick:!1}),H9,xT,z9,pQ.configure({types:["heading","paragraph","image"]}),OZ,MZ,_Z,Bj,UT.configure({multicolor:!0}),IT,r8,bT,fQ,dQ.configure({nested:!0}),iQ.configure({suggestion:hQ}),G2.configure({placeholder:t}),_T],[t])}function Z2(t){return Array.from(t).filter(e=>(e.type||"").toLowerCase().startsWith("image/"))}const vQ=t=>{const e=bQ({placeholder:"Add your own content here..."});if(t.renderContentOnly)return g.jsx(mM,{content:t.renderContentOnly,extensions:e});const{name:n,label:r,labelProps:o={fontSize:"0.9em",color:"#808080",fontWeight:"400"},onUploadFiles:i,readOnly:s=!1}=t,[a,l,u]=Ht.useField({name:n}),{setValue:f}=u,{value:p}=a;J.useEffect(()=>{var S,k,T;(T=(k=(S=m==null?void 0:m.current)==null?void 0:S.editor)==null?void 0:k.commands)==null||T.setContent(p)},[p]);const m=J.useRef(null),b=J.useCallback((S,k)=>{var C;const T=(C=m.current)==null?void 0:C.editor;if(!(!T||!i))if(i instanceof Promise)i(S).then(O=>{ib({images:O,editor:T,position:k})});else{const O=i(S);ib({images:O,editor:T,position:k})}},[]),v=J.useCallback((S,k,T,C)=>{var I;if(!(k instanceof DragEvent)||!k.dataTransfer)return!1;const O=Z2(k.dataTransfer.files);if(O.length>0){const N=(I=S.posAtCoords({left:k.clientX,top:k.clientY}))==null?void 0:I.pos;return b(O,N),k.preventDefault(),!0}return!1},[b]),y=J.useCallback((S,k,T)=>{if(!k.clipboardData)return!1;const C=Z2(k.clipboardData.files);return C.length>0?(b(C),!0):!1},[b]),x=g.jsx(z.Box,{sx:{"& .ProseMirror":{"& h1, & h2, & h3, & h4, & h5, & h6":{scrollMarginTop:s?0:50}}},children:g.jsx(hM,{ref:m,extensions:e,content:p,editable:!s,editorProps:{handleDrop:v,handlePaste:y},renderControls:s?void 0:()=>g.jsx(kZ,{onUploadFiles:i}),onBlur:()=>{var S,k;return f(((k=(S=m.current)==null?void 0:S.editor)==null?void 0:k.getHTML())??"")},RichTextFieldProps:{variant:"outlined",MenuBarProps:{hide:s}},children:()=>g.jsxs(g.Fragment,{children:[g.jsx(k7,{}),g.jsx(R7,{})]})})});return g.jsxs(z.Box,{display:"flex",flexDirection:"column",children:[r&&g.jsx(z.Typography,{...o,children:r}),x]})},Q2=t=>{const{colSpan:e,isExpanded:n,renderExpand:r,obj:o,asMobileCard:i=!1,reRenderExpand:s=!1}=t,[a,l]=J.useState(!1),[u,f]=J.useState(void 0);J.useEffect(()=>{n&&(!a||s)&&(l(!0),f(r(o)))},[n,o]);const p={"&:last-child > td":{borderBottom:"unset"}};return i?g.jsx(z.Collapse,{in:n,children:u}):g.jsx(z.TableRow,{sx:p,children:g.jsx(z.TableCell,{sx:{paddingBottom:0,paddingTop:0},colSpan:e,children:g.jsx(z.Collapse,{in:n,children:u})})})},lv=({isLoading:t,children:e})=>{const[n,r]=J.useState(!1);return J.useEffect(()=>{let o,i;return t?o=setTimeout(()=>r(!0),300):n?i=setTimeout(()=>r(!1),200):(o&&clearTimeout(o),r(!1)),()=>{o&&clearTimeout(o),i&&clearTimeout(i)}},[t,n]),g.jsxs(z.Box,{position:"relative","data-testid":`loading-overlay_${t?"active":"inactive"}`,children:[e,g.jsx(z.Box,{sx:{position:"absolute",top:0,left:0,width:"100%",height:"100%",backgroundColor:"rgba(255,255,255,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,pointerEvents:n?"auto":"none",opacity:n?1:0,transition:"opacity 0.3s ease"},children:g.jsx(z.CircularProgress,{})})]})},Qo=t=>{const{gap:e=1,alignItems:n="center",...r}=t;return g.jsx(z.Box,{display:"flex",flexDirection:"row",gap:e,alignItems:n,...r})},Lu=t=>{const{gap:e=1,...n}=t;return g.jsx(z.Box,{display:"flex",flexDirection:"column",gap:e,...n})};function eI({icon:t,children:e,sx:n,...r}){return e?g.jsx(z.Tooltip,{title:e,children:g.jsx(t,{"data-testid":"MBv2_table-tooltip",fontSize:"small",sx:n??{ml:.5},...r})}):null}function tI(t){return g.jsx(eI,{icon:LU,...t})}const cv=t=>{const{id:e,getRowKey:n=me=>"id"in me&&(typeof me.id=="string"||typeof me.id=="number")&&me.id!=null?me.id:(console.warn(`Table: "id" not found or undefined in ${JSON.stringify(me)}. If provided, id must have a value and be type string or number. Please implement the Table.getRowKey prop so Table knows how to uniquely identify this row.`),String(JSON.stringify(me))),columns:r,data:o=[],onRowClick:i,onRowClickObj:s,checkedKeys:a,setCheckedKeys:l,renderExpand:u,sortField:f,sortOrder:p,onSortChange:m,allowSortCols:b,fixedLayout:v=!1,className:y,emptyTableMsg:x="No items to display",errorTableMsg:S,retryCallback:k,isLoading:T=!1,disableMobileCards:C=!1,highlightSelectedRow:O=!1,selectedRowColor:I,selectedRowKey:N,headerRowStyle:L={},stickyHeader:V,reRenderExpand:M=!1,expandOnRowClick:B=!1,tooltipProps:H={},...F}=t,{palette:P}=z.useTheme(),_=P.grey[P.mode=="dark"?600:50],[D,R]=J.useState(void 0),[j,K]=J.useState(typeof O=="string"||typeof O=="number"?O:void 0);xQ(t);const U=me=>{me!==f?m&&m(me,"asc"):m&&m(f,p==="asc"?"desc":"asc")},Y=me=>f===me?p:null,fe=z.useMediaQuery(z.useTheme().breakpoints.down("sm")),ue=r.filter(me=>!me.hideCol&&(!fe||!me.hideOnMobile));u&&!fe&&ue.unshift({key:"MBv2_Expandable_Column",fieldName:"id",label:"",render:(me,Be)=>{const De=n(Be),yt=D===De;return g.jsx(z.IconButton,{"data-testid":"expand-collapse-btn","aria-label":yt?"collapse row":"expand row",size:"small",onClick:()=>X(De),children:yt?g.jsx(pp,{"data-testid":"collapse-up"}):g.jsx(y0,{"data-testid":"expand-down"})})}}),a&&l&&ue.unshift({key:"MBv2_Checkbox_Column",fieldName:"id",label:"",hideOnMobile:!0,render:(me,Be)=>{const De=n(Be);return g.jsx(z.Checkbox,{onChange:()=>{const yt=a.includes(De);l(yt?a.filter(ct=>ct!==De):[...a,De])},checked:a.includes(De)})}});const pe=m!==void 0,Z=me=>pe?b?b.includes(me):!0:!1,te=g.jsxs(z.Box,{display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"row",children:[g.jsx(BU,{})," ",x]}),ce=g.jsxs(z.Box,{"data-testid":"table-fetch-error-msg",display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"row",children:[g.jsx(fw,{color:"error"})," ",S,k&&g.jsx(z.Button,{variant:"text",onClick:k,children:"Retry?"})]}),ne=()=>{if(S)return g.jsx(z.TableRow,{children:g.jsx(z.TableCell,{colSpan:r.length,align:"center",sx:{borderBottom:"unset"},children:ce})});if(o.length===0)return g.jsx(z.TableRow,{children:g.jsx(z.TableCell,{colSpan:r.length,align:"center",sx:{borderBottom:"unset"},children:te})})},re=()=>{if(S)return ce;if(o.length===0)return te},le=me=>{O&&K(me)},ye=me=>{const Be=n(me);if((i||s)&&(i==null||i(Be),s==null||s(me),le(Be)),u&&B){const De=D===Be?void 0:Be;R(De),le(De)}},X=me=>{const Be=D===me?void 0:me;R(Be),le(Be)},ee=me=>{if(!u)return;const Be=D===n(me);return g.jsxs(g.Fragment,{children:[g.jsxs(z.Button,{"data-testid":"show-more-less-btn",variant:"text",onClick:()=>X(n(me)),children:[Be?g.jsx(pp,{}):g.jsx(y0,{})," Show"," ",Be?"Less":"More"]}),g.jsx(Q2,{colSpan:r.length,isExpanded:n(me)===D,obj:me,renderExpand:De=>u(De),asMobileCard:!0})]})},ie=I??_,we=me=>{const De=(O?j:N)===n(me)?ie:"inherit",yt=i||s||B;return{cursor:yt?"pointer":"default",backgroundColor:De,...u?{"& > td":{borderBottom:"unset"}}:{"&:last-child td":{borderBottom:"unset"}},...yt&&{"&:hover":{backgroundColor:De===ie?oG(De,.1):ie}}}},Ce=me=>g.jsx(tI,{...H,children:me}),Pe=(me,Be)=>{const De=me.find(ct=>ct.key==="MBv2_Checkbox_Column"),yt=ue.filter(ct=>ct.key!=="MBv2_Checkbox_Column");return g.jsxs(Qo,{alignItems:"flex-start",children:[De&&g.jsx(Lu,{children:Ll(De,Be,fe)}),g.jsxs(Lu,{width:"100%",children:[g.jsx("table",{className:"MBv2_Table_Stack",children:g.jsx("tbody",{className:"MBv2_Table_Stack_Body",children:yt.map(ct=>g.jsxs("tr",{className:"MBv2_Table_Stack_Row",children:[g.jsxs("td",{className:`MBv2_Table_Stack_Cell_Label MBv2_Table_Stack_Col_${xn(ct)}`,style:{textWrap:"nowrap"},children:[ct.label??Ln(xn(ct)),Ce(ct.tooltip)]}),g.jsx("td",{className:`MBv2_Table_Stack_Cell_Value MBv2_Table_Stack_Val_${xn(ct)}`,style:{paddingLeft:"10px"},children:Ll(ct,Be,fe)})]},`row-${n(Be)}-${xn(ct)}`))})}),ee(Be)]})]})},Me=()=>g.jsxs("div",{...e?{id:`mobile-table-${e}`}:{},className:y,"data-testid":"mui-table-mobile",children:[pe&&g.jsxs(g.Fragment,{children:[g.jsxs(z.Box,{display:"flex",className:"MBv2_Table_Stack_Sort",children:[g.jsx(z.TextField,{select:!0,sx:{flexGrow:1},size:"small",value:f??"",label:"Sort By...",onChange:me=>U(me.target.value),fullWidth:!0,children:ue.map(me=>{if(Z(xn(me)))return g.jsx(z.MenuItem,{value:xn(me),children:me.label??Ln(xn(me))},`rowHeader-${xn(me)}`)})}),g.jsx(z.IconButton,{onClick:()=>{f&&U(f)},children:g.jsx(UU,{className:`sort-icon-${p}`})})]}),g.jsx(z.Divider,{sx:{margin:"10px 0"}})]}),re()??o.map(me=>g.jsx(z.Card,{className:"MBv2_Table_Stack_Container",sx:{margin:"5px 0",padding:"5px",overflowX:"auto",...we(me)},onClick:()=>ye(me),"data-testid":`card-${n(me)}`,children:Pe(ue,me)},n(me)))]}),Ie=()=>g.jsx(z.TableContainer,{component:z.Card,"data-testid":"mui-table",...e?{tableId:`table-${e}`}:{},className:y,style:V?{maxHeight:V,overflow:"auto"}:{},children:g.jsxs(z.Table,{stickyHeader:V!=="undefined",style:{tableLayout:v?"fixed":"auto"},className:"MBv2_Table",sx:L?{"& .MuiTableCell-head":{...L}}:{},...F,children:[g.jsx(z.TableHead,{className:"MBv2_Table_Head",children:g.jsx(z.TableRow,{className:"MBv2_Table_Head_Row",children:ue.map((me,Be)=>{const De=Z(xn(me));return g.jsx(z.TableCell,{width:Array.isArray(v)?v[Be]:"auto",sx:me.tableCellSx??{},children:g.jsx(z.Box,{style:{display:"flex",alignItems:"center"},children:g.jsxs(z.Box,{sx:[De&&{"&:hover":{cursor:"pointer",backgroundColor:P.mode==="dark"?"#222222":"#ededed",borderRadius:2}}],style:{display:"flex",alignItems:"center",padding:"5px",paddingLeft:"6px",marginLeft:"-6px"},onClick:De?()=>U(xn(me)):void 0,children:[g.jsx("strong",{className:"MBv2_Table_Col_Label",style:{wordBreak:"normal"},"data-testid":"column-title",children:me.label??Ln(xn(me))}),Ce(me.tooltip),De&&Y(xn(me))==="asc"&&g.jsx(pp,{style:{marginLeft:"5px"}}),De&&Y(xn(me))==="desc"&&g.jsx(y0,{style:{marginLeft:"5px"}}),De&&Y(xn(me))!=="asc"&&Y(xn(me))!=="desc"&&g.jsx(WU,{style:{marginLeft:"5px"}})]})})},`rowHeader-${xn(me)}`)})})}),g.jsx(z.TableBody,{className:"MBv2_Table_Body",children:ne()??o.map(me=>g.jsxs(J.Fragment,{children:[g.jsx(z.TableRow,{"data-testid":`row-${n(me)}`,className:"MBv2_Table_Body_Row",onClick:()=>ye(me),sx:we(me),children:ue.map(Be=>g.jsx(z.TableCell,{className:`MBv2_Table_Body_Cell MBv2_Table_Body_Col_${xn(Be)}`,children:Ll(Be,me,fe)},`row-${n(me)}-${xn(Be)}`))}),u&&g.jsx(Q2,{colSpan:ue.length,isExpanded:n(me)===D,obj:me,renderExpand:Be=>u(Be),reRenderExpand:M})]},n(me)))})]})});return g.jsx(lv,{isLoading:T,children:fe&&!C?Me():Ie()})},xQ=t=>{const{fixedLayout:e,checkedKeys:n,setCheckedKeys:r,renderExpand:o,columns:i,expandOnRowClick:s,onRowClick:a,onRowClickObj:l,selectedRowKey:u,highlightSelectedRow:f}=t,p="Table component:";Array.isArray(e)&&(!o&&e.length!==i.length&&console.warn(`${p} Length of "fixedLayout" is not equal to the length of "columns". Got=${e.length}. Expected=${i.length}`),o&&e.length!==i.length+1&&console.warn(`${p} Length of "fixedLayout" is not equal to the length of "columns"+1. Make sure you're including a percentage for the expand/collapse column AND each column in "columns".`)),s&&!o&&console.warn(`${p} renderExpand should be defined when expandOnRowClick is defined`),a&&l&&console.warn(`${p} 'onRowClick' and 'onRowClickObj' are both defined. Only one should be defined.`),(n||r)&&o&&console.warn(`${p} checkedKeys/setCheckedKeys & renderExpand cannot both be defined`),n&&!r&&console.warn(`${p} if checkedKeys is defined, setCheckedKeys must also be defined`),!n&&r&&console.warn(`${p} if setCheckedKeys is defined, checkedKeys must also be defined`);const m=i.map(y=>xn(y)),b=m.filter((y,x)=>m.indexOf(y)!==x),v=[...new Set(b)];v.length>0&&console.warn(`${p} duplicate key/fieldName found in 'columns': ${v.join(", ")}. Make sure to define a unique 'key' if you have multiple column definitions with the same 'fieldName'.`),f&&u&&console.warn(`${p} must choose 'highlightSelectedRow' (uncontrolled) or 'selectedRowKey' (controlled)`)},xn=t=>t.key??t.fieldName,wQ=(t,e)=>e.split(".").reduce((n,r)=>{if(n&&typeof n=="object")return n[r]},t),Ll=(t,e,n=!1)=>{const r=wQ(e,t.fieldName);return t.render?t.render(r,e,n):r},nI=t=>{const{paginationState:e,onPageChange:n,onRowsPerPageChange:r,hidePaginationControls:o=!1,rowsPerPageOptions:i=[5,10,25],...s}=t,{pageNo:a,pageSize:l,totalCount:u,sortField:f,sortOrder:p}=e,m=x=>{n(x)},b=x=>{r(parseInt(x.target.value,10))},v=z.useMediaQuery(z.useTheme().breakpoints.down("sm")),y=!t.data||t.data&&t.data.length===0;return g.jsxs(z.Box,{children:[g.jsx(cv,{sortOrder:p,sortField:f,...s}),!o&&!y&&g.jsx(z.TablePagination,{"data-testid":"pagination-controls",component:"div",rowsPerPageOptions:v?[]:i,count:u,rowsPerPage:l,page:a,onPageChange:(x,S)=>m(S),onRowsPerPageChange:b,sx:{flexGrow:1,marginRight:{xs:0,md:15}}})]})},rI=()=>({height:window.innerHeight,width:window.innerWidth}),oI=()=>{const[t,e]=J.useState(rI());return J.useEffect(()=>{const n=()=>{e(rI())};return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),t},Tr=t=>{const{name:e="button",color:n="primary",fullWidthOnMobile:r=!0,type:o="button",variant:i="contained"}=t,{width:s}=oI(),a=["locationInBar","closeDialog","fullWidthOnMobile"],l=r&&s<600;return g.jsx(z.Button,{role:"button",name:e,color:n,variant:i,type:o,fullWidth:t.fullWidth?!0:l,...lr({...t},a)})},SQ=t=>{const{citation:e,anchorEl:n,onDeleteCitation:r,onClose:o}=t;if(r)return g.jsx(z.Popper,{open:e!==null,anchorEl:n,placement:"bottom-end",style:{zIndex:1300},children:e&&g.jsxs(z.Box,{component:z.Paper,p:1,display:"flex",gap:1,boxShadow:9,"data-testid":`citation-table_delete-prompt-${e.id}`,children:[g.jsxs(z.Typography,{variant:"body2",children:["Are you sure you want to delete this ",e.fileName?"attachment":"citation","?"]}),g.jsxs(z.Box,{display:"flex",flexDirection:"row",children:[g.jsx(Tr,{size:"small",variant:"text",onClick:o,"data-testid":`citation-table_delete-prompt-${e.id}-noBtn`,children:"No"}),g.jsx(Tr,{size:"small",color:"error",startIcon:g.jsx(e0,{}),onClick:()=>r(e.id).finally(o),"data-testid":`citation-table_delete-prompt-${e.id}-yesBtn`,children:"Yes"})]})]})})},CQ=t=>{const{citation:e,anchorEl:n,onClose:r,open:o}=t;return g.jsx(z.Popper,{open:o,anchorEl:n,placement:"bottom-end",style:{zIndex:1300},children:e&&g.jsxs(z.Box,{component:z.Paper,p:1,display:"flex",gap:1,boxShadow:9,"data-testid":`citation-table_launch-link-prompt-${e.id}`,flexDirection:"column",alignItems:"end",children:[g.jsxs(z.Typography,{variant:"body2",sx:{wordBreak:"break-all",maxWidth:"350px"},children:["Are you sure you want to go to ",g.jsx("br",{}),g.jsx("b",{children:e.url}),"?"]}),g.jsxs(z.Box,{display:"flex",flexDirection:"row",children:[g.jsx(Tr,{size:"small",variant:"text",onClick:r,"data-testid":`citation-table_launch-prompt-${e.id}-noBtn`,children:"No"}),g.jsx(Tr,{size:"small",startIcon:g.jsx(b0,{}),onClick:()=>{window.open(e.url,"_blank","noopener,noreferrer"),r()},"data-testid":`citation-table_launch-prompt-${e.id}-yesBtn`,children:"Yes"})]})]})})};function uv({canLaunchUrl:t,citation:e,asLink:n}){const r=J.useRef(null),[o,i]=J.useState(!1),s=()=>{i(!1)};return!t||e.fileName?null:g.jsxs(g.Fragment,{children:[n?g.jsx(z.Link,{ref:r,component:"button",sx:{cursor:"pointer"},type:"button",onClick:()=>i(!0),children:e.url}):g.jsx(z.Tooltip,{title:"Open URL",children:g.jsx(z.IconButton,{ref:r,color:"primary",onClick:()=>{i(!0)},"data-testid":`citation-table_launch-link-btn-${e.id}`,sx:{visibility:t!=null&&t(e)?"visible":"hidden"},children:g.jsx(b0,{})})}),g.jsx(CQ,{citation:e,anchorEl:r.current,onClose:s,open:o})]})}function iI({onDownloadAttachment:t,citation:e}){if(!(!t||!e.fileName))return g.jsx(z.Tooltip,{title:"Download",children:g.jsx(z.IconButton,{color:"primary",onClick:()=>t==null?void 0:t(e),"data-testid":`citation-table_download-btn-${e.id}`,children:g.jsx(NU,{})})})}function sI({onPreviewAttachment:t,citation:e}){if(!t||!e.fileName)return;const n=["pdf","png","jpg","jpeg","gif","bmp","svg","webp","mp3","wav","mp4","webm","html","htm","txt","xml","json","csv"],r=e.fileName.split(".").pop();if(!(!r||!n.includes(r)))return g.jsx(z.Tooltip,{title:"View File",children:g.jsx(z.IconButton,{color:"primary",onClick:()=>t==null?void 0:t(e),"data-testid":`citation-table_view-file-btn-${e.id}`,children:g.jsx(b0,{})})})}const dv=(t,e=30)=>ma.truncate(t,{length:e,omission:"..."}),TQ=t=>{const{refreshKey:e,title:n,onCancel:r,onNewCitation:o,onNewAttachment:i,onEditCitation:s,onEditAttachment:a,onViewCitation:l,onViewAttachment:u,onDeleteCitation:f,onDownloadAttachment:p,onPreviewAttachment:m,onSelect:b,getCitationsPaginated:v,selectedIds:y,setSelectedIds:x,onError:S=()=>{},condenseTable:k=!1,canSelect:T=!1,canLaunchUrl:C,addlActions:O,readOnly:I=!1,showCloseBtn:N=!1,canSearch:L=!1}=t,V=!!t.canCreate&&!I,M=!!a&&!!s&&!I,B=!!u&&!!l&&I&&k,H=!!f&&!I,{palette:F}=z.useTheme(),[P,_]=J.useState([]),[D,R]=J.useState(!1),[j,K]=J.useState(!0),[U,Y]=J.useState(null),[fe,ue]=J.useState(null),[pe,Z]=J.useState({pageNo:0,pageSize:k?5:10,totalCount:0,search:L?"":void 0}),te=()=>{R(!1),K(!0),v({pageNo:pe.pageNo,pageSize:pe.pageSize,search:pe.search},y).then(Ie=>(_(Ie.data),Z(me=>({...me,totalCount:Ie.totalCount})),Ie)).catch(Ie=>{S(Ie),R(!0),_([])}).finally(()=>K(!1))};J.useEffect(te,[pe.pageNo,pe.pageSize,e,pe.search]);const ce=()=>{ue(null),Y(null)},ne=g.jsx(Tr,{variant:T?"outlined":"contained",size:T?"small":"medium",onClick:o,startIcon:g.jsx(Hf,{}),children:"Add Citation"}),re=g.jsx(Tr,{variant:T?"outlined":"contained",size:T?"small":"medium",onClick:i,startIcon:g.jsx(YM,{}),children:"Add Attachment"}),le=Ie=>{if(!(!M&&!B)){if(M)return g.jsx(z.Tooltip,{title:"Edit",children:g.jsx(z.IconButton,{color:"primary",onClick:()=>Ie.fileName?a(Ie.id):s(Ie.id),"data-testid":`citation-table_edit-btn-${Ie.id}`,children:g.jsx($U,{})})});if(B)return g.jsx(z.Tooltip,{title:"View",children:g.jsx(z.IconButton,{color:"primary",onClick:()=>Ie.fileName?u(Ie.id):l(Ie.id),"data-testid":`citation-table_view-btn-${Ie.id}`,children:g.jsx(qU,{})})})}},ye=Ie=>{if(!(!H||I))return g.jsx(z.Tooltip,{title:"Delete",children:g.jsx(z.IconButton,{color:"error",onClick:me=>{ue(Ie),Y(me.currentTarget)},"data-testid":`citation-table_delete-btn-${Ie.id}`,children:g.jsx(e0,{})})})},X=Ie=>g.jsx(uv,{citation:Ie,canLaunchUrl:C}),ee=Ie=>g.jsx(sI,{citation:Ie,onPreviewAttachment:m}),ie=Ie=>g.jsx(iI,{citation:Ie,onDownloadAttachment:p}),we=B||M||H||C||m||p||O,Ce=[...lI(F,k),{fieldName:"id",key:"Action",label:"Action",hideCol:!we,render:(Ie,me)=>g.jsxs(z.Box,{display:"flex",flexDirection:"row-reverse",children:[O==null?void 0:O(me),ye(me),le(me),ee(me),X(me),ie(me)]})}],Pe=J.useCallback(Ie=>{Z(me=>({...me,pageNo:0,search:Ie}))},[]),Me=()=>L?g.jsx(XM,{onSearch:Pe}):null;return g.jsxs(Lu,{children:[g.jsxs(z.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[g.jsx(z.Typography,{variant:k?"h6":"h2",children:n}),!T&&V&&g.jsxs(z.Box,{display:"flex",flexDirection:"row",gap:1,children:[ne,re]}),N&&g.jsx(z.IconButton,{onClick:r,children:g.jsx(fp,{})})]}),Me(),g.jsx(nI,{"data-testid":"citation-table",size:k?"x-small":"medium",isLoading:j,columns:Ce,data:P,paginationState:pe,onPageChange:Ie=>Z(me=>({...me,pageNo:Ie})),onRowsPerPageChange:Ie=>Z(me=>({...me,pageSize:Ie,pageNo:0})),errorTableMsg:D?"Failed to load citations.":void 0,retryCallback:te,setCheckedKeys:T?x:void 0,checkedKeys:T?y:void 0}),T&&g.jsxs(z.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",children:[g.jsx(z.Box,{display:"flex",flexDirection:"row",gap:".25rem",children:V&&g.jsxs(g.Fragment,{children:[ne,re]})}),!I&&g.jsxs(z.Box,{display:"flex",flexDirection:"row",gap:".25rem",children:[g.jsx(Tr,{variant:"outlined",size:"small",onClick:r,children:"Cancel"}),g.jsxs(Tr,{variant:"contained",size:"small",onClick:()=>b(y),children:["Select",y.length>0&&` (${y.length})`]})]})]}),g.jsx(SQ,{citation:fe,anchorEl:U,onDeleteCitation:f,onClose:ce})]})},aI=(t,e)=>{const n=t?dv(e):e,r=n==null?void 0:n.endsWith("...");return g.jsx("span",{style:{wordBreak:"break-all"},children:r?g.jsx(z.Tooltip,{title:e,children:g.jsx("span",{children:n})}):e})},lI=(t,e=!1)=>[{fieldName:"fileName",key:"CitationOrAttachment",label:"Type",render:(n,r)=>g.jsx(z.Tooltip,{title:n?"Attachment":"URL",children:n?g.jsx(YM,{sx:{color:t.grey[500],marginTop:"4px"},"data-testid":`attachment-icon-${r.id}`}):g.jsx(Hf,{sx:{color:t.grey[500],marginTop:"6px"},"data-testid":`url-icon-${r.id}`})}),ignoreDiff:!0},{fieldName:"title",render:n=>aI(e,n)},{fieldName:"fileName",key:"URL/File Name",label:"URL/Other Identifier/File Name",render:(n,r)=>aI(e,n||r.url),isEqual:(n,r)=>n.fileName&&r.fileName?n.fileName===r.fileName:n.url===r.url},{fieldName:"source",hideCol:e},{fieldName:"details",hideCol:e},{fieldName:"accessedAt",hideCol:e,render:(n,r)=>{if(!r.fileName)return(n==null?void 0:n.slice(0,10))??""}},{fieldName:"classification",hideCol:e}];var fv,cI;function kQ(){if(cI)return fv;cI=1;function t(S){this._maxSize=S,this.clear()}t.prototype.clear=function(){this._size=0,this._values=Object.create(null)},t.prototype.get=function(S){return this._values[S]},t.prototype.set=function(S,k){return this._size>=this._maxSize&&this.clear(),S in this._values||this._size++,this._values[S]=k};var e=/[^.^\]^[]+|(?=\[\]|\.\.)/g,n=/^\d+$/,r=/^\d/,o=/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,i=/^\s*(['"]?)(.*?)(\1)\s*$/,s=512,a=new t(s),l=new t(s),u=new t(s);fv={Cache:t,split:p,normalizePath:f,setter:function(S){var k=f(S);return l.get(S)||l.set(S,function(C,O){for(var I=0,N=k.length,L=C;I<N-1;){var V=k[I];if(V==="__proto__"||V==="constructor"||V==="prototype")return C;L=L[k[I++]]}L[k[I]]=O})},getter:function(S,k){var T=f(S);return u.get(S)||u.set(S,function(O){for(var I=0,N=T.length;I<N;)if(O!=null||!k)O=O[T[I++]];else return;return O})},join:function(S){return S.reduce(function(k,T){return k+(b(T)||n.test(T)?"["+T+"]":(k?".":"")+T)},"")},forEach:function(S,k,T){m(Array.isArray(S)?S:p(S),k,T)}};function f(S){return a.get(S)||a.set(S,p(S).map(function(k){return k.replace(i,"$2")}))}function p(S){return S.match(e)||[""]}function m(S,k,T){var C=S.length,O,I,N,L;for(I=0;I<C;I++)O=S[I],O&&(x(O)&&(O='"'+O+'"'),L=b(O),N=!L&&/^\d+$/.test(O),k.call(T,O,L,N,I,S))}function b(S){return typeof S=="string"&&S&&["'",'"'].indexOf(S.charAt(0))!==-1}function v(S){return S.match(r)&&!S.match(n)}function y(S){return o.test(S)}function x(S){return!b(S)&&(v(S)||y(S))}return fv}var Ca=kQ(),pv,uI;function EQ(){if(uI)return pv;uI=1;const t=/[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g,e=f=>f.match(t)||[],n=f=>f[0].toUpperCase()+f.slice(1),r=(f,p)=>e(f).join(p).toLowerCase(),o=f=>e(f).reduce((p,m)=>`${p}${p?m[0].toUpperCase()+m.slice(1).toLowerCase():m.toLowerCase()}`,"");return pv={words:e,upperFirst:n,camelCase:o,pascalCase:f=>n(o(f)),snakeCase:f=>r(f,"_"),kebabCase:f=>r(f,"-"),sentenceCase:f=>n(r(f," ")),titleCase:f=>e(f).map(n).join(" ")},pv}var hv=EQ(),Th={exports:{}},dI;function OQ(){if(dI)return Th.exports;dI=1,Th.exports=function(o){return t(e(o),o)},Th.exports.array=t;function t(o,i){var s=o.length,a=new Array(s),l={},u=s,f=n(i),p=r(o);for(i.forEach(function(b){if(!p.has(b[0])||!p.has(b[1]))throw new Error("Unknown node. There is an unknown node in the supplied edges.")});u--;)l[u]||m(o[u],u,new Set);return a;function m(b,v,y){if(y.has(b)){var x;try{x=", node was:"+JSON.stringify(b)}catch{x=""}throw new Error("Cyclic dependency"+x)}if(!p.has(b))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(b));if(!l[v]){l[v]=!0;var S=f.get(b)||new Set;if(S=Array.from(S),v=S.length){y.add(b);do{var k=S[--v];m(k,p.get(k),y)}while(v);y.delete(b)}a[--s]=b}}}function e(o){for(var i=new Set,s=0,a=o.length;s<a;s++){var l=o[s];i.add(l[0]),i.add(l[1])}return Array.from(i)}function n(o){for(var i=new Map,s=0,a=o.length;s<a;s++){var l=o[s];i.has(l[0])||i.set(l[0],new Set),i.has(l[1])||i.set(l[1],new Set),i.get(l[0]).add(l[1])}return i}function r(o){for(var i=new Map,s=0,a=o.length;s<a;s++)i.set(o[s],s);return i}return Th.exports}var MQ=OQ();const _Q=Un(MQ),IQ=Object.prototype.toString,DQ=Error.prototype.toString,AQ=RegExp.prototype.toString,PQ=typeof Symbol<"u"?Symbol.prototype.toString:()=>"",NQ=/^Symbol\((.*)\)(.*)$/;function $Q(t){return t!=+t?"NaN":t===0&&1/t<0?"-0":""+t}function fI(t,e=!1){if(t==null||t===!0||t===!1)return""+t;const n=typeof t;if(n==="number")return $Q(t);if(n==="string")return e?`"${t}"`:t;if(n==="function")return"[Function "+(t.name||"anonymous")+"]";if(n==="symbol")return PQ.call(t).replace(NQ,"Symbol($1)");const r=IQ.call(t).slice(8,-1);return r==="Date"?isNaN(t.getTime())?""+t:t.toISOString(t):r==="Error"||t instanceof Error?"["+DQ.call(t)+"]":r==="RegExp"?AQ.call(t):null}function Ss(t,e){let n=fI(t,e);return n!==null?n:JSON.stringify(t,function(r,o){let i=fI(this[r],e);return i!==null?i:o},2)}function pI(t){return t==null?[]:[].concat(t)}let hI,mI,gI,LQ=/\$\{\s*(\w+)\s*\}/g;hI=Symbol.toStringTag;class yI{constructor(e,n,r,o){this.name=void 0,this.message=void 0,this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=void 0,this.inner=void 0,this[hI]="Error",this.name="ValidationError",this.value=n,this.path=r,this.type=o,this.errors=[],this.inner=[],pI(e).forEach(i=>{if(pr.isError(i)){this.errors.push(...i.errors);const s=i.inner.length?i.inner:[i];this.inner.push(...s)}else this.errors.push(i)}),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0]}}mI=Symbol.hasInstance,gI=Symbol.toStringTag;class pr extends Error{static formatError(e,n){const r=n.label||n.path||"this";return n=Object.assign({},n,{path:r,originalPath:n.path}),typeof e=="string"?e.replace(LQ,(o,i)=>Ss(n[i])):typeof e=="function"?e(n):e}static isError(e){return e&&e.name==="ValidationError"}constructor(e,n,r,o,i){const s=new yI(e,n,r,o);if(i)return s;super(),this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=[],this.inner=[],this[gI]="Error",this.name=s.name,this.message=s.message,this.type=s.type,this.value=s.value,this.path=s.path,this.errors=s.errors,this.inner=s.inner,Error.captureStackTrace&&Error.captureStackTrace(this,pr)}static[mI](e){return yI[Symbol.hasInstance](e)||super[Symbol.hasInstance](e)}}let ei={default:"${path} is invalid",required:"${path} is a required field",defined:"${path} must be defined",notNull:"${path} cannot be null",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:t,type:e,value:n,originalValue:r})=>{const o=r!=null&&r!==n?` (cast from the value \`${Ss(r,!0)}\`).`:".";return e!=="mixed"?`${t} must be a \`${e}\` type, but the final value was: \`${Ss(n,!0)}\``+o:`${t} must match the configured type. The validated value was: \`${Ss(n,!0)}\``+o}},kr={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",datetime:"${path} must be a valid ISO date-time",datetime_precision:"${path} must be a valid ISO date-time with a sub-second precision of exactly ${precision} digits",datetime_offset:'${path} must be a valid ISO date-time with UTC "Z" timezone',trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"},BQ={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"},mv={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},FQ={isValue:"${path} field must be ${value}"},kh={noUnknown:"${path} field has unspecified keys: ${unknown}",exact:"${path} object contains unknown properties: ${properties}"};Object.assign(Object.create(null),{mixed:ei,string:kr,number:BQ,date:mv,object:kh,array:{min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"},boolean:FQ,tuple:{notType:t=>{const{path:e,value:n,spec:r}=t,o=r.types.length;if(Array.isArray(n)){if(n.length<o)return`${e} tuple value has too few items, expected a length of ${o} but got ${n.length} for value: \`${Ss(n,!0)}\``;if(n.length>o)return`${e} tuple value has too many items, expected a length of ${o} but got ${n.length} for value: \`${Ss(n,!0)}\``}return pr.formatError(ei.notType,t)}}});const gv=t=>t&&t.__isYupSchema__;class Eh{static fromOptions(e,n){if(!n.then&&!n.otherwise)throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");let{is:r,then:o,otherwise:i}=n,s=typeof r=="function"?r:(...a)=>a.every(l=>l===r);return new Eh(e,(a,l)=>{var u;let f=s(...a)?o:i;return(u=f==null?void 0:f(l))!=null?u:l})}constructor(e,n){this.fn=void 0,this.refs=e,this.refs=e,this.fn=n}resolve(e,n){let r=this.refs.map(i=>i.getValue(n==null?void 0:n.value,n==null?void 0:n.parent,n==null?void 0:n.context)),o=this.fn(r,e,n);if(o===void 0||o===e)return e;if(!gv(o))throw new TypeError("conditions must return a schema object");return o.resolve(n)}}const Oh={context:"$",value:"."};class Ta{constructor(e,n={}){if(this.key=void 0,this.isContext=void 0,this.isValue=void 0,this.isSibling=void 0,this.path=void 0,this.getter=void 0,this.map=void 0,typeof e!="string")throw new TypeError("ref must be a string, got: "+e);if(this.key=e.trim(),e==="")throw new TypeError("ref must be a non-empty string");this.isContext=this.key[0]===Oh.context,this.isValue=this.key[0]===Oh.value,this.isSibling=!this.isContext&&!this.isValue;let r=this.isContext?Oh.context:this.isValue?Oh.value:"";this.path=this.key.slice(r.length),this.getter=this.path&&Ca.getter(this.path,!0),this.map=n.map}getValue(e,n,r){let o=this.isContext?r:this.isValue?e:n;return this.getter&&(o=this.getter(o||{})),this.map&&(o=this.map(o)),o}cast(e,n){return this.getValue(e,n==null?void 0:n.parent,n==null?void 0:n.context)}resolve(){return this}describe(){return{type:"ref",key:this.key}}toString(){return`Ref(${this.key})`}static isRef(e){return e&&e.__isYupRef}}Ta.prototype.__isYupRef=!0;const ka=t=>t==null;function Bl(t){function e({value:n,path:r="",options:o,originalValue:i,schema:s},a,l){const{name:u,test:f,params:p,message:m,skipAbsent:b}=t;let{parent:v,context:y,abortEarly:x=s.spec.abortEarly,disableStackTrace:S=s.spec.disableStackTrace}=o;const k={value:n,parent:v,context:y};function T(B={}){const H=bI(Object.assign({value:n,originalValue:i,label:s.spec.label,path:B.path||r,spec:s.spec,disableStackTrace:B.disableStackTrace||S},p,B.params),k),F=new pr(pr.formatError(B.message||m,H),n,H.path,B.type||u,H.disableStackTrace);return F.params=H,F}const C=x?a:l;let O={path:r,parent:v,type:u,from:o.from,createError:T,resolve(B){return vI(B,k)},options:o,originalValue:i,schema:s};const I=B=>{pr.isError(B)?C(B):B?l(null):C(T())},N=B=>{pr.isError(B)?C(B):a(B)};if(b&&ka(n))return I(!0);let V;try{var M;if(V=f.call(O,n,O),typeof((M=V)==null?void 0:M.then)=="function"){if(o.sync)throw new Error(`Validation test of type: "${O.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`);return Promise.resolve(V).then(I,N)}}catch(B){N(B);return}I(V)}return e.OPTIONS=t,e}function bI(t,e){if(!t)return t;for(const n of Object.keys(t))t[n]=vI(t[n],e);return t}function vI(t,e){return Ta.isRef(t)?t.getValue(e.value,e.parent,e.context):t}function RQ(t,e,n,r=n){let o,i,s;return e?(Ca.forEach(e,(a,l,u)=>{let f=l?a.slice(1,a.length-1):a;t=t.resolve({context:r,parent:o,value:n});let p=t.type==="tuple",m=u?parseInt(f,10):0;if(t.innerType||p){if(p&&!u)throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${s}" must contain an index to the tuple element, e.g. "${s}[0]"`);if(n&&m>=n.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${a}, in the path: ${e}. because there is no value at that index. `);o=n,n=n&&n[m],t=p?t.spec.types[m]:t.innerType}if(!u){if(!t.fields||!t.fields[f])throw new Error(`The schema does not contain the path: ${e}. (failed at: ${s} which is a type: "${t.type}")`);o=n,n=n&&n[f],t=t.fields[f]}i=f,s=l?"["+a+"]":"."+a}),{schema:t,parent:o,parentPath:i}):{parent:o,parentPath:e,schema:t}}class Mh extends Set{describe(){const e=[];for(const n of this.values())e.push(Ta.isRef(n)?n.describe():n);return e}resolveAll(e){let n=[];for(const r of this.values())n.push(e(r));return n}clone(){return new Mh(this.values())}merge(e,n){const r=this.clone();return e.forEach(o=>r.add(o)),n.forEach(o=>r.delete(o)),r}}function Fl(t,e=new Map){if(gv(t)||!t||typeof t!="object")return t;if(e.has(t))return e.get(t);let n;if(t instanceof Date)n=new Date(t.getTime()),e.set(t,n);else if(t instanceof RegExp)n=new RegExp(t),e.set(t,n);else if(Array.isArray(t)){n=new Array(t.length),e.set(t,n);for(let r=0;r<t.length;r++)n[r]=Fl(t[r],e)}else if(t instanceof Map){n=new Map,e.set(t,n);for(const[r,o]of t.entries())n.set(r,Fl(o,e))}else if(t instanceof Set){n=new Set,e.set(t,n);for(const r of t)n.add(Fl(r,e))}else if(t instanceof Object){n={},e.set(t,n);for(const[r,o]of Object.entries(t))n[r]=Fl(o,e)}else throw Error(`Unable to clone ${t}`);return n}function zQ(t){if(!(t!=null&&t.length))return;const e=[];let n="",r=!1,o=!1;for(let i=0;i<t.length;i++){const s=t[i];if(s==="["&&!o){n&&(e.push(...n.split(".").filter(Boolean)),n=""),r=!0;continue}if(s==="]"&&!o){n&&(/^\d+$/.test(n)?e.push(n):e.push(n.replace(/^"|"$/g,"")),n=""),r=!1;continue}if(s==='"'){o=!o;continue}if(s==="."&&!r&&!o){n&&(e.push(n),n="");continue}n+=s}return n&&e.push(...n.split(".").filter(Boolean)),e}function VQ(t,e){const n=e?`${e}.${t.path}`:t.path;return t.errors.map(r=>({message:r,path:zQ(n)}))}function xI(t,e){var n;if(!((n=t.inner)!=null&&n.length)&&t.errors.length)return VQ(t,e);const r=e?`${e}.${t.path}`:t.path;return t.inner.flatMap(o=>xI(o,r))}class ti{constructor(e){this.type=void 0,this.deps=[],this.tests=void 0,this.transforms=void 0,this.conditions=[],this._mutate=void 0,this.internalTests={},this._whitelist=new Mh,this._blacklist=new Mh,this.exclusiveTests=Object.create(null),this._typeCheck=void 0,this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation(()=>{this.typeError(ei.notType)}),this.type=e.type,this._typeCheck=e.check,this.spec=Object.assign({strip:!1,strict:!1,abortEarly:!0,recursive:!0,disableStackTrace:!1,nullable:!1,optional:!0,coerce:!0},e==null?void 0:e.spec),this.withMutation(n=>{n.nonNullable()})}get _type(){return this.type}clone(e){if(this._mutate)return e&&Object.assign(this.spec,e),this;const n=Object.create(Object.getPrototypeOf(this));return n.type=this.type,n._typeCheck=this._typeCheck,n._whitelist=this._whitelist.clone(),n._blacklist=this._blacklist.clone(),n.internalTests=Object.assign({},this.internalTests),n.exclusiveTests=Object.assign({},this.exclusiveTests),n.deps=[...this.deps],n.conditions=[...this.conditions],n.tests=[...this.tests],n.transforms=[...this.transforms],n.spec=Fl(Object.assign({},this.spec,e)),n}label(e){let n=this.clone();return n.spec.label=e,n}meta(...e){if(e.length===0)return this.spec.meta;let n=this.clone();return n.spec.meta=Object.assign(n.spec.meta||{},e[0]),n}withMutation(e){let n=this._mutate;this._mutate=!0;let r=e(this);return this._mutate=n,r}concat(e){if(!e||e===this)return this;if(e.type!==this.type&&this.type!=="mixed")throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${e.type}`);let n=this,r=e.clone();const o=Object.assign({},n.spec,r.spec);return r.spec=o,r.internalTests=Object.assign({},n.internalTests,r.internalTests),r._whitelist=n._whitelist.merge(e._whitelist,e._blacklist),r._blacklist=n._blacklist.merge(e._blacklist,e._whitelist),r.tests=n.tests,r.exclusiveTests=n.exclusiveTests,r.withMutation(i=>{e.tests.forEach(s=>{i.test(s.OPTIONS)})}),r.transforms=[...n.transforms,...r.transforms],r}isType(e){return e==null?!!(this.spec.nullable&&e===null||this.spec.optional&&e===void 0):this._typeCheck(e)}resolve(e){let n=this;if(n.conditions.length){let r=n.conditions;n=n.clone(),n.conditions=[],n=r.reduce((o,i)=>i.resolve(o,e),n),n=n.resolve(e)}return n}resolveOptions(e){var n,r,o,i;return Object.assign({},e,{from:e.from||[],strict:(n=e.strict)!=null?n:this.spec.strict,abortEarly:(r=e.abortEarly)!=null?r:this.spec.abortEarly,recursive:(o=e.recursive)!=null?o:this.spec.recursive,disableStackTrace:(i=e.disableStackTrace)!=null?i:this.spec.disableStackTrace})}cast(e,n={}){let r=this.resolve(Object.assign({},n,{value:e})),o=n.assert==="ignore-optionality",i=r._cast(e,n);if(n.assert!==!1&&!r.isType(i)){if(o&&ka(i))return i;let s=Ss(e),a=Ss(i);throw new TypeError(`The value of ${n.path||"field"} could not be cast to a value that satisfies the schema type: "${r.type}".
406
406
 
407
407
  attempted value: ${s}
408
- `+(a!==s?`result of cast: ${a}`:""))}return i}_cast(e,n){let r=e===void 0?e:this.transforms.reduce((o,i)=>i.call(this,o,e,this,n),e);return r===void 0&&(r=this.getDefault(n)),r}_validate(e,n={},r,o){let{path:i,originalValue:s=e,strict:a=this.spec.strict}=n,l=e;a||(l=this._cast(l,Object.assign({assert:!1},n)));let u=[];for(let f of Object.values(this.internalTests))f&&u.push(f);this.runTests({path:i,value:l,originalValue:s,options:n,tests:u},r,f=>{if(f.length)return o(f,l);this.runTests({path:i,value:l,originalValue:s,options:n,tests:this.tests},r,o)})}runTests(e,n,r){let o=!1,{tests:i,value:s,originalValue:a,path:l,options:u}=e,f=y=>{o||(o=!0,n(y,s))},p=y=>{o||(o=!0,r(y,s))},m=i.length,b=[];if(!m)return p([]);let v={value:s,originalValue:a,path:l,options:u,schema:this};for(let y=0;y<i.length;y++){const x=i[y];x(v,f,function(k){k&&(Array.isArray(k)?b.push(...k):b.push(k)),--m<=0&&p(b)})}}asNestedTest({key:e,index:n,parent:r,parentPath:o,originalParent:i,options:s}){const a=e??n;if(a==null)throw TypeError("Must include `key` or `index` for nested validations");const l=typeof a=="number";let u=r[a];const f=Object.assign({},s,{strict:!0,parent:r,value:u,originalValue:i[a],key:void 0,[l?"index":"key"]:a,path:l||a.includes(".")?`${o||""}[${l?a:`"${a}"`}]`:(o?`${o}.`:"")+e});return(p,m,b)=>this.resolve(f)._validate(u,f,m,b)}validate(e,n){var r;let o=this.resolve(Object.assign({},n,{value:e})),i=(r=n==null?void 0:n.disableStackTrace)!=null?r:o.spec.disableStackTrace;return new Promise((s,a)=>o._validate(e,n,(l,u)=>{pr.isError(l)&&(l.value=u),a(l)},(l,u)=>{l.length?a(new pr(l,u,void 0,void 0,i)):s(u)}))}validateSync(e,n){var r;let o=this.resolve(Object.assign({},n,{value:e})),i,s=(r=n==null?void 0:n.disableStackTrace)!=null?r:o.spec.disableStackTrace;return o._validate(e,Object.assign({},n,{sync:!0}),(a,l)=>{throw pr.isError(a)&&(a.value=l),a},(a,l)=>{if(a.length)throw new pr(a,e,void 0,void 0,s);i=l}),i}isValid(e,n){return this.validate(e,n).then(()=>!0,r=>{if(pr.isError(r))return!1;throw r})}isValidSync(e,n){try{return this.validateSync(e,n),!0}catch(r){if(pr.isError(r))return!1;throw r}}_getDefault(e){let n=this.spec.default;return n==null?n:typeof n=="function"?n.call(this,e):Fl(n)}getDefault(e){return this.resolve(e||{})._getDefault(e)}default(e){return arguments.length===0?this._getDefault():this.clone({default:e})}strict(e=!0){return this.clone({strict:e})}nullability(e,n){const r=this.clone({nullable:e});return r.internalTests.nullable=Bl({message:n,name:"nullable",test(o){return o===null?this.schema.spec.nullable:!0}}),r}optionality(e,n){const r=this.clone({optional:e});return r.internalTests.optionality=Bl({message:n,name:"optionality",test(o){return o===void 0?this.schema.spec.optional:!0}}),r}optional(){return this.optionality(!0)}defined(e=ei.defined){return this.optionality(!1,e)}nullable(){return this.nullability(!0)}nonNullable(e=ei.notNull){return this.nullability(!1,e)}required(e=ei.required){return this.clone().withMutation(n=>n.nonNullable(e).defined(e))}notRequired(){return this.clone().withMutation(e=>e.nullable().optional())}transform(e){let n=this.clone();return n.transforms.push(e),n}test(...e){let n;if(e.length===1?typeof e[0]=="function"?n={test:e[0]}:n=e[0]:e.length===2?n={name:e[0],test:e[1]}:n={name:e[0],message:e[1],test:e[2]},n.message===void 0&&(n.message=ei.default),typeof n.test!="function")throw new TypeError("`test` is a required parameters");let r=this.clone(),o=Bl(n),i=n.exclusive||n.name&&r.exclusiveTests[n.name]===!0;if(n.exclusive&&!n.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return n.name&&(r.exclusiveTests[n.name]=!!n.exclusive),r.tests=r.tests.filter(s=>!(s.OPTIONS.name===n.name&&(i||s.OPTIONS.test===o.OPTIONS.test))),r.tests.push(o),r}when(e,n){!Array.isArray(e)&&typeof e!="string"&&(n=e,e=".");let r=this.clone(),o=pI(e).map(i=>new Ta(i));return o.forEach(i=>{i.isSibling&&r.deps.push(i.key)}),r.conditions.push(typeof n=="function"?new Eh(o,n):Eh.fromOptions(o,n)),r}typeError(e){let n=this.clone();return n.internalTests.typeError=Bl({message:e,name:"typeError",skipAbsent:!0,test(r){return this.schema._typeCheck(r)?!0:this.createError({params:{type:this.schema.type}})}}),n}oneOf(e,n=ei.oneOf){let r=this.clone();return e.forEach(o=>{r._whitelist.add(o),r._blacklist.delete(o)}),r.internalTests.whiteList=Bl({message:n,name:"oneOf",skipAbsent:!0,test(o){let i=this.schema._whitelist,s=i.resolveAll(this.resolve);return s.includes(o)?!0:this.createError({params:{values:Array.from(i).join(", "),resolved:s}})}}),r}notOneOf(e,n=ei.notOneOf){let r=this.clone();return e.forEach(o=>{r._blacklist.add(o),r._whitelist.delete(o)}),r.internalTests.blacklist=Bl({message:n,name:"notOneOf",test(o){let i=this.schema._blacklist,s=i.resolveAll(this.resolve);return s.includes(o)?this.createError({params:{values:Array.from(i).join(", "),resolved:s}}):!0}}),r}strip(e=!0){let n=this.clone();return n.spec.strip=e,n}describe(e){const n=(e?this.resolve(e):this).clone(),{label:r,meta:o,optional:i,nullable:s}=n.spec;return{meta:o,label:r,optional:i,nullable:s,default:n.getDefault(e),type:n.type,oneOf:n._whitelist.describe(),notOneOf:n._blacklist.describe(),tests:n.tests.filter((l,u,f)=>f.findIndex(p=>p.OPTIONS.name===l.OPTIONS.name)===u).map(l=>{const u=l.OPTIONS.params&&e?bI(Object.assign({},l.OPTIONS.params),e):l.OPTIONS.params;return{name:l.OPTIONS.name,params:u}})}}get"~standard"(){const e=this;return{version:1,vendor:"yup",async validate(r){try{return{value:await e.validate(r,{abortEarly:!1})}}catch(o){if(o instanceof pr)return{issues:xI(o)};throw o}}}}}ti.prototype.__isYupSchema__=!0;for(const t of["validate","validateSync"])ti.prototype[`${t}At`]=function(e,n,r={}){const{parent:o,parentPath:i,schema:s}=RQ(this,e,n,r.context);return s[t](o&&o[i],Object.assign({},r,{parent:o,path:e}))};for(const t of["equals","is"])ti.prototype[t]=ti.prototype.oneOf;for(const t of["not","nope"])ti.prototype[t]=ti.prototype.notOneOf;const HQ=/^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;function WQ(t){const e=yv(t);if(!e)return Date.parse?Date.parse(t):Number.NaN;if(e.z===void 0&&e.plusMinus===void 0)return new Date(e.year,e.month,e.day,e.hour,e.minute,e.second,e.millisecond).valueOf();let n=0;return e.z!=="Z"&&e.plusMinus!==void 0&&(n=e.hourOffset*60+e.minuteOffset,e.plusMinus==="+"&&(n=0-n)),Date.UTC(e.year,e.month,e.day,e.hour,e.minute+n,e.second,e.millisecond)}function yv(t){var e,n;const r=HQ.exec(t);return r?{year:Ai(r[1]),month:Ai(r[2],1)-1,day:Ai(r[3],1),hour:Ai(r[4]),minute:Ai(r[5]),second:Ai(r[6]),millisecond:r[7]?Ai(r[7].substring(0,3)):0,precision:(e=(n=r[7])==null?void 0:n.length)!=null?e:void 0,z:r[8]||void 0,plusMinus:r[9]||void 0,hourOffset:Ai(r[10]),minuteOffset:Ai(r[11])}:null}function Ai(t,e=0){return Number(t)||e}let jQ=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,UQ=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,qQ=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,KQ="^\\d{4}-\\d{2}-\\d{2}",YQ="\\d{2}:\\d{2}:\\d{2}",GQ="(([+-]\\d{2}(:?\\d{2})?)|Z)",JQ=new RegExp(`${KQ}T${YQ}(\\.\\d+)?${GQ}$`),XQ=t=>ka(t)||t===t.trim(),ZQ={}.toString();function Rl(){return new wI}class wI extends ti{constructor(){super({type:"string",check(e){return e instanceof String&&(e=e.valueOf()),typeof e=="string"}}),this.withMutation(()=>{this.transform((e,n)=>{if(!this.spec.coerce||this.isType(e)||Array.isArray(e))return e;const r=e!=null&&e.toString?e.toString():e;return r===ZQ?e:r})})}required(e){return super.required(e).withMutation(n=>n.test({message:e||ei.required,name:"required",skipAbsent:!0,test:r=>!!r.length}))}notRequired(){return super.notRequired().withMutation(e=>(e.tests=e.tests.filter(n=>n.OPTIONS.name!=="required"),e))}length(e,n=kr.length){return this.test({message:n,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(r){return r.length===this.resolve(e)}})}min(e,n=kr.min){return this.test({message:n,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(r){return r.length>=this.resolve(e)}})}max(e,n=kr.max){return this.test({name:"max",exclusive:!0,message:n,params:{max:e},skipAbsent:!0,test(r){return r.length<=this.resolve(e)}})}matches(e,n){let r=!1,o,i;return n&&(typeof n=="object"?{excludeEmptyString:r=!1,message:o,name:i}=n:o=n),this.test({name:i||"matches",message:o||kr.matches,params:{regex:e},skipAbsent:!0,test:s=>s===""&&r||s.search(e)!==-1})}email(e=kr.email){return this.matches(jQ,{name:"email",message:e,excludeEmptyString:!0})}url(e=kr.url){return this.matches(UQ,{name:"url",message:e,excludeEmptyString:!0})}uuid(e=kr.uuid){return this.matches(qQ,{name:"uuid",message:e,excludeEmptyString:!1})}datetime(e){let n="",r,o;return e&&(typeof e=="object"?{message:n="",allowOffset:r=!1,precision:o=void 0}=e:n=e),this.matches(JQ,{name:"datetime",message:n||kr.datetime,excludeEmptyString:!0}).test({name:"datetime_offset",message:n||kr.datetime_offset,params:{allowOffset:r},skipAbsent:!0,test:i=>{if(!i||r)return!0;const s=yv(i);return s?!!s.z:!1}}).test({name:"datetime_precision",message:n||kr.datetime_precision,params:{precision:o},skipAbsent:!0,test:i=>{if(!i||o==null)return!0;const s=yv(i);return s?s.precision===o:!1}})}ensure(){return this.default("").transform(e=>e===null?"":e)}trim(e=kr.trim){return this.transform(n=>n!=null?n.trim():n).test({message:e,name:"trim",test:XQ})}lowercase(e=kr.lowercase){return this.transform(n=>ka(n)?n:n.toLowerCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:n=>ka(n)||n===n.toLowerCase()})}uppercase(e=kr.uppercase){return this.transform(n=>ka(n)?n:n.toUpperCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:n=>ka(n)||n===n.toUpperCase()})}}Rl.prototype=wI.prototype;let SI=new Date(""),QQ=t=>Object.prototype.toString.call(t)==="[object Date]";function bv(){return new Bu}class Bu extends ti{constructor(){super({type:"date",check(e){return QQ(e)&&!isNaN(e.getTime())}}),this.withMutation(()=>{this.transform((e,n)=>!this.spec.coerce||this.isType(e)||e===null?e:(e=WQ(e),isNaN(e)?Bu.INVALID_DATE:new Date(e)))})}prepareParam(e,n){let r;if(Ta.isRef(e))r=e;else{let o=this.cast(e);if(!this._typeCheck(o))throw new TypeError(`\`${n}\` must be a Date or a value that can be \`cast()\` to a Date`);r=o}return r}min(e,n=mv.min){let r=this.prepareParam(e,"min");return this.test({message:n,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(o){return o>=this.resolve(r)}})}max(e,n=mv.max){let r=this.prepareParam(e,"max");return this.test({message:n,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(o){return o<=this.resolve(r)}})}}Bu.INVALID_DATE=SI,bv.prototype=Bu.prototype,bv.INVALID_DATE=SI;function eee(t,e=[]){let n=[],r=new Set,o=new Set(e.map(([s,a])=>`${s}-${a}`));function i(s,a){let l=Ca.split(s)[0];r.add(l),o.has(`${a}-${l}`)||n.push([a,l])}for(const s of Object.keys(t)){let a=t[s];r.add(s),Ta.isRef(a)&&a.isSibling?i(a.path,s):gv(a)&&"deps"in a&&a.deps.forEach(l=>i(l,s))}return _Q.array(Array.from(r),n).reverse()}function CI(t,e){let n=1/0;return t.some((r,o)=>{var i;if((i=e.path)!=null&&i.includes(r))return n=o,!0}),n}function TI(t){return(e,n)=>CI(t,e)-CI(t,n)}const tee=(t,e,n)=>{if(typeof t!="string")return t;let r=t;try{r=JSON.parse(t)}catch{}return n.isType(r)?r:t};function _h(t){if("fields"in t){const e={};for(const[n,r]of Object.entries(t.fields))e[n]=_h(r);return t.setFields(e)}if(t.type==="array"){const e=t.optional();return e.innerType&&(e.innerType=_h(e.innerType)),e}return t.type==="tuple"?t.optional().clone({types:t.spec.types.map(_h)}):"optional"in t?t.optional():t}const nee=(t,e)=>{const n=[...Ca.normalizePath(e)];if(n.length===1)return n[0]in t;let r=n.pop(),o=Ca.getter(Ca.join(n),!0)(t);return!!(o&&r in o)};let kI=t=>Object.prototype.toString.call(t)==="[object Object]";function EI(t,e){let n=Object.keys(t.fields);return Object.keys(e).filter(r=>n.indexOf(r)===-1)}const ree=TI([]);function vv(t){return new OI(t)}class OI extends ti{constructor(e){super({type:"object",check(n){return kI(n)||typeof n=="function"}}),this.fields=Object.create(null),this._sortErrors=ree,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{e&&this.shape(e)})}_cast(e,n={}){var r;let o=super._cast(e,n);if(o===void 0)return this.getDefault(n);if(!this._typeCheck(o))return o;let i=this.fields,s=(r=n.stripUnknown)!=null?r:this.spec.noUnknown,a=[].concat(this._nodes,Object.keys(o).filter(p=>!this._nodes.includes(p))),l={},u=Object.assign({},n,{parent:l,__validating:n.__validating||!1}),f=!1;for(const p of a){let m=i[p],b=p in o,v=o[p];if(m){let y;u.path=(n.path?`${n.path}.`:"")+p,m=m.resolve({value:v,context:n.context,parent:l});let x=m instanceof ti?m.spec:void 0,S=x==null?void 0:x.strict;if(x!=null&&x.strip){f=f||p in o;continue}y=!n.__validating||!S?m.cast(v,u):v,y!==void 0&&(l[p]=y)}else b&&!s&&(l[p]=v);(b!==p in l||l[p]!==v)&&(f=!0)}return f?l:o}_validate(e,n={},r,o){let{from:i=[],originalValue:s=e,recursive:a=this.spec.recursive}=n;n.from=[{schema:this,value:s},...i],n.__validating=!0,n.originalValue=s,super._validate(e,n,r,(l,u)=>{if(!a||!kI(u)){o(l,u);return}s=s||u;let f=[];for(let p of this._nodes){let m=this.fields[p];!m||Ta.isRef(m)||f.push(m.asNestedTest({options:n,key:p,parent:u,parentPath:n.path,originalParent:s}))}this.runTests({tests:f,value:u,originalValue:s,options:n},r,p=>{o(p.sort(this._sortErrors).concat(l),u)})})}clone(e){const n=super.clone(e);return n.fields=Object.assign({},this.fields),n._nodes=this._nodes,n._excludedEdges=this._excludedEdges,n._sortErrors=this._sortErrors,n}concat(e){let n=super.concat(e),r=n.fields;for(let[o,i]of Object.entries(this.fields)){const s=r[o];r[o]=s===void 0?i:s}return n.withMutation(o=>o.setFields(r,[...this._excludedEdges,...e._excludedEdges]))}_getDefault(e){if("default"in this.spec)return super._getDefault(e);if(!this._nodes.length)return;let n={};return this._nodes.forEach(r=>{var o;const i=this.fields[r];let s=e;(o=s)!=null&&o.value&&(s=Object.assign({},s,{parent:s.value,value:s.value[r]})),n[r]=i&&"getDefault"in i?i.getDefault(s):void 0}),n}setFields(e,n){let r=this.clone();return r.fields=e,r._nodes=eee(e,n),r._sortErrors=TI(Object.keys(e)),n&&(r._excludedEdges=n),r}shape(e,n=[]){return this.clone().withMutation(r=>{let o=r._excludedEdges;return n.length&&(Array.isArray(n[0])||(n=[n]),o=[...r._excludedEdges,...n]),r.setFields(Object.assign(r.fields,e),o)})}partial(){const e={};for(const[n,r]of Object.entries(this.fields))e[n]="optional"in r&&r.optional instanceof Function?r.optional():r;return this.setFields(e)}deepPartial(){return _h(this)}pick(e){const n={};for(const r of e)this.fields[r]&&(n[r]=this.fields[r]);return this.setFields(n,this._excludedEdges.filter(([r,o])=>e.includes(r)&&e.includes(o)))}omit(e){const n=[];for(const r of Object.keys(this.fields))e.includes(r)||n.push(r);return this.pick(n)}from(e,n,r){let o=Ca.getter(e,!0);return this.transform(i=>{if(!i)return i;let s=i;return nee(i,e)&&(s=Object.assign({},i),r||delete s[e],s[n]=o(i)),s})}json(){return this.transform(tee)}exact(e){return this.test({name:"exact",exclusive:!0,message:e||kh.exact,test(n){if(n==null)return!0;const r=EI(this.schema,n);return r.length===0||this.createError({params:{properties:r.join(", ")}})}})}stripUnknown(){return this.clone({noUnknown:!0})}noUnknown(e=!0,n=kh.noUnknown){typeof e!="boolean"&&(n=e,e=!0);let r=this.test({name:"noUnknown",exclusive:!0,message:n,test(o){if(o==null)return!0;const i=EI(this.schema,o);return!e||i.length===0||this.createError({params:{unknown:i.join(", ")}})}});return r.spec.noUnknown=e,r}unknown(e=!0,n=kh.noUnknown){return this.noUnknown(!e,n)}transformKeys(e){return this.transform(n=>{if(!n)return n;const r={};for(const o of Object.keys(n))r[e(o)]=n[o];return r})}camelCase(){return this.transformKeys(hv.camelCase)}snakeCase(){return this.transformKeys(hv.snakeCase)}constantCase(){return this.transformKeys(e=>hv.snakeCase(e).toUpperCase())}describe(e){const n=(e?this.resolve(e):this).clone(),r=super.describe(e);r.fields={};for(const[i,s]of Object.entries(n.fields)){var o;let a=e;(o=a)!=null&&o.value&&(a=Object.assign({},a,{parent:a.value,value:a.value[i]})),r.fields[i]=s.describe(a)}return r}}vv.prototype=OI.prototype;const oee=t=>{const{open:e,anchorEl:n,onGenerateCitation:r,onClose:o}=t;return g.jsx(z.Popper,{open:e,anchorEl:n,placement:"bottom-end",style:{zIndex:1300},sx:{maxWidth:"500px"},children:g.jsxs(Lu,{component:z.Paper,p:1,boxShadow:9,gap:.25,children:[g.jsx(z.Typography,{variant:"body1",children:"Paste in a preformatted citation"}),g.jsx(z.Typography,{variant:"body2",color:"text.secondary",fontStyle:"italic",fontSize:".8em",children:"For best results, ensure your citations use a vertical bar ( | ) to separate the title, source, url, etc. Incomplete citations are allowed but may result in incompletely filled fields."}),g.jsx(Ht.Formik,{initialValues:{pasteExistingCitation:""},onSubmit:({pasteExistingCitation:i})=>{r(aee(i)),o()},children:({values:i,submitForm:s,setFieldValue:a})=>g.jsxs(Qo,{flexWrap:"wrap",justifyContent:"flex-end",children:[g.jsx(qM,{name:"pasteExistingCitation",errorMode:"collapse",label:"",placeholder:"Scientific News Today | How to Organize Your Workspace for Maximum Efficiency | https://mock-news-site.com | ACCESSED 2 JAN 2026 | Public Source",endIcon:g.jsx(z.Tooltip,{title:"Paste from Clipboard",children:g.jsx(z.IconButton,{"data-testid":"paste-content-button",onClick:()=>{navigator.clipboard.readText().then(l=>a("pasteExistingCitation",l))},children:g.jsx(PU,{})})})}),g.jsxs(Qo,{children:[g.jsx(Tr,{size:"small",variant:"outlined",onClick:o,"data-testid":"citation-table_paste-prompt_cancel",children:"Cancel"}),g.jsx(Tr,{size:"small",type:"submit",onClick:s,"data-testid":"citation-table_paste-prompt_submit",disabled:!i.pasteExistingCitation,children:"Prefill Citation"})]})]})})]})})},iee=["https://","http://","www."],see=new RegExp(iee.join("|")),aee=t=>{const e=t.replace(/\.\s*$/,"").split("|").map(f=>f.trim()).filter(Boolean),n=e.findIndex(f=>f.match(see)),r=e.findIndex(f=>f.toUpperCase().startsWith("ACCESSED")),o=e.findIndex(f=>/\bSOURCE\b/.test(f.toUpperCase()));let s=[n,r,o].find(f=>f!==-1)??e.length;const a=s-1,l=s-2;return{type:"Url",source:Ih(e,l),title:Ih(e,a),url:Ih(e,n),accessedAt:lee(e,r),classification:cee(e,o),details:Ih(e,o)}},Ih=(t,e)=>e<0||e>=t.length?"":t[e],lee=(t,e)=>e<0||e>=t.length?"":wZ(t[e].toUpperCase().replace(/^ACCESSED\s+/,"")),cee=(t,e)=>e<0||e>=t.length?"":t[e].toUpperCase().includes("PUBLIC")?"Public Source":"Proprietary Source",MI=t=>{const{loading:e=!1,type:n="submit",size:r="medium",...o}=t,s={small:16,medium:20,large:24}[r];return g.jsx(Tr,{type:n,disabled:e,size:r,startIcon:e?g.jsx(z.CircularProgress,{size:s,color:"inherit"}):null,...o})},_I=t=>{const{onCancel:e,onViewCitationTable:n,readOnly:r=!1,showViewAllCitationsBtn:o=!1,isLoading:i,onSaveClicked:s}=t;return r&&!o?null:r?g.jsx(z.DialogActions,{sx:{px:0},children:g.jsx(z.Button,{onClick:n,size:"small",variant:"outlined",children:"Back To Table"})}):g.jsxs(z.DialogActions,{sx:{px:0,justifyContent:"space-between"},children:[g.jsx(z.Box,{children:o&&g.jsx(z.Button,{onClick:n,size:"small",variant:"outlined",children:"View All Citations"})}),g.jsxs(Qo,{children:[g.jsx(z.Button,{onClick:e,variant:"outlined",size:"small",children:"Cancel"}),g.jsx(MI,{size:"small",loading:i,type:"button",onClick:s,children:"Save"})]})]})},uee=t=>{const{onSave:e,onCancel:n,onViewCitationTable:r,onClose:o,modifyCitation:i,readOnly:s=!1,showViewAllCitationsBtn:a=!1,canLaunchUrl:l}=t,u=J.useRef(null),[f,p]=J.useState(!1),[m,b]=J.useState(!1),v=J.useRef(null),[y,x]=J.useState(!1),[S,k]=J.useState({type:"Url",source:"",title:"",accessedAt:null,url:"",classification:"",details:""});J.useEffect(()=>{i&&k({...i,type:"Url"})},[]);const T={disabled:f,margin:"none",readOnly:s},C=!s;return g.jsxs(z.Box,{minWidth:"400px",maxWidth:"500px",children:[g.jsxs(Qo,{justifyContent:"space-between",children:[g.jsxs(Qo,{gap:2,children:[g.jsxs(z.Typography,{variant:"h6",margin:"10px 0",children:[s?"View":"Edit"," Citation"]}),C&&g.jsx(z.Button,{variant:"outlined",size:"small",ref:v,onClick:()=>x(!0),children:"Paste & Prefill"})]}),g.jsx(z.IconButton,{onClick:o,children:g.jsx(fp,{})})]}),g.jsx(Ht.Formik,{innerRef:u,enableReinitialize:!0,initialValues:S,onSubmit:async O=>{p(!0),e(O).catch(I=>{throw p(!1),I}).finally(()=>p(!1))},validationSchema:vv({title:Rl().required("Title is required"),accessedAt:bv().required("Accessed At is required"),url:Rl().required("URL is required"),classification:Rl().required("Classification is required")}),validateOnBlur:m,validateOnChange:m,children:({submitForm:O,setValues:I,values:N})=>g.jsxs(Ht.Form,{autoComplete:"off",children:[g.jsxs(z.Box,{display:"flex",flexDirection:"column",gap:s?1:0,alignItems:"flex-start",children:[g.jsx(ki,{...T,name:"title",required:!0}),g.jsx(ki,{...T,name:"source"}),g.jsx(ki,{...T,name:"details",label:"Details (e.g. Source Description)"}),g.jsx(Up,{...T,name:"accessedAt",required:!0,isDatePicker:!0}),s&&(l!=null&&l(N))?g.jsx(g.Fragment,{children:g.jsx(Ti,{label:"URL / Other Identifier",readOnlyValue:g.jsx(uv,{citation:N,canLaunchUrl:l,asLink:!0}),value:N.url??""})}):g.jsx(ki,{...T,name:"url",label:"URL / Other Identifier",required:!0,endIcon:g.jsx(uv,{citation:N,canLaunchUrl:l})}),g.jsx(UM,{...T,name:"classification",row:!0,required:!0,radios:dee})]}),g.jsx(_I,{isLoading:f,onSaveClicked:()=>{b(!0),O()},readOnly:s,showViewAllCitationsBtn:a,onViewCitationTable:r,onCancel:n}),g.jsx(oee,{open:y,onGenerateCitation:L=>{I(L,!0)},anchorEl:v.current,onClose:()=>x(!1)})]})})]})},dee=[{label:"Public Source",value:"Public Source",helperText:"URL is accessible to anyone from any location without special permissions. You can safely access this URL on any computer, including public or shared devices."},{label:"Proprietary Source",value:"Proprietary Source",helperText:"For private, sensitive, or access-controlled content. Use a VPN, or take extra precautions, when accessing to protect your privacy."}],fee=t=>{const{onSave:e,onCancel:n,onViewCitationTable:r,onClose:o,modifyCitation:i,readOnly:s=!1,showViewAllCitationsBtn:a=!1,onDownloadAttachment:l,onPreviewAttachment:u}=t,f=J.useRef(null),[p,m]=J.useState(!1),[b,v]=J.useState(!1),[y,x]=J.useState({type:"Attachment",title:"",file:void 0,fileName:""});return J.useEffect(()=>{i&&x({...i,type:"Attachment",file:void 0})},[]),g.jsxs(z.Box,{minWidth:"400px",maxWidth:"500px",children:[g.jsxs(z.Box,{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",children:[g.jsxs(z.Typography,{variant:"h6",margin:"10px 0",children:[s?"View":"Edit"," Attachment"]}),g.jsx(z.IconButton,{onClick:o,children:g.jsx(fp,{})})]}),g.jsx(Ht.Formik,{innerRef:f,enableReinitialize:!0,initialValues:y,validationSchema:vv().shape({title:Rl().required("Title is required"),fileName:Rl().required("A file is required")}),validateOnBlur:b,validateOnChange:b,onSubmit:async S=>{m(!0),e(S).catch(k=>{throw m(!1),k}).finally(()=>m(!1))},children:({values:S,setFieldValue:k,handleSubmit:T})=>{var O;const C=!s&&!S.id;return J.useEffect(()=>{var I,N;(I=S.file)!=null&&I.name&&k("fileName",(N=S.file)==null?void 0:N.name)},[(O=S.file)==null?void 0:O.name]),g.jsxs(Ht.Form,{autoComplete:"off",children:[g.jsx(ki,{name:"title",disabled:p,required:!0,margin:"none",readOnly:s}),g.jsxs(z.Box,{marginTop:C?1:0,children:[g.jsxs(Qo,{alignItems:"flex-start",children:[C&&g.jsx(EM,{name:"file",errorMode:"hidden"}),g.jsxs(Qo,{alignItems:"flex-end",children:[g.jsx(ki,{readOnly:!0,name:"fileName",label:C?"":"File Name"}),!C&&g.jsxs(Qo,{children:[g.jsx(iI,{citation:S,onDownloadAttachment:l}),g.jsx(sI,{citation:S,onPreviewAttachment:u})]})]})]}),g.jsx(yr,{name:"fileName"})]}),g.jsx(_I,{isLoading:p,onSaveClicked:()=>{v(!0),T()},readOnly:s,showViewAllCitationsBtn:a,onViewCitationTable:r,onCancel:n})]})}})]})},Fu=t=>{const{open:e=!1,onClose:n,title:r,children:o,actions:i,closeBtnLabel:s,closeButtonPosition:a,closeButtonProps:l={},disableDismiss:u=!1,...f}=t;if(!e)return null;const p=a==="bottom"||a==="top-and-bottom",m=a==="top"||a==="top-and-bottom",b=()=>{if(s&&p)return g.jsx(z.Button,{className:"MBv2_Modal_Close",onClick:t.onClose,...l,children:s})},v=()=>{if(i)return g.jsx(z.DialogActions,{className:"MBv2_Modal_Actions",children:g.jsxs(z.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",gap:"0.25rem",children:[g.jsx(z.Box,{children:b()}),g.jsxs(z.Box,{display:"flex",gap:".25rem",children:[...i]})]})});if(s&&p)return g.jsx(z.DialogActions,{className:"MBv2_Modal_Actions",children:g.jsx(z.Box,{children:b()})})};return g.jsxs(z.Dialog,{className:"MBv2_Modal",open:e,onClose:()=>{u||n==null||n()},...f,children:[typeof r=="string"?g.jsx(z.DialogTitle,{className:"MBv2_Modal_Title",children:g.jsxs(z.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[r,m&&g.jsx(z.IconButton,{"data-testid":"modal-header-close-btn",onClick:n,children:g.jsx(fp,{})})]})}):r,o&&(typeof o=="string"?g.jsx(z.DialogContent,{className:"MBv2_Modal_Content",children:g.jsx(z.DialogContentText,{className:"MBv2_Modal_Content_Text",children:o})}):o),v()]})};function pee(t){return Ke("MuiAlert",t)}const II=je("MuiAlert",["root","action","icon","message","filled","colorSuccess","colorInfo","colorWarning","colorError","filledSuccess","filledInfo","filledWarning","filledError","outlined","outlinedSuccess","outlinedInfo","outlinedWarning","outlinedError","standard","standardSuccess","standardInfo","standardWarning","standardError"]),hee=Le(g.jsx("path",{d:"M20,12A8,8 0 0,1 12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4C12.76,4 13.5,4.11 14.2, 4.31L15.77,2.74C14.61,2.26 13.34,2 12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0, 0 22,12M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z"}),"SuccessOutlined"),mee=Le(g.jsx("path",{d:"M12 5.99L19.53 19H4.47L12 5.99M12 2L1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z"}),"ReportProblemOutlined"),gee=Le(g.jsx("path",{d:"M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}),"ErrorOutline"),yee=Le(g.jsx("path",{d:"M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"}),"InfoOutlined"),bee=Le(g.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Close"),vee=t=>{const{variant:e,color:n,severity:r,classes:o}=t,i={root:["root",`color${Ne(n||r)}`,`${e}${Ne(n||r)}`,`${e}`],icon:["icon"],message:["message"],action:["action"]};return qe(i,pee,o)},xee=oe(fs,{name:"MuiAlert",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,e[n.variant],e[`${n.variant}${Ne(n.color||n.severity)}`]]}})(bt(({theme:t})=>{const e=t.palette.mode==="light"?zs:Va,n=t.palette.mode==="light"?Va:zs;return{...t.typography.body2,backgroundColor:"transparent",display:"flex",padding:"6px 16px",variants:[...Object.entries(t.palette).filter(Hn(["light"])).map(([r])=>({props:{colorSeverity:r,variant:"standard"},style:{color:t.vars?t.vars.palette.Alert[`${r}Color`]:e(t.palette[r].light,.6),backgroundColor:t.vars?t.vars.palette.Alert[`${r}StandardBg`]:n(t.palette[r].light,.9),[`& .${II.icon}`]:t.vars?{color:t.vars.palette.Alert[`${r}IconColor`]}:{color:t.palette[r].main}}})),...Object.entries(t.palette).filter(Hn(["light"])).map(([r])=>({props:{colorSeverity:r,variant:"outlined"},style:{color:t.vars?t.vars.palette.Alert[`${r}Color`]:e(t.palette[r].light,.6),border:`1px solid ${(t.vars||t).palette[r].light}`,[`& .${II.icon}`]:t.vars?{color:t.vars.palette.Alert[`${r}IconColor`]}:{color:t.palette[r].main}}})),...Object.entries(t.palette).filter(Hn(["dark"])).map(([r])=>({props:{colorSeverity:r,variant:"filled"},style:{fontWeight:t.typography.fontWeightMedium,...t.vars?{color:t.vars.palette.Alert[`${r}FilledColor`],backgroundColor:t.vars.palette.Alert[`${r}FilledBg`]}:{backgroundColor:t.palette.mode==="dark"?t.palette[r].dark:t.palette[r].main,color:t.palette.getContrastText(t.palette[r].main)}}}))]}})),wee=oe("div",{name:"MuiAlert",slot:"Icon",overridesResolver:(t,e)=>e.icon})({marginRight:12,padding:"7px 0",display:"flex",fontSize:22,opacity:.9}),See=oe("div",{name:"MuiAlert",slot:"Message",overridesResolver:(t,e)=>e.message})({padding:"8px 0",minWidth:0,overflow:"auto"}),Cee=oe("div",{name:"MuiAlert",slot:"Action",overridesResolver:(t,e)=>e.action})({display:"flex",alignItems:"flex-start",padding:"4px 0 0 16px",marginLeft:"auto",marginRight:-8}),DI={success:g.jsx(hee,{fontSize:"inherit"}),warning:g.jsx(mee,{fontSize:"inherit"}),error:g.jsx(gee,{fontSize:"inherit"}),info:g.jsx(yee,{fontSize:"inherit"})},AI=A.forwardRef(function(e,n){const r=mt({props:e,name:"MuiAlert"}),{action:o,children:i,className:s,closeText:a="Close",color:l,components:u={},componentsProps:f={},icon:p,iconMapping:m=DI,onClose:b,role:v="alert",severity:y="success",slotProps:x={},slots:S={},variant:k="standard",...T}=r,C={...r,color:l,severity:y,variant:k,colorSeverity:l||y},O=vee(C),I={slots:{closeButton:u.CloseButton,closeIcon:u.CloseIcon,...S},slotProps:{...f,...x}},[N,L]=_t("root",{ref:n,shouldForwardComponentProp:!0,className:ge(O.root,s),elementType:xee,externalForwardedProps:{...I,...T},ownerState:C,additionalProps:{role:v,elevation:0}}),[V,M]=_t("icon",{className:O.icon,elementType:wee,externalForwardedProps:I,ownerState:C}),[B,H]=_t("message",{className:O.message,elementType:See,externalForwardedProps:I,ownerState:C}),[F,P]=_t("action",{className:O.action,elementType:Cee,externalForwardedProps:I,ownerState:C}),[_,D]=_t("closeButton",{elementType:_l,externalForwardedProps:I,ownerState:C}),[R,j]=_t("closeIcon",{elementType:bee,externalForwardedProps:I,ownerState:C});return g.jsxs(N,{...L,children:[p!==!1?g.jsx(V,{...M,children:p||m[y]||DI[y]}):null,g.jsx(B,{...H,children:i}),o!=null?g.jsx(F,{...P,children:o}):null,o==null&&b?g.jsx(F,{...P,children:g.jsx(_,{size:"small","aria-label":a,title:a,color:"inherit",onClick:b,...D,children:g.jsx(R,{fontSize:"small",...j})})}):null]})});process.env.NODE_ENV!=="production"&&(AI.propTypes={action:c.node,children:c.node,classes:c.object,className:c.string,closeText:c.string,color:c.oneOfType([c.oneOf(["error","info","success","warning"]),c.string]),components:c.shape({CloseButton:c.elementType,CloseIcon:c.elementType}),componentsProps:c.shape({closeButton:c.object,closeIcon:c.object}),icon:c.node,iconMapping:c.shape({error:c.node,info:c.node,success:c.node,warning:c.node}),onClose:c.func,role:c.string,severity:c.oneOfType([c.oneOf(["error","info","success","warning"]),c.string]),slotProps:c.shape({action:c.oneOfType([c.func,c.object]),closeButton:c.oneOfType([c.func,c.object]),closeIcon:c.oneOfType([c.func,c.object]),icon:c.oneOfType([c.func,c.object]),message:c.oneOfType([c.func,c.object]),root:c.oneOfType([c.func,c.object])}),slots:c.shape({action:c.elementType,closeButton:c.elementType,closeIcon:c.elementType,icon:c.elementType,message:c.elementType,root:c.elementType}),sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object]),variant:c.oneOfType([c.oneOf(["filled","outlined","standard"]),c.string])});const Ru=t=>{var b;const{noIcon:e=!1,children:n,severity:r="success",variant:o="leftBorder",sx:i,title:s,...a}=t,{palette:l}=z.useTheme(),u=e?{icon:!1}:{},f=o==="leftBorder"?"standard":o,p=o==="leftBorder"?{...i,borderLeft:`4px solid ${(b=l[r])==null?void 0:b.main}`}:i,m=s?{icon:{sx:{mt:"6px"}}}:{};return g.jsxs(AI,{severity:r,variant:f,sx:p,slotProps:m,...u,...a,children:[s&&g.jsx(z.Typography,{variant:"h3",children:s}),n]})},PI=t=>g.jsx(Ru,{severity:"error",...t}),NI=t=>g.jsx(Ru,{severity:"success",...t}),Tee=t=>{const{alert:e,setAlert:n}=t,r=()=>n(void 0);return g.jsxs(g.Fragment,{children:[(e==null?void 0:e.type)==="Error"&&g.jsx(PI,{"data-testid":"citation-menu-error",onClose:r,title:e.title,children:e.message.toString()}),(e==null?void 0:e.type)==="Success"&&g.jsx(NI,{"data-testid":"citation-menu-success",onClose:r,children:e.message})]})};function $I({getCitationsPaginated:t,onCreateCitation:e,onUpdateCitation:n,onDeleteCitation:r,getCitationById:o,onDownloadAttachment:i,onPreviewAttachment:s,onSelectCitations:a,onClose:l,initialSelectedIds:u=[],onContentChange:f,onError:p=()=>{},renderAsPopup:m=!1,canSelect:b=!1,tableTitle:v="Attachments & Citations",addlActions:y,canLaunchUrl:x,readOnly:S,canSearch:k=!1}){const[T,C]=J.useState("Insert Citation/Attachment(s)"),[O,I]=J.useState(u),[N,L]=J.useState(void 0),[V,M]=J.useState(void 0),[B,H]=J.useState(!1),[F,P]=J.useState(!1),_=ee=>{M(void 0),C(ee)},[D,R]=J.useState(0);J.useEffect(()=>{f==null||f()},[T,V,f]);const j=(ee=!1)=>{(!m||ee)&&R(ie=>ie+1)},K=(ee,ie)=>{var Me;const we=typeof((Me=ie.response)==null?void 0:Me.data)=="string"&&ie.response.data,Ce=typeof ie.message=="string"&&ie.message;M({type:"Error",title:ee,message:we??Ce}),p(ie)},U=ee=>M({type:"Success",title:"",message:ee}),Y=async ee=>{if(T==="Insert Citation/Attachment(s)")throw Error("onSave called with invalid state");ee.id?await(n==null?void 0:n(ee).then(()=>{B?l():(_("Insert Citation/Attachment(s)"),j())}).catch(ie=>{K("Failed to update",ie)})):await(e==null?void 0:e(ee).then(ie=>{I([...O,ie.id]),_("Insert Citation/Attachment(s)"),j()}).catch(ie=>{K("Failed to create",ie)}))},fe=r&&(async ee=>r(ee).then(()=>{j(!0),I(O.filter(ie=>ie!==ee)),U("Successfully deleted")}).catch(ie=>K("Failed to delete",ie))),ue=o&&(ee=>{o(ee).then(ie=>{const we=!!ie.fileName;L(ie),_(we?"Attachment":"Citation")}).catch(ie=>{K("Failed to load",ie)}).finally(()=>P(!1))}),pe=n&&ue,Z=n&&ue,te=i&&(async ee=>i(ee).catch(ie=>{K(`Failed to download ${ee.fileName}`,ie)})),ce=s&&(async ee=>s(ee).catch(ie=>{K(`Failed to view ${ee.fileName}`,ie)})),ne=g.jsx(TQ,{refreshKey:D,getCitationsPaginated:(ee,ie)=>t(ee,ie).then(we=>(f==null||f(),we)),onCancel:l,onNewCitation:()=>{L(void 0),_("Citation")},onNewAttachment:()=>{L(void 0),_("Attachment")},onEditCitation:pe,onEditAttachment:Z,onViewCitation:ue,onViewAttachment:ue,onDeleteCitation:fe,onDownloadAttachment:te,onPreviewAttachment:ce,onSelect:a,setSelectedIds:I,selectedIds:O,onError:p,condenseTable:m,canSelect:b,title:v,addlActions:y,canCreate:!!e,canLaunchUrl:x,readOnly:S,showCloseBtn:m,canSearch:k}),re=g.jsx(uee,{modifyCitation:N,onSave:Y,onCancel:()=>B?l():_("Insert Citation/Attachment(s)"),onViewCitationTable:()=>{_("Insert Citation/Attachment(s)"),H(!1)},onClose:()=>m?l():_("Insert Citation/Attachment(s)"),readOnly:S,showViewAllCitationsBtn:S&&!B||!S&&B,canLaunchUrl:x}),le=g.jsx(fee,{onSave:Y,onCancel:()=>B?l():_("Insert Citation/Attachment(s)"),onViewCitationTable:()=>{_("Insert Citation/Attachment(s)"),H(!1)},onClose:()=>m?l():_("Insert Citation/Attachment(s)"),modifyCitation:N,readOnly:S,showViewAllCitationsBtn:S&&!B||!S&&B,onDownloadAttachment:te,onPreviewAttachment:ce}),ye=g.jsx(Tee,{alert:V,setAlert:M});J.useEffect(()=>{m&&u.length===1&&ue&&(P(!0),H(!0),ue(u[0]))},[]);const X=()=>{switch(T){case"Insert Citation/Attachment(s)":return ne;case"Citation":return re;case"Attachment":return le}};return m?g.jsxs(z.Box,{children:[ye,g.jsx(z.Box,{paddingTop:"8px",children:g.jsx(lv,{isLoading:F,children:X()})})]}):g.jsxs(z.Box,{width:"100%",children:[T==="Insert Citation/Attachment(s)"&&ye,g.jsx(z.Box,{paddingTop:"8px",children:ne}),g.jsx(Fu,{open:T!=="Insert Citation/Attachment(s)",children:g.jsxs(z.Box,{padding:"10px 20px",minWidth:"400px","data-testid":"citation-form-modal",children:[ye,T==="Citation"?re:le]})})]})}function LI({getSelectedCitationsPaginated:t,getCitationsPaginated:e,readOnly:n,initialSelectedIds:r=[],...o}){const i=(s,a)=>n?t(s,r):e(s,a);return g.jsx($I,{renderAsPopup:!0,canSelect:!n,getCitationsPaginated:i,readOnly:n,tableTitle:`${n?"Selected":"Insert"} Citation/Attachment(s)`,initialSelectedIds:r,...o})}const kee=z.styled("div",{name:"CitationBubbleMenu",slot:"content",overridesResolver:(t,e)=>e.content})(({theme:t})=>{const e=t.palette.mode==="dark";return{padding:t.spacing(1.5,2,.5),backgroundColor:e?"#101010":"#f9f9f9",border:`1px solid ${t.palette.grey[e?700:200]}`}});function Eee({getCitationsPaginated:t,getSelectedCitationsPaginated:e,onCreateCitation:n,onUpdateCitation:r,onDeleteCitation:o,getCitationById:i,onDownloadAttachment:s,onPreviewAttachment:a,canLaunchUrl:l,readOnly:u,canSearch:f,...p}){const m=Tt();if(m&&!("citationBubbleMenuHandler"in(m==null?void 0:m.storage)))throw new Error("You must add the CitationBubbleMenuHandler extension to the useEditor `extensions` array in order to use this component!");const b=m==null?void 0:m.storage.citationBubbleMenuHandler,v=b.isOpen,y=b.selectedIds,x=b.selectedNodePos,S=O=>{m&&(O.length===0?m.commands.deleteCitation(x):y.length===0?m.commands.insertCitation({ids:O}):m.commands.updateCitation({ids:O},x))},k=O=>{S(O),m==null||m.commands.closeCitationBubbleMenu()},T=()=>{S(y),m==null||m.commands.closeCitationBubbleMenu()},C=J.useCallback(()=>{requestAnimationFrame(()=>{m!=null&&m.view&&m.view.dispatch(m.view.state.tr)})},[m]);return m?g.jsx(Sy,{editor:m,open:v,...b.bubbleMenuOptions,...p,children:g.jsx(kee,{children:g.jsx(LI,{getCitationsPaginated:t,getSelectedCitationsPaginated:O=>e(O,y),onCreateCitation:n,onUpdateCitation:r,onDeleteCitation:o,getCitationById:i,onDownloadAttachment:s,onPreviewAttachment:a,onSelectCitations:k,onClose:T,initialSelectedIds:y,onContentChange:C,canLaunchUrl:l,readOnly:u,canSearch:f})})}):null}const Oee=()=>cn.create({name:"citationBubbleMenuHandler",addStorage(){return{isOpen:!1,selectedIds:[],bubbleMenuOptions:void 0,selectedNodePos:0}},addCommands(){return{openCitationBubbleMenu:(t={},e)=>({editor:n,dispatch:r})=>{var a;const{doc:o}=n.state,i=o.nodeAt(e??0),s=((a=i==null?void 0:i.attrs)==null?void 0:a.ids)??[];return r&&(this.storage.isOpen=!0,this.storage.selectedIds=s,this.storage.bubbleMenuOptions=t,this.storage.selectedNodePos=e??0),!0},closeCitationBubbleMenu:()=>({commands:t,dispatch:e})=>this.storage.isOpen?(t.focus(),e&&(this.storage.isOpen=!1,this.storage.selectedIds=[],this.storage.selectedNodePos=0),!0):!1}},onSelectionUpdate(){this.storage.isOpen&&!this.editor.isActive("citation")&&this.editor.commands.closeCitationBubbleMenu()},addKeyboardShortcuts(){return{"Mod-Shift-c":()=>(this.editor.commands.openCitationBubbleMenu(),!0)}}});function Mee(t){const e=Tt(),n=J.useRef(null);return g.jsx(wt,{buttonRef:n,tooltipLabel:"Insert Citation/Attachment",tooltipShortcutKeys:["mod","Shift","C"],disabled:!(e!=null&&e.isEditable),onClick:()=>e==null?void 0:e.commands.openCitationBubbleMenu({anchorEl:n.current,placement:"bottom"}),...t,children:g.jsxs(z.Box,{display:"flex",flexDirection:"row",gap:"4px",alignItems:"center",children:[g.jsx(IU,{fontSize:"small"}),g.jsx(z.Typography,{variant:"body2",children:"Insert Citation/Attachment"})]})})}const BI=J.createContext(void 0),FI=()=>{const t=J.useContext(BI);if(!t)throw new Error("useSync must be used inside CitationFieldProvider");return t},_ee=({node:t,HTMLAttributes:e,selected:n,extension:r,updateAttributes:o,deleteNode:i})=>{const s=t.attrs.ids||[],{citations:a,isLoaded:l}=FI(),[u,f]=J.useState(s?String(s):""),[p,m]=J.useState([]),b=r.options.citationMaxLength;if(J.useEffect(()=>{if(!l)return;const v=a.filter(S=>s.includes(S.id)),y=v.map(S=>dv(S.title,b)).join(", ");f(y),m(v);const x=v.map(S=>S.id);x.length===0?setTimeout(i,0):x.length!==s.length&&setTimeout(()=>o({ids:v.map(S=>S.id)}),0)},[a,s,l]),p.length!==0)return g.jsx(_b,{as:"span",...e,"data-testid":"citation-node-component",children:g.jsx(z.Tooltip,{title:g.jsx(z.Box,{className:"citation-tooltip",children:p.map((v,y)=>{var k;const S=!!v.fileName?[v.title,v.fileName]:[v.title,v.source,v.details,(k=v.accessedAt)==null?void 0:k.slice(0,10),v.url,v.classification];return g.jsxs(z.Typography,{variant:"subtitle2",children:[S.filter(Boolean).join(" | "),y<p.length-1&&g.jsx(z.Divider,{className:"citation-tooltip-divider"})]},v.id)})}),slotProps:{tooltip:{sx:{maxWidth:500}}},children:g.jsx("a",{href:"#",onClick:v=>{v.preventDefault(),v.stopPropagation()},className:n?"selected-citation-link":"citation-link",children:u})})})},Iee=tn.create({name:"citation",group:"inline",inline:!0,atom:!0,selectable:!0,addAttributes(){return{ids:{default:[],parseHTML:t=>{const e=t.getAttribute("ids");return e?e.split(",").map(n=>parseInt(n.trim(),10)).filter(n=>!isNaN(n)):[]},renderHTML:t=>({ids:Array.isArray(t.ids)?t.ids.join(","):""})}}},parseHTML(){return[{tag:"citation"}]},renderHTML({HTMLAttributes:t}){return["citation",Ct(t)]},addNodeView(){return Ib(_ee)},addProseMirrorPlugins(){return[new en({props:{handleClickOn:(t,e,n,r,o,i)=>n&&n.type.name==="citation"?(this.editor.commands.openCitationBubbleMenu({},r),!0):!1}})]},addCommands(){return{insertCitation:t=>({commands:e})=>e.insertContent({type:"citation",attrs:t}),updateCitation:(t,e)=>({state:n,dispatch:r,tr:o})=>{const i=n.doc.nodeAt(e);return!i||i.type.name!=="citation"?!1:(o.setNodeMarkup(e,void 0,t),r&&r(o),!0)},deleteCitation:t=>({tr:e,dispatch:n})=>{if(typeof t!="number")return!1;const r=t,o=t+1;return n&&n(e.delete(r,o)),!0}}}});function RI({editor:t,canComment:e=!0,onComment:n,commentCount:r,commentResolved:o,...i}){const s=J.useRef(null);if(!n)return null;const a=o?g.jsx(sE,{sx:{width:14,height:14},"data-testid":"resolved-checkmark"}):r,l=o?"success":"primary",u=o?{"& .MuiBadge-badge":{padding:0,height:16,minWidth:16}}:{"& .MuiBadge-badge":{fontSize:14,height:16,minWidth:16}};return e?g.jsx(wt,{buttonRef:s,tooltipLabel:"Comments",onClick:()=>{if(!t)return;const{from:f,to:p}=t.state.selection,m=t.state.doc.textBetween(f,p,`
408
+ `+(a!==s?`result of cast: ${a}`:""))}return i}_cast(e,n){let r=e===void 0?e:this.transforms.reduce((o,i)=>i.call(this,o,e,this,n),e);return r===void 0&&(r=this.getDefault(n)),r}_validate(e,n={},r,o){let{path:i,originalValue:s=e,strict:a=this.spec.strict}=n,l=e;a||(l=this._cast(l,Object.assign({assert:!1},n)));let u=[];for(let f of Object.values(this.internalTests))f&&u.push(f);this.runTests({path:i,value:l,originalValue:s,options:n,tests:u},r,f=>{if(f.length)return o(f,l);this.runTests({path:i,value:l,originalValue:s,options:n,tests:this.tests},r,o)})}runTests(e,n,r){let o=!1,{tests:i,value:s,originalValue:a,path:l,options:u}=e,f=y=>{o||(o=!0,n(y,s))},p=y=>{o||(o=!0,r(y,s))},m=i.length,b=[];if(!m)return p([]);let v={value:s,originalValue:a,path:l,options:u,schema:this};for(let y=0;y<i.length;y++){const x=i[y];x(v,f,function(k){k&&(Array.isArray(k)?b.push(...k):b.push(k)),--m<=0&&p(b)})}}asNestedTest({key:e,index:n,parent:r,parentPath:o,originalParent:i,options:s}){const a=e??n;if(a==null)throw TypeError("Must include `key` or `index` for nested validations");const l=typeof a=="number";let u=r[a];const f=Object.assign({},s,{strict:!0,parent:r,value:u,originalValue:i[a],key:void 0,[l?"index":"key"]:a,path:l||a.includes(".")?`${o||""}[${l?a:`"${a}"`}]`:(o?`${o}.`:"")+e});return(p,m,b)=>this.resolve(f)._validate(u,f,m,b)}validate(e,n){var r;let o=this.resolve(Object.assign({},n,{value:e})),i=(r=n==null?void 0:n.disableStackTrace)!=null?r:o.spec.disableStackTrace;return new Promise((s,a)=>o._validate(e,n,(l,u)=>{pr.isError(l)&&(l.value=u),a(l)},(l,u)=>{l.length?a(new pr(l,u,void 0,void 0,i)):s(u)}))}validateSync(e,n){var r;let o=this.resolve(Object.assign({},n,{value:e})),i,s=(r=n==null?void 0:n.disableStackTrace)!=null?r:o.spec.disableStackTrace;return o._validate(e,Object.assign({},n,{sync:!0}),(a,l)=>{throw pr.isError(a)&&(a.value=l),a},(a,l)=>{if(a.length)throw new pr(a,e,void 0,void 0,s);i=l}),i}isValid(e,n){return this.validate(e,n).then(()=>!0,r=>{if(pr.isError(r))return!1;throw r})}isValidSync(e,n){try{return this.validateSync(e,n),!0}catch(r){if(pr.isError(r))return!1;throw r}}_getDefault(e){let n=this.spec.default;return n==null?n:typeof n=="function"?n.call(this,e):Fl(n)}getDefault(e){return this.resolve(e||{})._getDefault(e)}default(e){return arguments.length===0?this._getDefault():this.clone({default:e})}strict(e=!0){return this.clone({strict:e})}nullability(e,n){const r=this.clone({nullable:e});return r.internalTests.nullable=Bl({message:n,name:"nullable",test(o){return o===null?this.schema.spec.nullable:!0}}),r}optionality(e,n){const r=this.clone({optional:e});return r.internalTests.optionality=Bl({message:n,name:"optionality",test(o){return o===void 0?this.schema.spec.optional:!0}}),r}optional(){return this.optionality(!0)}defined(e=ei.defined){return this.optionality(!1,e)}nullable(){return this.nullability(!0)}nonNullable(e=ei.notNull){return this.nullability(!1,e)}required(e=ei.required){return this.clone().withMutation(n=>n.nonNullable(e).defined(e))}notRequired(){return this.clone().withMutation(e=>e.nullable().optional())}transform(e){let n=this.clone();return n.transforms.push(e),n}test(...e){let n;if(e.length===1?typeof e[0]=="function"?n={test:e[0]}:n=e[0]:e.length===2?n={name:e[0],test:e[1]}:n={name:e[0],message:e[1],test:e[2]},n.message===void 0&&(n.message=ei.default),typeof n.test!="function")throw new TypeError("`test` is a required parameters");let r=this.clone(),o=Bl(n),i=n.exclusive||n.name&&r.exclusiveTests[n.name]===!0;if(n.exclusive&&!n.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return n.name&&(r.exclusiveTests[n.name]=!!n.exclusive),r.tests=r.tests.filter(s=>!(s.OPTIONS.name===n.name&&(i||s.OPTIONS.test===o.OPTIONS.test))),r.tests.push(o),r}when(e,n){!Array.isArray(e)&&typeof e!="string"&&(n=e,e=".");let r=this.clone(),o=pI(e).map(i=>new Ta(i));return o.forEach(i=>{i.isSibling&&r.deps.push(i.key)}),r.conditions.push(typeof n=="function"?new Eh(o,n):Eh.fromOptions(o,n)),r}typeError(e){let n=this.clone();return n.internalTests.typeError=Bl({message:e,name:"typeError",skipAbsent:!0,test(r){return this.schema._typeCheck(r)?!0:this.createError({params:{type:this.schema.type}})}}),n}oneOf(e,n=ei.oneOf){let r=this.clone();return e.forEach(o=>{r._whitelist.add(o),r._blacklist.delete(o)}),r.internalTests.whiteList=Bl({message:n,name:"oneOf",skipAbsent:!0,test(o){let i=this.schema._whitelist,s=i.resolveAll(this.resolve);return s.includes(o)?!0:this.createError({params:{values:Array.from(i).join(", "),resolved:s}})}}),r}notOneOf(e,n=ei.notOneOf){let r=this.clone();return e.forEach(o=>{r._blacklist.add(o),r._whitelist.delete(o)}),r.internalTests.blacklist=Bl({message:n,name:"notOneOf",test(o){let i=this.schema._blacklist,s=i.resolveAll(this.resolve);return s.includes(o)?this.createError({params:{values:Array.from(i).join(", "),resolved:s}}):!0}}),r}strip(e=!0){let n=this.clone();return n.spec.strip=e,n}describe(e){const n=(e?this.resolve(e):this).clone(),{label:r,meta:o,optional:i,nullable:s}=n.spec;return{meta:o,label:r,optional:i,nullable:s,default:n.getDefault(e),type:n.type,oneOf:n._whitelist.describe(),notOneOf:n._blacklist.describe(),tests:n.tests.filter((l,u,f)=>f.findIndex(p=>p.OPTIONS.name===l.OPTIONS.name)===u).map(l=>{const u=l.OPTIONS.params&&e?bI(Object.assign({},l.OPTIONS.params),e):l.OPTIONS.params;return{name:l.OPTIONS.name,params:u}})}}get"~standard"(){const e=this;return{version:1,vendor:"yup",async validate(r){try{return{value:await e.validate(r,{abortEarly:!1})}}catch(o){if(o instanceof pr)return{issues:xI(o)};throw o}}}}}ti.prototype.__isYupSchema__=!0;for(const t of["validate","validateSync"])ti.prototype[`${t}At`]=function(e,n,r={}){const{parent:o,parentPath:i,schema:s}=RQ(this,e,n,r.context);return s[t](o&&o[i],Object.assign({},r,{parent:o,path:e}))};for(const t of["equals","is"])ti.prototype[t]=ti.prototype.oneOf;for(const t of["not","nope"])ti.prototype[t]=ti.prototype.notOneOf;const HQ=/^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;function WQ(t){const e=yv(t);if(!e)return Date.parse?Date.parse(t):Number.NaN;if(e.z===void 0&&e.plusMinus===void 0)return new Date(e.year,e.month,e.day,e.hour,e.minute,e.second,e.millisecond).valueOf();let n=0;return e.z!=="Z"&&e.plusMinus!==void 0&&(n=e.hourOffset*60+e.minuteOffset,e.plusMinus==="+"&&(n=0-n)),Date.UTC(e.year,e.month,e.day,e.hour,e.minute+n,e.second,e.millisecond)}function yv(t){var e,n;const r=HQ.exec(t);return r?{year:Ai(r[1]),month:Ai(r[2],1)-1,day:Ai(r[3],1),hour:Ai(r[4]),minute:Ai(r[5]),second:Ai(r[6]),millisecond:r[7]?Ai(r[7].substring(0,3)):0,precision:(e=(n=r[7])==null?void 0:n.length)!=null?e:void 0,z:r[8]||void 0,plusMinus:r[9]||void 0,hourOffset:Ai(r[10]),minuteOffset:Ai(r[11])}:null}function Ai(t,e=0){return Number(t)||e}let jQ=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,UQ=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,qQ=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,KQ="^\\d{4}-\\d{2}-\\d{2}",YQ="\\d{2}:\\d{2}:\\d{2}",GQ="(([+-]\\d{2}(:?\\d{2})?)|Z)",JQ=new RegExp(`${KQ}T${YQ}(\\.\\d+)?${GQ}$`),XQ=t=>ka(t)||t===t.trim(),ZQ={}.toString();function Rl(){return new wI}class wI extends ti{constructor(){super({type:"string",check(e){return e instanceof String&&(e=e.valueOf()),typeof e=="string"}}),this.withMutation(()=>{this.transform((e,n)=>{if(!this.spec.coerce||this.isType(e)||Array.isArray(e))return e;const r=e!=null&&e.toString?e.toString():e;return r===ZQ?e:r})})}required(e){return super.required(e).withMutation(n=>n.test({message:e||ei.required,name:"required",skipAbsent:!0,test:r=>!!r.length}))}notRequired(){return super.notRequired().withMutation(e=>(e.tests=e.tests.filter(n=>n.OPTIONS.name!=="required"),e))}length(e,n=kr.length){return this.test({message:n,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(r){return r.length===this.resolve(e)}})}min(e,n=kr.min){return this.test({message:n,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(r){return r.length>=this.resolve(e)}})}max(e,n=kr.max){return this.test({name:"max",exclusive:!0,message:n,params:{max:e},skipAbsent:!0,test(r){return r.length<=this.resolve(e)}})}matches(e,n){let r=!1,o,i;return n&&(typeof n=="object"?{excludeEmptyString:r=!1,message:o,name:i}=n:o=n),this.test({name:i||"matches",message:o||kr.matches,params:{regex:e},skipAbsent:!0,test:s=>s===""&&r||s.search(e)!==-1})}email(e=kr.email){return this.matches(jQ,{name:"email",message:e,excludeEmptyString:!0})}url(e=kr.url){return this.matches(UQ,{name:"url",message:e,excludeEmptyString:!0})}uuid(e=kr.uuid){return this.matches(qQ,{name:"uuid",message:e,excludeEmptyString:!1})}datetime(e){let n="",r,o;return e&&(typeof e=="object"?{message:n="",allowOffset:r=!1,precision:o=void 0}=e:n=e),this.matches(JQ,{name:"datetime",message:n||kr.datetime,excludeEmptyString:!0}).test({name:"datetime_offset",message:n||kr.datetime_offset,params:{allowOffset:r},skipAbsent:!0,test:i=>{if(!i||r)return!0;const s=yv(i);return s?!!s.z:!1}}).test({name:"datetime_precision",message:n||kr.datetime_precision,params:{precision:o},skipAbsent:!0,test:i=>{if(!i||o==null)return!0;const s=yv(i);return s?s.precision===o:!1}})}ensure(){return this.default("").transform(e=>e===null?"":e)}trim(e=kr.trim){return this.transform(n=>n!=null?n.trim():n).test({message:e,name:"trim",test:XQ})}lowercase(e=kr.lowercase){return this.transform(n=>ka(n)?n:n.toLowerCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:n=>ka(n)||n===n.toLowerCase()})}uppercase(e=kr.uppercase){return this.transform(n=>ka(n)?n:n.toUpperCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:n=>ka(n)||n===n.toUpperCase()})}}Rl.prototype=wI.prototype;let SI=new Date(""),QQ=t=>Object.prototype.toString.call(t)==="[object Date]";function bv(){return new Bu}class Bu extends ti{constructor(){super({type:"date",check(e){return QQ(e)&&!isNaN(e.getTime())}}),this.withMutation(()=>{this.transform((e,n)=>!this.spec.coerce||this.isType(e)||e===null?e:(e=WQ(e),isNaN(e)?Bu.INVALID_DATE:new Date(e)))})}prepareParam(e,n){let r;if(Ta.isRef(e))r=e;else{let o=this.cast(e);if(!this._typeCheck(o))throw new TypeError(`\`${n}\` must be a Date or a value that can be \`cast()\` to a Date`);r=o}return r}min(e,n=mv.min){let r=this.prepareParam(e,"min");return this.test({message:n,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(o){return o>=this.resolve(r)}})}max(e,n=mv.max){let r=this.prepareParam(e,"max");return this.test({message:n,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(o){return o<=this.resolve(r)}})}}Bu.INVALID_DATE=SI,bv.prototype=Bu.prototype,bv.INVALID_DATE=SI;function eee(t,e=[]){let n=[],r=new Set,o=new Set(e.map(([s,a])=>`${s}-${a}`));function i(s,a){let l=Ca.split(s)[0];r.add(l),o.has(`${a}-${l}`)||n.push([a,l])}for(const s of Object.keys(t)){let a=t[s];r.add(s),Ta.isRef(a)&&a.isSibling?i(a.path,s):gv(a)&&"deps"in a&&a.deps.forEach(l=>i(l,s))}return _Q.array(Array.from(r),n).reverse()}function CI(t,e){let n=1/0;return t.some((r,o)=>{var i;if((i=e.path)!=null&&i.includes(r))return n=o,!0}),n}function TI(t){return(e,n)=>CI(t,e)-CI(t,n)}const tee=(t,e,n)=>{if(typeof t!="string")return t;let r=t;try{r=JSON.parse(t)}catch{}return n.isType(r)?r:t};function _h(t){if("fields"in t){const e={};for(const[n,r]of Object.entries(t.fields))e[n]=_h(r);return t.setFields(e)}if(t.type==="array"){const e=t.optional();return e.innerType&&(e.innerType=_h(e.innerType)),e}return t.type==="tuple"?t.optional().clone({types:t.spec.types.map(_h)}):"optional"in t?t.optional():t}const nee=(t,e)=>{const n=[...Ca.normalizePath(e)];if(n.length===1)return n[0]in t;let r=n.pop(),o=Ca.getter(Ca.join(n),!0)(t);return!!(o&&r in o)};let kI=t=>Object.prototype.toString.call(t)==="[object Object]";function EI(t,e){let n=Object.keys(t.fields);return Object.keys(e).filter(r=>n.indexOf(r)===-1)}const ree=TI([]);function vv(t){return new OI(t)}class OI extends ti{constructor(e){super({type:"object",check(n){return kI(n)||typeof n=="function"}}),this.fields=Object.create(null),this._sortErrors=ree,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{e&&this.shape(e)})}_cast(e,n={}){var r;let o=super._cast(e,n);if(o===void 0)return this.getDefault(n);if(!this._typeCheck(o))return o;let i=this.fields,s=(r=n.stripUnknown)!=null?r:this.spec.noUnknown,a=[].concat(this._nodes,Object.keys(o).filter(p=>!this._nodes.includes(p))),l={},u=Object.assign({},n,{parent:l,__validating:n.__validating||!1}),f=!1;for(const p of a){let m=i[p],b=p in o,v=o[p];if(m){let y;u.path=(n.path?`${n.path}.`:"")+p,m=m.resolve({value:v,context:n.context,parent:l});let x=m instanceof ti?m.spec:void 0,S=x==null?void 0:x.strict;if(x!=null&&x.strip){f=f||p in o;continue}y=!n.__validating||!S?m.cast(v,u):v,y!==void 0&&(l[p]=y)}else b&&!s&&(l[p]=v);(b!==p in l||l[p]!==v)&&(f=!0)}return f?l:o}_validate(e,n={},r,o){let{from:i=[],originalValue:s=e,recursive:a=this.spec.recursive}=n;n.from=[{schema:this,value:s},...i],n.__validating=!0,n.originalValue=s,super._validate(e,n,r,(l,u)=>{if(!a||!kI(u)){o(l,u);return}s=s||u;let f=[];for(let p of this._nodes){let m=this.fields[p];!m||Ta.isRef(m)||f.push(m.asNestedTest({options:n,key:p,parent:u,parentPath:n.path,originalParent:s}))}this.runTests({tests:f,value:u,originalValue:s,options:n},r,p=>{o(p.sort(this._sortErrors).concat(l),u)})})}clone(e){const n=super.clone(e);return n.fields=Object.assign({},this.fields),n._nodes=this._nodes,n._excludedEdges=this._excludedEdges,n._sortErrors=this._sortErrors,n}concat(e){let n=super.concat(e),r=n.fields;for(let[o,i]of Object.entries(this.fields)){const s=r[o];r[o]=s===void 0?i:s}return n.withMutation(o=>o.setFields(r,[...this._excludedEdges,...e._excludedEdges]))}_getDefault(e){if("default"in this.spec)return super._getDefault(e);if(!this._nodes.length)return;let n={};return this._nodes.forEach(r=>{var o;const i=this.fields[r];let s=e;(o=s)!=null&&o.value&&(s=Object.assign({},s,{parent:s.value,value:s.value[r]})),n[r]=i&&"getDefault"in i?i.getDefault(s):void 0}),n}setFields(e,n){let r=this.clone();return r.fields=e,r._nodes=eee(e,n),r._sortErrors=TI(Object.keys(e)),n&&(r._excludedEdges=n),r}shape(e,n=[]){return this.clone().withMutation(r=>{let o=r._excludedEdges;return n.length&&(Array.isArray(n[0])||(n=[n]),o=[...r._excludedEdges,...n]),r.setFields(Object.assign(r.fields,e),o)})}partial(){const e={};for(const[n,r]of Object.entries(this.fields))e[n]="optional"in r&&r.optional instanceof Function?r.optional():r;return this.setFields(e)}deepPartial(){return _h(this)}pick(e){const n={};for(const r of e)this.fields[r]&&(n[r]=this.fields[r]);return this.setFields(n,this._excludedEdges.filter(([r,o])=>e.includes(r)&&e.includes(o)))}omit(e){const n=[];for(const r of Object.keys(this.fields))e.includes(r)||n.push(r);return this.pick(n)}from(e,n,r){let o=Ca.getter(e,!0);return this.transform(i=>{if(!i)return i;let s=i;return nee(i,e)&&(s=Object.assign({},i),r||delete s[e],s[n]=o(i)),s})}json(){return this.transform(tee)}exact(e){return this.test({name:"exact",exclusive:!0,message:e||kh.exact,test(n){if(n==null)return!0;const r=EI(this.schema,n);return r.length===0||this.createError({params:{properties:r.join(", ")}})}})}stripUnknown(){return this.clone({noUnknown:!0})}noUnknown(e=!0,n=kh.noUnknown){typeof e!="boolean"&&(n=e,e=!0);let r=this.test({name:"noUnknown",exclusive:!0,message:n,test(o){if(o==null)return!0;const i=EI(this.schema,o);return!e||i.length===0||this.createError({params:{unknown:i.join(", ")}})}});return r.spec.noUnknown=e,r}unknown(e=!0,n=kh.noUnknown){return this.noUnknown(!e,n)}transformKeys(e){return this.transform(n=>{if(!n)return n;const r={};for(const o of Object.keys(n))r[e(o)]=n[o];return r})}camelCase(){return this.transformKeys(hv.camelCase)}snakeCase(){return this.transformKeys(hv.snakeCase)}constantCase(){return this.transformKeys(e=>hv.snakeCase(e).toUpperCase())}describe(e){const n=(e?this.resolve(e):this).clone(),r=super.describe(e);r.fields={};for(const[i,s]of Object.entries(n.fields)){var o;let a=e;(o=a)!=null&&o.value&&(a=Object.assign({},a,{parent:a.value,value:a.value[i]})),r.fields[i]=s.describe(a)}return r}}vv.prototype=OI.prototype;const oee=t=>{const{open:e,anchorEl:n,onGenerateCitation:r,onClose:o}=t;return g.jsx(z.Popper,{open:e,anchorEl:n,placement:"bottom-end",style:{zIndex:1300},sx:{maxWidth:"500px"},children:g.jsxs(Lu,{component:z.Paper,p:1,boxShadow:9,gap:.25,children:[g.jsx(z.Typography,{variant:"body1",children:"Paste in a preformatted citation"}),g.jsx(z.Typography,{variant:"body2",color:"text.secondary",fontStyle:"italic",fontSize:".8em",children:"For best results, ensure your citations use a vertical bar ( | ) to separate the title, source, url, etc. Incomplete citations are allowed but may result in incompletely filled fields."}),g.jsx(Ht.Formik,{initialValues:{pasteExistingCitation:""},onSubmit:({pasteExistingCitation:i})=>{r(aee(i)),o()},children:({values:i,submitForm:s,setFieldValue:a})=>g.jsxs(Qo,{flexWrap:"wrap",justifyContent:"flex-end",children:[g.jsx(qM,{name:"pasteExistingCitation",errorMode:"collapse",label:"",placeholder:"Scientific News Today | How to Organize Your Workspace for Maximum Efficiency | https://mock-news-site.com | ACCESSED 2 JAN 2026 | Public Source",endIcon:g.jsx(z.Tooltip,{title:"Paste from Clipboard",children:g.jsx(z.IconButton,{"data-testid":"paste-content-button",onClick:()=>{navigator.clipboard.readText().then(l=>a("pasteExistingCitation",l))},children:g.jsx(PU,{})})})}),g.jsxs(Qo,{children:[g.jsx(Tr,{size:"small",variant:"outlined",onClick:o,"data-testid":"citation-table_paste-prompt_cancel",children:"Cancel"}),g.jsx(Tr,{size:"small",type:"submit",onClick:s,"data-testid":"citation-table_paste-prompt_submit",disabled:!i.pasteExistingCitation,children:"Prefill Citation"})]})]})})]})})},iee=["https://","http://","www."],see=new RegExp(iee.join("|")),aee=t=>{const e=t.replace(/\.\s*$/,"").split("|").map(f=>f.trim()).filter(Boolean),n=e.findIndex(f=>f.match(see)),r=e.findIndex(f=>f.toUpperCase().startsWith("ACCESSED")),o=e.findIndex(f=>/\bSOURCE\b/.test(f.toUpperCase()));let s=[n,r,o].find(f=>f!==-1)??e.length;const a=s-1,l=s-2;return{type:"Url",source:Ih(e,l),title:Ih(e,a),url:Ih(e,n),accessedAt:lee(e,r),classification:cee(e,o),details:Ih(e,o)}},Ih=(t,e)=>e<0||e>=t.length?"":t[e],lee=(t,e)=>e<0||e>=t.length?"":wZ(t[e].toUpperCase().replace(/^ACCESSED\s+/,"")),cee=(t,e)=>e<0||e>=t.length?"":t[e].toUpperCase().includes("PUBLIC")?"Public Source":"Proprietary Source",MI=t=>{const{loading:e=!1,type:n="submit",size:r="medium",...o}=t,s={small:16,medium:20,large:24}[r];return g.jsx(Tr,{type:n,disabled:e,size:r,startIcon:e?g.jsx(z.CircularProgress,{size:s,color:"inherit"}):null,...o})},_I=t=>{const{onCancel:e,onViewCitationTable:n,readOnly:r=!1,showViewAllCitationsBtn:o=!1,isLoading:i,onSaveClicked:s}=t;return r&&!o?null:r?g.jsx(z.DialogActions,{sx:{px:0},children:g.jsx(z.Button,{onClick:n,size:"small",variant:"outlined",children:"Back To Table"})}):g.jsxs(z.DialogActions,{sx:{px:0,justifyContent:"space-between"},children:[g.jsx(z.Box,{children:o&&g.jsx(z.Button,{onClick:n,size:"small",variant:"outlined",children:"View All Citations"})}),g.jsxs(Qo,{children:[g.jsx(z.Button,{onClick:e,variant:"outlined",size:"small",children:"Cancel"}),g.jsx(MI,{size:"small",loading:i,type:"button",onClick:s,children:"Save"})]})]})},uee=t=>{const{onSave:e,onCancel:n,onViewCitationTable:r,onClose:o,modifyCitation:i,readOnly:s=!1,showViewAllCitationsBtn:a=!1,canLaunchUrl:l}=t,u=J.useRef(null),[f,p]=J.useState(!1),[m,b]=J.useState(!1),v=J.useRef(null),[y,x]=J.useState(!1),[S,k]=J.useState({type:"Url",source:"",title:"",accessedAt:null,url:"",classification:"",details:""});J.useEffect(()=>{i&&k({...i,type:"Url"})},[]);const T={disabled:f,margin:"none",readOnly:s},C=!s;return g.jsxs(z.Box,{minWidth:"400px",maxWidth:"500px",children:[g.jsxs(Qo,{justifyContent:"space-between",children:[g.jsxs(Qo,{gap:2,children:[g.jsxs(z.Typography,{variant:"h6",margin:"10px 0",children:[s?"View":"Edit"," Citation"]}),C&&g.jsx(z.Button,{variant:"outlined",size:"small",ref:v,onClick:()=>x(!0),children:"Paste & Prefill"})]}),g.jsx(z.IconButton,{onClick:o,children:g.jsx(fp,{})})]}),g.jsx(Ht.Formik,{innerRef:u,enableReinitialize:!0,initialValues:S,onSubmit:async O=>{p(!0),e(O).catch(I=>{throw p(!1),I}).finally(()=>p(!1))},validationSchema:vv({title:Rl().required("Title is required"),accessedAt:bv().required("Accessed At is required"),url:Rl().required("URL is required"),classification:Rl().required("Classification is required")}),validateOnBlur:m,validateOnChange:m,children:({submitForm:O,setValues:I,values:N})=>g.jsxs(Ht.Form,{autoComplete:"off",children:[g.jsxs(z.Box,{display:"flex",flexDirection:"column",gap:s?1:0,alignItems:"flex-start",children:[g.jsx(ki,{...T,name:"title",required:!0}),g.jsx(ki,{...T,name:"source"}),g.jsx(ki,{...T,name:"details",label:"Details (e.g. Source Description)"}),g.jsx(Up,{...T,name:"accessedAt",required:!0,isDatePicker:!0}),s&&(l!=null&&l(N))?g.jsx(g.Fragment,{children:g.jsx(Ti,{label:"URL / Other Identifier",readOnlyValue:g.jsx(uv,{citation:N,canLaunchUrl:l,asLink:!0}),value:N.url??""})}):g.jsx(ki,{...T,name:"url",label:"URL / Other Identifier",required:!0,endIcon:g.jsx(uv,{citation:N,canLaunchUrl:l})}),g.jsx(UM,{...T,name:"classification",row:!0,required:!0,radios:dee})]}),g.jsx(_I,{isLoading:f,onSaveClicked:()=>{b(!0),O()},readOnly:s,showViewAllCitationsBtn:a,onViewCitationTable:r,onCancel:n}),g.jsx(oee,{open:y,onGenerateCitation:L=>{I(L,!0)},anchorEl:v.current,onClose:()=>x(!1)})]})})]})},dee=[{label:"Public Source",value:"Public Source",helperText:"URL is accessible to anyone from any location without special permissions. You can safely access this URL on any computer, including public or shared devices."},{label:"Proprietary Source",value:"Proprietary Source",helperText:"For private, sensitive, or access-controlled content. Use a VPN, or take extra precautions, when accessing to protect your privacy."}],fee=t=>{const{onSave:e,onCancel:n,onViewCitationTable:r,onClose:o,modifyCitation:i,readOnly:s=!1,showViewAllCitationsBtn:a=!1,onDownloadAttachment:l,onPreviewAttachment:u}=t,f=J.useRef(null),[p,m]=J.useState(!1),[b,v]=J.useState(!1),[y,x]=J.useState({type:"Attachment",title:"",file:void 0,fileName:""});return J.useEffect(()=>{i&&x({...i,type:"Attachment",file:void 0})},[]),g.jsxs(z.Box,{minWidth:"400px",maxWidth:"500px",children:[g.jsxs(z.Box,{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",children:[g.jsxs(z.Typography,{variant:"h6",margin:"10px 0",children:[s?"View":"Edit"," Attachment"]}),g.jsx(z.IconButton,{onClick:o,children:g.jsx(fp,{})})]}),g.jsx(Ht.Formik,{innerRef:f,enableReinitialize:!0,initialValues:y,validationSchema:vv().shape({title:Rl().required("Title is required"),fileName:Rl().required("A file is required")}),validateOnBlur:b,validateOnChange:b,onSubmit:async S=>{m(!0),e(S).catch(k=>{throw m(!1),k}).finally(()=>m(!1))},children:({values:S,setFieldValue:k,handleSubmit:T})=>{var O;const C=!s&&!S.id;return J.useEffect(()=>{var I,N;(I=S.file)!=null&&I.name&&k("fileName",(N=S.file)==null?void 0:N.name)},[(O=S.file)==null?void 0:O.name]),g.jsxs(Ht.Form,{autoComplete:"off",children:[g.jsx(ki,{name:"title",disabled:p,required:!0,margin:"none",readOnly:s}),g.jsxs(z.Box,{marginTop:C?1:0,children:[g.jsxs(Qo,{alignItems:"flex-start",children:[C&&g.jsx(EM,{name:"file",errorMode:"hidden"}),g.jsxs(Qo,{alignItems:"flex-end",children:[g.jsx(ki,{readOnly:!0,name:"fileName",label:C?"":"File Name"}),!C&&g.jsxs(Qo,{children:[g.jsx(iI,{citation:S,onDownloadAttachment:l}),g.jsx(sI,{citation:S,onPreviewAttachment:u})]})]})]}),g.jsx(yr,{name:"fileName"})]}),g.jsx(_I,{isLoading:p,onSaveClicked:()=>{v(!0),T()},readOnly:s,showViewAllCitationsBtn:a,onViewCitationTable:r,onCancel:n})]})}})]})},Fu=t=>{const{open:e=!1,onClose:n,title:r,children:o,actions:i,closeBtnLabel:s,closeButtonPosition:a,closeButtonProps:l={},disableDismiss:u=!1,...f}=t;if(!e)return null;const p=a==="bottom"||a==="top-and-bottom",m=a==="top"||a==="top-and-bottom",b=()=>{if(s&&p)return g.jsx(z.Button,{className:"MBv2_Modal_Close",onClick:t.onClose,...l,children:s})},v=()=>{if(i)return g.jsx(z.DialogActions,{className:"MBv2_Modal_Actions",children:g.jsxs(z.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",gap:"0.25rem",children:[g.jsx(z.Box,{children:b()}),g.jsxs(z.Box,{display:"flex",gap:".25rem",children:[...i]})]})});if(s&&p)return g.jsx(z.DialogActions,{className:"MBv2_Modal_Actions",children:g.jsx(z.Box,{children:b()})})};return g.jsxs(z.Dialog,{className:"MBv2_Modal",open:e,onClose:()=>{u||n==null||n()},...f,children:[typeof r=="string"?g.jsx(z.DialogTitle,{className:"MBv2_Modal_Title",children:g.jsxs(z.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[r,m&&g.jsx(z.IconButton,{"data-testid":"modal-header-close-btn",onClick:n,children:g.jsx(fp,{})})]})}):r,o&&(typeof o=="string"?g.jsx(z.DialogContent,{className:"MBv2_Modal_Content",children:g.jsx(z.DialogContentText,{className:"MBv2_Modal_Content_Text",children:o})}):o),v()]})};function pee(t){return Ke("MuiAlert",t)}const II=je("MuiAlert",["root","action","icon","message","filled","colorSuccess","colorInfo","colorWarning","colorError","filledSuccess","filledInfo","filledWarning","filledError","outlined","outlinedSuccess","outlinedInfo","outlinedWarning","outlinedError","standard","standardSuccess","standardInfo","standardWarning","standardError"]),hee=Le(g.jsx("path",{d:"M20,12A8,8 0 0,1 12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4C12.76,4 13.5,4.11 14.2, 4.31L15.77,2.74C14.61,2.26 13.34,2 12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0, 0 22,12M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z"}),"SuccessOutlined"),mee=Le(g.jsx("path",{d:"M12 5.99L19.53 19H4.47L12 5.99M12 2L1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z"}),"ReportProblemOutlined"),gee=Le(g.jsx("path",{d:"M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}),"ErrorOutline"),yee=Le(g.jsx("path",{d:"M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"}),"InfoOutlined"),bee=Le(g.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Close"),vee=t=>{const{variant:e,color:n,severity:r,classes:o}=t,i={root:["root",`color${Ne(n||r)}`,`${e}${Ne(n||r)}`,`${e}`],icon:["icon"],message:["message"],action:["action"]};return qe(i,pee,o)},xee=oe(fs,{name:"MuiAlert",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,e[n.variant],e[`${n.variant}${Ne(n.color||n.severity)}`]]}})(bt(({theme:t})=>{const e=t.palette.mode==="light"?zs:Va,n=t.palette.mode==="light"?Va:zs;return{...t.typography.body2,backgroundColor:"transparent",display:"flex",padding:"6px 16px",variants:[...Object.entries(t.palette).filter(Hn(["light"])).map(([r])=>({props:{colorSeverity:r,variant:"standard"},style:{color:t.vars?t.vars.palette.Alert[`${r}Color`]:e(t.palette[r].light,.6),backgroundColor:t.vars?t.vars.palette.Alert[`${r}StandardBg`]:n(t.palette[r].light,.9),[`& .${II.icon}`]:t.vars?{color:t.vars.palette.Alert[`${r}IconColor`]}:{color:t.palette[r].main}}})),...Object.entries(t.palette).filter(Hn(["light"])).map(([r])=>({props:{colorSeverity:r,variant:"outlined"},style:{color:t.vars?t.vars.palette.Alert[`${r}Color`]:e(t.palette[r].light,.6),border:`1px solid ${(t.vars||t).palette[r].light}`,[`& .${II.icon}`]:t.vars?{color:t.vars.palette.Alert[`${r}IconColor`]}:{color:t.palette[r].main}}})),...Object.entries(t.palette).filter(Hn(["dark"])).map(([r])=>({props:{colorSeverity:r,variant:"filled"},style:{fontWeight:t.typography.fontWeightMedium,...t.vars?{color:t.vars.palette.Alert[`${r}FilledColor`],backgroundColor:t.vars.palette.Alert[`${r}FilledBg`]}:{backgroundColor:t.palette.mode==="dark"?t.palette[r].dark:t.palette[r].main,color:t.palette.getContrastText(t.palette[r].main)}}}))]}})),wee=oe("div",{name:"MuiAlert",slot:"Icon",overridesResolver:(t,e)=>e.icon})({marginRight:12,padding:"7px 0",display:"flex",fontSize:22,opacity:.9}),See=oe("div",{name:"MuiAlert",slot:"Message",overridesResolver:(t,e)=>e.message})({padding:"8px 0",minWidth:0,overflow:"auto"}),Cee=oe("div",{name:"MuiAlert",slot:"Action",overridesResolver:(t,e)=>e.action})({display:"flex",alignItems:"flex-start",padding:"4px 0 0 16px",marginLeft:"auto",marginRight:-8}),DI={success:g.jsx(hee,{fontSize:"inherit"}),warning:g.jsx(mee,{fontSize:"inherit"}),error:g.jsx(gee,{fontSize:"inherit"}),info:g.jsx(yee,{fontSize:"inherit"})},AI=A.forwardRef(function(e,n){const r=mt({props:e,name:"MuiAlert"}),{action:o,children:i,className:s,closeText:a="Close",color:l,components:u={},componentsProps:f={},icon:p,iconMapping:m=DI,onClose:b,role:v="alert",severity:y="success",slotProps:x={},slots:S={},variant:k="standard",...T}=r,C={...r,color:l,severity:y,variant:k,colorSeverity:l||y},O=vee(C),I={slots:{closeButton:u.CloseButton,closeIcon:u.CloseIcon,...S},slotProps:{...f,...x}},[N,L]=_t("root",{ref:n,shouldForwardComponentProp:!0,className:ge(O.root,s),elementType:xee,externalForwardedProps:{...I,...T},ownerState:C,additionalProps:{role:v,elevation:0}}),[V,M]=_t("icon",{className:O.icon,elementType:wee,externalForwardedProps:I,ownerState:C}),[B,H]=_t("message",{className:O.message,elementType:See,externalForwardedProps:I,ownerState:C}),[F,P]=_t("action",{className:O.action,elementType:Cee,externalForwardedProps:I,ownerState:C}),[_,D]=_t("closeButton",{elementType:_l,externalForwardedProps:I,ownerState:C}),[R,j]=_t("closeIcon",{elementType:bee,externalForwardedProps:I,ownerState:C});return g.jsxs(N,{...L,children:[p!==!1?g.jsx(V,{...M,children:p||m[y]||DI[y]}):null,g.jsx(B,{...H,children:i}),o!=null?g.jsx(F,{...P,children:o}):null,o==null&&b?g.jsx(F,{...P,children:g.jsx(_,{size:"small","aria-label":a,title:a,color:"inherit",onClick:b,...D,children:g.jsx(R,{fontSize:"small",...j})})}):null]})});process.env.NODE_ENV!=="production"&&(AI.propTypes={action:c.node,children:c.node,classes:c.object,className:c.string,closeText:c.string,color:c.oneOfType([c.oneOf(["error","info","success","warning"]),c.string]),components:c.shape({CloseButton:c.elementType,CloseIcon:c.elementType}),componentsProps:c.shape({closeButton:c.object,closeIcon:c.object}),icon:c.node,iconMapping:c.shape({error:c.node,info:c.node,success:c.node,warning:c.node}),onClose:c.func,role:c.string,severity:c.oneOfType([c.oneOf(["error","info","success","warning"]),c.string]),slotProps:c.shape({action:c.oneOfType([c.func,c.object]),closeButton:c.oneOfType([c.func,c.object]),closeIcon:c.oneOfType([c.func,c.object]),icon:c.oneOfType([c.func,c.object]),message:c.oneOfType([c.func,c.object]),root:c.oneOfType([c.func,c.object])}),slots:c.shape({action:c.elementType,closeButton:c.elementType,closeIcon:c.elementType,icon:c.elementType,message:c.elementType,root:c.elementType}),sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object]),variant:c.oneOfType([c.oneOf(["filled","outlined","standard"]),c.string])});const Ru=t=>{var b;const{noIcon:e=!1,children:n,severity:r="success",variant:o="leftBorder",sx:i,title:s,...a}=t,{palette:l}=z.useTheme(),u=e?{icon:!1}:{},f=o==="leftBorder"?"standard":o,p=o==="leftBorder"?{...i,borderLeft:`4px solid ${(b=l[r])==null?void 0:b.main}`}:i,m=s?{icon:{sx:{mt:"6px"}}}:{};return g.jsxs(AI,{severity:r,variant:f,sx:p,slotProps:m,...u,...a,children:[s&&g.jsx(z.Typography,{variant:"h3",children:s}),n]})},PI=t=>g.jsx(Ru,{severity:"error",...t}),NI=t=>g.jsx(Ru,{severity:"success",...t}),Tee=t=>{const{alert:e,setAlert:n}=t,r=()=>n(void 0);return g.jsxs(g.Fragment,{children:[(e==null?void 0:e.type)==="Error"&&g.jsx(PI,{"data-testid":"citation-menu-error",onClose:r,title:e.title,children:e.message.toString()}),(e==null?void 0:e.type)==="Success"&&g.jsx(NI,{"data-testid":"citation-menu-success",onClose:r,children:e.message})]})};function $I({getCitationsPaginated:t,onCreateCitation:e,onUpdateCitation:n,onDeleteCitation:r,getCitationById:o,onDownloadAttachment:i,onPreviewAttachment:s,onSelectCitations:a,onClose:l,initialSelectedIds:u=[],onContentChange:f,onError:p=()=>{},renderAsPopup:m=!1,canSelect:b=!1,tableTitle:v="Attachments & Citations",addlActions:y,canLaunchUrl:x,readOnly:S,canSearch:k=!1}){const[T,C]=J.useState("Insert Citation/Attachment(s)"),[O,I]=J.useState(u),[N,L]=J.useState(void 0),[V,M]=J.useState(void 0),[B,H]=J.useState(!1),[F,P]=J.useState(!1),_=ee=>{M(void 0),C(ee)},[D,R]=J.useState(0);J.useEffect(()=>{f==null||f()},[T,V,f]);const j=(ee=!1)=>{(!m||ee)&&R(ie=>ie+1)},K=(ee,ie)=>{var Me;const we=typeof((Me=ie.response)==null?void 0:Me.data)=="string"&&ie.response.data,Ce=typeof ie.message=="string"&&ie.message;M({type:"Error",title:ee,message:we??Ce}),p(ie)},U=ee=>M({type:"Success",title:"",message:ee}),Y=async ee=>{if(T==="Insert Citation/Attachment(s)")throw Error("onSave called with invalid state");ee.id?await(n==null?void 0:n(ee).then(()=>{B?l():(_("Insert Citation/Attachment(s)"),j())}).catch(ie=>{K("Failed to update",ie)})):await(e==null?void 0:e(ee).then(ie=>{I([...O,ie.id]),_("Insert Citation/Attachment(s)"),j()}).catch(ie=>{K("Failed to create",ie)}))},fe=r&&(async ee=>r(ee).then(()=>{j(!0),I(O.filter(ie=>ie!==ee)),U("Successfully deleted")}).catch(ie=>K("Failed to delete",ie))),ue=o&&(ee=>{o(ee).then(ie=>{const we=!!ie.fileName;L(ie),_(we?"Attachment":"Citation")}).catch(ie=>{K("Failed to load",ie)}).finally(()=>P(!1))}),pe=n&&ue,Z=n&&ue,te=i&&(async ee=>i(ee).catch(ie=>{K(`Failed to download ${ee.fileName}`,ie)})),ce=s&&(async ee=>s(ee).catch(ie=>{K(`Failed to view ${ee.fileName}`,ie)})),ne=g.jsx(TQ,{refreshKey:D,getCitationsPaginated:(ee,ie)=>t(ee,ie).then(we=>(f==null||f(),we)),onCancel:l,onNewCitation:()=>{L(void 0),_("Citation")},onNewAttachment:()=>{L(void 0),_("Attachment")},onEditCitation:pe,onEditAttachment:Z,onViewCitation:ue,onViewAttachment:ue,onDeleteCitation:fe,onDownloadAttachment:te,onPreviewAttachment:ce,onSelect:a,setSelectedIds:I,selectedIds:O,onError:p,condenseTable:m,canSelect:b,title:v,addlActions:y,canCreate:!!e,canLaunchUrl:x,readOnly:S,showCloseBtn:m,canSearch:k}),re=g.jsx(uee,{modifyCitation:N,onSave:Y,onCancel:()=>B?l():_("Insert Citation/Attachment(s)"),onViewCitationTable:()=>{_("Insert Citation/Attachment(s)"),H(!1)},onClose:()=>m?l():_("Insert Citation/Attachment(s)"),readOnly:S,showViewAllCitationsBtn:S&&!B||!S&&B,canLaunchUrl:x}),le=g.jsx(fee,{onSave:Y,onCancel:()=>B?l():_("Insert Citation/Attachment(s)"),onViewCitationTable:()=>{_("Insert Citation/Attachment(s)"),H(!1)},onClose:()=>m?l():_("Insert Citation/Attachment(s)"),modifyCitation:N,readOnly:S,showViewAllCitationsBtn:S&&!B||!S&&B,onDownloadAttachment:te,onPreviewAttachment:ce}),ye=g.jsx(Tee,{alert:V,setAlert:M});J.useEffect(()=>{m&&u.length===1&&ue&&(P(!0),H(!0),ue(u[0]))},[]);const X=()=>{switch(T){case"Insert Citation/Attachment(s)":return ne;case"Citation":return re;case"Attachment":return le}};return m?g.jsxs(z.Box,{children:[ye,g.jsx(z.Box,{paddingTop:"8px",children:g.jsx(lv,{isLoading:F,children:X()})})]}):g.jsxs(z.Box,{width:"100%",children:[T==="Insert Citation/Attachment(s)"&&ye,g.jsx(z.Box,{paddingTop:"8px",children:ne}),g.jsx(Fu,{open:T!=="Insert Citation/Attachment(s)",children:g.jsxs(z.Box,{padding:"10px 20px",minWidth:"400px","data-testid":"citation-form-modal",children:[ye,T==="Citation"?re:le]})})]})}function LI({getSelectedCitationsPaginated:t,getCitationsPaginated:e,readOnly:n,initialSelectedIds:r=[],...o}){const i=(s,a)=>n?t(s,r):e(s,a);return g.jsx($I,{renderAsPopup:!0,canSelect:!n,getCitationsPaginated:i,readOnly:n,tableTitle:`${n?"Selected":"Insert"} Citation/Attachment(s)`,initialSelectedIds:r,...o})}const kee=z.styled("div",{name:"CitationBubbleMenu",slot:"content",overridesResolver:(t,e)=>e.content})(({theme:t})=>{const e=t.palette.mode==="dark";return{padding:t.spacing(1.5,2,.5),backgroundColor:e?"#101010":"#f9f9f9",border:`1px solid ${t.palette.grey[e?700:200]}`}});function Eee({getCitationsPaginated:t,getSelectedCitationsPaginated:e,onCreateCitation:n,onUpdateCitation:r,onDeleteCitation:o,getCitationById:i,onDownloadAttachment:s,onPreviewAttachment:a,canLaunchUrl:l,readOnly:u,canSearch:f,...p}){const m=Tt();if(m&&!("citationBubbleMenuHandler"in(m==null?void 0:m.storage)))throw new Error("You must add the CitationBubbleMenuHandler extension to the useEditor `extensions` array in order to use this component!");const b=m==null?void 0:m.storage.citationBubbleMenuHandler,v=b.isOpen,y=b.selectedIds,x=b.selectedNodePos,S=O=>{m&&(O.length===0?m.commands.deleteCitation(x):y.length===0?m.commands.insertCitation({ids:O}):m.commands.updateCitation({ids:O},x))},k=O=>{S(O),m==null||m.commands.closeCitationBubbleMenu()},T=()=>{S(y),m==null||m.commands.closeCitationBubbleMenu()},C=J.useCallback(()=>{requestAnimationFrame(()=>{m!=null&&m.view&&m.view.dispatch(m.view.state.tr)})},[m]);return m?g.jsx(Sy,{editor:m,open:v,...b.bubbleMenuOptions,...p,children:g.jsx(kee,{children:g.jsx(LI,{getCitationsPaginated:t,getSelectedCitationsPaginated:O=>e(O,y),onCreateCitation:n,onUpdateCitation:r,onDeleteCitation:o,getCitationById:i,onDownloadAttachment:s,onPreviewAttachment:a,onSelectCitations:k,onClose:T,initialSelectedIds:y,onContentChange:C,canLaunchUrl:l,readOnly:u,canSearch:f})})}):null}const Oee=()=>cn.create({name:"citationBubbleMenuHandler",addStorage(){return{isOpen:!1,selectedIds:[],bubbleMenuOptions:void 0,selectedNodePos:0}},addCommands(){return{openCitationBubbleMenu:(t={},e)=>({editor:n,dispatch:r})=>{var a;const{doc:o}=n.state,i=o.nodeAt(e??0),s=((a=i==null?void 0:i.attrs)==null?void 0:a.ids)??[];return r&&(this.storage.isOpen=!0,this.storage.selectedIds=s,this.storage.bubbleMenuOptions=t,this.storage.selectedNodePos=e??0),!0},closeCitationBubbleMenu:()=>({commands:t,dispatch:e})=>this.storage.isOpen?(t.focus(),e&&(this.storage.isOpen=!1,this.storage.selectedIds=[],this.storage.selectedNodePos=0),!0):!1}},onSelectionUpdate(){this.storage.isOpen&&!this.editor.isActive("citation")&&this.editor.commands.closeCitationBubbleMenu()},addKeyboardShortcuts(){return{"Mod-Shift-c":()=>(this.editor.commands.openCitationBubbleMenu(),!0)}}});function Mee(t){const e=Tt(),n=J.useRef(null);return g.jsx(wt,{buttonRef:n,tooltipLabel:"Insert Citation/Attachment",tooltipShortcutKeys:["mod","Shift","C"],disabled:!(e!=null&&e.isEditable),onClick:()=>e==null?void 0:e.commands.openCitationBubbleMenu({anchorEl:n.current,placement:"bottom"}),...t,children:g.jsxs(z.Box,{display:"flex",flexDirection:"row",gap:"4px",alignItems:"center",children:[g.jsx(IU,{fontSize:"small"}),g.jsx(z.Typography,{variant:"body2",children:"Insert Citation/Attachment"})]})})}const BI=J.createContext(void 0),FI=()=>{const t=J.useContext(BI);if(!t)throw new Error("useSync must be used inside CitationFieldProvider");return t},_ee=({node:t,HTMLAttributes:e,selected:n,extension:r,updateAttributes:o,deleteNode:i})=>{const s=t.attrs.ids||[],{citations:a,isLoaded:l}=FI(),[u,f]=J.useState(s?String(s):""),[p,m]=J.useState([]),b=r.options.citationMaxLength;if(J.useEffect(()=>{if(!l)return;const v=a.filter(S=>s.includes(S.id)),y=v.map(S=>dv(S.title,b)).join(", ");f(y),m(v);const x=v.map(S=>S.id);x.length===0?setTimeout(i,0):x.length!==s.length&&setTimeout(()=>o({ids:v.map(S=>S.id)}),0)},[a,s,l]),p.length!==0)return g.jsx(_b,{as:"span",...e,"data-testid":"citation-node-component","data-drag-handle":!0,onDragOver:v=>v.preventDefault(),onDrop:()=>{},children:g.jsx(z.Tooltip,{title:g.jsx(z.Box,{className:"citation-tooltip",children:p.map((v,y)=>{var k;const S=!!v.fileName?[v.title,v.fileName]:[v.title,v.source,v.details,(k=v.accessedAt)==null?void 0:k.slice(0,10),v.url,v.classification];return g.jsxs(z.Typography,{variant:"subtitle2",children:[S.filter(Boolean).join(" | "),y<p.length-1&&g.jsx(z.Divider,{className:"citation-tooltip-divider"})]},v.id)})}),slotProps:{tooltip:{sx:{maxWidth:500}}},children:g.jsx("a",{href:"#",onClick:v=>{v.preventDefault(),v.stopPropagation()},className:n?"selected-citation-link":"citation-link",children:u})})})},Iee=tn.create({name:"citation",group:"inline",inline:!0,atom:!0,selectable:!0,draggable:!0,addAttributes(){return{ids:{default:[],parseHTML:t=>{const e=t.getAttribute("ids");return e?e.split(",").map(n=>parseInt(n.trim(),10)).filter(n=>!isNaN(n)):[]},renderHTML:t=>({ids:Array.isArray(t.ids)?t.ids.join(","):""})}}},parseHTML(){return[{tag:"citation"}]},renderHTML({HTMLAttributes:t}){return["citation",Ct(t)]},addNodeView(){return Ib(_ee)},addProseMirrorPlugins(){return[new en({props:{handleClickOn:(t,e,n,r,o,i)=>n&&n.type.name==="citation"?(this.editor.commands.openCitationBubbleMenu({},r),!0):!1},appendTransaction(t,e,n){if(!t.some(i=>i.docChanged))return null;let r=n.tr,o=!1;return n.doc.descendants((i,s)=>{if(i.type.name!=="citation")return;const a=s+i.nodeSize,l=n.doc.nodeAt(a);if(l&&l.type===i.type){const u=[...new Set([...i.attrs.ids,...l.attrs.ids])],f=i.type.create({...i.attrs,ids:u});return r.replaceWith(s,a+l.nodeSize,f),o=!0,!1}}),o?r:null}})]},addCommands(){return{insertCitation:t=>({commands:e})=>e.insertContent({type:"citation",attrs:t}),updateCitation:(t,e)=>({state:n,dispatch:r,tr:o})=>{const i=n.doc.nodeAt(e);return!i||i.type.name!=="citation"?!1:(o.setNodeMarkup(e,void 0,t),r&&r(o),!0)},deleteCitation:t=>({tr:e,dispatch:n})=>{if(typeof t!="number")return!1;const r=t,o=t+1;return n&&n(e.delete(r,o)),!0}}}});function RI({editor:t,canComment:e=!0,onComment:n,commentCount:r,commentResolved:o,...i}){const s=J.useRef(null);if(!n)return null;const a=o?g.jsx(sE,{sx:{width:14,height:14},"data-testid":"resolved-checkmark"}):r,l=o?"success":"primary",u=o?{"& .MuiBadge-badge":{padding:0,height:16,minWidth:16}}:{"& .MuiBadge-badge":{fontSize:14,height:16,minWidth:16}};return e?g.jsx(wt,{buttonRef:s,tooltipLabel:"Comments",onClick:()=>{if(!t)return;const{from:f,to:p}=t.state.selection,m=t.state.doc.textBetween(f,p,`
409
409
  `).trim();n(m)},...i,children:g.jsx(z.Box,{display:"flex",flexDirection:"row",gap:"4px",alignItems:"center",children:g.jsx(z.Badge,{"data-testid":"comment-button-badge",badgeContent:a,color:l,sx:u,children:g.jsx(HU,{sx:{fontSize:"22px"}})})})}):null}const Dee=t=>{var Z;const{name:e,label:n=Ln(e),hideLabel:r=!1,required:o=!1,readOnly:i,margin:s="dense",citationMaxLength:a=24,getCitationsPaginated:l,getSelectedCitationsPaginated:u,onCreateCitation:f,onUpdateCitation:p,onDeleteCitation:m,getCitationById:b,onDownloadAttachment:v,onPreviewAttachment:y,onError:x=()=>{},placeholder:S="Start typing here...",errorMode:k="normal",canLaunchUrl:T,canSearch:C=!1,redoUndo:O=!1}=t,I=[RT.configure({code:!1,codeBlock:!1,heading:!1,blockquote:!1,horizontalRule:!1,strike:!1}),Xb,G2.configure({placeholder:S}),Oee(),Iee.configure({citationMaxLength:a})],[N,L,V]=Ht.useField({name:e}),{setValue:M}=V,{value:B}=N,{addUpdateCitation:H,deleteCitation:F,batchUpdate:P,citations:_}=FI();J.useEffect(()=>{var ne;const te=(ne=D==null?void 0:D.current)==null?void 0:ne.editor;if(!te)return;te.getHTML()!==B&&setTimeout(()=>{te.commands.setContent(B)},0)},[B]);const D=J.useRef(null),R={normal:{marginTop:"16px",marginBottom:"8px"},dense:{marginTop:"8px",marginBottom:"4px"},none:{margin:0}},j=(te=void 0)=>{var re,le;const ce=((le=(re=D.current)==null?void 0:re.editor)==null?void 0:le.getHTML())??"",ne=!ce.replace(/<\/?p>|<br>/g,"").trim();M(ne?"":ce,te)},K=J.useMemo(()=>ma.debounce(()=>j(!1),500),[M]),U=Vs(),{showDiff:Y,getPreviousValue:fe}=Hs(),ue=i??U;if(Y){const te=fe(e)??"",ce=B,ne=/<citation\s+ids="([^"]*)"><\/citation>/g,re=(X,ee)=>{const ie=ee.split(",").map(Number);return`<sup>${_.filter(we=>ie.includes(we.id)).map(we=>dv(we.title,a))}</sup>`},le=te.replace(ne,re),ye=ce.replace(ne,re);return g.jsx(Ti,{label:n,value:ye,showDiff:!0,diffSnapshot:le,mode:"html"})}const pe=ma.pick(t,["canComment","onComment","commentCount","commentResolved"]);return g.jsxs(z.Box,{id:`citation-field_${e}`,sx:{"& .ProseMirror":{"& h1, & h2, & h3, & h4, & h5, & h6":{scrollMarginTop:ue?0:50}},".MuiTiptap-RichTextContent-readonly ":{padding:0}},...R[s],display:"flex",flexDirection:"column",width:"100%",children:[g.jsxs(z.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[!r&&g.jsx(z.InputLabel,{htmlFor:`citation-field_${e}`,required:!i&&o,children:n}),i&&g.jsx(RI,{...pe,editor:(Z=D==null?void 0:D.current)==null?void 0:Z.editor})]}),g.jsx(hM,{ref:D,extensions:I,content:B,editable:!ue,renderControls:()=>{var te;return g.jsxs(jf,{justifyContent:"space-between",children:[g.jsxs(jf,{children:[g.jsx(Mee,{}),g.jsx(An,{}),g.jsx(CE,{}),g.jsx(AE,{}),g.jsx($E,{}),g.jsx(An,{}),g.jsx(PE,{}),g.jsx(TE,{})]}),g.jsx(RI,{...pe,editor:(te=D==null?void 0:D.current)==null?void 0:te.editor})]})},onBlur:()=>j(),onUpdate:K,RichTextFieldProps:{variant:ue?"standard":"outlined",MenuBarProps:{hide:ue},footer:O&&g.jsxs(z.Stack,{direction:"row",spacing:2,sx:{borderTop:te=>`1px solid ${te.palette.divider}`,p:1},children:[g.jsx(LE,{}),g.jsx(NE,{})]})},children:()=>g.jsx(Eee,{getCitationsPaginated:(te,ce)=>l(te,ce).then(ne=>(P(ne.data),ne)),getSelectedCitationsPaginated:u,onCreateCitation:f&&(te=>f(te).then(ce=>(H(ce),ce))),onUpdateCitation:p&&(te=>p(te).then(ce=>(H(ce),ce))),onDeleteCitation:m&&(te=>m(te).then(()=>F(te))),getCitationById:b,onDownloadAttachment:v,onPreviewAttachment:y,onError:x,canLaunchUrl:T,readOnly:ue,canSearch:C})}),g.jsx(yr,{name:e,id:`${e}-err`,errorMode:k})]})},Aee=t=>g.jsx(TM,{name:t.name,label:"Not Applicable",errorMode:"hidden"}),Pee=t=>{const{name:e="submit"}=t;return g.jsx(Tr,{name:e,type:"submit",...t})},Nee=t=>{const{label:e="Return to Top",icon:n=pp,scrollThresholdPx:r=100}=t,o=z.useScrollTrigger({threshold:r}),i=J.useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"})},[]);return g.jsx(z.Zoom,{in:o,children:g.jsx(z.Box,{sx:{position:"fixed",bottom:32,right:32,zIndex:1},children:g.jsxs(z.Fab,{onClick:i,color:"primary",size:"small",variant:"extended","aria-label":"Scroll back to top",children:[g.jsx(n,{fontSize:"medium"}),e]})})})},zI=t=>{const{label:e,menuOptions:n=[],icon:r}=t,o=bo.useNavigate(),[i,s]=A.useState(null),a=!!i,l=p=>{s(p.currentTarget)},u=()=>{s(null)};if(n.length===0)return null;const f=r&&!e;return g.jsxs(g.Fragment,{children:[g.jsx(z.Button,{startIcon:f?void 0:r,variant:"outlined",color:"inherit",sx:{minWidth:0,...f&&{paddingLeft:"6px",paddingRight:"6px"}},onClick:l,children:f?r:e}),g.jsx(z.Menu,{anchorEl:i,open:a,onClick:u,children:n.map(p=>g.jsxs(z.MenuItem,{...La(p,o),children:[p.icon&&g.jsx(z.ListItemIcon,{children:p.icon}),g.jsx(z.ListItemText,{primary:p.label})]},p.label))})]})},$ee=()=>{const{values:t,errors:e,status:n}=Ht.useFormikContext(),{palette:r}=z.useTheme();return g.jsx(z.Paper,{style:{backgroundColor:r.mode==="dark"?"#303030":"#f0f0f0",margin:"10px 0"},children:g.jsxs(z.List,{children:[g.jsxs(z.ListItem,{children:[g.jsx(z.Typography,{display:"block",variant:"h6",children:"Values"}),g.jsx("br",{}),g.jsx(z.Divider,{variant:"inset"}),g.jsx("pre",{children:JSON.stringify(t,null,2)})]}),g.jsx(z.Divider,{variant:"inset",component:"li"}),g.jsxs(z.ListItem,{id:"testing",children:[g.jsx(z.Typography,{display:"block",variant:"h6",children:"Errors"}),g.jsx("br",{}),g.jsx(z.Divider,{variant:"inset"}),g.jsx("pre",{children:JSON.stringify(e,null,2)})]}),g.jsxs(z.ListItem,{children:[g.jsx(z.Typography,{display:"block",variant:"h6",children:"Status"}),g.jsx("br",{}),g.jsx(z.Divider,{variant:"inset"}),g.jsx("pre",{children:JSON.stringify(n,null,2)})]})]})})},Lee=t=>{const{steps:e,orientation:n,inlineLabel:r=n=="vertical",isResponsive:o=!1}=t,{width:i}=oI();let s=!r,a=n;o&&(n&&console.warn("Stepper: Ignoring orientation. isResponsive is set to true, so the orientation is determined automatically based on the window size."),a=i<600?"vertical":"horizontal",a=="vertical"?s=!1:s=!r),n=="vertical"&&!r&&(console.warn("Stepper: ignoring inlineLabel={false}. Must use inline labels when orientation is vertical"),s=!1);const l=["steps","inlineLabel","orientation","isResponsive"],u={alternativeLabel:s,orientation:a,...lr({...t},l)};return g.jsx(z.Stepper,{...u,children:e.map(f=>g.jsx(z.Step,{children:g.jsx(z.StepLabel,{children:f})},f))})},Bee=t=>{const{name:e,label:n=Ln(e),labelProps:r={fontSize:"1.1em",color:"#808080",fontWeight:"600"},initialState:o,renderFormGroup:i,addButtonContent:s="Add Another",removeButtonContent:a=t.removePosition==="right"?g.jsx(JM,{}):"Remove",variant:l="card",addButtonSx:u,removeButtonSx:f,allowRemoveAll:p=!1,readOnly:m=!1,emptyListMsg:b="None",showDivider:v=!1,removePosition:y="bottom"}=t,[x]=Ht.useField({name:e}),{value:S}=x,k=T=>({display:"flex",flexDirection:T==="bottom"?"column":"row",alignItems:T==="bottom"?"flex-start":"center"});return g.jsxs(z.FormControl,{fullWidth:!0,children:[g.jsx(z.Typography,{...r,children:n}),m&&x.value.length===0?g.jsx(z.Typography,{children:b}):g.jsx(Ht.FieldArray,{name:e,render:T=>g.jsxs("div",{children:[S.map((C,O)=>g.jsx(J.Fragment,{children:g.jsx(Fee,{variant:l,content:g.jsxs(z.Box,{"data-testid":"form-group-container",sx:typeof y=="string"?k(y):{...y},children:[g.jsxs(z.Box,{width:"100%",children:[i(`${e}.${O}`,O),v&&O!==S.length-1&&g.jsx(z.Divider,{"data-testid":"divider"})]}),!m&&S.length>(p?0:1)&&g.jsx(z.Button,{"data-testid":"repeatable-form-group_remove-btn",sx:f,onClick:()=>T.remove(O),children:a})]})})},`${e}-${O}`)),!m&&g.jsx(z.Button,{"data-testid":"repeatable-form-group_add-btn",onClick:()=>T.push(o),sx:u,children:s})]})})]})},Fee=({variant:t,content:e})=>{switch(t){case"card":return g.jsx(z.Card,{"data-testid":"repeatable-form-group_card",sx:{padding:"8px",marginBottom:"8px"},children:g.jsx(z.CardContent,{children:e})});case"elevatedCard":return g.jsx(z.Card,{"data-testid":"repeatable-form-group_elevated-card",elevation:4,sx:{border:"unset",padding:"8px",marginBottom:"8px"},children:g.jsx(z.CardContent,{children:e})});case"none":return e}},Ree=t=>{const{confirmBtnLabel:e,onConfirm:n,confirmButtonProps:r={color:"primary",variant:"contained"},closeBtnLabel:o="Cancel",closeButtonPosition:i="bottom",...s}=t;return g.jsx(Fu,{actions:[g.jsx(z.Button,{className:"MBv2_ConfirmationModal_ConfirmBtn",onClick:n,...r,children:e})],closeBtnLabel:o,closeButtonPosition:i,...s})},zee=t=>{const{closeBtnLabel:e="OK",closeButtonPosition:n="bottom",closeButtonProps:r={color:"primary",variant:"contained"},...o}=t;return g.jsx(Fu,{closeBtnLabel:e,closeButtonPosition:n,closeButtonProps:r,...o})},Vee=t=>{const{primaryBtnLabel:e,onPrimaryAction:n,primaryActionProps:r={color:"primary",variant:"contained"},secondaryBtnLabel:o,onSecondaryAction:i,secondaryActionProps:s={color:"primary",variant:"outlined"},closeBtnLabel:a="Cancel",closeButtonPosition:l="bottom",...u}=t;return g.jsx(Fu,{actions:[g.jsx(z.Button,{className:"MBv2_DecisionModal_SecondaryAction",onClick:i,...s,children:o}),g.jsx(z.Button,{className:"MBv2_DecisionModal_PrimaryAction",onClick:n,...r,children:e})],closeBtnLabel:a,closeButtonPosition:l,...u})},Hee={added:{icon:MU,label:"Added",color:"success"},deleted:{icon:JM,label:"Deleted",color:"error"},modified:{icon:DU,label:"Modified",color:"info"},unmodified:{label:"Unmodified",color:"default"}},Wee=(t,e)=>g.jsxs(g.Fragment,{children:[g.jsx(z.Box,{"data-testid":"diff-table-cell-removed",sx:{backgroundColor:up},children:g.jsx("s",{children:t})}),g.jsx(z.Box,{"data-testid":"diff-table-cell-added",sx:{backgroundColor:cp},children:g.jsx("u",{children:e})})]}),jee=(t,e,n,r=!1)=>{var i;let o={};for(const s of t)if(!s.ignoreDiff){const a=Ll(s,e,r),l=Ll(s,n,r);(((i=s.isEqual)==null?void 0:i.call(s,e,n))??CM.isEqual(a,l))||(o[xn(s)]=Wee(a,l))}return o},VI=(t,e,n,r=!1,o)=>{const i=[],s=[];let a=0,l=0;for(e.sort((u,f)=>u.id-f.id),n.sort((u,f)=>u.id-f.id);a<e.length&&l<n.length;){const u=e[a],f=n[l];if(u.id===f.id){const p=jee(t,u,f,r);(o==null?void 0:o(u,f))??Object.keys(p).length===0?s.push({...f,changeType:"unmodified"}):i.push({...f,changeType:"modified",modifiedDiff:p}),a++,l++}else u.id<f.id?(i.push({...u,changeType:"deleted"}),a++):(i.push({...f,changeType:"added"}),l++)}for(;a<e.length;)i.push({...e[a],changeType:"deleted"}),a++;for(;l<n.length;)i.push({...n[l],changeType:"added"}),l++;return{dataDiff:i,dataUnmodified:s}},HI=t=>{const{beforeData:e,afterData:n,columns:r,isEqual:o,size:i,isMobileScreen:s}=t;t.renderExpand!=null&&o==null&&console.warn("DiffTable: isEqual prop should be provided when renderExpand is provided");const{dataDiff:a,dataUnmodified:l}=VI(r,e,n,s,o);return{columns:[{fieldName:"changeType",render:f=>{const p=Hee[f];return g.jsx(z.Chip,{color:p.color,size:i=="small"||i=="x-small"?"small":"medium",label:g.jsxs(z.Typography,{children:[p.icon&&g.jsx(Um,{icon:p.icon}),p.label]})})}},...r.map(f=>({...f,render:(p,m)=>{var b;return((b=m.modifiedDiff)==null?void 0:b[xn(f)])??Ll(f,m,s)}}))],data:a,unmodifiedData:l,renderExpand:t.renderExpand?f=>{const p=e.find(m=>m.id===f.id);return g.jsx(gw,{previousSnapshot:p,currentSnapshot:f,showDiff:f.changeType==="modified",children:t.renderExpand(f)})}:void 0}},WI=({columns:t,data:e,unmodifiedData:n=[],emptyTableMsg:r="No changes to display",renderExpand:o,size:i})=>{const[s,a]=J.useState(!1),l=()=>a(!s),u=`${s?"Hide":"Show"} ${n.length} unmodified row${n.length>1?"s":""}`;return g.jsxs(z.Box,{children:[g.jsx(cv,{columns:t,data:[...e,...s?n:[]],emptyTableMsg:r,renderExpand:o,size:i}),n.length>0&&g.jsx(z.Box,{children:g.jsx(z.Button,{onClick:l,children:u})})]})},Uee=t=>{const{emptyTableMsg:e="No changes to display",...n}=t,r=z.useMediaQuery(z.useTheme().breakpoints.down("sm")),o="beforeData"in n?HI({...n,isMobileScreen:r}):n;return g.jsx(WI,{...o,size:t.size})},qee=t=>{const{featureMenuOptions:e=[],copyright:n,logo:r,sx:o={},fontColor:i="primary"}=t,{palette:s}=z.useTheme(),a=bo.useNavigate();return g.jsxs(z.Box,{className:"MBv2_Footer",sx:{backgroundColor:s.mode==="dark"?"#222222":"#ededed",padding:"25px 30px",...o},children:[g.jsx(z.Box,{className:"MBv2_Footer_Logo",sx:{display:"flex",gap:2,alignItems:"center",paddingBottom:1},children:typeof r=="string"?g.jsx("img",{draggable:"false",src:r,style:{width:"200px"},alt:"logo"}):r}),g.jsxs(z.Box,{display:"flex",justifyContent:"space-between",flexWrap:"wrap",className:"MBv2_Footer_Nav_Links_Container",gap:2,children:[g.jsx(z.Box,{sx:{flexGrow:1},className:"MBv2_Footer_Nav_Links",display:"flex",flexDirection:"row",justifyContent:"flex-start",gap:3,children:e==null?void 0:e.map(l=>g.jsx(z.Link,{"data-testid":l.label,sx:{cursor:"pointer",fontSize:15},color:i,...La(l,a),children:l.label},l.label))}),n&&g.jsx(z.Typography,{style:{fontSize:15},"data-testid":"copyright",className:"MBv2_Footer_Copyright",color:i,children:n})]})]})},jI=t=>{const{menuOptionLists:e,anchor:n="left",children:r}=t,{pathname:o}=bo.useLocation(),i=bo.useNavigate(),[s,a]=J.useState(!1),l=(m,b)=>g.jsx(z.MenuList,{children:m.map(v=>g.jsxs(z.MenuItem,{...La(v,i,()=>a(!1)),children:[v.icon&&g.jsx(z.ListItemIcon,{children:v.icon}),g.jsx(z.ListItemText,{primary:v.label})]},`mobile-drawer-group-${b}-item-${v.path}`))}),f=(()=>{if(e){const m=e.filter(b=>b&&b.length>0);return m.length===0?null:m.map((b,v)=>g.jsxs(J.Fragment,{children:[l(b,v),v<m.length-1&&g.jsx(z.Divider,{})]},`mobile-drawer-group-${v}`))}return r?g.jsx(z.Box,{role:"presentation",onClick:()=>a(!1),children:r}):null})(),p=f??!1;return J.useEffect(()=>{a(!1)},[o]),p&&g.jsxs(g.Fragment,{children:[g.jsx(z.IconButton,{onClick:()=>a(!0),color:"inherit",title:"Menu",children:g.jsx(RU,{})}),g.jsx(z.Drawer,{"data-testid":"mobile-drawer",anchor:n,open:s,onClose:()=>a(!1),children:g.jsx(z.Box,{sx:{width:300},display:"flex",flexDirection:"column",justifyContent:"space-between",children:g.jsx(z.Box,{display:"flex",justifyContent:"start",flexDirection:"column",children:f})})})]})},UI=t=>{const{env:e,isProd:n}=t;return n?null:g.jsx(z.Paper,{sx:{borderRadius:0,display:"flex",alignItems:"center",justifyContent:"center"},children:g.jsxs(z.Typography,{variant:"h6",color:"error",children:[e," Environment - Test Data Only"]})})},qI=t=>{const{displayName:e,userMenuOptions:n}=t;return g.jsx(zI,{label:e,menuOptions:n,icon:g.jsx(VU,{})})},Dh=t=>{const{menuOptions:e,orientation:n="horizontal",activeTabIdx:r,sx:o=n=="vertical"?{"& .MuiTabs-indicator":{left:0}}:void 0,slotProps:i={indicator:{sx:n=="horizontal"?{height:4}:{width:4}}}}=t,{palette:s}=z.useTheme(),a=bo.useNavigate();return g.jsx(z.Tabs,{orientation:n,value:r??!1,sx:o,slotProps:i,children:e.map((l,u)=>g.jsx(z.Tab,{icon:l.icon,label:l.label,value:u,...La(l,a),sx:{alignItems:n=="vertical"?"flex-start":void 0,borderBottom:n=="vertical"?"1px solid":void 0,borderColor:"divider","&.Mui-selected":{backgroundColor:n=="vertical"?s.grey[s.mode=="dark"?800:50]:void 0,color:"inherit"}}},l.label))})},KI=t=>{const{featureMenuOptions:e=[],activeTabIdx:n,sx:r}=t;return e.length>0&&g.jsx(z.Paper,{sx:{pl:4,pr:4,borderRadius:0},"data-testid":"navBar",children:g.jsx(Dh,{menuOptions:e,activeTabIdx:n,sx:r})})},YI=t=>{const{onToggle:e}=t,{palette:n}=z.useTheme(),r=n.mode==="dark";return g.jsx(z.IconButton,{onClick:e,color:"inherit",title:"Dark Mode Toggle",children:r?g.jsx(GM,{}):g.jsx(KM,{})})},Kee=t=>{const{envInfo:e,headerRef:n,logo:r,featureMenuOptions:o=[],userMenuOptions:i=[],onToggleDarkMode:s,quickLinks:a=[],displayName:l,banner:u,position:f="fixed",children:p,sx:m,navBarSx:b}=t,v=bo.useNavigate(),y=z.useMediaQuery(z.useTheme().breakpoints.down("sm")),{palette:x}=z.useTheme(),{pathname:S}=bo.useLocation(),k=x.mode==="dark",[T,C]=A.useState(void 0);A.useEffect(()=>{const N=o.findIndex(L=>L.path&&S.startsWith(L.path));C(N>=0?N:void 0)},[S,o]);const O=s&&g.jsx(YI,{onToggle:s}),I=s&&(y||!y&&l)?[{icon:k?g.jsx(GM,{}):g.jsx(KM,{}),label:`Switch to ${k?"Light":"Dark"} mode`,onClick:s},...i]:i;return g.jsxs(z.AppBar,{ref:n,position:f,sx:m,elevation:4,children:[e&&g.jsx(UI,{...e}),u,g.jsxs(z.Toolbar,{sx:{color:"white",display:"flex",justifyContent:"space-between",gap:2},children:[g.jsx(z.Button,{disableRipple:!0,component:bo.Link,to:"/",children:r&&typeof r=="string"?g.jsx("img",{draggable:"false",src:r,style:{width:"200px",filter:"brightness(0) invert(1)"},alt:"logo"}):r}),g.jsxs(z.Box,{display:"flex",gap:2,alignItems:"center",children:[!l&&!y&&O,y&&g.jsx(jI,{menuOptionLists:[o,a,I],anchor:"right"}),!y&&g.jsxs(g.Fragment,{children:[g.jsx(z.Box,{display:"flex",gap:0,children:a==null?void 0:a.map((N,L)=>g.jsxs(z.Box,{display:"flex",alignItems:"center",children:[L>0&&g.jsx(z.Typography,{className:"quickLink-divider",color:x.primary.contrastText,children:"|"}),g.jsx(z.Button,{variant:"text",sx:{color:"white"},...La(N,v),children:g.jsxs(z.Box,{display:"flex",gap:"3px",alignItems:"center",children:[N.icon,N.label]})})]},N.label))}),p,l&&g.jsx(qI,{displayName:l,userMenuOptions:I})]})]})]}),!y&&g.jsx(KI,{featureMenuOptions:o,activeTabIdx:T,sx:b})]})},Yee=t=>{const{sx:e,menuOptions:n=[]}=t,{pathname:r}=bo.useLocation(),o=z.useMediaQuery(z.useTheme().breakpoints.down("sm")),[i,s]=J.useState(void 0);return J.useEffect(()=>{const a=n.findIndex(l=>l.path&&r.startsWith(l.path))??-1;s(a>=0?a:void 0)},[r,n]),!o&&n.length>0&&g.jsx(z.Box,{sx:e,children:g.jsx(z.Card,{sx:{height:"100%",width:200},children:g.jsx(Dh,{orientation:"vertical",menuOptions:n,activeTabIdx:i})})})},Gee=t=>{const{featureMenuOptions:e=[],activeTabIdx:n,sx:r}=t,{palette:o}=z.useTheme();return e.length>0&&g.jsx(Dh,{menuOptions:e,activeTabIdx:n,sx:{margin:"8px",backgroundColor:o.primary.dark,borderRadius:"8px","& .MuiTab-root":{color:o.secondary.light,flexDirection:"row",gap:"2px","& .MuiTab-icon":{marginBottom:"unset"},minHeight:"58px"},"& .MuiTab-root.Mui-selected":{color:o.primary.contrastText,fontSize:"120%"},"& .MuiTabs-indicator":{display:"none"},...r}})},Jee=({children:t,getCitations:e})=>{const[n,r]=J.useState([]),[o,i]=J.useState(!1);J.useEffect(()=>{(async()=>e().then(f=>{r(p=>{const m=new Set(p.map(v=>v.id));return[...p.filter(v=>!m.has(v.id)),...f]}),i(!0)}).catch(f=>{console.error(`Error fetching citations: ${f==null?void 0:f.toString()}`)}))()},[]);const s=J.useCallback(u=>{r(f=>{const p=f.map(v=>{const y=u.find(x=>x.id===v.id);return y||v}),m=new Set(f.map(v=>v.id)),b=u.filter(v=>!m.has(v.id));return[...p,...b]})},[]),a=J.useCallback(u=>{const f=n.findIndex(p=>p.id===u.id);r(f!==-1?p=>{const m=[...p];return m[f]=u,m}:[...n,u])},[n]),l=J.useCallback(u=>r(n.filter(f=>f.id!==u)),[n]);return g.jsx(BI.Provider,{value:{citations:n,isLoaded:o,addUpdateCitation:a,deleteCitation:l,batchUpdate:s},children:t})},Xee=t=>g.jsx(Ru,{severity:"info",...t}),Zee=t=>g.jsx(Ru,{severity:"warning",...t}),GI=t=>{const{crumbs:e}=t,n=bo.useNavigate(),r=e.map(o=>({label:o.label,onClick:()=>{var i;o.path?n(o.path):(i=o.onClick)==null||i.call(o)}}));return g.jsx(z.Breadcrumbs,{"aria-label":"breadcrumb",separator:g.jsx(zU,{}),sx:{marginBottom:2},children:r.map(({label:o,...i},s)=>s<e.length-1?g.jsx(z.Link,{color:"primary",sx:{cursor:"pointer",fontWeight:"600"},underline:"hover",...La(i,n),children:o},o):g.jsx(z.Typography,{color:"text.primary",children:o},o))})},Qee=t=>{const{title:e,message:n,type:r,onClose:o,autoHideDuration:i,variant:s="leftBorder",elevation:a=6}=t,l=ete(r);return g.jsx(z.Snackbar,{"data-testid":"message-snackbar",anchorOrigin:{vertical:"bottom",horizontal:"right"},open:!0,onClose:u=>{u==null&&o()},autoHideDuration:i,children:g.jsx(Ru,{"data-testid":"message-snackbar-alert",severity:l,iconMapping:{info:JI(r),warning:JI(r)},onClose:o,elevation:a,variant:s,children:n?g.jsxs(g.Fragment,{children:[g.jsx(z.AlertTitle,{"data-testid":"alertTitle",sx:{fontWeight:"bold"},children:e}),n]}):e})})},ete=t=>t=="logout"?"info":t=="timeout"?"warning":t,JI=t=>{if(t=="timeout")return g.jsx(OU,{});if(t=="logout")return g.jsx(FU,{})},tte=t=>{nte(t);const{title:e,createButtonLabel:n="Add Item",showAddButton:r=!1,onAdd:o=()=>alert("Not implemented yet"),breadcrumbs:i=[],children:s,sx:a={},bottomGutter:l=!1}=t,u=z.useMediaQuery(z.useTheme().breakpoints.down("sm"));return!e&&(!r||!n)?null:g.jsxs(z.Box,{"data-testid":"MBv2-Page-Header",sx:{...a,...l&&{marginBottom:"4px"}},children:[i.length>0&&g.jsx(GI,{crumbs:i}),g.jsxs(z.Box,{className:"MBv2_PageHeader_Header",display:"flex",flexDirection:u?"column":"row",justifyContent:"space-between",alignItems:"center",gap:1,children:[g.jsxs(z.Box,{className:"MBv2_PageHeader_TitleAndCreateBtn",display:"flex",flexDirection:"row",justifyContent:u||!s?"space-between":"start",alignItems:"center",width:"100%",gap:1,children:[typeof e=="string"?g.jsx(z.Typography,{className:"MBv2_PageHeader_Title",variant:"h2",children:e}):e,r&&g.jsxs(Tr,{className:"MBv2_PageHeader_CreateBtn",onClick:()=>o(),children:[g.jsx(_U,{style:{marginRight:"0.5rem"}}),n]})]}),s&&g.jsx(z.Box,{width:u?"100%":"50%",children:s})]})]})},nte=t=>{const{showAddButton:e,onAdd:n,createButtonLabel:r}=t,o="PageHeader component:";e&&!n&&console.warn(`${o} "showAddButton" is true but "onAdd" is not defined.`),e&&!r&&console.warn(`${o} "showAddButton" is true but "createButtonLabel" is not defined`)},rte=t=>{const{title:e,titleIcon:n,fullWidthIcon:r=!1,children:o,actionLabel:i,action:s,sx:a}=t,l=z.useMediaQuery(z.useTheme().breakpoints.down("sm"));return g.jsxs(z.Card,{sx:a||{padding:"30px 40px",display:"flex",flexDirection:"column",gap:"1rem"},children:[n&&g.jsx(z.Box,{className:"MBv2_SingleActionCard_Img",sx:[r?{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",gap:"20px",marginBottom:"10px"}:{display:"inline"}],children:n}),g.jsx(z.Typography,{variant:"h1",display:"inline",fontSize:"calc(20px + .9vw)",className:"MBv2_SingleActionCard_Title",children:e}),o,g.jsx(z.Button,{variant:"contained",color:"primary",onClick:s,fullWidth:l,className:"MBv2_SingleActionCard_ActionButton",children:i})]})},ote=t=>{const{title:e="Loading...",message:n}=t;return g.jsxs(z.Box,{className:"loading-page",sx:{gap:2},"data-testid":"loading-page",children:[g.jsxs(z.Box,{className:"text-content",children:[g.jsx(z.Typography,{variant:"h1","data-testid":"title",children:e}),n&&g.jsx(z.Typography,{"data-testid":"message",children:n})]}),g.jsx(z.CircularProgress,{size:75,"data-testid":"loading-spinner"})]})};function ite({...t}){return g.jsx($I,{onSelectCitations:()=>{},onClose:()=>{},...t})}const ste=t=>{const{size:e="small"}=t;let n=`${e}px`;switch(e){case"x-small":n="6px";break;case"small":n="10px";break;case"medium":n="14px";break;case"large":n="18px";break;case"x-large":n="22px";break}return g.jsx(z.Box,{height:n})},ate=t=>{const{text:e,indent:n=!1}=t;return e?g.jsx(z.Box,{component:"blockquote",sx:{borderLeft:"4px solid",borderColor:"primary.main",pl:1,bgcolor:"action.hover",m:0,ml:n?3:0},children:g.jsxs(z.Typography,{variant:"h6",component:"p",fontStyle:"italic",fontWeight:600,gutterBottom:!0,children:['"',e,'"']})}):null};Ae.AlertModal=zee,Ae.Autocomplete=wM,Ae.Blockquote=ate,Ae.Breadcrumbs=GI,Ae.Button=Tr,Ae.Checkbox=TM,Ae.CheckboxGroup=Z7,Ae.CitationField=Dee,Ae.CitationFieldProvider=Jee,Ae.CitationManager=ite,Ae.Column=Lu,Ae.ConfirmationModal=Ree,Ae.DarkModeToggle=YI,Ae.DateField=Up,Ae.DateRangeField=TZ,Ae.DecisionModal=Vee,Ae.Diff=vM,Ae.DiffProvider=gw,Ae.DiffTable=Uee,Ae.DiffTableView=WI,Ae.Drawer=jI,Ae.DynamicAutocomplete=J7,Ae.EnvironmentBanner=UI,Ae.ErrorAlert=PI,Ae.FileList=tU,Ae.FileUpload=EM,Ae.FloatingNavBar=Gee,Ae.Footer=qee,Ae.FormDebugger=$ee,Ae.Header=Kee,Ae.HelpTooltip=tI,Ae.IconTooltip=eI,Ae.InfoAlert=Xee,Ae.LoadingButton=MI,Ae.LoadingIndicator=ote,Ae.LoadingOverlay=lv,Ae.Location=CU,Ae.MenuButton=zI,Ae.Modal=Fu,Ae.MultiAutocomplete=X7,Ae.NavBar=KI,Ae.NotApplicableCheckbox=Aee,Ae.PageHeader=tte,Ae.PaginatedTable=nI,Ae.ProfileMenu=qI,Ae.RadioGroup=UM,Ae.RangeSlider=TU,Ae.ReadOnly=Ti,Ae.ReadOnlyProvider=hw,Ae.RepeatableFormGroup=Bee,Ae.RichTextField=vQ,Ae.Row=Qo,Ae.ScrollToTop=Nee,Ae.SearchField=XM,Ae.Select=kU,Ae.SelectableCitationManager=LI,Ae.Sidebar=Yee,Ae.SingleActionCard=rte,Ae.Snackbar=Qee,Ae.Spacer=ste,Ae.Stepper=Lee,Ae.Submit=Pee,Ae.SuccessAlert=NI,Ae.Switch=EU,Ae.Table=cv,Ae.Tabs=Dh,Ae.TextArea=qM,Ae.TextField=ki,Ae.TextIcon=Um,Ae.ValidationError=yr,Ae.WarningAlert=Zee,Ae.baseCitationTableColumns=lI,Ae.buildDiffData=VI,Ae.buildTableDiff=HI,Ae.createAppTheme=_P,Ae.useDiff=Hs,Ae.useReadOnly=Vs,Object.defineProperty(Ae,Symbol.toStringTag,{value:"Module"})}));