@kaushalparajuli/react-crud-ui 1.0.26 → 1.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -249,5 +249,5 @@ body{height: min-content; overflow: hidden;}
249
249
  </html>`}else u=c;e.element.code.style.display="block",e.element.wysiwygFrame.style.display="none",this._setCodeView(u)},toggleFullScreen:function(c){const u=e.element.topArea,p=e.element.toolbar,b=e.element.editorArea,y=e.element.wysiwygFrame,w=e.element.code,x=this._variable;this.controllersOff();const E=p.style.display==="none"||this._isInline&&!this._inlineToolbarAttr.isShow;x.isFullScreen?(x.isFullScreen=!1,y.style.cssText=x._wysiwygOriginCssText,w.style.cssText=x._codeOriginCssText,p.style.cssText="",b.style.cssText=x._editorAreaOriginCssText,u.style.cssText=x._originCssText,l.body.style.overflow=x._bodyOverflow,s.height==="auto"&&!s.codeMirrorEditor&&h._codeViewAutoHeight(),s.toolbarContainer&&s.toolbarContainer.appendChild(p),s.stickyToolbar>-1&&r.removeClass(p,"se-toolbar-sticky"),x._fullScreenAttrs.sticky&&!s.toolbarContainer&&(x._fullScreenAttrs.sticky=!1,e.element._stickyDummy.style.display="block",r.addClass(p,"se-toolbar-sticky")),this._isInline=x._fullScreenAttrs.inline,this._isBalloon=x._fullScreenAttrs.balloon,this._isInline&&h._showToolbarInline(),s.toolbarContainer&&r.removeClass(p,"se-toolbar-balloon"),h.onScroll_window(),c&&r.changeElement(c.firstElementChild,f.expansion),e.element.topArea.style.marginTop="",r.removeClass(this._styleCommandMap.fullScreen,"active")):(x.isFullScreen=!0,x._fullScreenAttrs.inline=this._isInline,x._fullScreenAttrs.balloon=this._isBalloon,(this._isInline||this._isBalloon)&&(this._isInline=!1,this._isBalloon=!1),s.toolbarContainer&&e.element.relative.insertBefore(p,b),u.style.position="fixed",u.style.top="0",u.style.left="0",u.style.width="100%",u.style.maxWidth="100%",u.style.height="100%",u.style.zIndex="2147483647",e.element._stickyDummy.style.display!==""&&(x._fullScreenAttrs.sticky=!0,e.element._stickyDummy.style.display="none",r.removeClass(p,"se-toolbar-sticky")),x._bodyOverflow=l.body.style.overflow,l.body.style.overflow="hidden",x._editorAreaOriginCssText=b.style.cssText,x._wysiwygOriginCssText=y.style.cssText,x._codeOriginCssText=w.style.cssText,b.style.cssText=p.style.cssText="",y.style.cssText=(y.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/)||[""])[0]+s._editorStyles.editor,w.style.cssText=(w.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/)||[""])[0],p.style.width=y.style.height=w.style.height="100%",p.style.position="relative",p.style.display="block",x.innerHeight_fullScreen=a.innerHeight-p.offsetHeight,b.style.height=x.innerHeight_fullScreen-s.fullScreenOffset+"px",c&&r.changeElement(c.firstElementChild,f.reduction),s.iframe&&s.height==="auto"&&(b.style.overflow="auto",this._iframeAutoHeight()),e.element.topArea.style.marginTop=s.fullScreenOffset+"px",r.addClass(this._styleCommandMap.fullScreen,"active")),E&&v.toolbar.hide(),typeof v.toggleFullScreen=="function"&&v.toggleFullScreen(this._variable.isFullScreen,this)},print:function(){const c=r.createElement("IFRAME");c.style.display="none",l.body.appendChild(c);const u=s.printTemplate?s.printTemplate.replace(/\{\{\s*contents\s*\}\}/i,this.getContents(!0)):this.getContents(!0),p=r.getIframeDocument(c),b=this._wd;if(s.iframe){const y=s._printClass!==null?'class="'+s._printClass+'"':s.fullPage?r.getAttributesToString(b.body,["contenteditable"]):'class="'+s._editableClass+'"';p.write("<!DOCTYPE html><html><head>"+b.head.innerHTML+"</head><body "+y+">"+u+"</body></html>")}else{const y=l.head.getElementsByTagName("link"),w=l.head.getElementsByTagName("style");let x="";for(let E=0,k=y.length;E<k;E++)x+=y[E].outerHTML;for(let E=0,k=w.length;E<k;E++)x+=w[E].outerHTML;p.write("<!DOCTYPE html><html><head>"+x+'</head><body class="'+(s._printClass!==null?s._printClass:s._editableClass)+'">'+u+"</body></html>")}this.showLoading(),a.setTimeout(function(){try{if(c.focus(),r.isIE_Edge||r.isChromium||l.documentMode||a.StyleMedia)try{c.contentWindow.document.execCommand("print",!1,null)}catch{c.contentWindow.print()}else c.contentWindow.print()}catch(y){throw Error("[SUNEDITOR.core.print.fail] error: "+y)}finally{d.closeLoading(),r.removeItem(c)}},1e3)},preview:function(){d.submenuOff(),d.containerOff(),d.controllersOff();const c=s.previewTemplate?s.previewTemplate.replace(/\{\{\s*contents\s*\}\}/i,this.getContents(!0)):this.getContents(!0),u=a.open("","_blank");u.mimeType="text/html";const p=this._wd;if(s.iframe){const b=s._printClass!==null?'class="'+s._printClass+'"':s.fullPage?r.getAttributesToString(p.body,["contenteditable"]):'class="'+s._editableClass+'"';u.document.write("<!DOCTYPE html><html><head>"+p.head.innerHTML+"<style>body {overflow:auto !important; margin: 10px auto !important; height:auto !important; outline:1px dashed #ccc;}</style></head><body "+b+">"+c+"</body></html>")}else{const b=l.head.getElementsByTagName("link"),y=l.head.getElementsByTagName("style");let w="";for(let x=0,E=b.length;x<E;x++)w+=b[x].outerHTML;for(let x=0,E=y.length;x<E;x++)w+=y[x].outerHTML;u.document.write('<!DOCTYPE html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"><title>'+i.toolbar.preview+"</title>"+w+'</head><body class="'+(s._printClass!==null?s._printClass:s._editableClass)+'" style="margin:10px auto !important; height:auto !important; outline:1px dashed #ccc;">'+c+"</body></html>")}},setDir:function(c){const u=c==="rtl",p=this._prevRtl!==u;this._prevRtl=s.rtl=u,p&&(this.plugins.align&&this.plugins.align.exchangeDir.call(this),e.tool.indent&&r.changeElement(e.tool.indent.firstElementChild,f.indent),e.tool.outdent&&r.changeElement(e.tool.outdent.firstElementChild,f.outdent));const b=e.element;u?(r.addClass(b.topArea,"se-rtl"),r.addClass(b.wysiwygFrame,"se-rtl")):(r.removeClass(b.topArea,"se-rtl"),r.removeClass(b.wysiwygFrame,"se-rtl"));const y=r.getListChildren(b.wysiwyg,function(x){return r.isFormatElement(x)&&(x.style.marginRight||x.style.marginLeft||x.style.textAlign)});for(let x=0,E=y.length,k,N,T;x<E;x++)k=y[x],T=k.style.marginRight,N=k.style.marginLeft,(T||N)&&(k.style.marginRight=N,k.style.marginLeft=T),T=k.style.textAlign,T==="left"?k.style.textAlign="right":T==="right"&&(k.style.textAlign="left");const w=e.tool;w.dir&&(r.changeTxt(w.dir.querySelector(".se-tooltip-text"),i.toolbar[s.rtl?"dir_ltr":"dir_rtl"]),r.changeElement(w.dir.firstElementChild,f[s.rtl?"dir_ltr":"dir_rtl"])),w.dir_ltr&&(u?r.removeClass(w.dir_ltr,"active"):r.addClass(w.dir_ltr,"active")),w.dir_rtl&&(u?r.addClass(w.dir_rtl,"active"):r.removeClass(w.dir_rtl,"active"))},setContents:function(c){this.removeRange();const u=c==null?"":this.convertContentsForEditor(c,null,null);if(!this._variable.isCodeView)e.element.wysiwyg.innerHTML=u,this._resetComponents(),this.history.push(!1);else{const p=this.convertHTMLForCodeView(u,!1);this._setCodeView(p)}},setIframeContents:function(c){if(!s.iframe)return!1;c.head&&(this._wd.head.innerHTML=this.options.__allowedScriptTag?c.head:c.head.replace(this.__scriptTagRegExp,"")),c.body&&(this._wd.body.innerHTML=this.convertContentsForEditor(c.body)),this._resetComponents()},getContents:function(c){const u=this.cleanHTML(e.element.wysiwyg.innerHTML,null,null),p=r.createElement("DIV");p.innerHTML=u;const b=r.getListChildren(p,function(y){return y.hasAttribute("contenteditable")});for(let y=0,w=b.length;y<w;y++)b[y].removeAttribute("contenteditable");if(s.fullPage&&!c){const y=r.getAttributesToString(this._wd.body,["contenteditable"]);return"<!DOCTYPE html><html>"+this._wd.head.outerHTML+"<body "+y+">"+p.innerHTML+"</body></html>"}else return p.innerHTML},getFullContents:function(c){return'<div class="sun-editor-editable'+(s.rtl?" se-rtl":"")+'">'+this.getContents(c)+"</div>"},_makeLine:function(c,u){const p=s.defaultTag;if(c.nodeType===1){if(this.__disallowedTagNameRegExp.test(c.nodeName))return"";if(/__se__tag/.test(c.className))return c.outerHTML;const b=r.getListChildNodes(c,function(y){return r.isSpanWithoutAttr(y)&&!r.getParentElement(y,r.isNotCheckingNode)})||[];for(let y=b.length-1;y>=0;y--)b[y].outerHTML=b[y].innerHTML;return!u||r.isFormatElement(c)||r.isRangeFormatElement(c)||r.isComponent(c)||r.isFigures(c)||r.isAnchor(c)&&r.isMedia(c.firstElementChild)?r.isSpanWithoutAttr(c)?c.innerHTML:c.outerHTML:"<"+p+">"+(r.isSpanWithoutAttr(c)?c.innerHTML:c.outerHTML)+"</"+p+">"}if(c.nodeType===3){if(!u)return r._HTMLConvertor(c.textContent);const b=c.textContent.split(/\n/g);let y="";for(let w=0,x=b.length,E;w<x;w++)E=b[w].trim(),E.length>0&&(y+="<"+p+">"+r._HTMLConvertor(E)+"</"+p+">");return y}return c.nodeType===8&&this._allowHTMLComments?"<!--"+c.textContent.trim()+"-->":""},_tagConvertor:function(c){if(!this._disallowedTextTagsRegExp)return c;const u=s._textTagsMap;return c.replace(this._disallowedTextTagsRegExp,function(p,b,y,w){return b+(typeof u[y]=="string"?u[y]:y)+(w?" "+w:"")})},_deleteDisallowedTags:function(c){return c=c.replace(this.__disallowedTagsRegExp,"").replace(/<[a-z0-9]+\:[a-z0-9]+[^>^\/]*>[^>]*<\/[a-z0-9]+\:[a-z0-9]+>/gi,""),/\bfont\b/i.test(this.options._editorTagsWhitelist)||(c=c.replace(/(<\/?)font(\s?)/gi,"$1span$2")),c.replace(this.editorTagsWhitelistRegExp,"").replace(this.editorTagsBlacklistRegExp,"")},_convertFontSize:function(c,u){const p=this._w.Math,b=u.match(/(\d+(?:\.\d+)?)(.+)/),y=b?b[1]*1:r.fontValueMap[u],w=b?b[2]:"rem";let x=y;switch(/em/.test(w)?x=p.round(y/.0625):w==="pt"?x=p.round(y*1.333):w==="%"&&(x=y/100),c){case"em":case"rem":case"%":return(x*.0625).toFixed(2)+c;case"pt":return p.round(x/1.333)+c;default:return x+c}},_cleanStyle:function(c,u,p){let b=(c.match(/style\s*=\s*(?:"|')[^"']*(?:"|')/)||[])[0];if(/span/i.test(p)&&!b&&(c.match(/<[^\s]+\s(.+)/)||[])[1]){const y=(c.match(/\ssize="([^"]+)"/i)||[])[1],w=(c.match(/\sface="([^"]+)"/i)||[])[1],x=(c.match(/\scolor="([^"]+)"/i)||[])[1];(y||w||x)&&(b='style="'+(y?"font-size:"+this.util.getNumber(y/3.333,1)+"rem;":"")+(w?"font-family:"+w+";":"")+(x?"color:"+x+";":"")+'"')}if(b){u||(u=[]);const y=b.replace(/&quot;/g,"").match(this._cleanStyleRegExp[p]);if(y){const w=[];for(let x=0,E=y.length,k;x<E;x++)if(k=y[x].match(/([a-zA-Z0-9-]+)(:)([^"']+)/),k&&!/inherit|initial|revert|unset/i.test(k[3])){const N=r.kebabToCamelCase(k[1].trim()),T=this.wwComputedStyle[N]?this.wwComputedStyle[N].replace(/"/g,""):"",R=k[3].trim();switch(N){case"fontFamily":if(!s.plugins.font||s.font.indexOf(R)===-1)continue;break;case"fontSize":if(!s.plugins.fontSize)continue;this._cleanStyleRegExp.fontSizeUnit.test(k[0])||(k[0]=k[0].replace((k[0].match(/:\s*([^;]+)/)||[])[1],this._convertFontSize.bind(this,s.fontSizeUnit)));break;case"color":if(!s.plugins.fontColor||/rgba\(([0-9]+\s*,\s*){3}0\)|windowtext/i.test(R))continue;break;case"backgroundColor":if(!s.plugins.hiliteColor||/rgba\(([0-9]+\s*,\s*){3}0\)|windowtext/i.test(R))continue;break}T!==R&&w.push(k[0])}w.length>0&&u.push('style="'+w.join(";")+'"')}}return u},_cleanTags:function(c,u,p){if(/^<[a-z0-9]+\:[a-z0-9]+/i.test(u))return u;let b=null;const y=p.match(/(?!<)[a-zA-Z0-9\-]+/)[0].toLowerCase(),w=this._attributesTagsBlacklist[y];u=u.replace(/\s(?:on[a-z]+)\s*=\s*(")[^"]*\1/ig,""),w?u=u.replace(w,""):u=u.replace(this._attributesBlacklistRegExp,"");const x=this._attributesTagsWhitelist[y];if(x?b=u.match(x):b=u.match(c?this._attributesWhitelistRegExp:this._attributesWhitelistRegExp_all_data),c||y==="span"||y==="li"||this._cleanStyleRegExp[y])if(y==="a"){const E=u.match(/(?:(?:id|name)\s*=\s*(?:"|')[^"']*(?:"|'))/g);E&&(b||(b=[]),b.push(E[0]))}else(!b||!/style=/i.test(b.toString()))&&((y==="span"||y==="li")&&(b=this._cleanStyle(u,b,"span")),this._cleanStyleRegExp[y]?b=this._cleanStyle(u,b,y):/^(P|DIV|H[1-6]|PRE)$/i.test(y)&&(b=this._cleanStyle(u,b,"format")));else{const E=u.match(/style\s*=\s*(?:"|')[^"']*(?:"|')/);E&&!b?b=[E[0]]:E&&!b.some(function(k){return/^style/.test(k.trim())})&&b.push(E[0])}if(r.isFigures(y)){const E=u.match(/style\s*=\s*(?:"|')[^"']*(?:"|')/);b||(b=[]),E&&b.push(E[0])}if(b)for(let E=0,k=b.length,N;E<k;E++)N=/^(?:href|src)\s*=\s*('|"|\s)*javascript\s*\:/i.test(b[E].trim())?"":b[E],p+=(/^\s/.test(N)?"":" ")+N;return p},_editFormat:function(c){let u="",p;const b=c.childNodes;for(let y=0,w=b.length,x;y<w;y++)x=b[y],x.nodeType===8?u+="<!-- "+x.textContent+" -->":!r.isFormatElement(x)&&!r.isRangeFormatElement(x)&&!r.isComponent(x)&&!/meta/i.test(x.nodeName)?(p||(p=r.createElement(s.defaultTag)),r.isTextStyleElement(x)&&x.removeAttribute("style"),p.appendChild(x),y--,w--):(p&&(u+=p.outerHTML,p=null),u+=x.outerHTML);return p&&(u+=p.outerHTML),l.createRange().createContextualFragment(u)},_convertListCell:function(c){let u="";for(let p=0,b=c.length,y;p<b;p++)y=c[p],y.nodeType===1?r.isList(y)?u+=y.innerHTML:r.isListCell(y)?u+=y.outerHTML:r.isFormatElement(y)?u+="<li>"+(y.innerHTML.trim()||"<br>")+"</li>":r.isRangeFormatElement(y)&&!r.isTable(y)?u+=this._convertListCell(y):u+="<li>"+y.outerHTML+"</li>":u+="<li>"+(y.textContent||"<br>")+"</li>";return u},_isFormatData:function(c){let u=!1;for(let p=0,b=c.length,y;p<b;p++)if(y=c[p],y.nodeType===1&&!r.isTextStyleElement(y)&&!r.isBreak(y)&&!this.__disallowedTagNameRegExp.test(y.nodeName)){u=!0;break}return u},cleanHTML:function(c,u,p){if(!s.strictMode)return r.htmlCompress(c);c=this._deleteDisallowedTags(this._parser.parseFromString(r.htmlCompress(c),"text/html").body.innerHTML).replace(/(<[a-zA-Z0-9\-]+)[^>]*(?=>)/g,this._cleanTags.bind(this,!0)).replace(/<br\/?>$/i,"");const b=l.createRange().createContextualFragment(c);try{r._consistencyCheckOfHTML(b,this._htmlCheckWhitelistRegExp,this._htmlCheckBlacklistRegExp,this._classNameFilter,s.strictHTMLValidation)}catch(E){console.warn("[SUNEDITOR.cleanHTML.consistencyCheck.fail] "+E)}if(this.managedTagsInfo&&this.managedTagsInfo.query){const E=b.querySelectorAll(this.managedTagsInfo.query);for(let k=0,N=E.length,T,R;k<N;k++){R=[].slice.call(E[k].classList);for(let M=0,A=R.length;M<A;M++)if(T=this.managedTagsInfo.map[R[M]],T){T(E[k]);break}}}let y=b.childNodes,w="";const x=this._isFormatData(y);x&&(y=this._editFormat(b).childNodes);for(let E=0,k=y.length,N;E<k;E++){if(N=y[E],this.__allowedScriptRegExp.test(N.nodeName)){w+=N.outerHTML;continue}w+=this._makeLine(N,x)}return w=r.htmlRemoveWhiteSpace(w),w?(u&&(w=w.replace(typeof u=="string"?r.createTagsWhitelist(u):u,"")),p&&(w=w.replace(typeof p=="string"?r.createTagsBlacklist(p):p,""))):w=c,this._tagConvertor(w)},convertContentsForEditor:function(c){if(!s.strictMode)return r.htmlCompress(c);c=this._deleteDisallowedTags(this._parser.parseFromString(r.htmlCompress(c),"text/html").body.innerHTML).replace(/(<[a-zA-Z0-9\-]+)[^>]*(?=>)/g,this._cleanTags.bind(this,!0));const u=l.createRange().createContextualFragment(c);try{r._consistencyCheckOfHTML(u,this._htmlCheckWhitelistRegExp,this._htmlCheckBlacklistRegExp,this._classNameFilter,s.strictHTMLValidation)}catch(w){console.warn("[SUNEDITOR.convertContentsForEditor.consistencyCheck.fail] "+w)}if(this.managedTagsInfo&&this.managedTagsInfo.query){const w=u.querySelectorAll(this.managedTagsInfo.query);for(let x=0,E=w.length,k,N;x<E;x++){N=[].slice.call(w[x].classList);for(let T=0,R=N.length;T<R;T++)if(k=this.managedTagsInfo.map[N[T]],k){k(w[x]);break}}}const p=u.childNodes;let b="",y=null;for(let w=0,x;w<p.length;w++){if(x=p[w],this.__allowedScriptRegExp.test(x.nodeName)){b+=x.outerHTML;continue}if(!r.isFormatElement(x)&&!r.isRangeFormatElement(x)&&!r.isComponent(x)&&!r.isFigures(x)&&x.nodeType!==8&&!/__se__tag/.test(x.className)){if(y||(y=r.createElement(s.defaultTag)),y.appendChild(x),w--,p[w+1]&&!r.isFormatElement(p[w+1]))continue;x=y,y=null}y&&(b+=this._makeLine(y,!0),y=null),b+=this._makeLine(x,!0)}return y&&(b+=this._makeLine(y,!0)),b.length===0?"<"+s.defaultTag+"><br></"+s.defaultTag+">":(b=r.htmlRemoveWhiteSpace(b),this._tagConvertor(b))},convertHTMLForCodeView:function(c,u){let p="";const b=a.RegExp,y=new b("^(BLOCKQUOTE|PRE|TABLE|THEAD|TBODY|TR|TH|TD|OL|UL|IMG|IFRAME|VIDEO|AUDIO|FIGURE|FIGCAPTION|HR|BR|CANVAS|SELECT)$","i"),w=typeof c=="string"?l.createRange().createContextualFragment(c):c,x=(function(N){return this.isFormatElement(N)||this.isComponent(N)}).bind(r),E=u?"":`
250
250
  `;let k=u?0:this._variable.codeIndent*1;return k=k>0?new a.Array(k+1).join(" "):"",function N(T,R){const M=T.childNodes,A=y.test(T.nodeName),D=A?R:"";for(let $=0,H=M.length,j,F,z,P,B,L;$<H;$++){if(j=M[$],P=y.test(j.nodeName),F=P?E:"",z=x(j)&&!A&&!/^(TH|TD)$/i.test(T.nodeName)?E:"",j.nodeType===8){p+=`
251
251
  <!-- `+j.textContent.trim()+" -->"+F;continue}if(j.nodeType===3){r.isList(j.parentElement)||(p+=r._HTMLConvertor(/^\n+$/.test(j.data)?"":j.data));continue}if(j.childNodes.length===0){p+=(/^HR$/i.test(j.nodeName)?E:"")+(/^PRE$/i.test(j.parentElement.nodeName)&&/^BR$/i.test(j.nodeName)?"":D)+j.outerHTML+F;continue}j.outerHTML?(B=j.nodeName.toLowerCase(),L=D||P?R:"",p+=(z||(A?"":F))+L+j.outerHTML.match(b("<"+B+"[^>]*>","i"))[0]+F,N(j,R+k),p+=(/\n$/.test(p)?L:"")+"</"+B+">"+(z||F||A||/^(TH|TD)$/i.test(j.nodeName)?E:"")):p+=new a.XMLSerializer().serializeToString(j)}}(w,""),p.trim()+E},addDocEvent:function(c,u,p){l.addEventListener(c,u,p),s.iframe&&this._wd.addEventListener(c,u)},removeDocEvent:function(c,u){l.removeEventListener(c,u),s.iframe&&this._wd.removeEventListener(c,u)},_charCount:function(c){const u=s.maxCharCount,p=s.charCounterType;let b=0;if(c&&(b=this.getCharLength(c,p)),this._setCharCount(),u>0){let y=!1;const w=v.getCharCount(p);if(w>u){if(y=!0,b>0){this._editorRange();const x=this.getRange(),E=x.endOffset-1,k=this.getSelectionNode().textContent,N=x.endOffset-(w-u);this.getSelectionNode().textContent=k.slice(0,N<0?0:N)+k.slice(x.endOffset,k.length),this.setRange(x.endContainer,E,x.endContainer,E)}}else w+b>u&&(y=!0);if(y&&(this._callCounterBlink(),b>0))return!1}return!0},checkCharCount:function(c,u){if(s.maxCharCount){const p=u||s.charCounterType,b=this.getCharLength(typeof c=="string"?c:this._charTypeHTML&&c.nodeType===1?c.outerHTML:c.textContent,p);if(b>0&&b+v.getCharCount(p)>s.maxCharCount)return this._callCounterBlink(),!1}return!0},getCharLength:function(c,u){return/byte/.test(u)?r.getByteLength(c):c.length},resetResponsiveToolbar:function(){d.controllersOff();const c=h._responsiveButtonSize;if(c){let u=0;(d._isBalloon||d._isInline)&&s.toolbarWidth==="auto"?u=e.element.topArea.offsetWidth:u=e.element.toolbar.offsetWidth;let p="default";for(let b=1,y=c.length;b<y;b++)if(u<c[b]){p=c[b]+"";break}h._responsiveCurrentSize!==p&&(h._responsiveCurrentSize=p,v.setToolbarButtons(h._responsiveButtons[p]))}},_setCharCount:function(){e.element.charCounter&&a.setTimeout((function(c,u){this.textContent&&c&&(this.textContent=c.getCharCount(u.charCounterType))}).bind(e.element.charCounter,v,s),0)},_callCounterBlink:function(){const c=e.element.charWrapper;c&&!r.hasClass(c,"se-blink")&&(r.addClass(c,"se-blink"),a.setTimeout(function(){r.removeClass(c,"se-blink")},600))},_checkComponents:function(){for(let c=0,u=this._fileInfoPluginsCheck.length;c<u;c++)this._fileInfoPluginsCheck[c]()},_resetComponents:function(){for(let c=0,u=this._fileInfoPluginsReset.length;c<u;c++)this._fileInfoPluginsReset[c]()},_setCodeView:function(c){s.codeMirrorEditor?s.codeMirrorEditor.getDoc().setValue(c):e.element.code.value=c},_getCodeView:function(){return s.codeMirrorEditor?s.codeMirrorEditor.getDoc().getValue():e.element.code.value},_setKeyEffect:function(c){const u=this.commandMap,p=this.activePlugins;for(let b in u)c.indexOf(b)>-1||!r.hasOwn(u,b)||(p.indexOf(b)>-1?n[b].active.call(this,null):u.OUTDENT&&/^OUTDENT$/i.test(b)?r.isImportantDisabled(u.OUTDENT)||u.OUTDENT.setAttribute("disabled",!0):u.INDENT&&/^INDENT$/i.test(b)?r.isImportantDisabled(u.INDENT)||u.INDENT.removeAttribute("disabled"):r.removeClass(u[b],"active"))},_init:function(c,u){const p=a.RegExp;this._ww=s.iframe?e.element.wysiwygFrame.contentWindow:a,this._wd=l,this._charTypeHTML=s.charCounterType==="byte-html",this.wwComputedStyle=a.getComputedStyle(e.element.wysiwyg),this._editorHeight=e.element.wysiwygFrame.offsetHeight,this._editorHeightPadding=r.getNumber(this.wwComputedStyle.getPropertyValue("padding-top"))+r.getNumber(this.wwComputedStyle.getPropertyValue("padding-bottom")),this._classNameFilter=(function(P){return this.test(P)?P:""}).bind(s.allowedClassNames);const b=s.__allowedScriptTag?"":"script|";if(this.__scriptTagRegExp=new p("<(script)[^>]*>([\\s\\S]*?)<\\/\\1>|<script[^>]*\\/?>","gi"),this.__disallowedTagsRegExp=new p("<("+b+"style)[^>]*>([\\s\\S]*?)<\\/\\1>|<("+b+"style)[^>]*\\/?>","gi"),this.__disallowedTagNameRegExp=new p("^("+b+"meta|link|style|[a-z]+:[a-z]+)$","i"),this.__allowedScriptRegExp=new p("^"+(s.__allowedScriptTag?"script":"")+"$","i"),!s.iframe&&typeof a.ShadowRoot=="function"){let P=e.element.wysiwygFrame;for(;P;){if(P.shadowRoot){this._shadowRoot=P.shadowRoot;break}else if(P instanceof a.ShadowRoot){this._shadowRoot=P;break}P=P.parentNode}this._shadowRoot&&(this._shadowRootControllerEventTarget=[])}const y=a.Object.keys(s._textTagsMap),w=s.addTagsWhitelist?s.addTagsWhitelist.split("|").filter(function(P){return/b|i|ins|s|strike/i.test(P)}):[];for(let P=0;P<w.length;P++)y.splice(y.indexOf(w[P].toLowerCase()),1);this._disallowedTextTagsRegExp=y.length===0?null:new p("(<\\/?)("+y.join("|")+")\\b\\s*([^>^<]+)?\\s*(?=>)","gi");const x=function(P,B){return P?P==="*"?"[a-z-]+":B?P+"|"+B:P:"^"},N="contenteditable|colspan|rowspan|target|href|download|rel|src|alt|class|type|origin-size"+"|controls|autoplay|loop|muted|poster|preload|playsinline"+"|allowfullscreen|sandbox|loading|allow|referrerpolicy|frameborder|scrolling",T="data-format|data-size|data-file-size|data-file-name|data-origin|data-align|data-image-link|data-rotate|data-proportion|data-percentage|data-exp|data-font-size";this._allowHTMLComments=s._editorTagsWhitelist.indexOf("//")>-1||s._editorTagsWhitelist==="*",this._htmlCheckWhitelistRegExp=new p("^("+x(s._editorTagsWhitelist.replace("|//",""),"")+")$","i"),this._htmlCheckBlacklistRegExp=new p("^("+(s.tagsBlacklist||"^")+")$","i"),this.editorTagsWhitelistRegExp=r.createTagsWhitelist(x(s._editorTagsWhitelist.replace("|//","|<!--|-->"),"")),this.editorTagsBlacklistRegExp=r.createTagsBlacklist(s.tagsBlacklist.replace("|//","|<!--|-->")),this.pasteTagsWhitelistRegExp=r.createTagsWhitelist(x(s.pasteTagsWhitelist,"")),this.pasteTagsBlacklistRegExp=r.createTagsBlacklist(s.pasteTagsBlacklist);const R='\\s*=\\s*(")[^"]*\\1',M=s.attributesWhitelist;let A={},D="";if(M)for(let P in M)!r.hasOwn(M,P)||/^on[a-z]+$/i.test(M[P])||(P==="all"?D=x(M[P],N):A[P]=new p("\\s(?:"+x(M[P],N)+")"+R,"ig"));this._attributesWhitelistRegExp=new p("\\s(?:"+(D||N+"|"+T)+")"+R,"ig"),this._attributesWhitelistRegExp_all_data=new p("\\s(?:"+((D||N)+"|data-[a-z0-9\\-]+")+")"+R,"ig"),this._attributesTagsWhitelist=A;const $=s.attributesBlacklist;if(A={},D="",$)for(let P in $)r.hasOwn($,P)&&(P==="all"?D=x($[P],""):A[P]=new p("\\s(?:"+x($[P],"")+")"+R,"ig"));this._attributesBlacklistRegExp=new p("\\s(?:"+(D||"^")+")"+R,"ig"),this._attributesTagsBlacklist=A,this._isInline=/inline/i.test(s.mode),this._isBalloon=/balloon|balloon-always/i.test(s.mode),this._isBalloonAlways=/balloon-always/i.test(s.mode),this._cachingButtons(),this._fileInfoPluginsCheck=[],this._fileInfoPluginsReset=[],this.managedTagsInfo={query:"",map:{}};const H=[];this.activePlugins=[],this._fileManager.tags=[],this._fileManager.pluginMap={};let j=[],F,z;for(let P in n)if(r.hasOwn(n,P)){if(F=n[P],z=t[P],(F.active||F.action)&&z&&this.callPlugin(P,null,z),typeof F.checkFileInfo=="function"&&typeof F.resetFileInfo=="function"&&(this.callPlugin(P,null,z),this._fileInfoPluginsCheck.push(F.checkFileInfo.bind(this)),this._fileInfoPluginsReset.push(F.resetFileInfo.bind(this))),a.Array.isArray(F.fileTags)){const B=F.fileTags;this.callPlugin(P,null,z),this._fileManager.tags=this._fileManager.tags.concat(B),j.push(P);for(let L=0,U=B.length;L<U;L++)this._fileManager.pluginMap[B[L].toLowerCase()]=P}if(F.managedTags){const B=F.managedTags();H.push("."+B.className),this.managedTagsInfo.map[B.className]=B.method.bind(this)}}this.managedTagsInfo.query=H.toString(),this._fileManager.queryString=this._fileManager.tags.join(","),this._fileManager.regExp=new p("^("+(this._fileManager.tags.join("|")||"^")+")$","i"),this._fileManager.pluginRegExp=new p("^("+(j.length===0?"^":j.join("|"))+")$","i"),this._variable._originCssText=e.element.topArea.style.cssText,this._placeholder=e.element.placeholder,this._lineBreaker=e.element.lineBreaker,this._lineBreakerButton=this._lineBreaker.querySelector("button"),this.history=kC(this,this._onChange_historyStack.bind(this)),this.addModule([Ia]),s.iframe&&(this._wd=e.element.wysiwygFrame.contentDocument,e.element.wysiwyg=this._wd.body,s._editorStyles.editor&&(e.element.wysiwyg.style.cssText=s._editorStyles.editor),s.height==="auto"&&(this._iframeAuto=this._wd.body)),this._initWysiwygArea(c,u)},_cachingButtons:function(){this.codeViewDisabledButtons=e.element._buttonTray.querySelectorAll('.se-menu-list button[data-display]:not([class~="se-code-view-enabled"]):not([data-display="MORE"])'),this.resizingDisabledButtons=e.element._buttonTray.querySelectorAll('.se-menu-list button[data-display]:not([class~="se-resizing-enabled"]):not([data-display="MORE"])');const c=e.tool,u=this.commandMap;u.INDENT=c.indent,u.OUTDENT=c.outdent,u[s.textTags.bold.toUpperCase()]=c.bold,u[s.textTags.underline.toUpperCase()]=c.underline,u[s.textTags.italic.toUpperCase()]=c.italic,u[s.textTags.strike.toUpperCase()]=c.strike,u[s.textTags.sub.toUpperCase()]=c.subscript,u[s.textTags.sup.toUpperCase()]=c.superscript,this._styleCommandMap={fullScreen:c.fullScreen,showBlocks:c.showBlocks,codeView:c.codeView},this._saveButtonStates()},_initWysiwygArea:function(c,u){e.element.wysiwyg.innerHTML=c?u:this.convertContentsForEditor((typeof u=="string"?u:/^TEXTAREA$/i.test(e.element.originElement.nodeName)?e.element.originElement.value:e.element.originElement.innerHTML)||"")},_resourcesStateChange:function(){this._iframeAutoHeight(),this._checkPlaceholder()},_onChange_historyStack:function(){this.hasFocus&&h._applyTagEffects(),this._variable.isChanged=!0,e.tool.save&&e.tool.save.removeAttribute("disabled"),v.onChange&&v.onChange(this.getContents(!0),this),e.element.toolbar.style.display==="block"&&h._showToolbarBalloon()},_iframeAutoHeight:function(){this._iframeAuto?a.setTimeout(function(){const c=d._iframeAuto.offsetHeight;e.element.wysiwygFrame.style.height=c+"px",r.isResizeObserverSupported||d.__callResizeFunction(c,null)}):r.isResizeObserverSupported||d.__callResizeFunction(e.element.wysiwygFrame.offsetHeight,null)},__callResizeFunction:function(c,u){c=c===-1?u.borderBoxSize&&u.borderBoxSize[0]?u.borderBoxSize[0].blockSize:u.contentRect.height+this._editorHeightPadding:c,this._editorHeight!==c&&(typeof v.onResizeEditor=="function"&&v.onResizeEditor(c,this._editorHeight,d,u),this._editorHeight=c)},_checkPlaceholder:function(){if(this._placeholder){if(this._variable.isCodeView){this._placeholder.style.display="none";return}const c=e.element.wysiwyg;!r.onlyZeroWidthSpace(c.textContent)||c.querySelector(r._allowedEmptyNodeList)||(c.innerText.match(/\n/g)||"").length>1?this._placeholder.style.display="none":this._placeholder.style.display="block"}},_setDefaultFormat:function(c){if(this._fileManager.pluginRegExp.test(this.currentControllerName))return;const u=this.getRange(),p=u.commonAncestorContainer,b=u.startContainer,y=r.getRangeFormatElement(p,null);let w,x,E;const k=r.getParentElement(p,r.isComponent);if(!(k&&!r.isTable(k))){if(p.nodeType===1&&p.getAttribute("data-se-embed")==="true"){let N=p.nextElementSibling;r.isFormatElement(N)||(N=this.appendFormatTag(p,s.defaultTag)),this.setRange(N.firstChild,0,N.firstChild,0);return}if(!((r.isRangeFormatElement(b)||r.isWysiwygDiv(b))&&(r.isComponent(b.children[u.startOffset])||r.isComponent(b.children[u.startOffset-1])))){if(r.getParentElement(p,r.isNotCheckingNode))return null;if(y){E=r.createElement(c||s.defaultTag),E.innerHTML=y.innerHTML,E.childNodes.length===0&&(E.innerHTML=r.zeroWidthSpace),y.innerHTML=E.outerHTML,E=y.firstChild,w=r.getEdgeChildNodes(E,null).sc,w||(w=r.createTextNode(r.zeroWidthSpace),E.insertBefore(w,E.firstChild)),x=w.textContent.length,this.setRange(w,x,w,x);return}if(r.isRangeFormatElement(p)&&p.childNodes.length<=1){let N=null;p.childNodes.length===1&&r.isBreak(p.firstChild)?N=p.firstChild:(N=r.createTextNode(r.zeroWidthSpace),p.appendChild(N)),this.setRange(N,1,N,1);return}try{if(p.nodeType===3&&(E=r.createElement(c||s.defaultTag),p.parentNode.insertBefore(E,p),E.appendChild(p)),r.isWysiwygDiv(p)){E=r.createElement(c||s.defaultTag),E.innerHTML=p.innerHTML,p.innerHTML="",p.appendChild(E),this.effectNode=null,this.setRange(E,1,E,1);return}if(E&&(r.isBreak(E.nextSibling)&&r.removeItem(E.nextSibling),r.isBreak(E.previousSibling)&&r.removeItem(E.previousSibling)),r.isBreak(w)){const N=r.createTextNode(r.zeroWidthSpace);w.parentNode.insertBefore(N,w),w=N}}catch{this.execCommand("formatBlock",!1,c||s.defaultTag),this.removeRange(),this._editorRange(),this.effectNode=null;return}if(E&&(r.isBreak(E.nextSibling)&&r.removeItem(E.nextSibling),r.isBreak(E.previousSibling)&&r.removeItem(E.previousSibling),r.isBreak(w))){const N=r.createTextNode(r.zeroWidthSpace);w.parentNode.insertBefore(N,w),w=N}this.effectNode=null,b?this.setRange(b,1,b,1):this.nativeFocus()}}},_setOptionsInit:function(c,u){this.context=e=qr(c.originElement,this._getConstructed(c),s),this._componentsInfoReset=!0,this._editorInit(!0,u)},_editorInit:function(c,u){this._init(c,u),h._addEvent(),this._setCharCount(),h._offStickyToolbar(),h.onResize_window(),e.element.toolbar.style.visibility="";const p=s.frameAttrbutes;for(let b in p)e.element.wysiwyg.setAttribute(b,p[b]);this._checkComponents(),this._componentsInfoInit=!1,this._componentsInfoReset=!1,this.history.reset(!0),a.setTimeout(function(){typeof d._resourcesStateChange=="function"&&(h._resizeObserver&&h._resizeObserver.observe(e.element.wysiwygFrame),h._toolbarObserver&&h._toolbarObserver.observe(e.element._toolbarShadow),d._resourcesStateChange(),typeof v.onload=="function"&&v.onload(d,c))})},_getConstructed:function(c){return{_top:c.topArea,_relative:c.relative,_toolBar:c.toolbar,_toolbarShadow:c._toolbarShadow,_menuTray:c._menuTray,_editorArea:c.editorArea,_wysiwygArea:c.wysiwygFrame,_codeArea:c.code,_placeholder:c.placeholder,_resizingBar:c.resizingBar,_navigation:c.navigation,_charCounter:c.charCounter,_charWrapper:c.charWrapper,_loading:c.loading,_lineBreaker:c.lineBreaker,_lineBreaker_t:c.lineBreaker_t,_lineBreaker_b:c.lineBreaker_b,_resizeBack:c.resizeBackground,_stickyDummy:c._stickyDummy,_arrow:c._arrow}}},h={_IEisComposing:!1,_lineBreakerBind:null,_responsiveCurrentSize:"default",_responsiveButtonSize:null,_responsiveButtons:null,_deleteKeyCode:new a.RegExp("^(8|46)$"),_cursorMoveKeyCode:new a.RegExp("^(8|3[2-9]|40|46)$"),_directionKeyCode:new a.RegExp("^(8|13|3[2-9]|40|46)$"),_nonTextKeyCode:new a.RegExp("^(8|13|1[6-9]|20|27|3[3-9]|40|45|46|11[2-9]|12[0-3]|144|145)$"),_historyIgnoreKeyCode:new a.RegExp("^(1[6-9]|20|27|3[3-9]|40|45|11[2-9]|12[0-3]|144|145)$"),_onButtonsCheck:new a.RegExp("^("+a.Object.keys(s._textTagsMap).join("|")+")$","i"),_frontZeroWidthReg:new a.RegExp(r.zeroWidthSpace+"+",""),_keyCodeShortcut:{65:"A",66:"B",83:"S",85:"U",73:"I",89:"Y",90:"Z",219:"[",221:"]"},_shortcutCommand:function(c,u){let p=null;const b=h._keyCodeShortcut[c];switch(b){case"A":p="selectAll";break;case"B":s.shortcutsDisable.indexOf("bold")===-1&&(p="bold");break;case"S":u&&s.shortcutsDisable.indexOf("strike")===-1?p="strike":!u&&s.shortcutsDisable.indexOf("save")===-1&&(p="save");break;case"U":s.shortcutsDisable.indexOf("underline")===-1&&(p="underline");break;case"I":s.shortcutsDisable.indexOf("italic")===-1&&(p="italic");break;case"Z":s.shortcutsDisable.indexOf("undo")===-1&&(u?p="redo":p="undo");break;case"Y":s.shortcutsDisable.indexOf("undo")===-1&&(p="redo");break;case"[":s.shortcutsDisable.indexOf("indent")===-1&&(p=s.rtl?"indent":"outdent");break;case"]":s.shortcutsDisable.indexOf("indent")===-1&&(p=s.rtl?"outdent":"indent");break}return p?(d.commandHandler(d.commandMap[p],p),!0):!!b},_applyTagEffects:function(){if(r.hasClass(e.element.wysiwyg,"se-read-only"))return!1;let c=d.getSelectionNode();if(c===d.effectNode)return;d.effectNode=c;const u=s.rtl?"marginRight":"marginLeft",p=d.commandMap,b=h._onButtonsCheck,y=[],w=[],x=d.activePlugins,E=x.length;let k="";for(;c.firstChild;)c=c.firstChild;for(let N=c;!r.isWysiwygDiv(N)&&N;N=N.parentNode)if(!(N.nodeType!==1||r.isBreak(N))){if(k=N.nodeName.toUpperCase(),w.push(k),!d.isReadOnly)for(let T=0,R;T<E;T++)R=x[T],y.indexOf(R)===-1&&n[R].active.call(d,N)&&y.push(R);if(r.isFormatElement(N)){y.indexOf("OUTDENT")===-1&&p.OUTDENT&&!r.isImportantDisabled(p.OUTDENT)&&(r.isListCell(N)||N.style[u]&&r.getNumber(N.style[u],0)>0)&&(y.push("OUTDENT"),p.OUTDENT.removeAttribute("disabled")),y.indexOf("INDENT")===-1&&p.INDENT&&!r.isImportantDisabled(p.INDENT)&&(y.push("INDENT"),r.isListCell(N)&&!N.previousElementSibling?p.INDENT.setAttribute("disabled",!0):p.INDENT.removeAttribute("disabled"));continue}b&&b.test(k)&&(y.push(k),r.addClass(p[k],"active"))}d._setKeyEffect(y),d._variable.currentNodes=w.reverse(),d._variable.currentNodesMap=y,s.showPathLabel&&(e.element.navigation.textContent=d._variable.currentNodes.join(" > "))},_buttonsEventHandler:function(c){let u=c.target;if(d._bindControllersOff&&c.stopPropagation(),/^(input|textarea|select|option)$/i.test(u.nodeName)?d._antiBlur=!1:c.preventDefault(),r.getParentElement(u,".se-submenu"))c.stopPropagation(),d._notHideToolbar=!0;else{let p=u.getAttribute("data-command"),b=u.className;for(;!p&&!/se-menu-list/.test(b)&&!/sun-editor-common/.test(b);)u=u.parentNode,p=u.getAttribute("data-command"),b=u.className;(p===d._submenuName||p===d._containerName)&&c.stopPropagation()}},addGlobalEvent:function(c,u,p){return s.iframe&&d._ww.addEventListener(c,u,p),d._w.addEventListener(c,u,p),{type:c,listener:u,useCapture:p}},removeGlobalEvent:function(c,u,p){c&&(typeof c=="object"&&(u=c.listener,p=c.useCapture,c=c.type),s.iframe&&d._ww.removeEventListener(c,u,p),d._w.removeEventListener(c,u,p))},onClick_toolbar:function(c){let u=c.target,p=u.getAttribute("data-display"),b=u.getAttribute("data-command"),y=u.className;for(d.controllersOff();u.parentNode&&!b&&!/se-menu-list/.test(y)&&!/se-toolbar/.test(y);)u=u.parentNode,b=u.getAttribute("data-command"),p=u.getAttribute("data-display"),y=u.className;!b&&!p||u.disabled||d.actionCall(b,p,u)},__selectionSyncEvent:null,onMouseDown_wysiwyg:function(c){if(d.isReadOnly||r.isNonEditable(e.element.wysiwyg))return;if(r._isExcludeSelectionElement(c.target)){c.preventDefault();return}if(h.removeGlobalEvent(h.__selectionSyncEvent),h.__selectionSyncEvent=h.addGlobalEvent("mouseup",function(){d&&d._editorRange(),h.removeGlobalEvent(h.__selectionSyncEvent)}),typeof v.onMouseDown=="function"&&v.onMouseDown(c,d)===!1)return;const u=r.getParentElement(c.target,r.isCell);if(u){const p=d.plugins.table;p&&u!==p._fixedCell&&!p._shift&&d.callPlugin("table",function(){p.onTableCellMultiSelect.call(d,u,!1)},null)}d._isBalloon&&h._hideToolbar()},onClick_wysiwyg:function(c){const u=c.target;if(d.isReadOnly)return c.preventDefault(),r.isAnchor(u)&&a.open(u.href,u.target),!1;if(r.isNonEditable(e.element.wysiwyg)||typeof v.onClick=="function"&&v.onClick(c,d)===!1)return;const p=d.getFileComponent(u);if(p){c.preventDefault(),d.selectComponent(p.target,p.pluginName);return}const b=r.getParentElement(u,"FIGCAPTION");if(b&&r.isNonEditable(b)&&(c.preventDefault(),b.focus(),d._isInline&&!d._inlineToolbarAttr.isShow)){h._showToolbarInline();const N=function(){h._hideToolbar(),b.removeEventListener("blur",N)};b.addEventListener("blur",N)}if(d._editorRange(),c.detail===3){let N=d.getRange();r.isFormatElement(N.endContainer)&&N.endOffset===0&&(N=d.setRange(N.startContainer,N.startOffset,N.startContainer,N.startContainer.length),d._rangeInfo(N,d.getSelection()))}const y=d.getSelectionNode(),w=r.getFormatElement(y,null),x=r.getRangeFormatElement(y,null);let E=y;for(;E&&E.firstChild;)E=E.firstChild;const k=d.getFileComponent(E);if(k){const N=d.getRange();!x&&N.startContainer===N.endContainer&&d.selectComponent(k.target,k.pluginName)}else d.currentFileComponentInfo&&d.controllersOff();if(!w&&!r.isNonEditable(u)&&!r.isList(x)){const N=d.getRange();if(r.getFormatElement(N.startContainer)===r.getFormatElement(N.endContainer))if(r.isList(x)){c.preventDefault();const T=r.createElement("LI"),R=y.nextElementSibling;T.appendChild(y),x.insertBefore(T,R),d.focus()}else!r.isWysiwygDiv(y)&&!r.isComponent(y)&&(!r.isTable(y)||r.isCell(y))&&d._setDefaultFormat(r.isRangeFormatElement(x)?"DIV":s.defaultTag)!==null?(c.preventDefault(),d.focus()):h._applyTagEffects()}else h._applyTagEffects();d._isBalloon&&a.setTimeout(h._toggleToolbarBalloon)},_balloonDelay:null,_showToolbarBalloonDelay:function(){h._balloonDelay&&a.clearTimeout(h._balloonDelay),h._balloonDelay=a.setTimeout((function(){a.clearTimeout(this._balloonDelay),this._balloonDelay=null,this._showToolbarBalloon()}).bind(h),350)},_toggleToolbarBalloon:function(){if(d){d._editorRange();const c=d.getRange();d._bindControllersOff||!d._isBalloonAlways&&c.collapsed?h._hideToolbar():h._showToolbarBalloon(c)}},_showToolbarBalloon:function(c){if(!d._isBalloon)return;const u=c||d.getRange(),p=e.element.toolbar,b=e.element.topArea,y=d.getSelection();let w;if(d._isBalloonAlways&&u.collapsed)w=!0;else if(y.focusNode===y.anchorNode)w=y.focusOffset<y.anchorOffset;else{const F=r.getListChildNodes(u.commonAncestorContainer,null);w=r.getArrayIndex(F,y.focusNode)<r.getArrayIndex(F,y.anchorNode)}let x=u.getClientRects();x=x[w?0:x.length-1];const E=d.getGlobalScrollOffset();let k=E.left,N=E.top;const T=b.offsetWidth,R=h._getEditorOffsets(null),M=R.top,A=R.left;if(p.style.top="-10000px",p.style.visibility="hidden",p.style.display="block",!x){const F=d.getSelectionNode();if(r.isFormatElement(F)){const z=r.createTextNode(r.zeroWidthSpace);d.insertNode(z,null,!1),d.setRange(z,1,z,1),d._editorRange(),x=d.getRange().getClientRects(),x=x[w?0:x.length-1]}if(!x){const z=r.getOffset(F,e.element.wysiwygFrame);x={left:z.left,top:z.top,right:z.left,bottom:z.top+F.offsetHeight,noText:!0},k=0,N=0}w=!0}const D=a.Math.round(e.element._arrow.offsetWidth/2),$=p.offsetWidth,H=p.offsetHeight,j=/iframe/i.test(e.element.wysiwygFrame.nodeName)?e.element.wysiwygFrame.getClientRects()[0]:null;if(j&&(x={left:x.left+j.left,top:x.top+j.top,right:x.right+j.right-j.width,bottom:x.bottom+j.bottom-j.height}),h._setToolbarOffset(w,x,p,A,T,k,N,M,D),($!==p.offsetWidth||H!==p.offsetHeight)&&h._setToolbarOffset(w,x,p,A,T,k,N,M,D),s.toolbarContainer){const F=b.parentElement;let z=s.toolbarContainer,P=z.offsetLeft,B=z.offsetTop;for(;!z.parentElement.contains(F)||!/^(BODY|HTML)$/i.test(z.parentElement.nodeName);)z=z.offsetParent,P+=z.offsetLeft,B+=z.offsetTop;p.style.left=p.offsetLeft-P+b.offsetLeft+"px",p.style.top=p.offsetTop-B+b.offsetTop+"px"}p.style.visibility=""},_setToolbarOffset:function(c,u,p,b,y,w,x,E,k){const T=p.offsetWidth,R=u.noText&&!c?0:p.offsetHeight,M=(c?u.left:u.right)-b-T/2+w,A=M+T-y;let D=(c?u.top-R-k:u.bottom+k)-(u.noText?0:E)+x,$=M<0?1:A<0?M:M-A-1-1,H=!1;const j=D+(c?h._getEditorOffsets(null).top:p.offsetHeight-e.element.wysiwyg.offsetHeight);!c&&j>0&&h._getPageBottomSpace()<j?(c=!0,H=!0):c&&l.documentElement.offsetTop>j&&(c=!1,H=!0),H&&(D=(c?u.top-R-k:u.bottom+k)-(u.noText?0:E)+x),p.style.left=a.Math.floor($)+"px",p.style.top=a.Math.floor(D)+"px",c?(r.removeClass(e.element._arrow,"se-arrow-up"),r.addClass(e.element._arrow,"se-arrow-down"),e.element._arrow.style.top=R+"px"):(r.removeClass(e.element._arrow,"se-arrow-down"),r.addClass(e.element._arrow,"se-arrow-up"),e.element._arrow.style.top=-k+"px");const F=a.Math.floor(T/2+(M-$));e.element._arrow.style.left=(F+k>p.offsetWidth?p.offsetWidth-k:F<k?k:F)+"px"},_showToolbarInline:function(){if(!d._isInline)return;const c=e.element.toolbar;s.toolbarContainer?c.style.position="relative":c.style.position="absolute",c.style.visibility="hidden",c.style.display="block",d._inlineToolbarAttr.width=c.style.width=s.toolbarWidth,d._inlineToolbarAttr.top=c.style.top=(s.toolbarContainer?0:-1-c.offsetHeight)+"px",typeof v.showInline=="function"&&v.showInline(c,e,d),h.onScroll_window(),d._inlineToolbarAttr.isShow=!0,c.style.visibility=""},_hideToolbar:function(){!d._notHideToolbar&&!d._variable.isFullScreen&&(e.element.toolbar.style.display="none",d._inlineToolbarAttr.isShow=!1)},onInput_wysiwyg:function(c){if(/AUDIO/.test(c.target.nodeName))return!1;if(d.isReadOnly||d.isDisabled)return c.preventDefault(),c.stopPropagation(),d.history.go(d.history.getCurrentIndex()),!1;const u=d.getRange(),p=d.getSelectionNode(),b=r.getFormatElement(p,null);if(!b&&u.collapsed&&!r.isComponent(p)&&!r.isList(p)){const w=r.getRangeFormatElement(b,null);d._setDefaultFormat(r.isRangeFormatElement(w)?"DIV":s.defaultTag)}d._editorRange();const y=(c.data===null?"":c.data===void 0?" ":c.data)||"";if(!d._charCount(y))return c.preventDefault(),c.stopPropagation(),!1;typeof v.onInput=="function"&&v.onInput(c,d)===!1||d.history.push(!0)},_isUneditableNode:function(c,u){const p=u?c.startContainer:c.endContainer,b=u?c.startOffset:c.endOffset,y=u?"previousSibling":"nextSibling",w=p.nodeType===1;let x;return w?(x=h._isUneditableNode_getSibling(p.childNodes[b],y,p),x&&x.nodeType===1&&x.getAttribute("contenteditable")==="false"):(x=h._isUneditableNode_getSibling(p,y,p),d.isEdgePoint(p,b,u?"start":"end")&&x&&x.nodeType===1&&x.getAttribute("contenteditable")==="false")},_isUneditableNode_getSibling:function(c,u,p){if(!c)return null;let b=c[u];if(!b)if(b=r.getFormatElement(p),b=b?b[u]:null,b&&!r.isComponent(b))b=u==="previousSibling"?b.firstChild:b.lastChild;else return null;return b},_onShortcutKey:!1,onKeyDown_wysiwyg:function(c){let u=d.getSelectionNode();if(r.isInputElement(u))return;const p=c.keyCode,b=c.shiftKey,y=c.ctrlKey||c.metaKey||p===91||p===92||p===224,w=c.altKey;if(h._IEisComposing=p===229,!y&&d.isReadOnly&&!h._cursorMoveKeyCode.test(p))return c.preventDefault(),!1;if(d.submenuOff(),d._isBalloon&&h._hideToolbar(),typeof v.onKeyDown=="function"&&v.onKeyDown(c,d)===!1)return;if(y&&h._shortcutCommand(p,b))return h._onShortcutKey=!0,c.preventDefault(),c.stopPropagation(),!1;h._onShortcutKey&&(h._onShortcutKey=!1),p===13&&r.isFormatElement(d.getRange().startContainer)&&(d._resetRangeToTextNode(),u=d.getSelectionNode());const x=d.getRange(),E=!x.collapsed||x.startContainer!==x.endContainer,k=d._fileManager.pluginRegExp.test(d.currentControllerName)?d.currentControllerName:"";let N=r.getFormatElement(u,null)||u,T=r.getRangeFormatElement(N,null);if(!(/37|38|39|40/.test(c.keyCode)&&h._onKeyDown_wysiwyg_arrowKey(c)===!1)){switch(p){case 8:if(!E&&k){c.preventDefault(),c.stopPropagation(),d.plugins[k].destroy.call(d);break}if(E&&h._hardDelete()){c.preventDefault(),c.stopPropagation();break}if(!r.isFormatElement(N)&&!e.element.wysiwyg.firstElementChild&&!r.isComponent(u)&&d._setDefaultFormat(s.defaultTag)!==null)return c.preventDefault(),c.stopPropagation(),!1;if(!E&&!N.previousElementSibling&&x.startOffset===0&&!u.previousSibling&&!r.isListCell(N)&&r.isFormatElement(N)&&(!r.isFreeFormatElement(N)||r.isClosureFreeFormatElement(N))){if(r.isClosureRangeFormatElement(N.parentNode))return c.preventDefault(),c.stopPropagation(),!1;if(r.isWysiwygDiv(N.parentNode)&&N.childNodes.length<=1&&(!N.firstChild||r.onlyZeroWidthSpace(N.textContent))){if(c.preventDefault(),c.stopPropagation(),N.nodeName.toUpperCase()===s.defaultTag.toUpperCase()){N.innerHTML="<br>";const L=N.attributes;for(;L[0];)N.removeAttribute(L[0].name)}else{const L=r.createElement(s.defaultTag);L.innerHTML="<br>",N.parentElement.replaceChild(L,N)}return d.nativeFocus(),!1}}const M=x.startContainer;if(N&&!N.previousElementSibling&&x.startOffset===0&&M.nodeType===3&&!r.isFormatElement(M.parentNode)){let L=M.parentNode.previousSibling;const U=M.parentNode.nextSibling;L||(U?L=U:(L=r.createElement("BR"),N.appendChild(L)));let O=M;for(;N.contains(O)&&!O.previousSibling;)O=O.parentNode;if(!N.contains(O)){M.textContent="",r.removeItemAllParents(M,null,N);break}}if(h._isUneditableNode(x,!0)){c.preventDefault(),c.stopPropagation();break}!E&&d._isEdgeFormat(x.startContainer,x.startOffset,"start")&&r.isFormatElement(N.previousElementSibling)&&(d._formatAttrsTemp=N.previousElementSibling.attributes);const A=x.commonAncestorContainer;if(N=r.getFormatElement(x.startContainer,null),T=r.getRangeFormatElement(N,null),T&&N&&!r.isCell(T)&&!/^FIGCAPTION$/i.test(T.nodeName)){if(r.isListCell(N)&&r.isList(T)&&(r.isListCell(T.parentNode)||N.previousElementSibling)&&(u===N||u.nodeType===3&&(!u.previousSibling||r.isList(u.previousSibling)))&&(r.getFormatElement(x.startContainer,null)!==r.getFormatElement(x.endContainer,null)?T.contains(x.startContainer):x.startOffset===0&&x.collapsed)){if(x.startContainer!==x.endContainer)c.preventDefault(),d.removeNode(),x.startContainer.nodeType===3&&d.setRange(x.startContainer,x.startContainer.textContent.length,x.startContainer,x.startContainer.textContent.length),d.history.push(!0);else{let L=N.previousElementSibling||T.parentNode;if(r.isListCell(L)){c.preventDefault();let U=L;if(!L.contains(N)&&r.isListCell(U)&&r.isList(U.lastElementChild)){for(U=U.lastElementChild.lastElementChild;r.isListCell(U)&&r.isList(U.lastElementChild);)U=U.lastElementChild&&U.lastElementChild.lastElementChild;L=U}let O=L===T.parentNode?T.previousSibling:L.lastChild;O||(O=r.createTextNode(r.zeroWidthSpace),T.parentNode.insertBefore(O,T.parentNode.firstChild));const W=O.nodeType===3?O.textContent.length:1,Q=N.childNodes;let V=O,X=Q[0];for(;X=Q[0];)L.insertBefore(X,V.nextSibling),V=X;r.removeItem(N),T.children.length===0&&r.removeItem(T),d.setRange(O,W,O,W),d.history.push(!0)}}break}if(!E&&x.startOffset===0){let L=!0,U=A;for(;U&&U!==T&&!r.isWysiwygDiv(U);){if(U.previousSibling&&(U.previousSibling.nodeType===1||!r.onlyZeroWidthSpace(U.previousSibling.textContent.trim()))){L=!1;break}U=U.parentNode}if(L&&T.parentNode){c.preventDefault(),d.detachRangeFormatElement(T,r.isListCell(N)?[N]:null,null,!1,!1),d.history.push(!0);break}}}if(!E&&N&&(x.startOffset===0||u===N&&N.childNodes[x.startOffset])){const L=r.isListCell(N),U=u===N?N.childNodes[x.startOffset]:u,O=L?U.previousSibling:N.previousSibling,W=L||(A.nodeType===3||r.isBreak(A))&&!A.previousSibling&&x.startOffset===0;if(U&&(L||!U.previousSibling)&&(A&&r.isComponent(A.previousSibling)||W&&r.isComponent(O))){const Q=d.getFileComponent(O);Q?(c.preventDefault(),c.stopPropagation(),L?r.removeItem(U):N.textContent.length===0&&r.removeItem(N),d.selectComponent(Q.target,Q.pluginName)===!1&&d.blur()):r.isComponent(O)&&(c.preventDefault(),c.stopPropagation(),r.removeItem(O));break}if(U&&r.isNonEditable(U.previousSibling)){c.preventDefault(),c.stopPropagation(),r.removeItem(U.previousSibling);break}}break;case 46:if(k){c.preventDefault(),c.stopPropagation(),d.plugins[k].destroy.call(d);break}if(E&&h._hardDelete()){c.preventDefault(),c.stopPropagation();break}if(!E&&d._isEdgeFormat(x.endContainer,x.endOffset,"end")&&!N.nextSibling){c.preventDefault(),c.stopPropagation();return}if(h._isUneditableNode(x,!1)){c.preventDefault(),c.stopPropagation();break}if((r.isFormatElement(u)||u.nextSibling===null||r.onlyZeroWidthSpace(u.nextSibling)&&u.nextSibling.nextSibling===null)&&x.startOffset===u.textContent.length){const L=N.nextElementSibling;if(!L)break;if(r.isComponent(L)){if(c.preventDefault(),r.onlyZeroWidthSpace(N)&&(r.removeItem(N),r.isTable(L))){let O=r.getChildElement(L,r.isCell,!1);O=O.firstElementChild||O,d.setRange(O,0,O,0);break}const U=d.getFileComponent(L);U?(c.stopPropagation(),d.selectComponent(U.target,U.pluginName)===!1&&d.blur()):r.isComponent(L)&&(c.stopPropagation(),r.removeItem(L));break}}if(!E&&(d.isEdgePoint(x.endContainer,x.endOffset)||u===N&&N.childNodes[x.startOffset])){const L=u===N&&N.childNodes[x.startOffset]||u;if(L&&r.isNonEditable(L.nextSibling)){c.preventDefault(),c.stopPropagation(),r.removeItem(L.nextSibling);break}else if(r.isComponent(L)){c.preventDefault(),c.stopPropagation(),r.removeItem(L);break}}if(!E&&d._isEdgeFormat(x.endContainer,x.endOffset,"end")&&r.isFormatElement(N.nextElementSibling)&&(d._formatAttrsTemp=N.attributes),N=r.getFormatElement(x.startContainer,null),T=r.getRangeFormatElement(N,null),r.isListCell(N)&&r.isList(T)&&(u===N||u.nodeType===3&&(!u.nextSibling||r.isList(u.nextSibling))&&(r.getFormatElement(x.startContainer,null)!==r.getFormatElement(x.endContainer,null)?T.contains(x.endContainer):x.endOffset===u.textContent.length&&x.collapsed))){x.startContainer!==x.endContainer&&d.removeNode();let L=r.getArrayItem(N.children,r.isList,!1);if(L=L||N.nextElementSibling||(T.parentNode?T.parentNode.nextElementSibling:null),L&&(r.isList(L)||r.getArrayItem(L.children,r.isList,!1))){c.preventDefault();let U,O;if(r.isList(L)){const W=L.firstElementChild;for(O=W.childNodes,U=O[0];O[0];)N.insertBefore(O[0],L);r.removeItem(W)}else{for(U=L.firstChild,O=L.childNodes;O[0];)N.appendChild(O[0]);r.removeItem(L)}d.setRange(U,0,U,0),d.history.push(!0)}break}break;case 9:if(k||s.tabDisable||(c.preventDefault(),y||w||r.isWysiwygDiv(u)))break;const D=!x.collapsed||d.isEdgePoint(x.startContainer,x.startOffset),$=d.getSelectedElements(null);u=d.getSelectionNode();const H=[];let j=[],F=r.isListCell($[0]),z=r.isListCell($[$.length-1]),P={sc:x.startContainer,so:x.startOffset,ec:x.endContainer,eo:x.endOffset};for(let L=0,U=$.length,O;L<U;L++)if(O=$[L],r.isListCell(O)){if(!O.previousElementSibling&&!b)continue;H.push(O)}else j.push(O);if(H.length>0&&D&&d.plugins.list)P=d.plugins.list.editInsideList.call(d,b,H);else{const L=r.getParentElement(u,r.isCell);if(L&&D){const U=r.getParentElement(L,"table"),O=r.getListChildren(U,r.isCell);let W=b?r.prevIdx(O,L):r.nextIdx(O,L);W===O.length&&!b&&(W=0),W===-1&&b&&(W=O.length-1);let Q=O[W];if(!Q)break;Q=Q.firstElementChild||Q,d.setRange(Q,0,Q,0);break}j=j.concat(H),F=z=null}if(j.length>0)if(b){const L=j.length-1;for(let W=0,Q;W<=L;W++){Q=j[W].childNodes;for(let V=0,X=Q.length,Z;V<X&&(Z=Q[V],!!Z);V++)if(!r.onlyZeroWidthSpace(Z)){/^\s{1,4}$/.test(Z.textContent)?r.removeItem(Z):/^\s{1,4}/.test(Z.textContent)&&(Z.textContent=Z.textContent.replace(/^\s{1,4}/,""));break}}const U=r.getChildElement(j[0],"text",!1),O=r.getChildElement(j[L],"text",!0);!F&&U&&(P.sc=U,P.so=0),!z&&O&&(P.ec=O,P.eo=O.textContent.length)}else{const L=r.createTextNode(new a.Array(d._variable.tabSize+1).join(" "));if(j.length===1){if(!d.insertNode(L,null,!0))return!1;F||(P.sc=L,P.so=L.length),z||(P.ec=L,P.eo=L.length)}else{const U=j.length-1;for(let Q=0,V;Q<=U;Q++)V=j[Q].firstChild,V&&(r.isBreak(V)?j[Q].insertBefore(L.cloneNode(!1),V):V.textContent=L.textContent+V.textContent);const O=r.getChildElement(j[0],"text",!1),W=r.getChildElement(j[U],"text",!0);!F&&O&&(P.sc=O,P.so=0),!z&&W&&(P.ec=W,P.eo=W.textContent.length)}}d.setRange(P.sc,P.so,P.ec,P.eo),d.history.push(!1);break;case 13:const B=r.getFreeFormatElement(u,null);if(d._charTypeHTML){let L="";if(!b&&B||b?L="<br>":L="<"+N.nodeName+"><br></"+N.nodeName+">",!d.checkCharCount(L,"byte-html"))return c.preventDefault(),!1}if(!b&&!k){const L=d._isEdgeFormat(x.endContainer,x.endOffset,"end"),U=d._isEdgeFormat(x.startContainer,x.startOffset,"start");if(L&&(/^H[1-6]$/i.test(N.nodeName)||/^HR$/i.test(N.nodeName))){h._enterPrevent(c);let O=null;const W=d.appendFormatTag(N,s.defaultTag);if(L&&L.length>0){O=L.pop();const Q=O;for(;L.length>0;)O=O.appendChild(L.pop());W.appendChild(Q)}if(O=O?O.appendChild(W.firstChild):W.firstChild,r.isBreak(O)){const Q=r.createTextNode(r.zeroWidthSpace);O.parentNode.insertBefore(Q,O),d.setRange(Q,1,Q,1)}else d.setRange(O,0,O,0);break}else if(T&&N&&!r.isCell(T)&&!/^FIGCAPTION$/i.test(T.nodeName)){const O=d.getRange();if(d.isEdgePoint(O.endContainer,O.endOffset)&&r.isList(u.nextSibling)){h._enterPrevent(c);const W=r.createElement("LI"),Q=r.createElement("BR");W.appendChild(Q),N.parentNode.insertBefore(W,N.nextElementSibling),W.appendChild(u.nextSibling),d.setRange(Q,1,Q,1);break}if((O.commonAncestorContainer.nodeType!==3||!O.commonAncestorContainer.nextElementSibling)&&r.onlyZeroWidthSpace(N.innerText.trim())&&!r.isListCell(N.nextElementSibling)){h._enterPrevent(c);let W=null;if(r.isListCell(T.parentNode)){const Q=N.parentNode.parentNode;T=Q.parentNode;const V=r.createElement("LI");V.innerHTML="<br>",r.copyTagAttributes(V,N,s.lineAttrReset),W=V,T.insertBefore(W,Q.nextElementSibling)}else{const Q=r.isCell(T.parentNode)?"DIV":r.isList(T.parentNode)?"LI":r.isFormatElement(T.nextElementSibling)&&!r.isRangeFormatElement(T.nextElementSibling)?T.nextElementSibling.nodeName:r.isFormatElement(T.previousElementSibling)&&!r.isRangeFormatElement(T.previousElementSibling)?T.previousElementSibling.nodeName:s.defaultTag;W=r.createElement(Q),r.copyTagAttributes(W,N,s.lineAttrReset);const V=d.detachRangeFormatElement(T,[N],null,!0,!0);V.cc.insertBefore(W,V.ec)}W.innerHTML="<br>",r.removeItemAllParents(N,null,null),d.setRange(W,1,W,1);break}}if(B){h._enterPrevent(c);const O=u===B,W=d.getSelection(),Q=u.childNodes,V=W.focusOffset,X=u.previousElementSibling,Z=u.nextSibling;if(!r.isClosureFreeFormatElement(B)&&Q&&(O&&x.collapsed&&Q.length-1<=V+1&&r.isBreak(Q[V])&&(!Q[V+1]||(!Q[V+2]||r.onlyZeroWidthSpace(Q[V+2].textContent))&&Q[V+1].nodeType===3&&r.onlyZeroWidthSpace(Q[V+1].textContent))&&V>0&&r.isBreak(Q[V-1])||!O&&r.onlyZeroWidthSpace(u.textContent)&&r.isBreak(X)&&(r.isBreak(X.previousSibling)||!r.onlyZeroWidthSpace(X.previousSibling.textContent))&&(!Z||!r.isBreak(Z)&&r.onlyZeroWidthSpace(Z.textContent)))){O?r.removeItem(Q[V-1]):r.removeItem(u);const G=d.appendFormatTag(B,r.isFormatElement(B.nextElementSibling)&&!r.isRangeFormatElement(B.nextElementSibling)?B.nextElementSibling:null);r.copyFormatAttributes(G,B),d.setRange(G,1,G,1);break}if(O){v.insertHTML(x.collapsed&&r.isBreak(x.startContainer.childNodes[x.startOffset-1])?"<br>":"<br><br>",!0,!1);let G=W.focusNode;const J=W.focusOffset;B===G&&(G=G.childNodes[J-V>1?J-1:J]),d.setRange(G,1,G,1)}else{const G=W.focusNode.nextSibling,J=r.createElement("BR");d.insertNode(J,null,!1);const ee=J.previousSibling,se=J.nextSibling;!r.isBreak(G)&&!r.isBreak(ee)&&(!se||r.onlyZeroWidthSpace(se))?(J.parentNode.insertBefore(J.cloneNode(!1),J),d.setRange(J,1,J,1)):d.setRange(se,0,se,0)}h._onShortcutKey=!0;break}if(x.collapsed&&(U||L)){h._enterPrevent(c);const O=r.createElement("BR"),W=r.createElement(N.nodeName);r.copyTagAttributes(W,N,s.lineAttrReset);let Q=O;do{if(!r.isBreak(u)&&u.nodeType===1){const V=u.cloneNode(!1);V.appendChild(Q),Q=V}u=u.parentNode}while(N!==u&&N.contains(u));W.appendChild(Q),N.parentNode.insertBefore(W,U&&!L?N:N.nextElementSibling),L&&d.setRange(O,1,O,1);break}if(N){c.stopPropagation();let O,W=0;if(x.collapsed)r.onlyZeroWidthSpace(N)?O=d.appendFormatTag(N,N.cloneNode(!1)):O=r.splitElement(x.endContainer,x.endOffset,r.getElementDepth(N));else{const Q=r.getFormatElement(x.startContainer,null)!==r.getFormatElement(x.endContainer,null),V=N.cloneNode(!1);V.innerHTML="<br>";const X=x.commonAncestorContainer,Z=X===x.startContainer&&X===x.endContainer&&r.onlyZeroWidthSpace(X)?x:d.removeNode();if(O=r.getFormatElement(Z.container,null),!O){r.isWysiwygDiv(Z.container)&&(h._enterPrevent(c),e.element.wysiwyg.appendChild(V),O=V,r.copyTagAttributes(O,N,s.lineAttrReset),d.setRange(O,W,O,W));break}const G=r.getRangeFormatElement(Z.container);if(O=O.contains(G)?r.getChildElement(G,r.getFormatElement.bind(r)):O,Q){if(L&&!U)O.parentNode.insertBefore(V,!Z.prevContainer||Z.container===Z.prevContainer?O.nextElementSibling:O),O=V,W=0;else if(W=Z.offset,U){const J=O.parentNode.insertBefore(V,O);L&&(O=J,W=0)}}else L&&U?(O.parentNode.insertBefore(V,Z.prevContainer&&Z.container===Z.prevContainer?O.nextElementSibling:O),O=V,W=0):O=r.splitElement(Z.container,Z.offset,r.getElementDepth(N))}h._enterPrevent(c),r.copyTagAttributes(O,N,s.lineAttrReset),d.setRange(O,W,O,W);break}}if(E)break;if(T&&r.getParentElement(T,"FIGCAPTION")&&r.getParentElement(T,r.isList)&&(h._enterPrevent(c),N=d.appendFormatTag(N,null),d.setRange(N,0,N,0)),k){c.preventDefault(),c.stopPropagation(),d.containerOff(),d.controllersOff();const L=e[k],U=L._container,O=U.previousElementSibling||U.nextElementSibling;let W=null;r.isListCell(U.parentNode)?W=r.createElement("BR"):(W=r.createElement(r.isFormatElement(O)&&!r.isRangeFormatElement(O)?O.nodeName:s.defaultTag),W.innerHTML="<br>"),b?U.parentNode.insertBefore(W,U):U.parentNode.insertBefore(W,U.nextElementSibling),d.callPlugin(k,function(){d.selectComponent(L._element,k)===!1&&d.blur()},null)}break;case 27:if(k)return c.preventDefault(),c.stopPropagation(),d.controllersOff(),!1;break}if(d.currentFileComponentInfo&&d.controllersOff(),b&&p===16){c.preventDefault(),c.stopPropagation();const M=d.plugins.table;if(M&&!M._shift&&!M._ref){const A=r.getParentElement(N,r.isCell);if(A){M.onTableCellMultiSelect.call(d,A,!0);return}}}else if(b&&(r.isOSX_IOS?w:y)&&p===32){c.preventDefault(),c.stopPropagation();const M=d.insertNode(r.createTextNode(" "));if(M){d.setRange(M,M.length,M,M.length);return}}if(r.isIE&&!y&&!w&&!E&&!h._nonTextKeyCode.test(p)&&r.isBreak(x.commonAncestorContainer)){const M=r.createTextNode(r.zeroWidthSpace);d.insertNode(M,null,!1),d.setRange(M,1,M,1)}h._directionKeyCode.test(p)&&(a.setTimeout(d._editorRange.bind(d),0),h._applyTagEffects())}},_onKeyDown_wysiwyg_arrowKey:function(c){if(c.shiftKey)return;let u=d.getSelectionNode();const p=function(w,x){if(x||(x=0),c.preventDefault(),c.stopPropagation(),!w)return;let E=d.getFileComponent(w);E?d.selectComponent(E.target,E.pluginName):(d.setRange(w,x,w,x),d.controllersOff())},b=r.getParentElement(u,"table");if(b){const w=r.getParentElement(u,"tr"),x=r.getParentElement(u,"td");let E=x,k=x;if(x){for(;E&&E.firstChild;)E=E.firstChild;for(;k&&k.lastChild;)k=k.lastChild}let N=u;for(;N&&N.firstChild;)N=N.firstChild;const T=N===E,R=N===k;let M=null,A=0;if(c.keyCode===38&&T){const D=w&&w.previousElementSibling;for(D?M=D.children[x.cellIndex]:M=r.getPreviousDeepestNode(b,d.context.element.wysiwyg);M&&M.lastChild;)M=M.lastChild;M&&(A=M.textContent.length)}else if(c.keyCode===40&&R){const D=w&&w.nextElementSibling;for(D?M=D.children[x.cellIndex]:M=r.getNextDeepestNode(b,d.context.element.wysiwyg);M&&M.firstChild;)M=M.firstChild}if(M)return p(M,A),!1}const y=d.getFileComponent(u);if(y){const w=/37|38/.test(c.keyCode),x=/39|40/.test(c.keyCode);if(w){const E=r.getPreviousDeepestNode(y.target,d.context.element.wysiwyg);p(E,E&&E.textContent.length)}else if(x){const E=r.getNextDeepestNode(y.target,d.context.element.wysiwyg);p(E)}}},onKeyUp_wysiwyg:function(c){if(h._onShortcutKey)return;d._editorRange();const u=c.keyCode,p=c.ctrlKey||c.metaKey||u===91||u===92||u===224,b=c.altKey;if(d.isReadOnly){!p&&h._cursorMoveKeyCode.test(u)&&h._applyTagEffects();return}const y=d.getRange();let w=d.getSelectionNode();if(d._isBalloon&&(d._isBalloonAlways&&u!==27||!y.collapsed))if(d._isBalloonAlways)u!==27&&h._showToolbarBalloonDelay();else{h._showToolbarBalloon();return}let x=w;for(;x&&x.firstChild;)x=x.firstChild;const E=d.getFileComponent(x);if(!(c.keyCode===16||c.shiftKey)&&E&&d.selectComponent(E.target,E.pluginName),u===8&&r.isWysiwygDiv(w)&&w.textContent===""&&w.children.length===0){c.preventDefault(),c.stopPropagation(),w.innerHTML="";const M=r.createElement(r.isFormatElement(d._variable.currentNodes[0])?d._variable.currentNodes[0]:s.defaultTag);M.innerHTML="<br>",w.appendChild(M),d.setRange(M,0,M,0),h._applyTagEffects(),d.history.push(!1);return}const k=r.getFormatElement(w,null),N=r.getRangeFormatElement(w,null),T=d._formatAttrsTemp;if(T){for(let M=0,A=T.length;M<A;M++){if(u===13&&/^id$/i.test(T[M].name)){k.removeAttribute("id");continue}k.setAttribute(T[M].name,T[M].value)}d._formatAttrsTemp=null}if(!k&&y.collapsed&&!r.isComponent(w)&&!r.isList(w)&&d._setDefaultFormat(r.isRangeFormatElement(N)?"DIV":s.defaultTag)!==null&&(w=d.getSelectionNode()),!p&&!b&&!h._nonTextKeyCode.test(u)&&w.nodeType===3&&r.zeroWidthRegExp.test(w.textContent)&&!(c.isComposing!==void 0?c.isComposing:h._IEisComposing)){let M=y.startOffset,A=y.endOffset;const D=(w.textContent.substring(0,A).match(h._frontZeroWidthReg)||"").length;M=y.startOffset-D,A=y.endOffset-D,w.textContent=w.textContent.replace(r.zeroWidthRegExp,""),d.setRange(w,M<0?0:M,w,A<0?0:A)}h._deleteKeyCode.test(u)&&k&&r.onlyZeroWidthSpace(k.textContent)&&!k.previousElementSibling&&(k.innerHTML="<br>",d.setRange(k,0,k,0)),d._charCount(""),!(typeof v.onKeyUp=="function"&&v.onKeyUp(c,d)===!1)&&!p&&!b&&!h._historyIgnoreKeyCode.test(u)&&d.history.push(!0)},onScroll_wysiwyg:function(c){d.controllersOff(),d._isBalloon&&h._hideToolbar(),typeof v.onScroll=="function"&&v.onScroll(c,d)},onFocus_wysiwyg:function(c){d._antiBlur||(d.hasFocus=!0,a.setTimeout(h._applyTagEffects),d._isInline&&h._showToolbarInline(),typeof v.onFocus=="function"&&v.onFocus(c,d))},onBlur_wysiwyg:function(c){d._antiBlur||d._variable.isCodeView||(d.hasFocus=!1,d.effectNode=null,d.controllersOff(),(d._isInline||d._isBalloon)&&h._hideToolbar(),d._setKeyEffect([]),d._variable.currentNodes=[],d._variable.currentNodesMap=[],s.showPathLabel&&(e.element.navigation.textContent=""),typeof v.onBlur=="function"&&v.onBlur(c,d,this))},onMouseDown_resizingBar:function(c){c.stopPropagation(),d.submenuOff(),d.controllersOff(),d._variable.resizeClientY=c.clientY,e.element.resizeBackground.style.display="block";function u(){e.element.resizeBackground.style.display="none",l.removeEventListener("mousemove",h._resize_editor),l.removeEventListener("mouseup",u)}l.addEventListener("mousemove",h._resize_editor),l.addEventListener("mouseup",u)},_resize_editor:function(c){const u=e.element.editorArea.offsetHeight+(c.clientY-d._variable.resizeClientY),p=u<d._variable.minResizingSize?d._variable.minResizingSize:u;e.element.wysiwygFrame.style.height=e.element.code.style.height=p+"px",d._variable.resizeClientY=c.clientY,r.isResizeObserverSupported||d.__callResizeFunction(p,null)},onResize_window:function(){r.isResizeObserverSupported||d.resetResponsiveToolbar();const c=e.element.toolbar,u=c.style.display==="none"||d._isInline&&!d._inlineToolbarAttr.isShow;if(!(c.offsetWidth===0&&!u)){if(e.fileBrowser&&e.fileBrowser.area.style.display==="block"&&(e.fileBrowser.body.style.maxHeight=a.innerHeight-e.fileBrowser.header.offsetHeight-50+"px"),d.submenuActiveButton&&d.submenu&&d._setMenuPosition(d.submenuActiveButton,d.submenu),d._variable.isFullScreen){d._variable.innerHeight_fullScreen+=a.innerHeight-c.offsetHeight-d._variable.innerHeight_fullScreen,e.element.editorArea.style.height=d._variable.innerHeight_fullScreen+"px";return}if(d._variable.isCodeView&&d._isInline){h._showToolbarInline();return}d._iframeAutoHeight(),d._sticky&&(c.style.width=e.element.topArea.offsetWidth-2+"px",h.onScroll_window())}},onScroll_window:function(){if(d._variable.isFullScreen||e.element.toolbar.offsetWidth===0||s.stickyToolbar<0)return;const c=e.element,u=c.editorArea.offsetHeight,p=(this.scrollY||l.documentElement.scrollTop)+s.stickyToolbar,b=h._getEditorOffsets(s.toolbarContainer).top-(d._isInline?c.toolbar.offsetHeight:0),y=d._isInline&&p-b>0?p-b-e.element.toolbar.offsetHeight:0;p<b?h._offStickyToolbar():p+d._variable.minResizingSize>=u+b?(d._sticky||h._onStickyToolbar(y),c.toolbar.style.top=y+u+b+s.stickyToolbar-p-d._variable.minResizingSize+"px"):p>=b&&h._onStickyToolbar(y)},_getEditorOffsets:function(c){let u=c||e.element.topArea,p=0,b=0,y=0;for(;u;)p+=u.offsetTop,b+=u.offsetLeft,y+=u.scrollTop,u=u.offsetParent;return{top:p,left:b,scroll:y}},_getPageBottomSpace:function(){return l.documentElement.scrollHeight-(h._getEditorOffsets(null).top+e.element.topArea.offsetHeight)},_onStickyToolbar:function(c){const u=e.element;!d._isInline&&!s.toolbarContainer&&(u._stickyDummy.style.height=u.toolbar.offsetHeight+"px",u._stickyDummy.style.display="block"),u.toolbar.style.top=s.stickyToolbar+c+"px",u.toolbar.style.width=d._isInline?d._inlineToolbarAttr.width:u.toolbar.offsetWidth+"px",r.addClass(u.toolbar,"se-toolbar-sticky"),d._sticky=!0},_offStickyToolbar:function(){const c=e.element;c._stickyDummy.style.display="none",c.toolbar.style.top=d._isInline?d._inlineToolbarAttr.top:"",c.toolbar.style.width=d._isInline?d._inlineToolbarAttr.width:"",c.editorArea.style.marginTop="",r.removeClass(c.toolbar,"se-toolbar-sticky"),d._sticky=!1},_codeViewAutoHeight:function(){d._variable.isFullScreen||(e.element.code.style.height=e.element.code.scrollHeight+"px")},_hardDelete:function(){const c=d.getRange(),u=c.startContainer,p=c.endContainer,b=r.getRangeFormatElement(u),y=r.getRangeFormatElement(p),w=r.isCell(b),x=r.isCell(y),E=c.commonAncestorContainer;if((w&&!b.previousElementSibling&&!b.parentElement.previousElementSibling||x&&!y.nextElementSibling&&!y.parentElement.nextElementSibling)&&b!==y)if(!w)r.removeItem(r.getParentElement(y,function(T){return E===T.parentNode}));else if(!x)r.removeItem(r.getParentElement(b,function(T){return E===T.parentNode}));else return r.removeItem(r.getParentElement(b,function(T){return E===T.parentNode})),d.nativeFocus(),!0;const k=u.nodeType===1?r.getParentElement(u,".se-component"):null,N=p.nodeType===1?r.getParentElement(p,".se-component"):null;return k&&r.removeItem(k),N&&r.removeItem(N),!1},onPaste_wysiwyg:function(c){const u=r.isIE?a.clipboardData:c.clipboardData;return u?h._dataTransferAction("paste",c,u):!0},_setClipboardComponent:function(c,u,p){c.preventDefault(),c.stopPropagation(),p.setData("text/html",u.component.outerHTML)},onCopy_wysiwyg:function(c){const u=r.isIE?a.clipboardData:c.clipboardData;if(typeof v.onCopy=="function"&&v.onCopy(c,u,d)===!1)return c.preventDefault(),c.stopPropagation(),!1;const p=d.currentFileComponentInfo;p&&!r.isIE&&(h._setClipboardComponent(c,p,u),r.addClass(p.component,"se-component-copy"),a.setTimeout(function(){r.removeClass(p.component,"se-component-copy")},150))},onSave_wysiwyg:function(c){if(typeof v.onSave=="function"){v.onSave(c,d);return}},onCut_wysiwyg:function(c){const u=r.isIE?a.clipboardData:c.clipboardData;if(typeof v.onCut=="function"&&v.onCut(c,u,d)===!1)return c.preventDefault(),c.stopPropagation(),!1;const p=d.currentFileComponentInfo;p&&!r.isIE&&(h._setClipboardComponent(c,p,u),r.removeItem(p.component),d.controllersOff()),a.setTimeout(function(){d.history.push(!1)})},onDrop_wysiwyg:function(c){if(d.isReadOnly||r.isIE)return c.preventDefault(),c.stopPropagation(),!1;const u=c.dataTransfer;return u?(h._setDropLocationSelection(c),d.removeNode(),document.body.contains(d.currentControllerTarget)||d.controllersOff(),h._dataTransferAction("drop",c,u)):!0},_setDropLocationSelection:function(c){const u={startContainer:null,startOffset:null,endContainer:null,endOffset:null};let p=null;if(c.rangeParent?(u.startContainer=c.rangeParent,u.startOffset=c.rangeOffset,u.endContainer=c.rangeParent,u.endOffset=c.rangeOffset):d._wd.caretRangeFromPoint?p=d._wd.caretRangeFromPoint(c.clientX,c.clientY):p=d.getRange(),p&&(u.startContainer=p.startContainer,u.startOffset=p.startOffset,u.endContainer=p.endContainer,u.endOffset=p.endOffset),u.startContainer===u.endContainer){const b=r.getParentElement(u.startContainer,r.isComponent);b&&(u.startContainer=b,u.startOffset=0,u.endContainer=b,u.endOffset=0)}d.setRange(u.startContainer,u.startOffset,u.endContainer,u.endOffset)},_dataTransferAction:function(c,u,p){let b,y;if(r.isIE){b=p.getData("Text");const w=d.getRange(),x=r.createElement("DIV"),E={sc:w.startContainer,so:w.startOffset,ec:w.endContainer,eo:w.endOffset};return x.setAttribute("contenteditable",!0),x.style.cssText="position:absolute; top:0; left:0; width:1px; height:1px; overflow:hidden;",e.element.relative.appendChild(x),x.focus(),a.setTimeout(function(){y=x.innerHTML,r.removeItem(x),d.setRange(E.sc,E.so,E.ec,E.eo),h._setClipboardData(c,u,b,y,p)}),!0}else if(b=p.getData("text/plain"),y=p.getData("text/html"),h._setClipboardData(c,u,b,y,p)===!1)return u.preventDefault(),u.stopPropagation(),!1},_setClipboardData:function(c,u,p,b,y){const w=/class=["']*Mso(Normal|List)/i.test(b)||/content=["']*Word.Document/i.test(b)||/content=["']*OneNote.File/i.test(b)||/content=["']*Excel.Sheet/i.test(b);!b?b=r._HTMLConvertor(p).replace(/\n/g,"<br>"):(b=b.replace(/^<html>\r?\n?<body>\r?\n?\x3C!--StartFragment--\>|\x3C!--EndFragment-->\r?\n?<\/body\>\r?\n?<\/html>$/g,""),w&&(b=b.replace(/\n/g," "),p=p.replace(/\n/g," ")),b=d.cleanHTML(b,d.pasteTagsWhitelistRegExp,d.pasteTagsBlacklistRegExp));const E=d._charCount(d._charTypeHTML?b:p);if(c==="paste"&&typeof v.onPaste=="function"){const N=v.onPaste(u,b,E,d);if(N===!1)return!1;if(typeof N=="string"){if(!N)return!1;b=N}}if(c==="drop"&&typeof v.onDrop=="function"){const N=v.onDrop(u,b,E,d);if(N===!1)return!1;if(typeof N=="string"){if(!N)return!1;b=N}}const k=y.files;if(k.length>0&&!w)return/^image/.test(k[0].type)&&d.plugins.image&&v.insertImage(k),!1;if(!E)return!1;if(b)return v.insertHTML(b,!0,!1),!1},onMouseMove_wysiwyg:function(c){if(d.isDisabled||d.isReadOnly)return!1;const u=r.getParentElement(c.target,r.isComponent),p=d._lineBreaker.style;if(u&&!d.currentControllerName){const b=e.element;let y=0,w=b.wysiwyg;do y+=w.scrollTop,w=w.parentElement;while(w&&!/^(BODY|HTML)$/i.test(w.nodeName));const x=b.wysiwyg.scrollTop,E=h._getEditorOffsets(null),k=r.getOffset(u,b.wysiwygFrame).top+x,N=c.pageY+y+(s.iframe&&!s.toolbarContainer?b.toolbar.offsetHeight:0),T=k+(s.iframe?y:E.top),R=r.isListCell(u.parentNode);let M="",A="";if((R?!u.previousSibling:!r.isFormatElement(u.previousElementSibling))&&N<T+20)A=k,M="t";else if((R?!u.nextSibling:!r.isFormatElement(u.nextElementSibling))&&N>T+u.offsetHeight-20)A=k+u.offsetHeight,M="b";else{p.display="none";return}d._variable._lineBreakComp=u,d._variable._lineBreakDir=M,p.top=A-x+"px",d._lineBreakerButton.style.left=r.getOffset(u).left+u.offsetWidth/2-15+"px",p.display="block"}else p.display!=="none"&&(p.display="none")},_enterPrevent:function(c){c.preventDefault(),r.isMobile&&d.__focusTemp.focus()},_onMouseDown_lineBreak:function(c){c.preventDefault()},_onLineBreak:function(c){c.preventDefault();const u=d._variable._lineBreakComp,p=this?this:d._variable._lineBreakDir,b=r.isListCell(u.parentNode),y=r.createElement(b?"BR":r.isCell(u.parentNode)?"DIV":s.defaultTag);if(b||(y.innerHTML="<br>"),d._charTypeHTML&&!d.checkCharCount(y.outerHTML,"byte-html"))return;u.parentNode.insertBefore(y,p==="t"?u:u.nextSibling),d._lineBreaker.style.display="none",d._variable._lineBreakComp=null;const w=b?y:y.firstChild;d.setRange(w,1,w,1),d.history.push(!1)},_resizeObserver:null,_toolbarObserver:null,_addEvent:function(){const c=s.iframe?d._ww:e.element.wysiwyg;r.isResizeObserverSupported&&(this._resizeObserver=new a.ResizeObserver(function(u){d.__callResizeFunction(-1,u[0])})),e.element.toolbar.addEventListener("mousedown",h._buttonsEventHandler,!1),e.element._menuTray.addEventListener("mousedown",h._buttonsEventHandler,!1),e.element.toolbar.addEventListener("click",h.onClick_toolbar,!1),c.addEventListener("mousedown",h.onMouseDown_wysiwyg,!1),c.addEventListener("click",h.onClick_wysiwyg,!1),c.addEventListener(r.isIE?"textinput":"input",h.onInput_wysiwyg,!1),c.addEventListener("keydown",h.onKeyDown_wysiwyg,!1),c.addEventListener("keyup",h.onKeyUp_wysiwyg,!1),c.addEventListener("paste",h.onPaste_wysiwyg,!1),c.addEventListener("copy",h.onCopy_wysiwyg,!1),c.addEventListener("cut",h.onCut_wysiwyg,!1),c.addEventListener("drop",h.onDrop_wysiwyg,!1),c.addEventListener("scroll",h.onScroll_wysiwyg,!1),c.addEventListener("focus",h.onFocus_wysiwyg,!1),c.addEventListener("blur",h.onBlur_wysiwyg,!1),h._lineBreakerBind={a:h._onLineBreak.bind(""),t:h._onLineBreak.bind("t"),b:h._onLineBreak.bind("b")},c.addEventListener("mousemove",h.onMouseMove_wysiwyg,!1),d._lineBreakerButton.addEventListener("mousedown",h._onMouseDown_lineBreak,!1),d._lineBreakerButton.addEventListener("click",h._lineBreakerBind.a,!1),e.element.lineBreaker_t.addEventListener("mousedown",h._lineBreakerBind.t,!1),e.element.lineBreaker_b.addEventListener("mousedown",h._lineBreakerBind.b,!1),c.addEventListener("touchstart",h.onMouseDown_wysiwyg,{passive:!0,useCapture:!1}),c.addEventListener("touchend",h.onClick_wysiwyg,{passive:!0,useCapture:!1}),s.height==="auto"&&!s.codeMirrorEditor&&(e.element.code.addEventListener("keydown",h._codeViewAutoHeight,!1),e.element.code.addEventListener("keyup",h._codeViewAutoHeight,!1),e.element.code.addEventListener("paste",h._codeViewAutoHeight,!1)),e.element.resizingBar&&(/\d+/.test(s.height)&&s.resizeEnable?e.element.resizingBar.addEventListener("mousedown",h.onMouseDown_resizingBar,!1):r.addClass(e.element.resizingBar,"se-resizing-none")),h._setResponsiveToolbar(),r.isResizeObserverSupported&&(this._toolbarObserver=new a.ResizeObserver(d.resetResponsiveToolbar)),a.addEventListener("resize",h.onResize_window,!1),s.stickyToolbar>-1&&a.addEventListener("scroll",h.onScroll_window,!1)},_removeEvent:function(){const c=s.iframe?d._ww:e.element.wysiwyg;e.element.toolbar.removeEventListener("mousedown",h._buttonsEventHandler),e.element._menuTray.removeEventListener("mousedown",h._buttonsEventHandler),e.element.toolbar.removeEventListener("click",h.onClick_toolbar),c.removeEventListener("mousedown",h.onMouseDown_wysiwyg),c.removeEventListener("click",h.onClick_wysiwyg),c.removeEventListener(r.isIE?"textinput":"input",h.onInput_wysiwyg),c.removeEventListener("keydown",h.onKeyDown_wysiwyg),c.removeEventListener("keyup",h.onKeyUp_wysiwyg),c.removeEventListener("paste",h.onPaste_wysiwyg),c.removeEventListener("copy",h.onCopy_wysiwyg),c.removeEventListener("cut",h.onCut_wysiwyg),c.removeEventListener("drop",h.onDrop_wysiwyg),c.removeEventListener("scroll",h.onScroll_wysiwyg),c.removeEventListener("mousemove",h.onMouseMove_wysiwyg),d._lineBreakerButton.removeEventListener("mousedown",h._onMouseDown_lineBreak),d._lineBreakerButton.removeEventListener("click",h._lineBreakerBind.a),e.element.lineBreaker_t.removeEventListener("mousedown",h._lineBreakerBind.t),e.element.lineBreaker_b.removeEventListener("mousedown",h._lineBreakerBind.b),h._lineBreakerBind=null,c.removeEventListener("touchstart",h.onMouseDown_wysiwyg,{passive:!0,useCapture:!1}),c.removeEventListener("touchend",h.onClick_wysiwyg,{passive:!0,useCapture:!1}),c.removeEventListener("focus",h.onFocus_wysiwyg),c.removeEventListener("blur",h.onBlur_wysiwyg),e.element.code.removeEventListener("keydown",h._codeViewAutoHeight),e.element.code.removeEventListener("keyup",h._codeViewAutoHeight),e.element.code.removeEventListener("paste",h._codeViewAutoHeight),e.element.resizingBar&&e.element.resizingBar.removeEventListener("mousedown",h.onMouseDown_resizingBar),h._resizeObserver&&(h._resizeObserver.unobserve(e.element.wysiwygFrame),h._resizeObserver=null),h._toolbarObserver&&(h._toolbarObserver.unobserve(e.element._toolbarShadow),h._toolbarObserver=null),a.removeEventListener("resize",h.onResize_window),a.removeEventListener("scroll",h.onScroll_window)},_setResponsiveToolbar:function(){if(o.length===0){o=null;return}h._responsiveCurrentSize="default";const c=h._responsiveButtonSize=[],u=h._responsiveButtons={default:o[0]};for(let p=1,b=o.length,y,w;p<b;p++)w=o[p],y=w[0]*1,c.push(y),u[y]=w[1];c.sort(function(p,b){return p-b}).unshift("default")}},v={core:d,util:r,onload:null,onScroll:null,onMouseDown:null,onClick:null,onInput:null,onKeyDown:null,onKeyUp:null,onCopy:null,onCut:null,onFocus:null,onBlur:null,onChange:null,onSave:null,onDrop:null,onPaste:null,showInline:null,showController:null,toggleCodeView:null,toggleFullScreen:null,imageUploadHandler:null,videoUploadHandler:null,audioUploadHandler:null,onImageUploadBefore:null,onVideoUploadBefore:null,onAudioUploadBefore:null,onImageUpload:null,onVideoUpload:null,onAudioUpload:null,onImageUploadError:null,onVideoUploadError:null,onAudioUploadError:null,onResizeEditor:null,onSetToolbarButtons:null,setToolbarButtons:function(c){d.submenuOff(),d.containerOff(),d.moreLayerOff();const u=Zr._createToolBar(l,c,d.plugins,s);o=u.responsiveButtons,h._setResponsiveToolbar(),e.element.toolbar.replaceChild(u._buttonTray,e.element._buttonTray);const p=qr(e.element.originElement,d._getConstructed(e.element),s);e.element=p.element,e.tool=p.tool,s.iframe&&(e.element.wysiwyg=d._wd.body),d._recoverButtonStates(),d._cachingButtons(),d.history._resetCachingButton(),d.effectNode=null,d.hasFocus&&h._applyTagEffects(),d.isReadOnly&&r.setDisabledButtons(!0,d.resizingDisabledButtons),typeof v.onSetToolbarButtons=="function"&&v.onSetToolbarButtons(u._buttonTray.querySelectorAll("button"),d)},setOptions:function(c){h._removeEvent(),d._resetComponents(),r.removeClass(d._styleCommandMap.showBlocks,"active"),r.removeClass(d._styleCommandMap.codeView,"active"),d._variable.isCodeView=!1,d._iframeAuto=null,d.plugins=c.plugins||d.plugins;const u=[s,c].reduce(function(w,x){for(let E in x)if(r.hasOwn(x,E))if(E==="plugins"&&x[E]&&w[E]){let k=w[E],N=x[E];k=k.length?k:a.Object.keys(k).map(function(T){return k[T]}),N=N.length?N:a.Object.keys(N).map(function(T){return N[T]}),w[E]=N.filter(function(T){return k.indexOf(T)===-1}).concat(k)}else w[E]=x[E];return w},{}),p=e.element,b=p.wysiwyg.innerHTML,y=Zr._setOptions(u,e,s);y.callButtons&&(t=y.callButtons,d.initPlugins={}),y.plugins&&(d.plugins=n=y.plugins),p._menuTray.children.length===0&&(this._menuTray={}),o=y.toolbar.responsiveButtons,d.options=s=u,d.lang=i=s.lang,s.iframe&&p.wysiwygFrame.addEventListener("load",function(){r._setIframeDocument(this,s),d._setOptionsInit(p,b)}),p.editorArea.appendChild(p.wysiwygFrame),s.iframe||d._setOptionsInit(p,b)},setDefaultStyle:function(c){const u=s._editorStyles=r._setDefaultOptionStyle(s,c),p=e.element;p.topArea.style.cssText=u.top,p.code.style.cssText=s._editorStyles.frame,p.code.style.display="none",s.height==="auto"?p.code.style.overflow="hidden":p.code.style.overflow="",s.iframe?(p.wysiwygFrame.style.cssText=u.frame,p.wysiwyg.style.cssText=u.editor):p.wysiwygFrame.style.cssText=u.frame+u.editor},noticeOpen:function(c){d.notice.open.call(d,c)},noticeClose:function(){d.notice.close.call(d)},save:function(){const c=d.getContents(!1);e.element.originElement.value=c,h.onSave_wysiwyg(c,d)},getContext:function(){return e},getContents:function(c){return d.getContents(c)},getText:function(){return e.element.wysiwyg.textContent},getCharCount:function(c){return c=typeof c=="string"?c:s.charCounterType,d.getCharLength(d._charTypeHTML?e.element.wysiwyg.innerHTML:e.element.wysiwyg.textContent,c)},getImagesInfo:function(){return e.image?e.image._infoList:[]},getFilesInfo:function(c){return e[c]?e[c]._infoList:[]},insertImage:function(c){!d.plugins.image||!c||(d.initPlugins.image?d.plugins.image.submitAction.call(d,c):d.callPlugin("image",d.plugins.image.submitAction.bind(d,c),null),d.focus())},insertHTML:function(c,u,p,b){if(e.element.wysiwygFrame.contains(d.getSelection().focusNode)||d.focus(),typeof c=="string"){u||(c=d.cleanHTML(c,null,null));try{if(r.isListCell(r.getFormatElement(d.getSelectionNode(),null))){const A=l.createRange().createContextualFragment(c).childNodes;d._isFormatData(A)&&(c=d._convertListCell(A))}const w=l.createRange().createContextualFragment(c).childNodes;if(p){const M=d._charTypeHTML?"outerHTML":"textContent";let A="";for(let D=0,$=w.length;D<$;D++)A+=w[D][M];if(!d.checkCharCount(A,null))return}let x,E,k,N,T;for(;x=w[0];){if(N&&N.nodeType===3&&E&&E.nodeType===1&&r.isBreak(x)){N=x,r.removeItem(x);continue}k=d.insertNode(x,E,!1),E=k.container||k,T||(T=k),N=x}N.nodeType===3&&E.nodeType===1&&(E=N);const R=E.nodeType===3?k.endOffset||E.textContent.length:E.childNodes.length;b?d.setRange(T.container||T,T.startOffset||0,E,R):d.setRange(E,R,E,R)}catch(y){if(d.isDisabled||d.isReadOnly)return;console.warn("[SUNEDITOR.insertHTML.fail] "+y),d.execCommand("insertHTML",!1,c)}}else if(r.isComponent(c))d.insertComponent(c,!1,p,!1);else{let y=null;(r.isFormatElement(c)||r.isMedia(c))&&(y=r.getFormatElement(d.getSelectionNode(),null)),d.insertNode(c,y,p)}d.effectNode=null,d.focus(),d.history.push(!1)},setContents:function(c){d.setContents(c)},appendContents:function(c){const u=d.convertContentsForEditor(c);if(d._variable.isCodeView)d._setCodeView(d._getCodeView()+`
252
- `+d.convertHTMLForCodeView(u,!1));else{const p=r.createElement("DIV");p.innerHTML=u;const b=e.element.wysiwyg,y=p.children;for(let w=0,x=y.length;w<x;w++)y[w]&&b.appendChild(y[w])}d.history.push(!1)},readOnly:function(c){d.isReadOnly=c,r.setDisabledButtons(!!c,d.resizingDisabledButtons),c?(d.controllersOff(),d.submenuActiveButton&&d.submenuActiveButton.disabled&&d.submenuOff(),d._moreLayerActiveButton&&d._moreLayerActiveButton.disabled&&d.moreLayerOff(),d.containerActiveButton&&d.containerActiveButton.disabled&&d.containerOff(),d.modalForm&&d.plugins.dialog.close.call(d),e.element.code.setAttribute("readOnly","true"),r.addClass(e.element.wysiwygFrame,"se-read-only")):(e.element.code.removeAttribute("readOnly"),r.removeClass(e.element.wysiwygFrame,"se-read-only")),s.codeMirrorEditor&&s.codeMirrorEditor.setOption("readOnly",!!c)},disable:function(){this.toolbar.disable(),this.wysiwyg.disable()},disabled:function(){this.disable()},enable:function(){this.toolbar.enable(),this.wysiwyg.enable()},enabled:function(){this.enable()},show:function(){const c=e.element.topArea.style;c.display==="none"&&(c.display=s.display)},hide:function(){e.element.topArea.style.display="none"},destroy:function(){d.submenuOff(),d.containerOff(),d.controllersOff(),d.notice&&d.notice.close.call(d),d.modalForm&&d.plugins.dialog.close.call(d),d.history._destroy(),h._removeEvent(),r.removeItem(e.element.toolbar),r.removeItem(e.element.topArea);for(let c in d.functions)r.hasOwn(d,c)&&delete d.functions[c];for(let c in d)r.hasOwn(d,c)&&delete d[c];for(let c in h)r.hasOwn(h,c)&&delete h[c];for(let c in e)r.hasOwn(e,c)&&delete e[c];for(let c in t)r.hasOwn(t,c)&&delete t[c];for(let c in this)r.hasOwn(this,c)&&delete this[c]},toolbar:{disable:function(){d.submenuOff(),d.moreLayerOff(),d.containerOff(),e.tool.cover.style.display="block"},disabled:function(){this.disable()},enable:function(){e.tool.cover.style.display="none"},enabled:function(){this.enable()},show:function(){d._isInline?h._showToolbarInline():(e.element.toolbar.style.display="",e.element._stickyDummy.style.display=""),h.onResize_window()},hide:function(){d._isInline?h._hideToolbar():(e.element.toolbar.style.display="none",e.element._stickyDummy.style.display="none"),h.onResize_window()}},wysiwyg:{disable:function(){d.controllersOff(),d.modalForm&&d.plugins.dialog.close.call(d),e.element.wysiwyg.setAttribute("contenteditable",!1),d.isDisabled=!0,s.codeMirrorEditor?s.codeMirrorEditor.setOption("readOnly",!0):e.element.code.setAttribute("disabled","disabled")},enable:function(){e.element.wysiwyg.setAttribute("contenteditable",!0),d.isDisabled=!1,s.codeMirrorEditor?s.codeMirrorEditor.setOption("readOnly",!1):e.element.code.removeAttribute("disabled")}}};d.functions=v,d.options=s;let _=e.element,C=_.originElement,S=_.topArea;return C.style.display="none",S.style.display="block",s.iframe&&_.wysiwygFrame.addEventListener("load",function(){r._setIframeDocument(this,s),d._editorInit(!1,s.value),s.value=null}),typeof C.nextElementSibling=="object"?C.parentNode.insertBefore(S,C.nextElementSibling):C.parentNode.appendChild(S),_.editorArea.appendChild(_.wysiwygFrame),_=C=S=null,s.iframe||(d._editorInit(!1,s.value),s.value=null),v}const MC={init:function(e){return{create:(function(t,n){return this.create(t,n,e)}).bind(this)}},create:function(e,t,n){pe._propertiesInit(),typeof t!="object"&&(t={}),n&&(t=[n,t].reduce(function(o,l){for(let a in l)if(pe.hasOwn(l,a))if(a==="plugins"&&l[a]&&o[a]){let r=o[a],f=l[a];r=r.length?r:Object.keys(r).map(function(d){return r[d]}),f=f.length?f:Object.keys(f).map(function(d){return f[d]}),o[a]=f.filter(function(d){return r.indexOf(d)===-1}).concat(r)}else o[a]=l[a];return o},{}));const i=typeof e=="string"?document.getElementById(e):e;if(!i)throw Error(typeof e=="string"?'[SUNEDITOR.create.fail] The element for that id was not found (ID:"'+e+'")':"[SUNEDITOR.create.fail] suneditor requires textarea's element or id value");const s=Zr.init(i,t);if(s.constructed._top.id&&document.getElementById(s.constructed._top.id))throw Error('[SUNEDITOR.create.fail] The ID of the suneditor you are trying to create already exists (ID:"'+s.constructed._top.id+'")');return TC(qr(i,s.constructed,s.options),s.pluginCallButtons,s.plugins,s.options.lang,t,s._responsiveButtons)}},AC={name:"blockquote",display:"command",add:function(e,t){const n=e.context;n.blockquote={targetButton:t,tag:e.util.createElement("BLOCKQUOTE")}},active:function(e){if(!e)this.util.removeClass(this.context.blockquote.targetButton,"active");else if(/blockquote/i.test(e.nodeName))return this.util.addClass(this.context.blockquote.targetButton,"active"),!0;return!1},action:function(){const e=this.util.getParentElement(this.getSelectionNode(),"blockquote");e?this.detachRangeFormatElement(e,null,null,!1,!1):this.applyRangeFormatElement(this.context.blockquote.tag.cloneNode(!1))}},RC={name:"align",display:"submenu",add:function(e,t){const n=e.icons,i=e.context;i.align={targetButton:t,_itemMenu:null,_alignList:null,currentAlign:"",defaultDir:e.options.rtl?"right":"left",icons:{justify:n.align_justify,left:n.align_left,right:n.align_right,center:n.align_center}};let s=this.setSubmenu(e),o=i.align._itemMenu=s.querySelector("ul");o.addEventListener("click",this.pickup.bind(e)),i.align._alignList=o.querySelectorAll("li button"),e.initMenuTarget(this.name,t,s),s=null,o=null},setSubmenu:function(e){const t=e.lang,n=e.icons,i=e.util.createElement("DIV"),s=e.options.alignItems;let o="";for(let l=0,a,r;l<s.length;l++)a=s[l],r=t.toolbar["align"+a.charAt(0).toUpperCase()+a.slice(1)],o+='<li><button type="button" class="se-btn-list se-btn-align" data-value="'+a+'" title="'+r+'" aria-label="'+r+'"><span class="se-list-icon">'+n["align_"+a]+"</span>"+r+"</button></li>";return i.className="se-submenu se-list-layer se-list-align",i.innerHTML='<div class="se-list-inner"><ul class="se-list-basic">'+o+"</ul></div>",i},active:function(e){const t=this.context.align,n=t.targetButton,i=n.firstElementChild;if(!e)this.util.changeElement(i,t.icons[t.defaultDir]),n.removeAttribute("data-focus");else if(this.util.isFormatElement(e)){const s=e.style.textAlign;if(s)return this.util.changeElement(i,t.icons[s]||t.icons[t.defaultDir]),n.setAttribute("data-focus",s),!0}return!1},on:function(){const e=this.context.align,t=e._alignList,n=e.targetButton.getAttribute("data-focus")||e.defaultDir;if(n!==e.currentAlign){for(let i=0,s=t.length;i<s;i++)n===t[i].getAttribute("data-value")?this.util.addClass(t[i],"active"):this.util.removeClass(t[i],"active");e.currentAlign=n}},exchangeDir:function(){const e=this.options.rtl?"right":"left";if(!this.context.align||this.context.align.defaultDir===e)return;this.context.align.defaultDir=e;let t=this.context.align._itemMenu,n=t.querySelector('[data-value="left"]'),i=t.querySelector('[data-value="right"]');if(n&&i){const s=n.parentElement,o=i.parentElement;s.appendChild(i),o.appendChild(n)}},pickup:function(e){e.preventDefault(),e.stopPropagation();let t=e.target,n=null;for(;!n&&!/UL/i.test(t.tagName);)n=t.getAttribute("data-value"),t=t.parentNode;if(!n)return;const i=this.context.align.defaultDir,s=this.getSelectedElements();for(let o=0,l=s.length;o<l;o++)this.util.setStyle(s[o],"textAlign",n===i?"":n);this.effectNode=null,this.submenuOff(),this.focus(),this.history.push(!1)}},DC={name:"font",display:"submenu",add:function(e,t){const n=e.context;n.font={targetText:t.querySelector(".txt"),targetTooltip:t.parentNode.querySelector(".se-tooltip-text"),_fontList:null,currentFont:""};let i=this.setSubmenu(e);i.querySelector(".se-list-inner").addEventListener("click",this.pickup.bind(e)),n.font._fontList=i.querySelectorAll("ul li button"),e.initMenuTarget(this.name,t,i),i=null},setSubmenu:function(e){const t=e.lang,n=e.util.createElement("DIV");n.className="se-submenu se-list-layer se-list-font-family";let i,s,o,l,a=e.options.font,r='<div class="se-list-inner"><ul class="se-list-basic"><li><button type="button" class="default_value se-btn-list" title="'+t.toolbar.default+'" aria-label="'+t.toolbar.default+'">('+t.toolbar.default+")</button></li>";for(o=0,l=a.length;o<l;o++)i=a[o],s=i.split(",")[0],r+='<li><button type="button" class="se-btn-list" data-value="'+i+'" data-txt="'+s+'" title="'+s+'" aria-label="'+s+'" style="font-family:'+i+';">'+s+"</button></li>";return r+="</ul></div>",n.innerHTML=r,n},active:function(e){const t=this.context.font.targetText,n=this.context.font.targetTooltip;if(e){if(e.style&&e.style.fontFamily.length>0){const i=e.style.fontFamily.replace(/["']/g,"");return this.util.changeTxt(t,i),this.util.changeTxt(n,this.lang.toolbar.font+" ("+i+")"),!0}}else{const i=this.hasFocus?this.wwComputedStyle.fontFamily:this.lang.toolbar.font;this.util.changeTxt(t,i),this.util.changeTxt(n,this.hasFocus?this.lang.toolbar.font+(i?" ("+i+")":""):i)}return!1},on:function(){const e=this.context.font,t=e._fontList,n=e.targetText.textContent;if(n!==e.currentFont){for(let i=0,s=t.length;i<s;i++)n===(t[i].getAttribute("data-value")||"").replace(/'|"/g,"")?this.util.addClass(t[i],"active"):this.util.removeClass(t[i],"active");e.currentFont=n}},pickup:function(e){if(!/^BUTTON$/i.test(e.target.tagName))return!1;e.preventDefault(),e.stopPropagation();let t=e.target.getAttribute("data-value");if(t){const n=this.util.createElement("SPAN");/[\s\d\W]/.test(t)&&!/^['"].*['"]$/.test(t)&&(t='"'+t+'"'),n.style.fontFamily=t,this.nodeChange(n,["font-family"],null,null)}else this.nodeChange(null,["font-family"],["span"],!0);this.submenuOff()}},LC={name:"fontSize",display:"submenu",add:function(e,t){const n=e.context;n.fontSize={targetText:t.querySelector(".txt"),_sizeList:null,currentSize:""};let i=this.setSubmenu(e),s=i.querySelector("ul");s.addEventListener("click",this.pickup.bind(e)),n.fontSize._sizeList=s.querySelectorAll("li button"),e.initMenuTarget(this.name,t,i),i=null,s=null},setSubmenu:function(e){const t=e.options,n=e.lang,i=e.util.createElement("DIV");i.className="se-submenu se-list-layer se-list-font-size";const s=t.fontSize?t.fontSize:[8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72];let o='<div class="se-list-inner"><ul class="se-list-basic"><li><button type="button" class="default_value se-btn-list" title="'+n.toolbar.default+'" aria-label="'+n.toolbar.default+'">('+n.toolbar.default+")</button></li>";for(let l=0,a=t.fontSizeUnit,r=s.length,f;l<r;l++)f=s[l],o+='<li><button type="button" class="se-btn-list" data-value="'+f+a+'" title="'+f+a+'" aria-label="'+f+a+'" style="font-size:'+f+a+';">'+f+"</button></li>";return o+="</ul></div>",i.innerHTML=o,i},active:function(e){if(!e)this.util.changeTxt(this.context.fontSize.targetText,this.hasFocus?this._convertFontSize.call(this,this.options.fontSizeUnit,this.wwComputedStyle.fontSize):this.lang.toolbar.fontSize);else if(e.style&&e.style.fontSize.length>0)return this.util.changeTxt(this.context.fontSize.targetText,this._convertFontSize.call(this,this.options.fontSizeUnit,e.style.fontSize)),!0;return!1},on:function(){const e=this.context.fontSize,t=e._sizeList,n=e.targetText.textContent;if(n!==e.currentSize){for(let i=0,s=t.length;i<s;i++)n===t[i].getAttribute("data-value")?this.util.addClass(t[i],"active"):this.util.removeClass(t[i],"active");e.currentSize=n}},pickup:function(e){if(!/^BUTTON$/i.test(e.target.tagName))return!1;e.preventDefault(),e.stopPropagation();const t=e.target.getAttribute("data-value");if(t){const n=this.util.createElement("SPAN");n.style.fontSize=t,this.nodeChange(n,["font-size"],null,null)}else this.nodeChange(null,["font-size"],["span"],!0);this.submenuOff()}},lh={name:"colorPicker",add:function(e){const t=e.context;t.colorPicker={colorListHTML:"",_colorInput:"",_defaultColor:"#000",_styleProperty:"color",_currentColor:"",_colorList:[]},t.colorPicker.colorListHTML=this.createColorList(e,this._makeColorList)},createColorList:function(e,t){const n=e.options,i=e.lang,s=!n.colorList||n.colorList.length===0?["#ff0000","#ff5e00","#ffe400","#abf200","#00d8ff","#0055ff","#6600ff","#ff00dd","#000000","#ffd8d8","#fae0d4","#faf4c0","#e4f7ba","#d4f4fa","#d9e5ff","#e8d9ff","#ffd9fa","#f1f1f1","#ffa7a7","#ffc19e","#faed7d","#cef279","#b2ebf4","#b2ccff","#d1b2ff","#ffb2f5","#bdbdbd","#f15f5f","#f29661","#e5d85c","#bce55c","#5cd1e5","#6699ff","#a366ff","#f261df","#8c8c8c","#980000","#993800","#998a00","#6b9900","#008299","#003399","#3d0099","#990085","#353535","#670000","#662500","#665c00","#476600","#005766","#002266","#290066","#660058","#222222"]:n.colorList;let o=[],l='<div class="se-list-inner">';for(let a=0,r=s.length,f;a<r;a++)f=s[a],f&&(typeof f=="string"&&(o.push(f),a<r-1)||(o.length>0&&(l+='<div class="se-selector-color">'+t(o)+"</div>",o=[]),typeof f=="object"&&(l+='<div class="se-selector-color">'+t(f)+"</div>")));return l+='<form class="se-form-group"><input type="text" maxlength="9" class="_se_color_picker_input se-color-input"/><button type="submit" class="se-btn-primary _se_color_picker_submit" title="'+i.dialogBox.submitButton+'" aria-label="'+i.dialogBox.submitButton+'">'+e.icons.checked+'</button><button type="button" class="se-btn _se_color_picker_remove" title="'+i.toolbar.removeFormat+'" aria-label="'+i.toolbar.removeFormat+'">'+e.icons.erase+"</button></form></div>",l},_makeColorList:function(e){let t="";t+='<ul class="se-color-pallet">';for(let n=0,i=e.length,s;n<i;n++)s=e[n],typeof s=="string"&&(t+='<li><button type="button" data-value="'+s+'" title="'+s+'" aria-label="'+s+'" style="background-color:'+s+';"></button></li>');return t+="</ul>",t},init:function(e,t){const n=this.plugins.colorPicker;let i=t||n.getColorInNode.call(this,e)||this.context.colorPicker._defaultColor;i=n.isHexColor(i)?i:n.rgb2hex(i)||i;const s=this.context.colorPicker._colorList;if(s)for(let o=0,l=s.length;o<l;o++)i.toLowerCase()===s[o].getAttribute("data-value").toLowerCase()?this.util.addClass(s[o],"active"):this.util.removeClass(s[o],"active");n.setInputText.call(this,n.colorName2hex.call(this,i))},setCurrentColor:function(e){this.context.colorPicker._currentColor=e,this.context.colorPicker._colorInput.style.borderColor=e},setInputText:function(e){e=/^#/.test(e)?e:"#"+e,this.context.colorPicker._colorInput.value=e,this.plugins.colorPicker.setCurrentColor.call(this,e)},getColorInNode:function(e){let t="";const n=this.context.colorPicker._styleProperty;for(;e&&!this.util.isWysiwygDiv(e)&&t.length===0;)e.nodeType===1&&e.style[n]&&(t=e.style[n]),e=e.parentNode;return t},isHexColor:function(e){return/^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(e)},rgb2hex:function(e){const t=e.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);return t&&t.length===4?"#"+("0"+parseInt(t[1],10).toString(16)).slice(-2)+("0"+parseInt(t[2],10).toString(16)).slice(-2)+("0"+parseInt(t[3],10).toString(16)).slice(-2):""},colorName2hex:function(e){if(/^#/.test(e))return e;var t=this.util.createElement("div");t.style.display="none",t.style.color=e;var n=this._w.getComputedStyle(this._d.body.appendChild(t)).color.match(/\d+/g).map(function(i){return parseInt(i,10)});return this.util.removeItem(t),n.length>=3?"#"+((1<<24)+(n[0]<<16)+(n[1]<<8)+n[2]).toString(16).substr(1):!1}},OC={name:"fontColor",display:"submenu",add:function(e,t){e.addModule([lh]);const n=e.context;n.fontColor={previewEl:null,colorInput:null,colorList:null};let i=this.setSubmenu(e);n.fontColor.colorInput=i.querySelector("._se_color_picker_input"),n.fontColor.colorInput.addEventListener("keyup",this.onChangeInput.bind(e)),i.querySelector("._se_color_picker_submit").addEventListener("click",this.submit.bind(e)),i.querySelector("._se_color_picker_remove").addEventListener("click",this.remove.bind(e)),i.addEventListener("click",this.pickup.bind(e)),n.fontColor.colorList=i.querySelectorAll("li button"),e.initMenuTarget(this.name,t,i),i=null},setSubmenu:function(e){const t=e.context.colorPicker.colorListHTML,n=e.util.createElement("DIV");return n.className="se-submenu se-list-layer",n.innerHTML=t,n},on:function(){const e=this.context.colorPicker,t=this.context.fontColor;e._colorInput=t.colorInput;const n=this.wwComputedStyle.color;e._defaultColor=n?this.plugins.colorPicker.isHexColor(n)?n:this.plugins.colorPicker.rgb2hex(n):"#333333",e._styleProperty="color",e._colorList=t.colorList,this.plugins.colorPicker.init.call(this,this.getSelectionNode(),null)},onChangeInput:function(e){this.plugins.colorPicker.setCurrentColor.call(this,e.target.value)},submit:function(){this.plugins.fontColor.applyColor.call(this,this.context.colorPicker._currentColor)},pickup:function(e){e.preventDefault(),e.stopPropagation(),this.plugins.fontColor.applyColor.call(this,e.target.getAttribute("data-value"))},remove:function(){this.nodeChange(null,["color"],["span"],!0),this.submenuOff()},applyColor:function(e){if(!e)return;const t=this.util.createElement("SPAN");t.style.color=e,this.nodeChange(t,["color"],null,null),this.submenuOff()}},PC={name:"hiliteColor",display:"submenu",add:function(e,t){e.addModule([lh]);const n=e.context;n.hiliteColor={previewEl:null,colorInput:null,colorList:null};let i=this.setSubmenu(e);n.hiliteColor.colorInput=i.querySelector("._se_color_picker_input"),n.hiliteColor.colorInput.addEventListener("keyup",this.onChangeInput.bind(e)),i.querySelector("._se_color_picker_submit").addEventListener("click",this.submit.bind(e)),i.querySelector("._se_color_picker_remove").addEventListener("click",this.remove.bind(e)),i.addEventListener("click",this.pickup.bind(e)),n.hiliteColor.colorList=i.querySelectorAll("li button"),e.initMenuTarget(this.name,t,i),i=null},setSubmenu:function(e){const t=e.context.colorPicker.colorListHTML,n=e.util.createElement("DIV");return n.className="se-submenu se-list-layer",n.innerHTML=t,n},on:function(){const e=this.context.colorPicker,t=this.context.hiliteColor;e._colorInput=t.colorInput;const n=this.wwComputedStyle.backgroundColor;e._defaultColor=n?this.plugins.colorPicker.isHexColor(n)?n:this.plugins.colorPicker.rgb2hex(n):"#ffffff",e._styleProperty="backgroundColor",e._colorList=t.colorList,this.plugins.colorPicker.init.call(this,this.getSelectionNode(),null)},onChangeInput:function(e){this.plugins.colorPicker.setCurrentColor.call(this,e.target.value)},submit:function(){this.plugins.hiliteColor.applyColor.call(this,this.context.colorPicker._currentColor)},pickup:function(e){e.preventDefault(),e.stopPropagation(),this.plugins.hiliteColor.applyColor.call(this,e.target.getAttribute("data-value"))},remove:function(){this.nodeChange(null,["background-color"],["span"],!0),this.submenuOff()},applyColor:function(e){if(!e)return;const t=this.util.createElement("SPAN");t.style.backgroundColor=e,this.nodeChange(t,["background-color"],null,null),this.submenuOff()}},IC={name:"horizontalRule",display:"submenu",add:function(e,t){e.context.horizontalRule={currentHR:null};let n=this.setSubmenu(e);n.querySelector("ul").addEventListener("click",this.horizontalRulePick.bind(e)),e.initMenuTarget(this.name,t,n),n=null},setSubmenu:function(e){const t=e.lang,n=e.util.createElement("DIV"),i=e.options.hrItems||[{name:t.toolbar.hr_solid,class:"__se__solid"},{name:t.toolbar.hr_dashed,class:"__se__dashed"},{name:t.toolbar.hr_dotted,class:"__se__dotted"}];let s="";for(let o=0,l=i.length;o<l;o++)s+='<li><button type="button" class="se-btn-list btn_line" data-command="horizontalRule" data-value="'+i[o].class+'" title="'+i[o].name+'" aria-label="'+i[o].name+'"><hr'+(i[o].class?' class="'+i[o].class+'"':"")+(i[o].style?' style="'+i[o].style+'"':"")+"/></button></li>";return n.className="se-submenu se-list-layer se-list-line",n.innerHTML='<div class="se-list-inner"><ul class="se-list-basic">'+s+"</ul></div>",n},active:function(e){if(!e)this.util.hasClass(this.context.horizontalRule.currentHR,"on")&&this.controllersOff();else if(/HR/i.test(e.nodeName))return this.context.horizontalRule.currentHR=e,this.util.hasClass(e,"on")||(this.util.addClass(e,"on"),this.controllersOn("hr",this.util.removeClass.bind(this.util,e,"on"))),!0;return!1},appendHr:function(e){return this.focus(),this.insertComponent(e.cloneNode(!1),!1,!0,!1)},horizontalRulePick:function(e){e.preventDefault(),e.stopPropagation();let t=e.target,n=t.getAttribute("data-command");for(;!n&&!/UL/i.test(t.tagName);)t=t.parentNode,n=t.getAttribute("data-command");if(!n)return;const i=this.plugins.horizontalRule.appendHr.call(this,t.firstElementChild);i&&(this.setRange(i,0,i,0),this.submenuOff())}},BC={name:"list",display:"submenu",add:function(e,t){const n=e.context;n.list={targetButton:t,_list:null,currentList:"",icons:{bullets:e.icons.list_bullets,number:e.icons.list_number}};let i=this.setSubmenu(e),s=i.querySelector("ul");s.addEventListener("click",this.pickup.bind(e)),n.list._list=s.querySelectorAll("li button"),e.initMenuTarget(this.name,t,i),i=null,s=null},setSubmenu:function(e){const t=e.lang,n=e.util.createElement("DIV");return n.className="se-submenu se-list-layer",n.innerHTML='<div class="se-list-inner"><ul class="se-list-basic"><li><button type="button" class="se-btn-list se-tooltip" data-command="OL" title="'+t.toolbar.orderList+'" aria-label="'+t.toolbar.orderList+'">'+e.icons.list_number+'</button></li><li><button type="button" class="se-btn-list se-tooltip" data-command="UL" title="'+t.toolbar.unorderList+'" aria-label="'+t.toolbar.unorderList+'">'+e.icons.list_bullets+"</button></li></ul></div>",n},active:function(e){const t=this.context.list.targetButton,n=t.firstElementChild,i=this.util;if(i.isList(e)){const s=e.nodeName;return t.setAttribute("data-focus",s),i.addClass(t,"active"),/UL/i.test(s)?i.changeElement(n,this.context.list.icons.bullets):i.changeElement(n,this.context.list.icons.number),!0}else t.removeAttribute("data-focus"),i.changeElement(n,this.context.list.icons.number),i.removeClass(t,"active");return!1},on:function(){const e=this.context.list,t=e._list,n=e.targetButton.getAttribute("data-focus")||"";if(n!==e.currentList){for(let i=0,s=t.length;i<s;i++)n===t[i].getAttribute("data-command")?this.util.addClass(t[i],"active"):this.util.removeClass(t[i],"active");e.currentList=n}},editList:function(e,t,n){let i=this.getRange(),s=t||this.getSelectedElementsAndComponents(!1);if(s.length===0&&(t||(i=this.getRange_addLine(i,null),s=this.getSelectedElementsAndComponents(!1),s.length===0)))return;const o=this.util;o.sortByDepth(s,!0);let l=s[0],a=s[s.length-1],r=(o.isListCell(l)||o.isComponent(l))&&!l.previousElementSibling?l.parentNode.previousElementSibling:l.previousElementSibling,f=(o.isListCell(a)||o.isComponent(a))&&!a.nextElementSibling?a.parentNode.nextElementSibling:a.nextElementSibling;const d=i.collapsed,h={sc:i.startContainer,so:i.startContainer===i.endContainer&&o.onlyZeroWidthSpace(i.startContainer)&&i.startOffset===0&&i.endOffset===1?i.endOffset:i.startOffset,ec:i.endContainer,eo:i.endOffset};let v=null,_=!0;for(let C=0,S=s.length;C<S;C++)if(!o.isList(o.getRangeFormatElement(s[C],(function(c){return this.getRangeFormatElement(c)&&c!==s[C]}).bind(o)))){_=!1;break}if(_&&(!r||l.tagName!==r.tagName||e!==r.tagName.toUpperCase())&&(!f||a.tagName!==f.tagName||e!==f.tagName.toUpperCase())){if(n){for(let b=0,y=s.length;b<y;b++)for(let w=b-1;w>=0;w--)if(s[w].contains(s[b])){s.splice(b,1),b--,y--;break}}const C=o.getRangeFormatElement(l),S=C&&C.tagName===e;let c,u;const p=(function(b){return!this.isComponent(b)}).bind(o);S||(u=o.createElement(e));for(let b=0,y=s.length,w,x;b<y;b++)x=o.getRangeFormatElement(s[b],p),!(!x||!o.isList(x))&&(w?w!==x?(n&&o.isListCell(x.parentNode)?this.plugins.list._detachNested.call(this,c.f):v=this.detachRangeFormatElement(c.f[0].parentNode,c.f,u,!1,!0),x=s[b].parentNode,S||(u=o.createElement(e)),w=x,c={r:w,f:[o.getParentElement(s[b],"LI")]}):c.f.push(o.getParentElement(s[b],"LI")):(w=x,c={r:w,f:[o.getParentElement(s[b],"LI")]}),b===y-1&&(n&&o.isListCell(x.parentNode)?this.plugins.list._detachNested.call(this,c.f):v=this.detachRangeFormatElement(c.f[0].parentNode,c.f,u,!1,!0)))}else{const C=r&&r.parentNode,S=f&&f.parentNode;r=C&&!o.isWysiwygDiv(C)&&C.nodeName===e?C:r,f=S&&!o.isWysiwygDiv(S)&&S.nodeName===e?S:f;const c=r&&r.tagName===e,u=f&&f.tagName===e;let p=c?r:o.createElement(e),b=null,y=null,w=null;const x=(function(E){return!this.isComponent(E)&&!this.isList(E)}).bind(o);for(let E=0,k=s.length,N,T,R,M,A,D,$,H,j;E<k;E++){if(T=s[E],T.childNodes.length===0&&!o._isIgnoreNodeChange(T)){o.removeItem(T);continue}if(M=s[E+1],A=T.parentNode,D=M?M.parentNode:null,R=o.isListCell(T),j=o.isRangeFormatElement(A)?A:null,$=R&&!o.isWysiwygDiv(A)?A.parentNode:A,H=R&&!o.isWysiwygDiv(A)?!M||o.isListCell($)?A:A.nextSibling:T.nextSibling,N=o.createElement("LI"),o.copyFormatAttributes(N,T),E===0&&h.sc===T&&(h.sc=N),E===k-1&&h.ec===T&&(h.ec=N),o.isComponent(T)){const F=/^HR$/i.test(T.nodeName);F||(N.innerHTML="<br>"),N.innerHTML+=T.outerHTML,F&&(N.innerHTML+="<br>")}else{const F=T.childNodes;for(;F[0];)N.appendChild(F[0])}p.appendChild(N),(!M||$!==D||o.isRangeFormatElement(H))&&(b||(b=p),(!c||!M||$!==D)&&!(M&&o.isList(D)&&D===A)&&p.parentNode!==$&&$.insertBefore(p,H)),o.removeItem(T),c&&y===null&&(y=p.children.length-1),M&&(o.getRangeFormatElement(D,x)!==o.getRangeFormatElement(A,x)||o.isList(D)&&o.isList(A)&&o.getElementDepth(D)!==o.getElementDepth(A))&&(p=o.createElement(e)),j&&j.children.length===0&&o.removeItem(j)}y&&(b=b.children[y]),u&&(w=p.children.length-1,p.innerHTML+=f.innerHTML,p.children[w],o.removeItem(f))}return this.effectNode=null,d&&v||h},_detachNested:function(e){const t=e[0],n=e[e.length-1],i=n.nextElementSibling,s=t.parentNode,o=s.parentNode.nextElementSibling,l=s.parentNode.parentNode;for(let r=0,f=e.length;r<f;r++)l.insertBefore(e[r],o);if(i&&s.children.length>0){const r=s.cloneNode(!1),f=s.childNodes,d=this.util.getPositionIndex(i);for(;f[d];)r.appendChild(f[d]);n.appendChild(r)}s.children.length===0&&this.util.removeItem(s),this.util.mergeSameTags(l);const a=this.util.getEdgeChildNodes(t,n);return{cc:t.parentNode,sc:a.sc,ec:a.ec}},editInsideList:function(e,t){t=t||this.getSelectedElements().filter((function(l){return this.isListCell(l)}).bind(this.util));const n=t.length;if(n===0||!e&&!this.util.isListCell(t[0].previousElementSibling)&&!this.util.isListCell(t[n-1].nextElementSibling))return{sc:t[0],so:0,ec:t[n-1],eo:1};let i=t[0].parentNode,s=t[n-1],o=null;if(e){if(i!==s.parentNode&&this.util.isList(s.parentNode.parentNode)&&s.nextElementSibling)for(s=s.nextElementSibling;s;)t.push(s),s=s.nextElementSibling;o=this.plugins.list.editList.call(this,i.nodeName.toUpperCase(),t,!0)}else{let l=this.util.createElement(i.nodeName),a=t[0].previousElementSibling,r=s.nextElementSibling;const f={s:null,e:null,sl:i,el:i};for(let v=0,_=n,C;v<_;v++)C=t[v],C.parentNode!==i&&(this.plugins.list._insiedList.call(this,i,l,a,r,f),i=C.parentNode,l=this.util.createElement(i.nodeName)),a=C.previousElementSibling,r=C.nextElementSibling,l.appendChild(C);this.plugins.list._insiedList.call(this,i,l,a,r,f);const d=this.util.getNodeFromPath(f.s,f.sl),h=this.util.getNodeFromPath(f.e,f.el);o={sc:d,so:0,ec:h,eo:h.textContent.length}}return o},_insiedList:function(e,t,n,i,s){let o=!1;if(n&&t.tagName===n.tagName){const l=t.children;for(;l[0];)n.appendChild(l[0]);t=n,o=!0}if(i&&t.tagName===i.tagName){const l=i.children;for(;l[0];)t.appendChild(l[0]);const a=i.nextElementSibling;i.parentNode.removeChild(i),i=a}if(!o){this.util.isListCell(n)&&(e=n,i=null),e.insertBefore(t,i),s.s||(s.s=this.util.getNodePath(t.firstElementChild.firstChild,e,null),s.sl=e);const l=e.contains(s.sl)?this.util.getNodePath(s.sl,e):null;s.e=this.util.getNodePath(t.lastElementChild.firstChild,e,null),s.el=e,this.util.mergeSameTags(e,[s.s,s.e,l],!1),this.util.mergeNestedTags(e),l&&(s.sl=this.util.getNodeFromPath(l,e))}return t},pickup:function(e){e.preventDefault(),e.stopPropagation();let t=e.target,n="";for(;!n&&!/^UL$/i.test(t.tagName);)n=t.getAttribute("data-command"),t=t.parentNode;if(!n)return;const i=this.plugins.list.editList.call(this,n,null,!1);i&&this.setRange(i.sc,i.so,i.ec,i.eo),this.submenuOff(),this.history.push(!1)}},FC={name:"table",display:"submenu",add:function(e,t){const n=e.context;let i=n.table={_element:null,_tdElement:null,_trElement:null,_trElements:null,_tableXY:[],_maxWidth:!0,_fixedColumn:!1,_rtl:e.options.rtl,cellControllerTop:e.options.tableCellControllerPosition==="top",resizeText:null,headerButton:null,mergeButton:null,splitButton:null,splitMenu:null,maxText:e.lang.controller.maxSize,minText:e.lang.controller.minSize,_physical_cellCnt:0,_logical_cellCnt:0,_rowCnt:0,_rowIndex:0,_physical_cellIndex:0,_logical_cellIndex:0,_current_colSpan:0,_current_rowSpan:0,icons:{expansion:e.icons.expansion,reduction:e.icons.reduction}},s=this.setSubmenu(e),o=s.querySelector(".se-controller-table-picker");i.tableHighlight=s.querySelector(".se-table-size-highlighted"),i.tableUnHighlight=s.querySelector(".se-table-size-unhighlighted"),i.tableDisplay=s.querySelector(".se-table-size-display"),e.options.rtl&&(i.tableHighlight.style.left=10*18-13+"px");let l=this.setController_table(e);i.tableController=l,i.resizeButton=l.querySelector("._se_table_resize"),i.resizeText=l.querySelector("._se_table_resize > span > span"),i.columnFixedButton=l.querySelector("._se_table_fixed_column"),i.headerButton=l.querySelector("._se_table_header");let a=this.setController_tableEditor(e,i.cellControllerTop);i.resizeDiv=a,i.splitMenu=a.querySelector(".se-btn-group-sub"),i.mergeButton=a.querySelector("._se_table_merge_button"),i.splitButton=a.querySelector("._se_table_split_button"),i.insertRowAboveButton=a.querySelector("._se_table_insert_row_a"),i.insertRowBelowButton=a.querySelector("._se_table_insert_row_b"),o.addEventListener("mousemove",this.onMouseMove_tablePicker.bind(e,i)),o.addEventListener("click",this.appendTable.bind(e)),a.addEventListener("click",this.onClick_tableController.bind(e)),l.addEventListener("click",this.onClick_tableController.bind(e)),e.initMenuTarget(this.name,t,s),n.element.relative.appendChild(a),n.element.relative.appendChild(l),s=null,o=null,a=null,l=null,i=null},setSubmenu:function(e){const t=e.util.createElement("DIV");return t.className="se-submenu se-selector-table",t.innerHTML='<div class="se-table-size"><div class="se-table-size-picker se-controller-table-picker"></div><div class="se-table-size-highlighted"></div><div class="se-table-size-unhighlighted"></div></div><div class="se-table-size-display">1 x 1</div>',t},setController_table:function(e){const t=e.lang,n=e.icons,i=e.util.createElement("DIV");return i.className="se-controller se-controller-table",i.innerHTML='<div><div class="se-btn-group"><button type="button" data-command="resize" class="se-btn se-tooltip _se_table_resize">'+n.expansion+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+t.controller.maxSize+'</span></span></button><button type="button" data-command="layout" class="se-btn se-tooltip _se_table_fixed_column">'+n.fixed_column_width+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+t.controller.fixedColumnWidth+'</span></span></button><button type="button" data-command="header" class="se-btn se-tooltip _se_table_header">'+n.table_header+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+t.controller.tableHeader+'</span></span></button><button type="button" data-command="remove" class="se-btn se-tooltip">'+n.delete+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+t.controller.remove+"</span></span></button></div></div>",i},setController_tableEditor:function(e,t){const n=e.lang,i=e.icons,s=e.util.createElement("DIV");return s.className="se-controller se-controller-table-cell",s.innerHTML=(t?"":'<div class="se-arrow se-arrow-up"></div>')+'<div class="se-btn-group"><button type="button" data-command="insert" data-value="row" data-option="up" class="se-btn se-tooltip _se_table_insert_row_a">'+i.insert_row_above+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+n.controller.insertRowAbove+'</span></span></button><button type="button" data-command="insert" data-value="row" data-option="down" class="se-btn se-tooltip _se_table_insert_row_b">'+i.insert_row_below+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+n.controller.insertRowBelow+'</span></span></button><button type="button" data-command="delete" data-value="row" class="se-btn se-tooltip">'+i.delete_row+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+n.controller.deleteRow+'</span></span></button><button type="button" data-command="merge" class="_se_table_merge_button se-btn se-tooltip" disabled>'+i.merge_cell+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+n.controller.mergeCells+'</span></span></button></div><div class="se-btn-group" style="padding-top: 0;"><button type="button" data-command="insert" data-value="cell" data-option="left" class="se-btn se-tooltip">'+i.insert_column_left+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+n.controller.insertColumnBefore+'</span></span></button><button type="button" data-command="insert" data-value="cell" data-option="right" class="se-btn se-tooltip">'+i.insert_column_right+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+n.controller.insertColumnAfter+'</span></span></button><button type="button" data-command="delete" data-value="cell" class="se-btn se-tooltip">'+i.delete_column+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+n.controller.deleteColumn+'</span></span></button><button type="button" data-command="onsplit" class="_se_table_split_button se-btn se-tooltip">'+i.split_cell+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+n.controller.splitCells+'</span></span></button><div class="se-btn-group-sub sun-editor-common se-list-layer se-table-split"><div class="se-list-inner"><ul class="se-list-basic"><li class="se-btn-list" data-command="split" data-value="vertical" style="line-height:32px;" title="'+n.controller.VerticalSplit+'" aria-label="'+n.controller.VerticalSplit+'">'+n.controller.VerticalSplit+'</li><li class="se-btn-list" data-command="split" data-value="horizontal" style="line-height:32px;" title="'+n.controller.HorizontalSplit+'" aria-label="'+n.controller.HorizontalSplit+'">'+n.controller.HorizontalSplit+"</li></ul></div></div></div>",s},appendTable:function(){const e=this.util.createElement("TABLE"),t=this.plugins.table.createCells,n=this.context.table._tableXY[0];let i=this.context.table._tableXY[1],s="<tbody>";for(;i>0;)s+="<tr>"+t.call(this,"td",n)+"</tr>",--i;if(s+="</tbody>",e.innerHTML=s,this.insertComponent(e,!1,!0,!1)){const l=e.querySelector("td div");this.setRange(l,0,l,0),this.plugins.table.reset_table_picker.call(this)}},createCells:function(e,t,n){if(e=e.toLowerCase(),n){const i=this.util.createElement(e);return i.innerHTML="<div><br></div>",i}else{let i="";for(;t>0;)i+="<"+e+"><div><br></div></"+e+">",t--;return i}},onMouseMove_tablePicker:function(e,t){t.stopPropagation();let n=this._w.Math.ceil(t.offsetX/18),i=this._w.Math.ceil(t.offsetY/18);n=n<1?1:n,i=i<1?1:i,e._rtl&&(e.tableHighlight.style.left=n*18-13+"px",n=11-n),e.tableHighlight.style.width=n+"em",e.tableHighlight.style.height=i+"em",this.util.changeTxt(e.tableDisplay,n+" x "+i),e._tableXY=[n,i]},reset_table_picker:function(){if(!this.context.table.tableHighlight)return;const e=this.context.table.tableHighlight.style,t=this.context.table.tableUnHighlight.style;e.width="1em",e.height="1em",t.width="10em",t.height="10em",this.util.changeTxt(this.context.table.tableDisplay,"1 x 1"),this.submenuOff()},init:function(){const e=this.context.table,t=this.plugins.table;if(t._removeEvents.call(this),t._selectedTable){const n=t._selectedTable.querySelectorAll(".se-table-selected-cell");for(let i=0,s=n.length;i<s;i++)this.util.removeClass(n[i],"se-table-selected-cell")}t._toggleEditor.call(this,!0),e._element=null,e._tdElement=null,e._trElement=null,e._trElements=null,e._tableXY=[],e._maxWidth=!0,e._fixedColumn=!1,e._physical_cellCnt=0,e._logical_cellCnt=0,e._rowCnt=0,e._rowIndex=0,e._physical_cellIndex=0,e._logical_cellIndex=0,e._current_colSpan=0,e._current_rowSpan=0,t._shift=!1,t._selectedCells=null,t._selectedTable=null,t._ref=null,t._fixedCell=null,t._selectedCell=null,t._fixedCellName=null},call_controller_tableEdit:function(e){const t=this.plugins.table,n=this.context.table;if(!this.getSelection().isCollapsed&&!t._selectedCell){this.controllersOff(),this.util.removeClass(e,"se-table-selected-cell");return}const i=n._element||this.plugins.table._selectedTable||this.util.getParentElement(e,"TABLE");n._maxWidth=this.util.hasClass(i,"se-table-size-100")||i.style.width==="100%"||!i.style.width&&!this.util.hasClass(i,"se-table-size-auto"),n._fixedColumn=this.util.hasClass(i,"se-table-layout-fixed")||i.style.tableLayout==="fixed",t.setTableStyle.call(this,n._maxWidth?"width|column":"width"),t.setPositionControllerTop.call(this,i),t.setPositionControllerDiv.call(this,e,t._shift),t._shift||this.controllersOn(n.resizeDiv,n.tableController,t.init.bind(this),e,"table")},setPositionControllerTop:function(e){this.setControllerPosition(this.context.table.tableController,e,"top",{left:0,top:0})},setPositionControllerDiv:function(e,t){const n=this.context.table,i=n.resizeDiv;this.plugins.table.setCellInfo.call(this,e,t),n.cellControllerTop?this.setControllerPosition(i,n._element,"top",{left:n.tableController.offsetWidth,top:0}):this.setControllerPosition(i,e,"bottom",{left:0,top:0})},setCellInfo:function(e,t){const n=this.context.table,i=n._element=this.plugins.table._selectedTable||this.util.getParentElement(e,"TABLE");if(/THEAD/i.test(i.firstElementChild.nodeName)?this.util.addClass(n.headerButton,"active"):this.util.removeClass(n.headerButton,"active"),t||n._physical_cellCnt===0){n._tdElement!==e&&(n._tdElement=e,n._trElement=e.parentNode);const s=n._trElements=i.rows,o=e.cellIndex;let l=0;for(let d=0,h=s[0].cells,v=s[0].cells.length;d<v;d++)l+=h[d].colSpan;const a=n._rowIndex=n._trElement.rowIndex;n._rowCnt=s.length,n._physical_cellCnt=n._trElement.cells.length,n._logical_cellCnt=l,n._physical_cellIndex=o,n._current_colSpan=n._tdElement.colSpan-1,n._current_rowSpan-n._trElement.cells[o].rowSpan-1;let r=[],f=[];for(let d=0,h,v;d<=a;d++){h=s[d].cells,v=0;for(let _=0,C=h.length,S,c,u,p;_<C;_++){if(S=h[_],c=S.colSpan-1,u=S.rowSpan-1,p=_+v,f.length>0)for(let b=0,y;b<f.length;b++)y=f[b],!(y.row>d)&&(p>=y.index?(v+=y.cs,p+=y.cs,y.rs-=1,y.row=d+1,y.rs<1&&(f.splice(b,1),b--)):_===C-1&&(y.rs-=1,y.row=d+1,y.rs<1&&(f.splice(b,1),b--)));if(d===a&&_===o){n._logical_cellIndex=p;break}u>0&&r.push({index:p,cs:c+1,rs:u,row:-1}),v+=c}f=f.concat(r).sort(function(_,C){return _.index-C.index}),r=[]}r=null,f=null}},editTable:function(e,t){const n=this.plugins.table,i=this.context.table,s=i._element,o=e==="row";if(o){const l=i._trElement.parentNode;if(/^THEAD$/i.test(l.nodeName)){if(t==="up")return;if(!l.nextElementSibling||!/^TBODY$/i.test(l.nextElementSibling.nodeName)){s.innerHTML+="<tbody><tr>"+n.createCells.call(this,"td",i._logical_cellCnt,!1)+"</tr></tbody>";return}}}if(n._ref){const l=i._tdElement,a=n._selectedCells;if(o)if(t)n.setCellInfo.call(this,t==="up"?a[0]:a[a.length-1],!0),n.editRow.call(this,t,l);else{let r=a[0].parentNode;const f=[a[0]];for(let d=1,h=a.length,v;d<h;d++)v=a[d],r!==v.parentNode&&(f.push(v),r=v.parentNode);for(let d=0,h=f.length;d<h;d++)n.setCellInfo.call(this,f[d],!0),n.editRow.call(this,t)}else{const r=a[0].parentNode;if(t){let f=null;for(let d=0,h=a.length-1;d<h;d++)if(r!==a[d+1].parentNode){f=a[d];break}n.setCellInfo.call(this,t==="left"?a[0]:f||a[0],!0),n.editCell.call(this,t,l)}else{const f=[a[0]];for(let d=1,h=a.length,v;d<h&&(v=a[d],r===v.parentNode);d++)f.push(v);for(let d=0,h=f.length;d<h;d++)n.setCellInfo.call(this,f[d],!0),n.editCell.call(this,t)}}t||n.init.call(this)}else n[o?"editRow":"editCell"].call(this,t);if(!t){const l=s.children;for(let a=0;a<l.length;a++)l[a].children.length===0&&(this.util.removeItem(l[a]),a--);s.children.length===0&&this.util.removeItem(s)}},editRow:function(e,t){const n=this.context.table,i=!e,s=e==="up",o=n._rowIndex,l=i||s?o:o+n._current_rowSpan+1,a=i?-1:1,r=n._trElements;let f=n._logical_cellCnt;for(let d=0,h=o+(i?-1:0),v;d<=h;d++){if(v=r[d].cells,v.length===0)return;for(let _=0,C=v.length,S,c;_<C;_++)S=v[_].rowSpan,c=v[_].colSpan,!(S<2&&c<2)&&S+d>l&&l>d&&(v[_].rowSpan=S+a,f-=c)}if(i){const d=r[o+1];if(d){const h=[];let v=r[o].cells,_=0;for(let C=0,S=v.length,c,u;C<S;C++)c=v[C],u=C+_,_+=c.colSpan-1,c.rowSpan>1&&(c.rowSpan-=1,h.push({cell:c.cloneNode(!1),index:u}));if(h.length>0){let C=h.shift();v=d.cells,_=0;for(let S=0,c=v.length,u,p;S<c&&(u=v[S],p=S+_,_+=u.colSpan-1,!(p>=C.index&&(S--,_--,_+=C.cell.colSpan-1,d.insertBefore(C.cell,u),C=h.shift(),!C)));S++);if(C){d.appendChild(C.cell);for(let S=0,c=h.length;S<c;S++)d.appendChild(h[S].cell)}}}n._element.deleteRow(l)}else{const d=n._element.insertRow(l);d.innerHTML=this.plugins.table.createCells.call(this,"td",f,!1)}i?this.controllersOff():this.plugins.table.setPositionControllerDiv.call(this,t||n._tdElement,!0)},editCell:function(e,t){const n=this.context.table,i=this.util,s=!e,o=e==="left",l=n._current_colSpan,a=s||o?n._logical_cellIndex:n._logical_cellIndex+l+1,r=n._trElements;let f=[],d=[],h=0;const v=[],_=[];for(let C=0,S=n._rowCnt,c,u,p,b,y,w;C<S;C++){c=r[C],u=a,y=!1,p=c.cells,w=0;for(let x=0,E,k=p.length,N,T,R;x<k&&(E=p[x],!!E);x++)if(N=E.rowSpan-1,T=E.colSpan-1,s){if(R=x+w,d.length>0){const M=!p[x+1];for(let A=0,D;A<d.length;A++)D=d[A],!(D.row>C)&&(R>=D.index?(w+=D.cs,R=x+w,D.rs-=1,D.row=C+1,D.rs<1&&(d.splice(A,1),A--)):M&&(D.rs-=1,D.row=C+1,D.rs<1&&(d.splice(A,1),A--)))}N>0&&f.push({rs:N,cs:T+1,index:R,row:-1}),R>=u&&R+T<=u+l?v.push(E):R<=u+l&&R+T>=u?E.colSpan-=i.getOverlapRangeAtIndex(a,a+l,R,R+T):N>0&&(R<u||R+T>u+l)&&_.push({cell:E,i:C,rs:C+N}),w+=T}else{if(x>=u)break;if(T>0){if(h<1&&T+x>=u){E.colSpan+=1,u=null,h=N+1;break}u-=T}if(!y){for(let M=0,A;M<d.length;M++)A=d[M],u-=A.cs,A.rs-=1,A.rs<1&&(d.splice(M,1),M--);y=!0}}if(d=d.concat(f).sort(function(x,E){return x.index-E.index}),f=[],!s){if(h>0){h-=1;continue}u!==null&&p.length>0&&(b=this.plugins.table.createCells.call(this,p[0].nodeName,0,!0),b=c.insertBefore(b,p[u]))}}if(s){let C,S;for(let c=0,u=v.length,p;c<u;c++)p=v[c].parentNode,i.removeItem(v[c]),p.cells.length===0&&(C||(C=i.getArrayIndex(r,p)),S=i.getArrayIndex(r,p),i.removeItem(p));for(let c=0,u=_.length,p;c<u;c++)p=_[c],p.cell.rowSpan=i.getOverlapRangeAtIndex(C,S,p.i,p.rs);this.controllersOff()}else this.plugins.table.setPositionControllerDiv.call(this,t||n._tdElement,!0)},_closeSplitMenu:null,openSplitMenu:function(){this.util.addClass(this.context.table.splitButton,"on"),this.context.table.splitMenu.style.display="inline-table",this.plugins.table._closeSplitMenu=(function(){this.util.removeClass(this.context.table.splitButton,"on"),this.context.table.splitMenu.style.display="none",this.removeDocEvent("click",this.plugins.table._closeSplitMenu),this.plugins.table._closeSplitMenu=null}).bind(this),this.addDocEvent("click",this.plugins.table._closeSplitMenu)},splitCells:function(e){const t=this.util,n=e==="vertical",i=this.context.table,s=i._tdElement,o=i._trElements,l=i._trElement,a=i._logical_cellIndex,r=i._rowIndex,f=this.plugins.table.createCells.call(this,s.nodeName,0,!0);if(n){const d=s.colSpan;if(f.rowSpan=s.rowSpan,d>1)f.colSpan=this._w.Math.floor(d/2),s.colSpan=d-f.colSpan,l.insertBefore(f,s.nextElementSibling);else{let h=[],v=[];for(let _=0,C=i._rowCnt,S,c;_<C;_++){S=o[_].cells,c=0;for(let u=0,p=S.length,b,y,w,x;u<p;u++){if(b=S[u],y=b.colSpan-1,w=b.rowSpan-1,x=u+c,v.length>0)for(let E=0,k;E<v.length;E++)k=v[E],!(k.row>_)&&(x>=k.index?(c+=k.cs,x+=k.cs,k.rs-=1,k.row=_+1,k.rs<1&&(v.splice(E,1),E--)):u===p-1&&(k.rs-=1,k.row=_+1,k.rs<1&&(v.splice(E,1),E--)));if(x<=a&&w>0&&h.push({index:x,cs:y+1,rs:w,row:-1}),b!==s&&x<=a&&x+y>=a+d-1){b.colSpan+=1;break}if(x>a)break;c+=y}v=v.concat(h).sort(function(u,p){return u.index-p.index}),h=[]}l.insertBefore(f,s.nextElementSibling)}}else{const d=s.rowSpan;if(f.colSpan=s.colSpan,d>1){f.rowSpan=this._w.Math.floor(d/2);const h=d-f.rowSpan,v=[],_=t.getArrayIndex(o,l)+h;for(let u=0,p,b;u<_;u++){p=o[u].cells,b=0;for(let y=0,w=p.length,x,E,k;y<w&&(k=y+b,!(k>=a));y++)x=p[y],E=x.rowSpan-1,E>0&&E+u>=_&&k<a&&v.push({index:k,cs:x.colSpan}),b+=x.colSpan-1}const C=o[_],S=C.cells;let c=v.shift();for(let u=0,p=S.length,b=0,y,w,x,E;u<p;u++){if(x=u+b,y=S[u],w=y.colSpan-1,E=x+w+1,c&&E>=c.index&&(b+=c.cs,E+=c.cs,c=v.shift()),E>=a||u===p-1){C.insertBefore(f,y.nextElementSibling);break}b+=w}s.rowSpan=h}else{f.rowSpan=s.rowSpan;const h=t.createElement("TR");h.appendChild(f);for(let C=0,S;C<r;C++){if(S=o[C].cells,S.length===0)return;for(let c=0,u=S.length;c<u;c++)C+S[c].rowSpan-1>=r&&(S[c].rowSpan+=1)}const v=i._physical_cellIndex,_=l.cells;for(let C=0,S=_.length;C<S;C++)C!==v&&(_[C].rowSpan+=1);l.parentNode.insertBefore(h,l.nextElementSibling)}}this.focusEdge(s),this.plugins.table.setPositionControllerDiv.call(this,s,!0)},mergeCells:function(){const e=this.plugins.table,t=this.context.table,n=this.util,i=e._ref,s=e._selectedCells,o=s[0];let l=null,a=null,r=i.ce-i.cs+1,f=i.re-i.rs+1,d="",h=null;for(let v=1,_=s.length,C,S;v<_;v++){C=s[v],h!==C.parentNode&&(h=C.parentNode),S=C.children;for(let c=0,u=S.length;c<u;c++)n.isFormatElement(S[c])&&n.onlyZeroWidthSpace(S[c].textContent)&&n.removeItem(S[c]);d+=C.innerHTML,n.removeItem(C),h.cells.length===0&&(l?a=h:l=h,f-=1)}if(l){const v=t._trElements,_=n.getArrayIndex(v,l),C=n.getArrayIndex(v,a||l),S=[];for(let c=0,u;c<=C;c++){if(u=v[c].cells,u.length===0){S.push(v[c]);continue}for(let p=0,b=u.length,y,w;p<b;p++)y=u[p],w=y.rowSpan-1,w>0&&c+w>=_&&(y.rowSpan-=n.getOverlapRangeAtIndex(_,C,c,c+w))}for(let c=0,u=S.length;c<u;c++)n.removeItem(S[c])}o.innerHTML+=d,o.colSpan=r,o.rowSpan=f,this.controllersOff(),e.setActiveButton.call(this,!0,!1),e.call_controller_tableEdit.call(this,o),n.addClass(o,"se-table-selected-cell"),this.focusEdge(o)},toggleHeader:function(){const e=this.util,t=this.context.table.headerButton,n=e.hasClass(t,"active"),i=this.context.table._element;if(n)e.removeItem(i.querySelector("thead"));else{const s=e.createElement("THEAD");s.innerHTML="<tr>"+this.plugins.table.createCells.call(this,"th",this.context.table._logical_cellCnt,!1)+"</tr>",i.insertBefore(s,i.firstElementChild)}e.toggleClass(t,"active"),/TH/i.test(this.context.table._tdElement.nodeName)?this.controllersOff():this.plugins.table.setPositionControllerDiv.call(this,this.context.table._tdElement,!1)},setTableStyle:function(e){const t=this.context.table,n=t._element;let i,s,o,l;e.indexOf("width")>-1&&(i=t.resizeButton.firstElementChild,s=t.resizeText,t._maxWidth?(o=t.icons.reduction,l=t.minText,t.columnFixedButton.style.display="block",this.util.removeClass(n,"se-table-size-auto"),this.util.addClass(n,"se-table-size-100")):(o=t.icons.expansion,l=t.maxText,t.columnFixedButton.style.display="none",this.util.removeClass(n,"se-table-size-100"),this.util.addClass(n,"se-table-size-auto")),this.util.changeElement(i,o),this.util.changeTxt(s,l)),e.indexOf("column")>-1&&(t._fixedColumn?(this.util.removeClass(n,"se-table-layout-auto"),this.util.addClass(n,"se-table-layout-fixed"),this.util.addClass(t.columnFixedButton,"active")):(this.util.removeClass(n,"se-table-layout-fixed"),this.util.addClass(n,"se-table-layout-auto"),this.util.removeClass(t.columnFixedButton,"active")))},setActiveButton:function(e,t){const n=this.context.table;/^TH$/i.test(e.nodeName)?(n.insertRowAboveButton.setAttribute("disabled",!0),n.insertRowBelowButton.setAttribute("disabled",!0)):(n.insertRowAboveButton.removeAttribute("disabled"),n.insertRowBelowButton.removeAttribute("disabled")),!t||e===t?(n.splitButton.removeAttribute("disabled"),n.mergeButton.setAttribute("disabled",!0)):(n.splitButton.setAttribute("disabled",!0),n.mergeButton.removeAttribute("disabled"))},_bindOnSelect:null,_bindOffSelect:null,_bindOffShift:null,_selectedCells:null,_shift:!1,_fixedCell:null,_fixedCellName:null,_selectedCell:null,_selectedTable:null,_ref:null,_toggleEditor:function(e){this.context.element.wysiwyg.setAttribute("contenteditable",e),e?this.util.removeClass(this.context.element.wysiwyg,"se-disabled"):this.util.addClass(this.context.element.wysiwyg,"se-disabled")},_offCellMultiSelect:function(e){e.stopPropagation();const t=this.plugins.table;t._shift?t._initBind&&(this._wd.removeEventListener("touchmove",t._initBind),t._initBind=null):(t._removeEvents.call(this),t._toggleEditor.call(this,!0)),!(!t._fixedCell||!t._selectedTable)&&(t.setActiveButton.call(this,t._fixedCell,t._selectedCell),t.call_controller_tableEdit.call(this,t._selectedCell||t._fixedCell),t._selectedCells=t._selectedTable.querySelectorAll(".se-table-selected-cell"),t._selectedCell&&t._fixedCell&&this.focusEdge(t._selectedCell),t._shift||(t._fixedCell=null,t._selectedCell=null,t._fixedCellName=null))},_onCellMultiSelect:function(e){this._antiBlur=!0;const t=this.plugins.table,n=this.util.getParentElement(e.target,this.util.isCell);if(t._shift)n===t._fixedCell?t._toggleEditor.call(this,!0):t._toggleEditor.call(this,!1);else if(!t._ref){if(n===t._fixedCell)return;t._toggleEditor.call(this,!1)}!n||n===t._selectedCell||t._fixedCellName!==n.nodeName||t._selectedTable!==this.util.getParentElement(n,"TABLE")||(t._selectedCell=n,t._setMultiCells.call(this,t._fixedCell,n))},_setMultiCells:function(e,t){const n=this.plugins.table,i=n._selectedTable.rows,s=this.util,o=n._selectedTable.querySelectorAll(".se-table-selected-cell");for(let d=0,h=o.length;d<h;d++)s.removeClass(o[d],"se-table-selected-cell");if(e===t&&(s.addClass(e,"se-table-selected-cell"),!n._shift))return;let l=!0,a=[],r=[];const f=n._ref={_i:0,cs:null,ce:null,rs:null,re:null};for(let d=0,h=i.length,v,_;d<h;d++){v=i[d].cells,_=0;for(let C=0,S=v.length,c,u,p,b;C<S;C++){if(c=v[C],p=c.colSpan-1,b=c.rowSpan-1,u=C+_,a.length>0)for(let y=0,w;y<a.length;y++)w=a[y],!(w.row>d)&&(u>=w.index?(_+=w.cs,u+=w.cs,w.rs-=1,w.row=d+1,w.rs<1&&(a.splice(y,1),y--)):C===S-1&&(w.rs-=1,w.row=d+1,w.rs<1&&(a.splice(y,1),y--)));if(l){if((c===e||c===t)&&(f.cs=f.cs!==null&&f.cs<u?f.cs:u,f.ce=f.ce!==null&&f.ce>u+p?f.ce:u+p,f.rs=f.rs!==null&&f.rs<d?f.rs:d,f.re=f.re!==null&&f.re>d+b?f.re:d+b,f._i+=1),f._i===2){l=!1,a=[],r=[],d=-1;break}}else if(s.getOverlapRangeAtIndex(f.cs,f.ce,u,u+p)&&s.getOverlapRangeAtIndex(f.rs,f.re,d,d+b)){const y=f.cs<u?f.cs:u,w=f.ce>u+p?f.ce:u+p,x=f.rs<d?f.rs:d,E=f.re>d+b?f.re:d+b;if(f.cs!==y||f.ce!==w||f.rs!==x||f.re!==E){f.cs=y,f.ce=w,f.rs=x,f.re=E,d=-1,a=[],r=[];break}s.addClass(c,"se-table-selected-cell")}b>0&&r.push({index:u,cs:p+1,rs:b,row:-1}),_+=c.colSpan-1}a=a.concat(r).sort(function(C,S){return C.index-S.index}),r=[]}},_removeEvents:function(){const e=this.plugins.table;e._initBind&&(this._wd.removeEventListener("touchmove",e._initBind),e._initBind=null),e._bindOnSelect&&(this._wd.removeEventListener("mousedown",e._bindOnSelect),this._wd.removeEventListener("mousemove",e._bindOnSelect),e._bindOnSelect=null),e._bindOffSelect&&(this._wd.removeEventListener("mouseup",e._bindOffSelect),e._bindOffSelect=null),e._bindOffShift&&(this._wd.removeEventListener("keyup",e._bindOffShift),e._bindOffShift=null)},_initBind:null,onTableCellMultiSelect:function(e,t){const n=this.plugins.table;n._removeEvents.call(this),this.controllersOff(),n._shift=t,n._fixedCell=e,n._fixedCellName=e.nodeName,n._selectedTable=this.util.getParentElement(e,"TABLE");const i=n._selectedTable.querySelectorAll(".se-table-selected-cell");for(let s=0,o=i.length;s<o;s++)this.util.removeClass(i[s],"se-table-selected-cell");this.util.addClass(e,"se-table-selected-cell"),n._bindOnSelect=n._onCellMultiSelect.bind(this),n._bindOffSelect=n._offCellMultiSelect.bind(this),t?(n._bindOffShift=(function(){this.controllersOn(this.context.table.resizeDiv,this.context.table.tableController,this.plugins.table.init.bind(this),e,"table"),n._ref||this.controllersOff()}).bind(this),this._wd.addEventListener("keyup",n._bindOffShift,!1),this._wd.addEventListener("mousedown",n._bindOnSelect,!1)):this._wd.addEventListener("mousemove",n._bindOnSelect,!1),this._wd.addEventListener("mouseup",n._bindOffSelect,!1),n._initBind=n.init.bind(this),this._wd.addEventListener("touchmove",n._initBind,!1)},onClick_tableController:function(e){e.stopPropagation();const t=e.target.getAttribute("data-command")?e.target:e.target.parentNode;if(t.getAttribute("disabled"))return;const n=t.getAttribute("data-command"),i=t.getAttribute("data-value"),s=t.getAttribute("data-option"),o=this.plugins.table;if(typeof o._closeSplitMenu=="function"&&(o._closeSplitMenu(),n==="onsplit")||!n)return;e.preventDefault();const l=this.context.table;switch(n){case"insert":case"delete":o.editTable.call(this,i,s);break;case"header":o.toggleHeader.call(this);break;case"onsplit":o.openSplitMenu.call(this);break;case"split":o.splitCells.call(this,i);break;case"merge":o.mergeCells.call(this);break;case"resize":l._maxWidth=!l._maxWidth,o.setTableStyle.call(this,"width"),o.setPositionControllerTop.call(this,l._element),o.setPositionControllerDiv.call(this,l._tdElement,o._shift);break;case"layout":l._fixedColumn=!l._fixedColumn,o.setTableStyle.call(this,"column"),o.setPositionControllerTop.call(this,l._element),o.setPositionControllerDiv.call(this,l._tdElement,o._shift);break;case"remove":const a=l._element.parentNode;this.util.removeItem(l._element),this.controllersOff(),a!==this.context.element.wysiwyg&&this.util.removeItemAllParents(a,function(r){return r.childNodes.length===0},null),this.focus()}this.history.push(!1)}},jC={name:"formatBlock",display:"submenu",add:function(e,t){const n=e.context;n.formatBlock={targetText:t.querySelector(".txt"),targetTooltip:t.parentNode.querySelector(".se-tooltip-text"),_formatList:null,currentFormat:""};let i=this.setSubmenu(e);i.querySelector("ul").addEventListener("click",this.pickUp.bind(e)),n.formatBlock._formatList=i.querySelectorAll("li button"),e.initMenuTarget(this.name,t,i),i=null},setSubmenu:function(e){const t=e.options,n=e.lang.toolbar,i=e.util.createElement("DIV");i.className="se-submenu se-list-layer se-list-format";const s=["p","div","blockquote","pre","h1","h2","h3","h4","h5","h6"],o=!t.formats||t.formats.length===0?s:t.formats;let l='<div class="se-list-inner"><ul class="se-list-basic">';for(let a=0,r=o.length,f,d,h,v,_,C,S;a<r;a++)f=o[a],typeof f=="string"&&s.indexOf(f)>-1?(d=f.toLowerCase(),h=d==="blockquote"?"range":d==="pre"?"free":"replace",_=/^h/.test(d)?d.match(/\d+/)[0]:"",v=n["tag_"+(_?"h":d)]+_,S="",C=""):(d=f.tag.toLowerCase(),h=f.command,v=f.name||d,S=f.class,C=S?' class="'+S+'"':""),l+='<li><button type="button" class="se-btn-list" data-command="'+h+'" data-value="'+d+'" data-class="'+S+'" title="'+v+'" aria-label="'+v+'"><'+d+C+">"+v+"</"+d+"></button></li>";return l+="</ul></div>",i.innerHTML=l,i},active:function(e){let t=this.lang.toolbar.formats;const n=this.context.formatBlock.targetText;if(!e)this.util.changeTxt(n,t);else if(this.util.isFormatElement(e)){const s=this.context.formatBlock._formatList,o=e.nodeName.toLowerCase(),l=(e.className.match(/(\s|^)__se__format__[^\s]+/)||[""])[0].trim();for(let a=0,r=s.length,f;a<r;a++)if(f=s[a],o===f.getAttribute("data-value")&&l===f.getAttribute("data-class")){t=f.title;break}return this.util.changeTxt(n,t),n.setAttribute("data-value",o),n.setAttribute("data-class",l),!0}return!1},on:function(){const e=this.context.formatBlock,t=e._formatList,n=e.targetText,i=(n.getAttribute("data-value")||"")+(n.getAttribute("data-class")||"");if(i!==e.currentFormat){for(let s=0,o=t.length,l;s<o;s++)l=t[s],i===l.getAttribute("data-value")+l.getAttribute("data-class")?this.util.addClass(l,"active"):this.util.removeClass(l,"active");e.currentFormat=i}},pickUp:function(e){e.preventDefault(),e.stopPropagation();let t=e.target,n=null,i=null,s=null,o="";for(;!n&&!/UL/i.test(t.tagName);){if(n=t.getAttribute("data-command"),i=t.getAttribute("data-value"),o=t.getAttribute("data-class"),n){s=t.firstChild;break}t=t.parentNode}if(n){if(n==="range"){const l=s.cloneNode(!1);this.applyRangeFormatElement(l)}else{let l=this.getRange(),a=this.getSelectedElementsAndComponents(!1);if(a.length===0&&(l=this.getRange_addLine(l,null),a=this.getSelectedElementsAndComponents(!1),a.length===0))return;const r=l.startOffset,f=l.endOffset,d=this.util;let h=a[0],v=a[a.length-1];const _=d.getNodePath(l.startContainer,h,null,null),C=d.getNodePath(l.endContainer,v,null,null),S=this.detachList(a,!1);S.sc&&(h=S.sc),S.ec&&(v=S.ec),this.setRange(d.getNodeFromPath(_,h),r,d.getNodeFromPath(C,v),f);const c=this.getSelectedElementsAndComponents(!1);if(n==="free"){const u=c.length-1;let p=c[u].parentNode,b=s.cloneNode(!1);const y=b;for(let w=u,x,E,k,N,T,R,M=!0;w>=0;w--)if(x=c[w],x!==(c[w+1]?c[w+1].parentNode:null)){if(R=d.isComponent(x),E=R?"":x.innerHTML.replace(/(?!>)\s+(?=<)|\n/g," "),k=d.getParentElement(x,function(A){return A.parentNode===p}),(p!==x.parentNode||R)&&(d.isFormatElement(p)?(p.parentNode.insertBefore(b,p.nextSibling),p=p.parentNode):(p.insertBefore(b,k?k.nextSibling:null),p=x.parentNode),N=b.nextSibling,N&&b.nodeName===N.nodeName&&d.isSameAttributes(b,N)&&(b.innerHTML+="<BR>"+N.innerHTML,d.removeItem(N)),b=s.cloneNode(!1),M=!0),T=b.innerHTML,b.innerHTML=(M||!E||!T||/<br>$/i.test(E)?E:E+"<BR>")+T,w===0){p.insertBefore(b,x),N=x.nextSibling,N&&b.nodeName===N.nodeName&&d.isSameAttributes(b,N)&&(b.innerHTML+="<BR>"+N.innerHTML,d.removeItem(N));const A=b.previousSibling;A&&b.nodeName===A.nodeName&&d.isSameAttributes(b,A)&&(A.innerHTML+="<BR>"+b.innerHTML,d.removeItem(b))}R||d.removeItem(x),E&&(M=!1)}this.setRange(y,0,y,0)}else{for(let u=0,p=c.length,b,y;u<p;u++)b=c[u],(b.nodeName.toLowerCase()!==i.toLowerCase()||(b.className.match(/(\s|^)__se__format__[^\s]+/)||[""])[0].trim()!==o)&&!d.isComponent(b)&&(y=s.cloneNode(!1),d.copyFormatAttributes(y,b),y.innerHTML=b.innerHTML,b.parentNode.replaceChild(y,b)),u===0&&(h=y||b),u===p-1&&(v=y||b),y=null;this.setRange(d.getNodeFromPath(_,h),r,d.getNodeFromPath(C,v),f)}this.history.push(!1)}this.submenuOff()}}},zC={name:"lineHeight",display:"submenu",add:function(e,t){const n=e.context;n.lineHeight={_sizeList:null,currentSize:-1};let i=this.setSubmenu(e),s=i.querySelector("ul");s.addEventListener("click",this.pickup.bind(e)),n.lineHeight._sizeList=s.querySelectorAll("li button"),e.initMenuTarget(this.name,t,i),i=null,s=null},setSubmenu:function(e){const t=e.options,n=e.lang,i=e.util.createElement("DIV");i.className="se-submenu se-list-layer";const s=t.lineHeights?t.lineHeights:[{text:"1",value:1},{text:"1.15",value:1.15},{text:"1.5",value:1.5},{text:"2",value:2}];let o='<div class="se-list-inner"><ul class="se-list-basic"><li><button type="button" class="default_value se-btn-list" title="'+n.toolbar.default+'" aria-label="'+n.toolbar.default+'">('+n.toolbar.default+")</button></li>";for(let l=0,a=s.length,r;l<a;l++)r=s[l],o+='<li><button type="button" class="se-btn-list" data-value="'+r.value+'" title="'+r.text+'" aria-label="'+r.text+'">'+r.text+"</button></li>";return o+="</ul></div>",i.innerHTML=o,i},on:function(){const e=this.context.lineHeight,t=e._sizeList,n=this.util.getFormatElement(this.getSelectionNode()),i=n?n.style.lineHeight+"":"";if(i!==e.currentSize){for(let s=0,o=t.length;s<o;s++)i===t[s].getAttribute("data-value")?this.util.addClass(t[s],"active"):this.util.removeClass(t[s],"active");e.currentSize=i}},pickup:function(e){if(!/^BUTTON$/i.test(e.target.tagName))return!1;e.preventDefault(),e.stopPropagation();const t=e.target.getAttribute("data-value")||"",n=this.getSelectedElements();for(let i=0,s=n.length;i<s;i++)n[i].style.lineHeight=t;this.submenuOff(),this.history.push(!1)}},HC={name:"template",display:"submenu",add:function(e,t){const n=e.context;n.template={selectedIndex:-1};let i=this.setSubmenu(e);i.querySelector("ul").addEventListener("click",this.pickup.bind(e)),e.initMenuTarget(this.name,t,i),i=null},setSubmenu:function(e){const t=e.options.templates;if(!t||t.length===0)throw Error('[SUNEDITOR.plugins.template.fail] To use the "template" plugin, please define the "templates" option.');const n=e.util.createElement("DIV");n.className="se-list-layer";let i='<div class="se-submenu se-list-inner"><ul class="se-list-basic">';for(let s=0,o=t.length,l;s<o;s++)l=t[s],i+='<li><button type="button" class="se-btn-list" data-value="'+s+'" title="'+l.name+'" aria-label="'+l.name+'">'+l.name+"</button></li>";return i+="</ul></div>",n.innerHTML=i,n},pickup:function(e){if(!/^BUTTON$/i.test(e.target.tagName))return!1;e.preventDefault(),e.stopPropagation(),this.context.template.selectedIndex=e.target.getAttribute("data-value")*1;const t=this.options.templates[this.context.template.selectedIndex];if(t.html)this.setContents(t.html);else throw this.submenuOff(),Error('[SUNEDITOR.template.fail] cause : "templates[i].html not found"');this.submenuOff()}},VC={name:"paragraphStyle",display:"submenu",add:function(e,t){const n=e.context;n.paragraphStyle={_classList:null};let i=this.setSubmenu(e);i.querySelector("ul").addEventListener("click",this.pickUp.bind(e)),n.paragraphStyle._classList=i.querySelectorAll("li button"),e.initMenuTarget(this.name,t,i),i=null},setSubmenu:function(e){const t=e.options,n=e.util.createElement("DIV");n.className="se-submenu se-list-layer se-list-format";const i=e.lang.menu,s={spaced:{name:i.spaced,class:"__se__p-spaced",_class:""},bordered:{name:i.bordered,class:"__se__p-bordered",_class:""},neon:{name:i.neon,class:"__se__p-neon",_class:""}},o=!t.paragraphStyles||t.paragraphStyles.length===0?["spaced","bordered","neon"]:t.paragraphStyles;let l='<div class="se-list-inner"><ul class="se-list-basic">';for(let a=0,r=o.length,f,d,h,v;a<r;a++){if(f=o[a],typeof f=="string"){const _=s[f.toLowerCase()];if(!_)continue;f=_}d=f.name,h=f.class?' class="'+f.class+'"':"",v=f._class,l+='<li><button type="button" class="se-btn-list'+(v?" "+v:"")+'" data-value="'+f.class+'" title="'+d+'" aria-label="'+d+'"><div'+h+">"+d+"</div></button></li>"}return l+="</ul></div>",n.innerHTML=l,n},on:function(){const t=this.context.paragraphStyle._classList,n=this.util.getFormatElement(this.getSelectionNode());for(let i=0,s=t.length;i<s;i++)this.util.hasClass(n,t[i].getAttribute("data-value"))?this.util.addClass(t[i],"active"):this.util.removeClass(t[i],"active")},pickUp:function(e){e.preventDefault(),e.stopPropagation();let t=e.target,n=null;for(;!/^UL$/i.test(t.tagName)&&(n=t.getAttribute("data-value"),!n);)t=t.parentNode;if(!n)return;let i=this.getSelectedElements();if(i.length===0&&(this.getRange_addLine(this.getRange(),null),i=this.getSelectedElements(),i.length===0))return;const s=this.util.hasClass(t,"active")?this.util.removeClass.bind(this.util):this.util.addClass.bind(this.util);for(let o=0,l=i.length;o<l;o++)s(i[o],n);this.submenuOff(),this.history.push(!1)}},WC={name:"textStyle",display:"submenu",add:function(e,t){const n=e.context;n.textStyle={_styleList:null};let i=this.setSubmenu(e),s=i.querySelector("ul");s.addEventListener("click",this.pickup.bind(e)),n.textStyle._styleList=i.querySelectorAll("li button"),e.initMenuTarget(this.name,t,i),i=null,s=null},setSubmenu:function(e){const t=e.options,n=e.util.createElement("DIV");n.className="se-submenu se-list-layer se-list-format";const i={code:{name:e.lang.menu.code,class:"__se__t-code",tag:"code"},translucent:{name:e.lang.menu.translucent,style:"opacity: 0.5;",tag:"span"},shadow:{name:e.lang.menu.shadow,class:"__se__t-shadow",tag:"span"}},s=t.textStyles?t.textStyles:e._w.Object.keys(i);let o='<div class="se-list-inner"><ul class="se-list-basic">';for(let l=0,a=s.length,r,f,d,h,v,_,C;l<a;l++){if(r=s[l],h="",_="",v=[],typeof r=="string"){const S=i[r.toLowerCase()];if(!S)continue;r=S}d=r.name,f=r.tag||"span",C=r._class,r.style&&(h+=' style="'+r.style+'"',_+=r.style.replace(/:[^;]+(;|$)\s*/g,","),v.push("style")),r.class&&(h+=' class="'+r.class+'"',_+="."+r.class.trim().replace(/\s+/g,",."),v.push("class")),_=_.replace(/,$/,""),o+='<li><button type="button" class="se-btn-list'+(C?" "+C:"")+'" data-command="'+f+'" data-value="'+_+'" title="'+d+'" aria-label="'+d+'"><'+f+h+">"+d+"</"+f+"></button></li>"}return o+="</ul></div>",n.innerHTML=o,n},on:function(){const e=this.util,n=this.context.textStyle._styleList,i=this.getSelectionNode();for(let s=0,o=n.length,l,a,r;s<o;s++){l=n[s],a=l.getAttribute("data-value").split(",");for(let f=0,d,h;f<a.length;f++){for(d=i,r=!1;d&&!e.isFormatElement(d)&&!e.isComponent(d);){if(d.nodeName.toLowerCase()===l.getAttribute("data-command").toLowerCase()&&(h=a[f],/^\./.test(h)?e.hasClass(d,h.replace(/^\./,"")):d.style[h])){r=!0;break}d=d.parentNode}if(!r)break}r?e.addClass(l,"active"):e.removeClass(l,"active")}},pickup:function(e){e.preventDefault(),e.stopPropagation();let t=e.target,n=null,i=null;for(;!n&&!/UL/i.test(t.tagName);){if(n=t.getAttribute("data-command"),n){i=t.firstChild;break}t=t.parentNode}if(!n)return;const s=i.style.cssText.replace(/:.+(;|$)/g,",").split(",");s.pop();const o=i.classList;for(let r=0,f=o.length;r<f;r++)s.push("."+o[r]);const l=this.util.hasClass(t,"active")?null:i.cloneNode(!1),a=l?null:[i.nodeName];this.nodeChange(l,s,a,!0),this.submenuOff()}};var ah={exports:{}};(function(e){(function(t,n){e.exports=t.document?n(t,!0):function(i){if(!i.document)throw new Error("SUNEDITOR_MODULES a window with a document");return n(i)}})(typeof window<"u"?window:Yn,function(t,n){const i={name:"dialog",add:function(s){const o=s.context;o.dialog={kind:"",updateModal:!1,_closeSignal:!1};let l=s.util.createElement("DIV");l.className="se-dialog sun-editor-common";let a=s.util.createElement("DIV");a.className="se-dialog-back",a.style.display="none";let r=s.util.createElement("DIV");r.className="se-dialog-inner",r.style.display="none",l.appendChild(a),l.appendChild(r),o.dialog.modalArea=l,o.dialog.back=a,o.dialog.modal=r,o.dialog.modal.addEventListener("mousedown",this._onMouseDown_dialog.bind(s)),o.dialog.modal.addEventListener("click",this._onClick_dialog.bind(s)),o.element.relative.appendChild(l),l=null,a=null,r=null},_onMouseDown_dialog:function(s){/se-dialog-inner/.test(s.target.className)?this.context.dialog._closeSignal=!0:this.context.dialog._closeSignal=!1},_onClick_dialog:function(s){(/close/.test(s.target.getAttribute("data-command"))||this.context.dialog._closeSignal)&&this.plugins.dialog.close.call(this)},open:function(s,o){if(this.modalForm)return!1;this.plugins.dialog._bindClose&&(this._d.removeEventListener("keydown",this.plugins.dialog._bindClose),this.plugins.dialog._bindClose=null),this.plugins.dialog._bindClose=(function(a){/27/.test(a.keyCode)&&this.plugins.dialog.close.call(this)}).bind(this),this._d.addEventListener("keydown",this.plugins.dialog._bindClose),this.context.dialog.updateModal=o,this.options.popupDisplay==="full"?this.context.dialog.modalArea.style.position="fixed":this.context.dialog.modalArea.style.position="absolute",this.context.dialog.kind=s,this.modalForm=this.context[s].modal;const l=this.context[s].focusElement;typeof this.plugins[s].on=="function"&&this.plugins[s].on.call(this,o),this.context.dialog.modalArea.style.display="block",this.context.dialog.back.style.display="block",this.context.dialog.modal.style.display="block",this.modalForm.style.display="block",l&&l.focus()},_bindClose:null,close:function(){this.plugins.dialog._bindClose&&(this._d.removeEventListener("keydown",this.plugins.dialog._bindClose),this.plugins.dialog._bindClose=null);const s=this.context.dialog.kind;this.modalForm.style.display="none",this.context.dialog.back.style.display="none",this.context.dialog.modalArea.style.display="none",this.context.dialog.updateModal=!1,typeof this.plugins[s].init=="function"&&this.plugins[s].init.call(this),this.context.dialog.kind="",this.modalForm=null,this.focus()}};return typeof n>"u"&&(t.SUNEDITOR_MODULES||Object.defineProperty(t,"SUNEDITOR_MODULES",{enumerable:!0,writable:!1,configurable:!1,value:{}}),Object.defineProperty(t.SUNEDITOR_MODULES,"dialog",{enumerable:!0,writable:!1,configurable:!1,value:i})),i})})(ah);var $C=ah.exports;const Fi=Zn($C),UC={name:"selectMenu",add:function(e){e.context.selectMenu={caller:{},callerContext:null}},setForm:function(){return'<div class="se-select-list"></div>'},createList:function(e,t,n){e.form.innerHTML="<ul>"+n+"</ul>",e.items=t,e.menus=e.form.querySelectorAll("li")},initEvent:function(e,t){const n=t.querySelector(".se-select-list"),i=this.context.selectMenu.caller[e]={form:n,items:[],menus:[],index:-1,item:null,clickMethod:null,callerName:e};n.addEventListener("mousedown",this.plugins.selectMenu.onMousedown_list),n.addEventListener("mousemove",this.plugins.selectMenu.onMouseMove_list.bind(this,i)),n.addEventListener("click",this.plugins.selectMenu.onClick_list.bind(this,i))},onMousedown_list:function(e){e.preventDefault(),e.stopPropagation()},onMouseMove_list:function(e,t){this.util.addClass(e.form,"__se_select-menu-mouse-move");const n=t.target.getAttribute("data-index");n&&(e.index=n*1)},onClick_list:function(e,t){const n=t.target.getAttribute("data-index");n&&e.clickMethod.call(this,e.items[n])},moveItem:function(e,t){this.util.removeClass(e.form,"__se_select-menu-mouse-move"),t=e.index+t;const n=e.menus,i=n.length,s=e.index=t>=i?0:t<0?i-1:t;for(let o=0;o<i;o++)o===s?this.util.addClass(n[o],"active"):this.util.removeClass(n[o],"active");e.item=e.items[s]},getItem:function(e,t){return t=!t||t<0?e.index:t,e.items[t]},on:function(e,t){const n=this.context.selectMenu.caller[e];this.context.selectMenu.callerContext=n,n.clickMethod=t,n.callerName=e},open:function(e,t){const n=e.form;n.style.visibility="hidden",n.style.display="block",t(n),n.style.visibility=""},close:function(e){e.form.style.display="none",e.items=[],e.menus=[],e.index=-1,e.item=null},init:function(e){e&&(e.items=[],e.menus=[],e.index=-1,e.item=null,e.callerName="",this.context.selectMenu.callerContext=null)}},ch={name:"anchor",add:function(e){e.addModule([UC]),e.context.anchor={caller:{},forms:this.setDialogForm(e),host:(e._w.location.origin+e._w.location.pathname).replace(/\/$/,""),callerContext:null}},setDialogForm:function(e){const t=e.lang,n=e.options.linkRel,i=(e.options.linkRelDefault.default||"").split(" "),s=e.icons,o=e.util.createElement("DIV");let l='<div class="se-dialog-body"><div class="se-dialog-form"><label>'+t.dialogBox.linkBox.url+'</label><div class="se-dialog-form-files"><input class="se-input-form se-input-url" type="text" placeholder="'+(e.options.protocol||"")+'" /><button type="button" class="se-btn se-dialog-files-edge-button _se_bookmark_button" title="'+t.dialogBox.linkBox.bookmark+'" aria-label="'+t.dialogBox.linkBox.bookmark+'">'+s.bookmark+"</button>"+e.plugins.selectMenu.setForm()+'</div><div class="se-anchor-preview-form"><span class="se-svg se-anchor-preview-icon _se_anchor_bookmark_icon">'+s.bookmark+'</span><span class="se-svg se-anchor-preview-icon _se_anchor_download_icon">'+s.download+'</span><pre class="se-link-preview"></pre></div></div><div class="se-dialog-form"><label>'+t.dialogBox.linkBox.text+'</label><input class="se-input-form _se_anchor_text" type="text" /></div><div class="se-dialog-form-footer"><label><input type="checkbox" class="se-dialog-btn-check _se_anchor_check" />&nbsp;'+t.dialogBox.linkBox.newWindowCheck+'</label><label><input type="checkbox" class="se-dialog-btn-check _se_anchor_download" />&nbsp;'+t.dialogBox.linkBox.downloadLinkCheck+"</label>";if(n.length>0){l+='<div class="se-anchor-rel"><button type="button" class="se-btn se-btn-select se-anchor-rel-btn">&lt;rel&gt;</button><div class="se-anchor-rel-wrapper"><pre class="se-link-preview se-anchor-rel-preview"></pre></div><div class="se-list-layer"><div class="se-list-inner"><ul class="se-list-basic se-list-checked">';for(let a=0,r=n.length,f;a<r;a++)f=n[a],l+='<li><button type="button" class="se-btn-list'+(i.indexOf(f)>-1?" se-checked":"")+'" data-command="'+f+'" title="'+f+'" aria-label="'+f+'"><span class="se-svg">'+s.checked+"</span>"+f+"</button></li>";l+="</ul></div></div></div>"}return l+="</div></div>",o.innerHTML=l,o},initEvent:function(e,t){const n=this.plugins.anchor,i=this.context.anchor.caller[e]={modal:t,urlInput:null,linkDefaultRel:this.options.linkRelDefault,defaultRel:this.options.linkRelDefault.default||"",currentRel:[],linkAnchor:null,linkValue:"",_change:!1,callerName:e};typeof i.linkDefaultRel.default=="string"&&(i.linkDefaultRel.default=i.linkDefaultRel.default.trim()),typeof i.linkDefaultRel.check_new_window=="string"&&(i.linkDefaultRel.check_new_window=i.linkDefaultRel.check_new_window.trim()),typeof i.linkDefaultRel.check_bookmark=="string"&&(i.linkDefaultRel.check_bookmark=i.linkDefaultRel.check_bookmark.trim()),i.urlInput=t.querySelector(".se-input-url"),i.anchorText=t.querySelector("._se_anchor_text"),i.newWindowCheck=t.querySelector("._se_anchor_check"),i.downloadCheck=t.querySelector("._se_anchor_download"),i.download=t.querySelector("._se_anchor_download_icon"),i.preview=t.querySelector(".se-link-preview"),i.bookmark=t.querySelector("._se_anchor_bookmark_icon"),i.bookmarkButton=t.querySelector("._se_bookmark_button"),this.plugins.selectMenu.initEvent.call(this,e,t);const s=this.context.selectMenu.caller[e];this.options.linkRel.length>0&&(i.relButton=t.querySelector(".se-anchor-rel-btn"),i.relList=t.querySelector(".se-list-layer"),i.relPreview=t.querySelector(".se-anchor-rel-preview"),i.relButton.addEventListener("click",n.onClick_relButton.bind(this,i)),i.relList.addEventListener("click",n.onClick_relList.bind(this,i))),i.newWindowCheck.addEventListener("change",n.onChange_newWindowCheck.bind(this,i)),i.downloadCheck.addEventListener("change",n.onChange_downloadCheck.bind(this,i)),i.anchorText.addEventListener("input",n.onChangeAnchorText.bind(this,i)),i.urlInput.addEventListener("input",n.onChangeUrlInput.bind(this,i)),i.urlInput.addEventListener("keydown",n.onKeyDownUrlInput.bind(this,s)),i.urlInput.addEventListener("focus",n.onFocusUrlInput.bind(this,i,s)),i.urlInput.addEventListener("blur",n.onBlurUrlInput.bind(this,s)),i.bookmarkButton.addEventListener("click",n.onClick_bookmarkButton.bind(this,i))},on:function(e,t){const n=this.plugins.anchor;if(!t)n.init.call(this,e),e.anchorText.value=this.getSelection().toString().trim(),e.newWindowCheck.checked=this.options.linkTargetNewWindow;else if(e.linkAnchor){this.context.dialog.updateModal=!0;const i=e.linkAnchor.getAttribute("href");e.linkValue=e.preview.textContent=e.urlInput.value=n.selfPathBookmark.call(this,i)?i.substr(i.lastIndexOf("#")):i,e.anchorText.value=e.linkAnchor.textContent,e.newWindowCheck.checked=!!/_blank/i.test(e.linkAnchor.target),e.downloadCheck.checked=e.linkAnchor.download}this.context.anchor.callerContext=e,n.setRel.call(this,e,t&&e.linkAnchor?e.linkAnchor.rel:e.defaultRel),n.setLinkPreview.call(this,e,e.linkValue),this.plugins.selectMenu.on.call(this,e.callerName,this.plugins.anchor.setHeaderBookmark)},selfPathBookmark:function(e){const t=this._w.location.href.replace(/\/$/,"");return e.indexOf("#")===0||e.indexOf(t)===0&&e.indexOf("#")===(t.indexOf("#")===-1?t.length:t.substr(0,t.indexOf("#")).length)},_closeRelMenu:null,toggleRelList:function(e,t){if(!t)this.plugins.anchor._closeRelMenu&&this.plugins.anchor._closeRelMenu();else{const n=e.relButton,i=e.relList;this.util.addClass(n,"active"),i.style.visibility="hidden",i.style.display="block",this.options.rtl?i.style.left=n.offsetLeft-i.offsetWidth-1+"px":i.style.left=n.offsetLeft+n.offsetWidth+1+"px",i.style.top=n.offsetTop+n.offsetHeight/2-i.offsetHeight/2+"px",i.style.visibility="",this.plugins.anchor._closeRelMenu=(function(s,o,l){l&&(s.relButton.contains(l.target)||s.relList.contains(l.target))||(this.util.removeClass(o,"active"),s.relList.style.display="none",this.modalForm.removeEventListener("click",this.plugins.anchor._closeRelMenu),this.plugins.anchor._closeRelMenu=null)}).bind(this,e,n),this.modalForm.addEventListener("click",this.plugins.anchor._closeRelMenu)}},onClick_relButton:function(e,t){this.plugins.anchor.toggleRelList.call(this,e,!this.util.hasClass(t.target,"active"))},onClick_relList:function(e,t){const n=t.target,i=n.getAttribute("data-command");if(!i)return;const s=e.currentRel,o=this.util.toggleClass(n,"se-checked"),l=s.indexOf(i);o?l===-1&&s.push(i):l>-1&&s.splice(l,1),e.relPreview.title=e.relPreview.textContent=s.join(" ")},setRel:function(e,t){const n=e.relList,i=e.currentRel=t?t.split(" "):[];if(!n)return;const s=n.querySelectorAll("button");for(let o=0,l=s.length,a;o<l;o++)a=s[o].getAttribute("data-command"),i.indexOf(a)>-1?this.util.addClass(s[o],"se-checked"):this.util.removeClass(s[o],"se-checked");e.relPreview.title=e.relPreview.textContent=i.join(" ")},createHeaderList:function(e,t,n){const i=this.util.getListChildren(this.context.element.wysiwyg,function(a){return/h[1-6]/i.test(a.nodeName)});if(i.length===0)return;const s=new this._w.RegExp("^"+n.replace(/^#/,""),"i"),o=[];let l="";for(let a=0,r=i.length,f;a<r;a++)f=i[a],s.test(f.textContent)&&(o.push(f),l+='<li class="se-select-item" data-index="'+a+'">'+f.textContent+"</li>");o.length===0?this.plugins.selectMenu.close.call(this,t):(this.plugins.selectMenu.createList(t,o,l),this.plugins.selectMenu.open.call(this,t,this.plugins.anchor._setMenuListPosition.bind(this,e)))},_setMenuListPosition:function(e,t){t.style.top=e.urlInput.offsetHeight+1+"px"},onKeyDownUrlInput:function(e,t){switch(t.keyCode){case 38:t.preventDefault(),t.stopPropagation(),this.plugins.selectMenu.moveItem.call(this,e,-1);break;case 40:t.preventDefault(),t.stopPropagation(),this.plugins.selectMenu.moveItem.call(this,e,1);break;case 13:e.index>-1&&(t.preventDefault(),t.stopPropagation(),this.plugins.anchor.setHeaderBookmark.call(this,this.plugins.selectMenu.getItem(e,null)));break}},setHeaderBookmark:function(e){const t=this.context.anchor.callerContext,n=e.id||"h_"+this._w.Math.random().toString().replace(/.+\./,"");e.id=n,t.urlInput.value="#"+n,(!t.anchorText.value.trim()||!t._change)&&(t.anchorText.value=e.textContent),this.plugins.anchor.setLinkPreview.call(this,t,t.urlInput.value),this.plugins.selectMenu.close.call(this,this.context.selectMenu.callerContext),this.context.anchor.callerContext.urlInput.focus()},onChangeAnchorText:function(e,t){e._change=!!t.target.value.trim()},onChangeUrlInput:function(e,t){const n=t.target.value.trim();this.plugins.anchor.setLinkPreview.call(this,e,n),this.plugins.anchor.selfPathBookmark.call(this,n)?this.plugins.anchor.createHeaderList.call(this,e,this.context.selectMenu.callerContext,n):this.plugins.selectMenu.close.call(this,this.context.selectMenu.callerContext)},onFocusUrlInput:function(e,t){const n=e.urlInput.value;this.plugins.anchor.selfPathBookmark.call(this,n)&&this.plugins.anchor.createHeaderList.call(this,e,t,n)},onBlurUrlInput:function(e){this.plugins.selectMenu.close.call(this,e)},setLinkPreview:function(e,t){const n=e.preview,i=this.options.linkProtocol,s=this.options.linkNoPrefix,o=/^(mailto\:|tel\:|sms\:|https*\:\/\/|#)/.test(t)||t.indexOf(i)===0,l=i?this._w.RegExp("^"+this.util.escapeStringRegexp(t.substr(0,i.length))).test(i):!1;t=e.linkValue=n.textContent=t?s?t:i&&!o&&!l?i+t:o?t:/^www\./.test(t)?"http://"+t:this.context.anchor.host+(/^\//.test(t)?"":"/")+t:"",this.plugins.anchor.selfPathBookmark.call(this,t)?(e.bookmark.style.display="block",this.util.addClass(e.bookmarkButton,"active")):(e.bookmark.style.display="none",this.util.removeClass(e.bookmarkButton,"active")),!this.plugins.anchor.selfPathBookmark.call(this,t)&&e.downloadCheck.checked?e.download.style.display="block":e.download.style.display="none"},setCtx:function(e,t){e&&(t.linkAnchor=e,t.linkValue=e.href,t.currentRel=e.rel.split(" "))},updateAnchor:function(e,t,n,i,s){!this.plugins.anchor.selfPathBookmark.call(this,t)&&i.downloadCheck.checked?e.setAttribute("download",n||t):e.removeAttribute("download"),i.newWindowCheck.checked?e.target="_blank":e.removeAttribute("target");const o=i.currentRel.join(" ");o?e.rel=o:e.removeAttribute("rel"),e.href=t,s?e.children.length===0&&(e.textContent=""):e.textContent=n},createAnchor:function(e,t){if(e.linkValue.length===0)return null;const n=e.linkValue,i=e.anchorText,s=i.value.length===0?n:i.value,o=e.linkAnchor||this.util.createElement("A");return this.plugins.anchor.updateAnchor.call(this,o,n,s,e,t),e.linkValue=e.preview.textContent=e.urlInput.value=e.anchorText.value="",o},onClick_bookmarkButton:function(e){let t=e.urlInput.value;this.plugins.anchor.selfPathBookmark.call(this,t)?(t=t.substr(1),e.bookmark.style.display="none",this.util.removeClass(e.bookmarkButton,"active"),this.plugins.selectMenu.close.call(this,this.context.selectMenu.callerContext)):(t="#"+t,e.bookmark.style.display="block",this.util.addClass(e.bookmarkButton,"active"),e.downloadCheck.checked=!1,e.download.style.display="none",this.plugins.anchor.createHeaderList.call(this,e,this.context.selectMenu.callerContext,t)),e.urlInput.value=t,this.plugins.anchor.setLinkPreview.call(this,e,t),e.urlInput.focus()},onChange_newWindowCheck:function(e,t){typeof e.linkDefaultRel.check_new_window=="string"&&(t.target.checked?this.plugins.anchor.setRel.call(this,e,this.plugins.anchor._relMerge.call(this,e,e.linkDefaultRel.check_new_window)):this.plugins.anchor.setRel.call(this,e,this.plugins.anchor._relDelete.call(this,e,e.linkDefaultRel.check_new_window)))},onChange_downloadCheck:function(e,t){t.target.checked?(e.download.style.display="block",e.bookmark.style.display="none",this.util.removeClass(e.bookmarkButton,"active"),e.linkValue=e.preview.textContent=e.urlInput.value=e.urlInput.value.replace(/^\#+/,""),typeof e.linkDefaultRel.check_bookmark=="string"&&this.plugins.anchor.setRel.call(this,e,this.plugins.anchor._relMerge.call(this,e,e.linkDefaultRel.check_bookmark))):(e.download.style.display="none",typeof e.linkDefaultRel.check_bookmark=="string"&&this.plugins.anchor.setRel.call(this,e,this.plugins.anchor._relDelete.call(this,e,e.linkDefaultRel.check_bookmark)))},_relMerge:function(e,t){const n=e.currentRel;if(!t)return n.join(" ");if(/^only\:/.test(t))return t=t.replace(/^only\:/,"").trim(),e.currentRel=t.split(" "),t;const i=t.split(" ");for(let s=0,o=i.length,l;s<o;s++)l=n.indexOf(i[s]),l===-1&&n.push(i[s]);return n.join(" ")},_relDelete:function(e,t){if(!t)return e.currentRel.join(" ");/^only\:/.test(t)&&(t=t.replace(/^only\:/,"").trim());const n=e.currentRel.join(" ").replace(this._w.RegExp(t+"\\s*"),"");return e.currentRel=n.split(" "),n},init:function(e){e.linkAnchor=null,e.linkValue=e.preview.textContent=e.urlInput.value="",e.anchorText.value="",e.newWindowCheck.checked=!1,e.downloadCheck.checked=!1,e._change=!1,this.plugins.anchor.setRel.call(this,e,e.defaultRel),e.relList&&this.plugins.anchor.toggleRelList.call(this,e,!1),this.context.anchor.callerContext=null,this.plugins.selectMenu.init.call(this,this.context.selectMenu.callerContext)}},YC={name:"link",display:"dialog",add:function(e){e.addModule([Fi,ch]);const t=e.context,n=t.link={focusElement:null,_linkAnchor:null,anchorCtx:null};let i=this.setDialog(e);n.modal=i;let s=this.setController_LinkButton(e);n.linkController=s,i.querySelector("form").addEventListener("submit",this.submit.bind(e)),s.addEventListener("click",this.onClick_linkController.bind(e)),t.dialog.modal.appendChild(i),t.element.relative.appendChild(s),e.plugins.anchor.initEvent.call(e,"link",i),n.focusElement=t.anchor.caller.link.urlInput,i=null,s=null},setDialog:function(e){const t=e.lang,n=e.util.createElement("DIV"),i=e.icons;n.className="se-dialog-content",n.style.display="none";let s='<form><div class="se-dialog-header"><button type="button" data-command="close" class="se-btn se-dialog-close" title="'+t.dialogBox.close+'" aria-label="'+t.dialogBox.close+'">'+i.cancel+'</button><span class="se-modal-title">'+t.dialogBox.linkBox.title+"</span></div>"+e.context.anchor.forms.innerHTML+'<div class="se-dialog-footer"><button type="submit" class="se-btn-primary" title="'+t.dialogBox.submitButton+'" aria-label="'+t.dialogBox.submitButton+'"><span>'+t.dialogBox.submitButton+"</span></button></div></form>";return n.innerHTML=s,n},setController_LinkButton:function(e){const t=e.lang,n=e.icons,i=e.util.createElement("DIV");return i.className="se-controller se-controller-link",i.innerHTML='<div class="se-arrow se-arrow-up"></div><div class="link-content"><span><a target="_blank" href=""></a>&nbsp;</span><div class="se-btn-group"><button type="button" data-command="update" tabindex="-1" class="se-btn se-tooltip">'+n.edit+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+t.controller.edit+'</span></span></button><button type="button" data-command="unlink" tabindex="-1" class="se-btn se-tooltip">'+n.unlink+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+t.controller.unlink+'</span></span></button><button type="button" data-command="delete" tabindex="-1" class="se-btn se-tooltip">'+n.delete+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+t.controller.remove+"</span></span></button></div></div>",i},open:function(){this.plugins.dialog.open.call(this,"link",this.currentControllerName==="link")},submit:function(e){this.showLoading(),e.preventDefault(),e.stopPropagation();try{const t=this.plugins.anchor.createAnchor.call(this,this.context.anchor.caller.link,!1);if(t===null)return;if(this.context.dialog.updateModal){const n=this.context.link._linkAnchor.childNodes[0];this.setRange(n,0,n,n.textContent.length)}else{const n=this.getSelectedElements();if(n.length>1){const i=this.util.createElement(n[0].nodeName);if(i.appendChild(t),!this.insertNode(i,null,!0))return}else if(!this.insertNode(t,null,!0))return;this.setRange(t.childNodes[0],0,t.childNodes[0],t.textContent.length)}}finally{this.plugins.dialog.close.call(this),this.closeLoading(),this.history.push(!1)}return!1},active:function(e){if(!e)this.controllerArray.indexOf(this.context.link.linkController)>-1&&this.controllersOff();else if(this.util.isAnchor(e)&&e.getAttribute("data-image-link")===null)return this.controllerArray.indexOf(this.context.link.linkController)<0&&this.plugins.link.call_controller.call(this,e),!0;return!1},on:function(e){this.plugins.anchor.on.call(this,this.context.anchor.caller.link,e)},call_controller:function(e){this.editLink=this.context.link._linkAnchor=this.context.anchor.caller.link.linkAnchor=e;const t=this.context.link.linkController,n=t.querySelector("a");n.href=e.href,n.title=e.textContent,n.textContent=e.textContent,this.util.addClass(e,"on"),this.setControllerPosition(t,e,"bottom",{left:0,top:0}),this.controllersOn(t,e,"link",this.util.removeClass.bind(this.util,this.context.link._linkAnchor,"on"))},onClick_linkController:function(e){e.stopPropagation();const t=e.target.getAttribute("data-command")||e.target.parentNode.getAttribute("data-command");if(t){if(e.preventDefault(),/update/.test(t))this.plugins.dialog.open.call(this,"link",!0);else if(/unlink/.test(t)){const n=this.util.getChildElement(this.context.link._linkAnchor,function(s){return s.childNodes.length===0||s.nodeType===3},!1),i=this.util.getChildElement(this.context.link._linkAnchor,function(s){return s.childNodes.length===0||s.nodeType===3},!0);this.setRange(n,0,i,i.textContent.length),this.nodeChange(null,null,["A"],!1)}else this.util.removeItem(this.context.link._linkAnchor),this.context.anchor.caller.link.linkAnchor=null,this.focus(),this.history.push(!1);this.controllersOff()}},init:function(){this.context.link.linkController.style.display="none",this.plugins.anchor.init.call(this,this.context.anchor.caller.link)}};var uh={exports:{}};(function(e){(function(t,n){e.exports=t.document?n(t,!0):function(i){if(!i.document)throw new Error("SUNEDITOR_MODULES a window with a document");return n(i)}})(typeof window<"u"?window:Yn,function(t,n){const i={name:"component",set_container:function(s,o){const l=this.util.createElement("DIV");return l.className="se-component "+o,l.appendChild(s),l},set_cover:function(s){const o=this.util.createElement("FIGURE");return o.appendChild(s),o},create_caption:function(){const s=this.util.createElement("FIGCAPTION");return s.innerHTML="<div>"+this.lang.dialogBox.caption+"</div>",s}};return typeof n>"u"&&(t.SUNEDITOR_MODULES||Object.defineProperty(t,"SUNEDITOR_MODULES",{enumerable:!0,writable:!1,configurable:!1,value:{}}),Object.defineProperty(t.SUNEDITOR_MODULES,"component",{enumerable:!0,writable:!1,configurable:!1,value:i})),i})})(uh);var ZC=uh.exports;const Xo=Zn(ZC);var dh={exports:{}};(function(e){(function(t,n){e.exports=t.document?n(t,!0):function(i){if(!i.document)throw new Error("SUNEDITOR_MODULES a window with a document");return n(i)}})(typeof window<"u"?window:Yn,function(t,n){const i={name:"resizing",add:function(s){const o=s.icons,l=s.context;l.resizing={_resizeClientX:0,_resizeClientY:0,_resize_plugin:"",_resize_w:0,_resize_h:0,_origin_w:0,_origin_h:0,_rotateVertical:!1,_resize_direction:"",_move_path:null,_isChange:!1,alignIcons:{basic:o.align_justify,left:o.align_left,right:o.align_right,center:o.align_center}};let a=this.setController_resize(s);l.resizing.resizeContainer=a,l.resizing.resizeDiv=a.querySelector(".se-modal-resize"),l.resizing.resizeDot=a.querySelector(".se-resize-dot"),l.resizing.resizeDisplay=a.querySelector(".se-resize-display");let r=this.setController_button(s);l.resizing.resizeButton=r;let f=l.resizing.resizeHandles=l.resizing.resizeDot.querySelectorAll("span");l.resizing.resizeButtonGroup=r.querySelector("._se_resizing_btn_group"),l.resizing.rotationButtons=r.querySelectorAll("._se_resizing_btn_group ._se_rotation"),l.resizing.percentageButtons=r.querySelectorAll("._se_resizing_btn_group ._se_percentage"),l.resizing.alignMenu=r.querySelector(".se-resizing-align-list"),l.resizing.alignMenuList=l.resizing.alignMenu.querySelectorAll("button"),l.resizing.alignButton=r.querySelector("._se_resizing_align_button"),l.resizing.autoSizeButton=r.querySelector("._se_resizing_btn_group ._se_auto_size"),l.resizing.captionButton=r.querySelector("._se_resizing_caption_button"),a.addEventListener("mousedown",function(d){d.preventDefault()}),f[0].addEventListener("mousedown",this.onMouseDown_resize_handle.bind(s)),f[1].addEventListener("mousedown",this.onMouseDown_resize_handle.bind(s)),f[2].addEventListener("mousedown",this.onMouseDown_resize_handle.bind(s)),f[3].addEventListener("mousedown",this.onMouseDown_resize_handle.bind(s)),f[4].addEventListener("mousedown",this.onMouseDown_resize_handle.bind(s)),f[5].addEventListener("mousedown",this.onMouseDown_resize_handle.bind(s)),f[6].addEventListener("mousedown",this.onMouseDown_resize_handle.bind(s)),f[7].addEventListener("mousedown",this.onMouseDown_resize_handle.bind(s)),r.addEventListener("click",this.onClick_resizeButton.bind(s)),l.element.relative.appendChild(a),l.element.relative.appendChild(r),a=null,r=null,f=null},setController_resize:function(s){const o=s.util.createElement("DIV");return o.className="se-controller se-resizing-container",o.style.display="none",o.innerHTML='<div class="se-modal-resize"></div><div class="se-resize-dot"><span class="tl"></span><span class="tr"></span><span class="bl"></span><span class="br"></span><span class="lw"></span><span class="th"></span><span class="rw"></span><span class="bh"></span><div class="se-resize-display"></div></div>',o},setController_button:function(s){const o=s.lang,l=s.icons,a=s.util.createElement("DIV");return a.className="se-controller se-controller-resizing",a.innerHTML='<div class="se-arrow se-arrow-up"></div><div class="se-btn-group _se_resizing_btn_group"><button type="button" data-command="percent" data-value="1" class="se-tooltip _se_percentage"><span>100%</span><span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.controller.resize100+'</span></span></button><button type="button" data-command="percent" data-value="0.75" class="se-tooltip _se_percentage"><span>75%</span><span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.controller.resize75+'</span></span></button><button type="button" data-command="percent" data-value="0.5" class="se-tooltip _se_percentage"><span>50%</span><span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.controller.resize50+'</span></span></button><button type="button" data-command="auto" class="se-btn se-tooltip _se_auto_size">'+l.auto_size+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.controller.autoSize+'</span></span></button><button type="button" data-command="rotate" data-value="-90" class="se-btn se-tooltip _se_rotation">'+l.rotate_left+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.controller.rotateLeft+'</span></span></button><button type="button" data-command="rotate" data-value="90" class="se-btn se-tooltip _se_rotation">'+l.rotate_right+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.controller.rotateRight+'</span></span></button></div><div class="se-btn-group" style="padding-top: 0;"><button type="button" data-command="mirror" data-value="h" class="se-btn se-tooltip">'+l.mirror_horizontal+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.controller.mirrorHorizontal+'</span></span></button><button type="button" data-command="mirror" data-value="v" class="se-btn se-tooltip">'+l.mirror_vertical+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.controller.mirrorVertical+'</span></span></button><button type="button" data-command="onalign" class="se-btn se-tooltip _se_resizing_align_button">'+l.align_justify+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.toolbar.align+'</span></span></button><div class="se-btn-group-sub sun-editor-common se-list-layer se-resizing-align-list"><div class="se-list-inner"><ul class="se-list-basic"><li><button type="button" class="se-btn-list se-tooltip" data-command="align" data-value="basic">'+l.align_justify+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.dialogBox.basic+'</span></span></button></li><li><button type="button" class="se-btn-list se-tooltip" data-command="align" data-value="left">'+l.align_left+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.dialogBox.left+'</span></span></button></li><li><button type="button" class="se-btn-list se-tooltip" data-command="align" data-value="center">'+l.align_center+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.dialogBox.center+'</span></span></button></li><li><button type="button" class="se-btn-list se-tooltip" data-command="align" data-value="right">'+l.align_right+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.dialogBox.right+'</span></span></button></li></ul></div></div><button type="button" data-command="caption" class="se-btn se-tooltip _se_resizing_caption_button">'+l.caption+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.dialogBox.caption+'</span></span></button><button type="button" data-command="revert" class="se-btn se-tooltip">'+l.revert+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.dialogBox.revertButton+'</span></span></button><button type="button" data-command="update" class="se-btn se-tooltip">'+l.modify+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.controller.edit+'</span></span></button><button type="button" data-command="delete" class="se-btn se-tooltip">'+l.delete+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.controller.remove+"</span></span></button></div>",a},_module_getSizeX:function(s,o,l,a){return o||(o=s._element),l||(l=s._cover),a||(a=s._container),o?/%$/.test(o.style.width)?(a&&this.util.getNumber(a.style.width,2)||100)+"%":o.style.width:""},_module_getSizeY:function(s,o,l,a){return o||(o=s._element),l||(l=s._cover),a||(a=s._container),!a||!l?o&&o.style.height||"":this.util.getNumber(l.style.paddingBottom,0)>0&&!this.context.resizing._rotateVertical?l.style.height:!/%$/.test(o.style.height)||!/%$/.test(o.style.width)?o.style.height:(a&&this.util.getNumber(a.style.height,2)||100)+"%"},_module_setModifyInputSize:function(s,o){const l=s._onlyPercentage&&this.context.resizing._rotateVertical;s.proportion.checked=s._proportionChecked=s._element.getAttribute("data-proportion")!=="false";let a=l?"":this.plugins.resizing._module_getSizeX.call(this,s);if(a===s._defaultSizeX&&(a=""),s._onlyPercentage&&(a=this.util.getNumber(a,2)),s.inputX.value=a,o.setInputSize.call(this,"x"),!s._onlyPercentage){let r=l?"":this.plugins.resizing._module_getSizeY.call(this,s);r===s._defaultSizeY&&(r=""),s._onlyPercentage&&(r=this.util.getNumber(r,2)),s.inputY.value=r}s.inputX.disabled=!!l,s.inputY.disabled=!!l,s.proportion.disabled=!!l,o.setRatio.call(this)},_module_setInputSize:function(s,o){if(s._onlyPercentage){o==="x"&&s.inputX.value>100&&(s.inputX.value=100);return}if(s.proportion.checked&&s._ratio&&/\d/.test(s.inputX.value)&&/\d/.test(s.inputY.value)){const l=s.inputX.value.replace(/\d+|\./g,"")||s.sizeUnit,a=s.inputY.value.replace(/\d+|\./g,"")||s.sizeUnit;if(l!==a)return;const r=l==="%"?2:0;o==="x"?s.inputY.value=this.util.getNumber(s._ratioY*this.util.getNumber(s.inputX.value,r),r)+a:s.inputX.value=this.util.getNumber(s._ratioX*this.util.getNumber(s.inputY.value,r),r)+l}},_module_setRatio:function(s){const o=s.inputX.value,l=s.inputY.value;if(s.proportion.checked&&/\d+/.test(o)&&/\d+/.test(l)){const a=o.replace(/\d+|\./g,"")||s.sizeUnit,r=l.replace(/\d+|\./g,"")||s.sizeUnit;if(a!==r)s._ratio=!1;else if(!s._ratio){const f=this.util.getNumber(o,0),d=this.util.getNumber(l,0);s._ratio=!0,s._ratioX=f/d,s._ratioY=d/f}}else s._ratio=!1},_module_sizeRevert:function(s){s._onlyPercentage?s.inputX.value=s._origin_w>100?100:s._origin_w:(s.inputX.value=s._origin_w,s.inputY.value=s._origin_h)},_module_saveCurrentSize:function(s){const o=this.plugins.resizing._module_getSizeX.call(this,s),l=this.plugins.resizing._module_getSizeY.call(this,s);s._element.setAttribute("width",o.replace("px","")),s._element.setAttribute("height",l.replace("px","")),s._element.setAttribute("data-size",o+","+l),s._videoRatio&&(s._videoRatio=l)},call_controller_resize:function(s,o){const l=this.context.resizing,a=this.context[o];l._resize_plugin=o;const r=l.resizeContainer,f=l.resizeDiv,d=this.util.getOffset(s,this.context.element.wysiwygFrame),h=l._rotateVertical=/^(90|270)$/.test(Math.abs(s.getAttribute("data-rotate")).toString()),v=h?s.offsetHeight:s.offsetWidth,_=h?s.offsetWidth:s.offsetHeight,C=d.top,S=d.left-this.context.element.wysiwygFrame.scrollLeft;r.style.top=C+"px",r.style.left=S+"px",r.style.width=v+"px",r.style.height=_+"px",f.style.top="0px",f.style.left="0px",f.style.width=v+"px",f.style.height=_+"px";let c=s.getAttribute("data-align")||"basic";c=c==="none"?"basic":c;const u=this.util.getParentElement(s,this.util.isComponent),p=this.util.getParentElement(s,"FIGURE"),b=this.plugins.resizing._module_getSizeX.call(this,a,s,p,u)||"auto",y=a._onlyPercentage&&o==="image"?"":", "+(this.plugins.resizing._module_getSizeY.call(this,a,s,p,u)||"auto");this.util.changeTxt(l.resizeDisplay,this.lang.dialogBox[c]+" ("+b+y+")"),l.resizeButtonGroup.style.display=a._resizing?"":"none";const w=a._resizing&&!a._resizeDotHide&&!a._onlyPercentage?"flex":"none",x=l.resizeHandles;for(let M=0,A=x.length;M<A;M++)x[M].style.display=w;if(a._resizing){const M=l.rotationButtons;M[0].style.display=M[1].style.display=a._rotation?"":"none"}if(a._alignHide)l.alignButton.style.display="none";else{l.alignButton.style.display="";const M=l.alignMenuList;this.util.changeElement(l.alignButton.firstElementChild,l.alignIcons[c]);for(let A=0,D=M.length;A<D;A++)M[A].getAttribute("data-value")===c?this.util.addClass(M[A],"on"):this.util.removeClass(M[A],"on")}const E=l.percentageButtons,k=/%$/.test(s.style.width)&&/%$/.test(u.style.width)?this.util.getNumber(u.style.width,0)/100+"":"";for(let M=0,A=E.length;M<A;M++)E[M].getAttribute("data-value")===k?this.util.addClass(E[M],"active"):this.util.removeClass(E[M],"active");a._captionShow?(l.captionButton.style.display="",this.util.getChildElement(s.parentNode,"figcaption")?(this.util.addClass(l.captionButton,"active"),a._captionChecked=!0):(this.util.removeClass(l.captionButton,"active"),a._captionChecked=!1)):l.captionButton.style.display="none",r.style.display="block";const N={left:0,top:50};this.options.iframe&&(N.left-=this.context.element.wysiwygFrame.parentElement.offsetLeft,N.top-=this.context.element.wysiwygFrame.parentElement.offsetTop),this.setControllerPosition(l.resizeButton,r,"bottom",N);const T=function(){this.util.setDisabledButtons.call(this.util,!1,this.resizingDisabledButtons),this.history._resetCachingButton()};this.controllersOn(r,l.resizeButton,T.bind(this),s,o),this.util.setDisabledButtons(!0,this.resizingDisabledButtons),l._resize_w=v,l._resize_h=_;const R=(s.getAttribute("origin-size")||"").split(",");return l._origin_w=R[0]||s.naturalWidth,l._origin_h=R[1]||s.naturalHeight,{w:v,h:_,t:C,l:S}},_closeAlignMenu:null,openAlignMenu:function(){const s=this.context.resizing.alignButton;this.util.addClass(s,"on"),this.context.resizing.alignMenu.style.top=s.offsetTop+s.offsetHeight+"px",this.context.resizing.alignMenu.style.left=s.offsetLeft-s.offsetWidth/2+"px",this.context.resizing.alignMenu.style.display="block",this.plugins.resizing._closeAlignMenu=(function(){this.util.removeClass(this.context.resizing.alignButton,"on"),this.context.resizing.alignMenu.style.display="none",this.removeDocEvent("click",this.plugins.resizing._closeAlignMenu),this.plugins.resizing._closeAlignMenu=null}).bind(this),this.addDocEvent("click",this.plugins.resizing._closeAlignMenu)},onClick_resizeButton:function(s){s.stopPropagation();const o=s.target,l=o.getAttribute("data-command")||o.parentNode.getAttribute("data-command");if(!l)return;const a=o.getAttribute("data-value")||o.parentNode.getAttribute("data-value"),r=this.context.resizing._resize_plugin,f=this.context[r],d=f._element,h=this.plugins[r];if(s.preventDefault(),!(typeof this.plugins.resizing._closeAlignMenu=="function"&&(this.plugins.resizing._closeAlignMenu(),l==="onalign"))){switch(l){case"auto":this.plugins.resizing.resetTransform.call(this,d),h.setAutoSize.call(this),this.selectComponent(d,r);break;case"percent":let v=this.plugins.resizing._module_getSizeY.call(this,f);if(this.context.resizing._rotateVertical){const w=d.getAttribute("data-percentage");w&&(v=w.split(",")[1])}this.plugins.resizing.resetTransform.call(this,d),h.setPercentSize.call(this,a*100,this.util.getNumber(v,0)===null||!/%$/.test(v)?"":v),this.selectComponent(d,r);break;case"mirror":const _=d.getAttribute("data-rotate")||"0";let C=d.getAttribute("data-rotateX")||"",S=d.getAttribute("data-rotateY")||"";a==="h"&&!this.context.resizing._rotateVertical||a==="v"&&this.context.resizing._rotateVertical?S=S?"":"180":C=C?"":"180",d.setAttribute("data-rotateX",C),d.setAttribute("data-rotateY",S),this.plugins.resizing._setTransForm(d,_,C,S);break;case"rotate":const c=this.context.resizing,u=d.getAttribute("data-rotate")*1+a*1,p=this._w.Math.abs(u)>=360?0:u;d.setAttribute("data-rotate",p),c._rotateVertical=/^(90|270)$/.test(this._w.Math.abs(p).toString()),this.plugins.resizing.setTransformSize.call(this,d,null,null),this.selectComponent(d,r);break;case"onalign":this.plugins.resizing.openAlignMenu.call(this);return;case"align":const b=a==="basic"?"none":a;h.setAlign.call(this,b,null,null,null),this.selectComponent(d,r);break;case"caption":const y=!f._captionChecked;if(h.openModify.call(this,!0),f._captionChecked=f.captionCheckEl.checked=y,h.update_image.call(this,!1,!1,!1),y){const w=this.util.getChildElement(f._caption,function(x){return x.nodeType===3});w?this.setRange(w,0,w,w.textContent.length):f._caption.focus(),this.controllersOff()}else this.selectComponent(d,r),h.openModify.call(this,!0);break;case"revert":h.setOriginSize.call(this),this.selectComponent(d,r);break;case"update":h.openModify.call(this),this.controllersOff();break;case"delete":h.destroy.call(this);break}this.history.push(!1)}},resetTransform:function(s){const o=(s.getAttribute("data-size")||s.getAttribute("data-origin")||"").split(",");this.context.resizing._rotateVertical=!1,s.style.maxWidth="",s.style.transform="",s.style.transformOrigin="",s.setAttribute("data-rotate",""),s.setAttribute("data-rotateX",""),s.setAttribute("data-rotateY",""),this.plugins[this.context.resizing._resize_plugin].setSize.call(this,o[0]?o[0]:"auto",o[1]?o[1]:"",!0)},setTransformSize:function(s,o,l){let a=s.getAttribute("data-percentage");const r=this.context.resizing._rotateVertical,f=s.getAttribute("data-rotate")*1;let d="";if(a&&!r)a=a.split(","),a[0]==="auto"&&a[1]==="auto"?this.plugins[this.context.resizing._resize_plugin].setAutoSize.call(this):this.plugins[this.context.resizing._resize_plugin].setPercentSize.call(this,a[0],a[1]);else{const h=this.util.getParentElement(s,"FIGURE"),v=o||s.offsetWidth,_=l||s.offsetHeight,C=(r?_:v)+"px",S=(r?v:_)+"px";if(this.plugins[this.context.resizing._resize_plugin].cancelPercentAttr.call(this),this.plugins[this.context.resizing._resize_plugin].setSize.call(this,v+"px",_+"px",!0),h.style.width=C,h.style.height=this.context[this.context.resizing._resize_plugin]._caption?"":S,r){let c=v/2+"px "+v/2+"px 0",u=_/2+"px "+_/2+"px 0";d=f===90||f===-270?u:c}}s.style.transformOrigin=d,this.plugins.resizing._setTransForm(s,f.toString(),s.getAttribute("data-rotateX")||"",s.getAttribute("data-rotateY")||""),r?s.style.maxWidth="none":s.style.maxWidth="",this.plugins.resizing.setCaptionPosition.call(this,s)},_setTransForm:function(s,o,l,a){let r=(s.offsetWidth-s.offsetHeight)*(/-/.test(o)?1:-1),f="";if(/[1-9]/.test(o)&&(l||a))switch(f=l?"Y":"X",o){case"90":f=l&&a?"X":a?f:"";break;case"270":r*=-1,f=l&&a?"Y":l?f:"";break;case"-90":f=l&&a?"Y":l?f:"";break;case"-270":r*=-1,f=l&&a?"X":a?f:"";break;default:f=""}o%180===0&&(s.style.maxWidth=""),s.style.transform="rotate("+o+"deg)"+(l?" rotateX("+l+"deg)":"")+(a?" rotateY("+a+"deg)":"")+(f?" translate"+f+"("+r+"px)":"")},setCaptionPosition:function(s){const o=this.util.getChildElement(this.util.getParentElement(s,"FIGURE"),"FIGCAPTION");o&&(o.style.marginTop=(this.context.resizing._rotateVertical?s.offsetWidth-s.offsetHeight:0)+"px")},onMouseDown_resize_handle:function(s){s.stopPropagation(),s.preventDefault();const o=this.context.resizing,l=o._resize_direction=s.target.classList[0];o._resizeClientX=s.clientX,o._resizeClientY=s.clientY,this.context.element.resizeBackground.style.display="block",o.resizeButton.style.display="none",o.resizeDiv.style.float=/l/.test(l)?"right":/r/.test(l)?"left":"none";const a=(function(d){if(d.type==="keydown"&&d.keyCode!==27)return;const h=o._isChange;o._isChange=!1,this.removeDocEvent("mousemove",r),this.removeDocEvent("mouseup",a),this.removeDocEvent("keydown",a),d.type==="keydown"?(this.controllersOff(),this.context.element.resizeBackground.style.display="none",this.plugins[this.context.resizing._resize_plugin].init.call(this)):(this.plugins.resizing.cancel_controller_resize.call(this,l),h&&this.history.push(!1))}).bind(this),r=this.plugins.resizing.resizing_element.bind(this,o,l,this.context[o._resize_plugin]);this.addDocEvent("mousemove",r),this.addDocEvent("mouseup",a),this.addDocEvent("keydown",a)},resizing_element:function(s,o,l,a){const r=a.clientX,f=a.clientY;let d=l._element_w,h=l._element_h;const v=l._element_w+(/r/.test(o)?r-s._resizeClientX:s._resizeClientX-r),_=l._element_h+(/b/.test(o)?f-s._resizeClientY:s._resizeClientY-f),C=l._element_h/l._element_w*v;/t/.test(o)&&(s.resizeDiv.style.top=l._element_h-(/h/.test(o)?_:C)+"px"),/l/.test(o)&&(s.resizeDiv.style.left=l._element_w-v+"px"),/r|l/.test(o)&&(s.resizeDiv.style.width=v+"px",d=v),/^(t|b)[^h]$/.test(o)?(s.resizeDiv.style.height=C+"px",h=C):/^(t|b)h$/.test(o)&&(s.resizeDiv.style.height=_+"px",h=_),s._resize_w=d,s._resize_h=h,this.util.changeTxt(s.resizeDisplay,this._w.Math.round(d)+" x "+this._w.Math.round(h)),s._isChange=!0},cancel_controller_resize:function(s){const o=this.context.resizing._rotateVertical;this.controllersOff(),this.context.element.resizeBackground.style.display="none";let l=this._w.Math.round(o?this.context.resizing._resize_h:this.context.resizing._resize_w),a=this._w.Math.round(o?this.context.resizing._resize_w:this.context.resizing._resize_h);if(!o&&!/%$/.test(l)){const d=this.context.element.wysiwygFrame.clientWidth-32-2;this.util.getNumber(l,0)>d&&(a=this._w.Math.round(a/l*d),l=d)}const r=this.context.resizing._resize_plugin;this.plugins[r].setSize.call(this,l,a,!1,s),o&&this.plugins.resizing.setTransformSize.call(this,this.context[this.context.resizing._resize_plugin]._element,l,a),this.selectComponent(this.context[r]._element,r)}};return typeof n>"u"&&(t.SUNEDITOR_MODULES||Object.defineProperty(t,"SUNEDITOR_MODULES",{enumerable:!0,writable:!1,configurable:!1,value:{}}),Object.defineProperty(t.SUNEDITOR_MODULES,"resizing",{enumerable:!0,writable:!1,configurable:!1,value:i})),i})})(dh);var qC=dh.exports;const fh=Zn(qC);var hh={exports:{}};(function(e){(function(t,n){e.exports=t.document?n(t,!0):function(i){if(!i.document)throw new Error("SUNEDITOR_MODULES a window with a document");return n(i)}})(typeof window<"u"?window:Yn,function(t,n){const i={name:"fileManager",_xmlHttp:null,_checkMediaComponent:function(s){return/IMG|IFRAME|VIDEO|AUDIO/i.test(s.tagName)?/FIGURE/i.test(s.parentElement.nodeName)||/FIGURE/i.test(s.parentElement.parentElement.nodeName):!0},upload:function(s,o,l,a,r){this.showLoading();const f=this.plugins.fileManager,d=f._xmlHttp=this.util.getXMLHttpRequest();if(d.onreadystatechange=f._callBackUpload.bind(this,d,a,r),d.open("post",s,!0),o!==null&&typeof o=="object"&&this._w.Object.keys(o).length>0)for(let h in o)d.setRequestHeader(h,o[h]);d.send(l)},_callBackUpload:function(s,o,l){if(s.readyState===4)if(s.status===200)try{o(s)}catch(a){throw Error('[SUNEDITOR.fileManager.upload.callBack.fail] cause : "'+a.message+'"')}finally{this.closeLoading()}else{this.closeLoading();const a=s.responseText?JSON.parse(s.responseText):s;if(typeof l!="function"||l("",a,this)){const r="[SUNEDITOR.fileManager.upload.serverException] status: "+s.status+", response: "+(a.errorMessage||s.responseText);throw this.functions.noticeOpen(r),Error(r)}}},checkInfo:function(s,o,l,a,r){let f=[];for(let u=0,p=o.length;u<p;u++)f=f.concat([].slice.call(this.context.element.wysiwyg.querySelectorAll(o[u]+':not([data-se-embed="true"])')));const d=this.plugins.fileManager,h=this.context[s],v=h._infoList,_=d.setInfo.bind(this);if(f.length===v.length)if(this._componentsInfoReset){for(let u=0,p=f.length;u<p;u++)_(s,f[u],l,null,r);return}else{let u=!1;for(let p=0,b=v.length,y;p<b;p++)if(y=v[p],f.filter(function(w){return y.src===w.src&&y.index.toString()===w.getAttribute("data-index")}).length===0){u=!0;break}if(!u)return}const C=r?this.context.resizing._resize_plugin:"";r&&(this.context.resizing._resize_plugin=s);const S=[],c=[];for(let u=0,p=v.length;u<p;u++)c[u]=v[u].index;for(h.__updateTags=f;f.length>0;){const u=f.shift();!this.util.getParentElement(u,this.util.isMediaComponent)||!d._checkMediaComponent(u)?(S.push(h._infoIndex),a(u)):!u.getAttribute("data-index")||c.indexOf(u.getAttribute("data-index")*1)<0?(S.push(h._infoIndex),u.removeAttribute("data-index"),_(s,u,l,null,r)):S.push(u.getAttribute("data-index")*1)}for(let u=0,p;u<v.length;u++)p=v[u].index,!(S.indexOf(p)>-1)&&(v.splice(u,1),typeof l=="function"&&l(null,p,"delete",null,0,this),u--);r&&(this.context.resizing._resize_plugin=C)},setInfo:function(s,o,l,a,r){const f=r?this.context.resizing._resize_plugin:"";r&&(this.context.resizing._resize_plugin=s);const d=this.plugins[s],h=this.context[s],v=h._infoList;let _=o.getAttribute("data-index"),C=null,S="";if(a||(a={name:o.getAttribute("data-file-name")||(typeof o.src=="string"?o.src.split("/").pop():""),size:o.getAttribute("data-file-size")||0}),!_||this._componentsInfoInit)S="create",_=h._infoIndex++,o.setAttribute("data-index",_),o.setAttribute("data-file-name",a.name),o.setAttribute("data-file-size",a.size),C={src:o.src,index:_*1,name:a.name,size:a.size},v.push(C);else{S="update",_*=1;for(let c=0,u=v.length;c<u;c++)if(_===v[c].index){C=v[c];break}C||(_=h._infoIndex++,C={index:_},v.push(C)),C.src=o.src,C.name=o.getAttribute("data-file-name"),C.size=o.getAttribute("data-file-size")*1}if(C.element=o,C.delete=d.destroy.bind(this,o),C.select=(function(c){c.scrollIntoView(!0),this._w.setTimeout(d.select.bind(this,c))}).bind(this,o),r){if(!o.getAttribute("origin-size")&&o.naturalWidth&&o.setAttribute("origin-size",o.naturalWidth+","+o.naturalHeight),!o.getAttribute("data-origin")){const c=this.util.getParentElement(o,this.util.isMediaComponent),u=this.util.getParentElement(o,"FIGURE"),p=this.plugins.resizing._module_getSizeX.call(this,h,o,u,c),b=this.plugins.resizing._module_getSizeY.call(this,h,o,u,c);o.setAttribute("data-origin",p+","+b),o.setAttribute("data-size",p+","+b)}if(!o.style.width){const c=(o.getAttribute("data-size")||o.getAttribute("data-origin")||"").split(",");d.onModifyMode.call(this,o,null),d.applySize.call(this,c[0],c[1])}this.context.resizing._resize_plugin=f}typeof l=="function"&&l(o,_,S,C,--h._uploadFileLength<0?0:h._uploadFileLength,this)},deleteInfo:function(s,o,l){if(o>=0){const a=this.context[s]._infoList;for(let r=0,f=a.length;r<f;r++)if(o===a[r].index){a.splice(r,1),typeof l=="function"&&l(null,o,"delete",null,0,this);return}}},resetInfo:function(s,o){const l=this.context[s];if(typeof o=="function"){const a=l._infoList;for(let r=0,f=a.length;r<f;r++)o(null,a[r].index,"delete",null,0,this)}l._infoList=[],l._infoIndex=0}};return typeof n>"u"&&(t.SUNEDITOR_MODULES||Object.defineProperty(t,"SUNEDITOR_MODULES",{enumerable:!0,writable:!1,configurable:!1,value:{}}),Object.defineProperty(t.SUNEDITOR_MODULES,"fileManager",{enumerable:!0,writable:!1,configurable:!1,value:i})),i})})(hh);var GC=hh.exports;const Qo=Zn(GC),KC={name:"image",display:"dialog",add:function(e){e.addModule([Fi,ch,Xo,fh,Qo]);const t=e.options,n=e.context,i=n.image={_infoList:[],_infoIndex:0,_uploadFileLength:0,focusElement:null,sizeUnit:t._imageSizeUnit,_linkElement:"",_altText:"",_align:"none",_floatClassRegExp:"__se__float\\-[a-z]+",_v_src:{_linkValue:""},svgDefaultSize:"30%",base64RenderIndex:0,_element:null,_cover:null,_container:null,inputX:null,inputY:null,_element_w:1,_element_h:1,_element_l:0,_element_t:0,_defaultSizeX:"auto",_defaultSizeY:"auto",_origin_w:t.imageWidth==="auto"?"":t.imageWidth,_origin_h:t.imageHeight==="auto"?"":t.imageHeight,_proportionChecked:!0,_resizing:t.imageResizing,_resizeDotHide:!t.imageHeightShow,_rotation:t.imageRotation,_alignHide:!t.imageAlignShow,_onlyPercentage:t.imageSizeOnlyPercentage,_ratio:!1,_ratioX:1,_ratioY:1,_captionShow:!0,_captionChecked:!1,_caption:null,captionCheckEl:null};let s=this.setDialog(e);i.modal=s,i.imgInputFile=s.querySelector("._se_image_file"),i.imgUrlFile=s.querySelector("._se_image_url"),i.focusElement=i.imgInputFile||i.imgUrlFile,i.altText=s.querySelector("._se_image_alt"),i.captionCheckEl=s.querySelector("._se_image_check_caption"),i.previewSrc=s.querySelector("._se_tab_content_image .se-link-preview"),s.querySelector(".se-dialog-tabs").addEventListener("click",this.openTab.bind(e)),s.querySelector("form").addEventListener("submit",this.submit.bind(e)),i.imgInputFile&&s.querySelector(".se-file-remove").addEventListener("click",this._removeSelectedFiles.bind(i.imgInputFile,i.imgUrlFile,i.previewSrc)),i.imgUrlFile&&i.imgUrlFile.addEventListener("input",this._onLinkPreview.bind(i.previewSrc,i._v_src,t.linkProtocol)),i.imgInputFile&&i.imgUrlFile&&i.imgInputFile.addEventListener("change",this._fileInputChange.bind(i));const o=s.querySelector(".__se__gallery");o&&o.addEventListener("click",this._openGallery.bind(e)),i.proportion={},i.inputX={},i.inputY={},t.imageResizing&&(i.proportion=s.querySelector("._se_image_check_proportion"),i.inputX=s.querySelector("._se_image_size_x"),i.inputY=s.querySelector("._se_image_size_y"),i.inputX.value=t.imageWidth,i.inputY.value=t.imageHeight,i.inputX.addEventListener("keyup",this.setInputSize.bind(e,"x")),i.inputY.addEventListener("keyup",this.setInputSize.bind(e,"y")),i.inputX.addEventListener("change",this.setRatio.bind(e)),i.inputY.addEventListener("change",this.setRatio.bind(e)),i.proportion.addEventListener("change",this.setRatio.bind(e)),s.querySelector(".se-dialog-btn-revert").addEventListener("click",this.sizeRevert.bind(e))),n.dialog.modal.appendChild(s),e.plugins.anchor.initEvent.call(e,"image",s.querySelector("._se_tab_content_url")),i.anchorCtx=e.context.anchor.caller.image,s=null},setDialog:function(e){const t=e.options,n=e.lang,i=e.util.createElement("DIV");i.className="se-dialog-content se-dialog-image",i.style.display="none";let s='<div class="se-dialog-header"><button type="button" data-command="close" class="se-btn se-dialog-close" class="close" title="'+n.dialogBox.close+'" aria-label="'+n.dialogBox.close+'">'+e.icons.cancel+'</button><span class="se-modal-title">'+n.dialogBox.imageBox.title+'</span></div><div class="se-dialog-tabs"><button type="button" class="_se_tab_link active" data-tab-link="image">'+n.toolbar.image+'</button><button type="button" class="_se_tab_link" data-tab-link="url">'+n.toolbar.link+'</button></div><form method="post" enctype="multipart/form-data"><div class="_se_tab_content _se_tab_content_image"><div class="se-dialog-body"><div style="border-bottom: 1px dashed #ccc;">';if(t.imageFileInput&&(s+='<div class="se-dialog-form"><label>'+n.dialogBox.imageBox.file+'</label><div class="se-dialog-form-files"><input class="se-input-form _se_image_file" type="file" accept="'+t.imageAccept+'"'+(t.imageMultipleFile?' multiple="multiple"':"")+'/><button type="button" class="se-btn se-dialog-files-edge-button se-file-remove" title="'+n.controller.remove+'" aria-label="'+n.controller.remove+'">'+e.icons.cancel+"</button></div></div>"),t.imageUrlInput&&(s+='<div class="se-dialog-form"><label>'+n.dialogBox.imageBox.url+'</label><div class="se-dialog-form-files"><input class="se-input-form se-input-url _se_image_url" type="text" />'+(t.imageGalleryUrl&&e.plugins.imageGallery?'<button type="button" class="se-btn se-dialog-files-edge-button __se__gallery" title="'+n.toolbar.imageGallery+'" aria-label="'+n.toolbar.imageGallery+'">'+e.icons.image_gallery+"</button>":"")+'</div><pre class="se-link-preview"></pre></div>'),s+='</div><div class="se-dialog-form"><label>'+n.dialogBox.imageBox.altText+'</label><input class="se-input-form _se_image_alt" type="text" /></div>',t.imageResizing){const o=t.imageSizeOnlyPercentage,l=o?' style="display: none !important;"':"",a=t.imageHeightShow?"":' style="display: none !important;"';s+='<div class="se-dialog-form">',o||!t.imageHeightShow?s+='<div class="se-dialog-size-text"><label class="size-w">'+n.dialogBox.size+"</label></div>":s+='<div class="se-dialog-size-text"><label class="size-w">'+n.dialogBox.width+'</label><label class="se-dialog-size-x">&nbsp;</label><label class="size-h">'+n.dialogBox.height+"</label></div>",s+='<input class="se-input-control _se_image_size_x" placeholder="auto"'+(o?' type="number" min="1"':'type="text"')+(o?' max="100"':"")+' /><label class="se-dialog-size-x"'+a+">"+(o?"%":"x")+'</label><input type="text" class="se-input-control _se_image_size_y" placeholder="auto"'+l+(o?' max="100"':"")+a+"/><label"+l+a+'><input type="checkbox" class="se-dialog-btn-check _se_image_check_proportion" checked/>&nbsp;'+n.dialogBox.proportion+'</label><button type="button" title="'+n.dialogBox.revertButton+'" aria-label="'+n.dialogBox.revertButton+'" class="se-btn se-dialog-btn-revert" style="float: right;">'+e.icons.revert+"</button></div>"}return s+='<div class="se-dialog-form se-dialog-form-footer"><label><input type="checkbox" class="se-dialog-btn-check _se_image_check_caption" />&nbsp;'+n.dialogBox.caption+'</label></div></div></div><div class="_se_tab_content _se_tab_content_url" style="display: none">'+e.context.anchor.forms.innerHTML+'</div><div class="se-dialog-footer"><div'+(t.imageAlignShow?"":' style="display: none"')+'><label><input type="radio" name="suneditor_image_radio" class="se-dialog-btn-radio" value="none" checked>'+n.dialogBox.basic+'</label><label><input type="radio" name="suneditor_image_radio" class="se-dialog-btn-radio" value="left">'+n.dialogBox.left+'</label><label><input type="radio" name="suneditor_image_radio" class="se-dialog-btn-radio" value="center">'+n.dialogBox.center+'</label><label><input type="radio" name="suneditor_image_radio" class="se-dialog-btn-radio" value="right">'+n.dialogBox.right+'</label></div><button type="submit" class="se-btn-primary" title="'+n.dialogBox.submitButton+'" aria-label="'+n.dialogBox.submitButton+'"><span>'+n.dialogBox.submitButton+"</span></button></div></form>",i.innerHTML=s,i},_fileInputChange:function(){this.imgInputFile.value?(this.imgUrlFile.setAttribute("disabled",!0),this.previewSrc.style.textDecoration="line-through"):(this.imgUrlFile.removeAttribute("disabled"),this.previewSrc.style.textDecoration="")},_removeSelectedFiles:function(e,t){this.value="",e&&(e.removeAttribute("disabled"),t.style.textDecoration="")},_openGallery:function(){this.callPlugin("imageGallery",this.plugins.imageGallery.open.bind(this,this.plugins.image._setUrlInput.bind(this.context.image)),null)},_setUrlInput:function(e){this.altText.value=e.alt,this._v_src._linkValue=this.previewSrc.textContent=this.imgUrlFile.value=e.getAttribute("data-value")||e.src,this.imgUrlFile.focus()},_onLinkPreview:function(e,t,n){const i=n.target.value.trim();e._linkValue=this.textContent=i?t&&i.indexOf("://")===-1&&i.indexOf("#")!==0?t+i:i.indexOf("://")===-1?"/"+i:i:""},fileTags:["img"],select:function(e){this.plugins.image.onModifyMode.call(this,e,this.plugins.resizing.call_controller_resize.call(this,e,"image"))},destroy:function(e){const t=e||this.context.image._element,n=this.util.getParentElement(t,this.util.isMediaComponent)||t,i=t.getAttribute("data-index")*1;if(typeof this.functions.onImageDeleteBefore=="function"&&this.functions.onImageDeleteBefore(t,n,i,this)===!1)return;let s=n.previousElementSibling||n.nextElementSibling;const o=n.parentNode;this.util.removeItem(n),this.plugins.image.init.call(this),this.controllersOff(),o!==this.context.element.wysiwyg&&this.util.removeItemAllParents(o,function(l){return l.childNodes.length===0},null),this.focusEdge(s),this.plugins.fileManager.deleteInfo.call(this,"image",i,this.functions.onImageUpload),this.history.push(!1)},on:function(e){const t=this.context.image;e?t.imgInputFile&&this.options.imageMultipleFile&&t.imgInputFile.removeAttribute("multiple"):(t.inputX.value=t._origin_w=this.options.imageWidth===t._defaultSizeX?"":this.options.imageWidth,t.inputY.value=t._origin_h=this.options.imageHeight===t._defaultSizeY?"":this.options.imageHeight,t.imgInputFile&&this.options.imageMultipleFile&&t.imgInputFile.setAttribute("multiple","multiple")),this.plugins.anchor.on.call(this,t.anchorCtx,e)},open:function(){this.plugins.dialog.open.call(this,"image",this.currentControllerName==="image")},openTab:function(e){const t=this.context.image.modal,n=e==="init"?t.querySelector("._se_tab_link"):e.target;if(!/^BUTTON$/i.test(n.tagName))return!1;const i=n.getAttribute("data-tab-link"),s="_se_tab_content";let o,l,a;for(l=t.getElementsByClassName(s),o=0;o<l.length;o++)l[o].style.display="none";for(a=t.getElementsByClassName("_se_tab_link"),o=0;o<a.length;o++)this.util.removeClass(a[o],"active");return t.querySelector("."+s+"_"+i).style.display="block",this.util.addClass(n,"active"),i==="image"&&this.context.image.focusElement?this.context.image.focusElement.focus():i==="url"&&this.context.anchor.caller.image.urlInput.focus(),!1},submit:function(e){const t=this.context.image,n=this.plugins.image;e.preventDefault(),e.stopPropagation(),t._altText=t.altText.value,t._align=t.modal.querySelector('input[name="suneditor_image_radio"]:checked').value,t._captionChecked=t.captionCheckEl.checked,t._resizing&&(t._proportionChecked=t.proportion.checked);try{this.context.dialog.updateModal&&n.update_image.call(this,!1,!0,!1),t.imgInputFile&&t.imgInputFile.files.length>0?(this.showLoading(),n.submitAction.call(this,this.context.image.imgInputFile.files)):t.imgUrlFile&&t._v_src._linkValue.length>0&&(this.showLoading(),n.onRender_imgUrl.call(this,t._v_src._linkValue))}catch(i){throw this.closeLoading(),Error('[SUNEDITOR.image.submit.fail] cause : "'+i.message+'"')}finally{this.plugins.dialog.close.call(this)}return!1},submitAction:function(e){if(e.length===0)return;let t=0,n=[];for(let a=0,r=e.length;a<r;a++)/image/i.test(e[a].type)&&(n.push(e[a]),t+=e[a].size);const i=this.options.imageUploadSizeLimit;if(i>0){let a=0;const r=this.context.image._infoList;for(let f=0,d=r.length;f<d;f++)a+=r[f].size*1;if(t+a>i){this.closeLoading();const f="[SUNEDITOR.imageUpload.fail] Size of uploadable total images: "+i/1e3+"KB";(typeof this.functions.onImageUploadError!="function"||this.functions.onImageUploadError(f,{limitSize:i,currentSize:a,uploadSize:t},this))&&this.functions.noticeOpen(f);return}}const s=this.context.image;s._uploadFileLength=n.length;const l={anchor:this.plugins.anchor.createAnchor.call(this,s.anchorCtx,!0),inputWidth:s.inputX.value,inputHeight:s.inputY.value,align:s._align,isUpdate:this.context.dialog.updateModal,alt:s._altText,element:s._element};if(typeof this.functions.onImageUploadBefore=="function"){const a=this.functions.onImageUploadBefore(n,l,this,(function(r){r&&this._w.Array.isArray(r.result)?this.plugins.image.register.call(this,l,r):this.plugins.image.upload.call(this,l,r)}).bind(this));if(typeof a>"u")return;if(!a){this.closeLoading();return}this._w.Array.isArray(a)&&a.length>0&&(n=a)}this.plugins.image.upload.call(this,l,n)},error:function(e,t){if(this.closeLoading(),typeof this.functions.onImageUploadError!="function"||this.functions.onImageUploadError(e,t,this))throw this.functions.noticeOpen(e),Error("[SUNEDITOR.plugin.image.error] response: "+e)},upload:function(e,t){if(!t){this.closeLoading();return}if(typeof t=="string"){this.plugins.image.error.call(this,t,null);return}const n=this.options.imageUploadUrl,i=this.context.dialog.updateModal?1:t.length;if(typeof n=="string"&&n.length>0){const s=new FormData;for(let o=0;o<i;o++)s.append("file-"+o,t[o]);this.plugins.fileManager.upload.call(this,n,this.options.imageUploadHeader,s,this.plugins.image.callBack_imgUpload.bind(this,e),this.functions.onImageUploadError)}else this.plugins.image.setup_reader.call(this,t,e.anchor,e.inputWidth,e.inputHeight,e.align,e.alt,i,e.isUpdate)},callBack_imgUpload:function(e,t){if(typeof this.functions.imageUploadHandler=="function")this.functions.imageUploadHandler(t,e,this);else{const n=JSON.parse(t.responseText);n.errorMessage?this.plugins.image.error.call(this,n.errorMessage,n):this.plugins.image.register.call(this,e,n)}},register:function(e,t){const n=t.result;for(let i=0,s=n.length,o;i<s;i++)if(o={name:n[i].name,size:n[i].size},e.isUpdate){this.plugins.image.update_src.call(this,n[i].url,e.element,o);break}else this.plugins.image.create_image.call(this,n[i].url,e.anchor,e.inputWidth,e.inputHeight,e.align,o,e.alt);this.closeLoading()},setup_reader:function(e,t,n,i,s,o,l,a){try{if(l===0){this.closeLoading(),console.warn("[SUNEDITOR.image.base64.fail] cause : No applicable files");return}this.context.image.base64RenderIndex=l;const r=this._w.FileReader,f=[l];this.context.image.inputX.value=n,this.context.image.inputY.value=i;for(let d=0,h,v;d<l;d++)h=new r,v=e[d],h.onload=(function(_,C,S,c,u){f[u]={result:_.result,file:c},--this.context.image.base64RenderIndex===0&&(this.plugins.image.onRender_imgBase64.call(this,C,f,S,t,n,i,s,o),this.closeLoading())}).bind(this,h,a,this.context.image._element,v,d),h.readAsDataURL(v)}catch(r){throw this.closeLoading(),Error('[SUNEDITOR.image.setup_reader.fail] cause : "'+r.message+'"')}},onRender_imgBase64:function(e,t,n,i,s,o,l,a){const r=this.plugins.image.update_src,f=this.plugins.image.create_image;for(let d=0,h=t.length;d<h;d++)e?(this.context.image._element.setAttribute("data-file-name",t[d].file.name),this.context.image._element.setAttribute("data-file-size",t[d].file.size),r.call(this,t[d].result,n,t[d].file)):f.call(this,t[d].result,i,s,o,l,t[d].file,a)},onRender_imgUrl:function(e){if(e||(e=this.context.image._v_src._linkValue),!e)return!1;const t=this.context.image;try{const n={name:e.split("/").pop(),size:0};this.context.dialog.updateModal?this.plugins.image.update_src.call(this,e,t._element,n):this.plugins.image.create_image.call(this,e,this.plugins.anchor.createAnchor.call(this,t.anchorCtx,!0),t.inputX.value,t.inputY.value,t._align,n,t._altText)}catch(n){throw Error('[SUNEDITOR.image.URLRendering.fail] cause : "'+n.message+'"')}finally{this.closeLoading()}},onRender_link:function(e,t){return t?(t.setAttribute("data-image-link","image"),e.setAttribute("data-image-link",t.href),t.appendChild(e),t):e},setInputSize:function(e,t){if(t&&t.keyCode===32){t.preventDefault();return}this.plugins.resizing._module_setInputSize.call(this,this.context.image,e)},setRatio:function(){this.plugins.resizing._module_setRatio.call(this,this.context.image)},checkFileInfo:function(){const e=this.plugins.image,t=this.context.image,n=(function(i){e.onModifyMode.call(this,i,null),e.openModify.call(this,!0),t.inputX.value=t._origin_w,t.inputY.value=t._origin_h;const s=this.util.getFormatElement(i);s&&(t._align=s.style.textAlign||s.style.float),this.util.isAnchor(i.parentNode)&&!t.anchorCtx.linkValue&&(t.anchorCtx.linkValue=" "),e.update_image.call(this,!0,!1,!0),e.init.call(this)}).bind(this);this.plugins.fileManager.checkInfo.call(this,"image",["img"],this.functions.onImageUpload,n,!0)},resetFileInfo:function(){this.plugins.fileManager.resetInfo.call(this,"image",this.functions.onImageUpload)},create_image:function(e,t,n,i,s,o,l){const a=this.plugins.image,r=this.context.image;this.context.resizing._resize_plugin="image";let f=this.util.createElement("IMG");f.src=e,f.alt=l,f.setAttribute("data-rotate","0"),t=a.onRender_link.call(this,f,t?t.cloneNode(!1):null),r._resizing&&f.setAttribute("data-proportion",r._proportionChecked);const d=this.plugins.component.set_cover.call(this,t),h=this.plugins.component.set_container.call(this,d,"se-image-container");r._captionChecked&&(r._caption=this.plugins.component.create_caption.call(this),d.appendChild(r._caption)),r._element=f,r._cover=d,r._container=h,a.applySize.call(this,n,i),a.setAlign.call(this,s,f,d,h),f.onload=a._image_create_onload.bind(this,f,r.svgDefaultSize,h),this.insertComponent(h,!0,!0,!this.options.mediaAutoSelect)&&this.plugins.fileManager.setInfo.call(this,"image",f,this.functions.onImageUpload,o,!0),this.context.resizing._resize_plugin=""},_image_create_onload:function(e,t,n){if(e.offsetWidth===0&&this.plugins.image.applySize.call(this,t,""),this.options.mediaAutoSelect)this.selectComponent(e,"image");else{const i=this.appendFormatTag(n,null);i&&this.setRange(i,0,i,0)}this.history.push(!1)},update_image:function(e,t,n){const i=this.context.image;let s=i._element,o=i._cover,l=i._container,a=!1;o===null&&(a=!0,s=i._element.cloneNode(!0),o=this.plugins.component.set_cover.call(this,s)),l===null?(o=o.cloneNode(!0),s=o.querySelector("img"),a=!0,l=this.plugins.component.set_container.call(this,o,"se-image-container")):a&&(l.innerHTML="",l.appendChild(o),i._cover=o,i._element=s,a=!1);let r;const f=this.util.isNumber(i.inputX.value)?i.inputX.value+i.sizeUnit:i.inputX.value,d=this.util.isNumber(i.inputY.value)?i.inputY.value+i.sizeUnit:i.inputY.value;/%$/.test(s.style.width)?r=f!==l.style.width||d!==l.style.height:r=f!==s.style.width||d!==s.style.height,s.alt=i._altText;let h=!1;i._captionChecked?i._caption||(i._caption=this.plugins.component.create_caption.call(this),o.appendChild(i._caption),h=!0):i._caption&&(this.util.removeItem(i._caption),i._caption=null,h=!0);let v=null;const _=this.plugins.anchor.createAnchor.call(this,i.anchorCtx,!0);if(_)i._linkElement!==_||a&&!l.contains(_)?(i._linkElement=_.cloneNode(!1),o.insertBefore(this.plugins.image.onRender_link.call(this,s,i._linkElement),i._caption),v=i._element):i._linkElement.setAttribute("data-image-link","image");else if(i._linkElement!==null){const S=s;if(S.setAttribute("data-image-link",""),o.contains(i._linkElement)){const c=S.cloneNode(!0);o.removeChild(i._linkElement),o.insertBefore(c,i._caption),i._element=s=c}}let C=null;if(a){const S=i._element.parentNode;if(C=this.util.isRangeFormatElement(S)||this.util.isWysiwygDiv(S)?i._element:S||i._element,this.util.getParentElement(i._element,this.util.isNotCheckingNode))C=v?_:i._element,C.parentNode.replaceChild(l,C);else if(this.util.isListCell(C)){const c=this.util.getParentElement(i._element,function(u){return u.parentNode===C});C.insertBefore(l,c),this.util.removeItem(i._element),this.util.removeEmptyNode(c,null,!0)}else if(this.util.isFormatElement(C)){const c=this.util.getParentElement(i._element,function(u){return u.parentNode===C});C=this.util.splitElement(C,c),C.parentNode.insertBefore(l,C),this.util.removeItem(i._element),this.util.removeEmptyNode(C,null,!0),C.children.length===0&&(C.innerHTML=this.util.htmlRemoveWhiteSpace(C.innerHTML))}else if(this.util.isFormatElement(C.parentNode)){const c=C.parentNode;c.parentNode.insertBefore(l,C.previousSibling?c.nextElementSibling:c),i.__updateTags.map(function(u){return C.contains(u)}).length===0&&this.util.removeItem(C)}else C=this.util.isFigures(C.parentNode)?C.parentNode:C,C.parentNode.replaceChild(l,C);s=l.querySelector("img"),i._element=s,i._cover=o,i._container=l}v&&(a?(this.util.removeItem(v),this.util.getListChildren(_,function(S){return/IMG/i.test(S.tagName)}).length===0&&this.util.removeItem(_)):this.util.removeItem(_)),(h||!i._onlyPercentage&&r)&&!e&&(/\d+/.test(s.style.height)||this.context.resizing._rotateVertical&&i._captionChecked)&&(/%$/.test(i.inputX.value)||/%$/.test(i.inputY.value)?this.plugins.resizing.resetTransform.call(this,s):this.plugins.resizing.setTransformSize.call(this,s,this.util.getNumber(i.inputX.value,0),this.util.getNumber(i.inputY.value,0))),i._resizing&&(s.setAttribute("data-proportion",i._proportionChecked),r&&this.plugins.image.applySize.call(this)),this.plugins.image.setAlign.call(this,null,s,null,null),e&&this.plugins.fileManager.setInfo.call(this,"image",s,this.functions.onImageUpload,null,!0),t&&this.selectComponent(s,"image"),n||this.history.push(!1)},update_src:function(e,t,n){t.src=e,this._w.setTimeout(this.plugins.fileManager.setInfo.bind(this,"image",t,this.functions.onImageUpload,n,!0)),this.selectComponent(t,"image")},onModifyMode:function(e,t){if(!e)return;const n=this.context.image;n._linkElement=n.anchorCtx.linkAnchor=this.util.isAnchor(e.parentNode)?e.parentNode:null,n._element=e,n._cover=this.util.getParentElement(e,"FIGURE"),n._container=this.util.getParentElement(e,this.util.isMediaComponent),n._caption=this.util.getChildElement(n._cover,"FIGCAPTION"),n._align=e.getAttribute("data-align")||e.style.float||"none",e.style.float="",this.plugins.anchor.setCtx(n._linkElement,n.anchorCtx),t&&(n._element_w=t.w,n._element_h=t.h,n._element_t=t.t,n._element_l=t.l);let i=n._element.getAttribute("data-size")||n._element.getAttribute("data-origin"),s,o;i?(i=i.split(","),s=i[0],o=i[1]):t&&(s=t.w,o=t.h),n._origin_w=s||e.style.width||e.width||"",n._origin_h=o||e.style.height||e.height||""},openModify:function(e){const t=this.context.image;t.imgUrlFile&&(t._v_src._linkValue=t.previewSrc.textContent=t.imgUrlFile.value=t._element.src),t._altText=t.altText.value=t._element.alt,(t.modal.querySelector('input[name="suneditor_image_radio"][value="'+t._align+'"]')||t.modal.querySelector('input[name="suneditor_image_radio"][value="none"]')).checked=!0,t._align=t.modal.querySelector('input[name="suneditor_image_radio"]:checked').value,t._captionChecked=t.captionCheckEl.checked=!!t._caption,t._resizing&&this.plugins.resizing._module_setModifyInputSize.call(this,t,this.plugins.image),e||this.plugins.dialog.open.call(this,"image",!0)},applySize:function(e,t){const n=this.context.image;return e||(e=n.inputX.value||this.options.imageWidth),t||(t=n.inputY.value||this.options.imageHeight),n._onlyPercentage&&e||/%$/.test(e)?(this.plugins.image.setPercentSize.call(this,e,t),!0):((!e||e==="auto")&&(!t||t==="auto")?this.plugins.image.setAutoSize.call(this):this.plugins.image.setSize.call(this,e,t,!1),!1)},sizeRevert:function(){this.plugins.resizing._module_sizeRevert.call(this,this.context.image)},setSize:function(e,t,n,i){const s=this.context.image,o=/^(rw|lw)$/.test(i)&&/\d+/.test(s._element.style.height);/^(th|bh)$/.test(i)&&/\d+/.test(s._element.style.width)||(s._element.style.width=this.util.isNumber(e)?e+s.sizeUnit:e,this.plugins.image.cancelPercentAttr.call(this)),o||(s._element.style.height=this.util.isNumber(t)?t+s.sizeUnit:/%$/.test(t)?"":t),s._align==="center"&&this.plugins.image.setAlign.call(this,null,null,null,null),n||s._element.removeAttribute("data-percentage"),this.plugins.resizing._module_saveCurrentSize.call(this,s)},setAutoSize:function(){const e=this.context.image;e._caption&&(e._caption.style.marginTop=""),this.plugins.resizing.resetTransform.call(this,e._element),this.plugins.image.cancelPercentAttr.call(this),e._element.style.maxWidth="",e._element.style.width="",e._element.style.height="",e._cover.style.width="",e._cover.style.height="",this.plugins.image.setAlign.call(this,null,null,null,null),e._element.setAttribute("data-percentage","auto,auto"),this.plugins.resizing._module_saveCurrentSize.call(this,e)},setOriginSize:function(){const e=this.context.image;e._element.removeAttribute("data-percentage"),this.plugins.resizing.resetTransform.call(this,e._element),this.plugins.image.cancelPercentAttr.call(this);const t=(e._element.getAttribute("data-origin")||"").split(","),n=t[0],i=t[1];t&&(e._onlyPercentage||/%$/.test(n)&&(/%$/.test(i)||!/\d/.test(i))?this.plugins.image.setPercentSize.call(this,n,i):this.plugins.image.setSize.call(this,n,i),this.plugins.resizing._module_saveCurrentSize.call(this,e))},setPercentSize:function(e,t){const n=this.context.image;t=t&&!/%$/.test(t)&&!this.util.getNumber(t,0)?this.util.isNumber(t)?t+"%":t:this.util.isNumber(t)?t+n.sizeUnit:t||"";const i=/%$/.test(t);n._container.style.width=this.util.isNumber(e)?e+"%":e,n._container.style.height="",n._cover.style.width="100%",n._cover.style.height=i?t:"",n._element.style.width="100%",n._element.style.height=i?"":t,n._element.style.maxWidth="",n._align==="center"&&this.plugins.image.setAlign.call(this,null,null,null,null),n._element.setAttribute("data-percentage",e+","+t),this.plugins.resizing.setCaptionPosition.call(this,n._element),this.plugins.resizing._module_saveCurrentSize.call(this,n)},cancelPercentAttr:function(){const e=this.context.image;e._cover.style.width="",e._cover.style.height="",e._container.style.width="",e._container.style.height="",this.util.removeClass(e._container,this.context.image._floatClassRegExp),this.util.addClass(e._container,"__se__float-"+e._align),e._align==="center"&&this.plugins.image.setAlign.call(this,null,null,null,null)},setAlign:function(e,t,n,i){const s=this.context.image;e||(e=s._align),t||(t=s._element),n||(n=s._cover),i||(i=s._container),/%$/.test(t.style.width)&&e==="center"?(i.style.minWidth="100%",n.style.width=i.style.width):(i.style.minWidth="",n.style.width=this.context.resizing._rotateVertical?t.style.height||t.offsetHeight:!t.style.width||t.style.width==="auto"?"":t.style.width||"100%"),this.util.hasClass(i,"__se__float-"+e)||(this.util.removeClass(i,s._floatClassRegExp),this.util.addClass(i,"__se__float-"+e)),t.setAttribute("data-align",e)},init:function(){const e=this.context.image;e.imgInputFile&&(e.imgInputFile.value=""),e.imgUrlFile&&(e._v_src._linkValue=e.previewSrc.textContent=e.imgUrlFile.value=""),e.imgInputFile&&e.imgUrlFile&&(e.imgUrlFile.removeAttribute("disabled"),e.previewSrc.style.textDecoration=""),e.altText.value="",e.modal.querySelector('input[name="suneditor_image_radio"][value="none"]').checked=!0,e.captionCheckEl.checked=!1,e._element=null,this.plugins.image.openTab.call(this,"init"),e._resizing&&(e.inputX.value=this.options.imageWidth===e._defaultSizeX?"":this.options.imageWidth,e.inputY.value=this.options.imageHeight===e._defaultSizeY?"":this.options.imageHeight,e.proportion.checked=!0,e._ratio=!1,e._ratioX=1,e._ratioY=1),this.plugins.anchor.init.call(this,e.anchorCtx)}},XC={name:"video",display:"dialog",add:function(e){e.addModule([Fi,Xo,fh,Qo]);const t=e.options,n=e.context,i=n.video={_infoList:[],_infoIndex:0,_uploadFileLength:0,focusElement:null,sizeUnit:t._videoSizeUnit,_align:"none",_floatClassRegExp:"__se__float\\-[a-z]+",_youtubeQuery:t.youtubeQuery,_vimeoQuery:t.vimeoQuery,_videoRatio:t.videoRatio*100+"%",_defaultRatio:t.videoRatio*100+"%",_linkValue:"",_element:null,_cover:null,_container:null,inputX:null,inputY:null,_element_w:1,_element_h:1,_element_l:0,_element_t:0,_defaultSizeX:"100%",_defaultSizeY:t.videoRatio*100+"%",_origin_w:t.videoWidth==="100%"?"":t.videoWidth,_origin_h:t.videoHeight==="56.25%"?"":t.videoHeight,_proportionChecked:!0,_resizing:t.videoResizing,_resizeDotHide:!t.videoHeightShow,_rotation:t.videoRotation,_alignHide:!t.videoAlignShow,_onlyPercentage:t.videoSizeOnlyPercentage,_ratio:!1,_ratioX:1,_ratioY:1,_captionShow:!1};let s=this.setDialog(e);i.modal=s,i.videoInputFile=s.querySelector("._se_video_file"),i.videoUrlFile=s.querySelector(".se-input-url"),i.focusElement=i.videoUrlFile||i.videoInputFile,i.preview=s.querySelector(".se-link-preview"),s.querySelector("form").addEventListener("submit",this.submit.bind(e)),i.videoInputFile&&s.querySelector(".se-dialog-files-edge-button").addEventListener("click",this._removeSelectedFiles.bind(i.videoInputFile,i.videoUrlFile,i.preview)),i.videoInputFile&&i.videoUrlFile&&i.videoInputFile.addEventListener("change",this._fileInputChange.bind(i)),i.videoUrlFile&&i.videoUrlFile.addEventListener("input",this._onLinkPreview.bind(i.preview,i,t.linkProtocol)),i.proportion={},i.videoRatioOption={},i.inputX={},i.inputY={},t.videoResizing&&(i.proportion=s.querySelector("._se_video_check_proportion"),i.videoRatioOption=s.querySelector(".se-video-ratio"),i.inputX=s.querySelector("._se_video_size_x"),i.inputY=s.querySelector("._se_video_size_y"),i.inputX.value=t.videoWidth,i.inputY.value=t.videoHeight,i.inputX.addEventListener("keyup",this.setInputSize.bind(e,"x")),i.inputY.addEventListener("keyup",this.setInputSize.bind(e,"y")),i.inputX.addEventListener("change",this.setRatio.bind(e)),i.inputY.addEventListener("change",this.setRatio.bind(e)),i.proportion.addEventListener("change",this.setRatio.bind(e)),i.videoRatioOption.addEventListener("change",this.setVideoRatio.bind(e)),s.querySelector(".se-dialog-btn-revert").addEventListener("click",this.sizeRevert.bind(e))),n.dialog.modal.appendChild(s),s=null},setDialog:function(e){const t=e.options,n=e.lang,i=e.util.createElement("DIV");i.className="se-dialog-content",i.style.display="none";let s='<form method="post" enctype="multipart/form-data"><div class="se-dialog-header"><button type="button" data-command="close" class="se-btn se-dialog-close" title="'+n.dialogBox.close+'" aria-label="'+n.dialogBox.close+'">'+e.icons.cancel+'</button><span class="se-modal-title">'+n.dialogBox.videoBox.title+'</span></div><div class="se-dialog-body">';if(t.videoFileInput&&(s+='<div class="se-dialog-form"><label>'+n.dialogBox.videoBox.file+'</label><div class="se-dialog-form-files"><input class="se-input-form _se_video_file" type="file" accept="'+t.videoAccept+'"'+(t.videoMultipleFile?' multiple="multiple"':"")+'/><button type="button" data-command="filesRemove" class="se-btn se-dialog-files-edge-button se-file-remove" title="'+n.controller.remove+'" aria-label="'+n.controller.remove+'">'+e.icons.cancel+"</button></div></div>"),t.videoUrlInput&&(s+='<div class="se-dialog-form"><label>'+n.dialogBox.videoBox.url+'</label><input class="se-input-form se-input-url" type="text" /><pre class="se-link-preview"></pre></div>'),t.videoResizing){const o=t.videoRatioList||[{name:"16:9",value:.5625},{name:"4:3",value:.75},{name:"21:9",value:.4285}],l=t.videoRatio,a=t.videoSizeOnlyPercentage,r=a?' style="display: none !important;"':"",f=t.videoHeightShow?"":' style="display: none !important;"',d=t.videoRatioShow?"":' style="display: none !important;"',h=!a&&!t.videoHeightShow&&!t.videoRatioShow?' style="display: none !important;"':"";s+='<div class="se-dialog-form"><div class="se-dialog-size-text"><label class="size-w">'+n.dialogBox.width+'</label><label class="se-dialog-size-x">&nbsp;</label><label class="size-h"'+f+">"+n.dialogBox.height+'</label><label class="size-h"'+d+">("+n.dialogBox.ratio+')</label></div><input class="se-input-control _se_video_size_x" placeholder="100%"'+(a?' type="number" min="1"':'type="text"')+(a?' max="100"':"")+'/><label class="se-dialog-size-x"'+h+">"+(a?"%":"x")+'</label><input class="se-input-control _se_video_size_y" placeholder="'+t.videoRatio*100+'%"'+(a?' type="number" min="1"':'type="text"')+(a?' max="100"':"")+f+'/><select class="se-input-select se-video-ratio" title="'+n.dialogBox.ratio+'" aria-label="'+n.dialogBox.ratio+'"'+d+">",f||(s+='<option value=""> - </option>');for(let v=0,_=o.length;v<_;v++)s+='<option value="'+o[v].value+'"'+(l.toString()===o[v].value.toString()?" selected":"")+">"+o[v].name+"</option>";s+='</select><button type="button" title="'+n.dialogBox.revertButton+'" aria-label="'+n.dialogBox.revertButton+'" class="se-btn se-dialog-btn-revert" style="float: right;">'+e.icons.revert+'</button></div><div class="se-dialog-form se-dialog-form-footer"'+r+h+'><label><input type="checkbox" class="se-dialog-btn-check _se_video_check_proportion" checked/>&nbsp;'+n.dialogBox.proportion+"</label></div>"}return s+='</div><div class="se-dialog-footer"><div'+(t.videoAlignShow?"":' style="display: none"')+'><label><input type="radio" name="suneditor_video_radio" class="se-dialog-btn-radio" value="none" checked>'+n.dialogBox.basic+'</label><label><input type="radio" name="suneditor_video_radio" class="se-dialog-btn-radio" value="left">'+n.dialogBox.left+'</label><label><input type="radio" name="suneditor_video_radio" class="se-dialog-btn-radio" value="center">'+n.dialogBox.center+'</label><label><input type="radio" name="suneditor_video_radio" class="se-dialog-btn-radio" value="right">'+n.dialogBox.right+'</label></div><button type="submit" class="se-btn-primary" title="'+n.dialogBox.submitButton+'" aria-label="'+n.dialogBox.submitButton+'"><span>'+n.dialogBox.submitButton+"</span></button></div></form>",i.innerHTML=s,i},_fileInputChange:function(){this.videoInputFile.value?(this.videoUrlFile.setAttribute("disabled",!0),this.preview.style.textDecoration="line-through"):(this.videoUrlFile.removeAttribute("disabled"),this.preview.style.textDecoration="")},_removeSelectedFiles:function(e,t){this.value="",e&&(e.removeAttribute("disabled"),t.style.textDecoration="")},_onLinkPreview:function(e,t,n){const i=n.target.value.trim();/^<iframe.*\/iframe>$/.test(i)?(e._linkValue=i,this.textContent='<IFrame :src=".."></IFrame>'):e._linkValue=this.textContent=i?t&&i.indexOf("://")===-1&&i.indexOf("#")!==0?t+i:i.indexOf("://")===-1?"/"+i:i:""},_setTagAttrs:function(e){e.setAttribute("controls",!0);const t=this.options.videoTagAttrs;if(t)for(let n in t)this.util.hasOwn(t,n)&&e.setAttribute(n,t[n])},createVideoTag:function(){const e=this.util.createElement("VIDEO");return this.plugins.video._setTagAttrs.call(this,e),e},_setIframeAttrs:function(e){e.frameBorder="0",e.allowFullscreen=!0;const t=this.options.videoIframeAttrs;if(t)for(let n in t)this.util.hasOwn(t,n)&&e.setAttribute(n,t[n])},createIframeTag:function(){const e=this.util.createElement("IFRAME");return this.plugins.video._setIframeAttrs.call(this,e),e},fileTags:["iframe","video"],select:function(e){this.plugins.video.onModifyMode.call(this,e,this.plugins.resizing.call_controller_resize.call(this,e,"video"))},destroy:function(e){const t=e||this.context.video._element,n=this.context.video._container,i=t.getAttribute("data-index")*1;if(typeof this.functions.onVideoDeleteBefore=="function"&&this.functions.onVideoDeleteBefore(t,n,i,this)===!1)return;let s=n.previousElementSibling||n.nextElementSibling;const o=n.parentNode;this.util.removeItem(n),this.plugins.video.init.call(this),this.controllersOff(),o!==this.context.element.wysiwyg&&this.util.removeItemAllParents(o,function(l){return l.childNodes.length===0},null),this.focusEdge(s),this.plugins.fileManager.deleteInfo.call(this,"video",i,this.functions.onVideoUpload),this.history.push(!1)},on:function(e){const t=this.context.video;e?t.videoInputFile&&this.options.videoMultipleFile&&t.videoInputFile.removeAttribute("multiple"):(t.inputX.value=t._origin_w=this.options.videoWidth===t._defaultSizeX?"":this.options.videoWidth,t.inputY.value=t._origin_h=this.options.videoHeight===t._defaultSizeY?"":this.options.videoHeight,t.proportion.disabled=!0,t.videoInputFile&&this.options.videoMultipleFile&&t.videoInputFile.setAttribute("multiple","multiple")),t._resizing&&this.plugins.video.setVideoRatioSelect.call(this,t._origin_h||t._defaultRatio)},open:function(){this.plugins.dialog.open.call(this,"video",this.currentControllerName==="video")},setVideoRatio:function(e){const t=this.context.video,n=e.target.options[e.target.selectedIndex].value;t._defaultSizeY=t._videoRatio=n?n*100+"%":t._defaultSizeY,t.inputY.placeholder=n?n*100+"%":"",t.inputY.value=""},setInputSize:function(e,t){if(t&&t.keyCode===32){t.preventDefault();return}const n=this.context.video;this.plugins.resizing._module_setInputSize.call(this,n,e),e==="y"&&this.plugins.video.setVideoRatioSelect.call(this,t.target.value||n._defaultRatio)},setRatio:function(){this.plugins.resizing._module_setRatio.call(this,this.context.video)},submit:function(e){const t=this.context.video,n=this.plugins.video;e.preventDefault(),e.stopPropagation(),t._align=t.modal.querySelector('input[name="suneditor_video_radio"]:checked').value;try{t.videoInputFile&&t.videoInputFile.files.length>0?(this.showLoading(),n.submitAction.call(this,this.context.video.videoInputFile.files)):t.videoUrlFile&&t._linkValue.length>0&&(this.showLoading(),n.setup_url.call(this,t._linkValue))}catch(i){throw this.closeLoading(),Error('[SUNEDITOR.video.submit.fail] cause : "'+i.message+'"')}finally{this.plugins.dialog.close.call(this)}return!1},submitAction:function(e){if(e.length===0)return;let t=0,n=[];for(let l=0,a=e.length;l<a;l++)/video/i.test(e[l].type)&&(n.push(e[l]),t+=e[l].size);const i=this.options.videoUploadSizeLimit;if(i>0){let l=0;const a=this.context.video._infoList;for(let r=0,f=a.length;r<f;r++)l+=a[r].size*1;if(t+l>i){this.closeLoading();const r="[SUNEDITOR.videoUpload.fail] Size of uploadable total videos: "+i/1e3+"KB";(typeof this.functions.onVideoUploadError!="function"||this.functions.onVideoUploadError(r,{limitSize:i,currentSize:l,uploadSize:t},this))&&this.functions.noticeOpen(r);return}}const s=this.context.video;s._uploadFileLength=n.length;const o={inputWidth:s.inputX.value,inputHeight:s.inputY.value,align:s._align,isUpdate:this.context.dialog.updateModal,element:s._element};if(typeof this.functions.onVideoUploadBefore=="function"){const l=this.functions.onVideoUploadBefore(n,o,this,(function(a){a&&this._w.Array.isArray(a.result)?this.plugins.video.register.call(this,o,a):this.plugins.video.upload.call(this,o,a)}).bind(this));if(typeof l>"u")return;if(!l){this.closeLoading();return}typeof l=="object"&&l.length>0&&(n=l)}this.plugins.video.upload.call(this,o,n)},error:function(e,t){if(this.closeLoading(),typeof this.functions.onVideoUploadError!="function"||this.functions.onVideoUploadError(e,t,this))throw this.functions.noticeOpen(e),Error("[SUNEDITOR.plugin.video.error] response: "+e)},upload:function(e,t){if(!t){this.closeLoading();return}if(typeof t=="string"){this.plugins.video.error.call(this,t,null);return}const n=this.options.videoUploadUrl,i=this.context.dialog.updateModal?1:t.length;if(typeof n=="string"&&n.length>0){const s=new FormData;for(let o=0;o<i;o++)s.append("file-"+o,t[o]);this.plugins.fileManager.upload.call(this,n,this.options.videoUploadHeader,s,this.plugins.video.callBack_videoUpload.bind(this,e),this.functions.onVideoUploadError)}else throw Error('[SUNEDITOR.videoUpload.fail] cause : There is no "videoUploadUrl" option.')},callBack_videoUpload:function(e,t){if(typeof this.functions.videoUploadHandler=="function")this.functions.videoUploadHandler(t,e,this);else{const n=JSON.parse(t.responseText);n.errorMessage?this.plugins.video.error.call(this,n.errorMessage,n):this.plugins.video.register.call(this,e,n)}},register:function(e,t){const n=t.result,i=this.plugins.video.createVideoTag.call(this);for(let s=0,o=n.length,l;s<o;s++)l={name:n[s].name,size:n[s].size},this.plugins.video.create_video.call(this,e.isUpdate?e.element:i.cloneNode(!1),n[s].url,e.inputWidth,e.inputHeight,e.align,l,e.isUpdate);this.closeLoading()},setup_url:function(e){try{const t=this.context.video;if(e||(e=t._linkValue),!e||/^<iframe.*\/iframe>$/.test(e)&&(e=new this._w.DOMParser().parseFromString(e,"text/html").querySelector("iframe").src,e.length===0))return!1;if(/youtu\.?be/.test(e)){if(/^http/.test(e)||(e="https://"+e),e=e.replace("watch?v=",""),/^\/\/.+\/embed\//.test(e)||(e=e.replace(e.match(/\/\/.+\//)[0],"//www.youtube.com/embed/").replace("&","?&")),t._youtubeQuery.length>0)if(/\?/.test(e)){const n=e.split("?");e=n[0]+"?"+t._youtubeQuery+"&"+n[1]}else e+="?"+t._youtubeQuery}else if(/vimeo\.com/.test(e)&&(e.endsWith("/")&&(e=e.slice(0,-1)),e="https://player.vimeo.com/video/"+e.slice(e.lastIndexOf("/")+1),t._vimeoQuery.length>0))if(/\?/.test(e)){const n=e.split("?");e=n[0]+"?"+t._vimeoQuery+"&"+n[1]}else e+="?"+t._vimeoQuery;this.plugins.video.create_video.call(this,this.plugins.video[!/embed|iframe|player|\/e\/|\.php|\.html?/.test(e)&&!/vimeo\.com/.test(e)?"createVideoTag":"createIframeTag"].call(this),e,t.inputX.value,t.inputY.value,t._align,null,this.context.dialog.updateModal)}catch(t){throw Error('[SUNEDITOR.video.upload.fail] cause : "'+t.message+'"')}finally{this.closeLoading()}},create_video:function(e,t,n,i,s,o,l){this.context.resizing._resize_plugin="video";const a=this.context.video;let r=null,f=null,d=!1;if(l){if(e=a._element,e.src!==t){d=!0;const S=/youtu\.?be/.test(t),c=/vimeo\.com/.test(t);if((S||c)&&!/^iframe$/i.test(e.nodeName)){const u=this.plugins.video.createIframeTag.call(this);u.src=t,e.parentNode.replaceChild(u,e),a._element=e=u}else if(!S&&!c&&!/^video$/i.test(e.nodeName)){const u=this.plugins.video.createVideoTag.call(this);u.src=t,e.parentNode.replaceChild(u,e),a._element=e=u}else e.src=t}f=a._container,r=this.util.getParentElement(e,"FIGURE")}else d=!0,e.src=t,a._element=e,r=this.plugins.component.set_cover.call(this,e),f=this.plugins.component.set_container.call(this,r,"se-video-container");a._cover=r,a._container=f;const h=this.plugins.resizing._module_getSizeX.call(this,a)!==(n||a._defaultSizeX)||this.plugins.resizing._module_getSizeY.call(this,a)!==(i||a._videoRatio),v=!l||h;a._resizing&&(this.context.video._proportionChecked=a.proportion.checked,e.setAttribute("data-proportion",a._proportionChecked));let _=!1;v&&(_=this.plugins.video.applySize.call(this)),_&&s==="center"||this.plugins.video.setAlign.call(this,null,e,r,f);let C=!0;if(l)a._resizing&&this.context.resizing._rotateVertical&&v&&this.plugins.resizing.setTransformSize.call(this,e,null,null);else if(C=this.insertComponent(f,!1,!0,!this.options.mediaAutoSelect),!this.options.mediaAutoSelect){const S=this.appendFormatTag(f,null);S&&this.setRange(S,0,S,0)}C&&(d&&this.plugins.fileManager.setInfo.call(this,"video",e,this.functions.onVideoUpload,o,!0),l&&(this.selectComponent(e,"video"),this.history.push(!1))),this.context.resizing._resize_plugin=""},_update_videoCover:function(e){if(!e)return;const t=this.context.video;/^video$/i.test(e.nodeName)?this.plugins.video._setTagAttrs.call(this,e):this.plugins.video._setIframeAttrs.call(this,e);const n=e.parentNode;let i=this.util.isRangeFormatElement(n)||this.util.isWysiwygDiv(n)?e:n||e;const s=e;t._element=e=e.cloneNode(!0);const o=t._cover=this.plugins.component.set_cover.call(this,e),l=t._container=this.plugins.component.set_container.call(this,o,"se-video-container");try{const a=i.querySelector("figcaption");let r=null;a&&(r=this.util.createElement("DIV"),r.innerHTML=a.innerHTML,this.util.removeItem(a));const f=(e.getAttribute("data-size")||e.getAttribute("data-origin")||"").split(",");this.plugins.video.applySize.call(this,f[0]||s.style.width||s.width||"",f[1]||s.style.height||s.height||"");const d=this.util.getFormatElement(s);if(d&&(t._align=d.style.textAlign||d.style.float),this.plugins.video.setAlign.call(this,null,e,o,l),this.util.getParentElement(s,this.util.isNotCheckingNode))s.parentNode.replaceChild(l,s);else if(this.util.isListCell(i)){const h=this.util.getParentElement(s,function(v){return v.parentNode===i});i.insertBefore(l,h),this.util.removeItem(s),this.util.removeEmptyNode(h,null,!0)}else if(this.util.isFormatElement(i)){const h=this.util.getParentElement(s,function(v){return v.parentNode===i});i=this.util.splitElement(i,h),i.parentNode.insertBefore(l,i),this.util.removeItem(s),this.util.removeEmptyNode(i,null,!0),i.children.length===0&&(i.innerHTML=this.util.htmlRemoveWhiteSpace(i.innerHTML))}else i.parentNode.replaceChild(l,i);r&&i.parentNode.insertBefore(r,l.nextElementSibling)}catch(a){console.warn("[SUNEDITOR.video.error] Maybe the video tag is nested.",a)}this.plugins.fileManager.setInfo.call(this,"video",e,this.functions.onVideoUpload,null,!0),this.plugins.video.init.call(this)},onModifyMode:function(e,t){const n=this.context.video;n._element=e,n._cover=this.util.getParentElement(e,"FIGURE"),n._container=this.util.getParentElement(e,this.util.isMediaComponent),n._align=e.style.float||e.getAttribute("data-align")||"none",e.style.float="",t&&(n._element_w=t.w,n._element_h=t.h,n._element_t=t.t,n._element_l=t.l);let i=n._element.getAttribute("data-size")||n._element.getAttribute("data-origin"),s,o;i?(i=i.split(","),s=i[0],o=i[1]):t&&(s=t.w,o=t.h),n._origin_w=s||e.style.width||e.width||"",n._origin_h=o||e.style.height||e.height||""},openModify:function(e){const t=this.context.video;if(t.videoUrlFile&&(t._linkValue=t.preview.textContent=t.videoUrlFile.value=t._element.src||(t._element.querySelector("source")||"").src||""),(t.modal.querySelector('input[name="suneditor_video_radio"][value="'+t._align+'"]')||t.modal.querySelector('input[name="suneditor_video_radio"][value="none"]')).checked=!0,t._resizing){this.plugins.resizing._module_setModifyInputSize.call(this,t,this.plugins.video);const n=t._videoRatio=this.plugins.resizing._module_getSizeY.call(this,t);this.plugins.video.setVideoRatioSelect.call(this,n)||(t.inputY.value=t._onlyPercentage?this.util.getNumber(n,2):n)}e||this.plugins.dialog.open.call(this,"video",!0)},setVideoRatioSelect:function(e){let t=!1;const n=this.context.video,i=n.videoRatioOption.options;/%$/.test(e)||n._onlyPercentage?e=this.util.getNumber(e,2)/100+"":(!this.util.isNumber(e)||e*1>=1)&&(e=""),n.inputY.placeholder="";for(let s=0,o=i.length;s<o;s++)i[s].value===e?(t=i[s].selected=!0,n.inputY.placeholder=e?e*100+"%":""):i[s].selected=!1;return t},checkFileInfo:function(){this.plugins.fileManager.checkInfo.call(this,"video",["iframe","video"],this.functions.onVideoUpload,this.plugins.video._update_videoCover.bind(this),!0)},resetFileInfo:function(){this.plugins.fileManager.resetInfo.call(this,"video",this.functions.onVideoUpload)},applySize:function(e,t){const n=this.context.video;return e||(e=n.inputX.value||this.options.videoWidth),t||(t=n.inputY.value||this.options.videoHeight),n._onlyPercentage||/%$/.test(e)||!e?(this.plugins.video.setPercentSize.call(this,e||"100%",t||(/%$/.test(n._videoRatio)?n._videoRatio:n._defaultRatio)),!0):((!e||e==="auto")&&(!t||t==="auto")?this.plugins.video.setAutoSize.call(this):this.plugins.video.setSize.call(this,e,t||n._videoRatio||n._defaultRatio,!1),!1)},sizeRevert:function(){this.plugins.resizing._module_sizeRevert.call(this,this.context.video)},setSize:function(e,t,n,i){const s=this.context.video,o=/^(rw|lw)$/.test(i),l=/^(th|bh)$/.test(i);l||(e=this.util.getNumber(e,0)),o||(t=this.util.isNumber(t)?t+s.sizeUnit:t||""),e=e?e+s.sizeUnit:"",l||(s._element.style.width=e),o||(s._cover.style.paddingBottom=s._cover.style.height=t),!l&&!/%$/.test(e)&&(s._cover.style.width=e,s._container.style.width=""),!o&&!/%$/.test(t)?s._element.style.height=t:s._element.style.height="",n||s._element.removeAttribute("data-percentage"),this.plugins.resizing._module_saveCurrentSize.call(this,s)},setAutoSize:function(){this.plugins.video.setPercentSize.call(this,100,this.context.video._defaultRatio)},setOriginSize:function(e){const t=this.context.video;t._element.removeAttribute("data-percentage"),this.plugins.resizing.resetTransform.call(this,t._element),this.plugins.video.cancelPercentAttr.call(this);const n=((e?t._element.getAttribute("data-size"):"")||t._element.getAttribute("data-origin")||"").split(",");if(n){const i=n[0],s=n[1];t._onlyPercentage||/%$/.test(i)&&(/%$/.test(s)||!/\d/.test(s))?this.plugins.video.setPercentSize.call(this,i,s):this.plugins.video.setSize.call(this,i,s),this.plugins.resizing._module_saveCurrentSize.call(this,t)}},setPercentSize:function(e,t){const n=this.context.video;t=t&&!/%$/.test(t)&&!this.util.getNumber(t,0)?this.util.isNumber(t)?t+"%":t:this.util.isNumber(t)?t+n.sizeUnit:t||n._defaultRatio,n._container.style.width=this.util.isNumber(e)?e+"%":e,n._container.style.height="",n._cover.style.width="100%",n._cover.style.height=t,n._cover.style.paddingBottom=t,n._element.style.width="100%",n._element.style.height="100%",n._element.style.maxWidth="",n._align==="center"&&this.plugins.video.setAlign.call(this,null,null,null,null),n._element.setAttribute("data-percentage",e+","+t),this.plugins.resizing._module_saveCurrentSize.call(this,n)},cancelPercentAttr:function(){const e=this.context.video;e._cover.style.width="",e._cover.style.height="",e._cover.style.paddingBottom="",e._container.style.width="",e._container.style.height="",this.util.removeClass(e._container,this.context.video._floatClassRegExp),this.util.addClass(e._container,"__se__float-"+e._align),e._align==="center"&&this.plugins.video.setAlign.call(this,null,null,null,null)},setAlign:function(e,t,n,i){const s=this.context.video;e||(e=s._align),t||(t=s._element),n||(n=s._cover),i||(i=s._container),/%$/.test(t.style.width)&&e==="center"?(i.style.minWidth="100%",n.style.width=i.style.width,n.style.height=n.style.height,n.style.paddingBottom=/%$/.test(n.style.height)?this.util.getNumber(this.util.getNumber(n.style.height,2)/100*this.util.getNumber(n.style.width,2),2)+"%":n.style.height):(i.style.minWidth="",n.style.width=this.context.resizing._rotateVertical?t.style.height||t.offsetHeight:t.style.width||"100%",n.style.paddingBottom=n.style.height),this.util.hasClass(i,"__se__float-"+e)||(this.util.removeClass(i,s._floatClassRegExp),this.util.addClass(i,"__se__float-"+e)),t.setAttribute("data-align",e)},init:function(){const e=this.context.video;e.videoInputFile&&(e.videoInputFile.value=""),e.videoUrlFile&&(e._linkValue=e.preview.textContent=e.videoUrlFile.value=""),e.videoInputFile&&e.videoUrlFile&&(e.videoUrlFile.removeAttribute("disabled"),e.preview.style.textDecoration=""),e._origin_w=this.options.videoWidth,e._origin_h=this.options.videoHeight,e.modal.querySelector('input[name="suneditor_video_radio"][value="none"]').checked=!0,e._resizing&&(e.inputX.value=this.options.videoWidth===e._defaultSizeX?"":this.options.videoWidth,e.inputY.value=this.options.videoHeight===e._defaultSizeY?"":this.options.videoHeight,e.proportion.checked=!0,e.proportion.disabled=!0,this.plugins.video.setVideoRatioSelect.call(this,e._defaultRatio))}},QC={name:"audio",display:"dialog",add:function(e){e.addModule([Fi,Xo,Qo]);const t=e.context,n=t.audio={_infoList:[],_infoIndex:0,_uploadFileLength:0,focusElement:null,targetSelect:null,_origin_w:e.options.audioWidth,_origin_h:e.options.audioHeight,_linkValue:"",_element:null,_cover:null,_container:null};let i=this.setDialog(e);n.modal=i,n.audioInputFile=i.querySelector("._se_audio_files"),n.audioUrlFile=i.querySelector(".se-input-url"),n.focusElement=n.audioInputFile||n.audioUrlFile,n.preview=i.querySelector(".se-link-preview");let s=this.setController(e);n.controller=s,i.querySelector("form").addEventListener("submit",this.submit.bind(e)),n.audioInputFile&&i.querySelector(".se-dialog-files-edge-button").addEventListener("click",this._removeSelectedFiles.bind(n.audioInputFile,n.audioUrlFile,n.preview)),n.audioInputFile&&n.audioUrlFile&&n.audioInputFile.addEventListener("change",this._fileInputChange.bind(n)),s.addEventListener("click",this.onClick_controller.bind(e)),n.audioUrlFile&&n.audioUrlFile.addEventListener("input",this._onLinkPreview.bind(n.preview,n,e.options.linkProtocol)),t.dialog.modal.appendChild(i),t.element.relative.appendChild(s),i=null,s=null},setDialog:function(e){const t=e.options,n=e.lang,i=e.util.createElement("DIV");i.className="se-dialog-content",i.style.display="none";let s='<form method="post" enctype="multipart/form-data"><div class="se-dialog-header"><button type="button" data-command="close" class="se-btn se-dialog-close" title="'+n.dialogBox.close+'" aria-label="'+n.dialogBox.close+'">'+e.icons.cancel+'</button><span class="se-modal-title">'+n.dialogBox.audioBox.title+'</span></div><div class="se-dialog-body">';return t.audioFileInput&&(s+='<div class="se-dialog-form"><label>'+n.dialogBox.audioBox.file+'</label><div class="se-dialog-form-files"><input class="se-input-form _se_audio_files" type="file" accept="'+t.audioAccept+'"'+(t.audioMultipleFile?' multiple="multiple"':"")+'/><button type="button" data-command="filesRemove" class="se-btn se-dialog-files-edge-button se-file-remove" title="'+n.controller.remove+'" aria-label="'+n.controller.remove+'">'+e.icons.cancel+"</button></div></div>"),t.audioUrlInput&&(s+='<div class="se-dialog-form"><label>'+n.dialogBox.audioBox.url+'</label><input class="se-input-form se-input-url" type="text" /><pre class="se-link-preview"></pre></div>'),s+='</div><div class="se-dialog-footer"><button type="submit" class="se-btn-primary" title="'+n.dialogBox.submitButton+'" aria-label="'+n.dialogBox.submitButton+'"><span>'+n.dialogBox.submitButton+"</span></button></div></form>",i.innerHTML=s,i},setController:function(e){const t=e.lang,n=e.icons,i=e.util.createElement("DIV");return i.className="se-controller se-controller-link",i.innerHTML='<div class="se-arrow se-arrow-up"></div><div class="link-content"><div class="se-btn-group"><button type="button" data-command="update" tabindex="-1" class="se-tooltip">'+n.edit+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+t.controller.edit+'</span></span></button><button type="button" data-command="delete" tabindex="-1" class="se-tooltip">'+n.delete+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+t.controller.remove+"</span></span></button></div></div>",i},_fileInputChange:function(){this.audioInputFile.value?(this.audioUrlFile.setAttribute("disabled",!0),this.preview.style.textDecoration="line-through"):(this.audioUrlFile.removeAttribute("disabled"),this.preview.style.textDecoration="")},_removeSelectedFiles:function(e,t){this.value="",e&&(e.removeAttribute("disabled"),t.style.textDecoration="")},_createAudioTag:function(){const e=this.util.createElement("AUDIO");this.plugins.audio._setTagAttrs.call(this,e);const t=this.context.audio._origin_w,n=this.context.audio._origin_h;return e.setAttribute("origin-size",t+","+n),e.style.cssText=(t?"width:"+t+"; ":"")+(n?"height:"+n+";":""),e},_setTagAttrs:function(e){e.setAttribute("controls",!0);const t=this.options.audioTagAttrs;if(t)for(let n in t)this.util.hasOwn(t,n)&&e.setAttribute(n,t[n])},_onLinkPreview:function(e,t,n){const i=n.target.value.trim();e._linkValue=this.textContent=i?t&&i.indexOf("://")===-1&&i.indexOf("#")!==0?t+i:i.indexOf("://")===-1?"/"+i:i:""},fileTags:["audio"],select:function(e){this.plugins.audio.onModifyMode.call(this,e)},destroy:function(e){e=e||this.context.audio._element;const t=this.util.getParentElement(e,this.util.isComponent)||e,n=e.getAttribute("data-index")*1;if(typeof this.functions.onAudioDeleteBefore=="function"&&this.functions.onAudioDeleteBefore(e,t,n,this)===!1)return;const i=t.previousElementSibling||t.nextElementSibling,s=t.parentNode;this.util.removeItem(t),this.plugins.audio.init.call(this),this.controllersOff(),s!==this.context.element.wysiwyg&&this.util.removeItemAllParents(s,function(o){return o.childNodes.length===0},null),this.focusEdge(i),this.plugins.fileManager.deleteInfo.call(this,"audio",n,this.functions.onAudioUpload),this.history.push(!1)},checkFileInfo:function(){this.plugins.fileManager.checkInfo.call(this,"audio",["audio"],this.functions.onAudioUpload,this.plugins.audio.updateCover.bind(this),!1)},resetFileInfo:function(){this.plugins.fileManager.resetInfo.call(this,"audio",this.functions.onAudioUpload)},on:function(e){const t=this.context.audio;e?t._element?(this.context.dialog.updateModal=!0,t._linkValue=t.preview.textContent=t.audioUrlFile.value=t._element.src,t.audioInputFile&&this.options.audioMultipleFile&&t.audioInputFile.removeAttribute("multiple")):t.audioInputFile&&this.options.audioMultipleFile&&t.audioInputFile.removeAttribute("multiple"):(this.plugins.audio.init.call(this),t.audioInputFile&&this.options.audioMultipleFile&&t.audioInputFile.setAttribute("multiple","multiple"))},open:function(){this.plugins.dialog.open.call(this,"audio",this.currentControllerName==="audio")},submit:function(e){const t=this.context.audio;e.preventDefault(),e.stopPropagation();try{t.audioInputFile&&t.audioInputFile.files.length>0?(this.showLoading(),this.plugins.audio.submitAction.call(this,t.audioInputFile.files)):t.audioUrlFile&&t._linkValue.length>0&&(this.showLoading(),this.plugins.audio.setupUrl.call(this,t._linkValue))}catch(n){throw this.closeLoading(),Error('[SUNEDITOR.audio.submit.fail] cause : "'+n.message+'"')}finally{this.plugins.dialog.close.call(this)}return!1},submitAction:function(e){if(e.length===0)return;let t=0,n=[];for(let l=0,a=e.length;l<a;l++)/audio/i.test(e[l].type)&&(n.push(e[l]),t+=e[l].size);const i=this.options.audioUploadSizeLimit;if(i>0){let l=0;const a=this.context.audio._infoList;for(let r=0,f=a.length;r<f;r++)l+=a[r].size*1;if(t+l>i){this.closeLoading();const r="[SUNEDITOR.audioUpload.fail] Size of uploadable total audios: "+i/1e3+"KB";(typeof this.functions.onAudioUploadError!="function"||this.functions.onAudioUploadError(r,{limitSize:i,currentSize:l,uploadSize:t},this))&&this.functions.noticeOpen(r);return}}const s=this.context.audio;s._uploadFileLength=n.length;const o={isUpdate:this.context.dialog.updateModal,element:s._element};if(typeof this.functions.onAudioUploadBefore=="function"){const l=this.functions.onAudioUploadBefore(n,o,this,(function(a){a&&this._w.Array.isArray(a.result)?this.plugins.audio.register.call(this,o,a):this.plugins.audio.upload.call(this,o,a)}).bind(this));if(typeof l>"u")return;if(!l){this.closeLoading();return}typeof l=="object"&&l.length>0&&(n=l)}this.plugins.audio.upload.call(this,o,n)},error:function(e,t){if(this.closeLoading(),typeof this.functions.onAudioUploadError!="function"||this.functions.onAudioUploadError(e,t,this))throw this.functions.noticeOpen(e),Error("[SUNEDITOR.plugin.audio.exception] response: "+e)},upload:function(e,t){if(!t){this.closeLoading();return}if(typeof t=="string"){this.plugins.audio.error.call(this,t,null);return}const n=this.options.audioUploadUrl,i=this.context.dialog.updateModal?1:t.length,s=new FormData;for(let o=0;o<i;o++)s.append("file-"+o,t[o]);this.plugins.fileManager.upload.call(this,n,this.options.audioUploadHeader,s,this.plugins.audio.callBack_upload.bind(this,e),this.functions.onAudioUploadError)},callBack_upload:function(e,t){if(typeof this.functions.audioUploadHandler=="function")this.functions.audioUploadHandler(t,e,this);else{const n=JSON.parse(t.responseText);n.errorMessage?this.plugins.audio.error.call(this,n.errorMessage,n):this.plugins.audio.register.call(this,e,n)}},register:function(e,t){const n=t.result;for(let i=0,s=n.length,o,l;i<s;i++)e.isUpdate?l=e.element:l=this.plugins.audio._createAudioTag.call(this),o={name:n[i].name,size:n[i].size},this.plugins.audio.create_audio.call(this,l,n[i].url,o,e.isUpdate);this.closeLoading()},setupUrl:function(e){try{if(e.length===0)return!1;this.plugins.audio.create_audio.call(this,this.plugins.audio._createAudioTag.call(this),e,null,this.context.dialog.updateModal)}catch(t){throw Error('[SUNEDITOR.audio.audio.fail] cause : "'+t.message+'"')}finally{this.closeLoading()}},create_audio:function(e,t,n,i){const s=this.context.audio;if(i)if(s._element&&(e=s._element),e&&e.src!==t)e.src=t,this.selectComponent(e,"audio");else{this.selectComponent(e,"audio");return}else{e.src=t;const o=this.plugins.component.set_cover.call(this,e),l=this.plugins.component.set_container.call(this,o,"");if(!this.insertComponent(l,!1,!0,!this.options.mediaAutoSelect)){this.focus();return}if(!this.options.mediaAutoSelect){const a=this.appendFormatTag(l,null);a&&this.setRange(a,0,a,0)}}this.plugins.fileManager.setInfo.call(this,"audio",e,this.functions.onAudioUpload,n,!1),i&&this.history.push(!1)},updateCover:function(e){const t=this.context.audio;this.plugins.audio._setTagAttrs.call(this,e);const n=e.parentNode;let i=this.util.isRangeFormatElement(n)||this.util.isWysiwygDiv(n)?e:n||e;const s=e;t._element=e=e.cloneNode(!1);const o=this.plugins.component.set_cover.call(this,e),l=this.plugins.component.set_container.call(this,o,"se-audio-container");try{if(this.util.getParentElement(s,this.util.isNotCheckingNode))s.parentNode.replaceChild(l,s);else if(this.util.isListCell(i)){const a=this.util.getParentElement(s,function(r){return r.parentNode===i});i.insertBefore(l,a),this.util.removeItem(s),this.util.removeEmptyNode(a,null,!0)}else if(this.util.isFormatElement(i)){const a=this.util.getParentElement(s,function(r){return r.parentNode===i});i=this.util.splitElement(i,a),i.parentNode.insertBefore(l,i),this.util.removeItem(s),this.util.removeEmptyNode(i,null,!0),i.children.length===0&&(i.innerHTML=this.util.htmlRemoveWhiteSpace(i.innerHTML))}else i.parentNode.replaceChild(l,i)}catch(a){console.warn("[SUNEDITOR.audio.error] Maybe the audio tag is nested.",a)}this.plugins.fileManager.setInfo.call(this,"audio",e,this.functions.onAudioUpload,null,!1),this.plugins.audio.init.call(this)},onModifyMode:function(e){const t=this.context.audio;this.setControllerPosition(t.controller,e,"bottom",{left:0,top:0}),this.controllersOn(t.controller,e,this.plugins.audio.onControllerOff.bind(this,e),"audio"),this.util.addClass(e,"active"),t._element=e,t._cover=this.util.getParentElement(e,"FIGURE"),t._container=this.util.getParentElement(e,this.util.isComponent)},openModify:function(e){if(this.context.audio.audioUrlFile){const t=this.context.audio;t._linkValue=t.preview.textContent=t.audioUrlFile.value=t._element.src}e||this.plugins.dialog.open.call(this,"audio",!0)},onClick_controller:function(e){e.stopPropagation();const t=e.target.getAttribute("data-command");t&&(e.preventDefault(),/update/.test(t)?this.plugins.audio.openModify.call(this,!1):this.plugins.audio.destroy.call(this,this.context.audio._element),this.controllersOff())},onControllerOff:function(e){this.util.removeClass(e,"active"),this.context.audio.controller.style.display="none"},init:function(){if(this.context.dialog.updateModal)return;const e=this.context.audio;e.audioInputFile&&(e.audioInputFile.value=""),e.audioUrlFile&&(e._linkValue=e.preview.textContent=e.audioUrlFile.value=""),e.audioInputFile&&e.audioUrlFile&&(e.audioUrlFile.removeAttribute("disabled"),e.preview.style.textDecoration=""),e._element=null}},Ba="https://katex.org/docs/supported.html",JC={name:"math",display:"dialog",add:function(e){e.addModule([Fi]);const t=e.context;t.math={focusElement:null,previewElement:null,fontSizeElement:null,defaultFontSize:"",_mathExp:null};let n=this.setDialog(e);t.math.modal=n,t.math.focusElement=n.querySelector(".se-math-exp"),t.math.previewElement=n.querySelector(".se-math-preview"),t.math.fontSizeElement=n.querySelector(".se-math-size"),t.math.focusElement.addEventListener("paste",function(s){typeof e.functions.onPasteMath=="function"&&e.functions.onPasteMath(s,e)},!1),t.math.focusElement.addEventListener(e.util.isIE?"textinput":"input",this._renderMathExp.bind(e,t.math),!1),t.math.fontSizeElement.addEventListener("change",(function(s){this.fontSize=s.target.value}).bind(t.math.previewElement.style),!1);let i=this.setController_MathButton(e);t.math.mathController=i,t.math._mathExp=null,n.querySelector("form").addEventListener("submit",this.submit.bind(e),!1),i.addEventListener("click",this.onClick_mathController.bind(e)),t.math.previewElement.style.fontSize=t.math.defaultFontSize,t.dialog.modal.appendChild(n),t.element.relative.appendChild(i),n=null,i=null},setDialog:function(e){const t=e.lang,n=e.util.createElement("DIV"),i=e.options.mathFontSize;let s=i[0].value;n.className="se-dialog-content",n.style.display="none";let o='<form><div class="se-dialog-header"><button type="button" data-command="close" class="se-btn se-dialog-close" title="'+t.dialogBox.close+'" aria-label="'+t.dialogBox.close+'">'+e.icons.cancel+'</button><span class="se-modal-title">'+t.dialogBox.mathBox.title+'</span></div><div class="se-dialog-body"><div class="se-dialog-form"><label>'+t.dialogBox.mathBox.inputLabel+' (<a href="'+Ba+'" target="_blank">KaTeX</a>)</label><textarea class="se-input-form se-math-exp" type="text"></textarea></div><div class="se-dialog-form"><label>'+t.dialogBox.mathBox.fontSizeLabel+'</label><select class="se-input-select se-math-size">';for(let l=0,a=i.length,r;l<a;l++)r=i[l],r.default&&(s=r.value),o+='<option value="'+r.value+'"'+(r.default?" selected":"")+">"+r.text+"</option>";return o+='</select></div><div class="se-dialog-form"><label>'+t.dialogBox.mathBox.previewLabel+'</label><p class="se-math-preview"></p></div></div><div class="se-dialog-footer"><button type="submit" class="se-btn-primary" title="'+t.dialogBox.submitButton+'" aria-label="'+t.dialogBox.submitButton+'"><span>'+t.dialogBox.submitButton+"</span></button></div></form>",e.context.math.defaultFontSize=s,n.innerHTML=o,n},setController_MathButton:function(e){const t=e.lang,n=e.util.createElement("DIV");return n.className="se-controller se-controller-link",n.innerHTML='<div class="se-arrow se-arrow-up"></div><div class="link-content"><div class="se-btn-group"><button type="button" data-command="update" tabindex="-1" class="se-btn se-tooltip">'+e.icons.edit+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+t.controller.edit+'</span></span></button><button type="button" data-command="delete" tabindex="-1" class="se-btn se-tooltip">'+e.icons.delete+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+t.controller.remove+"</span></span></button></div></div>",n},open:function(){this.plugins.dialog.open.call(this,"math",this.currentControllerName==="math")},managedTags:function(){return{className:"katex",method:function(e){if(!e.getAttribute("data-exp")||!this.options.katex)return;const t=this._d.createRange().createContextualFragment(this.plugins.math._renderer.call(this,this.util.HTMLDecoder(e.getAttribute("data-exp"))));e.innerHTML=t.querySelector(".katex").innerHTML,e.setAttribute("contenteditable",!1)}}},_renderer:function(e){let t="";try{this.util.removeClass(this.context.math.focusElement,"se-error"),t=this.options.katex.src.renderToString(e,{throwOnError:!0,displayMode:!0})}catch(n){this.util.addClass(this.context.math.focusElement,"se-error"),t='<span class="se-math-katex-error">Katex syntax error. (Refer <a href="'+Ba+'" target="_blank">KaTeX</a>)</span>',console.warn("[SUNEDITOR.math.Katex.error] ",n)}return t},_renderMathExp:function(e,t){e.previewElement.innerHTML=this.plugins.math._renderer.call(this,t.target.value)},submit:function(e){this.showLoading(),e.preventDefault(),e.stopPropagation();const t=(function(){if(this.context.math.focusElement.value.trim().length===0)return!1;const n=this.context.math,i=n.focusElement.value,s=n.previewElement.querySelector(".katex");if(!s)return!1;if(s.className="__se__katex "+s.className,s.setAttribute("contenteditable",!1),s.setAttribute("data-exp",this.util.HTMLEncoder(i)),s.setAttribute("data-font-size",n.fontSizeElement.value),s.style.fontSize=n.fontSizeElement.value,this.context.dialog.updateModal){const o=this.util.getParentElement(n._mathExp,".katex");o.parentNode.replaceChild(s,o),this.setRange(s,0,s,1)}else{const o=this.getSelectedElements();if(o.length>1){const a=this.util.createElement(o[0].nodeName);if(a.appendChild(s),!this.insertNode(a,null,!0))return!1}else if(!this.insertNode(s,null,!0))return!1;const l=this.util.createTextNode(this.util.zeroWidthSpace);s.parentNode.insertBefore(l,s.nextSibling),this.setRange(s,0,s,1)}return n.focusElement.value="",n.fontSizeElement.value="1em",n.previewElement.style.fontSize="1em",n.previewElement.innerHTML="",!0}).bind(this);try{t()&&(this.plugins.dialog.close.call(this),this.history.push(!1))}catch{this.plugins.dialog.close.call(this)}finally{this.closeLoading()}return!1},active:function(e){if(!e)this.controllerArray.indexOf(this.context.math.mathController)>-1&&this.controllersOff();else if(e.getAttribute("data-exp"))return this.controllerArray.indexOf(this.context.math.mathController)<0&&(this.setRange(e,0,e,1),this.plugins.math.call_controller.call(this,e)),!0;return!1},on:function(e){if(!e)this.plugins.math.init.call(this);else{const t=this.context.math;if(t._mathExp){const n=this.util.HTMLDecoder(t._mathExp.getAttribute("data-exp")),i=t._mathExp.getAttribute("data-font-size")||"1em";this.context.dialog.updateModal=!0,t.focusElement.value=n,t.fontSizeElement.value=i,t.previewElement.innerHTML=this.plugins.math._renderer.call(this,n),t.previewElement.style.fontSize=i}}},call_controller:function(e){this.context.math._mathExp=e;const t=this.context.math.mathController;this.setControllerPosition(t,e,"bottom",{left:0,top:0}),this.controllersOn(t,e,"math")},onClick_mathController:function(e){e.stopPropagation();const t=e.target.getAttribute("data-command")||e.target.parentNode.getAttribute("data-command");t&&(e.preventDefault(),/update/.test(t)?(this.context.math.focusElement.value=this.util.HTMLDecoder(this.context.math._mathExp.getAttribute("data-exp")),this.plugins.dialog.open.call(this,"math",!0)):(this.util.removeItem(this.context.math._mathExp),this.context.math._mathExp=null,this.focus(),this.history.push(!1)),this.controllersOff())},init:function(){const e=this.context.math;e.mathController.style.display="none",e._mathExp=null,e.focusElement.value="",e.previewElement.innerHTML=""}};var ph={exports:{}};(function(e){(function(t,n){e.exports=t.document?n(t,!0):function(i){if(!i.document)throw new Error("SUNEDITOR_MODULES a window with a document");return n(i)}})(typeof window<"u"?window:Yn,function(t,n){const i={name:"fileBrowser",_xmlHttp:null,_loading:null,add:function(s){const o=s.context;o.fileBrowser={_closeSignal:!1,area:null,header:null,tagArea:null,body:null,list:null,tagElements:null,items:[],selectedTags:[],selectorHandler:null,contextPlugin:"",columnSize:4};let l=s.util.createElement("DIV");l.className="se-file-browser sun-editor-common";let a=s.util.createElement("DIV");a.className="se-file-browser-back";let r=s.util.createElement("DIV");r.className="se-file-browser-inner",r.innerHTML=this.set_browser(s),l.appendChild(a),l.appendChild(r),this._loading=l.querySelector(".se-loading-box"),o.fileBrowser.area=l,o.fileBrowser.header=r.querySelector(".se-file-browser-header"),o.fileBrowser.titleArea=r.querySelector(".se-file-browser-title"),o.fileBrowser.tagArea=r.querySelector(".se-file-browser-tags"),o.fileBrowser.body=r.querySelector(".se-file-browser-body"),o.fileBrowser.list=r.querySelector(".se-file-browser-list"),o.fileBrowser.tagArea.addEventListener("click",this.onClickTag.bind(s)),o.fileBrowser.list.addEventListener("click",this.onClickFile.bind(s)),r.addEventListener("mousedown",this._onMouseDown_browser.bind(s)),r.addEventListener("click",this._onClick_browser.bind(s)),o.element.relative.appendChild(l),l=null,a=null,r=null},set_browser:function(s){const o=s.lang;return'<div class="se-file-browser-content"><div class="se-file-browser-header"><button type="button" data-command="close" class="se-btn se-file-browser-close" class="close" title="'+o.dialogBox.close+'" aria-label="'+o.dialogBox.close+'">'+s.icons.cancel+'</button><span class="se-file-browser-title"></span><div class="se-file-browser-tags"></div></div><div class="se-file-browser-body"><div class="se-loading-box sun-editor-common"><div class="se-loading-effect"></div></div><div class="se-file-browser-list"></div></div></div>'},_onMouseDown_browser:function(s){/se-file-browser-inner/.test(s.target.className)?this.context.fileBrowser._closeSignal=!0:this.context.fileBrowser._closeSignal=!1},_onClick_browser:function(s){s.stopPropagation(),(/close/.test(s.target.getAttribute("data-command"))||this.context.fileBrowser._closeSignal)&&this.plugins.fileBrowser.close.call(this)},open:function(s,o){this.plugins.fileBrowser._bindClose&&(this._d.removeEventListener("keydown",this.plugins.fileBrowser._bindClose),this.plugins.fileBrowser._bindClose=null),this.plugins.fileBrowser._bindClose=(function(f){/27/.test(f.keyCode)&&this.plugins.fileBrowser.close.call(this)}).bind(this),this._d.addEventListener("keydown",this.plugins.fileBrowser._bindClose);const l=this.context.fileBrowser;l.contextPlugin=s,l.selectorHandler=o;const a=this.context[s],r=a.listClass;this.util.hasClass(l.list,r)||(l.list.className="se-file-browser-list "+r),this.options.popupDisplay==="full"?l.area.style.position="fixed":l.area.style.position="absolute",l.titleArea.textContent=a.title,l.area.style.display="block",this.context[s].directData?this.plugins.fileBrowser._drawListItem.call(this,this.context[s].directData,!0):this.plugins.fileBrowser._drawFileList.call(this,this.context[s].url,this.context[s].header)},_bindClose:null,close:function(){const s=this.plugins.fileBrowser;s._xmlHttp&&s._xmlHttp.abort(),s._bindClose&&(this._d.removeEventListener("keydown",s._bindClose),s._bindClose=null);const o=this.context.fileBrowser;o.area.style.display="none",o.selectorHandler=null,o.selectedTags=[],o.items=[],o.list.innerHTML=o.tagArea.innerHTML=o.titleArea.textContent="",typeof this.plugins[o.contextPlugin].init=="function"&&this.plugins[o.contextPlugin].init.call(this),o.contextPlugin=""},showBrowserLoading:function(){this._loading.style.display="block"},closeBrowserLoading:function(){this._loading.style.display="none"},_drawFileList:function(s,o){const l=this.plugins.fileBrowser,a=l._xmlHttp=this.util.getXMLHttpRequest();if(a.onreadystatechange=l._callBackGet.bind(this,a),a.open("get",s,!0),o!==null&&typeof o=="object"&&this._w.Object.keys(o).length>0)for(let r in o)a.setRequestHeader(r,o[r]);a.send(null),this.plugins.fileBrowser.showBrowserLoading()},_callBackGet:function(s){if(s.readyState===4){if(this.plugins.fileBrowser._xmlHttp=null,s.status===200)try{const o=JSON.parse(s.responseText);o.result.length>0?this.plugins.fileBrowser._drawListItem.call(this,o.result,!0):o.nullMessage&&(this.context.fileBrowser.list.innerHTML=o.nullMessage)}catch(o){throw Error('[SUNEDITOR.fileBrowser.drawList.fail] cause : "'+o.message+'"')}finally{this.plugins.fileBrowser.closeBrowserLoading(),this.context.fileBrowser.body.style.maxHeight=this._w.innerHeight-this.context.fileBrowser.header.offsetHeight-50+"px"}else if(this.plugins.fileBrowser.closeBrowserLoading(),s.status!==0){const o=s.responseText?JSON.parse(s.responseText):s,l="[SUNEDITOR.fileBrowser.get.serverException] status: "+s.status+", response: "+(o.errorMessage||s.responseText);throw Error(l)}}},_drawListItem:function(s,o){const l=this.context.fileBrowser,a=this.context[l.contextPlugin],r=[],f=s.length,d=a.columnSize||l.columnSize,h=d<=1?1:Math.round(f/d)||1,v=a.itemTemplateHandler;let _="",C='<div class="se-file-item-column">',S=1;for(let c=0,u,p;c<f;c++)if(u=s[c],p=u.tag?typeof u.tag=="string"?u.tag.split(","):u.tag:[],p=u.tag=p.map(function(b){return b.trim()}),C+=v(u),(c+1)%h===0&&S<d&&c+1<f&&(S++,C+='</div><div class="se-file-item-column">'),o&&p.length>0)for(let b=0,y=p.length,w;b<y;b++)w=p[b],w&&r.indexOf(w)===-1&&(r.push(w),_+='<a title="'+w+'" aria-label="'+w+'">'+w+"</a>");C+="</div>",l.list.innerHTML=C,o&&(l.items=s,l.tagArea.innerHTML=_,l.tagElements=l.tagArea.querySelectorAll("A"))},onClickTag:function(s){const o=s.target;if(!this.util.isAnchor(o))return;const l=o.textContent,a=this.plugins.fileBrowser,r=this.context.fileBrowser,f=r.tagArea.querySelector('a[title="'+l+'"]'),d=r.selectedTags,h=d.indexOf(l);h>-1?(d.splice(h,1),this.util.removeClass(f,"on")):(d.push(l),this.util.addClass(f,"on")),a._drawListItem.call(this,d.length===0?r.items:r.items.filter(function(v){return v.tag.some(function(_){return d.indexOf(_)>-1})}),!1)},onClickFile:function(s){s.preventDefault(),s.stopPropagation();const o=this.context.fileBrowser,l=o.list;let a=s.target,r=null;if(a===l)return;for(;l!==a.parentNode&&(r=a.getAttribute("data-command"),!r);)a=a.parentNode;if(!r)return;(o.selectorHandler||this.context[o.contextPlugin].selectorHandler)(a,a.parentNode.querySelector(".__se__img_name").textContent),this.plugins.fileBrowser.close.call(this)}};return typeof n>"u"&&(t.SUNEDITOR_MODULES||Object.defineProperty(t,"SUNEDITOR_MODULES",{enumerable:!0,writable:!1,configurable:!1,value:{}}),Object.defineProperty(t.SUNEDITOR_MODULES,"fileBrowser",{enumerable:!0,writable:!1,configurable:!1,value:i})),i})})(ph);var eS=ph.exports;const tS=Zn(eS),nS={name:"imageGallery",add:function(e){e.addModule([tS]);const t=e.context;t.imageGallery={title:e.lang.toolbar.imageGallery,directData:e.options.imageGalleryData,url:e.options.imageGalleryUrl,header:e.options.imageGalleryHeader,listClass:"se-image-list",itemTemplateHandler:this.drawItems,selectorHandler:this.setImage.bind(e),columnSize:4}},open:function(e){this.plugins.fileBrowser.open.call(this,"imageGallery",e)},drawItems:function(e){const t=e.src.split("/").pop();return'<div class="se-file-item-img"><img src="'+(e.thumbnail||e.src)+'" alt="'+(e.alt||t)+'" data-command="pick" data-value="'+(e.src||e.thumbnail)+'"><div class="se-file-img-name se-file-name-back"></div><div class="se-file-img-name __se__img_name">'+(e.name||t)+"</div></div>"},setImage:function(e,t){this.callPlugin("image",(function(){const n={name:t,size:0};this.plugins.image.create_image.call(this,e.getAttribute("data-value"),null,this.context.image._origin_w,this.context.image._origin_h,"none",n,e.alt)}).bind(this),null)}},iS={blockquote:AC,align:RC,font:DC,fontSize:LC,fontColor:OC,hiliteColor:PC,horizontalRule:IC,list:BC,table:FC,formatBlock:jC,lineHeight:zC,template:HC,paragraphStyle:VC,textStyle:WC,link:YC,image:KC,video:XC,audio:QC,math:JC,imageGallery:nS},Jo=m.forwardRef(({value:e="",onChange:t,placeholder:n="Start writing...",height:i="200px",className:s,...o},l)=>{const a=m.useRef(null),[r,f]=m.useState(null);return m.useEffect(()=>{if(a.current&&!r){const d=MC.create(a.current,{plugins:iS,buttonList:[["undo","redo"],["font","fontSize","formatBlock"],["paragraphStyle","blockquote"],["bold","underline","italic","strike","subscript","superscript"],["fontColor","hiliteColor","textStyle"],["removeFormat"],["outdent","indent"],["align","horizontalRule","list","lineHeight"],["table","link","image","video","audio"],["fullScreen","showBlocks","codeView"],["preview","print"],["save","template"]],defaultTag:"div",minHeight:i,showPathLabel:!1,placeholder:n,resizingBar:!1,charCounter:!0,maxCharCount:1e4,width:"100%",height:"auto",mode:"classic",katex:"window.katex",imageGalleryUrl:"/editor/image-gallery",videoFileInput:!1,audioFileInput:!1,tabDisable:!1,linkProtocol:"",linkRelDefault:{default:"nofollow",check_new_window:"nofollow noopener",check_bookmark:""},iframe:!1,stickyToolbar:!1,popupDisplay:"local",display:"block",position:null,font:["Arial","Comic Sans MS","Courier New","Impact","Georgia","tahoma","Trebuchet MS","Verdana"],fontSize:[8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72],formats:["p","div","blockquote","pre","h1","h2","h3","h4","h5","h6"],colorList:["#ff0000","#ff5e00","#ffbb00","#ffe400","#abf200","#00d8ff","#0055ff","#0900ff","#6600ff","#ff00dd","#ff007f","#000000","#2d3436","#636e72","#b2bec3","#ffffff","#ffeaa7","#fab1a0","#e17055","#d63031","#fd79a8","#e84393","#6c5ce7","#a29bfe","#fdcb6e","#e17055","#00b894","#00cec9","#55a3ff","#74b9ff","#a29bfe","#ffeaa7","#fab1a0"],lineHeights:[{text:"1",value:1},{text:"1.15",value:1.15},{text:"1.5",value:1.5},{text:"2",value:2}],paragraphStyles:["spaced","neon",{name:"Custom",class:"__se__customClass"}],textStyles:["translucent",{name:"Shadow",style:"text-shadow: 2px 2px 2px #000;"}],imageSizeOnlyPercentage:!1,imageWidth:"100%",imageHeight:"auto",imageSize:"auto",imageUploadSizeLimit:5242880,imageUploadUrl:null,imageUploadHeader:{},imageUrlInput:!0,imageMultipleFile:!1,imageAccept:".jpg,.jpeg,.png,.gif,.svg,.webp",videoWidth:"100%",videoHeight:"auto",videoSize:"auto",videoUploadSizeLimit:10485760,videoUploadUrl:null,videoUploadHeader:{},videoUrlInput:!0,videoMultipleFile:!1,videoAccept:".mp4,.avi,.wmv,.flv,.mov,.webm,.m4v",audioWidth:"100%",audioHeight:"auto",audioSize:"auto",audioUploadSizeLimit:10485760,audioUploadUrl:null,audioUploadHeader:{},audioUrlInput:!0,audioMultipleFile:!1,audioAccept:".mp3,.wav,.ogg,.flac,.aac,.wma",tableCellControllerPosition:"cell",tableResizing:!0,tableUseBackgroundColor:!0,tableBackgroundColor:"#fff",codeMirror:null,codeMirror_src:null,codeMirror_options:null,fullScreenOffset:0,previewTemplate:null,printTemplate:null,iframeAttributes:{},iframeStyles:{},attributesWhitelist:{},tagsBlacklist:"",pasteTagsWhitelist:"",pasteAttributesWhitelist:"",pasteKeepOnlyTags:"",pasteDenyTags:"",pasteTagsBlacklist:"",pasteKeepOnlyAttributes:"",pasteDenyAttributes:"",pasteTagsRemove:"",pasteAttributesRemove:"",...o});d.onChange=h=>{t==null||t(h)},f(d)}return()=>{r&&(r.destroy(),f(null))}},[t,i,n,o]),m.useEffect(()=>{r&&e!==r.getContents()&&r.setContents(e)},[r,e]),m.useImperativeHandle(l,()=>({getContents:()=>r==null?void 0:r.getContents(),setContents:d=>r==null?void 0:r.setContents(d),insertHTML:d=>r==null?void 0:r.insertHTML(d),focus:()=>r==null?void 0:r.core.focus(),blur:()=>r==null?void 0:r.core.blur()}),[r]),g.jsx("div",{className:ne("sun-editor-wrapper",s),children:g.jsx("div",{ref:a})})});Jo.displayName="RichTextEditor";function sS(e,t=[]){let n=[];function i(o,l){const a=m.createContext(l),r=n.length;n=[...n,l];const f=h=>{var u;const{scope:v,children:_,...C}=h,S=((u=v==null?void 0:v[e])==null?void 0:u[r])||a,c=m.useMemo(()=>C,Object.values(C));return g.jsx(S.Provider,{value:c,children:_})};f.displayName=o+"Provider";function d(h,v){var S;const _=((S=v==null?void 0:v[e])==null?void 0:S[r])||a,C=m.useContext(_);if(C)return C;if(l!==void 0)return l;throw new Error(`\`${h}\` must be used within \`${o}\``)}return[f,d]}const s=()=>{const o=n.map(l=>m.createContext(l));return function(a){const r=(a==null?void 0:a[e])||o;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:r}}),[a,r])}};return s.scopeName=e,[i,rS(s,...t)]}function rS(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const l=i.reduce((a,{useScope:r,scopeName:f})=>{const h=r(o)[`__scope${f}`];return{...a,...h}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:l}),[l])}};return n.scopeName=t.scopeName,n}function oS(e){const t=lS(e),n=m.forwardRef((i,s)=>{const{children:o,...l}=i,a=m.Children.toArray(o),r=a.find(cS);if(r){const f=r.props.children,d=a.map(h=>h===r?m.Children.count(f)>1?m.Children.only(null):m.isValidElement(f)?f.props.children:null:h);return g.jsx(t,{...l,ref:s,children:m.isValidElement(f)?m.cloneElement(f,void 0,d):null})}return g.jsx(t,{...l,ref:s,children:o})});return n.displayName=`${e}.Slot`,n}function lS(e){const t=m.forwardRef((n,i)=>{const{children:s,...o}=n;if(m.isValidElement(s)){const l=dS(s),a=uS(o,s.props);return s.type!==m.Fragment&&(a.ref=i?je(i,l):l),m.cloneElement(s,a)}return m.Children.count(s)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var aS=Symbol("radix.slottable");function cS(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===aS}function uS(e,t){const n={...t};for(const i in t){const s=e[i],o=t[i];/^on[A-Z]/.test(i)?s&&o?n[i]=(...a)=>{const r=o(...a);return s(...a),r}:s&&(n[i]=s):i==="style"?n[i]={...s,...o}:i==="className"&&(n[i]=[s,o].filter(Boolean).join(" "))}return{...e,...n}}function dS(e){var i,s;let t=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var fS=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],hS=fS.reduce((e,t)=>{const n=oS(`Primitive.${t}`),i=m.forwardRef((s,o)=>{const{asChild:l,...a}=s,r=l?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),g.jsx(r,{...a,ref:o})});return i.displayName=`Primitive.${t}`,{...e,[t]:i}},{});function pS(e,t=[]){let n=[];function i(o,l){const a=m.createContext(l),r=n.length;n=[...n,l];const f=h=>{var u;const{scope:v,children:_,...C}=h,S=((u=v==null?void 0:v[e])==null?void 0:u[r])||a,c=m.useMemo(()=>C,Object.values(C));return g.jsx(S.Provider,{value:c,children:_})};f.displayName=o+"Provider";function d(h,v){var S;const _=((S=v==null?void 0:v[e])==null?void 0:S[r])||a,C=m.useContext(_);if(C)return C;if(l!==void 0)return l;throw new Error(`\`${h}\` must be used within \`${o}\``)}return[f,d]}const s=()=>{const o=n.map(l=>m.createContext(l));return function(a){const r=(a==null?void 0:a[e])||o;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:r}}),[a,r])}};return s.scopeName=e,[i,mS(s,...t)]}function mS(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const l=i.reduce((a,{useScope:r,scopeName:f})=>{const h=r(o)[`__scope${f}`];return{...a,...h}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:l}),[l])}};return n.scopeName=t.scopeName,n}function mh(e){const t=gS(e),n=m.forwardRef((i,s)=>{const{children:o,...l}=i,a=m.Children.toArray(o),r=a.find(bS);if(r){const f=r.props.children,d=a.map(h=>h===r?m.Children.count(f)>1?m.Children.only(null):m.isValidElement(f)?f.props.children:null:h);return g.jsx(t,{...l,ref:s,children:m.isValidElement(f)?m.cloneElement(f,void 0,d):null})}return g.jsx(t,{...l,ref:s,children:o})});return n.displayName=`${e}.Slot`,n}function gS(e){const t=m.forwardRef((n,i)=>{const{children:s,...o}=n;if(m.isValidElement(s)){const l=xS(s),a=yS(o,s.props);return s.type!==m.Fragment&&(a.ref=i?je(i,l):l),m.cloneElement(s,a)}return m.Children.count(s)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var vS=Symbol("radix.slottable");function bS(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===vS}function yS(e,t){const n={...t};for(const i in t){const s=e[i],o=t[i];/^on[A-Z]/.test(i)?s&&o?n[i]=(...a)=>{const r=o(...a);return s(...a),r}:s&&(n[i]=s):i==="style"?n[i]={...s,...o}:i==="className"&&(n[i]=[s,o].filter(Boolean).join(" "))}return{...e,...n}}function xS(e){var i,s;let t=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var wS=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ji=wS.reduce((e,t)=>{const n=mh(`Primitive.${t}`),i=m.forwardRef((s,o)=>{const{asChild:l,...a}=s,r=l?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),g.jsx(r,{...a,ref:o})});return i.displayName=`Primitive.${t}`,{...e,[t]:i}},{});function _S(e,t){e&&wi.flushSync(()=>e.dispatchEvent(t))}var Gr=["Enter"," "],CS=["ArrowDown","PageUp","Home"],gh=["ArrowUp","PageDown","End"],SS=[...CS,...gh],ES={ltr:[...Gr,"ArrowRight"],rtl:[...Gr,"ArrowLeft"]},NS={ltr:["ArrowLeft"],rtl:["ArrowRight"]},zi="Menu",[gi,kS,TS]=co(zi),[mn,vh]=pS(zi,[TS,en,js]),Hi=en(),bh=js(),[yh,rn]=mn(zi),[MS,Vi]=mn(zi),xh=e=>{const{__scopeMenu:t,open:n=!1,children:i,dir:s,onOpenChange:o,modal:l=!0}=e,a=Hi(t),[r,f]=m.useState(null),d=m.useRef(!1),h=Ze(o),v=Ei(s);return m.useEffect(()=>{const _=()=>{d.current=!0,document.addEventListener("pointerdown",C,{capture:!0,once:!0}),document.addEventListener("pointermove",C,{capture:!0,once:!0})},C=()=>d.current=!1;return document.addEventListener("keydown",_,{capture:!0}),()=>{document.removeEventListener("keydown",_,{capture:!0}),document.removeEventListener("pointerdown",C,{capture:!0}),document.removeEventListener("pointermove",C,{capture:!0})}},[]),g.jsx(Ti,{...a,children:g.jsx(yh,{scope:t,open:n,onOpenChange:h,content:r,onContentChange:f,children:g.jsx(MS,{scope:t,onClose:m.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:d,dir:v,modal:l,children:i})})})};xh.displayName=zi;var AS="MenuAnchor",el=m.forwardRef((e,t)=>{const{__scopeMenu:n,...i}=e,s=Hi(n);return g.jsx(Mi,{...s,...i,ref:t})});el.displayName=AS;var tl="MenuPortal",[RS,wh]=mn(tl,{forceMount:void 0}),_h=e=>{const{__scopeMenu:t,forceMount:n,children:i,container:s}=e,o=rn(tl,t);return g.jsx(RS,{scope:t,forceMount:n,children:g.jsx(Ke,{present:n||o.open,children:g.jsx(Ai,{asChild:!0,container:s,children:i})})})};_h.displayName=tl;var pt="MenuContent",[DS,nl]=mn(pt),Ch=m.forwardRef((e,t)=>{const n=wh(pt,e.__scopeMenu),{forceMount:i=n.forceMount,...s}=e,o=rn(pt,e.__scopeMenu),l=Vi(pt,e.__scopeMenu);return g.jsx(gi.Provider,{scope:e.__scopeMenu,children:g.jsx(Ke,{present:i||o.open,children:g.jsx(gi.Slot,{scope:e.__scopeMenu,children:l.modal?g.jsx(LS,{...s,ref:t}):g.jsx(OS,{...s,ref:t})})})})}),LS=m.forwardRef((e,t)=>{const n=rn(pt,e.__scopeMenu),i=m.useRef(null),s=ye(t,i);return m.useEffect(()=>{const o=i.current;if(o)return Ms(o)},[]),g.jsx(il,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:oe(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),OS=m.forwardRef((e,t)=>{const n=rn(pt,e.__scopeMenu);return g.jsx(il,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),PS=mh("MenuContent.ScrollLock"),il=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:i=!1,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:l,disableOutsidePointerEvents:a,onEntryFocus:r,onEscapeKeyDown:f,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:v,onDismiss:_,disableOutsideScroll:C,...S}=e,c=rn(pt,n),u=Vi(pt,n),p=Hi(n),b=bh(n),y=kS(n),[w,x]=m.useState(null),E=m.useRef(null),k=ye(t,E,c.onContentChange),N=m.useRef(0),T=m.useRef(""),R=m.useRef(0),M=m.useRef(null),A=m.useRef("right"),D=m.useRef(0),$=C?Ri:m.Fragment,H=C?{as:PS,allowPinchZoom:!0}:void 0,j=z=>{var V,X;const P=T.current+z,B=y().filter(Z=>!Z.disabled),L=document.activeElement,U=(V=B.find(Z=>Z.ref.current===L))==null?void 0:V.textValue,O=B.map(Z=>Z.textValue),W=ZS(O,P,U),Q=(X=B.find(Z=>Z.textValue===W))==null?void 0:X.ref.current;(function Z(G){T.current=G,window.clearTimeout(N.current),G!==""&&(N.current=window.setTimeout(()=>Z(""),1e3))})(P),Q&&setTimeout(()=>Q.focus())};m.useEffect(()=>()=>window.clearTimeout(N.current),[]),_s();const F=m.useCallback(z=>{var B,L;return A.current===((B=M.current)==null?void 0:B.side)&&GS(z,(L=M.current)==null?void 0:L.area)},[]);return g.jsx(DS,{scope:n,searchRef:T,onItemEnter:m.useCallback(z=>{F(z)&&z.preventDefault()},[F]),onItemLeave:m.useCallback(z=>{var P;F(z)||((P=E.current)==null||P.focus(),x(null))},[F]),onTriggerLeave:m.useCallback(z=>{F(z)&&z.preventDefault()},[F]),pointerGraceTimerRef:R,onPointerGraceIntentChange:m.useCallback(z=>{M.current=z},[]),children:g.jsx($,{...H,children:g.jsx(Ni,{asChild:!0,trapped:s,onMountAutoFocus:oe(o,z=>{var P;z.preventDefault(),(P=E.current)==null||P.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:g.jsx(Vn,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:f,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:v,onDismiss:_,children:g.jsx(Dd,{asChild:!0,...b,dir:u.dir,orientation:"vertical",loop:i,currentTabStopId:w,onCurrentTabStopIdChange:x,onEntryFocus:oe(r,z=>{u.isUsingKeyboardRef.current||z.preventDefault()}),preventScrollOnEntryFocus:!0,children:g.jsx(ks,{role:"menu","aria-orientation":"vertical","data-state":zh(c.open),"data-radix-menu-content":"",dir:u.dir,...p,...S,ref:k,style:{outline:"none",...S.style},onKeyDown:oe(S.onKeyDown,z=>{const B=z.target.closest("[data-radix-menu-content]")===z.currentTarget,L=z.ctrlKey||z.altKey||z.metaKey,U=z.key.length===1;B&&(z.key==="Tab"&&z.preventDefault(),!L&&U&&j(z.key));const O=E.current;if(z.target!==O||!SS.includes(z.key))return;z.preventDefault();const Q=y().filter(V=>!V.disabled).map(V=>V.ref.current);gh.includes(z.key)&&Q.reverse(),US(Q)}),onBlur:oe(e.onBlur,z=>{z.currentTarget.contains(z.target)||(window.clearTimeout(N.current),T.current="")}),onPointerMove:oe(e.onPointerMove,vi(z=>{const P=z.target,B=D.current!==z.clientX;if(z.currentTarget.contains(P)&&B){const L=z.clientX>D.current?"right":"left";A.current=L,D.current=z.clientX}}))})})})})})})});Ch.displayName=pt;var IS="MenuGroup",sl=m.forwardRef((e,t)=>{const{__scopeMenu:n,...i}=e;return g.jsx(ji.div,{role:"group",...i,ref:t})});sl.displayName=IS;var BS="MenuLabel",Sh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...i}=e;return g.jsx(ji.div,{...i,ref:t})});Sh.displayName=BS;var ds="MenuItem",Fa="menu.itemSelect",Ks=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:i,...s}=e,o=m.useRef(null),l=Vi(ds,e.__scopeMenu),a=nl(ds,e.__scopeMenu),r=ye(t,o),f=m.useRef(!1),d=()=>{const h=o.current;if(!n&&h){const v=new CustomEvent(Fa,{bubbles:!0,cancelable:!0});h.addEventListener(Fa,_=>i==null?void 0:i(_),{once:!0}),_S(h,v),v.defaultPrevented?f.current=!1:l.onClose()}};return g.jsx(Eh,{...s,ref:r,disabled:n,onClick:oe(e.onClick,d),onPointerDown:h=>{var v;(v=e.onPointerDown)==null||v.call(e,h),f.current=!0},onPointerUp:oe(e.onPointerUp,h=>{var v;f.current||(v=h.currentTarget)==null||v.click()}),onKeyDown:oe(e.onKeyDown,h=>{const v=a.searchRef.current!=="";n||v&&h.key===" "||Gr.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Ks.displayName=ds;var Eh=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:i=!1,textValue:s,...o}=e,l=nl(ds,n),a=bh(n),r=m.useRef(null),f=ye(t,r),[d,h]=m.useState(!1),[v,_]=m.useState("");return m.useEffect(()=>{const C=r.current;C&&_((C.textContent??"").trim())},[o.children]),g.jsx(gi.ItemSlot,{scope:n,disabled:i,textValue:s??v,children:g.jsx(Ld,{asChild:!0,...a,focusable:!i,children:g.jsx(ji.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...o,ref:f,onPointerMove:oe(e.onPointerMove,vi(C=>{i?l.onItemLeave(C):(l.onItemEnter(C),C.defaultPrevented||C.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:oe(e.onPointerLeave,vi(C=>l.onItemLeave(C))),onFocus:oe(e.onFocus,()=>h(!0)),onBlur:oe(e.onBlur,()=>h(!1))})})})}),FS="MenuCheckboxItem",Nh=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:i,...s}=e;return g.jsx(Rh,{scope:e.__scopeMenu,checked:n,children:g.jsx(Ks,{role:"menuitemcheckbox","aria-checked":fs(n)?"mixed":n,...s,ref:t,"data-state":ll(n),onSelect:oe(s.onSelect,()=>i==null?void 0:i(fs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Nh.displayName=FS;var kh="MenuRadioGroup",[jS,zS]=mn(kh,{value:void 0,onValueChange:()=>{}}),Th=m.forwardRef((e,t)=>{const{value:n,onValueChange:i,...s}=e,o=Ze(i);return g.jsx(jS,{scope:e.__scopeMenu,value:n,onValueChange:o,children:g.jsx(sl,{...s,ref:t})})});Th.displayName=kh;var Mh="MenuRadioItem",Ah=m.forwardRef((e,t)=>{const{value:n,...i}=e,s=zS(Mh,e.__scopeMenu),o=n===s.value;return g.jsx(Rh,{scope:e.__scopeMenu,checked:o,children:g.jsx(Ks,{role:"menuitemradio","aria-checked":o,...i,ref:t,"data-state":ll(o),onSelect:oe(i.onSelect,()=>{var l;return(l=s.onValueChange)==null?void 0:l.call(s,n)},{checkForDefaultPrevented:!1})})})});Ah.displayName=Mh;var rl="MenuItemIndicator",[Rh,HS]=mn(rl,{checked:!1}),Dh=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:i,...s}=e,o=HS(rl,n);return g.jsx(Ke,{present:i||fs(o.checked)||o.checked===!0,children:g.jsx(ji.span,{...s,ref:t,"data-state":ll(o.checked)})})});Dh.displayName=rl;var VS="MenuSeparator",Lh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...i}=e;return g.jsx(ji.div,{role:"separator","aria-orientation":"horizontal",...i,ref:t})});Lh.displayName=VS;var WS="MenuArrow",Oh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...i}=e,s=Hi(n);return g.jsx(Ts,{...s,...i,ref:t})});Oh.displayName=WS;var ol="MenuSub",[$S,Ph]=mn(ol),Ih=e=>{const{__scopeMenu:t,children:n,open:i=!1,onOpenChange:s}=e,o=rn(ol,t),l=Hi(t),[a,r]=m.useState(null),[f,d]=m.useState(null),h=Ze(s);return m.useEffect(()=>(o.open===!1&&h(!1),()=>h(!1)),[o.open,h]),g.jsx(Ti,{...l,children:g.jsx(yh,{scope:t,open:i,onOpenChange:h,content:f,onContentChange:d,children:g.jsx($S,{scope:t,contentId:it(),triggerId:it(),trigger:a,onTriggerChange:r,children:n})})})};Ih.displayName=ol;var oi="MenuSubTrigger",Bh=m.forwardRef((e,t)=>{const n=rn(oi,e.__scopeMenu),i=Vi(oi,e.__scopeMenu),s=Ph(oi,e.__scopeMenu),o=nl(oi,e.__scopeMenu),l=m.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:r}=o,f={__scopeMenu:e.__scopeMenu},d=m.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return m.useEffect(()=>d,[d]),m.useEffect(()=>{const h=a.current;return()=>{window.clearTimeout(h),r(null)}},[a,r]),g.jsx(el,{asChild:!0,...f,children:g.jsx(Eh,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":s.contentId,"data-state":zh(n.open),...e,ref:je(t,s.onTriggerChange),onClick:h=>{var v;(v=e.onClick)==null||v.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:oe(e.onPointerMove,vi(h=>{o.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!l.current&&(o.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:oe(e.onPointerLeave,vi(h=>{var _,C;d();const v=(_=n.content)==null?void 0:_.getBoundingClientRect();if(v){const S=(C=n.content)==null?void 0:C.dataset.side,c=S==="right",u=c?-5:5,p=v[c?"left":"right"],b=v[c?"right":"left"];o.onPointerGraceIntentChange({area:[{x:h.clientX+u,y:h.clientY},{x:p,y:v.top},{x:b,y:v.top},{x:b,y:v.bottom},{x:p,y:v.bottom}],side:S}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(h),h.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:oe(e.onKeyDown,h=>{var _;const v=o.searchRef.current!=="";e.disabled||v&&h.key===" "||ES[i.dir].includes(h.key)&&(n.onOpenChange(!0),(_=n.content)==null||_.focus(),h.preventDefault())})})})});Bh.displayName=oi;var Fh="MenuSubContent",jh=m.forwardRef((e,t)=>{const n=wh(pt,e.__scopeMenu),{forceMount:i=n.forceMount,...s}=e,o=rn(pt,e.__scopeMenu),l=Vi(pt,e.__scopeMenu),a=Ph(Fh,e.__scopeMenu),r=m.useRef(null),f=ye(t,r);return g.jsx(gi.Provider,{scope:e.__scopeMenu,children:g.jsx(Ke,{present:i||o.open,children:g.jsx(gi.Slot,{scope:e.__scopeMenu,children:g.jsx(il,{id:a.contentId,"aria-labelledby":a.triggerId,...s,ref:f,align:"start",side:l.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var h;l.isUsingKeyboardRef.current&&((h=r.current)==null||h.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:oe(e.onFocusOutside,d=>{d.target!==a.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:oe(e.onEscapeKeyDown,d=>{l.onClose(),d.preventDefault()}),onKeyDown:oe(e.onKeyDown,d=>{var _;const h=d.currentTarget.contains(d.target),v=NS[l.dir].includes(d.key);h&&v&&(o.onOpenChange(!1),(_=a.trigger)==null||_.focus(),d.preventDefault())})})})})})});jh.displayName=Fh;function zh(e){return e?"open":"closed"}function fs(e){return e==="indeterminate"}function ll(e){return fs(e)?"indeterminate":e?"checked":"unchecked"}function US(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function YS(e,t){return e.map((n,i)=>e[(t+i)%e.length])}function ZS(e,t,n){const s=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let l=YS(e,Math.max(o,0));s.length===1&&(l=l.filter(f=>f!==n));const r=l.find(f=>f.toLowerCase().startsWith(s.toLowerCase()));return r!==n?r:void 0}function qS(e,t){const{x:n,y:i}=e;let s=!1;for(let o=0,l=t.length-1;o<t.length;l=o++){const a=t[o],r=t[l],f=a.x,d=a.y,h=r.x,v=r.y;d>i!=v>i&&n<(h-f)*(i-d)/(v-d)+f&&(s=!s)}return s}function GS(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return qS(n,t)}function vi(e){return t=>t.pointerType==="mouse"?e(t):void 0}var KS=xh,XS=el,QS=_h,JS=Ch,e4=sl,t4=Sh,n4=Ks,i4=Nh,s4=Th,r4=Ah,o4=Dh,l4=Lh,a4=Oh,c4=Ih,u4=Bh,d4=jh,Xs="DropdownMenu",[f4]=sS(Xs,[vh]),et=vh(),[h4,Hh]=f4(Xs),Vh=e=>{const{__scopeDropdownMenu:t,children:n,dir:i,open:s,defaultOpen:o,onOpenChange:l,modal:a=!0}=e,r=et(t),f=m.useRef(null),[d,h]=wt({prop:s,defaultProp:o??!1,onChange:l,caller:Xs});return g.jsx(h4,{scope:t,triggerId:it(),triggerRef:f,contentId:it(),open:d,onOpenChange:h,onOpenToggle:m.useCallback(()=>h(v=>!v),[h]),modal:a,children:g.jsx(KS,{...r,open:d,onOpenChange:h,dir:i,modal:a,children:n})})};Vh.displayName=Xs;var Wh="DropdownMenuTrigger",$h=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:i=!1,...s}=e,o=Hh(Wh,n),l=et(n);return g.jsx(XS,{asChild:!0,...l,children:g.jsx(hS.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":i?"":void 0,disabled:i,...s,ref:je(t,o.triggerRef),onPointerDown:oe(e.onPointerDown,a=>{!i&&a.button===0&&a.ctrlKey===!1&&(o.onOpenToggle(),o.open||a.preventDefault())}),onKeyDown:oe(e.onKeyDown,a=>{i||(["Enter"," "].includes(a.key)&&o.onOpenToggle(),a.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});$h.displayName=Wh;var p4="DropdownMenuPortal",Uh=e=>{const{__scopeDropdownMenu:t,...n}=e,i=et(t);return g.jsx(QS,{...i,...n})};Uh.displayName=p4;var Yh="DropdownMenuContent",Zh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...i}=e,s=Hh(Yh,n),o=et(n),l=m.useRef(!1);return g.jsx(JS,{id:s.contentId,"aria-labelledby":s.triggerId,...o,...i,ref:t,onCloseAutoFocus:oe(e.onCloseAutoFocus,a=>{var r;l.current||(r=s.triggerRef.current)==null||r.focus(),l.current=!1,a.preventDefault()}),onInteractOutside:oe(e.onInteractOutside,a=>{const r=a.detail.originalEvent,f=r.button===0&&r.ctrlKey===!0,d=r.button===2||f;(!s.modal||d)&&(l.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Zh.displayName=Yh;var m4="DropdownMenuGroup",qh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...i}=e,s=et(n);return g.jsx(e4,{...s,...i,ref:t})});qh.displayName=m4;var g4="DropdownMenuLabel",Gh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...i}=e,s=et(n);return g.jsx(t4,{...s,...i,ref:t})});Gh.displayName=g4;var v4="DropdownMenuItem",Kh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...i}=e,s=et(n);return g.jsx(n4,{...s,...i,ref:t})});Kh.displayName=v4;var b4="DropdownMenuCheckboxItem",Xh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...i}=e,s=et(n);return g.jsx(i4,{...s,...i,ref:t})});Xh.displayName=b4;var y4="DropdownMenuRadioGroup",Qh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...i}=e,s=et(n);return g.jsx(s4,{...s,...i,ref:t})});Qh.displayName=y4;var x4="DropdownMenuRadioItem",Jh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...i}=e,s=et(n);return g.jsx(r4,{...s,...i,ref:t})});Jh.displayName=x4;var w4="DropdownMenuItemIndicator",e0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...i}=e,s=et(n);return g.jsx(o4,{...s,...i,ref:t})});e0.displayName=w4;var _4="DropdownMenuSeparator",t0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...i}=e,s=et(n);return g.jsx(l4,{...s,...i,ref:t})});t0.displayName=_4;var C4="DropdownMenuArrow",S4=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...i}=e,s=et(n);return g.jsx(a4,{...s,...i,ref:t})});S4.displayName=C4;var E4=e=>{const{__scopeDropdownMenu:t,children:n,open:i,onOpenChange:s,defaultOpen:o}=e,l=et(t),[a,r]=wt({prop:i,defaultProp:o??!1,onChange:s,caller:"DropdownMenuSub"});return g.jsx(c4,{...l,open:a,onOpenChange:r,children:n})},N4="DropdownMenuSubTrigger",n0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...i}=e,s=et(n);return g.jsx(u4,{...s,...i,ref:t})});n0.displayName=N4;var k4="DropdownMenuSubContent",i0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...i}=e,s=et(n);return g.jsx(d4,{...s,...i,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});i0.displayName=k4;var T4=Vh,M4=$h,s0=Uh,r0=Zh,A4=qh,o0=Gh,l0=Kh,a0=Xh,R4=Qh,c0=Jh,u0=e0,d0=t0,D4=E4,f0=n0,h0=i0;const al=T4,cl=M4,L4=A4,O4=s0,P4=D4,I4=R4,p0=m.forwardRef(({className:e,inset:t,children:n,...i},s)=>g.jsxs(f0,{ref:s,className:ne("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...i,children:[n,g.jsx(_i,{className:"ml-auto h-4 w-4"})]}));p0.displayName=f0.displayName;const m0=m.forwardRef(({className:e,...t},n)=>g.jsx(h0,{ref:n,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));m0.displayName=h0.displayName;const Qs=m.forwardRef(({className:e,sideOffset:t=4,...n},i)=>g.jsx(s0,{children:g.jsx(r0,{ref:i,sideOffset:t,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Qs.displayName=r0.displayName;const bi=m.forwardRef(({className:e,inset:t,...n},i)=>g.jsx(l0,{ref:i,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));bi.displayName=l0.displayName;const g0=m.forwardRef(({className:e,children:t,checked:n,...i},s)=>g.jsxs(a0,{ref:s,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...i,children:[g.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:g.jsx(u0,{children:g.jsx(ui,{className:"h-4 w-4"})})}),t]}));g0.displayName=a0.displayName;const v0=m.forwardRef(({className:e,children:t,...n},i)=>g.jsxs(c0,{ref:i,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[g.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:g.jsx(u0,{children:g.jsx(ym,{className:"h-2 w-2 fill-current"})})}),t]}));v0.displayName=c0.displayName;const Js=m.forwardRef(({className:e,inset:t,...n},i)=>g.jsx(o0,{ref:i,className:ne("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Js.displayName=o0.displayName;const yi=m.forwardRef(({className:e,...t},n)=>g.jsx(d0,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));yi.displayName=d0.displayName;const b0=({className:e,...t})=>g.jsx("span",{className:ne("ml-auto text-xs tracking-widest opacity-60",e),...t});b0.displayName="DropdownMenuShortcut";function B4(e){const t=F4(e),n=m.forwardRef((i,s)=>{const{children:o,...l}=i,a=m.Children.toArray(o),r=a.find(z4);if(r){const f=r.props.children,d=a.map(h=>h===r?m.Children.count(f)>1?m.Children.only(null):m.isValidElement(f)?f.props.children:null:h);return g.jsx(t,{...l,ref:s,children:m.isValidElement(f)?m.cloneElement(f,void 0,d):null})}return g.jsx(t,{...l,ref:s,children:o})});return n.displayName=`${e}.Slot`,n}function F4(e){const t=m.forwardRef((n,i)=>{const{children:s,...o}=n;if(m.isValidElement(s)){const l=V4(s),a=H4(o,s.props);return s.type!==m.Fragment&&(a.ref=i?je(i,l):l),m.cloneElement(s,a)}return m.Children.count(s)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var j4=Symbol("radix.slottable");function z4(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===j4}function H4(e,t){const n={...t};for(const i in t){const s=e[i],o=t[i];/^on[A-Z]/.test(i)?s&&o?n[i]=(...a)=>{const r=o(...a);return s(...a),r}:s&&(n[i]=s):i==="style"?n[i]={...s,...o}:i==="className"&&(n[i]=[s,o].filter(Boolean).join(" "))}return{...e,...n}}function V4(e){var i,s;let t=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var W4=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Wi=W4.reduce((e,t)=>{const n=B4(`Primitive.${t}`),i=m.forwardRef((s,o)=>{const{asChild:l,...a}=s,r=l?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),g.jsx(r,{...a,ref:o})});return i.displayName=`Primitive.${t}`,{...e,[t]:i}},{});function $4(e,t=[]){let n=[];function i(o,l){const a=m.createContext(l),r=n.length;n=[...n,l];const f=h=>{var u;const{scope:v,children:_,...C}=h,S=((u=v==null?void 0:v[e])==null?void 0:u[r])||a,c=m.useMemo(()=>C,Object.values(C));return g.jsx(S.Provider,{value:c,children:_})};f.displayName=o+"Provider";function d(h,v){var S;const _=((S=v==null?void 0:v[e])==null?void 0:S[r])||a,C=m.useContext(_);if(C)return C;if(l!==void 0)return l;throw new Error(`\`${h}\` must be used within \`${o}\``)}return[f,d]}const s=()=>{const o=n.map(l=>m.createContext(l));return function(a){const r=(a==null?void 0:a[e])||o;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:r}}),[a,r])}};return s.scopeName=e,[i,U4(s,...t)]}function U4(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const l=i.reduce((a,{useScope:r,scopeName:f})=>{const h=r(o)[`__scope${f}`];return{...a,...h}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:l}),[l])}};return n.scopeName=t.scopeName,n}function Y4(e,t){return m.useReducer((n,i)=>t[n][i]??n,e)}var ul="ScrollArea",[y0]=$4(ul),[Z4,mt]=y0(ul),x0=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:i="hover",dir:s,scrollHideDelay:o=600,...l}=e,[a,r]=m.useState(null),[f,d]=m.useState(null),[h,v]=m.useState(null),[_,C]=m.useState(null),[S,c]=m.useState(null),[u,p]=m.useState(0),[b,y]=m.useState(0),[w,x]=m.useState(!1),[E,k]=m.useState(!1),N=ye(t,R=>r(R)),T=Ei(s);return g.jsx(Z4,{scope:n,type:i,dir:T,scrollHideDelay:o,scrollArea:a,viewport:f,onViewportChange:d,content:h,onContentChange:v,scrollbarX:_,onScrollbarXChange:C,scrollbarXEnabled:w,onScrollbarXEnabledChange:x,scrollbarY:S,onScrollbarYChange:c,scrollbarYEnabled:E,onScrollbarYEnabledChange:k,onCornerWidthChange:p,onCornerHeightChange:y,children:g.jsx(Wi.div,{dir:T,...l,ref:N,style:{position:"relative","--radix-scroll-area-corner-width":u+"px","--radix-scroll-area-corner-height":b+"px",...e.style}})})});x0.displayName=ul;var w0="ScrollAreaViewport",_0=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:i,nonce:s,...o}=e,l=mt(w0,n),a=m.useRef(null),r=ye(t,a,l.onViewportChange);return g.jsxs(g.Fragment,{children:[g.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),g.jsx(Wi.div,{"data-radix-scroll-area-viewport":"",...o,ref:r,style:{overflowX:l.scrollbarXEnabled?"scroll":"hidden",overflowY:l.scrollbarYEnabled?"scroll":"hidden",...e.style},children:g.jsx("div",{ref:l.onContentChange,style:{minWidth:"100%",display:"table"},children:i})})]})});_0.displayName=w0;var Ot="ScrollAreaScrollbar",dl=m.forwardRef((e,t)=>{const{forceMount:n,...i}=e,s=mt(Ot,e.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:l}=s,a=e.orientation==="horizontal";return m.useEffect(()=>(a?o(!0):l(!0),()=>{a?o(!1):l(!1)}),[a,o,l]),s.type==="hover"?g.jsx(q4,{...i,ref:t,forceMount:n}):s.type==="scroll"?g.jsx(G4,{...i,ref:t,forceMount:n}):s.type==="auto"?g.jsx(C0,{...i,ref:t,forceMount:n}):s.type==="always"?g.jsx(fl,{...i,ref:t}):null});dl.displayName=Ot;var q4=m.forwardRef((e,t)=>{const{forceMount:n,...i}=e,s=mt(Ot,e.__scopeScrollArea),[o,l]=m.useState(!1);return m.useEffect(()=>{const a=s.scrollArea;let r=0;if(a){const f=()=>{window.clearTimeout(r),l(!0)},d=()=>{r=window.setTimeout(()=>l(!1),s.scrollHideDelay)};return a.addEventListener("pointerenter",f),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(r),a.removeEventListener("pointerenter",f),a.removeEventListener("pointerleave",d)}}},[s.scrollArea,s.scrollHideDelay]),g.jsx(Ke,{present:n||o,children:g.jsx(C0,{"data-state":o?"visible":"hidden",...i,ref:t})})}),G4=m.forwardRef((e,t)=>{const{forceMount:n,...i}=e,s=mt(Ot,e.__scopeScrollArea),o=e.orientation==="horizontal",l=tr(()=>r("SCROLL_END"),100),[a,r]=Y4("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return m.useEffect(()=>{if(a==="idle"){const f=window.setTimeout(()=>r("HIDE"),s.scrollHideDelay);return()=>window.clearTimeout(f)}},[a,s.scrollHideDelay,r]),m.useEffect(()=>{const f=s.viewport,d=o?"scrollLeft":"scrollTop";if(f){let h=f[d];const v=()=>{const _=f[d];h!==_&&(r("SCROLL"),l()),h=_};return f.addEventListener("scroll",v),()=>f.removeEventListener("scroll",v)}},[s.viewport,o,r,l]),g.jsx(Ke,{present:n||a!=="hidden",children:g.jsx(fl,{"data-state":a==="hidden"?"hidden":"visible",...i,ref:t,onPointerEnter:oe(e.onPointerEnter,()=>r("POINTER_ENTER")),onPointerLeave:oe(e.onPointerLeave,()=>r("POINTER_LEAVE"))})})}),C0=m.forwardRef((e,t)=>{const n=mt(Ot,e.__scopeScrollArea),{forceMount:i,...s}=e,[o,l]=m.useState(!1),a=e.orientation==="horizontal",r=tr(()=>{if(n.viewport){const f=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;l(a?f:d)}},10);return jn(n.viewport,r),jn(n.content,r),g.jsx(Ke,{present:i||o,children:g.jsx(fl,{"data-state":o?"visible":"hidden",...s,ref:t})})}),fl=m.forwardRef((e,t)=>{const{orientation:n="vertical",...i}=e,s=mt(Ot,e.__scopeScrollArea),o=m.useRef(null),l=m.useRef(0),[a,r]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),f=T0(a.viewport,a.content),d={...i,sizes:a,onSizesChange:r,hasThumb:f>0&&f<1,onThumbChange:v=>o.current=v,onThumbPointerUp:()=>l.current=0,onThumbPointerDown:v=>l.current=v};function h(v,_){return t3(v,l.current,a,_)}return n==="horizontal"?g.jsx(K4,{...d,ref:t,onThumbPositionChange:()=>{if(s.viewport&&o.current){const v=s.viewport.scrollLeft,_=ja(v,a,s.dir);o.current.style.transform=`translate3d(${_}px, 0, 0)`}},onWheelScroll:v=>{s.viewport&&(s.viewport.scrollLeft=v)},onDragScroll:v=>{s.viewport&&(s.viewport.scrollLeft=h(v,s.dir))}}):n==="vertical"?g.jsx(X4,{...d,ref:t,onThumbPositionChange:()=>{if(s.viewport&&o.current){const v=s.viewport.scrollTop,_=ja(v,a);o.current.style.transform=`translate3d(0, ${_}px, 0)`}},onWheelScroll:v=>{s.viewport&&(s.viewport.scrollTop=v)},onDragScroll:v=>{s.viewport&&(s.viewport.scrollTop=h(v))}}):null}),K4=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:i,...s}=e,o=mt(Ot,e.__scopeScrollArea),[l,a]=m.useState(),r=m.useRef(null),f=ye(t,r,o.onScrollbarXChange);return m.useEffect(()=>{r.current&&a(getComputedStyle(r.current))},[r]),g.jsx(E0,{"data-orientation":"horizontal",...s,ref:f,sizes:n,style:{bottom:0,left:o.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:o.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":er(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,h)=>{if(o.viewport){const v=o.viewport.scrollLeft+d.deltaX;e.onWheelScroll(v),A0(v,h)&&d.preventDefault()}},onResize:()=>{r.current&&o.viewport&&l&&i({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:r.current.clientWidth,paddingStart:ps(l.paddingLeft),paddingEnd:ps(l.paddingRight)}})}})}),X4=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:i,...s}=e,o=mt(Ot,e.__scopeScrollArea),[l,a]=m.useState(),r=m.useRef(null),f=ye(t,r,o.onScrollbarYChange);return m.useEffect(()=>{r.current&&a(getComputedStyle(r.current))},[r]),g.jsx(E0,{"data-orientation":"vertical",...s,ref:f,sizes:n,style:{top:0,right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":er(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,h)=>{if(o.viewport){const v=o.viewport.scrollTop+d.deltaY;e.onWheelScroll(v),A0(v,h)&&d.preventDefault()}},onResize:()=>{r.current&&o.viewport&&l&&i({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:r.current.clientHeight,paddingStart:ps(l.paddingTop),paddingEnd:ps(l.paddingBottom)}})}})}),[Q4,S0]=y0(Ot),E0=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:i,hasThumb:s,onThumbChange:o,onThumbPointerUp:l,onThumbPointerDown:a,onThumbPositionChange:r,onDragScroll:f,onWheelScroll:d,onResize:h,...v}=e,_=mt(Ot,n),[C,S]=m.useState(null),c=ye(t,N=>S(N)),u=m.useRef(null),p=m.useRef(""),b=_.viewport,y=i.content-i.viewport,w=Ze(d),x=Ze(r),E=tr(h,10);function k(N){if(u.current){const T=N.clientX-u.current.left,R=N.clientY-u.current.top;f({x:T,y:R})}}return m.useEffect(()=>{const N=T=>{const R=T.target;(C==null?void 0:C.contains(R))&&w(T,y)};return document.addEventListener("wheel",N,{passive:!1}),()=>document.removeEventListener("wheel",N,{passive:!1})},[b,C,y,w]),m.useEffect(x,[i,x]),jn(C,E),jn(_.content,E),g.jsx(Q4,{scope:n,scrollbar:C,hasThumb:s,onThumbChange:Ze(o),onThumbPointerUp:Ze(l),onThumbPositionChange:x,onThumbPointerDown:Ze(a),children:g.jsx(Wi.div,{...v,ref:c,style:{position:"absolute",...v.style},onPointerDown:oe(e.onPointerDown,N=>{N.button===0&&(N.target.setPointerCapture(N.pointerId),u.current=C.getBoundingClientRect(),p.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",_.viewport&&(_.viewport.style.scrollBehavior="auto"),k(N))}),onPointerMove:oe(e.onPointerMove,k),onPointerUp:oe(e.onPointerUp,N=>{const T=N.target;T.hasPointerCapture(N.pointerId)&&T.releasePointerCapture(N.pointerId),document.body.style.webkitUserSelect=p.current,_.viewport&&(_.viewport.style.scrollBehavior=""),u.current=null})})})}),hs="ScrollAreaThumb",N0=m.forwardRef((e,t)=>{const{forceMount:n,...i}=e,s=S0(hs,e.__scopeScrollArea);return g.jsx(Ke,{present:n||s.hasThumb,children:g.jsx(J4,{ref:t,...i})})}),J4=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:i,...s}=e,o=mt(hs,n),l=S0(hs,n),{onThumbPositionChange:a}=l,r=ye(t,h=>l.onThumbChange(h)),f=m.useRef(void 0),d=tr(()=>{f.current&&(f.current(),f.current=void 0)},100);return m.useEffect(()=>{const h=o.viewport;if(h){const v=()=>{if(d(),!f.current){const _=n3(h,a);f.current=_,a()}};return a(),h.addEventListener("scroll",v),()=>h.removeEventListener("scroll",v)}},[o.viewport,d,a]),g.jsx(Wi.div,{"data-state":l.hasThumb?"visible":"hidden",...s,ref:r,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...i},onPointerDownCapture:oe(e.onPointerDownCapture,h=>{const _=h.target.getBoundingClientRect(),C=h.clientX-_.left,S=h.clientY-_.top;l.onThumbPointerDown({x:C,y:S})}),onPointerUp:oe(e.onPointerUp,l.onThumbPointerUp)})});N0.displayName=hs;var hl="ScrollAreaCorner",k0=m.forwardRef((e,t)=>{const n=mt(hl,e.__scopeScrollArea),i=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&i?g.jsx(e3,{...e,ref:t}):null});k0.displayName=hl;var e3=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...i}=e,s=mt(hl,n),[o,l]=m.useState(0),[a,r]=m.useState(0),f=!!(o&&a);return jn(s.scrollbarX,()=>{var h;const d=((h=s.scrollbarX)==null?void 0:h.offsetHeight)||0;s.onCornerHeightChange(d),r(d)}),jn(s.scrollbarY,()=>{var h;const d=((h=s.scrollbarY)==null?void 0:h.offsetWidth)||0;s.onCornerWidthChange(d),l(d)}),f?g.jsx(Wi.div,{...i,ref:t,style:{width:o,height:a,position:"absolute",right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function ps(e){return e?parseInt(e,10):0}function T0(e,t){const n=e/t;return isNaN(n)?0:n}function er(e){const t=T0(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,i=(e.scrollbar.size-n)*t;return Math.max(i,18)}function t3(e,t,n,i="ltr"){const s=er(n),o=s/2,l=t||o,a=s-l,r=n.scrollbar.paddingStart+l,f=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,h=i==="ltr"?[0,d]:[d*-1,0];return M0([r,f],h)(e)}function ja(e,t,n="ltr"){const i=er(t),s=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,o=t.scrollbar.size-s,l=t.content-t.viewport,a=o-i,r=n==="ltr"?[0,l]:[l*-1,0],f=Rr(e,r);return M0([0,l],[0,a])(f)}function M0(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const i=(t[1]-t[0])/(e[1]-e[0]);return t[0]+i*(n-e[0])}}function A0(e,t){return e>0&&e<t}var n3=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},i=0;return function s(){const o={left:e.scrollLeft,top:e.scrollTop},l=n.left!==o.left,a=n.top!==o.top;(l||a)&&t(),n=o,i=window.requestAnimationFrame(s)}(),()=>window.cancelAnimationFrame(i)};function tr(e,t){const n=Ze(e),i=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(i.current),[]),m.useCallback(()=>{window.clearTimeout(i.current),i.current=window.setTimeout(n,t)},[n,t])}function jn(e,t){const n=Ze(t);$e(()=>{let i=0;if(e){const s=new ResizeObserver(()=>{cancelAnimationFrame(i),i=window.requestAnimationFrame(n)});return s.observe(e),()=>{window.cancelAnimationFrame(i),s.unobserve(e)}}},[e,n])}var R0=x0,i3=_0,s3=k0;const D0=m.forwardRef(({className:e,children:t,...n},i)=>g.jsxs(R0,{ref:i,className:ne("relative overflow-hidden",e),...n,children:[g.jsx(i3,{className:"h-full w-full rounded-[inherit]",children:t}),g.jsx(pl,{}),g.jsx(s3,{})]}));D0.displayName=R0.displayName;const pl=m.forwardRef(({className:e,orientation:t="vertical",...n},i)=>g.jsx(dl,{ref:i,orientation:t,className:ne("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:g.jsx(N0,{className:"relative flex-1 rounded-full bg-border"})}));pl.displayName=dl.displayName;const L0=bs("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",success:"border-green-500/50 text-green-700 dark:text-green-400 [&>svg]:text-green-500",warning:"border-yellow-500/50 text-yellow-700 dark:text-yellow-400 [&>svg]:text-yellow-500",info:"border-blue-500/50 text-blue-700 dark:text-blue-400 [&>svg]:text-blue-500"}},defaultVariants:{variant:"default"}}),ml=m.forwardRef(({className:e,variant:t,...n},i)=>g.jsx("div",{ref:i,role:"alert",className:ne(L0({variant:t}),e),...n}));ml.displayName="Alert";const gl=m.forwardRef(({className:e,...t},n)=>g.jsx("h5",{ref:n,className:ne("mb-1 font-medium leading-none tracking-tight",e),...t}));gl.displayName="AlertTitle";const vl=m.forwardRef(({className:e,...t},n)=>g.jsx("div",{ref:n,className:ne("text-sm [&_p]:leading-relaxed",e),...t}));vl.displayName="AlertDescription";const O0=m.forwardRef(({variant:e,title:t,children:n,className:i,...s},o)=>{const l={default:Yl,destructive:bm,success:vm,warning:gm,info:Yl},a=l[e]||l.default;return g.jsxs(ml,{ref:o,variant:e,className:i,...s,children:[g.jsx(a,{className:"h-4 w-4"}),t&&g.jsx(gl,{children:t}),n&&g.jsx(vl,{children:n})]})});O0.displayName="AlertWithIcon";const bl=m.forwardRef(({className:e,...t},n)=>g.jsx("div",{className:"relative w-full overflow-auto",children:g.jsx("table",{ref:n,className:ne("w-full caption-bottom text-sm",e),...t})}));bl.displayName="Table";const yl=m.forwardRef(({className:e,...t},n)=>g.jsx("thead",{ref:n,className:ne("[&_tr]:border-b",e),...t}));yl.displayName="TableHeader";const xl=m.forwardRef(({className:e,...t},n)=>g.jsx("tbody",{ref:n,className:ne("[&_tr:last-child]:border-0",e),...t}));xl.displayName="TableBody";const P0=m.forwardRef(({className:e,...t},n)=>g.jsx("tfoot",{ref:n,className:ne("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));P0.displayName="TableFooter";const En=m.forwardRef(({className:e,...t},n)=>g.jsx("tr",{ref:n,className:ne("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...t}));En.displayName="TableRow";const li=m.forwardRef(({className:e,...t},n)=>g.jsx("th",{ref:n,className:ne("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",e),...t}));li.displayName="TableHead";const ln=m.forwardRef(({className:e,...t},n)=>g.jsx("td",{ref:n,className:ne("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));ln.displayName="TableCell";const I0=m.forwardRef(({className:e,...t},n)=>g.jsx("caption",{ref:n,className:ne("mt-4 text-sm text-muted-foreground",e),...t}));I0.displayName="TableCaption";const wl=m.forwardRef(({options:e=[],value:t,onChange:n,onSearch:i,placeholder:s="Select...",searchPlaceholder:o="Search...",loading:l=!1,disabled:a=!1,multiple:r=!1,clearable:f=!0,className:d,renderOption:h,renderValue:v,getOptionLabel:_=y=>(y==null?void 0:y.label)||(y==null?void 0:y.name)||String(y),getOptionValue:C=y=>(y==null?void 0:y.value)||(y==null?void 0:y.id)||y,filterOption:S,noOptionsMessage:c="No options found",loadingMessage:u="Loading...",...p},b)=>{const[y,w]=m.useState(!1),[x,E]=m.useState(""),[k,N]=m.useState(0),T=m.useRef(null),R=m.useRef(null),M=m.useMemo(()=>x?S?e.filter(B=>S(B,x)):e.filter(B=>_(B).toLowerCase().includes(x.toLowerCase())):e,[e,x,S,_]),A=m.useMemo(()=>uc(B=>{i==null||i(B)},300),[i]),D=B=>{const L=B.target.value;E(L),N(0),A(L)},$=B=>{if(r){const L=Array.isArray(t)?t:[],U=C(B);L.some(W=>C(W)===U)?n==null||n(L.filter(W=>C(W)!==U)):n==null||n([...L,B])}else n==null||n(B),w(!1),E("")},H=B=>{B.stopPropagation(),n==null||n(r?[]:null),E("")},j=B=>{if(!y){(B.key==="Enter"||B.key===" "||B.key==="ArrowDown")&&(B.preventDefault(),w(!0));return}switch(B.key){case"ArrowDown":B.preventDefault(),N(L=>Math.min(L+1,M.length-1));break;case"ArrowUp":B.preventDefault(),N(L=>Math.max(L-1,0));break;case"Enter":B.preventDefault(),M[k]&&$(M[k]);break;case"Escape":B.preventDefault(),w(!1),E("");break}};m.useEffect(()=>{const B=L=>{T.current&&!T.current.contains(L.target)&&(w(!1),E(""))};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[]);const F=B=>r?(Array.isArray(t)?t:[]).some(O=>(typeof O=="object"&&O!==null?C(O):O)===C(B)):t?(typeof t=="object"&&t!==null?C(t):t)===C(B):!1,z=r?Array.isArray(t)&&t.length>0:!!t,P=()=>{if(!z)return g.jsx("span",{className:"text-muted-foreground",children:s});if(v)return v(t);if(r){const L=Array.isArray(t)?t:[];if(L.length===1){const U=L[0],O=e.find(W=>{const Q=C(W),V=typeof U=="object"&&U!==null?C(U):U;return Q===V});return O?_(O):String(U)}return`${L.length} selected`}const B=e.find(L=>{const U=C(L),O=typeof t=="object"&&t!==null?C(t):t;return U===O});return B?_(B):String(t)};return g.jsxs("div",{ref:T,className:ne("relative w-full",d),...p,children:[g.jsxs("button",{ref:b,type:"button",role:"combobox","aria-expanded":y,"aria-haspopup":"listbox",disabled:a,onClick:()=>w(!y),onKeyDown:j,className:ne("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",y&&"ring-2 ring-ring ring-offset-2"),children:[g.jsx("span",{className:"flex-1 text-left truncate",children:P()}),g.jsxs("div",{className:"flex items-center gap-1",children:[f&&z&&!a&&g.jsx(Mn,{className:"h-4 w-4 opacity-50 hover:opacity-100 cursor-pointer",onClick:H}),g.jsx(ys,{className:ne("h-4 w-4 opacity-50 transition-transform",y&&"rotate-180")})]})]}),y&&g.jsxs("div",{className:"absolute z-50 mt-1 w-full rounded-md border bg-popover text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95",children:[g.jsxs("div",{className:"flex items-center border-b px-3",children:[g.jsx(to,{className:"h-4 w-4 shrink-0 opacity-50"}),g.jsx("input",{ref:R,type:"text",value:x,onChange:D,placeholder:o,className:"flex h-10 w-full bg-transparent py-3 pl-2 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",autoFocus:!0}),l&&g.jsx(un,{className:"h-4 w-4 animate-spin"})]}),g.jsx("div",{className:"max-h-60 overflow-auto p-1",children:l&&M.length===0?g.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:u}):M.length===0?g.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:c}):M.map((B,L)=>g.jsxs("div",{role:"option","aria-selected":F(B),onClick:()=>$(B),onMouseEnter:()=>N(L),className:ne("relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none",k===L&&"bg-accent text-accent-foreground",F(B)&&"bg-accent/50"),children:[r&&g.jsx("div",{className:ne("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",F(B)&&"bg-primary text-primary-foreground"),children:F(B)&&g.jsx(ui,{className:"h-3 w-3"})}),h?h(B):g.jsx("span",{className:"flex-1",children:_(B)}),!r&&F(B)&&g.jsx(ui,{className:"ml-auto h-4 w-4"})]},C(B)))})]})]})});wl.displayName="SearchSelect";const $t=m.forwardRef(({className:e,label:t,description:n,error:i,required:s,children:o,...l},a)=>{const r=m.useId();return g.jsxs("div",{ref:a,className:ne("space-y-2",e),...l,children:[t&&g.jsxs(Kt,{htmlFor:r,className:ne(i&&"text-destructive"),children:[t,s&&g.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),m.Children.map(o,f=>m.isValidElement(f)?m.cloneElement(f,{id:r,"aria-invalid":!!i}):f),n&&!i&&g.jsx("p",{className:"text-sm text-muted-foreground",children:n}),i&&g.jsx("p",{className:"text-sm text-destructive",children:i})]})});$t.displayName="FormField";const ms=m.forwardRef(({label:e,description:t,error:n,required:i,className:s,inputClassName:o,onChange:l,...a},r)=>{const f=d=>{l==null||l(d.target.value)};return g.jsx($t,{label:e,description:t,error:n,required:i,className:s,children:g.jsx(Ln,{ref:r,className:ne(n&&"border-destructive",o),onChange:f,...a})})});ms.displayName="QInput";const _l=m.forwardRef(({label:e,description:t,error:n,required:i,className:s,textareaClassName:o,onChange:l,...a},r)=>{const f=d=>{l==null||l(d.target.value)};return g.jsx($t,{label:e,description:t,error:n,required:i,className:s,children:g.jsx(no,{ref:r,className:ne(n&&"border-destructive",o),onChange:f,...a})})});_l.displayName="QTextarea";const Cl=m.forwardRef(({label:e,description:t,error:n,required:i,options:s=[],placeholder:o="Select...",className:l,value:a,onChange:r,getOptionLabel:f,getOptionValue:d,optionLabel:h,optionValue:v,..._},C)=>{const S=f||(typeof h=="function"?h:h?u=>u==null?void 0:u[h]:u=>(u==null?void 0:u.label)||(u==null?void 0:u.name)||(u==null?void 0:u.display_name)||String(u)),c=d||(typeof v=="function"?v:v?u=>u==null?void 0:u[v]:u=>(u==null?void 0:u.value)||(u==null?void 0:u.id)||u);return g.jsx($t,{label:e,description:t,error:n,required:i,className:l,children:g.jsxs(xo,{value:a,onValueChange:r,..._,children:[g.jsx(Os,{ref:C,className:ne(n&&"border-destructive"),children:g.jsx(wo,{placeholder:o})}),g.jsx(Ps,{children:s.map(u=>g.jsx(Is,{value:String(c(u)),children:S(u)},c(u)))})]})})});Cl.displayName="QSelect";const Sl=m.forwardRef(({label:e,description:t,error:n,required:i,className:s,value:o,onChange:l,getOptionLabel:a,getOptionValue:r,optionLabel:f,optionValue:d,...h},v)=>{const _=a||(typeof f=="function"?f:f?c=>c==null?void 0:c[f]:c=>(c==null?void 0:c.label)||(c==null?void 0:c.name)||(c==null?void 0:c.display_name)||String(c)),C=r||(typeof d=="function"?d:d?c=>c==null?void 0:c[d]:c=>(c==null?void 0:c.value)||(c==null?void 0:c.id)||c),S=c=>{if(c==null)l==null||l(null);else{const u=C(c);l==null||l(u)}};return g.jsx($t,{label:e,description:t,error:n,required:i,className:s,children:g.jsx(wl,{ref:v,value:o,onChange:S,getOptionLabel:_,getOptionValue:C,...h})})});Sl.displayName="QSearchSelect";const El=m.forwardRef(({label:e,description:t,error:n,className:i,checked:s,onCheckedChange:o,onChange:l,...a},r)=>{const f=m.useId(),d=h=>{l==null||l(h),o==null||o(h)};return g.jsxs("div",{className:ne("flex items-center justify-between space-x-2",i),children:[g.jsxs("div",{className:"space-y-0.5",children:[e&&g.jsx(Kt,{htmlFor:f,className:"text-base",children:e}),t&&g.jsx("p",{className:"text-sm text-muted-foreground",children:t}),n&&g.jsx("p",{className:"text-sm text-destructive",children:n})]}),g.jsx(ao,{ref:r,id:f,checked:s,onCheckedChange:d,...a})]})});El.displayName="QSwitch";const Nl=m.forwardRef(({label:e,description:t,error:n,className:i,checked:s,onCheckedChange:o,...l},a)=>{const r=m.useId();return g.jsxs("div",{className:ne("flex items-start space-x-2",i),children:[g.jsx(On,{ref:a,id:r,checked:s,onCheckedChange:o,className:"mt-1",...l}),g.jsxs("div",{className:"space-y-1 leading-none",children:[e&&g.jsx(Kt,{htmlFor:r,children:e}),t&&g.jsx("p",{className:"text-sm text-muted-foreground",children:t}),n&&g.jsx("p",{className:"text-sm text-destructive",children:n})]})]})});Nl.displayName="QCheckbox";const B0=m.forwardRef(({onSubmit:e,className:t,children:n,...i},s)=>{const o=l=>{l.preventDefault(),e==null||e(l)};return g.jsx("form",{ref:s,onSubmit:o,className:ne("space-y-4",t),...i,children:n})});B0.displayName="QForm";const F0=m.forwardRef(({label:e,description:t,error:n,required:i,className:s,value:o,onChange:l,placeholder:a="Pick a date",...r},f)=>g.jsx($t,{label:e,description:t,error:n,required:i,className:s,children:g.jsx(Go,{ref:f,date:o,onDateChange:l,placeholder:a,...r})}));F0.displayName="QDatePicker";const j0=m.forwardRef(({label:e,description:t,error:n,required:i,className:s,value:o,onChange:l,placeholder:a="Pick a date range",...r},f)=>g.jsx($t,{label:e,description:t,error:n,required:i,className:s,children:g.jsx(Ko,{ref:f,dateRange:o,onDateRangeChange:l,placeholder:a,...r})}));j0.displayName="QDateRangePicker";const z0=m.forwardRef(({label:e,description:t,error:n,required:i,className:s,value:o,onChange:l,placeholder:a="Start writing...",height:r="200px",...f},d)=>g.jsx($t,{label:e,description:t,error:n,required:i,className:s,children:g.jsx(Jo,{ref:d,value:o,onChange:l,placeholder:a,height:r,...f})}));z0.displayName="QRichTextEditor";const kl=({currentPage:e=1,totalPages:t=1,totalItems:n=0,pageSize:i=10,pageSizeOptions:s=[10,20,50,100],onPageChange:o,onPageSizeChange:l,showPageSizeSelector:a=!0,showInfo:r=!0,className:f})=>{const d=(e-1)*i+1,h=Math.min(e*i,n),v=e>1,_=e<t,C=()=>{const S=[];if(t<=5)for(let u=1;u<=t;u++)S.push(u);else{S.push(1),e>3&&S.push("...");const u=Math.max(2,e-1),p=Math.min(t-1,e+1);for(let b=u;b<=p;b++)S.push(b);e<t-2&&S.push("..."),t>1&&S.push(t)}return S};return g.jsxs("div",{className:ne("flex flex-col sm:flex-row items-center justify-between gap-4 px-2 py-4",f),children:[g.jsxs("div",{className:"flex items-center gap-4",children:[a&&g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("span",{className:"text-sm text-muted-foreground",children:"Rows per page"}),g.jsxs(xo,{value:String(i),onValueChange:S=>l==null?void 0:l(Number(S)),children:[g.jsx(Os,{className:"h-8 w-[70px]",children:g.jsx(wo,{placeholder:i})}),g.jsx(Ps,{side:"top",children:s.map(S=>g.jsx(Is,{value:String(S),children:S},S))})]})]}),r&&n>0&&g.jsxs("span",{className:"text-sm text-muted-foreground",children:["Showing ",d," to ",h," of ",n," results"]})]}),g.jsxs("div",{className:"flex items-center gap-1",children:[g.jsxs(we,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>o==null?void 0:o(1),disabled:!v,children:[g.jsx(pm,{className:"h-4 w-4"}),g.jsx("span",{className:"sr-only",children:"First page"})]}),g.jsxs(we,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>o==null?void 0:o(e-1),disabled:!v,children:[g.jsx(eo,{className:"h-4 w-4"}),g.jsx("span",{className:"sr-only",children:"Previous page"})]}),g.jsx("div",{className:"flex items-center gap-1",children:C().map((S,c)=>S==="..."?g.jsx("span",{className:"px-2 text-muted-foreground",children:"..."},`ellipsis-${c}`):g.jsx(we,{variant:e===S?"default":"outline",size:"icon",className:"h-8 w-8",onClick:()=>o==null?void 0:o(S),children:S},S))}),g.jsxs(we,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>o==null?void 0:o(e+1),disabled:!_,children:[g.jsx(_i,{className:"h-4 w-4"}),g.jsx("span",{className:"sr-only",children:"Next page"})]}),g.jsxs(we,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>o==null?void 0:o(t),disabled:!_,children:[g.jsx(mm,{className:"h-4 w-4"}),g.jsx("span",{className:"sr-only",children:"Last page"})]})]})]})};kl.displayName="Pagination";const zn=({variant:e="spinner",size:t="default",text:n,className:i,fullScreen:s=!1,overlay:o=!1})=>{const l={sm:"h-4 w-4",default:"h-8 w-8",lg:"h-12 w-12",xl:"h-16 w-16"},a=ne("flex flex-col items-center justify-center gap-3",s&&"fixed inset-0 z-50",o&&"bg-background/80 backdrop-blur-sm",i),r=()=>{switch(e){case"spinner":return g.jsx(un,{className:ne("animate-spin text-primary",l[t])});case"dots":return g.jsx("div",{className:"flex gap-1",children:[0,1,2].map(f=>g.jsx("div",{className:ne("rounded-full bg-primary animate-bounce",t==="sm"&&"h-1.5 w-1.5",t==="default"&&"h-2 w-2",t==="lg"&&"h-3 w-3",t==="xl"&&"h-4 w-4"),style:{animationDelay:`${f*.15}s`}},f))});case"pulse":return g.jsx("div",{className:ne("rounded-full bg-primary animate-pulse",l[t])});case"skeleton":return g.jsxs("div",{className:"space-y-3 w-full max-w-sm",children:[g.jsx("div",{className:"h-4 bg-muted rounded animate-pulse"}),g.jsx("div",{className:"h-4 bg-muted rounded animate-pulse w-3/4"}),g.jsx("div",{className:"h-4 bg-muted rounded animate-pulse w-1/2"})]});default:return g.jsx(un,{className:ne("animate-spin text-primary",l[t])})}};return g.jsxs("div",{className:a,children:[r(),n&&g.jsx("p",{className:"text-sm text-muted-foreground animate-pulse",children:n})]})};zn.displayName="Loading";const H0=({loading:e,children:t,text:n,className:i})=>g.jsxs("div",{className:ne("relative",i),children:[t,e&&g.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/80 backdrop-blur-sm rounded-lg",children:g.jsx(zn,{text:n})})]});H0.displayName="LoadingOverlay";const V0=m.forwardRef(({loading:e,loadingText:t,children:n,disabled:i,className:s,...o},l)=>g.jsx(we,{ref:l,disabled:i||e,className:s,...o,children:e?g.jsxs(g.Fragment,{children:[g.jsx(un,{className:"mr-2 h-4 w-4 animate-spin"}),t||"Loading..."]}):n}));V0.displayName="LoadingButton";const Gn=({icon:e=Ul,title:t="No data found",description:n="There are no items to display.",action:i,actionLabel:s,onAction:o,variant:l="default",className:a,children:r})=>{const f={default:{icon:Ul,title:"No data found",description:"There are no items to display."},search:{icon:to,title:"No results found",description:"Try adjusting your search or filters to find what you're looking for."},empty:{icon:fc,title:"Get started",description:"Create your first item to get started."},error:{icon:hc,title:"Something went wrong",description:"There was an error loading the data. Please try again."}},d=f[l]||f.default,h=e||d.icon,v=t||d.title,_=n||d.description;return g.jsxs("div",{className:ne("flex flex-col items-center justify-center py-12 px-4 text-center",a),children:[g.jsx("div",{className:"rounded-full bg-muted p-4 mb-4",children:g.jsx(h,{className:"h-8 w-8 text-muted-foreground"})}),g.jsx("h3",{className:"text-lg font-semibold mb-2",children:v}),g.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-sm",children:_}),r,(i||o)&&g.jsx(we,{onClick:o,children:s||"Take Action"})]})};Gn.displayName="EmptyState";const Tl=({searchTerm:e,onClear:t,className:n})=>g.jsx(Gn,{variant:"search",title:`No results for "${e}"`,description:"Try searching with different keywords or check your filters.",className:n,children:t&&g.jsx(we,{variant:"outline",onClick:t,children:"Clear Search"})});Tl.displayName="SearchEmptyState";const W0=({itemName:e="item",onCreate:t,className:n})=>g.jsx(Gn,{variant:"empty",icon:fc,title:`No ${e}s yet`,description:`Create your first ${e} to get started.`,onAction:t,actionLabel:`Create ${e}`,className:n});W0.displayName="CreateEmptyState";const $0=({error:e,onRetry:t,className:n})=>g.jsx(Gn,{variant:"error",title:"Error loading data",description:(e==null?void 0:e.message)||"Something went wrong. Please try again.",onAction:t,actionLabel:"Try Again",className:n});$0.displayName="ErrorState";const nr=({open:e,onOpenChange:t,title:n,description:i,children:s,footer:o,size:l="default",showClose:a=!0,className:r,...f})=>{const d={sm:"max-w-sm",default:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-[95vw]"};return g.jsx(Sd,{open:e,onOpenChange:t,...f,children:g.jsxs(To,{className:ne(d[l],r),children:[(n||i)&&g.jsxs(Mo,{children:[n&&g.jsx(Ao,{children:n}),i&&g.jsx(Ro,{children:i})]}),s,o&&g.jsx(Fs,{children:o})]})})};nr.displayName="Modal";const Ml=({open:e,onOpenChange:t,onConfirm:n,onCancel:i,title:s="Are you sure?",description:o="This action cannot be undone.",confirmText:l="Confirm",cancelText:a="Cancel",variant:r="default",loading:f=!1,className:d})=>{const h=async()=>{await(n==null?void 0:n())},v=()=>{i==null||i(),t==null||t(!1)};return g.jsx(nr,{open:e,onOpenChange:t,title:s,description:o,size:"sm",className:d,footer:g.jsxs("div",{className:"flex gap-2 justify-end",children:[g.jsx(we,{variant:"outline",onClick:v,disabled:f,children:a}),g.jsx(we,{variant:r==="destructive"?"destructive":"default",onClick:h,disabled:f,children:f?"Loading...":l})]})})};Ml.displayName="ConfirmModal";const xi=({open:e,onOpenChange:t,onConfirm:n,itemName:i="item",loading:s=!1})=>g.jsx(Ml,{open:e,onOpenChange:t,onConfirm:n,title:`Delete ${i}?`,description:`Are you sure you want to delete this ${i}? This action cannot be undone.`,confirmText:"Delete",variant:"destructive",loading:s});xi.displayName="DeleteConfirmModal";const U0=({open:e,onOpenChange:t,onSubmit:n,title:i,description:s,children:o,submitText:l="Save",cancelText:a="Cancel",loading:r=!1,size:f="default",className:d})=>{const h=async v=>{v==null||v.preventDefault(),await(n==null?void 0:n())};return g.jsx(nr,{open:e,onOpenChange:t,title:i,description:s,size:f,className:d,children:g.jsxs("form",{onSubmit:h,children:[g.jsx("div",{className:"py-4",children:o}),g.jsxs(Fs,{children:[g.jsx(we,{type:"button",variant:"outline",onClick:()=>t==null?void 0:t(!1),disabled:r,children:a}),g.jsx(we,{type:"submit",disabled:r,children:r?"Saving...":l})]})]})})};U0.displayName="FormModal";const Al=({data:e=[],columns:t=[],loading:n=!1,error:i=null,pagination:s=null,currentPage:o=1,pageSize:l=10,totalItems:a=0,totalPages:r=1,onPageChange:f,onPageSizeChange:d,sortable:h=!0,sortColumn:v=null,sortDirection:_=null,onSort:C,searchable:S=!0,searchValue:c="",onSearchChange:u,searchPlaceholder:p="Search...",selectable:b=!1,selectedRows:y=[],onSelectionChange:w,actions:x=[],onRowClick:E,striped:k=!1,hover:N=!0,compact:T=!1,className:R,emptyTitle:M="No data found",emptyDescription:A="There are no items to display.",emptyAction:D,onEmptyAction:$,getRowKey:H=j=>j.id||j._id})=>{const[j,F]=m.useState(c);m.useEffect(()=>{const V=setTimeout(()=>{u&&j!==c&&u(j)},300);return()=>clearTimeout(V)},[j]);const z=V=>{if(!h||!V.sortable)return;const X=V.sortKey||V.accessor;let Z="asc";v===X&&(Z=_==="asc"?"desc":"asc"),C==null||C(X,Z)},P=V=>{V?w==null||w(e.map(H)):w==null||w([])},B=(V,X)=>{X?w==null||w([...y,V]):w==null||w(y.filter(Z=>Z!==V))},L=e.length>0&&y.length===e.length,U=y.length>0&&y.length<e.length,O=(V,X,Z)=>{const G=V.accessor||V.key,J=G?typeof G=="function"?G(X):X[G]:void 0;return V.render?V.render(J,X,Z):V.format?V.format(J,X):J!==null&&typeof J=="object"?"-":J??"-"},W=V=>{if(!h||!V.sortable)return null;const X=V.sortKey||V.accessor;return v!==X?g.jsx(dm,{className:"ml-2 h-4 w-4 opacity-50"}):_==="asc"?g.jsx(fm,{className:"ml-2 h-4 w-4"}):g.jsx(um,{className:"ml-2 h-4 w-4"})},Q=V=>{if(!x||x.length===0)return null;const X=x.filter(Z=>Z.hidden?typeof Z.hidden=="function"?!Z.hidden(V):!Z.hidden:!0);return X.length===0?null:g.jsxs(al,{children:[g.jsx(cl,{asChild:!0,children:g.jsxs(we,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[g.jsx(wm,{className:"h-4 w-4"}),g.jsx("span",{className:"sr-only",children:"Open menu"})]})}),g.jsxs(Qs,{align:"end",children:[g.jsx(Js,{children:"Actions"}),g.jsx(yi,{}),X.map((Z,G)=>g.jsxs(bi,{onClick:()=>{var J;return(J=Z.onClick)==null?void 0:J.call(Z,V)},className:ne(Z.variant==="destructive"&&"text-destructive focus:text-destructive"),disabled:Z.disabled,children:[Z.icon&&g.jsx(Z.icon,{className:"mr-2 h-4 w-4"}),Z.label]},Z.label||G))]})]})};return g.jsxs("div",{className:ne("w-full",R),children:[(S||y.length>0)&&g.jsxs("div",{className:"flex items-center justify-between gap-4 mb-4",children:[S&&g.jsxs("div",{className:"relative max-w-sm",children:[g.jsx(to,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),g.jsx(Ln,{placeholder:p,value:j,onChange:V=>F(V.target.value),className:"pl-9 pr-9"}),j&&g.jsx("button",{onClick:()=>{F(""),u==null||u("")},className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:g.jsx(Mn,{className:"h-4 w-4"})})]}),b&&y.length>0&&g.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[y.length," row(s) selected",g.jsx(we,{variant:"ghost",size:"sm",onClick:()=>w==null?void 0:w([]),children:"Clear selection"})]})]}),g.jsx("div",{className:"rounded-md border",children:g.jsxs(bl,{children:[g.jsx(yl,{children:g.jsxs(En,{children:[b&&g.jsx(li,{className:"w-12",children:g.jsx(On,{checked:L,indeterminate:U,onCheckedChange:P})}),t.map((V,X)=>g.jsx(li,{className:ne(V.headerClassName,h&&V.sortable&&"cursor-pointer select-none"),style:{width:V.width},onClick:()=>z(V),children:g.jsxs("div",{className:"flex items-center",children:[V.header||V.label,W(V)]})},V.accessor||X)),x&&x.length>0&&g.jsx(li,{className:"w-12",children:"Actions"})]})}),g.jsx(xl,{children:n?g.jsx(En,{children:g.jsx(ln,{colSpan:t.length+(b?1:0)+(x!=null&&x.length?1:0),className:"h-48",children:g.jsx(zn,{text:"Loading data..."})})}):e.length===0?g.jsx(En,{children:g.jsx(ln,{colSpan:t.length+(b?1:0)+(x!=null&&x.length?1:0),className:"h-48",children:j?g.jsx(Tl,{searchTerm:j,onClear:()=>{F(""),u==null||u("")}}):g.jsx(Gn,{title:M,description:A,onAction:$,actionLabel:D})})}):e.map((V,X)=>{const Z=H(V),G=y.includes(Z);return g.jsxs(En,{"data-state":G?"selected":void 0,className:ne(k&&X%2===1&&"bg-muted/50",N&&"cursor-pointer",E&&"hover:bg-muted"),onClick:()=>E==null?void 0:E(V),children:[b&&g.jsx(ln,{onClick:J=>J.stopPropagation(),children:g.jsx(On,{checked:G,onCheckedChange:J=>B(Z,J)})}),t.map((J,ee)=>g.jsx(ln,{className:ne(T&&"py-2",J.cellClassName),children:O(J,V,X)},J.accessor||ee)),x&&x.length>0&&g.jsx(ln,{onClick:J=>J.stopPropagation(),children:Q(V)})]},Z)})})]})}),!n&&e.length>0&&s!==!1&&g.jsx(kl,{currentPage:o,totalPages:r,totalItems:a,pageSize:l,onPageChange:f,onPageSizeChange:d})]})};Al.displayName="DataTable";const Y0=({store:e,data:t,loading:n=!1,error:i=null,columns:s=[],currentPage:o=1,pageSize:l=10,totalItems:a=0,totalPages:r=1,onPageChange:f,onPageSizeChange:d,sortColumn:h,sortDirection:v,onSort:_,searchValue:C="",onSearchChange:S,searchPlaceholder:c="Search...",selectable:u=!1,selectedRows:p=[],onSelectionChange:b,onCreate:y,onView:w,onEdit:x,onDelete:E,onRefresh:k,onExport:N,createPath:T,detailPath:R,editPath:M,additionalActions:A=[],bulkActions:D=[],title:$,description:H,createLabel:j="Create",refreshLabel:F="Refresh",exportLabel:z="Export",viewLabel:P="View",editLabel:B="Edit",deleteLabel:L="Delete",itemName:U="item",getRowKey:O=ue=>ue.id||ue._id,showHeader:W=!0,showToolbar:Q=!0,compact:V=!1,className:X,deleteConfirmTitle:Z,deleteConfirmDescription:G,getDeleteItemName:J,filters:ee,headerActions:se,searchable:le=!0})=>{const ue=Je.useNavigate(),[Se,Re]=m.useState(!1),[ge,ke]=m.useState(null),[I,Y]=m.useState(!1),[q,re]=m.useState(""),ie=m.useRef(!1),te=m.useRef(q),ae=m.useRef(null),ve=m.useRef(null),me=(e==null?void 0:e.items)??t??[],xe=(e==null?void 0:e.loading)??n,Ae=(e==null?void 0:e.error)??i,Ee=(e==null?void 0:e.pagination)??{page:o,pageSize:l,total:a,totalPages:r},Fe=Ee.page??o,Ie=Ee.pageSize??l,Ye=Ee.total??a,Ge=Ee.totalPages??r,ze=e==null?void 0:e.fetchList,Pt=e==null?void 0:e.delete,ut=e==null?void 0:e.setPage,gn=e==null?void 0:e.setPageSize,he=e==null?void 0:e.setFilters;m.useEffect(()=>{ze&&!ie.current&&(ie.current=!0,ae.current=Fe,ve.current=Ie,ze())},[ze]),m.useEffect(()=>{if(!ze||!ie.current)return;const Ce=ae.current!==Fe,lr=ve.current!==Ie;(Ce||lr)&&(ae.current=Fe,ve.current=Ie,ze())},[Fe,Ie,ze]),m.useEffect(()=>{if(!ze||!ie.current||te.current===q)return;const Ce=setTimeout(()=>{le&&(te.current=q,he==null||he({search:q}),Fe!==1?ut==null||ut(1):ze())},300);return()=>clearTimeout(Ce)},[q,le,Fe,he,ut,ze]);const Te=m.useCallback(Ce=>{ut?ut(Ce):f==null||f(Ce)},[ut,f]),fe=m.useCallback(Ce=>{gn?gn(Ce):d==null||d(Ce)},[gn,d]),Ne=m.useCallback(Ce=>{he?re(Ce):S==null||S(Ce)},[he,S]),Xe=m.useCallback(()=>{T?ue(T):y==null||y()},[T,ue,y]),_e=m.useCallback(Ce=>{R?ue(`${R}/${O(Ce)}`):w==null||w(Ce)},[R,ue,O,w]),Ui=m.useCallback(Ce=>{M?ue(`${M}/${O(Ce)}/edit`):x==null||x(Ce)},[M,ue,O,x]),rr=m.useCallback(()=>{ze?ze():k==null||k()},[ze,k]),Yi=m.useCallback(Ce=>{ke(Ce),Re(!0)},[]),Kn=async()=>{if(ge){Y(!0);try{Pt?(await Pt(O(ge)),ze==null||ze()):E&&await E(ge),Re(!1),ke(null)}catch(Ce){console.error("Delete error:",Ce)}finally{Y(!1)}}},Xn=m.useMemo(()=>{const Ce=[];return(R||w)&&Ce.push({label:P,icon:_m,onClick:_e}),(M||x)&&Ce.push({label:B,icon:Mr,onClick:Ui}),(Pt||E)&&Ce.push({label:L,icon:Ar,variant:"destructive",onClick:Yi}),[...Ce,...A]},[R,M,w,x,Pt,E,P,B,L,_e,Ui,Yi,A]),or=T||y,cp=ze||k,Il=m.useMemo(()=>ge?J?J(ge):ge.name||ge.title||U:U,[ge,J,U]),Bl=()=>Q?g.jsxs("div",{className:"flex items-center gap-2",children:[se,u&&p.length>0&&D.length>0&&g.jsx(g.Fragment,{children:D.map((Ce,lr)=>g.jsxs(we,{variant:Ce.variant||"outline",size:"sm",onClick:()=>{var jl;return(jl=Ce.onClick)==null?void 0:jl.call(Ce,p)},disabled:Ce.disabled,children:[Ce.icon&&g.jsx(Ce.icon,{className:"mr-2 h-4 w-4"}),Ce.label]},Ce.label||lr))}),N&&g.jsxs(we,{variant:"outline",size:"sm",onClick:N,children:[g.jsx(xm,{className:"mr-2 h-4 w-4"}),z]}),cp&&g.jsxs(we,{variant:"outline",size:"sm",onClick:rr,disabled:xe,children:[g.jsx(hc,{className:ne("mr-2 h-4 w-4",xe&&"animate-spin")}),F]}),or&&g.jsxs(we,{size:"sm",onClick:Xe,children:[g.jsx(Em,{className:"mr-2 h-4 w-4"}),j]})]}):null,Fl=g.jsxs(g.Fragment,{children:[ee&&g.jsx("div",{className:"mb-4 flex items-center gap-2",children:ee}),g.jsx(Al,{data:me,columns:s,loading:xe,error:Ae,currentPage:Fe,pageSize:Ie,totalItems:Ye,totalPages:Ge,onPageChange:Te,onPageSizeChange:fe,sortColumn:h,sortDirection:v,onSort:_,searchable:le,searchValue:he?q:C,onSearchChange:Ne,searchPlaceholder:c,selectable:u,selectedRows:p,onSelectionChange:b,actions:Xn,getRowKey:O,compact:V,emptyTitle:`No ${U}s found`,emptyDescription:`Create your first ${U} to get started.`,emptyAction:or?`Create ${U}`:void 0,onEmptyAction:or?Xe:void 0}),g.jsx(xi,{open:Se,onOpenChange:Re,onConfirm:Kn,title:Z||`Delete ${U}`,description:G||`Are you sure you want to delete "${Il}"? This action cannot be undone.`,itemName:Il,loading:I})]});return W&&($||H)?g.jsxs(ft,{className:X,children:[g.jsxs(An,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[g.jsxs("div",{children:[$&&g.jsx(Rn,{children:$}),H&&g.jsx(Dn,{children:H})]}),Bl()]}),g.jsx(ht,{children:Fl})]}):g.jsxs("div",{className:X,children:[Q&&g.jsxs("div",{className:"flex items-center justify-between mb-4",children:[g.jsx("div",{}),Bl()]}),Fl]})};Y0.displayName="CrudList";var $i=e=>e.type==="checkbox",cn=e=>e instanceof Date,nt=e=>e==null;const Z0=e=>typeof e=="object";var We=e=>!nt(e)&&!Array.isArray(e)&&Z0(e)&&!cn(e),r3=e=>We(e)&&e.target?$i(e.target)?e.target.checked:e.target.value:e,o3=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,l3=(e,t)=>e.has(o3(t)),a3=e=>{const t=e.constructor&&e.constructor.prototype;return We(t)&&t.hasOwnProperty("isPrototypeOf")},Rl=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function qe(e){let t;const n=Array.isArray(e),i=typeof FileList<"u"?e instanceof FileList:!1;if(e instanceof Date)t=new Date(e);else if(!(Rl&&(e instanceof Blob||i))&&(n||We(e)))if(t=n?[]:Object.create(Object.getPrototypeOf(e)),!n&&!a3(e))t=e;else for(const s in e)e.hasOwnProperty(s)&&(t[s]=qe(e[s]));else return e;return t}var ir=e=>/^\w*$/.test(e),He=e=>e===void 0,Dl=e=>Array.isArray(e)?e.filter(Boolean):[],Ll=e=>Dl(e.replace(/["|']|\]/g,"").split(/\.|\[/)),ce=(e,t,n)=>{if(!t||!We(e))return n;const i=(ir(t)?[t]:Ll(t)).reduce((s,o)=>nt(s)?s:s[o],e);return He(i)||i===e?He(e[t])?n:e[t]:i},Nt=e=>typeof e=="boolean",Oe=(e,t,n)=>{let i=-1;const s=ir(t)?[t]:Ll(t),o=s.length,l=o-1;for(;++i<o;){const a=s[i];let r=n;if(i!==l){const f=e[a];r=We(f)||Array.isArray(f)?f:isNaN(+s[i+1])?{}:[]}if(a==="__proto__"||a==="constructor"||a==="prototype")return;e[a]=r,e=e[a]}};const za={BLUR:"blur",FOCUS_OUT:"focusout"},bt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Bt={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},c3=K.createContext(null);c3.displayName="HookFormContext";var u3=(e,t,n,i=!0)=>{const s={defaultValues:t._defaultValues};for(const o in e)Object.defineProperty(s,o,{get:()=>{const l=o;return t._proxyFormState[l]!==bt.all&&(t._proxyFormState[l]=!i||bt.all),e[l]}});return s};const d3=typeof window<"u"?K.useLayoutEffect:K.useEffect;var ot=e=>typeof e=="string",f3=(e,t,n,i,s)=>ot(e)?(i&&t.watch.add(e),ce(n,e,s)):Array.isArray(e)?e.map(o=>(i&&t.watch.add(o),ce(n,o))):(i&&(t.watchAll=!0),n),Kr=e=>nt(e)||!Z0(e);function Gt(e,t,n=new WeakSet){if(Kr(e)||Kr(t))return Object.is(e,t);if(cn(e)&&cn(t))return e.getTime()===t.getTime();const i=Object.keys(e),s=Object.keys(t);if(i.length!==s.length)return!1;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);for(const o of i){const l=e[o];if(!s.includes(o))return!1;if(o!=="ref"){const a=t[o];if(cn(l)&&cn(a)||We(l)&&We(a)||Array.isArray(l)&&Array.isArray(a)?!Gt(l,a,n):!Object.is(l,a))return!1}}return!0}var q0=(e,t,n,i,s)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[i]:s||!0}}:{},ai=e=>Array.isArray(e)?e:[e],Ha=()=>{let e=[];return{get observers(){return e},next:s=>{for(const o of e)o.next&&o.next(s)},subscribe:s=>(e.push(s),{unsubscribe:()=>{e=e.filter(o=>o!==s)}}),unsubscribe:()=>{e=[]}}};function G0(e,t){const n={};for(const i in e)if(e.hasOwnProperty(i)){const s=e[i],o=t[i];if(s&&We(s)&&o){const l=G0(s,o);We(l)&&(n[i]=l)}else e[i]&&(n[i]=o)}return n}var tt=e=>We(e)&&!Object.keys(e).length,Ol=e=>e.type==="file",yt=e=>typeof e=="function",gs=e=>{if(!Rl)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},K0=e=>e.type==="select-multiple",Pl=e=>e.type==="radio",h3=e=>Pl(e)||$i(e),kr=e=>gs(e)&&e.isConnected;function p3(e,t){const n=t.slice(0,-1).length;let i=0;for(;i<n;)e=He(e)?i++:e[t[i++]];return e}function m3(e){for(const t in e)if(e.hasOwnProperty(t)&&!He(e[t]))return!1;return!0}function Ve(e,t){const n=Array.isArray(t)?t:ir(t)?[t]:Ll(t),i=n.length===1?e:p3(e,n),s=n.length-1,o=n[s];return i&&delete i[o],s!==0&&(We(i)&&tt(i)||Array.isArray(i)&&m3(i))&&Ve(e,n.slice(0,-1)),e}var g3=e=>{for(const t in e)if(yt(e[t]))return!0;return!1};function X0(e){return Array.isArray(e)||We(e)&&!g3(e)}function Xr(e,t={}){for(const n in e){const i=e[n];X0(i)?(t[n]=Array.isArray(i)?[]:{},Xr(i,t[n])):He(i)||(t[n]=!0)}return t}function Sn(e,t,n){n||(n=Xr(t));for(const i in e){const s=e[i];if(X0(s))He(t)||Kr(n[i])?n[i]=Xr(s,Array.isArray(s)?[]:{}):Sn(s,nt(t)?{}:t[i],n[i]);else{const o=t[i];n[i]=!Gt(s,o)}}return n}const Va={value:!1,isValid:!1},Wa={value:!0,isValid:!0};var Q0=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!He(e[0].attributes.value)?He(e[0].value)||e[0].value===""?Wa:{value:e[0].value,isValid:!0}:Wa:Va}return Va},J0=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:i})=>He(e)?e:t?e===""?NaN:e&&+e:n&&ot(e)?new Date(e):i?i(e):e;const $a={isValid:!1,value:null};var ep=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,$a):$a;function Ua(e){const t=e.ref;return Ol(t)?t.files:Pl(t)?ep(e.refs).value:K0(t)?[...t.selectedOptions].map(({value:n})=>n):$i(t)?Q0(e.refs).value:J0(He(t.value)?e.ref.value:t.value,e)}var v3=(e,t,n,i)=>{const s={};for(const o of e){const l=ce(t,o);l&&Oe(s,o,l._f)}return{criteriaMode:n,names:[...e],fields:s,shouldUseNativeValidation:i}},vs=e=>e instanceof RegExp,ni=e=>He(e)?e:vs(e)?e.source:We(e)?vs(e.value)?e.value.source:e.value:e,Ya=e=>({isOnSubmit:!e||e===bt.onSubmit,isOnBlur:e===bt.onBlur,isOnChange:e===bt.onChange,isOnAll:e===bt.all,isOnTouch:e===bt.onTouched});const Za="AsyncFunction";var b3=e=>!!e&&!!e.validate&&!!(yt(e.validate)&&e.validate.constructor.name===Za||We(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Za)),y3=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),qa=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(i=>e.startsWith(i)&&/^\.\w+/.test(e.slice(i.length))));const ci=(e,t,n,i)=>{for(const s of n||Object.keys(e)){const o=ce(e,s);if(o){const{_f:l,...a}=o;if(l){if(l.refs&&l.refs[0]&&t(l.refs[0],s)&&!i)return!0;if(l.ref&&t(l.ref,l.name)&&!i)return!0;if(ci(a,t))break}else if(We(a)&&ci(a,t))break}}};function Ga(e,t,n){const i=ce(e,n);if(i||ir(n))return{error:i,name:n};const s=n.split(".");for(;s.length;){const o=s.join("."),l=ce(t,o),a=ce(e,o);if(l&&!Array.isArray(l)&&n!==o)return{name:n};if(a&&a.type)return{name:o,error:a};if(a&&a.root&&a.root.type)return{name:`${o}.root`,error:a.root};s.pop()}return{name:n}}var x3=(e,t,n,i)=>{n(e);const{name:s,...o}=e;return tt(o)||Object.keys(o).length>=Object.keys(t).length||Object.keys(o).find(l=>t[l]===(!i||bt.all))},w3=(e,t,n)=>!e||!t||e===t||ai(e).some(i=>i&&(n?i===t:i.startsWith(t)||t.startsWith(i))),_3=(e,t,n,i,s)=>s.isOnAll?!1:!n&&s.isOnTouch?!(t||e):(n?i.isOnBlur:s.isOnBlur)?!e:(n?i.isOnChange:s.isOnChange)?e:!0,C3=(e,t)=>!Dl(ce(e,t)).length&&Ve(e,t),S3=(e,t,n)=>{const i=ai(ce(e,n));return Oe(i,"root",t[n]),Oe(e,n,i),e};function Ka(e,t,n="validate"){if(ot(e)||Array.isArray(e)&&e.every(ot)||Nt(e)&&!e)return{type:n,message:ot(e)?e:"",ref:t}}var _n=e=>We(e)&&!vs(e)?e:{value:e,message:""},Xa=async(e,t,n,i,s,o)=>{const{ref:l,refs:a,required:r,maxLength:f,minLength:d,min:h,max:v,pattern:_,validate:C,name:S,valueAsNumber:c,mount:u}=e._f,p=ce(n,S);if(!u||t.has(S))return{};const b=a?a[0]:l,y=M=>{s&&b.reportValidity&&(b.setCustomValidity(Nt(M)?"":M||""),b.reportValidity())},w={},x=Pl(l),E=$i(l),k=x||E,N=(c||Ol(l))&&He(l.value)&&He(p)||gs(l)&&l.value===""||p===""||Array.isArray(p)&&!p.length,T=q0.bind(null,S,i,w),R=(M,A,D,$=Bt.maxLength,H=Bt.minLength)=>{const j=M?A:D;w[S]={type:M?$:H,message:j,ref:l,...T(M?$:H,j)}};if(o?!Array.isArray(p)||!p.length:r&&(!k&&(N||nt(p))||Nt(p)&&!p||E&&!Q0(a).isValid||x&&!ep(a).isValid)){const{value:M,message:A}=ot(r)?{value:!!r,message:r}:_n(r);if(M&&(w[S]={type:Bt.required,message:A,ref:b,...T(Bt.required,A)},!i))return y(A),w}if(!N&&(!nt(h)||!nt(v))){let M,A;const D=_n(v),$=_n(h);if(!nt(p)&&!isNaN(p)){const H=l.valueAsNumber||p&&+p;nt(D.value)||(M=H>D.value),nt($.value)||(A=H<$.value)}else{const H=l.valueAsDate||new Date(p),j=P=>new Date(new Date().toDateString()+" "+P),F=l.type=="time",z=l.type=="week";ot(D.value)&&p&&(M=F?j(p)>j(D.value):z?p>D.value:H>new Date(D.value)),ot($.value)&&p&&(A=F?j(p)<j($.value):z?p<$.value:H<new Date($.value))}if((M||A)&&(R(!!M,D.message,$.message,Bt.max,Bt.min),!i))return y(w[S].message),w}if((f||d)&&!N&&(ot(p)||o&&Array.isArray(p))){const M=_n(f),A=_n(d),D=!nt(M.value)&&p.length>+M.value,$=!nt(A.value)&&p.length<+A.value;if((D||$)&&(R(D,M.message,A.message),!i))return y(w[S].message),w}if(_&&!N&&ot(p)){const{value:M,message:A}=_n(_);if(vs(M)&&!p.match(M)&&(w[S]={type:Bt.pattern,message:A,ref:l,...T(Bt.pattern,A)},!i))return y(A),w}if(C){if(yt(C)){const M=await C(p,n),A=Ka(M,b);if(A&&(w[S]={...A,...T(Bt.validate,A.message)},!i))return y(A.message),w}else if(We(C)){let M={};for(const A in C){if(!tt(M)&&!i)break;const D=Ka(await C[A](p,n),b,A);D&&(M={...D,...T(A,D.message)},y(D.message),i&&(w[S]=M))}if(!tt(M)&&(w[S]={ref:b,...M},!i))return w}}return y(!0),w};const E3={mode:bt.onSubmit,reValidateMode:bt.onChange,shouldFocusError:!0};function N3(e={}){let t={...E3,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:yt(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},i={},s=We(t.defaultValues)||We(t.values)?qe(t.defaultValues||t.values)||{}:{},o=t.shouldUnregister?{}:qe(s),l={action:!1,mount:!1,watch:!1},a={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},r,f=0;const d={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let h={...d};const v={array:Ha(),state:Ha()},_=t.criteriaMode===bt.all,C=I=>Y=>{clearTimeout(f),f=setTimeout(I,Y)},S=async I=>{if(!t.disabled&&(d.isValid||h.isValid||I)){const Y=t.resolver?tt((await E()).errors):await N(i,!0);Y!==n.isValid&&v.state.next({isValid:Y})}},c=(I,Y)=>{!t.disabled&&(d.isValidating||d.validatingFields||h.isValidating||h.validatingFields)&&((I||Array.from(a.mount)).forEach(q=>{q&&(Y?Oe(n.validatingFields,q,Y):Ve(n.validatingFields,q))}),v.state.next({validatingFields:n.validatingFields,isValidating:!tt(n.validatingFields)}))},u=(I,Y=[],q,re,ie=!0,te=!0)=>{if(re&&q&&!t.disabled){if(l.action=!0,te&&Array.isArray(ce(i,I))){const ae=q(ce(i,I),re.argA,re.argB);ie&&Oe(i,I,ae)}if(te&&Array.isArray(ce(n.errors,I))){const ae=q(ce(n.errors,I),re.argA,re.argB);ie&&Oe(n.errors,I,ae),C3(n.errors,I)}if((d.touchedFields||h.touchedFields)&&te&&Array.isArray(ce(n.touchedFields,I))){const ae=q(ce(n.touchedFields,I),re.argA,re.argB);ie&&Oe(n.touchedFields,I,ae)}(d.dirtyFields||h.dirtyFields)&&(n.dirtyFields=Sn(s,o)),v.state.next({name:I,isDirty:R(I,Y),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Oe(o,I,Y)},p=(I,Y)=>{Oe(n.errors,I,Y),v.state.next({errors:n.errors})},b=I=>{n.errors=I,v.state.next({errors:n.errors,isValid:!1})},y=(I,Y,q,re)=>{const ie=ce(i,I);if(ie){const te=ce(o,I,He(q)?ce(s,I):q);He(te)||re&&re.defaultChecked||Y?Oe(o,I,Y?te:Ua(ie._f)):D(I,te),l.mount&&!l.action&&S()}},w=(I,Y,q,re,ie)=>{let te=!1,ae=!1;const ve={name:I};if(!t.disabled){if(!q||re){(d.isDirty||h.isDirty)&&(ae=n.isDirty,n.isDirty=ve.isDirty=R(),te=ae!==ve.isDirty);const me=Gt(ce(s,I),Y);ae=!!ce(n.dirtyFields,I),me?Ve(n.dirtyFields,I):Oe(n.dirtyFields,I,!0),ve.dirtyFields=n.dirtyFields,te=te||(d.dirtyFields||h.dirtyFields)&&ae!==!me}if(q){const me=ce(n.touchedFields,I);me||(Oe(n.touchedFields,I,q),ve.touchedFields=n.touchedFields,te=te||(d.touchedFields||h.touchedFields)&&me!==q)}te&&ie&&v.state.next(ve)}return te?ve:{}},x=(I,Y,q,re)=>{const ie=ce(n.errors,I),te=(d.isValid||h.isValid)&&Nt(Y)&&n.isValid!==Y;if(t.delayError&&q?(r=C(()=>p(I,q)),r(t.delayError)):(clearTimeout(f),r=null,q?Oe(n.errors,I,q):Ve(n.errors,I)),(q?!Gt(ie,q):ie)||!tt(re)||te){const ae={...re,...te&&Nt(Y)?{isValid:Y}:{},errors:n.errors,name:I};n={...n,...ae},v.state.next(ae)}},E=async I=>{c(I,!0);const Y=await t.resolver(o,t.context,v3(I||a.mount,i,t.criteriaMode,t.shouldUseNativeValidation));return c(I),Y},k=async I=>{const{errors:Y}=await E(I);if(I)for(const q of I){const re=ce(Y,q);re?Oe(n.errors,q,re):Ve(n.errors,q)}else n.errors=Y;return Y},N=async(I,Y,q={valid:!0})=>{for(const re in I){const ie=I[re];if(ie){const{_f:te,...ae}=ie;if(te){const ve=a.array.has(te.name),me=ie._f&&b3(ie._f);me&&d.validatingFields&&c([te.name],!0);const xe=await Xa(ie,a.disabled,o,_,t.shouldUseNativeValidation&&!Y,ve);if(me&&d.validatingFields&&c([te.name]),xe[te.name]&&(q.valid=!1,Y))break;!Y&&(ce(xe,te.name)?ve?S3(n.errors,xe,te.name):Oe(n.errors,te.name,xe[te.name]):Ve(n.errors,te.name))}!tt(ae)&&await N(ae,Y,q)}}return q.valid},T=()=>{for(const I of a.unMount){const Y=ce(i,I);Y&&(Y._f.refs?Y._f.refs.every(q=>!kr(q)):!kr(Y._f.ref))&&V(I)}a.unMount=new Set},R=(I,Y)=>!t.disabled&&(I&&Y&&Oe(o,I,Y),!Gt(P(),s)),M=(I,Y,q)=>f3(I,a,{...l.mount?o:He(Y)?s:ot(I)?{[I]:Y}:Y},q,Y),A=I=>Dl(ce(l.mount?o:s,I,t.shouldUnregister?ce(s,I,[]):[])),D=(I,Y,q={})=>{const re=ce(i,I);let ie=Y;if(re){const te=re._f;te&&(!te.disabled&&Oe(o,I,J0(Y,te)),ie=gs(te.ref)&&nt(Y)?"":Y,K0(te.ref)?[...te.ref.options].forEach(ae=>ae.selected=ie.includes(ae.value)):te.refs?$i(te.ref)?te.refs.forEach(ae=>{(!ae.defaultChecked||!ae.disabled)&&(Array.isArray(ie)?ae.checked=!!ie.find(ve=>ve===ae.value):ae.checked=ie===ae.value||!!ie)}):te.refs.forEach(ae=>ae.checked=ae.value===ie):Ol(te.ref)?te.ref.value="":(te.ref.value=ie,te.ref.type||v.state.next({name:I,values:qe(o)})))}(q.shouldDirty||q.shouldTouch)&&w(I,ie,q.shouldTouch,q.shouldDirty,!0),q.shouldValidate&&z(I)},$=(I,Y,q)=>{for(const re in Y){if(!Y.hasOwnProperty(re))return;const ie=Y[re],te=I+"."+re,ae=ce(i,te);(a.array.has(I)||We(ie)||ae&&!ae._f)&&!cn(ie)?$(te,ie,q):D(te,ie,q)}},H=(I,Y,q={})=>{const re=ce(i,I),ie=a.array.has(I),te=qe(Y);Oe(o,I,te),ie?(v.array.next({name:I,values:qe(o)}),(d.isDirty||d.dirtyFields||h.isDirty||h.dirtyFields)&&q.shouldDirty&&v.state.next({name:I,dirtyFields:Sn(s,o),isDirty:R(I,te)})):re&&!re._f&&!nt(te)?$(I,te,q):D(I,te,q),qa(I,a)&&v.state.next({...n,name:I}),v.state.next({name:l.mount?I:void 0,values:qe(o)})},j=async I=>{l.mount=!0;const Y=I.target;let q=Y.name,re=!0;const ie=ce(i,q),te=me=>{re=Number.isNaN(me)||cn(me)&&isNaN(me.getTime())||Gt(me,ce(o,q,me))},ae=Ya(t.mode),ve=Ya(t.reValidateMode);if(ie){let me,xe;const Ae=Y.type?Ua(ie._f):r3(I),Ee=I.type===za.BLUR||I.type===za.FOCUS_OUT,Fe=!y3(ie._f)&&!t.resolver&&!ce(n.errors,q)&&!ie._f.deps||_3(Ee,ce(n.touchedFields,q),n.isSubmitted,ve,ae),Ie=qa(q,a,Ee);Oe(o,q,Ae),Ee?(!Y||!Y.readOnly)&&(ie._f.onBlur&&ie._f.onBlur(I),r&&r(0)):ie._f.onChange&&ie._f.onChange(I);const Ye=w(q,Ae,Ee),Ge=!tt(Ye)||Ie;if(!Ee&&v.state.next({name:q,type:I.type,values:qe(o)}),Fe)return(d.isValid||h.isValid)&&(t.mode==="onBlur"?Ee&&S():Ee||S()),Ge&&v.state.next({name:q,...Ie?{}:Ye});if(!Ee&&Ie&&v.state.next({...n}),t.resolver){const{errors:ze}=await E([q]);if(te(Ae),re){const Pt=Ga(n.errors,i,q),ut=Ga(ze,i,Pt.name||q);me=ut.error,q=ut.name,xe=tt(ze)}}else c([q],!0),me=(await Xa(ie,a.disabled,o,_,t.shouldUseNativeValidation))[q],c([q]),te(Ae),re&&(me?xe=!1:(d.isValid||h.isValid)&&(xe=await N(i,!0)));re&&(ie._f.deps&&(!Array.isArray(ie._f.deps)||ie._f.deps.length>0)&&z(ie._f.deps),x(q,xe,me,Ye))}},F=(I,Y)=>{if(ce(n.errors,Y)&&I.focus)return I.focus(),1},z=async(I,Y={})=>{let q,re;const ie=ai(I);if(t.resolver){const te=await k(He(I)?I:ie);q=tt(te),re=I?!ie.some(ae=>ce(te,ae)):q}else I?(re=(await Promise.all(ie.map(async te=>{const ae=ce(i,te);return await N(ae&&ae._f?{[te]:ae}:ae)}))).every(Boolean),!(!re&&!n.isValid)&&S()):re=q=await N(i);return v.state.next({...!ot(I)||(d.isValid||h.isValid)&&q!==n.isValid?{}:{name:I},...t.resolver||!I?{isValid:q}:{},errors:n.errors}),Y.shouldFocus&&!re&&ci(i,F,I?ie:a.mount),re},P=(I,Y)=>{let q={...l.mount?o:s};return Y&&(q=G0(Y.dirtyFields?n.dirtyFields:n.touchedFields,q)),He(I)?q:ot(I)?ce(q,I):I.map(re=>ce(q,re))},B=(I,Y)=>({invalid:!!ce((Y||n).errors,I),isDirty:!!ce((Y||n).dirtyFields,I),error:ce((Y||n).errors,I),isValidating:!!ce(n.validatingFields,I),isTouched:!!ce((Y||n).touchedFields,I)}),L=I=>{I&&ai(I).forEach(Y=>Ve(n.errors,Y)),v.state.next({errors:I?n.errors:{}})},U=(I,Y,q)=>{const re=(ce(i,I,{_f:{}})._f||{}).ref,ie=ce(n.errors,I)||{},{ref:te,message:ae,type:ve,...me}=ie;Oe(n.errors,I,{...me,...Y,ref:re}),v.state.next({name:I,errors:n.errors,isValid:!1}),q&&q.shouldFocus&&re&&re.focus&&re.focus()},O=(I,Y)=>yt(I)?v.state.subscribe({next:q=>"values"in q&&I(M(void 0,Y),q)}):M(I,Y,!0),W=I=>v.state.subscribe({next:Y=>{w3(I.name,Y.name,I.exact)&&x3(Y,I.formState||d,Re,I.reRenderRoot)&&I.callback({values:{...o},...n,...Y,defaultValues:s})}}).unsubscribe,Q=I=>(l.mount=!0,h={...h,...I.formState},W({...I,formState:h})),V=(I,Y={})=>{for(const q of I?ai(I):a.mount)a.mount.delete(q),a.array.delete(q),Y.keepValue||(Ve(i,q),Ve(o,q)),!Y.keepError&&Ve(n.errors,q),!Y.keepDirty&&Ve(n.dirtyFields,q),!Y.keepTouched&&Ve(n.touchedFields,q),!Y.keepIsValidating&&Ve(n.validatingFields,q),!t.shouldUnregister&&!Y.keepDefaultValue&&Ve(s,q);v.state.next({values:qe(o)}),v.state.next({...n,...Y.keepDirty?{isDirty:R()}:{}}),!Y.keepIsValid&&S()},X=({disabled:I,name:Y})=>{(Nt(I)&&l.mount||I||a.disabled.has(Y))&&(I?a.disabled.add(Y):a.disabled.delete(Y))},Z=(I,Y={})=>{let q=ce(i,I);const re=Nt(Y.disabled)||Nt(t.disabled);return Oe(i,I,{...q||{},_f:{...q&&q._f?q._f:{ref:{name:I}},name:I,mount:!0,...Y}}),a.mount.add(I),q?X({disabled:Nt(Y.disabled)?Y.disabled:t.disabled,name:I}):y(I,!0,Y.value),{...re?{disabled:Y.disabled||t.disabled}:{},...t.progressive?{required:!!Y.required,min:ni(Y.min),max:ni(Y.max),minLength:ni(Y.minLength),maxLength:ni(Y.maxLength),pattern:ni(Y.pattern)}:{},name:I,onChange:j,onBlur:j,ref:ie=>{if(ie){Z(I,Y),q=ce(i,I);const te=He(ie.value)&&ie.querySelectorAll&&ie.querySelectorAll("input,select,textarea")[0]||ie,ae=h3(te),ve=q._f.refs||[];if(ae?ve.find(me=>me===te):te===q._f.ref)return;Oe(i,I,{_f:{...q._f,...ae?{refs:[...ve.filter(kr),te,...Array.isArray(ce(s,I))?[{}]:[]],ref:{type:te.type,name:I}}:{ref:te}}}),y(I,!1,void 0,te)}else q=ce(i,I,{}),q._f&&(q._f.mount=!1),(t.shouldUnregister||Y.shouldUnregister)&&!(l3(a.array,I)&&l.action)&&a.unMount.add(I)}}},G=()=>t.shouldFocusError&&ci(i,F,a.mount),J=I=>{Nt(I)&&(v.state.next({disabled:I}),ci(i,(Y,q)=>{const re=ce(i,q);re&&(Y.disabled=re._f.disabled||I,Array.isArray(re._f.refs)&&re._f.refs.forEach(ie=>{ie.disabled=re._f.disabled||I}))},0,!1))},ee=(I,Y)=>async q=>{let re;q&&(q.preventDefault&&q.preventDefault(),q.persist&&q.persist());let ie=qe(o);if(v.state.next({isSubmitting:!0}),t.resolver){const{errors:te,values:ae}=await E();n.errors=te,ie=qe(ae)}else await N(i);if(a.disabled.size)for(const te of a.disabled)Ve(ie,te);if(Ve(n.errors,"root"),tt(n.errors)){v.state.next({errors:{}});try{await I(ie,q)}catch(te){re=te}}else Y&&await Y({...n.errors},q),G(),setTimeout(G);if(v.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:tt(n.errors)&&!re,submitCount:n.submitCount+1,errors:n.errors}),re)throw re},se=(I,Y={})=>{ce(i,I)&&(He(Y.defaultValue)?H(I,qe(ce(s,I))):(H(I,Y.defaultValue),Oe(s,I,qe(Y.defaultValue))),Y.keepTouched||Ve(n.touchedFields,I),Y.keepDirty||(Ve(n.dirtyFields,I),n.isDirty=Y.defaultValue?R(I,qe(ce(s,I))):R()),Y.keepError||(Ve(n.errors,I),d.isValid&&S()),v.state.next({...n}))},le=(I,Y={})=>{const q=I?qe(I):s,re=qe(q),ie=tt(I),te=ie?s:re;if(Y.keepDefaultValues||(s=q),!Y.keepValues){if(Y.keepDirtyValues){const ae=new Set([...a.mount,...Object.keys(Sn(s,o))]);for(const ve of Array.from(ae))ce(n.dirtyFields,ve)?Oe(te,ve,ce(o,ve)):H(ve,ce(te,ve))}else{if(Rl&&He(I))for(const ae of a.mount){const ve=ce(i,ae);if(ve&&ve._f){const me=Array.isArray(ve._f.refs)?ve._f.refs[0]:ve._f.ref;if(gs(me)){const xe=me.closest("form");if(xe){xe.reset();break}}}}if(Y.keepFieldsRef)for(const ae of a.mount)H(ae,ce(te,ae));else i={}}o=t.shouldUnregister?Y.keepDefaultValues?qe(s):{}:qe(te),v.array.next({values:{...te}}),v.state.next({values:{...te}})}a={mount:Y.keepDirtyValues?a.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!d.isValid||!!Y.keepIsValid||!!Y.keepDirtyValues||!t.shouldUnregister&&!tt(te),l.watch=!!t.shouldUnregister,l.action=!1,Y.keepErrors||(n.errors={}),v.state.next({submitCount:Y.keepSubmitCount?n.submitCount:0,isDirty:ie?!1:Y.keepDirty?n.isDirty:!!(Y.keepDefaultValues&&!Gt(I,s)),isSubmitted:Y.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:ie?{}:Y.keepDirtyValues?Y.keepDefaultValues&&o?Sn(s,o):n.dirtyFields:Y.keepDefaultValues&&I?Sn(s,I):Y.keepDirty?n.dirtyFields:{},touchedFields:Y.keepTouched?n.touchedFields:{},errors:Y.keepErrors?n.errors:{},isSubmitSuccessful:Y.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},ue=(I,Y)=>le(yt(I)?I(o):I,Y),Se=(I,Y={})=>{const q=ce(i,I),re=q&&q._f;if(re){const ie=re.refs?re.refs[0]:re.ref;ie.focus&&(ie.focus(),Y.shouldSelect&&yt(ie.select)&&ie.select())}},Re=I=>{n={...n,...I}},ke={control:{register:Z,unregister:V,getFieldState:B,handleSubmit:ee,setError:U,_subscribe:W,_runSchema:E,_focusError:G,_getWatch:M,_getDirty:R,_setValid:S,_setFieldArray:u,_setDisabledField:X,_setErrors:b,_getFieldArray:A,_reset:le,_resetDefaultValues:()=>yt(t.defaultValues)&&t.defaultValues().then(I=>{ue(I,t.resetOptions),v.state.next({isLoading:!1})}),_removeUnmounted:T,_disableForm:J,_subjects:v,_proxyFormState:d,get _fields(){return i},get _formValues(){return o},get _state(){return l},set _state(I){l=I},get _defaultValues(){return s},get _names(){return a},set _names(I){a=I},get _formState(){return n},get _options(){return t},set _options(I){t={...t,...I}}},subscribe:Q,trigger:z,register:Z,handleSubmit:ee,watch:O,setValue:H,getValues:P,reset:ue,resetField:se,clearErrors:L,unregister:V,setError:U,setFocus:Se,getFieldState:B};return{...ke,formControl:ke}}function k3(e={}){const t=K.useRef(void 0),n=K.useRef(void 0),[i,s]=K.useState({isDirty:!1,isValidating:!1,isLoading:yt(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:yt(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:i},e.defaultValues&&!yt(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...a}=N3(e);t.current={...a,formState:i}}const o=t.current.control;return o._options=e,d3(()=>{const l=o._subscribe({formState:o._proxyFormState,callback:()=>s({...o._formState}),reRenderRoot:!0});return s(a=>({...a,isReady:!0})),o._formState.isReady=!0,l},[o]),K.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),K.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),K.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),K.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),K.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==i.isDirty&&o._subjects.state.next({isDirty:l})}},[o,i.isDirty]),K.useEffect(()=>{var l;e.values&&!Gt(e.values,n.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((l=o._options.resetOptions)===null||l===void 0)&&l.keepIsValid||o._setValid(),n.current=e.values,s(a=>({...a}))):o._resetDefaultValues()},[o,e.values]),K.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),t.current.formState=u3(i,o),t.current}const Qa=(e,t,n)=>{if(e&&"reportValidity"in e){const i=ce(n,t);e.setCustomValidity(i&&i.message||""),e.reportValidity()}},tp=(e,t)=>{for(const n in t.fields){const i=t.fields[n];i&&i.ref&&"reportValidity"in i.ref?Qa(i.ref,n,e):i.refs&&i.refs.forEach(s=>Qa(s,n,e))}},T3=(e,t)=>{t.shouldUseNativeValidation&&tp(e,t);const n={};for(const i in e){const s=ce(t.fields,i),o=Object.assign(e[i]||{},{ref:s&&s.ref});if(M3(t.names||Object.keys(e),i)){const l=Object.assign({},ce(n,i));Oe(l,"root",o),Oe(n,i,l)}else Oe(n,i,o)}return n},M3=(e,t)=>e.some(n=>n.startsWith(t+"."));var A3=function(e,t){for(var n={};e.length;){var i=e[0],s=i.code,o=i.message,l=i.path.join(".");if(!n[l])if("unionErrors"in i){var a=i.unionErrors[0].errors[0];n[l]={message:a.message,type:a.code}}else n[l]={message:o,type:s};if("unionErrors"in i&&i.unionErrors.forEach(function(d){return d.errors.forEach(function(h){return e.push(h)})}),t){var r=n[l].types,f=r&&r[i.code];n[l]=q0(l,t,n,s,f?[].concat(f,i.message):i.message)}e.shift()}return n},R3=function(e,t,n){return n===void 0&&(n={}),function(i,s,o){try{return Promise.resolve(function(l,a){try{var r=Promise.resolve(e[n.mode==="sync"?"parse":"parseAsync"](i,t)).then(function(f){return o.shouldUseNativeValidation&&tp({},o),{errors:{},values:n.raw?i:f}})}catch(f){return a(f)}return r&&r.then?r.then(void 0,a):r}(0,function(l){if(function(a){return Array.isArray(a==null?void 0:a.errors)}(l))return{values:{},errors:T3(A3(l.errors,!o.shouldUseNativeValidation&&o.criteriaMode==="all"),o)};throw l}))}catch(l){return Promise.reject(l)}}};const np=({useStore:e,fields:t=[],defaultValues:n={},validationSchema:i,children:s,onSubmit:o,onCancel:l,onBack:a,onBeforeSubmit:r,initialData:f=null,loading:d=!1,submitting:h=!1,title:v,description:_,submitLabel:C="Save",cancelLabel:S="Cancel",backLabel:c="Back",columns:u=1,showHeader:p=!0,showFooter:b=!0,showBack:y=!0,showCard:w=!0,listPath:x,icon:E,className:k,...N})=>{var ke;const T=Je.useNavigate(),{id:R}=Je.useParams(),M=!!R,A=e==null?void 0:e(),D=A==null?void 0:A.form,$=(A==null?void 0:A.loading)??!1,H=((ke=A==null?void 0:A.form)==null?void 0:ke.isSubmitting)??!1,j=(A==null?void 0:A.fetchAndPopulateForm)||(A==null?void 0:A.fetchById)||(A==null?void 0:A.fetchOne),F=A==null?void 0:A.create,z=A==null?void 0:A.update,P=A==null?void 0:A.resetForm,B=d||$,L=h||H;m.useEffect(()=>(M&&R&&j&&j(R),()=>{P==null||P()}),[R,M]);const U=()=>{a?a():T(x||-1)},O=()=>{l?l():U()},W=async I=>{var Y;(Y=I==null?void 0:I.preventDefault)==null||Y.call(I);try{let q=(D==null?void 0:D.values)||{};r&&(q=r(q)),M?await(z==null?void 0:z(R,q)):await(F==null?void 0:F(q)),U()}catch(q){console.error("Form submission error:",q)}};if(e&&s){const I=M?`Edit ${v}`:`Create ${v}`,Y=g.jsxs("form",{onSubmit:W,children:[s,b&&g.jsxs("div",{className:"flex items-center justify-end gap-2 mt-6 pt-4 border-t",children:[g.jsxs(we,{type:"button",variant:"outline",onClick:O,disabled:L,children:[g.jsx(Mn,{className:"mr-2 h-4 w-4"}),S]}),g.jsx(we,{type:"submit",disabled:L||B,children:L?g.jsxs(g.Fragment,{children:[g.jsx(un,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):g.jsxs(g.Fragment,{children:[g.jsx(Zl,{className:"mr-2 h-4 w-4"}),C]})})]})]});return w?g.jsxs(ft,{className:k,...N,children:[g.jsx(An,{children:g.jsxs("div",{className:"flex items-center gap-4",children:[y&&g.jsx(we,{variant:"ghost",size:"icon",onClick:U,children:g.jsx(Ft,{className:"h-4 w-4"})}),E&&g.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center",children:g.jsx(E,{className:"h-5 w-5 text-primary"})}),g.jsxs("div",{children:[g.jsx(Rn,{children:I}),_&&g.jsx(Dn,{children:_})]})]})}),g.jsx(ht,{children:Y})]}):g.jsxs("div",{className:ne("space-y-6",k),...N,children:[g.jsxs("div",{className:"flex items-center gap-4",children:[y&&g.jsx(we,{variant:"ghost",size:"icon",onClick:U,children:g.jsx(Ft,{className:"h-4 w-4"})}),E&&g.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center",children:g.jsx(E,{className:"h-5 w-5 text-primary"})}),g.jsxs("div",{children:[g.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:I}),_&&g.jsx("p",{className:"text-muted-foreground",children:_})]})]}),Y]})}const Q=k3({defaultValues:f||n,resolver:i?R3(i):void 0,mode:"onBlur"}),{handleSubmit:V,formState:{errors:X,isDirty:Z,isValid:G},reset:J,watch:ee,setValue:se,control:le}=Q;m.useEffect(()=>{f&&J(f)},[f,J]);const ue=async I=>{try{await(o==null?void 0:o(I))}catch(Y){console.error("Form submission error:",Y)}},Se=I=>{var Ye;const{name:Y,type:q="text",label:re,placeholder:ie,description:te,required:ae,disabled:ve,options:me=[],className:xe,...Ae}=I,Ee=(Ye=X[Y])==null?void 0:Ye.message,Fe=ee(Y),Ie={label:re,placeholder:ie,description:te,error:Ee,required:ae,disabled:ve||B||L,className:xe};switch(q){case"text":case"email":case"password":case"number":case"url":case"tel":return g.jsx(ms,{...Ie,type:q,...Q.register(Y),...Ae});case"textarea":return g.jsx(_l,{...Ie,...Q.register(Y),...Ae});case"select":return g.jsx(Cl,{...Ie,options:me,value:Fe,onChange:Ge=>se(Y,Ge,{shouldValidate:!0}),...Ae});case"search-select":return g.jsx(Sl,{...Ie,options:me,value:Fe,onChange:Ge=>se(Y,Ge,{shouldValidate:!0}),...Ae});case"switch":return g.jsx(El,{...Ie,checked:Fe,onCheckedChange:Ge=>se(Y,Ge,{shouldValidate:!0}),...Ae});case"checkbox":return g.jsx(Nl,{...Ie,checked:Fe,onCheckedChange:Ge=>se(Y,Ge,{shouldValidate:!0}),...Ae});case"custom":return I.render?I.render({form:Q,field:I,error:Ee,value:Fe}):null;default:return g.jsx(ms,{...Ie,type:"text",...Q.register(Y),...Ae})}},Re=ne("grid gap-4",u===1&&"grid-cols-1",u===2&&"grid-cols-1 md:grid-cols-2",u===3&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-3",u===4&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-4"),ge=g.jsxs("form",{onSubmit:V(ue),children:[g.jsx("div",{className:Re,children:t.map(I=>{if(I.hidden&&(typeof I.hidden=="function"?I.hidden(ee()):I.hidden))return null;const Y=I.colSpan||1,q=ne(Y===2&&"md:col-span-2",Y===3&&"md:col-span-2 lg:col-span-3",Y===4&&"md:col-span-2 lg:col-span-4",Y==="full"&&"col-span-full");return g.jsx("div",{className:q,children:Se(I)},I.name)})}),b&&g.jsxs("div",{className:"flex items-center justify-end gap-2 mt-6 pt-4 border-t",children:[l&&g.jsxs(we,{type:"button",variant:"outline",onClick:l,disabled:L,children:[g.jsx(Mn,{className:"mr-2 h-4 w-4"}),S]}),g.jsx(we,{type:"submit",disabled:L||B,children:L?g.jsxs(g.Fragment,{children:[g.jsx(un,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):g.jsxs(g.Fragment,{children:[g.jsx(Zl,{className:"mr-2 h-4 w-4"}),C]})})]})]});return p&&(v||_||y)?g.jsxs(ft,{className:k,...N,children:[g.jsx(An,{children:g.jsxs("div",{className:"flex items-center gap-4",children:[y&&a&&g.jsx(we,{variant:"ghost",size:"icon",onClick:a,children:g.jsx(Ft,{className:"h-4 w-4"})}),g.jsxs("div",{children:[v&&g.jsx(Rn,{children:v}),_&&g.jsx(Dn,{children:_})]})]})}),g.jsx(ht,{children:ge})]}):g.jsx("div",{className:k,...N,children:ge})};np.displayName="CrudForm";const ip=({useStore:e,children:t,data:n=null,loading:i=!1,error:s=null,fields:o=[],onBack:l,onEdit:a,onDelete:r,listPath:f,editPath:d,title:h,description:v,editLabel:_="Edit",deleteLabel:C="Delete",backLabel:S="Back",itemName:c="item",getItemName:u,showHeader:p=!0,showMeta:b=!0,showCard:y=!0,columns:w=2,icon:x,className:E,...k})=>{const N=Je.useNavigate(),{id:T}=Je.useParams(),R=e==null?void 0:e(),M=R==null?void 0:R.currentItem,A=(R==null?void 0:R.loading)??!1,D=R==null?void 0:R.error,$=(R==null?void 0:R.fetchById)||(R==null?void 0:R.fetchOne),H=R==null?void 0:R.delete,j=n||M,F=i||A,z=s||D,[P,B]=m.useState(!1),[L,U]=m.useState(!1);m.useEffect(()=>{T&&$&&$(T)},[T]);const O=()=>{l?l():N(f||-1)},W=()=>{a?a(j):d&&T&&N(`${d}/${T}/edit`)},Q=async()=>{U(!0);try{r?await r(j):H&&T&&(await H(T),O()),B(!1)}catch(ee){console.error("Delete error:",ee)}finally{U(!1)}},V=j&&u?u(j):(j==null?void 0:j.name)||(j==null?void 0:j.title)||c,X=(ee,se)=>{if(ee.render)return j?ee.render(se,j):g.jsx("span",{className:"text-muted-foreground",children:"-"});if(se==null||se==="")return g.jsx("span",{className:"text-muted-foreground",children:"-"});switch(ee.type){case"badge":return g.jsx(ii,{variant:ee.variant||"default",children:ee.format?ee.format(se):String(se)});case"status":const le={active:"success",inactive:"secondary",pending:"warning",error:"destructive",...ee.statusColors};return g.jsx(ii,{variant:le[se==null?void 0:se.toLowerCase()]||"default",children:ee.format?ee.format(se):String(se)});case"boolean":const ue=!!se;return g.jsx(ii,{variant:ue?"success":"secondary",children:ue?ee.trueLabel||"Yes":ee.falseLabel||"No"});case"date":return Jr(se);case"datetime":return Ji(se);case"currency":return new Intl.NumberFormat("en-US",{style:"currency",currency:ee.currency||"USD"}).format(se);case"number":return ee.format?ee.format(se):new Intl.NumberFormat().format(se);case"list":return Array.isArray(se)?g.jsx("div",{className:"flex flex-wrap gap-1",children:se.map((Se,Re)=>g.jsx(ii,{variant:"outline",children:ee.getItemLabel?ee.getItemLabel(Se):String(Se)},Re))}):String(se);case"link":return g.jsx("a",{href:se,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:ee.linkText||se});case"email":return g.jsx("a",{href:`mailto:${se}`,className:"text-primary hover:underline",children:se});case"phone":return g.jsx("a",{href:`tel:${se}`,className:"text-primary hover:underline",children:se});case"image":return g.jsx("img",{src:se,alt:ee.label||"Image",className:ne("rounded-md object-cover",ee.imageClassName||"h-20 w-20")});case"html":return g.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:se}});default:return ee.format?ee.format(se):String(se)}},Z=ee=>{if(j)return ee.accessor?typeof ee.accessor=="function"?ee.accessor(j):j[ee.accessor]:j[ee.name]},G=ne("grid gap-6",w===1&&"grid-cols-1",w===2&&"grid-cols-1 md:grid-cols-2",w===3&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-3"),J=g.jsxs(g.Fragment,{children:[g.jsx("div",{className:G,children:o.map(ee=>{if(ee.hidden&&(typeof ee.hidden=="function"?j&&ee.hidden(j):ee.hidden))return null;const se=Z(ee),le=ee.colSpan||1,ue=ne(le===2&&"md:col-span-2",le===3&&"lg:col-span-3",le==="full"&&"col-span-full");return g.jsxs("div",{className:ue,children:[g.jsxs("dt",{className:"text-sm font-medium text-muted-foreground mb-1",children:[ee.icon&&g.jsx(ee.icon,{className:"inline-block mr-2 h-4 w-4"}),ee.label]}),g.jsx("dd",{className:"text-sm",children:X(ee,se)})]},ee.name||ee.accessor)})}),b&&j&&(j.created_at||j.updated_at||j.createdAt||j.updatedAt)&&g.jsxs(g.Fragment,{children:[g.jsx(Si,{className:"my-6"}),g.jsxs("div",{className:"flex flex-wrap gap-6 text-sm text-muted-foreground",children:[(j.created_at||j.createdAt)&&(j.created_at||j.createdAt)!==""&&g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(ss,{className:"h-4 w-4"}),g.jsxs("span",{children:["Created: ",Ji(j.created_at||j.createdAt)]})]}),(j.updated_at||j.updatedAt)&&(j.updated_at||j.updatedAt)!==""&&g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(ss,{className:"h-4 w-4"}),g.jsxs("span",{children:["Updated: ",Ji(j.updated_at||j.updatedAt)]})]}),(j.id||j._id)&&g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(Cm,{className:"h-4 w-4"}),g.jsxs("span",{children:["ID: ",j.id||j._id]})]})]})]})]});return e&&t&&typeof t=="function"?F?g.jsx("div",{className:ne("space-y-6",E),children:g.jsx(ft,{children:g.jsx(ht,{className:"py-12",children:g.jsx(zn,{text:`Loading ${c}...`})})})}):z?g.jsx("div",{className:ne("space-y-6",E),children:g.jsx(ft,{children:g.jsxs(ht,{className:"py-12 text-center",children:[g.jsx("p",{className:"text-destructive",children:(z==null?void 0:z.message)||"An error occurred"}),g.jsxs(we,{variant:"outline",onClick:O,className:"mt-4",children:[g.jsx(Ft,{className:"mr-2 h-4 w-4"}),S]})]})})}):j?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:ne("space-y-6",E),...k,children:[p&&g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{className:"flex items-center gap-4",children:[g.jsx(we,{variant:"ghost",size:"icon",onClick:O,children:g.jsx(Ft,{className:"h-4 w-4"})}),x&&g.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center",children:g.jsx(x,{className:"h-5 w-5 text-primary"})}),g.jsxs("div",{children:[g.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:h}),v&&g.jsx("p",{className:"text-muted-foreground",children:v})]})]}),g.jsxs("div",{className:"flex items-center gap-2",children:[(a||d)&&g.jsxs(we,{variant:"outline",onClick:W,children:[g.jsx(Mr,{className:"mr-2 h-4 w-4"}),_]}),(r||H)&&g.jsxs(we,{variant:"destructive",onClick:()=>B(!0),children:[g.jsx(Ar,{className:"mr-2 h-4 w-4"}),C]})]})]}),t(j)]}),g.jsx(xi,{open:P,onOpenChange:B,onConfirm:Q,itemName:V,loading:L})]}):g.jsx("div",{className:ne("space-y-6",E),children:g.jsx(ft,{children:g.jsxs(ht,{className:"py-12 text-center",children:[g.jsxs("p",{className:"text-muted-foreground",children:["No ",c," found"]}),g.jsxs(we,{variant:"outline",onClick:O,className:"mt-4",children:[g.jsx(Ft,{className:"mr-2 h-4 w-4"}),S]})]})})}):F?g.jsx(ft,{className:E,children:g.jsx(ht,{className:"py-12",children:g.jsx(zn,{text:`Loading ${c}...`})})}):z?g.jsx(ft,{className:E,children:g.jsxs(ht,{className:"py-12 text-center",children:[g.jsx("p",{className:"text-destructive",children:(z==null?void 0:z.message)||"An error occurred"}),g.jsxs(we,{variant:"outline",onClick:O,className:"mt-4",children:[g.jsx(Ft,{className:"mr-2 h-4 w-4"}),S]})]})}):j?g.jsxs(g.Fragment,{children:[g.jsxs(ft,{className:E,...k,children:[p&&g.jsxs(An,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[g.jsxs("div",{className:"flex items-center gap-4",children:[g.jsx(we,{variant:"ghost",size:"icon",onClick:O,children:g.jsx(Ft,{className:"h-4 w-4"})}),g.jsxs("div",{children:[h&&g.jsx(Rn,{children:h}),v&&g.jsx(Dn,{children:v})]})]}),g.jsxs("div",{className:"flex items-center gap-2",children:[(a||d)&&g.jsxs(we,{variant:"outline",onClick:W,children:[g.jsx(Mr,{className:"mr-2 h-4 w-4"}),_]}),(r||H)&&g.jsxs(we,{variant:"destructive",onClick:()=>B(!0),children:[g.jsx(Ar,{className:"mr-2 h-4 w-4"}),C]})]})]}),g.jsx(ht,{children:J})]}),g.jsx(xi,{open:P,onOpenChange:B,onConfirm:Q,itemName:V,loading:L})]}):g.jsx(ft,{className:E,children:g.jsxs(ht,{className:"py-12 text-center",children:[g.jsxs("p",{className:"text-muted-foreground",children:["No ",c," found"]}),g.jsxs(we,{variant:"outline",onClick:O,className:"mt-4",children:[g.jsx(Ft,{className:"mr-2 h-4 w-4"}),S]})]})})};ip.displayName="CrudDetail";const sp=e=>{const{name:t="crud",apiClient:n,endpoint:i,transformResponse:s=h=>h,transformRequest:o=h=>h,initialState:l={},extraActions:a={},idField:r="id",listKey:f="results",countKey:d="count"}=e;if(!n)throw new Error("createCrudStore: apiClient is required");if(!i)throw new Error("createCrudStore: endpoint is required");return h=>h((v,_)=>({items:[],item:null,loading:!1,submitting:!1,error:null,page:1,pageSize:10,totalItems:0,totalPages:0,sortColumn:null,sortDirection:null,search:"",filters:{},selectedIds:[],...l,setPage:C=>v({page:C}),setPageSize:C=>v({pageSize:C,page:1}),setSearch:C=>v({search:C,page:1}),setFilters:C=>v({filters:C,page:1}),setSort:(C,S)=>v({sortColumn:C,sortDirection:S}),setSelectedIds:C=>v({selectedIds:C}),clearSelection:()=>v({selectedIds:[]}),clearError:()=>v({error:null}),reset:()=>v({items:[],item:null,loading:!1,submitting:!1,error:null,page:1,search:"",filters:{},selectedIds:[]}),fetchList:async(C={})=>{var c,u,p,b;const S=_();v({loading:!0,error:null});try{const y={page:S.page,page_size:S.pageSize,search:S.search||void 0,ordering:S.sortColumn?`${S.sortDirection==="desc"?"-":""}${S.sortColumn}`:void 0,...S.filters,...C};Object.keys(y).forEach(T=>{(y[T]===void 0||y[T]==="")&&delete y[T]});const x=(await n.get(i,{params:y})).data,E=x[f]||x.data||(Array.isArray(x)?x:[]),k=x[d]||x.total||E.length,N=Math.ceil(k/S.pageSize);return v({items:E.map(s),totalItems:k,totalPages:N,loading:!1}),{items:E,totalItems:k,totalPages:N}}catch(y){const w=((u=(c=y.response)==null?void 0:c.data)==null?void 0:u.message)||((b=(p=y.response)==null?void 0:p.data)==null?void 0:b.detail)||y.message||"Failed to fetch items";throw v({error:{message:w,original:y},loading:!1}),y}},fetchOne:async C=>{var S,c,u,p;v({loading:!0,error:null,item:null});try{const b=await n.get(`${i}/${C}/`),y=s(b.data);return v({item:y,loading:!1}),y}catch(b){const y=((c=(S=b.response)==null?void 0:S.data)==null?void 0:c.message)||((p=(u=b.response)==null?void 0:u.data)==null?void 0:p.detail)||b.message||"Failed to fetch item";throw v({error:{message:y,original:b},loading:!1}),b}},create:async C=>{var S,c,u,p,b;v({submitting:!0,error:null});try{const y=o(C),w=await n.post(`${i}/`,y),x=s(w.data);return v(E=>({items:[x,...E.items],totalItems:E.totalItems+1,submitting:!1})),x}catch(y){const w=((c=(S=y.response)==null?void 0:S.data)==null?void 0:c.message)||((p=(u=y.response)==null?void 0:u.data)==null?void 0:p.detail)||y.message||"Failed to create item",x=((b=y.response)==null?void 0:b.data)||{};throw v({error:{message:w,fieldErrors:x,original:y},submitting:!1}),y}},update:async(C,S)=>{var c,u,p,b,y;v({submitting:!0,error:null});try{const w=o(S),x=await n.patch(`${i}/${C}/`,w),E=s(x.data);return v(k=>{var N;return{items:k.items.map(T=>T[r]===C?E:T),item:((N=k.item)==null?void 0:N[r])===C?E:k.item,submitting:!1}}),E}catch(w){const x=((u=(c=w.response)==null?void 0:c.data)==null?void 0:u.message)||((b=(p=w.response)==null?void 0:p.data)==null?void 0:b.detail)||w.message||"Failed to update item",E=((y=w.response)==null?void 0:y.data)||{};throw v({error:{message:x,fieldErrors:E,original:w},submitting:!1}),w}},delete:async C=>{var S,c,u,p;v({submitting:!0,error:null});try{return await n.delete(`${i}/${C}/`),v(b=>{var y;return{items:b.items.filter(w=>w[r]!==C),totalItems:b.totalItems-1,item:((y=b.item)==null?void 0:y[r])===C?null:b.item,selectedIds:b.selectedIds.filter(w=>w!==C),submitting:!1}}),!0}catch(b){const y=((c=(S=b.response)==null?void 0:S.data)==null?void 0:c.message)||((p=(u=b.response)==null?void 0:u.data)==null?void 0:p.detail)||b.message||"Failed to delete item";throw v({error:{message:y,original:b},submitting:!1}),b}},bulkDelete:async C=>{var S,c,u,p;v({submitting:!0,error:null});try{return await Promise.all(C.map(b=>n.delete(`${i}/${b}/`))),v(b=>({items:b.items.filter(y=>!C.includes(y[r])),totalItems:b.totalItems-C.length,selectedIds:[],submitting:!1})),!0}catch(b){const y=((c=(S=b.response)==null?void 0:S.data)==null?void 0:c.message)||((p=(u=b.response)==null?void 0:u.data)==null?void 0:p.detail)||b.message||"Failed to delete items";throw v({error:{message:y,original:b},submitting:!1}),b}},replace:async(C,S)=>{var c,u,p,b,y;v({submitting:!0,error:null});try{const w=o(S),x=await n.put(`${i}/${C}/`,w),E=s(x.data);return v(k=>{var N;return{items:k.items.map(T=>T[r]===C?E:T),item:((N=k.item)==null?void 0:N[r])===C?E:k.item,submitting:!1}}),E}catch(w){const x=((u=(c=w.response)==null?void 0:c.data)==null?void 0:u.message)||((b=(p=w.response)==null?void 0:p.data)==null?void 0:b.detail)||w.message||"Failed to update item",E=((y=w.response)==null?void 0:y.data)||{};throw v({error:{message:x,fieldErrors:E,original:w},submitting:!1}),w}},...a}))},D3=e=>{const{create:t}=require("zustand");return t(sp(e))};function L3({brandName:e="Your Brand",brandLogo:t,brandDescription:n="Welcome back",quote:i,quoteAuthor:s,copyright:o,leftPanelClassName:l,rightPanelClassName:a,leftPanelContent:r,rightPanelContent:f,showLeftPanel:d=!0,children:h}){const v=new Date().getFullYear(),_=o||`© ${v} ${e}. All rights reserved.`,C=g.jsxs("div",{className:"flex flex-col h-full p-8 lg:p-12 text-white",children:[g.jsxs("div",{className:"flex items-center gap-3",children:[t||g.jsx("div",{className:"h-10 w-10 rounded-lg bg-white/20 flex items-center justify-center",children:g.jsx("span",{className:"text-white font-bold text-xl",children:e.charAt(0)})}),g.jsx("span",{className:"text-xl font-semibold",children:e})]}),g.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[i&&g.jsxs("div",{className:"max-w-md",children:[g.jsxs("blockquote",{className:"text-2xl lg:text-3xl font-light leading-relaxed",children:['"',i,'"']}),s&&g.jsxs("p",{className:"mt-4 text-white/70",children:["— ",s]})]}),!i&&n&&g.jsx("div",{className:"text-center",children:g.jsx("p",{className:"text-2xl lg:text-3xl font-light",children:n})})]}),g.jsx("div",{className:"text-sm text-white/60",children:_})]});return g.jsxs("div",{className:"min-h-screen flex",children:[d&&g.jsx("div",{className:ne("hidden lg:flex lg:w-1/2 bg-gray-900",l),children:r||C}),g.jsx("div",{className:ne("w-full flex items-center justify-center p-8",d?"lg:w-1/2":"",a),children:g.jsx("div",{className:"w-full max-w-md",children:f||h||g.jsx(Je.Outlet,{})})})]})}function O3({onSubmit:e,isLoading:t=!1,error:n,title:i="Login",subtitle:s="Enter your email below to login to your account",emailLabel:o="Email",emailPlaceholder:l="m@example.com",passwordLabel:a="Password",rememberMeLabel:r="Remember me",forgotPasswordText:f="Forgot your password?",forgotPasswordPath:d="/forgot-password",submitButtonText:h="Login",signUpText:v="Don't have an account?",signUpLinkText:_="Sign up",signUpPath:C="/register",showRememberMe:S=!0,showForgotPassword:c=!0,showSignUp:u=!0,logo:p,className:b,children:y}){const[w,x]=K.useState(""),[E,k]=K.useState(""),[N,T]=K.useState(!1),R=async M=>{M.preventDefault(),e&&await e({email:w,password:E,rememberMe:N})};return g.jsxs("div",{className:ne("space-y-6",b),children:[p&&g.jsx("div",{className:"flex justify-center",children:p}),g.jsxs("div",{className:"space-y-2 text-center",children:[g.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:i}),s&&g.jsx("p",{className:"text-sm text-muted-foreground",children:s})]}),n&&g.jsx("div",{className:"p-3 text-sm text-destructive bg-destructive/10 rounded-md",children:n}),g.jsxs("form",{onSubmit:R,className:"space-y-4",children:[g.jsxs("div",{className:"space-y-2",children:[g.jsx(Kt,{htmlFor:"email",children:o}),g.jsx(Ln,{id:"email",type:"email",placeholder:l,value:w,onChange:M=>x(M.target.value),required:!0,autoComplete:"email"})]}),g.jsxs("div",{className:"space-y-2",children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsx(Kt,{htmlFor:"password",children:a}),c&&d&&g.jsx(Je.Link,{to:d,className:"text-sm text-muted-foreground hover:text-primary underline-offset-4 hover:underline",children:f})]}),g.jsx(Ln,{id:"password",type:"password",value:E,onChange:M=>k(M.target.value),required:!0,autoComplete:"current-password"})]}),S&&g.jsxs("div",{className:"flex items-center space-x-2",children:[g.jsx(On,{id:"remember",checked:N,onCheckedChange:T}),g.jsx(Kt,{htmlFor:"remember",className:"text-sm font-normal cursor-pointer",children:r})]}),y,g.jsx(we,{type:"submit",className:"w-full",disabled:t,children:t?"Signing in...":h})]}),u&&C&&g.jsxs("div",{className:"text-center text-sm text-muted-foreground",children:[v," ",g.jsx(Je.Link,{to:C,className:"text-primary underline-offset-4 hover:underline",children:_})]})]})}const rp=K.createContext(null);function sr(){const e=K.useContext(rp);if(!e)throw new Error("useSidebarContext must be used within a SidebarProvider");return e}function op({defaultOpen:e=!1,defaultCollapsed:t=!1,children:n}){const[i,s]=K.useState(e),[o,l]=K.useState(t),a=K.useCallback(()=>{s(v=>!v)},[]),r=K.useCallback(v=>{s(v)},[]),f=K.useCallback(()=>{l(v=>!v)},[]),d=K.useCallback(v=>{l(v)},[]),h={isOpen:i,isCollapsed:o,toggle:a,setOpen:r,toggleCollapse:f,setCollapsed:d};return g.jsx(rp.Provider,{value:h,children:n})}function lp({items:e=[],brandName:t="Brand",brandLogo:n,brandPath:i="/dashboard",user:s,onLogout:o,userMenuItems:l=[],showUserProfile:a=!0,className:r,collapsedWidth:f="w-16",expandedWidth:d="w-60",renderItem:h,headerSlot:v,footerSlot:_}){var N,T;const{isOpen:C,isCollapsed:S,setOpen:c,toggleCollapse:u}=sr(),p=Je.useLocation(),[b,y]=K.useState([]),w=R=>{y(M=>M.includes(R)?M.filter(A=>A!==R):[...M,R])},x=(R,M=!1)=>{if(R.title)return g.jsxs("div",{className:"mt-6",children:[!S&&g.jsx("h3",{className:"px-3 text-xs font-medium text-sidebar-foreground/50 uppercase tracking-wider mb-2",children:R.title}),S&&g.jsx(Si,{className:"my-3 bg-sidebar-border"})]},R.title);if(h)return h(R,{isCollapsed:S,isSubItem:M,location:p});const A=R.icon,D=R.children&&R.children.length>0,$=b.includes(R.label),H=R.path&&(p.pathname===R.path||p.pathname.startsWith(R.path+"/")),j=D&&R.children.some(F=>p.pathname===F.path||p.pathname.startsWith(F.path+"/"));return D?g.jsxs("div",{children:[g.jsxs("button",{onClick:()=>w(R.label),className:ne("w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors text-sm",j?"bg-sidebar-accent text-sidebar-accent-foreground":"hover:bg-sidebar-accent text-sidebar-foreground hover:text-sidebar-accent-foreground",S&&"justify-center px-2"),title:S?R.label:void 0,children:[A&&g.jsx(A,{className:"h-4 w-4 flex-shrink-0"}),!S&&g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"flex-1 text-left",children:R.label}),g.jsx(ys,{className:ne("h-4 w-4 transition-transform",$&&"rotate-180")})]})]}),!S&&$&&g.jsx("div",{className:"ml-4 mt-1 space-y-0.5",children:R.children.map(F=>x(F,!0))})]},R.label):g.jsxs(Je.Link,{to:R.path,className:ne("flex items-center gap-3 px-3 py-2 rounded-lg transition-colors",H?"bg-sidebar-primary text-sidebar-primary-foreground":"hover:bg-sidebar-accent text-sidebar-foreground hover:text-sidebar-accent-foreground",S&&"justify-center px-2","text-sm"),title:S?R.label:void 0,children:[A&&g.jsx(A,{className:"h-4 w-4 flex-shrink-0"}),!S&&g.jsx("span",{children:R.label})]},R.path||R.label)},E=g.jsxs("div",{className:"flex items-center justify-between h-14 px-3 border-b border-sidebar-border",children:[!S&&g.jsxs(Je.Link,{to:i,className:"flex items-center gap-2",children:[n||g.jsx("div",{className:"h-7 w-7 rounded-md bg-sidebar-primary flex items-center justify-center",children:g.jsx("span",{className:"text-sidebar-primary-foreground font-semibold text-sm",children:t.charAt(0)})}),g.jsx("span",{className:"font-semibold text-sidebar-foreground",children:t})]}),S&&g.jsx(Je.Link,{to:i,className:"mx-auto",children:n||g.jsx("div",{className:"h-7 w-7 rounded-md bg-sidebar-primary flex items-center justify-center",children:g.jsx("span",{className:"text-sidebar-primary-foreground font-semibold text-sm",children:t.charAt(0)})})}),g.jsx("button",{onClick:()=>c(!1),className:"p-1.5 rounded-lg hover:bg-sidebar-accent lg:hidden",children:g.jsx(Mn,{className:"h-4 w-4 text-sidebar-foreground"})}),g.jsx("button",{onClick:u,className:ne("hidden lg:block p-1.5 rounded-lg hover:bg-sidebar-accent",S&&"mx-auto"),children:S?g.jsx(_i,{className:"h-4 w-4 text-sidebar-foreground"}):g.jsx(eo,{className:"h-4 w-4 text-sidebar-foreground"})})]}),k=s&&a&&g.jsx("div",{className:"px-3 py-3 border-t border-sidebar-border",children:g.jsxs(al,{children:[g.jsx(cl,{asChild:!0,children:g.jsxs("button",{className:ne("w-full flex items-center gap-3 px-2 py-2 rounded-lg transition-colors hover:bg-sidebar-accent",S&&"justify-center px-0"),children:[g.jsxs(Oo,{className:"h-8 w-8",children:[g.jsx(Po,{src:s.avatar,alt:s.firstName||"User"}),g.jsxs(Io,{className:"bg-sidebar-primary text-sidebar-primary-foreground text-xs",children:[((N=s.firstName)==null?void 0:N[0])||"U",((T=s.lastName)==null?void 0:T[0])||""]})]}),!S&&g.jsxs("div",{className:"flex-1 text-left",children:[g.jsxs("p",{className:"text-sm font-medium text-sidebar-foreground truncate",children:[s.firstName," ",s.lastName]}),g.jsx("p",{className:"text-xs text-sidebar-foreground/50 truncate",children:s.email})]})]})}),g.jsxs(Qs,{align:"end",className:"w-56",children:[g.jsx(Js,{children:"My Account"}),g.jsx(yi,{}),l.map((R,M)=>g.jsx(bi,{asChild:!!R.path,onClick:R.onClick,children:R.path?g.jsx(Je.Link,{to:R.path,children:R.label}):R.label},M)),l.length>0&&g.jsx(yi,{}),o&&g.jsx(bi,{onClick:o,className:"text-destructive",children:"Log out"})]})]})});return g.jsxs(g.Fragment,{children:[C&&g.jsx("div",{className:"fixed inset-0 bg-black/50 z-40 lg:hidden",onClick:()=>c(!1)}),g.jsxs("aside",{className:ne("fixed top-0 left-0 z-50 h-full bg-sidebar border-r border-sidebar-border transition-all duration-300 ease-in-out flex flex-col",C?"translate-x-0":"-translate-x-full",S?f:d,"lg:translate-x-0",r),children:[v||E,g.jsx("nav",{className:"flex-1 overflow-y-auto px-3 py-3",children:g.jsx("div",{className:"space-y-1",children:e.map(R=>x(R))})}),_||k]})]})}function ap({pathNames:e={},showBreadcrumbs:t=!0,showMenuButton:n=!0,className:i,leftSlot:s,rightSlot:o,breadcrumbsSlot:l,children:a}){const{toggle:r}=sr(),f=Je.useLocation(),d={dashboard:"Dashboard",users:"Users",roles:"Roles",permissions:"Permissions",settings:"Settings",profile:"Profile",create:"Create",edit:"Edit",...e},h=()=>{const v=f.pathname.split("/").filter(Boolean);return g.jsx("nav",{className:"flex items-center gap-1 text-sm",children:v.map((_,C)=>{const S="/"+v.slice(0,C+1).join("/"),c=C===v.length-1,u=d[_]||_;return g.jsxs("div",{className:"flex items-center gap-1",children:[C>0&&g.jsx(_i,{className:"h-4 w-4 text-muted-foreground"}),c?g.jsx("span",{className:"font-medium text-foreground",children:u}):g.jsx(Je.Link,{to:S,className:"text-muted-foreground hover:text-foreground transition-colors",children:u})]},S)})})};return g.jsxs("header",{className:ne("sticky top-0 z-30 bg-background",i),children:[g.jsxs("div",{className:"flex items-center h-14 px-4 md:px-6",children:[n&&g.jsx("button",{onClick:r,className:"p-2 -ml-2 rounded-lg hover:bg-muted lg:hidden",children:g.jsx(Sm,{className:"h-5 w-5"})}),g.jsx("div",{className:"flex items-center gap-4 flex-1",children:s||t&&(l||g.jsx(h,{}))}),o&&g.jsx("div",{className:"flex items-center gap-2",children:o}),a]}),g.jsx(Si,{})]})}function P3({sidebarProps:e,headerProps:t,showHeader:n=!0,showSidebar:i=!0,contentClassName:s,mainSlot:o,children:l}){const{isCollapsed:a}=sr();return g.jsxs("div",{className:"min-h-screen bg-background",children:[i&&g.jsx(lp,{...e}),g.jsxs("div",{className:ne("transition-all duration-300 ease-in-out",i&&(a?"lg:ml-16":"lg:ml-60")),children:[n&&g.jsx(ap,{...t}),g.jsx("main",{className:ne("p-4 md:p-6",s),children:o||l||g.jsx(Je.Outlet,{})})]})]})}function I3({sidebarProps:e={},headerProps:t={},defaultOpen:n=!1,defaultCollapsed:i=!1,showHeader:s=!0,showSidebar:o=!0,contentClassName:l,mainSlot:a,children:r}){return g.jsx(op,{defaultOpen:n,defaultCollapsed:i,children:g.jsx(P3,{sidebarProps:e,headerProps:t,showHeader:s,showSidebar:o,contentClassName:l,mainSlot:a,children:r})})}exports.Alert=ml;exports.AlertDescription=vl;exports.AlertTitle=gl;exports.AlertWithIcon=O0;exports.AuthLayout=L3;exports.Avatar=Oo;exports.AvatarFallback=Io;exports.AvatarImage=Po;exports.Badge=ii;exports.Button=we;exports.Calendar=Gs;exports.Card=ft;exports.CardContent=ht;exports.CardDescription=Dn;exports.CardFooter=mc;exports.CardHeader=An;exports.CardTitle=Rn;exports.Checkbox=On;exports.ConfirmModal=Ml;exports.CreateEmptyState=W0;exports.CrudDetail=ip;exports.CrudForm=np;exports.CrudList=Y0;exports.DashboardLayout=I3;exports.DataTable=Al;exports.DatePicker=Go;exports.DateRangePicker=Ko;exports.DeleteConfirmModal=xi;exports.Dialog=Sd;exports.DialogClose=Wy;exports.DialogContent=To;exports.DialogDescription=Ro;exports.DialogFooter=Fs;exports.DialogHeader=Mo;exports.DialogOverlay=ko;exports.DialogPortal=Ed;exports.DialogTitle=Ao;exports.DialogTrigger=Vy;exports.DropdownMenu=al;exports.DropdownMenuCheckboxItem=g0;exports.DropdownMenuContent=Qs;exports.DropdownMenuGroup=L4;exports.DropdownMenuItem=bi;exports.DropdownMenuLabel=Js;exports.DropdownMenuPortal=O4;exports.DropdownMenuRadioGroup=I4;exports.DropdownMenuRadioItem=v0;exports.DropdownMenuSeparator=yi;exports.DropdownMenuShortcut=b0;exports.DropdownMenuSub=P4;exports.DropdownMenuSubContent=m0;exports.DropdownMenuSubTrigger=p0;exports.DropdownMenuTrigger=cl;exports.EmptyState=Gn;exports.ErrorState=$0;exports.FormField=$t;exports.FormModal=U0;exports.Header=ap;exports.Input=Ln;exports.Label=Kt;exports.Loading=zn;exports.LoadingButton=V0;exports.LoadingOverlay=H0;exports.LoginPage=O3;exports.Modal=nr;exports.Pagination=kl;exports.Popover=jo;exports.PopoverContent=Ys;exports.PopoverTrigger=zo;exports.QCheckbox=Nl;exports.QDatePicker=F0;exports.QDateRangePicker=j0;exports.QForm=B0;exports.QInput=ms;exports.QRichTextEditor=z0;exports.QSearchSelect=Sl;exports.QSelect=Cl;exports.QSwitch=El;exports.QTabs=Kd;exports.QTextarea=_l;exports.RichTextEditor=Jo;exports.ScrollArea=D0;exports.ScrollBar=pl;exports.SearchEmptyState=Tl;exports.SearchSelect=wl;exports.Select=xo;exports.SelectContent=Ps;exports.SelectGroup=xy;exports.SelectItem=Is;exports.SelectLabel=ed;exports.SelectScrollDownButton=Co;exports.SelectScrollUpButton=_o;exports.SelectSeparator=td;exports.SelectTrigger=Os;exports.SelectValue=wo;exports.Separator=Si;exports.Sidebar=lp;exports.SidebarProvider=op;exports.Skeleton=ag;exports.Switch=ao;exports.Table=bl;exports.TableBody=xl;exports.TableCaption=I0;exports.TableCell=ln;exports.TableFooter=P0;exports.TableHead=li;exports.TableHeader=yl;exports.TableRow=En;exports.Tabs=wx;exports.TabsContent=Gd;exports.TabsList=Zd;exports.TabsTrigger=qd;exports.Textarea=no;exports.Tooltip=aw;exports.TooltipContent=gf;exports.TooltipProvider=lw;exports.TooltipTrigger=cw;exports.alertVariants=L0;exports.badgeVariants=gc;exports.buildQueryString=om;exports.buttonVariants=pc;exports.capitalize=Jp;exports.cn=ne;exports.createCrudStore=sp;exports.createStore=D3;exports.debounce=uc;exports.deepClone=tm;exports.formatCurrency=Kp;exports.formatDate=Jr;exports.formatDateTime=Ji;exports.formatRelativeTime=Xp;exports.generateId=sm;exports.getInitials=im;exports.isEmpty=nm;exports.parseQueryString=rm;exports.slugify=em;exports.truncate=Qp;exports.useSidebarContext=sr;
252
+ `+d.convertHTMLForCodeView(u,!1));else{const p=r.createElement("DIV");p.innerHTML=u;const b=e.element.wysiwyg,y=p.children;for(let w=0,x=y.length;w<x;w++)y[w]&&b.appendChild(y[w])}d.history.push(!1)},readOnly:function(c){d.isReadOnly=c,r.setDisabledButtons(!!c,d.resizingDisabledButtons),c?(d.controllersOff(),d.submenuActiveButton&&d.submenuActiveButton.disabled&&d.submenuOff(),d._moreLayerActiveButton&&d._moreLayerActiveButton.disabled&&d.moreLayerOff(),d.containerActiveButton&&d.containerActiveButton.disabled&&d.containerOff(),d.modalForm&&d.plugins.dialog.close.call(d),e.element.code.setAttribute("readOnly","true"),r.addClass(e.element.wysiwygFrame,"se-read-only")):(e.element.code.removeAttribute("readOnly"),r.removeClass(e.element.wysiwygFrame,"se-read-only")),s.codeMirrorEditor&&s.codeMirrorEditor.setOption("readOnly",!!c)},disable:function(){this.toolbar.disable(),this.wysiwyg.disable()},disabled:function(){this.disable()},enable:function(){this.toolbar.enable(),this.wysiwyg.enable()},enabled:function(){this.enable()},show:function(){const c=e.element.topArea.style;c.display==="none"&&(c.display=s.display)},hide:function(){e.element.topArea.style.display="none"},destroy:function(){d.submenuOff(),d.containerOff(),d.controllersOff(),d.notice&&d.notice.close.call(d),d.modalForm&&d.plugins.dialog.close.call(d),d.history._destroy(),h._removeEvent(),r.removeItem(e.element.toolbar),r.removeItem(e.element.topArea);for(let c in d.functions)r.hasOwn(d,c)&&delete d.functions[c];for(let c in d)r.hasOwn(d,c)&&delete d[c];for(let c in h)r.hasOwn(h,c)&&delete h[c];for(let c in e)r.hasOwn(e,c)&&delete e[c];for(let c in t)r.hasOwn(t,c)&&delete t[c];for(let c in this)r.hasOwn(this,c)&&delete this[c]},toolbar:{disable:function(){d.submenuOff(),d.moreLayerOff(),d.containerOff(),e.tool.cover.style.display="block"},disabled:function(){this.disable()},enable:function(){e.tool.cover.style.display="none"},enabled:function(){this.enable()},show:function(){d._isInline?h._showToolbarInline():(e.element.toolbar.style.display="",e.element._stickyDummy.style.display=""),h.onResize_window()},hide:function(){d._isInline?h._hideToolbar():(e.element.toolbar.style.display="none",e.element._stickyDummy.style.display="none"),h.onResize_window()}},wysiwyg:{disable:function(){d.controllersOff(),d.modalForm&&d.plugins.dialog.close.call(d),e.element.wysiwyg.setAttribute("contenteditable",!1),d.isDisabled=!0,s.codeMirrorEditor?s.codeMirrorEditor.setOption("readOnly",!0):e.element.code.setAttribute("disabled","disabled")},enable:function(){e.element.wysiwyg.setAttribute("contenteditable",!0),d.isDisabled=!1,s.codeMirrorEditor?s.codeMirrorEditor.setOption("readOnly",!1):e.element.code.removeAttribute("disabled")}}};d.functions=v,d.options=s;let _=e.element,C=_.originElement,S=_.topArea;return C.style.display="none",S.style.display="block",s.iframe&&_.wysiwygFrame.addEventListener("load",function(){r._setIframeDocument(this,s),d._editorInit(!1,s.value),s.value=null}),typeof C.nextElementSibling=="object"?C.parentNode.insertBefore(S,C.nextElementSibling):C.parentNode.appendChild(S),_.editorArea.appendChild(_.wysiwygFrame),_=C=S=null,s.iframe||(d._editorInit(!1,s.value),s.value=null),v}const MC={init:function(e){return{create:(function(t,n){return this.create(t,n,e)}).bind(this)}},create:function(e,t,n){pe._propertiesInit(),typeof t!="object"&&(t={}),n&&(t=[n,t].reduce(function(o,l){for(let a in l)if(pe.hasOwn(l,a))if(a==="plugins"&&l[a]&&o[a]){let r=o[a],f=l[a];r=r.length?r:Object.keys(r).map(function(d){return r[d]}),f=f.length?f:Object.keys(f).map(function(d){return f[d]}),o[a]=f.filter(function(d){return r.indexOf(d)===-1}).concat(r)}else o[a]=l[a];return o},{}));const i=typeof e=="string"?document.getElementById(e):e;if(!i)throw Error(typeof e=="string"?'[SUNEDITOR.create.fail] The element for that id was not found (ID:"'+e+'")':"[SUNEDITOR.create.fail] suneditor requires textarea's element or id value");const s=Zr.init(i,t);if(s.constructed._top.id&&document.getElementById(s.constructed._top.id))throw Error('[SUNEDITOR.create.fail] The ID of the suneditor you are trying to create already exists (ID:"'+s.constructed._top.id+'")');return TC(qr(i,s.constructed,s.options),s.pluginCallButtons,s.plugins,s.options.lang,t,s._responsiveButtons)}},AC={name:"blockquote",display:"command",add:function(e,t){const n=e.context;n.blockquote={targetButton:t,tag:e.util.createElement("BLOCKQUOTE")}},active:function(e){if(!e)this.util.removeClass(this.context.blockquote.targetButton,"active");else if(/blockquote/i.test(e.nodeName))return this.util.addClass(this.context.blockquote.targetButton,"active"),!0;return!1},action:function(){const e=this.util.getParentElement(this.getSelectionNode(),"blockquote");e?this.detachRangeFormatElement(e,null,null,!1,!1):this.applyRangeFormatElement(this.context.blockquote.tag.cloneNode(!1))}},RC={name:"align",display:"submenu",add:function(e,t){const n=e.icons,i=e.context;i.align={targetButton:t,_itemMenu:null,_alignList:null,currentAlign:"",defaultDir:e.options.rtl?"right":"left",icons:{justify:n.align_justify,left:n.align_left,right:n.align_right,center:n.align_center}};let s=this.setSubmenu(e),o=i.align._itemMenu=s.querySelector("ul");o.addEventListener("click",this.pickup.bind(e)),i.align._alignList=o.querySelectorAll("li button"),e.initMenuTarget(this.name,t,s),s=null,o=null},setSubmenu:function(e){const t=e.lang,n=e.icons,i=e.util.createElement("DIV"),s=e.options.alignItems;let o="";for(let l=0,a,r;l<s.length;l++)a=s[l],r=t.toolbar["align"+a.charAt(0).toUpperCase()+a.slice(1)],o+='<li><button type="button" class="se-btn-list se-btn-align" data-value="'+a+'" title="'+r+'" aria-label="'+r+'"><span class="se-list-icon">'+n["align_"+a]+"</span>"+r+"</button></li>";return i.className="se-submenu se-list-layer se-list-align",i.innerHTML='<div class="se-list-inner"><ul class="se-list-basic">'+o+"</ul></div>",i},active:function(e){const t=this.context.align,n=t.targetButton,i=n.firstElementChild;if(!e)this.util.changeElement(i,t.icons[t.defaultDir]),n.removeAttribute("data-focus");else if(this.util.isFormatElement(e)){const s=e.style.textAlign;if(s)return this.util.changeElement(i,t.icons[s]||t.icons[t.defaultDir]),n.setAttribute("data-focus",s),!0}return!1},on:function(){const e=this.context.align,t=e._alignList,n=e.targetButton.getAttribute("data-focus")||e.defaultDir;if(n!==e.currentAlign){for(let i=0,s=t.length;i<s;i++)n===t[i].getAttribute("data-value")?this.util.addClass(t[i],"active"):this.util.removeClass(t[i],"active");e.currentAlign=n}},exchangeDir:function(){const e=this.options.rtl?"right":"left";if(!this.context.align||this.context.align.defaultDir===e)return;this.context.align.defaultDir=e;let t=this.context.align._itemMenu,n=t.querySelector('[data-value="left"]'),i=t.querySelector('[data-value="right"]');if(n&&i){const s=n.parentElement,o=i.parentElement;s.appendChild(i),o.appendChild(n)}},pickup:function(e){e.preventDefault(),e.stopPropagation();let t=e.target,n=null;for(;!n&&!/UL/i.test(t.tagName);)n=t.getAttribute("data-value"),t=t.parentNode;if(!n)return;const i=this.context.align.defaultDir,s=this.getSelectedElements();for(let o=0,l=s.length;o<l;o++)this.util.setStyle(s[o],"textAlign",n===i?"":n);this.effectNode=null,this.submenuOff(),this.focus(),this.history.push(!1)}},DC={name:"font",display:"submenu",add:function(e,t){const n=e.context;n.font={targetText:t.querySelector(".txt"),targetTooltip:t.parentNode.querySelector(".se-tooltip-text"),_fontList:null,currentFont:""};let i=this.setSubmenu(e);i.querySelector(".se-list-inner").addEventListener("click",this.pickup.bind(e)),n.font._fontList=i.querySelectorAll("ul li button"),e.initMenuTarget(this.name,t,i),i=null},setSubmenu:function(e){const t=e.lang,n=e.util.createElement("DIV");n.className="se-submenu se-list-layer se-list-font-family";let i,s,o,l,a=e.options.font,r='<div class="se-list-inner"><ul class="se-list-basic"><li><button type="button" class="default_value se-btn-list" title="'+t.toolbar.default+'" aria-label="'+t.toolbar.default+'">('+t.toolbar.default+")</button></li>";for(o=0,l=a.length;o<l;o++)i=a[o],s=i.split(",")[0],r+='<li><button type="button" class="se-btn-list" data-value="'+i+'" data-txt="'+s+'" title="'+s+'" aria-label="'+s+'" style="font-family:'+i+';">'+s+"</button></li>";return r+="</ul></div>",n.innerHTML=r,n},active:function(e){const t=this.context.font.targetText,n=this.context.font.targetTooltip;if(e){if(e.style&&e.style.fontFamily.length>0){const i=e.style.fontFamily.replace(/["']/g,"");return this.util.changeTxt(t,i),this.util.changeTxt(n,this.lang.toolbar.font+" ("+i+")"),!0}}else{const i=this.hasFocus?this.wwComputedStyle.fontFamily:this.lang.toolbar.font;this.util.changeTxt(t,i),this.util.changeTxt(n,this.hasFocus?this.lang.toolbar.font+(i?" ("+i+")":""):i)}return!1},on:function(){const e=this.context.font,t=e._fontList,n=e.targetText.textContent;if(n!==e.currentFont){for(let i=0,s=t.length;i<s;i++)n===(t[i].getAttribute("data-value")||"").replace(/'|"/g,"")?this.util.addClass(t[i],"active"):this.util.removeClass(t[i],"active");e.currentFont=n}},pickup:function(e){if(!/^BUTTON$/i.test(e.target.tagName))return!1;e.preventDefault(),e.stopPropagation();let t=e.target.getAttribute("data-value");if(t){const n=this.util.createElement("SPAN");/[\s\d\W]/.test(t)&&!/^['"].*['"]$/.test(t)&&(t='"'+t+'"'),n.style.fontFamily=t,this.nodeChange(n,["font-family"],null,null)}else this.nodeChange(null,["font-family"],["span"],!0);this.submenuOff()}},LC={name:"fontSize",display:"submenu",add:function(e,t){const n=e.context;n.fontSize={targetText:t.querySelector(".txt"),_sizeList:null,currentSize:""};let i=this.setSubmenu(e),s=i.querySelector("ul");s.addEventListener("click",this.pickup.bind(e)),n.fontSize._sizeList=s.querySelectorAll("li button"),e.initMenuTarget(this.name,t,i),i=null,s=null},setSubmenu:function(e){const t=e.options,n=e.lang,i=e.util.createElement("DIV");i.className="se-submenu se-list-layer se-list-font-size";const s=t.fontSize?t.fontSize:[8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72];let o='<div class="se-list-inner"><ul class="se-list-basic"><li><button type="button" class="default_value se-btn-list" title="'+n.toolbar.default+'" aria-label="'+n.toolbar.default+'">('+n.toolbar.default+")</button></li>";for(let l=0,a=t.fontSizeUnit,r=s.length,f;l<r;l++)f=s[l],o+='<li><button type="button" class="se-btn-list" data-value="'+f+a+'" title="'+f+a+'" aria-label="'+f+a+'" style="font-size:'+f+a+';">'+f+"</button></li>";return o+="</ul></div>",i.innerHTML=o,i},active:function(e){if(!e)this.util.changeTxt(this.context.fontSize.targetText,this.hasFocus?this._convertFontSize.call(this,this.options.fontSizeUnit,this.wwComputedStyle.fontSize):this.lang.toolbar.fontSize);else if(e.style&&e.style.fontSize.length>0)return this.util.changeTxt(this.context.fontSize.targetText,this._convertFontSize.call(this,this.options.fontSizeUnit,e.style.fontSize)),!0;return!1},on:function(){const e=this.context.fontSize,t=e._sizeList,n=e.targetText.textContent;if(n!==e.currentSize){for(let i=0,s=t.length;i<s;i++)n===t[i].getAttribute("data-value")?this.util.addClass(t[i],"active"):this.util.removeClass(t[i],"active");e.currentSize=n}},pickup:function(e){if(!/^BUTTON$/i.test(e.target.tagName))return!1;e.preventDefault(),e.stopPropagation();const t=e.target.getAttribute("data-value");if(t){const n=this.util.createElement("SPAN");n.style.fontSize=t,this.nodeChange(n,["font-size"],null,null)}else this.nodeChange(null,["font-size"],["span"],!0);this.submenuOff()}},lh={name:"colorPicker",add:function(e){const t=e.context;t.colorPicker={colorListHTML:"",_colorInput:"",_defaultColor:"#000",_styleProperty:"color",_currentColor:"",_colorList:[]},t.colorPicker.colorListHTML=this.createColorList(e,this._makeColorList)},createColorList:function(e,t){const n=e.options,i=e.lang,s=!n.colorList||n.colorList.length===0?["#ff0000","#ff5e00","#ffe400","#abf200","#00d8ff","#0055ff","#6600ff","#ff00dd","#000000","#ffd8d8","#fae0d4","#faf4c0","#e4f7ba","#d4f4fa","#d9e5ff","#e8d9ff","#ffd9fa","#f1f1f1","#ffa7a7","#ffc19e","#faed7d","#cef279","#b2ebf4","#b2ccff","#d1b2ff","#ffb2f5","#bdbdbd","#f15f5f","#f29661","#e5d85c","#bce55c","#5cd1e5","#6699ff","#a366ff","#f261df","#8c8c8c","#980000","#993800","#998a00","#6b9900","#008299","#003399","#3d0099","#990085","#353535","#670000","#662500","#665c00","#476600","#005766","#002266","#290066","#660058","#222222"]:n.colorList;let o=[],l='<div class="se-list-inner">';for(let a=0,r=s.length,f;a<r;a++)f=s[a],f&&(typeof f=="string"&&(o.push(f),a<r-1)||(o.length>0&&(l+='<div class="se-selector-color">'+t(o)+"</div>",o=[]),typeof f=="object"&&(l+='<div class="se-selector-color">'+t(f)+"</div>")));return l+='<form class="se-form-group"><input type="text" maxlength="9" class="_se_color_picker_input se-color-input"/><button type="submit" class="se-btn-primary _se_color_picker_submit" title="'+i.dialogBox.submitButton+'" aria-label="'+i.dialogBox.submitButton+'">'+e.icons.checked+'</button><button type="button" class="se-btn _se_color_picker_remove" title="'+i.toolbar.removeFormat+'" aria-label="'+i.toolbar.removeFormat+'">'+e.icons.erase+"</button></form></div>",l},_makeColorList:function(e){let t="";t+='<ul class="se-color-pallet">';for(let n=0,i=e.length,s;n<i;n++)s=e[n],typeof s=="string"&&(t+='<li><button type="button" data-value="'+s+'" title="'+s+'" aria-label="'+s+'" style="background-color:'+s+';"></button></li>');return t+="</ul>",t},init:function(e,t){const n=this.plugins.colorPicker;let i=t||n.getColorInNode.call(this,e)||this.context.colorPicker._defaultColor;i=n.isHexColor(i)?i:n.rgb2hex(i)||i;const s=this.context.colorPicker._colorList;if(s)for(let o=0,l=s.length;o<l;o++)i.toLowerCase()===s[o].getAttribute("data-value").toLowerCase()?this.util.addClass(s[o],"active"):this.util.removeClass(s[o],"active");n.setInputText.call(this,n.colorName2hex.call(this,i))},setCurrentColor:function(e){this.context.colorPicker._currentColor=e,this.context.colorPicker._colorInput.style.borderColor=e},setInputText:function(e){e=/^#/.test(e)?e:"#"+e,this.context.colorPicker._colorInput.value=e,this.plugins.colorPicker.setCurrentColor.call(this,e)},getColorInNode:function(e){let t="";const n=this.context.colorPicker._styleProperty;for(;e&&!this.util.isWysiwygDiv(e)&&t.length===0;)e.nodeType===1&&e.style[n]&&(t=e.style[n]),e=e.parentNode;return t},isHexColor:function(e){return/^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(e)},rgb2hex:function(e){const t=e.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);return t&&t.length===4?"#"+("0"+parseInt(t[1],10).toString(16)).slice(-2)+("0"+parseInt(t[2],10).toString(16)).slice(-2)+("0"+parseInt(t[3],10).toString(16)).slice(-2):""},colorName2hex:function(e){if(/^#/.test(e))return e;var t=this.util.createElement("div");t.style.display="none",t.style.color=e;var n=this._w.getComputedStyle(this._d.body.appendChild(t)).color.match(/\d+/g).map(function(i){return parseInt(i,10)});return this.util.removeItem(t),n.length>=3?"#"+((1<<24)+(n[0]<<16)+(n[1]<<8)+n[2]).toString(16).substr(1):!1}},OC={name:"fontColor",display:"submenu",add:function(e,t){e.addModule([lh]);const n=e.context;n.fontColor={previewEl:null,colorInput:null,colorList:null};let i=this.setSubmenu(e);n.fontColor.colorInput=i.querySelector("._se_color_picker_input"),n.fontColor.colorInput.addEventListener("keyup",this.onChangeInput.bind(e)),i.querySelector("._se_color_picker_submit").addEventListener("click",this.submit.bind(e)),i.querySelector("._se_color_picker_remove").addEventListener("click",this.remove.bind(e)),i.addEventListener("click",this.pickup.bind(e)),n.fontColor.colorList=i.querySelectorAll("li button"),e.initMenuTarget(this.name,t,i),i=null},setSubmenu:function(e){const t=e.context.colorPicker.colorListHTML,n=e.util.createElement("DIV");return n.className="se-submenu se-list-layer",n.innerHTML=t,n},on:function(){const e=this.context.colorPicker,t=this.context.fontColor;e._colorInput=t.colorInput;const n=this.wwComputedStyle.color;e._defaultColor=n?this.plugins.colorPicker.isHexColor(n)?n:this.plugins.colorPicker.rgb2hex(n):"#333333",e._styleProperty="color",e._colorList=t.colorList,this.plugins.colorPicker.init.call(this,this.getSelectionNode(),null)},onChangeInput:function(e){this.plugins.colorPicker.setCurrentColor.call(this,e.target.value)},submit:function(){this.plugins.fontColor.applyColor.call(this,this.context.colorPicker._currentColor)},pickup:function(e){e.preventDefault(),e.stopPropagation(),this.plugins.fontColor.applyColor.call(this,e.target.getAttribute("data-value"))},remove:function(){this.nodeChange(null,["color"],["span"],!0),this.submenuOff()},applyColor:function(e){if(!e)return;const t=this.util.createElement("SPAN");t.style.color=e,this.nodeChange(t,["color"],null,null),this.submenuOff()}},PC={name:"hiliteColor",display:"submenu",add:function(e,t){e.addModule([lh]);const n=e.context;n.hiliteColor={previewEl:null,colorInput:null,colorList:null};let i=this.setSubmenu(e);n.hiliteColor.colorInput=i.querySelector("._se_color_picker_input"),n.hiliteColor.colorInput.addEventListener("keyup",this.onChangeInput.bind(e)),i.querySelector("._se_color_picker_submit").addEventListener("click",this.submit.bind(e)),i.querySelector("._se_color_picker_remove").addEventListener("click",this.remove.bind(e)),i.addEventListener("click",this.pickup.bind(e)),n.hiliteColor.colorList=i.querySelectorAll("li button"),e.initMenuTarget(this.name,t,i),i=null},setSubmenu:function(e){const t=e.context.colorPicker.colorListHTML,n=e.util.createElement("DIV");return n.className="se-submenu se-list-layer",n.innerHTML=t,n},on:function(){const e=this.context.colorPicker,t=this.context.hiliteColor;e._colorInput=t.colorInput;const n=this.wwComputedStyle.backgroundColor;e._defaultColor=n?this.plugins.colorPicker.isHexColor(n)?n:this.plugins.colorPicker.rgb2hex(n):"#ffffff",e._styleProperty="backgroundColor",e._colorList=t.colorList,this.plugins.colorPicker.init.call(this,this.getSelectionNode(),null)},onChangeInput:function(e){this.plugins.colorPicker.setCurrentColor.call(this,e.target.value)},submit:function(){this.plugins.hiliteColor.applyColor.call(this,this.context.colorPicker._currentColor)},pickup:function(e){e.preventDefault(),e.stopPropagation(),this.plugins.hiliteColor.applyColor.call(this,e.target.getAttribute("data-value"))},remove:function(){this.nodeChange(null,["background-color"],["span"],!0),this.submenuOff()},applyColor:function(e){if(!e)return;const t=this.util.createElement("SPAN");t.style.backgroundColor=e,this.nodeChange(t,["background-color"],null,null),this.submenuOff()}},IC={name:"horizontalRule",display:"submenu",add:function(e,t){e.context.horizontalRule={currentHR:null};let n=this.setSubmenu(e);n.querySelector("ul").addEventListener("click",this.horizontalRulePick.bind(e)),e.initMenuTarget(this.name,t,n),n=null},setSubmenu:function(e){const t=e.lang,n=e.util.createElement("DIV"),i=e.options.hrItems||[{name:t.toolbar.hr_solid,class:"__se__solid"},{name:t.toolbar.hr_dashed,class:"__se__dashed"},{name:t.toolbar.hr_dotted,class:"__se__dotted"}];let s="";for(let o=0,l=i.length;o<l;o++)s+='<li><button type="button" class="se-btn-list btn_line" data-command="horizontalRule" data-value="'+i[o].class+'" title="'+i[o].name+'" aria-label="'+i[o].name+'"><hr'+(i[o].class?' class="'+i[o].class+'"':"")+(i[o].style?' style="'+i[o].style+'"':"")+"/></button></li>";return n.className="se-submenu se-list-layer se-list-line",n.innerHTML='<div class="se-list-inner"><ul class="se-list-basic">'+s+"</ul></div>",n},active:function(e){if(!e)this.util.hasClass(this.context.horizontalRule.currentHR,"on")&&this.controllersOff();else if(/HR/i.test(e.nodeName))return this.context.horizontalRule.currentHR=e,this.util.hasClass(e,"on")||(this.util.addClass(e,"on"),this.controllersOn("hr",this.util.removeClass.bind(this.util,e,"on"))),!0;return!1},appendHr:function(e){return this.focus(),this.insertComponent(e.cloneNode(!1),!1,!0,!1)},horizontalRulePick:function(e){e.preventDefault(),e.stopPropagation();let t=e.target,n=t.getAttribute("data-command");for(;!n&&!/UL/i.test(t.tagName);)t=t.parentNode,n=t.getAttribute("data-command");if(!n)return;const i=this.plugins.horizontalRule.appendHr.call(this,t.firstElementChild);i&&(this.setRange(i,0,i,0),this.submenuOff())}},BC={name:"list",display:"submenu",add:function(e,t){const n=e.context;n.list={targetButton:t,_list:null,currentList:"",icons:{bullets:e.icons.list_bullets,number:e.icons.list_number}};let i=this.setSubmenu(e),s=i.querySelector("ul");s.addEventListener("click",this.pickup.bind(e)),n.list._list=s.querySelectorAll("li button"),e.initMenuTarget(this.name,t,i),i=null,s=null},setSubmenu:function(e){const t=e.lang,n=e.util.createElement("DIV");return n.className="se-submenu se-list-layer",n.innerHTML='<div class="se-list-inner"><ul class="se-list-basic"><li><button type="button" class="se-btn-list se-tooltip" data-command="OL" title="'+t.toolbar.orderList+'" aria-label="'+t.toolbar.orderList+'">'+e.icons.list_number+'</button></li><li><button type="button" class="se-btn-list se-tooltip" data-command="UL" title="'+t.toolbar.unorderList+'" aria-label="'+t.toolbar.unorderList+'">'+e.icons.list_bullets+"</button></li></ul></div>",n},active:function(e){const t=this.context.list.targetButton,n=t.firstElementChild,i=this.util;if(i.isList(e)){const s=e.nodeName;return t.setAttribute("data-focus",s),i.addClass(t,"active"),/UL/i.test(s)?i.changeElement(n,this.context.list.icons.bullets):i.changeElement(n,this.context.list.icons.number),!0}else t.removeAttribute("data-focus"),i.changeElement(n,this.context.list.icons.number),i.removeClass(t,"active");return!1},on:function(){const e=this.context.list,t=e._list,n=e.targetButton.getAttribute("data-focus")||"";if(n!==e.currentList){for(let i=0,s=t.length;i<s;i++)n===t[i].getAttribute("data-command")?this.util.addClass(t[i],"active"):this.util.removeClass(t[i],"active");e.currentList=n}},editList:function(e,t,n){let i=this.getRange(),s=t||this.getSelectedElementsAndComponents(!1);if(s.length===0&&(t||(i=this.getRange_addLine(i,null),s=this.getSelectedElementsAndComponents(!1),s.length===0)))return;const o=this.util;o.sortByDepth(s,!0);let l=s[0],a=s[s.length-1],r=(o.isListCell(l)||o.isComponent(l))&&!l.previousElementSibling?l.parentNode.previousElementSibling:l.previousElementSibling,f=(o.isListCell(a)||o.isComponent(a))&&!a.nextElementSibling?a.parentNode.nextElementSibling:a.nextElementSibling;const d=i.collapsed,h={sc:i.startContainer,so:i.startContainer===i.endContainer&&o.onlyZeroWidthSpace(i.startContainer)&&i.startOffset===0&&i.endOffset===1?i.endOffset:i.startOffset,ec:i.endContainer,eo:i.endOffset};let v=null,_=!0;for(let C=0,S=s.length;C<S;C++)if(!o.isList(o.getRangeFormatElement(s[C],(function(c){return this.getRangeFormatElement(c)&&c!==s[C]}).bind(o)))){_=!1;break}if(_&&(!r||l.tagName!==r.tagName||e!==r.tagName.toUpperCase())&&(!f||a.tagName!==f.tagName||e!==f.tagName.toUpperCase())){if(n){for(let b=0,y=s.length;b<y;b++)for(let w=b-1;w>=0;w--)if(s[w].contains(s[b])){s.splice(b,1),b--,y--;break}}const C=o.getRangeFormatElement(l),S=C&&C.tagName===e;let c,u;const p=(function(b){return!this.isComponent(b)}).bind(o);S||(u=o.createElement(e));for(let b=0,y=s.length,w,x;b<y;b++)x=o.getRangeFormatElement(s[b],p),!(!x||!o.isList(x))&&(w?w!==x?(n&&o.isListCell(x.parentNode)?this.plugins.list._detachNested.call(this,c.f):v=this.detachRangeFormatElement(c.f[0].parentNode,c.f,u,!1,!0),x=s[b].parentNode,S||(u=o.createElement(e)),w=x,c={r:w,f:[o.getParentElement(s[b],"LI")]}):c.f.push(o.getParentElement(s[b],"LI")):(w=x,c={r:w,f:[o.getParentElement(s[b],"LI")]}),b===y-1&&(n&&o.isListCell(x.parentNode)?this.plugins.list._detachNested.call(this,c.f):v=this.detachRangeFormatElement(c.f[0].parentNode,c.f,u,!1,!0)))}else{const C=r&&r.parentNode,S=f&&f.parentNode;r=C&&!o.isWysiwygDiv(C)&&C.nodeName===e?C:r,f=S&&!o.isWysiwygDiv(S)&&S.nodeName===e?S:f;const c=r&&r.tagName===e,u=f&&f.tagName===e;let p=c?r:o.createElement(e),b=null,y=null,w=null;const x=(function(E){return!this.isComponent(E)&&!this.isList(E)}).bind(o);for(let E=0,k=s.length,N,T,R,M,A,D,$,H,j;E<k;E++){if(T=s[E],T.childNodes.length===0&&!o._isIgnoreNodeChange(T)){o.removeItem(T);continue}if(M=s[E+1],A=T.parentNode,D=M?M.parentNode:null,R=o.isListCell(T),j=o.isRangeFormatElement(A)?A:null,$=R&&!o.isWysiwygDiv(A)?A.parentNode:A,H=R&&!o.isWysiwygDiv(A)?!M||o.isListCell($)?A:A.nextSibling:T.nextSibling,N=o.createElement("LI"),o.copyFormatAttributes(N,T),E===0&&h.sc===T&&(h.sc=N),E===k-1&&h.ec===T&&(h.ec=N),o.isComponent(T)){const F=/^HR$/i.test(T.nodeName);F||(N.innerHTML="<br>"),N.innerHTML+=T.outerHTML,F&&(N.innerHTML+="<br>")}else{const F=T.childNodes;for(;F[0];)N.appendChild(F[0])}p.appendChild(N),(!M||$!==D||o.isRangeFormatElement(H))&&(b||(b=p),(!c||!M||$!==D)&&!(M&&o.isList(D)&&D===A)&&p.parentNode!==$&&$.insertBefore(p,H)),o.removeItem(T),c&&y===null&&(y=p.children.length-1),M&&(o.getRangeFormatElement(D,x)!==o.getRangeFormatElement(A,x)||o.isList(D)&&o.isList(A)&&o.getElementDepth(D)!==o.getElementDepth(A))&&(p=o.createElement(e)),j&&j.children.length===0&&o.removeItem(j)}y&&(b=b.children[y]),u&&(w=p.children.length-1,p.innerHTML+=f.innerHTML,p.children[w],o.removeItem(f))}return this.effectNode=null,d&&v||h},_detachNested:function(e){const t=e[0],n=e[e.length-1],i=n.nextElementSibling,s=t.parentNode,o=s.parentNode.nextElementSibling,l=s.parentNode.parentNode;for(let r=0,f=e.length;r<f;r++)l.insertBefore(e[r],o);if(i&&s.children.length>0){const r=s.cloneNode(!1),f=s.childNodes,d=this.util.getPositionIndex(i);for(;f[d];)r.appendChild(f[d]);n.appendChild(r)}s.children.length===0&&this.util.removeItem(s),this.util.mergeSameTags(l);const a=this.util.getEdgeChildNodes(t,n);return{cc:t.parentNode,sc:a.sc,ec:a.ec}},editInsideList:function(e,t){t=t||this.getSelectedElements().filter((function(l){return this.isListCell(l)}).bind(this.util));const n=t.length;if(n===0||!e&&!this.util.isListCell(t[0].previousElementSibling)&&!this.util.isListCell(t[n-1].nextElementSibling))return{sc:t[0],so:0,ec:t[n-1],eo:1};let i=t[0].parentNode,s=t[n-1],o=null;if(e){if(i!==s.parentNode&&this.util.isList(s.parentNode.parentNode)&&s.nextElementSibling)for(s=s.nextElementSibling;s;)t.push(s),s=s.nextElementSibling;o=this.plugins.list.editList.call(this,i.nodeName.toUpperCase(),t,!0)}else{let l=this.util.createElement(i.nodeName),a=t[0].previousElementSibling,r=s.nextElementSibling;const f={s:null,e:null,sl:i,el:i};for(let v=0,_=n,C;v<_;v++)C=t[v],C.parentNode!==i&&(this.plugins.list._insiedList.call(this,i,l,a,r,f),i=C.parentNode,l=this.util.createElement(i.nodeName)),a=C.previousElementSibling,r=C.nextElementSibling,l.appendChild(C);this.plugins.list._insiedList.call(this,i,l,a,r,f);const d=this.util.getNodeFromPath(f.s,f.sl),h=this.util.getNodeFromPath(f.e,f.el);o={sc:d,so:0,ec:h,eo:h.textContent.length}}return o},_insiedList:function(e,t,n,i,s){let o=!1;if(n&&t.tagName===n.tagName){const l=t.children;for(;l[0];)n.appendChild(l[0]);t=n,o=!0}if(i&&t.tagName===i.tagName){const l=i.children;for(;l[0];)t.appendChild(l[0]);const a=i.nextElementSibling;i.parentNode.removeChild(i),i=a}if(!o){this.util.isListCell(n)&&(e=n,i=null),e.insertBefore(t,i),s.s||(s.s=this.util.getNodePath(t.firstElementChild.firstChild,e,null),s.sl=e);const l=e.contains(s.sl)?this.util.getNodePath(s.sl,e):null;s.e=this.util.getNodePath(t.lastElementChild.firstChild,e,null),s.el=e,this.util.mergeSameTags(e,[s.s,s.e,l],!1),this.util.mergeNestedTags(e),l&&(s.sl=this.util.getNodeFromPath(l,e))}return t},pickup:function(e){e.preventDefault(),e.stopPropagation();let t=e.target,n="";for(;!n&&!/^UL$/i.test(t.tagName);)n=t.getAttribute("data-command"),t=t.parentNode;if(!n)return;const i=this.plugins.list.editList.call(this,n,null,!1);i&&this.setRange(i.sc,i.so,i.ec,i.eo),this.submenuOff(),this.history.push(!1)}},FC={name:"table",display:"submenu",add:function(e,t){const n=e.context;let i=n.table={_element:null,_tdElement:null,_trElement:null,_trElements:null,_tableXY:[],_maxWidth:!0,_fixedColumn:!1,_rtl:e.options.rtl,cellControllerTop:e.options.tableCellControllerPosition==="top",resizeText:null,headerButton:null,mergeButton:null,splitButton:null,splitMenu:null,maxText:e.lang.controller.maxSize,minText:e.lang.controller.minSize,_physical_cellCnt:0,_logical_cellCnt:0,_rowCnt:0,_rowIndex:0,_physical_cellIndex:0,_logical_cellIndex:0,_current_colSpan:0,_current_rowSpan:0,icons:{expansion:e.icons.expansion,reduction:e.icons.reduction}},s=this.setSubmenu(e),o=s.querySelector(".se-controller-table-picker");i.tableHighlight=s.querySelector(".se-table-size-highlighted"),i.tableUnHighlight=s.querySelector(".se-table-size-unhighlighted"),i.tableDisplay=s.querySelector(".se-table-size-display"),e.options.rtl&&(i.tableHighlight.style.left=10*18-13+"px");let l=this.setController_table(e);i.tableController=l,i.resizeButton=l.querySelector("._se_table_resize"),i.resizeText=l.querySelector("._se_table_resize > span > span"),i.columnFixedButton=l.querySelector("._se_table_fixed_column"),i.headerButton=l.querySelector("._se_table_header");let a=this.setController_tableEditor(e,i.cellControllerTop);i.resizeDiv=a,i.splitMenu=a.querySelector(".se-btn-group-sub"),i.mergeButton=a.querySelector("._se_table_merge_button"),i.splitButton=a.querySelector("._se_table_split_button"),i.insertRowAboveButton=a.querySelector("._se_table_insert_row_a"),i.insertRowBelowButton=a.querySelector("._se_table_insert_row_b"),o.addEventListener("mousemove",this.onMouseMove_tablePicker.bind(e,i)),o.addEventListener("click",this.appendTable.bind(e)),a.addEventListener("click",this.onClick_tableController.bind(e)),l.addEventListener("click",this.onClick_tableController.bind(e)),e.initMenuTarget(this.name,t,s),n.element.relative.appendChild(a),n.element.relative.appendChild(l),s=null,o=null,a=null,l=null,i=null},setSubmenu:function(e){const t=e.util.createElement("DIV");return t.className="se-submenu se-selector-table",t.innerHTML='<div class="se-table-size"><div class="se-table-size-picker se-controller-table-picker"></div><div class="se-table-size-highlighted"></div><div class="se-table-size-unhighlighted"></div></div><div class="se-table-size-display">1 x 1</div>',t},setController_table:function(e){const t=e.lang,n=e.icons,i=e.util.createElement("DIV");return i.className="se-controller se-controller-table",i.innerHTML='<div><div class="se-btn-group"><button type="button" data-command="resize" class="se-btn se-tooltip _se_table_resize">'+n.expansion+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+t.controller.maxSize+'</span></span></button><button type="button" data-command="layout" class="se-btn se-tooltip _se_table_fixed_column">'+n.fixed_column_width+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+t.controller.fixedColumnWidth+'</span></span></button><button type="button" data-command="header" class="se-btn se-tooltip _se_table_header">'+n.table_header+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+t.controller.tableHeader+'</span></span></button><button type="button" data-command="remove" class="se-btn se-tooltip">'+n.delete+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+t.controller.remove+"</span></span></button></div></div>",i},setController_tableEditor:function(e,t){const n=e.lang,i=e.icons,s=e.util.createElement("DIV");return s.className="se-controller se-controller-table-cell",s.innerHTML=(t?"":'<div class="se-arrow se-arrow-up"></div>')+'<div class="se-btn-group"><button type="button" data-command="insert" data-value="row" data-option="up" class="se-btn se-tooltip _se_table_insert_row_a">'+i.insert_row_above+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+n.controller.insertRowAbove+'</span></span></button><button type="button" data-command="insert" data-value="row" data-option="down" class="se-btn se-tooltip _se_table_insert_row_b">'+i.insert_row_below+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+n.controller.insertRowBelow+'</span></span></button><button type="button" data-command="delete" data-value="row" class="se-btn se-tooltip">'+i.delete_row+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+n.controller.deleteRow+'</span></span></button><button type="button" data-command="merge" class="_se_table_merge_button se-btn se-tooltip" disabled>'+i.merge_cell+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+n.controller.mergeCells+'</span></span></button></div><div class="se-btn-group" style="padding-top: 0;"><button type="button" data-command="insert" data-value="cell" data-option="left" class="se-btn se-tooltip">'+i.insert_column_left+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+n.controller.insertColumnBefore+'</span></span></button><button type="button" data-command="insert" data-value="cell" data-option="right" class="se-btn se-tooltip">'+i.insert_column_right+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+n.controller.insertColumnAfter+'</span></span></button><button type="button" data-command="delete" data-value="cell" class="se-btn se-tooltip">'+i.delete_column+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+n.controller.deleteColumn+'</span></span></button><button type="button" data-command="onsplit" class="_se_table_split_button se-btn se-tooltip">'+i.split_cell+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+n.controller.splitCells+'</span></span></button><div class="se-btn-group-sub sun-editor-common se-list-layer se-table-split"><div class="se-list-inner"><ul class="se-list-basic"><li class="se-btn-list" data-command="split" data-value="vertical" style="line-height:32px;" title="'+n.controller.VerticalSplit+'" aria-label="'+n.controller.VerticalSplit+'">'+n.controller.VerticalSplit+'</li><li class="se-btn-list" data-command="split" data-value="horizontal" style="line-height:32px;" title="'+n.controller.HorizontalSplit+'" aria-label="'+n.controller.HorizontalSplit+'">'+n.controller.HorizontalSplit+"</li></ul></div></div></div>",s},appendTable:function(){const e=this.util.createElement("TABLE"),t=this.plugins.table.createCells,n=this.context.table._tableXY[0];let i=this.context.table._tableXY[1],s="<tbody>";for(;i>0;)s+="<tr>"+t.call(this,"td",n)+"</tr>",--i;if(s+="</tbody>",e.innerHTML=s,this.insertComponent(e,!1,!0,!1)){const l=e.querySelector("td div");this.setRange(l,0,l,0),this.plugins.table.reset_table_picker.call(this)}},createCells:function(e,t,n){if(e=e.toLowerCase(),n){const i=this.util.createElement(e);return i.innerHTML="<div><br></div>",i}else{let i="";for(;t>0;)i+="<"+e+"><div><br></div></"+e+">",t--;return i}},onMouseMove_tablePicker:function(e,t){t.stopPropagation();let n=this._w.Math.ceil(t.offsetX/18),i=this._w.Math.ceil(t.offsetY/18);n=n<1?1:n,i=i<1?1:i,e._rtl&&(e.tableHighlight.style.left=n*18-13+"px",n=11-n),e.tableHighlight.style.width=n+"em",e.tableHighlight.style.height=i+"em",this.util.changeTxt(e.tableDisplay,n+" x "+i),e._tableXY=[n,i]},reset_table_picker:function(){if(!this.context.table.tableHighlight)return;const e=this.context.table.tableHighlight.style,t=this.context.table.tableUnHighlight.style;e.width="1em",e.height="1em",t.width="10em",t.height="10em",this.util.changeTxt(this.context.table.tableDisplay,"1 x 1"),this.submenuOff()},init:function(){const e=this.context.table,t=this.plugins.table;if(t._removeEvents.call(this),t._selectedTable){const n=t._selectedTable.querySelectorAll(".se-table-selected-cell");for(let i=0,s=n.length;i<s;i++)this.util.removeClass(n[i],"se-table-selected-cell")}t._toggleEditor.call(this,!0),e._element=null,e._tdElement=null,e._trElement=null,e._trElements=null,e._tableXY=[],e._maxWidth=!0,e._fixedColumn=!1,e._physical_cellCnt=0,e._logical_cellCnt=0,e._rowCnt=0,e._rowIndex=0,e._physical_cellIndex=0,e._logical_cellIndex=0,e._current_colSpan=0,e._current_rowSpan=0,t._shift=!1,t._selectedCells=null,t._selectedTable=null,t._ref=null,t._fixedCell=null,t._selectedCell=null,t._fixedCellName=null},call_controller_tableEdit:function(e){const t=this.plugins.table,n=this.context.table;if(!this.getSelection().isCollapsed&&!t._selectedCell){this.controllersOff(),this.util.removeClass(e,"se-table-selected-cell");return}const i=n._element||this.plugins.table._selectedTable||this.util.getParentElement(e,"TABLE");n._maxWidth=this.util.hasClass(i,"se-table-size-100")||i.style.width==="100%"||!i.style.width&&!this.util.hasClass(i,"se-table-size-auto"),n._fixedColumn=this.util.hasClass(i,"se-table-layout-fixed")||i.style.tableLayout==="fixed",t.setTableStyle.call(this,n._maxWidth?"width|column":"width"),t.setPositionControllerTop.call(this,i),t.setPositionControllerDiv.call(this,e,t._shift),t._shift||this.controllersOn(n.resizeDiv,n.tableController,t.init.bind(this),e,"table")},setPositionControllerTop:function(e){this.setControllerPosition(this.context.table.tableController,e,"top",{left:0,top:0})},setPositionControllerDiv:function(e,t){const n=this.context.table,i=n.resizeDiv;this.plugins.table.setCellInfo.call(this,e,t),n.cellControllerTop?this.setControllerPosition(i,n._element,"top",{left:n.tableController.offsetWidth,top:0}):this.setControllerPosition(i,e,"bottom",{left:0,top:0})},setCellInfo:function(e,t){const n=this.context.table,i=n._element=this.plugins.table._selectedTable||this.util.getParentElement(e,"TABLE");if(/THEAD/i.test(i.firstElementChild.nodeName)?this.util.addClass(n.headerButton,"active"):this.util.removeClass(n.headerButton,"active"),t||n._physical_cellCnt===0){n._tdElement!==e&&(n._tdElement=e,n._trElement=e.parentNode);const s=n._trElements=i.rows,o=e.cellIndex;let l=0;for(let d=0,h=s[0].cells,v=s[0].cells.length;d<v;d++)l+=h[d].colSpan;const a=n._rowIndex=n._trElement.rowIndex;n._rowCnt=s.length,n._physical_cellCnt=n._trElement.cells.length,n._logical_cellCnt=l,n._physical_cellIndex=o,n._current_colSpan=n._tdElement.colSpan-1,n._current_rowSpan-n._trElement.cells[o].rowSpan-1;let r=[],f=[];for(let d=0,h,v;d<=a;d++){h=s[d].cells,v=0;for(let _=0,C=h.length,S,c,u,p;_<C;_++){if(S=h[_],c=S.colSpan-1,u=S.rowSpan-1,p=_+v,f.length>0)for(let b=0,y;b<f.length;b++)y=f[b],!(y.row>d)&&(p>=y.index?(v+=y.cs,p+=y.cs,y.rs-=1,y.row=d+1,y.rs<1&&(f.splice(b,1),b--)):_===C-1&&(y.rs-=1,y.row=d+1,y.rs<1&&(f.splice(b,1),b--)));if(d===a&&_===o){n._logical_cellIndex=p;break}u>0&&r.push({index:p,cs:c+1,rs:u,row:-1}),v+=c}f=f.concat(r).sort(function(_,C){return _.index-C.index}),r=[]}r=null,f=null}},editTable:function(e,t){const n=this.plugins.table,i=this.context.table,s=i._element,o=e==="row";if(o){const l=i._trElement.parentNode;if(/^THEAD$/i.test(l.nodeName)){if(t==="up")return;if(!l.nextElementSibling||!/^TBODY$/i.test(l.nextElementSibling.nodeName)){s.innerHTML+="<tbody><tr>"+n.createCells.call(this,"td",i._logical_cellCnt,!1)+"</tr></tbody>";return}}}if(n._ref){const l=i._tdElement,a=n._selectedCells;if(o)if(t)n.setCellInfo.call(this,t==="up"?a[0]:a[a.length-1],!0),n.editRow.call(this,t,l);else{let r=a[0].parentNode;const f=[a[0]];for(let d=1,h=a.length,v;d<h;d++)v=a[d],r!==v.parentNode&&(f.push(v),r=v.parentNode);for(let d=0,h=f.length;d<h;d++)n.setCellInfo.call(this,f[d],!0),n.editRow.call(this,t)}else{const r=a[0].parentNode;if(t){let f=null;for(let d=0,h=a.length-1;d<h;d++)if(r!==a[d+1].parentNode){f=a[d];break}n.setCellInfo.call(this,t==="left"?a[0]:f||a[0],!0),n.editCell.call(this,t,l)}else{const f=[a[0]];for(let d=1,h=a.length,v;d<h&&(v=a[d],r===v.parentNode);d++)f.push(v);for(let d=0,h=f.length;d<h;d++)n.setCellInfo.call(this,f[d],!0),n.editCell.call(this,t)}}t||n.init.call(this)}else n[o?"editRow":"editCell"].call(this,t);if(!t){const l=s.children;for(let a=0;a<l.length;a++)l[a].children.length===0&&(this.util.removeItem(l[a]),a--);s.children.length===0&&this.util.removeItem(s)}},editRow:function(e,t){const n=this.context.table,i=!e,s=e==="up",o=n._rowIndex,l=i||s?o:o+n._current_rowSpan+1,a=i?-1:1,r=n._trElements;let f=n._logical_cellCnt;for(let d=0,h=o+(i?-1:0),v;d<=h;d++){if(v=r[d].cells,v.length===0)return;for(let _=0,C=v.length,S,c;_<C;_++)S=v[_].rowSpan,c=v[_].colSpan,!(S<2&&c<2)&&S+d>l&&l>d&&(v[_].rowSpan=S+a,f-=c)}if(i){const d=r[o+1];if(d){const h=[];let v=r[o].cells,_=0;for(let C=0,S=v.length,c,u;C<S;C++)c=v[C],u=C+_,_+=c.colSpan-1,c.rowSpan>1&&(c.rowSpan-=1,h.push({cell:c.cloneNode(!1),index:u}));if(h.length>0){let C=h.shift();v=d.cells,_=0;for(let S=0,c=v.length,u,p;S<c&&(u=v[S],p=S+_,_+=u.colSpan-1,!(p>=C.index&&(S--,_--,_+=C.cell.colSpan-1,d.insertBefore(C.cell,u),C=h.shift(),!C)));S++);if(C){d.appendChild(C.cell);for(let S=0,c=h.length;S<c;S++)d.appendChild(h[S].cell)}}}n._element.deleteRow(l)}else{const d=n._element.insertRow(l);d.innerHTML=this.plugins.table.createCells.call(this,"td",f,!1)}i?this.controllersOff():this.plugins.table.setPositionControllerDiv.call(this,t||n._tdElement,!0)},editCell:function(e,t){const n=this.context.table,i=this.util,s=!e,o=e==="left",l=n._current_colSpan,a=s||o?n._logical_cellIndex:n._logical_cellIndex+l+1,r=n._trElements;let f=[],d=[],h=0;const v=[],_=[];for(let C=0,S=n._rowCnt,c,u,p,b,y,w;C<S;C++){c=r[C],u=a,y=!1,p=c.cells,w=0;for(let x=0,E,k=p.length,N,T,R;x<k&&(E=p[x],!!E);x++)if(N=E.rowSpan-1,T=E.colSpan-1,s){if(R=x+w,d.length>0){const M=!p[x+1];for(let A=0,D;A<d.length;A++)D=d[A],!(D.row>C)&&(R>=D.index?(w+=D.cs,R=x+w,D.rs-=1,D.row=C+1,D.rs<1&&(d.splice(A,1),A--)):M&&(D.rs-=1,D.row=C+1,D.rs<1&&(d.splice(A,1),A--)))}N>0&&f.push({rs:N,cs:T+1,index:R,row:-1}),R>=u&&R+T<=u+l?v.push(E):R<=u+l&&R+T>=u?E.colSpan-=i.getOverlapRangeAtIndex(a,a+l,R,R+T):N>0&&(R<u||R+T>u+l)&&_.push({cell:E,i:C,rs:C+N}),w+=T}else{if(x>=u)break;if(T>0){if(h<1&&T+x>=u){E.colSpan+=1,u=null,h=N+1;break}u-=T}if(!y){for(let M=0,A;M<d.length;M++)A=d[M],u-=A.cs,A.rs-=1,A.rs<1&&(d.splice(M,1),M--);y=!0}}if(d=d.concat(f).sort(function(x,E){return x.index-E.index}),f=[],!s){if(h>0){h-=1;continue}u!==null&&p.length>0&&(b=this.plugins.table.createCells.call(this,p[0].nodeName,0,!0),b=c.insertBefore(b,p[u]))}}if(s){let C,S;for(let c=0,u=v.length,p;c<u;c++)p=v[c].parentNode,i.removeItem(v[c]),p.cells.length===0&&(C||(C=i.getArrayIndex(r,p)),S=i.getArrayIndex(r,p),i.removeItem(p));for(let c=0,u=_.length,p;c<u;c++)p=_[c],p.cell.rowSpan=i.getOverlapRangeAtIndex(C,S,p.i,p.rs);this.controllersOff()}else this.plugins.table.setPositionControllerDiv.call(this,t||n._tdElement,!0)},_closeSplitMenu:null,openSplitMenu:function(){this.util.addClass(this.context.table.splitButton,"on"),this.context.table.splitMenu.style.display="inline-table",this.plugins.table._closeSplitMenu=(function(){this.util.removeClass(this.context.table.splitButton,"on"),this.context.table.splitMenu.style.display="none",this.removeDocEvent("click",this.plugins.table._closeSplitMenu),this.plugins.table._closeSplitMenu=null}).bind(this),this.addDocEvent("click",this.plugins.table._closeSplitMenu)},splitCells:function(e){const t=this.util,n=e==="vertical",i=this.context.table,s=i._tdElement,o=i._trElements,l=i._trElement,a=i._logical_cellIndex,r=i._rowIndex,f=this.plugins.table.createCells.call(this,s.nodeName,0,!0);if(n){const d=s.colSpan;if(f.rowSpan=s.rowSpan,d>1)f.colSpan=this._w.Math.floor(d/2),s.colSpan=d-f.colSpan,l.insertBefore(f,s.nextElementSibling);else{let h=[],v=[];for(let _=0,C=i._rowCnt,S,c;_<C;_++){S=o[_].cells,c=0;for(let u=0,p=S.length,b,y,w,x;u<p;u++){if(b=S[u],y=b.colSpan-1,w=b.rowSpan-1,x=u+c,v.length>0)for(let E=0,k;E<v.length;E++)k=v[E],!(k.row>_)&&(x>=k.index?(c+=k.cs,x+=k.cs,k.rs-=1,k.row=_+1,k.rs<1&&(v.splice(E,1),E--)):u===p-1&&(k.rs-=1,k.row=_+1,k.rs<1&&(v.splice(E,1),E--)));if(x<=a&&w>0&&h.push({index:x,cs:y+1,rs:w,row:-1}),b!==s&&x<=a&&x+y>=a+d-1){b.colSpan+=1;break}if(x>a)break;c+=y}v=v.concat(h).sort(function(u,p){return u.index-p.index}),h=[]}l.insertBefore(f,s.nextElementSibling)}}else{const d=s.rowSpan;if(f.colSpan=s.colSpan,d>1){f.rowSpan=this._w.Math.floor(d/2);const h=d-f.rowSpan,v=[],_=t.getArrayIndex(o,l)+h;for(let u=0,p,b;u<_;u++){p=o[u].cells,b=0;for(let y=0,w=p.length,x,E,k;y<w&&(k=y+b,!(k>=a));y++)x=p[y],E=x.rowSpan-1,E>0&&E+u>=_&&k<a&&v.push({index:k,cs:x.colSpan}),b+=x.colSpan-1}const C=o[_],S=C.cells;let c=v.shift();for(let u=0,p=S.length,b=0,y,w,x,E;u<p;u++){if(x=u+b,y=S[u],w=y.colSpan-1,E=x+w+1,c&&E>=c.index&&(b+=c.cs,E+=c.cs,c=v.shift()),E>=a||u===p-1){C.insertBefore(f,y.nextElementSibling);break}b+=w}s.rowSpan=h}else{f.rowSpan=s.rowSpan;const h=t.createElement("TR");h.appendChild(f);for(let C=0,S;C<r;C++){if(S=o[C].cells,S.length===0)return;for(let c=0,u=S.length;c<u;c++)C+S[c].rowSpan-1>=r&&(S[c].rowSpan+=1)}const v=i._physical_cellIndex,_=l.cells;for(let C=0,S=_.length;C<S;C++)C!==v&&(_[C].rowSpan+=1);l.parentNode.insertBefore(h,l.nextElementSibling)}}this.focusEdge(s),this.plugins.table.setPositionControllerDiv.call(this,s,!0)},mergeCells:function(){const e=this.plugins.table,t=this.context.table,n=this.util,i=e._ref,s=e._selectedCells,o=s[0];let l=null,a=null,r=i.ce-i.cs+1,f=i.re-i.rs+1,d="",h=null;for(let v=1,_=s.length,C,S;v<_;v++){C=s[v],h!==C.parentNode&&(h=C.parentNode),S=C.children;for(let c=0,u=S.length;c<u;c++)n.isFormatElement(S[c])&&n.onlyZeroWidthSpace(S[c].textContent)&&n.removeItem(S[c]);d+=C.innerHTML,n.removeItem(C),h.cells.length===0&&(l?a=h:l=h,f-=1)}if(l){const v=t._trElements,_=n.getArrayIndex(v,l),C=n.getArrayIndex(v,a||l),S=[];for(let c=0,u;c<=C;c++){if(u=v[c].cells,u.length===0){S.push(v[c]);continue}for(let p=0,b=u.length,y,w;p<b;p++)y=u[p],w=y.rowSpan-1,w>0&&c+w>=_&&(y.rowSpan-=n.getOverlapRangeAtIndex(_,C,c,c+w))}for(let c=0,u=S.length;c<u;c++)n.removeItem(S[c])}o.innerHTML+=d,o.colSpan=r,o.rowSpan=f,this.controllersOff(),e.setActiveButton.call(this,!0,!1),e.call_controller_tableEdit.call(this,o),n.addClass(o,"se-table-selected-cell"),this.focusEdge(o)},toggleHeader:function(){const e=this.util,t=this.context.table.headerButton,n=e.hasClass(t,"active"),i=this.context.table._element;if(n)e.removeItem(i.querySelector("thead"));else{const s=e.createElement("THEAD");s.innerHTML="<tr>"+this.plugins.table.createCells.call(this,"th",this.context.table._logical_cellCnt,!1)+"</tr>",i.insertBefore(s,i.firstElementChild)}e.toggleClass(t,"active"),/TH/i.test(this.context.table._tdElement.nodeName)?this.controllersOff():this.plugins.table.setPositionControllerDiv.call(this,this.context.table._tdElement,!1)},setTableStyle:function(e){const t=this.context.table,n=t._element;let i,s,o,l;e.indexOf("width")>-1&&(i=t.resizeButton.firstElementChild,s=t.resizeText,t._maxWidth?(o=t.icons.reduction,l=t.minText,t.columnFixedButton.style.display="block",this.util.removeClass(n,"se-table-size-auto"),this.util.addClass(n,"se-table-size-100")):(o=t.icons.expansion,l=t.maxText,t.columnFixedButton.style.display="none",this.util.removeClass(n,"se-table-size-100"),this.util.addClass(n,"se-table-size-auto")),this.util.changeElement(i,o),this.util.changeTxt(s,l)),e.indexOf("column")>-1&&(t._fixedColumn?(this.util.removeClass(n,"se-table-layout-auto"),this.util.addClass(n,"se-table-layout-fixed"),this.util.addClass(t.columnFixedButton,"active")):(this.util.removeClass(n,"se-table-layout-fixed"),this.util.addClass(n,"se-table-layout-auto"),this.util.removeClass(t.columnFixedButton,"active")))},setActiveButton:function(e,t){const n=this.context.table;/^TH$/i.test(e.nodeName)?(n.insertRowAboveButton.setAttribute("disabled",!0),n.insertRowBelowButton.setAttribute("disabled",!0)):(n.insertRowAboveButton.removeAttribute("disabled"),n.insertRowBelowButton.removeAttribute("disabled")),!t||e===t?(n.splitButton.removeAttribute("disabled"),n.mergeButton.setAttribute("disabled",!0)):(n.splitButton.setAttribute("disabled",!0),n.mergeButton.removeAttribute("disabled"))},_bindOnSelect:null,_bindOffSelect:null,_bindOffShift:null,_selectedCells:null,_shift:!1,_fixedCell:null,_fixedCellName:null,_selectedCell:null,_selectedTable:null,_ref:null,_toggleEditor:function(e){this.context.element.wysiwyg.setAttribute("contenteditable",e),e?this.util.removeClass(this.context.element.wysiwyg,"se-disabled"):this.util.addClass(this.context.element.wysiwyg,"se-disabled")},_offCellMultiSelect:function(e){e.stopPropagation();const t=this.plugins.table;t._shift?t._initBind&&(this._wd.removeEventListener("touchmove",t._initBind),t._initBind=null):(t._removeEvents.call(this),t._toggleEditor.call(this,!0)),!(!t._fixedCell||!t._selectedTable)&&(t.setActiveButton.call(this,t._fixedCell,t._selectedCell),t.call_controller_tableEdit.call(this,t._selectedCell||t._fixedCell),t._selectedCells=t._selectedTable.querySelectorAll(".se-table-selected-cell"),t._selectedCell&&t._fixedCell&&this.focusEdge(t._selectedCell),t._shift||(t._fixedCell=null,t._selectedCell=null,t._fixedCellName=null))},_onCellMultiSelect:function(e){this._antiBlur=!0;const t=this.plugins.table,n=this.util.getParentElement(e.target,this.util.isCell);if(t._shift)n===t._fixedCell?t._toggleEditor.call(this,!0):t._toggleEditor.call(this,!1);else if(!t._ref){if(n===t._fixedCell)return;t._toggleEditor.call(this,!1)}!n||n===t._selectedCell||t._fixedCellName!==n.nodeName||t._selectedTable!==this.util.getParentElement(n,"TABLE")||(t._selectedCell=n,t._setMultiCells.call(this,t._fixedCell,n))},_setMultiCells:function(e,t){const n=this.plugins.table,i=n._selectedTable.rows,s=this.util,o=n._selectedTable.querySelectorAll(".se-table-selected-cell");for(let d=0,h=o.length;d<h;d++)s.removeClass(o[d],"se-table-selected-cell");if(e===t&&(s.addClass(e,"se-table-selected-cell"),!n._shift))return;let l=!0,a=[],r=[];const f=n._ref={_i:0,cs:null,ce:null,rs:null,re:null};for(let d=0,h=i.length,v,_;d<h;d++){v=i[d].cells,_=0;for(let C=0,S=v.length,c,u,p,b;C<S;C++){if(c=v[C],p=c.colSpan-1,b=c.rowSpan-1,u=C+_,a.length>0)for(let y=0,w;y<a.length;y++)w=a[y],!(w.row>d)&&(u>=w.index?(_+=w.cs,u+=w.cs,w.rs-=1,w.row=d+1,w.rs<1&&(a.splice(y,1),y--)):C===S-1&&(w.rs-=1,w.row=d+1,w.rs<1&&(a.splice(y,1),y--)));if(l){if((c===e||c===t)&&(f.cs=f.cs!==null&&f.cs<u?f.cs:u,f.ce=f.ce!==null&&f.ce>u+p?f.ce:u+p,f.rs=f.rs!==null&&f.rs<d?f.rs:d,f.re=f.re!==null&&f.re>d+b?f.re:d+b,f._i+=1),f._i===2){l=!1,a=[],r=[],d=-1;break}}else if(s.getOverlapRangeAtIndex(f.cs,f.ce,u,u+p)&&s.getOverlapRangeAtIndex(f.rs,f.re,d,d+b)){const y=f.cs<u?f.cs:u,w=f.ce>u+p?f.ce:u+p,x=f.rs<d?f.rs:d,E=f.re>d+b?f.re:d+b;if(f.cs!==y||f.ce!==w||f.rs!==x||f.re!==E){f.cs=y,f.ce=w,f.rs=x,f.re=E,d=-1,a=[],r=[];break}s.addClass(c,"se-table-selected-cell")}b>0&&r.push({index:u,cs:p+1,rs:b,row:-1}),_+=c.colSpan-1}a=a.concat(r).sort(function(C,S){return C.index-S.index}),r=[]}},_removeEvents:function(){const e=this.plugins.table;e._initBind&&(this._wd.removeEventListener("touchmove",e._initBind),e._initBind=null),e._bindOnSelect&&(this._wd.removeEventListener("mousedown",e._bindOnSelect),this._wd.removeEventListener("mousemove",e._bindOnSelect),e._bindOnSelect=null),e._bindOffSelect&&(this._wd.removeEventListener("mouseup",e._bindOffSelect),e._bindOffSelect=null),e._bindOffShift&&(this._wd.removeEventListener("keyup",e._bindOffShift),e._bindOffShift=null)},_initBind:null,onTableCellMultiSelect:function(e,t){const n=this.plugins.table;n._removeEvents.call(this),this.controllersOff(),n._shift=t,n._fixedCell=e,n._fixedCellName=e.nodeName,n._selectedTable=this.util.getParentElement(e,"TABLE");const i=n._selectedTable.querySelectorAll(".se-table-selected-cell");for(let s=0,o=i.length;s<o;s++)this.util.removeClass(i[s],"se-table-selected-cell");this.util.addClass(e,"se-table-selected-cell"),n._bindOnSelect=n._onCellMultiSelect.bind(this),n._bindOffSelect=n._offCellMultiSelect.bind(this),t?(n._bindOffShift=(function(){this.controllersOn(this.context.table.resizeDiv,this.context.table.tableController,this.plugins.table.init.bind(this),e,"table"),n._ref||this.controllersOff()}).bind(this),this._wd.addEventListener("keyup",n._bindOffShift,!1),this._wd.addEventListener("mousedown",n._bindOnSelect,!1)):this._wd.addEventListener("mousemove",n._bindOnSelect,!1),this._wd.addEventListener("mouseup",n._bindOffSelect,!1),n._initBind=n.init.bind(this),this._wd.addEventListener("touchmove",n._initBind,!1)},onClick_tableController:function(e){e.stopPropagation();const t=e.target.getAttribute("data-command")?e.target:e.target.parentNode;if(t.getAttribute("disabled"))return;const n=t.getAttribute("data-command"),i=t.getAttribute("data-value"),s=t.getAttribute("data-option"),o=this.plugins.table;if(typeof o._closeSplitMenu=="function"&&(o._closeSplitMenu(),n==="onsplit")||!n)return;e.preventDefault();const l=this.context.table;switch(n){case"insert":case"delete":o.editTable.call(this,i,s);break;case"header":o.toggleHeader.call(this);break;case"onsplit":o.openSplitMenu.call(this);break;case"split":o.splitCells.call(this,i);break;case"merge":o.mergeCells.call(this);break;case"resize":l._maxWidth=!l._maxWidth,o.setTableStyle.call(this,"width"),o.setPositionControllerTop.call(this,l._element),o.setPositionControllerDiv.call(this,l._tdElement,o._shift);break;case"layout":l._fixedColumn=!l._fixedColumn,o.setTableStyle.call(this,"column"),o.setPositionControllerTop.call(this,l._element),o.setPositionControllerDiv.call(this,l._tdElement,o._shift);break;case"remove":const a=l._element.parentNode;this.util.removeItem(l._element),this.controllersOff(),a!==this.context.element.wysiwyg&&this.util.removeItemAllParents(a,function(r){return r.childNodes.length===0},null),this.focus()}this.history.push(!1)}},jC={name:"formatBlock",display:"submenu",add:function(e,t){const n=e.context;n.formatBlock={targetText:t.querySelector(".txt"),targetTooltip:t.parentNode.querySelector(".se-tooltip-text"),_formatList:null,currentFormat:""};let i=this.setSubmenu(e);i.querySelector("ul").addEventListener("click",this.pickUp.bind(e)),n.formatBlock._formatList=i.querySelectorAll("li button"),e.initMenuTarget(this.name,t,i),i=null},setSubmenu:function(e){const t=e.options,n=e.lang.toolbar,i=e.util.createElement("DIV");i.className="se-submenu se-list-layer se-list-format";const s=["p","div","blockquote","pre","h1","h2","h3","h4","h5","h6"],o=!t.formats||t.formats.length===0?s:t.formats;let l='<div class="se-list-inner"><ul class="se-list-basic">';for(let a=0,r=o.length,f,d,h,v,_,C,S;a<r;a++)f=o[a],typeof f=="string"&&s.indexOf(f)>-1?(d=f.toLowerCase(),h=d==="blockquote"?"range":d==="pre"?"free":"replace",_=/^h/.test(d)?d.match(/\d+/)[0]:"",v=n["tag_"+(_?"h":d)]+_,S="",C=""):(d=f.tag.toLowerCase(),h=f.command,v=f.name||d,S=f.class,C=S?' class="'+S+'"':""),l+='<li><button type="button" class="se-btn-list" data-command="'+h+'" data-value="'+d+'" data-class="'+S+'" title="'+v+'" aria-label="'+v+'"><'+d+C+">"+v+"</"+d+"></button></li>";return l+="</ul></div>",i.innerHTML=l,i},active:function(e){let t=this.lang.toolbar.formats;const n=this.context.formatBlock.targetText;if(!e)this.util.changeTxt(n,t);else if(this.util.isFormatElement(e)){const s=this.context.formatBlock._formatList,o=e.nodeName.toLowerCase(),l=(e.className.match(/(\s|^)__se__format__[^\s]+/)||[""])[0].trim();for(let a=0,r=s.length,f;a<r;a++)if(f=s[a],o===f.getAttribute("data-value")&&l===f.getAttribute("data-class")){t=f.title;break}return this.util.changeTxt(n,t),n.setAttribute("data-value",o),n.setAttribute("data-class",l),!0}return!1},on:function(){const e=this.context.formatBlock,t=e._formatList,n=e.targetText,i=(n.getAttribute("data-value")||"")+(n.getAttribute("data-class")||"");if(i!==e.currentFormat){for(let s=0,o=t.length,l;s<o;s++)l=t[s],i===l.getAttribute("data-value")+l.getAttribute("data-class")?this.util.addClass(l,"active"):this.util.removeClass(l,"active");e.currentFormat=i}},pickUp:function(e){e.preventDefault(),e.stopPropagation();let t=e.target,n=null,i=null,s=null,o="";for(;!n&&!/UL/i.test(t.tagName);){if(n=t.getAttribute("data-command"),i=t.getAttribute("data-value"),o=t.getAttribute("data-class"),n){s=t.firstChild;break}t=t.parentNode}if(n){if(n==="range"){const l=s.cloneNode(!1);this.applyRangeFormatElement(l)}else{let l=this.getRange(),a=this.getSelectedElementsAndComponents(!1);if(a.length===0&&(l=this.getRange_addLine(l,null),a=this.getSelectedElementsAndComponents(!1),a.length===0))return;const r=l.startOffset,f=l.endOffset,d=this.util;let h=a[0],v=a[a.length-1];const _=d.getNodePath(l.startContainer,h,null,null),C=d.getNodePath(l.endContainer,v,null,null),S=this.detachList(a,!1);S.sc&&(h=S.sc),S.ec&&(v=S.ec),this.setRange(d.getNodeFromPath(_,h),r,d.getNodeFromPath(C,v),f);const c=this.getSelectedElementsAndComponents(!1);if(n==="free"){const u=c.length-1;let p=c[u].parentNode,b=s.cloneNode(!1);const y=b;for(let w=u,x,E,k,N,T,R,M=!0;w>=0;w--)if(x=c[w],x!==(c[w+1]?c[w+1].parentNode:null)){if(R=d.isComponent(x),E=R?"":x.innerHTML.replace(/(?!>)\s+(?=<)|\n/g," "),k=d.getParentElement(x,function(A){return A.parentNode===p}),(p!==x.parentNode||R)&&(d.isFormatElement(p)?(p.parentNode.insertBefore(b,p.nextSibling),p=p.parentNode):(p.insertBefore(b,k?k.nextSibling:null),p=x.parentNode),N=b.nextSibling,N&&b.nodeName===N.nodeName&&d.isSameAttributes(b,N)&&(b.innerHTML+="<BR>"+N.innerHTML,d.removeItem(N)),b=s.cloneNode(!1),M=!0),T=b.innerHTML,b.innerHTML=(M||!E||!T||/<br>$/i.test(E)?E:E+"<BR>")+T,w===0){p.insertBefore(b,x),N=x.nextSibling,N&&b.nodeName===N.nodeName&&d.isSameAttributes(b,N)&&(b.innerHTML+="<BR>"+N.innerHTML,d.removeItem(N));const A=b.previousSibling;A&&b.nodeName===A.nodeName&&d.isSameAttributes(b,A)&&(A.innerHTML+="<BR>"+b.innerHTML,d.removeItem(b))}R||d.removeItem(x),E&&(M=!1)}this.setRange(y,0,y,0)}else{for(let u=0,p=c.length,b,y;u<p;u++)b=c[u],(b.nodeName.toLowerCase()!==i.toLowerCase()||(b.className.match(/(\s|^)__se__format__[^\s]+/)||[""])[0].trim()!==o)&&!d.isComponent(b)&&(y=s.cloneNode(!1),d.copyFormatAttributes(y,b),y.innerHTML=b.innerHTML,b.parentNode.replaceChild(y,b)),u===0&&(h=y||b),u===p-1&&(v=y||b),y=null;this.setRange(d.getNodeFromPath(_,h),r,d.getNodeFromPath(C,v),f)}this.history.push(!1)}this.submenuOff()}}},zC={name:"lineHeight",display:"submenu",add:function(e,t){const n=e.context;n.lineHeight={_sizeList:null,currentSize:-1};let i=this.setSubmenu(e),s=i.querySelector("ul");s.addEventListener("click",this.pickup.bind(e)),n.lineHeight._sizeList=s.querySelectorAll("li button"),e.initMenuTarget(this.name,t,i),i=null,s=null},setSubmenu:function(e){const t=e.options,n=e.lang,i=e.util.createElement("DIV");i.className="se-submenu se-list-layer";const s=t.lineHeights?t.lineHeights:[{text:"1",value:1},{text:"1.15",value:1.15},{text:"1.5",value:1.5},{text:"2",value:2}];let o='<div class="se-list-inner"><ul class="se-list-basic"><li><button type="button" class="default_value se-btn-list" title="'+n.toolbar.default+'" aria-label="'+n.toolbar.default+'">('+n.toolbar.default+")</button></li>";for(let l=0,a=s.length,r;l<a;l++)r=s[l],o+='<li><button type="button" class="se-btn-list" data-value="'+r.value+'" title="'+r.text+'" aria-label="'+r.text+'">'+r.text+"</button></li>";return o+="</ul></div>",i.innerHTML=o,i},on:function(){const e=this.context.lineHeight,t=e._sizeList,n=this.util.getFormatElement(this.getSelectionNode()),i=n?n.style.lineHeight+"":"";if(i!==e.currentSize){for(let s=0,o=t.length;s<o;s++)i===t[s].getAttribute("data-value")?this.util.addClass(t[s],"active"):this.util.removeClass(t[s],"active");e.currentSize=i}},pickup:function(e){if(!/^BUTTON$/i.test(e.target.tagName))return!1;e.preventDefault(),e.stopPropagation();const t=e.target.getAttribute("data-value")||"",n=this.getSelectedElements();for(let i=0,s=n.length;i<s;i++)n[i].style.lineHeight=t;this.submenuOff(),this.history.push(!1)}},HC={name:"template",display:"submenu",add:function(e,t){const n=e.context;n.template={selectedIndex:-1};let i=this.setSubmenu(e);i.querySelector("ul").addEventListener("click",this.pickup.bind(e)),e.initMenuTarget(this.name,t,i),i=null},setSubmenu:function(e){const t=e.options.templates;if(!t||t.length===0)throw Error('[SUNEDITOR.plugins.template.fail] To use the "template" plugin, please define the "templates" option.');const n=e.util.createElement("DIV");n.className="se-list-layer";let i='<div class="se-submenu se-list-inner"><ul class="se-list-basic">';for(let s=0,o=t.length,l;s<o;s++)l=t[s],i+='<li><button type="button" class="se-btn-list" data-value="'+s+'" title="'+l.name+'" aria-label="'+l.name+'">'+l.name+"</button></li>";return i+="</ul></div>",n.innerHTML=i,n},pickup:function(e){if(!/^BUTTON$/i.test(e.target.tagName))return!1;e.preventDefault(),e.stopPropagation(),this.context.template.selectedIndex=e.target.getAttribute("data-value")*1;const t=this.options.templates[this.context.template.selectedIndex];if(t.html)this.setContents(t.html);else throw this.submenuOff(),Error('[SUNEDITOR.template.fail] cause : "templates[i].html not found"');this.submenuOff()}},VC={name:"paragraphStyle",display:"submenu",add:function(e,t){const n=e.context;n.paragraphStyle={_classList:null};let i=this.setSubmenu(e);i.querySelector("ul").addEventListener("click",this.pickUp.bind(e)),n.paragraphStyle._classList=i.querySelectorAll("li button"),e.initMenuTarget(this.name,t,i),i=null},setSubmenu:function(e){const t=e.options,n=e.util.createElement("DIV");n.className="se-submenu se-list-layer se-list-format";const i=e.lang.menu,s={spaced:{name:i.spaced,class:"__se__p-spaced",_class:""},bordered:{name:i.bordered,class:"__se__p-bordered",_class:""},neon:{name:i.neon,class:"__se__p-neon",_class:""}},o=!t.paragraphStyles||t.paragraphStyles.length===0?["spaced","bordered","neon"]:t.paragraphStyles;let l='<div class="se-list-inner"><ul class="se-list-basic">';for(let a=0,r=o.length,f,d,h,v;a<r;a++){if(f=o[a],typeof f=="string"){const _=s[f.toLowerCase()];if(!_)continue;f=_}d=f.name,h=f.class?' class="'+f.class+'"':"",v=f._class,l+='<li><button type="button" class="se-btn-list'+(v?" "+v:"")+'" data-value="'+f.class+'" title="'+d+'" aria-label="'+d+'"><div'+h+">"+d+"</div></button></li>"}return l+="</ul></div>",n.innerHTML=l,n},on:function(){const t=this.context.paragraphStyle._classList,n=this.util.getFormatElement(this.getSelectionNode());for(let i=0,s=t.length;i<s;i++)this.util.hasClass(n,t[i].getAttribute("data-value"))?this.util.addClass(t[i],"active"):this.util.removeClass(t[i],"active")},pickUp:function(e){e.preventDefault(),e.stopPropagation();let t=e.target,n=null;for(;!/^UL$/i.test(t.tagName)&&(n=t.getAttribute("data-value"),!n);)t=t.parentNode;if(!n)return;let i=this.getSelectedElements();if(i.length===0&&(this.getRange_addLine(this.getRange(),null),i=this.getSelectedElements(),i.length===0))return;const s=this.util.hasClass(t,"active")?this.util.removeClass.bind(this.util):this.util.addClass.bind(this.util);for(let o=0,l=i.length;o<l;o++)s(i[o],n);this.submenuOff(),this.history.push(!1)}},WC={name:"textStyle",display:"submenu",add:function(e,t){const n=e.context;n.textStyle={_styleList:null};let i=this.setSubmenu(e),s=i.querySelector("ul");s.addEventListener("click",this.pickup.bind(e)),n.textStyle._styleList=i.querySelectorAll("li button"),e.initMenuTarget(this.name,t,i),i=null,s=null},setSubmenu:function(e){const t=e.options,n=e.util.createElement("DIV");n.className="se-submenu se-list-layer se-list-format";const i={code:{name:e.lang.menu.code,class:"__se__t-code",tag:"code"},translucent:{name:e.lang.menu.translucent,style:"opacity: 0.5;",tag:"span"},shadow:{name:e.lang.menu.shadow,class:"__se__t-shadow",tag:"span"}},s=t.textStyles?t.textStyles:e._w.Object.keys(i);let o='<div class="se-list-inner"><ul class="se-list-basic">';for(let l=0,a=s.length,r,f,d,h,v,_,C;l<a;l++){if(r=s[l],h="",_="",v=[],typeof r=="string"){const S=i[r.toLowerCase()];if(!S)continue;r=S}d=r.name,f=r.tag||"span",C=r._class,r.style&&(h+=' style="'+r.style+'"',_+=r.style.replace(/:[^;]+(;|$)\s*/g,","),v.push("style")),r.class&&(h+=' class="'+r.class+'"',_+="."+r.class.trim().replace(/\s+/g,",."),v.push("class")),_=_.replace(/,$/,""),o+='<li><button type="button" class="se-btn-list'+(C?" "+C:"")+'" data-command="'+f+'" data-value="'+_+'" title="'+d+'" aria-label="'+d+'"><'+f+h+">"+d+"</"+f+"></button></li>"}return o+="</ul></div>",n.innerHTML=o,n},on:function(){const e=this.util,n=this.context.textStyle._styleList,i=this.getSelectionNode();for(let s=0,o=n.length,l,a,r;s<o;s++){l=n[s],a=l.getAttribute("data-value").split(",");for(let f=0,d,h;f<a.length;f++){for(d=i,r=!1;d&&!e.isFormatElement(d)&&!e.isComponent(d);){if(d.nodeName.toLowerCase()===l.getAttribute("data-command").toLowerCase()&&(h=a[f],/^\./.test(h)?e.hasClass(d,h.replace(/^\./,"")):d.style[h])){r=!0;break}d=d.parentNode}if(!r)break}r?e.addClass(l,"active"):e.removeClass(l,"active")}},pickup:function(e){e.preventDefault(),e.stopPropagation();let t=e.target,n=null,i=null;for(;!n&&!/UL/i.test(t.tagName);){if(n=t.getAttribute("data-command"),n){i=t.firstChild;break}t=t.parentNode}if(!n)return;const s=i.style.cssText.replace(/:.+(;|$)/g,",").split(",");s.pop();const o=i.classList;for(let r=0,f=o.length;r<f;r++)s.push("."+o[r]);const l=this.util.hasClass(t,"active")?null:i.cloneNode(!1),a=l?null:[i.nodeName];this.nodeChange(l,s,a,!0),this.submenuOff()}};var ah={exports:{}};(function(e){(function(t,n){e.exports=t.document?n(t,!0):function(i){if(!i.document)throw new Error("SUNEDITOR_MODULES a window with a document");return n(i)}})(typeof window<"u"?window:Yn,function(t,n){const i={name:"dialog",add:function(s){const o=s.context;o.dialog={kind:"",updateModal:!1,_closeSignal:!1};let l=s.util.createElement("DIV");l.className="se-dialog sun-editor-common";let a=s.util.createElement("DIV");a.className="se-dialog-back",a.style.display="none";let r=s.util.createElement("DIV");r.className="se-dialog-inner",r.style.display="none",l.appendChild(a),l.appendChild(r),o.dialog.modalArea=l,o.dialog.back=a,o.dialog.modal=r,o.dialog.modal.addEventListener("mousedown",this._onMouseDown_dialog.bind(s)),o.dialog.modal.addEventListener("click",this._onClick_dialog.bind(s)),o.element.relative.appendChild(l),l=null,a=null,r=null},_onMouseDown_dialog:function(s){/se-dialog-inner/.test(s.target.className)?this.context.dialog._closeSignal=!0:this.context.dialog._closeSignal=!1},_onClick_dialog:function(s){(/close/.test(s.target.getAttribute("data-command"))||this.context.dialog._closeSignal)&&this.plugins.dialog.close.call(this)},open:function(s,o){if(this.modalForm)return!1;this.plugins.dialog._bindClose&&(this._d.removeEventListener("keydown",this.plugins.dialog._bindClose),this.plugins.dialog._bindClose=null),this.plugins.dialog._bindClose=(function(a){/27/.test(a.keyCode)&&this.plugins.dialog.close.call(this)}).bind(this),this._d.addEventListener("keydown",this.plugins.dialog._bindClose),this.context.dialog.updateModal=o,this.options.popupDisplay==="full"?this.context.dialog.modalArea.style.position="fixed":this.context.dialog.modalArea.style.position="absolute",this.context.dialog.kind=s,this.modalForm=this.context[s].modal;const l=this.context[s].focusElement;typeof this.plugins[s].on=="function"&&this.plugins[s].on.call(this,o),this.context.dialog.modalArea.style.display="block",this.context.dialog.back.style.display="block",this.context.dialog.modal.style.display="block",this.modalForm.style.display="block",l&&l.focus()},_bindClose:null,close:function(){this.plugins.dialog._bindClose&&(this._d.removeEventListener("keydown",this.plugins.dialog._bindClose),this.plugins.dialog._bindClose=null);const s=this.context.dialog.kind;this.modalForm.style.display="none",this.context.dialog.back.style.display="none",this.context.dialog.modalArea.style.display="none",this.context.dialog.updateModal=!1,typeof this.plugins[s].init=="function"&&this.plugins[s].init.call(this),this.context.dialog.kind="",this.modalForm=null,this.focus()}};return typeof n>"u"&&(t.SUNEDITOR_MODULES||Object.defineProperty(t,"SUNEDITOR_MODULES",{enumerable:!0,writable:!1,configurable:!1,value:{}}),Object.defineProperty(t.SUNEDITOR_MODULES,"dialog",{enumerable:!0,writable:!1,configurable:!1,value:i})),i})})(ah);var $C=ah.exports;const Fi=Zn($C),UC={name:"selectMenu",add:function(e){e.context.selectMenu={caller:{},callerContext:null}},setForm:function(){return'<div class="se-select-list"></div>'},createList:function(e,t,n){e.form.innerHTML="<ul>"+n+"</ul>",e.items=t,e.menus=e.form.querySelectorAll("li")},initEvent:function(e,t){const n=t.querySelector(".se-select-list"),i=this.context.selectMenu.caller[e]={form:n,items:[],menus:[],index:-1,item:null,clickMethod:null,callerName:e};n.addEventListener("mousedown",this.plugins.selectMenu.onMousedown_list),n.addEventListener("mousemove",this.plugins.selectMenu.onMouseMove_list.bind(this,i)),n.addEventListener("click",this.plugins.selectMenu.onClick_list.bind(this,i))},onMousedown_list:function(e){e.preventDefault(),e.stopPropagation()},onMouseMove_list:function(e,t){this.util.addClass(e.form,"__se_select-menu-mouse-move");const n=t.target.getAttribute("data-index");n&&(e.index=n*1)},onClick_list:function(e,t){const n=t.target.getAttribute("data-index");n&&e.clickMethod.call(this,e.items[n])},moveItem:function(e,t){this.util.removeClass(e.form,"__se_select-menu-mouse-move"),t=e.index+t;const n=e.menus,i=n.length,s=e.index=t>=i?0:t<0?i-1:t;for(let o=0;o<i;o++)o===s?this.util.addClass(n[o],"active"):this.util.removeClass(n[o],"active");e.item=e.items[s]},getItem:function(e,t){return t=!t||t<0?e.index:t,e.items[t]},on:function(e,t){const n=this.context.selectMenu.caller[e];this.context.selectMenu.callerContext=n,n.clickMethod=t,n.callerName=e},open:function(e,t){const n=e.form;n.style.visibility="hidden",n.style.display="block",t(n),n.style.visibility=""},close:function(e){e.form.style.display="none",e.items=[],e.menus=[],e.index=-1,e.item=null},init:function(e){e&&(e.items=[],e.menus=[],e.index=-1,e.item=null,e.callerName="",this.context.selectMenu.callerContext=null)}},ch={name:"anchor",add:function(e){e.addModule([UC]),e.context.anchor={caller:{},forms:this.setDialogForm(e),host:(e._w.location.origin+e._w.location.pathname).replace(/\/$/,""),callerContext:null}},setDialogForm:function(e){const t=e.lang,n=e.options.linkRel,i=(e.options.linkRelDefault.default||"").split(" "),s=e.icons,o=e.util.createElement("DIV");let l='<div class="se-dialog-body"><div class="se-dialog-form"><label>'+t.dialogBox.linkBox.url+'</label><div class="se-dialog-form-files"><input class="se-input-form se-input-url" type="text" placeholder="'+(e.options.protocol||"")+'" /><button type="button" class="se-btn se-dialog-files-edge-button _se_bookmark_button" title="'+t.dialogBox.linkBox.bookmark+'" aria-label="'+t.dialogBox.linkBox.bookmark+'">'+s.bookmark+"</button>"+e.plugins.selectMenu.setForm()+'</div><div class="se-anchor-preview-form"><span class="se-svg se-anchor-preview-icon _se_anchor_bookmark_icon">'+s.bookmark+'</span><span class="se-svg se-anchor-preview-icon _se_anchor_download_icon">'+s.download+'</span><pre class="se-link-preview"></pre></div></div><div class="se-dialog-form"><label>'+t.dialogBox.linkBox.text+'</label><input class="se-input-form _se_anchor_text" type="text" /></div><div class="se-dialog-form-footer"><label><input type="checkbox" class="se-dialog-btn-check _se_anchor_check" />&nbsp;'+t.dialogBox.linkBox.newWindowCheck+'</label><label><input type="checkbox" class="se-dialog-btn-check _se_anchor_download" />&nbsp;'+t.dialogBox.linkBox.downloadLinkCheck+"</label>";if(n.length>0){l+='<div class="se-anchor-rel"><button type="button" class="se-btn se-btn-select se-anchor-rel-btn">&lt;rel&gt;</button><div class="se-anchor-rel-wrapper"><pre class="se-link-preview se-anchor-rel-preview"></pre></div><div class="se-list-layer"><div class="se-list-inner"><ul class="se-list-basic se-list-checked">';for(let a=0,r=n.length,f;a<r;a++)f=n[a],l+='<li><button type="button" class="se-btn-list'+(i.indexOf(f)>-1?" se-checked":"")+'" data-command="'+f+'" title="'+f+'" aria-label="'+f+'"><span class="se-svg">'+s.checked+"</span>"+f+"</button></li>";l+="</ul></div></div></div>"}return l+="</div></div>",o.innerHTML=l,o},initEvent:function(e,t){const n=this.plugins.anchor,i=this.context.anchor.caller[e]={modal:t,urlInput:null,linkDefaultRel:this.options.linkRelDefault,defaultRel:this.options.linkRelDefault.default||"",currentRel:[],linkAnchor:null,linkValue:"",_change:!1,callerName:e};typeof i.linkDefaultRel.default=="string"&&(i.linkDefaultRel.default=i.linkDefaultRel.default.trim()),typeof i.linkDefaultRel.check_new_window=="string"&&(i.linkDefaultRel.check_new_window=i.linkDefaultRel.check_new_window.trim()),typeof i.linkDefaultRel.check_bookmark=="string"&&(i.linkDefaultRel.check_bookmark=i.linkDefaultRel.check_bookmark.trim()),i.urlInput=t.querySelector(".se-input-url"),i.anchorText=t.querySelector("._se_anchor_text"),i.newWindowCheck=t.querySelector("._se_anchor_check"),i.downloadCheck=t.querySelector("._se_anchor_download"),i.download=t.querySelector("._se_anchor_download_icon"),i.preview=t.querySelector(".se-link-preview"),i.bookmark=t.querySelector("._se_anchor_bookmark_icon"),i.bookmarkButton=t.querySelector("._se_bookmark_button"),this.plugins.selectMenu.initEvent.call(this,e,t);const s=this.context.selectMenu.caller[e];this.options.linkRel.length>0&&(i.relButton=t.querySelector(".se-anchor-rel-btn"),i.relList=t.querySelector(".se-list-layer"),i.relPreview=t.querySelector(".se-anchor-rel-preview"),i.relButton.addEventListener("click",n.onClick_relButton.bind(this,i)),i.relList.addEventListener("click",n.onClick_relList.bind(this,i))),i.newWindowCheck.addEventListener("change",n.onChange_newWindowCheck.bind(this,i)),i.downloadCheck.addEventListener("change",n.onChange_downloadCheck.bind(this,i)),i.anchorText.addEventListener("input",n.onChangeAnchorText.bind(this,i)),i.urlInput.addEventListener("input",n.onChangeUrlInput.bind(this,i)),i.urlInput.addEventListener("keydown",n.onKeyDownUrlInput.bind(this,s)),i.urlInput.addEventListener("focus",n.onFocusUrlInput.bind(this,i,s)),i.urlInput.addEventListener("blur",n.onBlurUrlInput.bind(this,s)),i.bookmarkButton.addEventListener("click",n.onClick_bookmarkButton.bind(this,i))},on:function(e,t){const n=this.plugins.anchor;if(!t)n.init.call(this,e),e.anchorText.value=this.getSelection().toString().trim(),e.newWindowCheck.checked=this.options.linkTargetNewWindow;else if(e.linkAnchor){this.context.dialog.updateModal=!0;const i=e.linkAnchor.getAttribute("href");e.linkValue=e.preview.textContent=e.urlInput.value=n.selfPathBookmark.call(this,i)?i.substr(i.lastIndexOf("#")):i,e.anchorText.value=e.linkAnchor.textContent,e.newWindowCheck.checked=!!/_blank/i.test(e.linkAnchor.target),e.downloadCheck.checked=e.linkAnchor.download}this.context.anchor.callerContext=e,n.setRel.call(this,e,t&&e.linkAnchor?e.linkAnchor.rel:e.defaultRel),n.setLinkPreview.call(this,e,e.linkValue),this.plugins.selectMenu.on.call(this,e.callerName,this.plugins.anchor.setHeaderBookmark)},selfPathBookmark:function(e){const t=this._w.location.href.replace(/\/$/,"");return e.indexOf("#")===0||e.indexOf(t)===0&&e.indexOf("#")===(t.indexOf("#")===-1?t.length:t.substr(0,t.indexOf("#")).length)},_closeRelMenu:null,toggleRelList:function(e,t){if(!t)this.plugins.anchor._closeRelMenu&&this.plugins.anchor._closeRelMenu();else{const n=e.relButton,i=e.relList;this.util.addClass(n,"active"),i.style.visibility="hidden",i.style.display="block",this.options.rtl?i.style.left=n.offsetLeft-i.offsetWidth-1+"px":i.style.left=n.offsetLeft+n.offsetWidth+1+"px",i.style.top=n.offsetTop+n.offsetHeight/2-i.offsetHeight/2+"px",i.style.visibility="",this.plugins.anchor._closeRelMenu=(function(s,o,l){l&&(s.relButton.contains(l.target)||s.relList.contains(l.target))||(this.util.removeClass(o,"active"),s.relList.style.display="none",this.modalForm.removeEventListener("click",this.plugins.anchor._closeRelMenu),this.plugins.anchor._closeRelMenu=null)}).bind(this,e,n),this.modalForm.addEventListener("click",this.plugins.anchor._closeRelMenu)}},onClick_relButton:function(e,t){this.plugins.anchor.toggleRelList.call(this,e,!this.util.hasClass(t.target,"active"))},onClick_relList:function(e,t){const n=t.target,i=n.getAttribute("data-command");if(!i)return;const s=e.currentRel,o=this.util.toggleClass(n,"se-checked"),l=s.indexOf(i);o?l===-1&&s.push(i):l>-1&&s.splice(l,1),e.relPreview.title=e.relPreview.textContent=s.join(" ")},setRel:function(e,t){const n=e.relList,i=e.currentRel=t?t.split(" "):[];if(!n)return;const s=n.querySelectorAll("button");for(let o=0,l=s.length,a;o<l;o++)a=s[o].getAttribute("data-command"),i.indexOf(a)>-1?this.util.addClass(s[o],"se-checked"):this.util.removeClass(s[o],"se-checked");e.relPreview.title=e.relPreview.textContent=i.join(" ")},createHeaderList:function(e,t,n){const i=this.util.getListChildren(this.context.element.wysiwyg,function(a){return/h[1-6]/i.test(a.nodeName)});if(i.length===0)return;const s=new this._w.RegExp("^"+n.replace(/^#/,""),"i"),o=[];let l="";for(let a=0,r=i.length,f;a<r;a++)f=i[a],s.test(f.textContent)&&(o.push(f),l+='<li class="se-select-item" data-index="'+a+'">'+f.textContent+"</li>");o.length===0?this.plugins.selectMenu.close.call(this,t):(this.plugins.selectMenu.createList(t,o,l),this.plugins.selectMenu.open.call(this,t,this.plugins.anchor._setMenuListPosition.bind(this,e)))},_setMenuListPosition:function(e,t){t.style.top=e.urlInput.offsetHeight+1+"px"},onKeyDownUrlInput:function(e,t){switch(t.keyCode){case 38:t.preventDefault(),t.stopPropagation(),this.plugins.selectMenu.moveItem.call(this,e,-1);break;case 40:t.preventDefault(),t.stopPropagation(),this.plugins.selectMenu.moveItem.call(this,e,1);break;case 13:e.index>-1&&(t.preventDefault(),t.stopPropagation(),this.plugins.anchor.setHeaderBookmark.call(this,this.plugins.selectMenu.getItem(e,null)));break}},setHeaderBookmark:function(e){const t=this.context.anchor.callerContext,n=e.id||"h_"+this._w.Math.random().toString().replace(/.+\./,"");e.id=n,t.urlInput.value="#"+n,(!t.anchorText.value.trim()||!t._change)&&(t.anchorText.value=e.textContent),this.plugins.anchor.setLinkPreview.call(this,t,t.urlInput.value),this.plugins.selectMenu.close.call(this,this.context.selectMenu.callerContext),this.context.anchor.callerContext.urlInput.focus()},onChangeAnchorText:function(e,t){e._change=!!t.target.value.trim()},onChangeUrlInput:function(e,t){const n=t.target.value.trim();this.plugins.anchor.setLinkPreview.call(this,e,n),this.plugins.anchor.selfPathBookmark.call(this,n)?this.plugins.anchor.createHeaderList.call(this,e,this.context.selectMenu.callerContext,n):this.plugins.selectMenu.close.call(this,this.context.selectMenu.callerContext)},onFocusUrlInput:function(e,t){const n=e.urlInput.value;this.plugins.anchor.selfPathBookmark.call(this,n)&&this.plugins.anchor.createHeaderList.call(this,e,t,n)},onBlurUrlInput:function(e){this.plugins.selectMenu.close.call(this,e)},setLinkPreview:function(e,t){const n=e.preview,i=this.options.linkProtocol,s=this.options.linkNoPrefix,o=/^(mailto\:|tel\:|sms\:|https*\:\/\/|#)/.test(t)||t.indexOf(i)===0,l=i?this._w.RegExp("^"+this.util.escapeStringRegexp(t.substr(0,i.length))).test(i):!1;t=e.linkValue=n.textContent=t?s?t:i&&!o&&!l?i+t:o?t:/^www\./.test(t)?"http://"+t:this.context.anchor.host+(/^\//.test(t)?"":"/")+t:"",this.plugins.anchor.selfPathBookmark.call(this,t)?(e.bookmark.style.display="block",this.util.addClass(e.bookmarkButton,"active")):(e.bookmark.style.display="none",this.util.removeClass(e.bookmarkButton,"active")),!this.plugins.anchor.selfPathBookmark.call(this,t)&&e.downloadCheck.checked?e.download.style.display="block":e.download.style.display="none"},setCtx:function(e,t){e&&(t.linkAnchor=e,t.linkValue=e.href,t.currentRel=e.rel.split(" "))},updateAnchor:function(e,t,n,i,s){!this.plugins.anchor.selfPathBookmark.call(this,t)&&i.downloadCheck.checked?e.setAttribute("download",n||t):e.removeAttribute("download"),i.newWindowCheck.checked?e.target="_blank":e.removeAttribute("target");const o=i.currentRel.join(" ");o?e.rel=o:e.removeAttribute("rel"),e.href=t,s?e.children.length===0&&(e.textContent=""):e.textContent=n},createAnchor:function(e,t){if(e.linkValue.length===0)return null;const n=e.linkValue,i=e.anchorText,s=i.value.length===0?n:i.value,o=e.linkAnchor||this.util.createElement("A");return this.plugins.anchor.updateAnchor.call(this,o,n,s,e,t),e.linkValue=e.preview.textContent=e.urlInput.value=e.anchorText.value="",o},onClick_bookmarkButton:function(e){let t=e.urlInput.value;this.plugins.anchor.selfPathBookmark.call(this,t)?(t=t.substr(1),e.bookmark.style.display="none",this.util.removeClass(e.bookmarkButton,"active"),this.plugins.selectMenu.close.call(this,this.context.selectMenu.callerContext)):(t="#"+t,e.bookmark.style.display="block",this.util.addClass(e.bookmarkButton,"active"),e.downloadCheck.checked=!1,e.download.style.display="none",this.plugins.anchor.createHeaderList.call(this,e,this.context.selectMenu.callerContext,t)),e.urlInput.value=t,this.plugins.anchor.setLinkPreview.call(this,e,t),e.urlInput.focus()},onChange_newWindowCheck:function(e,t){typeof e.linkDefaultRel.check_new_window=="string"&&(t.target.checked?this.plugins.anchor.setRel.call(this,e,this.plugins.anchor._relMerge.call(this,e,e.linkDefaultRel.check_new_window)):this.plugins.anchor.setRel.call(this,e,this.plugins.anchor._relDelete.call(this,e,e.linkDefaultRel.check_new_window)))},onChange_downloadCheck:function(e,t){t.target.checked?(e.download.style.display="block",e.bookmark.style.display="none",this.util.removeClass(e.bookmarkButton,"active"),e.linkValue=e.preview.textContent=e.urlInput.value=e.urlInput.value.replace(/^\#+/,""),typeof e.linkDefaultRel.check_bookmark=="string"&&this.plugins.anchor.setRel.call(this,e,this.plugins.anchor._relMerge.call(this,e,e.linkDefaultRel.check_bookmark))):(e.download.style.display="none",typeof e.linkDefaultRel.check_bookmark=="string"&&this.plugins.anchor.setRel.call(this,e,this.plugins.anchor._relDelete.call(this,e,e.linkDefaultRel.check_bookmark)))},_relMerge:function(e,t){const n=e.currentRel;if(!t)return n.join(" ");if(/^only\:/.test(t))return t=t.replace(/^only\:/,"").trim(),e.currentRel=t.split(" "),t;const i=t.split(" ");for(let s=0,o=i.length,l;s<o;s++)l=n.indexOf(i[s]),l===-1&&n.push(i[s]);return n.join(" ")},_relDelete:function(e,t){if(!t)return e.currentRel.join(" ");/^only\:/.test(t)&&(t=t.replace(/^only\:/,"").trim());const n=e.currentRel.join(" ").replace(this._w.RegExp(t+"\\s*"),"");return e.currentRel=n.split(" "),n},init:function(e){e.linkAnchor=null,e.linkValue=e.preview.textContent=e.urlInput.value="",e.anchorText.value="",e.newWindowCheck.checked=!1,e.downloadCheck.checked=!1,e._change=!1,this.plugins.anchor.setRel.call(this,e,e.defaultRel),e.relList&&this.plugins.anchor.toggleRelList.call(this,e,!1),this.context.anchor.callerContext=null,this.plugins.selectMenu.init.call(this,this.context.selectMenu.callerContext)}},YC={name:"link",display:"dialog",add:function(e){e.addModule([Fi,ch]);const t=e.context,n=t.link={focusElement:null,_linkAnchor:null,anchorCtx:null};let i=this.setDialog(e);n.modal=i;let s=this.setController_LinkButton(e);n.linkController=s,i.querySelector("form").addEventListener("submit",this.submit.bind(e)),s.addEventListener("click",this.onClick_linkController.bind(e)),t.dialog.modal.appendChild(i),t.element.relative.appendChild(s),e.plugins.anchor.initEvent.call(e,"link",i),n.focusElement=t.anchor.caller.link.urlInput,i=null,s=null},setDialog:function(e){const t=e.lang,n=e.util.createElement("DIV"),i=e.icons;n.className="se-dialog-content",n.style.display="none";let s='<form><div class="se-dialog-header"><button type="button" data-command="close" class="se-btn se-dialog-close" title="'+t.dialogBox.close+'" aria-label="'+t.dialogBox.close+'">'+i.cancel+'</button><span class="se-modal-title">'+t.dialogBox.linkBox.title+"</span></div>"+e.context.anchor.forms.innerHTML+'<div class="se-dialog-footer"><button type="submit" class="se-btn-primary" title="'+t.dialogBox.submitButton+'" aria-label="'+t.dialogBox.submitButton+'"><span>'+t.dialogBox.submitButton+"</span></button></div></form>";return n.innerHTML=s,n},setController_LinkButton:function(e){const t=e.lang,n=e.icons,i=e.util.createElement("DIV");return i.className="se-controller se-controller-link",i.innerHTML='<div class="se-arrow se-arrow-up"></div><div class="link-content"><span><a target="_blank" href=""></a>&nbsp;</span><div class="se-btn-group"><button type="button" data-command="update" tabindex="-1" class="se-btn se-tooltip">'+n.edit+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+t.controller.edit+'</span></span></button><button type="button" data-command="unlink" tabindex="-1" class="se-btn se-tooltip">'+n.unlink+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+t.controller.unlink+'</span></span></button><button type="button" data-command="delete" tabindex="-1" class="se-btn se-tooltip">'+n.delete+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+t.controller.remove+"</span></span></button></div></div>",i},open:function(){this.plugins.dialog.open.call(this,"link",this.currentControllerName==="link")},submit:function(e){this.showLoading(),e.preventDefault(),e.stopPropagation();try{const t=this.plugins.anchor.createAnchor.call(this,this.context.anchor.caller.link,!1);if(t===null)return;if(this.context.dialog.updateModal){const n=this.context.link._linkAnchor.childNodes[0];this.setRange(n,0,n,n.textContent.length)}else{const n=this.getSelectedElements();if(n.length>1){const i=this.util.createElement(n[0].nodeName);if(i.appendChild(t),!this.insertNode(i,null,!0))return}else if(!this.insertNode(t,null,!0))return;this.setRange(t.childNodes[0],0,t.childNodes[0],t.textContent.length)}}finally{this.plugins.dialog.close.call(this),this.closeLoading(),this.history.push(!1)}return!1},active:function(e){if(!e)this.controllerArray.indexOf(this.context.link.linkController)>-1&&this.controllersOff();else if(this.util.isAnchor(e)&&e.getAttribute("data-image-link")===null)return this.controllerArray.indexOf(this.context.link.linkController)<0&&this.plugins.link.call_controller.call(this,e),!0;return!1},on:function(e){this.plugins.anchor.on.call(this,this.context.anchor.caller.link,e)},call_controller:function(e){this.editLink=this.context.link._linkAnchor=this.context.anchor.caller.link.linkAnchor=e;const t=this.context.link.linkController,n=t.querySelector("a");n.href=e.href,n.title=e.textContent,n.textContent=e.textContent,this.util.addClass(e,"on"),this.setControllerPosition(t,e,"bottom",{left:0,top:0}),this.controllersOn(t,e,"link",this.util.removeClass.bind(this.util,this.context.link._linkAnchor,"on"))},onClick_linkController:function(e){e.stopPropagation();const t=e.target.getAttribute("data-command")||e.target.parentNode.getAttribute("data-command");if(t){if(e.preventDefault(),/update/.test(t))this.plugins.dialog.open.call(this,"link",!0);else if(/unlink/.test(t)){const n=this.util.getChildElement(this.context.link._linkAnchor,function(s){return s.childNodes.length===0||s.nodeType===3},!1),i=this.util.getChildElement(this.context.link._linkAnchor,function(s){return s.childNodes.length===0||s.nodeType===3},!0);this.setRange(n,0,i,i.textContent.length),this.nodeChange(null,null,["A"],!1)}else this.util.removeItem(this.context.link._linkAnchor),this.context.anchor.caller.link.linkAnchor=null,this.focus(),this.history.push(!1);this.controllersOff()}},init:function(){this.context.link.linkController.style.display="none",this.plugins.anchor.init.call(this,this.context.anchor.caller.link)}};var uh={exports:{}};(function(e){(function(t,n){e.exports=t.document?n(t,!0):function(i){if(!i.document)throw new Error("SUNEDITOR_MODULES a window with a document");return n(i)}})(typeof window<"u"?window:Yn,function(t,n){const i={name:"component",set_container:function(s,o){const l=this.util.createElement("DIV");return l.className="se-component "+o,l.appendChild(s),l},set_cover:function(s){const o=this.util.createElement("FIGURE");return o.appendChild(s),o},create_caption:function(){const s=this.util.createElement("FIGCAPTION");return s.innerHTML="<div>"+this.lang.dialogBox.caption+"</div>",s}};return typeof n>"u"&&(t.SUNEDITOR_MODULES||Object.defineProperty(t,"SUNEDITOR_MODULES",{enumerable:!0,writable:!1,configurable:!1,value:{}}),Object.defineProperty(t.SUNEDITOR_MODULES,"component",{enumerable:!0,writable:!1,configurable:!1,value:i})),i})})(uh);var ZC=uh.exports;const Xo=Zn(ZC);var dh={exports:{}};(function(e){(function(t,n){e.exports=t.document?n(t,!0):function(i){if(!i.document)throw new Error("SUNEDITOR_MODULES a window with a document");return n(i)}})(typeof window<"u"?window:Yn,function(t,n){const i={name:"resizing",add:function(s){const o=s.icons,l=s.context;l.resizing={_resizeClientX:0,_resizeClientY:0,_resize_plugin:"",_resize_w:0,_resize_h:0,_origin_w:0,_origin_h:0,_rotateVertical:!1,_resize_direction:"",_move_path:null,_isChange:!1,alignIcons:{basic:o.align_justify,left:o.align_left,right:o.align_right,center:o.align_center}};let a=this.setController_resize(s);l.resizing.resizeContainer=a,l.resizing.resizeDiv=a.querySelector(".se-modal-resize"),l.resizing.resizeDot=a.querySelector(".se-resize-dot"),l.resizing.resizeDisplay=a.querySelector(".se-resize-display");let r=this.setController_button(s);l.resizing.resizeButton=r;let f=l.resizing.resizeHandles=l.resizing.resizeDot.querySelectorAll("span");l.resizing.resizeButtonGroup=r.querySelector("._se_resizing_btn_group"),l.resizing.rotationButtons=r.querySelectorAll("._se_resizing_btn_group ._se_rotation"),l.resizing.percentageButtons=r.querySelectorAll("._se_resizing_btn_group ._se_percentage"),l.resizing.alignMenu=r.querySelector(".se-resizing-align-list"),l.resizing.alignMenuList=l.resizing.alignMenu.querySelectorAll("button"),l.resizing.alignButton=r.querySelector("._se_resizing_align_button"),l.resizing.autoSizeButton=r.querySelector("._se_resizing_btn_group ._se_auto_size"),l.resizing.captionButton=r.querySelector("._se_resizing_caption_button"),a.addEventListener("mousedown",function(d){d.preventDefault()}),f[0].addEventListener("mousedown",this.onMouseDown_resize_handle.bind(s)),f[1].addEventListener("mousedown",this.onMouseDown_resize_handle.bind(s)),f[2].addEventListener("mousedown",this.onMouseDown_resize_handle.bind(s)),f[3].addEventListener("mousedown",this.onMouseDown_resize_handle.bind(s)),f[4].addEventListener("mousedown",this.onMouseDown_resize_handle.bind(s)),f[5].addEventListener("mousedown",this.onMouseDown_resize_handle.bind(s)),f[6].addEventListener("mousedown",this.onMouseDown_resize_handle.bind(s)),f[7].addEventListener("mousedown",this.onMouseDown_resize_handle.bind(s)),r.addEventListener("click",this.onClick_resizeButton.bind(s)),l.element.relative.appendChild(a),l.element.relative.appendChild(r),a=null,r=null,f=null},setController_resize:function(s){const o=s.util.createElement("DIV");return o.className="se-controller se-resizing-container",o.style.display="none",o.innerHTML='<div class="se-modal-resize"></div><div class="se-resize-dot"><span class="tl"></span><span class="tr"></span><span class="bl"></span><span class="br"></span><span class="lw"></span><span class="th"></span><span class="rw"></span><span class="bh"></span><div class="se-resize-display"></div></div>',o},setController_button:function(s){const o=s.lang,l=s.icons,a=s.util.createElement("DIV");return a.className="se-controller se-controller-resizing",a.innerHTML='<div class="se-arrow se-arrow-up"></div><div class="se-btn-group _se_resizing_btn_group"><button type="button" data-command="percent" data-value="1" class="se-tooltip _se_percentage"><span>100%</span><span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.controller.resize100+'</span></span></button><button type="button" data-command="percent" data-value="0.75" class="se-tooltip _se_percentage"><span>75%</span><span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.controller.resize75+'</span></span></button><button type="button" data-command="percent" data-value="0.5" class="se-tooltip _se_percentage"><span>50%</span><span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.controller.resize50+'</span></span></button><button type="button" data-command="auto" class="se-btn se-tooltip _se_auto_size">'+l.auto_size+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.controller.autoSize+'</span></span></button><button type="button" data-command="rotate" data-value="-90" class="se-btn se-tooltip _se_rotation">'+l.rotate_left+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.controller.rotateLeft+'</span></span></button><button type="button" data-command="rotate" data-value="90" class="se-btn se-tooltip _se_rotation">'+l.rotate_right+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.controller.rotateRight+'</span></span></button></div><div class="se-btn-group" style="padding-top: 0;"><button type="button" data-command="mirror" data-value="h" class="se-btn se-tooltip">'+l.mirror_horizontal+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.controller.mirrorHorizontal+'</span></span></button><button type="button" data-command="mirror" data-value="v" class="se-btn se-tooltip">'+l.mirror_vertical+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.controller.mirrorVertical+'</span></span></button><button type="button" data-command="onalign" class="se-btn se-tooltip _se_resizing_align_button">'+l.align_justify+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.toolbar.align+'</span></span></button><div class="se-btn-group-sub sun-editor-common se-list-layer se-resizing-align-list"><div class="se-list-inner"><ul class="se-list-basic"><li><button type="button" class="se-btn-list se-tooltip" data-command="align" data-value="basic">'+l.align_justify+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.dialogBox.basic+'</span></span></button></li><li><button type="button" class="se-btn-list se-tooltip" data-command="align" data-value="left">'+l.align_left+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.dialogBox.left+'</span></span></button></li><li><button type="button" class="se-btn-list se-tooltip" data-command="align" data-value="center">'+l.align_center+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.dialogBox.center+'</span></span></button></li><li><button type="button" class="se-btn-list se-tooltip" data-command="align" data-value="right">'+l.align_right+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.dialogBox.right+'</span></span></button></li></ul></div></div><button type="button" data-command="caption" class="se-btn se-tooltip _se_resizing_caption_button">'+l.caption+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.dialogBox.caption+'</span></span></button><button type="button" data-command="revert" class="se-btn se-tooltip">'+l.revert+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.dialogBox.revertButton+'</span></span></button><button type="button" data-command="update" class="se-btn se-tooltip">'+l.modify+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.controller.edit+'</span></span></button><button type="button" data-command="delete" class="se-btn se-tooltip">'+l.delete+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+o.controller.remove+"</span></span></button></div>",a},_module_getSizeX:function(s,o,l,a){return o||(o=s._element),l||(l=s._cover),a||(a=s._container),o?/%$/.test(o.style.width)?(a&&this.util.getNumber(a.style.width,2)||100)+"%":o.style.width:""},_module_getSizeY:function(s,o,l,a){return o||(o=s._element),l||(l=s._cover),a||(a=s._container),!a||!l?o&&o.style.height||"":this.util.getNumber(l.style.paddingBottom,0)>0&&!this.context.resizing._rotateVertical?l.style.height:!/%$/.test(o.style.height)||!/%$/.test(o.style.width)?o.style.height:(a&&this.util.getNumber(a.style.height,2)||100)+"%"},_module_setModifyInputSize:function(s,o){const l=s._onlyPercentage&&this.context.resizing._rotateVertical;s.proportion.checked=s._proportionChecked=s._element.getAttribute("data-proportion")!=="false";let a=l?"":this.plugins.resizing._module_getSizeX.call(this,s);if(a===s._defaultSizeX&&(a=""),s._onlyPercentage&&(a=this.util.getNumber(a,2)),s.inputX.value=a,o.setInputSize.call(this,"x"),!s._onlyPercentage){let r=l?"":this.plugins.resizing._module_getSizeY.call(this,s);r===s._defaultSizeY&&(r=""),s._onlyPercentage&&(r=this.util.getNumber(r,2)),s.inputY.value=r}s.inputX.disabled=!!l,s.inputY.disabled=!!l,s.proportion.disabled=!!l,o.setRatio.call(this)},_module_setInputSize:function(s,o){if(s._onlyPercentage){o==="x"&&s.inputX.value>100&&(s.inputX.value=100);return}if(s.proportion.checked&&s._ratio&&/\d/.test(s.inputX.value)&&/\d/.test(s.inputY.value)){const l=s.inputX.value.replace(/\d+|\./g,"")||s.sizeUnit,a=s.inputY.value.replace(/\d+|\./g,"")||s.sizeUnit;if(l!==a)return;const r=l==="%"?2:0;o==="x"?s.inputY.value=this.util.getNumber(s._ratioY*this.util.getNumber(s.inputX.value,r),r)+a:s.inputX.value=this.util.getNumber(s._ratioX*this.util.getNumber(s.inputY.value,r),r)+l}},_module_setRatio:function(s){const o=s.inputX.value,l=s.inputY.value;if(s.proportion.checked&&/\d+/.test(o)&&/\d+/.test(l)){const a=o.replace(/\d+|\./g,"")||s.sizeUnit,r=l.replace(/\d+|\./g,"")||s.sizeUnit;if(a!==r)s._ratio=!1;else if(!s._ratio){const f=this.util.getNumber(o,0),d=this.util.getNumber(l,0);s._ratio=!0,s._ratioX=f/d,s._ratioY=d/f}}else s._ratio=!1},_module_sizeRevert:function(s){s._onlyPercentage?s.inputX.value=s._origin_w>100?100:s._origin_w:(s.inputX.value=s._origin_w,s.inputY.value=s._origin_h)},_module_saveCurrentSize:function(s){const o=this.plugins.resizing._module_getSizeX.call(this,s),l=this.plugins.resizing._module_getSizeY.call(this,s);s._element.setAttribute("width",o.replace("px","")),s._element.setAttribute("height",l.replace("px","")),s._element.setAttribute("data-size",o+","+l),s._videoRatio&&(s._videoRatio=l)},call_controller_resize:function(s,o){const l=this.context.resizing,a=this.context[o];l._resize_plugin=o;const r=l.resizeContainer,f=l.resizeDiv,d=this.util.getOffset(s,this.context.element.wysiwygFrame),h=l._rotateVertical=/^(90|270)$/.test(Math.abs(s.getAttribute("data-rotate")).toString()),v=h?s.offsetHeight:s.offsetWidth,_=h?s.offsetWidth:s.offsetHeight,C=d.top,S=d.left-this.context.element.wysiwygFrame.scrollLeft;r.style.top=C+"px",r.style.left=S+"px",r.style.width=v+"px",r.style.height=_+"px",f.style.top="0px",f.style.left="0px",f.style.width=v+"px",f.style.height=_+"px";let c=s.getAttribute("data-align")||"basic";c=c==="none"?"basic":c;const u=this.util.getParentElement(s,this.util.isComponent),p=this.util.getParentElement(s,"FIGURE"),b=this.plugins.resizing._module_getSizeX.call(this,a,s,p,u)||"auto",y=a._onlyPercentage&&o==="image"?"":", "+(this.plugins.resizing._module_getSizeY.call(this,a,s,p,u)||"auto");this.util.changeTxt(l.resizeDisplay,this.lang.dialogBox[c]+" ("+b+y+")"),l.resizeButtonGroup.style.display=a._resizing?"":"none";const w=a._resizing&&!a._resizeDotHide&&!a._onlyPercentage?"flex":"none",x=l.resizeHandles;for(let M=0,A=x.length;M<A;M++)x[M].style.display=w;if(a._resizing){const M=l.rotationButtons;M[0].style.display=M[1].style.display=a._rotation?"":"none"}if(a._alignHide)l.alignButton.style.display="none";else{l.alignButton.style.display="";const M=l.alignMenuList;this.util.changeElement(l.alignButton.firstElementChild,l.alignIcons[c]);for(let A=0,D=M.length;A<D;A++)M[A].getAttribute("data-value")===c?this.util.addClass(M[A],"on"):this.util.removeClass(M[A],"on")}const E=l.percentageButtons,k=/%$/.test(s.style.width)&&/%$/.test(u.style.width)?this.util.getNumber(u.style.width,0)/100+"":"";for(let M=0,A=E.length;M<A;M++)E[M].getAttribute("data-value")===k?this.util.addClass(E[M],"active"):this.util.removeClass(E[M],"active");a._captionShow?(l.captionButton.style.display="",this.util.getChildElement(s.parentNode,"figcaption")?(this.util.addClass(l.captionButton,"active"),a._captionChecked=!0):(this.util.removeClass(l.captionButton,"active"),a._captionChecked=!1)):l.captionButton.style.display="none",r.style.display="block";const N={left:0,top:50};this.options.iframe&&(N.left-=this.context.element.wysiwygFrame.parentElement.offsetLeft,N.top-=this.context.element.wysiwygFrame.parentElement.offsetTop),this.setControllerPosition(l.resizeButton,r,"bottom",N);const T=function(){this.util.setDisabledButtons.call(this.util,!1,this.resizingDisabledButtons),this.history._resetCachingButton()};this.controllersOn(r,l.resizeButton,T.bind(this),s,o),this.util.setDisabledButtons(!0,this.resizingDisabledButtons),l._resize_w=v,l._resize_h=_;const R=(s.getAttribute("origin-size")||"").split(",");return l._origin_w=R[0]||s.naturalWidth,l._origin_h=R[1]||s.naturalHeight,{w:v,h:_,t:C,l:S}},_closeAlignMenu:null,openAlignMenu:function(){const s=this.context.resizing.alignButton;this.util.addClass(s,"on"),this.context.resizing.alignMenu.style.top=s.offsetTop+s.offsetHeight+"px",this.context.resizing.alignMenu.style.left=s.offsetLeft-s.offsetWidth/2+"px",this.context.resizing.alignMenu.style.display="block",this.plugins.resizing._closeAlignMenu=(function(){this.util.removeClass(this.context.resizing.alignButton,"on"),this.context.resizing.alignMenu.style.display="none",this.removeDocEvent("click",this.plugins.resizing._closeAlignMenu),this.plugins.resizing._closeAlignMenu=null}).bind(this),this.addDocEvent("click",this.plugins.resizing._closeAlignMenu)},onClick_resizeButton:function(s){s.stopPropagation();const o=s.target,l=o.getAttribute("data-command")||o.parentNode.getAttribute("data-command");if(!l)return;const a=o.getAttribute("data-value")||o.parentNode.getAttribute("data-value"),r=this.context.resizing._resize_plugin,f=this.context[r],d=f._element,h=this.plugins[r];if(s.preventDefault(),!(typeof this.plugins.resizing._closeAlignMenu=="function"&&(this.plugins.resizing._closeAlignMenu(),l==="onalign"))){switch(l){case"auto":this.plugins.resizing.resetTransform.call(this,d),h.setAutoSize.call(this),this.selectComponent(d,r);break;case"percent":let v=this.plugins.resizing._module_getSizeY.call(this,f);if(this.context.resizing._rotateVertical){const w=d.getAttribute("data-percentage");w&&(v=w.split(",")[1])}this.plugins.resizing.resetTransform.call(this,d),h.setPercentSize.call(this,a*100,this.util.getNumber(v,0)===null||!/%$/.test(v)?"":v),this.selectComponent(d,r);break;case"mirror":const _=d.getAttribute("data-rotate")||"0";let C=d.getAttribute("data-rotateX")||"",S=d.getAttribute("data-rotateY")||"";a==="h"&&!this.context.resizing._rotateVertical||a==="v"&&this.context.resizing._rotateVertical?S=S?"":"180":C=C?"":"180",d.setAttribute("data-rotateX",C),d.setAttribute("data-rotateY",S),this.plugins.resizing._setTransForm(d,_,C,S);break;case"rotate":const c=this.context.resizing,u=d.getAttribute("data-rotate")*1+a*1,p=this._w.Math.abs(u)>=360?0:u;d.setAttribute("data-rotate",p),c._rotateVertical=/^(90|270)$/.test(this._w.Math.abs(p).toString()),this.plugins.resizing.setTransformSize.call(this,d,null,null),this.selectComponent(d,r);break;case"onalign":this.plugins.resizing.openAlignMenu.call(this);return;case"align":const b=a==="basic"?"none":a;h.setAlign.call(this,b,null,null,null),this.selectComponent(d,r);break;case"caption":const y=!f._captionChecked;if(h.openModify.call(this,!0),f._captionChecked=f.captionCheckEl.checked=y,h.update_image.call(this,!1,!1,!1),y){const w=this.util.getChildElement(f._caption,function(x){return x.nodeType===3});w?this.setRange(w,0,w,w.textContent.length):f._caption.focus(),this.controllersOff()}else this.selectComponent(d,r),h.openModify.call(this,!0);break;case"revert":h.setOriginSize.call(this),this.selectComponent(d,r);break;case"update":h.openModify.call(this),this.controllersOff();break;case"delete":h.destroy.call(this);break}this.history.push(!1)}},resetTransform:function(s){const o=(s.getAttribute("data-size")||s.getAttribute("data-origin")||"").split(",");this.context.resizing._rotateVertical=!1,s.style.maxWidth="",s.style.transform="",s.style.transformOrigin="",s.setAttribute("data-rotate",""),s.setAttribute("data-rotateX",""),s.setAttribute("data-rotateY",""),this.plugins[this.context.resizing._resize_plugin].setSize.call(this,o[0]?o[0]:"auto",o[1]?o[1]:"",!0)},setTransformSize:function(s,o,l){let a=s.getAttribute("data-percentage");const r=this.context.resizing._rotateVertical,f=s.getAttribute("data-rotate")*1;let d="";if(a&&!r)a=a.split(","),a[0]==="auto"&&a[1]==="auto"?this.plugins[this.context.resizing._resize_plugin].setAutoSize.call(this):this.plugins[this.context.resizing._resize_plugin].setPercentSize.call(this,a[0],a[1]);else{const h=this.util.getParentElement(s,"FIGURE"),v=o||s.offsetWidth,_=l||s.offsetHeight,C=(r?_:v)+"px",S=(r?v:_)+"px";if(this.plugins[this.context.resizing._resize_plugin].cancelPercentAttr.call(this),this.plugins[this.context.resizing._resize_plugin].setSize.call(this,v+"px",_+"px",!0),h.style.width=C,h.style.height=this.context[this.context.resizing._resize_plugin]._caption?"":S,r){let c=v/2+"px "+v/2+"px 0",u=_/2+"px "+_/2+"px 0";d=f===90||f===-270?u:c}}s.style.transformOrigin=d,this.plugins.resizing._setTransForm(s,f.toString(),s.getAttribute("data-rotateX")||"",s.getAttribute("data-rotateY")||""),r?s.style.maxWidth="none":s.style.maxWidth="",this.plugins.resizing.setCaptionPosition.call(this,s)},_setTransForm:function(s,o,l,a){let r=(s.offsetWidth-s.offsetHeight)*(/-/.test(o)?1:-1),f="";if(/[1-9]/.test(o)&&(l||a))switch(f=l?"Y":"X",o){case"90":f=l&&a?"X":a?f:"";break;case"270":r*=-1,f=l&&a?"Y":l?f:"";break;case"-90":f=l&&a?"Y":l?f:"";break;case"-270":r*=-1,f=l&&a?"X":a?f:"";break;default:f=""}o%180===0&&(s.style.maxWidth=""),s.style.transform="rotate("+o+"deg)"+(l?" rotateX("+l+"deg)":"")+(a?" rotateY("+a+"deg)":"")+(f?" translate"+f+"("+r+"px)":"")},setCaptionPosition:function(s){const o=this.util.getChildElement(this.util.getParentElement(s,"FIGURE"),"FIGCAPTION");o&&(o.style.marginTop=(this.context.resizing._rotateVertical?s.offsetWidth-s.offsetHeight:0)+"px")},onMouseDown_resize_handle:function(s){s.stopPropagation(),s.preventDefault();const o=this.context.resizing,l=o._resize_direction=s.target.classList[0];o._resizeClientX=s.clientX,o._resizeClientY=s.clientY,this.context.element.resizeBackground.style.display="block",o.resizeButton.style.display="none",o.resizeDiv.style.float=/l/.test(l)?"right":/r/.test(l)?"left":"none";const a=(function(d){if(d.type==="keydown"&&d.keyCode!==27)return;const h=o._isChange;o._isChange=!1,this.removeDocEvent("mousemove",r),this.removeDocEvent("mouseup",a),this.removeDocEvent("keydown",a),d.type==="keydown"?(this.controllersOff(),this.context.element.resizeBackground.style.display="none",this.plugins[this.context.resizing._resize_plugin].init.call(this)):(this.plugins.resizing.cancel_controller_resize.call(this,l),h&&this.history.push(!1))}).bind(this),r=this.plugins.resizing.resizing_element.bind(this,o,l,this.context[o._resize_plugin]);this.addDocEvent("mousemove",r),this.addDocEvent("mouseup",a),this.addDocEvent("keydown",a)},resizing_element:function(s,o,l,a){const r=a.clientX,f=a.clientY;let d=l._element_w,h=l._element_h;const v=l._element_w+(/r/.test(o)?r-s._resizeClientX:s._resizeClientX-r),_=l._element_h+(/b/.test(o)?f-s._resizeClientY:s._resizeClientY-f),C=l._element_h/l._element_w*v;/t/.test(o)&&(s.resizeDiv.style.top=l._element_h-(/h/.test(o)?_:C)+"px"),/l/.test(o)&&(s.resizeDiv.style.left=l._element_w-v+"px"),/r|l/.test(o)&&(s.resizeDiv.style.width=v+"px",d=v),/^(t|b)[^h]$/.test(o)?(s.resizeDiv.style.height=C+"px",h=C):/^(t|b)h$/.test(o)&&(s.resizeDiv.style.height=_+"px",h=_),s._resize_w=d,s._resize_h=h,this.util.changeTxt(s.resizeDisplay,this._w.Math.round(d)+" x "+this._w.Math.round(h)),s._isChange=!0},cancel_controller_resize:function(s){const o=this.context.resizing._rotateVertical;this.controllersOff(),this.context.element.resizeBackground.style.display="none";let l=this._w.Math.round(o?this.context.resizing._resize_h:this.context.resizing._resize_w),a=this._w.Math.round(o?this.context.resizing._resize_w:this.context.resizing._resize_h);if(!o&&!/%$/.test(l)){const d=this.context.element.wysiwygFrame.clientWidth-32-2;this.util.getNumber(l,0)>d&&(a=this._w.Math.round(a/l*d),l=d)}const r=this.context.resizing._resize_plugin;this.plugins[r].setSize.call(this,l,a,!1,s),o&&this.plugins.resizing.setTransformSize.call(this,this.context[this.context.resizing._resize_plugin]._element,l,a),this.selectComponent(this.context[r]._element,r)}};return typeof n>"u"&&(t.SUNEDITOR_MODULES||Object.defineProperty(t,"SUNEDITOR_MODULES",{enumerable:!0,writable:!1,configurable:!1,value:{}}),Object.defineProperty(t.SUNEDITOR_MODULES,"resizing",{enumerable:!0,writable:!1,configurable:!1,value:i})),i})})(dh);var qC=dh.exports;const fh=Zn(qC);var hh={exports:{}};(function(e){(function(t,n){e.exports=t.document?n(t,!0):function(i){if(!i.document)throw new Error("SUNEDITOR_MODULES a window with a document");return n(i)}})(typeof window<"u"?window:Yn,function(t,n){const i={name:"fileManager",_xmlHttp:null,_checkMediaComponent:function(s){return/IMG|IFRAME|VIDEO|AUDIO/i.test(s.tagName)?/FIGURE/i.test(s.parentElement.nodeName)||/FIGURE/i.test(s.parentElement.parentElement.nodeName):!0},upload:function(s,o,l,a,r){this.showLoading();const f=this.plugins.fileManager,d=f._xmlHttp=this.util.getXMLHttpRequest();if(d.onreadystatechange=f._callBackUpload.bind(this,d,a,r),d.open("post",s,!0),o!==null&&typeof o=="object"&&this._w.Object.keys(o).length>0)for(let h in o)d.setRequestHeader(h,o[h]);d.send(l)},_callBackUpload:function(s,o,l){if(s.readyState===4)if(s.status===200)try{o(s)}catch(a){throw Error('[SUNEDITOR.fileManager.upload.callBack.fail] cause : "'+a.message+'"')}finally{this.closeLoading()}else{this.closeLoading();const a=s.responseText?JSON.parse(s.responseText):s;if(typeof l!="function"||l("",a,this)){const r="[SUNEDITOR.fileManager.upload.serverException] status: "+s.status+", response: "+(a.errorMessage||s.responseText);throw this.functions.noticeOpen(r),Error(r)}}},checkInfo:function(s,o,l,a,r){let f=[];for(let u=0,p=o.length;u<p;u++)f=f.concat([].slice.call(this.context.element.wysiwyg.querySelectorAll(o[u]+':not([data-se-embed="true"])')));const d=this.plugins.fileManager,h=this.context[s],v=h._infoList,_=d.setInfo.bind(this);if(f.length===v.length)if(this._componentsInfoReset){for(let u=0,p=f.length;u<p;u++)_(s,f[u],l,null,r);return}else{let u=!1;for(let p=0,b=v.length,y;p<b;p++)if(y=v[p],f.filter(function(w){return y.src===w.src&&y.index.toString()===w.getAttribute("data-index")}).length===0){u=!0;break}if(!u)return}const C=r?this.context.resizing._resize_plugin:"";r&&(this.context.resizing._resize_plugin=s);const S=[],c=[];for(let u=0,p=v.length;u<p;u++)c[u]=v[u].index;for(h.__updateTags=f;f.length>0;){const u=f.shift();!this.util.getParentElement(u,this.util.isMediaComponent)||!d._checkMediaComponent(u)?(S.push(h._infoIndex),a(u)):!u.getAttribute("data-index")||c.indexOf(u.getAttribute("data-index")*1)<0?(S.push(h._infoIndex),u.removeAttribute("data-index"),_(s,u,l,null,r)):S.push(u.getAttribute("data-index")*1)}for(let u=0,p;u<v.length;u++)p=v[u].index,!(S.indexOf(p)>-1)&&(v.splice(u,1),typeof l=="function"&&l(null,p,"delete",null,0,this),u--);r&&(this.context.resizing._resize_plugin=C)},setInfo:function(s,o,l,a,r){const f=r?this.context.resizing._resize_plugin:"";r&&(this.context.resizing._resize_plugin=s);const d=this.plugins[s],h=this.context[s],v=h._infoList;let _=o.getAttribute("data-index"),C=null,S="";if(a||(a={name:o.getAttribute("data-file-name")||(typeof o.src=="string"?o.src.split("/").pop():""),size:o.getAttribute("data-file-size")||0}),!_||this._componentsInfoInit)S="create",_=h._infoIndex++,o.setAttribute("data-index",_),o.setAttribute("data-file-name",a.name),o.setAttribute("data-file-size",a.size),C={src:o.src,index:_*1,name:a.name,size:a.size},v.push(C);else{S="update",_*=1;for(let c=0,u=v.length;c<u;c++)if(_===v[c].index){C=v[c];break}C||(_=h._infoIndex++,C={index:_},v.push(C)),C.src=o.src,C.name=o.getAttribute("data-file-name"),C.size=o.getAttribute("data-file-size")*1}if(C.element=o,C.delete=d.destroy.bind(this,o),C.select=(function(c){c.scrollIntoView(!0),this._w.setTimeout(d.select.bind(this,c))}).bind(this,o),r){if(!o.getAttribute("origin-size")&&o.naturalWidth&&o.setAttribute("origin-size",o.naturalWidth+","+o.naturalHeight),!o.getAttribute("data-origin")){const c=this.util.getParentElement(o,this.util.isMediaComponent),u=this.util.getParentElement(o,"FIGURE"),p=this.plugins.resizing._module_getSizeX.call(this,h,o,u,c),b=this.plugins.resizing._module_getSizeY.call(this,h,o,u,c);o.setAttribute("data-origin",p+","+b),o.setAttribute("data-size",p+","+b)}if(!o.style.width){const c=(o.getAttribute("data-size")||o.getAttribute("data-origin")||"").split(",");d.onModifyMode.call(this,o,null),d.applySize.call(this,c[0],c[1])}this.context.resizing._resize_plugin=f}typeof l=="function"&&l(o,_,S,C,--h._uploadFileLength<0?0:h._uploadFileLength,this)},deleteInfo:function(s,o,l){if(o>=0){const a=this.context[s]._infoList;for(let r=0,f=a.length;r<f;r++)if(o===a[r].index){a.splice(r,1),typeof l=="function"&&l(null,o,"delete",null,0,this);return}}},resetInfo:function(s,o){const l=this.context[s];if(typeof o=="function"){const a=l._infoList;for(let r=0,f=a.length;r<f;r++)o(null,a[r].index,"delete",null,0,this)}l._infoList=[],l._infoIndex=0}};return typeof n>"u"&&(t.SUNEDITOR_MODULES||Object.defineProperty(t,"SUNEDITOR_MODULES",{enumerable:!0,writable:!1,configurable:!1,value:{}}),Object.defineProperty(t.SUNEDITOR_MODULES,"fileManager",{enumerable:!0,writable:!1,configurable:!1,value:i})),i})})(hh);var GC=hh.exports;const Qo=Zn(GC),KC={name:"image",display:"dialog",add:function(e){e.addModule([Fi,ch,Xo,fh,Qo]);const t=e.options,n=e.context,i=n.image={_infoList:[],_infoIndex:0,_uploadFileLength:0,focusElement:null,sizeUnit:t._imageSizeUnit,_linkElement:"",_altText:"",_align:"none",_floatClassRegExp:"__se__float\\-[a-z]+",_v_src:{_linkValue:""},svgDefaultSize:"30%",base64RenderIndex:0,_element:null,_cover:null,_container:null,inputX:null,inputY:null,_element_w:1,_element_h:1,_element_l:0,_element_t:0,_defaultSizeX:"auto",_defaultSizeY:"auto",_origin_w:t.imageWidth==="auto"?"":t.imageWidth,_origin_h:t.imageHeight==="auto"?"":t.imageHeight,_proportionChecked:!0,_resizing:t.imageResizing,_resizeDotHide:!t.imageHeightShow,_rotation:t.imageRotation,_alignHide:!t.imageAlignShow,_onlyPercentage:t.imageSizeOnlyPercentage,_ratio:!1,_ratioX:1,_ratioY:1,_captionShow:!0,_captionChecked:!1,_caption:null,captionCheckEl:null};let s=this.setDialog(e);i.modal=s,i.imgInputFile=s.querySelector("._se_image_file"),i.imgUrlFile=s.querySelector("._se_image_url"),i.focusElement=i.imgInputFile||i.imgUrlFile,i.altText=s.querySelector("._se_image_alt"),i.captionCheckEl=s.querySelector("._se_image_check_caption"),i.previewSrc=s.querySelector("._se_tab_content_image .se-link-preview"),s.querySelector(".se-dialog-tabs").addEventListener("click",this.openTab.bind(e)),s.querySelector("form").addEventListener("submit",this.submit.bind(e)),i.imgInputFile&&s.querySelector(".se-file-remove").addEventListener("click",this._removeSelectedFiles.bind(i.imgInputFile,i.imgUrlFile,i.previewSrc)),i.imgUrlFile&&i.imgUrlFile.addEventListener("input",this._onLinkPreview.bind(i.previewSrc,i._v_src,t.linkProtocol)),i.imgInputFile&&i.imgUrlFile&&i.imgInputFile.addEventListener("change",this._fileInputChange.bind(i));const o=s.querySelector(".__se__gallery");o&&o.addEventListener("click",this._openGallery.bind(e)),i.proportion={},i.inputX={},i.inputY={},t.imageResizing&&(i.proportion=s.querySelector("._se_image_check_proportion"),i.inputX=s.querySelector("._se_image_size_x"),i.inputY=s.querySelector("._se_image_size_y"),i.inputX.value=t.imageWidth,i.inputY.value=t.imageHeight,i.inputX.addEventListener("keyup",this.setInputSize.bind(e,"x")),i.inputY.addEventListener("keyup",this.setInputSize.bind(e,"y")),i.inputX.addEventListener("change",this.setRatio.bind(e)),i.inputY.addEventListener("change",this.setRatio.bind(e)),i.proportion.addEventListener("change",this.setRatio.bind(e)),s.querySelector(".se-dialog-btn-revert").addEventListener("click",this.sizeRevert.bind(e))),n.dialog.modal.appendChild(s),e.plugins.anchor.initEvent.call(e,"image",s.querySelector("._se_tab_content_url")),i.anchorCtx=e.context.anchor.caller.image,s=null},setDialog:function(e){const t=e.options,n=e.lang,i=e.util.createElement("DIV");i.className="se-dialog-content se-dialog-image",i.style.display="none";let s='<div class="se-dialog-header"><button type="button" data-command="close" class="se-btn se-dialog-close" class="close" title="'+n.dialogBox.close+'" aria-label="'+n.dialogBox.close+'">'+e.icons.cancel+'</button><span class="se-modal-title">'+n.dialogBox.imageBox.title+'</span></div><div class="se-dialog-tabs"><button type="button" class="_se_tab_link active" data-tab-link="image">'+n.toolbar.image+'</button><button type="button" class="_se_tab_link" data-tab-link="url">'+n.toolbar.link+'</button></div><form method="post" enctype="multipart/form-data"><div class="_se_tab_content _se_tab_content_image"><div class="se-dialog-body"><div style="border-bottom: 1px dashed #ccc;">';if(t.imageFileInput&&(s+='<div class="se-dialog-form"><label>'+n.dialogBox.imageBox.file+'</label><div class="se-dialog-form-files"><input class="se-input-form _se_image_file" type="file" accept="'+t.imageAccept+'"'+(t.imageMultipleFile?' multiple="multiple"':"")+'/><button type="button" class="se-btn se-dialog-files-edge-button se-file-remove" title="'+n.controller.remove+'" aria-label="'+n.controller.remove+'">'+e.icons.cancel+"</button></div></div>"),t.imageUrlInput&&(s+='<div class="se-dialog-form"><label>'+n.dialogBox.imageBox.url+'</label><div class="se-dialog-form-files"><input class="se-input-form se-input-url _se_image_url" type="text" />'+(t.imageGalleryUrl&&e.plugins.imageGallery?'<button type="button" class="se-btn se-dialog-files-edge-button __se__gallery" title="'+n.toolbar.imageGallery+'" aria-label="'+n.toolbar.imageGallery+'">'+e.icons.image_gallery+"</button>":"")+'</div><pre class="se-link-preview"></pre></div>'),s+='</div><div class="se-dialog-form"><label>'+n.dialogBox.imageBox.altText+'</label><input class="se-input-form _se_image_alt" type="text" /></div>',t.imageResizing){const o=t.imageSizeOnlyPercentage,l=o?' style="display: none !important;"':"",a=t.imageHeightShow?"":' style="display: none !important;"';s+='<div class="se-dialog-form">',o||!t.imageHeightShow?s+='<div class="se-dialog-size-text"><label class="size-w">'+n.dialogBox.size+"</label></div>":s+='<div class="se-dialog-size-text"><label class="size-w">'+n.dialogBox.width+'</label><label class="se-dialog-size-x">&nbsp;</label><label class="size-h">'+n.dialogBox.height+"</label></div>",s+='<input class="se-input-control _se_image_size_x" placeholder="auto"'+(o?' type="number" min="1"':'type="text"')+(o?' max="100"':"")+' /><label class="se-dialog-size-x"'+a+">"+(o?"%":"x")+'</label><input type="text" class="se-input-control _se_image_size_y" placeholder="auto"'+l+(o?' max="100"':"")+a+"/><label"+l+a+'><input type="checkbox" class="se-dialog-btn-check _se_image_check_proportion" checked/>&nbsp;'+n.dialogBox.proportion+'</label><button type="button" title="'+n.dialogBox.revertButton+'" aria-label="'+n.dialogBox.revertButton+'" class="se-btn se-dialog-btn-revert" style="float: right;">'+e.icons.revert+"</button></div>"}return s+='<div class="se-dialog-form se-dialog-form-footer"><label><input type="checkbox" class="se-dialog-btn-check _se_image_check_caption" />&nbsp;'+n.dialogBox.caption+'</label></div></div></div><div class="_se_tab_content _se_tab_content_url" style="display: none">'+e.context.anchor.forms.innerHTML+'</div><div class="se-dialog-footer"><div'+(t.imageAlignShow?"":' style="display: none"')+'><label><input type="radio" name="suneditor_image_radio" class="se-dialog-btn-radio" value="none" checked>'+n.dialogBox.basic+'</label><label><input type="radio" name="suneditor_image_radio" class="se-dialog-btn-radio" value="left">'+n.dialogBox.left+'</label><label><input type="radio" name="suneditor_image_radio" class="se-dialog-btn-radio" value="center">'+n.dialogBox.center+'</label><label><input type="radio" name="suneditor_image_radio" class="se-dialog-btn-radio" value="right">'+n.dialogBox.right+'</label></div><button type="submit" class="se-btn-primary" title="'+n.dialogBox.submitButton+'" aria-label="'+n.dialogBox.submitButton+'"><span>'+n.dialogBox.submitButton+"</span></button></div></form>",i.innerHTML=s,i},_fileInputChange:function(){this.imgInputFile.value?(this.imgUrlFile.setAttribute("disabled",!0),this.previewSrc.style.textDecoration="line-through"):(this.imgUrlFile.removeAttribute("disabled"),this.previewSrc.style.textDecoration="")},_removeSelectedFiles:function(e,t){this.value="",e&&(e.removeAttribute("disabled"),t.style.textDecoration="")},_openGallery:function(){this.callPlugin("imageGallery",this.plugins.imageGallery.open.bind(this,this.plugins.image._setUrlInput.bind(this.context.image)),null)},_setUrlInput:function(e){this.altText.value=e.alt,this._v_src._linkValue=this.previewSrc.textContent=this.imgUrlFile.value=e.getAttribute("data-value")||e.src,this.imgUrlFile.focus()},_onLinkPreview:function(e,t,n){const i=n.target.value.trim();e._linkValue=this.textContent=i?t&&i.indexOf("://")===-1&&i.indexOf("#")!==0?t+i:i.indexOf("://")===-1?"/"+i:i:""},fileTags:["img"],select:function(e){this.plugins.image.onModifyMode.call(this,e,this.plugins.resizing.call_controller_resize.call(this,e,"image"))},destroy:function(e){const t=e||this.context.image._element,n=this.util.getParentElement(t,this.util.isMediaComponent)||t,i=t.getAttribute("data-index")*1;if(typeof this.functions.onImageDeleteBefore=="function"&&this.functions.onImageDeleteBefore(t,n,i,this)===!1)return;let s=n.previousElementSibling||n.nextElementSibling;const o=n.parentNode;this.util.removeItem(n),this.plugins.image.init.call(this),this.controllersOff(),o!==this.context.element.wysiwyg&&this.util.removeItemAllParents(o,function(l){return l.childNodes.length===0},null),this.focusEdge(s),this.plugins.fileManager.deleteInfo.call(this,"image",i,this.functions.onImageUpload),this.history.push(!1)},on:function(e){const t=this.context.image;e?t.imgInputFile&&this.options.imageMultipleFile&&t.imgInputFile.removeAttribute("multiple"):(t.inputX.value=t._origin_w=this.options.imageWidth===t._defaultSizeX?"":this.options.imageWidth,t.inputY.value=t._origin_h=this.options.imageHeight===t._defaultSizeY?"":this.options.imageHeight,t.imgInputFile&&this.options.imageMultipleFile&&t.imgInputFile.setAttribute("multiple","multiple")),this.plugins.anchor.on.call(this,t.anchorCtx,e)},open:function(){this.plugins.dialog.open.call(this,"image",this.currentControllerName==="image")},openTab:function(e){const t=this.context.image.modal,n=e==="init"?t.querySelector("._se_tab_link"):e.target;if(!/^BUTTON$/i.test(n.tagName))return!1;const i=n.getAttribute("data-tab-link"),s="_se_tab_content";let o,l,a;for(l=t.getElementsByClassName(s),o=0;o<l.length;o++)l[o].style.display="none";for(a=t.getElementsByClassName("_se_tab_link"),o=0;o<a.length;o++)this.util.removeClass(a[o],"active");return t.querySelector("."+s+"_"+i).style.display="block",this.util.addClass(n,"active"),i==="image"&&this.context.image.focusElement?this.context.image.focusElement.focus():i==="url"&&this.context.anchor.caller.image.urlInput.focus(),!1},submit:function(e){const t=this.context.image,n=this.plugins.image;e.preventDefault(),e.stopPropagation(),t._altText=t.altText.value,t._align=t.modal.querySelector('input[name="suneditor_image_radio"]:checked').value,t._captionChecked=t.captionCheckEl.checked,t._resizing&&(t._proportionChecked=t.proportion.checked);try{this.context.dialog.updateModal&&n.update_image.call(this,!1,!0,!1),t.imgInputFile&&t.imgInputFile.files.length>0?(this.showLoading(),n.submitAction.call(this,this.context.image.imgInputFile.files)):t.imgUrlFile&&t._v_src._linkValue.length>0&&(this.showLoading(),n.onRender_imgUrl.call(this,t._v_src._linkValue))}catch(i){throw this.closeLoading(),Error('[SUNEDITOR.image.submit.fail] cause : "'+i.message+'"')}finally{this.plugins.dialog.close.call(this)}return!1},submitAction:function(e){if(e.length===0)return;let t=0,n=[];for(let a=0,r=e.length;a<r;a++)/image/i.test(e[a].type)&&(n.push(e[a]),t+=e[a].size);const i=this.options.imageUploadSizeLimit;if(i>0){let a=0;const r=this.context.image._infoList;for(let f=0,d=r.length;f<d;f++)a+=r[f].size*1;if(t+a>i){this.closeLoading();const f="[SUNEDITOR.imageUpload.fail] Size of uploadable total images: "+i/1e3+"KB";(typeof this.functions.onImageUploadError!="function"||this.functions.onImageUploadError(f,{limitSize:i,currentSize:a,uploadSize:t},this))&&this.functions.noticeOpen(f);return}}const s=this.context.image;s._uploadFileLength=n.length;const l={anchor:this.plugins.anchor.createAnchor.call(this,s.anchorCtx,!0),inputWidth:s.inputX.value,inputHeight:s.inputY.value,align:s._align,isUpdate:this.context.dialog.updateModal,alt:s._altText,element:s._element};if(typeof this.functions.onImageUploadBefore=="function"){const a=this.functions.onImageUploadBefore(n,l,this,(function(r){r&&this._w.Array.isArray(r.result)?this.plugins.image.register.call(this,l,r):this.plugins.image.upload.call(this,l,r)}).bind(this));if(typeof a>"u")return;if(!a){this.closeLoading();return}this._w.Array.isArray(a)&&a.length>0&&(n=a)}this.plugins.image.upload.call(this,l,n)},error:function(e,t){if(this.closeLoading(),typeof this.functions.onImageUploadError!="function"||this.functions.onImageUploadError(e,t,this))throw this.functions.noticeOpen(e),Error("[SUNEDITOR.plugin.image.error] response: "+e)},upload:function(e,t){if(!t){this.closeLoading();return}if(typeof t=="string"){this.plugins.image.error.call(this,t,null);return}const n=this.options.imageUploadUrl,i=this.context.dialog.updateModal?1:t.length;if(typeof n=="string"&&n.length>0){const s=new FormData;for(let o=0;o<i;o++)s.append("file-"+o,t[o]);this.plugins.fileManager.upload.call(this,n,this.options.imageUploadHeader,s,this.plugins.image.callBack_imgUpload.bind(this,e),this.functions.onImageUploadError)}else this.plugins.image.setup_reader.call(this,t,e.anchor,e.inputWidth,e.inputHeight,e.align,e.alt,i,e.isUpdate)},callBack_imgUpload:function(e,t){if(typeof this.functions.imageUploadHandler=="function")this.functions.imageUploadHandler(t,e,this);else{const n=JSON.parse(t.responseText);n.errorMessage?this.plugins.image.error.call(this,n.errorMessage,n):this.plugins.image.register.call(this,e,n)}},register:function(e,t){const n=t.result;for(let i=0,s=n.length,o;i<s;i++)if(o={name:n[i].name,size:n[i].size},e.isUpdate){this.plugins.image.update_src.call(this,n[i].url,e.element,o);break}else this.plugins.image.create_image.call(this,n[i].url,e.anchor,e.inputWidth,e.inputHeight,e.align,o,e.alt);this.closeLoading()},setup_reader:function(e,t,n,i,s,o,l,a){try{if(l===0){this.closeLoading(),console.warn("[SUNEDITOR.image.base64.fail] cause : No applicable files");return}this.context.image.base64RenderIndex=l;const r=this._w.FileReader,f=[l];this.context.image.inputX.value=n,this.context.image.inputY.value=i;for(let d=0,h,v;d<l;d++)h=new r,v=e[d],h.onload=(function(_,C,S,c,u){f[u]={result:_.result,file:c},--this.context.image.base64RenderIndex===0&&(this.plugins.image.onRender_imgBase64.call(this,C,f,S,t,n,i,s,o),this.closeLoading())}).bind(this,h,a,this.context.image._element,v,d),h.readAsDataURL(v)}catch(r){throw this.closeLoading(),Error('[SUNEDITOR.image.setup_reader.fail] cause : "'+r.message+'"')}},onRender_imgBase64:function(e,t,n,i,s,o,l,a){const r=this.plugins.image.update_src,f=this.plugins.image.create_image;for(let d=0,h=t.length;d<h;d++)e?(this.context.image._element.setAttribute("data-file-name",t[d].file.name),this.context.image._element.setAttribute("data-file-size",t[d].file.size),r.call(this,t[d].result,n,t[d].file)):f.call(this,t[d].result,i,s,o,l,t[d].file,a)},onRender_imgUrl:function(e){if(e||(e=this.context.image._v_src._linkValue),!e)return!1;const t=this.context.image;try{const n={name:e.split("/").pop(),size:0};this.context.dialog.updateModal?this.plugins.image.update_src.call(this,e,t._element,n):this.plugins.image.create_image.call(this,e,this.plugins.anchor.createAnchor.call(this,t.anchorCtx,!0),t.inputX.value,t.inputY.value,t._align,n,t._altText)}catch(n){throw Error('[SUNEDITOR.image.URLRendering.fail] cause : "'+n.message+'"')}finally{this.closeLoading()}},onRender_link:function(e,t){return t?(t.setAttribute("data-image-link","image"),e.setAttribute("data-image-link",t.href),t.appendChild(e),t):e},setInputSize:function(e,t){if(t&&t.keyCode===32){t.preventDefault();return}this.plugins.resizing._module_setInputSize.call(this,this.context.image,e)},setRatio:function(){this.plugins.resizing._module_setRatio.call(this,this.context.image)},checkFileInfo:function(){const e=this.plugins.image,t=this.context.image,n=(function(i){e.onModifyMode.call(this,i,null),e.openModify.call(this,!0),t.inputX.value=t._origin_w,t.inputY.value=t._origin_h;const s=this.util.getFormatElement(i);s&&(t._align=s.style.textAlign||s.style.float),this.util.isAnchor(i.parentNode)&&!t.anchorCtx.linkValue&&(t.anchorCtx.linkValue=" "),e.update_image.call(this,!0,!1,!0),e.init.call(this)}).bind(this);this.plugins.fileManager.checkInfo.call(this,"image",["img"],this.functions.onImageUpload,n,!0)},resetFileInfo:function(){this.plugins.fileManager.resetInfo.call(this,"image",this.functions.onImageUpload)},create_image:function(e,t,n,i,s,o,l){const a=this.plugins.image,r=this.context.image;this.context.resizing._resize_plugin="image";let f=this.util.createElement("IMG");f.src=e,f.alt=l,f.setAttribute("data-rotate","0"),t=a.onRender_link.call(this,f,t?t.cloneNode(!1):null),r._resizing&&f.setAttribute("data-proportion",r._proportionChecked);const d=this.plugins.component.set_cover.call(this,t),h=this.plugins.component.set_container.call(this,d,"se-image-container");r._captionChecked&&(r._caption=this.plugins.component.create_caption.call(this),d.appendChild(r._caption)),r._element=f,r._cover=d,r._container=h,a.applySize.call(this,n,i),a.setAlign.call(this,s,f,d,h),f.onload=a._image_create_onload.bind(this,f,r.svgDefaultSize,h),this.insertComponent(h,!0,!0,!this.options.mediaAutoSelect)&&this.plugins.fileManager.setInfo.call(this,"image",f,this.functions.onImageUpload,o,!0),this.context.resizing._resize_plugin=""},_image_create_onload:function(e,t,n){if(e.offsetWidth===0&&this.plugins.image.applySize.call(this,t,""),this.options.mediaAutoSelect)this.selectComponent(e,"image");else{const i=this.appendFormatTag(n,null);i&&this.setRange(i,0,i,0)}this.history.push(!1)},update_image:function(e,t,n){const i=this.context.image;let s=i._element,o=i._cover,l=i._container,a=!1;o===null&&(a=!0,s=i._element.cloneNode(!0),o=this.plugins.component.set_cover.call(this,s)),l===null?(o=o.cloneNode(!0),s=o.querySelector("img"),a=!0,l=this.plugins.component.set_container.call(this,o,"se-image-container")):a&&(l.innerHTML="",l.appendChild(o),i._cover=o,i._element=s,a=!1);let r;const f=this.util.isNumber(i.inputX.value)?i.inputX.value+i.sizeUnit:i.inputX.value,d=this.util.isNumber(i.inputY.value)?i.inputY.value+i.sizeUnit:i.inputY.value;/%$/.test(s.style.width)?r=f!==l.style.width||d!==l.style.height:r=f!==s.style.width||d!==s.style.height,s.alt=i._altText;let h=!1;i._captionChecked?i._caption||(i._caption=this.plugins.component.create_caption.call(this),o.appendChild(i._caption),h=!0):i._caption&&(this.util.removeItem(i._caption),i._caption=null,h=!0);let v=null;const _=this.plugins.anchor.createAnchor.call(this,i.anchorCtx,!0);if(_)i._linkElement!==_||a&&!l.contains(_)?(i._linkElement=_.cloneNode(!1),o.insertBefore(this.plugins.image.onRender_link.call(this,s,i._linkElement),i._caption),v=i._element):i._linkElement.setAttribute("data-image-link","image");else if(i._linkElement!==null){const S=s;if(S.setAttribute("data-image-link",""),o.contains(i._linkElement)){const c=S.cloneNode(!0);o.removeChild(i._linkElement),o.insertBefore(c,i._caption),i._element=s=c}}let C=null;if(a){const S=i._element.parentNode;if(C=this.util.isRangeFormatElement(S)||this.util.isWysiwygDiv(S)?i._element:S||i._element,this.util.getParentElement(i._element,this.util.isNotCheckingNode))C=v?_:i._element,C.parentNode.replaceChild(l,C);else if(this.util.isListCell(C)){const c=this.util.getParentElement(i._element,function(u){return u.parentNode===C});C.insertBefore(l,c),this.util.removeItem(i._element),this.util.removeEmptyNode(c,null,!0)}else if(this.util.isFormatElement(C)){const c=this.util.getParentElement(i._element,function(u){return u.parentNode===C});C=this.util.splitElement(C,c),C.parentNode.insertBefore(l,C),this.util.removeItem(i._element),this.util.removeEmptyNode(C,null,!0),C.children.length===0&&(C.innerHTML=this.util.htmlRemoveWhiteSpace(C.innerHTML))}else if(this.util.isFormatElement(C.parentNode)){const c=C.parentNode;c.parentNode.insertBefore(l,C.previousSibling?c.nextElementSibling:c),i.__updateTags.map(function(u){return C.contains(u)}).length===0&&this.util.removeItem(C)}else C=this.util.isFigures(C.parentNode)?C.parentNode:C,C.parentNode.replaceChild(l,C);s=l.querySelector("img"),i._element=s,i._cover=o,i._container=l}v&&(a?(this.util.removeItem(v),this.util.getListChildren(_,function(S){return/IMG/i.test(S.tagName)}).length===0&&this.util.removeItem(_)):this.util.removeItem(_)),(h||!i._onlyPercentage&&r)&&!e&&(/\d+/.test(s.style.height)||this.context.resizing._rotateVertical&&i._captionChecked)&&(/%$/.test(i.inputX.value)||/%$/.test(i.inputY.value)?this.plugins.resizing.resetTransform.call(this,s):this.plugins.resizing.setTransformSize.call(this,s,this.util.getNumber(i.inputX.value,0),this.util.getNumber(i.inputY.value,0))),i._resizing&&(s.setAttribute("data-proportion",i._proportionChecked),r&&this.plugins.image.applySize.call(this)),this.plugins.image.setAlign.call(this,null,s,null,null),e&&this.plugins.fileManager.setInfo.call(this,"image",s,this.functions.onImageUpload,null,!0),t&&this.selectComponent(s,"image"),n||this.history.push(!1)},update_src:function(e,t,n){t.src=e,this._w.setTimeout(this.plugins.fileManager.setInfo.bind(this,"image",t,this.functions.onImageUpload,n,!0)),this.selectComponent(t,"image")},onModifyMode:function(e,t){if(!e)return;const n=this.context.image;n._linkElement=n.anchorCtx.linkAnchor=this.util.isAnchor(e.parentNode)?e.parentNode:null,n._element=e,n._cover=this.util.getParentElement(e,"FIGURE"),n._container=this.util.getParentElement(e,this.util.isMediaComponent),n._caption=this.util.getChildElement(n._cover,"FIGCAPTION"),n._align=e.getAttribute("data-align")||e.style.float||"none",e.style.float="",this.plugins.anchor.setCtx(n._linkElement,n.anchorCtx),t&&(n._element_w=t.w,n._element_h=t.h,n._element_t=t.t,n._element_l=t.l);let i=n._element.getAttribute("data-size")||n._element.getAttribute("data-origin"),s,o;i?(i=i.split(","),s=i[0],o=i[1]):t&&(s=t.w,o=t.h),n._origin_w=s||e.style.width||e.width||"",n._origin_h=o||e.style.height||e.height||""},openModify:function(e){const t=this.context.image;t.imgUrlFile&&(t._v_src._linkValue=t.previewSrc.textContent=t.imgUrlFile.value=t._element.src),t._altText=t.altText.value=t._element.alt,(t.modal.querySelector('input[name="suneditor_image_radio"][value="'+t._align+'"]')||t.modal.querySelector('input[name="suneditor_image_radio"][value="none"]')).checked=!0,t._align=t.modal.querySelector('input[name="suneditor_image_radio"]:checked').value,t._captionChecked=t.captionCheckEl.checked=!!t._caption,t._resizing&&this.plugins.resizing._module_setModifyInputSize.call(this,t,this.plugins.image),e||this.plugins.dialog.open.call(this,"image",!0)},applySize:function(e,t){const n=this.context.image;return e||(e=n.inputX.value||this.options.imageWidth),t||(t=n.inputY.value||this.options.imageHeight),n._onlyPercentage&&e||/%$/.test(e)?(this.plugins.image.setPercentSize.call(this,e,t),!0):((!e||e==="auto")&&(!t||t==="auto")?this.plugins.image.setAutoSize.call(this):this.plugins.image.setSize.call(this,e,t,!1),!1)},sizeRevert:function(){this.plugins.resizing._module_sizeRevert.call(this,this.context.image)},setSize:function(e,t,n,i){const s=this.context.image,o=/^(rw|lw)$/.test(i)&&/\d+/.test(s._element.style.height);/^(th|bh)$/.test(i)&&/\d+/.test(s._element.style.width)||(s._element.style.width=this.util.isNumber(e)?e+s.sizeUnit:e,this.plugins.image.cancelPercentAttr.call(this)),o||(s._element.style.height=this.util.isNumber(t)?t+s.sizeUnit:/%$/.test(t)?"":t),s._align==="center"&&this.plugins.image.setAlign.call(this,null,null,null,null),n||s._element.removeAttribute("data-percentage"),this.plugins.resizing._module_saveCurrentSize.call(this,s)},setAutoSize:function(){const e=this.context.image;e._caption&&(e._caption.style.marginTop=""),this.plugins.resizing.resetTransform.call(this,e._element),this.plugins.image.cancelPercentAttr.call(this),e._element.style.maxWidth="",e._element.style.width="",e._element.style.height="",e._cover.style.width="",e._cover.style.height="",this.plugins.image.setAlign.call(this,null,null,null,null),e._element.setAttribute("data-percentage","auto,auto"),this.plugins.resizing._module_saveCurrentSize.call(this,e)},setOriginSize:function(){const e=this.context.image;e._element.removeAttribute("data-percentage"),this.plugins.resizing.resetTransform.call(this,e._element),this.plugins.image.cancelPercentAttr.call(this);const t=(e._element.getAttribute("data-origin")||"").split(","),n=t[0],i=t[1];t&&(e._onlyPercentage||/%$/.test(n)&&(/%$/.test(i)||!/\d/.test(i))?this.plugins.image.setPercentSize.call(this,n,i):this.plugins.image.setSize.call(this,n,i),this.plugins.resizing._module_saveCurrentSize.call(this,e))},setPercentSize:function(e,t){const n=this.context.image;t=t&&!/%$/.test(t)&&!this.util.getNumber(t,0)?this.util.isNumber(t)?t+"%":t:this.util.isNumber(t)?t+n.sizeUnit:t||"";const i=/%$/.test(t);n._container.style.width=this.util.isNumber(e)?e+"%":e,n._container.style.height="",n._cover.style.width="100%",n._cover.style.height=i?t:"",n._element.style.width="100%",n._element.style.height=i?"":t,n._element.style.maxWidth="",n._align==="center"&&this.plugins.image.setAlign.call(this,null,null,null,null),n._element.setAttribute("data-percentage",e+","+t),this.plugins.resizing.setCaptionPosition.call(this,n._element),this.plugins.resizing._module_saveCurrentSize.call(this,n)},cancelPercentAttr:function(){const e=this.context.image;e._cover.style.width="",e._cover.style.height="",e._container.style.width="",e._container.style.height="",this.util.removeClass(e._container,this.context.image._floatClassRegExp),this.util.addClass(e._container,"__se__float-"+e._align),e._align==="center"&&this.plugins.image.setAlign.call(this,null,null,null,null)},setAlign:function(e,t,n,i){const s=this.context.image;e||(e=s._align),t||(t=s._element),n||(n=s._cover),i||(i=s._container),/%$/.test(t.style.width)&&e==="center"?(i.style.minWidth="100%",n.style.width=i.style.width):(i.style.minWidth="",n.style.width=this.context.resizing._rotateVertical?t.style.height||t.offsetHeight:!t.style.width||t.style.width==="auto"?"":t.style.width||"100%"),this.util.hasClass(i,"__se__float-"+e)||(this.util.removeClass(i,s._floatClassRegExp),this.util.addClass(i,"__se__float-"+e)),t.setAttribute("data-align",e)},init:function(){const e=this.context.image;e.imgInputFile&&(e.imgInputFile.value=""),e.imgUrlFile&&(e._v_src._linkValue=e.previewSrc.textContent=e.imgUrlFile.value=""),e.imgInputFile&&e.imgUrlFile&&(e.imgUrlFile.removeAttribute("disabled"),e.previewSrc.style.textDecoration=""),e.altText.value="",e.modal.querySelector('input[name="suneditor_image_radio"][value="none"]').checked=!0,e.captionCheckEl.checked=!1,e._element=null,this.plugins.image.openTab.call(this,"init"),e._resizing&&(e.inputX.value=this.options.imageWidth===e._defaultSizeX?"":this.options.imageWidth,e.inputY.value=this.options.imageHeight===e._defaultSizeY?"":this.options.imageHeight,e.proportion.checked=!0,e._ratio=!1,e._ratioX=1,e._ratioY=1),this.plugins.anchor.init.call(this,e.anchorCtx)}},XC={name:"video",display:"dialog",add:function(e){e.addModule([Fi,Xo,fh,Qo]);const t=e.options,n=e.context,i=n.video={_infoList:[],_infoIndex:0,_uploadFileLength:0,focusElement:null,sizeUnit:t._videoSizeUnit,_align:"none",_floatClassRegExp:"__se__float\\-[a-z]+",_youtubeQuery:t.youtubeQuery,_vimeoQuery:t.vimeoQuery,_videoRatio:t.videoRatio*100+"%",_defaultRatio:t.videoRatio*100+"%",_linkValue:"",_element:null,_cover:null,_container:null,inputX:null,inputY:null,_element_w:1,_element_h:1,_element_l:0,_element_t:0,_defaultSizeX:"100%",_defaultSizeY:t.videoRatio*100+"%",_origin_w:t.videoWidth==="100%"?"":t.videoWidth,_origin_h:t.videoHeight==="56.25%"?"":t.videoHeight,_proportionChecked:!0,_resizing:t.videoResizing,_resizeDotHide:!t.videoHeightShow,_rotation:t.videoRotation,_alignHide:!t.videoAlignShow,_onlyPercentage:t.videoSizeOnlyPercentage,_ratio:!1,_ratioX:1,_ratioY:1,_captionShow:!1};let s=this.setDialog(e);i.modal=s,i.videoInputFile=s.querySelector("._se_video_file"),i.videoUrlFile=s.querySelector(".se-input-url"),i.focusElement=i.videoUrlFile||i.videoInputFile,i.preview=s.querySelector(".se-link-preview"),s.querySelector("form").addEventListener("submit",this.submit.bind(e)),i.videoInputFile&&s.querySelector(".se-dialog-files-edge-button").addEventListener("click",this._removeSelectedFiles.bind(i.videoInputFile,i.videoUrlFile,i.preview)),i.videoInputFile&&i.videoUrlFile&&i.videoInputFile.addEventListener("change",this._fileInputChange.bind(i)),i.videoUrlFile&&i.videoUrlFile.addEventListener("input",this._onLinkPreview.bind(i.preview,i,t.linkProtocol)),i.proportion={},i.videoRatioOption={},i.inputX={},i.inputY={},t.videoResizing&&(i.proportion=s.querySelector("._se_video_check_proportion"),i.videoRatioOption=s.querySelector(".se-video-ratio"),i.inputX=s.querySelector("._se_video_size_x"),i.inputY=s.querySelector("._se_video_size_y"),i.inputX.value=t.videoWidth,i.inputY.value=t.videoHeight,i.inputX.addEventListener("keyup",this.setInputSize.bind(e,"x")),i.inputY.addEventListener("keyup",this.setInputSize.bind(e,"y")),i.inputX.addEventListener("change",this.setRatio.bind(e)),i.inputY.addEventListener("change",this.setRatio.bind(e)),i.proportion.addEventListener("change",this.setRatio.bind(e)),i.videoRatioOption.addEventListener("change",this.setVideoRatio.bind(e)),s.querySelector(".se-dialog-btn-revert").addEventListener("click",this.sizeRevert.bind(e))),n.dialog.modal.appendChild(s),s=null},setDialog:function(e){const t=e.options,n=e.lang,i=e.util.createElement("DIV");i.className="se-dialog-content",i.style.display="none";let s='<form method="post" enctype="multipart/form-data"><div class="se-dialog-header"><button type="button" data-command="close" class="se-btn se-dialog-close" title="'+n.dialogBox.close+'" aria-label="'+n.dialogBox.close+'">'+e.icons.cancel+'</button><span class="se-modal-title">'+n.dialogBox.videoBox.title+'</span></div><div class="se-dialog-body">';if(t.videoFileInput&&(s+='<div class="se-dialog-form"><label>'+n.dialogBox.videoBox.file+'</label><div class="se-dialog-form-files"><input class="se-input-form _se_video_file" type="file" accept="'+t.videoAccept+'"'+(t.videoMultipleFile?' multiple="multiple"':"")+'/><button type="button" data-command="filesRemove" class="se-btn se-dialog-files-edge-button se-file-remove" title="'+n.controller.remove+'" aria-label="'+n.controller.remove+'">'+e.icons.cancel+"</button></div></div>"),t.videoUrlInput&&(s+='<div class="se-dialog-form"><label>'+n.dialogBox.videoBox.url+'</label><input class="se-input-form se-input-url" type="text" /><pre class="se-link-preview"></pre></div>'),t.videoResizing){const o=t.videoRatioList||[{name:"16:9",value:.5625},{name:"4:3",value:.75},{name:"21:9",value:.4285}],l=t.videoRatio,a=t.videoSizeOnlyPercentage,r=a?' style="display: none !important;"':"",f=t.videoHeightShow?"":' style="display: none !important;"',d=t.videoRatioShow?"":' style="display: none !important;"',h=!a&&!t.videoHeightShow&&!t.videoRatioShow?' style="display: none !important;"':"";s+='<div class="se-dialog-form"><div class="se-dialog-size-text"><label class="size-w">'+n.dialogBox.width+'</label><label class="se-dialog-size-x">&nbsp;</label><label class="size-h"'+f+">"+n.dialogBox.height+'</label><label class="size-h"'+d+">("+n.dialogBox.ratio+')</label></div><input class="se-input-control _se_video_size_x" placeholder="100%"'+(a?' type="number" min="1"':'type="text"')+(a?' max="100"':"")+'/><label class="se-dialog-size-x"'+h+">"+(a?"%":"x")+'</label><input class="se-input-control _se_video_size_y" placeholder="'+t.videoRatio*100+'%"'+(a?' type="number" min="1"':'type="text"')+(a?' max="100"':"")+f+'/><select class="se-input-select se-video-ratio" title="'+n.dialogBox.ratio+'" aria-label="'+n.dialogBox.ratio+'"'+d+">",f||(s+='<option value=""> - </option>');for(let v=0,_=o.length;v<_;v++)s+='<option value="'+o[v].value+'"'+(l.toString()===o[v].value.toString()?" selected":"")+">"+o[v].name+"</option>";s+='</select><button type="button" title="'+n.dialogBox.revertButton+'" aria-label="'+n.dialogBox.revertButton+'" class="se-btn se-dialog-btn-revert" style="float: right;">'+e.icons.revert+'</button></div><div class="se-dialog-form se-dialog-form-footer"'+r+h+'><label><input type="checkbox" class="se-dialog-btn-check _se_video_check_proportion" checked/>&nbsp;'+n.dialogBox.proportion+"</label></div>"}return s+='</div><div class="se-dialog-footer"><div'+(t.videoAlignShow?"":' style="display: none"')+'><label><input type="radio" name="suneditor_video_radio" class="se-dialog-btn-radio" value="none" checked>'+n.dialogBox.basic+'</label><label><input type="radio" name="suneditor_video_radio" class="se-dialog-btn-radio" value="left">'+n.dialogBox.left+'</label><label><input type="radio" name="suneditor_video_radio" class="se-dialog-btn-radio" value="center">'+n.dialogBox.center+'</label><label><input type="radio" name="suneditor_video_radio" class="se-dialog-btn-radio" value="right">'+n.dialogBox.right+'</label></div><button type="submit" class="se-btn-primary" title="'+n.dialogBox.submitButton+'" aria-label="'+n.dialogBox.submitButton+'"><span>'+n.dialogBox.submitButton+"</span></button></div></form>",i.innerHTML=s,i},_fileInputChange:function(){this.videoInputFile.value?(this.videoUrlFile.setAttribute("disabled",!0),this.preview.style.textDecoration="line-through"):(this.videoUrlFile.removeAttribute("disabled"),this.preview.style.textDecoration="")},_removeSelectedFiles:function(e,t){this.value="",e&&(e.removeAttribute("disabled"),t.style.textDecoration="")},_onLinkPreview:function(e,t,n){const i=n.target.value.trim();/^<iframe.*\/iframe>$/.test(i)?(e._linkValue=i,this.textContent='<IFrame :src=".."></IFrame>'):e._linkValue=this.textContent=i?t&&i.indexOf("://")===-1&&i.indexOf("#")!==0?t+i:i.indexOf("://")===-1?"/"+i:i:""},_setTagAttrs:function(e){e.setAttribute("controls",!0);const t=this.options.videoTagAttrs;if(t)for(let n in t)this.util.hasOwn(t,n)&&e.setAttribute(n,t[n])},createVideoTag:function(){const e=this.util.createElement("VIDEO");return this.plugins.video._setTagAttrs.call(this,e),e},_setIframeAttrs:function(e){e.frameBorder="0",e.allowFullscreen=!0;const t=this.options.videoIframeAttrs;if(t)for(let n in t)this.util.hasOwn(t,n)&&e.setAttribute(n,t[n])},createIframeTag:function(){const e=this.util.createElement("IFRAME");return this.plugins.video._setIframeAttrs.call(this,e),e},fileTags:["iframe","video"],select:function(e){this.plugins.video.onModifyMode.call(this,e,this.plugins.resizing.call_controller_resize.call(this,e,"video"))},destroy:function(e){const t=e||this.context.video._element,n=this.context.video._container,i=t.getAttribute("data-index")*1;if(typeof this.functions.onVideoDeleteBefore=="function"&&this.functions.onVideoDeleteBefore(t,n,i,this)===!1)return;let s=n.previousElementSibling||n.nextElementSibling;const o=n.parentNode;this.util.removeItem(n),this.plugins.video.init.call(this),this.controllersOff(),o!==this.context.element.wysiwyg&&this.util.removeItemAllParents(o,function(l){return l.childNodes.length===0},null),this.focusEdge(s),this.plugins.fileManager.deleteInfo.call(this,"video",i,this.functions.onVideoUpload),this.history.push(!1)},on:function(e){const t=this.context.video;e?t.videoInputFile&&this.options.videoMultipleFile&&t.videoInputFile.removeAttribute("multiple"):(t.inputX.value=t._origin_w=this.options.videoWidth===t._defaultSizeX?"":this.options.videoWidth,t.inputY.value=t._origin_h=this.options.videoHeight===t._defaultSizeY?"":this.options.videoHeight,t.proportion.disabled=!0,t.videoInputFile&&this.options.videoMultipleFile&&t.videoInputFile.setAttribute("multiple","multiple")),t._resizing&&this.plugins.video.setVideoRatioSelect.call(this,t._origin_h||t._defaultRatio)},open:function(){this.plugins.dialog.open.call(this,"video",this.currentControllerName==="video")},setVideoRatio:function(e){const t=this.context.video,n=e.target.options[e.target.selectedIndex].value;t._defaultSizeY=t._videoRatio=n?n*100+"%":t._defaultSizeY,t.inputY.placeholder=n?n*100+"%":"",t.inputY.value=""},setInputSize:function(e,t){if(t&&t.keyCode===32){t.preventDefault();return}const n=this.context.video;this.plugins.resizing._module_setInputSize.call(this,n,e),e==="y"&&this.plugins.video.setVideoRatioSelect.call(this,t.target.value||n._defaultRatio)},setRatio:function(){this.plugins.resizing._module_setRatio.call(this,this.context.video)},submit:function(e){const t=this.context.video,n=this.plugins.video;e.preventDefault(),e.stopPropagation(),t._align=t.modal.querySelector('input[name="suneditor_video_radio"]:checked').value;try{t.videoInputFile&&t.videoInputFile.files.length>0?(this.showLoading(),n.submitAction.call(this,this.context.video.videoInputFile.files)):t.videoUrlFile&&t._linkValue.length>0&&(this.showLoading(),n.setup_url.call(this,t._linkValue))}catch(i){throw this.closeLoading(),Error('[SUNEDITOR.video.submit.fail] cause : "'+i.message+'"')}finally{this.plugins.dialog.close.call(this)}return!1},submitAction:function(e){if(e.length===0)return;let t=0,n=[];for(let l=0,a=e.length;l<a;l++)/video/i.test(e[l].type)&&(n.push(e[l]),t+=e[l].size);const i=this.options.videoUploadSizeLimit;if(i>0){let l=0;const a=this.context.video._infoList;for(let r=0,f=a.length;r<f;r++)l+=a[r].size*1;if(t+l>i){this.closeLoading();const r="[SUNEDITOR.videoUpload.fail] Size of uploadable total videos: "+i/1e3+"KB";(typeof this.functions.onVideoUploadError!="function"||this.functions.onVideoUploadError(r,{limitSize:i,currentSize:l,uploadSize:t},this))&&this.functions.noticeOpen(r);return}}const s=this.context.video;s._uploadFileLength=n.length;const o={inputWidth:s.inputX.value,inputHeight:s.inputY.value,align:s._align,isUpdate:this.context.dialog.updateModal,element:s._element};if(typeof this.functions.onVideoUploadBefore=="function"){const l=this.functions.onVideoUploadBefore(n,o,this,(function(a){a&&this._w.Array.isArray(a.result)?this.plugins.video.register.call(this,o,a):this.plugins.video.upload.call(this,o,a)}).bind(this));if(typeof l>"u")return;if(!l){this.closeLoading();return}typeof l=="object"&&l.length>0&&(n=l)}this.plugins.video.upload.call(this,o,n)},error:function(e,t){if(this.closeLoading(),typeof this.functions.onVideoUploadError!="function"||this.functions.onVideoUploadError(e,t,this))throw this.functions.noticeOpen(e),Error("[SUNEDITOR.plugin.video.error] response: "+e)},upload:function(e,t){if(!t){this.closeLoading();return}if(typeof t=="string"){this.plugins.video.error.call(this,t,null);return}const n=this.options.videoUploadUrl,i=this.context.dialog.updateModal?1:t.length;if(typeof n=="string"&&n.length>0){const s=new FormData;for(let o=0;o<i;o++)s.append("file-"+o,t[o]);this.plugins.fileManager.upload.call(this,n,this.options.videoUploadHeader,s,this.plugins.video.callBack_videoUpload.bind(this,e),this.functions.onVideoUploadError)}else throw Error('[SUNEDITOR.videoUpload.fail] cause : There is no "videoUploadUrl" option.')},callBack_videoUpload:function(e,t){if(typeof this.functions.videoUploadHandler=="function")this.functions.videoUploadHandler(t,e,this);else{const n=JSON.parse(t.responseText);n.errorMessage?this.plugins.video.error.call(this,n.errorMessage,n):this.plugins.video.register.call(this,e,n)}},register:function(e,t){const n=t.result,i=this.plugins.video.createVideoTag.call(this);for(let s=0,o=n.length,l;s<o;s++)l={name:n[s].name,size:n[s].size},this.plugins.video.create_video.call(this,e.isUpdate?e.element:i.cloneNode(!1),n[s].url,e.inputWidth,e.inputHeight,e.align,l,e.isUpdate);this.closeLoading()},setup_url:function(e){try{const t=this.context.video;if(e||(e=t._linkValue),!e||/^<iframe.*\/iframe>$/.test(e)&&(e=new this._w.DOMParser().parseFromString(e,"text/html").querySelector("iframe").src,e.length===0))return!1;if(/youtu\.?be/.test(e)){if(/^http/.test(e)||(e="https://"+e),e=e.replace("watch?v=",""),/^\/\/.+\/embed\//.test(e)||(e=e.replace(e.match(/\/\/.+\//)[0],"//www.youtube.com/embed/").replace("&","?&")),t._youtubeQuery.length>0)if(/\?/.test(e)){const n=e.split("?");e=n[0]+"?"+t._youtubeQuery+"&"+n[1]}else e+="?"+t._youtubeQuery}else if(/vimeo\.com/.test(e)&&(e.endsWith("/")&&(e=e.slice(0,-1)),e="https://player.vimeo.com/video/"+e.slice(e.lastIndexOf("/")+1),t._vimeoQuery.length>0))if(/\?/.test(e)){const n=e.split("?");e=n[0]+"?"+t._vimeoQuery+"&"+n[1]}else e+="?"+t._vimeoQuery;this.plugins.video.create_video.call(this,this.plugins.video[!/embed|iframe|player|\/e\/|\.php|\.html?/.test(e)&&!/vimeo\.com/.test(e)?"createVideoTag":"createIframeTag"].call(this),e,t.inputX.value,t.inputY.value,t._align,null,this.context.dialog.updateModal)}catch(t){throw Error('[SUNEDITOR.video.upload.fail] cause : "'+t.message+'"')}finally{this.closeLoading()}},create_video:function(e,t,n,i,s,o,l){this.context.resizing._resize_plugin="video";const a=this.context.video;let r=null,f=null,d=!1;if(l){if(e=a._element,e.src!==t){d=!0;const S=/youtu\.?be/.test(t),c=/vimeo\.com/.test(t);if((S||c)&&!/^iframe$/i.test(e.nodeName)){const u=this.plugins.video.createIframeTag.call(this);u.src=t,e.parentNode.replaceChild(u,e),a._element=e=u}else if(!S&&!c&&!/^video$/i.test(e.nodeName)){const u=this.plugins.video.createVideoTag.call(this);u.src=t,e.parentNode.replaceChild(u,e),a._element=e=u}else e.src=t}f=a._container,r=this.util.getParentElement(e,"FIGURE")}else d=!0,e.src=t,a._element=e,r=this.plugins.component.set_cover.call(this,e),f=this.plugins.component.set_container.call(this,r,"se-video-container");a._cover=r,a._container=f;const h=this.plugins.resizing._module_getSizeX.call(this,a)!==(n||a._defaultSizeX)||this.plugins.resizing._module_getSizeY.call(this,a)!==(i||a._videoRatio),v=!l||h;a._resizing&&(this.context.video._proportionChecked=a.proportion.checked,e.setAttribute("data-proportion",a._proportionChecked));let _=!1;v&&(_=this.plugins.video.applySize.call(this)),_&&s==="center"||this.plugins.video.setAlign.call(this,null,e,r,f);let C=!0;if(l)a._resizing&&this.context.resizing._rotateVertical&&v&&this.plugins.resizing.setTransformSize.call(this,e,null,null);else if(C=this.insertComponent(f,!1,!0,!this.options.mediaAutoSelect),!this.options.mediaAutoSelect){const S=this.appendFormatTag(f,null);S&&this.setRange(S,0,S,0)}C&&(d&&this.plugins.fileManager.setInfo.call(this,"video",e,this.functions.onVideoUpload,o,!0),l&&(this.selectComponent(e,"video"),this.history.push(!1))),this.context.resizing._resize_plugin=""},_update_videoCover:function(e){if(!e)return;const t=this.context.video;/^video$/i.test(e.nodeName)?this.plugins.video._setTagAttrs.call(this,e):this.plugins.video._setIframeAttrs.call(this,e);const n=e.parentNode;let i=this.util.isRangeFormatElement(n)||this.util.isWysiwygDiv(n)?e:n||e;const s=e;t._element=e=e.cloneNode(!0);const o=t._cover=this.plugins.component.set_cover.call(this,e),l=t._container=this.plugins.component.set_container.call(this,o,"se-video-container");try{const a=i.querySelector("figcaption");let r=null;a&&(r=this.util.createElement("DIV"),r.innerHTML=a.innerHTML,this.util.removeItem(a));const f=(e.getAttribute("data-size")||e.getAttribute("data-origin")||"").split(",");this.plugins.video.applySize.call(this,f[0]||s.style.width||s.width||"",f[1]||s.style.height||s.height||"");const d=this.util.getFormatElement(s);if(d&&(t._align=d.style.textAlign||d.style.float),this.plugins.video.setAlign.call(this,null,e,o,l),this.util.getParentElement(s,this.util.isNotCheckingNode))s.parentNode.replaceChild(l,s);else if(this.util.isListCell(i)){const h=this.util.getParentElement(s,function(v){return v.parentNode===i});i.insertBefore(l,h),this.util.removeItem(s),this.util.removeEmptyNode(h,null,!0)}else if(this.util.isFormatElement(i)){const h=this.util.getParentElement(s,function(v){return v.parentNode===i});i=this.util.splitElement(i,h),i.parentNode.insertBefore(l,i),this.util.removeItem(s),this.util.removeEmptyNode(i,null,!0),i.children.length===0&&(i.innerHTML=this.util.htmlRemoveWhiteSpace(i.innerHTML))}else i.parentNode.replaceChild(l,i);r&&i.parentNode.insertBefore(r,l.nextElementSibling)}catch(a){console.warn("[SUNEDITOR.video.error] Maybe the video tag is nested.",a)}this.plugins.fileManager.setInfo.call(this,"video",e,this.functions.onVideoUpload,null,!0),this.plugins.video.init.call(this)},onModifyMode:function(e,t){const n=this.context.video;n._element=e,n._cover=this.util.getParentElement(e,"FIGURE"),n._container=this.util.getParentElement(e,this.util.isMediaComponent),n._align=e.style.float||e.getAttribute("data-align")||"none",e.style.float="",t&&(n._element_w=t.w,n._element_h=t.h,n._element_t=t.t,n._element_l=t.l);let i=n._element.getAttribute("data-size")||n._element.getAttribute("data-origin"),s,o;i?(i=i.split(","),s=i[0],o=i[1]):t&&(s=t.w,o=t.h),n._origin_w=s||e.style.width||e.width||"",n._origin_h=o||e.style.height||e.height||""},openModify:function(e){const t=this.context.video;if(t.videoUrlFile&&(t._linkValue=t.preview.textContent=t.videoUrlFile.value=t._element.src||(t._element.querySelector("source")||"").src||""),(t.modal.querySelector('input[name="suneditor_video_radio"][value="'+t._align+'"]')||t.modal.querySelector('input[name="suneditor_video_radio"][value="none"]')).checked=!0,t._resizing){this.plugins.resizing._module_setModifyInputSize.call(this,t,this.plugins.video);const n=t._videoRatio=this.plugins.resizing._module_getSizeY.call(this,t);this.plugins.video.setVideoRatioSelect.call(this,n)||(t.inputY.value=t._onlyPercentage?this.util.getNumber(n,2):n)}e||this.plugins.dialog.open.call(this,"video",!0)},setVideoRatioSelect:function(e){let t=!1;const n=this.context.video,i=n.videoRatioOption.options;/%$/.test(e)||n._onlyPercentage?e=this.util.getNumber(e,2)/100+"":(!this.util.isNumber(e)||e*1>=1)&&(e=""),n.inputY.placeholder="";for(let s=0,o=i.length;s<o;s++)i[s].value===e?(t=i[s].selected=!0,n.inputY.placeholder=e?e*100+"%":""):i[s].selected=!1;return t},checkFileInfo:function(){this.plugins.fileManager.checkInfo.call(this,"video",["iframe","video"],this.functions.onVideoUpload,this.plugins.video._update_videoCover.bind(this),!0)},resetFileInfo:function(){this.plugins.fileManager.resetInfo.call(this,"video",this.functions.onVideoUpload)},applySize:function(e,t){const n=this.context.video;return e||(e=n.inputX.value||this.options.videoWidth),t||(t=n.inputY.value||this.options.videoHeight),n._onlyPercentage||/%$/.test(e)||!e?(this.plugins.video.setPercentSize.call(this,e||"100%",t||(/%$/.test(n._videoRatio)?n._videoRatio:n._defaultRatio)),!0):((!e||e==="auto")&&(!t||t==="auto")?this.plugins.video.setAutoSize.call(this):this.plugins.video.setSize.call(this,e,t||n._videoRatio||n._defaultRatio,!1),!1)},sizeRevert:function(){this.plugins.resizing._module_sizeRevert.call(this,this.context.video)},setSize:function(e,t,n,i){const s=this.context.video,o=/^(rw|lw)$/.test(i),l=/^(th|bh)$/.test(i);l||(e=this.util.getNumber(e,0)),o||(t=this.util.isNumber(t)?t+s.sizeUnit:t||""),e=e?e+s.sizeUnit:"",l||(s._element.style.width=e),o||(s._cover.style.paddingBottom=s._cover.style.height=t),!l&&!/%$/.test(e)&&(s._cover.style.width=e,s._container.style.width=""),!o&&!/%$/.test(t)?s._element.style.height=t:s._element.style.height="",n||s._element.removeAttribute("data-percentage"),this.plugins.resizing._module_saveCurrentSize.call(this,s)},setAutoSize:function(){this.plugins.video.setPercentSize.call(this,100,this.context.video._defaultRatio)},setOriginSize:function(e){const t=this.context.video;t._element.removeAttribute("data-percentage"),this.plugins.resizing.resetTransform.call(this,t._element),this.plugins.video.cancelPercentAttr.call(this);const n=((e?t._element.getAttribute("data-size"):"")||t._element.getAttribute("data-origin")||"").split(",");if(n){const i=n[0],s=n[1];t._onlyPercentage||/%$/.test(i)&&(/%$/.test(s)||!/\d/.test(s))?this.plugins.video.setPercentSize.call(this,i,s):this.plugins.video.setSize.call(this,i,s),this.plugins.resizing._module_saveCurrentSize.call(this,t)}},setPercentSize:function(e,t){const n=this.context.video;t=t&&!/%$/.test(t)&&!this.util.getNumber(t,0)?this.util.isNumber(t)?t+"%":t:this.util.isNumber(t)?t+n.sizeUnit:t||n._defaultRatio,n._container.style.width=this.util.isNumber(e)?e+"%":e,n._container.style.height="",n._cover.style.width="100%",n._cover.style.height=t,n._cover.style.paddingBottom=t,n._element.style.width="100%",n._element.style.height="100%",n._element.style.maxWidth="",n._align==="center"&&this.plugins.video.setAlign.call(this,null,null,null,null),n._element.setAttribute("data-percentage",e+","+t),this.plugins.resizing._module_saveCurrentSize.call(this,n)},cancelPercentAttr:function(){const e=this.context.video;e._cover.style.width="",e._cover.style.height="",e._cover.style.paddingBottom="",e._container.style.width="",e._container.style.height="",this.util.removeClass(e._container,this.context.video._floatClassRegExp),this.util.addClass(e._container,"__se__float-"+e._align),e._align==="center"&&this.plugins.video.setAlign.call(this,null,null,null,null)},setAlign:function(e,t,n,i){const s=this.context.video;e||(e=s._align),t||(t=s._element),n||(n=s._cover),i||(i=s._container),/%$/.test(t.style.width)&&e==="center"?(i.style.minWidth="100%",n.style.width=i.style.width,n.style.height=n.style.height,n.style.paddingBottom=/%$/.test(n.style.height)?this.util.getNumber(this.util.getNumber(n.style.height,2)/100*this.util.getNumber(n.style.width,2),2)+"%":n.style.height):(i.style.minWidth="",n.style.width=this.context.resizing._rotateVertical?t.style.height||t.offsetHeight:t.style.width||"100%",n.style.paddingBottom=n.style.height),this.util.hasClass(i,"__se__float-"+e)||(this.util.removeClass(i,s._floatClassRegExp),this.util.addClass(i,"__se__float-"+e)),t.setAttribute("data-align",e)},init:function(){const e=this.context.video;e.videoInputFile&&(e.videoInputFile.value=""),e.videoUrlFile&&(e._linkValue=e.preview.textContent=e.videoUrlFile.value=""),e.videoInputFile&&e.videoUrlFile&&(e.videoUrlFile.removeAttribute("disabled"),e.preview.style.textDecoration=""),e._origin_w=this.options.videoWidth,e._origin_h=this.options.videoHeight,e.modal.querySelector('input[name="suneditor_video_radio"][value="none"]').checked=!0,e._resizing&&(e.inputX.value=this.options.videoWidth===e._defaultSizeX?"":this.options.videoWidth,e.inputY.value=this.options.videoHeight===e._defaultSizeY?"":this.options.videoHeight,e.proportion.checked=!0,e.proportion.disabled=!0,this.plugins.video.setVideoRatioSelect.call(this,e._defaultRatio))}},QC={name:"audio",display:"dialog",add:function(e){e.addModule([Fi,Xo,Qo]);const t=e.context,n=t.audio={_infoList:[],_infoIndex:0,_uploadFileLength:0,focusElement:null,targetSelect:null,_origin_w:e.options.audioWidth,_origin_h:e.options.audioHeight,_linkValue:"",_element:null,_cover:null,_container:null};let i=this.setDialog(e);n.modal=i,n.audioInputFile=i.querySelector("._se_audio_files"),n.audioUrlFile=i.querySelector(".se-input-url"),n.focusElement=n.audioInputFile||n.audioUrlFile,n.preview=i.querySelector(".se-link-preview");let s=this.setController(e);n.controller=s,i.querySelector("form").addEventListener("submit",this.submit.bind(e)),n.audioInputFile&&i.querySelector(".se-dialog-files-edge-button").addEventListener("click",this._removeSelectedFiles.bind(n.audioInputFile,n.audioUrlFile,n.preview)),n.audioInputFile&&n.audioUrlFile&&n.audioInputFile.addEventListener("change",this._fileInputChange.bind(n)),s.addEventListener("click",this.onClick_controller.bind(e)),n.audioUrlFile&&n.audioUrlFile.addEventListener("input",this._onLinkPreview.bind(n.preview,n,e.options.linkProtocol)),t.dialog.modal.appendChild(i),t.element.relative.appendChild(s),i=null,s=null},setDialog:function(e){const t=e.options,n=e.lang,i=e.util.createElement("DIV");i.className="se-dialog-content",i.style.display="none";let s='<form method="post" enctype="multipart/form-data"><div class="se-dialog-header"><button type="button" data-command="close" class="se-btn se-dialog-close" title="'+n.dialogBox.close+'" aria-label="'+n.dialogBox.close+'">'+e.icons.cancel+'</button><span class="se-modal-title">'+n.dialogBox.audioBox.title+'</span></div><div class="se-dialog-body">';return t.audioFileInput&&(s+='<div class="se-dialog-form"><label>'+n.dialogBox.audioBox.file+'</label><div class="se-dialog-form-files"><input class="se-input-form _se_audio_files" type="file" accept="'+t.audioAccept+'"'+(t.audioMultipleFile?' multiple="multiple"':"")+'/><button type="button" data-command="filesRemove" class="se-btn se-dialog-files-edge-button se-file-remove" title="'+n.controller.remove+'" aria-label="'+n.controller.remove+'">'+e.icons.cancel+"</button></div></div>"),t.audioUrlInput&&(s+='<div class="se-dialog-form"><label>'+n.dialogBox.audioBox.url+'</label><input class="se-input-form se-input-url" type="text" /><pre class="se-link-preview"></pre></div>'),s+='</div><div class="se-dialog-footer"><button type="submit" class="se-btn-primary" title="'+n.dialogBox.submitButton+'" aria-label="'+n.dialogBox.submitButton+'"><span>'+n.dialogBox.submitButton+"</span></button></div></form>",i.innerHTML=s,i},setController:function(e){const t=e.lang,n=e.icons,i=e.util.createElement("DIV");return i.className="se-controller se-controller-link",i.innerHTML='<div class="se-arrow se-arrow-up"></div><div class="link-content"><div class="se-btn-group"><button type="button" data-command="update" tabindex="-1" class="se-tooltip">'+n.edit+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+t.controller.edit+'</span></span></button><button type="button" data-command="delete" tabindex="-1" class="se-tooltip">'+n.delete+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+t.controller.remove+"</span></span></button></div></div>",i},_fileInputChange:function(){this.audioInputFile.value?(this.audioUrlFile.setAttribute("disabled",!0),this.preview.style.textDecoration="line-through"):(this.audioUrlFile.removeAttribute("disabled"),this.preview.style.textDecoration="")},_removeSelectedFiles:function(e,t){this.value="",e&&(e.removeAttribute("disabled"),t.style.textDecoration="")},_createAudioTag:function(){const e=this.util.createElement("AUDIO");this.plugins.audio._setTagAttrs.call(this,e);const t=this.context.audio._origin_w,n=this.context.audio._origin_h;return e.setAttribute("origin-size",t+","+n),e.style.cssText=(t?"width:"+t+"; ":"")+(n?"height:"+n+";":""),e},_setTagAttrs:function(e){e.setAttribute("controls",!0);const t=this.options.audioTagAttrs;if(t)for(let n in t)this.util.hasOwn(t,n)&&e.setAttribute(n,t[n])},_onLinkPreview:function(e,t,n){const i=n.target.value.trim();e._linkValue=this.textContent=i?t&&i.indexOf("://")===-1&&i.indexOf("#")!==0?t+i:i.indexOf("://")===-1?"/"+i:i:""},fileTags:["audio"],select:function(e){this.plugins.audio.onModifyMode.call(this,e)},destroy:function(e){e=e||this.context.audio._element;const t=this.util.getParentElement(e,this.util.isComponent)||e,n=e.getAttribute("data-index")*1;if(typeof this.functions.onAudioDeleteBefore=="function"&&this.functions.onAudioDeleteBefore(e,t,n,this)===!1)return;const i=t.previousElementSibling||t.nextElementSibling,s=t.parentNode;this.util.removeItem(t),this.plugins.audio.init.call(this),this.controllersOff(),s!==this.context.element.wysiwyg&&this.util.removeItemAllParents(s,function(o){return o.childNodes.length===0},null),this.focusEdge(i),this.plugins.fileManager.deleteInfo.call(this,"audio",n,this.functions.onAudioUpload),this.history.push(!1)},checkFileInfo:function(){this.plugins.fileManager.checkInfo.call(this,"audio",["audio"],this.functions.onAudioUpload,this.plugins.audio.updateCover.bind(this),!1)},resetFileInfo:function(){this.plugins.fileManager.resetInfo.call(this,"audio",this.functions.onAudioUpload)},on:function(e){const t=this.context.audio;e?t._element?(this.context.dialog.updateModal=!0,t._linkValue=t.preview.textContent=t.audioUrlFile.value=t._element.src,t.audioInputFile&&this.options.audioMultipleFile&&t.audioInputFile.removeAttribute("multiple")):t.audioInputFile&&this.options.audioMultipleFile&&t.audioInputFile.removeAttribute("multiple"):(this.plugins.audio.init.call(this),t.audioInputFile&&this.options.audioMultipleFile&&t.audioInputFile.setAttribute("multiple","multiple"))},open:function(){this.plugins.dialog.open.call(this,"audio",this.currentControllerName==="audio")},submit:function(e){const t=this.context.audio;e.preventDefault(),e.stopPropagation();try{t.audioInputFile&&t.audioInputFile.files.length>0?(this.showLoading(),this.plugins.audio.submitAction.call(this,t.audioInputFile.files)):t.audioUrlFile&&t._linkValue.length>0&&(this.showLoading(),this.plugins.audio.setupUrl.call(this,t._linkValue))}catch(n){throw this.closeLoading(),Error('[SUNEDITOR.audio.submit.fail] cause : "'+n.message+'"')}finally{this.plugins.dialog.close.call(this)}return!1},submitAction:function(e){if(e.length===0)return;let t=0,n=[];for(let l=0,a=e.length;l<a;l++)/audio/i.test(e[l].type)&&(n.push(e[l]),t+=e[l].size);const i=this.options.audioUploadSizeLimit;if(i>0){let l=0;const a=this.context.audio._infoList;for(let r=0,f=a.length;r<f;r++)l+=a[r].size*1;if(t+l>i){this.closeLoading();const r="[SUNEDITOR.audioUpload.fail] Size of uploadable total audios: "+i/1e3+"KB";(typeof this.functions.onAudioUploadError!="function"||this.functions.onAudioUploadError(r,{limitSize:i,currentSize:l,uploadSize:t},this))&&this.functions.noticeOpen(r);return}}const s=this.context.audio;s._uploadFileLength=n.length;const o={isUpdate:this.context.dialog.updateModal,element:s._element};if(typeof this.functions.onAudioUploadBefore=="function"){const l=this.functions.onAudioUploadBefore(n,o,this,(function(a){a&&this._w.Array.isArray(a.result)?this.plugins.audio.register.call(this,o,a):this.plugins.audio.upload.call(this,o,a)}).bind(this));if(typeof l>"u")return;if(!l){this.closeLoading();return}typeof l=="object"&&l.length>0&&(n=l)}this.plugins.audio.upload.call(this,o,n)},error:function(e,t){if(this.closeLoading(),typeof this.functions.onAudioUploadError!="function"||this.functions.onAudioUploadError(e,t,this))throw this.functions.noticeOpen(e),Error("[SUNEDITOR.plugin.audio.exception] response: "+e)},upload:function(e,t){if(!t){this.closeLoading();return}if(typeof t=="string"){this.plugins.audio.error.call(this,t,null);return}const n=this.options.audioUploadUrl,i=this.context.dialog.updateModal?1:t.length,s=new FormData;for(let o=0;o<i;o++)s.append("file-"+o,t[o]);this.plugins.fileManager.upload.call(this,n,this.options.audioUploadHeader,s,this.plugins.audio.callBack_upload.bind(this,e),this.functions.onAudioUploadError)},callBack_upload:function(e,t){if(typeof this.functions.audioUploadHandler=="function")this.functions.audioUploadHandler(t,e,this);else{const n=JSON.parse(t.responseText);n.errorMessage?this.plugins.audio.error.call(this,n.errorMessage,n):this.plugins.audio.register.call(this,e,n)}},register:function(e,t){const n=t.result;for(let i=0,s=n.length,o,l;i<s;i++)e.isUpdate?l=e.element:l=this.plugins.audio._createAudioTag.call(this),o={name:n[i].name,size:n[i].size},this.plugins.audio.create_audio.call(this,l,n[i].url,o,e.isUpdate);this.closeLoading()},setupUrl:function(e){try{if(e.length===0)return!1;this.plugins.audio.create_audio.call(this,this.plugins.audio._createAudioTag.call(this),e,null,this.context.dialog.updateModal)}catch(t){throw Error('[SUNEDITOR.audio.audio.fail] cause : "'+t.message+'"')}finally{this.closeLoading()}},create_audio:function(e,t,n,i){const s=this.context.audio;if(i)if(s._element&&(e=s._element),e&&e.src!==t)e.src=t,this.selectComponent(e,"audio");else{this.selectComponent(e,"audio");return}else{e.src=t;const o=this.plugins.component.set_cover.call(this,e),l=this.plugins.component.set_container.call(this,o,"");if(!this.insertComponent(l,!1,!0,!this.options.mediaAutoSelect)){this.focus();return}if(!this.options.mediaAutoSelect){const a=this.appendFormatTag(l,null);a&&this.setRange(a,0,a,0)}}this.plugins.fileManager.setInfo.call(this,"audio",e,this.functions.onAudioUpload,n,!1),i&&this.history.push(!1)},updateCover:function(e){const t=this.context.audio;this.plugins.audio._setTagAttrs.call(this,e);const n=e.parentNode;let i=this.util.isRangeFormatElement(n)||this.util.isWysiwygDiv(n)?e:n||e;const s=e;t._element=e=e.cloneNode(!1);const o=this.plugins.component.set_cover.call(this,e),l=this.plugins.component.set_container.call(this,o,"se-audio-container");try{if(this.util.getParentElement(s,this.util.isNotCheckingNode))s.parentNode.replaceChild(l,s);else if(this.util.isListCell(i)){const a=this.util.getParentElement(s,function(r){return r.parentNode===i});i.insertBefore(l,a),this.util.removeItem(s),this.util.removeEmptyNode(a,null,!0)}else if(this.util.isFormatElement(i)){const a=this.util.getParentElement(s,function(r){return r.parentNode===i});i=this.util.splitElement(i,a),i.parentNode.insertBefore(l,i),this.util.removeItem(s),this.util.removeEmptyNode(i,null,!0),i.children.length===0&&(i.innerHTML=this.util.htmlRemoveWhiteSpace(i.innerHTML))}else i.parentNode.replaceChild(l,i)}catch(a){console.warn("[SUNEDITOR.audio.error] Maybe the audio tag is nested.",a)}this.plugins.fileManager.setInfo.call(this,"audio",e,this.functions.onAudioUpload,null,!1),this.plugins.audio.init.call(this)},onModifyMode:function(e){const t=this.context.audio;this.setControllerPosition(t.controller,e,"bottom",{left:0,top:0}),this.controllersOn(t.controller,e,this.plugins.audio.onControllerOff.bind(this,e),"audio"),this.util.addClass(e,"active"),t._element=e,t._cover=this.util.getParentElement(e,"FIGURE"),t._container=this.util.getParentElement(e,this.util.isComponent)},openModify:function(e){if(this.context.audio.audioUrlFile){const t=this.context.audio;t._linkValue=t.preview.textContent=t.audioUrlFile.value=t._element.src}e||this.plugins.dialog.open.call(this,"audio",!0)},onClick_controller:function(e){e.stopPropagation();const t=e.target.getAttribute("data-command");t&&(e.preventDefault(),/update/.test(t)?this.plugins.audio.openModify.call(this,!1):this.plugins.audio.destroy.call(this,this.context.audio._element),this.controllersOff())},onControllerOff:function(e){this.util.removeClass(e,"active"),this.context.audio.controller.style.display="none"},init:function(){if(this.context.dialog.updateModal)return;const e=this.context.audio;e.audioInputFile&&(e.audioInputFile.value=""),e.audioUrlFile&&(e._linkValue=e.preview.textContent=e.audioUrlFile.value=""),e.audioInputFile&&e.audioUrlFile&&(e.audioUrlFile.removeAttribute("disabled"),e.preview.style.textDecoration=""),e._element=null}},Ba="https://katex.org/docs/supported.html",JC={name:"math",display:"dialog",add:function(e){e.addModule([Fi]);const t=e.context;t.math={focusElement:null,previewElement:null,fontSizeElement:null,defaultFontSize:"",_mathExp:null};let n=this.setDialog(e);t.math.modal=n,t.math.focusElement=n.querySelector(".se-math-exp"),t.math.previewElement=n.querySelector(".se-math-preview"),t.math.fontSizeElement=n.querySelector(".se-math-size"),t.math.focusElement.addEventListener("paste",function(s){typeof e.functions.onPasteMath=="function"&&e.functions.onPasteMath(s,e)},!1),t.math.focusElement.addEventListener(e.util.isIE?"textinput":"input",this._renderMathExp.bind(e,t.math),!1),t.math.fontSizeElement.addEventListener("change",(function(s){this.fontSize=s.target.value}).bind(t.math.previewElement.style),!1);let i=this.setController_MathButton(e);t.math.mathController=i,t.math._mathExp=null,n.querySelector("form").addEventListener("submit",this.submit.bind(e),!1),i.addEventListener("click",this.onClick_mathController.bind(e)),t.math.previewElement.style.fontSize=t.math.defaultFontSize,t.dialog.modal.appendChild(n),t.element.relative.appendChild(i),n=null,i=null},setDialog:function(e){const t=e.lang,n=e.util.createElement("DIV"),i=e.options.mathFontSize;let s=i[0].value;n.className="se-dialog-content",n.style.display="none";let o='<form><div class="se-dialog-header"><button type="button" data-command="close" class="se-btn se-dialog-close" title="'+t.dialogBox.close+'" aria-label="'+t.dialogBox.close+'">'+e.icons.cancel+'</button><span class="se-modal-title">'+t.dialogBox.mathBox.title+'</span></div><div class="se-dialog-body"><div class="se-dialog-form"><label>'+t.dialogBox.mathBox.inputLabel+' (<a href="'+Ba+'" target="_blank">KaTeX</a>)</label><textarea class="se-input-form se-math-exp" type="text"></textarea></div><div class="se-dialog-form"><label>'+t.dialogBox.mathBox.fontSizeLabel+'</label><select class="se-input-select se-math-size">';for(let l=0,a=i.length,r;l<a;l++)r=i[l],r.default&&(s=r.value),o+='<option value="'+r.value+'"'+(r.default?" selected":"")+">"+r.text+"</option>";return o+='</select></div><div class="se-dialog-form"><label>'+t.dialogBox.mathBox.previewLabel+'</label><p class="se-math-preview"></p></div></div><div class="se-dialog-footer"><button type="submit" class="se-btn-primary" title="'+t.dialogBox.submitButton+'" aria-label="'+t.dialogBox.submitButton+'"><span>'+t.dialogBox.submitButton+"</span></button></div></form>",e.context.math.defaultFontSize=s,n.innerHTML=o,n},setController_MathButton:function(e){const t=e.lang,n=e.util.createElement("DIV");return n.className="se-controller se-controller-link",n.innerHTML='<div class="se-arrow se-arrow-up"></div><div class="link-content"><div class="se-btn-group"><button type="button" data-command="update" tabindex="-1" class="se-btn se-tooltip">'+e.icons.edit+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+t.controller.edit+'</span></span></button><button type="button" data-command="delete" tabindex="-1" class="se-btn se-tooltip">'+e.icons.delete+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+t.controller.remove+"</span></span></button></div></div>",n},open:function(){this.plugins.dialog.open.call(this,"math",this.currentControllerName==="math")},managedTags:function(){return{className:"katex",method:function(e){if(!e.getAttribute("data-exp")||!this.options.katex)return;const t=this._d.createRange().createContextualFragment(this.plugins.math._renderer.call(this,this.util.HTMLDecoder(e.getAttribute("data-exp"))));e.innerHTML=t.querySelector(".katex").innerHTML,e.setAttribute("contenteditable",!1)}}},_renderer:function(e){let t="";try{this.util.removeClass(this.context.math.focusElement,"se-error"),t=this.options.katex.src.renderToString(e,{throwOnError:!0,displayMode:!0})}catch(n){this.util.addClass(this.context.math.focusElement,"se-error"),t='<span class="se-math-katex-error">Katex syntax error. (Refer <a href="'+Ba+'" target="_blank">KaTeX</a>)</span>',console.warn("[SUNEDITOR.math.Katex.error] ",n)}return t},_renderMathExp:function(e,t){e.previewElement.innerHTML=this.plugins.math._renderer.call(this,t.target.value)},submit:function(e){this.showLoading(),e.preventDefault(),e.stopPropagation();const t=(function(){if(this.context.math.focusElement.value.trim().length===0)return!1;const n=this.context.math,i=n.focusElement.value,s=n.previewElement.querySelector(".katex");if(!s)return!1;if(s.className="__se__katex "+s.className,s.setAttribute("contenteditable",!1),s.setAttribute("data-exp",this.util.HTMLEncoder(i)),s.setAttribute("data-font-size",n.fontSizeElement.value),s.style.fontSize=n.fontSizeElement.value,this.context.dialog.updateModal){const o=this.util.getParentElement(n._mathExp,".katex");o.parentNode.replaceChild(s,o),this.setRange(s,0,s,1)}else{const o=this.getSelectedElements();if(o.length>1){const a=this.util.createElement(o[0].nodeName);if(a.appendChild(s),!this.insertNode(a,null,!0))return!1}else if(!this.insertNode(s,null,!0))return!1;const l=this.util.createTextNode(this.util.zeroWidthSpace);s.parentNode.insertBefore(l,s.nextSibling),this.setRange(s,0,s,1)}return n.focusElement.value="",n.fontSizeElement.value="1em",n.previewElement.style.fontSize="1em",n.previewElement.innerHTML="",!0}).bind(this);try{t()&&(this.plugins.dialog.close.call(this),this.history.push(!1))}catch{this.plugins.dialog.close.call(this)}finally{this.closeLoading()}return!1},active:function(e){if(!e)this.controllerArray.indexOf(this.context.math.mathController)>-1&&this.controllersOff();else if(e.getAttribute("data-exp"))return this.controllerArray.indexOf(this.context.math.mathController)<0&&(this.setRange(e,0,e,1),this.plugins.math.call_controller.call(this,e)),!0;return!1},on:function(e){if(!e)this.plugins.math.init.call(this);else{const t=this.context.math;if(t._mathExp){const n=this.util.HTMLDecoder(t._mathExp.getAttribute("data-exp")),i=t._mathExp.getAttribute("data-font-size")||"1em";this.context.dialog.updateModal=!0,t.focusElement.value=n,t.fontSizeElement.value=i,t.previewElement.innerHTML=this.plugins.math._renderer.call(this,n),t.previewElement.style.fontSize=i}}},call_controller:function(e){this.context.math._mathExp=e;const t=this.context.math.mathController;this.setControllerPosition(t,e,"bottom",{left:0,top:0}),this.controllersOn(t,e,"math")},onClick_mathController:function(e){e.stopPropagation();const t=e.target.getAttribute("data-command")||e.target.parentNode.getAttribute("data-command");t&&(e.preventDefault(),/update/.test(t)?(this.context.math.focusElement.value=this.util.HTMLDecoder(this.context.math._mathExp.getAttribute("data-exp")),this.plugins.dialog.open.call(this,"math",!0)):(this.util.removeItem(this.context.math._mathExp),this.context.math._mathExp=null,this.focus(),this.history.push(!1)),this.controllersOff())},init:function(){const e=this.context.math;e.mathController.style.display="none",e._mathExp=null,e.focusElement.value="",e.previewElement.innerHTML=""}};var ph={exports:{}};(function(e){(function(t,n){e.exports=t.document?n(t,!0):function(i){if(!i.document)throw new Error("SUNEDITOR_MODULES a window with a document");return n(i)}})(typeof window<"u"?window:Yn,function(t,n){const i={name:"fileBrowser",_xmlHttp:null,_loading:null,add:function(s){const o=s.context;o.fileBrowser={_closeSignal:!1,area:null,header:null,tagArea:null,body:null,list:null,tagElements:null,items:[],selectedTags:[],selectorHandler:null,contextPlugin:"",columnSize:4};let l=s.util.createElement("DIV");l.className="se-file-browser sun-editor-common";let a=s.util.createElement("DIV");a.className="se-file-browser-back";let r=s.util.createElement("DIV");r.className="se-file-browser-inner",r.innerHTML=this.set_browser(s),l.appendChild(a),l.appendChild(r),this._loading=l.querySelector(".se-loading-box"),o.fileBrowser.area=l,o.fileBrowser.header=r.querySelector(".se-file-browser-header"),o.fileBrowser.titleArea=r.querySelector(".se-file-browser-title"),o.fileBrowser.tagArea=r.querySelector(".se-file-browser-tags"),o.fileBrowser.body=r.querySelector(".se-file-browser-body"),o.fileBrowser.list=r.querySelector(".se-file-browser-list"),o.fileBrowser.tagArea.addEventListener("click",this.onClickTag.bind(s)),o.fileBrowser.list.addEventListener("click",this.onClickFile.bind(s)),r.addEventListener("mousedown",this._onMouseDown_browser.bind(s)),r.addEventListener("click",this._onClick_browser.bind(s)),o.element.relative.appendChild(l),l=null,a=null,r=null},set_browser:function(s){const o=s.lang;return'<div class="se-file-browser-content"><div class="se-file-browser-header"><button type="button" data-command="close" class="se-btn se-file-browser-close" class="close" title="'+o.dialogBox.close+'" aria-label="'+o.dialogBox.close+'">'+s.icons.cancel+'</button><span class="se-file-browser-title"></span><div class="se-file-browser-tags"></div></div><div class="se-file-browser-body"><div class="se-loading-box sun-editor-common"><div class="se-loading-effect"></div></div><div class="se-file-browser-list"></div></div></div>'},_onMouseDown_browser:function(s){/se-file-browser-inner/.test(s.target.className)?this.context.fileBrowser._closeSignal=!0:this.context.fileBrowser._closeSignal=!1},_onClick_browser:function(s){s.stopPropagation(),(/close/.test(s.target.getAttribute("data-command"))||this.context.fileBrowser._closeSignal)&&this.plugins.fileBrowser.close.call(this)},open:function(s,o){this.plugins.fileBrowser._bindClose&&(this._d.removeEventListener("keydown",this.plugins.fileBrowser._bindClose),this.plugins.fileBrowser._bindClose=null),this.plugins.fileBrowser._bindClose=(function(f){/27/.test(f.keyCode)&&this.plugins.fileBrowser.close.call(this)}).bind(this),this._d.addEventListener("keydown",this.plugins.fileBrowser._bindClose);const l=this.context.fileBrowser;l.contextPlugin=s,l.selectorHandler=o;const a=this.context[s],r=a.listClass;this.util.hasClass(l.list,r)||(l.list.className="se-file-browser-list "+r),this.options.popupDisplay==="full"?l.area.style.position="fixed":l.area.style.position="absolute",l.titleArea.textContent=a.title,l.area.style.display="block",this.context[s].directData?this.plugins.fileBrowser._drawListItem.call(this,this.context[s].directData,!0):this.plugins.fileBrowser._drawFileList.call(this,this.context[s].url,this.context[s].header)},_bindClose:null,close:function(){const s=this.plugins.fileBrowser;s._xmlHttp&&s._xmlHttp.abort(),s._bindClose&&(this._d.removeEventListener("keydown",s._bindClose),s._bindClose=null);const o=this.context.fileBrowser;o.area.style.display="none",o.selectorHandler=null,o.selectedTags=[],o.items=[],o.list.innerHTML=o.tagArea.innerHTML=o.titleArea.textContent="",typeof this.plugins[o.contextPlugin].init=="function"&&this.plugins[o.contextPlugin].init.call(this),o.contextPlugin=""},showBrowserLoading:function(){this._loading.style.display="block"},closeBrowserLoading:function(){this._loading.style.display="none"},_drawFileList:function(s,o){const l=this.plugins.fileBrowser,a=l._xmlHttp=this.util.getXMLHttpRequest();if(a.onreadystatechange=l._callBackGet.bind(this,a),a.open("get",s,!0),o!==null&&typeof o=="object"&&this._w.Object.keys(o).length>0)for(let r in o)a.setRequestHeader(r,o[r]);a.send(null),this.plugins.fileBrowser.showBrowserLoading()},_callBackGet:function(s){if(s.readyState===4){if(this.plugins.fileBrowser._xmlHttp=null,s.status===200)try{const o=JSON.parse(s.responseText);o.result.length>0?this.plugins.fileBrowser._drawListItem.call(this,o.result,!0):o.nullMessage&&(this.context.fileBrowser.list.innerHTML=o.nullMessage)}catch(o){throw Error('[SUNEDITOR.fileBrowser.drawList.fail] cause : "'+o.message+'"')}finally{this.plugins.fileBrowser.closeBrowserLoading(),this.context.fileBrowser.body.style.maxHeight=this._w.innerHeight-this.context.fileBrowser.header.offsetHeight-50+"px"}else if(this.plugins.fileBrowser.closeBrowserLoading(),s.status!==0){const o=s.responseText?JSON.parse(s.responseText):s,l="[SUNEDITOR.fileBrowser.get.serverException] status: "+s.status+", response: "+(o.errorMessage||s.responseText);throw Error(l)}}},_drawListItem:function(s,o){const l=this.context.fileBrowser,a=this.context[l.contextPlugin],r=[],f=s.length,d=a.columnSize||l.columnSize,h=d<=1?1:Math.round(f/d)||1,v=a.itemTemplateHandler;let _="",C='<div class="se-file-item-column">',S=1;for(let c=0,u,p;c<f;c++)if(u=s[c],p=u.tag?typeof u.tag=="string"?u.tag.split(","):u.tag:[],p=u.tag=p.map(function(b){return b.trim()}),C+=v(u),(c+1)%h===0&&S<d&&c+1<f&&(S++,C+='</div><div class="se-file-item-column">'),o&&p.length>0)for(let b=0,y=p.length,w;b<y;b++)w=p[b],w&&r.indexOf(w)===-1&&(r.push(w),_+='<a title="'+w+'" aria-label="'+w+'">'+w+"</a>");C+="</div>",l.list.innerHTML=C,o&&(l.items=s,l.tagArea.innerHTML=_,l.tagElements=l.tagArea.querySelectorAll("A"))},onClickTag:function(s){const o=s.target;if(!this.util.isAnchor(o))return;const l=o.textContent,a=this.plugins.fileBrowser,r=this.context.fileBrowser,f=r.tagArea.querySelector('a[title="'+l+'"]'),d=r.selectedTags,h=d.indexOf(l);h>-1?(d.splice(h,1),this.util.removeClass(f,"on")):(d.push(l),this.util.addClass(f,"on")),a._drawListItem.call(this,d.length===0?r.items:r.items.filter(function(v){return v.tag.some(function(_){return d.indexOf(_)>-1})}),!1)},onClickFile:function(s){s.preventDefault(),s.stopPropagation();const o=this.context.fileBrowser,l=o.list;let a=s.target,r=null;if(a===l)return;for(;l!==a.parentNode&&(r=a.getAttribute("data-command"),!r);)a=a.parentNode;if(!r)return;(o.selectorHandler||this.context[o.contextPlugin].selectorHandler)(a,a.parentNode.querySelector(".__se__img_name").textContent),this.plugins.fileBrowser.close.call(this)}};return typeof n>"u"&&(t.SUNEDITOR_MODULES||Object.defineProperty(t,"SUNEDITOR_MODULES",{enumerable:!0,writable:!1,configurable:!1,value:{}}),Object.defineProperty(t.SUNEDITOR_MODULES,"fileBrowser",{enumerable:!0,writable:!1,configurable:!1,value:i})),i})})(ph);var eS=ph.exports;const tS=Zn(eS),nS={name:"imageGallery",add:function(e){e.addModule([tS]);const t=e.context;t.imageGallery={title:e.lang.toolbar.imageGallery,directData:e.options.imageGalleryData,url:e.options.imageGalleryUrl,header:e.options.imageGalleryHeader,listClass:"se-image-list",itemTemplateHandler:this.drawItems,selectorHandler:this.setImage.bind(e),columnSize:4}},open:function(e){this.plugins.fileBrowser.open.call(this,"imageGallery",e)},drawItems:function(e){const t=e.src.split("/").pop();return'<div class="se-file-item-img"><img src="'+(e.thumbnail||e.src)+'" alt="'+(e.alt||t)+'" data-command="pick" data-value="'+(e.src||e.thumbnail)+'"><div class="se-file-img-name se-file-name-back"></div><div class="se-file-img-name __se__img_name">'+(e.name||t)+"</div></div>"},setImage:function(e,t){this.callPlugin("image",(function(){const n={name:t,size:0};this.plugins.image.create_image.call(this,e.getAttribute("data-value"),null,this.context.image._origin_w,this.context.image._origin_h,"none",n,e.alt)}).bind(this),null)}},iS={blockquote:AC,align:RC,font:DC,fontSize:LC,fontColor:OC,hiliteColor:PC,horizontalRule:IC,list:BC,table:FC,formatBlock:jC,lineHeight:zC,template:HC,paragraphStyle:VC,textStyle:WC,link:YC,image:KC,video:XC,audio:QC,math:JC,imageGallery:nS},Jo=m.forwardRef(({value:e="",onChange:t,placeholder:n="Start writing...",height:i="200px",className:s,...o},l)=>{const a=m.useRef(null),[r,f]=m.useState(null);return m.useEffect(()=>{if(a.current&&!r){const d=MC.create(a.current,{plugins:iS,buttonList:[["undo","redo"],["font","fontSize","formatBlock"],["paragraphStyle","blockquote"],["bold","underline","italic","strike","subscript","superscript"],["fontColor","hiliteColor","textStyle"],["removeFormat"],["outdent","indent"],["align","horizontalRule","list","lineHeight"],["table","link","image","video","audio"],["fullScreen","showBlocks","codeView"],["preview","print"],["save","template"]],defaultTag:"div",minHeight:i,showPathLabel:!1,placeholder:n,resizingBar:!1,charCounter:!0,maxCharCount:1e4,width:"100%",height:"auto",mode:"classic",katex:"window.katex",imageGalleryUrl:"/editor/image-gallery",videoFileInput:!1,audioFileInput:!1,tabDisable:!1,linkProtocol:"",linkRelDefault:{default:"nofollow",check_new_window:"nofollow noopener",check_bookmark:""},iframe:!1,stickyToolbar:!1,popupDisplay:"local",display:"block",position:null,font:["Arial","Comic Sans MS","Courier New","Impact","Georgia","tahoma","Trebuchet MS","Verdana"],fontSize:[8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72],formats:["p","div","blockquote","pre","h1","h2","h3","h4","h5","h6"],colorList:["#ff0000","#ff5e00","#ffbb00","#ffe400","#abf200","#00d8ff","#0055ff","#0900ff","#6600ff","#ff00dd","#ff007f","#000000","#2d3436","#636e72","#b2bec3","#ffffff","#ffeaa7","#fab1a0","#e17055","#d63031","#fd79a8","#e84393","#6c5ce7","#a29bfe","#fdcb6e","#e17055","#00b894","#00cec9","#55a3ff","#74b9ff","#a29bfe","#ffeaa7","#fab1a0"],lineHeights:[{text:"1",value:1},{text:"1.15",value:1.15},{text:"1.5",value:1.5},{text:"2",value:2}],paragraphStyles:["spaced","neon",{name:"Custom",class:"__se__customClass"}],textStyles:["translucent",{name:"Shadow",style:"text-shadow: 2px 2px 2px #000;"}],imageSizeOnlyPercentage:!1,imageWidth:"100%",imageHeight:"auto",imageSize:"auto",imageUploadSizeLimit:5242880,imageUploadUrl:null,imageUploadHeader:{},imageUrlInput:!0,imageMultipleFile:!1,imageAccept:".jpg,.jpeg,.png,.gif,.svg,.webp",videoWidth:"100%",videoHeight:"auto",videoSize:"auto",videoUploadSizeLimit:10485760,videoUploadUrl:null,videoUploadHeader:{},videoUrlInput:!0,videoMultipleFile:!1,videoAccept:".mp4,.avi,.wmv,.flv,.mov,.webm,.m4v",audioWidth:"100%",audioHeight:"auto",audioSize:"auto",audioUploadSizeLimit:10485760,audioUploadUrl:null,audioUploadHeader:{},audioUrlInput:!0,audioMultipleFile:!1,audioAccept:".mp3,.wav,.ogg,.flac,.aac,.wma",tableCellControllerPosition:"cell",tableResizing:!0,tableUseBackgroundColor:!0,tableBackgroundColor:"#fff",codeMirror:null,codeMirror_src:null,codeMirror_options:null,fullScreenOffset:0,previewTemplate:null,printTemplate:null,iframeAttributes:{},iframeStyles:{},attributesWhitelist:{},tagsBlacklist:"",pasteTagsWhitelist:"",pasteAttributesWhitelist:"",pasteKeepOnlyTags:"",pasteDenyTags:"",pasteTagsBlacklist:"",pasteKeepOnlyAttributes:"",pasteDenyAttributes:"",pasteTagsRemove:"",pasteAttributesRemove:"",...o});d.onChange=h=>{t==null||t(h)},f(d)}return()=>{r&&(r.destroy(),f(null))}},[t,i,n,o]),m.useEffect(()=>{r&&e!==r.getContents()&&r.setContents(e)},[r,e]),m.useImperativeHandle(l,()=>({getContents:()=>r==null?void 0:r.getContents(),setContents:d=>r==null?void 0:r.setContents(d),insertHTML:d=>r==null?void 0:r.insertHTML(d),focus:()=>r==null?void 0:r.core.focus(),blur:()=>r==null?void 0:r.core.blur()}),[r]),g.jsx("div",{className:ne("sun-editor-wrapper",s),children:g.jsx("div",{ref:a})})});Jo.displayName="RichTextEditor";function sS(e,t=[]){let n=[];function i(o,l){const a=m.createContext(l),r=n.length;n=[...n,l];const f=h=>{var u;const{scope:v,children:_,...C}=h,S=((u=v==null?void 0:v[e])==null?void 0:u[r])||a,c=m.useMemo(()=>C,Object.values(C));return g.jsx(S.Provider,{value:c,children:_})};f.displayName=o+"Provider";function d(h,v){var S;const _=((S=v==null?void 0:v[e])==null?void 0:S[r])||a,C=m.useContext(_);if(C)return C;if(l!==void 0)return l;throw new Error(`\`${h}\` must be used within \`${o}\``)}return[f,d]}const s=()=>{const o=n.map(l=>m.createContext(l));return function(a){const r=(a==null?void 0:a[e])||o;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:r}}),[a,r])}};return s.scopeName=e,[i,rS(s,...t)]}function rS(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const l=i.reduce((a,{useScope:r,scopeName:f})=>{const h=r(o)[`__scope${f}`];return{...a,...h}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:l}),[l])}};return n.scopeName=t.scopeName,n}function oS(e){const t=lS(e),n=m.forwardRef((i,s)=>{const{children:o,...l}=i,a=m.Children.toArray(o),r=a.find(cS);if(r){const f=r.props.children,d=a.map(h=>h===r?m.Children.count(f)>1?m.Children.only(null):m.isValidElement(f)?f.props.children:null:h);return g.jsx(t,{...l,ref:s,children:m.isValidElement(f)?m.cloneElement(f,void 0,d):null})}return g.jsx(t,{...l,ref:s,children:o})});return n.displayName=`${e}.Slot`,n}function lS(e){const t=m.forwardRef((n,i)=>{const{children:s,...o}=n;if(m.isValidElement(s)){const l=dS(s),a=uS(o,s.props);return s.type!==m.Fragment&&(a.ref=i?je(i,l):l),m.cloneElement(s,a)}return m.Children.count(s)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var aS=Symbol("radix.slottable");function cS(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===aS}function uS(e,t){const n={...t};for(const i in t){const s=e[i],o=t[i];/^on[A-Z]/.test(i)?s&&o?n[i]=(...a)=>{const r=o(...a);return s(...a),r}:s&&(n[i]=s):i==="style"?n[i]={...s,...o}:i==="className"&&(n[i]=[s,o].filter(Boolean).join(" "))}return{...e,...n}}function dS(e){var i,s;let t=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var fS=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],hS=fS.reduce((e,t)=>{const n=oS(`Primitive.${t}`),i=m.forwardRef((s,o)=>{const{asChild:l,...a}=s,r=l?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),g.jsx(r,{...a,ref:o})});return i.displayName=`Primitive.${t}`,{...e,[t]:i}},{});function pS(e,t=[]){let n=[];function i(o,l){const a=m.createContext(l),r=n.length;n=[...n,l];const f=h=>{var u;const{scope:v,children:_,...C}=h,S=((u=v==null?void 0:v[e])==null?void 0:u[r])||a,c=m.useMemo(()=>C,Object.values(C));return g.jsx(S.Provider,{value:c,children:_})};f.displayName=o+"Provider";function d(h,v){var S;const _=((S=v==null?void 0:v[e])==null?void 0:S[r])||a,C=m.useContext(_);if(C)return C;if(l!==void 0)return l;throw new Error(`\`${h}\` must be used within \`${o}\``)}return[f,d]}const s=()=>{const o=n.map(l=>m.createContext(l));return function(a){const r=(a==null?void 0:a[e])||o;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:r}}),[a,r])}};return s.scopeName=e,[i,mS(s,...t)]}function mS(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const l=i.reduce((a,{useScope:r,scopeName:f})=>{const h=r(o)[`__scope${f}`];return{...a,...h}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:l}),[l])}};return n.scopeName=t.scopeName,n}function mh(e){const t=gS(e),n=m.forwardRef((i,s)=>{const{children:o,...l}=i,a=m.Children.toArray(o),r=a.find(bS);if(r){const f=r.props.children,d=a.map(h=>h===r?m.Children.count(f)>1?m.Children.only(null):m.isValidElement(f)?f.props.children:null:h);return g.jsx(t,{...l,ref:s,children:m.isValidElement(f)?m.cloneElement(f,void 0,d):null})}return g.jsx(t,{...l,ref:s,children:o})});return n.displayName=`${e}.Slot`,n}function gS(e){const t=m.forwardRef((n,i)=>{const{children:s,...o}=n;if(m.isValidElement(s)){const l=xS(s),a=yS(o,s.props);return s.type!==m.Fragment&&(a.ref=i?je(i,l):l),m.cloneElement(s,a)}return m.Children.count(s)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var vS=Symbol("radix.slottable");function bS(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===vS}function yS(e,t){const n={...t};for(const i in t){const s=e[i],o=t[i];/^on[A-Z]/.test(i)?s&&o?n[i]=(...a)=>{const r=o(...a);return s(...a),r}:s&&(n[i]=s):i==="style"?n[i]={...s,...o}:i==="className"&&(n[i]=[s,o].filter(Boolean).join(" "))}return{...e,...n}}function xS(e){var i,s;let t=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var wS=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ji=wS.reduce((e,t)=>{const n=mh(`Primitive.${t}`),i=m.forwardRef((s,o)=>{const{asChild:l,...a}=s,r=l?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),g.jsx(r,{...a,ref:o})});return i.displayName=`Primitive.${t}`,{...e,[t]:i}},{});function _S(e,t){e&&wi.flushSync(()=>e.dispatchEvent(t))}var Gr=["Enter"," "],CS=["ArrowDown","PageUp","Home"],gh=["ArrowUp","PageDown","End"],SS=[...CS,...gh],ES={ltr:[...Gr,"ArrowRight"],rtl:[...Gr,"ArrowLeft"]},NS={ltr:["ArrowLeft"],rtl:["ArrowRight"]},zi="Menu",[gi,kS,TS]=co(zi),[mn,vh]=pS(zi,[TS,en,js]),Hi=en(),bh=js(),[yh,rn]=mn(zi),[MS,Vi]=mn(zi),xh=e=>{const{__scopeMenu:t,open:n=!1,children:i,dir:s,onOpenChange:o,modal:l=!0}=e,a=Hi(t),[r,f]=m.useState(null),d=m.useRef(!1),h=Ze(o),v=Ei(s);return m.useEffect(()=>{const _=()=>{d.current=!0,document.addEventListener("pointerdown",C,{capture:!0,once:!0}),document.addEventListener("pointermove",C,{capture:!0,once:!0})},C=()=>d.current=!1;return document.addEventListener("keydown",_,{capture:!0}),()=>{document.removeEventListener("keydown",_,{capture:!0}),document.removeEventListener("pointerdown",C,{capture:!0}),document.removeEventListener("pointermove",C,{capture:!0})}},[]),g.jsx(Ti,{...a,children:g.jsx(yh,{scope:t,open:n,onOpenChange:h,content:r,onContentChange:f,children:g.jsx(MS,{scope:t,onClose:m.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:d,dir:v,modal:l,children:i})})})};xh.displayName=zi;var AS="MenuAnchor",el=m.forwardRef((e,t)=>{const{__scopeMenu:n,...i}=e,s=Hi(n);return g.jsx(Mi,{...s,...i,ref:t})});el.displayName=AS;var tl="MenuPortal",[RS,wh]=mn(tl,{forceMount:void 0}),_h=e=>{const{__scopeMenu:t,forceMount:n,children:i,container:s}=e,o=rn(tl,t);return g.jsx(RS,{scope:t,forceMount:n,children:g.jsx(Ke,{present:n||o.open,children:g.jsx(Ai,{asChild:!0,container:s,children:i})})})};_h.displayName=tl;var pt="MenuContent",[DS,nl]=mn(pt),Ch=m.forwardRef((e,t)=>{const n=wh(pt,e.__scopeMenu),{forceMount:i=n.forceMount,...s}=e,o=rn(pt,e.__scopeMenu),l=Vi(pt,e.__scopeMenu);return g.jsx(gi.Provider,{scope:e.__scopeMenu,children:g.jsx(Ke,{present:i||o.open,children:g.jsx(gi.Slot,{scope:e.__scopeMenu,children:l.modal?g.jsx(LS,{...s,ref:t}):g.jsx(OS,{...s,ref:t})})})})}),LS=m.forwardRef((e,t)=>{const n=rn(pt,e.__scopeMenu),i=m.useRef(null),s=ye(t,i);return m.useEffect(()=>{const o=i.current;if(o)return Ms(o)},[]),g.jsx(il,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:oe(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),OS=m.forwardRef((e,t)=>{const n=rn(pt,e.__scopeMenu);return g.jsx(il,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),PS=mh("MenuContent.ScrollLock"),il=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:i=!1,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:l,disableOutsidePointerEvents:a,onEntryFocus:r,onEscapeKeyDown:f,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:v,onDismiss:_,disableOutsideScroll:C,...S}=e,c=rn(pt,n),u=Vi(pt,n),p=Hi(n),b=bh(n),y=kS(n),[w,x]=m.useState(null),E=m.useRef(null),k=ye(t,E,c.onContentChange),N=m.useRef(0),T=m.useRef(""),R=m.useRef(0),M=m.useRef(null),A=m.useRef("right"),D=m.useRef(0),$=C?Ri:m.Fragment,H=C?{as:PS,allowPinchZoom:!0}:void 0,j=z=>{var V,X;const P=T.current+z,B=y().filter(Z=>!Z.disabled),L=document.activeElement,U=(V=B.find(Z=>Z.ref.current===L))==null?void 0:V.textValue,O=B.map(Z=>Z.textValue),W=ZS(O,P,U),Q=(X=B.find(Z=>Z.textValue===W))==null?void 0:X.ref.current;(function Z(G){T.current=G,window.clearTimeout(N.current),G!==""&&(N.current=window.setTimeout(()=>Z(""),1e3))})(P),Q&&setTimeout(()=>Q.focus())};m.useEffect(()=>()=>window.clearTimeout(N.current),[]),_s();const F=m.useCallback(z=>{var B,L;return A.current===((B=M.current)==null?void 0:B.side)&&GS(z,(L=M.current)==null?void 0:L.area)},[]);return g.jsx(DS,{scope:n,searchRef:T,onItemEnter:m.useCallback(z=>{F(z)&&z.preventDefault()},[F]),onItemLeave:m.useCallback(z=>{var P;F(z)||((P=E.current)==null||P.focus(),x(null))},[F]),onTriggerLeave:m.useCallback(z=>{F(z)&&z.preventDefault()},[F]),pointerGraceTimerRef:R,onPointerGraceIntentChange:m.useCallback(z=>{M.current=z},[]),children:g.jsx($,{...H,children:g.jsx(Ni,{asChild:!0,trapped:s,onMountAutoFocus:oe(o,z=>{var P;z.preventDefault(),(P=E.current)==null||P.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:g.jsx(Vn,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:f,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:v,onDismiss:_,children:g.jsx(Dd,{asChild:!0,...b,dir:u.dir,orientation:"vertical",loop:i,currentTabStopId:w,onCurrentTabStopIdChange:x,onEntryFocus:oe(r,z=>{u.isUsingKeyboardRef.current||z.preventDefault()}),preventScrollOnEntryFocus:!0,children:g.jsx(ks,{role:"menu","aria-orientation":"vertical","data-state":zh(c.open),"data-radix-menu-content":"",dir:u.dir,...p,...S,ref:k,style:{outline:"none",...S.style},onKeyDown:oe(S.onKeyDown,z=>{const B=z.target.closest("[data-radix-menu-content]")===z.currentTarget,L=z.ctrlKey||z.altKey||z.metaKey,U=z.key.length===1;B&&(z.key==="Tab"&&z.preventDefault(),!L&&U&&j(z.key));const O=E.current;if(z.target!==O||!SS.includes(z.key))return;z.preventDefault();const Q=y().filter(V=>!V.disabled).map(V=>V.ref.current);gh.includes(z.key)&&Q.reverse(),US(Q)}),onBlur:oe(e.onBlur,z=>{z.currentTarget.contains(z.target)||(window.clearTimeout(N.current),T.current="")}),onPointerMove:oe(e.onPointerMove,vi(z=>{const P=z.target,B=D.current!==z.clientX;if(z.currentTarget.contains(P)&&B){const L=z.clientX>D.current?"right":"left";A.current=L,D.current=z.clientX}}))})})})})})})});Ch.displayName=pt;var IS="MenuGroup",sl=m.forwardRef((e,t)=>{const{__scopeMenu:n,...i}=e;return g.jsx(ji.div,{role:"group",...i,ref:t})});sl.displayName=IS;var BS="MenuLabel",Sh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...i}=e;return g.jsx(ji.div,{...i,ref:t})});Sh.displayName=BS;var ds="MenuItem",Fa="menu.itemSelect",Ks=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:i,...s}=e,o=m.useRef(null),l=Vi(ds,e.__scopeMenu),a=nl(ds,e.__scopeMenu),r=ye(t,o),f=m.useRef(!1),d=()=>{const h=o.current;if(!n&&h){const v=new CustomEvent(Fa,{bubbles:!0,cancelable:!0});h.addEventListener(Fa,_=>i==null?void 0:i(_),{once:!0}),_S(h,v),v.defaultPrevented?f.current=!1:l.onClose()}};return g.jsx(Eh,{...s,ref:r,disabled:n,onClick:oe(e.onClick,d),onPointerDown:h=>{var v;(v=e.onPointerDown)==null||v.call(e,h),f.current=!0},onPointerUp:oe(e.onPointerUp,h=>{var v;f.current||(v=h.currentTarget)==null||v.click()}),onKeyDown:oe(e.onKeyDown,h=>{const v=a.searchRef.current!=="";n||v&&h.key===" "||Gr.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Ks.displayName=ds;var Eh=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:i=!1,textValue:s,...o}=e,l=nl(ds,n),a=bh(n),r=m.useRef(null),f=ye(t,r),[d,h]=m.useState(!1),[v,_]=m.useState("");return m.useEffect(()=>{const C=r.current;C&&_((C.textContent??"").trim())},[o.children]),g.jsx(gi.ItemSlot,{scope:n,disabled:i,textValue:s??v,children:g.jsx(Ld,{asChild:!0,...a,focusable:!i,children:g.jsx(ji.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...o,ref:f,onPointerMove:oe(e.onPointerMove,vi(C=>{i?l.onItemLeave(C):(l.onItemEnter(C),C.defaultPrevented||C.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:oe(e.onPointerLeave,vi(C=>l.onItemLeave(C))),onFocus:oe(e.onFocus,()=>h(!0)),onBlur:oe(e.onBlur,()=>h(!1))})})})}),FS="MenuCheckboxItem",Nh=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:i,...s}=e;return g.jsx(Rh,{scope:e.__scopeMenu,checked:n,children:g.jsx(Ks,{role:"menuitemcheckbox","aria-checked":fs(n)?"mixed":n,...s,ref:t,"data-state":ll(n),onSelect:oe(s.onSelect,()=>i==null?void 0:i(fs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Nh.displayName=FS;var kh="MenuRadioGroup",[jS,zS]=mn(kh,{value:void 0,onValueChange:()=>{}}),Th=m.forwardRef((e,t)=>{const{value:n,onValueChange:i,...s}=e,o=Ze(i);return g.jsx(jS,{scope:e.__scopeMenu,value:n,onValueChange:o,children:g.jsx(sl,{...s,ref:t})})});Th.displayName=kh;var Mh="MenuRadioItem",Ah=m.forwardRef((e,t)=>{const{value:n,...i}=e,s=zS(Mh,e.__scopeMenu),o=n===s.value;return g.jsx(Rh,{scope:e.__scopeMenu,checked:o,children:g.jsx(Ks,{role:"menuitemradio","aria-checked":o,...i,ref:t,"data-state":ll(o),onSelect:oe(i.onSelect,()=>{var l;return(l=s.onValueChange)==null?void 0:l.call(s,n)},{checkForDefaultPrevented:!1})})})});Ah.displayName=Mh;var rl="MenuItemIndicator",[Rh,HS]=mn(rl,{checked:!1}),Dh=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:i,...s}=e,o=HS(rl,n);return g.jsx(Ke,{present:i||fs(o.checked)||o.checked===!0,children:g.jsx(ji.span,{...s,ref:t,"data-state":ll(o.checked)})})});Dh.displayName=rl;var VS="MenuSeparator",Lh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...i}=e;return g.jsx(ji.div,{role:"separator","aria-orientation":"horizontal",...i,ref:t})});Lh.displayName=VS;var WS="MenuArrow",Oh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...i}=e,s=Hi(n);return g.jsx(Ts,{...s,...i,ref:t})});Oh.displayName=WS;var ol="MenuSub",[$S,Ph]=mn(ol),Ih=e=>{const{__scopeMenu:t,children:n,open:i=!1,onOpenChange:s}=e,o=rn(ol,t),l=Hi(t),[a,r]=m.useState(null),[f,d]=m.useState(null),h=Ze(s);return m.useEffect(()=>(o.open===!1&&h(!1),()=>h(!1)),[o.open,h]),g.jsx(Ti,{...l,children:g.jsx(yh,{scope:t,open:i,onOpenChange:h,content:f,onContentChange:d,children:g.jsx($S,{scope:t,contentId:it(),triggerId:it(),trigger:a,onTriggerChange:r,children:n})})})};Ih.displayName=ol;var oi="MenuSubTrigger",Bh=m.forwardRef((e,t)=>{const n=rn(oi,e.__scopeMenu),i=Vi(oi,e.__scopeMenu),s=Ph(oi,e.__scopeMenu),o=nl(oi,e.__scopeMenu),l=m.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:r}=o,f={__scopeMenu:e.__scopeMenu},d=m.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return m.useEffect(()=>d,[d]),m.useEffect(()=>{const h=a.current;return()=>{window.clearTimeout(h),r(null)}},[a,r]),g.jsx(el,{asChild:!0,...f,children:g.jsx(Eh,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":s.contentId,"data-state":zh(n.open),...e,ref:je(t,s.onTriggerChange),onClick:h=>{var v;(v=e.onClick)==null||v.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:oe(e.onPointerMove,vi(h=>{o.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!l.current&&(o.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:oe(e.onPointerLeave,vi(h=>{var _,C;d();const v=(_=n.content)==null?void 0:_.getBoundingClientRect();if(v){const S=(C=n.content)==null?void 0:C.dataset.side,c=S==="right",u=c?-5:5,p=v[c?"left":"right"],b=v[c?"right":"left"];o.onPointerGraceIntentChange({area:[{x:h.clientX+u,y:h.clientY},{x:p,y:v.top},{x:b,y:v.top},{x:b,y:v.bottom},{x:p,y:v.bottom}],side:S}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(h),h.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:oe(e.onKeyDown,h=>{var _;const v=o.searchRef.current!=="";e.disabled||v&&h.key===" "||ES[i.dir].includes(h.key)&&(n.onOpenChange(!0),(_=n.content)==null||_.focus(),h.preventDefault())})})})});Bh.displayName=oi;var Fh="MenuSubContent",jh=m.forwardRef((e,t)=>{const n=wh(pt,e.__scopeMenu),{forceMount:i=n.forceMount,...s}=e,o=rn(pt,e.__scopeMenu),l=Vi(pt,e.__scopeMenu),a=Ph(Fh,e.__scopeMenu),r=m.useRef(null),f=ye(t,r);return g.jsx(gi.Provider,{scope:e.__scopeMenu,children:g.jsx(Ke,{present:i||o.open,children:g.jsx(gi.Slot,{scope:e.__scopeMenu,children:g.jsx(il,{id:a.contentId,"aria-labelledby":a.triggerId,...s,ref:f,align:"start",side:l.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var h;l.isUsingKeyboardRef.current&&((h=r.current)==null||h.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:oe(e.onFocusOutside,d=>{d.target!==a.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:oe(e.onEscapeKeyDown,d=>{l.onClose(),d.preventDefault()}),onKeyDown:oe(e.onKeyDown,d=>{var _;const h=d.currentTarget.contains(d.target),v=NS[l.dir].includes(d.key);h&&v&&(o.onOpenChange(!1),(_=a.trigger)==null||_.focus(),d.preventDefault())})})})})})});jh.displayName=Fh;function zh(e){return e?"open":"closed"}function fs(e){return e==="indeterminate"}function ll(e){return fs(e)?"indeterminate":e?"checked":"unchecked"}function US(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function YS(e,t){return e.map((n,i)=>e[(t+i)%e.length])}function ZS(e,t,n){const s=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let l=YS(e,Math.max(o,0));s.length===1&&(l=l.filter(f=>f!==n));const r=l.find(f=>f.toLowerCase().startsWith(s.toLowerCase()));return r!==n?r:void 0}function qS(e,t){const{x:n,y:i}=e;let s=!1;for(let o=0,l=t.length-1;o<t.length;l=o++){const a=t[o],r=t[l],f=a.x,d=a.y,h=r.x,v=r.y;d>i!=v>i&&n<(h-f)*(i-d)/(v-d)+f&&(s=!s)}return s}function GS(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return qS(n,t)}function vi(e){return t=>t.pointerType==="mouse"?e(t):void 0}var KS=xh,XS=el,QS=_h,JS=Ch,e4=sl,t4=Sh,n4=Ks,i4=Nh,s4=Th,r4=Ah,o4=Dh,l4=Lh,a4=Oh,c4=Ih,u4=Bh,d4=jh,Xs="DropdownMenu",[f4]=sS(Xs,[vh]),et=vh(),[h4,Hh]=f4(Xs),Vh=e=>{const{__scopeDropdownMenu:t,children:n,dir:i,open:s,defaultOpen:o,onOpenChange:l,modal:a=!0}=e,r=et(t),f=m.useRef(null),[d,h]=wt({prop:s,defaultProp:o??!1,onChange:l,caller:Xs});return g.jsx(h4,{scope:t,triggerId:it(),triggerRef:f,contentId:it(),open:d,onOpenChange:h,onOpenToggle:m.useCallback(()=>h(v=>!v),[h]),modal:a,children:g.jsx(KS,{...r,open:d,onOpenChange:h,dir:i,modal:a,children:n})})};Vh.displayName=Xs;var Wh="DropdownMenuTrigger",$h=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:i=!1,...s}=e,o=Hh(Wh,n),l=et(n);return g.jsx(XS,{asChild:!0,...l,children:g.jsx(hS.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":i?"":void 0,disabled:i,...s,ref:je(t,o.triggerRef),onPointerDown:oe(e.onPointerDown,a=>{!i&&a.button===0&&a.ctrlKey===!1&&(o.onOpenToggle(),o.open||a.preventDefault())}),onKeyDown:oe(e.onKeyDown,a=>{i||(["Enter"," "].includes(a.key)&&o.onOpenToggle(),a.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});$h.displayName=Wh;var p4="DropdownMenuPortal",Uh=e=>{const{__scopeDropdownMenu:t,...n}=e,i=et(t);return g.jsx(QS,{...i,...n})};Uh.displayName=p4;var Yh="DropdownMenuContent",Zh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...i}=e,s=Hh(Yh,n),o=et(n),l=m.useRef(!1);return g.jsx(JS,{id:s.contentId,"aria-labelledby":s.triggerId,...o,...i,ref:t,onCloseAutoFocus:oe(e.onCloseAutoFocus,a=>{var r;l.current||(r=s.triggerRef.current)==null||r.focus(),l.current=!1,a.preventDefault()}),onInteractOutside:oe(e.onInteractOutside,a=>{const r=a.detail.originalEvent,f=r.button===0&&r.ctrlKey===!0,d=r.button===2||f;(!s.modal||d)&&(l.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Zh.displayName=Yh;var m4="DropdownMenuGroup",qh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...i}=e,s=et(n);return g.jsx(e4,{...s,...i,ref:t})});qh.displayName=m4;var g4="DropdownMenuLabel",Gh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...i}=e,s=et(n);return g.jsx(t4,{...s,...i,ref:t})});Gh.displayName=g4;var v4="DropdownMenuItem",Kh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...i}=e,s=et(n);return g.jsx(n4,{...s,...i,ref:t})});Kh.displayName=v4;var b4="DropdownMenuCheckboxItem",Xh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...i}=e,s=et(n);return g.jsx(i4,{...s,...i,ref:t})});Xh.displayName=b4;var y4="DropdownMenuRadioGroup",Qh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...i}=e,s=et(n);return g.jsx(s4,{...s,...i,ref:t})});Qh.displayName=y4;var x4="DropdownMenuRadioItem",Jh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...i}=e,s=et(n);return g.jsx(r4,{...s,...i,ref:t})});Jh.displayName=x4;var w4="DropdownMenuItemIndicator",e0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...i}=e,s=et(n);return g.jsx(o4,{...s,...i,ref:t})});e0.displayName=w4;var _4="DropdownMenuSeparator",t0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...i}=e,s=et(n);return g.jsx(l4,{...s,...i,ref:t})});t0.displayName=_4;var C4="DropdownMenuArrow",S4=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...i}=e,s=et(n);return g.jsx(a4,{...s,...i,ref:t})});S4.displayName=C4;var E4=e=>{const{__scopeDropdownMenu:t,children:n,open:i,onOpenChange:s,defaultOpen:o}=e,l=et(t),[a,r]=wt({prop:i,defaultProp:o??!1,onChange:s,caller:"DropdownMenuSub"});return g.jsx(c4,{...l,open:a,onOpenChange:r,children:n})},N4="DropdownMenuSubTrigger",n0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...i}=e,s=et(n);return g.jsx(u4,{...s,...i,ref:t})});n0.displayName=N4;var k4="DropdownMenuSubContent",i0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...i}=e,s=et(n);return g.jsx(d4,{...s,...i,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});i0.displayName=k4;var T4=Vh,M4=$h,s0=Uh,r0=Zh,A4=qh,o0=Gh,l0=Kh,a0=Xh,R4=Qh,c0=Jh,u0=e0,d0=t0,D4=E4,f0=n0,h0=i0;const al=T4,cl=M4,L4=A4,O4=s0,P4=D4,I4=R4,p0=m.forwardRef(({className:e,inset:t,children:n,...i},s)=>g.jsxs(f0,{ref:s,className:ne("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...i,children:[n,g.jsx(_i,{className:"ml-auto h-4 w-4"})]}));p0.displayName=f0.displayName;const m0=m.forwardRef(({className:e,...t},n)=>g.jsx(h0,{ref:n,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));m0.displayName=h0.displayName;const Qs=m.forwardRef(({className:e,sideOffset:t=4,...n},i)=>g.jsx(s0,{children:g.jsx(r0,{ref:i,sideOffset:t,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Qs.displayName=r0.displayName;const bi=m.forwardRef(({className:e,inset:t,...n},i)=>g.jsx(l0,{ref:i,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));bi.displayName=l0.displayName;const g0=m.forwardRef(({className:e,children:t,checked:n,...i},s)=>g.jsxs(a0,{ref:s,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...i,children:[g.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:g.jsx(u0,{children:g.jsx(ui,{className:"h-4 w-4"})})}),t]}));g0.displayName=a0.displayName;const v0=m.forwardRef(({className:e,children:t,...n},i)=>g.jsxs(c0,{ref:i,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[g.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:g.jsx(u0,{children:g.jsx(ym,{className:"h-2 w-2 fill-current"})})}),t]}));v0.displayName=c0.displayName;const Js=m.forwardRef(({className:e,inset:t,...n},i)=>g.jsx(o0,{ref:i,className:ne("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Js.displayName=o0.displayName;const yi=m.forwardRef(({className:e,...t},n)=>g.jsx(d0,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));yi.displayName=d0.displayName;const b0=({className:e,...t})=>g.jsx("span",{className:ne("ml-auto text-xs tracking-widest opacity-60",e),...t});b0.displayName="DropdownMenuShortcut";function B4(e){const t=F4(e),n=m.forwardRef((i,s)=>{const{children:o,...l}=i,a=m.Children.toArray(o),r=a.find(z4);if(r){const f=r.props.children,d=a.map(h=>h===r?m.Children.count(f)>1?m.Children.only(null):m.isValidElement(f)?f.props.children:null:h);return g.jsx(t,{...l,ref:s,children:m.isValidElement(f)?m.cloneElement(f,void 0,d):null})}return g.jsx(t,{...l,ref:s,children:o})});return n.displayName=`${e}.Slot`,n}function F4(e){const t=m.forwardRef((n,i)=>{const{children:s,...o}=n;if(m.isValidElement(s)){const l=V4(s),a=H4(o,s.props);return s.type!==m.Fragment&&(a.ref=i?je(i,l):l),m.cloneElement(s,a)}return m.Children.count(s)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var j4=Symbol("radix.slottable");function z4(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===j4}function H4(e,t){const n={...t};for(const i in t){const s=e[i],o=t[i];/^on[A-Z]/.test(i)?s&&o?n[i]=(...a)=>{const r=o(...a);return s(...a),r}:s&&(n[i]=s):i==="style"?n[i]={...s,...o}:i==="className"&&(n[i]=[s,o].filter(Boolean).join(" "))}return{...e,...n}}function V4(e){var i,s;let t=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var W4=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Wi=W4.reduce((e,t)=>{const n=B4(`Primitive.${t}`),i=m.forwardRef((s,o)=>{const{asChild:l,...a}=s,r=l?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),g.jsx(r,{...a,ref:o})});return i.displayName=`Primitive.${t}`,{...e,[t]:i}},{});function $4(e,t=[]){let n=[];function i(o,l){const a=m.createContext(l),r=n.length;n=[...n,l];const f=h=>{var u;const{scope:v,children:_,...C}=h,S=((u=v==null?void 0:v[e])==null?void 0:u[r])||a,c=m.useMemo(()=>C,Object.values(C));return g.jsx(S.Provider,{value:c,children:_})};f.displayName=o+"Provider";function d(h,v){var S;const _=((S=v==null?void 0:v[e])==null?void 0:S[r])||a,C=m.useContext(_);if(C)return C;if(l!==void 0)return l;throw new Error(`\`${h}\` must be used within \`${o}\``)}return[f,d]}const s=()=>{const o=n.map(l=>m.createContext(l));return function(a){const r=(a==null?void 0:a[e])||o;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:r}}),[a,r])}};return s.scopeName=e,[i,U4(s,...t)]}function U4(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const l=i.reduce((a,{useScope:r,scopeName:f})=>{const h=r(o)[`__scope${f}`];return{...a,...h}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:l}),[l])}};return n.scopeName=t.scopeName,n}function Y4(e,t){return m.useReducer((n,i)=>t[n][i]??n,e)}var ul="ScrollArea",[y0]=$4(ul),[Z4,mt]=y0(ul),x0=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:i="hover",dir:s,scrollHideDelay:o=600,...l}=e,[a,r]=m.useState(null),[f,d]=m.useState(null),[h,v]=m.useState(null),[_,C]=m.useState(null),[S,c]=m.useState(null),[u,p]=m.useState(0),[b,y]=m.useState(0),[w,x]=m.useState(!1),[E,k]=m.useState(!1),N=ye(t,R=>r(R)),T=Ei(s);return g.jsx(Z4,{scope:n,type:i,dir:T,scrollHideDelay:o,scrollArea:a,viewport:f,onViewportChange:d,content:h,onContentChange:v,scrollbarX:_,onScrollbarXChange:C,scrollbarXEnabled:w,onScrollbarXEnabledChange:x,scrollbarY:S,onScrollbarYChange:c,scrollbarYEnabled:E,onScrollbarYEnabledChange:k,onCornerWidthChange:p,onCornerHeightChange:y,children:g.jsx(Wi.div,{dir:T,...l,ref:N,style:{position:"relative","--radix-scroll-area-corner-width":u+"px","--radix-scroll-area-corner-height":b+"px",...e.style}})})});x0.displayName=ul;var w0="ScrollAreaViewport",_0=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:i,nonce:s,...o}=e,l=mt(w0,n),a=m.useRef(null),r=ye(t,a,l.onViewportChange);return g.jsxs(g.Fragment,{children:[g.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),g.jsx(Wi.div,{"data-radix-scroll-area-viewport":"",...o,ref:r,style:{overflowX:l.scrollbarXEnabled?"scroll":"hidden",overflowY:l.scrollbarYEnabled?"scroll":"hidden",...e.style},children:g.jsx("div",{ref:l.onContentChange,style:{minWidth:"100%",display:"table"},children:i})})]})});_0.displayName=w0;var Ot="ScrollAreaScrollbar",dl=m.forwardRef((e,t)=>{const{forceMount:n,...i}=e,s=mt(Ot,e.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:l}=s,a=e.orientation==="horizontal";return m.useEffect(()=>(a?o(!0):l(!0),()=>{a?o(!1):l(!1)}),[a,o,l]),s.type==="hover"?g.jsx(q4,{...i,ref:t,forceMount:n}):s.type==="scroll"?g.jsx(G4,{...i,ref:t,forceMount:n}):s.type==="auto"?g.jsx(C0,{...i,ref:t,forceMount:n}):s.type==="always"?g.jsx(fl,{...i,ref:t}):null});dl.displayName=Ot;var q4=m.forwardRef((e,t)=>{const{forceMount:n,...i}=e,s=mt(Ot,e.__scopeScrollArea),[o,l]=m.useState(!1);return m.useEffect(()=>{const a=s.scrollArea;let r=0;if(a){const f=()=>{window.clearTimeout(r),l(!0)},d=()=>{r=window.setTimeout(()=>l(!1),s.scrollHideDelay)};return a.addEventListener("pointerenter",f),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(r),a.removeEventListener("pointerenter",f),a.removeEventListener("pointerleave",d)}}},[s.scrollArea,s.scrollHideDelay]),g.jsx(Ke,{present:n||o,children:g.jsx(C0,{"data-state":o?"visible":"hidden",...i,ref:t})})}),G4=m.forwardRef((e,t)=>{const{forceMount:n,...i}=e,s=mt(Ot,e.__scopeScrollArea),o=e.orientation==="horizontal",l=tr(()=>r("SCROLL_END"),100),[a,r]=Y4("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return m.useEffect(()=>{if(a==="idle"){const f=window.setTimeout(()=>r("HIDE"),s.scrollHideDelay);return()=>window.clearTimeout(f)}},[a,s.scrollHideDelay,r]),m.useEffect(()=>{const f=s.viewport,d=o?"scrollLeft":"scrollTop";if(f){let h=f[d];const v=()=>{const _=f[d];h!==_&&(r("SCROLL"),l()),h=_};return f.addEventListener("scroll",v),()=>f.removeEventListener("scroll",v)}},[s.viewport,o,r,l]),g.jsx(Ke,{present:n||a!=="hidden",children:g.jsx(fl,{"data-state":a==="hidden"?"hidden":"visible",...i,ref:t,onPointerEnter:oe(e.onPointerEnter,()=>r("POINTER_ENTER")),onPointerLeave:oe(e.onPointerLeave,()=>r("POINTER_LEAVE"))})})}),C0=m.forwardRef((e,t)=>{const n=mt(Ot,e.__scopeScrollArea),{forceMount:i,...s}=e,[o,l]=m.useState(!1),a=e.orientation==="horizontal",r=tr(()=>{if(n.viewport){const f=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;l(a?f:d)}},10);return jn(n.viewport,r),jn(n.content,r),g.jsx(Ke,{present:i||o,children:g.jsx(fl,{"data-state":o?"visible":"hidden",...s,ref:t})})}),fl=m.forwardRef((e,t)=>{const{orientation:n="vertical",...i}=e,s=mt(Ot,e.__scopeScrollArea),o=m.useRef(null),l=m.useRef(0),[a,r]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),f=T0(a.viewport,a.content),d={...i,sizes:a,onSizesChange:r,hasThumb:f>0&&f<1,onThumbChange:v=>o.current=v,onThumbPointerUp:()=>l.current=0,onThumbPointerDown:v=>l.current=v};function h(v,_){return t3(v,l.current,a,_)}return n==="horizontal"?g.jsx(K4,{...d,ref:t,onThumbPositionChange:()=>{if(s.viewport&&o.current){const v=s.viewport.scrollLeft,_=ja(v,a,s.dir);o.current.style.transform=`translate3d(${_}px, 0, 0)`}},onWheelScroll:v=>{s.viewport&&(s.viewport.scrollLeft=v)},onDragScroll:v=>{s.viewport&&(s.viewport.scrollLeft=h(v,s.dir))}}):n==="vertical"?g.jsx(X4,{...d,ref:t,onThumbPositionChange:()=>{if(s.viewport&&o.current){const v=s.viewport.scrollTop,_=ja(v,a);o.current.style.transform=`translate3d(0, ${_}px, 0)`}},onWheelScroll:v=>{s.viewport&&(s.viewport.scrollTop=v)},onDragScroll:v=>{s.viewport&&(s.viewport.scrollTop=h(v))}}):null}),K4=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:i,...s}=e,o=mt(Ot,e.__scopeScrollArea),[l,a]=m.useState(),r=m.useRef(null),f=ye(t,r,o.onScrollbarXChange);return m.useEffect(()=>{r.current&&a(getComputedStyle(r.current))},[r]),g.jsx(E0,{"data-orientation":"horizontal",...s,ref:f,sizes:n,style:{bottom:0,left:o.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:o.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":er(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,h)=>{if(o.viewport){const v=o.viewport.scrollLeft+d.deltaX;e.onWheelScroll(v),A0(v,h)&&d.preventDefault()}},onResize:()=>{r.current&&o.viewport&&l&&i({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:r.current.clientWidth,paddingStart:ps(l.paddingLeft),paddingEnd:ps(l.paddingRight)}})}})}),X4=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:i,...s}=e,o=mt(Ot,e.__scopeScrollArea),[l,a]=m.useState(),r=m.useRef(null),f=ye(t,r,o.onScrollbarYChange);return m.useEffect(()=>{r.current&&a(getComputedStyle(r.current))},[r]),g.jsx(E0,{"data-orientation":"vertical",...s,ref:f,sizes:n,style:{top:0,right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":er(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,h)=>{if(o.viewport){const v=o.viewport.scrollTop+d.deltaY;e.onWheelScroll(v),A0(v,h)&&d.preventDefault()}},onResize:()=>{r.current&&o.viewport&&l&&i({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:r.current.clientHeight,paddingStart:ps(l.paddingTop),paddingEnd:ps(l.paddingBottom)}})}})}),[Q4,S0]=y0(Ot),E0=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:i,hasThumb:s,onThumbChange:o,onThumbPointerUp:l,onThumbPointerDown:a,onThumbPositionChange:r,onDragScroll:f,onWheelScroll:d,onResize:h,...v}=e,_=mt(Ot,n),[C,S]=m.useState(null),c=ye(t,N=>S(N)),u=m.useRef(null),p=m.useRef(""),b=_.viewport,y=i.content-i.viewport,w=Ze(d),x=Ze(r),E=tr(h,10);function k(N){if(u.current){const T=N.clientX-u.current.left,R=N.clientY-u.current.top;f({x:T,y:R})}}return m.useEffect(()=>{const N=T=>{const R=T.target;(C==null?void 0:C.contains(R))&&w(T,y)};return document.addEventListener("wheel",N,{passive:!1}),()=>document.removeEventListener("wheel",N,{passive:!1})},[b,C,y,w]),m.useEffect(x,[i,x]),jn(C,E),jn(_.content,E),g.jsx(Q4,{scope:n,scrollbar:C,hasThumb:s,onThumbChange:Ze(o),onThumbPointerUp:Ze(l),onThumbPositionChange:x,onThumbPointerDown:Ze(a),children:g.jsx(Wi.div,{...v,ref:c,style:{position:"absolute",...v.style},onPointerDown:oe(e.onPointerDown,N=>{N.button===0&&(N.target.setPointerCapture(N.pointerId),u.current=C.getBoundingClientRect(),p.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",_.viewport&&(_.viewport.style.scrollBehavior="auto"),k(N))}),onPointerMove:oe(e.onPointerMove,k),onPointerUp:oe(e.onPointerUp,N=>{const T=N.target;T.hasPointerCapture(N.pointerId)&&T.releasePointerCapture(N.pointerId),document.body.style.webkitUserSelect=p.current,_.viewport&&(_.viewport.style.scrollBehavior=""),u.current=null})})})}),hs="ScrollAreaThumb",N0=m.forwardRef((e,t)=>{const{forceMount:n,...i}=e,s=S0(hs,e.__scopeScrollArea);return g.jsx(Ke,{present:n||s.hasThumb,children:g.jsx(J4,{ref:t,...i})})}),J4=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:i,...s}=e,o=mt(hs,n),l=S0(hs,n),{onThumbPositionChange:a}=l,r=ye(t,h=>l.onThumbChange(h)),f=m.useRef(void 0),d=tr(()=>{f.current&&(f.current(),f.current=void 0)},100);return m.useEffect(()=>{const h=o.viewport;if(h){const v=()=>{if(d(),!f.current){const _=n3(h,a);f.current=_,a()}};return a(),h.addEventListener("scroll",v),()=>h.removeEventListener("scroll",v)}},[o.viewport,d,a]),g.jsx(Wi.div,{"data-state":l.hasThumb?"visible":"hidden",...s,ref:r,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...i},onPointerDownCapture:oe(e.onPointerDownCapture,h=>{const _=h.target.getBoundingClientRect(),C=h.clientX-_.left,S=h.clientY-_.top;l.onThumbPointerDown({x:C,y:S})}),onPointerUp:oe(e.onPointerUp,l.onThumbPointerUp)})});N0.displayName=hs;var hl="ScrollAreaCorner",k0=m.forwardRef((e,t)=>{const n=mt(hl,e.__scopeScrollArea),i=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&i?g.jsx(e3,{...e,ref:t}):null});k0.displayName=hl;var e3=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...i}=e,s=mt(hl,n),[o,l]=m.useState(0),[a,r]=m.useState(0),f=!!(o&&a);return jn(s.scrollbarX,()=>{var h;const d=((h=s.scrollbarX)==null?void 0:h.offsetHeight)||0;s.onCornerHeightChange(d),r(d)}),jn(s.scrollbarY,()=>{var h;const d=((h=s.scrollbarY)==null?void 0:h.offsetWidth)||0;s.onCornerWidthChange(d),l(d)}),f?g.jsx(Wi.div,{...i,ref:t,style:{width:o,height:a,position:"absolute",right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function ps(e){return e?parseInt(e,10):0}function T0(e,t){const n=e/t;return isNaN(n)?0:n}function er(e){const t=T0(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,i=(e.scrollbar.size-n)*t;return Math.max(i,18)}function t3(e,t,n,i="ltr"){const s=er(n),o=s/2,l=t||o,a=s-l,r=n.scrollbar.paddingStart+l,f=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,h=i==="ltr"?[0,d]:[d*-1,0];return M0([r,f],h)(e)}function ja(e,t,n="ltr"){const i=er(t),s=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,o=t.scrollbar.size-s,l=t.content-t.viewport,a=o-i,r=n==="ltr"?[0,l]:[l*-1,0],f=Rr(e,r);return M0([0,l],[0,a])(f)}function M0(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const i=(t[1]-t[0])/(e[1]-e[0]);return t[0]+i*(n-e[0])}}function A0(e,t){return e>0&&e<t}var n3=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},i=0;return function s(){const o={left:e.scrollLeft,top:e.scrollTop},l=n.left!==o.left,a=n.top!==o.top;(l||a)&&t(),n=o,i=window.requestAnimationFrame(s)}(),()=>window.cancelAnimationFrame(i)};function tr(e,t){const n=Ze(e),i=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(i.current),[]),m.useCallback(()=>{window.clearTimeout(i.current),i.current=window.setTimeout(n,t)},[n,t])}function jn(e,t){const n=Ze(t);$e(()=>{let i=0;if(e){const s=new ResizeObserver(()=>{cancelAnimationFrame(i),i=window.requestAnimationFrame(n)});return s.observe(e),()=>{window.cancelAnimationFrame(i),s.unobserve(e)}}},[e,n])}var R0=x0,i3=_0,s3=k0;const D0=m.forwardRef(({className:e,children:t,...n},i)=>g.jsxs(R0,{ref:i,className:ne("relative overflow-hidden",e),...n,children:[g.jsx(i3,{className:"h-full w-full rounded-[inherit]",children:t}),g.jsx(pl,{}),g.jsx(s3,{})]}));D0.displayName=R0.displayName;const pl=m.forwardRef(({className:e,orientation:t="vertical",...n},i)=>g.jsx(dl,{ref:i,orientation:t,className:ne("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:g.jsx(N0,{className:"relative flex-1 rounded-full bg-border"})}));pl.displayName=dl.displayName;const L0=bs("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",success:"border-green-500/50 text-green-700 dark:text-green-400 [&>svg]:text-green-500",warning:"border-yellow-500/50 text-yellow-700 dark:text-yellow-400 [&>svg]:text-yellow-500",info:"border-blue-500/50 text-blue-700 dark:text-blue-400 [&>svg]:text-blue-500"}},defaultVariants:{variant:"default"}}),ml=m.forwardRef(({className:e,variant:t,...n},i)=>g.jsx("div",{ref:i,role:"alert",className:ne(L0({variant:t}),e),...n}));ml.displayName="Alert";const gl=m.forwardRef(({className:e,...t},n)=>g.jsx("h5",{ref:n,className:ne("mb-1 font-medium leading-none tracking-tight",e),...t}));gl.displayName="AlertTitle";const vl=m.forwardRef(({className:e,...t},n)=>g.jsx("div",{ref:n,className:ne("text-sm [&_p]:leading-relaxed",e),...t}));vl.displayName="AlertDescription";const O0=m.forwardRef(({variant:e,title:t,children:n,className:i,...s},o)=>{const l={default:Yl,destructive:bm,success:vm,warning:gm,info:Yl},a=l[e]||l.default;return g.jsxs(ml,{ref:o,variant:e,className:i,...s,children:[g.jsx(a,{className:"h-4 w-4"}),t&&g.jsx(gl,{children:t}),n&&g.jsx(vl,{children:n})]})});O0.displayName="AlertWithIcon";const bl=m.forwardRef(({className:e,...t},n)=>g.jsx("div",{className:"relative w-full overflow-auto",children:g.jsx("table",{ref:n,className:ne("w-full caption-bottom text-sm",e),...t})}));bl.displayName="Table";const yl=m.forwardRef(({className:e,...t},n)=>g.jsx("thead",{ref:n,className:ne("[&_tr]:border-b",e),...t}));yl.displayName="TableHeader";const xl=m.forwardRef(({className:e,...t},n)=>g.jsx("tbody",{ref:n,className:ne("[&_tr:last-child]:border-0",e),...t}));xl.displayName="TableBody";const P0=m.forwardRef(({className:e,...t},n)=>g.jsx("tfoot",{ref:n,className:ne("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));P0.displayName="TableFooter";const En=m.forwardRef(({className:e,...t},n)=>g.jsx("tr",{ref:n,className:ne("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...t}));En.displayName="TableRow";const li=m.forwardRef(({className:e,...t},n)=>g.jsx("th",{ref:n,className:ne("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",e),...t}));li.displayName="TableHead";const ln=m.forwardRef(({className:e,...t},n)=>g.jsx("td",{ref:n,className:ne("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));ln.displayName="TableCell";const I0=m.forwardRef(({className:e,...t},n)=>g.jsx("caption",{ref:n,className:ne("mt-4 text-sm text-muted-foreground",e),...t}));I0.displayName="TableCaption";const wl=m.forwardRef(({options:e=[],value:t,onChange:n,onSearch:i,placeholder:s="Select...",searchPlaceholder:o="Search...",loading:l=!1,disabled:a=!1,multiple:r=!1,clearable:f=!0,className:d,renderOption:h,renderValue:v,getOptionLabel:_=y=>y?typeof y=="string"||typeof y=="number"?String(y):(y==null?void 0:y.label)||(y==null?void 0:y.name)||(y==null?void 0:y.title)||(y==null?void 0:y.display_name)||JSON.stringify(y):"",getOptionValue:C=y=>(y==null?void 0:y.value)||(y==null?void 0:y.id)||y,filterOption:S,noOptionsMessage:c="No options found",loadingMessage:u="Loading...",...p},b)=>{const[y,w]=m.useState(!1),[x,E]=m.useState(""),[k,N]=m.useState(0),T=m.useRef(null),R=m.useRef(null),M=m.useMemo(()=>x?S?e.filter(B=>S(B,x)):e.filter(B=>_(B).toLowerCase().includes(x.toLowerCase())):e,[e,x,S,_]),A=m.useMemo(()=>uc(B=>{i==null||i(B)},300),[i]),D=B=>{const L=B.target.value;E(L),N(0),A(L)},$=B=>{if(r){const L=Array.isArray(t)?t:[],U=C(B);L.some(W=>C(W)===U)?n==null||n(L.filter(W=>C(W)!==U)):n==null||n([...L,B])}else n==null||n(B),w(!1),E("")},H=B=>{B.stopPropagation(),n==null||n(r?[]:null),E("")},j=B=>{if(!y){(B.key==="Enter"||B.key===" "||B.key==="ArrowDown")&&(B.preventDefault(),w(!0));return}switch(B.key){case"ArrowDown":B.preventDefault(),N(L=>Math.min(L+1,M.length-1));break;case"ArrowUp":B.preventDefault(),N(L=>Math.max(L-1,0));break;case"Enter":B.preventDefault(),M[k]&&$(M[k]);break;case"Escape":B.preventDefault(),w(!1),E("");break}};m.useEffect(()=>{const B=L=>{T.current&&!T.current.contains(L.target)&&(w(!1),E(""))};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[]);const F=B=>r?(Array.isArray(t)?t:[]).some(O=>(typeof O=="object"&&O!==null?C(O):O)===C(B)):t?(typeof t=="object"&&t!==null?C(t):t)===C(B):!1,z=r?Array.isArray(t)&&t.length>0:!!t,P=()=>{if(!z)return g.jsx("span",{className:"text-muted-foreground",children:s});if(v)return v(t);if(r){const L=Array.isArray(t)?t:[];if(L.length===1){const U=L[0],O=e.find(W=>{const Q=C(W),V=typeof U=="object"&&U!==null?C(U):U;return Q===V});return O?_(O):String(U)}return`${L.length} selected`}const B=e.find(L=>{const U=C(L),O=typeof t=="object"&&t!==null?C(t):t;return U===O});return B?_(B):String(t)};return g.jsxs("div",{ref:T,className:ne("relative w-full",d),...p,children:[g.jsxs("button",{ref:b,type:"button",role:"combobox","aria-expanded":y,"aria-haspopup":"listbox",disabled:a,onClick:()=>w(!y),onKeyDown:j,className:ne("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",y&&"ring-2 ring-ring ring-offset-2"),children:[g.jsx("span",{className:"flex-1 text-left truncate",children:P()}),g.jsxs("div",{className:"flex items-center gap-1",children:[f&&z&&!a&&g.jsx(Mn,{className:"h-4 w-4 opacity-50 hover:opacity-100 cursor-pointer",onClick:H}),g.jsx(ys,{className:ne("h-4 w-4 opacity-50 transition-transform",y&&"rotate-180")})]})]}),y&&g.jsxs("div",{className:"absolute z-50 mt-1 w-full rounded-md border bg-popover text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95",children:[g.jsxs("div",{className:"flex items-center border-b px-3",children:[g.jsx(to,{className:"h-4 w-4 shrink-0 opacity-50"}),g.jsx("input",{ref:R,type:"text",value:x,onChange:D,placeholder:o,className:"flex h-10 w-full bg-transparent py-3 pl-2 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",autoFocus:!0}),l&&g.jsx(un,{className:"h-4 w-4 animate-spin"})]}),g.jsx("div",{className:"max-h-60 overflow-auto p-1",children:l&&M.length===0?g.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:u}):M.length===0?g.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:c}):M.map((B,L)=>g.jsxs("div",{role:"option","aria-selected":F(B),onClick:()=>$(B),onMouseEnter:()=>N(L),className:ne("relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none",k===L&&"bg-accent text-accent-foreground",F(B)&&"bg-accent/50"),children:[r&&g.jsx("div",{className:ne("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",F(B)&&"bg-primary text-primary-foreground"),children:F(B)&&g.jsx(ui,{className:"h-3 w-3"})}),h?h(B):g.jsx("span",{className:"flex-1",children:_(B)}),!r&&F(B)&&g.jsx(ui,{className:"ml-auto h-4 w-4"})]},C(B)))})]})]})});wl.displayName="SearchSelect";const $t=m.forwardRef(({className:e,label:t,description:n,error:i,required:s,children:o,...l},a)=>{const r=m.useId();return g.jsxs("div",{ref:a,className:ne("space-y-2",e),...l,children:[t&&g.jsxs(Kt,{htmlFor:r,className:ne(i&&"text-destructive"),children:[t,s&&g.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),m.Children.map(o,f=>m.isValidElement(f)?m.cloneElement(f,{id:r,"aria-invalid":!!i}):f),n&&!i&&g.jsx("p",{className:"text-sm text-muted-foreground",children:n}),i&&g.jsx("p",{className:"text-sm text-destructive",children:i})]})});$t.displayName="FormField";const ms=m.forwardRef(({label:e,description:t,error:n,required:i,className:s,inputClassName:o,onChange:l,...a},r)=>{const f=d=>{l==null||l(d.target.value)};return g.jsx($t,{label:e,description:t,error:n,required:i,className:s,children:g.jsx(Ln,{ref:r,className:ne(n&&"border-destructive",o),onChange:f,...a})})});ms.displayName="QInput";const _l=m.forwardRef(({label:e,description:t,error:n,required:i,className:s,textareaClassName:o,onChange:l,...a},r)=>{const f=d=>{l==null||l(d.target.value)};return g.jsx($t,{label:e,description:t,error:n,required:i,className:s,children:g.jsx(no,{ref:r,className:ne(n&&"border-destructive",o),onChange:f,...a})})});_l.displayName="QTextarea";const Cl=m.forwardRef(({label:e,description:t,error:n,required:i,options:s=[],placeholder:o="Select...",className:l,value:a,onChange:r,getOptionLabel:f,getOptionValue:d,optionLabel:h,optionValue:v,..._},C)=>{const S=f||(typeof h=="function"?h:h?u=>u==null?void 0:u[h]:u=>u?typeof u=="string"||typeof u=="number"?String(u):(u==null?void 0:u.label)||(u==null?void 0:u.name)||(u==null?void 0:u.title)||(u==null?void 0:u.display_name)||JSON.stringify(u):""),c=d||(typeof v=="function"?v:v?u=>u==null?void 0:u[v]:u=>(u==null?void 0:u.value)||(u==null?void 0:u.id)||u);return g.jsx($t,{label:e,description:t,error:n,required:i,className:l,children:g.jsxs(xo,{value:a,onValueChange:r,..._,children:[g.jsx(Os,{ref:C,className:ne(n&&"border-destructive"),children:g.jsx(wo,{placeholder:o})}),g.jsx(Ps,{children:s.map(u=>g.jsx(Is,{value:String(c(u)),children:S(u)},c(u)))})]})})});Cl.displayName="QSelect";const Sl=m.forwardRef(({label:e,description:t,error:n,required:i,className:s,value:o,onChange:l,getOptionLabel:a,getOptionValue:r,optionLabel:f,optionValue:d,...h},v)=>{const _=a||(typeof f=="function"?f:f?c=>c==null?void 0:c[f]:c=>c?typeof c=="string"||typeof c=="number"?String(c):(c==null?void 0:c.label)||(c==null?void 0:c.name)||(c==null?void 0:c.title)||(c==null?void 0:c.display_name)||JSON.stringify(c):""),C=r||(typeof d=="function"?d:d?c=>c==null?void 0:c[d]:c=>(c==null?void 0:c.value)||(c==null?void 0:c.id)||c),S=c=>{if(c==null)l==null||l(null);else{const u=C(c);l==null||l(u)}};return g.jsx($t,{label:e,description:t,error:n,required:i,className:s,children:g.jsx(wl,{ref:v,value:o,onChange:S,getOptionLabel:_,getOptionValue:C,...h})})});Sl.displayName="QSearchSelect";const El=m.forwardRef(({label:e,description:t,error:n,className:i,checked:s,onCheckedChange:o,onChange:l,...a},r)=>{const f=m.useId(),d=h=>{l==null||l(h),o==null||o(h)};return g.jsxs("div",{className:ne("flex items-center justify-between space-x-2",i),children:[g.jsxs("div",{className:"space-y-0.5",children:[e&&g.jsx(Kt,{htmlFor:f,className:"text-base",children:e}),t&&g.jsx("p",{className:"text-sm text-muted-foreground",children:t}),n&&g.jsx("p",{className:"text-sm text-destructive",children:n})]}),g.jsx(ao,{ref:r,id:f,checked:s,onCheckedChange:d,...a})]})});El.displayName="QSwitch";const Nl=m.forwardRef(({label:e,description:t,error:n,className:i,checked:s,onCheckedChange:o,...l},a)=>{const r=m.useId();return g.jsxs("div",{className:ne("flex items-start space-x-2",i),children:[g.jsx(On,{ref:a,id:r,checked:s,onCheckedChange:o,className:"mt-1",...l}),g.jsxs("div",{className:"space-y-1 leading-none",children:[e&&g.jsx(Kt,{htmlFor:r,children:e}),t&&g.jsx("p",{className:"text-sm text-muted-foreground",children:t}),n&&g.jsx("p",{className:"text-sm text-destructive",children:n})]})]})});Nl.displayName="QCheckbox";const B0=m.forwardRef(({onSubmit:e,className:t,children:n,...i},s)=>{const o=l=>{l.preventDefault(),e==null||e(l)};return g.jsx("form",{ref:s,onSubmit:o,className:ne("space-y-4",t),...i,children:n})});B0.displayName="QForm";const F0=m.forwardRef(({label:e,description:t,error:n,required:i,className:s,value:o,onChange:l,placeholder:a="Pick a date",...r},f)=>g.jsx($t,{label:e,description:t,error:n,required:i,className:s,children:g.jsx(Go,{ref:f,date:o,onDateChange:l,placeholder:a,...r})}));F0.displayName="QDatePicker";const j0=m.forwardRef(({label:e,description:t,error:n,required:i,className:s,value:o,onChange:l,placeholder:a="Pick a date range",...r},f)=>g.jsx($t,{label:e,description:t,error:n,required:i,className:s,children:g.jsx(Ko,{ref:f,dateRange:o,onDateRangeChange:l,placeholder:a,...r})}));j0.displayName="QDateRangePicker";const z0=m.forwardRef(({label:e,description:t,error:n,required:i,className:s,value:o,onChange:l,placeholder:a="Start writing...",height:r="200px",...f},d)=>g.jsx($t,{label:e,description:t,error:n,required:i,className:s,children:g.jsx(Jo,{ref:d,value:o,onChange:l,placeholder:a,height:r,...f})}));z0.displayName="QRichTextEditor";const kl=({currentPage:e=1,totalPages:t=1,totalItems:n=0,pageSize:i=10,pageSizeOptions:s=[10,20,50,100],onPageChange:o,onPageSizeChange:l,showPageSizeSelector:a=!0,showInfo:r=!0,className:f})=>{const d=(e-1)*i+1,h=Math.min(e*i,n),v=e>1,_=e<t,C=()=>{const S=[];if(t<=5)for(let u=1;u<=t;u++)S.push(u);else{S.push(1),e>3&&S.push("...");const u=Math.max(2,e-1),p=Math.min(t-1,e+1);for(let b=u;b<=p;b++)S.push(b);e<t-2&&S.push("..."),t>1&&S.push(t)}return S};return g.jsxs("div",{className:ne("flex flex-col sm:flex-row items-center justify-between gap-4 px-2 py-4",f),children:[g.jsxs("div",{className:"flex items-center gap-4",children:[a&&g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("span",{className:"text-sm text-muted-foreground",children:"Rows per page"}),g.jsxs(xo,{value:String(i),onValueChange:S=>l==null?void 0:l(Number(S)),children:[g.jsx(Os,{className:"h-8 w-[70px]",children:g.jsx(wo,{placeholder:i})}),g.jsx(Ps,{side:"top",children:s.map(S=>g.jsx(Is,{value:String(S),children:S},S))})]})]}),r&&n>0&&g.jsxs("span",{className:"text-sm text-muted-foreground",children:["Showing ",d," to ",h," of ",n," results"]})]}),g.jsxs("div",{className:"flex items-center gap-1",children:[g.jsxs(we,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>o==null?void 0:o(1),disabled:!v,children:[g.jsx(pm,{className:"h-4 w-4"}),g.jsx("span",{className:"sr-only",children:"First page"})]}),g.jsxs(we,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>o==null?void 0:o(e-1),disabled:!v,children:[g.jsx(eo,{className:"h-4 w-4"}),g.jsx("span",{className:"sr-only",children:"Previous page"})]}),g.jsx("div",{className:"flex items-center gap-1",children:C().map((S,c)=>S==="..."?g.jsx("span",{className:"px-2 text-muted-foreground",children:"..."},`ellipsis-${c}`):g.jsx(we,{variant:e===S?"default":"outline",size:"icon",className:"h-8 w-8",onClick:()=>o==null?void 0:o(S),children:S},S))}),g.jsxs(we,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>o==null?void 0:o(e+1),disabled:!_,children:[g.jsx(_i,{className:"h-4 w-4"}),g.jsx("span",{className:"sr-only",children:"Next page"})]}),g.jsxs(we,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>o==null?void 0:o(t),disabled:!_,children:[g.jsx(mm,{className:"h-4 w-4"}),g.jsx("span",{className:"sr-only",children:"Last page"})]})]})]})};kl.displayName="Pagination";const zn=({variant:e="spinner",size:t="default",text:n,className:i,fullScreen:s=!1,overlay:o=!1})=>{const l={sm:"h-4 w-4",default:"h-8 w-8",lg:"h-12 w-12",xl:"h-16 w-16"},a=ne("flex flex-col items-center justify-center gap-3",s&&"fixed inset-0 z-50",o&&"bg-background/80 backdrop-blur-sm",i),r=()=>{switch(e){case"spinner":return g.jsx(un,{className:ne("animate-spin text-primary",l[t])});case"dots":return g.jsx("div",{className:"flex gap-1",children:[0,1,2].map(f=>g.jsx("div",{className:ne("rounded-full bg-primary animate-bounce",t==="sm"&&"h-1.5 w-1.5",t==="default"&&"h-2 w-2",t==="lg"&&"h-3 w-3",t==="xl"&&"h-4 w-4"),style:{animationDelay:`${f*.15}s`}},f))});case"pulse":return g.jsx("div",{className:ne("rounded-full bg-primary animate-pulse",l[t])});case"skeleton":return g.jsxs("div",{className:"space-y-3 w-full max-w-sm",children:[g.jsx("div",{className:"h-4 bg-muted rounded animate-pulse"}),g.jsx("div",{className:"h-4 bg-muted rounded animate-pulse w-3/4"}),g.jsx("div",{className:"h-4 bg-muted rounded animate-pulse w-1/2"})]});default:return g.jsx(un,{className:ne("animate-spin text-primary",l[t])})}};return g.jsxs("div",{className:a,children:[r(),n&&g.jsx("p",{className:"text-sm text-muted-foreground animate-pulse",children:n})]})};zn.displayName="Loading";const H0=({loading:e,children:t,text:n,className:i})=>g.jsxs("div",{className:ne("relative",i),children:[t,e&&g.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/80 backdrop-blur-sm rounded-lg",children:g.jsx(zn,{text:n})})]});H0.displayName="LoadingOverlay";const V0=m.forwardRef(({loading:e,loadingText:t,children:n,disabled:i,className:s,...o},l)=>g.jsx(we,{ref:l,disabled:i||e,className:s,...o,children:e?g.jsxs(g.Fragment,{children:[g.jsx(un,{className:"mr-2 h-4 w-4 animate-spin"}),t||"Loading..."]}):n}));V0.displayName="LoadingButton";const Gn=({icon:e=Ul,title:t="No data found",description:n="There are no items to display.",action:i,actionLabel:s,onAction:o,variant:l="default",className:a,children:r})=>{const f={default:{icon:Ul,title:"No data found",description:"There are no items to display."},search:{icon:to,title:"No results found",description:"Try adjusting your search or filters to find what you're looking for."},empty:{icon:fc,title:"Get started",description:"Create your first item to get started."},error:{icon:hc,title:"Something went wrong",description:"There was an error loading the data. Please try again."}},d=f[l]||f.default,h=e||d.icon,v=t||d.title,_=n||d.description;return g.jsxs("div",{className:ne("flex flex-col items-center justify-center py-12 px-4 text-center",a),children:[g.jsx("div",{className:"rounded-full bg-muted p-4 mb-4",children:g.jsx(h,{className:"h-8 w-8 text-muted-foreground"})}),g.jsx("h3",{className:"text-lg font-semibold mb-2",children:v}),g.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-sm",children:_}),r,(i||o)&&g.jsx(we,{onClick:o,children:s||"Take Action"})]})};Gn.displayName="EmptyState";const Tl=({searchTerm:e,onClear:t,className:n})=>g.jsx(Gn,{variant:"search",title:`No results for "${e}"`,description:"Try searching with different keywords or check your filters.",className:n,children:t&&g.jsx(we,{variant:"outline",onClick:t,children:"Clear Search"})});Tl.displayName="SearchEmptyState";const W0=({itemName:e="item",onCreate:t,className:n})=>g.jsx(Gn,{variant:"empty",icon:fc,title:`No ${e}s yet`,description:`Create your first ${e} to get started.`,onAction:t,actionLabel:`Create ${e}`,className:n});W0.displayName="CreateEmptyState";const $0=({error:e,onRetry:t,className:n})=>g.jsx(Gn,{variant:"error",title:"Error loading data",description:(e==null?void 0:e.message)||"Something went wrong. Please try again.",onAction:t,actionLabel:"Try Again",className:n});$0.displayName="ErrorState";const nr=({open:e,onOpenChange:t,title:n,description:i,children:s,footer:o,size:l="default",showClose:a=!0,className:r,...f})=>{const d={sm:"max-w-sm",default:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-[95vw]"};return g.jsx(Sd,{open:e,onOpenChange:t,...f,children:g.jsxs(To,{className:ne(d[l],r),children:[(n||i)&&g.jsxs(Mo,{children:[n&&g.jsx(Ao,{children:n}),i&&g.jsx(Ro,{children:i})]}),s,o&&g.jsx(Fs,{children:o})]})})};nr.displayName="Modal";const Ml=({open:e,onOpenChange:t,onConfirm:n,onCancel:i,title:s="Are you sure?",description:o="This action cannot be undone.",confirmText:l="Confirm",cancelText:a="Cancel",variant:r="default",loading:f=!1,className:d})=>{const h=async()=>{await(n==null?void 0:n())},v=()=>{i==null||i(),t==null||t(!1)};return g.jsx(nr,{open:e,onOpenChange:t,title:s,description:o,size:"sm",className:d,footer:g.jsxs("div",{className:"flex gap-2 justify-end",children:[g.jsx(we,{variant:"outline",onClick:v,disabled:f,children:a}),g.jsx(we,{variant:r==="destructive"?"destructive":"default",onClick:h,disabled:f,children:f?"Loading...":l})]})})};Ml.displayName="ConfirmModal";const xi=({open:e,onOpenChange:t,onConfirm:n,itemName:i="item",loading:s=!1})=>g.jsx(Ml,{open:e,onOpenChange:t,onConfirm:n,title:`Delete ${i}?`,description:`Are you sure you want to delete this ${i}? This action cannot be undone.`,confirmText:"Delete",variant:"destructive",loading:s});xi.displayName="DeleteConfirmModal";const U0=({open:e,onOpenChange:t,onSubmit:n,title:i,description:s,children:o,submitText:l="Save",cancelText:a="Cancel",loading:r=!1,size:f="default",className:d})=>{const h=async v=>{v==null||v.preventDefault(),await(n==null?void 0:n())};return g.jsx(nr,{open:e,onOpenChange:t,title:i,description:s,size:f,className:d,children:g.jsxs("form",{onSubmit:h,children:[g.jsx("div",{className:"py-4",children:o}),g.jsxs(Fs,{children:[g.jsx(we,{type:"button",variant:"outline",onClick:()=>t==null?void 0:t(!1),disabled:r,children:a}),g.jsx(we,{type:"submit",disabled:r,children:r?"Saving...":l})]})]})})};U0.displayName="FormModal";const Al=({data:e=[],columns:t=[],loading:n=!1,error:i=null,pagination:s=null,currentPage:o=1,pageSize:l=10,totalItems:a=0,totalPages:r=1,onPageChange:f,onPageSizeChange:d,sortable:h=!0,sortColumn:v=null,sortDirection:_=null,onSort:C,searchable:S=!0,searchValue:c="",onSearchChange:u,searchPlaceholder:p="Search...",selectable:b=!1,selectedRows:y=[],onSelectionChange:w,actions:x=[],onRowClick:E,striped:k=!1,hover:N=!0,compact:T=!1,className:R,emptyTitle:M="No data found",emptyDescription:A="There are no items to display.",emptyAction:D,onEmptyAction:$,getRowKey:H=j=>j.id||j._id})=>{const[j,F]=m.useState(c);m.useEffect(()=>{const V=setTimeout(()=>{u&&j!==c&&u(j)},300);return()=>clearTimeout(V)},[j]);const z=V=>{if(!h||!V.sortable)return;const X=V.sortKey||V.accessor;let Z="asc";v===X&&(Z=_==="asc"?"desc":"asc"),C==null||C(X,Z)},P=V=>{V?w==null||w(e.map(H)):w==null||w([])},B=(V,X)=>{X?w==null||w([...y,V]):w==null||w(y.filter(Z=>Z!==V))},L=e.length>0&&y.length===e.length,U=y.length>0&&y.length<e.length,O=(V,X,Z)=>{const G=V.accessor||V.key,J=G?typeof G=="function"?G(X):X[G]:void 0;return V.render?V.render(J,X,Z):V.format?V.format(J,X):J!==null&&typeof J=="object"?"-":J??"-"},W=V=>{if(!h||!V.sortable)return null;const X=V.sortKey||V.accessor;return v!==X?g.jsx(dm,{className:"ml-2 h-4 w-4 opacity-50"}):_==="asc"?g.jsx(fm,{className:"ml-2 h-4 w-4"}):g.jsx(um,{className:"ml-2 h-4 w-4"})},Q=V=>{if(!x||x.length===0)return null;const X=x.filter(Z=>Z.hidden?typeof Z.hidden=="function"?!Z.hidden(V):!Z.hidden:!0);return X.length===0?null:g.jsxs(al,{children:[g.jsx(cl,{asChild:!0,children:g.jsxs(we,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[g.jsx(wm,{className:"h-4 w-4"}),g.jsx("span",{className:"sr-only",children:"Open menu"})]})}),g.jsxs(Qs,{align:"end",children:[g.jsx(Js,{children:"Actions"}),g.jsx(yi,{}),X.map((Z,G)=>g.jsxs(bi,{onClick:()=>{var J;return(J=Z.onClick)==null?void 0:J.call(Z,V)},className:ne(Z.variant==="destructive"&&"text-destructive focus:text-destructive"),disabled:Z.disabled,children:[Z.icon&&g.jsx(Z.icon,{className:"mr-2 h-4 w-4"}),Z.label]},Z.label||G))]})]})};return g.jsxs("div",{className:ne("w-full",R),children:[(S||y.length>0)&&g.jsxs("div",{className:"flex items-center justify-between gap-4 mb-4",children:[S&&g.jsxs("div",{className:"relative max-w-sm",children:[g.jsx(to,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),g.jsx(Ln,{placeholder:p,value:j,onChange:V=>F(V.target.value),className:"pl-9 pr-9"}),j&&g.jsx("button",{onClick:()=>{F(""),u==null||u("")},className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:g.jsx(Mn,{className:"h-4 w-4"})})]}),b&&y.length>0&&g.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[y.length," row(s) selected",g.jsx(we,{variant:"ghost",size:"sm",onClick:()=>w==null?void 0:w([]),children:"Clear selection"})]})]}),g.jsx("div",{className:"rounded-md border",children:g.jsxs(bl,{children:[g.jsx(yl,{children:g.jsxs(En,{children:[b&&g.jsx(li,{className:"w-12",children:g.jsx(On,{checked:L,indeterminate:U,onCheckedChange:P})}),t.map((V,X)=>g.jsx(li,{className:ne(V.headerClassName,h&&V.sortable&&"cursor-pointer select-none"),style:{width:V.width},onClick:()=>z(V),children:g.jsxs("div",{className:"flex items-center",children:[V.header||V.label,W(V)]})},V.accessor||X)),x&&x.length>0&&g.jsx(li,{className:"w-12",children:"Actions"})]})}),g.jsx(xl,{children:n?g.jsx(En,{children:g.jsx(ln,{colSpan:t.length+(b?1:0)+(x!=null&&x.length?1:0),className:"h-48",children:g.jsx(zn,{text:"Loading data..."})})}):e.length===0?g.jsx(En,{children:g.jsx(ln,{colSpan:t.length+(b?1:0)+(x!=null&&x.length?1:0),className:"h-48",children:j?g.jsx(Tl,{searchTerm:j,onClear:()=>{F(""),u==null||u("")}}):g.jsx(Gn,{title:M,description:A,onAction:$,actionLabel:D})})}):e.map((V,X)=>{const Z=H(V),G=y.includes(Z);return g.jsxs(En,{"data-state":G?"selected":void 0,className:ne(k&&X%2===1&&"bg-muted/50",N&&"cursor-pointer",E&&"hover:bg-muted"),onClick:()=>E==null?void 0:E(V),children:[b&&g.jsx(ln,{onClick:J=>J.stopPropagation(),children:g.jsx(On,{checked:G,onCheckedChange:J=>B(Z,J)})}),t.map((J,ee)=>g.jsx(ln,{className:ne(T&&"py-2",J.cellClassName),children:O(J,V,X)},J.accessor||ee)),x&&x.length>0&&g.jsx(ln,{onClick:J=>J.stopPropagation(),children:Q(V)})]},Z)})})]})}),!n&&e.length>0&&s!==!1&&g.jsx(kl,{currentPage:o,totalPages:r,totalItems:a,pageSize:l,onPageChange:f,onPageSizeChange:d})]})};Al.displayName="DataTable";const Y0=({store:e,data:t,loading:n=!1,error:i=null,columns:s=[],currentPage:o=1,pageSize:l=10,totalItems:a=0,totalPages:r=1,onPageChange:f,onPageSizeChange:d,sortColumn:h,sortDirection:v,onSort:_,searchValue:C="",onSearchChange:S,searchPlaceholder:c="Search...",selectable:u=!1,selectedRows:p=[],onSelectionChange:b,onCreate:y,onView:w,onEdit:x,onDelete:E,onRefresh:k,onExport:N,createPath:T,detailPath:R,editPath:M,additionalActions:A=[],bulkActions:D=[],title:$,description:H,createLabel:j="Create",refreshLabel:F="Refresh",exportLabel:z="Export",viewLabel:P="View",editLabel:B="Edit",deleteLabel:L="Delete",itemName:U="item",getRowKey:O=ue=>ue.id||ue._id,showHeader:W=!0,showToolbar:Q=!0,compact:V=!1,className:X,deleteConfirmTitle:Z,deleteConfirmDescription:G,getDeleteItemName:J,filters:ee,headerActions:se,searchable:le=!0})=>{const ue=Je.useNavigate(),[Se,Re]=m.useState(!1),[ge,ke]=m.useState(null),[I,Y]=m.useState(!1),[q,re]=m.useState(""),ie=m.useRef(!1),te=m.useRef(q),ae=m.useRef(null),ve=m.useRef(null),me=(e==null?void 0:e.items)??t??[],xe=(e==null?void 0:e.loading)??n,Ae=(e==null?void 0:e.error)??i,Ee=(e==null?void 0:e.pagination)??{page:o,pageSize:l,total:a,totalPages:r},Fe=Ee.page??o,Ie=Ee.pageSize??l,Ye=Ee.total??a,Ge=Ee.totalPages??r,ze=e==null?void 0:e.fetchList,Pt=e==null?void 0:e.delete,ut=e==null?void 0:e.setPage,gn=e==null?void 0:e.setPageSize,he=e==null?void 0:e.setFilters;m.useEffect(()=>{ze&&!ie.current&&(ie.current=!0,ae.current=Fe,ve.current=Ie,ze())},[ze]),m.useEffect(()=>{if(!ze||!ie.current)return;const Ce=ae.current!==Fe,lr=ve.current!==Ie;(Ce||lr)&&(ae.current=Fe,ve.current=Ie,ze())},[Fe,Ie,ze]),m.useEffect(()=>{if(!ze||!ie.current||te.current===q)return;const Ce=setTimeout(()=>{le&&(te.current=q,he==null||he({search:q}),Fe!==1?ut==null||ut(1):ze())},300);return()=>clearTimeout(Ce)},[q,le,Fe,he,ut,ze]);const Te=m.useCallback(Ce=>{ut?ut(Ce):f==null||f(Ce)},[ut,f]),fe=m.useCallback(Ce=>{gn?gn(Ce):d==null||d(Ce)},[gn,d]),Ne=m.useCallback(Ce=>{he?re(Ce):S==null||S(Ce)},[he,S]),Xe=m.useCallback(()=>{T?ue(T):y==null||y()},[T,ue,y]),_e=m.useCallback(Ce=>{R?ue(`${R}/${O(Ce)}`):w==null||w(Ce)},[R,ue,O,w]),Ui=m.useCallback(Ce=>{M?ue(`${M}/${O(Ce)}/edit`):x==null||x(Ce)},[M,ue,O,x]),rr=m.useCallback(()=>{ze?ze():k==null||k()},[ze,k]),Yi=m.useCallback(Ce=>{ke(Ce),Re(!0)},[]),Kn=async()=>{if(ge){Y(!0);try{Pt?(await Pt(O(ge)),ze==null||ze()):E&&await E(ge),Re(!1),ke(null)}catch(Ce){console.error("Delete error:",Ce)}finally{Y(!1)}}},Xn=m.useMemo(()=>{const Ce=[];return(R||w)&&Ce.push({label:P,icon:_m,onClick:_e}),(M||x)&&Ce.push({label:B,icon:Mr,onClick:Ui}),(Pt||E)&&Ce.push({label:L,icon:Ar,variant:"destructive",onClick:Yi}),[...Ce,...A]},[R,M,w,x,Pt,E,P,B,L,_e,Ui,Yi,A]),or=T||y,cp=ze||k,Il=m.useMemo(()=>ge?J?J(ge):ge.name||ge.title||U:U,[ge,J,U]),Bl=()=>Q?g.jsxs("div",{className:"flex items-center gap-2",children:[se,u&&p.length>0&&D.length>0&&g.jsx(g.Fragment,{children:D.map((Ce,lr)=>g.jsxs(we,{variant:Ce.variant||"outline",size:"sm",onClick:()=>{var jl;return(jl=Ce.onClick)==null?void 0:jl.call(Ce,p)},disabled:Ce.disabled,children:[Ce.icon&&g.jsx(Ce.icon,{className:"mr-2 h-4 w-4"}),Ce.label]},Ce.label||lr))}),N&&g.jsxs(we,{variant:"outline",size:"sm",onClick:N,children:[g.jsx(xm,{className:"mr-2 h-4 w-4"}),z]}),cp&&g.jsxs(we,{variant:"outline",size:"sm",onClick:rr,disabled:xe,children:[g.jsx(hc,{className:ne("mr-2 h-4 w-4",xe&&"animate-spin")}),F]}),or&&g.jsxs(we,{size:"sm",onClick:Xe,children:[g.jsx(Em,{className:"mr-2 h-4 w-4"}),j]})]}):null,Fl=g.jsxs(g.Fragment,{children:[ee&&g.jsx("div",{className:"mb-4 flex items-center gap-2",children:ee}),g.jsx(Al,{data:me,columns:s,loading:xe,error:Ae,currentPage:Fe,pageSize:Ie,totalItems:Ye,totalPages:Ge,onPageChange:Te,onPageSizeChange:fe,sortColumn:h,sortDirection:v,onSort:_,searchable:le,searchValue:he?q:C,onSearchChange:Ne,searchPlaceholder:c,selectable:u,selectedRows:p,onSelectionChange:b,actions:Xn,getRowKey:O,compact:V,emptyTitle:`No ${U}s found`,emptyDescription:`Create your first ${U} to get started.`,emptyAction:or?`Create ${U}`:void 0,onEmptyAction:or?Xe:void 0}),g.jsx(xi,{open:Se,onOpenChange:Re,onConfirm:Kn,title:Z||`Delete ${U}`,description:G||`Are you sure you want to delete "${Il}"? This action cannot be undone.`,itemName:Il,loading:I})]});return W&&($||H)?g.jsxs(ft,{className:X,children:[g.jsxs(An,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[g.jsxs("div",{children:[$&&g.jsx(Rn,{children:$}),H&&g.jsx(Dn,{children:H})]}),Bl()]}),g.jsx(ht,{children:Fl})]}):g.jsxs("div",{className:X,children:[Q&&g.jsxs("div",{className:"flex items-center justify-between mb-4",children:[g.jsx("div",{}),Bl()]}),Fl]})};Y0.displayName="CrudList";var $i=e=>e.type==="checkbox",cn=e=>e instanceof Date,nt=e=>e==null;const Z0=e=>typeof e=="object";var We=e=>!nt(e)&&!Array.isArray(e)&&Z0(e)&&!cn(e),r3=e=>We(e)&&e.target?$i(e.target)?e.target.checked:e.target.value:e,o3=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,l3=(e,t)=>e.has(o3(t)),a3=e=>{const t=e.constructor&&e.constructor.prototype;return We(t)&&t.hasOwnProperty("isPrototypeOf")},Rl=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function qe(e){let t;const n=Array.isArray(e),i=typeof FileList<"u"?e instanceof FileList:!1;if(e instanceof Date)t=new Date(e);else if(!(Rl&&(e instanceof Blob||i))&&(n||We(e)))if(t=n?[]:Object.create(Object.getPrototypeOf(e)),!n&&!a3(e))t=e;else for(const s in e)e.hasOwnProperty(s)&&(t[s]=qe(e[s]));else return e;return t}var ir=e=>/^\w*$/.test(e),He=e=>e===void 0,Dl=e=>Array.isArray(e)?e.filter(Boolean):[],Ll=e=>Dl(e.replace(/["|']|\]/g,"").split(/\.|\[/)),ce=(e,t,n)=>{if(!t||!We(e))return n;const i=(ir(t)?[t]:Ll(t)).reduce((s,o)=>nt(s)?s:s[o],e);return He(i)||i===e?He(e[t])?n:e[t]:i},Nt=e=>typeof e=="boolean",Oe=(e,t,n)=>{let i=-1;const s=ir(t)?[t]:Ll(t),o=s.length,l=o-1;for(;++i<o;){const a=s[i];let r=n;if(i!==l){const f=e[a];r=We(f)||Array.isArray(f)?f:isNaN(+s[i+1])?{}:[]}if(a==="__proto__"||a==="constructor"||a==="prototype")return;e[a]=r,e=e[a]}};const za={BLUR:"blur",FOCUS_OUT:"focusout"},bt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Bt={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},c3=K.createContext(null);c3.displayName="HookFormContext";var u3=(e,t,n,i=!0)=>{const s={defaultValues:t._defaultValues};for(const o in e)Object.defineProperty(s,o,{get:()=>{const l=o;return t._proxyFormState[l]!==bt.all&&(t._proxyFormState[l]=!i||bt.all),e[l]}});return s};const d3=typeof window<"u"?K.useLayoutEffect:K.useEffect;var ot=e=>typeof e=="string",f3=(e,t,n,i,s)=>ot(e)?(i&&t.watch.add(e),ce(n,e,s)):Array.isArray(e)?e.map(o=>(i&&t.watch.add(o),ce(n,o))):(i&&(t.watchAll=!0),n),Kr=e=>nt(e)||!Z0(e);function Gt(e,t,n=new WeakSet){if(Kr(e)||Kr(t))return Object.is(e,t);if(cn(e)&&cn(t))return e.getTime()===t.getTime();const i=Object.keys(e),s=Object.keys(t);if(i.length!==s.length)return!1;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);for(const o of i){const l=e[o];if(!s.includes(o))return!1;if(o!=="ref"){const a=t[o];if(cn(l)&&cn(a)||We(l)&&We(a)||Array.isArray(l)&&Array.isArray(a)?!Gt(l,a,n):!Object.is(l,a))return!1}}return!0}var q0=(e,t,n,i,s)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[i]:s||!0}}:{},ai=e=>Array.isArray(e)?e:[e],Ha=()=>{let e=[];return{get observers(){return e},next:s=>{for(const o of e)o.next&&o.next(s)},subscribe:s=>(e.push(s),{unsubscribe:()=>{e=e.filter(o=>o!==s)}}),unsubscribe:()=>{e=[]}}};function G0(e,t){const n={};for(const i in e)if(e.hasOwnProperty(i)){const s=e[i],o=t[i];if(s&&We(s)&&o){const l=G0(s,o);We(l)&&(n[i]=l)}else e[i]&&(n[i]=o)}return n}var tt=e=>We(e)&&!Object.keys(e).length,Ol=e=>e.type==="file",yt=e=>typeof e=="function",gs=e=>{if(!Rl)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},K0=e=>e.type==="select-multiple",Pl=e=>e.type==="radio",h3=e=>Pl(e)||$i(e),kr=e=>gs(e)&&e.isConnected;function p3(e,t){const n=t.slice(0,-1).length;let i=0;for(;i<n;)e=He(e)?i++:e[t[i++]];return e}function m3(e){for(const t in e)if(e.hasOwnProperty(t)&&!He(e[t]))return!1;return!0}function Ve(e,t){const n=Array.isArray(t)?t:ir(t)?[t]:Ll(t),i=n.length===1?e:p3(e,n),s=n.length-1,o=n[s];return i&&delete i[o],s!==0&&(We(i)&&tt(i)||Array.isArray(i)&&m3(i))&&Ve(e,n.slice(0,-1)),e}var g3=e=>{for(const t in e)if(yt(e[t]))return!0;return!1};function X0(e){return Array.isArray(e)||We(e)&&!g3(e)}function Xr(e,t={}){for(const n in e){const i=e[n];X0(i)?(t[n]=Array.isArray(i)?[]:{},Xr(i,t[n])):He(i)||(t[n]=!0)}return t}function Sn(e,t,n){n||(n=Xr(t));for(const i in e){const s=e[i];if(X0(s))He(t)||Kr(n[i])?n[i]=Xr(s,Array.isArray(s)?[]:{}):Sn(s,nt(t)?{}:t[i],n[i]);else{const o=t[i];n[i]=!Gt(s,o)}}return n}const Va={value:!1,isValid:!1},Wa={value:!0,isValid:!0};var Q0=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!He(e[0].attributes.value)?He(e[0].value)||e[0].value===""?Wa:{value:e[0].value,isValid:!0}:Wa:Va}return Va},J0=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:i})=>He(e)?e:t?e===""?NaN:e&&+e:n&&ot(e)?new Date(e):i?i(e):e;const $a={isValid:!1,value:null};var ep=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,$a):$a;function Ua(e){const t=e.ref;return Ol(t)?t.files:Pl(t)?ep(e.refs).value:K0(t)?[...t.selectedOptions].map(({value:n})=>n):$i(t)?Q0(e.refs).value:J0(He(t.value)?e.ref.value:t.value,e)}var v3=(e,t,n,i)=>{const s={};for(const o of e){const l=ce(t,o);l&&Oe(s,o,l._f)}return{criteriaMode:n,names:[...e],fields:s,shouldUseNativeValidation:i}},vs=e=>e instanceof RegExp,ni=e=>He(e)?e:vs(e)?e.source:We(e)?vs(e.value)?e.value.source:e.value:e,Ya=e=>({isOnSubmit:!e||e===bt.onSubmit,isOnBlur:e===bt.onBlur,isOnChange:e===bt.onChange,isOnAll:e===bt.all,isOnTouch:e===bt.onTouched});const Za="AsyncFunction";var b3=e=>!!e&&!!e.validate&&!!(yt(e.validate)&&e.validate.constructor.name===Za||We(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Za)),y3=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),qa=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(i=>e.startsWith(i)&&/^\.\w+/.test(e.slice(i.length))));const ci=(e,t,n,i)=>{for(const s of n||Object.keys(e)){const o=ce(e,s);if(o){const{_f:l,...a}=o;if(l){if(l.refs&&l.refs[0]&&t(l.refs[0],s)&&!i)return!0;if(l.ref&&t(l.ref,l.name)&&!i)return!0;if(ci(a,t))break}else if(We(a)&&ci(a,t))break}}};function Ga(e,t,n){const i=ce(e,n);if(i||ir(n))return{error:i,name:n};const s=n.split(".");for(;s.length;){const o=s.join("."),l=ce(t,o),a=ce(e,o);if(l&&!Array.isArray(l)&&n!==o)return{name:n};if(a&&a.type)return{name:o,error:a};if(a&&a.root&&a.root.type)return{name:`${o}.root`,error:a.root};s.pop()}return{name:n}}var x3=(e,t,n,i)=>{n(e);const{name:s,...o}=e;return tt(o)||Object.keys(o).length>=Object.keys(t).length||Object.keys(o).find(l=>t[l]===(!i||bt.all))},w3=(e,t,n)=>!e||!t||e===t||ai(e).some(i=>i&&(n?i===t:i.startsWith(t)||t.startsWith(i))),_3=(e,t,n,i,s)=>s.isOnAll?!1:!n&&s.isOnTouch?!(t||e):(n?i.isOnBlur:s.isOnBlur)?!e:(n?i.isOnChange:s.isOnChange)?e:!0,C3=(e,t)=>!Dl(ce(e,t)).length&&Ve(e,t),S3=(e,t,n)=>{const i=ai(ce(e,n));return Oe(i,"root",t[n]),Oe(e,n,i),e};function Ka(e,t,n="validate"){if(ot(e)||Array.isArray(e)&&e.every(ot)||Nt(e)&&!e)return{type:n,message:ot(e)?e:"",ref:t}}var _n=e=>We(e)&&!vs(e)?e:{value:e,message:""},Xa=async(e,t,n,i,s,o)=>{const{ref:l,refs:a,required:r,maxLength:f,minLength:d,min:h,max:v,pattern:_,validate:C,name:S,valueAsNumber:c,mount:u}=e._f,p=ce(n,S);if(!u||t.has(S))return{};const b=a?a[0]:l,y=M=>{s&&b.reportValidity&&(b.setCustomValidity(Nt(M)?"":M||""),b.reportValidity())},w={},x=Pl(l),E=$i(l),k=x||E,N=(c||Ol(l))&&He(l.value)&&He(p)||gs(l)&&l.value===""||p===""||Array.isArray(p)&&!p.length,T=q0.bind(null,S,i,w),R=(M,A,D,$=Bt.maxLength,H=Bt.minLength)=>{const j=M?A:D;w[S]={type:M?$:H,message:j,ref:l,...T(M?$:H,j)}};if(o?!Array.isArray(p)||!p.length:r&&(!k&&(N||nt(p))||Nt(p)&&!p||E&&!Q0(a).isValid||x&&!ep(a).isValid)){const{value:M,message:A}=ot(r)?{value:!!r,message:r}:_n(r);if(M&&(w[S]={type:Bt.required,message:A,ref:b,...T(Bt.required,A)},!i))return y(A),w}if(!N&&(!nt(h)||!nt(v))){let M,A;const D=_n(v),$=_n(h);if(!nt(p)&&!isNaN(p)){const H=l.valueAsNumber||p&&+p;nt(D.value)||(M=H>D.value),nt($.value)||(A=H<$.value)}else{const H=l.valueAsDate||new Date(p),j=P=>new Date(new Date().toDateString()+" "+P),F=l.type=="time",z=l.type=="week";ot(D.value)&&p&&(M=F?j(p)>j(D.value):z?p>D.value:H>new Date(D.value)),ot($.value)&&p&&(A=F?j(p)<j($.value):z?p<$.value:H<new Date($.value))}if((M||A)&&(R(!!M,D.message,$.message,Bt.max,Bt.min),!i))return y(w[S].message),w}if((f||d)&&!N&&(ot(p)||o&&Array.isArray(p))){const M=_n(f),A=_n(d),D=!nt(M.value)&&p.length>+M.value,$=!nt(A.value)&&p.length<+A.value;if((D||$)&&(R(D,M.message,A.message),!i))return y(w[S].message),w}if(_&&!N&&ot(p)){const{value:M,message:A}=_n(_);if(vs(M)&&!p.match(M)&&(w[S]={type:Bt.pattern,message:A,ref:l,...T(Bt.pattern,A)},!i))return y(A),w}if(C){if(yt(C)){const M=await C(p,n),A=Ka(M,b);if(A&&(w[S]={...A,...T(Bt.validate,A.message)},!i))return y(A.message),w}else if(We(C)){let M={};for(const A in C){if(!tt(M)&&!i)break;const D=Ka(await C[A](p,n),b,A);D&&(M={...D,...T(A,D.message)},y(D.message),i&&(w[S]=M))}if(!tt(M)&&(w[S]={ref:b,...M},!i))return w}}return y(!0),w};const E3={mode:bt.onSubmit,reValidateMode:bt.onChange,shouldFocusError:!0};function N3(e={}){let t={...E3,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:yt(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},i={},s=We(t.defaultValues)||We(t.values)?qe(t.defaultValues||t.values)||{}:{},o=t.shouldUnregister?{}:qe(s),l={action:!1,mount:!1,watch:!1},a={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},r,f=0;const d={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let h={...d};const v={array:Ha(),state:Ha()},_=t.criteriaMode===bt.all,C=I=>Y=>{clearTimeout(f),f=setTimeout(I,Y)},S=async I=>{if(!t.disabled&&(d.isValid||h.isValid||I)){const Y=t.resolver?tt((await E()).errors):await N(i,!0);Y!==n.isValid&&v.state.next({isValid:Y})}},c=(I,Y)=>{!t.disabled&&(d.isValidating||d.validatingFields||h.isValidating||h.validatingFields)&&((I||Array.from(a.mount)).forEach(q=>{q&&(Y?Oe(n.validatingFields,q,Y):Ve(n.validatingFields,q))}),v.state.next({validatingFields:n.validatingFields,isValidating:!tt(n.validatingFields)}))},u=(I,Y=[],q,re,ie=!0,te=!0)=>{if(re&&q&&!t.disabled){if(l.action=!0,te&&Array.isArray(ce(i,I))){const ae=q(ce(i,I),re.argA,re.argB);ie&&Oe(i,I,ae)}if(te&&Array.isArray(ce(n.errors,I))){const ae=q(ce(n.errors,I),re.argA,re.argB);ie&&Oe(n.errors,I,ae),C3(n.errors,I)}if((d.touchedFields||h.touchedFields)&&te&&Array.isArray(ce(n.touchedFields,I))){const ae=q(ce(n.touchedFields,I),re.argA,re.argB);ie&&Oe(n.touchedFields,I,ae)}(d.dirtyFields||h.dirtyFields)&&(n.dirtyFields=Sn(s,o)),v.state.next({name:I,isDirty:R(I,Y),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Oe(o,I,Y)},p=(I,Y)=>{Oe(n.errors,I,Y),v.state.next({errors:n.errors})},b=I=>{n.errors=I,v.state.next({errors:n.errors,isValid:!1})},y=(I,Y,q,re)=>{const ie=ce(i,I);if(ie){const te=ce(o,I,He(q)?ce(s,I):q);He(te)||re&&re.defaultChecked||Y?Oe(o,I,Y?te:Ua(ie._f)):D(I,te),l.mount&&!l.action&&S()}},w=(I,Y,q,re,ie)=>{let te=!1,ae=!1;const ve={name:I};if(!t.disabled){if(!q||re){(d.isDirty||h.isDirty)&&(ae=n.isDirty,n.isDirty=ve.isDirty=R(),te=ae!==ve.isDirty);const me=Gt(ce(s,I),Y);ae=!!ce(n.dirtyFields,I),me?Ve(n.dirtyFields,I):Oe(n.dirtyFields,I,!0),ve.dirtyFields=n.dirtyFields,te=te||(d.dirtyFields||h.dirtyFields)&&ae!==!me}if(q){const me=ce(n.touchedFields,I);me||(Oe(n.touchedFields,I,q),ve.touchedFields=n.touchedFields,te=te||(d.touchedFields||h.touchedFields)&&me!==q)}te&&ie&&v.state.next(ve)}return te?ve:{}},x=(I,Y,q,re)=>{const ie=ce(n.errors,I),te=(d.isValid||h.isValid)&&Nt(Y)&&n.isValid!==Y;if(t.delayError&&q?(r=C(()=>p(I,q)),r(t.delayError)):(clearTimeout(f),r=null,q?Oe(n.errors,I,q):Ve(n.errors,I)),(q?!Gt(ie,q):ie)||!tt(re)||te){const ae={...re,...te&&Nt(Y)?{isValid:Y}:{},errors:n.errors,name:I};n={...n,...ae},v.state.next(ae)}},E=async I=>{c(I,!0);const Y=await t.resolver(o,t.context,v3(I||a.mount,i,t.criteriaMode,t.shouldUseNativeValidation));return c(I),Y},k=async I=>{const{errors:Y}=await E(I);if(I)for(const q of I){const re=ce(Y,q);re?Oe(n.errors,q,re):Ve(n.errors,q)}else n.errors=Y;return Y},N=async(I,Y,q={valid:!0})=>{for(const re in I){const ie=I[re];if(ie){const{_f:te,...ae}=ie;if(te){const ve=a.array.has(te.name),me=ie._f&&b3(ie._f);me&&d.validatingFields&&c([te.name],!0);const xe=await Xa(ie,a.disabled,o,_,t.shouldUseNativeValidation&&!Y,ve);if(me&&d.validatingFields&&c([te.name]),xe[te.name]&&(q.valid=!1,Y))break;!Y&&(ce(xe,te.name)?ve?S3(n.errors,xe,te.name):Oe(n.errors,te.name,xe[te.name]):Ve(n.errors,te.name))}!tt(ae)&&await N(ae,Y,q)}}return q.valid},T=()=>{for(const I of a.unMount){const Y=ce(i,I);Y&&(Y._f.refs?Y._f.refs.every(q=>!kr(q)):!kr(Y._f.ref))&&V(I)}a.unMount=new Set},R=(I,Y)=>!t.disabled&&(I&&Y&&Oe(o,I,Y),!Gt(P(),s)),M=(I,Y,q)=>f3(I,a,{...l.mount?o:He(Y)?s:ot(I)?{[I]:Y}:Y},q,Y),A=I=>Dl(ce(l.mount?o:s,I,t.shouldUnregister?ce(s,I,[]):[])),D=(I,Y,q={})=>{const re=ce(i,I);let ie=Y;if(re){const te=re._f;te&&(!te.disabled&&Oe(o,I,J0(Y,te)),ie=gs(te.ref)&&nt(Y)?"":Y,K0(te.ref)?[...te.ref.options].forEach(ae=>ae.selected=ie.includes(ae.value)):te.refs?$i(te.ref)?te.refs.forEach(ae=>{(!ae.defaultChecked||!ae.disabled)&&(Array.isArray(ie)?ae.checked=!!ie.find(ve=>ve===ae.value):ae.checked=ie===ae.value||!!ie)}):te.refs.forEach(ae=>ae.checked=ae.value===ie):Ol(te.ref)?te.ref.value="":(te.ref.value=ie,te.ref.type||v.state.next({name:I,values:qe(o)})))}(q.shouldDirty||q.shouldTouch)&&w(I,ie,q.shouldTouch,q.shouldDirty,!0),q.shouldValidate&&z(I)},$=(I,Y,q)=>{for(const re in Y){if(!Y.hasOwnProperty(re))return;const ie=Y[re],te=I+"."+re,ae=ce(i,te);(a.array.has(I)||We(ie)||ae&&!ae._f)&&!cn(ie)?$(te,ie,q):D(te,ie,q)}},H=(I,Y,q={})=>{const re=ce(i,I),ie=a.array.has(I),te=qe(Y);Oe(o,I,te),ie?(v.array.next({name:I,values:qe(o)}),(d.isDirty||d.dirtyFields||h.isDirty||h.dirtyFields)&&q.shouldDirty&&v.state.next({name:I,dirtyFields:Sn(s,o),isDirty:R(I,te)})):re&&!re._f&&!nt(te)?$(I,te,q):D(I,te,q),qa(I,a)&&v.state.next({...n,name:I}),v.state.next({name:l.mount?I:void 0,values:qe(o)})},j=async I=>{l.mount=!0;const Y=I.target;let q=Y.name,re=!0;const ie=ce(i,q),te=me=>{re=Number.isNaN(me)||cn(me)&&isNaN(me.getTime())||Gt(me,ce(o,q,me))},ae=Ya(t.mode),ve=Ya(t.reValidateMode);if(ie){let me,xe;const Ae=Y.type?Ua(ie._f):r3(I),Ee=I.type===za.BLUR||I.type===za.FOCUS_OUT,Fe=!y3(ie._f)&&!t.resolver&&!ce(n.errors,q)&&!ie._f.deps||_3(Ee,ce(n.touchedFields,q),n.isSubmitted,ve,ae),Ie=qa(q,a,Ee);Oe(o,q,Ae),Ee?(!Y||!Y.readOnly)&&(ie._f.onBlur&&ie._f.onBlur(I),r&&r(0)):ie._f.onChange&&ie._f.onChange(I);const Ye=w(q,Ae,Ee),Ge=!tt(Ye)||Ie;if(!Ee&&v.state.next({name:q,type:I.type,values:qe(o)}),Fe)return(d.isValid||h.isValid)&&(t.mode==="onBlur"?Ee&&S():Ee||S()),Ge&&v.state.next({name:q,...Ie?{}:Ye});if(!Ee&&Ie&&v.state.next({...n}),t.resolver){const{errors:ze}=await E([q]);if(te(Ae),re){const Pt=Ga(n.errors,i,q),ut=Ga(ze,i,Pt.name||q);me=ut.error,q=ut.name,xe=tt(ze)}}else c([q],!0),me=(await Xa(ie,a.disabled,o,_,t.shouldUseNativeValidation))[q],c([q]),te(Ae),re&&(me?xe=!1:(d.isValid||h.isValid)&&(xe=await N(i,!0)));re&&(ie._f.deps&&(!Array.isArray(ie._f.deps)||ie._f.deps.length>0)&&z(ie._f.deps),x(q,xe,me,Ye))}},F=(I,Y)=>{if(ce(n.errors,Y)&&I.focus)return I.focus(),1},z=async(I,Y={})=>{let q,re;const ie=ai(I);if(t.resolver){const te=await k(He(I)?I:ie);q=tt(te),re=I?!ie.some(ae=>ce(te,ae)):q}else I?(re=(await Promise.all(ie.map(async te=>{const ae=ce(i,te);return await N(ae&&ae._f?{[te]:ae}:ae)}))).every(Boolean),!(!re&&!n.isValid)&&S()):re=q=await N(i);return v.state.next({...!ot(I)||(d.isValid||h.isValid)&&q!==n.isValid?{}:{name:I},...t.resolver||!I?{isValid:q}:{},errors:n.errors}),Y.shouldFocus&&!re&&ci(i,F,I?ie:a.mount),re},P=(I,Y)=>{let q={...l.mount?o:s};return Y&&(q=G0(Y.dirtyFields?n.dirtyFields:n.touchedFields,q)),He(I)?q:ot(I)?ce(q,I):I.map(re=>ce(q,re))},B=(I,Y)=>({invalid:!!ce((Y||n).errors,I),isDirty:!!ce((Y||n).dirtyFields,I),error:ce((Y||n).errors,I),isValidating:!!ce(n.validatingFields,I),isTouched:!!ce((Y||n).touchedFields,I)}),L=I=>{I&&ai(I).forEach(Y=>Ve(n.errors,Y)),v.state.next({errors:I?n.errors:{}})},U=(I,Y,q)=>{const re=(ce(i,I,{_f:{}})._f||{}).ref,ie=ce(n.errors,I)||{},{ref:te,message:ae,type:ve,...me}=ie;Oe(n.errors,I,{...me,...Y,ref:re}),v.state.next({name:I,errors:n.errors,isValid:!1}),q&&q.shouldFocus&&re&&re.focus&&re.focus()},O=(I,Y)=>yt(I)?v.state.subscribe({next:q=>"values"in q&&I(M(void 0,Y),q)}):M(I,Y,!0),W=I=>v.state.subscribe({next:Y=>{w3(I.name,Y.name,I.exact)&&x3(Y,I.formState||d,Re,I.reRenderRoot)&&I.callback({values:{...o},...n,...Y,defaultValues:s})}}).unsubscribe,Q=I=>(l.mount=!0,h={...h,...I.formState},W({...I,formState:h})),V=(I,Y={})=>{for(const q of I?ai(I):a.mount)a.mount.delete(q),a.array.delete(q),Y.keepValue||(Ve(i,q),Ve(o,q)),!Y.keepError&&Ve(n.errors,q),!Y.keepDirty&&Ve(n.dirtyFields,q),!Y.keepTouched&&Ve(n.touchedFields,q),!Y.keepIsValidating&&Ve(n.validatingFields,q),!t.shouldUnregister&&!Y.keepDefaultValue&&Ve(s,q);v.state.next({values:qe(o)}),v.state.next({...n,...Y.keepDirty?{isDirty:R()}:{}}),!Y.keepIsValid&&S()},X=({disabled:I,name:Y})=>{(Nt(I)&&l.mount||I||a.disabled.has(Y))&&(I?a.disabled.add(Y):a.disabled.delete(Y))},Z=(I,Y={})=>{let q=ce(i,I);const re=Nt(Y.disabled)||Nt(t.disabled);return Oe(i,I,{...q||{},_f:{...q&&q._f?q._f:{ref:{name:I}},name:I,mount:!0,...Y}}),a.mount.add(I),q?X({disabled:Nt(Y.disabled)?Y.disabled:t.disabled,name:I}):y(I,!0,Y.value),{...re?{disabled:Y.disabled||t.disabled}:{},...t.progressive?{required:!!Y.required,min:ni(Y.min),max:ni(Y.max),minLength:ni(Y.minLength),maxLength:ni(Y.maxLength),pattern:ni(Y.pattern)}:{},name:I,onChange:j,onBlur:j,ref:ie=>{if(ie){Z(I,Y),q=ce(i,I);const te=He(ie.value)&&ie.querySelectorAll&&ie.querySelectorAll("input,select,textarea")[0]||ie,ae=h3(te),ve=q._f.refs||[];if(ae?ve.find(me=>me===te):te===q._f.ref)return;Oe(i,I,{_f:{...q._f,...ae?{refs:[...ve.filter(kr),te,...Array.isArray(ce(s,I))?[{}]:[]],ref:{type:te.type,name:I}}:{ref:te}}}),y(I,!1,void 0,te)}else q=ce(i,I,{}),q._f&&(q._f.mount=!1),(t.shouldUnregister||Y.shouldUnregister)&&!(l3(a.array,I)&&l.action)&&a.unMount.add(I)}}},G=()=>t.shouldFocusError&&ci(i,F,a.mount),J=I=>{Nt(I)&&(v.state.next({disabled:I}),ci(i,(Y,q)=>{const re=ce(i,q);re&&(Y.disabled=re._f.disabled||I,Array.isArray(re._f.refs)&&re._f.refs.forEach(ie=>{ie.disabled=re._f.disabled||I}))},0,!1))},ee=(I,Y)=>async q=>{let re;q&&(q.preventDefault&&q.preventDefault(),q.persist&&q.persist());let ie=qe(o);if(v.state.next({isSubmitting:!0}),t.resolver){const{errors:te,values:ae}=await E();n.errors=te,ie=qe(ae)}else await N(i);if(a.disabled.size)for(const te of a.disabled)Ve(ie,te);if(Ve(n.errors,"root"),tt(n.errors)){v.state.next({errors:{}});try{await I(ie,q)}catch(te){re=te}}else Y&&await Y({...n.errors},q),G(),setTimeout(G);if(v.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:tt(n.errors)&&!re,submitCount:n.submitCount+1,errors:n.errors}),re)throw re},se=(I,Y={})=>{ce(i,I)&&(He(Y.defaultValue)?H(I,qe(ce(s,I))):(H(I,Y.defaultValue),Oe(s,I,qe(Y.defaultValue))),Y.keepTouched||Ve(n.touchedFields,I),Y.keepDirty||(Ve(n.dirtyFields,I),n.isDirty=Y.defaultValue?R(I,qe(ce(s,I))):R()),Y.keepError||(Ve(n.errors,I),d.isValid&&S()),v.state.next({...n}))},le=(I,Y={})=>{const q=I?qe(I):s,re=qe(q),ie=tt(I),te=ie?s:re;if(Y.keepDefaultValues||(s=q),!Y.keepValues){if(Y.keepDirtyValues){const ae=new Set([...a.mount,...Object.keys(Sn(s,o))]);for(const ve of Array.from(ae))ce(n.dirtyFields,ve)?Oe(te,ve,ce(o,ve)):H(ve,ce(te,ve))}else{if(Rl&&He(I))for(const ae of a.mount){const ve=ce(i,ae);if(ve&&ve._f){const me=Array.isArray(ve._f.refs)?ve._f.refs[0]:ve._f.ref;if(gs(me)){const xe=me.closest("form");if(xe){xe.reset();break}}}}if(Y.keepFieldsRef)for(const ae of a.mount)H(ae,ce(te,ae));else i={}}o=t.shouldUnregister?Y.keepDefaultValues?qe(s):{}:qe(te),v.array.next({values:{...te}}),v.state.next({values:{...te}})}a={mount:Y.keepDirtyValues?a.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!d.isValid||!!Y.keepIsValid||!!Y.keepDirtyValues||!t.shouldUnregister&&!tt(te),l.watch=!!t.shouldUnregister,l.action=!1,Y.keepErrors||(n.errors={}),v.state.next({submitCount:Y.keepSubmitCount?n.submitCount:0,isDirty:ie?!1:Y.keepDirty?n.isDirty:!!(Y.keepDefaultValues&&!Gt(I,s)),isSubmitted:Y.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:ie?{}:Y.keepDirtyValues?Y.keepDefaultValues&&o?Sn(s,o):n.dirtyFields:Y.keepDefaultValues&&I?Sn(s,I):Y.keepDirty?n.dirtyFields:{},touchedFields:Y.keepTouched?n.touchedFields:{},errors:Y.keepErrors?n.errors:{},isSubmitSuccessful:Y.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},ue=(I,Y)=>le(yt(I)?I(o):I,Y),Se=(I,Y={})=>{const q=ce(i,I),re=q&&q._f;if(re){const ie=re.refs?re.refs[0]:re.ref;ie.focus&&(ie.focus(),Y.shouldSelect&&yt(ie.select)&&ie.select())}},Re=I=>{n={...n,...I}},ke={control:{register:Z,unregister:V,getFieldState:B,handleSubmit:ee,setError:U,_subscribe:W,_runSchema:E,_focusError:G,_getWatch:M,_getDirty:R,_setValid:S,_setFieldArray:u,_setDisabledField:X,_setErrors:b,_getFieldArray:A,_reset:le,_resetDefaultValues:()=>yt(t.defaultValues)&&t.defaultValues().then(I=>{ue(I,t.resetOptions),v.state.next({isLoading:!1})}),_removeUnmounted:T,_disableForm:J,_subjects:v,_proxyFormState:d,get _fields(){return i},get _formValues(){return o},get _state(){return l},set _state(I){l=I},get _defaultValues(){return s},get _names(){return a},set _names(I){a=I},get _formState(){return n},get _options(){return t},set _options(I){t={...t,...I}}},subscribe:Q,trigger:z,register:Z,handleSubmit:ee,watch:O,setValue:H,getValues:P,reset:ue,resetField:se,clearErrors:L,unregister:V,setError:U,setFocus:Se,getFieldState:B};return{...ke,formControl:ke}}function k3(e={}){const t=K.useRef(void 0),n=K.useRef(void 0),[i,s]=K.useState({isDirty:!1,isValidating:!1,isLoading:yt(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:yt(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:i},e.defaultValues&&!yt(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...a}=N3(e);t.current={...a,formState:i}}const o=t.current.control;return o._options=e,d3(()=>{const l=o._subscribe({formState:o._proxyFormState,callback:()=>s({...o._formState}),reRenderRoot:!0});return s(a=>({...a,isReady:!0})),o._formState.isReady=!0,l},[o]),K.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),K.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),K.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),K.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),K.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==i.isDirty&&o._subjects.state.next({isDirty:l})}},[o,i.isDirty]),K.useEffect(()=>{var l;e.values&&!Gt(e.values,n.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((l=o._options.resetOptions)===null||l===void 0)&&l.keepIsValid||o._setValid(),n.current=e.values,s(a=>({...a}))):o._resetDefaultValues()},[o,e.values]),K.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),t.current.formState=u3(i,o),t.current}const Qa=(e,t,n)=>{if(e&&"reportValidity"in e){const i=ce(n,t);e.setCustomValidity(i&&i.message||""),e.reportValidity()}},tp=(e,t)=>{for(const n in t.fields){const i=t.fields[n];i&&i.ref&&"reportValidity"in i.ref?Qa(i.ref,n,e):i.refs&&i.refs.forEach(s=>Qa(s,n,e))}},T3=(e,t)=>{t.shouldUseNativeValidation&&tp(e,t);const n={};for(const i in e){const s=ce(t.fields,i),o=Object.assign(e[i]||{},{ref:s&&s.ref});if(M3(t.names||Object.keys(e),i)){const l=Object.assign({},ce(n,i));Oe(l,"root",o),Oe(n,i,l)}else Oe(n,i,o)}return n},M3=(e,t)=>e.some(n=>n.startsWith(t+"."));var A3=function(e,t){for(var n={};e.length;){var i=e[0],s=i.code,o=i.message,l=i.path.join(".");if(!n[l])if("unionErrors"in i){var a=i.unionErrors[0].errors[0];n[l]={message:a.message,type:a.code}}else n[l]={message:o,type:s};if("unionErrors"in i&&i.unionErrors.forEach(function(d){return d.errors.forEach(function(h){return e.push(h)})}),t){var r=n[l].types,f=r&&r[i.code];n[l]=q0(l,t,n,s,f?[].concat(f,i.message):i.message)}e.shift()}return n},R3=function(e,t,n){return n===void 0&&(n={}),function(i,s,o){try{return Promise.resolve(function(l,a){try{var r=Promise.resolve(e[n.mode==="sync"?"parse":"parseAsync"](i,t)).then(function(f){return o.shouldUseNativeValidation&&tp({},o),{errors:{},values:n.raw?i:f}})}catch(f){return a(f)}return r&&r.then?r.then(void 0,a):r}(0,function(l){if(function(a){return Array.isArray(a==null?void 0:a.errors)}(l))return{values:{},errors:T3(A3(l.errors,!o.shouldUseNativeValidation&&o.criteriaMode==="all"),o)};throw l}))}catch(l){return Promise.reject(l)}}};const np=({useStore:e,fields:t=[],defaultValues:n={},validationSchema:i,children:s,onSubmit:o,onCancel:l,onBack:a,onBeforeSubmit:r,initialData:f=null,loading:d=!1,submitting:h=!1,title:v,description:_,submitLabel:C="Save",cancelLabel:S="Cancel",backLabel:c="Back",columns:u=1,showHeader:p=!0,showFooter:b=!0,showBack:y=!0,showCard:w=!0,listPath:x,icon:E,className:k,...N})=>{var ke;const T=Je.useNavigate(),{id:R}=Je.useParams(),M=!!R,A=e==null?void 0:e(),D=A==null?void 0:A.form,$=(A==null?void 0:A.loading)??!1,H=((ke=A==null?void 0:A.form)==null?void 0:ke.isSubmitting)??!1,j=(A==null?void 0:A.fetchAndPopulateForm)||(A==null?void 0:A.fetchById)||(A==null?void 0:A.fetchOne),F=A==null?void 0:A.create,z=A==null?void 0:A.update,P=A==null?void 0:A.resetForm,B=d||$,L=h||H;m.useEffect(()=>(M&&R&&j&&j(R),()=>{P==null||P()}),[R,M]);const U=()=>{a?a():T(x||-1)},O=()=>{l?l():U()},W=async I=>{var Y;(Y=I==null?void 0:I.preventDefault)==null||Y.call(I);try{let q=(D==null?void 0:D.values)||{};r&&(q=r(q)),M?await(z==null?void 0:z(R,q)):await(F==null?void 0:F(q)),U()}catch(q){console.error("Form submission error:",q)}};if(e&&s){const I=M?`Edit ${v}`:`Create ${v}`,Y=g.jsxs("form",{onSubmit:W,children:[s,b&&g.jsxs("div",{className:"flex items-center justify-end gap-2 mt-6 pt-4 border-t",children:[g.jsxs(we,{type:"button",variant:"outline",onClick:O,disabled:L,children:[g.jsx(Mn,{className:"mr-2 h-4 w-4"}),S]}),g.jsx(we,{type:"submit",disabled:L||B,children:L?g.jsxs(g.Fragment,{children:[g.jsx(un,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):g.jsxs(g.Fragment,{children:[g.jsx(Zl,{className:"mr-2 h-4 w-4"}),C]})})]})]});return w?g.jsxs(ft,{className:k,...N,children:[g.jsx(An,{children:g.jsxs("div",{className:"flex items-center gap-4",children:[y&&g.jsx(we,{variant:"ghost",size:"icon",onClick:U,children:g.jsx(Ft,{className:"h-4 w-4"})}),E&&g.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center",children:g.jsx(E,{className:"h-5 w-5 text-primary"})}),g.jsxs("div",{children:[g.jsx(Rn,{children:I}),_&&g.jsx(Dn,{children:_})]})]})}),g.jsx(ht,{children:Y})]}):g.jsxs("div",{className:ne("space-y-6",k),...N,children:[g.jsxs("div",{className:"flex items-center gap-4",children:[y&&g.jsx(we,{variant:"ghost",size:"icon",onClick:U,children:g.jsx(Ft,{className:"h-4 w-4"})}),E&&g.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center",children:g.jsx(E,{className:"h-5 w-5 text-primary"})}),g.jsxs("div",{children:[g.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:I}),_&&g.jsx("p",{className:"text-muted-foreground",children:_})]})]}),Y]})}const Q=k3({defaultValues:f||n,resolver:i?R3(i):void 0,mode:"onBlur"}),{handleSubmit:V,formState:{errors:X,isDirty:Z,isValid:G},reset:J,watch:ee,setValue:se,control:le}=Q;m.useEffect(()=>{f&&J(f)},[f,J]);const ue=async I=>{try{await(o==null?void 0:o(I))}catch(Y){console.error("Form submission error:",Y)}},Se=I=>{var Ye;const{name:Y,type:q="text",label:re,placeholder:ie,description:te,required:ae,disabled:ve,options:me=[],className:xe,...Ae}=I,Ee=(Ye=X[Y])==null?void 0:Ye.message,Fe=ee(Y),Ie={label:re,placeholder:ie,description:te,error:Ee,required:ae,disabled:ve||B||L,className:xe};switch(q){case"text":case"email":case"password":case"number":case"url":case"tel":return g.jsx(ms,{...Ie,type:q,...Q.register(Y),...Ae});case"textarea":return g.jsx(_l,{...Ie,...Q.register(Y),...Ae});case"select":return g.jsx(Cl,{...Ie,options:me,value:Fe,onChange:Ge=>se(Y,Ge,{shouldValidate:!0}),...Ae});case"search-select":return g.jsx(Sl,{...Ie,options:me,value:Fe,onChange:Ge=>se(Y,Ge,{shouldValidate:!0}),...Ae});case"switch":return g.jsx(El,{...Ie,checked:Fe,onCheckedChange:Ge=>se(Y,Ge,{shouldValidate:!0}),...Ae});case"checkbox":return g.jsx(Nl,{...Ie,checked:Fe,onCheckedChange:Ge=>se(Y,Ge,{shouldValidate:!0}),...Ae});case"custom":return I.render?I.render({form:Q,field:I,error:Ee,value:Fe}):null;default:return g.jsx(ms,{...Ie,type:"text",...Q.register(Y),...Ae})}},Re=ne("grid gap-4",u===1&&"grid-cols-1",u===2&&"grid-cols-1 md:grid-cols-2",u===3&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-3",u===4&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-4"),ge=g.jsxs("form",{onSubmit:V(ue),children:[g.jsx("div",{className:Re,children:t.map(I=>{if(I.hidden&&(typeof I.hidden=="function"?I.hidden(ee()):I.hidden))return null;const Y=I.colSpan||1,q=ne(Y===2&&"md:col-span-2",Y===3&&"md:col-span-2 lg:col-span-3",Y===4&&"md:col-span-2 lg:col-span-4",Y==="full"&&"col-span-full");return g.jsx("div",{className:q,children:Se(I)},I.name)})}),b&&g.jsxs("div",{className:"flex items-center justify-end gap-2 mt-6 pt-4 border-t",children:[l&&g.jsxs(we,{type:"button",variant:"outline",onClick:l,disabled:L,children:[g.jsx(Mn,{className:"mr-2 h-4 w-4"}),S]}),g.jsx(we,{type:"submit",disabled:L||B,children:L?g.jsxs(g.Fragment,{children:[g.jsx(un,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):g.jsxs(g.Fragment,{children:[g.jsx(Zl,{className:"mr-2 h-4 w-4"}),C]})})]})]});return p&&(v||_||y)?g.jsxs(ft,{className:k,...N,children:[g.jsx(An,{children:g.jsxs("div",{className:"flex items-center gap-4",children:[y&&a&&g.jsx(we,{variant:"ghost",size:"icon",onClick:a,children:g.jsx(Ft,{className:"h-4 w-4"})}),g.jsxs("div",{children:[v&&g.jsx(Rn,{children:v}),_&&g.jsx(Dn,{children:_})]})]})}),g.jsx(ht,{children:ge})]}):g.jsx("div",{className:k,...N,children:ge})};np.displayName="CrudForm";const ip=({useStore:e,children:t,data:n=null,loading:i=!1,error:s=null,fields:o=[],onBack:l,onEdit:a,onDelete:r,listPath:f,editPath:d,title:h,description:v,editLabel:_="Edit",deleteLabel:C="Delete",backLabel:S="Back",itemName:c="item",getItemName:u,showHeader:p=!0,showMeta:b=!0,showCard:y=!0,columns:w=2,icon:x,className:E,...k})=>{const N=Je.useNavigate(),{id:T}=Je.useParams(),R=e==null?void 0:e(),M=R==null?void 0:R.currentItem,A=(R==null?void 0:R.loading)??!1,D=R==null?void 0:R.error,$=(R==null?void 0:R.fetchById)||(R==null?void 0:R.fetchOne),H=R==null?void 0:R.delete,j=n||M,F=i||A,z=s||D,[P,B]=m.useState(!1),[L,U]=m.useState(!1);m.useEffect(()=>{T&&$&&$(T)},[T]);const O=()=>{l?l():N(f||-1)},W=()=>{a?a(j):d&&T&&N(`${d}/${T}/edit`)},Q=async()=>{U(!0);try{r?await r(j):H&&T&&(await H(T),O()),B(!1)}catch(ee){console.error("Delete error:",ee)}finally{U(!1)}},V=j&&u?u(j):(j==null?void 0:j.name)||(j==null?void 0:j.title)||c,X=(ee,se)=>{if(ee.render)return j?ee.render(se,j):g.jsx("span",{className:"text-muted-foreground",children:"-"});if(se==null||se==="")return g.jsx("span",{className:"text-muted-foreground",children:"-"});switch(ee.type){case"badge":return g.jsx(ii,{variant:ee.variant||"default",children:ee.format?ee.format(se):String(se)});case"status":const le={active:"success",inactive:"secondary",pending:"warning",error:"destructive",...ee.statusColors};return g.jsx(ii,{variant:le[se==null?void 0:se.toLowerCase()]||"default",children:ee.format?ee.format(se):String(se)});case"boolean":const ue=!!se;return g.jsx(ii,{variant:ue?"success":"secondary",children:ue?ee.trueLabel||"Yes":ee.falseLabel||"No"});case"date":return Jr(se);case"datetime":return Ji(se);case"currency":return new Intl.NumberFormat("en-US",{style:"currency",currency:ee.currency||"USD"}).format(se);case"number":return ee.format?ee.format(se):new Intl.NumberFormat().format(se);case"list":return Array.isArray(se)?g.jsx("div",{className:"flex flex-wrap gap-1",children:se.map((Se,Re)=>g.jsx(ii,{variant:"outline",children:ee.getItemLabel?ee.getItemLabel(Se):String(Se)},Re))}):String(se);case"link":return g.jsx("a",{href:se,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:ee.linkText||se});case"email":return g.jsx("a",{href:`mailto:${se}`,className:"text-primary hover:underline",children:se});case"phone":return g.jsx("a",{href:`tel:${se}`,className:"text-primary hover:underline",children:se});case"image":return g.jsx("img",{src:se,alt:ee.label||"Image",className:ne("rounded-md object-cover",ee.imageClassName||"h-20 w-20")});case"html":return g.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:se}});default:return ee.format?ee.format(se):String(se)}},Z=ee=>{if(j)return ee.accessor?typeof ee.accessor=="function"?ee.accessor(j):j[ee.accessor]:j[ee.name]},G=ne("grid gap-6",w===1&&"grid-cols-1",w===2&&"grid-cols-1 md:grid-cols-2",w===3&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-3"),J=g.jsxs(g.Fragment,{children:[g.jsx("div",{className:G,children:o.map(ee=>{if(ee.hidden&&(typeof ee.hidden=="function"?j&&ee.hidden(j):ee.hidden))return null;const se=Z(ee),le=ee.colSpan||1,ue=ne(le===2&&"md:col-span-2",le===3&&"lg:col-span-3",le==="full"&&"col-span-full");return g.jsxs("div",{className:ue,children:[g.jsxs("dt",{className:"text-sm font-medium text-muted-foreground mb-1",children:[ee.icon&&g.jsx(ee.icon,{className:"inline-block mr-2 h-4 w-4"}),ee.label]}),g.jsx("dd",{className:"text-sm",children:X(ee,se)})]},ee.name||ee.accessor)})}),b&&j&&(j.created_at||j.updated_at||j.createdAt||j.updatedAt)&&g.jsxs(g.Fragment,{children:[g.jsx(Si,{className:"my-6"}),g.jsxs("div",{className:"flex flex-wrap gap-6 text-sm text-muted-foreground",children:[(j.created_at||j.createdAt)&&(j.created_at||j.createdAt)!==""&&g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(ss,{className:"h-4 w-4"}),g.jsxs("span",{children:["Created: ",Ji(j.created_at||j.createdAt)]})]}),(j.updated_at||j.updatedAt)&&(j.updated_at||j.updatedAt)!==""&&g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(ss,{className:"h-4 w-4"}),g.jsxs("span",{children:["Updated: ",Ji(j.updated_at||j.updatedAt)]})]}),(j.id||j._id)&&g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(Cm,{className:"h-4 w-4"}),g.jsxs("span",{children:["ID: ",j.id||j._id]})]})]})]})]});return e&&t&&typeof t=="function"?F?g.jsx("div",{className:ne("space-y-6",E),children:g.jsx(ft,{children:g.jsx(ht,{className:"py-12",children:g.jsx(zn,{text:`Loading ${c}...`})})})}):z?g.jsx("div",{className:ne("space-y-6",E),children:g.jsx(ft,{children:g.jsxs(ht,{className:"py-12 text-center",children:[g.jsx("p",{className:"text-destructive",children:(z==null?void 0:z.message)||"An error occurred"}),g.jsxs(we,{variant:"outline",onClick:O,className:"mt-4",children:[g.jsx(Ft,{className:"mr-2 h-4 w-4"}),S]})]})})}):j?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:ne("space-y-6",E),...k,children:[p&&g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{className:"flex items-center gap-4",children:[g.jsx(we,{variant:"ghost",size:"icon",onClick:O,children:g.jsx(Ft,{className:"h-4 w-4"})}),x&&g.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center",children:g.jsx(x,{className:"h-5 w-5 text-primary"})}),g.jsxs("div",{children:[g.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:h}),v&&g.jsx("p",{className:"text-muted-foreground",children:v})]})]}),g.jsxs("div",{className:"flex items-center gap-2",children:[(a||d)&&g.jsxs(we,{variant:"outline",onClick:W,children:[g.jsx(Mr,{className:"mr-2 h-4 w-4"}),_]}),(r||H)&&g.jsxs(we,{variant:"destructive",onClick:()=>B(!0),children:[g.jsx(Ar,{className:"mr-2 h-4 w-4"}),C]})]})]}),t(j)]}),g.jsx(xi,{open:P,onOpenChange:B,onConfirm:Q,itemName:V,loading:L})]}):g.jsx("div",{className:ne("space-y-6",E),children:g.jsx(ft,{children:g.jsxs(ht,{className:"py-12 text-center",children:[g.jsxs("p",{className:"text-muted-foreground",children:["No ",c," found"]}),g.jsxs(we,{variant:"outline",onClick:O,className:"mt-4",children:[g.jsx(Ft,{className:"mr-2 h-4 w-4"}),S]})]})})}):F?g.jsx(ft,{className:E,children:g.jsx(ht,{className:"py-12",children:g.jsx(zn,{text:`Loading ${c}...`})})}):z?g.jsx(ft,{className:E,children:g.jsxs(ht,{className:"py-12 text-center",children:[g.jsx("p",{className:"text-destructive",children:(z==null?void 0:z.message)||"An error occurred"}),g.jsxs(we,{variant:"outline",onClick:O,className:"mt-4",children:[g.jsx(Ft,{className:"mr-2 h-4 w-4"}),S]})]})}):j?g.jsxs(g.Fragment,{children:[g.jsxs(ft,{className:E,...k,children:[p&&g.jsxs(An,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[g.jsxs("div",{className:"flex items-center gap-4",children:[g.jsx(we,{variant:"ghost",size:"icon",onClick:O,children:g.jsx(Ft,{className:"h-4 w-4"})}),g.jsxs("div",{children:[h&&g.jsx(Rn,{children:h}),v&&g.jsx(Dn,{children:v})]})]}),g.jsxs("div",{className:"flex items-center gap-2",children:[(a||d)&&g.jsxs(we,{variant:"outline",onClick:W,children:[g.jsx(Mr,{className:"mr-2 h-4 w-4"}),_]}),(r||H)&&g.jsxs(we,{variant:"destructive",onClick:()=>B(!0),children:[g.jsx(Ar,{className:"mr-2 h-4 w-4"}),C]})]})]}),g.jsx(ht,{children:J})]}),g.jsx(xi,{open:P,onOpenChange:B,onConfirm:Q,itemName:V,loading:L})]}):g.jsx(ft,{className:E,children:g.jsxs(ht,{className:"py-12 text-center",children:[g.jsxs("p",{className:"text-muted-foreground",children:["No ",c," found"]}),g.jsxs(we,{variant:"outline",onClick:O,className:"mt-4",children:[g.jsx(Ft,{className:"mr-2 h-4 w-4"}),S]})]})})};ip.displayName="CrudDetail";const sp=e=>{const{name:t="crud",apiClient:n,endpoint:i,transformResponse:s=h=>h,transformRequest:o=h=>h,initialState:l={},extraActions:a={},idField:r="id",listKey:f="results",countKey:d="count"}=e;if(!n)throw new Error("createCrudStore: apiClient is required");if(!i)throw new Error("createCrudStore: endpoint is required");return h=>h((v,_)=>({items:[],item:null,loading:!1,submitting:!1,error:null,page:1,pageSize:10,totalItems:0,totalPages:0,sortColumn:null,sortDirection:null,search:"",filters:{},selectedIds:[],...l,setPage:C=>v({page:C}),setPageSize:C=>v({pageSize:C,page:1}),setSearch:C=>v({search:C,page:1}),setFilters:C=>v({filters:C,page:1}),setSort:(C,S)=>v({sortColumn:C,sortDirection:S}),setSelectedIds:C=>v({selectedIds:C}),clearSelection:()=>v({selectedIds:[]}),clearError:()=>v({error:null}),reset:()=>v({items:[],item:null,loading:!1,submitting:!1,error:null,page:1,search:"",filters:{},selectedIds:[]}),fetchList:async(C={})=>{var c,u,p,b;const S=_();v({loading:!0,error:null});try{const y={page:S.page,page_size:S.pageSize,search:S.search||void 0,ordering:S.sortColumn?`${S.sortDirection==="desc"?"-":""}${S.sortColumn}`:void 0,...S.filters,...C};Object.keys(y).forEach(T=>{(y[T]===void 0||y[T]==="")&&delete y[T]});const x=(await n.get(i,{params:y})).data,E=x[f]||x.data||(Array.isArray(x)?x:[]),k=x[d]||x.total||E.length,N=Math.ceil(k/S.pageSize);return v({items:E.map(s),totalItems:k,totalPages:N,loading:!1}),{items:E,totalItems:k,totalPages:N}}catch(y){const w=((u=(c=y.response)==null?void 0:c.data)==null?void 0:u.message)||((b=(p=y.response)==null?void 0:p.data)==null?void 0:b.detail)||y.message||"Failed to fetch items";throw v({error:{message:w,original:y},loading:!1}),y}},fetchOne:async C=>{var S,c,u,p;v({loading:!0,error:null,item:null});try{const b=await n.get(`${i}/${C}/`),y=s(b.data);return v({item:y,loading:!1}),y}catch(b){const y=((c=(S=b.response)==null?void 0:S.data)==null?void 0:c.message)||((p=(u=b.response)==null?void 0:u.data)==null?void 0:p.detail)||b.message||"Failed to fetch item";throw v({error:{message:y,original:b},loading:!1}),b}},create:async C=>{var S,c,u,p,b;v({submitting:!0,error:null});try{const y=o(C),w=await n.post(`${i}/`,y),x=s(w.data);return v(E=>({items:[x,...E.items],totalItems:E.totalItems+1,submitting:!1})),x}catch(y){const w=((c=(S=y.response)==null?void 0:S.data)==null?void 0:c.message)||((p=(u=y.response)==null?void 0:u.data)==null?void 0:p.detail)||y.message||"Failed to create item",x=((b=y.response)==null?void 0:b.data)||{};throw v({error:{message:w,fieldErrors:x,original:y},submitting:!1}),y}},update:async(C,S)=>{var c,u,p,b,y;v({submitting:!0,error:null});try{const w=o(S),x=await n.patch(`${i}/${C}/`,w),E=s(x.data);return v(k=>{var N;return{items:k.items.map(T=>T[r]===C?E:T),item:((N=k.item)==null?void 0:N[r])===C?E:k.item,submitting:!1}}),E}catch(w){const x=((u=(c=w.response)==null?void 0:c.data)==null?void 0:u.message)||((b=(p=w.response)==null?void 0:p.data)==null?void 0:b.detail)||w.message||"Failed to update item",E=((y=w.response)==null?void 0:y.data)||{};throw v({error:{message:x,fieldErrors:E,original:w},submitting:!1}),w}},delete:async C=>{var S,c,u,p;v({submitting:!0,error:null});try{return await n.delete(`${i}/${C}/`),v(b=>{var y;return{items:b.items.filter(w=>w[r]!==C),totalItems:b.totalItems-1,item:((y=b.item)==null?void 0:y[r])===C?null:b.item,selectedIds:b.selectedIds.filter(w=>w!==C),submitting:!1}}),!0}catch(b){const y=((c=(S=b.response)==null?void 0:S.data)==null?void 0:c.message)||((p=(u=b.response)==null?void 0:u.data)==null?void 0:p.detail)||b.message||"Failed to delete item";throw v({error:{message:y,original:b},submitting:!1}),b}},bulkDelete:async C=>{var S,c,u,p;v({submitting:!0,error:null});try{return await Promise.all(C.map(b=>n.delete(`${i}/${b}/`))),v(b=>({items:b.items.filter(y=>!C.includes(y[r])),totalItems:b.totalItems-C.length,selectedIds:[],submitting:!1})),!0}catch(b){const y=((c=(S=b.response)==null?void 0:S.data)==null?void 0:c.message)||((p=(u=b.response)==null?void 0:u.data)==null?void 0:p.detail)||b.message||"Failed to delete items";throw v({error:{message:y,original:b},submitting:!1}),b}},replace:async(C,S)=>{var c,u,p,b,y;v({submitting:!0,error:null});try{const w=o(S),x=await n.put(`${i}/${C}/`,w),E=s(x.data);return v(k=>{var N;return{items:k.items.map(T=>T[r]===C?E:T),item:((N=k.item)==null?void 0:N[r])===C?E:k.item,submitting:!1}}),E}catch(w){const x=((u=(c=w.response)==null?void 0:c.data)==null?void 0:u.message)||((b=(p=w.response)==null?void 0:p.data)==null?void 0:b.detail)||w.message||"Failed to update item",E=((y=w.response)==null?void 0:y.data)||{};throw v({error:{message:x,fieldErrors:E,original:w},submitting:!1}),w}},...a}))},D3=e=>{const{create:t}=require("zustand");return t(sp(e))};function L3({brandName:e="Your Brand",brandLogo:t,brandDescription:n="Welcome back",quote:i,quoteAuthor:s,copyright:o,leftPanelClassName:l,rightPanelClassName:a,leftPanelContent:r,rightPanelContent:f,showLeftPanel:d=!0,children:h}){const v=new Date().getFullYear(),_=o||`© ${v} ${e}. All rights reserved.`,C=g.jsxs("div",{className:"flex flex-col h-full p-8 lg:p-12 text-white",children:[g.jsxs("div",{className:"flex items-center gap-3",children:[t||g.jsx("div",{className:"h-10 w-10 rounded-lg bg-white/20 flex items-center justify-center",children:g.jsx("span",{className:"text-white font-bold text-xl",children:e.charAt(0)})}),g.jsx("span",{className:"text-xl font-semibold",children:e})]}),g.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[i&&g.jsxs("div",{className:"max-w-md",children:[g.jsxs("blockquote",{className:"text-2xl lg:text-3xl font-light leading-relaxed",children:['"',i,'"']}),s&&g.jsxs("p",{className:"mt-4 text-white/70",children:["— ",s]})]}),!i&&n&&g.jsx("div",{className:"text-center",children:g.jsx("p",{className:"text-2xl lg:text-3xl font-light",children:n})})]}),g.jsx("div",{className:"text-sm text-white/60",children:_})]});return g.jsxs("div",{className:"min-h-screen flex",children:[d&&g.jsx("div",{className:ne("hidden lg:flex lg:w-1/2 bg-gray-900",l),children:r||C}),g.jsx("div",{className:ne("w-full flex items-center justify-center p-8",d?"lg:w-1/2":"",a),children:g.jsx("div",{className:"w-full max-w-md",children:f||h||g.jsx(Je.Outlet,{})})})]})}function O3({onSubmit:e,isLoading:t=!1,error:n,title:i="Login",subtitle:s="Enter your email below to login to your account",emailLabel:o="Email",emailPlaceholder:l="m@example.com",passwordLabel:a="Password",rememberMeLabel:r="Remember me",forgotPasswordText:f="Forgot your password?",forgotPasswordPath:d="/forgot-password",submitButtonText:h="Login",signUpText:v="Don't have an account?",signUpLinkText:_="Sign up",signUpPath:C="/register",showRememberMe:S=!0,showForgotPassword:c=!0,showSignUp:u=!0,logo:p,className:b,children:y}){const[w,x]=K.useState(""),[E,k]=K.useState(""),[N,T]=K.useState(!1),R=async M=>{M.preventDefault(),e&&await e({email:w,password:E,rememberMe:N})};return g.jsxs("div",{className:ne("space-y-6",b),children:[p&&g.jsx("div",{className:"flex justify-center",children:p}),g.jsxs("div",{className:"space-y-2 text-center",children:[g.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:i}),s&&g.jsx("p",{className:"text-sm text-muted-foreground",children:s})]}),n&&g.jsx("div",{className:"p-3 text-sm text-destructive bg-destructive/10 rounded-md",children:n}),g.jsxs("form",{onSubmit:R,className:"space-y-4",children:[g.jsxs("div",{className:"space-y-2",children:[g.jsx(Kt,{htmlFor:"email",children:o}),g.jsx(Ln,{id:"email",type:"email",placeholder:l,value:w,onChange:M=>x(M.target.value),required:!0,autoComplete:"email"})]}),g.jsxs("div",{className:"space-y-2",children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsx(Kt,{htmlFor:"password",children:a}),c&&d&&g.jsx(Je.Link,{to:d,className:"text-sm text-muted-foreground hover:text-primary underline-offset-4 hover:underline",children:f})]}),g.jsx(Ln,{id:"password",type:"password",value:E,onChange:M=>k(M.target.value),required:!0,autoComplete:"current-password"})]}),S&&g.jsxs("div",{className:"flex items-center space-x-2",children:[g.jsx(On,{id:"remember",checked:N,onCheckedChange:T}),g.jsx(Kt,{htmlFor:"remember",className:"text-sm font-normal cursor-pointer",children:r})]}),y,g.jsx(we,{type:"submit",className:"w-full",disabled:t,children:t?"Signing in...":h})]}),u&&C&&g.jsxs("div",{className:"text-center text-sm text-muted-foreground",children:[v," ",g.jsx(Je.Link,{to:C,className:"text-primary underline-offset-4 hover:underline",children:_})]})]})}const rp=K.createContext(null);function sr(){const e=K.useContext(rp);if(!e)throw new Error("useSidebarContext must be used within a SidebarProvider");return e}function op({defaultOpen:e=!1,defaultCollapsed:t=!1,children:n}){const[i,s]=K.useState(e),[o,l]=K.useState(t),a=K.useCallback(()=>{s(v=>!v)},[]),r=K.useCallback(v=>{s(v)},[]),f=K.useCallback(()=>{l(v=>!v)},[]),d=K.useCallback(v=>{l(v)},[]),h={isOpen:i,isCollapsed:o,toggle:a,setOpen:r,toggleCollapse:f,setCollapsed:d};return g.jsx(rp.Provider,{value:h,children:n})}function lp({items:e=[],brandName:t="Brand",brandLogo:n,brandPath:i="/dashboard",user:s,onLogout:o,userMenuItems:l=[],showUserProfile:a=!0,className:r,collapsedWidth:f="w-16",expandedWidth:d="w-60",renderItem:h,headerSlot:v,footerSlot:_}){var N,T;const{isOpen:C,isCollapsed:S,setOpen:c,toggleCollapse:u}=sr(),p=Je.useLocation(),[b,y]=K.useState([]),w=R=>{y(M=>M.includes(R)?M.filter(A=>A!==R):[...M,R])},x=(R,M=!1)=>{if(R.title)return g.jsxs("div",{className:"mt-6",children:[!S&&g.jsx("h3",{className:"px-3 text-xs font-medium text-sidebar-foreground/50 uppercase tracking-wider mb-2",children:R.title}),S&&g.jsx(Si,{className:"my-3 bg-sidebar-border"})]},R.title);if(h)return h(R,{isCollapsed:S,isSubItem:M,location:p});const A=R.icon,D=R.children&&R.children.length>0,$=b.includes(R.label),H=R.path&&(p.pathname===R.path||p.pathname.startsWith(R.path+"/")),j=D&&R.children.some(F=>p.pathname===F.path||p.pathname.startsWith(F.path+"/"));return D?g.jsxs("div",{children:[g.jsxs("button",{onClick:()=>w(R.label),className:ne("w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors text-sm",j?"bg-sidebar-accent text-sidebar-accent-foreground":"hover:bg-sidebar-accent text-sidebar-foreground hover:text-sidebar-accent-foreground",S&&"justify-center px-2"),title:S?R.label:void 0,children:[A&&g.jsx(A,{className:"h-4 w-4 flex-shrink-0"}),!S&&g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"flex-1 text-left",children:R.label}),g.jsx(ys,{className:ne("h-4 w-4 transition-transform",$&&"rotate-180")})]})]}),!S&&$&&g.jsx("div",{className:"ml-4 mt-1 space-y-0.5",children:R.children.map(F=>x(F,!0))})]},R.label):g.jsxs(Je.Link,{to:R.path,className:ne("flex items-center gap-3 px-3 py-2 rounded-lg transition-colors",H?"bg-sidebar-primary text-sidebar-primary-foreground":"hover:bg-sidebar-accent text-sidebar-foreground hover:text-sidebar-accent-foreground",S&&"justify-center px-2","text-sm"),title:S?R.label:void 0,children:[A&&g.jsx(A,{className:"h-4 w-4 flex-shrink-0"}),!S&&g.jsx("span",{children:R.label})]},R.path||R.label)},E=g.jsxs("div",{className:"flex items-center justify-between h-14 px-3 border-b border-sidebar-border",children:[!S&&g.jsxs(Je.Link,{to:i,className:"flex items-center gap-2",children:[n||g.jsx("div",{className:"h-7 w-7 rounded-md bg-sidebar-primary flex items-center justify-center",children:g.jsx("span",{className:"text-sidebar-primary-foreground font-semibold text-sm",children:t.charAt(0)})}),g.jsx("span",{className:"font-semibold text-sidebar-foreground",children:t})]}),S&&g.jsx(Je.Link,{to:i,className:"mx-auto",children:n||g.jsx("div",{className:"h-7 w-7 rounded-md bg-sidebar-primary flex items-center justify-center",children:g.jsx("span",{className:"text-sidebar-primary-foreground font-semibold text-sm",children:t.charAt(0)})})}),g.jsx("button",{onClick:()=>c(!1),className:"p-1.5 rounded-lg hover:bg-sidebar-accent lg:hidden",children:g.jsx(Mn,{className:"h-4 w-4 text-sidebar-foreground"})}),g.jsx("button",{onClick:u,className:ne("hidden lg:block p-1.5 rounded-lg hover:bg-sidebar-accent",S&&"mx-auto"),children:S?g.jsx(_i,{className:"h-4 w-4 text-sidebar-foreground"}):g.jsx(eo,{className:"h-4 w-4 text-sidebar-foreground"})})]}),k=s&&a&&g.jsx("div",{className:"px-3 py-3 border-t border-sidebar-border",children:g.jsxs(al,{children:[g.jsx(cl,{asChild:!0,children:g.jsxs("button",{className:ne("w-full flex items-center gap-3 px-2 py-2 rounded-lg transition-colors hover:bg-sidebar-accent",S&&"justify-center px-0"),children:[g.jsxs(Oo,{className:"h-8 w-8",children:[g.jsx(Po,{src:s.avatar,alt:s.firstName||"User"}),g.jsxs(Io,{className:"bg-sidebar-primary text-sidebar-primary-foreground text-xs",children:[((N=s.firstName)==null?void 0:N[0])||"U",((T=s.lastName)==null?void 0:T[0])||""]})]}),!S&&g.jsxs("div",{className:"flex-1 text-left",children:[g.jsxs("p",{className:"text-sm font-medium text-sidebar-foreground truncate",children:[s.firstName," ",s.lastName]}),g.jsx("p",{className:"text-xs text-sidebar-foreground/50 truncate",children:s.email})]})]})}),g.jsxs(Qs,{align:"end",className:"w-56",children:[g.jsx(Js,{children:"My Account"}),g.jsx(yi,{}),l.map((R,M)=>g.jsx(bi,{asChild:!!R.path,onClick:R.onClick,children:R.path?g.jsx(Je.Link,{to:R.path,children:R.label}):R.label},M)),l.length>0&&g.jsx(yi,{}),o&&g.jsx(bi,{onClick:o,className:"text-destructive",children:"Log out"})]})]})});return g.jsxs(g.Fragment,{children:[C&&g.jsx("div",{className:"fixed inset-0 bg-black/50 z-40 lg:hidden",onClick:()=>c(!1)}),g.jsxs("aside",{className:ne("fixed top-0 left-0 z-50 h-full bg-sidebar border-r border-sidebar-border transition-all duration-300 ease-in-out flex flex-col",C?"translate-x-0":"-translate-x-full",S?f:d,"lg:translate-x-0",r),children:[v||E,g.jsx("nav",{className:"flex-1 overflow-y-auto px-3 py-3",children:g.jsx("div",{className:"space-y-1",children:e.map(R=>x(R))})}),_||k]})]})}function ap({pathNames:e={},showBreadcrumbs:t=!0,showMenuButton:n=!0,className:i,leftSlot:s,rightSlot:o,breadcrumbsSlot:l,children:a}){const{toggle:r}=sr(),f=Je.useLocation(),d={dashboard:"Dashboard",users:"Users",roles:"Roles",permissions:"Permissions",settings:"Settings",profile:"Profile",create:"Create",edit:"Edit",...e},h=()=>{const v=f.pathname.split("/").filter(Boolean);return g.jsx("nav",{className:"flex items-center gap-1 text-sm",children:v.map((_,C)=>{const S="/"+v.slice(0,C+1).join("/"),c=C===v.length-1,u=d[_]||_;return g.jsxs("div",{className:"flex items-center gap-1",children:[C>0&&g.jsx(_i,{className:"h-4 w-4 text-muted-foreground"}),c?g.jsx("span",{className:"font-medium text-foreground",children:u}):g.jsx(Je.Link,{to:S,className:"text-muted-foreground hover:text-foreground transition-colors",children:u})]},S)})})};return g.jsxs("header",{className:ne("sticky top-0 z-30 bg-background",i),children:[g.jsxs("div",{className:"flex items-center h-14 px-4 md:px-6",children:[n&&g.jsx("button",{onClick:r,className:"p-2 -ml-2 rounded-lg hover:bg-muted lg:hidden",children:g.jsx(Sm,{className:"h-5 w-5"})}),g.jsx("div",{className:"flex items-center gap-4 flex-1",children:s||t&&(l||g.jsx(h,{}))}),o&&g.jsx("div",{className:"flex items-center gap-2",children:o}),a]}),g.jsx(Si,{})]})}function P3({sidebarProps:e,headerProps:t,showHeader:n=!0,showSidebar:i=!0,contentClassName:s,mainSlot:o,children:l}){const{isCollapsed:a}=sr();return g.jsxs("div",{className:"min-h-screen bg-background",children:[i&&g.jsx(lp,{...e}),g.jsxs("div",{className:ne("transition-all duration-300 ease-in-out",i&&(a?"lg:ml-16":"lg:ml-60")),children:[n&&g.jsx(ap,{...t}),g.jsx("main",{className:ne("p-4 md:p-6",s),children:o||l||g.jsx(Je.Outlet,{})})]})]})}function I3({sidebarProps:e={},headerProps:t={},defaultOpen:n=!1,defaultCollapsed:i=!1,showHeader:s=!0,showSidebar:o=!0,contentClassName:l,mainSlot:a,children:r}){return g.jsx(op,{defaultOpen:n,defaultCollapsed:i,children:g.jsx(P3,{sidebarProps:e,headerProps:t,showHeader:s,showSidebar:o,contentClassName:l,mainSlot:a,children:r})})}exports.Alert=ml;exports.AlertDescription=vl;exports.AlertTitle=gl;exports.AlertWithIcon=O0;exports.AuthLayout=L3;exports.Avatar=Oo;exports.AvatarFallback=Io;exports.AvatarImage=Po;exports.Badge=ii;exports.Button=we;exports.Calendar=Gs;exports.Card=ft;exports.CardContent=ht;exports.CardDescription=Dn;exports.CardFooter=mc;exports.CardHeader=An;exports.CardTitle=Rn;exports.Checkbox=On;exports.ConfirmModal=Ml;exports.CreateEmptyState=W0;exports.CrudDetail=ip;exports.CrudForm=np;exports.CrudList=Y0;exports.DashboardLayout=I3;exports.DataTable=Al;exports.DatePicker=Go;exports.DateRangePicker=Ko;exports.DeleteConfirmModal=xi;exports.Dialog=Sd;exports.DialogClose=Wy;exports.DialogContent=To;exports.DialogDescription=Ro;exports.DialogFooter=Fs;exports.DialogHeader=Mo;exports.DialogOverlay=ko;exports.DialogPortal=Ed;exports.DialogTitle=Ao;exports.DialogTrigger=Vy;exports.DropdownMenu=al;exports.DropdownMenuCheckboxItem=g0;exports.DropdownMenuContent=Qs;exports.DropdownMenuGroup=L4;exports.DropdownMenuItem=bi;exports.DropdownMenuLabel=Js;exports.DropdownMenuPortal=O4;exports.DropdownMenuRadioGroup=I4;exports.DropdownMenuRadioItem=v0;exports.DropdownMenuSeparator=yi;exports.DropdownMenuShortcut=b0;exports.DropdownMenuSub=P4;exports.DropdownMenuSubContent=m0;exports.DropdownMenuSubTrigger=p0;exports.DropdownMenuTrigger=cl;exports.EmptyState=Gn;exports.ErrorState=$0;exports.FormField=$t;exports.FormModal=U0;exports.Header=ap;exports.Input=Ln;exports.Label=Kt;exports.Loading=zn;exports.LoadingButton=V0;exports.LoadingOverlay=H0;exports.LoginPage=O3;exports.Modal=nr;exports.Pagination=kl;exports.Popover=jo;exports.PopoverContent=Ys;exports.PopoverTrigger=zo;exports.QCheckbox=Nl;exports.QDatePicker=F0;exports.QDateRangePicker=j0;exports.QForm=B0;exports.QInput=ms;exports.QRichTextEditor=z0;exports.QSearchSelect=Sl;exports.QSelect=Cl;exports.QSwitch=El;exports.QTabs=Kd;exports.QTextarea=_l;exports.RichTextEditor=Jo;exports.ScrollArea=D0;exports.ScrollBar=pl;exports.SearchEmptyState=Tl;exports.SearchSelect=wl;exports.Select=xo;exports.SelectContent=Ps;exports.SelectGroup=xy;exports.SelectItem=Is;exports.SelectLabel=ed;exports.SelectScrollDownButton=Co;exports.SelectScrollUpButton=_o;exports.SelectSeparator=td;exports.SelectTrigger=Os;exports.SelectValue=wo;exports.Separator=Si;exports.Sidebar=lp;exports.SidebarProvider=op;exports.Skeleton=ag;exports.Switch=ao;exports.Table=bl;exports.TableBody=xl;exports.TableCaption=I0;exports.TableCell=ln;exports.TableFooter=P0;exports.TableHead=li;exports.TableHeader=yl;exports.TableRow=En;exports.Tabs=wx;exports.TabsContent=Gd;exports.TabsList=Zd;exports.TabsTrigger=qd;exports.Textarea=no;exports.Tooltip=aw;exports.TooltipContent=gf;exports.TooltipProvider=lw;exports.TooltipTrigger=cw;exports.alertVariants=L0;exports.badgeVariants=gc;exports.buildQueryString=om;exports.buttonVariants=pc;exports.capitalize=Jp;exports.cn=ne;exports.createCrudStore=sp;exports.createStore=D3;exports.debounce=uc;exports.deepClone=tm;exports.formatCurrency=Kp;exports.formatDate=Jr;exports.formatDateTime=Ji;exports.formatRelativeTime=Xp;exports.generateId=sm;exports.getInitials=im;exports.isEmpty=nm;exports.parseQueryString=rm;exports.slugify=em;exports.truncate=Qp;exports.useSidebarContext=sr;
253
253
  //# sourceMappingURL=index.cjs.map