1import{$a as go,Da as fo,Ga as mo,I as K,La as kt,Ma as g,Na as V,Qa as D,Sa as Cs,Ta as Ts,Ua as Ss,V as j,W as Ue,Ya as po,Z as ho,Za as xs,_a as z,a as T,aa as B,bb as qe,c as As,ca as Le,cb as bo,da as M,db as wo,e as co,eb as Rs,f as bt,fa as _s,fb as Ee,g as wt,ga as Z,h as L,hb as yo,jb as ko,kb as vo,la as yt,lb as Bs,na as v,oa as E,p as R,r as uo,s as Ne}from"/.wh/ea/ap/utwente_base.ws2026/chunk-RPOHHMHQ.mjs";function Nt(i,e,t,o){e=Q?.target??e;let s=Q?.target??t.target;if(!s)return;let n;if("touches"in t&&t.touches.length?n=t.touches[0]:t.type==="touchend"?n=vt:n=t,!n)return;t.type==="touchmove"&&(vt=Lo(n));let l=Q?n.clientX-Q.startX:0,r=Q?n.clientY-Q.startY:0,a={movedX:l,movedY:r,pageX:n.pageX,pageY:n.pageY,clientX:n.clientX,clientY:n.clientY,screenX:n.screenX,screenY:n.screenY,listener:e,currentTarget:t.target};return B(s,i,{detail:a,cancelable:o,bubbles:!0})}function Is(i,e,t){Q={target:i,startX:e,startY:t},window.addEventListener("mousemove",Ve,!0),window.addEventListener("mouseup",We,!0),window.addEventListener("touchmove",Ve,!0),window.addEventListener("touchend",We,!0)}function Ps(){Q=null,window.removeEventListener("mousemove",Ve,!0),window.removeEventListener("mouseup",We,!0),window.removeEventListener("touchmove",Ve,!0),window.removeEventListener("touchend",We,!0)}function Lo(i){return{pageX:i.pageX,pageY:i.pageY,clientX:i.clientX,clientY:i.clientY,screenX:i.screenX,screenY:i.screenY}}function No(i){if(i instanceof MouseEvent&&i.button||!Nt("dompack:movestart",i.target,i,!0))return;let e=Ms&&i instanceof TouchEvent?i.touches[0]:i;vt=Lo(e),Is(i.target,e.clientX,e.clientY),M(i)}function Ve(i){Q&&(M(i),Nt("dompack:move",null,i,!1))}function We(i){Q&&(M(i),Nt("dompack:moveend",null,i,!1)),Ps()}function Eo(i){i.addEventListener("mousedown",No),i.addEventListener("touchstart",No)}var Ms,Q,vt,Ao=T(()=>{"use strict";_s();Ms=typeof TouchEvent<"u",Q=null,vt=null});function H(i,e){return Array.isArray(e)?e.includes(i.nodeType):i.nodeType===e}function _t(i,e){let t={};for(let o=0;o<e.length;++o)if(i.hasAttribute(e[o])){let s=i.getAttribute(e[o]);t[e[o]]=s||""}return t}function Bo(i){let e={};for(let t=0,o=i.attributes.length;t<o;++t){let s=i.attributes[t].name,n=i.getAttribute(s);e[s]=n||""}return e}function Qe(i,e){let t=Object.keys(e).sort();z()==="firefox"&&(t=t.reverse());for(let o=0;o<t.length;++o)i.setAttribute(t[o],e[t[o]])}function Ke(i){let e=0,t=i;for(;t=t.previousSibling;)++e;return e}function _o(i,e){let t=[];for(let o=i;o;o=o.parentNode)t.push(o);for(let o=e;o;o=o.parentNode)if(t.includes(o))return o;throw new Error("Internal error: no common ancestor found. Nodes are outside the DOM ?")}function Co(i,e){if(i.offset===0)return 1;if(i.offset===qo(i.element))return-1;let t=e.clone();return t.ascend(i.element,"really",!0),t.offset<=i.offset?-1:1}function Ct(i,e){if(!i)throw new Error("No node in isNodeFilterMatch");return Array.isArray(e)?e.includes(i.nodeName.toLowerCase()):typeof e=="string"?i.nodeName.toLowerCase()===e.toLowerCase():e(i)}function F(i,e){let t=[];if(!i)return t;for(let o of i)for(let s of o.getContainedLocators())t.indexOf(s)===-1&&t.push(s);return t.forEach((o,s)=>e(o,s,t)),t}function Hs(i){return H(i,[S.element,S.documentFragment])?i.childNodes.length:i.nodeValue?i.nodeValue.length:0}function P(i,e,t){for(;i;i=i.parentNode){if(Ct(i,e))return i;if(i===t)break}return null}function To(i){let e=i.nodeName.toUpperCase();return["TBODY","COL","COLGROUP","TR","TFOOT","THEAD"].indexOf(e)!==-1}function I(i){let e=i.nodeName.toUpperCase();return["ADDRESS","BLOCKQUOTE","CENTER","CODE","DIV","DL","FIELDSET","FORM","H1","H2","H3","H4","H5","H6","HR","ISINDEX","MENU","OL","P","PRE","TABLE","UL","DD","DT","FRAMESET","LI","TBODY","TD","TFOOT","TH","THEAD","TR"].indexOf(e)!==-1}function Lt(i){let e=i.nodeName.toUpperCase();return["ADDRESS","BLOCKQUOTE","DL","FIELDSET","FORM","ISINDEX","MENU","TABLE","DD","DT","FRAMESET","LI","TBODY","TD","TFOOT","TH","THEAD","TR"].indexOf(e)!==-1}function Fs(i){return js(i)}function js(i){let e=["CENTER","DIV","H1","H2","H3","H4","H5","H6","HR","P","LI"],t=i.nodeName.toUpperCase();return e.indexOf(t)!==-1}function oe(i){return H(i,S.element)&&i.classList&&i.classList.contains("wh-rtd-embeddedobject")}function Ye(i){return R(i,".wh-rtd-embeddedobject")}function W(i){if(i.nodeType!==1)return!0;
1if(oe(i))return!1;let e=i.nodeName.toUpperCase();return e!=="BR"&&e!=="AREA"&&e!=="LINK"&&e!=="IMG"&&e!=="PARAM"&&e!=="HR"&&e!=="INPUT"&&e!=="META"&&e!=="COL"&&e!=="SVG"}function Tt(i,e){let t=i;i=i.clone(),!i.parentIsElementOrFragmentNode&&(i.element.nodeValue||"").substring(i.offset,i.offset+2)===`\r 2`?i.offset+=2:++i.offset;let o=i.clone(),s=i.scanForward(e,{whitespace:!0});return s.type==="outerblock"||s.type==="innerblock"?new Y(t,o):null}function de(i,e,t){let o=e.clone(),s=o.scanBackward(i,{whitespace:!0}),n=e.clone(),l=n.scanForward(i,{whitespace:!0});t&&s.type==="br"&&l.blockboundary&&(--o.offset,n=o.clone(),l=s,s=o.scanForward(i,{whitespace:!0}));let r;s.visiblecontent?r="normal":l.visiblecontent||l.type==="br"||l.type==="outerblock"&&l.alwaysvisible&&s.type==="outerblock"&&s.alwaysvisible?r="ignore":r="invalid";let a=r!=="invalid";if(r==="normal"){let d=e.clone(),c=null,u=e.clone();for(;;){let h=u.scanBackward(i,{});if(h.type==="whitespace")d.assign(u),c=h,--u.offset;else break}c?(o.assign(d),s=c):(n.assign(o),l=n.scanForward(i,{}))}return{valid:a,down:o,downres:s,up:n,upres:l,range:new Y(o,n)}}function So(i,e){let t=e.element;for(;t&&t!==i;){if(!W(t)){let n=f.newPointingTo(t),l=f.newPointingAfter(t);return{down:n,downres:n.scanBackward(i,{whitespace:!0,blocks:!0,li:!0}),up:l,upres:l.scanForward(i,{whitespace:!0,blocks:!0,li:!0}),range:new Y(n,l)}}t=t.parentNode}let o=de(i,e,!1);if(o.valid)return o;o.downres.type==="br"&&--o.down.offset;let s=P(e.element,I,i)||i;for(let n=0;n<2;++n){let l=o.up.clone();if(o.up.scanForward(s,{whitespace:!0,blocks:!0}),!l.equals(o.up)&&(o=de(i,o.up,!0),o.valid))return o;let r=o.down.clone();if(o.down.scanBackward(s,{whitespace:!0,blocks:!0}),(!r.equals(o.down)||n===1)&&(o=de(i,o.down,!0),o.valid||n===1))return o;if(s===i)break;s=i}return de(i,o.up,!0)}function Ge(i,e,t){if(t&&!["start","end"].includes(t))throw new Error("Illegal preservetoward value '"+t+"'");i=i.clone();let o=i.element.splitText(i.offset);return F(e,s=>Mo(i,o,t==="start",s)),f.newPointingTo(o)}function zs(i,e,t){if(t&&!["start","end"].includes(t))throw new Error("Illegal preservetoward value '"+t+"'");i=i.clone();let o=f.newPointingTo(i.element);++o.offset;let s=i.element.cloneNode(!1);o.insertNode(s);let n=Array.from(i.element.childNodes).slice(i.offset);return s.append(...n),F(e,l=>Mo(i,s,t==="start",l)),o}function Mo(i,e,t,o){o.element===i.element&&(t?o.offset>i.offset:o.offset>=i.offset)?(o.element=e,o.offset-=i.offset):o.element===i.element.parentNode&&o.offset>Ke(i.element)&&++o.offset}function A(i,e,t){if(!i)throw new Error("No ancestor in splitdom!");if([3,4].includes(i.nodeType))throw new Error("splitDom ancestor must be an element");t=(t||[]).slice();let o=[];for(let n=0;n<e.length;++n){let l=e[n].locator;e[n].locator=e[n].locator.clone(),e[n].locator.ascend(i,e[n].toward==="end");let r=e[n].preservetoward=e[n].preservetoward||"end";if(!["start","end"].includes(r))throw new Error("Illegal preservetoward value '"+r+"'");let a=e[n].locator.compare(l);a<0?(F(t,d=>xo(e[n].locator,l,r==="start",e[n].locator,d)),e[n].preservetoward="start"):a>0&&(F(t,d=>xo(l,e[n].locator,r==="end",e[n].locator,d)),e[n].preservetoward="end")}for(let n=e.length-1;n>=0;--n){let l=e[n].locator;for(l.ascend(i,e[n].toward==="end"),l.element.nodeType===3&&(l=Ge(l,t,e[n].preservetoward));l.element!==i;)l=zs(l,t,e[n].preservetoward);o.splice(0,0,l),t.push(l)}o.splice(0,0,new f(i)),o.push(new f(i,"end"));let s=[];for(let n=0;n<o.length-1;++n)s.push(new Y(o[n],o[n+1]));return s}function xo(i,e,t,o,s){s.compare(i)>(t?-1:0)&&s.compare(e)<(t?1:0)&&s.assign(o)}function Us(i,e){if(!i)throw new Error("Illegal parameter");let t=i.previousSibling,o=i;if(!t)throw new Error("Node has no previous sibling to combine with");return Ae(new f(t,"end"),o,e)}function Ae(i,e,t){i=i.clone();let o=i.element;if(o.nodeType!==e.nodeType||![1,3,4].includes(o.nodeType))throw new Error("Left and right node not the same type (or no element or data node)");let s=f.newPointingTo(e),n=f.newPointingAfter(e),l=!1;if(n.compare(i)<=0)l=!0;else if(s.compare(i)<0)throw new Error("Can't move content inside removed node");F(t,a=>
2qs(i,e,s,n,l,a));let r=i.clone();if(o.nodeType===1){let a=Je(e);Ce(a,i),r.offset+=a.length}else o.nodeValue=(o.nodeValue||"").substring(0,i.offset)+e.nodeValue+(o.nodeValue||"").substring(i.offset),r.offset+=(e.nodeValue||"").length;return s=f.newPointingTo(e),s.removeNode([i,r]),{node:o,locator:i,afterlocator:r}}function qs(i,e,t,o,s,n){let l=i;if(i.element===t.element&&i.offset>t.offset&&(l=i.clone(),--l.offset),n.element===e){n.element=l.element,n.offset+=l.offset;return}if(!(n.compare(t)>0&&n.compare(o)<0))if(s)if(n.compare(o)>=0&&n.compare(i)<=0)n.assign(l),n.offset+=e.childNodes.length;else if(n.element===i.element&&n.offset>=i.offset){let r=n.offset-i.offset;n.assign(l),n.offset+=r}else n.element===t.element&&n.offset>t.offset&&--n.offset;else if(n.compare(t)<=0&&n.compare(i)>=0)n.assign(l);else if(n.element===i.element&&n.offset>=i.offset){let r=n.offset-i.offset;n.element===t.element&&n.offset>t.offset&&--r,n.assign(l),n.offset+=r+e.childNodes.length}else n.element===t.element&&n.offset>t.offset&&--n.offset}function Xe(i,e,t){if(i.start.element!==i.end.element)throw new Error("moveRangeTo can only move a range with the start and end element the same");let o=i.start.parentIsElementOrFragmentNode();if(o!==e.parentIsElementOrFragmentNode())throw new Error("moveRangeTo can only move nodes to within elements & data to within data nodes");e=e.clone();let s=i.start.clone(),n=i.end.clone(),l=e.clone(),r=!1;if(n.compare(e)<=0)r=!0;else if(s.compare(e)<0)throw new Error("Can't move content inside removed node");e.element===s.element&&e.offset>=n.offset&&(e.offset-=n.offset-s.offset),F(t,d=>Vs(s,n,l,e,r,d));let a=e.clone();if(o){let d=Array.from(s.element.childNodes).slice(s.offset,n.offset);a=Xs(d,a)}else{let d=s.element,c=e.element,u=(d.nodeValue||"").substring(s.offset,n.offset);d.nodeValue=(d.nodeValue||"").substring(0,s.offset)+(d.nodeValue||"").substring(n.offset),c.nodeValue=(c.nodeValue||"").substring(0,e.offset)+u+(c.nodeValue||"").substring(e.offset),a.offset+=u.length}return{insertlocator:e,afterlocator:a,movedforward:r}}function Vs(i,e,t,o,s,n){if(n.element===i.element&&n.offset>i.offset&&n.offset<e.offset){n.element=o.element,n.offset=o.offset+(n.offset-i.offset);return}let l=n.compare(i),r=n.compare(e);if(!(l>0&&r<0)){if(s){if(r>=0&&n.compare(t)<=0){n.element=o.element,n.offset=o.offset+(e.offset-i.offset);return}}else if(l<=0&&n.compare(t)>=0){n.assign(o);return}if(i.element!==t.element){if(n.element===t.element){if(n.offset>t.offset){n.offset=o.offset+(n.offset-t.offset)+(e.offset-i.offset);return}}else if(n.element===e.element&&n.offset>=e.offset){n.offset-=e.offset-i.offset;return}}}}function ce(i,e){if(i.start.element!==i.end.element)throw new Error("removeRange can only remove a range with the start and end element the same");i=i.clone();let t=i.start.parentIsElementOrFragmentNode();F(e,s=>Ws(i,s));let o=document.createDocumentFragment();if(t){let s=Array.from(i.start.element.childNodes).slice(i.start.offset,i.end.offset);for(let n=0;n<s.length;++n)o.appendChild(s[n])}else{let s=i.start.element,n=(s.nodeValue||"").substring(i.start.offset,i.end.offset);s.nodeValue=(s.nodeValue||"").substr(0,i.start.offset)+(s.nodeValue||"").substr(i.end.offset),o.appendChild(document.createTextNode(n))}return{fragment:o}}function Ws(i,e){e.element===i.end.element&&e.offset>=i.end.offset?e.offset-=i.end.offset-i.start.offset:e.compare(i.start)>0&&e.compare(i.end)<0&&e.assign(i.start)}function St(i,e){let t=f.newPointingTo(i),o=Je(i);Ce(o,t),f.newPointingTo(i).removeNode(),F(e,n=>Ks(t,i,o.length,n))}function Ks(i,e,t,o){o.element===e?(o.element=i.element,o.offset+=i.offset):o.element===i.element&&o.offset>i.offset&&(o.offset=o.offset-1+t)}function _e(i,e,t){if(i.start.element!==i.end.element)throw new Error("wrapSimpleRangeInNewNode only works with ranges where start element is equal to end element");return t=(t||[]).concat(i),Et(i.start,i.end.offset-i.start.offset,e,t)}function Et(i,e,t,o){i=i.clone();let s=Array.from(i.element.childNodes).slice(i.offset,i.offset+e);return t.append(...s),i.insertNode(t),F(o,n=>Qs(i,e,t,n)),++i.offset,i}function Qs(i,e,t,o){o.element===i.element&&o.offset>=i.offset&&(o.offset<=i.offset+e?(o.element=t,o.offset-=i.offset):o.offset=o.offset-e+1)}function Io(i,e,t){for(let o=0;o<i.childNodes.length;){let s=i.childNodes[o];Ct(s,e)?St(s,t):(Io(s,e,t),++o)}}function Po(i,e,t,o){let s=e.start.clone();s.ascend(i,!1,!0);let n=e.end.clone();for(n.ascend(i,!0,!0),o=(o||[]).slice(),o.push(n);!s.equals(n);){let l=s.getPointedNode();if(!l)throw new Error("Could not find pointed to node");if([3,4].includes(l.nodeType)){++s.offset;continue}if(Ct(l,t))St(l,o);else{let r=Y.fromNodeInner(l),a=e.clone();a.intersect(r),a.equals(r)?Io(l,t,o):Po(l,a,t,o),++s.offset}}}function Oo(i,e,t,o){o=(o||[]).slice(),o.push(i);let s;for(;;){s=i.getAncestorElement();let n=P(s,t,e);if(!n||n===e||!n.parentNode)break;let l=A(n.parentNode,[{locator:i.start,toward:"start"},{locator:i.end,toward:"end"}],o),r=l[1].start.clone(),a=o.concat([r,l[1].end]);for(;!r.equals(l[1].end);){let d=r.getPointedNode();if(!d)throw new Error("Could not find pointed to node");++r.offset,St(d,a)}i.start.assign(l[1].start.clone()),i.end.assign(r)}for(;;){let n=P(i.start.element,t,s);if(!n)break;let l=A(n.parentNode,[{locator:i.start,toward:"start"}],o);i.start.assign(l[1].start)}for(;;){let n=P(i.end.element,t,s);if(!n)break;let l=A(n.parentNode,[{locator:i.end,toward:"end"}],o);i.end.assign(l[0].end)}Po(s,i,t,o)}function Do(i,e){return!e||e(i)}function Ro(i,e,t){let o=i.element;for([3,4].includes(o.nodeType)&&(o=o.parentNode);o!==e&&Do(o,t);)o=o.parentNode;return o}function Ho(i,e,t,o,s){let n=i.clone();n.start.ascend(e,!1,!0),n.end.ascend(e,!0,!0),o=(o||[]).slice(),o.push(n.end);let l=n.start.clone();for(;!n.start.equals(n.end);){let r=n.start.getPointedNode();if(!r)throw new Error("Could not find pointed to node");if([3,4].includes(r.nodeType)||Do(r,s?.onCanWrapNode)){++n.start.offset;continue}if(!l.equals(n.start)){let c=t();Et(l,n.start.offset-l.offset,c,o),++l.offset}let a=Y.fromNodeInner(r),d=i.clone();d.intersect(a),(!s?.onAllowIn||s?.onAllowIn(r))&&Ho(d,r,t,o,s),++l.offset,n.start.assign(l)}if(!l.equals(n.start)){let r=t();Et(l,n.start.offset-l.offset,r,o)}}function Fo(i,e,t){let o=[...t?.preserveLocators||[],i];i=i.clone();let s=i.getAncestorElement(),n=Ro(i.start,s,t?.onCanWrapNode),l=A(n,[{locator:i.start,toward:"end"}],o.concat([i.end]));i.start.assign(l[1].start);let r=Ro(i.end,s,t?.onCanWrapNode);l=A(r,[{locator:i.end,toward:"start"}],o.concat([i.start])),i.end.assign(l[0].end),Ho(i,s,e,o,t)}function xt(i,e,t,o,s){if(!e.contains(i.element))throw new Error("Locator position problem");for(s=(s||[]).slice(),s.push(i),i=i.clone(),i.ascend(e,t,!1);i.offset!==0&&!(!i.parentIsElementOrFragmentNode()||i.pointsPastChildrenEnd());){let n=i.getPointedNode();if(!n)throw new Error("Could not find pointed to node");let l=n.previousSibling;if(n.nodeType!==l.nodeType)break;if(![3,4].includes(n.nodeType)){if(n.nodeType!==1)break;if(typeof o=="function"){if(!o(l,n))return}else if(o){if(l.nodeName.toLowerCase()!==n.nodeName.toLowerCase())break;
2if(typeof o=="string"){if(l.nodeName.toLowerCase()!==o.toLowerCase())break}else if(Array.isArray(o)){if(!o.includes(l.nodeName.toLowerCase()))break}else throw new Error("Illegal combinetest in combineWithPreviousNodesAtLocator")}else break}i=Us(n,s).locator}}function jo(i){return Lt(i)?!0:new f(i).scanForward(i,{whitespace:!0}).type!=="outerblock"}function Ys(i,e,t){let o=i.clone(),s=o.scanBackward(e,{whitespace:!0});if(s.type==="br"||s.type==="node"&&s.data.classList.contains("wh-rtd-embeddedobject--inline")){let n=i.clone();if(n.scanForward(e,{whitespace:!0}).blockboundary){let r=document.createElement("br");return r.setAttribute("data-wh-rte","bogus"),n.insertNode(r,t),{locator:n,node:r}}return null}if(s=o.scanBackward(e,{whitespace:!0,blocks:!0}),s.type==="outerblock"&&s.data===e&&Fs(e)){let n=i.clone(),l=n.scanForward(e,{whitespace:!0,blocks:!0});if(l.type==="outerblock"&&l.data===e){let r=document.createElement("br");return r.setAttribute("data-wh-rte","bogus"),n.insertNode(r,t),{locator:n,node:r}}}else{let n=i.clone(),l=n.scanForward(e,{whitespace:!0,blocks:!0});if(l.type==="br"){let r=n.clone();++n.offset,l=n.scanForward(e,{whitespace:!0,blocks:!0}),l.type==="outerblock"&&l.data===e&&r.removeNode(t)}}return null}function zo(i,e,t){return Ys(i,e,t)}function Rt(i,e){let t=i.querySelectorAll('br[data-wh-rte="bogus"]');for(let o of t){let s=f.newPointingTo(o),n=s.clone().scanBackward(i,{whitespace:!0});n.type==="br"&&!n.bogussegmentbreak||n.type==="outerblock"||n.type==="innerblock"||n.type==="node"&&n.data.classList.contains("wh-rtd-embeddedobject--inline")||s.removeNode(e)}}function Gs(i){for(let e=0;e<i.length;++e){let t=i[e].parentNode;t&&t.removeChild(i[e])}}function Xs(i,e){return Gs(i),Ce(i,e)}function Ce(i,e,t){let o=e.clone();for(let s=0;s<i.length;++s)o=o.insertNode(i[s],t);return o}function Je(i){let e=Array.from(i.childNodes);return e.forEach(t=>i.removeChild(t)),e}function Uo(i,e){let t=i,o=i.clone();e=(e||[]).concat([o]),o.descendToLeafNode(i.element,!1),[3,4].includes(i.element.nodeType)&&i.assign(f.newPointingTo(i.element));let s=i.getPointedNode();if(!s||![3,4].includes(s.nodeType))throw console.log(t,o,i),new Error("Locator does not point to a text node");for(;;){let n=s.previousSibling;if(!n||![3,4].includes(n.nodeType))break;s=n}for(;;){let n=s.nextSibling;if(!n||![3,4].includes(n.nodeType))break;let l=new f(s,"end");Ae(l,n,e)}return o}function Bt(i,e,t){let o=e.clone();t=(t||[]).concat(o);let s=e.element,n=s.nodeValue;if(![3,4].includes(s.nodeType))throw new Error("Locator does not point inside a text node");let l=s.nodeValue||"",r=e.offset===0||` \r 3`.indexOf(l.substr(e.offset-1,1))!==-1;for(;e.offset<l.length;){let a=0;for(;e.offset+a<l.length&&` \r 4`.indexOf(l.substr(e.offset+a,1))!==-1;)++a;let d=l.substr(e.offset,a||1);if(!a&&d!=="\xA0")break;let c=r?"\xA0":" ",u=e.offset+d.length;l=l.substr(0,e.offset)+c+l.substr(e.offset+d.length);let h=e.offset+c.length;F(t,m=>{m.element===e.element&&m.offset>e.offset&&(m.offset>=u?m.offset+=c.length-d.length:m.offset=h)}),r=!r,e.offset=h}if(r){let a=e.clone().scanForward(i,{whitespace:!0});["innerblock","outerblock","br"].includes(a.type)&&(l=l.substr(0,e.offset-1)+"\xA0"+l.substr(e.offset))}return n!==l&&(s.nodeValue=l),o}function qo(i){return i.nodeType===1||i.nodeType===11?i.childNodes.length:i.nodeValue?i.nodeValue.length:0}var S,Ds,Y,f,ee=T(()=>{"use strict";qe();V();Ue();S={element:1,attribute:2,text:3,cDATASection:4,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11};Ds=0,Y=class i{start;end;constructor(e,t){this.start=e.clone(),this.end=t.clone()}clone(){return new i(this.start.clone(),this.end.clone())}assign(e){return this.start.assign(e.start),this.end.assign(e.end),this}isInDOM(){return this.start.isInDOM()&&this.end.isInDOM()}check(e){if(this.start.check(e),this.end.check(e),this.start.compare(this.end)>0)throw new Error("Start lies after end");return this}getAncestor(){return f.findCommonAncestor(this.start,this.end)}getAncestorElement(){return f.findCommonAncestorElement(this.start,this.end)}getAncestorClosest(e,t){if(!t)throw new Error("Scope is required");let o=this.getAncestorElement().closest(e);return t.contains(o)?o:null}isCollapsed(){return this.start.equals(this.end)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}normalize(e,t){if(!e.contains(this.getAncestorElement()))throw new Error("Maxancestor is not an ancestor of range");if(this.check(e),this.isCollapsed()&&t&&z()==="firefox")return this;if(this.legalize(e),this.start.moveToFirstVisible(e,!1,!1),this.end.movePastLastVisible(e,!1,!1),this.end.compare(this.start)<=0){this.start.moveToFirstVisible(e,!1,!0),this.end.movePastLastVisible(e,!1,!0);let o=P(this.end.getNearestNode(),"a",e);P(this.start.getNearestNode(),"a",e)!==o&&o?this.end.assign(this.start):this.start.assign(this.end)}return this}moveEndToPastLastVisible(e){if(!e)throw new Error("Missing maxancestor");let t=this.getAncestor();this.isCollapsed()||(this.end.ascend(t),!this.isCollapsed()&&this.end.parentIsElementOrFragmentNode()&&(--this.end.offset,this.end.element=this.end.getPointedNode()??j("End locator does not point to a node"),this.end.positionPastLastChild(),this.end.descendToLeafNode(e)))}splitStartBoundary(e){if(!this.start.parentIsElementOrFragmentNode()&&(this.start.element===this.end.element&&this.end.moveToParent(!0),this.start.moveToParent(!1),!this.start.parentIsElementOrFragmentNode())){let t=Ge(this.start,(e||[]).concat([this.end]),"end");this.start.assign(t)}}insertBefore(e,t){this.start.parentIsElementOrFragmentNode()||this.splitStartBoundary(t);let o=this.start.clone();
4return this.start.insertNode(e,(t||[]).concat(this)),o}descendToLeafNodes(e){if(!e)throw new Error("Missing ancestor!");return this.isCollapsed()?(this.start.descendToLeafNode(e),this.end.assign(this.start)):(this.start.descendToLeafNode(e),this.start.compare(this.end)>0?this.end.assign(this.start):this.moveEndToPastLastVisible(e)),this}containsLocator(e){return this.start.compare(e)<=0&&this.end.compare(e)>=0}intersect(e){return this.start.compare(e.start)<0?this.start.assign(e.start):this.start.compare(e.end)>0&&this.start.assign(e.end),this.end.compare(e.start)<0?this.end.assign(e.start):this.end.compare(e.end)>0&&this.end.assign(e.end),this}limitToNode(e){let t=i.fromNodeInner(e);return this.isInDOM()?this.intersect(t):(this.start.assign(t.start),this.end.assign(t.start),this)}getLocalRangeInNode(e){let t=this.clone(),o=i.fromNodeInner(e);return t.intersect(o),t.start.ascend(e,!1,!0),t.end.ascend(e,!1,!0),{range:t,containswholenode:t.equals(o)}}getContainedLocators(){return[this.start,this.end]}querySelectorAll(e){let t=this.clone(),o=t.getAncestorElement();if(!o)return[];t.start.ascend(o,!1,!0),t.end.ascend(o,!0,!0);let s=[];for(let n=t.start.clone();n.offset<t.end.offset;++n.offset){let l=n.getPointedNode();if(H(l,S.element))if(l.matches(e)&&s.push(l),n.offset===t.start.offset||n.offset===t.end.offset-1){let r=this.clone().intersect(i.fromNodeInner(l));s=s.concat(r.querySelectorAll(e))}else{let r=Array.from(l.querySelectorAll(e));s=s.concat(r)}}return s}toDOMRange(){return{startContainer:this.start.element,startOffset:this.start.offset,endContainer:this.end.element,endOffset:this.end.offset}}isLegal(e){return!this.start.isLegal(e)||!this.end.isLegal(e)?!1:this.start.getParentContentEditable(e)===this.end.getParentContentEditable(e)}legalize(e){this.start.legalize(e,!1),this.end.legalize(e,!0);let t=this.start.getParentContentEditable(e);return t!==this.end.getParentContentEditable(e)&&this.limitToNode(t),this}static fromSelection(e){let t=new f(e.anchorNode??j("Incomplete selection, no anchorNode"),e.anchorOffset),o=new f(e.focusNode??j("Incomplete selection, no focusNode"),e.focusOffset),s=t.compare(o)>0;return new i(s?o:t,s?t:o)}static fromDOMRange(e){return new i(new f(e.startContainer,e.startOffset),new f(e.endContainer,e.endOffset))}static fromRangyRange(e){return new i(new f(e.startContainer,e.startOffset),new f(e.endContainer,e.endOffset))}static forNode(e){return console.warn("Range.forNode is deprecated, use fromNodeInner!"),console.trace(),new i(new f(e),new f(e,"end"))}static withinNode(e){return console.warn("Range.withinNode is deprecated, use fromNodeInner!"),console.trace(),new i(new f(e),new f(e,"end"))}static fromNodeInner(e){return new i(new f(e),new f(e,"end"))}static fromNodeOuter(e){return new i(f.newPointingTo(e),f.newPointingAfter(e))}static fromLocator(e){return new i(e,e)}static getLogLevel(){return Ds}};f=class i{element;offset;constructor(e,t){if(!e)throw new Error("No valid element in locator initialize");this.element=e,this.offset=t==="end"?Hs(e):t||0}getMaxChildOffset(e){return H(e,[S.element,S.documentFragment])?e.childNodes.length:e.nodeValue?e.nodeValue.length:0}set(e,t){if(!e)throw new Error("No valid element in locator set");this.element=e,t==="end"?this.offset=this.getMaxChildOffset(e):this.offset=t||0}clone(){return new i(this.element,this.offset)}assign(e){return this.element=e.element,this.offset=e.offset,this}getPointedNode(){return this.parentIsElementOrFragmentNode()&&this.offset<this.element.childNodes.length?this.element.childNodes[this.offset]:null}getNearestNode(){return this.getPointedNode()||this.element}getNearestElement(){let e=this.getNearestNode();return e.nodeType!==1&&e.nodeType!==11?e.parentNode:e}pointsPastChildrenEnd(){return this.offset>=this.getMaxChildOffset(this.element)}getPathFromAncestor(e){let t=[],o=this.element;for(;o!==e;o=o.parentNode)t.push(o);return t.reverse()}getRelativePath(e){let t=[this.offset],o=this.element;for(;o&&o!==e;o=o.parentNode)t.unshift(Ke(o));return t}isWithinNode(e){let t=this.element;for(;t&&t!==e;)t=t.parentNode;return t===e}parentIsElementOrFragmentNode(){return this.element.nodeType===1||this.element.nodeType===11}moveToParent(e,t){if(this.pointsPastChildrenEnd())this.offset!==0&&(e=!0);else if(this.offset===0)e!=="really"&&(e=!1);else if(!t)return!1;return this.offset=Ke(this.element)+(e?1:0),this.element=this.element.parentNode,!0}ascend(e,t,o){if(!e)throw new Error("Invalid ancestor in Locator.ascend");for(;this.element!==e&&this.moveToParent(t,o);)if(!this.element)throw new Error("Locator was pointed outside the tree of ancestor");return this}descendToLeafNode(e,t){if(typeof e!="object")throw new Error("Missing ancestor!");let o=!1;if(this.element.nodeType===1||this.element.nodeType===11)if(this.offset>=this.element.childNodes.length){for(;(this.element.nodeType===1||this.element.nodeType===11)&&this.element.lastChild;)this.element=this.element.lastChild;this.positionPastLastChild(),o=!0}else for(this.offset!==0&&(this.element=this.element.childNodes[this.offset],this.offset=0);(this.element.nodeType===1||this.element.nodeType===11)&&this.element.firstChild;)this.element=this.element.firstChild;return!t&&!W(this.element)&&this.moveToParent(o),this}positionPastLastChild(){return this.offset=this.getMaxChildOffset(this.element),this}insertNode(e,t){if(!this.parentIsElementOrFragmentNode())throw new Error("Inserting only allowed when parent is a node");let o=null;if(this.offset){let l=this.element.childNodes[this.offset-1];H(l,S.element)&&l.nodeName.toLowerCase()==="br"&&l.getAttribute("_moz_editor_bogus_node")&&(o=document.createElement("br"),this.element.insertBefore(o,this.getPointedNode()),l.parentNode&&l.parentNode.removeChild(l))}let s=this.getPointedNode();this.element.insertBefore(e,s);let n=this.clone();return F(t,l=>this._correctForNodeInsert(n,l)),++n.offset,n}_correctForNodeInsert(e,t){t.element===e.element&&t.offset>=e.offset&&++t.offset}removeNode(e){if(!this.parentIsElementOrFragmentNode())throw new Error("Removing a node only allowed when parent is a node");if(this.offset>=this.getMaxChildOffset(this.element))throw new Error("Locator does not point to an element");let t=this.element.childNodes[this.offset];this.element.removeChild(t);let o=this.clone();F(e,s=>this._correctForNodeRemove(o,t,s))}_correctForNodeRemove(e,t,o){o.element===e.element&&o.offset>e.offset?--o.offset:(o.element===t||t.contains&&t.contains(o.element))&&o.assign(e)}replacePointedNode(e,t){if(!this.parentIsElementOrFragmentNode())throw new Error("Removing a node only allowed when parent is a node");if(this.offset>=this.getMaxChildOffset(this.element))throw new Error("Locator does not point to an element");
4if(!e)throw new Error("No valid new node given");let o=this.element.childNodes[this.offset];this.element.replaceChild(e,o),F(t,s=>this._correctForNodeReplace(o,e,s))}_correctForNodeReplace(e,t,o){o.element===e&&(o.element=t)}equals(e){return this.element===e.element&&this.offset===e.offset}compare(e){if(this.element===e.element)return Math.sign(this.offset-e.offset);let t=this.element.compareDocumentPosition(e.element);return t&Node.DOCUMENT_POSITION_CONTAINS?Co(e,this):t&Node.DOCUMENT_POSITION_CONTAINED_BY?Co(this,e)*-1:t&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}check(e){if(!this.element)throw new Error("Element not valid");if(e&&!e.contains(this.element))throw new Error("Element is not child of maxancestor");if(this.offset<0)throw new Error("Negative offset");if(this.offset>this.getMaxChildOffset(this.element))throw new Error("Offset too big")}isInDOM(){return!this.element.ownerDocument||!this.element.ownerDocument.documentElement?(console.warn("Element has no ownerDocument",this.element.ownerDocument,(this.element.ownerDocument||{}).documentElement),!1):this.element.ownerDocument.documentElement.contains(this.element)}getContainedLocators(){return[this]}scanBackward(e,t){if(!e)throw new Error("Missing ancestor");if(this.offset>qo(this.element))throw new Error("Illegal offset!");for(typeof t.li>"u"&&(t.li=t.blocks);;)if(this.offset===0){if(I(this.element)||this.element===e){let s=Lt(this.element);if(!t.blocks||s&&!t.alwaysvisibleblocks||this.element===e)return{type:"outerblock",data:this.element,blockboundary:!0,segmentbreak:!0,alwaysvisible:s}}this.moveToParent(!1)}else{if([3,4].includes(this.element.nodeType)){let s=(this.element.nodeValue||"").substr(this.offset-1,1),n=` \r 5`.indexOf(s)!==-1;if(!n||!t.whitespace)return{type:n?"whitespace":"char",data:s,visiblecontent:!n};--this.offset;continue}--this.offset;let o=this.getPointedNode();if(!o||!H(o,[S.element,S.text,S.cDATASection]))continue;if(H(o,S.element)&&!To(o)){if(!W(o)){if(++this.offset,o.nodeName.toLowerCase()==="br"){let r=!1;if(I(this.element)){r=!0;for(let a=this.offset,d=this.element.childNodes.length;a<d;++a){let c=this.element.childNodes[a];if(![3,4].includes(c.nodeType)||(c.nodeValue||"").trim()){r=!1;break}}}return{type:"br",data:o,segmentbreak:!0,bogussegmentbreak:r}}return{type:"node",data:o,visiblecontent:!0}}let s=I(o),n=o.nodeName.toLowerCase()==="li";if(n&&!t.li||!n&&s&&!t.blocks)return++this.offset,{type:"innerblock",data:o,blockboundary:!0,segmentbreak:!0}}this.set(this.getPointedNode(),"end")}}scanUpStream(e,t){return this.scanForward(e,t)}scanForward(e,t){if(!e.contains(this.element))throw console.log(e,this.element),new Error("Maxancestor is not ancestor of locator");for(;;)if(this.pointsPastChildrenEnd()){if(I(this.element)||this.element===e){let s=Lt(this.element);if(!t.blocks||s||this.element===e)return{type:"outerblock",data:this.element,blockboundary:!0,segmentbreak:!0,alwaysvisible:s}}this.moveToParent(!0)}else{if([3,4].includes(this.element.nodeType)){let s=(this.element.nodeValue||"").substring(this.offset,this.offset+1),n=` \r 6`.indexOf(s)!==-1;if(!n||!t.whitespace)return{type:n?"whitespace":"char",data:s,visiblecontent:!n};++this.offset;continue}let o=this.getPointedNode();if(!o)throw new Error("Could not get pointed to node");if(![1,3,4].includes(o.nodeType)){++this.offset;continue}if(H(o,S.element)&&!To(o)){if(!W(o)){let n=o.nodeName.toLowerCase()==="br";if(n){let l=n&&o.getAttribute("data-wh-rte")==="bogus";return{type:"br",data:o,segmentbreak:!0,bogussegmentbreak:l}}return{type:"node",data:o,visiblecontent:!0}}if(I(o)&&!t.blocks)return{type:"innerblock",data:o,blockboundary:!0,segmentbreak:!0}}this.set(o,0)}}movePastLastVisible(e,t,o){if(!e.contains(this.element))throw new Error("Ancestor is not ancestor of this locator");if(t)throw new Error("Stopatblock not supported for movePastLastVisible");let s=So(e,this);if(this.assign(s.down),o&&!["whitespace","char"].includes(s.downres.type)){let n=this.clone(),l=n.scanForward(e,{});["whitespace","char"].includes(l.type)&&this.assign(n)}return s.downres}moveToFirstVisible(e,t,o){if(!e.contains(this.element))throw new Error("Ancestor is not ancestor of this locator");
6if(t)throw new Error("Stopatblock not supported for moveToFirstVisible");let s=So(e,this);if(this.assign(s.up),o&&!["whitespace","char"].includes(s.upres.type)){let n=this.clone(),l=n.scanBackward(e,{});["whitespace","char"].includes(l.type)&&this.assign(n)}return s.upres}moveLeft(e,t={}){let o=this.clone(),s=this.movePastLastVisible(e);switch(s.type){case"innerblock":this.set(s.data,"end");break;case"outerblock":if(this.element!==e&&this.ascend(e,!1),s=this.scanBackward(e,{whitespace:!0}),(s.type==="node"||s.type==="innerblock")&&t.checkblock&&!t.checkblock(s.data))return this.assign(o),!1;break;case"br":case"node":--this.offset;break;case"whitespace":case"char":{--this.offset;let l=(this.element.nodeValue||"").charCodeAt(this.offset);this.offset&&l>=56320&&l<57344&&--this.offset;break}}let n=de(e,this);return n.valid?(this.assign(n.down),!0):(s=this.scanBackward(e,{blocks:!0,whitespace:!0}),s.type==="br"&&s.bogussegmentbreak&&--this.offset,this.scanForward(e,{whitespace:!0}),this.movePastLastVisible(e),!0)}moveRight(e,t={}){let o=this.clone(),s=this.moveToFirstVisible(e);if(s.type==="br"){let l=Tt(this,e);l&&(this.assign(l.end),s=this.scanForward(e,{whitespace:!0}))}switch(s.type){case"innerblock":this.set(s.data,0);break;case"outerblock":if(this.element!==e&&this.ascend(e,!0),s=this.scanForward(e,{whitespace:!0}),(s.type==="node"||s.type==="innerblock")&&t.checkblock&&!t.checkblock(s.data))return this.assign(o),!1;break;case"br":case"node":{++this.offset;break}case"whitespace":case"char":{let l=(this.element.nodeValue||"").charCodeAt(this.offset),r=l>=55296&&l<56320;++this.offset,r&&(l=(this.element.nodeValue||"").charCodeAt(this.offset),l>=56320&&l<57344&&++this.offset);break}}let n=de(e,this);return n.valid?(this.assign(n.up),!0):(this.scanForward(e,{blocks:!0,whitespace:!0}),this.scanBackward(e,{whitespace:!0}),this.movePastLastVisible(e),!0)}moveToPreviousBlockBoundary(e,t){for(;;)if(this.parentIsElementOrFragmentNode()||(this.offset=0),this.offset===0){if(this.element===e||I(this.element))return{type:"outerblock",data:this.element,blockboundary:!0};this.moveToParent(!1)}else{--this.offset;let o=this.getPointedNode();if(!o)throw new Error("Could not find pointed to node");if(o.nodeType!==1||!W(o)||t)continue;if(I(o))return++this.offset,{type:"innerblock",data:o,blockboundary:!0};this.element=o,this.positionPastLastChild()}}moveToNextBlockBoundary(e,t){for(;;)if(this.parentIsElementOrFragmentNode()||this.positionPastLastChild(),this.pointsPastChildrenEnd()){if(this.element===e||I(this.element))return{type:"outerblock",data:this.element,blockboundary:!0};this.moveToParent(!0)}else{let o=this.getPointedNode();if(!o)throw new Error("No pointed node found");if(o.nodeType!==1||!W(o)||t){++this.offset;continue}if(I(o))return{type:"innerblock",data:o,blockboundary:!0};this.element=o,this.offset=0}}isLegal(e){let t=this.element;for(;t;){if(!W(t))return!1;if(t===e)return!0;t=t.parentNode}return!1}getParentContentEditable(e){let t=this.element;for(;t&&t!==e;t=t.parentNode)if(!t.parentNode||!t.parentNode.isContentEditable)return t;return e}legalize(e,t){let o=this.element;for(;o&&o!==e;)!W(o)&&o&&this.ascend(o.parentNode,t,!0),o=o.parentNode}static findCommonAncestor(e,t){return _o(e.element,t.element)}static findCommonAncestorElement(e,t){let o=_o(e.element,t.element);return[3,4].includes(o.nodeType)&&(o=o.parentNode),o}static getFromRange(e){return e?{start:new i(e.startContainer,e.startOffset),end:new i(e.endContainer,e.endOffset)}:null}static newPointingTo(e){return new i(e.parentNode,Ke(e))}static newPointingAfter(e){let t=i.newPointingTo(e);return++t.offset,t}static fromRelativePath(e,t){let o=t.pop(),s=e;for(let n=0;n<t.length;++n)s=s.childNodes[t[n]];return new i(s,o)}}});function Mt(i){for(let e of R(i,"tr")){let t=!!e.querySelector("th[scope=row]");e.classList.toggle("wh-rtd--hasrowheader",t);let o=!!e.querySelector("th[scope=col]");e.classList.toggle("wh-rtd--hascolheader",o)}}function Ze(i){return{x:i.offsetWidth,y:i.offsetHeight}}function G(i){return i.tBodies[0]?Array.from(i.tBodies[0].rows):[]}function Vo(i){let e=[];
6return G(i).forEach(t=>e.push(...Array.from(t.cells))),e}function It(i){let e=i.querySelector("colgroup");return e?Array.from(e.children):[]}function se(i,e,t){let o=[],s=0;for(let n of G(i)){let l=0;for(let r of Array.from(n.children)){for(;(o[l]||0)>s;)++l;let a=r.colSpan,d=r.rowSpan;e&&e(r,s,l);for(let c=0;c<a;++c)o[l++]=s+d}for(;(o[l]||0)>s;)++l;t&&t(n,s,l),++s}}function tt(i){let e=0,t=0;return se(i,(o,s,n)=>{let l=s+o.rowSpan,r=n+o.colSpan;l>e&&(e=l),r>t&&(t=r)}),{rows:e,cols:t}}function Se(i){let e=0,t=0,o=tt(i);return se(i,(s,n,l)=>{s.nodeName.toUpperCase()==="TH"&&(n+s.rowSpan===o.rows&&e<l+s.colSpan&&(e=l+s.colSpan),l+s.colSpan===o.cols&&t<n+s.rowSpan&&(t=n+s.rowSpan))}),e===o.cols&&t===o.rows&&(o.cols===1?t=0:e=0),{row:t,col:e}}function Te(i){let e=tt(i);se(i,null,(t,o,s)=>{for(;s++<e.cols;)t.appendChild(E("td",{class:"wh-rtd__tablecell"}))})}function le(i){return i.propWhTableEditor||null}function Wo(i){R(i,"div.wh-tableeditor-resize-holder").forEach(e=>{R(e.firstChild,"tfoot.wh-tableeditor-resize-columns").forEach(t=>t.remove()),e.parentNode.insertBefore(e.firstChild,e),e.remove()}),R(i,".wh-rtd__table").forEach(e=>e.removeAttribute("style")),R(i,".wh-rtd__table > colgroup").forEach(e=>e.removeAttribute("class")),R(i,".wh-rtd__table tr[style]").forEach(e=>e.removeAttribute("style"))}var $e,et,ot=T(()=>{"use strict";V();V();Ao();ee();$e=[];et=class{constructor(e,t,o){if(this.node_win=null,this.resizeholder=null,this.columns=null,this.colgroup=null,this.numcolumns=0,this.numrows=0,this.resizers=[],this.resizing=null,this.node=e,this.node.nodeName.toUpperCase()!=="TABLE")throw new Error("TableEditor can only be used on table nodes");this.node_win=e.ownerDocument.window,this.containernode=t,this.options={resizer_size:9,placeholder_size:5,resize_columns:!0,resize_rows:!0,resize_table:!0,...o},this.node.propWhTableEditor=this,this.node.classList.add("wh-rtd__table"),Te(this.node),this.reset(),$e.push(this)}reset(){if(this.cleanup(),!this.node||!this.options.resize_columns&&!this.options.resize_rows)return;if(this.numcolumns=0,this.options.resize_columns){this.columns&&this.columns.remove(),this.columns=v("tfoot",{className:"wh-tableeditor-resize-columns",childNodes:[v("tr")]}),this.node.appendChild(this.columns);for(let n of Array.from(this.node.rows[0].cells))for(let l=0;l<n.colSpan;++l){let r=v("td",{style:{borderWidth:"0",fontSize:"0",height:"0",lineHeight:"0",margin:"0",outline:"none",padding:0}});this.columns.lastChild.appendChild(r)}this.numcolumns=this.columns.lastChild.childNodes.length}else Array.from(G(this.node)[0].cells).forEach(n=>{this.numcolumns+=n.colSpan});let e=[];for(let n=0;n<this.numcolumns;++n)e.push(0);let t=G(this.node);this.numrows=t.length,t.forEach((n,l)=>{let r=Array.from(n.cells),a=0,d=0;for(;a<this.numcolumns;)if(e[a]>0)--e[a++];else{r[d].propWhPos={row:l,col:a};for(let c=0;c<r[d].colSpan;++c)e[a++]=r[d].rowSpan-1;this.options.resize_columns&&a<this.numcolumns&&this._createResizer(r[d],"col",a-1),this.options.resize_rows&&l+r[d].rowSpan<this.numrows?this._createResizer(r[d],"row",l+r[d].rowSpan-1):this.options.resize_rows&&this.options.resize_table&&a===1&&l+r[d].rowSpan===this.numrows&&this._createResizer(r[d],"row",-1),++d}this.options.resize_columns&&this.options.resize_table&&l===0&&this._createResizer(r[d-1],"col",-1)});let o;this.options.resize_columns&&(o=this._getCurrentWidths());let s=this.node.querySelector("colgroup");if(s){let n=Array.from(s.querySelectorAll("col"));for(let l=0;l<n.length&&l<o.length;++l){let r=parseInt(n[l].style.width);r&&(o[l]=Math.max(o[l],r))}}if(this.options.resize_rows&&G(this.node).forEach(n=>{n.style.height=n.offsetHeight+"px",Array.from(n.cells).forEach(l=>{this.options.resize_columns&&(l.removeAttribute("width"),l.style.width=""),this.options.resize_rows&&(l.removeAttribute("height"),l.style.height="")})}),this.options.resize_columns){for(s!==this.colgroup&&s.remove(),this.colgroup||(this.colgroup=E("colgroup",{class:"wh-tableeditor-colgroup"})),this.ensureColGroupInserted();this.colgroup.childNodes.length>this.numcolumns;)this.colgroup.lastChild.remove();for(;this.colgroup.childNodes.length<this.numcolumns;)this.colgroup.appendChild(E("col",null));this._applyColumnWidths(o)}this.resizeholder=E("div",{class:"wh-tableeditor-resize-holder",style:"position:absolute"}),this.containernode.before(this.resizeholder),this.resizeholder.append(...this.resizers),this.updateResizers()}cleanup(){this.columns&&(this.columns.remove(),this.columns=null),this.resizeholder&&(this.resizeholder.remove(),this.resizeholder=null,this.resizers=[]);let e=$e.indexOf(this);e>=0&&$e.splice(e,1)}isActive(){return!!this.node.parentNode&&this.node.isContentEditable}destroy(){this.cleanup(),this.colgroup=null,this.node.propWhTableEditor=null,this.node=null}getUndoLock(){return this.options.getUndoLock?this.options.getUndoLock():null}insertColumns(e,t,o,s,n){if(e.closest("table")!==this.node)return;let r=this.getUndoLock(),a=e.propWhPos.col;t||(a+=e.colSpan-1),this._insertColumnsAt("test",a,t,o,s,n||{}),this.reset(),this._gotStateChange(),r.close()}insertRows(e,t,o,s,n){if(e.closest("table")!==this.node)return;let r=this.getUndoLock(),a=e.propWhPos.row;t||(a+=e.rowSpan-1),this._insertRowsAt(a,t,o,s,n||{}),this.reset(),this._gotStateChange(),r.close()}deleteColumns(e,t){if(e.closest("table")!==this.node)return;let s=this.getUndoLock(),n=e.propWhPos.col;this._deleteColumns(n,t),this.reset(),this._gotStateChange(),s.close()}deleteRows(e,t){if(e.closest("table")!==this.node)return;let s=this.getUndoLock(),n=e.propWhPos.row;this._deleteRows(n,t),this.reset(),this._gotStateChange(),s.close()}_applyNewStyle(e,t){let o=Object.keys(t),s=e.__wh_oldstyle;s||(s=e.__wh_oldstyle={});for(let n=0,l=o.length;n<l;++n){let r=o[n],a=t[r];s[r]!==a&&(e.style[r]=a,s[r]=a)}}updateResizers(){if(!this.resizeholder)return;let e=Ne(this.node,this.containernode);e.top+=this.containernode.offsetTop,e.left+=this.containernode.offsetLeft,this.resizeholder.style.top=e.top+"px",this.resizeholder.style.left=e.left+"px",this.resizers.forEac
6h(function(o){let s=o.myTdNode,n={height:s.offsetHeight,width:s.offsetWidth,left:s.offsetLeft,right:s.offsetLeft+s.offsetWidth,top:s.offsetTop,bottom:s.offsetTop+s.offsetHeight};if(o.classList.contains("wh-tableeditor-resize-col")){let l={height:n.height+1+"px",left:n.right+"px",marginLeft:-Math.floor(this.options.resizer_size/2)+"px",top:n.top+"px",width:this.options.resizer_size+"px",zIndex:1};this.options.resize_table&&o.classList.contains("wh-tableeditor-resize-table")&&(l.height=e.height+"px"),this._applyNewStyle(o,l)}else if(o.classList.contains("wh-tableeditor-resize-row")){let l={height:this.options.resizer_size+"px",left:n.left+"px",top:n.bottom+"px",marginTop:-Math.floor(this.options.resizer_size/2)+"px",width:n.width+1+"px",zIndex:2};this.options.resize_table&&o.classList.contains("wh-tableeditor-resize-table")&&(l.width=e.width+"px"),this._applyNewStyle(o,l)}},this),this.options.resize_columns&&setTimeout(()=>{this.node&&(this.ensureColGroupInserted(),this.columns.remove())},1)}getCaptionNode(){return this.node.firstElementChild?.tagName==="CAPTION"?this.node.firstElementChild:null}ensureColGroupInserted(){if(this.colgroup.parentNode!==this.node){let e=this.getCaptionNode();e?e.after(this.colgroup):this.node.prepend(this.colgroup)}}locateFirstDataCell(e){return Se(this.node)}setFirstDataCell(e,t){let o=!1;se(this.node,function(s,n,l){let r=n<e,a=l<t,d=r!==a?"th":"td";if(s.nodeName.toLowerCase()!==d){let c=document.createElement(d);Qe(c,Bo(s));let u=Array.from(s.childNodes);for(let h=0;h<u.length;++h)c.appendChild(u[h]);s.parentNode.replaceChild(c,s),s.remove(),s=c,o=!0}s.setAttribute("scope",d==="td"?"":r?"col":"row")}),Mt(this.node),o&&this._gotStateChange(),this.reset()}setStyleTag(e){this.node.className=e+" wh-rtd__table"}getCaption(){return this.getCaptionNode()?.textContent||""}setCaption(e){if(!e){this.getCaptionNode()?.remove();return}let t=this.getCaptionNode();t||(t=E("caption",{class:"wh-rtd__tablecaption",contenteditable:"false",inert:!0}),this.node.prepend(t)),t.textContent=e}getActionState(e){let t=this._getSplitMergeData(e);return{"table-deleterow":{available:this.numrows!==1},"table-deletecolumn":{available:this.numcolumns!==1},"table-mergeright":{available:!!t.mergerightcells},"table-mergedown":{available:!!t.mergedowncells},"table-splitcols":{available:e.colSpan!==1},"table-splitrows":{available:e.rowSpan!==1}}}mergeRight(e){let t=this.getUndoLock(),s=this._getSplitMergeData(e).mergerightcells;for(let n of s)e.append(...Array.from(n.childNodes));e.colSpan+=s[0].colSpan;for(let n of s)n.remove();this.reset(),this._gotStateChange(),t.close()}mergeDown(e){let t=this.getUndoLock(),s=this._getSplitMergeData(e).mergedowncells;for(let n of s)e.append(...Array.from(n.childNodes));e.rowSpan+=s[0].rowSpan;for(let n of s)n.remove();this.reset(),this._gotStateChange(),t.close()}splitCols(e){let t=this.getUndoLock(),o=[];for(let s=1;s<e.colSpan;++s){let n=document.createElement(e.nodeName);n.rowSpan=e.rowSpan,o.push(n)}e.colSpan=1,e.after(...o),this.reset(),this._gotStateChange(),t.close()}splitRows(e){let t=this.getUndoLock(),o=this._getSplitMergeData(e);e.rowSpan=1;for(let s of o.splitappends){let n=document.createElement(e.nodeName);n.colSpan=e.colSpan,s.td?s.td.after(n):s.tr.prepend(n)}this.reset(),this._gotStateChange(),t.close()}_getSplitMergeData(e){let t=null,o=0,s=0,n=[],l=[],r=[],a=null;return se(this.node,(d,c,u)=>{d===e?t={row:c,col:u,limitrow:c+d.rowSpan,limitcol:u+d.colSpan}:t&&(u<t.col&&c<t.limitrow&&(a=d),u===t.limitcol&&c<t.limitrow&&(n.push(d),o?o!==u+d.colSpan&&(o=-1):o=u+d.colSpan,c+d.rowSpan>t.limitrow&&(o=-1),e.nodeName!==d.nodeName&&(o=-1)),c===t.limitrow&&u>=t.col&&u<t.limitcol&&(l.push(d),s?s!==c+d.rowSpan&&(s=-1):s=c+d.rowSpan,u+d.colSpan>t.limitcol&&(s=-1),e.nodeName!==d.nodeName&&(s=-1)))},(d,c)=>{t&&c>t.row&&c<t.limitrow&&r.push({tr:d,td:a}),a=null}),{mergerightcells:o>0?n:null,mergedowncells:s>0?l:null,splitappends:r}}_gotStateChange(){this.options.onStatechange&&this.options.onStatechange(this)}_createResizer(e,t,o){let s=o<0,n=document.createElement("div");n.className="wh-tableeditor-resize-"+t+(s?" wh-tableeditor-resize-table":""),n.style.cursor=t+"-resize",Eo(n),n.addEventListener("dompack:movestart",l=>this._onResize(l)),n.addEventListener("dompack:move",l=>this._onResizing(l)),n.addEventListener("dompack:moveend",l=>this._onResized(l)),n.contentEditable="false",n.myTdNode=e,s||(n[t==="col"?"propWhCol":"propWhRow"]=o),this.resizers.push(n)}_applyColumnWidths(e){let t=1;e.forEach(function(s){t+=s}),this.node.style.width=t+"px",It(this.node).forEach(function(s,n){s.style.width=e[n]+"px"},this)}_getCurrentWidths(e){this.node.appendChild(this.columns);let t=Array.from(this.columns.rows[0].cells).map(o=>o.offsetWidth);return this.columns.remove(),t}_getSizes(){let e=Ze(this.node),t=v("div");this.node.before(t);let o=Ze(t),s=this.node.offsetLeft-t.offsetLeft;return o.x-=s,t.remove(),{cursize:e,maxsize:o}}_resizeColumns(e,t){let o=this._getCurrentWidths();e<0&&(e=o.length+e);let s=e===o.length-1;if(s){let{cursize:d,maxsize:c}=this._getSizes(),u=c.x-d.x;t=Math.min(u,t)}let n=s?-1:e+1,l=-1,r=-1;t<0?(l=e,r=n,t=-t):(l=n,r=e);let a=t;if(l!==-1){let d=[...o];t>d[l]-8&&(t=d[l]-8),d[l]-=t,d[l]<1&&(d[l]=1),this._applyColumnWidths(d),d=this._getCurrentWidths(),a=o[l]-d[l]}l!==-1&&(o[l]-=a),r!==-1&&(o[r]+=a),this._applyColumnWidths(o),this._gotStateChange(),this.updateResizers()}_insertColumnsAt(e,t,o,s,n,l){if(t<0||t>=this.numcolumns||s<=0)return;Te(this.node);let r=Se(this.node);
6if(this.colgroup){let d=this.colgroup.childNodes[t];for(let c=0;c<s;++c){let u=v("col",{style:{width:n+"px"}});o?d.before(u):d.after(u)}}let a=[];for(let d=0;d<this.numcolumns;++d)a.push(0);G(this.node).forEach(function(d,c){let u=Array.from(d.cells),h=0,m=0;for(;h<=t;)if(a[h]>0)--a[h++];else{for(let p=1;h<=t&&p<=u[m].colSpan;++p){if(h===t)if(o&&p>1&&p<=u[m].colSpan||!o&&p>=1&&p<u[m].colSpan)u[m].colSpan+=s;else for(let k=0;k<s;++k){let N=h<r.col!=c<r.row?"th":"td",b=v(N,{rowSpan:u[m].rowSpan});o?u[m].before(b):u[m].after(b),l.newcell_callback&&l.newcell_callback(b)}a[h++]=u[m].rowSpan-1}++m}},this),this.numcolumns+=s,this.node.style.width="auto",this.reset()}_insertRowsAt(e,t,o,s,n){if(e<0||e>=this.numrows||o<=0)return;Te(this.node);let l=Se(this.node),r=[];se(this.node,(u,h,m)=>{let p=h+u.rowSpan;if(h<=e&&p>e){let k=t?h<e:p>e+1;r.push({td:u,col:m,extendcell:k})}}),r.sort((u,h)=>u.col-h.col);let a=[];for(let u=0;u<o;++u)a.push(v("tr"));let d=G(this.node)[e];t?d.before(...a):d.after(...a);let c=e+(t?0:1);for(let u of a){for(let h of r)if(h.extendcell)++h.td.rowSpan;else{let m=h.col<l.col!=c<l.row?"th":"td",p=v(m);h.td.colSpan>1&&(p.colSpan=h.td.colSpan),u.appendChild(p),n.newcell_callback&&n.newcell_callback(p)}++c}this.numrows+=o,this.reset()}_removeRange(e,t,o,s,n){let l=n-s;return t>s&&(t=t>n?t-l:s),o>s&&(o=o>n?o-l:s),{node:e,start:t,end:o,span:o-t}}_deleteColumns(e,t){let o=e+t;if(e<0||t<0||o>this.numcolumns)return;Te(this.node);let s=[];se(this.node,(function(n,l,r){s.push(this._removeRange(n,r,r+n.colSpan,e,o))}).bind(this)),s.forEach(function(n){n.span?n.node.colSpan=n.span:n.node.remove()}),Array.from(this.colgroup.childNodes).slice(e.num).forEach(function(n){n.remove()}),this.numcolumns-=t,this.reset()}_deleteRows(e,t){let o=e+t;if(e<0||t<0||o>this.numrows)return;Te(this.node);let s=[];se(this.node,(function(r,a){s.push(this._removeRange(r,a,a+r.rowSpan,e,o))}).bind(this));let n=G(this.node),l=n.splice(e,t);s.forEach(function(r){r.span?(r.node.rowSpan=r.span,n[r.start].appendChild(r.node)):r.node.remove()}),l.forEach(r=>r.remove()),this.numrows-=t,this.reset()}_onResize(e){e.stopPropagation();let t=e.detail.listener,o=t.classList.contains("wh-tableeditor-resize-col")?"col":t.classList.contains("wh-tableeditor-resize-row")?"row":null;if(!o){e.preventDefault();return}let s=o==="col",n=t.classList.contains("wh-tableeditor-resize-table"),{cursize:l,maxsize:r}=this._getSizes(),a={x:n?r.x:l.x,y:n?Number.MAX_VALUE:l.y},d={x:parseInt(t.style.left),y:parseInt(t.style.top)},c=v("div",{className:"wh-tableeditor-resize-placeholder",style:{height:(s?l.y:this.options.placeholder_size)+"px",left:(s?d.x:0)+"px","margin-left":(s?-Math.floor(this.options.placeholder_size/2):0)+"px",position:"absolute",top:(s?0:d.y)+"px","margin-top":(s?0:-Math.floor(this.options.placeholder_size/2))+"px",width:(s?this.options.placeholder_size:l.x)+"px","z-index":3}});this.resizeholder.appendChild(c),this.resizing={orgpos:d,maxpos:a,resizer:t,placeholder:c,colresize:s,tableresize:n}}_onResizing(e){e.stopPropagation(),this.resizing.colresize?this.resizing.placeholder.style.left=Math.max(Math.min(this.resizing.orgpos.x+e.detail.movedX,this.resizing.maxpos.x-this.options.placeholder_size),8)+"px":this.resizing.placeholder.style.top=Math.max(Math.min(this.resizing.orgpos.y+e.detail.movedY,this.resizing.maxpos.y-this.options.placeholder_size),8)+"px"}_onResized(e){e.stopPropagation(),this.resizing.placeholder.remove();let t=this.getUndoLock();if(this.resizing.tableresize)if(this.resizing.colresize){let o=Math.min(e.detail.movedX,this.resizing.maxpos.x-this.resizing.orgpos.x);this._resizeColumns(-1,o)}else{let o=G(this.node).at(-1);o.style.height=Math.max(parseInt(o.style.height)+e.detail.movedY,0)+"px";let s=Ze(o).y;o.style.height=s+"px",this.updateResizers()}else if(this.resizing.colresize){let o=this.resizing.resizer.propWhCol;this._resizeColumns(o,e.detail.movedX)}else{let o=this.resizing.resizer.propWhRow,s=e.detail.movedY<0?o:o+1,n=e.detail.movedY<0?o+1:o,l=e.detail.movedY;l<0&&(l=-l);let r=G(this.node),a=r[s],d=r[n],c=parseInt(a.style.height)+parseInt(d.style.height);a.style.height=Math.max(parseInt(a.style.height)-l,0)+"px";let u=Ze(a).y;a.style.height=u+"px",d.style.height=c-u+"px",this.updateResizers()}this.resizing=null,t.close()}};document.addEventListener("load",function(i){i.target&&i.target.nodeName==="LINK"&&i.target.rel==="stylesheet"&&$e.forEach(e
6=>e.updateResizers())},!0)});function Ot(i){let e=i.__node;if(e.matches("a"))return{type:"hyperlink",link:e.getAttribute("href")||"",target:e.target||"",__node:e};if(e.matches("td,th,caption")){let t=e.closest("table"),o=le(t),s={tablecaption:o.getCaption(),tablestyletag:t.classList[0],numrows:o.numrows,numcolumns:o.numcolumns,datacell:o.locateFirstDataCell()};return e.matches("td,th")?s={...s,type:"cell",cellstyletag:e.classList[1]||"",__node:e}:s={...s,type:"table",__node:t},s}else{if(e.matches(".wh-rtd-embeddedobject"))return{type:"embeddedobject",instanceref:e.dataset.instanceref,__node:e};if(e.matches("img")){let t=e.classList.contains("wh-rtd__img--floatleft")?"left":e.classList.contains("wh-rtd__img--floatright")?"right":"",o=null,s=e.closest("a");return s&&(o={link:s.href,target:s.target||""}),{type:"img",align:t,width:Number(e.getAttribute("width")),height:Number(e.getAttribute("height")),alttext:e.alt,link:o,src:e.src,__node:e}}}return null}function Dt(i,e,t){if(e=e.trim(),t=t.trim(),e!=="")for(let o of e.split(" "))o!==""&&i.classList.remove(o);if(t!=="")for(let o of t.split(" "))o!==""&&i.classList.add(o)}function Ko(i){let e=i.dataset.innerhtmlContents||"";if(!e){let t=i.querySelector(".wh-rtd-embeddedobject__preview");t&&(e=t.innerHTML)}return{type:"embeddedobject",instanceref:i.getAttribute("data-instanceref")||"",htmltext:e,typetext:i.getAttribute("data-widget-typetext")||"",canedit:i.classList.contains("wh-rtd-embeddedobject--editable"),canwrite:i.hasAttribute("data-writable"),embedtype:i.nodeName==="SPAN"?"inline":"block",wide:i.hasAttribute("data-widget-wide")}}function Qo(i,e){let t=i.embedtype==="inline",o=t?"span":"div",s=/wh-rtd__inlinepreview/.exec(i.htmltext),n=document.createElement(o);n.className="wh-rtd-embeddedobject"+(i.canedit?" wh-rtd-embeddedobject--editable":"")+(i.canwrite?" wh-rtd-embeddedobject--writable":"")+(i.wide?" wh-rtd-embeddedobject--wide":"")+(t?" wh-rtd-embeddedobject--inline":" wh-rtd-embeddedobject--block")+(s?" wh-rtd-embeddedobject--hasinlinepreview":""),n.dataset.instanceref=i.instanceref,n.contentEditable="false";let l=document.createElement(o);l.className="wh-rtd-embeddedobject__box",n.appendChild(l);let r=null;i.typetext&&(r=document.createElement(o),r.className="wh-rtd-embeddedobject__typebox",r.innerHTML=i.typetext);let a=document.createElement(o);a.className="wh-rtd-objectbuttons";let d=document.createElement(o);d.className="wh-rtd-embeddedobject__stickyheader",r&&d.appendChild(r),d.appendChild(a),l.appendChild(d);let c=document.createElement(o);if(c.className="wh-rtd-embeddedobject__preview",c.innerHTML=i.htmltext,l.appendChild(c),!t){let h=document.createElement(o);h.className="wh-rtd-navabovebutton",h.setAttribute("data-rte-subaction","navabove"),a.appendChild(h);let m=document.createElement(o);m.className="wh-rtd-navunderbutton",m.setAttribute("data-rte-subaction","navunder"),a.appendChild(m)}if(e.editembeddedobjects){let h=document.createElement(o);h.className="wh-rtd-editbutton",h.setAttribute("data-rte-subaction","edit"),a.appendChild(h)}let u=document.createElement(o);return u.className="wh-rtd-deletebutton",u.setAttribute("data-rte-subaction","delete"),a.appendChild(u),n}function Yo(i){let e=i.cloneNode(!0);return Ye(e).forEach(t=>{t.contentEditable="inherit",t.replaceChildren();for(let o of t.classList)["wh-rtd-embeddedobject","wh-rtd-embeddedobject--inline","wh-rtd-embeddedobject--block"].includes(o)||t.classList.remove(o)}),Wo(e),R(e,"*[tabindex], *[todd-savedtabindex]").forEach(t=>{t.removeAttribute("tabindex"),t.removeAttribute("todd-savedtabindex")}),e.innerHTML}var xe=T(()=>{"use strict";ot();V();ee()});var y,Re=T(()=>{"use strict";ee();y=Y});function Be(i,e){if(!i)return"";i+=e||0;let t=` 7`;for(;--i;)t+=" ";return t}function _(i,e,t){typeof t=="number"||typeof t=="boolean"?t={indent:!!t}:t=t||{};let o={},s=t?.indent?1:0;for(let[l,r]of Object.entries(e))if(r&&typeof r=="object"){if("element"in r)o[l]=r;else if("nodeType"in r)o[l+"#elt"]=new f(r),o[l+"#elt"].moveToParent();else for(let[a,d]of Object.entries(r))if(d&&typeof d=="object")if("element"in d)o[l+"."+a]=d;else if("nodeType"in d)o[l+"."+a+"#elt"]=new f(d),o[l+"."+a+"#elt"].moveToParent();else for(let[c,u]of Object.entries(d))u&&typeof u=="object"&&("element"in u?o[l+"."+a+"."+c]=u:"nodeType"in u&&(o[l+"."+a+"."+c+"#elt"]=new f(u),o[l+"."+a+"."+c+"#elt"].moveToParent()))}if(!i){let l,r;for(let d of Object.keys(o)){let c=o[d];(!l||l.compare(c)>0)&&(l=c),(!r||r.compare(c)<0)&&(r=c)}if(!l||!r)throw new Error("No locators provided");
7i=new y(l,r).getAncestorElement()}let n="";if(i.parentNode){let l=i.parentNode;for(let r in o)o[r].element===l&&o[r].offset<l.childNodes.length&&l.childNodes[o[r].offset]===i&&(n+=Xo(r,o[r]))}if(n&&(n+=Be(s)),n=n+Ht(i,o,s),t.title&&(n=t.title+" "+n),t.colorize){n=["%c"+n.replace(/\(#/g,"%c(#").replace(/#\)/g,")%c")];for(let l=0,r=n[0].split("%c").length-1;l<r;++l)n.push(l%2===0?"color:black;":"color:red;")}return n}function Xo(i,e){return"(#"+i+(e.id?"$"+e.id+(e.cc?"/"+e.cc:""):"")+"#)"}function he(i,e,t,o,s){let n="";for(let l in i)i[l].element===e&&i[l].offset===t&&(n+=Xo(l,i[l]));return n&&o&&(n=Be(o,s)+n),n}function Ht(i,e,t){if(!i)return"<undefined>";let o="";if(i.nodeType===11||i.nodeType===9){for(let s=0;s<i.childNodes.length;++s)s!==0&&!t&&(o+=" "),o+=he(e,i,s,t),o+=Be(t),o+=Ht(i.childNodes[s],e,t&&t+1);return o+=he(e,i,i.childNodes.length,t),o}if(i.nodeType===1){o+="<"+K(i.nodeName,"attribute");for(let n=0;n<i.attributes.length;++n){let l=String(i.attributes[n].value||i.attributes[n].nodeValue||"");if(l){let r=String(i.attributes[n].nodeName);if(l.substr(0,9)==="function (")continue;o+=" "+K(r,"attribute")+'="'+K(l,"attribute")+'"'}}i._xtest&&(o+=":"+i._xtest),o+=">";let s="";for(let n=0;n<i.childNodes.length;++n)n!==0&&!t&&(s+=" "),s+=he(e,i,n,t,1),s+=Be(t,1),s+=Ht(i.childNodes[n],e,t&&t+1);return s+=he(e,i,i.childNodes.length,t,1),o+=s,s&&(o+=Be(t)),o+"</"+K(i.nodeName,"attribute")+">"}if(i.nodeType===3||i.nodeType===4||i.nodeType===8){i.nodeType===3&&(o+="#text:"),i.nodeType===4&&(o+="#cdata:"),i.nodeType===8&&(o+="#comment:"),i._xtest&&(o+=i._xtest+":");let s="",n=i.nodeValue;for(let r=0;r<n.length;++r)s+=he(e,i,r),s+=n.substr(r,1);s+=he(e,i,n.length);let l=unescape(escape(K(s,"attribute")).split("%u").join("\\u").split("%A0").join("\\u00A0"));return o+='"'+l+'"',o}return i.nodeName}var Ft=T(()=>{"use strict";ee();Ue();Re()});function Zs(i){let e=i.target;e&&(g.scm&&console.log("[scm] SCROLL ",e,` to ${e.scrollLeft},${e.scrollTop}`),zt(e))}function $s(){let i=Me;Me=[];for(let e of i)g.scm&&console.log(`[scm] Delayed resetting scroll from ${e.node.scrollLeft},${e.node.scrollTop} to ${e.left},${e.top} for `,e.node),e.node.scrollLeft=e.left+1,e.node.scrollLeft=e.left,e.node.scrollTop=e.top}function es(i){if(z()==="firefox"){if(Me.length===0)requestAnimationFrame($s);else if(Me.find(e=>e.node===i))return;Me.push({node:i,top:parseFloat(i.dataset.dompackSavedScrollTop||""),left:parseFloat(i.dataset.dompackSavedScrollLeft||"")})}else g.scm&&console.log(`[scm] Resetting scroll from ${i.scrollLeft},${i.scrollTop} to ${i.dataset.dompackSavedScrollLeft},${i.dataset.dompackSavedScrollTop} for `,i),i.scrollLeft=parseFloat(i.dataset.dompackSavedScrollLeft||""),i.scrollTop=parseFloat(i.dataset.dompackSavedScrollTop||"");return!0}function en(i){g.scm&&console.log("[scm] FOCUS",i,i.scrollTop,i.dataset.dompackSavedScrollTop),es(i)}function tn(i){if(i.scrollTop===parseFloat(i.dataset.dompackSavedScrollTop||"")&&i.scrollLeft===parseFloat(i.dataset.dompackSavedScrollLeft||""))return!1;es(i)}function zt(i){i.dataset.dompackSavedScrollTop===void 0&&(g.scm&&console.log("[scm] Starting to record scroll positions for ",i),i.classList.add("dompack--scrollmonitor"),i.addEventListener("focus",()=>en(i),!0)),i.dataset.dompackSavedScrollTop=String(i.scrollTop),i.dataset.dompackSavedScrollLeft=String(i.scrollLeft)}var Me,nt,ts=T(()=>{"use strict";qe();V();Me=[];nt=class{node;constructor(e){this.node=e,this.node.addEventListener("scroll",t=>Zs(t),!0)}fixupPositions(){g.scm&&console.log("[scm] FixupPositions()",this.node);for(let e of this.node.querySelectorAll(".dompack--scrollmonitor"))tn(e)}}});var os=T(()=>{});var it,ss=T(()=>{"use strict";V();os();it=class{node;options;constructor(e){this.options={enabled:!0,pressed:!1,...e},this.node=E("div",{class:["wh-toolbar-button",...this.options.classNames||[]].join(" "),title:this.options.hint}),this.node.addEventListener("click",()=>this.executeAction()),this.options.icon&&(this.options.icon.classList.add("wh-toolbar-button-img"),this.node.appendChild(this.options.icon)),this.options.label&&this.node.appendChild(E("span",null,this.options.label)),this.options.enabled||this.node.classList.add("disabled"),this.options.pressed&&this.node.classList.add("pressed"),this.options.onExecute&&this.node.addEventListener("execute",this.options.onExecute)}executeAction(){this.options.enabled&&B(this.node,"execute",{bubbles:!1,cancelable:!1})}setEnabled(e){e=!!e,e!==this.options.enabled&&(this.options.enabled=e,this.node.classList.toggle("disabled",!this.options.enabled))}setPressed(e){e=!!e,e!==this.options.pressed&&(this.options.pressed=e,this.node.classList.toggle("pressed",this.options.pressed))}}});var ns=T(()=>{});function nn(){dt=[]}function Ut(i){let e=[];for(;i;i=i.parentNode)e.push(i);return e}function fe(i){if(i.target){let e=C.find(t=>t.isInMenu(i.target));if(g.men&&console.log("[men] globalMouseDown handler captured mousedown (semifocus) and detected menu: ",e,i),e)return!0}me()}function is(i){let e=Le(i);if(e.key.match(/^F.+/)||(e.ctrlKey||e.altKey||e.metaKey)&&!e.key.match(/^(Control$|Alt$|Meta$|Shift$|Arrow)/)){me(
7);return}if(e.key==="Escape"){me(),i.preventDefault(),i.stopPropagation();return}for(let t=C.length-1;t>=0;--t)if(C[t]._handleKey(i,t===0)){g.men&&console.log("[men] globalKeyDown handler captured keyboard event that was handled by a menu, cancelling the event",C[t],i),i.stopPropagation(),i.preventDefault();return}if(!re)return!0;i.stopPropagation(),i.preventDefault()}function ct(){Pe&&clearTimeout(Pe),Pe=null}function ls(){re||(g.men&&console.log("[men] takeSemiFocus"),ct(),re=!0)}function ln(){g.men&&console.log("[men] releaseSemiFocus"),re=!1}function rn(i){X.indexOf(i)===-1&&X.push(i),ct()}function qt(i,e){let t=C.indexOf(i);e!==(t!==-1)&&(e?C.push(i):C.splice(t,1),C.length===(e?1:0)&&(e?(window.addEventListener("mousedown",fe,!0),window.addEventListener("keydown",is,!0),document.activeElement?.nodeName==="IFRAME"&&(document.activeElement.blur(),(!document.activeElement||document.activeElement.nodeName==="IFRAME")&&window.focus()),window.addEventListener("blur",fe,!1),window.addEventListener("touchstart",fe,!0)):(window.removeEventListener("mousedown",fe,!0),window.removeEventListener("keydown",is,!0),window.removeEventListener("blur",fe,!1),window.removeEventListener("touchstart",fe,!0),ct(),re&&ln())))}function an(i){let e=X.indexOf(i);e!==-1&&X.splice(e,1),X.length===0&&C.length&&!re&&(ct(),Pe=setTimeout(()=>un(),sn))}function rs(){return lt||(C.length>0&&C[0]instanceof at?C[0].el:document.documentElement)}function me(){for(C.length&&C[0]._selectItem(null);C.length;)C[0]._closeMenu();X.length=0,lt=null}function dn(i,e,t){g.men&&console.log("[men] openSubMenu called");let o=t.querySelector("ul");if(!o)return null;let s=as(o);return s._fireOpenCloseEvent(!0)?(dt=[],s._openMenu(Ne(t),e?i.currentalign==="right"?"left":"right":"down",i,e?i.currentalign:null,e?"left":"top",0),Oe(),s):null}function cn(i,e,t,o,s,n,l){g.men&&console.log("[men] openAsList called"),i._fireOpenCloseEvent(!0)&&(dt=[],i._openMenu(e,t,null,o,s,n,l),Oe(),ls())}function as(i){if(g.men&&console.log("[men] createSubMenu called"),i[Ie]instanceof at)throw new Error("Cannot create a submenu from a menubar");return i[Ie]||(i[Ie]=new Vt(i))}function un(){Pe=null,g.men&&console.log("[men] checkMenuClose, menu active: ",X.length?"yes":"no"),!(X.length>0)&&me()}function Oe(){let i=!1;for(let e=C.length-1;e>=0;--e)C[e].el.classList.toggle("hassubselect",i),C[e].selecteditem&&(i=!0)}function ut(i,e,t){if(t={...t},typeof i!="object")throw new Error("openAt requires an object, not an #id");let o;"pageX"in e&&"pageY"in e?(t.direction="right",o={left:e.pageX||0,right:e.pageX||0,top:e.pageY||0,bottom:e.pageY||0,width:0,height:0},t.eventnode||(t.eventnode=e.target)):(o=Ne(e.target||e),t.direction||(t.direction="right",o={left:o.left,right:o.left,top:o.top,bottom:o.bottom,width:0,height:0}),t.eventnode||(t.eventnode=e.target||e));let s={direction:t.direction,align:t.align,exitdirection:t.exitdirection},n=t.eventnode,l=as(i);me();let r={};return"forcenooverlap"in t&&(r.forcenooverlap=t.forcenooverlap),lt=n||null,cn(l,o,s.direction,s.align||"",s.exitdirection,0,r),l}var Ie,sn,dt,re,C,X,Pe,lt,rt,at,Vt,Wt=T(()=>{"use strict";V();ns();Ie=Symbol("wh-tollium-menucontroller"),sn=500,dt=[];re=!1,C=[],X=[],Pe=null,lt=null;rt=class{el;openonhover;active=!1;horizontalsubs=!0;openedsubmenu=null;depth=0;parentmenu=null;exitdirection="";selecteditem=null;currentalign;constructor(e,t){if(this.active=!1,this.selecteditem=null,this.horizontalsubs=!0,this.openedsubmenu=null,this.depth=0,this.parentmenu=null,this.exitdirection="",this.currentalign="",this.openonhover=t,g.men&&console.log("[men] initialize $wh.MenuBase called"),this.el=e,!this.el)throw console.error("No such menubar node:",e),new Error("No such menubar node");this.el.classList.add("wh-menu"),this.el.addEventListener("mousedown",o=>this._onMouseDownOnItem(o)),this.el.addEventListener("click",o=>this._closeAfterClick(o),!0),this.el.addEventListener("mouseenter",o=>this._onMouseEnter(o)),this.el.addEventListener("mouseleave",o=>this._onMouseLeave(o)),this.el.addEventListener("mousemove",o=>this._onMouseMove(o)),this.el.addEventListener("contextmenu",o=>this._onContextMenu(o))}isInMenu(e){return e&&e instanceof HTMLElement&&this.el.contains(e)}_getMenuItems(){return g.men&&console.log("[men] _getMenuItems called"),R(this.el,"li").filter(e=>e.parentNode===this.el)}_isOrientationVertical(){return this.horizontalsubs}_getSelectableItems(){throw new Error("This code must have been unreachable? tried to Moo node.getElements...")}_fireOpenCloseEvent(e){let t=e?"wh:menu-open":"wh:menu-close",o=rs();return g.men&&console.log("[men] dispatching "+t+" for ",this.el," to ",o," tree ",Ut(o)),B(o,t,{bubbles:!0,cancelable:e,detail:{menu:this.el,depth:this.depth}})}_selectItem(e,t){if(e&&!C.includes(this)&&(qt(this,!0),this.active=!0),e&&!X.includes(this)&&X.push(this),this.selecteditem&&(this.openedsubmenu&&(this.openedsubmenu._closeMenu(),this.openedsubmenu=null),this.selecteditem.classList.remove("selected"),this.selecteditem=null),!e||e.classList.contains("disabled")){Oe();return}e.classList.contains("divider")||(this.selecteditem=e,B(e,"wh:menu-selectitem",{bubbles:!0,cancelable:!0})&&e.classList.add("selected")),t&&e.scrollIntoView(),e.classList.contains("hassubmenu")&&(this.openedsubmenu=dn(this,this.horizontalsubs,e)),Oe()}_closeMenu(){this._fireOpenCloseEvent(!1),this.active=!1,qt(this,!1),Oe(),this._selectItem(null)}_onMouseEnter(e){rn(this)}_onMouseLeave(e){an(this)}_onMouseDownOnItem(e){let t=e.target.closest("li");t&&(e.preventDefault(),this._selectItem(t),ls())}_onContextMenu(e){e.stopPropagation(),e.preventDefault()}_closeAfterClick(e){let t=e.target.closest("li");!t||t.classList.contains("hassubmenu")||t.classList.contains("disabled")||t.classList.contains("divider")||setTimeout(()=>me())}_onMouseMove(e){let t=e.target.closest("li");!t||!(t!==this.selecteditem||this.openedsubmenu&&this.openedsubmenu.selecteditem)||(re?this.active:this.openonhover)&&this._selectItem(t)}_handleKey(e,t){if(!this.el)return!1;switch(e.key){case"enter":return this._handleKeyEnter(e);case"up":return this._handleKeyUp(e,t);case"down":return this._handleKeyDown(e,t);case"left":return this._handleKeyLeft(e,t);case"right":return this._handleKeyRight(e,t);case"home":return this._handleKeyHome(e,t);case"end":return this._handleKeyEnd(e,t);case"meta+up":return this._handleKeyHome(e,t);case"meta+down":return this._handleKeyEnd(e,t);default:return!1}}_handleKeyUp(e,t){return g.men&&console.log("[men] _handleKeyUp"),this._isOrientationVertical()?!(!this.selecteditem&&!t):this.selecteditem&&this.exitdirection==="top"?(this._selectItem(null),!0):!1}_handleKeyDown(e,t){return g.men&&console.log("[men] _handleKeyDown"),this._isOrientationVertical()?!(!this.selecteditem&&!t):!!(this.openedsubmenu&&!this.openedsubmenu.selecteditem)}_handleKeyLeft(e,t){if(g.men&&console.log("[men] _handleKeyLeft"),this._isOrientationVertical()){if(this.selecteditem&&this.exitdirection==="left")return this._selectItem(null),!0}else return!(!this.selecteditem&&!t);return!1}_handleKeyRight(e,t){if(g.men&&console.log("[men] _handleKeyRight"),this._isOrientationVertical()){if(this.openedsubmenu&&!this.openedsubmenu.selecteditem)return!0}else return!(!this.selecteditem&&!t);return!1}_handleKeyHome(e,t){return g.men&&console.log("[men] _handleKeyHome"),!(!this.selecteditem&&!t)}_handleKeyEnd(e,t){return g.men&&console.log("[men] _handleKeyEnd"),!(!this.selecteditem&&!t)}_handleKeyEnter(e){return g.men&&console.log("[men] _handleKeyEnter"),this.selecteditem?(this.selecteditem.click(),!0):!1}},at=class extends rt{constructor(e){if(super(e,!1),e[Ie])throw new Error("Menu already initialized");e[Ie]=this,this.horizontalsubs=!1,g.men&&console.error("[men] initialize MenuBar c
7alled"),this.el.classList.add("wh-menubar")}},Vt=class extends rt{substitutionnode;position;preferreddirection;constructor(e){super(e,!0),this.position=null,this.substitutionnode=null,this.currentalign="",this.preferreddirection="",g.men&&console.log("[men] initialize MenuList called"),this.el.classList.add("wh-menulist")}_fixupDividers(){g.men&&console.log("[men] fixupDividers called");let e=null,t=!1;this._getMenuItems().forEach(s=>{s.classList.contains("divider")?(s.classList.add("hidden"),t&&(e=s)):s.classList.contains("hidden")||(t?e&&e.classList.remove("hidden"):t=!0,e=null)})}_calculatePosition(e,t,o,s,n,l,r,a,d){let c=r?"x":"y",u=r?"left":"top",h=r?"right":"bottom",m=r?"width":"height";g.men&&console.log("[men] _calculatePosition",r?"horizontal":"vertical");let p=d?t[h]:t[u],k=d?t[u]:t[h];p=Math.min(p,n[h]),k=Math.max(k,n[u]);let N=Math.max(s[u],n[u]),b=Math.min(s[h],n[h]);g.men&&console.log("[men] corrected bounds",N,b);let w=p-N,x=b-k;g.men&&console.log("[men] bounded space",w,x),e[m]=o[c]+"px";for(let ie=0;ie<2;++ie){if(a&&w>=o[c])return g.men&&console.log(`[men] setting maxattr '${h}' sizeattr '${m}' to ${l[m]-p}`),e[h]=l[m]-p+"px",!1;if(!a&&x>=o[c])return g.men&&console.log(`[men] setting minattr '${u}' to ${k}`),e[u]=k+"px",!1;a=!a}let O=p-n[u],ne=n[h]-k;g.men&&console.log("[men] view spaces",O,ne);for(let ie=0;ie<2;++ie){if(a&&O>=o[c])return g.men&&console.log("[men] setting maxattr",h,"sizeattr",c,l,p),e[h]=l[m]-p+"px",!1;if(!a&&ne>=o[c])return g.men&&console.log("[men] setting minattr",u,k),e[u]=k+"px",!1;a=!a}if(g.men&&console.log("[men] no fit on both sides"),g.men&&console.log("[men] minattr: ",u," maxattr",h,"sizeattr",c,s,o),s[h]-s[u]>=o[c])g.men&&console.log("[men] Honour direction, stick to bound border"),a?e[u]=s[u]+"px":e[h]=l[m]-s[h]+"px";else if(n[h]-n[u]>=o[c])g.men&&console.log("[men] Fits within view - honour direction, stick to view border"),a?e[u]=n[u]+"px":e[h]=l[m]-n[h]+"px";else return g.men&&console.log("[men] Doesn't fit at all - stick to top. Force the max size to force scroll"),e[u]=n[u]+"px",e[m]=n[h]-n[u]+"px",!0;return!1}_handleMenuOpen(){g.men&&console.log("[men] dispatching wh-menu-opened to ",this.el," in tree ",Ut(this.el)),B(this.el,"wh:menu-opened",{bubbles:!0,cancelable:!0,detail:{menu:this.el}})}_openMenu(e,t,o,s,n,l,r){g.men&&console.log("[men] openMenu called, prefdir:",t,"prefalign:",t,"exitdir",n),r=r||{},this._fixupDividers(),document.body.contains(this.el)&&(this.substitutionnode=this.el.cloneNode(!1),this.el.replaceWith(this.substitutionnode)),this.el.classList.add("open"),this.parentmenu=o,this.el.classList.remove("level-"+this.depth),this.depth=o?o.depth+1:1,this.el.classList.add("level-"+this.depth),this.currentalign=s,this.preferreddirection=t,this.exitdirection=n||"notspecified",document.body.appendChild(this.el),yt(this.el,{height:"auto",width:"auto",left:"0px",top:"0px",bottom:"auto",right:"auto","max-height":"inherit","max-width":"inherit"});let a=this.el.getBoundingClientRect();this.position={x:a.x,y:a.y};let d={x:a.width,y:a.height};d.x=Math.ceil(Math.max(d.x,l||0)),d.y=Math.ceil(d.y);let c=document.body.getBoundingClientRect();c={left:c.left,top:c.top,right:c.right,bottom:c.bottom,height:c.height,width:c.width,x:c.x,y:c.y};let u={x:window.innerWidth,y:window.innerHeight},h={left:-c.left,top:-c.top,right:-c.left+u.x,bottom:-c.top+u.y,width:0,height:0},m={...h},p={bottom:"auto",top:"auto",left:"auto",height:"auto",width:"auto","max-height":"inherit","max-width":"inherit"};g.men&&(console.log("[men] Menu coordinate data"),console.log("[men] target element",e),console.log("[men] menu size",d),console.log("[men] bounds",m),console.log("[men] viewport ",h,u),console.log("[men] body bounds",{...c})),t==="left"||t==="right"||!t?(this._calculatePosition(p,e,d,m,h,c,!0,t==="left",!1),this._calculatePosition(p,e,d,m,h,c,!1,s==="up",!0)):(this._calculatePosition(p,e,d,m,h,c,!1,t==="up",!1),this._calculatePosition(p,e,d,m,h,c,!0,s==="right",!0)),g.men&&console.log("[men] result style:",p,this.el),yt(this.el,p),qt(this,!0),this.active=!0,this._handleMenuOpen()}_closeMenu(){super._closeMenu(),dt.push(this.el),setTimeout(nn,0);let e=rs();g.men&&console.log("[men] dispatching wh-menu-closed for menu ",this.el," to ",e," in tree ",Ut(e)),B(e,"wh:menu-closed",{bubbles:!0,cancelable:!1,detail:{menu:this.el}}),g.meo||(this.el.classList.remove("open"),this.substitutionnode?this.substitutionnode.replaceWith(this.el):this.el.remove(),this.substitutionnode=null)}}});var ht,ft,J,U,Kt,mt,Qt,Yt,Gt,Xt,fn,De,cs=T(()=>{"use strict";kt();ss();Wt();ht=class extends it{active=!1;available=!0;buttondebugid="";toolbar;constructor(e,t){super(t),this.toolbar=e}isAllowed(e){return!0}updateState(e){let t=e&&e.actionstate[this.type];t&&(this.available=t.available||!1,this.active=t.active||!1),this.updateButtonRendering()}updateButtonRendering(){}},ft=class extends ht{constructor(e,t){super(e),this.node=v("span",{className:"wh-rtd-button",on:{mousedown:this.mousedown.bind(this),click:this.click.bind(this)},dataset:{button:t}})}mousedown(e){e.stopPropagation(),e.preventDefault()}click(e){e.stopPropagation(),e.preventDefault(),!(!this.available||!this.toolbar.rte.isEditable())&&this.executeAction()}updateButtonRendering(){this.node.classList.toggle("disabled",!(this.available&&this.toolbar.rte.isEditable())),this.node.classList.toggle("active",this.active)}},J=class extends ft{type;constructor(e,t){super(e,t),this.type=t,this.buttondebugid="toolbarbutton:"+t,this.updateState(null)}isAllowed(e){return this.type==="li-increase-level"||this.type==="li-decrease-level"?e.includes("ul")||e.includes("ol"):this.type==="action-properties"?e.includes("a-href")||e.includes("img")||e.includes("object-video"):this.type==="action-clearformatting"||this.type==="object-insert"?!0:e.includes(this.type)}executeAction(){return this.toolbar.rte.executeAction(this.type),!1}},U=class extends ft{type;constructor(e,t){super(e,t),this.type=t,this.updateState(null)}isAllowed(e){return e.includes(this.type)}executeAction(){return this.toolbar.rte.executeAction(this.type),!1}},Kt=class extends U{listnode=v("ul");constructor(e,t){super(e,t),this.node.appendChild(v("div",{style:{display:"none"},childNodes:[this.listnode],onClick:o=>this.activateItem(o)}))}updateState(e){this.updateButtonRendering()}click(e){e.stopPropagation(),e.preventDefault(),this.ensureSubMenu(),!(!this.available||!this.toolbar.rte.isEditable()||!this.listnode.childNodes.length)&&(ut(this.listnode,e,{direction:"down"}),this.updateState(null))}ensureSubMenu(){}activateItem(e){M(e),this.updateState(null)}},mt=class extends ht{owngroup=!0;optionlist=[];select;type;constructor(e,t){super(e),this.type=t,this.node=E("span",null,this.select=E("select",{class:"wh-rtd__toolbarstyle","data-button":t,on:{change:()=>this.selectStyle()}})),this.updateStructure(null)}updateStructure(e){this.optionlist=[];let t=e?this.getAvailableStyles(e):[];for(let o=0;o<t.length;++o){let s=t[o],n=s.def.title?s.def.title:s.tag,l=E("option",{class:"wh-rtd__toolbaroption",value:s.tag},n);l.blockstyle=s,this.optionlist.push(l)}this.select.replaceChildren(...this.optionlist)}updateState(e){this.updateStructure(e),e&&(this.select.value=this.getCurrentStyle(e)||""),this.select.disabled=!(this.available&&this.toolbar.rte.isEditable()&&this.optionlist.length)}selectStyle(){let e=this.toolbar.rte.getEditor();e&&(this.setStyle(this.select.value),e.takeFocus())}},Qt=class extends mt{constructor(e){super(e,"td-class")}getAvailableStyles(e){let t=this.toolbar.rte.getEditor();return t&&e&&e.cellparent?t.getAvailableCellStyles(e).map(o=>({...o,tag:o.tag.toLowerCase()})):[]}getCurrentStyle(e){return e&&e.cellparent&&e.cellparent.classList.contains("wh-rtd__tablecell")?e.cellparent.classList[1]||"":null}setStyle(e){let t=this.toolbar.rte.getEditor();t&&t.setSelectionCellStyle(e)}},Yt=class extends mt{type="p-class";constructor(e){super(e,"p-class")}getAvailableStyles(e){return this.toolbar.rte.getAvailableBlockStyles(e)}getCurrentStyle(e){return e&&e.blockstyle?e.blockstyle.tag:null}setStyle(e){let t=this.toolbar.rte.getEditor();t&&t.setSelectionBlockStyle(e)}},Gt=class extends U{updateState(e){let t=this.toolbar.rte;this.active=t&&t.getShowFormatting(),this.updateButtonRendering()}click(e){e.stopPropagation(),e.preventDefault();let t=this.toolbar.rte.getEditor();!this.available||!this.toolbar.rte.isEditable()||t.setShowFormatting(!this.active)}},Xt=class extends Kt{initialrows=6;initialcolumns=8;statusnode;constructor(e,t){super(e,t)}
7ensureSubMenu(){if(!this.listnode.childNodes.length){this.listnode.classList.add("wh-rtd-tablemenu"),this.listnode.addEventListener("mouseleave",this.hoverItem.bind(this)),this.listnode.addEventListener("mousemove",this.hoverItem.bind(this)),this.listnode.addEventListener("click",e=>this.doInsertTable(e));for(let e=0;e<this.initialrows;++e)for(let t=0;t<this.initialcolumns;++t){let o=["wh-rtd-tablemenuitem"];t===0&&o.push("wh-rtd-tablemenuitem-newrow"),e===0&&o.push("wh-rtd-tablemenuitem-newcol"),this.listnode.appendChild(v("li",{innerHTML:" ",className:o.join(" "),dataset:{col:t+1,row:e+1}}))}this.statusnode=v("li",{textContent:"",className:"wh-rtd-tablemenustatus disabled"}),this.listnode.appendChild(this.statusnode)}}updateState(e){this.available=!!(e&&e.tables.length===0),super.updateState(e)}isAllowed(e){return e.includes("table")}hoverItem(e){if(e.stopPropagation(),e.preventDefault(),e.type==="mousemove"&&uo(e.target)&&e.target.nodeName.toUpperCase()!=="LI")return;let t=this.getItemSize(e.target);R(this.listnode,"li").forEach((o,s)=>{let n=this.getItemSize(o);o.classList.toggle("selected",!!(t&&n&&n.x<=t.x&&n.y<=t.y))}),this.statusnode&&(this.statusnode.textContent=t?t.x+"x"+t.y:"")}doInsertTable(e){M(e);let t=this.toolbar.rte.getEditor();if(!t)return;let o=this.getItemSize(e.target);o&&t.executeAction({action:"table",size:o}),super.activateItem(e)}getItemSize(e){if(e&&e.getAttribute){let t=parseInt(e.getAttribute("data-col")||"",10),o=parseInt(e.getAttribute("data-row")||"",10);if(t>0&&o>0)return{x:t,y:o}}}},fn={"a-href":J,b:U,i:U,u:U,strike:U,sup:U,sub:U,img:J,"action-properties":J,"action-clearformatting":J,"action-showformatting":Gt,"td-class":Qt,"p-class":Yt,ol:U,ul:U,"li-decrease-level":J,"li-increase-level":J,"object-insert":J,"object-video":J,table:Xt},De=class{options;buttons;rte;el;constructor(e,t,o){this.rte=e,this.el=t,this.options={hidebuttons:[],layout:[],compact:!1,allowtags:null,...o},this.buttons=[],this.buildButtonBar(),this.rte.onStateChange(()=>this.onStateChange())}createButtonObject(e){if(this.options.hidebuttons.includes(e))return null;let t=fn[e];if(!t)return null;let o=new t(this,e);return this.options.allowtags&&!o.isAllowed(this.options.allowtags)?null:(this.buttons.push(o),o)}buildButtonBar(){this.el.replaceChildren();for(let e=0;e<this.options.layout.length;++e){let t=this.options.layout[e];for(let o=0;o<t.length;++o){let s=t[o];if(typeof s=="string"){let l=this.createButtonObject(s);if(!l)continue;this.el.appendChild(l.node);continue}let n=null;for(let l=0;l<s.length;++l){let r=s[l],a=this.createButtonObject(r);a&&(n||(n=v("span",{className:"wh-rtd-toolgroup"}),this.el.appendChild(n)),n.appendChild(a.node))}}this.options.compact||this.el.appendChild(v("br"))}this.onStateChange()}onStateChange(){let e=this.rte.getSelectionState();for(let t=0;t<this.buttons.length;++t)this.buttons[t].updateState(e)}getButton(e){for(let t=0;t<this.buttons.length;++t)if(this.buttons[t].type===e)return this.buttons[t]}}});var pe,us=T(()=>{"use strict";pe=(Ts(),co(Cs)).registerTexts;pe("tollium","nl",{components:{rte:{inspect:"Inspecteer",properties:"Eigenschappen",table_addcolumn_after:"Kolom toevoegen aan de rechterkant",table_addcolumn_before:"Kolom toevoegen aan de linkerkant",table_addpara_after:"Voeg paragraaf toe na tabel",table_addpara_before:"Voeg paragraaf toe boven tabel",table_addrow_after:"Rij toevoegen hieronder",table_addrow_before:"Rij toevoegen hierboven",table_deletecolumn:"Kolom verwijderen",table_deleterow:"Rij verwijderen",table_mergedown:"Samenvoegen met onderste cellen",table_mergeright:"Samenvoegen met cellen aan de rechterkant",table_splitcols:"Kolommen splitsen",table_splitrows:"Rijen splitsen",toomanyplaintextbytes:["Veld '",1,"' bevat meer tekst dan aangeraden (",2," bytes, ",3," aangeraden)."],toomanyplaintextbytes_error:["Veld '",1,"' bevat meer tekst dan toegestaan (",2," bytes, ",3," toegestaan)."],toomanyplaintextcharacters:["Veld '",1,"' bevat meer tekst dan aangeraden (",2," karakters, ",3," aangeraden)."],toomanyplaintextcharacters_error:["Veld '",1,"' bevat meer tekst dan toegestaan (",2," karakters, ",3," toegestaan)."]}}});pe("tollium","en",{components:{rte:{inspect:"Inspect",properties:"Properties",table_addcolumn_after:"Add Column to the Right",table_addcolumn_before:"Add Column to the Left",table_addpara_after:"Add Paragraph after Table",table_addpara_before:"Add Paragraph above table",table_addrow_after:"Add Row Below",table_addrow_before:"Add Row Above",table_delete
7column:"Remove Column",table_deleterow:"Remove Row",table_mergedown:"Merge With Cells Below",table_mergeright:"Merge With Cells to the Right",table_splitcols:"Split Columns",table_splitrows:"Split Rows",toomanyplaintextbytes:["Field '",1,"' contains more text than recommended (",2," bytes, ",3," recommended)."],toomanyplaintextbytes_error:["Field '",1,"' contains more text than allowed (",2," bytes, ",3," allowed)."],toomanyplaintextcharacters:["Field '",1,"' contains more text than recommended (",2," characters, ",3," recommended)."],toomanyplaintextcharacters_error:["Field '",1,"' contains more text than allowed (",2," characters, ",3," allowed)."]}}});pe("tollium","de",{components:{rte:{inspect:"Inspect",properties:"Properties",table_addcolumn_after:"Add Column to the Right",table_addcolumn_before:"Add Column to the Left",table_addpara_after:"Add Paragraph after Table",table_addpara_before:"Add Paragraph above table",table_addrow_after:"Add Row Below",table_addrow_before:"Add Row Above",table_deletecolumn:"Remove Column",table_deleterow:"Remove Row",table_mergedown:"Merge With Cells Below",table_mergeright:"Merge With Cells to the Right",table_splitcols:"Split Columns",table_splitrows:"Split Rows",toomanyplaintextbytes:["Field '",1,"' contains more text than recommended (",2," bytes, ",3," recommended)."],toomanyplaintextbytes_error:["Field '",1,"' contains more text than allowed (",2," bytes, ",3," allowed)."],toomanyplaintextcharacters:["Field '",1,"' contains more text than recommended (",2," characters, ",3," recommended)."],toomanyplaintextcharacters_error:["Field '",1,"' contains more text than allowed (",2," characters, ",3," allowed)."]}}});pe("tollium","es",{components:{rte:{inspect:"Inspect",properties:"Properties",table_addcolumn_after:"Add Column to the Right",table_addcolumn_before:"Add Column to the Left",table_addpara_after:"Add Paragraph after Table",table_addpara_before:"Add Paragraph above table",table_addrow_after:"Add Row Below",table_addrow_before:"Add Row Above",table_deletecolumn:"Remove Column",table_deleterow:"Remove Row",table_mergedown:"Merge With Cells Below",table_mergeright:"Merge With Cells to the Right",table_splitcols:"Split Columns",table_splitrows:"Split Rows",toomanyplaintextbytes:["Field '",1,"' contains more text than recommended (",2," bytes, ",3," recommended)."],toomanyplaintextbytes_error:["Field '",1,"' contains more text than allowed (",2," bytes, ",3," allowed)."],toomanyplaintextcharacters:["Field '",1,"' contains more text than recommended (",2," characters, ",3," recommended)."],toomanyplaintextcharacters_error:["Field '",1,"' contains more text than allowed (",2," characters, ",3," allowed)."]}}});pe("tollium","it",{components:{rte:{inspect:"Inspect",properties:"Properties",table_addcolumn_after:"Add Column to the Right",table_addcolumn_before:"Add Column to the Left",table_addpara_after:"Add Paragraph after Table",table_addpara_before:"Add Paragraph above table",table_addrow_after:"Add Row Below",table_addrow_before:"Add Row Above",table_deletecolumn:"Remove Column",table_deleterow:"Remove Row",table_mergedown:"Merge With Cells Below",table_mergeright:"Merge With Cells to the Right",table_splitcols:"Split Columns",table_splitrows:"Split Rows",toomanyplaintextbytes:["Field '",1,"' contains more text than recommended (",2," bytes, ",3," recommended)."],toomanyplaintextbytes_error:["Field '",1,"' contains more text than allowed (",2," bytes, ",3," allowed)."],toomanyplaintextcharacters:["Field '",1,"' contains more text than recommended (",2," characters, ",3," recommended)."],toomanyplaintextcharacters_error:["Field '",1,"' contains more text than allowed (",2," characters, ",3," allowed)."]}}});pe("tollium","xt",{components:{rte:{inspect:"Inspect",properties:"Properties",table_addcolumn_after:"Add Column to the Right",table_addcolumn_before:"Add Column to the Left",table_addpara_after:"Add Paragraph after Table",table_addpara_before:"Add Paragraph above table",table_addrow_after:"Add Row Below",table_addrow_before:"Add Row Above",table_deletecolumn:"Remove Column",table_deleterow:"Remove Row",table_mergedown:"Merge With Cells Below",table_mergeright:"Merge With Cells to the Right",table_splitcols:"Split Columns",table_splitrows:"Split Rows",toomanyplaintextbytes:["Field '",1,"' contains more text than recommended (",2," bytes, ",3," recommended)."],toomanyplaintextbytes_error:["Field '",1,"' contains more text than allowed (",2," bytes, ",3," allowed)."],toomanyplaintextcharacters:["Field '",1,"' contains more text than recommended (",2," characters, ",3," recommended)."],toomanyplaintextcharacters_error:["Field '",1,"' contains more text than allowed (",2," characters, ",3," allowed)."]}}})});function hs(i,e={},t){return typeof e=="number"&&(e={imagehandling:e},t!==void 0&&(e.linkresolver=t)),e={imagehandling:0,linkresolver:void 0,suppress_urls:!1,unix_newlines:!1,...e},new Jt(i,e).plain_text}var mn,Jt,fs=T(()=>{"use strict";mn=["P","H1","H2","H3","H4","H5","H6","PRE","OL","UL","DL","DIV","NOSCRIPT","BLOCKQUOTE","FORM","HR","TABLE","FIELDSET","ADDRESS"];Jt=class{plain_text;ol;dont_break;hyperlink;hyperlink_text;first_cell;parsing_text;in_style_tag;in_title_tag;options;constructor(e,t){for(this.plain_text="",this.ol=-1,this.dont_break=!1,this.hyperlink="",this.hyperlink_text="",this.first_cell=!1,this.parsing_text=!1,this.in_style_tag=!1,this.in_title_tag=!1,this.options=t,this.saxparse(e,{start_element:(o,s)=>this.plainElementStart(o,s),end_element:o=>this.plainElementEnd(o),text_node:o=>this.plainText(o)});[" ","\r",` 8`].includes(this.plain_text.substr(0,1));)this.plain_text=this.plain_text.substr(1);for(;this.plain_text.indexOf(`\r 9`)>=0;)this.plain_text=this.plain_text.replace(`\r 10`,` 11`);for(;this.plain_text.indexOf("\r")>=0;)this.plain_text=this.plain_text.replace("\r",` 12`);for(;this.plain_text.indexOf(` 13`)>=0;)this.plain_text=this.plain_text.replace(` 14`,` 15`);for(;this.plain_text.indexOf(` 16 17 18`)>=0;)this.plain_text=this.plain_text.replace(` 19 20 21`,` 22 23`);this.options.unix_newlines||(this.plain_text=this.plain_text.split(` 24`).join(`\r 25`))}saxparse(e,t){switch(e.nodeType){case 1:{if(t.start_element){let s=Array.from(e.attributes);
25t.start_element(e.nodeName,s)}let o=e.firstChild;for(;o;)this.saxparse(o,t),o=o.nextSibling;t.end_element&&t.end_element(e.nodeName)}break;case 3:t.text_node&&t.text_node(e.nodeValue||"");break;case 9:case 11:{let o=e.firstChild;for(;o;)this.saxparse(o,t),o=o.nextSibling}break}}getAttr(e,t){for(let o=0;o<e.length;++o)if(e[o].name.toUpperCase()===t)return e[o].value;return""}plainElementStart(e,t){let o=e.toUpperCase();switch(mn.includes(o)&&(this.dont_break?this.dont_break=!1:this.plain_text=this.plain_text+`\r 26`),o){case"BR":this.plain_text=this.plain_text+`\r 27`;break;case"STYLE":this.in_style_tag=!0;break;case"TITLE":this.in_title_tag=!0;break;case"A":this.hyperlink=this.getAttr(t,"HREF"),this.hyperlink_text="";break;case"IMG":{let s=this.getAttr(t,"ALT");if(s==="")return;this.plain_text=this.plain_text+(this.options.imagehandling===1?"[[":"[")+s+"]"}break;case"UL":this.ol=-1;break;case"OL":{let s=parseInt(this.getAttr(t,"START"));this.ol=Number.isNaN(s)?1:s,this.ol<0&&(this.ol=1)}break;case"LI":if(this.ol===-1)this.plain_text=this.plain_text+`\r 28* `;else{let s=parseInt(this.getAttr(t,"VALUE"));this.ol=Number.isNaN(s)?this.ol:s,this.plain_text=this.plain_text+`\r 29`+this.ol+". ",this.ol=this.ol+1}break;case"TR":this.first_cell=!0;break;case"TH":case"TD":this.first_cell?this.first_cell=!1:this.plain_text=this.plain_text+" ",this.dont_break=!0;break}}textEqualsHyperlink(e,t){return this.options.linkresolver&&(t=this.options.linkresolver(t)),!!(e===t||t==="mailto:"+e||t.startsWith("http://")&&("http://"+e===t||"http://"+e+"/"===t))}plainElementEnd(e){!this.options.suppress_urls&&e.toUpperCase()==="A"&&this.hyperlink!==""&&(this.textEqualsHyperlink(this.hyperlink_text,this.hyperlink)||(this.plain_text=this.plain_text+" <URL:"+this.hyperlink+">"),this.hyperlink=""),e.toUpperCase()==="STYLE"&&(this.in_style_tag=!1),e.toUpperCase()==="TITLE"&&(this.in_title_tag=!1),e.toUpperCase()==="TR"&&(this.plain_text=this.plain_text+`\r 30`)}plainText(e){if(!(this.in_style_tag||this.in_title_tag)){for(this.hyperlink!==""&&(this.hyperlink_text=this.hyperlink_text+e),e=e.replace(/(\r|\n|\t|\u00A0)/g," ");e.indexOf(" ")>=0;)e=e.replaceAll(" "," ");this.plain_text=this.plain_text+e}}}});function pn(i){return new Promise((e,t)=>{i.onload=()=>e(),i.onerror=t})}function ms(i){for(let e=0;e<ge.length;++e)if(ge[e].type===i.type&&ge[e].src===i.src)return{idx:e,rule:ge[e]};return null}function $t(i){g.rte&&console.log("[wh.rich] Register new rte");let e=[];for(let t=0;t<i.addcss.length;++t){let o=ms(i.addcss[t]);if(o)o.rule.rtes.push(i),e.push(o.rule);else{let s,n=null;i.addcss[t].type==="link"?(s=v("link",{href:i.addcss[t].src,rel:"stylesheet",dataset:{whRtdTempstyle:""}}),n=pn(s),n.catch(()=>null),document.body.appendChild(s)):(s=v("style",{type:"text/css",dataset:{whRtdTempstyle:""}}),document.body.appendChild(s),s.innerHTML=i.addcss[t].src);let l={type:i.addcss[t].type,src:i.addcss[t].src,node:s,rtes:[i],promise:n};ge.push(l),e.push(l)}}return e}function eo(i){g.rte&&console.log("[wh.rich] Unregister new rte");for(let e=i.addcss.length-1;e>=0;--e){let t=ms(i.addcss[e]);t&&(t.rule.rtes=t.rule.rtes.filter(o=>o!==i),t.rule.rtes.length||(t.rule.node.remove(),ge.splice(t.idx,1)))}}function gn(i){return new Zt(i)}var ge,Zt,to=T(()=>{"use strict";V();ge=[];Zt=class i{addcss;loadpromise;constructor(e){this.addcss=e.map(o=>({type:"link",src:o}));let t=$t(this);this.loadpromise=Promise.all(t.map(o=>o.promise.then(()=>!0,()=>!1))).then(o=>o.every(s=>s))}clone(){return new i(this.addcss.map(e=>e.src))}}});function wn(i){if(!i)throw new Error("No range specified");if(!i.start.element||!i.end.element)throw new Error("Range start or end are not valid nodes");let e=i.start.element.ownerDocument,t=e.getSelection();if(!t)return y.getLogLevel()&1&&console.log("have NO selection object"),!1;y.getLogLevel()&1&&console.log("have selection object",i.start,i.end);let o=e.createRange();return o.setStart(i.start.element,i.start.offset),o.setEnd(i.end.element,i.end.offset),y.getLogLevel()&1&&console.log("SI selectRange dom result",o),t.removeAllRanges(),t.addRange(o),y.getLogLevel()&1&&console.log("SI final selection",t),!0}var be,ps=T(()=>{"use strict";Re();be=class{constructor(e){this.node=e,this.doc=e.ownerDocument}getSelectionRange(){let e=this.doc.getSelection();if(!e||e.rangeCount===0)return null;let t=e.getRangeAt(0);y.getLogLevel()&1&&console.log("got range",t.startContainer,t.startOffset,t.endContainer,t.endOffset);let o=y.fromDOMRange(t);return y.getLogLevel()&1&&console.log("range",o.start.element,o.start.offset,o.end.element,o.end.offset),o}selectRange(e){return wn(e)}}});function kn(i,e,t,o,s){s==="w"?s="w,b":s==="c"&&(s="c,b");
30let n={imgnames:e,width:t,height:o,color:s||""},l=`${e.join("+")}|${n.width}|${n.height}|${n.color}`,r=ae.get(l);if(i.dataset.toddimg!==l){i.dataset.toddimg=l;for(let[,a]of ae)if(a.imgs.includes(i)){a.imgs.splice(a.imgs.indexOf(i),1);break}if(r&&r.result)return L.ild&&console.log("Applying cached "+l),ws(r,i),i;r||ae.set(l,{key:l,data:n,imgs:[]}),i&&ae.get(l).imgs.push(i),we.has(l)||(we.set(l,n),L.ild&&console.log("Loading image "+l+", image queue size: "+we.size)),oo||(L.ild&&console.log("Setting image loading timeout"),so=Z(),oo=window.setTimeout(()=>{vn()},1))}}async function vn(){oo=null,so?.release(),so=null;let i=Z(),e=[];L.ild&&console.warn("Image queue size: "+we.size);for(let[t,o]of we){let s=ae.get(t)??j(`Image ${t} missing in cache`);if(L.ild&&console.log(t,s),!s.imgs.length||s.result){gs(s);continue}e.push({key:t,data:o})}we.clear(),L.ild&&console.info("Loading "+e.length+" images");try{let t=await yn.retrieveImages(e,!!L.ild);L.ild&&console.info("Received "+t.images.length+" images",t);let o=await Promise.all(t.images.map(s=>{let n=ae.get(s.key)??j(`Image ${s.key} missing in cache`);return Nn(s.key,s.images,n.data)}));L.ild&&console.info("Applying images"),o.forEach(s=>{if(!s)return;let n=ae.get(s.key)??j(`Image ${s.key} missing in cache`);n.imgs.length&&(n.result=s.result,n.result||(n.result="/.tollium/ui/img/broken.svg"),gs(n))})}catch(t){console.error(t)}finally{i.release()}}function gs(i){i.imgs.length&&L.ild&&console.log("Applying "+i.key+" to "+i.imgs.length+" images"),i.imgs.forEach(e=>ws(i,e)),i.imgs=[]}function ws(i,e){e.width=i.data.width,e.height=i.data.height,e.src=i.result??j(`Image ${i.key} has no result`)}async function Nn(i,e,t){if(!e.length||!e[0])return console.error("Broken "+(e.length>1?"base ":"")+"image "+i),{key:i};let o=e[0],s=o.type;L.ild&&console.log("Received image "+i+" of type "+s);let n=o.data;if(o.invertable&&s==="image/svg+xml"&&o.color==="b"&&t.color==="w,b"&&(L.ild&&console.log("Inverting image"),n=bs(n)),e.length===1)return{key:i,result:"data:"+s+";base64,"+n};let l=t.width*window.devicePixelRatio,r=t.height*window.devicePixelRatio,a=[],d=[];e.forEach((c,u)=>{if(u&&!c){d.push(Promise.reject(new Error("Broken overlay "+u+" for "+i)));return}let h=u?c.data:n;u&&c.invertable&&c.type==="image/svg+xml"&&c.color==="b"&&t.color==="w,b"&&(L.ild&&console.log("Inverting overlay "+u),h=bs(h));let m="data:"+c.type+";base64,"+h,p=new Image(l,r);p.knockout=c.knockout,p.translatex=c.translatex,p.translatey=c.translatey,d.push(new Promise((k,N)=>{L.ild&&console.log("Reading image "+u),p.onload=function(){L.ild&&console.log("Read image "+u),k(u)},p.onerror=function(b){N(new Error("Error reading image "+u+" for "+i+" ("+m+")"))},p.src=m})),a.push(p)});try{await Promise.all(d),L.ild&&console.info("Combining layers");let c=document.createElement("canvas");c.width=l,c.height=r;let u=c.getContext("2d")??j("Could not get canvas 2D context"),h,m,p=[c],k=0;for(let N of a){let b=!h;if(b&&(h=document.createElement("canvas"),h.width=l,h.height=r,m=h.getContext("2d")),m.drawImage(N,N.translatex,N.translatey,l,r),k&&b){L.ild&&console.info("Knockout overlay "+k),u.save(),u.globalCompositeOperation="destination-out",u.imageSmoothingEnabled=!1;let w=Math.max(Math.round(l/window.devicePixelRatio)/128,Number(window.devicePixelRatio));for(let x=-w;x<=w;++x)for(let O=-w;O<=w;++O)u.drawImage(h,x,O);u.restore()}u.drawImage(h,0,0),N.knockout?(h=null,m=null):(L.ild&&console.info("Adding stack layer for non-knockout layer "+k),c=document.createElement("canvas"),c.width=l,c.height=r,u=c.getContext("2d")??j("Could not get canvas 2D context"),p.push(c)),++k}L.ild&&console.log("Setting cached src "+i),c=document.createElement("canvas"),c.width=l,c.height=r,u=c.getContext("2d")??j("Could not get canvas 2D context");for(h of p)u.drawImage(h,0,0);return{key:i,result:c.toDataURL()}}catch(c){return console.error(c),{key:i}}}function bs(i){return i=window.atob(i),i=i.replace(/(stroke|fill): ?#4a4a4a;/gi,"$1: #f3f3f3;"),i=i.replace(/(stroke|fill): ?#f3f3f3;/gi,"$1: #4a4a4a;"),i=i.replace(/(stroke|fill): ?rgb\(74,74,74\);/gi,"$1: #f3f3f3;"),i=i.replace(/(stroke|fill): ?rgb\(243,243,243\);/gi,"$1: #4a4a4a;"),i=i.replace(/(stroke|fill)="#4a4a4a/gi,'$1=" #f3f3f3'),i=i.replace(/(stroke|fill)="#f3f3f3/gi,'$1=" #4a4a4a'),i=i.replace(/(stroke|fill)="rgb\(74,74,74\)/gi,'$1=" #f3f3f3'),i=i.replace(/(stroke|fill)="rgb\(243,243,243\)/gi,'$1=" #4a4a4a'),window.btoa(i)}function ys({force:i,node:e}={}){for(let t of(e||document).querySelectorAll("img[data-toddimg]"))if((!t.src||i)&&t.dataset.toddimg){let o=t.dataset.toddimg.split("|");
30t.dataset.toddimg=o.slice(0,4).join("|")+"|reloading",kn(t,o[0].split("+"),parseInt(o[1]),parseInt(o[2]),o[3])}}var yn,we,ae,oo,so,ks=T(()=>{"use strict";ho();xs();Ue();V();yn=po("tollium:todd"),we=new Map,ae=new Map,oo=null,so=null});function En(){return[["p-class",["ul","ol","li-decrease-level","li-increase-level"],["p-align-left","p-align-right","p-align-center","p-align-justify"],["action-spellcheck","action-search","action-showformatting","action-properties"],["b","i","u","strike"],["sub","sup"],["a-href"],["img","object-video","object-insert","table","action-symbol"],["action-clearformatting"]]]}var pt,vs=T(()=>{"use strict";kt();pt=class{options;toolbarnode;toolbaropts;container;stylescopenode;htmldiv;constructor(e,t){if(this.container=e,this.options={allowtags:null,log:!1,contentareawidth:null,imgloadplaceholder:null,structure:null,hidebuttons:[],content:"",enabled:!0,readonly:!1,cssinstance:null,csslinks:null,csscode:"",preloadedcss:null,breakupnodes:[],htmlclass:"",bodyclass:"",contentarea:!0,editembeddedobjects:!0,allowundo:!!t?.structure,margins:"compact",propertiesaction:!1,toolbarlayout:null,language:"en",...t},this.container.replaceChildren(),this.container.classList.contains("wh-rtd__editor"))throw new Error("Duplicate RTD initialization");this.toolbarnode=v("div",{className:"wh-rtd-toolbar"}),this.stylescopenode=v("div",{className:"wh-rtd__stylescope "+(this.options.cssinstance||"")}),this.container.classList.add("wh-rtd__editor"),this.container.append(this.toolbarnode,this.stylescopenode),this.options.structure&&this.container.classList.add("wh-rtd--structured"),this.htmldiv=v("div",{className:"wh-rtd-editor wh-rtd__html wh-rtd-editor-htmlnode "+this.options.htmlclass}),this.stylescopenode.append(this.htmldiv);let o={hidebuttons:this.options.hidebuttons,allowtags:this.options.allowtags,layout:this.options.toolbarlayout||En()};this.options.structure?o.hidebuttons.push("action-clearformatting"):o.hidebuttons.push("p-class","action-showformatting","object-insert","object-video","table"),this.options.propertiesaction||o.hidebuttons.push("action-properties"),this.toolbaropts=o}}});var Es={};As(Es,{TextFormattingState:()=>ye,default:()=>q});function Ls(i){if(H(i,[S.element,S.documentFragment])){if("|script|style|".indexOf("|"+i.nodeName.toLowerCase()+"|")>=0)return"";if("|br|hr|img|".indexOf("|"+i.nodeName.toLowerCase()+"|")>=0)return no(i);let e=[];"|blockquote|table|tbody|tr|th|td|".indexOf("|"+i.nodeName.toLowerCase()+"|")>=0&&e.push("<"+i.nodeName.toLowerCase()+io(i)+">");for(let t=i.firstChild;t;t=t.nextSibling)e.push(Ls(t));return"|blockquote|div|dd|dt|fieldset|form|h1|h2|h3|h4|h5|h6|li|p|pre|".indexOf("|"+i.nodeName.toLowerCase()+"|")>=0&&e.push("<br/>"),"|blockquote|table|tbody|tr|th|td|".indexOf("|"+i.nodeName.toLowerCase()+"|")>=0&&e.push("</"+i.nodeName.toLowerCase()+">"),e.join("")}if(i.nodeType===3||i.nodeType===4){if(!i.nodeValue)return"";let e=K(i.nodeValue,"attribute"),t=i.parentNode;for(;t&&!("|pre|".indexOf("|"+i.nodeName.toLowerCase()+"|")>=0);t=t.parentNode);return t&&(e=e.split(`\r 31`).join(` 32`).split("\r").join(` 33`).split(` 34`).join("<br/>")),e}return""}function no(i,e){if(!i)return"";let t=[];switch(i.nodeType){case 9:e||t.push("<html><body>"),t.push(no(i.body,!0)),e||t.push("</body></html>");break;case 1:{let o=i;if(o.childNodes.length){e||t.push("<"+o.nodeName.toLowerCase()+io(o)+">");for(let s=o.firstChild;s;s=s.nextSibling)t.push(no(s,!1));e||t.push("</"+o.nodeName.toLowerCase()+">")}else{if(o.nodeName.toLowerCase()==="br"&&(o.getAttribute("_moz_editor_bogus_node")==="TRUE"||o.getAttribute("type")==="_moz"))break;e||t.push("<"+o.nodeName.toLowerCase()+io(o)+"/>")}break}case 3:i.nodeValue&&t.push(K(i.nodeValue,"attribute"));break}return t.join("")}function io(i){let e=[];for(let t=0;t<i.attributes.length;++t)e.push(" "+i.attributes[t].nodeName.toLowerCase()+'="'+K(i.attributes[t].nodeValue||"","attribute")+'"');return e.join("")}function Ns(i,e,t){let o=[],s;t&&(s=new MutationObserver(n=>o.push(...n)),s.observe(i,{childList:!0,subtree:!0,attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0}));for(let n of e.reverse())switch(n.type){case"attributes":n.oldValue===null?n.attributeNamespace?n.target.removeAttributeNS(n.attributeNamespace,n.attributeName):n.target.removeAttribute(n.attributeName):n.attributeNamespace?n.target.setAttributeNS(n.attributeNamespace,n.attributeName,n.oldValue):n.target.setAttribute(n.attributeName,n.oldValue);break;case"characterData":n.target.nodeValue=n.oldValue;break;case"childList":{for(let l of n.addedNodes)l.remove();
34if(n.removedNodes.length){let l=Array.from(n.removedNodes);n.nextSibling?n.nextSibling.before(...l):n.target.append(...l)}}}return s?(o.push(...s.takeRecords()),s.disconnect(),o):null}var lo,He,An,q,ye,gt=T(()=>{"use strict";V();ts();cs();Wt();Ss();us();fs();to();yo();kt();qe();Rs();ps();ot();Ft();ee();xe();ks();Re();Ue();Bs();vs();lo=class{editor;preselection;postselection;undoRecords;redoRecords;locks;undoChangeObserver;finished;onfinish;constructor(e,t){this.editor=e,this.preselection=t.clone(),this.postselection=null,this.undoRecords=[],this.redoRecords=null,this.locks=[],this.undoChangeObserver=new MutationObserver(o=>this.undoRecords.push(...o)),this.undoChangeObserver.observe(e.getBody(),{childList:!0,subtree:!0,attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0})}finish(e){e||(e=this.editor.getSelectionRange()),this.undoRecords.push(...this.undoChangeObserver?.takeRecords()??[]),this.undoChangeObserver?.disconnect(),this.undoChangeObserver=null,this.postselection=e.clone(),this.finished=!0,this.onfinish&&this.onfinish(this)}undo(){this.redoRecords=Ns(this.editor.getBody(),this.undoRecords,!this.redoRecords)||this.redoRecords,this.editor.selectRange(this.preselection)}redo(){if(!this.redoRecords)throw new Error("Redo records not available");Ns(this.editor.getBody(),this.redoRecords,!1),this.editor.selectRange(this.postselection)}},He=class{undoitem;_undoitem;stack;editor;constructor(e,t){this.editor=e,this.undoitem=null,this._undoitem=t,t&&(t.locks.push(this),this.stack=new Error("undo lock acquisition"))}close(){if(this._undoitem){let e=this._undoitem.locks.pop();if(e!==this)throw new Error(`Inner lock was not closed!, this lock stack: ${this.stack} inner lock stack ${e?.stack}`);this._undoitem.locks.length||this._undoitem.finish()}}},An="data:image/png;base64,R0lGODlhHwAfAPUAAP///0h5ke7y9N7m687b4cTU27zN1uXs78vZ37bJ0+vw8uLq7cHS2brM1cbV3Nrj6Pj5+sDQ2d/o6+zx826VqGOMoYGis9Tf5ZizwbDFz4Wmtfv7/JKvvXqdr9Xg5fn6+3uer2uTpgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAHwAfAAAG/0CAcEgUDAgFA4BiwSQexKh0eEAkrldAZbvlOD5TqYKALWu5XIwnPFwwymY0GsRgAxrwuJwbCi8aAHlYZ3sVdwtRCm8JgVgODwoQAAIXGRpojQwKRGSDCRESYRsGHYZlBFR5AJt2a3kHQlZlERN2QxMRcAiTeaG2QxJ5RnAOv1EOcEdwUMZDD3BIcKzNq3BJcJLUABBwStrNBtjf3GUGBdLfCtadWMzUz6cDxN/IZQMCvdTBcAIAsli0jOHSJeSAqmlhNr0awo7RJ19TJORqdAXVEEVZyjyKtE3Bg3oZE2iK8oeiKkFZGiCaggelSTiA2LhxiZLBSjZjBL2siNBOFQ84LxHA+mYEiRJzBO7ZCQIAIfkECQoAAAAsAAAAAB8AHwAABv9AgHBIFAwIBQPAUCAMBMSodHhAJK5XAPaKOEynCsIWqx0nCIrvcMEwZ90JxkINaMATZXfju9jf82YAIQxRCm14Ww4PChAAEAoPDlsAFRUgHkRiZAkREmoSEXiVlRgfQgeBaXRpo6MOQlZbERN0Qx4drRUcAAJmnrVDBrkVDwNjr8BDGxq5Z2MPyUQZuRgFY6rRABe5FgZjjdm8uRTh2d5b4NkQY0zX5QpjTc/lD2NOx+WSW0++2RJmUGJhmZVsQqgtCE6lqpXGjBchmt50+hQKEAEiht5gUcTIESR9GhlgE9IH0BiTkxrMmWIHDkose9SwcQlHDsOIk9ygiVbl5JgMLuV4HUmypMkTOkEAACH5BAkKAAAALAAAAAAfAB8AAAb/QIBwSBQMCAUDwFAgDATEqHR4QCSuVwD2ijhMpwrCFqsdJwiK73DBMGfdCcZCDWjAE2V347vY3/NmdXNECm14Ww4PChAAEAoPDltlDGlDYmQJERJqEhGHWARUgZVqaWZeAFZbERN0QxOeWwgAAmabrkMSZkZjDrhRkVtHYw+/RA9jSGOkxgpjSWOMxkIQY0rT0wbR2LQV3t4UBcvcF9/eFpdYxdgZ5hUYA73YGxruCbVjt78G7hXFqlhY/fLQwR0HIQdGuUrTz5eQdIc0cfIEwByGD0MKvcGSaFGjR8GyeAPhIUofQGNQSgrB4IsdOCqx7FHDBiYcOQshYjKDxliVDpRjunCjdSTJkiZP6AQBACH5BAkKAAAALAAAAAAfAB8AAAb/QIBwSBQMCAUDwFAgDATEqHR4QCSuVwD2ijhMpwrCFqsdJwiK73DBMGfdCcZCDWjAE2V347vY3/NmdXNECm14Ww4PChAAEAoPDltlDGlDYmQJERJqEhGHWARUgZVqaWZeAFZbERN0QxOeWwgAAmabrkMSZkZjDrhRkVtHYw+/RA9jSGOkxgpjSWOMxkIQY0rT0wbR2I3WBcvczltNxNzIW0693MFYT7bTumNQqlisv7BjswAHo64egFdQAbj0RtOXDQY6VAAUakihN1gSLaJ1IYOGChgXXqEUpQ9ASRlDYhT0xQ4cACJDhqDD5mRKjCAYuArjBmVKDP9+VRljMyMHDwcfuBlBooSCBQwJiqkJAgAh+QQJCgAAACwAAAAAHwAfAAAG/0CAcEgUDAgFA8BQIAwExKh0eEAkrlcA9oo4TKcKwharHScIiu9wwTBn3QnGQg1owBNld+O72N/zZnVzRApteFsODwoQABAKDw5bZQxpQ2JkCRESahIRh1gEVIGVamlmXgBWWxETdEMTnlsIAAJmm65DEmZGYw64UZFbR2MPv0QPY0hjpMYKY0ljjMZCEGNK09MG0diN1gXL3M5bTcTcyFtOvdzBWE+207pjUKpYrL+wY7MAB4EerqZjUAG4lKVCBwMbvnT6dCXUkEIFK0jUkOECFEeQJF2hFKUPAIkgQwIaI+hLiJAoR27Zo4YBCJQgVW4cpMYDBpgVZKL59cEBhw+U+QROQ4bBAoUlTZ7QCQIAIfkECQoAAAAsAAAAAB8AHwAABv9AgHBIFAwIBQPAUCAMBMSodHhAJK5XAPaKOEynCsIWqx0nCIrvcMEwZ90JxkINaMATZXfju9jf82Z1c0QKbXhbDg8KEAAQCg8OW2UMaUNiZAkREmoSEYdYBFSBlWppZl4AVlsRE3RDE55bCAACZpuuQxJmRmMOuFGRW0djD79ED2NIY6TGCmNJY4zGQhBjStPTFBXb21
34DY1VsGFtzbF9gAzlsFGOQVGefIW2LtGhvYwVgDD+0V17+6Y6BwaNfBwy9YY2YBcMAPnStTY1B9YMdNiyZOngCFGuIBxDZAiRY1eoTvE6UoDEIAGrNSUoNBUuzAaYlljxo2M+HIeXiJpRsRNMaq+JSFCpsRJEqYOPH2JQgAIfkECQoAAAAsAAAAAB8AHwAABv9AgHBIFAwIBQPAUCAMBMSodHhAJK5XAPaKOEynCsIWqx0nCIrvcMEwZ90JxkINaMATZXfjywjlzX9jdXNEHiAVFX8ODwoQABAKDw5bZQxpQh8YiIhaERJqEhF4WwRDDpubAJdqaWZeAByoFR0edEMTolsIAA+yFUq2QxJmAgmyGhvBRJNbA5qoGcpED2MEFrIX0kMKYwUUslDaj2PA4soGY47iEOQFY6vS3FtNYw/m1KQDYw7mzFhPZj5JGzYGipUtESYowzVmF4ADgOCBCZTgFQAxZBJ4AiXqT6ltbUZhWdToUSR/Ii1FWbDnDkUyDQhJsQPn5ZU9atjUhCPHVhgTNy/RSKsiqKFFbUaQKGHiJNyXIAAh+QQJCgAAACwAAAAAHwAfAAAG/0CAcEh8JDAWCsBQIAwExKhU+HFwKlgsIMHlIg7TqQeTLW+7XYIiPGSAymY0mrFgA0LwuLzbCC/6eVlnewkADXVECgxcAGUaGRdQEAoPDmhnDGtDBJcVHQYbYRIRhWgEQwd7AB52AGt7YAAIchETrUITpGgIAAJ7ErdDEnsCA3IOwUSWaAOcaA/JQ0amBXKa0QpyBQZyENFCEHIG39HcaN7f4WhM1uTZaE1y0N/TacZoyN/LXU+/0cNyoMxCUytYLjm8AKSS46rVKzmxADhjlCACMFGkBiU4NUQRxS4OHijwNqnSJS6ZovzRyJAQo0NhGrgs5bIPmwWLCLHsQsfhxBWTe9QkOzCwC8sv5Ho127akyRM7QQAAOwAAAAAAAAAAAA==",q=class extends pt{structure;blockroots;lastselectionstate=new ye;toolbar=null;addcss=[];dirty=!0;original_value="<neverset>";knownimages=[];language;bodydiv;allChangeObserver;allChangeObserverActive=!1;constructor(e,t){let o=[...e.childNodes];super(e,t),g.rte&&console.log("[rte] initializing rtd",this.container,this.options),this.options.csslinks&&this.options.csslinks.forEach(l=>this.addcss.push({type:"link",src:l})),this.options.preloadedcss&&this.addcss.push(...this.options.preloadedcss.addcss),this.options.csscode&&this.addcss.push({type:"style",src:this.options.csscode}),this.bodydiv=v("div",{className:"wh-rtd wh-rtd-editor wh-rtd__body wh-rtd-editor-bodynode wh-rtd-theme-default "+this.options.bodyclass,on:{"dompack:takefocus":l=>this._takeSafeFocus(l)},childNodes:o}),this.htmldiv.append(this.bodydiv),z()==="safari"&&go()<13&&this.bodydiv.classList.add("wh-rtd__body--safariscrollfix"),this.scrollmonitor=new nt(this.container),zt(this.container),this.htmldiv.addEventListener("mousedown",l=>this._gotPageClick(l)),this.htmldiv.addEventListener("click",l=>this._gotClick(l)),this.htmldiv.addEventListener("contextmenu",l=>this._gotContextMenu(l)),this.options.readonly&&(this.toolbarnode.style.display="none"),this._updateEnablingAttributes();let s="none";this.options.structure&&this.options.structure.contentareawidth&&(this.options.contentarea&&(this.bodydiv.parentNode.classList.add("wh-rtd-withcontentarea"),this.bodydiv.classList.add("wh-rtd__body--contentarea")),this.bodydiv.style.width=this.options.structure.contentareawidth,s=this.options.margins),this.htmldiv.classList.add("wh-rtd--margins-"+s),s!=="none"&&this.htmldiv.classList.add("wh-rtd--margins-active");let n={log:this.options.log,breakupnodes:this.options.breakupnodes,editembeddedobjects:this.options.editembeddedobjects,allowundo:this.options.structure&&this.options.allowundo};this.options.structure?(this.options.allowundo&&(this.undonode=E("div",{contenteditable:"true",class:"wh-rtd__undoholder",tabindex:"-1"}),this.container.appendChild(this.undonode)),n.structure=this.options.structure):n.allowtags=this.options.allowtags,this.selectionitf=new be(this.bodydiv),this.selectingrange=!1,this.ignorenextfocus=!1,this.ultypes=["","disc","circle","square"],this.oltypes=["","decimal","lower-roman","upper-roman"],this.delayedsurrounds=[],this.undostack=[],this.undopos=0,this.undoselectitf=null,this.oninputhandlers=[],this.activeinputhandler="",this.tableeditors=[],this.repeatupdatetableuntil=null,this.attachedinputevents=!1,this.inputeventfunction=null,this.blockroots=["body","td","th"],this.tableeditorstatechangedelay=null,this.undonode&&(t.allowundo=!0),this.properties_selector="img, a[href]",this.onload&&this.onload(),this._mouseupcallback=l=>this._gotMouseUp(l),this.options.log&&console.log("onloadcompletedelayed finished"),this._registerFrameEventListeners(),this.language=this.options.language,this.SetBreakupNodes(t&&t.breakupnodes),this.setupUndoNode(),this.allChangeObserver=new MutationObserver(()=>B(this.bodydiv,"wh:richeditor-change",{bubbles:!0,cancelable:!1})),this.setAllChangeObserver(!0)}setAllChangeObserver(e){this.allChangeObserverActive!==e&&(this.allChangeObserverActive=e,e?this.allChangeObserver.observe(this.bodydiv,{childList:!0,subtree:!0,attributes:!0,characterData:!0}
34):this.allChangeObserver.disconnect())}_constructorTail(){this.options.enabled&&this.editareaconnect(),this.toolbar=new De(this,this.toolbarnode,this.toolbaropts),this._fireStateChange(),$t(this),this.options.preloadedcss&&eo(this.options.preloadedcss),this.clearDirty()}_takeSafeFocus(e){e.preventDefault();let t=e.target.parentNode.scrollLeft,o=e.target.parentNode.scrollTop;e.target.focus(),e.target.parentNode.scrollLeft=t,e.target.parentNode.scrollTop=o}_gotContextMenu(e){if(e.ctrlKey&&e.shiftKey)return;e.stopPropagation(),e.preventDefault(),this._gotSelectionChange(null);let t=this.getSelectionState(!0);if(!t)return;let o=t.propstarget?Ot({__node:t.propstarget}):null,s=[];for(let l of[{action:"table-addrow-before",title:D("tollium:components.rte.table_addrow_before")},{action:"table-addrow-after",title:D("tollium:components.rte.table_addrow_after")},null,{action:"table-addcolumn-before",title:D("tollium:components.rte.table_addcolumn_before")},{action:"table-addcolumn-after",title:D("tollium:components.rte.table_addcolumn_after")},null,{action:"table-deleterow",title:D("tollium:components.rte.table_deleterow")},{action:"table-deletecolumn",title:D("tollium:components.rte.table_deletecolumn")},null,{action:"table-addpara-before",title:D("tollium:components.rte.table_addpara_before")},{action:"table-addpara-after",title:D("tollium:components.rte.table_addpara_after")},null,{action:"table-mergeright",title:D("tollium:components.rte.table_mergeright")},{action:"table-mergedown",title:D("tollium:components.rte.table_mergedown")},{action:"table-splitcols",title:D("tollium:components.rte.table_splitcols")},{action:"table-splitrows",title:D("tollium:components.rte.table_splitrows")},null,...this.options.propertiesaction?[{action:"action-properties",title:D("tollium:components.rte.properties")}]:[]])(!l||t.actionstate[l.action].available)&&s.push(l);if(!B(this.bodydiv,"wh:richeditor-contextmenu",{bubbles:!0,cancelable:!0,detail:{actiontarget:o,menuitems:s}})||!s.some(l=>l))return;let n=E("ul",{onClick:l=>this._activateRTDMenuItem(l,o)},s.map(l=>l?E("li",{"data-action":l.action},l.title):E("li",{class:"divider"})));ut(n,e,{eventnode:this.node})}_activateRTDMenuItem(e,t){M(e);let o=e.target.closest("li");this.executeAction(o.dataset.action,t)}isDirty(){return this.dirty}clearDirty(){this.original_value=this.getValue(),this.dirty=!1}_checkDirty(){this.dirty||(this.dirty=this.original_value!==this.getValue(),this.dirty&&(g.rte&&console.log("[rte] Document got dirty, firing event"),B(this.container,"wh:richeditor-dirty",{bubbles:!0,cancelable:!1})))}_gotClick(e){M(e);let t=e.target.closest("a[href]");t&&t.href.match(/^https?:/)&&(!this.isEditable()||mo(e))&&window.open(t.href,"_blank")}_gotPageClick(e){if(!this.isEditable())return;this.htmldiv===e.target&&(this.bodydiv.focus(),e.preventDefault());let t=this.bodydiv.lastElementChild;(!t||e.clientY>t.getBoundingClientRect().bottom)&&this.requireBottomParagraph()}_updateEnablingAttributes(){let e=this.stylescopenode||this.htmldiv;e.classList.toggle("wh-rtd--enabled",this.isEditable()),e.classList.toggle("wh-rtd--disabled",!this.options.enabled),e.classList.toggle("wh-rtd--readonly",this.options.readonly)}_gotStateChange(e){this._fireStateChange(),this._checkDirty()}_fireStateChange(){B(this.bodydiv,"wh:richeditor-statechange",{bubbles:!0,cancelable:!1})}updateTarget(e,t){let o=this.getUndoLock(),s=e.__node;if(s.matches("a"))this._updateHyperlink(e.__node,t);else if(s.matches("td,th"))this._updateCell(e.__node,t);else if(s.matches("table"))this._updateTable(e.__node,t);else if(s.matches(".wh-rtd-embeddedobject"))s.classList.contains("wh-rtd-embeddedobject")&&t&&(t.type==="replace"?this.updateEmbeddedObject(s,t.data):t.type==="remove"&&this.removeEmbeddedObject(s));else if(s.matches("img")){t.width?s.setAttribute("width",t.width):s.removeAttribute("width"),t.height?s.setAttribute("height",t.height):s.removeAttribute("height"),s.align="",s.alt=t.alttext,s.className="wh-rtd__img"+(t.align==="left"?" wh-rtd__img--floatleft":t.align==="right"?" wh-rtd__img--floatright":"");let n=s.closest("A");n&&!t.link?(n.replaceWith(s),this.selectNodeOuter(s)):t.link&&(n||(n=document.createElement("a"),s.replaceWith(n),n.appendChild(s),this.selectNodeOuter(n)),n.href=t.link.link,n.target=t.link.target||"")}
34else throw console.error(s,t),new Error("Did not understand action target");o.close()}_updateHyperlink(e,t){let o=this.getUndoLock();t.destroy?(this.selectNodeOuter(e),this.removeHyperlink()):("link"in t&&e.setAttribute("href",t.link),"target"in t&&(t.target?e.target=t.target:e.removeAttribute("target"))),this._checkDirty(),o.close()}_updateTable(e,t){if(t.removetable){this.removeTable(e);return}let o=le(e);o&&(o.setFirstDataCell(t.datacell.row,t.datacell.col),o.setStyleTag(t.tablestyletag),o.setCaption(t.tablecaption))}_updateCell(e,t){this.setCellStyle(e,t.cellstyletag),this._updateTable(e.closest("table"),t)}getBody(){return this.bodydiv}onStateChange(e){this.getBody().addEventListener("wh:richeditor-statechange",e)}qS(e){return this.getBody().querySelector(e)}qR(e){let t=this.qSA(e);if(t.length===0)throw new Error(`No element found for selector: ${e}`);if(t.length>1)throw console.error(`Multiple elements found for selector: ${e}`,t),new Error(`Multiple elements found for selector: ${e}`);return t[0]}qSA(e){return Array.from(this.getBody().querySelectorAll(e))}getButtonNode(e){return this.toolbarnode.querySelector("span.wh-rtd-button[data-button="+e+"]")}isEditable(){return this.options.enabled&&!this.options.readonly}getEditor(){return this}getValue(){return Yo(this.getBody())}setValue(e){this.dirty=!0,this.setAllChangeObserver(!1),this.bodydiv.innerHTML=e,this.resetUndoStack(),this.knownimages=this.qSA("img").filter(t=>!t.closest(".wh-rtd-embeddedobject")).map(t=>t.src),this.reprocessAfterExternalSet(),this.original_value=this.getValue(),this.dirty=!1,this._checkDirty(),this.setAllChangeObserver(!0)}focus(){this.bodydiv.focus()}setEnabled(e){e!==this.options.enabled&&(this.options.enabled=e,this.bodydiv&&this._updateEnablingAttributes(),!this.options.readonly&&(e?(this.editareaconnect(),this._fireStateChange()):(this.editareadisconnect(),this._fireStateChange())))}setReadonly(e){e!==this.options.readonly&&(this.options.readonly=e,this.toolbarnode.style.display=e?"none":"block",this._updateEnablingAttributes(),this.options.enabled&&(e?(this.editareadisconnect(),this._fireStateChange()):(this._fireStateChange(),this.editareaconnect())))}setHTMLClass(e){Dt(this.htmldiv,this.options.htmlclass,e),this.options.htmlclass=e}setBodyClass(e){Dt(this.bodydiv,this.options.bodyclass,e),this.options.bodyclass=e}getPlainText(e,t=[]){switch(e){case"converthtmltoplaintext":{let o=t.includes("suppress_urls"),s=t.includes("unix_newlines");return hs(this.bodydiv,{suppress_urls:o,unix_newlines:s})}case"textcontent":return this.bodydiv.textContent||""}throw new Error("Unsupported method for plaintext conversion: "+e)}get editnode(){return this.bodydiv}setupUndoNode(){this.undonode&&this.options.allowundo&&(this.undonode.innerHTML="0",this.undoselectitf=new be(this.undonode),window.MutationObserver?(this.undoNodeMutationObserver=new MutationObserver(e=>this.gotUndoChange("mutation",e)),this.undoNodeMutationObserver.observe(this.undonode,{characterData:!0,subtree:!0,childList:!0})):this.undonode.addEventListener("input",e=>this.gotUndoChange("input",e)),this.undonode.addEventListener("focus",e=>this.refocusAfterUndoUpdate(e)))}gotUndoChange(e,t){let o=parseInt(this.undonode.innerHTML);o!==this.undopos&&this.changeUndoPosition(o)}refocusAfterUndoUpdate(){setTimeout(()=>this.getBody().focus()),this.stateHasChanged()}destroy(){this.setAllChangeObserver(!1),this.toolbarnode.remove(),eo(this),this.fontslistener&&document.fonts.removeEventListener("loadingdone",this.fontslistener),this.scheduledupdatetableeditors&&(cancelAnimationFrame(this.repeatupdatetableanimframe),clearTimeout(this.repeatupdatetabletimeout)),this.bodydiv.contentEditable=!1}execCommand(e,t,o){try{this.bodydiv.ownerDocument.execCommand(e,t,o)}catch(s){return this.options.log&&console.log("ExecCommand exception",s),!1}return!0}_constrainRangeCrossTDSelections(e){let t=!1,o=e.getAncestorElement();e=e.clone();let s=e.start.getPathFromAncestor(o).reverse();for(let l=0;l<s.length;++l){let r=s[l];if(r.nodeType===1&&["td","th"].includes(r.nodeName.toLowerCase())){e.intersect(y.fromNodeInner(r)),t=!0;break}}o=e.getAncestorElement();let n=e.end.getPathFromAncestor(o).reverse();for(let l=0;l<n.length;++l){let r=n[l];if(r.nodeType===1&&r.nodeName.toLowerCase()==="table"){let a=f.newPointingTo(r);a.scanBackward(this.getBody(),{whitespace:!0,blocks:!0}),e.start.compare(a)<=0?e.end.assign(a):e.end.assign(e.start),t=!0;break}}return{changed:t,range:e}}hasFocus(){let e=document.activeElement;for(;e&&e!==this.bodydiv;)e=e.parentNode;return!!e}takeFocus(){this.bodydiv.focus()}setContentsHTML(e,t){this.bodydiv.innerHTML=e,this.setCursorAtLocator(new f(this.getBody()))}setContentsHTMLRaw(e){this.setContentsHTML(e,{raw:!0})}debugGetRawSelectionRange(){return this.selectionitf.getSelectionRange()}_fixChromeInitialPositionBug(e){let t=this.getBody();if(e.end.element===t&&e.end.offset===0){let o=e.end.clone(),s=!1;for(;;){let n=o.getPointedNode();if(!n||n.nodeType!==1||n.isContentEditable)break;++o.offset,s=!0}e.assign(y.fromLocator(o)),this.selectionitf.selectRange(e),s&&y.getLogLevel()&4&&console.log("getSelectionRange native was not legal (contentEditable error). After normalize",_(this.getBody(),e,!0),e.start,e.end)}}getSelectionRange(e){let t=e&&e.skipnormalize,o=this.getBody();if(this.hasFocus()){let n=this.selectionitf.getSelectionRange();
34n?(y.getLogLevel()&4&&console.log("getSelectionRange have native selection (limited to body node)",_(this.getBody(),n,!0),{...n.start},{...n.end}),n.limitToNode(o),n.isLegal(this.getBody())||(console.log("normalize illegal range"),n.normalize(this.getBody()),this.selectionitf.selectRange(n),y.getLogLevel()&4&&console.log("getSelectionRange native was not legal. After normalize",_(this.getBody(),n,!0),n.start,n.end)),this._fixChromeInitialPositionBug(n),this.currentrange=n):this.currentrange&&(this.currentrange.limitToNode(o),y.getLogLevel()&4&&console.log("getSelectionRange no native selection, use saved",_(this.getBody(),this.currentrange,!0),this.currentrange.start,this.currentrange.end))}else this.currentrange&&(this.currentrange.limitToNode(o),y.getLogLevel()&4&&console.log("getSelectionRange no focus, use saved",_(this.getBody(),this.currentrange,!0),this.currentrange.start,this.currentrange.end));if(!this.currentrange){let n=new f(o);this.currentrange=new y(n,n),y.getLogLevel()&4&&console.log("getSelectionRange no saved selection",_(this.getBody(),this.currentrange,!0),this.currentrange.start,this.currentrange.end)}let s=this.currentrange.clone();return t||(s.normalize(o,!0),y.getLogLevel()&4&&console.log("getSelectionRange normalized selection",_(this.getBody(),s,!0),s.start,s.end)),s}selectRange(e,t){if(!W(e.start.element))throw new Error("Trying to put start of selection within an unsplittable element ("+e.start.element.nodeName+")");if(!W(e.end.element))throw new Error("Trying to put end of selection within an unsplittable element ("+e.end.element.nodeName+")");let o=this.getBody();this.currentrange=e.clone(),y.getLogLevel()&64&&console.log("selectrange before limit",_(o,this.currentrange,!0),this.currentrange.start,this.currentrange.end),this.currentrange.limitToNode(o),y.getLogLevel()&64&&console.log("selectrange after limit",_(o,this.currentrange,!0),this.currentrange.start,this.currentrange.end),(!t||!t.skipnormalize)&&(this.currentrange.normalize(o),y.getLogLevel()&64&&console.log("selectrange after normalize",_(o,this.currentrange,!0),this.currentrange.start,this.currentrange.end)),this.selectingrange=!0,this.hasFocus()&&this.selectionitf.selectRange(this.currentrange),y.getLogLevel()&64&&console.log("EA selectRange",this.connected,_(o,e,!1)),this.selectingrange=!1,this.selectionHasChanged(this.currentrange),this.stateHasChanged()}setCursorAtLocator(e){this.selectRange(new y(e,e))}selectNodeInner(e){this.selectRange(y.fromNodeInner(e))}selectNodeOuter(e){this.selectRange(y.fromNodeOuter(e))}collapseSelection(e){let t=this.getSelectionRange();e?t.end.assign(t.start):t.start.assign(t.end),this.selectRange(t)}editareaconnect(){this.options.readonly?this.bodydiv.tabIndex=0:this.bodydiv.contentEditable=!0,this.execCommand("enableInlineTableEditing",null,"false"),this.execCommand("enableObjectResizing",null,"false"),this.stateHasChanged()}editareadisconnect(){this.options.readonly?this.bodydiv.tabIndex=-1:this.bodydiv.contentEditable=!1,this.stateHasChanged()}reprocessAfterExternalSet(){this.currentrange=null,this.delayedsurrounds=[];let e=this.getSelectionRange();this.selectRange(e),this._reprocessEmbeddedAutoElements()}_reprocessEmbeddedAutoElements(){ys({node:this.getBody()})}SetBreakupNodes(e){e&&e.length?this.breakupnodes=e:this.breakupnodes=[]}onFocus(e){this.currentrange&&!this.ignorenextfocus&&this.selectionitf.selectRange(this.currentrange),z()==="firefox"&&(document.execCommand("enableInlineTableEditing",null,"false"),document.execCommand("enableObjectResizing",null,"false")),this.ignorenextfocus=!1,this.updateTableEditors()}onFocusIn(e){this.currentrange&&!this.ignorenextfocus&&this.selectionitf.selectRange(this.currentrange),this.ignorenextfocus=!0}applyTextStyle(e,t){["b","i","u","strike","sub","sup"].includes(e)||console.warn("ADDME: Didn't test ApplyTextStyle for '"+e+"' yet"),this.DelayedSurroundSelection({element:e,wrapin:t,splitprohibits:["a"],splitblockelements:!1})}setCursor(e,t){if(!e)throw new Error("Invalid element passed to setCursor");this.setCursorAtLocator(new f(e,t||0))}SetSelection(e){this.selectRange(y.fromDOMRange(e))}SelectAll(){this.selectNodeInner(this.getBody()),this.stateHasChanged()}selectNodeContents(e){console.warn("selectNodeContents is deprecated, use selectNodeInner!"),console.trace(),this.selectRange(y.withinNode(e))}insertTextAtCursor(e){let t=this.getSelectionRange();if(!t.isCollapsed())throw new Error("insertTextAtCursor does not support selections");t.start.descendToLeafNode(this.getBody());let o=t.start.element,s=t.start.offset;o.nodeType!==3&&(o.childNodes.length?o=o.insertBefore(document.createTextNode(""),o.childNodes.item(s)):o=o.appendChild(document.createTextNode("")),s=0);let n=o.nodeValue;n=n.substr(0,s)+e+n.substr(s),o.nodeValue=n,this.selectRange(new y(new f(o,s),new f(o,s+e.length)))}_updateUndoNodeForNewUndoItem(e){this.undonode.focus(),this.undoselectitf.selectRange(y.fromNodeInner(this.undonode)),this.undonode.ownerDocument.execCommand("InsertHTML",!1,String(this.undopos)),this.getBody().focus(),this.selectRange(e.postselection),g.rte&&console.log("[rte] finished recording undo item",e)}getUndoLock(){if(!this.options.allowundo)return new He(this,null);let e=this.undostack.length&&this.undostack[this.undostack.length-1];if(e&&!e.finished)return new He(this,e);
34let t=new lo(this,this.getSelectionRange());return this.undostack.splice(this.undopos,this.undostack.length-this.undopos,t),++this.undopos,g.rte&&console.warn("[rte] start recording undo item",t),t.onfinish=o=>this._updateUndoNodeForNewUndoItem(o),new He(this,t)}resetUndoStack(){this.options.allowundo&&(this.undopos=0,this.undostack=[],this.undonode&&(this.undonode.textContent="0"))}changeUndoPosition(e){let t=!1;try{for(;e<this.undopos;)--this.undopos,this.undostack[this.undopos].undo();for(;e>this.undopos&&this.undopos<this.undostack.length;)this.undostack[this.undopos].redo(),++this.undopos;this.undopos=e,t=!0}finally{t||(this.undostack=[],this.undopos=0)}}getBlockAtNode(e){let t=this.getBody(),o=null,s=null,n=null,l=null,r=!1,a=!1,d=null,c=e;for(;c&&c!==t;c=c.parentNode)if(H(c,S.element)){if(["tr","td"].includes(c.nodeName.toLowerCase())&&(a=!0),c.nodeName.toLowerCase()==="li")s=c;else if(I(c)){let h=["ol","ul"].includes(c.nodeName.toLowerCase());this.structure&&this.structure.getBlockStyleByTag&&(d=c.className?this.structure.getBlockStyleByTag(c.className):null),o=c,s=h&&s||c,l=c.parentNode,r=h;break}else if(this.blockroots.includes(c.nodeName.toLowerCase())){o=c,s=c,n=c,l=c.parentNode;break}}else H(c,S.documentFragment)&&(t=c);for(;c&&c!==t;c=c.parentNode)if(H(c,S.documentFragment))t=c;else if(H(c,S.element)&&this.blockroots.includes(c.nodeName.toLowerCase())){n=c;break}return{node:o||t,contentnode:s||t,blockroot:n||t,blockparent:l||t,islist:r,isintable:a,blockstyle:d}}requireVisibleContentInBlockAfterLocator(e,t,o){let s=this.getBlockAtNode(e.element).contentnode;zo(e,s,t,o)}_removeRangeAndStitch(e,t,o,{normalize:s=!0}={}){if(t=(t||[]).slice(),s&&e.normalize(this.getBody()),e.isCollapsed())return e.start.clone();e.splitStartBoundary(t);let n=e.start.clone(),l=document.createElement("img");e.start=e.start.insertNode(l,[e.end,...t]);let r=this.getBlockAtNode(e.start.getNearestNode()),a=this.getBlockAtNode(e.end.getNearestNode()),d=null,c=a.node===e.end.getNearestNode(),u=e.getAncestorElement();r.contentnode!==a.contentnode?d=new f(a.contentnode,"end"):d=new f(e.end.element,"end");let h=A(u,[{locator:e.start,toward:"start"},{locator:e.end,toward:"end"},{locator:d,toward:"end"}],t);t=t.concat(h),t.push(n),ce(h[1],t);let m=f.newPointingTo(l);if(m.removeNode(t),!c&&!h[2].start.equals(h[2].end)){let p=h[2].start.clone();p.descendToLeafNode(this.getBody());let k=this.getBlockAtNode(p.getNearestNode());e=y.fromNodeInner(k.contentnode),e.intersect(h[2]);let N=Xe(e,m,h);e=new y(N.afterlocator,h[2].end),e.start.ascend(u,!0,!0),ce(e,t)}else this.requireVisibleContentInBlockAfterLocator(m,t,o);return m=this._correctWhitespaceAroundLocator(m,o),e.start.assign(m),e.end.assign(m),m}appendNodeContentsAfterRemove(e,t){let o=Je(t);return Ce(o,e,[]),e}_correctWhitespaceAroundLocator(e,t){[3,4].includes(e.getNearestNode().nodeType)&&(e=Uo(e,null,t));let o=e.clone();if(o.scanBackward(this.getBody(),{}).type==="whitespace"&&Bt(this.getBody(),o,[e],t),!o.equals(e)){let n=e.clone();n.scanForward(this.getBody(),{}).type==="whitespace"&&Bt(this.getBody(),n,[e],t)}return e}replaceRangeWithNode(e,t,o){return t&&e.insertBefore(t,[],o),this._removeRangeAndStitch(e,null,o)}replaceSelectionWithNode(e,t){let o=this.getUndoLock(),s=this.replaceRangeWithNode(this.getSelectionRange(),e,o.undoitem);t?this.selectNodeOuter(e):this.setCursorAtLocator(s),o.close()}executeSoftEnter(){let e=this.getSelectionRange(),t=this.getUndoLock(),o=e.isCollapsed(),s=document.createElement("br");e.insertBefore(s,[],t.undoitem);let n;return o?(this.requireVisibleContentInBlockAfterLocator(e.start,null,t.undoitem),n=this._correctWhitespaceAroundLocator(e.start,t.undoitem)):n=this._removeRangeAndStitch(e,null,t.undoitem),n=this._correctWhitespaceAroundLocator(n,t.undoitem),this.setCursorAtLocator(n),t.close(),this.stateHasChanged(),!1}executeHardEnter(){let e=this.getSelectionRange(),t=P(e.start.element,["blockquote","th","td"],this.getBody()),o;for(;t&&t.nodeName.toLowerCase()==="blockquote";)o=t,t=P(t.parentNode,["blockquote","th","td"],this.getBody());if(o){let s=this.getUndoLock(),n=A(o.parentNode,[{locator:e.start,toward:"end"}],e,s.undoitem);
34return n[1].start.insertNode(document.createElement("br"),[],s.undoitem),this.setCursorAtLocator(n[1].start),s.close(),this.stateHasChanged(),!1}return!0}ReplaceSelection(e,t){let o=this.getSelectionRange(),s=this.getUndoLock(),n=o;e||(e=f.findCommonAncestorElement(n.start,n.end));let l=[{locator:n.start,toward:"start"}];(n.start.element!==n.end.element||n.start.offset!==n.end.offset)&&l.push({locator:n.end,toward:"end"});let r=A(e,l,s.undoitem),a=r[0].end.element;for(;a.parentNode&&a.parentNode!==e;)a=a.parentNode;let d=r[r.length-1].start.element;for(;d.parentNode&&d.parentNode!==e;)d=d.parentNode;if(!(a.parentNode!==e||d.parentNode!==e)){if(a!==d)for(;a.nextSibling&&a.nextSibling!==d;)a.parentNode.removeChild(a.nextSibling);a!==d&&a.nextSibling!==d||(d.parentNode.insertBefore(t,d),this.selectNodeOuter(t),s.close())}}insertImage(e,t,o){let s=E("img",{src:e,class:"wh-rtd__img"});t&&o&&(s.height=o,s.width=t),this.replaceSelectionWithNode(s,!0),this.stateHasChanged()}insertHyperlink(e,t){this._surroundSelection({element:"a",wrapin:!0,attrs:{href:e,target:t&&t.target?t.target:null},splitprohibits:[],avoidwhitespace:!0}),this.stateHasChanged(),this._checkDirty()}removeHyperlink(){let e=this.getSelectionRange();if(e.isCollapsed()){let t=new f(e.getAncestorElement()).getPathFromAncestor(this.getBody()),o;for(o=t.length-1;o>=0;--o)if(t[o].nodeName.toLowerCase()==="a"){this.selectRange(y.withinNode(t[o]));break}if(o===-1)return}this._surroundSelection({element:"a",wrapin:!1,splitprohibits:[]})}insertTable(e,t){if(e<=0||t<=0)return;let o=this.getBody(),s=this.getSelectionRange();if(!s)return;let n=this.getUndoLock(),l=s.start.element;if(l===o)l=o.firstChild;else for(;l.parentNode!==o;)l=l.parentNode;let r=s.end.element;if(r===o)r=o.lastChild;else for(;r.parentNode!==o;)r=r.parentNode;r=r.nextSibling;let a=document.createElement("table");a.appendChild(document.createElement("tbody"));for(let d=0;d<t;++d){let c=a.lastChild.appendChild(document.createElement("tr"));for(let u=0;u<e;++u)c.appendChild(document.createElement("td")).appendChild(document.createTextNode(u+1+","+(d+1)))}o.insertBefore(a,r),this.stateHasChanged(),n.close()}_undo(){}_redo(){}_clearFormatting(){let e=this.getBody();this.setContentsHTML(Ls(e,!0)),this.stateHasChanged()}_registerFrameEventListeners(){this.bodydiv.__wh_rte_doneevents||(this.bodydiv.__wh_rte_doneevents=!0,this.bodydiv.addEventListener("focus",this.onFocus.bind(this)),this.bodydiv.addEventListener("focusin",this.onFocusIn.bind(this)),new bo(this.bodydiv,{"Accel+Alt+1":e=>this._onStyleSwitch(e,1),"Accel+Alt+2":e=>this._onStyleSwitch(e,2),"Accel+Alt+3":e=>this._onStyleSwitch(e,3),"Accel+Alt+4":e=>this._onStyleSwitch(e,4),"Accel+Alt+5":e=>this._onStyleSwitch(e,5),"Accel+Alt+6":e=>this._onStyleSwitch(e,6),"Accel+Alt+7":e=>this._onStyleSwitch(e,7),"Accel+Alt+8":e=>this._onStyleSwitch(e,8),"Accel+Alt+9":e=>this._onStyleSwitch(e,9),"Accel+Alt+0":e=>this._onStyleSwitch(e,0)}),this.bodydiv.addEventListener("keydown",this._gotKeyDown.bind(this)),this.bodydiv.addEventListener("keypress",this._gotKeyPress.bind(this)),this.bodydiv.addEventListener("keyup",this._gotKeyUp.bind(this)),this.bodydiv.addEventListener("mousedown",this._gotMouseDown.bind(this)),this.bodydiv.addEventListener("click",this._gotMouseClick.bind(this)),this.bodydiv.addEventListener("paste",this._gotPaste.bind(this)),this.bodydiv.addEventListener("copy",this._gotCopy.bind(this)),this.bodydiv.addEventListener("cut",this._gotCut.bind(this)),this.bodydiv.addEventListener("dblclick",this._gotDoubleClick.bind(this)),z()==="firefox"&&this.bodydiv.addEventListener("DOMNodeRemoved",this._gotDOMNodeRemoved.bind(this)))}_getImageDownloadURL(){return this.options.imgloadplaceholder||An}_createImageDownloadNode(){return E("img",{class:"wh-rtd__img wh-rtd__img--uploading",src:this._getImageDownloadURL()})}_isStillImageDownloadNode(e){return e.matches(".wh-rtd__img--uploading")}_gotPaste(e){g.rte&&console.log("[rte] paste",this,e),this.gotPaste(e)}gotPaste(e){let t=this.qSA("style");setTimeout(()=>this.handlePasteDone(t),1)}async handlePasteDone(e){this.qSA("script,style,head").filter(s=>
34!e.includes(s)).forEach(s=>s.remove());let t=this.qSA("img");if(t=t.filter(s=>!this.knownimages.includes(s.src)&&!this._isStillImageDownloadNode(s)&&s.isContentEditable).filter(s=>!s.closest(".wh-rtd-embeddedobject")),!t.length)return;let o=Z();try{let s=[];for(let n of t){let l=n.src;n.src=this._getImageDownloadURL(),n.classList.add("wh-rtd__img--uploading"),s.push(Ee().getImgFromRemoteURL(l).then(r=>this._handleUploadedRemoteImage(n,r)).catch(r=>this._handleUploadedRemoteImage(n,null)))}await Promise.all(s)}finally{o.release()}}_handleUploadedRemoteImage(e,t){e.classList.remove("wh-rtd__img--uploading"),t?(e.src=t,e.removeAttribute("width"),e.removeAttribute("height"),this.knownimages.push(e.src)):e.remove()}DelayedSurroundSelection(e){if(this.getSelectionRange().isCollapsed()){for(let t=0;t<this.delayedsurrounds.length;++t){let o=this.delayedsurrounds[t];if(o.element===e.element){if(o.wrapin===e.wrapin)return;this.delayedsurrounds.splice(t,1),this.stateHasChanged();return}}this.delayedsurrounds.push(e),this.stateHasChanged()}else this._surroundSelection(e)}ClearDelayedSurrounds(){for(;this.delayedsurrounds.length;)this.delayedsurrounds.pop()}_createNodeFromElementInfo(e){let t=document.createElement(e.element);if(e.attrs){let o=Object.keys(e.attrs).sort();for(let s=0;s<o.length;++s)e.attrs[o[s]]!==null&&t.setAttribute(o[s],e.attrs[o[s]])}return t}_canWrapNode(e,t){return I(t)?e.splitblockelements===!0:!(e.splitprohibits&&e.splitprohibits.includes(t.nodeName.toLowerCase()))}surroundRange(e,t){Oo(e,this.getBody(),t.element,null),t.wrapin&&Fo(e,()=>this._createNodeFromElementInfo(t),{onCanWrapNode:o=>this._canWrapNode(t,o)})}_surroundSelection(e){let t=this.getUndoLock(),o=this.getSelectionRange();if(e.avoidwhitespace){for(;o.start.element.nodeType===3&&o.start.element.textContent[o.start.offset]===" "&&o.start.compare(o.end)<0;)++o.start.offset;for(;o.end.element.nodeType===3&&o.end.element.textContent[o.end.offset-1]===" "&&o.start.compare(o.end)<0;)--o.end.offset}this.surroundRange(o,e),this.selectRange(o),t.close()}selectionHasChanged(e){}stateHasChanged(){this.lastselectionstate=this.getFormattingStateForRange(this.getSelectionRange()),this.updateTableEditors(),this._gotStateChange()}getSelectionState(e){return e&&(this.lastselectionstate=this.getFormattingStateForRange(this.getSelectionRange()),this.updateTableEditors()),this.lastselectionstate}getTextStyleRecordFromNode(e){let t=e.nodeName.toLowerCase();return t==="strong"?t="b":t==="em"?t="i":t==="a"&&e.hasAttribute("href")&&(t="a-href"),t==="b"&&e.style.fontWeight==="normal"?null:{nodeName:t}}getAvailableBlockStyles(e){return[]}getAvailableCellStyles(e){return[]}getFormattingStateForRange(e){y.getLogLevel()&16&&console.log("gFSR received range",e,e.start,e.end);let t=new ye;if(!e)return t;e=e.clone();let o="";t.haveselection=!e.isCollapsed();let s=e.start.clone();y.getLogLevel()&16&&console.log("selected before ascend",_(e.getAncestorElement(),e));let n=s.element&&s.getNearestNode();for(let b=n;b&&b!==this.bodydiv;b=b.parentNode){switch(b.nodeName.toUpperCase()){case"B":case"STRONG":case"I":case"EM":case"U":case"SUP":case"SUB":case"STRIKE":{let w=this.getTextStyleRecordFromNode(b);w&&t.textstyles.push(w)}break;case"A":t.textstyles.push(this.getTextStyleRecordFromNode(b)),t.hyperlink=!0;break;case"UL":t.bulletedlist=!0;break;case"OL":t.numberedlist=!0;break;case"CENTER":o=o||"center";break;case"TABLE":t.tables.push(b),t.tablestyle=this.structure?.lookupTableStyle(b)||null;break}b.getAttribute&&b.getAttribute("align")?o=o||b.getAttribute("align"):b.style&&b.style.textAlign&&(o=o||b.style.textAlign)}o=o||"left",t.alignleft=o==="left",t.aligncenter=o==="center",t.alignright=o==="right",t.alignjustified=o==="justified";let l=e.querySelectorAll("*");l=l.filter(b=>b.isContentEditable||oe(b)&&b.parentNode.isContentEditable);for(let b=e.getAncestorElement();b&&b!==this.bodydiv;b=b.parentNode)l.push(b);y.getLogLevel()&16&&console.log("all gfsfr relevantnodes",l);for(let b=0;b<l.length;++b){let w=l[b];switch(w.nodeName.toUpperCase()){case"A":t.hyperlink=!0;break;case"UL":t.bulletedlist=!0;break;case"OL":t.numberedlist=!0;break;case"DIV":w.classList.contains("wh-rtd-embeddedobject")&&(t.isblockwidget=!0);break;case"SPAN":w.classList.contains("wh-rtd-embeddedobject")&&(t.isinlinewidget=!0);break}!t.propstarget&&w.matches(this.properties_selector)&&(t.propstarget=w)}for(let b=0;b<this.delayedsurrounds.length;++b){let w=this.delayedsurrounds[b],x=!1;for(let O=0;O<t.textstyles.length;++O)if(t.textstyles[O].nodeName===w.element){t.textstyles.splice(O,1),x=!0;break}w.wrapin&&t.textstyles.push({nodeName:w.element})}let r=this.getAvailableListActions(e),a=P(n,["ol","ul","td","th"],this.getBody());t.actionparent=a;let d=e.end.clone();d.scanBackward(this.getBody(),{blocks:!0,alwaysvisibleblocks:!0}),e.start.compare(d)>0&&(d=e.start);let c=this.getBlockAtNode(e.start.element).contentnode,u=this.getBlockAtNode(d.element).contentnode,h=P(n,["td","th"],this.getBody());t.cellparent=h;let m=c===u&&h,p=m&&le(h.closest("table")),k=p&&p.getActionState(h),N=!t.tablestyle||t.tablestyle?.allowwidgets;return t.actionstate={"li-increase-level":{available:r.canincrease},"li-decrease-level":{available:r.candecrease},"a-href":{available:!e.isCollapsed()||t.hyperlink},img:{available:!0},"action-properties":{available:t.propstarget},"object-insert":{available:N},"object-video":{available:N},b:{available:!0,active:t.hasTextStyle("b")},i:{available:!0,active:t.hasTextStyle("i")},u:{available:!0,active:t.hasTextStyle("u")},strike:{available:!0,active:t.hasTextStyle("strike")},sub:{available:!0,active:t.hasTextStyle("sub")},sup:{available:!0,active:t.hasTextStyle("sup")},ol:{available:!0,active:a&&a.nodeName.toLowerCase()==="ol"},ul:{available:!0,active:a&&a.nodeName.toLowerCase()==="ul"},"table-addrow-before":{available:m},"table-addrow-after":{available:m},"table-addpara-before":{available:m},"table-addpara-after":{available:m},"table-addcolumn-before":{available:m},"table-addcolumn-after":{available:m},"table-deleterow":{available:m&&p&&p.numrows!==1},"table-deletecolumn":{available:m&&p&&p.numcolumns!==1},"table-mergeright":k&&k["table-mergeright"]||{available:!1},"table-mergedown":k&&k["table-mergedown"]||{available:!1},"table-splitcols":k&&k["table-splitcols"]||{available:!1},"table-splitrows":k&&k["table-splitrows"]||{available:!1}},this.options.allowtags&&this._stripDisallowedTags(t),t}_isActionAllowed(e){if(!this.options.allowtags)return!0;let t=[{name:"img",requiretags:["img"]},{name:"a-href",requiretags:["a"]},{name:"remove_hyperlink",requiretags:["a"]},{name:"anchor",requiretags:["a"]},{name:"insert_table",requiretags:["table","tr","td"]},{name:"ul",requiretags:["ul","li"]},{name:"ol",requiretags:["ol","li"]},{name:"li-increase-level",requiretags:["li"]},{name:"li-decrease-level",requiretags:["li"]},{name:"b",requiretags:["b"]},{name:"u",requiretags:["u"]},{name:"i",requiretags:["i"]},{name:"strike",requiretags:["strike"]},{name:"sub",requiretags:["sub"]},{name:"sup",requiretags:["sup"]}],o;for(let s=0;s<t.length;++s)if(t[s].name===e){o=t[s];break}if(o){for(let s=0;s<o.requiretags.length;++s)if(!this.options.allowtags.includes(o.requiretags[s]))return!1}return!0}_stripDisallowedTags(e){e&&this.options.allowtags&&Object.keys(e.actionstate).forEach(t=>{this._isActionAllowed(t)||(e.actionstate[t].available=!1)})}async _gotCopy(e){}async _gotCut(e){this.scheduleCallbackOnInputOrDelay(this.checkDomStructure.bind(this),"checkdom")}_gotSelectionChange(e){if(this.selectingrange)return;let{changed:t,range:o}=this._constrainRangeCrossTDSelections(this.getSelectionRange());t&&this.selectRange(o)}_gotDOMNodeRemoved(e){e.relatedNode===this.getBody()&&this.scheduleCallbackOnInputOrDelay(this.checkDomStructure.bind(this),"checkdom")}SubtreeModified(e){this.insubtreemod||(this.insubtreemod=!0,this.CleanupChildren(e),this.insubtreemod=!1)}checkDomStructure(e,t){}tableEditorStateHasChanged(){this.tableeditorstatechangedelay||(this.tableeditorstatechangedelay=setTimeout(()=>{this.tableeditorstatechangedelay=null,this.stateHasChanged()},0))}initializeTableEditor(e,t){let o=le(e);
34if(o){o.updateResizers();return}let s={onStatechange:this.tableEditorStateHasChanged.bind(this),getUndoLock:()=>this.getUndoLock()};s.resize_columns=!0,s.resize_rows=!0,s.resize_table=!0,o=new et(e,this.getBody(),s),this.tableeditors.push(o)}_getResizingOptionsForTable(e){return["all"]}_getEditableTables(){let e=[];for(let t of this.qSA("table")){if(!t.isContentEditable)continue;let o=this._getResizingOptionsForTable(t);o&&e.push({node:t,tableresizing:o})}return e}updateTableEditors(){this._getEditableTables().forEach(t=>this.initializeTableEditor(t.node,t.tableresizing)),this.tableeditors=this.tableeditors.filter(t=>{let o=t.isActive();return o||t.destroy(),o}),this.__updateTableEditorsSetupDone||(this.__updateTableEditorsSetupDone=!0,document.fonts&&"onloadingdone"in document.fonts?(this.fontslistener=this.updateTableEditors.bind(this),document.fonts.addEventListener("loadingdone",this.fontslistener)):this.repeatupdatetableuntil=Date.now()+5e3),this.repeatupdatetableuntil&&Date.now()<this.repeatupdatetableuntil&&!this.scheduledupdatetableeditors&&(this.scheduledupdatetableeditors=!0,this.repeatupdatetabletimeout=setTimeout((function(){this.repeatupdatetableanimframe=requestAnimationFrame(this.rescheduledUpdateTableEditors.bind(this))}).bind(this),200))}rescheduledUpdateTableEditors(){this.scheduledupdatetableeditors=!1,this.updateTableEditors()}_executeDeleteByKey(e){return!1}_handleKeyCommand(e,t){for(let o of t)switch(o){case"Accel+A":e.preventDefault(),e.stopPropagation(),this.SelectAll();return;case"Accel+B":e.preventDefault(),e.stopPropagation(),this.executeAction("b");return;case"Accel+I":e.preventDefault(),e.stopPropagation(),this.executeAction("i");return;case"Accel+U":e.preventDefault(),e.stopPropagation(),this.executeAction("u");return;case"Accel+K":e.preventDefault(),e.stopPropagation(),this.executeAction("a-href");return;case"Shift+Enter":e.preventDefault(),e.stopPropagation(),this.executeSoftEnter();return;case"Enter":if(!this.executeHardEnter()){e.preventDefault(),e.stopPropagation();return}break;case"Tab":case"Shift+Tab":e.stopPropagation();break;case"Delete":if(this._executeDeleteByKey(!0)){e.preventDefault(),e.stopPropagation();return}break;case"Backspace":if(this._executeDeleteByKey(!1)){e.preventDefault(),e.stopPropagation();return}break;case"F2":{this._inspectCursorPosition(),e.preventDefault(),e.stopPropagation();return}}}_inspectCursorPosition(){let e=this.getSelectionRange(),t=e.start,o=e.end,s=t.scanForward(this.getBody(),{}),n=o.scanBackward(this.getBody(),{}),l=e.start.clone();l.moveRight(this.getBody());let r=e.end.clone();r.moveLeft(this.getBody()),console.log("inspectres",_(this.getBody(),{range:e,b:t,e:o,br:l,el:r},{indent:1}),s,n),console.log({b:t,e:o,br:l,el:r})}_onStyleSwitch(e,t){}_gotKeyDown(e){if(!this.hasFocus()){e.preventDefault(),console.log("Received keydown without having focus");return}return z()==="firefox"&&this._gotSelectionChange(null),this._detectedInputEvent(e),this._handleKeyCommand(e,wo(e)),setTimeout(()=>{this._gotSelectionChange(e),this.stateHasChanged()},1),!0}_gotKeyPress(e){let t=Le(e);if(t.ctrlKey||(this._gotSelectionChange(e),t.key==="Enter"))return;this.checkDomStructure();let o=this.getSelectionRange();if(this.delayedsurrounds.length)if(!o.isCollapsed()||t.key.length!==1)this.ClearDelayedSurrounds();else{this.insertTextAtCursor(t.key);for(let s=0;s<this.delayedsurrounds.length;++s)this._surroundSelection(this.delayedsurrounds[s]);this.ClearDelayedSurrounds(),this.collapseSelection(),e.preventDefault(),e.stopPropagation();return}return!0}_gotKeyUp(e){return Le(e).key!=="Enter"&&this.ClearDelayedSurrounds(),this._gotSelectionChange(e),this.stateHasChanged(),!0}_gotMouseDown(e){return this.ClearDelayedSurrounds(),e.target.matches("img, .wh-rtd-embeddedobject")&&this.selectNodeOuter(e.target),this._gotSelectionChange(e),this.stateHasChanged(),window.setTimeout(()=>{this._gotSelectionChange(e),this.stateHasChanged()},1),window.addEventListener("mouseup",this._mouseupcallback),!0}_gotMouseUp(e){window.removeEventListener("mouseup",this._mouseupcallback),this.ClearDelayedSurrounds(),window.setTimeout(()=>{this._gotSelectionChange(e),this.stateHasChanged()},1)}_gotMouseClick(e){}_gotDoubleClick(e){!e.target||!this.isEditable()||(e.target&&e.target.nodeName.toUpperCase()==="IMG"&&(this.selectNodeOuter(e.target),this.executeAction("action-properties")),e.stopPropagation(),e.preventDefault())}setInputEventAttach(e){this.attachedinputevents!==e&&(this.inputeventfunction||(this.inputeventfunction=this._detectedInputEvent.bind(this)),e?(document.addEventListener("selectionchange",this.inputeventfunction),this.getBody().addEventListener("input",this.inputeventfunction)):(document.removeEventListener("selectionchange",this.inputeventfunction),this.getBody().removeEventListener("input",this.inputeventfunction)),this.attachedinputevents=e)}scheduleCallbackOnInputOrDelay(e,t){if(this.activeinputhandler!==t){for(let o=0;o<this.oninputhandlers.length;++o)if(this.oninputhandlers[o].name===t)return;this.oninputhandlers.length||(this.setInputEventAttach(!0),this._delayedDetectedInputEvent(null)),this.oninputhandlers.push({name:t,callback:e})}}_delayedDetectedInputEvent(e){e?Promise.resolve(!0).then(()=>this._detectedInputEvent(e)):setTimeout(()=>this._detectedInputEvent(null),1)}_detectedInputEvent(e){if(!this.selectingrange&&this.oninputhandlers.length){let t=this.oninputhandlers.slice();this.oninputhandlers=[],this.setInputEventAttach(!1);for(let o=0;o<t.length;++o)this.activeinputhandler=t[o].name,t[o].callback();this.activeinputhandler=""}}setShowFormatting(e){this.getBody().classList.toggle("wh-rtd-formatting",!!e),this.stateHasChanged()}getShowFormatting(){return this.getBody().classList.contains("wh-rtd-formatting")}executeDefaultPropertiesAction(e){if(e.target.nodeName==="A"){let t=prompt(this.GetLanguageText("prompt_hyperlink"),e.target.href);t&&(e.target.href=t);return}}async newUploadInsertImage(){var s=[];try{let e=bt(s,Z());void 0;let t=await ko({accept:["image/png","image/jpeg","image/gif"]});if(!t)return;let o=this._createImageDownloadNode();this.replaceSelectionWithNode(o,!0);this.uploadImageToServer(t,o)}catch(n){var l=n,r=!0}finally{wt(s,l,r)}}async uploadImageToServer(e,t){var n=[];try{let o=bt(n,Z());void 0;let s=await Ee().getUploadedFileFinalURL(await vo(e));t.src=s;this.knownimages.push(t.src);t.classList.add("wh-rtd__img");t.removeAttribute("width");t.removeAttribute("height");await fo(t.src)}catch(l){var r=l,a=!0}finally{wt(n,r,a)}}launchActionPropertiesForNode(e,t){let o={action:"action-properties",actiontarget:{__node:e},subaction:t,rte:this};B(e,"wh:richeditor-action",{bubbles:!0,cancelable:!0,detail:o})&&this.executeDefaultPropertiesAction({target:e,detail:o})}executeAction(e,t){if(typeof e=="string"&&(e={action:e}),!this._isActionAllowed(e.action))return;let o=this.container;if(t)e.actiontargetinfo=t;else if(e){if(!e.action)throw new Error("Expected an 'action' value");
34if(e.rte=this,e.action==="a-href"&&this.getSelectionState().hyperlink&&(e.action="action-properties"),e.action==="action-properties"){let s=this.getSelectionState();if(!s.propstarget)return;o=s.propstarget,e.actiontarget={__node:o}}}if(B(o,"wh:richeditor-action",{bubbles:!0,cancelable:!0,detail:e}))switch(e.action){case"img":this.newUploadInsertImage();break;case"a-href":{let s=prompt(this.GetLanguageText("prompt_hyperlink"),"http://");this.takeFocus(),s&&this.insertHyperlink(s)}break;case"remove_hyperlink":this.RemoveHyperlink();break;case"table":if(!e.size)throw new Error("Expected size param for table action");this.insertTable(e.size.x,e.size.y);break;case"ul":this._toggleBulletedList();break;case"ol":this._toggleNumberedList();break;case"li-increase-level":this.addListLevel();break;case"li-decrease-level":this.removeListLevel();break;case"align_left":case"align_center":case"align_right":case"align_justified":this._setAlignment(e.action.substr(6));break;case"undo":this._undo();break;case"redo":this._redo();break;case"action-clearformatting":confirm(this.GetLanguageText("messages_confirmclearformatting"))&&this._clearFormatting();break;case"action-showformatting":this.setShowFormatting(!this.getShowFormatting());break;case"action-properties":this.executeDefaultPropertiesAction({target:o,detail:e});break;case"b":case"u":case"i":case"strike":this.applyTextStyle(e.action,!this.getSelectionState().hasTextStyle(e.action));break;case"sub":case"sup":this.getSelectionState().hasTextStyle(e.action)||this.applyTextStyle(e.action==="sub"?"sup":"sub",!1),this.applyTextStyle(e.action,!this.getSelectionState().hasTextStyle(e.action));break;case"table-addpara-before":case"table-addpara-after":{let n=this.getSelectionState().actionparent.closest("table");this.insertEmptyParagraph(n,e.action==="table-addpara-after")}break;case"table-addrow-before":case"table-addrow-after":case"table-addcolumn-before":case"table-addcolumn-after":case"table-deletecolumn":case"table-deleterow":case"table-mergeright":case"table-mergedown":case"table-splitcols":case"table-splitrows":{let s=this.getSelectionState().actionparent,n=s.closest("table"),l=le(n);switch(e.action){case"table-addrow-before":case"table-addrow-after":l.insertRows(s,e.action==="table-addrow-before",1,s.offsetHeight,{newcell_callback:this._initNewTableCell.bind(this)});break;case"table-addcolumn-before":case"table-addcolumn-after":l.insertColumns(s,e.action==="table-addcolumn-before",1,32,{newcell_callback:this._initNewTableCell.bind(this)});break;case"table-deleterow":l.deleteRows(s,1);break;case"table-deletecolumn":l.deleteColumns(s,1);break;case"table-mergeright":l.mergeRight(s);break;case"table-mergedown":l.mergeDown(s);break;case"table-splitcols":l.splitCols(s);break;case"table-splitrows":l.splitRows(s);break}break}}}_initNewTableCell(e){}_getLangTexts(){return this._langtexts||(this._langtexts={en:{buttonbar_bold:"Bold",buttonbar_italic:"Italic",buttonbar_underline:"Underline",buttonbar_insert_image:"Insert Image",buttonbar_insert_hyperlink:"Insert Hyperlink",buttonbar_remove_hyperlink:"Remove Hyperlink",buttonbar_anchor:"Bookmark",buttonbar_insert_table:"Insert Table",buttonbar_bulleted_list:"Bulleted List",buttonbar_numbered_list:"Numbered List",buttonbar_align_left:"Align left",buttonbar_align_center:"Center",buttonbar_align_right:"Align right",buttonbar_align_justified:"Justify",buttonbar_undo:"Undo",buttonbar_redo:"Redo",buttonbar_clear_formatting:"Clear Formatting",prompt_hyperlink:"Hyperlink URL",messages_openlink:"%1<br/><b>Shift + click to open in a new window</b>",messages_anchor:"Bookmark #%1",messages_confirmclearformatting:`Are you sure you want to discard all style? 35 36This operation cannot be undone.`,messages_confirmclearcontents:`Are you sure you want to delete all contents? 37 38This operation cannot be undone.`},nl:{buttonbar_bold:"Vet",buttonbar_italic:"Cursief",buttonbar_underline:"Onderstrepen",buttonbar_insert_image:"Afbeelding invoegen",buttonbar_insert_hyperlink:"Hyperlink invoegen",buttonbar_remove_hyperlink:"Hyperlink verwijderen",buttonbar_anchor:"Bladwijzer",buttonbar_insert_table:"Tabel invoegen",buttonbar_bulleted_list:"Lijst met opsommingstekens",buttonbar_numbered_list:"Genummerde lijst",buttonbar_align_left:"Links uitlijnen",buttonbar_align_center:"Centreren",buttonbar_align_right:"Rechts uitlijnen",buttonbar_align_justified:"Uitvullen",buttonbar_undo:"Ongedaan maken",buttonbar_redo:"Opnieuw",buttonbar_clear_formatting:"Opmaak verwijderen",prompt_hyperlink:"URL voor de hyperlink",messages_openlink:"%1<br/><b>Shift + klik om in een nieuw venster te openen</b>",messages_anchor:"Bladwijzer #%1",messages_confirmclearformatting:`Weet u zeker dat u alle opmaak wilt verwijderen? 39 40Deze operatie kan niet ongedaan gemaakt worden.`,messages_confirmclearcontents:`Weet u zeker dat u alle inhoud wilt verwijderen? 41 42Deze operatie kan niet ongedaan gemaakt worden.`}}
42),this._langtexts}GetLanguageText(e,t,o){let s=this._getLangTexts();return s[this.language]&&s[this.language][e]?s[this.language][e].split("%1").join(t).split("%2").join(o):""}requireBottomParagraph(){}getAvailableStyles(e){let t=this.getEditor();return t?t.getAvailableBlockStyles(e):[]}},ye=class{hyperlink=!1;bulletedlist=!1;numberedlist=!1;alignleft=!1;aligncenter=!1;alignright=!1;alignjustified=!1;haveselection=!1;isblockwidget=!1;isinlinewidget=!1;textstyles=[];propstarget=null;actionstate={};actionparent=null;tables=[];tablestyle=null;blockstyle=null;cellparent=null;hasTextStyle(e){return this.getTextStyleByNodeName(e)!==null}getTextStyleByNodeName(e){for(let t=0;t<this.textstyles.length;++t)if(this.textstyles[t].nodeName===e)return this.textstyles[t];return null}};q.TextFormattingState=ye});ho();xe();Ft();yo();V();qe();ee();function Zo(i,e){let t=!1;for(let o=i.length-1;!t&&o>=0;--o)if(i[o].contains(e)){i.splice(o+1,i.length-o-1),t=!0;break}return t||i.splice(0,i.length),i.push(e),t}function st(i,e){i=i.clone();let t=P(i.start.getNearestNode(),"li",e);t&&i.start.assign(f.newPointingTo(t));let o=P(i.end.getNearestNode(),"li",e);if(o)if(o===t)i.end.assign(f.newPointingAfter(t));else{i.end.ascend(e,!1);let a=f.newPointingTo(o),d=f.newPointingAfter(o);i.end.compare(a)>0&&(i.end=d)}let s=Array.from(i.querySelectorAll("li")),n=[],l=[],r=[];for(let a=0;a<s.length;++a)if(s[a].isContentEditable){if(s[a].previousSibling){if(s[a].previousSibling.nodeType!==1||s[a].previousSibling.nodeName.toLowerCase()!=="li")continue}else{let d=f.newPointingTo(s[a].parentNode);if(d.moveToPreviousBlockBoundary(s[a].parentNode.parentNode,!0),d=d.getPointedNode(),!d||d===s[a].parentNode||d.nodeName.toUpperCase()!=="UL"&&d.nodeName.toUpperCase()!=="OL")continue}t&&s[a]!==t&&s[a].contains(t)||Zo(r,s[a])||n.push(s[a])}r=[];for(let a=0;a<s.length;++a)s[a].isContentEditable&&P(s[a].parentNode,"li",e)&&(s[a]!==t&&s[a].contains(t)||Zo(r,s[a])||l.push(s[a]));return{addable:n,removeable:l}}var jt=class{blockstyles=[];cellstyles=[];defaultorderedliststyle=null;defaultunorderedliststyle=null;defaulttablestyle=null;defaultblockstyle=null;constructor(e){this.parseBlockStyles(e.blockstyles),e.cellstyles&&this.parseCellStyles(e.cellstyles);for(let t=0;t<this.blockstyles.length;++t){let o=this.blockstyles[t];o.listtype==="ordered"&&(this.defaultorderedliststyle=this.defaultorderedliststyle||o),o.listtype==="unordered"&&(this.defaultunorderedliststyle=this.defaultunorderedliststyle||o),o.istable&&(this.defaulttablestyle=this.defaulttablestyle||o)}if(!e.defaultblockstyle)throw Error("Required field 'defaultblockstyle' not defined in structure");if(this.defaultblockstyle=this.getBlockStyleByTag(e.defaultblockstyle),!this.defaultblockstyle)throw Error("Block style named by 'defaultblockstyle' does not exist in structure")}parseCellStyles(e){for(let t of e)this.cellstyles.push({tag:t.tag.toLowerCase(),def:t})}getClassStyleForCell(e){for(let t of this.cellstyles)if(t.tag&&e.classList&&e.classList.contains(t.tag))return t.tag;return""}parseBlockStyles(e){for(let t=0;t<e.length;++t){let o=e[t],s=o.tag.toLowerCase(),n=o.containertag.toLowerCase(),l={classname:s,def:o,tag:o.tag,istable:o.type==="table",tabledefaultblockstyle:null,islist:["ul","ol"].includes(n),listtype:n==="ul"?"unordered":n==="ol"?"ordered":"",importfrom:[],nextblockstyle:null,allowstyles:[],allowwidgets:o.type==="table"&&o.allowwidgets!==!1}
42;o.importfrom&&l.importfrom.push(...o.importfrom),this.blockstyles.push(l)}for(let t=0;t<this.blockstyles.length;++t){let o=e[t],s=this.blockstyles[t];if(s.nextblockstyle=o.nextblockstyle?this.getBlockStyleByTag(o.nextblockstyle):null,!s.nextblockstyle&&s.islist&&(s.nextblockstyle=s),o.type==="table"){if(o.tabledefaultblockstyle){let n=this.getBlockStyleByTag(o.tabledefaultblockstyle);if(!n)throw Error("Block style named by table 'defaultstyle' does not exist in structure");s.tabledefaultblockstyle=n}for(let n of o.allowstyles??[]){let l=this.getBlockStyleByTag(n);if(!l)throw Error("Block style named by table 'allowedstyle' does not exist in structure");s.allowstyles.push(l)}}}}getBlockStyleByTag(e){for(let t=0;t<this.blockstyles.length;++t)if(this.blockstyles[t].tag.toUpperCase()===e.toUpperCase())return this.blockstyles[t];return null}lookupTableStyle(e){let t=this.getBlockStyleByTag(e.className.split(" ")[0]);return t&&t.istable?t:this.defaulttablestyle}},$o=jt;Re();ot();ee();gt();ee();var Fe=class{data;constructor(){this.data=null}applyCleanup(e){this.data=e;let t={breakafter:null},o=[];for(let l=0;l<o.length;++l){let r=o[l];for(;r!==this.data&&r.parentNode&&!r.firstChild;){let a=r.parentNode;a.removeChild(r),r=a}}let s=this.data.querySelectorAll("*");for(let l=s.length-1;l>=0;--l)if(["p","h1","h2","h3","h4","h5","h6","ol","ul","li"].includes(s[l].nodeName.toLowerCase())){let r=s[l];new f(r,0).scanForward(r,{whitespace:!0}).type==="outerblock"&&s[l].remove()}let n=this.data.querySelectorAll("li");for(let l=0;l<n.length;++l){let r=n[l].parentNode;if(!["ol","ul"].includes(r?.nodeName.toLowerCase()||"")){let a=n[l],d=[];for(;a&&a.nodeType===1&&a.nodeName.toLowerCase()==="li";a=a.nextSibling)d.push(a);let c=document.createElement("ul");r?.insertBefore(c,n[l]);for(let u=0;u<d.length;++u)c.appendChild(d[u])}}return e.lastChild&&e.lastChild.nodeType===1&&e.lastChild.nodeName.toLowerCase()==="br"&&(e.removeChild(e.lastChild),t.breakafter=!0),t.breakafter===null&&(t.breakafter=!1),t}};xe();async function ro(i){let e=window.getSelection(),t={"text/html":"","text/plain":""};if(e?.rangeCount){let s=e.getRangeAt(0).cloneContents(),n=document.createElement("div");n.appendChild(s),t["text/html"]=n.innerHTML,t["text/plain"]=e.toString()}await navigator.clipboard.write([new ClipboardItem(t)])}gt();var ke=L["rte-icc"];function _n(i){let e=[],t=[];for(let o of i)["block","table","list","br"].includes(o.type)||o.type==="embeddedobject"&&o.embedtype!=="inline"?(t.length&&(e.push({inline:t}),t=[]),e.push({block:o})):t.push(o);return t.length&&e.push({inline:t}),e}function Cn(i){for(;i.length&&i[0].type==="text"&&i[0].value[0]===" ";)i[0].value=i[0].value.substr(1),i[0].value||i.shift();for(;i.length&&i[i.length-1].type==="text"&&i[i.length-1].value.endsWith(" ");)i[i.length-1].value=i[i.length-1].value.substr(0,i[i.length-1].value.length-1),i[i.length-1].value||i.pop();for(let e=1;e<i.length;++e)i[e].type==="text"&&i[e].value[0]===" "&&i[e-1].type==="text"&&i[e-1].value.endsWith(" ")&&(i[e].value=i[e].value.substr(1));return i=i.filter(e=>!(e.type==="text"&&!e.value)),i}var je=class extends q{structure;constructor(e,t){t={structure:null,editembeddedobjects:!0,...t,allowundo:!0},super(e,t),this.properties_selector+=", div.wh-rtd-embeddedobject, span.wh-rtd-embeddedobject, .wh-rtd__tablecell, table.wh-rtd__table caption",this.textstyletags=["a-href","i","b","u","strike","span","sub","sup"],this.textstylewhitelistedattributes={"a-href":["href","target"]},this.structure=new $o(this.options.structure),this.reprocessAfterExternalSet(),this._constructorTail()}_onStyleSwitch(e,t){let o=["P","H1","H2","H3","H4","H5","H6","UL","OL","CODE"][t],s=this.getSelectionState(),n=s.blockstyle,l=this.getAvailableBlockStyles(s).filter(a=>a.def.containertag.toUpperCase()===o),r=n?l.findIndex(a=>a.classname===n.classname):-1;l.length!==0&&(M(e),this.setSelectionBlockStyle(l[(r+1)%l.length].classname))}reprocessAfterExternalSet(){this.refilterContent(!0),super.reprocessAfterExternalSet()}getAvailableBlockStyles(e){return(e?.tablestyle?.allowstyles.length?e.tablestyle?.allowstyles:this.structure.blockstyles).filter(o=>!o.istable)}getAvailableCellStyles(e){return this.structure.cellstyles}async _gotCopy(e){M(e),await ro(this)}async _gotCut(e){M(e);let t=this.getUndoLock();await ro(this),this.removeSelection(),this.checkDomStructure(),t.close()}gotPaste(e){let t=e.clipboardData;if(t&&t.getData){let o=Array.from(t.types);if(g.rte){console.log("[rte] paste",t,"types",o),t.files&&console.log("[rte] Files",t.files,"length",t.files&&t.files.length),t.items&&console.log("[rte] Items",t.items,"length",t.items&&t.items.length);for(let s=0;s<o.length;++s){let n=o[s],l=t.getData(n);console.log("[rte] type ",n,"data("+typeof l+"):","<",l,">")}}if(o.includes("text/html")){let s=t.getData("text/html");g.rte&&(console.log("[rte] Received clipboardData text/html:"),console.log("[rte] ["+s+"]"),console.log("[rte] end of clipboardData")),e.preventDefault();let n=document.createElement("div");n.innerHTML=s,this._pasteContent(n);return}else if(o.includes("Files"))for(let s=0;s<t.items.length;++s){let n=t.items[s];
42if(["image/png"].includes(n.type)){g.rte&&console.log("[rte] Got image file of type "+n.type);let l=document.createElement("div"),r=this._createImageDownloadNode();l.appendChild(r);let a=this.uploadImageToServer(n.getAsFile(),r);if(a){a.then((function(){this._pasteContent(l)}).bind(this)),e.preventDefault();return}}}else if(z()==="safari"&&o.includes("image/tiff")&&o.includes("text/uri-list")){g.rte&&console.log("[rte] Got a safari image paste");let s=t.getData("text/uri-list"),n=document.createElement("div");n.appendChild(v("img",{src:s})),this._pasteContent(n),e.preventDefault();return}else if(o.includes("text/plain")){let s=t.getData("text/plain");g.rte&&(console.log("[rte] Received clipboardData text/plain:"),console.log("[rte] ["+s+"]"),console.log("[rte] end of clipboardData")),e.preventDefault();let n=document.createElement("div");s.split(` 43`).forEach(r=>{n.appendChild(document.createTextNode(r)),n.appendChild(document.createElement("br"))}),g.rte&&(console.log("[rte] html to insert"),console.log(n.innerHTML)),this._pasteContent(n);return}}throw e.preventDefault(),new Error(`Paste detected, but no usable clipboardData (${JSON.stringify(Array.from(t?.types??["no clipboardData"]))})`)}_pasteContent(e){let t=this.getUndoLock(),o=this.removeSelection();this._pasteContentAt(e,o).finally(()=>t.close())}async _validateEmbeddedObjects(){let e=Ye(this.getBody());if(e.length===0)return;e=e.reduce((o,s)=>((!o.length||!o[o.length-1].contains(s))&&o.push(s),o),[]);let t=Z();try{let o=e.map(n=>n.dataset.instanceref||""),s=await Ee().validateEmbeddedObjects(o);s.tokill.length&&(console.warn("removing embedded objects",s.tokill),e.filter(n=>!n.dataset.instanceref||s.tokill.includes(n.dataset.instanceref)).forEac
43h(n=>n.remove()))}catch(o){console.log("Error validating embedded objects",o)}t.release()}_gotSelectionChange(e){if(this.selectingrange)return;let t=this.getSelectionRange();t.limitToNode(this.getBody());let o=new f(this.getBody()),s=o.scanForward(this.getBody(),{whitespace:!0,blocks:!0});(s.type!=="outerblock"||s.data!==this.getBody())&&t.start.compare(o)<0?(t.start.assign(o),o.compare(t.end)>0&&t.end.assign(o),this.selectRange(t)):this.selectionHasChanged(t),super._gotSelectionChange(e)}selectionHasChanged(e){let t=Array.from(e.querySelectorAll(".wh-rtd-embeddedobject")).filter(s=>!s.parentNode.closest(".wh-rtd-embeddedobject")),o=Array.from(this.getBody().querySelectorAll(".wh-rtd-embeddedobject--selected"));t.forEach(s=>s.classList.add("wh-rtd-embeddedobject--selected")),o.filter(s=>!t.includes(s)).forEach(s=>s.classList.remove("wh-rtd-embeddedobject--selected"))}insertEmptyParagraph(e,t){let o=this.getUndoLock(),s=t?f.newPointingAfter(e):f.newPointingTo(e),n=this.insertBlockNode(s,this.structure.defaultblockstyle,!1,null,null,null);this.requireVisibleContentInBlockAfterLocator(new f(n.node),null,null),this.selectRange(y.fromLocator(n.contentlocator)),o.close()}_gotMouseClick(e){if(!e.target)return;let t;if(e.target.getAttribute("data-rte-subaction")?t=e.target:t=e.target.closest("*[data-rte-subaction]"),!(!this.isEditable()&&!this._getTopmostEmbeddedObject(t)?.classList.contains("wh-rtd-embeddedobject--writable"))){if(t){e.preventDefault(),e.stopPropagation();let o=t.closest(".wh-rtd-embeddedobject");if(o)switch(t.getAttribute("data-rte-subaction")){case"navabove":this.insertEmptyParagraph(o,!1);break;case"navunder":this.insertEmptyParagraph(o,!0);break;default:this.launchActionPropertiesForNode(o,t.getAttribute("data-rte-subaction"));break}return}super._gotMouseClick(e)}}_gotDoubleClick(e){let t=this._getTopmostEmbeddedObject(e.target);if(t&&(this.isEditable()||t.classList.contains("wh-rtd-embeddedobject--writable"))){M(e),this.launchActionPropertiesForNode(t,"edit");return}super._gotDoubleClick(e)}_getTopmostEmbeddedObject(e){if(e){let t=e.closest(".wh-rtd-embeddedobject");if(t)for(;;){let o=t.parentNode.closest(".wh-rtd-embeddedobject");if(!o)break;t=o}return t}}executeDefaultPropertiesAction(e){if(e.target.nodeName.toLowerCase()==="div"&&e.detail.subaction==="delete"){this.removeEmbeddedObject(e.target);return}super.executeDefaultPropertiesAction(e)}canCombineNodes(e,t,o){let s;return t.nodeName.toLowerCase()!==o.nodeName.toLowerCase()||e.includes(t)||e.includes(o)?s=!1:["ol","ul"].includes(t.nodeName.toLowerCase())&&t.className===o.className?s=!0:this.textstyletags.includes(t.nodeName.toLowerCase())?s=this.isNodeTextStyleMatch(t,this.getTextStyleRecordFromNode(o)):s=!1,s}combineAtLocator(e,t,o,s,n,l){return xt(t,e,o,this.canCombineNodes.bind(this,s||[]),n||[],l),t}removeRange(e,t,o){if(e.element===t.element&&e.offset===t.offset)return e.clone();o=o||f.findCommonAncestorElement(e,t);let n=A(o,[{locator:e,toward:"start"},{locator:t,toward:"end"}]),l=n[1].start,r=n[1].end;l.ascend(o,!0),r.ascend(o,!1);for(let a=r.offset;a>l.offset;--a)o.removeChild(l.getPointedNode());return l}removeSelection(){let e=this.getSelectionRange();return this.removeRange(e.start,e.end)}insertNodeAutoSplit(e,t,o,s){!e.parentIsElementOrFragmentNode()&&!e.moveToParent()&&(e=Ge(e,o,"end",s));let n=e.insertNode(t,o,s);return{locator:e,next:n}}pointsToLastBlockBR(e){return e=e.clone(),e.scanForward(this.getBody(),{}).type!=="br"?null:Tt(e,this.getBody())}insertBlockNode(e,t,o,s,n){let l=this.getBlockAtNode(e.element),r=null;if(l.blockroot!==l.node&&(r=this.pointsToLastBlockBR(e)),l.blockstyle&&l.blockstyle.islist&&t.islist){if(!r){let m=document.createElement("img");this.insertNodeAutoSplit(e,m,s,n),r=y.fromNodeOuter(m)}A(l.node,[{locator:r.end,toward:"end",preservetoward:"start"}],s,n),e=r.start,ce(r,[e,...s||[]],n)}else r&&(e=r.end),l.blockstyle&&l.blockstyle.islist&&(t=l.blockstyle),e=A(l.blockroot,[{locator:e,toward:"end"}],s,n)[1].start.clone(),e.ascend(l.blockroot);let a=this.createBlockStyleElement(t,!0);e.insertNode(a.node,s,n);let d=new f(a.node,0);t.islist&&(this.combineAtLocator(l.blockroot,d,!1,[],s,n),this.combineAtLocator(l.blockroot,d,!0,[],s,n));let c=d.element,u=c;t.islist&&o&&(u=document.createElement("li"),d.insertNode(u,s,n),d.descendToLeafNode(this.getBody()));let h=new f(c,"end");return h.moveToParent(!0),{node:c,afternodelocator:h,contentlocator:d,contentnode:u}}
43_insertEmbeddedObjectNode(e,t,o,s){if(t.nodeName==="SPAN"){let l=this.insertNodeAutoSplit(e,t,o,s).next;return this.requireVisibleContentInBlockAfterLocator(l,[e,...o||[]],s),{node:t,afternodelocator:l}}else{let n=this.getBlockAtNode(e.element),l=null;n.blockroot!==n.node&&(l=this.pointsToLastBlockBR(e)),l&&(e=l.end),e=A(n.blockroot,[{locator:e,toward:"end"}],o,s)[1].start.clone(),e.ascend(n.blockroot),e.insertNode(t,o,s);let a=new f(t,0),d=a.element,c=d,u=new f(d,"end");return u.moveToParent(!0),{node:d,afternodelocator:u,contentlocator:a,contentnode:c}}}insertTable(e,t){let o=this.getUndoLock(),s=this.structure.blockstyles.filter(d=>d.istable)[0];if(!s)throw new Error("no table block style available");let n=s.tabledefaultblockstyle||this.structure.defaultblockstyle,l={type:"table",style:s,nodes:[],colwidths:[],firstdatacell:{row:0,col:0}};for(let d=0;d<t;++d){let c={type:"rowitem",nodes:[],height:null};l.nodes.push(c);for(let u=0;u<e;++u){let h={type:"cellitem",defaultstyle:n,nodes:[{type:"block",style:n,nodes:[{type:"br"}],temporary:!0,surrogate:!0}],colspan:1,rowspan:1};c.nodes.push(h)}}let r=Math.floor((parseInt(window.getComputedStyle(this.getBody()).width)-e)/e);for(let d=0;d<e;++d)l.colwidths.push(r);let a=this.removeSelection();this._insertParsed(a,[l]),o.close()}_insertTableNode(e,t,o,s){let n=this.getBlockAtNode(e.element),l=null;n.blockroot!==n.node&&(l=this.pointsToLastBlockBR(e)),l&&(e=l.end),e=A(n.blockroot,[{locator:e,toward:"end"}],o,s)[1].start.clone(),e.ascend(n.blockroot),e.insertNode(t,o,s),Vo(t).forEach(h=>{let m=h.propWhRtdCellitem;if(!m)return;let p=new f(h,0);this._insertParsed(p,m.nodes,!1,!1,!0,o,s)});let a=new f(t,0),d=a.element,c=d,u=new f(d,"end");return u.moveToParent(!0),{node:d,afternodelocator:u,contentlocator:a,contentnode:c}}_initNewTableCell(e){e.classList.add("wh-rtd__tablecell");let t=e.closest("table"),o=this.structure.getBlockStyleByTag(t.className.split(" ")[0]),n=[{type:"block",style:o&&o.istable&&o.tabledefaultblockstyle||this.structure.defaultblockstyle,nodes:[{type:"br"}],temporary:!0,surrogate:!0}],l=new f(e,0);this._insertParsed(l,n)}async _pasteContentAt(e,t){let o=this.getUndoLock();g.rte&&console.log("[rte] parseContentAt, raw",e.innerHTML);let s=t.clone(),n=s.scanBackward(this.getBody(),{whitespace:!0}),l=["innerblock","outerblock"].includes(n.type);g.rte&&console.log("[rte] paste at block start: ",l?"yes":"no",n,_(this.getBody(),{down:s,insertlocator:t}));let a=new Fe().applyCleanup(e);g.rte&&console.log("[rte] parseContentAt, cleaned",e.innerHTML);let d=this.qSA("style"),c=this.insertContainerContents(t,e,{externalcontent:!0,breakafter:a.breakafter});this.setCursorAtLocator(c),this.stateHasChanged(),this.handlePasteDone(d),await this._validateEmbeddedObjects(),o&&o.close(),this._reprocessEmbeddedAutoElements()}compareTextStyleOrder(e,t){return this.textstyletags.indexOf(e)-this.textstyletags.indexOf(t)}getTextStyleRecordFromNode(e){if(e.nodeName.toLowerCase()==="span")return null;let t=super.getTextStyleRecordFromNode(e);if(!t)return null;let o=this.textstylewhitelistedattributes[t.nodeName];return o&&(t={...t,..._t(e,o)}),t}getImageStyleRecordFromNode(e){let t={nodeName:"img",class:"wh-rtd__img"},o=e.align?e.align.toLowerCase():"";return e.classList.contains("wh-rtd__img--uploading")&&(t.class+=" wh-rtd__img--uploading"),e.classList.contains("wh-rtd__img--floatleft")||e.classList.contains("-wh-rtd-floatleft")||e.classList.contains("wh-rtd-floatleft")||o==="left"?t.class+=" wh-rtd__img--floatleft":(e.classList.contains("wh-rtd__img--floatright")||e.classList.contains("-wh-rtd-floatright")||e.classList.contains("wh-rtd-floatright")||o==="right")&&(t.class+=" wh-rtd__img--floatright"),t={...t,..._t(e,["width","height","alt","src"])},t}isNodeTextStyleMatch(e,t){let o=this.getTextStyleRecordFromNode(e);if(!o||o.nodeName!==t.nodeName)return!1;let s=this.textstylewhitelistedattributes[o.nodeName];if(s)for(let n=0;n<s.length;++n){let l=s[n];if(o[l]!==t[l])return!1}return!0}createTextStyleNode(e){let t=e.nodeName==="a-href"?"a":e.nodeName,o=document.createElement(t),s={...e};return delete s.nodeName,Qe(o,s),o}insertTextStyleNode(e,t,o,s){let n=this.createTextStyleNode(t);
43return e.insertNode(n,o,s),new f(n)}insertInlineFormattedNode(e,t,o,s,n){e.descendToLeafNode(this.getBody());let l=this.getBlockAtNode(e.getNearestNode()),r=e.getPathFromAncestor(l.contentnode),a;for(a=0;a<this.textstyletags.length;++a){let u=this.textstyletags[a];if(!o.hasTextStyle(u))continue;let h=r.length&&r[0];if(!h||!this.isNodeTextStyleMatch(h,o.getTextStyleByNodeName(u)))break;r.splice(0,1)}if(r.length||!e.parentIsElementOrFragmentNode()){let u=r.length?r[0].parentNode:e.element.parentNode;e.ascend(u,!0),e.element!==u&&(e=A(u,[{locator:e,toward:"start"}],s,n)[0].end.clone())}for(;a<this.textstyletags.length;++a){let u=this.textstyletags[a];if(!o.hasTextStyle(u))continue;let h=o.getTextStyleByNodeName(u);e=this.insertTextStyleNode(e,h,s,n)}e.parentIsElementOrFragmentNode()||e.ascend(e.element.parentNode,!1),e.insertNode(t,s,n);let d=e.clone();return++d.offset,{node:t,inserted:e,after:d}}DelayedSurroundSelection(e){let t=this.textstyletags.indexOf(e.element);t&&(e.subtags=this.textstyletags.slice(t+1)),super.DelayedSurroundSelection(e)}getBlockAtNode(e){let t=super.getBlockAtNode(e);return t.blockparent!==t.node?t.blockstyle=this.structure.getBlockStyleByTag(t.node.className.split(" ")[0]):t.blockstyle=null,t}getBlocksInRange(e,t){e=e.clone(),e.descendToLeafNodes(this.getBody()),e.start.moveToPreviousBlockBoundary(this.getBody(),!0),e.end.movePastLastVisible(this.getBody()).type==="outerblock"?(e.end.ascend(this.getBody(),!1),e.end.moveToPreviousBlockBoundary(this.getBody(),!1),e.end.compare(e.start)<0&&e.end.assign(e.start)):e.end.moveToNextBlockBoundary(this.getBody(),!t);let o=[],s=e.querySelectorAll("*");for(let l=0;l<s.length;++l)!s[l].isContentEditable||!I(s[l])||o.push(s[l]);let n=[];for(let l=0;l<o.length;++l){let r=this.getBlockAtNode(o[l]);r.islist&&r.contentnode===r.node||n.push({type:"block",block:r})}if(e.start.element===e.end.element){let l=this.getBlockAtNode(e.start.element);if(l.contentnode===l.blockparent)if(o.length===0)n.push({type:"range",range:e});else{let r=e.clone();r.end.assign(r.start),r.end.moveToNextBlockBoundary(this.getBody()),r.isCollapsed()||n.unshift({type:"range",range:r});let a=e.clone();a.start.assign(r.start),a.start.moveToPreviousBlockBoundary(this.getBody()),a.isCollapsed()||n.push({type:"range",range:a})}else n.push({type:"block",block:l})}return n}getFormattingStateForRange(e){let t=super.getFormattingStateForRange(e);t.blockstyle=null,t.limited={textstyles:this.textstyletags.slice().concat("img")};let o=this.getBlocksInRange(e,!1),s=[],n=[];for(let r=0;r<o.length;++r){if(o[r].type!=="block"||!o[r].block.blockstyle)continue;let a=o[r].block.blockstyle;n.includes(a.tag)||(s.push(a),n.push(a.tag))}if(s.length){for(let r=0;r<s.length;++r){if(s[r].istable)continue;let a=[],d=s[r].def.textstyles;for(let c=0;c<d.length;++c)t.limited.textstyles.includes(d[c])&&a.push(d[c]);t.limited.textstyles=a}t.blockstyle=s.length>1?null:s[0]}else t.blockstyle=this.structure.defaultblockstyle;for(let r=0;r<this.textstyletags.length;++r){let a=this.textstyletags[r];t.actionstate[a]&&(!t.limited.textstyles.includes(a)||t.isblockwidget)&&(t.actionstate[a].available=!1)}let l=[];return this.structure.blockstyles.forEach(r=>{l.push(r.listtype)}),(!l.includes("unordered")||t.isblockwidget)&&(t.actionstate.ul.available=!1),(!l.includes("ordered")||t.isblockwidget)&&(t.actionstate.ol.available=!1),(!t.limited.textstyles.includes("img")||t.isblockwidget)&&(t.actionstate.img.available=!1),t}parseNode(e){if([3,4].includes(e.nodeType))return e.nodeValue===""?{type:"ignore"}:{type:"text",data:e.nodeValue};if(![1,11].includes(e.nodeType))return null;if(oe(e))return Ko(e);let t=null,o=null,s=null,n=e.nodeName.toLowerCase(),l=["ul","ol"].includes(n),r=["table"].includes(n),a=!1;for(let m=0;m<this.structure.blockstyles.length;++m){let p=this.structure.blockstyles[m];a=a||!!p.istable,!s&&p.importfrom.find(k=>e.matches(k))&&(s=p),!o&&p.islist===l&&!!p.istable==!!r&&e.classList.contains(p.classname)&&(o=p),["h1","h2","h3","h4","h5","h6"].includes(n)&&n===p.def.containertag.toLowerCase()&&!t&&(t=p)}let d=s||o||t;if(d)return d.istable?{type:"tablestyle",style:d}:{type:"blockstyle",style:d};if(!a&&["td","th"].includes(n))return{type:"cellitem"};let c=this.getTextStyleRecordFromNode(e);return c&&this.textstyletags.includes(c.nodeName)?{type:"textstyle",style:c,displayblock:e.style.display==="block"}:e.nodeName.toLowerCase()==="br"?{type:"br",isinterchange:e.classList.contains("Apple-interchange-newline")}:e.nodeName.toLowerCase()==="img"?{type:"img"}:["style","script","meta"].includes(e.nodeName.toLowerCase())?{type:"ignore"}:e.nodeName.toLowerCase()==="ol"&&(this.structure.defaultorderedliststyle||this.structure.defaultunorderedliststyle)?{type:"blockstyle",style:this.structure.defaultorderedliststyle||this.structure.defaultunorderedliststyle}:e.nodeName.toLowerCase()==="ul"&&(this.structure.defaultunorderedliststyle||this.structure.defaultorderedliststyle)?{type:"blockstyle",style:this.structure.defaultunorderedliststyle||this.structure.defaultorderedliststyle}:e.nodeName.toLowerCase()==="table"&&this.structure.defaulttablestyle?{type:"tablestyle",style:this.structure.defaulttablestyle}:["abbr","acronym","b","big","cite","code","dfn","em","font","i","kbd","samp","small","strong","sub","sup","tt","var","a","bdo","label","q","span"].includes(e.nodeName.toLowerCase())?{type:"unknown",displayblock:e.style.display==="block"}:{type:"blockstyle",style:this.structure.defaultblockstyle}}parseContainerContents(e,{inblock:t,externalcontent:o,initialblockstyle:s}){let n=[];return this.parseContainerContentsRecursive(e,null,n,[],s,{externalcontent:o}),n.length!==0&&t&&(n[0].temporary=!0),n}_addItemToBlockNodes(e,t){if(e.deferredbr){if(t.type==="text"&&t.value.match(/^[ \t\r\n]*$/)){e.deferredbr.push(t);return}e.nodes.push(...e.deferredbr)}t.type==="br"?(e.deferredbr=[t],e.forcevisible=!0):(e.deferredbr=null,e.nodes.push(t))}parseContainerContentsRecursive(e,t,o,s,n,l){let r=Array.from(e.childNodes);for(let a=0;a<r.length;++a){let d=r[a],c=this.parseNode(d);if(!(!c||c.type==="ignore")){if((!t||t.type==="cellitem")&&["text","textstyle","br","img"].includes(c.type)){if(c.type==="text"){for(;c.data&&` \r 44`.indexOf(c.data.substr(0,1))!==-1;)c.data=c.data.substr(1);if(!c.data)continue}let u=t&&t.type==="cellitem"&&t.defaultstyle?t.defaultstyle:n||this.structure.defaultblockstyle;n=null,t={type:"block",style:u,nodes:[],surrogate:!0},o.push(t)}switch(t&&t.gotlist&&(t={type:"listitem",nodes:[],listitems:t.listitems,style:t.style},t.listitems.push(t)),c.type){case"unknown":{let u;c.displayblock&&t&&t.nodes.length&&t.nodes[t.nodes.length-1].type!=="br"&&!t.deferredbr&&(u=t,this._addItemToBlockNodes(t,{type:"br"})),t=this.parseContainerContentsRecursive(d,t,o,s,null,l),u&&u===t&&t.nodes[t.nodes.length-1].type!=="br"&&!t.deferredbr&&this._addItemToBlockNodes(t,{type:"br"})}break;case"textstyle":{let u;c.displayblock&&t.nodes.length&&t.nodes[t.nodes.length-1].type!=="br"&&!t.deferredbr&&(u=t,this._addItemToBlockNodes(t,{type:"br"}));let h=s.slice();t.style.def.textstyles.includes(c.style.nodeName)&&h.push(c.style),t=this.parseContainerContentsRecursive(d,t,o,h,null,l),u&&u===t&&t.nodes[t.nodes.length-1].type!=="br"&&!t.deferredbr&&this._addItemToBlockNodes(t,{type:"br"})}break;case"text":{let u=c.data;for(u=u.replaceAll("\u200B",""),u=u.replaceAll("\r"," "),u=u.replaceAll(` 45`," ");u.includes(" ");)u=u.replaceAll(" "," ");u!==c.data&&(t.forcevisible=!0),u!==""&&this._addItemToBlockNodes(t,{type:"text",value:u,textstyles:s})}break;case"img":{if(!t.style.def.textstyles.includes("img")){if(!this.structure.defaultblockstyle.def.textstyles.includes("img")||t.style.islist)break;t={type:"block",style:this.structure.defaultblockstyle,nodes:[],surrogate:!0},o.push(t)}this._addItemToBlockNodes(t,{type:"img",value:this.getImageStyleRecordFromNode(d),textstyles:s})}break;case"br":(!c.isinterchange||!d.nextSibling||d.nextSibling.nodeName.toLowerCase()!=="br")&&this._addItemToBlockNodes(t,{type:c.type,value:this.getTextStyleRecordFromNode(d)});break;case"embeddedobject":{c.embedtype==="block"?(t=null,o.push(c)):this._addItemToBlockNodes(t,c);break}case"blockstyle":{t&&t.surrogate&&(t=null);let u=c.style.islist;if(n&&(c.style.islist||(c.style=n),n=null),t&&t.type==="listitem"&&!c.style.islist)this.parseContainerContentsRecursive(d,t,o,s,null,l);else if(c.style.islist&&!u){let h={type:"list",style:c.style,nodes:[],surrogate:!0};o.push(h);let m={type:"listitem",nodes:[],listitems:h.nodes,style:c.style};h.nodes.push(m),this.parseContainerContentsRecursive(d,m,o,s,null,l)}else if(c.style.islist){let h={type:"list",style:c.style,nodes:[]};t&&t.type==="listitem"?(this._addItemToBlockNodes(t,h),t.gotlist=!0):(o.push(h),t=null);for(let m=0;m<d.childNodes.length;++m)if(["li","ol","ul"].includes(d.childNodes[m].nodeName.toLowerCase())){let p={type:"listitem",nodes:[],listitems:h.nodes,style:c.style};h.nodes.push(p);let k=d.childNodes[m];this.parseContainerContentsRecursive(k,p,o,s,null,l)}}else t={type:"block",style:c.style,nodes:[]},o.push(t),this.parseContainerContentsRecursive(d,t,o,s,null,l),t=null}break;case"tablestyle":{let u=tt(d),h=Se(d);if(u.rows===0||u.cols===0)continue;t={type:"table",style:c.style,nodes:[],colwidths:[],firstdatacell:h,caption:d.querySelector("caption")?.textContent??""},o.push(t);let m=d.tHead?Array.from(d.tHead.rows):[];h.row+=m.length;let p=Array.from(d.rows),k=Array(u.cols).fill(0);for(let w=0;w<p.length;++w){let x=Array.from(p[w].cells),O={type:"rowitem",nodes:[],height:parseInt(p[w].style.height)};t.nodes.push(O);let ne=0,ie=0;for(;ne<u.cols;){if(k[ne]>w){++ne;continue}let te=x[ie++],ve={type:"cellitem",defaultstyle:c.style.tabledefaultblockstyle,nodes:[],colspan:te?te.colSpan:1,rowspan:te?te.rowSpan:1,styletag:te?this.structure.getClassStyleForCell(te):""};O.nodes.push(ve),te&&this.parseContainerContentsRecursive(te,ve,ve.nodes,s,null,l);for(let ao=0;ao<ve.colspan;++ao)k[ne++]=w+ve.rowspan}}let N=document.createElement("tr");d.appendChild(N);let b=It(d);for(let w=0;w<u.cols;++w)N.appendChild(document.createElement("td"));for(let w=0;w<u.cols;++w){let x=null;w<b.length&&(x=parseInt(b[w].style.width)),x||(x=N.childNodes[w].offsetWidth),t.colwidths.push(x)}N.remove(),t=null}break;case"cellitem":t={type:"block",style:this.structure.defaultblockstyle,nodes:[]},o.push(t),this.parseContainerContentsRecursive(d,t,o,s,null,l),t=null;break}}}return t}showParsed(e,t){let o=" ";for(;o.length<t;)o+=o;o=o.substr(0,t);for(let s=0;s<e.length;++s)if(console.log(o+"b "+s+": "+e[s].type+(e[s].type==="text"?' "'+e[s].value+'"'
45:"")+(e[s].type==="img"?" "+JSON.stringify(e[s].value):"")+(["list","block"].includes(e[s].type)?" "+e[s].style.def.containertag+"."+e[s].style.tag:"")+(e[s].forcevisible?" forcevisible":"")+(e[s].temporary?" temporary":"")+(e[s].surrogate?" surrogate":"")+(e[s].deferred?" (deferred)":"")+(e[s].textstyles?" ["+e[s].textstyles.map(n=>n.nodeName).join(", ")+"]":"")),["list","listitem","block","table","rowitem","cellitem"].includes(e[s].type)){let n=[...e[s].nodes,...(e[s].deferredbr||[]).map(l=>({...l,deferred:!0}))];this.showParsed(n,t+2)}}exitTextStyles(e){e=e.clone();let t=e.getNearestNode(),o=this.getBlockAtNode(t);return o.contentnode!==t&&e.ascend(o.contentnode,!0),e}_insertParsed(e,t,o,s,n,l,r){l=l||[];for(let a of _n(t))if(a.block){e.assign(this.exitTextStyles(e));let d=a.block;switch(d.type){case"block":if(o&&d.temporary)e=this._insertParsed(e,d.nodes,o,s,n,l,r),d.forcevisible&&this.requireVisibleContentInBlockAfterLocator(e,[e,...l||[]],r);else{let c=this.insertBlockNode(e,d.style,!0,l,r);e=this._insertParsed(c.contentlocator,d.nodes,!0,!1,n,l,r),d.forcevisible?this.requireVisibleContentInBlockAfterLocator(e,[e,...l||[]],r):jo(c.node)||f.newPointingTo(c.node).removeNode([c.contentlocator,e,...l||[]],r)}break;case"embeddedobject":{let c=this._createEmbeddedObjectNode(d);e=this._insertEmbeddedObjectNode(e,c,l,r).afternodelocator;break}case"table":{if(n||o||s)for(let c of d.nodes)for(let u of c.nodes)e=this._insertParsed(e,u.nodes,o,s,n,l,r);else{let c=this._createTableNode(d);e=this._insertTableNode(e,c,l,r).afternodelocator,this.initializeTableEditor(c,d.style.tableresizing)}break}case"list":{if(!d.nodes.length)continue;if(s&&d.temporary&&d.nodes.length===1){e=this._insertParsed(e,d.nodes[0].nodes,o,s,n,l,r);continue}let c=this.insertBlockNode(e,d.style,!1,l,r);for(let u=0;u<d.nodes.length;++u){let h=document.createElement("li");c.contentlocator.insertNode(h,l,r),++c.contentlocator.offset,e=new f(h),e=this._insertParsed(e,d.nodes[u].nodes,!0,!0,n,l,r),this.requireVisibleContentInBlockAfterLocator(e,[e],r)}c.node.childNodes.length===0?(e=f.newPointingTo(c.node),e.removeNode(l,r)):e=f.newPointingAfter(c.node)}break;case"br":{let c=new q.TextFormattingState,u=document.createElement("br");c.textstyles=[],e=this.insertInlineFormattedNode(e,u,c,l,r).after}break}}else for(let d of Cn(a.inline))switch(d.type){case"text":{let c=new q.TextFormattingState;c.textstyles=d.textstyles;let u=document.createTextNode(d.value);e=this.insertInlineFormattedNode(e,u,c,l,r).after}break;case"img":{let c=this.createTextStyleNode(d.value),u=new q.TextFormattingState;u.textstyles=d.textstyles,e=this.insertInlineFormattedNode(e,c,u,l,r).after}break;case"embeddedobject":{e.assign(this.exitTextStyles(e));let c=this._createEmbeddedObjectNode(d);e=this._insertEmbeddedObjectNode(e,c,l,r).afternodelocator;break}default:{console.error("Unexpected nodetype '"+d.type+"'",d);break}}return e}cleanupParsedExternalContent(e){let t=!0;for(let o=0;o<e.length;++o){let s=e[o];switch(s.type){case"block":t&&(s.temporary=!0);case"listitem":{let n=s.nodes;n.length&&this.cleanupParsedExternalContent(n),s.type==="block"&&!n.length&&!s.forcevisible&&e.splice(o--,1)}break;case"list":this.cleanupParsedExternalContent(s.nodes),s.nodes.length===0&&e.splice(o--,1);break}t=!1}}insertContainerContents(e,t,o,s,n){s=s||[],e=e.clone();let l=this.getBlockAtNode(e.getNearestNode()),r=l.islist,a=!1;typeof o.inblock>"u"&&(e.clone().scanBackward(this.getBody(),{whitespace:!0}).type==="outerblock"?(o.inblock=l.islist,a=!0):o.inblock=!0);let d=o.inblock&&l&&l.blockstyle||null,c=this.parseContainerContents(t,{...o,initialblockstyle:d});if(g.rte&&console.log("[rte] parsed container contents",c,{breakblock:a}),a){let m=e.clone().scanForward(this.getBody(),{whitespace:!0}),p=!1;if(m.bogussegmentbreak&&e.clone().scanBackward(this.getBody(),{whitespace:!0}).type==="outerblock"&&(p=!0),p&&c.length)l.islist||(e=f.newPointingTo(l.contentnode),e.removeNode(s));else if(l.contentnode!==l.blockroot){let k=e.clone();k.scanBackward(this.getBody(),{whitespace:!0}),e=A(l.blockparent,[{locator:k,toward:"start",preservetoward:"end"}],null)[0].end}}if(ke&&(console.log("parsed (pre clean) ",o.externalcontent),this.showParsed(c,1)),o.externalcontent&&this.cleanupParsedExternalContent(c),o.breakafter){let m=e.clone().scanForward(this.getBody(),{whitespace:!0});(m.type==="node"||m.type==="char")&&!m.segmentbreak&&c.push({type:"block",style:this.structure.defaultblockstyle,nodes:[]})}ke&&(console.log("parsed ("+(o.externalcontent?"post":"no")+" clean)"),this.showParsed(c,1),console.log("pre insertParsed: ",_(this.getBody(),{locator:e})));let u=this._insertParsed(e,c,o.inblock,r,o.isintable,s,n);ke&&console.log("post insert: ",_(this.getBody(),{locator:e,res:u})),e=this.combineAtLocator(this.getBody(),e,!0,[],[u,...s],n),u=this.combineAtLocator(this.getBody(),u,!0,[],[e,...s],n),ke&&console.log("post combine: ",_(this.getBody(),{locator:e,res:u})),ke&&console.log("ICC postinsert, html: ",_(this.getBody(),{locator:e,res:u}));let h=new y(u,u);return this.checkDomStructure(h,[e,u,...s||[]],n),ke&&console.log("ICC postcheck, html: ",_(this.getBody(),{locator:e,res:u})),Rt(h.getAncestorElement(),[e,u,...s||[]],n),u}setContentsHTML(e,t){if(t&&t.raw)return super.setContentsHTML(e);super.setContentsHTML("");let o=document.createElement("div");o.innerHTML=e;let s=new f(this.getBody());this.insertContainerContents(s,o,{externalcontent:!0});let n=new f(this.getBody());this.setCursorAtLocator(n),this.stateHasChanged(),this._reprocessEmbeddedAutoElements()}createBlockStyleElement(e,t){let o=document.createElement(e.def.containertag);o.className=e.classname;let s=o;return!t&&["ul","ol"].includes(e.def.containertag.toLowerCase())&&(s=document.createElement("li"),o.appendChild(s)),{node:o,insertno
45de:s}}_toggleBulletedList(){this.toggleList(this.structure.defaultunorderedliststyle)}_toggleNumberedList(){this.toggleList(this.structure.defaultorderedliststyle)}toggleList(e){this.setSelectionBlockStyle(e,!1)}changeRangeBlockStyle(e,t,o,s,n){if(!t.contains(e.getAncestorElement()))throw new Error("Ancestor not parent of range in changeRangeBlockStyle");if(e.start.element!==e.end.element)throw new Error("Simple range required in changeRangeBlockStyle");let l=A(t,[{locator:e.start,toward:"start",preservetoward:"end"},{locator:e.end,toward:"end",preservetoward:"start"}],s.concat(e),n),r=this.createBlockStyleElement(o,!0).node;if(_e(e,r,s.concat(l).concat(e),n),o.islist){let c=document.createElement("li");_e(y.fromNodeInner(r),c,s.concat(l).concat(e),n)}let a=document.createElement("div");_e(y.fromNodeOuter(r),a,s.concat(l).concat(e),n);let d=l[1].start;return ce(l[1],s.concat([d]),n),this.insertContainerContents(d,a,{inblock:!1},s,n),e.start.assign(d),e.end.assign(l[1].end),this.combineAtLocator(t,e.start,!1,[],s.concat([e]),n),this.combineAtLocator(t,e.end,!0,[],s.concat([e]),n),e}setSelectionBlockStyle(e,t){let o=this.getUndoLock(),s=e;if(typeof s=="string"&&(s=this.structure.getBlockStyleByTag(s)),!s)throw new Error("Invalid blockstyle "+e);let n=this.getSelectionRange(),l=this.getBlocksInRange(n,!s.islist);if(!t&&s.islist){let r=!0;for(let a=0;a<l.length;++a)if(l[a].type!=="block"||l[a].block.blockstyle.tag!==s.tag){r=!1;break}r&&(s=this.structure.defaultblockstyle)}for(let r=l.length-1;r>=0;--r){let a=l[r],d,c;if(a.type==="range")d=a.range.getAncestorElement(),c=a.range;else{if(!a.block.blockstyle||a.block.blockstyle.istable||a.block.blockstyle.tag===s.tag)continue;d=a.block.islist&&s.islist?a.block.blockparent:a.block.blockroot,c=y.fromNodeInner(a.block.contentnode)}let u=this.changeRangeBlockStyle(c,d,s,[n],o.undoitem);r===l.length-1&&n.end.assign(u.end),n.start.assign(u.start)}return this.selectRange(n),o.close(),this.stateHasChanged(),!0}refilterContent(e){let t=this.getBody(),o=document.createElement("div");_e(y.fromNodeInner(t),o),t.removeChild(o);let s=new f(t);this.insertContainerContents(s,o,{externalcontent:e});let n=new y(s,s);n.normalize(t),this.selectRange(n),this.stateHasChanged(),this._reprocessEmbeddedAutoElements()}setCellStyle(e,t){e.className="wh-rtd__tablecell"+(t?" "+t:"")}setSelectionCellStyle(e){let t=this.getSelectionRange(),o=t.querySelectorAll("tr,td"),s=t.getAncestorElement().closest("tr,td");for(let n of[s,...o])n&&this.setCellStyle(n,e)}executeHardEnter(){let e=this.getSelectionRange();this._executeHardEnterOnRange(e)}_executeHardEnterOnRange(e){let o=this.getUndoLock();this.checkDomStructure(e);let s=this.getBlockAtNode(e.start.element),n=this.getBlockAtNode(e.end.element),l=e.start.movePastLastVisible(s.contentnode),r=e.end.moveToFirstVisible(n.contentnode),a=l.type==="outerblock",d=r.type==="outerblock";if(r.type==="br"){let w=this.pointsToLastBlockBR(e.end);w?(e.end.assign(w.end),d=!0):(++e.end.offset,r=e.end.moveToFirstVisible(n.contentnode))}let c,u=s,h=s.islist,m=!a,p=!a;if(s.islist&&a&&d&&(m=!0,h=!1,u=null,p=!0),m){let w=s.blockparent;h&&(w=s.node),c=A(w,[{locator:e.start,toward:"start"}],[e],o.undoitem)[1].start}else{let w=l.type==="outerblock"&&l.data.previousElementSibling;w&&(u=this.getBlockAtNode(w)),c=f.newPointingTo(l.data)}let k;if(h){let w=document.createElement("li");c.insertNode(w,[e],o.undoitem),k=new f(w)}else{let w=u&&u?.blockstyle?.nextblockstyle||this.structure.defaultblockstyle;k=this.insertBlockNode(c,w,!0,[e],null,null).contentlocator}p?e.start=k:this.requireVisibleContentInBlockAfterLocator(k,[e],o.undoitem);let N=this._removeRangeAndStitch(e,null,o.undoitem,{normalize:!1}),b=this.getBlockAtNode(N.element);return b.contentnode&&this.requireVisibleContentInBlockAfterLocator(new f(b.contentnode),null,o.undoitem),N=this._correctWhitespaceAroundLocator(N,o.undoitem),this.setCursorAtLocator(N),o.close(),this.stateHasChanged(),!1}_isEmptyBlock(e){let t=new f(e),o=t.scanForward(e,{whitespace:!0});return o.type==="outerblock"?!0:o.type==="br"?(t=f.newPointingAfter(o.data),o=t.scanForward(e,{whitespace:!0}),o.type==="outerblock"):!1}_scanBackwardSkipEmbedded(e,t){for(t=t.clone();;){let o=t.scanBackward(this.getBody(),{whitespace:!0,blocks:!0});if(o.type==="outerblock")return o.data===e?null:t;if(o.type!=="node"||!o.data.classList.contains("wh-rtd-embeddedobject"))return o.type==="br"&&o.bogussegmentbreak&&--t.offset,t;--t.offset}}_scanForwardSkipEmbedded(e,t){for(t=t.clone();;){let o=t.scanForward(e,{whitespace:!0,blocks:!0});if(o.type==="outerblock")return o.data===e?null:t;if(o.type!=="node"||!o.data.classList.contains("wh-rtd-embeddedobject"))return t;++t.offset}}_executeDeleteByKey(e){let t=this.getUndoLock(),o=this.getSelectionRange();if(o.isCollapsed()){let n=this.getBlockAtNode(o.start.getNearestNode());if(this._isEmptyBlock(n.contentnode)){let a;if(e||(a=this._scanBackwardSkipEmbedded(n.blockroot,o.start)),a||(a=this._scanForwardSkipEmbedded(n.blockroot,f.newPointingAfter(n.contentnode))),!a&&e&&(a=this._scanBackwardSkipEmbedded(n.blockroot,o.start)),!a)return t.close(),!0;let d=f.newPointingTo(n.contentnode);return d.removeNode([a],t.undoitem),n.islist&&new f(n.node,0).moveToNextBlockBoundary(this.getBody(),!1).type==="outerblock"&&(d=f.newPointingTo(n.node),d.removeNode([a],t.undoitem)),this.checkDomStructure(y.fromLocator(a),[]),t.close(),!0}let l=a=>!a.matches("div,table,caption"),r=o.end.clone();if(e)if(r.moveRight(this.getBody(),{checkblock:l}))o.end.assign(r);else return t.close(),!0;else if(r.moveLeft(this.getBody(),{checkblock:l})){if(n=this.getBlockAtNode(r.getNearestNode()),this._isEmptyBlock(n.contentnode))return n.contentnode.remove(),n.node!==n.contentnode&&this._isEmptyBlock(n.node)&&n.node.remove(),t.close(),!0;o.start.assign(r)}else return t.close(),!0}o=this._constrainRangeCrossTDSelections(o).range;let s=this._removeRangeAndStitch(o,null,t.undoitem);return this.setCursorAtLocator(s),t.close(),!0}addListNodeToNode(e,t){if(e.lastChild&&e.lastChild.lastChild){let o=this.getBlockAtNode(e.lastChild.lastChild);o&&o.blockstyle&&(t=o.blockstyle)}
45return this.insertBlockNode(new f(e,"end"),t,!0,null,null,null)}areBothListRoots(e,t){return["ol","ul"].includes(e.nodeName.toLowerCase())&&["ol","ul"].includes(t.nodeName.toLowerCase())}combineAdjacentLists(e,t,o,s){xt(t,e,!1,this.areBothListRoots.bind(this),o,s)}addListLevel(){let e=this.getSelectionRange(),t=this.getUndoLock(),o=st(e,this.getBody()).addable;for(let s=0;s<o.length;++s){let n=o[s],l=n.previousSibling,r=!l;r&&(l=n.parentNode.previousSibling.lastChild);let a=n.parentNode,d=a.cloneNode(!1);new f(l,"end").insertNode(d,null,t.undoitem);let c=a.parentNode,u=n.cloneNode(!1);new f(d,"end").insertNode(u,null,t.undoitem);let h=new f(u);Ae(h,n,[e],t.undoitem),r&&!a.childNodes.length&&(h=f.newPointingTo(a),h.removeNode([e],t.undoitem)),this.combineAdjacentLists(c,h,[e],t.undoitem)}this.selectRange(e),t.close(),this.stateHasChanged()}removeListLevel(){let e=this.getSelectionRange(),t=this.getUndoLock(),o=e.clone(),s=st(e,this.getBody()).removeable;for(let n=0;n<s.length;++n){let l=s[n];this.requireVisibleContentInBlockAfterLocator(new f(l,0),[o],t.undoitem);let r=this.getBlockAtNode(l),a=this.getBlockAtNode(r.blockparent),d=l.parentNode,c=new f(l),h=A(a.node,[{locator:c,toward:"start"}],[o],t.undoitem)[1].start.getPointedNode(),m=new f(h,0),k=Ae(m,l,[o],t.undoitem).afterlocator;this.combineAdjacentLists(h,k,[o],t.undoitem),d.parentNode&&d.childNodes.length===0&&f.newPointingTo(d).removeNode([o],t.undoitem),this.requireVisibleContentInBlockAfterLocator(new f(h,0),[o],t.undoitem)}this.selectRange(o),t.close(),this.stateHasChanged()}checkDomStructure(e,t){let o=!e;o&&(e=this.getSelectionRange()),t=[e,...t||[]];let s=this.getBlockAtNode(e.start.getNearestNode()),n=new f(s.contentnode);if(this.requireVisibleContentInBlockAfterLocator(n,t),Rt(e.getAncestorElement(),t),s.blockparent!==s.contentnode&&!s.blockstyle&&!oe(s.contentnode)&&!s.isintable){let r=y.fromNodeInner(s.contentnode);this.changeRangeBlockStyle(r,s.blockparent,this.structure.defaultblockstyle,t.concat([e]))}n=new f(this.getBody());let l=n.scanForward(this.getBody(),{whitespace:!0});if(!["innerblock"].includes(l.type)&&!(l.type==="node"&&oe(l.data))){n.moveToNextBlockBoundary(this.getBody(),!1);let r=A(this.getBody(),[{locator:n,toward:"start"}],t);l=this.insertBlockNode(r[1].start,this.structure.defaultblockstyle,t,null),Xe(r[0],l.contentlocator,t),this.requireVisibleContentInBlockAfterLocator(l.contentlocator,t)}this.combineAtLocator(this.getBody(),e.start,!1,[],t),o&&(this.selectRange(e),this.stateHasChanged())}_createEmbeddedObjectNode(e){return Qo(e,this.options)}insertEmbeddedObject(e){let t=this.getSelectionRange(),o=this.getUndoLock(),s=t.isCollapsed(),n=this.removeSelection(),l=this._createEmbeddedObjectNode(e);this._insertEmbeddedObjectNode(n,l,[],o.undoitem),s?this.setCursorAtLocator(n):this.selectNodeOuter(l),o.close(),this.stateHasChanged(),this._reprocessEmbeddedAutoElements()}updateEmbeddedObject(e,t){let o=this.getSelectionRange(),s=this.getUndoLock(),n=f.newPointingTo(e),l=this._createEmbeddedObjectNode(t);n.replacePointedNode(l,[o]),this.selectRange(o),s.close(),this.stateHasChanged(),this._reprocessEmbeddedAutoElements()}removeEmbeddedObject(e){let t=this.getSelectionRange(),o=this.getUndoLock();f.newPointingTo(e).removeNode([t],o.undoitem),this.selectRange(t),o.close(),this.stateHasChanged()}_createTableNode(e){let t=document.createElement("table");t.className=e.style.classname+" wh-rtd__table";let o=document.createElement("tbody");if(e.caption&&t.appendChild(E("caption",{class:"wh-rtd__tablecaption",contenteditable:"false",inert:!0},e.caption.trim())),e.colwidths){let n=document.createElement("colgroup");e.colwidths.forEach(l=>{let r=document.createElement("col");l&&(r.style.width=l+"px"),n.appendChild(r)}),t.appendChild(n)}let s=[];return e.nodes.forEach((n,l)=>{if(n.type!=="rowitem")throw new Error("Unexpected table rowitem node");let r=document.createElement("tr");
45n.height&&(r.style.height=n.height+"px");let a=0;n.nodes.forEach(d=>{if(n.type!=="rowitem")throw new Error("Unexpected table rowitem node");for(;(s[a]||0)>l;)++a;let c=null;a>=e.firstdatacell.col==l>=e.firstdatacell.row?c=document.createElement("td"):(c=document.createElement("th"),c.setAttribute("scope",a>=e.firstdatacell.col?"col":"row")),d.colspan>1&&(c.colSpan=d.colspan),d.rowspan>1&&(c.rowSpan=d.rowspan),c.className="wh-rtd__tablecell"+(d.styletag?" "+d.styletag:""),c.propWhRtdCellitem=d,r.appendChild(c);for(let u=0;u<d.colspan;++u)s[a++]=l+d.rowspan}),o.appendChild(r)}),t.appendChild(o),Mt(t),t}removeTable(e){let t=this.getSelectionRange(),o=this.getUndoLock();f.newPointingTo(e).removeNode([t],o.undoitem),this.selectRange(t),o.close(),this.stateHasChanged()}requireBottomParagraph(){let e=this.getBody(),o=new f(e,"end").scanBackward(e,{whitespace:!0});switch(o.type){case"char":case"br":return;case"node":case"innerblock":{if(o.data.nodeName.toLowerCase()!=="table"&&!o.data.classList.contains("wh-rtd-embeddedobject"))return;let n=this.getUndoLock(),l=new f(e,"end");o=this.insertBlockNode(l,this.structure.defaultblockstyle,!1,null,null,null),this.requireVisibleContentInBlockAfterLocator(new f(o.node),null,null),this.selectRange(y.fromLocator(o.contentlocator)),n.close()}break;default:this.checkDomStructure();break}}getAvailableListActions(e){let t=st(e,this.getBody());return{canincrease:t.addable.length!==0,candecrease:t.removeable.length!==0}}};gt();var ze=class extends q{constructor(e,t){t={...t,allowundo:!1},super(e,t),this._constructorTail()}execCommand(e,t,o){try{this.bodydiv.ownerDocument.execCommand(e,t,o)}catch(s){return this.options.log&&console.log("ExecCommand exception",s),!1}return!0}addListLevel(){this.execCommand("indent"),this.stateHasChanged()}removeListLevel(){this.execCommand("outdent"),this.stateHasChanged()}_toggleBulletedList(){this.execCommand("insertunorderedlist"),this.stateHasChanged()}_toggleNumberedList(){this.execCommand("insertorderedlist"),this.stateHasChanged()}_setAlignment(e){let t="";switch(e){case"center":t="justifycenter";break;case"right":t="justifyright";break;case"justified":t="justifyfull";break;default:t="justifyleft";break}this.execCommand(t),this.stateHasChanged()}getAvailableListActions(e){let t=e.getAncestorClosest("ul,ol",this.getBody()),o=e.querySelectorAll("ul,ol,li").length;return{canincrease:t||o,candecrease:t||o}}_pasteContent(e){throw new Error("Only supported by the StructuredEditor")}};to();xe();function Bi(i,e){return e.structure?new je(i,e):new ze(i,e)}export{Bi as createRTE,Ot as getTargetInfo,gn as preloadCSS}; 46//# sourceMappingURL=/.wh/ea/ap/utwente_base.ws2026/richeditor-RLHASJUN.mjs.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.