(()=>{var t={cfbI(t){var e,s;e="undefined"!=typeof window?window:this,s=function(t,e){const s={code:"en",align:"Align",alignBottom:"Align bottom",alignCenter:"Align center",alignJustify:"Align justify",alignLeft:"Align left",alignMiddle:"Align middle",alignRight:"Align right",alignTop:"Align top",anchor:"Anchor",asBlock:"As a block",asInline:"As a inline",asLink:"As a link",audio:"Audio",audioGallery:"Audio gallery",audio_modal_file:"Select from files",audio_modal_title:"Insert Audio",audio_modal_url:"Audio URL",autoSize:"Auto size",backgroundColor:"Background color",basic:"Basic",blockStyle:"Block style",bold:"Bold",border:"Border",border_all:"Border all",border_inside:"Border inside",border_horizontal:"Border horizontal",border_vertical:"Border vertical",border_outside:"Border outside",border_left:"Border left",border_top:"Border top",border_right:"Border right",border_bottom:"Border bottom",border_none:"Border none",bulletedList:"Bulleted list",cancel:"Cancel",caption:"Insert description",cellProperties:"Cell properties",center:"Center",close:"Close",codeView:"Code view",color:"Color",colorPicker:"Color picker",column:"Column",comment:"Comments",commentAdd:"Add comment",commentShow:"Show comments",copy:"Copy",copyFormat:"Paint Formatting",cut:"Cut",default:"Default",deleteColumn:"Delete column",deleteRow:"Delete row",dir_ltr:"Left to right",dir_rtl:"Right to left",download:"Download",drag:"Drag",drawing:"Drawing",drawing_modal_title:"Drawing",edit:"Edit",embed:"Embed",embed_modal_title:"Embed",embed_modal_source:"Embed Source / URL",exportPDF:"Export to PDF",exportWord:"Export to Word",find:"Find",decrease:"Decrease",increase:"Increase",fileBrowser:"File browser",fileGallery:"File gallery",fileUpload:"File upload",fixedColumnWidth:"Fixed column width",font:"Font",fontColor:"Font color",fontSize:"Size",formats:"Formats",fullScreen:"Full screen",height:"Height",horizontalLine:"Horizontal line",horizontalSplit:"Horizontal split",hr_dashed:"Dashed",hr_dotted:"Dotted",hr_solid:"Solid",id:"ID",image:"Image",imageGallery:"Image gallery",image_modal_altText:"Alternative text",image_modal_file:"Select from files",image_modal_title:"Insert image",image_modal_url:"Image URL",importWord:"Import from Word",indent:"Indent",inlineStyle:"Inline style",insertColumnAfter:"Insert column after",insertColumnBefore:"Insert column before",insertRowAbove:"Insert row above",insertRowBelow:"Insert row below",insertLine:"Insert line",italic:"Italic",layout:"Layout",left:"Left",lineHeight:"Line height",link:"Link",link_modal_bookmark:"Bookmark",link_modal_downloadLinkCheck:"Download link",link_modal_newWindowCheck:"Open in new window",link_modal_text:"Text to display",link_modal_title:"Insert Link",link_modal_url:"URL to link",link_modal_relAttribute:"Rel attribute",list:"List",markdownView:"Markdown view",math:"Math",math_modal_fontSizeLabel:"Font Size",math_modal_inputLabel:"Mathematical Notation",math_modal_previewLabel:"Preview",math_modal_title:"Math",maxSize:"Max size",mediaGallery:"Media gallery",menu_bordered:"Bordered",menu_code:"Code",menu_neon:"Neon",menu_shadow:"Shadow",menu_spaced:"Spaced",menu_translucent:"Translucent",mergeCells:"Merge cells",minSize:"Min size",mirrorHorizontal:"Mirror, Horizontal",mirrorVertical:"Mirror, Vertical",newDocument:"New document",numberedList:"Numbered list",outdent:"Outdent",pageBreak:"Page break",pageDown:"Page down",pageNumber:"Page number",pageUp:"Page up",paragraphStyle:"Paragraph style",preview:"Preview",print:"print",proportion:"Constrain proportions",ratio:"Ratio",redo:"Redo",remove:"Remove",removeFormat:"Remove Format",replace:"Replace",replaceAll:"Replace all",resize100:"Zoom 100%",resize25:"Zoom 25%",resize50:"Zoom 50%",resize75:"Zoom 75%",resize:"Resize",revert:"Revert",revisionHistory:"Revision History",right:"Right",rotateLeft:"Rotate left",rotateRight:"Rotate right",row:"Row",save:"Save",search:"Search",selectAll:"Select All",showBlocks:"Show blocks",size:"Size",splitCells:"Split cells",strike:"Strike",submitButton:"Submit",subscript:"Subscript",superscript:"Superscript",table:"Table",tableHeader:"Table header",tableProperties:"Table properties",tags:"Tags",tag_blockquote:"Quote",codeBlock:"Code Block",tag_div:"Normal (DIV)",tag_h:"Header",tag_p:"Paragraph",tag_pre:"Code",template:"Template",textStyle:"Text style",title:"Title",underline:"Underline",undo:"Undo",unmergeCells:"Unmerge cells",unlink:"Unlink",verticalSplit:"Vertical split",video:"Video",videoGallery:"Video gallery",video_modal_file:"Select from files",video_modal_title:"Insert Video",video_modal_url:"Media embed URL, YouTube/Vimeo",width:"Width",codeLanguage:"Language",codeLanguage_none:"None",finder_matchCase:"Match Case",finder_wholeWord:"Whole Word",finder_regex:"Regular Expression",finder_prev:"Previous Match",finder_next:"Next Match",message_copy_success:"Copied to clipboard",message_copy_fail:"Copy failed. Please copy manually."};return void 0===e&&(t.SUNEDITOR_LANG||Object.defineProperty(t,"SUNEDITOR_LANG",{enumerable:!0,writable:!1,configurable:!1,value:{}}),Object.defineProperty(t.SUNEDITOR_LANG,"en",{enumerable:!0,writable:!0,configurable:!0,value:s})),s},"object"==typeof t.exports?t.exports=e.document?s(e,!0):function(t){if(!t.document)throw new Error("SUNEDITOR_LANG a window with a document");return s(t)}:s(e)}},e={};function s(i){var n=e[i];if(void 0!==n)return n.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,s),o.exports}s.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},s.d=(t,e)=>{for(var i in e)s.o(e,i)&&!s.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{"use strict";var t={};s.r(t),s.d(t,{Browser:()=>Xr,ColorPicker:()=>zl,Controller:()=>Ii,Figure:()=>ji,HueSlider:()=>Al,Modal:()=>Fl});var e={};s.r(e),s.d(e,{ApiManager:()=>Kr,FileManager:()=>ql});var i={};s.r(i),s.d(i,{CommandMenu:()=>gn,ModalAnchorEditor:()=>Vl,SelectMenu:()=>Ai,_DragHandle:()=>_i});var n={};s.r(n),s.d(n,{EditorComponent:()=>Tc,ModuleBrowser:()=>$c,ModuleColorPicker:()=>Sc,ModuleController:()=>xc,ModuleHueSlider:()=>Ec,ModuleModal:()=>kc,PluginBrowser:()=>Kl,PluginCommand:()=>Yl,PluginDropdown:()=>Xl,PluginDropdownFree:()=>Zl,PluginField:()=>Jl,PluginInput:()=>Ql,PluginModal:()=>ta,PluginPopup:()=>ea});const o=window,r=document,l=Symbol("noEventHandler"),a=Symbol("onOverComponent"),h=navigator.userAgent.toLowerCase();const c="function"==typeof ResizeObserver,d="function"==typeof navigator.clipboard?.write,u=/Edg/.test(navigator.userAgent),p=/(Mac|iPhone|iPod|iPad)/.test(navigator.userAgent),g=h.includes("chrome/")&&!h.includes("edge/"),m=!!h.match(/gecko\/\d+/),f=!!o.chrome,v=h.includes("applewebkit/")&&!h.includes("chrome"),b=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(h),y=navigator.maxTouchPoints>0&&"ontouchstart"in o,w=h.includes("android"),C=p?"⌘":"CTRL",_=p?"⇧":"+SHIFT",k=o.devicePixelRatio;let x=null;const $={_w:o,_d:r,NO_EVENT:l,ON_OVER_COMPONENT:a,getXMLHttpRequest:function(){return new XMLHttpRequest},getPageStyle:function(t){let e="";const s=(t||r).styleSheets;for(let t,i=0,n=s.length;i0?i[0][o]:""),s.includes(":/")||"//"===s.slice(0,2)||(s=!1===s.includes("/")?location.href.match(/^.*?:\/\/[^/]*/)[0]+s:location.href.match(/^[^?]*\/(?:)/)[0]+s),s},isResizeObserverSupported:c,isClipboardSupported:d,isEdge:u,isBlink:g,isGecko:m,isChromium:f,isSafari:v,isOSX_IOS:p,isAndroid:w,isMobile:b,isTouchDevice:y,canUseBeforeInput:function(){if(null!==x)return x;if(!r.body||"function"!=typeof r.execCommand)return!0;let t=!1;try{const e=r.createElement("div");e.setAttribute("contenteditable","true"),e.setAttribute("aria-hidden","true"),e.style.cssText="position: fixed; top: 0; left: -9999px; width: 1px; height: 1px; opacity: 0; pointer-events: none;";const s=r.activeElement;r.body.appendChild(e);const i=()=>{t=!0};e.addEventListener("beforeinput",i,!0),e.addEventListener("input",i,!0),e.focus({preventScroll:!0}),r.execCommand("insertText",!1,"​"),e.removeEventListener("beforeinput",i,!0),e.removeEventListener("input",i,!0),e.remove(),s&&s!==r.body&&"function"==typeof s.focus&&s.focus({preventScroll:!0})}catch{t=!0}return x=t},cmdIcon:C,shiftIcon:_,DPI:k,KATEX_WEBSITE:"https://katex.org/docs/supported.html",MATHJAX_WEBSITE:"https://www.mathjax.org/"},S=8203,E=String.fromCharCode(S),T=new RegExp(String.fromCharCode(S),"g"),M=new RegExp("^"+String.fromCharCode(S)+"+$");const N={zeroWidthSpace:E,zeroWidthRegExp:T,onlyZeroWidthRegExp:M,escapeStringRegexp:function(t){if("string"!=typeof t)throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}};function B(t,e=0){if(!t)return 0;const s=(t+"").match(/-?\d+(\.\d+)?/);if(!s||!s[0])return 0;const i=Number(s[0]);return e<0?i:0===e?Math.round(i):Number(i.toFixed(e))}const I={is:function(t){return/^-?\d+(\.\d+)?$/.test(t+"")},get:B,getOverlapRangeAtIndex:function(t,e,s,i){if(t<=i?es)return 0;const n=(t>s?t:s)-(e/g,A=/&| |'|"|<|>/g,O={"&":"&"," ":" ","'":"'",'"':""","<":"<",">":">"},R={"&":"&"," ":" ","'":"'",""":'"',"<":"<",">":">"},z=/[A-Z]/g,P=/-[a-zA-Z]/g,D={"xx-small":.5625,"x-small":.625,small:.8333,medium:1,large:1.125,"x-large":1.5,"xx-large":2,"xxx-large":2.5};function F(t){if(3===t.nodeType){const e=t.nodeValue.trim();return e?{type:"text",content:e}:null}if(1===t.nodeType){const e={type:"element",tag:t.tagName.toLowerCase(),attributes:{},children:[]};for(const s of t.attributes)e.attributes[s.name]=s.value;for(const s of t.childNodes){const t=F(s);t&&e.children.push(t)}return e}return null}function H(t){return t.replace(L,(t=>O[t]||t))}function q(t){return/^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(t)}const W={htmlToJson:function(t){return F((new DOMParser).parseFromString(t,"text/html").body)},jsonToHtml:function t(e){if(!e)return"";if("text"===e.type)return H(e.content||"");if("element"===e.type){const{tag:s,attributes:i={},children:n=[]}=e,o=Object.entries(i).map((([t,e])=>`${t}="${H(e)}"`)).join(" "),r=``;return`${o?`<${s} ${o}>`:`<${s}>`}${n.map(t).join("")}${r}`}return""},htmlToEntity:H,entityToHTML:function(t){return t.replace(A,(t=>R[t]||t))},debounce:function(t,e){let s;function i(...i){o.clearTimeout(s),s=o.setTimeout((()=>{s=null,t(...i)}),e)}return i.cancel=()=>{o.clearTimeout(s),s=null},i},syncMaps:function(t,e){e.forEach(((e,s)=>{t.set(s,e)})),t.forEach(((s,i)=>{e.has(i)||t.delete(i)}))},mergeMaps:function(...t){const e=t.filter((t=>t instanceof Map)).flatMap((t=>[...t]));return new Map(e)},getValues:function(t){return t?Object.keys(t).map((function(e){return t[e]})):[]},camelToKebabCase:function t(e){return"string"==typeof e?e.replace(z,(t=>"-"+t.toLowerCase())):e.map((function(e){return t(e)}))},kebabToCamelCase:function t(e){return"string"==typeof e?e.replace(P,(t=>t.replace("-","").toUpperCase())):e.map((function(e){return t(e)}))},toFontUnit:function(t,e){const s=e.match(/(\d+(?:\.\d+)?)(.+)/),i=s?Number(s[1]):D[e],n=s?s[2]:"rem";let o=i;switch(/em/.test(n)?o=Math.round(i/.0625):"pt"===n?o=Math.round(1.333*i):"%"===n&&(o=i/100),t){case"em":case"rem":return(.0625*o).toFixed(2)+t;case"%":return 100*Number((.0625*o).toFixed(2))+t;case"pt":return Math.round(o/1.333)+t;default:return o+t}},nodeListToArray:function(t){return t?Array.prototype.slice.call(t):[]},swapKeyValue:function(t){const e={},s=Object.prototype.hasOwnProperty;for(const i in t)s.call(t,i)&&(e[t[i]]=i);return e},createElementWhitelist:function(t){return new RegExp(`<\\/?\\b(?!\\b${(t||"").replace(/\|/g,"\\b|\\b")}\\b)[^>]*>`,"gi")},createElementBlacklist:function(t){return new RegExp(`<\\/?\\b(?:\\b${(t||"^").replace(/\|/g,"\\b|\\b")}\\b)[^>]*>`,"gi")},isHexColor:q,rgb2hex:function(t){if(q(t)||!t)return t;const e=t.match(/^rgba?[\s+]?\(([\d]+)[\s+]?,[\s+]?([\d]+)[\s+]?,[\s+]?([\d]+)[\s+]?/i);if(e&&e.length>=4){const s=("0"+parseInt(e[1],10).toString(16)).slice(-2),i=("0"+parseInt(e[2],10).toString(16)).slice(-2),n=("0"+parseInt(e[3],10).toString(16)).slice(-2);let o="";if(t.includes("rgba")){const e=t.match(/,\s*([\d]+\.?[\d]*)\s*\)/);e&&(o=("0"+Math.round(255*parseFloat(e[1])).toString(16)).slice(-2))}return`#${s}${i}${n}${o}`}return t},getWidthInPercentage:function(t,e){const s=e||t.parentElement,i=o.getComputedStyle(s),n=B(i.paddingLeft,-1),r=B(i.paddingRight,-1),l=s.offsetWidth-s.clientWidth,a=s.offsetWidth-n-r-l;return t.offsetWidth/a*100},textToAnchor:function(t){const e=/https?:\/\/[^\s]+/g;if(3===t.nodeType&&e.test(t.textContent)&&!/^A$/i.test(t.parentNode?.nodeName)){const s=t.textContent,i=r.createDocumentFragment();let n=0;return s.replace(e,((t,e)=>{e>n&&i.appendChild(r.createTextNode(s.slice(n,e)));const o=r.createElement("a");return o.href=t,o.target="_blank",o.textContent=t,i.appendChild(o),n=e+t.length,t})),n{if(t[e].regex.test(s)){const s=r.createElement(t[e].tag);i.push(s)}})),i.length>0){const t=r.createElement("span");let s=e.firstChild;i.forEach(((e,s)=>{0===s?t.appendChild(e):i[s-1].appendChild(e)}));const n=i[i.length-1];for(;s;){const t=s.nextSibling;n.appendChild(s),s=t}e.appendChild(t)}}},addUrlQuery:function(t,e){if(e.length>0)if(/\?/.test(t)){const s=t.split("?");t=s[0]+"?"+e+"&"+s[1]}else t+="?"+e;return t},_setDefaultOptionStyle:function(t,e){let s="";t.get("height")&&(s+="height:"+t.get("height")+";"),t.get("minHeight")&&(s+="min-height:"+t.get("minHeight")+";"),t.get("maxHeight")&&(s+="max-height:"+t.get("maxHeight")+";"),t.get("width")&&(s+="width:"+t.get("width")+";"),t.get("minWidth")&&(s+="min-width:"+t.get("minWidth")+";"),t.get("maxWidth")&&(s+="max-width:"+t.get("maxWidth")+";");let i="",n="",o="";const r=(e=s+e).split(";");for(let e,s=0,l=r.length;s'}}return e},_setAutoHeightStyle:function(t){return"auto"===t?"":""}},U=W,V=/(\s|^)(katex|MathJax|se-exclude-format)(\s|$)/;function j(t){if(null==t)return!1;if("string"!=typeof t){if(G(t)){const e=t.children;for(let t=0,s=e.length;t=t.nodeValue.length},isText:function(t){return 3===t?.nodeType},isElement:G,isInputElement:function(t){return G(t)&&/^(INPUT|TEXTAREA|SELECT|OPTION)$/i.test(t.nodeName)},isButtonElement:function(t){return G(t)&&/^(BUTTON)$/i.test(t.nodeName)},isList:K,isListCell:function(t){return/^LI$/i.test("string"==typeof t?t:t?.nodeName)},isTable:Y,isTableElements:function(t){return/^(TABLE|THEAD|TBODY|TR|TH|TD|COL)$/i.test("string"==typeof t?t:t?.nodeName)},isTableCell:X,isTableRow:function(t){return/^TR$/i.test("string"==typeof t?t:t?.nodeName)},isBreak:Z,isAnchor:function(t){return/^A$/i.test("string"==typeof t?t:t?.nodeName)},isMedia:function(t){return/^(IMG|IFRAME|AUDIO|VIDEO|CANVAS)$/i.test("string"==typeof t?t:t?.nodeName)},isIFrame:function(t){return/^IFRAME$/i.test("string"==typeof t?t:t?.nodeName)},isFigure:function(t){return/^FIGURE$/i.test("string"==typeof t?t:t?.nodeName)},isContentLess:J,isEmptyLine:function(t){if(!t?.parentNode)return!0;const e=t;return!e.querySelector("IMG, IFRAME, AUDIO, VIDEO, CANVAS, TABLE")&&(e.children.length<=1||Z(e.firstElementChild))&&j(e.textContent)},isComponentContainer:Q,isWysiwygFrame:tt,isNonEditable:function(t){return 1===t?.nodeType&&"false"===t.getAttribute("contenteditable")},isSpanWithoutAttr:function(t){if(1!==t?.nodeType)return!1;const e=t;return/^SPAN$/i.test(e.nodeName)&&!e.className&&0===e.style.length},isSameAttributes:function(t,e){if(3===t.nodeType&&3===e.nodeType)return!0;if(3===t.nodeType||3===e.nodeType)return!1;const s=t,i=e,n=s.style,o=i.style;let r=0;for(let t=0,e=n.length;t0){const t=n.style;for(let e=0,s=t.length;et.classList.contains(e)))}function dt(t,e){if(!t)return;const s=nt(t)?t:[t],i=e.split("|");for(let t=0,e=s.length;t!0;const s=[];for(let i,n=0,o=t.length;n!0;for(let s,i=0,n=t.length;i{ut(t,e)}),s)},getClientSize:pt,getViewportSize:function(){return"visualViewport"in o?{top:o.visualViewport.pageTop,left:o.visualViewport.pageLeft,scale:o.visualViewport.scale}:{top:0,left:0,scale:1}},applyInlineStylesAll:function(t,e,s){if(!t)return console.warn('"parentTarget" is not exist'),null;let i=t;const n=r.createElement("DIV");if(n.style.display="none",/body/i.test(i.nodeName)){const t=r.createElement("DIV"),e=i.attributes;for(let s=0,i=e.length;s{const i=["img","video","audio","iframe"].flatMap((t=>Array.from(s.querySelectorAll(t))));if(0===i.length)return void t();const n=i.map((t=>{if(function(t){return"[object HTMLImageElement]"===Object.prototype.toString.call(t)}(t)){if(t.complete)return Promise.resolve()}else if(function(t){const e=Object.prototype.toString.call(t);return"[object HTMLVideoElement]"===e||"[object HTMLAudioElement]"===e}(t)){if(t.readyState>=2)return Promise.resolve()}else if(function(t){return"[object HTMLIFrameElement]"===Object.prototype.toString.call(t)}(t))try{if("complete"===t.contentDocument?.readyState)return Promise.resolve()}catch(t){console.warn(["[SUNEDITOR] Iframe load error",t])}return new Promise((e=>{t.addEventListener("load",e,{once:!0}),t.addEventListener("error",e,{once:!0})}))}));Promise.race([Promise.all(n),new Promise((t=>o.setTimeout(t,e)))]).then((()=>{t()}))}))},getRootCssVar:function(t){return r.documentElement.style.getPropertyValue(t)},setRootCssVar:function(t,e){r.documentElement.style.setProperty(t,e)},createTooltipInner:function(t){return`${t}`}};function mt(t){let e=0;for(;t=t.previousSibling;)e+=1;return e}function ft(t,e,s){const i=[];let n=!0;return wt(t,(t=>{if(t===e&&(n=!1),n&&!it.isWysiwygFrame(t)){if(s&&3===t.nodeType){let e=null,i=null;s.s=s.e=0;let n=t.previousSibling;for(;3===n?.nodeType;)i=n.textContent.replace(T,""),s.s+=i.length,t.textContent=i+t.textContent,e=n,n=n.previousSibling,gt.removeItem(e);let o=t.nextSibling;for(;3===o?.nodeType;)i=o.textContent.replace(T,""),s.e+=i.length,t.textContent+=i,e=o,o=o.nextSibling,gt.removeItem(e)}i.push(t)}return!1})),i.map(mt).reverse()}function vt(t,e){let s,i=e;for(let e=0,n=t.length;e!0,function t(n,o){if(o>s)return;if(o>0&&e(n)&&i.push(n),o===s)return;const r=n.childNodes;for(let e=0,s=r.length;et===e;else{let t;/^\./.test(e)?(t="className",e="(\\s|^)"+e.split(".")[1]+"(\\s|$)"):/^#/.test(e)?(t="id",e="^"+e.split("#")[1]+"$"):/^:/.test(e)?(t="name",e="^"+e.split(":")[1]+"$"):(t="nodeName",e="^"+e+"$");const s=new RegExp(e,"i");i=e=>s.test(e[t])}s||=1/0;let n=0;for(;t&&!i(t);){if(n>=s||it.isWysiwygFrame(t))return null;t=t.parentElement,n++}return t}const Ct={getPositionIndex:mt,getNodePath:ft,getNodeFromPath:vt,getChildNode:function(t,e){let s=null;if(!t)return s;const i=t;return i.children&&0!==i.children.length?(e||=()=>!0,function t(n){if(i!==n&&e(n))return s=n,!0;if(n.children)for(let e=0,s=n.children.length;e!0,function t(o,r){if(!(r>s)&&(r>0&&n!==o&&e(o)&&i.push(o),r!==s&&o.children))for(let e=0,s=o.children.length;eo?s:no){let t=n-o;for(;t>0&&s;)s=s.parentElement,t--}else if(o>n){let t=o-n;for(;t>0&&i;)i=i.parentElement,t--}for(;s&&i&&s.parentElement!==i.parentElement;)s=s.parentElement,i=i.parentElement;if(!s?.parentNode||!i?.parentNode)return{ancestor:null,a:t,b:e,result:0};const r=s.parentNode.childNodes,l=gt.getArrayIndex(r,s),a=gt.getArrayIndex(r,i);return{ancestor:s.parentElement,a:s,b:i,result:l>a?1:lt===e;else{let t;/^\./.test(e)?(t="className",e="(\\s|^)"+e.split(".")[1]+"(\\s|$)"):/^#/.test(e)?(t="id",e="^"+e.split("#")[1]+"$"):/^:/.test(e)?(t="name",e="^"+e.split(":")[1]+"$"):(t="nodeName",e="^"+e+"$");const s=new RegExp(e,"i");i=e=>s.test(e[t])}const n=[];s||=1/0;let o=0;for(;o<=s&&t&&!it.isWysiwygFrame(t);)i(t)&&n.push(t),t=t.parentElement,o++;return n},getCommandTarget:function(t){let e=t;for(;e&&!/^(UL)$/i.test(e.nodeName)&&!gt.hasClass(e,"sun-editor");){if(e.hasAttribute("data-command"))return e;e=e.parentElement}return null},getEventTarget:function(t){return t.target},getEdgeChild:function(t,e,s){let i;if("function"==typeof e)i=e;else if("object"==typeof e)i=function(t){return t===e};else{let t;/^\./.test(e)?(t="className",e="(\\s|^)"+e.split(".")[1]+"(\\s|$)"):/^#/.test(e)?(t="id",e="^"+e.split("#")[1]+"$"):/^:/.test(e)?(t="name",e="^"+e.split(":")[1]+"$"):(t="nodeName",e="^"+("text"===e?"#"+e:e)+"$");const s=new RegExp(e,"i");i=function(e){return s.test(e[t])}}const n=bt(t,(t=>i(t)),null);return n[s?n.length-1:0]},getEdgeChildNodes:function(t,e){if(t){for(e||=t;t&&1===t.nodeType&&t.childNodes.length>0&&!it.isBreak(t);)t=t.firstChild;for(;e&&1===e.nodeType&&e.childNodes.length>0&&!it.isBreak(e);)e=e.lastChild;return{sc:t,ec:e||t}}},getPreviousDeepestNode:function(t,e){let s=t.previousSibling;if(!s){for(let i=t.parentNode;i;i=i.parentNode){if(i===e)return null;if(i.previousSibling){s=i.previousSibling;break}}if(!s)return null}if(it.isNonEditable(s))return s;for(;!it.isComponentContainer(s)&&s.lastChild;)s=s.lastChild;return s},getNextDeepestNode:function(t,e){let s=t.nextSibling;if(!s){for(let i=t.parentNode;i;i=i.parentNode){if(i===e)return null;if(i.nextSibling){s=i.nextSibling;break}}if(!s)return null}if(it.isNonEditable(s))return s;for(;!it.isComponentContainer(s)&&s.firstChild;)s=s.firstChild;return s},findTextIndexOnLine:function(t,e,s,i){if(!t)return 0;i||=()=>!0;let n=0,o=!1;return function t(r){if(!o&&8!==r.nodeType&&!i(r))if(3===r.nodeType){if(r===e)return n+=s,void(o=!0);n+=r.textContent.length}else if(1===r.nodeType){const e=r.childNodes;for(let s=0,i=e.length;s=e){const t=o.index+o[0].length-1;return t+(i.slice(0,t+1).match(/[^\u00A0\s]/g)||[]).length+s}return 0},findVisualLastCell:function(t){if(!t||0===t.length)return null;const e={};let s=null,i=-1,n=-1;for(const o of t){const t=o.parentElement.rowIndex,r=o.rowSpan||1,l=o.colSpan||1;e[t]||=[];let a=0;const h=e[t];for(;h[a];)a++;for(let t=0;ti||c===i&&d>n)&&(i=c,n=d,s=o)}return s},getScrollParents:function(t){const e=[];let s=t?.parentElement;for(;s&&!/^(body|html)$/i.test(s.nodeName);){const t=o.getComputedStyle(s),{overflow:i,overflowX:n,overflowY:r}=t;[i,n,r].some((t=>["auto","scroll","overlay"].includes(t)))&&e.push(s),s=s.parentElement}return e},getIframeDocument:function(t){return t.contentWindow?.document||t.contentDocument}};const _t={query:Ct,check:it,utils:gt},kt="ArrowLeft|ArrowUp|ArrowRight|ArrowDown",xt="F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12",$t=kt.split("|"),St="Backspace|Delete".split("|"),Et=`Backspace|Tab|Enter|ShiftLeft|ShiftRight|ControlLeft|ControlRight|AltLeft|AltRight|Pause|CapsLock|Escape|PageUp|PageDown|End|Home|${kt}|Insert|Delete|${xt}|NumLock|ScrollLock`.split("|"),Tt="Backspace|Enter|Delete".split("|"),Mt="Backspace|Enter|Delete".split("|"),Nt=`ControlLeft|ControlRight|AltLeft|AltRight|Pause|CapsLock|Escape|Insert|${xt}|NumLock|ScrollLock`.split("|");const Bt={write:async function(t){if(!d)return console.error("Clipboard is not supported in this browser."),!1;let e="",s="";"string"==typeof t?(e=t,s=t):G(t)?(t.querySelectorAll("iframe").forEach((t=>{const e=document.createElement("div"),s={};for(const e of Array.from(t.attributes))s[e.name]=e.value;e.setAttribute("data-se-iframe-holder","1"),e.setAttribute("data-se-iframe-holder-attrs",JSON.stringify(s)),e.innerText=`[iframe: ${t.src}]`,t.replaceWith(e)})),e=t.outerHTML,s=t.textContent):(e=t.textContent,s=t.textContent);try{await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([e],{type:"text/html"}),"text/plain":new Blob([s],{type:"text/plain"})})])}catch{console.warn("[SUNEDITOR.copy.warn] This browser is not supported Clipboard API");try{await navigator.clipboard.writeText(s||function(t){const e=document.createElement("div");return e.innerHTML=t,e.textContent||e.innerText||""}(e))}catch(t){console.error("[SUNEDITOR.copy.fail] "+t)}}}},It=/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/i,Lt=/^[\u200B\uFEFF]+$/;function At(t){const e=t.trim();return""===e||Lt.test(e)}const Ot={strong:"**",b:"**",em:"*",i:"*",del:"~~",s:"~~",mark:"=="};function Rt(t){if(!t||0===t.length)return"";const e=[];for(let s=0;s0){const t=e[e.length-1];!t||t.endsWith(" ")||t.endsWith("\n")||i.startsWith(" ")||i.startsWith("\n")||e.push(" ")}e.push(i)}}return e.join("")}function zt(t){return t?"text"===t.type?t.content||"":t.children?t.children.map(zt).join(""):"":""}function Pt(t){if(!t)return"";if("text"===t.type)return t.content||"";const{tag:e,attributes:s={},children:i=[]}=t,n=Object.entries(s).map((([t,e])=>`${t}="${e}"`)).join(" "),o=n?`<${e} ${n}>`:`<${e}>`;if(It.test(e))return o;return`${o}${i.map(Pt).join("")}`}function Dt(t,e){return t?t.split("\n").map((t=>t?e+t:"")).join("\n")+"\n":""}function Ft(t,e,s){const i=t.children||[];let n="",o=1;for(const t of i){if("element"!==t.type||"li"!==t.tag)continue;const i=s?`${o}. `:"- ",r=t.children||[];let l="",a="";const h=e+" ".repeat(i.length);let c="";const d=r[0];d&&"element"===d.type&&"input"===d.tag&&"checkbox"===d.attributes?.type&&(c=void 0!==d.attributes.checked?"[x] ":"[ ] ");for(let t=0;t"element"===t.type&&"table"===t.tag));a+=Dt(t?Ht(t):qt(e,"",!0),h)}else"blockquote"===s||"pre"===s?a+=Dt(qt(e,"",!0),h):l+=qt(e,"",!1)}n+=`${e}${i}${c}${l.trim()}\n`,a&&(n+=a),o++}return n}function Ht(t){const e=[];let s=!1;if(function t(i,n){for(const o of i.children||[])if("thead"===o.tag)t(o,!0);else if("tbody"===o.tag||"tfoot"===o.tag)t(o,!1);else if("tr"===o.tag){const t=[];for(const e of o.children||[])if("td"===e.tag||"th"===e.tag){const s=Rt(e.children).trim(),i=parseInt(e.attributes?.colspan,10)||1,n=parseInt(e.attributes?.rowspan,10)||1;t.push({content:s,colspan:i,rowspan:n})}const i=n||!s&&o.children?.some((t=>"th"===t.tag));i&&(s=!0),e.push({cells:t,isHeader:i})}}(t,!1),0===e.length)return"";const i=e.filter((t=>t.isHeader)),n=e.filter((t=>!t.isHeader)),o=[...i,...n];let r=0;for(const t of o){let e=0;for(const s of t.cells)e+=s.colspan;e>r&&(r=e)}const l=Array.from({length:o.length},(()=>new Array(r).fill(null)));for(let t=0;t=r)break;for(let i=0;i0){a+="| "+l[0].join(" | ")+" |\n",a+="| "+l[0].map((()=>"---")).join(" | ")+" |\n";for(let t=1;tqt(t,"",!0))).join("");const r=/^h([1-6])$/.exec(i);if(r){const t=Rt(o).trim();if(!t)return"\n";const e=parseInt(r[1],10);return`${"#".repeat(e)} ${t}\n\n`}if("p"===i){const t=Rt(o);return t.trim()?`${t.trim()}\n\n`:"\n"}if("br"===i)return"\n";if("hr"===i)return"---\n\n";const l=Ot[i];if(l){return`${l}${Rt(o)}${l}`}if("code"===i){const t=zt({children:o});return t.includes("`")?"`` "+t+" ``":"`"+t+"`"}if("kbd"===i){return`${zt({children:o})}`}if("sub"===i){return`${Rt(o)}`}if("sup"===i){return`${Rt(o)}`}if("a"===i){const t=n.href||"",e=Rt(o),s=n.title;return s?`[${e}](${t} "${s}")`:`[${e}](${t})`}if("img"===i){const t=n.src||"";return`![${n.alt||""}](${t})`}if("blockquote"===i){return o.map((t=>qt(t,"",!0))).join("").replace(/\n$/,"").split("\n").map((t=>`> ${t}`)).join("\n")+"\n\n"}if("pre"===i){let e="",s="";const i=o.find((t=>"element"===t.type&&"code"===t.tag));return i?(e=(i.attributes?.class||"").replace(/^language-/,""),s=zt(i)):(e=(t.attributes?.class||"").match(/language-(\S+)/)?.[1]||"",s=zt({children:o})),"```"+e+"\n"+s+"\n```\n\n"}if("details"===i)return Pt(t)+"\n\n";if("summary"===i)return Pt(t);if("ul"===i)return Ft(t,e,!1)+"\n";if("ol"===i)return Ft(t,e,!0)+"\n";if("table"===i)return Ht(t)+"\n";if("dl"===i){let t="";for(const e of o)"element"===e.type&&("dt"===e.tag?t+=Rt(e.children).trim()+"\n":"dd"===e.tag&&(t+=": "+Rt(e.children).trim()+"\n"));return t+"\n"}if("dt"===i||"dd"===i)return Rt(o).trim();if("div"===i){if(n.class&&/se-component/.test(n.class))return o.map((t=>qt(t,e,!0))).join("");const t=Rt(o);return s?t+"\n\n":t}if("span"===i)return n.style||n.class?Pt(t):Rt(o);if("figure"===i){const t=o.map((t=>qt(t,e,!0))).join("");return/\n$/.test(t)?t:t+"\n\n"}if("figcaption"===i){const t=Rt(o).trim();return t?t+"\n\n":""}return"video"===i||"audio"===i||"iframe"===i?Pt(t)+"\n\n":Pt(t)}function Wt(t){if(!t)return"";const e=[];function s(t){return e.push(t),""+(e.length-1)+""}return t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace(/\\([\\*_~`[\]()#!|{}<>+-])/g,((t,e)=>s(e)))).replace(/``\s(.+?)\s``/g,((t,e)=>s(""+e+"")))).replace(/`([^`]+)`/g,((t,e)=>s(""+e+"")))).replace(/!\[([^\]]*)\]\(([^)\s]+)(?:\s+"([^"]*)")?\)/g,((t,e,i,n)=>s(n?`${e}`:`${e}`)))).replace(/\[([^\]]+)\]\(([^)\s]+)(?:\s+"([^"]*)")?\)/g,((t,e,i,n)=>s(n?`${e}`:`${e}`)))).replace(/<(https?:\/\/[^>]+)>/g,((t,e)=>s(`${e}`)))).replace(/<([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})>/g,((t,e)=>s(`${e}`)))).replace(/(?\])"]+)/g,((t,e)=>s(`${e}`)))).replace(/~~(.+?)~~/g,"$1")).replace(/\*{3}(.+?)\*{3}/g,"$1")).replace(/_{3}(.+?)_{3}/g,"$1")).replace(/\*{2}(.+?)\*{2}/g,"$1")).replace(/_{2}(.+?)_{2}/g,"$1")).replace(/\*(.+?)\*/g,"$1")).replace(/(?$1")).replace(/==(.+?)==/g,"$1")).replace(/\^([^\s^]+)\^/g,"$1")).replace(/(?$1")).replace(/\uFFFC(\d+)\uFFFC/g,((t,s)=>e[parseInt(s,10)]))}function Ut(t){if(t.length<2)return"";const e=t=>t.replace(/^\|/,"").replace(/\|$/,"").split("|").map((t=>t.trim())),s=e(t[0]),i=e(t[1]).map((t=>{const e=t.trim();return/^:-+:$/.test(e)?"center":/^-+:$/.test(e)?"right":/^:-+$/.test(e)?"left":""})),n=t.slice(2).map(e),o=s.length,r=s.every((t=>""===t));let l="";const a=t=>{const e=i[t];return e?` style="text-align: ${e};"`:""};if(!r){l+="";for(let t=0;t${Wt(s[t])}`;l+=""}if(n.length>0||r){l+="";for(const t of n){l+="";for(let e=0;e${Wt(t[e]||"")}`;l+=""}l+=""}return l+="
",l}function Vt(t,e,s){const i=s?"ol":"ul",n=s?/^(\s*)\d+\.\s+(.*)/:/^(\s*)([-*+])\s+(.*)/;let o=`<${i}>`,r=e;const l=(t[r].match(/^(\s*)/)[1]||"").length;for(;r${h?' ':' '}${Wt(c)}${u}`}else o+=`
  • ${Wt(i)}${u}
  • `}}return o+=``,{html:o,index:r}}const jt={jsonToMarkdown:function(t){return t?qt(t,"",!0).replace(/\n{3,}/g,"\n\n").trim()+"\n":""},markdownToHtml:function t(e,s){if(!e)return"";s||(s="p");const i=e.split("\n"),n=[];let o=0;for(;o${r=a.join("\n"),r.replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}`);continue}const a=/^(#{1,6})\s+(.+)/.exec(e);if(a){const t=a[1].length;n.push(`${Wt(a[2].trim())}`),o++;continue}if(/^(\*{3,}|-{3,}|_{3,})\s*$/.test(e)){n.push("
    "),o++;continue}if(/^>\s?/.test(e)){const e=[];for(;o\s?/.test(i[o]);)e.push(i[o].replace(/^>\s?/,"")),o++;const r=t(e.join("\n"),s);n.push(`
    ${r}
    `);continue}if(/^\|.*\|/.test(e)&&o+1|\||(\s*)([-*+]|\d+\.)\s|(\*{3,}|-{3,}|_{3,})\s*$)/.test(i[o]);)h.push(i[o]),o++;if(h.length>0){const t=Wt(h.join("\n"));n.push(`<${s}>${t}`)}else n.push(`<${s}>${Wt(i[o])}`),o++}var r;return n.join("")}},Gt=//gi,Kt=/<\/?(?:\w+:)\w+[^>]*>/gi,Yt=/[\s\S]*?<\/xml>/gi,Xt=/]*>[\s\S]*?<\/style>/gi,Zt=/\s*mso-[^:]+:[^;"]+;?/gi,Jt=/l(\d+)\s+level(\d+)\s+lfo(\d+)/i,Qt=/mso-list:\s*Ignore/i,te=/\bMso\w+/g,ee=/\bxl\d+/g,se=/\s*tab-stops:[^;"]+;?/gi,ie=/^[\s\u00a0]*[\u2022\u00b7\u00a7\u25cf\u25cb\u25aa\u25a0·o§]\s*/,ne=[/^\s*[0-9]+[.)]\s/,/^\s*[a-z][.)]\s/i,/^\s*[ivxlmcd]+[.)]\s/i],oe=/([\s\u00a0]*)<\/span>/gi,re=/[^<]*<\/span>/gi,le=/mso-outline-level:\s*(\d+)/i,ae=/mso-highlight:\s*([^;"]+)/i,he=/mso-level-number-format:\s*([^;\s]+)/i,ce=/mso-level-start-at:\s*(\d+)/i,de=/mso-level-text:\s*([^;\s]+)/i,ue={decimal:"decimal","alpha-upper":"upper-alpha","alpha-lower":"lower-alpha","roman-upper":"upper-roman","roman-lower":"lower-roman","arabic-leading-zero":"decimal-leading-zero"},pe=/\s*margin:\s*0[a-z]*\s+0[a-z]*\s+0[a-z]*\s*;?/gi,ge=/\s*text-indent:\s*-?[\d.]+[a-z]*\s*;?/gi,me=/\s*line-height:\s*normal\s*;?/gi,fe=/MsoHeading(\d)/i,ve=/^file:\/\/\//i,be=/^_(Toc|Ref|Hlt|Hlk)\d+$/i,ye=/^#_(Toc|Ref|Hlt|Hlk)\d+$/i,we=/page-break-before\s*:\s*always/i,Ce=/mso-break-type\s*:\s*section-break/i,_e=/mso-column-break-before\s*:\s*always/i,ke=/^(?:Word)?Section\d+$/i;function xe(t){const e=t.replace(/[\s\u00a0]+/g," ").trim();if(ie.test(e))return"ul";for(const t of ne)if(t.test(e))return"ol";return"ul"}function $e(t){const e=document.createTreeWalker(t,NodeFilter.SHOW_COMMENT,null),s=[];for(;e.nextNode();)s.push(e.currentNode);for(const t of s)t?.remove();const i=t.querySelectorAll("span");for(const t of i){const e=t.getAttribute("style")||"";Qt.test(e)&&t.remove()}t.firstChild&&3===t.firstChild.nodeType&&(t.firstChild.nodeValue=t.firstChild.nodeValue.replace(/^[\s\u00a0]+/,""))}function Se(t){const e=t.getAttribute("style");if(!e)return;let s=e;const i=ae.exec(s);!i||/background-color/i.test(s)||/background\s*:/i.test(s)||(s+=";background-color:"+i[1].trim()),s=s.replace(Zt,"").replace(se,"").replace(pe,"").replace(ge,"").replace(me,"").trim(),s=s.replace(/^;+|;+$/g,"").replace(/;{2,}/g,";").trim(),s?t.setAttribute("style",s):t.removeAttribute("style")}function Ee(t){const e=t.getAttribute("class");if(!e)return;const s=e.replace(te,"").replace(ee,"").trim();s?t.setAttribute("class",s):t.removeAttribute("class")}function Te(t){let e=t.previousSibling;for(;e;){if(1===e.nodeType)return e;if(3===e.nodeType&&e.nodeValue.trim())return null;e=e.previousSibling}return null}function Me(t,e){for(const s of t){const t=`l${s.listId}:level${s.level}`,i=e.get(t);if(i)s.type=i.type,s.listStyleType=i.listStyleType,s.startAt=i.startAt;else{const t=Be(s.el);s.type=xe(t),s.listStyleType="",s.startAt=1}}const s=t[0].el.parentNode,i=t[t.length-1].el.nextSibling,n=[];let o=null;for(const e of t){const{el:t,level:s,type:i,listStyleType:r,startAt:l}=e;$e(t),Se(t),Ee(t);const a=t.ownerDocument.createElement("li");for(;t.firstChild;)a.appendChild(t.firstChild);if(t.getAttribute("style")&&a.setAttribute("style",t.getAttribute("style")),0===n.length)o=Ne(t.ownerDocument,i,r,l),o.appendChild(a),n.push({listEl:o,level:s});else{const e=n[n.length-1].level;if(s>e){const e=n[n.length-1].listEl.lastElementChild,o=Ne(t.ownerDocument,i,r,l);o.appendChild(a),e?e.appendChild(o):n[n.length-1].listEl.appendChild(o),n.push({listEl:o,level:s})}else if(s1&&n[n.length-1].level>s;)n.pop();n[n.length-1].listEl.appendChild(a)}else n[n.length-1].listEl.appendChild(a)}t.remove()}o&&s.insertBefore(o,i)}function Ne(t,e,s,i){const n=t.createElement(e);return s&&(n.style.listStyleType=s),"ol"===e&&i>1&&n.setAttribute("start",String(i)),n}function Be(t){const e=t.querySelectorAll("span");for(const t of e){const e=t.getAttribute("style")||"";if(Qt.test(e))return t.textContent||""}return t.textContent?.substring(0,10)||""}const Ie={cleanHTML:function(t){if(!t)return"";const e=function(t){const e=new Map,s=t.match(/]*>([\s\S]*?)<\/style>/i);if(!s)return e;const i=s[1],n=/@list\s+l(\d+):level(\d+)\s*\{([^}]*)\}/gi;let o;for(;null!==(o=n.exec(i));){const t=o[1],s=o[2],i=o[3],n=`l${t}:level${s}`,r=he.exec(i),l=ce.exec(i),a=de.exec(i);let h="ol",c="";if(r){const t=r[1].toLowerCase();if("bullet"===t||"image"===t){if(h="ul",a){const t=a[1].replace(/["%\\]/g,"");"·"===t||"·"===t?c="disc":"o"===t?c="circle":"§"!==t&&"§"!==t||(c="square")}}else c=ue[t]||""}e.set(n,{type:h,listStyleType:c,startAt:l?parseInt(l[1],10):1})}return e}(t);let s=t;s=s.replace(Xt,""),s=s.replace(Yt,""),s=s.replace(Gt,""),s=s.replace(Kt,""),s=s.replace(//gi,""),s=s.replace(/<(?:meta|link)[^>]*>/gi,""),s=s.replace(oe," "),s=s.replace(re," "),s=s.replace(/( ){2,}/g," "),s=s.replace(/\u00AD/g,"");const i=(new DOMParser).parseFromString(s,"text/html");!function(t){const e=t.body.querySelectorAll("del, .msoDel");for(const t of e)t.remove();const s=t.body.querySelectorAll("ins, .msoIns");for(let t=s.length-1;t>=0;t--){const e=s[t],i=e.parentNode;if(i){for(;e.firstChild;)i.insertBefore(e.firstChild,e);e.remove()}}const i=t.body.querySelectorAll('.MsoCommentReference, [style*="mso-comment-reference"]');for(const t of i)t.remove();const n=t.body.querySelectorAll(".MsoCommentText");for(const t of n)t.remove();const o=t.body.querySelectorAll('div[style*="mso-element:comment"]');for(const t of o)t.remove();const r=t.body.querySelectorAll('a[name^="_msocom"], a[name^="_msoanchor"]');for(const t of r)t.remove()}(i),function(t,e){const s=[],i=t.body.querySelectorAll("p, h1, h2, h3, h4, h5, h6");for(const t of i){const e=t.getAttribute("style")||"",i=t.getAttribute("class")||"",n=Jt.exec(e);(n||/MsoListParagraph/i.test(i))&&s.push({el:t,listId:n?n[1]:"0",level:n?parseInt(n[2],10):1,lfo:n?n[3]:"1"})}if(0===s.length)return;const n=[];let o=null;for(const t of s){const e=Te(t.el);o&&o.length>0&&e===o[o.length-1].el?o.push(t):(o=[t],n.push(o))}for(const t of n)Me(t,e)}(i,e),function(t){const e=t.body.querySelectorAll("p");for(const s of e){const e=s.getAttribute("style")||"",i=s.getAttribute("class")||"";let n=0;const o=le.exec(e);if(o&&(n=parseInt(o[1],10)),!n){const t=fe.exec(i);t&&(n=parseInt(t[1],10))}if(n>=1&&n<=6){const i=t.createElement("h"+n);for(;s.firstChild;)i.appendChild(s.firstChild);e&&i.setAttribute("style",e),s.replaceWith(i)}}}(i),function(t){const e=t.body.querySelectorAll("table");for(const t of e){Ee(t),t.removeAttribute("cellspacing"),t.removeAttribute("cellpadding");const e=t.querySelectorAll("col");for(const t of e)t.remove();const s=t.querySelectorAll("colgroup");for(const t of s)t.children.length||t.remove()}const s=t.body.querySelectorAll("tr");for(const t of s)t.removeAttribute("height");const i=t.body.querySelectorAll("td, th");for(const t of i){const e=t.getAttribute("valign");if(e){t.removeAttribute("valign");const s=t.getAttribute("style")||"";/vertical-align/i.test(s)||t.setAttribute("style",(s?s+";":"")+"vertical-align:"+e)}const s=t.children;if(1===s.length&&"P"===s[0].tagName){const e=s[0],i=e.getAttribute("class")||"";if(/MsoNormal/i.test(i)||!i){for(;e.firstChild;)t.insertBefore(e.firstChild,e);e.remove()}}}}(i),function(t){const e=t.body.querySelectorAll("a");for(let t=e.length-1;t>=0;t--){const s=e[t],i=s.getAttribute("href")||"",n=s.getAttribute("name")||"";if(ve.test(i)){const t=s.parentNode;if(t){for(;s.firstChild;)t.insertBefore(s.firstChild,s);s.remove()}}else if(be.test(n)){const t=s.parentNode;if(t){if(s.childNodes.length)for(;s.firstChild;)t.insertBefore(s.firstChild,s);s.remove()}}else if(ye.test(i)){const t=s.parentNode;if(t){for(;s.firstChild;)t.insertBefore(s.firstChild,s);s.remove()}}else s.removeAttribute("v:shapes")}}(i),function(t){const e=t.body.querySelectorAll("img");for(let t=e.length-1;t>=0;t--){const s=e[t],i=s.getAttribute("src")||"";ve.test(i)?s.remove():s.removeAttribute("v:shapes")}}(i),function(t){const e=t.body.querySelectorAll("br");for(let t=e.length-1;t>=0;t--){const s=e[t],i=s.getAttribute("style")||"";we.test(i)||Ce.test(i)||_e.test(i)?s.remove():(s.removeAttribute("style"),s.removeAttribute("clear"))}const s=t.body.querySelectorAll('div[class*="Section"]');for(let t=s.length-1;t>=0;t--){const e=s[t],i=e.getAttribute("class")||"";if(ke.test(i.trim())){const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);e.remove()}}}}(i);const n=i.body.querySelectorAll("*");for(const t of n){Se(t),Ee(t),t.getAttribute("lang")&&t.removeAttribute("lang"),t.removeAttribute("v:shapes");const e=t.tagName.toLowerCase();"img"!==e&&"video"!==e&&"iframe"!==e&&"table"!==e&&"td"!==e&&"th"!==e&&(t.removeAttribute("width"),t.removeAttribute("height"))}!function(t){const e=t.querySelectorAll("span");for(let t=e.length-1;t>=0;t--){const s=e[t];if(!s.attributes.length||!s.getAttribute("style")&&!s.getAttribute("class")){const t=s.parentNode;if(t){for(;s.firstChild;)t.insertBefore(s.firstChild,s);t.removeChild(s)}}}}(i.body);const o=i.body.querySelectorAll("p");for(const t of o)t.textContent.trim()||t.querySelector("img, video, iframe, br, table")||t.remove();return i.body.innerHTML}},Le=/id=["']?docs-internal-guid-/i;const Ae={isGoogleDocs:function(t){return Le.test(t)},cleanHTML:function(t){const e=(new DOMParser).parseFromString(t,"text/html"),s=e.body.querySelectorAll('b[id^="docs-internal-guid-"], span[id^="docs-internal-guid-"]');if(0===s.length)return t;for(let t,e=0,i=s.length;e',undo:'',bold:'',underline:'',italic:'',strike:'',subscript:'',superscript:'',remove_color:'',remove_format:'',indent:'',outdent:'',expansion:'',reduction:'',code_block:'',code_view:'',markdown_view:'',preview:'',print:'',template:'',layout:'',ai:'',new_document:'',select_all:'',line_height:'',paragraph_style:'',text_style:'',save:'',blockquote:'',arrow_down:'',align_justify:'',align_left:'',align_right:'',align_center:'',align_top:'',align_middle:'',align_bottom:'',format_float_none:'',format_float_left:'',format_float_right:'',format_float_center:'',font_color:'',background_color:'',list_bulleted:'',list_numbered:'',list_checked:'',table:'',table_header:'',table_properties:'',cell_properties:'',table_column:'',table_row:'',color_checked:'',color_palette:'',border_all:'',border_inside:'',border_horizontal:'',border_vertical:'',border_outside:'',border_left:'',border_top:'',border_right:'',border_bottom:'',border_none:'',horizontal_line:'',show_blocks:'',cancel:'',selection_remove:'',image:'',image_thumbnail:'',video:'',video_thumbnail:'',link:'',link_rel:'',math:'',unlink:'',merge_cell:'',split_cell:'',unmerge_cell:'',caption:'',edit:'',delete:'',revert:'',auto_size:'',resize:'',insert_row_below:'',insert_row_above:'',insert_column_left:'',insert_column_right:'',delete_row:'',delete_column:'',fixed_column_width:'',rotate_left:'',rotate_right:'',mirror_horizontal:'',mirror_vertical:'',checked:'',line_break:'',audio:'',audio_thumbnail:'',image_gallery:'',audio_gallery:'',video_gallery:'',file_gallery:'',file_browser:'',bookmark:'',bookmark_anchor:'',download:'',dir_ltr:'',dir_rtl:'',dragHandle:'',file_upload:'',file_thumbnail:'',file_plus:'',upload_tray:'',folder:'',plus:'',minus:'',selection:'',copy:'',cut:'',PDF:'',format_paint:'',drawing:'',eraser:'',search:'',selection_search:'',embed:'',finder:'',regex:'',match_case:'',whole_word:'',swap_vert:'',arrow_down_small:'',arrow_up_small:'',replaceText:'',relaceTextAll:'',menu_arrow_down:'',menu_arrow_up:'',menu_arrow_right:'',menu_arrow_left:'',side_menu_hamburger:'',side_menu_folder:'',side_menu_folder_item:'',side_menu_item:'',side_menu_folder_plus:'',alert_outline:'',more_media:'',more_gallery:'',more_folder:'',more_list:'',more_file:'',more_view:'',more_page:'',more_text:'',more_paragraph:'',more_plus:'',more_horizontal:'',more_vertical:'',more_flag:'',as_inline:'',as_block:'',page_break:'',page_down:'',page_up:'',collapse_left:'',collapse_right:'',map:'',magic_stick:'',open_in_new:''};var Ge=s("cfbI"),Ke=s.n(Ge);function Ye(t,e,s,i,n){const o=new Map([["menuTray",s],["toolbar_main",t],["toolbar_buttonTray",t.querySelector(".se-btn-tray")],["toolbar_arrow",t.querySelector(".se-arrow")]]);return i&&(o.set("toolbar_sub_main",i),o.set("toolbar_sub_buttonTray",i.querySelector(".se-btn-tray")),o.set("toolbar_sub_arrow",i.querySelector(".se-arrow")),o.set("toolbar_sub_wrapper",i.parentElement.parentElement)),e&&(o.set("toolbar_wrapper",e.querySelector(".sun-editor")),o.set("_stickyDummy",e.querySelector(".se-toolbar-sticky-dummy"))),n&&o.set("statusbar_wrapper",n.querySelector(".sun-editor")),o}function Xe(t,e,s,i,n,o,r,l,a,h,c){const d=new Map([["key",c],["options",t.options],["originElement",t.target],["topArea",e],["container",e.querySelector(".se-container")],["wrapper",e.querySelector(".se-wrapper")],["wysiwygFrame",s],["wysiwyg",s],["codeWrapper",i],["code",n],["codeNumbers",i?.querySelector(".se-code-view-line")],["markdownWrapper",o],["markdown",r],["markdownNumbers",o?.querySelector(".se-markdown-view-line")],["lineBreaker_t",e.querySelector(".se-line-breaker-component-t")],["lineBreaker_b",e.querySelector(".se-line-breaker-component-b")],["blockHandleArea",h],["blockHandle",h?.querySelector(".se-block-handle")||null],["blockHandlePlus",h?.querySelector(".se-block-handle-plus")||null],["blockHandleDrag",h?.querySelector(".se-block-handle-drag")||null],["_stickyDummy",e.querySelector(".se-toolbar-sticky-dummy")],["_toolbarShadow",e.querySelector(".se-toolbar-shadow")],["_minHeight",B(s.style.minHeight||"65",0)],["isCodeView",!1],["isMarkdownView",!1],["isFullScreen",!1],["isReadOnly",!1],["isDisabled",!1],["isChanged",!1],["historyIndex",-1],["savedIndex",-1],["documentTypeInner",a.inner],["documentTypePage",a.page],["documentTypePageMirror",a.pageMirror]]);l&&Ze(l,d);const u=e.querySelector(".se-placeholder");u&&d.set("placeholder",u);const p=t.options.get("placeholder_line");return p&&d.set("placeholder_line",p),d}function Ze(t,e){t?e.set("statusbar",t):e.delete("statusbar");const s=t?t.querySelector(".se-navigation"):null,i=t?t.querySelector(".se-char-counter-wrapper"):null,n=t?t.querySelector(".se-char-counter-wrapper .se-char-counter"):null;s?e.set("navigation",s):e.delete("navigation"),i?e.set("charWrapper",i):e.delete("charWrapper"),n?e.set("charCounter",n):e.delete("charCounter");const o=t?t.querySelector(".se-word-counter-wrapper"):null,r=t?t.querySelector(".se-word-counter-wrapper .se-word-counter"):null;o?e.set("wordWrapper",o):e.delete("wordWrapper"),r?e.set("wordCounter",r):e.delete("wordCounter")}const Je={BUTTON_LIST:[["undo","redo"],"|",["bold","underline","italic","strike","|","subscript","superscript"],"|",["removeFormat"],"|",["outdent","indent"],"|",["fullScreen","showBlocks","codeView"],"|",["preview","print"]],REQUIRED_FORMAT_LINE:"div",REQUIRED_ELEMENT_WHITELIST:"br|div",ELEMENT_WHITELIST:"p|pre|blockquote|h1|h2|h3|h4|h5|h6|ol|ul|li|hr|figure|figcaption|img|iframe|audio|video|source|table|colgroup|col|thead|tbody|tr|th|td|caption|a|b|strong|var|i|em|u|ins|s|span|strike|del|sub|sup|code|svg|path|details|summary",TEXT_STYLE_TAGS:"strong|span|font|b|var|i|em|u|ins|s|strike|del|sub|sup|mark|a|label|code|summary",SCOPE_SELECTION_TAGS:["td","table","li","ol","ul","pre","figcaption","blockquote","dl","dt","dd"],ATTRIBUTE_WHITELIST:"contenteditable|target|href|title|download|rel|src|alt|class|type|colspan|rowspan|width|height|controls|autoplay|loop|muted|poster|preload|playsinline|volume|crossorigin|disableRemotePlayback|controlsList|allowfullscreen|sandbox|loading|allow|referrerpolicy|frameborder|scrolling",FORMAT_LINE:"P|H[1-6]|LI|TH|TD|DETAILS",FORMAT_BR_LINE:"PRE",FORMAT_CLOSURE_BR_LINE:"",FORMAT_BLOCK:"BLOCKQUOTE|OL|UL|FIGCAPTION|TABLE|THEAD|TBODY|TR|CAPTION|DETAILS",FORMAT_CLOSURE_BLOCK:"TH|TD",ALLOWED_EMPTY_NODE_LIST:".se-component, pre, blockquote, hr, li, table, img, iframe, video, audio, canvas, details",SIZE_UNITS:["px","pt","em","rem"],CLASS_NAME:"^__se__|^se-|^katex|^MathJax|^language-",CLASS_MJX:"mjx-container|mjx-math|mjx-mrow|mjx-mi|mjx-mo|mjx-mn|mjx-msup|mjx-mfrac|mjx-munderover",EXTRA_TAG_MAP:{script:!1,style:!1,meta:!1,link:!1,"[a-z]+:[a-z]+":!1},CONTENT_STYLES:"background|background-clip|background-color|border|border-bottom|border-collapse|border-color|border-image|border-left-width|border-radius|border-right-width|border-spacing|border-style|border-top|border-width|box-shadow|box-sizing|caption-side|color|content|direction|display|position|float|font|font-family|font-size|font-style|font-weight|height|min-height|max-height|width|min-width|max-width|left|letter-spacing|line-height|list-style-position|list-style-type|margin|margin-block-end|margin-block-start|margin-bottom|margin-inline-end|margin-inline-start|margin-left|margin-right|margin-top|padding|padding-bottom|padding-inline-start|padding-left|padding-right|padding-top|outline|overflow|page-break-before|page-break-after|page-break-inside|rotate|rotateX|rotateY|table-layout|text-align|text-decoration|text-shadow|text-transform|top|text-indent|text-rendering|vertical-align|visibility|white-space|word-break|word-wrap",TAG_STYLES:{"@text":"font-family|font-size|color|background-color|width|height","@line":"text-align|margin|margin-left|margin-right|line-height","@component":"width|height|min-width",li:"font-family|font-size|color|background-color|font-weight|font-style","table|th|td":"border|border-[a-z]+|color|background-color|text-align|float|font-weight|text-decoration|font-style|vertical-align","table|td":"width",tr:"height",col:"width",caption:"text-align|caption-side","ol|ul":"list-style-type",figure:"display|width|height|padding|padding-bottom",figcaption:"margin|margin-top|margin-bottom|text-align","img|video|iframe":"transform|transform-origin|width|min-width|max-width|height|min-height|max-height|float|margin|margin-top",hr:""},RETAIN_STYLE_MODE:["repeat","always","none"]},Qe={value:"fixed",placeholder:!0,placeholder_line:!0,editableFrameAttributes:!0,width:!0,minWidth:!0,maxWidth:!0,innerWidth:"fixed",height:!0,minHeight:!0,maxHeight:!0,editorStyle:!0,iframe:"fixed",iframe_fullPage:"fixed",iframe_attributes:!0,iframe_cssFileName:!0,statusbar:!0,statusbar_showPathLabel:!0,statusbar_resizeEnable:"fixed",charCounter:!0,charCounter_max:!0,charCounter_label:!0,charCounter_type:!0,wordCounter:!0,wordCounter_label:!0},ts={plugins:"fixed",excludedPlugins:"fixed",buttonList:"fixed",v2Migration:"fixed",strictMode:"fixed",mode:"fixed",blockHandle:"fixed",type:"fixed",theme:!0,lang:"fixed",fontSizeUnits:"fixed",allowedClassName:"fixed",closeModalOutsideClick:"fixed",copyFormatKeepOn:!0,syncTabIndent:!0,tabDisable:!0,autoLinkify:!0,autoStyleify:!0,retainStyleMode:!0,allowedExtraTags:"fixed",events:!0,__textStyleTags:"fixed",textStyleTags:"fixed",convertTextTags:"fixed",__tagStyles:"fixed",tagStyles:"fixed",textDirection:!0,reverseButtons:"fixed",historyStackDelayTime:!0,historyStackSize:"fixed",lineAttrReset:!0,printClass:!0,defaultLine:"fixed",defaultLineBreakFormat:!0,lineBreakClearStyle:!0,scopeSelectionTags:!0,__defaultElementWhitelist:"fixed",elementWhitelist:"fixed",elementBlacklist:"fixed",__defaultAttributeWhitelist:"fixed",attributeWhitelist:"fixed",attributeBlacklist:"fixed",__defaultFormatLine:"fixed",formatLine:"fixed",__defaultFormatBrLine:"fixed",formatBrLine:"fixed",__defaultFormatClosureBrLine:"fixed",formatClosureBrLine:"fixed",__defaultFormatBlock:"fixed",formatBlock:"fixed",__defaultFormatClosureBlock:"fixed",formatClosureBlock:"fixed",allowedEmptyTags:!0,toolbar_width:!0,toolbar_innerWidth:"fixed",toolbar_container:"fixed",toolbar_sticky:!0,toolbar_hide:!0,subToolbar:"fixed",statusbar_container:"fixed",shortcutsHint:!0,shortcutsDisable:"fixed",shortcuts:"fixed",fullScreenOffset:!0,previewTemplate:!0,printTemplate:!0,componentInsertBehavior:!0,defaultUrlProtocol:!0,allUsedStyles:"fixed",toastMessageTime:!0,icons:"fixed",freeCodeViewMode:!0,finder_panel:"fixed",finder_liveSearch:!0,__lineFormatFilter:!0,__pluginRetainFilter:!0,__listCommonStyle:"fixed",externalLibs:"fixed"},es=Oe._d;let ss=0;function is(t,e,s,i,n,o){if(!s||s.length<2)return;const r=e?.querySelector(".se-tooltip-text");for(let l,a,h,c,d,u,p,g,m,f,v,b,y,w,C=0;C'+s+""),n=t.querySelector(".se-shortcut");n?t.replaceChild(i,n):t.appendChild(i)}function os(t,e){return[t,e].reduce(((t,e)=>{for(const s in e)t[s]=(e[s]||"").toLowerCase();return t}),{})}function rs(t,e,s){const i=t.buttonList||Je.BUTTON_LIST,n=new Map;if(e.length>1&&!t.toolbar_container&&!/inline|balloon/i.test(t.mode))throw Error('[SUNEDITOR.create.fail] In multi root, The "mode" option cannot be "classic" without using the "toolbar_container" option.');n.set("v2Migration",!!t.v2Migration),n.set("buttons",new Set(i.toString().split(","))),n.set("strictMode",{tagFilter:!0,formatFilter:!0,classFilter:!0,textStyleTagFilter:!0,attrFilter:!0,styleFilter:!0,..."boolean"==typeof t.strictMode?{}:t.strictMode}),n.set("freeCodeViewMode",!!t.freeCodeViewMode),n.set("finder_panel",!1!==t.finder_panel),n.set("finder_liveSearch",!1!==t.finder_liveSearch),n.set("__lineFormatFilter",t.__lineFormatFilter??!0),n.set("__pluginRetainFilter",t.__pluginRetainFilter??!0);const[o,r]=(t.mode||"classic").split(":");n.set("mode",o),n.set("_toolbar_bottom","bottom"===r&&/^(classic|inline)$/i.test(o)),n.set("blockHandle",t.blockHandle?"object"==typeof t.blockHandle?t.blockHandle:{}:null),n.set("type",t.type?.split(":")[0]||""),n.set("theme",t.theme||""),n.set("_themeClass",t.theme?` se-theme-${t.theme}`:""),n.set("_type_options",t.type?.split(":")[1]||""),n.set("externalLibs",t.externalLibs||{}),n.set("fontSizeUnits",Array.isArray(t.fontSizeUnits)&&t.fontSizeUnits.length>0?t.fontSizeUnits.map((t=>t.toLowerCase())):Je.SIZE_UNITS),n.set("allowedClassName",new RegExp(`${t.allowedClassName&&"string"==typeof t.allowedClassName?t.allowedClassName+"|":""}${Je.CLASS_NAME}`)),n.set("closeModalOutsideClick",!!t.closeModalOutsideClick),n.set("copyFormatKeepOn",!!t.copyFormatKeepOn),n.set("syncTabIndent",t.syncTabIndent??!0),n.set("autoLinkify",t.autoLinkify??!!s.link),n.set("autoStyleify",Array.isArray(t.autoStyleify)?t.autoStyleify:["bold","underline","italic","strike"]);let l=t.retainStyleMode||"repeat";"string"!=typeof l||Je.RETAIN_STYLE_MODE.includes(l)||(console.error(`Invalid retainStyleMode: ${l}. Valid options are ${Je.RETAIN_STYLE_MODE.join(", ")}. Using default 'repeat'.`),l="repeat"),n.set("retainStyleMode",l);const a={...Je.EXTRA_TAG_MAP,...t.allowedExtraTags,"-":!0},h=Object.keys(a),c=h.filter((t=>a[t])).join("|"),d=h.filter((t=>!a[t])).join("|");n.set("_allowedExtraTag",c),n.set("_disallowedExtraTag",d),n.set("events",t.events||{}),n.set("textStyleTags",("string"==typeof t.__textStyleTags?t.__textStyleTags:Je.TEXT_STYLE_TAGS)+(t.textStyleTags?"|"+t.textStyleTags:""));const u=os({bold:"strong",underline:"u",italic:"em",strike:"del",subscript:"sub",superscript:"sup"},t.convertTextTags||{});n.set("convertTextTags",u),n.set("_textStyleTags",Object.values(u).concat(["span","li"])),n.set("tagStyles",[{...Je.TAG_STYLES,...t.__tagStyles||{}},t.tagStyles||{}].reduce(((t,e)=>{for(const s in e)t[s]=e[s];return t}),{})),n.set("_defaultStyleTagMap",{strong:u.bold,b:u.bold,u:u.underline,ins:u.underline,em:u.italic,i:u.italic,del:u.strike,strike:u.strike,s:u.strike,sub:u.subscript,sup:u.superscript}),n.set("_styleCommandMap",os(ze.swapKeyValue(u),{strong:"bold",b:"bold",u:"underline",ins:"underline",em:"italic",i:"italic",del:"strike",strike:"strike",s:"strike",sub:"subscript",sup:"superscript"})),n.set("_defaultTagCommand",{bold:u.bold,underline:u.underline,italic:u.italic,strike:u.strike,subscript:u.sub,superscript:u.sup}),n.set("textDirection",t.textDirection??"ltr"),n.set("_rtl","rtl"===n.get("textDirection")),n.set("reverseCommands",["indent-outdent"].concat(t.reverseButtons||[])),n.set("_reverseCommandArray",("-"+n.get("reverseCommands").join("-")).split("-")),De.isEven(n.get("_reverseCommandArray").length)&&console.warn('[SUNEDITOR.create.warning] The "reverseCommands" option is invalid, Shortcuts key may not work properly.'),n.set("historyStackDelayTime","number"==typeof t.historyStackDelayTime?t.historyStackDelayTime:400),n.set("historyStackSize","number"==typeof t.historyStackSize&&t.historyStackSize>0?t.historyStackSize:100),n.set("_editableClass","sun-editor-editable"+n.get("_themeClass")+(n.get("_rtl")?" se-rtl":"")+("document"===n.get("type")?" se-type-document-editable-a4":"")),n.set("lineAttrReset",["id"].concat(t.lineAttrReset&&"string"==typeof t.lineAttrReset?t.lineAttrReset.toLowerCase().split("|"):[])),n.set("printClass","string"==typeof t.printClass?t.printClass+" "+n.get("_editableClass"):null),n.set("defaultLine","string"==typeof t.defaultLine&&t.defaultLine.length>0?t.defaultLine:"p"),n.set("defaultLineBreakFormat",t.defaultLineBreakFormat||"line"),n.set("lineBreakClearStyle",!!t.lineBreakClearStyle),n.set("scopeSelectionTags",t.scopeSelectionTags||Je.SCOPE_SELECTION_TAGS);const p=("string"==typeof t.elementWhitelist?t.elementWhitelist:"").toLowerCase(),g=n.get("externalLibs").mathjax?Je.CLASS_MJX+"|":"";n.set("elementWhitelist",p+(p?"|":"")+g+n.get("_allowedExtraTag"));const m=(f=("string"==typeof t.elementBlacklist?t.elementBlacklist:"").toLowerCase(),v=(v=n.get("defaultLine")).toLowerCase(),f.split("|").filter((function(t){return t!==v||(console.warn(`[SUNEDITOR.constructor.createBlacklist.warn] defaultLine("<${v}>") cannot be included in the blacklist and will be removed.`),!1)})).join("|"));var f,v;if(n.set("elementBlacklist",m+(m?"|":"")+n.get("_disallowedExtraTag")),n.set("attributeWhitelist",t.attributeWhitelist&&"object"==typeof t.attributeWhitelist?t.attributeWhitelist:null),n.set("attributeBlacklist",t.attributeBlacklist&&"object"==typeof t.attributeBlacklist?t.attributeBlacklist:null),n.set("formatClosureBrLine",ds(t.formatClosureBrLine,(t.__defaultFormatClosureBrLine="string"==typeof t.__defaultFormatClosureBrLine?t.__defaultFormatClosureBrLine:Je.FORMAT_CLOSURE_BR_LINE).toLowerCase(),n.get("elementBlacklist"))),n.set("formatBrLine",ds((t.formatBrLine||"")+"|"+n.get("formatClosureBrLine").str,(t.__defaultFormatBrLine="string"==typeof t.__defaultFormatBrLine?t.__defaultFormatBrLine:Je.FORMAT_BR_LINE).toLowerCase(),n.get("elementBlacklist"))),n.set("formatLine",ds(Je.REQUIRED_FORMAT_LINE+"|"+(t.formatLine||"")+"|"+n.get("formatBrLine").str,(t.__defaultFormatLine="string"==typeof t.__defaultFormatLine?t.__defaultFormatLine:Je.FORMAT_LINE).toLowerCase(),n.get("elementBlacklist"))),!n.get("formatLine").reg.test(n.get("defaultLine")))throw Error(`[SUNEDITOR.create.fail] The "defaultLine(${n.get("defaultLine")})" option must be included in the "formatLine(${n.get("formatLine").str})" option.`);n.set("formatClosureBlock",ds(t.formatClosureBlock,(t.__defaultFormatClosureBlock="string"==typeof t.__defaultFormatClosureBlock?t.__defaultFormatClosureBlock:Je.FORMAT_CLOSURE_BLOCK).toLowerCase(),n.get("elementBlacklist"))),n.set("formatBlock",ds((t.formatBlock||"")+"|"+n.get("formatClosureBlock").str,(t.__defaultFormatBlock="string"==typeof t.__defaultFormatBlock?t.__defaultFormatBlock:Je.FORMAT_BLOCK).toLowerCase(),n.get("elementBlacklist"))),n.set("allowedEmptyTags",Je.ALLOWED_EMPTY_NODE_LIST+(t.allowedEmptyTags?", "+t.allowedEmptyTags:"")),n.set("__defaultElementWhitelist",Je.REQUIRED_ELEMENT_WHITELIST+"|"+("string"==typeof t.__defaultElementWhitelist?t.__defaultElementWhitelist:Je.ELEMENT_WHITELIST).toLowerCase()),n.set("__defaultAttributeWhitelist",("string"==typeof t.__defaultAttributeWhitelist?t.__defaultAttributeWhitelist:Je.ATTRIBUTE_WHITELIST).toLowerCase()),n.set("_editorElementWhitelist","*"===n.get("elementWhitelist")?"*":function(t){const e=t.get("elementBlacklist").split("|"),s=(t.get("__defaultElementWhitelist")+"|"+t.get("elementWhitelist")+"|"+t.get("formatLine").str+"|"+t.get("formatBrLine").str+"|"+t.get("formatClosureBlock").str+"|"+t.get("formatClosureBrLine").str).replace(/(^\||\|$)/g,"").split("|").filter(((t,s,i)=>t&&i.indexOf(t)===s&&!e.includes(t)));return s.join("|")}(n)),n.set("toolbar_width",t.toolbar_width?De.is(t.toolbar_width)?t.toolbar_width+"px":t.toolbar_width:"auto"),n.set("toolbar_innerWidth",t.toolbar_innerWidth?De.is(t.toolbar_innerWidth)?t.toolbar_innerWidth+"px":t.toolbar_innerWidth:""),n.set("toolbar_container",t.toolbar_container&&!/inline/i.test(n.get("mode"))?"string"==typeof t.toolbar_container?es.querySelector(t.toolbar_container):t.toolbar_container:null);const b=t.toolbar_sticky;/balloon/i.test(n.get("mode"))?(n.set("_toolbar_sticky",-1),n.set("_toolbar_sticky_offset",0),n.set("_toolbar_sticky_fixed",!1)):null!==b&&"object"==typeof b?(n.set("_toolbar_sticky",De.get(b.top,0)),n.set("_toolbar_sticky_offset",De.get(b.offset,0)),n.set("_toolbar_sticky_fixed","fixed"===b.position)):(n.set("_toolbar_sticky",void 0===b?0:De.is(b)?b:-1),n.set("_toolbar_sticky_offset",0),n.set("_toolbar_sticky_fixed",!1)),n.set("toolbar_hide",!!t.toolbar_hide);let y=null;const w=t.subToolbar;w?.buttonList?.length>0&&(/balloon/.test(n.get("mode"))?console.warn('[SUNEDITOR.create.subToolbar.fail] When the "mode" option is "balloon-*", the "subToolbar" option is omitted.'):(n.set("_subMode",w.mode||"balloon"),n.set("toolbar_sub_width",w.width?De.is(w.width)?w.width+"px":w.width:"auto"),y=w.buttonList,n.set("buttons_sub",new Set(y.toString().split(",")))));const C=new Map;for(let s=0,i=e.length;s{for(const s in e)t[s]=e[s];return t}),{});n.set("shortcuts",_),n.set("fullScreenOffset",void 0===t.fullScreenOffset?0:De.is(t.fullScreenOffset)?De.get(t.fullScreenOffset,0):0),n.set("previewTemplate","string"==typeof t.previewTemplate?t.previewTemplate:null),n.set("printTemplate","string"==typeof t.printTemplate?t.printTemplate:null),n.set("componentInsertBehavior",["auto","select","line","none"].includes(t.componentInsertBehavior)?t.componentInsertBehavior:"auto"),n.set("defaultUrlProtocol","string"==typeof t.defaultUrlProtocol?t.defaultUrlProtocol:null);const k=n.get("externalLibs").codeMirror;k&&(n.set("codeMirror",k),k.src?n.set("codeMirrorEditor",!0):(console.warn("[SUNEDITOR.options.externalLibs.codeMirror.fail] The codeMirror option is set incorrectly. See: https://github.com/ARA-developer/suneditor/blob/develop/guide/external-libraries.md"),n.set("codeMirror",null))),n.set("__listCommonStyle",t.__listCommonStyle||["fontSize","color","fontFamily","fontWeight","fontStyle"]);const x=t.icons&&"object"==typeof t.icons?[je,t.icons].reduce(((t,e)=>{for(const s in e)t[s]=e[s];return t}),{}):je;n.set("icons",x);const $=new Set(Je.CONTENT_STYLES.split("|")),S=n.get("__listCommonStyle");for(const t of Object.values(n.get("tagStyles"))){const e=t.split("|");for(let t=0,s=e.length;t0){const e=i.querySelector(".se-char-max")||Pe.utils.createElement("SPAN",{class:"se-char-max"});e.textContent=" / "+t.get("charCounter_max"),i.appendChild(e)}e.appendChild(i)}}return{statusbar:e,navigation:s,charWrapper:i,charCounter:n,wordWrapper:o,wordCounter:r}}function as(t,e){const s=new Map;s.set("_origin",t);const i=e.statusbar_container,n=void 0===t.value?e.value:t.value,o=void 0===t.placeholder?e.placeholder:t.placeholder,r=void 0===t.placeholder_line?e.placeholder_line:t.placeholder_line,l=void 0===t.editableFrameAttributes?e.editableFrameAttributes:t.editableFrameAttributes,a=void 0===t.width?e.width:t.width,h=void 0===t.minWidth?e.minWidth:t.minWidth,c=void 0===t.maxWidth?e.maxWidth:t.maxWidth,d=void 0===t.innerWidth?e.innerWidth:t.innerWidth,u=void 0===t.height?e.height:t.height,p=void 0===t.minHeight?e.minHeight:t.minHeight,g=void 0===t.maxHeight?e.maxHeight:t.maxHeight,m=void 0===t.editorStyle?e.editorStyle:t.editorStyle,f=void 0===t.iframe?e.iframe:t.iframe,v=void 0===t.iframe_fullPage?e.iframe_fullPage:t.iframe_fullPage,b=void 0===t.iframe_attributes?e.iframe_attributes:t.iframe_attributes,y=void 0===t.iframe_cssFileName?e.iframe_cssFileName:t.iframe_cssFileName,w=i||void 0===t.statusbar?e.statusbar:t.statusbar,C=i||void 0===t.statusbar_showPathLabel?e.statusbar_showPathLabel:t.statusbar_showPathLabel,_=!i&&(void 0===t.statusbar_resizeEnable?e.statusbar_resizeEnable:t.statusbar_resizeEnable),k=i||void 0===t.charCounter?e.charCounter:t.charCounter,x=i||void 0===t.charCounter_max?e.charCounter_max:t.charCounter_max,$=i||void 0===t.charCounter_label?e.charCounter_label:t.charCounter_label,S=i||void 0===t.charCounter_type?e.charCounter_type:t.charCounter_type,E=i||void 0===t.wordCounter?e.wordCounter:t.wordCounter,T=i||void 0===t.wordCounter_label?e.wordCounter_label:t.wordCounter_label;s.set("value",n),s.set("placeholder",o),s.set("placeholder_line",r),s.set("editableFrameAttributes",{spellcheck:"false",...l}),s.set("width",a?String(De.is(a)?a+"px":a):"100%"),s.set("minWidth",h?String(De.is(h)?h+"px":h):""),s.set("maxWidth",c?String(De.is(c)?c+"px":c):""),s.set("innerWidth",d?String(De.is(d)?d+"px":d):""),s.set("height",u?String(De.is(u)?u+"px":u):"auto"),s.set("minHeight",p?String(De.is(p)?p+"px":p):""),s.set("maxHeight",g?String(De.is(g)?g+"px":g):""),s.set("editorStyle",m),s.set("_defaultStyles",ze._setDefaultOptionStyle(s,"string"==typeof m?m:"")),s.set("iframe",!(!v&&!f)),s.set("iframe_fullPage",!!v),s.set("iframe_attributes",b||{}),s.set("iframe_cssFileName",f?("string"==typeof y?[y]:y)||["suneditor"]:null);const M=void 0===w||!!w;return s.set("statusbar",M),s.set("statusbar_showPathLabel",!!M&&("boolean"!=typeof C||C)),s.set("statusbar_resizeEnable",!!M&&(void 0===_||!!_)),s.set("charCounter",x>0||"boolean"==typeof k&&k),s.set("charCounter_max",De.is(x)&&x>-1?1*x:null),s.set("charCounter_label","string"==typeof $?$.trim():null),s.set("charCounter_type","string"==typeof S?S:"char"),s.set("wordCounter","boolean"==typeof E&&E),s.set("wordCounter_label","string"==typeof T?T.trim():null),s}function hs(t,e,s,i,n){const o=i.get("_defaultStyles");s.style.cssText=o.top;const r=Pe.utils.createElement(i.get("iframe")?"IFRAME":"DIV",{class:"se-wrapper-inner se-wrapper-wysiwyg"+("document"===e.get("type")?" se-type-document-iframe-a4":""),"data-root-key":t});if(i.get("iframe")){const t=r,e=i.get("iframe_attributes");let s=e.sandbox;if(s){const t=["allow-same-origin","allow-scripts"],e=s.split(/\s+/),i=t.filter((t=>!e.includes(t)));i.length>0&&(s=e.concat(i).join(" "))}else s="allow-same-origin allow-scripts";t.setAttribute("sandbox",s),t.setAttribute("frameBorder","0");for(const s in e)"sandbox"!==s&&t.setAttribute(s,e[s]);t.allowFullscreen=!0,t.setAttribute("scrolling","auto"===i.get("height")?"no":"auto"),t.style.cssText=o.frame}else r.setAttribute("contenteditable","true"),e.get("_rtl")&&(r.dir="rtl"),r.className+=" "+e.get("_editableClass"),r.style.cssText=o.frame+o.editor;const l=Pe.utils.createElement("TEXTAREA",{id:n+"-code-viewer-"+(t||"default"),class:"se-wrapper-inner se-code-viewer",style:o.frame,autocomplete:"off"}),a=Pe.utils.createElement("TEXTAREA",{id:n+"-markdown-viewer-"+(t||"default"),class:"se-wrapper-inner se-markdown-viewer",style:o.frame,autocomplete:"off"}),h=Pe.utils.createElement("SPAN",{class:"se-placeholder"});return i.get("placeholder")&&(h.textContent=i.get("placeholder")),{bottomBar:ls(i,null),wysiwygFrame:r,codeView:l,markdownView:a,placeholder:h}}function cs(t,e,s){let i=null,n=!1;if(t.get("codeMirrorEditor")){const o=t.get("codeMirror"),r=[{mode:"htmlmixed",htmlMode:!0,lineNumbers:!0,lineWrapping:!1},o.options||{}].reduce(((t,e)=>{for(const s in e)t[s]=e[s];return t}),{});"auto"===e.get("height")&&(r.viewportMargin=1/0,r.height="auto");const l=s.style.cssText,a=o.src.fromTextArea(s,r);e.set("codeMirrorEditor",a),i=a.display.wrapper,i.style.cssText=l,n=!0}return t.set("hasCodeMirror",n),i?(Pe.utils.removeItem(s),i.className+=" se-code-viewer-mirror",i):s}function ds(t,e,s){const i=s.split("|"),n=(e+"|"+("string"==typeof t?t.toLowerCase():"")).replace(/^\||\|$/g,"").split("|").filter((t=>t&&!i.includes(t))).join("|");return{reg:new RegExp(`^(${n})$`,"i"),str:n}}function us(t,e,s,i,n){const o=e?.[t];if(o){const e="function"==typeof o?o:o.constructor;return{className:o.className||e.className||"",title:n[o.title]||o.title||n[e.title]||e.title||t,command:t,type:o.type||e.type||"",icon:i[o.icon]||o.icon||i[e.icon]||e.icon||""}}const r=ps(s.get("_rtl"),i,n)[t];return r?{className:r[0],title:r[1],command:r[2],type:r[3],icon:r[4]}:null}function ps(t,e,s){return{bold:["",s.bold,"bold","",e.bold],underline:["",s.underline,"underline","",e.underline],italic:["",s.italic,"italic","",e.italic],strike:["",s.strike,"strike","",e.strike],subscript:["",s.subscript,"subscript","",e.subscript],superscript:["",s.superscript,"superscript","",e.superscript],removeFormat:["",s.removeFormat,"removeFormat","",e.remove_format],copyFormat:["",s.copyFormat,"copyFormat","",e.format_paint],indent:["se-icon-flip-rtl",s.indent,"indent","",t?e.outdent:e.indent],outdent:["se-icon-flip-rtl",s.outdent,"outdent","",t?e.indent:e.outdent],fullScreen:["se-code-view-enabled se-component-enabled",s.fullScreen,"fullScreen","",e.expansion],showBlocks:["",s.showBlocks,"showBlocks","",e.show_blocks],codeView:["se-code-view-enabled se-component-enabled",s.codeView,"codeView","",e.code_view],markdownView:["se-code-view-enabled se-component-enabled",s.markdownView,"markdownView","",e.markdown_view],undo:["se-component-enabled",s.undo,"undo","",e.undo],redo:["se-component-enabled",s.redo,"redo","",e.redo],preview:["se-component-enabled",s.preview,"preview","",e.preview],print:["se-component-enabled",s.print,"print","",e.print],copy:["",s.copy,"copy","",e.copy],dir:["",s[t?"dir_ltr":"dir_rtl"],"dir","",e[t?"dir_ltr":"dir_rtl"]],dir_ltr:["",s.dir_ltr,"dir_ltr","",e.dir_ltr],dir_rtl:["",s.dir_rtl,"dir_rtl","",e.dir_rtl],finder:["se-component-enabled",s.find,"finder","",e.finder],save:["se-component-enabled",s.save,"save","",e.save],newDocument:["se-component-enabled",s.newDocument,"newDocument","",e.new_document],selectAll:["se-component-enabled",s.selectAll,"selectAll_full","",e.select_all],pageBreak:["se-component-enabled",s.pageBreak,"pageBreak","",e.page_break],pageUp:["se-component-enabled",s.pageUp,"pageUp","",e.page_up],pageDown:["se-component-enabled",s.pageDown,"pageDown","",e.page_down],pageNavigator:["se-component-enabled","","pageNavigator","input",""]}}function gs(){const t=Pe.utils.createElement("UL",{class:"se-menu-list"});return{div:Pe.utils.createElement("DIV",{class:"se-btn-module se-btn-module-border"},t),ul:t}}function ms(t,e,s,i,n,o,r){n||="";const l=Pe.utils.createElement("LI"),a=e||"",h=/^INPUT|FIELD$/i.test(i),c="se-toolbar-separator-vertical"===t?Pe.utils.createElement("DIV",{class:t,tabindex:"-1"},null):Pe.utils.createElement(h?"DIV":"BUTTON",{class:"se-toolbar-btn se-btn se-tooltip"+(t?" "+t:""),"data-command":s,"data-type":i,"aria-label":a.replace(//,""),tabindex:"-1"});return h||c.setAttribute("type","button"),/^default\./i.test(n)&&(n=r[n.replace(/^default\./i,"")]),/^text\./i.test(n)&&(n=n.replace(/^text\./i,""),c.className+=" se-btn-more-text"),o&&(c.disabled=!0),/^FIELD$/i.test(i)&&Pe.utils.addClass(l,"se-toolbar-hidden-btn"),a&&(n+=Pe.utils.createTooltipInner(a)),n&&(c.innerHTML=n),l.appendChild(c),{li:l,button:c}}function fs(t,e,s,i){if(!t)return;const n=!1===e.inner;if(1===e.inner?.nodeType?t.appendChild(e.inner):t.innerHTML=n?"":(e.inner||s[e.icon]||e.icon||'!')+''+(i[e.title]||e.title)+"",t.setAttribute("aria-label",e.title),e.type&&t.setAttribute("data-type",e.type),e.className&&(t.className+=" "+e.className),e.afterItem&&(Pe.utils.addClass(e.afterItem,"se-toolbar-btn"),t.parentElement.appendChild(e.afterItem),Pe.utils.addClass(t,"se-side-btn-a"),Pe.utils.addClass(e.afterItem,"se-side-btn-after")),e.beforeItem&&(Pe.utils.addClass(e.beforeItem,"se-toolbar-btn"),t.parentElement.insertBefore(e.beforeItem,t),e.afterItem?(Pe.utils.addClass(t,"se-side-btn"),Pe.utils.removeClass(t,"se-side-btn-a")):Pe.utils.addClass(t,"se-side-btn-b"),Pe.utils.addClass(e.beforeItem,"se-side-btn-before")),e.replaceButton&&(t.parentElement.appendChild(e.replaceButton),t.style.display="none"),!e.replaceButton&&/^INPUT$/i.test(t.getAttribute("data-type"))){const e=t.querySelector("input");e&&(Pe.utils.addClass(e,"se-toolbar-btn"),e.setAttribute("data-command",t.getAttribute("data-command")),e.setAttribute("data-type",t.getAttribute("data-type")),t.hasAttribute("disabled")&&(e.disabled=!0))}}function vs(t,e,s,i,n,o){t=JSON.parse(JSON.stringify(t));const r=ps(s.get("_rtl"),i,n),l={},a=[],h=[];let c=null,d=null,u=null,p=null,g=null;const m=Pe.utils.createElement("DIV",{class:"se-toolbar-more-layer"}),f=Pe.utils.createElement("DIV",{class:"se-btn-tray"}),v=Pe.utils.createElement("DIV",{class:"se-toolbar-separator-vertical"});t:for(let s,b,y,w,C,_=0;_",m.appendChild(b),b=b.firstElementChild.firstElementChild)}f.appendChild(p.div)}else{if("|"===w){const t=v.cloneNode(!1);f.appendChild(t);continue}if(/^\/$/.test(w)){const t=Pe.utils.createElement("DIV",{class:"se-btn-module-enter"});f.appendChild(t)}}switch(f.children.length){case 0:f.style.display="none";break;case 1:Pe.utils.removeClass(f.firstElementChild,"se-btn-module-border")}var b,y;m.children.length>0&&f.appendChild(m),a.length>0&&a.unshift(t),b=f,y=s.get("toolbar_innerWidth"),b&&y&&("auto"!==y&&(b.style.maxWidth=y),b.style.width="max-content",b.style.marginLeft="auto",b.style.marginRight="auto");const w=Pe.utils.createElement("DIV",{class:"se-toolbar sun-editor-common"+(s.get("shortcutsHint")?"":" se-shortcut-hide")},f);return s.get("toolbar_hide")&&(w.style.display="none"),{element:w,pluginCallButtons:l,responsiveButtons:a,buttonTray:f,updateButtons:h}}const bs=function(t,e){"object"!=typeof e&&(e={});const s={};if(e.plugins){const t=e.excludedPlugins||[],i=e.plugins,n=Array.isArray(i)?i.map((t=>[null,t])):Object.keys(i).map((t=>[t,i[t]]));for(let e,i,o=0,r=n.length;o'),a="suneditor-"+ ++ss,h=Pe.utils.createElement("DIV",{class:"sun-editor sun-editor-carrier-wrapper sun-editor-common"+n.get("_themeClass")+(n.get("_rtl")?" se-rtl":"")}),c=Pe.utils.createElement("DIV",{class:"se-menu-tray",popover:"manual"});h.appendChild(c);const d=Pe.utils.createElement("INPUT",{type:"text",id:a+"-focus-temp",class:"__se__focus__temp__",autocomplete:"off","aria-hidden":"true",style:"position: fixed !important; top: -10000px !important; left: -10000px !important; display: block !important; width: 0 !important; height: 0 !important; margin: 0 !important; padding: 0 !important;"});d.tabIndex=-1,h.appendChild(d);const u=Pe.utils.createElement("DIV",{class:"se-modal se-modal-area sun-editor-common",popover:"manual"}),p=Pe.utils.createElement("DIV",{class:"se-modal-back"}),g=Pe.utils.createElement("DIV",{class:"se-modal-inner"});u.appendChild(p),u.appendChild(g),h.appendChild(u);const m=Pe.utils.createElement("DIV",{class:"se-alert se-modal-area sun-editor-common",style:"display: none;",popover:"manual"}),f=Pe.utils.createElement("DIV",{class:"se-modal-back"}),v=Pe.utils.createElement("DIV",{class:"se-modal-inner"});m.appendChild(f),m.appendChild(v),h.appendChild(m),h.appendChild(Pe.utils.createElement("DIV",{class:"se-back-wrapper",popover:"manual"}));const b=l.cloneNode(!0);b.setAttribute("popover","manual"),h.appendChild(b);const y=Pe.utils.createElement("DIV",{class:"se-drag-cursor",popover:"manual"});h.appendChild(y),es.body.appendChild(h);let w=null,C=null;const _=vs(i.buttons,s,n,o,r,!1),k=_.element;k.style.visibility="hidden",/inline/i.test(n.get("mode"))?(k.className+=" se-toolbar-inline",k.style.width=n.get("toolbar_width")):/balloon/i.test(n.get("mode"))&&(k.className+=" se-toolbar-balloon",k.style.width=n.get("toolbar_width"),k.appendChild(Pe.utils.createElement("DIV",{class:"se-arrow"}))),n.get("_toolbar_bottom")&&(k.className+=" se-toolbar-bottom"),i.subButtons&&(C=vs(i.subButtons,s,n,o,r,!1),w=C.element,w.style.visibility="hidden",w.className+=" se-toolbar-balloon se-toolbar-sub",w.style.width=n.get("toolbar_sub_width"),w.appendChild(Pe.utils.createElement("DIV",{class:"se-arrow"})));const x=t[0].key||null,$=[],S=new Map,E=i.statusbarContainer;let T=null;for(let e=0,s=t.length;e')),n.get("_type_options").includes("page")&&(N.page=Pe.utils.createElement("DIV",{class:"se-document-page"},null),N.pageMirror=Pe.utils.createElement("DIV",{class:"sun-editor-editable se-document-page-mirror-a4",style:"position: absolute; width: 21cm; columns: 21cm; border: 0; overflow: hidden; height: auto; top: -10000px; left: -10000px;"},null));let B=null;if(u){B=Pe.utils.createElement("DIV",{class:"se-block-handle-area"});const t=Pe.utils.createElement("DIV",{class:"se-block-handle",popover:"manual"}),e=Pe.utils.createElement("DIV",{class:"se-block-handle-btn se-block-handle-plus"},o.plus),s=Pe.utils.createElement("DIV",{class:"se-block-handle-btn se-block-handle-drag"},o.dragHandle);t.appendChild(e),t.appendChild(s),B.appendChild(t)}c.appendChild(d),$.push(_),S.set(_,Xe({target:s.target,key:s.key,options:h},c,v,k,y,x,M,T||f,N,B,_))}const M=n.get("toolbar_container");if(M){const t=Pe.utils.createElement("DIV",{class:"sun-editor"+n.get("_themeClass")+(n.get("_rtl")?" se-rtl":"")}),e=Pe.utils.createElement("DIV",{class:"se-container"});e.appendChild(k),w&&e.appendChild(w),t.appendChild(e),M.appendChild(t),M.appendChild(Pe.utils.createElement("DIV",{class:"se-toolbar-sticky-dummy"}))}else{const t=S.get(x).get("container");if(n.get("_toolbar_bottom")){const e=t.querySelector(".se-statusbar");t.insertBefore(k,e),w&&t.insertBefore(w,k)}else t.insertBefore(k,t.firstElementChild),w&&t.insertBefore(w,t.firstElementChild)}return{context:Ye(k,M,c,w,E),carrierWrapper:h,options:n,plugins:s,icons:o,lang:r,value:i.v,rootId:x,rootKeys:$,frameRoots:S,pluginCallButtons:_.pluginCallButtons,responsiveButtons:_.responsiveButtons,pluginCallButtons_sub:C?C.pluginCallButtons:[],responsiveButtons_sub:C?C.responsiveButtons:[]}},{_w:ys}=Oe,ws=Math.floor(96/72*841.89105);const Cs=class{#t;#e;#s;#i;#n;#o;#r;#l;#a;#h;#c;#d;#u;#p;#g;#m;#f=-1;#v=-1;#b=null;#y=null;#w=0;#C=0;#_=-1;#k=0;#x=[];#$=null;#S=0;#E=0;#T=new Map;#M=null;constructor(t,e){const s=t.$;if(this.#t=s.store,this.#e=s.context,this.#s=this.#t.get("isScrollable"),this.#i=s.offset,this.#n=s.selection,this.#o=s.toolbar,this.useHeader=s.options.get("_type_options").includes("header"),this.usePage=s.options.get("_type_options").includes("page"),this.#r=e,this.#l=e.get("wysiwyg"),this.#a=e.get("wysiwygFrame"),this.#h=e.get("documentTypeInner"),this.#p=e.get("documentTypePageMirror"),this.#p){const t=ys.getComputedStyle(this.#p);this.#g=De.get(t.paddingTop),this.#m=De.get(t.paddingBottom)}if(this.useHeader){const t=this._getHeaders(),e=this.#c=this.#h.querySelector(".se-document-lines-inner");let i="";for(let e,s=0,n=t.length;s${e.textContent}`;e.innerHTML=i,this.#b=e.querySelectorAll("div"),s.eventManager.addEvent(e,"click",this.#N.bind(this,this.#l))}this.usePage&&(this.#d=e.get("documentTypePage"),this.#u=s.plugins.pageNavigator)}reHeader(){if(!this.useHeader)return;const t=this._getHeaders(),e=this.#c,s=this.#b;for(let i,n,o,r=0,l=t.length;rt.length)for(let i=t.length;i{await Pe.utils.waitForMediaLoad(this.#p,1500);const e=this.#l.scrollHeight>this.#p.scrollHeight?this.#l.scrollHeight-this.#p.scrollHeight:0,s=this.#p.scrollHeight+e,i=this.#l.querySelectorAll(".se-page-break");if(!t&&this.#_===s&&this.#k===i.length)return;this.#_=s,this.#k=i.length;let n=0;const o=[];if(i.length>0){n=i[0].offsetHeight;for(let t=0;tt.end))],d=[...o.map((t=>t.top)),s];for(let t=0;t=e);)if(!l.some((t=>Math.abs(t.top-s)<3))){const t=this._calcPageBreakTop(s,a,h,l);if(null===t)break;l.push({number:0,top:t})}}if(0===l.length)return this.#$=null,this.#w=1,void this._displayCurrentPage();l.sort(((t,e)=>t.top-e.top)),this.#d.innerHTML="",this.#x=[];const u=this.#a.offsetWidth+1;for(let t,e=0;e${e+1}`);this.#d.appendChild(s),this.#x.push(s)}this.#$=this.#d.querySelectorAll(".se-document-page-line"),this.#w=this.#x.length,this.#B(),this._displayCurrentPage()}),400))}_getDisplayPage(){return this.#s(this.#r)?this.#r.get("wysiwyg"):ys}_calcPageBreakTop(t,e,s,i){const{ci:n}=this._getElementAtPosition(t,s,i),o=s[n],r=e[n];if(!o||!r)return null;const l=t+(r.offsetTop-o.offsetTop)+(r.offsetHeight-o.offsetHeight)/2;return Math.round(l)}_initializeCache(t){this.#T.clear();for(let e=0,s=t.length;e0){const e=this.#T.get(i);e&&t=r&&t<=a){let i=o;if(s&&Pe.utils.hasClass(e[i],"se-page-break")){i=i+1800?Pe.utils.removeClass(this.#h,"se-document-responsible"):Pe.utils.addClass(this.#h,"se-document-responsible"),this.#f=t,this.#v=e;const i=this.#$;for(let e=0,s=i?.length;ee?"none":""}}scrollWindow(){this.#s(this.#r)||this._displayCurrentPage()}getCurrentPageNumber(){if(this.#w<=1)return 1;let t=0;if(this.#s(this.#r))t=this.#v/2;else{const e=this._getGlobalTop();if(t=ys.scrollY-e+ws/2,t<=0)return 1}const e=this.#x;for(let s=0,i=e.length;s=t)return this.#C=s;return this.#C=this.#w}pageUp(){const t=this.#C-1<=1?1:this.#C-1;this._movePage(t,!1)}pageDown(){const t=this.#C+1>this.#x.length?this.#x.length:this.#C+1;this._movePage(t,!1)}pageGo(t){t<1?t=1:t>this.#x.length&&(t=this.#x.length),this._movePage(t,!0)}on(t){if(!this.useHeader)return;if(this._is(t)||(t=this._findLinesHeader(t)),!t)return;const e=this._findItem(t);e&&(Pe.utils.removeClass(this.#b,"active"),Pe.utils.addClass(e,"active"))}onChangeText(t){if(!this.useHeader)return;if(!this._is(t))return;const e=this._findItem(t);e&&(e.textContent=t.textContent)}_displayCurrentPage(){const t=this.getCurrentPageNumber();this.#u?.display(t,this.#w)}_getWWScrollTop(){const t=this._getDisplayPage();return t.scrollTop||t.scrollY||0}_movePage(t,e){const s=this._getGlobalTop(),i=this.#s(this.#r),n=ze.nodeListToArray(this.#l.children),o=this.#d.offsetTop+De.get(this.#x[t-1].style.top)+(i?this._getWWScrollTop():0);for(let r,l=0,a=n.length;l=o){e||this.#n.setRange(r,0,r,0);const n=0===l&&i?0:r.offsetTop-this.#d.offsetTop-r.offsetHeight+s;this._applyPageScroll(n,(()=>{this.#o.isSticky&&!this.#t.mode.isBottom&&this._getDisplayPage().scrollTo({top:n-this.#e.get("toolbar_main").offsetHeight,behavior:"smooth"})})),this.#C=t;break}}_applyPageScroll(t,e){const s=this._getDisplayPage();s.scrollTo({top:t,behavior:"smooth"});const i=()=>{Math.abs((s.scrollY??s.scrollTop)-t)<1?e():ys.requestAnimationFrame(i)};ys.requestAnimationFrame(i)}_getGlobalTop(){return this.#s(this.#r)?0:this.#i.getGlobal(this.#a).top}_findItem(t){const e=this.#y,s=Array.prototype.indexOf.call(e,t);return-1!==s&&this.#b[s]?this.#b[s]:null}_findLinesHeader(t){for(;t&&t!==this.#l;){if(this._is(t))return t;t=t.previousElementSibling||t.parentElement}return null}_is(t){return/^h[1-6]$/i.test(t?.nodeName)}_getHeaders(){return this.#y=this.#l.querySelectorAll("h1, h2, h3, h4, h5, h6")}#N(t,e){e.preventDefault();try{this.#t.set("_preventBlur",!0);const t=Pe.query.getEventTarget(e);if(Pe.utils.hasClass(t,"se-doc-item")){const e=Array.prototype.indexOf.call(this.#b,t);if(-1===e)return;const s=this.#y[e];s&&this.#n.scrollTo(s)}}finally{this.#t.set("_preventBlur",!1)}}_destroy(){this.#M&&(ys.clearTimeout(this.#M),this.#M=null),this.#T&&(this.#T.clear(),this.#T=null),this.#r=null,this.#l=null,this.#a=null,this.#h=null,this.#c=null,this.#d=null,this.#x=null,this.#$=null,this.#b=null,this.#y=null,this.#u=null,this.#p=null}};const _s=class{#I;#L=new Map;constructor(t){const e=t.options,s=e.get("mode"),i=e.get("_subMode");this._editorInitFinished=!1,this.mode={isClassic:/classic/i.test(s),isInline:/inline/i.test(s),isBalloon:/balloon/i.test(s),isBalloonAlways:/balloon-always/i.test(s),isSubBalloon:/balloon/i.test(i),isSubBalloonAlways:/balloon-always/i.test(i),isBottom:!!e.get("_toolbar_bottom")},this.#I={rootKey:t.rootId,hasFocus:!1,tabSize:4,indentSize:25,codeIndentSize:2,currentNodes:[],currentNodesMap:[],initViewportHeight:0,currentViewportHeight:0,controlActive:!1,_lastSelectionNode:null,isScrollable:t=>{const e=t.get("options"),s=e.get("height"),i=e.get("maxHeight");return"auto"!==s||!!i&&t.get("wysiwyg").offsetHeight>=De.get(i)},_range:null,_mousedown:!1,_preventBlur:!1,_preventFocus:!1,_canUseBeforeInput:!0}}get(t){return this.#I[t]}set(t,e){const s=this.#I[t];this.#I[t]=e,this.#A(t,e,s)}subscribe(t,e){return this.#L.has(t)||this.#L.set(t,new Set),this.#L.get(t).add(e),()=>this.#L.get(t).delete(e)}#A(t,e,s){const i=this.#L.get(t);if(i)for(const n of i)try{n(e,s)}catch(e){console.error(`[Store] Subscriber error for "${t}":`,e)}}_reset(){}_destroy(){this.#L.clear(),this.#I=null}},{_w:ks,_d:xs}=Oe;class $s{#O;#R;#z;constructor(t){this.#O=t.frameRoots,this.#R=this.#P(t.context),this.#z=this.#D({value:new Map}),this.rootKeys=t.rootKeys,this.carrierWrapper=t.carrierWrapper,this.icons=t.icons,this.lang=t.lang,this.shadowRoot=null}get frameRoots(){return this.#O}get context(){return this.#R}get frameContext(){return this.#z}init(){this.applyToRoots((t=>{this.#F(t)}))}reset(t){this.#z.reset(t)}applyToRoots(t){this.#O.forEach(t)}#F(t){const e=t.get("options");if(t.set("wwComputedStyle",ks.getComputedStyle(t.get("wysiwyg"))),!e.get("iframe")&&"function"==typeof ShadowRoot){let e=t.get("wysiwygFrame");for(;e;){if(e.shadowRoot){this.shadowRoot=e.shadowRoot;break}if(e instanceof ShadowRoot){this.shadowRoot=e;break}e=e.parentNode}}e.get("iframe")?(t.set("_ww",t.get("wysiwygFrame").contentWindow),t.set("_wd",t.get("wysiwygFrame").contentDocument),t.set("wysiwyg",t.get("_wd").body),e.get("_defaultStyles").editor&&(t.get("wysiwyg").style.cssText=e.get("_defaultStyles").editor),"auto"===e.get("height")&&t.set("_iframeAuto",t.get("_wd").body)):(t.set("_ww",ks),t.set("_wd",xs));const s=e.get("editableFrameAttributes");for(const e in s)t.get("wysiwyg").setAttribute(e,s[e])}#P(t){const e=t;return{get:t=>e.get(t),set:(t,s)=>e.set(t,s),has:t=>e.has(t),delete:t=>e.delete(t),getAll:()=>Object.fromEntries(e.entries()),get size(){return e.size},clear(){e.clear()}}}#D(t){let e=t.value;return{get:t=>e.get(t),set:(t,s)=>e.set(t,s),has:t=>e.has(t),delete:t=>e.delete(t),getAll:()=>Object.fromEntries(e.entries()),reset(s){e=t.value=s},get size(){return e.size},clear(){e.clear()}}}_destroy(){this.applyToRoots((t=>{const e=t.get("documentType");e&&e._destroy(),Pe.utils.removeItem(t.get("topArea")),t.get("options").clear(),t.clear()})),this.#R.clear(),this.#z.clear(),this.#O.clear(),Pe.utils.removeItem(this.carrierWrapper),this.rootKeys=null,this.carrierWrapper=null,this.icons=null,this.lang=null,this.shadowRoot=null}}class Ss{#H;#q;#W;#U;constructor(t,e,s){this.#H=t,this.#q=s,this.#W=this.#V({value:e.options}),this.#U=this.#j({value:new Map})}get options(){return this.#W}get frameOptions(){return this.#U}reset(t){const{$:e}=this.#H,s=e.frameRoots,i=e.context,n=e.eventManager,o=e.format,r=e.html,l=e.char,a=e.viewer,h=e.plugins,c=e.history,d=e.ui,u=this.#H._eventOrchestrator;a.codeView(!1),a.showBlocks(!1);const p=new Map,g=[],m=new Map,f={};for(const e in t)void 0!==Qe[e]&&(f[e]=t[e],delete t[e]);for(const e of s.keys())t[e||""]={...f,...t[e||""]};const v=Object.keys(t);if(this.#G(v,h,""),0===v.length)return;1===s.size&&v.unshift(null);const b=[this.#q,t].reduce(((t,e)=>{for(const i in e)s.has(i||null)?this.#K(i,e,s,p,m,g):t[i]=e[i];return t}),{}),y=this.#W,w=rs(b,g,h),C=w.o,_=w.frameMap;for(let t,e=0,i=v.length;ee.get(t),set:(t,s)=>e.set(t,s),has:t=>e.has(t),getAll:()=>Object.fromEntries(e.entries()),setMany(t){t.forEach(((t,s)=>e.set(s,t)))},reset(s){e=t.value=s},size:()=>e.size,clear(){e.clear()},entries:()=>e.entries(),keys:()=>e.keys(),values:()=>e.values(),forEach(t){e.forEach(t)}}}#j(t){let e=t.value;return{get:t=>e.get(t),set:(t,s)=>e.set(t,s),has:t=>e.has(t),getAll:()=>Object.fromEntries(e.entries()),setMany(t){t.forEach(((t,s)=>e.set(s,t)))},reset(s){e=t.value=s},size:()=>e.size,clear(){e.clear()},entries:()=>e.entries(),keys:()=>e.keys(),values:()=>e.values(),forEach(t){e.forEach(t)}}}_destroy(){this.#q=null,this.#W.clear(),this.#U.clear()}}const Es=class{#X;constructor(t){this.#X=t}isNode(t){return t&&"number"==typeof t.nodeType||t instanceof this.#Z().Node}isElement(t){return t&&1===t.nodeType||t instanceof this.#Z().Element}isRange(t){return t&&"Range"===t.constructor?.name||t instanceof this.#Z().Range}isSelection(t){return t&&"Selection"===t.constructor?.name||t instanceof this.#Z().Selection}#Z(){return this.#X.get("_ww")}},{_w:Ts,_d:Ms,NO_EVENT:Ns}=Oe;const Bs=class{#J;#X;#Q;#tt=null;#et=null;#st=[];#it=[];constructor(t,e,s){this.#J=s,this.#X=t.frameContext,this.#Q=e.frameOptions,this.events=e.options.get("events")||{},this.triggerEvent=async(t,e)=>{if(Pe.check.isNonEditable(e?.frameContext?.get("wysiwyg")))return!1;const s=this.events[t];if("function"==typeof s)try{return await s({$:this.#J,...e})}catch(e){return console.error(`[SUNEDITOR.triggerEvent.${t}]`,e),!1}return Ns}}_bindOrchestrator(t){this.#tt=t}applyTagEffect(t){return this.#tt?.applyTagEffect(t)}addEvent(t,e,s,i){if(!t)return null;if((t===Ts||t===Ms||"number"!=typeof t.length||t.nodeType||!Array.isArray(t)&&t.length<1)&&(t=[t]),0===t.length)return null;const n=t.length;for(let o=0;oi.type===t&&i.listener===e&&i.useCapture===s))??-1;return i>-1&&this.#it.splice(i,1),null}_injectActiveEvent(t){Pe.utils.addClass(t,"__se__active"),this.#et=this.addGlobalEvent("mouseup",(()=>{Pe.utils.removeClass(t,"__se__active"),this.#et=this.removeGlobalEvent(this.#et)}))}_init(){for(let t,e=0,s=this.#st.length;e0&&(c+=v.offsetTop),v.scrollHeight>=v.clientHeight&&(d=/^html$/i.test(v.nodeName)?d||v.clientHeight:v.clientHeight+(m?-m.clientTop:0),p=m||p||v,m=v),v.scrollLeft>0&&(h+=v.offsetLeft),v.scrollWidth>=v.clientWidth&&(u=/^html$/i.test(v.nodeName)?u||v.clientWidth:v.clientWidth+(f?-f.clientLeft:0),g=f||g||v,f=v),v=v.parentElement;if(!i&&!s&&/^iframe$/i.test(this.#X.get("wysiwygFrame").nodeName))for(v=this.#X.get("wrapper"),p=g=e;v;)n+=v.scrollTop,r+=v.scrollLeft,l+=v.scrollHeight,a+=v.scrollWidth,v.scrollTop>0&&(c+=v.offsetTop),v.scrollHeight>=v.clientHeight&&(d=/^html$/i.test(v.nodeName)?d||v.clientHeight:v.clientHeight+(m?-m.clientTop:0),m=v),v.scrollLeft>0&&(h+=v.offsetLeft),v.scrollWidth>=v.clientWidth&&(u=/^html$/i.test(v.nodeName)?u||v.clientWidth:v.clientWidth+(f?-f.clientLeft:0),f=v),v=v.parentElement;for(v=this.#nt?.host,v&&(p=g=e);v;)n+=v.scrollTop,r+=v.scrollLeft,l+=v.scrollHeight,a+=v.scrollWidth,v.scrollTop>0&&(c+=v.offsetTop),v.scrollHeight>=v.clientHeight&&(d=/^html$/i.test(v.nodeName)?d||v.clientHeight:v.clientHeight+(m?-m.clientTop:0),m=v),v.scrollLeft>0&&(h+=v.offsetLeft),v.scrollWidth>=v.clientWidth&&(u=/^html$/i.test(v.nodeName)?u||v.clientWidth:v.clientWidth+(f?-f.clientLeft:0),f=v),v=v.parentElement;const b=e.contains(p),y=e.contains(g);p=b?e:p,g=y?e:g;const w=p?p.getBoundingClientRect().top+(!p.parentElement||/^html$/i.test(p.parentElement.nodeName)?o.scrollY:0):0,C=g?g.getBoundingClientRect().left+(!g.parentElement||/^html$/i.test(g.parentElement.nodeName)?o.scrollX:0):0;d=b?e.clientHeight:d,u=y?e.clientWidth:u;const _=pt(this.#X.get("_wd"));return{top:n,left:r,ts:w,ls:C,width:a,height:l,x:h,y:c,ohOffsetEl:i?window:p,owOffsetEl:i?window:g,oh:i?_.h:d,ow:i?_.w:u,heightEditorRefer:b,widthEditorRefer:y}}getWWScroll(){const t=this.#X.get("eventWysiwyg"),e=t.scrollTop||t.scrollY||0,s=t.scrollHeight||t.document?.documentElement.scrollHeight||0;return{top:e,left:t.scrollLeft||t.scrollX||0,width:t.scrollWidth||t.document?.documentElement.scrollWidth||0,height:s,bottom:e+s}}setRelPosition(t,e,s,i,{preferUp:n}={}){const l=/^fixed$/i.test(o.getComputedStyle(i).position),a=this.getGlobal(s);if(l)t.style.position="fixed",t.style.top=n?a.fixedTop-t.offsetHeight+"px":`${a.fixedTop+a.height}px`;else{t.style.position="";const l=i.contains(t)?this.getGlobal(e).top:0,h=t.offsetHeight,c=o.scrollY,d=a.top;if(n){const e=l-c+d;if(e=h?t.style.top=`${d+s.offsetHeight}px`:i>e?(t.style.height=`${i}px`,t.style.top=`${d+s.offsetHeight}px`):(t.style.height=`${e}px`,t.style.top=-1*(e-d+3)+"px")}else t.style.top=d-h+"px"}else{const e=pt(r).h-(l-c+d+s.offsetHeight);if(ee?(t.style.height=`${o}px`,i=-1*(o-d+3)):(t.style.height=`${e}px`,i=d+s.offsetHeight),t.style.top=`${i}px`}else t.style.top=`${d+s.offsetHeight}px`}}const h=t.offsetWidth,c=a.left,d=this.getGlobal(i).left;if(this.#rt.get("_rtl")){const e=s.getBoundingClientRect(),n=o.innerWidth;let r=n-e.right;if(h>0){const t=i.getBoundingClientRect();n-r-h0||!this.#J.toolbar.isSticky&&N?0:T+(this.#J.toolbar.isSticky?this.#rt.get("_toolbar_sticky"):0),I=this.#X.get("statusbar")?.offsetHeight||0,{rmt:L,rmb:A,bMargin:O,rt:R}=this.#at(x,$,B,m,v,p,d);if(c&&(A-I+k<=0||L+R+k-(this.#J.toolbar.isSticky&&g?B:0)<=0)||L+k<0)return;const z=this.#X.get("topArea").getBoundingClientRect(),P=this.#t.mode.isBottom?z.bottom>=o.innerHeight-T:z.top<=T,D=this.#J.toolbar.isSticky&&"none"!==this.#e.get("toolbar_main").style.display&&(!N||P);let F=i.top,H=0,q="";"bottom"===n?(q="up",F+=v.bottom+C+E,H=A-(_+C),H-w<0&&(q="down",F-=k+_+2*C,H=L-(_+C),H-w<0&&(q="",F-=H-w-Math.max(1,H+_+C)))):(q="down",F+=v.top-_-C+E,H=(D&&!this.#t.mode.isBottom?v.top-B:L)-_-C,H-w<0&&(q="up",F+=k+_+2*C,H=(A>0?O:A)-(_+C)-I,H-w<0&&(q="",F+=H-2))),this.#ht(y,q),t.style.top=`${F}px`;const W=(1===t.nodeType?De.get(o.getComputedStyle(t).borderRadius):0)||0,U=b.width,V=t.offsetWidth,j=y?y.offsetWidth:0,G=v.left,K=m.w-v.right;if(c&&(G+U<=0||K+U<=0))return;y&&(y.style.left="",y.style.right="");let Y=i.left||(i.right?a?i.right-t.offsetWidth:t.offsetWidth-i.right:0),X=0,Z=0,J=0;return a?(Y+=v.left+o.scrollX-(G<0?G:0),X=U+G,XJ?J:Z),y&&Z>0&&(y.style.left=Z+"px")):(Y+=v.right-V+o.scrollX+(K<0?K:0),X=U+K,XV-J?V-J:Z),y&&Z>0&&(y.style.right=Z+"px")),t.style.left=`${Y}px`,l.__offset={left:t.offsetLeft+f.left,top:t.offsetTop+f.top,addOffset:i},{position:"up"===q?"bottom":"top"}}setRangePosition(t,e,{position:s,addTop:i}={}){t.style.top="-10000px",t.style.visibility="hidden",t.style.display="block";let n="top"===s;e||=this.#J.selection.getRange();const l=this.#J.selection.getRects(e,n?"start":"end");if(n="start"===l.position,l.rects.noText){let t=e.startContainer;1===t.nodeType&&(t=t.childNodes[e.startOffset]||t);const s=t.parentNode;if(s){const e=rt(E);s.insertBefore(e,t);const i=r.createRange();i.setStart(e,1),i.setEnd(e,1);const n=i.getClientRects()[0];n&&(l.rects=n,l.scrollLeft=o.scrollX,l.scrollTop=o.scrollY),s.removeChild(e)}}const a=this.#X.get("isFullScreen"),h=this.#X.get("topArea"),c=this.#ot.contains(t),d=l.rects,u=a?0:l.scrollLeft,p=a?0:l.scrollTop,g=c?pt(r).w:h.offsetWidth,m=this.getGlobal(h),f=c?0:m.left,v=t.offsetWidth,b=t.offsetHeight;this.#ct(n,d,t,f,g,u,p,i),this.getGlobal(t).top-m.top<0&&(n=!n,this.#ct(n,d,t,f,g,u,p,i)),v===t.offsetWidth&&b===t.offsetHeight||this.#ct(n,d,t,f,g,u,p,i);const y=!this.#ot.contains(t),w=pt(r),C=d.height,_=d.top,k=w.h-d.bottom,x=this.#J.toolbar.isSticky||!this.#t.mode.isBalloon&&!this.#t.mode.isInline?this.#e.get("toolbar_main").offsetHeight:0,{rmt:$,rmb:S,rt:T}=this.#at(_,k,x,w,d,y,!1);if(!(S+C<=0||$+T+C<=0))return t.style.visibility="",!0}#ct(t,e,s,i,n,o,l,a=0){const h=s.querySelector(".se-arrow "),c=Math.round(h.offsetWidth/2),d=s.offsetWidth,u=e.noText&&!t?0:s.offsetHeight,p=(t?e.left:e.right)-i-d/2+o,g=p+d-n;let m=(t?e.top-u-c:e.bottom+c)-(e.noText?0:a)+l;const f=p<0?1:g<0?p:p-g-1-1;let v=!1;const b=m+(t?this.getGlobal(this.#X.get("topArea")).top:s.offsetHeight-this.#X.get("wysiwyg").offsetHeight);!t&&b>0&&this.#dt()b&&(t=!1,v=!0),v&&(m=(t?e.top-u-c:e.bottom+c)-(e.noText?0:a)+l),s.style.left=Math.floor(f)+"px",s.style.top=Math.floor(m)+"px",t?(ut(h,"se-arrow-up"),dt(h,"se-arrow-down")):(ut(h,"se-arrow-down"),dt(h,"se-arrow-up"));const y=Math.floor(d/2+(p-f));h.style.left=(y+c>s.offsetWidth?s.offsetWidth-c:ye?r=this.#J.toolbar.isSticky?s:e+s:this.#rt.get("toolbar_container")&&!this.#J.toolbar.isSticky?s=0:r=e+s,h=n.top-(a.top-t),c=a.bottom-(n.bottom-r)+s,c=c>0?c:c-s):(s>t?i=this.#J.toolbar.isSticky?s:t+s:this.#rt.get("toolbar_container")&&!this.#J.toolbar.isSticky?s=0:i=t+s,h=n.top-(a.top-i)+s,c=a.bottom-(n.bottom-e),h=h>0?h:h-s)}else{const t=m.fixedTop>0?m.fixedTop:0,e=o.innerHeight-(m.fixedTop+m.height);d=l||!this.#J.toolbar.isSticky&&this.#J.toolbar.isBalloonMode?0:s,f?(h=u-(l?0:t),c=p-(e>0?e:0)-d):(h=u-(l?0:t)-d,c=p-(e>0?e:0))}return{rmt:h,rmb:c,rt:d,tMargin:u,bMargin:p}}#ht(t,e){"up"===e?(t&&(t.style.visibility=""),dt(t,"se-arrow-up"),ut(t,"se-arrow-down")):"down"===e?(t&&(t.style.visibility=""),dt(t,"se-arrow-down"),ut(t,"se-arrow-up")):t&&(t.style.visibility="hidden")}#lt(){const t=pt(r);return{top:o.scrollY,left:o.scrollX,width:t.w,height:t.h,bottom:o.scrollY+t.h,rects:{left:0,top:0,right:o.innerWidth,bottom:this.#t.get("currentViewportHeight")||o.innerHeight,noText:!0}}}},{_w:Ls}=Oe;const As=class{#H;#J;#t;#nt;#ut;#e;#X;#rt;#Q;#pt=0;#gt=!1;constructor(t){this.#H=t,this.#J=t.$,this.#t=t.store,this.#nt=this.#J.contextProvider.shadowRoot,this.#ut=this.#J.instanceCheck,this.#e=this.#J.context,this.#X=this.#J.frameContext,this.#rt=this.#J.options,this.#Q=this.#J.frameOptions,this.range=null,this.selectionNode=null,this.__iframeFocus=!1}get(){let t=null;return t="function"==typeof this.#nt?.getSelection?this.#nt.getSelection():this.#X.get("_ww").getSelection(),t?(this.#t.get("_range")||this.#X.get("wysiwyg").contains(t.focusNode)||(t.removeAllRanges(),t.addRange(this.#mt())),t):null}isRange(t){return this.#ut.isRange(t)}getRange(){const t=this.#t.get("_range")||this.#mt(),e=this.get();if(t.collapsed===e.isCollapsed||!this.#X.get("wysiwyg").contains(e.focusNode)){if(this.#J.component.is(t.startContainer)){const e=this.#J.component.get(t.startContainer),s=e?.container;return s?this.setRange(s,0,s,1):t}return t}if(e.rangeCount>0){const t=e.getRangeAt(0);return this.#t.set("_range",t),t}{const t=e.anchorNode,s=e.focusNode,i=e.anchorOffset,n=e.focusOffset,o=Pe.query.compareElements(t,s),r=o.ancestor&&(0===o.result?i<=n:o.result>1);return this.setRange(r?t:s,r?i:n,r?s:t,r?n:i)}}setRange(t,e,s,i){let n,o,r,l;if(this.isRange(t)){const e=t;n=e.startContainer,o=e.startOffset,r=e.endContainer,l=e.endOffset}else n=t,o=e,r=s,l=i;if(!n||!r)return;(Pe.check.isBreak(n)||3===n.nodeType)&&o>n.textContent.length&&(o=n.textContent.length),(Pe.check.isBreak(r)||3===r.nodeType)&&l>r.textContent.length&&(l=r.textContent.length),this.#J.format.isLine(n)&&(n=n.childNodes[o>0?n.childNodes.length-1:0]||n,o=o>0?1!==n.nodeType||Pe.check.isBreak(n)?n.textContent?n.textContent.length:0:1:0),this.#J.format.isLine(r)&&(r=r.childNodes[l>0?r.childNodes.length-1:0]||r,l=l>0?1!==r.nodeType||Pe.check.isBreak(r)?r.textContent?r.textContent.length:0:1:0);const a=this.#X.get("_wd").createRange();try{o=Math.min(o,n.textContent?.length||0),l=l>0&&0===(r.textContent?.length||0)&&1===r.nodeType?1:Math.min(Math.max(l,0),r.textContent?.length||0),a.setStart(n,o),a.setEnd(r,l),this.#t.set("hasFocus",!0)}catch(t){return console.warn("[SUNEDITOR.selection.focus.warn]",t.message),void this.#J.focusManager.nativeFocus()}const h=this.get();return h.removeAllRanges&&h.removeAllRanges(),h.addRange(a),this.#t.set("_range",a),this.#ft(a,this.get()),this.#Q.get("iframe")&&this.__focus(),a}removeRange(){this.#t.set("_range",null),this.#t.set("_lastSelectionNode",null),this.selectionNode=null,this.#t.get("hasFocus")&&this.get().removeAllRanges(),this.#H._eventOrchestrator.selectionState.reset()}getNearRange(t){const e=t.nextSibling,s=t.previousSibling;return e?{container:e,offset:0}:s?{container:s,offset:1}:null}getRangeAndAddLine(t,e){if(this.#vt(t)){const s=e?.parentElement||this.#X.get("wysiwyg"),i=Pe.utils.createElement(this.#rt.get("defaultLine"),null,"
    ");s.insertBefore(i,e&&e!==s?e.previousElementSibling?e.nextElementSibling:e:s.firstElementChild),this.setRange(i.firstElementChild,0,i.firstElementChild,1),t=this.#t.get("_range")}return t}getNode(){if(this.#X.get("wysiwyg").contains(this.selectionNode)||this.init(),!this.selectionNode){const t=Pe.query.getEdgeChild(this.#X.get("wysiwyg").firstChild,(t=>0===t.childNodes.length||3===t.nodeType),!1);if(t)return this.selectionNode=t,t;this.init()}return this.selectionNode}getRects(t,e){const s=!!Pe.check.isElement(t)&&"absolute"===Ls.getComputedStyle(t).position;t=!t||Pe.check.isText(t)?this.getRange():t;let i="start"===e,n=Ls.scrollX,o=Ls.scrollY,r=t.getClientRects();if(r=r[i?0:r.length-1],!r){const t=this.getNode();if(this.#J.format.isLine(t)){const t=Pe.utils.createTextNode(Re.zeroWidthSpace);this.#J.html.insertNode(t,{afterNode:null,skipCharCount:!0}),this.setRange(t,1,t,1),this.init(),r=this.getRange().getClientRects(),r=r[i?0:r.length-1]}if(!r){const e=this.#J.offset.get(t);r={left:e.left,top:e.top,right:e.left+t.offsetWidth,bottom:e.top+t.offsetHeight,noText:!0},n=0,o=0}i=!0}const l=/^iframe$/i.test(this.#X.get("wysiwygFrame").nodeName)?this.#X.get("wysiwygFrame").getClientRects()[0]:null;return!s&&l&&(r={left:r.left+l.left,top:r.top+l.top,right:r.right+l.right-l.width,bottom:r.bottom+l.bottom-l.height}),{rects:r,position:i?"start":"end",scrollLeft:n,scrollTop:o}}getDragEventLocationRange(t){const e=this.#X.get("_wd");let s,i,n,o,r;return e.caretPositionFromPoint?(s=e.caretPositionFromPoint(t.clientX,t.clientY),i=s.offsetNode,n=s.offset,o=s.offsetNode,r=s.offset):e.caretRangeFromPoint&&(s=e.caretRangeFromPoint(t.clientX,t.clientY),i=s.startContainer,n=s.startOffset,o=s.endContainer,r=s.endOffset),{sc:i,so:n,ec:o,eo:r}}scrollTo(t,e){const s=e?.noFocus;if(this.#ut.isSelection(t))t=t.getRangeAt(0);else if(this.#ut.isNode(t))if(s){const e=this.#X.get("_wd").createRange();e.selectNodeContents(t),t=e}else t=this.setRange(t,1,t,1);else void 0===t?.startContainer&&console.warn('[SUNEDITOR.html.scrollTo.warn] "selectionRange" must be Selection or Range or Node object.',t);const i=Pe.query.getParentElement(t?.startContainer,(t=>1===t.nodeType));if(!i)return;delete(e={behavior:"smooth",block:"nearest",inline:"nearest",...e}).noFocus;const n=this.#X.get("_ww"),o=this.#X.get("wysiwygFrame"),r=this.#Q.get("iframe"),l=!this.#t.get("isScrollable")(this.#X),a=this.#t.get("currentViewportHeight"),h=l?Ls.scrollY:r?n.scrollY:o.scrollTop,c=this.#t.mode.isBottom,d=this.#e.get("toolbar_main").offsetHeight,u=this.#J.toolbar.isSticky?d:0,p=this.#J.toolbar.isSticky?u+this.#rt.get("_toolbar_sticky"):u,g=this.#X.get("statusbar")?.offsetHeight||0;if(this.#gt){const s=this.#J.format.isBrLine(i)?t?.getBoundingClientRect?.():null;if(s?.height>0?this.#bt(s,e.behavior):i?.scrollIntoView(e),"auto"===e?.behavior)if(p&&!c){const e=t?.getBoundingClientRect?.();e?.height>0&&e.top>=0&&e.top0?v.height:i.offsetHeight)||0,y=e?.behavior,w=c?0:p;if(l)if(r){const e=this.getRects(t,"end").rects,s=e.top+b-w,i=f-m-(e.top+b);if(s>=0&&i>=0)return;const n=h-(s<0?-(s-m):i),o=w>0&&s<0;Ls.scrollTo({top:o?n-w:n,behavior:y})}else{const t=v?.height>0?v.top+h:this.#J.offset.getGlobal(i).top,e=f+h-t-b,s=w>0?t-h>=w:f>e+m;if(e-m>0&&s)return;const n=e<=m?h-e+m+g:h-e+(f-b-m),o=w>0&&!s;Ls.scrollTo({top:o?n-w:n,behavior:y})}else{const t=v?.height>0?v.top:i.getBoundingClientRect().top,e=r?t:t-o.getBoundingClientRect().top,s=e>=(c?0:u)&&e+m<=f;let l=h+(c?e-m>0?e+m-f+u:e-b:e-m>0?e+m-f:e-(u+b));const p=Ls.scrollY,w=this.#J.offset.getGlobal(),C=c?0:d,_=c?d:0,k=p-w.top+C,x=w.top+w.height-(p+a)+_;if(k>0){const t=(s?e:e+h-l)-b-m-k;t<0&&(l+=C,Ls.scrollTo({top:p+t,behavior:"smooth"}))}if(x>0){const t=(s?e:e+h-l)+b+m-(w.height-x);t>0&&(l+=c?_:g,Ls.scrollTo({top:p+t,behavior:"smooth"}))}s||(r?n:o).scrollTo({top:l,behavior:y})}}#bt(t,e){let{top:s,bottom:i}=t;const n=[...this.#H._eventOrchestrator.scrollparents||[],Ls];for(const t of n){const n=t===Ls,o=n?0:t.getBoundingClientRect().top,r=n?this.#t.get("currentViewportHeight"):t.getBoundingClientRect().bottom;let l=0;sr&&(l=i-r),0!==l&&(t.scrollBy({top:l,behavior:e}),s-=l,i-=l)}}resetRangeToTextNode(){let t=this.getRange();if(this.#vt(t)){if(!Pe.check.isWysiwygFrame(t.startContainer)||!Pe.check.isWysiwygFrame(t.endContainer))return!1;const e=t.commonAncestorContainer,s=e.children[t.startOffset],i=e.children[t.endOffset];if(!(t=this.setRange(s,0,i,s===i?0:1)))return!1}const e=t,s=e.collapsed;let i,n,o,r=e.startContainer,l=e.startOffset,a=e.endContainer,h=e.endOffset;if(this.#J.format.isLine(r))for(r.childNodes[l]?(r=r.childNodes[l]||r,l=0):(r=r.lastChild||r,l=r.textContent.length);1===r?.nodeType&&r.firstChild;)r=r.firstChild||r,l=0;if(this.#J.format.isLine(a)){for(a=a.childNodes[h]||a.lastChild||a;1===a?.nodeType&&a.lastChild;)a=a.lastChild;s?h=0:h>0&&(h=a.textContent.length)}if(i=Pe.check.isWysiwygFrame(r)?this.#X.get("wysiwyg").firstChild:r,n=l,Pe.check.isBreak(i)||1===i.nodeType&&i.childNodes.length>0){const t=Pe.check.isBreak(i);if(!t){const t=i;for(;i&&!Pe.check.isBreak(i)&&1===i.nodeType&&(o=i.childNodes,0!==o.length);)i=o[n>0?n-1:n]||!/FIGURE/i.test(o[0].nodeName)?o[0]:i.previousElementSibling||i.previousSibling||r,n=n>0?i.textContent.length:n;let e=this.#J.format.getLine(i,null);e===this.#J.format.getBlock(e,null)&&(i||=t,e=Pe.utils.createElement(Pe.query.getParentElement(i,Pe.check.isTableCell)?"DIV":this.#rt.get("defaultLine")),i.parentNode.insertBefore(e,i),i!==t&&e.appendChild(i))}if(Pe.check.isBreak(i)||this.#J.component.is(i)){const e=Pe.utils.createTextNode(Re.zeroWidthSpace);i.parentNode.insertBefore(e,i),i=e,t&&r===a&&(a=i,h=1)}}if(r=i,l=n,i=Pe.check.isWysiwygFrame(a)?this.#X.get("wysiwyg").lastChild:a,n=h,Pe.check.isBreak(i)||1===i.nodeType&&i.childNodes.length>0){const t=Pe.check.isBreak(i);if(!t){for(;i&&!Pe.check.isBreak(i)&&1===i.nodeType&&(o=i.childNodes,0!==o.length);)i=o[n>0?n-1:n]||!/FIGURE/i.test(o[0].nodeName)?o[0]:i.previousElementSibling||i.previousSibling||r,n=n>0?i.textContent.length:n;let t=this.#J.format.getLine(i,null);t===this.#J.format.getBlock(t,null)&&(t=Pe.utils.createElement(Pe.check.isTableCell(t)?"DIV":this.#rt.get("defaultLine")),i.parentNode.insertBefore(t,i),t.appendChild(i))}if(Pe.check.isBreak(i)){const e=Pe.utils.createTextNode(Re.zeroWidthSpace);i.parentNode.insertBefore(e,i),i=e,n=1,t&&!i.previousSibling&&Pe.utils.removeItem(a)}}return a=i,h=n,this.setRange(r,l,a,h),!0}init(){const t=this.#X.get("_wd").activeElement;if(Pe.check.isInputElement(t))return this.selectionNode=t,t;const e=this.get();if(!e)return null;let s=null;s=e.rangeCount>0?e.getRangeAt(0):this.#mt(),this.#ft(s,e)}#ft(t,e){let s=null;this.#t.set("_range",t),s=t.collapsed?Pe.check.isWysiwygFrame(t.commonAncestorContainer)&&t.commonAncestorContainer.children[t.startOffset]||t.commonAncestorContainer:e.anchorNode,this.selectionNode=s}#vt(t){const e=t.commonAncestorContainer;return Pe.check.isWysiwygFrame(t.startContainer)&&Pe.check.isWysiwygFrame(t.endContainer)||/FIGURE/i.test(e.nodeName)||this.#J.pluginManager.fileInfo.regExp.test(e.nodeName)&&(!this.#J.pluginManager.fileInfo.tagAttrs[e.nodeName]||this.#J.pluginManager.fileInfo.tagAttrs[e.nodeName]?.every((t=>e.hasAttribute(t))))||this.#J.component.is(e)}#mt(){const t=this.#X.get("wysiwyg"),e=this.#X.get("_wd").createRange();let s=t.firstElementChild,i=null;return s?(i=s.firstChild,i||(i=Pe.utils.createElement("BR"),s.appendChild(i))):(i=Pe.utils.createElement("BR"),s=Pe.utils.createElement(this.#rt.get("defaultLine"),null,i),t.appendChild(s)),e.setStart(i,0),e.setEnd(i,0),e}__focus(){try{this.__iframeFocus=!0;const t=Pe.query.getParentElement(this.getNode(),"figcaption");t?t.focus():this.#X.get("wysiwyg").focus()}finally{Ls.setTimeout((()=>this.__iframeFocus=!1),0)}}__init(){this.#gt=this.#H._eventOrchestrator.scrollparents?.length>0,this.#pt=this.#X?.get("wysiwyg")?(De.get(Ls.getComputedStyle(this.#X.get("wysiwyg")).scrollMargin,0)||40)+De.get(Ls.getComputedStyle(this.#X.get("wrapper")).paddingBottom,0):40}};function Os(t,e,s){const i=[];for(let n,o,r=0,l=t.length;r!0;t;){if(Pe.check.isWysiwygFrame(t))return null;if(this.isBlock(t)){if(this.isLine(t.firstElementChild))return t.firstElementChild;if(this.isLine(t))return t}if(this.isLine(t)&&e(t))return t;t=t.parentNode}return null}setBrLine(t){if(!this.isBrLine(t))throw new Error('[SUNEDITOR.format.setBrLine.fail] The "element" must satisfy "format.isBrLine()".');const e=this.#St().lines,s=e.length-1;let i=e[s].parentNode,n=t.cloneNode(!1);const o=n;for(let o,r,l,a,h,c,d=s,u=!0;d>=0;d--)if(o=e[d],o!==(e[d+1]?e[d+1].parentNode:null)){if(c=this.#J.component.is(o),r=c?"":o.innerHTML.replace(/(?!>)\s+(?=<)|\n/g," "),l=Pe.query.getParentElement(o,(t=>t.parentNode===i)),(i!==o.parentNode||c)&&(this.isLine(i)?(i.parentNode.insertBefore(n,i.nextSibling),i=i.parentNode):(i.insertBefore(n,l?l.nextSibling:null),i=o.parentNode),a=n.nextSibling,a&&n.nodeName===a.nodeName&&Pe.check.isSameAttributes(n,a)&&(n.innerHTML+="
    "+a.innerHTML,Pe.utils.removeItem(a)),n=t.cloneNode(!1),u=!0),h=n.innerHTML,n.innerHTML=(u||!r||!h||/
    $/i.test(r)?r:r+"
    ")+h,0===d){i.insertBefore(n,o),a=o.nextSibling,a&&n.nodeName===a.nodeName&&Pe.check.isSameAttributes(n,a)&&(n.innerHTML+="
    "+a.innerHTML,Pe.utils.removeItem(a));const t=n.previousSibling;t&&n.nodeName===t.nodeName&&Pe.check.isSameAttributes(n,t)&&(t.innerHTML+="
    "+n.innerHTML,Pe.utils.removeItem(n))}c||Pe.utils.removeItem(o),r&&(u=!1)}this.#J.selection.setRange(o,0,o,0),this.#J.history.push(!1)}getBrLine(t,e){if(!t)return null;for(e||=()=>!0;t;){if(Pe.check.isWysiwygFrame(t))return null;if(this.isBrLine(t)&&e(t))return t;t=t.parentNode}return null}addLine(t,e){if(!t||!t.parentNode)return null;const s=this.getLine(this.#J.selection.getNode(),null);let i=null;if(this.isBrLine(t)||!this.isBrLine(s||t.parentNode)||this.#J.component.is(t)){const t=e?"string"==typeof e?e:e.nodeName:this.isNormalLine(s)?s.nodeName:this.#rt.get("defaultLine");i=Pe.utils.createElement(t,null,"
    "),(e&&"string"!=typeof e||!e&&this.isLine(s))&&Pe.utils.copyTagAttributes(i,e||s,["id"])}else i=Pe.utils.createElement("BR");return Pe.check.isTableCell(t)?t.insertBefore(i,t.nextElementSibling):t.parentNode.insertBefore(i,t.nextElementSibling),i}addLineAfter(t){if(!t||!t.parentNode)return null;const e=t.nodeName,s=this.#rt.get("lineAttrReset");let i;return/^H[1-6]$/i.test(e)||this.#J.component.is(t)||this.isBrLine(t)?i=Pe.utils.createElement(this.#rt.get("defaultLine"),null,"
    "):(i=Pe.utils.createElement(e,null,"
    "),Pe.utils.copyTagAttributes(i,t,s)),Pe.check.isTableCell(t)?t.insertBefore(i,t.nextElementSibling):t.parentNode.insertBefore(i,t.nextElementSibling),i}getBlock(t,e){if(!t)return null;for(e||=()=>!0;t;){if(Pe.check.isWysiwygFrame(t))return null;if(this.isBlock(t)&&!/^(THEAD|TBODY|TR)$/i.test(t.nodeName)&&e(t))return t;t=t.parentNode}return null}applyBlock(t){this.#J.selection.getRangeAndAddLine(this.#J.selection.getRange(),null);const e=this.getLinesAndComponents(!1);if(!e||0===e.length)return;t:for(let t,s,i,n,o,r,l=0,a=e.length;l{let i=null;if(t!==e&&!Pe.check.isTableElements(e)){if(e&&Pe.query.getNodeDepth(t)===Pe.query.getNodeDepth(e))return s;i=this.#J.nodeTransform.removeAllParents(e,null,t)}return i?i.ec:s};for(let t,s,i,d,u,p,g,m=0,f=e.length;m=i?(l=i,o=f.cc,n=c(o,s,f.ec),n&&(o=n.parentNode)):o===f.cc&&(n=f.ec),o!==f.cc&&(d=c(o,f.cc,d),n=void 0!==d?d:f.cc);for(let t=0,e=f.removeArray.length;t=i&&(l=i,o=s,n=t.nextSibling),r.appendChild(t),o!==s&&(d=c(o,s),void 0!==d&&(n=d));if(this.#t.set("_lastSelectionNode",null),this.#J.nodeTransform.mergeSameTags(r,null,!1),this.#J.nodeTransform.mergeNestedTags(r,(t=>Pe.check.isList(t))),n&&Pe.query.getNodeDepth(n)>0&&(Pe.check.isList(n.parentNode)||Pe.check.isList(n.parentNode.parentNode))){const t=Pe.query.getParentElement(n,(t=>this.isBlock(t)&&!Pe.check.isList(t))),e=this.#J.nodeTransform.split(n,null,t?Pe.query.getNodeDepth(t)+1:0);e.parentNode.insertBefore(r,e)}else o.insertBefore(r,n),c(r,n);const d=Pe.query.getEdgeChildNodes(r.firstElementChild,r.lastElementChild);e.length>1?this.#J.selection.setRange(d.sc,0,d.ec,d.ec.textContent.length):this.#J.selection.setRange(d.ec,d.ec.textContent.length,d.ec,d.ec.textContent.length),this.#J.history.push(!1)}removeBlock(t,{selectedFormats:e,newBlockElement:s,shouldDelete:i,skipHistory:n}={}){const o=this.#J.selection.getRange();let r=o.startOffset,l=o.endOffset,a=Pe.query.getListChildNodes(t,null,1),h=t.parentNode,c=null,d=null,u=t.cloneNode(!1);const p=[],g=Pe.check.isList(s);let m=!1,f=!1,v=!1;const b=(e,s,i,n)=>{if(1===s.childNodes.length&&Pe.check.isZeroWidth(s)&&(s.innerHTML=Re.zeroWidthSpace,r=l=1),3===s.nodeType)return e.insertBefore(s,i),s;const o=(v?s:n).childNodes;let a=s.cloneNode(!1),h=null,c=null;for(;o[0];)c=o[0],!this._isNotTextNode(c)||Pe.check.isBreak(c)||Pe.check.isListCell(a)?a.appendChild(c):(a.childNodes.length>0&&(h||=a,e.insertBefore(a,i),a=s.cloneNode(!1)),e.insertBefore(c,i),h||=c);if(a.childNodes.length>0){if(Pe.check.isListCell(e)&&Pe.check.isListCell(a)&&Pe.check.isList(i))if(g){for(h=i;i;)a.appendChild(i),i=i.nextSibling;e.parentNode.insertBefore(a,e.nextElementSibling)}else{const e=n.nextElementSibling,s=this.#J.listFormat.removeNested(n,!1);if(t!==s||e!==n.nextElementSibling){const e=a.childNodes;for(;e[0];)n.appendChild(e[0]);t=s,f=!0}}else e.insertBefore(a,i);h||=a}return h};for(let n,o,r,l=0,y=a.length;l0&&(h.insertBefore(u,t),u=null),!g&&Pe.check.isListCell(n))if(r&&Pe.query.getNodeDepth(n)!==Pe.query.getNodeDepth(r)&&(Pe.check.isListCell(h)||Pe.utils.arrayFind(n.children,Pe.check.isList))){const e=n.nextElementSibling,s=this.#J.listFormat.removeNested(n,!1);t===s&&e===n.nextElementSibling||(t=s,f=!0)}else{const e=n;n=Pe.utils.createElement(i?e.nodeName:Pe.check.isList(t.parentNode)||Pe.check.isListCell(t.parentNode)?"LI":Pe.check.isTableCell(t.parentNode)?"DIV":this.#rt.get("defaultLine"));const s=Pe.check.isListCell(n),o=e.childNodes;for(;o[0]&&(!Pe.check.isList(o[0])||s);)n.appendChild(o[0]);Pe.utils.copyFormatAttributes(n,e),v=!0}else n=n.cloneNode(!1);if(!f&&(i?(p.push(n),Pe.utils.removeItem(a[l])):(s?(m||(h.insertBefore(s,t),m=!0),n=b(s,n,null,a[l])):n=b(h,n,t,a[l]),f||(e?(d=n,c||=n):c||(c=d=n))),f)){f=v=!1,a=Pe.query.getListChildNodes(t,null,1),u=t.cloneNode(!1),h=t.parentNode,l=-1,y=a.length;continue}}const y=t.parentNode;let w=t.nextSibling;u?.children.length>0&&y.insertBefore(u,w),s?c=s.previousSibling:c||=t.previousSibling,w=t.nextSibling!==u?t.nextSibling:u?u.nextSibling:null,0===t.children.length||0===t.textContent.length?Pe.utils.removeItem(t):this.#J.nodeTransform.removeEmptyNode(t,null,!1);let C=null;if(this.#t.set("_lastSelectionNode",null),i)C={cc:y,sc:c,so:r,ec:w,eo:l,removeArray:p};else{c||=d,d||=c;const t=Pe.query.getEdgeChildNodes(c,d?.parentNode?c:d);t?C={cc:(t.sc||t.ec).parentNode,sc:t.sc,so:r,ec:t.ec,eo:l,removeArray:null}:this.#J.focusManager.focus()}if(n)return C;!i&&C&&(e?this.#J.selection.setRange(C.sc,r,C.ec,l):this.#J.selection.setRange(C.sc,0,C.sc,0)),this.#J.history.push(!1)}indent(){const t=this.#J.selection.getRange(),e=t.startContainer,s=t.endContainer,i=t.startOffset,n=t.endOffset,o=Os(this.getLines(null),this.#t.get("indentSize"),this.#rt.get("_rtl")?"marginRight":"marginLeft");o.length>0&&this.#J.listFormat.applyNested(o,!1),this.#t.set("_lastSelectionNode",null),this.#J.selection.setRange(e,i,s,n),this.#J.history.push(!1)}outdent(){const t=this.#J.selection.getRange(),e=t.startContainer,s=t.endContainer,i=t.startOffset,n=t.endOffset,o=Os(this.getLines(null),-1*this.#t.get("indentSize"),this.#rt.get("_rtl")?"marginRight":"marginLeft");o.length>0&&this.#J.listFormat.applyNested(o,!0),this.#t.set("_lastSelectionNode",null),this.#J.selection.setRange(e,i,s,n),this.#J.history.push(!1)}isEdgeLine(t,e,s){if("front"===s){if(e>0)return!1}else if(t?.textContent?.length>e)return!1;let i=!1;const n="front"===s?"previousSibling":"nextSibling";for(;t&&!this.isLine(t)&&!Pe.check.isWysiwygFrame(t);){if(t[n]&&(!Pe.check.isBreak(t[n])||t[n][n]))return!1;i=!0,t=t.parentNode}return i}isTextStyleNode(t){return"string"==typeof t?this.#xt.test(t):1===t?.nodeType&&this.#xt.test(t.nodeName)}isLine(t){return"string"==typeof t?this.#yt.test(t):1===t?.nodeType&&(this.#yt.test(t.nodeName)||Pe.utils.hasClass(t,"__se__format__line_.+|__se__format__br_line_.+"))&&!this.#Et(t)}isNormalLine(t){return this.isLine(t)&&(this.#$t||!this.isBrLine(t))&&!this.isBlock(t)}isBrLine(t){return this.#$t&&this.isLine(t)||("string"==typeof t?this.#wt.test(t):1===t?.nodeType&&(this.#wt.test(t.nodeName)||Pe.utils.hasClass(t,"__se__format__br_line_.+"))&&!this.#Et(t))}isBlock(t){return"string"==typeof t?this.#Ct.test(t):1===t?.nodeType&&(this.#Ct.test(t.nodeName)||Pe.utils.hasClass(t,"__se__format__block_.+"))&&!this.#Et(t)}isClosureBlock(t){return"string"==typeof t?this.#_t.test(t):1===t?.nodeType&&(this.#_t.test(t.nodeName)||Pe.utils.hasClass(t,"__se__format__block_closure_.+"))&&!this.#Et(t)}isClosureBrLine(t){return"string"==typeof t?this.#kt.test(t):1===t?.nodeType&&(this.#kt.test(t.nodeName)||Pe.utils.hasClass(t,"__se__format__br_line__closure_.+"))&&!this.#Et(t)}getLines(t){if(!this.#J.selection.resetRangeToTextNode())return[];let e=this.#J.selection.getRange();if(Pe.check.isWysiwygFrame(e.startContainer)){const t=this.#X.get("wysiwyg").children,s=t.length;if(0===s)return[];this.#J.selection.setRange(t[0],0,t[s-1],t[s-1].textContent.trim().length),e=this.#J.selection.getRange()}const s=e.startContainer,i=e.endContainer,n=e.commonAncestorContainer;t||=this.isLine.bind(this);const o=Pe.query.getListChildren(n,(e=>t(e)),null);if(3!==n.nodeType&&(Pe.check.isWysiwygFrame(n)||this.isBlock(n))||o.unshift(this.getLine(n,null)),s===i||1===o.length)return o;const r=this.getLine(s,null),l=this.getLine(i,null);let a=null,h=null;const c=function(t){return!Pe.check.isTableElements(t)||/^TABLE$/i.test(t.nodeName)};let d=this.getBlock(r,c),u=this.getBlock(l,c);Pe.check.isTableElements(d)&&Pe.check.isListCell(d.parentNode)&&(d=d.parentNode),Pe.check.isTableElements(u)&&Pe.check.isListCell(u.parentNode)&&(u=u.parentNode);const p=d===u;for(let t,e=0,s=o.length;e{const e=Pe.query.getParentElement(t,this.#J.component.is.bind(this.#J.component));return this.isLine(t)&&(!e||e===s)||Pe.check.isComponentContainer(t)&&!this.getLine(t)}));if(t)for(let t=0,e=i.length;t=0;s--)if(i[s].contains(i[t])){i.splice(t,1),t--,e--;break}return i}_isNotTextNode(t){if(!t)return!1;const e=/^(br|input|select|canvas|img|iframe|audio|video)$/i;return"string"==typeof t?e.test(t):1===t.nodeType&&(this.#J.component.is(t)||e.test(t.nodeName))}_isExcludeSelectionElement(t){return!/FIGCAPTION/i.test(t.nodeName)&&(this.#J.component.is(t)||/FIGURE/i.test(t.nodeName))}#Et(t){return Pe.check.isExcludeFormat(t)||this.#J.component.is(t)||Pe.check.isWysiwygFrame(t)}#St(){let t=this.#J.selection.getRange(),e=this.getLinesAndComponents(!1);if(0===e.length&&(t=this.#J.selection.getRangeAndAddLine(t,null),e=this.getLinesAndComponents(!1),0===e.length))return;const s=t.startOffset,i=t.endOffset;let n=e[0],o=e.at(-1);const r=Pe.query.getNodePath(t.startContainer,n,null),l=Pe.query.getNodePath(t.endContainer,o,null),a=this.#J.listFormat.remove(e,!1);return a.sc&&(n=a.sc),a.ec&&(o=a.ec),this.#J.selection.setRange(Pe.query.getNodeFromPath(r,n),s,Pe.query.getNodeFromPath(l,o),i),{lines:this.getLinesAndComponents(!1),firstNode:n,lastNode:o,firstPath:r,lastPath:l,startOffset:s,endOffset:i}}__resetBrLineBreak(t){return this.#$t="br"===t}};function zs(t){const e=t.parentNode;if(!t||3===t.nodeType||!e)return;const s=t.childNodes;for(;s[0];)e.insertBefore(s[0],t);e.removeChild(t)}const Ps=class{#J;#rt;#Tt;#Mt;constructor(t){this.#J=t.$,this.#rt=this.#J.options,this.#Tt=this.#rt.get("__listCommonStyle"),this.#Mt=ze.camelToKebabCase(this.#rt.get("__listCommonStyle"))}apply(t,{stylesToModify:e,nodesToRemove:s,strictRemove:i}={}){if(Pe.query.getParentElement(this.#J.selection.getNode(),Pe.check.isNonEditable))return;this.#J.selection.resetRangeToTextNode();let n=this.#J.selection.getRangeAndAddLine(this.#J.selection.getRange(),null);e=e?.length>0?e:null,s=s?.length>0?s:null;const o=!t,r=o&&!s&&!e;let l=n.startContainer,a=n.startOffset,h=n.endContainer,c=n.endOffset;if(r&&n.collapsed&&this.#J.format.isLine(l.parentNode)&&this.#J.format.isLine(h.parentNode)||l===h&&1===l.nodeType&&Pe.check.isNonEditable(l)){const t=l.parentNode;if(!Pe.check.isListCell(t)||!ze.getValues(t.style).some((t=>this.#Mt.includes(t))))return}if(n.collapsed&&!r&&1===l.nodeType&&!Pe.check.isBreak(l)&&!this.#J.component.is(l)){let t=null;const e=l.childNodes[a];e&&(t=e.nextSibling?Pe.check.isBreak(e)?e:e.nextSibling:null);const s=Pe.utils.createTextNode(Re.zeroWidthSpace);l.insertBefore(s,t),this.#J.selection.setRange(s,1,s,1),n=this.#J.selection.getRange(),l=n.startContainer,a=n.startOffset,h=n.endContainer,c=n.endOffset}this.#J.format.isLine(l)&&(l=l.childNodes[a]||l.firstChild,a=0),this.#J.format.isLine(h)&&(h=h.childNodes[c]||h.lastChild,c=h.textContent.length),o&&(t=Pe.utils.createElement("DIV"));const d=RegExp,u=t.nodeName;if(!r&&l===h&&!s&&t){let e=l,s=0;const i=[],n=t.style;for(let t=0,e=n.length;t0){for(;!this.#J.format.isLine(e)&&!Pe.check.isWysiwygFrame(e);){for(let t=0;t=i.length)return}}let p,g,m={},f={},v="",b="";if(e){for(let t,s=0,i=e.length;s0&&(l=n.replace(v,"").trim(),l!==n&&(y.v=!0));const a=e.className;let h="";return b&&a.length>0&&(h=a.replace(b,"").trim(),h!==a&&(y.v=!0)),(!o||!b&&a||!v&&n||l||h||!s)&&(l||h||e.nodeName!==u||Boolean(v)!==Boolean(n)||Boolean(b)!==Boolean(a))?(v&&n.length>0&&(e.style.cssText=l),e.style.cssText||e.removeAttribute("style"),b&&a.length>0&&(e.className=h.trim()),e.className.trim()||e.removeAttribute("class"),e.style.cssText||e.className||e.nodeName!==u&&!s?e:(y.v=!0,null)):(y.v=!0,null)},C=this.#J.format.getLines(null);if(0===C.length)return void console.warn("[SUNEDITOR.inline.apply.warn] There is no line to apply.");n=this.#J.selection.getRange(),l=n.startContainer,a=n.startOffset,h=n.endContainer,c=n.endOffset,this.#J.format.getLine(l,null)||(l=Pe.query.getEdgeChild(C[0],(function(t){return 3===t.nodeType}),!1),a=0),this.#J.format.getLine(h,null)||(h=Pe.query.getEdgeChild(C.at(-1),(function(t){return 3===t.nodeType}),!1),c=h.textContent.length);const _=this.#J.format.getLine(l,null)===this.#J.format.getLine(h,null),k=C.length-(_?0:1);p=t.cloneNode(!1);const x=r||o&&(t=>{for(let e=0,s=t?.length;e0&&this.#Lt(C[k],e)&&(s=!0),this.#Lt(C[0],e)&&(s=!0),s&&this.#J.selection.setRange(l,a,h,c),k>0&&(p=t.cloneNode(!1),f=this.#Rt(C[k],p,w,h,c,r,o,y,S,E));for(let s,i=k-1;i>0;i--)this.#Lt(C[i],e),p=t.cloneNode(!1),s=this.#zt(C[i],p,w,r,o,y,f.container),s.endContainer&&s.ancestor.contains(s.endContainer)&&(f.ancestor=null,f.container=s.endContainer),this.#Ot(s.ancestor,null);p=t.cloneNode(!1),m=this.#Pt(C[0],p,w,l,a,r,o,y,S,E,f.container),m.endContainer&&(f.ancestor=null,f.container=m.endContainer),k<=0?f=m:f.container||(f.ancestor=null,f.container=m.container,f.offset=m.container.textContent.length),this.#Ot(m.ancestor,null),this.#Ot(f.ancestor||this.#J.format.getLine(f.container),null)}return this.#J.ui.offCurrentController(),this.#J.selection.setRange(m.container,m.offset,f.container,f.offset),this.#J.history.push(!1),p}remove(){this.apply(null,{stylesToModify:null,nodesToRemove:null,strictRemove:null})}_isNonSplitNode(t){if(!t)return!1;const e=/^(a|label|code|summary)$/i;return"string"==typeof t?e.test(t):1===t.nodeType&&e.test(t.nodeName)}_isIgnoreNodeChange(t){return t&&1===t.nodeType&&(Pe.check.isNonEditable(t)||!this.#J.format.isTextStyleNode(t)||this.#J.component.is(t))}#At(t,e,s,i,n,o,r,l,a,h,c,d,u){let p=i.parentNode;for(;!(p.nextSibling||p.previousSibling||this.#J.format.isLine(p.parentNode)||Pe.check.isWysiwygFrame(p.parentNode))&&p.nodeName!==e.nodeName;)p=p.parentNode;if(!a&&!l&&p===o.parentNode&&p.nodeName===e.nodeName&&Pe.check.isZeroWidth(i.textContent.slice(0,n))&&Pe.check.isZeroWidth(o.textContent.slice(r))){const s=p.childNodes;let l=!0;for(let t,e,n,r,a=0,h=s.length;a0&&(s=e.test(t.style.cssText)),!s}if(function t(i,n){const o=i.childNodes;for(let i,r=0,a=o.length;r=$?E-$:t.data.length-$)}const l=Pe.utils.createTextNode(o),h=Pe.utils.createTextNode(r);if(k){const e=d(n);if(e.parentNode!==t){let s=e,i=null;for(;s.parentNode!==t;){for(n=i=s.parentNode.cloneNode(!1);s.childNodes[0];)i.appendChild(s.childNodes[0]);s.appendChild(i),s=s.parentNode}s.parentNode.appendChild(e)}k=k.cloneNode(!1)}Pe.check.isZeroWidth(l)||n.appendChild(l);const c=d(n);for(c&&(k=c),k&&(t=k),w=a,y=[],_="";w!==t&&w!==m&&null!==w;)i=u(w)?null:s(w),i&&1===w.nodeType&&B(w)&&(y.push(i),_+=w.style.cssText.substring(0,w.style.cssText.indexOf(":"))+"|"),w=w.parentElement;const p=y.pop()||h;for(C=w=p;y.length>0;)w=y.pop(),C.appendChild(w),C=w;if(e.appendChild(p),t.appendChild(e),k&&!d(S)&&(e=e.cloneNode(!1),v.appendChild(e),f.push(e)),x=h,$=0,T=!0,w!==h&&w.appendChild(x),!b)continue}if(M||a!==S){if(T){if(1===a.nodeType&&!Pe.check.isBreak(a)){g._isIgnoreNodeChange(a)?(v.appendChild(a.cloneNode(!0)),h||(e=e.cloneNode(!1),v.appendChild(e),f.push(e))):t(a,a);continue}w=a,y=[],_="";const o=[];for(;null!==w.parentNode&&w!==m&&w!==e;)i=M?w.cloneNode(!1):s(w),1===w.nodeType&&!Pe.check.isBreak(a)&&i&&B(w)&&(u(w)?k||o.push(i):y.push(i),_+=w.style.cssText.substring(0,w.style.cssText.indexOf(":"))+"|"),w=w.parentElement;y=y.concat(o);const r=y.pop()||a;for(C=w=r;y.length>0;)w=y.pop(),C.appendChild(w),C=w;if(!u(e.parentNode)||u(r)||Pe.check.isZeroWidth(e)||(e=e.cloneNode(!1),v.appendChild(e),f.push(e)),M||k||!u(r))r===a?n=M?v:e:M?(v.appendChild(r),n=w):(e.appendChild(r),n=w);else{e=e.cloneNode(!1);const t=r.childNodes;for(let s=0,i=t.length;s0?w:e}if(k&&3===a.nodeType)if(d(a)){const t=Pe.query.getParentElement(n,(t=>g._isNonSplitNode(t.parentNode)||t.parentNode===v));k.appendChild(t),e=t.cloneNode(!1),f.push(e),v.appendChild(e)}else k=null}c=a.cloneNode(!1),n.appendChild(c),1!==a.nodeType||Pe.check.isBreak(a)||(p=c),t(a,p)}else{k=d(a);let t="",n="";if(3===S.nodeType){const e=S;t=e.substringData(E,e.length-E),n=b?"":e.substringData(0,E)}const o=Pe.utils.createTextNode(t),r=Pe.utils.createTextNode(n);if(k?k=k.cloneNode(!1):u(e.parentNode)&&!k&&(e=e.cloneNode(!1),v.appendChild(e),f.push(e)),!Pe.check.isZeroWidth(o)){w=a,_="",y=[];const t=[];for(;w!==v&&w!==m&&null!==w;)1===w.nodeType&&B(w)&&(u(w)?t.push(w.cloneNode(!1)):y.push(w.cloneNode(!1)),_+=w.style.cssText.substring(0,w.style.cssText.indexOf(":"))+"|"),w=w.parentElement;for(y=y.concat(t),c=C=w=y.pop()||o;y.length>0;)w=y.pop(),C.appendChild(w),C=w;v.appendChild(c),w.textContent=o.data}if(k&&c){const t=d(c);t&&(k=t)}for(w=a,y=[],_="";w!==v&&w!==m&&null!==w;)i=u(w)?null:s(w),i&&1===w.nodeType&&B(w)&&(y.push(i),_+=w.style.cssText.substring(0,w.style.cssText.indexOf(":"))+"|"),w=w.parentElement;const p=y.pop()||r;for(C=w=p;y.length>0;)w=y.pop(),C.appendChild(w),C=w;k?((e=e.cloneNode(!1)).appendChild(p),k.insertBefore(e,k.firstChild),v.appendChild(k),f.push(e),k=null):e.appendChild(p),S=r,E=r.data.length,M=!0,!l&&h&&(e=r,r.textContent=Re.zeroWidthSpace),w!==r&&w.appendChild(S)}}}(t,v),a&&!l&&!c.v)return{ancestor:t,startContainer:i,startOffset:n,endContainer:o,endOffset:r};if(l&&=a,l)for(let t=0;t0,w=f.pop()||d;for(b=v=w;f.length>0;)v=f.pop(),b.appendChild(v),b=v;if(h(e.parentNode)&&!h(w)&&(e=e.cloneNode(!1),m.appendChild(e),g.push(e)),!y&&h(w)){e=e.cloneNode(!1);const t=w.childNodes;for(let s=0,i=t.length;su._isNonSplitNode(t.parentNode)||t.parentNode===m));y.appendChild(t),e=t.cloneNode(!1),g.push(e),m.appendChild(e)}else y=null}if(_||d!==w)i=_?s(d):d.cloneNode(!1),i&&(n.appendChild(i),1!==d.nodeType||Pe.check.isBreak(d)||(k=i)),t(d,k);else{let t=m;y=a(d);let o="",r="";if(3===w.nodeType){const t=w;o=t.substringData(0,C),r=t.substringData(C,t.length-C)}const l=Pe.utils.createTextNode(o),h=Pe.utils.createTextNode(r);if(y){const e=a(n);if(e&&e.parentNode!==t){let s=e,i=null;for(;s.parentNode!==t;){for(n=i=s.parentNode.cloneNode(!1);s.childNodes[0];)i.appendChild(s.childNodes[0]);s.appendChild(i),s=s.parentNode}s.parentNode.appendChild(e)}y=y.cloneNode(!1)}Pe.check.isZeroWidth(l)||n.appendChild(l);const c=a(n);for(c&&(y=c),y&&(t=y),v=n,f=[];v!==t&&null!==v;)i=s(v),1===v.nodeType&&i&&f.push(i),v=v.parentNode;const u=f.pop()||n;for(b=v=u;f.length>0;)v=f.pop(),b.appendChild(v),b=v;u!==n?(e.appendChild(u),n=v):n=e,Pe.check.isBreak(d)&&e.appendChild(d.cloneNode(!1)),t.appendChild(e),w=h,C=0,_=!0,n.appendChild(w)}}}(t,m),r&&!o&&!l.v)return{ancestor:t,container:i,offset:n,endContainer:c};if(o&&=r,o)for(let t=0;t0&&h===c)return t.innerHTML=i.innerHTML,{ancestor:t,endContainer:s?Pe.query.getNodeFromPath(s,t):null}}o.v=!1;const l=this,a=t.cloneNode(!1),h=[e];let c=!0;if(function t(i,n){const o=i.childNodes;for(let i,d,u=0,p=o.length;u0&&(a.appendChild(e),e=e.cloneNode(!1)),d=p.cloneNode(!0),a.appendChild(d),a.appendChild(e),h.push(e),n=e,r&&p.contains(r)){const t=Pe.query.getNodePath(r,p);r=Pe.query.getNodeFromPath(t,d)}}}(t,e),c||n&&!i&&!o.v)return{ancestor:t,endContainer:r};if(a.appendChild(e),i&&n)for(let t=0;t0,c=m.pop()||l;for(v=f=c;m.length>0;)f=m.pop(),v.appendChild(f),v=f;if(h(e.parentNode)&&!h(c)&&(e=e.cloneNode(!1),g.insertBefore(e,g.firstChild),p.push(e)),!b&&h(c)){e=e.cloneNode(!1);const t=c.childNodes;for(let s=0,i=t.length;s0?f:e}else r?(e.insertBefore(c,e.firstChild),n=f):n=e;if(b&&3===l.nodeType)if(a(l)){const t=Pe.query.getParentElement(n,(t=>d._isNonSplitNode(t.parentNode)||t.parentNode===g));b.appendChild(t),e=t.cloneNode(!1),p.push(e),g.insertBefore(e,g.firstChild)}else b=null}if(C||l!==y)i=C?s(l):l.cloneNode(!1),i&&(n.insertBefore(i,n.firstChild),1!==l.nodeType||Pe.check.isBreak(l)||(c=i)),t(l,c);else{b=a(l);let t="",o="";if(3===y.nodeType){const e=y;t=e.substringData(w,e.length-w),o=e.substringData(0,w)}const r=Pe.utils.createTextNode(t),c=Pe.utils.createTextNode(o);if(b){b=b.cloneNode(!1);const t=a(n);if(t.parentNode!==g){let e=t,s=null;for(;e.parentNode!==g;){for(n=s=e.parentNode.cloneNode(!1);e.childNodes[0];)s.appendChild(e.childNodes[0]);e.appendChild(s),e=e.parentNode}e.parentNode.insertBefore(t,e.parentNode.firstChild)}b=b.cloneNode(!1)}else h(e.parentNode)&&!b&&(e=e.cloneNode(!1),g.appendChild(e),p.push(e));for(Pe.check.isZeroWidth(r)||n.insertBefore(r,n.firstChild),f=n,m=[];f!==g&&null!==f;)i=h(f)?null:s(f),i&&1===f.nodeType&&m.push(i),f=f.parentNode;const d=m.pop()||n;for(v=f=d;m.length>0;)f=m.pop(),v.appendChild(f),v=f;d!==n?(e.insertBefore(d,e.firstChild),n=f):n=e,Pe.check.isBreak(l)&&e.appendChild(l.cloneNode(!1)),b?(b.insertBefore(e,b.firstChild),g.insertBefore(b,g.firstChild),b=null):g.insertBefore(e,g.firstChild),y=c,w=c.data.length,C=!0,n.insertBefore(y,n.firstChild)}}}(t,g),r&&!o&&!l.v)return{ancestor:t,container:i,offset:n};if(o&&=r,o)for(let t=0;t!Pe.check.isBreak(t)));if(e=s[0],!Pe.check.isElement(e)||s.length>1)return;const i=e.style,n=t.style,o=e.nodeName.toLowerCase();let r=!1;this.#rt.get("_defaultStyleTagMap")[o]===this.#rt.get("_defaultTagCommand").bold.toLowerCase()&&(n.fontWeight="bold"),this.#rt.get("_defaultStyleTagMap")[o]===this.#rt.get("_defaultTagCommand").italic.toLowerCase()&&(n.fontStyle="italic");const l=ze.getValues(i);if(l.length>0)for(let t=0,e=this.#Tt.length;t0;)s.insertBefore(t[0],i);Pe.utils.removeItem(e)}}#Lt(t,e){if(!Pe.check.isListCell(t))return;e||=this.#Mt;const s=Pe.utils.arrayFilter(t.childNodes,(t=>!Pe.check.isBreak(t))),i=t.style,n=[],o=[],r=ze.getValues(i);for(let t=0,s=this.#Mt.length;t0&&(t.insertBefore(a,h),a=l.cloneNode(!1),h=null,c=!0));return a.childNodes.length>0&&(t.insertBefore(a,h),c=!0),0===i.length&&t.removeAttribute("style"),c}};function Ds(t){const e=t.parentNode;let s,i,n,o,r,l=e.parentNode,a=e;for(;Pe.check.isListCell(l);){for(o=Pe.query.getPositionIndex(t),s=l.nextElementSibling,i=l.parentNode,n=a;n;){if(a=a.nextSibling,Pe.check.isList(n)){for(r=n.childNodes;r[o];)i.insertBefore(r[o],s);0===r.length&&Pe.utils.removeItem(n)}else i.appendChild(n);n=a}l=i.parentNode}return 0===e.children.length&&Pe.utils.removeItem(e),i}const Fs=class{#J;#t;constructor(t){this.#J=t.$,this.#t=t.store}apply(t,e,s){const i=(t.split(":")[0]||"ol").toUpperCase(),n=t.split(":")[1]||"";let o=this.#J.selection.getRange(),r=e||this.#J.format.getLinesAndComponents(!1);if(0===r.length){if(e)return;if(o=this.#J.selection.getRangeAndAddLine(o,null),r=this.#J.format.getLinesAndComponents(!1),0===r.length)return}Pe.query.sortNodeByDepth(r,!0);const l=r[0],a=r.at(-1);let h=!Pe.check.isListCell(l)&&!this.#J.component.is(l)||l.previousElementSibling?l.previousElementSibling:l.parentElement.previousElementSibling,c=!Pe.check.isListCell(a)&&!this.#J.component.is(a)||a.nextElementSibling?a.nextElementSibling:a.parentElement.nextElementSibling;const d=o.collapsed,u={sc:o.startContainer,so:o.startContainer===o.endContainer&&Pe.check.isZeroWidth(o.startContainer)&&0===o.startOffset&&1===o.endOffset?o.endOffset:o.startOffset,ec:o.endContainer,eo:o.endOffset};let p=null,g=!0;for(let t=0,e=r.length;tthis.#J.format.getBlock(e)&&e!==r[t])))){g=!1;break}if(!g||h&&l.tagName===h.tagName&&i===h.tagName.toUpperCase()||c&&a.tagName===c.tagName&&i===c.tagName.toUpperCase()){const t=h?h.parentNode:h,e=c?c.parentNode:c;h=t&&!Pe.check.isWysiwygFrame(t)&&t.nodeName===i?t:h,c=e&&!Pe.check.isWysiwygFrame(e)&&e.nodeName===i?e:c;const s=h?.tagName===i,o=c?.tagName===i;let l=s?h:Pe.utils.createElement(i,{style:"list-style-type: "+n}),a=null,d=null;const u=t=>!Pe.check.isComponentContainer(t)&&!Pe.check.isList(t);for(let t,e,o,h,c,p,g,m,f,v=0,b=r.length;v"),t.innerHTML+=e.outerHTML,s&&(t.innerHTML+="
    ")}else{Pe.utils.copyFormatAttributes(t,e);const s=e.childNodes;for(;s[0];)t.appendChild(s[0])}l.appendChild(t),h&&g===p&&!this.#J.format.isBlock(m)||(a||=l,s&&h&&g===p||h&&Pe.check.isList(p)&&p===c||l.parentNode!==g&&g.insertBefore(l,m)),Pe.utils.removeItem(e),s&&null===d&&(d=l.children.length-1),h&&(this.#J.format.getBlock(p,u)!==this.#J.format.getBlock(c,u)||Pe.check.isList(p)&&Pe.check.isList(c)&&Pe.query.getNodeDepth(p)!==Pe.query.getNodeDepth(c))&&(l=Pe.utils.createElement(i,{style:"list-style-type: "+n})),0===f?.children.length&&Pe.utils.removeItem(f)}else Pe.utils.removeItem(e);d&&(a=a.children[d]),o&&(l.innerHTML+=c.innerHTML,Pe.utils.removeItem(c))}else{if(s)for(let t=0,e=r.length;t=0;s--)if(r[s].contains(r[t])){r.splice(t,1),t--,e--;break}const t=this.#J.format.getBlock(l),e=t?.tagName===i;let o,a;const h=t=>!Pe.check.isComponentContainer(t);e||(a=Pe.utils.createElement(i,{style:"list-style-type: "+n}));for(let t,l,c=0,d=r.length;c!Pe.check.isComponentContainer(t);for(let a,h,c,d,u=0,p=t.length;u1){const t=Pe.query.getNodeFromPath(a.s,a.sl),e=Pe.query.getNodeFromPath(a.e,a.el);o={sc:t,so:0,ec:e,eo:e.textContent.length}}else o={sc:h,so:c,ec:d,eo:u}}return o}removeNested(t,e){const s=Ds(t);let i,n,o;if(s){i=s.cloneNode(!1),n=s.childNodes;const e=Pe.query.getPositionIndex(t);for(;n[e];)i.appendChild(n[e])}else i=t;if(e)o=Pe.query.getListChildren(i,(t=>Pe.check.isListCell(t)&&!t.previousElementSibling),null);else{const e=Pe.query.getNodeDepth(t)+2;o=Pe.query.getListChildren(t,(t=>Pe.check.isListCell(t)&&!t.previousElementSibling&&Pe.query.getNodeDepth(t)===e),null)}for(let t=0,e=o.length;t0){const t=n.cloneNode(!1),e=n.childNodes,o=Pe.query.getPositionIndex(i);for(;e[o];)t.appendChild(e[o]);s.appendChild(t)}0===n.children.length&&Pe.utils.removeItem(n),this.#J.nodeTransform.mergeSameTags(r);const l=Pe.query.getEdgeChildNodes(e,s);return{cc:e.parentNode,sc:l.sc,ec:l.ec}}},{_d:Hs}=Oe,qs=new RegExp(Re.zeroWidthSpace+"+","g");const Ws=/^<[a-z0-9]+:[a-z0-9]+/i,Us=/(?!<)[a-zA-Z0-9-]+/,Vs=/\s(?:on[a-z]+)\s*=\s*(?:(["'])[^"']*\1|\S+)/gi,js=/style=/i,Gs=/style\s*=\s*(?:"|')[^"']*(?:"|')/,Ks=/class\s*=\s*("|')(?:[^"']*\s)?se-component(?=[\s"'])/i,Ys=/^\s/,Xs=/<[^\s]+\s(.+)/,Zs=/^[ \t\n\r\f\v]+$/,Js=/\ssize="([^"]+)"/i,Qs=/\sface="([^"]+)"/i,ti=/\scolor="([^"]+)"/i,ei=/"/g,si=/([a-zA-Z0-9-]+)(:)([^"']+)/,ii=/inherit|initial|revert|unset/i,ni=/"/g,oi=/:\s*([^;]+)/,ri=/rgba\(([0-9]+\s*,\s*){3}0\)|windowtext/i,li=/[^;]+;/g,ai=/^span$/i,hi=/^(?:https?|ftps?|mailto|tel|blob|sms|geo|webcal|callto):|^[#/]|^data:image\//i,ci=/^(?:href|src)\s*=/i,di=/=\s*(?:"([^"]*)"|'([^']*)'|(\S+))/,ui=/:/i;function pi(t){const e=function(t){let e,s=5;do{e=t,t=t.replace(/&(#x([0-9a-f]+)|#([0-9]+)|([a-z]+));/gi,((t,e,s,i)=>s?String.fromCharCode(parseInt(s,16)):i?String.fromCharCode(parseInt(i,10)):""))}while(t!==e&&--s);try{t=decodeURIComponent(t)}catch{}return t.replace(/[\u0000-\u0020]+/g,"")}(t);return hi.test(e)||!ui.test(e)}function gi(t){if(!ci.test(t))return!0;const e=t.match(di);if(!e)return!0;return pi(e[1]??e[2]??e[3]??"")}function mi(t,e){return t?"*"===t?"[a-z-]+":e?t+"|"+e:t:"^"}const fi=class{#J;#t;#X;#Q;#rt;#ut;#Ht;#qt;#Wt;#Ut;#Vt;#jt;#Gt;#Kt;#Yt;#Xt;#Zt;#Jt;#Qt;#te;#ee;#se;#ie;#ne;#oe;#re;constructor(t){this.#J=t.$,this.#t=t.store;const e=this.#rt=this.#J.options;this.#Q=this.#J.frameOptions,this.#X=this.#J.frameContext,this.#ut=this.#J.instanceCheck,this.#qt=function(t){return this.test(t)?t:""}.bind(e.get("allowedClassName")),this.#Qt=e.get("_textStyleTags");const s=e.get("tagStyles"),i={};for(const t in s){const e=t.split("|");for(let n,o=0,r=e.length;o]*>([\\s\\S]*?)<\\/\\1>|<(${l})[^>]*\\/?>`,"gi"),this.#ee=new RegExp(`^(${l})$`,"i"),this.#se=new RegExp(`^(${r})$`,"i"),this.#ie=new RegExp(`<${e.get("defaultLine")}(?:\\s[^>]*)?>`,"i");const a=Object.keys(e.get("_defaultStyleTagMap")),h=e.get("elementWhitelist")?e.get("elementWhitelist").split("|").filter((t=>/b|i|ins|s|strike/i.test(t))):[];for(let t=0;t^<]+)?\\s*(?=>)","gi");const c=e.get("__defaultAttributeWhitelist");this.#Wt=e.get("_editorElementWhitelist").includes("//")||"*"===e.get("_editorElementWhitelist"),this.#Vt=new RegExp("^("+mi(e.get("_editorElementWhitelist").replace("|//",""),"")+")$","i"),this.#jt=new RegExp("^("+(e.get("elementBlacklist")||"^")+")$","i"),this.#Gt=ze.createElementWhitelist(mi(e.get("_editorElementWhitelist").replace("|//","|\x3c!--|--\x3e"),"")),this.#Kt=ze.createElementBlacklist(e.get("elementBlacklist").replace("|//","|\x3c!--|--\x3e"));const d='\\s*=\\s*(")[^"]*\\1',u=e.get("attributeWhitelist");let p={},g="";if(u)for(const t in u)/^on[a-z]+$/i.test(u[t])||("*"===t?g=mi(u[t],c):p[t]=new RegExp("\\s(?:"+mi(u[t],c)+")"+d,"ig"));this.#Yt=new RegExp("\\s(?:"+(g||c)+"|data-se-[^\\s]+"+(e.get("v2Migration")?"|data-index|data-file-size|data-file-name|data-exp|data-font-size":"")+")"+d,"ig"),this.#ne=p;const m=e.get("attributeBlacklist");if(p={},g="",m)for(const t in m)"*"===t?g=mi(m[t],""):p[t]=new RegExp("\\s(?:"+mi(m[t],"")+")"+d,"ig");this.#Xt=new RegExp("\\s(?:"+(g||"^")+")"+d,"ig"),this.#oe=p,this.__resetAutoStyleify(e.get("autoStyleify"))}filter(t,{tagWhitelist:e,tagBlacklist:s,validate:i,validateAll:n}){if(e&&(t=t.replace(ze.createElementWhitelist(e),"")),s&&(t=t.replace(ze.createElementBlacklist(s),"")),i){const e=(new DOMParser).parseFromString(t,"text/html");e.body.querySelectorAll("*").forEach((t=>{if(n||!t.closest(".se-component")&&!t.closest(".se-flex-component")){const e=i(t);null===e?t.remove():this.#ut.isNode(e)?t.replaceWith(e):"string"==typeof e&&(t.outerHTML=e)}})),t=e.body.innerHTML}return t}clean(t,{forceFormat:e,whitelist:s,blacklist:i,_freeCodeViewMode:n}={}){const{tagFilter:o,formatFilter:r,classFilter:l,textStyleTagFilter:a,attrFilter:h,styleFilter:c}=this.#rt.get("strictMode");let d="";if(t=this.compress(t),o&&(t=t.replace(this.#te,""),t=this.#le(t,this.#Gt,this.#Kt).replace(/$/i,"")),this.#re){const e=(new DOMParser).parseFromString(t,"text/html");Pe.query.getListChildNodes(e.body,ze.spanToStyleNode.bind(null,this.#re),null),t=e.body.innerHTML}(h||c)&&(t=t.replace(/(<[a-zA-Z0-9-]+)[^>]*(?=>)/g,this.#ae.bind(this,h,c)));const u=Hs.createRange().createContextualFragment(t);if(o)try{this.#he(u,this.#Vt,this.#jt,o,r,l,n)}catch(t){console.warn("[SUNEDITOR.html.clean.fail]",t.message)}const p=u.querySelectorAll("[data-se-iframe-holder]");for(let t=0,e=p.length;t{const i=0===e||">"===s[e-1],n=e+t.length===s.length||"<"===s[e+t.length];return i&&n?t:""}))),r&&!n&&(d=this.#ge(d)),d}insert(t,{selectInserted:e,skipCharCount:s,skipCleaning:i}={}){this.#X.get("wysiwyg").contains(this.#J.selection.get().focusNode)||this.#J.focusManager.focus(),this.remove(),this.#J.focusManager.focus();let n=null;if("string"==typeof t){i||(t=this.clean(t,{forceFormat:!1,whitelist:null,blacklist:null}));try{if(Pe.check.isListCell(this.#J.format.getLine(this.#J.selection.getNode(),null))){const e=Hs.createRange().createContextualFragment(t).childNodes;this.#ce(e)&&(t=this.#me(e))}const i=Hs.createRange().createContextualFragment(t).childNodes;if(!s){const t="byte-html"===this.#Q.get("charCounter_type")?"outerHTML":"textContent";let e="";for(let s=0,n=i.length;s0){n=t.at(-1);const e=3===n?.nodeType?n.textContent.length:1;this.#J.selection.setRange(n,e,n,e)}else this.#J.focusManager.focus()}else this.#J.focusManager.focus();this.#J.history.push(!1)}insertNode(t,{afterNode:e,skipCharCount:s}={}){let i=null;if(this.#X.get("isReadOnly")||!s&&!this.#J.char.check(t))return i;let n=null,o=null;if(e){const t=this.#J.format.isLine(e)||this.#J.format.isBlock(e)||this.#J.component.is(e)?this.#J.format.addLine(e,null):e;o=this.#J.selection.setRange(t,1,t,1)}else o=this.#J.selection.getRange();let r,l,a,h=Pe.check.isListCell(o.commonAncestorContainer)?o.commonAncestorContainer:this.#J.format.getLine(this.#J.selection.getNode(),null),c=Pe.check.isListCell(h)&&(Pe.check.isListCell(t)||Pe.check.isList(t)),d=null;const u=this.#J.format.isBrLine(h),p=this.#J.format.isLine(t)||this.#J.format.isBlock(t)||this.#J.component.isBasic(t);if(c&&(a=e||Pe.check.isList(t)?h.lastChild:h.nextElementSibling,d=Pe.check.isList(t)?h:(a||h).parentNode),!e&&(p||this.#J.component.isBasic(t)||Pe.check.isMedia(t))){const t=Pe.check.isEdgePoint(o.endContainer,o.endOffset,"end"),s=this.remove(),i=s.container,n=i===s.prevContainer&&o.collapsed?null:s.prevContainer;if(c&&n)if(d=3===n.nodeType?n.parentNode:n,d.contains(i)){let t=!0;for(a=i;a.parentNode&&a.parentNode!==d;)a=a.parentNode,t=!1;t&&i===n&&(a=a.nextSibling)}else a=null;else if(c&&Pe.check.isListCell(i)&&!h.parentElement)h=Pe.utils.createElement("LI"),d.appendChild(h),i.appendChild(d),a=null;else if(3===i.nodeType||Pe.check.isBreak(i)||c){const n=Pe.query.getParentElement(i,(t=>this.#J.format.isBlock(t)||Pe.check.isListCell(t)));if(e=this.#J.nodeTransform.split(i,s.offset,n?Pe.query.getNodeDepth(n)+1:0))if(c){if(h.contains(i)){const s=Pe.check.isList(h.lastElementChild);let i=null;t||(i=h.cloneNode(!1),i.appendChild(e.textContent.trim()?e:Pe.utils.createTextNode(Re.zeroWidthSpace))),s&&(i||(i=h.cloneNode(!1),i.appendChild(Pe.utils.createTextNode(Re.zeroWidthSpace))),i.appendChild(h.lastElementChild)),i&&(h.parentNode.insertBefore(i,h.nextElementSibling),a=e=i)}}else e=e.previousSibling;else Pe.check.isListCell(h)||(a=e=h)}}o=e||p?this.#J.selection.getRange():this.#J.selection.getRangeAndAddLine(this.#J.selection.getRange(),null);const g=o.commonAncestorContainer,m=o.startOffset,f=o.endOffset,v=o.startContainer===g&&this.#J.format.isLine(g),b=v&&(g.childNodes[m]||g.childNodes[0])||o.startContainer,y=v&&(g.childNodes[f]||g.childNodes[g.childNodes.length-1])||o.endContainer;if(!c)if(e)r=e.parentNode,e=e.nextSibling,l=!0;else if(r=b,3===b.nodeType&&(r=b.parentNode),o.collapsed)if(3===g.nodeType)e=g.textContent.length>f?g.splitText(f):g.nextSibling;else if(Pe.check.isBreak(r))e=r,r=r.parentNode;else{const s=r.childNodes[m],i=3===s?.nodeType&&Pe.check.isZeroWidth(s)&&Pe.check.isBreak(s.nextSibling)?s.nextSibling:s;i?!i.nextSibling&&Pe.check.isBreak(i)?(r.removeChild(i),e=null):e=Pe.check.isBreak(i)&&!Pe.check.isBreak(t)?i:i.nextSibling:e=null}else{if(b===y){e=Pe.check.isEdgePoint(y,f)?y.nextSibling:y.splitText(f);let t=b;Pe.check.isEdgePoint(b,m)||(t=b.splitText(m)),r.removeChild(t),0===r.childNodes.length&&p&&(r.innerHTML="
    ")}else{const s=this.remove(),i=s.container,n=s.prevContainer;if(0===i?.childNodes.length&&p&&(this.#J.format.isLine(i)?i.innerHTML="
    ":this.#J.format.isBlock(i)&&(i.innerHTML="<"+this.#rt.get("defaultLine")+">
    ")),Pe.check.isListCell(i)&&3===t.nodeType)r=i,e=null;else if(!p&&n)if(r=3===n.nodeType?n.parentNode:n,r.contains(i)){let t=!0;for(e=i;e.parentNode&&e.parentNode!==r;)e=e.parentNode,t=!1;t&&i===n&&(e=e.nextSibling)}else e=null;else Pe.check.isWysiwygFrame(i)&&!this.#J.format.isLine(t)?(r=i.appendChild(Pe.utils.createElement(this.#rt.get("defaultLine"))),e=null):r=(e=p?y:i===n?i.nextSibling:i)&&e.parentNode?e.parentNode:g;for(;e&&!this.#J.format.isLine(e)&&e.parentNode!==g;)e=e.parentNode}}try{const s=this.#X.get("wysiwyg");if(!c){if((Pe.check.isWysiwygFrame(e)||r===s.parentNode)&&(r=s,e=null),this.#J.format.isLine(t)||this.#J.format.isBlock(t)||!Pe.check.isListCell(r)&&this.#J.component.isBasic(t)){const t=r;if(Pe.check.isListCell(e))r=e.previousElementSibling||e;else if(!l&&!e){const t=this.remove(),s=3===t.container.nodeType?Pe.check.isListCell(this.#J.format.getLine(t.container,null))?t.container:this.#J.format.getLine(t.container,null)||t.container.parentNode:t.container,i=Pe.check.isWysiwygFrame(s)||this.#J.format.isBlock(s);r=i?s:s.parentNode,e=i?null:s.nextSibling}0===t.childNodes.length&&r!==t&&Pe.utils.removeItem(t)}if(!p||u||this.#J.format.isBlock(r)||Pe.check.isListCell(r)||Pe.check.isWysiwygFrame(r)||(e=r.nextElementSibling,r=r.parentNode),Pe.check.isWysiwygFrame(r)&&(3===t.nodeType||Pe.check.isBreak(t))){const e=Pe.utils.createElement(this.#rt.get("defaultLine"),null,t);n=t,t=e}}if(c?d.parentNode?(r=d,e=a):(r=s,e=null):e=r===e?r.lastChild:e,Pe.check.isListCell(t)&&!Pe.check.isList(r)){if(Pe.check.isListCell(r))e=r.nextElementSibling,r=r.parentNode;else{const t=Pe.utils.createElement("ol");r.insertBefore(t,e),r=t,e=null}c=!0}if(this.#fe(t,r),r.insertBefore(t,e),c)if(Pe.check.isZeroWidth(h.textContent.trim()))Pe.utils.removeItem(h),t=t.lastChild;else{const e=Pe.utils.arrayFind(h.children,Pe.check.isList);e&&(t!==e?(t.appendChild(e),t=e.previousSibling):(r.appendChild(t),t=r),Pe.check.isZeroWidth(h.textContent.trim())&&Pe.utils.removeItem(h))}}catch(e){r.appendChild(t),console.warn("[SUNEDITOR.html.insertNode.warn]",e)}finally{n&&(t=n);const e=r.querySelectorAll("[data-duple]");if(e.length>0)for(let s,i,n,o,r=0,l=e.length;r0&&f>-1&&v>-1){for(let t=f+1,e=a;t>=0;t--)m[t]===e.parentNode&&m[t].firstChild===e&&0===c&&(f=t,e=e.parentNode);for(let t=v-1,e=h;t>f;t--)m[t]===e.parentNode&&1===m[t].nodeType&&(m.splice(t,1),e=e.parentNode,--v)}else{if(0===m.length){if(this.#J.format.isLine(u)||this.#J.format.isBlock(u)||Pe.check.isWysiwygFrame(u)||Pe.check.isBreak(u)||Pe.check.isMedia(u))return{container:u,offset:0,commonCon:u};if(Pe.check.isText(u))return{container:u,offset:d,commonCon:u};m.push(u),a=h=u}else if(a=h=m[0],Pe.check.isBreak(a)||Pe.check.isZeroWidth(a))return{container:Pe.check.isMedia(u)?u:a,offset:0,commonCon:u};f=v=0}const b=Pe.check.isText,y=Pe.check.isElement,w=f===v;let C=null;for(let t=f;t<=v;t++){const e=m[t];if(!b(e)||void 0!==e.data&&0!==e.length)if(e!==a)if(e!==h)C=this.#be(e,w);else{if(b(h))g=Pe.utils.createTextNode(h.substringData(d,h.length-d));else{if(this.#J.component.is(h))continue;g=Pe.utils.createTextNode(h.textContent)}g.length>0?h.data=g.data:C=this.#be(h,w)}else{if(y(a)){if(this.#J.component.is(a))continue;p=Pe.utils.createTextNode(a.textContent)}else{const t=a,s=h;e===h?(p=Pe.utils.createTextNode(t.substringData(0,c)+s.substringData(d,s.length-d)),l=c):p=Pe.utils.createTextNode(t.substringData(0,c))}if(p.length>0?a.data=p.data:C=this.#be(a,w),e===h)break}else C=this.#be(e,w)}const _=Pe.query.getParentElement(h,"ul"),k=Pe.query.getParentElement(a,"li");if(_&&k&&k.contains(_)?(r=_.previousSibling,l=r.textContent.length):(r=h&&h.parentNode?h:a&&a.parentNode?a:t.endContainer||t.startContainer,(e||s)&&(s?1===r.nodeType&&0===r.childNodes.length?(r.appendChild(Pe.utils.createElement("BR")),l=1):l=r.textContent.length:l=0)),this.#J.format.getLine(r)||a&&a.parentNode||(o?(r=o,l=0):n&&(r=n,l=1)),!Pe.check.isWysiwygFrame(r)&&0===r.childNodes.length){const t=this.#J.nodeTransform.removeAllParents(r,null,null);t&&(r=t.sc||t.ec||this.#X.get("wysiwyg"))}return r&&(1!==r.nodeType||this.#J.format.isLine(r)||Pe.check.isBreak(r))||(r=C?.sc||C?.ec,l=3===r?.nodeType?r.textContent.length:1),this.#J.selection.setRange(r,l,r,l),{container:r,offset:l,prevContainer:i,commonCon:u?.parentElement?u:null}}get({withFrame:t,includeFullPage:e,rootKey:s}={}){s?Array.isArray(s)||(s=[s]):s=[this.#t.get("rootKey")];const i=this.#t.get("rootKey"),n={};for(let i,o=0,r=s.length;o{t.hasAttribute("contenteditable")&&c.push(t);const e=t.parentElement;return a(e)&&e.children.length<=1&&h(t)&&d.push(e),!1}),null);for(let t=0,e=c.length;t";this.#ye(r);const u=r.innerHTML;if(this.#Q.get("iframe_fullPage"))if(e){const t=Pe.utils.getAttributesToString(this.#X.get("_wd").body,["contenteditable"]);i=`${this.#X.get("_wd").head.outerHTML}${u}`}else i=u;else i=t?`
    ${u}
    `:r.innerHTML;n[s[o]]=i}return this.#J.facade.changeFrameContext(i),s.length>1?n:n[s[0]]}set(t,{rootKey:e}={}){this.#J.ui.offCurrentController(),this.#J.selection.removeRange();const s=null==t?"":this.clean(t,{forceFormat:!0,whitelist:null,blacklist:null});e?Array.isArray(e)||(e=[e]):e=[this.#t.get("rootKey")];for(let t=0;t\s+ <").replace(/\n/g,"").trim()}_convertToCode(t,e){let s="";const i=RegExp,n=new i("^(BLOCKQUOTE|PRE|TABLE|THEAD|TBODY|TR|TH|TD|OL|UL|IMG|IFRAME|VIDEO|AUDIO|FIGURE|FIGCAPTION|HR|BR|CANVAS|SELECT)$","i"),o="string"==typeof t?Hs.createRange().createContextualFragment(t):t,r=t=>this.#J.format.isLine(t)||this.#J.component.is(t),l=e?"":"\n",a=e?0:1*this.#t.get("codeIndentSize"),h=a>0?new Array(a+1).join(" "):"";return function t(e,o){const a=e?.childNodes;if(!a)return;const c=n.test(e.nodeName),d=c?o:"";for(let u,p,g,m,f,v,b=0,y=a.length;b]*>","i"))[0]+p,t(u,o+h+""),s+=(/\n$/.test(s)?v:"")+""+(g||p||c||/^(TH|TD)$/i.test(u.nodeName)?l:"")):s+=(new XMLSerializer).serializeToString(u):s+=(/^HR$/i.test(u.nodeName)?l:"")+(/^PRE$/i.test(u.parentElement.nodeName)&&/^BR$/i.test(u.nodeName)?"":d)+u.outerHTML+p:Pe.check.isList(u.parentElement)||(s+=ze.htmlToEntity(/^\n+$/.test(u.data)?"":u.data)):s+="\n\x3c!-- "+u.textContent.trim()+" --\x3e"+p}(o,""),s.trim()+l}#be(t,e){const s=this.#J.format.getLine(t,null);if(Pe.utils.removeItem(t),!Pe.check.isListCell(s)||e)return;const i=this.#J.nodeTransform.removeAllParents(s,null,null);return Pe.check.isList(s?.firstChild)&&s.insertBefore(Pe.utils.createTextNode(Re.zeroWidthSpace),s.firstChild),i?{sc:i.sc,ec:i.ec}:null}#ve(t){const e=t.parentNode;let s,i;for(;this.#J.format.isLine(t)||this.#J.format.isBlock(t);){for(s=t.childNodes,i=null;s[0];)if(i=s[0],this.#J.format.isLine(i)||this.#J.format.isBlock(i)){if(this.#ve(i),!t.parentNode)break;s=t.childNodes}else e.insertBefore(i,t);0===t.childNodes.length&&Pe.utils.removeItem(t),t=Pe.utils.createElement("BR"),e.insertBefore(t,i.nextSibling)}return t}#ue(t,e){const s=this.#rt.get("defaultLine");if(1===t.nodeType){if(this.#ee.test(t.nodeName))return"";if(Pe.check.isExcludeFormat(t))return t.outerHTML;const i=Pe.query.getListChildNodes(t,(t=>Pe.check.isSpanWithoutAttr(t)&&!Pe.query.getParentElement(t,Pe.check.isExcludeFormat)),null)||[];for(let t,e=i.length-1;e>=0;e--)t=i[e],t.replaceWith(...t.childNodes);if(!e||this.#J.format.isLine(t)||this.#J.format.isBlock(t)||this.#J.component.is(t)||Pe.check.isMedia(t)||Pe.check.isFigure(t)||Pe.check.isAnchor(t)&&Pe.check.isMedia(t.firstElementChild)){const e=t;return Pe.check.isSpanWithoutAttr(t)?e.innerHTML:e.outerHTML}{const e=t;return"<"+s+">"+(Pe.check.isSpanWithoutAttr(t)?e.innerHTML:e.outerHTML)+""}}if(3===t.nodeType){if(!e)return ze.htmlToEntity(t.textContent);const i=t.textContent.split(/\n/g);let n="";for(let t,e=0,o=i.length;e0&&(n+="<"+s+">"+ze.htmlToEntity(t)+"");return n}return 8===t.nodeType&&this.#Wt?"\x3c!--"+t.textContent.trim()+"--\x3e":""}#ge(t){if(!this.#ie.test(t))return t;const e=Pe.utils.createElement("DIV",null,t),s=e.querySelectorAll(this.#rt.get("defaultLine"));let i=!1;for(let t=s.length-1;t>=0;t--)s[t].firstChild||(Pe.utils.removeItem(s[t]),i=!0);return i?e.innerHTML:t}#we(t){return!t||11===t.nodeType||Pe.check.isWysiwygFrame(t)||Pe.check.isList(t)||Pe.check.isTableElements(t)||this.#J.format.isBlock(t)}#he(t,e,s,i,n,o,r){const l=[],a=[],h=[],c=[],d=Pe.query.getListChildNodes(t,(d=>{if(1!==d.nodeType)return n&&Pe.check.isList(d.parentElement)&&l.push(d),3===d.nodeType&&(!d.textContent||Zs.test(d.textContent)&&(this.#we(d.parentNode)||!d.previousSibling!=!d.nextSibling))&&l.push(d),!1;if(i&&(s.test(d.nodeName)||!e.test(d.nodeName)&&0===d.childNodes.length&&Pe.check.isExcludeFormat(d)))return l.push(d),!1;"PRE"===d.nodeName&&this.#Ce(d);const u=!Pe.query.getParentElement(d,Pe.check.isExcludeFormat);if(n){if(!Pe.check.isTableElements(d)&&!Pe.check.isListCell(d)&&!Pe.check.isAnchor(d)&&(this.#J.format.isLine(d)||this.#J.format.isBlock(d)||this.#J.format.isTextStyleNode(d))&&0===d.childNodes.length&&u)return a.push(d),!1;if(Pe.check.isList(d.parentNode)&&!Pe.check.isList(d)&&!Pe.check.isListCell(d))return h.push(d),!1;if(Pe.check.isTableCell(d)){const t=d.firstElementChild;if(!this.#J.format.isLine(t)&&!this.#J.format.isBlock(t)&&!this.#J.component.is(t))return c.push(d),!1}}if(o&&u&&d.className){const t=Array.from(d.classList).map(this.#qt).join(" ").trim();t?d.className=t:d.removeAttribute("class")}if(!n)return!1;return!r&&d.parentNode!==t&&u&&(Pe.check.isListCell(d)&&!Pe.check.isList(d.parentNode)||(this.#J.format.isLine(d)||this.#J.component.is(d))&&!this.#J.format.isBlock(d.parentNode)&&!Pe.query.getParentElement(d,this.#J.component.is.bind(this.#J.component)))}),null);for(let t=0,e=l.length;t=0;i--)e.insertBefore(s[i],t);u.push(t)}else{const s=e.nextSibling;let i=null;if(t.nextSibling)for(i=e.cloneNode(!1);t.nextSibling;)i.appendChild(t.nextSibling);e.parentNode.insertBefore(t,s),i&&(e.parentNode.insertBefore(i,s),u.push(i)),u.push(e)}for(let t,e=0,s=u.length;ePe.check.isListCell(t)&&!Pe.check.isList(t.parentNode)),null);for(let t,s,i,n,o=0,r=e.length;o"}t.appendChild(e)}}#_e(t){const e=t.querySelectorAll("*"),s=this.#J.format;for(let t=0;ts+("string"==typeof e[i]?e[i]:i)+(n?" "+n:"")))}#de(t){let e,s="";const i=t.childNodes;for(let t,n=0,o=i.length;n"+(s.innerHTML.trim()||"
    ")+"":this.#J.format.isBlock(s)&&!Pe.check.isTableElements(s)?e+=this.#me(s.children):e+="
  • "+s.outerHTML+"
  • ":e+="
  • "+(s.textContent||"
    ")+"
  • ";return e}#ce(t){let e=!1;for(let s,i=0,n=t.length;i0&&e.push('style="'+o.join(";")+'"')}return e}#le(t,e,s){return e.test("")&&(t=t.replace(/(<\/?)font(\s?)/gi,"$1span$2")),t.replace(e,"").replace(s,"")}#fe(t,e){const s=t=>{this.#xe(t,e);const i=t.childNodes;for(let t=0,e=i.length;t-1&&s.splice(t,1);for(let e=0,s=r.classList.length;e0){const e=this.#rt.get("convertTextTags"),s={};t.forEach((t=>{switch(t){case"bold":s.bold={regex:/font-weight\s*:\s*bold/i,tag:e.bold};break;case"italic":s.italic={regex:/font-style\s*:\s*italic/i,tag:e.italic};break;case"underline":s.underline={regex:/text-decoration\s*:\s*underline/i,tag:e.underline};break;case"strike":s.strike={regex:/text-decoration\s*:\s*line-through/i,tag:e.strike}}})),this.#re=s}else this.#re=null}_destroy(){this.#Jt&&this.#Jt.clear()}#Ce(t){if(1!==t.children.length||"CODE"!==t.firstElementChild?.nodeName)return;const e=t.firstElementChild,s=(e.className||"").match(/language-(\S+)/);for(s&&(Pe.utils.addClass(t,"language-"+s[1]),t.setAttribute("data-se-lang",s[1]));e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}#ye(t){const e=t.querySelectorAll('pre[class*="language-"]');for(let t,s,i,n=0,o=e.length;ni))continue;o.appendChild(s[t])}t--,e--,i--}return n.childNodes.length>0&&t.parentNode.insertBefore(n,t),o.childNodes.length>0&&t.parentNode.insertBefore(o,t.nextElementSibling),t}const i=t.parentNode;let n,o,r,l=0,a=1,h=!0;if((!s||s<0)&&(s=0),Pe.check.isText(t)){if(l=Pe.query.getPositionIndex(t),(e=Number(e))>=0&&t.length!==e){t.splitText(e);const s=Pe.query.getNodeFromPath([l+1],i);Pe.check.isZeroWidth(s)&&(s.data=Re.zeroWidthSpace)}}else if(1===t.nodeType){if(0===e){for(;t.firstChild;)t=t.firstChild;if(3===t.nodeType){const e=Pe.utils.createTextNode(Re.zeroWidthSpace);t.parentNode.insertBefore(e,t),t=e}}t.previousSibling?t=t.previousSibling:Pe.query.getNodeDepth(t)===s&&(h=!1)}1===t.nodeType&&(a=0);let c=t;for(;Pe.query.getNodeDepth(c)>s;){if(l=Pe.query.getPositionIndex(c)+a,c=c.parentNode,r=n,n=c.cloneNode(!1),o=c.childNodes,r)if(Pe.check.isListCell(n)&&Pe.check.isList(r)&&r.firstElementChild){const t=r.firstElementChild;for(;t.firstChild;)n.appendChild(t.firstChild);Pe.utils.removeItem(t),r.children.length>0&&n.appendChild(r)}else n.appendChild(r);for(;o[l];)n.appendChild(o[l])}1===c.nodeType&&c.childNodes.length<=1&&!c.firstChild?.textContent?.length&&(c.innerHTML="
    ");const d=c.parentNode;return h&&(c=c.nextSibling),n?(this.mergeSameTags(n,null,!1),this.mergeNestedTags(n,Pe.check.isList),n.childNodes.length>0?d.insertBefore(n,c):n=c,Pe.check.isListCell(n)&&n.children&&Pe.check.isList(n.children[0])&&n.insertBefore(Pe.utils.createElement("BR"),n.children[0]),0===i.childNodes.length&&Pe.utils.removeItem(i),n):c}mergeSameTags(t,e,s){const i=e?e.length:0;let n=null;i&&(n=Array.apply(null,new Array(i)).map(Number.prototype.valueOf,0));const o=(t,r,l)=>{const a=t.childNodes;for(let h,c,d=0,u=a.length;d=0;){if(Pe.utils.getArrayIndex(o.childNodes,n)!==s[l]){a=!1;break}n=h.parentNode,o=n.parentNode,l--}a&&(s.splice(r,1),s[r]=d)}}Pe.utils.copyTagAttributes(h,t),t.parentNode.insertBefore(h,t),Pe.utils.removeItem(t)}if(!c){1===h.nodeType&&o(h,r+1,d);break}if(h.nodeName===c.nodeName&&Pe.check.isSameAttributes(h,c)&&h.getAttribute?.("href")===c.getAttribute?.("href")){const t=h.childNodes;let s=0;for(let e=0,i=t.length;e0&&s++;const o=h.lastChild,a=c.firstChild;let u=0;if(o&&a){const t=3===o.nodeType&&3===a.nodeType;u=o.textContent.length;let h=o.previousSibling;for(;h&&3===h.nodeType;)u+=h.textContent.length,h=h.previousSibling;if(s>0&&3===o.nodeType&&3===a.nodeType&&(o.textContent.length>0||a.textContent.length>0)&&s--,i){let h=null;for(let c=0;cd){if(r>0&&h[r-1]!==l)continue;h[r]-=1,h[r+1]>=0&&h[r]===d&&(h[r+1]+=s,t&&o&&3===o.nodeType&&a&&3===a.nodeType&&(n[c]+=u))}}}if(3===h.nodeType){if(u=h.textContent.length,h.textContent+=c.textContent,i){let t=null;for(let o=0;od){if(r>0&&t[r-1]!==l)continue;t[r]-=1,t[r+1]>=0&&t[r]===d&&(t[r+1]+=s,n[o]+=u)}}}else{for(;c.firstChild;)h.appendChild(c.firstChild);h.normalize()}Pe.utils.removeItem(c),d--}else 1===h.nodeType&&o(h,r+1,d)}};return o(t,0,0),n}mergeNestedTags(t,e){if("string"==typeof e){const t=new RegExp(`^(${e||".+"})$`,"i");e=e=>t.test(e.nodeName)}else"function"!=typeof e&&(e=()=>!0);!function t(s){let i=s.children;if(1===i.length&&i[0].nodeName===s.nodeName&&e(s)){const t=i[0];for(i=t.children;i[0];)s.appendChild(i[0]);s.removeChild(t)}for(let e=0,i=s.children.length;e{if(t===s||this.#J.component.is(t))return!1;const e=t.textContent.trim();return 0===e.length||/^(\n|\u200B)+$/.test(e)},function t(s){if(!Pe.check.isWysiwygFrame(s)){const n=s.parentNode;n&&e(s)&&(i={sc:s.previousElementSibling,ec:s.nextElementSibling},Pe.utils.removeItem(s),t(n))}}(t),i}removeEmptyNode(t,e,s){const i=this.#rt.get("allowedEmptyTags");e&&=Pe.query.getParentElement(e,(e=>t===e.parentElement));const n=s=>{if(this.#J.format._isNotTextNode(s)||s===e||Pe.check.isNonEditable(s))return 0;if(s===t||!Pe.check.isZeroWidth(s.textContent)||s.firstChild&&Pe.check.isBreak(s.firstChild)||s.querySelector(i)){const t=s.children;for(let e=0,s=t.length,i=0;e")}createNestedNode(t,e){"function"!=typeof e&&(e=()=>!0);const s=t[0].cloneNode(!1);let i=s;for(let s,n=1,o=t.length;n{ut(t,"se-blink")}),600))}const yi=class{#J;#X;#Q;constructor(t){this.#J=t.$,this.#X=this.#J.frameContext,this.#Q=this.#J.frameOptions}check(t){const e=this.#Q.get("charCounter_max");if(e){const s=this.getLength("string"==typeof t?t:"byte-html"===this.#Q.get("charCounter_type")&&1===t.nodeType?t.outerHTML:t.textContent);if(s>0&&s+this.getLength()>e)return bi(this.#X.get("charWrapper")),!1}return!0}getLength(t){return"string"!=typeof t&&(t="byte-html"===this.#Q.get("charCounter_type")?this.#X.get("wysiwyg").innerHTML:this.#X.get("wysiwyg").textContent),/byte/.test(this.#Q.get("charCounter_type"))?this.getByteLength(t):t.length}getByteLength(t){if(!t||!t.toString)return 0;let e,s;return t=t.toString(),u?(s=decodeURIComponent(encodeURIComponent(t)).length,e=0,null!==encodeURIComponent(t).match(/(%0A|%0D)/gi)&&(e=encodeURIComponent(t).match(/(%0A|%0D)/gi).length),s+e):(s=(new TextEncoder).encode(t).length,e=0,null!==encodeURIComponent(t).match(/(%0A|%0D)/gi)&&(e=encodeURIComponent(t).match(/(%0A|%0D)/gi).length),s+e)}getWordCount(t){"string"!=typeof t&&(t=this.#X.get("wysiwyg").innerText);const e=t.trim();return e?e.split(/\s+/).length:0}display(t){const e=t||this.#X,s=e.get("charCounter"),i=e.get("wordCounter");(s||i)&&o.setTimeout((()=>{s&&(s.textContent=String(this.getLength())),i&&(i.textContent=String(this.getWordCount()))}),0)}test(t,e){let s=0;t&&(s=this.getLength(t)),this.display();const i=this.#Q.get("charCounter_max");if(i>0){let t=!1;const n=this.getLength();if(n>i){if(t=!0,s>0&&e){this.#J.selection.init();const t=this.#J.selection.getRange(),e=t.endOffset-1,s=this.#J.selection.getNode().textContent,i=t.endOffset-1;this.#J.selection.getNode().textContent=s.slice(0,i<0?0:i)+s.slice(t.endOffset,s.length),this.#J.selection.setRange(t.endContainer,e,t.endContainer,e)}}else n+s>i&&(t=!0);if(t&&(bi(this.#X.get("charWrapper")),s>0))return!1}return!0}};const wi=class{#J;#rt;#$e=!1;constructor(t){this.#J=t.$,this.#rt=this.#J.options,this.keyMap=new Map,this.reverseKeys=new Set}command(t,e,s,i,n,o,r,l){if(this.#$e)return!1;let a=null;return a=e?this.keyMap.get(i+(s?"1000":"")):this.keyMap.get(n)||this.keyMap.get(n+t.key),!(!a||!s&&a.s||a.space&&!Fe.isSpace(i)||a.enter&&!Fe.isEnter(i)||a.textTrigger&&!t.key.trim()||a.edge&&!o)&&(a.plugin&&"string"==typeof a.method?this.#J.plugins[a.plugin][a.method]?.({range:l,line:r,info:a,event:t,keyCode:i}):"function"==typeof a.method?a.method({range:l,line:r,info:a,event:t,keyCode:i}):this.#J.commandDispatcher.run(a.command,a.type,a.button),!0)}disable(){this.#$e=!0}enable(){this.#$e=!1}_registerShortcuts(){const t=this.#rt.get("shortcuts"),e=this.#rt.get("_reverseCommandArray"),s=this.keyMap=new Map,i=this.reverseKeys;for(const n of Object.keys(t)){if(this.#J.plugins[n])continue;is(n.startsWith("_")?"":n,null,t[n],s,e,i)}}_destroy(){this.keyMap.clear(),this.reverseKeys.clear()}},Ci=new Map([["__figureInst",null],["__dragInst",null],["__dragHandler",null],["__dragContainer",null],["__dragCover",null],["__dragMove",null],["__overInfo",null]]),_i=Ci,{_w:ki,isMobile:xi,ON_OVER_COMPONENT:$i}=Oe,Si="2147483646",Ei="2147483645",Ti="2147483642",Mi="2147483641",Ni={left:0,right:0,top:0};let Bi=null;const Ii=class{#J;#Se;#Ee;#Te;#Me=Ni;#Ne=!1;#Be=!1;#Ie=null;#Le=null;#Ae=null;#Oe=[];#Re=new Map;constructor(t,e,s,i,n){this.#J=e,this.kind=n||t.constructor.key||t.constructor.name,this.host=t,this.form=s,this.isOpen=!1,this.currentTarget=null,this.currentPositionTarget=null,this.isWWTarget=i.isWWTarget??!0,this.position=i.position||"bottom",this.disabled=!!i.disabled,this.parents=i.parents||[],this.parentsForm=[],this.parentsHide=!!i.parentsHide,this.sibling=i.sibling||null,this.siblingMain=!!i.siblingMain,this.isInsideForm=!!i.isInsideForm,this.isOutsideForm=!!i.isOutsideForm,this.toTop=!1,this.__offset={},this.#Se="function"==typeof i.initMethod?i.initMethod:null,this.#Ee="function"==typeof i.escGuard?i.escGuard:null,this.#Te={keydown:this.#ze.bind(this),mousedown:this.#Pe.bind(this)};for(const t of this.parents)Pe.check.isElement(t)?this.parentsForm.push(t):(t.#Oe.push(this),this.parentsForm.push(t.form));this.form.setAttribute("popover","manual"),this.#J.contextProvider.carrierWrapper.appendChild(s),this.#J.eventManager.addEvent(s,"click",this.#De.bind(this)),this.#J.eventManager.addEvent(s,"mouseenter",this.#Fe.bind(this)),this.#J.eventManager.addEvent(s,"mouseleave",this.#He.bind(this))}open(t,e,{isWWTarget:s,passive:i,initMethod:n,disabled:o,addOffset:r}={}){if(Ci.get("__overInfo")===$i&&(i=!0),!t)return void console.warn("[SUNEDITOR.Controller.open.fail] The target element is required.");if(this.form.removeAttribute("data-se-hidden-by-parent"),this.form.removeAttribute("data-se-hidden-by-children"),this.#Re.clear(),i||(this.#J.store.mode.isBalloon?this.#J.toolbar.hide():this.#J.store.mode.isSubBalloon&&this.#J.subToolbar.hide(),this.#J.store.get("hasFocus")||(o??this.disabled?this.#J.ui.setControllerOnDisabledButtons(!0):this.#J.ui.setControllerOnDisabledButtons(!1))),this.currentPositionTarget=e||t,this.isWWTarget=s??this.isWWTarget,"function"==typeof n&&(this.#Se=n),i||(this.#J.ui.currentControllerName=this.kind),this.#Me={left:0,right:0,top:0,...r},!i){const t=this.isOutsideForm?this.parentsForm:[];this.#J.ui.opendControllers?.forEach((e=>{t.includes(e.form)||(e.form.style.zIndex=Mi)})),this.parentsHide&&this.parentsForm.forEach((t=>{t.style.display="none",t.setAttribute("data-se-hidden-by-children","1")}))}this.#qe(),this.#We(this.form,this.currentPositionTarget,!1);const l=this.#J.instanceCheck.isRange(t);this.currentTarget=l?null:t,this.#Ue(this.form,t,l,i),ki.setTimeout((()=>Ci.set("__overInfo",!1)),0)}close(t){(t||this.isOpen&&!this.#Be)&&(this.form.removeAttribute("data-se-hidden-by-parent"),this.form.removeAttribute("data-se-hidden-by-children"),this.#Re.clear(),this.#Ve("close"),this.toTop=!1,this.isOpen=!1,this.#Be=!1,this.__offset={},this.#Me=Ni,this.#je(),this.#Se?.(),this.#Ge(),this.parentsHide&&!t&&this.parentsForm.forEach((t=>{t.style.display="block",t.removeAttribute("data-se-hidden-by-children")})),this.host.controllerClose?.(),this.parentsForm.length>0||this.#J.component.deselect())}hide(){this.#Ve("hide"),this.form.style.display="none"}show(){this.#We(this.form,this.currentPositionTarget,!1)}bringToTop(t){this.toTop=t,this.form.style.zIndex=t?Si:Ei}resetPosition(t){this.#We(this.form,t||this.currentPositionTarget,!0)}_scrollReposition(){this.form.hasAttribute("data-se-hidden-by-parent")||this.form.hasAttribute("data-se-hidden-by-children")||this.#We(this.form,this.currentPositionTarget,!1)&&ki.setTimeout((()=>{this.#Ve("show")}),0)}#Ve(t){for(const e of this.#Oe)if("hide"===t&&"none"!==e.form.style.display){const t=this.#Ke(e);e.#Re.set(this,!0);const s=this.#Ke(e);!t&&s&&(e.form.setAttribute("data-se-hidden-by-parent","1"),e.hide())}else if("show"===t){if(e.form.hasAttribute("data-se-hidden-by-children")){e.#Ve("show");continue}const t=this.#Ke(e);e.#Re.set(this,!1);const s=this.#Ke(e);t&&!s&&(e.form.removeAttribute("data-se-hidden-by-parent"),e.show())}else e[t]?.(!0)}#Ke(t){for(const e of t.#Re.values())if(!0===e)return!0;return!1}async#Ue(t,e,s,i){const n={position:this.position,inst:this,form:t,target:e,isRangeTarget:s,notInCarrier:!this.#J.contextProvider.carrierWrapper.contains(t)};!1!==await this.#J.eventManager.triggerEvent("onBeforeShowController",{caller:this.kind,frameContext:this.#J.frameContext,info:n})&&(t.style.display="block",this.#J.contextProvider.shadowRoot&&(this.#Ie=this.#J.eventManager.addEvent(t,"mousedown",(t=>t.stopPropagation()))),i||(this.#J.ui.onControllerContext(),this.#J.store.set("controlActive",!0),this.#J.store.set("_preventBlur",!0)),this.isOpen||this.#J.ui.opendControllers.push(n),this.isOpen=!0,this.host.controllerOn?.(t,e),this.#J.eventManager.triggerEvent("onShowController",{caller:this.kind,frameContext:this.#J.frameContext,info:n}))}#Ge(){Bi===this&&(Bi=null),this.form.hidePopover?.(),this.form.style.display="none",this.#J.ui.opendControllers=this.#J.ui.opendControllers.filter((t=>t.form!==this.form)),this.#J.ui.currentControllerName!==this.kind&&this.#J.ui.opendControllers.length>0||(this.#J.ui.setControllerOnDisabledButtons(!1),this.#J.ui.offControllerContext(),this.#J.frameContext.get("lineBreaker_t").style.display=this.#J.frameContext.get("lineBreaker_b").style.display="none",this.#J.store.set("_lastSelectionNode",null),this.#J.ui.currentControllerName="",this.#J.store.set("_preventBlur",!1),ki.setTimeout((()=>{this.#J.store.set("controlActive",!1)}),0),this.#Ie&&=this.#J.eventManager.removeEvent(this.#Ie))}#We(t,e,s){if(!e)return!1;if(t.style.visibility="hidden",t.style.display="block",this.sibling&&"block"!==this.sibling.style.display&&(this.sibling.style.visibility="hidden",this.sibling.style.display="block"),this.#J.selection.isRange(e)){if(!this.#J.offset.setRangePosition(this.form,e,{position:"bottom"}))return this.hide(),!1}else{const i=this.#J.offset.setAbsPosition(t,e,{addOffset:this.#Me,position:this.position,isWWTarget:this.isWWTarget,inst:this,sibling:this.sibling});if(!i)return this.hide(),!1;if(s||!this.sibling||this.siblingMain)this.#Ne=!1;else{const e=t.offsetTop-this.#Me.top;"bottom"===i.position?(this.#Ne=!0,t.style.top=e+this.sibling.offsetHeight-1+"px"):(this.#Ne=!1,t.style.top=e-this.sibling.offsetHeight+2+"px")}}return t.style.zIndex=this.toTop?Ei:this.#Ne?Ti:Mi,t.style.visibility="",t.showPopover?.(),!0}#qe(){this.#je(),this.#Le=this.#J.eventManager.addGlobalEvent("keydown",this.#Te.keydown,!0),this.#Ae=this.#J.eventManager.addGlobalEvent(xi?"click":"mousedown",this.#Te.mousedown,!0)}#je(){this.#J.component.__removeGlobalEvent(),this.#Le&&=this.#J.eventManager.removeGlobalEvent(this.#Le),this.#Ae&&=this.#J.eventManager.removeGlobalEvent(this.#Ae)}#Ye(){if(this.#J.ui.selectMenuOn)return!0;const t=this.#J.ui.opendControllers;for(let e=0;e0&&this.parentsForm.some((s=>{if(s.contains(t))return e=!0,!0}));const s=this.host._element;return!e&&(!!Pe.query.getParentElement(t,".se-controller")||(this.#J.component.isInline(s)?t===s:t?.contains(s)))}#De(t){const e=Pe.query.getEventTarget(t),s=Pe.query.getCommandTarget(e);s&&(t.stopPropagation(),t.preventDefault(),"close"!==s.getAttribute("data-command")?this.host.controllerAction(s):this.close())}#Fe(t){if(this.#J.ui.currentControllerName=this.kind,this.parentsForm.length>0&&this.isInsideForm)return;Pe.query.getEventTarget(t).style.zIndex=this.toTop?Si:Ei,this.sibling&&Bi!==this&&this.form.matches?.(":popover-open")&&(Bi=this,this.form.hidePopover(),this.form.showPopover())}#He(t){if(this.parentsForm.length>0&&this.isInsideForm)return;Pe.query.getEventTarget(t).style.zIndex=this.toTop?Ei:this.#Ne?Ti:Mi}#ze(t){if(this.#Ye())return;const e=t.code;if(Fe.isCtrl(t)||!Fe.isNonResponseKey(e))return;const s=Pe.query.getEventTarget(t);if(Fe.isEsc(e)){if(this.#Oe.some((({isOpen:t})=>t)))return;if(this.#Ee?.())return}else{if(this.form.contains(s)||this.#Xe(s))return;if(this.#J.pluginManager.fileInfo.pluginRegExp.test(this.kind))return}this.#Ze(s),this.close()}#Pe(t){const e=Pe.query.getEventTarget(t);this.host?._element?.contains(e)?this.#Be=!0:(this.#Be=!1,e===this.host._element||e===this.currentTarget||this.#Ye()||this.form.contains(e)||this.#Xe(e)||Pe.query.getParentElement(e,".se-line-breaker-component")||(this.#Ze(e),this.close(!0)))}#Ze(t){this.#J.frameContext.get("wysiwyg").contains(t)||(this.#J.component.__prevent=!1)}},{_w:Li}=Oe;const Ai=class{#J;#Je;#Qe;#ts;#es;#Te;#ss=null;#is=null;#ns=null;#os=null;#rs=null;#Le=null;#ls=null;#as=null;#hs=null;#st=null;#cs=null;#ds=null;#us=new Map;#ps=-1;#gs=-1;#ms=!1;#fs=null;constructor(t,e){this.#J=t;const s=e.position.split("-");this.form=null,this.items=[],this.menus=null,this.menuLen=0,this.index=-1,this.item=null,this.isOpen=!1,this.checkList=!!e.checkList,this.position=s[0],this.subPosition=s[1],this.splitNum=e.splitNum||0,this.horizontal=!!this.splitNum,this.openMethod=e.openMethod,this.closeMethod=e.closeMethod,this.subEscMethod=e.subEscMethod||null,this.subCheckMethod=e.subCheckMethod||null,this.maxHeight=e.maxHeight||"",this.minWidth=e.minWidth||"",this.#os=e.keydownTarget||null,this.#Je=/^(left|right)$/.test(this.position)?"left"===this.position?"right":"left":this.position,this.#Qe=/^(left|right)$/.test(this.subPosition)?"left"===this.subPosition?"right":"left":this.subPosition,this.#ts="ltr"!==e.dir&&("rtl"===e.dir||null),this.#es={mousedown:this.#vs.bind(this),mousemove:this.#bs.bind(this),click:this.#ys.bind(this),keydown:this.#ws.bind(this)},this.#Te={keydown:this.#Cs.bind(this),mousedown:this.#Pe.bind(this),click:this.#_s.bind(this),submenuReposition:this.#ks.bind(this)}}create(t,e){this.#ss.innerHTML="";for(const[,t]of this.#us)t.element?.remove();this.#us.clear(),e||=t;let s="";for(let i=0,n=e.length;i0&&i%this.splitNum==0&&(this.#xs(s),s="");const n=t[i],o="string"==typeof e[i]?e[i]:e[i].outerHTML,r=n&&"object"==typeof n?n:{};if(r.children?.length>0){let t="";const e=r.childMenus||r.children;for(let s=0;s${"string"==typeof e[s]?e[s]:e[s].outerHTML}`;s+=`
  • ${o}${this.#J.icons.menu_arrow_right}
  • `;const n=Pe.utils.createElement("DIV",{class:"se-select-submenu",popover:"manual","data-parent-index":String(i)},`
      ${t}
    `);this.#us.set(i,{items:r.children,menus:e,element:n})}else s+=`
  • ${o}
  • `}this.#xs(s);for(const[,t]of this.#us)this.form.appendChild(t.element);this.items=t,this.menus=Array.from(this.form.querySelectorAll("li[data-index]")),this.menuLen=this.menus.length}on(t,e,s={}){this.#is=t,this.#ns=this.#os||(Pe.check.isInputElement(t)?t:this.#J.frameContext.get("_ww")),this.#rs=e;let i="";this.maxHeight&&(i+="max-height:"+this.maxHeight+";overflow-y:auto;"),this.minWidth&&(i+="min-width:"+this.minWidth+";"),this.form=Pe.utils.createElement("DIV",{class:"se-select-menu"+(!0===this.#ts?" se-rtl":"")+(s.class?" "+s.class:""),style:s.style||""},'
    "),this.#ss=this.form.firstElementChild,t.parentNode.insertBefore(this.form,t)}open(t,e){this.#J.ui.setSelectMenuOpen(this,!0),this.openMethod?.(),this.#$s(),this.#qe();const s=t?t.split("-"):[],i=s[0]||(null!==this.#ts&&this.#ts!==this.#J.options.get("_rtl")?this.#Je:this.position),n=s[1]||(null!==this.#ts&&this.#ts!==this.#J.options.get("_rtl")?this.#Qe:this.subPosition);this.#cs=i,this.#ds=n,this.#Ss(i,n,e),this.isOpen=!0}reposition(){this.isOpen&&this.#cs&&this.#Ss(this.#cs,this.#ds)}setHidden(t){this.isOpen&&(t?(this.#Es(),this.form.style.display="none"):this.reposition())}close(){this.#J.ui.setSelectMenuOpen(this,!1),Pe.utils.removeClass(this.#is,"on"),this.#Ts(),this.form?.removeAttribute("style"),this.#ss&&this.#Ms(),this.isOpen=!1,this.closeMethod?.()}getItem(t){return this.items[t]}setItem(t){this.#Ns(t)}hasOpenSubmenu(){return this.#ps>-1}#Bs(t){if(this.#ps===t)return;this.#Es();const e=this.menus[t];if(!e||!Pe.utils.hasClass(e,"se-has-submenu"))return;Pe.utils.addClass(e,"se-submenu-open"),this.#ps=t,this.#gs=-1,this.#ms=!1;const s=this.#us.get(t),i=s?.element;if(i){const t="function"==typeof i.showPopover;i.style.visibility="hidden",t?i.matches(":popover-open")||i.showPopover():i.style.display="block",this.#Is(e,i,t),i.style.visibility="",this.#hs=this.#J.eventManager.addGlobalEvent("scroll",this.#Te.submenuReposition,!0)}}#Is(t,e,s){const i=s?{top:0,left:0}:this.form.getBoundingClientRect(),n=t.getBoundingClientRect(),o=e.offsetWidth,r=e.offsetHeight,l=Li.innerWidth,a=Li.innerHeight,h=n.right,c=n.left-o,d=Math.max(0,h+o-l),u=Math.max(0,-c);let p;p=!0===this.#ts?0===u?c:0===d?h:u<=d?c+u:h-d:0===d?h:0===u?c:d<=u?h-d:c+u,e.style.left=p-i.left+"px",e.style.right="";const g=n.top,m=n.bottom-r,f=Math.max(0,g+r-a),v=Math.max(0,-m);let b;b=0===f?g:0===v?m:f<=v?g-f:m+v,e.style.top=b-i.top+"px"}#ks(){if(this.#ps<0)return;const t=this.#us.get(this.#ps),e=t?.element,s=this.menus[this.#ps];e&&s&&this.#Is(s,e,"function"==typeof e.showPopover)}#Es(){if(this.#fs&&(Li.clearTimeout(this.#fs),this.#fs=null),this.#hs&&=this.#J.eventManager.removeGlobalEvent(this.#hs),this.#ps>-1){const t=this.menus[this.#ps];t&&Pe.utils.removeClass(t,"se-submenu-open");const e=this.#us.get(this.#ps);e?.element&&("function"==typeof e.element.hidePopover?e.element.matches(":popover-open")&&e.element.hidePopover():e.element.style.display="",Pe.utils.removeClass(e.element.querySelectorAll(".se-select-item"),"se-select-cursor"))}this.#ps=-1,this.#gs=-1,this.#ms=!1}#Ls(t,e){const s=this.#us.get(t);if(s){if(this.checkList){const t=s.element?.querySelectorAll(".se-select-item")[e];t&&Pe.utils.toggleClass(t,"se-checked")}this.#rs(s.items[e])}}#As(t){const e=this.#us.get(this.#ps);if(!e?.element)return;const s=e.element.querySelectorAll(".se-select-item"),i=s.length;if(!i)return;t=this.#gs+t;const n=this.#gs=t>=i?0:t<0?i-1:t;Pe.utils.removeClass(this.form,"se-select-menu-mouse-move");for(let t=0;t${t}`}#Ts(){this.#Os(),this.#je(),this.#Es(),this.index=-1,this.item=null,this._onItem&&(Pe.utils.removeClass(this._onItem,"se-select-on"),this._onItem=null)}#Rs(t){t=this.index+t;const e=this.menuLen,s=this.index=t>=e?0:t<0?e-1:t;this.#Ns(s)}#Ms(){this.form.style.height="",this.#ss.style.maxHeight=this.maxHeight,this.#ss.style.overflowY=this.maxHeight?"auto":""}#zs(t){const e=this.form.offsetHeight-this.#ss.offsetHeight;this.form.style.height=t+"px",this.#ss.style.maxHeight=(t-e>0?t-e:0)+"px",this.#ss.style.overflowY="auto"}#Ps(t){if(!t)return;const e=this.#ss;if(!e.style.maxHeight)return;const s=e.getBoundingClientRect().top+e.clientTop,i=s+e.clientHeight,{top:n,bottom:o}=t.getBoundingClientRect();ni&&(e.scrollTop+=o-i)}#Ns(t){Pe.utils.removeClass(this.form,"se-select-menu-mouse-move");const e=this.menuLen;for(let s=0;s0&&(u-=i+4,o.style.top=u+"px"),s=this.#J.offset.getGlobal(o).top,s<0&&(t+=s-4,u-=s-4),this.#zs(t);break}case"top":if(m=38&&this.#zs(y)}u=g-o.offsetHeight+b;break;case"bottom":if(v=38&&this.#zs(y)}u=g+(c?0:f)}if(y<38&&!i&&"middle"!==t)return void this.#Ss("top"===t?"bottom":"top",e,s,!0);if(!c)switch(e){case"center":d=h+a/2-l/2;break;case"left":d=h;break;case"right":d=h-(l-a)}o.style.left=d+"px";let w=this.#J.offset.getGlobal(o).fixedLeft,C=0;switch(c+"-"+(c?n:e)){case"true-left":w<0&&(d=h+a+1);break;case"true-right":w+l>Li.innerWidth&&(d=h-l-1);break;case"false-center":C=Li.innerWidth-(w+l),C<0&&(d+=C-4),o.style.left=d+"px",w=this.#J.offset.getGlobal(o).fixedLeft,w<0&&(d-=w-4);break;case"false-left":C=Li.innerWidth-(w+l),C<0&&(d+=C-4);break;case"false-right":w<0&&(d-=w-4)}if(s){const t=this.#ss.querySelector(s);t&&(this._onItem=t,Pe.utils.addClass(t,"se-select-on"))}o.style.left=d+"px",o.style.top=u+"px",o.style.visibility=""}#Ds(t){this.checkList&&Pe.utils.toggleClass(this.menus[t],"se-checked"),this.#rs(this.getItem(t))}#$s(){this.#Os(),this.#st={mousedown:this.#J.eventManager.addEvent(this.form,"mousedown",this.#es.mousedown),mousemove:this.#J.eventManager.addEvent(this.form,"mousemove",this.#es.mousemove),click:this.#J.eventManager.addEvent(this.form,"click",this.#es.click),keydown:this.#J.eventManager.addEvent(this.#ns,"keydown",this.#es.keydown)}}#Os(){this.#st&&(this.#J.eventManager.removeEvent(this.#st.mousedown),this.#J.eventManager.removeEvent(this.#st.mousemove),this.#J.eventManager.removeEvent(this.#st.click),this.#J.eventManager.removeEvent(this.#st.keydown),this.#st=null)}#qe(){this.#je(),this.#Le=this.#J.eventManager.addGlobalEvent("keydown",this.#Te.keydown,!0),this.#ls=this.#J.eventManager.addGlobalEvent("mousedown",this.#Te.mousedown,!0)}#je(){this.#Le&&=this.#J.eventManager.removeGlobalEvent(this.#Le),this.#ls&&=this.#J.eventManager.removeGlobalEvent(this.#ls),this.#as&&=this.#J.eventManager.removeGlobalEvent(this.#as)}#ws(t){if(this.#ms)switch(t.code){case"ArrowUp":return t.preventDefault(),t.stopPropagation(),void this.#As(-1);case"ArrowDown":return t.preventDefault(),t.stopPropagation(),void this.#As(1);case"ArrowLeft":case"ArrowRight":{t.preventDefault(),t.stopPropagation();const e=this.#ps;return this.#Es(),void(e>-1&&this.#Ns(e))}case"Enter":return void(this.#gs>-1&&(t.preventDefault(),t.stopPropagation(),this.#Ls(this.#ps,this.#gs)))}let e;switch(t.code){case"ArrowUp":if(t.preventDefault(),t.stopPropagation(),this.horizontal&&this.index>-1){const t=this.splitNum;e=this.index-t<0?t:-t}else e=-1;break;case"ArrowDown":if(t.preventDefault(),t.stopPropagation(),this.horizontal&&this.index>-1){const t=this.splitNum;e=this.index+t>this.menuLen?-t:t}else e=1;break;case"ArrowLeft":case"ArrowRight":if(t.preventDefault(),t.stopPropagation(),this.#ps>-1){const t=this.#ps;return this.#Es(),void this.#Ns(t)}if(this.subEscMethod?.())return;if(this.index>-1){if(this.#us.has(this.index))return this.#Bs(this.index),this.#ms=!0,void this.#As(1);if(this.subCheckMethod?.(this.index))return void this.#Ds(this.index)}if(!this.horizontal)return;e="ArrowLeft"===t.code?-1:1;break;case"Enter":this.index>-1&&(t.preventDefault(),t.stopPropagation(),this.#us.has(this.index)?(this.#Bs(this.index),this.#ms=!0,this.#As(1)):this.#Ds(this.index))}e&&(this.#Es(),this.subEscMethod?.(),this.#Rs(e))}#vs(t){if(Oe.isGecko){const e=Pe.query.getEventTarget(t),s=Pe.query.getParentElement(e,".se-select-item");s&&this.#J.eventManager._injectActiveEvent(s)}}#bs(t){const e=Pe.query.getEventTarget(t);Pe.utils.addClass(this.form,"se-select-menu-mouse-move");const s=e.closest?.("[data-child-index]"),i=s?.getAttribute("data-child-index");if(null!=i){this.#gs=Number(i);const t=this.#us.get(this.#ps);if(t?.element){const e=t.element.querySelectorAll(".se-select-item");Pe.utils.removeClass(e,"se-select-cursor"),Pe.utils.addClass(e[this.#gs],"se-select-cursor")}return}const n=e.closest?.("[data-index]"),o=n?.getAttribute("data-index");if(!o)return;const r=Number(o);if(this.index=r,this.#us.has(r))this.#fs&&Li.clearTimeout(this.#fs),this.#Bs(r);else if(this.#ps>-1){const t=this.#us.get(this.#ps);t?.element?.contains(e)||this.#Es()}}#ys(t){let e=Pe.query.getEventTarget(t),s=null,i=null;for(;!(s||i||/UL/i.test(e.tagName)||Pe.utils.hasClass(e,"se-select-menu"));)i=e.getAttribute("data-child-index"),i||(s=e.getAttribute("data-index")),e=e.parentElement;if(null!==i){let t=e,s=null;for(;!s&&t;)s=t.getAttribute("data-parent-index")||t.getAttribute("data-index"),t=t.parentElement;return void(null!==s&&this.#Ls(Number(s),Number(i)))}if(!s)return;const n=Number(s);this.#us.has(n)?this.#ps===n?this.#Es():this.#Bs(n):this.#Ds(n)}#Cs(t){if(Fe.isEsc(t.code)){if(this.#ps>-1){t.preventDefault(),t.stopPropagation();const e=this.#ps;return this.#Es(),void this.#Ns(e)}if(this.subEscMethod?.())return t.preventDefault(),void t.stopPropagation();this.close()}}#Pe(t){const e=Pe.query.getEventTarget(t);this.form.contains(e)||this.#J.ui.opendControllers?.some((({form:t})=>t?.contains?.(e)&&!t.contains(this.#is)))||(this.#is.contains(e)?Pe.check.isInputElement(e)||(this.#as=this.#J.eventManager.addGlobalEvent("click",this.#Te.click,!0)):this.close())}#_s(t){this.#as=this.#J.eventManager.removeGlobalEvent(this.#as),t.target===this.#is&&(t.stopPropagation(),this.close())}},{_w:Oi,ON_OVER_COMPONENT:Ri}=Oe,zi={tl:"nwse-resize",tr:"nesw-resize",bl:"nesw-resize",br:"nwse-resize",lw:"ew-resize",th:"ns-resize",rw:"ew-resize",bh:"ns-resize"};let Pi=!1,Di=!1,Fi=0,Hi=0;class qi{#J;#Fs;#Hs;#qs="";#Ws="";#Us=0;#Vs=0;#js=0;#Gs=0;#Ks="__se__float-none|__se__float-left|__se__float-center|__se__float-right";#Ys=!1;#Xs={w:"",h:""};#Zs=null;constructor(t,e,s,i){this.#J=e,this.kind=t.constructor.key||t.constructor.name,this._alignIcons={none:this.#J.icons.format_float_none,left:this.#J.icons.format_float_left,right:this.#J.icons.format_float_right,center:this.#J.icons.format_float_center},this._action={};const n=function(t,e,s){let i=null;if(s?.length>0){const{lang:n,icons:o}=e;i='
    ';for(let e,r=0;r';for(let s,r=0,l=e.length;r\n\t\t\t\t\t\t${o[s.i]||s.i}\n\t\t\t\t\t\t${n[s.l]||s.l}\n\t\t\t\t\t`}i+=""}}return i?Pe.utils.createElement("DIV",{class:"se-controller se-controller-resizing"},i):null}(this,e,s||[]);if(this.controller=n?new Ii(this,e,n,{position:"bottom",disabled:!0},this.kind):null,n){this.alignButton=n.querySelector('[data-command="onalign"]');const t=function(t,e,s){if(!s)return null;const i=[t._alignIcons.none,t._alignIcons.left,t._alignIcons.center,t._alignIcons.right],n=[e.lang.basic,e.lang.left,e.lang.center,e.lang.right],o=["none","left","center","right"],r=[],l=[];for(let t=0;t\n\t\t\t${i[t]}\n\t\t\t\n\t\t\t\t${n[t]}\n\t\t\t\n\t\t`),l.push(o[t]);return{html:r,items:l}}(this,e,this.alignButton);t&&(this.selectMenu_align=new Ai(e,{checkList:!1,position:"bottom-center"}),this.selectMenu_align.on(this.alignButton,this.#Js.bind(this),{class:"se-figure-select-list"}),this.selectMenu_align.create(t.items,t.html)),this.asButton=n.querySelector('[data-command="onas"]');const s=function(t,e){if(!e)return null;const s=[t.icons.as_block,t.icons.as_inline],i=[t.lang.asBlock,t.lang.asInline],n=["block","inline"],o=[],r=[];for(let t=0;t\n\t\t\t${s[t]}\n\t\t\t\n\t\t\t\t${i[t]}\n\t\t\t\n\t\t`),r.push(n[t]);return{html:o,items:r}}(e,this.asButton);s&&(this.selectMenu_as=new Ai(e,{checkList:!1,position:"bottom-center"}),this.selectMenu_as.on(this.asButton,this.#Qs.bind(this),{class:"se-figure-select-list"}),this.selectMenu_as.create(s.items,s.html)),this.resizeButton=n.querySelector('[data-command="onresize"]');const i=function(t,e){if(!e)return null;const s=e.getAttribute("data-value").split(","),i=[];for(let e,n,o,r,l=0;l'+r+"");return{html:i,items:s}}(e,this.resizeButton);i&&(this.selectMenu_resize=new Ai(e,{checkList:!1,position:"bottom-left",dir:"ltr"}),this.selectMenu_resize.on(this.resizeButton,this.#ti.bind(this)),this.selectMenu_resize.create(i.items,i.html))}this.inst=t,this.sizeUnit=i.sizeUnit||"px",this.autoRatio=i.autoRatio,this.isVertical=!1,this.percentageButtons=n?.querySelectorAll('[data-command="resize_percent"]')||[],this.captionButton=n?.querySelector('[data-command="caption"]'),this.align="none",this.as="block",this.__offset={},this._element=null,this._cover=null,this._inlineCover=null,this._container=null,this._caption=null,this._resizeClientX=0,this._resizeClientY=0,this._resize_direction="",this.__containerResizingOff=this.#ei.bind(this),this.__containerResizing=this.#si.bind(this),this.__onContainerEvent=null,this.__offContainerEvent=null,this.#Fs=this.#ii.bind(this),this.#Hs=this.#ni.bind(this),this.#J.eventManager.addEvent(this.alignButton,"click",this.#oi.bind(this)),this.#J.eventManager.addEvent(this.asButton,"click",this.#ri.bind(this)),this.#J.eventManager.addEvent(this.resizeButton,"click",this.#li.bind(this)),this.#J.contextProvider.applyToRoots((t=>{if(!t.get("wrapper").querySelector(".se-controller.se-resizing-container")){const e=function(){const t='\n\t\t
    \n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t
    \n\t\t
    ';return Pe.utils.createElement("DIV",{class:"se-controller se-resizing-container",style:"display: none;"},t)}(),s=e.querySelectorAll(".se-resize-dot > span");t.set("_figure",{main:e,border:e.querySelector(".se-resize-dot"),display:e.querySelector(".se-resize-display"),handles:s}),t.get("wrapper").appendChild(e),this.#J.eventManager.addEvent(s,"mousedown",this.#ai.bind(this))}}))}static CreateContainer(t,e){return Pe.utils.createElement("DIV",{class:"se-component"+(e?" "+e:"")},Pe.utils.createElement("FIGURE",null,t)),qi.GetContainer(t)}static CreateInlineContainer(t,e){return Pe.utils.createElement("SPAN",{class:"se-component se-inline-component"+(e?" "+e:"")},t),qi.GetContainer(t)}static CreateCaption(t,e){const s=Pe.utils.createElement("FIGCAPTION",null,"
    "+e+"
    ");return t.appendChild(s),s}static GetContainer(t){const e=Pe.query.getParentElement(t,"FIGURE",2),s=Pe.query.getParentElement(t,"SPAN",2),i=e||s;let n=Pe.query.getParentElement(t,(t=>t.parentElement===i),0)||t;if(Pe.check.isAnchor(n)){const t=n.querySelector(":scope > img");t&&(n=t)}return{target:n,container:Pe.query.getParentElement(n,qi.is,3)||e,cover:e,inlineCover:Pe.utils.hasClass(s,"se-inline-component")?s:null,caption:Pe.query.getEdgeChild(n.parentElement,"FIGCAPTION",!1),isVertical:Ui(n)}}static GetRatio(t,e,s){let i=0,n=0;if(/\d+/.test(t+"")&&/\d+/.test(e+"")){if((!De.is(t)&&String(t).replace(/\d+|\./g,"")||s||"px")===(!De.is(e)&&String(e).replace(/\d+|\./g,"")||s||"px")){const s=De.get(t,4),o=De.get(e,4);i=s/o,n=o/s}}return{w:De.get(i,4),h:De.get(n,4)}}static CalcRatio(t,e,s,i){if(i?.w&&i?.h&&/\d+/.test(t+"")&&/\d+/.test(e+"")){const n=!De.is(t)&&String(t).replace(/\d+|\./g,"")||s||"px",o=!De.is(e)&&String(e).replace(/\d+|\./g,"")||s||"px";if(n===o){const s="%"===n?2:0,r=t,l=e;e=De.get(i.h*De.get(r,s),s)+o,t=De.get(i.w*De.get(l,s),s)+n}}return{w:t,h:e}}static is(t){return Pe.check.isComponentContainer(t)||/^(HR)$/.test(t?.nodeName)}close(){this.#J.store.set("_preventBlur",!1),Pe.utils.removeClass(this._cover,"se-figure-selected"),this.#J.component.__removeDragEvent(),this.#hi(),this.controller?.close()}open(t,{nonResizing:e,nonSizeInfo:s,nonBorder:i,figureTarget:n,infoOnly:o}){if(!t)return void console.warn('[SUNEDITOR.modules.Figure.open] The "targetNode" is null.');Ci.get("__overInfo")===Ri&&(i=!0);const r=qi.GetContainer(t),l=r.target;let a=!1;if(!r.container){if(this.#J.options.get("strictMode").formatFilter)return{container:null,cover:null,width:l.style.width||l.width||"",height:l.style.height||l.height||"",isVertical:this.isVertical};r.container=l,r.cover=l,a=!0}Ci.set("__figureInst",this),this.#ci(r);const h=n&&(this._cover||this._container)||l,c=h.offsetWidth||null,d=h.offsetHeight||null,{top:u,left:p,scrollX:g,scrollY:m}=this.#J.offset.getLocal(h),f=(l.getAttribute("data-se-size")||"").split(",");let v=De.get(l.style.width,2)||c,b=De.get(l.style.height,2)||d;this.isVertical&&([v,b]=[b,v]);const y=qi.GetRatio(v,b,this.sizeUnit),w={container:r.container,cover:r.cover,caption:r.caption,align:this.align,ratio:y,isVertical:this.isVertical,w:c||"",h:d||"",t:u,l:p,width:f[0]||"auto",height:f[1]||"auto",originWidth:l.naturalWidth||l.offsetWidth,originHeight:l.naturalHeight||l.offsetHeight};if(this.#qs=w.width,this.#Ws=w.height,o)return w;const C=this.#J.frameContext.get("_figure");this.#J.ui.setFigureContainer(C.main),this.#J.ui.opendControllers=this.#J.ui.opendControllers.filter((t=>t.form!==C.main)),C.main.style.top=u+"px",C.main.style.left=p+"px",C.main.style.width=(this.isVertical?d:c)+"px",C.main.style.height=(this.isVertical?c:d)+"px",C.border.style.top="0px",C.border.style.left="0px",C.border.style.width=(this.isVertical?d:c)+"px",C.border.style.height=(this.isVertical?c:d)+"px",this.__offset={left:p+g,top:u+m},this.#J.ui.opendControllers.push({position:"none",form:C.main,target:h,inst:this,notInCarrier:!0});const _=/%$/.test(l.style.width)&&/%$/.test(r.container.style.width)?De.get(r.container.style.width,0)/100+"":"";for(let t=0,e=this.percentageButtons.length;t{t.style.display=s}));const i=this.controller.form.querySelector('[data-command="onas"]');i&&(i.style.display=a?"none":"")}Pe.utils.removeClass(this._cover,"se-figure-over-selected"),this.controller?.open(C.main,null,{initMethod:this.#Fs,isWWTarget:!1,addOffset:null}),Oi.setTimeout((()=>Ci.set("__overInfo",!1)),0)}else Pe.utils.addClass(this._cover,"se-figure-over-selected");return Pe.utils.addClass(this._cover,"se-figure-selected"),this.#js=this.#Us=c,this.#Gs=this.#Vs=d,this._inlineCover||Ci.get("__overInfo")===Ri&&!Pe.utils.hasClass(r.container,"se-input-component")||this.#pi(C.main),w}controllerHide(){this.controller?.hide()}controllerShow(){this.controller?.show()}controllerOpen(t,e){this._element=t,this.controller?.open(t,null,e)}setFigureSize(t,e){/%$/.test(t+"")?this._setPercentSize(t,e):t&&"auto"!==t||e&&"auto"!==e?this._applySize(t,e,""):this.autoRatio?this._setPercentSize(100,this.autoRatio.default||this.autoRatio.current):this._setAutoSize()}setSize(t,e){const s=this.isVertical;s&&([t,e]=[e,t]),this.setFigureSize(t,e),s&&this.setTransform(this._element,t,e,0)}getSize(t){t||=this._element;const e=Ui(t);let s="",i="",n="",o="";if(!t)return{w:s,h:i,dw:n,dh:o};const r=qi.GetContainer(t),l=r.target;return r.container?(s=/%$/.test(l.style.width)?(r.container&&De.get(r.container.style.width,2)||100)+"%":l.style.width,i=r.inlineCover?r.inlineCover.style.height||t.style.height||String(t.height||""):De.get(r.cover?.style.paddingBottom,0)>0&&!e?r.cover?.style.height:/%$/.test(l.style.height)&&/%$/.test(l.style.width)?(r.container&&De.get(r.container.style.height,2)||100)+"%":l.style.height,s||="auto",i||="auto"):this.#J.options.get("strictMode").formatFilter?(s="",i=l.style.height):(s=l.style.width||"auto",i=l.style.height||"auto"),n=e?i:s,o=e?s:i,{w:s,h:i,dw:n,dh:o}}setAlign(t,e){t||=this._element,this.align=e||="none";const s=qi.GetContainer(t);if(!s.cover)return;const i=s.target,n=s.container,o=s.cover;if(/%$/.test(i.style.width)&&"center"===e&&!this.#J.component.isInline(n)?(n.style.minWidth="100%",o.style.width=n.style.width):(n.style.minWidth="",o.style.width=this.isVertical?i.style.height||i.offsetHeight+"px":i.style.width&&"auto"!==i.style.width?i.style.width||"100%":""),Pe.utils.hasClass(n,"__se__float-"+e)||(Pe.utils.removeClass(n,this.#Ks),Pe.utils.addClass(n,"__se__float-"+e)),this.autoRatio){const{w:t,h:e}=this.getSize(this._element);this.__setCoverPaddingBottom(t,e)}this.#di()}convertAsFormat(t,e){t||=this._element,this.as=e||"block";const{container:s,inlineCover:i,target:n}=qi.GetContainer(t),{w:o,h:r}=this.getSize(n),l=Pe.check.isAnchor(n.parentNode)?n.parentNode:null,a=n.cloneNode(!1);a.style.width="",a.style.height="",a.removeAttribute("width"),a.removeAttribute("height");let h=a;if(l){const t=l.cloneNode(!1);t.appendChild(a),h=t}switch(e){case"inline":{if(i)break;this.#J.component.deselect();const t=s.nextElementSibling,e=s.parentElement,n=qi.CreateInlineContainer(h);Pe.utils.addClass(n.container,s.className.split(" ").filter((t=>"se-figure-selected"!==t&&"se-component-selected"!==t)).join("|")),this.#gi(n,o,r);const l=Pe.utils.createElement(this.#J.options.get("defaultLine"),null,n.container);e.insertBefore(l,t),Pe.utils.removeItem(s);break}case"block":{if(!i)break;this.#J.component.deselect(),this.#J.selection.setRange(s,0,s,1);const t=this.#J.html.remove(),e=this.#J.nodeTransform.split(t.container,t.offset,0);e?.previousElementSibling&&Pe.check.isZeroWidth(e.previousElementSibling)&&Pe.utils.removeItem(e.previousElementSibling);const n=qi.CreateContainer(h);Pe.utils.addClass(n.container,s.className.split(" ").filter((t=>"se-inline-component"!==t&&"se-figure-selected"!==t&&"se-component-selected"!==t)).join("|")),this.#gi(n,o,r),(e||t.container).parentElement.insertBefore(n.container,e);break}}return a}controllerAction(t){const e=t.getAttribute("data-command"),s=t.getAttribute("data-value"),i=t.getAttribute("data-type"),n=this._element;if(!/^on.+/.test(e)&&"selectMenu"!==i){switch(e){case"mirror":{const t=Wi(n);let e=t.x,i=t.y;"h"===s&&!this.isVertical||"v"===s&&this.isVertical?i=i?"":"180":e=e?"":"180",this._setRotate(n,t.r,e,i);break}case"rotate":this.setTransform(n,null,null,Number(s));break;case"caption":if(this._caption)Pe.utils.removeItem(this._caption),Oi.setTimeout(this.#J.component.select.bind(this.#J.component,n,this.kind),0),this._caption=null;else{const t=qi.CreateCaption(this._cover,this.#J.lang.caption),e=Pe.query.getEdgeChild(t,(t=>3===t.nodeType),!1);e?this.#J.selection.setRange(e,0,e,e.textContent.length):t.focus(),this._caption=t,this.controller.close()}(/\d+/.test(n.style.height)||this.isVertical&&this._caption)&&(/%$/.test(n.style.width)||/auto/.test(n.style.height)?this.deleteTransform():this.setTransform(n,n.style.width,n.style.height,0));break;case"revert":this._setRevert();break;case"edit":this.inst.componentEdit(n);break;case"copy":this.#J.component.copy(this._container);break;case"remove":this.inst.componentDestroy(n),this.controller.close()}/^__c__/.test(e)?this._action[e](n,s,t):"edit"!==e&&(this.#J.history.push(!1),/^remove|caption$/.test(e)||this.#J.component.select(n,this.kind))}}retainFigureFormat(t,e,s,i){const n=this.#J.component.isInline(t),o=e.parentNode,r=1===o.children?.length&&!o.textContent.replace(Re.zeroWidthRegExp,"").trim();let l=this.#J.format.isBlock(o)||Pe.check.isWysiwygFrame(o)||o.nodeType>=9?e:qi.GetContainer(e)?.container||(r?o:e);if(Pe.query.getParentElement(e,Pe.check.isExcludeFormat))l=s&&s!==e?s:e,l.parentNode.replaceChild(t,l);else if(n&&this.#J.format.isLine(l)){const s=n&&/^SPAN$/i.test(e.parentElement.nodeName)?e.parentElement:e;s.parentElement.replaceChild(t,s)}else if(Pe.check.isListCell(l)){const s=Pe.query.getParentElement(e,(t=>t.parentNode===l));l.insertBefore(t,s),Pe.utils.removeItem(e),this.#J.nodeTransform.removeEmptyNode(s,null,!0)}else if(this.#J.format.isLine(l)){const s=Pe.query.getParentElement(e,(t=>t.parentNode===l));l=this.#J.nodeTransform.split(l,s),l.parentNode.insertBefore(t,l),Pe.utils.removeItem(e),this.#J.nodeTransform.removeEmptyNode(l,null,!0)}else if(this.#J.format.isLine(l.parentNode)){const e=l.parentNode;e.parentNode.insertBefore(t,l.previousSibling?e.nextElementSibling:e),(0===i?.__updateTags.map((t=>l.contains(t))).length||Pe.check.isZeroWidth(l))&&Pe.utils.removeItem(l)}else l=Pe.check.isFigure(l.parentNode)?Pe.query.getParentElement(l.parentNode,qi.is):l,l.parentNode.replaceChild(t,l)}deleteTransform(t){t||=this._element;const e=t,s=(e.getAttribute("data-se-size")||"").split(",");this.isVertical=!1,e.style.maxWidth="",e.style.transform="",e.style.transformOrigin="",this.#mi(e),this._applySize(s[0]||"auto",s[1]||"","")}setTransform(t,e,s,i){try{this.#Ys=!0;const n=Wi(t),o=n.r+1*(i||0);i=Math.abs(o)>=360?0:o;const r=this.isVertical=Ui(i);e=De.get(e,0),s=De.get(s,0);const l=t,a=(l.getAttribute("data-se-size")||"auto,auto").split(",");r&&this._setRotate(l,i,n.x,n.y);let h="";if(/auto|%$/.test(a[0])&&!r)"auto"===a[0]&&"auto"===a[1]?this._setAutoSize():this._setPercentSize(a[0],a[1]);else{const t=qi.GetContainer(l),n=t.cover||t.inlineCover,o=e||l.offsetWidth,a=s||l.offsetHeight,c=(r?a:o)+"px",d=(r?o:a)+"px";if(this.#fi(),this._applySize(o+"px",a+"px",""),n&&(n.style.width=c,n.style.height=t.caption||t.inlineCover?"":d),r){h=90===i||-270===i?a/2+"px "+a/2+"px 0":o/2+"px "+o/2+"px 0"}}l.style.transformOrigin=h,r||this._setRotate(l,i,n.x,n.y),l.style.maxWidth=r?"none":"",this.#vi(l)}finally{this.#Ys=!1}}_displayResizeHandles(t){const e=t?"flex":"none";this.controller&&(this.controller.form.style.display=e);const s=this.#J.frameContext.get("_figure"),i=s.handles;for(let t=0,s=i.length;tthis.#J.component.select(t.target,i),this.#ci(t),t.inlineCover&&(this.setAlign(t.target,"none"),this.deleteTransform()),this.setFigureSize(e,s)}#ci(t){this._inlineCover=t.inlineCover,this._cover=t.cover||this._inlineCover,this._container=t.container,this._caption=t.caption,this._element=t.target,this.align=(this._container.className.match(/(?:^|\s)__se__float-(none|left|center|right)(?:$|\s)/)||[])[1]||t.target.style.float||"none",this.as=this._inlineCover?"inline":"block",this.isVertical=Ui(t.target)}_setRotate(t,e,s,i){let n=(t.offsetWidth-t.offsetHeight)*(/^-/.test(e+"")?1:-1),o="";if(/[1-9]/.test(e+"")&&(s||i))switch(o=s?"Y":"X",e+""){case"90":o=s&&i?"X":i?o:"";break;case"270":n*=-1,o=s&&i?"Y":s?o:"";break;case"-90":o=s&&i?"Y":s?o:"";break;case"-270":n*=-1,o=s&&i?"X":i?o:"";break;default:o=""}e%180==0&&(t.style.maxWidth=""),t.style.transform="rotate("+e+"deg)"+(s?" rotateX("+s+"deg)":"")+(i?" rotateY("+i+"deg)":"")+(o?" translate"+o+"("+n+"px)":"")}_applySize(t,e,s){const i=/^(rw|lw)$/.test(s)&&/\d+/.test(this._element.style.height),n=/^(th|bh)$/.test(s)&&/\d+/.test(this._element.style.width);e=e||(this.autoRatio?this.autoRatio.current||this.autoRatio.default:e),t=De.is(t)?t+this.sizeUnit:t,/%$/.test(t)||/%$/.test(e)||i||n||this.#fi();const o=this._cover||this._element;this.autoRatio&&this._cover&&(this._cover.style.width=t),n||(o.style.width=this._element.style.width=t),i||(e=De.is(e)?e+this.sizeUnit:e,o.style.height=this._element.style.height=this.autoRatio&&!this.isVertical?"100%":e,this.autoRatio&&this._cover&&(this._cover.style.height=e,this.__setCoverPaddingBottom(t,e))),"center"===this.align&&this.setAlign(this._element,this.align),this.#bi()}__setCoverPaddingBottom(t,e){this._inlineCover!==this._cover&&(this.isVertical&&([t,e]=[e,t]),this._cover.style.height=e,/%$/.test(t)&&"center"===this.align?this._cover.style.paddingBottom=/%$/.test(e)?De.get(De.get(e,2)/100*De.get(t,2),2)+"%":e:this._cover.style.paddingBottom=e)}_setAutoSize(){this._caption&&(this._caption.style.marginTop=""),this.deleteTransform(),this.#fi(),this.autoRatio?this._setPercentSize("100%",this.autoRatio.current||this.autoRatio.default):(this._element.style.maxWidth="",this._element.style.width="",this._element.style.height="",this._cover&&(this._cover.style.width="",this._cover.style.height="")),this.setAlign(this._element,this.align),this.#bi()}_setPercentSize(t,e){e||=this.autoRatio?/%$/.test(this.autoRatio.current)?this.autoRatio.current:this.autoRatio.default:e,e=!e||/%$/.test(e+"")||De.get(e,0)?De.is(e)?e+this.sizeUnit:e||(this.autoRatio?this.autoRatio.default:""):De.is(e)?e+"%":e;const s=/%$/.test(e+"");this._container.style.width=String(De.is(t)?t+"%":t),this._container.style.height="",this._element!==this._cover||this.#J.options.get("strictMode").formatFilter?(this._inlineCover!==this._cover&&this._cover&&(this._cover.style.width="100%",this._cover.style.height=String(e)),this._element.style.width="100%",this._element.style.maxWidth="",this._element.style.height=String(this.autoRatio?"100%":s?"":e),"center"===this.align&&this.setAlign(this._element,this.align),this.autoRatio&&this.__setCoverPaddingBottom(String(t),String(e)),this.#vi(this._element),this.#bi()):this.#bi()}#fi(){this._cover&&(this._cover.style.width="",this._cover.style.height=""),this._container.style.width="",this._container.style.height="",Pe.utils.removeClass(this._container,this.#Ks),Pe.utils.addClass(this._container,"__se__float-"+this.align),"center"===this.align&&this.setAlign(this._element,this.align)}_setRevert(){this.setFigureSize(this.#Xs.w,this.#Xs.h)}#di(){this.alignButton&&Pe.utils.changeElement(this.alignButton.firstElementChild,this._alignIcons[this.align])}#ui(){this.asButton&&Pe.utils.changeElement(this.asButton.firstElementChild,this.#J.icons[`as_${this.as}`])}#bi(){if(this.#Ys)return;const t=(this._element.getAttribute("data-se-size")||",").split(",");this.#Xs.w=t[0],this.#Xs.h=t[1];const e=this.getSize(this._element);this._element.setAttribute("width",e.w.replace("px","")),this._element.setAttribute("height",e.h.replace("px","")),this._element.setAttribute("data-se-size",e.w+","+e.h),this.autoRatio&&(this.autoRatio.current=/%$/.test(e.h)?e.h:"")}#vi(t){const e=Pe.query.getEdgeChild(Pe.query.getParentElement(t,"FIGURE"),"FIGCAPTION",!1);e&&(e.style.marginTop=(this.isVertical&&!this.autoRatio?t.offsetWidth-t.offsetHeight:0)+"px",this.isVertical&&this.autoRatio?t.style.marginTop=e.offsetHeight+"px":t.style.marginTop="")}#mi(t){const e=Pe.query.getEdgeChild(Pe.query.getParentElement(t,"FIGURE"),"FIGCAPTION",!1);e&&(e.style.marginTop="")}#yi(){this.#J.component.__removeDragEvent(),this.#hi(),this._displayResizeHandles(!0),this.#J.ui.offCurrentController(),this.#J.ui.disableBackWrapper()}#hi(){this.#J.eventManager.removeGlobalEvent(this.__onContainerEvent),this.#J.eventManager.removeGlobalEvent(this.__offContainerEvent),this.#J.eventManager.removeGlobalEvent(this.#Zs)}#pi(t){const e=this.#J.frameContext.get("wrapper").querySelector(".se-drag-handle");Pe.utils.removeClass(e,"se-drag-handle-full"),e.style.opacity="",e.style.width="",e.style.height="",Ci.set("__dragHandler",e),Ci.set("__dragContainer",this._container),Ci.set("__dragCover",this._cover),Ci.set("__dragMove",this.#wi.bind(this,e,t)),Ci.get("__dragMove")(),e.style.display="block"}#wi(t,e){t.style.display="block",t.style.left=e.offsetLeft+(this.#J.options.get("_rtl")?t.offsetWidth:e.offsetWidth-1.5*t.offsetWidth)+"px",t.style.top=e.offsetTop-t.offsetHeight+.5+"px"}#ai(t){t.stopPropagation(),t.preventDefault();const e=Ci.get("__figureInst");if(!e)return;const s=Pe.query.getEventTarget(t),i=e._resize_direction=s.classList[0];e._resizeClientX=t.clientX,e._resizeClientY=t.clientY,this.#J.frameContext.get("_figure").main.style.float=/l/.test(i)?"right":/r/.test(i)?"left":"none",this.#J.ui.enableBackWrapper(zi[i]);const{w:n,h:o,dw:r,dh:l}=this.getSize(e._element);if(Pi=Di=!1,Fi=Hi=0,!this.isVertical){const t=!n||/auto|%$/.test(n),s=!o||/auto|%$/.test(o);if("tl|bl|tr|br".includes(i)&&t&&s?Pi=!0:"lw|rw".includes(i)&&t&&(Di=!0),Pi||Di){const t=e._cover||e._element;Hi=t.offsetWidth,Fi=ze.getWidthInPercentage(t,this.#J.frameContext.get("wysiwygFrame"))/100}}e.__onContainerEvent=this.#J.eventManager.addGlobalEvent("mousemove",e.__containerResizing),e.__offContainerEvent=this.#J.eventManager.addGlobalEvent("mouseup",e.__containerResizingOff),e._displayResizeHandles(!1);const a=this.#J.frameContext.get("_figure").display;a.style.display="block",Pe.utils.changeTxt(a,r+" * "+l)}#si(t){const e=this._resize_direction,s=t.clientX,i=t.clientY,n=this.isVertical;let o=n?this.#Gs:this.#js,r=n?this.#js:this.#Gs;const l=o+(/r/.test(e)?s-this._resizeClientX:this._resizeClientX-s),a=r+(/b/.test(e)?i-this._resizeClientY:this._resizeClientY-i),h=r/o*l,c=this.#J.frameContext.get("_figure").border;/t/.test(e)&&(c.style.top=r-(/h/.test(e)?a:h)+"px"),/l/.test(e)&&(c.style.left=o-l+"px"),/r|l/.test(e)&&(c.style.width=l+"px",o=l),/^(t|b)[^h]$/.test(e)?(c.style.height=h+"px",r=h):/^(t|b)h$/.test(e)&&(c.style.height=a+"px",r=a);const d=!n&&/h$/.test(e)?this.#qs:Math.round(o),u=!n&&/w$/.test(e)?this.#Ws:Math.round(r),p=Fi?d/Hi*Fi*100:d;Pe.utils.changeTxt(this.#J.frameContext.get("_figure").display,Fi?De.get(p>100?100:p,2).toFixed(2)+"%":p+" * "+u),this.#Us=d,this.#Vs=u}#ei(){this.#yi();let t=this.isVertical?this.#Vs:this.#Us,e=this.isVertical?this.#Us:this.#Vs;if(t=Math.round(t)||t,e=Math.round(e)||e,!this.isVertical&&!/%$/.test(t+"")){const s=this.#J.frameContext.get("wysiwygFrame").clientWidth-De.get(this.#J.frameContext.get("wwComputedStyle").getPropertyValue("padding-left"))+De.get(this.#J.frameContext.get("wwComputedStyle").getPropertyValue("padding-right"))-2;De.get(t,0)>s&&(e=Math.round(e/t*s),t=s)}if(Pi||Di){t=t/(this._cover||this._element).offsetWidth*Fi*100;const e=De.get(t>100?100:t,2)+"%";this._setPercentSize(e,Di?this.getSize(this._element).h:"")}else this._applySize(t,e,this._resize_direction),this.isVertical&&this.setTransform(this._element,t,e,0);this.#J.history.push(!1),this.#J.component.select(this._element,this.kind)}#ni(t){Fe.isEsc(t.code)&&(this.#yi(),this.#J.component.select(this._element,this.kind))}#Js(t){this.setAlign(this._element,t),this.selectMenu_align.close(),this.#J.component.select(this._element,this.kind),this.#J.history.push(!1)}#Qs(t){this.convertAsFormat(this._element,t),this.selectMenu_as.close(),this.#J.history.push(!1)}#ti(t){if("auto"===t)this.deleteTransform(),this._setAutoSize();else{let e=this.getSize(this._element).h;if(this.isVertical){const t=(this._element.getAttribute("data-se-size")||",").split(",");t[1]&&(e=t[1])}this.deleteTransform(),this._setPercentSize(1*t,null!==De.get(e,0)&&/%$/.test(e)?e:"")}this.selectMenu_resize.close(),this.#J.component.select(this._element,this.kind),this.#J.history.push(!1)}#ii(){const t=this.#J.frameContext.get("_figure");t.main.style.display="none",this.#J.ui.setFigureContainer(null),this.#J.ui.opendControllers=this.#J.ui.opendControllers.filter((e=>e.form!==t.main))}#oi(){this.selectMenu_align.open("",'[data-command="'+this.align+'"]')}#ri(){this.selectMenu_as.open("",'[data-command="'+this.as+'"]')}#li(){const t=this.getSize(this._element),e=t.w,s=t.h;let i="";if(this.autoRatio){if(s===this.autoRatio.default&&/%$/.test(e)){const t=De.get(e);i=100===t?"auto":"resize_percent"+t}}else"auto"===s&&("auto"===e?i="auto":/%$/.test(e)&&(i="resize_percent"+De.get(e)));this.selectMenu_resize.open("",'[data-command="'+i+'"]')}}function Wi(t){const e=t.style.transform;return e?{r:Number((e.match(/rotate\(([-0-9]+)deg\)/)||[])[1]||0),x:(e.match(/rotateX\(([-0-9]+)deg\)/)||[])[1]||"",y:(e.match(/rotateY\(([-0-9]+)deg\)/)||[])[1]||""}:{r:0,x:"",y:""}}function Ui(t){return/^(90|270)$/.test(Math.abs(De.is(t)?t:Wi(t).r).toString())}function Vi(t){const e=t.split("_"),s=e[0],i=e[1];let n,o,r,l;switch(s){case"resize":n="onresize",o=i,r="resize",l="resize";break;case"auto":n="auto",r="autoSize",l="auto_size";break;case"rotate":n="rotate",o="l"===i?-90:"r"===i?90:De.get(i),r=o<0?"rotateLeft":"rotateRight",l=o<0?"rotate_left":"rotate_right";break;case"mirror":n="mirror",o=i,r="h"===i?"mirrorHorizontal":"mirrorVertical",l="h"===i?"mirror_horizontal":"mirror_vertical";break;case"align":n="onalign",r="align",l="align_justify";break;case"caption":n="caption",r="caption",l="caption";break;case"revert":n="revert",r="revert",l="revert";break;case"edit":n="edit",r="edit",l="edit";break;case"as":n="onas",r="blockStyle",l="as_block";break;case"copy":n="copy",r="copy",l="copy";break;case"remove":n="remove",r="remove",l="delete"}return n?{c:n,v:o,l:r,t:undefined,i:l}:null}const ji=qi,{_w:Gi,ON_OVER_COMPONENT:Ki,isMobile:Yi}=Oe,Xi=/^Arrow(Left|Up|Right|Down)$/,Zi=/^Arrow(Left|Up)$/;function Ji(t,e,s){t.preventDefault(),t.stopPropagation(),Qi(e),s.setData("text/html",e.outerHTML)}function Qi(t){Pe.utils.removeClass(t,"se-component-selected"),Pe.utils.removeClass(t.querySelectorAll(".se-figure-selected"),"se-figure-selected"),Pe.utils.removeClass(t.querySelectorAll(".se-selected-table-cell"),"se-selected-table-cell"),Pe.utils.removeClass(t.querySelector(".se-selected-cell-focus"),"se-selected-cell-focus")}const tn=class{#H;#J;#t;#Ci;#ot;#rt;#X;#_i;#it;#ki=null;#xi=null;#$i=null;#ls=null;constructor(t){this.#H=t,this.#J=t.$,this.#t=t.store,this.#Ci=this.#J.contextProvider,this.#ot=this.#Ci.carrierWrapper,this.#rt=this.#J.options,this.#X=this.#J.frameContext,this.#_i=this.#J.eventManager,this.info=null,this.isSelected=!1,this.currentTarget=null,this.currentPlugin=null,this.currentPluginName="",this.currentInfo=null,this.#it={copy:this.#Si.bind(this),cut:this.#Ei.bind(this),keydown:this.#Ti.bind(this),mousedown:this.#Pe.bind(this)},this.__selectionSelected=!1,this.__prevent=!1}_init(){this.#Ci.applyToRoots((t=>{const e=Pe.utils.createElement("DIV",{class:"se-drag-handle",draggable:"true"},this.#Ci.icons.selection);t.get("wrapper").appendChild(e),this.#_i.addEvent(e,"mouseenter",this.#Mi.bind(this)),this.#_i.addEvent(e,"mouseleave",this.#Ni.bind(this)),this.#_i.addEvent(e,"dragstart",this.#Bi.bind(this)),this.#_i.addEvent(e,"dragend",this.#Ii.bind(this)),this.#_i.addEvent(e,"click",this.#Li.bind(this))}))}insert(t,{skipCharCount:e=!1,skipHistory:s=!1,scrollTo:i=!0,insertBehavior:n}={}){if(this.#X.get("isReadOnly")||!e&&!this.#J.char.check(t))return null;void 0===n&&(n=this.#rt.get("componentInsertBehavior")),this.isSelected&&this.__deselect();const o=this.#J.html.remove(),r=this.isInline(t);this.#J.selection.getRangeAndAddLine(this.#J.selection.getRange(),o.container);const l=this.#J.selection.getNode();let a=null,h=this.#J.format.getLine(l,null);try{if(Pe.check.isListCell(h))this.#J.html.insertNode(t,{afterNode:r?null:Pe.check.isZeroWidth(l)?(l||o.container||{}).nextSibling:null,skipCharCount:!0}),r||t.nextSibling||t.parentNode.appendChild(Pe.utils.createElement("BR"));else{if(!r&&this.#J.selection.getRange().collapsed&&(3===o.container?.nodeType||Pe.check.isBreak(o.container))){const t=Pe.query.getParentElement(o.container,this.#J.format.isBlock.bind(this.#J.format));a=this.#J.nodeTransform.split(o.container,o.offset,t?Pe.query.getNodeDepth(t)+1:0),a&&(h=a.previousSibling)}this.#J.html.insertNode(t,{afterNode:r||this.#J.format.isBlock(h)?null:h,skipCharCount:!0}),!r&&h&&Pe.check.isZeroWidth(h)&&Pe.utils.removeItem(h)}if(r){const e=Pe.utils.createTextNode(Re.zeroWidthSpace);t.parentNode.insertBefore(e,t.nextSibling)}}catch(t){console.error("Component insert error:",t)}s||this.#J.history.push(!1),this.#X.has("documentType_use_header")&&this.#X.get("documentType").reHeader();const c=a||t;return i&&this.#J.selection.scrollTo(c,{behavior:"auto",noFocus:!0}),null!==n&&this.applyInsertBehavior(t,a,n),c}applyInsertBehavior(t,e,s){const i=this.get(t);if(this.isInline(t)){const e=this.#J.selection.getNearRange(t);e?this.#J.selection.setRange(e.container,e.offset,e.container,e.offset):this.select(i.target,i.pluginName)}else switch(s){case"auto":this.#Ai(t)||this.select(i.target,i.pluginName);break;case"select":this.#J.selection.setRange(t,0,t,0),i?this.select(i.target,i.pluginName):e&&(e=Pe.query.getEdgeChildNodes(e,null).sc||e,this.#J.selection.setRange(e,0,e,0));break;case"line":if(!this.#Ai(t)){const e=this.#J.format.addLine(t,null);e&&this.#J.selection.setRange(e,0,e,0)}}}get(t){if(!t)return null;let e,s="",i={},n=!1,o=null;if(this.is(t)){if(Pe.check.isComponentContainer(t)&&!Pe.utils.hasClass(t,"se-inline-component")&&(t=t.firstElementChild||t),/^FIGURE$/i.test(t.nodeName)&&(t=t.firstElementChild),!t)return null;const n=this.#J.pluginManager.findComponentInfo(t);if(!n)return null;e=n.target,s=n.pluginName,i=n.options,o=n.launcher}if(!e&&t.nodeName){this.#Oi(t)&&(n=!0);const r=this.#J.pluginManager.findComponentInfo(t);if(!r)return null;e=r.target,s=r.pluginName,i=r.options,o=r.launcher}if(!e)return null;const r=ji.GetContainer(e),l=r.container||r.cover||e;return this.info={target:r.target,pluginName:s,options:i,container:l,cover:r.cover,inlineCover:r.inlineCover,caption:r.caption,isFile:n,launcher:o,isInputType:Pe.utils.hasClass(l,"se-input-component")}}select(t,e,{isInput:s=!1}={}){const i=this.get(t);if(!i||Pe.check.isUneditable(Pe.query.getParentElement(t,this.is.bind(this)))||Pe.check.isUneditable(t))return!1;const n=i.launcher||this.#J.plugins[e];if(!n)return;const o=_i.get("__overInfo")!==Ki;if(!s&&o){if(this.#t.get("_mousedown"))return;this.#t.set("_preventBlur",!0),this.__selectionSelected=!0,this.isInline(i.container)&&this.#J.selection.setRange(i.container,0,i.container,0),this.#J.focusManager.blur(),Gi.setTimeout((()=>{this.__selectionSelected=!1}))}let r;this.isSelected=!0,this.__prevent=!0,"function"==typeof n.componentSelect&&(r=n.componentSelect(t));const l=Pe.utils.hasClass(i.target,"se-component-line-break");(l||!r&&!Pe.utils.hasClass(i.container,"se-inline-component"))&&this._setComponentLineBreaker(i.container||i.cover||t),this.currentTarget=t,this.currentPlugin=n,this.currentPluginName=e,this.currentInfo=i,_i.set("__dragInst",this);const a=_i.get("__overInfo");if(Gi.setTimeout((()=>{_i.set("__overInfo",a===Ki&&void 0),a!==Ki&&this.#qe(),i.isFile||this.#Ri(),Pe.utils.addClass(i.container,"se-component-selected")}),0),!o||this.#t.get("hasFocus")||this.#t.get("_preventFocus")||(this.#H._eventOrchestrator.__postFocusEvent(this.#X,null),this.#t.set("_preventFocus",!0)),l||a===Ki){if(l||!Pe.utils.hasClass(i.container,"se-input-component")){const t=this.#X.get("wrapper").querySelector(".se-drag-handle");Pe.utils.addClass(t,"se-drag-handle-full"),this.#J.ui._visibleControllers(!1,!1);const e=i.caption?i.target:i.cover||i.container||i.target,s=e.offsetWidth,n=e.offsetHeight,{top:o,left:r}=this.#J.offset.getLocal(e);t.style.opacity="0",t.style.width=s+"px",t.style.height=n+"px",t.style.top=o+"px",t.style.left=r+"px",_i.set("__dragHandler",t),_i.set("__dragContainer",i.container),_i.set("__dragCover",i.cover),t.style.display="block"}}else{if(!this.isInline(i.container))return;const t=i.container;let e=null;t.previousSibling&&!Pe.check.isBreak(t.previousSibling)||(e=Pe.utils.createTextNode(Re.zeroWidthSpace),t.parentNode.insertBefore(e,t)),t.nextSibling&&!Pe.check.isBreak(t.nextSibling)||(e=Pe.utils.createTextNode(Re.zeroWidthSpace),t.parentNode.insertBefore(e,t.nextSibling)),this.#t.set("controlActive",!0)}}deselect(){Gi.setTimeout((()=>{this.#t.set("controlActive",!1)}),0),this.__deselect(),this.#J.ui.setControllerOnDisabledButtons(!1),!this.#t.get("_preventFocus")||this.#t.get("hasFocus")||this.__prevent||(this.#H._eventOrchestrator.__postBlurEvent(this.#X,null),this.#t.set("_preventFocus",!1))}is(t){return!!t&&(!(!/^FIGURE$/i.test(t.nodeName)&&!Pe.check.isComponentContainer(t))||!!this.#J.pluginManager.findComponentInfo(t))}isInline(t){if(!t)return!1;if(/^FIGURE$/i.test(t.nodeName)&&(t=t.parentElement),Pe.utils.hasClass(t,"se-inline-component"))return!0;return!(!this.#J.pluginManager.findComponentInfo(t)||!Pe.utils.hasClass(t,"se-inline-component")&&!Pe.utils.hasClass(t.parentElement,"se-inline-component"))}isBasic(t){return this.is(t)&&!this.isInline(t)}async copy(t){const e=Pe.utils.clone(t,!0);Qi(e),!1!==await this.#J.html.copy(e)&&Pe.utils.flashClass(t,"se-copy")}hoverSelect(t){const e=Pe.query.getParentElement(t,Pe.check.isFigure);let s=this.get(t);s||e?(s||=this.get(e),s&&!Pe.utils.hasClass(s.container,"se-component-selected")&&(this.#J.ui.offCurrentController(),_i.set("__overInfo",Ki),this.select(s.target,s.pluginName))):null===_i.get("__overInfo")||Pe.utils.hasClass(t,"se-drag-handle")||(this.__deselect(),_i.set("__overInfo",null))}__deselect(){if(this.#t.set("_preventBlur",!1),_i.set("__overInfo",null),this.__removeDragEvent(),this.currentInfo){const t=this.currentInfo.container,e=this.currentInfo.cover;Gi.setTimeout((()=>{Qi(t),Pe.utils.removeClass(e,"se-figure-over-selected")}),0)}this.#X.get("lineBreaker_t")&&(this.#X.get("lineBreaker_t").style.display=this.#X.get("lineBreaker_b").style.display="none"),this.currentPlugin&&this.currentPlugin.componentDeselect?.(this.currentTarget),this.isSelected=!1,this.currentPlugin=null,this.currentTarget=null,this.currentPluginName="",this.currentInfo=null,this.__removeGlobalEvent(),this.#J.ui._offControllers()}_setComponentLineBreaker(t){const e=_i.get("__overInfo")===Ki;this.#H._eventOrchestrator._lineBreakComp=null;const s=this.get(t);if(!s)return;const i=this.#X,n=s.container,o=Pe.utils.hasClass(n,"se-flex-component"),r=i.get("lineBreaker_t"),l=i.get("lineBreaker_b"),a=r.style,h=l.style,c=n.offsetWidtht.hasAttribute(e))))}#Mi(){this.#t.set("_preventBlur",!0),this.#J.ui._visibleControllers(!1,Pe.utils.hasClass(_i.get("__dragHandler"),"se-drag-handle-full")),Pe.utils.addClass(_i.get("__dragCover")||_i.get("__dragContainer"),"se-drag-over")}#Ni(){this.#t.set("_preventBlur",!1),Pe.utils.hasClass(_i.get("__dragHandler"),"se-drag-handle-full")||this.#J.ui._visibleControllers(!0,!0),Pe.utils.removeClass([_i.get("__dragCover"),_i.get("__dragContainer")],"se-drag-over")}#Bi(t){const e=_i.get("__dragCover")||_i.get("__dragContainer");e?(this.#t.set("_preventBlur",!1),Pe.utils.addClass(_i.get("__dragHandler"),"se-dragging"),Pe.utils.addClass(_i.get("__dragContainer"),"se-dragging"),t.dataTransfer.setDragImage(e,this.#rt.get("_rtl")?e.offsetWidth:-5,-5)):t.preventDefault()}#Ii(){this.#t.set("_preventBlur",!1),Pe.utils.removeClass([_i.get("__dragHandler"),_i.get("__dragContainer")],"se-dragging"),this.__removeDragEvent()}#Li(t){const e=Pe.query.getEventTarget(t);if(!Pe.utils.hasClass(e,"se-drag-handle-full"))return;const s=_i.get("__dragInst");s&&(this.__removeDragEvent(),this.select(s.currentTarget,s.currentPluginName))}#Pe(t){const e=Pe.query.getEventTarget(t);this.currentTarget?.contains(e)||Pe.query.getParentElement(e,".se-controller")||Pe.utils.hasClass(e,"se-drag-handle")||this.currentPluginName===this.#J.ui.currentControllerName&&this.#J.ui.opendControllers.some((({form:t})=>t.contains(e)))||this.deselect()}#Si(t){const e=Pe.query.getEventTarget(t);if(Pe.check.isInputElement(e)&&Pe.query.getParentElement(e,".se-modal"))return;const s=this.info;if(!s)return;const i=s.container.cloneNode(!0);"function"==typeof this.#J.plugins[s.pluginName]?.componentCopy&&!1!==this.#J.plugins[s.pluginName].componentCopy({event:t,cloneContainer:i,info:s})||Ji(t,i,t.clipboardData),Pe.utils.flashClass(s.container,"se-copy")}#Ei(t){const e=this.info;if(!e)return;const s=e.container.cloneNode(!0);Pe.utils.removeClass(s,"se-component-selected"),Ji(t,s,t.clipboardData),this.deselect(),Pe.utils.removeItem(e.container)}async#Ti(t){if(this.#J.ui.selectMenuOn)return;const e=t.code;if(Fe.isCtrl(t)){if("ControlRight"!==e&&"ControlLeft"!==e){const s=this.#J.shortcuts.keyMap.get(e+(t.shiftKey?"1000":""));/^(redo|undo)$/.test(s?.command)&&(t.preventDefault(),t.stopPropagation(),this.#J.commandDispatcher.run(s.command,s.type,s.button))}}else if(!Fe.isRemoveKey(e)||(t.preventDefault(),t.stopPropagation(),"function"!=typeof this.currentPlugin?.componentDestroy||this.info.isInputType&&this.#t.get("hasFocus"))){if(Fe.isEnter(e)){t.preventDefault();const e=this.currentInfo||this.get(this.currentTarget),s=e.container||e.target,i=s.previousElementSibling||s.nextElementSibling;let n=null;n=Pe.check.isListCell(s.parentNode)?Pe.utils.createElement("BR"):Pe.utils.createElement(this.#J.format.isLine(i)?i.nodeName:this.#rt.get("defaultLine"),null,"
    ");const o=this.currentPluginName;return this.deselect(),s.parentNode.insertBefore(n,s),!1===this.select(e.target,o)&&this.#J.focusManager.blur(),void this.#J.history.push(!1)}if(Xi.lastIndex=0,Xi.test(e)){const{container:s}=this.get(this.currentTarget);let i=null,n=1;if(this.isInline(s||this.currentTarget))switch(e){case"ArrowLeft":i=s.previousSibling,n=3===i?.nodeType?i.textContent.length:1;break;case"ArrowRight":i=s.nextSibling,n=0;break;case"ArrowUp":{const t=this.#J.format.getLine(s,null);i=t?.previousElementSibling,n=0;break}case"ArrowDown":{const t=this.#J.format.getLine(s,null);i=t?.nextElementSibling;break}}else Zi.lastIndex=0,Zi.test(e)?i=s.previousElementSibling:(i=s.nextElementSibling,n=0);if(!i)return;this.deselect();const o=this.get(i);if(o?.container)t.stopPropagation(),t.preventDefault(),this.select(o.target,o.pluginName);else try{this.#t.set("_preventBlur",!0),t.stopPropagation(),t.preventDefault(),this.#J.selection.setRange(i,n,i,n)}finally{this.#t.set("_preventBlur",!1)}}else Fe.isEsc(e)&&this.deselect()}else{const t=this.info.container.previousSibling;if(await this.currentPlugin.componentDestroy(this.currentTarget),this.deselect(),t){const e=3===t.nodeType?t.textContent.length:1;this.#J.selection.setRange(t,e,t,e)}else this.#J.focusManager.focus()}}_destroy(){this.__removeGlobalEvent(),this.__removeDragEvent()}};const en=class{#H;#J;#Pi;#Ci;#rt;#Di;#Fi;#Hi=[];#qi=[];#Wi={tags:null,regExp:null,pluginRegExp:null,pluginMap:null};#Ui=[];#Vi=new Map;#ji=new Map([["onMouseMove",[]],["onMouseLeave",[]],["onMouseDown",[]],["onMouseUp",[]],["onScroll",[]],["onClick",[]],["onBeforeInput",[]],["onInput",[]],["onKeyDown",[]],["onKeyUp",[]],["onFocus",[]],["onBlur",[]],["onPaste",[]],["onFilePasteAndDrop",[]]]);constructor(t,e){this.#H=t,this.#J=t.$,this.#Pi=e.plugins||{},this.#Ci=this.#J.contextProvider,this.#rt=this.#J.options,this.#Di=e.pluginCallButtons,this.#Fi=e.pluginCallButtons_sub}get plugins(){return this.#Pi}get fileInfo(){return this.#Wi}findComponentInfo(t){for(const e of this.#Ui){const s=e(t);if(s)return s}return null}applyRetainFormat(t){let e;(e=this.#rt.get("__pluginRetainFilter"))&&this.#Vi.forEach(((s,i)=>{let n;try{n=t.querySelectorAll(i)}catch(t){return void console.warn(`[SUNEDITOR.retainFormat.fail]-[${s.key}]`,t.message)}for(let t=0,i=n.length;t{if("function"==typeof i[s]){const n=i[s].bind(i);n.index=e[`eventIndex_${s}`]||e.eventIndex||0,t.push(n)}})),i.retainFormat){const t=i.retainFormat();this.#Vi.set(t.query,{key:i.constructor.key,method:t.method})}}for(const t of this.#ji.values())t.sort(((t,e)=>t.index-e.index));(this.#rt.get("buttons").has("pageBreak")||this.#rt.get("buttons_sub")?.has("pageBreak"))&&this.#Ui.push(function(t,e,s){if(!s||!Pe.utils.hasClass(s,"se-page-break"))return null;return{target:s,launcher:{componentDestroy:s=>{const i=s.previousElementSibling||s.nextElementSibling;Pe.utils.removeItem(s),t.focusEdge(i),e.push(!1)}}}}.bind(null,this.#J.focusManager,this.#J.history)),this.#Wi.regExp=new RegExp(`^(${this.#Wi.tags.join("|")||"\\^"})$`,"i"),this.#Wi.pluginRegExp=new RegExp(`^(${0===s.length?"\\^":s.join("|")})$`,"i"),this.#Di=null,this.#Fi=null}get(t){return this.#Pi[t]}_destroy(){for(const t in this.#Pi){const e=this.#Pi[t];e._destroy?.(),e.editor=null}this.#Pi=null,this.#Wi=null,this.#Ui=null,this.#ji?.clear(),this.#Vi?.clear()}};class sn{#H;#J;#t;#rt;#X;#Q;constructor(t){this.#H=t,this.#J=t.$,this.#t=t.store,this.#rt=this.#J.options,this.#X=this.#J.frameContext,this.#Q=this.#J.frameOptions}focus(t){if(t&&this.#J.facade.changeFrameContext(t),"none"!==this.#X.get("wysiwygFrame").style.display){if(this.#t.set("_preventBlur",!1),this.#Q.get("iframe")||!this.#X.get("wysiwyg").contains(this.#J.selection.getNode()))this.nativeFocus();else try{const t=this.#J.selection.getRange();if(t.startContainer===t.endContainer&&Pe.check.isWysiwygFrame(t.startContainer)){const e=t.commonAncestorContainer.children[t.startOffset];if(!this.#J.format.isLine(e)&&!this.#J.component.is(e)){const t=Pe.utils.createElement("BR"),s=Pe.utils.createElement(this.#rt.get("defaultLine"),null,t);return this.#X.get("wysiwyg").insertBefore(s,e),void this.#J.selection.setRange(t,0,t,0)}}this.#J.selection.setRange(t.startContainer,t.startOffset,t.endContainer,t.endOffset)}catch(t){console.warn("[SUNEDITOR.focus.warn] ",t),this.nativeFocus()}this.#t.mode.isBalloon&&this.#H._eventOrchestrator._toggleToolbarBalloon()}}focusEdge(t){this.#t.set("_preventBlur",!1),t||=this.#X.get("wysiwyg").lastElementChild;const e=this.#J.component.get(t);e?this.#J.component.select(e.target,e.pluginName):t?(3!==t.nodeType&&(t=Pe.query.getEdgeChild(t,(function(t){return 0===t.childNodes.length||3===t.nodeType}),!0)),t?this.#J.selection.setRange(t,t.textContent.length,t,t.textContent.length):this.nativeFocus()):this.focus()}nativeFocus(){this.#J.selection.__focus(),this.#J.selection.init()}blur(){this.#Q.get("iframe")?this.#X.get("wysiwygFrame").blur():this.#X.get("wysiwyg").blur()}}const nn=/^H[1-6]$/,on=/^(UL|OL)$/,rn=/^LI$/,ln=/^(THEAD|TBODY|TR|TD|TH)$/;function an(t){let e=t;for(;e&&!tt(e);){if("TABLE"===e.nodeName)return e;e=e.parentNode}return null}function hn(t){let e=t;for(;e&&!tt(e);){if(1===e.nodeType&&Q(e))return!0;e=e.parentNode}return!1}function cn(t){let e=t,s=null;for(;e&&!tt(e);)1===e.nodeType&&Q(e)&&(s=e),e=e.parentNode;return s&&s.parentNode&&tt(s.parentNode)?s:null}function dn(t,e){const s=t.querySelector(":scope > ul, :scope > ol");if(!s)return null;if(e=r.top&&e<=r.bottom)return dn(s,e)||s;const l=Math.min(Math.abs(e-r.top),Math.abs(e-r.bottom));l=r.top&&e<=r.bottom)return dn(o,e)||o;const l=Math.min(Math.abs(e-r.top),Math.abs(e-r.bottom));l{this.#sn(),this.#in(),i?.()},subCheckMethod:t=>this.#Zi.has(t),subEscMethod:()=>{if(!this.#Ji)return!1;const t=this.#Ji.anchorLi;this.#sn();const e=t?Number(t.getAttribute("data-index")):NaN;return Number.isNaN(e)||this.selectMenu.setItem(e),!0}})}attach(t,e,s={}){this.selectMenu.on(t,e,s),this.#J.eventManager.addEvent(this.selectMenu.form,"mousedown",(t=>{Oe.isMobile||Pe.check.isInputElement(Pe.query.getEventTarget(t))?this.#J.store.set("_preventBlur",!0):t.preventDefault()})),this.#J.eventManager.addEvent(this.selectMenu.form,"mousemove",this.#nn.bind(this))}setItems(t){this.#Ki=Array.isArray(t)?t:[],this.#Yi=null}getItems(){if(this.#Yi)return this.#Yi;const t=[];for(const i of this.#Ki)if("string"==typeof i){const e=this.#Gi(i,this.#J.plugins,this.#J.options,this.#J.icons,this.#J.lang);if(!e)continue;const s=e.type||"";if(/dropdown-free/.test(s)){t.push({kind:"dropdownFree",title:e.title,iconHTML:e.icon||"",search:(e.title+" "+i).toLowerCase(),name:i,type:s});continue}if(/dropdown/.test(s)){const s=this.#J.menu?.itemsMap?.[i]||[];if(s.length>0){t.push({kind:"submenu",title:e.title,iconHTML:e.icon||"",search:(e.title+" "+i).toLowerCase(),name:i,children:s.map((t=>({pluginName:i,element:t._element}))),childMenus:s.map((t=>{const e=t._element?.querySelector(".se-list-icon")||t._element?.querySelector("svg"),s=e?e.outerHTML:"";return`${s?`${s}${t.title}`:t.title}`}))});continue}}t.push({kind:"plugin",title:e.title,iconHTML:e.icon||"",search:(e.title+" "+i).toLowerCase(),name:i,type:s,command:e.command})}else if(i&&"object"==typeof i&&"function"==typeof i.action){const n=i.title||i.key||"",o=Array.isArray(i.keywords)?i.keywords.join(" "):"";t.push({kind:"custom",title:n,iconHTML:(e=i.icon,s=this.#J.icons,e&&"string"==typeof e?"<"===e.charAt(0)?e:s[e]||"":""),search:(n+" "+o).toLowerCase(),raw:i})}var e,s;return this.#Yi=t,t}filter(t,e=1/0){const s=this.getItems(),i=(t||"").toLowerCase().trim(),n=[];for(const t of s)if(i&&-1===t.search.indexOf(i)||n.push(t),n.length>=e)break;return n}renderRows(t){const e={icons:this.#J.icons},s=`${this.#J.icons.menu_arrow_right}`;return t.map((t=>{if("custom"===t.kind&&this.#Xi)return this.#Xi(t.raw,e);const i=(n=t.title,``);var n,o;return"dropdownFree"===t.kind?i+s:i}))}createRows(t){this.#in();const e=t.map((t=>"submenu"===t.kind?{children:t.children,childMenus:t.childMenus}:t));this.selectMenu.create(e,this.renderRows(t)),this.#Zi.clear(),this.#tn.length=0,t.forEach(((t,e)=>{"dropdownFree"===t.kind&&this.#Zi.set(e,{name:t.name,plugin:this.#J.plugins[t.name],li:this.selectMenu.menus[e]}),"plugin"!==t.kind&&"dropdownFree"!==t.kind||this.#tn.push({name:t.name,idx:e})})),this.selectMenu.isOpen&&this.#on()}open(t){this.selectMenu.open(t),0===this.#en.length&&this.#on()}close(){this.#in(),this.selectMenu.close()}hasOpenSubPanel(){return this.selectMenu.hasOpenSubmenu()||!!this.#Ji}#on(){const t=this.#J.commandDispatcher;for(const{name:e,idx:s}of this.#tn){const i=this.#rn(s);i&&(t.registerTargets(e,i),this.#en.push({name:e,target:i}))}this.#J.store.set("_lastSelectionNode",null),this.#J.eventManager.applyTagEffect()}#in(){if(0===this.#en.length)return;const t=this.#J.commandDispatcher;for(const{name:e,target:s}of this.#en)t.unregisterTargets(e,s);this.#en.length=0}#rn(t){const e=this.selectMenu.menus[t];return e?e.querySelector("button.se-cmd-row")||e:null}setItem(t){this.selectMenu.setItem(t)}setHidden(t){this.selectMenu.setHidden(t)}get isOpen(){return this.selectMenu.isOpen}dispatch(t,e){if(!t)return!1;const s=t;if(s.pluginName&&s.element){const t=this.#J.plugins[s.pluginName];return t?.action?.(s.element),this.#J.history.push(!1),!0}const i=t;if("custom"===i.kind){try{i.raw.action(this.#J,e)}catch(t){console.error("[SUNEDITOR.commandMenu.customAction]",t)}return!1}if("dropdownFree"===i.kind){const t=this.#J.plugins[i.name];if(!t)return!1;if(this.#Ji?.plugin===t)return this.#sn(),!1;const e=this.selectMenu.items.indexOf(i),s=e>=0?this.selectMenu.menus[e]:null;return s&&this.#ln(i.name,t,s),!1}const n=i.name?this.#J.plugins[i.name]:null;if(n){const t=i.type||"";return/modal/.test(t)?n.open?.():/browser/.test(t)?n.open?.(null):/popup/.test(t)?n.show?.():n.action?.(Pe.utils.createElement("BUTTON",{type:"button","data-command":i.name})),this.#J.history.push(!1),!0}return i.command&&this.#J.commandDispatcher.run(i.command,null,null),!1}#nn(t){if(0===this.#Zi.size)return;const e=t.target;if(this.#Ji?.dropdown?.contains(e))return;const s=e.closest?.("li[data-index]");if(!s)return;const i=Number(s.getAttribute("data-index")),n=this.#Zi.get(i);n?this.#Ji?.plugin!==n.plugin&&this.#ln(n.name,n.plugin,n.li):this.#Ji&&this.#sn()}#ln(t,e,s){this.#Ji&&this.#sn();const i=this.#J.menu?.targetMap?.[t];if(!i||!this.selectMenu.form)return;const n=i.parentNode;this.selectMenu.form.appendChild(i),this.#an(i,s,this.selectMenu.form),Pe.utils.addClass(s,"se-submenu-open"),e.on?.(s);const o=this.#hn(i),r=this.#J.menu.subscribeDropdownOff((()=>{this.#sn(),this.selectMenu.close()}));this.#Ji={dropdown:i,plugin:e,originalParent:n,anchorLi:s,unsub:r,offCommit:o}}#hn(t){if(!this.#Qi)return()=>{};let e=!1;const s=t=>{if(e)return;const s=Pe.query.getEventTarget(t);Pe.check.isInputElement(s)||(e=!0,this.#Qi())};return t.addEventListener("mousedown",s,!0),t.addEventListener("keydown",s,!0),t.addEventListener("submit",s,!0),()=>{t.removeEventListener("mousedown",s,!0),t.removeEventListener("keydown",s,!0),t.removeEventListener("submit",s,!0)}}#sn(){const t=this.#Ji;t&&(this.#Ji=null,t.unsub?.(),t.offCommit?.(),t.dropdown.style.cssText="",t.dropdown.style.display="none",t.anchorLi&&Pe.utils.removeClass(t.anchorLi,"se-submenu-open"),t.originalParent&&t.originalParent!==t.dropdown.parentNode&&t.originalParent.appendChild(t.dropdown),t.plugin?.off?.())}#an(t,e,s){const i=e.getBoundingClientRect(),n=s.getBoundingClientRect(),o=!!this.#J.options.get("_rtl");t.style.position="absolute",t.style.right="",t.style.visibility="hidden",t.style.display="block";const r=t.offsetWidth,l=t.offsetHeight,a=pn.innerWidth,h=pn.innerHeight,c=i.right+4,d=i.left-r-4,u=Math.max(0,c+r-a),p=Math.max(0,-d);let g;g="right"===(o?"left":"right")?0===u?c:0===p?d:u<=p?c-u:d+p:0===p?d:0===u?c:p<=u?d+p:c-u,t.style.left=g-n.left+"px";const m=i.top,f=i.bottom-l,v=Math.max(0,m+l-h),b=Math.max(0,-f);let y;y=0===v?m:0===b?f:v<=b?m-v:f+b,t.style.top=y-n.top+"px",t.style.visibility=""}},{_w:mn,_d:fn}=Oe;const vn=class{#J;#cn;#dn;#un;#pn;#gn;#mn;#fn;#vn;#bn=null;#yn=null;#wn=null;#Cn=null;#_n=void 0;#kn=null;#xn=!1;#$n=void 0;#Sn=[];#En=!1;#Tn=null;#Mn=null;#Nn=null;#Bn=null;#In=null;constructor(t,e,s,i,n,o){this.#J=t,this.#cn=e,this.#dn=s,this.#un=i,this.#pn=n;const r=Array.isArray(o)?{menu:o}:o||{};this.#gn=r.menu||null,this.#mn="string"==typeof r.maxHeight?r.maxHeight:"",this.#fn="string"==typeof r.minWidth?r.minWidth:"200px",this.#vn="function"==typeof r.onPlusClick?r.onPlusClick:null,this.#J.contextProvider.carrierWrapper.appendChild(this.#dn);const l=this.#J.eventManager;l.addEvent(this.#dn,"mousedown",this.#Ln.bind(this)),this.#Tn=Pe.utils.createElement("DIV",{class:"se-block-drag-indicator"}),this.#Tn.style.display="none",this.#cn.parentElement?.appendChild(this.#Tn),l.addEvent(this.#un,"click",this.#An.bind(this)),this.#pn.draggable=!0,l.addEvent(this.#pn,"dragstart",this.#On.bind(this)),l.addEvent(this.#pn,"dragend",this.#Rn.bind(this)),l.addEvent(this.#pn,"click",this.#zn.bind(this)),l.addEvent(this.#cn,"mousemove",this.#Pn.bind(this)),l.addEvent(this.#cn,"mouseleave",this.#Dn.bind(this));const a=this.#cn.parentElement;a&&(l.addEvent(a,"mouseleave",this.#Fn.bind(this)),l.addEvent(a,"dragover",this.#Hn.bind(this)),l.addEvent(a,"drop",this.#qn.bind(this)))}#Wn(){this.#dn.style.display="flex";try{this.#dn.showPopover?.()}catch{}}#Un(){try{this.#dn.hidePopover?.()}catch{}this.#dn.style.display="none"}positionForTarget(t,e){if(this.#Vn(),this.#bn?.isOpen||this.#En)return;if(this.#xn){if(e===this.#$n)return;this.#xn=!1}const s=null!==this.#Cn;this.#Cn=t,this.#$n=e,this.#_n=e,s||(this.#wn=mn.requestAnimationFrame((()=>{this.#wn=null;const t=this.#Cn;this.#Cn=null,t&&this.#jn(t,this.#_n)})))}hide(t){if(this.#bn?.isOpen)return;const e=t?.relatedTarget;e&&(this.#cn.contains(e)||this.#dn?.contains(e))||this.#Gn()}hideNow(){this.#Vn(),this.#Un(),this.#bn?.close(),this.#Kn(null)}syncScroll(){this.#yn&&(Pe.utils.addClass(this.#dn,"se-no-transition"),this.#Yn(this.#yn),this.#dn.offsetHeight,Pe.utils.removeClass(this.#dn,"se-no-transition"),this.#bn?.isOpen&&this.#bn.setHidden("none"===this.#dn.style.display))}destroy(){this.#wn&&(mn.cancelAnimationFrame(this.#wn),this.#wn=null),this.#En=!1,this.#Vn(),this.#pn&&(this.#pn.draggable=!1),this.#Tn?.remove(),this.#dn?.remove(),this.#bn?.close(),this.#bn=null,this.#Kn(null),this.#Cn=null,this.#_n=void 0,this.#J=null,this.#cn=null,this.#dn=null,this.#un=null,this.#pn=null}#Kn(t){if(this.#Xn(),this.#yn=t,!t)return;const e=this.#Zn(t);if(e){this.#Sn=e;for(let t=0;tthis.#J.format.isLine(t)),null),o=n.indexOf(s),r=n.indexOf(i);if(-1===o||-1===r)return null;const l=n.slice(Math.min(o,r),Math.max(o,r)+1);return-1===l.indexOf(t)?null:l}catch{}return null}#Jn(t){this.#Xn(),this.#Sn=t||[];for(let t=0;t{this.#kn=null,this.#Un(),this.#bn?.close(),this.#Kn(null)}),200))}#Vn(){this.#kn&&(mn.clearTimeout(this.#kn),this.#kn=null)}#Pn(t){if(!this.#J)return;if(this.#En)return;if(this.#xn=!1,this.#Vn(),this.#bn?.isOpen)return;const e=this.#J.frameContext.get("wysiwyg");if(!e)return;const s=this.#J.frameContext.get("wysiwygFrame");let i;if(s&&"IFRAME"===s.nodeName){const e=s.getBoundingClientRect(),n=s.contentDocument;n&&(i=n.elementFromPoint(e.width/2,t.clientY-e.top))}else{const s=e.getBoundingClientRect();i=document.elementFromPoint(s.left+s.width/2,t.clientY)}i&&e.contains(i)&&this.#jn(i,t.clientY)}#Dn(t){this.#bn?.isOpen||this.#Qn(t?.relatedTarget)||this.hideNow()}#Fn(t){this.#bn?.isOpen||this.#Qn(t?.relatedTarget)||this.hideNow()}#Qn(t){if(!t)return!1;const e=this.#cn?.parentElement;return!(!this.#dn?.contains(t)&&!e?.contains(t))}#jn(t,e){if(!this.#J)return;const s=this.#J.format,i=this.#J.frameContext.get("wysiwyg");if(!i)return;let n=t;if(n===i&&void 0!==e){const t=i.getBoundingClientRect(),s=document.elementFromPoint(t.left+t.width/2,e);s&&i.contains(s)&&s!==i&&(n=s)}const o=function(t,e,s,i){if(!t||!s)return null;if(3===t.nodeType&&!(t=t.parentNode))return null;if(tt(t))return null;if(hn(t)){const s=cn(t);return s?un(s,e,i):null}let n=null;if(ln.test(t.nodeName))n=an(t);else if(on.test(t.nodeName))n=t;else if(rn.test(t.nodeName))n=t;else if(X(t.parentNode))n=an(t);else{const s=e.getLine(t,null);if(s&&(n=s),!n){const s=e.getBlock(t,null);s&&(n=ln.test(s.nodeName)?an(s):s)}}if(!n){let e=t;for(;e&&!tt(e);){if(1===e.nodeType&&e.parentNode&&tt(e.parentNode)){n=e;break}e=e.parentNode}}if(!n)return null;if(hn(n)){const t=cn(n);return t?un(t,e,i):null}return un(n,e,i)}(n,{getLine:(t,e)=>s.getLine(t,e),getBlock:(t,e)=>s.getBlock(t,e),isLine:t=>s.isLine(t),isBlock:t=>s.isBlock(t)},i,e);if(o){if(o.element!==this.#yn||"flex"!==this.#dn.style.display){if(this.#yn?.isConnected&&"flex"===this.#dn.style.display&&void 0!==e&&!this.#yn.contains(o.element)){const t=this.#yn.getBoundingClientRect();if(e>=t.top&&e<=t.bottom)return}this.#Kn(o.element),this.#Yn(o.element)}}else this.#Gn()}#Yn(t){if(!t.isConnected)return void this.hideNow();const e=t.getBoundingClientRect(),s=this.#cn.getBoundingClientRect(),i=this.#J.frameContext.get("wysiwygFrame"),n=/^iframe$/i.test(i.nodeName),o=n?i.getBoundingClientRect():null;if(n){const t=i.clientHeight||0;if(e.bottom<=0||e.top>=t)return void this.#Un()}else{const t=i.getBoundingClientRect();if(e.bottom<=t.top||e.top>=t.bottom)return void this.#Un()}const r=mn.scrollX,l=mn.scrollY,a="flex"!==this.#dn.style.display;a&&(Pe.utils.addClass(this.#dn,"se-no-transition"),this.#dn.style.display="flex");const h=this.#dn.offsetHeight||0,c=this.#to(t,e),d=n?c+o.top:c,u=d+l-h/2,p=!!this.#J.options.get("_rtl"),g=this.#eo(t,p);let m=0;if(this.#J.frameOptions.get("innerWidth")){const t=this.#J.frameContext.get("wysiwyg");if(t){const e=mn.getComputedStyle(t),s=De.get(p?e.paddingRight:e.paddingLeft,-1)||0,i=function(t,e){const s=(t||"").trim(),i=De.get(s,-1);return i?/rem$/.test(s)?i*(De.get(mn.getComputedStyle(fn.documentElement).fontSize,-1)||16):/em$/.test(s)?i*(De.get(e.fontSize,-1)||16):i:0}(e.getPropertyValue("--se-edit-inner-padding"),e);m=Math.max(0,s-i)}}const f=g+m,v=this.#J.context?.get("toolbar_main");if(v){const t=v.getBoundingClientRect(),e=this.#dn.offsetWidth||0,i=d-h/2,n=p?s.right-f-e:s.left+f;if(t.height>0&&it.top+1&&nt.left)return void this.#Un()}this.#dn.style.top=u+"px",p?(this.#dn.style.left="",this.#dn.style.right=mn.innerWidth-s.right-r+f+"px"):(this.#dn.style.right="",this.#dn.style.left=s.left+r+f+"px"),this.#Wn(),a&&(this.#dn.offsetHeight,Pe.utils.removeClass(this.#dn,"se-no-transition"))}#to(t,e){try{const e=t.ownerDocument,s=e.createTreeWalker(t,NodeFilter.SHOW_TEXT,null);let i=null;for(;(i=s.nextNode())&&!i.textContent?.trim(););if(i){const t=e.createRange();t.setStart(i,0),t.setEnd(i,Math.min(1,i.length));const s=t.getClientRects();if(s.length)return(s[0].top+s[0].bottom)/2}}catch{}const s=De.get(mn.getComputedStyle(t).lineHeight,-1)||e.height;return e.top+Math.min(s,e.height)/2}#eo(t,e){const s=this.#J.frameContext.get("wysiwyg");if(!s)return 0;const i=this.#J.format,n=e?"marginRight":"marginLeft",o=e?"paddingRight":"paddingLeft";let r=0;r+=De.get(mn.getComputedStyle(t)[n],-1)||0;let l=t.parentElement;for(;l&&l!==s;){if(i.isBlock(l)){const t=mn.getComputedStyle(l);r+=(De.get(t[o],-1)||0)+(De.get(t[n],-1)||0)}l=l.parentElement}return r}#so(){if(!this.#yn)return;const t=this.#yn,e=this.#Zn(t),s=e?e[0]:t,i=e?e[e.length-1]:t;this.#J.selection.setRange(s,0,i,i.childNodes.length)}#An(t){if(t.preventDefault(),t.stopPropagation(),!this.#yn)return;const e=this.#J.format.addLineAfter(this.#yn);e&&(this.#J.selection.setRange(e,1,e,1),this.#J.history.push(!1),this.#vn&&(this.#Kn(e),this.#Yn(e),this.#vn(this.#J,{block:e,openMenu:()=>this.#io()})))}#Ln(t){const e=this.#pn&&(t.target===this.#pn||this.#pn.contains(t.target));Oe.isMobile?this.#J.store.set("_preventBlur",!0):e||t.preventDefault()}hideOnKeyDown(){this.#bn?.isOpen||(this.#xn=!0,this.hideNow())}#On(t){if(!this.#yn)return void t.preventDefault();this.#Mn=this.#yn,this.#En=!0,this.#bn?.close(),Pe.utils.addClass(this.#Mn,"se-block-dragging");const e=this.#J.frameContext.get("wysiwyg");this.#Bn=e||null,this.#In=e?Array.from(e.children):null;const s=!!this.#J.options.get("_rtl"),i=this.#Mn;t.dataTransfer.setDragImage(i,s?i.offsetWidth:-5,-5),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("application/x-suneditor-block-drag","1")}#Hn(t){this.#En&&(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect="move",this.#no(t.clientY))}#qn(t){this.#En&&(t.preventDefault(),t.stopPropagation(),this.#oo())}#Rn(){if(this.#Mn&&Pe.utils.removeClass(this.#Mn,"se-block-dragging"),this.#Tn.style.display="none",this.#En=!1,this.#Mn=null,this.#Nn=null,this.#Bn=null,this.#In=null,this.#pn?.parentNode){const t=this.#pn.parentNode,e=this.#pn.nextSibling;t.removeChild(this.#pn),t.insertBefore(this.#pn,e)}}#no(t){if(!this.#J||!this.#Mn)return;const e=this.#Bn,s=this.#In;if(!e||!s)return;const i=e.getBoundingClientRect(),n=this.#cn.parentElement.getBoundingClientRect();let o=null,r="after",l=0,a=1/0;for(let e=0;e0&&this.#Jn(t);const e=this.#J.offset.getGlobal(this.#pn),s=Pe.utils.getClientSize().h-(e.top-mn.scrollY+e.height),i=e.top-mn.scrollY,n=`${this.#J.options.get("_rtl")?"left":"right"}-${s>=i?"bottom":"top"}`;this.#bn.open(n)}#ro(){const t=new gn(this,this.#J,{items:this.#gn,resolveButton:us,selectMenuParams:{position:"right-top",dir:this.#J.options.get("_rtl")?"rtl":"ltr",minWidth:this.#fn,maxHeight:this.#mn,keydownTarget:mn,closeMethod:()=>{Pe.utils.removeClass(this.#pn,"on"),this.#Xn()},openMethod:()=>{Pe.utils.addClass(this.#pn,"on")}}});return t.attach(this.#pn,this.#lo.bind(this),{class:"se-block-action-menu"}),t.createRows(t.getItems()),t}#lo(t){this.#yn&&this.#J&&t&&(this.#bn?.dispatch(t,{block:this.#yn}),"dropdownFree"!==t.kind&&this.#bn?.close())}},{NO_EVENT:bn}=Oe,yn={bold:["font-weight"],underline:["text-decoration"],italic:["font-style"],strike:["text-decoration"]};class wn{#H;#J;#t;#X;#rt;#_i;#ao=null;#ho=null;#co=null;#do=null;constructor(t){this.#H=t,this.#J=t.$,this.#t=t.store,this.#X=this.#J.frameContext,this.#rt=this.#J.options,this.#_i=this.#J.eventManager}async execute(t,e){if(!this.#X.get("isReadOnly")||/copy|cut|selectAll|selectAll_full|codeView|markdownView|fullScreen|print|preview|showBlocks|finder/.test(t))switch(t){case"selectAll":this.#uo();break;case"selectAll_full":this.#po();break;case"copy":{const t=this.#J.selection.getRange();if(t.collapsed)break;const e=Pe.utils.createElement("div",null,t.cloneContents());await this.#J.html.copy(e.innerHTML);break}case"newDocument":this.#J.html.set(`<${this.#rt.get("defaultLine")}>
    `),this.#J.focusManager.focus(),this.#J.history.push(!1),this.#X.has("documentType_use_header")&&this.#X.get("documentType").reHeader();break;case"finder":this.#J.finder.isOpen?this.#J.finder.close():this.#J.finder.open(!0);break;case"codeView":this.#J.viewer.codeView(!this.#X.get("isCodeView"));break;case"markdownView":this.#J.viewer.markdownView(!this.#X.get("isMarkdownView"));break;case"fullScreen":this.#J.viewer.fullScreen(!this.#X.get("isFullScreen"));break;case"indent":this.#J.format.indent();break;case"outdent":this.#J.format.outdent();break;case"undo":this.#J.history.undo();break;case"redo":this.#J.history.redo();break;case"removeFormat":this.#J.inline.remove(),this.#J.focusManager.focus();break;case"print":this.#J.viewer.print();break;case"preview":this.#J.viewer.preview();break;case"showBlocks":this.#J.viewer.showBlocks(!this.#X.get("isShowBlocks"));break;case"dir":this.#J.ui.setDir(this.#rt.get("_rtl")?"ltr":"rtl");break;case"dir_ltr":this.#J.ui.setDir("ltr");break;case"dir_rtl":this.#J.ui.setDir("rtl");break;case"save":await this.#go();break;case"copyFormat":this.#mo(e);break;case"pageBreak":this.#fo();break;case"pageUp":this.#X.get("documentType").pageUp();break;case"pageDown":this.#X.get("documentType").pageDown();break;default:this.#vo(t)}}copyFormat(){if(this.#co?.length)try{const t=[...this.#co],e=t.pop();if(this.#J.inline.remove(),e){const s=this.#J.inline.apply(e,{stylesToModify:null,nodesToRemove:[e.nodeName],strictRemove:!1}),{parent:i,inner:n}=this.#J.nodeTransform.createNestedNode(t);s.parentNode.insertBefore(i,s),n.appendChild(s),this.#J.selection.setRange(s,Pe.check.isZeroWidth(s)?1:0,s,1)}if(this.#rt.get("copyFormatKeepOn"))return;this.#do()}catch(t){console.warn("[SUNEDITOR.copyFormat.error] ",t),this.#do?.()||(this.#co=null,this.#do=null)}}#uo(){this.#J.ui.offCurrentController(),this.#J.menu.containerOff();const t=this.#X.get("wysiwyg");let e=null,s="";const i=this.#rt.get("scopeSelectionTags"),n=this.#J.selection.getRange();if(!n.collapsed){let o=e=n.commonAncestorContainer,r=s=o.nodeName?.toLowerCase();if(0===n.startOffset&&n.endOffset===n.endContainer.textContent?.length){const t=o.parentElement;(Pe.check.isList(t)||Pe.check.isListCell(t))&&t.firstChild.contains?.(n.startContainer)&&t.lastChild?.contains(n.endContainer)&&(e=o=t.parentElement,s=o.nodeName?.toLowerCase())}for(r=o.nodeName?.toLowerCase();o&&(!o.nextSibling&&!o.previousSibling&&!i.includes(r)||Pe.check.isContentLess(r))&&o!==t;)o=o.parentElement,r=o.nodeName?.toLowerCase();i.includes(r)&&(e=o,s=r)}const o=i.filter((t=>t!==s));let r=Pe.query.getParentElement(e||this.#J.selection.getNode(),(t=>o.includes(t.nodeName?.toLowerCase())))||t,{first:l,last:a}=Cn(r);if(!l||!a)return;const h=Pe.check.isZeroWidth;for(;h(l)&&h(a)&&r!==t;)r=r.parentElement,({first:l,last:a}=Cn(Pe.query.getParentElement(r,(t=>o.includes(t.nodeName?.toLowerCase())))||t));if(!l||!a)return;let c=null;if(Pe.check.isMedia(l)||(c=this.#J.component.get(l))||Pe.check.isTableElements(l)){c||=this.#J.component.get(l);const t=Pe.utils.createElement("BR"),e=Pe.utils.createElement(this.#rt.get("defaultLine"),null,t);l=c?c.container||c.cover:l,l.parentElement.insertBefore(e,l),l=t}if(Pe.check.isMedia(a)||(c=this.#J.component.get(a))||Pe.check.isTableElements(a)){c||=this.#J.component.get(a);const t=Pe.utils.createElement("BR"),e=Pe.utils.createElement(this.#rt.get("defaultLine"),null,t);a=c?c.container||c.cover:a,a.parentElement.appendChild(e),a=t}this.#J.toolbar._showBalloon(this.#J.selection.setRange(l,0,a,a.textContent.length))}#po(){this.#J.ui.offCurrentController(),this.#J.menu.containerOff();const t=this.#X.get("wysiwyg");let{first:e,last:s}=Cn(t);if(!e||!s)return;let i=null;if(Pe.check.isMedia(e)||(i=this.#J.component.get(e))||Pe.check.isTableElements(e)){i||=this.#J.component.get(e);const t=Pe.utils.createElement("BR"),s=Pe.utils.createElement(this.#rt.get("defaultLine"),null,t);e=i?i.container||i.cover:e,e.parentElement.insertBefore(s,e),e=t}if(Pe.check.isMedia(s)||(i=this.#J.component.get(s))||Pe.check.isTableElements(s)){i||=this.#J.component.get(s);const t=Pe.utils.createElement("BR"),e=Pe.utils.createElement(this.#rt.get("defaultLine"),null,t);s=i?i.container||i.cover:s,s.parentElement.appendChild(e),s=t}this.#J.toolbar._showBalloon(this.#J.selection.setRange(e,0,s,s.textContent.length))}async#go(){const t=this.#X;if(!t.get("isChanged"))return;const e=this.#J.html.get(),s=await this.#_i.triggerEvent("onSave",{frameContext:t,data:e});if(s===bn){const s=t.get("originElement");/^TEXTAREA$/i.test(s.nodeName)?s.value=e:s.innerHTML=e}else if(!1===s)return;t.set("isChanged",!1),t.set("savedIndex",this.#J.history.getRootStack()[this.#t.get("rootKey")].index),this.#J.commandDispatcher.applyTargets("save",(t=>{t.disabled=!0}))}#mo(t){if("function"==typeof this.#do)return void this.#do();const e=this.#X.get("wysiwyg");this.#co=[...this.#H._eventOrchestrator.__cacheStyleNodes],this.#do=this.#bo.bind(this,this.#_i,e,t),Pe.utils.addClass(e,"se-copy-format-cursor"),Pe.utils.addClass(t,"on"),this.#ao=this.#_i.addGlobalEvent("keydown",(t=>{Fe.isEsc(t.code)&&this.#do?.()})),this.#ho=this.#_i.addGlobalEvent("mousedown",(s=>{e.contains(s.target)||s.target===t||this.#do?.()}))}#bo(t,e,s){return this.#ao=t.removeGlobalEvent(this.#ao),this.#ho=t.removeGlobalEvent(this.#ho),this.#co=null,this.#do=null,Pe.utils.removeClass(e,"se-copy-format-cursor"),Pe.utils.removeClass(s,"on"),!0}#vo(t){t=this.#rt.get("_defaultTagCommand")[t.toLowerCase()]||t;let e=this.#rt.get("convertTextTags")[t]||t;const s=this.#t.get("currentNodesMap"),i=s.includes(this.#rt.get("_styleCommandMap")[e])?null:Pe.utils.createElement(e);/^sub$/i.test(e)&&s.includes("superscript")?e="sup":/^sup$/i.test(e)&&s.includes("subscript")&&(e="sub"),this.#J.inline.apply(i,{stylesToModify:yn[t]||null,nodesToRemove:[e],strictRemove:!1}),this.#J.focusManager.focus()}#fo(){const t=Pe.utils.createElement("DIV",{class:"se-component se-component-line-break se-page-break"});this.#J.component.insert(t,{skipCharCount:!0,insertBehavior:"line"});const e=t.nextElementSibling||this.#J.format.addLine(t);this.#J.selection.setRange(e,1,e,1),this.#J.history.push(!1)}}const Cn=function(t){const e=Pe.check.isContentLess;return{first:Pe.query.getEdgeChild(Pe.query.getEdgeChild(t,(t=>!e(t)),!1),(t=>0===t.childNodes.length||3===t.nodeType||Y(t)||K(t)),!1)||t.firstChild,last:Pe.query.getEdgeChild(t.lastChild,(t=>0===t.childNodes.length||3===t.nodeType||Y(t)||K(t)),!0)||t.lastChild}},_n=".se-menu-list .se-toolbar-btn[data-command]",kn=["bold","underline","italic","strike","subscript","superscript","indent","outdent"],xn=kn.concat(["undo","redo","save","fullScreen","showBlocks","codeView","markdownView","finder","dir","dir_ltr","dir_rtl"]);class $n{#J;#e;#rt;#yo;#wo=new Map;#Co=kn;constructor(t){this.#J=t.$,this.#e=this.#J.context,this.#rt=this.#J.options,this.#yo=new wn(t),this.allCommandButtons=new Map,this.subAllCommandButtons=new Map}get targets(){return this.#wo}get activeCommands(){return this.#Co}run(t,e,s){if(e){if(/more/i.test(e)){const e=Pe.query.getParentElement(s,".se-toolbar"),i=Pe.utils.hasClass(e,"se-toolbar-sub")?this.#J.subToolbar:this.#J.toolbar;if(s!==i.currentMoreLayerActiveButton){const n=e.querySelector("."+t);n&&(i._moreLayerOn(s,n),i._showBalloon(),i._showInline()),Pe.utils.addClass(s,"on")}else i.currentMoreLayerActiveButton&&(i._moreLayerOff(),i._showBalloon(),i._showInline());return void this.#J.viewer._resetFullScreenHeight()}if(/container/.test(e)&&(null===this.#J.menu.targetMap[t]||s!==this.#J.menu.currentContainerActiveButton))return void this.#J.menu.containerOn(s);if(this.#J.ui.isButtonDisabled(s))return;if(/dropdown/.test(e)&&(null===this.#J.menu.targetMap[t]||s!==this.#J.menu.currentDropdownActiveButton))return void this.#J.menu.dropdownOn(s);if(/modal/.test(e))return void this.#J.plugins[t].open(s);/command/.test(e)?this.#J.plugins[t].action(s):/browser/.test(e)?this.#J.plugins[t].open(null):/popup/.test(e)&&this.#J.plugins[t].show()}else t&&this.#yo.execute(t,s);/dropdown/.test(e)?this.#J.menu.dropdownOff():/command/.test(e)||(this.#J.menu.dropdownOff(),this.#J.menu.containerOff())}runFromTarget(t){if(Pe.check.isInputElement(t))return;const e=Pe.query.getCommandTarget(t);if(!e)return;const s=e.getAttribute("data-command"),i=e.getAttribute("data-type");(s||i)&&(e.disabled||this.run(s,i,t))}applyTargets(t,e){this.#wo.has(t)&&this.#wo.get(t).forEach(e)}registerTargets(t,e){if(!t||!e)return;(xn.includes(t)||this.#J.plugins[t])&&(this.#wo.get(t)?this.#wo.get(t).includes(e)||this.#wo.get(t).push(e):this.#wo.set(t,[e]))}unregisterTargets(t,e){const s=this.#wo.get(t);if(!s)return;const i=s.indexOf(e);-1!==i&&s.splice(i,1),0===s.length&&this.#wo.delete(t)}resetTargets(){this.#wo=new Map,this._initCommandButtons()}_initCommandButtons(){const t=this.#e;this.#_o(this.allCommandButtons,t.get("toolbar_buttonTray")),this.#_o(this.subAllCommandButtons,t.get("toolbar_sub_buttonTray"))}_copyFormat(){this.#yo.copyFormat()}#_o(t,e){if(!e)return;const s=e.querySelectorAll(_n),i=this.#rt.get("shortcuts"),n=this.#rt.get("_reverseCommandArray"),o=this.#J.shortcuts.keyMap,r=this.#J.shortcuts.reverseKeys;for(let e,l,a=0,h=s.length;a'+e.cancel+"
    ";return Pe.utils.createElement("DIV",{class:"se-alert-content"},s)}(this.#Ci);this.alertModal=e,this.alertMessage=e.querySelector("span");const s=function(){const t='
    ';return Pe.utils.createElement("DIV",{class:"se-toast"},t)}();s.setAttribute("popover","manual"),this.toastPopup=s,this.toastContainer=s.querySelector(".se-toast-container"),this.toastMessage=s.querySelector("span"),this.#ot.appendChild(s),this.#ko=this.#ot.querySelector(".se-alert"),this.#xo=this.#ot.querySelector(".se-alert .se-modal-inner"),this.#xo.appendChild(e),this.#$o=[this.#Do.bind(this),this.#Fo.bind(this)],this.#So=!1,this.#To=this.#ot.querySelector(".se-back-wrapper"),this.opendControllers=[],this.controllerTargetContext=null,this._figureContainer=null}get selectMenuOn(){return this.#Po.size>0}setSelectMenuOpen(t,e){e?this.#Po.add(t):this.#Po.delete(t)}setEditorStyle(t,e){e||=this.#X;const s=e.get("options");s.set("editorStyle",t);const i=ze._setDefaultOptionStyle(s,t);s.set("_defaultStyles",i),e.get("topArea").style.cssText=i.top;const n=e.get("code");if(this.#rt.get("hasCodeMirror")){const t=s.get("_defaultStyles").frame.split(";");for(let e,s=0,i=t.length;s{e&&(s&&Pe.utils.removeClass(e,s),t&&Pe.utils.addClass(e,t))};i(this.#ot),this.#Ci.applyToRoots((t=>{i(t.get("topArea")),i(t.get("wysiwyg"))})),i(this.#e.get("statusbar_wrapper")),i(this.#e.get("toolbar_wrapper"))}setDir(t){const e="rtl"===t;if(this.#rt.get("_rtl")===e)return;const s=this.#rt.get("textDirection"),i=this.#rt.get("_editableClass"),n=this.#rt.get("printClass");try{this.#rt.set("_rtl",e),this.#rt.set("textDirection",t);const s=e?this.#rt.get("_editableClass").replace(/\s*se-rtl/,"")+" se-rtl":this.#rt.get("_editableClass").replace(/\s*se-rtl/,"");this.#rt.set("_editableClass",s),this.#rt.get("printClass")&&this.#rt.set("printClass",e?this.#rt.get("printClass").replace(/\s*se-rtl/,"")+" se-rtl":this.#rt.get("printClass").replace(/\s*se-rtl/,"")),this.offCurrentController();const i=this.#X,n=this.#J.pluginManager.plugins;for(const e in n)n[e].setDir?.(t);const o=this.#e.get("toolbar_wrapper"),r=this.#e.get("statusbar_wrapper");e?(this.#Ci.applyToRoots((t=>{Pe.utils.addClass([t.get("topArea"),t.get("wysiwyg"),t.get("documentTypePageMirror")],"se-rtl"),t.get("wysiwyg").dir="rtl"})),Pe.utils.addClass([this.#ot,o,r],"se-rtl")):(this.#Ci.applyToRoots((t=>{Pe.utils.removeClass([t.get("topArea"),t.get("wysiwyg"),t.get("documentTypePageMirror")],"se-rtl"),t.get("wysiwyg").removeAttribute("dir")})),Pe.utils.removeClass([this.#ot,o,r],"se-rtl"));const l=Pe.query.getListChildren(i.get("wysiwyg"),(t=>this.#J.format.isLine(t)&&!!(t.style.marginRight||t.style.marginLeft||t.style.textAlign)),null);for(let t,e,s,i=0;t=l[i];i++)t=l[i],s=t.style.marginRight,e=t.style.marginLeft,(s||e)&&(t.style.marginRight=e,t.style.marginLeft=s),s=t.style.textAlign,"left"===s?t.style.textAlign="right":"right"===s&&(t.style.textAlign="left");this.#Ho(e),this.#t.mode.isBalloon?this.#J.toolbar._showBalloon():this.#t.mode.isSubBalloon&&this.#J.subToolbar._showBalloon()}catch(t){this.#rt.set("_rtl",!e),this.#rt.set("textDirection",s),this.#rt.set("_editableClass",i),null!==n&&this.#rt.set("printClass",n),console.warn(`[SUNEDITOR.ui.setDir.fail] ${t.toString()}`)}this.#t.set("_lastSelectionNode",null),this.#H._eventOrchestrator.applyTagEffect()}readOnly(t,e){const s=e?this.#O.get(e):this.#X;s.set("isReadOnly",!!t),this._toggleControllerButtons(!!t),t?(this.offCurrentController(),this.offCurrentModal(),this.#J.toolbar?.currentMoreLayerActiveButton?.disabled&&this.#J.toolbar._moreLayerOff(),this.#J.subToolbar?.currentMoreLayerActiveButton?.disabled&&this.#J.subToolbar._moreLayerOff(),this.#J.menu?.currentDropdownActiveButton?.disabled&&this.#J.menu.dropdownOff(),this.#J.menu?.currentContainerActiveButton?.disabled&&this.#J.menu.containerOff(),s.get("code").setAttribute("readOnly","true"),Pe.utils.addClass(s.get("wysiwyg"),"se-read-only")):(s.get("code").removeAttribute("readOnly"),Pe.utils.removeClass(s.get("wysiwyg"),"se-read-only")),this.#rt.get("hasCodeMirror")&&this.#J.viewer._codeMirrorEditor("readonly",!!t,e)}disable(t){const e=t?this.#O.get(t):this.#X;this.#J.toolbar.disable(),this.offCurrentController(),this.offCurrentModal(),e.get("wysiwyg").setAttribute("contenteditable","false"),e.set("isDisabled",!0),this.#rt.get("hasCodeMirror")?this.#J.viewer._codeMirrorEditor("readonly",!0,t):e.get("code").disabled=!0}enable(t){const e=t?this.#O.get(t):this.#X;this.#J.toolbar.enable(),e.get("wysiwyg").setAttribute("contenteditable","true"),e.set("isDisabled",!1),this.#rt.get("hasCodeMirror")?this.#J.viewer._codeMirrorEditor("readonly",!1,t):e.get("code").disabled=!1}show(t){const e=(t?this.#O.get(t):this.#X).get("topArea").style;"none"===e.display&&(e.display="block")}hide(t){(t?this.#O.get(t):this.#X).get("topArea").style.display="none"}showLoading(t){const e=(t?this.#O.get(t).get("container"):this.#ot).querySelector(".se-loading-box");e.style.display="block",e.showPopover?.()}hideLoading(t){const e=(t?this.#O.get(t).get("container"):this.#ot).querySelector(".se-loading-box");e.hidePopover?.(),e.style.display="none"}alertOpen(t,e){this.alertMessage.textContent=t,Pe.utils.removeClass(this.alertModal,"se-alert-error|se-alert-success"),e&&Pe.utils.addClass(this.alertModal,`se-alert-${e}`),this.#So&&(this.#Eo=this.#_i.addEvent(this.#xo,"click",this.#$o[1])),this.#No&&=this.#_i.removeGlobalEvent(this.#No),this.#No=this.#_i.addGlobalEvent("keydown",this.#$o[0]),this.#ko.style.display="block",this.#ko.showPopover?.(),Pe.utils.addClass(this.alertModal,"se-modal-show")}alertClose(){Pe.utils.removeClass(this.alertModal,"se-modal-show"),Pe.utils.removeClass(this.alertModal,"se-alert-*"),this.#ko.hidePopover?.(),this.#ko.style.display="none",this.#Eo&&=this.#_i.removeEvent(this.#Eo),this.#No&&=this.#_i.removeGlobalEvent(this.#No)}showToast(t,e=1e3,s){Pe.utils.hasClass(this.toastContainer,"se-toast-show")&&this.closeToast(),Pe.utils.removeClass(this.toastPopup,"se-toast-error|se-toast-success"),s&&Pe.utils.addClass(this.toastPopup,`se-toast-${s}`),this.toastPopup.style.display="block",this.toastPopup.showPopover?.(),this.toastMessage.textContent=t,Pe.utils.addClass(this.toastContainer,"se-toast-show"),this.#Bo=Tn.setTimeout((()=>{this.closeToast()}),e)}closeToast(){this.#Bo&&Tn.clearTimeout(this.#Bo),this.#Bo=null,Pe.utils.removeClass(this.toastContainer,"se-toast-show"),this.toastPopup.hidePopover?.(),this.toastPopup.style.display="none"}setControllerOnDisabledButtons(t){return t&&!this.#Mo?(this._toggleControllerButtons(!0),this.#Mo=!0):!t&&this.#Mo&&(this._toggleControllerButtons(!1),this.#Mo=!1),this.#Mo}onControllerContext(){this.controllerTargetContext=this.#X.get("topArea")}offControllerContext(){this.controllerTargetContext=null}enableBackWrapper(t){this.#To.style.cursor=t,this.#To.style.display="block",this.#To.showPopover?.()}disableBackWrapper(){this.#To.hidePopover?.(),this.#To.style.display="none",this.#To.style.cursor="default"}offCurrentController(){this.#J.component.__deselect()}offCurrentModal(){this.opendModal?.close()}getVisibleFigure(){return"block"===this._figureContainer?.style.display?this._figureContainer:null}setFigureContainer(t){this._figureContainer=t}preventToolbarHide(t){this.#Ao=t}get isPreventToolbarHide(){return this.#Ao}get blockHandle(){return this.#zo}reset(t){t.set("_editorHeight",t.get("wysiwygFrame").offsetHeight),this.#Oo=t.get("lineBreaker_t"),this.#Ro=t.get("lineBreaker_b");const e=this.#rt.get("blockHandle");e&&t.get("blockHandleArea")&&!this.#zo&&(this.#zo=new vn(this.#J,t.get("blockHandleArea"),t.get("blockHandle"),t.get("blockHandlePlus"),t.get("blockHandleDrag"),e))}_offControllers(){const t=this.opendControllers,e=[];for(let s,i=0;i{const e=i?.get(t);e&&([e.command,e.r]=[e.r,e.command])})),this.#J.commandDispatcher.applyTargets("dir",(s=>{Pe.utils.changeTxt(s.querySelector(".se-tooltip-text"),this.#Ci.lang[t?"dir_ltr":"dir_rtl"]),Pe.utils.changeElement(s.firstElementChild,e[t?"dir_ltr":"dir_rtl"])})),t?(Pe.utils.addClass(s.get("dir_rtl"),"active"),Pe.utils.removeClass(s.get("dir_ltr"),"active")):(Pe.utils.addClass(s.get("dir_ltr"),"active"),Pe.utils.removeClass(s.get("dir_rtl"),"active"))}_initToggleButtons(){const t=this.#e;this.#Lo=ze.nodeListToArray(t.get("toolbar_buttonTray").querySelectorAll(Sn)),this.#Io=ze.nodeListToArray(t.get("toolbar_buttonTray").querySelectorAll(En)),this.#rt.has("_subMode")&&(this.#Lo=this.#Lo.concat(ze.nodeListToArray(t.get("toolbar_sub_buttonTray").querySelectorAll(Sn))),this.#Io=this.#Io.concat(ze.nodeListToArray(t.get("toolbar_sub_buttonTray").querySelectorAll(En))))}_toggleCodeViewButtons(t){Pe.utils.setDisabled(this.#Lo,t)}_toggleControllerButtons(t){Pe.utils.setDisabled(this.#Io,t)}isButtonDisabled(t){return!(!this.#X.get("isReadOnly")||!Pe.utils.arrayIncludes(this.#Io,t))}_updatePlaceholder(t){t||=this.#X;const e=t.get("isMarkdownView")||t.get("isCodeView"),s=!e&&this.#Wo(t),i=t.get("placeholder");i&&(i.style.display=e||s||!this.#J.facade.isEmpty(t)?"none":"block")}resolveLinePlaceholder(t,e){if(!t||!e)return"";if("object"!=typeof e)return Pe.check.isListCell(t)||Pe.query.getParentElement(t,Pe.check.isTableCell)?"":e;const s=this.#J.format,i=t.nodeName.toLowerCase();if("string"==typeof e[i])return e[i];if(Pe.check.isListCell(t)&&"string"==typeof e["@list"])return e["@list"];if(s.isClosureBrLine(t)&&"string"==typeof e["@closureBrLine"])return e["@closureBrLine"];if(s.isBrLine(t)&&"string"==typeof e["@brLine"])return e["@brLine"];const n=s.getBlock(t);if(n&&n!==t){const t=n.nodeName.toLowerCase();if("string"==typeof e[t])return e[t];if(s.isClosureBlock(n)&&"string"==typeof e["@closureBlock"])return e["@closureBlock"];if("string"==typeof e["@block"])return e["@block"]}return s.isNormalLine(t)&&"string"==typeof e["@normalLine"]?e["@normalLine"]:"string"==typeof e["@line"]?e["@line"]:""}#Wo(t){const e=t.get("placeholder_line");if(!e)return!1;const s=t.get("wysiwyg"),i=this.#t.get("hasFocus")?this.#J.format.getLine(this.#J.selection.selectionNode):null,n=Pe.check.isEmptyLine(i)?this.resolveLinePlaceholder(i,e):"",o=n?i:null,r=s.querySelectorAll(".se-placeholder-line");for(let t=0;t{const s=e.offsetHeight,i=t.get("wysiwygFrame");if(!i)return;i.style.height=s+"px";const n=t.get("options");if(n?.get("iframe")){const t=n.get("maxHeight");t&&i.setAttribute("scrolling",s>De.get(t)?"auto":"no")}Oe.isResizeObserverSupported||this._emitResizeEvent(t,s,null)}),0);else if(!Oe.isResizeObserverSupported){const e=t.get("wysiwygFrame");e&&this._emitResizeEvent(t,e.offsetHeight,null)}}_emitResizeEvent(t,e,s){e=-1===e?s?.borderBoxSize&&s.borderBoxSize[0]?s.borderBoxSize[0].blockSize:s.contentRect.height+De.get(t.get("wwComputedStyle").getPropertyValue("padding-left"))+De.get(t.get("wwComputedStyle").getPropertyValue("padding-right")):e,t.get("_editorHeight")!==e&&(this.#_i.triggerEvent("onResizeEditor",{height:e,prevHeight:t.get("_editorHeight"),frameContext:t,observerEntry:s}),t.set("_editorHeight",e)),t.has("documentType_use_page")&&t.get("documentType").resizePage()}init(){this.#So=!this.#_i.addEvent(this.alertModal.querySelector('[data-command="close"]'),"click",this.alertClose.bind(this)),this._initToggleButtons()}#Fo(t){const e=Pe.query.getEventTarget(t);(/close/.test(e.getAttribute("data-command"))||e===this.#xo)&&this.alertClose()}#Do(t){Fe.isEsc(t.code)&&this.alertClose()}_destroy(){this.#Bo&&Tn.clearTimeout(this.#Bo),this.#No&&=this.#_i.removeGlobalEvent(this.#No),this.#Eo&&=this.#_i.removeEvent(this.#Eo),this.opendModal=null,this.opendBrowser=null,this.#Oo=null,this.#Ro=null,this.#zo?.destroy(),this.#zo=null,this.#Io=null,this.#Lo=null}},Nn=["se-component-selected","se-figure-over-selected","se-block-hover","se-pre-code-focus"],Bn=new RegExp(Nn.join("|")),In="."+Nn.join(", .");function Ln(t){if(!Bn.test(t))return t;const e=r.createElement("template");e.innerHTML=t;const s=e.content.querySelectorAll(In);for(let t=0;t0?s:u[d],o=p[n];o.index+=t;const l=o.value[o.index];if(!l)return console.warn("[SunEditor.history.setContent.fail] History state desynchronized. Aborting undo/redo operation."),o.index-=t,void(d-=t);r.get(n).get("wysiwyg").innerHTML=l.content,s!==n&&t<0&&1===d?d=0:s!==n&&t>0&&1===o.index?d++:(t<0&&o.index<1||t>0&&o.index>o.value.length)&&(d+=t);let h=n,c=l;if(t<0&&d>0&&0===o.index){const e=u[d+t];if(e!==n){const t=p[e];h=e,c=t.value[t.index]}}e.facade.changeFrameContext(h),e.selection.setRange(vt(c.s.path,c.frame),c.s.offset,vt(c.e.path,c.frame),c.e.offset),e.focusManager.focus(),d<0?d=0:d>=u.length&&(d=u.length-1),e.ui.offCurrentController(),e.pluginManager.checkFileInfo(!1),e.char.display(),e.ui._syncFrameState(a),a.has("documentType_use_header")&&a.get("documentType").reHeader(),b(a,o.index,!0)}function w(t,e,s,i){let n,o;e?(n={path:ft(e.startContainer,null,null),offset:e.startOffset},o={path:ft(e.endContainer,null,null),offset:e.endOffset}):(n={path:[0,0],offset:[0,0]},o={path:0,offset:0}),d+=i,u[d]=s;const l=p[s];l.index+=i,l.value[l.index]={content:t,s:n,e:o,frame:r.get(s).get("wysiwyg")}}function C(t){p[t]={value:[],index:-1},g[t]=r.get(t).get("wysiwyg").innerHTML}function _(t,s){e.pluginManager.checkFileInfo(!1);const i=r.get(t),n=Ln(i.get("wysiwyg").innerHTML),o=p[t];if(n&&(!o.value[o.index]||n!==o.value[o.index].content)){if(u.length>d+1&&function(t){const s=[];for(let t=d+1,e=u.length;t{t.disabled=!0}));for(let t=0,e=s.length;tc){const e=o.value.length-c;o.value.splice(0,e),o.index-=e;let s=0;for(let i=u.length-1;i>=0&&s{t.disabled=!1})),e.char.display(),b(i,o.index,!1)}}return{push(t,i){if(f)return;i=i||null===i?i:s.get("rootKey");const n=s.get("_range");o.setTimeout(e.ui._syncFrameState.bind(e.ui,r.get(i)),0);const l="number"==typeof t?t>0?t:0:t?h:0;l&&!m||(o.clearTimeout(m),l)?m=o.setTimeout((()=>{o.clearTimeout(m),m=null,_(i,n)}),l):_(i,n)},check(t,e){m&&(o.clearTimeout(m),m=null,_(t,e))},undo(){d>0&&y(-1)},redo(){u.length-1>d&&y(1)},overwrite(t){w(Ln(r.get(t||s.get("rootKey")).get("wysiwyg").innerHTML),null,s.get("rootKey"),0)},pause(){f=!0,v&&(o.clearTimeout(v),v=null),v=o.setTimeout((()=>{f=!1}),5e3)},resume(){v&&(o.clearTimeout(v),v=null),f=!1},reset(){e.commandDispatcher.applyTargets("undo",(t=>t.disabled=!0)),e.commandDispatcher.applyTargets("redo",(t=>t.disabled=!0)),e.commandDispatcher.applyTargets("save",(t=>t.disabled=!0)),i.applyToRoots((t=>t.set("historyIndex",-1))),i.applyToRoots((t=>t.set("isChanged",!1))),d=-1,u=[],p={},g={},f=!1;const t=i.rootKeys;for(let e=0,s=t.length;e{t.disabled=!(s>0&&s<=a)})),e.commandDispatcher.applyTargets("redo",(t=>{t.disabled=!(s>-1&&s-1?h!==s:i?o.index>0:s>0&&c!==s;l.set("historyIndex",s),l.set("isChanged",g),e.commandDispatcher.applyTargets("save",(t=>{t.disabled=!g})),n.triggerEvent("onResetButtons",{rootKey:t})},getRootStack:()=>p,resetDelayTime(t){h=t},_destroy(){m&&o.clearTimeout(m),v&&o.clearTimeout(v),d=u=p=g=null}}}const{_w:On}=Oe;const Rn=class{#H;#J;#t;#Uo;#Vo;#e;#X;#rt;#_i;#jo;#Go;#Ko;#Yo="default";#Xo=null;#Zo=null;#Jo=!1;#Qo=!1;#tr=!1;constructor(t,{keyName:e,balloon:s,inline:i,balloonAlways:n,res:o}){this.#H=t,this.#J=t.$,this.#t=t.store,this.#Uo=this.#J.icons,this.#Vo=this.#J.lang,this.#e=this.#J.context,this.#X=this.#J.frameContext,this.#rt=this.#J.options,this.#_i=this.#J.eventManager,this.isSub="toolbar_sub"===e,this.keyName={main:this.isSub?"toolbar_sub_main":"toolbar_main",buttonTray:this.isSub?"toolbar_sub_buttonTray":"toolbar_buttonTray",width:this.isSub?"toolbar_sub_width":"toolbar_width"},this.currentMoreLayerActiveButton=null,this.isBalloonMode=s,this.isInlineMode=i,this.isBalloonAlwaysMode=n,this.inlineToolbarAttr={top:"",width:"",isShow:!1},this.balloonOffset={top:0,left:0},this.#jo=o,this.#Go=o,this.#Ko="visualViewport"in On;const r=!this.isSub&&!s&&!i,l=this.#rt.get("_toolbar_sticky");if(this.#Jo=r&&l>=0&&!this.#rt.get("toolbar_container")&&!this.#rt.get("_toolbar_sticky_fixed")&&"undefined"!=typeof CSS&&CSS.supports("position","sticky"),this.isBottomMode=this.#t.mode.isBottom,this.#Jo){const t=this.#e.get(this.keyName.main);this.isBottomMode?(t.style.bottom=l+"px",t.style.top="auto"):l>0&&(t.style.top=l+"px")}else r&&Pe.utils.addClass(this.#e.get(this.keyName.main),"se-toolbar-relative");this._setResponsive()}get isSticky(){if(this.isSub)return!1;const t=this.#rt.get("_toolbar_sticky");if(t<0)return!1;if(this.#Jo){const e=this.#e.get(this.keyName.main);if(!e||0===e.offsetWidth||"none"===e.style.display)return!1;if(this.isBottomMode){const s=this.#Ko?On.visualViewport.height:On.innerHeight;return e.getBoundingClientRect().bottom>=s-t-1}return e.getBoundingClientRect().top<=t+1}return this.#Qo}get isCSSSticky(){return this.#Jo}disable(){this._moreLayerOff(),this.#J.menu.dropdownOff(),this.#J.menu.containerOff(),Pe.utils.setDisabled(this.#e.get(this.keyName.buttonTray).querySelectorAll(".se-menu-list .se-toolbar-btn[data-type]"),!0)}enable(){Pe.utils.setDisabled(this.#e.get(this.keyName.buttonTray).querySelectorAll(".se-menu-list .se-toolbar-btn[data-type]"),!1)}show(){this.isInlineMode?this._showInline():this.isBalloonMode?this._showBalloon():(this.#e.get(this.keyName.main).style.display="",this.isSub||(this.#X.get("_stickyDummy").style.display="")),this.isSub||this.resetResponsiveToolbar()}hide(){this.isInlineMode?(this.#e.get(this.keyName.main).style.display="none",this.#e.get(this.keyName.main).style.top="0px",this.inlineToolbarAttr.isShow=!1):(this.#e.get(this.keyName.main).style.display="none",this.isSub||(this.#X.get("_stickyDummy").style.display="none"),this.isBalloonMode&&(this.balloonOffset={top:0,left:0}))}resetResponsiveToolbar(){this.#J.menu.containerOff();const t=this.#Zo;if(t){let e=0;e=(this.isBalloonMode||this.isInlineMode)&&"auto"===this.#rt.get("toolbar_width")||this.#t.mode.isSubBalloon&&"auto"===this.#rt.get("toolbar_sub_width")?this.#X.get("topArea").offsetWidth:this.#e.get(this.keyName.main).offsetWidth;let s="default";for(let i=1,n=t.length;ifs(t.button,t.plugin,this.#Uo,this.#Vo))),this.#e.get(this.keyName.main).replaceChild(e.buttonTray,this.#e.get(this.keyName.buttonTray)),this.#e.set(this.keyName.buttonTray,e.buttonTray),this.#er(),this.#_i.triggerEvent("onSetToolbarButtons",{buttonTray:e.buttonTray,frameContext:this.#X})}_resetSticky(){if(this.#Jo)return void this.#sr();const t=this.#X.get("wrapper");if(!t)return;const e=this.#e.get(this.keyName.main),s=this.#rt.get("_toolbar_sticky");if(this.#X.get("isFullScreen")||0===e.offsetWidth||s<0)return;const i=this.#Ko?On.visualViewport.pageTop:On.scrollY,n=this.#X.get("_minHeight"),o=t.offsetHeight,r=this.#J.offset.getGlobal(this.#X.get("topArea"));if(this.isBottomMode){const t=i+On.innerHeight,l=r.top+o,a=t-s-(this.isInlineMode?e.offsetHeight:0),h=this.#rt.get("toolbar_container")?t-s-r.top-n-e.offsetHeight:a-r.top-n;a>l?this.#ir():h<0?(this.isSticky||this.#nr(1),e.style.bottom=1+h+this.#or()+"px",e.style.top="auto"):this.#nr(1)}else{const t=i+s,l=(this.isBalloonMode||this.isInlineMode?r.top:this.#J.offset.getGlobal(this.#rt.get("toolbar_container")).top)-(this.isInlineMode?e.offsetHeight:0),a=this.#rt.get("toolbar_container")?r.top-i+o-n-s-e.offsetHeight:o+l+s-t-n;tt-e)).unshift("default")}_showBalloon(t){if(!this.isBalloonMode)return;this.isSub&&this.resetResponsiveToolbar();const e=t||this.#J.selection.getRange(),s=this.#e.get(this.keyName.main),i=this.#J.selection.get();let n;if(this.isBalloonAlwaysMode&&e.collapsed)n=!0;else if(i.focusNode===i.anchorNode)n=i.focusOffset0)return;const t=Math.round(On.visualViewport.offsetTop);if(0===t&&!this.#tr)return;const e=this.#e.get(this.keyName.main),s=this.#rt.get("_toolbar_sticky_offset");if(t>0)if(this.#tr=!0,this.isBottomMode){const i=Math.round(On.innerHeight-On.visualViewport.height-t);e.style.bottom=s+i+"px",e.style.top="auto"}else e.style.top=s+t+"px";else{this.#tr=!1;const t=this.#rt.get("_toolbar_sticky");this.isBottomMode?(e.style.bottom=t+"px",e.style.top="auto"):e.style.top=t>0?t+"px":""}}#ir(){(this.#rt.get("toolbar_container")?this.#e.get("_stickyDummy"):this.#X.get("_stickyDummy")).style.display="none";const t=this.#e.get(this.keyName.main);this.isBottomMode?(t.style.bottom=this.isInlineMode?-t.offsetHeight+"px":"",t.style.top="auto",this.#X.get("wrapper").style.marginBottom=""):(t.style.top=this.isInlineMode?this.inlineToolbarAttr.top:"",this.#X.get("wrapper").style.marginTop=""),t.style.width=this.isInlineMode?this.inlineToolbarAttr.width:"",Pe.utils.removeClass(t,"se-toolbar-sticky"),this.#Qo=!1}_destroy(){this._moreLayerOff()}},{isMobile:zn,_w:Pn}=Oe;function Dn(t){return/free$/.test(t)}const Fn=class{#J;#t;#Ci;#e;#_i;#rr;#lr=[];#ar=null;#hr=null;#cr=null;#dr=null;#ur=null;#pr=null;#gr=null;#mr=null;#fr=null;#vr=null;#br=null;#yr=new Set;constructor(t){this.#J=t.$,this.#t=t.store,this.#Ci=this.#J.contextProvider,this.#e=this.#J.context,this.#_i=this.#J.eventManager,this.targetMap={},this.itemsMap={},this.index=-1,this.menus=[],this.currentButton=null,this.currentDropdown=null,this.currentDropdownActiveButton=null,this.currentDropdownName="",this.currentDropdownType="",this.currentContainer=null,this.currentContainerActiveButton=null,this.currentContainerName="",this.currentDropdownPlugin=null,this.#rr={mousedown:this.#wr.bind(this),containerDown:this.containerOff.bind(this),keydown:this.#Cr.bind(this),esc:this.#_r.bind(this),mousemove:this.#kr.bind(this),mouseout:this.#xr.bind(this)},this.#ar=null,this.#hr=null,this.#cr=null,this.#dr=null,this.#gr=null,this.#mr=null,this.#br=Pn.visualViewport||null}initDropdownTarget({key:t,type:e},s,i){if(!t)throw Error("[SUNEDITOR.init.fail] The plugin's key is not added.");let n;if(Array.isArray(s)){n=function(t,e={}){let s="";for(let e=0,i=t.length;e\n\t\t\t\n\t\t`}return Pe.utils.createElement("DIV",{class:"se-dropdown se-list-layer"+(e.className?" "+e.className:"")},`
      ${e.prependHTML||""}${s}
    `)}(s,i);const e=n.querySelectorAll(".se-list-inner li > button"),o=e.length-s.length;for(let t=0;t0&&(this.#hr=this.#_i.addGlobalEvent("keydown",this.#rr.keydown,!1),this.#ur=this.#_i.addEvent(n,"mousemove",this.#rr.mousemove,!1),this.#pr=this.#_i.addEvent(n,"mouseout",this.#rr.mouseout,!1))),this.currentDropdownPlugin=this.#J.plugins[i],this.currentDropdownPlugin?.on(s),this.#t.set("_preventBlur",!0)}dropdownOff(){this.#Tr(),this.#je(),Dn(this.currentDropdownType)&&this.currentDropdownPlugin?.off?.(),this.index=-1,this.menus=[],this.#gr=null,this.#mr=null,this.currentButton=null,this.currentDropdown&&(this.currentDropdownName="",this.currentDropdownType="",this.currentDropdown.style.display="none",this.currentDropdown=null,this.currentDropdownActiveButton&&Pe.utils.removeClass(this.currentDropdownActiveButton.parentElement.children,"on"),this.currentDropdownActiveButton=null,this.#J.ui.preventToolbarHide(!1),this.#e.get("menuTray").hidePopover?.()),this.#t.set("_preventBlur",!1),this.currentDropdownPlugin=null;for(const t of[...this.#yr])t()}subscribeDropdownOff(t){return this.#yr.add(t),()=>this.#yr.delete(t)}dropdownShow(){this.currentButton&&this.dropdownOn(this.currentButton)}dropdownHide(){this.currentDropdown&&(this.currentDropdown.style.display="none")}containerOn(t){this.#je(),this.currentContainerActiveButton=t;const e=this.currentContainerName=this.currentContainerActiveButton.getAttribute("data-command");this.currentContainer=this.targetMap[e],zn?this.#Sr(t,this.currentContainer):this.#Er(t,this.currentContainer),this.#e.get("menuTray").showPopover?.(),this.#dr=this.#_i.addGlobalEvent("mousedown",this.#rr.containerDown,!1),this.#J.plugins[e].on&&this.#J.plugins[e].on(t),this.#t.set("_preventBlur",!0)}containerOff(){this.#Tr(),this.#je(),this.currentContainer&&(this.currentContainerName="",this.currentContainer.style.display="none",this.currentContainer=null,Pe.utils.removeClass(this.currentContainerActiveButton,"on"),this.currentContainerActiveButton=null,this.#J.ui.preventToolbarHide(!1),this.#e.get("menuTray").hidePopover?.()),this.#t.set("_preventBlur",!1)}__resetMenuPosition(t,e){this.#J.offset.setRelPosition(e,this.#Ci.carrierWrapper,t.parentElement,Pe.query.getParentElement(t,".se-toolbar"),{preferUp:this.#t.mode.isBottom})}__restoreMenuPosition(){this.#gr&&this.#mr&&(this.#vr||this.#fr||this.#Er(this.#gr,this.#mr))}#Er(t,e){e.style.visibility="hidden",e.style.display="block",e.style.height="",Pe.utils.addClass(t.parentElement.children,"on"),this.#J.offset.setRelPosition(e,this.#Ci.carrierWrapper,t.parentElement,Pe.query.getParentElement(t,".se-toolbar"),{preferUp:this.#t.mode.isBottom}),e.style.visibility="",this.#gr=t,this.#mr=e}#Sr(t,e){this.#Tr(),e.style.display="none",Pe.utils.addClass(t.parentElement.children,"on"),this.#gr=t,this.#mr=e;let s=!1;const i=i=>{s||(s=!0,this.#Tr(),this.#fr=Pn.setTimeout((()=>{this.#fr=null,this.#gr===t&&this.#Er(t,e)}),i))};this.#br&&(this.#vr=()=>i(10),this.#br.addEventListener("resize",this.#vr,{once:!0})),this.#fr=Pn.setTimeout((()=>i(0)),50)}#Tr(){this.#fr&&(Pn.clearTimeout(this.#fr),this.#fr=null),this.#vr&&(this.#br?.removeEventListener("resize",this.#vr),this.#vr=null)}#$r(t){const e=Pe.query.getParentElement(t,".se-more-layer");return e&&"block"!==e.style.display&&e.getAttribute("data-ref")?e:null}#Rs(t){Pe.utils.removeClass(this.currentDropdown,"se-select-menu-mouse-move"),Pe.utils.addClass(this.currentDropdown,"se-select-menu-key-action"),t=this.index+t;const e=this.menus.length,s=this.index=t>=e?0:t<0?e-1:t;for(let t=0;tt&&Pe.utils.hasClass(t,"se-dropdown")))||(t.preventDefault(),t.stopPropagation(),this.dropdownOff()))}#kr(t){Pe.utils.addClass(this.currentDropdown,"se-select-menu-mouse-move"),Pe.utils.removeClass(this.currentDropdown,"se-select-menu-key-action");const e=this.menus.indexOf(t.target);-1!==e&&(this.index=1*e)}_destroy(){this.#je()}},{_w:Hn,_d:qn}=Oe;function Wn(t,e){const s="markdown"===e?"markdownNumbers":"codeNumbers",i="markdown"===e?"markdown":"code",n=t.get(s);if(!n)return;const o=t.get(i),r=(o.value.match(/\n/g)||[]).length+1;let l="";for(let t=1;t<=r;t++)l+=`${t}\n`;const a=Hn.getComputedStyle(o);n.style.lineHeight=a.lineHeight,n.style.fontSize=a.fontSize,n.style.fontFamily=a.fontFamily,n.style.paddingTop=a.paddingTop,n.style.paddingBottom=a.paddingBottom,n.value=l}const Un=class{#H;#J;#t;#Uo;#Vo;#O;#e;#X;#rt;#Q;#_i;#ee;#Mr="";#Nr="";#Br="";#Ir="";#Lr="";#Ar="";#Or="";#Rr="";#zr="";#Pr="";#Dr="";#Fr=0;#Hr=!1;#qr=!1;#Wr=!1;#Ur=null;#Vr="";constructor(t){this.#H=t,this.#J=t.$,this.#t=t.store,this.#Uo=this.#J.icons,this.#Vo=this.#J.lang,this.#O=this.#J.frameRoots,this.#e=this.#J.context,this.#X=this.#J.frameContext,this.#rt=this.#J.options,this.#Q=this.#J.frameOptions,this.#_i=this.#J.eventManager,this.#ee=new RegExp(`^(${this.#rt.get("_disallowedExtraTag")})$`,"i")}codeView(t){const e=this.#X;if(!e.get("codeWrapper"))return;if(void 0===t&&(t=!e.get("isCodeView")),t===e.get("isCodeView"))return;t&&e.get("isMarkdownView")&&this.markdownView(!1),e.set("isCodeView",t),this.#J.ui.offCurrentController(),this.#J.ui.offCurrentModal();const s=e.get("codeWrapper"),i=e.get("code"),n=e.get("wysiwygFrame"),o=e.get("wrapper");t?(this.#J.finder.close(),this.#jr(),s.style.setProperty("display","flex","important"),n.style.display="none",e.get("isFullScreen")?i.style.height="100%":"auto"!==this.#Q.get("height")||this.#rt.get("hasCodeMirror")||(i.style.height=i.scrollHeight>0?i.scrollHeight+"px":"auto"),this.#rt.get("hasCodeMirror")&&this._codeMirrorEditor("refresh",null,null),e.get("isFullScreen")||(this.#J.ui.preventToolbarHide(!0),this.#t.mode.isBalloon&&(this.#e.get("toolbar_arrow").style.display="none",this.#e.get("toolbar_main").style.left="",this.#t.mode.isInline=this.#J.toolbar.isInlineMode=!0,this.#t.mode.isBalloon=this.#J.toolbar.isBalloonMode=!1,this.#J.toolbar._showInline())),this.#t.mode.isBalloon&&this.#J.subToolbar.hide(),Wn(e),this.#t.set("_range",null),i.focus(),Pe.utils.addClass(this.#J.commandDispatcher.targets.get("codeView"),"active"),Pe.utils.addClass(o,"se-source-view-status")):(Pe.check.isNonEditable(n)||this.#Gr(),n.scrollTop=0,s.style.setProperty("display","none","important"),n.style.display="block","auto"!==this.#Q.get("height")||this.#rt.get("hasCodeMirror")||(e.get("code").style.height="0px"),e.get("isFullScreen")||(this.#J.ui.preventToolbarHide(!1),/balloon/.test(this.#rt.get("mode"))&&(this.#e.get("toolbar_arrow").style.display="",this.#t.mode.isInline=this.#J.toolbar.isInlineMode=!1,this.#t.mode.isBalloon=this.#J.toolbar.isBalloonMode=!0,this.#H._eventOrchestrator._hideToolbar())),this.#J.focusManager.nativeFocus(),Pe.utils.removeClass(this.#J.commandDispatcher.targets.get("codeView"),"active"),Pe.check.isNonEditable(n)||(this.#J.history.push(!1),this.#J.history.resetButtons(e.get("key"),null)),Pe.utils.removeClass(o,"se-source-view-status")),this.#J.ui._updatePlaceholder(e),this.#J.ui._toggleCodeViewButtons(t),e.has("documentType_use_header")&&(t?e.get("documentTypeInner").style.display="none":(e.get("documentTypeInner").style.display="",e.get("documentType").reHeader())),this.#_i.triggerEvent("onToggleCodeView",{frameContext:e,is:e.get("isCodeView")})}markdownView(t){const e=this.#X;if(!e.get("markdownWrapper"))return;if(void 0===t&&(t=!e.get("isMarkdownView")),t===e.get("isMarkdownView"))return;t&&e.get("isCodeView")&&this.codeView(!1),e.set("isMarkdownView",t),this.#J.ui.offCurrentController(),this.#J.ui.offCurrentModal();const s=e.get("markdownWrapper"),i=e.get("markdown"),n=e.get("wysiwygFrame"),o=e.get("wrapper");t?(this.#J.finder.close(),this.#Kr(),s.style.setProperty("display","flex","important"),n.style.display="none",e.get("isFullScreen")?i.style.height="100%":"auto"===this.#Q.get("height")&&(i.style.height=i.scrollHeight>0?i.scrollHeight+"px":"auto"),e.get("isFullScreen")||(this.#J.ui.preventToolbarHide(!0),this.#t.mode.isBalloon&&(this.#e.get("toolbar_arrow").style.display="none",this.#e.get("toolbar_main").style.left="",this.#t.mode.isInline=this.#J.toolbar.isInlineMode=!0,this.#t.mode.isBalloon=this.#J.toolbar.isBalloonMode=!1,this.#J.toolbar._showInline())),this.#t.mode.isBalloon&&this.#J.subToolbar.hide(),Wn(e,"markdown"),this.#t.set("_range",null),i.focus(),Pe.utils.addClass(this.#J.commandDispatcher.targets.get("markdownView"),"active"),Pe.utils.addClass(o,"se-source-view-status")):(Pe.check.isNonEditable(n)||this.#Yr(),n.scrollTop=0,s.style.setProperty("display","none","important"),n.style.display="block","auto"===this.#Q.get("height")&&(i.style.height="0px"),e.get("isFullScreen")||(this.#J.ui.preventToolbarHide(!1),/balloon/.test(this.#rt.get("mode"))&&(this.#e.get("toolbar_arrow").style.display="",this.#t.mode.isInline=this.#J.toolbar.isInlineMode=!1,this.#t.mode.isBalloon=this.#J.toolbar.isBalloonMode=!0,this.#H._eventOrchestrator._hideToolbar())),this.#J.focusManager.nativeFocus(),Pe.utils.removeClass(this.#J.commandDispatcher.targets.get("markdownView"),"active"),Pe.check.isNonEditable(n)||(this.#J.history.push(!1),this.#J.history.resetButtons(e.get("key"),null)),Pe.utils.removeClass(o,"se-source-view-status")),this.#J.ui._updatePlaceholder(e),this.#J.ui._toggleCodeViewButtons(t),e.has("documentType_use_header")&&(t?e.get("documentTypeInner").style.display="none":(e.get("documentTypeInner").style.display="",e.get("documentType").reHeader())),this.#_i.triggerEvent("onToggleMarkdownView",{frameContext:e,is:e.get("isMarkdownView")})}fullScreen(t){const e=this.#X;if(void 0===t&&(t=!e.get("isFullScreen")),t===e.get("isFullScreen"))return;e.set("isFullScreen",t);const s=e.get("topArea"),i=this.#e.get("toolbar_main"),n=e.get("wrapper"),o=e.get("wysiwygFrame"),r=e.get("codeWrapper"),l=e.get("code"),a=e.get("codeNumbers"),h=e.get("markdownWrapper"),c=e.get("markdown"),d=e.get("markdownNumbers"),u=this.#X.get("isCodeView"),p=this.#X.get("isMarkdownView"),g=this.#e.get("toolbar_arrow");this.#J.ui.offCurrentController();const m="none"===i.style.display||this.#t.mode.isInline&&!this.#J.toolbar.inlineToolbarAttr.isShow;if(t){this.#Vr=s.style.cssText,this.#Nr=n.style.cssText,this.#Br=o.style.cssText,this.#Ir=r?.style.cssText,this.#Lr=l.style.cssText,this.#Ar=a?.style.cssText,this.#Or=h?.style.cssText,this.#Rr=c?.style.cssText,this.#zr=d?.style.cssText,this.#Pr=i.style.cssText,g&&(this.#Dr=g.style.cssText),(this.#t.mode.isBalloon||this.#t.mode.isInline)&&(g&&(g.style.display="none"),this.#Wr=this.#t.mode.isInline,this.#qr=this.#t.mode.isBalloon,this.#t.mode.isInline=this.#J.toolbar.isInlineMode=!1,this.#t.mode.isBalloon=this.#J.toolbar.isBalloonMode=!1),this.#rt.get("toolbar_container")&&(this.#Ur=i.parentElement,e.get("container").insertBefore(i,n)),s.style.position="fixed",s.style.top="0",s.style.left="0",s.style.width="100%",s.style.maxWidth="100%",s.style.height="100%",s.style.zIndex="2147483639","none"!==e.get("_stickyDummy").style.display&&""!==e.get("_stickyDummy").style.display&&(this.#Hr=!0,e.get("_stickyDummy").style.display="none",Pe.utils.removeClass(i,"se-toolbar-sticky")),this.#Mr=qn.body.style.overflow,qn.body.style.overflow="hidden",n.style.cssText=i.style.cssText="",o.style.cssText=(o.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/)||[""])[0]+this.#Q.get("_defaultStyles").editor+(u||p?"display: none;":""),r&&(r.style.cssText=(r.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/)||[""])[0]+`display: ${u?"flex":"none"} !important;`,r.style.overflow="auto",r.style.height="100%"),h&&(h.style.cssText=(h.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/)||[""])[0]+`display: ${p?"flex":"none"} !important;`,h.style.overflow="auto",h.style.height="100%"),l.style.height="",c&&(c.style.height=""),i.style.width=o.style.height="100%",i.style.position="relative",i.style.display="block",this.#Fr=Hn.innerHeight-i.offsetHeight,n.style.height=this.#Fr-(e.has("statusbar")?e.get("statusbar").offsetHeight:0)-this.#rt.get("fullScreenOffset")+"px",this.#Q.get("iframe")&&"auto"===this.#Q.get("height")&&(n.style.overflow="auto",this.#J.ui._iframeAutoHeight(e)),e.get("topArea").style.marginTop=this.#rt.get("fullScreenOffset")+"px";const t=this.#Uo.reduction;this.#J.commandDispatcher.applyTargets("fullScreen",(e=>{Pe.utils.changeElement(e.firstElementChild,t),Pe.utils.addClass(e,"active")}))}else{o.style.cssText=this.#Br.replace(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/,"")+(u||p?"display: none;":""),r&&(r.style.cssText=this.#Ir.replace(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/,"")+`display: ${u?"flex":"none"} !important;`),l.style.cssText=this.#Lr,a&&(a.style.cssText=this.#Ar),h&&(h.style.cssText=this.#Or.replace(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/,"")+`display: ${p?"flex":"none"} !important;`),c&&(c.style.cssText=this.#Rr),d&&(d.style.cssText=this.#zr),i.style.cssText=this.#Pr,n.style.cssText=this.#Nr,s.style.cssText=this.#Vr,g&&(g.style.cssText=this.#Dr),qn.body.style.overflow=this.#Mr,"auto"!==this.#Q.get("height")||this.#rt.get("hasCodeMirror")||this._codeViewAutoHeight(e.get("code"),e.get("codeNumbers"),!0),this.#Ur&&(this.#Ur.appendChild(i),this.#Ur=null),this.#rt.get("_toolbar_sticky")>-1&&Pe.utils.removeClass(i,"se-toolbar-sticky"),this.#Hr&&!this.#rt.get("toolbar_container")&&(this.#Hr=!1,e.get("_stickyDummy").style.display="block",Pe.utils.addClass(i,"se-toolbar-sticky")),this.#t.mode.isInline=this.#J.toolbar.isInlineMode=this.#Wr,this.#t.mode.isBalloon=this.#J.toolbar.isBalloonMode=this.#qr,e.get("isCodeView")||(this.#t.mode.isInline?this.#J.toolbar._showInline():this.#t.mode.isBalloon&&this.#J.toolbar._showBalloon()),this.#J.toolbar._resetSticky(),e.get("topArea").style.marginTop="";const t=this.#Uo.expansion;this.#J.commandDispatcher.applyTargets("fullScreen",(e=>{Pe.utils.changeElement(e.firstElementChild,t),Pe.utils.removeClass(e,"active")}))}!m||e.get("isCodeView")||e.get("isMarkdownView")||this.#J.toolbar.hide(),this.#_i.triggerEvent("onToggleFullScreen",{frameContext:e,is:e.get("isFullScreen")})}showBlocks(t){const e=this.#X;void 0===t&&(t=!e.get("isShowBlocks")),e.set("isShowBlocks",!!t),t?(Pe.utils.addClass(e.get("wysiwyg"),"se-show-block"),Pe.utils.addClass(this.#J.commandDispatcher.targets.get("showBlocks"),"active")):(Pe.utils.removeClass(e.get("wysiwyg"),"se-show-block"),Pe.utils.removeClass(this.#J.commandDispatcher.targets.get("showBlocks"),"active")),this.#J.ui._syncFrameState(e)}_setButtonsActive(){const t=this.#X;if(t.get("isCodeView")?Pe.utils.addClass(this.#J.commandDispatcher.targets.get("codeView"),"active"):Pe.utils.removeClass(this.#J.commandDispatcher.targets.get("codeView"),"active"),t.get("isFullScreen")){const t=this.#Uo.reduction;this.#J.commandDispatcher.applyTargets("fullScreen",(e=>{Pe.utils.changeElement(e.firstElementChild,t),Pe.utils.addClass(e,"active")}))}else{const t=this.#Uo.expansion;this.#J.commandDispatcher.applyTargets("fullScreen",(e=>{Pe.utils.changeElement(e.firstElementChild,t),Pe.utils.removeClass(e,"active")}))}t.get("isMarkdownView")?Pe.utils.addClass(this.#J.commandDispatcher.targets.get("markdownView"),"active"):Pe.utils.removeClass(this.#J.commandDispatcher.targets.get("markdownView"),"active"),t.get("isShowBlocks")?Pe.utils.addClass(this.#J.commandDispatcher.targets.get("showBlocks"),"active"):Pe.utils.removeClass(this.#J.commandDispatcher.targets.get("showBlocks"),"active")}print(){const t=Pe.utils.createElement("IFRAME",{style:"display: none;"});qn.body.appendChild(t);const e=Hn.getComputedStyle(this.#X.get("wysiwyg")).padding,s=this.#rt.get("printTemplate")?this.#rt.get("printTemplate").replace(/\{\{\s*contents\s*\}\}/i,this.#J.html.get()):this.#J.html.get(),i=Pe.query.getIframeDocument(t),n=this.#X.get("_wd"),o=this.#rt.get("_rtl")?" se-rtl":"",r=(this.#rt.get("_themeClass")||"").trim(),l=t=>r?t.replace(r,"").trim():t,a=`\n\t\t\t`;if(this.#Q.get("iframe")){const t=this.#rt.get("printClass")?'class="'+l(this.#rt.get("printClass"))+o+'"':this.#Q.get("iframe_fullPage")?Pe.utils.getAttributesToString(n.body,["contenteditable"]).replace(r,""):'class="'+l(this.#rt.get("_editableClass"))+o+'"';i.write(`\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t${n.head.innerHTML}\n\t\t\t\t\t\t${a}\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t${s}\n\t\t\t\t\t\n\t\t\t\t`)}else{const t=qn.head.getElementsByTagName("link"),e=qn.head.getElementsByTagName("style");let n="";for(let e=0,s=t.length;e\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t${n}\n\t\t\t\t\t\t${a}\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t${s}\n\t\t\t\t\t\n\t\t\t\t`)}this.#J.ui.showLoading(),Hn.setTimeout((()=>{try{if(t.focus(),Oe.isEdge||Oe.isChromium||"StyleMedia"in Oe._w)try{t.contentWindow.document.execCommand("print",!1,null)}catch(e){console.warn("[SUNEDITOR.print.warn]",e),t.contentWindow.print()}else t.contentWindow.print()}catch(t){throw Error(`[SUNEDITOR.print.fail] error: ${t.message}`)}finally{this.#J.ui.hideLoading(),Pe.utils.removeItem(t)}}),1e3)}preview(){this.#J.menu.dropdownOff(),this.#J.menu.containerOff(),this.#J.ui.offCurrentController(),this.#J.ui.offCurrentModal();const t=this.#rt.get("previewTemplate")?this.#rt.get("previewTemplate").replace(/\{\{\s*contents\s*\}\}/i,this.#J.html.get({withFrame:!0})):this.#J.html.get({withFrame:!0}),e=Hn.open("","_blank"),s=this.#X.get("_wd"),i=this.#rt.get("_rtl")?" se-rtl":"";if(this.#Q.get("iframe")){const n=this.#rt.get("printClass")?'class="'+this.#rt.get("printClass")+i+'"':this.#Q.get("iframe_fullPage")?Pe.utils.getAttributesToString(s.body,["contenteditable"]):'class="'+this.#rt.get("_editableClass")+i+'"';e.document.write(`\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t${s.head.innerHTML}\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t${t}\n\t\t\t\t\t\n\t\t\t\t`)}else{const s=qn.head.getElementsByTagName("link"),n=qn.head.getElementsByTagName("style");let o="";for(let t=0,e=s.length;t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t${this.#Vo.preview}\n\t\t\t\t\t\t${o}\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t${t}\n\t\t\t\t\t\n\t\t\t\t`)}}_resetFullScreenHeight(){if(this.#X.get("isFullScreen"))return this.#Fr+=Hn.innerHeight-this.#e.get("toolbar_main").offsetHeight-(this.#X.has("statusbar")?this.#X.get("statusbar").offsetHeight:0)-this.#Fr,this.#X.get("wrapper").style.height=this.#Fr+"px",!0}_codeMirrorEditor(t,e,s){const i=s?this.#O.get(s).get("options"):this.#Q;switch(t){case"set":i.get("codeMirrorEditor").getDoc().setValue(e);break;case"get":return i.get("codeMirrorEditor").getDoc().getValue();case"readonly":i.get("codeMirrorEditor").setOption("readOnly",e);break;case"refresh":i.get("codeMirrorEditor").refresh()}}_setCodeView(t){this.#rt.get("hasCodeMirror")?this._codeMirrorEditor("set",t,null):this.#X.get("code").value=t}_getCodeView(){return this.#rt.get("hasCodeMirror")?this._codeMirrorEditor("get",null,null):this.#X.get("code").value}_codeViewAutoHeight(t,e,s){s&&(t.style.height=t.scrollHeight+"px"),this.#Xr(e,t)}_scrollLineNumbers(t){t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft}_markdownViewAutoHeight(t,e,s){s&&(t.style.height=t.scrollHeight+"px"),this.#Xr(e,t)}_scrollMarkdownLineNumbers(t){t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft}#Gr(){const t=this._getCodeView();if(this.#Q.get("iframe_fullPage")){const e=this.#X.get("_wd"),s=(new DOMParser).parseFromString(t,"text/html");if(!this.#ee.test("script")){const t=s.head.children;for(let e=0,i=t.length;e0?this.#J.html.clean(t,{forceFormat:!0,whitelist:null,blacklist:null,_freeCodeViewMode:this.#rt.get("freeCodeViewMode")}):"<"+this.#rt.get("defaultLine")+">
    "}#jr(){const t=this.#J.html._convertToCode(this.#X.get("wysiwyg"),!1);let e="";if(this.#Q.get("iframe_fullPage")){const s=Pe.utils.getAttributesToString(this.#X.get("_wd").body,null);e="\n\n"+this.#X.get("_wd").head.outerHTML.replace(/>(?!\n)/g,">\n")+"\n"+t+"\n"}else e=t;this._setCodeView(e)}#Kr(){const t=ze.htmlToJson(this.#X.get("wysiwyg").innerHTML),e=qe.jsonToMarkdown(t);this.#X.get("markdown").value=e}#Yr(){const t=this.#X.get("markdown").value,e=qe.markdownToHtml(t,this.#rt.get("defaultLine"));this.#X.get("wysiwyg").innerHTML=e.length>0?this.#J.html.clean(e,{forceFormat:!0,whitelist:null,blacklist:null}):"<"+this.#rt.get("defaultLine")+">
    "}#Xr(t,e){if(!t)return;const s=(e.value.match(/\n/g)||[]).length+1;if(s!==(t.value.match(/\n/g)||[]).length){let e="";for(let t=1;t<=s;t++)e+=`${t}\n`;t.value=e}}_destroy(){}},{_d:Vn,_w:jn}=Oe;class Gn{#J;#t;#Zr;#Jr;#Qr;#tl;#el;#sl;#il;#nl;#ol;#rl;#ll;#al;#hl=!1;#cl=!0;#dl=[];#ul=-1;#pl="";#gl={matchCase:!1,wholeWord:!1,regex:!1};#ml;#fl=[];#vl=null;#bl=null;#yl=null;#wl=null;#Cl=null;#_l=!1;static#kl=!1;static#xl(){if(Gn.#kl)return;Gn.#kl=!0;const t=Vn.createElement("style");t.textContent="::highlight(se-find-match){background-color:var(--se-find-match-color,rgba(255,213,0,.4));color:inherit}::highlight(se-find-current){background-color:var(--se-find-current-color,rgba(255,150,50,.7));color:inherit}",Vn.head.appendChild(t)}constructor(t){if(this.#J=t.$,this.#t=t.store,this.#ml=!!jn.Highlight&&!!CSS?.highlights,this.#J.options.get("finder_panel")){const t=function({lang:t,icons:e}){const s=`\n\t
    \n\t\t
    \n\t\t\t\n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t\n\t\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t\t
    \n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t
    \n\t
    \n\t
    \n\t\t
    \n\t\t\t\n\t\t
    \n\t\t
    \n\t\t\t\n\t\t\t\n\t\t
    \n\t
    `,i=Pe.utils.createElement("DIV",{class:"se-find-replace"},s);return{panel:i,findInput:i.querySelector(".se-find-replace-input"),replaceInput:i.querySelector(".se-replace-input"),countDisplay:i.querySelector(".se-find-replace-count"),replaceRow:i.querySelector(".se-find-replace-row-replace"),btnCase:i.querySelector(".se-find-opt-case"),btnWord:i.querySelector(".se-find-opt-word"),btnRegex:i.querySelector(".se-find-opt-regex"),btnPrev:i.querySelector('[data-command="prev"]'),btnNext:i.querySelector('[data-command="next"]'),btnReplace:i.querySelector('[data-command="replace"]'),btnReplaceAll:i.querySelector('[data-command="replace-all"]')}}(this.#J);this.#Zr=t.panel,this.#Jr=t.findInput,this.#Qr=t.replaceInput,this.#tl=t.countDisplay,this.#el=t.replaceRow,this.#sl=t.btnCase,this.#il=t.btnWord,this.#nl=t.btnRegex,this.#ol=t.btnPrev,this.#rl=t.btnNext,this.#ll=t.btnReplace,this.#al=t.btnReplaceAll,this.#$l();const e=this.#J.frameRoots.values().next().value.get("container");if(this.#t.mode.isBottom){const t=this.#J.context.get("toolbar_main");e.insertBefore(this.#Zr,t)}else{const t=e.querySelector(".se-wrapper");e.insertBefore(this.#Zr,t)}Oe.isResizeObserverSupported&&(this.#yl=new ResizeObserver((()=>this.#Sl())).observe(this.#J.context.get("toolbar_main")))}}get isOpen(){return this.#hl}open(t=!0){const e=this.#J.frameContext;if(!e.get("isCodeView")&&!e.get("isMarkdownView")&&(this.#hl=!0,Pe.utils.addClass(this.#J.commandDispatcher.targets.get("finder"),"active"),this.#El(),this.#Zr)){this.#ol.disabled=!0,this.#rl.disabled=!0,this.#ll.disabled=!0,this.#al.disabled=!0,this.#Sl();const e=this.#J.selection.get(),s=e&&!e.isCollapsed?e.toString().trim():"";Pe.utils.addClass(this.#Zr,"se-find-replace-open"),this.#t.set("_preventBlur",!0),this.#Tl(),t&&this.#Ml(t),s&&(this.#Jr.value=s),this.#Jr.focus(),this.#Jr.select(),this.#Jr.value&&this.#Nl()}}#Sl(){if(!this.#hl||!this.#Zr)return;const t=this.#J.options.get("_toolbar_sticky");this.#t.mode.isBottom?(this.#Zr.style.top="auto",this.#Zr.style.bottom=t>=0?t+this.#J.context.get("toolbar_main").offsetHeight+"px":"0px"):this.#Zr.style.top=t>=0?t+this.#J.context.get("toolbar_main").offsetHeight+"px":"0px"}close(){this.#hl&&(this.#hl=!1,Pe.utils.removeClass(this.#J.commandDispatcher.targets.get("finder"),"active"),this.#Bl(),this.#dl=[],this.#ul=-1,this.#Il(),this.#Ll(),this.#Zr&&(Pe.utils.removeClass(this.#Zr,"se-find-replace-open"),this.#Al(),this.#t.set("_preventBlur",!1),this.#J.focusManager.nativeFocus()))}findNext(){this.#hl&&0!==this.#dl.length&&(this.#ul=(this.#ul+1)%this.#dl.length,this.#Ol())}findPrev(){this.#hl&&0!==this.#dl.length&&(this.#ul=(this.#ul-1+this.#dl.length)%this.#dl.length,this.#Ol())}search(t,{matchCase:e,wholeWord:s,regex:i}={}){return this.#hl||this.open(),void 0!==e&&(this.#gl.matchCase=e),void 0!==s&&(this.#gl.wholeWord=s),void 0!==i&&(this.#gl.regex=i),this.#pl=t||"",this.#Jr&&(this.#Jr.value=this.#pl),this.#Nl(),this.#dl.length}replace(t){this.#Rl(t)}replaceAll(t){this.#zl(t)}get matchInfo(){return{current:this.#ul+1,total:this.#dl.length}}refresh(){this.#hl&&this.#pl&&!this.#_l&&(this.#_l=!0,this.#Pl(),this.#fl=[],this.#_l=!1,clearTimeout(this.#bl),this.#bl=setTimeout((()=>this.#Nl()),300))}#Tl(){this.#Al(),this.#wl=this.#J.eventManager.addGlobalEvent("keydown",(t=>{"Escape"===t.key&&(t.preventDefault(),t.stopPropagation(),this.close())}),!0)}#Al(){this.#wl&&=this.#J.eventManager.removeGlobalEvent(this.#wl)}#El(){this.#Ll();const t=this.#J.frameContext.get("wysiwyg");this.#Cl=new MutationObserver((()=>this.refresh())),this.#Cl.observe(t,{childList:!0,subtree:!0,characterData:!0})}#Ll(){this.#Cl&&(this.#Cl.disconnect(),this.#Cl=null)}#$l(){const t=this.#J.eventManager;t.addEvent(this.#Jr,"input",this.#Dl.bind(this)),t.addEvent(this.#Jr,"keydown",this.#Fl.bind(this)),t.addEvent(this.#Qr,"keydown",this.#Hl.bind(this)),t.addEvent(this.#Zr,"click",this.#ql.bind(this)),Oe.isGecko&&t.addEvent(this.#Zr,"mousedown",(t=>{if("BUTTON"===t.target.tagName){t.preventDefault();const e=Pe.query.getCommandTarget(t.target);e&&this.#J.eventManager._injectActiveEvent(e)}this.#t.set("_preventBlur",!0)}))}#Dl(){this.#J.options.get("finder_liveSearch")&&(clearTimeout(this.#bl),this.#bl=setTimeout((()=>this.#Nl()),120))}#Fl(t){"Escape"===t.key?(t.preventDefault(),this.close()):"Enter"===t.key&&(t.preventDefault(),this.#J.options.get("finder_liveSearch")||this.#Jr.value===this.#pl?t.shiftKey?this.findPrev():this.findNext():this.#Nl())}#Hl(t){"Escape"===t.key?(t.preventDefault(),this.close()):"Enter"===t.key&&(t.preventDefault(),this.#Rl())}#ql(t){const e=Pe.query.getEventTarget(t),s=Pe.query.getCommandTarget(e);if(!s)return;t.preventDefault();switch(s.getAttribute("data-command")){case"prev":this.findPrev();break;case"next":this.findNext();break;case"toggle-replace":this.#Ml(!this.#cl);break;case"close":this.close();break;case"replace":this.#Rl();break;case"replace-all":this.#zl();break;case"opt-case":this.#gl.matchCase=!this.#gl.matchCase,Pe.utils.toggleClass(this.#sl,"on",this.#gl.matchCase),this.#Nl();break;case"opt-word":this.#gl.wholeWord=!this.#gl.wholeWord,Pe.utils.toggleClass(this.#il,"on",this.#gl.wholeWord),this.#Nl();break;case"opt-regex":this.#gl.regex=!this.#gl.regex,Pe.utils.toggleClass(this.#nl,"on",this.#gl.regex),this.#Nl()}}#Ml(t){this.#cl=t,this.#el.style.display=t?"":"none",Pe.utils.toggleClass(this.#Zr.querySelector(".se-find-toggle-replace"),"on",t),t&&this.#Qr.focus()}#Nl(){const t=this.#Jr?this.#Jr.value:this.#pl;if(this.#_l=!0,this.#Bl(),this.#dl=[],this.#ul=-1,!t)return this.#pl="",this.#Il(),void Pe.utils.removeClass(this.#Jr,"se-find-no-match");this.#pl=t;const e=this.#J.frameContext.get("wysiwyg");this.#vl=this.#Wl(),this.#dl=this.#Ul(t,e),this.#dl.length>0?(this.#ul=0,this.#Vl(),this.#Ol(),Pe.utils.removeClass(this.#Jr,"se-find-no-match")):this.#Jr&&Pe.utils.toggleClass(this.#Jr,"se-find-no-match",t.length>0),this.#Il(),this.#_l=!1}#Ul(t,e){const s=[];if(!t||!e)return s;const i=this.#gl.matchCase?"g":"gi";let n;if(this.#gl.regex)try{n=new RegExp(t,i)}catch{return s}else{const e=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n=this.#gl.wholeWord?new RegExp(`\\b${e}\\b`,i):new RegExp(e,i)}const o=this.#vl,r=this.#J.format,l=o.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),a=[];let h,c,d="",u=null;for(;h=l.nextNode();){const t=r.getLine(h,null)||e;u&&t!==u&&(d+="\n"),u=t,a.push({node:h,start:d.length}),d+=h.textContent.replace(/\u00A0/g," ")}if(!d)return s;n.lastIndex=0;let p=0;for(;null!==(c=n.exec(d));){if(0===c[0].length){n.lastIndex++;continue}const t=c.index,e=t+c[0].length,i=o.createRange();let r=!1;for(let s=p;s=n.start&&tn.start&&e<=o){i.setEnd(n.node,e-n.start);break}}r&&s.push(i)}return s}#Vl(){if(0===this.#dl.length)return;const t=this.#J.frameContext.get("options").get("iframe");this.#ml&&!t?this.#jl():this.#Gl()}#jl(){Gn.#xl();const t=new Highlight(...this.#dl);CSS.highlights.set("se-find-match",t),this.#Kl()}#Kl(){if(this.#ul>=0&&this.#ul=0;e--){const s=this.#dl[e],i=this.#Yl(t,s,e);for(let t=0;t=0;l--){const a=r[l],h=a===i?e.startOffset:0,c=a===n?e.endOffset:a.textContent.length;h>=c||o.push(this.#Zl(t,a,h,c,s))}}return o}#Zl(t,e,s,i,n){const o=s>0?e.splitText(s):e;i-s=0)for(const t of this.#fl)t.getAttribute("data-se-find-idx")===String(this.#ul)&&Pe.utils.addClass(t,"se-find-current")}#Bl(){const t=this.#J.frameContext.get("options").get("iframe");this.#ml&&!t&&(CSS.highlights.delete("se-find-match"),CSS.highlights.delete("se-find-current")),this.#Pl()}#Pl(){const t=this.#J.frameContext.get("wysiwyg").querySelectorAll("mark.se-find-mark");if(0!==t.length){for(const e of t){const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e),t.normalize()}}this.#fl=[]}}#Ol(){if(this.#ul<0||this.#ul>=this.#dl.length)return;const t=this.#J.frameContext.get("options").get("iframe");if(this.#ml&&!t){this.#Kl();const t=this.#dl[this.#ul];this.#J.selection.scrollTo(t,{behavior:"auto"})}else{this.#Xl();const t=this.#fl.find((t=>t.getAttribute("data-se-find-idx")===String(this.#ul)));t&&this.#J.selection.scrollTo(t,{behavior:"auto",noFocus:!0})}this.#Il()}#Rl(t){if(this.#ul<0||0===this.#dl.length)return;this.#Bl();const e=this.#J.frameContext.get("wysiwyg"),s=this.#Ul(this.#pl,e);this.#ul>=s.length||(this.#Ql(s[this.#ul],t??(this.#Qr?this.#Qr.value:"")),this.#J.history.push(!1),this.#Nl(),this.#ul>=this.#dl.length&&this.#dl.length>0&&(this.#ul=0,this.#Ol()))}#zl(t){if(0===this.#dl.length)return;this.#Bl();const e=this.#J.frameContext.get("wysiwyg"),s=this.#Ul(this.#pl,e);if(0!==s.length){t=t??(this.#Qr?this.#Qr.value:"");for(let e=s.length-1;e>=0;e--)this.#Ql(s[e],t);e.normalize(),this.#J.history.push(!1),this.#Nl()}}#Ql(t,e){const s=t.startContainer,i=this.#vl.createTextNode(e);if(s===t.endContainer)return t.deleteContents(),t.insertNode(i),void s.parentNode?.normalize();t.deleteContents(),3===s.nodeType?s.parentNode&&(s.parentNode.insertBefore(i,s.nextSibling),s.parentNode.normalize()):(t.insertNode(i),i.parentNode?.normalize())}#Il(){if(!this.#Zr)return;const t=this.#dl.length>0;this.#tl.textContent=t?`${this.#ul+1}/${this.#dl.length}`:this.#pl?"0":"",this.#ol.disabled=!t,this.#rl.disabled=!t,this.#ll.disabled=!t,this.#al.disabled=!t}#Wl(){const t=this.#J.frameContext;return t.get("options").get("iframe")?t.get("_wd"):Vn}_destroy(){this.#Al(),this.#Ll(),this.#yl&&=this.#yl.disconnect(),clearTimeout(this.#bl)}}const Kn=Gn;const Yn=class{$;constructor(t){this.$=t.$}},{isMobile:Xn,_w:Zn}=Oe;function Jn(t){const e=Pe.query.getEventTarget(t);let s=e;this.$.store.mode.isBalloon&&!this.$.context.get("toolbar_sub_main")?.contains(s)&&this._hideToolbar_sub();const i=Pe.check.isInputElement(s);if(i?this.$.store.set("_preventBlur",!1):this.$.frameContext.get("wysiwyg").contains(this.$.selection.getNode())||this.$.focusManager.focus(),Pe.query.getParentElement(s,".se-dropdown"))t.stopPropagation(),this.$.ui.preventToolbarHide(!0);else{let n=s.getAttribute("data-command"),o=s.className;for(;s&&!n&&!/(se-menu-list|sun-editor-common|se-menu-tray)/.test(o);)s=s.parentElement,n=s.getAttribute("data-command"),o=s.className;if(i&&/^INPUT$/i.test(s?.getAttribute("data-type"))){if(this.$.store.set("_preventBlur",!0),this._inputFocus=!0,this.$.store.get("hasFocus")||this.applyTagEffect(),!Pe.check.isInputElement(e)||e.disabled)return;const t=this.$.plugins[n];if(!t)return;if(this.__inputBlurEvent&&this.__removeInput(),"function"==typeof t.toolbarInputChange&&(this.__inputPlugin={obj:t,target:e,value:e.value}),this.__inputBlurEvent=this.$.eventManager.addEvent(e,"blur",(s=>{if(!t.isInputActive)try{const i=e.value.trim();"function"==typeof t.toolbarInputChange&&i!==this.__inputPlugin.value&&t.toolbarInputChange({target:e,value:i,event:s})}finally{Zn.setTimeout((()=>this._inputFocus=!1),0),this.__removeInput()}})),!t)return;"function"==typeof t.toolbarInputKeyDown&&(this.__inputKeyEvent=this.$.eventManager.addEvent(e,"keydown",(s=>{t.toolbarInputKeyDown({target:e,event:s})})))}else{if(this.__inputBlurEvent&&this.__inputPlugin){const e=this.__inputPlugin.target.value.trim();return e!==this.__inputPlugin.value&&this.__inputPlugin.obj.toolbarInputChange({target:this.__inputPlugin.target,value:e,event:t}),void this.__removeInput()}this.$.frameContext.get("isCodeView")||(Xn?this.$.store.set("_preventBlur",!0):(t.preventDefault(),Oe.isGecko&&n&&this.$.eventManager._injectActiveEvent(s)))}n!==this.$.menu.currentDropdownName&&n!==this.$.menu.currentContainerName||t.stopPropagation()}}function Qn(t){const e=Pe.query.getEventTarget(t),s=Pe.query.getCommandTarget(e);if(!s)return;let i=s,n="";for(;i&&!/se-menu-tray/.test(i.className)&&!n;)i=i.parentElement,n=i?.getAttribute("data-key");if(!n)return;const o=this.$.plugins[n];o&&"function"==typeof o.action&&(t.stopPropagation(),o.action(s))}function to(t){const e=Pe.query.getEventTarget(t);this.$.commandDispatcher.runFromTarget(e)}const{_w:eo}=Oe,so=new WeakMap;async function io(t,e){const s=Pe.query.getEventTarget(e);this.$.store.set("_mousedown",!0),this.__onDownEv&&no.call(this),this.__onDownEv=this.$.eventManager.addGlobalEvent("mouseup",no.bind(this)),t.get("isReadOnly")||Pe.check.isNonEditable(t.get("wysiwyg"))||(this.$.format._isExcludeSelectionElement(s)?e.preventDefault():(this._setSelectionSync(),eo.setTimeout(this.$.selection.init.bind(this.$.selection),0),!1!==await this.$.eventManager.triggerEvent("onMouseDown",{frameContext:t,event:e})&&!1!==await this._callPluginEventAsync("onMouseDown",{frameContext:t,event:e})&&(this.$.store.mode.isBalloon?this._hideToolbar():this.$.store.mode.isSubBalloon&&this._hideToolbar_sub(),/FIGURE/i.test(s?.nodeName)&&e.preventDefault())))}function no(){this.$.store.set("_mousedown",!1),this.__onDownEv=this.$.eventManager.removeGlobalEvent(this.__onDownEv)}async function oo(t,e){!1!==await this.$.eventManager.triggerEvent("onMouseUp",{frameContext:t,event:e})&&await this._callPluginEventAsync("onMouseUp",{frameContext:t,event:e})}async function ro(t,e){const s=Pe.query.getEventTarget(e);if(t.get("isReadOnly"))return e.preventDefault(),Pe.check.isAnchor(s)&&eo.open(s.href,s.target),!1;if(Pe.check.isNonEditable(t.get("wysiwyg")))return;if(!1===await this.$.eventManager.triggerEvent("onClick",{frameContext:t,event:e}))return;if(!1===await this._callPluginEventAsync("onClick",{frameContext:t,event:e}))return;const i=this.$.component.get(s);if(i)return e.preventDefault(),void this.$.component.select(i.target,i.pluginName);if(this.$.selection.init(),3===e.detail){const t=this.$.selection.getRange();this.$.format.isLine(t.endContainer)&&0===t.endOffset&&this.$.selection.setRange(t.startContainer,t.startOffset,t.startContainer,t.startContainer.textContent.length)}const n=this.$.selection.getNode(),o=this.$.format.getLine(n,null),r=this.$.format.getBlock(n,null);if(!o&&!Pe.check.isNonEditable(s)&&!Pe.check.isList(r)){const t=this.$.selection.getRange();if(this.$.format.getLine(t.startContainer)===this.$.format.getLine(t.endContainer))if(Pe.check.isList(r)){e.preventDefault();const t=n.nextElementSibling,s=Pe.utils.createElement("LI",null,n);r.insertBefore(s,t),this.$.focusManager.focus()}else Pe.check.isWysiwygFrame(n)||this.$.component.is(n)||Pe.check.isTableElements(n)&&!Pe.check.isTableCell(n)||null===this._setDefaultLine(this.$.format.isBlock(r)?"DIV":this.$.options.get("defaultLine"))||(e.preventDefault(),this.$.focusManager.focus())}this.$.commandDispatcher._copyFormat(),(this.$.store.mode.isBalloon||this.$.store.mode.isSubBalloon)&&eo.setTimeout(this._toggleToolbarBalloon.bind(this),0)}function lo(t,e){if(t.get("isReadOnly")||t.get("isDisabled"))return!1;let s=so.get(t);s||(s={rafId:null,event:null},so.set(t,s)),s.event=e,null===s.rafId&&(s.rafId=eo.requestAnimationFrame((()=>{const e=s.event;if(s.rafId=null,s.event=null,!e)return;const i=Pe.query.getEventTarget(e);!1===_i.get("__overInfo")||this.$.ui.selectMenuOn||this.$.component.hoverSelect(i),this.$.ui.blockHandle?.positionForTarget(i,e.clientY),this._callPluginEvent("onMouseMove",{frameContext:t,event:e})})))}async function ao(t,e){this.$.ui.blockHandle?.hide(e),!1!==await this.$.eventManager.triggerEvent("onMouseLeave",{frameContext:t,event:e})&&await this._callPluginEventAsync("onMouseLeave",{frameContext:t,event:e})}const ho={"event.prevent":({ctx:t})=>t.e.preventDefault(),"event.stop":({ctx:t})=>t.e.stopPropagation(),"event.prevent.stop":({ctx:t})=>{t.e.preventDefault(),t.e.stopPropagation()},"cache.styleNode":({ports:t})=>t.styleNodeCache(),"cache.formatAttrsTemp":({ports:t},{attrs:e})=>t.formatAttrsTempCache(e),"focusManager.nativeFocus":({ports:t})=>t.focusManager.nativeFocus(),"history.push":({ports:t},e)=>t.history.push(e),"documentType.refreshHeader":({ctx:t})=>{o.setTimeout((()=>{t.fc.get("documentType").reHeader()}),0)},"component.deselect":({ports:t})=>t.component.deselect(),"selection.setRange":({ports:t},{sc:e,so:s,ec:i,eo:n})=>t.selection.setRange(e,s,i,n),"format.removeBlock":({ports:t},{rangeEl:e,selectedFormats:s,newBlockElement:i,shouldDelete:n,skipHistory:o})=>t.format.removeBlock(e,{selectedFormats:s,newBlockElement:i,shouldDelete:n,skipHistory:o}),"dom.utils.removeItem":(t,{item:e})=>Pe.utils.removeItem(e),"select.component.fallback":({ports:t},{cmponentInfo:e})=>{!1===t.component.select(e.target,e.pluginName)&&t.focusManager.blur()}};function co(t){const e=t.selection.getRange(),s=e.startContainer,i=e.endContainer,n=t.format.getBlock(s),o=t.format.getBlock(i),r=Pe.check.isTableCell(n),l=Pe.check.isTableCell(o);if((r&&!n.previousElementSibling&&!n.parentElement.previousElementSibling||l&&!o.nextElementSibling&&!o.parentElement.nextElementSibling)&&n!==o){const s=Pe.query.getParentElement(e.commonAncestorContainer,Pe.check.isFigure)?.parentElement||e.commonAncestorContainer;if(r){if(l)return Pe.utils.removeItem(Pe.query.getParentElement(n,(t=>s===t.parentNode))),t.focusManager.nativeFocus(),!0;Pe.utils.removeItem(Pe.query.getParentElement(n,(t=>s===t.parentNode)))}else Pe.utils.removeItem(Pe.query.getParentElement(o,(t=>s===t.parentNode)))}const a=1===s.nodeType?Pe.query.getParentElement(s,".se-component"):null,h=1===i.nodeType?Pe.query.getParentElement(i,".se-component"):null;return a&&Pe.utils.removeItem(a),h&&Pe.utils.removeItem(h),!1}function uo(t,e,s){const i=s?e.startContainer:e.endContainer,n=s?e.startOffset:e.endOffset,o=s?"previousSibling":"nextSibling";let r;return 1===i.nodeType?(r=po(t,i.childNodes[n],o,i),Pe.check.isComponentContainer(r)||Pe.check.isNonEditable(r)?r:null):(r=po(t,i,o,i),Pe.check.isEdgePoint(i,n,s?"front":"end")&&(Pe.check.isComponentContainer(r)||Pe.check.isNonEditable(r))?r:null)}function po(t,e,s,i){if(!e)return null;let n=e[s];if(!n){if(n=t.format.getLine(i),n=n?n[s]:null,!n||t.component.is(n))return null;n="previousSibling"===s?n.firstChild:n.lastChild}return n}function go(t,e,s,i){if(!t.collapsed||!e)return!1;const n=t.getBoundingClientRect();if(n.height<=0)return!1;const o=i.createRange();o.selectNodeContents(e);const r=o.getBoundingClientRect();return!(r.width<=2)&&("front"===s?n.left<=r.left+2:n.left>=r.right-2)}function mo(t,e,s){if(!t.collapsed||!Pe.check.isBreak(e))return!1;const i="front"===s?"previousSibling":"nextSibling";let n=e[i];for(;3===n?.nodeType&&Pe.check.isZeroWidth(n);)n=n[i];return!n||Pe.check.isList(n)}function fo(t,e,s){const i="front"===s?"previousElementSibling":"nextElementSibling",n="front"===s?"lastElementChild":"firstElementChild";let o=e,r=null;for(;o&&!(r=o[i]);){const e=o.parentElement;if(!e||t.isClosureBlock(e)||Pe.check.isWysiwygFrame(e))return null;if(t.isBlock(e))o=e;else{if(!Pe.check.isListCell(e))return null;if("front"===s)return e;o=e}}for(;r&&t.isBlock(r)&&!t.isClosureBlock(r);)r=r[n];return r}function vo(t,e,s){if(!e||!t.isNormalLine(e)||!Pe.check.isEmptyLine(e))return null;if(Pe.utils.arrayFind(e.children,Pe.check.isList))return null;const i="front"===s?e.previousElementSibling:e.nextElementSibling;return t.isNormalLine(i)||t.isBrLine(i)?i:null}function bo(t,e){const s=Pe.utils.arrayFind(t.children,Pe.check.isList)||t.nextElementSibling||e?.parentElement?.nextElementSibling;return s&&(Pe.check.isList(s)||Pe.utils.arrayFind(s.children,Pe.check.isList))?s:null}const yo={"del.format.removeAndMove":({ports:t},{container:e,formatEl:s})=>{const i=t.html.remove();if(i.commonCon!==i.container&&s.parentElement)if(s.contains(e)){const e=function(t){const e=t.lastChild,s=t.nextElementSibling;if(!s)return e;if(Pe.check.isZeroWidth(s))return Pe.utils.removeItem(s),e;const i=s.childNodes;for(;i[0];)t.appendChild(i[0]);return Pe.utils.removeItem(s),e}(s);t.selection.setRange(e,e.textContent.length,e,e.textContent.length)}else{const{focusNode:e,focusOffset:i}=function(t){const e=t.childNodes,s=t.previousElementSibling;let i=e[0],n=0;if(!s)return{focusNode:i,focusOffset:n};if(Pe.check.isZeroWidth(s))return Pe.utils.removeItem(s),{focusNode:i,focusOffset:n};if(e.length>1||e[0]?.textContent.length>0)for(;e[0];)s.appendChild(e[0]);else i=s.lastChild,n=i.textContent.length;return Pe.utils.removeItem(t),{focusNode:i,focusOffset:n}}(s);t.selection.setRange(e,i,e,i)}},"backspace.brline.strip":({ctx:t,ports:e},{formatEl:s})=>{const i=t.options.get("defaultLine"),n=s.parentNode,o=Pe.utils.createElement(i);for(;s.firstChild&&!Pe.check.isBreak(s.firstChild);)o.appendChild(s.firstChild);s.firstChild&&Pe.check.isBreak(s.firstChild)&&s.removeChild(s.firstChild),o.firstChild||(o.innerHTML="
    "),n.insertBefore(o,s),s.firstChild&&(s.textContent.trim()||s.querySelector("br"))||n.removeChild(s);const r=o.firstChild;e.selection.setRange(r,0,r,0)},"backspace.format.maintain":({ctx:t},{formatEl:e})=>{if(e.nodeName.toUpperCase()===t.options.get("defaultLine").toUpperCase()){e.innerHTML="
    ";const t=e.attributes;for(;t[0];)e.removeAttribute(t[0].name)}else e.parentNode.replaceChild(Pe.utils.createElement(t.options.get("defaultLine"),null,"
    "),e)},"backspace.component.select":({ports:t},{selectionNode:e,range:s,fileComponentInfo:i})=>{let n=null;Pe.check.isBreak(e)?Pe.utils.removeItem(e):Pe.check.isBreak(n=s.startContainer.childNodes?.[s.startOffset])&&Pe.utils.removeItem(n),!1===t.component.select(i.target,i.pluginName)&&t.focusManager.blur()},"backspace.component.remove":({ports:t},{isList:e,sel:s,formatEl:i,fileComponentInfo:n})=>{e&&Pe.utils.removeItem(s),0===i.textContent.length&&Pe.utils.removeItem(i),!1===t.component.select(n.target,n.pluginName)&&t.focusManager.blur()},"backspace.list.mergePrev":({ports:t},{prev:e,formatEl:s,rangeEl:i})=>{let n=e===i.parentNode?i.previousSibling:e.lastChild;n||(n=Pe.utils.createTextNode(Re.zeroWidthSpace),i.parentNode.insertBefore(n,i.parentNode.firstChild));const o=3===n.nodeType?n.textContent.length:1;_o(s);const r=s.childNodes;let l=n,a=r[0];for(;a=r[0];)e.insertBefore(a,l.nextSibling),l=a;Pe.utils.removeItem(s),0===i.children.length&&Pe.utils.removeItem(i),t.selection.setRange(n,o,n,o)},"backspace.list.removeNested":({ports:t},{range:e})=>{t.html.remove(),3===e.startContainer.nodeType&&t.selection.setRange(e.startContainer,e.startContainer.textContent.length,e.startContainer,e.startContainer.textContent.length)},"backspace.emptyLine.mergePrev":({ports:t},{formatEl:e,prev:s})=>{Pe.utils.removeItem(e),wo(t,s,!0)},"backspace.brline.rowMerge":({ports:t},{rowEndBr:e,rowStartBr:s})=>{const i=s.nextSibling;i!==e&&3===i?.nodeType&&Pe.check.isZeroWidth(i)&&Pe.utils.removeItem(i);const n=s.previousSibling;if(Pe.utils.removeItem(s),n&&3===n.nodeType)t.selection.setRange(n,n.textContent.length,n,n.textContent.length);else if(Pe.check.isBreak(n))t.selection.setRange(e,0,e,0);else{const s=e.parentNode;t.selection.setRange(s,0,s,0)}},"backspace.softBreak.merge":({ports:t},{zws:e})=>{const s=e.previousSibling,i=e.parentNode,n=s?.previousSibling;Pe.utils.removeItem(e),s&&Pe.utils.removeItem(s),n?Co(t,n):i&&t.selection.setRange(i,0,i,0)},"delete.component.select":({ports:t},{formatEl:e,fileComponentInfo:s})=>{if(Pe.check.isListCell(e)){const t=s.container.previousSibling;Pe.check.isZeroWidth(t)&&Pe.utils.removeItem(t)}else Pe.check.isZeroWidth(e)&&Pe.utils.removeItem(e);!1===t.component.select(s.target,s.pluginName)&&t.focusManager.blur()},"delete.component.selectNext":({ports:t,ctx:e},{formatEl:s,nextEl:i})=>{if(Pe.check.isZeroWidth(s)&&(Pe.utils.removeItem(s),Pe.check.isTable(i))){let e=Pe.query.getEdgeChild(i,Pe.check.isTableCell,!1);return e=e.firstElementChild||e,void t.selection.setRange(e,0,e,0)}const n=t.component.get(i);n?(e.e.stopPropagation(),!1===t.component.select(n.target,n.pluginName)&&t.focusManager.blur()):t.component.is(i)&&(e.e.stopPropagation(),Pe.utils.removeItem(i))},"delete.list.removeNested":({ports:t,ctx:e},{range:s,formatEl:i,rangeEl:n})=>{s.startContainer!==s.endContainer&&t.html.remove();const o=bo(i,n);if(o){let s,n;if(e.e.preventDefault(),Pe.check.isList(o)){const t=o.firstElementChild;for(n=t.childNodes,s=n[0];n[0];)i.insertBefore(n[0],o);Pe.utils.removeItem(t)}else{for(s=o.firstChild,n=o.childNodes;n[0];)i.appendChild(n[0]);Pe.utils.removeItem(o)}t.selection.setRange(s,0,s,0),t.history.push(!0)}},"delete.emptyLine.mergeNext":({ports:t},{formatEl:e,next:s})=>{Pe.utils.removeItem(e),wo(t,s,!1)},"line.merge":({ports:t},{into:e,from:s})=>{const i=t.format,n=s.parentElement;_o(e);const o=e.lastChild;for(_o(s);s.firstChild;)e.appendChild(s.firstChild);Pe.utils.removeItem(s);let r=n;for(;r&&r!==e.parentElement&&i.isBlock(r)&&!i.isClosureBlock(r)&&Pe.check.isZeroWidth(r);){const t=r.parentElement;Pe.utils.removeItem(r),r=t}e.firstChild||e.appendChild(Pe.utils.createElement("BR")),o?Co(t,o):t.selection.setRange(e,0,e,0)},"delete.brline.rowMerge":({ports:t},{rowEndBr:e})=>{let s=e.nextSibling;3===s?.nodeType&&Pe.check.isZeroWidth(s)&&(s=s.nextSibling);const i=e.parentNode;Pe.utils.removeItem(e),s&&(3===s.nodeType||Pe.check.isBreak(s))?t.selection.setRange(s,0,s,0):t.selection.setRange(i,i.childNodes.length,i,i.childNodes.length)},"delete.softBreak.merge":({ports:t},{br:e})=>{const s=e.previousSibling,i=e.parentNode,n=e.nextSibling;n&&3===n.nodeType&&Pe.check.isZeroWidth(n.textContent)&&Pe.utils.removeItem(n),Pe.utils.removeItem(e),s?Co(t,s):i&&t.selection.setRange(i,0,i,0)},"tab.format.indent":({ports:t,ctx:e},{range:s,formatEl:i,shift:n})=>{const o=t.format.getLines(null),r=[],l=[],a=Pe.check.isListCell(o[0]),h=Pe.check.isListCell(o.at(-1));let c={sc:s.startContainer,so:s.startOffset,ec:s.endContainer,eo:s.endOffset};for(let t,e=0,s=o.length;e0&&(c=t.listFormat.applyNested(r,n)),l.length>0)if(n){const t=l.length-1;for(let e,s=0;s<=t;s++){e=l[s].childNodes;for(let t,s=0,i=e.length;st.component.is(e))),o=t.format.isLine(i.previousElementSibling)?Pe.query.findTabEndIndex(i.previousElementSibling,e,2):0;o>e&&(n=o-e)}const o=Pe.utils.createTextNode(new Array(n).join(" "));if(!t.html.insertNode(o,{afterNode:null,skipCharCount:!1}))return!1;a||(c.sc=o,c.so=o.length),h||(c.ec=o,c.eo=o.length)}else{const t=Pe.utils.createTextNode(new Array(e.store.get("tabSize")+1).join(" ")),s=l.length-1;for(let e,i=0;i<=s;i++)e=l[i].firstChild,e&&(Pe.check.isBreak(e)?l[i].insertBefore(t.cloneNode(!1),e):e.textContent=t.textContent+e.textContent);const i=Pe.query.getEdgeChild(l[0],"text",!1),n=Pe.query.getEdgeChild(l[s],"text",!0);!a&&i&&(c.sc=i,c.so=0),!h&&n&&(c.ec=n,c.eo=n.textContent.length)}t.selection.setRange(c.sc,c.so,c.ec,c.eo)},"caret.scrollTo":({ports:t},{range:e})=>{t.caretScrollTo(e)},"enter.line.addDefault":({ports:t},{formatEl:e})=>{const s=t.format.addLineAfter(e).firstChild;t.selection.setRange(s,0,s,0)},"enter.list.addItem":({ports:t},{formatEl:e,selectionNode:s})=>{const i=Pe.utils.createElement("BR"),n=Pe.utils.createElement("LI",null,i);e.parentNode.insertBefore(n,e.nextElementSibling),n.appendChild(s.nextSibling),t.selection.setRange(i,1,i,1)},"enter.format.exitEmpty":({ports:t,ctx:e},{formatEl:s,rangeEl:i})=>{let n=null;if(Pe.check.isListCell(i.parentElement)){const t=s.parentNode.parentElement;i=t.parentElement;const o=Pe.utils.createElement("LI");o.innerHTML="
    ",Pe.utils.copyTagAttributes(o,s,e.options.get("lineAttrReset")),n=o,i.insertBefore(n,t.nextElementSibling)}else{let o;o=Pe.check.isTableCell(i.parentElement)?"DIV":Pe.check.isList(i.parentElement)?"LI":t.format.isLine(i.nextElementSibling)?i.nextElementSibling.nodeName:t.format.isLine(i.previousElementSibling)?i.previousElementSibling.nodeName:e.options.get("defaultLine"),n=Pe.utils.createElement(o);const r=t.format.removeBlock(i,{selectedFormats:[s],newBlockElement:null,shouldDelete:!0,skipHistory:!0});r.cc.insertBefore(n,r.sc?r.sc.nextSibling:r.cc.firstChild)}n.innerHTML="
    ",t.nodeTransform.removeAllParents(s,null,null),t.selection.setRange(n,1,n,1)},"enter.format.cleanBrAndZWS":({ports:t},{selectionNode:e,selectionFormat:s,brBlock:i,children:n,offset:o})=>{s?Pe.utils.removeItem(n[o-1]):Pe.utils.removeItem(e);const r=i.nextElementSibling,l=t.format.addLine(i,t.format.isLine(r)?r:null);Pe.utils.copyFormatAttributes(l,i),t.selection.setRange(l,1,l,1)},"enter.format.insertBrHtml":({ports:t},{brBlock:e,range:s,wSelection:i,offset:n})=>{t.html.insert(s.collapsed&&Pe.check.isBreak(s.startContainer.childNodes[s.startOffset-1])?"
    ":"

    ",{selectInserted:!1,skipCharCount:!0,skipCleaning:!0});let o=i.focusNode;const r=i.focusOffset;e===o&&(o=o.childNodes[r-n>1?r-1:r]),t.selection.setRange(o,1,o,1),t.setOnShortcutKey(!0)},"enter.brline.insert":({ports:t},{range:e})=>{t.selection.setRange(e.startContainer,e.startOffset,e.endContainer,e.endOffset),e.collapsed||t.html.remove();const s=Pe.utils.createElement("BR");t.html.insertNode(s,{afterNode:null,skipCharCount:!0}),s.nextSibling||s.parentNode.appendChild(Pe.utils.createElement("BR"));const i=s.nextSibling;t.selection.setRange(i,0,i,0),t.setOnShortcutKey(!0)},"enter.shift.br":({ports:t,ctx:e},{range:s})=>{const i=e.fc.get("_wd"),n=t.selection.get(),o=n?.rangeCount>0&&e.fc.get("wysiwyg").contains(n.focusNode)?n.getRangeAt(0):s,r=i.createRange();if(r.setStart(o.startContainer,o.startOffset),r.setEnd(o.endContainer,o.endOffset),o.collapsed||(r.deleteContents(),r.collapse(!0)),1===r.startContainer.nodeType&&Pe.check.isBreak(r.startContainer)){const t=r.startContainer;r.setStart(t.parentNode,Pe.utils.getArrayIndex(t.parentNode.childNodes,t)+r.startOffset),r.collapse(!0)}const l=Pe.utils.createElement("BR");r.insertNode(l);const a=l.nextSibling;if(a&&3===a.nodeType&&!Pe.check.isZeroWidth(a.textContent))t.selection.setRange(a,0,a,0);else{const e=Pe.utils.createTextNode(Re.zeroWidthSpace);l.parentNode.insertBefore(e,l.nextSibling),t.selection.setRange(e,1,e,1)}t.history.push(!1)},"enter.brline.exit":({ports:t},{brBlock:e})=>{const s=e.lastChild;s&&(Pe.check.isBreak(s)||Pe.check.isZeroWidth(s.textContent))&&Pe.utils.removeItem(s);const i=e.nextElementSibling,n=t.format.addLine(e,t.format.isLine(i)?i:null);Pe.utils.copyFormatAttributes(n,e),t.selection.setRange(n,1,n,1)},"enter.format.insertBrNode":({ports:t},{wSelection:e})=>{const s=e.focusNode.nextSibling,i=Pe.utils.createElement("BR");t.html.insertNode(i,{afterNode:null,skipCharCount:!0});const n=i.previousSibling,o=i.nextSibling;Pe.check.isBreak(s)||Pe.check.isBreak(n)||o&&!Pe.check.isZeroWidth(o)?t.selection.setRange(o,0,o,0):(i.parentNode.insertBefore(i.cloneNode(!1),i),t.selection.setRange(i,1,i,1)),t.setOnShortcutKey(!0)},"enter.format.breakAtEdge":({ports:t,ctx:e},{formatEl:s,selectionNode:i,formatStartEdge:n,formatEndEdge:o,bidiSwapped:r})=>{const l=Pe.utils.createElement("BR"),a=Pe.utils.createElement(s.nodeName,null,l);Pe.utils.copyTagAttributes(a,s,e.options.get("lineAttrReset"));let h=l;if(!o||!e.options.get("lineBreakClearStyle")){let t=i;do{if(!Pe.check.isBreak(t)&&1===t.nodeType){const e=t.cloneNode(!1);e.appendChild(h),h=e}t=t.parentElement}while(s!==t&&s.contains(t))}if(a.appendChild(h),s.parentNode.insertBefore(a,n&&!o?s:s.nextElementSibling),o)t.selection.setRange(l,1,l,1);else if(r)t.selection.setRange(s,1,s,1);else{const e=s.firstChild||s;t.selection.setRange(e,0,e,0)}},"enter.format.breakWithSelection":({ports:t,ctx:e},{formatEl:s,range:i,formatStartEdge:n,formatEndEdge:o})=>{const r=t.format.getLine(i.startContainer,null)!==t.format.getLine(i.endContainer,null),l=s.cloneNode(!1);l.innerHTML="
    ";const a=i.commonAncestorContainer,h=a===i.startContainer&&a===i.endContainer&&Pe.check.isZeroWidth(a)?{container:a,offset:i.endOffset,prevContainer:a.previousElementSibling,commonCon:a}:t.html.remove();let c=t.format.getLine(h.container,null),d=0;if(!c)return void(Pe.check.isWysiwygFrame(h.container)&&(t.enterPrevent(e.e),e.fc.get("wysiwyg").appendChild(l),c=l,Pe.utils.copyTagAttributes(c,s,e.options.get("lineAttrReset")),t.selection.setRange(c,d,c,d)));const u=t.format.getBlock(h.container);c=c.contains(u)?Pe.query.getEdgeChild(u,(e=>Boolean(t.format.getLine(e))),!1):c,r?o&&!n?(c.parentNode.insertBefore(l,h.prevContainer&&h.container!==h.prevContainer?c:c.nextElementSibling),c=l,d=0):(d=h.offset,n&&(c.parentNode.insertBefore(l,c),o&&(d=0))):o&&n?(c.parentNode.insertBefore(l,c),d=0):o?(c=c.parentNode.insertBefore(l,c.nextElementSibling),c=l,d=0):c=t.nodeTransform.split(h.container,h.offset,Pe.query.getNodeDepth(s)),t.enterPrevent(e.e),Pe.utils.copyTagAttributes(c,s,e.options.get("lineAttrReset")),t.selection.setRange(c,d,c,d)},"enter.format.breakAtCursor":({ports:t,ctx:e},{formatEl:s,range:i})=>{let n=null;n=Pe.check.isZeroWidth(s)?t.format.addLine(s,s.cloneNode(!1)):t.nodeTransform.split(i.endContainer,i.endOffset,Pe.query.getNodeDepth(s)),t.enterPrevent(e.e),Pe.utils.copyTagAttributes(n,s,e.options.get("lineAttrReset")),t.selection.setRange(n,0,n,0)},"enter.figcaption.exitInList":({ports:t},{formatEl:e})=>{const s=t.format.addLine(e,null);t.selection.setRange(s,0,s,0)},"keydown.input.insertNbsp":({ports:t})=>{const e=t.html.insertNode(Pe.utils.createTextNode(" "),{afterNode:null,skipCharCount:!0});e&&t.selection.setRange(e,e.length,e,e.length)},"keydown.input.insertZWS":({ports:t})=>{const e=Pe.utils.createTextNode(Re.zeroWidthSpace);t.html.insertNode(e,{afterNode:null,skipCharCount:!0}),t.selection.setRange(e,1,e,1)}};function wo(t,e,s){const i=s?e.childNodes.length:0;t.selection.setRange(e,i,e,i)}function Co(t,e){const s=3===e.nodeType?e.textContent.length:e.childNodes.length;t.selection.setRange(e,s,e,s)}function _o(t){let e=t.lastChild;for(;e&&(Pe.check.isBreak(e)||3===e.nodeType&&Pe.check.isZeroWidth(e));){const t=e.previousSibling;Pe.utils.removeItem(e),e=t}}async function ko(t,e){const s={...ho,...yo};for(const i of t){if("action.stop"===i.t)return!1;const t=s[i.t];if(t){if(!1===await t(e,i.p))return!1}}}const xo=()=>({t:"event.prevent"}),$o=()=>({t:"event.prevent.stop"}),So=()=>({t:"cache.styleNode"}),Eo=t=>({t:"cache.formatAttrsTemp",p:{attrs:t}}),To=()=>({t:"component.deselect"}),Mo=()=>({t:"focusManager.nativeFocus"}),No=t=>({t:"history.push",p:t}),Bo=()=>({t:"documentType.refreshHeader"}),Io=(t,e,s,i,n)=>({t:"format.removeBlock",p:{rangeEl:t,selectedFormats:e,newBlockElement:s,shouldDelete:i,skipHistory:n}}),Lo=t=>({t:"dom.utils.removeItem",p:{item:t}}),Ao=t=>({t:"select.component.fallback",p:{cmponentInfo:t}}),Oo=(t,e)=>({t:"del.format.removeAndMove",p:{container:t,formatEl:e}}),Ro=t=>({t:"backspace.format.maintain",p:{formatEl:t}}),zo=t=>({t:"backspace.brline.strip",p:{formatEl:t}}),Po=(t,e,s)=>({t:"backspace.component.select",p:{selectionNode:t,range:e,fileComponentInfo:s}}),Do=(t,e,s,i)=>({t:"backspace.component.remove",p:{isList:t,sel:e,formatEl:s,fileComponentInfo:i}}),Fo=(t,e,s)=>({t:"backspace.list.mergePrev",p:{prev:t,formatEl:e,rangeEl:s}}),Ho=t=>({t:"backspace.list.removeNested",p:{range:t}}),qo=(t,e)=>({t:"backspace.emptyLine.mergePrev",p:{formatEl:t,prev:e}}),Wo=(t,e)=>({t:"backspace.brline.rowMerge",p:{rowEndBr:t,rowStartBr:e}}),Uo=t=>({t:"backspace.softBreak.merge",p:{zws:t}}),Vo=(t,e)=>({t:"delete.component.select",p:{formatEl:t,fileComponentInfo:e}}),jo=(t,e)=>({t:"delete.component.selectNext",p:{formatEl:t,nextEl:e}}),Go=(t,e,s)=>({t:"delete.list.removeNested",p:{range:t,formatEl:e,rangeEl:s}}),Ko=(t,e)=>({t:"delete.emptyLine.mergeNext",p:{formatEl:t,next:e}}),Yo=t=>({t:"delete.brline.rowMerge",p:{rowEndBr:t}}),Xo=t=>({t:"delete.softBreak.merge",p:{br:t}}),Zo=(t,e)=>({t:"line.merge",p:{into:t,from:e}}),Jo=(t,e,s)=>({t:"tab.format.indent",p:{range:t,formatEl:e,shift:s}}),Qo=t=>({t:"caret.scrollTo",p:{range:t}}),tr=t=>({t:"enter.line.addDefault",p:{formatEl:t}}),er=(t,e)=>({t:"enter.list.addItem",p:{formatEl:t,selectionNode:e}}),sr=(t,e)=>({t:"enter.format.exitEmpty",p:{formatEl:t,rangeEl:e}}),ir=(t,e,s,i)=>({t:"enter.format.insertBrHtml",p:{brBlock:t,range:e,wSelection:s,offset:i}}),nr=t=>({t:"enter.format.insertBrNode",p:{wSelection:t}}),or=t=>({t:"enter.brline.insert",p:{range:t}}),rr=t=>({t:"enter.shift.br",p:{range:t}}),lr=t=>({t:"enter.brline.exit",p:{brBlock:t}}),ar=(t,e,s,i,n)=>({t:"enter.format.breakAtEdge",p:{formatEl:t,selectionNode:e,formatStartEdge:s,formatEndEdge:i,bidiSwapped:n}}),hr=(t,e,s,i)=>({t:"enter.format.breakWithSelection",p:{formatEl:t,range:e,formatStartEdge:s,formatEndEdge:i}}),cr=(t,e)=>({t:"enter.format.breakAtCursor",p:{formatEl:t,range:e}}),dr=t=>({t:"enter.figcaption.exitInList",p:{formatEl:t}}),ur=()=>({t:"keydown.input.insertNbsp"}),pr=()=>({t:"keydown.input.insertZWS"});function gr(t,e,s){const{format:i,component:n}=e,{fc:o,options:r,range:l,selectionNode:a}=s;let{formatEl:h}=s;const c=!l.collapsed||l.startContainer!==l.endContainer,d=r.get("_rtl")&&!c&&0===l.startOffset&&go(l,h,"front",o.get("_wd"));if(t.push(To()),t.push(So()),c&&co(e))return t.push($o()),t.push(Qo(l)),!0;if(!(i.isNormalLine(h)||i.isBrLine(h)||o.get("wysiwyg").firstElementChild||n.is(a)||null===function(t,e){return t.setDefaultLine(e)}(e,r.get("defaultLine"))))return t.push($o()),!1;if(i.isLine(h)&&c&&Pe.check.isEdgePoint(l.startContainer,l.startOffset,"front")&&(!l.startContainer.previousSibling||Pe.check.isZeroWidth(l.startContainer.previousSibling))&&i.getLine(l.startContainer)!==i.getLine(l.endContainer)&&(i.isLine(h.previousElementSibling)||Pe.check.isListCell(h)))return t.push($o()),t.push(Oo(l.startContainer,h)),t.push(No(!0)),t.push(Qo(l)),!1;if(!c&&!d&&h&&i.isNormalLine(h)&&!Pe.check.isListCell(h)&&i.isEdgeLine(l.startContainer,l.startOffset,"front")){const e=function(t,e,s){const i=fo(t,e,s);return t.isLine(i)?i:null}(i,h,"front");if(e&&e.parentElement!==h.parentElement&&i.isNormalLine(e))return t.push($o()),t.push(Zo(e,h)),t.push(No(!0)),!1}if(!c&&!d&&!h.previousElementSibling&&0===l.startOffset&&!a.previousSibling&&!Pe.check.isListCell(h)&&i.isLine(h)&&(!i.isBrLine(h)||i.isClosureBrLine(h)||Pe.check.isWysiwygFrame(h.parentNode)))return i.isClosureBlock(h.parentNode)?(t.push($o()),!1):i.isBrLine(h)&&Pe.check.isWysiwygFrame(h.parentNode)?(t.push($o()),t.push(zo(h)),t.push(No(!0)),!1):(Pe.check.isWysiwygFrame(h.parentNode)&&h.childNodes.length<=1&&(!h.firstChild||Pe.check.isZeroWidth(h.textContent))&&(t.push($o()),t.push(Ro(h))),t.push(Mo()),t.push(Qo(l)),!1);const u=l.startContainer;if(h&&!d&&!h.previousElementSibling&&0===l.startOffset&&3===u.nodeType&&Pe.check.isZeroWidth(u)&&!0===function(t,e,s){let i=e.parentNode.previousSibling;const n=e.parentNode.nextSibling;i||(n?i=n:(i=Pe.utils.createElement("BR"),s.appendChild(i)));let o=e;for(;s.contains(o)&&!o.previousSibling;)o=o.parentNode;if(!s.contains(o))return e.textContent="",t.nodeTransform.removeAllParents(e,null,s),!0}(e,u,h))return!0;if(!c&&h&&(0===l.startOffset||a===h)){const s=a===h?uo(e,l,!0):Pe.check.isElement(a.previousSibling)?a.previousSibling:Pe.check.isEdgePoint(l.startContainer,l.startOffset)?Pe.query.getPreviousDeepestNode(l.startContainer):null;if(n.is(s)){const e=n.get(s);if(e)return t.push($o()),t.push(Po(a,l,e)),!0}}if(uo(e,l,!0))return t.push($o()),!0;c||d||!i.isEdgeLine(l.startContainer,l.startOffset,"front")||i.isLine(h.previousElementSibling)&&t.push(Eo(h.previousElementSibling.attributes)),h=i.getLine(l.startContainer,null);const p=i.getBlock(h,null),g=l.commonAncestorContainer;if(p&&h&&!Pe.check.isTableCell(p)&&!/^FIGCAPTION$/i.test(p.nodeName)){if(Pe.check.isListCell(h)&&Pe.check.isList(p)&&(Pe.check.isListCell(p.parentElement)||h.previousElementSibling)&&(a===h||mo(l,a,"front")||3===a.nodeType&&(!a.previousSibling||Pe.check.isList(a.previousSibling)))&&(i.getLine(l.startContainer,null)!==i.getLine(l.endContainer,null)?p.contains(l.startContainer):0===l.startOffset&&l.collapsed&&!d)){if(l.startContainer!==l.endContainer)t.push(xo()),t.push(Ho(l)),t.push(No(!0));else{let e=h.previousElementSibling||p.parentElement;if(Pe.check.isListCell(e)){t.push(xo());let s=e;if(!e.contains(h)&&Pe.check.isListCell(s)&&Pe.check.isList(s.lastElementChild)){for(s=s.lastElementChild.lastElementChild;Pe.check.isListCell(s)&&Pe.check.isList(s.lastElementChild);)s=s.lastElementChild&&s.lastElementChild.lastElementChild;e=s}t.push(Fo(e,h,p)),t.push(No(!0))}}return t.push(Qo(l)),!0}if(!c&&0===l.startOffset&&!d){let e=!0,s=g;for(;s&&s!==p&&!Pe.check.isWysiwygFrame(s);){if(s.previousSibling&&(1===s.previousSibling.nodeType||!Pe.check.isZeroWidth(s.previousSibling.textContent.trim()))){e=!1;break}s=s.parentNode}if(e&&p.parentNode)return t.push(xo()),t.push(Io(p,Pe.check.isListCell(h)?[h]:null,null,!1,!1)),t.push(No(!0)),t.push(Qo(l)),!0}}if(!c&&h&&Pe.check.isEmptyLine(h)&&n.is(h.previousElementSibling)){const e=n.get(h.previousElementSibling);if(e)return t.push($o()),t.push(Do(!1,h.firstChild,h,e)),t.push(Qo(l)),!0}if(!c&&h&&(0===l.startOffset||a===h&&h.childNodes[l.startOffset])){const e=Pe.check.isListCell(h),s=a===h?h.childNodes[l.startOffset]:a,i=(e?s:h).previousSibling,o=e||(3===g.nodeType||Pe.check.isBreak(g))&&!g.previousSibling&&0===l.startOffset;if(s&&(e||!s.previousSibling)&&(g&&n.is(g.previousSibling)||o&&n.is(i))){const o=n.get(i);return o?(t.push($o()),t.push(Do(e,s,h,o))):n.is(i)&&(t.push($o()),t.push(Lo(i))),t.push(Qo(l)),!0}if(s&&Pe.check.isNonEditable(s.previousSibling))return t.push($o()),t.push(Lo(s.previousSibling)),t.push(Qo(l)),!0}if(!c&&i.isBrLine(h)&&Pe.check.isBreak(l.startContainer)&&0===l.startOffset){let e=l.startContainer.previousSibling;if(3===e?.nodeType&&Pe.check.isZeroWidth(e)&&(e=e.previousSibling),Pe.check.isBreak(e))return t.push($o()),t.push(Wo(l.startContainer,e)),t.push(No(!0)),t.push(Qo(l)),!1}if(!c&&3===l.startContainer.nodeType&&Pe.check.isZeroWidth(l.startContainer)&&l.startOffset<=1&&Pe.check.isBreak(l.startContainer.previousSibling))return t.push($o()),t.push(Uo(l.startContainer)),t.push(No(!0)),t.push(Qo(l)),!1;const m=vo(i,h,"front");return!c&&m?(t.push($o()),t.push(qo(h,m)),t.push(No(!0)),t.push(Qo(l)),!1):(t.push(Qo(l)),!0)}function mr(t,e,s){const{format:i,char:n,selection:o}=e,{frameOptions:r,range:l,formatEl:a,selectionNode:h,shift:c,e:d}=s,u=!l.collapsed||l.startContainer!==l.endContainer;t.push(To());const p=i.getBrLine(h,null),g=i.getBlock(a,null);if("byte-html"===r.get("charCounter_type")){let e="";if(e=!c&&p||c?"
    ":"<"+a.nodeName+">
    ",!n.check(e))return t.push(xo()),!1}if(c)return e.enterPrevent(d),t.push(rr(l)),t.push(Qo(l)),!0;if(!c){let n=i.isEdgeLine(l.endContainer,l.endOffset,"end"),r=i.isEdgeLine(l.startContainer,l.startOffset,"front"),c=!1;if(s.options.get("_rtl")&&a&&l.collapsed&&r!==n){const t=s.fc.get("_wd");r&&go(l,a,"front",t)?(r=!1,n=!0,c=!0):n&&go(l,a,"end",t)&&(n=!1,r=!0,c=!0)}if(n&&(/^H[1-6]$/i.test(a.nodeName)||/^HR$/i.test(a.nodeName)))return e.enterPrevent(d),t.push(tr(a)),t.push(Qo(l)),!0;if(g&&a&&!Pe.check.isTableCell(g)&&!/^FIGCAPTION$/i.test(g.nodeName)){const s=o.getRange();if(Pe.check.isEdgePoint(s.endContainer,s.endOffset)&&Pe.check.isList(h.nextSibling))return e.enterPrevent(d),t.push(er(a,h)),t.push(Qo(l)),!0;if((3!==s.commonAncestorContainer.nodeType||!s.commonAncestorContainer.nextElementSibling)&&Pe.check.isZeroWidth(a.innerText.trim())&&!Pe.check.isListCell(a.nextElementSibling))return e.enterPrevent(d),t.push(sr(a,g)),!0}if(p||g===a&&i.isClosureBlock(g)&&i.isLine(a)){if(e.enterPrevent(d),p&&!i.isClosureBrLine(p))return!function(t,e){const s=Array.from(t.childNodes),i=[[]];for(const t of s)Pe.check.isBreak(t)?i.push([]):i[i.length-1].push(t);s.length&&Pe.check.isBreak(s[s.length-1])&&i.pop();const n=t=>!t||t.every((t=>Pe.check.isZeroWidth(t.textContent))),o=e.anchorNode;let r=0;if(o===t)for(let t=0;t=1&&n(i[a-1])}}(p,o.get()).shouldExit?t.push(or(l)):t.push(lr(p)),t.push(Qo(l)),!0;const s=o.get();return h===p?t.push(ir(p,l,s,s.focusOffset)):t.push(nr(s)),t.push(Qo(l)),!0}if(l.collapsed&&(r||n))return e.enterPrevent(d),t.push(ar(a,h,r,n,c)),t.push(Qo(l)),!0;if(a){if(t.push(xo()),u){if(s.options.get("_rtl")&&r&&!n){const t=s.fc.get("_wd"),e=t.createRange();e.setStart(l.startContainer,l.startOffset),e.collapse(!0),go(e,a,"front",t)&&(r=!1,n=!0,c=!0)}t.push(hr(a,l,r,n))}else t.push(cr(a,l));return t.push(Qo(l)),!0}}return u?(t.push(Qo(l)),!0):(g&&Pe.query.getParentElement(g,"FIGCAPTION")&&Pe.query.getParentElement(g,Pe.check.isList)&&(e.enterPrevent(d),t.push(dr(a)),t.push(Qo(l))),!0)}const{isOSX_IOS:fr}=Oe;function vr(t,e){return t.get("_canUseBeforeInput")&&!e?.repeat}async function br(t,e){const s=[];switch(e.keyCode){case"Backspace":if(!1===gr(s,t,e))return s;break;case"Delete":if(!1===function(t,e,s){const{format:i,component:n}=e,{fc:o,range:r,selectionNode:l}=s;let{formatEl:a}=s;const h=!r.collapsed||r.startContainer!==r.endContainer,c=s.options.get("_rtl")&&!h&&r.endOffset>=(r.endContainer.textContent?.length||0)&&go(r,a,"end",o.get("_wd"));if(t.push(To()),t.push(So()),h&&co(e))return t.push($o()),!0;if(!h&&!c&&a&&i.isEdgeLine(r.endContainer,r.endOffset,"end")){const e=fo(i,a,"end");if(!e)return t.push($o()),!1;if(i.isLine(e)&&e.parentElement!==a.parentElement&&i.isNormalLine(a)&&i.isNormalLine(e))return t.push($o()),t.push(Zo(a,e)),t.push(No(!0)),!1}if(i.isLine(a)&&h&&Pe.check.isEdgePoint(r.endContainer,r.endOffset,"end")&&(!r.endContainer.nextSibling||Pe.check.isZeroWidth(r.endContainer.nextSibling))&&i.getLine(r.startContainer)!==i.getLine(r.endContainer)&&(i.isLine(a.nextElementSibling)||Pe.check.isListCell(a)))return t.push($o()),t.push(Oo(r.endContainer,a)),t.push(No(!0)),!1;if(!h&&a&&(r.endOffset===r.endContainer.textContent.length||l===a)){const s=l===a?uo(e,r,!1):Pe.check.isElement(l.nextSibling)?l.nextSibling:Pe.check.isEdgePoint(r.endContainer,r.endOffset)?Pe.query.getNextDeepestNode(r.endContainer,null):null;if(n.is(s)){const e=n.get(s);if(e)return t.push($o()),t.push(Vo(a,e)),!0}}if(uo(e,r,!1))return t.push($o()),!0;if((i.isLine(l)||null===l.nextSibling||Pe.check.isZeroWidth(l.nextSibling)&&null===l.nextSibling.nextSibling)&&r.startOffset===l.textContent.length){const e=a.nextElementSibling;if(!e)return!0;if(n.is(e))return t.push(xo()),t.push(jo(a,e)),!0}if(!h&&(Pe.check.isEdgePoint(r.endContainer,r.endOffset)||l===a&&a.childNodes[r.startOffset])){const e=l===a&&a.childNodes[r.startOffset]||l;if(e&&Pe.check.isNonEditable(e.nextSibling))return t.push($o()),t.push(Lo(e.nextSibling)),!0;if(n.is(e))return t.push($o()),t.push(Lo(e)),!0}h||c||!i.isEdgeLine(r.endContainer,r.endOffset,"end")||i.isLine(a.nextElementSibling)&&t.push(Eo(a.attributes)),a=i.getLine(r.startContainer,null);const d=i.getBlock(a,null);if(Pe.check.isListCell(a)&&Pe.check.isList(d)&&(r.startContainer!==r.endContainer||bo(a,d))&&(l===a||mo(r,l,"end")||3===l.nodeType&&(!l.nextSibling||Pe.check.isList(l.nextSibling))&&(i.getLine(r.startContainer,null)!==i.getLine(r.endContainer,null)?d.contains(r.endContainer):r.endOffset===l.textContent.length&&r.collapsed&&!c)))return t.push(Go(r,a,d)),!0;if(!h&&i.isBrLine(a)&&Pe.check.isBreak(r.startContainer)&&0===r.startOffset){let e=r.startContainer.previousSibling;if(3===e?.nodeType&&Pe.check.isZeroWidth(e)&&(e=e.previousSibling),Pe.check.isBreak(e))return t.push($o()),t.push(Yo(r.startContainer)),t.push(No(!0)),!1}if(!h){const e=r.startContainer;let s=null;if(3===e.nodeType&&r.startOffset>=e.textContent.length&&Pe.check.isBreak(e.nextSibling)){const t=e.nextSibling;3===t.nextSibling?.nodeType&&Pe.check.isZeroWidth(t.nextSibling.textContent)&&(s=t)}else 3===e.nodeType&&Pe.check.isZeroWidth(e)&&0===r.startOffset&&Pe.check.isBreak(e.previousSibling)&&(s=e.previousSibling);if(s)return t.push($o()),t.push(Xo(s)),t.push(No(!0)),!1}const u=vo(i,a,"end");return!(!h&&u&&(t.push($o()),t.push(Ko(a,u)),t.push(No(!0)),1))}(s,t,e))return s;break;case"Tab":if(!1===function(t,e,s){const{options:i,selectionNode:n,range:o,formatEl:r,ctrl:l,alt:a,shift:h}=s;return!!i.get("tabDisable")||(t.push(xo()),l||a||Pe.check.isWysiwygFrame(n)||(t.push(Jo(o,r,h)),t.push(No(!1))),!0)}(s,0,e))return s;break;case"Enter":if(!vr(e.store,e.e)&&!1===mr(s,t,e))return s}const{fc:i,keyCode:n,shift:o,alt:r,ctrl:l,range:a}=e;if(o&&(fr?r:l)&&Fe.isSpace(n))return s.push($o()),s.push(ur()),s;const h=!a.collapsed||a.startContainer!==a.endContainer;return l||r||h||Fe.isNonTextKey(n)||!Pe.check.isBreak(a.commonAncestorContainer)?!i.has("documentType_use_header")||!h||l||r||o||Fe.isDirectionKey(n)?(function(t,e,s){const{component:i}=e,{formatEl:n,range:o,selectionNode:r,keyCode:l}=s,a=s.options.get("_rtl"),h="ArrowLeft"===l?a?"forward":"back":"ArrowRight"===l?a?"back":"forward":null;let c=null;switch(l){case"ArrowUp":i.is(n.previousElementSibling)&&(c=i.get(n.previousElementSibling));break;case"ArrowLeft":case"ArrowRight":if("forward"===h){if(Pe.check.isEdgePoint(r,o.endOffset,"end")){const t=r.nextElementSibling||Pe.query.getNextDeepestNode(r);t?i.is(t)&&(c=i.get(t)):i.is(n.nextElementSibling)&&(c=i.get(n.nextElementSibling))}}else if("back"===h&&Pe.check.isEdgePoint(r,o.startOffset,"front")){const t=r.previousElementSibling||Pe.query.getPreviousDeepestNode(r);t?i.is(t)&&(c=i.get(t)):i.is(n.previousElementSibling)&&(c=i.get(n.previousElementSibling))}break;case"ArrowDown":i.is(n.nextElementSibling)&&(c=i.get(n.nextElementSibling))}c&&!c.options?.isInputComponent&&(t.push(xo()),t.push(Ao(c)))}(s,t,e),s):(s.push(Bo()),s):(s.push(pr()),s)}function yr(t,{_styleNodes:e}){const{frameContext:s,ui:i,focusManager:n,selection:o,format:r,listFormat:l,component:a,html:h,nodeTransform:c,history:d,char:u,menu:p,store:g}=t.$;return{focusManager:{nativeFocus:()=>n.nativeFocus(),blur:()=>n.blur()},selection:{getRange:()=>o.getRange(),getNode:()=>o.getNode(),setRange:(t,e,s,i)=>o.setRange(t,e,s,i),get:()=>o.get()},format:{isLine:t=>r.isLine(t),getLine:(t,e)=>r.getLine(t,e),getLines:t=>r.getLines(t),getBrLine:(t,e)=>r.getBrLine(t,e),getBlock:(t,e)=>r.getBlock(t,e),isNormalLine:t=>r.isNormalLine(t),isBrLine:t=>r.isBrLine(t),isClosureBrLine:t=>r.isClosureBrLine(t),isBlock:t=>r.isBlock(t),isClosureBlock:t=>r.isClosureBlock(t),isEdgeLine:(t,e,s)=>r.isEdgeLine(t,e,s),removeBlock:(t,e)=>r.removeBlock(t,e),addLine:(t,e)=>r.addLine(t,e),addLineAfter:t=>r.addLineAfter(t)},listFormat:{applyNested:(t,e)=>l.applyNested(t,e)},component:{deselect:()=>a.deselect(),is:t=>a.is(t),get:t=>a.get(t),select:(t,e)=>a.select(t,e)},html:{remove:()=>h.remove(),insert:(t,e)=>h.insert(t,e),insertNode:(t,e)=>h.insertNode(t,e)},history:{push:t=>d.push(!!t)},nodeTransform:{removeAllParents:(t,e,s)=>c.removeAllParents(t,e,s),split:(t,e,s)=>c.split(t,e,s)},char:{check:t=>u.check(t)},menu:{dropdownOff:()=>p.dropdownOff()},setDefaultLine:e=>t._setDefaultLine(e),hideToolbar:()=>t._hideToolbar(),hideToolbar_sub:()=>t._hideToolbar_sub(),styleNodeCache:()=>e.value=t.__cacheStyleNodes,formatAttrsTempCache:e=>t._formatAttrsTemp=e,setOnShortcutKey:e=>t._onShortcutKey=e,caretScrollTo(t){i._iframeAutoHeight(s),o.scrollTo(o.getRange()||t,{behavior:"auto",block:"nearest",inline:"nearest"})},enterPrevent(e){e.preventDefault(),b&&!vr(g)&&(t.__focusTemp.focus({preventScroll:!0}),s.get("wysiwyg").focus({preventScroll:!0}))}}}const wr={value:[]};async function Cr(t,e){if(t.get("isReadOnly")||t.get("isDisabled"))return e.preventDefault(),e.stopPropagation(),!1;if(vr(this.$.store)&&("insertParagraph"===e.inputType||"insertLineBreak"===e.inputType))return void await _r.call(this,t,e);const s=(null===e.data?"":void 0===e.data?" ":e.data)||"";if(Fe.isComposing(e))this._handledInBefore=!1;else{if(!this.$.char.test(s,!1))return e.preventDefault(),e.stopPropagation(),!1;this._handledInBefore=!0}!1!==await this.$.eventManager.triggerEvent("onBeforeInput",{frameContext:t,event:e,data:s})&&await this._callPluginEventAsync("onBeforeInput",{frameContext:t,event:e,data:s})}async function _r(t,e){if(e.isComposing||this.isComposing)return;if(this.$.ui.selectMenuOn)return;let s=this.$.selection.getNode();if(Pe.check.isInputElement(s))return;if(this.$.menu.currentDropdownName)return;Pe.check.isWysiwygFrame(s)&&(this._setDefaultLine(this.$.options.get("defaultLine")),s=this.$.selection.getNode());const i=this._enterKeyShift||"insertLineBreak"===e.inputType;if(this._enterKeyShift=!1,!i){const t=this._normalizeEditRange();t&&(s=t)}const n=this.$.selection.getRange(),o=this.$.format.getLine(s,null)||s,r={e,fc:t,store:this.$.store,options:this.$.options,frameOptions:this.$.frameOptions,range:n,selectionNode:s,formatEl:o,keyCode:"Enter",ctrl:!1,alt:!1,shift:i},l=yr(this,{_styleNodes:wr}),a=[];mr(a,l,r),a.some((t=>"event.prevent"===t.t||"event.prevent.stop"===t.t))&&e.preventDefault(),await ko(a,{ports:l,ctx:r})}async function kr(t,e){if(t.get("isReadOnly")||t.get("isDisabled"))return e.preventDefault(),e.stopPropagation(),!1;const s=this.$.selection.getRange(),i=this.$.selection.getNode(),n=this.$.format.getLine(i,null);if(!this.$.format.isNormalLine(n)&&!this.$.format.isBrLine(n)&&s.collapsed&&!this.$.component.is(i)&&!Pe.check.isList(i)){const t=this.$.format.getBlock(i,null);this._setDefaultLine(this.$.format.isBlock(t)?"DIV":this.$.options.get("defaultLine"))}this.$.selection.init();const o=(null===e.data?"":void 0===e.data?" ":e.data)||"";if(!this._handledInBefore&&!this.$.char.test(o,!0))return e.preventDefault(),e.stopPropagation(),!1;this._handledInBefore=!1,!1!==await this.$.eventManager.triggerEvent("onInput",{frameContext:t,event:e,data:o})&&(await this._callPluginEventAsync("onInput",{frameContext:t,event:e,data:o}),this.$.history.push(!0))}const{_w:xr}=Oe,$r=new RegExp(Re.zeroWidthSpace+"+",""),Sr={ctrl:!1,alt:!1},Er=Object.preventExtensions({value:[]});async function Tr(t,e){if(this.$.ui.blockHandle?.hideOnKeyDown(),this.isComposing=Fe.isComposing(e))return!0;if(this.$.ui.selectMenuOn||!e.isTrusted)return;let s=this.$.selection.getNode();if(Pe.check.isInputElement(s))return;if(this.$.menu.currentDropdownName)return;const i=e.code,n=Fe.isShift(e),o=Sr.ctrl=Fe.isCtrl(e),r=Sr.alt=Fe.isAlt(e);if(Fe.isEnter(i)&&(this._enterKeyShift=n),!o&&t.get("isReadOnly")&&!Fe.isDirectionKey(i))return e.preventDefault(),!1;this.$.menu.dropdownOff(),this.$.store.mode.isBalloon?this.$.store.mode.isBalloonAlways||this._hideToolbar():this.$.store.mode.isSubBalloon&&(this.$.store.mode.isSubBalloonAlways||this._hideToolbar_sub());if(Fe.isEnter(i)&&!vr(this.$.store,e)||Fe.isRemoveKey(i)){const t=this._normalizeEditRange();t&&(s=t)}const l=this.$.selection.getRange(),a=this.$.format.getLine(s,null)||s;if(o&&!Fe.isNonTextKey(i)&&this.$.shortcuts.command(e,o,n,i,"",!1,null,null))return this._onShortcutKey=!0,e.preventDefault(),e.stopPropagation(),!1;if(!o&&!Fe.isNonTextKey(i)&&this.$.format.isLine(a)&&l.collapsed&&Pe.check.isEdgePoint(l.startContainer,0,"front")){const t=l.startContainer.substringData?.(0,l.startOffset);if(t&&this.$.shortcuts.command(e,!1,n,i,t,!0,a,l))return this._onShortcutKey=!0,e.preventDefault(),e.stopPropagation(),!1}else this._onShortcutKey&&(this._onShortcutKey=!1);const h={e,fc:t,store:this.$.store,options:this.$.options,frameOptions:this.$.frameOptions,range:l,selectionNode:s,formatEl:a,keyCode:i,ctrl:o,alt:r,shift:n},c=yr(this,{_styleNodes:Er}),d=await br(c,h);!1!==await this.$.eventManager.triggerEvent("onKeyDown",{frameContext:t,event:e})&&!1!==await this._callPluginEventAsync("onKeyDown",{frameContext:t,event:e,range:l,line:a})&&await ko(d,{ports:c,ctx:h})}async function Mr(t,e){if(this._onShortcutKey||this.$.menu.currentDropdownName)return;const s=e.code,i=Fe.isCtrl(e),n=Fe.isAlt(e);if(i&&(Sr.ctrl=!1),n&&(Sr.alt=!1),t.get("isReadOnly"))return;const o=this.$.selection.getRange();let r=this.$.selection.getNode();if((this.$.store.mode.isBalloon||this.$.store.mode.isSubBalloon)&&((this.$.store.mode.isBalloonAlways||this.$.store.mode.isSubBalloonAlways)&&!Fe.isEsc(s)||!o.collapsed)){if(!this.$.store.mode.isBalloonAlways&&!this.$.store.mode.isSubBalloonAlways)return void(this.$.store.mode.isSubBalloon?this.$.subToolbar._showBalloon():this.$.toolbar._showBalloon());Fe.isEsc(s)||this._showToolbarBalloonDelay()}if(Fe.isBackspace(s)&&Pe.check.isWysiwygFrame(r)&&""===r.textContent&&0===r.children.length){e.preventDefault(),e.stopPropagation(),r.innerHTML="";const i=this.$.store.get("currentNodes")[0],n=Pe.utils.createElement(this.$.format.isLine(i)&&!Pe.check.isListCell(i)?i:this.$.options.get("defaultLine"),null,"
    ");return r.appendChild(n),this.$.selection.setRange(n,0,n,0),this.applyTagEffect(),this.$.history.push(!1),void(t.has("documentType_use_header")&&Fe.isDocumentTypeObserverKey(s)&&t.get("documentType").reHeader())}const l=this.$.format.getLine(r,null),a=this.$.format.getBlock(r,null),h=this._formatAttrsTemp;if(l&&h){for(let t=0,e=h.length;t0?"repeat"===t?this.__retainTimer?(this.__retainTimer=xr.clearTimeout(this.__retainTimer),this._clearRetainStyleNodes(l)):(this.__retainTimer=xr.setTimeout((()=>{this.__retainTimer=null}),0),this._retainStyleNodes(l,Er.value)):(this.__retainTimer=null,this._retainStyleNodes(l,Er.value)):this._clearRetainStyleNodes(l)}if(t.has("documentType_use_header"))if(Fe.isDocumentTypeObserverKey(s)){t.get("documentType").reHeader();const e=Pe.query.getParentElement(this.$.selection.selectionNode,this.$.format.isLine.bind(this.$.format));t.get("documentType").on(e)}else{const e=Pe.query.getParentElement(r,(t=>1===t.nodeType));t.get("documentType").onChangeText(e)}!1!==await this.$.eventManager.triggerEvent("onKeyUp",{frameContext:t,event:e})&&!1!==await this._callPluginEventAsync("onKeyUp",{frameContext:t,event:e,range:o,line:l})&&Fe.isHistoryRelevantKey(s)&&this.$.history.push(!0)}const{_w:Nr}=Oe;function Br(t,e){const s=e.clipboardData;return!s||this._dataTransferAction("paste",e,s,t)}async function Ir(t,e){const s=e.clipboardData;if(!1===await this.$.eventManager.triggerEvent("onCopy",{frameContext:t,event:e,clipboardData:s}))return e.preventDefault(),e.stopPropagation(),!1;const i=t.get("_ww").getSelection();this.__secopy=i.toString()}async function Lr(t,e){const s=e.clipboardData;if(!1===await this.$.eventManager.triggerEvent("onCut",{frameContext:t,event:e,clipboardData:s}))return e.preventDefault(),e.stopPropagation(),!1;const i=t.get("_ww").getSelection();this.__secopy=i.toString(),Nr.setTimeout((()=>{this.$.history.push(!1)}),0)}const{_w:Ar}=Oe;function Or(t,e,s,i,n){if(n.dataTransfer&&Array.from(n.dataTransfer.types||[]).includes("application/x-suneditor-block-drag"))return;const{sc:o,so:r,ec:l,eo:a}=this.$.selection.getDragEventLocationRange(n);if(!o)return;n.preventDefault();const h=t.get("_wd").createRange();h.setStart(o,r),h.setEnd(l,a);const c={y:0,x:0};if(s){const t=this.$.offset.getGlobal(s),e=i?this.$.context.get("toolbar_main").offsetHeight:0;c.y=t.top+e-Ar.scrollY,c.x=t.left-Ar.scrollX}const d=h.getBoundingClientRect();if(d.height>0){const s=t.get("wysiwygFrame");let i=0,n=0;/^iframe$/i.test(s.nodeName)&&(i=s.offsetLeft,n=s.offsetTop),e.style.left=`${d.right+Ar.scrollX+c.x+i}px`,e.style.top=`${d.top+Ar.scrollY+c.y-5+n}px`,e.style.height=`${d.height+10}px`,e.style.display="block";try{e.showPopover?.()}catch{}}else{try{e.hidePopover?.()}catch{}e.style.display="none"}}function Rr(t){try{t.hidePopover?.()}catch{}t.style.display="none"}function zr(t,e,s){try{if(t.get("isReadOnly"))return s.preventDefault(),s.stopPropagation(),!1;const e=s.dataTransfer;if(!e)return!0;if(Array.from(e.types||[]).includes("application/x-suneditor-block-drag"))return;const{sc:i,so:n,ec:o,eo:r}=this.$.selection.getDragEventLocationRange(s);if(!i)return;if(Pe.query.getParentElement(i,".se-disable-pointer"))return void s.preventDefault();if(_i.get("__dragContainer")){if(s.preventDefault(),_i.get("__dragContainer").contains(s.target))return void this.$.component.deselect();const e=_i.get("__dragContainer");return this.$.component.deselect(),this.$.selection.setRange(i,n,o,r),this.$.html.insertNode(e,{afterNode:null,skipCharCount:!0}),void(t.has("documentType_use_page")&&(t.get("documentTypePageMirror").innerHTML=t.get("wysiwyg").innerHTML,t.get("documentType").rePage(!0)))}return this.$.html.remove(),this.$.selection.setRange(i,n,o,r),this._dataTransferAction("drop",s,e,t)}finally{try{e.hidePopover?.()}catch{}e.style.display="none"}}class Pr{#J;constructor({$:t}){this.#J=t}execute(t){if(!this.#J.options.get("__lineFormatFilter"))return null;if(this.#J.pluginManager.fileInfo.pluginRegExp.test(this.#J.ui.currentControllerName))return;const e=this.#J.selection.getRange(),s=e.commonAncestorContainer,i=e.startContainer,n=e.endOffset,o=this.#J.format.getBlock(s,null);let r,l,a;if(o)return a=Pe.utils.createElement(t||this.#J.options.get("defaultLine")),a.innerHTML=o.innerHTML,0===a.childNodes.length&&(a.innerHTML=Re.zeroWidthSpace),o.innerHTML=a.outerHTML,a=o.firstChild,r=a.childNodes[n]||Pe.query.getEdgeChildNodes(a,null).sc,r||(r=Pe.utils.createTextNode(Re.zeroWidthSpace),a.insertBefore(r,a.firstChild)),l=r.textContent.length,void this.#J.selection.setRange(r,l,r,l);if(3===s.nodeType&&this.#J.component.is(s.parentElement)){const t=this.#J.component.get(s.parentElement);if(!t)return;const e=t.container;if(s.parentElement===e){const t=s.nextElementSibling?e:e.nextElementSibling,i=Pe.utils.createElement(this.#J.options.get("defaultLine"),null,s);return e.parentElement.insertBefore(i,t),void this.#J.focusManager.focusEdge(i)}return this.#J.component.select(t.target,t.pluginName),null}if(1===s.nodeType&&"true"===s.getAttribute("data-se-embed")){let t=s.nextElementSibling;return this.#J.format.isLine(t)||(t=this.#J.format.addLine(s,this.#J.options.get("defaultLine"))),void this.#J.selection.setRange(t.firstChild,0,t.firstChild,0)}if(!this.#J.format.isBlock(i)&&!Pe.check.isWysiwygFrame(i)||!this.#J.component.is(i.children[e.startOffset])&&!this.#J.component.is(i.children[e.startOffset-1])){if(Pe.query.getParentElement(s,Pe.check.isExcludeFormat))return null;if(this.#J.format.isBlock(s)&&s.childNodes.length<=1){let t=null;return 1===s.childNodes.length&&Pe.check.isBreak(s.firstChild)?t=s.firstChild:(t=Pe.utils.createTextNode(Re.zeroWidthSpace),s.appendChild(t)),void this.#J.selection.setRange(t,1,t,1)}try{if(3===s.nodeType&&(a=Pe.utils.createElement(t||this.#J.options.get("defaultLine")),s.parentNode.insertBefore(a,s),a.appendChild(s)),Pe.check.isBreak(a.nextSibling)&&Pe.utils.removeItem(a.nextSibling),Pe.check.isBreak(a.previousSibling)&&Pe.utils.removeItem(a.previousSibling),Pe.check.isBreak(r)){const t=Pe.utils.createTextNode(Re.zeroWidthSpace);r.parentNode.insertBefore(t,r),r=t}}catch{return this.#J.frameContext.get("_wd").execCommand("formatBlock",!1,`<${t||this.#J.options.get("defaultLine")}>`),this.#J.store.set("_lastSelectionNode",null),void this.#J.selection.init()}if(a&&(Pe.check.isBreak(a.nextSibling)&&Pe.utils.removeItem(a.nextSibling),Pe.check.isBreak(a.previousSibling)&&Pe.utils.removeItem(a.previousSibling),Pe.check.isBreak(r))){const t=Pe.utils.createTextNode(Re.zeroWidthSpace);r.parentNode.insertBefore(t,r),r=t}this.#J.store.set("_lastSelectionNode",null),i?this.#J.selection.setRange(i,1,i,1):this.#J.focusManager.nativeFocus()}}}class Dr{#ta;#J;#ea;constructor(t){this.#ta=t,this.#J=t.$,this.#ea=new RegExp(`^(${Object.keys(this.#J.options.get("_defaultStyleTagMap")).join("|")})$`,"i")}update(t){if(t||=this.#J.selection.getNode(),t===this.#J.store.get("_lastSelectionNode"))return;this.#J.store.set("_lastSelectionNode",t);const e=this.#J.options.get("_rtl")?"marginRight":"marginLeft",s=this.#J.plugins,i=this.#J.commandDispatcher.targets,n=this.#ea,o=this.#J.options.get("_styleCommandMap"),r=[],l=[],a=this.#J.options.get("_textStyleTags"),h=[],c=[],d=this.#J.commandDispatcher.activeCommands,u=d.length;let p="";if(this.#J.component.is(t)&&!this.#J.component.__selectionSelected){const e=this.#J.component.get(t);if(!e)return;return this.#J.store.set("_lastSelectionNode",null),void this.#J.component.select(e.target,e.pluginName)}for(;t.firstChild;)t=t.firstChild;const g=this.#J.frameContext,m=!g.get("isReadOnly");for(let g=t;!Pe.check.isWysiwygFrame(g)&&g;g=g.parentElement)if(1===g.nodeType&&!Pe.check.isBreak(g)){if(this.#sa(g))return void this.#J.focusManager.blur();if(p=g.nodeName.toLowerCase(),l.push(p),a.includes(p)&&!this.#J.format.isLine(p)&&h.push(g),m)for(let t,e=0;e{const i=s[t]?.active(g,e);return void 0===i&&c.push(t),i})).length>0&&r.push(t);if(this.#J.format.isLine(g)){if(!r.includes("outdent")&&i.has("outdent")&&(Pe.check.isListCell(g)||g.style[e]&&De.get(g.style[e],0)>0)&&i.get("outdent").filter((t=>!Pe.check.isImportantDisabled(t)&&(t.disabled=!1,!0))).length>0&&r.push("outdent"),!r.includes("indent")&&i.has("indent")){const t=Pe.check.isListCell(g)&&!g.previousElementSibling;i.get("indent").filter((e=>!Pe.check.isImportantDisabled(e)&&(e.disabled=t,!0))).length>0&&r.push("indent")}}else n.test(p)&&(p=o[p]||p,r.push(p),Pe.utils.addClass(i.get(p),"active"))}return this.#ia(r),this.#ta.__cacheStyleNodes=h.reverse(),this.#J.store.set("currentNodes",l.reverse()),this.#J.store.set("currentNodesMap",r),this.#J.frameOptions.get("statusbar_showPathLabel")&&g.get("navigation")&&(g.get("navigation").textContent=this.#J.options.get("_rtl")?this.#J.store.get("currentNodes").reverse().join(" < "):this.#J.store.get("currentNodes").join(" > ")),t}reset(){this.#ia([])}#ia(t){const e=this.#J.commandDispatcher.activeCommands,s=this.#J.commandDispatcher.targets,i=this.#J.plugins;for(let n,o,r,l=0,a=e.length;l{Fr.clearTimeout(this.#ra),this.#ra=null,this.#t.mode.isSubBalloon?this.$.subToolbar._showBalloon():this.#o._showBalloon()}),250)}#ca(){this.#ra&&Fr.clearTimeout(this.#ra),this.#ra=Fr.setTimeout((()=>{Fr.clearTimeout(this.#ra),this.#ra=null,this._toggleToolbarBalloon()}),250)}_toggleToolbarBalloon(){this.$.selection.init();const t=this.$.selection.getRange(),e=this.#rt.has("_subMode");!(e?this.#t.mode.isSubBalloonAlways:this.#t.mode.isBalloonAlways)&&t.collapsed?e?this._hideToolbar_sub():this._hideToolbar():e?this.$.subToolbar._showBalloon(t):this.#o._showBalloon(t)}_hideToolbar(){this.#na.isPreventToolbarHide||this.$.frameContext.get("isFullScreen")||this.#o.hide()}_hideToolbar_sub(){this.$.subToolbar&&!this.#na.isPreventToolbarHide&&this.$.subToolbar.hide()}_setDefaultLine(t){return this.defaultLineManager.execute(t)}_normalizeEditRange(){if(!this.$.format.isLine(this.$.selection.getRange()?.startContainer))return null;this.$.selection.resetRangeToTextNode();const t=this.$.selection.getRange();if(t.startContainer===t.endContainer&&t.startOffset!==t.endOffset&&3===t.startContainer.nodeType&&Pe.check.isZeroWidth(t.startContainer)){const e=t.startContainer,s=e.nextSibling;s&&Pe.check.isBreak(s)?(Pe.utils.removeItem(e),this.$.selection.setRange(s,0,s,0)):this.$.selection.setRange(t.endContainer,t.endOffset,t.endContainer,t.endOffset)}return this.$.selection.getNode()}async _dataTransferAction(t,e,s,i){try{return this.#na.showLoading(),await this.#da(t,e,s,i),e.preventDefault(),e.stopPropagation(),!1}catch(t){console.warn("[SUNEDITOR.paste.error]",t)}finally{this.#na.hideLoading()}}async#da(t,e,s,i){e.preventDefault(),e.stopPropagation();let n=s.getData("text/plain"),o=s.getData("text/html");const r=!o,l=this.__secopy===n,a=/class=["']*Mso(Normal|List)/i.test(o)||/content=["']*Word.Document/i.test(o)||/content=["']*OneNote.File/i.test(o)||/content=["']*Excel.Sheet/i.test(o),h=!l&&!a&&Ue.isGoogleDocs(o),c=l?"SE":a?"MS":h?"GOOGLE":"";if(r?o=ze.htmlToEntity(n).replace(/\n/g,"
    "):(o=o.replace(/^\r?\n?\r?\n?\x3C!--StartFragment-->|\x3C!--EndFragment-->\r?\n?<\/body>\r?\n?<\/html>$/g,""),a?(o=o.replace(/\n/g," "),n=n.replace(/\n/g," "),o=We.cleanHTML(o)):h&&(o=Ue.cleanHTML(o))),!l){if(this.#rt.get("autoLinkify")){const t=(new DOMParser).parseFromString(o,"text/html");Pe.query.getListChildNodes(t.body,ze.textToAnchor,null),o=t.body.innerHTML}}r||(o=this.$.html.clean(o,{forceFormat:!1,whitelist:null,blacklist:null}));const d=this.$.char.test("byte-html"===this.$.frameOptions.get("charCounter_type")?o:n,!1);if("paste"===t){const t=await this.#_i.triggerEvent("onPaste",{frameContext:i,event:e,data:o,maxCharCount:d,from:c});if(!1===t)return!1;if("string"==typeof t){if(!t)return!1;o=t}}if("drop"===t){const t=await this.#_i.triggerEvent("onDrop",{frameContext:i,event:e,data:o,maxCharCount:d,from:c});if(!1===t)return!1;if("string"==typeof t){if(!t)return!1;o=t}}const u=s.files;if(u.length>0&&!a){for(let t=0,s=u.length;t{Fr.setTimeout((()=>{this.#o.resetResponsiveToolbar()}),0)})),this._wwFrameObserver=new ResizeObserver((t=>{Fr.setTimeout((()=>{t.forEach((t=>{this.#na._emitResizeEvent(this.$.frameRoots.get(t.target.getAttribute("data-root-key")),-1,t)})),this.#t.mode.isInline&&this.#t.mode.isBottom&&this.#o._resetSticky()}),0)}))),this.#rt.get("closeModalOutsideClick")&&this.#_i.addEvent(this.#Ci.carrierWrapper.querySelector(".se-modal .se-modal-inner"),"click",(t=>{t.target===this.#Ci.carrierWrapper.querySelector(".se-modal .se-modal-inner")&&this.#na.offCurrentModal()}),!1),this.#_i.addEvent(Fr,"resize",this.#ua.bind(this),!1),this.#_i.addEvent(Fr.visualViewport,"resize",this.#pa.bind(this),!1),this.#_i.addEvent(Fr,"scroll",this.#ga.bind(this),!1),qr&&this.#_i.addEvent(Fr.visualViewport,"scroll",this.#ma.bind(this),!1)}_addFrameEvents(t){const e=t.get("options").get("iframe"),s=e?t.get("_ww"):t.get("wysiwyg");t.set("eventWysiwyg",s);const i=t.get("code"),n=this.#Ci.carrierWrapper.querySelector(".se-drag-cursor"),o=lo.bind(this,t);this.#_i.addEvent(s,"mousemove",o,!1),this.#_i.addEvent(s,"mouseleave",ao.bind(this,t),!1),this.#_i.addEvent(s,"mousedown",io.bind(this,t),!1),this.#_i.addEvent(s,"mouseup",oo.bind(this,t),!1),this.#_i.addEvent(s,"click",ro.bind(this,t),!1),this.#_i.addEvent(s,"beforeinput",Cr.bind(this,t),!1),this.#_i.addEvent(s,"input",kr.bind(this,t),!1),this.#_i.addEvent(s,"keydown",Tr.bind(this,t),!1),this.#_i.addEvent(s,"keyup",Mr.bind(this,t),!1),this.#_i.addEvent(s,"paste",Br.bind(this,t),!1),this.#_i.addEvent(s,"copy",Ir.bind(this,t),!1),this.#_i.addEvent(s,"cut",Lr.bind(this,t),!1),this.#_i.addEvent(s,"dragover",Or.bind(this,t,n,e?this.$.frameContext.get("topArea"):null,!this.#rt.get("toolbar_container")&&!this.#t.mode.isBalloon&&!this.#t.mode.isInline),!1),this.#_i.addEvent(s,"dragend",Rr.bind(this,n),!1),this.#_i.addEvent(s,"drop",zr.bind(this,t,n),!1),this.#_i.addEvent(s,"scroll",this.#fa.bind(this,t,s),{passive:!0,capture:!1}),this.#_i.addEvent(s,"focus",this.#va.bind(this,t),!1),this.#_i.addEvent(s,"blur",this.#ba.bind(this,t),!1),this.#_i.addEvent(i,"mousedown",this.#ya.bind(this,t),!1);const r=t.get("wrapper").querySelector(".se-drag-handle");if(this.#_i.addEvent(r,"wheel",(t=>{t.preventDefault(),this.$.component.deselect()}),!1),this.#_i.addEvent(t.get("lineBreaker_t"),"pointerdown",this.#wa.bind(this,"t"),!1),this.#_i.addEvent(t.get("lineBreaker_b"),"pointerdown",this.#wa.bind(this,"b"),!1),qr&&this.#_i.addEvent(s,"touchstart",o,{passive:!0,capture:!1}),!this.#rt.get("hasCodeMirror")){const e=t.get("codeNumbers"),s=this.$.viewer._codeViewAutoHeight.bind(this.$.viewer,t.get("code"),e,"auto"===this.$.frameOptions.get("height"));this.#_i.addEvent(i,"keydown",s,!1),this.#_i.addEvent(i,"keyup",s,!1),this.#_i.addEvent(i,"paste",s,!1),this.#rt.get("tabDisable")||this.#_i.addEvent(i,"keydown",Wr,!1),e&&this.#_i.addEvent(i,"scroll",this.$.viewer._scrollLineNumbers.bind(i,e),!1)}const l=t.get("markdown");if(l){this.#_i.addEvent(l,"mousedown",this.#Ca.bind(this,t),!1);const e=t.get("markdownNumbers"),s=this.$.viewer._markdownViewAutoHeight.bind(this.$.viewer,l,e,"auto"===this.$.frameOptions.get("height"));this.#_i.addEvent(l,"keydown",s,!1),this.#_i.addEvent(l,"keyup",s,!1),this.#_i.addEvent(l,"paste",s,!1),this.#rt.get("tabDisable")||this.#_i.addEvent(l,"keydown",Wr,!1),e&&this.#_i.addEvent(l,"scroll",this.$.viewer._scrollMarkdownLineNumbers.bind(l,e),!1)}t.has("statusbar")&&this.__addStatusbarEvent(t,t.get("options"));const a=this.#_a.bind(this),h=Pe.query.getScrollParents(t.get("originElement"));for(const t of h)this.scrollparents.push(t),this.#_i.addEvent(t,"scroll",a,!1);this.#_i.addEvent(this.__focusTemp,"focus",(t=>t.preventDefault()),!1),this.__eventDoc!==t.get("_wd")&&(this.__eventDoc=t.get("_wd"),this.#_i.addEvent(this.__eventDoc,"selectionchange",this.#ka.bind(this,this.__eventDoc),!1))}__addStatusbarEvent(t,e){/\d+/.test(e.get("height"))&&e.get("statusbar_resizeEnable")?e.set("__statusbarEvent",this.#_i.addEvent(t.get("statusbar"),"mousedown",this.#xa.bind(this),!1)):Pe.utils.addClass(t.get("statusbar"),"se-resizing-none")}_removeAllEvents(){this.#_i._init(),this._wwFrameObserver&&(this._wwFrameObserver.disconnect(),this._wwFrameObserver=null),this._toolbarObserver&&(this._toolbarObserver.disconnect(),this._toolbarObserver=null),this.#ra&&(Fr.clearTimeout(this.#ra),this.#ra=null),this.__retainTimer&&(Fr.clearTimeout(this.__retainTimer),this.__retainTimer=null),this.#aa&&=this.#_i.removeGlobalEvent(this.#aa),this.#ha&&=this.#_i.removeGlobalEvent(this.#ha),this.#la&&=this.#_i.removeGlobalEvent(this.#la),this._formatAttrsTemp=null,this.__cacheStyleNodes=null,this.__inputPlugin=null,this.__inputBlurEvent=null,this.__inputKeyEvent=null,this.__focusTemp=null,this.__eventDoc=null,this.__secopy=null,this._lineBreakComp=null,this.scrollparents=null}_setSelectionSync(){this.#_i.removeGlobalEvent(this.#aa),this.#aa=this.#_i.addGlobalEvent("mouseup",(()=>{this.$.selection.init(),this.#_i.removeGlobalEvent(this.#aa)}))}_retainStyleNodes(t,e){let s=e[0].cloneNode(!1);for(let t,i=1,n=e.length;i",this.$.selection.setRange(t,0,t,0)}_callPluginEvent(t,e){return this.$.pluginManager.emitEvent(t,e)}async _callPluginEventAsync(t,e){return await this.$.pluginManager.emitEventAsync(t,e)}__removeInput(){this.#t.set("_preventBlur",!1),this._inputFocus=!1,this.__inputBlurEvent=this.#_i.removeEvent(this.__inputBlurEvent),this.__inputKeyEvent=this.#_i.removeEvent(this.__inputKeyEvent),this.__inputPlugin=null}__postFocusEvent(t,e){(this.#t.mode.isInline||this.#t.mode.isBalloonAlways)&&this.#o.show(),this.#t.mode.isSubBalloonAlways&&this.$.subToolbar.show(),this.#o._resetSticky(),this.#na._updatePlaceholder(t),this.#_i.triggerEvent("onFocus",{frameContext:t,event:e}),this._callPluginEvent("onFocus",{frameContext:t,event:e})}__postBlurEvent(t,e){this.#t.mode.isInline?Fr.setTimeout((()=>{this.#t.get("hasFocus")||this._hideToolbar()}),0):this.#t.mode.isBalloon&&this._hideToolbar(),this.#t.mode.isSubBalloon&&this._hideToolbar_sub(),this.#_i.triggerEvent("onBlur",{frameContext:t,event:e}),this._callPluginEvent("onBlur",{frameContext:t,event:e})}__setViewportSize(){this.#t.set("currentViewportHeight",De.get(Fr.visualViewport.height,0))}#$a(){this.#oa.currentDropdownActiveButton&&this.#oa.currentDropdown&&this.#oa.__resetMenuPosition(this.#oa.currentDropdownActiveButton,this.#oa.currentDropdown),this.#na._repositionControllers()}#Sa(){Oe.isResizeObserverSupported||(this.#o.resetResponsiveToolbar(),this.#rt.get("_subMode")&&this.$.subToolbar.resetResponsiveToolbar());const t=this.#e.get("toolbar_main"),e="none"===t.style.display||this.#t.mode.isInline&&!this.#o.inlineToolbarAttr.isShow;if(0===t.offsetWidth&&!e)return;const s=this.#na.opendBrowser;if(s&&"block"===s.area.style.display&&(s.body.style.maxHeight=Pe.utils.getClientSize().h-s.header.offsetHeight-50+"px"),this.#oa.currentDropdownActiveButton&&this.#oa.currentDropdown&&this.#oa.__resetMenuPosition(this.#oa.currentDropdownActiveButton,this.#oa.currentDropdown),this.$.viewer._resetFullScreenHeight())return;const i=this.$.frameContext;i.get("isCodeView")&&this.#t.mode.isInline?this.#o._showInline():(this.#na._iframeAutoHeight(i),this.#o.isSticky&&(this.#o.isCSSSticky||(this.#e.get("toolbar_main").style.width=i.get("topArea").offsetWidth-2+"px"),this.#o._resetSticky()))}#fa(t,e,s){this.#na._syncScrollPosition(e),this.#$a(),this._callPluginEvent("onScroll",{frameContext:t,event:s}),t.has("documentType_use_page")&&t.get("documentType").scrollPage(),this.#_i.triggerEvent("onScroll",{frameContext:t,event:s})}#va(t,e){if(this.$.selection.__iframeFocus||t.get("isReadOnly")||t.get("isDisabled"))return e.preventDefault(),!1;this.#t.set("hasFocus",!0),this.$.component.__prevent=!1,this.#_i.triggerEvent("onNativeFocus",{frameContext:t,event:e});const s=t.get("key");this._inputFocus?this.#t.mode.isInline&&Fr.setTimeout((()=>{this.#o._showInline()}),0):this.#t.get("rootKey")===s&&this.#t.get("_preventBlur")||this.#t.get("_preventFocus")||(this.#t.set("_preventFocus",!0),Pe.utils.removeClass(this.$.commandDispatcher.targets.get("codeView"),"active"),this.#na._toggleCodeViewButtons(!1),this.$.facade.changeFrameContext(s),this.$.history.resetButtons(s,null),Fr.setTimeout((()=>{this.__postFocusEvent(t,e)}),0))}#ba(t,e){t.get("isCodeView")||t.get("isReadOnly")||t.get("isDisabled")||(this.#t.set("hasFocus",!1),this.#t.set("_lastSelectionNode",null),this.#_i.triggerEvent("onNativeBlur",{frameContext:t,event:e}),this.#na._updatePlaceholder(t),this._inputFocus||this.#t.get("_preventBlur")||(this.#t.set("_preventFocus",!1),this.selectionState.reset(),this.#t.set("currentNodes",[]),this.#t.set("currentNodesMap",[]),this.#na.offCurrentController(),this.#Ci.applyToRoots((t=>{t.get("navigation")&&(t.get("navigation").textContent="")})),this.$.history.check(t.get("key"),this.#t.get("_range")),this.__postBlurEvent(t,e)))}#xa(t){t.stopPropagation(),this._resizeClientY=t.clientY,this.#na.enableBackWrapper("ns-resize"),this.#ha=this.#_i.addGlobalEvent("mousemove",this.#Ea.bind(this)),this.#la=this.#_i.addGlobalEvent("mouseup",this.#Ta.bind(this))}#Ea(t){const e=this.$.frameContext,s=e.get("wrapper").offsetHeight+(t.clientY-this._resizeClientY),i=s"),"byte-html"!==this.$.frameOptions.get("charCounter_type")||this.$.char.check(n.outerHTML)){s.parentNode.insertBefore(n,"t"===t?s:s.nextSibling),this.$.component.deselect();try{const t=i?n:n.firstChild;this.$.selection.setRange(t,1,t,1),this.$.history.push(!1)}catch(t){console.warn("[SUNEDITOR.lineBreaker.error]",t)}}}#ua(){this.#t.set("initViewportHeight",Fr.visualViewport.height),Hr||this.#na.offCurrentController(),this.#t.mode.isBalloon?this.#o.hide():this.#t.mode.isSubBalloon&&this.$.subToolbar.hide(),this.#Sa()}#pa(){Hr&&this.#rt.get("_toolbar_sticky")>-1&&(this.#o._resetSticky(),this.#oa.__restoreMenuPosition()),this.#$a();const t=this.#t.get("currentViewportHeight");this.__setViewportSize(),Hr&&t>0&&t-Fr.visualViewport.height>100&&this.#t.get("hasFocus")&&this.$.selection.scrollTo(this.$.selection.getRange(),{behavior:"auto",block:"nearest",inline:"nearest"})}#ga(){this.#rt.get("_toolbar_sticky")>-1&&this.#o._resetSticky(),this.#t.mode.isBalloon&&"block"===this.#e.get("toolbar_main").style.display?this.#o._setBalloonOffset("top"===this.#o.balloonOffset.position):this.#t.mode.isSubBalloon&&"block"===this.#e.get("toolbar_sub_main").style.display&&this.$.subToolbar._setBalloonOffset("top"===this.$.subToolbar.balloonOffset.position),this.#$a(),this.#na.blockHandle?.syncScroll(),this.$.frameContext.has("documentType_use_page")&&this.$.frameContext.get("documentType").scrollWindow()}#ma(){this.#rt.get("_toolbar_sticky")>-1&&(this.#o._resetSticky(),this.#oa.__restoreMenuPosition())}#ka(t){let e=t.getSelection().anchorNode;this.#Ci.applyToRoots((t=>{if(e&&t.get("wysiwyg").contains(e)){if(t.get("isReadOnly")||t.get("isDisabled"))return;if(e=null,this.$.selection.init(),this.applyTagEffect(),this.#na._updatePlaceholder(t),qr&&(this.#t.mode.isBalloon||this.#t.mode.isSubBalloon)&&this.#ca(),t.has("documentType_use_header")){const e=Pe.query.getParentElement(this.$.selection.selectionNode,this.$.format.isLine.bind(this.$.format));t.get("documentType").on(e)}}}))}#_a(){this.#oa.dropdownOff(),this.#$a(),this.#na.blockHandle?.syncScroll()}#ya(t){this.$.facade.changeFrameContext(t.get("key")),Pe.utils.addClass(this.$.commandDispatcher.targets.get("codeView"),"active"),this.#na._toggleCodeViewButtons(!0)}#Ca(t){this.$.facade.changeFrameContext(t.get("key")),Pe.utils.addClass(this.$.commandDispatcher.targets.get("markdownView"),"active"),this.#na._toggleCodeViewButtons(!0)}};const Vr=class{#Ma=new Map;#Na=new Map;$=null;constructor(t,e){const{product:s,options:i}=e;this.store=new _s(s),this.$={facade:t,store:this.store},this.#Ba(s,i),this.#Ia(),this.#La(s),this.#Aa(),this.#Oa(),this._eventOrchestrator=new Ur(this),this.#Ma.get("eventManager")._bindOrchestrator(this._eventOrchestrator)}#Ba(t,e){const s=new $s(t),i=new Ss(this,t,e);this.#Ma.set("contextProvider",s),this.#Ma.set("optionProvider",i),this.#Ma.set("instanceCheck",new Es(s.frameContext)),this.#Ma.set("eventManager",new Bs(s,i,this.$))}#Ia(){const t=this.#Ma.get("contextProvider"),e=this.#Ma.get("optionProvider");Object.assign(this.$,{contextProvider:t,optionProvider:e,instanceCheck:this.#Ma.get("instanceCheck"),eventManager:this.#Ma.get("eventManager"),frameRoots:t.frameRoots,context:t.context,options:e.options,icons:t.icons,lang:t.lang,frameContext:t.frameContext,frameOptions:e.frameOptions})}#La(t){this.#Na.set("offset",new Is(this)),this.#Na.set("selection",new As(this)),this.#Na.set("html",new fi(this)),this.#Na.set("nodeTransform",new vi(this)),this.#Na.set("format",new Rs(this)),this.#Na.set("inline",new Ps(this)),this.#Na.set("listFormat",new Fs(this)),this.#Na.set("char",new yi(this)),this.#Na.set("shortcuts",new wi(this)),this.#Na.set("component",new tn(this)),this.#Na.set("pluginManager",new en(this,t)),this.#Na.set("focusManager",new sn(this)),this.#Na.set("ui",new Mn(this)),this.#Na.set("commandDispatcher",new $n(this)),this.#Na.set("toolbar",new Rn(this,{keyName:"toolbar",balloon:this.store.mode.isBalloon,balloonAlways:this.store.mode.isBalloonAlways,inline:this.store.mode.isInline,res:t.responsiveButtons})),this.$.options.has("_subMode")&&this.#Na.set("subToolbar",new Rn(this,{keyName:"toolbar_sub",balloon:this.store.mode.isSubBalloon,balloonAlways:this.store.mode.isSubBalloonAlways,inline:!1,res:t.responsiveButtons_sub})),this.#Na.set("menu",new Fn(this)),this.#Na.set("viewer",new Un(this)),this.#Na.set("finder",new Kn(this)),this.#Na.set("history",An(this))}#Oa(){for(const[,t]of this.#Na)"function"==typeof t?._init&&t._init()}#Aa(){const t=this.#Na.get("pluginManager");Object.assign(this.$,{offset:this.#Na.get("offset"),selection:this.#Na.get("selection"),format:this.#Na.get("format"),inline:this.#Na.get("inline"),listFormat:this.#Na.get("listFormat"),html:this.#Na.get("html"),nodeTransform:this.#Na.get("nodeTransform"),char:this.#Na.get("char"),component:this.#Na.get("component"),focusManager:this.#Na.get("focusManager"),pluginManager:t,plugins:t.plugins,ui:this.#Na.get("ui"),commandDispatcher:this.#Na.get("commandDispatcher"),history:this.#Na.get("history"),shortcuts:this.#Na.get("shortcuts"),toolbar:this.#Na.get("toolbar"),subToolbar:this.#Na.get("subToolbar"),menu:this.#Na.get("menu"),viewer:this.#Na.get("viewer"),finder:this.#Na.get("finder")})}_destroy(){if(null===this.$)return;const t=[];for(const[e,s]of this.#Na)try{s?._destroy?.()}catch(s){t.push(`[Logic:${e}] ${s.message}`)}this.#Na.clear();try{this._eventOrchestrator?._removeAllEvents()}catch(e){t.push(`[EventOrchestrator] ${e.message}`)}this._eventOrchestrator=null;for(const[e,s]of this.#Ma)try{s?._destroy?.()}catch(s){t.push(`[Config:${e}] ${s.message}`)}this.#Ma.clear(),t.length>0&&console.warn("[CoreKernel._destroy] Cleanup completed with errors:",t),this.$=null,this.store._destroy(),this.store=null,this.facade=null}};const jr=class{#H;$;constructor(t,e){const s=bs(t,e),i=new Vr(this,{product:s,options:e});this.#H=i,this.$=i.$,this.#Ra(e).catch((t=>{console.error("[SUNEDITOR:E_CREATE_FAIL] Failed to create editor instance.",t)}))}isEmpty(t){const e=(t||this.$.frameContext).get("wysiwyg");return Pe.check.isZeroWidth(e.textContent)&&!e.querySelector(this.$.options.get("allowedEmptyTags"))&&(e.innerText.match(/\n/g)||"").length<=1}resetOptions(t){this.$.optionProvider.reset(t),this.$.store.set("_lastSelectionNode",null),this.#za(this.$.frameRoots.get(this.$.store.get("rootKey")));for(const t of Object.values(this.$.plugins))t.init?.()}changeFrameContext(t){t!==this.$.store.get("rootKey")&&(this.$.store.set("rootKey",t),this.#za(this.$.frameRoots.get(t)),this.$.toolbar._resetSticky())}destroy(){this.$.options.get("hasCodeMirror")&&this.$.contextProvider.applyToRoots((t=>{const e=t.get("options").get("codeMirrorEditor");e&&e.toTextArea()})),Pe.utils.removeItem(this.$.context.get("toolbar_wrapper")),Pe.utils.removeItem(this.$.context.get("toolbar_sub_wrapper")),Pe.utils.removeItem(this.$.context.get("statusbar_wrapper"));for(const t in this.events)this.events[t]=null;return this.events=null,this.#H._destroy(),null}#za(t){this.$.contextProvider.reset(t),this.$.optionProvider.resetFrame(t.get("options")),this.$.ui.reset(t)}#Pa(t){this.$.store.set("initViewportHeight",Oe._w.visualViewport.height),this.#H._eventOrchestrator.__setViewportSize(),this.$.store.set("_canUseBeforeInput",Oe.canUseBeforeInput()),this.$.contextProvider.init(),this.#za(this.$.frameRoots.get(this.$.store.get("rootKey"))),this.#Ts(t),this.$.contextProvider.applyToRoots((t=>{this.#H._eventOrchestrator._addFrameEvents(t),this.#Da(t,t.get("options").get("value")),t.get("options").get("iframe")&&"auto"===t.get("options").get("height")&&this.$.ui._emitResizeEvent(t,t.get("wysiwygFrame").offsetHeight,null)})),this.#H._eventOrchestrator.__eventDoc=null,this.$.store._editorInitFinished=!0,this.$.pluginManager.checkFileInfo(!0),this.$.history.reset(),Oe._w.setTimeout((()=>{if(this.$.context?.size){this.$.context.get("toolbar_main").style.visibility="",this.$.contextProvider.applyToRoots((t=>{this.#H._eventOrchestrator._wwFrameObserver&&this.#H._eventOrchestrator._wwFrameObserver.observe(t.get("wysiwygFrame")),this.#H._eventOrchestrator._toolbarObserver&&this.#H._eventOrchestrator._toolbarObserver.observe(t.get("_toolbarShadow")),this.$.ui._syncFrameState(t)}));for(const t of Object.values(this.$.plugins))t.init?.();this.$.selection.__init(),this.$.eventManager.triggerEvent("onload",{})}else console.warn("[SUNEDITOR:E_INIT_FAIL] Editor instance was destroyed before initialization completed. Check if destroy() was called.")}),0)}#Da(t,e){if(t.get("wysiwyg").innerHTML=this.$.html.clean("string"==typeof e?e:(/^TEXTAREA$/i.test(t.get("originElement").nodeName)?t.get("originElement").value:t.get("originElement").innerHTML)||"",{forceFormat:!0,whitelist:null,blacklist:null,_freeCodeViewMode:this.$.options.get("freeCodeViewMode")})||"<"+this.$.options.get("defaultLine")+">
    ",t.has("charCounter")&&(t.get("charCounter").textContent=String(this.$.char.getLength())),t.has("wordCounter")&&(t.get("wordCounter").textContent=String(this.$.char.getWordCount())),"document"===this.$.options.get("type")&&(t.set("documentType",new Cs(this.#H,t)),t.get("documentType").useHeader&&t.set("documentType_use_header",!0),t.get("documentType").usePage)){t.set("documentType_use_page",!0);const e=t.get("documentTypePageMirror"),s=e.ownerDocument.createDocumentFragment();for(let e=t.get("wysiwyg").firstChild;e;e=e.nextSibling)s.appendChild(e.cloneNode(!0));e.replaceChildren(s)}}#Ts(t){this.$.pluginManager.init(t),this.$.shortcuts._registerShortcuts(),this.$.commandDispatcher._initCommandButtons(),this.$.ui.init()}#Fa(t,e,s){t.contentDocument.documentElement.className="sun-editor",t.contentDocument.head.innerHTML=''+ze._setIframeStyleLinks(s.get("iframe_cssFileName"))+ze._setAutoHeightStyle(s.get("height")),t.contentDocument.body.className=e.get("_editableClass"),t.contentDocument.body.setAttribute("contenteditable","true"),e.get("_rtl")&&(t.contentDocument.body.dir="rtl")}async#Ra(t){this.#H._eventOrchestrator._addCommonEvents();const e=[];this.$.contextProvider.applyToRoots((t=>{const s=t.get("originElement"),i=t.get("topArea");if(s.style.display="none",i.style.display="block",s.parentNode.insertBefore(i,s.nextElementSibling),t.get("options").get("iframe")){const s=new Promise((e=>{const s=s=>{this.#Fa(s,this.$.optionProvider.options,t.get("options")),e()};if(Oe.isGecko){let e=null;this.$.eventManager.addEvent(t.get("wysiwygFrame"),"load",(({target:t})=>{clearTimeout(e),e=setTimeout((()=>{this.$&&s(t)}),60)}))}else this.$.eventManager.addEvent(t.get("wysiwygFrame"),"load",(({target:t})=>{s(t)}))}));e.push(s)}})),this.$.contextProvider.applyToRoots((t=>{t.get("wrapper").appendChild(t.get("wysiwygFrame")),t.get("documentTypeInner")&&t.get("wrapper").insertBefore(t.get("documentTypeInner"),t.get("wysiwygFrame")),t.get("documentTypePage")&&(t.get("wrapper").appendChild(t.get("documentTypePage")),t.get("wrapper").appendChild(t.get("documentTypePageMirror"))),t.get("blockHandleArea")&&t.get("wrapper").insertBefore(t.get("blockHandleArea"),t.get("wysiwygFrame"))})),e.length>0&&await Promise.all(e),this.#Pa(t)}};function Gr(t){let e;try{e=t.responseText}catch{return`status ${t.status}`}if(!e)return`status ${t.status}`;try{return JSON.parse(e)}catch{return e}}const Kr=class{#J;#Ha;constructor(t,e,s){this.#J=e,this.kind=t.constructor.key||t.constructor.name,this.#Ha=Oe.getXMLHttpRequest(),this.method=s?.method,this.url=s?.url,this.headers=s?.headers,this.data=s?.data,this.callBack=s?.callBack,this.errorCallBack=s?.errorCallBack,this.responseType=s?.responseType}call({method:t,url:e,headers:s,data:i,callBack:n,errorCallBack:o,responseType:r}){if(this.cancel(),t||=this.method,e=this.#qa(e||this.url),s||=this.headers,i||=this.data,n||=this.callBack,o||=this.errorCallBack,r||=this.responseType,"function"!=typeof n)throw new Error(`[SUNEDITOR.ApiManager[${this.kind}].upload.callBack.fail] callBack is not a function`);const l=this.#Ha;if(r&&(l.responseType=r),l.onreadystatechange=this.#Wa.bind(this,l,n,o),l.open(t,e,!0),null!==s&&"object"==typeof s&&Object.keys(s).length>0)for(const t in s)l.setRequestHeader(t,s[t]);l.send(i)}asyncCall({method:t,url:e,headers:s,data:i,responseType:n}){this.cancel(),t||=this.method,e=this.#qa(e||this.url),s||=this.headers,i||=this.data,n||=this.responseType;const o=this.#Ha;return n&&(o.responseType=n),new Promise(((n,r)=>{if(o.open(t,e,!0),null!==s&&"object"==typeof s&&Object.keys(s).length>0)for(const t in s)o.setRequestHeader(t,s[t]);o.onload=()=>{if(200===o.status)try{n(o)}finally{this.#J.ui.hideLoading()}else{console.error(`[SUNEDITOR.ApiManager[${this.kind}].upload.serverException]`,o);try{r(Gr(o))}finally{this.#J.ui.hideLoading()}}},o.onerror=()=>{this.#J.ui.hideLoading(),r(new Error("Network error"))},o.send(i)}))}cancel(){this.#Ha&&(this.#Ha.onreadystatechange=null,this.#Ha.onload=null,this.#Ha.onerror=null,this.#Ha.abort())}#qa(t){return t?t.replace(/([^:])\/+/g,"$1/").replace(/\/(\?|#|$)/,"$1"):""}async#Wa(t,e,s){if(4===t.readyState)if(200===t.status)try{await e(t)}catch(t){throw Error(`[SUNEDITOR.ApiManager[${this.kind}].upload.callBack.fail] ${t.message}`)}finally{this.#J.ui.hideLoading()}else{console.error(`[SUNEDITOR.ApiManager[${this.kind}].upload.serverException]`,t);try{const e=Gr(t);let i="";"function"==typeof s&&(i=await s(e,t));const n=`[SUNEDITOR.ApiManager[${this.kind}].upload.serverException] status: ${t.status}, response: ${i||e.errorMessage||("string"==typeof e?e:JSON.stringify(e))}`;this.#J.ui.alertOpen(n,"error")}catch(t){throw Error(`[SUNEDITOR.ApiManager[${this.kind}].upload.errorCallBack.fail] ${t.message}`)}finally{this.#J.ui.hideLoading()}}}};function Yr(t){const e=t.src.split("/").pop(),s=t.thumbnail||"",i=s||t.src,n=this.props?.map((e=>`data-${e}="${t[e]}"`)).join(" ")||"",o=`data-type="${t.type}" data-command="${t.src}" data-name="${t.name||e}" data-thumbnail="${s}" data-extension="${t.src.split(".").pop()}" ${n}`,r=`class="${s||"se-browser-empty-image"}" src="${i}" alt="${t.alt||e}" ${o}`;return`\n\t\t
    \n\t\t\t${this.thumbnail&&!s&&"image"!==t.type?`
    ${this.thumbnail(t)}
    `:``}\n\t\t\t
    \n\t\t\t
    ${t.name||e}
    \n\t\t
    `}const Xr=class{#J;#Ua;#rr;#Va=[];#ja;#Ga;#So=!1;#No=null;constructor(t,e,s){this.#J=e,this.useSearch=s.useSearch??!0;const i=Pe.utils.createElement("DIV",{class:"se-browser sun-editor-common"+(s.className?` ${s.className}`:"")}),n=function(t,e){const s=t.lang,i=t.icons,n=`\n\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    `,o=Pe.utils.createElement("DIV",{class:"se-browser-inner"},n);return{html:o,header:o.querySelector(".se-browser-header"),titleArea:o.querySelector(".se-browser-title"),tagArea:o.querySelector(".se-browser-tags"),body:o.querySelector(".se-browser-body"),list:o.querySelector(".se-browser-list"),side:o.querySelector(".se-browser-side"),wrapper:o.querySelector(".se-browser-wrapper"),_loading:o.querySelector(".se-loading-box")}}(this.#J,this.useSearch),o=n.html;this.kind=t.constructor.key||t.constructor.name,this.host=t,this.area=i,this.header=n.header,this.titleArea=n.titleArea,this.tagArea=n.tagArea,this.body=n.body,this.list=n.list,this.side=n.side,this.wrapper=n.wrapper,this.#Ua=n._loading,this.title=s.title,this.listClass=s.listClass||"se-preview-list",this.directData=s.data,this.url=s.url,this.headers=s.headers,this.searchUrl=s.searchUrl,this.searchHeaders=s.searchHeaders,this.drawItemHandler=(s.drawItemHandler||Yr).bind({thumbnail:s.thumbnail,props:s.props||[]}),this.selectorHandler=s.selectorHandler,this.columnSize=s.columnSize||4,this.expand=s.expand??1,this.folderDefaultPath="",this.closeArrow=this.#J.icons.menu_arrow_right,this.openArrow=this.#J.icons.menu_arrow_down,this.icon_folder=this.#J.icons.side_menu_folder_item,this.icon_folder_item=this.#J.icons.side_menu_folder,this.icon_item=this.#J.icons.side_menu_item,this.items=[],this.folders={},this.tree={},this.data={},this.selectedTags=[],this.keyword="",this.sideInner=null,this.apiManager=new Kr(this,e,{method:"GET"}),this.#rr=t=>{Fe.isEsc(t.code)&&this.close()},i.appendChild(Pe.utils.createElement("DIV",{class:"se-browser-back"})),i.appendChild(o),i.setAttribute("popover","manual"),this.#J.contextProvider.carrierWrapper.appendChild(i),this.#J.eventManager.addEvent(this.tagArea,"click",this.#Ka.bind(this)),this.#J.eventManager.addEvent(this.list,"click",this.#Ya.bind(this)),this.#J.eventManager.addEvent(this.side,"click",this.#Xa.bind(this)),this.#J.eventManager.addEvent(o,"mousedown",this.#Za.bind(this)),this.#J.eventManager.addEvent(o,"click",this.#Ja.bind(this)),this.#J.eventManager.addEvent(this.sideOpenBtn=i.querySelector(".se-side-open-btn"),"click",this.#Qa.bind(this)),this.#J.eventManager.addEvent([this.header,i.querySelector(".se-browser-main")],"mousedown",this.#th.bind(this));const r=i.querySelector("form.se-browser-search-form");this.#ja=r?.querySelector('input[type="text"]'),this.#Ga=i.querySelector(".se-browser-search-clear"),this.#J.eventManager.addEvent(r,"submit",this.#eh.bind(this)),this.#J.eventManager.addEvent(this.#Ga,"click",this.#sh.bind(this))}open(t={}){this.#qe();const e=t.listClass||this.listClass;Pe.utils.hasClass(this.list,e)||(this.list.className="se-browser-list "+e),this.titleArea.textContent=t.title||this.title,this.area.style.display="block",this.area.showPopover?.(),this.#J.ui.opendBrowser=this,this.closeArrow=this.#J.options.get("_rtl")?this.#J.icons.menu_arrow_left:this.#J.icons.menu_arrow_right,this.directData?this.#ih(this.directData):this.#nh(t.url||this.url,t.headers||this.headers,!1),this.body.style.maxHeight=Pe.utils.getClientSize().h-(this.#J.offset.getGlobal(this.body).top-o.scrollY)-20+"px"}close(){this.#je(),this.apiManager.cancel(),this.area.hidePopover?.(),this.area.style.display="none",this.selectedTags=[],this.items=[],this.#Va=[],this.folders={},this.tree={},this.data={},this.keyword="",this.list.innerHTML=this.tagArea.innerHTML=this.titleArea.textContent="",this.#ja&&(this.#ja.value=""),this.#Ga&&(this.#Ga.style.display="none"),this.#J.ui.opendBrowser=null,this.sideInner=null,this.host.browserInit?.()}search(t){if(this.searchUrl){this.keyword=t;const e=this.searchUrl.includes("?")?"&":"?";this.#nh(this.searchUrl+e+"keyword="+o.encodeURIComponent(t),this.searchHeaders,!1)}else this.keyword=t.toLowerCase(),this.#oh(this.#Va.length>0?this.#Va:this.items,!1)}#rh(){const t=[];for(const e in this.data){const s=this.data[e];if(Array.isArray(s))for(let e=0;e!Array.isArray(t.tag)||t.tag.some((t=>e.includes(t)))))}showBrowserLoading(){this.#Ua.style.display="block"}closeBrowserLoading(){this.#Ua.style.display="none"}#nh(t,e,s){this.apiManager.call({method:"GET",url:t,headers:e,callBack:this.#lh.bind(this),errorCallBack:this.#ah.bind(this)}),s||(this.sideOpenBtn.style.display="none",this.showBrowserLoading())}#oh(t,e){const s=this.keyword,i=[],n=(t=this.tagfilter(t).filter((t=>t.name.toLowerCase().indexOf(s)>-1))).length,o=this.columnSize,r=o<=1?1:Math.round(n/o)||1,l=this.drawItemHandler;let a="",h='
    ',c=1;for(let s,d,u=0;ut.trim())),h+=l(s),(u+1)%r==0&&c
    '),e&&d.length>0)for(let t,e=0,s=d.length;e${t}`);h+="
    ",this.list.innerHTML=h,s&&this.#hh(s),e&&(this.items=t,this.tagArea.innerHTML=a)}#qe(){this.#je(),this.#No=this.#J.eventManager.addGlobalEvent("keydown",this.#rr,!0)}#je(){this.#No&&=this.#J.eventManager.removeGlobalEvent(this.#No)}#ih(t){if(Array.isArray(t))return t.length>0&&this.#oh(t,!0),!0;if("object"==typeof t){this.sideOpenBtn.style.display="",this.#ch(t),this.#Va=this.#rh(),this.side.innerHTML="";const e=this.sideInner=Pe.utils.createElement("div",null);if(this.#dh(this.tree,e),this.side.appendChild(e),this.folderDefaultPath){const t=e.querySelector(`[data-command="${this.folderDefaultPath}"]`);t.click(),this.folderDefaultPath.includes("/")&&(Pe.utils.removeClass(t.parentElement,"se-menu-hidden"),t.parentElement.previousElementSibling.querySelector("button").innerHTML=this.openArrow)}return!0}return!1}#ch(t,e){let s=this.tree;if(t._data){this.data[e]=t._data,this.folderDefaultPath&&!t.default||(this.folderDefaultPath=e);const i=e.split("/"),n=i.length-1;i.forEach(((t,i)=>{s[t]||={children:{}},i===n?(s[t].key=e,s[t].name=this.folders[e].name):s=s[t].children}))}else e&&(s[e]={name:this.folders[e].name,children:{}});Object.entries(t).forEach((([t,s])=>{if("_data"===t||!s||"object"!=typeof s)return;const i=s,n=e?`${e}/${t}`:t;this.folders[n]={name:i.name||t,meta:i.meta||{}},this.#ch(i,n)}))}#dh(t,e,s=0){const i=s0){const t=Pe.utils.createElement("div",o.key?{"data-command":o.key,"aria-label":o.name}:null,`${o.key?this.icon_folder:this.icon_folder_item}${o.name}`),n=Pe.utils.createElement("div",{class:"se-menu-folder"},t);t.insertBefore(Pe.utils.createElement("button",{type:"button"},i?this.openArrow:this.closeArrow),t.firstElementChild);const r=document.createElement("div");Pe.utils.addClass(r,i?"se-menu-child":"se-menu-child|se-menu-hidden"),this.#dh(o.children,r,s+1),n.appendChild(r),e.appendChild(n)}else{const t=Pe.utils.createElement("div",{"data-command":o.key,"aria-label":o.name,class:"se-menu-folder-item"},`${this.icon_item}${o.name}`);if(e===this.sideInner){const s=Pe.utils.createElement("div",{class:"se-menu-folder"},t);e.appendChild(s)}else e.appendChild(t)}}}#lh(t){try{const e=JSON.parse(t.responseText),s=e.result;if(this.#ih(s))return;e.nullMessage&&(this.list.innerHTML=e.nullMessage)}catch(t){throw Error(`[SUNEDITOR.browser.drawList.fail] cause: "${t.message}"`)}finally{this.closeBrowserLoading()}}#ah(t,e){throw this.closeBrowserLoading(),Error(`[SUNEDITOR.browser.get.serverException] status: ${e.status}, response: ${t.errorMessage||e.responseText}`)}#Ka(t){const e=Pe.query.getEventTarget(t);if(!Pe.check.isAnchor(e))return;const s=e.textContent,i=this.tagArea.querySelector('a[title="'+s+'"]'),n=this.selectedTags.indexOf(s);n>-1?(this.selectedTags.splice(n,1),Pe.utils.removeClass(i,"on")):(this.selectedTags.push(s),Pe.utils.addClass(i,"on")),this.#oh(this.items,!1)}#Ya(t){const e=Pe.query.getEventTarget(t);if(t.preventDefault(),t.stopPropagation(),e===this.list)return;const s=Pe.query.getCommandTarget(e);s&&(this.close(),this.selectorHandler(s))}#Xa(t){const e=Pe.query.getEventTarget(t);if(t.stopPropagation(),/^button$/i.test(e.nodeName)){const t=e.parentElement.parentElement.querySelector(".se-menu-child");return void(Pe.utils.hasClass(t,"se-menu-hidden")?(Pe.utils.removeClass(t,"se-menu-hidden"),e.innerHTML=this.openArrow):(Pe.utils.addClass(t,"se-menu-hidden"),e.innerHTML=this.closeArrow))}const s=Pe.query.getCommandTarget(e);if(!s||Pe.utils.hasClass(s,"active"))return;const i=this.data[s.getAttribute("data-command")];Pe.utils.removeClass(this.side.querySelectorAll(".active"),"active"),Pe.utils.addClass([s,Pe.query.getParentElement(s,".se-menu-folder")],"active"),this.tagArea.innerHTML="",this.selectedTags=[],"string"==typeof i?this.#nh(i,this.headers,!0):this.#oh(i,!0)}#Za(t){const e=Pe.query.getEventTarget(t);/se-browser-inner/.test(e.className)?this.#So=!0:this.#So=!1}#Ja(t){const e=Pe.query.getEventTarget(t);t.stopPropagation(),(/close/.test(e.getAttribute("data-command"))||this.#So)&&this.close()}#eh(t){t.preventDefault();const e=this.#ja.value;this.search(e),this.#Ga&&(this.#Ga.style.display=e?"":"none")}#sh(){this.#ja&&(this.#ja.value=""),this.#Ga&&(this.#Ga.style.display="none"),this.keyword="",this.#oh(this.items,!1)}#hh(t){const e=this.list.querySelectorAll(".se-file-name-image:not(.se-file-name-back)");for(let s=0;s-1&&(i.innerHTML=n.substring(0,o)+""+n.substring(o,o+t.length)+""+n.substring(o+t.length))}}#Qa(t){const e=Pe.query.getEventTarget(t);Pe.utils.hasClass(e,"active")?(Pe.utils.removeClass(this.side,"se-side-show"),Pe.utils.removeClass(e,"active")):(Pe.utils.addClass(this.side,"se-side-show"),Pe.utils.addClass(e,"active"))}#th({target:t}){t!==this.sideOpenBtn&&Pe.utils.hasClass(this.sideOpenBtn,"active")&&(Pe.utils.removeClass(this.side,"se-side-show"),Pe.utils.removeClass(this.sideOpenBtn,"active"))}},{isTouchDevice:Zr}=Oe,Jr=240,Qr=120,tl={hex:"#FFFFFF",r:255,g:255,b:255,h:0,s:1,l:1};let el,sl=0,il=!1,nl=!1,ol=120,rl=120,ll=tl,al=!1;const{slider:hl,offscreenCanvas:cl,offscreenCtx:dl,wheel:ul,wheelCtx:pl,wheelPointer:gl,gradientBar:ml,gradientPointer:fl,fanalColorHex:vl,fanalColorBackground:bl}=function(){const t=document.createElement("canvas");t.width=Jr,t.height=Jr;const e=`\n\t
    \n \n
    \n
    \n
    \n \n
    \n
    \n
    \n\t\t
    ${tl.hex}
    \n\t\t
    \n\t
    \n\t`,s=Pe.utils.createElement("DIV",{class:"se-hue-slider"},e),i=s.querySelector(".se-hue-wheel"),n=s.querySelector(".se-hue-gradient"),o=s.querySelector(".se-hue-final-hex").children;return{slider:s,offscreenCanvas:t,offscreenCtx:t.getContext("2d"),wheel:i,wheelCtx:i.getContext("2d"),wheelPointer:s.querySelector(".se-hue-wheel-pointer"),gradientBar:n,gradientPointer:s.querySelector(".se-hue-gradient-pointer"),fanalColorHex:o[0],fanalColorBackground:o[1]}}();function yl(t){const{target:e,touches:s}=t,i=s[0].clientX,n=s[0].clientY;e===ul?(t.preventDefault(),nl=!1,il=!0,kl(i,n)):e===ml&&(t.preventDefault(),nl=!0,il=!1,xl(i))}function wl(t){t.preventDefault();const{touches:e}=t,s=e[0].clientX,i=e[0].clientY;il?kl(s,i):nl&&xl(s)}function Cl({target:t,clientX:e,clientY:s}){t===ul?(nl=!1,il=!0,kl(e,s)):t===ml&&(nl=!0,il=!1,xl(e))}function _l({clientX:t,clientY:e}){il?kl(t,e):nl&&xl(t)}function kl(t,e){const s=ul.getBoundingClientRect();t=t-s.left-Qr,e=e-s.top-Qr;const i=180*Math.atan2(e,t)/Math.PI,n=Math.min(Math.sqrt(t*t+e*e),Qr),o=Qr+n*Math.cos(i*Math.PI/180),r=Qr+n*Math.sin(i*Math.PI/180);gl.style.left=`${o}px`,gl.style.top=`${r}px`,function(t,e){ol=t,rl=e,$l(Sl())}(o,r),El()}function xl(t){const e=ml.getBoundingClientRect();let s=t-e.left;s=Math.max(14,Math.min(s,e.width-14)),fl.style.left=`${s}px`,function(t){const e=ml.getBoundingClientRect();let s=t-e.left;s<0&&(s=0);s>e.width&&(s=e.width);const i=14;s>=ml.width-i?s=ml.width:s<=i&&(s=0);const n=1-s/e.width;sl=n,Nl()}(t),El()}function $l(t){const e=ml.getContext("2d"),s=e.createLinearGradient(0,0,ml.width,0);s.addColorStop(0,"black"),s.addColorStop(1,t.hex),e.fillStyle=s,e.fillRect(0,0,ml.width,ml.height)}function Sl(){return Ml(dl)}function El(){el.color=ll=Ml(pl),Tl(ll.hex)}function Tl(t){bl.style.backgroundColor=vl.textContent=t}function Ml(t){const e=t.getImageData(ol,rl,1,1).data;let[s,i,n]=function([t,e,s]){t/=255,e/=255,s/=255;const i=Math.max(t,e,s),n=Math.min(t,e,s);let o,r;const l=(i+n)/2;if(i===n)o=r=0;else{const a=i-n;switch(r=l>.5?a/(2-i-n):a/(i+n),i){case t:o=(e-s)/a+(e1&&(n=1),n<0&&(n=0);const{r:l,g:a,b:h}=function([t,e,s]){let i,n,o;if(0===e)i=n=o=s;else{const r=function(t,e,s){return s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+6*(e-t)*s:s<.5?e:s<2/3?t+(e-t)*(2/3-s)*6:t},l=s<.5?s*(1+e):s+e-s*e,a=2*s-l;i=r(a,l,t+1/3),n=r(a,l,t),o=r(a,l,t-1/3)}return{r:Math.round(255*i),g:Math.round(255*n),b:Math.round(255*o)}}([s,i,n]),c=`#${function({r:t,g:e,b:s}){let i=Math.floor(t).toString(16);t<16&&(i=`0${i}`);let n=Math.floor(e).toString(16);e<16&&(n=`0${n}`);let o=Math.floor(s).toString(16);s<16&&(o=`0${o}`);return`${i}${n}${o}`.toUpperCase()}({r:l,g:a,b:h})}`;return{hex:c,r:l,g:a,b:h,h:s,s:i,l:Il(n)}}function Nl(){pl.clearRect(0,0,Jr,Jr),pl.drawImage(cl,0,0),pl.globalAlpha=sl,pl.fillStyle="black",pl.beginPath(),pl.arc(Qr,Qr,Qr,0,2*Math.PI),pl.fill(),pl.globalAlpha=1}function Bl(t){return t*Math.PI/180}function Il(t){const e=Math.pow(10,10);return Math.round(t*e)/e}function Ll(){!function(t){if(!t)return void console.warn("[HueSlider.fail] Context not found.");for(let e=0;e<=360;e+=.5)for(let s=0;s<=Qr;s+=1){t.beginPath();const i=50+(Qr-s)/Qr*50;t.fillStyle=`hsl(${e}, 100%, ${i}%)`;const n=Qr+Math.cos(Bl(e))*s,o=Qr-Math.sin(Bl(e))*s;t.arc(n,o,1.5,0,2*Math.PI),t.fill()}al=!0}(dl),al&&Nl()}Ll();const Al=class{#J;#uh;#ph;#gh;#mh;#fh;#vh;constructor(t,e,s={},i=""){if(this.#J=e,this.inst=t,this.ctx={wheelX:ol,wheelY:rl,lightness:sl,wheelPointerX:"50%",wheelPointerY:"50%",gradientPointerX:"calc(100% - 14px)",color:tl},this.isOpen=!1,this.controlle=null,this.#uh=null,this.#ph=null,this.#gh=null,this.#mh=null,this.#fh=null,this.#vh=null,!s.isNewForm){const n=function({lang:t,icons:e},s){const i=Pe.utils.createElement("DIV",{class:`se-controller ${s}`},`\n\t\t
    \n\t\t
    \n\t\t\t\n\t\t\t\n\t\t
    \n\t`);return i}(e,i);this.circle=n.querySelector(".se-hue"),this.controller=new Ii(this,e,n,{position:"bottom",isWWTarget:!1,parents:[t.form],parentsHide:!0,...s.controllerOptions})}}controllerAction(t){const e=t.getAttribute("data-command");"submit"===e?(this.inst.hueSliderAction?.(this.get()),this.close()):"close"===e&&this.close()}controllerClose(){this.init(),this.inst.hueSliderCancelAction?.()}get(){return ll}open(t){this.attach(),this.controller.open(t,null,{isWWTarget:!1,initMethod:null,addOffset:null})}close(){this.ctx={gradientPointerX:fl.style.left,wheelPointerX:gl.style.left,wheelPointerY:gl.style.top,wheelX:ol,wheelY:rl,lightness:sl,color:el?.color||""},this.controller.close()}attach(t){al||Ll(),this.init(),(t||this.circle).appendChild(hl),el=this.ctx,el&&(ol=el.wheelX,rl=el.wheelY,sl=el.lightness,gl.style.left=el.wheelPointerX,gl.style.top=el.wheelPointerY,fl.style.left=el.gradientPointerX,Tl(el.color.hex),Nl(),$l(Sl())),Zr&&(this.#fh=this.#J.eventManager.addGlobalEvent("touchstart",yl,{passive:!1,capture:!0}),this.#ph=this.#J.eventManager.addGlobalEvent("touchmove",wl,!0),this.#vh=this.#J.eventManager.addGlobalEvent("touchend",(()=>{il=!1,nl=!1}),!0)),this.#uh=this.#J.eventManager.addGlobalEvent("mousedown",Cl,{passive:!1,capture:!0}),this.#mh=this.#J.eventManager.addGlobalEvent("mousemove",_l,!0),this.#gh=this.#J.eventManager.addGlobalEvent("mouseup",(()=>{il=!1,nl=!1}),!0),this.isOpen=!0}init(){this.isOpen=!1,il=!1,nl=!1,this.#uh&&=this.#J.eventManager.removeGlobalEvent(this.#uh),this.#mh&&=this.#J.eventManager.removeGlobalEvent(this.#mh),this.#gh&&=this.#J.eventManager.removeGlobalEvent(this.#gh),this.#fh&&=this.#J.eventManager.removeGlobalEvent(this.#fh),this.#ph&&=this.#J.eventManager.removeGlobalEvent(this.#ph),this.#vh&&=this.#J.eventManager.removeGlobalEvent(this.#vh)}},Ol=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#000000","#fca5a5","#fdba74","#fcd34d","#6ee7b7","#5eead4","#7dd3fc","#c4b5fd","#f9a8d4","#e5e7eb","#fee2e2","#ffedd5","#fef9c3","#dcfce7","#cffafe","#dbeafe","#ede9fe","#fce7f3","#f3f4f6","#f87171","#fb923c","#facc15","#4ade80","#22d3ee","#60a5fa","#a78bfa","#f472b6","#9ca3af","#b91c1c","#c2410c","#a16207","#15803d","#0e7490","#1d4ed8","#6d28d9","#be185d","#4b5563","#7f1d1d","#7c2d12","#713f12","#14532d","#164e63","#1e3a8a","#4c1d95","#831843","#1f2937"];function Rl(t,e){const s=`
      `;let i=s;for(let n,o,r,l=0,a=t.length;l0&&l%e==0&&(i+=`
    ${s}`),i+=`
  • `;return i+="",i}const zl=class{#J;constructor(t,e,s,i){this.#J=e,this.kind=t.constructor.key||t.constructor.name,this.host=t,this.form=i.form,this.target=function({lang:t,icons:e},{colorList:s,disableHEXInput:i,disableRemove:n,splitNum:o}){s||=Ol,o=s===Ol?9:o;let r="";for(let t,e=0,i=s.length,n=[];e0&&(r+=`
    ${Rl(n,o)}
    `,n=[]),"object"==typeof t&&(r+=`
    ${Rl(t,o)}
    `)));return r+=`\n\t\t
    \n\t\t\t${i?"":``}\n\t\t\t\n\t\t\t${i?"":``}\n\t\t\t${n?"":``}\n\t\t
    `,Pe.utils.createElement("DIV",{class:"se-list-inner"},r)}(this.#J,i),this.targetButton=null,this.inputElement=this.target.querySelector(".se-color-input"),this.styleProperties=s,this.splitNum=i.splitNum||0,this.defaultColor=i.defaultColor||"",this.hueSliderOptions=i.hueSliderOptions,this.currentColor="",this.colorList=this.target.querySelectorAll("li button")||[],this.hueSlider=null;const n=(new DOMParser).parseFromString(this.#J.icons.color_checked,"image/svg+xml");this.checkedIcon=n.documentElement,i.disableHEXInput||(this.hueSlider=new Al(this,e,i.hueSliderOptions,"se-dropdown"),this.#J.eventManager.addEvent(this.target.querySelector(".__se_hue"),"click",this.#bh.bind(this)),this.#J.eventManager.addEvent(this.inputElement,"input",this.#yh.bind(this)),this.#J.eventManager.addEvent(this.target.querySelector("form"),"submit",this.#wh.bind(this))),i.disableRemove||this.#J.eventManager.addEvent(this.target.querySelector(".__se_remove"),"click",this.#Ch.bind(this)),this.#J.eventManager.addEvent(this.target,"click",this.#_h.bind(this)),this.form.appendChild(this.target)}init(t,e,s){this.targetButton=e,"function"!=typeof s&&(s=()=>!1);let i=("string"==typeof t?t:this.#kh(t,s))||this.defaultColor;i=ze.isHexColor(i)?i:ze.rgb2hex(i)||i||"";const n=this.colorList;for(let t,e=0,s=n.length;e=3?"#"+((1<<24)+(s[0]<<16)+(s[1]<<8)+s[2]).toString(16).substring(1):""}#bh(){this.hueSlider.open(this.targetButton),this.host.colorPickerHueSliderOpen?.()}#wh(t){t.preventDefault(),this.host.colorPickerAction?.(this.currentColor)}#_h(t){const e=Pe.query.getEventTarget(t).getAttribute("data-value");e&&this.host.colorPickerAction?.(e)}#Ch(){this.host.colorPickerAction?.(null)}#yh(t){const e=Pe.query.getEventTarget(t);this.setHexColor(e.value)}},{_w:Pl}=Oe,Dl={w:"ns-resize",h:"ew-resize",c:"nwse-resize",wRTL:"ns-resize",hRTL:"ew-resize",cRTL:"nesw-resize"};const Fl=class{#J;#Sh;#Eh;#Th;#Mh;#$o;#Te;#No=null;#Nh=!1;#Bh=null;#Ih=null;#Lh="";#Ah=0;#Oh=0;#Rh=null;#zh=null;constructor(t,e,s){this.#J=e,this.inst=t,this.kind=t.constructor.key||t.constructor.name,this.form=s,this.isUpdate=!1,this.focusElement=s.querySelector("[data-focus]"),this.#Eh=this.#J.contextProvider.carrierWrapper.querySelector(".se-modal"),this.#Th=this.#J.contextProvider.carrierWrapper.querySelector(".se-modal .se-modal-inner"),this.#$o=[this.#Ph.bind(this),this.#Dh.bind(this)],this.#Th.appendChild(s),this.#J.eventManager.addEvent(s.querySelector("form"),"submit",this.#De.bind(this)),this.#Nh=!this.#J.eventManager.addEvent(s.querySelector('[data-command="close"]'),"click",this.close.bind(this)),(s.querySelector(".se-modal-resize-handle-w")||s.querySelector(".se-modal-resize-handle-h")||s.querySelector(".se-modal-resize-handle-c")||s.querySelector(".se-modal-resize-form"))&&!(this.#Mh=s.querySelector(".se-modal-resize-form"))&&(this.#Mh=s.querySelector(".se-modal-body"))&&(this.#J.eventManager.addEvent(s.querySelector(".se-modal-resize-handle-w"),"mousedown",this.#Fh.bind(this,"w")),this.#J.eventManager.addEvent(s.querySelector(".se-modal-resize-handle-h"),"mousedown",this.#Fh.bind(this,"h")),this.#J.eventManager.addEvent(s.querySelector(".se-modal-resize-handle-c"),"mousedown",this.#Fh.bind(this,"c")),this.#Te={mousemove:this.#Hh.bind(this),mouseup:this.#qh.bind(this)})}static CreateFileInput({icons:t,lang:e},{acceptedFormats:s,allowMultiple:i}){return`\n\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    ${t.upload_tray}
    \n\t\t\t\t\t\t\t
    ${t.file_plus}
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\n\t\t\t
    \n\t\t\t\n\t\t
    `}static OnChangeFile(t,e){if(!t||!e)return;const s=t.querySelector(".se-input-file-cnt"),i=t.querySelector(".se-input-file-icon-up"),n=t.querySelector(".se-input-file-icon-files");e.length>1?(i.style.display="none",n.style.display="inline-block",s.style.display="",s.textContent=` ..${e.length}`):e.length>0?(i.style.display="none",n.style.display="none",s.style.display="block",s.textContent=e[0].name):(i.style.display="inline-block",n.style.display="none",s.style.display="",s.textContent="")}open(){if(this.#J.ui.offCurrentModal(),this.#Wh(!0),this.#Nh&&(this.#Bh&&this.#J.eventManager.removeEvent(this.#Bh),this.#Bh=this.#J.eventManager.addEvent(this.#Th,"click",this.#$o[1])),this.#No&&=this.#J.eventManager.removeGlobalEvent(this.#No),this.#No=this.#J.eventManager.addGlobalEvent("keydown",this.#$o[0]),this.isUpdate=this.kind===this.#J.ui.currentControllerName,this.#J.ui.opendModal=this,this.isUpdate||this.inst.modalInit?.(),this.inst.modalOn?.(this.isUpdate),Pe.utils.addClass(this.#Eh,"se-backdrop-show"),Pe.utils.addClass(this.form,"se-modal-show"),this.#Eh.showPopover?.(),this.#Mh){const t=this.#Uh(),{maxWidth:e,maxHeight:s}=Pl.getComputedStyle(this.form),i=this.form.offsetWidth-t.width+"px",n=`${this.form.offsetTop+(this.form.offsetHeight-this.#Mh.offsetHeight)}px`;e&&"string"==typeof this.#Lh&&Pe.utils.setStyle(this.#Mh,"max-width",`calc(${e} - ${i})`),s&&Pe.utils.setStyle(this.#Mh,"max-height",`calc(${s} - ${n})`)}this.focusElement&&this.focusElement.focus(),this.#Sh=this.#J.component.currentTarget}close(){this.#je(),this.#Wh(!1),Pl.setTimeout((()=>{this.#J.ui.opendModal=null}),0),this.#Nh&&this.#Bh&&(this.#J.eventManager.removeEvent(this.#Bh),this.#Bh=null),this.#No&&=this.#J.eventManager.removeGlobalEvent(this.#No),this.#Eh.hidePopover?.(),Pe.utils.removeClass(this.#Eh,"se-backdrop-show"),Pe.utils.removeClass(this.form,"se-modal-show"),this.inst.modalInit?.(),this.inst.modalOff?.(this.isUpdate),this.isUpdate?this.#Sh&&this.inst.componentSelect?.(this.#Sh):this.#J.focusManager.focus(),this.#Sh=null,this.isUpdate=!1}#Wh(t){const e=this.#J.ui.opendControllers;for(let s=0;s0;){const t=e.shift();Hl(t,"index")&&n.includes(Number(Hl(t,"index")))?i.push(Number(Hl(t,"index"))):(i.push(this.infoIndex),t.removeAttribute("data-se-index"),this.#Vh(t,null))}if(t&&this.loadEventName)this.#J.eventManager.triggerEvent(this.loadEventName,{infoList:s});else for(let t,e=0;e=0)for(let e=0,s=this.infoList.length;e\n\t\t\t
    \n\t\t\t\t\n\t\t\t\t
    \n\t\t\t\t\t\n\t\t\t\t\t${e.enableFileUpload?``:""}\n\t\t\t\t\t\n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t${n.bookmark}\n\t\t\t\t\t${n.download}\n\t\t\t\t\t\n\t\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t\t`);return l+="
    ",Pe.utils.createElement("DIV",null,l)}(t,s,this.relList);if(this.host=(Wl.location.origin+Wl.location.pathname).replace(/\/$/,""),this.urlInput=i.querySelector(".se-input-url"),this.displayInput=i.querySelector("._se_display_text"),this.titleInput=i.querySelector("._se_title"),this.newWindowCheck=i.querySelector("._se_anchor_check"),this.downloadCheck=i.querySelector("._se_anchor_download"),this.download=i.querySelector("._se_anchor_download_icon"),this.preview=i.querySelector(".se-link-preview"),this.bookmark=i.querySelector("._se_anchor_bookmark_icon"),this.bookmarkButton=i.querySelector("._se_bookmark_button"),this.currentRel=[],this.currentTarget=null,this.linkValue="",this.#Kh=this.relList.length>0,this.#Kh){this.relButton=i.querySelector(".se-anchor-rel-btn"),this.relPreview=i.querySelector(".se-anchor-rel-preview");const e=this.relList,s=(this.defaultRel.default||"").split(" "),n=[];for(let t,i=0,o=e.length;i'+this.#J.icons.checked+"
    "));this.#Yh=new Ai(t,{checkList:!0,position:"right-middle",dir:"ltr"}),this.#Yh.on(this.relButton,this.#Jh.bind(this)),this.#Yh.create(n),this.#J.eventManager.addEvent(this.relButton,"click",this.#Qh.bind(this))}this.#Gh=e,this.#Gh.querySelector(".se-anchor-editor").appendChild(i),this.#Xh=new Ai(t,{checkList:!1,position:"bottom-left",dir:"ltr"}),this.#Xh.on(this.urlInput,this.#tc.bind(this)),this.#J.eventManager.addEvent(this.newWindowCheck,"change",this.#ec.bind(this)),this.#J.eventManager.addEvent(this.downloadCheck,"change",this.#sc.bind(this)),this.#J.eventManager.addEvent(this.urlInput,"input",this.#ic.bind(this)),this.#J.eventManager.addEvent(this.urlInput,"focus",this.#nc.bind(this)),this.#J.eventManager.addEvent(this.bookmarkButton,"click",this.#oc.bind(this)),this.#J.eventManager.addEvent(i.querySelector("._se_upload_button"),"click",(()=>this.input.click()))}set(t){this.currentTarget=t}on(t){if(t){if(this.currentTarget){const t=this.currentTarget.href;this.linkValue=this.preview.textContent=this.urlInput.value=this.#rc(t)?t.substring(t.lastIndexOf("#")):t,this.displayInput.value=this.currentTarget.textContent,this.titleInput.value=this.currentTarget.title,this.newWindowCheck.checked=!!/_blank/i.test(this.currentTarget.target),this.downloadCheck.checked=!!this.currentTarget.download}}else this.init(),this.displayInput.value=this.#J.selection.get().toString().trim(),this.newWindowCheck.checked=this.openNewWindow,this.titleInput.value="";this.#lc(t&&this.currentTarget?this.currentTarget.rel:this.defaultRel.default||""),this.#ac(this.linkValue)}create(t,e){const s=this.linkValue||e||"";if(0===s.length)return null;const i=0===this.displayInput.value.length?s:this.displayInput.value,n=this.currentTarget||Pe.utils.createElement("A");return this.#hc(n,s,i,this.titleInput.value,t),this.linkValue=this.preview.textContent=this.urlInput.value=this.displayInput.value="",n}init(){this.currentTarget=null,this.linkValue=this.preview.textContent=this.urlInput.value="",this.displayInput.value="",this.newWindowCheck.checked=!1,this.downloadCheck.checked=!1,this.#lc(this.defaultRel.default||"")}#hc(t,e,s,i,n){!this.#rc(e)&&this.downloadCheck.checked?t.setAttribute("download",s||e):t.removeAttribute("download"),this.newWindowCheck.checked?t.target="_blank":t.removeAttribute("target");const o=this.currentRel.join(" ");o?t.rel=o:t.removeAttribute("rel"),t.href=e,i?t.title=i:t.removeAttribute("title"),n?0===t.children.length&&(t.textContent=""):t.textContent=s}#rc(t){const e=Wl.location.href.replace(/\/$/,"");return 0===t.indexOf("#")||0===t.indexOf(e)&&t.indexOf("#")===(e.includes("#")?e.substring(0,e.indexOf("#")).length:e.length)}#lc(t){if(!this.#Kh)return;const e=this.currentRel=t?t.split(" "):[],s=this.#Yh.form.querySelectorAll("button");for(let t,i=0,n=s.length;i0?Pe.utils.addClass(this.relButton,"on"):Pe.utils.removeClass(this.relButton,"on")}#cc(t){const e=Pe.query.getListChildren(this.#J.frameContext.get("wysiwyg"),(t=>/h[1-6]/i.test(t.nodeName)||Pe.check.isAnchor(t)&&!!t.id),null);if(0===e.length)return;const s=new RegExp(`^${t.replace(/^#/,"")}`,"i"),i=[],n=[];for(let t,o=0,r=e.length;o${this.#J.icons.bookmark_anchor}${t.id}`:`
    ${t.textContent}
    `));0===i.length?this.#Xh.close():(this.#Xh.create(i,n),this.#Xh.open(this.#J.options.get("_rtl")?"bottom-right":""))}#ac(t){const e=this.preview,s=this.#J.options.get("defaultUrlProtocol"),i=this.noAutoPrefix,n=/^(mailto:|tel:|sms:|https*:\/\/|#)/.test(t)||0===t.indexOf(s),o=!!s&&RegExp("^"+Re.escapeStringRegexp(t.substring(0,s.length))).test(s);t=this.linkValue=e.textContent=t?i?t:!s||n||o?n?t:/^www\./.test(t)?"http://"+t:this.host+(/^\//.test(t)?"":"/")+t:s+t:"",this.#rc(t)?(this.bookmark.style.display="block",Pe.utils.addClass(this.bookmarkButton,"active")):(this.bookmark.style.display="none",Pe.utils.removeClass(this.bookmarkButton,"active")),!this.#rc(t)&&this.downloadCheck.checked?this.download.style.display="block":this.download.style.display="none"}#dc(t){const e=this.currentRel;if(!t)return e.join(" ");if(/^only:/.test(t))return t=t.replace(/^only:/,"").trim(),this.currentRel=t.split(" "),t;const s=t.split(" ");for(let t=0,i=s.length;tthis.create(e,s,t)}},create(t,e,s){if("object"!=typeof e&&(e={}),s&&(e=[s,e].reduce(((t,e)=>(Object.entries(e).forEach((([e,s])=>{if("plugins"===e&&s&&t[e]){const i=Array.isArray(t[e])?t[e]:Object.values(t[e]),n=Array.isArray(s)?s:Object.values(s);t[e]=[...n.filter((t=>!i.includes(t))),...i]}else t[e]=s})),t)),{})),!t)throw Error('[SUNEDITOR.create.fail] The first parameter "target" is missing.');const i=[];if("string"==typeof t){const e=document.querySelector(t);if(!e)throw Error(`[SUNEDITOR.create.fail]-[document.querySelector(${t})] Cannot find target element. Make sure "${t}" is a valid selector and exists in the document.`);i.push({key:null,target:e})}else if(1===t.nodeType)i.push({key:null,target:t});else{let e;for(const s in t){if(e=t[s],!e.target||1!==e.target.nodeType)throw Error('[SUNEDITOR.create.fail] suneditor multi root requires textarea\'s element at the "target" property.');e.key=s,i.push(e)}}return new jr(i,e)}};class Gl extends Yn{static type="";static key="";static className="";static options={};constructor(t){super(t),this.title="",this.icon="",this.inner=null,this.beforeItem=null,this.afterItem=null,this.replaceButton=null}}class Kl extends Gl{static type="browser";open(t){throw new Error(`[${this.constructor.name}] Abstract method 'open()' must be implemented`)}close(){throw new Error(`[${this.constructor.name}] Abstract method 'close()' must be implemented`)}}class Yl extends Gl{static type="command";action(t){throw new Error(`[${this.constructor.name}] Abstract method 'action()' must be implemented`)}}class Xl extends Gl{static type="dropdown";on(t){}action(t){throw new Error(`[${this.constructor.name}] Abstract method 'action()' must be implemented`)}}class Zl extends Gl{static type="dropdown-free";on(t){}off(){}}class Jl extends Gl{static type="field"}class Ql extends Gl{static type="input";toolbarInputKeyDown(t){}toolbarInputChange(t){}}class ta extends Gl{static type="modal";open(t){throw new Error(`[${this.constructor.name}] Abstract method 'open()' must be implemented`)}}class ea extends Gl{static type="popup";show(){throw new Error(`[${this.constructor.name}] Abstract method 'show()' must be implemented`)}}const sa=class extends Yl{static key="blockquote";static className="";constructor(t){super(t),this.title=this.$.lang.tag_blockquote,this.icon="blockquote",this.quoteTag=Pe.utils.createElement("BLOCKQUOTE")}active(t,e){return/blockquote/i.test(t?.nodeName)?(Pe.utils.addClass(e,"active"),!0):(Pe.utils.removeClass(e,"active"),!1)}action(){const t=Pe.query.getParentElement(this.$.selection.getNode(),"blockquote");t?this.$.format.removeBlock(t,{selectedFormats:null,newBlockElement:null,shouldDelete:!1,skipHistory:!1}):this.$.format.applyBlock(this.quoteTag.cloneNode(!1))}},ia=["javascript","typescript","html","css","json","python","java","c","cpp","csharp","go","rust","ruby","php","swift","kotlin","sql","bash","markdown","xml","yaml"];class na extends Yl{static key="codeBlock";static className="";#fc;#vc;#bc;#yc;#wc;#Cc;#_c;#kc;#xc;constructor(t,e){if(super(t),this.title=this.$.lang.codeBlock||"Code Block",this.icon="code_block",this.#fc=Pe.utils.createElement("PRE"),this.#bc=e?.langs??ia,!this.#bc.length)return;this.afterItem=Pe.utils.createElement("button",{class:"se-btn se-tooltip se-sub-arrow-btn",type:"button","data-command":na.key,"data-type":"dropdown"},`${this.$.icons.arrow_down}${this.$.lang.codeLanguage||"Language"}`);const s=function(t,e){const s=t.lang.codeLanguage_none||"None";let i='
      ';i+=`
    • `;for(const t of e)i+=`
    • `;return i+="
    ",Pe.utils.createElement("DIV",{class:"se-dropdown se-list-layer se-list-code-block"},i)}(this.$,this.#bc);this.#vc=s.querySelectorAll("li button"),this.$.menu.initDropdownTarget({key:na.key,type:"dropdown"},s);const i=Pe.utils.createElement("DIV",{class:"se-controller se-code-lang"});this.#yc=Pe.utils.createElement("DIV",{class:"se-code-lang-button"}),this.#$c(""),i.appendChild(this.#yc),this.#Cc=new Ii(this,this.$,i,{position:"top",isWWTarget:!0}),this.#xc=ze.debounce((t=>{this.#kc=this.$.eventManager.removeEvent(this.#kc),t&&i.contains(t.relatedTarget)?this.#Sc():this.#Ec()}),0),this.#wc=new Ai(this.$,{position:"bottom-right",dir:this.$.options.get("_rtl")?"rtl":"ltr",maxHeight:"214px",minWidth:"132px",closeMethod:this.#xc}),this.#wc.on(this.#yc,this.#Tc.bind(this)),this.#Mc(""),this.$.eventManager.addEvent(i,"mousedown",(t=>{Oe.isMobile||this.#wc.form?.contains(Pe.query.getEventTarget(t))?this.$.store.set("_preventBlur",!0):t.preventDefault()})),this.$.eventManager.addEvent(this.#yc,"click",(t=>{if(t.preventDefault(),t.stopPropagation(),this.#wc.isOpen)this.#wc.close();else{const t=this.#Nc(this.#_c);this.#Mc(t);const e=this.#wc.items,s=t?e.indexOf(t):0;this.#wc.open(null,s>=0?`[data-index="${s}"]`:null)}}))}onMouseMove({event:t}){if(!this.#Cc)return;const e=Pe.query.getEventTarget(t).closest("pre");e&&!this.#Bc()&&0===this.$.ui.opendControllers.length&&this.#Ic(e)}active(t,e){return/^PRE$/i.test(t?.nodeName)?(Pe.utils.addClass(e,"active"),!0):(Pe.utils.removeClass(e,"active"),!1)}action(t){const e=t?.getAttribute("data-value")||"",s=this.$.selection.getNode(),i=Pe.query.getParentElement(s,(t=>/^PRE$/i.test(t.nodeName)));if(i&&!e)this.$.format.setLine(Pe.utils.createElement(this.$.options.get("defaultLine")));else if(i||this.$.format.setBrLine(this.#fc.cloneNode(!1)),e){const t=Pe.query.getParentElement(this.$.selection.getNode(),(t=>/^PRE$/i.test(t.nodeName)));t&&this.#Lc(t,e)}this.$.menu.dropdownOff(),this.$.focusManager.focus(),this.$.history.push(!1)}on(){if(!this.#vc)return;const t=this.#Nc(this.$.selection.getNode());for(let e=0,s=this.#vc.length;e</>${t||this.$.lang.codeLanguage||"Language"}`}#Bc(){return this.#wc?.isOpen||this.#Cc?.isOpen}#Nc(t){const e="PRE"===t?.nodeName?t:Pe.query.getParentElement(t,(t=>/^PRE$/i.test(t.nodeName)));return e&&e.className.match(/language-(\S+)/)?.[1]||""}#Lc(t,e){t.className=t.className.replace(/\s*language-\S+/g,"").trim(),e?(Pe.utils.addClass(t,"language-"+e),t.setAttribute("data-se-lang",e)):t.removeAttribute("data-se-lang")}destroy(){this.#_c&&Pe.utils.removeClass(this.#_c,"se-pre-code-focus"),this.#Cc?.form?.parentNode?.removeChild(this.#Cc.form),this.#_c=null}}const oa=na,{_w:ra,_d:la}=Oe;const aa=class extends Yl{static key="exportPDF";static className="se-component-enabled";constructor(t,e){super(t),this.title=this.$.lang.exportPDF,this.icon="PDF",this.apiUrl=e.apiUrl,this.fileName=e.fileName||"suneditor-pdf",this.apiUrl?this.apiManager=new Kr(this,this.$,{method:"POST",url:this.apiUrl,headers:{"Content-Type":"application/json"},responseType:"blob"}):console.warn('[SUNEDITOR.plugins.exportPDF.error] Requires exportPDF."apiUrl" options.')}async action(){if(!this.apiUrl)return void console.warn('[SUNEDITOR.plugins.exportPDF.error] Requires exportPDF."apiUrl" options.');this.$.ui.showLoading();let t=null;try{const e=this.$.frameContext.get("documentTypePageMirror")||this.$.frameContext.get("wysiwygFrame"),s=(this.$.options.get("_themeClass")||"").trim(),i=s?e.className.replace(s,"").trim():e.className,n=Pe.utils.createElement("div",{class:i},e.innerHTML);t=Pe.utils.createElement("div",{style:"position: absolute; top: -10000px; left: -10000px; width: 21cm; columns: 21cm; height: auto;"},n);const o=ra.getComputedStyle(e).padding,r=Pe.utils.applyInlineStylesAll(n,!0,this.$.options.get("allUsedStyles"));if(r.style.padding=r.style.paddingTop=r.style.paddingBottom=r.style.paddingLeft=r.style.paddingRight="0",t.innerHTML=`\n\t\t\t\t\n\t\t\t\t${r.outerHTML}`,la.body.appendChild(t),!1===await this.$.eventManager.triggerEvent("onExportPDFBefore",{target:t}))return;return void await this.#Rc(t)}catch(t){console.error("[SUNEDITOR.plugins.exportPDF.error]",t.message)}finally{Pe.utils.removeItem(t),this.$.ui.hideLoading()}}async#Rc(t){const e={fileName:this.fileName,htmlContent:t.innerHTML},s=await this.apiManager.asyncCall({data:JSON.stringify(e)});if(200!==s.status){let t;try{t=JSON.parse(s.responseText).errorMessage}catch{}throw Error(`[SUNEDITOR.plugins.exportPDF.error] ${t||s.statusText}`)}const i=new Blob([s.response],{type:"application/pdf"}),n=s.getResponseHeader("Content-Disposition"),o=URL.createObjectURL(i),r=(n.match(/filename="([^"]+)/)||[])[1]||this.fileName+".pdf",l=Pe.utils.createElement("A",{href:o,download:r,style:"display: none;"},null);try{la.body.appendChild(l),l.click()}finally{ra.setTimeout((()=>{Pe.utils.removeItem(l),URL.revokeObjectURL(o)}),100)}}},{NO_EVENT:ha}=Oe;class ca extends Yl{static key="fileUpload";static className="";static options={eventIndex:1e4};static component(t){return Pe.check.isAnchor(t)&&t.hasAttribute("data-se-file-download")?t:null}#zc;#Pc=null;constructor(t,e){super(t),this.title=this.$.lang.fileUpload,this.icon="file_upload",e.uploadUrl||console.warn('[SUNEDITOR.fileUpload.warn] "fileUpload" plugin must be have "uploadUrl" option.'),this.uploadUrl=e.uploadUrl,this.uploadHeaders=e.uploadHeaders,this.uploadSizeLimit=De.get(e.uploadSizeLimit,0),this.uploadSingleSizeLimit=De.get(e.uploadSingleSizeLimit,0),this.allowMultiple=!!e.allowMultiple,this.acceptedFormats="string"!=typeof e.acceptedFormats?"*":e.acceptedFormats.trim()||"*",this.as=e.as||"box",this.insertBehavior=e.insertBehavior,this.input=Pe.utils.createElement("input",{type:"file",accept:this.acceptedFormats}),this.allowMultiple&&this.input.setAttribute("multiple","multiple"),this.#zc=this.acceptedFormats.split(", ");const s={"custom-download":{command:"download",title:this.$.lang.download,icon:"download",action:t=>{const e=t.getAttribute("href");e&&Pe.utils.createElement("A",{href:e},null).click()}},"custom-as":{command:"as",value:"link",title:this.$.lang.asLink,icon:"reduction",action:(t,e)=>{this.convertFormat(t,e)}}},i=(e.controls||[["custom-as","align","edit","custom-download","copy","remove"]]).map((t=>t.map((t=>t.startsWith("custom-")?s[t]:t))));if(this.figure=new ji(this,this.$,i,{}),this.fileManager=new ql(this,this.$,{query:"a[download][data-se-file-download]",loadEventName:"onFileLoad",actionEventName:"onFileAction"}),/\bedit\b/.test(JSON.stringify(i))){const t=function({lang:t,icons:e}){const s=`\n\t\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t\t`;return Pe.utils.createElement("DIV",{class:"se-controller se-controller-simple-input"},s)}(this.$);this.controller=new Ii(this,this.$,t,{position:"bottom",disabled:!0},ca.key),this.editInput=t.querySelector("input")}this.$.eventManager.addEvent(this.input,"change",this.#Zh.bind(this))}action(){this.$.store.set("_preventBlur",!0),this.input.click()}onFilePasteAndDrop({file:t}){const e=t.type;this.#zc.some((t=>!!t.startsWith("*")||(!!t.startsWith(e)||void 0)))&&(this.submitFile([t]),this.$.focusManager.focus())}controllerAction(t){const e=t.getAttribute("data-command");if(e){if("edit"===e){if(0===this.editInput.value.trim().length)return;this.#Pc.textContent=this.editInput.value}this.controller.close(),this.$.component.select(this.#Pc,ca.key)}}componentSelect(t){this.#Pc=t;const e=this.figure.controller.form.querySelector('[data-command="__c__as"]');if(e)return Pe.check.isFigure(t.parentElement)?(e.innerHTML=this.$.icons.reduction+Pe.utils.createTooltipInner(this.$.lang.asLink),e.setAttribute("data-value","link"),void this.figure.open(t,{nonResizing:!0,nonSizeInfo:!0,nonBorder:!0,figureTarget:!0,infoOnly:!1})):(e.innerHTML=this.$.icons.expansion+Pe.utils.createTooltipInner(this.$.lang.asBlock),e.setAttribute("data-value","box"),this.figure.controllerOpen(t,{isWWTarget:!0}),!0)}componentEdit(t){this.editInput.value=t.textContent,this.figure.controllerHide(),this.controller.open(t,null,{isWWTarget:!Pe.check.isFigure(t.parentElement),initMethod:null,addOffset:null}),this.editInput.focus()}async componentDestroy(t){if(!t)return;const e=ji.GetContainer(t),s=Pe.query.getParentElement(t,".se-component")||t;if(!1===await this.$.eventManager.triggerEvent("onFileDeleteBefore",{element:e.target,container:e,url:e.target.getAttribute("href")}))return;const i=this.$.component.isInline(s)?s.previousSibling||s.nextSibling:s.previousElementSibling||s.nextElementSibling;Pe.utils.removeItem(s),this.$.ui.offCurrentController(),this.$.focusManager.focusEdge(i),this.$.history.push(!1)}async submitFile(t){if(0===t.length)return;let e=0;const s=[],i=this.uploadSingleSizeLimit;for(let n,o,r=0,l=t.length;r0&&o>i){const t="[SUNEDITOR.fileUpload.fail] Size of uploadable single file: "+i/1e3+"KB",e=await this.$.eventManager.triggerEvent("onFileUploadError",{error:t,limitSize:i,uploadSize:o,file:n});return this.$.ui.alertOpen(e===ha?t:e||t,"error"),!1}s.push(n),e+=o}const n=this.uploadSizeLimit,o=this.fileManager.getSize();if(n>0&&e+o>n){const t="[SUNEDITOR.fileUpload.fail] Size of uploadable total files: "+n/1e3+"KB",s=await this.$.eventManager.triggerEvent("onFileUploadError",{error:t,limitSize:n,currentSize:o,uploadSize:e});return this.$.ui.alertOpen(s===ha?t:s||t,"error"),!1}const r={url:this.uploadUrl,uploadHeaders:this.uploadHeaders,files:s},l=async function(t,e,s){e=s||e;t(await this.fileManager.asyncUpload(e.url,e.uploadHeaders,e.files))}.bind(this,this.#mc.bind(this),r),a=await this.$.eventManager.triggerEvent("onFileUploadBefore",{info:r,handler:l});return void 0===a||!1!==a&&(null!==a&&"object"==typeof a&&l(a),void(!0!==a&&a!==ha||l(null)))}convertFormat(t,e){if("link"===e){this.figure.close();const{container:e}=ji.GetContainer(t),s=e.nextElementSibling,i=e.parentElement;t.removeAttribute("data-se-non-focus"),t.setAttribute("contenteditable","false"),Pe.utils.addClass(t,"se-component|se-inline-component");const n=Pe.utils.createElement(this.$.options.get("defaultLine"),null,t);i.insertBefore(n,s),Pe.utils.removeItem(e)}else{this.$.selection.setRange(t,0,t,1);const e=this.$.html.remove(),s=this.$.nodeTransform.split(e.container,e.offset,0);s?.previousElementSibling&&Pe.check.isZeroWidth(s.previousElementSibling)&&Pe.utils.removeItem(s.previousElementSibling),t.setAttribute("data-se-non-focus","true"),t.removeAttribute("contenteditable"),Pe.utils.removeClass(t,"se-component|se-component-selected|se-inline-component");const i=ji.CreateContainer(t,"se-file-figure se-flex-component");(s||e.container).parentElement.insertBefore(i.container,s)}this.$.history.push(!1),this.$.component.select(t,ca.key)}create(t,e,s){const i=e.name||t,n=Pe.utils.createElement("A",{href:t,title:i,download:i,"data-se-file-download":"",contenteditable:"false","data-se-non-focus":"true","data-se-non-link":"true"},i);if(this.fileManager.setFileData(n,e),"link"===this.as)return n.className="se-component se-inline-component",void this.$.component.insert(n,{scrollTo:!!s,insertBehavior:s?this.insertBehavior:null});const o=ji.CreateContainer(n);if(Pe.utils.addClass(o.container,"se-file-figure|se-flex-component"),this.$.component.insert(o.container,{scrollTo:!!s,insertBehavior:s?this.insertBehavior:null})){if(s)if(this.$.options.get("componentInsertBehavior"))this.$.component.select(n,ca.key);else{const t=this.$.format.addLine(o.container,null);t&&this.$.selection.setRange(t,0,t,0)}}else this.$.focusManager.focus()}#pc(t){t.result.forEach(((t,e,s)=>{this.create(t.url,{name:t.name,size:t.size},e===s.length-1)}))}async#gc(t){const e=await this.$.eventManager.triggerEvent("onFileUploadError",{error:t});if(!1===e)return;const s=e===ha?t.errorMessage:e||t.errorMessage;this.$.ui.alertOpen(s,"error"),console.error("[SUNEDITOR.plugin.fileUpload.error]",s)}#mc(t){const e=JSON.parse(t.responseText);e.errorMessage?this.#gc(e):this.#pc(e)}async#Zh(t){const e=Pe.query.getEventTarget(t);await this.submitFile(e.files)}}const da=ca;class ua extends Yl{static key="list_bulleted";static className="se-icon-flip-rtl";#Dc;constructor(t){super(t),this.title=this.$.lang.bulletedList,this.icon="list_bulleted",this.afterItem=Pe.utils.createElement("button",{class:"se-btn se-tooltip se-sub-arrow-btn",type:"button","data-command":ua.key,"data-type":"dropdown"},`${this.$.icons.arrow_down}${this.$.lang.bulletedList}`);const e=function(){const t=`\n\t
    \n\t\t
      \n\t\t\t${e=["disc","circle","square"],e.map((t=>`\n\t\t\t
    • \n\t\t\t\t\n\t\t\t
    • \n\t\t`)).join("")}\n\t\t
    \n\t
    `;var e;return Pe.utils.createElement("DIV",{class:"se-dropdown se-list-layer"},t)}();this.#Dc=e.querySelectorAll("li button ul"),this.$.menu.initDropdownTarget({key:ua.key,type:"dropdown"},e)}active(t,e){return Pe.check.isListCell(t)&&/^UL$/i.test(t.parentElement.nodeName)?(Pe.utils.addClass(e,"active"),!0):(Pe.utils.removeClass(e,"active"),!1)}action(t){const e=this.$.format.getBlock(this.$.selection.getNode()),s=t?.querySelector("ul")?.style.listStyleType;Pe.check.isList(e)&&s?e.style.listStyleType=s:this.submit(s),this.$.menu.dropdownOff()}on(){const t=this.#Dc,e=this.$.format.getBlock(this.$.selection.getNode()),s=e?.style?e.style.listStyleType||"disc":"";for(let e,i=0,n=t.length;i${this.$.lang.numberedList}`);const e=function(){const t=`\n\t
    \n\t\t
      \n\t\t\t${ma(["decimal","upper-roman","lower-roman"])}\n\t\t
    \n\t\t
      \n\t\t${ma(["lower-latin","upper-latin","lower-greek"])}\n\t\t
    \n\t
    `;return Pe.utils.createElement("DIV",{class:"se-dropdown se-list-layer"},t)}();this.#Dc=e.querySelectorAll("li button ol"),this.$.menu.initDropdownTarget({key:ga.key,type:"dropdown"},e)}active(t,e){return Pe.check.isListCell(t)&&/^OL$/i.test(t.parentElement.nodeName)?(Pe.utils.addClass(e,"active"),!0):(Pe.utils.removeClass(e,"active"),!1)}action(t){const e=this.$.format.getBlock(this.$.selection.getNode()),s=t?.querySelector("ol")?.style.listStyleType;Pe.check.isList(e)&&s?e.style.listStyleType=s:this.submit(s),this.$.menu.dropdownOff()}on(){const t=this.#Dc,e=this.$.format.getBlock(this.$.selection.getNode()),s=e?.style?e.style.listStyleType||"decimal":"";for(let e,i=0,n=t.length;i`\n\t\t\t
  • \n\t\t\t\t\n\t\t\t
  • \n\t\t`)).join("")}const fa=ga,{debounce:va}=ze;function ba(t){return`
    ${t.key}${t.name?`${t.name}`:""}
    `}function ya(t,e){return{tag:"span",attrs:{"data-se-autocomplete":e+t.key},text:e+t.key}}const wa=class extends Jl{static key="autocomplete";static className="";#Fc=0;#Hc=0;#qc=null;#Wc=null;constructor(t,e){super(t);const s=e.limitSize||5,i=e.searchStartLength||0,n="number"==typeof e.delayTime?e.delayTime:120,o=e.useCachingData??!0,r=e.useCachingFieldData??!0;this.triggerContexts=new Map;const l=e.triggers||{};for(const[t,e]of Object.entries(l)){const n=e.limitSize??s;this.triggerContexts.set(t,{trigger:t,limitSize:n,searchStartLength:e.searchStartLength??i,directData:e.data||null,apiUrl:e.apiUrl?.replace(/\s/g,"").replace(/\{limitSize\}/i,String(n))||"",apiHeaders:e.apiHeaders||null,transformResponse:e.transformResponse||null,renderItem:e.renderItem||ba,onSelect:e.onSelect||ya,apiManager:e.apiUrl?new Kr(this,this.$,{headers:e.apiHeaders}):null,cachingData:e.useCachingData??o?new Map:null,cachingFieldData:e.useCachingFieldData??r?[]:null})}this.sortedTriggers=[...this.triggerContexts.keys()].sort(((t,e)=>e.length-t.length));const a=Pe.utils.createElement("DIV",{class:"se-controller se-empty-controller"},"
    ");this.selectMenu=new Ai(this.$,{position:"right-bottom",dir:"ltr",closeMethod:()=>this.controller.close()}),this.controller=new Ii(this,this.$,a,{position:"bottom",initMethod:()=>{this.#Uc(),this.selectMenu.close()}},null),this.selectMenu.on(a.firstElementChild,this.#Vc.bind(this)),this.onInput=va(this.onInput.bind(this),n)}#Uc(){this.#Wc?.apiManager&&this.#Wc.apiManager.cancel()}async onInput(){this.#Uc();const t=this.$.selection.get();if(!t.rangeCount)return void this.selectMenu.close();const e=t.anchorNode,s=t.anchorOffset,i=e.textContent.substring(0,s);for(const t of this.sortedTriggers){const n=i.lastIndexOf(t);if(-1===n)continue;const o=i.substring(n+t.length,s),r=i[n-1]?.trim();if(!/\s/.test(o)&&(!r||Pe.check.isZeroWidth(r))){const i=this.triggerContexts.get(t);if(o.lengtht.key.toLowerCase().startsWith(n))).slice(0,i);else{const s=await t.apiManager.asyncCall({method:"GET",url:this.#Gc(t,e)}),i=JSON.parse(s.responseText);o=t.transformResponse?t.transformResponse(i,s):i}if(t.cachingFieldData){const e=new Set;o=t.cachingFieldData.concat(o).filter((({key:t})=>!e.has(t)&&(e.add(t),t.toLowerCase().startsWith(n)))).slice(0,i)}if(!o?.length)return this.selectMenu.close(),!1;const r=[],l=[];for(let e,s=0,i=o.length;se.key===t.key))&&e.cachingFieldData.push(t)}},{debounce:Ca}=ze;const _a=class extends Jl{static key="slashCommand";static className="";#Kc;#Yc;#Xc;#oa;#Fc=0;#Hc=0;#qc=null;#Zc=!1;constructor(t,e){super(t),this.#Kc="string"==typeof e.triggerChar&&e.triggerChar.length>0?e.triggerChar:"/",this.#Yc="number"==typeof e.limitSize&&e.limitSize>0?e.limitSize:1/0,this.#Xc="string"==typeof e.emptyMessage?e.emptyMessage:"";const s="number"==typeof e.delayTime?e.delayTime:120;this.#oa=new gn(this,this.$,{items:Array.isArray(e.items)?e.items:[],resolveButton:us,renderCustomItem:"function"==typeof e.renderItem?e.renderItem:null,prepareCommit:()=>this.#Jc(),selectMenuParams:{position:"bottom-left",dir:"ltr",minWidth:"string"==typeof e.minWidth?e.minWidth:"200px",maxHeight:"string"==typeof e.maxHeight?e.maxHeight:"320px",closeMethod:()=>this.#Qc()}});const i=Pe.utils.createElement("DIV",{class:"se-controller se-empty-controller"},"
    ");this.controller=new Ii(this,this.$,i,{position:"bottom",escGuard:()=>this.#oa.hasOpenSubPanel()},null),this.#oa.attach(i.firstElementChild,this.#Vc.bind(this),{class:"se-block-action-menu se-slash-command-menu"}),this.onInput=Ca(this.onInput.bind(this),s)}onKeyDown({event:t}){Fe.isEsc(t.code)&&this.onInput.cancel?.()}onInput(){if(0===this.#oa.getItems().length)return;const t=this.$.selection.get();if(!t.rangeCount)return void this.#td();const e=t.anchorNode,s=t.anchorOffset;if(!e||"string"!=typeof e.textContent)return void this.#td();const i=e.textContent.substring(0,s),n=this.#Kc,o=i.lastIndexOf(n);if(-1===o)return void this.#td();const r=i.substring(o+n.length,s);if(/\s/.test(r))return void this.#td();const l=i[o-1];if(l&&""!==l.trim()&&!Pe.check.isZeroWidth(l))return void this.#td();const a=this.#oa.filter(r,this.#Yc);0!==a.length?(this.controller.open(e,null,{isWWTarget:!0,initMethod:null,addOffset:null}),this.#oa.createRows(a),this.#oa.open(),this.#oa.setItem(0),this.#ed(e,o,s)):this.#Xc?(this.#sd(e),this.#ed(e,o,s)):this.#td()}open(t){if(!t)return!1;const e=this.#oa.filter("",this.#Yc);return 0!==e.length&&(this.controller.open(t,null,{isWWTarget:!0,initMethod:null,addOffset:null}),this.#oa.createRows(e),this.#oa.open(),this.#oa.setItem(0),this.#ed(t,0,0),!0)}#td(){this.#Zc=!0,this.#oa.close(),this.#Zc=!1}#Qc(){this.#Zc||this.#Jc(),this.#qc=null,this.controller.close()}#Jc(){const t=this.#qc;if(!t||!t.parentNode)return;if(t.textContent?.[this.#Fc]!==this.#Kc)return;this.$.selection.setRange(t,this.#Fc,t,this.#Hc);const e=this.$.selection.getRange();e&&!e.collapsed&&this.$.html.remove()}#ed(t,e,s){this.#qc=t,this.#Fc=e,this.#Hc=s}#sd(t){this.controller.open(t,null,{isWWTarget:!0,initMethod:null,addOffset:null}),this.#oa.selectMenu.create([null],[`${this.#Xc}`]),this.#oa.open()}#Vc(t){if(!t)return!1;const e=this.#qc;if(!e)return!1;const s=this.#Kc,i=(e.textContent||"").substring(this.#Fc+s.length,this.#Hc);if("dropdownFree"!==t.kind)return this.#Jc(),this.#td(),void this.#oa.dispatch(t,{triggerChar:s,query:i,item:t.raw});const n=this.#oa.hasOpenSubPanel();this.#oa.dispatch(t,{triggerChar:s,query:i,item:t.raw}),n||this.#oa.hasOpenSubPanel()||this.#td()}};class ka extends Xl{static key="align";static className="";constructor(t,e){super(t),this.title=this.$.lang.align,this.icon=this.$.options.get("_rtl")?"align_right":"align_left",this.defaultDir="",this.alignIcons={justify:this.$.icons.align_justify,left:this.$.icons.align_left,right:this.$.icons.align_right,center:this.$.icons.align_center};const s=this.$.menu.initDropdownTarget(ka,function({lang:t,icons:e,options:s},i){return(Array.isArray(i)?i:s.get("_rtl")?["right","center","left","justify"]:["left","center","right","justify"]).map((s=>{const i=t["align"+s.charAt(0).toUpperCase()+s.slice(1)];return{command:s,title:i,innerHTML:`${e["align_"+s]}${i}`}}))}(this.$,e.items),{className:"se-list-align"});this._itemMenu=s.querySelector("ul"),this.alignList=s.querySelectorAll("li button")}active(t,e){const s=e.firstElementChild;if(t){if(this.$.format.isLine(t)){const i=t.style.textAlign;return i?(Pe.utils.changeElement(s,this.alignIcons[i]||this.alignIcons[this.defaultDir]),e.setAttribute("data-focus",i),!0):void 0}}else Pe.utils.changeElement(s,this.alignIcons[this.defaultDir]),e.removeAttribute("data-focus");return!1}on(t){const e=t.getAttribute("data-focus")||this.defaultDir;if(!e)return;const s=this.alignList;for(let t=0,i=s.length;t'+this.$.lang.font+""+this.$.icons.arrow_down;const s=e.items||["Arial","Comic Sans MS","Courier New","Impact","Georgia","tahoma","Trebuchet MS","Verdana"],i=`
  • `,n=this.$.menu.initDropdownTarget($a,function(t){return t.map((t=>{const e=t.split(",")[0];return{command:t,title:e,innerHTML:e,attrs:{"data-txt":e,style:`font-family:${t};`}}}))}(s),{className:"se-list-font-family",prependHTML:i});this.currentFont="",this.fontList=n.querySelectorAll("ul li button"),this.fontArray=s,this.#nd=n.querySelector(".se-sub-list span")}active(t,e){const s=e.querySelector(".se-txt"),i=e.parentNode.querySelector(".se-tooltip-text");let n="";if(t){if(this.$.format.isLine(t))return;if(n=Pe.utils.getStyle(t,"fontFamily")){const t=n.replace(/["']/g,"");return Pe.utils.changeTxt(s,t),Pe.utils.changeTxt(i,this.$.lang.font+" ("+t+")"),!0}}else{const t=this.$.store.get("hasFocus")?this.$.frameContext.get("wwComputedStyle").fontFamily:this.$.lang.font;Pe.utils.changeTxt(s,t),Pe.utils.changeTxt(i,this.$.store.get("hasFocus")?this.$.lang.font+(t?" ("+t+")":""):t)}return!1}on(t){const e=this.fontList,s=t.querySelector(".se-txt").textContent;if(s!==this.currentFont){let t=!1;for(let i=0,n=e.length;ithis.$.format.isLine(t)))}off(){this.colorPicker.hueSliderClose()}colorPickerAction(t){if(t){const e=Pe.utils.createElement("SPAN",{style:"color: "+t+";"});this.$.inline.apply(e,{stylesToModify:["color"],nodesToRemove:null,strictRemove:null})}else this.$.inline.apply(null,{stylesToModify:["color"],nodesToRemove:["span"],strictRemove:!0});this.$.menu.dropdownOff()}}const Ta=Ea;class Ma extends Zl{static key="backgroundColor";static className="";constructor(t,e){super(t),this.title=this.$.lang.backgroundColor,this.icon="background_color";const s=Pe.utils.createElement("DIV",{class:"se-dropdown se-list-layer"},null);this.colorPicker=new zl(this,this.$,"backgroundColor",{form:s,colorList:e.items,splitNum:e.splitNum,disableHEXInput:e.disableHEXInput,hueSliderOptions:{controllerOptions:{isOutsideForm:!0}}}),this.$.menu.initDropdownTarget(Ma,s)}active(t,e){const s=e.querySelector("path.se-svg-color-helper");if(!s)return;let i="";if(t){if(this.$.format.isLine(t))return;if(i=Pe.utils.getStyle(t,"backgroundColor"))return s.style.color=i,!0}else s.style.color=i;return!1}on(t){this.colorPicker.init(this.$.selection.getNode(),t,(t=>this.$.format.isLine(t)))}off(){this.colorPicker.hueSliderClose()}colorPickerAction(t){if(t){const e=Pe.utils.createElement("SPAN",{style:"background-color: "+t+";"});this.$.inline.apply(e,{stylesToModify:["background-color"],nodesToRemove:null,strictRemove:null})}else this.$.inline.apply(null,{stylesToModify:["background-color"],nodesToRemove:["span"],strictRemove:!0});this.$.menu.dropdownOff()}}const Na=Ma;class Ba extends Xl{static key="hr";static className="";static component(t){return/^hr$/i.test(t?.nodeName)?t:null}constructor(t,e){super(t),this.title=this.$.lang.horizontalLine,this.icon="horizontal_line";const s=this.$.menu.initDropdownTarget(Ba,function({lang:t},e){return(e||[{name:t.hr_solid,class:"__se__solid",style:null},{name:t.hr_dashed,class:"__se__dashed",style:null},{name:t.hr_dotted,class:"__se__dotted",style:null}]).map((t=>({command:"hr",title:t.name,innerHTML:``})))}(this.$,e.items),{className:"se-list-line"});this.list=s.querySelectorAll("button")}componentSelect(t){Pe.utils.addClass(t,"on")}componentDeselect(t){Pe.utils.removeClass(t,"on")}componentDestroy(t){if(!t)return;const e=t.previousElementSibling||t.nextElementSibling;Pe.utils.removeItem(t),this.$.focusManager.focusEdge(e),this.$.history.push(!1)}shortcut({line:t,range:e}){const s=this.$.nodeTransform.split(e.endContainer,e.endOffset,0);this.submit("__se__solid"),Pe.utils.removeItem(t),this.$.selection.setRange(s,0,s,0)}action(t){const e=this.submit(t.firstElementChild.className),s=this.$.format.addLine(e);this.$.selection.setRange(s,1,s,1),this.$.menu.dropdownOff()}submit(t){const e=Pe.utils.createElement("hr",{class:t});return this.$.focusManager.focus(),this.$.component.insert(e,{insertBehavior:"line"}),e}}const Ia=Ba;class La extends Xl{static key="list";static className="se-icon-flip-rtl";#Dc;#od;constructor(t){super(t),this.title=this.$.lang.list,this.icon="list_numbered",this.#od={bulleted:this.$.icons.list_bulleted,numbered:this.$.icons.list_numbered};const e=this.$.menu.initDropdownTarget(La,function({lang:t,icons:e}){return[{command:"ol",title:t.numberedList,innerHTML:e.list_numbered,className:"se-tooltip se-icon-flip-rtl"},{command:"ul",title:t.bulletedList,innerHTML:e.list_bulleted,className:"se-tooltip se-icon-flip-rtl"}]}(this.$));this.#Dc=e.querySelectorAll("li button")}active(t,e){const s=e.firstElementChild;if(Pe.check.isList(t)){const i=t.nodeName.toLowerCase();return e.setAttribute("data-focus",i),Pe.utils.addClass(e,"active"),/^ul$/.test(i)?Pe.utils.changeElement(s,this.#od.bulleted):Pe.utils.changeElement(s,this.#od.numbered),!0}return e.removeAttribute("data-focus"),Pe.utils.changeElement(s,this.#od.numbered),Pe.utils.removeClass(e,"active"),!1}on(t){const e=t.getAttribute("data-focus")||"",s=this.#Dc;for(let t=0,i=s.length;t

    `.repeat(e)}function ih(t){return t=t.toLowerCase(),Pe.utils.createElement(t,null,"

    ")}function nh(t,e,s){let i=Za.get(t);return i||(i=function(t){const e=[],s=t.rows,i=[];for(let t=0,n=s.length;t1)for(let e=1;e{const e=i.indexOf(t);return e>-1?n[e]:null})).filter((t=>null!==t))}}function rh(t){t&&(Xa.delete(t),Za.delete(t))}function lh(t,e,s){const i=[];let n="";for(const o in Ha){if(s.includes(o))continue;const r=Ha[o];i.push(o),n+=`\n\t\t\t`}return{items:i,menus:Pe.utils.createElement("DIV",null,n).querySelectorAll("button")}}const ah=class{#rd;#J;#I;constructor(t,{mergeButton:e,unmergeButton:s,splitButton:i,openCellMenuFunc:n,closeCellMenuFunc:o}){this.#rd=t,this.#J=t.$,this.#I=t.state,this.mergeButton=e,this.unmergeButton=s,this.splitButton=i;const r=(l=this.#J.lang,{items:["vertical","horizontal"],menus:Pe.utils.createElement("DIV",null,`\n\t\t
    \n\t\t\t${l.verticalSplit}\n\t\t
    \n\t\t
    \n\t\t\t${l.horizontalSplit}\n\t\t
    `).querySelectorAll("div")});var l;this.selectMenu_split=new Ai(this.#J,{checkList:!1,position:"bottom-center",openMethod:n,closeMethod:o}),this.selectMenu_split.on(this.splitButton,this._OnSplitCells.bind(this)),this.selectMenu_split.create(r.items,r.menus)}get#ld(){return this.#rd.selectionService}openSplitMenu(){this.selectMenu_split.open()}mergeCells(t,e=!1){const s=t[0].closest("table");rh(s);const{clonedTable:i,clonedSelectedCells:n}=e?{clonedTable:s,clonedSelectedCells:t}:oh(s,t);this.#rd.setTableInfo(i),t=n,this.#rd.setState("ref",null),this.#ld.setMultiCells(t[0],Pe.query.findVisualLastCell(t));const o=this.#I.ref,r=t[0];let l=null,a=null;const h=o.ce-o.cs+1;let c=o.re-o.rs+1,d="",u=null;for(let e,s,i=1,n=t.length;i0&&o+i>=e&&(t.rowSpan-=De.getOverlapRangeAtIndex(e,s,o,o+i));else i.push(t[o]);for(let t=0,e=i.length;tl.closest("tr").rowIndex||r.cellIndex>l.cellIndex?r:l,this.#ld.setMultiCells(o,r),this.#rd.setState("selectedCells",Array.from(a.querySelectorAll(".se-selected-table-cell")))):this.#rd.setCellInfo(r,!0),this.#ld.initCellSelection(o),this.#rd.setState("selectedCell",r),this.setUnMergeButton(),this.#rd.controller_cell.resetPosition(r),this.#rd.historyPush())}findMergedCells(t){const e=[];return t?.forEach((t=>{t&&(t.rowSpan>1||t.colSpan>1)&&e.push(t)})),e}setMergeSplitButton(){this.#I.ref?(this.splitButton.style.display="none",this.mergeButton.style.display="block"):(this.splitButton.style.display="block",this.mergeButton.style.display="none")}setUnMergeButton(){const t=this.findMergedCells(this.#I.selectedCells?.length?this.#I.selectedCells:[this.#I.fixedCell]).length>0;this.unmergeButton.style.display=t?"block":"none"}_OnSplitCells(t){rh(this.#rd._element);const e="vertical"===t,s=this.#I.tdElement,i=this.#I.trElements,n=this.#I.trElement,o=this.#I.logical_cellIndex,r=this.#I.rowIndex,l=ih(s.nodeName);if(e){const t=s.colSpan;if(l.rowSpan=s.rowSpan,t>1)l.colSpan=Math.floor(t/2),s.colSpan=t-l.colSpan,n.insertBefore(l,s.nextElementSibling);else{let e=[],r=[];for(let n,l,a=0,h=this.#I.rowCnt;a0)for(let t,e=0;ea||(d>=t.index?(l+=t.cs,d+=t.cs,t.rs-=1,t.row=a+1,t.rs<1&&(r.splice(e,1),e--)):u===p-1&&(t.rs-=1,t.row=a+1,t.rs<1&&(r.splice(e,1),e--)));if(d<=o&&c>0&&e.push({index:d,cs:h+1,rs:c,row:-1}),i!==s&&d<=o&&d+h>=o+t-1){i.colSpan+=1;break}if(d>o)break;l+=h}r=r.concat(e).sort((function(t,e){return t.index-e.index})),e=[]}n.insertBefore(l,s.nextElementSibling)}}else{const t=s.rowSpan;if(l.colSpan=s.colSpan,t>1){l.rowSpan=Math.floor(t/2);const e=t-l.rowSpan,r=[],a=Pe.utils.getArrayIndex(i,n)+e;for(let t,e,s=0;s=o));h++)i=t[h],n=i.rowSpan-1,n>0&&n+s>=a&&l=d.index&&(u+=d.cs,i+=d.cs,d=r.shift()),i>=o||n===a-1){h.insertBefore(l,t.nextElementSibling);break}u+=e}s.rowSpan=e}else{l.rowSpan=s.rowSpan;const t=Pe.utils.createElement("TR");t.appendChild(l);for(let t,e=0;e=r&&(t[s].rowSpan+=1)}const e=this.#I.physical_cellIndex,o=n.cells;for(let t=0,s=o.length;t{r.set(t,!0)}));const l=i.rows,a=l.length,h=Array.from(l[0].cells).reduce(((t,e)=>t+(e.colSpan||1)),0),c=Array.from({length:a},(()=>Array(h).fill(null)));for(let t=0;t0&&c[t-1][s]===i)continue;const n=i.cloneNode(!0);let l=1,d=1;for(;t+l1&&(n.rowSpan=l),d>1&&(n.colSpan=d),e.appendChild(n)}}const d=Pe.utils.createElement("figure");d.className=e.className,d.appendChild(n);const u=`\x3c!--StartFragment--\x3e${d.outerHTML}\x3c!--EndFragment--\x3e`;t.clipboardData.setData("text/html",u)}pasteTableCellMatrix(t,e){if(!t||!e)return;rh(e.closest("table"));const s=t.rows;let i=0;const n=[];for(let t=0;t0||g>0){const t=d[d.length-1],e=t.cells[t.cells.length-1];for(let t=0;t1||o>1)for(let e=1;e=f&&(o>1||r>1)&&b.push(n),s+=o}}b.length>0&&(this.#hd.unmergeCells(b,!0),this.#rd.setState("trElements",d=c.rows));const w=[],C=[],_=[];for(let t=0,e=r.rowCnt;t1)for(let t=1;t=l&&c<=a&&h.push(n),s+=o}}h.length>0&&w.push(h),i+=o}}if(w.length>0){for(const t of w)this.#rd.setState("ref",null),this.#rd.setState("trElements",c.rows),this.#hd.mergeCells(t,!0);this.#rd.setState("trElements",d=c.rows)}const k=[],x=[];for(let t=0;t1)for(let e=1;e=f&&r+i-1<=v&&(e.innerHTML=s.innerHTML,k.push(e),a++),r+=i}}return l.replaceWith(c),this.#rd._closeTableSelectInfo(),this.#rd.setTableInfo(c),this.#hd.setMergeSplitButton(),this.#hd.setUnMergeButton(),this.#ld.focusCellEdge(k[0]),this.#rd.historyPush(),k}};const ch=class{#rd;#J;#I;constructor(t,{columnButton:e,rowButton:s,openCellMenuFunc:i,closeCellMenuFunc:n}){this.#rd=t,this.#J=t.$,this.#I=t.state;const o=(r=this.#J.lang,l=this.#J.icons,{items:["insert-left","insert-right","delete"],menus:Pe.utils.createElement("DIV",null,`\n\t\t
    \n\t\t\t${l.insert_column_left}${r.insertColumnBefore}\n\t\t
    \n\t\t
    \n\t\t\t${l.insert_column_right}${r.insertColumnAfter}\n\t\t
    \n\t\t
    \n\t\t\t${l.delete_column}${r.deleteColumn}\n\t\t
    `).querySelectorAll("div")});var r,l;this.selectMenu_column=new Ai(this.#J,{checkList:!1,position:"bottom-center",openMethod:i,closeMethod:n}),this.selectMenu_column.on(e,this.#cd.bind(this)),this.selectMenu_column.create(o.items,o.menus);const a=function(t,e){return{items:["insert-above","insert-below","delete"],menus:Pe.utils.createElement("DIV",null,`\n\t\t
    \n\t\t\t${e.insert_row_above}${t.insertRowAbove}\n\t\t
    \n\t\t
    \n\t\t\t${e.insert_row_below}${t.insertRowBelow}\n\t\t
    \n\t\t
    \n\t\t\t${e.delete_row}${t.deleteRow}\n\t\t
    `).querySelectorAll("div")}}(this.#J.lang,this.#J.icons);this.selectMenu_row=new Ai(this.#J,{checkList:!1,position:"bottom-center",openMethod:i,closeMethod:n}),this.selectMenu_row.on(s,this.#dd.bind(this)),this.selectMenu_row.create(a.items,a.menus)}get#ld(){return this.#rd.selectionService}openColumnMenu(){this.selectMenu_column.open()}openRowMenu(){this.selectMenu_row.menus[0].style.display=this.selectMenu_row.menus[1].style.display=/^TH$/i.test(this.#I.tdElement?.nodeName)?"none":"",this.selectMenu_row.open()}editTable(t,e){const s=this.#rd._element,i="row"===t;if(i){const t=this.#I.trElement.parentElement;if(/^THEAD$/i.test(t.nodeName)){if("up"===e)return;if(!t.nextElementSibling||!/^TBODY$/i.test(t.nextElementSibling.nodeName))return void(e?s.innerHTML+=""+sh("td",this.#I.logical_cellCnt)+"":(Pe.utils.removeItem(this.#I.figureElement),this.#rd._closeTableSelectInfo()))}}if(this.#I.ref){const t=this.#I.tdElement,s=this.#I.selectedCells;if(i)if(e)this.#rd.setCellInfo("up"===e?s[0]:s.at(-1),!0),this.editRow(e,null,t);else{let t=s[0].parentNode;const i=[s[0]];for(let e,n=1,o=s.length;n0){const t=!e[v+1];for(let e,s=0;sm||(f>=e.index?(g+=e.cs,f=v+g,e.rs-=1,e.row=m+1,e.rs<1&&(c.splice(s,1),s--)):t&&(e.rs-=1,e.row=m+1,e.rs<1&&(c.splice(s,1),s--)))}s>0&&h.push({rs:s,cs:l+1,index:f,row:-1}),f>=a&&f+l<=a+o?u.push(t):f<=a+o&&f+l>=a?t.colSpan-=De.getOverlapRangeAtIndex(r,r+o,f,f+l):s>0&&(fa+o)&&p.push({cell:t,i:m,rs:m+s}),g+=l}else{if(v>=a)break;if(l>0){if(d<1&&l+v>=a){t.colSpan+=1,a=null,d=s+1;break}a-=l}if(!n){for(let t,e=0;e0){d-=1;continue}null!==a&&e.length>0&&(s=ih(e[0].nodeName),s=t.insertBefore(s,e[a]))}}const g=this.#rd._element.querySelector("colgroup");if(g){const t=g.querySelectorAll("col");if(i)Pe.utils.removeItem(t[a]);else{if(!(!Pe.utils.hasClass(this.#rd._element,"se-table-layout-fixed")&&"fixed"!==this.#rd._element.style.tableLayout)&&Array.prototype.some.call(t,(t=>De.get(t.style.width)>0))){let e=0;for(let s,i=0,n=t.length;ir&&r>e&&(t[n].rowSpan=s+l,h-=i)}if(i){const t=a[o+1];if(t){const e=[];let s=a[o].cells,i=0;for(let t,n,o=0,r=s.length;o1&&(t.rowSpan-=1,e.push({cell:t.cloneNode(!0),index:n}));if(e.length>0){let n=e.shift();s=t.cells,i=0;for(let o,r,l=0,a=s.length;l=n.index)||(l--,i--,i+=n.cell.colSpan-1,t.insertBefore(n.cell,o),n=e.shift(),n));l++);if(n){t.appendChild(n.cell);for(let s=0,i=e.length;s1)for(;Pe.check.isTableRow(t)&&s>1;)t=t.nextElementSibling,--s;this.#ld.deleteStyleSelectedCells(),this.#rd.setRowInfo(t),this.#J.ui.enableBackWrapper("ns-resize"),this.#pd||=this.#J.frameContext.get("wrapper").querySelector(Pa),this.#gd=this.#J.frameContext.get("wrapper").querySelector(Da),this._startRowResizing(t,i.startY,De.get(dh.getComputedStyle(t).height,0)),this.#rd._editorEnable(!1)}catch(t){console.warn("[SUNEDITOR.plugins.table.error]",t),this.#rd._editorEnable(!0),this.#hi()}finally{this.#rd.setState("fixedCell",null),this.#rd.setState("selectedCell",null),this.#rd.controller_table.hide(),this.#rd.controller_cell.hide()}return!1}}#bd(t){const e=t.querySelector("colgroup").querySelectorAll("col"),s=t.offsetWidth;e.forEach((t=>{const e=t.style.width;if(!e.endsWith("%")){const i=(t.offsetWidth||De.get(e,0))/s*100;t.style.width=i+"%"}}))}_startCellResizing(t,e,s,i){const n=this.#I.figureElement;Pe.utils.removeClass(n,"se-component-selected"),this.#bd(this.#rd._element),this.#md(n,this.#I.tdElement,this.#gd,i),this.#gd.style.display="block";const o=t.style.width,r=t.nextElementSibling,l=r.style.width,a=Pe.utils.hasClass(this.#rd._element,"se-table-layout-fixed")?l:ze.getWidthInPercentage(r||t);_i.get("__dragHandler")&&(_i.get("__dragHandler").style.display="none"),this.#yd(this.#wd.bind(this,t,r,n,this.#I.tdElement,this.#pd,i,e,s,De.get(o,0),De.get(a,0),this.#rd._element.offsetWidth),(()=>{this.#hi(),this.#bd(this.#rd._element),this.#J.history.push(!0),this.#J.component.hoverSelect(this.#rd._element),this.#rd._editorEnable(!0)}),(e=>{this._stopResize(t,o,"width",e),this._stopResize(r,l,"width",e)}))}#wd(t,e,s,i,n,o,r,l,a,h,c,d){const u=(l+(d.clientX-r))/c*100;if(u>0){t.style.width=`${u}%`;const r=a-u;e.style.width=`${h+r}%`,this.#md(s,i,n,o)}}_startRowResizing(t,e,s){const i=this.#I.figureElement;Pe.utils.removeClass(i,"se-component-selected"),this.#fd(i,t,this.#gd),this.#gd.style.display="block";const n=t.style.height;_i.get("__dragHandler")&&(_i.get("__dragHandler").style.display="none"),this.#yd(this.#Cd.bind(this,t,i,this.#pd,e,s),(()=>{this.#hi(),this.#J.history.push(!0),this.#J.component.hoverSelect(this.#rd._element),this.#rd._editorEnable(!0)}),this._stopResize.bind(this,t,n,"height"))}#Cd(t,e,s,i,n,o){const r=n+(o.clientY-i);t.style.height=`${r}px`,this.#fd(e,t,s)}_startFigureResizing(t,e){const s=this.#I.figureElement;Pe.utils.removeClass(s,"se-component-selected"),this.#md(s,s,this.#gd,e),this.#gd.style.display="block";const i=ze.getWidthInPercentage(s);_i.get("__dragHandler")&&(_i.get("__dragHandler").style.display="none"),this.#yd(this.#_d.bind(this,s,this.#pd,e,t,s.offsetWidth,De.get(i,0)),(()=>{this.#hi(),De.get(s.style.width,0)>100&&(s.style.width="100%"),this.#J.history.push(!0),this.#J.component.hoverSelect(this.#rd._element),this.#rd._editorEnable(!0)}),this._stopResize.bind(this,s,s.style.width,"width"))}#_d(t,e,s,i,n,o,r){const l=(n+(s?i-r.clientX:r.clientX-i))/n*o;l>0&&(t.style.width=`${l}%`,this.#md(t,t,e,s))}#md(t,e,s,i){const n=this.#J.offset.getLocal(e),o=this.#J.offset.getLocal(t);s.style.left=`${n.left+(i?0:e.offsetWidth)}px`,s.style.top=`${o.top}px`,s.style.height=`${t.offsetHeight}px`}#fd(t,e,s){const i=this.#J.offset.getLocal(e),n=this.#J.offset.getLocal(t);s.style.top=`${i.top+e.offsetHeight}px`,s.style.left=`${n.left}px`,s.style.width=`${t.offsetWidth}px`}_stopResize(t,e,s,i){Fe.isEsc(i.code)&&(this.#hi(),this.#J.component.hoverSelect(this.#rd._element),this.#rd._editorEnable(!0),t.style[s]=e,"width"===s&&this.#J.component.select(this.#rd._element,this.#rd.constructor.key,{isInput:!0}))}#yd(t,e,s){this.#it.resize=this.#J.eventManager.addGlobalEvent("mousemove",t,!1),this.#it.resizeStop=this.#J.eventManager.addGlobalEvent("mouseup",e,!1),this.#it.resizeKeyDown=this.#J.eventManager.addGlobalEvent("keydown",s,!1),this.#ud=!0}#hi(){this.#ud=!1,this.#J.ui.disableBackWrapper(),this.#vd(),this.#gd&&(this.#gd.style.display="none",this.#gd=null);const t=this.#it;for(const e in t)t[e]&&=this.#J.eventManager.removeGlobalEvent(t[e]);this.#ud=!1,this.#pd=null}#vd(){this.#pd&&(this.#pd.style.display="none",this.#pd=null),this.#rd._element&&(this.#rd._element.style.cursor="")}init(){this.#hi()}};const ph=class{#rd;#J;#I;#kd;#xd;#$d;#Sd;#it;#Ed=null;constructor(t){this.#rd=t,this.#J=t.$,this.#I=t.state,this.#kd=this.#Td.bind(this),this.#xd=this.#Md.bind(this),this.#$d=this.#Nd.bind(this),this.#Sd=this.#Bd.bind(this),this.#it={on:null,off:null,shiftOff:null,touchOff:null,resize:null,resizeStop:null,resizeKeyDown:null}}get#hd(){return this.#rd.cellService}selectCells(t){const e=t[0],s=Pe.query.findVisualLastCell(t);return this.#Ed=e.nodeName,this.setMultiCells(e,s),{fixedCell:e,selectedCell:s}}setMultiCells(t,e){const s=this.#I.selectedTable,i=s.rows;if(this.deleteStyleSelectedCells(),Pe.utils.addClass(t,"se-selected-table-cell"),t===e&&!this.#I.isShiftPressed)return;const n=function(t,e){const s=t.parentNode,i=e.parentNode;return`${s.rowIndex},${t.cellIndex}-${i.rowIndex},${e.cellIndex}`}(t,e);let o=Xa.get(s);const r=o?.get(n);if(r)return this.#rd.setState("ref",r),void this.#Id(i,r);const l=this.#Ld(i,t,e);this.#rd.setState("ref",l),o||(o=new Map,Xa.set(s,o)),o.set(n,l),this.#Id(i,l)}#Ld(t,e,s){let i=!0,n=[],o=[];const r={_i:0,cs:null,ce:null,rs:null,re:null};for(let l,a,h=0,c=t.length;h0)for(let t,e=0;eh||(c>=t.index?(a+=t.cs,c+=t.cs,t.rs-=1,t.row=h+1,t.rs<1&&(n.splice(e,1),e--)):p===g-1&&(t.rs-=1,t.row=h+1,t.rs<1&&(n.splice(e,1),e--)));if(i){if(t!==e&&t!==s||(r.cs=null!==r.cs&&r.csc+d?r.ce:c+d,r.rs=null!==r.rs&&r.rsh+u?r.re:h+u,r._i+=1),2===r._i){i=!1,n=[],o=[],h=-1;break}}else{const t=r.csc+d?r.ce:c+d,s=r.rsh+u?r.re:h+u;if(De.getOverlapRangeAtIndex(r.cs,r.ce,c,c+d)&&De.getOverlapRangeAtIndex(r.rs,r.re,h,h+u)&&(r.cs!==t||r.ce!==e||r.rs!==s||r.re!==i)){r.cs=t,r.ce=e,r.rs=s,r.re=i,h=-1,n=[],o=[];break}}u>0&&o.push({index:c,cs:d+1,rs:u,row:-1}),a+=t.colSpan-1}n=n.concat(o).sort(((t,e)=>t.index-e.index)),o=[]}return r}#Id(t,e){let s=[],i=[];for(let n,o,r=0,l=t.length;r0)for(let t,e=0;er||(l>=t.index?(o+=t.cs,l+=t.cs,t.rs-=1,t.row=r+1,t.rs<1&&(s.splice(e,1),e--)):c===d-1&&(t.rs-=1,t.row=r+1,t.rs<1&&(s.splice(e,1),e--)));De.getOverlapRangeAtIndex(e.cs,e.ce,l,l+a)&&De.getOverlapRangeAtIndex(e.rs,e.re,r,r+h)&&Pe.utils.addClass(t,"se-selected-table-cell"),h>0&&i.push({index:l,cs:a+1,rs:h,row:-1}),o+=t.colSpan-1}s=s.concat(i).sort(((t,e)=>t.index-e.index)),i=[]}}initCellSelection(t){this.#rd.setState("fixedCell",t),this.#I.selectedCells?.length||this.#rd.setState("selectedCells",[t]),this.#Ed=t.nodeName,this.#rd.setState("selectedTable",Pe.query.getParentElement(t,"TABLE")),this.deleteStyleSelectedCells(),Pe.utils.addClass(t,"se-selected-cell-focus")}startCellSelection(t,e){this.#I.isShiftPressed||this.#I.ref||this.#hi(),this.#rd.setState("isShiftPressed",e),this.initCellSelection(t),e?(this.#it.shiftOff=this.#J.eventManager.addGlobalEvent("keyup",this.#$d,!1),this.#it.on=this.#J.eventManager.addGlobalEvent("mousedown",this.#kd,!1)):this.#it.on=this.#J.eventManager.addGlobalEvent("mousemove",this.#kd,!1),this.#it.off=this.#J.eventManager.addGlobalEvent("mouseup",this.#xd,!1),this.#it.touchOff=this.#J.eventManager.addGlobalEvent("touchmove",this.#Sd,!1)}deleteStyleSelectedCells(){Pe.utils.removeClass([this.#I.fixedCell,this.#I.selectedCell],"se-selected-cell-focus");const t=this.#I.fixedCell?.closest("table");if(t){const e=t.querySelectorAll(".se-selected-table-cell");for(let t=0,s=e.length;t0?this.#I.selectedCell:e;this.#rd._setController(s)}#Nd(){if(this.#I.ref){this.#hi(),this.#rd._editorEnable(!0),this.focusCellEdge(this.#I.fixedCell);const t=this.#I.selectedCells?.length>0?this.#I.selectedCell:this.#I.fixedCell;this.#rd._setController(t)}else this.#rd._closeController()}#Bd(){this.#rd.resetInfo()}#hi(){this.#J.ui.disableBackWrapper();const t=this.#it;for(const e in t)t[e]&&=this.#J.eventManager.removeGlobalEvent(t[e])}init(){this.#hi()}},{_w:gh}=Oe;const mh=class{#rd;#I;#J;constructor(t,{pluginOptions:e,controller_table:s}){this.#rd=t,this.#I=t.state,this.#J=t.$,this.sliderType="",this.resizeButton=s.querySelector("._se_table_resize"),this.resizeText=s.querySelector("._se_table_resize > span > span"),this.columnFixedButton=s.querySelector("._se_table_fixed_column"),this.headerButton=s.querySelector("._se_table_header"),this.captionButton=s.querySelector("._se_table_caption");const i=function({lang:t,icons:e,options:s}){const i=s.get("_rtl")?["right","center","left","justify"]:["left","center","right","justify"];let n="";for(let s,o,r=0;r\n\t\t\t${e["align_"+s]}\n\t\t\t\n\t\t\t\t${o}\n\t\t\t\n\t\t`;const o=["top","middle","bottom"];let r="";for(let s,i,n=0;n\n\t\t\t${e["align_"+s]}\n\t\t\t\n\t\t\t\t${i}\n\t\t\t\n\t\t`;const l=`\n\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t${t.tableProperties}\n\t\t\t
    \n\t\t\t
    \n\n\t\t\t\t${t.border}\n\t\t\t\t
    \n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
    \n\n\t\t\t\t${t.color}\n\t\t\t\t
    \n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
    \n\n\t\t\t\t${t.font}\n\t\t\t\t
    \n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
    \n\n\t\t\t\t
    \n\t\t\t\t\t${t.align} ( ${t.table} )\n\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t${n}\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t${r}\n\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    `,a=Pe.utils.createElement("DIV",{class:"se-controller se-table-props"},l);return{html:a,controller_props_title:a.querySelector(".se-controller-title"),borderButton:a.querySelector('[data-command="props_onborder_style"]'),borderFormatButton:a.querySelector('[data-command="props_onborder_format"]'),cell_alignment:a.querySelector(".se-table-props-align .__se__a_h"),cell_alignment_vertical:a.querySelector(".se-table-props-align .__se__a_v"),cell_alignment_table_text:a.querySelector(".se-table-props-align .__se__a_table_t"),border_style:a.querySelector('[data-command="props_onborder_style"] .se-txt'),border_color:a.querySelector(".__se_border_color"),border_width:a.querySelector(".__se__border_size"),back_color:a.querySelector(".__se_back_color"),font_color:a.querySelector(".__se_font_color"),palette_border_button:a.querySelector('[data-command="props_onpalette"][data-value="border"]'),font_bold:a.querySelector('[data-command="props_font_style"][data-value="bold"]'),font_underline:a.querySelector('[data-command="props_font_style"][data-value="underline"]'),font_italic:a.querySelector('[data-command="props_font_style"][data-value="italic"]'),font_strike:a.querySelector('[data-command="props_font_style"][data-value="strike"]')}}(this.#J),n=[this.#rd.controller_table,this.#rd.controller_cell];this.controller_props=new Ii(this,this.#J,i.html,{position:"bottom",parents:n,isInsideForm:!0}),this.controller_props_title=i.controller_props_title;const o=Pe.utils.createElement("DIV",{class:"se-controller se-list-layer"},null);this.controller_colorPicker=new Ii(this,this.#J,o,{position:"bottom",parents:[this.controller_props].concat(n),isInsideForm:!0,isWWTarget:!1,initMethod:()=>{this.colorPicker.hueSlider.close(),Pe.utils.removeClass(this.controller_colorPicker.currentTarget,"on")}}),this.colorPicker=new zl(this,this.#J,"",{form:o,colorList:e.colorList||Ga,splitNum:5,disableRemove:!0,hueSliderOptions:{controllerOptions:{isOutsideForm:!0,parents:[this.controller_colorPicker],parentsHide:!0}}});const r=function(){let t="";for(let e,s=0,i=Fa.length;s\n\t\t\t${e}\n\t\t`;const e=Pe.utils.createElement("DIV",null,t);return{items:Fa,menus:e.querySelectorAll("div")}}(),l=i.borderButton;this.selectMenu_props_border=new Ai(this.#J,{checkList:!1,position:"bottom-center"}),this.selectMenu_props_border.on(l,this.#Ad.bind(this)),this.selectMenu_props_border.create(r.items,r.menus);const a=lh(this.#J.lang,this.#J.icons,[]),h=i.borderFormatButton;this.selectMenu_props_border_format=new Ai(this.#J,{checkList:!1,position:"bottom-left",dir:"ltr",splitNum:5}),this.selectMenu_props_border_format.on(h,this.#Od.bind(this,"all")),this.selectMenu_props_border_format.create(a.items,a.menus);const c=lh(this.#J.lang,this.#J.icons,qa);this.selectMenu_props_border_format_oneCell=new Ai(this.#J,{checkList:!1,position:"bottom-left",dir:"ltr",splitNum:6}),this.selectMenu_props_border_format_oneCell.on(h,this.#Od.bind(this,"outside")),this.selectMenu_props_border_format_oneCell.create(c.items,c.menus),this.maxText=this.#J.lang.maxSize,this.minText=this.#J.lang.minSize,this.propTargets={cell_alignment:i.cell_alignment,cell_alignment_vertical:i.cell_alignment_vertical,cell_alignment_table_text:i.cell_alignment_table_text,border_format:h,border_style:i.border_style,border_color:i.border_color,border_width:i.border_width,back_color:i.back_color,font_color:i.font_color,palette_border_button:i.palette_border_button,font_bold:i.font_bold,font_underline:i.font_underline,font_italic:i.font_italic,font_strike:i.font_strike},this._propsCache=[],this._currentFontStyles=[],this._propsAlignCache="",this._propsVerticalAlignCache="",this._typeCache=""}get#ld(){return this.#rd.selectionService}colorPickerAction(t){this.applyColorPicker(t)}controllerAction(t){const e=t.getAttribute("data-command");if(!e)return;const s=t.getAttribute("data-value");switch(e){case"props_onborder_format":this.openBorderFormatMenu();break;case"props_onborder_style":this.openBorderStyleMenu();break;case"props_onpalette":this.openColorPalette(t,s);break;case"props_font_style":this.toggleFontStyle(s);break;case"props_submit":this.submitProps(t);break;case"props_align":this.setAlignProps(t.getAttribute("data-value"));break;case"props_align_vertical":this.setVerticalAlignProps(t.getAttribute("data-value"))}}openTableProps(t){this.controller_props.currentTarget===t&&"block"===this.controller_props.form?.style.display?this.controller_props.close():(this.controller_props_title.textContent=this.#J.lang.tableProperties,this.#Rd("table"),this.controller_props.open(t,this.#rd.controller_table.form,{isWWTarget:!1,initMethod:null,addOffset:null}))}openCellProps(t){this.controller_props.currentTarget===t&&"block"===this.controller_props.form?.style.display?this.controller_props.close():(this.controller_props_title.textContent=this.#J.lang.cellProperties,this.#Rd("cell"),this.controller_props.open(t,this.#rd.controller_cell.form,{isWWTarget:!1,initMethod:null,addOffset:null}))}openBorderFormatMenu(){1===this._propsCache.length?this.selectMenu_props_border_format_oneCell.open():this.selectMenu_props_border_format.open()}openBorderStyleMenu(){this.selectMenu_props_border.open()}openColorPalette(t,e){const{back_color:s,font_color:i,border_color:n}=this.propTargets,o="border"===e?n:"back"===e?s:i;this.controller_colorPicker.isOpen&&e===this.sliderType?this.controller_colorPicker.close():(this.sliderType=e,Pe.utils.addClass(t,"on"),this.colorPicker.init(o?.value||"",t),this.controller_colorPicker.open(t,null,{isWWTarget:!1,initMethod:null,addOffset:null}))}toggleFontStyle(t){Pe.utils.toggleClass(this.propTargets[`font_${t}`],"on")}toggleHeader(){const t=this.headerButton,e=Pe.utils.hasClass(t,"active"),s=this.#rd._element;if(rh(s),e)Pe.utils.removeItem(s.querySelector("thead"));else{const t=Pe.utils.createElement("THEAD");t.innerHTML=""+sh("th",this.#I.logical_cellCnt)+"",s.insertBefore(t,s.querySelector("tbody"))}Pe.utils.toggleClass(t,"active"),/TH/i.test(this.#I.tdElement.nodeName)?this.#rd._closeController():this.#rd._setCellControllerPosition(this.#I.tdElement,!1)}toggleCaption(){const t=this.captionButton,e=Pe.utils.hasClass(t,"active"),s=this.#rd._element;if(e)Pe.utils.removeItem(s.querySelector("caption"));else{const t=Pe.utils.createElement("CAPTION",{class:`se-table-caption-${this.#rd.captionPosition}`});t.innerHTML="

    ",s.insertBefore(t,s.firstElementChild)}Pe.utils.toggleClass(t,"active"),this.#rd._setCellControllerPosition(this.#I.tdElement,!1)}resetHeaderButton(t){t.querySelector("thead")?Pe.utils.addClass(this.headerButton,"active"):Pe.utils.removeClass(this.headerButton,"active")}resetCaptionButton(t){t.querySelector("caption")?Pe.utils.addClass(this.captionButton,"active"):Pe.utils.removeClass(this.captionButton,"active")}resetPropsAlign(){const{cell_alignment:t}=this.propTargets,e=t.querySelector('[data-value="left"]'),s=t.querySelector('[data-value="right"]'),i=e.parentElement,n=s.parentElement;i.appendChild(s),n.appendChild(e)}revertProps(){const t=this._propsCache;for(let e=0,s=t.length;enew Array(r-o+1).fill(0))),a=o;n-=e,e-=e,r-=o,o-=o;let h=t;for(let t,i,c,d,u,p=0,g=0,m=s.length,y=0;p1){const t=u-1;for(let e=y;e<=y+t;e++)l[e][c]+=d-(y===e?1:0)}else d>1&&(l[y][c]+=d-1)}catch{}const w=y+u-1===n;y===e&&$.top.push(t),(y===n||w)&&$.bottom.push(t),c===o&&$.left.push(t),c!==r&&c+d-1!==r||$.right.push(t),w||y===e||y===n||c===o||c===r||$.middle.push(t),i=t.style,i.textAlign=v,i.verticalAlign=b,i.backgroundColor=C,i.color=_,this.#Pd(i),k||(i.border=f?i.borderLeft=i.borderTop=i.borderRight=i.borderBottom="":x)}0===$.middle.length&&($.middle=s)}$.all=s,k&&this.#Dd($,p,x),this.#rd.historyPush(),this.controller_props.close(),this.#I.tdElement&&(this.#ld.recallStyleSelectedCells(),this.#rd.setCellInfo(this.#I.tdElement,!0),Pe.utils.addClass(this.#I.tdElement,"se-selected-cell-focus"))}catch(t){console.warn("[SUNEDITOR.plugins.table.setProps.error]",t)}finally{t.disabled=!1}}closeProps(){this.controller_props.close(),this.controller_colorPicker.close()}#Rd(t){this._typeCache=t;const e="table"===t,s=e?[this.#rd._element]:this.#I.selectedCells;if(!s?.[0])return;const{border_format:i,border_color:n,border_style:o,border_width:r,back_color:l,font_color:a,cell_alignment:h,cell_alignment_vertical:c,cell_alignment_table_text:d,font_bold:u,font_underline:p,font_italic:g,font_strike:m}=this.propTargets,{border:f,backgroundColor:v,color:b,textAlign:y,verticalAlign:w,fontWeight:C,textDecoration:_,fontStyle:k}=gh.getComputedStyle(s[0]),x=this.#Fd(f);h.querySelector('[data-value="justify"]').style.display=e?"none":"",d.style.display=e?"":"none",c.style.display=e?"none":"";let $=ze.rgb2hex(x.c),S=x.s,E=x.w,T=ze.rgb2hex(v),M=ze.rgb2hex(b),N=/.+/.test(C),B=/underline/i.test(_),I=/line-through/i.test(_),L=/italic/i.test(k),A=e?this.#I.figureElement?.style.float:y,O=w;this._propsCache=[];for(let t,i,n=0;t=s[n];n++){const{cssText:s,border:n,backgroundColor:o,color:r,textAlign:l,verticalAlign:a,fontWeight:h,textDecoration:c,fontStyle:d}=t.style;if(this._propsCache.push([t,s]),i)continue;const{c:u,s:p,w:g}=this.#Fd(n);let m=o,f=r;if(m||f){const e=gh.getComputedStyle(t);m&&(m=e.backgroundColor),f&&(f=e.color)}$&&x.c!==u&&($=""),S&&x.s!==p&&(S=""),E&&x.w!==g&&(E=""),T!==ze.rgb2hex(m)&&(T=""),M!==ze.rgb2hex(f)&&(M=""),A!==(e?this.#I.figureElement?.style.float:l)&&(A=""),O&&O!==a&&(O=""),N&&N!==/.+/.test(h)&&(N=!1),B&&B!==/underline/i.test(c)&&(B=!1),I&&I!==/line-through/i.test(c)&&(I=!1),L&&L!==/italic/i.test(d)&&(L=!1),$&&S&&E&&T&&M||(i=!0)}i.firstElementChild.innerHTML=this.#J.icons[Ha[1===s.length?"outside":"all"]],i.setAttribute("se-border-format","all"),Pe.utils.removeClass(i,"active"),S||=Fa[0],o.textContent=S,n.style.borderColor=n.value=$,r.value=E,this.#Hd(S===Fa[0]),l.value=l.style.borderColor=T,a.value=a.style.borderColor=M,N&&Pe.utils.addClass(u,"on"),B&&Pe.utils.addClass(p,"on"),I&&Pe.utils.addClass(m,"on"),L&&Pe.utils.addClass(g,"on"),this.#zd(h,this._propsAlignCache=A,!0),this.#zd(c,this._propsVerticalAlignCache=O,!0)}#Pd(t){const{font_bold:e,font_italic:s,font_strike:i,font_underline:n}=this.propTargets;t.fontWeight=Pe.utils.hasClass(e,"on")?"bold":"",t.fontStyle=Pe.utils.hasClass(s,"on")?"italic":"",t.textDecoration=((Pe.utils.hasClass(i,"on")?"line-through ":"")+(Pe.utils.hasClass(n,"on")?"underline":"")).trim()}#Fd(t){const e=t.split(/\s(?![^()]*\))/);let s="",i="",n="";return 3===e.length?(s=e[0],i=e[1],n=e[2]):2===e.length?/\d/.test(e[0])?(s=e[0],i=e[1]):(i=e[0],n=e[1]):1===e.length&&(/\d/.test(e[0])?s=e[0]:i=e[0]),{w:s,s:i,c:ze.rgb2hex(n)}}#Dd(t,e,s){const{left:i,top:n,right:o,bottom:r,all:l}=t;switch(e){case"inside":if(1===l.length)return;Pe.utils.setStyle(l.filter((t=>!r.includes(t))),ja,s),Pe.utils.setStyle(l.filter((t=>!o.includes(t))),Va,s);break;case"horizon":if(1===l.length)return;Pe.utils.setStyle(l.filter((t=>!r.includes(t))),ja,s);break;case"vertical":if(1===l.length)return;Pe.utils.setStyle(l.filter((t=>!o.includes(t))),Va,s);break;case"outside":Pe.utils.setStyle(i,Wa,s),Pe.utils.setStyle(n,Ua,s),Pe.utils.setStyle(o,Va,s),Pe.utils.setStyle(r,ja,s);break;case"left":Pe.utils.setStyle(i,Wa,s);break;case"top":Pe.utils.setStyle(n,Ua,s);break;case"right":Pe.utils.setStyle(o,Va,s);break;case"bottom":Pe.utils.setStyle(r,ja,s)}}#Hd(t){const{border_color:e,border_width:s,palette_border_button:i}=this.propTargets;t?(e.disabled=!0,s.disabled=!0,i.disabled=!0,s.disabled=!0):(e.disabled=!1,s.disabled=!1,i.disabled=!1,s.disabled=!1)}#zd(t,e,s){Pe.utils.removeClass(t.querySelectorAll("button"),"on"),s||t.getAttribute("se-cell-align")!==e?(Pe.utils.addClass(t.querySelector(`[data-value="${e}"]`),"on"),t.setAttribute("se-cell-align",e)):t.setAttribute("se-cell-align","")}#Ad(t){this.propTargets.border_style.textContent=t,this.#Hd(t===Fa[0]),this.selectMenu_props_border.close()}#Od(t,e){const{border_format:s}=this.propTargets;s.setAttribute("se-border-format",e),s.firstElementChild.innerHTML=this.#J.icons[Ha[e]],e!==t?Pe.utils.addClass(s,"active"):Pe.utils.removeClass(s,"active"),this.selectMenu_props_border_format.close(),this.selectMenu_props_border_format_oneCell.close()}init(){const{border_format:t,border_color:e,border_style:s,border_width:i,back_color:n,font_color:o,cell_alignment:r,cell_alignment_vertical:l,font_bold:a,font_underline:h,font_italic:c,font_strike:d}=this.propTargets;Pe.utils.removeClass([t,e,s,i,n,o,r,l,a,h,c,d],"on")}},{_w:fh,ON_OVER_COMPONENT:vh}=Oe;class bh extends Zl{static key="table";static className="";static options={isInputComponent:!0};static component(t){return Pe.check.isTable(t)?t:null}#qd;#Wd;#Ud;#Vd;#jd;#Gd=[];#Kd=!0;#Yd=!1;#Xd=!1;constructor(t,e){super(t),this.title=this.$.lang.table,this.icon="table",this.figureScrollList=["se-scroll-figure-xy","se-scroll-figure-x","se-scroll-figure-y"],this.figureScroll="string"==typeof e.scrollType?e.scrollType.toLowerCase():"x",this.captionPosition="bottom"!==e.captionPosition?"top":"bottom",this.cellControllerTop="table"==("cell"!==e.cellControllerPosition?"table":"cell");const s=Pe.utils.createElement("DIV",{class:"se-dropdown se-selector-table"},'\n\t
    \n\t\t
    \n\t\t
    \n\t\t
    \n\t
    \n\t
    1 x 1
    '),i=s.querySelector(".se-controller-table-picker"),n=function({lang:t,icons:e}){const s=`\n\t
    \n\t
    \n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t
    `;return Pe.utils.createElement("DIV",{class:"se-controller se-controller-table"},s)}(this.$),o=function({lang:t,icons:e},s){const i=`\n\t
    \n
    \n\t\t\n \n \n \n \n\t\t\n
    `,n=Pe.utils.createElement("DIV",{class:"se-controller se-controller-table-cell"},i);return{html:n,splitButton:n.querySelector('[data-command="onsplit"]'),columnButton:n.querySelector('[data-command="oncolumn"]'),rowButton:n.querySelector('[data-command="onrow"]'),mergeButton:n.querySelector('[data-command="merge"]'),unmergeButton:n.querySelector('[data-command="unmerge"]')}}(this.$,this.cellControllerTop);this.$.contextProvider.applyToRoots((t=>{t.get("wrapper").appendChild(Pe.utils.createElement("DIV",{class:Ra.replace(/^\./,"")})),t.get("wrapper").appendChild(Pe.utils.createElement("DIV",{class:za.replace(/^\./,"")})),t.get("wrapper").appendChild(Pe.utils.createElement("DIV",{class:Pa.replace(/^\./,"")})),t.get("wrapper").appendChild(Pe.utils.createElement("DIV",{class:Da.replace(/^\./,"")}))})),this.cellControllerTop?(this.controller_cell=new Ii(this,this.$,o.html,{position:"top"}),this.controller_table=new Ii(this,this.$,n,{position:"top"}),this.controller_cell.sibling=this.controller_table.form,this.controller_table.sibling=this.controller_cell.form,this.controller_table.siblingMain=!0):(this.controller_table=new Ii(this,this.$,n,{position:"top"}),this.controller_cell=new Ii(this,this.$,o.html,{position:"bottom"})),this.figure=new ji(this,this.$,null,{}),this._element=null,this.state=Ka,this.#qd=s,this.#Wd=s.querySelector(".se-table-size-highlighted"),this.#Ud=s.querySelector(".se-table-size-unhighlighted"),this.#Vd=s.querySelector(".se-table-size-display");const r=yh.bind(this,!0),l=yh.bind(this,!1),a={...o,openCellMenuFunc:r,closeCellMenuFunc:l};this.cellService=new ah(this,a),this.clipboardService=new hh(this),this.gridService=new ch(this,a),this.resizeService=new uh(this),this.selectionService=new ph(this),this.styleService=new mh(this,{pluginOptions:e,controller_table:n}),this.$.menu.initDropdownTarget(bh,s),this.$.eventManager.addEvent(i,"mousemove",this.#Zd.bind(this)),this.$.eventManager.addEvent(i,"click",this.#Jd.bind(this))}setState(t,e){this.state[t]=e}#Qd(){Object.assign(this.state,Ka)}off(){this.#tu()}componentSelect(t){if(this.#eu(t),this.state.figureElement||this.setTableInfo(t),this.#Kd="100%"===this.state.figureElement?.style.width,this.#Yd=Pe.utils.hasClass(t,"se-table-layout-fixed")||"fixed"===t.style.tableLayout,this.styleService.setTableLayout(this.#Kd?"width|column":"width",this.#Kd,this.#Yd,!0),_i.get("__overInfo")===vh)return;if(!this.state.tdElement)return;this.setCellInfo(this.state.tdElement,!0);const e=this.state.selectedCells?.length>1,s=Pe.query.getParentElement(t,Pe.check.isFigure);this.controller_table.open(s,null,{isWWTarget:!1,initMethod:null,addOffset:null,disabled:e}),this.state.fixedCell&&(this.cellService.setUnMergeButton(),this.controller_cell.open(this.state.tdElement,this.cellControllerTop?s:null,{isWWTarget:!1,initMethod:null,addOffset:null,disabled:e}))}componentDeselect(){this.resetInfo()}componentDestroy(t){if(!t)return;const e=t.parentNode;Pe.utils.removeItem(t),this._closeTableSelectInfo(),e!==this.$.frameContext.get("wysiwyg")&&this.$.nodeTransform.removeAllParents(e,(function(t){return 0===t.childNodes.length}),null),this.$.focusManager.focus(),this.$.history.push(!1)}componentCopy({event:t,cloneContainer:e}){const s=e.querySelectorAll(".se-selected-table-cell");Pe.utils.removeClass(s,"se-selected-table-cell|se-selected-cell-focus"),s.length>0&&(this.clipboardService.copySelectedTableCells(t,e,s),this.$.ui.showToast(this.$.lang.message_copy_success,550))}onPaste({event:t,doc:e}){const s=Pe.query.getParentElement(Pe.query.getEventTarget(t),Pe.check.isTableCell);if(!s)return;const i=e.body;if(1!==i.childElementCount)return;const n=this.$.component.get(i.firstElementChild);if(n?.pluginName!==bh.key)return;const o=n.target,r=this.clipboardService.pasteTableCellMatrix(o,s),{fixedCell:l,selectedCell:a}=this.selectionService.selectCells(r);return this.setState("selectedCells",r),this.setState("fixedCell",l),this.setState("selectedCell",a),this.setState("selectedTable",Pe.query.getParentElement(l,"TABLE")),!1}retainFormat(){return{query:"table",method:t=>{const e=t.querySelector("colgroup");let s=Pe.check.isFigure(t.parentNode)?t.parentNode:null;if(!e){const e=t.rows,s=function(t){const e=t.rows;let s=0;for(let t=0,i=e.length;t=s)break;n&&!i[r]&&(i[r]=n);for(let t=0;t=s||!n)continue;l[r+t]=!0;const e=De.get(n,-1);for(let t=0;t=s)continue;const l=i[o];if(null===l)i[o]=`width: ${n};`;else{const t=De.get(l.replace("width: ","").replace(";",""),-1);1===a&&e!==t&&(i[o]=`width: ${n};`)}}}r+=a}if(t===s)break}const n=[];for(let t=0;t`)}const o=Pe.utils.createElement("colgroup",null,n.join(""));t.insertBefore(o,t.firstElementChild);for(let t=0;te!==t)).join("|"))}else Pe.utils.removeClass(s,this.figureScrollList.join("|"))}}}setDir(){this.#tu(),this.styleService.resetPropsAlign()}onMouseMove({event:t}){if(this.resizeService.isResizing())return;const e=Pe.query.getEventTarget(t),s=Pe.query.getParentElement(e,Ja);s&&1!==t.buttons?!1!==this.resizeService.onResizeGuide(t,s)&&(this._element&&(this._element.style.cursor=""),this.resizeService.offResizeGuide()):this.resizeService.offResizeGuide()}onMouseDown({event:t}){this.setState("ref",null),this.setState("selectedCell",null);const e=Pe.query.getEventTarget(t);if(this._element&&Pe.query.getParentElement(e,Qa))return void this._closeController();const s=Pe.query.getParentElement(e,Ja);s&&(this.cellControllerTop||this.controller_cell.hide(),!1!==this.resizeService.readyResizeFromEdge(t,s)&&(this.state.isShiftPressed&&s!==this.state.fixedCell||(this.selectionService.deleteStyleSelectedCells(),/^TR$/i.test(s.nodeName)||(this.#Xd=!1,this.selectionService.startCellSelection(s,!1)))))}onMouseUp(){this.setState("isShiftPressed",!1)}onMouseLeave(){this.resizeService.offResizeGuide()}onKeyDown({event:t,range:e,line:s}){this.setState("ref",null);const i=t.code,n=Fe.isTab(i);if(this.$.ui.selectMenuOn||this.resizeService.isResizing()||!n&&this.#Xd||Fe.isCtrl(t))return;if(this.cellControllerTop||this.controller_cell.hide(),this.#Xd=Fe.isShift(t),n){this.selectionService.deleteStyleSelectedCells();const i=Pe.query.getParentElement(s,Pe.check.isTableCell);if(i&&e.collapsed&&Pe.check.isEdgePoint(e.startContainer,e.startOffset)){this._closeController();const e=this.#Xd;this.setState("isShiftPressed",this.#Xd=!1);const s=Pe.query.getParentElement(i,"table"),n=Pe.query.getListChildren(s,Pe.check.isTableCell,null),o=e?Pe.utils.prevIndex(n,i):Pe.utils.nextIndex(n,i);if(o===n.length&&!e){if(!Pe.query.getParentElement(i,"thead")){const t=s.rows,e=this.gridService.insertBodyRow(s,t.length,this.state.cellCnt).querySelector("td div");this.$.selection.setRange(e,0,e,0)}return t.preventDefault(),t.stopPropagation(),!1}if(-1===o&&e)return!1;const r=n[o];if(!r)return;const l=r.firstElementChild||r;return this.$.selection.setRange(l,0,l,0),t.preventDefault(),t.stopPropagation(),!1}}let o=null;if(!Fe.isShift(t)){if(o=Pe.query.getParentElement(s,Pe.check.isTableCell),!Pe.utils.hasClass(o,"se-selected-cell-focus"))return;return this.selectionService.deleteStyleSelectedCells(),this._editorEnable(!0),this.#su(),void this._closeController()}return this.state.isShiftPressed||this.state.ref?void 0:(o||=Pe.query.getParentElement(s,Pe.check.isTableCell),o?(this.#Xd=t.shiftKey,this.setState("fixedCell",o),this._closeController(),this.selectionService.startCellSelection(o,this.#Xd),!1):void 0)}onKeyUp({line:t}){this.#Xd=!1,this.state.isShiftPressed&&Pe.query.getParentElement(t,Pe.check.isTableCell)===this.state.fixedCell&&(this.selectionService.deleteStyleSelectedCells(),this._editorEnable(!0),this.#su()),this.setState("isShiftPressed",!1)}onScroll(){this.resizeService.offResizeGuide()}controllerAction(t){const e=t.getAttribute("data-command");if(e){switch(e){case"header":this.styleService.toggleHeader(),this.historyPush();break;case"caption":this.styleService.toggleCaption(),this.historyPush();break;case"onsplit":this.cellService.openSplitMenu();break;case"oncolumn":this.gridService.openColumnMenu();break;case"onrow":this.gridService.openRowMenu();break;case"openTableProperties":this.styleService.openTableProps(t);break;case"openCellProperties":this.styleService.openCellProps(t);break;case"revert":this.styleService.revertProps();break;case"merge":this.cellService.mergeCells(this.state.selectedCells);break;case"unmerge":this.cellService.unmergeCells(this.state.selectedCells);break;case"resize":this.#Kd=!this.#Kd,this.styleService.setTableLayout("width",this.#Kd,this.#Yd,!1),this.historyPush(),fh.setTimeout((()=>{this.$.component.select(this._element,bh.key,{isInput:!0})}),0);break;case"layout":this.#Yd=!this.#Yd,this.styleService.setTableLayout("column",this.#Kd,this.#Yd,!1),this.historyPush(),fh.setTimeout((()=>{this.$.component.select(this._element,bh.key,{isInput:!0})}),0);break;case"copy":this.$.component.copy(this.state.figureElement);break;case"remove":this.componentDestroy(this.state.figureElement)}/(^revert|Properties$)/.test(e)||this.styleService.closeProps(),/^(remove|on|open)/.test(e)||this._setCellControllerPosition(this.state.tdElement,this.state.isShiftPressed)}}setCellInfo(t,e){const s=this.setTableInfo(t);if(s&&(this.setState("fixedCell",t),this.setState("trElement",t.parentNode),this.styleService.resetHeaderButton(s),this.styleService.resetCaptionButton(s),e||0===this.state.physical_cellCnt)){this.state.tdElement!==t&&this.setState("tdElement",t),this.state.selectedCells?.length||this.setState("selectedCells",[t]);const e=s.rows;this.setState("trElements",e);const i=t.cellIndex;let n=0;for(let t=0,s=e[0].cells,i=e[0].cells.length;t8?10:e+2,o=s<5?5:s>8?10:s+2;if(this.#Ud.style.width=n+"em",this.#Ud.style.height=o+"em",i){const t=n-(this.#jd||5);if(0!==t){const e=De.get(this.#qd.style.left);this.#qd.style.left=e-18*t+"px",this.#jd=n}}Pe.utils.changeTxt(this.#Vd,e+" x "+s),this.#Gd=[e,s]}#Jd(){this.insert(this.#Gd[0],this.#Gd[1])}insert(t,e){const s=t>0?t:Oa[0],i=e>0?e:Oa[1],n=Pe.utils.createElement("TABLE"),o=`${`${sh("td",s)}`.repeat(i)}`,r=`${``.repeat(s)}`;n.innerHTML=r+o;let l="";this.figureScroll&&(l=` se-scroll-figure-${this.figureScroll}`);const a=Pe.utils.createElement("FIGURE",{class:"se-flex-component se-input-component"+l,style:"width: 100%;"});if(a.appendChild(n),this.#Kd=!0,!this.$.component.insert(a,{insertBehavior:"none"}))return!1;this.#tu(),this.$.menu.dropdownOff();const h=n.querySelector("td div");return this.$.selection.setRange(h,0,h,0),!0}#su(){this.resizeService.init(),this.selectionService.init(),this.styleService.init()}}function yh(t){this.controller_cell.bringToTop(t)}const wh=bh;class Ch extends Xl{static key="blockStyle";static className="se-btn-select se-btn-tool-format";constructor(t,e){super(t),this.title=this.$.lang.formats,this.inner=''+this.$.lang.formats+""+this.$.icons.arrow_down;const s=this.$.menu.initDropdownTarget(Ch,function({lang:t},e){const s=["p","blockquote","h1","h2","h3","h4","h5","h6"],i=e&&0!==e.length?e:s,n=[];for(let e,o,r,l,a,h,c,d=0,u=i.length;d${l}`,attrs:{"data-class":c||""}})}return n}(this.$,e.items),{className:"se-list-format"});this.formatList=s.querySelectorAll("li button"),this.currentFormat=""}active(t,e){let s=this.$.lang.formats;const i=e.querySelector(".se-txt");if(t){if(this.$.format.isLine(t)){const e=this.formatList,n=t.nodeName.toLowerCase(),o=(t.className.match(/(\s|^)__se__format__[^\s]+/)||[""])[0].trim();for(let t,i=0,r=e.length;i({command:"layout",value:String(e),title:t.name,innerHTML:t.name})))}(this.items))}action(t){const e=Number(t.getAttribute("data-value")),s=this.items[this.selectedIndex=e];if(!s.html)throw this.$.menu.dropdownOff(),Error('[SUNEDITOR.layout.fail] cause : "layouts[i].html not found"');this.$.html.set(s.html),this.$.menu.dropdownOff()}}const xh=kh;class $h extends Xl{static key="lineHeight";static className="";#nd;constructor(t,e){super(t),this.title=this.$.lang.lineHeight,this.icon="line_height";const s=`
  • `,i=this.$.menu.initDropdownTarget($h,(e.items||[{text:"1",value:"1em"},{text:"1.2",value:"1.2em"},{text:"1.7",value:"1.7em"},{text:"2",value:"2em"}]).map((t=>({command:t.value,title:t.text,innerHTML:t.text}))),{prependHTML:s});this.sizeList=i.querySelectorAll("li button"),this.currentSize=null,this.#nd=i.querySelector(".se-sub-list span")}active(t,e){return this.$.format.isLine(t)&&t.style.lineHeight.length>0?(Pe.utils.addClass(e,"active"),!0):(Pe.utils.removeClass(e,"active"),!1)}on(){const t=this.$.format.getLine(this.$.selection.getNode()),e=t?t.style.lineHeight+"":"";if(e!==this.currentSize){let t=!1;const s=this.sizeList;for(let i=0,n=s.length;i({command:"template",value:String(e),title:t.name,innerHTML:t.name})))}(this.items))}action(t){const e=Number(t.getAttribute("data-value")),s=this.items[this.selectedIndex=e];if(!s.html)throw this.$.menu.dropdownOff(),Error('[SUNEDITOR.template.fail] cause : "templates[i].html not found"');this.$.html.insert(s.html,{selectInserted:!1,skipCharCount:!1,skipCleaning:!1}),this.$.menu.dropdownOff()}}const Th=Eh;class Mh extends Xl{static key="paragraphStyle";static className="";constructor(t,e){super(t),this.title=this.$.lang.paragraphStyle,this.icon="paragraph_style";const s=this.$.menu.initDropdownTarget(Mh,function({lang:t},e){const s={spaced:{name:t.menu_spaced,class:"__se__p-spaced",_class:""},bordered:{name:t.menu_bordered,class:"__se__p-bordered",_class:""},neon:{name:t.menu_neon,class:"__se__p-neon",_class:""}},i=e&&0!==e.length?e:["spaced","bordered","neon"],n=[];for(let t,e,o,r=0,l=i.length;r${e}`,className:t._class||void 0})}return n}(this.$,e.items),{className:"se-list-format"});this.classList=s.querySelectorAll("li button")}on(){const t=this.classList,e=this.$.format.getLine(this.$.selection.getNode());for(let s=0,i=t.length;s${o}`})}return n}(this.$,e.items),{className:"se-list-format"});this.styleList=s.querySelectorAll("li button")}on(){const t=this.styleList,e=this.$.selection.getNode();for(let s,i,n,o=0,r=t.length;o\n\t\t
    \n\t\t\t\n\t\t\t${t.link_modal_title}\n\t\t
    \n\t\t
    \n\t\t\n\t`;return Pe.utils.createElement("DIV",{class:"se-modal-content"},s)}(this.$),i=function({lang:t,icons:e}){const s=`\n\t
    \n\t`;return Pe.utils.createElement("DIV",{class:"se-controller se-controller-link"},s)}(this.$),n="string"==typeof e.uploadUrl?e.uploadUrl:null;this.target=null,this.isUpdateState=!1,this.pluginOptions={...e,uploadUrl:n,uploadHeaders:e.uploadHeaders||null,uploadSizeLimit:De.get(e.uploadSizeLimit,0),uploadSingleSizeLimit:De.get(e.uploadSingleSizeLimit,0),acceptedFormats:"string"==typeof e.acceptedFormats?e.acceptedFormats.trim():null,enableFileUpload:!!n},this.anchor=new Vl(this.$,s,this.pluginOptions),this.modal=new Fl(this,this.$,s),this.controller=new Ii(this,this.$,i,{position:"bottom",disabled:!1}),this.#iu=this.controller.form.querySelector("a")}active(t){if(Pe.check.isAnchor(t)&&!t.hasAttribute("data-se-non-link")){const e=this.#iu,s=t.getAttribute("href");return e.href=s,e.textContent=e.title=t.textContent,e.target=s?.startsWith("#")?t.target:"_blank",Pe.utils.addClass(t,"on"),this.anchor.set(t),this.controller.open(t,null,{isWWTarget:!1,initMethod:null,addOffset:null}),this.target=t,!0}return this.controller.close(),!1}open(){this.modal.open()}modalOn(t){this.isUpdateState=t,this.anchor.on(t)}async modalAction(){const t=this.anchor.create(!1);if(null===t)return!1;if(this.isUpdateState){const t=this.controller.currentTarget.childNodes[0];this.$.selection.setRange(t,0,t,t.textContent.length)}else{const e=this.$.format.getLines();if(e.length>1){if(!this.$.html.insertNode(Pe.utils.createElement(e[0].nodeName,null,t),{afterNode:null,skipCharCount:!1}))return!0}else if(!this.$.html.insertNode(t,{afterNode:null,skipCharCount:!1}))return!0;this.$.selection.setRange(t.childNodes[0],0,t.childNodes[0],t.textContent.length)}return this.$.history.push(!1),!0}modalInit(){this.controller.close(),this.anchor.init()}controllerAction(t){const e=t.getAttribute("data-command");if(/update/.test(e))this.modal.open();else if(/copy/.test(e))this.$.html.copy(this.target);else if(/unlink/.test(e)){const t=Pe.query.getEdgeChild(this.controller.currentTarget,(function(t){return 0===t.childNodes.length||3===t.nodeType}),!1),e=Pe.query.getEdgeChild(this.controller.currentTarget,(function(t){return 0===t.childNodes.length||3===t.nodeType}),!0);this.$.selection.setRange(t,0,e,e.textContent.length),this.$.inline.apply(null,{stylesToModify:null,nodesToRemove:["A"],strictRemove:!1})}else Pe.utils.removeItem(this.controller.currentTarget),this.controller.currentTarget=null,this.$.focusManager.focus(),this.$.history.push(!1)}controllerClose(){Pe.utils.removeClass(this.controller.currentTarget,"on")}},Ah="%",Oh="px",Rh={BLOCK:"block",INLINE:"inline"},zh="image/*";const Ph=class{#rd;#J;#I;#nu;#ud;#ou;#ru;#lu={w:0,h:0};#au=null;#hu=null;#cu=null;constructor(t,e){if(this.#rd=t,this.#J=t.$,this.#I=t.state,this.#nu=t.pluginOptions,this.#ud=this.#nu.canResize,this.#ou="auto"===this.#nu.defaultWidth?"":this.#nu.defaultWidth,this.#ru="auto"===this.#nu.defaultHeight?"":this.#nu.defaultHeight,this.#ud){this.#au=e.proportion,this.#hu=e.inputX,this.#cu=e.inputY,this.#hu.value=this.#nu.defaultWidth,this.#cu.value=this.#nu.defaultHeight;const t=this.#du.bind(this);this.#J.eventManager.addEvent(this.#hu,"keyup",this.#uu.bind(this,"x")),this.#J.eventManager.addEvent(this.#cu,"keyup",this.#uu.bind(this,"y")),this.#J.eventManager.addEvent(this.#hu,"change",t),this.#J.eventManager.addEvent(this.#cu,"change",t),this.#J.eventManager.addEvent(this.#au,"change",t),this.#J.eventManager.addEvent(e.revertBtn,"click",this.#pu.bind(this))}}setInputSize(t,e){this.#hu.value="auto"===t?"":t,this.#I.onlyPercentage||(this.#cu.value="auto"===e?"":e)}getInputSize(){return{w:this.#hu?.value||"",h:this.#cu?.value||""}}setOriginSize(t,e){this.#ou=t,this.#ru=e}applySize(t,e){t||=this.#hu?.value||this.#nu.defaultWidth,e||=this.#cu?.value||this.#nu.defaultHeight,this.#I.onlyPercentage&&(t?/%$/.test(t)||(t+=Ah):t="100%"),this.#rd.figure.setSize(t,e)}on(){if(!this.#ud)return;const t=this.#nu.defaultWidth,e=this.#nu.defaultHeight;this.setInputSize(t,e),this.setOriginSize(t,e)}ready(t,e,s){this.setInputSize(e,s);const i=this.#I.onlyPercentage&&this.#rd.figure.isVertical;this.#au.checked=!0,this.#hu.disabled=i,this.#cu.disabled=i,this.#au.disabled=i,this.#lu=this.#au.checked?t.ratio:{w:0,h:0}}init(){this.#lu={w:0,h:0},this.#ud&&(this.setInputSize(this.#nu.defaultWidth,this.#nu.defaultHeight),this.#au.checked=!0)}#uu(t,e){if(Fe.isSpace(e.code))return void e.preventDefault();const s=e.target;if("x"===t&&this.#I.onlyPercentage&&Number(s.value)>100)s.value="100";else if(this.#au.checked){const e=ji.CalcRatio(this.#hu.value,this.#cu.value,this.#I.sizeUnit,this.#lu);"x"===t?this.#cu.value=String(e.h):this.#hu.value=String(e.w)}}#du(){this.#lu=this.#au.checked?ji.GetRatio(this.#hu.value,this.#cu.value,this.#I.sizeUnit):{w:0,h:0}}#pu(){this.#I.onlyPercentage?this.#hu.value=Number(this.#ou)>100?"100":this.#ou:(this.#hu.value=this.#ou,this.#cu.value=this.#ru)}},{NO_EVENT:Dh}=Oe;const Fh=class{#rd;#J;#nu;#ud;constructor(t){this.#rd=t,this.#J=t.$,this.#nu=t.pluginOptions,this.#ud=this.#nu.canResize,this._base64RenderIndex=0}get#gu(){return this.#rd.sizeService}serverUpload(t){if(!t.files)return;const e=this.#nu.uploadUrl;"string"==typeof e&&e.length>0?this.#rd.fileManager.upload(e,this.#nu.uploadHeaders,t.files,this.#mu.bind(this,t),this.#gc.bind(this)):this.#fu(t)}urlUpload(t){this.#rd.setState("produceIndex",0);const e=t.url;this.#rd.modal.isUpdate?this.#vu(e,t.element,t.files):this.#bu(e,t.anchor,t.inputWidth,t.inputHeight,t.align,t.files,t.alt,!0)}#bu(t,e,s,i,n,o,r,l){this.#rd.as!==Rh.INLINE?this.#rd.create(t,e,s,i,n,o,r,l):this.#rd.createInline(t,e,s,i,o,r,l)}#vu(t,e,s){e.src=t,this.#rd.fileManager.setFileData(e,s),this.#J.component.select(e,this.#rd.constructor.key)}#pc(t,e){this.#rd.setState("produceIndex",0);const s=e.result;for(let e,i=0,n=s.length;i\n\t\t\t\n\t\t\t${Fl.CreateFileInput({icons:e,lang:t},i)}\n\t\t`:"",o=i.createUrlInput?`\n\t\t
    \n\t\t\t\n\t\t\t
    \n\t\t\t\t\n\t\t\t\t${s.imageGallery?``:""}\n\t\t\t
    \n\t\t\t\n\t\t
    `:"",r=i.canResize?`\n\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t
    `:"",l=i.useFormatType?`\n\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    `:"",a=`\n\t\t
    \n\t\t\t\n\t\t\t${t.image_modal_title}\n\t\t
    \n\t\t
    \n\t\t\t\n\t\t\t\n\t\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t${n}\n\t\t\t\t\t${o}\n\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t
    \n\t\t\t\t\t${r}\n\t\t\t\t\t${l}\n\t\t\t\t\t\n\t\t\t\t
    \n\t\t\t
    \n\t\t\t\n\t\t\t\n\t\t
    `,h=Pe.utils.createElement("DIV",{class:"se-modal-content"},a);return{html:h,alignForm:h.querySelector(".se-figure-align"),fileModalWrapper:h.querySelector(".se-flex-input-wrapper"),imgInputFile:h.querySelector(".__se__file_input"),imgUrlFile:h.querySelector(".se-input-url"),altText:h.querySelector("._se_image_alt"),captionCheckEl:h.querySelector("._se_image_check_caption"),previewSrc:h.querySelector("._se_tab_content_image .se-link-preview"),tabs:h.querySelector(".se-modal-tabs"),galleryButton:h.querySelector(".__se__gallery"),proportion:h.querySelector("._se_check_proportion"),inputX:h.querySelector("._se_size_x"),inputY:h.querySelector("._se_size_y"),revertBtn:h.querySelector(".se-modal-btn-revert"),asBlock:h.querySelector('[data-command="asBlock"]'),asInline:h.querySelector('[data-command="asInline"]'),fileRemoveBtn:h.querySelector(".se-file-remove")}}(this.$,this.pluginOptions),n=this.pluginOptions.useFormatType?"as":"",o=e.controls||(this.pluginOptions.canResize?[[n,"resize_auto,100,75,50","rotate_l","rotate_r","mirror_h","mirror_v"],["edit","align","caption","revert","copy","remove"]]:[[n,"mirror_h","mirror_v","align","caption","edit","revert","copy","remove"]]);this.alignForm=i.alignForm,o.some((t=>t.includes("align")))||(this.alignForm.style.display="none");const r=this.$.plugins.link?this.$.plugins.link.pluginOptions:{};this.anchor=new Vl(this.$,i.html,{...r,textToDisplay:!1,title:!0}),this.modal=new Fl(this,this.$,i.html),this.figure=new ji(this,this.$,o,{sizeUnit:s}),this.fileManager=new ql(this,this.$,{query:"img",loadEventName:"onImageLoad",actionEventName:"onImageAction"}),this.state={sizeUnit:s,onlyPercentage:this.pluginOptions.percentageOnlySize,produceIndex:0},this.fileModalWrapper=i.fileModalWrapper,this.imgInputFile=i.imgInputFile,this.imgUrlFile=i.imgUrlFile,this.focusElement=this.imgInputFile||this.imgUrlFile,this.altText=i.altText,this.captionCheckEl=i.captionCheckEl,this.captionEl=this.captionCheckEl?.parentElement,this.previewSrc=i.previewSrc,this.as=Rh.BLOCK,this.#ud=this.pluginOptions.canResize,this.#wu=!this.#ud||!this.pluginOptions.showHeightInput||this.pluginOptions.percentageOnlySize,this.sizeService=new Ph(this,i),this.uploadService=new Fh(this),this.$.eventManager.addEvent(i.tabs,"click",this.#Tu.bind(this)),this.imgInputFile&&this.$.eventManager.addEvent(i.fileRemoveBtn,"click",this.#Mu.bind(this)),this.imgUrlFile&&this.$.eventManager.addEvent(this.imgUrlFile,"input",this.#Nu.bind(this)),this.imgInputFile&&this.imgUrlFile&&this.$.eventManager.addEvent(this.imgInputFile,"change",this.#Bu.bind(this));const l=i.galleryButton;l&&this.$.eventManager.addEvent(l,"click",this.#Iu.bind(this)),this.pluginOptions.useFormatType&&(this.as=this.pluginOptions.defaultFormatType,this.asBlock=i.asBlock,this.asInline=i.asInline,this.$.eventManager.addEvent([this.asBlock,this.asInline],"click",this.#Lu.bind(this)))}setState(t,e){this.state[t]=e}open(){this.state.produceIndex=0,this.modal.open()}retainFormat(){return{query:"img",method:t=>{const e=ji.GetContainer(t);if(e&&e.container&&(e.cover||e.inlineCover))return;const{w:s,h:i}=this.#Au(t,!0);this.#Ou(s,i)}}}onFilePasteAndDrop({file:t}){/^image/.test(t.type)&&(this.submitFile([t]),this.$.focusManager.focus())}modalOn(t){t?this.imgInputFile&&this.pluginOptions.allowMultiple&&this.imgInputFile.removeAttribute("multiple"):(this.sizeService.on(),this.imgInputFile&&this.pluginOptions.allowMultiple&&this.imgInputFile.setAttribute("multiple","multiple")),this.anchor.on(t)}async modalAction(){return this.#ku=this.modal.form.querySelector('input[name="suneditor_image_radio"]:checked').value,this.modal.isUpdate&&(this.#Ru(),this.$.history.push(!1)),this.imgInputFile&&this.imgInputFile.files.length>0?await this.submitFile(this.imgInputFile.files):!!(this.imgUrlFile&&this.#_u.length>0)&&await this.submitURL(this.#_u)}modalInit(){Fl.OnChangeFile(this.fileModalWrapper,[]),this.imgInputFile&&(this.imgInputFile.value=""),this.imgUrlFile&&(this.#_u=this.previewSrc.textContent=this.imgUrlFile.value=""),this.imgInputFile&&this.imgUrlFile&&(this.imgUrlFile.disabled=!1,this.previewSrc.style.textDecoration=""),this.altText.value="",this.modal.form.querySelector('input[name="suneditor_image_radio"][value="none"]').checked=!0,this.captionCheckEl.checked=!1,this.#Pc=null,this.#Tu("init"),this.sizeService.init(),this.pluginOptions.useFormatType&&this.#zu((this.pluginOptions.keepFormatType?this.as:this.pluginOptions.defaultFormatType)===Rh.INLINE),this.anchor.init()}componentSelect(t){this.#Au(t)}componentEdit(){this.modal.open()}async componentDestroy(t){const e=t||this.#Pc,s=Pe.query.getParentElement(e,ji.is)||e,i=s.previousElementSibling||s.nextElementSibling,n=s.parentNode;!1!==await this.$.eventManager.triggerEvent("onImageDeleteBefore",{element:e,container:s,align:this.#ku,alt:this.altText.value,url:this.#_u})&&(Pe.utils.removeItem(s),this.modalInit(),n!==this.$.frameContext.get("wysiwyg")&&this.$.nodeTransform.removeAllParents(n,(function(t){return 0===t.childNodes.length}),null),this.$.focusManager.focusEdge(i),this.$.history.push(!1))}async submitFile(t){if(0===t.length)return!1;let e=0;const s=[],i=this.pluginOptions.uploadSingleSizeLimit;for(let n,o,r=0,l=t.length;r0&&o>i){const t="[SUNEDITOR.imageUpload.fail] Size of uploadable single file: "+i/1e3+"KB",e=await this.$.eventManager.triggerEvent("onImageUploadError",{error:t,limitSize:i,uploadSize:o,file:n});return this.$.ui.alertOpen(e===Hh?t:e||t,"error"),!1}s.push(n),e+=o}const n=this.pluginOptions.uploadSizeLimit,o=this.fileManager.getSize();if(n>0&&e+o>n){const t="[SUNEDITOR.imageUpload.fail] Size of uploadable total images: "+n/1e3+"KB",s=await this.$.eventManager.triggerEvent("onImageUploadError",{error:t,limitSize:n,currentSize:o,uploadSize:e});return this.$.ui.alertOpen(s===Hh?t:s||t,"error"),!1}const r={files:s,...this.#Pu()},l=function(t,e,s){t(e=s||e)}.bind(this,this.uploadService.serverUpload.bind(this.uploadService),r),a=await this.$.eventManager.triggerEvent("onImageUploadBefore",{info:r,handler:l});return void 0===a||!1!==a&&(null!==a&&"object"==typeof a&&l(a),void(!0!==a&&a!==Hh||l(null)))}async submitURL(t){if(!(t||=this.#_u))return!1;const e={name:t.split("/").pop(),size:0},s={url:t,files:e,...this.#Pu()},i=function(t,e,s){t(e=s||e)}.bind(this,this.uploadService.urlUpload.bind(this.uploadService),s),n=await this.$.eventManager.triggerEvent("onImageUploadBefore",{info:s,handler:i});return void 0===n||!1!==n&&(null!==n&&"object"==typeof n&&i(n),!0!==n&&n!==Hh||i(null),!0)}create(t,e,s,i,n,o,r,l){const a=Pe.utils.createElement("IMG");a.src=t,a.alt=r,e=this.#Du(a,e?e.cloneNode(!1):null);const h=ji.CreateContainer(e,"se-image-container"),c=h.cover,d=h.container;this.captionCheckEl.checked&&(this.#Eu=ji.CreateCaption(c,this.$.lang.caption)),this.#Pc=a,this.#$u=c,this.#Su=d,this.figure.open(a,{nonResizing:this.#wu,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:!0}),this.sizeService.applySize(s,i),this.figure.setAlign(a,n),this.fileManager.setFileData(a,o),this.setState("produceIndex",this.state.produceIndex+1),a.onload=this.#Fu.bind(this,a,this.#xu,d),this.$.component.insert(d,{scrollTo:!!l,insertBehavior:l?null:"line"})}createInline(t,e,s,i,n,o,r){const l=Pe.utils.createElement("IMG");l.src=t,l.alt=o,e=this.#Du(l,e?e.cloneNode(!1):null);const a=ji.CreateInlineContainer(e,"se-image-container").container;this.#Pc=l,this.#Su=a,this.figure.open(l,{nonResizing:this.#wu,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:!0}),this.sizeService.applySize(s,i),this.fileManager.setFileData(l,n),this.setState("produceIndex",this.state.produceIndex+1),l.onload=this.#Fu.bind(this,l,this.#xu,a),this.$.component.insert(a,{scrollTo:!!r,insertBehavior:r?null:"line"})}#Au(t,e=!1){if(!t)return;const s=this.figure.open(t,{nonResizing:this.#wu,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:e});this.anchor.set(Pe.check.isAnchor(t.parentNode)?t.parentNode:null),this.#Cu=this.anchor.currentTarget,this.#Pc=t,this.#$u=s.cover,this.#Su=s.container,this.#Eu=s.caption,this.#ku=s.align,t.style.float="",this.sizeService.setOriginSize(String(s.originWidth||s.w||""),String(s.originHeight||s.h||"")),this.altText.value=this.#Pc.alt,this.imgUrlFile&&(this.#_u=this.previewSrc.textContent=this.imgUrlFile.value=this.#Pc.src);(this.modal.form.querySelector('input[name="suneditor_image_radio"][value="'+this.#ku+'"]')||this.modal.form.querySelector('input[name="suneditor_image_radio"][value="none"]')).checked=!0,this.captionCheckEl.checked=!!this.#Eu;const{dw:i,dh:n}=this.figure.getSize(t);return this.#ud?(this.sizeService.ready(s,i,n),this.pluginOptions.useFormatType&&this.#zu(this.$.component.isInline(s.container)),{w:i,h:n}):{w:i,h:n}}#Pu(){const{w:t,h:e}=this.sizeService.getInputSize();return{element:this.#Pc,anchor:this.anchor.create(!0),inputWidth:t,inputHeight:e,align:this.#ku,isUpdate:this.modal.isUpdate,alt:this.altText.value}}#zu(t){t?(Pe.utils.addClass(this.asInline,"on"),Pe.utils.removeClass(this.asBlock,"on"),this.as=Rh.INLINE,this.alignForm&&(this.alignForm.style.display="none"),this.captionEl&&(this.captionEl.style.display="none")):(Pe.utils.addClass(this.asBlock,"on"),Pe.utils.removeClass(this.asInline,"on"),this.as=Rh.BLOCK,this.alignForm&&(this.alignForm.style.display=""),this.captionEl&&(this.captionEl.style.display=""))}#Ru(){const{w:t,h:e}=this.sizeService.getInputSize(),s=t||"auto",i=e||"auto";let n=this.#Pc;(this.as===Rh.BLOCK&&!this.#$u||this.as===Rh.INLINE&&this.#$u)&&(n=this.figure.convertAsFormat(n,this.as));const o=this.#$u,r=this.#Su===this.#$u?null:this.#Su;let l;const a=De.is(s)?s+this.state.sizeUnit:s,h=De.is(i)?i+this.state.sizeUnit:i;l=/%$/.test(n.style.width)?a!==r.style.width||h!==r.style.height:a!==n.style.width||h!==n.style.height,n.alt=this.altText.value;let c=!1;this.captionCheckEl.checked?this.#Eu||(this.#Eu=ji.CreateCaption(o,this.$.lang.caption),c=!0):this.#Eu&&(Pe.utils.removeItem(this.#Eu),this.#Eu=null,c=!0);let d=!1;const u=this.anchor.create(!0);if(u)this.#Cu===u&&r.contains(u)||(this.#Cu=u.cloneNode(!1),o.insertBefore(this.#Du(n,this.#Cu),this.#Eu),d=!0);else if(null!==this.#Cu&&o.contains(this.#Cu)){const t=n.cloneNode(!0);o.removeChild(this.#Cu),o.insertBefore(t,this.#Eu),n=t}d&&Pe.utils.removeItem(u),this.#ud&&l&&this.sizeService.applySize(s,i),(c||!this.state.onlyPercentage&&l)&&(/\d+/.test(n.style.height)||this.figure.isVertical&&this.captionCheckEl.checked)&&(/auto|%$/.test(s)||/auto|%$/.test(i)?this.figure.deleteTransform(n):this.#ud&&l&&this.figure.isVertical||this.figure.setTransform(n,s,i,0)),this.figure.setAlign(n,this.#ku),n.onload=()=>{this.componentSelect(n)}}#Ou(t,e){const{w:s,h:i}=this.sizeService.getInputSize();t||=s||"auto",e||=i||"auto";let n=this.#Pc,o=this.#$u,r=null,l=this.#Su===this.#$u?null:this.#Su,a=!1;if(!o||!l){a=!0,n=this.#Pc.cloneNode(!0);const e=this.pluginOptions.useFormatType&&"auto"!==t&&(/^span$/i.test(this.#Pc.parentElement?.nodeName)||this.$.format.isLine(this.#Pc.parentElement))?ji.CreateInlineContainer(n,"se-image-container"):ji.CreateContainer(n,"se-image-container");o=e.cover,l=e.container,r=e.inlineCover,this.figure.open(n,{nonResizing:!0,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:!0})}n.alt=this.altText.value;let h=!1;r||(this.captionCheckEl.checked?this.#Eu&&!a||(this.#Eu=ji.CreateCaption(o,this.$.lang.caption),h=!0):this.#Eu&&(Pe.utils.removeItem(this.#Eu),this.#Eu=null,h=!0));let c=null;const d=this.anchor.create(!0,Pe.check.isAnchor(this.#Pc.parentElement)?this.#Pc.parentElement.href:null);if(d)(this.#Cu!==d||a&&!l.contains(d))&&(this.#Cu=d.cloneNode(!1),o.insertBefore(this.#Du(n,this.#Cu),this.#Eu),c=this.#Pc);else if(null!==this.#Cu&&o.contains(this.#Cu)){const t=n.cloneNode(!0);o.removeChild(this.#Cu),o.insertBefore(t,this.#Eu),n=t}a&&(n=this.#Pc,this.figure.retainFigureFormat(l,this.#Pc,c?d:null,this.fileManager),this.#Pc=n=l.querySelector("img"),this.#$u=o,this.#Su=l),n.style.width="",n.style.height="",n.removeAttribute("width"),n.removeAttribute("height"),this.sizeService.applySize(t,e),c&&(a?(Pe.utils.removeItem(c),0===Pe.query.getListChildren(d,(t=>/IMG/i.test(t.tagName)),null).length&&Pe.utils.removeItem(d)):Pe.utils.removeItem(d)),!h&&this.state.onlyPercentage||(/\d+/.test(n.style.height)||this.figure.isVertical&&this.captionCheckEl.checked)&&(/auto|%$/.test(t)||/auto|%$/.test(e)?this.figure.deleteTransform(n):this.figure.setTransform(n,t,e,0)),this.figure.setAlign(n,this.#ku)}#Du(t,e){return e?(e.setAttribute("data-se-non-link","true"),e.appendChild(t),e):t}#Tu(t){const e=this.modal.form,s="string"==typeof t?e.querySelector("._se_tab_link"):Pe.query.getEventTarget(t);if(!/^BUTTON$/i.test(s.tagName))return!1;const i=s.getAttribute("data-tab-link");let n;const o=e.getElementsByClassName("_se_tab_content");for(n=0;n100?"100":this.#ou:(this.#hu.value=this.#ou,this.#cu.value=this.#ru)}#Gu(t){if(!this.frameRatioOption)return;let e=!1;const s=this.frameRatioOption.options;/%$/.test(t+"")||this.#I.onlyPercentage?t=De.get(t,2)/100+"":(!De.is(t)||Number(t)>=1)&&(t=""),this.#cu.placeholder="";for(let i=0,n=s.length;i100)s.value="100";else if(this.#au.checked&&!this.frameRatioOption?.value){const e=ji.CalcRatio(this.#hu.value,this.#cu.value,this.#I.sizeUnit,this.#lu);"x"===t?this.#cu.value=String(e.h):this.#hu.value=String(e.w)}"y"===t&&this.#Gu(s.value||this.#I.defaultRatio)}},{NO_EVENT:Uh}=Oe;const Vh=class{#rd;#J;#nu;constructor(t){this.#rd=t,this.#J=t.$,this.#nu=t.pluginOptions}serverUpload(t,e){if(!e)return;const s=this.#nu.uploadUrl;"string"==typeof s&&s.length>0&&this.#rd.fileManager.upload(s,this.#nu.uploadHeaders,e,this.#mu.bind(this,t),this.#gc.bind(this))}#pc(t,e){const s=e.result,i=this.#rd.createVideoTag();for(let e=0,n=s.length;et.endsWith(e)))&&!this.#Xu.some((e=>e.test(t))))}static#Yu=[".mp4",".avi",".mov",".webm",".flv",".mkv",".m4v",".ogv"];static#Xu=[/youtu\.?be/,/vimeo\.com\//,/dailymotion\.com\/video\//,/facebook\.com\/.+\/videos\//,/facebook\.com\/watch\/\?v=/,/twitter\.com\/.+\/status\//,/twitch\.tv\/videos\//,/twitch\.tv\/[^/]+$/,/tiktok\.com\/@[^/]+\/video\//,/instagram\.com\/p\//,/instagram\.com\/tv\//,/instagram\.com\/reel\//,/linkedin\.com\/posts\//,/\.(wistia\.com|wi\.st)\/(medias|embed)\//,/loom\.com\/share\//];#ud;#wu;#_u="";#ku="none";#Pc=null;#Su=null;constructor(t,e){super(t),this.title=this.$.lang.video,this.icon="video",this.pluginOptions={canResize:void 0===e.canResize||e.canResize,showHeightInput:void 0===e.showHeightInput||!!e.showHeightInput,defaultWidth:e.defaultWidth&&De.get(e.defaultWidth,0)?De.is(e.defaultWidth)?e.defaultWidth+"px":e.defaultWidth:"",defaultHeight:e.defaultHeight&&De.get(e.defaultHeight,0)?De.is(e.defaultHeight)?e.defaultHeight+"px":e.defaultHeight:"",percentageOnlySize:!!e.percentageOnlySize,createFileInput:!!e.createFileInput,createUrlInput:void 0===e.createUrlInput||!e.createFileInput||e.createUrlInput,uploadUrl:"string"==typeof e.uploadUrl?e.uploadUrl:null,uploadHeaders:e.uploadHeaders||null,uploadSizeLimit:De.get(e.uploadSizeLimit,0),uploadSingleSizeLimit:De.get(e.uploadSingleSizeLimit,0),allowMultiple:!!e.allowMultiple,acceptedFormats:"string"!=typeof e.acceptedFormats||"*"===e.acceptedFormats.trim()?"video/*":e.acceptedFormats.trim()||"video/*",defaultRatio:De.get(e.defaultRatio,4)||.5625,showRatioOption:void 0===e.showRatioOption||!!e.showRatioOption,ratioOptions:e.ratioOptions?e.ratioOptions:null,videoTagAttributes:e.videoTagAttributes||null,iframeTagAttributes:e.iframeTagAttributes||null,query_youtube:e.query_youtube||"",query_vimeo:e.query_vimeo||"",insertBehavior:e.insertBehavior};const s=this.pluginOptions.percentageOnlySize?"%":"px",i=function({lang:t,icons:e,plugins:s},i){let n=`\n\t
    \n\t\t
    \n\t\t\t\n\t\t\t${t.video_modal_title}\n\t\t
    \n\t\t
    `;if(i.createFileInput&&(n+=`\n\t\t\t
    \n\t\t\t\t\n\t\t\t\t${Fl.CreateFileInput({lang:t,icons:e},i)}\n\t\t\t
    `),i.createUrlInput&&(n+=`\n\t\t\t
    \n\t\t\t\t\n\t\t\t\t
    \n\t\t\t\t\t\n\t\t\t\t\t${s.videoGallery?``:""}\n\t\t\t\t
    \n\t\t\t\t\n\t\t\t
    `),i.canResize){const s=i.ratioOptions||[{name:"16:9",value:.5625},{name:"4:3",value:.75},{name:"21:9",value:.4285},{name:"9:16",value:1.78}],o=i.defaultRatio,r=i.percentageOnlySize,l=r?' style="display: none !important;"':"",a=i.showHeightInput?"":' style="display: none !important;"',h=i.showRatioOption?"":' style="display: none !important;"',c=r||i.showHeightInput||i.showRatioOption?"":' style="display: none !important;"';n+=`\n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t\t`}n+=`\n\t\t
    \n\t\t\n\t
    `;const o=Pe.utils.createElement("DIV",{class:"se-modal-content"},n);return{html:o,alignForm:o.querySelector(".se-figure-align"),fileModalWrapper:o.querySelector(".se-flex-input-wrapper"),videoInputFile:o.querySelector(".__se__file_input"),videoUrlFile:o.querySelector(".se-input-url"),previewSrc:o.querySelector(".se-link-preview"),galleryButton:o.querySelector(".__se__gallery"),proportion:o.querySelector("._se_check_proportion"),frameRatioOption:o.querySelector(".se-modal-ratio"),inputX:o.querySelector("._se_size_x"),inputY:o.querySelector("._se_size_y"),revertBtn:o.querySelector(".se-modal-btn-revert"),fileRemoveBtn:o.querySelector(".se-file-remove")}}(this.$,this.pluginOptions),n=e.controls||(this.pluginOptions.canResize?[["resize_auto,75,50","align","edit","revert","copy","remove"]]:[["align","edit","copy","remove"]]);n.some((t=>t.includes("align")))||(i.alignForm.style.display="none");const o=100*this.pluginOptions.defaultRatio+"%";this.modal=new Fl(this,this.$,i.html),this.figure=new ji(this,this.$,n,{sizeUnit:s,autoRatio:{current:o,default:o}}),this.fileManager=new ql(this,this.$,{query:"iframe, video",loadEventName:"onVideoLoad",actionEventName:"onVideoAction"}),this.fileModalWrapper=i.fileModalWrapper,this.videoInputFile=i.videoInputFile,this.videoUrlFile=i.videoUrlFile,this.focusElement=this.videoUrlFile||this.videoInputFile,this.previewSrc=i.previewSrc,this.#ud=this.pluginOptions.canResize,this.#wu=!this.#ud||!this.pluginOptions.showHeightInput||this.pluginOptions.percentageOnlySize,this.query={youtube:{pattern:/youtu\.?be/i,action:t=>(t=this.convertUrlYoutube(t),ze.addUrlQuery(t,this.pluginOptions.query_youtube)),tag:"iframe"},vimeo:{pattern:/vimeo\.com/i,action:t=>(t=this.convertUrlVimeo(t),ze.addUrlQuery(t,this.pluginOptions.query_vimeo)),tag:"iframe"},...e.embedQuery};const r=[];for(const t in this.query)r.push(this.query[t].pattern);Kh.#Yu=Kh.#Yu.concat(this.pluginOptions.extensions||[]),Kh.#Xu=Kh.#Xu.concat(e.urlPatterns||[]),this.state={onlyPercentage:this.pluginOptions.percentageOnlySize,sizeUnit:s,defaultRatio:100*this.pluginOptions.defaultRatio+"%"},this.sizeService=new Wh(this,i),this.uploadService=new Vh(this);const l=i.galleryButton;l&&this.$.eventManager.addEvent(l,"click",this.#Iu.bind(this)),this.videoInputFile&&this.$.eventManager.addEvent(i.fileRemoveBtn,"click",this.#Mu.bind(this)),this.videoUrlFile&&this.$.eventManager.addEvent(this.videoUrlFile,"input",this.#Nu.bind(this)),this.videoInputFile&&this.videoUrlFile&&this.$.eventManager.addEvent(this.videoInputFile,"change",this.#Bu.bind(this))}setState(t,e){this.state[t]=e}open(){this.modal.open()}retainFormat(){return{query:"iframe, video",method:async t=>{if(/^(iframe)$/i.test(t?.nodeName)&&!Kh.#Ku(t.src))return;const e=ji.GetContainer(t);if(e&&e.container&&e.cover)return;this.#Au(t,!0);const s=this.$.format.getLine(t);s&&(this.#ku=s.style.textAlign||s.style.float),this.#Ru(t)}}}onFilePasteAndDrop({file:t}){/^video/.test(t.type)&&(this.submitFile([t]),this.$.focusManager.focus())}modalOn(t){t?this.videoInputFile&&this.pluginOptions.allowMultiple&&this.videoInputFile.removeAttribute("multiple"):this.videoInputFile&&this.pluginOptions.allowMultiple&&this.videoInputFile.setAttribute("multiple","multiple"),this.sizeService.on(t)}async modalAction(){this.#ku=this.modal.form.querySelector('input[name="suneditor_video_radio"]:checked').value;let t=!1;return this.videoInputFile&&this.videoInputFile.files.length>0?t=await this.submitFile(this.videoInputFile.files):this.videoUrlFile&&this.#_u.length>0&&(t=await this.submitURL(this.#_u)),t&&jh.setTimeout(this.$.component.select.bind(this.$.component,this.#Pc,Kh.key),0),t}modalInit(){Fl.OnChangeFile(this.fileModalWrapper,[]),this.videoInputFile&&(this.videoInputFile.value=""),this.videoUrlFile&&(this.#_u=this.previewSrc.textContent=this.videoUrlFile.value=""),this.videoInputFile&&this.videoUrlFile&&(this.videoUrlFile.disabled=!1,this.previewSrc.style.textDecoration=""),this.modal.form.querySelector('input[name="suneditor_video_radio"][value="none"]').checked=!0,this.#wu=!1,this.sizeService.init()}componentSelect(t){this.#Au(t)}componentEdit(){this.modal.open()}async componentDestroy(t){const e=t||this.#Pc,s=Pe.query.getParentElement(e,ji.is)||e,i=s.previousElementSibling||s.nextElementSibling,n=s.parentNode;!1!==await this.$.eventManager.triggerEvent("onVideoDeleteBefore",{element:e,container:s,align:this.#ku,url:this.#_u})&&(Pe.utils.removeItem(s),this.modalInit(),n!==this.$.frameContext.get("wysiwyg")&&this.$.nodeTransform.removeAllParents(n,(function(t){return 0===t.childNodes.length}),null),this.$.focusManager.focusEdge(i),this.$.history.push(!1))}findProcessUrl(t){const e=this.query;for(const s in e){const i=e[s];if(i.pattern.test(t))return{origin:t,url:i.action(t),tag:i.tag}}return null}convertUrlYoutube(t){return/^http/.test(t)||(t="https://"+t),t=t.replace("watch?v=",""),/^\/\/.+\/embed\//.test(t)||(t=t.replace(t.match(/\/\/.+\//)[0],"//www.youtube.com/embed/").replace("&","?&")),t}convertUrlVimeo(t){return t.endsWith("/")&&(t=t.slice(0,-1)),t="https://player.vimeo.com/video/"+t.slice(t.lastIndexOf("/")+1)}addQuery(t,e){if(e.length>0)if(/\?/.test(t)){const s=t.split("?");t=s[0]+"?"+e+"&"+s[1]}else t+="?"+e;return t}create(t,e,s,i,n,o,r,l){let a=null;if(o){if((t=this.#Pc).src!==e){const s=this.findProcessUrl(e);if(/^iframe$/i.test(s?.tag)&&!/^iframe$/i.test(t.nodeName)){const s=this.createIframeTag();s.src=e,t.replaceWith(s),this.#Pc=t=s}else if(/^video$/i.test(s?.tag)&&!/^video$/i.test(t.nodeName)){const s=this.createVideoTag();s.src=e,t.replaceWith(s),this.#Pc=t=s}else t.src=e}a=this.#Su}else{t.src=e,this.#Pc=t;a=ji.CreateContainer(t,"se-video-container").container}this.#Pc=t,this.#Su=a,this.figure.open(t,{nonResizing:this.#wu,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:!0});const h=this.sizeService.resolveSize(s,i,t,o);s=h.width,i=h.height,this.figure.setAlign(t,n),this.fileManager.setFileData(t,r),o?(this.#ud&&h.isChanged&&this.figure.isVertical||this.figure.setTransform(t,s,i,0),this.$.history.push(!1)):this.$.component.insert(a,{scrollTo:!!l,insertBehavior:l?this.pluginOptions.insertBehavior:"line"})}createIframeTag(t){const e=Pe.utils.createElement("IFRAME");if(t)for(const s in t)e[s]=t[s];return this.#Zu(e),e}createVideoTag(t){const e=Pe.utils.createElement("VIDEO");if(t)for(const s in t)e[s]=t[s];return this.#Ju(e),e}async submitFile(t){if(0===t.length)return;let e=0;const s=[],i=this.pluginOptions.uploadSingleSizeLimit;for(let n,o,r=0,l=t.length;r0&&o>i){const t="[SUNEDITOR.videoUpload.fail] Size of uploadable single file: "+i/1e3+"KB",e=await this.$.eventManager.triggerEvent("onVideoUploadError",{error:t,limitSize:i,uploadSize:o,file:n});return this.$.ui.alertOpen(e===Gh?t:e||t,"error"),!1}s.push(n),e+=o}const n=this.pluginOptions.uploadSizeLimit,o=this.fileManager.getSize();if(n>0&&e+o>n){const t="[SUNEDITOR.videoUpload.fail] Size of uploadable total videos: "+n/1e3+"KB",s=await this.$.eventManager.triggerEvent("onVideoUploadError",{error:t,limitSize:n,currentSize:o,uploadSize:e});return this.$.ui.alertOpen(s===Gh?t:s||t,"error"),!1}const r={url:null,files:s,...this.#Pu()},l=function(t,e,s){t(e=s||e,e.files)}.bind(this,this.uploadService.serverUpload.bind(this.uploadService),r),a=await this.$.eventManager.triggerEvent("onVideoUploadBefore",{info:r,handler:l});return void 0===a||!1!==a&&(null!==a&&"object"==typeof a&&l(a),void(!0!==a&&a!==Gh||l(null)))}async submitURL(t){if(!(t=this.#_u))return!1;if(/^$/.test(t)){if(0===(t=(new DOMParser).parseFromString(t,"text/html").querySelector("iframe").src).length)return!1}const e=this.findProcessUrl(t);e&&(t=e.url);const s={name:t.split("/").pop(),size:0},i={url:t,files:s,...this.#Pu(),process:e},n=function(t,e){t=e||t,this.create(this[/^iframe$/i.test(t.process?.tag)?"createIframeTag":"createVideoTag"](),t.url,t.inputWidth,t.inputHeight,t.align,t.isUpdate,t.files,!0)}.bind(this,i),o=await this.$.eventManager.triggerEvent("onVideoUploadBefore",{info:i,handler:n});return void 0===o||!1!==o&&(null!==o&&"object"==typeof o&&n(o),!0!==o&&o!==Gh||n(null),!0)}#Au(t,e=!1){if(!t)return;const s=this.figure.open(t,{nonResizing:this.#wu,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:e});this.#Pc=t,this.#Su=s.container,this.#ku=s.align,t.style.float="";const i=String(s.width||s.originWidth||s.w||""),n=String(s.height||s.originHeight||s.h||"");this.sizeService.setOriginSize(i,n),this.videoUrlFile&&(this.#_u=this.previewSrc.textContent=this.videoUrlFile.value=this.#Pc.src||this.#Pc.querySelector("source")?.src||"");(this.modal.form.querySelector('input[name="suneditor_video_radio"][value="'+this.#ku+'"]')||this.modal.form.querySelector('input[name="suneditor_video_radio"][value="none"]')).checked=!0,this.#ud&&this.sizeService.ready(s,t)}#Pu(){const{w:t,h:e}=this.sizeService.getInputSize();return{inputWidth:t,inputHeight:e,align:this.#ku,isUpdate:this.modal.isUpdate,element:this.#Pc}}#Ru(t){if(!t)return;/^video$/i.test(t.nodeName)?this.#Ju(t):/^iframe$/i.test(t.nodeName)&&this.#Zu(t);const e=t,s=t.cloneNode(!0),i=ji.CreateContainer(s,"se-video-container"),n=i.container,o=ji.GetContainer(e)?.container?.querySelector("figcaption");let r=null;o&&(r=Pe.utils.createElement("figcaption"),r.innerHTML=o.innerHTML,Pe.utils.removeItem(o),i.cover.appendChild(r)),this.figure.open(s,{nonResizing:this.#wu,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:!0});const l=(s.getAttribute("data-se-size")||",").split(","),a=l[0]||e.width||"",h=l[1]||e.height||this.state.defaultRatio||"";this.sizeService.applySize(a,h);const c=this.$.format.getLine(e);return c&&(this.#ku=c.style.textAlign||c.style.float),this.figure.setAlign(s,this.#ku),this.figure.retainFigureFormat(n,this.#Pc,null,this.fileManager),s}#Ju(t){t.setAttribute("controls","true");const e=this.pluginOptions.videoTagAttributes;if(e)for(const s in e)t.setAttribute(s,e[s])}#Zu(t){t.frameBorder="0",t.allowFullscreen=!0;const e=this.pluginOptions.iframeTagAttributes;if(e)for(const s in e)t.setAttribute(s,e[s])}#Mu(){this.videoInputFile.value="",this.videoUrlFile&&(this.videoUrlFile.disabled=!1,this.previewSrc.style.textDecoration=""),Fl.OnChangeFile(this.fileModalWrapper,[])}#Nu(t){const e=Pe.query.getEventTarget(t).value.trim();/^$/.test(e)?(this.#_u=e,this.previewSrc.textContent=''):this.#_u=this.previewSrc.textContent=e?this.$.options.get("defaultUrlProtocol")&&!e.includes("://")&&0!==e.indexOf("#")?this.$.options.get("defaultUrlProtocol")+e:e.includes("://")?e:"/"+e:""}#Iu(){this.$.plugins.videoGallery.open(this.#Hu.bind(this))}#Hu(t){this.#_u=this.previewSrc.textContent=this.videoUrlFile.value=t.getAttribute("data-command")||t.src,this.videoUrlFile.focus()}#Bu(t){this.videoInputFile.value?(this.videoUrlFile.disabled=!0,this.previewSrc.style.textDecoration="line-through"):(this.videoUrlFile.disabled=!1,this.previewSrc.style.textDecoration="");const e=Pe.query.getEventTarget(t);Fl.OnChangeFile(this.fileModalWrapper,e.files)}}const Yh=Kh,{NO_EVENT:Xh,ON_OVER_COMPONENT:Zh}=Oe;class Jh extends ta{static key="audio";static className="";static component(t){return/^AUDIO$/i.test(t?.nodeName)?t:null}#Qu;#tp;#ep="";#Pc=null;constructor(t,e){super(t),this.title=this.$.lang.audio,this.icon="audio",this.pluginOptions={defaultWidth:e.defaultWidth?De.is(e.defaultWidth)?e.defaultWidth+"px":e.defaultWidth:"",defaultHeight:e.defaultHeight?De.is(e.defaultHeight)?e.defaultHeight+"px":e.defaultHeight:"",createFileInput:!!e.createFileInput,createUrlInput:void 0===e.createUrlInput||!e.createFileInput||e.createUrlInput,uploadUrl:"string"==typeof e.uploadUrl?e.uploadUrl:null,uploadHeaders:e.uploadHeaders||null,uploadSizeLimit:De.get(e.uploadSizeLimit,0),uploadSingleSizeLimit:De.get(e.uploadSingleSizeLimit,0),allowMultiple:!!e.allowMultiple,acceptedFormats:"string"!=typeof e.acceptedFormats||"*"===e.acceptedFormats.trim()?"audio/*":e.acceptedFormats.trim()||"audio/*",audioTagAttributes:e.audioTagAttributes||null,insertBehavior:e.insertBehavior};const s=function({lang:t,icons:e,plugins:s},i){let n=`\n
    \n
    \n \n ${t.audio_modal_title}\n
    \n
    `;i.createFileInput&&(n+=`\n
    \n \n ${Fl.CreateFileInput({lang:t,icons:e},i)}\n
    `);i.createUrlInput&&(n+=`\n
    \n \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t${s.audioGallery?``:""}\n\t\t\t
    \n \n
    `);return n+=`\n
    \n \n
    `,Pe.utils.createElement("DIV",{class:"se-modal-content"},n)}(this.$,this.pluginOptions),i=function({lang:t,icons:e}){const s=`\n
    \n `;return Pe.utils.createElement("DIV",{class:"se-controller"},s)}(this.$);this.modal=new Fl(this,this.$,s),this.controller=new Ii(this,this.$,i,{position:"bottom",disabled:!0}),this.fileManager=new ql(this,this.$,{query:"audio",loadEventName:"onAudioLoad",actionEventName:"onAudioAction"}),this.figure=new ji(this,this.$,null,{}),this.fileModalWrapper=s.querySelector(".se-flex-input-wrapper"),this.audioInputFile=s.querySelector(".__se__file_input"),this.audioUrlFile=s.querySelector(".se-input-url"),this.preview=s.querySelector(".se-link-preview"),this.#Qu=this.pluginOptions.defaultWidth,this.#tp=this.pluginOptions.defaultHeight;const n=s.querySelector(".__se__gallery");n&&this.$.eventManager.addEvent(n,"click",this.#Iu.bind(this)),this.audioInputFile&&(this.$.eventManager.addEvent(s.querySelector(".se-modal-files-edge-button"),"click",this.#Mu.bind(this,this.audioUrlFile,this.preview)),this.audioUrlFile&&this.$.eventManager.addEvent(this.audioInputFile,"change",this.#sp.bind(this))),this.audioUrlFile&&this.$.eventManager.addEvent(this.audioUrlFile,"input",this.#Nu.bind(this))}open(){this.modal.open()}retainFormat(){return{query:"audio",method:t=>{const e=ji.GetContainer(t);if(e&&e.container&&e.cover)return;this.#Ju(t);const s=ji.CreateContainer(t.cloneNode(!0),"se-flex-component");this.figure.retainFigureFormat(s.container,t,null,this.fileManager)}}}onFilePasteAndDrop({file:t}){/^audio/.test(t.type)&&(this.submitFile([t]),this.$.focusManager.focus())}modalOn(t){t?this.#Pc?(this.#ep=this.preview.textContent=this.audioUrlFile.value=this.#Pc.src,this.audioInputFile&&this.pluginOptions.allowMultiple&&this.audioInputFile.removeAttribute("multiple")):this.audioInputFile&&this.pluginOptions.allowMultiple&&this.audioInputFile.removeAttribute("multiple"):this.audioInputFile&&this.pluginOptions.allowMultiple&&this.audioInputFile.setAttribute("multiple","multiple")}async modalAction(){return this.audioInputFile&&this.audioInputFile?.files.length>0?await this.submitFile(this.audioInputFile.files):!!(this.audioUrlFile&&this.#ep.length>0)&&await this.submitURL(this.#ep)}modalInit(){Fl.OnChangeFile(this.fileModalWrapper,[]),this.audioInputFile&&(this.audioInputFile.value=""),this.audioUrlFile&&(this.#ep=this.preview.textContent=this.audioUrlFile.value=""),this.audioInputFile&&this.audioUrlFile&&(this.audioUrlFile.disabled=!1,this.preview.style.textDecoration="")}controllerAction(t){switch(t.getAttribute("data-command")){case"update":this.audioUrlFile&&(this.#ep=this.preview.textContent=this.audioUrlFile.value=this.#Pc.src),this.open();break;case"copy":{const t=ji.GetContainer(this.#Pc);this.$.component.copy(t.container);break}case"delete":this.componentDestroy(null)}}componentSelect(t){this.figure.open(t,{nonResizing:!0,nonSizeInfo:!0,nonBorder:!0,figureTarget:!0,infoOnly:!1}),this.#Au(t)}async componentDestroy(t){const e=t||this.#Pc,s=ji.GetContainer(e),i=s.container||e,n=i.previousElementSibling||i.nextElementSibling;if(!1===await this.$.eventManager.triggerEvent("onAudioDeleteBefore",{element:e,container:s,url:e.getAttribute("src")}))return;const o=i.parentNode;Pe.utils.removeItem(i),this.modalInit(),this.controller.close(),o!==this.$.frameContext.get("wysiwyg")&&this.$.nodeTransform.removeAllParents(o,(function(t){return 0===t.childNodes.length}),null),this.$.focusManager.focusEdge(n),this.$.history.push(!1)}async submitFile(t){if(0===t.length)return!1;let e=0;const s=[],i=this.pluginOptions.uploadSingleSizeLimit;for(let n,o,r=0,l=t.length;r0&&o>i){const t="[SUNEDITOR.audioUpload.fail] Size of uploadable single file: "+i/1e3+"KB",e=await this.$.eventManager.triggerEvent("onAudioUploadError",{error:t,limitSize:i,uploadSize:o,file:n});return this.$.ui.alertOpen(e===Xh?t:e||t,"error"),!1}s.push(n),e+=o}const n=this.pluginOptions.uploadSizeLimit;if(n>0&&e+this.fileManager.getSize()>n){const t="[SUNEDITOR.audioUpload.fail] Size of uploadable total audios: "+n/1e3+"KB",s=await this.$.eventManager.triggerEvent("onAudioUploadError",{error:t,limitSize:n,currentSize:this.fileManager.getSize(),uploadSize:e});return this.$.ui.alertOpen(s===Xh?t:s||t,"error"),!1}const o={files:s,isUpdate:this.modal.isUpdate,element:this.#Pc},r=function(t,e,s){t(s=e||s,s.files)}.bind(this,this.#ip.bind(this),o),l=await this.$.eventManager.triggerEvent("onAudioUploadBefore",{info:o,handler:r});return void 0===l||!!l&&(null!==l&&"object"==typeof l&&r(l),!0!==l&&l!==Xh||r(null),!0)}async submitURL(t){if(0===t.length)return!1;const e={name:t.split("/").pop(),size:0},s={url:t,files:e,isUpdate:this.modal.isUpdate,element:this.#np()},i=function(t,e,s){t((s=e||s).element,s.url,s.files,s.isUpdate,!0)}.bind(this,this.create.bind(this),s),n=await this.$.eventManager.triggerEvent("onAudioUploadBefore",{info:s,handler:i});return void 0===n||!!n&&(null!==n&&"object"==typeof n&&i(n),!0!==n&&n!==Xh||i(null),!0)}create(t,e,s,i,n){if(i){if(this.#Pc&&(t=this.#Pc),this.fileManager.setFileData(t,s),!t||t.src===e)return void this.$.component.select(t,Jh.key);t.src=e,this.$.component.select(t,Jh.key)}else{this.fileManager.setFileData(t,s),t.src=e;const i=ji.CreateContainer(t,"se-flex-component");if(!this.$.component.insert(i.container,{scrollTo:!!n,insertBehavior:n?this.pluginOptions.insertBehavior:"line"}))return void(n&&this.$.focusManager.focus());if(!this.$.options.get("componentInsertBehavior")){const t=this.$.format.addLine(i.container,null);t&&this.$.selection.setRange(t,0,t,0)}}i&&this.$.history.push(!1)}#Au(t){_i.get("__overInfo")!==Zh&&(this.#Pc=t,this.controller.open(t,null,{isWWTarget:!1,addOffset:null}))}#pc(t,e){const s=e.result;for(let e,i,n=0,o=s.length;nt.src||t.href)),s=i?.src||i?.href}if(/^BLOCKQUOTE$/i.test(t?.nodeName)){const e=t.querySelector("a");if(e&&e.href)return i=t,s=e.href,this.#Ku(s)?i:null}return s?this.#Ku(s)?i:null:i}static#Ku(t){return t=t?.toLowerCase()||"",!!this.#Xu.some((e=>e.test(t)))}static#op(t,e){return!!t&&e.some((e=>e instanceof RegExp?e.test(t):t.startsWith(e)))}static#Xu=null;#Wu;#Uu;#ou;#ru;#ud;#rp;#wu;#_u="";#ku="none";#Pc=null;#$u=null;#Su=null;#lu={w:0,h:0};constructor(t,e){super(t),this.title=this.$.lang.embed,this.icon="embed",this.pluginOptions={canResize:void 0===e.canResize||e.canResize,showHeightInput:void 0===e.showHeightInput||!!e.showHeightInput,defaultWidth:e.defaultWidth&&De.get(e.defaultWidth,0)?De.is(e.defaultWidth)?e.defaultWidth+"px":e.defaultWidth:"",defaultHeight:e.defaultHeight&&De.get(e.defaultHeight,0)?De.is(e.defaultHeight)?e.defaultHeight+"px":e.defaultHeight:"",percentageOnlySize:!!e.percentageOnlySize,uploadUrl:"string"==typeof e.uploadUrl?e.uploadUrl:null,uploadHeaders:e.uploadHeaders||null,uploadSizeLimit:De.get(e.uploadSizeLimit,0),uploadSingleSizeLimit:De.get(e.uploadSingleSizeLimit,0),iframeTagAttributes:e.iframeTagAttributes||null,query_youtube:e.query_youtube||"",query_vimeo:e.query_vimeo||"",scriptSrcWhitelist:Array.isArray(e.scriptSrcWhitelist)?e.scriptSrcWhitelist:[],insertBehavior:e.insertBehavior};const s=this.pluginOptions.percentageOnlySize?"%":"px",i=function({lang:t,icons:e},s){let i=`\n\t
    \n\t\t
    \n\t\t\t\n\t\t\t${t.embed_modal_title}\n\t\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t
    `;if(s.canResize){const n=s.percentageOnlySize,o=n?' style="display: none !important;"':"",r=s.showHeightInput?"":' style="display: none !important;"',l=s.showRatioOption?"":' style="display: none !important;"',a=n||s.showHeightInput||s.showRatioOption?"":' style="display: none !important;"';i+=`\n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t\t`}i+=`\n\t\t
    \n\t\t\n\t
    `;const n=Pe.utils.createElement("DIV",{class:"se-modal-content"},i);return{html:n,figureAlignBtn:n.querySelector(".se-figure-align"),fileModalWrapper:n.querySelector(".se-flex-input-wrapper"),embedInput:n.querySelector(".se-input-url"),previewSrc:n.querySelector(".se-link-preview"),proportion:n.querySelector("._se_check_proportion"),inputX:n.querySelector("._se_size_x"),inputY:n.querySelector("._se_size_y"),revertBtn:n.querySelector(".se-modal-btn-revert")}}(this.$,this.pluginOptions),n=e.controls||(this.pluginOptions.canResize?[["resize_auto,75,50","align","edit","revert","copy","remove"]]:[["align","edit","copy","remove"]]);n.some((t=>t.includes("align")))||(i.figureAlignBtn.style.display="none"),this.modal=new Fl(this,this.$,i.html),this.figure=new ji(this,this.$,n,{sizeUnit:s}),this.fileModalWrapper=i.fileModalWrapper,this.embedInput=i.embedInput,this.focusElement=this.embedInput,this.previewSrc=i.previewSrc,this.sizeUnit=s,this.proportion=null,this.inputX=null,this.inputY=null,this.#Wu=this.pluginOptions.defaultWidth,this.#Uu=this.pluginOptions.defaultHeight,this.#ou="auto"===this.pluginOptions.defaultWidth?"":this.pluginOptions.defaultWidth,this.#ru="auto"===this.pluginOptions.defaultHeight?"":this.pluginOptions.defaultHeight,this.#ud=this.pluginOptions.canResize,this.#rp=this.pluginOptions.percentageOnlySize,this.#wu=!this.#ud||!this.pluginOptions.showHeightInput||this.#rp,this.query={facebook:{pattern:/(?:https?:\/\/)?(?:www\.)?(?:facebook\.com)\/(.+)/i,action:t=>`https://www.facebook.com/plugins/post.php?href=${encodeURIComponent(t)}&show_text=true&width=500`,tag:"iframe"},twitter:{pattern:/^(?:https?:\/\/)?(?:(?:www\.)?(?:twitter\.com|x\.com)\/(?:[^/?#]+\/)?status\/\d+(?:[/?#]|$)|platform\.twitter\.com\/embed\/Tweet\.html(?:[?#].*)?$)/i,action:t=>`https://platform.twitter.com/embed/Tweet.html?url=${encodeURIComponent(t)}`,tag:"iframe"},instagram:{pattern:/(?:https?:\/\/)?(?:www\.)?(?:instagram\.com)\/p\/(.+)/i,action:t=>`https://www.instagram.com/p/${t.match(this.query.instagram.pattern)[1]}/embed`,tag:"iframe"},linkedin:{pattern:/(?:https?:\/\/)?(?:www\.)?(?:linkedin\.com)\/(.+)\/(.+)/i,action:t=>`https://www.linkedin.com/embed/feed/update/${encodeURIComponent(t.split("/").pop())}`,tag:"iframe"},pinterest:{pattern:/(?:https?:\/\/)?(?:www\.)?(?:pinterest\.com)\/pin\/(.+)/i,action:t=>`https://assets.pinterest.com/ext/embed.html?id=${t.match(this.query.pinterest.pattern)[1]}`,tag:"iframe"},spotify:{pattern:/(?:https?:\/\/)?(?:open\.)?(?:spotify\.com)\/(track|album|playlist|show|episode)\/(.+)/i,action:t=>{const e=t.match(this.query.spotify.pattern);return`https://open.spotify.com/embed/${e[1]}/${e[2]}`},tag:"iframe"},codepen:{pattern:/(?:https?:\/\/)?(?:www\.)?(?:codepen\.io)\/(.+)\/pen\/(.+)/i,action:t=>{const[,e,s]=t.match(this.query.codepen.pattern);return`https://codepen.io/${e}/embed/${s}`},tag:"iframe"},...e.embedQuery};const o=[];for(const t in this.query)o.push(this.query[t].pattern);sc.#Xu=o.concat(e.urlPatterns||[]),this.$.eventManager.addEvent(this.embedInput,"input",this.#Nu.bind(this)),this.#ud&&(this.proportion=i.proportion,this.inputX=i.inputX,this.inputY=i.inputY,this.inputX.value=this.pluginOptions.defaultWidth,this.inputY.value=this.pluginOptions.defaultHeight,this.$.eventManager.addEvent(this.inputX,"keyup",this.#uu.bind(this,"x")),this.$.eventManager.addEvent(this.inputY,"keyup",this.#uu.bind(this,"y")),this.$.eventManager.addEvent(i.revertBtn,"click",this.#pu.bind(this)))}open(){this.modal.open()}retainFormat(){return{query:"iframe",method:async t=>{if(!sc.#Ku(t.src))return;const e=ji.GetContainer(t);if(e&&e.container&&e.cover)return;this.#Au(t,!0);const s=this.$.format.getLine(t);s&&(this.#ku=s.style.textAlign||s.style.float),this.#Ru(t)}}}modalOn(t){!t&&this.#ud?(this.inputX.value=this.#ou="auto"===this.pluginOptions.defaultWidth?"":this.pluginOptions.defaultWidth,this.inputY.value=this.#ru="auto"===this.pluginOptions.defaultHeight?"":this.pluginOptions.defaultHeight,this.proportion.disabled=!0):t&&(this.#_u=this.previewSrc.textContent=this.embedInput.value=this.#$u.getAttribute("data-se-origin")||"")}async modalAction(){this.#ku=this.modal.form.querySelector('input[name="suneditor_embed_radio"]:checked').value;let t=!1;return this.#_u.length>0&&(t=await this.submitSRC(this.#_u)),t&&tc.setTimeout(this.$.component.select.bind(this.$.component,this.#Pc,sc.key),0),t}modalInit(){Fl.OnChangeFile(this.fileModalWrapper,[]),this.#_u=this.previewSrc.textContent=this.embedInput.value="",this.modal.form.querySelector('input[name="suneditor_embed_radio"][value="none"]').checked=!0,this.#lu={w:0,h:0},this.#wu=!1,this.#ud&&(this.inputX.value=this.pluginOptions.defaultWidth===this.#Wu?"":this.pluginOptions.defaultWidth,this.inputY.value=this.pluginOptions.defaultHeight===this.#Uu?"":this.pluginOptions.defaultHeight,this.proportion.checked=!1,this.proportion.disabled=!0)}componentSelect(t){this.#Au(t)}componentEdit(){this.modal.open()}async componentDestroy(t){const e=t||this.#Pc,s=Pe.query.getParentElement(e,ji.is)||e,i=s.previousElementSibling||s.nextElementSibling,n=s.parentNode;!1!==await this.$.eventManager.triggerEvent("onEmbedDeleteBefore",{element:e,container:s,align:this.#ku,url:this.#_u})&&(Pe.utils.removeItem(s),this.modalInit(),n!==this.$.frameContext.get("wysiwyg")&&this.$.nodeTransform.removeAllParents(n,(function(t){return 0===t.childNodes.length}),null),this.$.focusManager.focusEdge(i),this.$.history.push(!1))}findProcessUrl(t){const e=this.query;for(const s in e){const i=e[s];if(i.pattern.test(t))return{origin:t,url:i.action(t),tag:i.tag}}return null}async submitSRC(t){if(!(t||=this.#_u))return!1;let e=null;if(/^{Pe.utils.removeItem(d),d=null},h.appendChild(d);const t=new MutationObserver((e=>{for(const s of e)if("childList"===s.type&&!a.parentElement){this.$.history.resume(),this.$.history.push(!1),t.disconnect();break}}));t.observe(this.$.frameContext.get("wysiwyg"),{subtree:!0,childList:!0})}catch(t){this.$.history.resume(),console.warn("[SUNEDITOR] Embed tag script load error.",t)}if(!this.$.options.get("componentInsertBehavior")){const t=this.$.format.addLine(c,null);t&&this.$.selection.setRange(t,0,t,0)}}}#Ru(t){if(!t)return;this.#Zu(t);const e=t;t=t.cloneNode(!0);const s=ji.CreateContainer(t,"se-embed-container").container;this.figure.open(t,{nonResizing:this.#wu,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:!0});const i=(t.getAttribute("data-se-size")||",").split(","),n=i[0]||e.width||"",o=i[1]||e.height||"";this.#cp(n,o);const r=this.$.format.getLine(e);return r&&(this.#ku=r.style.textAlign||r.style.float),this.figure.setAlign(t,this.#ku),this.figure.retainFigureFormat(s,this.#Pc,null,null),t}#cp(t,e){t||=this.inputX?.value||this.pluginOptions.defaultWidth,e||=this.inputY?.value||this.pluginOptions.defaultHeight,this.#rp&&(t?/%$/.test(t+"")||(t+="%"):t="100%"),this.figure.setSize(t,e)}#Pu(){return{inputWidth:this.inputX?.value||"",inputHeight:this.inputY?.value||"",align:this.#ku,isUpdate:this.modal.isUpdate,element:this.#Pc}}#Zu(t){t.frameBorder="0",t.allowFullscreen=!0;const e=this.pluginOptions.iframeTagAttributes;if(e)for(const s in e)t.setAttribute(s,e[s])}#Nu(t){const e=Pe.query.getEventTarget(t).value.trim();/^$/.test(e)?(this.#_u=e,this.previewSrc.textContent=''):this.#_u=this.previewSrc.textContent=e?this.$.options.get("defaultUrlProtocol")&&!e.includes("://")&&0!==e.indexOf("#")?this.$.options.get("defaultUrlProtocol")+e:e.includes("://")?e:"/"+e:""}#pu(){this.#rp?this.inputX.value=Number(this.#ou)>100?"100":this.#ou:(this.inputX.value=this.#ou,this.inputY.value=this.#ru)}#uu(t,e){if(Fe.isSpace(e.code))return void e.preventDefault();const s=Pe.query.getEventTarget(e);if("x"===t&&this.#rp&&Number(s.value)>100)s.value="100";else if(this.proportion.checked){const e=ji.CalcRatio(this.inputX.value,this.inputY.value,this.sizeUnit,this.#lu);"x"===t?this.inputY.value=String(e.h):this.inputX.value=String(e.w)}}}const ic=sc,{_w:nc,_d:oc}=Oe;class rc extends ta{static key="math";static className="";static component(t){return Pe.utils.hasClass(t,"se-math|katex")&&Pe.check.isComponentContainer(t)?t:null}#Pc=null;constructor(t,e){super(t),this.title=this.$.lang.math,this.icon="math",this.katex=null,this.mathjax=null,(this.katex=this.#dp())||(this.mathjax=this.#up())||console.warn('[SUNEDITOR.plugins.math.warn] The math plugin must need either "KaTeX" or "MathJax" library. Please add the katex or mathjax option. See: https://github.com/ARA-developer/suneditor/blob/develop/guide/external-libraries.md'),this.pluginOptions={formSize:{width:"460px",height:"14em",maxWidth:"",maxHeight:"",minWidth:"400px",minHeight:"40px",...e.formSize},canResize:e.canResize??!0,autoHeight:!!e.autoHeight,fontSizeList:e.fontSizeList||[{text:"1",value:"1em"},{text:"1.5",value:"1.5em"},{text:"2",value:"2em"},{text:"2.5",value:"2.5em"}],onPaste:"function"==typeof e.onPaste?e.onPaste:null},this.pluginOptions.autoHeight&&(this.pluginOptions.formSize.height=this.pluginOptions.formSize.minHeight),this.defaultFontSize=null;const s=function(t){const{$:e,pluginOptions:s,katex:i}=t,{lang:n,icons:o}=e,{formSize:r,fontSizeList:l,canResize:a,autoHeight:h}=s,{width:c,height:d,maxWidth:u,maxHeight:p,minWidth:g,minHeight:m}=r,f=a?h?"horizontal":"auto":"none";let v=l[0].value,b=`\n
    \n
    \n \n ${n.math_modal_title}\n
    \n
    \n
    \n \n \n
    \n
    \n \n \n
    \n
    \n \n

    \n
    \n
    \n \n
    `,t.defaultFontSize=v,Pe.utils.createElement("DIV",{class:"se-modal-content se-modal-responsive",style:`max-width: ${u}; max-height: ${p};`},b)}(this),i=function({lang:t,icons:e}){const s=`\n
    \n `;return Pe.utils.createElement("DIV",{class:"se-controller se-controller-link"},s)}(this.$);this.modal=new Fl(this,this.$,s),this.controller=new Ii(this,this.$,i,{position:"bottom",disabled:!0}),this.textArea=s.querySelector(".se-math-exp"),this.previewElement=s.querySelector(".se-math-preview"),this.fontSizeElement=s.querySelector(".se-math-size"),this.isUpdateState=!1,this.previewElement.style.fontSize=this.defaultFontSize,this.$.eventManager.addEvent(this.textArea,"input",this.#pp.bind(this)),this.$.eventManager.addEvent(this.fontSizeElement,"change",function(t){this.fontSize=t.target.value}.bind(this.previewElement.style)),this.pluginOptions.onPaste&&this.$.eventManager.addEvent(this.textArea,"paste",this.pluginOptions.onPaste.bind(this))}open(){this.modal.open()}retainFormat(){return{query:".se-math, .katex, .MathJax",method:t=>{if(!this.katex&&!this.mathjax)return;const e=lc(t);if(!e)return;const s=oc.createRange().createContextualFragment(this.#gp(ze.entityToHTML(this.#mp(e,!0))));t.innerHTML=s.querySelector(".se-math, .katex").innerHTML,t.setAttribute("contenteditable","false"),Pe.utils.addClass(t,"se-component|se-inline-component|se-disable-pointer|se-math"),this.katex?Pe.utils.addClass(t,"katex"):Pe.utils.removeClass(t,"katex"),this.mathjax&&this.#fp(this.mathjax)}}}modalOn(t){if(this.isUpdateState=t,t){if(this.controller.currentTarget){const t=this.controller.currentTarget,e=ze.entityToHTML(this.#mp(lc(t),!0)),s=function(t){const e=t.getAttribute("data-se-type");if(e)return e;const s=t.getAttribute("data-font-size");return s?(t.removeAttribute("data-font-size"),t.setAttribute("data-se-type",s),s):null}(t)||"1em";this.textArea.value=e,this.fontSizeElement.value=s,this.previewElement.innerHTML=this.#gp(e),this.previewElement.style.fontSize=s}}else this.modalInit()}async modalAction(){if(0===this.textArea.value.trim().length||Pe.utils.hasClass(this.textArea,"se-error"))return this.textArea.focus(),!1;const t=this.textArea.value,e=this.previewElement.querySelector(".se-math, .katex");if(!e)return!1;if(Pe.utils.addClass(e,"se-component|se-inline-component|se-disable-pointer|se-math"),e.setAttribute("contenteditable","false"),e.setAttribute("data-se-value",ze.htmlToEntity(this.#mp(t,!1))),e.setAttribute("data-se-type",this.fontSizeElement.value),e.style.fontSize=this.fontSizeElement.value,this.katex?(Pe.utils.addClass(e,"katex"),Pe.utils.removeClass(e,"MathJax")):Pe.utils.removeClass(e,"katex"),this.isUpdateState){Pe.query.getParentElement(this.controller.currentTarget,".se-component").replaceWith(e);const t=this.$.component.get(e);return this.$.component.select(t.target,t.pluginName),!0}{const t=this.$.format.getLines();if(t.length>1){const s=Pe.utils.createElement(t[0].nodeName,null,e);this.$.component.insert(s,{insertBehavior:"none",scrollTo:!1})}else this.$.component.insert(e,{insertBehavior:"none",scrollTo:!1})}this.mathjax&&this.#fp(this.mathjax);const s=this.$.selection.getNearRange(e);return s?this.$.selection.setRange(s.container,s.offset,s.container,s.offset):this.$.component.select(e,rc.key),!0}modalInit(){this.textArea.value="",this.previewElement.innerHTML="",Pe.utils.removeClass(this.textArea,"se-error")}controllerAction(t){switch(t.getAttribute("data-command")){case"update":this.modal.open();break;case"copy":this.#vp(this.#Pc);break;case"delete":this.componentDestroy(this.controller.currentTarget)}}controllerClose(){this.#Pc=null}componentSelect(t){if(Pe.utils.hasClass(t,"se-math|katex")&&lc(t))return this.#Pc=t,void this.controller.open(t,null,{isWWTarget:!1,initMethod:null,addOffset:null})}async componentDestroy(t){Pe.utils.removeItem(t),this.controller.close(),this.$.focusManager.focus(),this.$.history.push(!1)}#gp(t){let e="";try{if(Pe.utils.removeClass(this.textArea,"se-error"),this.katex)e=this.katex.src.renderToString(t,{throwOnError:!0,displayMode:!0});else{if(!this.mathjax){const t=new Error('404 Not found. "KaTeX" or "MathJax" library');throw t.code="MATH_LIB_NOT_FOUND",t}e=this.mathjax.convert(t).outerHTML,/${e}`):e=`${e}`}}catch(t){Pe.utils.addClass(this.textArea,"se-error"),e="MATH_LIB_NOT_FOUND"===t.code?`${t.message}`:`Math syntax error. (Refer ${this.katex?`KaTeX`:`MathJax`})`,console.warn("[SUNEDITOR.math.error] ",t.message)}return e}#mp(t,e){return t.replace(/\\{2}/g,e?"\\":"\\\\")}async#vp(t){if(navigator.clipboard&&t)try{const e=lc(t);await this.$.html.copy(e),Pe.utils.addClass(t,"se-copy"),nc.setTimeout((()=>{Pe.utils.removeClass(t,"se-copy")}),120)}catch(t){console.error("[SUNEDITOR.math.copy.fail]",t)}}#pp(t){const e=Pe.query.getEventTarget(t);this.pluginOptions.autoHeight&&(e.style.height="5px",e.style.height=e.scrollHeight+5+"px"),this.previewElement.innerHTML=this.#gp(e.value),this.mathjax&&this.#fp(this.mathjax)}#fp(t){t.clear(),t.updateDocument()}#dp(){const t=this.$.options.get("externalLibs").katex;if(!t)return null;if(!t.src)return console.warn("[SUNEDITOR.math.katex.fail] The katex option is set incorrectly."),null;const e=[{throwOnError:!1},t.options||{}].reduce(((t,e)=>{for(const s in e)t[s]=e[s];return t}),{});return t.options=e,t}#up(){const t=this.$.options.get("externalLibs").mathjax;if(!t)return null;this.$.frameOptions.get("iframe")&&console.warn("[SUNEDITOR.math.mathjax.fail] The MathJax option is not supported in the iframe.");try{const e=t.browserAdaptor();t.RegisterHTMLHandler(e);const s=new t.TeX,i=new t.CHTML;return t.src.document(document,{InputJax:s,OutputJax:i})}catch(t){return console.warn("[SUNEDITOR.math.mathjax.fail] The MathJax option is set incorrectly.",t),null}}}function lc(t){const e=t.getAttribute("data-se-value");if(e)return e;const s=t.getAttribute("data-exp");return s?(t.removeAttribute("data-exp"),t.setAttribute("data-se-value",s),s):null}const ac=rc,{_w:hc}=Oe;const cc=class extends ta{static key="drawing";static className="";#st;#bp;constructor(t,e){super(t),this.title=this.$.lang.drawing,this.icon="drawing",this.pluginOptions={outputFormat:e.outputFormat||"dataurl",useFormatType:e.useFormatType??!1,defaultFormatType:["block","inline"].includes(e.defaultFormatType)?e.defaultFormatType:"block",keepFormatType:e.keepFormatType??!1,lineWidth:e.lineWidth||5,lineReconnect:!!e.lineReconnect,lineCap:["butt","round","square"].includes(e.lineCap)?e.lineCap:"round",lineColor:e.lineColor||"",formSize:{width:"750px",height:"50vh",maxWidth:"",maxHeight:"",minWidth:"150px",minHeight:"100px",...e.formSize},canResize:e.canResize??!0,maintainRatio:e.maintainRatio??!0},this.$.plugins.image?"svg"!==this.pluginOptions.outputFormat||this.$.plugins.image.pluginOptions.uploadUrl||console.warn('[SUNEDITOR.plugins.drawing.warn] The drawing plugin must need the "image" plugin with the "uploadUrl" option. Please add the "image" plugin with the "uploadUrl" option.'):console.warn('[SUNEDITOR.plugins.drawing.warn] The drawing plugin must need either "image" plugin. Please add the "image" plugin.');const s=function({lang:t,icons:e},s){const{width:i,height:n,maxWidth:o,maxHeight:r,minWidth:l,minHeight:a}=s.formSize,h=`\n
    \n
    \n \n ${t.drawing_modal_title}\n
    \n
    \n \n\t\t\t${s.canResize?'
    ':""}\n\t\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t${s.useFormatType?`\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    `:""}\n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n \n
    `;return Pe.utils.createElement("DIV",{class:"se-modal-content se-modal-responsive",style:`max-width: ${o}; max-height: ${r};`},h)}(this.$,this.pluginOptions);this.modal=new Fl(this,this.$,s),this.as=this.pluginOptions.defaultFormatType,this.pluginOptions.useFormatType&&(this.asBlock=s.querySelector('[data-command="asBlock"]'),this.asInline=s.querySelector('[data-command="asInline"]'),this.$.eventManager.addEvent([this.asBlock,this.asInline],"click",this.#Lu.bind(this))),this.canvas=null,this.ctx=null,this.isDrawing=!1,this.points=[],this.paths=[],this.resizeObserver=null,this.#st={touchstart:this.#yp.bind(this),touchmove:this.#wp.bind(this),mousedown:this.#Cp.bind(this),mousemove:this.#_p.bind(this),mouseup:this.#kp.bind(this),mouseleave:this.#xp.bind(this),mouseenter:this.#$p.bind(this)},this.#bp={touchstart:null,touchmove:null,mousedown:null,mousemove:null,mouseup:null,mouseleave:null,mouseenter:null},this.$.eventManager.addEvent(s.querySelector('[data-command="remove"]'),"click",this.#Sp.bind(this))}open(){this.pluginOptions.useFormatType&&this.#zu("inline"===(this.pluginOptions.keepFormatType?this.as:this.pluginOptions.defaultFormatType)),this.modal.open(),this.#Ep()}modalOff(){this.#Tp()}async modalAction(){if("svg"===this.pluginOptions.outputFormat){const t=this.#Mp();this.$.plugins.image.modalInit(),this.$.plugins.image.submitFile(t)}else{const t=this.canvas.toDataURL(),e={name:"drawing",size:0};this.$.plugins.image.modalInit(),"inline"!==this.as?this.$.plugins.image.create(t,null,"auto","","none",e,""):this.$.plugins.image.createInline(t,null,"auto","","none",e,"")}return!0}#Ep(){const t=this.canvas=this.modal.form.querySelector(".se-drawing-canvas");this.ctx=t.getContext("2d"),t.width=t.offsetWidth,t.height=t.offsetHeight,this.points=[],this.paths=[],this.#Np(),this.#bp.touchstart=this.$.eventManager.addEvent(t,"touchstart",this.#st.touchstart,{passive:!1,capture:!0}),this.#bp.touchmove=this.$.eventManager.addEvent(t,"touchmove",this.#st.touchmove,!0),this.#bp.mousedown=this.$.eventManager.addEvent(t,"mousedown",this.#st.mousedown,{passive:!1,capture:!0}),this.#bp.mousemove=this.$.eventManager.addEvent(t,"mousemove",this.#st.mousemove,!0),this.#bp.mouseup=this.$.eventManager.addEvent(t,"mouseup",this.#st.mouseup,!0),this.#bp.mouseleave=this.$.eventManager.addEvent(t,"mouseleave",this.#st.mouseleave),this.#bp.mouseenter=this.$.eventManager.addEvent(t,"mouseenter",this.#st.mouseenter),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),Oe.isResizeObserverSupported&&(this.resizeObserver=new ResizeObserver((()=>{const e=t.width,s=t.height,i=t.offsetWidth,n=t.offsetHeight;t.width=i,t.height=n,e===t.width&&s===t.height||(this.pluginOptions.maintainRatio&&this.#Bp(e,s,i,n),this.#Ip())})),this.resizeObserver.observe(t))}#Tp(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.canvas&&(this.$.eventManager.removeEvent(this.#bp.mousedown),this.$.eventManager.removeEvent(this.#bp.mousemove),this.$.eventManager.removeEvent(this.#bp.mouseup),this.$.eventManager.removeEvent(this.#bp.mouseleave),this.$.eventManager.removeEvent(this.#bp.mouseenter)),this.canvas=null,this.ctx=null,this.points=[],this.paths=[],this.isDrawing=!1}#Np(){this.ctx.lineWidth=this.pluginOptions.lineWidth,this.ctx.lineCap=this.pluginOptions.lineCap,this.ctx.strokeStyle=this.pluginOptions.lineColor||hc.getComputedStyle(this.$.contextProvider.carrierWrapper).color}#Lp(){this.#Np(),this.ctx.beginPath(),this.points.forEach((([t,e],s)=>{0===s?this.ctx.moveTo(t,e):this.ctx.lineTo(t,e)})),this.ctx.stroke()}#Ip(){this.#Np(),this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.paths.forEach((t=>{this.points=t,this.#Lp()})),this.points=[]}#Bp(t,e,s,i){const n=s/t,o=i/e;this.paths=this.paths.map((t=>t.map((([t,e])=>[t*n,e*o]))))}#Ap(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.points=[],this.paths=[]}#Op(){const t="http://www.w3.org/2000/svg",e=document.createElementNS(t,"svg");return e.setAttribute("width",this.canvas.width+""),e.setAttribute("height",this.canvas.height+""),e.setAttribute("viewBox",`0 0 ${this.canvas.width} ${this.canvas.height}`),e.setAttribute("xmlns",t),this.paths.forEach((s=>{const i=s.reduce(((t,[e,s],i)=>t+(0===i?`M ${e} ${s}`:` L ${e} ${s}`)),""),n=document.createElementNS(t,"path");n.setAttribute("d",i),n.setAttribute("fill","none"),n.setAttribute("stroke",String(this.ctx.strokeStyle)),n.setAttribute("stroke-width",this.ctx.lineWidth+""),e.appendChild(n)})),e}#Mp(){const t=this.#Op(),e=(new XMLSerializer).serializeToString(t),s=new Blob([e],{type:"image/svg+xml"}),i=new File([s],"drawing.svg",{type:"image/svg+xml"}),n=new DataTransfer;return n.items.add(i),n.files}#Rp(t){const{touches:e}=t,s=this.canvas.getBoundingClientRect();return{x:e[0].clientX-s.left,y:e[0].clientY-s.top}}#zu(t){t?(Pe.utils.addClass(this.asInline,"on"),Pe.utils.removeClass(this.asBlock,"on"),this.as="inline"):(Pe.utils.addClass(this.asBlock,"on"),Pe.utils.removeClass(this.asInline,"on"),this.as="block")}#Cp(t){t.preventDefault(),this.isDrawing=!0,this.points.push([t.offsetX,t.offsetY]),this.#Lp()}#_p(t){t.preventDefault(),this.isDrawing&&(this.points.push([t.offsetX,t.offsetY]),this.#Lp())}#yp(t){t.preventDefault();const{x:e,y:s}=this.#Rp(t);this.isDrawing=!0,this.points.push([e,s]),this.#Lp()}#wp(t){t.preventDefault();const{x:e,y:s}=this.#Rp(t);this.isDrawing&&(this.points.push([e,s]),this.#Lp())}#kp(){this.isDrawing=!1,this.points.length>0&&(this.paths.push([...this.points]),this.points=[])}#xp(){this.isDrawing&&(this.paths.push([...this.points]),this.pluginOptions.lineReconnect||(this.points=[],this.isDrawing=!1))}#$p(t){if(1===t.buttons){if(this.isDrawing=!0,this.pluginOptions.lineReconnect){const e=this.paths.at(-1).at(-1);this.points.push([e[0],e[1]]),this.points.push([t.offsetX,t.offsetY])}else this.points.push([t.offsetX,t.offsetY]);this.#Lp()}}#Sp(){this.#Ap()}#Lu(t){this.#zu("asInline"===Pe.query.getEventTarget(t).getAttribute("data-command"))}};const dc=class extends Kl{static key="imageGallery";static className="";constructor(t,e){super(t),this.title=this.$.lang.imageGallery,this.icon="image_gallery",this.onSelectfunction=null,this.browser=new Xr(this,this.$,{title:this.$.lang.imageGallery,data:e.data,url:e.url,headers:e.headers,searchUrl:e.searchUrl,searchHeaders:e.searchHeaders,selectorHandler:this.#zp.bind(this),columnSize:4,className:"se-image-gallery"}),this.width="auto"===this.$.plugins.image.pluginOptions.defaultWidth?"":this.$.plugins.image.pluginOptions.defaultWidth,this.height="auto"===this.$.plugins.image.pluginOptions.defaultHeight?"":this.$.plugins.image.pluginOptions.defaultHeight}open(t){this.onSelectfunction=t,this.browser.open()}close(){this.onSelectfunction=null,this.browser.close()}#zp(t){if(this.onSelectfunction)this.onSelectfunction(t);else{const e={name:t.getAttribute("data-name"),size:0};this.$.plugins.image.modalInit(),this.$.plugins.image.create(t.getAttribute("data-command"),null,this.width,this.height,"none",e,t.alt,!0)}}};const uc=class extends Kl{static key="videoGallery";static className="";constructor(t,e){super(t),this.title=this.$.lang.videoGallery,this.icon="video_gallery",this.onSelectfunction=null;const s="string"==typeof e.thumbnail?e.thumbnail:this.$.icons.video_thumbnail;this.browser=new Xr(this,this.$,{title:this.$.lang.videoGallery,data:e.data,url:e.url,headers:e.headers,searchUrl:e.searchUrl,searchHeaders:e.searchHeaders,selectorHandler:this.#zp.bind(this),columnSize:4,className:"se-video-gallery",thumbnail:"function"==typeof e.thumbnail?e.thumbnail:()=>s,props:["frame"]}),this.width="auto"===this.$.plugins.video.pluginOptions.defaultWidth?"":this.$.plugins.video.pluginOptions.defaultWidth,this.height="auto"===this.$.plugins.video.pluginOptions.defaultHeight?"":this.$.plugins.video.pluginOptions.defaultHeight}open(t){this.onSelectfunction=t,this.browser.open()}close(){this.onSelectfunction=null,this.browser.close()}#zp(t){if(this.onSelectfunction)this.onSelectfunction(t);else{let e=t.getAttribute("data-command");const s=this.$.plugins.video.findProcessUrl(e);s&&(e=s.url);const i={name:t.getAttribute("data-name"),size:0};this.$.plugins.video.modalInit(),this.$.plugins.video.create(this.$.plugins.video["iframe"===t.getAttribute("data-frame")?"createIframeTag":"createVideoTag"]({poster:t.getAttribute("data-thumbnail")}),e,null,this.width,this.height,!1,i,!0)}}};const pc=class extends Kl{static key="audioGallery";static className="";constructor(t,e){super(t),this.title=this.$.lang.audioGallery,this.icon="audio_gallery",this.onSelectfunction=null;const s="string"==typeof e.thumbnail?e.thumbnail:this.$.icons.audio_thumbnail;this.browser=new Xr(this,this.$,{title:this.$.lang.audioGallery,data:e.data,url:e.url,headers:e.headers,searchUrl:e.searchUrl,searchHeaders:e.searchHeaders,selectorHandler:this.#zp.bind(this),columnSize:4,className:"se-audio-gallery",thumbnail:"function"==typeof e.thumbnail?e.thumbnail:()=>s})}open(t){this.onSelectfunction=t,this.browser.open()}close(){this.onSelectfunction=null,this.browser.close()}#zp(t){this.onSelectfunction?this.onSelectfunction(t):(this.$.plugins.audio.modalInit(),this.$.plugins.audio.submitURL(t.getAttribute("data-command")))}};const gc=class extends Kl{static key="fileGallery";static className="";constructor(t,e){super(t),this.title=this.$.lang.fileGallery,this.icon="file_gallery",this.onSelectfunction=null;const s="string"==typeof e.thumbnail?e.thumbnail:this.$.icons.file_thumbnail;this.browser=new Xr(this,this.$,{title:this.$.lang.fileGallery,data:e.data,url:e.url,headers:e.headers,searchUrl:e.searchUrl,searchHeaders:e.searchHeaders,selectorHandler:this.#zp.bind(this),columnSize:4,className:"se-file-gallery",thumbnail:"function"==typeof e.thumbnail?e.thumbnail:()=>s})}open(t){this.onSelectfunction=t,this.browser.open()}close(){this.onSelectfunction=null,this.browser.close()}#zp(t){if(this.onSelectfunction)this.onSelectfunction(t);else{const e={name:t.getAttribute("data-name"),size:0};this.$.plugins.fileUpload.create(t.getAttribute("data-command"),e,!0)}}};const mc=class extends Kl{static key="fileBrowser";static className="";constructor(t,e){super(t),this.title=this.$.lang.fileBrowser,this.icon="file_browser",this.onSelectfunction=null;const s={video:this.$.icons.video_thumbnail,audio:this.$.icons.audio_thumbnail,file:this.$.icons.file_thumbnail},i=this.$.icons.file_thumbnail;this.browser=new Xr(this,this.$,{title:this.$.lang.fileBrowser,data:e.data,url:e.url,headers:e.headers,searchUrl:e.searchUrl,searchHeaders:e.searchHeaders,selectorHandler:this.#zp.bind(this),columnSize:4,className:"se-file-browser",thumbnail:"function"==typeof e.thumbnail?e.thumbnail:t=>s[t.type]||i,props:[...new Set((e.props??[]).concat(["frame"]))],expand:e.expand})}open(t){this.onSelectfunction=t,this.browser.open()}close(){this.onSelectfunction=null,this.browser.close()}#zp(t){if(this.onSelectfunction)this.onSelectfunction(t);else{switch(t.getAttribute("data-type")){case"image":this.$.plugins.imageGallery.browser.selectorHandler(t);break;case"video":this.$.plugins.videoGallery.browser.selectorHandler(t);break;case"audio":this.$.plugins.audioGallery.browser.selectorHandler(t);break;case"file":this.$.plugins.fileGallery.browser.selectorHandler(t)}}}},fc={text:{default:"16px",list:[{title:"XX-Small",size:"8px"},{title:"X-Small",size:"10px"},{title:"Small",size:"13px"},{title:"Medium",size:"16px"},{title:"Large",size:"18px"},{title:"X-Large",size:"24px"},{title:"XX-Large",size:"32px"}]},px:{default:13,inc:1,min:8,max:72,list:[8,10,13,15,18,20,22,26,28,36,48,72]},pt:{default:10,inc:1,min:6,max:72,list:[6,8,10,12,14,18,22,26,32]},em:{default:1,inc:.1,min:.5,max:5,list:[.5,.75,1,1.25,1.5,1.75,2,2.5,3]},rem:{default:1,inc:.1,min:.5,max:5,list:[.5,.75,1,1.25,1.5,1.75,2,2.5,3]},vw:{inc:.1,min:.5,max:10,list:[2,3.5,4,4.5,6,8]},vh:{default:1.5,inc:.1,min:.5,max:10,list:[1,1.5,2,2.5,3,3.5,4]},"%":{default:100,inc:1,min:50,max:200,list:[50,70,90,100,120,140,160,180,200]}};class vc extends Ql{static key="fontSize";static className="se-btn-select se-btn-input se-btn-tool-font-size";#Pp;constructor(t,e){super(t),this.unitMap={...fc,...e.unitMap||{}},this.sizeUnit=/text/.test(e.sizeUnit)?"":e.sizeUnit||this.$.options.get("fontSizeUnits")[0];const s=this.unitMap[this.sizeUnit||"text"],i=function({lang:t},e,s,i){const n=e.list,o=e.default,r=i?t.default:"";let l='\n\t
    \n\t\t
      ';for(let t,e,i,a,h,c=0,d=n.length;c\n\t\t\t\t\n\t\t\t`;return l+="\n\t\t
    \n\t
    ",Pe.utils.createElement("DIV",{class:"se-dropdown se-list-layer se-list-font-size"},l)}(this.$,s,this.sizeUnit,e.showDefaultSizeLabel),n=!!this.sizeUnit&&(e.showIncDecControls??!1),o=!this.sizeUnit||(e.disableInput??!1);this.title=this.$.lang.fontSize,this.inner=!(o&&!n)&&(o?`${this.$.lang.fontSize}`:``),n?(this.beforeItem=Pe.utils.createElement("button",{class:"se-btn se-tooltip se-sub-btn",type:"button","data-command":vc.key,"data-type":"command","data-value":"dec"},`${this.$.icons.minus}${this.$.lang.decrease}`),this.afterItem=Pe.utils.createElement("button",{class:"se-btn se-tooltip se-sub-btn",type:"button","data-command":vc.key,"data-type":"command","data-value":"inc"},`${this.$.icons.plus}${this.$.lang.increase}`)):o?o&&!n&&(this.replaceButton=Pe.utils.createElement("button",{class:"se-btn se-tooltip se-btn-select se-btn-tool-font-size",type:"button","data-command":vc.key,"data-type":"dropdown"},`${this.$.lang.fontSize}${this.$.icons.arrow_down}${this.$.lang.fontSize}`),this.$.menu.initDropdownTarget({key:vc.key,type:"dropdown"},i)):(this.afterItem=Pe.utils.createElement("button",{class:"se-btn se-tooltip se-sub-arrow-btn",type:"button","data-command":vc.key,"data-type":"dropdown"},`${this.$.icons.arrow_down}${this.$.lang.fontSize}`),this.$.menu.initDropdownTarget({key:vc.key,type:"dropdown"},i)),this.currentSize="",this.sizeList=i.querySelectorAll("li button"),this.hasInputFocus=!1,this.isInputActive=!1,this.#Pp=o,this.$.menu.initDropdownTarget(vc,i)}active(t,e){if(!Pe.utils.hasClass(e,"__se__font_size"))return!1;let s="";if(t){if(this.$.format.isLine(t))return;if(s=Pe.utils.getStyle(t,"fontSize"))return this.#Dp(e,s),!0}else this.#Dp(e,this.#Fp());return!1}toolbarInputKeyDown({target:t,event:e}){const s=e.code;if(this.#Pp||Fe.isSpace(s))return void e.preventDefault();if(!/^(ArrowUp|ArrowDown|Enter)$/.test(s))return;const{value:i,unit:n}=this.#Hp(t);if(!i)return;const o=De.get(i),r=this.unitMap[n];let l=o;switch(s){case"ArrowUp":l+=r.inc,l>r.max&&(l=o);break;case"ArrowDown":l-=r.inc,ln?n:so?o:i;const r=Pe.utils.createElement("SPAN",{style:"font-size: "+i+s+";"});this.$.inline.apply(r,{stylesToModify:["font-size"],nodesToRemove:null,strictRemove:null})}else if(e){const t=Pe.utils.createElement("SPAN",{style:"font-size: "+e+";"});this.$.inline.apply(t,{stylesToModify:["font-size"],nodesToRemove:null,strictRemove:null})}else this.$.inline.apply(null,{stylesToModify:["font-size"],nodesToRemove:["span"],strictRemove:!0});this.$.menu.dropdownOff()}#Fp(){return this.$.frameContext.get("wwComputedStyle").fontSize}#Hp(t){if(!(t="string"==typeof t?t:t.parentElement.querySelector(".__se__font_size")))return{unit:this.sizeUnit,value:this.sizeUnit?0:""};const e="string"==typeof t?t:Pe.check.isInputElement(t)?t.value:t.textContent,s=this.sizeUnit?e.split(/(\d+)/):[e,""];let i=(s.pop()||"").trim().toLowerCase();i=this.$.options.get("fontSizeUnits").includes(i)?i:this.sizeUnit;const n=s.pop();return{unit:i,value:i?Number(n):n}}#Dp(t,e){return(t=t.parentElement.querySelector(".__se__font_size"))?Pe.check.isInputElement(t)?t.value=String(e):t.textContent=String(this.sizeUnit?e:this.unitMap.text.list.find((t=>t.size===e))?.title||e):0}}const bc=vc;const yc=class extends Ql{static key="pageNavigator";static className="se-btn-input se-btn-tool-pageNavigator";constructor(t){super(t),this.title=this.$.lang.pageNumber,this.inner=Pe.utils.createElement("input",{type:"number",class:"se-not-arrow-text",placeholder:"1",value:"1",min:"1"},null),this.afterItem=Pe.utils.createElement("span",{class:"se-btn se-sub-btn"},""),this.pageNum=1,this.totalPages=1,this.$.eventManager.addEvent(this.inner,"change",this.#qp.bind(this))}display(t,e){this.pageNum=t,this.totalPages=e,this.inner.value=String(t),this.afterItem.textContent=this.inner.max=String(e)}#qp(t){if(!this.$.frameContext.has("documentType_use_page"))return;const e=Pe.query.getEventTarget(t),s=Number(e.value)||1;this.$.frameContext.get("documentType").pageGo(s)}},{_w:wc}=Oe;class Cc extends ea{static key="anchor";static className="";static component(t){return Pe.check.isAnchor(t)&&t.hasAttribute("id")&&t.hasAttribute("data-se-anchor")?t:null}#Pc=null;#Wp=null;constructor(t){super(t),this.title=this.$.lang.anchor,this.icon="bookmark_anchor";const e=(new DOMParser).parseFromString(this.$.icons.bookmark_anchor,"image/svg+xml");this.bookmarkIcon=e.documentElement;const s=function({lang:t,icons:e}){const s=`\n\t
    \n\t`;return Pe.utils.createElement("DIV",{class:"se-controller se-controller-link"},s)}(this.$);this.displayId=s.querySelector(".se-controller-display"),this.controllerSelect=new Ii(this,this.$,s,{position:"bottom",disabled:!0},Cc.key);const i=function({lang:t,icons:e}){const s=`\n\t\t
    \n\t\t
    \n\t\t\t
    ${t.id}
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t\t`;return Pe.utils.createElement("DIV",{class:"se-controller se-controller-simple-input"},s)}(this.$);this.inputEl=i.querySelector("input"),this.controller=new Ii(this,this.$,i,{position:"bottom",disabled:!0,parents:[this.controllerSelect.form],parentsHide:!0},Cc.key)}show(){this.controller.open(this.#Wp=this.$.selection.getRange()),wc.setTimeout((()=>{this.inputEl.focus()}),0)}componentSelect(t){this.#Pc=t,this.displayId.textContent=t.getAttribute("id"),this.controllerSelect.open(t)}componentDeselect(){this.#Ts()}controllerAction(t){const e=t.getAttribute("data-command");if(!e)return;const s=this.#Pc;switch(e){case"submit":if(this.controller.close(),s)s.id=this.inputEl.value,this.$.component.select(s,Cc.key);else{const t=this.inputEl.value.trim();if(!t)return void this.inputEl.focus();const e=Pe.utils.createElement("A",{id:t,"data-se-anchor":this.inputEl.value,"data-se-non-link":"true",contenteditable:"false",class:"se-component se-inline-component"});this.$.component.insert(e,{insertBehavior:"none",scrollTo:!1});const s=this.$.selection.getNearRange(e);s?this.$.selection.setRange(s.container,s.offset,s.container,s.offset):this.$.component.select(e,Cc.key),this.#Ts()}break;case"cancel":this.controller.close(!s),this.#Wp&&this.$.selection.setRange(this.#Wp),this.#Ts(),s&&this.componentSelect(s);break;case"edit":this.inputEl.value=this.displayId.textContent,this.controllerSelect.hide(),this.controller.open(s),this.inputEl.focus();break;case"delete":{const t=this.$.selection.getNearRange(s);Pe.utils.removeItem(s),this.controllerSelect.close(!0),t&&this.$.selection.setRange(t.container,t.offset,t.container,t.offset),this.#Ts();break}}}#Ts(){this.#Pc=null,this.#Wp=null,this.inputEl.value="",this.displayId.textContent=""}}const _c={blockquote:sa,codeBlock:oa,exportPDF:aa,fileUpload:da,list_bulleted:pa,list_numbered:fa,autocomplete:wa,slashCommand:_a,align:xa,font:Sa,fontColor:Ta,backgroundColor:Na,list:Aa,table:wh,blockStyle:_h,hr:Ia,layout:xh,lineHeight:Sh,template:Th,paragraphStyle:Nh,textStyle:Ih,link:Lh,image:qh,video:Yh,audio:Qh,embed:ic,math:ac,drawing:cc,imageGallery:dc,videoGallery:uc,audioGallery:pc,fileGallery:gc,fileBrowser:mc,fontSize:bc,pageNavigator:yc,anchor:Cc};class kc{async modalAction(){return!0}modalOn(t){}modalInit(){}modalOff(t){}modalResize(){}}class xc{controllerAction(t){}controllerOn(t,e){}controllerClose(){}}class $c{browserInit(){}}class Sc{colorPickerAction(t){}colorPickerHueSliderOpen(){}colorPickerHueSliderClose(){}}class Ec{hueSliderAction(){}hueSliderCancelAction(){}}class Tc{componentSelect(t){}componentDeselect(t){}componentEdit(t){}async componentDestroy(t){}componentCopy(t){}}const Mc={contract:t,manager:e,ui:i};Object.defineProperty(window,"SUNEDITOR",{enumerable:!0,writable:!1,configurable:!1,value:{...jl,plugins:_c,modules:Mc,helper:Ve,interfaces:n}})})()})();