bookstack/public/dist/wysiwyg.js

32 lines
278 KiB
JavaScript
Raw Normal View History

// See the "/licenses" URI for full package license details
function $(o){return __DEV__?{type:o}:{}}var we=$("SELECTION_CHANGE_COMMAND"),er=$("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),tr=$("CLICK_COMMAND"),Ze=$("DELETE_CHARACTER_COMMAND"),$t=$("INSERT_LINE_BREAK_COMMAND"),Pt=$("INSERT_PARAGRAPH_COMMAND"),rt=$("CONTROLLED_TEXT_INSERTION_COMMAND"),no=$("PASTE_COMMAND"),cn=$("REMOVE_TEXT_COMMAND"),Tt=$("DELETE_WORD_COMMAND"),it=$("DELETE_LINE_COMMAND"),Ne=$("FORMAT_TEXT_COMMAND"),ro=$("UNDO_COMMAND"),io=$("REDO_COMMAND"),Ds=$("KEYDOWN_COMMAND"),Lo=$("KEY_ARROW_RIGHT_COMMAND"),Os=$("MOVE_TO_END"),Mo=$("KEY_ARROW_LEFT_COMMAND"),As=$("MOVE_TO_START"),wo=$("KEY_ARROW_UP_COMMAND"),Bt=$("KEY_ARROW_DOWN_COMMAND"),Fe=$("KEY_ENTER_COMMAND"),or=$("KEY_SPACE_COMMAND"),Ft=$("KEY_BACKSPACE_COMMAND"),vo=$("KEY_ESCAPE_COMMAND"),Ht=$("KEY_DELETE_COMMAND"),Do=$("KEY_TAB_COMMAND"),Rs=$("INSERT_TAB_COMMAND"),ph=$("INDENT_CONTENT_COMMAND"),gh=$("OUTDENT_CONTENT_COMMAND"),Oo=$("DROP_COMMAND"),nr=$("DRAGSTART_COMMAND"),rr=$("DRAGOVER_COMMAND"),ks=$("DRAGEND_COMMAND"),so=$("COPY_COMMAND"),lo=$("CUT_COMMAND"),dn=$("SELECT_ALL_COMMAND"),Is=$("CLEAR_EDITOR_COMMAND"),$s=$("CLEAR_HISTORY_COMMAND"),ao=$("CAN_REDO_COMMAND"),co=$("CAN_UNDO_COMMAND"),ir=$("FOCUS_COMMAND"),Ps=$("BLUR_COMMAND"),Bs=$("KEY_MODIFIER_COMMAND");var fe=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";var hh=fe&&"documentMode"in document?document.documentMode:null,He=fe&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),Ke=fe&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),uo=fe&&"InputEvent"in window&&!hh?"getTargetRanges"in new window.InputEvent("input"):!1,Kt=fe&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Ct=fe&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,sc=fe&&/Android/.test(navigator.userAgent),Fs=fe&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Hs=fe&&sc&&Fs,Ut=fe&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Fs;var fo=1,Ue=3,_t=0,Ks=1,zt=2,lc=0,Qr=1,ei=2,sr=1,lr=2,un=4,fn=8,ar=16,cr=32,dr=64,ur=128,Us=sr|lr|un|fn|ar|cr|dr|ur,ti=1,mn=2;var ac="\xA0",Nh="\u200B",pn=Kt||Ct||Ut?ac:Nh,Ve=`
`,cc=Ke?ac:pn,dc="\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC",uc="A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u0300-\u0590\u0800-\u1FFF\u200E\u2C00-\uFB1C\uFE00-\uFE6F\uFEFD-\uFFFF",xh=new RegExp("^[^"+uc+"]*["+dc+"]"),Eh=new RegExp("^[^"+dc+"]*["+uc+"]"),Xe={bold:sr,code:ar,highlight:ur,italic:lr,strikethrough:un,subscript:cr,superscript:dr,underline:fn},fc={directionless:ti,unmergeable:mn},mc={normal:lc,segmented:ei,token:Qr},pc={[lc]:"normal",[ei]:"segmented",[Qr]:"token"};function x(o,e,...t){if(!o){for(let n of t)e=(e||"").replace("%s",n);throw new Error(e)}}function bt(...o){let e=[];for(let t of o)if(t&&typeof t=="string")for(let[n]of t.matchAll(/\S+/g))e.push(n);return e}var Th=100,Ws=!1,qs=0;function gc(){return Ws}function Ch(o){qs=o.timeStamp}function _h(o){qs===0&&gn(o).addEventListener("textInput",Ch,!0)}function zs(o,e,t){return e.__lexicalLineBreak===o||o[`__lexicalKey_${t._key}`]!==void 0}function bh(o){return o.getEditorState().read(()=>{let e=T();return e!==null?e.clone():null})}function yh(o,e,t){let n=be(t._window),r=null,i=null;n!==null&&n.anchorNode===o&&(r=n.anchorOffset,i=n.focusOffset);let s=o.nodeValue;s!==null&&fr(e,s,r,i,!1)}function Sh(o,e,t){return e.nodeType===Ue&&t.isAttached()}function hc(o,e,t){Ws=!0;let n=performance.now()-qs>Th;try{xe(o,()=>{let r=T()||bh(o),i=new Map,s=o.getRootElement(),l=o._editorState,a=o._blockCursorElement,c=!1,m="";for(let d=0;d<e.length;d++){let u=e[d],p=u.type,g=u.target,h=ee(g,l);if(!(h===null&&g!==s||B(h))){if(p==="characterData")n&&y(h)&&Sh(r,g,h)&&yh(g,h,o);else if(p==="childList"){c=!0;let C=u.addedNodes;for(let M=0;M<C.length;M++){let S=C[M],A=Ys(S),O=S.parentNode;if(O!=null&&S!==a&&A===null&&(S.nodeName!=="BR"||!zs(S,O,o))){if(Ke){let R=S.innerText||S.nodeValue;R&&(m+=R)}O.removeChild(S)}}let N=u.removedNodes,L=N.length;if(L>0){let M=0;for(let S=0;S<L;S++){let A=N[S];(A.nodeName==="BR"&&zs(A,g,o)||a===A)&&(g.appendChild(A),M++)}L!==M&&(g===s&&(h=Zs(l)),i.set(g,h))}}}}if(i.size>0)for(let[d,u]of i)if(E(u)){let p=u.getChildrenKeys(),g=d.firstChild;for(let h=0;h<p.length;h++){let C=p[h],N=o.getElementByKey(C);N!==null&&(g==null?(d.appendChild(N),g=N):g!==N&&d.replaceChild(N,g),g=g.nextSibling)}}else y(u)&&u.markDirty();let f=t.takeRecords();if(f.length>0){for(let d=0;d<f.length;d++){let u=f[d],p=u.addedNodes,g=u.target;for(let h=0;h<p.length;h++){let C=p[h],N=C.parentNode;N!=null&&C.nodeName==="BR"&&!zs(C,g,o)&&N.removeChild(C)}}t.takeRecords()}r!==null&&(c&&(r.dirty=!0,Y(r)),Ke&&ri(o)&&r.insertRawText(m))})}finally{Ws=!1}}function oi(o){let e=o._observer;if(e!==null){let t=e.takeRecords();hc(o,t,e)}}function ni(o){_h(o),o._observer=new MutationObserver((e,t)=>{hc(o,e,t)})}function Nc(o,e){let t=o.__mode,n=o.__format,r=o.__style,i=e.__mode,s=e.__format,l=e.__style;return(t===null||t===i)&&(n===null||n===s)&&(r===null||r===l)}function xc(o,e){let t=o.mergeWithSibling(e),n=j()._normalizedNodes;return n.add(o.__key),n.add(e.__key),t}function Vs(o){let e=o;if(e.__text===""&&e.isSimpleText()&&!e.isUnmergeable()){e.remove();return}let t;for(;(t=e.getPreviousSibling())!==null&&y(t)&&t.isSimpleText()&&!t.isUnmergeable();)if(t.__text==="")t.remove();else if(Nc(t,e)){e=xc(t,e);break}else break;let n;for(;(n=e.getNextSibling())!==null&&y(n)&&n.isSimpleText()&&!n.isUnmergeable();)if(n.__text==="")n.remove();else if(Nc(e,n)){e=xc(e,n);break}else break}function Ao(o){return Ec(o.anchor),Ec(o.focus),o}function Ec(o){for(;o.type==="element";){let e=o.getNode(),t=o.offset,n,r;if(t===e.getChildrenSize()?(n=e.getChildAtIndex(t-1),r=!0):(n=e.getChildAtIndex(t),r=!1),y(n)){o.set(n.__key,r?n.getTextContentSize():0,"text");break}else if(!E(n))break;o.set(n.__key,r?n.getChildrenSize():0,"element")}}var Lh=1;function Mh(){return""+Lh++}function _c(o,e){let t=o._nodes.get(e);return t===void 0&&x(!1,"registeredNode: Type %s not found",e),t}var zT=Array.isArray,bc=typeof queueMicrotask=="function"?queueMicrotask:o=>{Promise.resolve().then(o)};function yc(o){return B(ee(o))}function En(o){let e=document.activeElement;if(e===null)return!1;let t=e.nodeName;return B(ee(o))&&(t==="INPUT"||t==="TEXTA
`)o.preventDefault(),D(e,$t,!1);else if(i===Ve)o.preventDefault(),D(e,Pt,void 0);else if(i==null&&o.dataTransfer){let m=o.dataTransfer.getData("text/plain");o.preventDefault(),r.insertRawText(m)}else i!=null&&Ld(r,n,i,o.timeStamp,!0)?(o.preventDefault(),D(e,rt,i)):yn=i;yd=o.timeStamp;return}switch(o.preventDefault(),t){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":{D(e,rt,o);break}case"insertFromComposition":{se(null),D(e,rt,o);break}case"insertLineBreak":{se(null),D(e,$t,!1);break}case"insertParagraph":{se(null),yr&&!Ct?(yr=!1,D(e,$t,!1)):D(e,Pt,void 0);break}case"insertFromPaste":case"insertFromPasteAsQuotation":{D(e,no,o);break}case"deleteByComposition":{Yh(a,c)&&D(e,cn,o);break}case"deleteByDrag":case"deleteByCut":{D(e,cn,o);break}case"deleteContent":{D(e,Ze,!1);break}case"deleteWordBackward":{D(e,Tt,!0);break}case"deleteWordForward":{D(e,Tt,!1);break}case"deleteHardLineBackward":case"deleteSoftLineBackward":{D(e,it,!0);break}case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":{D(e,it,!1);break}case"formatStrikeThrough":{D(e,Ne,"strikethrough");break}case"formatBold":{D(e,Ne,"bold");break}case"formatItalic":{D(e,Ne,"italic");break}case"formatUnderline":{D(e,Ne,"underline");break}case"historyUndo":{D(e,ro,void 0);break}case"historyRedo":{D(e,io,void 0);break}default:}})}function Xh(o,e){o.stopPropagation(),xe(e,()=>{let t=T(),n=o.data,r=Md(o);if(n!=null&&_(t)&&Ld(t,r,n,o.timeStamp,!1)){br&&(hl(e,n),br=!1);let s=t.anchor.getNode(),l=be(e._window);if(l===null)return;let a=t.isBackward(),c=a?t.anchor.offset:t.focus.offset,m=a?t.focus.offset:t.anchor.offset;(!uo||t.isCollapsed()||!y(s)||l.anchorNode===null||s.getTextContent().slice(0,c)+n+s.getTextContent().slice(c+m)!==Qs(l.anchorNode))&&D(e,rt,n);let f=n.length;Ke&&f>1&&o.inputType==="insertCompositionText"&&!e.isComposing()&&(t.anchor.offset-=f),!Kt&&!Ct&&!Ut&&e.isComposing()&&(Sr=0,se(null))}else ai(!1,e,n!==null?n:void 0),br&&(hl(e,n||void 0),br=!1);wc()}),yn=null}function Gh(o,e){xe(e,()=>{let t=T();if(_(t)&&!e.isComposing()){let n=t.anchor,r=t.anchor.getNode();se(n.key),(o.timeStamp<Sr+Nl||n.type==="element"||!t.isCollapsed()||y(r)&&r.getStyle()!==t.style)&&D(e,rt,cc)}})}function hl(o,e){let t=o._compositionKey;if(se(null),t!==null&&e!=null){if(e===""){let n=J(t),r=Cn(o.getElementByKey(t));r!==null&&r.nodeValue!==null&&y(n)&&fr(n,r.nodeValue,null,null,!0);return}if(e[e.length-1]===`
`){let n=T();if(_(n)){let r=n.focus;n.anchor.set(r.key,r.offset,r.type),D(o,Fe,null);return}}}ai(!0,o,e)}function jh(o,e){Ke?br=!0:xe(e,()=>{hl(e,o.data)})}function Jh(o,e){if(Sr=o.timeStamp,bd=o.key,e.isComposing())return;let{key:t,shiftKey:n,ctrlKey:r,metaKey:i,altKey:s}=o;if(!D(e,Ds,o)&&t!=null){if(jc(t,r,s,i))D(e,Lo,o);else if(Jc(t,r,n,s,i))D(e,Os,o);else if(Xc(t,r,s,i))D(e,Mo,o);else if(Gc(t,r,n,s,i))D(e,As,o);else if(Qc(t,r,i))D(e,wo,o);else if(ed(t,r,i))D(e,Bt,o);else if(Ic(t,n))yr=!0,D(e,Fe,o);else if(od(t))D(e,or,o);else if($c(t,r))o.preventDefault(),yr=!0,D(e,$t,!0);else if(kc(t,n))yr=!1,D(e,Fe,o);else if(Kc(t,s,i,r))hn(t)?D(e,Ft,o):(o.preventDefault(),D(e,Ze,!0));else if(rd(t))D(e,vo,o);else if(Uc(t,r,n,s,i))Nn(t)?D(e,Ht,o):(o.preventDefault(),D(e,Ze,!1));else if(Pc(t,s,r))o.preventDefault(),D(e,Tt,!0);else if(Bc(t,s,r))o.preventDefault(),D(e,Tt,!1);else if(Fc(t,i))o.preventDefault(),D(e,it,!0);else if(Hc(t,i))o.preventDefault(),D(e,it,!1);else if(Oc(t,s,i,r))o.preventDefault(),D(e,Ne,"bold");else if(Rc(t,s,i,r))o.preventDefault(),D(e,Ne,"underline");else if(Ac(t,s,i,r))o.preventDefault(),D(e,Ne,"italic");else if(Dc(t,s,r,i))D(e,Do,o);else if(zc(t,n,i,r))o.preventDefault(),D(e,ro,void 0);else if(Wc(t,n,i,r))o.preventDefault(),D(e,io,void 0);else{let l=e._editorState._selection;Se(l)?qc(t,n,i,r)?(o.preventDefault(),D(e,so,o)):Yc(t,n,i,r)?(o.preventDefault(),D(e,lo,o)):el(t,i,r)&&(o.preventDefault(),D(e,dn,o)):!Ke&&el(t,i,r)&&(o.preventDefault(),D(e,dn,o))}td(r,n,s,i)&&D(e,Bs,o)}}function wd(o){let e=o.__lexicalEventHandles;return e===void 0&&(e=[],o.__lexicalEventHandles=e),e}var Sn=new Map;function vd(o){let e=o.target,t=e==null?null:e.nodeType===9?e.defaultView:e.ownerDocument.defaultView,n=be(t);if(n===null)return;let r=ii(n.anchorNode);if(r===null)return;gl&&(gl=!1,xe(r,()=>{let m=We(),f=n.anchorNode;if(f===null)return;let d=f.nodeType;if(d!==fo&&d!==Ue)return;let u=Lr(m,n,r,o);Y(u)}));let i=hr(r),s=i[i.length-1],l=s._key,a=Sn.get(l),c=a||s;c!==r&&Td(n,c,!1),Td(n,r,!0),r!==s?Sn.set(l,r):a&&Sn.delete(l)}function Cd(o){o._lexicalHandled=!0}function _d(o){return o._lexicalHandled===!0}function Dd(o,e){let t=o.ownerDocument,n=Ei.get(t);(n===void 0||n<1)&&t.addEventListener("selectionchange",vd),Ei.set(t,(n||0)+1),o.__lexicalEditor=e;let r=wd(o);for(let i=0;i<ml.length;i++){let[s,l]=ml[i],a=typeof l=="function"?c=>{_d(c)||(Cd(c),(e.isEditable()||s==="click")&&l(c,e))}:c=>{if(_d(c))return;Cd(c);let m=e.isEditable();switch(s){case"cut":return m&&D(e,lo,c);case"copy":return D(e,so,c);case"paste":return m&&D(e,no,c);case"dragstart":return m&&D(e,nr,c);case"dragover":return m&&D(e,rr,c);case"dragend":return m&&D(e,ks,c);case"focus":return m&&D(e,ir,c);case"blur":return m&&D(e,Ps,c);case"drop":return m&&D(e,Oo,c)}};o.addEventListener(s,a),r.push(()=>{o.removeEventListener(s,a)})}}function Od(o){let e=o.ownerDocument,t=Ei.get(e);x(t!==void 0,"Root element not registered");let n=t-1;x(n>=0,"Root element count less than 0"),Ei.set(e,n),n===0&&e.removeEventListener("selectionchange",vd);let r=Ro(o);Tn(r)?(Qh(r),o.__lexicalEditor=null):r&&x(!1,"Attempted to remove event handlers from a node that does not belong to this build of Lexical");let i=wd(o);for(let s=0;s<i.length;s++)i[s]();o.__lexicalEventHandles=[]}function Qh(o){if(o._parentEditor!==null){let e=hr(o),n=e[e.length-1]._key;Sn.get(n)===o&&Sn.delete(n)}else Sn.delete(o._key)}function Ad(){pl=!0}function Rd(o,e,t,n,r){Sd=[o,e,t,n,r]}function xl(o,e,t){ce();let n=o.__key,r=o.getParent();if(r===null)return;let i=sd(o),s=!1;if(_(i)&&e){let l=i.anchor,a=i.focus;l.key===n&&(Mn(l,o,r,o.getPreviousSibling(),o.getNextSibling()),s=!0),a.key===n&&(Mn(a,o,r,o.getPreviousSibling(),o.getNextSibling()),s=!0)}else Se(i)&&e&&o.isSelected()&&o.selectPrevious();if(_(i)&&e&&!s){let l=o.getIndexWithinParent();qt(o),Ln(i,r,l,-1)}else qt(o);!t&&!me(r)&&!r.canBeEmpty()&&r.isEmpty()&&xl(r,e),e&&oe(r)&&r.isEmpty()&&r.selectEnd()}var yt=class{static getType(){x(!1,"LexicalNode: Node %s does not implement .getType().",this.name)}static clone(e){x(!1,"LexicalNode: Node %s does not implement .
`}createDOM(){return document.createElement("br")}updateDOM(){return!1}static importDOM(){return{br:e=>oN(e)||nN(e)?null:{conversion:tN,priority:0}}}static importJSON(e){return ut()}exportJSON(){return{type:"linebreak",version:1}}};function tN(o){return{node:ut()}}function ut(){return ne(new Bo)}function ve(o){return o instanceof Bo}function oN(o){let e=o.parentElement;if(e!==null&&po(e)){let t=e.firstChild;if(t===o||t.nextSibling===o&&Ti(t)){let n=e.lastChild;if(n===o||n.previousSibling===o&&Ti(n))return!0}}return!1}function nN(o){let e=o.parentElement;if(e!==null&&po(e)){let t=e.firstChild;if(t===o||t.nextSibling===o&&Ti(t))return!1;let n=e.lastChild;if(n===o||n.previousSibling===o&&Ti(n))return!0}return!1}function Ti(o){return o.nodeType===Ue&&/^( |\t|\r?\n)+$/.test(o.textContent||"")}function Tl(o,e){return e&ar?"code":e&ur?"mark":e&cr?"sub":e&dr?"sup":null}function Cl(o,e){return e&sr?"strong":e&lr?"em":"span"}function Bd(o,e,t,n,r){let i=n.classList,s=mo(r,"base");s!==void 0&&i.add(...s),s=mo(r,"underlineStrikethrough");let l=!1,a=e&fn&&e&un,c=t&fn&&t&un;s!==void 0&&(c?(l=!0,a||i.add(...s)):a&&i.remove(...s));for(let m in Xe){let d=Xe[m];if(s=mo(r,m),s!==void 0)if(t&d){if(l&&(m==="underline"||m==="strikethrough")){e&d&&i.remove(...s);continue}((e&d)===0||a&&m==="underline"||m==="strikethrough")&&i.add(...s)}else e&d&&i.remove(...s)}}function rN(o,e){let t=o.length,n=e.length,r=0,i=0;for(;r<t&&r<n&&o[r]===e[r];)r++;for(;i+r<t&&i+r<n&&o[t-i-1]===e[n-i-1];)i++;return[r,t-r-i,e.slice(r,n-i)]}function Fd(o,e,t){let n=e.firstChild,r=t.isComposing(),s=o+(r?pn:"");if(n==null)e.textContent=s;else{let l=n.nodeValue;if(l!==s)if(r||Ke){let[a,c,m]=rN(l,s);c!==0&&n.deleteData(a,c),n.insertData(a,m)}else n.nodeValue=s}}function Id(o,e,t,n,r,i){Fd(r,o,e);let l=i.theme.text;l!==void 0&&Bd(t,0,n,o,l)}function Ci(o,e){let t=document.createElement(e);return t.appendChild(o),t}var Je=class o extends yt{static getType(){return"text"}static clone(e){return new o(e.__text,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__format=e.__format,this.__style=e.__style,this.__mode=e.__mode,this.__detail=e.__detail}constructor(e,t){super(t),this.__text=e,this.__format=0,this.__style="",this.__mode=0,this.__detail=0}getFormat(){return this.getLatest().__format}getDetail(){return this.getLatest().__detail}getMode(){let e=this.getLatest();return pc[e.__mode]}getStyle(){return this.getLatest().__style}isToken(){return this.getLatest().__mode===Qr}isComposing(){return this.__key===Ge()}isSegmented(){return this.getLatest().__mode===ei}isDirectionless(){return(this.getLatest().__detail&ti)!==0}isUnmergeable(){return(this.getLatest().__detail&mn)!==0}hasFormat(e){let t=Xe[e];return(this.getFormat()&t)!==0}isSimpleText(){return this.__type==="text"&&this.__mode===0}getTextContent(){return this.getLatest().__text}getFormatFlags(e,t){let r=this.getLatest().__format;return pr(r,e,t)}canHaveFormat(){return!0}createDOM(e,t){let n=this.__format,r=Tl(this,n),i=Cl(this,n),s=r===null?i:r,l=document.createElement(s),a=l;this.hasFormat("code")&&l.setAttribute("spellcheck","false"),r!==null&&(a=document.createElement(i),l.appendChild(a));let c=this.__text;Id(a,this,i,n,c,e);let m=this.__style;return m!==""&&(l.style.cssText=m),l}updateDOM(e,t,n){let r=this.__text,i=e.__format,s=this.__format,l=Tl(this,i),a=Tl(this,s),c=Cl(this,i),m=Cl(this,s);if((l===null?c:l)!==(a===null?m:a))return!0;if(l===a&&c!==m){let N=t.firstChild;N==null&&x(!1,"updateDOM: prevInnerDOM is null or undefined");let L=document.createElement(m);return Id(L,this,m,s,r,n),t.replaceChild(L,N),!1}let u=t;a!==null&&l!==null&&(u=t.firstChild,u==null&&x(!1,"updateDOM: innerDOM is null or undefined")),Fd(r,u,this);let g=n.theme.text;g!==void 0&&i!==s&&Bd(m,i,s,u,g);let h=e.__style,C=this.__style;return h!==C&&(t.style.cssText=C),!1}static importDOM(){return{"#text":()=>({conversion:cN,priority:0}),b:()=>({conversion:sN,priority:0}),code:()=>({conversion:No,priority:0}),em:()=>({conversion:No,priority:0}),i:()=>({conversion:No,priority:0}),s:()=>({conversion:No,priority:0}),span:()=>({conversion:iN
`||a===`\r
`?i.push(ut()):a===" "?i.push(St()):a!==""&&i.push(q(a))}return{node:i}}if(n=n.replace(/\r/g,"").replace(/[ \t\n]+/g," "),n==="")return{node:null};if(n[0]===" "){let r=e,i=!0;for(;r!==null&&(r=Pd(r,!1))!==null;){let s=r.textContent||"";if(s.length>0){/[ \t\n]$/.test(s)&&(n=n.slice(1)),i=!1;break}}i&&(n=n.slice(1))}if(n[n.length-1]===" "){let r=e,i=!0;for(;r!==null&&(r=Pd(r,!0))!==null;)if((r.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){i=!1;break}i&&(n=n.slice(0,n.length-1))}return n===""?{node:null}:{node:q(n)}}function Pd(o,e){let t=o;for(;;){let n;for(;(n=e?t.nextSibling:t.previousSibling)===null;){let i=t.parentElement;if(i===null)return null;t=i}if(t=n,t.nodeType===fo){let i=t.style.display;if(i===""&&!Io(t)||i!==""&&!i.startsWith("inline"))return null}let r=t;for(;(r=e?t.firstChild:t.lastChild)!==null;)t=r;if(t.nodeType===Ue)return t;if(t.nodeName==="BR")return null}}var dN={code:"code",em:"italic",i:"italic",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function No(o){let e=dN[o.nodeName.toLowerCase()];return e==="code"&&o.closest("pre")?{node:null}:e===void 0?{node:null}:{forChild:bl(o.style,e),node:null}}function q(o=""){return ne(new Je(o))}function y(o){return o instanceof Je}function bl(o,e){let t=o.fontWeight,n=o.textDecoration.split(" "),r=t==="700"||t==="bold",i=n.includes("line-through"),s=o.fontStyle==="italic",l=n.includes("underline"),a=o.verticalAlign,c=o.color,m=o.backgroundColor;return f=>{if(!y(f))return f;r&&!f.hasFormat("bold")&&f.toggleFormat("bold"),i&&!f.hasFormat("strikethrough")&&f.toggleFormat("strikethrough"),s&&!f.hasFormat("italic")&&f.toggleFormat("italic"),l&&!f.hasFormat("underline")&&f.toggleFormat("underline"),a==="sub"&&!f.hasFormat("subscript")&&f.toggleFormat("subscript"),a==="super"&&!f.hasFormat("superscript")&&f.toggleFormat("superscript");let d=f.getStyle();return c&&(d+=`color: ${c};`),m&&m!=="transparent"&&(d+=`background-color: ${m};`),d&&f.setStyle(d),e&&!f.hasFormat(e)&&f.toggleFormat(e),f}}var Fo=class o extends Je{static getType(){return"tab"}static clone(e){return new o(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__text=e.__text}constructor(e){super(" ",e),this.__detail=mn}static importDOM(){return null}static importJSON(e){let t=St();return t.setFormat(e.format),t.setStyle(e.style),t}exportJSON(){return{...super.exportJSON(),type:"tab",version:1}}setTextContent(e){x(!1,"TabNode does not support setTextContent")}setDetail(e){x(!1,"TabNode does not support setDetail")}setMode(e){x(!1,"TabNode does not support setMode")}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}};function St(){return ne(new Fo)}function yl(o){return o instanceof Fo}var Ml=class{constructor(e,t,n){this._selection=null,this.key=e,this.offset=t,this.type=n}is(e){return this.key===e.key&&this.offset===e.offset&&this.type===e.type}isBefore(e){let t=this.getNode(),n=e.getNode(),r=this.offset,i=e.offset;if(E(t)){let s=t.getDescendantByIndex(r);t=s??t}if(E(n)){let s=n.getDescendantByIndex(i);n=s??n}return t===n?r<i:t.isBefore(n)}getNode(){let e=this.key,t=J(e);return t===null&&x(!1,"Point.getNode: node not found"),t}set(e,t,n){let r=this._selection,i=this.key;this.key=e,this.offset=t,this.type=n,st()||(Ge()===i&&se(e),r!==null&&(r.setCachedNodes(null),r.dirty=!0))}};function De(o,e,t){return new Ml(o,e,t)}function Sl(o,e){let t=e.__key,n=o.offset,r="element";if(y(e)){r="text";let i=e.getTextContentSize();n>i&&(n=i)}else if(!E(e)){let i=e.getNextSibling();if(y(i))t=i.__key,n=0,r="text";else{let s=e.getParent();s&&(t=s.__key,n=e.getIndexWithinParent()+1)}}o.set(t,n,r)}function El(o,e){if(E(e)){let t=e.getLastDescendant();E(t)||y(t)?Sl(o,t):Sl(o,e)}else Sl(o,e)}function uN(o,e,t,n){let r=o.getNode(),i=r.getChildAtIndex(o.offset),s=q(),l=oe(r)?I().append(s):s;s.setFormat(t),s.setStyle(n),i===null?r.append(l):i.insertBefore(l),o.is(e)&&e.set(s.__key,0,"text"),o.set(s.__key,0,"text")}function xo(o,e,t,n){o.key=e,o.offset=t,o.type=n}var bi=class o{constructor(e){this._cachedNodes=null,this._nodes=e,this.dirty=!1}getCachedNodes(){return this.
`),d.isEmpty()?m=!1:m=!0;else if(m=!1,y(d)){let u=d.getTextContent();d===t?d===n?(r.type!=="element"||i.type!=="element"||i.offset===r.offset)&&(u=l<a?u.slice(l,a):u.slice(a,l)):u=s?u.slice(l):u.slice(a):d===n&&(u=s?u.slice(0,a):u.slice(0,l)),c+=u}else(B(d)||ve(d))&&(d!==n||!this.isCollapsed())&&(c+=d.getTextContent())}return c}applyDOMRange(e){let t=j(),r=t.getEditorState()._selection,i=Yd(e.startContainer,e.startOffset,e.endContainer,e.endOffset,t,r);if(i===null)return;let[s,l]=i;xo(this.anchor,s.key,s.offset,s.type),xo(this.focus,l.key,l.offset,l.type),this._cachedNodes=null}clone(){let e=this.anchor,t=this.focus;return new o(De(e.key,e.offset,e.type),De(t.key,t.offset,t.type),this.format,this.style)}toggleFormat(e){this.format=pr(this.format,e,null),this.dirty=!0}setStyle(e){this.style=e,this.dirty=!0}hasFormat(e){let t=Xe[e];return(this.format&t)!==0}insertRawText(e){let t=e.split(/(\r?\n|\t)/),n=[],r=t.length;for(let i=0;i<r;i++){let s=t[i];s===`
`||s===`\r
`?n.push(ut()):s===" "?n.push(St()):n.push(q(s))}this.insertNodes(n)}insertText(e){let t=this.anchor,n=this.focus,r=this.format,i=this.style,s=t,l=n;!this.isCollapsed()&&n.isBefore(t)&&(s=n,l=t),s.type==="element"&&uN(s,l,r,i);let a=s.offset,c=l.offset,m=this.getNodes(),f=m.length,d=m[0];y(d)||x(!1,"insertText: first node is not a text node");let p=d.getTextContent().length,g=d.getParentOrThrow(),h=f-1,C=m[h];if(f===1&&l.type==="element"&&(c=p,l.set(s.key,c,"text")),this.isCollapsed()&&a===p&&(d.isSegmented()||d.isToken()||!d.canInsertTextAfter()||!g.canInsertTextAfter()&&d.getNextSibling()===null)){let N=d.getNextSibling();if((!y(N)||!N.canInsertTextBefore()||ze(N))&&(N=q(),N.setFormat(r),N.setStyle(i),g.canInsertTextAfter()?d.insertAfter(N):g.insertAfter(N)),N.select(0,0),d=N,e!==""){this.insertText(e);return}}else if(this.isCollapsed()&&a===0&&(d.isSegmented()||d.isToken()||!d.canInsertTextBefore()||!g.canInsertTextBefore()&&d.getPreviousSibling()===null)){let N=d.getPreviousSibling();if((!y(N)||ze(N))&&(N=q(),N.setFormat(r),g.canInsertTextBefore()?d.insertBefore(N):g.insertBefore(N)),N.select(),d=N,e!==""){this.insertText(e);return}}else if(d.isSegmented()&&a!==p){let N=q(d.getTextContent());N.setFormat(r),d.replace(N),d=N}else if(!this.isCollapsed()&&e!==""){let N=C.getParent();if(!g.canInsertTextBefore()||!g.canInsertTextAfter()||E(N)&&(!N.canInsertTextBefore()||!N.canInsertTextAfter())){this.insertText(""),qd(this.anchor,this.focus,null),this.insertText(e);return}}if(f===1){if(d.isToken()){let S=q(e);S.select(),d.replace(S);return}let N=d.getFormat(),L=d.getStyle();if(a===c&&(N!==r||L!==i))if(d.getTextContent()==="")d.setFormat(r),d.setStyle(i);else{let S=q(e);if(S.setFormat(r),S.setStyle(i),S.select(),a===0)d.insertBefore(S,!1);else{let[A]=d.splitText(a);A.insertAfter(S,!1)}S.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length);return}else if(yl(d)){let S=q(e);S.setFormat(r),S.setStyle(i),S.select(),d.replace(S);return}let M=c-a;d=d.spliceText(a,M,e,!0),d.getTextContent()===""?d.remove():this.anchor.type==="text"&&(d.isComposing()?this.anchor.offset-=e.length:(this.format=N,this.style=L))}else{let N=new Set([...d.getParentKeys(),...C.getParentKeys()]),L=E(d)?d:d.getParentOrThrow(),M=E(C)?C:C.getParentOrThrow(),S=C;if(!L.is(M)&&M.isInline())do S=M,M=M.getParentOrThrow();while(M.isInline());if(l.type==="text"&&(c!==0||C.getTextContent()==="")||l.type==="element"&&C.getIndexWithinParent()<c)if(y(C)&&!C.isToken()&&c!==C.getTextContentSize()){if(C.isSegmented()){let k=q(C.getTextContent());C.replace(k),C=k}!oe(l.getNode())&&l.type==="text"&&(C=C.spliceText(0,c,"")),N.add(C.__key)}else{let k=C.getParentOrThrow();!k.canBeEmpty()&&k.getChildrenSize()===1?k.remove():C.remove()}else N.add(C.__key);let A=M.getChildren(),O=new Set(m),R=L.is(M),P=L.isInline()&&d.getNextSibling()===null?L:d;for(let k=A.length-1;k>=0;k--){let W=A[k];if(W.is(d)||E(W)&&W.isParentOf(d))break;W.isAttached()&&(!O.has(W)||W.is(S)?R||P.insertAfter(W,!1):W.remove())}if(!R){let k=M,W=null;for(;k!==null;){let ie=k.getChildren(),ln=ie.length;(ln===0||ie[ln-1].is(W))&&(N.delete(k.__key),W=k),k=k.getParent()}}if(!d.isToken())d=d.spliceText(a,p-a,e,!0),d.getTextContent()===""?d.remove():d.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length);else if(a===p)d.select();else{let k=q(e);k.select(),d.replace(k)}for(let k=1;k<f;k++){let W=m[k],ie=W.__key;N.has(ie)||W.remove()}}}removeText(){this.insertText("")}formatText(e){if(this.isCollapsed()){this.toggleFormat(e),se(null);return}let t=this.getNodes(),n=[];for(let N of t)y(N)&&n.push(N);let r=n.length;if(r===0){this.toggleFormat(e),se(null);return}let i=this.anchor,s=this.focus,l=this.isBackward(),a=l?s:i,c=l?i:s,m=0,f=n[0],d=a.type==="element"?0:a.offset;if(a.type==="text"&&d===f.getTextContentSize()&&(m=1,f=n[1],d=0),f==null)return;let u=f.getFormatFlags(e,null),p=r-1,g=n[p],h=c.type==="text"?c.offset:g.getTextContentSize();if(f.is(g)){if(d===h)return;if(ze(f)||d===0&&h===f.getTextContentSize())f.setFormat(u);else{let N=f.splitText(d,h),L=d===0?N[0]:N[1];L.setFormat(u),a
`||c===`\r
`?a.insertParagraph():c===" "?a.insertNodes([St()]):a.insertText(c)}}}else e.insertRawText(i)}function Kl(o,e,t){o.dispatchCommand(er,{nodes:e,selection:t})||t.insertNodes(e)}function YN(o){let e=o.exportJSON(),t=o.constructor;if(e.type!==t.getType()&&x(!1,"LexicalNode: Node %s does not implement .exportJSON().",t.name),E(o)){let n=e.children;Array.isArray(n)||x(!1,"LexicalNode: Node %s is an element but .exportJSON() does not have a children array.",t.name)}return e}function Ou(o,e,t,n=[]){let r=e!==null?t.isSelected(e):!0,i=E(t)&&t.excludeFromCopy("html"),s=t;if(e!==null){let c=Zt(t);c=y(c)&&e!==null?Or(e,c):c,s=c}let l=E(s)?s.getChildren():[],a=YN(s);if(y(s)){let c=s.__text;c.length>0?a.text=c:r=!1}for(let c=0;c<l.length;c++){let m=l[c],f=Ou(o,e,m,a.children);!r&&E(t)&&f&&t.extractWithChild(m,e,"clone")&&(r=!0)}if(r&&!i)n.push(a);else if(Array.isArray(a.children))for(let c=0;c<a.children.length;c++){let m=a.children[c];n.push(m)}return r}function Au(o,e){let t=[],r=F().getChildren();for(let i=0;i<r.length;i++){let s=r[i];Ou(o,e,s,t)}return{namespace:o._config.namespace,nodes:t}}function Ru(o){let e=[];for(let t=0;t<o.length;t++){let n=o[t],r=Dl(n);y(r)&&$l(r),e.push(r)}return e}var ZN=50,Rn=null;async function kn(o,e,t){if(Rn!==null)return!1;if(e!==null)return new Promise((a,c)=>{o.update(()=>{a(Mu(o,e,t))})});let n=o.getRootElement(),r=o._window==null?window.document:o._window.document,i=wu(o._window);if(n===null||i===null)return!1;let s=r.createElement("span");s.style.cssText="position: fixed; top: -1000px;",s.append(r.createTextNode("#")),n.append(s);let l=new Range;return l.setStart(s,0),l.setEnd(s,1),i.removeAllRanges(),i.addRange(l),new Promise((a,c)=>{let m=o.registerCommand(so,f=>(mt(f,ClipboardEvent)&&(m(),Rn!==null&&(window.clearTimeout(Rn),Rn=null),a(Mu(o,f,t))),!0),Re);Rn=window.setTimeout(()=>{m(),Rn=null,a(!1)},ZN),r.execCommand("copy"),s.remove()})}function Mu(o,e,t){if(t===void 0){let r=wu(o._window);if(!r)return!1;let i=r.anchorNode,s=r.focusNode;if(i!==null&&s!==null&&!Wt(o,i,s))return!1;let l=T();if(l===null)return!1;t=Ii(l)}e.preventDefault();let n=e.clipboardData;return n===null?!1:(ku(n,t),!0)}var VN=[["text/html",vu],["application/x-lexical-editor",Du]];function Ii(o=T()){let e={"text/plain":o?o.getTextContent():""};if(o){let t=nl();for(let[n,r]of VN){let i=r(t,o);i!==null&&(e[n]=i)}}return e}function ku(o,e){for(let t in e){let n=e[t];n!==void 0&&o.setData(t,n)}}function $i(o,e){if(typeof document.caretRangeFromPoint<"u"){let t=document.caretRangeFromPoint(o,e);return t===null?null:{node:t.startContainer,offset:t.startOffset}}else if(document.caretPositionFromPoint!=="undefined"){let t=document.caretPositionFromPoint(o,e);return t===null?null:{node:t.offsetNode,offset:t.offset}}else return null}var Iu=$("DRAG_DROP_PASTE_FILE");function XN(o,e){o.preventDefault(),e.update(()=>{let t=T(),n=mt(o,InputEvent)||mt(o,KeyboardEvent)?null:o.clipboardData;n!=null&&t!==null&&ki(n,t,e)},{tag:"paste"})}async function GN(o,e){await kn(e,mt(o,ClipboardEvent)?o:null),e.update(()=>{let t=T();_(t)?t.removeText():Se(t)&&t.getNodes().forEach(n=>n.remove())})}function Pi(o){let e=null;if(mt(o,DragEvent)?e=o.dataTransfer:mt(o,ClipboardEvent)&&(e=o.clipboardData),e===null)return[!1,[],!1];let t=e.types,n=t.includes("Files"),r=t.includes("text/html")||t.includes("text/plain");return[n,Array.from(e.files),r]}function Bi(o){let e=ee(o);return B(e)}function jN(o){let e=o.focus;return e.key==="root"&&e.offset===F().getChildrenSize()}function $u(o){return Gt(o.registerCommand(tr,t=>{let n=T();return Se(n)?(n.clear(),!0):!1},0),o.registerCommand(Ze,t=>{let n=T();return _(n)?(n.deleteCharacter(t),!0):!1},X),o.registerCommand(Tt,t=>{let n=T();return _(n)?(n.deleteWord(t),!0):!1},X),o.registerCommand(it,t=>{let n=T();return _(n)?(n.deleteLine(t),!0):!1},X),o.registerCommand(rt,t=>{let n=T();if(typeof t=="string")n!==null&&n.insertText(t);else{if(n===null)return!1;let r=t.dataTransfer;if(r!=null)ki(r,n,o);else if(_(n)){let i=t.data;return i&&n.insertText(i),!0}}return!0},X),o.registerCommand(cn,()=>{let t=T();return _(t)?(t.re
`?null:(y(d)&&(a&&d.toggleFormat("bold"),c&&d.toggleFormat("strikethrough"),m&&d.toggleFormat("italic"),f&&d.toggleFormat("underline")),p.append(d),p)}return d},node:i}}function Pe(o=re.NO_STATUS,e=1,t){return ne(new Jt(o,e,t))}function v(o){return o instanceof Jt}var sx=$("INSERT_TABLE_COMMAND");var Qt=class o extends Z{constructor(t){super(t);this.__styles=new Map}static getType(){return"tablerow"}static clone(t){let n=new o(t.__key);return n.__styles=new Map(t.__styles),n}static importDOM(){return{tr:t=>({conversion:lx,priority:0})}}static importJSON(t){let n=Xo();return n.setStyles(new Map(Object.entries(t.styles))),n}exportJSON(){return{...super.exportJSON(),type:"tablerow",version:1,styles:Object.fromEntries(this.__styles),height:this.__height||0}}createDOM(t){let n=document.createElement("tr");this.__height&&(n.style.height=`${this.__height}px`);for(let[r,i]of this.__styles.entries())n.style.setProperty(r,i);return Te(n,t.theme.tableRow),n}isShadowRoot(){return!0}getStyles(){let t=this.getLatest();return new Map(t.__styles)}setStyles(t){let n=this.getWritable();n.__styles=new Map(t)}setHeight(t){let n=this.getWritable();return n.__height=t,this.__height}getHeight(){return this.getLatest().__height}updateDOM(t){return t.__height!==this.__height||t.__styles!==this.__styles}canBeEmpty(){return!1}canIndent(){return!1}};function lx(o){let e=Xo(),n=Wo(o.style.height);return e.setHeight(n),o instanceof HTMLElement&&e.setStyles(vn(o)),{node:e}}function Xo(){return ne(new Qt)}function Q(o){return o instanceof Qt}function ea(o,e,t=!0){let n=$r();for(let r=0;r<o;r++){let i=Xo();for(let s=0;s<e;s++){let l=re.NO_STATUS;typeof t=="object"?(r===0&&t.rows&&(l|=re.ROW),s===0&&t.columns&&(l|=re.COLUMN)):t&&(r===0&&(l|=re.ROW),s===0&&(l|=re.COLUMN));let a=Pe(l),c=I();c.append(q()),a.append(c),i.append(a)}n.append(i)}return n}var Ql=(o,e)=>o===re.BOTH||o===e?e:re.NO_STATUS;function Ki(o=!0){let e=T();x(_(e)||z(e),"Expected a RangeSelection or TableSelection");let t=e.focus.getNode(),[n,,r]=Le(t),[i,s]=ot(r,n,n),l=i[0].length,{startRow:a}=s;if(o){let c=a+n.__rowSpan-1,m=i[c],f=Xo();for(let u=0;u<l;u++){let{cell:p,startRow:g}=m[u];if(g+p.__rowSpan-1<=c){let C=m[u].cell.__headerState,N=Ql(C,re.COLUMN);f.append(Pe(N).append(I()))}else p.setRowSpan(p.__rowSpan+1)}let d=r.getChildAtIndex(c);x(Q(d),"focusEndRow is not a TableRowNode"),d.insertAfter(f)}else{let c=i[a],m=Xo();for(let d=0;d<l;d++){let{cell:u,startRow:p}=c[d];if(p===a){let h=c[d].cell.__headerState,C=Ql(h,re.COLUMN);m.append(Pe(C).append(I()))}else u.setRowSpan(u.__rowSpan+1)}let f=r.getChildAtIndex(a);x(Q(f),"focusEndRow is not a TableRowNode"),f.insertBefore(m)}}function Ui(o=!0){let e=T();x(_(e)||z(e),"Expected a RangeSelection or TableSelection");let t=e.anchor.getNode(),n=e.focus.getNode(),[r]=Le(t),[i,,s]=Le(n),[l,a,c]=ot(s,i,r),m=l.length,f=o?Math.max(a.startColumn,c.startColumn):Math.min(a.startColumn,c.startColumn),d=o?f+i.__colSpan-1:f-1,u=s.getFirstChild();x(Q(u),"Expected firstTable child to be a row");let p=null;function g(C=re.NO_STATUS){let N=Pe(C).append(I());return p===null&&(p=N),N}let h=u;e:for(let C=0;C<m;C++){if(C!==0){let R=h.getNextSibling();x(Q(R),"Expected row nextSibling to be a row"),h=R}let N=l[C],L=N[d<0?0:d].cell.__headerState,M=Ql(L,re.ROW);if(d<0){na(h,g(M));continue}let{cell:S,startColumn:A,startRow:O}=N[d];if(A+S.__colSpan-1<=d){let R=S,P=O,k=d;for(;P!==C&&R.__rowSpan>1;)if(k-=S.__colSpan,k>=0){let{cell:W,startRow:ie}=N[k];R=W,P=ie}else{h.append(g(M));continue e}R.insertAfter(g(M))}else S.setColSpan(S.__colSpan+1)}p!==null&&Ir(p)}function ta(){let o=T();x(_(o)||z(o),"Expected a RangeSelection or TableSelection");let e=o.anchor.getNode(),t=o.focus.getNode(),[n,,r]=Le(e),[i]=Le(t),[s,l,a]=ot(r,n,i),{startRow:c}=l,{startRow:m}=a,f=m+i.__rowSpan-1;if(s.length===f-c+1){r.remove();return}let d=s[0].length,u=s[f+1],p=r.getChildAtIndex(f+1);for(let g=f;g>=c;g--){for(let C=d-1;C>=0;C--){let{cell:N,startRow:L,startColumn:M}=s[g][C];if(M===C&&(g===c&&L<c&&N.setRowSpan(N.__rowSpan-(L-c)),L>=c&&L+N.__rowSpan-1>f))if(N.setRowSpan(N.__rowSpan-(f-L+1)),x(p!==
`:" ")}return t}};function z(o){return o instanceof Wi}function qi(){let o=De("root",0,"element"),e=De("root",0,"element");return new Wi("root",o,e)}function ax(o){let e=[],t=[o];for(;t.length>0;){let n=t.pop();x(n!==void 0,"Stack.length > 0; can't be undefined"),E(n)&&t.unshift(...n.getChildren()),n!==o&&e.push(n)}return e}var Br=class{constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.trackTable(),this.isSelecting=!1}getTable(){return this.table}removeListeners(){Array.from(this.listenersToRemove).forEach(e=>e())}trackTable(){let e=new MutationObserver(t=>{this.editor.update(()=>{let n=!1;for(let i=0;i<t.length;i++){let a=t[i].target.nodeName;if(a==="TABLE"||a==="TBODY"||a==="THEAD"||a==="TR"){n=!0;break}}if(!n)return;let r=this.editor.getElementByKey(this.tableNodeKey);if(!r)throw new Error("Expected to find TableElement in DOM");this.table=Go(r)})});this.editor.update(()=>{let t=this.editor.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");this.table=Go(t),e.observe(t,{attributes:!0,childList:!0,subtree:!0})})}clearHighlight(){let e=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.enableHighlightStyle(),e.update(()=>{let t=J(this.tableNodeKey);if(!K(t))throw new Error("Expected TableNode.");let n=e.getElementByKey(this.tableNodeKey);if(!n)throw new Error("Expected to find TableElement in DOM");let r=Go(n);Pr(e,r,null),Y(null),e.dispatchCommand(we,void 0)})}enableHighlightStyle(){let e=this.editor;e.update(()=>{let t=e.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");Di(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1})}disableHighlightStyle(){let e=this.editor;e.update(()=>{let t=e.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");Te(t,e._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0})}updateTableTableSelection(e){if(e!==null&&e.tableKey===this.tableNodeKey){let t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.disableHighlightStyle(),Pr(t,this.table,this.tableSelection)}else e==null?this.clearHighlight():(this.tableNodeKey=e.tableKey,this.updateTableTableSelection(e))}setFocusCellForSelection(e,t=!1){let n=this.editor;n.update(()=>{let r=J(this.tableNodeKey);if(!K(r))throw new Error("Expected TableNode.");if(!n.getElementByKey(this.tableNodeKey))throw new Error("Expected to find TableElement in DOM");let s=e.x,l=e.y;if(this.focusCell=e,this.anchorCell!==null){let a=ia(n._window);a&&a.setBaseAndExtent(this.anchorCell.elem,0,this.focusCell.elem,0)}if(!this.isHighlightingCells&&(this.anchorX!==s||this.anchorY!==l||t))this.isHighlightingCells=!0,this.disableHighlightStyle();else if(s===this.focusX&&l===this.focusY)return;if(this.focusX=s,this.focusY=l,this.isHighlightingCells){let a=ee(e.elem);if(this.tableSelection!=null&&this.anchorCellNodeKey!=null&&v(a)&&r.is(bo(a))){let c=a.getKey();this.tableSelection=this.tableSelection.clone()||qi(),this.focusCellNodeKey=c,this.tableSelection.set(this.tableNodeKey,this.anchorCellNodeKey,this.focusCellNodeKey),Y(this.tableSelection),n.dispatchCommand(we,void 0),Pr(n,this.table,this.tableSelection)}}})}setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y,this.editor.update(()=>{let t=ee(e.elem);if(v(t)){let n=t.getKey();this.tableSelection=this.tableSelection!=null?this.tableSelection.clone():qi(),this.anchorCellNodeKey=n}})}formatCells(e){this.editor.update(()=>{
<defs>
<pattern id="pattern2" x="0.40000001" patternTransform="scale(200)" preserveAspectRatio="xMidYMid" xlink:href="#Checkerboard"/>
<pattern id="Checkerboard" width="2" height="2" fill="#b6b6b6" patternTransform="translate(0) scale(10)" patternUnits="userSpaceOnUse" preserveAspectRatio="xMidYMid">
<rect width="1" height="1"/>
<rect x="1" y="1" width="1" height="1"/>
</pattern>
</defs>
<rect class="editor-icon-color-display" x="103.53" y="-856.47" width="752.94" height="752.94" rx="47.059" ry="47.059" fill="url(#pattern2)" stroke="#666" stroke-linecap="square" stroke-linejoin="round" stroke-width="47.059"/>
</svg>
`;var Ta=class extends te{constructor(e){super([]),this.input=e,this.pickerButton=new Ee({button:{icon:Wf,label:"Select color"}},[new tn(this.onColorSelect.bind(this))]),this.addChildren(this.pickerButton,this.input)}buildDOM(){let e=this.input.getDOMElement();e.append(this.pickerButton.getDOMElement()),e.classList.add("editor-color-field-container");let t=e.querySelector("input");return t.addEventListener("change",()=>{this.setIconColor(t.value)}),e}onColorSelect(e,t){this.input.setValue(e)}setIconColor(e){let t=this.getDOMElement().querySelector("svg .editor-icon-color-display");t&&t.setAttribute("fill",e||"url(#pattern2)")}};function nn(o){return{build(){return new Ta(new It(o))}}}var Ca={label:"Border style",name:"border_style",type:"select",valuesByLabel:{"Select...":"",Solid:"solid",Dotted:"dotted",Dashed:"dashed",Double:"double",Groove:"groove",Ridge:"ridge",Inset:"inset",Outset:"outset",None:"none",Hidden:"hidden"}},_a={label:"Border color",name:"border_color",type:"text"},ba={label:"Background color",name:"background_color",type:"text"},qf={label:"Alignment",name:"align",type:"select",valuesByLabel:{None:"",Left:"left",Center:"center",Right:"right"}};function Yf(o,e){let t=o.getStyles(),n=e.manager.createModal("cell_properties");return n.show({width:Nf(e.editor,o),height:t.get("height")||"",type:o.getTag(),h_align:o.getAlignment(),v_align:t.get("vertical-align")||"",border_width:t.get("border-width")||"",border_style:t.get("border-style")||"",border_color:t.get("border-color")||"",background_color:t.get("background-color")||""}),n}var Zf={submitText:"Save",async action(o,e){return e.editor.update(()=>{let t=Qo(T());for(let n of t){let r=o.get("width")?.toString()||"";hf(n,r),n.updateTag(o.get("type")?.toString()||""),n.setAlignment(o.get("h_align")?.toString()||"");let i=n.getStyles();i.set("height",ft(o.get("height")?.toString()||"")),i.set("vertical-align",o.get("v_align")?.toString()||""),i.set("border-width",ft(o.get("border_width")?.toString()||"")),i.set("border-style",o.get("border_style")?.toString()||""),i.set("border-color",o.get("border_color")?.toString()||""),i.set("background-color",o.get("background_color")?.toString()||""),n.setStyles(i)}}),!0},fields:[{build(){let o=[{label:"Width",name:"width",type:"text"},{label:"Height",name:"height",type:"text"},{label:"Cell type",name:"type",type:"select",valuesByLabel:{Cell:"td","Header cell":"th"}},{...qf,label:"Horizontal align",name:"h_align"},{label:"Vertical align",name:"v_align",type:"select",valuesByLabel:{None:"",Top:"top",Middle:"middle",Bottom:"bottom"}}],e=[{label:"Border width",name:"border_width",type:"text"},Ca,nn(_a),nn(ba)];return new on([{label:"General",contents:o},{label:"Advanced",contents:e}])}}]};function Vf(o,e){let t=o.getStyles(),n=e.manager.createModal("row_properties");return n.show({height:t.get("height")||"",border_style:t.get("border-style")||"",border_color:t.get("border-color")||"",background_color:t.get("background-color")||""}),n}var Xf={submitText:"Save",async action(o,e){return e.editor.update(()=>{let t=eo(T());for(let n of t){let r=n.getStyles();r.set("height",ft(o.get("height")?.toString()||"")),r.set("border-style",o.get("border_style")?.toString()||""),r.set("border-color",o.get("border_color")?.toString()||""),r.set("background-color",o.get("background_color")?.toString()||""),n.setStyles(r)}}),!0},fields:[{label:"Height",name:"height",type:"text"},Ca,nn(_a),nn(ba)]};function Gf(o,e){let t=o.getStyles(),n=e.manager.createModal("table_properties");return n.show({width:t.get("width")||"",height:t.get("height")||"",cell_spacing:t.get("cell-spacing")||"",cell_padding:Cf(o),border_width:t.get("border-width")||"",border_style:t.get("border-style")||"",border_color:t.get("border-color")||"",background_color:t.get("background-color")||"",caption:ha(o)?"true":"",align:o.getAlignment()}),n}var jf={submitText:"Save",async action(o,e){return e.editor.update(()=>{let t=Nt(T());if(!t)return;let n=t.getStyles();n.set("width",ft(o.get("width")?.toString()||"")),n.set("height",ft(o.get("height")?.toString()||"")),n.set("cell-spaci
`;var sp='<svg version="1.1" viewBox="0 -960 960 960" xmlns="http://www.w3.org/2000/svg"><path class="editor-icon-color-bar" d="m80-2e-6v-160h800v160z"/><path d="m584-480-104-104-160 160 103 104zm-47-160 103 103 160-159-104-104zm-84-29 216 216-189 190c-16 16-34.833 24-56.5 24s-40.5-8-56.5-24l-27 23h-200l126-125c-16-16-24.333-35.167-25-57.5s7-41.5 23-57.5zm0 0 187-187c16-16 34.833-24 56.5-24s40.5 8 56.5 24l104 103c16 16 24 34.833 24 56.5s-8 40.5-24 56.5l-188 187z"/></svg>';var lp='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M80-400v-80h800v80H80Zm340-160v-120H200v-120h560v120H540v120H420Zm0 400v-160h120v160H420Z"/></svg>';var ap='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M760-600v-80q0-17 11.5-28.5T800-720h80v-40H760v-40h120q17 0 28.5 11.5T920-760v40q0 17-11.5 28.5T880-680h-80v40h120v40H760ZM235-160l185-291-172-269h106l124 200h4l123-200h107L539-451l186 291H618L482-377h-4L342-160H235Z"/></svg>';var cp='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M760-160v-80q0-17 11.5-28.5T800-280h80v-40H760v-40h120q17 0 28.5 11.5T920-320v40q0 17-11.5 28.5T880-240h-80v40h120v40H760Zm-525-80 185-291-172-269h106l124 200h4l123-200h107L539-531l186 291H618L482-457h-4L342-240H235Z"/></svg>';var dp='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M320-240 80-480l240-240 57 57-184 184 183 183-56 56Zm320 0-57-57 184-184-183-183 56-56 240 240-240 240Z"/></svg>';var up='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="m528-546-93-93-121-121h486v120H568l-40 94ZM792-56 460-388l-80 188H249l119-280L56-792l56-56 736 736-56 56Z"/></svg>';function rn(o,e,t){return{label:o,icon:t,action(n){n.editor.dispatchCommand(Ne,e)},isActive(n){return Uu(n,e)}}}var fp=rn("Bold","bold",op),mp=rn("Italic","italic",np),pp=rn("Underline","underline",rp),gp={label:"Text color",icon:ip},hp={label:"Background color",icon:sp};function Np(o,e,t){o.editor.update(()=>{let n=T();n&&Pl(n,{[e]:t||null})})}var xp=(o,e)=>Np(e,"color",o),Ep=(o,e)=>Np(e,"color",o),Tp=rn("Strikethrough","strikethrough",lp),Cp=rn("Superscript","superscript",ap),_p=rn("Subscript","subscript",cp),bp=rn("Inline code","code",dp),yp={label:"Clear formatting",icon:up,action(o){o.editor.update(()=>{let e=T();for(let t of e?.getNodes()||[])y(t)&&(t.setFormat(0),t.setStyle(""))})},isActive(){return!1}};var Sp='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"/></svg>';var Lp='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"/></svg>';var Mp='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"/></svg>';var wp='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"/></svg>';var vp='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M440-800v400q0 17-11.5 28.5T400-360q-17 0-28.5-11.5T360-400v-160q-66 0-113-47t-47-113q0-66 47-113t113-47h280q17 0 28.5 11.5T680-840q0 17-11.5 28.5T640-800h-40v400q0 17-11.5 28.5T560-360q-17 0-28.5-11.5T520-400v-400h-80Zm-80 160v-160q-33 0-56.5 23.5T280-720q0 33 23.5 56.5T360-640Zm0-80Zm328 520H160q-17 0-28.5-11.5T120-240q0-17 11.5-28.5T160-280h528l-36-36q-11-11-11-28t11-28q11-11 28-11t28 11l104 104q12 12 12 28t-12 28L708-108q-11 11-28 11t-28-11q-11-11-11-28t11-28l36-36Z"/></svg>';var Dp='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M440-800v400q0 17-11.5 28.5T400-360q-17 0-28.5-11.5T360-400v-160q-66 0-113-47t-47-113q0-66 47-113t113-47h280q17 0 28.5 11.5T680-840q0 17-11.5 28.5T640-800h-40v400q0 17-11.5 28.5T560-360q-17 0-28.5-11.5T520-400v-400h-80Z
`;var ng='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m21.41 11.41-8.83-8.83c-.37-.37-.88-.58-1.41-.58H4c-1.1 0-2 .9-2 2v7.17c0 .53.21 1.04.59 1.41l8.83 8.83c.78.78 2.05.78 2.83 0l7.17-7.17c.78-.78.78-2.04-.01-2.83M6.5 8C5.67 8 5 7.33 5 6.5S5.67 5 6.5 5 8 5.67 8 6.5 7.33 8 6.5 8"/></svg>';var rg='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="m380-300 280-180-280-180v360ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z"/></svg>';var jn=class extends Error{constructor(e,t){super(e.statusText),this.data=t,this.headers=e.headers,this.redirected=e.redirected,this.status=e.status,this.statusText=e.statusText,this.url=e.url,this.original=e}};function ms(o){return new Promise((e,t)=>{o.oncomplete=o.onsuccess=()=>e(o.result),o.onabort=o.onerror=()=>t(o.error)})}function IE(o,e){let t=indexedDB.open(o);t.onupgradeneeded=()=>t.result.createObjectStore(e);let n=ms(t);return(r,i)=>n.then(s=>i(s.transaction(e,r).objectStore(e)))}var Ia;function $a(){return Ia||(Ia=IE("keyval-store","keyval")),Ia}function Pa(o,e=$a()){return e("readonly",t=>ms(t.get(o)))}function Ba(o,e,t=$a()){return t("readwrite",n=>(n.put(e,o),ms(n.transaction)))}function Fa(o,e=$a()){return e("readwrite",t=>(t.delete(o),ms(t.transaction)))}var Et=null,Ua,ps,Ha,Ka="last-drawing-save";function za(o){Et?.contentWindow?.postMessage(JSON.stringify(o),Ua)}function PE(o){Ba(Ka,o.data),Ha&&Ha(o.data).then(()=>{Fa(Ka)})}function BE(o){za({action:"export",format:"xmlpng",xml:o.xml,spin:"Updating drawing"})}function FE(){ps&&ps().then(o=>{za({action:"load",autosave:1,xml:o})})}function HE(){let o={};Et&&(window.$events.emitPublic(Et,"editor-drawio::configure",{config:o}),za({action:"configure",config:o}))}function ig(){window.removeEventListener("message",sg),Et&&document.body.removeChild(Et)}function sg(o){if(!o.data||o.data.length<1||o.origin!==Ua)return;let e=JSON.parse(o.data);e.event==="init"?FE():e.event==="exit"?ig():e.event==="save"?BE(e):e.event==="export"?PE(e):e.event==="configure"&&HE()}async function KE(){let o=await Pa(Ka),e=document.getElementById("unsaved-drawing-dialog");e||console.error("Missing expected unsaved-drawing dialog"),o&&e&&await window.$components.firstOnElement(e,"confirm-dialog").show()&&(ps=async()=>o)}async function lg(o,e,t){ps=e,Ha=t,await KE(),Et=document.createElement("iframe"),Et.setAttribute("frameborder","0"),window.addEventListener("message",sg),Et.setAttribute("src",o),Et.setAttribute("class","fullscreen"),Et.style.backgroundColor="#FFFFFF",document.body.appendChild(Et),Ua=new URL(o).origin}async function ag(o,e){let t={image:o,uploaded_to:e};return(await window.$http.post(window.baseUrl("/images/drawio"),t)).data}function Wa(){ig()}async function cg(o){try{return`data:image/png;base64,${(await window.$http.get(window.baseUrl(`/images/drawio/base64/${o}`))).data.content}`}catch(e){throw e instanceof jn&&window.$events.showResponseError(e),Wa(),e}}function Xr(o){return o instanceof yo}function zE(o,e){o.status===413?window.$events.emit("error",e.options.translations.serverUploadLimitText||""):window.$events.emit("error",e.options.translations.imageUploadErrorText||""),console.error(o)}async function WE(o,e){return await new Promise((n,r)=>{o.getEditorState().read(()=>{let{id:i}=e.getDrawingIdAndUrl();n(i)})})||""}async function qE(o,e,t,n){if(Wa(),n){let r=window.baseUrl("/loading.gif");o.editor.update(()=>{e.setDrawingIdAndUrl("",r)})}try{let r=await ag(t,o.options.pageId);o.editor.update(()=>{e.setDrawingIdAndUrl(String(r.id),r.url)})}catch(r){throw r instanceof jn&&zE(r,o),n&&o.editor.update(()=>{e.remove()}),new Error(`Failed to save image with error: ${r}`)}}function Gr(o,e){let t=!1;lg(o.options.drawioUrl,async()=>{let n=await WE(o.editor,e);return t=!n,t?"":cg(n)},async n=>qE(o,e,n,t))}function YE(o){window.$components.first("image-manager").show(t=>{o(t)},"drawio")}function dg(o){let e=le(o.editor);YE(t=>{o.editor.update(()=>{let n=zn(t.id,t.url),r=V(e,Xr);Xr(r)?r.re
`;var Es=class extends te{constructor(e,t){super([e]),this.button=e,this.dropdownButton=new Ee({button:{label:"Menu",icon:Ag},showOnHover:!1,direction:"vertical",showAside:!1},t),this.addChildren(this.dropdownButton)}buildDOM(){return b("div",{class:"editor-button-with-menu-container"},[this.button.getDOMElement(),this.dropdownButton.getDOMElement()])}};var sn=class extends Me{buildDOM(){return b("div",{class:"editor-separator"})}};function Rg(o){let e=o.manager.getDefaultDirection()==="rtl";return new Ji("editor-toolbar-main",[new nt(2,[new w(Hm),new w(Km)]),new es([new Ye(b("h2"),Gm),new Ye(b("h3"),jm),new Ye(b("h4"),Jm),new Ye(b("h5"),Qm),new Ye(b("blockquote"),ep),new Ye(b("p"),tp),new Ee({button:{label:"Callouts",format:"long"},showOnHover:!0,direction:"vertical"},[new Ye(b("p",{class:"callout info"}),Ym),new Ye(b("p",{class:"callout success"}),Xm),new Ye(b("p",{class:"callout warning"}),Vm),new Ye(b("p",{class:"callout danger"}),Zm)])]),new nt(6,[new w(fp),new w(mp),new w(pp),new Ee({button:new Kr(gp,"color")},[new tn(xp)]),new Ee({button:new Kr(hp,"background-color")},[new tn(Ep)]),new w(Tp),new w(Cp),new w(_p),new w(bp),new w(yp)]),new nt(6,[new w(Ap),new w(Rp),new w(kp),new w(Ip),e?new w($p):null,e?new w(Pp):null].filter(t=>t!==null)),new nt(3,[new w(zp),new w(Wp),new w(qp),new w(Zp),new w(Yp)]),new nt(4,[new w(qa),new Ee({button:gm,direction:"vertical",showAside:!1},[new Ee({button:{label:"Insert",format:"long"},showOnHover:!0,showAside:!0},[new ns]),new sn,new Ee({button:{label:"Cell",format:"long"},direction:"vertical",showOnHover:!0},[new w(wm),new w(vm),new w(Dm)]),new Ee({button:{label:"Row",format:"long"},direction:"vertical",showOnHover:!0},[new w({...wa,format:"long"}),new w({...va,format:"long"}),new w({...Da,format:"long"}),new w(Em),new sn,new w(Tm),new w(Cm),new w(_m),new w(bm)]),new Ee({button:{label:"Column",format:"long"},direction:"vertical",showOnHover:!0},[new w({...Oa,format:"long"}),new w({...Aa,format:"long"}),new w({...Ra,format:"long"}),new sn,new w(ym),new w(Sm),new w(Lm),new w(Mm)]),new sn,new w({...La,format:"long"}),new w(hm),new w(Nm),new w(xm)]),new w(Ya),new w(bg),new w(Za),new Es(new w(Sg),[new w(Lg)]),new w(Mg),new w(wg)]),new nt(3,[new w(Um),new w(Wm),new w(zm)])])}function kg(){return[new w(Ya)]}function Ig(){return[new w(qa),new w(_g)]}function $g(){return[new w(yg)]}function Pg(){return[new nt(2,[new w(La),new w(Ma)]),new nt(3,[new w(wa),new w(va),new w(Da)]),new nt(3,[new w(Oa),new w(Aa),new w(Ra)])]}function Bg(){return[new w(vg),new w(Dg),new w(Og)]}var Fg='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>';var Ts=class extends te{constructor(e,t){super([new is(e.form)]),this.definition=e,this.key=t}show(e){let t=this.getDOMElement();document.body.append(t);let n=this.getForm();n.setValues(e),n.setOnCancel(this.hide.bind(this)),n.setOnSuccessfulSubmit(this.hide.bind(this)),this.getContext().manager.setModalActive(this.key,this)}hide(){this.getDOMElement().remove(),this.getContext().manager.setModalInactive(this.key)}getForm(){return this.children[0]}buildDOM(){let e=b("button",{class:"editor-modal-close",type:"button",title:this.trans("Close")});e.innerHTML=Fg,e.addEventListener("click",this.hide.bind(this));let t=b("div",{class:"editor-modal editor-form-modal"},[b("div",{class:"editor-modal-header"},[b("div",{class:"editor-modal-title"},[this.trans(this.definition.title)]),e]),b("div",{class:"editor-modal-body"},[this.getForm().getDOMElement()])]),n=b("div",{class:"editor-modal-wrapper"},[t]);return n.addEventListener("click",r=>{r.target&&!t.contains(r.target)&&this.hide()}),n}};var Cs=class extends te{constructor(e,t){super(t),this.target=e}buildDOM(){return b("div",{class:"editor-context-toolbar"},this.getChildren().map(e=>e.getDOMElement()))}updatePosition(){let e=this.getContext().scrollDOM.getBoundingClientRect(),t=this.target.getBoundingClientRect(),n=this.getDOMElement(),r=n.getBoundingClientRect(),i=t.bottom>e.top&&t.top<e.bottom;if(n
`).length*19.2+18+24;n.style.height=`${l}px`;let a=Date.now();n.addEventListener("click",f=>{requestAnimationFrame(()=>{t.editor.update(()=>{ke(this.getNode())})})}),n.addEventListener("dblclick",f=>{t.editor.getEditorState().read(()=>{Hr(t.editor,this.getNode())})});let c=f=>{n.classList.toggle("selected",Fi(f,r))};t.manager.onSelectionChange(c),this.onDestroy(()=>{t.manager.offSelectionChange(c)});let m=f=>{this.editor=f.wysiwygView(n,document,this.latestCode,this.latestLanguage),setTimeout(()=>{n.style.height=""},12)};window.importVersioned("code").then(f=>{let d=Date.now()-a<20?20:0;setTimeout(()=>m(f),d)}),this.completedSetup=!0}update(){let t=this.getNode(),n=t.getCode(),r=t.getLanguage();this.latestCode===n&&this.latestLanguage===r||(this.latestLanguage=r,this.latestCode=n,this.editor&&(this.editor.setContent(n),this.editor.setMode(r,n)))}render(t,n){this.completedSetup?this.update():this.setup(t,n)}};var ys=class extends Jn{constructor(){super(...arguments);this.completedSetup=!1}setup(t,n){let r=this.getNode();n.classList.add("editor-diagram"),n.addEventListener("click",s=>{t.editor.update(()=>{ke(this.getNode())})}),n.addEventListener("dblclick",s=>{t.editor.getEditorState().read(()=>{Gr(t,this.getNode())})});let i=s=>{n.classList.toggle("selected",Fi(s,r))};t.manager.onSelectionChange(i),this.onDestroy(()=>{t.manager.offSelectionChange(i)}),this.completedSetup=!0}update(){}render(t,n){this.completedSetup?this.update():this.setup(t,n)}};var Ss=class extends Me{constructor(t){super();this.url="";this.url=t}buildDOM(){let t=b("div",{class:"editor-external-content"});return window.$http.get(this.url).then(n=>{typeof n.data=="string"&&(t.innerHTML=n.data)}),t}};var Hg={submitText:"Save",async action(o,e){return Gn(e.editor,o.get("source")?.toString()||""),!0},fields:[{label:"Source",name:"source",type:"textarea"}]},Kg={submitText:"Close",async action(){return!0},fields:[{build(){return new Ss("/help/wysiwyg")}}]};var Va={link:{title:"Insert/Edit Link",form:Ng},image:{title:"Insert/Edit Image",form:hg},media:{title:"Insert/Edit Media",form:Eg},source:{title:"Source code",form:Hg},cell_properties:{title:"Cell Properties",form:Zf},row_properties:{title:"Row Properties",form:Xf},table_properties:{title:"Table Properties",form:jf},details:{title:"Edit collapsible block",form:Cg},about:{title:"About the WYSIWYG Editor",form:Kg}};function Ug(o,e,t,n,r){let i=new _s,s={editor:n,containerDOM:o,editorDOM:e,scrollDOM:t,manager:i,translate(l){return r.translations[l]||l},error(l){let a=l instanceof Error?l.message:l;window.$events.error(a)},options:r};i.setContext(s),i.setToolbar(Rg(s));for(let l of Object.keys(Va))i.registerModal(l,Va[l]);return i.registerContextToolbar("image",{selector:"img:not([drawio-diagram] img)",content:kg()}),i.registerContextToolbar("link",{selector:"a",content:Ig(),displayTargetLocator(l){return l.querySelector("img")||l}}),i.registerContextToolbar("code",{selector:".editor-code-block-wrap",content:$g()}),i.registerContextToolbar("table",{selector:"td,th",content:Pg(),displayTargetLocator(l){return l.closest("table")}}),i.registerContextToolbar("details",{selector:"details",content:Bg()}),i.registerDecoratorType("code",bs),i.registerDecoratorType("diagram",ys),s}var Qn=class{constructor(e,t,n){this.startX=0;this.startY=0;this.target=null;this.container=e,this.dragTargetSelector=t,this.options=n,this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.container.addEventListener("mousedown",this.onMouseDown)}teardown(){this.container.removeEventListener("mousedown",this.onMouseDown),this.container.removeEventListener("mouseup",this.onMouseUp),this.container.removeEventListener("mousemove",this.onMouseMove)}onMouseDown(e){this.target=e.target.closest(this.dragTargetSelector),this.target&&(this.startX=e.screenX,this.startY=e.screenY,window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("mouseup",this.onMouseUp),this.options.down&&this.options.down(e,this.target))}onMouseMove(e){this.options.move&&this
//# sourceMappingURL=wysiwyg.js.map