@lax-wp/editor 0.3.22 → 0.3.23
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.es.js +10 -18
- package/dist/index.umd.js +2 -2
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -22493,23 +22493,15 @@ const zD = Ae.create({
|
|
|
22493
22493
|
...m.attrs,
|
|
22494
22494
|
value: h
|
|
22495
22495
|
};
|
|
22496
|
-
|
|
22497
|
-
|
|
22498
|
-
|
|
22499
|
-
|
|
22500
|
-
|
|
22501
|
-
|
|
22502
|
-
|
|
22503
|
-
|
|
22504
|
-
|
|
22505
|
-
redlinePreviousAttrs: b ? m.attrs.redlinePreviousAttrs || null : JSON.stringify({
|
|
22506
|
-
variableName: m.attrs.variableName,
|
|
22507
|
-
value: m.attrs.value ?? ""
|
|
22508
|
-
})
|
|
22509
|
-
});
|
|
22510
|
-
} else
|
|
22511
|
-
o = o.setNodeMarkup(p, void 0, g);
|
|
22512
|
-
a = !0;
|
|
22496
|
+
d && (m.attrs.redlineType === mn || m.attrs.redlineType === fn) ? o = o.setNodeMarkup(p, void 0, {
|
|
22497
|
+
...g,
|
|
22498
|
+
redlineType: m.attrs.redlineType,
|
|
22499
|
+
redlineUserId: c.id,
|
|
22500
|
+
redlineUserName: c.name,
|
|
22501
|
+
redlineTimestamp: m.attrs.redlineTimestamp || (/* @__PURE__ */ new Date()).toISOString(),
|
|
22502
|
+
redlineAction: m.attrs.redlineAction || "add",
|
|
22503
|
+
redlinePreviousAttrs: m.attrs.redlinePreviousAttrs || null
|
|
22504
|
+
}) : o = o.setNodeMarkup(p, void 0, g), a = !0;
|
|
22513
22505
|
}
|
|
22514
22506
|
}), a ? (o = o.setMeta("addToHistory", !1), r(o), !0) : !1;
|
|
22515
22507
|
}
|
|
@@ -86678,7 +86670,7 @@ const Ed = "data-redline-column-action", Jo = "data-redline-column-id", Kl = (e,
|
|
|
86678
86670
|
const y = {
|
|
86679
86671
|
id: `comment-${Date.now()}-${Math.random()}`,
|
|
86680
86672
|
userId: t.currentUser?.id || "unknown",
|
|
86681
|
-
userName: t.currentUser?.name || "User",
|
|
86673
|
+
userName: t.currentUser?.name || t.currentUser?.email || "Anonymous User",
|
|
86682
86674
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
86683
86675
|
text: b
|
|
86684
86676
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -145,7 +145,7 @@ ${g}
|
|
|
145
145
|
${_}`:`
|
|
146
146
|
${_}`}}),l}function xA(e,t,n={}){const{state:r}=t,{doc:i,tr:o}=r,a=e;i.descendants((s,l)=>{const c=o.mapping.map(l),d=o.mapping.map(l)+s.nodeSize;let u=null;if(s.marks.forEach(m=>{if(m!==a)return!1;u=m}),!u)return;let p=!1;if(Object.keys(n).forEach(m=>{n[m]!==u.attrs[m]&&(p=!0)}),p){const m=e.type.create({...e.attrs,...n});o.removeMark(c,d,e.type),o.addMark(c,d,m)}}),o.docChanged&&t.view.dispatch(o)}var bt=class _C extends _p{constructor(){super(...arguments),this.type="node"}static create(t={}){const n=typeof t=="function"?t():t;return new _C(n)}configure(t){return super.configure(t)}extend(t){const n=typeof t=="function"?t():t;return super.extend(n)}},NA=class{constructor(e,t,n){this.isDragging=!1,this.component=e,this.editor=t.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=t.extension,this.node=t.node,this.decorations=t.decorations,this.innerDecorations=t.innerDecorations,this.view=t.view,this.HTMLAttributes=t.HTMLAttributes,this.getPos=t.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(e){var t,n,r,i,o,a,s;const{view:l}=this.editor,c=e.target,d=c.nodeType===3?(t=c.parentElement)==null?void 0:t.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(n=this.contentDOM)!=null&&n.contains(c)||!d)return;let u=0,p=0;if(this.dom!==d){const E=this.dom.getBoundingClientRect(),S=d.getBoundingClientRect(),y=(i=e.offsetX)!=null?i:(r=e.nativeEvent)==null?void 0:r.offsetX,T=(a=e.offsetY)!=null?a:(o=e.nativeEvent)==null?void 0:o.offsetY;u=S.x-E.x+y,p=S.y-E.y+T}const m=this.dom.cloneNode(!0);try{const E=this.dom.getBoundingClientRect();m.style.width=`${Math.round(E.width)}px`,m.style.height=`${Math.round(E.height)}px`,m.style.boxSizing="border-box",m.style.pointerEvents="none"}catch{}let _=null;try{_=document.createElement("div"),_.style.position="absolute",_.style.top="-9999px",_.style.left="-9999px",_.style.pointerEvents="none",_.appendChild(m),document.body.appendChild(_),(s=e.dataTransfer)==null||s.setDragImage(m,u,p)}finally{_&&setTimeout(()=>{try{_?.remove()}catch{}},0)}const h=this.getPos();if(typeof h!="number")return;const g=ge.create(l.state.doc,h),b=l.state.tr.setSelection(g);l.dispatch(b)}stopEvent(e){var t;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:e});const n=e.target;if(!(this.dom.contains(n)&&!((t=this.contentDOM)!=null&&t.contains(n))))return!1;const i=e.type.startsWith("drag"),o=e.type==="dragover"||e.type==="dragenter",a=e.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!a&&!i)return!0;const{isEditable:l}=this.editor,{isDragging:c}=this,d=!!this.node.type.spec.draggable,u=ge.isSelectable(this.node),p=e.type==="copy",m=e.type==="paste",_=e.type==="cut",h=e.type==="mousedown";if(!d&&u&&i&&e.target===this.dom&&e.preventDefault(),d&&i&&!c&&e.target===this.dom)return e.preventDefault(),!1;if(d&&l&&!c&&h){const g=n.closest("[data-drag-handle]");g&&(this.dom===g||this.dom.contains(g))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(c||o||a||p||m||_||h&&u)}ignoreMutation(e){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:e}):this.node.isLeaf||this.node.isAtom?!0:e.type==="selection"||this.dom.contains(e.target)&&e.type==="childList"&&(Fa()||rp())&&this.editor.isFocused&&[...Array.from(e.addedNodes),...Array.from(e.removedNodes)].every(n=>n.isContentEditable)?!1:this.contentDOM===e.target&&e.type==="attributes"?!0:!this.contentDOM.contains(e.target)}updateAttributes(e){this.editor.commands.command(({tr:t})=>{const n=this.getPos();return typeof n!="number"?!1:(t.setNodeMarkup(n,void 0,{...this.node.attrs,...e}),!0)})}deleteNode(){const e=this.getPos();if(typeof e!="number")return;const t=e+this.node.nodeSize;this.editor.commands.deleteRange({from:e,to:t})}};function Hi(e){return new oA({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{const o=Qe(e.getAttributes,void 0,r,i);if(o===!1||o===null)return null;const{tr:a}=t,s=r[r.length-1],l=r[0];let c=n.to;if(s){const d=l.search(/\S/),u=n.from+l.indexOf(s),p=u+s.length;if(cp(n.from,n.to,t.doc).filter(h=>h.mark.type.excluded.find(b=>b===e.type&&b!==h.mark.type)).filter(h=>h.to>u).length)return null;p<n.to&&a.delete(p,n.to),u>n.from&&a.delete(n.from+d,u),c=n.from+d+s.length,a.addMark(n.from+d,c,e.type.create(o||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||a.removeStoredMark(e.type)}}})}var bp,Rb;function RA(){return Rb||(Rb=1,bp=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t=="object"&&typeof n=="object"){if(t.constructor!==n.constructor)return!1;var r,i,o;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;for(i of t.entries())if(!n.has(i[0]))return!1;for(i of t.entries())if(!e(i[1],n.get(i[0])))return!1;return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;for(i of t.entries())if(!n.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(n)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(t[i]!==n[i])return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(o=Object.keys(t),r=o.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,o[i]))return!1;for(i=r;i--!==0;){var a=o[i];if(!(a==="_owner"&&t.$$typeof)&&!e(t[a],n[a]))return!1}return!0}return t!==t&&n!==n}),bp}var AA=RA();const OA=eu(AA);var Ol={exports:{}},Ep={};var Ab;function IA(){if(Ab)return Ep;Ab=1;var e=A,t=ru();function n(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var r=typeof Object.is=="function"?Object.is:n,i=t.useSyncExternalStore,o=e.useRef,a=e.useEffect,s=e.useMemo,l=e.useDebugValue;return Ep.useSyncExternalStoreWithSelector=function(c,d,u,p,m){var _=o(null);if(_.current===null){var h={hasValue:!1,value:null};_.current=h}else h=_.current;_=s(function(){function b(x){if(!E){if(E=!0,S=x,x=p(x),m!==void 0&&h.hasValue){var v=h.value;if(m(v,x))return y=v}return y=x}if(v=y,r(S,x))return v;var C=p(x);return m!==void 0&&m(v,C)?(S=x,v):(S=x,y=C)}var E=!1,S,y,T=u===void 0?null:u;return[function(){return b(d())},T===null?void 0:function(){return b(T())}]},[d,u,p,m]);var g=i(c,_[0],_[1]);return a(function(){h.hasValue=!0,h.value=g},[g]),l(g),g},Ep}var Sp={};var Ob;function kA(){return Ob||(Ob=1,process.env.NODE_ENV!=="production"&&(function(){function e(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=A,n=ru(),r=typeof Object.is=="function"?Object.is:e,i=n.useSyncExternalStore,o=t.useRef,a=t.useEffect,s=t.useMemo,l=t.useDebugValue;Sp.useSyncExternalStoreWithSelector=function(c,d,u,p,m){var _=o(null);if(_.current===null){var h={hasValue:!1,value:null};_.current=h}else h=_.current;_=s(function(){function b(x){if(!E){if(E=!0,S=x,x=p(x),m!==void 0&&h.hasValue){var v=h.value;if(m(v,x))return y=v}return y=x}if(v=y,r(S,x))return v;var C=p(x);return m!==void 0&&m(v,C)?(S=x,v):(S=x,y=C)}var E=!1,S,y,T=u===void 0?null:u;return[function(){return b(d())},T===null?void 0:function(){return b(T())}]},[d,u,p,m]);var g=i(c,_[0],_[1]);return a(function(){h.hasValue=!0,h.value=g},[g]),l(g),g},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Sp}var Ib;function wA(){return Ib||(Ib=1,process.env.NODE_ENV==="production"?Ol.exports=IA():Ol.exports=kA()),Ol.exports}var MA=wA(),DA=(...e)=>t=>{e.forEach(n=>{typeof n=="function"?n(t):n&&(n.current=t)})},LA=({contentComponent:e})=>{const t=__.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot);return f.jsx(f.Fragment,{children:Object.values(t)})};function PA(){const e=new Set;let t={};return{subscribe(n){return e.add(n),()=>{e.delete(n)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(n,r){t={...t,[n]:Ai.createPortal(r.reactElement,r.element,n)},e.forEach(i=>i())},removeRenderer(n){const r={...t};delete r[n],t=r,e.forEach(i=>i())}}}var BA=class extends A.Component{constructor(e){var t;super(e),this.editorContentRef=A.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((t=e.editor)!=null&&t.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const e=this.props.editor;if(e&&!e.isDestroyed&&e.options.element){if(e.contentComponent)return;const t=this.editorContentRef.current;t.append(e.view.dom),e.setOptions({element:t}),e.contentComponent=PA(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var e;const t=this.props.editor;if(t){this.initialized=!1,t.isDestroyed||t.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),t.contentComponent=null;try{if(!((e=t.view.dom)!=null&&e.firstChild))return;const n=document.createElement("div");n.append(t.view.dom),t.setOptions({element:n})}catch{}}}render(){const{editor:e,innerRef:t,...n}=this.props;return f.jsxs(f.Fragment,{children:[f.jsx("div",{ref:DA(t,this.editorContentRef),...n}),e?.contentComponent&&f.jsx(LA,{contentComponent:e.contentComponent})]})}},FA=A.forwardRef((e,t)=>{const n=A.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return A.createElement(BA,{key:n,innerRef:t,...e})}),UA=A.memo(FA),zA=typeof window<"u"?A.useLayoutEffect:A.useEffect,HA=class{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 t=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",t),()=>{n.off("transaction",t)}}}};function kb(e){var t;const[n]=A.useState(()=>new HA(e.editor)),r=MA.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,e.selector,(t=e.equalityFn)!=null?t:OA);return zA(()=>n.watch(e.editor),[e.editor,n]),A.useDebugValue(r),r}var wb=process.env.NODE_ENV!=="production",Tp=typeof window>"u",GA=Tp||!!(typeof window<"u"&&window.next),VA=class hC{constructor(t){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=t,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(t){this.editor=t,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0){if(Tp||GA){if(wb)throw new Error("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches.");return null}return this.createEditor()}if(this.options.current.immediatelyRender&&Tp&&wb)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 t={...this.options.current,onBeforeCreate:(...r)=>{var i,o;return(o=(i=this.options.current).onBeforeCreate)==null?void 0:o.call(i,...r)},onBlur:(...r)=>{var i,o;return(o=(i=this.options.current).onBlur)==null?void 0:o.call(i,...r)},onCreate:(...r)=>{var i,o;return(o=(i=this.options.current).onCreate)==null?void 0:o.call(i,...r)},onDestroy:(...r)=>{var i,o;return(o=(i=this.options.current).onDestroy)==null?void 0:o.call(i,...r)},onFocus:(...r)=>{var i,o;return(o=(i=this.options.current).onFocus)==null?void 0:o.call(i,...r)},onSelectionUpdate:(...r)=>{var i,o;return(o=(i=this.options.current).onSelectionUpdate)==null?void 0:o.call(i,...r)},onTransaction:(...r)=>{var i,o;return(o=(i=this.options.current).onTransaction)==null?void 0:o.call(i,...r)},onUpdate:(...r)=>{var i,o;return(o=(i=this.options.current).onUpdate)==null?void 0:o.call(i,...r)},onContentError:(...r)=>{var i,o;return(o=(i=this.options.current).onContentError)==null?void 0:o.call(i,...r)},onDrop:(...r)=>{var i,o;return(o=(i=this.options.current).onDrop)==null?void 0:o.call(i,...r)},onPaste:(...r)=>{var i,o;return(o=(i=this.options.current).onPaste)==null?void 0:o.call(i,...r)},onDelete:(...r)=>{var i,o;return(o=(i=this.options.current).onDelete)==null?void 0:o.call(i,...r)}};return new fA(t)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(t){return this.subscriptions.add(t),()=>{this.subscriptions.delete(t)}}static compareOptions(t,n){return Object.keys(t).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&t.extensions&&n.extensions?t.extensions.length!==n.extensions.length?!1:t.extensions.every((i,o)=>{var a;return i===((a=n.extensions)==null?void 0:a[o])}):t[r]===n[r])}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&t.length===0?hC.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(t){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=t;return}if(this.previousDeps.length===t.length&&this.previousDeps.every((r,i)=>r===t[i]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=t}scheduleDestroy(){const t=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===t){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===t&&this.setEditor(null))},1)}};function YA(e={},t=[]){const n=A.useRef(e);n.current=e;const[r]=A.useState(()=>new VA(n)),i=__.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return A.useDebugValue(i),A.useEffect(r.onRender(t)),kb({editor:i,selector:({transactionNumber:o})=>e.shouldRerenderOnTransaction===!1||e.shouldRerenderOnTransaction===void 0?null:e.immediatelyRender&&o===0?0:o+1}),i}var Mb=A.createContext({editor:null});Mb.Consumer;var Db=()=>A.useContext(Mb),Lb=A.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),Pb=()=>A.useContext(Lb);function $A({as:e="div",...t}){const{nodeViewContentRef:n,nodeViewContentChildren:r}=Pb();return f.jsx(e,{...t,ref:n,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...t.style},children:r})}var yp=A.forwardRef((e,t)=>{const{onDragStart:n}=Pb(),r=e.as||"div";return f.jsx(r,{...e,ref:t,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...e.style}})});function Bb(e){return!!(typeof e=="function"&&e.prototype&&e.prototype.isReactComponent)}function Fb(e){return!!(typeof e=="object"&&e.$$typeof&&(e.$$typeof.toString()==="Symbol(react.forward_ref)"||e.$$typeof.description==="react.forward_ref"))}function WA(e){return!!(typeof e=="object"&&e.$$typeof&&(e.$$typeof.toString()==="Symbol(react.memo)"||e.$$typeof.description==="react.memo"))}function jA(e){if(Bb(e)||Fb(e))return!0;if(WA(e)){const t=e.type;if(t)return Bb(t)||Fb(t)}return!1}function qA(){try{if(A.version)return parseInt(A.version.split(".")[0],10)>=19}catch{}return!1}var KA=class{constructor(e,{editor:t,props:n={},as:r="div",className:i=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=e,this.editor=t,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),i&&this.element.classList.add(...i.split(" ")),this.editor.isInitialized?Ai.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var e;const t=this.component,n=this.props,r=this.editor,i=qA(),o=jA(t),a={...n};a.ref&&!(i||o)&&delete a.ref,!a.ref&&(i||o)&&(a.ref=s=>{this.ref=s}),this.reactElement=f.jsx(t,{...a}),(e=r?.contentComponent)==null||e.setRenderer(this.id,this)}updateProps(e={}){this.props={...this.props,...e},this.render()}destroy(){var e;const t=this.editor;(e=t?.contentComponent)==null||e.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(e){Object.keys(e).forEach(t=>{this.element.setAttribute(t,e[t])})}};A.createContext({markViewContentRef:()=>{}});var QA=class extends NA{constructor(e,t,n){if(super(e,t,n),!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 r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.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:(l={})=>this.updateAttributes(l),deleteNode:()=>this.deleteNode(),ref:A.createRef()};if(!this.component.displayName){const l=c=>c.charAt(0).toUpperCase()+c.substring(1);this.component.displayName=l(this.extension.name)}const r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:l=>{l&&this.contentDOMElement&&l.firstChild!==this.contentDOMElement&&(l.hasAttribute("data-node-view-wrapper")&&l.removeAttribute("data-node-view-wrapper"),l.appendChild(this.contentDOMElement))}},i=this.component,o=A.memo(l=>f.jsx(Lb.Provider,{value:r,children:A.createElement(i,l)}));o.displayName="ReactNodeView";let a=this.node.isInline?"span":"div";this.options.as&&(a=this.options.as);const{className:s=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new KA(o,{editor:this.editor,props:e,as:a,className:`node-${this.node.type.name} ${s}`.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.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:t}=this.editor.state.selection,n=this.getPos();if(typeof n=="number")if(e<=n&&t>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(e,t,n){const r=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,o=this.decorations,a=this.innerDecorations;return this.node=e,this.decorations=t,this.innerDecorations=n,this.options.update({oldNode:i,oldDecorations:o,newNode:e,newDecorations:t,oldInnerDecorations:a,innerDecorations:n,updateProps:()=>r({node:e,decorations:t,innerDecorations:n})})}return e===this.node&&this.decorations===t&&this.innerDecorations===n||(this.node=e,this.decorations=t,this.innerDecorations=n,r({node:e,decorations:t,innerDecorations:n})),!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 t=this.editor.extensionManager.attributes,n=za(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:n})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}};function Cp(e,t){return n=>n.editor.contentComponent?new QA(e,n,t):{}}const XA=28,Va=e=>e.charAt(0).toUpperCase()+e.slice(1),Ub=["Text","Table"],Gi={EDITING:"editing",SUGGESTING:"suggesting",VIEWING:"viewing"},ui={EDITING:{label:Va(Gi.EDITING),value:Gi.EDITING},SUGGESTING:{label:Va(Gi.SUGGESTING),value:Gi.SUGGESTING},VIEWING:{label:Va(Gi.VIEWING),value:Gi.VIEWING}},ZA=[{label:"8",value:8},{label:"9",value:9},{label:"10",value:10},{label:"11",value:11},{label:"12",value:12},{label:"14",value:14},{label:"16",value:16},{label:"18",value:18},{label:"20",value:20},{label:"22",value:22},{label:"24",value:24},{label:"26",value:26},{label:"28",value:28},{label:"32",value:32},{label:"36",value:36},{label:"48",value:48},{label:"72",value:72},{label:"96",value:96}],JA=[{label:"1.0",value:"1"},{label:"1.15",value:"1.15"},{label:"1.5",value:"1.5"},{label:"2.0",value:"2"},{label:"2.5",value:"2.5"},{label:"3.0",value:"3"}],zb=[{label:"Andale Mono",value:'"Andale Mono", monospace'},{label:"Arial",value:"Arial, sans-serif"},{label:"Baskerville",value:"Baskerville, serif"},{label:"Brush Script MT",value:'"Brush Script MT", cursive'},{label:"Cambria",value:"Cambria, serif"},{label:"Century Gothic",value:'"Century Gothic", sans-serif'},{label:"Comic Sans MS",value:'"Comic Sans MS", sans-serif'},{label:"Consolas",value:"Consolas, monospace"},{label:"Constantia",value:"Constantia, serif"},{label:"Copperplate",value:"Copperplate, serif"},{label:"Courier New",value:'"Courier New", monospace'},{label:"Didot",value:"Didot, serif"},{label:"Franklin Gothic Medium",value:'"Franklin Gothic Medium", sans-serif'},{label:"Garamond",value:'"Garamond", serif'},{label:"Georgia",value:"Georgia, serif"},{label:"Gill Sans",value:'"Gill Sans", sans-serif'},{label:"Helvetica",value:"Helvetica, sans-serif"},{label:"Lucida Console",value:'"Lucida Console", monospace'},{label:"Lucida Sans",value:'"Lucida Sans", sans-serif'},{label:"Menlo",value:"Menlo, monospace"},{label:"Monaco",value:"Monaco, monospace"},{label:"Optima",value:"Optima, sans-serif"},{label:"Palatino",value:'"Palatino", serif'},{label:"Papyrus",value:"Papyrus, fantasy"},{label:"Segoe UI",value:'"Segoe UI", sans-serif'},{label:"System UI",value:'system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'},{label:"Tahoma",value:"Tahoma, sans-serif"},{label:"Times New Roman",value:'"Times New Roman", serif'},{label:"Trebuchet MS",value:'"Trebuchet MS", sans-serif'},{label:"Verdana",value:"Verdana, sans-serif"}],zn={LEFT:"left",CENTER:"center",RIGHT:"right"},eO=[["#FFFFFF","#000000","#2D7FF9","#18A0FB","#0FA958","#F24726","#FF9800","#FFCC00","#9C27B0"],["#F5F5F5","#7A7A7A","#D0E8FF","#A6D4FA","#B3F0CA","#FFD8D6","#FFE0B2","#FFF9C4","#E1BEE7"],["#E0E0E0","#9E9E9E","#90CAF9","#81D4FA","#A5D6A7","#FFAB91","#FFCC80","#FFF176","#CE93D8"],["#BDBDBD","#757575","#42A5F5","#29B6F6","#66BB6A","#FF8A65","#FFB74D","#FFF59D","#BA68C8"],["#9E9E9E","#616161","#1E88E5","#039BE5","#43A047","#F4511E","#FB8C00","#FFD600","#8E24AA"],["#757575","#424242","#1565C0","#0288D1","#2E7D32","#D84315","#EF6C00","#FFC107","#6A1B9A"],["#616161","#212121","#0D47A1","#0277BD","#1B5E20","#BF360C","#E65100","#FFB300","#4A148C"]],tO=["#F44336","#FF5722","#FFC107","#CDDC39","#4CAF50","#009688","#03A9F4","#2196F3","#673AB7","#9C27B0"],nO=[[{key:"decimal",main:["1.","2."],nested:["a.","b."],deepNested:["i.","ii."]},{key:"decimal-parenthesis",main:["1)","2)"],nested:["a)","b)"],deepNested:["i)","ii)"]},{key:"decimal-nested",main:["1.","2."],nested:["1.1","1.2"],deepNested:["1.2.1","1.2.2"]}],[{key:"upper-alpha-mixed",main:["A.","B."],nested:["a.","b."],deepNested:["i.","ii."]},{key:"upper-roman-mixed",main:["I.","II."],nested:["A.","B."],deepNested:["1.","2."]},{key:"decimal-leading-zero-mixed",main:["01.","02."],nested:["a.","b."],deepNested:["i.","ii."]}]],rO=[[{key:"default",main:["●","●"],nested:["○","○"],deepNested:["■","■"]},{key:"diamondArrow",main:["❖","❖"],nested:["➤","➤"],deepNested:["■","■"]},{key:"square",main:["☐","☐"],nested:["☐","☐"],deepNested:["☐","☐"]}],[{key:"arrowDiamond",main:["➔","➔"],nested:["◆","◆"],deepNested:["●","●"]},{key:"star",main:["★","★"],nested:["○","○"],deepNested:["■","■"]},{key:"arrowCircle",main:["➤","➤"],nested:["○","○"],deepNested:["■","■"]}]],Hb=100,Gb=3,Vb="data-language",Yb="data-theme",iO="plaintext",$b="dark",Il="data-align",oO="left",Io="data-style-type",vp="single-line",aO="hr--",xp="data-list-type",kl="decimal",Np="data-list-type",Rp="default",Ap="data-type",Op="page-break",sO="editor-page-break",lO="editor-page-break-line",Vi="data-variable-name",ko="data-value",Wb="variable-text",Ya="data-table-type",Hn="data-table-id",jb="data-table-name",wo="data-row-id",Mo="data-header-id",Yi="data-cell-id",qb="data-column-selected",ye="data-redline-type",Ve="data-redline-user-id",je="data-redline-user-name",Ye="data-redline-timestamp",cn="user-insertion",$i="user-deletion",dn="ai-insertion",Wi="ai-deletion",Ip="data-user-id",Kb="data-user-name",wl="data-timestamp",Ml="data-user-insertion",Dl="data-user-deletion",Ll="data-ai-insertion",Pl="data-ai-deletion",cO="user-insertion",dO="user-deletion",uO="ai-insertion",pO="ai-deletion",Qb="redline-table-insertion",Xb="redline-table-deletion",mO="redline-mark-active",fO="redline:markClick",_O=3e3;function hO(e,t){return t==="descriptive"&&e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e}function gO(e){if(Array.isArray(e))return e;if(typeof e=="string"&&e.trim())try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}return[]}function Zb(e){if(e.type!=="anonymizedLink")return e;const t=e.attrs??{},n=gO(t.anonymizedData),r=n[0]?.value??t.href??null;return t.showValue===!0?{type:"link",attrs:{href:r,target:t.target??"_blank",rel:t.rel??"noopener noreferrer nofollow",class:t.class??null}}:{type:"anonymizedLink",attrs:{href:t.href??r,target:t.target??"_blank",rel:t.rel??"noopener noreferrer nofollow",class:t.class??null,anonymizedData:n,showValue:!1}}}function kp(e,t){const n=e.type;if(n==="Text"){const{type:i,content:o,marks:a,...s}=e;return{...s,type:"text",...Array.isArray(a)?{marks:a.map(Zb)}:{},...Array.isArray(o)?{content:o.map(l=>kp(l,t))}:{}}}if(n==="anonymizedText"){if(e.attrs&&typeof e.attrs=="object"&&e.attrs.placeholder!==void 0)return e;const i=String(e.text??"");return{type:"anonymizedText",attrs:{placeholder:hO(i,t),anonymizedData:JSON.stringify(e.anonymizedData??[]),showValue:e.showValue===!0}}}const r=Array.isArray(e.marks)?{...e,marks:e.marks.map(Zb)}:e;return Array.isArray(r.content)?{...r,content:r.content.map(i=>kp(i,t))}:r}function wp(e,t="numbered"){return kp(e,t)}function Mp(e){const t=e?.collaborativeEditing;return!(!t?.enabled||!t.ydoc||!t.provider||e?.mode===Gi.VIEWING||e?.asViewer)}const bO={file:{name:"Untitled Document",id:null},showPageSizeSelector:!0,content:"",enablePagination:!0,onContentChange:void 0,aiAutocompletion:{enabled:!1,minWordsToTriggerAutoCompletion:Gb,debounceTime:Hb},enableSuggestion:!1,enableVariableText:!1,variableValues:{},variableTableData:{},collaborativeEditing:{enabled:!1,ydoc:void 0,provider:void 0},currentUser:{},allUsers:[],asViewer:!1,editable:!0,debounceTimeForContentChange:_O,shareConfig:{enabled:!1,documentURL:void 0,onExternalUserInvite:void 0},parentContainerId:void 0,onInsertRowFromAgreement:void 0,onInsertColumnFromAgreement:void 0};function EO(e={}){return new Ie({view(t){return new SO(t,e)}})}class SO{constructor(t,n){var r;this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let o=a=>{this[i](a)};return t.dom.addEventListener(i,o),{name:i,handler:o}})}destroy(){this.handlers.forEach(({name:t,handler:n})=>this.editorView.dom.removeEventListener(t,n))}update(t,n){this.cursorPos!=null&&n.doc!=t.state.doc&&(this.cursorPos>t.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,t==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent,r,i=this.editorView.dom,o=i.getBoundingClientRect(),a=o.width/i.offsetWidth,s=o.height/i.offsetHeight;if(n){let u=t.nodeBefore,p=t.nodeAfter;if(u||p){let m=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(m){let _=m.getBoundingClientRect(),h=u?_.bottom:_.top;u&&p&&(h=(h+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*s;r={left:_.left,right:_.right,top:h-g,bottom:h+g}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*a;r={left:u.left-p,right:u.left+p,top:u.top,bottom:u.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,d;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=l.getBoundingClientRect(),p=u.width/l.offsetWidth,m=u.height/l.offsetHeight;c=u.left-l.scrollLeft*p,d=u.top-l.scrollTop*m}this.element.style.left=(r.left-c)/a+"px",this.element.style.top=(r.top-d)/s+"px",this.element.style.width=(r.right-r.left)/a+"px",this.element.style.height=(r.bottom-r.top)/s+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),t)}dragover(t){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,o=typeof i=="function"?i(this.editorView,n,t):i;if(n&&!o){let a=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let s=eh(this.editorView.state.doc,a,this.editorView.dragging.slice);s!=null&&(a=s)}this.setCursor(a),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}}class xt extends xe{constructor(t){super(t,t)}map(t,n){let r=t.resolve(n.map(this.head));return xt.valid(r)?new xt(r):xe.near(r)}content(){return ne.empty}eq(t){return t instanceof xt&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new xt(t.resolve(n.pos))}getBookmark(){return new Dp(this.anchor)}static valid(t){let n=t.parent;if(n.isTextblock||!TO(t)||!yO(t))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(t.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(t,n,r=!1){e:for(;;){if(!r&&xt.valid(t))return t;let i=t.pos,o=null;for(let a=t.depth;;a--){let s=t.node(a);if(n>0?t.indexAfter(a)<s.childCount:t.index(a)>0){o=s.child(n>0?t.indexAfter(a):t.index(a)-1);break}else if(a==0)return null;i+=n;let l=t.doc.resolve(i);if(xt.valid(l))return l}for(;;){let a=n>0?o.firstChild:o.lastChild;if(!a){if(o.isAtom&&!o.isText&&!ge.isSelectable(o)){t=t.doc.resolve(i+o.nodeSize*n),r=!1;continue e}break}o=a,i+=n;let s=t.doc.resolve(i);if(xt.valid(s))return s}return null}}}xt.prototype.visible=!1,xt.findFrom=xt.findGapCursorFrom,xe.jsonID("gapcursor",xt);class Dp{constructor(t){this.pos=t}map(t){return new Dp(t.map(this.pos))}resolve(t){let n=t.resolve(this.pos);return xt.valid(n)?new xt(n):xe.near(n)}}function TO(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function yO(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function CO(){return new Ie({props:{decorations:RO,createSelectionBetween(e,t,n){return t.pos==n.pos&&xt.valid(n)?new xt(n):null},handleClick:xO,handleKeyDown:vO,handleDOMEvents:{beforeinput:NO}}})}const vO=Zu({ArrowLeft:Bl("horiz",-1),ArrowRight:Bl("horiz",1),ArrowUp:Bl("vert",-1),ArrowDown:Bl("vert",1)});function Bl(e,t){const n=e=="vert"?t>0?"down":"up":t>0?"right":"left";return function(r,i,o){let a=r.selection,s=t>0?a.$to:a.$from,l=a.empty;if(a instanceof ue){if(!o.endOfTextblock(n)||s.depth==0)return!1;l=!1,s=r.doc.resolve(t>0?s.after():s.before())}let c=xt.findGapCursorFrom(s,t,l);return c?(i&&i(r.tr.setSelection(new xt(c))),!0):!1}}function xO(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!xt.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&ge.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new xt(r))),!0)}function NO(e,t){if(t.inputType!="insertCompositionText"||!(e.state.selection instanceof xt))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=j.empty;for(let a=r.length-1;a>=0;a--)i=j.from(r[a].createAndFill(null,i));let o=e.state.tr.replace(n.pos,n.pos,new ne(i,0,0));return o.setSelection(ue.near(o.doc.resolve(n.pos+1))),e.dispatch(o),!1}function RO(e){if(!(e.selection instanceof xt))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",Me.create(e.doc,[gt.widget(e.selection.head,t,{key:"gapcursor"})])}var Fl=200,Yt=function(){};Yt.prototype.append=function(t){return t.length?(t=Yt.from(t),!this.length&&t||t.length<Fl&&this.leafAppend(t)||this.length<Fl&&t.leafPrepend(this)||this.appendInner(t)):this},Yt.prototype.prepend=function(t){return t.length?Yt.from(t).append(this):this},Yt.prototype.appendInner=function(t){return new AO(this,t)},Yt.prototype.slice=function(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.length),t>=n?Yt.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,n))},Yt.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)},Yt.prototype.forEach=function(t,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(t,n,r,0):this.forEachInvertedInner(t,n,r,0)},Yt.prototype.map=function(t,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(o,a){return i.push(t(o,a))},n,r),i},Yt.from=function(t){return t instanceof Yt?t:t&&t.length?new Jb(t):Yt.empty};var Jb=(function(e){function t(r){e.call(this),this.values=r}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new t(this.values.slice(i,o))},t.prototype.getInner=function(i){return this.values[i]},t.prototype.forEachInner=function(i,o,a,s){for(var l=o;l<a;l++)if(i(this.values[l],s+l)===!1)return!1},t.prototype.forEachInvertedInner=function(i,o,a,s){for(var l=o-1;l>=a;l--)if(i(this.values[l],s+l)===!1)return!1},t.prototype.leafAppend=function(i){if(this.length+i.length<=Fl)return new t(this.values.concat(i.flatten()))},t.prototype.leafPrepend=function(i){if(this.length+i.length<=Fl)return new t(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t})(Yt);Yt.empty=new Jb([]);var AO=(function(e){function t(n,r){e.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},t.prototype.forEachInner=function(r,i,o,a){var s=this.left.length;if(i<s&&this.left.forEachInner(r,i,Math.min(o,s),a)===!1||o>s&&this.right.forEachInner(r,Math.max(i-s,0),Math.min(this.length,o)-s,a+s)===!1)return!1},t.prototype.forEachInvertedInner=function(r,i,o,a){var s=this.left.length;if(i>s&&this.right.forEachInvertedInner(r,i-s,Math.max(o,s)-s,a+s)===!1||o<s&&this.left.forEachInvertedInner(r,Math.min(i,s),o,a)===!1)return!1},t.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var o=this.left.length;return i<=o?this.left.slice(r,i):r>=o?this.right.slice(r-o,i-o):this.left.slice(r,o).append(this.right.slice(0,i-o))},t.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new t(this.left,i)},t.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new t(i,this.right)},t.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new t(this.left,new t(this.right,r)):new t(this,r)},t})(Yt);const OO=500;class Zn{constructor(t,n){this.items=t,this.eventCount=n}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,o;n&&(i=this.remapping(r,this.items.length),o=i.maps.length);let a=t.tr,s,l,c=[],d=[];return this.items.forEach((u,p)=>{if(!u.step){i||(i=this.remapping(r,p+1),o=i.maps.length),o--,d.push(u);return}if(i){d.push(new cr(u.map));let m=u.step.map(i.slice(o)),_;m&&a.maybeStep(m).doc&&(_=a.mapping.maps[a.mapping.maps.length-1],c.push(new cr(_,void 0,void 0,c.length+d.length))),o--,_&&i.appendMap(_,o)}else a.maybeStep(u.step);if(u.selection)return s=i?u.selection.map(i.slice(o)):u.selection,l=new Zn(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:a,selection:s}}addTransform(t,n,r,i){let o=[],a=this.eventCount,s=this.items,l=!i&&s.length?s.get(s.length-1):null;for(let d=0;d<t.steps.length;d++){let u=t.steps[d].invert(t.docs[d]),p=new cr(t.mapping.maps[d],u,n),m;(m=l&&l.merge(p))&&(p=m,d?o.pop():s=s.slice(0,s.length-1)),o.push(p),n&&(a++,n=void 0),i||(l=p)}let c=a-r.depth;return c>kO&&(s=IO(s,c),a-=c),new Zn(s.append(o),a)}remapping(t,n){let r=new va;return this.items.forEach((i,o)=>{let a=i.mirrorOffset!=null&&o-i.mirrorOffset>=t?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,a)},t,n),r}addMaps(t){return this.eventCount==0?this:new Zn(this.items.append(t.map(n=>new cr(n))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),o=t.mapping,a=t.steps.length,s=this.eventCount;this.items.forEach(p=>{p.selection&&s--},i);let l=n;this.items.forEach(p=>{let m=o.getMirror(--l);if(m==null)return;a=Math.min(a,m);let _=o.maps[m];if(p.step){let h=t.steps[m].invert(t.docs[m]),g=p.selection&&p.selection.map(o.slice(l+1,m));g&&s++,r.push(new cr(_,h,g))}else r.push(new cr(_))},i);let c=[];for(let p=n;p<a;p++)c.push(new cr(o.maps[p]));let d=this.items.slice(0,i).append(c).append(r),u=new Zn(d,s);return u.emptyItemCount()>OO&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let t=0;return this.items.forEach(n=>{n.step||t++}),t}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],o=0;return this.items.forEach((a,s)=>{if(s>=t)i.push(a),a.selection&&o++;else if(a.step){let l=a.step.map(n.slice(r)),c=l&&l.getMap();if(r--,c&&n.appendMap(c,r),l){let d=a.selection&&a.selection.map(n.slice(r));d&&o++;let u=new cr(c.invert(),l,d),p,m=i.length-1;(p=i.length&&i[m].merge(u))?i[m]=p:i.push(u)}}else a.map&&r--},this.items.length,0),new Zn(Yt.from(i.reverse()),o)}}Zn.empty=new Zn(Yt.empty,0);function IO(e,t){let n;return e.forEach((r,i)=>{if(r.selection&&t--==0)return n=i,!1}),e.slice(n)}class cr{constructor(t,n,r,i){this.map=t,this.step=n,this.selection=r,this.mirrorOffset=i}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new cr(n.getMap().invert(),n,this.selection)}}}class pi{constructor(t,n,r,i,o){this.done=t,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}}const kO=20;function wO(e,t,n,r){let i=n.getMeta(ji),o;if(i)return i.historyState;n.getMeta(LO)&&(e=new pi(e.done,e.undone,null,0,-1));let a=n.getMeta("appendedTransaction");if(n.steps.length==0)return e;if(a&&a.getMeta(ji))return a.getMeta(ji).redo?new pi(e.done.addTransform(n,void 0,r,Ul(t)),e.undone,eE(n.mapping.maps),e.prevTime,e.prevComposition):new pi(e.done,e.undone.addTransform(n,void 0,r,Ul(t)),null,e.prevTime,e.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(a&&a.getMeta("addToHistory")===!1)){let s=n.getMeta("composition"),l=e.prevTime==0||!a&&e.prevComposition!=s&&(e.prevTime<(n.time||0)-r.newGroupDelay||!MO(n,e.prevRanges)),c=a?Lp(e.prevRanges,n.mapping):eE(n.mapping.maps);return new pi(e.done.addTransform(n,l?t.selection.getBookmark():void 0,r,Ul(t)),Zn.empty,c,n.time,s??e.prevComposition)}else return(o=n.getMeta("rebased"))?new pi(e.done.rebased(n,o),e.undone.rebased(n,o),Lp(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new pi(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Lp(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function MO(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((r,i)=>{for(let o=0;o<t.length;o+=2)r<=t[o+1]&&i>=t[o]&&(n=!0)}),n}function eE(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((r,i,o,a)=>t.push(o,a));return t}function Lp(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),o=t.map(e[r+1],-1);i<=o&&n.push(i,o)}return n}function DO(e,t,n){let r=Ul(t),i=ji.get(t).spec.config,o=(n?e.undone:e.done).popEvent(t,r);if(!o)return null;let a=o.selection.resolve(o.transform.doc),s=(n?e.done:e.undone).addTransform(o.transform,t.selection.getBookmark(),i,r),l=new pi(n?s:o.remaining,n?o.remaining:s,null,0,-1);return o.transform.setSelection(a).setMeta(ji,{redo:n,historyState:l})}let Pp=!1,tE=null;function Ul(e){let t=e.plugins;if(tE!=t){Pp=!1,tE=t;for(let n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){Pp=!0;break}}return Pp}const ji=new Fe("history"),LO=new Fe("closeHistory");function PO(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new Ie({key:ji,state:{init(){return new pi(Zn.empty,Zn.empty,null,0,-1)},apply(t,n,r){return wO(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(t,n){let r=n.inputType,i=r=="historyUndo"?rE:r=="historyRedo"?iE:null;return i?(n.preventDefault(),i(t.state,t.dispatch)):!1}}}})}function nE(e,t){return(n,r)=>{let i=ji.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let o=DO(i,n,e);o&&r(t?o.scrollIntoView():o)}return!0}}const rE=nE(!1,!0),iE=nE(!0,!0);var BO=Re.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:e=>e.length,wordCounter:e=>e.split(" ").filter(t=>t!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{const t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)==="textSize"){const r=t.textBetween(0,t.content.size,void 0," ");return this.options.textCounter(r)}return t.nodeSize},this.storage.words=e=>{const t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new Ie({key:new Fe("characterCount"),appendTransaction:(t,n,r)=>{if(e)return;const i=this.options.limit;if(i==null||i===0){e=!0;return}const o=this.storage.characters({node:r.doc});if(o>i){const a=o-i,s=0,l=a;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(s,l);return e=!0,c}e=!0},filterTransaction:(t,n)=>{const r=this.options.limit;if(!t.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),o=this.storage.characters({node:t.doc});if(o<=r||i>r&&o>r&&o<=i)return!0;if(i>r&&o>r&&o>i||!t.getMeta("paste"))return!1;const s=t.selection.$head.pos,l=o-r,c=s-l,d=s;return t.deleteRange(c,d),!(this.storage.characters({node:t.doc})>r)}})]}});Re.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[EO(this.options)]}}),Re.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Ie({key:new Fe("focus"),props:{decorations:({doc:e,selection:t})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,o=[];if(!n||!r)return Me.create(e,[]);let a=0;this.options.mode==="deepest"&&e.descendants((l,c)=>{if(l.isText)return;if(!(i>=c&&i<=c+l.nodeSize-1))return!1;a+=1});let s=0;return e.descendants((l,c)=>{if(l.isText||!(i>=c&&i<=c+l.nodeSize-1))return!1;if(s+=1,this.options.mode==="deepest"&&a-s>0||this.options.mode==="shallowest"&&s>1)return this.options.mode==="deepest";o.push(gt.node(c,c+l.nodeSize,{class:this.options.className}))}),Me.create(e,o)}}})]}}),Re.create({name:"gapCursor",addProseMirrorPlugins(){return[CO()]},extendNodeSchema(e){var t;const n={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:(t=Qe(Ee(e,"allowGapCursor",n)))!=null?t:null}}});var FO=Re.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Ie({key:new Fe("placeholder"),props:{decorations:({doc:e,selection:t})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=t,i=[];if(!n)return null;const o=this.editor.isEmpty;return e.descendants((a,s)=>{const l=r>=s&&r<=s+a.nodeSize,c=!a.isLeaf&&vl(a);if((l||!this.options.showOnlyCurrent)&&c){const d=[this.options.emptyNodeClass];o&&d.push(this.options.emptyEditorClass);const u=gt.node(s,s+a.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:a,pos:s,hasAnchor:l}):this.options.placeholder});i.push(u)}return this.options.includeChildren}),Me.create(e,i)}}})]}});Re.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:e,options:t}=this;return[new Ie({key:new Fe("selection"),props:{decorations(n){return n.selection.empty||e.isFocused||!e.isEditable||db(n.selection)||e.view.dragging?null:Me.create(n.doc,[gt.inline(n.selection.from,n.selection.to,{class:t.className})])}}})]}});function oE({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var UO=Re.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:[]}},addProseMirrorPlugins(){const e=new Fe(this.name),t=Object.entries(this.editor.schema.nodes).map(([,n])=>n).filter(n=>(this.options.notAfter||[]).concat(this.options.node).includes(n.name));return[new Ie({key:e,appendTransaction:(n,r,i)=>{const{doc:o,tr:a,schema:s}=i,l=e.getState(i),c=o.content.size,d=s.nodes[this.options.node];if(l)return a.insert(c,d.create())},state:{init:(n,r)=>{const i=r.tr.doc.lastChild;return!oE({node:i,types:t})},apply:(n,r)=>{if(!n.docChanged)return r;const i=n.doc.lastChild;return!oE({node:i,types:t})}}})]}}),zO=Re.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>rE(e,t),redo:()=>({state:e,dispatch:t})=>iE(e,t)}},addProseMirrorPlugins(){return[PO(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),HO=BO;const $a=Math.floor,GO=Math.abs,mi=(e,t)=>e<t?e:t,Do=(e,t)=>e>t?e:t,VO=e=>e!==0?e<0:1/e<0,YO=64,Wa=128,$O=1<<29,aE=63,ja=127,WO=2147483647,jO=Number.isInteger||(e=>typeof e=="number"&&isFinite(e)&&$a(e)===e),qO=()=>new Set,KO=Array.isArray,QO=String.fromCharCode,XO=e=>e.toLowerCase(),ZO=/^\s*/g,JO=e=>e.replace(ZO,""),eI=/([A-Z])/g,sE=(e,t)=>JO(e.replace(eI,n=>`${t}${XO(n)}`)),tI=e=>{const t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=t.codePointAt(i);return r},qa=typeof TextEncoder<"u"?new TextEncoder:null,nI=qa?e=>qa.encode(e):tI;let Bp=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Bp&&Bp.decode(new Uint8Array).length===1&&(Bp=null);class rI{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const iI=()=>new rI,oI=e=>{const t=iI();return e(t),sI(t)},aI=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},sI=e=>{const t=new Uint8Array(aI(e));let n=0;for(let r=0;r<e.bufs.length;r++){const i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},lI=(e,t)=>{const n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(Do(n,t)*2),e.cpos=0)},en=(e,t)=>{const n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},Ka=(e,t)=>{for(;t>ja;)en(e,Wa|ja&t),t=$a(t/128);en(e,ja&t)},cI=(e,t)=>{const n=VO(t);for(n&&(t=-t),en(e,(t>aE?Wa:0)|(n?YO:0)|aE&t),t=$a(t/64);t>0;)en(e,(t>ja?Wa:0)|ja&t),t=$a(t/128)},Fp=new Uint8Array(3e4),dI=Fp.length/3,uI=(e,t)=>{if(t.length<dI){const n=qa.encodeInto(t,Fp).written||0;Ka(e,n);for(let r=0;r<n;r++)en(e,Fp[r])}else cE(e,nI(t))},pI=(e,t)=>{const n=unescape(encodeURIComponent(t)),r=n.length;Ka(e,r);for(let i=0;i<r;i++)en(e,n.codePointAt(i))},lE=qa&&qa.encodeInto?uI:pI,mI=(e,t)=>{const n=e.cbuf.length,r=e.cpos,i=mi(n-r,t.length),o=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,o>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(Do(n*2,o)),e.cbuf.set(t.subarray(i)),e.cpos=o)},cE=(e,t)=>{Ka(e,t.byteLength),mI(e,t)},Up=(e,t)=>{lI(e,t);const n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},fI=(e,t)=>Up(e,4).setFloat32(0,t,!1),_I=(e,t)=>Up(e,8).setFloat64(0,t,!1),hI=(e,t)=>Up(e,8).setBigInt64(0,t,!1),dE=new DataView(new ArrayBuffer(4)),gI=e=>(dE.setFloat32(0,e),dE.getFloat32(0)===e),zp=(e,t)=>{switch(typeof t){case"string":en(e,119),lE(e,t);break;case"number":jO(t)&&GO(t)<=WO?(en(e,125),cI(e,t)):gI(t)?(en(e,124),fI(e,t)):(en(e,123),_I(e,t));break;case"bigint":en(e,122),hI(e,t);break;case"object":if(t===null)en(e,126);else if(KO(t)){en(e,117),Ka(e,t.length);for(let n=0;n<t.length;n++)zp(e,t[n])}else if(t instanceof Uint8Array)en(e,116),cE(e,t);else{en(e,118);const n=Object.keys(t);Ka(e,n.length);for(let r=0;r<n.length;r++){const i=n[r];lE(e,i),zp(e,t[i])}}break;case"boolean":en(e,t?120:121);break;default:en(e,127)}},uE=e=>new Error(e),bI=()=>{throw uE("Method unimplemented")},pE=()=>{throw uE("Unexpected case")},zl=()=>new Map,mE=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},EI=Object.keys,SI=(e,t)=>{for(const n in e)if(!t(e[n],n))return!1;return!0},TI=(e,t)=>t.includes(e),yI=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}},CI=/[\uD800-\uDBFF]/,vI=/[\uDC00-\uDFFF]/,xI=(e,t)=>{let n=0,r=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;for(n>0&&CI.test(e[n-1])&&n--;r+n<e.length&&r+n<t.length&&e[e.length-r-1]===t[t.length-r-1];)r++;return r>0&&vI.test(e[e.length-r])&&r--,{index:n,remove:e.length-n-r,insert:t.slice(n,t.length-r)}},NI=Math.random,RI=e=>e[$a(NI()*e.length)],fE=e=>e===void 0?null:e;class AI{constructor(){this.map=new Map}setItem(t,n){this.map.set(t,n)}getItem(t){return this.map.get(t)}}let _E=new AI,OI=!0;try{typeof localStorage<"u"&&localStorage&&(_E=localStorage,OI=!1)}catch{}const II=_E,Lo=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",hE=typeof window<"u"&&typeof document<"u"&&!Lo;let dr;const kI=()=>{if(dr===void 0)if(Lo){dr=zl();const e=process.argv;let t=null;for(let n=0;n<e.length;n++){const r=e[n];r[0]==="-"?(t!==null&&dr.set(t,""),t=r):t!==null&&(dr.set(t,r),t=null)}t!==null&&dr.set(t,"")}else typeof location=="object"?(dr=zl(),(location.search||"?").slice(1).split("&").forEach(e=>{if(e.length!==0){const[t,n]=e.split("=");dr.set(`--${sE(t,"-")}`,n),dr.set(`-${sE(t,"-")}`,n)}})):dr=zl();return dr},Hp=e=>kI().has(e),Gp=e=>fE(Lo?process.env[e.toUpperCase().replaceAll("-","_")]:II.getItem(e)),gE=e=>Hp("--"+e)||Gp(e)!==null;gE("production"),Lo&&TI(process.env.FORCE_COLOR,["true","1","2"])||!Hp("--no-colors")&&!gE("no-color")&&(!Lo||process.stdout.isTTY)&&(!Lo||Hp("--color")||Gp("COLORTERM")!==null||(Gp("TERM")||"").includes("color"));const wI=typeof document<"u"?document:{};typeof DOMParser<"u"&&new DOMParser;const MI=(e=>class{constructor(n){this._=n}destroy(){e(this._)}})(clearTimeout),Hl=(e,t)=>new MI(setTimeout(t,e)),ur=(e,t)=>e>>>t|e<<32-t,DI=e=>ur(e,2)^ur(e,13)^ur(e,22),LI=e=>ur(e,6)^ur(e,11)^ur(e,25),PI=e=>ur(e,7)^ur(e,18)^e>>>3,BI=e=>ur(e,17)^ur(e,19)^e>>>10,FI=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),UI=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class zI{constructor(){const t=new ArrayBuffer(320);this._H=new Uint32Array(t,0,8),this._H.set(UI),this._W=new Uint32Array(t,64,64)}_updateHash(){const t=this._H,n=this._W;for(let u=16;u<64;u++)n[u]=BI(n[u-2])+n[u-7]+PI(n[u-15])+n[u-16];let r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],c=t[6],d=t[7];for(let u=0,p,m;u<64;u++)p=d+LI(s)+(s&l^~s&c)+FI[u]+n[u]>>>0,m=DI(r)+(r&i^r&o^i&o)>>>0,d=c,c=l,l=s,s=a+p>>>0,a=o,o=i,i=r,r=p+m>>>0;t[0]+=r,t[1]+=i,t[2]+=o,t[3]+=a,t[4]+=s,t[5]+=l,t[6]+=c,t[7]+=d}digest(t){let n=0;for(;n+56<=t.length;){let a=0;for(;a<16&&n+3<t.length;a++)this._W[a]=t[n++]<<24|t[n++]<<16|t[n++]<<8|t[n++];if(n%64!==0){for(this._W.fill(0,a,16);n<t.length;)this._W[a]|=t[n]<<(3-n%4)*8,n++;this._W[a]|=Wa<<(3-n%4)*8}this._updateHash()}const r=n%64!==0;this._W.fill(0,0,16);let i=0;for(;n<t.length;i++)for(let a=3;a>=0&&n<t.length;a--)this._W[i]|=t[n++]<<a*8;r||(this._W[i-(n%4===0?0:1)]|=Wa<<(3-n%4)*8),this._W[14]=t.byteLength/$O,this._W[15]=t.byteLength*8,this._updateHash();const o=new Uint8Array(32);for(let a=0;a<this._H.length;a++)for(let s=0;s<4;s++)o[a*4+s]=this._H[a]>>>(3-s)*8;return o}}const HI=e=>new zI().digest(e),GI=hE?e=>{let t="";for(let n=0;n<e.byteLength;n++)t+=QO(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("base64"),VI=e=>oI(t=>zp(t,e)),dt=new Fe("y-sync"),Br=new Fe("y-undo"),Gl=new Fe("yjs-cursor"),YI=e=>{for(let n=6;n<e.length;n++)e[n%6]=e[n%6]^e[n];return e.slice(0,6)},$I=e=>GI(YI(HI(VI(e)))),Vl=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&t.sv.get(e.id.client)>e.id.clock&&!Se.isDeleted(t.ds,e.id),WI=[{light:"#ecd44433",dark:"#ecd444"}],jI=(e,t,n)=>{if(!e.has(n)){if(e.size<t.length){const r=qO();e.forEach(i=>r.add(i)),t=t.filter(i=>!r.has(i))}e.set(n,RI(t))}return e.get(n)},qI=(e,{colors:t=WI,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:o}={})=>{let a=!1;const s=new XI(e,o),l=new Ie({props:{editable:c=>{const d=dt.getState(c);return d.snapshot==null&&d.prevSnapshot==null}},key:dt,state:{init:(c,d)=>({type:e,doc:e.doc,binding:s,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:t,colorMapping:n,permanentUserData:r}),apply:(c,d)=>{const u=c.getMeta(dt);if(u!==void 0){d=Object.assign({},d);for(const p in u)d[p]=u[p]}return d.addToHistory=c.getMeta("addToHistory")!==!1,d.isChangeOrigin=u!==void 0&&!!u.isChangeOrigin,d.isUndoRedoOperation=u!==void 0&&!!u.isChangeOrigin&&!!u.isUndoRedoOperation,s.prosemirrorView!==null&&u!==void 0&&(u.snapshot!=null||u.prevSnapshot!=null)&&Hl(0,()=>{s.prosemirrorView!=null&&(u.restore==null?s._renderSnapshot(u.snapshot,u.prevSnapshot,d):(s._renderSnapshot(u.snapshot,u.snapshot,d),delete d.restore,delete d.snapshot,delete d.prevSnapshot,s.mux(()=>{s._prosemirrorChanged(s.prosemirrorView.state.doc)})))}),d}},view:c=>(s.initView(c),o==null&&s._forceRerender(),i(),{update:()=>{const d=l.getState(c.state);if(d.snapshot==null&&d.prevSnapshot==null&&(a||c.state.doc.content.findDiffStart(c.state.doc.type.createAndFill().content)!==null)){if(a=!0,d.addToHistory===!1&&!d.isChangeOrigin){const u=Br.getState(c.state),p=u&&u.undoManager;p&&p.stopCapturing()}s.mux(()=>{d.doc.transact(u=>{u.meta.set("addToHistory",d.addToHistory),s._prosemirrorChanged(c.state.doc)},dt)})}},destroy:()=>{s.destroy()}})});return l},KI=(e,t,n)=>{if(t!==null&&t.anchor!==null&&t.head!==null)if(t.type==="all")e.setSelection(new yn(e.doc));else if(t.type==="node"){const r=qi(n.doc,n.type,t.anchor,n.mapping);e.setSelection(QI(e,r))}else{const r=qi(n.doc,n.type,t.anchor,n.mapping),i=qi(n.doc,n.type,t.head,n.mapping);r!==null&&i!==null&&e.setSelection(ue.between(e.doc.resolve(r),e.doc.resolve(i)))}},QI=(e,t)=>{const n=e.doc.resolve(t);return n.nodeAfter?ge.create(e.doc,t):ue.near(n)},Vp=(e,t)=>({type:t.selection.jsonID,anchor:Za(t.selection.anchor,e.type,e.mapping),head:Za(t.selection.head,e.type,e.mapping)});class XI{constructor(t,n=new Map){this.type=t,this.prosemirrorView=null,this.mux=yI(),this.mapping=n,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=t.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=Vp(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(hE&&this._domSelectionInView===null&&(Hl(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const t=this.prosemirrorView._root.getSelection();if(t==null||t.anchorNode==null)return!1;const n=this.prosemirrorView._root.createRange();n.setStart(t.anchorNode,t.anchorOffset),n.setEnd(t.focusNode,t.focusOffset),n.getClientRects().length===0&&n.startContainer&&n.collapsed&&n.selectNodeContents(n.startContainer);const i=n.getBoundingClientRect(),o=wI.documentElement;return i.bottom>=0&&i.right>=0&&i.left<=(window.innerWidth||o.clientWidth||0)&&i.top<=(window.innerHeight||o.clientHeight||0)}renderSnapshot(t,n){n||(n=Se.createSnapshot(Se.createDeleteSet(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(dt,{snapshot:t,prevSnapshot:n}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const t=this.type.toArray().map(r=>Yl(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ne(j.from(t),0,0));n.setMeta(dt,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(n)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const t=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,n=this.type.toArray().map(i=>Yl(i,this.prosemirrorView.state.schema,this)).filter(i=>i!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ne(j.from(n),0,0));if(t){const i=mi(Do(t.anchor,0),r.doc.content.size),o=mi(Do(t.head,0),r.doc.content.size);r.setSelection(ue.create(r.doc,i,o))}this.prosemirrorView.dispatch(r.setMeta(dt,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(t,n,r){let i=this.doc,o=this.type;if(t||(t=Se.snapshot(this.doc)),t instanceof Uint8Array||n instanceof Uint8Array)if((!(t instanceof Uint8Array)||!(n instanceof Uint8Array))&&pE(),i=new Se.Doc({gc:!1}),Se.applyUpdateV2(i,n),n=Se.snapshot(i),Se.applyUpdateV2(i,t),t=Se.snapshot(i),o._item===null){const a=Array.from(this.doc.share.keys()).find(s=>this.doc.share.get(s)===this.type);o=i.getXmlFragment(a)}else{const a=i.store.clients.get(o._item.id.client)??[],s=Se.findIndexSS(a,o._item.id.clock);o=a[s].content.type}this.mapping.clear(),this.mux(()=>{i.transact(a=>{const s=r.permanentUserData;s&&s.dss.forEach(u=>{Se.iterateDeletedStructs(a,u,p=>{})});const l=(u,p)=>{const m=u==="added"?s.getUserByClientId(p.client):s.getUserByDeletedId(p);return{user:m,type:u,color:jI(r.colorMapping,r.colors,m)}},c=Se.typeListToArraySnapshot(o,new Se.Snapshot(n.ds,t.sv)).map(u=>!u._item.deleted||Vl(u._item,t)||Vl(u._item,n)?Yl(u,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},t,n,l):null).filter(u=>u!==null),d=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ne(j.from(c),0,0));this.prosemirrorView.dispatch(d.setMeta(dt,{isChangeOrigin:!0}))},dt)})}_typeChanged(t,n){if(this.prosemirrorView==null)return;const r=dt.getState(this.prosemirrorView.state);if(t.length===0||r.snapshot!=null||r.prevSnapshot!=null){this.renderSnapshot(r.snapshot,r.prevSnapshot);return}this.mux(()=>{const i=(s,l)=>this.mapping.delete(l);Se.iterateDeletedStructs(n,n.deleteSet,s=>{if(s.constructor===Se.Item){const l=s.content.type;l&&this.mapping.delete(l)}}),n.changed.forEach(i),n.changedParentTypes.forEach(i);const o=this.type.toArray().map(s=>bE(s,this.prosemirrorView.state.schema,this)).filter(s=>s!==null);let a=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ne(j.from(o),0,0));KI(a,this.beforeTransactionSelection,this),a=a.setMeta(dt,{isChangeOrigin:!0,isUndoRedoOperation:n.origin instanceof Se.UndoManager}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&a.scrollIntoView(),this.prosemirrorView.dispatch(a)})}_prosemirrorChanged(t){this.doc.transact(()=>{Wp(this.doc,this.type,t,this),this.beforeTransactionSelection=Vp(this,this.prosemirrorView.state)},dt)}initView(t){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=t,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}}const bE=(e,t,n,r,i,o)=>{const a=n.mapping.get(e);if(a===void 0){if(e instanceof Se.XmlElement)return Yl(e,t,n,r,i,o);throw bI()}return a},Yl=(e,t,n,r,i,o)=>{const a=[],s=l=>{if(l instanceof Se.XmlElement){const c=bE(l,t,n,r,i,o);c!==null&&a.push(c)}else{const c=l._item.right?.content?.type;c instanceof Se.Text&&!c._item.deleted&&c._item.id.client===c.doc.clientID&&(l.applyDelta([{retain:l.length},...c.toDelta()]),c.doc.transact(u=>{c._item.delete(u)}));const d=ZI(l,t,n,r,i,o);d!==null&&d.forEach(u=>{u!==null&&a.push(u)})}};r===void 0||i===void 0?e.toArray().forEach(s):Se.typeListToArraySnapshot(e,new Se.Snapshot(i.ds,r.sv)).forEach(s);try{const l=e.getAttributes(r);r!==void 0&&(Vl(e._item,r)?Vl(e._item,i)||(l.ychange=o?o("added",e._item.id):{type:"added"}):l.ychange=o?o("removed",e._item.id):{type:"removed"});const c=t.node(e.nodeName,l,a);return n.mapping.set(e,c),c}catch{return e.doc.transact(c=>{e._item.delete(c)},dt),n.mapping.delete(e),null}},ZI=(e,t,n,r,i,o)=>{const a=[],s=e.toDelta(r,i,o);try{for(let l=0;l<s.length;l++){const c=s[l];a.push(t.text(c.insert,ik(c.attributes,t)))}}catch{return e.doc.transact(c=>{e._item.delete(c)},dt),null}return a},JI=(e,t)=>{const n=new Se.XmlText,r=e.map(i=>({insert:i.text,attributes:CE(i.marks,t)}));return n.applyDelta(r),t.mapping.set(n,e),n},ek=(e,t)=>{const n=new Se.XmlElement(e.type.name);for(const r in e.attrs){const i=e.attrs[r];i!==null&&r!=="ychange"&&n.setAttribute(r,i)}return n.insert(0,$l(e).map(r=>Yp(r,t))),t.mapping.set(n,e),n},Yp=(e,t)=>e instanceof Array?JI(e,t):ek(e,t),EE=e=>typeof e=="object"&&e!==null,$p=(e,t)=>{const n=Object.keys(e).filter(i=>e[i]!==null);let r=n.length===Object.keys(t).filter(i=>t[i]!==null).length;for(let i=0;i<n.length&&r;i++){const o=n[i],a=e[o],s=t[o];r=o==="ychange"||a===s||EE(a)&&EE(s)&&$p(a,s)}return r},$l=e=>{const t=e.content.content,n=[];for(let r=0;r<t.length;r++){const i=t[r];if(i.isText){const o=[];for(let a=t[r];r<t.length&&a.isText;a=t[++r])o.push(a);r--,n.push(o)}else n.push(i)}return n},SE=(e,t)=>{const n=e.toDelta();return n.length===t.length&&n.every((r,i)=>r.insert===t[i].text&&EI(r.attributes||{}).length===t[i].marks.length&&SI(r.attributes,(o,a)=>{const s=yE(a),l=t[i].marks;return l.find(d=>d.type.name===s)?$p(o,l.find(d=>d.type.name===s)?.attrs):!1}))},Qa=(e,t)=>{if(e instanceof Se.XmlElement&&!(t instanceof Array)&&jp(e,t)){const n=$l(t);return e._length===n.length&&$p(e.getAttributes(),t.attrs)&&e.toArray().every((r,i)=>Qa(r,n[i]))}return e instanceof Se.XmlText&&t instanceof Array&&SE(e,t)},Wl=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((n,r)=>t[r]===n),TE=(e,t,n)=>{const r=e.toArray(),i=$l(t),o=i.length,a=r.length,s=mi(a,o);let l=0,c=0,d=!1;for(;l<s;l++){const u=r[l],p=i[l];if(Wl(n.mapping.get(u),p))d=!0;else if(!Qa(u,p))break}for(;l+c<s;c++){const u=r[a-c-1],p=i[o-c-1];if(Wl(n.mapping.get(u),p))d=!0;else if(!Qa(u,p))break}return{equalityFactor:l+c,foundMappedChild:d}},tk=e=>{let t="",n=e._start;const r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof Se.ContentString?t+=n.content.str:n.content instanceof Se.ContentFormat&&(r[n.content.key]=null)),n=n.right;return{str:t,nAttrs:r}},nk=(e,t,n)=>{n.mapping.set(e,t);const{nAttrs:r,str:i}=tk(e),o=t.map(c=>({insert:c.text,attributes:Object.assign({},r,CE(c.marks,n))})),{insert:a,remove:s,index:l}=xI(i,o.map(c=>c.insert).join(""));e.delete(l,s),e.insert(l,a),e.applyDelta(o.map(c=>({retain:c.insert.length,attributes:c.attributes})))},rk=/(.*)(--[a-zA-Z0-9+/=]{8})$/,yE=e=>rk.exec(e)?.[1]??e,ik=(e,t)=>{const n=[];for(const r in e)n.push(t.mark(yE(r),e[r]));return n},CE=(e,t)=>{const n={};return e.forEach(r=>{if(r.type.name!=="ychange"){const i=mE(t.isOMark,r.type,()=>!r.type.excludes(r.type));n[i?`${r.type.name}--${$I(r.toJSON())}`:r.type.name]=r.attrs}}),n},Wp=(e,t,n,r)=>{if(t instanceof Se.XmlElement&&t.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.mapping.set(t,n),t instanceof Se.XmlElement){const u=t.getAttributes(),p=n.attrs;for(const m in p)p[m]!==null?u[m]!==p[m]&&m!=="ychange"&&t.setAttribute(m,p[m]):t.removeAttribute(m);for(const m in u)p[m]===void 0&&t.removeAttribute(m)}const i=$l(n),o=i.length,a=t.toArray(),s=a.length,l=mi(o,s);let c=0,d=0;for(;c<l;c++){const u=a[c],p=i[c];if(!Wl(r.mapping.get(u),p))if(Qa(u,p))r.mapping.set(u,p);else break}for(;d+c+1<l;d++){const u=a[s-d-1],p=i[o-d-1];if(!Wl(r.mapping.get(u),p))if(Qa(u,p))r.mapping.set(u,p);else break}e.transact(()=>{for(;s-c-d>0&&o-c-d>0;){const p=a[c],m=i[c],_=a[s-d-1],h=i[o-d-1];if(p instanceof Se.XmlText&&m instanceof Array)SE(p,m)||nk(p,m,r),c+=1;else{let g=p instanceof Se.XmlElement&&jp(p,m),b=_ instanceof Se.XmlElement&&jp(_,h);if(g&&b){const E=TE(p,m,r),S=TE(_,h,r);E.foundMappedChild&&!S.foundMappedChild?b=!1:!E.foundMappedChild&&S.foundMappedChild||E.equalityFactor<S.equalityFactor?g=!1:b=!1}g?(Wp(e,p,m,r),c+=1):b?(Wp(e,_,h,r),d+=1):(r.mapping.delete(t.get(c)),t.delete(c,1),t.insert(c,[Yp(m,r)]),c+=1)}}const u=s-c-d;if(s===1&&o===0&&a[0]instanceof Se.XmlText?(r.mapping.delete(a[0]),a[0].delete(0,a[0].length)):u>0&&(t.slice(c,c+u).forEach(p=>r.mapping.delete(p)),t.delete(c,u)),c+d<o){const p=[];for(let m=c;m<o-d;m++)p.push(Yp(i[m],r));t.insert(c,p)}},dt)},jp=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name;let Xa=null;class ok{constructor(t,n,r){this.view=t,this.key=n,this.value=r}apply(){const t=dt.getState(this.view.state);if(t&&t.binding&&!t.binding.isDestroyed){const n=this.view.state.tr;n.setMeta(this.key,this.value),this.view.dispatch(n)}}}class qp{constructor(t=[]){this.entries=t}getFirst(){return this.entries[0]}dequeueFirst(){return this.entries.shift()}isEmpty(){return this.entries.length===0}static fromViewsToUpdate(){const t=Xa;Xa=null;const n=[];return t.forEach((r,i)=>{r.forEach((o,a)=>{n.push(new ok(i,a,o))})}),new qp(n)}}const vE=(e=qp.fromViewsToUpdate(),t=!1)=>{let n=!0;for(;!e.isEmpty();){const r=e.getFirst();try{r.apply()}catch(i){if(i instanceof RangeError){t&&n&&e.dequeueFirst(),e.isEmpty()||Hl(0,()=>vE(e,!0));return}throw i}n=!1,e.dequeueFirst()}},ak=(e,t,n)=>{Xa||(Xa=new Map,Hl(0,vE)),mE(Xa,e,zl).set(t,n)},Za=(e,t,n)=>{if(e===0)return Se.createRelativePositionFromTypeIndex(t,0,-1);let r=t._first===null?null:t._first.content.type;for(;r!==null&&t!==r;){if(r instanceof Se.XmlText){if(r._length>=e)return Se.createRelativePositionFromTypeIndex(r,e,-1);if(e-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,e--;while(r!==t&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==t&&(r=r._item===null?null:r._item.next.content.type)}}else{const i=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&e<i)r=r._first.content.type,e--;else{if(e===1&&r._length===0&&i>1)return new Se.RelativePosition(r._item===null?null:r._item.id,r._item===null?Se.findRootTypeKey(r):null,null);if(e-=i,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(e===0)return r=r._item===null?r:r._item.parent,new Se.RelativePosition(r._item===null?null:r._item.id,r._item===null?Se.findRootTypeKey(r):null,null);do r=r._item.parent,e--;while(r!==t&&r._item.next===null);r!==t&&(r=r._item.next.content.type)}}}if(r===null)throw pE();if(e===0&&r.constructor!==Se.XmlText&&r!==t)return sk(r._item.parent,r._item)}return Se.createRelativePositionFromTypeIndex(t,t._length,-1)},sk=(e,t)=>{let n=null,r=null;return e._item===null?r=Se.findRootTypeKey(e):n=Se.createID(e._item.id.client,e._item.id.clock),new Se.RelativePosition(n,r,t.id)},qi=(e,t,n,r)=>{const i=Se.createAbsolutePositionFromRelativePosition(n,e);if(i===null||i.type!==t&&!Se.isParentOf(t,i.type._item))return null;let o=i.type,a=0;if(o.constructor===Se.XmlText)a=i.index;else if(o._item===null||!o._item.deleted){let s=o._first,l=0;for(;l<o._length&&l<i.index&&s!==null;){if(!s.deleted){const c=s.content.type;l++,c instanceof Se.XmlText?a+=c._length:a+=r.get(c).nodeSize}s=s.right}a+=1}for(;o!==t&&o._item!==null;){const s=o._item.parent;if(s._item===null||!s._item.deleted){a+=1;let l=s._first;for(;l!==null;){const c=l.content.type;if(c===o)break;l.deleted||(c instanceof Se.XmlText?a+=c._length:a+=r.get(c).nodeSize),l=l.right}}o=s}return a-1},lk=(e,t,n)=>e!==t,ck=e=>{const t=document.createElement("span");t.classList.add("ProseMirror-yjs-cursor"),t.setAttribute("style",`border-color: ${e.color}`);const n=document.createElement("div");n.setAttribute("style",`background-color: ${e.color}`),n.insertBefore(document.createTextNode(e.name),null);const r=document.createTextNode(""),i=document.createTextNode("");return t.insertBefore(r,null),t.insertBefore(n,null),t.insertBefore(i,null),t},xE=e=>({style:`background-color: ${e.color}70`,class:"ProseMirror-yjs-selection"}),dk=/^#[0-9a-fA-F]{6}$/,NE=(e,t,n,r,i)=>{const o=dt.getState(e);if(o==null||o.doc==null||o.binding==null)return Me.create(e.doc,[]);const a=o.doc,s=[];return o.snapshot!=null||o.prevSnapshot!=null||o.binding.mapping.size===0?Me.create(e.doc,[]):(t.getStates().forEach((l,c)=>{if(n(a.clientID,c,l)&&l.cursor!=null){const d=l.user||{};d.color==null?d.color="#ffa500":dk.test(d.color)||console.warn("A user uses an unsupported color format",d),d.name==null&&(d.name=`User: ${c}`);let u=qi(a,o.type,Se.createRelativePositionFromJSON(l.cursor.anchor),o.binding.mapping),p=qi(a,o.type,Se.createRelativePositionFromJSON(l.cursor.head),o.binding.mapping);if(u!==null&&p!==null){const m=Do(e.doc.content.size-1,0);u=mi(u,m),p=mi(p,m),s.push(gt.widget(p,()=>r(d,c),{key:c+"",side:10}));const _=mi(u,p),h=Do(u,p);s.push(gt.inline(_,h,i(d,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),Me.create(e.doc,s))},uk=(e,{awarenessStateFilter:t=lk,cursorBuilder:n=ck,selectionBuilder:r=xE,getSelection:i=a=>a.selection}={},o="cursor")=>new Ie({key:Gl,state:{init(a,s){return NE(s,e,t,n,r)},apply(a,s,l,c){const d=dt.getState(c),u=a.getMeta(Gl);return d&&d.isChangeOrigin||u&&u.awarenessUpdated?NE(c,e,t,n,r):s.map(a.mapping,a.doc)}},props:{decorations:a=>Gl.getState(a)},view:a=>{const s=()=>{a.docView&&ak(a,Gl,{awarenessUpdated:!0})},l=()=>{const c=dt.getState(a.state),d=e.getLocalState()||{};if(a.hasFocus()){const u=i(a.state),p=Za(u.anchor,c.type,c.binding.mapping),m=Za(u.head,c.type,c.binding.mapping);(d.cursor==null||!Se.compareRelativePositions(Se.createRelativePositionFromJSON(d.cursor.anchor),p)||!Se.compareRelativePositions(Se.createRelativePositionFromJSON(d.cursor.head),m))&&e.setLocalStateField(o,{anchor:p,head:m})}else d.cursor!=null&&qi(c.doc,c.type,Se.createRelativePositionFromJSON(d.cursor.anchor),c.binding.mapping)!==null&&e.setLocalStateField(o,null)};return e.on("change",s),a.dom.addEventListener("focusin",l),a.dom.addEventListener("focusout",l),{update:l,destroy:()=>{a.dom.removeEventListener("focusin",l),a.dom.removeEventListener("focusout",l),e.off("change",s),e.setLocalStateField(o,null)}}}}),pk=e=>{const t=Br.getState(e).undoManager;if(t!=null)return t.undo(),!0},mk=e=>{const t=Br.getState(e).undoManager;if(t!=null)return t.redo(),!0},fk=new Set(["paragraph"]),_k=(e,t)=>!(e instanceof mo.Item)||!(e.content instanceof mo.ContentType)||!(e.content.type instanceof mo.Text||e.content.type instanceof mo.XmlElement&&t.has(e.content.type.nodeName))||e.content.type._length===0,hk=({protectedNodes:e=fk,trackedOrigins:t=[],undoManager:n=null}={})=>new Ie({key:Br,state:{init:(r,i)=>{const o=dt.getState(i),a=n||new mo.UndoManager(o.type,{trackedOrigins:new Set([dt].concat(t)),deleteFilter:s=>_k(s,e),captureTransaction:s=>s.meta.get("addToHistory")!==!1});return{undoManager:a,prevSel:null,hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}},apply:(r,i,o,a)=>{const s=dt.getState(a).binding,l=i.undoManager,c=l.undoStack.length>0,d=l.redoStack.length>0;return s?{undoManager:l,prevSel:Vp(s,o),hasUndoOps:c,hasRedoOps:d}:c!==i.hasUndoOps||d!==i.hasRedoOps?Object.assign({},i,{hasUndoOps:l.undoStack.length>0,hasRedoOps:l.redoStack.length>0}):i}},view:r=>{const i=dt.getState(r.state),o=Br.getState(r.state).undoManager;return o.on("stack-item-added",({stackItem:a})=>{const s=i.binding;s&&a.meta.set(s,Br.getState(r.state).prevSel)}),o.on("stack-item-popped",({stackItem:a})=>{const s=i.binding;s&&(s.beforeTransactionSelection=a.meta.get(s)||s.beforeTransactionSelection)}),{destroy:()=>{o.destroy()}}}});function RE(e){return!!e.getMeta(dt)}function gk(e,t){const n=dt.getState(e);return qi(n.doc,n.type,t,n.binding.mapping)||0}function AE(e,t){const n=dt.getState(e);return Za(t,n.type,n.binding.mapping)}var jl=class gC extends pp{constructor(t,n){super(t),this.yRelativePosition=n}static fromJSON(t){return new gC(t.position,t.yRelativePosition)}toJSON(){return{position:this.position,yRelativePosition:this.yRelativePosition}}};function bk(e,t){const n=AE(t,e);return new jl(e,n)}function Ek(e,t,n){const r=e instanceof jl?e.yRelativePosition:null;if(RE(t)&&r){const a=gk(n,r);return{position:new jl(a,r),mapResult:null}}const i=ub(e,t),o=i.position.position;return{position:new jl(o,r??AE(n,o)),mapResult:i.mapResult}}var Sk=Re.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null,provider:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(e=>e.name==="undoRedo")&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".')},onBeforeCreate(){this.editor.utils.getUpdatedPosition=(e,t)=>Ek(e,t,this.editor.state),this.editor.utils.createMappablePosition=e=>bk(e,this.editor.state)},addCommands(){return{undo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta("preventDispatch",!0),Br.getState(t).undoManager.undoStack.length===0?!1:n?pk(t):!0),redo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta("preventDispatch",!0),Br.getState(t).undoManager.redoStack.length===0?!1:n?mk(t):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){const e=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),t=hk(this.options.yUndoOptions),n=t.spec.view;t.spec.view=o=>{const{undoManager:a}=Br.getState(o.state);a.restore&&(a.restore(),a.restore=()=>{});const s=n?n(o):void 0;return{destroy:()=>{const l=a.trackedOrigins.has(a),c=a._observers;a.restore=()=>{l&&a.trackedOrigins.add(a),a.doc.on("afterTransaction",a.afterTransactionHandler),a._observers=c},s?.destroy&&s.destroy()}}};const r={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender};return[qI(e,r),t,this.editor.options.enableContentCheck&&new Ie({key:new Fe("filterInvalidContent"),filterTransaction:o=>{if(!RE(o))return!0;if(this.storage.isDisabled)return!1;if(!o.docChanged)return!0;try{return o.doc.check(),!0}catch(a){return this.storage.isDisabled=!0,this.editor.emit("contentError",{error:a,editor:this.editor,disableCollaboration:()=>{var s;(s=e.doc)==null||s.destroy()}}),!1}}})].filter(Boolean)}}),Tk=Sk,OE=e=>Array.from(e.entries()).map(([t,n])=>({clientId:t,...n.user})),IE=()=>null,yk=Re.create({name:"collaborationCaret",priority:999,addOptions(){return{provider:null,user:{name:null,color:null},render:e=>{const t=document.createElement("span");t.classList.add("collaboration-carets__caret"),t.setAttribute("style",`border-color: ${e.color}`);const n=document.createElement("div");return n.classList.add("collaboration-carets__label"),n.setAttribute("style",`background-color: ${e.color}`),n.insertBefore(document.createTextNode(e.name),null),t.insertBefore(n,null),t},selectionRender:xE,onUpdate:IE}},onCreate(){if(this.options.onUpdate!==IE&&console.warn('[tiptap warn]: DEPRECATED: The "onUpdate" option is deprecated. Please use `editor.storage.collaborationCaret.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret'),!this.options.provider)throw new Error('The "provider" option is required for the CollaborationCaret extension')},addStorage(){return{users:[]}},addCommands(){return{updateUser:e=>()=>(this.options.user=e,this.options.provider.awareness.setLocalStateField("user",this.options.user),!0),user:e=>({editor:t})=>(console.warn('[tiptap warn]: DEPRECATED: The "user" command is deprecated. Please use "updateUser" instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret'),t.commands.updateUser(e))}},addProseMirrorPlugins(){return[uk((this.options.provider.awareness.setLocalStateField("user",this.options.user),this.storage.users=OE(this.options.provider.awareness.states),this.options.provider.awareness.on("update",()=>{this.storage.users=OE(this.options.provider.awareness.states)}),this.options.provider.awareness),{cursorBuilder:this.options.render,selectionBuilder:this.options.selectionRender})]}}),Ck=yk,vk=e=>vt({find:/--$/,replace:e??"—"}),xk=e=>vt({find:/\.\.\.$/,replace:e??"…"}),Nk=e=>vt({find:/(?:^|[\s{[(<'"\u2018\u201C])(")$/,replace:e??"“"}),Rk=e=>vt({find:/"$/,replace:e??"”"}),Ak=e=>vt({find:/(?:^|[\s{[(<'"\u2018\u201C])(')$/,replace:e??"‘"}),Ok=e=>vt({find:/'$/,replace:e??"’"}),Ik=e=>vt({find:/<-$/,replace:e??"←"}),kk=e=>vt({find:/->$/,replace:e??"→"}),wk=e=>vt({find:/\(c\)$/,replace:e??"©"}),Mk=e=>vt({find:/\(tm\)$/,replace:e??"™"}),Dk=e=>vt({find:/\(sm\)$/,replace:e??"℠"}),Lk=e=>vt({find:/\(r\)$/,replace:e??"®"}),Pk=e=>vt({find:/(?:^|\s)(1\/2)\s$/,replace:e??"½"}),Bk=e=>vt({find:/\+\/-$/,replace:e??"±"}),Fk=e=>vt({find:/!=$/,replace:e??"≠"}),Uk=e=>vt({find:/<<$/,replace:e??"«"}),zk=e=>vt({find:/>>$/,replace:e??"»"}),Hk=e=>vt({find:/\d+\s?([*x])\s?\d+$/,replace:e??"×"}),Gk=e=>vt({find:/\^2$/,replace:e??"²"}),Vk=e=>vt({find:/\^3$/,replace:e??"³"}),Yk=e=>vt({find:/(?:^|\s)(1\/4)\s$/,replace:e??"¼"}),$k=e=>vt({find:/(?:^|\s)(3\/4)\s$/,replace:e??"¾"}),Wk=Re.create({name:"typography",addOptions(){return{closeDoubleQuote:"”",closeSingleQuote:"’",copyright:"©",ellipsis:"…",emDash:"—",laquo:"«",leftArrow:"←",multiplication:"×",notEqual:"≠",oneHalf:"½",oneQuarter:"¼",openDoubleQuote:"“",openSingleQuote:"‘",plusMinus:"±",raquo:"»",registeredTrademark:"®",rightArrow:"→",servicemark:"℠",superscriptThree:"³",superscriptTwo:"²",threeQuarters:"¾",trademark:"™"}},addInputRules(){const e=[];return this.options.emDash!==!1&&e.push(vk(this.options.emDash)),this.options.ellipsis!==!1&&e.push(xk(this.options.ellipsis)),this.options.openDoubleQuote!==!1&&e.push(Nk(this.options.openDoubleQuote)),this.options.closeDoubleQuote!==!1&&e.push(Rk(this.options.closeDoubleQuote)),this.options.openSingleQuote!==!1&&e.push(Ak(this.options.openSingleQuote)),this.options.closeSingleQuote!==!1&&e.push(Ok(this.options.closeSingleQuote)),this.options.leftArrow!==!1&&e.push(Ik(this.options.leftArrow)),this.options.rightArrow!==!1&&e.push(kk(this.options.rightArrow)),this.options.copyright!==!1&&e.push(wk(this.options.copyright)),this.options.trademark!==!1&&e.push(Mk(this.options.trademark)),this.options.servicemark!==!1&&e.push(Dk(this.options.servicemark)),this.options.registeredTrademark!==!1&&e.push(Lk(this.options.registeredTrademark)),this.options.oneHalf!==!1&&e.push(Pk(this.options.oneHalf)),this.options.plusMinus!==!1&&e.push(Bk(this.options.plusMinus)),this.options.notEqual!==!1&&e.push(Fk(this.options.notEqual)),this.options.laquo!==!1&&e.push(Uk(this.options.laquo)),this.options.raquo!==!1&&e.push(zk(this.options.raquo)),this.options.multiplication!==!1&&e.push(Hk(this.options.multiplication)),this.options.superscriptTwo!==!1&&e.push(Gk(this.options.superscriptTwo)),this.options.superscriptThree!==!1&&e.push(Vk(this.options.superscriptThree)),this.options.oneQuarter!==!1&&e.push(Yk(this.options.oneQuarter)),this.options.threeQuarters!==!1&&e.push($k(this.options.threeQuarters)),e}}),jk=Wk,qk=bt.create({name:"doc",topNode:!0,content:"block+"}),Kk=qk,Qk=bt.create({name:"text",group:"inline"}),Xk=Qk,Zk=Object.defineProperty,Jk=(e,t)=>{for(var n in t)Zk(e,n,{get:t[n],enumerable:!0})},ew="listItem",kE="textStyle",wE=/^\s*([-+*])\s$/,ME=bt.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:e}){return["ul",Pe(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(ew,this.editor.getAttributes(kE)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=Oo({find:wE,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Oo({find:wE,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(kE),editor:this.editor})),[e]}}),DE=bt.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:e}){return["li",Pe(this.options.HTMLAttributes,e),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),tw={};Jk(tw,{findListItemPos:()=>Ja,getNextListDepth:()=>Kp,handleBackspace:()=>Qp,handleDelete:()=>Xp,hasListBefore:()=>LE,hasListItemAfter:()=>nw,hasListItemBefore:()=>PE,listItemHasSubList:()=>BE,nextListIsDeeper:()=>FE,nextListIsHigher:()=>UE});var Ja=(e,t)=>{const{$from:n}=t.selection,r=Dt(e,t.schema);let i=null,o=n.depth,a=n.pos,s=null;for(;o>0&&s===null;)i=n.node(o),i.type===r?s=o:(o-=1,a-=1);return s===null?null:{$pos:t.doc.resolve(a),depth:s}},Kp=(e,t)=>{const n=Ja(e,t);if(!n)return!1;const[,r]=NR(t,e,n.$pos.pos+4);return r},LE=(e,t,n)=>{const{$anchor:r}=e.selection,i=Math.max(0,r.pos-2),o=e.doc.resolve(i).node();return!(!o||!n.includes(o.type.name))},PE=(e,t)=>{var n;const{$anchor:r}=t.selection,i=t.doc.resolve(r.pos-2);return!(i.index()===0||((n=i.nodeBefore)==null?void 0:n.type.name)!==e)},BE=(e,t,n)=>{if(!n)return!1;const r=Dt(e,t.schema);let i=!1;return n.descendants(o=>{o.type===r&&(i=!0)}),i},Qp=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!di(e.state,t)&&LE(e.state,t,n)){const{$anchor:s}=e.state.selection,l=e.state.doc.resolve(s.before()-1),c=[];l.node().descendants((p,m)=>{p.type.name===t&&c.push({node:p,pos:m})});const d=c.at(-1);if(!d)return!1;const u=e.state.doc.resolve(l.start()+d.pos+1);return e.chain().cut({from:s.start()-1,to:s.end()+1},u.end()).joinForward().run()}if(!di(e.state,t)||!IR(e.state))return!1;const r=Ja(t,e.state);if(!r)return!1;const o=e.state.doc.resolve(r.$pos.pos-2).node(r.depth),a=BE(t,e.state,o);return PE(t,e.state)&&!a?e.commands.joinItemBackward():e.chain().liftListItem(t).run()},FE=(e,t)=>{const n=Kp(e,t),r=Ja(e,t);return!r||!n?!1:n>r.depth},UE=(e,t)=>{const n=Kp(e,t),r=Ja(e,t);return!r||!n?!1:n<r.depth},Xp=(e,t)=>{if(!di(e.state,t)||!OR(e.state,t))return!1;const{selection:n}=e.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:FE(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():UE(t,e.state)?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward()},nw=(e,t)=>{var n;const{$anchor:r}=t.selection,i=t.doc.resolve(r.pos-r.parentOffset-2);return!(i.index()===i.parent.childCount-1||((n=i.nodeAfter)==null?void 0:n.type.name)!==e)},rw=Re.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&Xp(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&Xp(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&Qp(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&Qp(e,n,r)&&(t=!0)}),t}}}}),iw="listItem",zE="textStyle",HE=/^(\d+)\.\s$/,GE=bt.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:null,parseHTML:e=>e.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:e}){const{start:t,...n}=e;return t===1?["ol",Pe(this.options.HTMLAttributes,n),0]:["ol",Pe(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(iw,this.editor.getAttributes(zE)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=Oo({find:HE,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Oo({find:HE,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(zE)}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1],editor:this.editor})),[e]}}),ow=/^\s*(\[([( |x])?\])\s$/,VE=bt.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:e=>{const t=e.getAttribute("data-checked");return t===""||t==="true"},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:e,HTMLAttributes:t}){return["li",Pe(this.options.HTMLAttributes,t,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:e.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{const i=document.createElement("li"),o=document.createElement("label"),a=document.createElement("span"),s=document.createElement("input"),l=document.createElement("div"),c=d=>{var u,p;s.ariaLabel=((p=(u=this.options.a11y)==null?void 0:u.checkboxLabel)==null?void 0:p.call(u,d,s.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return c(e),o.contentEditable="false",s.type="checkbox",s.addEventListener("mousedown",d=>d.preventDefault()),s.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}const{checked:u}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:p})=>{const m=n();if(typeof m!="number")return!1;const _=p.doc.nodeAt(m);return p.setNodeMarkup(m,void 0,{..._?.attrs,checked:u}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,u)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,u])=>{i.setAttribute(d,u)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,o.append(s,a),i.append(o,l),Object.entries(t).forEach(([d,u])=>{i.setAttribute(d,u)}),{dom:i,contentDOM:l,update:d=>d.type!==this.type?!1:(i.dataset.checked=d.attrs.checked,s.checked=d.attrs.checked,c(d),!0)}}},addInputRules(){return[Oo({find:ow,type:this.type,getAttributes:e=>({checked:e[e.length-1]==="x"})})]}}),YE=bt.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:e}){return["ul",Pe(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Re.create({name:"listKit",addExtensions(){const e=[];return this.options.bulletList!==!1&&e.push(ME.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(DE.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(rw.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(GE.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(VE.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(YE.configure(this.options.taskList)),e}});var aw=GE;const sw=aw.extend({name:"orderedList",addAttributes(){return{listType:{default:kl,parseHTML:e=>e.getAttribute(xp)||kl,renderHTML:e=>!e.listType||e.listType===kl?{}:{[xp]:e.listType}}}},parseHTML(){return[{tag:"ol",getAttrs:e=>typeof e=="string"?{}:{listType:e.getAttribute(xp)||kl}}]},renderHTML({HTMLAttributes:e}){return["ol",Pe(this.options.HTMLAttributes,e),0]},addCommands(){return{setOrderedListType:e=>({commands:t})=>t.updateAttributes("orderedList",{listType:e})}}});var lw=ME;const Zp=e=>{switch(e){case"default":case"diamondArrow":case"square":case"arrowDiamond":case"star":case"arrowCircle":return e;default:return Rp}},cw=lw.extend({name:"bulletList",addAttributes(){return{listType:{default:Rp,parseHTML:e=>Zp(e.getAttribute(Np)),renderHTML:e=>{const t=Zp(e.listType);return t===Rp?{}:{[Np]:t}}}}},parseHTML(){return[{tag:"ul",getAttrs:e=>typeof e=="string"?{}:{listType:Zp(e.getAttribute(Np))}}]},renderHTML({HTMLAttributes:e}){return["ul",Pe(this.options.HTMLAttributes,e),0]},addCommands(){return{setBulletListType:e=>({commands:t})=>t.updateAttributes("bulletList",{listType:e})}}});var dw=20,$E=(e,t=0)=>{const n=[];return!e.children.length||t>dw||Array.from(e.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...$E(r,t+1))}),n},uw=e=>{if(!e.children.length)return;const t=$E(e);t&&t.forEach(n=>{var r,i;const o=n.getAttribute("style"),a=(i=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:i.getAttribute("style");n.setAttribute("style",`${a};${o}`)})},WE=bn.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:e=>e.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&uw(e),{}):!1}]},renderHTML({HTMLAttributes:e}){return["span",Pe(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleTextStyle:e=>({commands:t})=>t.toggleMark(this.name,e),removeEmptyTextStyle:()=>({tr:e})=>{const{selection:t}=e;return e.doc.nodesBetween(t.from,t.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(i=>i.type===this.type).some(i=>Object.values(i.attrs).some(o=>!!o))||e.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),jE=Re.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:e=>{var t;const n=e.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const o=r[i].split(":");if(o.length>=2){const a=o[0].trim().toLowerCase(),s=o.slice(1).join(":").trim();if(a==="background-color")return s.replace(/['"]+/g,"")}}}return(t=e.style.backgroundColor)==null?void 0:t.replace(/['"]+/g,"")},renderHTML:e=>e.backgroundColor?{style:`background-color: ${e.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:e=>({chain:t})=>t().setMark("textStyle",{backgroundColor:e}).run(),unsetBackgroundColor:()=>({chain:e})=>e().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),qE=Re.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:e=>{var t;const n=e.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const o=r[i].split(":");if(o.length>=2){const a=o[0].trim().toLowerCase(),s=o.slice(1).join(":").trim();if(a==="color")return s.replace(/['"]+/g,"")}}}return(t=e.style.color)==null?void 0:t.replace(/['"]+/g,"")},renderHTML:e=>e.color?{style:`color: ${e.color}`}:{}}}}]},addCommands(){return{setColor:e=>({chain:t})=>t().setMark("textStyle",{color:e}).run(),unsetColor:()=>({chain:e})=>e().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),KE=Re.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:e=>e.style.fontFamily,renderHTML:e=>e.fontFamily?{style:`font-family: ${e.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:e=>({chain:t})=>t().setMark("textStyle",{fontFamily:e}).run(),unsetFontFamily:()=>({chain:e})=>e().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),QE=Re.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>e.style.fontSize,renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:e=>({chain:t})=>t().setMark("textStyle",{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),XE=Re.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:e=>e.style.lineHeight,renderHTML:e=>e.lineHeight?{style:`line-height: ${e.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:e=>({chain:t})=>t().setMark("textStyle",{lineHeight:e}).run(),unsetLineHeight:()=>({chain:e})=>e().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});Re.create({name:"textStyleKit",addExtensions(){const e=[];return this.options.backgroundColor!==!1&&e.push(jE.configure(this.options.backgroundColor)),this.options.color!==!1&&e.push(qE.configure(this.options.color)),this.options.fontFamily!==!1&&e.push(KE.configure(this.options.fontFamily)),this.options.fontSize!==!1&&e.push(QE.configure(this.options.fontSize)),this.options.lineHeight!==!1&&e.push(XE.configure(this.options.lineHeight)),this.options.textStyle!==!1&&e.push(WE.configure(this.options.textStyle)),e}});var pw=YE,mw=VE;const fw=new Fe("taskItemMarkerFontSize");function ZE(e){let t=null;return e.descendants(n=>{if(n.type.name==="orderedList"||n.type.name==="bulletList"||n.type.name==="taskList")return!1;if(typeof n.attrs?.fontSize=="string"&&n.attrs.fontSize)return t=n.attrs.fontSize,!1;const r=n.marks?.find(i=>i.type.name==="textStyle"&&typeof i.attrs.fontSize=="string"&&i.attrs.fontSize);return r?.attrs.fontSize?(t=r.attrs.fontSize,!1):t?!1:void 0}),t}function JE(e){let t=null;return e.descendants(n=>{if(n.type.name==="orderedList"||n.type.name==="bulletList"||n.type.name==="taskList")return!1;if(typeof n.attrs?.color=="string"&&n.attrs.color)return t=n.attrs.color,!1;const r=n.marks?.find(i=>i.type.name==="textStyle"&&typeof i.attrs.color=="string"&&i.attrs.color);return r?.attrs.color?(t=r.attrs.color,!1):t?!1:void 0}),t}function _w(e,t,n){const r=e.resolve(t);for(let i=r.depth-1;i>=0;i--){const o=r.node(i);if(o.type.name!=="taskList")continue;const a=r.index(i);if(a<=0)return null;for(let s=a-1;s>=0;s--){const l=o.child(s);if(l.type.name===n)return typeof l.attrs.markerFontSize=="string"&&l.attrs.markerFontSize?l.attrs.markerFontSize:ZE(l)}return null}return null}function hw(e,t,n){const r=e.resolve(t);for(let i=r.depth-1;i>=0;i--){const o=r.node(i);if(o.type.name!=="taskList")continue;const a=r.index(i);if(a<=0)return null;for(let s=a-1;s>=0;s--){const l=o.child(s);if(l.type.name===n)return typeof l.attrs.markerColor=="string"&&l.attrs.markerColor?l.attrs.markerColor:JE(l)}return null}return null}function e0(e,t){const{$from:n}=e.selection;for(let r=n.depth;r>0;r--)if(n.node(r).type.name===t)return n.before(r);return null}const gw=mw.extend({name:"taskItem",addAttributes(){const e=t=>{const n=[];return t.markerFontSize&&n.push(`--list-marker-font-size: ${t.markerFontSize}`),t.markerColor&&n.push(`--list-marker-color: ${t.markerColor}`),n.length===0?{}:{style:`${n.join("; ")};`}};return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const n=t.getAttribute("data-checked");return n===""||n==="true"},renderHTML:t=>({"data-checked":t.checked})},markerFontSize:{default:null,parseHTML:t=>t.style.getPropertyValue("--list-marker-font-size")||null,renderHTML:e},markerColor:{default:null,parseHTML:t=>t.style.getPropertyValue("--list-marker-color")||null,renderHTML:e}}},addCommands(){return{setSelectedTaskItemMarkerFontSize:e=>({state:t,tr:n,dispatch:r})=>{const i=new Set;if(t.selection.empty){const o=e0(t,this.name);o!==null&&i.add(o)}else t.doc.nodesBetween(t.selection.from,t.selection.to,(o,a)=>{o.type.name===this.name&&i.add(a)});return i.size===0||(i.forEach(o=>{const a=n.doc.nodeAt(o);!a||a.type.name!==this.name||(n=n.setNodeMarkup(o,void 0,{...a.attrs,markerFontSize:e}))}),r&&r(n)),!0},setSelectedTaskItemMarkerColor:e=>({state:t,tr:n,dispatch:r})=>{const i=new Set;if(t.selection.empty){const o=e0(t,this.name);o!==null&&i.add(o)}else t.doc.nodesBetween(t.selection.from,t.selection.to,(o,a)=>{o.type.name===this.name&&i.add(a)});return i.size===0||(i.forEach(o=>{const a=n.doc.nodeAt(o);!a||a.type.name!==this.name||(n=n.setNodeMarkup(o,void 0,{...a.attrs,markerColor:e}))}),r&&r(n)),!0}}},addProseMirrorPlugins(){return[new Ie({key:fw,appendTransaction:(e,t,n)=>{if(!e.some(o=>o.docChanged))return null;let r=n.tr,i=!1;return n.doc.descendants((o,a)=>{if(o.type.name!==this.name)return;const s=typeof o.attrs.markerFontSize=="string"&&o.attrs.markerFontSize?o.attrs.markerFontSize:null,l=typeof o.attrs.markerColor=="string"&&o.attrs.markerColor?o.attrs.markerColor:null,c=ZE(o),d=JE(o),u=s??_w(n.doc,a,this.name),p=l??hw(n.doc,a,this.name),m=c??u,_=d??p;m===s&&_===l||(r=r.setNodeMarkup(a,void 0,{...o.attrs,markerFontSize:m,markerColor:_}),i=!0)}),i?r:null}})]},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{const i=document.createElement("li"),o=document.createElement("label"),a=document.createElement("span"),s=document.createElement("input"),l=document.createElement("div"),c=p=>{p?i.style.setProperty("--list-marker-font-size",p):i.style.removeProperty("--list-marker-font-size")},d=p=>{p?i.style.setProperty("--list-marker-color",p):i.style.removeProperty("--list-marker-color")},u=p=>{s.ariaLabel=this.options.a11y?.checkboxLabel?.(p,s.checked)||`Task item checkbox for ${p.textContent||"empty task item"}`};return u(e),o.contentEditable="false",s.type="checkbox",s.addEventListener("mousedown",p=>p.preventDefault()),s.addEventListener("change",p=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}const{checked:m}=p.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:_})=>{const h=n();if(typeof h!="number")return!1;const g=_.doc.nodeAt(h);return _.setNodeMarkup(h,void 0,{...g?.attrs,checked:m}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,m)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([p,m])=>{i.setAttribute(p,String(m))}),i.dataset.checked=String(e.attrs.checked),i.dataset.type=this.name,s.checked=e.attrs.checked,c(e.attrs.markerFontSize),d(e.attrs.markerColor),o.append(s,a),i.append(o,l),Object.entries(t).forEach(([p,m])=>{m!=null&&i.setAttribute(p,String(m))}),{dom:i,contentDOM:l,update:p=>p.type!==this.type?!1:(i.dataset.checked=String(p.attrs.checked),s.checked=p.attrs.checked,c(p.attrs.markerFontSize),d(p.attrs.markerColor),u(p),!0)}}}}),Fr=new Fe("ai-autocompletion"),bw=Re.create({name:"aiAutoCompletion",priority:1e3,addOptions(){return{minWordsToTriggerAutoCompletion:3,debounceTime:100,isEnabled:!1,fetchCompletion:void 0}},addStorage(){return{isEnabled:this.options.isEnabled}},addCommands(){return{acceptSuggestion:()=>({state:e,dispatch:t})=>{const n=Fr.getState(e);if(!n?.suggestion)return!1;if(t){const{to:r,text:i}=n.suggestion,o=e.tr.insertText(i,r,r).setMeta(Fr,{type:"clear"});t(o)}return!0},dismissSuggestion:()=>({state:e,dispatch:t})=>{if(t){const n=e.tr.setMeta(Fr,{type:"clear"});t(n)}return!0},enableAutocompletion:()=>({editor:e})=>(this.options.isEnabled=!0,this.storage.isEnabled=!0,e.commands.dismissSuggestion(),!0),disableAutocompletion:()=>({editor:e})=>(this.options.isEnabled=!1,this.storage.isEnabled=!1,e.commands.dismissSuggestion(),!0),toggleAutocompletion:()=>({editor:e})=>this.storage.isEnabled?e.commands.disableAutocompletion():e.commands.enableAutocompletion()}},addKeyboardShortcuts(){return{Tab:({editor:e})=>Fr.getState(e.state)?.suggestion?e.commands.acceptSuggestion():!1,Escape:({editor:e})=>Fr.getState(e.state)?.suggestion?e.commands.dismissSuggestion():!1,"Mod-Shift-Space":({editor:e})=>e.commands.toggleAutocompletion()}},addProseMirrorPlugins(){const e=this;let t,n=null;return[new Ie({key:Fr,state:{init(){return{decorationSet:Me.empty,suggestion:null}},apply(r,i){const o=r.getMeta(Fr);if(o?.type==="clear")return{decorationSet:Me.empty,suggestion:null};if(o?.type==="setSuggestion"){const{to:s,text:l,styles:c}=o.suggestion,d=gt.widget(s,()=>{const u=document.createElement("span");return u.className="ai-suggestion",u.textContent=l,u.style.opacity="0.6",c.color&&(u.style.color=c.color),c.fontFamily&&(u.style.fontFamily=c.fontFamily),c.fontSize&&(u.style.fontSize=c.fontSize),c.fontWeight&&(u.style.fontWeight=c.fontWeight),c.fontStyle&&(u.style.fontStyle=c.fontStyle),c.textDecoration&&(u.style.textDecoration=c.textDecoration),c.backgroundColor&&(u.style.backgroundColor=c.backgroundColor),u});return{decorationSet:Me.create(r.doc,[d]),suggestion:o.suggestion}}const a=i.decorationSet.map(r.mapping,r.doc);return{decorationSet:r.docChanged?Me.empty:a,suggestion:r.docChanged?null:i.suggestion}}},props:{decorations(r){return this.getState(r)?.decorationSet}},view(r){const i=async(o,a)=>{if(e.storage.isEnabled){n?.abort(),n=new AbortController;try{if(!e.options.fetchCompletion)return;const s=await e.options.fetchCompletion(o),l=r.state.selection.$head.pos,c=r.state.doc.textBetween(Math.max(0,l-200),l,`
|
|
147
147
|
`);if(!r.state.selection.empty||Math.abs(l-a)>50||!c.includes(o.slice(-20)))return;const d=r.state.doc.resolve(l),u=r.state.storedMarks??d.marks(),p={};u.forEach(m=>{m.type.name==="textStyle"&&(m.attrs.color&&(p.color=m.attrs.color),m.attrs.fontFamily&&(p.fontFamily=m.attrs.fontFamily),m.attrs.fontSize&&(p.fontSize=m.attrs.fontSize),m.attrs.backgroundColor&&(p.backgroundColor=m.attrs.backgroundColor)),m.type.name==="bold"&&(p.fontWeight="bold"),m.type.name==="italic"&&(p.fontStyle="italic"),m.type.name==="underline"&&(p.textDecoration=p.textDecoration?`${p.textDecoration} underline`:"underline"),m.type.name==="strike"&&(p.textDecoration=p.textDecoration?`${p.textDecoration} line-through`:"line-through")}),s&&typeof s=="string"&&r.dispatch(r.state.tr.setMeta(Fr,{type:"setSuggestion",suggestion:{from:l-o.length,to:l,text:s,styles:p}}))}catch(s){s instanceof Error&&s.name!=="AbortError"&&console.error("[AI Autocompletion Error]:",s)}finally{n?.signal===n.signal&&(n=null)}}};return{update(o,a){if(!e.storage.isEnabled||a.doc.eq(o.state.doc))return;const{selection:s}=o.state;if(!s.empty)return;const l=s.$head.pos,c=o.state.doc.textBetween(Math.max(0,l-200),l,`
|
|
148
|
-
`);if(c.trim().split(/\s+/).filter(Boolean).length<e.options.minWordsToTriggerAutoCompletion){n?.abort(),n=null,clearTimeout(t),o.dispatch(o.state.tr.setMeta(Fr,{type:"clear"}));return}clearTimeout(t),t=setTimeout(()=>i(c,l),e.options.debounceTime)},destroy(){clearTimeout(t),n?.abort(),n=null}}}})]}}),es="onBlurHighlight",ql={BLUR:"blur",FOCUS:"focus"},Ew=Re.create({name:es,addProseMirrorPlugins(){return[new Ie({key:new Fe(es),state:{init(){return Me.empty},apply(e,t){const n=e.getMeta(es),{selection:r,doc:i}=e,o=r&&r.from!==r.to;if(!o||n?.action===ql.FOCUS)return Me.empty;if(o&&n?.action===ql.BLUR){const a=gt.inline(r.from,r.to,{class:"blur-highlight"});return Me.create(i,[a])}return t}},props:{decorations(e){return this.getState(e)},handleDOMEvents:{blur:e=>{const{tr:t}=e.state,n=t.setMeta(es,{from:t.selection.from,to:t.selection.to,action:ql.BLUR});return e.dispatch(n),!1},focus:e=>{const{tr:t}=e.state,n=t.setMeta(es,{from:t.selection.from,to:t.selection.to,action:ql.FOCUS});return e.dispatch(n),!1}}}})]}}),Sw=Re.create({name:"indent",addOptions(){return{types:["paragraph","heading","blockquote"],minLevel:0,maxLevel:12}},addGlobalAttributes(){return[{types:this.options.types,attributes:{indent:{default:0,parseHTML:e=>{const t=e.style.marginLeft;return t?t.includes("in")?parseFloat(t)/.5||0:parseInt(t)/48||0:0},renderHTML:e=>e.indent?{style:`margin-left: ${e.indent*.5}in`}:{}}}}]},addCommands(){return{indent:()=>({state:e,dispatch:t,tr:n})=>{const{selection:r}=e,{from:i,to:o}=r;return e.doc.nodesBetween(i,o,(a,s)=>{if(this.options.types.includes(a.type.name)){const l=a.attrs.indent||0;l<this.options.maxLevel&&n.setNodeMarkup(s,void 0,{...a.attrs,indent:l+1})}}),t&&t(n),!0},outdent:()=>({state:e,dispatch:t,tr:n})=>{const{selection:r}=e,{from:i,to:o}=r;return e.doc.nodesBetween(i,o,(a,s)=>{if(this.options.types.includes(a.type.name)){const l=a.attrs.indent||0;l>this.options.minLevel&&n.setNodeMarkup(s,void 0,{...a.attrs,indent:l-1})}}),t&&t(n),!0}}},addKeyboardShortcuts(){return{Tab:()=>{if(this.editor.can().sinkListItem("taskItem")||this.editor.can().sinkListItem("listItem")){if(this.editor.isActive("taskItem"))return this.editor.chain().focus().sinkListItem("taskItem").run();if(this.editor.isActive("listItem"))return this.editor.chain().focus().sinkListItem("listItem").run()}return this.editor.commands.indent()},"Shift-Tab":()=>{if(this.editor.can().liftListItem("taskItem")||this.editor.can().liftListItem("listItem")){if(this.editor.isActive("taskItem"))return this.editor.chain().focus().liftListItem("taskItem").run();if(this.editor.isActive("listItem"))return this.editor.chain().focus().liftListItem("listItem").run()}return this.editor.commands.outdent()}}}});var Tw=DE;const yw=new Fe("listMarkerFontSize");function Cw(e,t){let n=0;return t.nodesBetween(0,t.content.size,(r,i)=>{i<e&&i+r.nodeSize>e&&(r.type.name==="orderedList"||r.type.name==="bulletList")&&n++}),n}function t0(e){let t=null;return e.descendants(n=>{if(n.type.name==="orderedList"||n.type.name==="bulletList")return!1;if(typeof n.attrs?.fontSize=="string"&&n.attrs.fontSize)return t=n.attrs.fontSize,!1;const r=n.marks?.find(i=>i.type.name==="textStyle"&&typeof i.attrs.fontSize=="string"&&i.attrs.fontSize);return r?.attrs.fontSize?(t=r.attrs.fontSize,!1):t?!1:void 0}),t}function n0(e){let t=null;return e.descendants(n=>{if(n.type.name==="orderedList"||n.type.name==="bulletList")return!1;if(typeof n.attrs?.color=="string"&&n.attrs.color)return t=n.attrs.color,!1;const r=n.marks?.find(i=>i.type.name==="textStyle"&&typeof i.attrs.color=="string"&&i.attrs.color);return r?.attrs.color?(t=r.attrs.color,!1):t?!1:void 0}),t}function vw(e,t,n){const r=e.resolve(t);for(let i=r.depth-1;i>=0;i--){const o=r.node(i);if(o.type.name!=="orderedList"&&o.type.name!=="bulletList")continue;const a=r.index(i);if(a<=0)return null;for(let s=a-1;s>=0;s--){const l=o.child(s);if(l.type.name===n)return typeof l.attrs.markerFontSize=="string"&&l.attrs.markerFontSize?l.attrs.markerFontSize:t0(l)}return null}return null}function xw(e,t,n){const r=e.resolve(t);for(let i=r.depth-1;i>=0;i--){const o=r.node(i);if(o.type.name!=="orderedList"&&o.type.name!=="bulletList")continue;const a=r.index(i);if(a<=0)return null;for(let s=a-1;s>=0;s--){const l=o.child(s);if(l.type.name===n)return typeof l.attrs.markerColor=="string"&&l.attrs.markerColor?l.attrs.markerColor:n0(l)}return null}return null}function r0(e,t){const{$from:n}=e.selection;for(let r=n.depth;r>0;r--)if(n.node(r).type.name===t)return n.before(r);return null}const Nw=Tw.extend({name:"listItem",addAttributes(){const e=t=>{const n=[];return t.markerFontSize&&n.push(`--list-marker-font-size: ${t.markerFontSize}`),t.markerColor&&n.push(`--list-marker-color: ${t.markerColor}`),n.length===0?{}:{style:`${n.join("; ")};`}};return{...this.parent?.(),markerFontSize:{default:null,parseHTML:t=>t.style.getPropertyValue("--list-marker-font-size")||null,renderHTML:e},markerColor:{default:null,parseHTML:t=>t.style.getPropertyValue("--list-marker-color")||null,renderHTML:e}}},addOptions(){return{maxDepth:9}},addCommands(){return{setSelectedListItemMarkerFontSize:e=>({state:t,tr:n,dispatch:r})=>{const i=new Set;if(t.selection.empty){const o=r0(t,this.name);o!==null&&i.add(o)}else t.doc.nodesBetween(t.selection.from,t.selection.to,(o,a)=>{o.type.name===this.name&&i.add(a)});return i.size===0||(i.forEach(o=>{const a=n.doc.nodeAt(o);!a||a.type.name!==this.name||(n=n.setNodeMarkup(o,void 0,{...a.attrs,markerFontSize:e}))}),r&&r(n)),!0},setSelectedListItemMarkerColor:e=>({state:t,tr:n,dispatch:r})=>{const i=new Set;if(t.selection.empty){const o=r0(t,this.name);o!==null&&i.add(o)}else t.doc.nodesBetween(t.selection.from,t.selection.to,(o,a)=>{o.type.name===this.name&&i.add(a)});return i.size===0||(i.forEach(o=>{const a=n.doc.nodeAt(o);!a||a.type.name!==this.name||(n=n.setNodeMarkup(o,void 0,{...a.attrs,markerColor:e}))}),r&&r(n)),!0},sinkListItem:e=>({state:t,dispatch:n})=>{const{$from:r}=t.selection,i=typeof e=="string"?t.schema.nodes[e]:e;if(!i)return!1;let o=-1;for(let l=r.depth;l>0;l--)if(r.node(l).type===i){o=r.before(l);break}if(o===-1)return!1;const a=Cw(o,t.doc),s=Math.max(0,Math.min(9,this.options.maxDepth));return a>=s?!1:Ah(i)(t,n)},liftListItem:e=>({state:t,dispatch:n})=>{const r=typeof e=="string"?t.schema.nodes[e]:e;return Rh(r)(t,n)}}},addProseMirrorPlugins(){return[new Ie({key:yw,appendTransaction:(e,t,n)=>{if(!e.some(o=>o.docChanged))return null;let r=n.tr,i=!1;return n.doc.descendants((o,a)=>{if(o.type.name!==this.name)return;const s=typeof o.attrs.markerFontSize=="string"&&o.attrs.markerFontSize?o.attrs.markerFontSize:null,l=typeof o.attrs.markerColor=="string"&&o.attrs.markerColor?o.attrs.markerColor:null,c=t0(o),d=n0(o),u=s??vw(n.doc,a,this.name),p=l??xw(n.doc,a,this.name),m=c??u,_=d??p;m===s&&_===l||(r=r.setNodeMarkup(a,void 0,{...o.attrs,markerFontSize:m,markerColor:_}),i=!0)}),i?r:null}})]}});var Rw=bn.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(e){return e!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:e}){return["sub",Pe(this.options.HTMLAttributes,e),0]},addCommands(){return{setSubscript:()=>({commands:e})=>e.setMark(this.name),toggleSubscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSubscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),Aw=Rw,Ow=bn.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(e){return e!=="super"?!1:null}}]},renderHTML({HTMLAttributes:e}){return["sup",Pe(this.options.HTMLAttributes,e),0]},addCommands(){return{setSuperscript:()=>({commands:e})=>e.setMark(this.name),toggleSuperscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSuperscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),Iw=Ow,kw=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,ww=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,Mw=bn.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute("data-color")||e.style.backgroundColor,renderHTML:e=>e.color?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:e}){return["mark",Pe(this.options.HTMLAttributes,e),0]},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Ao({find:kw,type:this.type})]},addPasteRules(){return[Hi({find:ww,type:this.type})]}}),Dw=Mw,Lw=Re.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:e=>{const t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>e.textAlign?{style:`text-align: ${e.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).every(n=>n):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,"textAlign")).every(t=>t),toggleTextAlign:e=>({editor:t,commands:n})=>this.options.alignments.includes(e)?t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e):!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")}}}),Pw=Lw,Kl=(e,t)=>{if(e==="slot")return 0;if(e instanceof Function)return e(t);const{children:n,...r}=t??{};if(e==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[e,r,n]},Bw=/^\s*>\s$/,Fw=bt.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return Kl("blockquote",{...Pe(this.options.HTMLAttributes,e),children:Kl("slot",{})})},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Oo({find:Bw,type:this.type})]}}),Uw=Fw,zw=bt.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,Pe(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>_A({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),Hw=zw,Jp,em;if(typeof WeakMap<"u"){let e=new WeakMap;Jp=t=>e.get(t),em=(t,n)=>(e.set(t,n),n)}else{const e=[];let n=0;Jp=r=>{for(let i=0;i<e.length;i+=2)if(e[i]==r)return e[i+1]},em=(r,i)=>(n==10&&(n=0),e[n++]=r,e[n++]=i)}var Nt=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){const n=this.map[t];if(n!=e)continue;const r=t%this.width,i=t/this.width|0;let o=r+1,a=i+1;for(let s=1;o<this.width&&this.map[t+s]==n;s++)o++;for(let s=1;a<this.height&&this.map[t+this.width*s]==n;s++)a++;return{left:r,top:i,right:o,bottom:a}}throw new RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){const{left:r,right:i,top:o,bottom:a}=this.findCell(e);return t=="horiz"?(n<0?r==0:i==this.width)?null:this.map[o*this.width+(n<0?r-1:i)]:(n<0?o==0:a==this.height)?null:this.map[r+this.width*(n<0?o-1:a)]}rectBetween(e,t){const{left:n,right:r,top:i,bottom:o}=this.findCell(e),{left:a,right:s,top:l,bottom:c}=this.findCell(t);return{left:Math.min(n,a),top:Math.min(i,l),right:Math.max(r,s),bottom:Math.max(o,c)}}cellsInRect(e){const t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){const o=r*this.width+i,a=this.map[o];n[a]||(n[a]=!0,!(i==e.left&&i&&this.map[o-1]==a||r==e.top&&r&&this.map[o-this.width]==a)&&t.push(a))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){const o=i+n.child(r).nodeSize;if(r==e){let a=t+e*this.width;const s=(e+1)*this.width;for(;a<s&&this.map[a]<i;)a++;return a==s?o-1:this.map[a]}i=o}}static get(e){return Jp(e)||em(e,Gw(e))}};function Gw(e){if(e.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+e.type.name);const t=Vw(e),n=e.childCount,r=[];let i=0,o=null;const a=[];for(let c=0,d=t*n;c<d;c++)r[c]=0;for(let c=0,d=0;c<n;c++){const u=e.child(c);d++;for(let _=0;;_++){for(;i<r.length&&r[i]!=0;)i++;if(_==u.childCount)break;const h=u.child(_),{colspan:g,rowspan:b,colwidth:E}=h.attrs;for(let S=0;S<b;S++){if(S+c>=n){(o||(o=[])).push({type:"overlong_rowspan",pos:d,n:b-S});break}const y=i+S*t;for(let T=0;T<g;T++){r[y+T]==0?r[y+T]=d:(o||(o=[])).push({type:"collision",row:c,pos:d,n:g-T});const x=E&&E[T];if(x){const v=(y+T)%t*2,C=a[v];C==null||C!=x&&a[v+1]==1?(a[v]=x,a[v+1]=1):C==x&&a[v+1]++}}}i+=g,d+=h.nodeSize}const p=(c+1)*t;let m=0;for(;i<p;)r[i++]==0&&m++;m&&(o||(o=[])).push({type:"missing",row:c,n:m}),d++}(t===0||n===0)&&(o||(o=[])).push({type:"zero_sized"});const s=new Nt(t,n,r,o);let l=!1;for(let c=0;!l&&c<a.length;c+=2)a[c]!=null&&a[c+1]<n&&(l=!0);return l&&Yw(s,a,e),s}function Vw(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){const i=e.child(r);let o=0;if(n)for(let a=0;a<r;a++){const s=e.child(a);for(let l=0;l<s.childCount;l++){const c=s.child(l);a+c.attrs.rowspan>r&&(o+=c.attrs.colspan)}}for(let a=0;a<i.childCount;a++){const s=i.child(a);o+=s.attrs.colspan,s.attrs.rowspan>1&&(n=!0)}t==-1?t=o:t!=o&&(t=Math.max(t,o))}return t}function Yw(e,t,n){e.problems||(e.problems=[]);const r={};for(let i=0;i<e.map.length;i++){const o=e.map[i];if(r[o])continue;r[o]=!0;const a=n.nodeAt(o);if(!a)throw new RangeError(`No cell with offset ${o} found`);let s=null;const l=a.attrs;for(let c=0;c<l.colspan;c++){const d=(i+c)%e.width,u=t[d*2];u!=null&&(!l.colwidth||l.colwidth[c]!=u)&&((s||(s=$w(l)))[c]=u)}s&&e.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:s})}}function $w(e){if(e.colwidth)return e.colwidth.slice();const t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function un(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(const n in e.nodes){const r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}var fi=new Fe("selectingCells");function Po(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return e.node(0).resolve(e.before(t+1));return null}function Ww(e){for(let t=e.depth;t>0;t--){const n=e.node(t).type.spec.tableRole;if(n==="cell"||n==="header_cell")return e.node(t)}return null}function Jn(e){const t=e.selection.$head;for(let n=t.depth;n>0;n--)if(t.node(n).type.spec.tableRole=="row")return!0;return!1}function Ql(e){const t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&t.node.type.spec.tableRole=="cell")return t.$anchor;const n=Po(t.$head)||jw(t.$head);if(n)return n;throw new RangeError(`No cell found around position ${t.head}`)}function jw(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){const r=t.type.spec.tableRole;if(r=="cell"||r=="header_cell")return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){const r=t.type.spec.tableRole;if(r=="cell"||r=="header_cell")return e.doc.resolve(n-t.nodeSize)}}function tm(e){return e.parent.type.spec.tableRole=="row"&&!!e.nodeAfter}function qw(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function nm(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function i0(e,t,n){const r=e.node(-1),i=Nt.get(r),o=e.start(-1),a=i.nextCell(e.pos-o,t,n);return a==null?null:e.node(0).resolve(o+a)}function Ki(e,t,n=1){const r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function o0(e,t,n=1){const r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<n;i++)r.colwidth.splice(t,0,0)}return r}function Kw(e,t,n){const r=un(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=r)return!1;return!0}var it=class Qr extends xe{constructor(t,n=t){const r=t.node(-1),i=Nt.get(r),o=t.start(-1),a=i.rectBetween(t.pos-o,n.pos-o),s=t.node(0),l=i.cellsInRect(a).filter(d=>d!=n.pos-o);l.unshift(n.pos-o);const c=l.map(d=>{const u=r.nodeAt(d);if(!u)throw RangeError(`No cell with offset ${d} found`);const p=o+d+1;return new oh(s.resolve(p),s.resolve(p+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=t,this.$headCell=n}map(t,n){const r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(tm(r)&&tm(i)&&nm(r,i)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?Qr.rowSelection(r,i):o&&this.isColSelection()?Qr.colSelection(r,i):new Qr(r,i)}return ue.between(r,i)}content(){const t=this.$anchorCell.node(-1),n=Nt.get(t),r=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},a=[];for(let l=i.top;l<i.bottom;l++){const c=[];for(let d=l*n.width+i.left,u=i.left;u<i.right;u++,d++){const p=n.map[d];if(o[p])continue;o[p]=!0;const m=n.findCell(p);let _=t.nodeAt(p);if(!_)throw RangeError(`No cell with offset ${p} found`);const h=i.left-m.left,g=m.right-i.right;if(h>0||g>0){let b=_.attrs;if(h>0&&(b=Ki(b,0,h)),g>0&&(b=Ki(b,b.colspan-g,g)),m.left<i.left){if(_=_.type.createAndFill(b),!_)throw RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else _=_.type.create(b,_.content)}if(m.top<i.top||m.bottom>i.bottom){const b={..._.attrs,rowspan:Math.min(m.bottom,i.bottom)-Math.max(m.top,i.top)};m.top<i.top?_=_.type.createAndFill(b):_=_.type.create(b,_.content)}c.push(_)}a.push(t.child(l).copy(j.from(c)))}const s=this.isColSelection()&&this.isRowSelection()?t:a;return new ne(j.from(s),1,1)}replace(t,n=ne.empty){const r=t.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){const{$from:s,$to:l}=i[a],c=t.mapping.slice(r);t.replace(c.map(s.pos),c.map(l.pos),a?ne.empty:n)}const o=xe.findFrom(t.doc.resolve(t.mapping.slice(r).map(this.to)),-1);o&&t.setSelection(o)}replaceWith(t,n){this.replace(t,new ne(j.from(n),0,0))}forEachCell(t){const n=this.$anchorCell.node(-1),r=Nt.get(n),i=this.$anchorCell.start(-1),o=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let a=0;a<o.length;a++)t(n.nodeAt(o[a]),i+o[a])}isColSelection(){const t=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(t,n)>0)return!1;const r=t+this.$anchorCell.nodeAfter.attrs.rowspan,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){const r=t.node(-1),i=Nt.get(r),o=t.start(-1),a=i.findCell(t.pos-o),s=i.findCell(n.pos-o),l=t.node(0);return a.top<=s.top?(a.top>0&&(t=l.resolve(o+i.map[a.left])),s.bottom<i.height&&(n=l.resolve(o+i.map[i.width*(i.height-1)+s.right-1]))):(s.top>0&&(n=l.resolve(o+i.map[s.left])),a.bottom<i.height&&(t=l.resolve(o+i.map[i.width*(i.height-1)+a.right-1]))),new Qr(t,n)}isRowSelection(){const t=this.$anchorCell.node(-1),n=Nt.get(t),r=this.$anchorCell.start(-1),i=n.colCount(this.$anchorCell.pos-r),o=n.colCount(this.$headCell.pos-r);if(Math.min(i,o)>0)return!1;const a=i+this.$anchorCell.nodeAfter.attrs.colspan,s=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,s)==n.width}eq(t){return t instanceof Qr&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){const r=t.node(-1),i=Nt.get(r),o=t.start(-1),a=i.findCell(t.pos-o),s=i.findCell(n.pos-o),l=t.node(0);return a.left<=s.left?(a.left>0&&(t=l.resolve(o+i.map[a.top*i.width])),s.right<i.width&&(n=l.resolve(o+i.map[i.width*(s.top+1)-1]))):(s.left>0&&(n=l.resolve(o+i.map[s.top*i.width])),a.right<i.width&&(t=l.resolve(o+i.map[i.width*(a.top+1)-1]))),new Qr(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new Qr(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new Qr(t.resolve(n),t.resolve(r))}getBookmark(){return new Qw(this.$anchorCell.pos,this.$headCell.pos)}};it.prototype.visible=!1,xe.jsonID("cell",it);var Qw=class bC{constructor(t,n){this.anchor=t,this.head=n}map(t){return new bC(t.map(this.anchor),t.map(this.head))}resolve(t){const n=t.resolve(this.anchor),r=t.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&nm(n,r)?new it(n,r):xe.near(r,1)}};function Xw(e){if(!(e.selection instanceof it))return null;const t=[];return e.selection.forEachCell((n,r)=>{t.push(gt.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Me.create(e.doc,t)}function Zw({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let o=t.depth;o>=0&&!(t.before(o+1)>t.start(o));o--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function Jw({$from:e,$to:t}){let n,r;for(let i=e.depth;i>0;i--){const o=e.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=o;break}}for(let i=t.depth;i>0;i--){const o=t.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){r=o;break}}return n!==r&&t.parentOffset===0}function e2(e,t,n){const r=(t||e).selection,i=(t||e).doc;let o,a;if(r instanceof ge&&(a=r.node.type.spec.tableRole)){if(a=="cell"||a=="header_cell")o=it.create(i,r.from);else if(a=="row"){const s=i.resolve(r.from+1);o=it.rowSelection(s,s)}else if(!n){const s=Nt.get(r.node),l=r.from+1,c=l+s.map[s.width*s.height-1];o=it.create(i,l+1,c)}}else r instanceof ue&&Zw(r)?o=ue.create(i,r.from):r instanceof ue&&Jw(r)&&(o=ue.create(i,r.$from.start(),r.$from.end()));return o&&(t||(t=e.tr)).setSelection(o),t}var t2=new Fe("fix-tables");function a0(e,t,n,r){const i=e.childCount,o=t.childCount;e:for(let a=0,s=0;a<o;a++){const l=t.child(a);for(let c=s,d=Math.min(i,a+3);c<d;c++)if(e.child(c)==l){s=c+1,n+=l.nodeSize;continue e}r(l,n),s<i&&e.child(s).sameMarkup(l)?a0(e.child(s),l,n+1,r):l.nodesBetween(0,l.content.size,r,n+1),n+=l.nodeSize}}function s0(e,t){let n;const r=(i,o)=>{i.type.spec.tableRole=="table"&&(n=n2(e,i,o,n))};return t?t.doc!=e.doc&&a0(t.doc,e.doc,0,r):e.doc.descendants(r),n}function n2(e,t,n,r){const i=Nt.get(t);if(!i.problems)return r;r||(r=e.tr);const o=[];for(let l=0;l<i.height;l++)o.push(0);for(let l=0;l<i.problems.length;l++){const c=i.problems[l];if(c.type=="collision"){const d=t.nodeAt(c.pos);if(!d)continue;const u=d.attrs;for(let p=0;p<u.rowspan;p++)o[c.row+p]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,Ki(u,u.colspan-c.n,c.n))}else if(c.type=="missing")o[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=t.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=t.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const d=r.mapping.map(n);r.delete(d,d+t.nodeSize)}}let a,s;for(let l=0;l<o.length;l++)o[l]&&(a==null&&(a=l),s=l);for(let l=0,c=n+1;l<i.height;l++){const d=t.child(l),u=c+d.nodeSize,p=o[l];if(p>0){let m="cell";d.firstChild&&(m=d.firstChild.type.spec.tableRole);const _=[];for(let g=0;g<p;g++){const b=un(e.schema)[m].createAndFill();b&&_.push(b)}const h=(l==0||a==l-1)&&s==l?c+1:u-1;r.insert(r.mapping.map(h),_)}c=u}return r.setMeta(t2,{fixTables:!0})}function pr(e){const t=e.selection,n=Ql(e),r=n.node(-1),i=n.start(-1),o=Nt.get(r);return{...t instanceof it?o.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):o.findCell(n.pos-i),tableStart:i,map:o,table:r}}function l0(e,{map:t,tableStart:n,table:r},i){let o=i>0?-1:0;Kw(t,r,i+o)&&(o=i==0||i==t.width?null:0);for(let a=0;a<t.height;a++){const s=a*t.width+i;if(i>0&&i<t.width&&t.map[s-1]==t.map[s]){const l=t.map[s],c=r.nodeAt(l);e.setNodeMarkup(e.mapping.map(n+l),null,o0(c.attrs,i-t.colCount(l))),a+=c.attrs.rowspan-1}else{const l=o==null?un(r.type.schema).cell:r.nodeAt(t.map[s+o]).type,c=t.positionAt(a,i,r);e.insert(e.mapping.map(n+c),l.createAndFill())}}return e}function r2(e,t){if(!Jn(e))return!1;if(t){const n=pr(e);t(l0(e.tr,n,n.left))}return!0}function i2(e,t){if(!Jn(e))return!1;if(t){const n=pr(e);t(l0(e.tr,n,n.right))}return!0}function o2(e,{map:t,table:n,tableStart:r},i){const o=e.mapping.maps.length;for(let a=0;a<t.height;){const s=a*t.width+i,l=t.map[s],c=n.nodeAt(l),d=c.attrs;if(i>0&&t.map[s-1]==l||i<t.width-1&&t.map[s+1]==l)e.setNodeMarkup(e.mapping.slice(o).map(r+l),null,Ki(d,i-t.colCount(l)));else{const u=e.mapping.slice(o).map(r+l);e.delete(u,u+c.nodeSize)}a+=d.rowspan}}function a2(e,t){if(!Jn(e))return!1;if(t){const n=pr(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let i=n.right-1;o2(r,n,i),i!=n.left;i--){const o=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!o)throw RangeError("No table found");n.table=o,n.map=Nt.get(o)}t(r)}return!0}function s2(e,t,n){var r;const i=un(t.type.schema).header_cell;for(let o=0;o<e.width;o++)if(((r=t.nodeAt(e.map[o+n*e.width]))==null?void 0:r.type)!=i)return!1;return!0}function c0(e,{map:t,tableStart:n,table:r},i){var o;let a=n;for(let c=0;c<i;c++)a+=r.child(c).nodeSize;const s=[];let l=i>0?-1:0;s2(t,r,i+l)&&(l=i==0||i==t.height?null:0);for(let c=0,d=t.width*i;c<t.width;c++,d++)if(i>0&&i<t.height&&t.map[d]==t.map[d-t.width]){const u=t.map[d],p=r.nodeAt(u).attrs;e.setNodeMarkup(n+u,null,{...p,rowspan:p.rowspan+1}),c+=p.colspan-1}else{const u=l==null?un(r.type.schema).cell:(o=r.nodeAt(t.map[d+l*t.width]))==null?void 0:o.type,p=u?.createAndFill();p&&s.push(p)}return e.insert(a,un(r.type.schema).row.create(null,s)),e}function l2(e,t){if(!Jn(e))return!1;if(t){const n=pr(e);t(c0(e.tr,n,n.top))}return!0}function c2(e,t){if(!Jn(e))return!1;if(t){const n=pr(e);t(c0(e.tr,n,n.bottom))}return!0}function d2(e,{map:t,table:n,tableStart:r},i){let o=0;for(let c=0;c<i;c++)o+=n.child(c).nodeSize;const a=o+n.child(i).nodeSize,s=e.mapping.maps.length;e.delete(o+r,a+r);const l=new Set;for(let c=0,d=i*t.width;c<t.width;c++,d++){const u=t.map[d];if(!l.has(u)){if(l.add(u),i>0&&u==t.map[d-t.width]){const p=n.nodeAt(u).attrs;e.setNodeMarkup(e.mapping.slice(s).map(u+r),null,{...p,rowspan:p.rowspan-1}),c+=p.colspan-1}else if(i<t.height&&u==t.map[d+t.width]){const p=n.nodeAt(u),m=p.attrs,_=p.type.create({...m,rowspan:p.attrs.rowspan-1},p.content),h=t.positionAt(i+1,c,n);e.insert(e.mapping.slice(s).map(r+h),_),c+=m.colspan-1}}}}function u2(e,t){if(!Jn(e))return!1;if(t){const n=pr(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let i=n.bottom-1;d2(r,n,i),i!=n.top;i--){const o=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!o)throw RangeError("No table found");n.table=o,n.map=Nt.get(n.table)}t(r)}return!0}function d0(e){const t=e.content;return t.childCount==1&&t.child(0).isTextblock&&t.child(0).childCount==0}function p2({width:e,height:t,map:n},r){let i=r.top*e+r.left,o=i,a=(r.bottom-1)*e+r.left,s=i+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&n[o]==n[o-1]||r.right<e&&n[s]==n[s+1])return!0;o+=e,s+=e}for(let l=r.left;l<r.right;l++){if(r.top>0&&n[i]==n[i-e]||r.bottom<t&&n[a]==n[a+e])return!0;i++,a++}return!1}function u0(e,t){const n=e.selection;if(!(n instanceof it)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=pr(e),{map:i}=r;if(p2(i,r))return!1;if(t){const o=e.tr,a={};let s=j.empty,l,c;for(let d=r.top;d<r.bottom;d++)for(let u=r.left;u<r.right;u++){const p=i.map[d*i.width+u],m=r.table.nodeAt(p);if(!(a[p]||!m))if(a[p]=!0,l==null)l=p,c=m;else{d0(m)||(s=s.append(m.content));const _=o.mapping.map(p+r.tableStart);o.delete(_,_+m.nodeSize)}}if(l==null||c==null)return!0;if(o.setNodeMarkup(l+r.tableStart,null,{...o0(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),s.size){const d=l+1+c.content.size,u=d0(c)?l+1:d;o.replaceWith(u+r.tableStart,d+r.tableStart,s)}o.setSelection(new it(o.doc.resolve(l+r.tableStart))),t(o)}return!0}function p0(e,t){const n=un(e.schema);return m2(({node:r})=>n[r.type.spec.tableRole])(e,t)}function m2(e){return(t,n)=>{var r;const i=t.selection;let o,a;if(i instanceof it){if(i.$anchorCell.pos!=i.$headCell.pos)return!1;o=i.$anchorCell.nodeAfter,a=i.$anchorCell.pos}else{if(o=Ww(i.$from),!o)return!1;a=(r=Po(i.$from))==null?void 0:r.pos}if(o==null||a==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(n){let s=o.attrs;const l=[],c=s.colwidth;s.rowspan>1&&(s={...s,rowspan:1}),s.colspan>1&&(s={...s,colspan:1});const d=pr(t),u=t.tr;for(let m=0;m<d.right-d.left;m++)l.push(c?{...s,colwidth:c&&c[m]?[c[m]]:null}:s);let p;for(let m=d.top;m<d.bottom;m++){let _=d.map.positionAt(m,d.left,d.table);m==d.top&&(_+=o.nodeSize);for(let h=d.left,g=0;h<d.right;h++,g++)h==d.left&&m==d.top||u.insert(p=u.mapping.map(_+d.tableStart,1),e({node:o,row:m,col:h}).createAndFill(l[g]))}u.setNodeMarkup(a,e({node:o,row:d.top,col:d.left}),l[0]),i instanceof it&&u.setSelection(new it(u.doc.resolve(i.$anchorCell.pos),p?u.doc.resolve(p):void 0)),n(u)}return!0}}function f2(e,t){return function(n,r){if(!Jn(n))return!1;const i=Ql(n);if(i.nodeAfter.attrs[e]===t)return!1;if(r){const o=n.tr;n.selection instanceof it?n.selection.forEachCell((a,s)=>{a.attrs[e]!==t&&o.setNodeMarkup(s,null,{...a.attrs,[e]:t})}):o.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(o)}return!0}}function _2(e){return function(t,n){if(!Jn(t))return!1;if(n){const r=un(t.schema),i=pr(t),o=t.tr,a=i.map.cellsInRect(e=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=a.map(l=>i.table.nodeAt(l));for(let l=0;l<a.length;l++)s[l].type==r.header_cell&&o.setNodeMarkup(i.tableStart+a[l],r.cell,s[l].attrs);if(o.steps.length==0)for(let l=0;l<a.length;l++)o.setNodeMarkup(i.tableStart+a[l],r.header_cell,s[l].attrs);n(o)}return!0}}function m0(e,t,n){const r=t.map.cellsInRect({left:0,top:0,right:e=="row"?t.map.width:1,bottom:e=="column"?t.map.height:1});for(let i=0;i<r.length;i++){const o=t.table.nodeAt(r[i]);if(o&&o.type!==n.header_cell)return!1}return!0}function ts(e,t){return t=t||{useDeprecatedLogic:!1},t.useDeprecatedLogic?_2(e):function(n,r){if(!Jn(n))return!1;if(r){const i=un(n.schema),o=pr(n),a=n.tr,s=m0("row",o,i),l=m0("column",o,i),d=(e==="column"?s:e==="row"?l:!1)?1:0,u=e=="column"?{left:0,top:d,right:1,bottom:o.map.height}:e=="row"?{left:d,top:0,right:o.map.width,bottom:1}:o,p=e=="column"?l?i.cell:i.header_cell:e=="row"?s?i.cell:i.header_cell:i.cell;o.map.cellsInRect(u).forEach(m=>{const _=m+o.tableStart,h=a.doc.nodeAt(_);h&&a.setNodeMarkup(_,p,h.attrs)}),r(a)}return!0}}ts("row",{useDeprecatedLogic:!0}),ts("column",{useDeprecatedLogic:!0});var h2=ts("cell",{useDeprecatedLogic:!0});function g2(e,t){if(t<0){const n=e.nodeBefore;if(n)return e.pos-n.nodeSize;for(let r=e.index(-1)-1,i=e.before();r>=0;r--){const o=e.node(-1).child(r),a=o.lastChild;if(a)return i-1-a.nodeSize;i-=o.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;const n=e.node(-1);for(let r=e.indexAfter(-1),i=e.after();r<n.childCount;r++){const o=n.child(r);if(o.childCount)return i+1;i+=o.nodeSize}}return null}function f0(e){return function(t,n){if(!Jn(t))return!1;const r=g2(Ql(t),e);if(r==null)return!1;if(n){const i=t.doc.resolve(r);n(t.tr.setSelection(ue.between(i,qw(i))).scrollIntoView())}return!0}}function b2(e,t){const n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Xl(e,t){const n=e.selection;if(!(n instanceof it))return!1;if(t){const r=e.tr,i=un(e.schema).cell.createAndFill().content;n.forEachCell((o,a)=>{o.content.eq(i)||r.replace(r.mapping.map(a+1),r.mapping.map(a+o.nodeSize-1),new ne(i,0,0))}),r.docChanged&&t(r)}return!0}function E2(e){if(!e.size)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole=="table");)n--,r--,t=t.child(0).content;const i=t.child(0),o=i.type.spec.tableRole,a=i.type.schema,s=[];if(o=="row")for(let l=0;l<t.childCount;l++){let c=t.child(l).content;const d=l?0:Math.max(0,n-1),u=l<t.childCount-1?0:Math.max(0,r-1);(d||u)&&(c=rm(un(a).row,new ne(c,d,u)).content),s.push(c)}else if(o=="cell"||o=="header_cell")s.push(n||r?rm(un(a).row,new ne(t,n,r)).content:t);else return null;return S2(a,s)}function S2(e,t){const n=[];for(let i=0;i<t.length;i++){const o=t[i];for(let a=o.childCount-1;a>=0;a--){const{rowspan:s,colspan:l}=o.child(a).attrs;for(let c=i;c<i+s;c++)n[c]=(n[c]||0)+l}}let r=0;for(let i=0;i<n.length;i++)r=Math.max(r,n[i]);for(let i=0;i<n.length;i++)if(i>=t.length&&t.push(j.empty),n[i]<r){const o=un(e).cell.createAndFill(),a=[];for(let s=n[i];s<r;s++)a.push(o);t[i]=t[i].append(j.from(a))}return{height:t.length,width:r,rows:t}}function rm(e,t){const n=e.createAndFill();return new hu(n).replace(0,n.content.size,t).doc}function T2({width:e,height:t,rows:n},r,i){if(e!=r){const o=[],a=[];for(let s=0;s<n.length;s++){const l=n[s],c=[];for(let d=o[s]||0,u=0;d<r;u++){let p=l.child(u%l.childCount);d+p.attrs.colspan>r&&(p=p.type.createChecked(Ki(p.attrs,p.attrs.colspan,d+p.attrs.colspan-r),p.content)),c.push(p),d+=p.attrs.colspan;for(let m=1;m<p.attrs.rowspan;m++)o[s+m]=(o[s+m]||0)+p.attrs.colspan}a.push(j.from(c))}n=a,e=r}if(t!=i){const o=[];for(let a=0,s=0;a<i;a++,s++){const l=[],c=n[s%t];for(let d=0;d<c.childCount;d++){let u=c.child(d);a+u.attrs.rowspan>i&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,i-u.attrs.rowspan)},u.content)),l.push(u)}o.push(j.from(l))}n=o,t=i}return{width:e,height:t,rows:n}}function y2(e,t,n,r,i,o,a){const s=e.doc.type.schema,l=un(s);let c,d;if(i>t.width)for(let u=0,p=0;u<t.height;u++){const m=n.child(u);p+=m.nodeSize;const _=[];let h;m.lastChild==null||m.lastChild.type==l.cell?h=c||(c=l.cell.createAndFill()):h=d||(d=l.header_cell.createAndFill());for(let g=t.width;g<i;g++)_.push(h);e.insert(e.mapping.slice(a).map(p-1+r),_)}if(o>t.height){const u=[];for(let _=0,h=(t.height-1)*t.width;_<Math.max(t.width,i);_++){const g=_>=t.width?!1:n.nodeAt(t.map[h+_]).type==l.header_cell;u.push(g?d||(d=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}const p=l.row.create(null,j.from(u)),m=[];for(let _=t.height;_<o;_++)m.push(p);e.insert(e.mapping.slice(a).map(r+n.nodeSize-2),m)}return!!(c||d)}function _0(e,t,n,r,i,o,a,s){if(a==0||a==t.height)return!1;let l=!1;for(let c=i;c<o;c++){const d=a*t.width+c,u=t.map[d];if(t.map[d-t.width]==u){l=!0;const p=n.nodeAt(u),{top:m,left:_}=t.findCell(u);e.setNodeMarkup(e.mapping.slice(s).map(u+r),null,{...p.attrs,rowspan:a-m}),e.insert(e.mapping.slice(s).map(t.positionAt(a,_,n)),p.type.createAndFill({...p.attrs,rowspan:m+p.attrs.rowspan-a})),c+=p.attrs.colspan-1}}return l}function h0(e,t,n,r,i,o,a,s){if(a==0||a==t.width)return!1;let l=!1;for(let c=i;c<o;c++){const d=c*t.width+a,u=t.map[d];if(t.map[d-1]==u){l=!0;const p=n.nodeAt(u),m=t.colCount(u),_=e.mapping.slice(s).map(u+r);e.setNodeMarkup(_,null,Ki(p.attrs,a-m,p.attrs.colspan-(a-m))),e.insert(_+p.nodeSize,p.type.createAndFill(Ki(p.attrs,0,a-m))),c+=p.attrs.rowspan-1}}return l}function g0(e,t,n,r,i){let o=n?e.doc.nodeAt(n-1):e.doc;if(!o)throw new Error("No table found");let a=Nt.get(o);const{top:s,left:l}=r,c=l+i.width,d=s+i.height,u=e.tr;let p=0;function m(){if(o=n?u.doc.nodeAt(n-1):u.doc,!o)throw new Error("No table found");a=Nt.get(o),p=u.mapping.maps.length}y2(u,a,o,n,c,d,p)&&m(),_0(u,a,o,n,l,c,s,p)&&m(),_0(u,a,o,n,l,c,d,p)&&m(),h0(u,a,o,n,s,d,l,p)&&m(),h0(u,a,o,n,s,d,c,p)&&m();for(let _=s;_<d;_++){const h=a.positionAt(_,l,o),g=a.positionAt(_,c,o);u.replace(u.mapping.slice(p).map(h+n),u.mapping.slice(p).map(g+n),new ne(i.rows[_-s],0,0))}m(),u.setSelection(new it(u.doc.resolve(n+a.positionAt(s,l,o)),u.doc.resolve(n+a.positionAt(d-1,c-1,o)))),t(u)}var C2=Zu({ArrowLeft:Jl("horiz",-1),ArrowRight:Jl("horiz",1),ArrowUp:Jl("vert",-1),ArrowDown:Jl("vert",1),"Shift-ArrowLeft":ec("horiz",-1),"Shift-ArrowRight":ec("horiz",1),"Shift-ArrowUp":ec("vert",-1),"Shift-ArrowDown":ec("vert",1),Backspace:Xl,"Mod-Backspace":Xl,Delete:Xl,"Mod-Delete":Xl});function Zl(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function Jl(e,t){return(n,r,i)=>{if(!i)return!1;const o=n.selection;if(o instanceof it)return Zl(n,r,xe.near(o.$headCell,t));if(e!="horiz"&&!o.empty)return!1;const a=b0(i,e,t);if(a==null)return!1;if(e=="horiz")return Zl(n,r,xe.near(n.doc.resolve(o.head+t),t));{const s=n.doc.resolve(a),l=i0(s,e,t);let c;return l?c=xe.near(l,1):t<0?c=xe.near(n.doc.resolve(s.before(-1)),-1):c=xe.near(n.doc.resolve(s.after(-1)),1),Zl(n,r,c)}}}function ec(e,t){return(n,r,i)=>{if(!i)return!1;const o=n.selection;let a;if(o instanceof it)a=o;else{const l=b0(i,e,t);if(l==null)return!1;a=new it(n.doc.resolve(l))}const s=i0(a.$headCell,e,t);return s?Zl(n,r,new it(a.$anchorCell,s)):!1}}function v2(e,t){const n=e.state.doc,r=Po(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new it(r))),!0):!1}function x2(e,t,n){if(!Jn(e.state))return!1;let r=E2(n);const i=e.state.selection;if(i instanceof it){r||(r={width:1,height:1,rows:[j.from(rm(un(e.state.schema).cell,n))]});const o=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),s=Nt.get(o).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=T2(r,s.right-s.left,s.bottom-s.top),g0(e.state,e.dispatch,a,s,r),!0}else if(r){const o=Ql(e.state),a=o.start(-1);return g0(e.state,e.dispatch,a,Nt.get(o.node(-1)).findCell(o.pos-a),r),!0}else return!1}function N2(e,t){var n;if(t.ctrlKey||t.metaKey)return;const r=E0(e,t.target);let i;if(t.shiftKey&&e.state.selection instanceof it)o(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&r&&(i=Po(e.state.selection.$anchor))!=null&&((n=im(e,t))==null?void 0:n.pos)!=i.pos)o(i,t),t.preventDefault();else if(!r)return;function o(l,c){let d=im(e,c);const u=fi.getState(e.state)==null;if(!d||!nm(l,d))if(u)d=l;else return;const p=new it(l,d);if(u||!e.state.selection.eq(p)){const m=e.state.tr.setSelection(p);u&&m.setMeta(fi,l.pos),e.dispatch(m)}}function a(){e.root.removeEventListener("mouseup",a),e.root.removeEventListener("dragstart",a),e.root.removeEventListener("mousemove",s),fi.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(fi,-1))}function s(l){const c=l,d=fi.getState(e.state);let u;if(d!=null)u=e.state.doc.resolve(d);else if(E0(e,c.target)!=r&&(u=im(e,t),!u))return a();u&&o(u,c)}e.root.addEventListener("mouseup",a),e.root.addEventListener("dragstart",a),e.root.addEventListener("mousemove",s)}function b0(e,t,n){if(!(e.state.selection instanceof ue))return null;const{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){const o=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const s=r.before(i),l=t=="vert"?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(l)?s:null}}return null}function E0(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName=="TD"||t.nodeName=="TH")return t;return null}function im(e,t){const n=e.posAtCoords({left:t.clientX,top:t.clientY});return n&&n?Po(e.state.doc.resolve(n.pos)):null}var R2=class{constructor(t,n){this.node=t,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),om(t,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!=this.node.type?!1:(this.node=t,om(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function om(e,t,n,r,i,o){var a;let s=0,l=!0,c=t.firstChild;const d=e.firstChild;if(d){for(let u=0,p=0;u<d.childCount;u++){const{colspan:m,colwidth:_}=d.child(u).attrs;for(let h=0;h<m;h++,p++){const g=i==p?o:_&&_[h],b=g?g+"px":"";if(s+=g||r,g||(l=!1),c)c.style.width!=b&&(c.style.width=b),c=c.nextSibling;else{const E=document.createElement("col");E.style.width=b,t.appendChild(E)}}}for(;c;){const u=c.nextSibling;(a=c.parentNode)==null||a.removeChild(c),c=u}l?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}var On=new Fe("tableColumnResizing");function A2({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=R2,lastColumnResizable:i=!0}={}){const o=new Ie({key:On,state:{init(a,s){var l,c;const d=(c=(l=o.spec)==null?void 0:l.props)==null?void 0:c.nodeViews,u=un(s.schema).table.name;return r&&d&&(d[u]=(p,m)=>new r(p,n,m)),new O2(-1,!1)},apply(a,s){return s.apply(a)}},props:{attributes:a=>{const s=On.getState(a);return s&&s.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(a,s)=>{I2(a,s,e,i)},mouseleave:a=>{k2(a)},mousedown:(a,s)=>{w2(a,s,t,n)}},decorations:a=>{const s=On.getState(a);if(s&&s.activeHandle>-1)return B2(a,s.activeHandle)},nodeViews:{}}});return o}var O2=class Jd{constructor(t,n){this.activeHandle=t,this.dragging=n}apply(t){const n=this,r=t.getMeta(On);if(r&&r.setHandle!=null)return new Jd(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Jd(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let i=t.mapping.map(n.activeHandle,-1);return tm(t.doc.resolve(i))||(i=-1),new Jd(i,n.dragging)}return n}};function I2(e,t,n,r){if(!e.editable)return;const i=On.getState(e.state);if(i&&!i.dragging){const o=D2(t.target);let a=-1;if(o){const{left:s,right:l}=o.getBoundingClientRect();t.clientX-s<=n?a=S0(e,t,"left",n):l-t.clientX<=n&&(a=S0(e,t,"right",n))}if(a!=i.activeHandle){if(!r&&a!==-1){const s=e.state.doc.resolve(a),l=s.node(-1),c=Nt.get(l),d=s.start(-1);if(c.colCount(s.pos-d)+s.nodeAfter.attrs.colspan-1==c.width-1)return}y0(e,a)}}}function k2(e){if(!e.editable)return;const t=On.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&y0(e,-1)}function w2(e,t,n,r){var i;if(!e.editable)return!1;const o=(i=e.dom.ownerDocument.defaultView)!=null?i:window,a=On.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;const s=e.state.doc.nodeAt(a.activeHandle),l=M2(e,a.activeHandle,s.attrs);e.dispatch(e.state.tr.setMeta(On,{setDragging:{startX:t.clientX,startWidth:l}}));function c(u){o.removeEventListener("mouseup",c),o.removeEventListener("mousemove",d);const p=On.getState(e.state);p?.dragging&&(L2(e,p.activeHandle,T0(p.dragging,u,n)),e.dispatch(e.state.tr.setMeta(On,{setDragging:null})))}function d(u){if(!u.which)return c(u);const p=On.getState(e.state);if(p&&p.dragging){const m=T0(p.dragging,u,n);C0(e,p.activeHandle,m,r)}}return C0(e,a.activeHandle,l,r),o.addEventListener("mouseup",c),o.addEventListener("mousemove",d),t.preventDefault(),!0}function M2(e,t,{colspan:n,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const o=e.domAtPos(t);let s=o.node.childNodes[o.offset].offsetWidth,l=n;if(r)for(let c=0;c<n;c++)r[c]&&(s-=r[c],l--);return s/l}function D2(e){for(;e&&e.nodeName!="TD"&&e.nodeName!="TH";)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}function S0(e,t,n,r){const i=n=="right"?-r:r,o=e.posAtCoords({left:t.clientX+i,top:t.clientY});if(!o)return-1;const{pos:a}=o,s=Po(e.state.doc.resolve(a));if(!s)return-1;if(n=="right")return s.pos;const l=Nt.get(s.node(-1)),c=s.start(-1),d=l.map.indexOf(s.pos-c);return d%l.width==0?-1:c+l.map[d-1]}function T0(e,t,n){const r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function y0(e,t){e.dispatch(e.state.tr.setMeta(On,{setHandle:t}))}function L2(e,t,n){const r=e.state.doc.resolve(t),i=r.node(-1),o=Nt.get(i),a=r.start(-1),s=o.colCount(r.pos-a)+r.nodeAfter.attrs.colspan-1,l=e.state.tr;for(let c=0;c<o.height;c++){const d=c*o.width+s;if(c&&o.map[d]==o.map[d-o.width])continue;const u=o.map[d],p=i.nodeAt(u).attrs,m=p.colspan==1?0:s-o.colCount(u);if(p.colwidth&&p.colwidth[m]==n)continue;const _=p.colwidth?p.colwidth.slice():P2(p.colspan);_[m]=n,l.setNodeMarkup(a+u,null,{...p,colwidth:_})}l.docChanged&&e.dispatch(l)}function C0(e,t,n,r){const i=e.state.doc.resolve(t),o=i.node(-1),a=i.start(-1),s=Nt.get(o).colCount(i.pos-a)+i.nodeAfter.attrs.colspan-1;let l=e.domAtPos(i.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&om(o,l.firstChild,l,r,s,n)}function P2(e){return Array(e).fill(0)}function B2(e,t){var n;const r=[],i=e.doc.resolve(t),o=i.node(-1);if(!o)return Me.empty;const a=Nt.get(o),s=i.start(-1),l=a.colCount(i.pos-s)+i.nodeAfter.attrs.colspan-1;for(let c=0;c<a.height;c++){const d=l+c*a.width;if((l==a.width-1||a.map[d]!=a.map[d+1])&&(c==0||a.map[d]!=a.map[d-a.width])){const u=a.map[d],p=s+u+o.nodeAt(u).nodeSize-1,m=document.createElement("div");m.className="column-resize-handle",(n=On.getState(e))!=null&&n.dragging&&r.push(gt.node(s+u,s+u+o.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),r.push(gt.widget(p,m))}}return Me.create(e.doc,r)}function F2({allowTableNodeSelection:e=!1}={}){return new Ie({key:fi,state:{init(){return null},apply(t,n){const r=t.getMeta(fi);if(r!=null)return r==-1?null:r;if(n==null||!t.docChanged)return n;const{deleted:i,pos:o}=t.mapping.mapResult(n);return i?null:o}},props:{decorations:Xw,handleDOMEvents:{mousedown:N2},createSelectionBetween(t){return fi.getState(t.state)!=null?t.state.selection:null},handleTripleClick:v2,handleKeyDown:C2,handlePaste:x2},appendTransaction(t,n,r){return e2(r,s0(r,n),e)}})}var v0=bt.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{var t,n;const r=e.getAttribute("colwidth"),i=r?r.split(",").map(o=>parseInt(o,10)):null;if(!i){const o=(t=e.closest("table"))==null?void 0:t.querySelectorAll("colgroup > col"),a=Array.from(((n=e.parentElement)==null?void 0:n.children)||[]).indexOf(e);if(a&&a>-1&&o&&o[a]){const s=o[a].getAttribute("width");return s?[parseInt(s,10)]:null}}return i}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:e}){return["td",Pe(this.options.HTMLAttributes,e),0]}}),x0=bt.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:e}){return["th",Pe(this.options.HTMLAttributes,e),0]}}),N0=bt.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:e}){return["tr",Pe(this.options.HTMLAttributes,e),0]}});function am(e,t){return t?["width",`${Math.max(t,e)}px`]:["min-width",`${e}px`]}function R0(e,t,n,r,i,o){var a;let s=0,l=!0,c=t.firstChild;const d=e.firstChild;if(d!==null)for(let u=0,p=0;u<d.childCount;u+=1){const{colspan:m,colwidth:_}=d.child(u).attrs;for(let h=0;h<m;h+=1,p+=1){const g=i===p?o:_&&_[h],b=g?`${g}px`:"";if(s+=g||r,g||(l=!1),c){if(c.style.width!==b){const[E,S]=am(r,g);c.style.setProperty(E,S)}c=c.nextSibling}else{const E=document.createElement("col"),[S,y]=am(r,g);E.style.setProperty(S,y),t.appendChild(E)}}}for(;c;){const u=c.nextSibling;(a=c.parentNode)==null||a.removeChild(c),c=u}l?(n.style.width=`${s}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${s}px`)}var U2=class{constructor(e,t){this.node=e,this.cellMinWidth=t,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")),R0(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,R0(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){const t=e.target,n=this.dom.contains(t),r=this.contentDOM.contains(t);return!!(n&&!r&&(e.type==="attributes"||e.type==="childList"||e.type==="characterData"))}};function z2(e,t,n,r){let i=0,o=!0;const a=[],s=e.firstChild;if(!s)return{};for(let u=0,p=0;u<s.childCount;u+=1){const{colspan:m,colwidth:_}=s.child(u).attrs;for(let h=0;h<m;h+=1,p+=1){const g=n===p?r:_&&_[h];i+=g||t,g||(o=!1);const[b,E]=am(t,g);a.push(["col",{style:`${b}: ${E}`}])}}const l=o?`${i}px`:"",c=o?"":`${i}px`;return{colgroup:["colgroup",{},...a],tableWidth:l,tableMinWidth:c}}function A0(e,t){return e.createAndFill()}function H2(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;const t={};return Object.keys(e.nodes).forEach(n=>{const r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function G2(e,t,n,r,i){const o=H2(e),a=[],s=[];for(let c=0;c<n;c+=1){const d=A0(o.cell);if(d&&s.push(d),r){const u=A0(o.header_cell);u&&a.push(u)}}const l=[];for(let c=0;c<t;c+=1)l.push(o.row.createChecked(null,r&&c===0?a:s));return o.table.createChecked(null,l)}function V2(e){return e instanceof it}var tc=({editor:e})=>{const{selection:t}=e.state;if(!V2(t))return!1;let n=0;const r=Xg(t.ranges[0].$from,o=>o.type.name==="table");return r?.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(n+=1)}),n===t.ranges.length?(e.commands.deleteTable(),!0):!1},O0=bt.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:U2,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:e,HTMLAttributes:t}){const{colgroup:n,tableWidth:r,tableMinWidth:i}=z2(e,this.options.cellMinWidth);return["table",Pe(this.options.HTMLAttributes,t,{style:r?`width: ${r}`:`min-width: ${i}`}),n,["tbody",0]]},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:o})=>{const a=G2(o.schema,e,t,n);if(i){const s=r.selection.from+1;r.replaceSelectionWith(a).scrollIntoView().setSelection(ue.near(r.doc.resolve(s)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>r2(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>i2(e,t),deleteColumn:()=>({state:e,dispatch:t})=>a2(e,t),addRowBefore:()=>({state:e,dispatch:t})=>l2(e,t),addRowAfter:()=>({state:e,dispatch:t})=>c2(e,t),deleteRow:()=>({state:e,dispatch:t})=>u2(e,t),deleteTable:()=>({state:e,dispatch:t})=>b2(e,t),mergeCells:()=>({state:e,dispatch:t})=>u0(e,t),splitCell:()=>({state:e,dispatch:t})=>p0(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>ts("column")(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>ts("row")(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>h2(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>u0(e,t)?!0:p0(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>f2(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>f0(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>f0(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&s0(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){const r=it.create(t.doc,e.anchorCell,e.headCell);t.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:tc,"Mod-Backspace":tc,Delete:tc,"Mod-Delete":tc}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[A2({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],F2({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(e){const t={name:e.name,options:e.options,storage:e.storage};return{tableRole:Qe(Ee(e,"tableRole",t))}}});Re.create({name:"tableKit",addExtensions(){const e=[];return this.options.table!==!1&&e.push(O0.configure(this.options.table)),this.options.tableCell!==!1&&e.push(v0.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(x0.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(N0.configure(this.options.tableRow)),e}});const ut={USER_INSERTION:"userInsertion",USER_DELETION:"userDeletion",AI_INSERTION:"aiInsertion",AI_DELETION:"aiDeletion"},I0="redlineHandledTextInput",ns="skipRedlineInsertionTracking";function sm(e,t,n){let r=!1;return e.doc.nodesBetween(t,n,i=>{if(i.marks.some(o=>o.type.name===ut.USER_INSERTION||o.type.name===ut.AI_INSERTION))return r=!0,!1}),r}function lm(e,t,n){let r=!1;return e.doc.nodesBetween(t,n,i=>{const o=i.marks.find(a=>a.type.name===ut.USER_INSERTION||a.type.name===ut.AI_INSERTION);if(o)return r=!!o.attrs.formatChanges,!1}),r}function nc(e,t,n){let r=!1;return e.doc.nodesBetween(Math.max(0,t-1),Math.min(e.doc.content.size,n+1),(i,o)=>{if(i.type.name==="codeBlock"){const a=o,s=o+i.nodeSize;if(t>=a&&n<=s)return r=!0,!1}}),r}function Y2(e,t,n){let r=!1;return e.doc.nodesBetween(t,n,i=>{if(i.marks.some(o=>o.type.name===ut.USER_DELETION||o.type.name===ut.AI_DELETION))return r=!0,!1}),r}function Bo(e,t,n,r,i,o=!1,a){const s=[],l=[];e.doc.descendants((u,p)=>{if(!u.isText)return;const m=u.marks.find(_=>_.type.name===r&&_.attrs.userId===i);if(m){if(o&&m.attrs.formatChanges)return;const _=p,h=p+u.nodeSize,g=t-h,b=_-n,E=g>=0&&g<=4,S=b>=0&&b<=4;(E||S)&&(l.push({from:_,to:h,timestamp:m.attrs.timestamp,isAdjacent:!0}),s.push(m.attrs.timestamp))}});const c=[],d=l.map(({from:u,to:p})=>({from:u,to:p})).sort((u,p)=>u.from-p.from||u.to-p.to);for(const u of d){const p=c[c.length-1];if(!p){c.push({...u});continue}if(u.from<=p.to){p.to=Math.max(p.to,u.to);continue}c.push({...u})}return{timestamp:s.length>0?s.sort()[0]:new Date().toISOString(),adjacentRanges:c}}function rs(e,t,n){const r=t==="ai"?n==="insertion"?ut.AI_INSERTION:ut.AI_DELETION:n==="insertion"?ut.USER_INSERTION:ut.USER_DELETION;return e.schema.marks[r]||null}const $2=Re.create({name:"redlinePlugin",addOptions(){return{isActive:!1,mode:"user",currentEntity:{id:"anonymous",name:"Anonymous"}}},addStorage(){return{isActive:this.options.isActive,mode:this.options.mode}},addCommands(){return{toggleRedlineMode:(e,t="user")=>({editor:n})=>{const r=n.storage.redline;return r.isActive=e,r.mode=t,!0}}},addProseMirrorPlugins(){const e=this.options,t=()=>this.editor?.storage?.redline||{isActive:this.options.isActive,mode:this.options.mode};return[Gg({Backspace:(n,r)=>{const i=t();if(!i?.isActive)return!1;const{$from:o,$to:a}=n.selection,s=n.selection.empty?o.pos-1:o.pos,l=a.pos;if(s<0||!n.doc.textBetween(s,l)||nc(n,s,l)||sm(n,s,l)&&!lm(n,s,l))return!1;if(!r)return!0;const d=i.mode||"user",{id:u,name:p}=e.currentEntity,m=rs(n,d,"deletion");if(!m)return!1;const _=d==="ai"?ut.AI_DELETION:ut.USER_DELETION,{timestamp:h,adjacentRanges:g}=Bo(n,s,l,_,u),b=n.tr,E=d==="ai"?n.schema.marks[ut.AI_INSERTION]:n.schema.marks[ut.USER_INSERTION];if(E){const S=[];n.doc.nodesBetween(Math.max(0,s-100),Math.min(n.doc.content.size,l+100),(x,v)=>{const C=x.marks.find(O=>O.type===E&&O.attrs.formatChanges);if(C&&x.text){const O=v,w=v+x.text.length;O<l&&w>s&&S.push({from:O,to:w,mark:C})}});const y=[];let T=0;for(;T<S.length;){const x=S[T],v=x.from;let C=x.to,O=T+1;for(;O<S.length&&S[O].from===C&&S[O].mark.attrs.formatChanges===x.mark.attrs.formatChanges&&S[O].mark.attrs.timestamp===x.mark.attrs.timestamp;)C=S[O].to,O++;y.push({from:v,to:C,mark:x.mark}),T=O}y.forEach(({from:x,to:v,mark:C})=>{const O=x<s,w=v>l;O||w?(b.removeMark(x,v,E),O&&b.addMark(x,s,E.create(C.attrs)),w&&b.addMark(l,v,E.create({...C.attrs,timestamp:new Date().toISOString()}))):b.removeMark(x,v,E)})}for(const S of g)b.removeMark(S.from,S.to,m),b.addMark(S.from,S.to,m.create({userId:u,userName:p,timestamp:h,source:d}));return b.addMark(s,l,m.create({userId:u,userName:p,timestamp:h,source:d})),b.setSelection(ue.create(b.doc,s)),r(b),!0},Delete:(n,r)=>{const i=t();if(!i?.isActive)return!1;const{$from:o,$to:a}=n.selection,s=o.pos,l=n.selection.empty?a.pos+1:a.pos;if(l>n.doc.content.size||!n.doc.textBetween(s,l)||nc(n,s,l)||sm(n,s,l)&&!lm(n,s,l))return!1;if(!r)return!0;const d=i.mode||"user",{id:u,name:p}=e.currentEntity,m=rs(n,d,"deletion");if(!m)return!1;const _=d==="ai"?ut.AI_DELETION:ut.USER_DELETION,{timestamp:h,adjacentRanges:g}=Bo(n,s,l,_,u),b=n.tr,E=d==="ai"?n.schema.marks[ut.AI_INSERTION]:n.schema.marks[ut.USER_INSERTION];if(E){const S=[];n.doc.nodesBetween(Math.max(0,s-100),Math.min(n.doc.content.size,l+100),(x,v)=>{const C=x.marks.find(O=>O.type===E&&O.attrs.formatChanges);if(C&&x.text){const O=v,w=v+x.text.length;O<l&&w>s&&S.push({from:O,to:w,mark:C})}});const y=[];let T=0;for(;T<S.length;){const x=S[T],v=x.from;let C=x.to,O=T+1;for(;O<S.length&&S[O].from===C&&S[O].mark.attrs.formatChanges===x.mark.attrs.formatChanges&&S[O].mark.attrs.timestamp===x.mark.attrs.timestamp;)C=S[O].to,O++;y.push({from:v,to:C,mark:x.mark}),T=O}y.forEach(({from:x,to:v,mark:C})=>{const O=x<s,w=v>l;O||w?(b.removeMark(x,v,E),O&&b.addMark(x,s,E.create(C.attrs)),w&&b.addMark(l,v,E.create({...C.attrs,timestamp:new Date().toISOString()}))):b.removeMark(x,v,E)})}for(const S of g)b.removeMark(S.from,S.to,m),b.addMark(S.from,S.to,m.create({userId:u,userName:p,timestamp:h,source:d}));return b.addMark(s,l,m.create({userId:u,userName:p,timestamp:h,source:d})),r(b),!0}}),new Ie({props:{handleTextInput:(n,r,i,o)=>{const a=t();if(!a?.isActive||r>=i||!o)return!1;const s=n.state;if(nc(s,r,i))return!1;const l=a.mode||"user",{id:c,name:d}=e.currentEntity,u=rs(s,l,"insertion"),p=rs(s,l,"deletion");if(!u||!p)return!1;const m=l==="ai"?ut.AI_INSERTION:ut.USER_INSERTION,_=l==="ai"?ut.AI_DELETION:ut.USER_DELETION,h=s.tr.setMeta(I0,!0);if(sm(s,r,i)&&!lm(s,r,i)){const{timestamp:T,adjacentRanges:x}=Bo(s,r,i,m,c,!0);for(const v of x)h.removeMark(v.from,v.to,u),h.addMark(v.from,v.to,u.create({userId:c,userName:d,timestamp:T,source:l}));return h.insertText(o,r,i),h.addMark(r,r+o.length,u.create({userId:c,userName:d,timestamp:T,source:l})),h.setSelection(ue.create(h.doc,r+o.length)),n.dispatch(h),!0}const{timestamp:g,adjacentRanges:b}=Bo(s,r,i,_,c);for(const T of b)h.removeMark(T.from,T.to,p),h.addMark(T.from,T.to,p.create({userId:c,userName:d,timestamp:g,source:l}));h.addMark(r,i,p.create({userId:c,userName:d,timestamp:g,source:l}));const E=i,{timestamp:S,adjacentRanges:y}=Bo(s,E,E,m,c,!0);for(const T of y)h.removeMark(T.from,T.to,u),h.addMark(T.from,T.to,u.create({userId:c,userName:d,timestamp:S,source:l}));return h.insertText(o,E),h.addMark(E,E+o.length,u.create({userId:c,userName:d,timestamp:S,source:l})),h.setSelection(ue.create(h.doc,E+o.length)),n.dispatch(h),!0}}}),new Ie({appendTransaction:(n,r,i)=>{if(n.some(p=>p.getMeta(I0))||n.some(p=>p.getMeta(ns)))return null;const o=t();if(!o?.isActive)return null;const{id:a,name:s}=this.options.currentEntity,l=o.mode||"user",c=rs(i,l,"insertion");if(!c)return null;const d=i.tr;let u=!1;return n.forEach(p=>{p.mapping.maps.forEach(m=>{m.forEach((_,h,g,b)=>{if(_===h&&g<b){if(nc(i,g,b))return;if(Y2(i,g,b)){const T=l==="ai"?ut.AI_DELETION:ut.USER_DELETION,x=i.schema.marks[T];x&&(d.removeMark(g,b,x),u=!0)}const E=l==="ai"?ut.AI_INSERTION:ut.USER_INSERTION,{timestamp:S,adjacentRanges:y}=Bo(i,g,b,E,a,!0);for(const T of y)d.removeMark(T.from,T.to,c),d.addMark(T.from,T.to,c.create({userId:a,userName:s,timestamp:S,source:l}));d.addMark(g,b,c.create({userId:a,userName:s,timestamp:S,source:l})),u=!0}})})}),u?d:null}})]}}),Fo="data-redline-row-action",Lt="data-redline-column-action",pn="data-redline-column-id",k0=e=>!!(e&&e.type.name==="table"&&(e.attrs[ye]===cn||e.attrs[ye]===dn)),Uo="__%__",W2=O0.extend({addCommands(){return{...this.parent?.(),insertTableFromData:({tableType:e,data:t,columns:n,options:r={}})=>({state:i,tr:o,editor:a})=>{if(!t||t.length===0)return!1;const{withHeaderRow:s=!0,tableName:l=null}=r,{schema:c}=i,d=c.nodes.table,u=c.nodes.tableRow,p=c.nodes.tableCell,m=c.nodes.tableHeader,_=c.nodes.paragraph;if(!d||!u||!p||!_)return!1;const h=[];if(s&&m){const y=n.map(T=>{const x=c.text(T.label),v=_.create(null,x);return m.create({[Mo]:T.key},v)});h.push(u.create({[wo]:`header${Uo}row`},y))}t.forEach(y=>{const T=n.map(x=>{const v=String(y[x.label]??""),C=v?c.text(v):null,O=_.create(null,C);return p.create({[Yi]:`${y.__id}${Uo}${x.key}`},O)});h.push(u.create({[wo]:y.__id},T))});const g=a.storage?.redline,b={isVariableTable:!0,[Ya]:e,[jb]:l??""};if(g?.isActive){const T=a.extensionManager.extensions.find(v=>v.name==="redline")?.options?.currentEntity||{id:"unknown",name:"User"},x=g.mode==="ai"?dn:cn;Object.assign(b,{[ye]:x,[Ve]:T.id,[je]:T.name,[Ye]:new Date().toISOString()})}const E=d.create(b,h),{from:S}=i.selection;return o.insert(S,E),o.setMeta(ns,!0),!0},insertColumnsFromAgreement:({colIndex:e,tableId:t,columns:n,variableTableData:r})=>({state:i,tr:o,dispatch:a})=>{if(!a||!n||n.length===0)return!1;const{schema:s}=i,l=s.nodes.tableCell,c=s.nodes.tableHeader,d=s.nodes.paragraph;if(!l||!d)return!1;let u=-1,p=null,m="";i.doc.descendants((v,C)=>u!==-1?!1:v.type.name==="table"&&v.attrs[Hn]===t?(u=C,p=v,m=v.attrs[Ya]??"",!1):!0);const _=new Map;if(r&&m&&r[m]&&r[m].forEach(v=>{const C=v.__id;C&&_.set(C,v)}),u===-1||!p)return!1;const h=this.editor.storage?.redline,b=this.editor.extensionManager.extensions.find(v=>v.name==="redline")?.options?.currentEntity||{id:"unknown",name:"User"},E=h?.isActive?h.mode==="ai"?dn:cn:null,S=E&&!k0(p),y=new Date().toISOString(),T=n.map((v,C)=>`${v.key||"column"}-${Date.now()}-${C}-${Math.random().toString(36).slice(2,7)}`),x=[];p.forEach((v,C)=>{v.type.name==="tableRow"&&x.push({rowPos:u+1+C,rowNode:v})});for(let v=x.length-1;v>=0;v--){const{rowPos:C,rowNode:O}=x[v],w=O.child(0)?.type.name==="tableHeader";let z=C+1,N=0,P=0;O.forEach((R,k)=>{P===e&&(z=C+1+k),P<=e&&(N=k+R.nodeSize),P++}),e>=O.childCount&&(z=C+1+N),n.map((R,k)=>{const M=S?{[ye]:E,[Ve]:b.id,[je]:b.name,[Ye]:y,[Lt]:"add",[pn]:T[k]}:{};if(w&&c){const V=s.text(R.label),q=d.create(null,V);return c.create({[Mo]:R.key,...M},q)}const B=O.attrs[wo]??"",D=_.has(B)?String(_.get(B)[R.key]??""):"",U=D?s.text(D):null,H=d.create(null,U);return l.create({[Yi]:`${B}${Uo}${R.key}`,...M},H)}).reverse().forEach(R=>{o.insert(z,R)})}return o.setMeta(ns,!0),o.setMeta("addToHistory",!0),a(o),!0},insertRowsFromAgreement:({rowIndex:e,tableId:t,rowIds:n,variableTableData:r})=>({state:i,tr:o,dispatch:a,editor:s})=>{if(!a||!n||n.length===0)return!1;const{schema:l}=i,c=l.nodes.tableCell,d=l.nodes.tableRow,u=l.nodes.paragraph;if(!c||!d||!u)return!1;let p=-1,m=null,_="";if(i.doc.descendants((I,R)=>p!==-1?!1:I.type.name==="table"&&I.attrs[Hn]===t?(p=R,m=I,_=I.attrs[Ya]??"",!1):!0),p===-1||!m)return!1;const h=[],g=m.child(0);if(g&&g.type.name==="tableRow"&&g.forEach(I=>{if(I.type.name==="tableHeader"){const R=I.attrs[Mo];R&&h.push(R)}}),h.length===0)return!1;const b=new Map;(r?.[_]??[]).forEach(I=>{const R=String(I.__id??"");R&&b.set(R,I)});let S=0,y=0,T=0;m.forEach((I,R)=>{if(I.child(0)?.type.name==="tableHeader"){T=I.nodeSize;return}y<e&&(S=R+I.nodeSize,y++)});const x=p+1+(e===0?T:S),v=s.storage?.redline,O=s.extensionManager.extensions.find(I=>I.name==="redline")?.options?.currentEntity||{id:"unknown",name:"User"},w=v?.isActive?v.mode==="ai"?dn:cn:null,z=new Date().toISOString(),N=w&&!k0(m),P=[];for(const I of n){const R=b.get(I)??{},k=h.map(M=>{const B=String(R[M]??"").trim(),D=B.length>0?l.text(B):null,U=u.create(null,D);return c.create({[Yi]:`${I}${Uo}${M}`},U)});P.push(d.create({[wo]:I,...N?{[ye]:w,[Ve]:O.id,[je]:O.name,[Ye]:z,[Fo]:"add"}:{}},k))}for(let I=P.length-1;I>=0;I--)o.insert(x,P[I]);return o.setMeta("addToHistory",!0),a(o),!0},updateTableValues:e=>({state:t,tr:n,dispatch:r})=>{if(!r)return!1;const i=[];t.doc.descendants((a,s)=>a.type.name==="table"?(i.push({pos:s,node:a}),!1):!0);let o=!1;for(let a=i.length-1;a>=0;a--){const{pos:s,node:l}=i[a],c=l.attrs[Ya];if(!c)continue;const d=e[c];if(!d||d.length===0)continue;const u=new Map;d.forEach(_=>{const h=String(_.__id??"");h&&u.set(h,_)});const p=[];let m=1;l.forEach(_=>{if(_.type.name==="tableRow"){const h=_.attrs[wo];let g=1;_.forEach(b=>{if(b.type.name==="tableCell"){const E=b.attrs[Yi];if(E&&h&&u.has(h)){const S=E.indexOf(Uo);if(S!==-1){const y=E.slice(S+Uo.length);p.push({absPos:s+m+g,colKey:y,rowId:h})}}}g+=b.nodeSize})}m+=_.nodeSize}),p.sort((_,h)=>h.absPos-_.absPos);for(const{absPos:_,colKey:h,rowId:g}of p){const b=u.get(g);if(!b||!(h in b))continue;const E=String(b[h]??"").trim(),S=t.doc.nodeAt(_);if(!S||!S.firstChild||S.firstChild.textContent.trim()===E)continue;const x=n.mapping.map(_)+1,v=S.firstChild,C=E.length>0?t.schema.text(E):null,O=t.schema.nodes.paragraph.create(null,C);n.replaceWith(x,x+v.nodeSize,O),o=!0}}return o&&(n.setMeta("addToHistory",!1),r(n)),!0}}},addProseMirrorPlugins(){const e=new Fe("variableTableEditable"),t=new Fe("variableTableId"),n=(typeof this.parent=="function"?this.parent():[])||[],r=i=>{for(let o=i.depth;o>0;o--){const a=i.node(o);if(a.type.name==="tableCell"&&a.attrs[Yi]||a.type.name==="tableHeader"&&a.attrs[Mo])return!0}return!1};return[...n,new Ie({key:t,appendTransaction(i,o,a){if(i.some(c=>c.getMeta(t))||!i.some(c=>c.docChanged))return null;const s=[];if(a.doc.descendants((c,d)=>c.type.name!=="table"?!0:(c.attrs[Hn]||s.push({pos:d,node:c}),!1)),s.length===0)return null;const l=a.tr;for(let c=s.length-1;c>=0;c--){const{pos:d,node:u}=s[c],p=typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`table-${Date.now()}-${Math.random().toString(36).slice(2,9)}`;l.setNodeMarkup(d,void 0,{...u.attrs,[Hn]:p})}return l.setMeta(t,!0),l.setMeta("addToHistory",!1),l}}),new Ie({key:e,handleDOMEvents:{mousedown(i,o){const a=o.target;if(!a)return!1;const s=a.closest(`td[${Yi}], th[${Mo}]`);if(!s||!s.closest("table"))return!1;let c=null,d=0;if(i.state.doc.descendants((_,h)=>c!==null?!1:_.type.name==="table"?(c=h,d=_.nodeSize,!1):!0),c===null)return!1;const u=c+d,p=Math.min(u,i.state.doc.content.size),m=i.state.tr.setSelection(ue.near(i.state.doc.resolve(p)));return i.dispatch(m),i.focus(),o.preventDefault(),!0}},props:{handleKeyDown(i,o){const{$from:a}=i.state.selection;return r(a)?["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Tab","Escape","Home","End","PageUp","PageDown"].includes(o.key)?!1:(o.preventDefault(),!0):!1},handlePaste(i){const{$from:o}=i.state.selection;return r(o)}}})]},addAttributes(){return{...this.parent?.(),isVariableTable:{default:!1},[Hn]:{default:null,parseHTML:e=>e.getAttribute(Hn),renderHTML:e=>e[Hn]?{[Hn]:e[Hn]}:{}},[Ya]:{default:null},[jb]:{default:null},[ye]:{default:null,parseHTML:e=>e.getAttribute(ye),renderHTML:e=>e[ye]?{[ye]:e[ye]}:{}},[Ve]:{default:null,parseHTML:e=>e.getAttribute(Ve),renderHTML:e=>e[Ve]?{[Ve]:e[Ve]}:{}},[je]:{default:null,parseHTML:e=>e.getAttribute(je),renderHTML:e=>e[je]?{[je]:e[je]}:{}},[Ye]:{default:null,parseHTML:e=>{const t=e.getAttribute(Ye);return t?parseInt(t,10):null},renderHTML:e=>e[Ye]?{[Ye]:e[Ye]}:{}}}},renderHTML({HTMLAttributes:e}){const t={...e};return t.isVariableTable&&(t.class=(t.class||"")+" variable-table-readonly",t.style=(t.style||"")+"background-color: #f9fafb;"),t[ye]===cn?(t.class=(t.class||"")+` ${Qb}`,t.style=(t.style||"")+"outline: 2px solid #008000; outline-offset: 2px;"):t[ye]===$i?(t.class=(t.class||"")+` ${Xb}`,t.style=(t.style||"")+"outline: 2px solid #ef4444; outline-offset: 2px; opacity: 0.7;"):t[ye]===dn?(t.class=(t.class||"")+` ${Qb}`,t.style=(t.style||"")+"outline: 2px solid #10b981; outline-offset: 2px;"):t[ye]===Wi&&(t.class=(t.class||"")+` ${Xb}`,t.style=(t.style||"")+"outline: 2px solid #f59e0b; outline-offset: 2px; opacity: 0.7;"),["table",t,0]}}),j2=N0.extend({addAttributes(){return{...this.parent?.(),[Hn]:{default:null},[wo]:{default:null},[ye]:{default:null,parseHTML:e=>e.getAttribute(ye),renderHTML:e=>e[ye]?{[ye]:e[ye]}:{}},[Ve]:{default:null,parseHTML:e=>e.getAttribute(Ve),renderHTML:e=>e[Ve]?{[Ve]:e[Ve]}:{}},[je]:{default:null,parseHTML:e=>e.getAttribute(je),renderHTML:e=>e[je]?{[je]:e[je]}:{}},[Ye]:{default:null,parseHTML:e=>e.getAttribute(Ye),renderHTML:e=>e[Ye]?{[Ye]:e[Ye]}:{}},[Fo]:{default:null,parseHTML:e=>e.getAttribute(Fo),renderHTML:e=>e[Fo]?{[Fo]:e[Fo]}:{}},[Lt]:{default:null,parseHTML:e=>e.getAttribute(Lt),renderHTML:e=>e[Lt]?{[Lt]:e[Lt]}:{}},[pn]:{default:null,parseHTML:e=>e.getAttribute(pn),renderHTML:e=>e[pn]?{[pn]:e[pn]}:{}}}},renderHTML({HTMLAttributes:e}){const t={...e};return t[ye]===cn||t[ye]===dn?(t.class=(t.class||"")+" redline-row-insertion",t.style=(t.style||"")+"background-color: rgba(34, 197, 94, 0.08);"):(t[ye]===$i||t[ye]===Wi)&&(t.class=(t.class||"")+" redline-row-deletion",t.style=(t.style||"")+"background-color: rgba(239, 68, 68, 0.08);"),["tr",t,0]}}),q2=x0.extend({addAttributes(){return{...this.parent?this.parent():{},[Hn]:{default:null},[Mo]:{default:null},[qb]:{default:null},colspan:{default:1},rowspan:{default:1},colwidth:{default:null},backgroundColor:{default:null,parseHTML:e=>e.style.backgroundColor,renderHTML:e=>{const t=e.backgroundColor;return t?{style:`background-color: ${t};`}:{}}},[ye]:{default:null,parseHTML:e=>e.getAttribute(ye),renderHTML:e=>e[ye]?{[ye]:e[ye]}:{}},[Ve]:{default:null,parseHTML:e=>e.getAttribute(Ve),renderHTML:e=>e[Ve]?{[Ve]:e[Ve]}:{}},[je]:{default:null,parseHTML:e=>e.getAttribute(je),renderHTML:e=>e[je]?{[je]:e[je]}:{}},[Ye]:{default:null,parseHTML:e=>e.getAttribute(Ye),renderHTML:e=>e[Ye]?{[Ye]:e[Ye]}:{}},[Lt]:{default:null,parseHTML:e=>e.getAttribute(Lt),renderHTML:e=>e[Lt]?{[Lt]:e[Lt]}:{}},[pn]:{default:null,parseHTML:e=>e.getAttribute(pn),renderHTML:e=>e[pn]?{[pn]:e[pn]}:{}}}},parseHTML(){return[{tag:"th",getAttrs:e=>{if(typeof e=="string")return{};const t=e;return{colspan:parseInt(t.getAttribute("colspan")||"1",10),rowspan:parseInt(t.getAttribute("rowspan")||"1",10),colwidth:t.getAttribute("colwidth")?t.getAttribute("colwidth")?.split(",").map(n=>parseInt(n,10)):null}}}]},renderHTML({HTMLAttributes:e}){const t={...e};return delete t.backgroundColor,t[Lt]==="add"&&(t[ye]===cn||t[ye]===dn)?(t.class=(t.class||"")+" redline-column-insertion",t.style=(t.style||"")+"background-color: rgba(34, 197, 94, 0.12);"):t[Lt]==="delete"&&(t[ye]===$i||t[ye]===Wi)&&(t.class=(t.class||"")+" redline-column-deletion",t.style=(t.style||"")+"background-color: rgba(239, 68, 68, 0.12);opacity: 0.85;"),["th",t,0]}}),K2=v0.extend({addAttributes(){return{...this.parent?this.parent():{},[Hn]:{default:null},[Yi]:{default:null},[qb]:{default:null},colspan:{default:1},rowspan:{default:1},colwidth:{default:null},backgroundColor:{default:null,parseHTML:e=>e.style.backgroundColor,renderHTML:e=>{const t=e.backgroundColor;return t?{style:`background-color: ${t};`}:{}}},[ye]:{default:null,parseHTML:e=>e.getAttribute(ye),renderHTML:e=>e[ye]?{[ye]:e[ye]}:{}},[Ve]:{default:null,parseHTML:e=>e.getAttribute(Ve),renderHTML:e=>e[Ve]?{[Ve]:e[Ve]}:{}},[je]:{default:null,parseHTML:e=>e.getAttribute(je),renderHTML:e=>e[je]?{[je]:e[je]}:{}},[Ye]:{default:null,parseHTML:e=>e.getAttribute(Ye),renderHTML:e=>e[Ye]?{[Ye]:e[Ye]}:{}},[Lt]:{default:null,parseHTML:e=>e.getAttribute(Lt),renderHTML:e=>e[Lt]?{[Lt]:e[Lt]}:{}},[pn]:{default:null,parseHTML:e=>e.getAttribute(pn),renderHTML:e=>e[pn]?{[pn]:e[pn]}:{}}}},parseHTML(){return[{tag:"td",getAttrs:e=>{if(typeof e=="string")return{};const t=e;return{colspan:parseInt(t.getAttribute("colspan")||"1",10),rowspan:parseInt(t.getAttribute("rowspan")||"1",10),colwidth:t.getAttribute("colwidth")?t.getAttribute("colwidth")?.split(",").map(n=>parseInt(n,10)):null}}}]},renderHTML({HTMLAttributes:e}){const t={...e};return delete t.backgroundColor,t[Lt]==="add"&&(t[ye]===cn||t[ye]===dn)?(t.class=(t.class||"")+" redline-column-insertion",t.style=(t.style||"")+"background-color: rgba(34, 197, 94, 0.12);"):t[Lt]==="delete"&&(t[ye]===$i||t[ye]===Wi)&&(t.class=(t.class||"")+" redline-column-deletion",t.style=(t.style||"")+"background-color: rgba(239, 68, 68, 0.12);opacity: 0.85;"),["td",t,0]}}),Q2=/\{\{([a-zA-Z0-9_-]+)\}\}$/,X2=bt.create({name:"variableText",group:"inline",inline:!0,atom:!0,selectable:!0,marks:"_",addOptions(){return{enabled:!1,variableValues:{}}},addStorage(){return{variableValues:this.options.variableValues}},addAttributes(){return{variableName:{default:"",parseHTML:e=>e.getAttribute(Vi),renderHTML:e=>({[Vi]:e.variableName})},value:{default:"",parseHTML:e=>e.getAttribute(ko)||"",renderHTML:e=>({[ko]:e.value})},redlineType:{default:null,parseHTML:e=>e.getAttribute(ye),renderHTML:e=>e.redlineType?{[ye]:e.redlineType}:{}},redlineUserId:{default:null,parseHTML:e=>e.getAttribute(Ve),renderHTML:e=>e.redlineUserId?{[Ve]:e.redlineUserId}:{}},redlineUserName:{default:null,parseHTML:e=>e.getAttribute(je),renderHTML:e=>e.redlineUserName?{[je]:e.redlineUserName}:{}},redlineTimestamp:{default:null,parseHTML:e=>e.getAttribute(Ye),renderHTML:e=>e.redlineTimestamp?{[Ye]:e.redlineTimestamp}:{}},redlineAction:{default:null,parseHTML:e=>e.getAttribute("data-variable-action"),renderHTML:e=>e.redlineAction?{"data-variable-action":e.redlineAction}:{}},redlinePreviousAttrs:{default:null,parseHTML:e=>e.getAttribute("data-variable-previous-attrs"),renderHTML:e=>e.redlinePreviousAttrs?{"data-variable-previous-attrs":e.redlinePreviousAttrs}:{}}}},parseHTML(){return[{tag:`span[${Vi}]`}]},renderHTML({node:e}){const{variableName:t,value:n}=e.attrs,r=n||`{{${t}}}`;return["span",{[Vi]:t,[ko]:n,class:Wb,contenteditable:"false"},r]},addNodeView(){return({node:e})=>{const{variableName:t,value:n}=e.attrs,r=document.createElement("span");r.className=Wb,r.contentEditable="false",r.setAttribute(Vi,t),r.setAttribute(ko,n),r.textContent=n||`{{${t}}}`,e.attrs.redlineType&&r.setAttribute(ye,e.attrs.redlineType),e.attrs.redlineUserId&&r.setAttribute(Ve,e.attrs.redlineUserId),e.attrs.redlineUserName&&r.setAttribute(je,e.attrs.redlineUserName),e.attrs.redlineTimestamp&&r.setAttribute(Ye,e.attrs.redlineTimestamp),e.attrs.redlineAction&&r.setAttribute("data-variable-action",e.attrs.redlineAction),e.attrs.redlinePreviousAttrs&&r.setAttribute("data-variable-previous-attrs",e.attrs.redlinePreviousAttrs);const i=a=>{a.marks&&a.marks.length>0&&a.marks.forEach(s=>{if(s.type.name==="bold"&&(r.style.fontWeight="bold"),s.type.name==="italic"&&(r.style.fontStyle="italic"),s.type.name==="underline"){const l=r.style.textDecoration;r.style.textDecoration=l?`${l} underline`:"underline"}if(s.type.name==="strike"){const l=r.style.textDecoration;r.style.textDecoration=l?`${l} line-through`:"line-through"}s.type.name==="textStyle"&&(s.attrs.fontSize&&(r.style.fontSize=s.attrs.fontSize),s.attrs.color&&(r.style.color=s.attrs.color),s.attrs.fontFamily&&(r.style.fontFamily=s.attrs.fontFamily),s.attrs.backgroundColor&&(r.style.backgroundColor=s.attrs.backgroundColor))})};i(e);const o=()=>{const a=window.getSelection();a&&a.rangeCount>0&&a.getRangeAt(0).intersectsNode(r)?r.classList.add("variable-text-selected"):r.classList.remove("variable-text-selected")};return document.addEventListener("selectionchange",o),{dom:r,destroy:()=>{document.removeEventListener("selectionchange",o)},update:a=>{if(a.type.name!=="variableText")return!1;const{variableName:s,value:l}=a.attrs;return(r.getAttribute(ko)!==l||r.getAttribute(Vi)!==s)&&(r.setAttribute(Vi,s),r.setAttribute(ko,l),r.textContent=l||`{{${s}}}`),a.attrs.redlineType?r.setAttribute(ye,a.attrs.redlineType):r.removeAttribute(ye),a.attrs.redlineUserId?r.setAttribute(Ve,a.attrs.redlineUserId):r.removeAttribute(Ve),a.attrs.redlineUserName?r.setAttribute(je,a.attrs.redlineUserName):r.removeAttribute(je),a.attrs.redlineTimestamp?r.setAttribute(Ye,a.attrs.redlineTimestamp):r.removeAttribute(Ye),a.attrs.redlineAction?r.setAttribute("data-variable-action",a.attrs.redlineAction):r.removeAttribute("data-variable-action"),a.attrs.redlinePreviousAttrs?r.setAttribute("data-variable-previous-attrs",a.attrs.redlinePreviousAttrs):r.removeAttribute("data-variable-previous-attrs"),r.style.fontWeight="",r.style.fontStyle="",r.style.textDecoration="",r.style.fontSize="",r.style.color="",r.style.fontFamily="",r.style.backgroundColor="",i(a),!0}}}},addCommands(){return{insertVariable:(e,t)=>({commands:n,editor:r})=>{const i=t||this.storage.variableValues[e]||"",o=r.storage?.redline,s=r.extensionManager.extensions.find(c=>c.name==="redline")?.options?.currentEntity||{id:"unknown",name:"User"},l=o?.isActive?o.mode==="ai"?dn:cn:null;return n.insertContent({type:this.name,attrs:{variableName:e,value:i,...l?{redlineType:l,redlineUserId:s.id,redlineUserName:s.name,redlineTimestamp:new Date().toISOString(),redlineAction:"add"}:{}}})},updateVariableValues:e=>({tr:t,state:n,dispatch:r,editor:i})=>{if(!r)return!1;this.storage.variableValues={...this.storage.variableValues,...e};let o=t,a=!1;const s=i.storage?.redline,c=i.extensionManager.extensions.find(p=>p.name==="redline")?.options?.currentEntity||{id:"unknown",name:"User"},d=s?.isActive?s.mode==="ai"?dn:cn:null,u=[];return n.doc.descendants((p,m)=>{if(p.type.name==="variableText"){const{variableName:_,value:h}=p.attrs,g=e[_];g!==void 0&&g!==h&&u.unshift(m)}}),u.forEach(p=>{const m=n.doc.nodeAt(p);if(m){const{variableName:_}=m.attrs,h=e[_],g={...m.attrs,value:h};if(d){const b=m.attrs.redlineType===cn||m.attrs.redlineType===dn;o=o.setNodeMarkup(p,void 0,{...g,redlineType:b?m.attrs.redlineType:d,redlineUserId:c.id,redlineUserName:c.name,redlineTimestamp:m.attrs.redlineTimestamp||new Date().toISOString(),redlineAction:b?m.attrs.redlineAction||"add":"update",redlinePreviousAttrs:b?m.attrs.redlinePreviousAttrs||null:JSON.stringify({variableName:m.attrs.variableName,value:m.attrs.value??""})})}else o=o.setNodeMarkup(p,void 0,g);a=!0}}),a?(o=o.setMeta("addToHistory",!1),r(o),!0):!1}}},addInputRules(){return this.options.enabled?[new Ro({find:Q2,handler:({range:e,match:t,commands:n})=>{const r=t[1];r&&(n.deleteRange(e),n.insertVariable(r))}})]:[]},addKeyboardShortcuts(){const e=t=>{const{selection:n}=this.editor.state,{$from:r}=n;let i=null,o=null;if(n.empty){const m=t==="backward"?r.nodeBefore:r.nodeAfter;m?.type.name===this.name&&(o=m,i=t==="backward"?r.pos-m.nodeSize:r.pos)}if(!o||i===null)return!1;const a=this.editor.storage?.redline;if(!a?.isActive)return this.editor.commands.deleteRange({from:i,to:i+o.nodeSize});const l=this.editor.extensionManager.extensions.find(m=>m.name==="redline")?.options?.currentEntity||{id:"unknown",name:"User"},c=a.mode==="ai"?Wi:$i,d=o.attrs,u=d.redlineType===cn||d.redlineType===dn,p=this.editor.state.tr;return u?p.delete(i,i+o.nodeSize):p.setNodeMarkup(i,void 0,{...d,redlineType:c,redlineUserId:l.id,redlineUserName:l.name,redlineTimestamp:new Date().toISOString(),redlineAction:"delete",redlinePreviousAttrs:JSON.stringify({variableName:d.variableName,value:d.value??""})}),this.editor.view.dispatch(p),!0};return{Backspace:({editor:t})=>{const{selection:n}=t.state,{$from:r}=n,i=r.nodeBefore;return i&&i.type.name===this.name?e("backward"):!1},Delete:()=>e("forward")}}}),Z2="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",J2="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",cm="numeric",dm="ascii",um="alpha",is="asciinumeric",as="alphanumeric",pm="domain",w0="emoji",eM="scheme",tM="slashscheme",mm="whitespace";function nM(e,t){return e in t||(t[e]=[]),t[e]}function Qi(e,t,n){t[cm]&&(t[is]=!0,t[as]=!0),t[dm]&&(t[is]=!0,t[um]=!0),t[is]&&(t[as]=!0),t[um]&&(t[as]=!0),t[as]&&(t[pm]=!0),t[w0]&&(t[pm]=!0);for(const r in t){const i=nM(r,n);i.indexOf(e)<0&&i.push(e)}}function rM(e,t){const n={};for(const r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function vn(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}vn.groups={},vn.prototype={accepts(){return!!this.t},go(e){const t=this,n=t.j[e];if(n)return n;for(let r=0;r<t.jr.length;r++){const i=t.jr[r][0],o=t.jr[r][1];if(o&&i.test(e))return o}return t.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let i=0;i<e.length;i++)this.tt(e[i],t,n,r)},tr(e,t,n,r){r=r||vn.groups;let i;return t&&t.j?i=t:(i=new vn(t),n&&r&&Qi(t,n,r)),this.jr.push([e,i]),i},ts(e,t,n,r){let i=this;const o=e.length;if(!o)return i;for(let a=0;a<o-1;a++)i=i.tt(e[a]);return i.tt(e[o-1],t,n,r)},tt(e,t,n,r){r=r||vn.groups;const i=this;if(t&&t.j)return i.j[e]=t,t;const o=t;let a,s=i.go(e);if(s?(a=new vn,Object.assign(a.j,s.j),a.jr.push.apply(a.jr,s.jr),a.jd=s.jd,a.t=s.t):a=new vn,o){if(r)if(a.t&&typeof a.t=="string"){const l=Object.assign(rM(a.t,r),n);Qi(o,l,r)}else n&&Qi(o,n,r);a.t=o}return i.j[e]=a,a}};const De=(e,t,n,r,i)=>e.ta(t,n,r,i),Rt=(e,t,n,r,i)=>e.tr(t,n,r,i),M0=(e,t,n,r,i)=>e.ts(t,n,r,i),Q=(e,t,n,r,i)=>e.tt(t,n,r,i),Ur="WORD",fm="UWORD",D0="ASCIINUMERICAL",L0="ALPHANUMERICAL",ss="LOCALHOST",_m="TLD",hm="UTLD",rc="SCHEME",zo="SLASH_SCHEME",gm="NUM",bm="WS",Em="NL",ls="OPENBRACE",cs="CLOSEBRACE",ic="OPENBRACKET",oc="CLOSEBRACKET",ac="OPENPAREN",sc="CLOSEPAREN",lc="OPENANGLEBRACKET",cc="CLOSEANGLEBRACKET",dc="FULLWIDTHLEFTPAREN",uc="FULLWIDTHRIGHTPAREN",pc="LEFTCORNERBRACKET",mc="RIGHTCORNERBRACKET",fc="LEFTWHITECORNERBRACKET",_c="RIGHTWHITECORNERBRACKET",hc="FULLWIDTHLESSTHAN",gc="FULLWIDTHGREATERTHAN",bc="AMPERSAND",Ec="APOSTROPHE",Sc="ASTERISK",_i="AT",Tc="BACKSLASH",yc="BACKTICK",Cc="CARET",hi="COLON",Sm="COMMA",vc="DOLLAR",mr="DOT",xc="EQUALS",Tm="EXCLAMATION",Gn="HYPHEN",ds="PERCENT",Nc="PIPE",Rc="PLUS",Ac="POUND",us="QUERY",ym="QUOTE",P0="FULLWIDTHMIDDLEDOT",Cm="SEMI",fr="SLASH",ps="TILDE",Oc="UNDERSCORE",B0="EMOJI",Ic="SYM";var F0=Object.freeze({__proto__:null,ALPHANUMERICAL:L0,AMPERSAND:bc,APOSTROPHE:Ec,ASCIINUMERICAL:D0,ASTERISK:Sc,AT:_i,BACKSLASH:Tc,BACKTICK:yc,CARET:Cc,CLOSEANGLEBRACKET:cc,CLOSEBRACE:cs,CLOSEBRACKET:oc,CLOSEPAREN:sc,COLON:hi,COMMA:Sm,DOLLAR:vc,DOT:mr,EMOJI:B0,EQUALS:xc,EXCLAMATION:Tm,FULLWIDTHGREATERTHAN:gc,FULLWIDTHLEFTPAREN:dc,FULLWIDTHLESSTHAN:hc,FULLWIDTHMIDDLEDOT:P0,FULLWIDTHRIGHTPAREN:uc,HYPHEN:Gn,LEFTCORNERBRACKET:pc,LEFTWHITECORNERBRACKET:fc,LOCALHOST:ss,NL:Em,NUM:gm,OPENANGLEBRACKET:lc,OPENBRACE:ls,OPENBRACKET:ic,OPENPAREN:ac,PERCENT:ds,PIPE:Nc,PLUS:Rc,POUND:Ac,QUERY:us,QUOTE:ym,RIGHTCORNERBRACKET:mc,RIGHTWHITECORNERBRACKET:_c,SCHEME:rc,SEMI:Cm,SLASH:fr,SLASH_SCHEME:zo,SYM:Ic,TILDE:ps,TLD:_m,UNDERSCORE:Oc,UTLD:hm,UWORD:fm,WORD:Ur,WS:bm});const zr=/[a-z]/,ms=new RegExp("\\p{L}","u"),vm=new RegExp("\\p{Emoji}","u"),Hr=/\d/,xm=/\s/,U0="\r",Nm=`
|
|
148
|
+
`);if(c.trim().split(/\s+/).filter(Boolean).length<e.options.minWordsToTriggerAutoCompletion){n?.abort(),n=null,clearTimeout(t),o.dispatch(o.state.tr.setMeta(Fr,{type:"clear"}));return}clearTimeout(t),t=setTimeout(()=>i(c,l),e.options.debounceTime)},destroy(){clearTimeout(t),n?.abort(),n=null}}}})]}}),es="onBlurHighlight",ql={BLUR:"blur",FOCUS:"focus"},Ew=Re.create({name:es,addProseMirrorPlugins(){return[new Ie({key:new Fe(es),state:{init(){return Me.empty},apply(e,t){const n=e.getMeta(es),{selection:r,doc:i}=e,o=r&&r.from!==r.to;if(!o||n?.action===ql.FOCUS)return Me.empty;if(o&&n?.action===ql.BLUR){const a=gt.inline(r.from,r.to,{class:"blur-highlight"});return Me.create(i,[a])}return t}},props:{decorations(e){return this.getState(e)},handleDOMEvents:{blur:e=>{const{tr:t}=e.state,n=t.setMeta(es,{from:t.selection.from,to:t.selection.to,action:ql.BLUR});return e.dispatch(n),!1},focus:e=>{const{tr:t}=e.state,n=t.setMeta(es,{from:t.selection.from,to:t.selection.to,action:ql.FOCUS});return e.dispatch(n),!1}}}})]}}),Sw=Re.create({name:"indent",addOptions(){return{types:["paragraph","heading","blockquote"],minLevel:0,maxLevel:12}},addGlobalAttributes(){return[{types:this.options.types,attributes:{indent:{default:0,parseHTML:e=>{const t=e.style.marginLeft;return t?t.includes("in")?parseFloat(t)/.5||0:parseInt(t)/48||0:0},renderHTML:e=>e.indent?{style:`margin-left: ${e.indent*.5}in`}:{}}}}]},addCommands(){return{indent:()=>({state:e,dispatch:t,tr:n})=>{const{selection:r}=e,{from:i,to:o}=r;return e.doc.nodesBetween(i,o,(a,s)=>{if(this.options.types.includes(a.type.name)){const l=a.attrs.indent||0;l<this.options.maxLevel&&n.setNodeMarkup(s,void 0,{...a.attrs,indent:l+1})}}),t&&t(n),!0},outdent:()=>({state:e,dispatch:t,tr:n})=>{const{selection:r}=e,{from:i,to:o}=r;return e.doc.nodesBetween(i,o,(a,s)=>{if(this.options.types.includes(a.type.name)){const l=a.attrs.indent||0;l>this.options.minLevel&&n.setNodeMarkup(s,void 0,{...a.attrs,indent:l-1})}}),t&&t(n),!0}}},addKeyboardShortcuts(){return{Tab:()=>{if(this.editor.can().sinkListItem("taskItem")||this.editor.can().sinkListItem("listItem")){if(this.editor.isActive("taskItem"))return this.editor.chain().focus().sinkListItem("taskItem").run();if(this.editor.isActive("listItem"))return this.editor.chain().focus().sinkListItem("listItem").run()}return this.editor.commands.indent()},"Shift-Tab":()=>{if(this.editor.can().liftListItem("taskItem")||this.editor.can().liftListItem("listItem")){if(this.editor.isActive("taskItem"))return this.editor.chain().focus().liftListItem("taskItem").run();if(this.editor.isActive("listItem"))return this.editor.chain().focus().liftListItem("listItem").run()}return this.editor.commands.outdent()}}}});var Tw=DE;const yw=new Fe("listMarkerFontSize");function Cw(e,t){let n=0;return t.nodesBetween(0,t.content.size,(r,i)=>{i<e&&i+r.nodeSize>e&&(r.type.name==="orderedList"||r.type.name==="bulletList")&&n++}),n}function t0(e){let t=null;return e.descendants(n=>{if(n.type.name==="orderedList"||n.type.name==="bulletList")return!1;if(typeof n.attrs?.fontSize=="string"&&n.attrs.fontSize)return t=n.attrs.fontSize,!1;const r=n.marks?.find(i=>i.type.name==="textStyle"&&typeof i.attrs.fontSize=="string"&&i.attrs.fontSize);return r?.attrs.fontSize?(t=r.attrs.fontSize,!1):t?!1:void 0}),t}function n0(e){let t=null;return e.descendants(n=>{if(n.type.name==="orderedList"||n.type.name==="bulletList")return!1;if(typeof n.attrs?.color=="string"&&n.attrs.color)return t=n.attrs.color,!1;const r=n.marks?.find(i=>i.type.name==="textStyle"&&typeof i.attrs.color=="string"&&i.attrs.color);return r?.attrs.color?(t=r.attrs.color,!1):t?!1:void 0}),t}function vw(e,t,n){const r=e.resolve(t);for(let i=r.depth-1;i>=0;i--){const o=r.node(i);if(o.type.name!=="orderedList"&&o.type.name!=="bulletList")continue;const a=r.index(i);if(a<=0)return null;for(let s=a-1;s>=0;s--){const l=o.child(s);if(l.type.name===n)return typeof l.attrs.markerFontSize=="string"&&l.attrs.markerFontSize?l.attrs.markerFontSize:t0(l)}return null}return null}function xw(e,t,n){const r=e.resolve(t);for(let i=r.depth-1;i>=0;i--){const o=r.node(i);if(o.type.name!=="orderedList"&&o.type.name!=="bulletList")continue;const a=r.index(i);if(a<=0)return null;for(let s=a-1;s>=0;s--){const l=o.child(s);if(l.type.name===n)return typeof l.attrs.markerColor=="string"&&l.attrs.markerColor?l.attrs.markerColor:n0(l)}return null}return null}function r0(e,t){const{$from:n}=e.selection;for(let r=n.depth;r>0;r--)if(n.node(r).type.name===t)return n.before(r);return null}const Nw=Tw.extend({name:"listItem",addAttributes(){const e=t=>{const n=[];return t.markerFontSize&&n.push(`--list-marker-font-size: ${t.markerFontSize}`),t.markerColor&&n.push(`--list-marker-color: ${t.markerColor}`),n.length===0?{}:{style:`${n.join("; ")};`}};return{...this.parent?.(),markerFontSize:{default:null,parseHTML:t=>t.style.getPropertyValue("--list-marker-font-size")||null,renderHTML:e},markerColor:{default:null,parseHTML:t=>t.style.getPropertyValue("--list-marker-color")||null,renderHTML:e}}},addOptions(){return{maxDepth:9}},addCommands(){return{setSelectedListItemMarkerFontSize:e=>({state:t,tr:n,dispatch:r})=>{const i=new Set;if(t.selection.empty){const o=r0(t,this.name);o!==null&&i.add(o)}else t.doc.nodesBetween(t.selection.from,t.selection.to,(o,a)=>{o.type.name===this.name&&i.add(a)});return i.size===0||(i.forEach(o=>{const a=n.doc.nodeAt(o);!a||a.type.name!==this.name||(n=n.setNodeMarkup(o,void 0,{...a.attrs,markerFontSize:e}))}),r&&r(n)),!0},setSelectedListItemMarkerColor:e=>({state:t,tr:n,dispatch:r})=>{const i=new Set;if(t.selection.empty){const o=r0(t,this.name);o!==null&&i.add(o)}else t.doc.nodesBetween(t.selection.from,t.selection.to,(o,a)=>{o.type.name===this.name&&i.add(a)});return i.size===0||(i.forEach(o=>{const a=n.doc.nodeAt(o);!a||a.type.name!==this.name||(n=n.setNodeMarkup(o,void 0,{...a.attrs,markerColor:e}))}),r&&r(n)),!0},sinkListItem:e=>({state:t,dispatch:n})=>{const{$from:r}=t.selection,i=typeof e=="string"?t.schema.nodes[e]:e;if(!i)return!1;let o=-1;for(let l=r.depth;l>0;l--)if(r.node(l).type===i){o=r.before(l);break}if(o===-1)return!1;const a=Cw(o,t.doc),s=Math.max(0,Math.min(9,this.options.maxDepth));return a>=s?!1:Ah(i)(t,n)},liftListItem:e=>({state:t,dispatch:n})=>{const r=typeof e=="string"?t.schema.nodes[e]:e;return Rh(r)(t,n)}}},addProseMirrorPlugins(){return[new Ie({key:yw,appendTransaction:(e,t,n)=>{if(!e.some(o=>o.docChanged))return null;let r=n.tr,i=!1;return n.doc.descendants((o,a)=>{if(o.type.name!==this.name)return;const s=typeof o.attrs.markerFontSize=="string"&&o.attrs.markerFontSize?o.attrs.markerFontSize:null,l=typeof o.attrs.markerColor=="string"&&o.attrs.markerColor?o.attrs.markerColor:null,c=t0(o),d=n0(o),u=s??vw(n.doc,a,this.name),p=l??xw(n.doc,a,this.name),m=c??u,_=d??p;m===s&&_===l||(r=r.setNodeMarkup(a,void 0,{...o.attrs,markerFontSize:m,markerColor:_}),i=!0)}),i?r:null}})]}});var Rw=bn.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(e){return e!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:e}){return["sub",Pe(this.options.HTMLAttributes,e),0]},addCommands(){return{setSubscript:()=>({commands:e})=>e.setMark(this.name),toggleSubscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSubscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),Aw=Rw,Ow=bn.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(e){return e!=="super"?!1:null}}]},renderHTML({HTMLAttributes:e}){return["sup",Pe(this.options.HTMLAttributes,e),0]},addCommands(){return{setSuperscript:()=>({commands:e})=>e.setMark(this.name),toggleSuperscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSuperscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),Iw=Ow,kw=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,ww=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,Mw=bn.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute("data-color")||e.style.backgroundColor,renderHTML:e=>e.color?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:e}){return["mark",Pe(this.options.HTMLAttributes,e),0]},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Ao({find:kw,type:this.type})]},addPasteRules(){return[Hi({find:ww,type:this.type})]}}),Dw=Mw,Lw=Re.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:e=>{const t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>e.textAlign?{style:`text-align: ${e.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).every(n=>n):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,"textAlign")).every(t=>t),toggleTextAlign:e=>({editor:t,commands:n})=>this.options.alignments.includes(e)?t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e):!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")}}}),Pw=Lw,Kl=(e,t)=>{if(e==="slot")return 0;if(e instanceof Function)return e(t);const{children:n,...r}=t??{};if(e==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[e,r,n]},Bw=/^\s*>\s$/,Fw=bt.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return Kl("blockquote",{...Pe(this.options.HTMLAttributes,e),children:Kl("slot",{})})},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Oo({find:Bw,type:this.type})]}}),Uw=Fw,zw=bt.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,Pe(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>_A({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),Hw=zw,Jp,em;if(typeof WeakMap<"u"){let e=new WeakMap;Jp=t=>e.get(t),em=(t,n)=>(e.set(t,n),n)}else{const e=[];let n=0;Jp=r=>{for(let i=0;i<e.length;i+=2)if(e[i]==r)return e[i+1]},em=(r,i)=>(n==10&&(n=0),e[n++]=r,e[n++]=i)}var Nt=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){const n=this.map[t];if(n!=e)continue;const r=t%this.width,i=t/this.width|0;let o=r+1,a=i+1;for(let s=1;o<this.width&&this.map[t+s]==n;s++)o++;for(let s=1;a<this.height&&this.map[t+this.width*s]==n;s++)a++;return{left:r,top:i,right:o,bottom:a}}throw new RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){const{left:r,right:i,top:o,bottom:a}=this.findCell(e);return t=="horiz"?(n<0?r==0:i==this.width)?null:this.map[o*this.width+(n<0?r-1:i)]:(n<0?o==0:a==this.height)?null:this.map[r+this.width*(n<0?o-1:a)]}rectBetween(e,t){const{left:n,right:r,top:i,bottom:o}=this.findCell(e),{left:a,right:s,top:l,bottom:c}=this.findCell(t);return{left:Math.min(n,a),top:Math.min(i,l),right:Math.max(r,s),bottom:Math.max(o,c)}}cellsInRect(e){const t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){const o=r*this.width+i,a=this.map[o];n[a]||(n[a]=!0,!(i==e.left&&i&&this.map[o-1]==a||r==e.top&&r&&this.map[o-this.width]==a)&&t.push(a))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){const o=i+n.child(r).nodeSize;if(r==e){let a=t+e*this.width;const s=(e+1)*this.width;for(;a<s&&this.map[a]<i;)a++;return a==s?o-1:this.map[a]}i=o}}static get(e){return Jp(e)||em(e,Gw(e))}};function Gw(e){if(e.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+e.type.name);const t=Vw(e),n=e.childCount,r=[];let i=0,o=null;const a=[];for(let c=0,d=t*n;c<d;c++)r[c]=0;for(let c=0,d=0;c<n;c++){const u=e.child(c);d++;for(let _=0;;_++){for(;i<r.length&&r[i]!=0;)i++;if(_==u.childCount)break;const h=u.child(_),{colspan:g,rowspan:b,colwidth:E}=h.attrs;for(let S=0;S<b;S++){if(S+c>=n){(o||(o=[])).push({type:"overlong_rowspan",pos:d,n:b-S});break}const y=i+S*t;for(let T=0;T<g;T++){r[y+T]==0?r[y+T]=d:(o||(o=[])).push({type:"collision",row:c,pos:d,n:g-T});const x=E&&E[T];if(x){const v=(y+T)%t*2,C=a[v];C==null||C!=x&&a[v+1]==1?(a[v]=x,a[v+1]=1):C==x&&a[v+1]++}}}i+=g,d+=h.nodeSize}const p=(c+1)*t;let m=0;for(;i<p;)r[i++]==0&&m++;m&&(o||(o=[])).push({type:"missing",row:c,n:m}),d++}(t===0||n===0)&&(o||(o=[])).push({type:"zero_sized"});const s=new Nt(t,n,r,o);let l=!1;for(let c=0;!l&&c<a.length;c+=2)a[c]!=null&&a[c+1]<n&&(l=!0);return l&&Yw(s,a,e),s}function Vw(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){const i=e.child(r);let o=0;if(n)for(let a=0;a<r;a++){const s=e.child(a);for(let l=0;l<s.childCount;l++){const c=s.child(l);a+c.attrs.rowspan>r&&(o+=c.attrs.colspan)}}for(let a=0;a<i.childCount;a++){const s=i.child(a);o+=s.attrs.colspan,s.attrs.rowspan>1&&(n=!0)}t==-1?t=o:t!=o&&(t=Math.max(t,o))}return t}function Yw(e,t,n){e.problems||(e.problems=[]);const r={};for(let i=0;i<e.map.length;i++){const o=e.map[i];if(r[o])continue;r[o]=!0;const a=n.nodeAt(o);if(!a)throw new RangeError(`No cell with offset ${o} found`);let s=null;const l=a.attrs;for(let c=0;c<l.colspan;c++){const d=(i+c)%e.width,u=t[d*2];u!=null&&(!l.colwidth||l.colwidth[c]!=u)&&((s||(s=$w(l)))[c]=u)}s&&e.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:s})}}function $w(e){if(e.colwidth)return e.colwidth.slice();const t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function un(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(const n in e.nodes){const r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}var fi=new Fe("selectingCells");function Po(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return e.node(0).resolve(e.before(t+1));return null}function Ww(e){for(let t=e.depth;t>0;t--){const n=e.node(t).type.spec.tableRole;if(n==="cell"||n==="header_cell")return e.node(t)}return null}function Jn(e){const t=e.selection.$head;for(let n=t.depth;n>0;n--)if(t.node(n).type.spec.tableRole=="row")return!0;return!1}function Ql(e){const t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&t.node.type.spec.tableRole=="cell")return t.$anchor;const n=Po(t.$head)||jw(t.$head);if(n)return n;throw new RangeError(`No cell found around position ${t.head}`)}function jw(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){const r=t.type.spec.tableRole;if(r=="cell"||r=="header_cell")return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){const r=t.type.spec.tableRole;if(r=="cell"||r=="header_cell")return e.doc.resolve(n-t.nodeSize)}}function tm(e){return e.parent.type.spec.tableRole=="row"&&!!e.nodeAfter}function qw(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function nm(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function i0(e,t,n){const r=e.node(-1),i=Nt.get(r),o=e.start(-1),a=i.nextCell(e.pos-o,t,n);return a==null?null:e.node(0).resolve(o+a)}function Ki(e,t,n=1){const r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function o0(e,t,n=1){const r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<n;i++)r.colwidth.splice(t,0,0)}return r}function Kw(e,t,n){const r=un(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=r)return!1;return!0}var it=class Qr extends xe{constructor(t,n=t){const r=t.node(-1),i=Nt.get(r),o=t.start(-1),a=i.rectBetween(t.pos-o,n.pos-o),s=t.node(0),l=i.cellsInRect(a).filter(d=>d!=n.pos-o);l.unshift(n.pos-o);const c=l.map(d=>{const u=r.nodeAt(d);if(!u)throw RangeError(`No cell with offset ${d} found`);const p=o+d+1;return new oh(s.resolve(p),s.resolve(p+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=t,this.$headCell=n}map(t,n){const r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(tm(r)&&tm(i)&&nm(r,i)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?Qr.rowSelection(r,i):o&&this.isColSelection()?Qr.colSelection(r,i):new Qr(r,i)}return ue.between(r,i)}content(){const t=this.$anchorCell.node(-1),n=Nt.get(t),r=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},a=[];for(let l=i.top;l<i.bottom;l++){const c=[];for(let d=l*n.width+i.left,u=i.left;u<i.right;u++,d++){const p=n.map[d];if(o[p])continue;o[p]=!0;const m=n.findCell(p);let _=t.nodeAt(p);if(!_)throw RangeError(`No cell with offset ${p} found`);const h=i.left-m.left,g=m.right-i.right;if(h>0||g>0){let b=_.attrs;if(h>0&&(b=Ki(b,0,h)),g>0&&(b=Ki(b,b.colspan-g,g)),m.left<i.left){if(_=_.type.createAndFill(b),!_)throw RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else _=_.type.create(b,_.content)}if(m.top<i.top||m.bottom>i.bottom){const b={..._.attrs,rowspan:Math.min(m.bottom,i.bottom)-Math.max(m.top,i.top)};m.top<i.top?_=_.type.createAndFill(b):_=_.type.create(b,_.content)}c.push(_)}a.push(t.child(l).copy(j.from(c)))}const s=this.isColSelection()&&this.isRowSelection()?t:a;return new ne(j.from(s),1,1)}replace(t,n=ne.empty){const r=t.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){const{$from:s,$to:l}=i[a],c=t.mapping.slice(r);t.replace(c.map(s.pos),c.map(l.pos),a?ne.empty:n)}const o=xe.findFrom(t.doc.resolve(t.mapping.slice(r).map(this.to)),-1);o&&t.setSelection(o)}replaceWith(t,n){this.replace(t,new ne(j.from(n),0,0))}forEachCell(t){const n=this.$anchorCell.node(-1),r=Nt.get(n),i=this.$anchorCell.start(-1),o=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let a=0;a<o.length;a++)t(n.nodeAt(o[a]),i+o[a])}isColSelection(){const t=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(t,n)>0)return!1;const r=t+this.$anchorCell.nodeAfter.attrs.rowspan,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){const r=t.node(-1),i=Nt.get(r),o=t.start(-1),a=i.findCell(t.pos-o),s=i.findCell(n.pos-o),l=t.node(0);return a.top<=s.top?(a.top>0&&(t=l.resolve(o+i.map[a.left])),s.bottom<i.height&&(n=l.resolve(o+i.map[i.width*(i.height-1)+s.right-1]))):(s.top>0&&(n=l.resolve(o+i.map[s.left])),a.bottom<i.height&&(t=l.resolve(o+i.map[i.width*(i.height-1)+a.right-1]))),new Qr(t,n)}isRowSelection(){const t=this.$anchorCell.node(-1),n=Nt.get(t),r=this.$anchorCell.start(-1),i=n.colCount(this.$anchorCell.pos-r),o=n.colCount(this.$headCell.pos-r);if(Math.min(i,o)>0)return!1;const a=i+this.$anchorCell.nodeAfter.attrs.colspan,s=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,s)==n.width}eq(t){return t instanceof Qr&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){const r=t.node(-1),i=Nt.get(r),o=t.start(-1),a=i.findCell(t.pos-o),s=i.findCell(n.pos-o),l=t.node(0);return a.left<=s.left?(a.left>0&&(t=l.resolve(o+i.map[a.top*i.width])),s.right<i.width&&(n=l.resolve(o+i.map[i.width*(s.top+1)-1]))):(s.left>0&&(n=l.resolve(o+i.map[s.top*i.width])),a.right<i.width&&(t=l.resolve(o+i.map[i.width*(a.top+1)-1]))),new Qr(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new Qr(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new Qr(t.resolve(n),t.resolve(r))}getBookmark(){return new Qw(this.$anchorCell.pos,this.$headCell.pos)}};it.prototype.visible=!1,xe.jsonID("cell",it);var Qw=class bC{constructor(t,n){this.anchor=t,this.head=n}map(t){return new bC(t.map(this.anchor),t.map(this.head))}resolve(t){const n=t.resolve(this.anchor),r=t.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&nm(n,r)?new it(n,r):xe.near(r,1)}};function Xw(e){if(!(e.selection instanceof it))return null;const t=[];return e.selection.forEachCell((n,r)=>{t.push(gt.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Me.create(e.doc,t)}function Zw({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let o=t.depth;o>=0&&!(t.before(o+1)>t.start(o));o--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function Jw({$from:e,$to:t}){let n,r;for(let i=e.depth;i>0;i--){const o=e.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=o;break}}for(let i=t.depth;i>0;i--){const o=t.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){r=o;break}}return n!==r&&t.parentOffset===0}function e2(e,t,n){const r=(t||e).selection,i=(t||e).doc;let o,a;if(r instanceof ge&&(a=r.node.type.spec.tableRole)){if(a=="cell"||a=="header_cell")o=it.create(i,r.from);else if(a=="row"){const s=i.resolve(r.from+1);o=it.rowSelection(s,s)}else if(!n){const s=Nt.get(r.node),l=r.from+1,c=l+s.map[s.width*s.height-1];o=it.create(i,l+1,c)}}else r instanceof ue&&Zw(r)?o=ue.create(i,r.from):r instanceof ue&&Jw(r)&&(o=ue.create(i,r.$from.start(),r.$from.end()));return o&&(t||(t=e.tr)).setSelection(o),t}var t2=new Fe("fix-tables");function a0(e,t,n,r){const i=e.childCount,o=t.childCount;e:for(let a=0,s=0;a<o;a++){const l=t.child(a);for(let c=s,d=Math.min(i,a+3);c<d;c++)if(e.child(c)==l){s=c+1,n+=l.nodeSize;continue e}r(l,n),s<i&&e.child(s).sameMarkup(l)?a0(e.child(s),l,n+1,r):l.nodesBetween(0,l.content.size,r,n+1),n+=l.nodeSize}}function s0(e,t){let n;const r=(i,o)=>{i.type.spec.tableRole=="table"&&(n=n2(e,i,o,n))};return t?t.doc!=e.doc&&a0(t.doc,e.doc,0,r):e.doc.descendants(r),n}function n2(e,t,n,r){const i=Nt.get(t);if(!i.problems)return r;r||(r=e.tr);const o=[];for(let l=0;l<i.height;l++)o.push(0);for(let l=0;l<i.problems.length;l++){const c=i.problems[l];if(c.type=="collision"){const d=t.nodeAt(c.pos);if(!d)continue;const u=d.attrs;for(let p=0;p<u.rowspan;p++)o[c.row+p]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,Ki(u,u.colspan-c.n,c.n))}else if(c.type=="missing")o[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=t.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=t.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const d=r.mapping.map(n);r.delete(d,d+t.nodeSize)}}let a,s;for(let l=0;l<o.length;l++)o[l]&&(a==null&&(a=l),s=l);for(let l=0,c=n+1;l<i.height;l++){const d=t.child(l),u=c+d.nodeSize,p=o[l];if(p>0){let m="cell";d.firstChild&&(m=d.firstChild.type.spec.tableRole);const _=[];for(let g=0;g<p;g++){const b=un(e.schema)[m].createAndFill();b&&_.push(b)}const h=(l==0||a==l-1)&&s==l?c+1:u-1;r.insert(r.mapping.map(h),_)}c=u}return r.setMeta(t2,{fixTables:!0})}function pr(e){const t=e.selection,n=Ql(e),r=n.node(-1),i=n.start(-1),o=Nt.get(r);return{...t instanceof it?o.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):o.findCell(n.pos-i),tableStart:i,map:o,table:r}}function l0(e,{map:t,tableStart:n,table:r},i){let o=i>0?-1:0;Kw(t,r,i+o)&&(o=i==0||i==t.width?null:0);for(let a=0;a<t.height;a++){const s=a*t.width+i;if(i>0&&i<t.width&&t.map[s-1]==t.map[s]){const l=t.map[s],c=r.nodeAt(l);e.setNodeMarkup(e.mapping.map(n+l),null,o0(c.attrs,i-t.colCount(l))),a+=c.attrs.rowspan-1}else{const l=o==null?un(r.type.schema).cell:r.nodeAt(t.map[s+o]).type,c=t.positionAt(a,i,r);e.insert(e.mapping.map(n+c),l.createAndFill())}}return e}function r2(e,t){if(!Jn(e))return!1;if(t){const n=pr(e);t(l0(e.tr,n,n.left))}return!0}function i2(e,t){if(!Jn(e))return!1;if(t){const n=pr(e);t(l0(e.tr,n,n.right))}return!0}function o2(e,{map:t,table:n,tableStart:r},i){const o=e.mapping.maps.length;for(let a=0;a<t.height;){const s=a*t.width+i,l=t.map[s],c=n.nodeAt(l),d=c.attrs;if(i>0&&t.map[s-1]==l||i<t.width-1&&t.map[s+1]==l)e.setNodeMarkup(e.mapping.slice(o).map(r+l),null,Ki(d,i-t.colCount(l)));else{const u=e.mapping.slice(o).map(r+l);e.delete(u,u+c.nodeSize)}a+=d.rowspan}}function a2(e,t){if(!Jn(e))return!1;if(t){const n=pr(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let i=n.right-1;o2(r,n,i),i!=n.left;i--){const o=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!o)throw RangeError("No table found");n.table=o,n.map=Nt.get(o)}t(r)}return!0}function s2(e,t,n){var r;const i=un(t.type.schema).header_cell;for(let o=0;o<e.width;o++)if(((r=t.nodeAt(e.map[o+n*e.width]))==null?void 0:r.type)!=i)return!1;return!0}function c0(e,{map:t,tableStart:n,table:r},i){var o;let a=n;for(let c=0;c<i;c++)a+=r.child(c).nodeSize;const s=[];let l=i>0?-1:0;s2(t,r,i+l)&&(l=i==0||i==t.height?null:0);for(let c=0,d=t.width*i;c<t.width;c++,d++)if(i>0&&i<t.height&&t.map[d]==t.map[d-t.width]){const u=t.map[d],p=r.nodeAt(u).attrs;e.setNodeMarkup(n+u,null,{...p,rowspan:p.rowspan+1}),c+=p.colspan-1}else{const u=l==null?un(r.type.schema).cell:(o=r.nodeAt(t.map[d+l*t.width]))==null?void 0:o.type,p=u?.createAndFill();p&&s.push(p)}return e.insert(a,un(r.type.schema).row.create(null,s)),e}function l2(e,t){if(!Jn(e))return!1;if(t){const n=pr(e);t(c0(e.tr,n,n.top))}return!0}function c2(e,t){if(!Jn(e))return!1;if(t){const n=pr(e);t(c0(e.tr,n,n.bottom))}return!0}function d2(e,{map:t,table:n,tableStart:r},i){let o=0;for(let c=0;c<i;c++)o+=n.child(c).nodeSize;const a=o+n.child(i).nodeSize,s=e.mapping.maps.length;e.delete(o+r,a+r);const l=new Set;for(let c=0,d=i*t.width;c<t.width;c++,d++){const u=t.map[d];if(!l.has(u)){if(l.add(u),i>0&&u==t.map[d-t.width]){const p=n.nodeAt(u).attrs;e.setNodeMarkup(e.mapping.slice(s).map(u+r),null,{...p,rowspan:p.rowspan-1}),c+=p.colspan-1}else if(i<t.height&&u==t.map[d+t.width]){const p=n.nodeAt(u),m=p.attrs,_=p.type.create({...m,rowspan:p.attrs.rowspan-1},p.content),h=t.positionAt(i+1,c,n);e.insert(e.mapping.slice(s).map(r+h),_),c+=m.colspan-1}}}}function u2(e,t){if(!Jn(e))return!1;if(t){const n=pr(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let i=n.bottom-1;d2(r,n,i),i!=n.top;i--){const o=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!o)throw RangeError("No table found");n.table=o,n.map=Nt.get(n.table)}t(r)}return!0}function d0(e){const t=e.content;return t.childCount==1&&t.child(0).isTextblock&&t.child(0).childCount==0}function p2({width:e,height:t,map:n},r){let i=r.top*e+r.left,o=i,a=(r.bottom-1)*e+r.left,s=i+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&n[o]==n[o-1]||r.right<e&&n[s]==n[s+1])return!0;o+=e,s+=e}for(let l=r.left;l<r.right;l++){if(r.top>0&&n[i]==n[i-e]||r.bottom<t&&n[a]==n[a+e])return!0;i++,a++}return!1}function u0(e,t){const n=e.selection;if(!(n instanceof it)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=pr(e),{map:i}=r;if(p2(i,r))return!1;if(t){const o=e.tr,a={};let s=j.empty,l,c;for(let d=r.top;d<r.bottom;d++)for(let u=r.left;u<r.right;u++){const p=i.map[d*i.width+u],m=r.table.nodeAt(p);if(!(a[p]||!m))if(a[p]=!0,l==null)l=p,c=m;else{d0(m)||(s=s.append(m.content));const _=o.mapping.map(p+r.tableStart);o.delete(_,_+m.nodeSize)}}if(l==null||c==null)return!0;if(o.setNodeMarkup(l+r.tableStart,null,{...o0(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),s.size){const d=l+1+c.content.size,u=d0(c)?l+1:d;o.replaceWith(u+r.tableStart,d+r.tableStart,s)}o.setSelection(new it(o.doc.resolve(l+r.tableStart))),t(o)}return!0}function p0(e,t){const n=un(e.schema);return m2(({node:r})=>n[r.type.spec.tableRole])(e,t)}function m2(e){return(t,n)=>{var r;const i=t.selection;let o,a;if(i instanceof it){if(i.$anchorCell.pos!=i.$headCell.pos)return!1;o=i.$anchorCell.nodeAfter,a=i.$anchorCell.pos}else{if(o=Ww(i.$from),!o)return!1;a=(r=Po(i.$from))==null?void 0:r.pos}if(o==null||a==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(n){let s=o.attrs;const l=[],c=s.colwidth;s.rowspan>1&&(s={...s,rowspan:1}),s.colspan>1&&(s={...s,colspan:1});const d=pr(t),u=t.tr;for(let m=0;m<d.right-d.left;m++)l.push(c?{...s,colwidth:c&&c[m]?[c[m]]:null}:s);let p;for(let m=d.top;m<d.bottom;m++){let _=d.map.positionAt(m,d.left,d.table);m==d.top&&(_+=o.nodeSize);for(let h=d.left,g=0;h<d.right;h++,g++)h==d.left&&m==d.top||u.insert(p=u.mapping.map(_+d.tableStart,1),e({node:o,row:m,col:h}).createAndFill(l[g]))}u.setNodeMarkup(a,e({node:o,row:d.top,col:d.left}),l[0]),i instanceof it&&u.setSelection(new it(u.doc.resolve(i.$anchorCell.pos),p?u.doc.resolve(p):void 0)),n(u)}return!0}}function f2(e,t){return function(n,r){if(!Jn(n))return!1;const i=Ql(n);if(i.nodeAfter.attrs[e]===t)return!1;if(r){const o=n.tr;n.selection instanceof it?n.selection.forEachCell((a,s)=>{a.attrs[e]!==t&&o.setNodeMarkup(s,null,{...a.attrs,[e]:t})}):o.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(o)}return!0}}function _2(e){return function(t,n){if(!Jn(t))return!1;if(n){const r=un(t.schema),i=pr(t),o=t.tr,a=i.map.cellsInRect(e=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=a.map(l=>i.table.nodeAt(l));for(let l=0;l<a.length;l++)s[l].type==r.header_cell&&o.setNodeMarkup(i.tableStart+a[l],r.cell,s[l].attrs);if(o.steps.length==0)for(let l=0;l<a.length;l++)o.setNodeMarkup(i.tableStart+a[l],r.header_cell,s[l].attrs);n(o)}return!0}}function m0(e,t,n){const r=t.map.cellsInRect({left:0,top:0,right:e=="row"?t.map.width:1,bottom:e=="column"?t.map.height:1});for(let i=0;i<r.length;i++){const o=t.table.nodeAt(r[i]);if(o&&o.type!==n.header_cell)return!1}return!0}function ts(e,t){return t=t||{useDeprecatedLogic:!1},t.useDeprecatedLogic?_2(e):function(n,r){if(!Jn(n))return!1;if(r){const i=un(n.schema),o=pr(n),a=n.tr,s=m0("row",o,i),l=m0("column",o,i),d=(e==="column"?s:e==="row"?l:!1)?1:0,u=e=="column"?{left:0,top:d,right:1,bottom:o.map.height}:e=="row"?{left:d,top:0,right:o.map.width,bottom:1}:o,p=e=="column"?l?i.cell:i.header_cell:e=="row"?s?i.cell:i.header_cell:i.cell;o.map.cellsInRect(u).forEach(m=>{const _=m+o.tableStart,h=a.doc.nodeAt(_);h&&a.setNodeMarkup(_,p,h.attrs)}),r(a)}return!0}}ts("row",{useDeprecatedLogic:!0}),ts("column",{useDeprecatedLogic:!0});var h2=ts("cell",{useDeprecatedLogic:!0});function g2(e,t){if(t<0){const n=e.nodeBefore;if(n)return e.pos-n.nodeSize;for(let r=e.index(-1)-1,i=e.before();r>=0;r--){const o=e.node(-1).child(r),a=o.lastChild;if(a)return i-1-a.nodeSize;i-=o.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;const n=e.node(-1);for(let r=e.indexAfter(-1),i=e.after();r<n.childCount;r++){const o=n.child(r);if(o.childCount)return i+1;i+=o.nodeSize}}return null}function f0(e){return function(t,n){if(!Jn(t))return!1;const r=g2(Ql(t),e);if(r==null)return!1;if(n){const i=t.doc.resolve(r);n(t.tr.setSelection(ue.between(i,qw(i))).scrollIntoView())}return!0}}function b2(e,t){const n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Xl(e,t){const n=e.selection;if(!(n instanceof it))return!1;if(t){const r=e.tr,i=un(e.schema).cell.createAndFill().content;n.forEachCell((o,a)=>{o.content.eq(i)||r.replace(r.mapping.map(a+1),r.mapping.map(a+o.nodeSize-1),new ne(i,0,0))}),r.docChanged&&t(r)}return!0}function E2(e){if(!e.size)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole=="table");)n--,r--,t=t.child(0).content;const i=t.child(0),o=i.type.spec.tableRole,a=i.type.schema,s=[];if(o=="row")for(let l=0;l<t.childCount;l++){let c=t.child(l).content;const d=l?0:Math.max(0,n-1),u=l<t.childCount-1?0:Math.max(0,r-1);(d||u)&&(c=rm(un(a).row,new ne(c,d,u)).content),s.push(c)}else if(o=="cell"||o=="header_cell")s.push(n||r?rm(un(a).row,new ne(t,n,r)).content:t);else return null;return S2(a,s)}function S2(e,t){const n=[];for(let i=0;i<t.length;i++){const o=t[i];for(let a=o.childCount-1;a>=0;a--){const{rowspan:s,colspan:l}=o.child(a).attrs;for(let c=i;c<i+s;c++)n[c]=(n[c]||0)+l}}let r=0;for(let i=0;i<n.length;i++)r=Math.max(r,n[i]);for(let i=0;i<n.length;i++)if(i>=t.length&&t.push(j.empty),n[i]<r){const o=un(e).cell.createAndFill(),a=[];for(let s=n[i];s<r;s++)a.push(o);t[i]=t[i].append(j.from(a))}return{height:t.length,width:r,rows:t}}function rm(e,t){const n=e.createAndFill();return new hu(n).replace(0,n.content.size,t).doc}function T2({width:e,height:t,rows:n},r,i){if(e!=r){const o=[],a=[];for(let s=0;s<n.length;s++){const l=n[s],c=[];for(let d=o[s]||0,u=0;d<r;u++){let p=l.child(u%l.childCount);d+p.attrs.colspan>r&&(p=p.type.createChecked(Ki(p.attrs,p.attrs.colspan,d+p.attrs.colspan-r),p.content)),c.push(p),d+=p.attrs.colspan;for(let m=1;m<p.attrs.rowspan;m++)o[s+m]=(o[s+m]||0)+p.attrs.colspan}a.push(j.from(c))}n=a,e=r}if(t!=i){const o=[];for(let a=0,s=0;a<i;a++,s++){const l=[],c=n[s%t];for(let d=0;d<c.childCount;d++){let u=c.child(d);a+u.attrs.rowspan>i&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,i-u.attrs.rowspan)},u.content)),l.push(u)}o.push(j.from(l))}n=o,t=i}return{width:e,height:t,rows:n}}function y2(e,t,n,r,i,o,a){const s=e.doc.type.schema,l=un(s);let c,d;if(i>t.width)for(let u=0,p=0;u<t.height;u++){const m=n.child(u);p+=m.nodeSize;const _=[];let h;m.lastChild==null||m.lastChild.type==l.cell?h=c||(c=l.cell.createAndFill()):h=d||(d=l.header_cell.createAndFill());for(let g=t.width;g<i;g++)_.push(h);e.insert(e.mapping.slice(a).map(p-1+r),_)}if(o>t.height){const u=[];for(let _=0,h=(t.height-1)*t.width;_<Math.max(t.width,i);_++){const g=_>=t.width?!1:n.nodeAt(t.map[h+_]).type==l.header_cell;u.push(g?d||(d=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}const p=l.row.create(null,j.from(u)),m=[];for(let _=t.height;_<o;_++)m.push(p);e.insert(e.mapping.slice(a).map(r+n.nodeSize-2),m)}return!!(c||d)}function _0(e,t,n,r,i,o,a,s){if(a==0||a==t.height)return!1;let l=!1;for(let c=i;c<o;c++){const d=a*t.width+c,u=t.map[d];if(t.map[d-t.width]==u){l=!0;const p=n.nodeAt(u),{top:m,left:_}=t.findCell(u);e.setNodeMarkup(e.mapping.slice(s).map(u+r),null,{...p.attrs,rowspan:a-m}),e.insert(e.mapping.slice(s).map(t.positionAt(a,_,n)),p.type.createAndFill({...p.attrs,rowspan:m+p.attrs.rowspan-a})),c+=p.attrs.colspan-1}}return l}function h0(e,t,n,r,i,o,a,s){if(a==0||a==t.width)return!1;let l=!1;for(let c=i;c<o;c++){const d=c*t.width+a,u=t.map[d];if(t.map[d-1]==u){l=!0;const p=n.nodeAt(u),m=t.colCount(u),_=e.mapping.slice(s).map(u+r);e.setNodeMarkup(_,null,Ki(p.attrs,a-m,p.attrs.colspan-(a-m))),e.insert(_+p.nodeSize,p.type.createAndFill(Ki(p.attrs,0,a-m))),c+=p.attrs.rowspan-1}}return l}function g0(e,t,n,r,i){let o=n?e.doc.nodeAt(n-1):e.doc;if(!o)throw new Error("No table found");let a=Nt.get(o);const{top:s,left:l}=r,c=l+i.width,d=s+i.height,u=e.tr;let p=0;function m(){if(o=n?u.doc.nodeAt(n-1):u.doc,!o)throw new Error("No table found");a=Nt.get(o),p=u.mapping.maps.length}y2(u,a,o,n,c,d,p)&&m(),_0(u,a,o,n,l,c,s,p)&&m(),_0(u,a,o,n,l,c,d,p)&&m(),h0(u,a,o,n,s,d,l,p)&&m(),h0(u,a,o,n,s,d,c,p)&&m();for(let _=s;_<d;_++){const h=a.positionAt(_,l,o),g=a.positionAt(_,c,o);u.replace(u.mapping.slice(p).map(h+n),u.mapping.slice(p).map(g+n),new ne(i.rows[_-s],0,0))}m(),u.setSelection(new it(u.doc.resolve(n+a.positionAt(s,l,o)),u.doc.resolve(n+a.positionAt(d-1,c-1,o)))),t(u)}var C2=Zu({ArrowLeft:Jl("horiz",-1),ArrowRight:Jl("horiz",1),ArrowUp:Jl("vert",-1),ArrowDown:Jl("vert",1),"Shift-ArrowLeft":ec("horiz",-1),"Shift-ArrowRight":ec("horiz",1),"Shift-ArrowUp":ec("vert",-1),"Shift-ArrowDown":ec("vert",1),Backspace:Xl,"Mod-Backspace":Xl,Delete:Xl,"Mod-Delete":Xl});function Zl(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function Jl(e,t){return(n,r,i)=>{if(!i)return!1;const o=n.selection;if(o instanceof it)return Zl(n,r,xe.near(o.$headCell,t));if(e!="horiz"&&!o.empty)return!1;const a=b0(i,e,t);if(a==null)return!1;if(e=="horiz")return Zl(n,r,xe.near(n.doc.resolve(o.head+t),t));{const s=n.doc.resolve(a),l=i0(s,e,t);let c;return l?c=xe.near(l,1):t<0?c=xe.near(n.doc.resolve(s.before(-1)),-1):c=xe.near(n.doc.resolve(s.after(-1)),1),Zl(n,r,c)}}}function ec(e,t){return(n,r,i)=>{if(!i)return!1;const o=n.selection;let a;if(o instanceof it)a=o;else{const l=b0(i,e,t);if(l==null)return!1;a=new it(n.doc.resolve(l))}const s=i0(a.$headCell,e,t);return s?Zl(n,r,new it(a.$anchorCell,s)):!1}}function v2(e,t){const n=e.state.doc,r=Po(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new it(r))),!0):!1}function x2(e,t,n){if(!Jn(e.state))return!1;let r=E2(n);const i=e.state.selection;if(i instanceof it){r||(r={width:1,height:1,rows:[j.from(rm(un(e.state.schema).cell,n))]});const o=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),s=Nt.get(o).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=T2(r,s.right-s.left,s.bottom-s.top),g0(e.state,e.dispatch,a,s,r),!0}else if(r){const o=Ql(e.state),a=o.start(-1);return g0(e.state,e.dispatch,a,Nt.get(o.node(-1)).findCell(o.pos-a),r),!0}else return!1}function N2(e,t){var n;if(t.ctrlKey||t.metaKey)return;const r=E0(e,t.target);let i;if(t.shiftKey&&e.state.selection instanceof it)o(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&r&&(i=Po(e.state.selection.$anchor))!=null&&((n=im(e,t))==null?void 0:n.pos)!=i.pos)o(i,t),t.preventDefault();else if(!r)return;function o(l,c){let d=im(e,c);const u=fi.getState(e.state)==null;if(!d||!nm(l,d))if(u)d=l;else return;const p=new it(l,d);if(u||!e.state.selection.eq(p)){const m=e.state.tr.setSelection(p);u&&m.setMeta(fi,l.pos),e.dispatch(m)}}function a(){e.root.removeEventListener("mouseup",a),e.root.removeEventListener("dragstart",a),e.root.removeEventListener("mousemove",s),fi.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(fi,-1))}function s(l){const c=l,d=fi.getState(e.state);let u;if(d!=null)u=e.state.doc.resolve(d);else if(E0(e,c.target)!=r&&(u=im(e,t),!u))return a();u&&o(u,c)}e.root.addEventListener("mouseup",a),e.root.addEventListener("dragstart",a),e.root.addEventListener("mousemove",s)}function b0(e,t,n){if(!(e.state.selection instanceof ue))return null;const{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){const o=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const s=r.before(i),l=t=="vert"?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(l)?s:null}}return null}function E0(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName=="TD"||t.nodeName=="TH")return t;return null}function im(e,t){const n=e.posAtCoords({left:t.clientX,top:t.clientY});return n&&n?Po(e.state.doc.resolve(n.pos)):null}var R2=class{constructor(t,n){this.node=t,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),om(t,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!=this.node.type?!1:(this.node=t,om(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function om(e,t,n,r,i,o){var a;let s=0,l=!0,c=t.firstChild;const d=e.firstChild;if(d){for(let u=0,p=0;u<d.childCount;u++){const{colspan:m,colwidth:_}=d.child(u).attrs;for(let h=0;h<m;h++,p++){const g=i==p?o:_&&_[h],b=g?g+"px":"";if(s+=g||r,g||(l=!1),c)c.style.width!=b&&(c.style.width=b),c=c.nextSibling;else{const E=document.createElement("col");E.style.width=b,t.appendChild(E)}}}for(;c;){const u=c.nextSibling;(a=c.parentNode)==null||a.removeChild(c),c=u}l?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}var On=new Fe("tableColumnResizing");function A2({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=R2,lastColumnResizable:i=!0}={}){const o=new Ie({key:On,state:{init(a,s){var l,c;const d=(c=(l=o.spec)==null?void 0:l.props)==null?void 0:c.nodeViews,u=un(s.schema).table.name;return r&&d&&(d[u]=(p,m)=>new r(p,n,m)),new O2(-1,!1)},apply(a,s){return s.apply(a)}},props:{attributes:a=>{const s=On.getState(a);return s&&s.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(a,s)=>{I2(a,s,e,i)},mouseleave:a=>{k2(a)},mousedown:(a,s)=>{w2(a,s,t,n)}},decorations:a=>{const s=On.getState(a);if(s&&s.activeHandle>-1)return B2(a,s.activeHandle)},nodeViews:{}}});return o}var O2=class Jd{constructor(t,n){this.activeHandle=t,this.dragging=n}apply(t){const n=this,r=t.getMeta(On);if(r&&r.setHandle!=null)return new Jd(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Jd(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let i=t.mapping.map(n.activeHandle,-1);return tm(t.doc.resolve(i))||(i=-1),new Jd(i,n.dragging)}return n}};function I2(e,t,n,r){if(!e.editable)return;const i=On.getState(e.state);if(i&&!i.dragging){const o=D2(t.target);let a=-1;if(o){const{left:s,right:l}=o.getBoundingClientRect();t.clientX-s<=n?a=S0(e,t,"left",n):l-t.clientX<=n&&(a=S0(e,t,"right",n))}if(a!=i.activeHandle){if(!r&&a!==-1){const s=e.state.doc.resolve(a),l=s.node(-1),c=Nt.get(l),d=s.start(-1);if(c.colCount(s.pos-d)+s.nodeAfter.attrs.colspan-1==c.width-1)return}y0(e,a)}}}function k2(e){if(!e.editable)return;const t=On.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&y0(e,-1)}function w2(e,t,n,r){var i;if(!e.editable)return!1;const o=(i=e.dom.ownerDocument.defaultView)!=null?i:window,a=On.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;const s=e.state.doc.nodeAt(a.activeHandle),l=M2(e,a.activeHandle,s.attrs);e.dispatch(e.state.tr.setMeta(On,{setDragging:{startX:t.clientX,startWidth:l}}));function c(u){o.removeEventListener("mouseup",c),o.removeEventListener("mousemove",d);const p=On.getState(e.state);p?.dragging&&(L2(e,p.activeHandle,T0(p.dragging,u,n)),e.dispatch(e.state.tr.setMeta(On,{setDragging:null})))}function d(u){if(!u.which)return c(u);const p=On.getState(e.state);if(p&&p.dragging){const m=T0(p.dragging,u,n);C0(e,p.activeHandle,m,r)}}return C0(e,a.activeHandle,l,r),o.addEventListener("mouseup",c),o.addEventListener("mousemove",d),t.preventDefault(),!0}function M2(e,t,{colspan:n,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const o=e.domAtPos(t);let s=o.node.childNodes[o.offset].offsetWidth,l=n;if(r)for(let c=0;c<n;c++)r[c]&&(s-=r[c],l--);return s/l}function D2(e){for(;e&&e.nodeName!="TD"&&e.nodeName!="TH";)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}function S0(e,t,n,r){const i=n=="right"?-r:r,o=e.posAtCoords({left:t.clientX+i,top:t.clientY});if(!o)return-1;const{pos:a}=o,s=Po(e.state.doc.resolve(a));if(!s)return-1;if(n=="right")return s.pos;const l=Nt.get(s.node(-1)),c=s.start(-1),d=l.map.indexOf(s.pos-c);return d%l.width==0?-1:c+l.map[d-1]}function T0(e,t,n){const r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function y0(e,t){e.dispatch(e.state.tr.setMeta(On,{setHandle:t}))}function L2(e,t,n){const r=e.state.doc.resolve(t),i=r.node(-1),o=Nt.get(i),a=r.start(-1),s=o.colCount(r.pos-a)+r.nodeAfter.attrs.colspan-1,l=e.state.tr;for(let c=0;c<o.height;c++){const d=c*o.width+s;if(c&&o.map[d]==o.map[d-o.width])continue;const u=o.map[d],p=i.nodeAt(u).attrs,m=p.colspan==1?0:s-o.colCount(u);if(p.colwidth&&p.colwidth[m]==n)continue;const _=p.colwidth?p.colwidth.slice():P2(p.colspan);_[m]=n,l.setNodeMarkup(a+u,null,{...p,colwidth:_})}l.docChanged&&e.dispatch(l)}function C0(e,t,n,r){const i=e.state.doc.resolve(t),o=i.node(-1),a=i.start(-1),s=Nt.get(o).colCount(i.pos-a)+i.nodeAfter.attrs.colspan-1;let l=e.domAtPos(i.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&om(o,l.firstChild,l,r,s,n)}function P2(e){return Array(e).fill(0)}function B2(e,t){var n;const r=[],i=e.doc.resolve(t),o=i.node(-1);if(!o)return Me.empty;const a=Nt.get(o),s=i.start(-1),l=a.colCount(i.pos-s)+i.nodeAfter.attrs.colspan-1;for(let c=0;c<a.height;c++){const d=l+c*a.width;if((l==a.width-1||a.map[d]!=a.map[d+1])&&(c==0||a.map[d]!=a.map[d-a.width])){const u=a.map[d],p=s+u+o.nodeAt(u).nodeSize-1,m=document.createElement("div");m.className="column-resize-handle",(n=On.getState(e))!=null&&n.dragging&&r.push(gt.node(s+u,s+u+o.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),r.push(gt.widget(p,m))}}return Me.create(e.doc,r)}function F2({allowTableNodeSelection:e=!1}={}){return new Ie({key:fi,state:{init(){return null},apply(t,n){const r=t.getMeta(fi);if(r!=null)return r==-1?null:r;if(n==null||!t.docChanged)return n;const{deleted:i,pos:o}=t.mapping.mapResult(n);return i?null:o}},props:{decorations:Xw,handleDOMEvents:{mousedown:N2},createSelectionBetween(t){return fi.getState(t.state)!=null?t.state.selection:null},handleTripleClick:v2,handleKeyDown:C2,handlePaste:x2},appendTransaction(t,n,r){return e2(r,s0(r,n),e)}})}var v0=bt.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{var t,n;const r=e.getAttribute("colwidth"),i=r?r.split(",").map(o=>parseInt(o,10)):null;if(!i){const o=(t=e.closest("table"))==null?void 0:t.querySelectorAll("colgroup > col"),a=Array.from(((n=e.parentElement)==null?void 0:n.children)||[]).indexOf(e);if(a&&a>-1&&o&&o[a]){const s=o[a].getAttribute("width");return s?[parseInt(s,10)]:null}}return i}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:e}){return["td",Pe(this.options.HTMLAttributes,e),0]}}),x0=bt.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:e}){return["th",Pe(this.options.HTMLAttributes,e),0]}}),N0=bt.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:e}){return["tr",Pe(this.options.HTMLAttributes,e),0]}});function am(e,t){return t?["width",`${Math.max(t,e)}px`]:["min-width",`${e}px`]}function R0(e,t,n,r,i,o){var a;let s=0,l=!0,c=t.firstChild;const d=e.firstChild;if(d!==null)for(let u=0,p=0;u<d.childCount;u+=1){const{colspan:m,colwidth:_}=d.child(u).attrs;for(let h=0;h<m;h+=1,p+=1){const g=i===p?o:_&&_[h],b=g?`${g}px`:"";if(s+=g||r,g||(l=!1),c){if(c.style.width!==b){const[E,S]=am(r,g);c.style.setProperty(E,S)}c=c.nextSibling}else{const E=document.createElement("col"),[S,y]=am(r,g);E.style.setProperty(S,y),t.appendChild(E)}}}for(;c;){const u=c.nextSibling;(a=c.parentNode)==null||a.removeChild(c),c=u}l?(n.style.width=`${s}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${s}px`)}var U2=class{constructor(e,t){this.node=e,this.cellMinWidth=t,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")),R0(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,R0(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){const t=e.target,n=this.dom.contains(t),r=this.contentDOM.contains(t);return!!(n&&!r&&(e.type==="attributes"||e.type==="childList"||e.type==="characterData"))}};function z2(e,t,n,r){let i=0,o=!0;const a=[],s=e.firstChild;if(!s)return{};for(let u=0,p=0;u<s.childCount;u+=1){const{colspan:m,colwidth:_}=s.child(u).attrs;for(let h=0;h<m;h+=1,p+=1){const g=n===p?r:_&&_[h];i+=g||t,g||(o=!1);const[b,E]=am(t,g);a.push(["col",{style:`${b}: ${E}`}])}}const l=o?`${i}px`:"",c=o?"":`${i}px`;return{colgroup:["colgroup",{},...a],tableWidth:l,tableMinWidth:c}}function A0(e,t){return e.createAndFill()}function H2(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;const t={};return Object.keys(e.nodes).forEach(n=>{const r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function G2(e,t,n,r,i){const o=H2(e),a=[],s=[];for(let c=0;c<n;c+=1){const d=A0(o.cell);if(d&&s.push(d),r){const u=A0(o.header_cell);u&&a.push(u)}}const l=[];for(let c=0;c<t;c+=1)l.push(o.row.createChecked(null,r&&c===0?a:s));return o.table.createChecked(null,l)}function V2(e){return e instanceof it}var tc=({editor:e})=>{const{selection:t}=e.state;if(!V2(t))return!1;let n=0;const r=Xg(t.ranges[0].$from,o=>o.type.name==="table");return r?.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(n+=1)}),n===t.ranges.length?(e.commands.deleteTable(),!0):!1},O0=bt.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:U2,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:e,HTMLAttributes:t}){const{colgroup:n,tableWidth:r,tableMinWidth:i}=z2(e,this.options.cellMinWidth);return["table",Pe(this.options.HTMLAttributes,t,{style:r?`width: ${r}`:`min-width: ${i}`}),n,["tbody",0]]},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:o})=>{const a=G2(o.schema,e,t,n);if(i){const s=r.selection.from+1;r.replaceSelectionWith(a).scrollIntoView().setSelection(ue.near(r.doc.resolve(s)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>r2(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>i2(e,t),deleteColumn:()=>({state:e,dispatch:t})=>a2(e,t),addRowBefore:()=>({state:e,dispatch:t})=>l2(e,t),addRowAfter:()=>({state:e,dispatch:t})=>c2(e,t),deleteRow:()=>({state:e,dispatch:t})=>u2(e,t),deleteTable:()=>({state:e,dispatch:t})=>b2(e,t),mergeCells:()=>({state:e,dispatch:t})=>u0(e,t),splitCell:()=>({state:e,dispatch:t})=>p0(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>ts("column")(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>ts("row")(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>h2(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>u0(e,t)?!0:p0(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>f2(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>f0(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>f0(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&s0(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){const r=it.create(t.doc,e.anchorCell,e.headCell);t.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:tc,"Mod-Backspace":tc,Delete:tc,"Mod-Delete":tc}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[A2({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],F2({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(e){const t={name:e.name,options:e.options,storage:e.storage};return{tableRole:Qe(Ee(e,"tableRole",t))}}});Re.create({name:"tableKit",addExtensions(){const e=[];return this.options.table!==!1&&e.push(O0.configure(this.options.table)),this.options.tableCell!==!1&&e.push(v0.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(x0.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(N0.configure(this.options.tableRow)),e}});const ut={USER_INSERTION:"userInsertion",USER_DELETION:"userDeletion",AI_INSERTION:"aiInsertion",AI_DELETION:"aiDeletion"},I0="redlineHandledTextInput",ns="skipRedlineInsertionTracking";function sm(e,t,n){let r=!1;return e.doc.nodesBetween(t,n,i=>{if(i.marks.some(o=>o.type.name===ut.USER_INSERTION||o.type.name===ut.AI_INSERTION))return r=!0,!1}),r}function lm(e,t,n){let r=!1;return e.doc.nodesBetween(t,n,i=>{const o=i.marks.find(a=>a.type.name===ut.USER_INSERTION||a.type.name===ut.AI_INSERTION);if(o)return r=!!o.attrs.formatChanges,!1}),r}function nc(e,t,n){let r=!1;return e.doc.nodesBetween(Math.max(0,t-1),Math.min(e.doc.content.size,n+1),(i,o)=>{if(i.type.name==="codeBlock"){const a=o,s=o+i.nodeSize;if(t>=a&&n<=s)return r=!0,!1}}),r}function Y2(e,t,n){let r=!1;return e.doc.nodesBetween(t,n,i=>{if(i.marks.some(o=>o.type.name===ut.USER_DELETION||o.type.name===ut.AI_DELETION))return r=!0,!1}),r}function Bo(e,t,n,r,i,o=!1,a){const s=[],l=[];e.doc.descendants((u,p)=>{if(!u.isText)return;const m=u.marks.find(_=>_.type.name===r&&_.attrs.userId===i);if(m){if(o&&m.attrs.formatChanges)return;const _=p,h=p+u.nodeSize,g=t-h,b=_-n,E=g>=0&&g<=4,S=b>=0&&b<=4;(E||S)&&(l.push({from:_,to:h,timestamp:m.attrs.timestamp,isAdjacent:!0}),s.push(m.attrs.timestamp))}});const c=[],d=l.map(({from:u,to:p})=>({from:u,to:p})).sort((u,p)=>u.from-p.from||u.to-p.to);for(const u of d){const p=c[c.length-1];if(!p){c.push({...u});continue}if(u.from<=p.to){p.to=Math.max(p.to,u.to);continue}c.push({...u})}return{timestamp:s.length>0?s.sort()[0]:new Date().toISOString(),adjacentRanges:c}}function rs(e,t,n){const r=t==="ai"?n==="insertion"?ut.AI_INSERTION:ut.AI_DELETION:n==="insertion"?ut.USER_INSERTION:ut.USER_DELETION;return e.schema.marks[r]||null}const $2=Re.create({name:"redlinePlugin",addOptions(){return{isActive:!1,mode:"user",currentEntity:{id:"anonymous",name:"Anonymous"}}},addStorage(){return{isActive:this.options.isActive,mode:this.options.mode}},addCommands(){return{toggleRedlineMode:(e,t="user")=>({editor:n})=>{const r=n.storage.redline;return r.isActive=e,r.mode=t,!0}}},addProseMirrorPlugins(){const e=this.options,t=()=>this.editor?.storage?.redline||{isActive:this.options.isActive,mode:this.options.mode};return[Gg({Backspace:(n,r)=>{const i=t();if(!i?.isActive)return!1;const{$from:o,$to:a}=n.selection,s=n.selection.empty?o.pos-1:o.pos,l=a.pos;if(s<0||!n.doc.textBetween(s,l)||nc(n,s,l)||sm(n,s,l)&&!lm(n,s,l))return!1;if(!r)return!0;const d=i.mode||"user",{id:u,name:p}=e.currentEntity,m=rs(n,d,"deletion");if(!m)return!1;const _=d==="ai"?ut.AI_DELETION:ut.USER_DELETION,{timestamp:h,adjacentRanges:g}=Bo(n,s,l,_,u),b=n.tr,E=d==="ai"?n.schema.marks[ut.AI_INSERTION]:n.schema.marks[ut.USER_INSERTION];if(E){const S=[];n.doc.nodesBetween(Math.max(0,s-100),Math.min(n.doc.content.size,l+100),(x,v)=>{const C=x.marks.find(O=>O.type===E&&O.attrs.formatChanges);if(C&&x.text){const O=v,w=v+x.text.length;O<l&&w>s&&S.push({from:O,to:w,mark:C})}});const y=[];let T=0;for(;T<S.length;){const x=S[T],v=x.from;let C=x.to,O=T+1;for(;O<S.length&&S[O].from===C&&S[O].mark.attrs.formatChanges===x.mark.attrs.formatChanges&&S[O].mark.attrs.timestamp===x.mark.attrs.timestamp;)C=S[O].to,O++;y.push({from:v,to:C,mark:x.mark}),T=O}y.forEach(({from:x,to:v,mark:C})=>{const O=x<s,w=v>l;O||w?(b.removeMark(x,v,E),O&&b.addMark(x,s,E.create(C.attrs)),w&&b.addMark(l,v,E.create({...C.attrs,timestamp:new Date().toISOString()}))):b.removeMark(x,v,E)})}for(const S of g)b.removeMark(S.from,S.to,m),b.addMark(S.from,S.to,m.create({userId:u,userName:p,timestamp:h,source:d}));return b.addMark(s,l,m.create({userId:u,userName:p,timestamp:h,source:d})),b.setSelection(ue.create(b.doc,s)),r(b),!0},Delete:(n,r)=>{const i=t();if(!i?.isActive)return!1;const{$from:o,$to:a}=n.selection,s=o.pos,l=n.selection.empty?a.pos+1:a.pos;if(l>n.doc.content.size||!n.doc.textBetween(s,l)||nc(n,s,l)||sm(n,s,l)&&!lm(n,s,l))return!1;if(!r)return!0;const d=i.mode||"user",{id:u,name:p}=e.currentEntity,m=rs(n,d,"deletion");if(!m)return!1;const _=d==="ai"?ut.AI_DELETION:ut.USER_DELETION,{timestamp:h,adjacentRanges:g}=Bo(n,s,l,_,u),b=n.tr,E=d==="ai"?n.schema.marks[ut.AI_INSERTION]:n.schema.marks[ut.USER_INSERTION];if(E){const S=[];n.doc.nodesBetween(Math.max(0,s-100),Math.min(n.doc.content.size,l+100),(x,v)=>{const C=x.marks.find(O=>O.type===E&&O.attrs.formatChanges);if(C&&x.text){const O=v,w=v+x.text.length;O<l&&w>s&&S.push({from:O,to:w,mark:C})}});const y=[];let T=0;for(;T<S.length;){const x=S[T],v=x.from;let C=x.to,O=T+1;for(;O<S.length&&S[O].from===C&&S[O].mark.attrs.formatChanges===x.mark.attrs.formatChanges&&S[O].mark.attrs.timestamp===x.mark.attrs.timestamp;)C=S[O].to,O++;y.push({from:v,to:C,mark:x.mark}),T=O}y.forEach(({from:x,to:v,mark:C})=>{const O=x<s,w=v>l;O||w?(b.removeMark(x,v,E),O&&b.addMark(x,s,E.create(C.attrs)),w&&b.addMark(l,v,E.create({...C.attrs,timestamp:new Date().toISOString()}))):b.removeMark(x,v,E)})}for(const S of g)b.removeMark(S.from,S.to,m),b.addMark(S.from,S.to,m.create({userId:u,userName:p,timestamp:h,source:d}));return b.addMark(s,l,m.create({userId:u,userName:p,timestamp:h,source:d})),r(b),!0}}),new Ie({props:{handleTextInput:(n,r,i,o)=>{const a=t();if(!a?.isActive||r>=i||!o)return!1;const s=n.state;if(nc(s,r,i))return!1;const l=a.mode||"user",{id:c,name:d}=e.currentEntity,u=rs(s,l,"insertion"),p=rs(s,l,"deletion");if(!u||!p)return!1;const m=l==="ai"?ut.AI_INSERTION:ut.USER_INSERTION,_=l==="ai"?ut.AI_DELETION:ut.USER_DELETION,h=s.tr.setMeta(I0,!0);if(sm(s,r,i)&&!lm(s,r,i)){const{timestamp:T,adjacentRanges:x}=Bo(s,r,i,m,c,!0);for(const v of x)h.removeMark(v.from,v.to,u),h.addMark(v.from,v.to,u.create({userId:c,userName:d,timestamp:T,source:l}));return h.insertText(o,r,i),h.addMark(r,r+o.length,u.create({userId:c,userName:d,timestamp:T,source:l})),h.setSelection(ue.create(h.doc,r+o.length)),n.dispatch(h),!0}const{timestamp:g,adjacentRanges:b}=Bo(s,r,i,_,c);for(const T of b)h.removeMark(T.from,T.to,p),h.addMark(T.from,T.to,p.create({userId:c,userName:d,timestamp:g,source:l}));h.addMark(r,i,p.create({userId:c,userName:d,timestamp:g,source:l}));const E=i,{timestamp:S,adjacentRanges:y}=Bo(s,E,E,m,c,!0);for(const T of y)h.removeMark(T.from,T.to,u),h.addMark(T.from,T.to,u.create({userId:c,userName:d,timestamp:S,source:l}));return h.insertText(o,E),h.addMark(E,E+o.length,u.create({userId:c,userName:d,timestamp:S,source:l})),h.setSelection(ue.create(h.doc,E+o.length)),n.dispatch(h),!0}}}),new Ie({appendTransaction:(n,r,i)=>{if(n.some(p=>p.getMeta(I0))||n.some(p=>p.getMeta(ns)))return null;const o=t();if(!o?.isActive)return null;const{id:a,name:s}=this.options.currentEntity,l=o.mode||"user",c=rs(i,l,"insertion");if(!c)return null;const d=i.tr;let u=!1;return n.forEach(p=>{p.mapping.maps.forEach(m=>{m.forEach((_,h,g,b)=>{if(_===h&&g<b){if(nc(i,g,b))return;if(Y2(i,g,b)){const T=l==="ai"?ut.AI_DELETION:ut.USER_DELETION,x=i.schema.marks[T];x&&(d.removeMark(g,b,x),u=!0)}const E=l==="ai"?ut.AI_INSERTION:ut.USER_INSERTION,{timestamp:S,adjacentRanges:y}=Bo(i,g,b,E,a,!0);for(const T of y)d.removeMark(T.from,T.to,c),d.addMark(T.from,T.to,c.create({userId:a,userName:s,timestamp:S,source:l}));d.addMark(g,b,c.create({userId:a,userName:s,timestamp:S,source:l})),u=!0}})})}),u?d:null}})]}}),Fo="data-redline-row-action",Lt="data-redline-column-action",pn="data-redline-column-id",k0=e=>!!(e&&e.type.name==="table"&&(e.attrs[ye]===cn||e.attrs[ye]===dn)),Uo="__%__",W2=O0.extend({addCommands(){return{...this.parent?.(),insertTableFromData:({tableType:e,data:t,columns:n,options:r={}})=>({state:i,tr:o,editor:a})=>{if(!t||t.length===0)return!1;const{withHeaderRow:s=!0,tableName:l=null}=r,{schema:c}=i,d=c.nodes.table,u=c.nodes.tableRow,p=c.nodes.tableCell,m=c.nodes.tableHeader,_=c.nodes.paragraph;if(!d||!u||!p||!_)return!1;const h=[];if(s&&m){const y=n.map(T=>{const x=c.text(T.label),v=_.create(null,x);return m.create({[Mo]:T.key},v)});h.push(u.create({[wo]:`header${Uo}row`},y))}t.forEach(y=>{const T=n.map(x=>{const v=String(y[x.label]??""),C=v?c.text(v):null,O=_.create(null,C);return p.create({[Yi]:`${y.__id}${Uo}${x.key}`},O)});h.push(u.create({[wo]:y.__id},T))});const g=a.storage?.redline,b={isVariableTable:!0,[Ya]:e,[jb]:l??""};if(g?.isActive){const T=a.extensionManager.extensions.find(v=>v.name==="redline")?.options?.currentEntity||{id:"unknown",name:"User"},x=g.mode==="ai"?dn:cn;Object.assign(b,{[ye]:x,[Ve]:T.id,[je]:T.name,[Ye]:new Date().toISOString()})}const E=d.create(b,h),{from:S}=i.selection;return o.insert(S,E),o.setMeta(ns,!0),!0},insertColumnsFromAgreement:({colIndex:e,tableId:t,columns:n,variableTableData:r})=>({state:i,tr:o,dispatch:a})=>{if(!a||!n||n.length===0)return!1;const{schema:s}=i,l=s.nodes.tableCell,c=s.nodes.tableHeader,d=s.nodes.paragraph;if(!l||!d)return!1;let u=-1,p=null,m="";i.doc.descendants((v,C)=>u!==-1?!1:v.type.name==="table"&&v.attrs[Hn]===t?(u=C,p=v,m=v.attrs[Ya]??"",!1):!0);const _=new Map;if(r&&m&&r[m]&&r[m].forEach(v=>{const C=v.__id;C&&_.set(C,v)}),u===-1||!p)return!1;const h=this.editor.storage?.redline,b=this.editor.extensionManager.extensions.find(v=>v.name==="redline")?.options?.currentEntity||{id:"unknown",name:"User"},E=h?.isActive?h.mode==="ai"?dn:cn:null,S=E&&!k0(p),y=new Date().toISOString(),T=n.map((v,C)=>`${v.key||"column"}-${Date.now()}-${C}-${Math.random().toString(36).slice(2,7)}`),x=[];p.forEach((v,C)=>{v.type.name==="tableRow"&&x.push({rowPos:u+1+C,rowNode:v})});for(let v=x.length-1;v>=0;v--){const{rowPos:C,rowNode:O}=x[v],w=O.child(0)?.type.name==="tableHeader";let z=C+1,N=0,P=0;O.forEach((R,k)=>{P===e&&(z=C+1+k),P<=e&&(N=k+R.nodeSize),P++}),e>=O.childCount&&(z=C+1+N),n.map((R,k)=>{const M=S?{[ye]:E,[Ve]:b.id,[je]:b.name,[Ye]:y,[Lt]:"add",[pn]:T[k]}:{};if(w&&c){const V=s.text(R.label),q=d.create(null,V);return c.create({[Mo]:R.key,...M},q)}const B=O.attrs[wo]??"",D=_.has(B)?String(_.get(B)[R.key]??""):"",U=D?s.text(D):null,H=d.create(null,U);return l.create({[Yi]:`${B}${Uo}${R.key}`,...M},H)}).reverse().forEach(R=>{o.insert(z,R)})}return o.setMeta(ns,!0),o.setMeta("addToHistory",!0),a(o),!0},insertRowsFromAgreement:({rowIndex:e,tableId:t,rowIds:n,variableTableData:r})=>({state:i,tr:o,dispatch:a,editor:s})=>{if(!a||!n||n.length===0)return!1;const{schema:l}=i,c=l.nodes.tableCell,d=l.nodes.tableRow,u=l.nodes.paragraph;if(!c||!d||!u)return!1;let p=-1,m=null,_="";if(i.doc.descendants((I,R)=>p!==-1?!1:I.type.name==="table"&&I.attrs[Hn]===t?(p=R,m=I,_=I.attrs[Ya]??"",!1):!0),p===-1||!m)return!1;const h=[],g=m.child(0);if(g&&g.type.name==="tableRow"&&g.forEach(I=>{if(I.type.name==="tableHeader"){const R=I.attrs[Mo];R&&h.push(R)}}),h.length===0)return!1;const b=new Map;(r?.[_]??[]).forEach(I=>{const R=String(I.__id??"");R&&b.set(R,I)});let S=0,y=0,T=0;m.forEach((I,R)=>{if(I.child(0)?.type.name==="tableHeader"){T=I.nodeSize;return}y<e&&(S=R+I.nodeSize,y++)});const x=p+1+(e===0?T:S),v=s.storage?.redline,O=s.extensionManager.extensions.find(I=>I.name==="redline")?.options?.currentEntity||{id:"unknown",name:"User"},w=v?.isActive?v.mode==="ai"?dn:cn:null,z=new Date().toISOString(),N=w&&!k0(m),P=[];for(const I of n){const R=b.get(I)??{},k=h.map(M=>{const B=String(R[M]??"").trim(),D=B.length>0?l.text(B):null,U=u.create(null,D);return c.create({[Yi]:`${I}${Uo}${M}`},U)});P.push(d.create({[wo]:I,...N?{[ye]:w,[Ve]:O.id,[je]:O.name,[Ye]:z,[Fo]:"add"}:{}},k))}for(let I=P.length-1;I>=0;I--)o.insert(x,P[I]);return o.setMeta("addToHistory",!0),a(o),!0},updateTableValues:e=>({state:t,tr:n,dispatch:r})=>{if(!r)return!1;const i=[];t.doc.descendants((a,s)=>a.type.name==="table"?(i.push({pos:s,node:a}),!1):!0);let o=!1;for(let a=i.length-1;a>=0;a--){const{pos:s,node:l}=i[a],c=l.attrs[Ya];if(!c)continue;const d=e[c];if(!d||d.length===0)continue;const u=new Map;d.forEach(_=>{const h=String(_.__id??"");h&&u.set(h,_)});const p=[];let m=1;l.forEach(_=>{if(_.type.name==="tableRow"){const h=_.attrs[wo];let g=1;_.forEach(b=>{if(b.type.name==="tableCell"){const E=b.attrs[Yi];if(E&&h&&u.has(h)){const S=E.indexOf(Uo);if(S!==-1){const y=E.slice(S+Uo.length);p.push({absPos:s+m+g,colKey:y,rowId:h})}}}g+=b.nodeSize})}m+=_.nodeSize}),p.sort((_,h)=>h.absPos-_.absPos);for(const{absPos:_,colKey:h,rowId:g}of p){const b=u.get(g);if(!b||!(h in b))continue;const E=String(b[h]??"").trim(),S=t.doc.nodeAt(_);if(!S||!S.firstChild||S.firstChild.textContent.trim()===E)continue;const x=n.mapping.map(_)+1,v=S.firstChild,C=E.length>0?t.schema.text(E):null,O=t.schema.nodes.paragraph.create(null,C);n.replaceWith(x,x+v.nodeSize,O),o=!0}}return o&&(n.setMeta("addToHistory",!1),r(n)),!0}}},addProseMirrorPlugins(){const e=new Fe("variableTableEditable"),t=new Fe("variableTableId"),n=(typeof this.parent=="function"?this.parent():[])||[],r=i=>{for(let o=i.depth;o>0;o--){const a=i.node(o);if(a.type.name==="tableCell"&&a.attrs[Yi]||a.type.name==="tableHeader"&&a.attrs[Mo])return!0}return!1};return[...n,new Ie({key:t,appendTransaction(i,o,a){if(i.some(c=>c.getMeta(t))||!i.some(c=>c.docChanged))return null;const s=[];if(a.doc.descendants((c,d)=>c.type.name!=="table"?!0:(c.attrs[Hn]||s.push({pos:d,node:c}),!1)),s.length===0)return null;const l=a.tr;for(let c=s.length-1;c>=0;c--){const{pos:d,node:u}=s[c],p=typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`table-${Date.now()}-${Math.random().toString(36).slice(2,9)}`;l.setNodeMarkup(d,void 0,{...u.attrs,[Hn]:p})}return l.setMeta(t,!0),l.setMeta("addToHistory",!1),l}}),new Ie({key:e,handleDOMEvents:{mousedown(i,o){const a=o.target;if(!a)return!1;const s=a.closest(`td[${Yi}], th[${Mo}]`);if(!s||!s.closest("table"))return!1;let c=null,d=0;if(i.state.doc.descendants((_,h)=>c!==null?!1:_.type.name==="table"?(c=h,d=_.nodeSize,!1):!0),c===null)return!1;const u=c+d,p=Math.min(u,i.state.doc.content.size),m=i.state.tr.setSelection(ue.near(i.state.doc.resolve(p)));return i.dispatch(m),i.focus(),o.preventDefault(),!0}},props:{handleKeyDown(i,o){const{$from:a}=i.state.selection;return r(a)?["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Tab","Escape","Home","End","PageUp","PageDown"].includes(o.key)?!1:(o.preventDefault(),!0):!1},handlePaste(i){const{$from:o}=i.state.selection;return r(o)}}})]},addAttributes(){return{...this.parent?.(),isVariableTable:{default:!1},[Hn]:{default:null,parseHTML:e=>e.getAttribute(Hn),renderHTML:e=>e[Hn]?{[Hn]:e[Hn]}:{}},[Ya]:{default:null},[jb]:{default:null},[ye]:{default:null,parseHTML:e=>e.getAttribute(ye),renderHTML:e=>e[ye]?{[ye]:e[ye]}:{}},[Ve]:{default:null,parseHTML:e=>e.getAttribute(Ve),renderHTML:e=>e[Ve]?{[Ve]:e[Ve]}:{}},[je]:{default:null,parseHTML:e=>e.getAttribute(je),renderHTML:e=>e[je]?{[je]:e[je]}:{}},[Ye]:{default:null,parseHTML:e=>{const t=e.getAttribute(Ye);return t?parseInt(t,10):null},renderHTML:e=>e[Ye]?{[Ye]:e[Ye]}:{}}}},renderHTML({HTMLAttributes:e}){const t={...e};return t.isVariableTable&&(t.class=(t.class||"")+" variable-table-readonly",t.style=(t.style||"")+"background-color: #f9fafb;"),t[ye]===cn?(t.class=(t.class||"")+` ${Qb}`,t.style=(t.style||"")+"outline: 2px solid #008000; outline-offset: 2px;"):t[ye]===$i?(t.class=(t.class||"")+` ${Xb}`,t.style=(t.style||"")+"outline: 2px solid #ef4444; outline-offset: 2px; opacity: 0.7;"):t[ye]===dn?(t.class=(t.class||"")+` ${Qb}`,t.style=(t.style||"")+"outline: 2px solid #10b981; outline-offset: 2px;"):t[ye]===Wi&&(t.class=(t.class||"")+` ${Xb}`,t.style=(t.style||"")+"outline: 2px solid #f59e0b; outline-offset: 2px; opacity: 0.7;"),["table",t,0]}}),j2=N0.extend({addAttributes(){return{...this.parent?.(),[Hn]:{default:null},[wo]:{default:null},[ye]:{default:null,parseHTML:e=>e.getAttribute(ye),renderHTML:e=>e[ye]?{[ye]:e[ye]}:{}},[Ve]:{default:null,parseHTML:e=>e.getAttribute(Ve),renderHTML:e=>e[Ve]?{[Ve]:e[Ve]}:{}},[je]:{default:null,parseHTML:e=>e.getAttribute(je),renderHTML:e=>e[je]?{[je]:e[je]}:{}},[Ye]:{default:null,parseHTML:e=>e.getAttribute(Ye),renderHTML:e=>e[Ye]?{[Ye]:e[Ye]}:{}},[Fo]:{default:null,parseHTML:e=>e.getAttribute(Fo),renderHTML:e=>e[Fo]?{[Fo]:e[Fo]}:{}},[Lt]:{default:null,parseHTML:e=>e.getAttribute(Lt),renderHTML:e=>e[Lt]?{[Lt]:e[Lt]}:{}},[pn]:{default:null,parseHTML:e=>e.getAttribute(pn),renderHTML:e=>e[pn]?{[pn]:e[pn]}:{}}}},renderHTML({HTMLAttributes:e}){const t={...e};return t[ye]===cn||t[ye]===dn?(t.class=(t.class||"")+" redline-row-insertion",t.style=(t.style||"")+"background-color: rgba(34, 197, 94, 0.08);"):(t[ye]===$i||t[ye]===Wi)&&(t.class=(t.class||"")+" redline-row-deletion",t.style=(t.style||"")+"background-color: rgba(239, 68, 68, 0.08);"),["tr",t,0]}}),q2=x0.extend({addAttributes(){return{...this.parent?this.parent():{},[Hn]:{default:null},[Mo]:{default:null},[qb]:{default:null},colspan:{default:1},rowspan:{default:1},colwidth:{default:null},backgroundColor:{default:null,parseHTML:e=>e.style.backgroundColor,renderHTML:e=>{const t=e.backgroundColor;return t?{style:`background-color: ${t};`}:{}}},[ye]:{default:null,parseHTML:e=>e.getAttribute(ye),renderHTML:e=>e[ye]?{[ye]:e[ye]}:{}},[Ve]:{default:null,parseHTML:e=>e.getAttribute(Ve),renderHTML:e=>e[Ve]?{[Ve]:e[Ve]}:{}},[je]:{default:null,parseHTML:e=>e.getAttribute(je),renderHTML:e=>e[je]?{[je]:e[je]}:{}},[Ye]:{default:null,parseHTML:e=>e.getAttribute(Ye),renderHTML:e=>e[Ye]?{[Ye]:e[Ye]}:{}},[Lt]:{default:null,parseHTML:e=>e.getAttribute(Lt),renderHTML:e=>e[Lt]?{[Lt]:e[Lt]}:{}},[pn]:{default:null,parseHTML:e=>e.getAttribute(pn),renderHTML:e=>e[pn]?{[pn]:e[pn]}:{}}}},parseHTML(){return[{tag:"th",getAttrs:e=>{if(typeof e=="string")return{};const t=e;return{colspan:parseInt(t.getAttribute("colspan")||"1",10),rowspan:parseInt(t.getAttribute("rowspan")||"1",10),colwidth:t.getAttribute("colwidth")?t.getAttribute("colwidth")?.split(",").map(n=>parseInt(n,10)):null}}}]},renderHTML({HTMLAttributes:e}){const t={...e};return delete t.backgroundColor,t[Lt]==="add"&&(t[ye]===cn||t[ye]===dn)?(t.class=(t.class||"")+" redline-column-insertion",t.style=(t.style||"")+"background-color: rgba(34, 197, 94, 0.12);"):t[Lt]==="delete"&&(t[ye]===$i||t[ye]===Wi)&&(t.class=(t.class||"")+" redline-column-deletion",t.style=(t.style||"")+"background-color: rgba(239, 68, 68, 0.12);opacity: 0.85;"),["th",t,0]}}),K2=v0.extend({addAttributes(){return{...this.parent?this.parent():{},[Hn]:{default:null},[Yi]:{default:null},[qb]:{default:null},colspan:{default:1},rowspan:{default:1},colwidth:{default:null},backgroundColor:{default:null,parseHTML:e=>e.style.backgroundColor,renderHTML:e=>{const t=e.backgroundColor;return t?{style:`background-color: ${t};`}:{}}},[ye]:{default:null,parseHTML:e=>e.getAttribute(ye),renderHTML:e=>e[ye]?{[ye]:e[ye]}:{}},[Ve]:{default:null,parseHTML:e=>e.getAttribute(Ve),renderHTML:e=>e[Ve]?{[Ve]:e[Ve]}:{}},[je]:{default:null,parseHTML:e=>e.getAttribute(je),renderHTML:e=>e[je]?{[je]:e[je]}:{}},[Ye]:{default:null,parseHTML:e=>e.getAttribute(Ye),renderHTML:e=>e[Ye]?{[Ye]:e[Ye]}:{}},[Lt]:{default:null,parseHTML:e=>e.getAttribute(Lt),renderHTML:e=>e[Lt]?{[Lt]:e[Lt]}:{}},[pn]:{default:null,parseHTML:e=>e.getAttribute(pn),renderHTML:e=>e[pn]?{[pn]:e[pn]}:{}}}},parseHTML(){return[{tag:"td",getAttrs:e=>{if(typeof e=="string")return{};const t=e;return{colspan:parseInt(t.getAttribute("colspan")||"1",10),rowspan:parseInt(t.getAttribute("rowspan")||"1",10),colwidth:t.getAttribute("colwidth")?t.getAttribute("colwidth")?.split(",").map(n=>parseInt(n,10)):null}}}]},renderHTML({HTMLAttributes:e}){const t={...e};return delete t.backgroundColor,t[Lt]==="add"&&(t[ye]===cn||t[ye]===dn)?(t.class=(t.class||"")+" redline-column-insertion",t.style=(t.style||"")+"background-color: rgba(34, 197, 94, 0.12);"):t[Lt]==="delete"&&(t[ye]===$i||t[ye]===Wi)&&(t.class=(t.class||"")+" redline-column-deletion",t.style=(t.style||"")+"background-color: rgba(239, 68, 68, 0.12);opacity: 0.85;"),["td",t,0]}}),Q2=/\{\{([a-zA-Z0-9_-]+)\}\}$/,X2=bt.create({name:"variableText",group:"inline",inline:!0,atom:!0,selectable:!0,marks:"_",addOptions(){return{enabled:!1,variableValues:{}}},addStorage(){return{variableValues:this.options.variableValues}},addAttributes(){return{variableName:{default:"",parseHTML:e=>e.getAttribute(Vi),renderHTML:e=>({[Vi]:e.variableName})},value:{default:"",parseHTML:e=>e.getAttribute(ko)||"",renderHTML:e=>({[ko]:e.value})},redlineType:{default:null,parseHTML:e=>e.getAttribute(ye),renderHTML:e=>e.redlineType?{[ye]:e.redlineType}:{}},redlineUserId:{default:null,parseHTML:e=>e.getAttribute(Ve),renderHTML:e=>e.redlineUserId?{[Ve]:e.redlineUserId}:{}},redlineUserName:{default:null,parseHTML:e=>e.getAttribute(je),renderHTML:e=>e.redlineUserName?{[je]:e.redlineUserName}:{}},redlineTimestamp:{default:null,parseHTML:e=>e.getAttribute(Ye),renderHTML:e=>e.redlineTimestamp?{[Ye]:e.redlineTimestamp}:{}},redlineAction:{default:null,parseHTML:e=>e.getAttribute("data-variable-action"),renderHTML:e=>e.redlineAction?{"data-variable-action":e.redlineAction}:{}},redlinePreviousAttrs:{default:null,parseHTML:e=>e.getAttribute("data-variable-previous-attrs"),renderHTML:e=>e.redlinePreviousAttrs?{"data-variable-previous-attrs":e.redlinePreviousAttrs}:{}}}},parseHTML(){return[{tag:`span[${Vi}]`}]},renderHTML({node:e}){const{variableName:t,value:n}=e.attrs,r=n||`{{${t}}}`;return["span",{[Vi]:t,[ko]:n,class:Wb,contenteditable:"false"},r]},addNodeView(){return({node:e})=>{const{variableName:t,value:n}=e.attrs,r=document.createElement("span");r.className=Wb,r.contentEditable="false",r.setAttribute(Vi,t),r.setAttribute(ko,n),r.textContent=n||`{{${t}}}`,e.attrs.redlineType&&r.setAttribute(ye,e.attrs.redlineType),e.attrs.redlineUserId&&r.setAttribute(Ve,e.attrs.redlineUserId),e.attrs.redlineUserName&&r.setAttribute(je,e.attrs.redlineUserName),e.attrs.redlineTimestamp&&r.setAttribute(Ye,e.attrs.redlineTimestamp),e.attrs.redlineAction&&r.setAttribute("data-variable-action",e.attrs.redlineAction),e.attrs.redlinePreviousAttrs&&r.setAttribute("data-variable-previous-attrs",e.attrs.redlinePreviousAttrs);const i=a=>{a.marks&&a.marks.length>0&&a.marks.forEach(s=>{if(s.type.name==="bold"&&(r.style.fontWeight="bold"),s.type.name==="italic"&&(r.style.fontStyle="italic"),s.type.name==="underline"){const l=r.style.textDecoration;r.style.textDecoration=l?`${l} underline`:"underline"}if(s.type.name==="strike"){const l=r.style.textDecoration;r.style.textDecoration=l?`${l} line-through`:"line-through"}s.type.name==="textStyle"&&(s.attrs.fontSize&&(r.style.fontSize=s.attrs.fontSize),s.attrs.color&&(r.style.color=s.attrs.color),s.attrs.fontFamily&&(r.style.fontFamily=s.attrs.fontFamily),s.attrs.backgroundColor&&(r.style.backgroundColor=s.attrs.backgroundColor))})};i(e);const o=()=>{const a=window.getSelection();a&&a.rangeCount>0&&a.getRangeAt(0).intersectsNode(r)?r.classList.add("variable-text-selected"):r.classList.remove("variable-text-selected")};return document.addEventListener("selectionchange",o),{dom:r,destroy:()=>{document.removeEventListener("selectionchange",o)},update:a=>{if(a.type.name!=="variableText")return!1;const{variableName:s,value:l}=a.attrs;return(r.getAttribute(ko)!==l||r.getAttribute(Vi)!==s)&&(r.setAttribute(Vi,s),r.setAttribute(ko,l),r.textContent=l||`{{${s}}}`),a.attrs.redlineType?r.setAttribute(ye,a.attrs.redlineType):r.removeAttribute(ye),a.attrs.redlineUserId?r.setAttribute(Ve,a.attrs.redlineUserId):r.removeAttribute(Ve),a.attrs.redlineUserName?r.setAttribute(je,a.attrs.redlineUserName):r.removeAttribute(je),a.attrs.redlineTimestamp?r.setAttribute(Ye,a.attrs.redlineTimestamp):r.removeAttribute(Ye),a.attrs.redlineAction?r.setAttribute("data-variable-action",a.attrs.redlineAction):r.removeAttribute("data-variable-action"),a.attrs.redlinePreviousAttrs?r.setAttribute("data-variable-previous-attrs",a.attrs.redlinePreviousAttrs):r.removeAttribute("data-variable-previous-attrs"),r.style.fontWeight="",r.style.fontStyle="",r.style.textDecoration="",r.style.fontSize="",r.style.color="",r.style.fontFamily="",r.style.backgroundColor="",i(a),!0}}}},addCommands(){return{insertVariable:(e,t)=>({commands:n,editor:r})=>{const i=t||this.storage.variableValues[e]||"",o=r.storage?.redline,s=r.extensionManager.extensions.find(c=>c.name==="redline")?.options?.currentEntity||{id:"unknown",name:"User"},l=o?.isActive?o.mode==="ai"?dn:cn:null;return n.insertContent({type:this.name,attrs:{variableName:e,value:i,...l?{redlineType:l,redlineUserId:s.id,redlineUserName:s.name,redlineTimestamp:new Date().toISOString(),redlineAction:"add"}:{}}})},updateVariableValues:e=>({tr:t,state:n,dispatch:r,editor:i})=>{if(!r)return!1;this.storage.variableValues={...this.storage.variableValues,...e};let o=t,a=!1;const s=i.storage?.redline,c=i.extensionManager.extensions.find(p=>p.name==="redline")?.options?.currentEntity||{id:"unknown",name:"User"},d=s?.isActive?s.mode==="ai"?dn:cn:null,u=[];return n.doc.descendants((p,m)=>{if(p.type.name==="variableText"){const{variableName:_,value:h}=p.attrs,g=e[_];g!==void 0&&g!==h&&u.unshift(m)}}),u.forEach(p=>{const m=n.doc.nodeAt(p);if(m){const{variableName:_}=m.attrs,h=e[_],g={...m.attrs,value:h};d&&(m.attrs.redlineType===cn||m.attrs.redlineType===dn)?o=o.setNodeMarkup(p,void 0,{...g,redlineType:m.attrs.redlineType,redlineUserId:c.id,redlineUserName:c.name,redlineTimestamp:m.attrs.redlineTimestamp||new Date().toISOString(),redlineAction:m.attrs.redlineAction||"add",redlinePreviousAttrs:m.attrs.redlinePreviousAttrs||null}):o=o.setNodeMarkup(p,void 0,g),a=!0}}),a?(o=o.setMeta("addToHistory",!1),r(o),!0):!1}}},addInputRules(){return this.options.enabled?[new Ro({find:Q2,handler:({range:e,match:t,commands:n})=>{const r=t[1];r&&(n.deleteRange(e),n.insertVariable(r))}})]:[]},addKeyboardShortcuts(){const e=t=>{const{selection:n}=this.editor.state,{$from:r}=n;let i=null,o=null;if(n.empty){const m=t==="backward"?r.nodeBefore:r.nodeAfter;m?.type.name===this.name&&(o=m,i=t==="backward"?r.pos-m.nodeSize:r.pos)}if(!o||i===null)return!1;const a=this.editor.storage?.redline;if(!a?.isActive)return this.editor.commands.deleteRange({from:i,to:i+o.nodeSize});const l=this.editor.extensionManager.extensions.find(m=>m.name==="redline")?.options?.currentEntity||{id:"unknown",name:"User"},c=a.mode==="ai"?Wi:$i,d=o.attrs,u=d.redlineType===cn||d.redlineType===dn,p=this.editor.state.tr;return u?p.delete(i,i+o.nodeSize):p.setNodeMarkup(i,void 0,{...d,redlineType:c,redlineUserId:l.id,redlineUserName:l.name,redlineTimestamp:new Date().toISOString(),redlineAction:"delete",redlinePreviousAttrs:JSON.stringify({variableName:d.variableName,value:d.value??""})}),this.editor.view.dispatch(p),!0};return{Backspace:({editor:t})=>{const{selection:n}=t.state,{$from:r}=n,i=r.nodeBefore;return i&&i.type.name===this.name?e("backward"):!1},Delete:()=>e("forward")}}}),Z2="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",J2="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",cm="numeric",dm="ascii",um="alpha",is="asciinumeric",as="alphanumeric",pm="domain",w0="emoji",eM="scheme",tM="slashscheme",mm="whitespace";function nM(e,t){return e in t||(t[e]=[]),t[e]}function Qi(e,t,n){t[cm]&&(t[is]=!0,t[as]=!0),t[dm]&&(t[is]=!0,t[um]=!0),t[is]&&(t[as]=!0),t[um]&&(t[as]=!0),t[as]&&(t[pm]=!0),t[w0]&&(t[pm]=!0);for(const r in t){const i=nM(r,n);i.indexOf(e)<0&&i.push(e)}}function rM(e,t){const n={};for(const r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function vn(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}vn.groups={},vn.prototype={accepts(){return!!this.t},go(e){const t=this,n=t.j[e];if(n)return n;for(let r=0;r<t.jr.length;r++){const i=t.jr[r][0],o=t.jr[r][1];if(o&&i.test(e))return o}return t.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let i=0;i<e.length;i++)this.tt(e[i],t,n,r)},tr(e,t,n,r){r=r||vn.groups;let i;return t&&t.j?i=t:(i=new vn(t),n&&r&&Qi(t,n,r)),this.jr.push([e,i]),i},ts(e,t,n,r){let i=this;const o=e.length;if(!o)return i;for(let a=0;a<o-1;a++)i=i.tt(e[a]);return i.tt(e[o-1],t,n,r)},tt(e,t,n,r){r=r||vn.groups;const i=this;if(t&&t.j)return i.j[e]=t,t;const o=t;let a,s=i.go(e);if(s?(a=new vn,Object.assign(a.j,s.j),a.jr.push.apply(a.jr,s.jr),a.jd=s.jd,a.t=s.t):a=new vn,o){if(r)if(a.t&&typeof a.t=="string"){const l=Object.assign(rM(a.t,r),n);Qi(o,l,r)}else n&&Qi(o,n,r);a.t=o}return i.j[e]=a,a}};const De=(e,t,n,r,i)=>e.ta(t,n,r,i),Rt=(e,t,n,r,i)=>e.tr(t,n,r,i),M0=(e,t,n,r,i)=>e.ts(t,n,r,i),Q=(e,t,n,r,i)=>e.tt(t,n,r,i),Ur="WORD",fm="UWORD",D0="ASCIINUMERICAL",L0="ALPHANUMERICAL",ss="LOCALHOST",_m="TLD",hm="UTLD",rc="SCHEME",zo="SLASH_SCHEME",gm="NUM",bm="WS",Em="NL",ls="OPENBRACE",cs="CLOSEBRACE",ic="OPENBRACKET",oc="CLOSEBRACKET",ac="OPENPAREN",sc="CLOSEPAREN",lc="OPENANGLEBRACKET",cc="CLOSEANGLEBRACKET",dc="FULLWIDTHLEFTPAREN",uc="FULLWIDTHRIGHTPAREN",pc="LEFTCORNERBRACKET",mc="RIGHTCORNERBRACKET",fc="LEFTWHITECORNERBRACKET",_c="RIGHTWHITECORNERBRACKET",hc="FULLWIDTHLESSTHAN",gc="FULLWIDTHGREATERTHAN",bc="AMPERSAND",Ec="APOSTROPHE",Sc="ASTERISK",_i="AT",Tc="BACKSLASH",yc="BACKTICK",Cc="CARET",hi="COLON",Sm="COMMA",vc="DOLLAR",mr="DOT",xc="EQUALS",Tm="EXCLAMATION",Gn="HYPHEN",ds="PERCENT",Nc="PIPE",Rc="PLUS",Ac="POUND",us="QUERY",ym="QUOTE",P0="FULLWIDTHMIDDLEDOT",Cm="SEMI",fr="SLASH",ps="TILDE",Oc="UNDERSCORE",B0="EMOJI",Ic="SYM";var F0=Object.freeze({__proto__:null,ALPHANUMERICAL:L0,AMPERSAND:bc,APOSTROPHE:Ec,ASCIINUMERICAL:D0,ASTERISK:Sc,AT:_i,BACKSLASH:Tc,BACKTICK:yc,CARET:Cc,CLOSEANGLEBRACKET:cc,CLOSEBRACE:cs,CLOSEBRACKET:oc,CLOSEPAREN:sc,COLON:hi,COMMA:Sm,DOLLAR:vc,DOT:mr,EMOJI:B0,EQUALS:xc,EXCLAMATION:Tm,FULLWIDTHGREATERTHAN:gc,FULLWIDTHLEFTPAREN:dc,FULLWIDTHLESSTHAN:hc,FULLWIDTHMIDDLEDOT:P0,FULLWIDTHRIGHTPAREN:uc,HYPHEN:Gn,LEFTCORNERBRACKET:pc,LEFTWHITECORNERBRACKET:fc,LOCALHOST:ss,NL:Em,NUM:gm,OPENANGLEBRACKET:lc,OPENBRACE:ls,OPENBRACKET:ic,OPENPAREN:ac,PERCENT:ds,PIPE:Nc,PLUS:Rc,POUND:Ac,QUERY:us,QUOTE:ym,RIGHTCORNERBRACKET:mc,RIGHTWHITECORNERBRACKET:_c,SCHEME:rc,SEMI:Cm,SLASH:fr,SLASH_SCHEME:zo,SYM:Ic,TILDE:ps,TLD:_m,UNDERSCORE:Oc,UTLD:hm,UWORD:fm,WORD:Ur,WS:bm});const zr=/[a-z]/,ms=new RegExp("\\p{L}","u"),vm=new RegExp("\\p{Emoji}","u"),Hr=/\d/,xm=/\s/,U0="\r",Nm=`
|
|
149
149
|
`,iM="️",oM="",Rm="";let kc=null,wc=null;function aM(e=[]){const t={};vn.groups=t;const n=new vn;kc==null&&(kc=H0(Z2)),wc==null&&(wc=H0(J2)),Q(n,"'",Ec),Q(n,"{",ls),Q(n,"}",cs),Q(n,"[",ic),Q(n,"]",oc),Q(n,"(",ac),Q(n,")",sc),Q(n,"<",lc),Q(n,">",cc),Q(n,"(",dc),Q(n,")",uc),Q(n,"「",pc),Q(n,"」",mc),Q(n,"『",fc),Q(n,"』",_c),Q(n,"<",hc),Q(n,">",gc),Q(n,"&",bc),Q(n,"*",Sc),Q(n,"@",_i),Q(n,"`",yc),Q(n,"^",Cc),Q(n,":",hi),Q(n,",",Sm),Q(n,"$",vc),Q(n,".",mr),Q(n,"=",xc),Q(n,"!",Tm),Q(n,"-",Gn),Q(n,"%",ds),Q(n,"|",Nc),Q(n,"+",Rc),Q(n,"#",Ac),Q(n,"?",us),Q(n,'"',ym),Q(n,"/",fr),Q(n,";",Cm),Q(n,"~",ps),Q(n,"_",Oc),Q(n,"\\",Tc),Q(n,"・",P0);const r=Rt(n,Hr,gm,{[cm]:!0});Rt(r,Hr,r);const i=Rt(r,zr,D0,{[is]:!0}),o=Rt(r,ms,L0,{[as]:!0}),a=Rt(n,zr,Ur,{[dm]:!0});Rt(a,Hr,i),Rt(a,zr,a),Rt(i,Hr,i),Rt(i,zr,i);const s=Rt(n,ms,fm,{[um]:!0});Rt(s,zr),Rt(s,Hr,o),Rt(s,ms,s),Rt(o,Hr,o),Rt(o,zr),Rt(o,ms,o);const l=Q(n,Nm,Em,{[mm]:!0}),c=Q(n,U0,bm,{[mm]:!0}),d=Rt(n,xm,bm,{[mm]:!0});Q(n,Rm,d),Q(c,Nm,l),Q(c,Rm,d),Rt(c,xm,d),Q(d,U0),Q(d,Nm),Rt(d,xm,d),Q(d,Rm,d);const u=Rt(n,vm,B0,{[w0]:!0});Q(u,"#"),Rt(u,vm,u),Q(u,iM,u);const p=Q(u,oM);Q(p,"#"),Rt(p,vm,u);const m=[[zr,a],[Hr,i]],_=[[zr,null],[ms,s],[Hr,o]];for(let h=0;h<kc.length;h++)gi(n,kc[h],_m,Ur,m);for(let h=0;h<wc.length;h++)gi(n,wc[h],hm,fm,_);Qi(_m,{tld:!0,ascii:!0},t),Qi(hm,{utld:!0,alpha:!0},t),gi(n,"file",rc,Ur,m),gi(n,"mailto",rc,Ur,m),gi(n,"http",zo,Ur,m),gi(n,"https",zo,Ur,m),gi(n,"ftp",zo,Ur,m),gi(n,"ftps",zo,Ur,m),Qi(rc,{scheme:!0,ascii:!0},t),Qi(zo,{slashscheme:!0,ascii:!0},t),e=e.sort((h,g)=>h[0]>g[0]?1:-1);for(let h=0;h<e.length;h++){const g=e[h][0],E=e[h][1]?{[eM]:!0}:{[tM]:!0};g.indexOf("-")>=0?E[pm]=!0:zr.test(g)?Hr.test(g)?E[is]=!0:E[dm]=!0:E[cm]=!0,M0(n,g,g,E)}return M0(n,"localhost",ss,{ascii:!0}),n.jd=new vn(Ic),{start:n,tokens:Object.assign({groups:t},F0)}}function z0(e,t){const n=sM(t.replace(/[A-Z]/g,s=>s.toLowerCase())),r=n.length,i=[];let o=0,a=0;for(;a<r;){let s=e,l=null,c=0,d=null,u=-1,p=-1;for(;a<r&&(l=s.go(n[a]));)s=l,s.accepts()?(u=0,p=0,d=s):u>=0&&(u+=n[a].length,p++),c+=n[a].length,o+=n[a].length,a++;o-=u,a-=p,c-=u,i.push({t:d.t,v:t.slice(o-c,o),s:o-c,e:o})}return i}function sM(e){const t=[],n=e.length;let r=0;for(;r<n;){let i=e.charCodeAt(r),o,a=i<55296||i>56319||r+1===n||(o=e.charCodeAt(r+1))<56320||o>57343?e[r]:e.slice(r,r+2);t.push(a),r+=a.length}return t}function gi(e,t,n,r,i){let o;const a=t.length;for(let s=0;s<a-1;s++){const l=t[s];e.j[l]?o=e.j[l]:(o=new vn(r),o.jr=i.slice(),e.j[l]=o),e=o}return o=new vn(n),o.jr=i.slice(),e.j[t[a-1]]=o,o}function H0(e){const t=[],n=[];let r=0,i="0123456789";for(;r<e.length;){let o=0;for(;i.indexOf(e[r+o])>=0;)o++;if(o>0){t.push(n.join(""));for(let a=parseInt(e.substring(r,r+o),10);a>0;a--)n.pop();r+=o}else n.push(e[r]),r++}return t}const fs={defaultProtocol:"http",events:null,format:G0,formatHref:G0,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Am(e,t=null){let n=Object.assign({},fs);e&&(n=Object.assign(n,e instanceof Am?e.o:e));const r=n.ignoreTags,i=[];for(let o=0;o<r.length;o++)i.push(r[o].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=i}Am.prototype={o:fs,ignoreTags:[],defaultRender(e){return e},check(e){return this.get("validate",e.toString(),e)},get(e,t,n){const r=t!=null;let i=this.o[e];return i&&(typeof i=="object"?(i=n.t in i?i[n.t]:fs[e],typeof i=="function"&&r&&(i=i(t,n))):typeof i=="function"&&r&&(i=i(t,n.t,n)),i)},getObj(e,t,n){let r=this.o[e];return typeof r=="function"&&t!=null&&(r=r(t,n.t,n)),r},render(e){const t=e.render(this);return(this.get("render",null,e)||this.defaultRender)(t,e.t,e)}};function G0(e){return e}function V0(e,t){this.t="token",this.v=e,this.tk=t}V0.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){const t=this.toString(),n=e.get("truncate",t,this),r=e.get("format",t,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(e){return e.get("formatHref",this.toHref(e.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=fs.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get("validate",this.toString(),this)},render(e){const t=this,n=this.toHref(e.get("defaultProtocol")),r=e.get("formatHref",n,this),i=e.get("tagName",n,t),o=this.toFormattedString(e),a={},s=e.get("className",n,t),l=e.get("target",n,t),c=e.get("rel",n,t),d=e.getObj("attributes",n,t),u=e.getObj("events",n,t);return a.href=r,s&&(a.class=s),l&&(a.target=l),c&&(a.rel=c),d&&Object.assign(a,d),{tagName:i,attributes:a,content:o,eventListeners:u}}};function Mc(e,t){class n extends V0{constructor(i,o){super(i,o),this.t=e}}for(const r in t)n.prototype[r]=t[r];return n.t=e,n}const Y0=Mc("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),$0=Mc("text"),lM=Mc("nl"),Dc=Mc("url",{isLink:!0,toHref(e=fs.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){const e=this.tk;return e.length>=2&&e[0].t!==ss&&e[1].t===hi}}),Vn=e=>new vn(e);function cM({groups:e}){const t=e.domain.concat([bc,Sc,_i,Tc,yc,Cc,vc,xc,Gn,gm,ds,Nc,Rc,Ac,fr,Ic,ps,Oc]),n=[Ec,hi,Sm,mr,Tm,ds,us,ym,Cm,lc,cc,ls,cs,oc,ic,ac,sc,dc,uc,pc,mc,fc,_c,hc,gc],r=[bc,Ec,Sc,Tc,yc,Cc,vc,xc,Gn,ls,cs,ds,Nc,Rc,Ac,us,fr,Ic,ps,Oc],i=Vn(),o=Q(i,ps);De(o,r,o),De(o,e.domain,o);const a=Vn(),s=Vn(),l=Vn();De(i,e.domain,a),De(i,e.scheme,s),De(i,e.slashscheme,l),De(a,r,o),De(a,e.domain,a);const c=Q(a,_i);Q(o,_i,c),Q(s,_i,c),Q(l,_i,c);const d=Q(o,mr);De(d,r,o),De(d,e.domain,o);const u=Vn();De(c,e.domain,u),De(u,e.domain,u);const p=Q(u,mr);De(p,e.domain,u);const m=Vn(Y0);De(p,e.tld,m),De(p,e.utld,m),Q(c,ss,m);const _=Q(u,Gn);Q(_,Gn,_),De(_,e.domain,u),De(m,e.domain,u),Q(m,mr,p),Q(m,Gn,_);const h=Q(m,hi);De(h,e.numeric,Y0);const g=Q(a,Gn),b=Q(a,mr);Q(g,Gn,g),De(g,e.domain,a),De(b,r,o),De(b,e.domain,a);const E=Vn(Dc);De(b,e.tld,E),De(b,e.utld,E),De(E,e.domain,a),De(E,r,o),Q(E,mr,b),Q(E,Gn,g),Q(E,_i,c);const S=Q(E,hi),y=Vn(Dc);De(S,e.numeric,y);const T=Vn(Dc),x=Vn();De(T,t,T),De(T,n,x),De(x,t,T),De(x,n,x),Q(E,fr,T),Q(y,fr,T);const v=Q(s,hi),C=Q(l,hi),O=Q(C,fr),w=Q(O,fr);De(s,e.domain,a),Q(s,mr,b),Q(s,Gn,g),De(l,e.domain,a),Q(l,mr,b),Q(l,Gn,g),De(v,e.domain,T),Q(v,fr,T),Q(v,us,T),De(w,e.domain,T),De(w,t,T),Q(w,fr,T);const z=[[ls,cs],[ic,oc],[ac,sc],[lc,cc],[dc,uc],[pc,mc],[fc,_c],[hc,gc]];for(let N=0;N<z.length;N++){const[P,I]=z[N],R=Q(T,P);Q(x,P,R),Q(R,I,T);const k=Vn(Dc);De(R,t,k);const M=Vn();De(R,n),De(k,t,k),De(k,n,M),De(M,t,k),De(M,n,M),Q(k,I,T),Q(M,I,T)}return Q(i,ss,E),Q(i,Em,lM),{start:i,tokens:F0}}function dM(e,t,n){let r=n.length,i=0,o=[],a=[];for(;i<r;){let s=e,l=null,c=null,d=0,u=null,p=-1;for(;i<r&&!(l=s.go(n[i].t));)a.push(n[i++]);for(;i<r&&(c=l||s.go(n[i].t));)l=null,s=c,s.accepts()?(p=0,u=s):p>=0&&p++,i++,d++;if(p<0)i-=d,i<r&&(a.push(n[i]),i++);else{a.length>0&&(o.push(Om($0,t,a)),a=[]),i-=p,d-=p;const m=u.t,_=n.slice(i-d,i);o.push(Om(m,t,_))}}return a.length>0&&o.push(Om($0,t,a)),o}function Om(e,t,n){const r=n[0].s,i=n[n.length-1].e,o=t.slice(r,i);return new e(o,n)}const uM=typeof console<"u"&&console&&console.warn||(()=>{}),pM="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",mt={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function mM(){return vn.groups={},mt.scanner=null,mt.parser=null,mt.tokenQueue=[],mt.pluginQueue=[],mt.customSchemes=[],mt.initialized=!1,mt}function W0(e,t=!1){if(mt.initialized&&uM(`linkifyjs: already initialized - will not register custom scheme "${e}" ${pM}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw new Error(`linkifyjs: incorrect scheme format.
|
|
150
150
|
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
151
151
|
2. Cannot start or end with "-"
|
|
@@ -219,7 +219,7 @@ To suppress this warning, you need to explicitly provide the \`palette.${t}Chann
|
|
|
219
219
|
transition: zoom 0.2s ease;
|
|
220
220
|
}
|
|
221
221
|
`}),a&&f.jsx("div",{className:"editor-laser-pointer",style:{left:`${s.x}px`,top:`${s.y}px`,transform:"translate(-50%, -50%)"}})]})};var kf={},wf={},Ds={exports:{}},ao={exports:{}},r7=ao.exports,oy;function i7(){return oy||(oy=1,(function(){var e,t,n,r,i,o;typeof performance<"u"&&performance!==null&&performance.now?ao.exports=function(){return performance.now()}:typeof process<"u"&&process!==null&&process.hrtime?(ao.exports=function(){return(e()-i)/1e6},t=process.hrtime,e=function(){var a;return a=t(),a[0]*1e9+a[1]},r=e(),o=process.uptime()*1e9,i=r-o):Date.now?(ao.exports=function(){return Date.now()-n},n=Date.now()):(ao.exports=function(){return new Date().getTime()-n},n=new Date().getTime())}).call(r7)),ao.exports}var ay;function o7(){if(ay)return Ds.exports;ay=1;for(var e=i7(),t=typeof window>"u"?SC:window,n=["moz","webkit"],r="AnimationFrame",i=t["request"+r],o=t["cancel"+r]||t["cancelRequest"+r],a=0;!i&&a<n.length;a++)i=t[n[a]+"Request"+r],o=t[n[a]+"Cancel"+r]||t[n[a]+"CancelRequest"+r];if(!i||!o){var s=0,l=0,c=[],d=1e3/60;i=function(u){if(c.length===0){var p=e(),m=Math.max(0,d-(p-s));s=m+p,setTimeout(function(){var _=c.slice(0);c.length=0;for(var h=0;h<_.length;h++)if(!_[h].cancelled)try{_[h].callback(s)}catch(g){setTimeout(function(){throw g},0)}},Math.round(m))}return c.push({handle:++l,callback:u,cancelled:!1}),l},o=function(u){for(var p=0;p<c.length;p++)c[p].handle===u&&(c[p].cancelled=!0)}}return Ds.exports=function(u){return i.call(t,u)},Ds.exports.cancel=function(){o.apply(t,arguments)},Ds.exports.polyfill=function(u){u||(u=t),u.requestAnimationFrame=i,u.cancelAnimationFrame=o},Ds.exports}var Ls={exports:{}},Mf,sy;function a7(){if(sy)return Mf;sy=1;var e=null,t=["Webkit","Moz","O","ms"];return Mf=function(r){e||(e=document.createElement("div"));var i=e.style;if(r in i)return r;for(var o=r.charAt(0).toUpperCase()+r.slice(1),a=t.length;a>=0;a--){var s=t[a]+o;if(s in i)return s}return!1},Mf}var Df,ly;function s7(){if(ly)return Df;ly=1,Df=r;var e=/\s/,t=/(_|-|\.|:)/,n=/([a-z][A-Z]|[A-Z][a-z])/;function r(l){return e.test(l)?l.toLowerCase():t.test(l)?(o(l)||l).toLowerCase():n.test(l)?s(l).toLowerCase():l.toLowerCase()}var i=/[\W_]+(.|$)/g;function o(l){return l.replace(i,function(c,d){return d?" "+d:""})}var a=/(.)([A-Z]+)/g;function s(l){return l.replace(a,function(c,d,u){return d+" "+u.toLowerCase().split("").join(" ")})}return Df}var Lf,cy;function l7(){if(cy)return Lf;cy=1;var e=s7();Lf=t;function t(n){return e(n).replace(/[\W_]+(.|$)/g,function(r,i){return i?" "+i:""}).trim()}return Lf}var Pf,dy;function c7(){if(dy)return Pf;dy=1;var e=l7();Pf=t;function t(n){return e(n).replace(/\s(\w)/g,function(r,i){return i.toUpperCase()})}return Pf}var Bf,uy;function d7(){if(uy)return Bf;uy=1;var e={animationIterationCount:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridColumn:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,stopOpacity:!0,strokeDashoffset:!0,strokeOpacity:!0,strokeWidth:!0};return Bf=function(t,n){return typeof n=="number"&&!e[t]?n+"px":n},Bf}var py;function my(){if(py)return Ls.exports;py=1;var e=a7(),t=c7(),n={float:"cssFloat"},r=d7();function i(l,c,d){var u=n[c];if(typeof u>"u"&&(u=a(c)),u){if(d===void 0)return l.style[u];l.style[u]=r(u,d)}}function o(l,c){for(var d in c)c.hasOwnProperty(d)&&i(l,d,c[d])}function a(l){var c=t(l),d=e(c);return n[c]=n[l]=n[d]=d,d}function s(){arguments.length===2?typeof arguments[1]=="string"?arguments[0].style.cssText=arguments[1]:o(arguments[0],arguments[1]):i(arguments[0],arguments[1],arguments[2])}return Ls.exports=s,Ls.exports.set=s,Ls.exports.get=function(l,c){return Array.isArray(c)?c.reduce(function(d,u){return d[u]=i(l,u||""),d},{}):i(l,c||"")},Ls.exports}var Ff={},fy;function u7(){return fy||(fy=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=t;function t(n){return typeof n=="string"}})(Ff)),Ff}var Uf={},_y;function p7(){return _y||(_y=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=o;var t=my(),n=r(t);function r(a){return a&&a.__esModule?a:{default:a}}var i=!1;function o(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;if(a&&i!==!1)return i;if(typeof document<"u"){var s=document.createElement("div");(0,n.default)(s,{width:100,height:100,position:"absolute",top:-9999,overflow:"scroll",MsOverflowStyle:"scrollbar"}),document.body.appendChild(s),i=s.offsetWidth-s.clientWidth,document.body.removeChild(s)}else i=0;return i||0}})(Uf)),Uf}var zf={},hy;function m7(){return hy||(hy=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=t;function t(){return!1}})(zf)),zf}var Hf={},gy;function f7(){return gy||(gy=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=t;function t(n){var r=n.clientWidth,i=getComputedStyle(n),o=i.paddingLeft,a=i.paddingRight;return r-parseFloat(o)-parseFloat(a)}})(Hf)),Hf}var Gf={},by;function _7(){return by||(by=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=t;function t(n){var r=n.clientHeight,i=getComputedStyle(n),o=i.paddingTop,a=i.paddingBottom;return r-parseFloat(o)-parseFloat(a)}})(Gf)),Gf}var Nn={},Ey;function h7(){return Ey||(Ey=1,Object.defineProperty(Nn,"__esModule",{value:!0}),Nn.containerStyleDefault={position:"relative",overflow:"hidden",width:"100%",height:"100%"},Nn.containerStyleAutoHeight={height:"auto"},Nn.viewStyleDefault={position:"absolute",top:0,left:0,right:0,bottom:0,overflow:"scroll",WebkitOverflowScrolling:"touch"},Nn.viewStyleAutoHeight={position:"relative",top:void 0,left:void 0,right:void 0,bottom:void 0},Nn.viewStyleUniversalInitial={overflow:"hidden",marginRight:0,marginBottom:0},Nn.trackHorizontalStyleDefault={position:"absolute",height:6},Nn.trackVerticalStyleDefault={position:"absolute",width:6},Nn.thumbHorizontalStyleDefault={position:"relative",display:"block",height:"100%"},Nn.thumbVerticalStyleDefault={position:"relative",display:"block",width:"100%"},Nn.disableSelectStyle={userSelect:"none"},Nn.disableSelectStyleReset={userSelect:""}),Nn}var Ci={},Sy;function g7(){if(Sy)return Ci;Sy=1,Object.defineProperty(Ci,"__esModule",{value:!0});var e=Object.assign||function(d){for(var u=1;u<arguments.length;u++){var p=arguments[u];for(var m in p)Object.prototype.hasOwnProperty.call(p,m)&&(d[m]=p[m])}return d};Ci.renderViewDefault=o,Ci.renderTrackHorizontalDefault=a,Ci.renderTrackVerticalDefault=s,Ci.renderThumbHorizontalDefault=l,Ci.renderThumbVerticalDefault=c;var t=A,n=r(t);function r(d){return d&&d.__esModule?d:{default:d}}function i(d,u){var p={};for(var m in d)u.indexOf(m)>=0||Object.prototype.hasOwnProperty.call(d,m)&&(p[m]=d[m]);return p}function o(d){return n.default.createElement("div",d)}function a(d){var u=d.style,p=i(d,["style"]),m=e({},u,{right:2,bottom:2,left:2,borderRadius:3});return n.default.createElement("div",e({style:m},p))}function s(d){var u=d.style,p=i(d,["style"]),m=e({},u,{right:2,bottom:2,top:2,borderRadius:3});return n.default.createElement("div",e({style:m},p))}function l(d){var u=d.style,p=i(d,["style"]),m=e({},u,{cursor:"pointer",borderRadius:"inherit",backgroundColor:"rgba(0,0,0,.2)"});return n.default.createElement("div",e({style:m},p))}function c(d){var u=d.style,p=i(d,["style"]),m=e({},u,{cursor:"pointer",borderRadius:"inherit",backgroundColor:"rgba(0,0,0,.2)"});return n.default.createElement("div",e({style:m},p))}return Ci}var Ty;function b7(){return Ty||(Ty=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Object.assign||function(N){for(var P=1;P<arguments.length;P++){var I=arguments[P];for(var R in I)Object.prototype.hasOwnProperty.call(I,R)&&(N[R]=I[R])}return N},n=(function(){function N(P,I){for(var R=0;R<I.length;R++){var k=I[R];k.enumerable=k.enumerable||!1,k.configurable=!0,"value"in k&&(k.writable=!0),Object.defineProperty(P,k.key,k)}}return function(P,I,R){return I&&N(P.prototype,I),R&&N(P,R),P}})(),r=o7(),i=x(r),o=my(),a=x(o),s=A,l=DS(),c=x(l),d=u7(),u=x(d),p=p7(),m=x(p),_=m7(),h=x(_),g=f7(),b=x(g),E=_7(),S=x(E),y=h7(),T=g7();function x(N){return N&&N.__esModule?N:{default:N}}function v(N,P){var I={};for(var R in N)P.indexOf(R)>=0||Object.prototype.hasOwnProperty.call(N,R)&&(I[R]=N[R]);return I}function C(N,P){if(!(N instanceof P))throw new TypeError("Cannot call a class as a function")}function O(N,P){if(!N)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return P&&(typeof P=="object"||typeof P=="function")?P:N}function w(N,P){if(typeof P!="function"&&P!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof P);N.prototype=Object.create(P&&P.prototype,{constructor:{value:N,enumerable:!1,writable:!0,configurable:!0}}),P&&(Object.setPrototypeOf?Object.setPrototypeOf(N,P):N.__proto__=P)}var z=(function(N){w(P,N);function P(I){var R;C(this,P);for(var k=arguments.length,M=Array(k>1?k-1:0),B=1;B<k;B++)M[B-1]=arguments[B];var D=O(this,(R=P.__proto__||Object.getPrototypeOf(P)).call.apply(R,[this,I].concat(M)));return D.getScrollLeft=D.getScrollLeft.bind(D),D.getScrollTop=D.getScrollTop.bind(D),D.getScrollWidth=D.getScrollWidth.bind(D),D.getScrollHeight=D.getScrollHeight.bind(D),D.getClientWidth=D.getClientWidth.bind(D),D.getClientHeight=D.getClientHeight.bind(D),D.getValues=D.getValues.bind(D),D.getThumbHorizontalWidth=D.getThumbHorizontalWidth.bind(D),D.getThumbVerticalHeight=D.getThumbVerticalHeight.bind(D),D.getScrollLeftForOffset=D.getScrollLeftForOffset.bind(D),D.getScrollTopForOffset=D.getScrollTopForOffset.bind(D),D.scrollLeft=D.scrollLeft.bind(D),D.scrollTop=D.scrollTop.bind(D),D.scrollToLeft=D.scrollToLeft.bind(D),D.scrollToTop=D.scrollToTop.bind(D),D.scrollToRight=D.scrollToRight.bind(D),D.scrollToBottom=D.scrollToBottom.bind(D),D.handleTrackMouseEnter=D.handleTrackMouseEnter.bind(D),D.handleTrackMouseLeave=D.handleTrackMouseLeave.bind(D),D.handleHorizontalTrackMouseDown=D.handleHorizontalTrackMouseDown.bind(D),D.handleVerticalTrackMouseDown=D.handleVerticalTrackMouseDown.bind(D),D.handleHorizontalThumbMouseDown=D.handleHorizontalThumbMouseDown.bind(D),D.handleVerticalThumbMouseDown=D.handleVerticalThumbMouseDown.bind(D),D.handleWindowResize=D.handleWindowResize.bind(D),D.handleScroll=D.handleScroll.bind(D),D.handleDrag=D.handleDrag.bind(D),D.handleDragEnd=D.handleDragEnd.bind(D),D.state={didMountUniversal:!1},D}return n(P,[{key:"componentDidMount",value:function(){this.addListeners(),this.update(),this.componentDidMountUniversal()}},{key:"componentDidMountUniversal",value:function(){var R=this.props.universal;R&&this.setState({didMountUniversal:!0})}},{key:"componentDidUpdate",value:function(){this.update()}},{key:"componentWillUnmount",value:function(){this.removeListeners(),(0,r.cancel)(this.requestFrame),clearTimeout(this.hideTracksTimeout),clearInterval(this.detectScrollingInterval)}},{key:"getScrollLeft",value:function(){return this.view?this.view.scrollLeft:0}},{key:"getScrollTop",value:function(){return this.view?this.view.scrollTop:0}},{key:"getScrollWidth",value:function(){return this.view?this.view.scrollWidth:0}},{key:"getScrollHeight",value:function(){return this.view?this.view.scrollHeight:0}},{key:"getClientWidth",value:function(){return this.view?this.view.clientWidth:0}},{key:"getClientHeight",value:function(){return this.view?this.view.clientHeight:0}},{key:"getValues",value:function(){var R=this.view||{},k=R.scrollLeft,M=k===void 0?0:k,B=R.scrollTop,D=B===void 0?0:B,U=R.scrollWidth,H=U===void 0?0:U,V=R.scrollHeight,q=V===void 0?0:V,W=R.clientWidth,oe=W===void 0?0:W,Z=R.clientHeight,X=Z===void 0?0:Z;return{left:M/(H-oe)||0,top:D/(q-X)||0,scrollLeft:M,scrollTop:D,scrollWidth:H,scrollHeight:q,clientWidth:oe,clientHeight:X}}},{key:"getThumbHorizontalWidth",value:function(){var R=this.props,k=R.thumbSize,M=R.thumbMinSize,B=this.view,D=B.scrollWidth,U=B.clientWidth,H=(0,b.default)(this.trackHorizontal),V=Math.ceil(U/D*H);return H<=V?0:k||Math.max(V,M)}},{key:"getThumbVerticalHeight",value:function(){var R=this.props,k=R.thumbSize,M=R.thumbMinSize,B=this.view,D=B.scrollHeight,U=B.clientHeight,H=(0,S.default)(this.trackVertical),V=Math.ceil(U/D*H);return H<=V?0:k||Math.max(V,M)}},{key:"getScrollLeftForOffset",value:function(R){var k=this.view,M=k.scrollWidth,B=k.clientWidth,D=(0,b.default)(this.trackHorizontal),U=this.getThumbHorizontalWidth();return R/(D-U)*(M-B)}},{key:"getScrollTopForOffset",value:function(R){var k=this.view,M=k.scrollHeight,B=k.clientHeight,D=(0,S.default)(this.trackVertical),U=this.getThumbVerticalHeight();return R/(D-U)*(M-B)}},{key:"scrollLeft",value:function(){var R=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;this.view&&(this.view.scrollLeft=R)}},{key:"scrollTop",value:function(){var R=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;this.view&&(this.view.scrollTop=R)}},{key:"scrollToLeft",value:function(){this.view&&(this.view.scrollLeft=0)}},{key:"scrollToTop",value:function(){this.view&&(this.view.scrollTop=0)}},{key:"scrollToRight",value:function(){this.view&&(this.view.scrollLeft=this.view.scrollWidth)}},{key:"scrollToBottom",value:function(){this.view&&(this.view.scrollTop=this.view.scrollHeight)}},{key:"addListeners",value:function(){if(!(typeof document>"u"||!this.view)){var R=this.view,k=this.trackHorizontal,M=this.trackVertical,B=this.thumbHorizontal,D=this.thumbVertical;R.addEventListener("scroll",this.handleScroll),(0,m.default)()&&(k.addEventListener("mouseenter",this.handleTrackMouseEnter),k.addEventListener("mouseleave",this.handleTrackMouseLeave),k.addEventListener("mousedown",this.handleHorizontalTrackMouseDown),M.addEventListener("mouseenter",this.handleTrackMouseEnter),M.addEventListener("mouseleave",this.handleTrackMouseLeave),M.addEventListener("mousedown",this.handleVerticalTrackMouseDown),B.addEventListener("mousedown",this.handleHorizontalThumbMouseDown),D.addEventListener("mousedown",this.handleVerticalThumbMouseDown),window.addEventListener("resize",this.handleWindowResize))}}},{key:"removeListeners",value:function(){if(!(typeof document>"u"||!this.view)){var R=this.view,k=this.trackHorizontal,M=this.trackVertical,B=this.thumbHorizontal,D=this.thumbVertical;R.removeEventListener("scroll",this.handleScroll),(0,m.default)()&&(k.removeEventListener("mouseenter",this.handleTrackMouseEnter),k.removeEventListener("mouseleave",this.handleTrackMouseLeave),k.removeEventListener("mousedown",this.handleHorizontalTrackMouseDown),M.removeEventListener("mouseenter",this.handleTrackMouseEnter),M.removeEventListener("mouseleave",this.handleTrackMouseLeave),M.removeEventListener("mousedown",this.handleVerticalTrackMouseDown),B.removeEventListener("mousedown",this.handleHorizontalThumbMouseDown),D.removeEventListener("mousedown",this.handleVerticalThumbMouseDown),window.removeEventListener("resize",this.handleWindowResize),this.teardownDragging())}}},{key:"handleScroll",value:function(R){var k=this,M=this.props,B=M.onScroll,D=M.onScrollFrame;B&&B(R),this.update(function(U){var H=U.scrollLeft,V=U.scrollTop;k.viewScrollLeft=H,k.viewScrollTop=V,D&&D(U)}),this.detectScrolling()}},{key:"handleScrollStart",value:function(){var R=this.props.onScrollStart;R&&R(),this.handleScrollStartAutoHide()}},{key:"handleScrollStartAutoHide",value:function(){var R=this.props.autoHide;R&&this.showTracks()}},{key:"handleScrollStop",value:function(){var R=this.props.onScrollStop;R&&R(),this.handleScrollStopAutoHide()}},{key:"handleScrollStopAutoHide",value:function(){var R=this.props.autoHide;R&&this.hideTracks()}},{key:"handleWindowResize",value:function(){(0,m.default)(!1),this.forceUpdate()}},{key:"handleHorizontalTrackMouseDown",value:function(R){R.preventDefault();var k=R.target,M=R.clientX,B=k.getBoundingClientRect(),D=B.left,U=this.getThumbHorizontalWidth(),H=Math.abs(D-M)-U/2;this.view.scrollLeft=this.getScrollLeftForOffset(H)}},{key:"handleVerticalTrackMouseDown",value:function(R){R.preventDefault();var k=R.target,M=R.clientY,B=k.getBoundingClientRect(),D=B.top,U=this.getThumbVerticalHeight(),H=Math.abs(D-M)-U/2;this.view.scrollTop=this.getScrollTopForOffset(H)}},{key:"handleHorizontalThumbMouseDown",value:function(R){R.preventDefault(),this.handleDragStart(R);var k=R.target,M=R.clientX,B=k.offsetWidth,D=k.getBoundingClientRect(),U=D.left;this.prevPageX=B-(M-U)}},{key:"handleVerticalThumbMouseDown",value:function(R){R.preventDefault(),this.handleDragStart(R);var k=R.target,M=R.clientY,B=k.offsetHeight,D=k.getBoundingClientRect(),U=D.top;this.prevPageY=B-(M-U)}},{key:"setupDragging",value:function(){(0,a.default)(document.body,y.disableSelectStyle),document.addEventListener("mousemove",this.handleDrag),document.addEventListener("mouseup",this.handleDragEnd),document.onselectstart=h.default}},{key:"teardownDragging",value:function(){(0,a.default)(document.body,y.disableSelectStyleReset),document.removeEventListener("mousemove",this.handleDrag),document.removeEventListener("mouseup",this.handleDragEnd),document.onselectstart=void 0}},{key:"handleDragStart",value:function(R){this.dragging=!0,R.stopImmediatePropagation(),this.setupDragging()}},{key:"handleDrag",value:function(R){if(this.prevPageX){var k=R.clientX,M=this.trackHorizontal.getBoundingClientRect(),B=M.left,D=this.getThumbHorizontalWidth(),U=D-this.prevPageX,H=-B+k-U;this.view.scrollLeft=this.getScrollLeftForOffset(H)}if(this.prevPageY){var V=R.clientY,q=this.trackVertical.getBoundingClientRect(),W=q.top,oe=this.getThumbVerticalHeight(),Z=oe-this.prevPageY,X=-W+V-Z;this.view.scrollTop=this.getScrollTopForOffset(X)}return!1}},{key:"handleDragEnd",value:function(){this.dragging=!1,this.prevPageX=this.prevPageY=0,this.teardownDragging(),this.handleDragEndAutoHide()}},{key:"handleDragEndAutoHide",value:function(){var R=this.props.autoHide;R&&this.hideTracks()}},{key:"handleTrackMouseEnter",value:function(){this.trackMouseOver=!0,this.handleTrackMouseEnterAutoHide()}},{key:"handleTrackMouseEnterAutoHide",value:function(){var R=this.props.autoHide;R&&this.showTracks()}},{key:"handleTrackMouseLeave",value:function(){this.trackMouseOver=!1,this.handleTrackMouseLeaveAutoHide()}},{key:"handleTrackMouseLeaveAutoHide",value:function(){var R=this.props.autoHide;R&&this.hideTracks()}},{key:"showTracks",value:function(){clearTimeout(this.hideTracksTimeout),(0,a.default)(this.trackHorizontal,{opacity:1}),(0,a.default)(this.trackVertical,{opacity:1})}},{key:"hideTracks",value:function(){var R=this;if(!this.dragging&&!this.scrolling&&!this.trackMouseOver){var k=this.props.autoHideTimeout;clearTimeout(this.hideTracksTimeout),this.hideTracksTimeout=setTimeout(function(){(0,a.default)(R.trackHorizontal,{opacity:0}),(0,a.default)(R.trackVertical,{opacity:0})},k)}}},{key:"detectScrolling",value:function(){var R=this;this.scrolling||(this.scrolling=!0,this.handleScrollStart(),this.detectScrollingInterval=setInterval(function(){R.lastViewScrollLeft===R.viewScrollLeft&&R.lastViewScrollTop===R.viewScrollTop&&(clearInterval(R.detectScrollingInterval),R.scrolling=!1,R.handleScrollStop()),R.lastViewScrollLeft=R.viewScrollLeft,R.lastViewScrollTop=R.viewScrollTop},100))}},{key:"raf",value:function(R){var k=this;this.requestFrame&&i.default.cancel(this.requestFrame),this.requestFrame=(0,i.default)(function(){k.requestFrame=void 0,R()})}},{key:"update",value:function(R){var k=this;this.raf(function(){return k._update(R)})}},{key:"_update",value:function(R){var k=this.props,M=k.onUpdate,B=k.hideTracksWhenNotNeeded,D=this.getValues();if((0,m.default)()){var U=D.scrollLeft,H=D.clientWidth,V=D.scrollWidth,q=(0,b.default)(this.trackHorizontal),W=this.getThumbHorizontalWidth(),oe=U/(V-H)*(q-W),Z={width:W,transform:"translateX("+oe+"px)"},X=D.scrollTop,se=D.clientHeight,be=D.scrollHeight,pe=(0,S.default)(this.trackVertical),He=this.getThumbVerticalHeight(),ee=X/(be-se)*(pe-He),pt={height:He,transform:"translateY("+ee+"px)"};if(B){var Wt={visibility:V>H?"visible":"hidden"},jt={visibility:be>se?"visible":"hidden"};(0,a.default)(this.trackHorizontal,Wt),(0,a.default)(this.trackVertical,jt)}(0,a.default)(this.thumbHorizontal,Z),(0,a.default)(this.thumbVertical,pt)}M&&M(D),typeof R=="function"&&R(D)}},{key:"render",value:function(){var R=this,k=(0,m.default)(),M=this.props;M.onScroll,M.onScrollFrame,M.onScrollStart,M.onScrollStop,M.onUpdate;var B=M.renderView,D=M.renderTrackHorizontal,U=M.renderTrackVertical,H=M.renderThumbHorizontal,V=M.renderThumbVertical,q=M.tagName;M.hideTracksWhenNotNeeded;var W=M.autoHide;M.autoHideTimeout;var oe=M.autoHideDuration;M.thumbSize,M.thumbMinSize;var Z=M.universal,X=M.autoHeight,se=M.autoHeightMin,be=M.autoHeightMax,pe=M.style,He=M.children,ee=v(M,["onScroll","onScrollFrame","onScrollStart","onScrollStop","onUpdate","renderView","renderTrackHorizontal","renderTrackVertical","renderThumbHorizontal","renderThumbVertical","tagName","hideTracksWhenNotNeeded","autoHide","autoHideTimeout","autoHideDuration","thumbSize","thumbMinSize","universal","autoHeight","autoHeightMin","autoHeightMax","style","children"]),pt=this.state.didMountUniversal,Wt=t({},y.containerStyleDefault,X&&t({},y.containerStyleAutoHeight,{minHeight:se,maxHeight:be}),pe),jt=t({},y.viewStyleDefault,{marginRight:k?-k:0,marginBottom:k?-k:0},X&&t({},y.viewStyleAutoHeight,{minHeight:(0,u.default)(se)?"calc("+se+" + "+k+"px)":se+k,maxHeight:(0,u.default)(be)?"calc("+be+" + "+k+"px)":be+k}),X&&Z&&!pt&&{minHeight:se,maxHeight:be},Z&&!pt&&y.viewStyleUniversalInitial),Le={transition:"opacity "+oe+"ms",opacity:0},fn=t({},y.trackHorizontalStyleDefault,W&&Le,(!k||Z&&!pt)&&{display:"none"}),Tn=t({},y.trackVerticalStyleDefault,W&&Le,(!k||Z&&!pt)&&{display:"none"});return(0,s.createElement)(q,t({},ee,{style:Wt,ref:function(Bt){R.container=Bt}}),[(0,s.cloneElement)(B({style:jt}),{key:"view",ref:function(Bt){R.view=Bt}},He),(0,s.cloneElement)(D({style:fn}),{key:"trackHorizontal",ref:function(Bt){R.trackHorizontal=Bt}},(0,s.cloneElement)(H({style:y.thumbHorizontalStyleDefault}),{ref:function(Bt){R.thumbHorizontal=Bt}})),(0,s.cloneElement)(U({style:Tn}),{key:"trackVertical",ref:function(Bt){R.trackVertical=Bt}},(0,s.cloneElement)(V({style:y.thumbVerticalStyleDefault}),{ref:function(Bt){R.thumbVertical=Bt}}))])}}]),P})(s.Component);e.default=z,z.propTypes={onScroll:c.default.func,onScrollFrame:c.default.func,onScrollStart:c.default.func,onScrollStop:c.default.func,onUpdate:c.default.func,renderView:c.default.func,renderTrackHorizontal:c.default.func,renderTrackVertical:c.default.func,renderThumbHorizontal:c.default.func,renderThumbVertical:c.default.func,tagName:c.default.string,thumbSize:c.default.number,thumbMinSize:c.default.number,hideTracksWhenNotNeeded:c.default.bool,autoHide:c.default.bool,autoHideTimeout:c.default.number,autoHideDuration:c.default.number,autoHeight:c.default.bool,autoHeightMin:c.default.oneOfType([c.default.number,c.default.string]),autoHeightMax:c.default.oneOfType([c.default.number,c.default.string]),universal:c.default.bool,style:c.default.object,children:c.default.node},z.defaultProps={renderView:T.renderViewDefault,renderTrackHorizontal:T.renderTrackHorizontalDefault,renderTrackVertical:T.renderTrackVerticalDefault,renderThumbHorizontal:T.renderThumbHorizontalDefault,renderThumbVertical:T.renderThumbVerticalDefault,tagName:"div",thumbMinSize:30,hideTracksWhenNotNeeded:!1,autoHide:!1,autoHideTimeout:1e3,autoHideDuration:200,autoHeight:!1,autoHeightMin:0,autoHeightMax:200,universal:!1}})(wf)),wf}var yy;function E7(){return yy||(yy=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Scrollbars=void 0;var t=b7(),n=r(t);function r(i){return i&&i.__esModule?i:{default:i}}e.default=n.default,e.Scrollbars=n.default})(kf)),kf}var S7=E7();function T7({children:e}){return f.jsx(S7.Scrollbars,{autoHide:!0,autoHideTimeout:1e3,autoHideDuration:1e3,universal:!0,renderThumbVertical:t=>f.jsx("div",{...t,style:{backgroundColor:"rgba(100, 100, 100, 0.5)",borderRadius:"6px"}}),renderTrackVertical:t=>f.jsx("div",{...t,style:{backgroundColor:"rgba(0, 0, 0, 0.05)"},onMouseEnter:n=>n.currentTarget.style.backgroundColor="rgba(0,0,0,0.1)",onMouseLeave:n=>n.currentTarget.style.backgroundColor="rgba(0,0,0,0.05)"}),children:e})}const{TextArea:y7}=Oe.Input,Cy=e=>{const t=new Date(e),n=Math.floor((Date.now()-t.getTime())/6e4);return n<1?"Just now":n<60?`${n} minute${n!==1?"s":""}`:n<1440?`${Math.floor(n/60)} hour${Math.floor(n/60)!==1?"s":""}`:t.toLocaleDateString()},Dd=(e,t)=>e.length>t?`${e.substring(0,t)}...`:e,vy=e=>{const t=(e||"").trim().split(" ");return{firstName:t[0]??"",lastName:t.slice(1).join(" ")||" "}},Vf=A.forwardRef(({change:e,onAccept:t,onReject:n,onNavigate:r,onAddComment:i,onEditComment:o,onDeleteComment:a,currentUser:s,isActive:l=!1,onSetActive:c,isSuggestingMode:d=!0,showComments:u=!0,canReviewChanges:p=!0},m)=>{const _=e.type.includes("insertion"),h=e.type.includes("deletion"),g=e.type.includes("ai"),b=e.nodeType==="table",E=e.nodeType==="tableRow",S=e.nodeType==="tableColumn",y=e.nodeType==="signature",T=e.nodeType==="variable",x=e.nodeType==="link"||!!e.linkData,v=!!e.formatChanges&&!x,[C,O]=A.useState(""),[w,z]=A.useState(null),[N,P]=A.useState(null),[I,R]=A.useState(""),[k,M]=A.useState(new Set),[B,D]=A.useState(!1),{editorConfig:U}=nt(),H=U.allUsers,V=A.useRef(null),q=150,W=()=>x?"text-[#2196F3]":y?"text-[#8B5CF6]":T?"text-[#7C3AED]":E||S?"text-[#4CAF50]":v?"text-[#FF9800]":_?"text-[#4CAF50]":h?"text-[#F44336]":"text-gray-600",oe=()=>{if(x&&e.linkData){if(e.linkData.action==="add")return"Add link:";if(e.linkData.action==="remove")return"Delete link:";if(e.linkData.action==="change")return"Change link:"}if(y&&e.signatureData){if(e.signatureData.action==="add")return"Add:";if(e.signatureData.action==="delete")return"Delete:";if(e.signatureData.action==="update")return"Update:"}if(T&&e.variableData){if(e.variableData.action==="add")return"Add variable:";if(e.variableData.action==="delete")return"Delete variable:";if(e.variableData.action==="update")return"Update variable:"}return E&&e.tableRowData?.action==="add"?"Add row:":E&&e.tableRowData?.action==="delete"?"Delete row:":S&&e.tableColumnData?.action==="add"?"Add column:":S&&e.tableColumnData?.action==="delete"?"Delete column:":b?`${_?"Add":h?"Delete":"Change"} Table`:e.formatChanges?"Format:":_?"Add:":h?"Delete:":"Change:"},Z=()=>{if(!e.formatChanges)return"";try{const ce=JSON.parse(e.formatChanges),ft={bold:"Bold",italic:"Italic",underline:"Underline",strike:"Strikethrough",superscript:"Superscript",subscript:"Subscript",color:"Text Color",backgroundColor:"Background",highlight:"Highlight",fontSize:"Font Size",fontFamily:"Font",list:"List",heading:"Title",lineHeight:"Line spacing"};return Object.keys(ce).map(nn=>{if(nn==="lineHeight"){const _t=ce[nn]?.new;return typeof _t=="string"&&_t?`Line spacing (${_t} times)`:"Line spacing"}return ft[nn]||nn}).join(", ")}catch{return"Format changes"}},X=()=>{if(x&&e.linkData){if(e.linkData.action==="add")return`with url "${e.linkData.url}"`;if(e.linkData.action==="remove")return`with url "${e.linkData.url}"`;if(e.linkData.action==="change")return`from "${e.linkData.oldUrl}" to "${e.linkData.url}"`}if(y&&e.signatureData)return e.signatureData.action==="update"?e.signatureData.fileName?`updated to "${e.signatureData.fileName}"`:"signature updated":e.signatureData.fileName?`"${e.signatureData.fileName}"`:e.signatureData.recipientEmail?`for ${e.signatureData.recipientEmail}`:"signature";if(T&&e.variableData){if(e.variableData.action==="update"){const ce=e.variableData.value||`{{${e.variableData.variableName}}}`;return`${e.variableData.variableName} -> "${ce}"`}return e.variableData.value?`${e.variableData.variableName} = "${e.variableData.value}"`:e.variableData.variableName}if(E){const ce=e.tableRowData?.content??"";return ce.trim().length>0?Dd(ce,150):"empty row"}if(S){const ce=e.tableColumnData?.content??"";return ce.trim().length>0?Dd(ce,150):"empty column"}if(e.formatChanges)return Z();if(b)return e.tableData&&e.tableData.trim().length>0?Dd(e.tableData,150):"";if(e.content.trim().length===0){const ce=e.content.length;return`${ce} ${ce===1?"space":"spaces"}`}return Dd(e.content,100)},se=()=>{const ce=C.trim();ce&&(i(e.id,ce),O(""))},be=(ce,ft)=>{P(ce),R(ft),z(null)},pe=ce=>{const ft=I.trim();ft&&(o(e.id,ce,ft),P(null),R(""))},He=()=>{P(null),R("")},ee=ce=>{a(e.id,ce),z(null)},pt=ce=>{M(ft=>{const qn=new Set(ft);return qn.has(ce)?qn.delete(ce):qn.add(ce),qn})},Wt=ce=>ce.length>q,jt=(ce,ft)=>!Wt(ft)||k.has(ce)?ft:ft.substring(0,q)+"...",Le=ce=>{ce.stopPropagation(),r(e.position,e.timestamp,e.userId),c?.()},fn=ce=>ce.stopPropagation();A.useEffect(()=>{const ce=ft=>{V.current&&!V.current.contains(ft.target)&&z(null)};return document.addEventListener("mousedown",ce),()=>document.removeEventListener("mousedown",ce)},[]);const Tn=!!e.comments?.length,qt=H?.find(ce=>ce.id===e.userId),Bt=g?"AI Assistant":qt?.name||e.userName;return f.jsxs("div",{ref:m,className:`bg-white dark:bg-black-800 rounded-lg border p-4 mt-1 cursor-pointer transition-all duration-200 hover:shadow-[0_4px_12px_rgba(0,0,0,0.1)] hover:-translate-y-0.5 ${l?"border-[#2196F3] border-2":"border-gray-300 dark:border-black-500 border-2"}`,onClick:Le,children:[f.jsxs("div",{className:"flex items-start gap-2",children:[f.jsx(G.UserAvatar,{...vy(Bt),profilePic:g?void 0:qt?.profilePic||e.userProfilePic,size:"md",containerClassName:"w-10 h-10",enablePopper:!1}),f.jsx("div",{className:"flex-1 min-w-0",children:f.jsxs("div",{className:"flex flex-col",children:[f.jsxs("div",{className:"w-full flex items-center justify-between",children:[f.jsx("span",{className:"text-sm font-semibold text-gray-900 dark:text-white whitespace-nowrap truncate",children:Bt}),p&&f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(G.Button,{id:"redline-reject-change",status:"no-background",onClick:()=>n(e.id),className:"!p-1 !max-h-none !rounded-full flex items-center gap-1 !text-[#F44336] dark:!text-error-400 hover:!bg-red-50 dark:hover:!bg-error-600 dark:hover:!text-white !border-none",title:"Reject change",children:f.jsx(te.CloseRounded,{sx:{fontSize:16}})}),f.jsx(G.Button,{id:"redline-accept-change",status:"no-background",onClick:()=>t(e.id),className:"!p-1 !max-h-none !rounded-full flex items-center gap-1 !text-[#4CAF50] dark:!text-success-400 hover:!bg-green-50 dark:hover:!bg-success-600 dark:hover:!text-white !border-none",title:"Accept change",children:f.jsx(te.CheckRounded,{sx:{fontSize:16}})})]})]}),f.jsx("span",{className:"text-xs text-gray-500 dark:text-black-400 whitespace-nowrap",children:Cy(e.timestamp)})]})})]}),f.jsxs("div",{className:"flex items-start gap-1.5 mt-2",children:[f.jsx("span",{className:`text-sm font-medium whitespace-nowrap ${W()}`,children:oe()}),f.jsx("span",{className:"text-sm text-gray-800 dark:text-black-200 break-words",children:X()})]}),Tn&&u&&B&&l&&f.jsx("div",{className:"mt-4 pt-4 border-t border-gray-200 dark:border-black-600 space-y-4",children:e.comments?.map(ce=>{const ft=N===ce.id,nn=s?.id===ce.userId&&!ft&&d;return f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx(G.UserAvatar,{...vy(ce.userName),size:"sm",enablePopper:!1}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[f.jsx("span",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:ce.userName}),f.jsx("span",{className:"text-xs text-gray-500 dark:text-black-400",children:Cy(ce.timestamp)}),nn&&f.jsxs("div",{className:"relative ml-auto",ref:w===ce.id?V:null,children:[f.jsx("button",{onClick:_t=>{_t.stopPropagation(),z(w===ce.id?null:ce.id)},className:"p-1 hover:bg-gray-100 rounded transition-colors",title:"More options",children:f.jsx(re,{name:"three-dots-vertical",size:12,className:"text-gray-400"})}),w===ce.id&&f.jsxs("div",{className:"absolute right-0 top-8 bg-white dark:bg-black-700 border border-gray-200 dark:border-black-500 rounded-lg shadow-lg z-10 min-w-[120px]",children:[f.jsxs("button",{onClick:_t=>{_t.stopPropagation(),be(ce.id,ce.text)},className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 dark:hover:bg-black-600 flex items-center gap-2 text-gray-700 dark:text-black-200",children:[f.jsx(te.EditOutlined,{sx:{fontSize:16}}),"Edit"]}),f.jsxs("button",{onClick:_t=>{_t.stopPropagation(),ee(ce.id)},className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 dark:hover:bg-black-600 flex items-center gap-2 text-red-600 dark:text-error-400",children:[f.jsx(te.DeleteOutline,{sx:{fontSize:16}}),"Delete"]})]})]})]}),ft?f.jsxs("div",{className:"space-y-2",children:[f.jsx(y7,{value:I,onChange:_t=>R(_t.target.value),rows:2,autoFocus:!0,onClick:fn,onKeyDown:_t=>{_t.key==="Enter"&&(_t.metaKey||_t.ctrlKey)&&pe(ce.id),_t.key==="Escape"&&He()}}),f.jsxs("div",{className:"flex gap-2 justify-end",onClick:fn,children:[f.jsx(G.Button,{id:"redline-cancel-edit",status:"no-background",onClick:He,className:"!p-1 !max-h-none !rounded text-gray-600 hover:!bg-gray-50 !border-none",children:"Cancel"}),f.jsxs(G.Button,{id:"redline-save-edit",status:"no-background",onClick:()=>pe(ce.id),className:"!p-1 !max-h-none !rounded flex items-center gap-1 text-blue-600 hover:!bg-blue-50 !border-none",disabled:!I.trim(),children:[f.jsx(te.SendRounded,{sx:{fontSize:14}}),"Save"]})]})]}):f.jsxs("div",{children:[f.jsx("p",{className:"text-sm text-gray-700 dark:text-black-200 break-words whitespace-pre-wrap",children:jt(ce.id,ce.text)}),Wt(ce.text)&&f.jsx("button",{onClick:_t=>{_t.stopPropagation(),pt(ce.id)},className:"text-xs text-blue-600 hover:text-blue-800 font-medium mt-1",children:k.has(ce.id)?"Show less":"Show more"})]})]})]},ce.id)})}),l&&d&&u&&B&&f.jsx("div",{className:"mt-4 pt-4 border-t border-gray-200 dark:border-black-600",onClick:fn,children:f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"flex-1 relative",children:f.jsx("input",{type:"text",value:C,onChange:ce=>O(ce.target.value),placeholder:"Add feedback...",className:"w-full px-4 py-3 pr-12 text-sm border border-gray-200 dark:border-black-500 rounded-lg bg-white dark:bg-black-700 text-neutral-900 dark:text-white placeholder:text-neutral-400 dark:placeholder:text-black-400 focus:outline-none focus:border-[#2196F3] focus:ring-1 focus:ring-[#2196F3] transition-colors",onKeyDown:ce=>{ce.key==="Enter"&&!ce.shiftKey&&(ce.preventDefault(),se())}})}),f.jsx("button",{onClick:se,disabled:!C.trim(),className:`p-2 transition-colors ${C.trim()?"text-[#2196F3] hover:text-[#1976D2] cursor-pointer":"text-gray-300 cursor-not-allowed"}`,title:"Send feedback",children:f.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[f.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),f.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})})]})});Vf.displayName="RedlineItem";const Ld="data-redline-column-action",sa="data-redline-column-id",Pd=(e,t,n,r)=>{if(!e.isText||!e.text)return null;const i=e.marks.find(a=>a.type.name===n);if(!i)return null;const o={pos:t,endPos:t+e.text.length,text:e.text,type:r,userId:i.attrs.userId||(r.includes("ai")?"ai":"unknown"),userName:i.attrs.userName||(r.includes("ai")?"AI":"User"),timestamp:i.attrs.timestamp||new Date().toISOString(),nodeType:i.attrs.linkData?"link":"text"};return i.attrs.formatChanges&&(o.formatChanges=i.attrs.formatChanges),i.attrs.linkData&&(o.linkData=i.attrs.linkData),o},C7=e=>{const t=[];return e.descendants(n=>{if(n.type.name==="tableCell"||n.type.name==="tableHeader"){const r=n.textContent.trim();r&&t.push(r)}}),t.join(" | ")},v7=e=>{const t=[];return e.forEach(n=>{if(n.type.name==="tableCell"||n.type.name==="tableHeader"){const r=n.textContent.trim();t.push(r.length>0?r:"empty cell")}}),t.join(" | ")},x7=(e,t)=>{const n=[];return e.descendants(r=>{if((r.type.name==="tableCell"||r.type.name==="tableHeader")&&r.attrs[sa]===t){const i=r.textContent.trim();return n.push(i.length>0?i:"empty cell"),!1}return!0}),n.join(" | ")},N7=e=>{for(let t=e.depth;t>0;t--){const n=e.node(t);if(n.type.name==="tableRow")return!!(n.attrs["data-redline-row-action"]&&n.attrs["data-redline-type"])}return!1},R7=e=>{for(let t=e.depth;t>0;t--){const n=e.node(t);if(n.type.name==="table")return!!n.attrs["data-redline-type"]}return!1},A7=e=>{for(let t=e.depth;t>0;t--){const n=e.node(t);if(!(n.type.name!=="tableCell"&&n.type.name!=="tableHeader"))return!!(n.attrs[Ld]&&n.attrs[sa])}return!1},O7=(e,t)=>{if(e.type.name!=="table")return null;const n=e.attrs["data-redline-type"];if(!n)return null;const r=C7(e);return{pos:t,endPos:t+e.nodeSize,text:"table",type:n,userId:e.attrs["data-redline-user-id"]||"unknown",userName:e.attrs["data-redline-user-name"]||"User",timestamp:e.attrs["data-redline-timestamp"]||new Date().toISOString(),nodeType:"table",tableData:r}},I7=(e,t)=>{if(e.type.name!=="tableRow")return null;const n=e.attrs["data-redline-type"],r=e.attrs["data-redline-row-action"];return!n||!r?null:{pos:t,endPos:t+e.nodeSize,text:"row",type:n,userId:e.attrs["data-redline-user-id"]||"unknown",userName:e.attrs["data-redline-user-name"]||"User",timestamp:e.attrs["data-redline-timestamp"]||new Date().toISOString(),nodeType:"tableRow",tableRowData:JSON.stringify({action:r,rowId:e.attrs["data-row-id"]||"",content:v7(e)})}},k7=(e,t,n)=>{if(t.type.name!=="tableCell"&&t.type.name!=="tableHeader")return null;const r=t.attrs["data-redline-type"],i=t.attrs[Ld],o=t.attrs[sa];return!r||!i||!o?null:{pos:n,endPos:n+t.nodeSize,text:"column",type:r,userId:t.attrs["data-redline-user-id"]||"unknown",userName:t.attrs["data-redline-user-name"]||"User",timestamp:t.attrs["data-redline-timestamp"]||new Date().toISOString(),nodeType:"tableColumn",tableColumnData:JSON.stringify({action:i,columnId:o,content:x7(e,o)})}},w7=(e,t)=>{if(e.type.name!=="signature")return null;const n=e.attrs.redlineType,r=e.attrs.redlineAction;return!n||!r?null:{pos:t,endPos:t+e.nodeSize,text:"signature",type:n,userId:e.attrs.redlineUserId||"unknown",userName:e.attrs.redlineUserName||"User",timestamp:e.attrs.redlineTimestamp||new Date().toISOString(),nodeType:"signature",signatureData:JSON.stringify({action:r,fileName:e.attrs.fileName??null,recipientEmail:e.attrs.recipientEmail??""})}},M7=(e,t)=>{if(e.type.name!=="variableText")return null;const n=e.attrs.redlineType,r=e.attrs.redlineAction;if(!n||!r)return null;let i={};try{i=e.attrs.redlinePreviousAttrs?JSON.parse(e.attrs.redlinePreviousAttrs):{}}catch{i={}}return{pos:t,endPos:t+e.nodeSize,text:e.attrs.value||`{{${e.attrs.variableName}}}`,type:n,userId:e.attrs.redlineUserId||"unknown",userName:e.attrs.redlineUserName||"User",timestamp:e.attrs.redlineTimestamp||new Date().toISOString(),nodeType:"variable",variableData:JSON.stringify({action:r,variableName:e.attrs.variableName,value:e.attrs.value??"",previousValue:i.value??""})}},D7=(e,t)=>{if(e.nodeType==="table"||e.nodeType==="tableRow"||e.nodeType==="tableColumn"||e.nodeType==="signature"||e.nodeType==="variable"||t.nodeType==="table"||t.nodeType==="tableRow"||t.nodeType==="tableColumn"||t.nodeType==="signature"||t.nodeType==="variable")return!1;const n=t.pos-e.endPos;return n>=0&&n<=4&&t.type===e.type&&t.userId===e.userId&&t.timestamp===e.timestamp?e.formatChanges||t.formatChanges?e.formatChanges===t.formatChanges:e.linkData||t.linkData?e.linkData===t.linkData:!0:!1},L7=e=>{const t=[];let n=0;for(;n<e.length;){const r=e[n];let i=r.text,o=r.endPos,a=n+1;for(;a<e.length;){const l=e[a];if(D7({...r,endPos:o},l))l.pos-o>0&&(i+=`
|
|
222
|
-
`),i+=l.text,o=l.endPos,a++;else break}const s={id:`${r.type}-${r.pos}-${r.timestamp}`,type:r.type,content:i,userId:r.userId,userName:r.userName,timestamp:r.timestamp,position:r.pos};if(r.nodeType==="table"&&(s.nodeType="table",s.tableData=r.tableData),r.nodeType==="tableRow"&&r.tableRowData){s.nodeType="tableRow";try{s.tableRowData=JSON.parse(r.tableRowData)}catch{}}if(r.nodeType==="tableColumn"&&r.tableColumnData){s.nodeType="tableColumn";try{s.tableColumnData=JSON.parse(r.tableColumnData)}catch{}}if(r.nodeType==="signature"&&r.signatureData){s.nodeType="signature";try{s.signatureData=JSON.parse(r.signatureData)}catch{}}if(r.nodeType==="variable"&&r.variableData){s.nodeType="variable";try{s.variableData=JSON.parse(r.variableData)}catch{}}if(r.nodeType==="link"&&r.linkData){s.nodeType="link";try{s.linkData=JSON.parse(r.linkData)}catch{}}r.formatChanges&&(s.formatChanges=r.formatChanges),t.push(s),n=a}return t},P7=e=>{const t=e.filter(n=>n.nodeType==="tableRow").map(n=>({start:n.pos,end:n.endPos}));return t.length===0?e:e.filter(n=>n.nodeType==="tableRow"||n.nodeType==="tableColumn"?!0:!t.some(r=>n.pos>=r.start&&n.endPos<=r.end))},B7=e=>{const t=e.filter(n=>n.nodeType==="tableColumn").map(n=>({start:n.pos,end:n.endPos}));return t.length===0?e:e.filter(n=>n.nodeType==="tableColumn"||n.nodeType==="tableRow"?!0:!t.some(r=>n.pos>=r.start&&n.endPos<=r.end))},F7=e=>{const t=new Set;return e.filter(n=>{if(n.nodeType!=="tableColumn"||!n.tableColumnData)return!0;try{const r=JSON.parse(n.tableColumnData),i=[n.type,n.userId,n.timestamp,r.action,r.columnId].join("::");return t.has(i)?!1:(t.add(i),!0)}catch{return!0}})},U7=e=>["bold","italic","underline","strike","superscript","subscript"].includes(e)?"text-formatting":["fontSize","fontFamily","lineHeight"].includes(e)?"font-styling":["color","backgroundColor","highlight"].includes(e)?"colors":["list","heading"].includes(e)?"structure":e,z7=e=>{if(!e.formatChanges)return[e];try{const t=JSON.parse(e.formatChanges),n=new Map;return Object.keys(t).forEach(r=>{const i=U7(r),o=n.get(i)??{};o[r]=t[r],n.set(i,o)}),Array.from(n.entries()).map(([r,i])=>({...e,id:`${e.id}::${r}`,formatChanges:JSON.stringify(i)}))}catch{return[e]}},H7=e=>{const t=e.filter(n=>n.nodeType==="table").map(n=>({start:n.pos,end:n.endPos}));return t.length===0?e:e.filter(n=>n.nodeType==="table"?!0:!t.some(r=>n.pos>=r.start&&n.endPos<=r.end))},G7=e=>{const t=[],n=new Map;return e.flatMap(z7).forEach(r=>{if(!r.formatChanges){t.push(r);return}const i=[r.type,r.userId,r.timestamp,r.nodeType||"text",r.formatChanges].join("::"),o=n.get(i);if(o===void 0){n.set(i,t.length),t.push(r);return}const a=t[o];a.position=Math.min(a.position,r.position)}),t},V7=(e,t,n,r)=>{e.chain().focus().setTextSelection({from:t,to:n}).run();const i=()=>{e.isActive("taskList")?e.chain().focus().toggleTaskList().run():e.isActive("bulletList")?e.chain().focus().toggleList("bulletList","listItem").run():e.isActive("orderedList")&&e.chain().focus().toggleList("orderedList","listItem").run()};if(r==="none"){i();return}if(r==="task"){e.isActive("taskList")||(i(),e.chain().focus().toggleTaskList().run());return}if(r.startsWith("bullet:")){const o=r.slice(7);e.isActive("bulletList")||(i(),e.chain().focus().toggleList("bulletList","listItem").run()),e.chain().focus().updateAttributes("bulletList",{listType:o}).run();return}if(r.startsWith("ordered:")){const o=r.slice(8);e.isActive("orderedList")||(i(),e.chain().focus().toggleList("orderedList","listItem").run()),e.chain().focus().updateAttributes("orderedList",{listType:o}).run()}},Y7=(e,t,n,r)=>{const i=e.chain().focus().setTextSelection({from:t,to:n});if(r==="paragraph"){i.setParagraph().run();return}const o=Number(r.substring(1));o>=1&&o<=6&&i.setHeading({level:o}).run()},Bd=(e,t,n)=>{const{state:r}=e,{tr:i}=r;if(t.nodeType==="tableRow"){let u=t.position,p=r.doc.nodeAt(u);const m=(_,h)=>_?.type.name==="tableRow"&&_.attrs["data-redline-type"]===t.type&&_.attrs["data-redline-user-id"]===t.userId&&_.attrs["data-redline-timestamp"]===t.timestamp&&(h===void 0||_.attrs["data-row-id"]===h);if(!m(p,t.tableRowData?.rowId)){let _=null;r.doc.descendants((h,g)=>_?!1:m(h,t.tableRowData?.rowId)?(u=g,_=h,!1):!0),p=_}if(p&&p.type.name==="tableRow"){if(t.tableRowData?.action==="delete")n==="accept"?i.delete(u,u+p.nodeSize):i.setNodeMarkup(u,void 0,{...p.attrs,"data-redline-type":null,"data-redline-user-id":null,"data-redline-user-name":null,"data-redline-timestamp":null,"data-redline-row-action":null});else if(n==="accept"){i.setNodeMarkup(u,void 0,{...p.attrs,"data-redline-type":null,"data-redline-user-id":null,"data-redline-user-name":null,"data-redline-timestamp":null,"data-redline-row-action":null});const h=u+1,g=u+p.nodeSize-1;["userInsertion","userDeletion","aiInsertion","aiDeletion"].forEach(E=>{const S=r.schema.marks[E];S&&i.removeMark(h,g,S)})}else i.delete(u,u+p.nodeSize);return i.docChanged?(e.view.dispatch(i),!0):!1}}if(t.nodeType==="tableColumn"){const u=t.tableColumnData?.columnId;if(!u)return!1;const p=[];return r.doc.descendants((m,_)=>(m.type.name==="tableCell"||m.type.name==="tableHeader")&&m.attrs[sa]===u&&m.attrs["data-redline-type"]===t.type&&m.attrs["data-redline-user-id"]===t.userId&&m.attrs["data-redline-timestamp"]===t.timestamp?(p.push({pos:_,node:m}),!1):!0),p.length===0?!1:(t.tableColumnData?.action==="delete"?p.sort((m,_)=>_.pos-m.pos).forEach(({pos:m})=>{const _=i.mapping.map(m),h=i.doc.nodeAt(_);if(h){if(n==="accept"){i.delete(_,_+h.nodeSize);return}i.setNodeMarkup(_,void 0,{...h.attrs,"data-redline-type":null,"data-redline-user-id":null,"data-redline-user-name":null,"data-redline-timestamp":null,[Ld]:null,[sa]:null})}}):n==="accept"?p.sort((m,_)=>_.pos-m.pos).forEach(({pos:m})=>{const _=i.mapping.map(m),h=i.doc.nodeAt(_);if(!h)return;i.setNodeMarkup(_,void 0,{...h.attrs,"data-redline-type":null,"data-redline-user-id":null,"data-redline-user-name":null,"data-redline-timestamp":null,[Ld]:null,[sa]:null});const g=_+1,b=_+h.nodeSize-1;["userInsertion","userDeletion","aiInsertion","aiDeletion"].forEach(S=>{const y=i.doc.type.schema.marks[S];y&&i.removeMark(g,b,y)})}):p.sort((m,_)=>_.pos-m.pos).forEach(({pos:m})=>{const _=i.mapping.map(m),h=i.doc.nodeAt(_);h&&i.delete(_,_+h.nodeSize)}),i.docChanged?(e.view.dispatch(i),!0):!1)}if(t.nodeType==="table"){const u=t.position,p=r.doc.nodeAt(u);if(p&&p.type.name==="table"){if(t.type.includes("insertion"))if(n==="accept"){i.setNodeMarkup(u,void 0,{...p.attrs,"data-redline-type":null,"data-redline-user-id":null,"data-redline-user-name":null,"data-redline-timestamp":null});const _=u+1,h=u+p.nodeSize-1;["userInsertion","userDeletion","aiInsertion","aiDeletion"].forEach(E=>{const S=r.schema.marks[E];S&&i.removeMark(_,h,S)});const b=[];p.descendants((E,S)=>E.type.name==="tableRow"&&E.attrs["data-redline-type"]?(b.push(u+S),!1):!0),b.sort((E,S)=>S-E),b.forEach(E=>{const S=i.mapping.map(E),y=i.doc.nodeAt(S);y?.type.name==="tableRow"&&i.setNodeMarkup(S,void 0,{...y.attrs,"data-redline-type":null,"data-redline-user-id":null,"data-redline-user-name":null,"data-redline-timestamp":null,"data-redline-row-action":null})})}else i.delete(u,u+p.nodeSize);else n==="accept"?i.delete(u,u+p.nodeSize):i.setNodeMarkup(u,void 0,{...p.attrs,"data-redline-type":null,"data-redline-user-id":null,"data-redline-user-name":null,"data-redline-timestamp":null});return i.docChanged?(e.view.dispatch(i),!0):!1}}if(t.nodeType==="signature"){const u=t.position,p=r.doc.nodeAt(u);if(p&&p.type.name==="signature"){const m=t.signatureData?.action;if(m==="add")n==="accept"?i.setNodeMarkup(u,void 0,{...p.attrs,redlineType:null,redlineUserId:null,redlineUserName:null,redlineTimestamp:null,redlineAction:null,redlinePreviousAttrs:null}):i.delete(u,u+p.nodeSize);else if(m==="delete")n==="accept"?i.delete(u,u+p.nodeSize):i.setNodeMarkup(u,void 0,{...p.attrs,redlineType:null,redlineUserId:null,redlineUserName:null,redlineTimestamp:null,redlineAction:null,redlinePreviousAttrs:null});else if(m==="update")if(n==="accept")i.setNodeMarkup(u,void 0,{...p.attrs,redlineType:null,redlineUserId:null,redlineUserName:null,redlineTimestamp:null,redlineAction:null,redlinePreviousAttrs:null});else{let _={};try{_=p.attrs.redlinePreviousAttrs?JSON.parse(p.attrs.redlinePreviousAttrs):{}}catch{_={}}i.setNodeMarkup(u,void 0,{...p.attrs,..._,redlineType:null,redlineUserId:null,redlineUserName:null,redlineTimestamp:null,redlineAction:null,redlinePreviousAttrs:null})}return i.docChanged?(e.view.dispatch(i),!0):!1}}if(t.nodeType==="variable"){const u=t.position,p=r.doc.nodeAt(u);if(p&&p.type.name==="variableText"){const m=t.variableData?.action;if(m==="add")n==="accept"?i.setNodeMarkup(u,void 0,{...p.attrs,redlineType:null,redlineUserId:null,redlineUserName:null,redlineTimestamp:null,redlineAction:null,redlinePreviousAttrs:null}):i.delete(u,u+p.nodeSize);else if(m==="delete")if(n==="accept")i.delete(u,u+p.nodeSize);else{let _={};try{_=p.attrs.redlinePreviousAttrs?JSON.parse(p.attrs.redlinePreviousAttrs):{}}catch{_={}}i.setNodeMarkup(u,void 0,{...p.attrs,..._,redlineType:null,redlineUserId:null,redlineUserName:null,redlineTimestamp:null,redlineAction:null,redlinePreviousAttrs:null})}else if(m==="update")if(n==="accept")i.setNodeMarkup(u,void 0,{...p.attrs,redlineType:null,redlineUserId:null,redlineUserName:null,redlineTimestamp:null,redlineAction:null,redlinePreviousAttrs:null});else{let _={};try{_=p.attrs.redlinePreviousAttrs?JSON.parse(p.attrs.redlinePreviousAttrs):{}}catch{_={}}i.setNodeMarkup(u,void 0,{...p.attrs,..._,redlineType:null,redlineUserId:null,redlineUserName:null,redlineTimestamp:null,redlineAction:null,redlinePreviousAttrs:null})}return i.docChanged?(e.view.dispatch(i),!0):!1}}const o=!!t.formatChanges,a=[],s=t.type.includes("insertion"),l=t.type.includes("deletion"),c=t.type.includes("ai")?s?"aiInsertion":"aiDeletion":s?"userInsertion":"userDeletion",d=r.schema.marks[c];if(!d)return!1;if(r.doc.descendants((u,p)=>{if(!u.isText)return;u.marks.find(_=>_.type.name===c&&_.attrs.timestamp===t.timestamp&&_.attrs.userId===t.userId)&&u.text&&a.push({from:p,to:p+u.text.length})}),o){let u={};try{t.formatChanges&&(u=JSON.parse(t.formatChanges))}catch{console.error("Failed to parse format changes")}let p=null,m=null,_=null,h=null;for(const g of a){const b=r.doc.nodeAt(g.from),E=b?.marks.find(y=>y.type.name===c&&y.attrs.timestamp===t.timestamp&&y.attrs.userId===t.userId);let S={};if(E?.attrs.formatChanges)try{S={...JSON.parse(E.attrs.formatChanges)},Object.keys(u).forEach(T=>{delete S[T]})}catch{S={}}if(n==="accept")i.removeMark(g.from,g.to,d),Object.keys(S).length>0&&i.addMark(g.from,g.to,d.create({...E?.attrs,formatChanges:JSON.stringify(S)}));else{i.removeMark(g.from,g.to,d);const y={};let T=!1;const v=b?.marks.find(C=>C.type.name==="textStyle")?.attrs||{};if(Object.keys(u).forEach(C=>{const{old:O,new:w}=u[C];if(["bold","italic","underline","strike","superscript","subscript"].includes(C)){const N=r.schema.marks[C];N&&(w&&i.removeMark(g.from,g.to,N),O&&i.addMark(g.from,g.to,N.create()))}else["color","backgroundColor","fontSize","fontFamily","lineHeight"].includes(C)?(y[C]=O,T=!0):C==="highlight"&&r.schema.marks.highlight?(i.removeMark(g.from,g.to,r.schema.marks.highlight),O&&O!==null&&i.addMark(g.from,g.to,r.schema.marks.highlight.create({color:O}))):C==="list"&&typeof O=="string"?(p=O,m=m?{from:Math.min(m.from,g.from),to:Math.max(m.to,g.to)}:{from:g.from,to:g.to}):C==="heading"&&typeof O=="string"&&(_=O,h=h?{from:Math.min(h.from,g.from),to:Math.max(h.to,g.to)}:{from:g.from,to:g.to})}),T&&r.schema.marks.textStyle){i.removeMark(g.from,g.to,r.schema.marks.textStyle);const C={...v,...y};Object.keys(C).forEach(O=>{(C[O]===null||C[O]===void 0)&&delete C[O]}),Object.keys(C).length>0&&i.addMark(g.from,g.to,r.schema.marks.textStyle.create(C))}Object.keys(S).length>0&&i.addMark(g.from,g.to,d.create({...E?.attrs,formatChanges:JSON.stringify(S)}))}}if(i.docChanged){if(e.view.dispatch(i),n==="reject"&&p&&m!==null){const{from:g,to:b}=m;V7(e,g,b,p)}if(n==="reject"&&_&&h!==null){const{from:g,to:b}=h;Y7(e,g,b,_)}return!0}}else{(s&&n==="reject"||l&&n==="accept")&&a.sort((u,p)=>p.from-u.from);for(const u of a)s?n==="accept"?i.removeMark(u.from,u.to,d):i.delete(u.from,u.to):l&&(n==="accept"?i.delete(u.from,u.to):i.removeMark(u.from,u.to,d))}return i.docChanged?(e.view.dispatch(i),!0):!1},Yf=()=>{const{editor:e,editorConfig:t}=nt(),[n,r]=A.useState([]),i=A.useCallback(()=>{if(!e)return;const{state:g}=e,{doc:b}=g,E=[];b.descendants((T,x)=>{const v=O7(T,x);if(v)return E.push(v),!1;const C=w7(T,x);if(C)return E.push(C),!1;const O=I7(T,x);if(O)return E.push(O),!0;const w=k7(b,T,x);if(w)return E.push(w),!1;if(R7(b.resolve(x))||A7(b.resolve(x))||N7(b.resolve(x)))return!1;const z=M7(T,x);if(z)return E.push(z),!1;const N=Pd(T,x,"userInsertion","user-insertion");N&&E.push(N);const P=Pd(T,x,"userDeletion","user-deletion");P&&E.push(P);const I=Pd(T,x,"aiInsertion","ai-insertion");I&&E.push(I);const R=Pd(T,x,"aiDeletion","ai-deletion");R&&E.push(R)});const S=P7(B7(F7(H7(E))));S.sort((T,x)=>T.pos-x.pos);const y=G7(L7(S));r(y)},[e]);A.useEffect(()=>{if(!e)return;i();const g=()=>i();return e.on("update",g),()=>{e.off("update",g)}},[e,i]);const o=A.useCallback(g=>{if(!e)return;const b=n.find(E=>E.id===g);b&&Bd(e,b,"accept")},[e,n]),a=A.useCallback(g=>{if(!e)return;const b=n.find(E=>E.id===g);b&&Bd(e,b,"reject")},[e,n]),s=A.useCallback(()=>{if(!e||n.length===0)return;[...n].sort((b,E)=>E.position-b.position).forEach(b=>{Bd(e,b,"accept")})},[e,n]),l=A.useCallback(()=>{if(!e||n.length===0)return;[...n].sort((b,E)=>E.position-b.position).forEach(b=>{Bd(e,b,"reject")})},[e,n]),c=A.useCallback((g,b,E)=>{if(e)try{e.commands.focus(),e.commands.setTextSelection(g),b!==void 0&&E!==void 0&&e.commands.highlightMark(b,E);const{view:S}=e,y=S.coordsAtPos(g);y&&document.elementFromPoint(y.left,y.top)?.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})}catch(S){console.error("Error navigating to change:",S)}},[e]),d=A.useCallback((g,b)=>{if(e)try{e.commands.highlightMark(g,b)}catch(E){console.error("Error highlighting mark:",E)}},[e]),u=A.useCallback(()=>{if(e)try{e.commands.highlightMark(null,null)}catch(g){console.error("Error clearing mark highlight:",g)}},[e]),p=A.useCallback((g,b)=>{r(E=>E.map(S=>{if(S.id===g){const y={id:`comment-${Date.now()}-${Math.random()}`,userId:t.currentUser?.id||"unknown",userName:t.currentUser?.name||"User",timestamp:new Date().toISOString(),text:b};return{...S,comments:[...S.comments||[],y]}}return S}))},[t.currentUser]),m=A.useCallback((g,b,E)=>{r(S=>S.map(y=>y.id===g&&y.comments?{...y,comments:y.comments.map(T=>T.id===b?{...T,text:E}:T)}:y))},[]),_=A.useCallback((g,b)=>{r(E=>E.map(S=>S.id===g&&S.comments?{...S,comments:S.comments.filter(y=>y.id!==b)}:S))},[]),h=A.useCallback((g,b)=>n.find(E=>E.timestamp===g&&E.userId===b)||null,[n]);return{changes:n,acceptChange:o,rejectChange:a,acceptAllChanges:s,rejectAllChanges:l,navigateToChange:c,scanChanges:i,addComment:p,editComment:m,deleteComment:_,findChangeByMark:h,highlightMark:d,clearMarkHighlight:u}},$7=35,W7=120,j7=()=>{const{editor:e,editorConfig:t}=nt(),{changes:n,navigateToChange:r,findChangeByMark:i,clearMarkHighlight:o}=Yf(),[a,s]=A.useState(null),[l,c]=A.useState(null),[d,u]=A.useState(new Map),p=A.useRef(new Map),m=A.useRef(null),_=A.useCallback(S=>{const y=document.querySelector(`[data-timestamp="${S.timestamp}"][data-user-id="${S.userId}"]`)??document.querySelector(`[data-redline-timestamp="${S.timestamp}"][data-redline-user-id="${S.userId}"]`);if(y instanceof Element)return y;if(!e)return null;const T=e.view.nodeDOM(S.position);return T instanceof Element?T:T instanceof Text?T.parentElement:null},[e]),h=A.useCallback(()=>{const S=new Map,y=document.querySelector("#editor-shell-qwCfsxssdsfsd"),T=document.querySelector("#editor-content-qwCfsdsfsd"),x=document.querySelector("#editor-sidebar-qwCfsdsfsd");if(!y||!T)return S;const v=t?.parentContainerId,C=v?document.querySelector(`#${v}`):null,O=y.getBoundingClientRect(),w=T.getBoundingClientRect(),z=x?.getBoundingClientRect(),N=C?.getBoundingClientRect(),P=z?z.left:O.right,I=20,M=P-w.right<420+I*2,B=4,D=[];return n.forEach(U=>{const H=_(U);if(H){const V=H.getBoundingClientRect(),q=p.current.get(U.id),W=q?q.getBoundingClientRect().height:M?$7:W7,oe=w.right-(N?.left||0)+I;let Z=V.top,X=!0,se=0;const be=20;for(;X&&se<be;){X=!1,se++;for(const pe of D)if(Z<pe.bottom&&Z+W>pe.top){Z=pe.bottom+B,X=!0;break}}D.push({top:Z,bottom:Z+W}),S.set(U.id,{changeId:U.id,top:Z,left:oe,showCompact:M})}}),S},[n,t?.parentContainerId,_]),g=A.useCallback((S,y)=>{const T=document.querySelector("#editor-shell-qwCfsxssdsfsd");if(!T)return null;const x=n.find(U=>U.timestamp===S&&U.userId===y),v=x?_(x):null;if(!v)return null;const C=T.getBoundingClientRect(),O=v.getBoundingClientRect(),w=380,z=400,N=10;let I=O.left+O.width/2-w/2;const R=20;I<C.left+R?I=C.left+R:I+w>C.right-R&&(I=C.right-w-R);const k=O.top-C.top,M=C.bottom-O.bottom,B=k<z+N&&M>=z+N;return{top:B?O.bottom+N:O.top-N,left:I,showBelow:B}},[n,_]),b=A.useCallback(S=>{const y=n.find(T=>T.id===S);if(y){s(S);const T=d.get(S);if(T&&T.showCompact){const x=g(y.timestamp,y.userId);x&&c(x)}else c(null);r(y.position,y.timestamp,y.userId)}},[n,d,g,r]),E=A.useCallback(S=>{s(S);const y=d.get(S);if(y&&y.showCompact){const T=n.find(x=>x.id===S);if(T){const x=g(T.timestamp,T.userId);x&&c(x)}}},[d,n,g]);return A.useEffect(()=>{const S=()=>{const T=h();u(T)};S(),window.addEventListener("scroll",S,!0),window.addEventListener("resize",S);const y=setInterval(S,0);return()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",S),clearInterval(y)}},[h]),A.useEffect(()=>{const S=y=>{const T=y,{timestamp:x,userId:v}=T.detail,C=i(x,v);C&&E(C.id)};return window.addEventListener("redline:markClick",S),()=>{window.removeEventListener("redline:markClick",S)}},[i,E]),A.useEffect(()=>{const S=y=>{const T=y.target,x=T.closest("[data-redline-item]"),v=T.closest("[data-timestamp]");!x&&!v&&(s(null),c(null),o())};return document.addEventListener("mousedown",S),()=>{document.removeEventListener("mousedown",S)}},[o]),A.useEffect(()=>{if(!a)return;const S=()=>{const y=n.find(T=>T.id===a);if(y){const T=g(y.timestamp,y.userId);T&&c(T)}};return window.addEventListener("scroll",S,!0),window.addEventListener("resize",S),()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",S)}},[a,n,g]),A.useEffect(()=>{if(!a)return;const S=n.find(x=>x.id===a);if(!S)return;_(S)?.scrollIntoView({behavior:"smooth",block:"center"}),p.current.get(a)?.scrollIntoView({behavior:"smooth",block:"nearest"})},[a,n,_]),{panelRef:m,itemRefs:p,itemPositions:d,activeItemId:a,popupPosition:l,setActiveItemId:s,setPopupPosition:c,handleLabelClick:b}},xy=!1,q7=()=>{const{currentMode:e}=xd(),{editorConfig:t,redlineItemWidth:n,setRedlineItemWidth:r}=nt(),{changes:i,acceptChange:o,rejectChange:a,navigateToChange:s,addComment:l,editComment:c,deleteComment:d}=Yf(),{panelRef:u,itemPositions:p,itemRefs:m,activeItemId:_,popupPosition:h,setActiveItemId:g,setPopupPosition:b,handleLabelClick:E}=j7(),S=e===ui.SUGGESTING.value,y=!t.asViewer&&e!==ui.VIEWING.value,T=t.currentUser,x=_?i.find(U=>U.id===_):null,[v,C]=A.useState(!1),O=A.useRef(null),w=_?p.get(_):null,z=x&&h&&w?.showCompact,N=U=>U.includes("insertion")?"Add":U.includes("deletion")?"Del":"Change",P=U=>{const H=U.nodeType==="link"||!!U.linkData,V=U.nodeType==="signature",q=U.nodeType==="table",W=U.nodeType==="tableRow",oe=U.nodeType==="tableColumn",Z=U.nodeType==="variable";return!!U.formatChanges&&!H?"Format":H?"Link":V?"Signature":W?"Row":oe?"Column":q?"Table":Z?"Variable":U.type.includes("insertion")?"Add":U.type.includes("deletion")?"Delete":"Change"},I=Array.from(p.values()),R=5,k=I[0]?.left??0,M=I[0]?.showCompact??!1,B=M?120:380,D=I.reduce((U,H)=>{const V=m.current.get(H.changeId),q=V?V.getBoundingClientRect().height:M?35:120,W=H.showCompact?R*I.findIndex(oe=>oe.changeId===H.changeId):0;return Math.max(U,H.top+W+q)},0);return A.useEffect(()=>{r(B)},[B,r]),A.useEffect(()=>{const U=()=>{C(!0),O.current&&window.clearTimeout(O.current),O.current=window.setTimeout(()=>{C(!1)},120)},H=()=>{U()};window.addEventListener("resize",H);let V=null;if(typeof ResizeObserver<"u"){V=new ResizeObserver(()=>{U()});const q=[],W=document.querySelector("#editor-shell-qwCfsxssdsfsd"),oe=document.querySelector("#editor-content-qwCfsdsfsd"),Z=document.querySelector("#editor-sidebar-qwCfsdsfsd"),X=t?.parentContainerId?document.querySelector(`#${t.parentContainerId}`):null;W&&q.push(W),oe&&q.push(oe),Z&&q.push(Z),X&&q.push(X),q.forEach(se=>V?.observe(se))}return()=>{window.removeEventListener("resize",H),V?.disconnect(),O.current&&window.clearTimeout(O.current)}},[t?.parentContainerId]),i.length===0?null:f.jsxs(f.Fragment,{children:[f.jsx("div",{ref:u,"data-redline-panel":"true",className:"fixed top-0 overflow-y-auto pointer-events-auto",style:{left:`${k}px`,height:"93vh",width:`${n+20}px`,scrollbarWidth:"none",transition:v?"none":"width 220ms ease",pointerEvents:"none"},children:f.jsx("div",{style:{position:"relative",height:`${D+32}px`},children:I.map((U,H)=>{const V=i.find(oe=>oe.id===U.changeId);if(!V)return null;const q=U.top+(U.showCompact?H*R:0),W=_===V.id;return U.showCompact?f.jsx("div",{"data-redline-item":"true",className:"relative",style:{position:"absolute",top:`${q}px`,left:7,zIndex:W?8:3,pointerEvents:"auto",transition:v?"none":"top 200ms ease, left 200ms ease"},children:f.jsxs("button",{onClick:()=>E(V.id),className:`
|
|
222
|
+
`),i+=l.text,o=l.endPos,a++;else break}const s={id:`${r.type}-${r.pos}-${r.timestamp}`,type:r.type,content:i,userId:r.userId,userName:r.userName,timestamp:r.timestamp,position:r.pos};if(r.nodeType==="table"&&(s.nodeType="table",s.tableData=r.tableData),r.nodeType==="tableRow"&&r.tableRowData){s.nodeType="tableRow";try{s.tableRowData=JSON.parse(r.tableRowData)}catch{}}if(r.nodeType==="tableColumn"&&r.tableColumnData){s.nodeType="tableColumn";try{s.tableColumnData=JSON.parse(r.tableColumnData)}catch{}}if(r.nodeType==="signature"&&r.signatureData){s.nodeType="signature";try{s.signatureData=JSON.parse(r.signatureData)}catch{}}if(r.nodeType==="variable"&&r.variableData){s.nodeType="variable";try{s.variableData=JSON.parse(r.variableData)}catch{}}if(r.nodeType==="link"&&r.linkData){s.nodeType="link";try{s.linkData=JSON.parse(r.linkData)}catch{}}r.formatChanges&&(s.formatChanges=r.formatChanges),t.push(s),n=a}return t},P7=e=>{const t=e.filter(n=>n.nodeType==="tableRow").map(n=>({start:n.pos,end:n.endPos}));return t.length===0?e:e.filter(n=>n.nodeType==="tableRow"||n.nodeType==="tableColumn"?!0:!t.some(r=>n.pos>=r.start&&n.endPos<=r.end))},B7=e=>{const t=e.filter(n=>n.nodeType==="tableColumn").map(n=>({start:n.pos,end:n.endPos}));return t.length===0?e:e.filter(n=>n.nodeType==="tableColumn"||n.nodeType==="tableRow"?!0:!t.some(r=>n.pos>=r.start&&n.endPos<=r.end))},F7=e=>{const t=new Set;return e.filter(n=>{if(n.nodeType!=="tableColumn"||!n.tableColumnData)return!0;try{const r=JSON.parse(n.tableColumnData),i=[n.type,n.userId,n.timestamp,r.action,r.columnId].join("::");return t.has(i)?!1:(t.add(i),!0)}catch{return!0}})},U7=e=>["bold","italic","underline","strike","superscript","subscript"].includes(e)?"text-formatting":["fontSize","fontFamily","lineHeight"].includes(e)?"font-styling":["color","backgroundColor","highlight"].includes(e)?"colors":["list","heading"].includes(e)?"structure":e,z7=e=>{if(!e.formatChanges)return[e];try{const t=JSON.parse(e.formatChanges),n=new Map;return Object.keys(t).forEach(r=>{const i=U7(r),o=n.get(i)??{};o[r]=t[r],n.set(i,o)}),Array.from(n.entries()).map(([r,i])=>({...e,id:`${e.id}::${r}`,formatChanges:JSON.stringify(i)}))}catch{return[e]}},H7=e=>{const t=e.filter(n=>n.nodeType==="table").map(n=>({start:n.pos,end:n.endPos}));return t.length===0?e:e.filter(n=>n.nodeType==="table"?!0:!t.some(r=>n.pos>=r.start&&n.endPos<=r.end))},G7=e=>{const t=[],n=new Map;return e.flatMap(z7).forEach(r=>{if(!r.formatChanges){t.push(r);return}const i=[r.type,r.userId,r.timestamp,r.nodeType||"text",r.formatChanges].join("::"),o=n.get(i);if(o===void 0){n.set(i,t.length),t.push(r);return}const a=t[o];a.position=Math.min(a.position,r.position)}),t},V7=(e,t,n,r)=>{e.chain().focus().setTextSelection({from:t,to:n}).run();const i=()=>{e.isActive("taskList")?e.chain().focus().toggleTaskList().run():e.isActive("bulletList")?e.chain().focus().toggleList("bulletList","listItem").run():e.isActive("orderedList")&&e.chain().focus().toggleList("orderedList","listItem").run()};if(r==="none"){i();return}if(r==="task"){e.isActive("taskList")||(i(),e.chain().focus().toggleTaskList().run());return}if(r.startsWith("bullet:")){const o=r.slice(7);e.isActive("bulletList")||(i(),e.chain().focus().toggleList("bulletList","listItem").run()),e.chain().focus().updateAttributes("bulletList",{listType:o}).run();return}if(r.startsWith("ordered:")){const o=r.slice(8);e.isActive("orderedList")||(i(),e.chain().focus().toggleList("orderedList","listItem").run()),e.chain().focus().updateAttributes("orderedList",{listType:o}).run()}},Y7=(e,t,n,r)=>{const i=e.chain().focus().setTextSelection({from:t,to:n});if(r==="paragraph"){i.setParagraph().run();return}const o=Number(r.substring(1));o>=1&&o<=6&&i.setHeading({level:o}).run()},Bd=(e,t,n)=>{const{state:r}=e,{tr:i}=r;if(t.nodeType==="tableRow"){let u=t.position,p=r.doc.nodeAt(u);const m=(_,h)=>_?.type.name==="tableRow"&&_.attrs["data-redline-type"]===t.type&&_.attrs["data-redline-user-id"]===t.userId&&_.attrs["data-redline-timestamp"]===t.timestamp&&(h===void 0||_.attrs["data-row-id"]===h);if(!m(p,t.tableRowData?.rowId)){let _=null;r.doc.descendants((h,g)=>_?!1:m(h,t.tableRowData?.rowId)?(u=g,_=h,!1):!0),p=_}if(p&&p.type.name==="tableRow"){if(t.tableRowData?.action==="delete")n==="accept"?i.delete(u,u+p.nodeSize):i.setNodeMarkup(u,void 0,{...p.attrs,"data-redline-type":null,"data-redline-user-id":null,"data-redline-user-name":null,"data-redline-timestamp":null,"data-redline-row-action":null});else if(n==="accept"){i.setNodeMarkup(u,void 0,{...p.attrs,"data-redline-type":null,"data-redline-user-id":null,"data-redline-user-name":null,"data-redline-timestamp":null,"data-redline-row-action":null});const h=u+1,g=u+p.nodeSize-1;["userInsertion","userDeletion","aiInsertion","aiDeletion"].forEach(E=>{const S=r.schema.marks[E];S&&i.removeMark(h,g,S)})}else i.delete(u,u+p.nodeSize);return i.docChanged?(e.view.dispatch(i),!0):!1}}if(t.nodeType==="tableColumn"){const u=t.tableColumnData?.columnId;if(!u)return!1;const p=[];return r.doc.descendants((m,_)=>(m.type.name==="tableCell"||m.type.name==="tableHeader")&&m.attrs[sa]===u&&m.attrs["data-redline-type"]===t.type&&m.attrs["data-redline-user-id"]===t.userId&&m.attrs["data-redline-timestamp"]===t.timestamp?(p.push({pos:_,node:m}),!1):!0),p.length===0?!1:(t.tableColumnData?.action==="delete"?p.sort((m,_)=>_.pos-m.pos).forEach(({pos:m})=>{const _=i.mapping.map(m),h=i.doc.nodeAt(_);if(h){if(n==="accept"){i.delete(_,_+h.nodeSize);return}i.setNodeMarkup(_,void 0,{...h.attrs,"data-redline-type":null,"data-redline-user-id":null,"data-redline-user-name":null,"data-redline-timestamp":null,[Ld]:null,[sa]:null})}}):n==="accept"?p.sort((m,_)=>_.pos-m.pos).forEach(({pos:m})=>{const _=i.mapping.map(m),h=i.doc.nodeAt(_);if(!h)return;i.setNodeMarkup(_,void 0,{...h.attrs,"data-redline-type":null,"data-redline-user-id":null,"data-redline-user-name":null,"data-redline-timestamp":null,[Ld]:null,[sa]:null});const g=_+1,b=_+h.nodeSize-1;["userInsertion","userDeletion","aiInsertion","aiDeletion"].forEach(S=>{const y=i.doc.type.schema.marks[S];y&&i.removeMark(g,b,y)})}):p.sort((m,_)=>_.pos-m.pos).forEach(({pos:m})=>{const _=i.mapping.map(m),h=i.doc.nodeAt(_);h&&i.delete(_,_+h.nodeSize)}),i.docChanged?(e.view.dispatch(i),!0):!1)}if(t.nodeType==="table"){const u=t.position,p=r.doc.nodeAt(u);if(p&&p.type.name==="table"){if(t.type.includes("insertion"))if(n==="accept"){i.setNodeMarkup(u,void 0,{...p.attrs,"data-redline-type":null,"data-redline-user-id":null,"data-redline-user-name":null,"data-redline-timestamp":null});const _=u+1,h=u+p.nodeSize-1;["userInsertion","userDeletion","aiInsertion","aiDeletion"].forEach(E=>{const S=r.schema.marks[E];S&&i.removeMark(_,h,S)});const b=[];p.descendants((E,S)=>E.type.name==="tableRow"&&E.attrs["data-redline-type"]?(b.push(u+S),!1):!0),b.sort((E,S)=>S-E),b.forEach(E=>{const S=i.mapping.map(E),y=i.doc.nodeAt(S);y?.type.name==="tableRow"&&i.setNodeMarkup(S,void 0,{...y.attrs,"data-redline-type":null,"data-redline-user-id":null,"data-redline-user-name":null,"data-redline-timestamp":null,"data-redline-row-action":null})})}else i.delete(u,u+p.nodeSize);else n==="accept"?i.delete(u,u+p.nodeSize):i.setNodeMarkup(u,void 0,{...p.attrs,"data-redline-type":null,"data-redline-user-id":null,"data-redline-user-name":null,"data-redline-timestamp":null});return i.docChanged?(e.view.dispatch(i),!0):!1}}if(t.nodeType==="signature"){const u=t.position,p=r.doc.nodeAt(u);if(p&&p.type.name==="signature"){const m=t.signatureData?.action;if(m==="add")n==="accept"?i.setNodeMarkup(u,void 0,{...p.attrs,redlineType:null,redlineUserId:null,redlineUserName:null,redlineTimestamp:null,redlineAction:null,redlinePreviousAttrs:null}):i.delete(u,u+p.nodeSize);else if(m==="delete")n==="accept"?i.delete(u,u+p.nodeSize):i.setNodeMarkup(u,void 0,{...p.attrs,redlineType:null,redlineUserId:null,redlineUserName:null,redlineTimestamp:null,redlineAction:null,redlinePreviousAttrs:null});else if(m==="update")if(n==="accept")i.setNodeMarkup(u,void 0,{...p.attrs,redlineType:null,redlineUserId:null,redlineUserName:null,redlineTimestamp:null,redlineAction:null,redlinePreviousAttrs:null});else{let _={};try{_=p.attrs.redlinePreviousAttrs?JSON.parse(p.attrs.redlinePreviousAttrs):{}}catch{_={}}i.setNodeMarkup(u,void 0,{...p.attrs,..._,redlineType:null,redlineUserId:null,redlineUserName:null,redlineTimestamp:null,redlineAction:null,redlinePreviousAttrs:null})}return i.docChanged?(e.view.dispatch(i),!0):!1}}if(t.nodeType==="variable"){const u=t.position,p=r.doc.nodeAt(u);if(p&&p.type.name==="variableText"){const m=t.variableData?.action;if(m==="add")n==="accept"?i.setNodeMarkup(u,void 0,{...p.attrs,redlineType:null,redlineUserId:null,redlineUserName:null,redlineTimestamp:null,redlineAction:null,redlinePreviousAttrs:null}):i.delete(u,u+p.nodeSize);else if(m==="delete")if(n==="accept")i.delete(u,u+p.nodeSize);else{let _={};try{_=p.attrs.redlinePreviousAttrs?JSON.parse(p.attrs.redlinePreviousAttrs):{}}catch{_={}}i.setNodeMarkup(u,void 0,{...p.attrs,..._,redlineType:null,redlineUserId:null,redlineUserName:null,redlineTimestamp:null,redlineAction:null,redlinePreviousAttrs:null})}else if(m==="update")if(n==="accept")i.setNodeMarkup(u,void 0,{...p.attrs,redlineType:null,redlineUserId:null,redlineUserName:null,redlineTimestamp:null,redlineAction:null,redlinePreviousAttrs:null});else{let _={};try{_=p.attrs.redlinePreviousAttrs?JSON.parse(p.attrs.redlinePreviousAttrs):{}}catch{_={}}i.setNodeMarkup(u,void 0,{...p.attrs,..._,redlineType:null,redlineUserId:null,redlineUserName:null,redlineTimestamp:null,redlineAction:null,redlinePreviousAttrs:null})}return i.docChanged?(e.view.dispatch(i),!0):!1}}const o=!!t.formatChanges,a=[],s=t.type.includes("insertion"),l=t.type.includes("deletion"),c=t.type.includes("ai")?s?"aiInsertion":"aiDeletion":s?"userInsertion":"userDeletion",d=r.schema.marks[c];if(!d)return!1;if(r.doc.descendants((u,p)=>{if(!u.isText)return;u.marks.find(_=>_.type.name===c&&_.attrs.timestamp===t.timestamp&&_.attrs.userId===t.userId)&&u.text&&a.push({from:p,to:p+u.text.length})}),o){let u={};try{t.formatChanges&&(u=JSON.parse(t.formatChanges))}catch{console.error("Failed to parse format changes")}let p=null,m=null,_=null,h=null;for(const g of a){const b=r.doc.nodeAt(g.from),E=b?.marks.find(y=>y.type.name===c&&y.attrs.timestamp===t.timestamp&&y.attrs.userId===t.userId);let S={};if(E?.attrs.formatChanges)try{S={...JSON.parse(E.attrs.formatChanges)},Object.keys(u).forEach(T=>{delete S[T]})}catch{S={}}if(n==="accept")i.removeMark(g.from,g.to,d),Object.keys(S).length>0&&i.addMark(g.from,g.to,d.create({...E?.attrs,formatChanges:JSON.stringify(S)}));else{i.removeMark(g.from,g.to,d);const y={};let T=!1;const v=b?.marks.find(C=>C.type.name==="textStyle")?.attrs||{};if(Object.keys(u).forEach(C=>{const{old:O,new:w}=u[C];if(["bold","italic","underline","strike","superscript","subscript"].includes(C)){const N=r.schema.marks[C];N&&(w&&i.removeMark(g.from,g.to,N),O&&i.addMark(g.from,g.to,N.create()))}else["color","backgroundColor","fontSize","fontFamily","lineHeight"].includes(C)?(y[C]=O,T=!0):C==="highlight"&&r.schema.marks.highlight?(i.removeMark(g.from,g.to,r.schema.marks.highlight),O&&O!==null&&i.addMark(g.from,g.to,r.schema.marks.highlight.create({color:O}))):C==="list"&&typeof O=="string"?(p=O,m=m?{from:Math.min(m.from,g.from),to:Math.max(m.to,g.to)}:{from:g.from,to:g.to}):C==="heading"&&typeof O=="string"&&(_=O,h=h?{from:Math.min(h.from,g.from),to:Math.max(h.to,g.to)}:{from:g.from,to:g.to})}),T&&r.schema.marks.textStyle){i.removeMark(g.from,g.to,r.schema.marks.textStyle);const C={...v,...y};Object.keys(C).forEach(O=>{(C[O]===null||C[O]===void 0)&&delete C[O]}),Object.keys(C).length>0&&i.addMark(g.from,g.to,r.schema.marks.textStyle.create(C))}Object.keys(S).length>0&&i.addMark(g.from,g.to,d.create({...E?.attrs,formatChanges:JSON.stringify(S)}))}}if(i.docChanged){if(e.view.dispatch(i),n==="reject"&&p&&m!==null){const{from:g,to:b}=m;V7(e,g,b,p)}if(n==="reject"&&_&&h!==null){const{from:g,to:b}=h;Y7(e,g,b,_)}return!0}}else{(s&&n==="reject"||l&&n==="accept")&&a.sort((u,p)=>p.from-u.from);for(const u of a)s?n==="accept"?i.removeMark(u.from,u.to,d):i.delete(u.from,u.to):l&&(n==="accept"?i.delete(u.from,u.to):i.removeMark(u.from,u.to,d))}return i.docChanged?(e.view.dispatch(i),!0):!1},Yf=()=>{const{editor:e,editorConfig:t}=nt(),[n,r]=A.useState([]),i=A.useCallback(()=>{if(!e)return;const{state:g}=e,{doc:b}=g,E=[];b.descendants((T,x)=>{const v=O7(T,x);if(v)return E.push(v),!1;const C=w7(T,x);if(C)return E.push(C),!1;const O=I7(T,x);if(O)return E.push(O),!0;const w=k7(b,T,x);if(w)return E.push(w),!1;if(R7(b.resolve(x))||A7(b.resolve(x))||N7(b.resolve(x)))return!1;const z=M7(T,x);if(z)return E.push(z),!1;const N=Pd(T,x,"userInsertion","user-insertion");N&&E.push(N);const P=Pd(T,x,"userDeletion","user-deletion");P&&E.push(P);const I=Pd(T,x,"aiInsertion","ai-insertion");I&&E.push(I);const R=Pd(T,x,"aiDeletion","ai-deletion");R&&E.push(R)});const S=P7(B7(F7(H7(E))));S.sort((T,x)=>T.pos-x.pos);const y=G7(L7(S));r(y)},[e]);A.useEffect(()=>{if(!e)return;i();const g=()=>i();return e.on("update",g),()=>{e.off("update",g)}},[e,i]);const o=A.useCallback(g=>{if(!e)return;const b=n.find(E=>E.id===g);b&&Bd(e,b,"accept")},[e,n]),a=A.useCallback(g=>{if(!e)return;const b=n.find(E=>E.id===g);b&&Bd(e,b,"reject")},[e,n]),s=A.useCallback(()=>{if(!e||n.length===0)return;[...n].sort((b,E)=>E.position-b.position).forEach(b=>{Bd(e,b,"accept")})},[e,n]),l=A.useCallback(()=>{if(!e||n.length===0)return;[...n].sort((b,E)=>E.position-b.position).forEach(b=>{Bd(e,b,"reject")})},[e,n]),c=A.useCallback((g,b,E)=>{if(e)try{e.commands.focus(),e.commands.setTextSelection(g),b!==void 0&&E!==void 0&&e.commands.highlightMark(b,E);const{view:S}=e,y=S.coordsAtPos(g);y&&document.elementFromPoint(y.left,y.top)?.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})}catch(S){console.error("Error navigating to change:",S)}},[e]),d=A.useCallback((g,b)=>{if(e)try{e.commands.highlightMark(g,b)}catch(E){console.error("Error highlighting mark:",E)}},[e]),u=A.useCallback(()=>{if(e)try{e.commands.highlightMark(null,null)}catch(g){console.error("Error clearing mark highlight:",g)}},[e]),p=A.useCallback((g,b)=>{r(E=>E.map(S=>{if(S.id===g){const y={id:`comment-${Date.now()}-${Math.random()}`,userId:t.currentUser?.id||"unknown",userName:t.currentUser?.name||t.currentUser?.email||"Anonymous User",timestamp:new Date().toISOString(),text:b};return{...S,comments:[...S.comments||[],y]}}return S}))},[t.currentUser]),m=A.useCallback((g,b,E)=>{r(S=>S.map(y=>y.id===g&&y.comments?{...y,comments:y.comments.map(T=>T.id===b?{...T,text:E}:T)}:y))},[]),_=A.useCallback((g,b)=>{r(E=>E.map(S=>S.id===g&&S.comments?{...S,comments:S.comments.filter(y=>y.id!==b)}:S))},[]),h=A.useCallback((g,b)=>n.find(E=>E.timestamp===g&&E.userId===b)||null,[n]);return{changes:n,acceptChange:o,rejectChange:a,acceptAllChanges:s,rejectAllChanges:l,navigateToChange:c,scanChanges:i,addComment:p,editComment:m,deleteComment:_,findChangeByMark:h,highlightMark:d,clearMarkHighlight:u}},$7=35,W7=120,j7=()=>{const{editor:e,editorConfig:t}=nt(),{changes:n,navigateToChange:r,findChangeByMark:i,clearMarkHighlight:o}=Yf(),[a,s]=A.useState(null),[l,c]=A.useState(null),[d,u]=A.useState(new Map),p=A.useRef(new Map),m=A.useRef(null),_=A.useCallback(S=>{const y=document.querySelector(`[data-timestamp="${S.timestamp}"][data-user-id="${S.userId}"]`)??document.querySelector(`[data-redline-timestamp="${S.timestamp}"][data-redline-user-id="${S.userId}"]`);if(y instanceof Element)return y;if(!e)return null;const T=e.view.nodeDOM(S.position);return T instanceof Element?T:T instanceof Text?T.parentElement:null},[e]),h=A.useCallback(()=>{const S=new Map,y=document.querySelector("#editor-shell-qwCfsxssdsfsd"),T=document.querySelector("#editor-content-qwCfsdsfsd"),x=document.querySelector("#editor-sidebar-qwCfsdsfsd");if(!y||!T)return S;const v=t?.parentContainerId,C=v?document.querySelector(`#${v}`):null,O=y.getBoundingClientRect(),w=T.getBoundingClientRect(),z=x?.getBoundingClientRect(),N=C?.getBoundingClientRect(),P=z?z.left:O.right,I=20,M=P-w.right<420+I*2,B=4,D=[];return n.forEach(U=>{const H=_(U);if(H){const V=H.getBoundingClientRect(),q=p.current.get(U.id),W=q?q.getBoundingClientRect().height:M?$7:W7,oe=w.right-(N?.left||0)+I;let Z=V.top,X=!0,se=0;const be=20;for(;X&&se<be;){X=!1,se++;for(const pe of D)if(Z<pe.bottom&&Z+W>pe.top){Z=pe.bottom+B,X=!0;break}}D.push({top:Z,bottom:Z+W}),S.set(U.id,{changeId:U.id,top:Z,left:oe,showCompact:M})}}),S},[n,t?.parentContainerId,_]),g=A.useCallback((S,y)=>{const T=document.querySelector("#editor-shell-qwCfsxssdsfsd");if(!T)return null;const x=n.find(U=>U.timestamp===S&&U.userId===y),v=x?_(x):null;if(!v)return null;const C=T.getBoundingClientRect(),O=v.getBoundingClientRect(),w=380,z=400,N=10;let I=O.left+O.width/2-w/2;const R=20;I<C.left+R?I=C.left+R:I+w>C.right-R&&(I=C.right-w-R);const k=O.top-C.top,M=C.bottom-O.bottom,B=k<z+N&&M>=z+N;return{top:B?O.bottom+N:O.top-N,left:I,showBelow:B}},[n,_]),b=A.useCallback(S=>{const y=n.find(T=>T.id===S);if(y){s(S);const T=d.get(S);if(T&&T.showCompact){const x=g(y.timestamp,y.userId);x&&c(x)}else c(null);r(y.position,y.timestamp,y.userId)}},[n,d,g,r]),E=A.useCallback(S=>{s(S);const y=d.get(S);if(y&&y.showCompact){const T=n.find(x=>x.id===S);if(T){const x=g(T.timestamp,T.userId);x&&c(x)}}},[d,n,g]);return A.useEffect(()=>{const S=()=>{const T=h();u(T)};S(),window.addEventListener("scroll",S,!0),window.addEventListener("resize",S);const y=setInterval(S,0);return()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",S),clearInterval(y)}},[h]),A.useEffect(()=>{const S=y=>{const T=y,{timestamp:x,userId:v}=T.detail,C=i(x,v);C&&E(C.id)};return window.addEventListener("redline:markClick",S),()=>{window.removeEventListener("redline:markClick",S)}},[i,E]),A.useEffect(()=>{const S=y=>{const T=y.target,x=T.closest("[data-redline-item]"),v=T.closest("[data-timestamp]");!x&&!v&&(s(null),c(null),o())};return document.addEventListener("mousedown",S),()=>{document.removeEventListener("mousedown",S)}},[o]),A.useEffect(()=>{if(!a)return;const S=()=>{const y=n.find(T=>T.id===a);if(y){const T=g(y.timestamp,y.userId);T&&c(T)}};return window.addEventListener("scroll",S,!0),window.addEventListener("resize",S),()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",S)}},[a,n,g]),A.useEffect(()=>{if(!a)return;const S=n.find(x=>x.id===a);if(!S)return;_(S)?.scrollIntoView({behavior:"smooth",block:"center"}),p.current.get(a)?.scrollIntoView({behavior:"smooth",block:"nearest"})},[a,n,_]),{panelRef:m,itemRefs:p,itemPositions:d,activeItemId:a,popupPosition:l,setActiveItemId:s,setPopupPosition:c,handleLabelClick:b}},xy=!1,q7=()=>{const{currentMode:e}=xd(),{editorConfig:t,redlineItemWidth:n,setRedlineItemWidth:r}=nt(),{changes:i,acceptChange:o,rejectChange:a,navigateToChange:s,addComment:l,editComment:c,deleteComment:d}=Yf(),{panelRef:u,itemPositions:p,itemRefs:m,activeItemId:_,popupPosition:h,setActiveItemId:g,setPopupPosition:b,handleLabelClick:E}=j7(),S=e===ui.SUGGESTING.value,y=!t.asViewer&&e!==ui.VIEWING.value,T=t.currentUser,x=_?i.find(U=>U.id===_):null,[v,C]=A.useState(!1),O=A.useRef(null),w=_?p.get(_):null,z=x&&h&&w?.showCompact,N=U=>U.includes("insertion")?"Add":U.includes("deletion")?"Del":"Change",P=U=>{const H=U.nodeType==="link"||!!U.linkData,V=U.nodeType==="signature",q=U.nodeType==="table",W=U.nodeType==="tableRow",oe=U.nodeType==="tableColumn",Z=U.nodeType==="variable";return!!U.formatChanges&&!H?"Format":H?"Link":V?"Signature":W?"Row":oe?"Column":q?"Table":Z?"Variable":U.type.includes("insertion")?"Add":U.type.includes("deletion")?"Delete":"Change"},I=Array.from(p.values()),R=5,k=I[0]?.left??0,M=I[0]?.showCompact??!1,B=M?120:380,D=I.reduce((U,H)=>{const V=m.current.get(H.changeId),q=V?V.getBoundingClientRect().height:M?35:120,W=H.showCompact?R*I.findIndex(oe=>oe.changeId===H.changeId):0;return Math.max(U,H.top+W+q)},0);return A.useEffect(()=>{r(B)},[B,r]),A.useEffect(()=>{const U=()=>{C(!0),O.current&&window.clearTimeout(O.current),O.current=window.setTimeout(()=>{C(!1)},120)},H=()=>{U()};window.addEventListener("resize",H);let V=null;if(typeof ResizeObserver<"u"){V=new ResizeObserver(()=>{U()});const q=[],W=document.querySelector("#editor-shell-qwCfsxssdsfsd"),oe=document.querySelector("#editor-content-qwCfsdsfsd"),Z=document.querySelector("#editor-sidebar-qwCfsdsfsd"),X=t?.parentContainerId?document.querySelector(`#${t.parentContainerId}`):null;W&&q.push(W),oe&&q.push(oe),Z&&q.push(Z),X&&q.push(X),q.forEach(se=>V?.observe(se))}return()=>{window.removeEventListener("resize",H),V?.disconnect(),O.current&&window.clearTimeout(O.current)}},[t?.parentContainerId]),i.length===0?null:f.jsxs(f.Fragment,{children:[f.jsx("div",{ref:u,"data-redline-panel":"true",className:"fixed top-0 overflow-y-auto pointer-events-auto",style:{left:`${k}px`,height:"93vh",width:`${n+20}px`,scrollbarWidth:"none",transition:v?"none":"width 220ms ease",pointerEvents:"none"},children:f.jsx("div",{style:{position:"relative",height:`${D+32}px`},children:I.map((U,H)=>{const V=i.find(oe=>oe.id===U.changeId);if(!V)return null;const q=U.top+(U.showCompact?H*R:0),W=_===V.id;return U.showCompact?f.jsx("div",{"data-redline-item":"true",className:"relative",style:{position:"absolute",top:`${q}px`,left:7,zIndex:W?8:3,pointerEvents:"auto",transition:v?"none":"top 200ms ease, left 200ms ease"},children:f.jsxs("button",{onClick:()=>E(V.id),className:`
|
|
223
223
|
group relative overflow-visible flex h-9 items-center justify-between px-2.5 rounded-lg
|
|
224
224
|
border shadow-sm transition-all duration-200
|
|
225
225
|
hover:-translate-y-[1px] hover:shadow-md
|