/*! For license information please see newsletter_editor.js.LICENSE.txt */
(self.webpackChunk=self.webpackChunk||[]).push([[883],{92140:function(){(function(){var e,t;e=this.jQuery||window.jQuery,t=e(window),e.fn.stick_in_parent=function(o){var n,r,i,s,a,l,c,d,u,h,m,p,g;for(null==o&&(o={}),g=o.sticky_class,l=o.inner_scrolling,p=o.recalc_every,m=o.parent,u=o.offset_top,d=o.spacer,i=o.bottoming,null==u&&(u=0),null==m&&(m=void 0),null==l&&(l=!0),null==g&&(g="is_stuck"),n=e(document),null==i&&(i=!0),h=function(e){var t,o;return window.getComputedStyle?(e[0],t=window.getComputedStyle(e[0]),o=parseFloat(t.getPropertyValue("width"))+parseFloat(t.getPropertyValue("margin-left"))+parseFloat(t.getPropertyValue("margin-right")),"border-box"!==t.getPropertyValue("box-sizing")&&(o+=parseFloat(t.getPropertyValue("border-left-width"))+parseFloat(t.getPropertyValue("border-right-width"))+parseFloat(t.getPropertyValue("padding-left"))+parseFloat(t.getPropertyValue("padding-right"))),o):e.outerWidth(!0)},s=function(o,r,s,a,c,f,v,b){var y,w,_,x,C,k,S,T,E,O,M,A;if(!o.data("sticky_kit")){if(o.data("sticky_kit",!0),C=n.height(),S=o.parent(),null!=m&&(S=S.closest(m)),!S.length)throw"failed to find stick parent";return _=!1,y=!1,(M=null!=d?d&&o.closest(d):e("
"))&&M.css("position",o.css("position")),(T=function(){var e,t,i;if(!b)return C=n.height(),e=parseInt(S.css("border-top-width"),10),t=parseInt(S.css("padding-top"),10),r=parseInt(S.css("padding-bottom"),10),s=S.offset().top+e+t,a=S.height(),_&&(_=!1,y=!1,null==d&&(o.insertAfter(M),M.detach()),o.css({position:"",top:"",width:"",bottom:""}).removeClass(g),i=!0),c=o.offset().top-(parseInt(o.css("margin-top"),10)||0)-u,f=o.outerHeight(!0),v=o.css("float"),M&&M.css({width:h(o),height:f,display:o.css("display"),"vertical-align":o.css("vertical-align"),float:v}),i?A():void 0})(),x=void 0,k=u,O=p,A=function(){var e,h,m,w,E,A;if(!b)return m=!1,null!=O&&(O-=1)<=0&&(O=p,T(),m=!0),m||n.height()===C||(T(),m=!0),w=t.scrollTop(),null!=x&&(h=w-x),x=w,_?(i&&(E=w+f+k>a+s,y&&!E&&(y=!1,o.css({position:"fixed",bottom:"",top:k}).trigger("sticky_kit:unbottom"))),wA&&(y||(k-=h,k=Math.max(A-f,k),k=Math.min(u,k),_&&o.css({top:k+"px"}))))):w>c&&(_=!0,(e={position:"fixed",top:k}).width="border-box"===o.css("box-sizing")?o.outerWidth()+"px":o.width()+"px",o.css(e).addClass(g),null==d&&(o.after(M),"left"!==v&&"right"!==v||M.append(o)),o.trigger("sticky_kit:stick")),_&&i&&(null==E&&(E=w+f+k>a+s),!y&&E)?(y=!0,"static"===S.css("position")&&S.css({position:"relative"}),o.css({position:"absolute",bottom:r,top:"auto"}).trigger("sticky_kit:bottom")):void 0},E=function(){return T(),A()},w=function(){if(b=!0,t.off("touchmove",A),t.off("scroll",A),t.off("resize",E),e(document.body).off("sticky_kit:recalc",E),o.off("sticky_kit:detach",w),o.removeData("sticky_kit"),o.css({position:"",bottom:"",top:"",width:""}),S.position("position",""),_)return null==d&&("left"!==v&&"right"!==v||o.insertAfter(M),M.remove()),o.removeClass(g)},t.on("touchmove",A),t.on("scroll",A),t.on("resize",E),e(document.body).on("sticky_kit:recalc",E),o.on("sticky_kit:detach",w),setTimeout(A,0)}},a=0,c=this.length;a{const t=document.getElementById("mailpoet_editor"),o=e=>(document.location.search.split(`${e}=`)[1]||"").split("&")[0];t&&window.EditorApplication&&(r.MailPoet.Modal.loading(!0),r.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"get",data:{id:o("id")}}).always((()=>r.MailPoet.Modal.loading(!1))).always((()=>(0,u.Z)())).done((t=>{const n=t.data;if("sending"===n.status&&n.queue&&null===n.queue.status){let e="yes"===o("pauseConfirmed");if(e||(e=window.confirm((0,i.__)("Sending is in progress. Do you want to pause sending and edit the newsletter?","mailpoet"))),!e)return void(window.location=`admin.php?page=mailpoet-newsletters#/${n.type}`);r.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"sending_queue",action:"pause",data:{newsletter_id:n.id}}).done((()=>r.MailPoet.Notice.system((0,i.__)("Email sending has been paused.","mailpoet")))).fail((e=>{e.errors.length>0&&r.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0,static:!0})}))}else if(l.qY.includes(n.type)&&"active"===n.status){let e="yes"===o("deactivationConfirmed");if(e||(e=window.confirm((0,i.__)("To edit this email, it needs to be deactivated. You can activate it again after you make the changes.","mailpoet"))),!e)return void(window.location=`admin.php?page=mailpoet-newsletters#/${n.type}`);r.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"setStatus",data:{id:n.id,status:"draft"}}).done((e=>{"draft"===e.data.status&&r.MailPoet.Notice.system((0,i.__)("This email was deactivated.","mailpoet"))})).fail((e=>{r.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0,static:!0})}))}Promise.resolve(((e,t)=>{if("automatic"!==t.type)return e;const o=e;return r.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"automatic_emails",action:"get_event_shortcodes",data:{email_slug:t.options.group,event_slug:t.options.event}}).then((e=>c.default.isObject(e)&&e.data?(o.shortcodes={...o.shortcodes,...e.data},o):o)).fail((e=>{e.errors.length>0&&r.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0,static:!0})}))})(e,n)).then((e=>{const t={...e.blockDefaults,container:{}};window.EditorApplication.start({newsletter:n,config:{...e,blockDefaults:t}})})).catch((()=>{window.EditorApplication.start({newsletter:n,config:e})})),((e,t)=>{if(!["wc_transactional","confirmation_email"].includes(e)){const o=document.getElementById("mailpoet_editor_steps_heading"),n=["automation","automation_transactional"].includes(e)?2:3;let i=null,l=()=>{window.location=`admin.php?page=${r.MailPoet.mainPageSlug}`};if(t.automationId){const e=`admin.php?page=mailpoet-automation-editor&id=${t.automationId}`;l=()=>{window.location=e};const o=()=>document.querySelector(".mailpoet_show_preview").click(),n=()=>document.querySelector(".mailpoet_save_go_to_automation").click();i=(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("input",{type:"button",name:"preview",className:"button link-button",onClick:o,value:"Preview"})," ",(0,h.jsx)("input",{type:"button",className:"button button-primary",onClick:n,value:"Save and continue"})]})}const c=(0,h.jsx)(d.ErrorBoundary,{children:(0,h.jsx)(a.b,{emailType:e,step:n,buttons:i,onLogoClick:l})});(0,s.s)(o).render(c)}})("automatic"===n.type?n.options?.group:n.type,n.options)})).fail((e=>{e.errors.length>0&&r.MailPoet.Notice.error(e.errors.map((e=>e.message)),{scroll:!0,static:!0})})))}));var m,p,g=o(82656),f=o.n(g),v=o(56463),b=o.n(v),y=o(65311),w=o.n(y);m=b(),p=f().View.extend({el:"#mailpoet_editor",regions:{stylesRegion:"#mailpoet_editor_styles",contentRegion:"#mailpoet_editor_content",sidebarRegion:"#mailpoet_editor_sidebar",bottomRegion:"#mailpoet_editor_bottom",headingRegion:"#mailpoet_editor_heading",historyRegion:"#mailpoet_editor_history",topRegion:"#mailpoet_editor_top"},events:{click:"onClickOutsideContentHideSettings"},onClickOutsideContentHideSettings:function(e){w()(e.target).parents("#mailpoet_editor_content").length||window.EditorApplication.getChannel().trigger("hideSettings")}});const x=new(f().Application.extend({region:"#mailpoet_editor",onStart:function(){this._appView=new p,this.showView(this._appView),this.listenTo(this.getChannel(),"settingsDisplayed",this.setDisplayedSettingsId)},getChannel:function(e){return void 0===e?m.channel("global"):m.channel(e)},getDisplayedSettingsId:function(){return this.displayedSettingsId},setDisplayedSettingsId:function(e){this.displayedSettingsId=e}}));window.EditorApplication=x,Backbone.SuperModel=function(e,t){var o=function(t){for(var o=t.length-1;o>=0;o--){var n=t.slice(0,o),r=t.slice(o);if(1!=r.length){var i=this;(n=n.join(".")).length>0&&(i=this.get(n));for(var s=e.first(r),a=e.rest(r),l=[s],c=0;c=1)||e.isObject(t[0]))},_nestedSet:function(n,r,i){for(var d=(n=n.split(".")).length-1,u=this,h=0;h1){var n=this.attributes[e.first(o)];if(!n)return;var r=e.rest(o).join(".");return e.isFunction(n.get)?n.get(r):n[r]}return this.attributes[t]},toJSON:function(t){t=t||{};var o=e.result(this,"unsafeAttributes");t.except&&(o=e.union(o,t.except));var n=e.clone(this.attributes);return e.each(o,(function(e){delete n[e]})),e.each(n,(function(t,o){t&&e.isFunction(t.toJSON)&&(n[o]=t.toJSON())})),n},hasChanged:function(t){return null==t?!e.isEmpty(this.changed):(o=this.changed,n=!1,r(o,t,(function(t,o){n=e.has(t,o)})),n);var o,n},previous:function(e){return null!=e&&this._previousAttributes?function(e,t,o){for(var r=(t=n(t)).length,i=0;i{const o=e,n=c.default.clone(t.config);o.getConfig=k.getConfig,o.setConfig=k.setConfig,n.blockDefaults=c.default.extend(n.blockDefaults,t.newsletter.body?.blockDefaults||{}),o.setConfig(n)}));var S={};S.StylesModel=C.extend({defaults:{text:{fontColor:"#000000",fontFamily:"Arial",fontSize:"16px",lineHeight:"1.6"},h1:{fontColor:"#111111",fontFamily:"Arial",fontSize:"40px",lineHeight:"1.6"},h2:{fontColor:"#222222",fontFamily:"Tahoma",fontSize:"32px",lineHeight:"1.6"},h3:{fontColor:"#333333",fontFamily:"Verdana",fontSize:"24px",lineHeight:"1.6"},link:{fontColor:"#21759B",textDecoration:"underline"},wrapper:{backgroundColor:"#ffffff"},body:{backgroundColor:"#cccccc"}},initialize:function(e){this.set(w().extend(!0,{},this.defaults,e)),this.on("change",(function(){x.getChannel().trigger("autoSave")})),x.getChannel().on("historyUpdate",this.onHistoryUpdate,this)},onHistoryUpdate:function(e){this.set(e.globalStyles)}}),S.StylesView=f().View.extend({getTemplate:function(){return window.templates.styles},templateContext:function(){return{isWoocommerceTransactional:this.isWoocommerceTransactional}},modelEvents:{change:"render"},serializeData:function(){return this.model.toJSON()},initialize:function(e){this.isWoocommerceTransactional=e.isWoocommerceTransactional}}),S._globalStyles=new C,S.getGlobalStyles=function(){return S._globalStyles},S.setGlobalStyles=function(e){return S._globalStyles=new S.StylesModel(e),S._globalStyles},S.getAvailableStyles=function(){return x.getConfig().get("availableStyles")},x.on("before:start",(function(e,t){var o,n,r,i=e;i.getGlobalStyles=S.getGlobalStyles,i.setGlobalStyles=S.setGlobalStyles,i.getAvailableStyles=S.getAvailableStyles,o=t.newsletter.body,n=c.default.has(o,"globalStyles")?o.globalStyles:{},r=c.default.has(t.config,"overrideGlobalStyles")?t.config.overrideGlobalStyles:{},this.setGlobalStyles(w().extend(!0,{},n,r))})),x.on("start",(function(e){var t=new S.StylesView({model:e.getGlobalStyles(),isWoocommerceTransactional:x.getNewsletter().isWoocommerceTransactional()});e._appView.showChildView("stylesRegion",t)}));var T=o(45729),E=o.n(T),O=o(70079);const M="brand",A="theme",B={selectedStyle:"brand",brand:{fontFamily:"SF Pro Text",fontWeight:"normal",background:"#ffffff",foreground:"#dfa8bb"},theme:{fontFamily:"SF Pro Text",fontWeight:"800",background:"#ffffff",foreground:"#ad86e9"}};function N(){const{brand:e,theme:t,selectedStyle:o}=B,[n,r]=(0,O.useState)(o),s=e=>()=>r(e);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("h4",{children:[(0,i.__)("Choose a style","mailpoet")," ",(0,h.jsx)("i",{className:"mailpoet_info"})]}),(0,h.jsxs)("div",{id:"mailpoet_style_types",children:[(0,h.jsxs)("div",{className:"mailpoet_form_field mailpoet_form_style_type_brand",children:[(0,h.jsx)("input",{type:"radio",name:"style_type",id:"style_type_brand",value:M,checked:n===M,onChange:s(M)}),(0,h.jsxs)("label",{htmlFor:"style_type_brand",children:[(0,h.jsx)("h1",{className:"style_type_typography",style:{fontFamily:e.fontFamily,fontWeight:e.fontWeight},children:"Aa"}),(0,h.jsxs)("span",{className:"style_type_colors",children:[(0,h.jsx)("span",{style:{background:e.foreground}}),(0,h.jsx)("span",{style:{background:e.background}})]}),(0,h.jsx)("i",{className:"mailpoet_checkmark radio_checkmark"})]})]}),(0,h.jsxs)("div",{className:"mailpoet_form_field mailpoet_form_style_type_theme",children:[(0,h.jsx)("input",{type:"radio",name:"style_type",id:"style_type_theme",value:A,checked:n===A,onChange:s(A)}),(0,h.jsxs)("label",{htmlFor:"style_type_theme",children:[(0,h.jsx)("h1",{className:"style_type_typography",style:{fontFamily:t.fontFamily,fontWeight:t.fontWeight},children:"Aa"}),(0,h.jsxs)("span",{className:"style_type_colors",children:[(0,h.jsx)("span",{style:{background:t.foreground}}),(0,h.jsx)("span",{style:{background:t.background}})]}),(0,h.jsx)("i",{className:"mailpoet_checkmark radio_checkmark"})]})]})]})]})}const R=(e,t)=>{const o=t.offset(),n=t.height(),r=t.width();return!(e.pageXo.left+r||e.pageYo.top+n)},V={};V._contentWidgets=new(E().Collection.extend({model:C.extend({defaults:{name:"",priority:100,widgetView:void 0}}),comparator:"priority"})),V.registerWidget=e=>{const t=x.getConfig().get("hiddenWidgets");return(!t||!t.includes(e.name))&&V._contentWidgets.add(e)},V.getWidgets=function(){return V._contentWidgets},V._layoutWidgets=new(E().Collection.extend({model:C.extend({defaults:{name:"",priority:100,widgetView:void 0}}),comparator:"priority"})),V.registerLayoutWidget=function(e){return V._layoutWidgets.add(e)},V.getLayoutWidgets=function(){return V._layoutWidgets};const D=f().View.extend({getTemplate:()=>window.templates.sidebar,regions:{contentRegion:".mailpoet_content_region",layoutRegion:".mailpoet_layout_region",stylesRegion:".mailpoet_styles_region",previewRegion:".mailpoet_preview_region"},events:{"click .mailpoet_sidebar_region h3, .mailpoet_sidebar_region .handlediv":function(e){const t=this.$el.find(".mailpoet_sidebar_region:not(.closed)"),o=this.$el.find(e.target).closest(".mailpoet_sidebar_region");t.find(".mailpoet_region_content").velocity("slideUp",{duration:250,easing:"easeOut",complete:()=>{t.addClass("closed")}}),t.get(0)!==o.get(0)&&o.find(".mailpoet_region_content").velocity("slideDown",{duration:250,easing:"easeIn",complete:()=>{o.removeClass("closed")}})}},templateContext(){return{isWoocommerceTransactional:this.model.isWoocommerceTransactional()}},initialize(){w()(window).on("resize",this.updateHorizontalScroll.bind(this)).on("scroll",this.updateHorizontalScroll.bind(this))},onRender(){this.showChildView("contentRegion",new V.SidebarWidgetsView(x.getWidgets())),this.showChildView("layoutRegion",new V.SidebarLayoutWidgetsView(x.getLayoutWidgets())),this.showChildView("stylesRegion",new V.SidebarStylesView({model:x.getGlobalStyles(),availableStyles:x.getAvailableStyles(),isWoocommerceTransactional:this.model.isWoocommerceTransactional()}))},updateHorizontalScroll(){this.$el.parent().each((function(){const e=w()(this);if("fixed"===e.css("position")){const t=e.parent().offset().left-w()(window).scrollLeft();e.css("left",`${t}px`)}else e.css("left","")}))},onDomRefresh(){this.$el.parent().stick_in_parent({offset_top:32}),this.$el.parent().on("sticky_kit:stick",this.updateHorizontalScroll.bind(this)),this.$el.parent().on("sticky_kit:unstick",this.updateHorizontalScroll.bind(this)),this.$el.parent().on("sticky_kit:bottom",this.updateHorizontalScroll.bind(this)),this.$el.parent().on("sticky_kit:unbottom",this.updateHorizontalScroll.bind(this))}});V.SidebarWidgetsCollectionView=f().CollectionView.extend({childView(e){return e.get("widgetView")}}),V.SidebarWidgetsView=f().View.extend({getTemplate:()=>window.templates.sidebarContent,regions:{widgets:".mailpoet_region_content"},initialize(e){this.widgets=e},onRender(){this.showChildView("widgets",new V.SidebarWidgetsCollectionView({collection:this.widgets}))}}),V.SidebarLayoutWidgetsView=V.SidebarWidgetsView.extend({getTemplate:()=>window.templates.sidebarLayout}),V.SidebarStylesView=f().View.extend({brandStylesRoot:null,getTemplate:()=>window.templates.sidebarStyles,behaviors:{ColorPickerBehavior:{},WooCommerceStylesBehavior:{}},events(){return{"change #mailpoet_text_font_color":c.default.partial(this.changeColorField,"text.fontColor"),"change #mailpoet_text_font_family":function(e){this.model.set("text.fontFamily",e.target.value)},"change #mailpoet_text_font_size":function(e){this.model.set("text.fontSize",e.target.value)},"change #mailpoet_h1_font_color":c.default.partial(this.changeColorField,"h1.fontColor"),"change #mailpoet_h1_font_family":function(e){this.model.set("h1.fontFamily",e.target.value)},"change #mailpoet_h1_font_size":function(e){this.model.set("h1.fontSize",e.target.value)},"change #mailpoet_h2_font_color":c.default.partial(this.changeColorField,"h2.fontColor"),"change #mailpoet_h2_font_family":function(e){this.model.set("h2.fontFamily",e.target.value)},"change #mailpoet_h2_font_size":function(e){this.model.set("h2.fontSize",e.target.value)},"change #mailpoet_h3_font_color":c.default.partial(this.changeColorField,"h3.fontColor"),"change #mailpoet_h3_font_family":function(e){this.model.set("h3.fontFamily",e.target.value)},"change #mailpoet_h3_font_size":function(e){this.model.set("h3.fontSize",e.target.value)},"change #mailpoet_a_font_color":c.default.partial(this.changeColorField,"link.fontColor"),"change #mailpoet_a_font_underline":function(e){this.model.set("link.textDecoration",e.target.checked?e.target.value:"none")},"change #mailpoet_text_line_height":function(e){this.model.set("text.lineHeight",e.target.value)},"change #mailpoet_heading_line_height":function(e){this.model.set("h1.lineHeight",e.target.value),this.model.set("h2.lineHeight",e.target.value),this.model.set("h3.lineHeight",e.target.value)},"change #mailpoet_newsletter_background_color":c.default.partial(this.changeColorField,"wrapper.backgroundColor"),"change #mailpoet_background_color":c.default.partial(this.changeColorField,"body.backgroundColor")}},templateContext(){return{model:this.model.toJSON(),availableStyles:this.availableStyles.toJSON(),isWoocommerceTransactional:this.isWoocommerceTransactional}},initialize(e){this.availableStyles=e.availableStyles,this.isWoocommerceTransactional=e.isWoocommerceTransactional,x.getChannel().on("historyUpdate",this.render)},changeField(e,t){this.model.set(e,w()(t.target).val())},changeColorField(e,t){const o=w()(t.target).val()||"transparent";this.model.set(e,o)},onRender(){const e=this.$el.find("#mailpoet_brand_styles")[0],t=r.MailPoet.FeaturesController.isSupported(r.MailPoet.FeaturesController.FEATURE_BRAND_TEMPLATES);e&&t&&(window.mailpoet_brand_styles||{}).available&&(this.brandStylesRoot=(0,s.s)(e),this.brandStylesRoot.render((0,h.jsx)(N,{})))},onDestroy(){this.brandStylesRoot&&this.brandStylesRoot.unmount()}}),x.on("before:start",(e=>{const t=e;t.registerWidget=V.registerWidget,t.getWidgets=V.getWidgets,t.registerLayoutWidget=V.registerLayoutWidget,t.getLayoutWidgets=V.getLayoutWidgets})),x.on("start",(e=>{const t=new D({model:e.getNewsletter()});e._appView.showChildView("sidebarRegion",t)}));var P=o(42305),I={};I.NewsletterModel=C.extend({whitelisted:["id","subject","preheader","type"],initialize:function(){this.on("change",(function(){x.getChannel().trigger("autoSave")}))},toJSON:function(){return c.default.pick(C.prototype.toJSON.call(this),this.whitelisted)},isWoocommerceTransactional:function(){return"wc_transactional"===this.get("type")},isAutomationEmail:function(){return["automation","automation_transactional"].includes(this.get("type"))},isConfirmationEmailTemplate:function(){return"confirmation_email"===this.get("type")},isStandardEmail:function(){return this.get("type")===P.j9.Standard}}),I._blockTypes={},I.registerBlockType=function(e,t){I._blockTypes[e]=t},I.getBlockTypeModel=function(e){return e in I._blockTypes?I._blockTypes[e].blockModel:I._blockTypes.unknownBlockFallback.blockModel},I.getBlockTypeView=function(e){return e in I._blockTypes?I._blockTypes[e].blockView:I._blockTypes.unknownBlockFallback.blockView},I.getBody=function(){return{content:x._contentContainer.toJSON(),globalStyles:x.getGlobalStyles().toJSON(),blockDefaults:c.default.omit(x.getConfig().toJSON().blockDefaults,"text","image")}},I.toJSON=function(){return c.default.extend({body:I.getBody()},x.getNewsletter().toJSON())},I.getNewsletter=function(){return I.newsletter},I.findModels=function(e){var t=x._contentContainer.getChildren();return c.default.filter(t,e)},I.renderContent=function(e){x._contentContainer&&x._contentContainer.destroy(),x._contentContainerView&&x._contentContainerView.destroy(),x._contentContainer=new(x.getBlockTypeModel("container"))(e,{parse:!0}),x._contentContainerView=new(x.getBlockTypeView("container"))({model:x._contentContainer,renderOptions:{depth:0}}),x._appView.showChildView("contentRegion",x._contentContainerView)},x.on("before:start",(function(e,t){var o=e;o.registerBlockType=I.registerBlockType,o.getBlockTypeModel=I.getBlockTypeModel,o.getBlockTypeView=I.getBlockTypeView,o.toJSON=I.toJSON,o.getBody=I.getBody,o.getNewsletter=I.getNewsletter,o.findModels=I.findModels,I.newsletter=new I.NewsletterModel(c.default.omit(c.default.clone(t.newsletter),["body"]))})),x.on("start",(function(e,t){var o=e,n=t.newsletter.body,s=c.default.has(n,"content")?n.content:{};c.default.has(t.newsletter,"body")&&c.default.isObject(t.newsletter.body)||r.MailPoet.Notice.error((0,i.__)("Contents of this newsletter are corrupted and may be lost, you may need to add new content to this newsletter, or create a new one. If possible, please contact us and report this issue.","mailpoet"),{static:!0}),I.renderContent(s),o.getChannel().on("historyUpdate",(function(e){I.renderContent(e.content)}),this)}));var F={};F.HeadingView=f().View.extend({getTemplate:function(){return window.templates.heading},templateContext:function(){return{model:this.model.toJSON(),isWoocommerceTransactional:this.model.isWoocommerceTransactional(),isAutomationEmail:this.model.isAutomationEmail(),isConfirmationEmailTemplate:this.model.isConfirmationEmailTemplate()}},events:function(){return{"change .mailpoet_input_title":c.default.partial(this.changeField,"subject"),"change .mailpoet_input_preheader":c.default.partial(this.changeField,"preheader"),"change #mailpoet_heading_email_type":e=>{x.getChannel().trigger("changeWCEmailType",e.target.value)}}},changeField:function(e,t){this.model.set(e,w()(t.target).val())}}),x.on("start",(function(e){var t=e.getNewsletter();e._appView.showChildView("headingRegion",new F.HeadingView({model:t}));const o=document.getElementById("tooltip-designer-subject-line"),n=document.getElementById("tooltip-designer-preheader");t.isWoocommerceTransactional()||t.isAutomationEmail()||(o&&r.MailPoet.helpTooltip.show(o,{tooltipId:"tooltip-designer-subject-line-ti",tooltip:(0,i.__)("You can add MailPoet shortcodes here. For example, you can add your subscribers' first names by using this shortcode: [subscriber:firstname | default:reader]. Simply copy and paste the shortcode into the field.","mailpoet"),place:"right"}),n&&r.MailPoet.helpTooltip.show(n,{tooltipId:"tooltip-designer-preheader-ti",tooltip:(0,i.__)("This optional text will appear in your subscribers' inboxes, beside the subject line. Write something enticing!","mailpoet")+" "+(0,i.__)("Max length is 250 characters, however, we recommend 80 characters.","mailpoet")}))}));var L=o(47317),z=o.n(L),H={};H.HistoryView=f().View.extend({MAX_HISTORY_STATES:25,elements:{redo:null,undo:null},events:{"click #mailpoet-history-arrow-undo":"undo","click #mailpoet-history-arrow-redo":"redo"},model:{statesStack:[],currentStateIndex:0},getTemplate:function(){return window.templates.history},initialize:function(){var e=this;x.getChannel().on("afterEditorSave",this.addState,this),z().bind(["ctrl+z","command+z"],(function(){e.undo()})),z().bind(["shift+ctrl+z","shift+command+z"],(function(){e.redo()}))},onAttach:function(){this.elements.redo=document.getElementById("mailpoet-history-arrow-redo"),this.elements.undo=document.getElementById("mailpoet-history-arrow-undo"),this.addState(x.toJSON())},addState:function(e){var t;e&&e.body&&(t=JSON.stringify(e.body),this.model.statesStack[this.model.currentStateIndex]!==t&&(this.model.currentStateIndex>0&&this.model.statesStack.splice(0,this.model.currentStateIndex),this.model.statesStack.unshift(t),this.model.currentStateIndex=0,this.model.statesStack.length=Math.min(this.model.statesStack.length,this.MAX_HISTORY_STATES),this.updateArrowsUI()))},canUndo:function(){return this.model.currentStateIndex0},undo:function(){this.canUndo()&&(this.model.currentStateIndex=Math.min(this.model.statesStack.length-1,this.model.currentStateIndex+1),this.updateArrowsUI(),this.applyState(this.model.currentStateIndex))},redo:function(){this.canRedo()&&(this.model.currentStateIndex=Math.max(0,this.model.currentStateIndex-1),this.updateArrowsUI(),this.applyState(this.model.currentStateIndex))},updateArrowsUI:function(){this.elements.undo.classList.toggle("mailpoet_history_arrow_inactive",!this.canUndo()),this.elements.redo.classList.toggle("mailpoet_history_arrow_inactive",!this.canRedo()),this.elements.undo.setAttribute("title",this.canUndo()?(0,i._x)("Undo","A button title when user can undo the change in editor","mailpoet"):(0,i._x)("No actions available to undo.","A button title when user can't undo the change in editor","mailpoet")),this.elements.redo.setAttribute("title",this.canRedo()?(0,i._x)("Redo","A button title when user can redo the change in editor","mailpoet"):(0,i._x)("No actions available to redo.","A button title when user can't redo the change in editor","mailpoet"))},applyState:function(e){const t=JSON.parse(this.model.statesStack[e]);x.getChannel().trigger("historyUpdate",t)}}),x.on("start",(function(e){e._appView.showChildView("historyRegion",new H.HistoryView)})),o(96300);var Z={_query:function(e){return r.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"automatedLatestContent",action:e.action,data:e.options||{}})}};Z._cachedQuery=c.default.memoize(Z._query,JSON.stringify),Z.getNewsletter=function(e){return Z._query({action:"get",options:e})},Z.getPostTypes=function(){return Z._cachedQuery({action:"getPostTypes",options:{}}).then((function(e){return c.default.values(e.data)}))},Z.getTaxonomies=function(e){return Z._cachedQuery({action:"getTaxonomies",options:{postType:e}}).then((function(e){return e.data}))},Z.getTerms=function(e){return Z._cachedQuery({action:"getTerms",options:e}).then((function(e){return e.data}))},Z.getPosts=function(e){return Z._cachedQuery({action:"getPosts",options:e}).then((function(e){return e.data}))},Z.getTransformedPosts=function(e){return Z._cachedQuery({action:"getTransformedPosts",options:e}).then((function(e){return e.data}))},Z.getBulkTransformedPosts=function(e){return Z._query({action:"getBulkTransformedPosts",options:e}).then((function(e){return e.data}))},Z.saveNewsletter=function(e){return r.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"save",data:e||{}})},Z.previewNewsletter=function(e){return r.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"sendPreview",data:e||{}})},x.on("start",(function(){Z.getPostTypes()})),function(e){if(e.URL=e.URL||e.webkitURL,e.Blob&&e.URL)try{return void new Blob}catch(e){}var t=e.BlobBuilder||e.WebKitBlobBuilder||e.MozBlobBuilder||function(e){var t=function(e){return Object.prototype.toString.call(e).match(/^\[object\s(.*)\]$/)[1]},o=function(){this.data=[]},n=function(e,t,o){this.data=e,this.size=e.length,this.type=t,this.encoding=o},r=o.prototype,i=n.prototype,s=e.FileReaderSync,a=function(e){this.code=this[this.name=e]},l="NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR".split(" "),c=l.length,d=e.URL||e.webkitURL||e,u=d.createObjectURL,h=d.revokeObjectURL,m=d,p=e.btoa,g=e.atob,f=e.ArrayBuffer,v=e.Uint8Array,b=/^[\w-]+:\/*\[?[\w\.:-]+\]?(?::[0-9]+)?/;for(n.fake=i.fake=!0;c--;)a.prototype[l[c]]=c+1;return d.createObjectURL||(m=e.URL=function(e){var t,o=document.createElementNS("http://www.w3.org/1999/xhtml","a");return o.href=e,"origin"in o||("data:"===o.protocol.toLowerCase()?o.origin=null:(t=e.match(b),o.origin=t&&t[1])),o}),m.createObjectURL=function(e){var t,o=e.type;return null===o&&(o="application/octet-stream"),e instanceof n?(t="data:"+o,"base64"===e.encoding?t+";base64,"+e.data:"URI"===e.encoding?t+","+decodeURIComponent(e.data):p?t+";base64,"+p(e.data):t+","+encodeURIComponent(e.data)):u?u.call(d,e):void 0},m.revokeObjectURL=function(e){"data:"!==e.substring(0,5)&&h&&h.call(d,e)},r.append=function(e){var o=this.data;if(v&&(e instanceof f||e instanceof v)){for(var r="",i=new v(e),l=0,c=i.length;l1?t:this.data.length),o,this.encoding)},i.toString=function(){return"[object Blob]"},i.close=function(){this.size=0,delete this.data},o}(e);e.Blob=function(e,o){var n=o&&o.type||"",r=new t;if(e)for(var i=0,s=e.length;i Template exported")}))}};G.SaveView=f().View.extend({getTemplate:function(){return window.templates.save},templateContext:function(){return{wrapperClass:this.wrapperClass,isWoocommerceTransactional:this.model.isWoocommerceTransactional(),isAutomationEmail:this.model.isAutomationEmail(),woocommerceCustomizerEnabled:x.getConfig().get("woocommerceCustomizerEnabled"),isConfirmationEmailTemplate:this.model.isConfirmationEmailTemplate(),confirmationEmailCustomizerEnabled:x.getConfig().get("confirmationEmailCustomizerEnabled")}},events:{"click .mailpoet_save_button":"save","click .mailpoet_save_show_options":"toggleSaveOptions","click .mailpoet_save_next":"next","click .mailpoet_save_template":"showSaveAsTemplate","click .mailpoet_save_as_template":"saveAsTemplate","click .mailpoet_save_export":"showExportTemplate","click .mailpoet_export_template":"exportTemplate","click .mailpoet_save_activate_wc_customizer_button":"activateWooCommerceCustomizer","click .mailpoet_save_activate_confirmation_email_customizer_button":"activateConfirmationEmailCustomizer","click .mailpoet_save_go_to_automation":"saveAndGoToAutomation","click .mailpoet_show_preview":"showPreview"},initialize:function(){this.setDropdownDirectionDown(),x.getChannel().on("beforeEditorSave",this.beforeSave,this),x.getChannel().on("afterEditorSave",this.afterSave,this),x.getChannel().on("editorSaveFailed",this.handleSavingErrors,this)},setDropdownDirectionDown:function(){this.wrapperClass="mailpoet_save_dropdown_down"},setDropdownDirectionUp:function(){this.wrapperClass="mailpoet_save_dropdown_up"},onRender:function(){this.validateNewsletter(x.toJSON())},save:function(){this.model.isConfirmationEmailTemplate()&&this.$(".mailpoet_save_button").hasClass("button-disabled")||(this.hideSaveOptions(),x.getChannel().request("save"))},beforeSave:function(){this.$(".mailpoet_autosaved_at").text((0,i.__)("Saving...","mailpoet"))},afterSave:function(e){this.validateNewsletter(e),this.$(".mailpoet_editor_last_saved .mailpoet_autosaved_message").removeClass("mailpoet_hidden"),this.$(".mailpoet_autosaved_at").text("")},handleSavingErrors:function(){this.showError((0,i.__)("The email could not be saved. Please, clear browser cache and reload the page. If the problem persists, duplicate the email and try again.","mailpoet"))},showSaveOptions:function(){this.$(".mailpoet_save_show_options").addClass("mailpoet_save_show_options_active"),this.$(".mailpoet_save_options").removeClass("mailpoet_hidden"),this.hideSaveAsTemplate(),this.hideExportTemplate()},hideSaveOptions:function(){this.$(".mailpoet_save_show_options").removeClass("mailpoet_save_show_options_active"),this.$(".mailpoet_save_options").addClass("mailpoet_hidden"),this.hideSaveAsTemplate(),this.hideExportTemplate()},toggleSaveOptions:function(){this.$(".mailpoet_save_show_options").hasClass("mailpoet_save_show_options_active")?this.hideSaveOptions():this.showSaveOptions()},showSaveAsTemplate:function(){this.$(".mailpoet_save_as_template_container").removeClass("mailpoet_hidden")},hideSaveAsTemplate:function(){this.$(".mailpoet_save_as_template_container").addClass("mailpoet_hidden")},saveAsTemplate:function(){var e=this.$(".mailpoet_save_as_template_name").val(),t=w()("#mailpoet_editor_top");""===e?r.MailPoet.Notice.error((0,i.__)("Please add a template name","mailpoet"),{positionAfter:t,scroll:!0}):(G.saveTemplate({name:e}).then((function(){r.MailPoet.Notice.success((0,i.__)("Template has been saved.","mailpoet"),{positionAfter:t,scroll:!0}),r.MailPoet.trackEvent("Editor > Template saved")})).catch((function(){r.MailPoet.Notice.error((0,i.__)("Template has not been saved, please try again","mailpoet"),{positionAfter:t,scroll:!0})})),this.hideSaveOptions())},showExportTemplate:function(){this.$(".mailpoet_export_template_container").removeClass("mailpoet_hidden")},hideExportTemplate:function(){this.$(".mailpoet_export_template_container").addClass("mailpoet_hidden")},exportTemplate:function(){var e=this.$(".mailpoet_export_template_name").val(),t=w()("#mailpoet_editor_top");""===e?r.MailPoet.Notice.error((0,i.__)("Please add a template name","mailpoet"),{positionAfter:t,scroll:!0}):(G.exportTemplate({name:e}),this.hideExportTemplate())},showPreview:function(){var e=x.toJSON();c.default.isUndefined(e.body)||(e.body=JSON.stringify(e.body)),r.MailPoet.Modal.loading(!0),r.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"newsletters",action:"showPreview",data:e}).always((function(){r.MailPoet.Modal.loading(!1)})).done(function(e){this.previewView=new G.NewsletterPreviewView({model:new G.NewsletterPreviewModel,previewType:window.localStorage.getItem(x.getConfig().get("newsletterPreview.previewTypeLocalStorageKey")),previewUrl:e.meta.preview_url}),this.previewView.render(),r.MailPoet.Modal.popup({template:"",element:this.previewView.$el,minWidth:"95%",height:"100%",title:(0,i.__)("Newsletter Preview","mailpoet"),onCancel:function(){this.previewView.destroy(),this.previewView=null}.bind(this)}),r.MailPoet.trackEvent("Editor > Browser Preview")}.bind(this)).fail((function(e){e.errors.length>0&&r.MailPoet.Notice.error(e.errors.map((function(e){return e.message})),{scroll:!0})}))},next:function(){this.hideSaveOptions(),this.$(".mailpoet_save_next").hasClass("button-disabled")||(G._cancelAutosave(),G.save().done((function(){window.location.href=x.getConfig().get("urls.send")})))},saveAndGoToAutomation:function(){this.hideSaveOptions(),G._cancelAutosave(),G.save().done((function(){const e=`admin.php?page=mailpoet-automation-editor&id=${x.getNewsletter().get("options").get("automationId")}`;window.location.href=e}))},validateNewsletter:function(e){var t,o="",n=x.getNewsletter();x._contentContainer.isValid()?e&&e.body&&e.body.content?(t=e.body.content,o=JSON.stringify(e.body.content),t.blocks&&Array.isArray(t.blocks)&&0!==t.blocks.length?x.getConfig().get("validation.validateUnsubscribeLinkPresent")&&o.indexOf("[link:subscription_unsubscribe_url]")<0&&o.indexOf("[link:subscription_unsubscribe]")<0&&"sent"!==n.get("status")?this.showValidationError((0,i.__)('All emails must include an "Unsubscribe" link. Add a footer widget to your email to continue.',"mailpoet")):x.getConfig().get("validation.validateActivationLinkIsPresent")&&o.indexOf("[activation_link]")<0?this.showValidationError((0,i.__)("Don't forget to include the [activation_link] shortcode in the email","mailpoet")):"re_engagement"===n.get("type")&&o.indexOf("[link:subscription_re_engage_url]")<0?this.showValidationError((0,i.__)("A re-engagement email must include a link with [link:subscription_re_engage_url] shortcode.","mailpoet")):"notification"===n.get("type")&&o.indexOf('"type":"automatedLatestContent"')<0&&o.indexOf('"type":"automatedLatestContentLayout"')<0?this.showValidationError((0,i._x)("Please add an “Automatic Latest Content” widget to the email from the right sidebar.","(Please reuse the current translation used for the string “Automatic Latest Content”) This Error message is displayed when a user tries to send a “Post Notification” email without any “Automatic Latest Content” widget inside","mailpoet")):"standard"!==n.get("type")||"sent"!==n.get("status")?this.hideValidationError():this.showValidationError((0,i.__)("This email has already been sent. It can be edited, but not sent again. Duplicate this email if you want to send it again.","mailpoet")):this.showValidationError((0,i.__)("Poet, please add prose to your masterpiece before you send it to your followers.","mailpoet"))):this.handleSavingErrors():this.showValidationError(x._contentContainer.validationError)},showError:function(e){var t=this.$(".mailpoet_save_error");t.html(e.replace(/\. /g,". ")),t.removeClass("mailpoet_hidden")},hideError:function(){this.$(".mailpoet_save_error").addClass("mailpoet_hidden")},showValidationError:function(e){this.showError(e),this.$(".mailpoet_save_next").addClass("button-disabled"),this.model.isConfirmationEmailTemplate()&&this.$(".mailpoet_save_button").attr("disabled","disabled").addClass("button-disabled")},hideValidationError:function(){this.hideError(),this.$(".mailpoet_save_next").removeClass("button-disabled"),this.model.isConfirmationEmailTemplate()&&this.$(".mailpoet_save_button").removeAttr("disabled").removeClass("button-disabled")},activateWooCommerceCustomizer:function(){var e=w()(".mailpoet_save_woocommerce_customizer_disabled");return r.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"settings",action:"set",data:{"woocommerce.use_mailpoet_editor":1}}).done((function(){e.addClass("mailpoet_hidden"),r.MailPoet.trackEvent("Editor > WooCommerce email customizer enabled")})).fail((function(e){r.MailPoet.Notice.showApiErrorNotice(e,{scroll:!0})}))},activateConfirmationEmailCustomizer:function(){var e=w()(".mailpoet_save_confirmation_email_disabled");return r.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"settings",action:"set",data:{"signup_confirmation.use_mailpoet_editor":1}}).done((function(){e.addClass("mailpoet_hidden"),r.MailPoet.trackEvent("Editor > Confirmation email customizer enabled")})).fail((function(e){r.MailPoet.Notice.showApiErrorNotice(e,{scroll:!0})}))}}),G.autoSave=function(){G._cancelAutosave(),j=setTimeout((function(){if(U)return U=!1,void G._cancelAutosave();G.isConfirmationEmailValid()?x.getChannel().request("save").always((function(){G._cancelAutosave()})):G._cancelAutosave()}),1e3)},G._cancelAutosave=function(){j&&(clearTimeout(j),j=void 0)},G.onHistoryUpdate=function(){U=!0},G.beforeExitWithUnsavedChanges=function(e){var t,o;if(j)return t=(0,i.__)("There are unsaved changes which will be lost if you leave this page.","mailpoet"),(o=e||window.event)&&(o.returnValue=t),t},G.NewsletterPreviewModel=C.extend({defaults:{previewSendingError:!1,previewSendingSuccess:!1,sendingPreview:!1,mssPendingApproval:window.mailpoet_mss_key_pending_approval,mssKeyPendingApprovalRefreshMessage:!0,awaitingKeyCheck:!1}}),G.NewsletterPreviewView=f().View.extend({className:"mailpoet_browser_preview_wrapper",getTemplate:function(){return window.templates.newsletterPreview},modelEvents:{change:"render"},events:function(){return{"change .mailpoet_browser_preview_type":"changeBrowserPreviewType","click #mailpoet_send_preview":"sendPreview","click #refresh-mss-key-status":"refreshMssKeyStatus"}},initialize:function(e){this.previewType=e.previewType||"mobile",this.previewUrl=e.previewUrl,this.width="100%",this.height="100%"},templateContext:function(){return{previewType:this.previewType,previewUrl:this.previewUrl,width:this.width,height:this.height,email:this.$("#mailpoet_preview_to_email").val()||window.currentUserEmail,previewSendingError:this.model.get("previewSendingError"),sendingPreview:this.model.get("sendingPreview"),mssKeyPendingApproval:this.model.get("mssPendingApproval"),mssKeyPendingApprovalRefreshMessage:this.model.get("mssKeyPendingApprovalRefreshMessage"),awaitingKeyCheck:this.model.get("awaitingKeyCheck")}},changeBrowserPreviewType:function(e){var t=w()(e.target).val();"mobile"===t?(this.$(".mailpoet_browser_preview_container").addClass("mailpoet_browser_preview_container_mobile"),this.$(".mailpoet_browser_preview_container").removeClass("mailpoet_browser_preview_container_desktop"),this.$(".mailpoet_browser_preview_container").removeClass("mailpoet_browser_preview_container_send_to_email")):"desktop"===t?(this.$(".mailpoet_browser_preview_container").addClass("mailpoet_browser_preview_container_desktop"),this.$(".mailpoet_browser_preview_container").removeClass("mailpoet_browser_preview_container_mobile"),this.$(".mailpoet_browser_preview_container").removeClass("mailpoet_browser_preview_container_send_to_email")):(this.$(".mailpoet_browser_preview_container").addClass("mailpoet_browser_preview_container_send_to_email"),this.$(".mailpoet_browser_preview_container").removeClass("mailpoet_browser_preview_container_desktop"),this.$(".mailpoet_browser_preview_container").removeClass("mailpoet_browser_preview_container_mobile")),window.localStorage.setItem(x.getConfig().get("newsletterPreview.previewTypeLocalStorageKey"),t),this.previewType=t},sendPreview:function(){var e=this,t=this.$("#mailpoet_preview_to_email"),o={subscriber:t.val(),id:x.getNewsletter().get("id")};if(o.subscriber.length<=0)return r.MailPoet.Notice.error((0,i.__)("Enter an email address to send the preview newsletter to.","mailpoet"),{positionAfter:t,scroll:!0}),!1;this.model.set("previewSendingError",!1),this.model.set("previewSendingSuccess",!1),this.model.set("sendingPreview",!0),x.getChannel().request("save").always((function(){Z.previewNewsletter(o).done((function(){e.model.set("sendingPreview",!1),e.model.set("previewSendingSuccess",!0),r.MailPoet.trackEvent("Editor > Preview sent",{"Domain name":o.subscriber.substring(o.subscriber.indexOf("@")+1)})})).fail((function(t){e.model.set("sendingPreview",!1),e.model.set("previewSendingError",!0);let o=` ${(0,i.__)("Sorry, there was an error, please try again later.","mailpoet")}
`;t.errors.length>0&&(o=t.errors.map((function(e){let t=`\n \n ${(0,i.__)("The email could not be sent due to a technical issue with %1$s","mailpoet").replace("%1$s",window.config.mtaMethod)}:\n ${e.message} \n
\n `;return"PHPMail"===window.config.mtaMethod?t+=`\n ${(0,i.__)("Please check your sending method configuration, you may need to consult with your hosting company.","mailpoet")}
\n \n ${(0,i.__)("The easy alternative is to send emails with MailPoet Sending Service instead, like thousands of other users do.","mailpoet")}
\n \n \n ${(0,i.__)("Sign up for free in minutes","mailpoet")}\n \n
\n `:t+=`${(0,i.__)("Check your [link]sending method settings[/link].","mailpoet").replace(/\[link\](.*?)\[\/link\]/g,'$1 ')}
`,t})).join("")),document.getElementById("mailpoet_preview_sending_error").innerHTML=o}))}))},refreshMssKeyStatus:function(){return this.model.set("awaitingKeyCheck",!0),r.MailPoet.Ajax.post({api_version:window.mailpoet_api_version,endpoint:"services",action:"refreshMSSKeyStatus"}).done((e=>{this.model.set("awaitingKeyCheck",!1),e.data&&200===e.data.result.code&&(this.model.set("mssPendingApproval",!(0,d.isTruthy)(e.data.result.data.is_approved)),this.model.set("mssKeyPendingApprovalRefreshMessage",!1))})).fail((e=>{if(this.model.set("awaitingKeyCheck",!1),e.errors&&Array.isArray(e.errors)){const t=e.errors.map((e=>e.message));document.querySelector(".pendindig_approval_error").innerHTML=t.join("\n")}}))}}),x.on("before:start",(function(e){var t=e;t.save=G.save,t.getChannel().on("autoSave",G.autoSave),t.getChannel().on("historyUpdate",G.onHistoryUpdate),window.onbeforeunload=G.beforeExitWithUnsavedChanges,t.getChannel().reply("save",t.save)})),x.on("start",(function(e){var t=e.getNewsletter(),o=new G.SaveView({model:t}),n=new G.SaveView({model:t});n.setDropdownDirectionUp(),e._appView.showChildView("topRegion",o),e._appView.showChildView("bottomRegion",n)}));var Y=f(),K={};Y.Behaviors.behaviorsLookup=function(){return K},window.BehaviorsLookup=K,o(48883),K.ColorPickerBehavior=f().Behavior.extend({onRender:function(){var e=this,t="hex6";this.view.$(".mailpoet_color").each((function(){var o=e.view.$(this),n=function(e){e&&e.getAlpha()>0?o.val(e.toString(t)):o.val(""),o.trigger("change")};o.spectrum({clickoutFiresChange:!0,showInput:!0,showInitial:!0,showPalette:!0,showSelectionPalette:!0,palette:[],localStorageKey:"newsletter_editor.spectrum.palette",preferredFormat:t,allowEmpty:!0,chooseText:(0,i._x)("Select","select color","mailpoet"),cancelText:(0,i._x)("Cancel","cancel color selection","mailpoet"),change:n,move:n,hide:n})}))}});var X=o(92710),J=o.n(X);K.ContainerDropZoneBehavior=f().Behavior.extend({defaults:{columnLimit:3},onRender:function(){c.default.isObject(this.view.options.renderOptions)&&!0===this.view.options.renderOptions.disableDragAndDrop||this.addDropZone()},addDropZone:function(){var e,t=this,o=this.view,n=t.$el.get(0);if(0===this.view.renderOptions.depth)e=".mailpoet_droppable_block.mailpoet_droppable_layout_block";else{if(2!==this.view.renderOptions.depth)return;e=".mailpoet_droppable_block:not(.mailpoet_droppable_layout_block)"}J()(n).dropzone({accept:e,overlap:"pointer",ondragenter:function(){o.$el.addClass("mailpoet_drop_active")},ondragleave:function(){t.cleanup()},ondropmove:function(e){var n,r,i,s,a,l,c,d=t.getDropPosition(e.dragmove.pageX,e.dragmove.pageY,o.$el,o.model.get("orientation"),o.model.get("blocks").length),u=o.$el,h="",m="",p=u.offset(),g=t.getCollection();void 0!==d&&(u.find(".mailpoet_drop_marker").remove(),g.isEmpty()||(0===g.length?(s=(i=u.find(o.childViewContainer)).offset().top-u.offset().top,a=i.offset().left-u.offset().left,h=i.width(),m=i.height()):(r=t.getCollection().length===d.index?g.at(d.index-1):g.at(d.index),s=(i=t.getChildren().findByModel(r).$el).offset().top-p.top,a=i.offset().left-p.left,"normal"===d.insertionType?("after"===d.position&&("vertical"===o.model.get("orientation")?s+=i.outerHeight(!0):a+=i.outerWidth()),"vertical"===o.model.get("orientation")?h=i.outerWidth():m=i.outerHeight()):("after"===d.position&&("vertical"===o.model.get("orientation")?a+=i.outerWidth():s+=i.outerHeight()),"vertical"===o.model.get("orientation")?m=i.outerHeight(!0):h=i.outerWidth(!0))),n=w()('
'),0===d.index&&n.addClass("mailpoet_drop_marker_first"),g.length-1===d.index&&n.addClass("mailpoet_drop_marker_last"),d.index>0&&g.length-1>d.index&&n.addClass("mailpoet_drop_marker_middle"),n.addClass("mailpoet_drop_marker_"+d.position),c=(l="before"===d.position?t.getChildren().findByModel(g.at(d.index-1)).$el:t.getChildren().findByModel(g.at(d.index)).$el).outerHeight(!0)-l.outerHeight(),n.css("top",s-c/2),n.css("left",a),n.css("width",h),n.css("height",m),u.append(n)))},ondrop:function(e){var n,r,i,s,a,l=t.getDropPosition(e.dragEvent.pageX,e.dragEvent.pageY,o.$el,o.model.get("orientation"),o.model.get("blocks").length),c=e.draggable.getDropModel(),d=t.getCollection();void 0!==l&&("normal"===l.insertionType?(r="after"===l.position?l.index+1:l.index,"horizontal"===o.model.get("orientation")&&"container"!==c.get("type")?((i=new(window.EditorApplication.getBlockTypeModel("container"))({orientation:"vertical"})).get("blocks").add(c),d.add(i,{at:r})):d.add(c,{at:r}),n=t.getChildren().findByModel(c)):(a=d.at(l.index),i=new(window.EditorApplication.getBlockTypeModel("container"))({orientation:"vertical"===o.model.get("orientation")?"horizontal":"vertical"}),d.remove(a),"horizontal"===i.get("orientation")?("before"===l.position&&((s=new(window.EditorApplication.getBlockTypeModel("container"))({orientation:"vertical"})).get("blocks").add(c),i.get("blocks").add(s)),(s=new(window.EditorApplication.getBlockTypeModel("container"))({orientation:"vertical"})).get("blocks").add(a),i.get("blocks").add(s),"after"===l.position&&((s=new(window.EditorApplication.getBlockTypeModel("container"))({orientation:"vertical"})).get("blocks").add(c),i.get("blocks").add(s))):("before"===l.position&&i.get("blocks").add(c),i.get("blocks").add(a),"after"===l.position&&i.get("blocks").add(c)),d.add(i,{at:l.index}),n=t.getChildren().findByModel(i).children.findByModel(c)),e.draggable.onDrop({dropBehavior:t,droppedModel:c,droppedView:n}),t.cleanup())}})},cleanup:function(){this.view.$el.removeClass("mailpoet_drop_active"),this.view.$(".mailpoet_drop_marker").remove()},getDropPosition:function(e,t,o){var n,r,i,s,a,l,c=0,d=this.view.$el,u=this.view.model.get("orientation"),h=d.offset(),m=h.left,p=h.top,g=d.outerWidth(!0),f=d.outerHeight(!0),v=e-m,b=t-p,y=this._canAcceptNormalInsertion(),w=this._canAcceptSpecialInsertion(),_=!!o;return 0===this.getCollection().length?{insertionType:"normal",index:0,position:"inside"}:("vertical"===u?(n=v,r=g):(n=b,r=f),w&&!y&&(c=.5),n<=r*c&&(_||w)?(i="special",a="before",s=this._computeSpecialIndex(e,t)):n>r*(1-c)&&(_||w)?(i="special",a="after",s=this._computeSpecialIndex(e,t)):(i="normal",a=(l=this._computeNormalIndex(e,t)).position,s=l.index),_||"vertical"!==u||"special"!==i||"horizontal"!==this.getCollection().at(s).get("orientation")||(i="normal",a=(l=this._computeNormalIndex(e,t)).position,s=l.index),"horizontal"!==u||"special"!==i?{insertionType:i,index:s,position:a}:void 0)},_computeNormalIndex:function(e,t){var o,n,r,i=this._computeCellIndex(e,t),s=this.getChildren().findByModel(this.getCollection().at(i)),a=this.view.model.get("orientation"),l=s.$el;return"vertical"===a?(o=t,n=l.offset().top,r=l.outerHeight(!0)):(o=e,n=l.offset().left,r=l.outerWidth(!0)),o<=n+r/2?{index:i,position:"before"}:{index:i,position:"after"}},_computeSpecialIndex:function(e,t){return this._computeCellIndex(e,t)},_computeCellIndex:function(e,t){var o=this.view.model.get("orientation"),n="vertical"===o?t:e,r=this.getChildren().find((function(e){var t,r,i=e.$el;return"vertical"===o?(t=i.offset().top,r=i.outerHeight(!0)):(t=i.offset().left,r=i.outerWidth(!0)),r+=t,t<=n&&n<=r}));return"object"==typeof r?r._index:0},_canAcceptNormalInsertion:function(){var e=this.view.model.get("orientation"),t=this.view.renderOptions.depth,o=this.getChildren().length;return"vertical"===e||"horizontal"===e&&1===t&&o0||x.getDisplayedSettingsId()||this.view.addHighlight()},onMouseLeave:function(){this.isFocusedByPointer=!1,this.isBeingEdited||this.view.removeHighlight()},onStartEditing:function(){this.isBeingEdited=!0,this.view.addHighlight()},onStopEditing:function(){this.isBeingEdited=!1,this.isFocusedByPointer||this.view.removeHighlight()},onStartResizing:function(){this.onStartEditing(),this.view.triggerMethod("resizeStart")},onStopResizing:function(e){this.isFocusedByPointer=R(e,this.view.$el),x.getDisplayedSettingsId()||this.onStopEditing(),this.view.triggerMethod("resizeStop",e)},onDomRefresh:function(){this.isBeingEdited&&this.view.addHighlight()},onChildviewResizeStart:function(){this.onStartEditing(),this.view.triggerMethod("resizeStart")},onChildviewResizeStop:function(e){this.isFocusedByPointer=R(e,this.view.$el),this.onStopEditing(),this.view.triggerMethod("resizeStop",e)}}),K.MediaManagerBehavior=f().Behavior.extend({ui:{"select-image":".mailpoet_field_image_select_image","address-input":".mailpoet_field_image_address"},events:{"click @ui.select-image":"showMediaManager","input @ui.address-input":"changeAddress"},initialize:function(){this.view.options.showImageManager&&this.showMediaManager()},changeAddress:c.default.debounce((function(e){var t=w()(e.target).val(),o=new Image;t||!this.options.onSelect?(o.onload=function(){this.options.onSelect&&this.view[this.options.onSelect]({src:t,width:o.naturalWidth+"px",height:o.naturalHeight+"px"})}.bind(this),o.src=t):this.view[this.options.onSelect]({src:null,width:null,height:null})}),500),showMediaManager:function(){var e,t,o=this;if(this._mediaManager)return this._mediaManager.resetSelections(),void this._mediaManager.open();e=window.wp.media.view.MediaFrame.Select.extend({initialize:function(){window.wp.media.view.MediaFrame.prototype.initialize.apply(this,arguments),c.default.defaults(this.options,{multiple:!0,editing:!1,state:"insert"}),this.createSelection(),this.createStates(),this.bindHandlers(),this.createIframeStates(),this.$el.addClass("hide-title")},resetSelections:function(){this.state().get("selection").reset()},createQuery:function(e){return window.wp.media.query(e)},createStates:function(){var e=this.options;this.states.add([new window.wp.media.controller.Library({id:"insert",title:"Add images",priority:20,toolbar:"main-insert",filterable:"image",library:this.createQuery(e.library),multiple:!!e.multiple&&"reset",editable:!1,allowLocalEdits:!1,displaySettings:!1,displayUserSettings:!1})]),window.wp.media.view.settings.post.featuredImageId&&this.states.add(new window.wp.media.controller.FeaturedImage)},bindHandlers:function(){var e;this.on("router:create:browse",this.createRouter,this),this.on("router:render:browse",this.browseRouter,this),this.on("content:create:browse",this.browseContent,this),this.on("content:render:upload",this.uploadContent,this),this.on("toolbar:create:select",this.createSelectToolbar,this),this.on("menu:create:gallery",this.createMenu,this),this.on("toolbar:create:main-insert",this.createToolbar,this),this.on("toolbar:create:main-gallery",this.createToolbar,this),this.on("toolbar:create:main-embed",this.mainEmbedToolbar,this),this.on("updateExcluded",this.browseContent,this),e={content:{embed:"embedContent","edit-selection":"editSelectionContent"},toolbar:{"main-insert":"mainInsertToolbar"}},c.default.each(e,(function(e,t){c.default.each(e,(function(e,o){this.on(t+":render:"+o,this[e],this)}),this)}),this)},uploadContent:function(){window.wp.media.view.MediaFrame.Select.prototype.uploadContent.apply(this,arguments),this.$el.addClass("hide-toolbar")},embedContent:function(){var e=new window.wp.media.view.Embed({controller:this,model:this.state()}).render();this.content.set(e),e.url.focus()},editSelectionContent:function(){var e,t=this.state(),o=t.get("selection");(e=new window.wp.media.view.AttachmentsBrowser({controller:this,collection:o,selection:o,model:t,sortable:!0,search:!1,dragInfo:!0,AttachmentView:window.wp.media.view.Attachment.EditSelection}).render()).toolbar.set("backToLibrary",{text:"Return to library",priority:-100,click:function(){this.controller.content.mode("browse")}}),this.content.set(e)},selectionStatusToolbar:function(e){var t=this.state().get("editable");e.set("selection",new window.wp.media.view.Selection({controller:this,collection:this.state().get("selection"),priority:-40,editable:t&&function(){this.controller.content.mode("edit-selection")}}).render())},mainInsertToolbar:function(e){var t=this;this.selectionStatusToolbar(e),e.set("insert",{style:"primary",priority:80,text:"Select Image",requires:{selection:!0},click:function(){var e=t.state(),o=e.get("selection");t.close(),e.trigger("insert",o).reset()}})},mainEmbedToolbar:function(e){e.view=new window.wp.media.view.Toolbar.Embed({controller:this,text:"Add images"})}}),t=new e({id:"mailpoet-media-manager",frame:"select",title:"Select image",editing:!1,multiple:!1,library:{type:"image"},displaySettings:!1,button:{text:"Select"}}),this._mediaManager=t,this._mediaManager.on("insert",(function(){t.state().get("selection").each((function(e){var t=e.get("sizes"),n=c.default.sortBy(c.default.keys(t),(function(e){return Math.abs(1320-t[e].width)})),r=t[c.default.first(n)].width,i=c.default.filter(c.default.values(t),(function(e){return e.width===r})),s=c.default.max(i,(function(e){return e.height}));o.options.onSelect&&o.view[o.options.onSelect]({height:s.height+"px",width:s.width+"px",src:s.url,alt:void 0!==e.get("alt")?e.get("alt"):""})}))})),this._mediaManager.open()},onBeforeDestroy:function(){"object"==typeof this._mediaManager&&this._mediaManager.remove()}}),K.ResizableBehavior=f().Behavior.extend({defaults:{elementSelector:null,resizeHandleSelector:!0,transformationFunction:function(e){return e},minLength:0,maxLength:1/0,modelField:"styles.block.height",onResize:function(e){var t=parseFloat(this.view.model.get(this.options.modelField))+this.options.transformationFunction(e.dy);t=Math.min(this.options.maxLength,Math.max(this.options.minLength,t)),this.view.model.set(this.options.modelField,t+"px")}},onRender:function(){this.attachResize(),this.view.$el.addClass("mailpoet_resizable_block")},attachResize:function(){var e,t=this;e=null===this.options.elementSelector?this.view.$el.get(0):this.view.$(this.options.elementSelector).get(0),J()(e).resizable({edges:{top:!1,left:!1,right:!1,bottom:"string"==typeof this.options.resizeHandleSelector?this.view.$(this.options.resizeHandleSelector).get(0):this.options.resizeHandleSelector}}).on("resizestart",(function(){t.view.model.trigger("startResizing"),document.activeElement.blur()})).on("resizemove",(function(e){return t.options.onResize.bind(t)(e)})).on("resizeend",(function(e){t.view.model.trigger("stopResizing",e),t.$el.removeClass("mailpoet_resize_active")}))}}),K.SortableBehavior=f().Behavior.extend({onRender:function(){var e=this.view.collection;c.default.isFunction(this.$el.sortable)&&this.$el.sortable({cursor:"move",start:function(e,t){t.item.data("previousIndex",t.item.index())},end:function(e,t){t.item.removeData("previousIndex")},update:function(t,o){var n=o.item.data("previousIndex"),r=o.item.index(),i=e.at(n);e.remove(i),e.add(i,{at:r})},items:this.options.items})}}),K.ShowSettingsBehavior=f().Behavior.extend({defaults:{ignoreFrom:""},events:{"click .mailpoet_content":"showSettings"},showSettings:function(e){this.isIgnoredElement(e.target)||this.view.triggerMethod("showSettings")},isIgnoredElement:function(e){return this.options.ignoreFrom&&this.options.ignoreFrom.length>0&&w()(e).is(this.options.ignoreFrom)}});var Q=o(3470),ee=o.n(Q);function te(e){e.options.register("mailpoet_shortcodes",{processor:"object",default:{}}),e.options.register("mailpoet_shortcodes_window_title",{processor:"string",default:""}),e.ui.registry.addIcon("mailpoet",' '),e.ui.registry.addButton("mailpoet_shortcodes",{icon:"mailpoet",onAction:function(){var t,o=[],n=e.options.get("mailpoet_shortcodes");Object.keys(n).forEach((function(e){var r;if(Object.prototype.hasOwnProperty.call(n,e)){for(r={name:e,title:e,items:[]},t=0;t ',"accordion-toggle":' ',accordion:' ',"action-next":' ',"action-prev":' ',addtag:' ',"ai-prompt":' ',ai:' ',"align-center":' ',"align-justify":' ',"align-left":' ',"align-none":' ',"align-right":' ',"arrow-left":' ',"arrow-right":' ',bold:' ',bookmark:' ',"border-style":' ',"border-width":' ',brightness:' ',browse:' ',cancel:' ',"cell-background-color":' ',"cell-border-color":' ',"change-case":' ',"character-count":' ',"checklist-rtl":' ',checklist:' ',checkmark:' ',"chevron-down":' ',"chevron-left":' ',"chevron-right":' ',"chevron-up":' ',close:' ',"code-sample":' ',"color-levels":' ',"color-picker":' ',"color-swatch-remove-color":' ',"color-swatch":' ',"comment-add":' ',comment:' ',contrast:' ',copy:' ',crop:' ',"cut-column":' ',"cut-row":' ',cut:' ',"document-properties":' ',drag:' ',"duplicate-column":' ',"duplicate-row":' ',duplicate:' ',"edit-block":' ',"edit-image":' ',"embed-page":' ',embed:' ',emoji:' ',export:' ',fill:' ',"flip-horizontally":' ',"flip-vertically":' ',footnote:' ',"format-painter":' ',format:' ',fullscreen:' ',gallery:' ',gamma:' ',help:' ',"highlight-bg-color":' ',home:' ',"horizontal-rule":' ',"image-options":' ',image:' ',indent:' ',info:' ',"insert-character":' ',"insert-time":' ',invert:' ',italic:' ',language:' ',"line-height":' ',line:' ',link:' ',"list-bull-circle":' ',"list-bull-default":' ',"list-bull-square":' ',"list-num-default-rtl":' ',"list-num-default":' ',"list-num-lower-alpha-rtl":' ',"list-num-lower-alpha":' ',"list-num-lower-greek-rtl":' ',"list-num-lower-greek":' ',"list-num-lower-roman-rtl":' ',"list-num-lower-roman":' ',"list-num-upper-alpha-rtl":' ',"list-num-upper-alpha":' ',"list-num-upper-roman-rtl":' ',"list-num-upper-roman":' ',lock:' ',ltr:' ',minus:' ',"more-drawer":' ',"new-document":' ',"new-tab":' ',"non-breaking":' ',notice:' ',"ordered-list-rtl":' ',"ordered-list":' ',orientation:' ',outdent:' ',"page-break":' ',paragraph:' ',"paste-column-after":' ',"paste-column-before":' ',"paste-row-after":' ',"paste-row-before":' ',"paste-text":' ',paste:' ',"permanent-pen":' ',plus:' ',preferences:' ',preview:' ',print:' ',quote:' ',redo:' ',reload:' ',"remove-formatting":' ',remove:' ',"resize-handle":' ',resize:' ',"restore-draft":' ',"rotate-left":' ',"rotate-right":' ',rtl:' ',save:' ',search:' ',"select-all":' ',selected:' ',send:' ',settings:' ',sharpen:' ',sourcecode:' ',"spell-check":' ',"strike-through":' ',subscript:' ',superscript:' ',"table-caption":' ',"table-cell-classes":' ',"table-cell-properties":' ',"table-cell-select-all":' ',"table-cell-select-inner":' ',"table-classes":' ',"table-delete-column":' ',"table-delete-row":' ',"table-delete-table":' ',"table-insert-column-after":' ',"table-insert-column-before":' ',"table-insert-row-above":' ',"table-insert-row-after":' ',"table-left-header":' ',"table-merge-cells":' ',"table-row-numbering-rtl":' ',"table-row-numbering":' ',"table-row-properties":' ',"table-split-cells":' ',"table-top-header":' ',table:' ',"template-add":' ',template:' ',"temporary-placeholder":' ',"text-color":' ',"text-size-decrease":' ',"text-size-increase":' ',toc:' ',translate:' ',typography:' ',underline:' ',undo:' ',unlink:' ',unlock:' ',"unordered-list":' ',unselected:' ',upload:' ',user:' ',"vertical-align":' ',visualblocks:' ',visualchars:' ',warning:' ',"zoom-in":' ',"zoom-out":' '}}),K.TextEditorBehavior=f().Behavior.extend({defaults:{selector:".mailpoet_content",toolbar1:"bold italic link unlink forecolor mailpoet_shortcodes",toolbar2:"",validElements:"p[class|style],span[class|style],a[href|class|title|target|style],strong[class|style],em[class|style],strike,br,del",invalidElements:"script",blockFormats:"Paragraph=p",plugins:"link mailpoet_shortcodes",configurationFilter:e=>e},initialize:function(){this.listenTo(x.getChannel(),"dragStart",this.hideEditor)},hideEditor:function(){this.tinymceEditor&&this.tinymceEditor.fire("blur")},onDomRefresh:async function(){!0!==this.view.disableTextEditor&&(ee().PluginManager.add("mailpoet_shortcodes",te),await ee().init(this.options.configurationFilter({target:this.el.querySelector(this.options.selector),inline:!0,contextmenu:!1,menubar:!1,toolbar1:this.options.toolbar1,toolbar2:this.options.toolbar2,browser_spellcheck:!0,valid_elements:this.options.validElements,invalid_elements:this.options.invalidElements,block_formats:this.options.blockFormats,relative_urls:!1,remove_script_host:!1,convert_urls:!0,urlconverter_callback:function(e){return e.match(/\[.+\]/g)?e:this.documentBaseURI.toAbsolute(e,this.options.get("remove_script_host"))},plugins:this.options.plugins,setup:e=>{this.tinymceEditor=e,e.on("change",(()=>{this.view.triggerMethod("text:editor:change",e.getContent())})),e.on("click",(t=>{x.getDisplayedSettingsId()&&x.getChannel().trigger("hideSettings"),document.activeElement!==e.targetElm&&e.selection.placeCaretAt(t.clientX,t.clientY)})),e.on("focus",(()=>{this.view.triggerMethod("text:editor:focus")})),e.on("blur",(()=>{this.view.triggerMethod("text:editor:blur")}))}})))}}),K.WooCommerceStylesBehavior=f().Behavior.extend({events:function(){return{"change #mailpoet_wc_branding_color":function(e){let t;const o=e.target.value,n=this.wcHexIsLight(o)?"#202020":"#ffffff";t=this.wcHexIsLight(this.view.model.get("wrapper.backgroundColor"))?this.wcHexIsLight(o)?n:o:this.wcHexIsLight(o)?o:n,this.view.model.set("woocommerce.brandingColor",o),this.view.model.set("woocommerce.headingFontColor",n),this.view.model.set("link.fontColor",t)}}},wcHexIsLight:function(e){const t=e.replace("#","");return(299*parseInt(t.substr(0,2),16)+587*parseInt(t.substr(2,2),16)+114*parseInt(t.substr(4,2),16))/1e3>155}}),o(15379);var oe={},ne=f().View.extend({});oe.BlockModel=C.extend({stale:[],initialize:function(){this.on("change",(function(){this._updateDefaults(),x.getChannel().trigger("autoSave")}))},_getDefaults:function(e,t){var o;return o=c.default.isObject(t)&&c.default.isFunction(t.toJSON)?t.toJSON():t,JSON.parse(JSON.stringify(w().extend(e,o||{})))},_updateDefaults:function(){var e=this.get("context")||this.get("type");x.getConfig().set("blockDefaults."+e,this.toJSON())},toJSON:function(){return c.default.omit(C.prototype.toJSON.call(this),this.stale)},getChildren:function(){return[]}}),oe.BlockView=ne.extend({regions:{toolsRegion:"> .mailpoet_tools"},modelEvents:{change:"render",delete:"deleteBlock",duplicate:"duplicateBlock"},behaviors:{DraggableBehavior:{cloneOriginal:!0,hideOriginal:!0,onDrop:function(e){x.getChannel().trigger("hideSettings"),e.dragBehavior.view.model.destroy()},onDragSubstituteBy:function(e){var t,o;if(c.default.isFunction(e.view.onDragSubstituteBy))return(t=new(e.view.onDragSubstituteBy())).render(),o=t.$el.get(0).cloneNode(!0),t.destroy(),o}},HighlightEditingBehavior:{}},templateContext:function(){return{model:this.model.toJSON(),viewCid:this.cid}},constructor:function(){ne.apply(this,arguments),this.$el.addClass("mailpoet_editor_view_"+this.cid)},initialize:function(){this.on("showSettings",this.showSettings,this)},addHighlight:function(){this.$el.addClass("mailpoet_highlight"),this.showingToolsDisabled||(this.$("> .mailpoet_tools").addClass("mailpoet_display_tools"),this.toolsView.triggerMethod("showTools"))},removeHighlight:function(){this.$el.removeClass("mailpoet_highlight"),this.hideTools()},hideTools:function(){this.$("> .mailpoet_tools").removeClass("mailpoet_display_tools"),this.toolsView.triggerMethod("hideTools")},enableShowingTools:function(){this.showingToolsDisabled=!1},disableShowingTools:function(){this.showingToolsDisabled=!0,this.hideTools()},showSettings:function(e){this.toolsView.triggerMethod("showSettings",e)},getDropFunc:function(){return function(){return this.model.clone()}.bind(this)},disableDragging:function(){this.$el.addClass("mailpoet_ignore_drag")},enableDragging:function(){this.$el.removeClass("mailpoet_ignore_drag")},deleteBlock:function(){this.transitionOut().then(function(){this.model.destroy()}.bind(this))},duplicateBlock:function(){this.model.collection.add(this.model.toJSON(),{at:this.model.collection.findIndex(this.model)})},transitionOut:function(){return this._transition("slideUp","fadeOut","easeIn")},_transition:function(e,t,o){var n=w().Deferred();return this.$el.velocity(e,{duration:250,easing:o,complete:function(){n.resolve()}}).velocity(t,{duration:250,easing:o,queue:!1}),n}}),oe.BlockToolsView=ne.extend({getTemplate:function(){return window.templates.genericBlockTools},events:{"click .mailpoet_edit_block":"toggleSettings","click .mailpoet_delete_block_activate":"showDeletionConfirmation","click .mailpoet_delete_block_cancel":"hideDeletionConfirmation","click .mailpoet_delete_block_confirm":"deleteBlock","click .mailpoet_duplicate_block":"duplicateBlock"},tools:{settings:!0,delete:!0,duplicate:!0,move:!0},getSettingsView:function(){return oe.BlockSettingsView},initialize:function(e){var t=e||{};c.default.isUndefined(t.tools)||(this.tools=w().extend({},this.tools,t.tools||{})),this.on("hideTools",this.hideDeletionConfirmation,this),this.on("showSettings",this.changeSettings)},templateContext:function(){return{model:this.model.toJSON(),viewCid:this.cid,tools:this.tools}},toggleSettings:function(){x.getDisplayedSettingsId()!==this.model.cid?this.changeSettings():x.getChannel().trigger("hideSettings")},changeSettings:function(e){var t=this.getSettingsView(),o=x.getDisplayedSettingsId();if(o){if(o===this.model.cid)return;x.getChannel().trigger("hideSettings")}else document.activeElement.blur(),x.getChannel().trigger("settingsDisplayed",this.model.cid),new t(c.default.extend({model:this.model},e||{})).render()},showDeletionConfirmation:function(){this.$(".mailpoet_delete_block").closest(".mailpoet_block").find("> .mailpoet_block_highlight").css({background:"#E64047",opacity:.5}),this.$(".mailpoet_delete_block").addClass("mailpoet_delete_block_activated")},hideDeletionConfirmation:function(){this.$(".mailpoet_delete_block").closest(".mailpoet_block").find("> .mailpoet_block_highlight").css({background:"transparent",opacity:1}),this.$(".mailpoet_delete_block").removeClass("mailpoet_delete_block_activated")},deleteBlock:function(e){return e.preventDefault(),this.model.trigger("delete"),x.getChannel().trigger("hideSettings"),!1},duplicateBlock:function(e){return e.preventDefault(),this.model.trigger("duplicate"),x.getChannel().trigger("hideSettings"),!1}}),oe.BlockSettingsView=f().View.extend({className:"mailpoet_editor_settings",behaviors:{ColorPickerBehavior:{}},initialize:function(e){var t;this.model.trigger("startEditing"),t={element:this.$el,template:"",position:"right",overlayRender:!1,width:x.getConfig().get("sidepanelWidth"),onCancel:function(){this.destroy()}.bind(this)},this.renderOptions=e.renderOptions||{},"subpanel"===this.renderOptions.displayFormat?r.MailPoet.Modal.subpanel(t):r.MailPoet.Modal.panel(t),this.listenTo(x.getChannel(),"hideSettings",this.close)},templateContext:function(){return{model:this.model.toJSON()}},close:function(){this.destroy()},changeField:function(e,t){this.model.set(e,w()(t.target).val())},changePixelField:function(e,t){this.changeFieldWithSuffix(e,t,"px")},changeFieldWithSuffix:function(e,t,o){this.model.set(e,w()(t.target).val()+o)},changeBoolField:function(e,t){this.model.set(e,"true"===w()(t.target).val())},changeBoolCheckboxField:function(e,t){this.model.set(e,!!w()(t.target).prop("checked"))},changeColorField:function(e,t){var o=w()(t.target).val();""===o&&(o="transparent"),this.model.set(e,o)},onBeforeDestroy:function(){r.MailPoet.Modal.close(),this.model.trigger("stopEditing"),x.getChannel().trigger("settingsDisplayed",null)}}),oe.WidgetView=f().View.extend({className:"mailpoet_widget mailpoet_droppable_block mailpoet_droppable_widget",behaviors:{DraggableBehavior:{drop:function(){throw new Error("Unsupported operation")}}}});var re,ie={},se=oe;re=E().Collection.extend({model:se.BlockModel,initialize:function(){this.on("add change remove",(function(){x.getChannel().trigger("autoSave")}))},parse:function(e){return c.default.map(e,(function(e){return new(x.getBlockTypeModel(e.type))(e,{parse:!0})}))}}),ie.ContainerBlockModel=se.BlockModel.extend({relations:{blocks:re},defaults:function(){return this._getDefaults({type:"container",columnLayout:!1,orientation:"vertical",image:{src:null,display:"scale"},styles:{block:{backgroundColor:"transparent"}},blocks:new re},x.getConfig().get("blockDefaults.container"))},_updateDefaults:function(){},validate:function(){var e=this.get("blocks").find((function(e){return!e.isValid()}));if(e)return e.validationError},parse:function(e){return"container"===e.type&&c.default.has(e,"blocks")&&e.blocks.constructor===Array&&(e.blocks=new re(e.blocks,{parse:!0})),e},getChildren:function(){var e=this.get("blocks").map((function(e){return[e,e.getChildren()]}));return c.default.flatten(e)}}),ie.ContainerBlocksView=f().CollectionView.extend({className:"mailpoet_container",events:{click:"removeFocusFromAnyActiveElement"},childView:function(e){return x.getBlockTypeView(e.get("type"))},childViewOptions:function(){var e=c.default.clone(this.renderOptions);return void 0!==e.depth&&(e.depth+=1),{renderOptions:e}},emptyView:function(){return ie.ContainerBlockEmptyView},emptyViewOptions:function(){return{renderOptions:this.renderOptions}},initialize:function(e){this.renderOptions=e.renderOptions},onChildviewResizeStart:function(){this.triggerMethod("resizeStart")},onChildviewResizeStop:function(e){this.triggerMethod("resizeStop",e)},removeFocusFromAnyActiveElement:function(e){var t;e&&e.target&&(t=e.target.getAttribute("class"))&&-1!==t.indexOf("mailpoet_container_horizontal")&&document.activeElement.blur()}}),ie.ContainerBlockView=se.BlockView.extend({regions:c.default.extend({},se.BlockView.prototype.regions,{blocks:{el:"> .mailpoet_container",replaceElement:!0}}),className:"mailpoet_block mailpoet_container_block mailpoet_droppable_block mailpoet_droppable_layout_block",getTemplate:function(){return window.templates.containerBlock},events:c.default.extend({},se.BlockView.prototype.events,{"click .mailpoet_newsletter_layer_selector":"toggleEditingLayer"}),ui:{tools:"> .mailpoet_tools"},behaviors:c.default.extend({},se.BlockView.prototype.behaviors,{ContainerDropZoneBehavior:{},DraggableBehavior:{cloneOriginal:!0,hideOriginal:!0,onDrop:function(e){e.dragBehavior.view.model.destroy()},onDragSubstituteBy:function(e){var t,o;if(c.default.isFunction(e.view.onDragSubstituteBy))return(t=new(e.view.onDragSubstituteBy())).render(),o=t.$el.get(0).cloneNode(!0),t.destroy(),o},testAttachToInstance:function(e,t){return 1===t.renderOptions.depth}},HighlightEditingBehavior:{}}),onDragSubstituteBy:function(){if(1===this.renderOptions.depth){if(3===this.model.get("blocks").length)return ie.ThreeColumnContainerWidgetView;if(2===this.model.get("blocks").length)return ie.TwoColumnContainerWidgetView}return ie.OneColumnContainerWidgetView},initialize:function(e){se.BlockView.prototype.initialize.apply(this,arguments),this.renderOptions=c.default.defaults(e.renderOptions||{},{})},onRender:function(){var e,t="";this.toolsView=new ie.ContainerBlockToolsView({model:this.model,tools:{settings:1===this.renderOptions.depth,delete:1===this.renderOptions.depth,duplicate:!0,move:1===this.renderOptions.depth,layerSelector:!1}}),this.showChildView("toolsRegion",this.toolsView),this.showChildView("blocks",new ie.ContainerBlocksView({collection:this.model.get("blocks"),renderOptions:this.renderOptions})),"string"==typeof(e=this.model.get("columnLayout"))&&(t="mailpoet_irregular_width_contents_container column_layout_"+e),this.$("> .mailpoet_container").attr("class","mailpoet_container mailpoet_container_"+this.model.get("orientation")+" "+t)},addHighlight:function(){1!==this.renderOptions.depth||this.$el.hasClass("mailpoet_container_layer_active")||(this.$(this.ui.tools).addClass("mailpoet_display_tools"),this.$el.addClass("mailpoet_highlight"),this.toolsView.triggerMethod("showTools"))},removeHighlight:function(){1!==this.renderOptions.depth||this.$el.hasClass("mailpoet_container_layer_active")||(this.$(this.ui.tools).removeClass("mailpoet_display_tools"),this.$el.removeClass("mailpoet_highlight"),this.toolsView.triggerMethod("hideTools"))},toggleEditingLayer:function(e){var t=this,o=this.$("> .mailpoet_tools .mailpoet_newsletter_layer_selector"),n=w()(".mailpoet_layer_overlay"),r=this.$("> .mailpoet_container"),i=function(){t.$el.removeClass("mailpoet_container_layer_active"),o.removeClass("mailpoet_container_layer_active"),r.removeClass("mailpoet_layer_highlight"),n.hide(),n.off("click")};o.hasClass("mailpoet_container_layer_active")?i():(t.$el.addClass("mailpoet_container_layer_active"),o.addClass("mailpoet_container_layer_active"),r.addClass("mailpoet_layer_highlight"),n.on("click",i),n.show()),e.stopPropagation()}}),ie.ContainerBlockEmptyView=f().View.extend({getTemplate:function(){return window.templates.containerEmpty},initialize:function(e){this.renderOptions=c.default.defaults(e.renderOptions||{},{})},templateContext:function(){return{isRoot:0===this.renderOptions.depth,emptyContainerMessage:this.renderOptions.emptyContainerMessage||""}}}),ie.ContainerBlockToolsView=se.BlockToolsView.extend({getSettingsView:function(){return ie.ContainerBlockSettingsView}}),ie.ContainerBlockSettingsView=se.BlockSettingsView.extend({behaviors:c.default.extend({},se.BlockSettingsView.prototype.behaviors,{MediaManagerBehavior:{onSelect:"onImageSelect"}}),getTemplate:function(){return window.templates.containerBlockSettings},events:function(){return{"change .mailpoet_field_container_background_color":c.default.partial(this.changeColorField,"styles.block.backgroundColor"),"click .mailpoet_done_editing":"close","change .mailpoet_field_display_type":"changeDisplayType"}},initialize:function(){se.BlockSettingsView.prototype.initialize.apply(this,arguments),this.model.trigger("startEditing"),this._columnsSettingsView=new ie.ContainerBlockColumnsSettingsView({collection:this.model.get("blocks")})},changeDisplayType:function(e){this.model.get("image").set("display",e.target.value),this.model.trigger("change")},onImageSelect:function(e){this.model.set("image.src",e.src),this.model.trigger("change"),this.render()}}),ie.ContainerBlockColumnsSettingsView=f().CollectionView.extend({childView:function(){return ie.ContainerBlockColumnSettingsView},childViewOptions:function(e,t){return{columnIndex:t}}}),ie.ContainerBlockColumnSettingsView=f().View.extend({getTemplate:function(){return window.templates.containerBlockColumnSettings},initialize:function(e){this.columnNumber=(e.columnIndex||0)+1},templateContext:function(){return{model:this.model.toJSON(),columnNumber:this.columnNumber}}}),ie.OneColumnContainerWidgetView=se.WidgetView.extend({className:se.WidgetView.prototype.className+" mailpoet_droppable_layout_block",getTemplate:function(){return window.templates.oneColumnLayoutInsertion},behaviors:{DraggableBehavior:{cloneOriginal:!0,drop:function(){return new ie.ContainerBlockModel({orientation:"horizontal",blocks:[new ie.ContainerBlockModel]})}}}}),ie.TwoColumnContainerWidgetView=se.WidgetView.extend({className:se.WidgetView.prototype.className+" mailpoet_droppable_layout_block",getTemplate:function(){return window.templates.twoColumnLayoutInsertion},behaviors:{DraggableBehavior:{cloneOriginal:!0,drop:function(){return new ie.ContainerBlockModel({orientation:"horizontal",blocks:[new ie.ContainerBlockModel,new ie.ContainerBlockModel]})}}}}),ie.ThreeColumnContainerWidgetView=se.WidgetView.extend({className:se.WidgetView.prototype.className+" mailpoet_droppable_layout_block",getTemplate:function(){return window.templates.threeColumnLayoutInsertion},behaviors:{DraggableBehavior:{cloneOriginal:!0,drop:function(){return new ie.ContainerBlockModel({orientation:"horizontal",blocks:[new ie.ContainerBlockModel,new ie.ContainerBlockModel,new ie.ContainerBlockModel]})}}}}),ie.TwoColumn12ContainerWidgetView=se.WidgetView.extend({className:se.WidgetView.prototype.className+" mailpoet_droppable_layout_block",getTemplate:function(){return window.templates.twoColumn12LayoutInsertion},behaviors:{DraggableBehavior:{cloneOriginal:!0,drop:function(){var e=new ie.ContainerBlockModel({orientation:"horizontal",blocks:[new ie.ContainerBlockModel,new ie.ContainerBlockModel]});return e.set("columnLayout","1_2"),e}}}}),ie.TwoColumn21ContainerWidgetView=se.WidgetView.extend({className:se.WidgetView.prototype.className+" mailpoet_droppable_layout_block",getTemplate:function(){return window.templates.twoColumn21LayoutInsertion},behaviors:{DraggableBehavior:{cloneOriginal:!0,drop:function(){var e=new ie.ContainerBlockModel({orientation:"horizontal",blocks:[new ie.ContainerBlockModel,new ie.ContainerBlockModel]});return e.set("columnLayout","2_1"),e}}}}),x.on("before:start",(function(e){e.registerBlockType("container",{blockModel:ie.ContainerBlockModel,blockView:ie.ContainerBlockView}),e.registerLayoutWidget({name:"oneColumnLayout",priority:100,widgetView:ie.OneColumnContainerWidgetView}),e.registerLayoutWidget({name:"twoColumnLayout",priority:100,widgetView:ie.TwoColumnContainerWidgetView}),e.registerLayoutWidget({name:"threeColumnLayout",priority:100,widgetView:ie.ThreeColumnContainerWidgetView}),e.registerLayoutWidget({name:"twoColumn12Layout",priority:100,widgetView:ie.TwoColumn12ContainerWidgetView}),e.registerLayoutWidget({name:"twoColumn21Layout",priority:100,widgetView:ie.TwoColumn21ContainerWidgetView})}));var ae={},le=oe;ae.ButtonBlockModel=le.BlockModel.extend({defaults:function(){return this._getDefaults({type:"button",text:"Button",url:"",styles:{block:{backgroundColor:"#ff0000",borderColor:"#cccccc",borderWidth:"1px",borderRadius:"4px",borderStyle:"solid",width:"200px",lineHeight:"40px",fontColor:"#000000",fontFamily:"Arial",fontSize:"16px",fontWeight:"normal",textAlign:"center"}}},x.getConfig().get("blockDefaults.button"))}}),ae.ButtonBlockView=le.BlockView.extend({className:"mailpoet_block mailpoet_button_block mailpoet_droppable_block",getTemplate:function(){return window.templates.buttonBlock},onDragSubstituteBy:function(){return ae.ButtonWidgetView},behaviors:c.default.extend({},le.BlockView.prototype.behaviors,{ShowSettingsBehavior:{}}),initialize:function(){le.BlockView.prototype.initialize.apply(this,arguments),this._replaceButtonStylesHandler=function(e){this.model.set(e)}.bind(this),x.getChannel().on("replaceAllButtonStyles",this._replaceButtonStylesHandler)},onRender:function(){this.toolsView=new ae.ButtonBlockToolsView({model:this.model}),this.showChildView("toolsRegion",this.toolsView)}}),ae.ButtonBlockToolsView=le.BlockToolsView.extend({getSettingsView:function(){return ae.ButtonBlockSettingsView}}),ae.ButtonBlockSettingsView=le.BlockSettingsView.extend({getTemplate:function(){return window.templates.buttonBlockSettings},events:function(){return{"input .mailpoet_field_button_text":c.default.partial(this.changeField,"text"),"input .mailpoet_field_button_url":c.default.partial(this.changeField,"url"),"change .mailpoet_field_button_alignment":c.default.partial(this.changeField,"styles.block.textAlign"),"change .mailpoet_field_button_font_color":c.default.partial(this.changeColorField,"styles.block.fontColor"),"change .mailpoet_field_button_font_family":c.default.partial(this.changeField,"styles.block.fontFamily"),"change .mailpoet_field_button_font_size":c.default.partial(this.changeField,"styles.block.fontSize"),"change .mailpoet_field_button_background_color":c.default.partial(this.changeColorField,"styles.block.backgroundColor"),"change .mailpoet_field_button_border_color":c.default.partial(this.changeColorField,"styles.block.borderColor"),"change .mailpoet_field_button_font_weight":"changeFontWeight","input .mailpoet_field_button_border_width":c.default.partial(this.updateValueAndCall,".mailpoet_field_button_border_width_input",c.default.partial(this.changePixelField,"styles.block.borderWidth").bind(this)),"change .mailpoet_field_button_border_width":c.default.partial(this.updateValueAndCall,".mailpoet_field_button_border_width_input",c.default.partial(this.changePixelField,"styles.block.borderWidth").bind(this)),"input .mailpoet_field_button_border_width_input":c.default.partial(this.updateValueAndCall,".mailpoet_field_button_border_width",c.default.partial(this.changePixelField,"styles.block.borderWidth").bind(this)),"input .mailpoet_field_button_border_radius":c.default.partial(this.updateValueAndCall,".mailpoet_field_button_border_radius_input",c.default.partial(this.changePixelField,"styles.block.borderRadius").bind(this)),"change .mailpoet_field_button_border_radius":c.default.partial(this.updateValueAndCall,".mailpoet_field_button_border_radius_input",c.default.partial(this.changePixelField,"styles.block.borderRadius").bind(this)),"input .mailpoet_field_button_border_radius_input":c.default.partial(this.updateValueAndCall,".mailpoet_field_button_border_radius",c.default.partial(this.changePixelField,"styles.block.borderRadius").bind(this)),"input .mailpoet_field_button_width":c.default.partial(this.updateValueAndCall,".mailpoet_field_button_width_input",c.default.partial(this.changePixelField,"styles.block.width").bind(this)),"change .mailpoet_field_button_width":c.default.partial(this.updateValueAndCall,".mailpoet_field_button_width_input",c.default.partial(this.changePixelField,"styles.block.width").bind(this)),"input .mailpoet_field_button_width_input":c.default.partial(this.updateValueAndCall,".mailpoet_field_button_width",c.default.partial(this.changePixelField,"styles.block.width").bind(this)),"input .mailpoet_field_button_line_height":c.default.partial(this.updateValueAndCall,".mailpoet_field_button_line_height_input",c.default.partial(this.changePixelField,"styles.block.lineHeight").bind(this)),"change .mailpoet_field_button_line_height":c.default.partial(this.updateValueAndCall,".mailpoet_field_button_line_height_input",c.default.partial(this.changePixelField,"styles.block.lineHeight").bind(this)),"input .mailpoet_field_button_line_height_input":c.default.partial(this.updateValueAndCall,".mailpoet_field_button_line_height",c.default.partial(this.changePixelField,"styles.block.lineHeight").bind(this)),"click .mailpoet_field_button_replace_all_styles":"applyToAll","click .mailpoet_done_editing":"close"}},templateContext:function(){return c.default.extend({},le.BlockView.prototype.templateContext.apply(this,arguments),{availableStyles:x.getAvailableStyles().toJSON(),renderOptions:this.renderOptions})},applyToAll:function(){x.getChannel().trigger("replaceAllButtonStyles",c.default.pick(this.model.toJSON(),"styles","type"))},updateValueAndCall:function(e,t,o){this.$(e).val(w()(o.target).val()),t(o)},changeFontWeight:function(e){var t=!!w()(e.target).prop("checked");this.model.set("styles.block.fontWeight",t?w()(e.target).val():"normal")}}),ae.ButtonWidgetView=le.WidgetView.extend({id:"automation_editor_block_button",getTemplate:function(){return window.templates.buttonInsertion},behaviors:{DraggableBehavior:{cloneOriginal:!0,drop:function(){return new ae.ButtonBlockModel}}}}),x.on("before:start",(function(e){e.registerBlockType("button",{blockModel:ae.ButtonBlockModel,blockView:ae.ButtonBlockView}),e.registerWidget({name:"button",widgetView:ae.ButtonWidgetView,priority:92})}));var ce,de={},ue=oe;de.ImageBlockModel=ue.BlockModel.extend({defaults:function(){return this._getDefaults({type:"image",link:"",src:"",alt:"An image of...",fullWidth:!0,width:"64px",height:"64px",styles:{block:{textAlign:"center"}}},x.getConfig().get("blockDefaults.image"))},_updateDefaults:function(){}}),de.ImageBlockView=ue.BlockView.extend({className:"mailpoet_block mailpoet_image_block mailpoet_droppable_block",getTemplate:function(){return window.templates.imageBlock},onDragSubstituteBy:function(){return de.ImageWidgetView},templateContext:function(){return c.default.extend({imageMissingSrc:x.getConfig().get("urls.imageMissing")},ue.BlockView.prototype.templateContext.apply(this))},behaviors:c.default.extend({},ue.BlockView.prototype.behaviors,{ResizableBehavior:{elementSelector:".mailpoet_image",resizeHandleSelector:".mailpoet_image_resize_handle",onResize:function(e){var t=this.view.model.get("styles.block.textAlign"),o=this.$(".mailpoet_image").offset(),n=this.$(".mailpoet_image").width(),r=e.pageX-o.left;"right"===t&&(r=n+o.left-e.pageX),this.view.model.set("width",r+"px")}},ShowSettingsBehavior:{ignoreFrom:".mailpoet_image_resize_handle"}}),onRender:function(){var e=this;this.toolsView=new de.ImageBlockToolsView({model:this.model}),this.showChildView("toolsRegion",this.toolsView),this.model.get("fullWidth")?this.$el.addClass("mailpoet_full_image"):this.$el.removeClass("mailpoet_full_image"),this.model.get("width")&&"auto"!==this.model.get("width")||this.$el.find("img").on("load",(function(){e.model.set("width",this.width),e.model.set("height",this.height)})),this.$(".mailpoet_content").css("width",this.model.get("width"))}}),de.ImageBlockToolsView=ue.BlockToolsView.extend({getSettingsView:function(){return de.ImageBlockSettingsView}}),de.ImageBlockSettingsView=ue.BlockSettingsView.extend({behaviors:c.default.extend({},ue.BlockSettingsView.prototype.behaviors,{MediaManagerBehavior:{onSelect:"onImageSelect"}}),onRender:function(){r.MailPoet.helpTooltip.show(document.getElementById("tooltip-designer-full-width"),{tooltipId:"tooltip-editor-full-width",tooltip:(0,i.__)("This option eliminates padding around the image.","mailpoet"),place:"top"}),r.MailPoet.helpTooltip.show(document.getElementById("tooltip-designer-ideal-width"),{tooltipId:"tooltip-editor-ideal-width",tooltip:(0,i.__)("Use images with widths of at least 1,000 pixels to ensure sharp display on high density screens, like mobile devices.","mailpoet"),place:"bottom"})},getTemplate:function(){return window.templates.imageBlockSettings},events:function(){return{"input .mailpoet_field_image_link":c.default.partial(this.changeField,"link"),"input .mailpoet_field_image_alt_text":c.default.partial(this.changeField,"alt"),"change .mailpoet_field_image_full_width":c.default.partial(this.changeBoolCheckboxField,"fullWidth"),"change .mailpoet_field_image_alignment":c.default.partial(this.changeField,"styles.block.textAlign"),"click .mailpoet_done_editing":"close","input .mailpoet_field_image_width":c.default.partial(this.updateValueAndCall,".mailpoet_field_image_width_input",c.default.partial(this.changePixelField,"width").bind(this)),"change .mailpoet_field_image_width":c.default.partial(this.updateValueAndCall,".mailpoet_field_image_width_input",c.default.partial(this.changePixelField,"width").bind(this)),"input .mailpoet_field_image_width_input":c.default.partial(this.updateValueAndCall,".mailpoet_field_image_width",c.default.partial(this.changePixelField,"width").bind(this))}},modelEvents:function(){return{"change:maxWidth":"updateMaxWidth","change:width":"updateWidth"}},updateValueAndCall:function(e,t,o){this.$(e).val(w()(o.target).val()),t(o)},updateMaxWidth:function(){var e=parseInt(this.model.get("maxWidth"),10);this.$(".mailpoet_field_image_width").attr("max",e),this.$(".mailpoet_field_image_width_input").attr("max",e)},updateWidth:function(){var e=parseInt(this.model.get("width"),10);this.$(".mailpoet_field_image_width").val(e),this.$(".mailpoet_field_image_width_input").val(e)},onImageSelect:function(e){null===e.src?this.model.set({src:""}):this.model.set(e),this.render()}}),ce=ue.WidgetView.extend({id:"automation_editor_block_image",getTemplate:function(){return window.templates.imageInsertion},behaviors:{DraggableBehavior:{cloneOriginal:!0,drop:function(){return new de.ImageBlockModel},onDrop:function(e){e.droppedView.triggerMethod("showSettings",{showImageManager:!0})}}}}),de.ImageWidgetView=ce,x.on("before:start",(function(e){e.registerBlockType("image",{blockModel:de.ImageBlockModel,blockView:de.ImageBlockView}),e.registerWidget({name:"image",widgetView:de.ImageWidgetView,priority:91})}));var he={},me=oe;he.DividerBlockModel=me.BlockModel.extend({defaults:function(){return this._getDefaults({type:"divider",styles:{block:{backgroundColor:"transparent",padding:"12px",borderStyle:"solid",borderWidth:"1px",borderColor:"#000000"}}},x.getConfig().get("blockDefaults.divider"))}}),he.DividerBlockView=me.BlockView.extend({className:"mailpoet_block mailpoet_divider_block mailpoet_droppable_block",getTemplate:function(){return window.templates.dividerBlock},modelEvents:c.default.omit(me.BlockView.prototype.modelEvents,"change"),behaviors:c.default.defaults({ResizableBehavior:{elementSelector:".mailpoet_content",resizeHandleSelector:".mailpoet_resize_handle",transformationFunction:function(e){return e/2},minLength:0,modelField:"styles.block.padding"},ShowSettingsBehavior:{ignoreFrom:".mailpoet_resize_handle"}},me.BlockView.prototype.behaviors),onDragSubstituteBy:function(){return he.DividerWidgetView},initialize:function(){var e=this;me.BlockView.prototype.initialize.apply(this,arguments),this._replaceDividerHandler=function(t){e.model.set(t),e.model.trigger("applyToAll")},x.getChannel().on("replaceAllDividers",this._replaceDividerHandler),this.listenTo(this.model,"change:src change:styles.block.backgroundColor change:styles.block.borderStyle change:styles.block.borderWidth change:styles.block.borderColor applyToAll",this.render),this.listenTo(this.model,"change:styles.block.padding",this.changePadding)},templateContext:function(){return c.default.extend({totalHeight:2*parseInt(this.model.get("styles.block.padding"),10)+parseInt(this.model.get("styles.block.borderWidth"),10)+"px"},me.BlockView.prototype.templateContext.apply(this))},onRender:function(){this.toolsView=new he.DividerBlockToolsView({model:this.model}),this.showChildView("toolsRegion",this.toolsView)},onBeforeDestroy:function(){x.getChannel().off("replaceAllDividers",this._replaceDividerHandler),this.stopListening(this.model)},changePadding:function(){this.$(".mailpoet_content").css("padding-top",this.model.get("styles.block.padding")),this.$(".mailpoet_content").css("padding-bottom",this.model.get("styles.block.padding")),this.$(".mailpoet_resize_handle_text").text(2*parseInt(this.model.get("styles.block.padding"),10)+parseInt(this.model.get("styles.block.borderWidth"),10)+"px")}}),he.DividerBlockToolsView=me.BlockToolsView.extend({getSettingsView:function(){return he.DividerBlockSettingsView}}),he.DividerBlockSettingsView=me.BlockSettingsView.extend({getTemplate:function(){return window.templates.dividerBlockSettings},events:function(){return{"click .mailpoet_field_divider_style":"changeStyle","input .mailpoet_field_divider_border_width":c.default.partial(this.updateValueAndCall,".mailpoet_field_divider_border_width_input",c.default.partial(this.changePixelField,"styles.block.borderWidth").bind(this)),"change .mailpoet_field_divider_border_width":c.default.partial(this.updateValueAndCall,".mailpoet_field_divider_border_width_input",c.default.partial(this.changePixelField,"styles.block.borderWidth").bind(this)),"input .mailpoet_field_divider_border_width_input":c.default.partial(this.updateValueAndCall,".mailpoet_field_divider_border_width",c.default.partial(this.changePixelField,"styles.block.borderWidth").bind(this)),"change .mailpoet_field_divider_border_color":c.default.partial(this.changeColorField,"styles.block.borderColor"),"change .mailpoet_field_divider_background_color":c.default.partial(this.changeColorField,"styles.block.backgroundColor"),"click .mailpoet_button_divider_apply_to_all":"applyToAll","click .mailpoet_done_editing":"close"}},modelEvents:function(){return{"change:styles.block.borderColor":"repaintDividerStyleOptions"}},templateContext:function(){return c.default.extend({},me.BlockView.prototype.templateContext.apply(this,arguments),{availableStyles:x.getAvailableStyles().toJSON(),renderOptions:this.renderOptions})},changeStyle:function(e){var t=w()(e.currentTarget).data("style");this.model.set("styles.block.borderStyle",t),this.$(".mailpoet_field_divider_style").removeClass("mailpoet_active_divider_style"),this.$('.mailpoet_field_divider_style[data-style="'+t+'"]').addClass("mailpoet_active_divider_style")},repaintDividerStyleOptions:function(){this.$(".mailpoet_field_divider_style > div").css("border-top-color",this.model.get("styles.block.borderColor"))},applyToAll:function(){x.getChannel().trigger("replaceAllDividers",this.model.toJSON())},updateValueAndCall:function(e,t,o){this.$(e).val(w()(o.target).val()),t(o)}}),he.DividerWidgetView=me.WidgetView.extend({id:"automation_editor_block_divider",getTemplate:function(){return window.templates.dividerInsertion},behaviors:{DraggableBehavior:{cloneOriginal:!0,drop:function(){return new he.DividerBlockModel}}}}),x.on("before:start",(function(e){e.registerBlockType("divider",{blockModel:he.DividerBlockModel,blockView:he.DividerBlockView}),e.registerWidget({name:"divider",widgetView:he.DividerWidgetView,priority:93})}));var pe={},ge=oe;pe.TextBlockModel=ge.BlockModel.extend({defaults:function(){return this._getDefaults({type:"text",text:"Edit this to insert text"},x.getConfig().get("blockDefaults.text"))},_updateDefaults:function(){}}),pe.TextBlockView=ge.BlockView.extend({className:"mailpoet_block mailpoet_text_block mailpoet_droppable_block",getTemplate:function(){return window.templates.textBlock},modelEvents:c.default.omit(ge.BlockView.prototype.modelEvents,"change"),behaviors:c.default.extend({},ge.BlockView.prototype.behaviors,{TextEditorBehavior:{toolbar1:"blocks bold italic forecolor | link unlink",toolbar2:"alignleft aligncenter alignright alignjustify | bullist numlist blockquote | code mailpoet_shortcodes",validElements:"p[class|style],span[class|style],a[href|class|title|target|style],h1[class|style],h2[class|style],h3[class|style],ol[class|style],ul[class|style],li[class|style],strong[class|style],em[class|style],strike,br,blockquote[class|style],table[class|style],tr[class|style],th[class|style],td[class|style],del",invalidElements:"script",blockFormats:"Heading 1=h1;Heading 2=h2;Heading 3=h3;Paragraph=p",plugins:"link lists code mailpoet_shortcodes",configurationFilter:function(e){return c.default.extend({},e,{mailpoet_shortcodes:x.getConfig().get("shortcodes").toJSON(),mailpoet_shortcodes_window_title:(0,i.__)("Select a shortcode","mailpoet")})}}}),initialize:function(e){ge.BlockView.prototype.initialize.apply(this,arguments),this.renderOptions=c.default.defaults(e.renderOptions||{},{disableTextEditor:!1}),this.disableTextEditor=this.renderOptions.disableTextEditor},onDragSubstituteBy:function(){return pe.TextWidgetView},onRender:function(){this.toolsView=new pe.TextBlockToolsView({model:this.model,tools:{settings:!1}}),this.showChildView("toolsRegion",this.toolsView)},onTextEditorChange:function(e){this.model.set("text",e)},onTextEditorFocus:function(){this.disableDragging(),this.disableShowingTools()},onTextEditorBlur:function(){this.enableDragging(),this.enableShowingTools()}}),pe.TextBlockToolsView=ge.BlockToolsView.extend({getSettingsView:function(){return pe.TextBlockSettingsView}}),pe.TextBlockSettingsView=ge.BlockSettingsView.extend({getTemplate:function(){return window.templates.textBlockSettings}}),pe.TextWidgetView=ge.WidgetView.extend({id:"automation_editor_block_text",getTemplate:function(){return window.templates.textInsertion},behaviors:{DraggableBehavior:{cloneOriginal:!0,drop:function(){return new pe.TextBlockModel}}}}),x.on("before:start",(function(e){e.registerBlockType("text",{blockModel:pe.TextBlockModel,blockView:pe.TextBlockView}),e.registerWidget({name:"text",widgetView:pe.TextWidgetView,priority:90})}));var fe={},ve=oe;fe.SpacerBlockModel=ve.BlockModel.extend({defaults:function(){return this._getDefaults({type:"spacer",styles:{block:{backgroundColor:"rgba(0, 0, 0, 0)",height:"40px"}}},x.getConfig().get("blockDefaults.spacer"))}}),fe.SpacerBlockView=ve.BlockView.extend({className:"mailpoet_block mailpoet_spacer_block mailpoet_droppable_block",getTemplate:function(){return window.templates.spacerBlock},behaviors:c.default.defaults({ResizableBehavior:{elementSelector:".mailpoet_spacer",resizeHandleSelector:".mailpoet_resize_handle",minLength:20,modelField:"styles.block.height"},ShowSettingsBehavior:{ignoreFrom:".mailpoet_resize_handle"}},ve.BlockView.prototype.behaviors),modelEvents:c.default.omit(ve.BlockView.prototype.modelEvents,"change"),onDragSubstituteBy:function(){return fe.SpacerWidgetView},initialize:function(){ve.BlockView.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"change:styles.block.backgroundColor",this.render),this.listenTo(this.model,"change:styles.block.height",this.changeHeight)},onRender:function(){this.toolsView=new fe.SpacerBlockToolsView({model:this.model}),this.showChildView("toolsRegion",this.toolsView)},changeHeight:function(){this.$(".mailpoet_spacer").css("height",this.model.get("styles.block.height")),this.$(".mailpoet_resize_handle_text").text(this.model.get("styles.block.height")),this.render()},onBeforeDestroy:function(){this.stopListening(this.model)}}),fe.SpacerBlockToolsView=ve.BlockToolsView.extend({getSettingsView:function(){return fe.SpacerBlockSettingsView}}),fe.SpacerBlockSettingsView=ve.BlockSettingsView.extend({getTemplate:function(){return window.templates.spacerBlockSettings},events:function(){return{"change .mailpoet_field_spacer_background_color":c.default.partial(this.changeColorField,"styles.block.backgroundColor"),"click .mailpoet_done_editing":"close"}}}),fe.SpacerWidgetView=ve.WidgetView.extend({id:"automation_editor_block_spacer",getTemplate:function(){return window.templates.spacerInsertion},behaviors:{DraggableBehavior:{cloneOriginal:!0,drop:function(){return new fe.SpacerBlockModel}}}}),x.on("before:start",(function(e){e.registerBlockType("spacer",{blockModel:fe.SpacerBlockModel,blockView:fe.SpacerBlockView}),e.registerWidget({name:"spacer",widgetView:fe.SpacerWidgetView,priority:94})}));var be={},ye=oe;be.FooterBlockModel=ye.BlockModel.extend({defaults:function(){return this._getDefaults({type:"footer",text:'Unsubscribe | Manage subscription Add your postal address here! ',styles:{block:{backgroundColor:"transparent"},text:{fontColor:"#000000",fontFamily:"Arial",fontSize:"12px",textAlign:"center"},link:{fontColor:"#0000ff",textDecoration:"none"}}},x.getConfig().get("blockDefaults.footer"))},_updateDefaults:function(){x.getConfig().set("blockDefaults.footer",c.default.omit(this.toJSON(),"text"))}}),be.FooterBlockView=ye.BlockView.extend({className:"mailpoet_block mailpoet_footer_block mailpoet_droppable_block",getTemplate:function(){return window.templates.footerBlock},modelEvents:c.default.extend({"change:styles.block.backgroundColor change:styles.text.fontColor change:styles.text.fontFamily change:styles.text.fontSize change:styles.text.textAlign change:styles.link.fontColor change:styles.link.textDecoration":"render"},c.default.omit(ye.BlockView.prototype.modelEvents,"change")),behaviors:c.default.extend({},ye.BlockView.prototype.behaviors,{TextEditorBehavior:{configurationFilter:function(e){return c.default.extend({},e,{mailpoet_shortcodes:x.getConfig().get("shortcodes").toJSON(),mailpoet_shortcodes_window_title:(0,i.__)("Select a shortcode","mailpoet")})}}}),onDragSubstituteBy:function(){return be.FooterWidgetView},onRender:function(){this.toolsView=new be.FooterBlockToolsView({model:this.model}),this.showChildView("toolsRegion",this.toolsView)},onTextEditorChange:function(e){this.model.set("text",e)},onTextEditorFocus:function(){this.disableDragging(),this.disableShowingTools()},onTextEditorBlur:function(){this.enableDragging(),this.enableShowingTools()}}),be.FooterBlockToolsView=ye.BlockToolsView.extend({getSettingsView:function(){return be.FooterBlockSettingsView}}),be.FooterBlockSettingsView=ye.BlockSettingsView.extend({getTemplate:function(){return window.templates.footerBlockSettings},events:function(){return{"change .mailpoet_field_footer_text_color":c.default.partial(this.changeColorField,"styles.text.fontColor"),"change .mailpoet_field_footer_text_font_family":c.default.partial(this.changeField,"styles.text.fontFamily"),"change .mailpoet_field_footer_text_size":c.default.partial(this.changeField,"styles.text.fontSize"),"change #mailpoet_field_footer_link_color":c.default.partial(this.changeColorField,"styles.link.fontColor"),"change #mailpoet_field_footer_link_underline":function(e){this.model.set("styles.link.textDecoration",e.target.checked?e.target.value:"none")},"change .mailpoet_field_footer_background_color":c.default.partial(this.changeColorField,"styles.block.backgroundColor"),"change .mailpoet_field_footer_alignment":c.default.partial(this.changeField,"styles.text.textAlign"),"click .mailpoet_done_editing":"close"}},templateContext:function(){return c.default.extend({},ye.BlockView.prototype.templateContext.apply(this,arguments),{availableStyles:x.getAvailableStyles().toJSON()})}}),be.FooterWidgetView=ye.WidgetView.extend({id:"automation_editor_block_footer",getTemplate:function(){return window.templates.footerInsertion},behaviors:{DraggableBehavior:{cloneOriginal:!0,drop:function(){return new be.FooterBlockModel}}}}),x.on("before:start",(function(e){e.registerBlockType("footer",{blockModel:be.FooterBlockModel,blockView:be.FooterBlockView}),e.registerWidget({name:"footer",widgetView:be.FooterWidgetView,priority:101})}));var we={},_e=oe;we.HeaderBlockModel=_e.BlockModel.extend({defaults:function(){return this._getDefaults({type:"header",text:'View this in your browser ',styles:{block:{backgroundColor:"transparent"},text:{fontColor:"#000000",fontFamily:"Arial",fontSize:"12px",textAlign:"center"},link:{fontColor:"#0000ff",textDecoration:"underline"}}},x.getConfig().get("blockDefaults.header"))},_updateDefaults:function(){x.getConfig().set("blockDefaults.header",c.default.omit(this.toJSON(),"text"))}}),we.HeaderBlockView=_e.BlockView.extend({className:"mailpoet_block mailpoet_header_block mailpoet_droppable_block",getTemplate:function(){return window.templates.headerBlock},modelEvents:c.default.extend({"change:styles.block.backgroundColor change:styles.text.fontColor change:styles.text.fontFamily change:styles.text.fontSize change:styles.text.textAlign change:styles.link.fontColor change:styles.link.textDecoration":"render"},c.default.omit(_e.BlockView.prototype.modelEvents,"change")),behaviors:c.default.extend({},_e.BlockView.prototype.behaviors,{TextEditorBehavior:{configurationFilter:function(e){return c.default.extend({},e,{mailpoet_shortcodes:x.getConfig().get("shortcodes").toJSON(),mailpoet_shortcodes_window_title:(0,i.__)("Select a shortcode","mailpoet")})}}}),onDragSubstituteBy:function(){return we.HeaderWidgetView},onRender:function(){this.toolsView=new we.HeaderBlockToolsView({model:this.model}),this.showChildView("toolsRegion",this.toolsView)},onTextEditorChange:function(e){this.model.set("text",e)},onTextEditorFocus:function(){this.disableDragging(),this.disableShowingTools()},onTextEditorBlur:function(){this.enableDragging(),this.enableShowingTools()}}),we.HeaderBlockToolsView=_e.BlockToolsView.extend({getSettingsView:function(){return we.HeaderBlockSettingsView}}),we.HeaderBlockSettingsView=_e.BlockSettingsView.extend({getTemplate:function(){return window.templates.headerBlockSettings},events:function(){return{"change .mailpoet_field_header_text_color":c.default.partial(this.changeColorField,"styles.text.fontColor"),"change .mailpoet_field_header_text_font_family":c.default.partial(this.changeField,"styles.text.fontFamily"),"change .mailpoet_field_header_text_size":c.default.partial(this.changeField,"styles.text.fontSize"),"change #mailpoet_field_header_link_color":c.default.partial(this.changeColorField,"styles.link.fontColor"),"change #mailpoet_field_header_link_underline":function(e){this.model.set("styles.link.textDecoration",e.target.checked?e.target.value:"none")},"change .mailpoet_field_header_background_color":c.default.partial(this.changeColorField,"styles.block.backgroundColor"),"change .mailpoet_field_header_alignment":c.default.partial(this.changeField,"styles.text.textAlign"),"click .mailpoet_done_editing":"close"}},templateContext:function(){return c.default.extend({},_e.BlockView.prototype.templateContext.apply(this,arguments),{availableStyles:x.getAvailableStyles().toJSON()})}}),we.HeaderWidgetView=_e.WidgetView.extend({id:"automation_editor_block_header",getTemplate:function(){return window.templates.headerInsertion},behaviors:{DraggableBehavior:{cloneOriginal:!0,drop:function(){return new we.HeaderBlockModel}}}}),x.on("before:start",(function(e){e.registerBlockType("header",{blockModel:we.HeaderBlockModel,blockView:we.HeaderBlockView}),e.registerWidget({name:"header",widgetView:we.HeaderWidgetView,priority:100})}));var xe={},Ce=oe;xe.ALCSupervisor=C.extend({initialize:function(){this.listenTo(x.getChannel(),"automatedLatestContentRefresh",c.default.debounce(this.refresh,500))},refresh:function(){var e,t=x.findModels((function(e){return"automatedLatestContent"===e.get("type")}))||[];0!==t.length&&(e=c.default.map(t,(function(e){return e.toJSON()})),Z.getBulkTransformedPosts({blocks:e}).then(c.default.partial(this.refreshBlocks,t)))},refreshBlocks:function(e,t){c.default.each(c.default.zip(e,t),(function(e){var t=e[0],o=e[1];t.trigger("refreshPosts",o)}))}}),xe.AutomatedLatestContentBlockModel=Ce.BlockModel.extend({stale:["_container"],defaults:function(){return this._getDefaults({type:"automatedLatestContent",withLayout:!1,amount:"5",contentType:"post",terms:[],inclusionType:"include",displayType:"excerpt",titleFormat:"h1",titleAlignment:"left",titleIsLink:!1,imageFullWidth:!1,featuredImagePosition:"belowTitle",showAuthor:"no",authorPrecededBy:"Author:",showCategories:"no",categoriesPrecededBy:"Categories:",readMoreType:"button",readMoreText:"Read more",readMoreButton:{text:"Read more",url:"[postLink]"},sortBy:"newest",showDivider:!0,divider:{},_container:new(x.getBlockTypeModel("container"))},x.getConfig().get("blockDefaults.automatedLatestContent"))},relations:function(){return{readMoreButton:x.getBlockTypeModel("button"),divider:x.getBlockTypeModel("divider"),_container:x.getBlockTypeModel("container")}},initialize:function(){Ce.BlockView.prototype.initialize.apply(this,arguments),this.on("change:amount change:contentType change:terms change:inclusionType change:displayType change:titleFormat change:featuredImagePosition change:titleAlignment change:titleIsLink change:imageFullWidth change:showAuthor change:authorPrecededBy change:showCategories change:categoriesPrecededBy change:readMoreType change:readMoreText change:sortBy change:showDivider",this._handleChanges,this),this.listenTo(this.get("readMoreButton"),"change",this._handleChanges),this.listenTo(this.get("divider"),"change",this._handleChanges),this.on("add remove update reset",this._handleChanges),this.on("refreshPosts",this.updatePosts,this)},updatePosts:function(e){this.get("_container.blocks").reset(e,{parse:!0})},_handleChanges:function(){this._updateDefaults(),x.getChannel().trigger("automatedLatestContentRefresh")}}),xe.AutomatedLatestContentBlockView=Ce.BlockView.extend({className:"mailpoet_block mailpoet_automated_latest_content_block mailpoet_droppable_block",initialize:function(){x.getChannel().on("replaceAllButtonStyles",function(e){this.model.set({readMoreButton:e})}.bind(this))},getTemplate:function(){return window.templates.automatedLatestContentBlock},regions:{toolsRegion:".mailpoet_tools",postsRegion:".mailpoet_automated_latest_content_block_posts"},modelEvents:c.default.extend(c.default.omit(Ce.BlockView.prototype.modelEvents,"change"),{postsChanged:"render"}),events:{"click .mailpoet_automated_latest_content_block_overlay":"showSettings"},onDragSubstituteBy:function(){return xe.AutomatedLatestContentWidgetView},onRender:function(){var e=x.getBlockTypeView("container"),t={disableTextEditor:!0,disableDragAndDrop:!0,emptyContainerMessage:(0,i.__)("There is no content to display.","mailpoet")};this.toolsView=new xe.AutomatedLatestContentBlockToolsView({model:this.model}),this.showChildView("toolsRegion",this.toolsView),this.showChildView("postsRegion",new e({model:this.model.get("_container"),renderOptions:t}))}}),xe.AutomatedLatestContentBlockToolsView=Ce.BlockToolsView.extend({getSettingsView:function(){return xe.AutomatedLatestContentBlockSettingsView}}),xe.AutomatedLatestContentBlockSettingsView=Ce.BlockSettingsView.extend({getTemplate:function(){return window.templates.automatedLatestContentBlockSettings},events:function(){return{"click .mailpoet_automated_latest_content_hide_display_options":"toggleDisplayOptions","click .mailpoet_automated_latest_content_show_display_options":"toggleDisplayOptions","click .mailpoet_automated_latest_content_select_button":"showButtonSettings","click .mailpoet_automated_latest_content_select_divider":"showDividerSettings","change .mailpoet_automated_latest_content_read_more_type":"changeReadMoreType","change .mailpoet_automated_latest_content_display_type":"changeDisplayType","change .mailpoet_automated_latest_content_title_format":"changeTitleFormat","change .mailpoet_automated_latest_content_title_as_links":c.default.partial(this.changeBoolField,"titleIsLink"),"change .mailpoet_automated_latest_content_show_divider":c.default.partial(this.changeBoolField,"showDivider"),"input .mailpoet_automated_latest_content_show_amount":c.default.partial(this.changeField,"amount"),"change .mailpoet_automated_latest_content_content_type":c.default.partial(this.changeField,"contentType"),"change .mailpoet_automated_latest_content_include_or_exclude":c.default.partial(this.changeField,"inclusionType"),"change .mailpoet_automated_latest_content_title_alignment":c.default.partial(this.changeField,"titleAlignment"),"change .mailpoet_automated_latest_content_image_full_width":c.default.partial(this.changeBoolField,"imageFullWidth"),"change .mailpoet_automated_latest_content_featured_image_position":c.default.partial(this.changeField,"featuredImagePosition"),"change .mailpoet_automated_latest_content_show_author":c.default.partial(this.changeField,"showAuthor"),"input .mailpoet_automated_latest_content_author_preceded_by":c.default.partial(this.changeField,"authorPrecededBy"),"change .mailpoet_automated_latest_content_show_categories":c.default.partial(this.changeField,"showCategories"),"input .mailpoet_automated_latest_content_categories":c.default.partial(this.changeField,"categoriesPrecededBy"),"input .mailpoet_automated_latest_content_read_more_text":c.default.partial(this.changeField,"readMoreText"),"change .mailpoet_automated_latest_content_sort_by":c.default.partial(this.changeField,"sortBy"),"click .mailpoet_done_editing":"close"}},onRender:function(){var e=this;Z.getPostTypes().done(c.default.bind(this._updateContentTypes,this)),this.$(".mailpoet_automated_latest_content_categories_and_tags").select2({multiple:!0,allowClear:!0,placeholder:(0,i.__)("Categories & tags","mailpoet"),ajax:{data:function(e){return{term:e.term,page:e.page||1}},transport:function(t,o,n){var r,i=Z.getTaxonomies(e.model.get("contentType")).then((function(e){return r=e,Z.getTerms({search:t.data.term,page:t.data.page,taxonomies:c.default.keys(r)}).then((function(e){return{taxonomies:r,terms:e}}))}));return i.then(o),i.fail(n),i},processResults:function(e){return{results:c.default.map(e.terms,(function(t){return c.default.defaults({text:e.taxonomies[t.taxonomy].labels.singular_name+": "+t.name,id:t.term_id},t)})),pagination:{more:100===e.terms.length}}}}}).on({"select2:select":function(t){var o=e.model.get("terms");o.add(t.params.data),e.model.set("terms",o.toJSON())},"select2:unselect":function(t){var o=e.model.get("terms");o.remove(t.params.data),e.model.set("terms",o.toJSON())}}).trigger("change")},toggleDisplayOptions:function(){var e=this.$(".mailpoet_automated_latest_content_display_options"),t=this.$(".mailpoet_automated_latest_content_show_display_options");e.hasClass("mailpoet_closed")?(e.removeClass("mailpoet_closed"),t.addClass("mailpoet_hidden")):(e.addClass("mailpoet_closed"),t.removeClass("mailpoet_hidden"))},showButtonSettings:function(){new ae.ButtonBlockSettingsView({model:this.model.get("readMoreButton"),renderOptions:{displayFormat:"subpanel",hideLink:!0,hideApplyToAll:!0}}).render()},showDividerSettings:function(){new he.DividerBlockSettingsView({model:this.model.get("divider"),renderOptions:{displayFormat:"subpanel",hideApplyToAll:!0}}).render()},changeReadMoreType:function(e){var t=w()(e.target).val();"link"===t?(this.$(".mailpoet_automated_latest_content_read_more_text").removeClass("mailpoet_hidden"),this.$(".mailpoet_automated_latest_content_select_button").addClass("mailpoet_hidden")):"button"===t&&(this.$(".mailpoet_automated_latest_content_read_more_text").addClass("mailpoet_hidden"),this.$(".mailpoet_automated_latest_content_select_button").removeClass("mailpoet_hidden")),this.changeField("readMoreType",e)},changeDisplayType:function(e){var t=w()(e.target).val();"titleOnly"===t?(this.$(".mailpoet_automated_latest_content_title_as_list").removeClass("mailpoet_hidden"),this.$(".mailpoet_automated_latest_content_image_full_width_option").addClass("mailpoet_hidden"),this.$(".mailpoet_automated_latest_content_image_separator").addClass("mailpoet_hidden")):(this.$(".mailpoet_automated_latest_content_title_as_list").addClass("mailpoet_hidden"),this.$(".mailpoet_automated_latest_content_image_full_width_option").removeClass("mailpoet_hidden"),this.$(".mailpoet_automated_latest_content_image_separator").removeClass("mailpoet_hidden"),"ul"===this.model.get("titleFormat")&&(this.model.set("titleFormat","h1"),this.$(".mailpoet_automated_latest_content_title_format").val(["h1"]),this.$(".mailpoet_automated_latest_content_title_as_link").removeClass("mailpoet_hidden"))),"excerpt"===t?this.$(".mailpoet_automated_latest_content_featured_image_position_container").removeClass("mailpoet_hidden"):this.$(".mailpoet_automated_latest_content_featured_image_position_container").addClass("mailpoet_hidden"),this.changeField("displayType",e)},changeTitleFormat:function(e){"ul"===w()(e.target).val()?(this.$(".mailpoet_automated_latest_content_non_title_list_options").addClass("mailpoet_hidden"),this.model.set("titleIsLink",!0),this.$(".mailpoet_automated_latest_content_title_as_link").addClass("mailpoet_hidden"),this.$(".mailpoet_automated_latest_content_title_as_links").val(["true"])):(this.$(".mailpoet_automated_latest_content_non_title_list_options").removeClass("mailpoet_hidden"),this.$(".mailpoet_automated_latest_content_title_as_link").removeClass("mailpoet_hidden")),this.changeField("titleFormat",e)},_updateContentTypes:function(e){var t=this.$(".mailpoet_automated_latest_content_content_type"),o=this.model.get("contentType");t.find("option").remove(),c.default.each(e,(function(e){t.append(w()("",{value:e.name,text:e.label}))})),t.val(o)}}),xe.AutomatedLatestContentWidgetView=Ce.WidgetView.extend({getTemplate:function(){return window.templates.automatedLatestContentInsertion},behaviors:{DraggableBehavior:{cloneOriginal:!0,drop:function(){return new xe.AutomatedLatestContentBlockModel({},{parse:!0})},onDrop:function(e){e.droppedView.triggerMethod("showSettings")}}}}),x.on("before:start",(function(e){e.registerBlockType("automatedLatestContent",{blockModel:xe.AutomatedLatestContentBlockModel,blockView:xe.AutomatedLatestContentBlockView})})),x.on("start",(function(e){var t=e;t._ALCSupervisor=new xe.ALCSupervisor,t._ALCSupervisor.refresh()}));var ke={},Se=oe;ke.ALCLayoutSupervisor=C.extend({initialize:function(){this.listenTo(x.getChannel(),"automatedLatestContentLayoutRefresh",c.default.debounce(this.refresh,500))},refresh:function(){var e,t=x.findModels((function(e){return"automatedLatestContentLayout"===e.get("type")}))||[];0!==t.length&&(e=c.default.map(t,(function(e){return e.toJSON()})),Z.getBulkTransformedPosts({blocks:e}).then(c.default.partial(this.refreshBlocks,t)))},refreshBlocks:function(e,t){c.default.each(c.default.zip(e,t),(function(e){var t=e[0],o=e[1];t.trigger("refreshPosts",o)}))}}),ke.AutomatedLatestContentLayoutBlockModel=Se.BlockModel.extend({stale:["_container","_displayOptionsHidden","_featuredImagePosition"],defaults:function(){return this._getDefaults({type:"automatedLatestContentLayout",withLayout:!0,amount:"5",contentType:"post",terms:[],inclusionType:"include",displayType:"excerpt",titleFormat:"h1",titleAlignment:"left",titleIsLink:!1,imageFullWidth:!1,titlePosition:"abovePost",featuredImagePosition:"centered",fullPostFeaturedImagePosition:"none",showAuthor:"no",authorPrecededBy:"Author:",showCategories:"no",categoriesPrecededBy:"Categories:",readMoreType:"button",readMoreText:"Read more",readMoreButton:{text:"Read more",url:"[postLink]"},sortBy:"newest",showDivider:!0,divider:{},_container:new(x.getBlockTypeModel("container")),_displayOptionsHidden:!0,_featuredImagePosition:"none"},x.getConfig().get("blockDefaults.automatedLatestContentLayout"))},relations:function(){return{readMoreButton:x.getBlockTypeModel("button"),divider:x.getBlockTypeModel("divider"),_container:x.getBlockTypeModel("container")}},initialize:function(e){c.default.isEmpty(e)&&this.set("fullPostFeaturedImagePosition","left"),e&&"full"===e.displayType&&"product"===e.contentType&&!this.get("fullPostFeaturedImagePosition")&&this.set("fullPostFeaturedImagePosition",this.get("featuredImagePosition")),Se.BlockView.prototype.initialize.apply(this,arguments),this.on("change:amount change:contentType change:terms change:inclusionType change:displayType change:titleFormat change:featuredImagePosition change:fullPostFeaturedImagePosition change:titleAlignment change:titleIsLink change:imageFullWidth change:showAuthor change:authorPrecededBy change:showCategories change:categoriesPrecededBy change:readMoreType change:readMoreText change:sortBy change:showDivider change:titlePosition",this._handleChanges,this),this.listenTo(this.get("readMoreButton"),"change",this._handleChanges),this.listenTo(this.get("divider"),"change",this._handleChanges),this.on("add remove update reset",this._handleChanges),this.on("refreshPosts",this.updatePosts,this);const t="full"===this.get("displayType")?"fullPostFeaturedImagePosition":"featuredImagePosition";this.set("_featuredImagePosition",this.get(t))},updatePosts:function(e){this.get("_container.blocks").reset(e,{parse:!0})},_handleChanges:function(){this._updateDefaults(),x.getChannel().trigger("automatedLatestContentLayoutRefresh")}}),ke.AutomatedLatestContentLayoutBlockView=Se.BlockView.extend({className:"mailpoet_block mailpoet_automated_latest_content_block mailpoet_droppable_block",initialize:function(){x.getChannel().on("replaceAllButtonStyles",function(e){this.model.set({readMoreButton:e})}.bind(this))},getTemplate:function(){return window.templates.automatedLatestContentLayoutBlock},regions:{toolsRegion:".mailpoet_tools",postsRegion:".mailpoet_automated_latest_content_block_posts"},modelEvents:c.default.extend(c.default.omit(Se.BlockView.prototype.modelEvents,"change"),{postsChanged:"render"}),events:{"click .mailpoet_automated_latest_content_block_overlay":"showSettings"},onDragSubstituteBy:function(){return ke.AutomatedLatestContentLayoutWidgetView},onRender:function(){var e=x.getBlockTypeView("container"),t={disableTextEditor:!0,disableDragAndDrop:!0,emptyContainerMessage:(0,i.__)("There is no content to display.","mailpoet")};this.toolsView=new ke.AutomatedLatestContentLayoutBlockToolsView({model:this.model}),this.showChildView("toolsRegion",this.toolsView),this.showChildView("postsRegion",new e({model:this.model.get("_container"),renderOptions:t}))},duplicateBlock:function(){var e=this.model.toJSON(),t=new ke.AutomatedLatestContentLayoutBlockModel(e);this.model.collection.add(t,{at:this.model.collection.findIndex(this.model)})}}),ke.AutomatedLatestContentLayoutBlockToolsView=Se.BlockToolsView.extend({getSettingsView:function(){return ke.AutomatedLatestContentLayoutBlockSettingsView}}),ke.AutomatedLatestContentLayoutBlockSettingsView=Se.BlockSettingsView.extend({getTemplate:function(){return window.templates.automatedLatestContentLayoutBlockSettings},events:function(){return{"click .mailpoet_automated_latest_content_hide_display_options":"toggleDisplayOptions","click .mailpoet_automated_latest_content_show_display_options":"toggleDisplayOptions","click .mailpoet_automated_latest_content_select_button":"showButtonSettings","click .mailpoet_automated_latest_content_select_divider":"showDividerSettings","change .mailpoet_automated_latest_content_read_more_type":"changeReadMoreType","change .mailpoet_automated_latest_content_display_type":"changeDisplayType","change .mailpoet_automated_latest_content_title_format":"changeTitleFormat","change .mailpoet_automated_latest_content_title_as_links":c.default.partial(this.changeBoolField,"titleIsLink"),"change .mailpoet_automated_latest_content_show_divider":c.default.partial(this.changeBoolField,"showDivider"),"input .mailpoet_automated_latest_content_show_amount":c.default.partial(this.changeField,"amount"),"change .mailpoet_automated_latest_content_content_type":c.default.partial(this.changeField,"contentType"),"change .mailpoet_automated_latest_content_include_or_exclude":c.default.partial(this.changeField,"inclusionType"),"change .mailpoet_automated_latest_content_title_alignment":c.default.partial(this.changeField,"titleAlignment"),"change .mailpoet_automated_latest_content_image_full_width":c.default.partial(this.changeBoolField,"imageFullWidth"),"change .mailpoet_automated_latest_content_featured_image_position":"changeFeaturedImagePosition","change .mailpoet_automated_latest_content_show_author":c.default.partial(this.changeField,"showAuthor"),"input .mailpoet_automated_latest_content_author_preceded_by":c.default.partial(this.changeField,"authorPrecededBy"),"change .mailpoet_automated_latest_content_show_categories":c.default.partial(this.changeField,"showCategories"),"input .mailpoet_automated_latest_content_categories":c.default.partial(this.changeField,"categoriesPrecededBy"),"input .mailpoet_automated_latest_content_read_more_text":c.default.partial(this.changeField,"readMoreText"),"change .mailpoet_automated_latest_content_sort_by":c.default.partial(this.changeField,"sortBy"),"change .mailpoet_automated_latest_content_title_position":c.default.partial(this.changeField,"titlePosition"),"click .mailpoet_done_editing":"close"}},onRender:function(){var e=this;Z.getPostTypes().done(c.default.bind(this._updateContentTypes,this)),this.$(".mailpoet_automated_latest_content_categories_and_tags").select2({multiple:!0,allowClear:!0,placeholder:(0,i.__)("Categories & tags","mailpoet"),ajax:{data:function(e){return{term:e.term,page:e.page||1}},transport:function(t,o,n){var r,i=Z.getTaxonomies(e.model.get("contentType")).then((function(e){return r=e,Z.getTerms({search:t.data.term,page:t.data.page,taxonomies:c.default.keys(r)}).then((function(e){return{taxonomies:r,terms:e}}))}));return i.then(o),i.fail(n),i},processResults:function(e){return{results:c.default.map(e.terms,(function(t){return c.default.defaults({text:e.taxonomies[t.taxonomy].labels.singular_name+": "+t.name,id:t.term_id},t)})),pagination:{more:100===e.terms.length}}}}}).on({"select2:select":function(t){var o=e.model.get("terms");o.add(t.params.data),e.model.set("terms",o.toJSON())},"select2:unselect":function(t){var o=e.model.get("terms");o.remove(t.params.data),e.model.set("terms",o.toJSON())}}).trigger("change")},toggleDisplayOptions:function(){this.model.set("_displayOptionsHidden",!this.model.get("_displayOptionsHidden")),this.render()},showButtonSettings:function(){new ae.ButtonBlockSettingsView({model:this.model.get("readMoreButton"),renderOptions:{displayFormat:"subpanel",hideLink:!0,hideApplyToAll:!0}}).render()},showDividerSettings:function(){new he.DividerBlockSettingsView({model:this.model.get("divider"),renderOptions:{displayFormat:"subpanel",hideApplyToAll:!0}}).render()},changeReadMoreType:function(e){var t=w()(e.target).val();"link"===t?(this.$(".mailpoet_automated_latest_content_read_more_text").removeClass("mailpoet_hidden"),this.$(".mailpoet_automated_latest_content_select_button").addClass("mailpoet_hidden")):"button"===t&&(this.$(".mailpoet_automated_latest_content_read_more_text").addClass("mailpoet_hidden"),this.$(".mailpoet_automated_latest_content_select_button").removeClass("mailpoet_hidden")),this.changeField("readMoreType",e)},changeDisplayType:function(e){"titleOnly"!==w()(e.target).val()&&"ul"===this.model.get("titleFormat")&&(this.model.set("titleFormat","h1"),this.$(".mailpoet_automated_latest_content_title_format").val(["h1"]),this.$(".mailpoet_automated_latest_content_title_as_link").removeClass("mailpoet_hidden")),this.changeField("displayType",e);const t="full"===this.model.get("displayType")?"fullPostFeaturedImagePosition":"featuredImagePosition";this.model.set("_featuredImagePosition",this.model.get(t)),this.render()},changeTitleFormat:function(e){"ul"===w()(e.target).val()?(this.$(".mailpoet_automated_latest_content_non_title_list_options").addClass("mailpoet_hidden"),this.model.set("titleIsLink",!0),this.$(".mailpoet_automated_latest_content_title_as_link").addClass("mailpoet_hidden"),this.$(".mailpoet_automated_latest_content_title_as_links").val(["true"])):(this.$(".mailpoet_automated_latest_content_non_title_list_options").removeClass("mailpoet_hidden"),this.$(".mailpoet_automated_latest_content_title_as_link").removeClass("mailpoet_hidden")),this.changeField("titleFormat",e)},changeFeaturedImagePosition:function(e){const t="full"===this.model.get("displayType")?"fullPostFeaturedImagePosition":"featuredImagePosition";this.changeField(t,e),this.changeField("_featuredImagePosition",e)},_updateContentTypes:function(e){var t=this.$(".mailpoet_automated_latest_content_content_type"),o=this.model.get("contentType");t.find("option").remove(),c.default.each(e,(function(e){t.append(w()(" ",{value:e.name,text:e.label}))})),t.val(o)}}),ke.AutomatedLatestContentLayoutWidgetView=Se.WidgetView.extend({className:Se.WidgetView.prototype.className+" mailpoet_droppable_layout_block",getTemplate:function(){return window.templates.automatedLatestContentLayoutInsertion},behaviors:{DraggableBehavior:{cloneOriginal:!0,drop:function(){return new ke.AutomatedLatestContentLayoutBlockModel({},{parse:!0})},onDrop:function(e){e.droppedView.triggerMethod("showSettings")}}}}),x.on("before:start",(function(e){e.registerBlockType("automatedLatestContentLayout",{blockModel:ke.AutomatedLatestContentLayoutBlockModel,blockView:ke.AutomatedLatestContentLayoutBlockView}),e.registerWidget({name:"automatedLatestContentLayout",widgetView:ke.AutomatedLatestContentLayoutWidgetView,priority:97})})),x.on("start",(function(e){var t=e;t._ALCLayoutSupervisor=new ke.ALCLayoutSupervisor,t._ALCLayoutSupervisor.refresh()})),o(1201);var Te,Ee,Oe,Me,Ae,Be={},Ne=oe;Be.PostsBlockModel=Ne.BlockModel.extend({stale:["_selectedPosts","_availablePosts","_transformedPosts","_featuredImagePosition"],defaults:function(){return this._getDefaults({type:"posts",withLayout:!0,amount:"10",offset:0,contentType:"post",postStatus:"publish",terms:[],search:"",inclusionType:"include",displayType:"excerpt",titleFormat:"h1",titleAlignment:"left",titleIsLink:!1,imageFullWidth:!1,titlePosition:"abovePost",featuredImagePosition:"centered",fullPostFeaturedImagePosition:"none",showAuthor:"no",authorPrecededBy:"Author:",showCategories:"no",categoriesPrecededBy:"Categories:",readMoreType:"link",readMoreText:"Read more",readMoreButton:{text:"Read more",url:"[postLink]"},sortBy:"newest",showDivider:!0,divider:{},_selectedPosts:[],_availablePosts:[],_transformedPosts:new(x.getBlockTypeModel("container")),_featuredImagePosition:"none"},x.getConfig().get("blockDefaults.posts"))},relations:function(){return{readMoreButton:x.getBlockTypeModel("button"),divider:x.getBlockTypeModel("divider"),_selectedPosts:E().Collection,_availablePosts:E().Collection,_transformedPosts:x.getBlockTypeModel("container")}},initialize:function(e){var t=c.default.debounce(this.fetchAvailablePosts.bind(this),500),o=c.default.debounce(this._refreshTransformedPosts.bind(this),500);c.default.isEmpty(e)&&this.set("fullPostFeaturedImagePosition","left"),e&&"full"===e.displayType&&"product"===e.contentType&&!this.get("fullPostFeaturedImagePosition")&&this.set("fullPostFeaturedImagePosition",this.get("featuredImagePosition")),c.default.extend(this,b().Requests),this.fetchAvailablePosts(),this.on("change",this._updateDefaults,this),this.on("change:contentType change:terms change:postStatus change:search",t),this.on("loadMorePosts",this._loadMorePosts,this),this.listenTo(this.get("_selectedPosts"),"add remove reset",o),this.on("change:displayType change:titleFormat change:featuredImagePosition change:fullPostFeaturedImagePosition change:titleAlignment change:titleIsLink change:imageFullWidth change:showAuthor change:authorPrecededBy change:showCategories change:categoriesPrecededBy change:readMoreType change:readMoreText change:showDivider change:titlePosition",o),this.listenTo(this.get("readMoreButton"),"change",o),this.listenTo(this.get("divider"),"change",o),this.listenTo(x.getChannel(),"hideSettings",this.destroy),this.on("insertSelectedPosts",this._insertSelectedPosts,this);const n="full"===this.get("displayType")?"fullPostFeaturedImagePosition":"featuredImagePosition";this.set("_featuredImagePosition",this.get(n))},fetchAvailablePosts:function(){var e=this;this.set("offset",0),Z.getPosts(this.toJSON()).done((function(t){e.get("_availablePosts").reset(t),e.get("_selectedPosts").reset(),e.trigger("change:_availablePosts")})).fail((function(){r.MailPoet.Notice.error((0,i.__)("Failed to fetch available posts","mailpoet"))}))},_loadMorePosts:function(){var e=this,t=this.get("_availablePosts").length,o=this.get("offset")+Number(this.get("amount"));return!(0===t||t=t[0].scrollHeight&&this.blockModel.trigger("loadMorePosts")}}),Me=f().View.extend({getTemplate:function(){return window.templates.postSelectionPostsBlockSettings},regions:{posts:".mailpoet_post_selection_container"},events:function(){return{"change .mailpoet_settings_posts_content_type":c.default.partial(this.changeField,"contentType"),"change .mailpoet_posts_post_status":c.default.partial(this.changeField,"postStatus"),"input .mailpoet_posts_search_term":c.default.partial(this.changeField,"search")}},modelEvents:{"change:offset":function(e,t){0===t&&this.$(".mailpoet_post_scroll_container").scrollTop(0)},loadingMorePosts:function(){this.$(".mailpoet_post_selection_loading").css("visibility","visible")},morePostsLoaded:function(){this.$(".mailpoet_post_selection_loading").css("visibility","hidden")}},templateContext:function(){return{model:this.model.toJSON()}},onRender:function(){var e;Z.getPostTypes().done(c.default.bind(this._updateContentTypes,this)),e=new Ae({collection:this.model.get("_availablePosts"),blockModel:this.model}),this.showChildView("posts",e)},onAttach:function(){var e=this;this.$(".mailpoet_posts_categories_and_tags").select2({multiple:!0,allowClear:!0,placeholder:(0,i.__)("Categories & tags","mailpoet"),ajax:{data:function(e){return{term:e.term,page:e.page||1}},transport:function(t,o,n){var r,i=Z.getTaxonomies(e.model.get("contentType")).then((function(e){return r=e,Z.getTerms({search:t.data.term,page:t.data.page,taxonomies:c.default.keys(r)}).then((function(e){return{taxonomies:r,terms:e}}))}));return i.then(o),i.fail(n),i},processResults:function(e){return{results:c.default.map(e.terms,(function(t){return c.default.defaults({text:e.taxonomies[t.taxonomy].labels.singular_name+": "+t.name,id:t.term_id},t)})),pagination:{more:100===e.terms.length}}}}}).on({"select2:select":function(t){var o=e.model.get("terms");o.add(t.params.data),e.model.set("terms",o.toJSON())},"select2:unselect":function(t){var o=e.model.get("terms");o.remove(t.params.data),e.model.set("terms",o.toJSON())}}).trigger("change")},changeField:function(e,t){this.model.set(e,w()(t.target).val())},_updateContentTypes:function(e){var t=this.$(".mailpoet_settings_posts_content_type"),o=this.model.get("contentType");t.find("option").remove(),c.default.each(e,(function(e){t.append(w()("",{value:e.name,text:e.label}))})),t.val(o)}}),Oe=f().View.extend({getTemplate:function(){return window.templates.emptyPostPostsBlockSettings}}),Ee=f().View.extend({getTemplate:function(){return window.templates.singlePostPostsBlockSettings},events:function(){return{"change .mailpoet_select_post_checkbox":"postSelectionChange"}},templateContext:function(){return{model:this.model.toJSON(),index:this._index}},initialize:function(e){this.blockModel=e.blockModel},postSelectionChange:function(e){var t=w()(e.target),o=this.blockModel.get("_selectedPosts");t.prop("checked")?o.add(this.model):o.remove(this.model)}}),Te=Ne.BlockSettingsView.extend({getTemplate:function(){return window.templates.displayOptionsPostsBlockSettings},events:function(){return{"click .mailpoet_posts_select_button":"showButtonSettings","click .mailpoet_posts_select_divider":"showDividerSettings","change .mailpoet_posts_read_more_type":"changeReadMoreType","change .mailpoet_posts_display_type":"changeDisplayType","change .mailpoet_posts_title_format":"changeTitleFormat","change .mailpoet_posts_title_as_links":c.default.partial(this.changeBoolField,"titleIsLink"),"change .mailpoet_posts_show_divider":c.default.partial(this.changeBoolField,"showDivider"),"change .mailpoet_posts_content_type":c.default.partial(this.changeField,"contentType"),"change .mailpoet_posts_title_alignment":c.default.partial(this.changeField,"titleAlignment"),"change .mailpoet_posts_image_full_width":c.default.partial(this.changeBoolField,"imageFullWidth"),"change .mailpoet_posts_featured_image_position":"changeFeaturedImagePosition","change .mailpoet_posts_show_author":c.default.partial(this.changeField,"showAuthor"),"input .mailpoet_posts_author_preceded_by":c.default.partial(this.changeField,"authorPrecededBy"),"change .mailpoet_posts_show_categories":c.default.partial(this.changeField,"showCategories"),"input .mailpoet_posts_categories":c.default.partial(this.changeField,"categoriesPrecededBy"),"input .mailpoet_posts_read_more_text":c.default.partial(this.changeField,"readMoreText"),"change .mailpoet_automated_latest_content_title_position":c.default.partial(this.changeField,"titlePosition")}},templateContext:function(){return{model:this.model.toJSON()}},showButtonSettings:function(){new ae.ButtonBlockSettingsView({model:this.model.get("readMoreButton"),renderOptions:{displayFormat:"subpanel",hideLink:!0,hideApplyToAll:!0}}).render()},showDividerSettings:function(){new he.DividerBlockSettingsView({model:this.model.get("divider"),renderOptions:{displayFormat:"subpanel",hideApplyToAll:!0}}).render()},changeReadMoreType:function(e){var t=w()(e.target).val();"link"===t?(this.$(".mailpoet_posts_read_more_text").removeClass("mailpoet_hidden"),this.$(".mailpoet_posts_select_button").addClass("mailpoet_hidden")):"button"===t&&(this.$(".mailpoet_posts_read_more_text").addClass("mailpoet_hidden"),this.$(".mailpoet_posts_select_button").removeClass("mailpoet_hidden")),this.changeField("readMoreType",e)},changeDisplayType:function(e){"titleOnly"!==w()(e.target).val()&&"ul"===this.model.get("titleFormat")&&(this.model.set("titleFormat","h1"),this.$(".mailpoet_posts_title_format").val(["h1"]),this.$(".mailpoet_posts_title_as_link").removeClass("mailpoet_hidden")),this.changeField("displayType",e);const t="full"===this.model.get("displayType")?"fullPostFeaturedImagePosition":"featuredImagePosition";this.model.set("_featuredImagePosition",this.model.get(t)),this.render()},changeTitleFormat:function(e){"ul"===w()(e.target).val()?(this.$(".mailpoet_posts_non_title_list_options").addClass("mailpoet_hidden"),this.model.set("titleIsLink",!0),this.$(".mailpoet_posts_title_as_link").addClass("mailpoet_hidden"),this.$(".mailpoet_posts_title_as_links").val(["true"])):(this.$(".mailpoet_posts_non_title_list_options").removeClass("mailpoet_hidden"),this.$(".mailpoet_posts_title_as_link").removeClass("mailpoet_hidden")),this.changeField("titleFormat",e)},changeFeaturedImagePosition:function(e){const t="full"===this.model.get("displayType")?"fullPostFeaturedImagePosition":"featuredImagePosition";this.changeField(t,e),this.changeField("_featuredImagePosition",e)}}),Be.PostsWidgetView=Ne.WidgetView.extend({className:Ne.WidgetView.prototype.className+" mailpoet_droppable_layout_block",getTemplate:function(){return window.templates.postsInsertion},behaviors:{DraggableBehavior:{cloneOriginal:!0,drop:function(){return new Be.PostsBlockModel({},{parse:!0})}}}}),x.on("before:start",(function(e){e.registerBlockType("posts",{blockModel:Be.PostsBlockModel,blockView:Be.PostsBlockView}),e.registerWidget({name:"posts",widgetView:Be.PostsWidgetView,priority:96})}));var Re,Ve,De,Pe,Ie,Fe={},Le=oe;Fe.ProductsBlockModel=Le.BlockModel.extend({stale:["_selectedProducts","_availableProducts","_transformedProducts"],defaults:function(){return this._getDefaults({type:"products",withLayout:!0,amount:"10",offset:0,contentType:"product",postStatus:"publish",terms:[],search:"",inclusionType:"include",displayType:"excerpt",titleFormat:"h1",titleAlignment:"left",titleIsLink:!1,imageFullWidth:!1,titlePosition:"abovePost",featuredImagePosition:"alternate",pricePosition:"below",readMoreType:"link",readMoreText:"Buy now",readMoreButton:{text:"Buy now",url:"[postLink]"},sortBy:"newest",showDivider:!0,divider:{},_selectedProducts:[],_availableProducts:[],_transformedProducts:new(x.getBlockTypeModel("container"))},x.getConfig().get("blockDefaults.products"))},relations:function(){return{readMoreButton:x.getBlockTypeModel("button"),divider:x.getBlockTypeModel("divider"),_selectedProducts:E().Collection,_availableProducts:E().Collection,_transformedProducts:x.getBlockTypeModel("container")}},initialize:function(){var e=c.default.debounce(this.fetchAvailableProducts.bind(this),500),t=c.default.debounce(this._refreshTransformedProducts.bind(this),500);c.default.extend(this,b().Requests),this.fetchAvailableProducts(),this.on("change",this._updateDefaults,this),this.on("change:terms change:postStatus change:search",e),this.on("loadMoreProducts",this._loadMoreProducts,this),this.listenTo(this.get("_selectedProducts"),"add remove reset",t),this.on("change:displayType change:titleFormat change:featuredImagePosition change:titleAlignment change:titleIsLink change:imageFullWidth change:pricePosition change:readMoreType change:readMoreText change:showDivider change:titlePosition",t),this.listenTo(this.get("readMoreButton"),"change",t),this.listenTo(this.get("divider"),"change",t),this.listenTo(x.getChannel(),"hideSettings",this.destroy),this.on("insertSelectedProducts",this._insertSelectedProducts,this)},fetchAvailableProducts:function(){var e=this;this.set("offset",0),Z.getPosts(this.toJSON()).done((function(t){e.get("_availableProducts").reset(t),e.get("_selectedProducts").reset(),e.trigger("change:_availableProducts")})).fail((function(){r.MailPoet.Notice.error((0,i.__)("Failed to fetch available posts","mailpoet"))}))},_loadMoreProducts:function(){var e=this,t=this.get("_availableProducts").length,o=this.get("offset")+Number(this.get("amount"));return!(0===t||t=t[0].scrollHeight&&this.blockModel.trigger("loadMoreProducts")}}),Pe=f().View.extend({getTemplate:function(){return window.templates.postSelectionProductsBlockSettings},regions:{posts:".mailpoet_product_selection_container"},events:function(){return{"change .mailpoet_products_post_status":c.default.partial(this.changeField,"postStatus"),"input .mailpoet_products_search_term":c.default.partial(this.changeField,"search")}},modelEvents:{"change:offset":function(e,t){0===t&&this.$(".mailpoet_products_scroll_container").scrollTop(0)},loadingMoreProducts:function(){this.$(".mailpoet_product_selection_loading").css("visibility","visible")},moreProductsLoaded:function(){this.$(".mailpoet_product_selection_loading").css("visibility","hidden")}},templateContext:function(){return{model:this.model.toJSON()}},onRender:function(){var e;e=new Ie({collection:this.model.get("_availableProducts"),blockModel:this.model}),this.showChildView("posts",e)},onAttach:function(){var e=this;this.$(".mailpoet_products_categories_and_tags").select2({multiple:!0,allowClear:!0,placeholder:(0,i.__)("Categories & tags","mailpoet"),ajax:{data:function(e){return{term:e.term,page:e.page||1}},transport:function(t,o,n){var r,i=Z.getTaxonomies(e.model.get("contentType")).then((function(e){return r=e,Z.getTerms({search:t.data.term,page:t.data.page,taxonomies:c.default.keys(r)}).then((function(e){return{taxonomies:r,terms:e}}))}));return i.then(o),i.fail(n),i},processResults:function(e){return{results:c.default.map(e.terms,(function(t){return c.default.defaults({text:e.taxonomies[t.taxonomy].labels.singular_name+": "+t.name,id:t.term_id},t)})),pagination:{more:100===e.terms.length}}}}}).on({"select2:select":function(t){var o=e.model.get("terms");o.add(t.params.data),e.model.set("terms",o.toJSON())},"select2:unselect":function(t){var o=e.model.get("terms");o.remove(t.params.data),e.model.set("terms",o.toJSON())}}).trigger("change")},changeField:function(e,t){this.model.set(e,w()(t.target).val())}}),De=f().View.extend({getTemplate:function(){return window.templates.emptyPostProductsBlockSettings}}),Ve=f().View.extend({getTemplate:function(){return window.templates.singlePostProductsBlockSettings},events:function(){return{"change .mailpoet_select_product_checkbox":"productSelectionChange"}},templateContext:function(){return{model:this.model.toJSON(),index:this._index}},initialize:function(e){this.blockModel=e.blockModel},productSelectionChange:function(e){var t=w()(e.target),o=this.blockModel.get("_selectedProducts");t.prop("checked")?o.add(this.model):o.remove(this.model)}}),Re=Le.BlockSettingsView.extend({getTemplate:function(){return window.templates.displayOptionsProductsBlockSettings},events:function(){return{"click .mailpoet_products_select_button":"showButtonSettings","click .mailpoet_products_select_divider":"showDividerSettings","change .mailpoet_products_read_more_type":"changeReadMoreType","change .mailpoet_products_display_type":"changeDisplayType","change .mailpoet_products_title_format":"changeTitleFormat","change .mailpoet_products_title_as_links":c.default.partial(this.changeBoolField,"titleIsLink"),"change .mailpoet_products_show_divider":c.default.partial(this.changeBoolField,"showDivider"),"change .mailpoet_products_title_alignment":c.default.partial(this.changeField,"titleAlignment"),"change .mailpoet_products_image_full_width":c.default.partial(this.changeBoolField,"imageFullWidth"),"change .mailpoet_products_featured_image_position":c.default.partial(this.changeField,"featuredImagePosition"),"change .mailpoet_products_price_position":c.default.partial(this.changeField,"pricePosition"),"input .mailpoet_products_read_more_text":c.default.partial(this.changeField,"readMoreText"),"change .mailpoet_products_title_position":c.default.partial(this.changeField,"titlePosition")}},templateContext:function(){return{model:this.model.toJSON()}},showButtonSettings:function(){new ae.ButtonBlockSettingsView({model:this.model.get("readMoreButton"),renderOptions:{displayFormat:"subpanel",hideLink:!0,hideApplyToAll:!0}}).render()},showDividerSettings:function(){new he.DividerBlockSettingsView({model:this.model.get("divider"),renderOptions:{displayFormat:"subpanel",hideApplyToAll:!0}}).render()},changeReadMoreType:function(e){var t=w()(e.target).val();"link"===t?(this.$(".mailpoet_products_read_more_text").removeClass("mailpoet_hidden"),this.$(".mailpoet_products_select_button").addClass("mailpoet_hidden")):"button"===t&&(this.$(".mailpoet_products_read_more_text").addClass("mailpoet_hidden"),this.$(".mailpoet_products_select_button").removeClass("mailpoet_hidden")),this.changeField("readMoreType",e)},changeDisplayType:function(e){"titleOnly"!==w()(e.target).val()?(this.$(".mailpoet_products_title_position").removeClass("mailpoet_hidden"),this.$(".mailpoet_products_title_position_separator").removeClass("mailpoet_hidden")):(this.$(".mailpoet_products_title_position").addClass("mailpoet_hidden"),this.$(".mailpoet_products_title_position_separator").addClass("mailpoet_hidden")),this.changeField("displayType",e)},changeTitleFormat:function(e){this.changeField("titleFormat",e)}}),Fe.ProductsWidgetView=Le.WidgetView.extend({className:Le.WidgetView.prototype.className+" mailpoet_droppable_layout_block",id:"automation_editor_block_products",getTemplate:function(){return window.templates.productsInsertion},behaviors:{DraggableBehavior:{cloneOriginal:!0,drop:function(){return new Fe.ProductsBlockModel({},{parse:!0})}}}}),x.on("before:start",(function(e){window.mailpoet_woocommerce_active&&(e.registerBlockType("products",{blockModel:Fe.ProductsBlockModel,blockView:Fe.ProductsBlockView}),e.registerWidget({name:"products",widgetView:Fe.ProductsWidgetView,priority:98}))}));var ze,He={},Ze=oe,je=!0;He.AbandonedCartContentBlockModel=Ze.BlockModel.extend({stale:["_selectedProducts","_availableProducts","_transformedProducts"],defaults:function(){return this._getDefaults({type:"abandonedCartContent",withLayout:!0,amount:"2",contentType:"product",postStatus:"publish",inclusionType:"include",displayType:"excerpt",titleFormat:"h1",titleAlignment:"left",titleIsLink:!1,imageFullWidth:!1,titlePosition:"abovePost",featuredImagePosition:"alternate",pricePosition:"below",readMoreType:"none",readMoreText:"",readMoreButton:{},sortBy:"newest",showDivider:!0,divider:{},_selectedProducts:[],_availableProducts:[],_transformedProducts:new(x.getBlockTypeModel("container"))},x.getConfig().get("blockDefaults.abandonedCartContent"))},relations:function(){return{divider:x.getBlockTypeModel("divider"),_selectedProducts:E().Collection,_availableProducts:E().Collection,_transformedProducts:x.getBlockTypeModel("container")}},initialize:function(){var e=c.default.debounce(this._refreshTransformedProducts.bind(this),500);c.default.extend(this,b().Requests),this._refreshTransformedProducts(),this.on("change",this._updateDefaults,this),this.listenTo(this.get("_selectedProducts"),"add remove reset",e),this.on("change:displayType change:titleFormat change:featuredImagePosition change:titleAlignment change:titleIsLink change:imageFullWidth change:pricePosition change:showDivider change:titlePosition",e),this.listenTo(this.get("divider"),"change",e)},_refreshTransformedProducts:function(){var e=this,t=this.toJSON();Z.getTransformedPosts(t).done((function(t){e.get("_transformedProducts").get("blocks").reset(t,{parse:!0})})).fail((function(){r.MailPoet.Notice.error((0,i.__)("Failed to fetch rendered posts","mailpoet"))}))}}),He.AbandonedCartContentBlockView=Ze.BlockView.extend({className:"mailpoet_block mailpoet_abandoned_cart_content_block mailpoet_droppable_block",getTemplate:function(){return window.templates.abandonedCartContentBlock},modelEvents:c.default.omit(Ze.BlockView.prototype.modelEvents,"change"),regions:c.default.extend({productsRegion:".mailpoet_abandoned_cart_content_container"},Ze.BlockView.prototype.regions),onDragSubstituteBy:function(){return He.AbandonedCartContentBlockWidgetView},initialize:function(){Ze.BlockView.prototype.initialize.apply(this,arguments),this.toolsView=new He.AbandonedCartContentBlockToolsView({model:this.model})},events:{"click .mailpoet_abandoned_cart_content_block_overlay":"showSettings"},onRender:function(){var e,t;je&&(this.getRegion("toolsRegion").hasView()||this.showChildView("toolsRegion",this.toolsView),e=x.getBlockTypeView("container"),t={disableTextEditor:!0,disableDragAndDrop:!0,emptyContainerMessage:(0,i.__)("There is no content to display.","mailpoet")},this.showChildView("productsRegion",new e({model:this.model.get("_transformedProducts"),renderOptions:t})))}}),He.AbandonedCartContentBlockToolsView=Ze.BlockToolsView.extend({getSettingsView:function(){return He.AbandonedCartContentBlockSettingsView}}),He.AbandonedCartContentBlockSettingsView=Ze.BlockSettingsView.extend({getTemplate:function(){return window.templates.abandonedCartContentBlockSettings},regions:{displayOptionsRegion:".mailpoet_settings_abandoned_cart_content_display_options"},events:{"click .mailpoet_done_editing":"close"},templateContext:function(){return{model:this.model.toJSON()}},initialize:function(){this.model.trigger("startEditing"),this.displayOptionsView=new ze({model:this.model})},onRender:function(){this.model.request("blockView"),this.showChildView("displayOptionsRegion",this.displayOptionsView),r.MailPoet.Modal.panel({element:this.$el,template:"",position:"right",overlayRender:!1,width:x.getConfig().get("sidepanelWidth")}),this.displayOptionsView.triggerMethod("attach")}}),ze=Ze.BlockSettingsView.extend({getTemplate:function(){return window.templates.displayOptionsAbandonedCartContentBlockSettings},events:function(){return{"click .mailpoet_products_select_divider":"showDividerSettings","change .mailpoet_products_display_type":"changeDisplayType","change .mailpoet_products_title_format":"changeTitleFormat","change .mailpoet_products_title_as_links":c.default.partial(this.changeBoolField,"titleIsLink"),"change .mailpoet_products_show_divider":c.default.partial(this.changeBoolField,"showDivider"),"change .mailpoet_products_title_alignment":c.default.partial(this.changeField,"titleAlignment"),"change .mailpoet_products_image_full_width":c.default.partial(this.changeBoolField,"imageFullWidth"),"change .mailpoet_products_featured_image_position":c.default.partial(this.changeField,"featuredImagePosition"),"change .mailpoet_products_price_position":c.default.partial(this.changeField,"pricePosition"),"change .mailpoet_products_title_position":c.default.partial(this.changeField,"titlePosition")}},templateContext:function(){return{model:this.model.toJSON()}},showDividerSettings:function(){new he.DividerBlockSettingsView({model:this.model.get("divider"),renderOptions:{displayFormat:"subpanel",hideApplyToAll:!0}}).render()},changeDisplayType:function(e){"titleOnly"!==w()(e.target).val()?(this.$(".mailpoet_products_title_position").removeClass("mailpoet_hidden"),this.$(".mailpoet_products_title_position_separator").removeClass("mailpoet_hidden")):(this.$(".mailpoet_products_title_position").addClass("mailpoet_hidden"),this.$(".mailpoet_products_title_position_separator").addClass("mailpoet_hidden")),this.changeField("displayType",e)},changeTitleFormat:function(e){this.changeField("titleFormat",e)}}),He.AbandonedCartContentBlockWidgetView=Ze.WidgetView.extend({className:Ze.WidgetView.prototype.className+" mailpoet_droppable_layout_block",id:"automation_editor_block_abandoned_cart_content",getTemplate:function(){return window.templates.abandonedCartContentInsertion},behaviors:{DraggableBehavior:{cloneOriginal:!0,drop:function(){return new He.AbandonedCartContentBlockModel({},{parse:!0})}}}}),x.on("before:start",(function(e,t){window.mailpoet_woocommerce_active&&(e.registerBlockType("abandonedCartContent",{blockModel:He.AbandonedCartContentBlockModel,blockView:He.AbandonedCartContentBlockView}),"woocommerce"===t.newsletter.options.group&&"woocommerce_abandoned_shopping_cart"===t.newsletter.options.event?e.registerWidget({name:"abandonedCartContent",widgetView:He.AbandonedCartContentBlockWidgetView,priority:99}):je=!1)}));var Ue,$e,We,qe,Ge,Ye={},Ke=oe;Ye.SocialIconModel=C.extend({defaults:function(){var e=x.getConfig().get("socialIcons.custom");return{type:"socialIcon",iconType:"custom",link:e.get("defaultLink"),image:x.getAvailableStyles().get("socialIconSets.default.custom"),height:"32px",width:"32px",text:e.get("title")}},initialize:function(){var e=this;this.on("change:iconType",(function(){var t=x.getConfig().get("socialIcons").get(e.get("iconType")),o=e.collection.iconBlockModel.getIconSet();this.set({link:t.get("defaultLink"),image:o.get(e.get("iconType")),text:t.get("title")})}),this),this.on("change",(function(){x.getChannel().trigger("autoSave")}))}}),Ye.SocialIconCollectionModel=E().Collection.extend({model:Ye.SocialIconModel}),Ye.SocialBlockModel=Ke.BlockModel.extend({name:"iconBlockModel",defaults:function(){return this._getDefaults({type:"social",iconSet:"default",styles:{block:{textAlign:"center"}},icons:new Ye.SocialIconCollectionModel},x.getConfig().get("blockDefaults.social"))},relations:{icons:Ye.SocialIconCollectionModel},initialize:function(){this.get("icons").on("add remove change",this._iconsChanged,this),this.on("change:iconSet",this.changeIconSet,this),this.on("change",this._updateDefaults,this)},getIconSet:function(){return x.getAvailableStyles().get("socialIconSets").get(this.get("iconSet"))},changeIconSet:function(){var e=this.getIconSet();c.default.each(this.get("icons").models,(function(t){t.set("image",e.get(t.get("iconType")))}))},_iconsChanged:function(){this._updateDefaults(),x.getChannel().trigger("autoSave")}}),Ge=f().View.extend({tagName:"span",getTemplate:function(){return window.templates.socialIconBlock},modelEvents:{change:"render"},templateContext:function(){var e=x.getAvailableStyles().get("socialIconSets");return{model:this.model.toJSON(),allIconSets:e.toJSON(),imageMissingSrc:x.getConfig().get("urls.imageMissing")}}}),Ye.SocialIconCollectionView=f().CollectionView.extend({childView:Ge}),Ye.SocialBlockView=Ke.BlockView.extend({className:"mailpoet_block mailpoet_social_block mailpoet_droppable_block",getTemplate:function(){return window.templates.socialBlock},regions:c.default.extend({},Ke.BlockView.prototype.regions,{icons:".mailpoet_social"}),ui:{tools:"> .mailpoet_tools"},behaviors:c.default.extend({},Ke.BlockView.prototype.behaviors,{ShowSettingsBehavior:{}}),onDragSubstituteBy:function(){return Ye.SocialWidgetView},onRender:function(){this.toolsView=new Ye.SocialBlockToolsView({model:this.model}),this.showChildView("toolsRegion",this.toolsView),this.showChildView("icons",new Ye.SocialIconCollectionView({collection:this.model.get("icons")}))}}),Ye.SocialBlockToolsView=Ke.BlockToolsView.extend({getSettingsView:function(){return Ye.SocialBlockSettingsView}}),Ye.SocialBlockSettingsView=Ke.BlockSettingsView.extend({getTemplate:function(){return window.templates.socialBlockSettings},regions:{iconRegion:"#mailpoet_social_icons_selection",stylesRegion:"#mailpoet_social_icons_styles"},events:function(){return{"click .mailpoet_done_editing":"close","change .mailpoet_social_block_alignment":c.default.partial(this.changeField,"styles.block.textAlign")}},initialize:function(){Ke.BlockSettingsView.prototype.initialize.apply(this,arguments),this._iconSelectorView=new Ue({model:this.model}),this._stylesView=new qe({model:this.model})},onRender:function(){this.showChildView("iconRegion",this._iconSelectorView),this.showChildView("stylesRegion",this._stylesView)}}),$e=f().View.extend({getTemplate:function(){return window.templates.socialSettingsIcon},events:function(){return{"click .mailpoet_delete_block":"deleteIcon","change .mailpoet_social_icon_field_type":c.default.partial(this.changeField,"iconType"),"input .mailpoet_social_icon_field_image":c.default.partial(this.changeField,"image"),"input .mailpoet_social_icon_field_link":this.changeLink,"input .mailpoet_social_icon_field_text":c.default.partial(this.changeField,"text")}},modelEvents:{"change:iconType":"render","change:image":function(){this.$(".mailpoet_social_icon_image").attr("src",this.model.get("image"))},"change:text":function(){this.$(".mailpoet_social_icon_image").attr("alt",this.model.get("text"))}},templateContext:function(){var e=x.getConfig().get("socialIcons"),t=c.default.map(c.default.keys(e.attributes),(function(t){return{iconType:t,title:e.get(t).get("title")}})),o=x.getAvailableStyles().get("socialIconSets");return c.default.extend({},Ke.BlockView.prototype.templateContext.apply(this,arguments),{iconTypes:t,currentType:e.get(this.model.get("iconType")).toJSON(),allIconSets:o.toJSON()})},deleteIcon:function(){this.model.destroy()},changeLink:function(e){if("email"!==this.model.get("iconType"))return this.changeField("link",e);this.model.set("link","mailto:"+w()(e.target).val())},changeField:function(e,t){this.model.set(e,w()(t.target).val())}}),We=f().CollectionView.extend({behaviors:{SortableBehavior:{items:"> div"}},childViewContainer:"#mailpoet_social_icon_selector_contents",childView:$e}),Ue=f().View.extend({getTemplate:function(){return window.templates.socialSettingsIconSelector},regions:{icons:"#mailpoet_social_icon_selector_contents"},events:{"click .mailpoet_add_social_icon":"addSocialIcon"},modelEvents:{"change:iconSet":"render"},addSocialIcon:function(){this.model.get("icons").add({})},onRender:function(){this.showChildView("icons",new We({collection:this.model.get("icons")}))}}),qe=f().View.extend({getTemplate:function(){return window.templates.socialSettingsStyles},modelEvents:{change:"render"},events:{"click .mailpoet_social_icon_set":"changeSocialIconSet"},initialize:function(){this.listenTo(this.model.get("icons"),"add remove change",this.render)},templateContext:function(){var e=x.getAvailableStyles().get("socialIconSets");return{activeSet:this.model.get("iconSet"),socialIconSets:e.toJSON(),availableSets:c.default.keys(e.toJSON()),availableSocialIcons:this.model.get("icons").pluck("iconType")}},changeSocialIconSet:function(e){this.model.set("iconSet",w()(e.currentTarget).data("setname"))},onBeforeDestroy:function(){this.model.get("icons").off("add remove",this.render,this)}}),Ye.SocialWidgetView=Ke.WidgetView.extend({id:"automation_editor_block_social",getTemplate:function(){return window.templates.socialInsertion},behaviors:{DraggableBehavior:{cloneOriginal:!0,drop:function(){return new Ye.SocialBlockModel}}}}),x.on("before:start",(function(e){e.registerBlockType("social",{blockModel:Ye.SocialBlockModel,blockView:Ye.SocialBlockView}),e.registerWidget({name:"social",widgetView:Ye.SocialWidgetView,priority:95})}));const Xe=oe.BlockModel.extend({stale:["selected"],defaults(){return this._getDefaults({type:"woocommerceContent",selected:"completed_order"},x.getConfig().get("blockDefaults.woocommerceContent"))}}),Je=oe.BlockToolsView.extend({tools:{move:!0}}),Qe=oe.WidgetView.extend({className:oe.WidgetView.prototype.className+" mailpoet_droppable_layout_block",getTemplate(){return window.templates.woocommerceContentInsertion},behaviors:{DraggableBehavior:{cloneOriginal:!0,drop(){return new Xe({},{parse:!0})}}}}),et=oe.BlockView.extend({className:"mailpoet_block mailpoet_woocommerce_content_block mailpoet_droppable_block",initialize:function(){oe.BlockView.prototype.initialize.apply(this,arguments),this.listenTo(x.getChannel(),"changeWCEmailType",(e=>{this.model.set("selected",e),this.render()}))},getTemplate(){return"new_account"===this.model.get("selected")?window.templates.woocommerceNewAccount:"processing_order"===this.model.get("selected")?window.templates.woocommerceProcessingOrder:"completed_order"===this.model.get("selected")?window.templates.woocommerceCompletedOrder:window.templates.woocommerceCustomerNote},regions:{toolsRegion:".mailpoet_tools"},onDragSubstituteBy(){return Qe},onRender(){this.toolsView=new Je({model:this.model}),this.showChildView("toolsRegion",this.toolsView)},templateContext(){return{viewCid:this.cid,model:this.model.toJSON(),selected:this.model.get("selected"),siteName:window.mailpoet_site_name,siteAddress:window.mailpoet_site_address}}});x.on("before:start",(e=>{e.registerBlockType("woocommerceContent",{blockModel:Xe,blockView:et})}));const tt=oe.BlockModel.extend({stale:["contents","selected"],defaults(){return this._getDefaults({type:"woocommerceHeading",selected:"completed_order"},x.getConfig().get("blockDefaults.woocommerceHeading"))}}),ot=oe.BlockToolsView.extend({tools:{move:!0}}),nt=oe.WidgetView.extend({className:oe.WidgetView.prototype.className+" mailpoet_droppable_layout_block",getTemplate(){return window.templates.woocommerceHeadingInsertion},behaviors:{DraggableBehavior:{cloneOriginal:!0,drop(){return new tt({},{parse:!0})}}}}),rt=oe.BlockView.extend({className:"mailpoet_container mailpoet_woocommerce_heading_block mailpoet_droppable_block",initialize:function(){oe.BlockView.prototype.initialize.apply(this,arguments),this.listenTo(x.getChannel(),"changeWCEmailType",(e=>{this.model.set("selected",e),this.render()}))},modelEvents:c.default.omit(oe.BlockView.prototype.modelEvents,"change"),getTemplate(){return window.templates.woocommerceHeadingBlock},regions:{toolsRegion:".mailpoet_tools"},onDragSubstituteBy(){return nt},onRender(){this.toolsView=new ot({model:this.model}),this.showChildView("toolsRegion",this.toolsView)},templateContext(){const e=this.model.get("contents").toJSON(),t=this.model.get("selected");return{viewCid:this.cid,model:this.model.toJSON(),content:e[t]}}});x.on("before:start",(e=>{e.registerBlockType("woocommerceHeading",{blockModel:tt,blockView:rt})}));var it=o(26869),st=o.n(it);const at={},lt=oe;at.BlockModel=lt.BlockModel.extend({}),at.BlockView=lt.BlockView.extend({className:"mailpoet_block mailpoet_fallback_block mailpoet_droppable_block",getTemplate:function(){return window.templates.unknownBlockFallbackBlock},onRender:function(){this.toolsView=new at.BlockToolsView({model:this.model,tools:{settings:!1,duplicate:!1}}),st()((()=>{this.showChildView("toolsRegion",this.toolsView)}))},templateContext(){return{blockType:this.model.get("type")}}}),at.WidgetView=lt.WidgetView.extend({id:"automation_editor_block_fallback",getTemplate:function(){return window.templates.unknownBlockFallbackInsertion},behaviors:{DraggableBehavior:{cloneOriginal:!0,drop:function(){return new at.BlockModel}}}}),at.BlockToolsView=lt.BlockToolsView.extend({}),x.on("before:start",(function(e){e.registerBlockType("unknownBlockFallback",{blockModel:at.BlockModel,blockView:at.BlockView})}));var ct=o(14526),dt=o(36340),ut=o(85606),ht=o(86558),mt=o(18925),pt=o(10311),gt=o(79951),ft=o(19382),vt=o(61888);class bt extends O.Component{availableDiscountTypes;getValueCallback;setValueCallback;loadCouponsDebounced=(0,vt.debounce)((()=>{this.loadCoupons()}),300);constructor(e){super(e),this.getValueCallback=e.getValueCallback,this.setValueCallback=e.setValueCallback,this.availableDiscountTypes=[{label:(0,i.__)("All types","mailpoet"),value:""}].concat(e.availableDiscountTypes),this.state={couponSearch:"",couponFilterDiscountType:"",couponId:this.getValueCallback("couponId"),availableCoupons:[],loadingInitial:!1,loadingMore:!1,pageNumber:1,moreCouponsAvailable:!0}}componentDidMount(){this.loadCoupons()}handleSearchInputChange=e=>{this.setState({couponSearch:e},(()=>this.loadCouponsDebounced()))};fetchCoupons(e){const t=e?"loadingInitial":"loadingMore";r.MailPoet.Ajax.post({api_version:r.MailPoet.apiVersion,endpoint:"coupons",action:"getCoupons",data:{page_size:1e3,page_number:this.state.pageNumber,discount_type:this.state.couponFilterDiscountType,search:this.state.couponSearch,include_coupon_ids:[this.state.couponId]}}).then((o=>{const n=o.data||[];let r=[];if(e)r=n;else{const{availableCoupons:e}=this.state;r=(0,vt.uniqBy)([...e,...n],"id")}this.setState((e=>({...e,availableCoupons:r,moreCouponsAvailable:n.length>0,[t]:!1})))})).catch((()=>{r.MailPoet.Notice.error((0,i.__)("Loading coupons was not successful","mailpoet"),{scroll:!0}),this.setState((e=>({...e,[t]:!1})))}))}loadCoupons(){this.setState({pageNumber:1,loadingInitial:!0},(()=>this.fetchCoupons(!0)))}loadMoreCoupons(){const{pageNumber:e}=this.state,t=e+1;this.setState({pageNumber:t,loadingMore:!0},(()=>this.fetchCoupons(!1)))}render(){const{loadingInitial:e,loadingMore:t,moreCouponsAvailable:o,availableCoupons:n}=this.state;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(dt.Z,{children:(0,h.jsxs)(ut.Z,{children:[(0,h.jsx)(ht.Z,{children:(0,h.jsx)(mt.Z,{value:this.state.couponSearch,onChange:this.handleSearchInputChange})}),(0,h.jsx)(ht.Z,{children:(0,h.jsx)(pt.Z,{label:(0,i.__)("Discount type","mailpoet"),onChange:e=>{this.setState({couponFilterDiscountType:e},(()=>this.loadCoupons()))},options:this.availableDiscountTypes,value:this.state.couponFilterDiscountType})})]})}),(0,h.jsx)(dt.Z,{children:(0,h.jsx)(ut.Z,{className:"mailpoet-coupon-block-existing-coupons",children:(0,h.jsxs)(ht.Z,{children:[e?(0,h.jsx)("div",{className:"mailpoet_coupon_block_coupon",children:(0,h.jsx)(gt.ZP,{})}):null,!e&&n.length>0?n.map((e=>{const t=this.availableDiscountTypes.find((t=>t.value===e.discountType));return(0,h.jsxs)("div",{className:"mailpoet_coupon_block_coupon",children:[(0,h.jsx)("input",{id:`coupon-${e.id}`,className:"components-radio-control__input",name:"coupon",type:"radio",value:e.id,checked:e.id===this.state.couponId,onChange:t=>{const o=Number(t.target.value);this.setState({couponId:o}),this.setValueCallback("couponId",o),this.setValueCallback("code",e.text)}}),(0,h.jsx)("label",{htmlFor:`coupon-${e.id}`,children:e.text}),(0,h.jsx)("div",{className:"discount_type",children:t.label}),e.excerpt?(0,h.jsx)("div",{children:e.excerpt}):null]},`coupon-${e.id}`)})):null,e||0!==n.length?null:(0,h.jsx)("div",{className:"mailpoet_coupon_block_coupon",children:(0,i.__)("No coupons found","mailpoet")}),!t&&o?(0,h.jsx)(ft.ZP,{variant:"secondary",onClick:()=>this.loadMoreCoupons(),children:(0,i.__)("Load more","mailpoet")}):null,t?(0,h.jsx)(gt.ZP,{}):null]})})})]})}}var yt=o(74356),wt=o(44714);class _t extends O.Component{availableDiscountTypes;getValueCallback;setValueCallback;constructor(e){super(e),this.availableDiscountTypes=e.availableDiscountTypes,this.getValueCallback=e.getValueCallback,this.setValueCallback=e.setValueCallback,this.state={amount:this.getValueCallback("amount"),amountMax:this.getValueCallback("amountMax"),discountType:this.getValueCallback("discountType"),expiryDay:this.getValueCallback("expiryDay"),freeShipping:this.getValueCallback("freeShipping")},this.discountTypeChange=this.discountTypeChange.bind(this)}discountTypeChange=e=>{const t=w()(".mailpoet_field_coupon_amount input");t.parsley().destroy();let o="";o=e.includes("percent")?"100":"1000000",t.prop("max",o),t.parsley().validate(),this.setState({amountMax:o,discountType:e}),this.setValueCallback("amountMax",o),this.setValueCallback("discountType",e)};render(){return(0,h.jsx)(dt.Z,{children:(0,h.jsxs)(ut.Z,{title:(0,i.__)("General settings","mailpoet"),children:[(0,h.jsx)(ht.Z,{children:(0,h.jsx)(pt.Z,{label:(0,i.__)("Discount type","mailpoet"),onChange:this.discountTypeChange,options:this.availableDiscountTypes,value:this.state.discountType})}),(0,h.jsx)(ht.Z,{children:(0,h.jsx)(yt.Z,{className:"mailpoet_field_coupon_amount",label:(0,i.__)("Coupon amount","mailpoet"),onChange:e=>{this.setState({amount:e}),w()(".mailpoet_field_coupon_amount input").parsley().isValid()&&this.setValueCallback("amount",e)},type:"number",min:"0",max:this.state.amountMax,value:this.state.amount,"data-parsley-validate":!0,"data-parsley-required":!0,"data-parsley-validation-threshold":"0","data-parsley-trigger":"input"})}),(0,h.jsx)(ht.Z,{children:(0,h.jsx)(yt.Z,{className:"mailpoet_field_coupon_expiry_day",label:(0,i.__)("Expires in","mailpoet"),onChange:e=>{this.setState({expiryDay:e}),w()(".mailpoet_field_coupon_expiry_day input").parsley().isValid()&&this.setValueCallback("expiryDay",e)},min:"0",type:"number",value:this.state.expiryDay,"data-parsley-required":!0,"data-parsley-validation-threshold":"0","data-parsley-trigger":"input"})}),(0,h.jsx)(ht.Z,{children:(0,h.jsx)(wt.Z,{checked:this.state.freeShipping,label:(0,i.__)("Free shipping","mailpoet"),onChange:e=>{this.setValueCallback("freeShipping",e),this.setState({freeShipping:e})}})})]})})}}var xt=o(26372),Ct=o.n(xt);let kt=function(e){return e.allCoupons="allCoupons",e.createNew="createNew",e}({});function St(e){let{activeTab:t,onClick:o}=e;return(0,h.jsx)("div",{className:"components-panel__header interface-complementary-area-header edit-post-sidebar__panel-tabs",children:(0,h.jsxs)("ul",{children:[(0,h.jsx)("li",{children:(0,h.jsx)(ft.ZP,{onClick:()=>o(kt.allCoupons),className:Ct()("edit-post-sidebar__panel-tab",{"is-active":t===kt.allCoupons}),"data-label":(0,i.__)("All coupons","mailpoet"),children:(0,i.__)("All coupons","mailpoet")})}),(0,h.jsx)("li",{children:(0,h.jsx)(ft.ZP,{onClick:()=>o(kt.createNew),className:Ct()("edit-post-sidebar__panel-tab",{"is-active":t===kt.createNew}),"data-label":(0,i.__)("Create new","mailpoet"),children:(0,i.__)("Create new","mailpoet")})})]})})}var Tt=o(79830);class Et extends O.Component{getValueCallback;setValueCallback;priceDecimalSeparator;constructor(e){super(e),this.getValueCallback=e.getValueCallback,this.setValueCallback=e.setValueCallback,this.priceDecimalSeparator=e.priceDecimalSeparator,this.state={minimumAmount:this.getValueCallback("minimumAmount"),maximumAmount:this.getValueCallback("maximumAmount"),individualUse:this.getValueCallback("individualUse"),excludeSaleItems:this.getValueCallback("excludeSaleItems"),productIds:this.getValueCallback("productIds").toJSON(),excludedProductIds:this.getValueCallback("excludedProductIds").toJSON(),productCategoryIds:this.getValueCallback("productCategoryIds").toJSON(),excludedProductCategoryIds:this.getValueCallback("excludedProductCategoryIds").toJSON(),emailRestrictions:this.getValueCallback("emailRestrictions")}}handleSelection=e=>{const t=this.getValueCallback(e.target.name);t.reset(e.target.value.map((e=>({id:e})))),this.setValueCallback(e.target.name,t);const o={};o[e.target.name]=e.target.value,this.setState(o)};render(){const e={forceSelect2:!0,endpoint:"products",resetSelect2OnUpdate:!0,multiple:!0,placeholder:(0,i.__)("Search for a product…","mailpoet")},t={forceSelect2:!0,endpoint:"product_categories",resetSelect2OnUpdate:!0,multiple:!0};return(0,h.jsx)(dt.Z,{children:(0,h.jsxs)(ut.Z,{title:(0,i.__)("Usage restriction","mailpoet"),className:"mailpoet-coupon-block-usage-restriction",initialOpen:!1,children:[(0,h.jsx)(ht.Z,{children:(0,h.jsx)(yt.Z,{className:"mailpoet_field_coupon_minimum_amount",label:(0,i.__)("Minimum spend","mailpoet"),value:this.state.minimumAmount,placeholder:(0,i.__)("No minimum","mailpoet"),onChange:e=>{this.setState({minimumAmount:e}),w()(".mailpoet_field_coupon_minimum_amount input").parsley().isValid()&&this.setValueCallback("minimumAmount",e)},pattern:`[0-9]+([${this.priceDecimalSeparator}][0-9]+)?`,"data-parsley-validate":!0,"data-parsley-trigger":"input","data-parsley-validation-threshold":"1","data-parsley-error-message":(0,i.__)("Please enter a value with one monetary decimal point (%s) without thousand separators and currency symbols.","mailpoet").replace("%s",this.priceDecimalSeparator)})}),(0,h.jsx)(ht.Z,{children:(0,h.jsx)(yt.Z,{className:"mailpoet_field_coupon_maximum_amount",label:(0,i.__)("Maximum spend","mailpoet"),value:this.state.maximumAmount,placeholder:(0,i.__)("No maximum","mailpoet"),onChange:e=>{this.setState({maximumAmount:e}),w()(".mailpoet_field_coupon_maximum_amount input").parsley().isValid()&&this.setValueCallback("maximumAmount",e)},pattern:`[0-9]+([${this.priceDecimalSeparator}][0-9]+)?`,"data-parsley-validate":!0,"data-parsley-trigger":"input","data-parsley-validation-threshold":"1","data-parsley-error-message":(0,i.__)("Please enter a value with one monetary decimal point (%s) without thousand separators and currency symbols.","mailpoet").replace("%s",this.priceDecimalSeparator)})}),(0,h.jsx)(ht.Z,{children:(0,h.jsx)(wt.Z,{checked:this.state.individualUse,label:(0,i.__)("Individual use only","mailpoet"),onChange:e=>{this.setValueCallback("individualUse",e),this.setState({individualUse:e})},help:(0,i.__)("Coupon cannot be used in conjunction with other coupons.","mailpoet")})}),(0,h.jsx)(ht.Z,{children:(0,h.jsx)(wt.Z,{checked:this.state.excludeSaleItems,label:(0,i.__)("Exclude sale items","mailpoet"),onChange:e=>{this.setValueCallback("excludeSaleItems",e),this.setState({excludeSaleItems:e})},help:(0,i.__)("Coupon does not apply to items on sale.","mailpoet")})}),(0,h.jsxs)(ht.Z,{children:[(0,h.jsx)("label",{htmlFor:"productIds",children:(0,i.__)("Products","mailpoet")}),(0,h.jsx)(Tt.Y,{field:{...e,name:"productIds",selected:()=>this.state.productIds.map((e=>e.id))},onValueChange:this.handleSelection})]}),(0,h.jsxs)(ht.Z,{children:[(0,h.jsx)("label",{htmlFor:"excludedProductIds",children:(0,i.__)("Excluded products","mailpoet")}),(0,h.jsx)(Tt.Y,{field:{...e,name:"excludedProductIds",selected:()=>this.state.excludedProductIds.map((e=>e.id))},onValueChange:this.handleSelection})]}),(0,h.jsxs)(ht.Z,{children:[(0,h.jsx)("label",{htmlFor:"productCategoriesIds",children:(0,i.__)("Product categories","mailpoet")}),(0,h.jsx)(Tt.Y,{field:{...t,name:"productCategoryIds",placeholder:(0,i.__)("Any category","mailpoet"),selected:()=>this.state.productCategoryIds.map((e=>e.id))},onValueChange:this.handleSelection})]}),(0,h.jsxs)(ht.Z,{children:[(0,h.jsx)("label",{htmlFor:"excludedProductCategoryIds",children:(0,i.__)("Exclude product categories","mailpoet")}),(0,h.jsx)(Tt.Y,{field:{...t,name:"excludedProductCategoryIds",placeholder:(0,i.__)("No categories","mailpoet"),selected:()=>this.state.excludedProductCategoryIds.map((e=>e.id))},onValueChange:this.handleSelection})]}),(0,h.jsx)(ht.Z,{children:(0,h.jsx)(yt.Z,{className:"mailpoet_field_coupon_email_restrictions",label:(0,i.__)("Allowed emails","mailpoet"),value:this.state.emailRestrictions,placeholder:(0,i.__)("No restrictions","mailpoet"),onChange:e=>{this.setState({emailRestrictions:e}),w()(".mailpoet_field_coupon_email_restrictions input").parsley().isValid()&&this.setValueCallback("emailRestrictions",e)},type:"text",pattern:"/^([\\w\\d._\\-#\\*])+@([\\w\\d._\\-#\\*]+[.][\\w\\d._\\-#\\*]+)+(,([\\w\\d._\\-#\\*])+@([\\w\\d._\\-#\\*]+[.][\\w\\d._\\-#\\*]+))*$/","data-parsley-validate":!0,"data-parsley-validation-threshold":"1","data-parsley-trigger":"input","data-parsley-error-message":(0,i.__)('Separate email addresses with commas. You can also use an asterisk (*) to match parts of an email. For example "*@gmail.com" would match all gmail addresses.',"mailpoet")})})]})})}}class Ot extends O.Component{getValueCallback;setValueCallback;constructor(e){super(e),this.getValueCallback=e.getValueCallback,this.setValueCallback=e.setValueCallback,this.state={usageLimit:this.getValueCallback("usageLimit"),usageLimitPerUser:this.getValueCallback("usageLimitPerUser")}}render(){return(0,h.jsx)(dt.Z,{children:(0,h.jsxs)(ut.Z,{title:(0,i.__)("Usage limits","mailpoet"),className:"mailpoet-coupon-block-usage-limits",initialOpen:!1,children:[(0,h.jsx)(ht.Z,{children:(0,h.jsx)(yt.Z,{label:(0,i.__)("Usage limit per coupon","mailpoet"),value:this.state.usageLimit,placeholder:(0,i.__)("Unlimited usage","mailpoet"),type:"number",onChange:e=>{this.setValueCallback("usageLimit",e),this.setState({usageLimit:e})}})}),(0,h.jsx)(ht.Z,{children:(0,h.jsx)(yt.Z,{label:(0,i.__)("Usage limit per user","mailpoet"),value:this.state.usageLimitPerUser,placeholder:(0,i.__)("Unlimited usage","mailpoet"),type:"number",onChange:e=>{this.setValueCallback("usageLimitPerUser",e),this.setState({usageLimitPerUser:e})}})})]})})}}function Mt(e){let{availableDiscountTypes:t,getValueCallback:o,setValueCallback:n,priceDecimalSeparator:r,codePlaceholder:i}=e;const[s,a]=(0,O.useState)(o("source"));return(0,h.jsx)(d.ErrorBoundary,{children:(0,h.jsxs)(ct.k.Provider,{value:(0,ct.S)(window),children:[(0,h.jsx)(St,{activeTab:s,onClick:e=>{n("source",e),a(e),e===kt.createNew?(n("code",i),n("couponId",""),jQuery(".mailpoet_editor_coupon_overlay").css("visibility","visible")):e===kt.allCoupons&&jQuery(".mailpoet_editor_coupon_overlay").css("visibility","hidden")}}),s===kt.createNew?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(_t,{availableDiscountTypes:t,getValueCallback:o,setValueCallback:n}),(0,h.jsx)(Et,{getValueCallback:o,setValueCallback:n,priceDecimalSeparator:r}),(0,h.jsx)(Ot,{getValueCallback:o,setValueCallback:n})]}):(0,h.jsx)(bt,{availableDiscountTypes:t,getValueCallback:o,setValueCallback:n})]})})}const At={},Bt=oe;At.CouponBlockModel=Bt.BlockModel.extend({defaults(){return this._getDefaults({isStandardEmail:x.getNewsletter().isStandardEmail(),productIds:[],excludedProductIds:[],productCategoryIds:[],excludedProductCategoryIds:[],type:"coupon",amount:10,amountMax:100,discountType:"percent",expiryDay:10,usageLimit:"",usageLimitPerUser:"",minimumAmount:"",maximumAmount:"",emailRestrictions:"",styles:{block:{backgroundColor:"#ffffff",borderColor:"#000000",borderRadius:"5px",borderStyle:"solid",borderWidth:"1px",fontColor:"#000000",fontFamily:"Verdan",fontSize:"18px",fontWeight:"normal",lineHeight:"40px",textAlign:"center",width:"200px"}},source:"createNew",code:x.getConfig().get("coupon.code_placeholder")},x.getConfig().get("blockDefaults.coupon"))}}),At.CouponBlockView=Bt.BlockView.extend({className:"mailpoet_block mailpoet_coupon_block mailpoet_droppable_block",getTemplate:()=>window.templates.couponBlock,onDragSubstituteBy:()=>At.CouponWidgetView,behaviors:c.default.extend({},Bt.BlockView.prototype.behaviors,{ShowSettingsBehavior:{}}),initialize(){for(var e=arguments.length,t=new Array(e),o=0;o{this.model.set(e)},x.getChannel().on("replaceAllCouponStyles",this.replaceCouponStylesHandler)},onRender(){this.toolsView=new At.CouponBlockToolsView({model:this.model}),this.showChildView("toolsRegion",this.toolsView)}}),At.CouponBlockToolsView=Bt.BlockToolsView.extend({getSettingsView:()=>At.CouponBlockSettingsView}),At.CouponBlockSettingsView=Bt.BlockSettingsView.extend({getTemplate:()=>window.templates.couponBlockSettings,events(){return{"change .mailpoet_field_coupon_alignment":c.default.partial(this.changeField,"styles.block.textAlign"),"change .mailpoet_field_coupon_font_color":c.default.partial(this.changeColorField,"styles.block.fontColor"),"change .mailpoet_field_coupon_font_family":c.default.partial(this.changeField,"styles.block.fontFamily"),"change .mailpoet_field_coupon_font_size":c.default.partial(this.changeField,"styles.block.fontSize"),"change .mailpoet_field_coupon_background_color":c.default.partial(this.changeColorField,"styles.block.backgroundColor"),"change .mailpoet_field_coupon_border_color":c.default.partial(this.changeColorField,"styles.block.borderColor"),"change .mailpoet_field_coupon_font_weight":"changeFontWeight","input .mailpoet_field_coupon_border_width":c.default.partial(this.updateValueAndCall,".mailpoet_field_coupon_border_width_input",c.default.partial(this.changePixelField,"styles.block.borderWidth").bind(this)),"change .mailpoet_field_coupon_border_width":c.default.partial(this.updateValueAndCall,".mailpoet_field_coupon_border_width_input",c.default.partial(this.changePixelField,"styles.block.borderWidth").bind(this)),"input .mailpoet_field_coupon_border_width_input":c.default.partial(this.updateValueAndCall,".mailpoet_field_coupon_border_width",c.default.partial(this.changePixelField,"styles.block.borderWidth").bind(this)),"input .mailpoet_field_coupon_border_radius":c.default.partial(this.updateValueAndCall,".mailpoet_field_coupon_border_radius_input",c.default.partial(this.changePixelField,"styles.block.borderRadius").bind(this)),"change .mailpoet_field_coupon_border_radius":c.default.partial(this.updateValueAndCall,".mailpoet_field_coupon_border_radius_input",c.default.partial(this.changePixelField,"styles.block.borderRadius").bind(this)),"input .mailpoet_field_coupon_border_radius_input":c.default.partial(this.updateValueAndCall,".mailpoet_field_coupon_border_radius",c.default.partial(this.changePixelField,"styles.block.borderRadius").bind(this)),"input .mailpoet_field_coupon_width":c.default.partial(this.updateValueAndCall,".mailpoet_field_coupon_width_input",c.default.partial(this.changePixelField,"styles.block.width").bind(this)),"change .mailpoet_field_coupon_width":c.default.partial(this.updateValueAndCall,".mailpoet_field_coupon_width_input",c.default.partial(this.changePixelField,"styles.block.width").bind(this)),"input .mailpoet_field_coupon_width_input":c.default.partial(this.updateValueAndCall,".mailpoet_field_coupon_width",c.default.partial(this.changePixelField,"styles.block.width").bind(this)),"input .mailpoet_field_coupon_line_height":c.default.partial(this.updateValueAndCall,".mailpoet_field_coupon_line_height_input",c.default.partial(this.changePixelField,"styles.block.lineHeight").bind(this)),"change .mailpoet_field_coupon_line_height":c.default.partial(this.updateValueAndCall,".mailpoet_field_coupon_line_height_input",c.default.partial(this.changePixelField,"styles.block.lineHeight").bind(this)),"input .mailpoet_field_coupon_line_height_input":c.default.partial(this.updateValueAndCall,".mailpoet_field_coupon_line_height",c.default.partial(this.changePixelField,"styles.block.lineHeight").bind(this)),"click .mailpoet_field_coupon_replace_all_styles":"applyToAll","click .mailpoet_done_editing":"close","click .mailpoet_settings_coupon_show_coupon_configuration":"switchToCouponConfiguration","click .mailpoet_settings_coupon_show_display_options":"switchToDisplayOptions"}},templateContext(){for(var e=arguments.length,t=new Array(e),o=0;othis.model.set(e,t),getValueCallback:e=>this.model.get(e)}))}}),At.CouponWidgetView=Bt.WidgetView.extend({id:"automation_editor_block_coupon",getTemplate:()=>window.templates.couponInsertion,behaviors:{DraggableBehavior:{cloneOriginal:!0,drop:()=>new At.CouponBlockModel}}}),x.on("before:start",(e=>{window.MailPoet.isWoocommerceActive&&(e.registerBlockType("coupon",{blockModel:At.CouponBlockModel,blockView:At.CouponBlockView}),e.registerWidget({name:"coupon",widgetView:At.CouponWidgetView,priority:92}))})),(0,d.registerTranslations)(),window.Backbone&&window.Backbone.noConflict()},82656:function(e,t,o){e.exports=function(e,t,o){"use strict";e="default"in e?e.default:e,t="default"in t?t.default:t,o="default"in o?o.default:o;var n="3.2.0",r=function(e){return function(t){for(var o=arguments.length,n=Array(o>1?o-1:0),r=1;r1?o-1:0),r=1;r1?o-1:0),r=1;r0)for(e=0;e1?n-1:0),i=1;i1&&void 0!==arguments[1]?arguments[1]:{},n=!e._isAttached&&a(this.el),r=void 0===o.replaceElement?!!t.result(this,"replaceElement"):!!o.replaceElement;n&&g(e,"before:attach",e),r?this._replaceEl(e):this.attachHtml(e),n&&(e._isAttached=!0,g(e,"attach",e))},_ensureElement:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(t.isObject(this.el)||(this.$el=this.getEl(this.el),this.el=this.$el[0]),!this.$el||0===this.$el.length){if(void 0===e.allowMissingEl?t.result(this,"allowMissingEl"):e.allowMissingEl)return!1;throw new M('An "el" must exist in DOM for this region '+this.cid)}return!0},_getView:function(t){if(!t)throw new M({name:"ViewNotValid",message:"The view passed is undefined and therefore invalid. You must pass a view instance to show."});if(t._isDestroyed)throw new M({name:"ViewDestroyedError",message:'View (cid: "'+t.cid+'") has already been destroyed and cannot be used.'});if(t instanceof e.View)return t;var o=this._getViewOptions(t);return new de(o)},_getViewOptions:function(e){return t.isFunction(e)?{template:e}:t.isObject(e)?e:{template:function(){return e}}},getEl:function(e){return this.findEls(e,t.result(this,"parentEl"))},_replaceEl:function(e){this._restoreEl(),e.on("before:destroy",this._restoreEl,this),this.replaceEl(e.el,this.el),this._isReplaced=!0},_restoreEl:function(){if(this._isReplaced){var e=this.currentView;e&&(this.replaceEl(this.el,e.el),this._isReplaced=!1)}},isReplaced:function(){return!!this._isReplaced},attachHtml:function(e){this.appendChildren(this.el,e.el)},empty:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{allowMissingEl:!0},t=this.currentView;if(!t)return this._ensureElement(e)&&this.detachHtml(),this;var o=!e.preventDestroy;return o||s("The preventDestroy option is deprecated. Use Region#detachView"),this._empty(t,o),this},_empty:function(e,t){e.off("destroy",this._empty,this),this.triggerMethod("before:empty",this,e),this._restoreEl(),delete this.currentView,e._isDestroyed||(this._removeView(e,t),this._stopChildViewEvents(e)),this.triggerMethod("empty",this,e)},_stopChildViewEvents:function(e){this._parentView&&this._parentView.stopListening(e)},_removeView:function(e,t){t?e.destroy?e.destroy():oe(e):this._detachView(e)},detachView:function(){var e=this.currentView;if(e)return this._empty(e),e},_detachView:function(e){var t=!!e._isAttached;t&&g(e,"before:detach",e),this.detachHtml(),t&&(e._isAttached=!1,g(e,"detach",e))},detachHtml:function(){this.detachContents(this.el)},hasView:function(){return!!this.currentView},reset:function(e){return this.empty(e),this.$el&&(this.el=this._initEl),delete this.$el,this},destroy:function(e){return this.reset(e),L.prototype.destroy.apply(this,arguments)}});t.extend(re.prototype,z);var ie=function(e,o){return e instanceof re?e:function(e,o){var n=t.extend({},o);if(t.isString(e))return t.extend(n,{el:e}),se(n);if(t.isFunction(e))return t.extend(n,{regionClass:e}),se(n);if(t.isObject(e))return e.selector&&s("The selector option on a Region definition object is deprecated. Use el to pass a selector string"),t.extend(n,{el:e.selector},e),se(n);throw new M({message:"Improper region configuration type.",url:"marionette.region.html#region-configuration-types"})}(e,o)};function se(e){return new(0,e.regionClass)(t.omit(e,"regionClass"))}var ae={regionClass:re,_initRegions:function(){this.regions=this.regions||{},this._regions={},this.addRegions(t.result(this,"regions"))},_reInitRegions:function(){Z(this._regions,"reset")},addRegion:function(e,t){var o={};return o[e]=t,this.addRegions(o)[e]},addRegions:function(e){if(!t.isEmpty(e))return e=this.normalizeUIValues(e,["selector","el"]),this.regions=t.extend({},this.regions,e),this._addRegions(e)},_addRegions:function(e){var o=this,n={regionClass:this.regionClass,parentEl:t.partial(t.result,this,"el")};return t.reduce(e,(function(e,t,r){return e[r]=ie(t,n),o._addRegion(e[r],r),e}),{})},_addRegion:function(e,t){this.triggerMethod("before:add:region",this,t,e),e._parentView=this,this._regions[t]=e,this.triggerMethod("add:region",this,t,e)},removeRegion:function(e){var t=this._regions[e];return this._removeRegion(t,e),t},removeRegions:function(){var e=this.getRegions();return t.each(this._regions,t.bind(this._removeRegion,this)),e},_removeRegion:function(e,t){this.triggerMethod("before:remove:region",this,t,e),e.destroy(),delete this.regions[t],delete this._regions[t],this.triggerMethod("remove:region",this,t,e)},emptyRegions:function(){var e=this.getRegions();return Z(e,"empty"),e},hasRegion:function(e){return!!this.getRegion(e)},getRegion:function(e){return this._regions[e]},getRegions:function(){return t.clone(this._regions)},showChildView:function(e,t){for(var o=this.getRegion(e),n=arguments.length,r=Array(n>2?n-2:0),i=2;i0&&void 0!==arguments[0]?arguments[0]:{},o=t.result(this,"templateContext");return t.extend(e,o)},attachElContent:function(e){return this.setInnerContent(this.el,e),this},_removeChildren:function(){this.removeRegions()},_getImmediateChildren:function(){return t.chain(this.getRegions()).map("currentView").compact().value()}});t.extend(de.prototype,te,ae);var ue,he,me=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck","reduce"],pe=function(e){this._views={},this._indexByModel={},this._indexByCustom={},this._updateLength(),t.each(e,t.bind(this.add,this))};ue=pe.prototype,he="_views",t.each(me,(function(e){ue[e]=function(){var o=[t.values(t.result(this,he))].concat(t.toArray(arguments));return t[e].apply(t,o)}})),t.extend(pe.prototype,{add:function(e,t){return this._add(e,t)._updateLength()},_add:function(e,t){var o=e.cid;return this._views[o]=e,e.model&&(this._indexByModel[e.model.cid]=o),t&&(this._indexByCustom[t]=o),this},findByModel:function(e){return this.findByModelCid(e.cid)},findByModelCid:function(e){var t=this._indexByModel[e];return this.findByCid(t)},findByCustom:function(e){var t=this._indexByCustom[e];return this.findByCid(t)},findByIndex:function(e){return t.values(this._views)[e]},findByCid:function(e){return this._views[e]},remove:function(e){return this._remove(e)._updateLength()},_remove:function(e){var o=e.cid;return e.model&&delete this._indexByModel[e.model.cid],t.some(this._indexByCustom,t.bind((function(e,t){if(e===o)return delete this._indexByCustom[t],!0}),this)),delete this._views[o],this},_updateLength:function(){return this.length=t.size(this._views),this}});var ge=["behaviors","childView","childViewEventPrefix","childViewEvents","childViewOptions","childViewTriggers","collectionEvents","events","filter","emptyView","emptyViewOptions","modelEvents","reorderOnSort","sort","triggers","ui","viewComparator"],fe=e.View.extend({sort:!0,constructor:function(o){this.render=t.bind(this.render,this),this._setOptions(o),this.mergeOptions(o,ge),E(this),this._initBehaviors(),this.once("render",this._initialEvents),this._initChildViewStorage(),this._bufferedChildren=[];var n=Array.prototype.slice.call(arguments);n[0]=this.options,e.View.prototype.constructor.apply(this,n),this.delegateEntityEvents()},_startBuffering:function(){this._isBuffering=!0},_endBuffering:function(){var e=this._isAttached?this._getImmediateChildren():[];this._isBuffering=!1,t.each(e,(function(e){g(e,"before:attach",e)})),this.attachBuffer(this,this._createBuffer()),t.each(e,(function(e){e._isAttached=!0,g(e,"attach",e)})),this._bufferedChildren=[]},_getImmediateChildren:function(){return t.values(this.children._views)},_initialEvents:function(){this.collection&&(this.listenTo(this.collection,"add",this._onCollectionAdd),this.listenTo(this.collection,"update",this._onCollectionUpdate),this.listenTo(this.collection,"reset",this.render),this.sort&&this.listenTo(this.collection,"sort",this._sortViews))},_onCollectionAdd:function(e,o,n){var r=void 0!==n.at&&(n.index||o.indexOf(e));(this.filter||!1===r)&&(r=t.indexOf(this._filteredSortedModels(r),e)),this._shouldAddChild(e,r)&&(this._destroyEmptyView(),this._addChild(e,r))},_onCollectionUpdate:function(e,t){var o=t.changes;this._removeChildModels(o.removed)},_removeChildModels:function(e){var t=this._getRemovedViews(e);t.length&&(this.children._updateLength(),this._updateIndices(t,!1),this.isEmpty()&&this._showEmptyView())},_getRemovedViews:function(e){var o=this;return t.reduce(e,(function(e,t){var n=t&&o.children.findByModel(t);return!n||n._isDestroyed||(o._removeChildView(n),e.push(n)),e}),[])},_removeChildView:function(e){this.triggerMethod("before:remove:child",this,e),this.children._remove(e),e.destroy?e.destroy():oe(e),this.stopListening(e),this.triggerMethod("remove:child",this,e)},setElement:function(){var t=!!this.el;return e.View.prototype.setElement.apply(this,arguments),t&&(this._isAttached=a(this.el)),this},render:function(){return this._isDestroyed||(this.triggerMethod("before:render",this),this._renderChildren(),this._isRendered=!0,this.triggerMethod("render",this)),this},setFilter:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).preventRender,o=this._isRendered&&!this._isDestroyed,n=this.filter!==e;if(o&&n&&!t){var r=this._filteredSortedModels();this.filter=e;var i=this._filteredSortedModels();this._applyModelDeltas(i,r)}else this.filter=e;return this},removeFilter:function(e){return this.setFilter(null,e)},_applyModelDeltas:function(e,o){var n=this,r={};t.each(e,(function(e,t){!n.children.findByModel(e)&&n._onCollectionAdd(e,n.collection,{at:t}),r[e.cid]=!0}));var i=t.filter(o,(function(e){return!r[e.cid]&&n.children.findByModel(e)}));this._removeChildModels(i)},reorder:function(){var e,o,n=this,r=this.children,i=this._filteredSortedModels();return!i.length&&this._showingEmptyView||(t.some(i,(function(e){return!r.findByModel(e)}))?this.render():(e=[],o=r.reduce((function(o,n){var r=t.indexOf(i,n.model);return-1===r?(e.push(n.model),o):(n._index=r,o[r]=n.el,o)}),new Array(i.length)),n.triggerMethod("before:reorder",n),n._appendReorderedChildren(o),n._removeChildModels(e),n.triggerMethod("reorder",n))),this},resortView:function(){return this.reorderOnSort?this.reorder():this._renderChildren(),this},_sortViews:function(){var e=this,o=this._filteredSortedModels();t.find(o,(function(t,o){var n=e.children.findByModel(t);return!n||n._index!==o}))&&this.resortView()},_emptyViewIndex:-1,_appendReorderedChildren:function(e){this.appendChildren(this.el,e)},_renderChildren:function(){this._isRendered&&(this._destroyEmptyView(),this._destroyChildren());var e=this._filteredSortedModels();this.isEmpty({processedModels:e})?this._showEmptyView():(this.triggerMethod("before:render:children",this),this._startBuffering(),this._showCollection(e),this._endBuffering(),this.triggerMethod("render:children",this))},_createView:function(e,t){var o=this._getChildView(e),n=this._getChildViewOptions(e,t);return this.buildChildView(e,o,n)},_setupChildView:function(e,t){E(e),this._proxyChildViewEvents(e),this.sort&&(e._index=t)},_showCollection:function(e){t.each(e,t.bind(this._addChild,this)),this.children._updateLength()},_filteredSortedModels:function(e){if(!this.collection||!this.collection.length)return[];var t=this.getViewComparator(),o=this.collection.models;if(e=Math.min(Math.max(e,0),o.length-1),t){var n=void 0;e&&(n=o[e],o=o.slice(0,e).concat(o.slice(e+1))),o=this._sortModelsBy(o,t),n&&o.splice(e,0,n)}return this._filterModels(o)},getViewComparator:function(){return this.viewComparator},_filterModels:function(e){var o=this;return this.filter&&(e=t.filter(e,(function(e,t){return o._shouldAddChild(e,t)}))),e},_sortModelsBy:function(e,o){return"string"==typeof o?t.sortBy(e,(function(e){return e.get(o)})):1===o.length?t.sortBy(e,t.bind(o,this)):t.clone(e).sort(t.bind(o,this))},_showEmptyView:function(){var o=this._getEmptyView();if(o&&!this._showingEmptyView){this._showingEmptyView=!0;var n=new e.Model,r=this.emptyViewOptions||this.childViewOptions;t.isFunction(r)&&(r=r.call(this,n,this._emptyViewIndex));var i=this.buildChildView(n,o,r);this.triggerMethod("before:render:empty",this,i),this.addChildView(i,0),this.triggerMethod("render:empty",this,i)}},_destroyEmptyView:function(){this._showingEmptyView&&(this.triggerMethod("before:remove:empty",this),this._destroyChildren(),delete this._showingEmptyView,this.triggerMethod("remove:empty",this))},_getEmptyView:function(){var e=this.emptyView;if(e)return this._getView(e)},_getChildView:function(e){var t=this.childView;if(!t)throw new M({name:"NoChildViewError",message:'A "childView" must be specified'});if(!(t=this._getView(t,e)))throw new M({name:"InvalidChildViewError",message:'"childView" must be a view class or a function that returns a view class'});return t},_getView:function(o,n){return o.prototype instanceof e.View||o===e.View?o:t.isFunction(o)?o.call(this,n):void 0},_addChild:function(e,t){var o=this._createView(e,t);return this.addChildView(o,t),o},_getChildViewOptions:function(e,o){return t.isFunction(this.childViewOptions)?this.childViewOptions(e,o):this.childViewOptions},addChildView:function(e,t){return this.triggerMethod("before:add:child",this,e),this._setupChildView(e,t),this._isBuffering?this.children._add(e):(this._updateIndices(e,!0),this.children.add(e)),this._renderView(e),this._attachView(e,t),this.triggerMethod("add:child",this,e),e},_updateIndices:function(e,o){if(this.sort)if(o){var n=t.isArray(e)?t.max(e,"_index"):e;t.isObject(n)&&this.children.each((function(e){e._index>=n._index&&(e._index+=1)}))}else t.each(t.sortBy(this.children._views,"_index"),(function(e,t){e._index=t}))},_renderView:function(e){e._isRendered||(e.supportsRenderLifecycle||g(e,"before:render",e),e.render(),e.supportsRenderLifecycle||(e._isRendered=!0,g(e,"render",e)))},_attachView:function(e,t){var o=!e._isAttached&&!this._isBuffering&&this._isAttached;o&&g(e,"before:attach",e),this.attachHtml(this,e,t),o&&(e._isAttached=!0,g(e,"attach",e))},buildChildView:function(e,o,n){return new o(t.extend({model:e},n))},removeChildView:function(e){return!e||e._isDestroyed||(this._removeChildView(e),this.children._updateLength(),this._updateIndices(e,!1)),e},isEmpty:function(e){var o=void 0;return t.result(e,"processedModels")?o=e.processedModels:(o=this.collection?this.collection.models:[],o=this._filterModels(o)),0===o.length},attachBuffer:function(e,t){this.appendChildren(e.el,t)},_createBuffer:function(){var e=this,o=this.createBuffer();return t.each(this._bufferedChildren,(function(t){e.appendChildren(o,t.el)})),o},attachHtml:function(e,t,o){e._isBuffering?e._bufferedChildren.splice(o,0,t):e._insertBefore(t,o)||e._insertAfter(t)},_insertBefore:function(e,t){var o=void 0;return this.sort&&t1?o-1:0),r=1;rthis.length&&(r=this.length),r<0&&(r+=this.length+1);var i,s,a=[],l=[],c=[],d=[],u={},h=t.add,m=t.merge,p=t.remove,g=!1,f=this.comparator&&null==r&&!1!==t.sort,v=o.isString(this.comparator)?this.comparator:null;for(s=0;s7),this._useHashChange=this._wantsHashChange&&this._hasHashChange,this._wantsPushState=!!this.options.pushState,this._hasPushState=!(!this.history||!this.history.pushState),this._usePushState=this._wantsPushState&&this._hasPushState,this.fragment=this.getFragment(),this.root=("/"+this.root+"/").replace(V,"/"),this._wantsHashChange&&this._wantsPushState){if(!this._hasPushState&&!this.atRoot()){var t=this.root.slice(0,-1)||"/";return this.location.replace(t+"#"+this.getPath()),!0}this._hasPushState&&this.atRoot()&&this.navigate(this.getHash(),{replace:!0})}if(!this._hasHashChange&&this._wantsHashChange&&!this._usePushState){this.iframe=document.createElement("iframe"),this.iframe.src="javascript:0",this.iframe.style.display="none",this.iframe.tabIndex=-1;var n=document.body,r=n.insertBefore(this.iframe,n.firstChild).contentWindow;r.document.open(),r.document.close(),r.location.hash="#"+this.fragment}var i=window.addEventListener||function(e,t){return attachEvent("on"+e,t)};if(this._usePushState?i("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe?i("hashchange",this.checkUrl,!1):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,this.interval)),!this.options.silent)return this.loadUrl()},stop:function(){var e=window.removeEventListener||function(e,t){return detachEvent("on"+e,t)};this._usePushState?e("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe&&e("hashchange",this.checkUrl,!1),this.iframe&&(document.body.removeChild(this.iframe),this.iframe=null),this._checkUrlInterval&&clearInterval(this._checkUrlInterval),N.started=!1},route:function(e,t){this.handlers.unshift({route:e,callback:t})},checkUrl:function(e){var t=this.getFragment();if(t===this.fragment&&this.iframe&&(t=this.getHash(this.iframe.contentWindow)),t===this.fragment)return!1;this.iframe&&this.navigate(t),this.loadUrl()},loadUrl:function(e){return!!this.matchRoot()&&(e=this.fragment=this.getFragment(e),o.some(this.handlers,(function(t){if(t.route.test(e))return t.callback(e),!0})))},navigate:function(e,t){if(!N.started)return!1;t&&!0!==t||(t={trigger:!!t}),e=this.getFragment(e||"");var o=this.root;""!==e&&"?"!==e.charAt(0)||(o=o.slice(0,-1)||"/");var n=o+e;if(e=this.decodeFragment(e.replace(D,"")),this.fragment!==e){if(this.fragment=e,this._usePushState)this.history[t.replace?"replaceState":"pushState"]({},document.title,n);else{if(!this._wantsHashChange)return this.location.assign(n);if(this._updateHash(this.location,e,t.replace),this.iframe&&e!==this.getHash(this.iframe.contentWindow)){var r=this.iframe.contentWindow;t.replace||(r.document.open(),r.document.close()),this._updateHash(r.location,e,t.replace)}}return t.trigger?this.loadUrl(e):void 0}},_updateHash:function(e,t,o){if(o){var n=e.href.replace(/(javascript:|#).*$/,"");e.replace(n+"#"+t)}else e.hash="#"+t}}),t.history=new N;b.extend=y.extend=E.extend=C.extend=N.extend=function(e,t){var n,r=this;return n=e&&o.has(e,"constructor")?e.constructor:function(){return r.apply(this,arguments)},o.extend(n,r,t),n.prototype=o.create(r.prototype,e),n.prototype.constructor=n,n.__super__=r.prototype,n};var P=function(){throw new Error('A "url" property or function must be specified')},I=function(e,t){var o=t.error;t.error=function(n){o&&o.call(t.context,e,n,t),e.trigger("error",e,n,t)}};return t}(i,o,e,t)}.apply(t,n),void 0===r||(e.exports=r)},55091:function(e,t,o){var n,r;void 0===(r="function"==typeof(n=function(){"use strict";function t(e,t,o){var n=new XMLHttpRequest;n.open("GET",e),n.responseType="blob",n.onload=function(){a(n.response,t,o)},n.onerror=function(){console.error("could not download file")},n.send()}function n(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function r(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(o){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var i="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof o.g&&o.g.global===o.g?o.g:void 0,s=i.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),a=i.saveAs||("object"!=typeof window||window!==i?function(){}:"download"in HTMLAnchorElement.prototype&&!s?function(e,o,s){var a=i.URL||i.webkitURL,l=document.createElement("a");o=o||e.name||"download",l.download=o,l.rel="noopener","string"==typeof e?(l.href=e,l.origin===location.origin?r(l):n(l.href)?t(e,o,s):r(l,l.target="_blank")):(l.href=a.createObjectURL(e),setTimeout((function(){a.revokeObjectURL(l.href)}),4e4),setTimeout((function(){r(l)}),0))}:"msSaveOrOpenBlob"in navigator?function(e,o,i){if(o=o||e.name||"download","string"!=typeof e)navigator.msSaveOrOpenBlob(function(e,t){return void 0===t?t={autoBom:!1}:"object"!=typeof t&&(console.warn("Deprecated: Expected third argument to be a object"),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e}(e,i),o);else if(n(e))t(e,o,i);else{var s=document.createElement("a");s.href=e,s.target="_blank",setTimeout((function(){r(s)}))}}:function(e,o,n,r){if((r=r||open("","_blank"))&&(r.document.title=r.document.body.innerText="downloading..."),"string"==typeof e)return t(e,o,n);var a="application/octet-stream"===e.type,l=/constructor/i.test(i.HTMLElement)||i.safari,c=/CriOS\/[\d]+/.test(navigator.userAgent);if((c||a&&l||s)&&"undefined"!=typeof FileReader){var d=new FileReader;d.onloadend=function(){var e=d.result;e=c?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),r?r.location.href=e:location=e,r=null},d.readAsDataURL(e)}else{var u=i.URL||i.webkitURL,h=u.createObjectURL(e);r?r.location=h:location.href=h,r=null,setTimeout((function(){u.revokeObjectURL(h)}),4e4)}});i.saveAs=a.saveAs=a,e.exports=a})?n.apply(t,[]):n)||(e.exports=r)},67694:function(e,t,o){"use strict";var n,r=o(65311),i=o.n(r);e=o.hmd(e),function(e){if(!e.jQuery){var t=function(e,o){return new t.fn.init(e,o)};t.isWindow=function(e){return e&&e===e.window},t.type=function(e){return e?"object"==typeof e||"function"==typeof e?n[i.call(e)]||"object":typeof e:e+""},t.isArray=Array.isArray||function(e){return"array"===t.type(e)},t.isPlainObject=function(e){var o;if(!e||"object"!==t.type(e)||e.nodeType||t.isWindow(e))return!1;try{if(e.constructor&&!r.call(e,"constructor")&&!r.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(e){return!1}for(o in e);return void 0===o||r.call(e,o)},t.each=function(e,t,o){var n=0,r=e.length,i=l(e);if(o){if(i)for(;n0&&o-1 in e)}}(window),n=function(){return function(e,t,o,n){var r,s=function(){if(o.documentMode)return o.documentMode;for(var e=7;e>4;e--){var t=o.createElement("div");if(t.innerHTML="\x3c!--[if IE "+e+"]> =0?t:Math.max(0,n+t),a=(o<0?n+o:Math.min(o,n))-s;if(a>0)if(i=new Array(a),this.charAt)for(r=0;r=0}:function(e,t){for(var o=0;ou&&Math.abs(a.v)>u;);return i?function(e){return c[e*(c.length-1)|0]}:d}}();f.Easings={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},spring:function(e){return 1-Math.cos(4.5*e*Math.PI)*Math.exp(6*-e)}},h.each([["ease",[.25,.1,.25,1]],["ease-in",[.42,0,1,1]],["ease-out",[0,0,.58,1]],["ease-in-out",[.42,0,.58,1]],["easeInSine",[.47,0,.745,.715]],["easeOutSine",[.39,.575,.565,1]],["easeInOutSine",[.445,.05,.55,.95]],["easeInQuad",[.55,.085,.68,.53]],["easeOutQuad",[.25,.46,.45,.94]],["easeInOutQuad",[.455,.03,.515,.955]],["easeInCubic",[.55,.055,.675,.19]],["easeOutCubic",[.215,.61,.355,1]],["easeInOutCubic",[.645,.045,.355,1]],["easeInQuart",[.895,.03,.685,.22]],["easeOutQuart",[.165,.84,.44,1]],["easeInOutQuart",[.77,0,.175,1]],["easeInQuint",[.755,.05,.855,.06]],["easeOutQuint",[.23,1,.32,1]],["easeInOutQuint",[.86,0,.07,1]],["easeInExpo",[.95,.05,.795,.035]],["easeOutExpo",[.19,1,.22,1]],["easeInOutExpo",[1,0,0,1]],["easeInCirc",[.6,.04,.98,.335]],["easeOutCirc",[.075,.82,.165,1]],["easeInOutCirc",[.785,.135,.15,.86]]],(function(e,t){f.Easings[t[0]]=T.apply(null,t[1])}));var b=f.CSS={RegEx:{isHex:/^#([A-f\d]{3}){1,2}$/i,valueUnwrap:/^[A-z]+\((.*)\)$/i,wrappedValueAlreadyExtracted:/[0-9.]+ [0-9.]+ [0-9.]+( [0-9.]+)?/,valueSplit:/([A-z]+\(.+\))|(([A-z0-9#-.]+?)(?=\s|$))/gi},Lists:{colors:["fill","stroke","stopColor","color","backgroundColor","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","outlineColor"],transformsBase:["translateX","translateY","scale","scaleX","scaleY","skewX","skewY","rotateZ"],transforms3D:["transformPerspective","translateZ","scaleZ","rotateX","rotateY"],units:["%","em","ex","ch","rem","vw","vh","vmin","vmax","cm","mm","Q","in","pc","pt","px","deg","grad","rad","turn","s","ms"],colorNames:{aliceblue:"240,248,255",antiquewhite:"250,235,215",aquamarine:"127,255,212",aqua:"0,255,255",azure:"240,255,255",beige:"245,245,220",bisque:"255,228,196",black:"0,0,0",blanchedalmond:"255,235,205",blueviolet:"138,43,226",blue:"0,0,255",brown:"165,42,42",burlywood:"222,184,135",cadetblue:"95,158,160",chartreuse:"127,255,0",chocolate:"210,105,30",coral:"255,127,80",cornflowerblue:"100,149,237",cornsilk:"255,248,220",crimson:"220,20,60",cyan:"0,255,255",darkblue:"0,0,139",darkcyan:"0,139,139",darkgoldenrod:"184,134,11",darkgray:"169,169,169",darkgrey:"169,169,169",darkgreen:"0,100,0",darkkhaki:"189,183,107",darkmagenta:"139,0,139",darkolivegreen:"85,107,47",darkorange:"255,140,0",darkorchid:"153,50,204",darkred:"139,0,0",darksalmon:"233,150,122",darkseagreen:"143,188,143",darkslateblue:"72,61,139",darkslategray:"47,79,79",darkturquoise:"0,206,209",darkviolet:"148,0,211",deeppink:"255,20,147",deepskyblue:"0,191,255",dimgray:"105,105,105",dimgrey:"105,105,105",dodgerblue:"30,144,255",firebrick:"178,34,34",floralwhite:"255,250,240",forestgreen:"34,139,34",fuchsia:"255,0,255",gainsboro:"220,220,220",ghostwhite:"248,248,255",gold:"255,215,0",goldenrod:"218,165,32",gray:"128,128,128",grey:"128,128,128",greenyellow:"173,255,47",green:"0,128,0",honeydew:"240,255,240",hotpink:"255,105,180",indianred:"205,92,92",indigo:"75,0,130",ivory:"255,255,240",khaki:"240,230,140",lavenderblush:"255,240,245",lavender:"230,230,250",lawngreen:"124,252,0",lemonchiffon:"255,250,205",lightblue:"173,216,230",lightcoral:"240,128,128",lightcyan:"224,255,255",lightgoldenrodyellow:"250,250,210",lightgray:"211,211,211",lightgrey:"211,211,211",lightgreen:"144,238,144",lightpink:"255,182,193",lightsalmon:"255,160,122",lightseagreen:"32,178,170",lightskyblue:"135,206,250",lightslategray:"119,136,153",lightsteelblue:"176,196,222",lightyellow:"255,255,224",limegreen:"50,205,50",lime:"0,255,0",linen:"250,240,230",magenta:"255,0,255",maroon:"128,0,0",mediumaquamarine:"102,205,170",mediumblue:"0,0,205",mediumorchid:"186,85,211",mediumpurple:"147,112,219",mediumseagreen:"60,179,113",mediumslateblue:"123,104,238",mediumspringgreen:"0,250,154",mediumturquoise:"72,209,204",mediumvioletred:"199,21,133",midnightblue:"25,25,112",mintcream:"245,255,250",mistyrose:"255,228,225",moccasin:"255,228,181",navajowhite:"255,222,173",navy:"0,0,128",oldlace:"253,245,230",olivedrab:"107,142,35",olive:"128,128,0",orangered:"255,69,0",orange:"255,165,0",orchid:"218,112,214",palegoldenrod:"238,232,170",palegreen:"152,251,152",paleturquoise:"175,238,238",palevioletred:"219,112,147",papayawhip:"255,239,213",peachpuff:"255,218,185",peru:"205,133,63",pink:"255,192,203",plum:"221,160,221",powderblue:"176,224,230",purple:"128,0,128",red:"255,0,0",rosybrown:"188,143,143",royalblue:"65,105,225",saddlebrown:"139,69,19",salmon:"250,128,114",sandybrown:"244,164,96",seagreen:"46,139,87",seashell:"255,245,238",sienna:"160,82,45",silver:"192,192,192",skyblue:"135,206,235",slateblue:"106,90,205",slategray:"112,128,144",snow:"255,250,250",springgreen:"0,255,127",steelblue:"70,130,180",tan:"210,180,140",teal:"0,128,128",thistle:"216,191,216",tomato:"255,99,71",turquoise:"64,224,208",violet:"238,130,238",wheat:"245,222,179",whitesmoke:"245,245,245",white:"255,255,255",yellowgreen:"154,205,50",yellow:"255,255,0"}},Hooks:{templates:{textShadow:["Color X Y Blur","black 0px 0px 0px"],boxShadow:["Color X Y Blur Spread","black 0px 0px 0px 0px"],clip:["Top Right Bottom Left","0px 0px 0px 0px"],backgroundPosition:["X Y","0% 0%"],transformOrigin:["X Y Z","50% 50% 0px"],perspectiveOrigin:["X Y","50% 50%"]},registered:{},register:function(){for(var e=0;e=1?"":"alpha(opacity="+parseInt(100*parseFloat(o),10)+")"}else switch(e){case"name":return"opacity";case"extract":case"inject":return o}}},register:function(){s&&!(s>9)||f.State.isGingerbread||(b.Lists.transformsBase=b.Lists.transformsBase.concat(b.Lists.transforms3D));for(var e=0;e8)&&3===i.split(" ").length&&(i+=" 1"),i;case"inject":return/^rgb/.test(r)?r:(s<=8?4===r.split(" ").length&&(r=r.split(/\s+/).slice(0,3).join(" ")):3===r.split(" ").length&&(r+=" 1"),(s<=8?"rgb":"rgba")+"("+r.replace(/\s+/g,",").replace(/\.(\d)+(?=,)/g,"")+")")}}}();function o(e,t,o){if("border-box"===b.getPropertyValue(t,"boxSizing").toString().toLowerCase()===(o||!1)){var n,r,i=0,s="width"===e?["Left","Right"]:["Top","Bottom"],a=["padding"+s[0],"padding"+s[1],"border"+s[0]+"Width","border"+s[1]+"Width"];for(n=0;n=2&&console.log("Get "+o+": "+l),l},setPropertyValue:function(e,o,n,r,i){var a=o;if("scroll"===o)i.container?i.container["scroll"+i.direction]=n:"Left"===i.direction?t.scrollTo(n,i.alternateValue):t.scrollTo(i.alternateValue,n);else if(b.Normalizations.registered[o]&&"transform"===b.Normalizations.registered[o]("name",e))b.Normalizations.registered[o]("inject",e,n),a="transform",n=x(e).transformCache[o];else{if(b.Hooks.registered[o]){var l=o,c=b.Hooks.getRoot(o);r=r||b.getPropertyValue(e,c),n=b.Hooks.injectValue(l,n,r),o=c}if(b.Normalizations.registered[o]&&(n=b.Normalizations.registered[o]("inject",e,n),o=b.Normalizations.registered[o]("name",e)),a=b.Names.prefixCheck(o)[0],s<=8)try{e.style[a]=n}catch(e){f.debug&&console.log("Browser does not support ["+n+"] for ["+a+"]")}else{var d=x(e);d&&d.isSVG&&b.Names.SVGAttribute(o)?e.setAttribute(o,n):e.style[a]=n}f.debug>=2&&console.log("Set "+o+" ("+a+"): "+n)}return[a,n]},flushTransformCache:function(e){var t="",o=x(e);if((s||f.State.isAndroid&&!f.State.isChrome)&&o&&o.isSVG){var n=function(t){return parseFloat(b.getPropertyValue(e,t))},r={translate:[n("translateX"),n("translateY")],skewX:[n("skewX")],skewY:[n("skewY")],scale:1!==n("scale")?[n("scale"),n("scale")]:[n("scaleX"),n("scaleY")],rotate:[n("rotateZ"),0,0]};h.each(x(e).transformCache,(function(e){/^translate/i.test(e)?e="translate":/^scale/i.test(e)?e="scale":/^rotate/i.test(e)&&(e="rotate"),r[e]&&(t+=e+"("+r[e].join(" ")+") ",delete r[e])}))}else{var i,a;h.each(x(e).transformCache,(function(o){if(i=x(e).transformCache[o],"transformPerspective"===o)return a=i,!0;9===s&&"rotateZ"===o&&(o="rotate"),t+=o+i+" "})),a&&(t="perspective"+a+" "+t)}b.setPropertyValue(e,"transform",t)}};b.Hooks.register(),b.Normalizations.register(),f.hook=function(e,t,o){var r;return e=u(e),h.each(e,(function(e,i){if(x(i)===n&&f.init(i),o===n)r===n&&(r=b.getPropertyValue(i,t));else{var s=b.setPropertyValue(i,t,o);"transform"===s[0]&&f.CSS.flushTransformCache(i),r=s}})),r};var y=function(){var e;function r(){return i?v.promise||null:s}var i,s,a,l,c,p,g=arguments[0]&&(arguments[0].p||h.isPlainObject(arguments[0].properties)&&!arguments[0].properties.names||m.isString(arguments[0].properties));m.isWrapped(this)?(i=!1,a=0,l=this,s=this):(i=!0,a=1,l=g?arguments[0].elements||arguments[0].e:arguments[0]);var v={promise:null,resolver:null,rejecter:null};if(i&&f.Promise&&(v.promise=new f.Promise((function(e,t){v.resolver=e,v.rejecter=t}))),g?(c=arguments[0].properties||arguments[0].p,p=arguments[0].options||arguments[0].o):(c=arguments[a],p=arguments[a+1]),l=u(l)){var w,_=l.length,S=0;if(!/^(stop|finish|finishAll|pause|resume)$/i.test(c)&&!h.isPlainObject(p)){p={};for(var T=a+1;T=4&&"("===R?A++:(A&&A<5||A>=4&&")"===R&&--A<5)&&(A=0),0===B&&"r"===R||1===B&&"g"===R||2===B&&"b"===R||3===B&&"a"===R||B>=3&&"("===R?(3===B&&"a"===R&&(N=1),B++):N&&","===R?++N>3&&(B=N=0):(N&&B<(N?5:4)||B>=(N?4:3)&&")"===R&&--B<(N?5:4))&&(B=N=0)}}T===w.length&&E===p.length||(f.debug&&console.error('Trying to pattern match mis-matched strings ["'+p+'", "'+w+'"]'),l=n),l&&(O.length?(f.debug&&console.log('Pattern found "'+l+'" -> ',O,M,"["+w+","+p+"]"),w=O,p=M,x=C=""):l=n)}if(l||(w=(_=S(r,w))[0],C=_[1],p=(_=S(r,p))[0].replace(/^([+-\/*])=/,(function(e,t){return k=t,""})),x=_[1],w=parseFloat(w)||0,p=parseFloat(p)||0,"%"===x&&(/^(fontSize|lineHeight)$/.test(r)?(p/=100,x="em"):/^scale/.test(r)?(p/=100,x=""):/(Red|Green|Blue)$/i.test(r)&&(p=p/100*255,x=""))),/[\/*]/.test(k))x=C;else if(C!==x&&0!==w)if(0===p)x=C;else{i=i||function(){var n={myParent:e.parentNode||o.body,position:b.getPropertyValue(e,"position"),fontSize:b.getPropertyValue(e,"fontSize")},r=n.position===D.lastPosition&&n.myParent===D.lastParent,i=n.fontSize===D.lastFontSize;D.lastParent=n.myParent,D.lastPosition=n.position,D.lastFontSize=n.fontSize;var s=100,a={};if(i&&r)a.emToPx=D.lastEmToPx,a.percentToPxWidth=D.lastPercentToPxWidth,a.percentToPxHeight=D.lastPercentToPxHeight;else{var l=g&&g.isSVG?o.createElementNS("http://www.w3.org/2000/svg","rect"):o.createElement("div");f.init(l),n.myParent.appendChild(l),h.each(["overflow","overflowX","overflowY"],(function(e,t){f.CSS.setPropertyValue(l,t,"hidden")})),f.CSS.setPropertyValue(l,"position",n.position),f.CSS.setPropertyValue(l,"fontSize",n.fontSize),f.CSS.setPropertyValue(l,"boxSizing","content-box"),h.each(["minWidth","maxWidth","width","minHeight","maxHeight","height"],(function(e,t){f.CSS.setPropertyValue(l,t,s+"%")})),f.CSS.setPropertyValue(l,"paddingLeft",s+"em"),a.percentToPxWidth=D.lastPercentToPxWidth=(parseFloat(b.getPropertyValue(l,"width",null,!0))||1)/s,a.percentToPxHeight=D.lastPercentToPxHeight=(parseFloat(b.getPropertyValue(l,"height",null,!0))||1)/s,a.emToPx=D.lastEmToPx=(parseFloat(b.getPropertyValue(l,"paddingLeft"))||1)/s,n.myParent.removeChild(l)}return null===D.remToPx&&(D.remToPx=parseFloat(b.getPropertyValue(o.body,"fontSize"))||16),null===D.vwToPx&&(D.vwToPx=parseFloat(t.innerWidth)/100,D.vhToPx=parseFloat(t.innerHeight)/100),a.remToPx=D.remToPx,a.vwToPx=D.vwToPx,a.vhToPx=D.vhToPx,f.debug>=1&&console.log("Unit ratios: "+JSON.stringify(a),e),a}();var U=/margin|padding|left|right|width|text|word|letter/i.test(r)||/X$/.test(r)||"x"===r?"x":"y";switch(C){case"%":w*="x"===U?i.percentToPxWidth:i.percentToPxHeight;break;case"px":break;default:w*=i[C+"ToPx"]}switch(x){case"%":w*=1/("x"===U?i.percentToPxWidth:i.percentToPxHeight);break;case"px":break;default:w*=1/i[x+"ToPx"]}}switch(k){case"+":p=w+p;break;case"-":p=w-p;break;case"*":p*=w;break;case"/":p=w/p}u[r]={rootPropertyValue:d,startValue:w,currentValue:w,endValue:p,unitType:x,easing:v},l&&(u[r].pattern=l),f.debug&&console.log("tweensContainer ("+r+"): "+JSON.stringify(u[r]),e)}else f.debug&&console.log("Skipping ["+c+"] due to a lack of browser support.")};for(var I in c)if(c.hasOwnProperty(I)){var F=b.Names.camelCase(I),L=R(c[I]);if(d(b.Lists.colors)){var z=L[0],H=L[1],Z=L[2];if(b.RegEx.isHex.test(z)){for(var j=["Red","Green","Blue"],U=b.Values.hexToRgb(z),$=Z?b.Values.hexToRgb(Z):n,W=0;W=.001?function(t,o){for(var r=0;r<4;++r){var i=m(o,e,n);if(0===i)return o;o-=(h(o,e,n)-t)/i}return o}(t,s):0===a?s:function(t,o,r){var i,s,a=0;do{(i=h(s=o+(r-o)/2,e,n)-t)>0?r=s:o=s}while(Math.abs(i)>1e-7&&++a<10);return s}(t,o,o+i)}(t),o,r)};g.getControlPoints=function(){return[{x:e,y:o},{x:n,y:r}]};var f="generateBezier("+[e,o,n,r]+")";return g.toString=function(){return f},g}function E(e,t){var o=e;return m.isString(e)?f.Easings[e]||(o=!1):o=m.isArray(e)&&1===e.length?S.apply(null,e):m.isArray(e)&&2===e.length?v.apply(null,e.concat([t])):!(!m.isArray(e)||4!==e.length)&&T.apply(null,e),!1===o&&(o=f.Easings[f.defaults.easing]?f.defaults.easing:g),o}function O(e){if(e){var t=f.timestamp&&!0!==e?e:l.now(),o=f.State.calls.length;o>1e4&&(f.State.calls=function(e){for(var t=-1,o=e?e.length:0,n=[];++t=1||n>=1)&&(G(i)?i.scrollBy(x.x*o,x.y*n):i&&(i.scrollLeft+=x.x*o,i.scrollTop+=x.y*n),o>=1&&(x.prevTimeX=s),n>=1&&(x.prevTimeY=s)),x.isScrolling&&(F(x.i),x.i=I(x.scroll))},isScrolling:!1,prevTimeX:0,prevTimeY:0,start:function(e){x.isScrolling=!0,F(x.i),x.interaction=e,x.prevTimeX=(new Date).getTime(),x.prevTimeY=(new Date).getTime(),x.i=I(x.scroll)},stop:function(){x.isScrolling=!1,F(x.i)}},C="ontouchstart"in s||s.DocumentTouch&&a instanceof s.DocumentTouch,k=m&&!/Chrome/.test(navigator.userAgent),S=C||k?20:10,T=1,E=0,O=1/0,M=a.all&&!s.atob?{drag:"move",resizex:"e-resize",resizey:"s-resize",resizexy:"se-resize",resizetop:"n-resize",resizeleft:"w-resize",resizebottom:"s-resize",resizeright:"e-resize",resizetopleft:"se-resize",resizebottomright:"se-resize",resizetopright:"ne-resize",resizebottomleft:"ne-resize",gesture:""}:{drag:"move",resizex:"ew-resize",resizey:"ns-resize",resizexy:"nwse-resize",resizetop:"ns-resize",resizeleft:"ew-resize",resizebottom:"ns-resize",resizeright:"ew-resize",resizetopleft:"nwse-resize",resizebottomright:"nwse-resize",resizetopright:"nesw-resize",resizebottomleft:"nesw-resize",gesture:""},A={drag:!0,resize:!0,gesture:!0},B="onmousewheel"in a?"mousewheel":"wheel",N=["dragstart","dragmove","draginertiastart","dragend","dragenter","dragleave","dropactivate","dropdeactivate","dropmove","drop","resizestart","resizemove","resizeinertiastart","resizeend","gesturestart","gesturemove","gestureinertiastart","gestureend","down","move","up","cancel","tap","doubletap","hold"],R={},V="Opera"==navigator.appName&&C&&navigator.userAgent.match("Presto"),D=/iP(hone|od|ad)/.test(navigator.platform)&&/OS 7[^\d]/.test(navigator.appVersion),P="matches"in Element.prototype?"matches":"webkitMatchesSelector"in Element.prototype?"webkitMatchesSelector":"mozMatchesSelector"in Element.prototype?"mozMatchesSelector":"oMatchesSelector"in Element.prototype?"oMatchesSelector":"msMatchesSelector",I=o.requestAnimationFrame,F=o.cancelAnimationFrame,L=function(){var e="attachEvent"in s&&!("addEventListener"in s),t=e?"attachEvent":"addEventListener",o=e?"detachEvent":"removeEventListener",n=e?"on":"",r=[],i=[],a=[];function l(){this.returnValue=!1}function c(){this.cancelBubble=!0}function d(){this.cancelBubble=!0,this.immediatePropagationStopped=!0}return{add:function(o,s,u,h){var m=Ke(r,o),p=i[m];if(p||(p={events:{},typeCount:0},m=r.push(o)-1,i.push(p),a.push(e?{supplied:[],wrapped:[],useCount:[]}:null)),p.events[s]||(p.events[s]=[],p.typeCount++),!Xe(p.events[s],u)){var g;if(e){var f=a[m],v=Ke(f.supplied,u),b=f.wrapped[v]||function(e){e.immediatePropagationStopped||(e.target=e.srcElement,e.currentTarget=o,e.preventDefault=e.preventDefault||l,e.stopPropagation=e.stopPropagation||c,e.stopImmediatePropagation=e.stopImmediatePropagation||d,/mouse|click/.test(e.type)&&(e.pageX=e.clientX+me(o).document.documentElement.scrollLeft,e.pageY=e.clientY+me(o).document.documentElement.scrollTop),u(e))};g=o[t](n+s,b,Boolean(h)),-1===v?(f.supplied.push(u),f.wrapped.push(b),f.useCount.push(1)):f.useCount[v]++}else g=o[t](s,u,h||!1);return p.events[s].push(u),g}},remove:function t(s,l,c,d){var u,h,m,p=Ke(r,s),g=i[p],f=c;if(g&&g.events)if(e&&(m=Ke((h=a[p]).supplied,c),f=h.wrapped[m]),"all"!==l){if(g.events[l]){var v=g.events[l].length;if("all"===c){for(u=0;u1?ve(n):n[0],g),o.page.x=g.x,o.page.y=g.y,de(r,g),o.client.x=g.x,o.client.y=g.y,void(o.timeStamp=(new Date).getTime());var o,n,r},pointerOver:function(e,t,o){if(!this.prepared.name&&this.mouse){var r=[],i=[],s=this.element;this.addPointer(e),!this.target||!Oe(this.target,this.element,o)&&Me(this.target,this.element,o)||(this.target=null,this.element=null,this.matches=[],this.matchElements=[]);var a=v.get(o),l=a&&!Oe(a,o,o)&&Me(a,o,o)&&Ze(a.getAction(e,t,this,o),a);l&&!Re(a,o,l)&&(l=null),l?(this.target=a,this.element=o,this.matches=[],this.matchElements=[]):(v.forEachSelector((function(e,t){e&&Ee(e,o)&&!Oe(e,o,o)&&Me(e,o,o)&&Je(o,t)&&(r.push(e),i.push(o))})),this.validateSelector(e,t,r,i)?(this.matches=r,this.matchElements=i,this.pointerHover(e,t,this.matches,this.matchElements),L.add(o,k?n.move:"mousemove",H.pointerHover)):this.target&&(ke(s,o)?(this.pointerHover(e,t,this.matches,this.matchElements),L.add(this.element,k?n.move:"mousemove",H.pointerHover)):(this.target=null,this.element=null,this.matches=[],this.matchElements=[])))}},pointerHover:function(e,t,o,n,r,i){var s,a=this.target;!this.prepared.name&&this.mouse?(this.setEventXY(this.curCoords,[e]),r?s=this.validateSelector(e,t,r,i):a&&(s=Ze(a.getAction(this.pointers[0],t,this,this.element),this.target)),a&&a.options.styleCursor&&(a._doc.documentElement.style.cursor=s?Le(s):"")):this.prepared.name&&this.checkAndPreventDefault(t,a,this.element)},pointerOut:function(e,t,o){this.prepared.name||(v.get(o)||L.remove(o,k?n.move:"mousemove",H.pointerHover),this.target&&this.target.options.styleCursor&&!this.interacting()&&(this.target._doc.documentElement.style.cursor=""))},selectorDown:function(e,t,o,n){var i,s=this,a=L.useAttachEvent?ne({},t):t,l=o,c=this.addPointer(e);if(this.holdTimers[c]=setTimeout((function(){s.pointerHold(L.useAttachEvent?a:e,a,o,n)}),_._holdDuration),this.pointerIsDown=!0,this.inertiaStatus.active&&this.target.selector)for(;q(l);){if(l===this.element&&Ze(this.target.getAction(e,t,this,this.element),this.target).name===this.prepared.name)return F(this.inertiaStatus.i),this.inertiaStatus.active=!1,void this.collectEventTargets(e,t,o,"down");l=Te(l)}if(this.interacting())this.collectEventTargets(e,t,o,"down");else{for(this.setEventXY(this.curCoords,[e]),this.downEvent=t;q(l)&&!i;)this.matches=[],this.matchElements=[],v.forEachSelector(d),i=this.validateSelector(e,t,this.matches,this.matchElements),l=Te(l);if(i)return this.prepared.name=i.name,this.prepared.axis=i.axis,this.prepared.edges=i.edges,this.collectEventTargets(e,t,o,"down"),this.pointerDown(e,t,o,n,i);this.downTimes[c]=(new Date).getTime(),this.downTargets[c]=o,re(this.downPointer,e),ie(this.prevCoords,this.curCoords),this.pointerWasMoved=!1,this.collectEventTargets(e,t,o,"down")}function d(e,t,n){var i=r?n.querySelectorAll(t):void 0;Ee(e,l)&&!Oe(e,l,o)&&Me(e,l,o)&&Je(l,t,i)&&(s.matches.push(e),s.matchElements.push(l))}},pointerDown:function(e,t,o,n,r){if(r||this.inertiaStatus.active||!this.pointerWasMoved||!this.prepared.name){this.pointerIsDown=!0,this.downEvent=t;var i,s=this.addPointer(e);if(this.pointerIds.length>1&&this.target._element===this.element){var a=Ze(r||this.target.getAction(e,t,this,this.element),this.target);Re(this.target,this.element,a)&&(i=a),this.prepared.name=null}else if(!this.prepared.name){var l=v.get(n);l&&!Oe(l,n,o)&&Me(l,n,o)&&(i=Ze(r||l.getAction(e,t,this,n),l))&&Re(l,n,i)&&(this.target=l,this.element=n)}var c=this.target,d=c&&c.options;if(!c||!r&&this.prepared.name)this.inertiaStatus.active&&n===this.element&&Ze(c.getAction(e,t,this,this.element),c).name===this.prepared.name&&(F(this.inertiaStatus.i),this.inertiaStatus.active=!1,this.checkAndPreventDefault(t,c,this.element));else{if(i=i||Ze(r||c.getAction(e,t,this,n),c,this.element),this.setEventXY(this.startCoords,this.pointers),!i)return;d.styleCursor&&(c._doc.documentElement.style.cursor=Le(i)),this.resizeAxes="resize"===i.name?i.axis:null,"gesture"===i&&this.pointerIds.length<2&&(i=null),this.prepared.name=i.name,this.prepared.axis=i.axis,this.prepared.edges=i.edges,this.snapStatus.snappedX=this.snapStatus.snappedY=this.restrictStatus.restrictedX=this.restrictStatus.restrictedY=NaN,this.downTimes[s]=(new Date).getTime(),this.downTargets[s]=o,re(this.downPointer,e),ie(this.prevCoords,this.startCoords),this.pointerWasMoved=!1,this.checkAndPreventDefault(t,c,this.element)}}else this.checkAndPreventDefault(t,this.target,this.element)},setModifications:function(e,t){var o=this.target,n=!0,r=Be(o,this.prepared.name)&&(!o.options[this.prepared.name].snap.endOnly||t),i=Ne(o,this.prepared.name)&&(!o.options[this.prepared.name].restrict.endOnly||t);return r?this.setSnapping(e):this.snapStatus.locked=!1,i?this.setRestriction(e):this.restrictStatus.restricted=!1,r&&this.snapStatus.locked&&!this.snapStatus.changed?n=i&&this.restrictStatus.restricted&&this.restrictStatus.changed:i&&this.restrictStatus.restricted&&!this.restrictStatus.changed&&(n=!1),n},setStartOffsets:function(e,t,o){var n,r,i=t.getRect(o),s=_e(t,o),a=t.options[this.prepared.name].snap,l=t.options[this.prepared.name].restrict;i?(this.startOffset.left=this.startCoords.page.x-i.left,this.startOffset.top=this.startCoords.page.y-i.top,this.startOffset.right=i.right-this.startCoords.page.x,this.startOffset.bottom=i.bottom-this.startCoords.page.y,n="width"in i?i.width:i.right-i.left,r="height"in i?i.height:i.bottom-i.top):this.startOffset.left=this.startOffset.top=this.startOffset.right=this.startOffset.bottom=0,this.snapOffsets.splice(0);var c=a&&"startCoords"===a.offset?{x:this.startCoords.page.x-s.x,y:this.startCoords.page.y-s.y}:a&&a.offset||{x:0,y:0};if(i&&a&&a.relativePoints&&a.relativePoints.length)for(var d=0;dT),u||this.pointerIsDown&&!this.pointerWasMoved||(this.pointerIsDown&&clearTimeout(this.holdTimers[h]),this.collectEventTargets(e,t,o,"move")),this.pointerIsDown)if(u&&this.pointerWasMoved&&!i)this.checkAndPreventDefault(t,this.target,this.element);else if(se(this.pointerDelta,this.prevCoords,this.curCoords),this.prepared.name){if(this.pointerWasMoved&&(!this.inertiaStatus.active||e instanceof Ie&&/inertiastart/.test(e.type))){if(!this.interacting()&&(se(this.pointerDelta,this.prevCoords,this.curCoords),"drag"===this.prepared.name)){var m=Math.abs(c),g=Math.abs(d),f=this.target.options.drag.axis,b=m>g?"x":md.bottom&&(i=d.top,d.top=d.bottom,d.bottom=i),d.left>d.right&&(i=d.left,d.left=d.right,d.right=i))):(d.top=Math.min(c.top,l.bottom),d.bottom=Math.max(c.bottom,l.top),d.left=Math.min(c.left,l.right),d.right=Math.max(c.right,l.left)),d.width=d.right-d.left,d.height=d.bottom-d.top,d)u[g]=d[g]-h[g];t.edges=this.prepared.edges,t.rect=d,t.deltaRect=u}return this.target.fire(t),t},gestureStart:function(e){var t=new Ie(this,e,"gesture","start",this.element);return t.ds=0,this.gesture.startDistance=this.gesture.prevDistance=t.distance,this.gesture.startAngle=this.gesture.prevAngle=t.angle,this.gesture.scale=1,this.gesturing=!0,this.target.fire(t),t},gestureMove:function(e){return this.pointerIds.length?((t=new Ie(this,e,"gesture","move",this.element)).ds=t.scale-this.gesture.scale,this.target.fire(t),this.gesture.prevAngle=t.angle,this.gesture.prevDistance=t.distance,t.scale===1/0||null===t.scale||void 0===t.scale||isNaN(t.scale)||(this.gesture.scale=t.scale),t):this.prevEvent;var t},pointerHold:function(e,t,o){this.collectEventTargets(e,t,o,"hold")},pointerUp:function(e,t,o,n){var r=this.mouse?0:Ke(this.pointerIds,ue(e));clearTimeout(this.holdTimers[r]),this.collectEventTargets(e,t,o,"up"),this.collectEventTargets(e,t,o,"tap"),this.pointerEnd(e,t,o,n),this.removePointer(e)},pointerCancel:function(e,t,o,n){var r=this.mouse?0:Ke(this.pointerIds,ue(e));clearTimeout(this.holdTimers[r]),this.collectEventTargets(e,t,o,"cancel"),this.pointerEnd(e,t,o,n),this.removePointer(e)},ie8Dblclick:function(e,t,o){this.prevTap&&t.clientX===this.prevTap.clientX&&t.clientY===this.prevTap.clientY&&o===this.prevTap.target&&(this.downTargets[0]=o,this.downTimes[0]=(new Date).getTime(),this.collectEventTargets(e,t,o,"tap"))},pointerEnd:function(e,t,o,n){var r,i=this.target,s=i&&i.options,a=s&&this.prepared.name&&s[this.prepared.name].inertia,l=this.inertiaStatus;if(this.interacting()){if(l.active&&!l.ending)return;var c,d,u,h=(new Date).getTime(),m=!1,p=Be(i,this.prepared.name)&&s[this.prepared.name].snap.endOnly,g=Ne(i,this.prepared.name)&&s[this.prepared.name].restrict.endOnly,f=0,v=0;if(c=this.dragging?"x"===s.drag.axis?Math.abs(this.pointerDelta.client.vx):"y"===s.drag.axis?Math.abs(this.pointerDelta.client.vy):this.pointerDelta.client.speed:this.pointerDelta.client.speed,u=(d=a&&a.enabled&&"gesture"!==this.prepared.name&&t!==l.startEvent)&&h-this.curCoords.timeStamp<50&&c>a.minSpeed&&c>a.endSpeed,d&&!u&&(p||g)){var b={};b.snap=b.restrict=b,p&&(this.setSnapping(this.curCoords.page,b),b.locked&&(f+=b.dx,v+=b.dy)),g&&(this.setRestriction(this.curCoords.page,b),b.restricted&&(f+=b.dx,v+=b.dy)),(f||v)&&(m=!0)}if(u||m){if(ie(l.upCoords,this.curCoords),this.pointers[0]=l.startEvent=new Ie(this,t,this.prepared.name,"inertiastart",this.element),l.t0=h,i.fire(l.startEvent),u){l.vx0=this.pointerDelta.client.vx,l.vy0=this.pointerDelta.client.vy,l.v0=c,this.calcInertia(l);var y,w=ne({},this.curCoords.page),_=_e(i,this.element);if(w.x=w.x+l.xe-_.x,w.y=w.y+l.ye-_.y,(y={useStatusXY:!0,x:w.x,y:w.y,dx:0,dy:0,snap:null}).snap=y,f=v=0,p){var x=this.setSnapping(this.curCoords.page,y);x.locked&&(f+=x.dx,v+=x.dy)}if(g){var C=this.setRestriction(this.curCoords.page,y);C.restricted&&(f+=C.dx,v+=C.dy)}l.modifiedXe+=f,l.modifiedYe+=v,l.i=I(this.boundInertiaFrame)}else l.smoothEnd=!0,l.xe=f,l.ye=v,l.sx=l.sy=0,l.i=I(this.boundSmoothEndFrame);return void(l.active=!0)}(p||g)&&this.pointerMove(e,t,o,n,!0)}if(this.dragging){r=new Ie(this,t,"drag","end",this.element);var k=this.element,S=this.getDrop(r,t,k);this.dropTarget=S.dropzone,this.dropElement=S.element;var T=this.getDropEvents(t,r);T.leave&&this.prevDropTarget.fire(T.leave),T.enter&&this.dropTarget.fire(T.enter),T.drop&&this.dropTarget.fire(T.drop),T.deactivate&&this.fireActiveDrops(T.deactivate),i.fire(r)}else this.resizing?(r=new Ie(this,t,"resize","end",this.element),i.fire(r)):this.gesturing&&(r=new Ie(this,t,"gesture","end",this.element),i.fire(r));this.stop(t)},collectDrops:function(e){var t,o=[],n=[];for(e=e||this.element,t=0;ts.innerWidth-x.margin,n=e.clientY>s.innerHeight-x.margin;else{var a=pe(s);r=e.clientXa.right-x.margin,n=e.clientY>a.bottom-x.margin}x.x=o?1:r?-1:0,x.y=n?1:t?-1:0,x.isScrolling||(x.margin=i.margin,x.speed=i.speed,x.start(this))}},_updateEventTargets:function(e,t){this._eventTarget=e,this._curEventTarget=t}},Ie.prototype={preventDefault:W,stopImmediatePropagation:function(){this.immediatePropagationStopped=this.propagationStopped=!0},stopPropagation:function(){this.propagationStopped=!0}};for(var H={},Z=["dragStart","dragMove","resizeStart","resizeMove","gestureStart","gestureMove","pointerOver","pointerOut","pointerHover","selectorDown","pointerDown","pointerMove","pointerUp","pointerCancel","pointerEnd","addPointer","removePointer","recordPointer","autoScrollMove"],j=0,U=Z.length;ji.left&&d.xi.top&&d.y=i.left&&m<=i.right&&p>=i.top&&p<=i.bottom}return Q(a)&&(s=Math.max(0,Math.min(i.right,h.right)-Math.max(i.left,h.left))*Math.max(0,Math.min(i.bottom,h.bottom)-Math.max(i.top,h.top))/(h.width*h.height)>=a),this.options.drop.checker&&(s=this.options.drop.checker(e,t,s,this,r,o,n)),s},dropChecker:function(e){return J(e)?(this.options.drop.checker=e,this):null===e?(delete this.options.getRect,this):this.options.drop.checker},accept:function(e){return q(e)||oe(e)?(this.options.drop.accept=e,this):null===e?(delete this.options.drop.accept,this):this.options.drop.accept},resizable:function(e){return X(e)?(this.options.resize.enabled=!1!==e.enabled,this.setPerAction("resize",e),this.setOnEvents("resize",e),/^x$|^y$|^xy$/.test(e.axis)?this.options.resize.axis=e.axis:null===e.axis&&(this.options.resize.axis=_.resize.axis),ee(e.preserveAspectRatio)?this.options.resize.preserveAspectRatio=e.preserveAspectRatio:ee(e.square)&&(this.options.resize.square=e.square),this):ee(e)?(this.options.resize.enabled=e,this):this.options.resize},squareResize:function(e){return ee(e)?(this.options.resize.square=e,this):null===e?(delete this.options.resize.square,this):this.options.resize.square},gesturable:function(e){return X(e)?(this.options.gesture.enabled=!1!==e.enabled,this.setPerAction("gesture",e),this.setOnEvents("gesture",e),this):ee(e)?(this.options.gesture.enabled=e,this):this.options.gesture},autoScroll:function(e){return X(e)?e=ne({actions:["drag","resize"]},e):ee(e)&&(e={actions:["drag","resize"],enabled:e}),this.setOptions("autoScroll",e)},snap:function(e){var t=this.setOptions("snap",e);return t===this?this:t.drag},setOptions:function(e,t){var o,n=t&&K(t.actions)?t.actions:["drag"];if(X(t)||ee(t)){for(o=0;o=0&&(s.selectors[i]!==this.selector||s.contexts[i]!==this._context);i--);-1===i&&(i=s.selectors.length,s.selectors.push(this.selector),s.contexts.push(this._context),s.listeners.push([])),s.listeners[i].push([t,o])}else L.add(this._element,e,t,o);return this},off:function(e,t,o){var n;if(te(e)&&-1!==e.search(" ")&&(e=e.trim().split(/ +/)),K(e)){for(n=0;n=0;s--)if(a.selectors[s]===this.selector&&a.contexts[s]===this._context){var c=a.listeners[s];for(n=c.length-1;n>=0;n--){var d=c[n][0],u=c[n][1];if(d===t&&u===o){c.splice(n,1),c.length||(a.selectors.splice(s,1),a.contexts.splice(s,1),a.listeners.splice(s,1),L.remove(this._context,e,je),L.remove(this._context,e,Ue,!0),a.selectors.length||(w[e]=null)),l=!0;break}}if(l)break}}else L.remove(this._element,e,t,o);return this},set:function(e){X(e)||(e={}),this.options=ne({},_.base);var t,o=["drag","drop","resize","gesture"],n=["draggable","dropzone","resizable","gesturable"],r=ne(ne({},_.perAction),e[i]||{});for(t=0;t=0;t--)b[t].stop(e);return $e},$e.dynamicDrop=function(e){return ee(e)?(y=e,$e):y},$e.pointerMoveTolerance=function(e){return Q(e)?(T=e,this):T},$e.maxInteractions=function(e){return Q(e)?(O=e,this):O},$e.createSnapGrid=function(e){return function(t,o){var n=0,r=0;X(e.offset)&&(n=e.offset.x,r=e.offset.y);var i=Math.round((t-n)/e.x),s=Math.round((o-r)/e.y);return{x:i*e.x+n,y:s*e.y+r,range:e.range}}},Ye(a),P in Element.prototype&&J(Element.prototype[P])||(r=function(e,t,o){for(var n=0,r=(o=o||e.parentNode.querySelectorAll(t)).length;n1){var t=fe(e),o=Math.min(t[0].pageX,t[1].pageX),n=Math.min(t[0].pageY,t[1].pageY);return{x:o,y:n,left:o,top:n,width:Math.max(t[0].pageX,t[1].pageX)-o,height:Math.max(t[0].pageY,t[1].pageY)-n}}}function ye(e,t){var o=(t=t||_.deltaSource)+"X",n=t+"Y",r=fe(e),i=r[0][o]-r[1][o],s=r[0][n]-r[1][n];return p(i,s)}function we(e,t,o){var n=(o=o||_.deltaSource)+"X",r=o+"Y",i=fe(e),s=i[0][n]-i[1][n],a=i[0][r]-i[1][r],l=180*Math.atan(a/s)/Math.PI;if(Q(t)){var c=(l-t)%360;c>315?l-=360+l/360|0:c>135?l-=180+l/360|0:c<-315?l+=360+l/360|0:c<-135&&(l+=180+l/360|0)}return l}function _e(e,t){var o=e?e.options.origin:_.origin;return"parent"===o?o=Te(t):"self"===o?o=e.getRect(t):oe(o)&&(o=Se(t,o)||{x:0,y:0}),J(o)&&(o=o(e&&t)),q(o)&&(o=ge(o)),o.x="x"in o?o.x:o.left,o.y="y"in o?o.y:o.top,o}function xe(e,t,o,n){var r=1-e;return r*r*t+2*r*e*o+e*e*n}function Ce(e,t,o,n){return-o*(e/=n)*(e-2)+t}function ke(e,t){for(;t;){if(t===e)return!0;t=t.parentNode}return!1}function Se(e,t){for(var o=Te(e);q(o);){if(Je(o,t))return o;o=Te(o)}return null}function Te(e){var t=e.parentNode;if(Y(t)){for(;(t=t.host)&&Y(t););return t}return t}function Ee(e,t){return e._context===t.ownerDocument||ke(e._context,t)}function Oe(e,t,o){var n=e.options.ignoreFrom;return!(!n||!q(o))&&(te(n)?Qe(o,n,t):!!q(n)&&ke(n,o))}function Me(e,t,o){var n=e.options.allowFrom;return!n||!!q(o)&&(te(n)?Qe(o,n,t):!!q(n)&&ke(n,o))}function Ae(e,t){if(!t)return!1;var o=t.options.drag.axis;return"xy"===e||"xy"===o||o===e}function Be(e,t){var o=e.options;return/^resize/.test(t)&&(t="resize"),o[t].snap&&o[t].snap.enabled}function Ne(e,t){var o=e.options;return/^resize/.test(t)&&(t="resize"),o[t].restrict&&o[t].restrict.enabled}function Re(e,t,o){for(var n=e.options,r=n[o.name].max,i=n[o.name].maxPerElement,s=0,a=0,l=0,c=0,d=b.length;c=O)return!1;if(u.target===e){if((a+=h===o.name|0)>=r)return!1;if(u.element===t&&(l++,h!==o.name||l>=i))return!1}}}return O>0}function Ve(){if(this.target=null,this.element=null,this.dropTarget=null,this.dropElement=null,this.prevDropTarget=null,this.prevDropElement=null,this.prepared={name:null,axis:null,edges:null},this.matches=[],this.matchElements=[],this.inertiaStatus={active:!1,smoothEnd:!1,ending:!1,startEvent:null,upCoords:{},xe:0,ye:0,sx:0,sy:0,t0:0,vx0:0,vys:0,duration:0,resumeDx:0,resumeDy:0,lambda_v0:0,one_ve_v0:0,i:null},J(Function.prototype.bind))this.boundInertiaFrame=this.inertiaFrame.bind(this),this.boundSmoothEndFrame=this.smoothEndFrame.bind(this);else{var e=this;this.boundInertiaFrame=function(){return e.inertiaFrame()},this.boundSmoothEndFrame=function(){return e.smoothEndFrame()}}this.activeDrops={dropzones:[],elements:[],rects:[]},this.pointers=[],this.pointerIds=[],this.downTargets=[],this.downTimes=[],this.holdTimers=[],this.prevCoords={page:{x:0,y:0},client:{x:0,y:0},timeStamp:0},this.curCoords={page:{x:0,y:0},client:{x:0,y:0},timeStamp:0},this.startCoords={page:{x:0,y:0},client:{x:0,y:0},timeStamp:0},this.pointerDelta={page:{x:0,y:0,vx:0,vy:0,speed:0},client:{x:0,y:0,vx:0,vy:0,speed:0},timeStamp:0},this.downEvent=null,this.downPointer={},this._eventTarget=null,this._curEventTarget=null,this.prevEvent=null,this.tapTime=0,this.prevTap=null,this.startOffset={left:0,right:0,top:0,bottom:0},this.restrictOffset={left:0,right:0,top:0,bottom:0},this.snapOffsets=[],this.gesture={start:{x:0,y:0},startDistance:0,prevDistance:0,distance:0,scale:1,startAngle:0,prevAngle:0},this.snapStatus={x:0,y:0,dx:0,dy:0,realX:0,realY:0,snappedX:0,snappedY:0,targets:[],locked:!1,changed:!1},this.restrictStatus={dx:0,dy:0,restrictedX:0,restrictedY:0,snap:null,restricted:!1,changed:!1},this.restrictStatus.snap=this.snapStatus,this.pointerIsDown=!1,this.pointerWasMoved=!1,this.gesturing=!1,this.dragging=!1,this.resizing=!1,this.resizeAxes="xy",this.mouse=!1,b.push(this)}function De(e,t,o){var n,r=0,i=b.length,s=/mouse/i.test(e.pointerType||t)||4===e.pointerType,a=ue(e);if(/down|start/i.test(t))for(r=0;r600&&this.timeStamp-e.prevEvent.timeStamp<150){var E=180*Math.atan2(e.prevEvent.velocityY,e.prevEvent.velocityX)/Math.PI;E<0&&(E+=360);var O=112.5<=E&&E<247.5,M=202.5<=E&&E<337.5,A=!O&&(292.5<=E||E<67.5),B=!M&&22.5<=E&&E<157.5;this.swipe={up:M,down:B,left:O,right:A,angle:E,speed:e.prevEvent.speed,velocity:{x:e.prevEvent.velocityX,y:e.prevEvent.velocityY}}}}function Fe(){this.originalEvent.preventDefault()}function Le(e){var t="";if("drag"===e.name&&(t=M.drag),"resize"===e.name)if(e.axis)t=M[e.name+e.axis];else if(e.edges){for(var o="resize",n=["top","bottom","left","right"],r=0;r<4;r++)e.edges[n[r]]&&(o+=n[r]);t=M[o]}return t}function ze(e,t,o,n,r,i,s){if(!t)return!1;if(!0===t){var a=Q(i.width)?i.width:i.right-i.left,l=Q(i.height)?i.height:i.bottom-i.top;if(a<0&&("left"===e?e="right":"right"===e&&(e="left")),l<0&&("top"===e?e="bottom":"bottom"===e&&(e="top")),"left"===e)return o.x<(a>=0?i.left:i.right)+s;if("top"===e)return o.y<(l>=0?i.top:i.bottom)+s;if("right"===e)return o.x>(a>=0?i.right:i.left)-s;if("bottom"===e)return o.y>(l>=0?i.bottom:i.top)-s}return!!q(n)&&(q(t)?t===n:Qe(n,t,r))}function He(e,t,o){var n,r=this.getRect(o),i=!1,s=null,a=null,l=ne({},t.curCoords.page),c=this.options;if(!r)return null;if(A.resize&&c.resize.enabled){var d=c.resize;if(n={left:!1,right:!1,top:!1,bottom:!1},X(d.edges)){for(var u in n)n[u]=ze(u,d.edges[u],l,t._eventTarget,o,r,d.margin||S);n.left=n.left&&!n.right,n.top=n.top&&!n.bottom,i=n.left||n.right||n.top||n.bottom}else{var h="y"!==c.resize.axis&&l.x>r.right-S,m="x"!==c.resize.axis&&l.y>r.bottom-S;i=h||m,a=(h?"x":"")+(m?"y":"")}}return s=i?"resize":A.drag&&c.drag.enabled?"drag":null,A.gesture&&t.pointerIds.length>=2&&!t.dragging&&!t.resizing&&(s="gesture"),s?{name:s,axis:a,edges:n}:null}function Ze(e,t){if(!X(e))return null;var o=e.name,n=t.options;return("resize"===o&&n.resize.enabled||"drag"===o&&n.drag.enabled||"gesture"===o&&n.gesture.enabled)&&A[o]?("resize"!==o&&"resizeyx"!==o||(o="resizexy"),e):null}function je(e,t){var o={},n=w[e.type],r=he(e.path?e.path[0]:e.target),i=r;for(var s in t=!!t,e)o[s]=e[s];for(o.originalEvent=e,o.preventDefault=Fe;q(i);){for(var a=0;a","","▼
",""].join(""),a=function(){var e="";if(r)for(var t=1;t<=6;t++)e+="
";return[""].join("")}();function l(t,o,n,r){for(var s=[],a=0;a ')}else{s.push(e("
").append(e(' ').attr("title",r.noColorSelectedText)).html())}}return""+s.join("")+"
"}function c(c,d){var g,f,v,b,y=function(t,n){var r=e.extend({},o,t);return r.callbacks={move:h(r.move,n),change:h(r.change,n),show:h(r.show,n),hide:h(r.hide,n),beforeShow:h(r.beforeShow,n)},r}(d,c),w=y.flat,_=y.showSelectionPalette,x=y.localStorageKey,C=y.theme,k=y.callbacks,S=(g=je,f=10,function(){var e=this,t=arguments,o=function(){b=null,g.apply(e,t)};v&&clearTimeout(b),!v&&b||(b=setTimeout(o,f))}),T=!1,E=!1,O=0,M=0,A=0,B=0,N=0,R=0,V=0,D=0,P=0,I=0,F=1,L=[],z=[],H={},Z=y.selectionPalette.slice(0),j=y.maxSelectionSize,U="sp-dragging",$=null,W=c.ownerDocument,q=(W.body,e(c)),G=!1,Y=e(a,W).addClass(C),K=Y.find(".sp-picker-container"),X=Y.find(".sp-color"),J=Y.find(".sp-dragger"),Q=Y.find(".sp-hue"),ee=Y.find(".sp-slider"),te=Y.find(".sp-alpha-inner"),oe=Y.find(".sp-alpha"),ne=Y.find(".sp-alpha-handle"),re=Y.find(".sp-input"),ie=Y.find(".sp-palette"),se=Y.find(".sp-initial"),ae=Y.find(".sp-cancel"),le=Y.find(".sp-clear"),ce=Y.find(".sp-choose"),de=Y.find(".sp-palette-toggle"),ue=q.is("input"),he=ue&&"color"===q.attr("type")&&p(),me=ue&&!w,pe=me?e(s).addClass(C).addClass(y.className).addClass(y.replacerClassName):e([]),ge=me?pe:q,fe=pe.find(".sp-preview-inner"),ve=y.color||ue&&q.val(),be=!1,ye=y.preferredFormat,we=!y.showButtons||y.clickoutFiresChange,_e=!ve,xe=y.allowEmpty&&!he;function Ce(){if(y.showPaletteOnly&&(y.showPalette=!0),de.text(y.showPaletteOnly?y.togglePaletteMoreText:y.togglePaletteLessText),y.palette){L=y.palette.slice(0),z=Array.isArray(L[0])?L:[L],H={};for(var e=0;e1&&(delete window.localStorage[x],e.each(t,(function(e,t){Se(t)})))}catch(e){}try{Z=window.localStorage[x].split(";")}catch(e){}}}function Se(t){if(_){var o=tinycolor(t).toRgbString();if(!H[o]&&-1===e.inArray(o,Z))for(Z.push(o);Z.length>j;)Z.shift();if(x&&window.localStorage)try{window.localStorage[x]=Z.join(";")}catch(e){}}}function Te(){var t=Fe(),o=e.map(z,(function(e,o){return l(e,t,"sp-palette-row sp-palette-row-"+o,y)}));ke(),Z&&o.push(l(function(){var e=[];if(y.showPalette)for(var t=0;tc&&c>r?Math.abs(h+r-c):0),{top:m-=Math.min(m,m+i>d&&d>i?Math.abs(i+s-n):n),bottom:u.bottom,left:h,right:u.right,width:u.width,height:u.height}}(Y,ge))),He(),y.showPalette&&Te(),q.trigger("reflow.spectrum"))}function Ue(){De(),G=!0,q.attr("disabled",!0),ge.addClass("sp-disabled")}!function(){if(r&&Y.find("*:not(input)").attr("unselectable","on"),Ce(),me&&q.after(pe).hide(),xe||le.hide(),w)q.after(Y).hide();else{var t="parent"===y.appendTo?q.parent():e(y.appendTo);1!==t.length&&(t=e("body")),t.append(Y)}function o(t){return t.data&&t.data.ignore?(Ie(e(t.target).closest(".sp-thumb-el").data("color")),Le()):(Ie(e(t.target).closest(".sp-thumb-el").data("color")),Le(),y.hideAfterPaletteSelect?(Ze(!0),De()):Ze()),!1}ke(),ge.on("click.spectrum touchstart.spectrum",(function(t){G||Be(),t.stopPropagation(),e(t.target).is("input")||t.preventDefault()})),(q.is(":disabled")||!0===y.disabled)&&Ue(),Y.on("click",u),re.on("change",Ae),re.on("paste",(function(){setTimeout(Ae,1)})),re.on("keydown",(function(e){13==e.keyCode&&Ae()})),ae.text(y.cancelText),ae.on("click.spectrum",(function(e){e.stopPropagation(),e.preventDefault(),Pe(),De()})),le.attr("title",y.clearText),le.on("click.spectrum",(function(e){e.stopPropagation(),e.preventDefault(),_e=!0,Le(),w&&Ze(!0)})),ce.text(y.chooseText),ce.on("click.spectrum",(function(e){e.stopPropagation(),e.preventDefault(),r&&re.is(":focus")&&re.trigger("change"),!re.hasClass("sp-validation-error")&&(Ze(!0),De())})),de.text(y.showPaletteOnly?y.togglePaletteMoreText:y.togglePaletteLessText),de.on("click.spectrum",(function(e){e.stopPropagation(),e.preventDefault(),y.showPaletteOnly=!y.showPaletteOnly,y.showPaletteOnly||w||Y.css("left","-="+(K.outerWidth(!0)+5)),Ce()})),m(oe,(function(e,t,o){F=e/N,_e=!1,o.shiftKey&&(F=Math.round(10*F)/10),Le()}),Oe,Me),m(Q,(function(e,t){D=parseFloat(t/B),_e=!1,y.showAlpha||(F=1),Le()}),Oe,Me),m(X,(function(e,t,o){if(o.shiftKey){if(!$){var n=P*O,r=M-I*M,i=Math.abs(e-n)>Math.abs(t-r);$=i?"x":"y"}}else $=null;var s=!$||"y"===$;(!$||"x"===$)&&(P=parseFloat(e/O)),s&&(I=parseFloat((M-t)/M)),_e=!1,y.showAlpha||(F=1),Le()}),Oe,Me),ve?(Ie(ve),ze(),ye=y.preferredFormat||tinycolor(ve).format,Se(ve)):ze(),w&&Ne();var n=r?"mousedown.spectrum":"click.spectrum touchstart.spectrum";ie.on(n,".sp-thumb-el",o),se.on(n,".sp-thumb-el:nth-child(1)",{ignore:!0},o)}();var $e={show:Ne,hide:De,toggle:Be,reflow:je,option:function(o,n){return o===t?e.extend({},y):n===t?y[o]:(y[o]=n,"preferredFormat"===o&&(ye=y.preferredFormat),void Ce())},enable:function(){G=!1,q.attr("disabled",!1),ge.removeClass("sp-disabled")},disable:Ue,offset:function(e){y.offset=e,je()},set:function(e){Ie(e),Ze()},get:Fe,destroy:function(){q.show(),ge.off("click.spectrum touchstart.spectrum"),Y.remove(),pe.remove(),n[$e.id]=null},container:Y};return $e.id=n.push($e)-1,$e}function d(){}function u(e){e.stopPropagation()}function h(e,t){var o=Array.prototype.slice,n=o.call(arguments,2);return function(){return e.apply(t,n.concat(o.call(arguments)))}}function m(t,o,n,i){o=o||function(){},n=n||function(){},i=i||function(){};var s=document,a=!1,l={},c=0,d=0,u="ontouchstart"in window,h={};function m(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault(),e.returnValue=!1}function p(e){if(a){if(r&&s.documentMode<9&&!e.button)return g();var n=e.originalEvent&&e.originalEvent.touches&&e.originalEvent.touches[0],i=n&&n.pageX||e.pageX,h=n&&n.pageY||e.pageY,p=Math.max(0,Math.min(i-l.left,d)),f=Math.max(0,Math.min(h-l.top,c));u&&m(e),o.apply(t,[p,f,e])}}function g(){a&&(e(s).off(h),e(s.body).removeClass("sp-dragging"),setTimeout((function(){i.apply(t,arguments)}),0)),a=!1}h.selectstart=m,h.dragstart=m,h["touchmove mousemove"]=p,h["touchend mouseup"]=g,e(t).on("touchstart mousedown",(function(o){(o.which?3==o.which:2==o.button)||a||!1!==n.apply(t,arguments)&&(a=!0,c=e(t).height(),d=e(t).width(),l=e(t).offset(),e(s).on(h),e(s.body).addClass("sp-dragging"),p(o),m(o))}))}function p(){return e.fn.spectrum.inputTypeColorSupport()}var g="spectrum.id";e.fn.spectrum=function(t,o){if("string"==typeof t){var r=this,i=Array.prototype.slice.call(arguments,1);return this.each((function(){var o=n[e(this).data(g)];if(o){var s=o[t];if(!s)throw new Error("Spectrum: no such method: '"+t+"'");"get"==t?r=o.get():"container"==t?r=o.container:"option"==t?r=o.option.apply(o,i):"destroy"==t?(o.destroy(),e(this).removeData(g)):s.apply(o,i)}})),r}return this.spectrum("destroy").each((function(){var o=c(this,e.extend({},e(this).data(),t));e(this).data(g,o.id)}))},e.fn.spectrum.load=!0,e.fn.spectrum.loadOpts={},e.fn.spectrum.draggable=m,e.fn.spectrum.defaults=o,e.fn.spectrum.inputTypeColorSupport=function t(){if(void 0===t._cachedResult){var o=e(" ")[0];t._cachedResult="color"===o.type&&""!==o.value}return t._cachedResult},e.spectrum={},e.spectrum.localization={},e.spectrum.palettes={},e.fn.spectrum.processNativeColorInputs=function(){var t=e("input[type=color]");t.length&&!p()&&t.spectrum({preferredFormat:"hex6"})},function(){var e=/^[\s,#]+/,t=/\s+$/,o=0,n=Math,r=n.round,i=n.min,s=n.max,a=n.random,l=function(a,c){if(c=c||{},(a=a||"")instanceof l)return a;if(!(this instanceof l))return new l(a,c);var d=function(o){var r={r:0,g:0,b:0},a=1,l=!1,c=!1;return"string"==typeof o&&(o=function(o){o=o.replace(e,"").replace(t,"").toLowerCase();var n,r=!1;if(T[o])o=T[o],r=!0;else if("transparent"==o)return{r:0,g:0,b:0,a:0,format:"name"};return(n=F.rgb.exec(o))?{r:n[1],g:n[2],b:n[3]}:(n=F.rgba.exec(o))?{r:n[1],g:n[2],b:n[3],a:n[4]}:(n=F.hsl.exec(o))?{h:n[1],s:n[2],l:n[3]}:(n=F.hsla.exec(o))?{h:n[1],s:n[2],l:n[3],a:n[4]}:(n=F.hsv.exec(o))?{h:n[1],s:n[2],v:n[3]}:(n=F.hsva.exec(o))?{h:n[1],s:n[2],v:n[3],a:n[4]}:(n=F.hex8.exec(o))?{a:V(n[1]),r:B(n[2]),g:B(n[3]),b:B(n[4]),format:r?"name":"hex8"}:(n=F.hex6.exec(o))?{r:B(n[1]),g:B(n[2]),b:B(n[3]),format:r?"name":"hex"}:!!(n=F.hex3.exec(o))&&{r:B(n[1]+""+n[1]),g:B(n[2]+""+n[2]),b:B(n[3]+""+n[3]),format:r?"name":"hex"}}(o)),"object"==typeof o&&(o.hasOwnProperty("r")&&o.hasOwnProperty("g")&&o.hasOwnProperty("b")?(d=o.r,u=o.g,h=o.b,r={r:255*M(d,255),g:255*M(u,255),b:255*M(h,255)},l=!0,c="%"===String(o.r).substr(-1)?"prgb":"rgb"):o.hasOwnProperty("h")&&o.hasOwnProperty("s")&&o.hasOwnProperty("v")?(o.s=R(o.s),o.v=R(o.v),r=function(e,t,o){e=6*M(e,360),t=M(t,100),o=M(o,100);var r=n.floor(e),i=e-r,s=o*(1-t),a=o*(1-i*t),l=o*(1-(1-i)*t),c=r%6;return{r:255*[o,a,s,s,l,o][c],g:255*[l,o,o,a,s,s][c],b:255*[s,s,l,o,o,a][c]}}(o.h,o.s,o.v),l=!0,c="hsv"):o.hasOwnProperty("h")&&o.hasOwnProperty("s")&&o.hasOwnProperty("l")&&(o.s=R(o.s),o.l=R(o.l),r=function(e,t,o){var n,r,i;function s(e,t,o){return o<0&&(o+=1),o>1&&(o-=1),o<1/6?e+6*(t-e)*o:o<.5?t:o<2/3?e+(t-e)*(2/3-o)*6:e}if(e=M(e,360),t=M(t,100),o=M(o,100),0===t)n=r=i=o;else{var a=o<.5?o*(1+t):o+t-o*t,l=2*o-a;n=s(l,a,e+1/3),r=s(l,a,e),i=s(l,a,e-1/3)}return{r:255*n,g:255*r,b:255*i}}(o.h,o.s,o.l),l=!0,c="hsl"),o.hasOwnProperty("a")&&(a=o.a)),a=O(a),{ok:l,format:o.format||c,r:i(255,s(r.r,0)),g:i(255,s(r.g,0)),b:i(255,s(r.b,0)),a:a};var d,u,h}(a);this._originalInput=a,this._r=d.r,this._g=d.g,this._b=d.b,this._a=d.a,this._roundA=r(1e3*this._a)/1e3,this._format=c.format||d.format,this._gradientType=c.gradientType,this._r<1&&(this._r=r(this._r)),this._g<1&&(this._g=r(this._g)),this._b<1&&(this._b=r(this._b)),this._ok=d.ok,this._tc_id=o++};function c(e,t,o){e=M(e,255),t=M(t,255),o=M(o,255);var n,r,a=s(e,t,o),l=i(e,t,o),c=(a+l)/2;if(a==l)n=r=0;else{var d=a-l;switch(r=c>.5?d/(2-a-l):d/(a+l),a){case e:n=(t-o)/d+(t>1)+720)%360;--t;)n.h=(n.h+r)%360,i.push(l(n));return i}function S(e,t){t=t||6;for(var o=l(e).toHsv(),n=o.h,r=o.s,i=o.v,s=[],a=1/t;t--;)s.push(l({h:n,s:r,v:i})),i=(i+a)%1;return s}l.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(299*e.r+587*e.g+114*e.b)/1e3},setAlpha:function(e){return this._a=O(e),this._roundA=r(1e3*this._a)/1e3,this},toHsv:function(){var e=d(this._r,this._g,this._b);return{h:360*e.h,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=d(this._r,this._g,this._b),t=r(360*e.h),o=r(100*e.s),n=r(100*e.v);return 1==this._a?"hsv("+t+", "+o+"%, "+n+"%)":"hsva("+t+", "+o+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var e=c(this._r,this._g,this._b);return{h:360*e.h,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=c(this._r,this._g,this._b),t=r(360*e.h),o=r(100*e.s),n=r(100*e.l);return 1==this._a?"hsl("+t+", "+o+"%, "+n+"%)":"hsla("+t+", "+o+"%, "+n+"%, "+this._roundA+")"},toHex:function(e){return u(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(){return h(this._r,this._g,this._b,this._a)},toHex8String:function(){return"#"+this.toHex8()},toRgb:function(){return{r:r(this._r),g:r(this._g),b:r(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+r(this._r)+", "+r(this._g)+", "+r(this._b)+")":"rgba("+r(this._r)+", "+r(this._g)+", "+r(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:r(100*M(this._r,255))+"%",g:r(100*M(this._g,255))+"%",b:r(100*M(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+r(100*M(this._r,255))+"%, "+r(100*M(this._g,255))+"%, "+r(100*M(this._b,255))+"%)":"rgba("+r(100*M(this._r,255))+"%, "+r(100*M(this._g,255))+"%, "+r(100*M(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(E[u(this._r,this._g,this._b,!0)]||!1)},toFilter:function(e){var t="#"+h(this._r,this._g,this._b,this._a),o=t,n=this._gradientType?"GradientType = 1, ":"";return e&&(o=l(e).toHex8String()),"progid:DXImageTransform.Microsoft.gradient("+n+"startColorstr="+t+",endColorstr="+o+")"},toString:function(e){var t=!!e;e=e||this._format;var o=!1,n=this._a<1&&this._a>=0;return t||!n||"hex"!==e&&"hex6"!==e&&"hex3"!==e&&"name"!==e?("rgb"===e&&(o=this.toRgbString()),"prgb"===e&&(o=this.toPercentageRgbString()),"hex"!==e&&"hex6"!==e||(o=this.toHexString()),"hex3"===e&&(o=this.toHexString(!0)),"hex8"===e&&(o=this.toHex8String()),"name"===e&&(o=this.toName()),"hsl"===e&&(o=this.toHslString()),"hsv"===e&&(o=this.toHsvString()),o||this.toHexString()):"name"===e&&0===this._a?this.toName():this.toRgbString()},_applyModification:function(e,t){var o=e.apply(null,[this].concat([].slice.call(t)));return this._r=o._r,this._g=o._g,this._b=o._b,this.setAlpha(o._a),this},lighten:function(){return this._applyModification(f,arguments)},brighten:function(){return this._applyModification(v,arguments)},darken:function(){return this._applyModification(b,arguments)},desaturate:function(){return this._applyModification(m,arguments)},saturate:function(){return this._applyModification(p,arguments)},greyscale:function(){return this._applyModification(g,arguments)},spin:function(){return this._applyModification(y,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(k,arguments)},complement:function(){return this._applyCombination(w,arguments)},monochromatic:function(){return this._applyCombination(S,arguments)},splitcomplement:function(){return this._applyCombination(C,arguments)},triad:function(){return this._applyCombination(_,arguments)},tetrad:function(){return this._applyCombination(x,arguments)}},l.fromRatio=function(e,t){if("object"==typeof e){var o={};for(var n in e)e.hasOwnProperty(n)&&(o[n]="a"===n?e[n]:R(e[n]));e=o}return l(e,t)},l.equals=function(e,t){return!(!e||!t)&&l(e).toRgbString()==l(t).toRgbString()},l.random=function(){return l.fromRatio({r:a(),g:a(),b:a()})},l.mix=function(e,t,o){o=0===o?0:o||50;var n,r=l(e).toRgb(),i=l(t).toRgb(),s=o/100,a=2*s-1,c=i.a-r.a,d=1-(n=((n=a*c==-1?a:(a+c)/(1+a*c))+1)/2),u={r:i.r*n+r.r*d,g:i.g*n+r.g*d,b:i.b*n+r.b*d,a:i.a*s+r.a*(1-s)};return l(u)},l.readability=function(e,t){var o=l(e),n=l(t),r=o.toRgb(),i=n.toRgb(),s=o.getBrightness(),a=n.getBrightness(),c=Math.max(r.r,i.r)-Math.min(r.r,i.r)+Math.max(r.g,i.g)-Math.min(r.g,i.g)+Math.max(r.b,i.b)-Math.min(r.b,i.b);return{brightness:Math.abs(s-a),color:c}},l.isReadable=function(e,t){var o=l.readability(e,t);return o.brightness>125&&o.color>500},l.mostReadable=function(e,t){for(var o=null,n=0,r=!1,i=0;i125&&s.color>500,c=s.brightness/125*3+s.color/500;(a&&!r||a&&r&&c>n||!a&&!r&&c>n)&&(r=a,n=c,o=l(t[i]))}return o};var T=l.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},E=l.hexNames=function(e){var t={};for(var o in e)e.hasOwnProperty(o)&&(t[e[o]]=o);return t}(T);function O(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function M(e,t){(function(e){return"string"==typeof e&&-1!=e.indexOf(".")&&1===parseFloat(e)})(e)&&(e="100%");var o=function(e){return"string"==typeof e&&-1!=e.indexOf("%")}(e);return e=i(t,s(0,parseFloat(e))),o&&(e=parseInt(e*t,10)/100),n.abs(e-t)<1e-6?1:e%t/parseFloat(t)}function A(e){return i(1,s(0,e))}function B(e){return parseInt(e,16)}function N(e){return 1==e.length?"0"+e:""+e}function R(e){return e<=1&&(e=100*e+"%"),e}function V(e){return B(e)/255}var D,P,I,F=(P="[\\s|\\(]+("+(D="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+D+")[,|\\s]+("+D+")\\s*\\)?",I="[\\s|\\(]+("+D+")[,|\\s]+("+D+")[,|\\s]+("+D+")[,|\\s]+("+D+")\\s*\\)?",{rgb:new RegExp("rgb"+P),rgba:new RegExp("rgba"+I),hsl:new RegExp("hsl"+P),hsla:new RegExp("hsla"+I),hsv:new RegExp("hsv"+P),hsva:new RegExp("hsva"+I),hex3:/^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex8:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});window.tinycolor=l}(),e((function(){e.fn.spectrum.load&&e.fn.spectrum.processNativeColorInputs()}))},void 0===(i=n.apply(t,r))||(e.exports=i)}()},5271:function(e,t,o){o(51471)},51471:function(){!function(){"use strict";var e=window.mailpoetTinymce.util.Tools.resolve("mailpoetTinymce.ModelManager");const t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=n=e,(r=String).prototype.isPrototypeOf(o)||(null===(i=n.constructor)||void 0===i?void 0:i.name)===r.name)?"string":t;var o,n,r,i})(t)===e,o=e=>t=>typeof t===e,n=e=>t=>e===t,r=t("string"),i=t("object"),s=t("array"),a=n(null),l=o("boolean"),c=n(void 0),d=e=>!(e=>null==e)(e),u=o("function"),h=o("number"),m=()=>{},p=e=>()=>e,g=e=>e,f=(e,t)=>e===t;function v(e,...t){return(...o)=>{const n=t.concat(o);return e.apply(null,n)}}const b=e=>t=>!e(t),y=e=>e(),w=p(!1),_=p(!0);class x{constructor(e,t){this.tag=e,this.value=t}static some(e){return new x(!0,e)}static none(){return x.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?x.some(e(this.value)):x.none()}bind(e){return this.tag?e(this.value):x.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:x.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return d(e)?x.some(e):x.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}x.singletonNone=new x(!1);const C=Array.prototype.slice,k=Array.prototype.indexOf,S=Array.prototype.push,T=(e,t)=>{return o=e,n=t,k.call(o,n)>-1;var o,n},E=(e,t)=>{for(let o=0,n=e.length;o{const o=[];for(let n=0;n{const o=e.length,n=new Array(o);for(let r=0;r{for(let o=0,n=e.length;o{const o=[],n=[];for(let r=0,i=e.length;r{const o=[];for(let n=0,r=e.length;n(((e,t)=>{for(let o=e.length-1;o>=0;o--)t(e[o],o)})(e,((e,n)=>{o=t(o,e,n)})),o),V=(e,t,o)=>(A(e,((e,n)=>{o=t(o,e,n)})),o),D=(e,t)=>((e,t,o)=>{for(let n=0,r=e.length;n{for(let o=0,n=e.length;o{const t=[];for(let o=0,n=e.length;oI(M(e,t)),L=(e,t)=>{for(let o=0,n=e.length;o{const o={};for(let n=0,r=e.length;nt>=0&&tH(e,0),j=e=>H(e,e.length-1),U=(e,t)=>{for(let o=0;o{const o=$(e);for(let n=0,r=o.length;nY(e,((e,o)=>({k:o,v:t(e,o)}))),Y=(e,t)=>{const o={};return q(e,((e,n)=>{const r=t(e,n);o[r.k]=r.v})),o},K=(e,t)=>{const o=[];return q(e,((e,n)=>{o.push(t(e,n))})),o},X=e=>K(e,g),J=(e,t)=>W.call(e,t),Q="undefined"!=typeof window?window:Function("return this;")(),ee=(e,t)=>((e,t)=>{let o=null!=t?t:Q;for(let t=0;t{const t=ee("ownerDocument.defaultView",e);return i(e)&&((e=>((e,t)=>{const o=((e,t)=>ee(e,t))(e,t);if(null==o)throw new Error(e+" not available on this browser");return o})("HTMLElement",e))(t).prototype.isPrototypeOf(e)||/^HTML\w*Element$/.test(te(e).constructor.name))},ne=e=>e.dom.nodeName.toLowerCase(),re=e=>e.dom.nodeType,ie=e=>t=>re(t)===e,se=e=>8===re(e)||"#comment"===ne(e),ae=e=>le(e)&&oe(e.dom),le=ie(1),ce=ie(3),de=ie(9),ue=ie(11),he=e=>t=>le(t)&&ne(t)===e,me=(e,t,o)=>{if(!(r(o)||l(o)||h(o)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",o,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,o+"")},pe=(e,t,o)=>{me(e.dom,t,o)},ge=(e,t)=>{const o=e.dom;q(t,((e,t)=>{me(o,t,e)}))},fe=(e,t)=>{const o=e.dom.getAttribute(t);return null===o?void 0:o},ve=(e,t)=>x.from(fe(e,t)),be=(e,t)=>{e.dom.removeAttribute(t)},ye=e=>V(e.dom.attributes,((e,t)=>(e[t.name]=t.value,e)),{}),we=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},_e={fromHtml:(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return we(o.childNodes[0])},fromTag:(e,t)=>{const o=(t||document).createElement(e);return we(o)},fromText:(e,t)=>{const o=(t||document).createTextNode(e);return we(o)},fromDom:we,fromPoint:(e,t,o)=>x.from(e.dom.elementFromPoint(t,o)).map(we)},xe=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},Ce=e=>1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType||0===e.childElementCount,ke=(e,t)=>{const o=void 0===t?document:t.dom;return Ce(o)?x.none():x.from(o.querySelector(e)).map(_e.fromDom)},Se=(e,t)=>e.dom===t.dom,Te=(e,t)=>{const o=e.dom,n=t.dom;return o!==n&&o.contains(n)},Ee=xe,Oe=e=>_e.fromDom(e.dom.ownerDocument),Me=e=>de(e)?e:Oe(e),Ae=e=>x.from(e.dom.parentNode).map(_e.fromDom),Be=e=>x.from(e.dom.parentElement).map(_e.fromDom),Ne=(e,t)=>{const o=u(t)?t:w;let n=e.dom;const r=[];for(;null!==n.parentNode&&void 0!==n.parentNode;){const e=n.parentNode,t=_e.fromDom(e);if(r.push(t),!0===o(t))break;n=e}return r},Re=e=>x.from(e.dom.previousSibling).map(_e.fromDom),Ve=e=>x.from(e.dom.nextSibling).map(_e.fromDom),De=e=>M(e.dom.childNodes,_e.fromDom),Pe=(e,t)=>{const o=e.dom.childNodes;return x.from(o[t]).map(_e.fromDom)},Ie=(e,t)=>{Ae(e).each((o=>{o.dom.insertBefore(t.dom,e.dom)}))},Fe=(e,t)=>{Ve(e).fold((()=>{Ae(e).each((e=>{ze(e,t)}))}),(e=>{Ie(e,t)}))},Le=(e,t)=>{const o=(e=>Pe(e,0))(e);o.fold((()=>{ze(e,t)}),(o=>{e.dom.insertBefore(t.dom,o.dom)}))},ze=(e,t)=>{e.dom.appendChild(t.dom)},He=(e,t)=>{Ie(e,t),ze(t,e)},Ze=(e,t)=>{A(t,((o,n)=>{const r=0===n?e:t[n-1];Fe(r,o)}))},je=(e,t)=>{A(t,(t=>{ze(e,t)}))},Ue=e=>{e.dom.textContent="",A(De(e),(e=>{$e(e)}))},$e=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},We=e=>{const t=De(e);t.length>0&&Ze(e,t),$e(e)},qe=(e,t)=>_e.fromDom(e.dom.cloneNode(t)),Ge=e=>qe(e,!1),Ye=e=>qe(e,!0),Ke=(e,t)=>{const o=_e.fromTag(t),n=ye(e);return ge(o,n),o},Xe=["tfoot","thead","tbody","colgroup"],Je=(e,t,o)=>({element:e,rowspan:t,colspan:o}),Qe=(e,t,o)=>({element:e,cells:t,section:o}),et=(e,t,o)=>({element:e,isNew:t,isLocked:o}),tt=(e,t,o,n)=>({element:e,cells:t,section:o,isNew:n}),ot=u(Element.prototype.attachShadow)&&u(Node.prototype.getRootNode),nt=p(ot),rt=ot?e=>_e.fromDom(e.dom.getRootNode()):Me,it=e=>_e.fromDom(e.dom.host),st=e=>{const t=ce(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return(e=>{const t=rt(e);return ue(o=t)&&d(o.dom.host)?x.some(t):x.none();var o})(_e.fromDom(t)).fold((()=>o.body.contains(t)),(n=st,r=it,e=>n(r(e))));var n,r},at=e=>{const t=e.dom.body;if(null==t)throw new Error("Body is not available yet");return _e.fromDom(t)},lt=(e,t)=>{let o=[];return A(De(e),(e=>{t(e)&&(o=o.concat([e])),o=o.concat(lt(e,t))})),o},ct=(e,t,o)=>((e,o,n)=>N(Ne(e,n),(e=>xe(e,t))))(e,0,o),dt=(e,t)=>((e,o)=>N(De(e),(e=>xe(e,t))))(e),ut=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return Ce(o)?[]:M(o.querySelectorAll(e),_e.fromDom)})(t,e);var ht=(e,t,o,n,r)=>e(o,n)?x.some(o):u(r)&&r(o)?x.none():t(o,n,r);const mt=(e,t,o)=>{let n=e.dom;const r=u(o)?o:w;for(;n.parentNode;){n=n.parentNode;const e=_e.fromDom(n);if(t(e))return x.some(e);if(r(e))break}return x.none()},pt=(e,t,o)=>ht(((e,t)=>t(e)),mt,e,t,o),gt=(e,t,o)=>mt(e,(e=>xe(e,t)),o),ft=(e,t)=>((e,o)=>D(e.dom.childNodes,(e=>{return o=_e.fromDom(e),xe(o,t);var o})).map(_e.fromDom))(e),vt=(e,t)=>ke(t,e),bt=(e,t,o)=>ht(((e,t)=>xe(e,t)),gt,e,t,o),yt=(e,t,o=f)=>e.exists((e=>o(e,t))),wt=e=>{const t=[],o=e=>{t.push(e)};for(let t=0;te?x.some(t):x.none(),xt=(e,t,o)=>""===t||e.length>=t.length&&e.substr(o,o+t.length)===t,Ct=(e,t,o=0,n)=>{const r=e.indexOf(t,o);return-1!==r&&(!!c(n)||r+t.length<=n)},kt=(e,t)=>xt(e,t,0),St=(e,t)=>xt(e,t,e.length-t.length),Tt=(e=>t=>t.replace(e,""))(/^\s+|\s+$/g),Et=e=>e.length>0,Ot=e=>void 0!==e.style&&u(e.style.getPropertyValue),Mt=(e,t,o)=>{if(!r(o))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",o,":: Element ",e),new Error("CSS value must be a string: "+o);Ot(e)&&e.style.setProperty(t,o)},At=(e,t,o)=>{const n=e.dom;Mt(n,t,o)},Bt=(e,t)=>{const o=e.dom;q(t,((e,t)=>{Mt(o,t,e)}))},Nt=(e,t)=>{const o=e.dom,n=window.getComputedStyle(o).getPropertyValue(t);return""!==n||st(e)?n:Rt(o,t)},Rt=(e,t)=>Ot(e)?e.style.getPropertyValue(t):"",Vt=(e,t)=>{const o=e.dom,n=Rt(o,t);return x.from(n).filter((e=>e.length>0))},Dt=(e,t)=>{((e,t)=>{Ot(e)&&e.style.removeProperty(t)})(e.dom,t),yt(ve(e,"style").map(Tt),"")&&be(e,"style")},Pt=(e,t,o=0)=>ve(e,t).map((e=>parseInt(e,10))).getOr(o),It=(e,t)=>Pt(e,t,1),Ft=e=>he("col")(e)?Pt(e,"span",1)>1:It(e,"colspan")>1,Lt=e=>It(e,"rowspan")>1,zt=(e,t)=>parseInt(Nt(e,t),10),Ht=p(10),Zt=p(10),jt=(e,t)=>Ut(e,t,_),Ut=(e,t,o)=>F(De(e),(e=>xe(e,t)?o(e)?[e]:[]:Ut(e,t,o))),$t=(e,t)=>((e,t,o=w)=>o(t)?x.none():T(e,ne(t))?x.some(t):gt(t,e.join(","),(e=>xe(e,"table")||o(e))))(["td","th"],e,t),Wt=e=>jt(e,"th,td"),qt=e=>xe(e,"colgroup")?dt(e,"col"):F(Kt(e),(e=>dt(e,"col"))),Gt=(e,t)=>bt(e,"table",t),Yt=e=>jt(e,"tr"),Kt=e=>Gt(e).fold(p([]),(e=>dt(e,"colgroup"))),Xt=(e,t)=>M(e,(e=>{if("colgroup"===ne(e)){const t=M(qt(e),(e=>{const t=Pt(e,"span",1);return Je(e,1,t)}));return Qe(e,t,"colgroup")}{const o=M(Wt(e),(e=>{const t=Pt(e,"rowspan",1),o=Pt(e,"colspan",1);return Je(e,t,o)}));return Qe(e,o,t(e))}})),Jt=e=>Ae(e).map((e=>{const t=ne(e);return(e=>T(Xe,e))(t)?t:"tbody"})).getOr("tbody"),Qt=e=>{const t=Yt(e),o=[...Kt(e),...t];return Xt(o,Jt)},eo=e=>{let t,o=!1;return(...n)=>(o||(o=!0,t=e.apply(null,n)),t)},to=()=>oo(0,0),oo=(e,t)=>({major:e,minor:t}),no={nu:oo,detect:(e,t)=>{const o=String(t).toLowerCase();return 0===e.length?to():((e,t)=>{const o=((e,t)=>{for(let o=0;oNumber(t.replace(o,"$"+e));return oo(n(1),n(2))})(e,o)},unknown:to},ro=(e,t)=>{const o=String(t).toLowerCase();return D(e,(e=>e.search(o)))},io=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,so=e=>t=>Ct(t,e),ao=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:e=>Ct(e,"edge/")&&Ct(e,"chrome")&&Ct(e,"safari")&&Ct(e,"applewebkit")},{name:"Chromium",brand:"Chromium",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,io],search:e=>Ct(e,"chrome")&&!Ct(e,"chromeframe")},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:e=>Ct(e,"msie")||Ct(e,"trident")},{name:"Opera",versionRegexes:[io,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:so("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:so("firefox")},{name:"Safari",versionRegexes:[io,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:e=>(Ct(e,"safari")||Ct(e,"mobile/"))&&Ct(e,"applewebkit")}],lo=[{name:"Windows",search:so("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:e=>Ct(e,"iphone")||Ct(e,"ipad"),versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:so("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"macOS",search:so("mac os x"),versionRegexes:[/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:so("linux"),versionRegexes:[]},{name:"Solaris",search:so("sunos"),versionRegexes:[]},{name:"FreeBSD",search:so("freebsd"),versionRegexes:[]},{name:"ChromeOS",search:so("cros"),versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/]}],co={browsers:p(ao),oses:p(lo)},uo="Edge",ho="Chromium",mo="Opera",po="Firefox",go="Safari",fo=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isEdge:n(uo),isChromium:n(ho),isIE:n("IE"),isOpera:n(mo),isFirefox:n(po),isSafari:n(go)}},vo=()=>fo({current:void 0,version:no.unknown()}),bo=fo,yo=(p(uo),p(ho),p("IE"),p(mo),p(po),p(go),"Windows"),wo="Android",_o="Linux",xo="macOS",Co="Solaris",ko="FreeBSD",So="ChromeOS",To=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isWindows:n(yo),isiOS:n("iOS"),isAndroid:n(wo),isMacOS:n(xo),isLinux:n(_o),isSolaris:n(Co),isFreeBSD:n(ko),isChromeOS:n(So)}},Eo=()=>To({current:void 0,version:no.unknown()}),Oo=To,Mo=(p(yo),p("iOS"),p(wo),p(_o),p(xo),p(Co),p(ko),p(So),e=>window.matchMedia(e).matches);let Ao=eo((()=>((e,t,o)=>{const n=co.browsers(),r=co.oses(),i=t.bind((e=>((e,t)=>U(t.brands,(t=>{const o=t.brand.toLowerCase();return D(e,(e=>{var t;return o===(null===(t=e.brand)||void 0===t?void 0:t.toLowerCase())})).map((e=>({current:e.name,version:no.nu(parseInt(t.version,10),0)})))})))(n,e))).orThunk((()=>((e,t)=>ro(e,t).map((e=>{const o=no.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(n,e))).fold(vo,bo),s=((e,t)=>ro(e,t).map((e=>{const o=no.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(r,e).fold(Eo,Oo),a=((e,t,o,n)=>{const r=e.isiOS()&&!0===/ipad/i.test(o),i=e.isiOS()&&!r,s=e.isiOS()||e.isAndroid(),a=s||n("(pointer:coarse)"),l=r||!i&&s&&n("(min-device-width:768px)"),c=i||s&&!l,d=t.isSafari()&&e.isiOS()&&!1===/safari/i.test(o),u=!c&&!l&&!d;return{isiPad:p(r),isiPhone:p(i),isTablet:p(l),isPhone:p(c),isTouch:p(a),isAndroid:e.isAndroid,isiOS:e.isiOS,isWebView:p(d),isDesktop:p(u)}})(s,i,e,o);return{browser:i,os:s,deviceType:a}})(navigator.userAgent,x.from(navigator.userAgentData),Mo)));const Bo=()=>Ao(),No=(e,t)=>{const o=o=>{const n=t(o);if(n<=0||null===n){const t=Nt(o,e);return parseFloat(t)||0}return n},n=(e,t)=>V(t,((t,o)=>{const n=Nt(e,o),r=void 0===n?0:parseInt(n,10);return isNaN(r)?t:t+r}),0);return{set:(t,o)=>{if(!h(o)&&!o.match(/^[0-9]+$/))throw new Error(e+".set accepts only positive integer values. Value was "+o);const n=t.dom;Ot(n)&&(n.style[e]=o+"px")},get:o,getOuter:o,aggregate:n,max:(e,t,o)=>{const r=n(e,o);return t>r?t-r:0}}},Ro=(e,t,o)=>((e,t)=>(e=>{const t=parseFloat(e);return isNaN(t)?x.none():x.some(t)})(e).getOr(t))(Nt(e,t),o),Vo=No("width",(e=>e.dom.offsetWidth)),Do=e=>Vo.get(e),Po=e=>Vo.getOuter(e),Io=e=>((e,t)=>{const o=e.dom,n=o.getBoundingClientRect().width||o.offsetWidth;return"border-box"===t?n:((e,t,o,n)=>t-Ro(e,`padding-${o}`,0)-Ro(e,`padding-${n}`,0)-Ro(e,`border-${o}-width`,0)-Ro(e,`border-${n}-width`,0))(e,n,"left","right")})(e,"content-box"),Fo=(e,t,o)=>{const n=e.cells,r=n.slice(0,t),i=n.slice(t),s=r.concat(o).concat(i);return Ho(e,s)},Lo=(e,t,o)=>Fo(e,t,[o]),zo=(e,t,o)=>{e.cells[t]=o},Ho=(e,t)=>tt(e.element,t,e.section,e.isNew),Zo=(e,t)=>e.cells[t],jo=(e,t)=>Zo(e,t).element,Uo=e=>e.cells.length,$o=e=>{const t=B(e,(e=>"colgroup"===e.section));return{rows:t.fail,cols:t.pass}},Wo=(e,t,o)=>{const n=M(e.cells,o);return tt(t(e.element),n,e.section,!0)},qo="data-snooker-locked-cols",Go=e=>ve(e,qo).bind((e=>x.from(e.match(/\d+/g)))).map((e=>z(e,_))),Yo=e=>{const t=V($o(e).rows,((e,t)=>(A(t.cells,((t,o)=>{t.isLocked&&(e[o]=!0)})),e)),{}),o=K(t,((e,t)=>parseInt(t,10)));return((e,t)=>{const o=C.call(e,0);return o.sort(void 0),o})(o)},Ko=(e,t)=>e+","+t,Xo=(e,t)=>{const o=F(e.all,(e=>e.cells));return N(o,t)},Jo=e=>{const t={},o=[],n=Z(e).map((e=>e.element)).bind(Gt).bind(Go).getOr({});let r=0,i=0,s=0;const{pass:a,fail:l}=B(e,(e=>"colgroup"===e.section));A(l,(e=>{const a=[];A(e.cells,(e=>{let o=0;for(;void 0!==t[Ko(s,o)];)o++;const r=((e,t)=>J(e,t)&&void 0!==e[t]&&null!==e[t])(n,o.toString()),l=((e,t,o,n,r,i)=>({element:e,rowspan:t,colspan:o,row:n,column:r,isLocked:i}))(e.element,e.rowspan,e.colspan,s,o,r);for(let n=0;n{const t=(e=>{const t={};let o=0;return A(e.cells,(e=>{const n=e.colspan;O(n,(r=>{const i=o+r;t[i]=((e,t,o)=>({element:e,colspan:t,column:o}))(e.element,n,i)})),o+=n})),t})(e),o=((e,t)=>({element:e,columns:t}))(e.element,X(t));return{colgroups:[o],columns:t}})).getOrThunk((()=>({colgroups:[],columns:{}}))),u=((e,t)=>({rows:e,columns:t}))(r,i);return{grid:u,access:t,all:o,columns:c,colgroups:d}},Qo=e=>{const t=Qt(e);return Jo(t)},en=Jo,tn=(e,t,o)=>x.from(e.access[Ko(t,o)]),on=(e,t,o)=>{const n=Xo(e,(e=>o(t,e.element)));return n.length>0?x.some(n[0]):x.none()},nn=Xo,rn=e=>F(e.all,(e=>e.cells)),sn=e=>X(e.columns),an=e=>$(e.columns).length>0,ln=(e,t)=>x.from(e.columns[t]),cn=(e,t=_)=>{const o=e.grid,n=O(o.columns,g),r=O(o.rows,g);return M(n,(o=>dn((()=>F(r,(t=>tn(e,t,o).filter((e=>e.column===o)).toArray()))),(e=>1===e.colspan&&t(e.element)),(()=>tn(e,0,o)))))},dn=(e,t,o)=>{const n=e();return D(n,t).orThunk((()=>x.from(n[0]).orThunk(o))).map((e=>e.element))},un=e=>{const t=e.grid,o=O(t.rows,g),n=O(t.columns,g);return M(o,(t=>dn((()=>F(n,(o=>tn(e,t,o).filter((e=>e.row===t)).fold(p([]),(e=>[e]))))),(e=>1===e.rowspan),(()=>tn(e,t,0)))))},hn=(e,t)=>o=>"rtl"===mn(o)?t:e,mn=e=>"rtl"===Nt(e,"direction")?"rtl":"ltr",pn=No("height",(e=>{const t=e.dom;return st(e)?t.getBoundingClientRect().height:t.offsetHeight})),gn=e=>pn.get(e),fn=e=>pn.getOuter(e),vn=(e,t)=>({left:e,top:t,translate:(o,n)=>vn(e+o,t+n)}),bn=vn,yn=(e,t)=>void 0!==e?e:void 0!==t?t:0,wn=e=>{const t=e.dom.ownerDocument,o=t.body,n=t.defaultView,r=t.documentElement;if(o===e.dom)return bn(o.offsetLeft,o.offsetTop);const i=yn(null==n?void 0:n.pageYOffset,r.scrollTop),s=yn(null==n?void 0:n.pageXOffset,r.scrollLeft),a=yn(r.clientTop,o.clientTop),l=yn(r.clientLeft,o.clientLeft);return _n(e).translate(s-l,i-a)},_n=e=>{const t=e.dom,o=t.ownerDocument.body;return o===t?bn(o.offsetLeft,o.offsetTop):st(e)?(e=>{const t=e.getBoundingClientRect();return bn(t.left,t.top)})(t):bn(0,0)},xn=(e,t)=>({row:e,y:t}),Cn=(e,t)=>({col:e,x:t}),kn=e=>wn(e).left+Po(e),Sn=e=>wn(e).left,Tn=(e,t)=>Cn(e,Sn(t)),En=(e,t)=>Cn(e,kn(t)),On=e=>wn(e).top,Mn=(e,t)=>xn(e,On(t)),An=(e,t)=>xn(e,On(t)+fn(t)),Bn=(e,t,o)=>{if(0===o.length)return[];const n=M(o.slice(1),((t,o)=>t.map((t=>e(o,t))))),r=o[o.length-1].map((e=>t(o.length-1,e)));return n.concat([r])},Nn={delta:g,positions:e=>Bn(Mn,An,e),edge:On},Rn=hn({delta:g,edge:Sn,positions:e=>Bn(Tn,En,e)},{delta:e=>-e,edge:kn,positions:e=>Bn(En,Tn,e)}),Vn={delta:(e,t)=>Rn(t).delta(e,t),positions:(e,t)=>Rn(t).positions(e,t),edge:e=>Rn(e).edge(e)},Dn={unsupportedLength:["em","ex","cap","ch","ic","rem","lh","rlh","vw","vh","vi","vb","vmin","vmax","cm","mm","Q","in","pc","pt","px"],fixed:["px","pt"],relative:["%"],empty:[""]},Pn=(()=>{const e="[0-9]+",t="[eE][+-]?"+e,o=e=>`(?:${e})?`,n=["Infinity",e+"\\."+o(e)+o(t),"\\."+e+o(t),e+o(t)].join("|");return new RegExp(`^([+-]?(?:${n}))(.*)$`)})(),In=/(\d+(\.\d+)?)%/,Fn=/(\d+(\.\d+)?)px|em/,Ln=he("col"),zn=(e,t,o)=>{const n=Be(e).getOrThunk((()=>at(Oe(e))));return t(e)/o(n)*100},Hn=(e,t)=>{At(e,"width",t+"px")},Zn=(e,t)=>{At(e,"width",t+"%")},jn=(e,t)=>{At(e,"height",t+"px")},Un=e=>{const t=(e=>{return Ro(t=e,"height",t.dom.offsetHeight)+"px";var t})(e);return t?((e,t,o,n)=>{const r=parseFloat(e);return St(e,"%")&&"table"!==ne(t)?((e,t,o,n)=>{const r=Gt(e).map((e=>{const n=o(e);return Math.floor(t/100*n)})).getOr(t);return n(e,r),r})(t,r,o,n):r})(t,e,gn,jn):gn(e)},$n=(e,t)=>Vt(e,t).orThunk((()=>ve(e,t).map((e=>e+"px")))),Wn=e=>$n(e,"width"),qn=e=>zn(e,Do,Io),Gn=e=>{return Ln(e)?Do(e):Ro(t=e,"width",t.dom.offsetWidth);var t},Yn=e=>((e,t,o)=>o(e)/It(e,"rowspan"))(e,0,Un),Kn=(e,t,o)=>{At(e,"width",t+o)},Xn=e=>zn(e,Do,Io)+"%",Jn=p(In),Qn=he("col"),er=e=>Wn(e).getOrThunk((()=>Gn(e)+"px")),tr=e=>{return(t=e,$n(t,"height")).getOrThunk((()=>Yn(e)+"px"));var t},or=(e,t,o,n,r,i)=>e.filter(n).fold((()=>i(((e,t)=>{if(t<0||t>=e.length-1)return x.none();const o=e[t].fold((()=>{const o=(e=>{const t=C.call(e,0);return t.reverse(),t})(e.slice(0,t));return U(o,((e,t)=>e.map((e=>({value:e,delta:t+1})))))}),(e=>x.some({value:e,delta:0}))),n=e[t+1].fold((()=>{const o=e.slice(t+1);return U(o,((e,t)=>e.map((e=>({value:e,delta:t+1})))))}),(e=>x.some({value:e,delta:1})));return o.bind((e=>n.map((t=>{const o=t.delta+e.delta;return Math.abs(t.value-e.value)/o}))))})(o,t))),(e=>r(e))),nr=(e,t,o,n)=>{const r=cn(e),i=an(e)?(e=>M(sn(e),(e=>x.from(e.element))))(e):r,s=[x.some(Vn.edge(t))].concat(M(Vn.positions(r,t),(e=>e.map((e=>e.x))))),a=b(Ft);return M(i,((e,t)=>or(e,t,s,a,(e=>{if((e=>{const t=Bo().browser,o=t.isChromium()||t.isFirefox();return!Qn(e)||o})(e))return o(e);{const e=null!=(i=r[t])?g(i):x.none();return or(e,t,s,a,(e=>n(x.some(Do(e)))),n)}var i}),n)))},rr=e=>e.map((e=>e+"px")).getOr(""),ir=(e,t,o)=>nr(e,t,Gn,(e=>e.getOrThunk(o.minCellWidth))),sr=(e,t,o,n,r)=>{const i=un(e),s=[x.some(o.edge(t))].concat(M(o.positions(i,t),(e=>e.map((e=>e.y)))));return M(i,((e,t)=>or(e,t,s,b(Lt),n,r)))},ar=(e,t)=>()=>st(e)?t(e):parseFloat(Vt(e,"width").getOr("0")),lr=e=>{const t=ar(e,(e=>parseFloat(Xn(e)))),o=ar(e,Do);return{width:t,pixelWidth:o,getWidths:(t,o)=>((e,t,o)=>nr(e,t,qn,(e=>e.fold((()=>o.minCellWidth()),(e=>e/o.pixelWidth()*100)))))(t,e,o),getCellDelta:e=>e/o()*100,singleColumnWidth:(e,t)=>[100-e],minCellWidth:()=>Ht()/o()*100,setElementWidth:Zn,adjustTableWidth:o=>{const n=t();Zn(e,n+o/100*n)},isRelative:!0,label:"percent"}},cr=e=>{const t=ar(e,Do);return{width:t,pixelWidth:t,getWidths:(t,o)=>ir(t,e,o),getCellDelta:g,singleColumnWidth:(e,t)=>[Math.max(Ht(),e+t)-e],minCellWidth:Ht,setElementWidth:Hn,adjustTableWidth:o=>{const n=t()+o;Hn(e,n)},isRelative:!1,label:"pixel"}},dr=e=>Wn(e).fold((()=>(e=>{const t=ar(e,Do),o=p(0);return{width:t,pixelWidth:t,getWidths:(t,o)=>ir(t,e,o),getCellDelta:o,singleColumnWidth:p([0]),minCellWidth:o,setElementWidth:m,adjustTableWidth:m,isRelative:!0,label:"none"}})(e)),(t=>((e,t)=>null!==Jn().exec(t)?lr(e):cr(e))(e,t))),ur=cr,hr=lr,mr=(e,t,o)=>{const n=e[o].element,r=_e.fromTag("td");ze(r,_e.fromTag("br")),(t?ze:Le)(n,r)},pr=((e,t)=>{const o=t=>e(t)?x.from(t.dom.nodeValue):x.none();return{get:t=>{if(!e(t))throw new Error("Can only get text value of a text node");return o(t).getOr("")},getOption:o,set:(t,o)=>{if(!e(t))throw new Error("Can only set raw text value of a text node");t.dom.nodeValue=o}}})(ce),gr=e=>pr.get(e),fr=e=>pr.getOption(e),vr=(e,t)=>pr.set(e,t),br=e=>"img"===ne(e)?1:fr(e).fold((()=>De(e).length),(e=>e.length)),yr=["img","br"],wr=e=>fr(e).filter((e=>0!==e.trim().length||e.indexOf(" ")>-1)).isSome()||T(yr,ne(e))||(e=>ae(e)&&"false"===fe(e,"contenteditable"))(e),_r=e=>((e,t)=>{const o=e=>{for(let n=0;nCr(e,wr),Cr=(e,t)=>{const o=e=>{const n=De(e);for(let e=n.length-1;e>=0;e--){const r=n[e];if(t(r))return x.some(r);const i=o(r);if(i.isSome())return i}return x.none()};return o(e)},kr={scope:["row","col"]},Sr=e=>()=>{const t=_e.fromTag("td",e.dom);return ze(t,_e.fromTag("br",e.dom)),t},Tr=e=>()=>_e.fromTag("col",e.dom),Er=e=>()=>_e.fromTag("colgroup",e.dom),Or=e=>()=>_e.fromTag("tr",e.dom),Mr=(e,t,o)=>{const n=((e,t)=>{const o=Ke(e,t),n=De(Ye(e));return je(o,n),o})(e,t);return q(o,((e,t)=>{null===e?be(n,t):pe(n,t,e)})),n},Ar=e=>e,Br=(e,t,o)=>{const n=(e,t)=>{((e,t)=>{const o=e.dom,n=t.dom;Ot(o)&&Ot(n)&&(n.style.cssText=o.style.cssText)})(e.element,t),Dt(t,"height"),1!==e.colspan&&Dt(t,"width")};return{col:o=>{const r=_e.fromTag(ne(o.element),t.dom);return n(o,r),e(o.element,r),r},colgroup:Er(t),row:Or(t),cell:r=>{const i=_e.fromTag(ne(r.element),t.dom),s=o.getOr(["strong","em","b","i","span","font","h1","h2","h3","h4","h5","h6","p","div"]),a=s.length>0?((e,t,o)=>_r(e).map((n=>{const r=o.join(","),i=ct(n,r,(t=>Se(t,e)));return R(i,((e,t)=>{const o=Ge(t);return ze(e,o),o}),t)})).getOr(t))(r.element,i,s):i;return ze(a,_e.fromTag("br")),n(r,i),((e,t)=>{q(kr,((o,n)=>ve(e,n).filter((e=>T(o,e))).each((e=>pe(t,n,e)))))})(r.element,i),e(r.element,i),i},replace:Mr,colGap:Tr(t),gap:Sr(t)}},Nr=e=>({col:Tr(e),colgroup:Er(e),row:Or(e),cell:Sr(e),replace:Ar,colGap:Tr(e),gap:Sr(e)}),Rr=e=>t=>t.options.get(e),Vr="100%",Dr=e=>{var t;const o=e.dom,n=null!==(t=o.getParent(e.selection.getStart(),o.isBlock))&&void 0!==t?t:e.getBody();return Io(_e.fromDom(n))+"px"},Pr=e=>x.from(e.options.get("table_clone_elements")),Ir=Rr("table_header_type"),Fr=Rr("table_column_resizing"),Lr=e=>"preservetable"===Fr(e),zr=e=>"resizetable"===Fr(e),Hr=Rr("table_sizing_mode"),Zr=e=>"relative"===Hr(e),jr=e=>"fixed"===Hr(e),Ur=e=>"responsive"===Hr(e),$r=Rr("table_resize_bars"),Wr=Rr("table_style_by_css"),qr=Rr("table_merge_content_on_paste"),Gr=e=>{const t=e.options,o=t.get("table_default_attributes");return t.isSet("table_default_attributes")?o:((e,t)=>Ur(e)||Wr(e)?t:jr(e)?{...t,width:Dr(e)}:{...t,width:Vr})(e,o)},Yr=Rr("table_use_colgroups"),Kr=e=>bt(e,"[contenteditable]"),Xr=(e,t=!1)=>st(e)?e.dom.isContentEditable:Kr(e).fold(p(t),(e=>"true"===Jr(e))),Jr=e=>e.dom.contentEditable,Qr=e=>_e.fromDom(e.getBody()),ei=e=>t=>Se(t,Qr(e)),ti=e=>{be(e,"data-mce-style");const t=e=>be(e,"data-mce-style");A(Wt(e),t),A(qt(e),t),A(Yt(e),t)},oi=e=>_e.fromDom(e.selection.getStart()),ni=e=>e.getBoundingClientRect().width,ri=e=>e.getBoundingClientRect().height,ii=e=>pt(e,he("table")).exists(Xr),si=(e,t)=>{const o=t.column,n=t.column+t.colspan-1,r=t.row,i=t.row+t.rowspan-1;return o<=e.finishCol&&n>=e.startCol&&r<=e.finishRow&&i>=e.startRow},ai=(e,t)=>t.column>=e.startCol&&t.column+t.colspan-1<=e.finishCol&&t.row>=e.startRow&&t.row+t.rowspan-1<=e.finishRow,li=(e,t,o)=>{const n=on(e,t,Se),r=on(e,o,Se);return n.bind((e=>r.map((t=>{return o=e,n=t,{startRow:Math.min(o.row,n.row),startCol:Math.min(o.column,n.column),finishRow:Math.max(o.row+o.rowspan-1,n.row+n.rowspan-1),finishCol:Math.max(o.column+o.colspan-1,n.column+n.colspan-1)};var o,n}))))},ci=(e,t,o)=>li(e,t,o).map((t=>{const o=nn(e,v(si,t));return M(o,(e=>e.element))})),di=(e,t)=>on(e,t,((e,t)=>Te(t,e))).map((e=>e.element)),ui=(e,t,o)=>{const n=mi(e);return ci(n,t,o)},hi=(e,t,o,n,r)=>{const i=mi(e),s=Se(e,o)?x.some(t):di(i,t),a=Se(e,r)?x.some(n):di(i,n);return s.bind((e=>a.bind((t=>ci(i,e,t)))))},mi=Qo;var pi=["body","p","div","article","aside","figcaption","figure","footer","header","nav","section","ol","ul","li","table","thead","tbody","tfoot","caption","tr","td","th","h1","h2","h3","h4","h5","h6","blockquote","pre","address"],gi=()=>({up:p({selector:gt,closest:bt,predicate:mt,all:Ne}),down:p({selector:ut,predicate:lt}),styles:p({get:Nt,getRaw:Vt,set:At,remove:Dt}),attrs:p({get:fe,set:pe,remove:be,copyTo:(e,t)=>{const o=ye(e);ge(t,o)}}),insert:p({before:Ie,after:Fe,afterAll:Ze,append:ze,appendAll:je,prepend:Le,wrap:He}),remove:p({unwrap:We,remove:$e}),create:p({nu:_e.fromTag,clone:e=>_e.fromDom(e.dom.cloneNode(!1)),text:_e.fromText}),query:p({comparePosition:(e,t)=>e.dom.compareDocumentPosition(t.dom),prevSibling:Re,nextSibling:Ve}),property:p({children:De,name:ne,parent:Ae,document:e=>Me(e).dom,isText:ce,isComment:se,isElement:le,isSpecial:e=>{const t=ne(e);return T(["script","noscript","iframe","noframes","noembed","title","style","textarea","xmp"],t)},getLanguage:e=>le(e)?ve(e,"lang"):x.none(),getText:gr,setText:vr,isBoundary:e=>!!le(e)&&("body"===ne(e)||T(pi,ne(e))),isEmptyTag:e=>!!le(e)&&T(["br","img","hr","input"],ne(e)),isNonEditable:e=>le(e)&&"false"===fe(e,"contenteditable")}),eq:Se,is:Ee});const fi=(e,t,o,n)=>{const r=t(e,o);return R(n,((o,n)=>{const r=t(e,n);return vi(e,o,r)}),r)},vi=(e,t,o)=>t.bind((t=>o.filter(v(e.eq,t)))),bi=gi(),yi=(e,t)=>((e,t,o)=>o.length>0?((e,t,o,n)=>n(e,t,o[0],o.slice(1)))(e,t,o,fi):x.none())(bi,((t,o)=>e(o)),t),wi=e=>gt(e,"table"),_i=(e,t,o)=>{const n=e=>t=>void 0!==o&&o(t)||Se(t,e);return Se(e,t)?x.some({boxes:x.some([e]),start:e,finish:t}):wi(e).bind((r=>wi(t).bind((i=>{if(Se(r,i))return x.some({boxes:ui(r,e,t),start:e,finish:t});if(Te(r,i)){const o=ct(t,"td,th",n(r)),s=o.length>0?o[o.length-1]:t;return x.some({boxes:hi(r,e,r,t,i),start:e,finish:s})}if(Te(i,r)){const o=ct(e,"td,th",n(i)),s=o.length>0?o[o.length-1]:e;return x.some({boxes:hi(i,e,r,t,i),start:e,finish:s})}return((e,t,o)=>((e,t,o,n=w)=>{const r=[t].concat(e.up().all(t)),i=[o].concat(e.up().all(o)),s=e=>P(e,n).fold((()=>e),(t=>e.slice(0,t+1))),a=s(r),l=s(i),c=D(a,(t=>E(l,((e,t)=>v(e.eq,t))(e,t))));return{firstpath:a,secondpath:l,shared:c}})(bi,e,t,void 0))(e,t).shared.bind((s=>bt(s,"table",o).bind((o=>{const s=ct(t,"td,th",n(o)),a=s.length>0?s[s.length-1]:t,l=ct(e,"td,th",n(o)),c=l.length>0?l[l.length-1]:e;return x.some({boxes:hi(o,e,r,t,i),start:c,finish:a})}))))}))))},xi=(e,t)=>{const o=ut(e,t);return o.length>0?x.some(o):x.none()},Ci=(e,t,o)=>vt(e,t).bind((t=>vt(e,o).bind((e=>yi(wi,[t,e]).map((o=>({first:t,last:e,table:o}))))))),ki=(e,t,o,n,r)=>((e,t)=>D(e,(e=>xe(e,t))))(e,r).bind((e=>((e,t,o)=>Gt(e).bind((n=>((e,t,o,n)=>on(e,t,Se).bind((t=>{const r=o>0?t.row+t.rowspan-1:t.row,i=n>0?t.column+t.colspan-1:t.column;return tn(e,r+o,i+n).map((e=>e.element))})))(mi(n),e,t,o))))(e,t,o).bind((e=>((e,t)=>gt(e,"table").bind((o=>vt(o,t).bind((t=>_i(t,e).bind((e=>e.boxes.map((t=>({boxes:t,start:e.start,finish:e.finish}))))))))))(e,n))))),Si=(e,t)=>xi(e,t),Ti=(e,t,o)=>Ci(e,t,o).bind((t=>{const o=t=>Se(e,t),n="thead,tfoot,tbody,table",r=gt(t.first,n,o),i=gt(t.last,n,o);return r.bind((e=>i.bind((o=>Se(e,o)?((e,t,o)=>((e,t,o)=>li(e,t,o).bind((t=>((e,t)=>{let o=!0;const n=v(ai,t);for(let r=t.startRow;r<=t.finishRow;r++)for(let i=t.startCol;i<=t.finishCol;i++)o=o&&tn(e,r,i).exists(n);return o?x.some(t):x.none()})(e,t))))(mi(e),t,o))(t.table,t.first,t.last):x.none()))))})),Ei=g,Oi=e=>{const t=(e,t)=>ve(e,t).exists((e=>parseInt(e,10)>1));return e.length>0&&L(e,(e=>t(e,"rowspan")||t(e,"colspan")))?x.some(e):x.none()},Mi=(e,t,o)=>t.length<=1?x.none():Ti(e,o.firstSelectedSelector,o.lastSelectedSelector).map((e=>({bounds:e,cells:t}))),Ai="data-mce-selected",Bi="data-mce-first-selected",Ni="data-mce-last-selected",Ri="["+Ai+"]",Vi={selected:Ai,selectedSelector:"td["+Ai+"],th["+Ai+"]",firstSelected:Bi,firstSelectedSelector:"td["+Bi+"],th["+Bi+"]",lastSelected:Ni,lastSelectedSelector:"td["+Ni+"],th["+Ni+"]"},Di=(e,t,o)=>({element:o,mergable:Mi(t,e,Vi),unmergable:Oi(e),selection:Ei(e)}),Pi=e=>(t,o)=>{const n=ne(t),r="col"===n||"colgroup"===n?Gt(i=t).bind((e=>Si(e,Vi.firstSelectedSelector))).fold(p(i),(e=>e[0])):t;var i;return bt(r,e,o)},Ii=Pi("th,td,caption"),Fi=Pi("th,td"),Li=e=>{return t=e.model.table.getSelectedCells(),M(t,_e.fromDom);var t},zi=(e,t)=>{e.on("BeforeGetContent",(t=>{const o=o=>{t.preventDefault(),(e=>Gt(e[0]).map((e=>{const t=((e,t)=>{const o=e=>xe(e.element,t),n=Ye(e),r=Qt(n),i=dr(e),s=en(r),a=((e,t)=>{const o=e.grid.columns;let n=e.grid.rows,r=o,i=0,s=0;const a=[],l=[];return q(e.access,(e=>{if(a.push(e),t(e)){l.push(e);const t=e.row,o=t+e.rowspan-1,a=e.column,c=a+e.colspan-1;ti&&(i=o),as&&(s=c)}})),((e,t,o,n,r,i)=>({minRow:e,minCol:t,maxRow:o,maxCol:n,allCells:r,selectedCells:i}))(n,r,i,s,a,l)})(s,o),l="th:not("+t+"),td:not("+t+")",c=Ut(n,"th,td",(e=>xe(e,l)));A(c,$e),((e,t,o,n)=>{const r=N(e,(e=>"colgroup"!==e.section)),i=t.grid.columns,s=t.grid.rows;for(let e=0;eo.maxRow||ao.maxCol||(tn(t,e,a).filter(n).isNone()?mr(r,s,e):s=!0)}})(r,s,a,o);const d=((e,t,o,n)=>{if(0===n.minCol&&t.grid.columns===n.maxCol+1)return 0;const r=ir(t,e,o),i=V(r,((e,t)=>e+t),0),s=V(r.slice(n.minCol,n.maxCol+1),((e,t)=>e+t),0),a=s/i*o.pixelWidth()-o.pixelWidth();return o.getCellDelta(a)})(e,Qo(e),i,a);return((e,t,o,n)=>{q(o.columns,(e=>{(e.columnt.maxCol)&&$e(e.element)}));const r=N(jt(e,"tr"),(e=>0===e.dom.childElementCount));A(r,$e),t.minCol!==t.maxCol&&t.minRow!==t.maxRow||A(jt(e,"th,td"),(e=>{be(e,"rowspan"),be(e,"colspan")})),be(e,qo),be(e,"data-snooker-col-series"),dr(e).adjustTableWidth(n)})(n,a,s,d),n})(e,Ri);return ti(t),[t]})))(o).each((o=>{t.content="text"===t.format?(e=>M(e,(e=>e.dom.innerText)).join(""))(o):((e,t)=>M(t,(t=>e.selection.serializer.serialize(t.dom,{}))).join(""))(e,o)}))};if(!0===t.selection){const t=(e=>N(Li(e),(e=>xe(e,Vi.selectedSelector))))(e);t.length>=1&&o(t)}})),e.on("BeforeSetContent",(o=>{if(!0===o.selection&&!0===o.paste){const n=Li(e);Z(n).each((n=>{Gt(n).each((r=>{const i=N(((e,t)=>{const o=document.createElement("div");return o.innerHTML=e,De(_e.fromDom(o))})(o.content),(e=>"meta"!==ne(e))),s=he("table");if(qr(e)&&1===i.length&&s(i[0])){o.preventDefault();const s=_e.fromDom(e.getDoc()),a=Nr(s),l=((e,t,o)=>({element:e,clipboard:t,generators:o}))(n,i[0],a);t.pasteCells(r,l).each((()=>{e.focus()}))}}))}))}}))},Hi=(e,t)=>({element:e,offset:t}),Zi=(e,t,o)=>e.property().isText(t)&&0===e.property().getText(t).trim().length||e.property().isComment(t)?o(t).bind((t=>Zi(e,t,o).orThunk((()=>x.some(t))))):x.none(),ji=(e,t)=>e.property().isText(t)?e.property().getText(t).length:e.property().children(t).length,Ui=(e,t)=>{const o=Zi(e,t,e.query().prevSibling).getOr(t);if(e.property().isText(o))return Hi(o,ji(e,o));const n=e.property().children(o);return n.length>0?Ui(e,n[n.length-1]):Hi(o,ji(e,o))},$i=Ui,Wi=gi(),qi=(e,t)=>{if(!Ft(e)){const o=(e=>Wn(e).bind((e=>{return t=e,o=["fixed","relative","empty"],x.from(Pn.exec(t)).bind((e=>{const t=Number(e[1]),n=e[2];return((e,t)=>E(t,(t=>E(Dn[t],(t=>e===t)))))(n,o)?x.some({value:t,unit:n}):x.none()}));var t,o})))(e);o.each((o=>{const n=o.value/2;Kn(e,n,o.unit),Kn(t,n,o.unit)}))}},Gi=e=>M(e,p(0)),Yi=(e,t,o,n,r)=>r(e.slice(0,t)).concat(n).concat(r(e.slice(o))),Ki=e=>(t,o,n,r)=>{if(e(n)){const e=Math.max(r,t[o]-Math.abs(n)),i=Math.abs(e-t[o]);return n>=0?i:-i}return n},Xi=Ki((e=>e<0)),Ji=Ki(_),Qi=()=>{const e=(e,t,o,n)=>{const r=(100+o)/100,i=Math.max(n,(e[t]+o)/r);return M(e,((e,o)=>(o===t?i:e/r)-e))},t=(t,o,n,r,i,s)=>s?e(t,o,r,i):((e,t,o,n,r)=>{const i=Xi(e,t,n,r);return Yi(e,t,o+1,[i,0],Gi)})(t,o,n,r,i);return{resizeTable:(e,t)=>e(t),clampTableDelta:Xi,calcLeftEdgeDeltas:t,calcMiddleDeltas:(e,o,n,r,i,s,a)=>t(e,n,r,i,s,a),calcRightEdgeDeltas:(t,o,n,r,i,s)=>{if(s)return e(t,n,r,i);{const e=Xi(t,n,r,i);return Gi(t.slice(0,n)).concat([e])}},calcRedestributedWidths:(e,t,o,n)=>{if(n){const n=(t+o)/t,r=M(e,(e=>e/n));return{delta:100*n-100,newSizes:r}}return{delta:o,newSizes:e}}}},es=()=>{const e=(e,t,o,n,r)=>{const i=Ji(e,n>=0?o:t,n,r);return Yi(e,t,o+1,[i,-i],Gi)};return{resizeTable:(e,t,o)=>{o&&e(t)},clampTableDelta:(e,t,o,n,r)=>{if(r){if(o>=0)return o;{const t=V(e,((e,t)=>e+t-n),0);return Math.max(-t,o)}}return Xi(e,t,o,n)},calcLeftEdgeDeltas:e,calcMiddleDeltas:(t,o,n,r,i,s)=>e(t,n,r,i,s),calcRightEdgeDeltas:(e,t,o,n,r,i)=>{if(i)return Gi(e);{const t=n/e.length;return M(e,p(t))}},calcRedestributedWidths:(e,t,o,n)=>({delta:0,newSizes:e})}},ts=e=>Qo(e).grid,os=he("th"),ns=e=>L(e,(e=>os(e.element))),rs=(e,t)=>e&&t?"sectionCells":e?"section":"cells",is=e=>{const t="thead"===e.section,o=yt(ss(e.cells),"th");return"tfoot"===e.section?{type:"footer"}:t||o?{type:"header",subType:rs(t,o)}:{type:"body"}},ss=e=>{const t=N(e,(e=>os(e.element)));return 0===t.length?x.some("td"):t.length===e.length?x.some("th"):x.none()},as=(e,t,o)=>et(o(e.element,t),!0,e.isLocked),ls=(e,t)=>e.section!==t?tt(e.element,e.cells,t,e.isNew):e,cs=()=>({transformRow:ls,transformCell:(e,t,o)=>{const n=o(e.element,t),r="td"!==ne(n)?((e,t)=>{const o=Ke(e,"td");Fe(e,o);const n=De(e);return je(o,n),$e(e),o})(n):n;return et(r,e.isNew,e.isLocked)}}),ds=()=>({transformRow:ls,transformCell:as}),us=()=>({transformRow:(e,t)=>ls(e,"thead"===t?"tbody":t),transformCell:as}),hs=cs,ms=ds,ps=us,gs=()=>({transformRow:g,transformCell:as}),fs=(e,t,o,n)=>{o===n?be(e,t):pe(e,t,o)},vs=(e,t,o)=>{j(dt(e,t)).fold((()=>Le(e,o)),(e=>Fe(e,o)))},bs=(e,t)=>{const o=[],n=[],r=e=>M(e,(e=>{e.isNew&&o.push(e.element);const t=e.element;return Ue(t),A(e.cells,(e=>{e.isNew&&n.push(e.element),fs(e.element,"colspan",e.colspan,1),fs(e.element,"rowspan",e.rowspan,1),ze(t,e.element)})),t})),i=e=>F(e,(e=>M(e.cells,(e=>(fs(e.element,"span",e.colspan,1),e.element))))),s=(t,o)=>{const n=((e,t)=>{const o=ft(e,t).getOrThunk((()=>{const o=_e.fromTag(t,Oe(e).dom);return"thead"===t?vs(e,"caption,colgroup",o):"colgroup"===t?vs(e,"caption",o):ze(e,o),o}));return Ue(o),o})(e,o),s=("colgroup"===o?i:r)(t);je(n,s)},a=(t,o)=>{t.length>0?s(t,o):(t=>{ft(e,t).each($e)})(o)},l=[],c=[],d=[],u=[];return A(t,(e=>{switch(e.section){case"thead":l.push(e);break;case"tbody":c.push(e);break;case"tfoot":d.push(e);break;case"colgroup":u.push(e)}})),a(u,"colgroup"),a(l,"thead"),a(c,"tbody"),a(d,"tfoot"),{newRows:o,newCells:n}},ys=(e,t)=>{if(0===e.length)return 0;const o=e[0];return P(e,(e=>!t(o.element,e.element))).getOr(e.length)},ws=(e,t)=>{const o=M(e,(e=>M(e.cells,w)));return M(e,((n,r)=>{const i=F(n.cells,((n,i)=>{if(!1===o[r][i]){const d=((e,t,o,n)=>{const r=((e,t)=>e[t])(e,t),i="colgroup"===r.section,s=ys(r.cells.slice(o),n),a=i?1:ys(((e,t)=>M(e,(e=>Zo(e,t))))(e.slice(t),o),n);return{colspan:s,rowspan:a}})(e,r,i,t);return((e,t,n,r)=>{for(let i=e;i({element:e,cells:t,section:o,isNew:n}))(n.element,i,n.section,n.isNew)}))},_s=(e,t,o)=>{const n=[];A(e.colgroups,(r=>{const i=[];for(let n=0;net(e.element,o,!1))).getOrThunk((()=>et(t.colGap(),!0,!1)));i.push(r)}n.push(tt(r.element,i,"colgroup",o))}));for(let r=0;ret(e.element,o,e.isLocked))).getOrThunk((()=>et(t.gap(),!0,!1)));i.push(s)}const s=e.all[r],a=tt(s.element,i,s.section,o);n.push(a)}return n},xs=e=>ws(e,Se),Cs=(e,t)=>U(e.all,(e=>D(e.cells,(e=>Se(t,e.element))))),ks=(e,t,o)=>{const n=M(t.selection,(t=>$t(t).bind((t=>Cs(e,t))).filter(o))),r=wt(n);return _t(r.length>0,r)},Ss=(e,t,o,n,r)=>(i,s,a,l)=>{const c=Qo(i),d=x.from(null==l?void 0:l.section).getOrThunk(gs);return t(c,s).map((t=>{const o=((e,t)=>_s(e,t,!1))(c,a),n=e(o,t,Se,r(a),d),i=Yo(n.grid);return{info:t,grid:xs(n.grid),cursor:n.cursor,lockedColumns:i}})).bind((e=>{const t=bs(i,e.grid),r=x.from(null==l?void 0:l.sizing).getOrThunk((()=>dr(i))),s=x.from(null==l?void 0:l.resize).getOrThunk(es);return o(i,e.grid,e.info,{sizing:r,resize:s,section:d}),n(i),be(i,qo),e.lockedColumns.length>0&&pe(i,qo,e.lockedColumns.join(",")),x.some({cursor:e.cursor,newRows:t.newRows,newCells:t.newCells})}))},Ts=(e,t)=>ks(e,t,_).map((e=>({cells:e,generators:t.generators,clipboard:t.clipboard}))),Es=(e,t)=>ks(e,t,_),Os=(e,t)=>ks(e,t,(e=>!e.isLocked)),Ms=(e,t)=>L(t,(t=>((e,t)=>Cs(e,t).exists((e=>!e.isLocked)))(e,t))),As=(e,t,o,n)=>{const r=$o(e).rows;let i=!0;for(let e=0;e{const t=t=>t(e),o=p(e),n=()=>r,r={tag:!0,inner:e,fold:(t,o)=>o(e),isValue:_,isError:w,map:t=>Rs.value(t(e)),mapError:n,bind:t,exists:t,forall:t,getOr:o,or:n,getOrThunk:o,orThunk:n,getOrDie:o,each:t=>{t(e)},toOptional:()=>x.some(e)};return r},Ns=e=>{const t=()=>o,o={tag:!1,inner:e,fold:(t,o)=>t(e),isValue:w,isError:_,map:t,mapError:t=>Rs.error(t(e)),bind:t,exists:w,forall:_,getOr:g,or:g,getOrThunk:y,orThunk:y,getOrDie:(n=String(e),()=>{throw new Error(n)}),each:m,toOptional:x.none};var n;return o},Rs={value:Bs,error:Ns,fromOption:(e,t)=>e.fold((()=>Ns(t)),Bs)},Vs=(e,t)=>({rowDelta:0,colDelta:Uo(e[0])-Uo(t[0])}),Ds=(e,t)=>({rowDelta:e.length-t.length,colDelta:0}),Ps=(e,t,o,n)=>{const r="colgroup"===t.section?o.col:o.cell;return O(e,(e=>et(r(),!0,n(e))))},Is=(e,t,o,n)=>{const r=e[e.length-1];return e.concat(O(t,(()=>{const e="colgroup"===r.section?o.colgroup:o.row,t=Wo(r,e,g),i=Ps(t.cells.length,t,o,(e=>J(n,e.toString())));return Ho(t,i)})))},Fs=(e,t,o,n)=>M(e,(e=>{const r=Ps(t,e,o,w);return Fo(e,n,r)})),Ls=(e,t,o)=>{const n=t.colDelta<0?Fs:g,r=t.rowDelta<0?Is:g,i=Yo(e),s=Uo(e[0]),a=E(i,(e=>e===s-1)),l=n(e,Math.abs(t.colDelta),o,a?s-1:s),c=Yo(l);return r(l,Math.abs(t.rowDelta),o,z(c,_))},zs=(e,t,o,n)=>{const r=v(n,Zo(e[t],o).element),i=e[t];return e.length>1&&Uo(i)>1&&(o>0&&r(jo(i,o-1))||o0&&r(jo(e[t-1],o))||tN(o,(o=>o>=e.column&&o<=Uo(t[0])+e.column)),Zs=(e,t,o,n,r)=>{((e,t,o,n)=>{t>0&&t{const r=e.cells[t-1];let i=0;const s=n();for(;e.cells.length>t+i&&o(r.element,e.cells[t+i].element);)zo(e,t+i,et(s,!0,e.cells[t+i].isLocked)),i++}))})(t,e,r,n.cell);const i=Ds(o,t),s=Ls(o,i,n),a=Ds(t,s),l=Ls(t,a,n);return M(l,((t,o)=>Fo(t,e,s[o].cells)))},js=(e,t,o,n,r)=>{((e,t,o,n)=>{const r=$o(e).rows;if(t>0&&tV(e,((e,o)=>E(e,(e=>t(e.element,o.element)))?e:e.concat([o])),[]))(r[t-1].cells,o);A(e,(e=>{let i=x.none();for(let s=t;s{zo(a,t,et(e,!0,l.isLocked))})))}}))}})(t,e,r,n.cell);const i=Yo(t),s=Vs(t,o),a={...s,colDelta:s.colDelta-i.length},l=Ls(t,a,n),{cols:c,rows:d}=$o(l),u=Yo(l),h=Vs(o,t),m={...h,colDelta:h.colDelta+u.length},p=(f=n,v=u,M(o,(e=>V(v,((t,o)=>{const n=Ps(1,e,f,_)[0];return Lo(t,o,n)}),e)))),g=Ls(p,m,n);var f,v;return[...c,...d.slice(0,e),...g,...d.slice(e,d.length)]},Us=(e,t,o,n,r)=>{const{rows:i,cols:s}=$o(e),a=i.slice(0,t),l=i.slice(t);return[...s,...a,((e,t,o,n)=>Wo(e,(e=>n(e,o)),t))(i[o],((e,o)=>t>0&&tM(e,(e=>{const i=t>0&&t{if("colgroup"!==o&&n)return Zo(e,t);{const t=Zo(e,r);return et(s(t.element,i),!0,!1)}})(e,t,e.section,i,o,n,r);return Lo(e,t,s)})),Ws=(e,t,o,n)=>((e,t,o,n)=>void 0!==jo(e[t],o)&&t>0&&n(jo(e[t-1],o),jo(e[t],o)))(e,t,o,n)||((e,t,o)=>t>0&&o(jo(e,t-1),jo(e,t)))(e[t],o,n),qs=(e,t,o,n)=>{const r=e=>(e=>"row"===e?Lt(t):Ft(t))(e)?`${e}group`:e;return e?os(t)?r(o):null:n&&os(t)?r("row"===o?"col":"row"):null},Gs=(e,t,o)=>et(o(e.element,t),!0,e.isLocked),Ys=(e,t,o,n,r,i,s)=>M(e,((e,a)=>((e,l)=>{const c=e.cells,d=M(c,((e,l)=>{if((e=>E(t,(t=>o(e.element,t.element))))(e)){const t=s(e,a,l)?r(e,o,n):e;return i(t,a,l).each((e=>{var o,n;o=t.element,n={scope:x.from(e)},q(n,((e,t)=>{e.fold((()=>{be(o,t)}),(e=>{me(o.dom,t,e)}))}))})),t}return e}));return tt(e.element,d,e.section,e.isNew)})(e))),Ks=(e,t,o)=>F(e,((n,r)=>Ws(e,r,t,o)?[]:[Zo(n,t)])),Xs=(e,t,o,n,r)=>{const i=$o(e).rows,s=F(t,(e=>Ks(i,e,n))),a=M(i,(e=>ns(e.cells))),l=((e,t)=>L(t,g)&&ns(e)?_:(e,o,n)=>!("th"===ne(e.element)&&t[o]))(s,a),c=((e,t)=>(o,n)=>x.some(qs(e,o.element,"row",t[n])))(o,a);return Ys(e,s,n,r,Gs,c,l)},Js=(e,t,o,n)=>{const r=$o(e).rows,i=M(t,(e=>Zo(r[e.row],e.column)));return Ys(e,i,o,n,Gs,x.none,_)},Qs=e=>{if(!s(e))throw new Error("cases must be an array");if(0===e.length)throw new Error("there must be at least one case");const t=[],o={};return A(e,((n,r)=>{const i=$(n);if(1!==i.length)throw new Error("one and only one name per case");const a=i[0],l=n[a];if(void 0!==o[a])throw new Error("duplicate key detected:"+a);if("cata"===a)throw new Error("cannot have a case named cata (sorry)");if(!s(l))throw new Error("case arguments must be an array");t.push(a),o[a]=(...o)=>{const n=o.length;if(n!==l.length)throw new Error("Wrong number of arguments to case "+a+". Expected "+l.length+" ("+l+"), got "+n);return{fold:(...t)=>{if(t.length!==e.length)throw new Error("Wrong number of arguments to fold. Expected "+e.length+", got "+t.length);return t[r].apply(null,o)},match:e=>{const n=$(e);if(t.length!==n.length)throw new Error("Wrong number of arguments to match. Expected: "+t.join(",")+"\nActual: "+n.join(","));if(!L(t,(e=>T(n,e))))throw new Error("Not all branches were specified when using match. Specified: "+n.join(", ")+"\nRequired: "+t.join(", "));return e[a].apply(null,o)},log:e=>{console.log(e,{constructors:t,constructor:a,params:o})}}}})),o},ea={...Qs([{none:[]},{only:["index"]},{left:["index","next"]},{middle:["prev","index","next"]},{right:["prev","index"]}])},ta=(e,t,o)=>{let n=0;for(let r=e;r{const o=rn(e);return M(o,(e=>{const o=ta(e.row,e.row+e.rowspan,t);return{element:e.element,height:o,rowspan:e.rowspan}}))},na=(e,t,o)=>{const n=((e,t)=>an(e)?((e,t)=>{const o=sn(e);return M(o,((e,o)=>({element:e.element,width:t[o],colspan:e.colspan})))})(e,t):((e,t)=>{const o=rn(e);return M(o,(e=>{const o=ta(e.column,e.column+e.colspan,t);return{element:e.element,width:o,colspan:e.colspan}}))})(e,t))(e,t);A(n,(e=>{o.setElementWidth(e.element,e.width)}))},ra=(e,t,o,n,r)=>{const i=Qo(e),s=r.getCellDelta(t),a=r.getWidths(i,r),l=o===i.grid.columns-1,c=n.clampTableDelta(a,o,s,r.minCellWidth(),l),d=((e,t,o,n,r)=>{const i=e.slice(0),s=((e,t)=>0===e.length?ea.none():1===e.length?ea.only(0):0===t?ea.left(0,1):t===e.length-1?ea.right(t-1,t):t>0&&tn.singleColumnWidth(i[e],o)),((e,t)=>r.calcLeftEdgeDeltas(i,e,t,o,n.minCellWidth(),n.isRelative)),((e,t,s)=>r.calcMiddleDeltas(i,e,t,s,o,n.minCellWidth(),n.isRelative)),((e,t)=>r.calcRightEdgeDeltas(i,e,t,o,n.minCellWidth(),n.isRelative)))})(a,o,c,r,n),u=M(d,((e,t)=>e+a[t]));na(i,u,r),n.resizeTable(r.adjustTableWidth,c,l)},ia=e=>V(e,((e,t)=>E(e,(e=>e.column===t.column))?e:e.concat([t])),[]).sort(((e,t)=>e.column-t.column)),sa=he("col"),aa=he("colgroup"),la=e=>"tr"===ne(e)||aa(e),ca=e=>({element:e,colspan:Pt(e,"colspan",1),rowspan:Pt(e,"rowspan",1)}),da=e=>ve(e,"scope").map((e=>e.substr(0,3))),ua=(e,t=ca)=>{const o=o=>{if(la(o))return aa((r={element:o}).element)?e.colgroup(r):e.row(r);{const r=o,i=(t=>sa(t.element)?e.col(t):e.cell(t))(t(r));return n=x.some({item:r,replacement:i}),i}var r};let n=x.none();return{getOrInit:(e,t)=>n.fold((()=>o(e)),(n=>t(e,n.item)?n.replacement:o(e)))}},ha=e=>t=>{const o=[],n=n=>{const r="td"===e?{scope:null}:{},i=t.replace(n,e,r);return o.push({item:n,sub:i}),i};return{replaceOrInit:(e,t)=>{if(la(e)||sa(e))return e;{const r=e;return((e,t)=>D(o,(o=>t(o.item,e))))(r,t).fold((()=>n(r)),(o=>t(e,o.item)?o.sub:n(r)))}}}},ma=e=>({unmerge:t=>{const o=da(t);return o.each((e=>pe(t,"scope",e))),()=>{const n=e.cell({element:t,colspan:1,rowspan:1});return Dt(n,"width"),Dt(t,"width"),o.each((e=>pe(n,"scope",e))),n}},merge:e=>(Dt(e[0],"width"),(()=>{const t=wt(M(e,da));if(0===t.length)return x.none();{const e=t[0],o=["row","col"];return E(t,(t=>t!==e&&T(o,t)))?x.none():x.from(e)}})().fold((()=>be(e[0],"scope")),(t=>pe(e[0],"scope",t+"group"))),p(e[0]))}),pa=["body","p","div","article","aside","figcaption","figure","footer","header","nav","section","ol","ul","table","thead","tfoot","tbody","caption","tr","td","th","h1","h2","h3","h4","h5","h6","blockquote","pre","address"],ga=gi(),fa=e=>((e,t)=>{const o=e.property().name(t);return T(pa,o)})(ga,e),va=e=>((e,t)=>{const o=e.property().name(t);return T(["ol","ul"],o)})(ga,e),ba=e=>{const t=he("br"),o=e=>xr(e).bind((o=>{const n=Ve(o).map((e=>!!fa(e)||!!((e,t)=>T(["br","img","hr","input"],e.property().name(t)))(ga,e)&&"img"!==ne(e))).getOr(!1);return Ae(o).map((r=>{return!0===n||("li"===ne(i=r)||mt(i,va).isSome())||t(o)||fa(r)&&!Se(e,r)?[]:[_e.fromTag("br")];var i}))})).getOr([]),n=(()=>{const n=F(e,(e=>{const n=De(e);return(e=>L(e,(e=>t(e)||ce(e)&&0===gr(e).trim().length)))(n)?[]:n.concat(o(e))}));return 0===n.length?[_e.fromTag("br")]:n})();Ue(e[0]),je(e[0],n)},ya=e=>Xr(e,!0),wa=e=>{0===Wt(e).length&&$e(e)},_a=(e,t)=>({grid:e,cursor:t}),xa=(e,t,o)=>{const n=((e,t,o)=>{var n,r;const i=$o(e).rows;return x.from(null===(r=null===(n=i[t])||void 0===n?void 0:n.cells[o])||void 0===r?void 0:r.element).filter(ya).orThunk((()=>(e=>U(e,(e=>U(e.cells,(e=>{const t=e.element;return _t(ya(t),t)})))))(i)))})(e,t,o);return _a(e,n)},Ca=e=>V(e,((e,t)=>E(e,(e=>e.row===t.row))?e:e.concat([t])),[]).sort(((e,t)=>e.row-t.row)),ka=(e,t)=>(o,n,r,i,s)=>{const a=Ca(n),l=M(a,(e=>e.row)),c=((e,t,o,n,r,i,s)=>{const{cols:a,rows:l}=$o(e),c=l[t[0]],d=F(t,(e=>((e,t,o)=>{const n=e[t];return F(n.cells,((n,r)=>Ws(e,t,r,o)?[]:[n]))})(l,e,r))),u=M(c.cells,((e,t)=>ns(Ks(l,t,r)))),h=[...l];A(t,(e=>{h[e]=s.transformRow(l[e],o)}));const m=[...a,...h],p=((e,t)=>L(t,g)&&ns(e.cells)?_:(e,o,n)=>!("th"===ne(e.element)&&t[n]))(c,u),f=((e,t)=>(o,n,r)=>x.some(qs(e,o.element,"col",t[r])))(n,u);return Ys(m,d,r,i,s.transformCell,f,p)})(o,l,e,t,r,i.replaceOrInit,s);return xa(c,n[0].row,n[0].column)},Sa=ka("thead",!0),Ta=ka("tbody",!1),Ea=ka("tfoot",!1),Oa=(e,t,o)=>{const n=((e,t)=>Xt(e,(()=>t)))(e,o.section),r=en(n);return _s(r,t,!0)},Ma=(e,t,o,n)=>((e,t,o,n)=>{const r=en(t),i=n.getWidths(r,n);na(r,i,n)})(0,t,0,n.sizing),Aa=(e,t,o,n)=>((e,t,o,n,r)=>{const i=en(t),s=n.getWidths(i,n),a=n.pixelWidth(),{newSizes:l,delta:c}=r.calcRedestributedWidths(s,a,o.pixelDelta,n.isRelative);na(i,l,n),n.adjustTableWidth(c)})(0,t,o,n.sizing,n.resize),Ba=(e,t)=>E(t,(e=>0===e.column&&e.isLocked)),Na=(e,t)=>E(t,(t=>t.column+t.colspan>=e.grid.columns&&t.isLocked)),Ra=(e,t)=>{const o=cn(e),n=ia(t);return V(n,((e,t)=>e+o[t.column].map(Po).getOr(0)),0)},Va=e=>(t,o)=>Es(t,o).filter((o=>!(e?Ba:Na)(t,o))).map((e=>({details:e,pixelDelta:Ra(t,e)}))),Da=e=>(t,o)=>Ts(t,o).filter((o=>!(e?Ba:Na)(t,o.cells))),Pa=ha("th"),Ia=ha("td"),Fa=Ss(((e,t,o,n)=>{const r=t[0].row,i=Ca(t),s=R(i,((e,t)=>({grid:Us(e.grid,r,t.row+e.delta,o,n.getOrInit),delta:e.delta+1})),{grid:e,delta:0}).grid;return xa(s,r,t[0].column)}),Es,m,m,ua),La=Ss(((e,t,o,n)=>{const r=Ca(t),i=r[r.length-1],s=i.row+i.rowspan,a=R(r,((e,t)=>Us(e,s,t.row,o,n.getOrInit)),e);return xa(a,s,t[0].column)}),Es,m,m,ua),za=Ss(((e,t,o,n)=>{const r=t.details,i=ia(r),s=i[0].column,a=R(i,((e,t)=>({grid:$s(e.grid,s,t.column+e.delta,o,n.getOrInit),delta:e.delta+1})),{grid:e,delta:0}).grid;return xa(a,r[0].row,s)}),Va(!0),Aa,m,ua),Ha=Ss(((e,t,o,n)=>{const r=t.details,i=r[r.length-1],s=i.column+i.colspan,a=ia(r),l=R(a,((e,t)=>$s(e,s,t.column,o,n.getOrInit)),e);return xa(l,r[0].row,s)}),Va(!1),Aa,m,ua),Za=Ss(((e,t,o,n)=>{const r=ia(t.details),i=((e,t)=>F(e,(e=>{const o=e.cells,n=R(t,((e,t)=>t>=0&&t0?[tt(e.element,n,e.section,e.isNew)]:[]})))(e,M(r,(e=>e.column))),s=i.length>0?i[0].cells.length-1:0;return xa(i,r[0].row,Math.min(r[0].column,s))}),((e,t)=>Os(e,t).map((t=>({details:t,pixelDelta:-Ra(e,t)})))),Aa,wa,ua),ja=Ss(((e,t,o,n)=>{const r=Ca(t),i=((e,t,o)=>{const{rows:n,cols:r}=$o(e);return[...r,...n.slice(0,t),...n.slice(o+1)]})(e,r[0].row,r[r.length-1].row),s=i.length>0?i.length-1:0;return xa(i,Math.min(t[0].row,s),t[0].column)}),Es,m,wa,ua),Ua=Ss(((e,t,o,n)=>{const r=ia(t),i=M(r,(e=>e.column)),s=Xs(e,i,!0,o,n.replaceOrInit);return xa(s,t[0].row,t[0].column)}),Os,m,m,Pa),$a=Ss(((e,t,o,n)=>{const r=ia(t),i=M(r,(e=>e.column)),s=Xs(e,i,!1,o,n.replaceOrInit);return xa(s,t[0].row,t[0].column)}),Os,m,m,Ia),Wa=Ss(Sa,Os,m,m,Pa),qa=Ss(Ta,Os,m,m,Ia),Ga=Ss(Ea,Os,m,m,Ia),Ya=Ss(((e,t,o,n)=>{const r=Js(e,t,o,n.replaceOrInit);return xa(r,t[0].row,t[0].column)}),Os,m,m,Pa),Ka=Ss(((e,t,o,n)=>{const r=Js(e,t,o,n.replaceOrInit);return xa(r,t[0].row,t[0].column)}),Os,m,m,Ia),Xa=Ss(((e,t,o,n)=>{const r=t.cells;ba(r);const i=((e,t,o,n)=>{const r=$o(e).rows;if(0===r.length)return e;for(let e=t.startRow;e<=t.finishRow;e++)for(let o=t.startCol;o<=t.finishCol;o++){const t=r[e],i=Zo(t,o).isLocked;zo(t,o,et(n(),!1,i))}return e})(e,t.bounds,0,n.merge(r));return _a(i,x.from(r[0]))}),((e,t)=>((e,t)=>t.mergable)(0,t).filter((t=>Ms(e,t.cells)))),Ma,m,ma),Ja=Ss(((e,t,o,n)=>{const r=R(t,((e,t)=>As(e,t,o,n.unmerge(t))),e);return _a(r,x.from(t[0]))}),((e,t)=>((e,t)=>t.unmergable)(0,t).filter((t=>Ms(e,t)))),Ma,m,ma),Qa=Ss(((e,t,o,n)=>{const r=((e,t)=>{const o=Qo(e);return _s(o,t,!0)})(t.clipboard,t.generators);var i,s;return((e,t,o,n,r)=>{const i=Yo(t),s=((e,t,o)=>{const n=Uo(t[0]),r=$o(t).cols.length+e.row,i=O(n-e.column,(t=>t+e.column));return{row:r,column:D(i,(e=>L(o,(t=>t!==e)))).getOr(n-1)}})(e,t,i),a=$o(o).rows,l=Hs(s,a,i),c=((e,t,o)=>{if(e.row>=t.length||e.column>Uo(t[0]))return Rs.error("invalid start address out of table bounds, row: "+e.row+", column: "+e.column);const n=t.slice(e.row),r=n[0].cells.slice(e.column),i=Uo(o[0]),s=o.length;return Rs.value({rowDelta:n.length-s,colDelta:r.length-i})})(s,t,a);return c.map((e=>{const o={...e,colDelta:e.colDelta-l.length},i=Ls(t,o,n),c=Yo(i),d=Hs(s,a,c);return((e,t,o,n,r,i)=>{const s=e.row,a=e.column,l=s+o.length,c=a+Uo(o[0])+i.length,d=z(i,_);for(let e=s;e_a(e,x.some(t.element))),(e=>xa(e,t.row,t.column)))}),((e,t)=>$t(t.element).bind((o=>Cs(e,o).map((e=>({...e,generators:t.generators,clipboard:t.clipboard})))))),Ma,m,ua),el=Ss(((e,t,o,n)=>{const r=$o(e).rows,i=t.cells[0].column,s=r[t.cells[0].row],a=Oa(t.clipboard,t.generators,s),l=Zs(i,e,a,t.generators,o);return xa(l,t.cells[0].row,t.cells[0].column)}),Da(!0),m,m,ua),tl=Ss(((e,t,o,n)=>{const r=$o(e).rows,i=t.cells[t.cells.length-1].column+t.cells[t.cells.length-1].colspan,s=r[t.cells[0].row],a=Oa(t.clipboard,t.generators,s),l=Zs(i,e,a,t.generators,o);return xa(l,t.cells[0].row,t.cells[0].column)}),Da(!1),m,m,ua),ol=Ss(((e,t,o,n)=>{const r=$o(e).rows,i=t.cells[0].row,s=r[i],a=Oa(t.clipboard,t.generators,s),l=js(i,e,a,t.generators,o);return xa(l,t.cells[0].row,t.cells[0].column)}),Ts,m,m,ua),nl=Ss(((e,t,o,n)=>{const r=$o(e).rows,i=t.cells[t.cells.length-1].row+t.cells[t.cells.length-1].rowspan,s=r[t.cells[0].row],a=Oa(t.clipboard,t.generators,s),l=js(i,e,a,t.generators,o);return xa(l,t.cells[0].row,t.cells[0].column)}),Ts,m,m,ua),rl=(e,t)=>{const o=Qo(e);return Es(o,t).bind((e=>{const t=e[e.length-1],n=e[0].column,r=t.column+t.colspan,i=I(M(o.all,(e=>N(e.cells,(e=>e.column>=n&&e.column{const o=Qo(e);return Es(o,t).bind(ss).getOr("")},sl=(e,t)=>{const o=Qo(e);return Es(o,t).bind((e=>{const t=e[e.length-1],n=e[0].row,r=t.row+t.rowspan;return(e=>{const t=M(e,(e=>is(e).type)),o=T(t,"header"),n=T(t,"footer");if(o||n){const e=T(t,"body");return!o||e||n?o||e||!n?x.none():x.some("footer"):x.some("header")}return x.some("body")})(o.all.slice(n,r))})).getOr("")},al=(e,t)=>e.dispatch("NewRow",{node:t}),ll=(e,t)=>e.dispatch("NewCell",{node:t}),cl=(e,t,o)=>{e.dispatch("TableModified",{...o,table:t})},dl={structure:!1,style:!0},ul={structure:!0,style:!1},hl={structure:!0,style:!0},ml=(e,t)=>Zr(e)?hr(t):jr(e)?ur(t):dr(t),pl=(e,t,o)=>{const n=e=>"table"===ne(Qr(e)),r=Pr(e),i=zr(e)?m:qi,s=t=>{switch(Ir(e)){case"section":return hs();case"sectionCells":return ms();case"cells":return ps();default:return((e,t)=>{var o;switch((o=Qo(e),U(o.all,(e=>{const t=is(e);return"header"===t.type?x.from(t.subType):x.none()}))).getOr(t)){case"section":return cs();case"sectionCells":return ds();case"cells":return us()}})(t,"section")}},a=(n,i,a,l)=>(c,d,u=!1)=>{ti(c);const h=_e.fromDom(e.getDoc()),m=Br(a,h,r),p={sizing:ml(e,c),resize:zr(e)?Qi():es(),section:s(c)};return i(c)?n(c,d,m,p).bind((n=>{t.refresh(c.dom),A(n.newRows,(t=>{al(e,t.dom)})),A(n.newCells,(t=>{ll(e,t.dom)}));const r=((t,n)=>n.cursor.fold((()=>{const n=Wt(t);return Z(n).filter(st).map((n=>{o.clearSelectedCells(t.dom);const r=e.dom.createRng();return r.selectNode(n.dom),e.selection.setRng(r),pe(n,"data-mce-selected","1"),r}))}),(n=>{const r=$i(Wi,n),i=e.dom.createRng();return i.setStart(r.element.dom,r.offset),i.setEnd(r.element.dom,r.offset),e.selection.setRng(i),o.clearSelectedCells(t.dom),x.some(i)})))(c,n);return st(c)&&(ti(c),u||cl(e,c.dom,l)),r.map((e=>({rng:e,effect:l})))})):x.none()},l=a(ja,(t=>!n(e)||ts(t).rows>1),m,ul),c=a(Za,(t=>!n(e)||ts(t).columns>1),m,ul);return{deleteRow:l,deleteColumn:c,insertRowsBefore:a(Fa,_,m,ul),insertRowsAfter:a(La,_,m,ul),insertColumnsBefore:a(za,_,i,ul),insertColumnsAfter:a(Ha,_,i,ul),mergeCells:a(Xa,_,m,ul),unmergeCells:a(Ja,_,m,ul),pasteColsBefore:a(el,_,m,ul),pasteColsAfter:a(tl,_,m,ul),pasteRowsBefore:a(ol,_,m,ul),pasteRowsAfter:a(nl,_,m,ul),pasteCells:a(Qa,_,m,hl),makeCellsHeader:a(Ya,_,m,ul),unmakeCellsHeader:a(Ka,_,m,ul),makeColumnsHeader:a(Ua,_,m,ul),unmakeColumnsHeader:a($a,_,m,ul),makeRowsHeader:a(Wa,_,m,ul),makeRowsBody:a(qa,_,m,ul),makeRowsFooter:a(Ga,_,m,ul),getTableRowType:sl,getTableCellType:il,getTableColType:rl}},gl=(e,t,o)=>{const n=Pt(e,t,1);1===o||n<=1?be(e,t):pe(e,t,Math.min(o,n))},fl=(e,t)=>o=>{const n=o.column+o.colspan-1,r=o.column;return n>=e&&r{const n=o.substring(0,o.length-e.length),r=parseFloat(n);return n===r.toString()?t(r):vl.invalid(o)},yl={...vl,from:e=>St(e,"%")?bl("%",vl.percent,e):St(e,"px")?bl("px",vl.pixels,e):vl.invalid(e)},wl=(e,t,o)=>{const n=yl.from(o),r=L(e,(e=>"0px"===e))?((e,t)=>{const o=e.fold((()=>p("")),(e=>p(e/t+"px")),(()=>p(100/t+"%")));return O(t,o)})(n,e.length):((e,t,o)=>e.fold((()=>t),(e=>((e,t,o)=>{const n=o/t;return M(e,(e=>yl.from(e).fold((()=>e),(e=>e*n+"px"),(e=>e/100*o+"px"))))})(t,o,e)),(e=>((e,t)=>M(e,(e=>yl.from(e).fold((()=>e),(e=>e/t*100+"%"),(e=>e+"%")))))(t,o))))(n,e,t);return Cl(r)},_l=(e,t)=>0===e.length?t:R(e,((e,t)=>yl.from(t).fold(p(0),g,g)+e),0),xl=(e,t)=>yl.from(e).fold(p(e),(e=>e+t+"px"),(e=>e+t+"%")),Cl=e=>{if(0===e.length)return e;const t=R(e,((e,t)=>{const o=yl.from(t).fold((()=>({value:t,remainder:0})),(e=>((e,t)=>{const o=Math.floor(e);return{value:o+"px",remainder:e-o}})(e)),(e=>({value:e+"%",remainder:0})));return{output:[o.value].concat(e.output),remainder:e.remainder+o.remainder}}),{output:[],remainder:0}),o=t.output;return o.slice(0,o.length-1).concat([xl(o[o.length-1],Math.round(t.remainder))])},kl=yl.from,Sl=e=>kl(e).fold(p("px"),p("px"),p("%")),Tl=(e,t,o)=>{const n=Qo(e),r=n.all,i=rn(n),s=sn(n);t.each((t=>{const o=Sl(t),r=Do(e),a=((e,t)=>nr(e,t,er,rr))(n,e),l=wl(a,r,t);an(n)?((e,t,o)=>{A(t,((t,n)=>{const r=_l([e[n]],Ht());At(t.element,"width",r+o)}))})(l,s,o):((e,t,o)=>{A(t,(t=>{const n=e.slice(t.column,t.colspan+t.column),r=_l(n,Ht());At(t.element,"width",r+o)}))})(l,i,o),At(e,"width",t)})),o.each((t=>{const o=Sl(t),s=gn(e),a=((e,t,o)=>sr(e,t,o,tr,rr))(n,e,Nn);((e,t,o,n)=>{A(o,(t=>{const o=e.slice(t.row,t.rowspan+t.row),r=_l(o,Zt());At(t.element,"height",r+n)})),A(t,((t,o)=>{At(t.element,"height",e[o])}))})(wl(a,s,t),r,i,o),At(e,"height",t)}))},El=e=>Wn(e).exists((e=>In.test(e))),Ol=e=>Wn(e).exists((e=>Fn.test(e))),Ml=e=>Wn(e).isNone(),Al=e=>{be(e,"width")},Bl=e=>{const t=Xn(e);Tl(e,x.some(t),x.none()),Al(e)},Nl=e=>{const t=(e=>Do(e)+"px")(e);Tl(e,x.some(t),x.none()),Al(e)},Rl=e=>{Dt(e,"width");const t=qt(e),o=t.length>0?t:Wt(e);A(o,(e=>{Dt(e,"width"),Al(e)})),Al(e)},Vl={styles:{"border-collapse":"collapse",width:"100%"},attributes:{border:"1"},colGroups:!1},Dl=(e,t,o,n)=>O(e,(e=>((e,t,o,n)=>{const r=_e.fromTag("tr");for(let i=0;i{e.selection.select(t.dom,!0),e.selection.collapse(!0)},Il=(e,t,o,n,i)=>{const s=(e=>{const t=e.options,o=t.get("table_default_styles");return t.isSet("table_default_styles")?o:((e,t)=>Ur(e)||!Wr(e)?t:jr(e)?{...t,width:Dr(e)}:{...t,width:Vr})(e,o)})(e),a={styles:s,attributes:Gr(e),colGroups:Yr(e)};return e.undoManager.ignore((()=>{const r=((e,t,o,n,r,i=Vl)=>{const s=_e.fromTag("table"),a="cells"!==r;Bt(s,i.styles),ge(s,i.attributes),i.colGroups&&ze(s,(e=>{const t=_e.fromTag("colgroup");return O(e,(()=>ze(t,_e.fromTag("col")))),t})(t));const l=Math.min(e,o);if(a&&o>0){const e=_e.fromTag("thead");ze(s,e);const i=Dl(o,t,"sectionCells"===r?l:0,n);je(e,i)}const c=_e.fromTag("tbody");ze(s,c);const d=Dl(a?e-l:e,t,a?0:o,n);return je(c,d),s})(o,t,i,n,Ir(e),a);pe(r,"data-mce-id","__mce");const s=(e=>{const t=_e.fromTag("div"),o=_e.fromDom(e.dom.cloneNode(!0));return ze(t,o),(e=>e.dom.innerHTML)(t)})(r);e.insertContent(s),e.addVisual()})),vt(Qr(e),'table[data-mce-id="__mce"]').map((t=>(jr(e)?Nl(t):Ur(e)?Rl(t):(Zr(e)||(e=>r(e)&&-1!==e.indexOf("%"))(s.width))&&Bl(t),ti(t),be(t,"data-mce-id"),((e,t)=>{A(ut(t,"tr"),(t=>{al(e,t.dom),A(ut(t,"th,td"),(t=>{ll(e,t.dom)}))}))})(e,t),((e,t)=>{vt(t,"td,th").each(v(Pl,e))})(e,t),t.dom))).getOrNull()};var Fl=window.mailpoetTinymce.util.Tools.resolve("mailpoetTinymce.FakeClipboard");const Ll="x-tinymce/dom-table-",zl=Ll+"rows",Hl=Ll+"columns",Zl=e=>{const t=Fl.FakeClipboardItem(e);Fl.write([t])},jl=e=>{var t;const o=null!==(t=Fl.read())&&void 0!==t?t:[];return U(o,(t=>x.from(t.getType(e))))},Ul=e=>{jl(e).isSome()&&Fl.clear()},$l=e=>{e.fold(ql,(e=>Zl({[zl]:e})))},Wl=()=>jl(zl),ql=()=>Ul(zl),Gl=e=>{e.fold(Kl,(e=>Zl({[Hl]:e})))},Yl=()=>jl(Hl),Kl=()=>Ul(Hl),Xl=e=>Ii(oi(e),ei(e)).filter(ii),Jl=(e,t)=>{const o=ei(e),n=e=>Gt(e,o),s=t=>(e=>Fi(oi(e),ei(e)).filter(ii))(e).bind((e=>n(e).map((o=>t(o,e))))),a=t=>{e.focus()},l=(t,o=!1)=>s(((n,r)=>{const i=Di(Li(e),n,r);t(n,i,o).each(a)})),c=()=>s(((t,o)=>((e,t,o)=>{const n=Qo(e);return Es(n,t).bind((e=>{const t=_s(n,o,!1),r=$o(t).rows.slice(e[0].row,e[e.length-1].row+e[e.length-1].rowspan),i=F(r,(e=>{const t=N(e.cells,(e=>!e.isLocked));return t.length>0?[{...e,cells:t}]:[]})),s=xs(i);return _t(s.length>0,s)})).map((e=>M(e,(e=>{const t=Ge(e.element);return A(e.cells,(e=>{const o=Ye(e.element);fs(o,"colspan",e.colspan,1),fs(o,"rowspan",e.rowspan,1),ze(t,o)})),t}))))})(t,Di(Li(e),t,o),Br(m,_e.fromDom(e.getDoc()),x.none())))),d=()=>s(((t,o)=>((e,t)=>{const o=Qo(e);return Os(o,t).map((e=>{const t=e[e.length-1],n=e[0].column,r=t.column+t.colspan,i=((e,t,o)=>{if(an(e)){const n=N(sn(e),fl(t,o)),r=M(n,(e=>{const n=Ye(e.element);return gl(n,"span",o-t),n})),i=_e.fromTag("colgroup");return je(i,r),[i]}return[]})(o,n,r),s=((e,t,o)=>M(e.all,(e=>{const n=N(e.cells,fl(t,o)),r=M(n,(e=>{const n=Ye(e.element);return gl(n,"colspan",o-t),n})),i=_e.fromTag("tr");return je(i,r),i})))(o,n,r);return[...i,...s]}))})(t,Di(Li(e),t,o)))),u=(t,o)=>o().each((o=>{const n=M(o,(e=>Ye(e)));s(((o,r)=>{const i=Nr(_e.fromDom(e.getDoc())),s=((e,t,o,n)=>({selection:Ei(e),clipboard:o,generators:n}))(Li(e),0,n,i);t(o,s).each(a)}))})),p=e=>(t,o)=>((e,t)=>J(e,t)?x.from(e[t]):x.none())(o,"type").each((t=>{l(e(t),o.no_events)}));q({mceTableSplitCells:()=>l(t.unmergeCells),mceTableMergeCells:()=>l(t.mergeCells),mceTableInsertRowBefore:()=>l(t.insertRowsBefore),mceTableInsertRowAfter:()=>l(t.insertRowsAfter),mceTableInsertColBefore:()=>l(t.insertColumnsBefore),mceTableInsertColAfter:()=>l(t.insertColumnsAfter),mceTableDeleteCol:()=>l(t.deleteColumn),mceTableDeleteRow:()=>l(t.deleteRow),mceTableCutCol:()=>d().each((e=>{Gl(e),l(t.deleteColumn)})),mceTableCutRow:()=>c().each((e=>{$l(e),l(t.deleteRow)})),mceTableCopyCol:()=>d().each((e=>Gl(e))),mceTableCopyRow:()=>c().each((e=>$l(e))),mceTablePasteColBefore:()=>u(t.pasteColsBefore,Yl),mceTablePasteColAfter:()=>u(t.pasteColsAfter,Yl),mceTablePasteRowBefore:()=>u(t.pasteRowsBefore,Wl),mceTablePasteRowAfter:()=>u(t.pasteRowsAfter,Wl),mceTableDelete:()=>Xl(e).each((t=>{Gt(t,o).filter(b(o)).each((t=>{const o=_e.fromText("");if(Fe(t,o),$e(t),e.dom.isEmpty(e.getBody()))e.setContent(""),e.selection.setCursorLocation();else{const t=e.dom.createRng();t.setStart(o.dom,0),t.setEnd(o.dom,0),e.selection.setRng(t),e.nodeChanged()}}))})),mceTableCellToggleClass:(t,o)=>{s((t=>{const n=Li(e),r=L(n,(t=>e.formatter.match("tablecellclass",{value:o},t.dom))),i=r?e.formatter.remove:e.formatter.apply;A(n,(e=>i("tablecellclass",{value:o},e.dom))),cl(e,t.dom,dl)}))},mceTableToggleClass:(t,o)=>{s((t=>{e.formatter.toggle("tableclass",{value:o},t.dom),cl(e,t.dom,dl)}))},mceTableToggleCaption:()=>{Xl(e).each((t=>{Gt(t,o).each((o=>{ft(o,"caption").fold((()=>{const t=_e.fromTag("caption");ze(t,_e.fromText("Caption")),((e,t,o)=>{Pe(e,0).fold((()=>{ze(e,t)}),(e=>{Ie(e,t)}))})(o,t),e.selection.setCursorLocation(t.dom,0)}),(n=>{he("caption")(t)&&ke("td",o).each((t=>e.selection.setCursorLocation(t.dom,0))),$e(n)})),cl(e,o.dom,ul)}))}))},mceTableSizingMode:(t,n)=>(t=>Xl(e).each((n=>{Ur(e)||jr(e)||Zr(e)||Gt(n,o).each((o=>{"relative"!==t||El(o)?"fixed"!==t||Ol(o)?"responsive"!==t||Ml(o)||Rl(o):Nl(o):Bl(o),ti(o),cl(e,o.dom,ul)}))})))(n),mceTableCellType:p((e=>"th"===e?t.makeCellsHeader:t.unmakeCellsHeader)),mceTableColType:p((e=>"th"===e?t.makeColumnsHeader:t.unmakeColumnsHeader)),mceTableRowType:p((e=>{switch(e){case"header":return t.makeRowsHeader;case"footer":return t.makeRowsFooter;default:return t.makeRowsBody}}))},((t,o)=>e.addCommand(o,t))),e.addCommand("mceInsertTable",((t,o)=>{((e,t,o,n={})=>{const r=e=>h(e)&&e>0;if(r(t)&&r(o)){const r=n.headerRows||0,i=n.headerColumns||0;return Il(e,o,t,i,r)}console.error("Invalid values for mceInsertTable - rows and columns values are required to insert a table.")})(e,o.rows,o.columns,o.options)})),e.addCommand("mceTableApplyCellStyle",((t,o)=>{const s=e=>"tablecell"+e.toLowerCase().replace("-","");if(!i(o))return;const a=N(Li(e),ii);if(0===a.length)return;const l=((e,t)=>{const o={};return((e,t,o,n)=>{q(e,((e,r)=>{(t(e,r)?o:n)(e,r)}))})(e,t,(e=>(t,o)=>{e[o]=t})(o),m),o})(o,((t,o)=>e.formatter.has(s(o))&&r(t)));(e=>{for(const t in e)if(W.call(e,t))return!1;return!0})(l)||(q(l,((t,o)=>{const n=s(o);A(a,(o=>{""===t?e.formatter.remove(n,{value:null},o.dom,!0):e.formatter.apply(n,{value:t},o.dom)}))})),n(a[0]).each((t=>cl(e,t.dom,dl))))}))},Ql=Qs([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),ec={before:Ql.before,on:Ql.on,after:Ql.after,cata:(e,t,o,n)=>e.fold(t,o,n),getStart:e=>e.fold(g,g,g)},tc=(e,t)=>({selection:e,kill:t}),oc=(e,t)=>{const o=e.document.createRange();return o.selectNode(t.dom),o},nc=(e,t)=>{const o=e.document.createRange();return rc(o,t),o},rc=(e,t)=>e.selectNodeContents(t.dom),ic=(e,t,o)=>{const n=e.document.createRange();var r;return r=n,t.fold((e=>{r.setStartBefore(e.dom)}),((e,t)=>{r.setStart(e.dom,t)}),(e=>{r.setStartAfter(e.dom)})),((e,t)=>{t.fold((t=>{e.setEndBefore(t.dom)}),((t,o)=>{e.setEnd(t.dom,o)}),(t=>{e.setEndAfter(t.dom)}))})(n,o),n},sc=(e,t,o,n,r)=>{const i=e.document.createRange();return i.setStart(t.dom,o),i.setEnd(n.dom,r),i},ac=e=>({left:e.left,top:e.top,right:e.right,bottom:e.bottom,width:e.width,height:e.height}),lc=Qs([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),cc=(e,t,o)=>t(_e.fromDom(o.startContainer),o.startOffset,_e.fromDom(o.endContainer),o.endOffset),dc=(e,t)=>{const o=((e,t)=>t.match({domRange:e=>({ltr:p(e),rtl:x.none}),relative:(t,o)=>({ltr:eo((()=>ic(e,t,o))),rtl:eo((()=>x.some(ic(e,o,t))))}),exact:(t,o,n,r)=>({ltr:eo((()=>sc(e,t,o,n,r))),rtl:eo((()=>x.some(sc(e,n,r,t,o))))})}))(e,t);return((e,t)=>{const o=t.ltr();return o.collapsed?t.rtl().filter((e=>!1===e.collapsed)).map((e=>lc.rtl(_e.fromDom(e.endContainer),e.endOffset,_e.fromDom(e.startContainer),e.startOffset))).getOrThunk((()=>cc(0,lc.ltr,o))):cc(0,lc.ltr,o)})(0,o)},uc=(e,t)=>dc(e,t).match({ltr:(t,o,n,r)=>{const i=e.document.createRange();return i.setStart(t.dom,o),i.setEnd(n.dom,r),i},rtl:(t,o,n,r)=>{const i=e.document.createRange();return i.setStart(n.dom,r),i.setEnd(t.dom,o),i}});lc.ltr,lc.rtl;const hc=(e,t,o,n)=>({start:e,soffset:t,finish:o,foffset:n}),mc=(e,t,o,n)=>({start:ec.on(e,t),finish:ec.on(o,n)}),pc=(e,t)=>{const o=uc(e,t);return hc(_e.fromDom(o.startContainer),o.startOffset,_e.fromDom(o.endContainer),o.endOffset)},gc=mc,fc=(e,t,o,n,r)=>Se(o,n)?x.none():_i(o,n,t).bind((t=>{const n=t.boxes.getOr([]);return n.length>1?(r(e,n,t.start,t.finish),x.some(tc(x.some(gc(o,0,o,br(o))),!0))):x.none()})),vc=(e,t)=>({item:e,mode:t}),bc=(e,t,o,n=yc)=>e.property().parent(t).map((e=>vc(e,n))),yc=(e,t,o,n=wc)=>o.sibling(e,t).map((e=>vc(e,n))),wc=(e,t,o,n=wc)=>{const r=e.property().children(t);return o.first(r).map((e=>vc(e,n)))},_c=[{current:bc,next:yc,fallback:x.none()},{current:yc,next:wc,fallback:x.some(bc)},{current:wc,next:wc,fallback:x.some(yc)}],xc=(e,t,o,n,r=_c)=>D(r,(e=>e.current===o)).bind((o=>o.current(e,t,n,o.next).orThunk((()=>o.fallback.bind((o=>xc(e,t,o,n))))))),Cc=(e,t,o,n,r,i)=>xc(e,t,n,r).bind((t=>i(t.item)?x.none():o(t.item)?x.some(t.item):Cc(e,t.item,o,t.mode,r,i))),kc=e=>t=>0===e.property().children(t).length,Sc=(e,t,o,n)=>Cc(e,t,o,yc,{sibling:(e,t)=>e.query().prevSibling(t),first:e=>e.length>0?x.some(e[e.length-1]):x.none()},n),Tc=(e,t,o,n)=>Cc(e,t,o,yc,{sibling:(e,t)=>e.query().nextSibling(t),first:e=>e.length>0?x.some(e[0]):x.none()},n),Ec=gi(),Oc=(e,t)=>((e,t,o)=>Sc(e,t,kc(e),o))(Ec,e,t),Mc=(e,t)=>((e,t,o)=>Tc(e,t,kc(e),o))(Ec,e,t),Ac=Qs([{none:["message"]},{success:[]},{failedUp:["cell"]},{failedDown:["cell"]}]),Bc=e=>bt(e,"tr"),Nc={...Ac,verify:(e,t,o,n,r,i,s)=>bt(n,"td,th",s).bind((o=>bt(t,"td,th",s).map((t=>Se(o,t)?Se(n,o)&&br(o)===r?i(t):Ac.none("in same cell"):yi(Bc,[o,t]).fold((()=>((e,t,o)=>{const n=e.getRect(t),r=e.getRect(o);return r.right>n.left&&r.lefti(t))))))).getOr(Ac.none("default")),cata:(e,t,o,n,r)=>e.fold(t,o,n,r)},Rc=he("br"),Vc=(e,t,o)=>t(e,o).bind((e=>ce(e)&&0===gr(e).trim().length?Vc(e,t,o):x.some(e))),Dc=(e,t,o,n)=>((e,t)=>Pe(e,t).filter(Rc).orThunk((()=>Pe(e,t-1).filter(Rc))))(t,o).bind((t=>n.traverse(t).fold((()=>Vc(t,n.gather,e).map(n.relative)),(e=>(e=>Ae(e).bind((t=>{const o=De(t);return((e,t)=>P(e,v(Se,t)))(o,e).map((n=>((e,t,o,n)=>({parent:e,children:t,element:o,index:n}))(t,o,e,n)))})))(e).map((e=>ec.on(e.parent,e.index))))))),Pc=(e,t)=>({left:e.left,top:e.top+t,right:e.right,bottom:e.bottom+t}),Ic=(e,t)=>({left:e.left,top:e.top-t,right:e.right,bottom:e.bottom-t}),Fc=(e,t,o)=>({left:e.left+t,top:e.top+o,right:e.right+t,bottom:e.bottom+o}),Lc=e=>({left:e.left,top:e.top,right:e.right,bottom:e.bottom}),zc=(e,t)=>x.some(e.getRect(t)),Hc=(e,t,o)=>le(t)?zc(e,t).map(Lc):ce(t)?((e,t,o)=>o>=0&&o 0?e.getRangedRect(t,o-1,t,o):x.none())(e,t,o).map(Lc):x.none(),Zc=(e,t)=>le(t)?zc(e,t).map(Lc):ce(t)?e.getRangedRect(t,0,t,br(t)).map(Lc):x.none(),jc=Qs([{none:[]},{retry:["caret"]}]),Uc=(e,t,o)=>pt(t,fa).fold(w,(t=>Zc(e,t).exists((e=>((e,t)=>e.leftt.right)(o,e))))),$c={point:e=>e.bottom,adjuster:(e,t,o,n,r)=>{const i=Pc(r,5);return Math.abs(o.bottom-n.bottom)<1||o.top>r.bottom?jc.retry(i):o.top===r.bottom?jc.retry(Pc(r,1)):Uc(e,t,r)?jc.retry(Fc(i,5,0)):jc.none()},move:Pc,gather:Mc},Wc=(e,t,o,n,r)=>0===r?x.some(n):((e,t,o)=>e.elementFromPoint(t,o).filter((e=>"table"===ne(e))).isSome())(e,n.left,t.point(n))?((e,t,o,n,r)=>Wc(e,t,o,t.move(n,5),r))(e,t,o,n,r-1):e.situsFromPoint(n.left,t.point(n)).bind((i=>i.start.fold(x.none,(i=>Zc(e,i).bind((s=>t.adjuster(e,i,s,o,n).fold(x.none,(n=>Wc(e,t,o,n,r-1))))).orThunk((()=>x.some(n)))),x.none))),qc=(e,t,o)=>{const n=e.move(o,5),r=Wc(t,e,o,n,100).getOr(n);return((e,t,o)=>e.point(t)>o.getInnerHeight()?x.some(e.point(t)-o.getInnerHeight()):e.point(t)<0?x.some(-e.point(t)):x.none())(e,r,t).fold((()=>t.situsFromPoint(r.left,e.point(r))),(o=>(t.scrollBy(0,o),t.situsFromPoint(r.left,e.point(r)-o))))},Gc={tryUp:v(qc,{point:e=>e.top,adjuster:(e,t,o,n,r)=>{const i=Ic(r,5);return Math.abs(o.top-n.top)<1||o.bottome.getSelection().bind((n=>((e,t,o,n)=>{const r=Rc(t)?((e,t,o)=>o.traverse(t).orThunk((()=>Vc(t,o.gather,e))).map(o.relative))(e,t,n):Dc(e,t,o,n);return r.map((e=>({start:e,finish:e})))})(t,n.finish,n.foffset,o).fold((()=>x.some(Hi(n.finish,n.foffset))),(r=>{const i=e.fromSitus(r);return s=Nc.verify(e,n.finish,n.foffset,i.finish,i.foffset,o.failure,t),Nc.cata(s,(e=>x.none()),(()=>x.none()),(e=>x.some(Hi(e,0))),(e=>x.some(Hi(e,br(e)))));var s})))),Kc=(e,t,o,n,r,i)=>0===i?x.none():Qc(e,t,o,n,r).bind((s=>{const a=e.fromSitus(s),l=Nc.verify(e,o,n,a.finish,a.foffset,r.failure,t);return Nc.cata(l,(()=>x.none()),(()=>x.some(s)),(s=>Se(o,s)&&0===n?Xc(e,o,n,Ic,r):Kc(e,t,s,0,r,i-1)),(s=>Se(o,s)&&n===br(s)?Xc(e,o,n,Pc,r):Kc(e,t,s,br(s),r,i-1)))})),Xc=(e,t,o,n,r)=>Hc(e,t,o).bind((t=>Jc(e,r,n(t,Gc.getJumpSize())))),Jc=(e,t,o)=>{const n=Bo().browser;return n.isChromium()||n.isSafari()||n.isFirefox()?t.retry(e,o):x.none()},Qc=(e,t,o,n,r)=>Hc(e,o,n).bind((t=>Jc(e,r,t))),ed=(e,t,o,n,r)=>bt(n,"td,th",t).bind((n=>bt(n,"table",t).bind((i=>((e,t)=>mt(e,(e=>Ae(e).exists((e=>Se(e,t)))),void 0).isSome())(r,i)?((e,t,o)=>Yc(e,t,o).bind((n=>Kc(e,t,n.element,n.offset,o,20).map(e.fromSitus))))(e,t,o).bind((e=>bt(e.finish,"td,th",t).map((t=>({start:n,finish:t,range:e}))))):x.none())))),td=(e,t,o,n,r,i)=>i(n,t).orThunk((()=>ed(e,t,o,n,r).map((e=>{const t=e.range;return tc(x.some(gc(t.start,t.soffset,t.finish,t.foffset)),!0)})))),od=(e,t)=>bt(e,"tr",t).bind((e=>bt(e,"table",t).bind((o=>{const n=ut(o,"tr");return Se(e,n[0])?((e,t,o)=>Sc(Ec,e,(e=>xr(e).isSome()),o))(o,0,t).map((e=>{const t=br(e);return tc(x.some(gc(e,t,e,t)),!0)})):x.none()})))),nd=(e,t)=>bt(e,"tr",t).bind((e=>bt(e,"table",t).bind((o=>{const n=ut(o,"tr");return Se(e,n[n.length-1])?((e,t,o)=>Tc(Ec,e,(e=>_r(e).isSome()),o))(o,0,t).map((e=>tc(x.some(gc(e,0,e,0)),!0))):x.none()})))),rd=(e,t,o,n,r,i,s)=>ed(e,o,n,r,i).bind((e=>fc(t,o,e.start,e.finish,s))),id=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},sd=()=>{const e=(e=>{const t=id(x.none()),o=()=>t.get().each(e);return{clear:()=>{o(),t.set(x.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:e=>{o(),t.set(x.some(e))}}})(m);return{...e,on:t=>e.get().each(t)}},ad=(e,t)=>bt(e,"td,th",t),ld=e=>Be(e).exists(Xr),cd={traverse:Ve,gather:Mc,relative:ec.before,retry:Gc.tryDown,failure:Nc.failedDown},dd={traverse:Re,gather:Oc,relative:ec.before,retry:Gc.tryUp,failure:Nc.failedUp},ud=e=>t=>t===e,hd=ud(38),md=ud(40),pd=e=>e>=37&&e<=40,gd={isBackward:ud(37),isForward:ud(39)},fd={isBackward:ud(39),isForward:ud(37)},vd=Qs([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),bd={domRange:vd.domRange,relative:vd.relative,exact:vd.exact,exactFromRange:e=>vd.exact(e.start,e.soffset,e.finish,e.foffset),getWin:e=>{const t=(e=>e.match({domRange:e=>_e.fromDom(e.startContainer),relative:(e,t)=>ec.getStart(e),exact:(e,t,o,n)=>e}))(e);return _e.fromDom(Me(t).dom.defaultView)},range:hc},yd=document.caretPositionFromPoint?(e,t,o)=>{var n,r;return x.from(null===(r=(n=e.dom).caretPositionFromPoint)||void 0===r?void 0:r.call(n,t,o)).bind((t=>{if(null===t.offsetNode)return x.none();const o=e.dom.createRange();return o.setStart(t.offsetNode,t.offset),o.collapse(),x.some(o)}))}:document.caretRangeFromPoint?(e,t,o)=>{var n,r;return x.from(null===(r=(n=e.dom).caretRangeFromPoint)||void 0===r?void 0:r.call(n,t,o))}:x.none,wd=(e,t)=>{const o=ne(e);return"input"===o?ec.after(e):T(["br","img"],o)?0===t?ec.before(e):ec.after(e):ec.on(e,t)},_d=e=>x.from(e.getSelection()),xd=(e,t)=>{_d(e).each((e=>{e.removeAllRanges(),e.addRange(t)}))},Cd=(e,t,o,n,r)=>{const i=sc(e,t,o,n,r);xd(e,i)},kd=(e,t)=>dc(e,t).match({ltr:(t,o,n,r)=>{Cd(e,t,o,n,r)},rtl:(t,o,n,r)=>{_d(e).each((i=>{if(i.setBaseAndExtent)i.setBaseAndExtent(t.dom,o,n.dom,r);else if(i.extend)try{((e,t,o,n,r,i)=>{t.collapse(o.dom,n),t.extend(r.dom,i)})(0,i,t,o,n,r)}catch(i){Cd(e,n,r,t,o)}else Cd(e,n,r,t,o)}))}}),Sd=(e,t,o,n,r)=>{const i=((e,t,o,n)=>{const r=wd(e,t),i=wd(o,n);return bd.relative(r,i)})(t,o,n,r);kd(e,i)},Td=(e,t,o)=>{const n=((e,t)=>{const o=e.fold(ec.before,wd,ec.after),n=t.fold(ec.before,wd,ec.after);return bd.relative(o,n)})(t,o);kd(e,n)},Ed=e=>{if(e.rangeCount>0){const t=e.getRangeAt(0),o=e.getRangeAt(e.rangeCount-1);return x.some(hc(_e.fromDom(t.startContainer),t.startOffset,_e.fromDom(o.endContainer),o.endOffset))}return x.none()},Od=e=>{if(null===e.anchorNode||null===e.focusNode)return Ed(e);{const t=_e.fromDom(e.anchorNode),o=_e.fromDom(e.focusNode);return((e,t,o,n)=>{const r=((e,t,o,n)=>{const r=Oe(e).dom.createRange();return r.setStart(e.dom,t),r.setEnd(o.dom,n),r})(e,t,o,n),i=Se(e,o)&&t===n;return r.collapsed&&!i})(t,e.anchorOffset,o,e.focusOffset)?x.some(hc(t,e.anchorOffset,o,e.focusOffset)):Ed(e)}},Md=(e,t,o=!0)=>{const n=(o?nc:oc)(e,t);xd(e,n)},Ad=e=>(e=>_d(e).filter((e=>e.rangeCount>0)).bind(Od))(e).map((e=>bd.exact(e.start,e.soffset,e.finish,e.foffset))),Bd=e=>({elementFromPoint:(t,o)=>_e.fromPoint(_e.fromDom(e.document),t,o),getRect:e=>e.dom.getBoundingClientRect(),getRangedRect:(t,o,n,r)=>{const i=bd.exact(t,o,n,r);return((e,t)=>(e=>{const t=e.getClientRects(),o=t.length>0?t[0]:e.getBoundingClientRect();return o.width>0||o.height>0?x.some(o).map(ac):x.none()})(uc(e,t)))(e,i)},getSelection:()=>Ad(e).map((t=>pc(e,t))),fromSitus:t=>{const o=bd.relative(t.start,t.finish);return pc(e,o)},situsFromPoint:(t,o)=>((e,t,o)=>((e,t,o)=>{const n=_e.fromDom(e.document);return yd(n,t,o).map((e=>hc(_e.fromDom(e.startContainer),e.startOffset,_e.fromDom(e.endContainer),e.endOffset)))})(e,t,o))(e,t,o).map((e=>mc(e.start,e.soffset,e.finish,e.foffset))),clearSelection:()=>{(e=>{_d(e).each((e=>e.removeAllRanges()))})(e)},collapseSelection:(t=!1)=>{Ad(e).each((o=>o.fold((e=>e.collapse(t)),((o,n)=>{const r=t?o:n;Td(e,r,r)}),((o,n,r,i)=>{const s=t?o:r,a=t?n:i;Sd(e,s,a,s,a)}))))},setSelection:t=>{Sd(e,t.start,t.soffset,t.finish,t.foffset)},setRelativeSelection:(t,o)=>{Td(e,t,o)},selectNode:t=>{Md(e,t,!1)},selectContents:t=>{Md(e,t)},getInnerHeight:()=>e.innerHeight,getScrollY:()=>(e=>{const t=void 0!==e?e.dom:document,o=t.body.scrollLeft||t.documentElement.scrollLeft,n=t.body.scrollTop||t.documentElement.scrollTop;return bn(o,n)})(_e.fromDom(e.document)).top,scrollBy:(t,o)=>{((e,t,o)=>{const n=(void 0!==o?o.dom:document).defaultView;n&&n.scrollBy(e,t)})(t,o,_e.fromDom(e.document))}}),Nd=(e,t)=>({rows:e,cols:t}),Rd=e=>pt(e,ae).exists(Xr),Vd=(e,t)=>Rd(e)||Rd(t),Dd=e=>void 0!==e.dom.classList,Pd=(e,t)=>((e,t,o)=>{const n=((e,t)=>{const o=fe(e,t);return void 0===o||""===o?[]:o.split(" ")})(e,t).concat([o]);return pe(e,t,n.join(" ")),!0})(e,"class",t),Id=(e,t)=>{Dd(e)?e.dom.classList.add(t):Pd(e,t)},Fd=(e,t)=>Dd(e)&&e.dom.classList.contains(t),Ld=()=>({tag:"none"}),zd=e=>({tag:"multiple",elements:e}),Hd=e=>({tag:"single",element:e}),Zd=e=>{const t=_e.fromDom((e=>{if(nt()&&d(e.target)){const t=_e.fromDom(e.target);if(le(t)&&d(t.dom.shadowRoot)&&e.composed&&e.composedPath){const t=e.composedPath();if(t)return Z(t)}}return x.from(e.target)})(e).getOr(e.target)),o=()=>e.stopPropagation(),n=()=>e.preventDefault(),r=(i=n,s=o,(...e)=>i(s.apply(null,e)));var i,s;return((e,t,o,n,r,i,s)=>({target:e,x:t,y:o,stop:n,prevent:r,kill:i,raw:s}))(t,e.clientX,e.clientY,o,n,r,e)},jd=(e,t,o,n)=>{e.dom.removeEventListener(t,o,n)},Ud=_,$d=(e,t,o)=>((e,t,o,n)=>((e,t,o,n,r)=>{const i=((e,t)=>o=>{e(o)&&t(Zd(o))})(o,n);return e.dom.addEventListener(t,i,r),{unbind:v(jd,e,t,i,r)}})(e,t,o,n,!1))(e,t,Ud,o),Wd=Zd,qd=e=>!Fd(_e.fromDom(e.target),"ephox-snooker-resizer-bar"),Gd=(e,t)=>{const o=(r=Vi.selectedSelector,{get:()=>Si(_e.fromDom(e.getBody()),r).fold((()=>Fi(oi(e),ei(e)).fold(Ld,Hd)),zd)}),n=((e,t,o)=>{const n=t=>{be(t,e.selected),be(t,e.firstSelected),be(t,e.lastSelected)},r=t=>{pe(t,e.selected,"1")},i=e=>{s(e),o()},s=t=>{const o=ut(t,`${e.selectedSelector},${e.firstSelectedSelector},${e.lastSelectedSelector}`);A(o,n)};return{clearBeforeUpdate:s,clear:i,selectRange:(o,n,s,a)=>{i(o),A(n,r),pe(s,e.firstSelected,"1"),pe(a,e.lastSelected,"1"),t(n,s,a)},selectedSelector:e.selectedSelector,firstSelectedSelector:e.firstSelectedSelector,lastSelectedSelector:e.lastSelectedSelector}})(Vi,((t,o,n)=>{Gt(o).each((r=>{const i=Pr(e),s=Br(m,_e.fromDom(e.getDoc()),i),a=((e,t,o)=>{const n=Qo(e);return Es(n,t).map((e=>{const t=_s(n,o,!1),{rows:r}=$o(t),i=((e,t)=>{const o=e.slice(0,t[t.length-1].row+1),n=xs(o);return F(n,(e=>{const o=e.cells.slice(0,t[t.length-1].column+1);return M(o,(e=>e.element))}))})(r,e),s=((e,t)=>{const o=e.slice(t[0].row+t[0].rowspan-1,e.length),n=xs(o);return F(n,(e=>{const o=e.cells.slice(t[0].column+t[0].colspan-1,e.cells.length);return M(o,(e=>e.element))}))})(r,e);return{upOrLeftCells:i,downOrRightCells:s}}))})(r,{selection:Li(e)},s);((e,t,o,n,r)=>{e.dispatch("TableSelectionChange",{cells:t,start:o,finish:n,otherCells:r})})(e,t,o,n,a)}))}),(()=>(e=>{e.dispatch("TableSelectionClear")})(e)));var r;return e.on("init",(o=>{const r=e.getWin(),i=Qr(e),s=ei(e),a=((e,t,o,n)=>{const r=((e,t,o,n)=>{const r=sd(),i=r.clear,s=i=>{r.on((r=>{n.clearBeforeUpdate(t),ad(i.target,o).each((s=>{_i(r,s,o).each((o=>{const r=o.boxes.getOr([]);if(1===r.length){const o=r[0],s="false"===Jr(o),a=yt(Kr(i.target),o,Se);s&&a&&(n.selectRange(t,r,o,o),e.selectContents(o))}else r.length>1&&(n.selectRange(t,r,o.start,o.finish),e.selectContents(s))}))}))}))};return{clearstate:i,mousedown:e=>{n.clear(t),ad(e.target,o).filter(ld).each(r.set)},mouseover:e=>{s(e)},mouseup:e=>{s(e),i()}}})(Bd(e),t,o,n);return{clearstate:r.clearstate,mousedown:r.mousedown,mouseover:r.mouseover,mouseup:r.mouseup}})(r,i,s,n),l=((e,t,o,n)=>{const r=Bd(e),i=()=>(n.clear(t),x.none());return{keydown:(e,s,a,l,c,d)=>{const u=e.raw,h=u.which,m=!0===u.shiftKey,p=xi(t,n.selectedSelector).fold((()=>(pd(h)&&!m&&n.clearBeforeUpdate(t),pd(h)&&m&&!Vd(s,l)?x.none:md(h)&&m?v(rd,r,t,o,cd,l,s,n.selectRange):hd(h)&&m?v(rd,r,t,o,dd,l,s,n.selectRange):md(h)?v(td,r,o,cd,l,s,nd):hd(h)?v(td,r,o,dd,l,s,od):x.none)),(e=>{const o=o=>()=>{const i=U(o,(o=>((e,t,o,n,r)=>ki(n,e,t,r.firstSelectedSelector,r.lastSelectedSelector).map((e=>(r.clearBeforeUpdate(o),r.selectRange(o,e.boxes,e.start,e.finish),e.boxes))))(o.rows,o.cols,t,e,n)));return i.fold((()=>Ci(t,n.firstSelectedSelector,n.lastSelectedSelector).map((e=>{const o=md(h)||d.isForward(h)?ec.after:ec.before;return r.setRelativeSelection(ec.on(e.first,0),o(e.table)),n.clear(t),tc(x.none(),!0)}))),(e=>x.some(tc(x.none(),!0))))};return pd(h)&&m&&!Vd(s,l)?x.none:md(h)&&m?o([Nd(1,0)]):hd(h)&&m?o([Nd(-1,0)]):d.isBackward(h)&&m?o([Nd(0,-1),Nd(-1,0)]):d.isForward(h)&&m?o([Nd(0,1),Nd(1,0)]):pd(h)&&!m?i:x.none}));return p()},keyup:(e,r,i,s,a)=>xi(t,n.selectedSelector).fold((()=>{const l=e.raw,c=l.which;return!0===l.shiftKey&&pd(c)&&Vd(r,s)?((e,t,o,n,r,i,s)=>Se(o,r)&&n===i?x.none():bt(o,"td,th",t).bind((o=>bt(r,"td,th",t).bind((n=>fc(e,t,o,n,s))))))(t,o,r,i,s,a,n.selectRange):x.none()}),x.none)}})(r,i,s,n),c=((e,t,o,n)=>{const r=Bd(e);return(e,i)=>{n.clearBeforeUpdate(t),_i(e,i,o).each((e=>{const o=e.boxes.getOr([]);n.selectRange(t,o,e.start,e.finish),r.selectContents(i),r.collapseSelection()}))}})(r,i,s,n);e.on("TableSelectorChange",(e=>c(e.start,e.finish)));const d=(t,o)=>{(e=>!0===e.raw.shiftKey)(t)&&(o.kill&&t.kill(),o.selection.each((t=>{const o=bd.relative(t.start,t.finish),n=uc(r,o);e.selection.setRng(n)})))},u=e=>0===e.button,h=(()=>{const e=id(_e.fromDom(i)),t=id(0);return{touchEnd:o=>{const n=_e.fromDom(o.target);if(he("td")(n)||he("th")(n)){const r=e.get(),i=t.get();Se(r,n)&&o.timeStamp-i<300&&(o.preventDefault(),c(n,n))}e.set(n),t.set(o.timeStamp)}}})();e.on("dragstart",(e=>{a.clearstate()})),e.on("mousedown",(e=>{u(e)&&qd(e)&&a.mousedown(Wd(e))})),e.on("mouseover",(e=>{var t;void 0!==(t=e).buttons&&0==(1&t.buttons)||!qd(e)||a.mouseover(Wd(e))})),e.on("mouseup",(e=>{u(e)&&qd(e)&&a.mouseup(Wd(e))})),e.on("touchend",h.touchEnd),e.on("keyup",(t=>{const o=Wd(t);if(o.raw.shiftKey&&pd(o.raw.which)){const t=e.selection.getRng(),n=_e.fromDom(t.startContainer),r=_e.fromDom(t.endContainer);l.keyup(o,n,t.startOffset,r,t.endOffset).each((e=>{d(o,e)}))}})),e.on("keydown",(o=>{const n=Wd(o);t.hide();const r=e.selection.getRng(),i=_e.fromDom(r.startContainer),s=_e.fromDom(r.endContainer),a=hn(gd,fd)(_e.fromDom(e.selection.getStart()));l.keydown(n,i,r.startOffset,s,r.endOffset,a).each((e=>{d(n,e)})),t.show()})),e.on("NodeChange",(()=>{const t=e.selection,o=_e.fromDom(t.getStart()),r=_e.fromDom(t.getEnd());yi(Gt,[o,r]).fold((()=>n.clear(i)),m)}))})),e.on("PreInit",(()=>{e.serializer.addTempAttr(Vi.firstSelected),e.serializer.addTempAttr(Vi.lastSelected)})),{getSelectedCells:()=>((e,t,o,n)=>{switch(e.tag){case"none":return t();case"single":return(e=>[e.dom])(e.element);case"multiple":return(e=>M(e,(e=>e.dom)))(e.elements)}})(o.get(),p([])),clearSelectedCells:e=>n.clear(_e.fromDom(e))}},Yd=e=>{let t=[];return{bind:e=>{if(void 0===e)throw new Error("Event bind error: undefined handler");t.push(e)},unbind:e=>{t=N(t,(t=>t!==e))},trigger:(...o)=>{const n={};A(e,((e,t)=>{n[e]=o[t]})),A(t,(e=>{e(n)}))}}},Kd=e=>({registry:G(e,(e=>({bind:e.bind,unbind:e.unbind}))),trigger:G(e,(e=>e.trigger))}),Xd=e=>e.slice(0).sort(),Jd=(e,t)=>{const o=N(t,(t=>!T(e,t)));o.length>0&&(e=>{throw new Error("Unsupported keys for object: "+Xd(e).join(", "))})(o)},Qd=e=>((e,t)=>((e,t,o)=>{if(0===t.length)throw new Error("You must specify at least one required field.");return((e,t)=>{if(!s(t))throw new Error("The "+e+" fields must be an array. Was: "+t+".");A(t,(t=>{if(!r(t))throw new Error("The value "+t+" in the "+e+" fields was not a string.")}))})("required",t),(e=>{const t=Xd(e);D(t,((e,o)=>o{throw new Error("The field: "+e+" occurs more than once in the combined fields: ["+t.join(", ")+"].")}))})(t),n=>{const r=$(n);L(t,(e=>T(r,e)))||((e,t)=>{throw new Error("All required keys ("+Xd(e).join(", ")+") were not specified. Specified keys were: "+Xd(t).join(", ")+".")})(t,r),e(t,r);const i=N(t,(e=>!o.validate(n[e],e)));return i.length>0&&((e,t)=>{throw new Error("All values need to be of type: "+t+". Keys ("+Xd(e).join(", ")+") were not.")})(i,o.label),n}})(e,t,{validate:u,label:"function"}))(Jd,e),eu=Qd(["compare","extract","mutate","sink"]),tu=Qd(["element","start","stop","destroy"]),ou=Qd(["forceDrop","drop","move","delayDrop"]),nu=()=>{const e=(()=>{const e=Kd({move:Yd(["info"])});return{onEvent:m,reset:m,events:e.registry}})(),t=(()=>{let e=x.none();const t=Kd({move:Yd(["info"])});return{onEvent:(o,n)=>{n.extract(o).each((o=>{const r=((t,o)=>{const n=e.map((e=>t.compare(e,o)));return e=x.some(o),n})(n,o);r.each((e=>{t.trigger.move(e)}))}))},reset:()=>{e=x.none()},events:t.registry}})();let o=e;return{on:()=>{o.reset(),o=t},off:()=>{o.reset(),o=e},isOn:()=>o===t,onEvent:(e,t)=>{o.onEvent(e,t)},events:t.events}},ru=e=>{const t=e.replace(/\./g,"-");return{resolve:e=>t+"-"+e}},iu=ru("ephox-dragster").resolve;var su=eu({compare:(e,t)=>bn(t.left-e.left,t.top-e.top),extract:e=>x.some(bn(e.x,e.y)),sink:(e,t)=>{const o=(e=>{const t={layerClass:iu("blocker"),...e},o=_e.fromTag("div");return pe(o,"role","presentation"),Bt(o,{position:"fixed",left:"0px",top:"0px",width:"100%",height:"100%"}),Id(o,iu("blocker")),Id(o,t.layerClass),{element:p(o),destroy:()=>{$e(o)}}})(t),n=$d(o.element(),"mousedown",e.forceDrop),r=$d(o.element(),"mouseup",e.drop),i=$d(o.element(),"mousemove",e.move),s=$d(o.element(),"mouseout",e.delayDrop);return tu({element:o.element,start:e=>{ze(e,o.element())},stop:()=>{$e(o.element())},destroy:()=>{o.destroy(),r.unbind(),i.unbind(),s.unbind(),n.unbind()}})},mutate:(e,t)=>{e.mutate(t.left,t.top)}});const au=ru("ephox-snooker").resolve,lu=au("resizer-bar"),cu=au("resizer-rows"),du=au("resizer-cols"),uu=e=>{const t=ut(e.parent(),"."+lu);A(t,$e)},hu=(e,t,o)=>{const n=e.origin();A(t,(t=>{t.each((t=>{const r=o(n,t);Id(r,lu),ze(e.parent(),r)}))}))},mu=(e,t,o,n,r)=>{const i=wn(o),s=t.isResizable,a=n.length>0?Nn.positions(n,o):[],l=a.length>0?((e,t)=>F(e.all,((e,o)=>t(e.element)?[o]:[])))(e,s):[];((e,t,o,n)=>{hu(e,t,((e,t)=>{const r=((e,t,o,n,r)=>{const i=_e.fromTag("div");return Bt(i,{position:"absolute",left:t+"px",top:o-3.5+"px",height:"7px",width:n+"px"}),ge(i,{"data-row":e,role:"presentation"}),i})(t.row,o.left-e.left,t.y-e.top,n);return Id(r,cu),r}))})(t,N(a,((e,t)=>E(l,(e=>t===e)))),i,Po(o));const c=r.length>0?Vn.positions(r,o):[],d=c.length>0?((e,t)=>{const o=[];return O(e.grid.columns,(n=>{ln(e,n).map((e=>e.element)).forall(t)&&o.push(n)})),N(o,(o=>{const n=nn(e,(e=>e.column===o));return L(n,(e=>t(e.element)))}))})(e,s):[];((e,t,o,n)=>{hu(e,t,((e,t)=>{const r=((e,t,o,n,r)=>{const i=_e.fromTag("div");return Bt(i,{position:"absolute",left:t-3.5+"px",top:o+"px",height:r+"px",width:"7px"}),ge(i,{"data-column":e,role:"presentation"}),i})(t.col,t.x-e.left,o.top-e.top,0,n);return Id(r,du),r}))})(t,N(c,((e,t)=>E(d,(e=>t===e)))),i,fn(o))},pu=(e,t)=>{if(uu(e),e.isResizable(t)){const o=Qo(t),n=un(o),r=cn(o);mu(o,e,t,n,r)}},gu=(e,t)=>{const o=ut(e.parent(),"."+lu);A(o,t)},fu=e=>{gu(e,(e=>{At(e,"display","none")}))},vu=e=>{gu(e,(e=>{At(e,"display","block")}))},bu=au("resizer-bar-dragging"),yu=e=>{const t=(()=>{const e=Kd({drag:Yd(["xDelta","yDelta","target"])});let t=x.none();const o=(()=>{const e=Kd({drag:Yd(["xDelta","yDelta"])});return{mutate:(t,o)=>{e.trigger.drag(t,o)},events:e.registry}})();return o.events.drag.bind((o=>{t.each((t=>{e.trigger.drag(o.xDelta,o.yDelta,t)}))})),{assign:e=>{t=x.some(e)},get:()=>t,mutate:o.mutate,events:e.registry}})(),o=((e,t={})=>{var o;return((e,t,o)=>{let n=!1;const r=Kd({start:Yd([]),stop:Yd([])}),i=nu(),s=()=>{d.stop(),i.isOn()&&(i.off(),r.trigger.stop())},l=((e,t)=>{let o=null;const n=()=>{a(o)||(clearTimeout(o),o=null)};return{cancel:n,throttle:(...t)=>{n(),o=setTimeout((()=>{o=null,e.apply(null,t)}),200)}}})(s);i.events.move.bind((o=>{t.mutate(e,o.info)}));const c=e=>(...t)=>{n&&e.apply(null,t)},d=t.sink(ou({forceDrop:s,drop:c(s),move:c((e=>{l.cancel(),i.onEvent(e,t)})),delayDrop:c(l.throttle)}),o);return{element:d.element,go:e=>{d.start(e),i.on(),r.trigger.start()},on:()=>{n=!0},off:()=>{n=!1},isActive:()=>n,destroy:()=>{d.destroy()},events:r.registry}})(e,null!==(o=t.mode)&&void 0!==o?o:su,t)})(t,{});let n=x.none();const r=(e,t)=>x.from(fe(e,t));t.events.drag.bind((e=>{r(e.target,"data-row").each((t=>{const o=zt(e.target,"top");At(e.target,"top",o+e.yDelta+"px")})),r(e.target,"data-column").each((t=>{const o=zt(e.target,"left");At(e.target,"left",o+e.xDelta+"px")}))}));const i=(e,t)=>zt(e,t)-Pt(e,"data-initial-"+t,0);o.events.stop.bind((()=>{t.get().each((t=>{n.each((o=>{r(t,"data-row").each((e=>{const n=i(t,"top");be(t,"data-initial-top"),u.trigger.adjustHeight(o,n,parseInt(e,10))})),r(t,"data-column").each((e=>{const n=i(t,"left");be(t,"data-initial-left"),u.trigger.adjustWidth(o,n,parseInt(e,10))})),pu(e,o)}))}))}));const s=(n,r)=>{u.trigger.startAdjust(),t.assign(n),pe(n,"data-initial-"+r,zt(n,r)),Id(n,bu),At(n,"opacity","0.2"),o.go(e.parent())},l=$d(e.parent(),"mousedown",(e=>{var t;t=e.target,Fd(t,cu)&&s(e.target,"top"),(e=>Fd(e,du))(e.target)&&s(e.target,"left")})),c=t=>Se(t,e.view()),d=$d(e.view(),"mouseover",(t=>{var r;(r=t.target,bt(r,"table",c).filter(Xr)).fold((()=>{st(t.target)&&uu(e)}),(t=>{o.isActive()&&(n=x.some(t),pu(e,t))}))})),u=Kd({adjustHeight:Yd(["table","delta","row"]),adjustWidth:Yd(["table","delta","column"]),startAdjust:Yd([])});return{destroy:()=>{l.unbind(),d.unbind(),o.destroy(),uu(e)},refresh:t=>{pu(e,t)},on:o.on,off:o.off,hideBars:v(fu,e),showBars:v(vu,e),events:u.registry}},wu=(e,t,o)=>{const n=Nn,r=Vn,i=yu(e),s=Kd({beforeResize:Yd(["table","type"]),afterResize:Yd(["table","type"]),startDrag:Yd([])});return i.events.adjustHeight.bind((e=>{const t=e.table;s.trigger.beforeResize(t,"row");((e,t,o,n)=>{const r=Qo(e),i=((e,t,o)=>sr(e,t,o,Yn,(e=>e.getOrThunk(Zt))))(r,e,n),s=M(i,((e,n)=>o===n?Math.max(t+e,Zt()):e)),a=oa(r,s),l=((e,t)=>M(e.all,((e,o)=>({element:e.element,height:t[o]}))))(r,s);A(l,(e=>{jn(e.element,e.height)})),A(a,(e=>{jn(e.element,e.height)}));const c=R(s,((e,t)=>e+t),0);jn(e,c)})(t,n.delta(e.delta,t),e.row,n),s.trigger.afterResize(t,"row")})),i.events.startAdjust.bind((e=>{s.trigger.startDrag()})),i.events.adjustWidth.bind((e=>{const n=e.table;s.trigger.beforeResize(n,"col");const i=r.delta(e.delta,n),a=o(n);ra(n,i,e.column,t,a),s.trigger.afterResize(n,"col")})),{on:i.on,off:i.off,refreshBars:i.refresh,hideBars:i.hideBars,showBars:i.showBars,destroy:i.destroy,events:s.registry}},_u=e=>d(e)&&"TABLE"===e.nodeName,xu="bar-",Cu=e=>"false"!==fe(e,"data-mce-resize"),ku=e=>{const t=sd(),o=sd(),n=sd();let r,i;const s=t=>ml(e,t),a=()=>Lr(e)?es():Qi();return e.on("init",(()=>{const r=((e,t)=>e.inline?((e,t,o)=>({parent:p(t),view:p(e),origin:p(bn(0,0)),isResizable:o}))(_e.fromDom(e.getBody()),(()=>{const e=_e.fromTag("div");return Bt(e,{position:"static",height:"0",width:"0",padding:"0",margin:"0",border:"0"}),ze(at(_e.fromDom(document)),e),e})(),t):((e,t)=>{const o=de(e)?(e=>_e.fromDom(Me(e).dom.documentElement))(e):e;return{parent:p(o),view:p(e),origin:p(bn(0,0)),isResizable:t}})(_e.fromDom(e.getDoc()),t))(e,Cu);if(n.set(r),(e=>{const t=e.options.get("object_resizing");return T(t.split(","),"table")})(e)&&$r(e)){const n=a(),i=wu(r,n,s);i.on(),i.events.startDrag.bind((o=>{t.set(e.selection.getRng())})),i.events.beforeResize.bind((t=>{const o=t.table.dom;((e,t,o,n,r)=>{e.dispatch("ObjectResizeStart",{target:t,width:o,height:n,origin:r})})(e,o,ni(o),ri(o),xu+t.type)})),i.events.afterResize.bind((o=>{const n=o.table,r=n.dom;ti(n),t.on((t=>{e.selection.setRng(t),e.focus()})),((e,t,o,n,r)=>{e.dispatch("ObjectResized",{target:t,width:o,height:n,origin:r})})(e,r,ni(r),ri(r),xu+o.type),e.undoManager.add()})),o.set(i)}})),e.on("ObjectResizeStart",(t=>{const o=t.target;if(_u(o)){const n=_e.fromDom(o);A(e.dom.select(".mce-clonedresizable"),(t=>{e.dom.addClass(t,"mce-"+Fr(e)+"-columns")})),!Ol(n)&&jr(e)?Nl(n):!El(n)&&Zr(e)&&Bl(n),Ml(n)&&kt(t.origin,xu)&&Bl(n),r=t.width,i=Ur(e)?"":((e,t)=>{const o=e.dom.getStyle(t,"width")||e.dom.getAttrib(t,"width");return x.from(o).filter(Et)})(e,o).getOr("")}})),e.on("ObjectResized",(t=>{const o=t.target;if(_u(o)){const n=_e.fromDom(o),l=t.origin;kt(l,"corner-")&&((t,o,n)=>{const l=St(o,"e");if(""===i&&Bl(t),n!==r&&""!==i){At(t,"width",i);const o=a(),c=s(t),d=Lr(e)||l?(e=>ts(e).columns)(t)-1:0;ra(t,n-r,d,o,c)}else if((e=>/^(\d+(\.\d+)?)%$/.test(e))(i)){const e=parseFloat(i.replace("%",""));At(t,"width",n*e/r+"%")}(e=>/^(\d+(\.\d+)?)px$/.test(e))(i)&&(e=>{const t=Qo(e);an(t)||A(Wt(e),(e=>{const t=Nt(e,"width");At(e,"width",t),be(e,"width")}))})(t)})(n,l,t.width),ti(n),cl(e,n.dom,dl)}})),e.on("SwitchMode",(()=>{o.on((t=>{e.mode.isReadOnly()?t.hideBars():t.showBars()}))})),e.on("dragstart dragend",(e=>{o.on((t=>{"dragstart"===e.type?(t.hideBars(),t.off()):(t.on(),t.showBars())}))})),e.on("remove",(()=>{o.on((e=>{e.destroy()})),n.on((t=>{((e,t)=>{e.inline&&$e(t.parent())})(e,t)}))})),{refresh:e=>{o.on((t=>t.refreshBars(_e.fromDom(e))))},hide:()=>{o.on((e=>e.hideBars()))},show:()=>{o.on((e=>e.showBars()))}}},Su=e=>{(e=>{const t=e.options.register;t("table_clone_elements",{processor:"string[]"}),t("table_use_colgroups",{processor:"boolean",default:!0}),t("table_header_type",{processor:e=>{const t=T(["section","cells","sectionCells","auto"],e);return t?{value:e,valid:t}:{valid:!1,message:"Must be one of: section, cells, sectionCells or auto."}},default:"section"}),t("table_sizing_mode",{processor:"string",default:"auto"}),t("table_default_attributes",{processor:"object",default:{border:"1"}}),t("table_default_styles",{processor:"object",default:{"border-collapse":"collapse"}}),t("table_column_resizing",{processor:e=>{const t=T(["preservetable","resizetable"],e);return t?{value:e,valid:t}:{valid:!1,message:"Must be preservetable, or resizetable."}},default:"preservetable"}),t("table_resize_bars",{processor:"boolean",default:!0}),t("table_style_by_css",{processor:"boolean",default:!0}),t("table_merge_content_on_paste",{processor:"boolean",default:!0})})(e);const t=ku(e),o=Gd(e,t),n=pl(e,t,o);return Jl(e,n),((e,t)=>{const o=ei(e),n=t=>Fi(oi(e)).bind((n=>Gt(n,o).map((o=>{const r=Di(Li(e),o,n);return t(o,r)})))).getOr("");q({mceTableRowType:()=>n(t.getTableRowType),mceTableCellType:()=>n(t.getTableCellType),mceTableColType:()=>n(t.getTableColType)},((t,o)=>e.addQueryValueHandler(o,t)))})(e,n),zi(e,n),{getSelectedCells:o.getSelectedCells,clearSelectedCells:o.clearSelectedCells}};e.add("dom",(e=>({table:Su(e)})))}()},37041:function(e,t,o){o(16803)},16803:function(){!function(){"use strict";window.mailpoetTinymce.util.Tools.resolve("mailpoetTinymce.PluginManager").add("code",(e=>((e=>{e.addCommand("mceCodeEditor",(()=>{(e=>{const t=(e=>e.getContent({source_view:!0}))(e);e.windowManager.open({title:"Source Code",size:"large",body:{type:"panel",items:[{type:"textarea",name:"code"}]},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:{code:t},onSubmit:t=>{((e,t)=>{e.focus(),e.undoManager.transact((()=>{e.setContent(t)})),e.selection.setCursorLocation(),e.nodeChanged()})(e,t.getData().code),t.close()}})})(e)}))})(e),(e=>{const t=()=>e.execCommand("mceCodeEditor");e.ui.registry.addButton("code",{icon:"sourcecode",tooltip:"Source code",onAction:t}),e.ui.registry.addMenuItem("code",{icon:"sourcecode",text:"Source code",onAction:t})})(e),{})))}()},88658:function(e,t,o){o(25840)},25840:function(){!function(){"use strict";var e=window.mailpoetTinymce.util.Tools.resolve("mailpoetTinymce.PluginManager");const t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=n=e,(r=String).prototype.isPrototypeOf(o)||(null===(i=n.constructor)||void 0===i?void 0:i.name)===r.name)?"string":t;var o,n,r,i})(t)===e,o=e=>t=>typeof t===e,n=t("string"),r=t("object"),i=t("array"),s=(null,e=>null===e);const a=o("boolean"),l=e=>!(e=>null==e)(e),c=o("function"),d=(e,t)=>{if(i(e)){for(let o=0,n=e.length;o{},h=(e,t)=>e===t;class m{constructor(e,t){this.tag=e,this.value=t}static some(e){return new m(!0,e)}static none(){return m.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?m.some(e(this.value)):m.none()}bind(e){return this.tag?e(this.value):m.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:m.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return l(e)?m.some(e):m.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}m.singletonNone=new m(!1);const p=Array.prototype.indexOf,g=Array.prototype.push,f=e=>{const t=[];for(let o=0,n=e.length;o{for(let o=0;oe.exists((e=>o(e,t))),y=e=>{const t=[],o=e=>{t.push(e)};for(let t=0;te?m.some(t):m.none(),_=e=>t=>t.options.get(e),x=_("link_assume_external_targets"),C=_("link_context_toolbar"),k=_("link_list"),S=_("link_default_target"),T=_("link_default_protocol"),E=_("link_target_list"),O=_("link_rel_list"),M=_("link_class_list"),A=_("link_title"),B=_("allow_unsafe_link_target"),N=_("link_quicklink");var R=window.mailpoetTinymce.util.Tools.resolve("window.mailpoetTinymce.util.Tools");const V=e=>n(e.value)?e.value:"",D=(e,t)=>{const o=[];return R.each(e,(e=>{const r=(e=>n(e.text)?e.text:n(e.title)?e.title:"")(e);if(void 0!==e.menu){const n=D(e.menu,t);o.push({text:r,items:n})}else{const n=t(e);o.push({text:r,value:n})}})),o},P=(e=V)=>t=>m.from(t).map((t=>D(t,e))),I=e=>P(V)(e),F=P,L=(e,t)=>o=>({name:e,type:"listbox",label:t,items:o}),z=V,H=Object.keys,Z=Object.hasOwnProperty,j=(e,t)=>Z.call(e,t);var U=window.mailpoetTinymce.util.Tools.resolve("mailpoetTinymce.dom.TreeWalker"),$=window.mailpoetTinymce.util.Tools.resolve("window.mailpoetTinymce.util.URI");const W=e=>l(e)&&"a"===e.nodeName.toLowerCase(),q=e=>W(e)&&!!K(e),G=(e,t)=>{if(e.collapsed)return[];{const o=e.cloneContents(),n=o.firstChild,r=new U(n,o),i=[];let s=n;do{t(s)&&i.push(s)}while(s=r.next());return i}},Y=e=>/^\w+:/i.test(e),K=e=>{var t,o;return null!==(o=null!==(t=e.getAttribute("data-mce-href"))&&void 0!==t?t:e.getAttribute("href"))&&void 0!==o?o:""},X=(e,t)=>{const o=["noopener"],n=e?e.split(/\s+/):[],r=e=>e.filter((e=>-1===R.inArray(o,e))),i=t?(e=>(e=r(e)).length>0?e.concat(o):o)(n):r(n);return i.length>0?(e=>R.trim(e.sort().join(" ")))(i):""},J=(e,t)=>(t=t||te(e.selection.getRng())[0]||e.selection.getNode(),ie(t)?m.from(e.dom.select("a[href]",t)[0]):m.from(e.dom.getParent(t,"a[href]"))),Q=(e,t)=>J(e,t).isSome(),ee=(e,t)=>t.fold((()=>e.getContent({format:"text"})),(e=>e.innerText||e.textContent||"")).replace(/\uFEFF/g,""),te=e=>G(e,q),oe=e=>R.grep(e,q),ne=e=>oe(e).length>0,re=e=>{const t=e.schema.getTextInlineElements();if(J(e).exists((e=>e.hasAttribute("data-mce-block"))))return!1;const o=e.selection.getRng();return!!o.collapsed||0===G(o,(e=>1===e.nodeType&&!W(e)&&!j(t,e.nodeName.toLowerCase()))).length},ie=e=>l(e)&&"FIGURE"===e.nodeName&&/\bimage\b/i.test(e.className),se=(e,t,o)=>{const n=e.selection.getNode(),r=J(e,n),i=((e,t)=>{const o={...t};if(0===O(e).length&&!B(e)){const e=X(o.rel,"_blank"===o.target);o.rel=e||null}return m.from(o.target).isNone()&&!1===E(e)&&(o.target=S(e)),o.href=((e,t)=>"http"!==t&&"https"!==t||Y(e)?e:t+"://"+e)(o.href,x(e)),o})(e,(e=>{return t=["title","rel","class","target"],o=(t,o)=>(e[o].each((e=>{t[o]=e.length>0?e:null})),t),n={href:e.href},((e,t)=>{for(let o=0,n=e.length;o{n=o(n,e)})),n;var t,o,n})(o));e.undoManager.transact((()=>{o.href===t.href&&t.attach(),r.fold((()=>{((e,t,o,n)=>{const r=e.dom;ie(t)?ue(r,t,n):o.fold((()=>{e.execCommand("mceInsertLink",!1,n)}),(t=>{e.insertContent(r.createHTML("a",n,r.encode(t)))}))})(e,n,o.text,i)}),(t=>{e.focus(),((e,t,o,n)=>{o.each((e=>{j(t,"innerText")?t.innerText=e:t.textContent=e})),e.dom.setAttribs(t,n),e.selection.select(t)})(e,t,o.text,i)}))}))},ae=e=>{const{class:t,href:o,rel:n,target:r,text:i,title:a}=e;return((e,t)=>{const o={};var n;return((e,t,o,n)=>{((e,t)=>{const o=H(e);for(let n=0,r=o.length;n{(t(e,r)?o:n)(e,r)}))})(e,((e,t)=>!1===s(e)),(n=o,(e,t)=>{n[t]=e}),u),o})({class:t.getOrNull(),href:o,rel:n.getOrNull(),target:r.getOrNull(),text:i.getOrNull(),title:a.getOrNull()})},le=(e,t,o)=>{const n=((e,t)=>{const o=e.options.get,n={allow_html_data_urls:o("allow_html_data_urls"),allow_script_urls:o("allow_script_urls"),allow_svg_data_urls:o("allow_svg_data_urls")},r=t.href;return{...t,href:$.isDomSafe(r,"a",n)?r:""}})(e,o);e.hasPlugin("rtc",!0)?e.execCommand("createlink",!1,ae(n)):se(e,t,n)},ce=e=>{e.hasPlugin("rtc",!0)?e.execCommand("unlink"):(e=>{e.undoManager.transact((()=>{const t=e.selection.getNode();ie(t)?de(e,t):(e=>{const t=e.dom,o=e.selection,n=o.getBookmark(),r=o.getRng().cloneRange(),i=t.getParent(r.startContainer,"a[href]",e.getBody()),s=t.getParent(r.endContainer,"a[href]",e.getBody());i&&r.setStartBefore(i),s&&r.setEndAfter(s),o.setRng(r),e.execCommand("unlink"),o.moveToBookmark(n)})(e),e.focus()}))})(e)},de=(e,t)=>{var o;const n=e.dom.select("img",t)[0];if(n){const r=e.dom.getParents(n,"a[href]",t)[0];r&&(null===(o=r.parentNode)||void 0===o||o.insertBefore(n,r),e.dom.remove(r))}},ue=(e,t,o)=>{var n;const r=e.select("img",t)[0];if(r){const t=e.create("a",o);null===(n=r.parentNode)||void 0===n||n.insertBefore(t,r),t.appendChild(r)}},he=(e,t)=>v(t,(t=>(e=>{return j(t=e,o="items")&&void 0!==t[o]&&null!==t[o];var t,o})(t)?he(e,t.items):w(t.value===e,t))),me=(e,t)=>{const o={text:e.text,title:e.title},n=(e,n)=>{const r=(i=t,s=n,"link"===s?i.link:"anchor"===s?i.anchor:m.none()).getOr([]);var i,s;return((e,t,o,n)=>{const r=n[t],i=e.length>0;return void 0!==r?he(r,o).map((t=>({url:{value:t.value,meta:{text:i?e:t.text,attach:u}},text:i?e:t.text}))):m.none()})(o.text,n,r,e)};return{onChange:(e,t)=>{const r=t.name;return"url"===r?(e=>{const t=(n=e.url,w(o.text.length<=0,m.from(null===(r=n.meta)||void 0===r?void 0:r.text).getOr(n.value)));var n,r;const i=(e=>{var t;return w(o.title.length<=0,m.from(null===(t=e.meta)||void 0===t?void 0:t.title).getOr(""))})(e.url);return t.isSome()||i.isSome()?m.some({...t.map((e=>({text:e}))).getOr({}),...i.map((e=>({title:e}))).getOr({})}):m.none()})(e()):((e,t)=>p.call(e,t))(["anchor","link"],r)>-1?n(e(),r):"text"===r||"title"===r?(o[r]=e()[r],m.none()):m.none()}}};var pe=window.mailpoetTinymce.util.Tools.resolve("window.mailpoetTinymce.util.Delay");const ge=e=>{const t=e.href;return t.indexOf("@")>0&&-1===t.indexOf("/")&&-1===t.indexOf("mailto:")?m.some({message:"The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?",preprocess:e=>({...e,href:"mailto:"+t})}):m.none()},fe=(e,t)=>o=>{const n=o.href;return 1===e&&!Y(n)||0===e&&/^\s*www(\.|\d\.)/i.test(n)?m.some({message:`The URL you entered seems to be an external link. Do you want to add the required ${t}:// prefix?`,preprocess:e=>({...e,href:t+"://"+n})}):m.none()},ve=e=>{const t=e.dom.select("a:not([href])"),o=f(((e,t)=>{const o=e.length,n=new Array(o);for(let r=0;r{const t=e.name||e.id;return t?[{text:t,value:"#"+t}]:[]})));return o.length>0?m.some([{text:"None",value:""}].concat(o)):m.none()},be=e=>{const t=M(e);return t.length>0?I(t):m.none()},ye=e=>{try{return m.some(JSON.parse(e))}catch(e){return m.none()}},we=(e,t)=>{const o=O(e);if(o.length>0){const n=b(t,"_blank"),r=e=>X(z(e),n);return(!1===B(e)?F(r):I)(o)}return m.none()},_e=[{text:"Current window",value:""},{text:"New window",value:"_blank"}],xe=e=>{const t=E(e);return i(t)?I(t).orThunk((()=>m.some(_e))):!1===t?m.none():m.some(_e)},Ce=(e,t,o)=>{const n=e.getAttrib(t,o);return null!==n&&n.length>0?m.some(n):m.none()},ke=(e,t)=>(e=>{const t=t=>e.convertURL(t.value||t.url||"","href"),o=k(e);return new Promise((e=>{n(o)?fetch(o).then((e=>e.ok?e.text().then(ye):Promise.reject())).then(e,(()=>e(m.none()))):c(o)?o((t=>e(m.some(t)))):e(m.from(o))})).then((e=>e.bind(F(t)).map((e=>e.length>0?[{text:"None",value:""}].concat(e):e))))})(e).then((o=>{const n=((e,t)=>{const o=e.dom,n=re(e)?m.some(ee(e.selection,t)):m.none(),r=t.bind((e=>m.from(o.getAttrib(e,"href")))),i=t.bind((e=>m.from(o.getAttrib(e,"target")))),s=t.bind((e=>Ce(o,e,"rel"))),a=t.bind((e=>Ce(o,e,"class")));return{url:r,text:n,title:t.bind((e=>Ce(o,e,"title"))),target:i,rel:s,linkClass:a}})(e,t);return{anchor:n,catalogs:{targets:xe(e),rels:we(e,n.target),classes:be(e),anchor:ve(e),link:o},optNode:t,flags:{titleEnabled:A(e)}}})),Se=e=>{const t=(e=>{const t=J(e);return ke(e,t)})(e);t.then((t=>{const o=((e,t)=>o=>{const n=o.getData();if(!n.url.value)return ce(e),void o.close();const r=e=>m.from(n[e]).filter((o=>!b(t.anchor[e],o))),i={href:n.url.value,text:r("text"),target:r("target"),rel:r("rel"),class:r("linkClass"),title:r("title")},s={href:n.url.value,attach:void 0!==n.url.meta&&n.url.meta.attach?n.url.meta.attach:u};((e,t)=>v([ge,fe(x(e),T(e))],(e=>e(t))).fold((()=>Promise.resolve(t)),(o=>new Promise((n=>{((e,t,o)=>{const n=e.selection.getRng();pe.setEditorTimeout(e,(()=>{e.windowManager.confirm(t,(t=>{e.selection.setRng(n),o(t)}))}))})(e,o.message,(e=>{n(e?o.preprocess(t):t)}))})))))(e,i).then((t=>{le(e,s,t)})),o.close()})(e,t);return((e,t,o)=>{const n=e.anchor.text.map((()=>({name:"text",type:"input",label:"Text to display"}))).toArray(),r=e.flags.titleEnabled?[{name:"title",type:"input",label:"Title"}]:[],i=((e,t)=>{const o=e.anchor,n=o.url.getOr("");return{url:{value:n,meta:{original:{value:n}}},text:o.text.getOr(""),title:o.title.getOr(""),anchor:n,link:n,rel:o.rel.getOr(""),target:o.target.or(t).getOr(""),linkClass:o.linkClass.getOr("")}})(e,m.from(S(o))),s=e.catalogs,a=me(i,s);return{title:"Insert/Edit Link",size:"normal",body:{type:"panel",items:f([[{name:"url",type:"urlinput",filetype:"file",label:"URL"}],n,r,y([s.anchor.map(L("anchor","Anchors")),s.rels.map(L("rel","Rel")),s.targets.map(L("target","Open link in...")),s.link.map(L("link","Link list")),s.classes.map(L("linkClass","Class"))])])},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:i,onChange:(e,{name:t})=>{a.onChange(e.getData,{name:t}).each((t=>{e.setData(t)}))},onSubmit:t}})(t,o,e)})).then((t=>{e.windowManager.open(t)}))};var Te=window.mailpoetTinymce.util.Tools.resolve("window.mailpoetTinymce.util.VK");const Ee=(e,t)=>e.dom.getParent(t,"a[href]"),Oe=e=>Ee(e,e.selection.getStart()),Me=(e,t)=>{if(t){const o=K(t);if(/^#/.test(o)){const t=e.dom.select(o);t.length&&e.selection.scrollIntoView(t[0],!0)}else(e=>{const t=document.createElement("a");t.target="_blank",t.href=e,t.rel="noreferrer noopener";const o=document.createEvent("MouseEvents");o.initMouseEvent("click",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),((e,t)=>{document.body.appendChild(e),e.dispatchEvent(t),document.body.removeChild(e)})(t,o)})(t.href)}},Ae=e=>()=>{e.execCommand("mceLink",!1,{dialog:!0})},Be=e=>()=>{Me(e,Oe(e))},Ne=(e,t)=>(e.on("NodeChange",t),()=>e.off("NodeChange",t)),Re=e=>t=>{const o=()=>{t.setActive(!e.mode.isReadOnly()&&Q(e,e.selection.getNode())),t.setEnabled(e.selection.isEditable())};return o(),Ne(e,o)},Ve=e=>t=>{const o=()=>{t.setEnabled(e.selection.isEditable())};return o(),Ne(e,o)},De=e=>t=>{const o=()=>t.setEnabled((e=>1===(e.selection.isCollapsed()?oe(e.dom.getParents(e.selection.getStart())):te(e.selection.getRng())).length)(e));return o(),Ne(e,o)},Pe=e=>t=>{const o=e.dom.getParents(e.selection.getStart()),n=o=>{t.setEnabled((t=>{return ne(t)||(o=e.selection.getRng(),te(o).length>0);var o})(o)&&e.selection.isEditable())};return n(o),Ne(e,(e=>n(e.parents)))};e.add("link",(e=>{(e=>{const t=e.options.register;t("link_assume_external_targets",{processor:e=>{const t=n(e)||a(e);return t?!0===e?{value:1,valid:t}:"http"===e||"https"===e?{value:e,valid:t}:{value:0,valid:t}:{valid:!1,message:"Must be a string or a boolean."}},default:!1}),t("link_context_toolbar",{processor:"boolean",default:!1}),t("link_list",{processor:e=>n(e)||c(e)||d(e,r)}),t("link_default_target",{processor:"string"}),t("link_default_protocol",{processor:"string",default:"https"}),t("link_target_list",{processor:e=>a(e)||d(e,r),default:!0}),t("link_rel_list",{processor:"object[]",default:[]}),t("link_class_list",{processor:"object[]",default:[]}),t("link_title",{processor:"boolean",default:!0}),t("allow_unsafe_link_target",{processor:"boolean",default:!1}),t("link_quicklink",{processor:"boolean",default:!1})})(e),(e=>{e.ui.registry.addToggleButton("link",{icon:"link",tooltip:"Insert/edit link",onAction:Ae(e),onSetup:Re(e)}),e.ui.registry.addButton("openlink",{icon:"new-tab",tooltip:"Open link",onAction:Be(e),onSetup:De(e)}),e.ui.registry.addButton("unlink",{icon:"unlink",tooltip:"Remove link",onAction:()=>ce(e),onSetup:Pe(e)})})(e),(e=>{e.ui.registry.addMenuItem("openlink",{text:"Open link",icon:"new-tab",onAction:Be(e),onSetup:De(e)}),e.ui.registry.addMenuItem("link",{icon:"link",text:"Link...",shortcut:"Meta+K",onSetup:Ve(e),onAction:Ae(e)}),e.ui.registry.addMenuItem("unlink",{icon:"unlink",text:"Remove link",onAction:()=>ce(e),onSetup:Pe(e)})})(e),(e=>{e.ui.registry.addContextMenu("link",{update:t=>e.dom.isEditable(t)?ne(e.dom.getParents(t,"a"))?"link unlink openlink":"link":""})})(e),(e=>{const t=t=>{const o=e.selection.getNode();return t.setEnabled(Q(e,o)),u};e.ui.registry.addContextForm("quicklink",{launch:{type:"contextformtogglebutton",icon:"link",tooltip:"Link",onSetup:Re(e)},label:"Link",predicate:t=>C(e)&&Q(e,t),initValue:()=>J(e).fold((()=>""),K),commands:[{type:"contextformtogglebutton",icon:"link",tooltip:"Link",primary:!0,onSetup:t=>{const o=e.selection.getNode();return t.setActive(Q(e,o)),Re(e)(t)},onAction:t=>{const o=t.getValue(),n=(t=>{const o=J(e),n=re(e);if(o.isNone()&&n){const n=ee(e.selection,o);return w(0===n.length,t)}return m.none()})(o);le(e,{href:o,attach:u},{href:o,text:n,title:m.none(),rel:m.none(),target:m.none(),class:m.none()}),(e=>{e.selection.collapse(!1)})(e),t.hide()}},{type:"contextformbutton",icon:"unlink",tooltip:"Remove link",onSetup:t,onAction:t=>{ce(e),t.hide()}},{type:"contextformbutton",icon:"new-tab",tooltip:"Open link",onSetup:t,onAction:t=>{Be(e)(),t.hide()}}]})})(e),(e=>{e.on("click",(t=>{const o=Ee(e,t.target);o&&Te.metaKeyPressed(t)&&(t.preventDefault(),Me(e,o))})),e.on("keydown",(t=>{if(!t.isDefaultPrevented()&&13===t.keyCode&&(e=>!0===e.altKey&&!1===e.shiftKey&&!1===e.ctrlKey&&!1===e.metaKey)(t)){const o=Oe(e);o&&(t.preventDefault(),Me(e,o))}}))})(e),(e=>{e.addCommand("mceLink",((t,o)=>{!0!==(null==o?void 0:o.dialog)&&N(e)?e.dispatch("contexttoolbar-show",{toolbarKey:"quicklink"}):Se(e)}))})(e),(e=>{e.addShortcut("Meta+K","",(()=>{e.execCommand("mceLink")}))})(e)}))}()},62980:function(e,t,o){o(48239)},48239:function(){!function(){"use strict";var e=window.mailpoetTinymce.util.Tools.resolve("mailpoetTinymce.PluginManager");const t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=n=e,(r=String).prototype.isPrototypeOf(o)||(null===(i=n.constructor)||void 0===i?void 0:i.name)===r.name)?"string":t;var o,n,r,i})(t)===e,o=e=>t=>typeof t===e,n=t("string"),r=t("object"),i=t("array"),s=o("boolean"),a=e=>!(e=>null==e)(e),l=o("function"),c=o("number"),d=()=>{},u=(e,t)=>e===t,h=e=>t=>!e(t),m=(!1,()=>false);class p{constructor(e,t){this.tag=e,this.value=t}static some(e){return new p(!0,e)}static none(){return p.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?p.some(e(this.value)):p.none()}bind(e){return this.tag?e(this.value):p.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:p.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return a(e)?p.some(e):p.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}p.singletonNone=new p(!1);const g=Array.prototype.slice,f=Array.prototype.indexOf,v=Array.prototype.push,b=(e,t)=>{return o=e,n=t,f.call(o,n)>-1;var o,n},y=(e,t)=>{for(let o=0,n=e.length;o{const o=e.length,n=new Array(o);for(let r=0;r{for(let o=0,n=e.length;o{const o=[];for(let n=0,r=e.length;n(_(e,((e,n)=>{o=t(o,e,n)})),o),k=(e,t,o)=>{for(let n=0,r=e.length;nk(e,t,m),T=(e,t)=>(e=>{const t=[];for(let o=0,n=e.length;o{const t=g.call(e,0);return t.reverse(),t},O=(e,t)=>t>=0&&tO(e,0),A=e=>O(e,e.length-1),B=(e,t)=>{const o=[],n=l(t)?e=>y(o,(o=>t(o,e))):e=>b(o,e);for(let t=0,r=e.length;te.exists((e=>o(e,t))),R=(e,t,o)=>e.isSome()&&t.isSome()?p.some(o(e.getOrDie(),t.getOrDie())):p.none(),V=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},D=(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return V(o.childNodes[0])},P=(e,t)=>{const o=(t||document).createElement(e);return V(o)},I=V,F=(e,t)=>e.dom===t.dom;"undefined"!=typeof window?window:Function("return this;")();const L=e=>e.dom.nodeName.toLowerCase(),z=e=>e.dom.nodeType,H=(1,e=>1===z(e));const Z=e=>t=>H(t)&&L(t)===e,j=e=>p.from(e.dom.parentNode).map(I),U=e=>w(e.dom.childNodes,I),$=(e,t)=>{const o=e.dom.childNodes;return p.from(o[t]).map(I)},W=e=>$(e,0),q=e=>$(e,e.dom.childNodes.length-1),G=(e,t,o)=>{let n=e.dom;const r=l(o)?o:m;for(;n.parentNode;){n=n.parentNode;const e=I(n);if(t(e))return p.some(e);if(r(e))break}return p.none()},Y=(e,t,o)=>((e,t,o,n,r)=>n(o)?p.some(o):l(r)&&r(o)?p.none():t(o,n,r))(0,G,e,t,o),K=(e,t)=>{j(e).each((o=>{o.dom.insertBefore(t.dom,e.dom)}))},X=(e,t)=>{e.dom.appendChild(t.dom)},J=(e,t)=>{_(t,(t=>{X(e,t)}))},Q=e=>{e.dom.textContent="",_(U(e),(e=>{ee(e)}))},ee=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)};var te=window.mailpoetTinymce.util.Tools.resolve("mailpoetTinymce.dom.RangeUtils"),oe=window.mailpoetTinymce.util.Tools.resolve("mailpoetTinymce.dom.TreeWalker"),ne=window.mailpoetTinymce.util.Tools.resolve("window.mailpoetTinymce.util.VK");const re=e=>w(e,I),ie=Object.keys,se=(e,t)=>{const o=ie(e);for(let n=0,r=o.length;n{const o=e.dom;se(t,((e,t)=>{((e,t,o)=>{if(!(n(o)||s(o)||c(o)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",o,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,o+"")})(o,t,e)}))},le=e=>C(e.dom.attributes,((e,t)=>(e[t.name]=t.value,e)),{}),ce=e=>((e,t)=>I(e.dom.cloneNode(!0)))(e),de=(e,t)=>{const o=((e,t)=>{const o=P(t),n=le(e);return ae(o,n),o})(e,t);var n,r;r=o,(e=>p.from(e.dom.nextSibling).map(I))(n=e).fold((()=>{j(n).each((e=>{X(e,r)}))}),(e=>{K(e,r)}));const i=U(e);return J(o,i),ee(e),o};var ue=window.mailpoetTinymce.util.Tools.resolve("mailpoetTinymce.dom.DOMUtils"),he=window.mailpoetTinymce.util.Tools.resolve("window.mailpoetTinymce.util.Tools");const me=e=>t=>a(t)&&t.nodeName.toLowerCase()===e,pe=e=>t=>a(t)&&e.test(t.nodeName),ge=e=>a(e)&&3===e.nodeType,fe=e=>a(e)&&1===e.nodeType,ve=pe(/^(OL|UL|DL)$/),be=pe(/^(OL|UL)$/),ye=me("ol"),we=pe(/^(LI|DT|DD)$/),_e=pe(/^(DT|DD)$/),xe=pe(/^(TH|TD)$/),Ce=me("br"),ke=(e,t)=>a(t)&&t.nodeName in e.schema.getTextBlockElements(),Se=(e,t)=>a(e)&&e.nodeName in t,Te=(e,t)=>a(t)&&t.nodeName in e.schema.getVoidElements(),Ee=(e,t,o)=>{const n=e.isEmpty(t);return!(o&&e.select("span[data-mce-type=bookmark]",t).length>0)&&n},Oe=(e,t)=>e.isChildOf(t,e.getRoot()),Me=e=>t=>t.options.get(e),Ae=Me("lists_indent_on_tab"),Be=Me("forced_root_block"),Ne=Me("forced_root_block_attrs"),Re=(e,t)=>{const o=e.dom,n=e.schema.getBlockElements(),r=o.createFragment(),i=Be(e),s=Ne(e);let a,l,c=!1;for(l=o.create(i,s),Se(t.firstChild,n)||r.appendChild(l);a=t.firstChild;){const e=a.nodeName;c||"SPAN"===e&&"bookmark"===a.getAttribute("data-mce-type")||(c=!0),Se(a,n)?(r.appendChild(a),l=null):(l||(l=o.create(i,s),r.appendChild(l)),l.appendChild(a))}return!c&&l&&l.appendChild(o.create("br",{"data-mce-bogus":"1"})),r},Ve=ue.DOM,De=Z("dd"),Pe=Z("dt"),Ie=(e,t)=>{var o;De(t)?de(t,"dt"):Pe(t)&&(o=t,p.from(o.dom.parentElement).map(I)).each((o=>((e,t,o)=>{const n=Ve.select('span[data-mce-type="bookmark"]',t),r=Re(e,o),i=Ve.createRng();i.setStartAfter(o),i.setEndAfter(t);const s=i.extractContents();for(let t=s.firstChild;t;t=t.firstChild)if("LI"===t.nodeName&&e.dom.isEmpty(t)){Ve.remove(t);break}e.dom.isEmpty(s)||Ve.insertAfter(s,t),Ve.insertAfter(r,t);const a=o.parentElement;a&&Ee(e.dom,a)&&(e=>{const t=e.parentNode;t&&he.each(n,(e=>{t.insertBefore(e,o.parentNode)})),Ve.remove(e)})(a),Ve.remove(o),Ee(e.dom,t)&&Ve.remove(t)})(e,o.dom,t.dom)))},Fe=e=>{Pe(e)&&de(e,"dd")},Le=(e,t)=>{if(ge(e))return{container:e,offset:t};const o=te.getNode(e,t);return ge(o)?{container:o,offset:t>=e.childNodes.length?o.data.length:0}:o.previousSibling&&ge(o.previousSibling)?{container:o.previousSibling,offset:o.previousSibling.data.length}:o.nextSibling&&ge(o.nextSibling)?{container:o.nextSibling,offset:0}:{container:e,offset:t}},ze=e=>{const t=e.cloneRange(),o=Le(e.startContainer,e.startOffset);t.setStart(o.container,o.offset);const n=Le(e.endContainer,e.endOffset);return t.setEnd(n.container,n.offset),t},He=["OL","UL","DL"],Ze=He.join(","),je=(e,t)=>{const o=t||e.selection.getStart(!0);return e.dom.getParent(o,Ze,We(e,o))},Ue=e=>{const t=e.selection.getSelectedBlocks();return x(((e,t)=>{const o=he.map(t,(t=>e.dom.getParent(t,"li,dd,dt",We(e,t))||t));return B(o)})(e,t),we)},$e=(e,t)=>{const o=e.dom.getParents(t,"TD,TH");return o.length>0?o[0]:e.getBody()},We=(e,t)=>{const o=e.dom.getParents(t,e.dom.isBlock),n=S(o,(t=>{return o=e.schema,!ve(n=t)&&!we(n)&&y(He,(e=>o.isValidChild(n.nodeName,e)));var o,n}));return n.getOr(e.getBody())},qe=(e,t)=>{const o=e.dom.getParents(t,"ol,ul",We(e,t));return A(o)},Ge=(e,t)=>{const o=w(t,(t=>qe(e,t).getOr(t)));return B(o)},Ye=e=>/\btox\-/.test(e.className),Ke=(e,t)=>k(e,ve,xe).exists((e=>e.nodeName===t&&!Ye(e))),Xe=(e,t)=>null!==t&&!e.dom.isEditable(t),Je=(e,t)=>{const o=e.dom.getParent(t,"ol,ul,dl");return Xe(e,o)},Qe=(e,t)=>{const o=e.selection.getNode();return t({parents:e.dom.getParents(o),element:o}),e.on("NodeChange",t),()=>e.off("NodeChange",t)},et=(e,t)=>{const o=(t||document).createDocumentFragment();return _(e,(e=>{o.appendChild(e.dom)})),I(o)},tt=(e,t,o)=>e.dispatch("ListMutation",{action:t,element:o}),ot=(nt=/^\s+|\s+$/g,e=>e.replace(nt,""));var nt;const rt=(e,t,o)=>{((e,t,o)=>{if(!n(o))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",o,":: Element ",e),new Error("CSS value must be a string: "+o);(e=>void 0!==e.style&&l(e.style.getPropertyValue))(e)&&e.style.setProperty(t,o)})(e.dom,t,o)},it=e=>((e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}})(e,"OL,UL"),st=e=>W(e).exists(it),at=e=>"listAttributes"in e,lt=e=>"isComment"in e,ct=e=>e.depth>0,dt=e=>e.isSelected,ut=e=>{const t=U(e),o=q(e).exists(it)?t.slice(0,-1):t;return w(o,ce)},ht=(e,t)=>{X(e.item,t.list)},mt=(e,t)=>{const o={list:P(t,e),item:P("li",e)};return X(o.list,o.item),o},pt=(e,t,o)=>{const n=t.slice(0,o.depth);return A(n).each((t=>{if(at(o)){const n=((e,t,o)=>{const n=P("li",e);return ae(n,t),J(n,o),n})(e,o.itemAttributes,o.content);((e,t)=>{X(e.list,t),e.item=t})(t,n),((e,t)=>{L(e.list)!==t.listType&&(e.list=de(e.list,t.listType)),ae(e.list,t.listAttributes)})(t,o)}else if((e=>"isInPreviousLi"in e)(o)){if(o.isInPreviousLi){const n=((e,t,o,n)=>{const r=P(n,e);return ae(r,t),J(r,o),r})(e,o.attributes,o.content,o.type);X(t.item,n)}}else{const e=D(`\x3c!--${o.content}--\x3e`);X(t.list,e)}})),n},gt=(e,t)=>{let o=p.none();const n=C(t,((t,n,r)=>at(n)?n.depth>t.length?((e,t,o)=>{const n=((e,t,o)=>{const n=[];for(let r=0;r{for(let t=1;t{for(let t=0;t{ae(e.list,t.listAttributes),ae(e.item,t.itemAttributes),J(e.item,t.content)}))})(n,o),r=n,R(A(t),M(r),ht),t.concat(n)})(e,t,n):pt(e,t,n):0===r&<(n)?(o=p.some(n),t):pt(e,t,n)),[]);return o.each((e=>{const t=D(`\x3c!--${e.content}--\x3e`);M(n).each((e=>{((e,t)=>{W(e).fold((()=>{X(e,t)}),(o=>{e.dom.insertBefore(t.dom,o.dom)}))})(e.list,t)}))})),M(n).map((e=>e.list))},ft=e=>(_(e,((t,o)=>{((e,t)=>{const o=e[t].depth,n=e=>e.depth===o&&!e.dirty,r=e=>e.depthk(e.slice(t+1),n,r)))})(e,o).fold((()=>{t.dirty&&at(t)&&(e=>{e.listAttributes=((e,t)=>{const o={};var n;return((e,t,o,n)=>{se(e,((e,r)=>{(t(e,r)?o:n)(e,r)}))})(e,t,(n=o,(e,t)=>{n[t]=e}),d),o})(e.listAttributes,((e,t)=>"start"!==t))})(t)}),(e=>{return n=e,void(at(o=t)&&at(n)&&(o.listType=n.listType,o.listAttributes={...n.listAttributes}));var o,n}))})),e),vt=(e,t,o,n)=>{var r,i;if(8===z(i=n)||"#comment"===L(i))return[{depth:e+1,content:null!==(r=n.dom.nodeValue)&&void 0!==r?r:"",dirty:!1,isSelected:!1,isComment:!0}];t.each((e=>{F(e.start,n)&&o.set(!0)}));const s=((e,t,o)=>j(e).filter(H).map((n=>({depth:t,dirty:!1,isSelected:o,content:ut(e),itemAttributes:le(e),listAttributes:le(n),listType:L(n),isInPreviousLi:!1}))))(n,e,o.get());t.each((e=>{F(e.end,n)&&o.set(!1)}));const a=q(n).filter(it).map((n=>yt(e,t,o,n))).getOr([]);return s.toArray().concat(a)},bt=(e,t,o,n)=>W(n).filter(it).fold((()=>vt(e,t,o,n)),(r=>{const i=C(U(n),((n,r,i)=>{if(0===i)return n;{const i=vt(e,t,o,r).map((e=>((e,t,o)=>at(e)?{depth:e.depth,dirty:e.dirty,content:e.content,isSelected:e.isSelected,type:t,attributes:e.itemAttributes,isInPreviousLi:!0}:e)(e,r.dom.nodeName.toLowerCase())));return n.concat(i)}}),[]);return yt(e,t,o,r).concat(i)})),yt=(e,t,o,n)=>T(U(n),(n=>(it(n)?yt:bt)(e+1,t,o,n))),wt=(e,t,o)=>{const n=((e,t)=>{const o=(e=>{let t=!1;return{get:()=>t,set:e=>{t=e}}})();return w(e,(e=>({sourceList:e,entries:yt(0,t,o,e)})))})(t,(e=>{const t=w(Ue(e),I);return R(S(t,h(st)),S(E(t),h(st)),((e,t)=>({start:e,end:t})))})(e));_(n,(t=>{((e,t)=>{_(x(e,dt),(e=>((e,t)=>{switch(e){case"Indent":t.depth++;break;case"Outdent":t.depth--;break;case"Flatten":t.depth=0}t.dirty=!0})(t,e)))})(t.entries,o);const n=((e,t)=>T(((e,t)=>{if(0===e.length)return[];{let o=t(e[0]);const n=[];let r=[];for(let i=0,s=e.length;iM(t).exists(ct)?((e,t)=>{const o=ft(t);return gt(e.contentDocument,o).toArray()})(e,t):((e,t)=>{const o=ft(t);return w(o,(t=>{const o=lt(t)?et([D(`\x3c!--${t.content}--\x3e`)]):et(t.content);return I(Re(e,o.dom))}))})(e,t))))(e,t.entries);var r;_(n,(t=>{tt(e,"Indent"===o?"IndentList":"OutdentList",t.dom)})),r=t.sourceList,_(n,(e=>{K(r,e)})),ee(t.sourceList)}))},_t=(e,t)=>{const o=re((e=>{const t=(e=>{const t=qe(e,e.selection.getStart()),o=x(e.selection.getSelectedBlocks(),be);return t.toArray().concat(o)})(e),o=(e=>{const t=e.selection.getStart();return e.dom.getParents(t,"ol,ul",We(e,t))})(e);return S(o,(e=>{return t=I(e),j(t).exists((e=>we(e.dom)&&W(e).exists((e=>!ve(e.dom)))&&q(e).exists((e=>!ve(e.dom)))));var t})).fold((()=>Ge(e,t)),(e=>[e]))})(e)),n=re((e=>x(Ue(e),_e))(e));let r=!1;if(o.length||n.length){const i=e.selection.getBookmark();wt(e,o,t),((e,t,o)=>{_(o,"Indent"===t?Fe:t=>Ie(e,t))})(e,t,n),e.selection.moveToBookmark(i),e.selection.setRng(ze(e.selection.getRng())),e.nodeChanged(),r=!0}return r},xt=(e,t)=>!(e=>{const t=je(e);return Xe(e,t)})(e)&&_t(e,t),Ct=e=>xt(e,"Indent"),kt=e=>xt(e,"Outdent"),St=e=>xt(e,"Flatten"),Tt=e=>"\ufeff"===e;var Et=window.mailpoetTinymce.util.Tools.resolve("mailpoetTinymce.dom.BookmarkManager");const Ot=ue.DOM,Mt=e=>{const t={},o=o=>{let n=e[o?"startContainer":"endContainer"],r=e[o?"startOffset":"endOffset"];if(fe(n)){const e=Ot.create("span",{"data-mce-type":"bookmark"});n.hasChildNodes()?(r=Math.min(r,n.childNodes.length-1),o?n.insertBefore(e,n.childNodes[r]):Ot.insertAfter(e,n.childNodes[r])):n.appendChild(e),n=e,r=0}t[o?"startContainer":"endContainer"]=n,t[o?"startOffset":"endOffset"]=r};return o(!0),e.collapsed||o(),t},At=e=>{const t=t=>{let o=e[t?"startContainer":"endContainer"],n=e[t?"startOffset":"endOffset"];if(o){if(fe(o)&&o.parentNode){const e=o;n=(e=>{var t;let o=null===(t=e.parentNode)||void 0===t?void 0:t.firstChild,n=0;for(;o;){if(o===e)return n;fe(o)&&"bookmark"===o.getAttribute("data-mce-type")||n++,o=o.nextSibling}return-1})(o),o=o.parentNode,Ot.remove(e),!o.hasChildNodes()&&Ot.isBlock(o)&&o.appendChild(Ot.create("br"))}e[t?"startContainer":"endContainer"]=o,e[t?"startOffset":"endOffset"]=n}};t(!0),t();const o=Ot.createRng();return o.setStart(e.startContainer,e.startOffset),e.endContainer&&o.setEnd(e.endContainer,e.endOffset),ze(o)},Bt=e=>{switch(e){case"UL":return"ToggleUlList";case"OL":return"ToggleOlList";case"DL":return"ToggleDLList"}},Nt=(e,t)=>{he.each(t,((t,o)=>{e.setAttribute(o,t)}))},Rt=(e,t,o)=>{((e,t,o)=>{const n=o["list-style-type"]?o["list-style-type"]:null;e.setStyle(t,"list-style-type",n)})(e,t,o),((e,t,o)=>{Nt(t,o["list-attributes"]),he.each(e.select("li",t),(e=>{Nt(e,o["list-item-attributes"])}))})(e,t,o)},Vt=(e,t)=>a(t)&&!Se(t,e.schema.getBlockElements()),Dt=(e,t,o,n)=>{let r=t[o?"startContainer":"endContainer"];const i=t[o?"startOffset":"endOffset"];fe(r)&&(r=r.childNodes[Math.min(i,r.childNodes.length-1)]||r),!o&&Ce(r.nextSibling)&&(r=r.nextSibling);const s=(t,o)=>{var r;const i=new oe(t,(t=>{for(;!e.dom.isBlock(t)&&t.parentNode&&n!==t;)t=t.parentNode;return t})(t)),s=o?"next":"prev";let a;for(;a=i[s]();)if(!Te(e,a)&&!Tt(a.textContent)&&0!==(null===(r=a.textContent)||void 0===r?void 0:r.length))return p.some(a);return p.none()};if(o&&ge(r))if(Tt(r.textContent))r=s(r,!1).getOr(r);else for(null!==r.parentNode&&Vt(e,r.parentNode)&&(r=r.parentNode);null!==r.previousSibling&&(Vt(e,r.previousSibling)||ge(r.previousSibling));)r=r.previousSibling;if(!o&&ge(r))if(Tt(r.textContent))r=s(r,!0).getOr(r);else for(null!==r.parentNode&&Vt(e,r.parentNode)&&(r=r.parentNode);null!==r.nextSibling&&(Vt(e,r.nextSibling)||ge(r.nextSibling));)r=r.nextSibling;for(;r.parentNode!==n;){const t=r.parentNode;if(ke(e,r))return r;if(/^(TD|TH)$/.test(t.nodeName))return r;r=t}return r},Pt=(e,t,o)=>{const n=e.selection.getRng();let r="LI";const i=We(e,((e,t)=>{const o=e.selection.getStart(!0),n=Dt(e,t,!0,e.getBody());return r=I(n),i=I(t.commonAncestorContainer),s=r,a=function(e,...t){return(...o)=>{const n=t.concat(o);return e.apply(null,n)}}(F,i),G(s,a,void 0).isSome()?t.commonAncestorContainer:o;var r,i,s,a})(e,n)),s=e.dom;if("false"===s.getContentEditable(e.selection.getNode()))return;"DL"===(t=t.toUpperCase())&&(r="DT");const a=Mt(n),l=x(((e,t,o)=>{const n=[],r=e.dom,i=Dt(e,t,!0,o),s=Dt(e,t,!1,o);let a;const l=[];for(let e=i;e&&(l.push(e),e!==s);e=e.nextSibling);return he.each(l,(t=>{var i;if(ke(e,t))return n.push(t),void(a=null);if(r.isBlock(t)||Ce(t))return Ce(t)&&r.remove(t),void(a=null);const s=t.nextSibling;Et.isBookmarkNode(t)&&(ve(s)||ke(e,s)||!s&&t.parentNode===o)?a=null:(a||(a=r.create("p"),null===(i=t.parentNode)||void 0===i||i.insertBefore(a,t),n.push(a)),a.appendChild(t))})),n})(e,n,i),e.dom.isEditable);he.each(l,(n=>{let i;const a=n.previousSibling,l=n.parentNode;we(l)||(a&&ve(a)&&a.nodeName===t&&((e,t,o)=>{const n=e.getStyle(t,"list-style-type");let r=o?o["list-style-type"]:"";return r=null===r?"":r,n===r})(s,a,o)?(i=a,n=s.rename(n,r),a.appendChild(n)):(i=s.create(t),l.insertBefore(i,n),i.appendChild(n),n=s.rename(n,r)),((e,t,o)=>{he.each(["margin","margin-right","margin-bottom","margin-left","margin-top","padding","padding-right","padding-bottom","padding-left","padding-top"],(o=>e.setStyle(t,o,"")))})(s,n),Rt(s,i,o),Ft(e.dom,i))})),e.selection.setRng(At(a))},It=(e,t,o)=>{return((e,t)=>ve(e)&&e.nodeName===(null==t?void 0:t.nodeName))(t,o)&&((e,t,o)=>e.getStyle(t,"list-style-type",!0)===e.getStyle(o,"list-style-type",!0))(e,t,o)&&(n=o,t.className===n.className);var n},Ft=(e,t)=>{let o,n=t.nextSibling;if(It(e,t,n)){const r=n;for(;o=r.firstChild;)t.appendChild(o);e.remove(r)}if(n=t.previousSibling,It(e,t,n)){const r=n;for(;o=r.lastChild;)t.insertBefore(o,t.firstChild);e.remove(r)}},Lt=(e,t,o,n)=>{if(t.nodeName!==o){const r=e.dom.rename(t,o);Rt(e.dom,r,n),tt(e,Bt(o),r)}else Rt(e.dom,t,n),tt(e,Bt(o),t)},zt=(e,t,o,n)=>{if(t.classList.forEach(((e,o,n)=>{e.startsWith("tox-")&&(n.remove(e),0===n.length&&t.removeAttribute("class"))})),t.nodeName!==o){const r=e.dom.rename(t,o);Rt(e.dom,r,n),tt(e,Bt(o),r)}else Rt(e.dom,t,n),tt(e,Bt(o),t)},Ht=e=>"list-style-type"in e,Zt=(e,t,o)=>{const n=je(e);if(Je(e,n))return;const i=(e=>{const t=je(e),o=e.selection.getSelectedBlocks();return((e,t)=>a(e)&&1===t.length&&t[0]===e)(t,o)?(e=>x(e.querySelectorAll(Ze),ve))(t):x(o,(e=>ve(e)&&t!==e))})(e),s=r(o)?o:{};i.length>0?((e,t,o,n,r)=>{const i=ve(t);if(!i||t.nodeName!==n||Ht(r)||Ye(t)){Pt(e,n,r);const s=Mt(e.selection.getRng()),a=i?[t,...o]:o,l=i&&Ye(t)?zt:Lt;he.each(a,(t=>{l(e,t,n,r)})),e.selection.setRng(At(s))}else St(e)})(e,n,i,t,s):((e,t,o,n)=>{if(t!==e.getBody())if(t)if(t.nodeName!==o||Ht(n)||Ye(t)){const r=Mt(e.selection.getRng());Ye(t)&&t.classList.forEach(((e,o,n)=>{e.startsWith("tox-")&&(n.remove(e),0===n.length&&t.removeAttribute("class"))})),Rt(e.dom,t,n);const i=e.dom.rename(t,o);Ft(e.dom,i),e.selection.setRng(At(r)),Pt(e,o,n),tt(e,Bt(o),i)}else St(e);else Pt(e,o,n),tt(e,Bt(o),t)})(e,n,t,s)},jt=ue.DOM,Ut=(e,t)=>{const o=he.grep(e.select("ol,ul",t));he.each(o,(t=>{((e,t)=>{const o=t.parentElement;if(o&&"LI"===o.nodeName&&o.firstChild===t){const n=o.previousSibling;n&&"LI"===n.nodeName?(n.appendChild(t),Ee(e,o)&&jt.remove(o)):jt.setStyle(o,"listStyleType","none")}if(ve(o)){const e=o.previousSibling;e&&"LI"===e.nodeName&&e.appendChild(t)}})(e,t)}))},$t=(e,t,o,n)=>{let r=t.startContainer;const i=t.startOffset;if(ge(r)&&(o?i0))return r;const s=e.schema.getNonEmptyElements();fe(r)&&(r=te.getNode(r,i));const a=new oe(r,n);o&&((e,t)=>!!Ce(t)&&e.isBlock(t.nextSibling)&&!Ce(t.previousSibling))(e.dom,r)&&a.next();const l=o?a.next.bind(a):a.prev2.bind(a);for(;r=l();){if("LI"===r.nodeName&&!r.hasChildNodes())return r;if(s[r.nodeName])return r;if(ge(r)&&r.data.length>0)return r}return null},Wt=(e,t)=>{const o=t.childNodes;return 1===o.length&&!ve(o[0])&&e.isBlock(o[0])},qt=(e,t,o)=>{let n;const r=t.parentNode;if(!Oe(e,t)||!Oe(e,o))return;ve(o.lastChild)&&(n=o.lastChild),r===o.lastChild&&Ce(r.previousSibling)&&e.remove(r.previousSibling);const i=o.lastChild;i&&Ce(i)&&t.hasChildNodes()&&e.remove(i),Ee(e,o,!0)&&Q(I(o)),((e,t,o)=>{let n;const r=Wt(e,o)?o.firstChild:o;if(((e,t)=>{Wt(e,t)&&e.remove(t.firstChild,!0)})(e,t),!Ee(e,t,!0))for(;n=t.firstChild;)r.appendChild(n)})(e,t,o),n&&o.appendChild(n);const s=((e,t)=>{const o=e.dom,n=t.dom;return o!==n&&o.contains(n)})(I(o),I(t))?e.getParents(t,ve,o):[];e.remove(t),_(s,(t=>{Ee(e,t)&&t!==e.getRoot()&&e.remove(t)}))},Gt=(e,t)=>{const o=e.dom,n=e.selection,r=n.getStart(),i=$e(e,r),s=o.getParent(n.getStart(),"LI",i);if(s){const r=s.parentElement;if(r===e.getBody()&&Ee(o,r))return!0;const a=ze(n.getRng()),l=o.getParent($t(e,a,t,i),"LI",i);if(l&&l!==s)return e.undoManager.transact((()=>{var o,n;t?((e,t,o,n)=>{const r=e.dom;if(r.isEmpty(n))((e,t,o)=>{Q(I(o)),qt(e.dom,t,o),e.selection.setCursorLocation(o,0)})(e,o,n);else{const i=Mt(t);qt(r,o,n),e.selection.setRng(At(i))}})(e,a,l,s):(null===(n=(o=s).parentNode)||void 0===n?void 0:n.firstChild)===o?kt(e):((e,t,o,n)=>{const r=Mt(t);qt(e.dom,o,n);const i=At(r);e.selection.setRng(i)})(e,a,s,l)})),!0;if(!l&&!t&&0===a.startOffset&&0===a.endOffset)return e.undoManager.transact((()=>{St(e)})),!0}return!1},Yt=e=>{const t=e.selection.getStart(),o=$e(e,t);return e.dom.getParent(t,"LI,DT,DD",o)||Ue(e).length>0},Kt=(e,t)=>{const o=e.selection;return!Je(e,o.getNode())&&(o.isCollapsed()?((e,t)=>Gt(e,t)||((e,t)=>{const o=e.dom,n=e.selection.getStart(),r=$e(e,n),i=o.getParent(n,o.isBlock,r);if(i&&o.isEmpty(i)){const n=ze(e.selection.getRng()),s=o.getParent($t(e,n,t,r),"LI",r);if(s){const a=e=>b(["td","th","caption"],L(e)),l=e=>e.dom===r;return!!((e,t,o=u)=>R(e,t,o).getOr(e.isNone()&&t.isNone()))(Y(I(s),a,l),Y(I(n.startContainer),a,l),F)&&(e.undoManager.transact((()=>{const n=s.parentNode;((e,t,o)=>{const n=e.getParent(t.parentNode,e.isBlock,o);e.remove(t),n&&e.isEmpty(n)&&e.remove(n)})(o,i,r),Ft(o,n),e.selection.select(s,!0),e.selection.collapse(t)})),!0)}}return!1})(e,t))(e,t):(e=>!!Yt(e)&&(e.undoManager.transact((()=>{e.execCommand("Delete"),Ut(e.dom,e.getBody())})),!0))(e))},Xt=e=>{const t=E(ot(e).split("")),o=w(t,((e,t)=>{const o=e.toUpperCase().charCodeAt(0)-"A".charCodeAt(0)+1;return Math.pow(26,t)*o}));return C(o,((e,t)=>e+t),0)},Jt=e=>{if(--e<0)return"";{const t=e%26,o=Math.floor(e/26);return Jt(o)+String.fromCharCode("A".charCodeAt(0)+t)}},Qt=e=>{const t=parseInt(e.start,10);return N(e.listStyleType,"upper-alpha")?Jt(t):N(e.listStyleType,"lower-alpha")?Jt(t).toLowerCase():e.start},eo=(e,t)=>()=>{const o=je(e);return a(o)&&o.nodeName===t},to=e=>{e.addCommand("mceListProps",(()=>{(e=>{const t=je(e);ye(t)&&!Je(e,t)&&e.windowManager.open({title:"List Properties",body:{type:"panel",items:[{type:"input",name:"start",label:"Start list at number",inputMode:"numeric"}]},initialData:{start:Qt({start:e.dom.getAttrib(t,"start","1"),listStyleType:p.from(e.dom.getStyle(t,"list-style-type"))})},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],onSubmit:t=>{(e=>{switch((e=>/^[0-9]+$/.test(e)?2:/^[A-Z]+$/.test(e)?0:/^[a-z]+$/.test(e)?1:e.length>0?4:3)(e)){case 2:return p.some({listStyleType:p.none(),start:e});case 0:return p.some({listStyleType:p.some("upper-alpha"),start:Xt(e).toString()});case 1:return p.some({listStyleType:p.some("lower-alpha"),start:Xt(e).toString()});case 3:return p.some({listStyleType:p.none(),start:""});case 4:return p.none()}})(t.getData().start).each((t=>{e.execCommand("mceListUpdate",!1,{attrs:{start:"1"===t.start?"":t.start},styles:{"list-style-type":t.listStyleType.getOr("")}})})),t.close()}})})(e)}))};var oo=window.mailpoetTinymce.util.Tools.resolve("mailpoetTinymce.html.Node");const no=e=>3===e.type,ro=e=>0===e.length,io=e=>{const t=(t,o)=>{const n=oo.create("li");_(t,(e=>n.append(e))),o?e.insert(n,o,!0):e.append(n)},o=C(e.children(),((e,o)=>no(o)?[...e,o]:ro(e)||no(o)?e:(t(e,o),[])),[]);ro(o)||t(o)},so=(e,t)=>o=>(o.setEnabled(e.selection.isEditable()),Qe(e,(n=>{o.setActive(Ke(n.parents,t)),o.setEnabled(!Je(e,n.element)&&e.selection.isEditable())}))),ao=(e,t)=>o=>Qe(e,(n=>o.setEnabled(Ke(n.parents,t)&&!Je(e,n.element))));e.add("lists",(e=>((e=>{(0,e.options.register)("lists_indent_on_tab",{processor:"boolean",default:!0})})(e),(e=>{e.on("PreInit",(()=>{const{parser:t}=e;t.addNodeFilter("ul,ol",(e=>_(e,io)))}))})(e),e.hasPlugin("rtc",!0)?to(e):((e=>{Ae(e)&&(e=>{e.on("keydown",(t=>{t.keyCode!==ne.TAB||ne.metaKeyPressed(t)||e.undoManager.transact((()=>{(t.shiftKey?kt(e):Ct(e))&&t.preventDefault()}))}))})(e),(e=>{e.on("ExecCommand",(t=>{const o=t.command.toLowerCase();"delete"!==o&&"forwarddelete"!==o||!Yt(e)||Ut(e.dom,e.getBody())})),e.on("keydown",(t=>{t.keyCode===ne.BACKSPACE?Kt(e,!1)&&t.preventDefault():t.keyCode===ne.DELETE&&Kt(e,!0)&&t.preventDefault()}))})(e)})(e),(e=>{e.on("BeforeExecCommand",(t=>{const o=t.command.toLowerCase();"indent"===o?Ct(e):"outdent"===o&&kt(e)})),e.addCommand("InsertUnorderedList",((t,o)=>{Zt(e,"UL",o)})),e.addCommand("InsertOrderedList",((t,o)=>{Zt(e,"OL",o)})),e.addCommand("InsertDefinitionList",((t,o)=>{Zt(e,"DL",o)})),e.addCommand("RemoveList",(()=>{St(e)})),to(e),e.addCommand("mceListUpdate",((t,o)=>{r(o)&&((e,t)=>{const o=je(e);null===o||Je(e,o)||e.undoManager.transact((()=>{r(t.styles)&&e.dom.setStyles(o,t.styles),r(t.attrs)&&se(t.attrs,((t,n)=>e.dom.setAttrib(o,n,t)))}))})(e,o)})),e.addQueryStateHandler("InsertUnorderedList",eo(e,"UL")),e.addQueryStateHandler("InsertOrderedList",eo(e,"OL")),e.addQueryStateHandler("InsertDefinitionList",eo(e,"DL"))})(e)),(e=>{const t=t=>()=>e.execCommand(t);e.hasPlugin("advlist")||(e.ui.registry.addToggleButton("numlist",{icon:"ordered-list",active:!1,tooltip:"Numbered list",onAction:t("InsertOrderedList"),onSetup:so(e,"OL")}),e.ui.registry.addToggleButton("bullist",{icon:"unordered-list",active:!1,tooltip:"Bullet list",onAction:t("InsertUnorderedList"),onSetup:so(e,"UL")}))})(e),(e=>{const t={text:"List properties...",icon:"ordered-list",onAction:()=>e.execCommand("mceListProps"),onSetup:ao(e,"OL")};e.ui.registry.addMenuItem("listprops",t),e.ui.registry.addContextMenu("lists",{update:t=>{const o=je(e,t);return ye(o)?["listprops"]:[]}})})(e),(e=>({backspaceDelete:t=>{Kt(e,t)}}))(e))))}()},37236:function(e,t,o){o(10659)},10659:function(){!function(){"use strict";const e=Object.getPrototypeOf,t=(e,t,o)=>{var n;return!!o(e,t.prototype)||(null===(n=e.constructor)||void 0===n?void 0:n.name)===t.name},o=e=>o=>(e=>{const o=typeof e;return null===e?"null":"object"===o&&Array.isArray(e)?"array":"object"===o&&t(e,String,((e,t)=>t.isPrototypeOf(e)))?"string":o})(o)===e,n=e=>t=>typeof t===e,r=e=>t=>e===t,i=o("string"),s=o("object"),a=o=>((o,n)=>s(o)&&t(o,n,((t,o)=>e(t)===o)))(o,Object),l=o("array"),c=r(null),d=n("boolean"),u=r(void 0),h=e=>null==e,m=e=>!h(e),p=n("function"),g=n("number"),f=(e,t)=>{if(l(e)){for(let o=0,n=e.length;o{},b=e=>()=>e(),y=(e,t)=>(...o)=>e(t.apply(null,o)),w=e=>()=>e,_=e=>e,x=(e,t)=>e===t;function C(e,...t){return(...o)=>{const n=t.concat(o);return e.apply(null,n)}}const k=e=>t=>!e(t),S=e=>()=>{throw new Error(e)},T=e=>e(),E=w(!1),O=w(!0);class M{constructor(e,t){this.tag=e,this.value=t}static some(e){return new M(!0,e)}static none(){return M.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?M.some(e(this.value)):M.none()}bind(e){return this.tag?e(this.value):M.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:M.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return m(e)?M.some(e):M.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}M.singletonNone=new M(!1);const A=Array.prototype.slice,B=Array.prototype.indexOf,N=Array.prototype.push,R=(e,t)=>B.call(e,t),V=(e,t)=>{const o=R(e,t);return-1===o?M.none():M.some(o)},D=(e,t)=>R(e,t)>-1,P=(e,t)=>{for(let o=0,n=e.length;o{const o=[];for(let n=0;n{const o=[];for(let n=0;n{const o=e.length,n=new Array(o);for(let r=0;r{for(let o=0,n=e.length;o{const o=[],n=[];for(let r=0,i=e.length;r{const o=[];for(let n=0,r=e.length;n(((e,t)=>{for(let o=e.length-1;o>=0;o--)t(e[o],o)})(e,((e,n)=>{o=t(o,e,n)})),o),U=(e,t,o)=>(z(e,((e,n)=>{o=t(o,e,n)})),o),$=(e,t)=>((e,t,o)=>{for(let n=0,r=e.length;n{for(let o=0,n=e.length;o{const t=[];for(let o=0,n=e.length;oq(L(e,t)),Y=(e,t)=>{for(let o=0,n=e.length;o{const t=A.call(e,0);return t.reverse(),t},X=(e,t)=>Z(e,(e=>!D(t,e))),J=(e,t)=>{const o={};for(let n=0,r=e.length;n[e],ee=(e,t)=>{const o=A.call(e,0);return o.sort(t),o},te=(e,t)=>t>=0&&tte(e,0),ne=e=>te(e,e.length-1),re=p(Array.from)?Array.from:e=>A.call(e),ie=(e,t)=>{for(let o=0;o{const o=se(e);for(let n=0,r=o.length;nde(e,((e,o)=>({k:o,v:t(e,o)}))),de=(e,t)=>{const o={};return le(e,((e,n)=>{const r=t(e,n);o[r.k]=r.v})),o},ue=e=>(t,o)=>{e[o]=t},he=(e,t,o,n)=>{le(e,((e,r)=>{(t(e,r)?o:n)(e,r)}))},me=(e,t)=>{const o={};return he(e,t,ue(o),v),o},pe=(e,t)=>{const o=[];return le(e,((e,n)=>{o.push(t(e,n))})),o},ge=(e,t)=>{const o=se(e);for(let n=0,r=o.length;npe(e,_),ve=(e,t)=>be(e,t)?M.from(e[t]):M.none(),be=(e,t)=>ae.call(e,t),ye=(e,t)=>be(e,t)&&void 0!==e[t]&&null!==e[t],we=(e,t,o=x)=>e.exists((e=>o(e,t))),_e=e=>{const t=[],o=e=>{t.push(e)};for(let t=0;te.isSome()&&t.isSome()?M.some(o(e.getOrDie(),t.getOrDie())):M.none(),Ce=(e,t)=>null!=e?M.some(t(e)):M.none(),ke=(e,t)=>e?M.some(t):M.none(),Se=(e,t,o)=>""===t||e.length>=t.length&&e.substr(o,o+t.length)===t,Te=(e,t)=>Oe(e,t)?((e,t)=>e.substring(t))(e,t.length):e,Ee=(e,t,o=0,n)=>{const r=e.indexOf(t,o);return-1!==r&&(!!u(n)||r+t.length<=n)},Oe=(e,t)=>Se(e,t,0),Me=(e,t)=>Se(e,t,e.length-t.length),Ae=(Mo=/^\s+|\s+$/g,e=>e.replace(Mo,"")),Be=e=>e.length>0,Ne=e=>void 0!==e.style&&p(e.style.getPropertyValue),Re=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},Ve=(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return Re(o.childNodes[0])},De=(e,t)=>{const o=(t||document).createElement(e);return Re(o)},Pe=(e,t)=>{const o=(t||document).createTextNode(e);return Re(o)},Ie=Re,Fe="undefined"!=typeof window?window:Function("return this;")(),Le=(e,t)=>((e,t)=>{let o=null!=t?t:Fe;for(let t=0;t{const t=Le("ownerDocument.defaultView",e);return s(e)&&((e=>((e,t)=>{const o=((e,t)=>Le(e,t))(e,t);if(null==o)throw new Error(e+" not available on this browser");return o})("HTMLElement",e))(t).prototype.isPrototypeOf(e)||/^HTML\w*Element$/.test(ze(e).constructor.name))},Ze=e=>e.dom.nodeName.toLowerCase(),je=e=>t=>(e=>e.dom.nodeType)(t)===e,Ue=e=>$e(e)&&He(e.dom),$e=je(1),We=je(3),qe=je(9),Ge=je(11),Ye=e=>t=>$e(t)&&Ze(t)===e,Ke=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},Xe=e=>1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType||0===e.childElementCount,Je=(e,t)=>e.dom===t.dom,Qe=(e,t)=>{const o=e.dom,n=t.dom;return o!==n&&o.contains(n)},et=e=>Ie(e.dom.ownerDocument),tt=e=>qe(e)?e:et(e),ot=e=>Ie(tt(e).dom.documentElement),nt=e=>Ie(tt(e).dom.defaultView),rt=e=>M.from(e.dom.parentNode).map(Ie),it=e=>M.from(e.dom.parentElement).map(Ie),st=e=>M.from(e.dom.offsetParent).map(Ie),at=e=>L(e.dom.childNodes,Ie),lt=(e,t)=>{const o=e.dom.childNodes;return M.from(o[t]).map(Ie)},ct=e=>lt(e,0),dt=(e,t)=>({element:e,offset:t}),ut=(e,t)=>{const o=at(e);return o.length>0&&tGe(e)&&m(e.dom.host),mt=p(Element.prototype.attachShadow)&&p(Node.prototype.getRootNode),pt=w(mt),gt=mt?e=>Ie(e.dom.getRootNode()):tt,ft=e=>ht(e)?e:Ie(tt(e).dom.body),vt=e=>{const t=gt(e);return ht(t)?M.some(t):M.none()},bt=e=>Ie(e.dom.host),yt=e=>{const t=We(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return vt(Ie(t)).fold((()=>o.body.contains(t)),(n=yt,r=bt,e=>n(r(e))));var n,r},wt=()=>_t(Ie(document)),_t=e=>{const t=e.dom.body;if(null==t)throw new Error("Body is not available yet");return Ie(t)},xt=(e,t,o)=>{if(!(i(o)||d(o)||g(o)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",o,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,o+"")},Ct=(e,t,o)=>{xt(e.dom,t,o)},kt=(e,t)=>{const o=e.dom;le(t,((e,t)=>{xt(o,t,e)}))},St=(e,t)=>{const o=e.dom.getAttribute(t);return null===o?void 0:o},Tt=(e,t)=>M.from(St(e,t)),Et=(e,t)=>{const o=e.dom;return!(!o||!o.hasAttribute)&&o.hasAttribute(t)},Ot=(e,t)=>{e.dom.removeAttribute(t)},Mt=(e,t,o)=>{if(!i(o))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",o,":: Element ",e),new Error("CSS value must be a string: "+o);Ne(e)&&e.style.setProperty(t,o)},At=(e,t)=>{Ne(e)&&e.style.removeProperty(t)},Bt=(e,t,o)=>{const n=e.dom;Mt(n,t,o)},Nt=(e,t)=>{const o=e.dom;le(t,((e,t)=>{Mt(o,t,e)}))},Rt=(e,t)=>{const o=e.dom;le(t,((e,t)=>{e.fold((()=>{At(o,t)}),(e=>{Mt(o,t,e)}))}))},Vt=(e,t)=>{const o=e.dom,n=window.getComputedStyle(o).getPropertyValue(t);return""!==n||yt(e)?n:Dt(o,t)},Dt=(e,t)=>Ne(e)?e.style.getPropertyValue(t):"",Pt=(e,t)=>{const o=e.dom,n=Dt(o,t);return M.from(n).filter((e=>e.length>0))},It=e=>{const t={},o=e.dom;if(Ne(o))for(let e=0;e{const n=De(e);return Bt(n,t,o),Pt(n,t).isSome()},Lt=(e,t)=>{const o=e.dom;At(o,t),we(Tt(e,"style").map(Ae),"")&&Ot(e,"style")},zt=e=>e.dom.offsetWidth,Ht=(e,t)=>{const o=o=>{const n=t(o);if(n<=0||null===n){const t=Vt(o,e);return parseFloat(t)||0}return n},n=(e,t)=>U(t,((t,o)=>{const n=Vt(e,o),r=void 0===n?0:parseInt(n,10);return isNaN(r)?t:t+r}),0);return{set:(t,o)=>{if(!g(o)&&!o.match(/^[0-9]+$/))throw new Error(e+".set accepts only positive integer values. Value was "+o);const n=t.dom;Ne(n)&&(n.style[e]=o+"px")},get:o,getOuter:o,aggregate:n,max:(e,t,o)=>{const r=n(e,o);return t>r?t-r:0}}},Zt=Ht("height",(e=>{const t=e.dom;return yt(e)?t.getBoundingClientRect().height:t.offsetHeight})),jt=e=>Zt.get(e),Ut=e=>Zt.getOuter(e),$t=(e,t)=>({left:e,top:t,translate:(o,n)=>$t(e+o,t+n)}),Wt=$t,qt=(e,t)=>void 0!==e?e:void 0!==t?t:0,Gt=e=>{const t=e.dom.ownerDocument,o=t.body,n=t.defaultView,r=t.documentElement;if(o===e.dom)return Wt(o.offsetLeft,o.offsetTop);const i=qt(null==n?void 0:n.pageYOffset,r.scrollTop),s=qt(null==n?void 0:n.pageXOffset,r.scrollLeft),a=qt(r.clientTop,o.clientTop),l=qt(r.clientLeft,o.clientLeft);return Yt(e).translate(s-l,i-a)},Yt=e=>{const t=e.dom,o=t.ownerDocument.body;return o===t?Wt(o.offsetLeft,o.offsetTop):yt(e)?(e=>{const t=e.getBoundingClientRect();return Wt(t.left,t.top)})(t):Wt(0,0)},Kt=Ht("width",(e=>e.dom.offsetWidth)),Xt=e=>Kt.get(e),Jt=e=>Kt.getOuter(e),Qt=e=>{let t,o=!1;return(...n)=>(o||(o=!0,t=e.apply(null,n)),t)},eo=()=>to(0,0),to=(e,t)=>({major:e,minor:t}),oo={nu:to,detect:(e,t)=>{const o=String(t).toLowerCase();return 0===e.length?eo():((e,t)=>{const o=((e,t)=>{for(let o=0;oNumber(t.replace(o,"$"+e));return to(n(1),n(2))})(e,o)},unknown:eo},no=(e,t)=>{const o=String(t).toLowerCase();return $(e,(e=>e.search(o)))},ro=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,io=e=>t=>Ee(t,e),so=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:e=>Ee(e,"edge/")&&Ee(e,"chrome")&&Ee(e,"safari")&&Ee(e,"applewebkit")},{name:"Chromium",brand:"Chromium",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,ro],search:e=>Ee(e,"chrome")&&!Ee(e,"chromeframe")},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:e=>Ee(e,"msie")||Ee(e,"trident")},{name:"Opera",versionRegexes:[ro,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:io("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:io("firefox")},{name:"Safari",versionRegexes:[ro,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:e=>(Ee(e,"safari")||Ee(e,"mobile/"))&&Ee(e,"applewebkit")}],ao=[{name:"Windows",search:io("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:e=>Ee(e,"iphone")||Ee(e,"ipad"),versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:io("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"macOS",search:io("mac os x"),versionRegexes:[/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:io("linux"),versionRegexes:[]},{name:"Solaris",search:io("sunos"),versionRegexes:[]},{name:"FreeBSD",search:io("freebsd"),versionRegexes:[]},{name:"ChromeOS",search:io("cros"),versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/]}],lo={browsers:w(so),oses:w(ao)},co="Edge",uo="Chromium",ho="Opera",mo="Firefox",po="Safari",go=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isEdge:n(co),isChromium:n(uo),isIE:n("IE"),isOpera:n(ho),isFirefox:n(mo),isSafari:n(po)}},fo=()=>go({current:void 0,version:oo.unknown()}),vo=go,bo=(w(co),w(uo),w("IE"),w(ho),w(mo),w(po),"Windows"),yo="Android",wo="Linux",_o="macOS",xo="Solaris",Co="FreeBSD",ko="ChromeOS",So=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isWindows:n(bo),isiOS:n("iOS"),isAndroid:n(yo),isMacOS:n(_o),isLinux:n(wo),isSolaris:n(xo),isFreeBSD:n(Co),isChromeOS:n(ko)}},To=()=>So({current:void 0,version:oo.unknown()}),Eo=So,Oo=(w(bo),w("iOS"),w(yo),w(wo),w(_o),w(xo),w(Co),w(ko),e=>window.matchMedia(e).matches);var Mo;let Ao=Qt((()=>((e,t,o)=>{const n=lo.browsers(),r=lo.oses(),i=t.bind((e=>((e,t)=>ie(t.brands,(t=>{const o=t.brand.toLowerCase();return $(e,(e=>{var t;return o===(null===(t=e.brand)||void 0===t?void 0:t.toLowerCase())})).map((e=>({current:e.name,version:oo.nu(parseInt(t.version,10),0)})))})))(n,e))).orThunk((()=>((e,t)=>no(e,t).map((e=>{const o=oo.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(n,e))).fold(fo,vo),s=((e,t)=>no(e,t).map((e=>{const o=oo.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(r,e).fold(To,Eo),a=((e,t,o,n)=>{const r=e.isiOS()&&!0===/ipad/i.test(o),i=e.isiOS()&&!r,s=e.isiOS()||e.isAndroid(),a=s||n("(pointer:coarse)"),l=r||!i&&s&&n("(min-device-width:768px)"),c=i||s&&!l,d=t.isSafari()&&e.isiOS()&&!1===/safari/i.test(o),u=!c&&!l&&!d;return{isiPad:w(r),isiPhone:w(i),isTablet:w(l),isPhone:w(c),isTouch:w(a),isAndroid:e.isAndroid,isiOS:e.isiOS,isWebView:w(d),isDesktop:w(u)}})(s,i,e,o);return{browser:i,os:s,deviceType:a}})(navigator.userAgent,M.from(navigator.userAgentData),Oo)));const Bo=()=>Ao(),No=e=>{const t=Ie((e=>{if(pt()&&m(e.target)){const t=Ie(e.target);if($e(t)&&(e=>m(e.dom.shadowRoot))(t)&&e.composed&&e.composedPath){const t=e.composedPath();if(t)return oe(t)}}return M.from(e.target)})(e).getOr(e.target)),o=()=>e.stopPropagation(),n=()=>e.preventDefault(),r=y(n,o);return((e,t,o,n,r,i,s)=>({target:e,x:t,y:o,stop:n,prevent:r,kill:i,raw:s}))(t,e.clientX,e.clientY,o,n,r,e)},Ro=(e,t,o,n,r)=>{const i=((e,t)=>o=>{e(o)&&t(No(o))})(o,n);return e.dom.addEventListener(t,i,r),{unbind:C(Vo,e,t,i,r)}},Vo=(e,t,o,n)=>{e.dom.removeEventListener(t,o,n)},Do=(e,t)=>{rt(e).each((o=>{o.dom.insertBefore(t.dom,e.dom)}))},Po=(e,t)=>{const o=(e=>M.from(e.dom.nextSibling).map(Ie))(e);o.fold((()=>{rt(e).each((e=>{Fo(e,t)}))}),(e=>{Do(e,t)}))},Io=(e,t)=>{ct(e).fold((()=>{Fo(e,t)}),(o=>{e.dom.insertBefore(t.dom,o.dom)}))},Fo=(e,t)=>{e.dom.appendChild(t.dom)},Lo=(e,t)=>{z(t,(t=>{Fo(e,t)}))},zo=e=>{e.dom.textContent="",z(at(e),(e=>{Ho(e)}))},Ho=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},Zo=e=>{const t=void 0!==e?e.dom:document,o=t.body.scrollLeft||t.documentElement.scrollLeft,n=t.body.scrollTop||t.documentElement.scrollTop;return Wt(o,n)},jo=(e,t,o)=>{const n=(void 0!==o?o.dom:document).defaultView;n&&n.scrollTo(e,t)},Uo=(e,t,o,n)=>({x:e,y:t,width:o,height:n,right:e+o,bottom:t+n}),$o=e=>{const t=void 0===e?window:e,o=t.document,n=Zo(Ie(o));return(e=>{const t=void 0===e?window:e;return Bo().browser.isFirefox()?M.none():M.from(t.visualViewport)})(t).fold((()=>{const e=t.document.documentElement,o=e.clientWidth,r=e.clientHeight;return Uo(n.left,n.top,o,r)}),(e=>Uo(Math.max(e.pageLeft,n.left),Math.max(e.pageTop,n.top),e.width,e.height)))},Wo=()=>Ie(document),qo=(e,t)=>e.view(t).fold(w([]),(t=>{const o=e.owner(t),n=qo(e,o);return[t].concat(n)}));var Go=Object.freeze({__proto__:null,view:e=>{var t;return(e.dom===document?M.none():M.from(null===(t=e.dom.defaultView)||void 0===t?void 0:t.frameElement)).map(Ie)},owner:e=>et(e)});const Yo=e=>{const t=Wo(),o=Zo(t),n=((e,t)=>{const o=t.owner(e),n=qo(t,o);return M.some(n)})(e,Go);return n.fold(C(Gt,e),(t=>{const n=Yt(e),r=j(t,((e,t)=>{const o=Yt(t);return{left:e.left+o.left,top:e.top+o.top}}),{left:0,top:0});return Wt(r.left+n.left+o.left,r.top+n.top+o.top)}))},Ko=(e,t,o,n)=>({x:e,y:t,width:o,height:n,right:e+o,bottom:t+n}),Xo=e=>{const t=Gt(e),o=Jt(e),n=Ut(e);return Ko(t.left,t.top,o,n)},Jo=e=>{const t=Yo(e),o=Jt(e),n=Ut(e);return Ko(t.left,t.top,o,n)},Qo=(e,t)=>{const o=Math.max(e.x,t.x),n=Math.max(e.y,t.y),r=Math.min(e.right,t.right),i=Math.min(e.bottom,t.bottom);return Ko(o,n,r-o,i-n)},en=()=>$o(window);var tn=window.mailpoetTinymce.util.Tools.resolve("mailpoetTinymce.ThemeManager");const on=e=>{const t=t=>t(e),o=w(e),n=()=>r,r={tag:!0,inner:e,fold:(t,o)=>o(e),isValue:O,isError:E,map:t=>rn.value(t(e)),mapError:n,bind:t,exists:t,forall:t,getOr:o,or:n,getOrThunk:o,orThunk:n,getOrDie:o,each:t=>{t(e)},toOptional:()=>M.some(e)};return r},nn=e=>{const t=()=>o,o={tag:!1,inner:e,fold:(t,o)=>t(e),isValue:E,isError:O,map:t,mapError:t=>rn.error(t(e)),bind:t,exists:E,forall:O,getOr:_,or:_,getOrThunk:T,orThunk:T,getOrDie:S(String(e)),each:v,toOptional:M.none};return o},rn={value:on,error:nn,fromOption:(e,t)=>e.fold((()=>nn(t)),on)};var sn;!function(e){e[e.Error=0]="Error",e[e.Value=1]="Value"}(sn||(sn={}));const an=(e,t,o)=>e.stype===sn.Error?t(e.serror):o(e.svalue),ln=e=>({stype:sn.Value,svalue:e}),cn=e=>({stype:sn.Error,serror:e}),dn=ln,un=cn,hn=an,mn=(e,t,o,n)=>({tag:"field",key:e,newKey:t,presence:o,prop:n}),pn=(e,t,o)=>{switch(e.tag){case"field":return t(e.key,e.newKey,e.presence,e.prop);case"custom":return o(e.newKey,e.instantiator)}},gn=e=>(...t)=>{if(0===t.length)throw new Error("Can't merge zero objects");const o={};for(let n=0;na(e)&&a(t)?fn(e,t):t)),vn=gn(((e,t)=>t)),bn=e=>({tag:"defaultedThunk",process:e}),yn=e=>bn(w(e)),wn=e=>({tag:"mergeWithThunk",process:e}),_n=e=>{const t=(e=>{const t=[],o=[];return z(e,(e=>{an(e,(e=>o.push(e)),(e=>t.push(e)))})),{values:t,errors:o}})(e);return t.errors.length>0?(o=t.errors,y(un,q)(o)):dn(t.values);var o},xn=e=>s(e)&&se(e).length>100?" removed due to size":JSON.stringify(e,null,2),Cn=(e,t)=>un([{path:e,getErrorInfo:t}]),kn=e=>({extract:(t,o)=>((e,t)=>e.stype===sn.Error?t(e.serror):e)(e(o),(e=>((e,t)=>Cn(e,w(t)))(t,e))),toString:w("val")}),Sn=kn(dn),Tn=(e,t,o,n)=>n(ve(e,t).getOrThunk((()=>o(e)))),En=(e,t,o,n,r)=>{const i=e=>r.extract(t.concat([n]),e),s=e=>e.fold((()=>dn(M.none())),(e=>((e,t)=>e.stype===sn.Value?{stype:sn.Value,svalue:t(e.svalue)}:e)(r.extract(t.concat([n]),e),M.some)));switch(e.tag){case"required":return((e,t,o,n)=>ve(t,o).fold((()=>((e,t,o)=>Cn(e,(()=>'Could not find valid *required* value for "'+t+'" in '+xn(o))))(e,o,t)),n))(t,o,n,i);case"defaultedThunk":return Tn(o,n,e.process,i);case"option":return((e,t,o)=>o(ve(e,t)))(o,n,s);case"defaultedOptionThunk":return((e,t,o,n)=>n(ve(e,t).map((t=>!0===t?o(e):t))))(o,n,e.process,s);case"mergeWithThunk":return Tn(o,n,w({}),(t=>{const n=fn(e.process(o),t);return i(n)}))}},On=e=>({extract:(t,o)=>e().extract(t,o),toString:()=>e().toString()}),Mn=e=>se(me(e,m)),An=e=>{const t=Bn(e),o=j(e,((e,t)=>pn(t,(t=>fn(e,{[t]:!0})),w(e))),{});return{extract:(e,n)=>{const r=d(n)?[]:Mn(n),i=Z(r,(e=>!ye(o,e)));return 0===i.length?t.extract(e,n):((e,t)=>Cn(e,(()=>"There are unsupported fields: ["+t.join(", ")+"] specified")))(e,i)},toString:t.toString}},Bn=e=>({extract:(t,o)=>((e,t,o)=>{const n={},r=[];for(const i of o)pn(i,((o,i,s,a)=>{const l=En(s,e,t,o,a);hn(l,(e=>{r.push(...e)}),(e=>{n[i]=e}))}),((e,o)=>{n[e]=o(t)}));return r.length>0?un(r):dn(n)})(t,o,e),toString:()=>{const t=L(e,(e=>pn(e,((e,t,o,n)=>e+" -> "+n.toString()),((e,t)=>"state("+e+")"))));return"obj{\n"+t.join("\n")+"}"}}),Nn=e=>({extract:(t,o)=>{const n=L(o,((o,n)=>e.extract(t.concat(["["+n+"]"]),o)));return _n(n)},toString:()=>"array("+e.toString()+")"}),Rn=(e,t)=>{const o=void 0!==t?t:_;return{extract:(t,n)=>{const r=[];for(const i of e){const e=i.extract(t,n);if(e.stype===sn.Value)return{stype:sn.Value,svalue:o(e.svalue)};r.push(e)}return _n(r)},toString:()=>"oneOf("+L(e,(e=>e.toString())).join(", ")+")"}},Vn=(e,t)=>({extract:(o,n)=>{const r=se(n),i=((t,o)=>Nn(kn(e)).extract(t,o))(o,r);return((e,t)=>e.stype===sn.Value?t(e.svalue):e)(i,(e=>{const r=L(e,(e=>mn(e,e,{tag:"required",process:{}},t)));return Bn(r).extract(o,n)}))},toString:()=>"setOf("+t.toString()+")"}),Dn=y(Nn,Bn),Pn=w(Sn),In=(e,t)=>kn((o=>{const n=typeof o;return e(o)?dn(o):un(`Expected type: ${t} but got: ${n}`)})),Fn=In(g,"number"),Ln=In(i,"string"),zn=In(d,"boolean"),Hn=In(p,"function"),Zn=e=>{if(Object(e)!==e)return!0;switch({}.toString.call(e).slice(8,-1)){case"Boolean":case"Number":case"String":case"Date":case"RegExp":case"Blob":case"FileList":case"ImageData":case"ImageBitmap":case"ArrayBuffer":return!0;case"Array":case"Object":return Object.keys(e).every((t=>Zn(e[t])));default:return!1}},jn=kn((e=>Zn(e)?dn(e):un("Expected value to be acceptable for sending via postMessage"))),Un=(e,t)=>({extract:(o,n)=>ve(n,e).fold((()=>((e,t)=>Cn(e,(()=>'Choice schema did not contain choice key: "'+t+'"')))(o,e)),(e=>((e,t,o,n)=>ve(o,n).fold((()=>((e,t,o)=>Cn(e,(()=>'The chosen schema: "'+o+'" did not exist in branches: '+xn(t))))(e,o,n)),(o=>o.extract(e.concat(["branch: "+n]),t))))(o,n,t,e))),toString:()=>"chooseOn("+e+"). Possible values: "+se(t)}),$n=e=>kn((t=>e(t).fold(un,dn))),Wn=(e,t)=>Vn((t=>e(t).fold(cn,ln)),t),qn=(e,t,o)=>{return n=((e,t,o)=>((e,t)=>e.stype===sn.Error?{stype:sn.Error,serror:t(e.serror)}:e)(t.extract([e],o),(e=>({input:o,errors:e}))))(e,t,o),an(n,rn.error,rn.value);var n},Gn=e=>e.fold((e=>{throw new Error(Kn(e))}),_),Yn=(e,t,o)=>Gn(qn(e,t,o)),Kn=e=>"Errors: \n"+(e=>{const t=e.length>10?e.slice(0,10).concat([{path:[],getErrorInfo:w("... (only showing first ten failures)")}]):e;return L(t,(e=>"Failed path: ("+e.path.join(" > ")+")\n"+e.getErrorInfo()))})(e.errors).join("\n")+"\n\nInput object: "+xn(e.input),Xn=(e,t)=>Un(e,ce(t,Bn)),Jn=(e,t)=>((e,t)=>{const o=Qt(t);return{extract:(e,t)=>o().extract(e,t),toString:()=>o().toString()}})(0,t),Qn=mn,er=(e,t)=>({tag:"custom",newKey:e,instantiator:t}),tr=e=>$n((t=>D(e,t)?rn.value(t):rn.error(`Unsupported value: "${t}", choose one of "${e.join(", ")}".`))),or=e=>Qn(e,e,{tag:"required",process:{}},Pn()),nr=(e,t)=>Qn(e,e,{tag:"required",process:{}},t),rr=e=>nr(e,Fn),ir=e=>nr(e,Ln),sr=(e,t)=>Qn(e,e,{tag:"required",process:{}},tr(t)),ar=e=>nr(e,Hn),lr=(e,t)=>Qn(e,e,{tag:"required",process:{}},Bn(t)),cr=(e,t)=>Qn(e,e,{tag:"required",process:{}},Dn(t)),dr=(e,t)=>Qn(e,e,{tag:"required",process:{}},Nn(t)),ur=e=>Qn(e,e,{tag:"option",process:{}},Pn()),hr=(e,t)=>Qn(e,e,{tag:"option",process:{}},t),mr=e=>hr(e,Fn),pr=e=>hr(e,Ln),gr=(e,t)=>hr(e,tr(t)),fr=e=>hr(e,Hn),vr=(e,t)=>hr(e,Nn(t)),br=(e,t)=>hr(e,Bn(t)),yr=(e,t)=>Qn(e,e,yn(t),Pn()),wr=(e,t,o)=>Qn(e,e,yn(t),o),_r=(e,t)=>wr(e,t,Fn),xr=(e,t)=>wr(e,t,Ln),Cr=(e,t,o)=>wr(e,t,tr(o)),kr=(e,t)=>wr(e,t,zn),Sr=(e,t)=>wr(e,t,Hn),Tr=(e,t,o)=>wr(e,t,Nn(o)),Er=(e,t,o)=>wr(e,t,Bn(o)),Or=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},Mr=e=>{if(!l(e))throw new Error("cases must be an array");if(0===e.length)throw new Error("there must be at least one case");const t=[],o={};return z(e,((n,r)=>{const i=se(n);if(1!==i.length)throw new Error("one and only one name per case");const s=i[0],a=n[s];if(void 0!==o[s])throw new Error("duplicate key detected:"+s);if("cata"===s)throw new Error("cannot have a case named cata (sorry)");if(!l(a))throw new Error("case arguments must be an array");t.push(s),o[s]=(...o)=>{const n=o.length;if(n!==a.length)throw new Error("Wrong number of arguments to case "+s+". Expected "+a.length+" ("+a+"), got "+n);return{fold:(...t)=>{if(t.length!==e.length)throw new Error("Wrong number of arguments to fold. Expected "+e.length+", got "+t.length);return t[r].apply(null,o)},match:e=>{const n=se(e);if(t.length!==n.length)throw new Error("Wrong number of arguments to match. Expected: "+t.join(",")+"\nActual: "+n.join(","));if(!Y(t,(e=>D(n,e))))throw new Error("Not all branches were specified when using match. Specified: "+n.join(", ")+"\nRequired: "+t.join(", "));return e[s].apply(null,o)},log:e=>{console.log(e,{constructors:t,constructor:s,params:o})}}}})),o};Mr([{bothErrors:["error1","error2"]},{firstError:["error1","value2"]},{secondError:["value1","error2"]},{bothValues:["value1","value2"]}]);const Ar=(e,t)=>((e,t)=>({[e]:t}))(e,t),Br=e=>(e=>{const t={};return z(e,(e=>{t[e.key]=e.value})),t})(e),Nr=e=>p(e)?e:E,Rr=(e,t,o)=>{let n=e.dom;const r=Nr(o);for(;n.parentNode;){n=n.parentNode;const e=Ie(n),o=t(e);if(o.isSome())return o;if(r(e))break}return M.none()},Vr=(e,t,o)=>{const n=t(e),r=Nr(o);return n.orThunk((()=>r(e)?M.none():Rr(e,t,r)))},Dr=(e,t)=>Je(e.element,t.event.target),Pr={can:O,abort:E,run:v},Ir=e=>{if(!ye(e,"can")&&!ye(e,"abort")&&!ye(e,"run"))throw new Error("EventHandler defined by: "+JSON.stringify(e,null,2)+" does not have can, abort, or run!");return{...Pr,...e}},Fr=w,Lr=Fr("touchstart"),zr=Fr("touchmove"),Hr=Fr("touchend"),Zr=Fr("touchcancel"),jr=Fr("mousedown"),Ur=Fr("mousemove"),$r=Fr("mouseout"),Wr=Fr("mouseup"),qr=Fr("mouseover"),Gr=Fr("focusin"),Yr=Fr("focusout"),Kr=Fr("keydown"),Xr=Fr("keyup"),Jr=Fr("input"),Qr=Fr("change"),ei=Fr("click"),ti=Fr("transitioncancel"),oi=Fr("transitionend"),ni=Fr("transitionstart"),ri=Fr("selectstart"),ii=e=>w("alloy."+e),si={tap:ii("tap")},ai=ii("focus"),li=ii("blur.post"),ci=ii("paste.post"),di=ii("receive"),ui=ii("execute"),hi=ii("focus.item"),mi=si.tap,pi=ii("longpress"),gi=ii("sandbox.close"),fi=ii("typeahead.cancel"),vi=ii("system.init"),bi=ii("system.touchmove"),yi=ii("system.touchend"),wi=ii("system.scroll"),_i=ii("system.resize"),xi=ii("system.attached"),Ci=ii("system.detached"),ki=ii("system.dismissRequested"),Si=ii("system.repositionRequested"),Ti=ii("focusmanager.shifted"),Ei=ii("slotcontainer.visibility"),Oi=ii("system.external.element.scroll"),Mi=ii("change.tab"),Ai=ii("dismiss.tab"),Bi=ii("highlight"),Ni=ii("dehighlight"),Ri=(e,t)=>{Ii(e,e.element,t,{})},Vi=(e,t,o)=>{Ii(e,e.element,t,o)},Di=e=>{Ri(e,ui())},Pi=(e,t,o)=>{Ii(e,t,o,{})},Ii=(e,t,o,n)=>{const r={target:t,...n};e.getSystem().triggerEvent(o,t,r)},Fi=(e,t,o,n)=>{e.getSystem().triggerEvent(o,t,n.event)},Li=e=>Br(e),zi=(e,t)=>({key:e,value:Ir({abort:t})}),Hi=e=>({key:e,value:Ir({run:(e,t)=>{t.event.prevent()}})}),Zi=(e,t)=>({key:e,value:Ir({run:t})}),ji=(e,t,o)=>({key:e,value:Ir({run:(e,n)=>{t.apply(void 0,[e,n].concat(o))}})}),Ui=e=>t=>({key:e,value:Ir({run:(e,o)=>{Dr(e,o)&&t(e,o)}})}),$i=(e,t,o)=>((e,t)=>Zi(e,((o,n)=>{o.getSystem().getByUid(t).each((t=>{Fi(t,t.element,e,n)}))})))(e,t.partUids[o]),Wi=(e,t)=>Zi(e,((e,o)=>{const n=o.event,r=e.getSystem().getByDom(n.target).getOrThunk((()=>Vr(n.target,(t=>e.getSystem().getByDom(t).toOptional()),E).getOr(e)));t(e,r,o)})),qi=e=>Zi(e,((e,t)=>{t.cut()})),Gi=e=>Zi(e,((e,t)=>{t.stop()})),Yi=(e,t)=>Ui(e)(t),Ki=Ui(xi()),Xi=Ui(Ci()),Ji=Ui(vi()),Qi=(is=ui(),e=>Zi(is,e)),es=e=>e.dom.innerHTML,ts=(e,t)=>{const o=et(e).dom,n=Ie(o.createDocumentFragment()),r=((e,t)=>{const o=(t||document).createElement("div");return o.innerHTML=e,at(Ie(o))})(t,o);Lo(n,r),zo(e),Fo(e,n)},os=e=>ht(e)?"#shadow-root":(e=>{const t=De("div"),o=Ie(e.dom.cloneNode(!0));return Fo(t,o),es(t)})((e=>((e,t)=>Ie(e.dom.cloneNode(!1)))(e))(e)),ns=e=>os(e),rs=Li([((e,t)=>({key:e,value:Ir({can:(e,t)=>{const o=t.event,n=o.originator,r=o.target;return!((e,t,o)=>Je(t,e.element)&&!Je(t,o))(e,n,r)||(console.warn(ai()+" did not get interpreted by the desired target. \nOriginator: "+ns(n)+"\nTarget: "+ns(r)+"\nCheck the "+ai()+" event handlers"),!1)}})}))(ai())]);var is,ss=Object.freeze({__proto__:null,events:rs});let as=0;const ls=e=>{const t=(new Date).getTime(),o=Math.floor(1e9*Math.random());return as++,e+"_"+o+as+String(t)},cs=w("alloy-id-"),ds=w("data-alloy-id"),us=cs(),hs=ds(),ms=(e,t)=>{Object.defineProperty(e.dom,hs,{value:t,writable:!0})},ps=e=>{const t=$e(e)?e.dom[hs]:null;return M.from(t)},gs=e=>ls(e),fs=_,vs=e=>{const t=t=>`The component must be in a context to execute: ${t}`+(e?"\n"+ns(e().element)+" is not in context.":""),o=e=>()=>{throw new Error(t(e))},n=e=>()=>{console.warn(t(e))};return{debugInfo:w("fake"),triggerEvent:n("triggerEvent"),triggerFocus:n("triggerFocus"),triggerEscape:n("triggerEscape"),broadcast:n("broadcast"),broadcastOn:n("broadcastOn"),broadcastEvent:n("broadcastEvent"),build:o("build"),buildOrPatch:o("buildOrPatch"),addToWorld:o("addToWorld"),removeFromWorld:o("removeFromWorld"),addToGui:o("addToGui"),removeFromGui:o("removeFromGui"),getByUid:o("getByUid"),getByDom:o("getByDom"),isConnected:E}},bs=vs(),ys=e=>L(e,(e=>Me(e,"/*")?e.substring(0,e.length-2):e)),ws=(e,t)=>{const o=e.toString(),n=o.indexOf(")")+1,r=o.indexOf("("),i=o.substring(r+1,n-1).split(/,\s*/);return e.toFunctionAnnotation=()=>({name:t,parameters:ys(i)}),e},_s=ls("alloy-premade"),xs=e=>(Object.defineProperty(e.element.dom,_s,{value:e.uid,writable:!0}),Ar(_s,e)),Cs=e=>ve(e,_s),ks=e=>((e,t)=>{const o=t.toString(),n=o.indexOf(")")+1,r=o.indexOf("("),i=o.substring(r+1,n-1).split(/,\s*/);return e.toFunctionAnnotation=()=>({name:"OVERRIDE",parameters:ys(i.slice(1))}),e})(((t,...o)=>e(t.getApis(),t,...o)),e),Ss={init:()=>Ts({readState:w("No State required")})},Ts=e=>e,Es=(e,t)=>{const o={};return le(e,((e,n)=>{le(e,((e,r)=>{const i=ve(o,r).getOr([]);o[r]=i.concat([t(n,e)])}))})),o},Os=e=>({classes:u(e.classes)?[]:e.classes,attributes:u(e.attributes)?{}:e.attributes,styles:u(e.styles)?{}:e.styles}),Ms=e=>e.cHandler,As=(e,t)=>({name:e,handler:t}),Bs=(e,t)=>{const o={};return z(e,(e=>{o[e.name()]=e.handlers(t)})),o},Ns=(e,t,o)=>{const n=t[o];return n?((e,t,o,n)=>{try{const r=ee(o,((o,r)=>{const i=o[t],s=r[t],a=n.indexOf(i),l=n.indexOf(s);if(-1===a)throw new Error("The ordering for "+e+" does not have an entry for "+i+".\nOrder specified: "+JSON.stringify(n,null,2));if(-1===l)throw new Error("The ordering for "+e+" does not have an entry for "+s+".\nOrder specified: "+JSON.stringify(n,null,2));return a(e=>{const t=((e,t)=>(...t)=>U(e,((e,o)=>e&&(e=>e.can)(o).apply(void 0,t)),!0))(e),o=((e,t)=>(...t)=>U(e,((e,o)=>e||(e=>e.abort)(o).apply(void 0,t)),!1))(e);return{can:t,abort:o,run:(...t)=>{z(e,(e=>{e.run.apply(void 0,t)}))}}})(L(e,(e=>e.handler))))):((e,t)=>rn.error(["The event ("+e+') has more than one behaviour that listens to it.\nWhen this occurs, you must specify an event ordering for the behaviours in your spec (e.g. [ "listing", "toggling" ]).\nThe behaviours that can trigger it are: '+JSON.stringify(L(t,(e=>e.name)),null,2)]))(o,e)},Rs=(e,t)=>((e,t)=>{const o=(e=>{const t=[],o=[];return z(e,(e=>{e.fold((e=>{t.push(e)}),(e=>{o.push(e)}))})),{errors:t,values:o}})(e);return o.errors.length>0?(n=o.errors,rn.error(q(n))):((e,t)=>0===e.length?rn.value(t):rn.value(fn(t,vn.apply(void 0,e))))(o.values,t);var n})(pe(e,((e,o)=>(1===e.length?rn.value(e[0].handler):Ns(e,t,o)).map((n=>{const r=(e=>{const t=(e=>p(e)?{can:O,abort:E,run:e}:e)(e);return(e,o,...n)=>{const r=[e,o].concat(n);t.abort.apply(void 0,r)?o.stop():t.can.apply(void 0,r)&&t.run.apply(void 0,r)}})(n),i=e.length>1?Z(t[o],(t=>P(e,(e=>e.name===t)))).join(" > "):e[0].name;return Ar(o,((e,t)=>({handler:e,purpose:t}))(r,i))})))),{}),Vs="alloy.base.behaviour",Ds=Bn([Qn("dom","dom",{tag:"required",process:{}},Bn([or("tag"),yr("styles",{}),yr("classes",[]),yr("attributes",{}),ur("value"),ur("innerHtml")])),or("components"),or("uid"),yr("events",{}),yr("apis",{}),Qn("eventOrder","eventOrder",(aa={[ui()]:["disabling",Vs,"toggling","typeaheadevents"],[ai()]:[Vs,"focusing","keying"],[vi()]:[Vs,"disabling","toggling","representing"],[Jr()]:[Vs,"representing","streaming","invalidating"],[Ci()]:[Vs,"representing","item-events","tooltipping"],[jr()]:["focusing",Vs,"item-type-events"],[Lr()]:["focusing",Vs,"item-type-events"],[qr()]:["item-type-events","tooltipping"],[di()]:["receiving","reflecting","tooltipping"]},wn(w(aa))),Pn()),ur("domModification")]),Ps=e=>e.events,Is=(e,t)=>{const o=St(e,t);return void 0===o||""===o?[]:o.split(" ")},Fs=e=>void 0!==e.dom.classList,Ls=e=>Is(e,"class"),zs=(e,t)=>{Fs(e)?e.dom.classList.add(t):((e,t)=>{((e,t,o)=>{const n=Is(e,t).concat([o]);Ct(e,t,n.join(" "))})(e,"class",t)})(e,t)},Hs=(e,t)=>{Fs(e)?e.dom.classList.remove(t):((e,t)=>{((e,t,o)=>{const n=Z(Is(e,t),(e=>e!==o));n.length>0?Ct(e,t,n.join(" ")):Ot(e,t)})(e,"class",t)})(e,t),(e=>{0===(Fs(e)?e.dom.classList:Ls(e)).length&&Ot(e,"class")})(e)},Zs=(e,t)=>Fs(e)&&e.dom.classList.contains(t),js=(e,t)=>{z(t,(t=>{zs(e,t)}))},Us=(e,t)=>{z(t,(t=>{Hs(e,t)}))},$s=(e,t)=>Y(t,(t=>Zs(e,t))),Ws=e=>e.dom.value,qs=(e,t)=>{if(void 0===t)throw new Error("Value.set was undefined");e.dom.value=t},Gs=(e,t,o)=>{o.fold((()=>Fo(e,t)),(e=>{Je(e,t)||(Do(e,t),Ho(e))}))},Ys=(e,t,o)=>{const n=L(t,o),r=at(e);return z(r.slice(n.length),Ho),n},Ks=(e,t,o,n)=>{const r=lt(e,t),i=n(o,r),s=((e,t,o)=>lt(e,t).map((e=>{if(o.exists((t=>!Je(t,e)))){const t=o.map(Ze).getOr("span"),n=De(t);return Do(e,n),n}return e})))(e,t,r);return Gs(e,i.element,s),i},Xs=(e,t)=>{const o=se(e),n=se(t),r=X(n,o),i=((e,o)=>{const n={},r={};return he(e,((e,o)=>!be(t,o)||e!==t[o]),ue(n),ue(r)),{t:n,f:r}})(e).t;return{toRemove:r,toSet:i}},Js=(e,t)=>{const{class:o,style:n,...r}=(e=>U(e.dom.attributes,((e,t)=>(e[t.name]=t.value,e)),{}))(t),{toSet:i,toRemove:s}=Xs(e.attributes,r),a=It(t),{toSet:l,toRemove:c}=Xs(e.styles,a),d=(e=>Fs(e)?(e=>{const t=e.dom.classList,o=new Array(t.length);for(let e=0;eOt(t,e))),kt(t,i),js(t,h),Us(t,u),z(c,(e=>Lt(t,e))),Nt(t,l),e.innerHtml.fold((()=>{const o=e.domChildren;((e,t)=>{Ys(e,t,((t,o)=>{const n=lt(e,o);return Gs(e,t,n),t}))})(t,o)}),(e=>{ts(t,e)})),(()=>{const o=t,n=e.value.getOrUndefined();n!==Ws(o)&&qs(o,null!=n?n:"")})(),t},Qs=e=>{const t=(e=>{const t=ve(e,"behaviours").getOr({});return G(se(t),(e=>{const o=t[e];return m(o)?[o.me]:[]}))})(e);return((e,t)=>((e,t)=>{const o=L(t,(e=>br(e.name(),[or("config"),yr("state",Ss)]))),n=qn("component.behaviours",Bn(o),e.behaviours).fold((t=>{throw new Error(Kn(t)+"\nComplete spec:\n"+JSON.stringify(e,null,2))}),_);return{list:t,data:ce(n,(e=>{const t=e.map((e=>({config:e.config,state:e.state.init(e.config)})));return w(t)}))}})(e,t))(e,t)},ea=(e,t)=>{const o=()=>h,n=Or(bs),r=Gn((e=>qn("custom.definition",Ds,e))(e)),i=Qs(e),s=(e=>e.list)(i),a=(e=>e.data)(i),l=((e,t,o)=>{const n={...(r=e).dom,uid:r.uid,domChildren:L(r.components,(e=>e.element))};var r;const i=(e=>e.domModification.fold((()=>Os({})),Os))(e),s={"alloy.base.modification":i},a=t.length>0?((e,t,o,n)=>{const r={...t};z(o,(t=>{r[t.name()]=t.exhibit(e,n)}));const i=Es(r,((e,t)=>({name:e,modification:t}))),s=e=>j(e,((e,t)=>({...t.modification,...e})),{}),a=j(i.classes,((e,t)=>t.modification.concat(e)),[]),l=s(i.attributes),c=s(i.styles);return Os({classes:a,attributes:l,styles:c})})(o,s,t,n):i;return l=n,c=a,{...l,attributes:{...l.attributes,...c.attributes},styles:{...l.styles,...c.styles},classes:l.classes.concat(c.classes)};var l,c})(r,s,a),c=((e,t)=>{const o=t.filter((t=>Ze(t)===e.tag&&!(e=>e.innerHtml.isSome()&&e.domChildren.length>0)(e)&&!(e=>be(e.dom,_s))(t))).bind((t=>((e,t)=>{try{const o=Js(e,t);return M.some(o)}catch(e){return M.none()}})(e,t))).getOrThunk((()=>(e=>{const t=De(e.tag);kt(t,e.attributes),js(t,e.classes),Nt(t,e.styles),e.innerHtml.each((e=>ts(t,e)));const o=e.domChildren;return Lo(t,o),e.value.each((e=>{qs(t,e)})),t})(e)));return ms(o,e.uid),o})(l,t),d=((e,t,o)=>{const n={"alloy.base.behaviour":Ps(e)};return((e,t,o,n)=>{const r=((e,t,o)=>{const n={...o,...Bs(t,e)};return Es(n,As)})(e,o,n);return Rs(r,t)})(o,e.eventOrder,t,n).getOrDie()})(r,s,a),u=Or(r.components),h={uid:e.uid,getSystem:n.get,config:t=>{const o=a;return(p(o[t.name()])?o[t.name()]:()=>{throw new Error("Could not find "+t.name()+" in "+JSON.stringify(e,null,2))})()},hasConfigured:e=>p(a[e.name()]),spec:e,readState:e=>a[e]().map((e=>e.state.readState())).getOr("not enabled"),getApis:()=>r.apis,connect:e=>{n.set(e)},disconnect:()=>{n.set(vs(o))},element:c,syncComponents:()=>{const e=at(c),t=G(e,(e=>n.get().getByDom(e).fold((()=>[]),Q)));u.set(t)},components:u.get,events:d};return h},ta=e=>{const t=Pe(e);return oa({element:t})},oa=e=>{const t=Yn("external.component",An([or("element"),ur("uid")]),e),o=Or(vs()),n=t.uid.getOrThunk((()=>gs("external")));ms(t.element,n);const r={uid:n,getSystem:o.get,config:M.none,hasConfigured:E,connect:e=>{o.set(e)},disconnect:()=>{o.set(vs((()=>r)))},getApis:()=>({}),element:t.element,spec:e,readState:w("No state"),syncComponents:v,components:w([]),events:{}};return xs(r)},na=gs,ra=(e,t)=>Cs(e).getOrThunk((()=>((e,t)=>{const{events:o,...n}=fs(e),r=((e,t)=>{const o=ve(e,"components").getOr([]);return t.fold((()=>L(o,ia)),(e=>L(o,((t,o)=>ra(t,lt(e,o))))))})(n,t),i={...n,events:{...ss,...o},components:r};return rn.value(ea(i,t))})((e=>be(e,"uid"))(e)?e:{uid:na(""),...e},t).getOrDie())),ia=e=>ra(e,M.none()),sa=xs;var aa,la=(e,t,o,n,r)=>e(o,n)?M.some(o):p(r)&&r(o)?M.none():t(o,n,r);const ca=(e,t,o)=>{let n=e.dom;const r=p(o)?o:E;for(;n.parentNode;){n=n.parentNode;const e=Ie(n);if(t(e))return M.some(e);if(r(e))break}return M.none()},da=(e,t,o)=>la(((e,t)=>t(e)),ca,e,t,o),ua=(e,t,o)=>da(e,t,o).isSome(),ha=(e,t,o)=>ca(e,(e=>Ke(e,t)),o),ma=(e,t)=>((e,o)=>$(e.dom.childNodes,(e=>{return o=Ie(e),Ke(o,t);var o})).map(Ie))(e),pa=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return Xe(o)?M.none():M.from(o.querySelector(e)).map(Ie)})(t,e),ga=(e,t,o)=>la(((e,t)=>Ke(e,t)),ha,e,t,o),fa="aria-controls",va=()=>{const e=ls(fa);return{id:e,link:t=>{Ct(t,fa,e)},unlink:e=>{Ot(e,fa)}}},ba=(e,t)=>ua(t,(t=>Je(t,e.element)),E)||((e,t)=>(e=>da(e,(e=>{if(!$e(e))return!1;const t=St(e,"id");return void 0!==t&&t.indexOf(fa)>-1})).bind((e=>{const t=St(e,"id"),o=gt(e);return pa(o,`[${fa}="${t}"]`)})))(t).exists((t=>ba(e,t))))(e,t);var ya;!function(e){e[e.STOP=0]="STOP",e[e.NORMAL=1]="NORMAL",e[e.LOGGING=2]="LOGGING"}(ya||(ya={}));const wa=Or({}),_a=["alloy/data/Fields","alloy/debugging/Debugging"],xa=(e,t,o)=>((e,t,o)=>{switch(ve(wa.get(),e).orThunk((()=>{const t=se(wa.get());return ie(t,(t=>e.indexOf(t)>-1?M.some(wa.get()[t]):M.none()))})).getOr(ya.NORMAL)){case ya.NORMAL:return o(Ca());case ya.LOGGING:{const n=((e,t)=>{const o=[],n=(new Date).getTime();return{logEventCut:(e,t,n)=>{o.push({outcome:"cut",target:t,purpose:n})},logEventStopped:(e,t,n)=>{o.push({outcome:"stopped",target:t,purpose:n})},logNoParent:(e,t,n)=>{o.push({outcome:"no-parent",target:t,purpose:n})},logEventNoHandlers:(e,t)=>{o.push({outcome:"no-handlers-left",target:t})},logEventResponse:(e,t,n)=>{o.push({outcome:"response",purpose:n,target:t})},write:()=>{const r=(new Date).getTime();D(["mousemove","mouseover","mouseout",vi()],e)||console.log(e,{event:e,time:r-n,target:t.dom,sequence:L(o,(e=>D(["cut","stopped","response"],e.outcome)?"{"+e.purpose+"} "+e.outcome+" at ("+ns(e.target)+")":e.outcome))})}}})(e,t),r=o(n);return n.write(),r}case ya.STOP:return!0}})(e,t,o),Ca=w({logEventCut:v,logEventStopped:v,logNoParent:v,logEventNoHandlers:v,logEventResponse:v,write:v}),ka=w([or("menu"),or("selectedMenu")]),Sa=w([or("item"),or("selectedItem")]);w(Bn(Sa().concat(ka())));const Ta=w(Bn(Sa())),Ea=lr("initSize",[or("numColumns"),or("numRows")]),Oa=()=>lr("markers",[or("backgroundMenu")].concat(ka()).concat(Sa())),Ma=e=>lr("markers",L(e,or)),Aa=(e,t,o)=>((()=>{const e=new Error;if(void 0!==e.stack){const t=e.stack.split("\n");$(t,(e=>e.indexOf("alloy")>0&&!P(_a,(t=>e.indexOf(t)>-1)))).getOr("unknown")}})(),Qn(t,t,o,$n((e=>rn.value(((...t)=>e.apply(void 0,t))))))),Ba=e=>Aa(0,e,yn(v)),Na=e=>Aa(0,e,yn(M.none)),Ra=e=>Aa(0,e,{tag:"required",process:{}}),Va=e=>Aa(0,e,{tag:"required",process:{}}),Da=(e,t)=>er(e,w(t)),Pa=e=>er(e,_),Ia=w(Ea),Fa=(e,t,o,n,r,i,s,a=!1)=>({x:e,y:t,bubble:o,direction:n,placement:r,restriction:i,label:`${s}-${r}`,alwaysFit:a}),La=Mr([{southeast:[]},{southwest:[]},{northeast:[]},{northwest:[]},{south:[]},{north:[]},{east:[]},{west:[]}]),za=La.southeast,Ha=La.southwest,Za=La.northeast,ja=La.northwest,Ua=La.south,$a=La.north,Wa=La.east,qa=La.west,Ga=(e,t,o,n)=>{const r=e+t;return r>n?o:rMath.min(Math.max(e,t),o),Ka=(e,t)=>J(["left","right","top","bottom"],(o=>ve(t,o).map((t=>((e,t)=>{switch(t){case 1:return e.x;case 0:return e.x+e.width;case 2:return e.y;case 3:return e.y+e.height}})(e,t))))),Xa="layout",Ja=e=>e.x,Qa=(e,t)=>e.x+e.width/2-t.width/2,el=(e,t)=>e.x+e.width-t.width,tl=(e,t)=>e.y-t.height,ol=e=>e.y+e.height,nl=(e,t)=>e.y+e.height/2-t.height/2,rl=(e,t,o)=>Fa(Ja(e),ol(e),o.southeast(),za(),"southeast",Ka(e,{left:1,top:3}),Xa),il=(e,t,o)=>Fa(el(e,t),ol(e),o.southwest(),Ha(),"southwest",Ka(e,{right:0,top:3}),Xa),sl=(e,t,o)=>Fa(Ja(e),tl(e,t),o.northeast(),Za(),"northeast",Ka(e,{left:1,bottom:2}),Xa),al=(e,t,o)=>Fa(el(e,t),tl(e,t),o.northwest(),ja(),"northwest",Ka(e,{right:0,bottom:2}),Xa),ll=(e,t,o)=>Fa(Qa(e,t),tl(e,t),o.north(),$a(),"north",Ka(e,{bottom:2}),Xa),cl=(e,t,o)=>Fa(Qa(e,t),ol(e),o.south(),Ua(),"south",Ka(e,{top:3}),Xa),dl=(e,t,o)=>Fa((e=>e.x+e.width)(e),nl(e,t),o.east(),Wa(),"east",Ka(e,{left:0}),Xa),ul=(e,t,o)=>Fa(((e,t)=>e.x-t.width)(e,t),nl(e,t),o.west(),qa(),"west",Ka(e,{right:1}),Xa),hl=()=>[rl,il,sl,al,cl,ll,dl,ul],ml=()=>[il,rl,al,sl,cl,ll,dl,ul],pl=()=>[sl,al,rl,il,ll,cl],gl=()=>[al,sl,il,rl,ll,cl],fl=()=>[rl,il,sl,al,cl,ll],vl=()=>[il,rl,al,sl,cl,ll];var bl=Object.freeze({__proto__:null,events:e=>Li([Zi(di(),((t,o)=>{const n=e.channels,r=se(n),i=o,s=((e,t)=>t.universal?e:Z(e,(e=>D(t.channels,e))))(r,i);z(s,(e=>{const o=n[e],r=o.schema,s=Yn("channel["+e+"] data\nReceiver: "+ns(t.element),r,i.data);o.onReceive(t,s)}))}))])}),yl=[nr("channels",Wn(rn.value,An([Ra("onReceive"),yr("schema",Pn())])))];const wl=(e,t,o)=>Ji(((n,r)=>{o(n,e,t)})),_l=e=>({key:e,value:void 0}),xl=(e,t,o,n,r,i,s)=>{const a=e=>ye(e,o)?e[o]():M.none(),l=ce(r,((e,t)=>((e,t,o)=>((e,t,o)=>{const n=o.toString(),r=n.indexOf(")")+1,i=n.indexOf("("),s=n.substring(i+1,r-1).split(/,\s*/);return e.toFunctionAnnotation=()=>({name:t,parameters:ys(s.slice(0,1).concat(s.slice(3)))}),e})(((n,...r)=>{const i=[n].concat(r);return n.config({name:w(e)}).fold((()=>{throw new Error("We could not find any behaviour configuration for: "+e+". Using API: "+o)}),(e=>{const o=Array.prototype.slice.call(i,1);return t.apply(void 0,[n,e.config,e.state].concat(o))}))}),o,t))(o,e,t))),c={...ce(i,((e,t)=>ws(e,t))),...l,revoke:C(_l,o),config:t=>{const n=Yn(o+"-config",e,t);return{key:o,value:{config:n,me:c,configAsRaw:Qt((()=>Yn(o+"-config",e,t))),initialConfig:t,state:s}}},schema:w(t),exhibit:(e,t)=>xe(a(e),ve(n,"exhibit"),((e,o)=>o(t,e.config,e.state))).getOrThunk((()=>Os({}))),name:w(o),handlers:e=>a(e).map((e=>ve(n,"events").getOr((()=>({})))(e.config,e.state))).getOr({})};return c},Cl=e=>Br(e),kl=An([or("fields"),or("name"),yr("active",{}),yr("apis",{}),yr("state",Ss),yr("extra",{})]),Sl=e=>{const t=Yn("Creating behaviour: "+e.name,kl,e);return((e,t,o,n,r,i)=>{const s=An(e),a=br(t,[("config",l=e,hr("config",An(l)))]);var l;return xl(s,a,t,o,n,r,i)})(t.fields,t.name,t.active,t.apis,t.extra,t.state)},Tl=An([or("branchKey"),or("branches"),or("name"),yr("active",{}),yr("apis",{}),yr("state",Ss),yr("extra",{})]),El=e=>{const t=Yn("Creating behaviour: "+e.name,Tl,e);return((e,t,o,n,r,i)=>{const s=e,a=br(t,[hr("config",e)]);return xl(s,a,t,o,n,r,i)})(Xn(t.branchKey,t.branches),t.name,t.active,t.apis,t.extra,t.state)},Ol=w(void 0),Ml=Sl({fields:yl,name:"receiving",active:bl});var Al=Object.freeze({__proto__:null,exhibit:(e,t)=>Os({classes:[],styles:t.useFixed()?{}:{position:"relative"}})});const Bl=e=>e.dom.focus(),Nl=e=>e.dom.blur(),Rl=e=>{const t=gt(e).dom;return e.dom===t.activeElement},Vl=(e=Wo())=>M.from(e.dom.activeElement).map(Ie),Dl=e=>Vl(gt(e)).filter((t=>e.dom.contains(t.dom))),Pl=(e,t)=>{const o=gt(t),n=Vl(o).bind((e=>{const o=t=>Je(e,t);return o(t)?M.some(t):((e,t)=>{const o=e=>{for(let n=0;n{Vl(o).filter((t=>Je(t,e))).fold((()=>{Bl(e)}),v)})),r},Il=(e,t,o,n,r)=>{const i=e=>e+"px";return{position:e,left:t.map(i),top:o.map(i),right:n.map(i),bottom:r.map(i)}},Fl=(e,t)=>{Rt(e,(e=>({...e,position:M.some(e.position)}))(t))},Ll=Mr([{none:[]},{relative:["x","y","width","height"]},{fixed:["x","y","width","height"]}]),zl=(e,t,o,n,r,i)=>{const s=t.rect,a=s.x-o,l=s.y-n,c=r-(a+s.width),d=i-(l+s.height),u=M.some(a),h=M.some(l),m=M.some(c),p=M.some(d),g=M.none();return t.direction.fold((()=>Il(e,u,h,g,g)),(()=>Il(e,g,h,m,g)),(()=>Il(e,u,g,g,p)),(()=>Il(e,g,g,m,p)),(()=>Il(e,u,h,g,g)),(()=>Il(e,u,g,g,p)),(()=>Il(e,u,h,g,g)),(()=>Il(e,g,h,m,g)))},Hl=(e,t)=>e.fold((()=>{const e=t.rect;return Il("absolute",M.some(e.x),M.some(e.y),M.none(),M.none())}),((e,o,n,r)=>zl("absolute",t,e,o,n,r)),((e,o,n,r)=>zl("fixed",t,e,o,n,r))),Zl=(e,t)=>{const o=C(Yo,t),n=e.fold(o,o,(()=>{const e=Zo();return Yo(t).translate(-e.left,-e.top)})),r=Jt(t),i=Ut(t);return Ko(n.left,n.top,r,i)},jl=(e,t)=>t.fold((()=>e.fold(en,en,Ko)),(t=>e.fold(w(t),w(t),(()=>{const o=Ul(e,t.x,t.y);return Ko(o.left,o.top,t.width,t.height)})))),Ul=(e,t,o)=>{const n=Wt(t,o);return e.fold(w(n),w(n),(()=>{const e=Zo();return n.translate(-e.left,-e.top)}))};Ll.none;const $l=Ll.relative,Wl=Ll.fixed,ql="data-alloy-placement",Gl=e=>Tt(e,ql),Yl=Mr([{fit:["reposition"]},{nofit:["reposition","visibleW","visibleH","isVisible"]}]),Kl=(e,t,o,n)=>{const r=e.bubble,i=r.offset,s=((e,t,o)=>{const n=(n,r)=>t[n].map((t=>{const i="top"===n||"bottom"===n,s=i?o.top:o.left,a=("left"===n||"top"===n?Math.max:Math.min)(t,r)+s;return i?Ya(a,e.y,e.bottom):Ya(a,e.x,e.right)})).getOr(r),r=n("left",e.x),i=n("top",e.y),s=n("right",e.right),a=n("bottom",e.bottom);return Ko(r,i,s-r,a-i)})(n,e.restriction,i),a=e.x+i.left,l=e.y+i.top,c=Ko(a,l,t,o),{originInBounds:d,sizeInBounds:u,visibleW:h,visibleH:m}=((e,t)=>{const{x:o,y:n,right:r,bottom:i}=t,{x:s,y:a,right:l,bottom:c,width:d,height:u}=e;return{originInBounds:s>=o&&s<=r&&a>=n&&a<=i,sizeInBounds:l<=r&&l>=o&&c<=i&&c>=n,visibleW:Math.min(d,s>=o?r-s:l-o),visibleH:Math.min(u,a>=n?i-a:c-n)}})(c,s),p=d&&u,g=p?c:((e,t)=>{const{x:o,y:n,right:r,bottom:i}=t,{x:s,y:a,width:l,height:c}=e,d=Math.max(o,r-l),u=Math.max(n,i-c),h=Ya(s,o,d),m=Ya(a,n,u),p=Math.min(h+l,r)-h,g=Math.min(m+c,i)-m;return Ko(h,m,p,g)})(c,s),f=g.width>0&&g.height>0,{maxWidth:v,maxHeight:b}=((e,t,o)=>{const n=w(t.bottom-o.y),r=w(o.bottom-t.y),i=((e,t,o,n)=>e.fold(t,t,n,n,t,n,o,o))(e,r,r,n),s=w(t.right-o.x),a=w(o.right-t.x),l=((e,t,o,n)=>e.fold(t,n,t,n,o,o,t,n))(e,a,a,s);return{maxWidth:l,maxHeight:i}})(e.direction,g,n),y={rect:g,maxHeight:b,maxWidth:v,direction:e.direction,placement:e.placement,classes:{on:r.classesOn,off:r.classesOff},layout:e.label,testY:l};return p||e.alwaysFit?Yl.fit(y):Yl.nofit(y,h,m,f)},Xl=e=>{const t=Or(M.none()),o=()=>t.get().each(e);return{clear:()=>{o(),t.set(M.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:e=>{o(),t.set(M.some(e))}}},Jl=()=>Xl((e=>e.unbind())),Ql=()=>{const e=Xl(v);return{...e,on:t=>e.get().each(t)}},ec=O,tc=(e,t,o)=>((e,t,o,n)=>Ro(e,t,o,n,!1))(e,t,ec,o),oc=(e,t,o)=>((e,t,o,n)=>Ro(e,t,o,n,!0))(e,t,ec,o),nc=No,rc=["top","bottom","right","left"],ic="data-alloy-transition-timer",sc=(e,t,o,n,r,s)=>{const a=((e,t,o)=>o.exists((o=>{const n=e.mode;return"all"===n||o[n]!==t[n]})))(n,r,s);if(a||((e,t)=>$s(e,t.classes))(e,n)){Bt(e,"position",o.position);const s=Zl(t,e),l=Hl(t,{...r,rect:s}),c=J(rc,(e=>l[e]));((e,t)=>{const o=e=>parseFloat(e).toFixed(3);return ge(t,((t,n)=>!((e,t,o=x)=>xe(e,t,o).getOr(e.isNone()&&t.isNone()))(e[n].map(o),t.map(o)))).isSome()})(o,c)&&(Rt(e,c),a&&((e,t)=>{js(e,t.classes),Tt(e,ic).each((t=>{clearTimeout(parseInt(t,10)),Ot(e,ic)})),((e,t)=>{const o=Jl(),n=Jl();let r;const s=t=>{var o;const n=null!==(o=t.raw.pseudoElement)&&void 0!==o?o:"";return Je(t.target,e)&&!Be(n)&&D(rc,t.raw.propertyName)},a=i=>{if(h(i)||s(i)){o.clear(),n.clear();const s=null==i?void 0:i.raw.type;(h(s)||s===oi())&&(clearTimeout(r),Ot(e,ic),Us(e,t.classes))}},l=tc(e,ni(),(t=>{s(t)&&(l.unbind(),o.set(tc(e,oi(),a)),n.set(tc(e,ti(),a)))})),c=(e=>{const t=t=>{const o=Vt(e,t).split(/\s*,\s*/);return Z(o,Be)},o=e=>{if(i(e)&&/^[\d.]+/.test(e)){const t=parseFloat(e);return Me(e,"ms")?t:1e3*t}return 0},n=t("transition-delay"),r=t("transition-duration");return U(r,((e,t,r)=>{const i=o(n[r])+o(t);return Math.max(e,i)}),0)})(e);requestAnimationFrame((()=>{r=setTimeout(a,c+17),Ct(e,ic,r)}))})(e,t)})(e,n),zt(e))}else Us(e,n.classes)},ac=(e,t)=>{((e,t)=>{const o=Zt.max(e,t,["margin-top","border-top-width","padding-top","padding-bottom","border-bottom-width","margin-bottom"]);Bt(e,"max-height",o+"px")})(e,Math.floor(t))},lc=w(((e,t)=>{ac(e,t),Nt(e,{"overflow-x":"hidden","overflow-y":"auto"})})),cc=w(((e,t)=>{ac(e,t)})),dc=(e,t,o)=>void 0===e[t]?o:e[t],uc=(e,t,o,n)=>{const r=((e,t,o,n)=>{Lt(t,"max-height"),Lt(t,"max-width");const r={width:Jt(i=t),height:Ut(i)};var i;return((e,t,o,n,r,i)=>{const s=n.width,a=n.height,l=(t,l,c,d,u)=>{const h=t(o,n,r,e,i),m=Kl(h,s,a,i);return m.fold(w(m),((e,t,o,n)=>(u===n?o>d||t>c:!u&&n)?m:Yl.nofit(l,c,d,u)))};return U(t,((e,t)=>{const o=C(l,t);return e.fold(w(e),o)}),Yl.nofit({rect:o,maxHeight:n.height,maxWidth:n.width,direction:za(),placement:"southeast",classes:{on:[],off:[]},layout:"none",testY:o.y},-1,-1,!1)).fold(_,_)})(t,n.preference,e,r,o,n.bounds)})(e,t,o,n);return((e,t,o)=>{const n=Hl(o.origin,t);o.transition.each((r=>{sc(e,o.origin,n,r,t,o.lastPlacement)})),Fl(e,n)})(t,r,n),((e,t)=>{((e,t)=>{Ct(e,ql,t)})(e,t.placement)})(t,r),((e,t)=>{const o=t.classes;Us(e,o.off),js(e,o.on)})(t,r),((e,t,o)=>{(0,o.maxHeightFunction)(e,t.maxHeight)})(t,r,n),((e,t,o)=>{(0,o.maxWidthFunction)(e,t.maxWidth)})(t,r,n),{layout:r.layout,placement:r.placement}},hc=["valignCentre","alignLeft","alignRight","alignCentre","top","bottom","left","right","inset"],mc=(e,t,o,n=1)=>{const r=e*n,i=t*n,s=e=>ve(o,e).getOr([]),a=(e,t,o)=>{const n=X(hc,o);return{offset:Wt(e,t),classesOn:G(o,s),classesOff:G(n,s)}};return{southeast:()=>a(-e,t,["top","alignLeft"]),southwest:()=>a(e,t,["top","alignRight"]),south:()=>a(-e/2,t,["top","alignCentre"]),northeast:()=>a(-e,-t,["bottom","alignLeft"]),northwest:()=>a(e,-t,["bottom","alignRight"]),north:()=>a(-e/2,-t,["bottom","alignCentre"]),east:()=>a(e,-t/2,["valignCentre","left"]),west:()=>a(-e,-t/2,["valignCentre","right"]),insetNortheast:()=>a(r,i,["top","alignLeft","inset"]),insetNorthwest:()=>a(-r,i,["top","alignRight","inset"]),insetNorth:()=>a(-r/2,i,["top","alignCentre","inset"]),insetSoutheast:()=>a(r,-i,["bottom","alignLeft","inset"]),insetSouthwest:()=>a(-r,-i,["bottom","alignRight","inset"]),insetSouth:()=>a(-r/2,-i,["bottom","alignCentre","inset"]),insetEast:()=>a(-r,-i/2,["valignCentre","right","inset"]),insetWest:()=>a(r,-i/2,["valignCentre","left","inset"])}},pc=()=>mc(0,0,{}),gc=_,fc=(e,t)=>o=>"rtl"===vc(o)?t:e,vc=e=>"rtl"===Vt(e,"direction")?"rtl":"ltr";var bc;!function(e){e.TopToBottom="toptobottom",e.BottomToTop="bottomtotop"}(bc||(bc={}));const yc="data-alloy-vertical-dir",wc=e=>ua(e,(e=>$e(e)&&St(e,"data-alloy-vertical-dir")===bc.BottomToTop)),_c=()=>br("layouts",[or("onLtr"),or("onRtl"),ur("onBottomLtr"),ur("onBottomRtl")]),xc=(e,t,o,n,r,i,s)=>{const a=s.map(wc).getOr(!1),l=t.layouts.map((t=>t.onLtr(e))),c=t.layouts.map((t=>t.onRtl(e))),d=a?t.layouts.bind((t=>t.onBottomLtr.map((t=>t(e))))).or(l).getOr(r):l.getOr(o),u=a?t.layouts.bind((t=>t.onBottomRtl.map((t=>t(e))))).or(c).getOr(i):c.getOr(n);return fc(d,u)(e)};var Cc=[or("hotspot"),ur("bubble"),yr("overrides",{}),_c(),Da("placement",((e,t,o)=>{const n=t.hotspot,r=Zl(o,n.element),i=xc(e.element,t,fl(),vl(),pl(),gl(),M.some(t.hotspot.element));return M.some(gc({anchorBox:r,bubble:t.bubble.getOr(pc()),overrides:t.overrides,layouts:i}))}))],kc=[or("x"),or("y"),yr("height",0),yr("width",0),yr("bubble",pc()),yr("overrides",{}),_c(),Da("placement",((e,t,o)=>{const n=Ul(o,t.x,t.y),r=Ko(n.left,n.top,t.width,t.height),i=xc(e.element,t,hl(),ml(),hl(),ml(),M.none());return M.some(gc({anchorBox:r,bubble:t.bubble,overrides:t.overrides,layouts:i}))}))];const Sc=Mr([{screen:["point"]},{absolute:["point","scrollLeft","scrollTop"]}]),Tc=e=>e.fold(_,((e,t,o)=>e.translate(-t,-o))),Ec=e=>e.fold(_,_),Oc=e=>U(e,((e,t)=>e.translate(t.left,t.top)),Wt(0,0)),Mc=e=>{const t=L(e,Ec);return Oc(t)},Ac=Sc.screen,Bc=Sc.absolute,Nc=(e,t,o)=>{const n=et(e.element),r=Zo(n),i=((e,t,o)=>{const n=nt(o.root).dom;return M.from(n.frameElement).map(Ie).filter((t=>{const o=et(t),n=et(e.element);return Je(o,n)})).map(Gt)})(e,0,o).getOr(r);return Bc(i,r.left,r.top)},Rc=(e,t,o,n)=>{const r=Ac(Wt(e,t));return M.some(((e,t,o)=>({point:e,width:t,height:o}))(r,o,n))},Vc=(e,t,o,n,r)=>e.map((e=>{const i=[t,e.point],s=(a=()=>Mc(i),l=()=>Mc(i),c=()=>(e=>{const t=L(e,Tc);return Oc(t)})(i),n.fold(a,l,c));var a,l,c;const d=(p=s.left,g=s.top,f=e.width,v=e.height,{x:p,y:g,width:f,height:v}),u=o.showAbove?pl():fl(),h=o.showAbove?gl():vl(),m=xc(r,o,u,h,u,h,M.none());var p,g,f,v;return gc({anchorBox:d,bubble:o.bubble.getOr(pc()),overrides:o.overrides,layouts:m})}));var Dc=[or("node"),or("root"),ur("bubble"),_c(),yr("overrides",{}),yr("showAbove",!1),Da("placement",((e,t,o)=>{const n=Nc(e,0,t);return t.node.filter(yt).bind((r=>{const i=r.dom.getBoundingClientRect(),s=Rc(i.left,i.top,i.width,i.height),a=t.node.getOr(e.element);return Vc(s,n,t,o,a)}))}))];const Pc=(e,t,o,n)=>({start:e,soffset:t,finish:o,foffset:n}),Ic=Mr([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),Fc=(Ic.before,Ic.on,Ic.after,e=>e.fold(_,_,_)),Lc=Mr([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),zc={domRange:Lc.domRange,relative:Lc.relative,exact:Lc.exact,exactFromRange:e=>Lc.exact(e.start,e.soffset,e.finish,e.foffset),getWin:e=>{const t=(e=>e.match({domRange:e=>Ie(e.startContainer),relative:(e,t)=>Fc(e),exact:(e,t,o,n)=>e}))(e);return nt(t)},range:Pc},Hc=(e,t,o)=>{const n=e.document.createRange();var r;return r=n,t.fold((e=>{r.setStartBefore(e.dom)}),((e,t)=>{r.setStart(e.dom,t)}),(e=>{r.setStartAfter(e.dom)})),((e,t)=>{t.fold((t=>{e.setEndBefore(t.dom)}),((t,o)=>{e.setEnd(t.dom,o)}),(t=>{e.setEndAfter(t.dom)}))})(n,o),n},Zc=(e,t,o,n,r)=>{const i=e.document.createRange();return i.setStart(t.dom,o),i.setEnd(n.dom,r),i},jc=e=>({left:e.left,top:e.top,right:e.right,bottom:e.bottom,width:e.width,height:e.height}),Uc=Mr([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),$c=(e,t,o)=>t(Ie(o.startContainer),o.startOffset,Ie(o.endContainer),o.endOffset),Wc=(e,t)=>((e,t)=>{const o=((e,t)=>t.match({domRange:e=>({ltr:w(e),rtl:M.none}),relative:(t,o)=>({ltr:Qt((()=>Hc(e,t,o))),rtl:Qt((()=>M.some(Hc(e,o,t))))}),exact:(t,o,n,r)=>({ltr:Qt((()=>Zc(e,t,o,n,r))),rtl:Qt((()=>M.some(Zc(e,n,r,t,o))))})}))(e,t);return((e,t)=>{const o=t.ltr();return o.collapsed?t.rtl().filter((e=>!1===e.collapsed)).map((e=>Uc.rtl(Ie(e.endContainer),e.endOffset,Ie(e.startContainer),e.startOffset))).getOrThunk((()=>$c(0,Uc.ltr,o))):$c(0,Uc.ltr,o)})(0,o)})(e,t).match({ltr:(t,o,n,r)=>{const i=e.document.createRange();return i.setStart(t.dom,o),i.setEnd(n.dom,r),i},rtl:(t,o,n,r)=>{const i=e.document.createRange();return i.setStart(n.dom,r),i.setEnd(t.dom,o),i}});Uc.ltr,Uc.rtl;const qc=(e,t,o)=>Z(((e,t)=>{const o=p(t)?t:E;let n=e.dom;const r=[];for(;null!==n.parentNode&&void 0!==n.parentNode;){const e=n.parentNode,t=Ie(e);if(r.push(t),!0===o(t))break;n=e}return r})(e,o),t),Gc=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return Xe(o)?[]:L(o.querySelectorAll(e),Ie)})(t,e),Yc=e=>{if(e.rangeCount>0){const t=e.getRangeAt(0),o=e.getRangeAt(e.rangeCount-1);return M.some(Pc(Ie(t.startContainer),t.startOffset,Ie(o.endContainer),o.endOffset))}return M.none()},Kc=e=>{if(null===e.anchorNode||null===e.focusNode)return Yc(e);{const t=Ie(e.anchorNode),o=Ie(e.focusNode);return((e,t,o,n)=>{const r=((e,t,o,n)=>{const r=et(e).dom.createRange();return r.setStart(e.dom,t),r.setEnd(o.dom,n),r})(e,t,o,n),i=Je(e,o)&&t===n;return r.collapsed&&!i})(t,e.anchorOffset,o,e.focusOffset)?M.some(Pc(t,e.anchorOffset,o,e.focusOffset)):Yc(e)}},Xc=(e,t)=>(e=>{const t=e.getClientRects(),o=t.length>0?t[0]:e.getBoundingClientRect();return o.width>0||o.height>0?M.some(o).map(jc):M.none()})(Wc(e,t)),Jc=((e,t)=>{const o=t=>e(t)?M.from(t.dom.nodeValue):M.none();return{get:t=>{if(!e(t))throw new Error("Can only get text value of a text node");return o(t).getOr("")},getOption:o,set:(t,o)=>{if(!e(t))throw new Error("Can only set raw text value of a text node");t.dom.nodeValue=o}}})(We),Qc=(e,t)=>({element:e,offset:t}),ed=(e,t)=>We(e)?Qc(e,t):((e,t)=>{const o=at(e);if(0===o.length)return Qc(e,t);if(tJc.get(e))(e).length:at(e).length;return Qc(e,t)}})(e,t),td=e=>void 0!==e.foffset,od=(e,t)=>t.getSelection.getOrThunk((()=>()=>(e=>(e=>M.from(e.getSelection()))(e).filter((e=>e.rangeCount>0)).bind(Kc))(e)))().map((e=>{if(td(e)){const t=ed(e.start,e.soffset),o=ed(e.finish,e.foffset);return zc.range(t.element,t.offset,o.element,o.offset)}return e}));var nd=[ur("getSelection"),or("root"),ur("bubble"),_c(),yr("overrides",{}),yr("showAbove",!1),Da("placement",((e,t,o)=>{const n=nt(t.root).dom,r=Nc(e,0,t),i=od(n,t).bind((e=>{if(td(e)){const t=((e,t)=>(e=>{const t=e.getBoundingClientRect();return t.width>0||t.height>0?M.some(t).map(jc):M.none()})(Wc(e,t)))(n,zc.exactFromRange(e)).orThunk((()=>{const t=Pe("\ufeff");Do(e.start,t);const o=Xc(n,zc.exact(t,0,t,1));return Ho(t),o}));return t.bind((e=>Rc(e.left,e.top,e.width,e.height)))}{const t=ce(e,(e=>e.dom.getBoundingClientRect())),o={left:Math.min(t.firstCell.left,t.lastCell.left),right:Math.max(t.firstCell.right,t.lastCell.right),top:Math.min(t.firstCell.top,t.lastCell.top),bottom:Math.max(t.firstCell.bottom,t.lastCell.bottom)};return Rc(o.left,o.top,o.right-o.left,o.bottom-o.top)}})),s=od(n,t).bind((e=>td(e)?$e(e.start)?M.some(e.start):it(e.start):M.some(e.firstCell))).getOr(e.element);return Vc(i,r,t,o,s)}))];const rd="link-layout",id=e=>e.x+e.width,sd=(e,t)=>e.x-t.width,ad=(e,t)=>e.y-t.height+e.height,ld=e=>e.y,cd=(e,t,o)=>Fa(id(e),ld(e),o.southeast(),za(),"southeast",Ka(e,{left:0,top:2}),rd),dd=(e,t,o)=>Fa(sd(e,t),ld(e),o.southwest(),Ha(),"southwest",Ka(e,{right:1,top:2}),rd),ud=(e,t,o)=>Fa(id(e),ad(e,t),o.northeast(),Za(),"northeast",Ka(e,{left:0,bottom:3}),rd),hd=(e,t,o)=>Fa(sd(e,t),ad(e,t),o.northwest(),ja(),"northwest",Ka(e,{right:1,bottom:3}),rd),md=()=>[cd,dd,ud,hd],pd=()=>[dd,cd,hd,ud];var gd=[or("item"),_c(),yr("overrides",{}),Da("placement",((e,t,o)=>{const n=Zl(o,t.item.element),r=xc(e.element,t,md(),pd(),md(),pd(),M.none());return M.some(gc({anchorBox:n,bubble:pc(),overrides:t.overrides,layouts:r}))}))],fd=Xn("type",{selection:nd,node:Dc,hotspot:Cc,submenu:gd,makeshift:kc});const vd=[dr("classes",Ln),Cr("mode","all",["all","layout","placement"])],bd=[yr("useFixed",E),ur("getBounds")],yd=[nr("anchor",fd),br("transition",vd)],wd=(e,t,o,n,r,i)=>{const s=Yn("placement.info",Bn(yd),r),a=s.anchor,l=n.element,c=o.get(n.uid);Pl((()=>{Bt(l,"position","fixed");const r=Pt(l,"visibility");Bt(l,"visibility","hidden");const d=t.useFixed()?(()=>{const e=document.documentElement;return Wl(0,0,e.clientWidth,e.clientHeight)})():(e=>{const t=Gt(e.element),o=e.element.dom.getBoundingClientRect();return $l(t.left,t.top,o.width,o.height)})(e);a.placement(e,a,d).each((e=>{const r=i.orThunk((()=>t.getBounds.map(T))),a=((e,t,o,n,r,i)=>((e,t,o,n,r,i,s,a)=>{const l=dc(s,"maxHeightFunction",lc()),c=dc(s,"maxWidthFunction",v),d=e.anchorBox,u=e.origin,h={bounds:jl(u,i),origin:u,preference:n,maxHeightFunction:l,maxWidthFunction:c,lastPlacement:r,transition:a};return uc(d,t,o,h)})(((e,t)=>((e,t)=>({anchorBox:e,origin:t}))(e,t))(t.anchorBox,e),n.element,t.bubble,t.layouts,r,o,t.overrides,i))(d,e,r,n,c,s.transition);o.set(n.uid,a)})),r.fold((()=>{Lt(l,"visibility")}),(e=>{Bt(l,"visibility",e)})),Pt(l,"left").isNone()&&Pt(l,"top").isNone()&&Pt(l,"right").isNone()&&Pt(l,"bottom").isNone()&&we(Pt(l,"position"),"fixed")&&Lt(l,"position")}),l)};var _d=Object.freeze({__proto__:null,position:(e,t,o,n,r)=>{const i=M.none();wd(e,t,o,n,r,i)},positionWithinBounds:wd,getMode:(e,t,o)=>t.useFixed()?"fixed":"absolute",reset:(e,t,o,n)=>{const r=n.element;z(["position","left","right","top","bottom"],(e=>Lt(r,e))),(e=>{Ot(e,ql)})(r),o.clear(n.uid)}});const xd=Sl({fields:bd,name:"positioning",active:Al,apis:_d,state:Object.freeze({__proto__:null,init:()=>{let e={};return Ts({readState:()=>e,clear:t=>{m(t)?delete e[t]:e={}},set:(t,o)=>{e[t]=o},get:t=>ve(e,t)})}})}),Cd=e=>e.getSystem().isConnected(),kd=e=>{Ri(e,Ci());const t=e.components();z(t,kd)},Sd=e=>{const t=e.components();z(t,Sd),Ri(e,xi())},Td=(e,t)=>{e.getSystem().addToWorld(t),yt(e.element)&&Sd(t)},Ed=e=>{kd(e),e.getSystem().removeFromWorld(e)},Od=(e,t)=>{Fo(e.element,t.element)},Md=(e,t)=>{Ad(e,t,Fo)},Ad=(e,t,o)=>{e.getSystem().addToWorld(t),o(e.element,t.element),yt(e.element)&&Sd(t),e.syncComponents()},Bd=e=>{kd(e),Ho(e.element),e.getSystem().removeFromWorld(e)},Nd=e=>{const t=rt(e.element).bind((t=>e.getSystem().getByDom(t).toOptional()));Bd(e),t.each((e=>{e.syncComponents()}))},Rd=e=>{const t=e.components();z(t,Bd),zo(e.element),e.syncComponents()},Vd=(e,t)=>{Pd(e,t,Fo)},Dd=(e,t)=>{Pd(e,t,Po)},Pd=(e,t,o)=>{o(e,t.element);const n=at(t.element);z(n,(e=>{t.getByDom(e).each(Sd)}))},Id=e=>{const t=at(e.element);z(t,(t=>{e.getByDom(t).each(kd)})),Ho(e.element)},Fd=(e,t,o,n)=>{o.get().each((t=>{Rd(e)}));const r=t.getAttachPoint(e);Md(r,e);const i=e.getSystem().build(n);return Md(e,i),o.set(i),i},Ld=(e,t,o,n)=>{const r=Fd(e,t,o,n);return t.onOpen(e,r),r},zd=(e,t,o)=>{o.get().each((n=>{Rd(e),Nd(e),t.onClose(e,n),o.clear()}))},Hd=(e,t,o)=>o.isOpen(),Zd=(e,t,o)=>{const n=t.getAttachPoint(e);Bt(e.element,"position",xd.getMode(n)),((e,t,o,n)=>{Pt(e.element,t).fold((()=>{Ot(e.element,o)}),(t=>{Ct(e.element,o,t)})),Bt(e.element,t,"hidden")})(e,"visibility",t.cloakVisibilityAttr)},jd=(e,t,o)=>{(e=>P(["top","left","right","bottom"],(t=>Pt(e,t).isSome())))(e.element)||Lt(e.element,"position"),((e,t,o)=>{Tt(e.element,o).fold((()=>Lt(e.element,t)),(o=>Bt(e.element,t,o)))})(e,"visibility",t.cloakVisibilityAttr)};var Ud=Object.freeze({__proto__:null,cloak:Zd,decloak:jd,open:Ld,openWhileCloaked:(e,t,o,n,r)=>{Zd(e,t),Ld(e,t,o,n),r(),jd(e,t)},close:zd,isOpen:Hd,isPartOf:(e,t,o,n)=>Hd(0,0,o)&&o.get().exists((o=>t.isPartOf(e,o,n))),getState:(e,t,o)=>o.get(),setContent:(e,t,o,n)=>o.get().map((()=>Fd(e,t,o,n)))}),$d=Object.freeze({__proto__:null,events:(e,t)=>Li([Zi(gi(),((o,n)=>{zd(o,e,t)}))])}),Wd=[Ba("onOpen"),Ba("onClose"),or("isPartOf"),or("getAttachPoint"),yr("cloakVisibilityAttr","data-precloak-visibility")],qd=Object.freeze({__proto__:null,init:()=>{const e=Ql(),t=w("not-implemented");return Ts({readState:t,isOpen:e.isSet,clear:e.clear,set:e.set,get:e.get})}});const Gd=Sl({fields:Wd,name:"sandboxing",active:$d,apis:Ud,state:qd}),Yd=w("dismiss.popups"),Kd=w("reposition.popups"),Xd=w("mouse.released"),Jd=An([yr("isExtraPart",E),br("fireEventInstead",[yr("event",ki())])]),Qd=e=>{const t=Yn("Dismissal",Jd,e);return{[Yd()]:{schema:An([or("target")]),onReceive:(e,o)=>{Gd.isOpen(e)&&(Gd.isPartOf(e,o.target)||t.isExtraPart(e,o.target)||t.fireEventInstead.fold((()=>Gd.close(e)),(t=>Ri(e,t.event))))}}}},eu=An([br("fireEventInstead",[yr("event",Si())]),ar("doReposition")]),tu=e=>{const t=Yn("Reposition",eu,e);return{[Kd()]:{onReceive:e=>{Gd.isOpen(e)&&t.fireEventInstead.fold((()=>t.doReposition(e)),(t=>Ri(e,t.event)))}}}},ou=(e,t,o)=>{t.store.manager.onLoad(e,t,o)},nu=(e,t,o)=>{t.store.manager.onUnload(e,t,o)};var ru=Object.freeze({__proto__:null,onLoad:ou,onUnload:nu,setValue:(e,t,o,n)=>{t.store.manager.setValue(e,t,o,n)},getValue:(e,t,o)=>t.store.manager.getValue(e,t,o),getState:(e,t,o)=>o}),iu=Object.freeze({__proto__:null,events:(e,t)=>{const o=e.resetOnDom?[Ki(((o,n)=>{ou(o,e,t)})),Xi(((o,n)=>{nu(o,e,t)}))]:[wl(e,t,ou)];return Li(o)}});const su=()=>{const e=Or(null);return Ts({set:e.set,get:e.get,isNotSet:()=>null===e.get(),clear:()=>{e.set(null)},readState:()=>({mode:"memory",value:e.get()})})},au=()=>{const e=Or({}),t=Or({});return Ts({readState:()=>({mode:"dataset",dataByValue:e.get(),dataByText:t.get()}),lookup:o=>ve(e.get(),o).orThunk((()=>ve(t.get(),o))),update:o=>{const n=e.get(),r=t.get(),i={},s={};z(o,(e=>{i[e.value]=e,ve(e,"meta").each((t=>{ve(t,"text").each((t=>{s[t]=e}))}))})),e.set({...n,...i}),t.set({...r,...s})},clear:()=>{e.set({}),t.set({})}})};var lu=Object.freeze({__proto__:null,memory:su,dataset:au,manual:()=>Ts({readState:v}),init:e=>e.store.manager.state(e)});const cu=(e,t,o,n)=>{const r=t.store;o.update([n]),r.setValue(e,n),t.onSetValue(e,n)};var du=[ur("initialValue"),or("getFallbackEntry"),or("getDataKey"),or("setValue"),Da("manager",{setValue:cu,getValue:(e,t,o)=>{const n=t.store,r=n.getDataKey(e);return o.lookup(r).getOrThunk((()=>n.getFallbackEntry(r)))},onLoad:(e,t,o)=>{t.store.initialValue.each((n=>{cu(e,t,o,n)}))},onUnload:(e,t,o)=>{o.clear()},state:au})],uu=[or("getValue"),yr("setValue",v),ur("initialValue"),Da("manager",{setValue:(e,t,o,n)=>{t.store.setValue(e,n),t.onSetValue(e,n)},getValue:(e,t,o)=>t.store.getValue(e),onLoad:(e,t,o)=>{t.store.initialValue.each((o=>{t.store.setValue(e,o)}))},onUnload:v,state:Ss.init})],hu=[ur("initialValue"),Da("manager",{setValue:(e,t,o,n)=>{o.set(n),t.onSetValue(e,n)},getValue:(e,t,o)=>o.get(),onLoad:(e,t,o)=>{t.store.initialValue.each((e=>{o.isNotSet()&&o.set(e)}))},onUnload:(e,t,o)=>{o.clear()},state:su})],mu=[wr("store",{mode:"memory"},Xn("mode",{memory:hu,manual:uu,dataset:du})),Ba("onSetValue"),yr("resetOnDom",!1)];const pu=Sl({fields:mu,name:"representing",active:iu,apis:ru,extra:{setValueFrom:(e,t)=>{const o=pu.getValue(t);pu.setValue(e,o)}},state:lu}),gu=(e,t)=>Er(e,{},L(t,(t=>{return o=t.name(),n="Cannot configure "+t.name()+" for "+e,Qn(o,o,{tag:"option",process:{}},kn((e=>un("The field: "+o+" is forbidden. "+n))));var o,n})).concat([er("dump",_)])),fu=e=>e.dump,vu=(e,t)=>({...Cl(t),...e.dump}),bu=gu,yu=vu,wu="placeholder",_u=Mr([{single:["required","valueThunk"]},{multiple:["required","valueThunks"]}]),xu=e=>be(e,"uiType"),Cu=(e,t,o,n)=>((e,t,o,n)=>xu(o)&&o.uiType===wu?((e,t,o,n)=>e.exists((e=>e!==o.owner))?_u.single(!0,w(o)):ve(n,o.name).fold((()=>{throw new Error("Unknown placeholder component: "+o.name+"\nKnown: ["+se(n)+"]\nNamespace: "+e.getOr("none")+"\nSpec: "+JSON.stringify(o,null,2))}),(e=>e.replace())))(e,0,o,n):_u.single(!1,w(o)))(e,0,o,n).fold(((r,i)=>{const s=xu(o)?i(t,o.config,o.validated):i(t),a=ve(s,"components").getOr([]),l=G(a,(o=>Cu(e,t,o,n)));return[{...s,components:l}]}),((e,n)=>{if(xu(o)){const e=n(t,o.config,o.validated);return o.validated.preprocess.getOr(_)(e)}return n(t)})),ku=_u.single,Su=_u.multiple,Tu=w(wu),Eu=Mr([{required:["data"]},{external:["data"]},{optional:["data"]},{group:["data"]}]),Ou=yr("factory",{sketch:_}),Mu=yr("schema",[]),Au=or("name"),Bu=Qn("pname","pname",bn((e=>"")),Pn()),Nu=er("schema",(()=>[ur("preprocess")])),Ru=yr("defaults",w({})),Vu=yr("overrides",w({})),Du=Bn([Ou,Mu,Au,Bu,Ru,Vu]),Pu=Bn([Ou,Mu,Au,Ru,Vu]),Iu=Bn([Ou,Mu,Au,Bu,Ru,Vu]),Fu=Bn([Ou,Nu,Au,or("unit"),Bu,Ru,Vu]),Lu=e=>e.fold(M.some,M.none,M.some,M.some),zu=e=>{const t=e=>e.name;return e.fold(t,t,t,t)},Hu=(e,t)=>o=>{const n=Yn("Converting part type",t,o);return e(n)},Zu=Hu(Eu.required,Du),ju=Hu(Eu.external,Pu),Uu=Hu(Eu.optional,Iu),$u=Hu(Eu.group,Fu),Wu=w("entirety");var qu=Object.freeze({__proto__:null,required:Zu,external:ju,optional:Uu,group:$u,asNamedPart:Lu,name:zu,asCommon:e=>e.fold(_,_,_,_),original:Wu});const Gu=(e,t,o,n)=>fn(t.defaults(e,o,n),o,{uid:e.partUids[t.name]},t.overrides(e,o,n)),Yu=(e,t)=>{const o={};return z(t,(t=>{Lu(t).each((t=>{const n=Ku(e,t.pname);o[t.name]=o=>{const r=Yn("Part: "+t.name+" in "+e,Bn(t.schema),o);return{...n,config:o,validated:r}}}))})),o},Ku=(e,t)=>({uiType:Tu(),owner:e,name:t}),Xu=(e,t,o)=>({uiType:Tu(),owner:e,name:t,config:o,validated:{}}),Ju=e=>G(e,(e=>e.fold(M.none,M.some,M.none,M.none).map((e=>lr(e.name,e.schema.concat([Pa(Wu())])))).toArray())),Qu=e=>L(e,zu),eh=(e,t,o)=>((e,t,o)=>{const n={},r={};return z(o,(e=>{e.fold((e=>{n[e.pname]=ku(!0,((t,o,n)=>e.factory.sketch(Gu(t,e,o,n))))}),(e=>{const o=t.parts[e.name];r[e.name]=w(e.factory.sketch(Gu(t,e,o[Wu()]),o))}),(e=>{n[e.pname]=ku(!1,((t,o,n)=>e.factory.sketch(Gu(t,e,o,n))))}),(e=>{n[e.pname]=Su(!0,((t,o,n)=>{const r=t[e.name];return L(r,(o=>e.factory.sketch(fn(e.defaults(t,o,n),o,e.overrides(t,o)))))}))}))})),{internals:w(n),externals:w(r)}})(0,t,o),th=(e,t,o)=>((e,t,o,n)=>{const r=ce(n,((e,t)=>((e,t)=>{let o=!1;return{name:w(e),required:()=>t.fold(((e,t)=>e),((e,t)=>e)),used:()=>o,replace:()=>{if(o)throw new Error("Trying to use the same placeholder more than once: "+e);return o=!0,t}}})(t,e))),i=((e,t,o,n)=>G(o,(o=>Cu(e,t,o,n))))(e,t,o,r);return le(r,(o=>{if(!1===o.used()&&o.required())throw new Error("Placeholder: "+o.name()+" was not found in components list\nNamespace: "+e.getOr("none")+"\nComponents: "+JSON.stringify(t.components,null,2))})),i})(M.some(e),t,t.components,o),oh=(e,t,o)=>{const n=t.partUids[o];return e.getSystem().getByUid(n).toOptional()},nh=(e,t,o)=>oh(e,t,o).getOrDie("Could not find part: "+o),rh=(e,t,o)=>{const n={},r=t.partUids,i=e.getSystem();return z(o,(e=>{n[e]=w(i.getByUid(r[e]))})),n},ih=(e,t)=>{const o=e.getSystem();return ce(t.partUids,((e,t)=>w(o.getByUid(e))))},sh=e=>se(e.partUids),ah=(e,t,o)=>{const n={},r=t.partUids,i=e.getSystem();return z(o,(e=>{n[e]=w(i.getByUid(r[e]).getOrDie())})),n},lh=(e,t)=>{const o=Qu(t);return Br(L(o,(t=>({key:t,value:e+"-"+t}))))},ch=e=>Qn("partUids","partUids",wn((t=>lh(t.uid,e))),Pn());var dh=Object.freeze({__proto__:null,generate:Yu,generateOne:Xu,schemas:Ju,names:Qu,substitutes:eh,components:th,defaultUids:lh,defaultUidsSchema:ch,getAllParts:ih,getAllPartNames:sh,getPart:oh,getPartOrDie:nh,getParts:rh,getPartsOrDie:ah});const uh=(e,t,o,n,r)=>{const i=((e,t)=>(e.length>0?[lr("parts",e)]:[]).concat([or("uid"),yr("dom",{}),yr("components",[]),Pa("originalSpec"),yr("debug.sketcher",{})]).concat(t))(n,r);return Yn(e+" [SpecSchema]",An(i.concat(t)),o)},hh=(e,t,o,n,r)=>{const i=mh(r),s=Ju(o),a=ch(o),l=uh(e,t,i,s,[a]),c=eh(0,l,o);return n(l,th(e,l,c.internals()),i,c.externals())},mh=e=>(e=>be(e,"uid"))(e)?e:{...e,uid:gs("uid")},ph=An([or("name"),or("factory"),or("configFields"),yr("apis",{}),yr("extraApis",{})]),gh=An([or("name"),or("factory"),or("configFields"),or("partFields"),yr("apis",{}),yr("extraApis",{})]),fh=e=>{const t=Yn("Sketcher for "+e.name,ph,e),o=ce(t.apis,ks),n=ce(t.extraApis,((e,t)=>ws(e,t)));return{name:t.name,configFields:t.configFields,sketch:e=>((e,t,o,n)=>{const r=mh(n);return o(uh(e,t,r,[],[]),r)})(t.name,t.configFields,t.factory,e),...o,...n}},vh=e=>{const t=Yn("Sketcher for "+e.name,gh,e),o=Yu(t.name,t.partFields),n=ce(t.apis,ks),r=ce(t.extraApis,((e,t)=>ws(e,t)));return{name:t.name,partFields:t.partFields,configFields:t.configFields,sketch:e=>hh(t.name,t.configFields,t.partFields,t.factory,e),parts:o,...n,...r}},bh=e=>Ye("input")(e)&&"radio"!==St(e,"type")||Ye("textarea")(e);var yh=Object.freeze({__proto__:null,getCurrent:(e,t,o)=>t.find(e)});const wh=[or("find")],_h=Sl({fields:wh,name:"composing",apis:yh}),xh=["input","button","textarea","select"],Ch=(e,t,o)=>{(t.disabled()?Mh:Ah)(e,t)},kh=(e,t)=>!0===t.useNative&&D(xh,Ze(e.element)),Sh=e=>{Ct(e.element,"disabled","disabled")},Th=e=>{Ot(e.element,"disabled")},Eh=e=>{Ct(e.element,"aria-disabled","true")},Oh=e=>{Ct(e.element,"aria-disabled","false")},Mh=(e,t,o)=>{t.disableClass.each((t=>{zs(e.element,t)})),(kh(e,t)?Sh:Eh)(e),t.onDisabled(e)},Ah=(e,t,o)=>{t.disableClass.each((t=>{Hs(e.element,t)})),(kh(e,t)?Th:Oh)(e),t.onEnabled(e)},Bh=(e,t)=>kh(e,t)?(e=>Et(e.element,"disabled"))(e):(e=>"true"===St(e.element,"aria-disabled"))(e);var Nh=Object.freeze({__proto__:null,enable:Ah,disable:Mh,isDisabled:Bh,onLoad:Ch,set:(e,t,o,n)=>{(n?Mh:Ah)(e,t)}}),Rh=Object.freeze({__proto__:null,exhibit:(e,t)=>Os({classes:t.disabled()?t.disableClass.toArray():[]}),events:(e,t)=>Li([zi(ui(),((t,o)=>Bh(t,e))),wl(e,t,Ch)])}),Vh=[Sr("disabled",E),yr("useNative",!0),ur("disableClass"),Ba("onDisabled"),Ba("onEnabled")];const Dh=Sl({fields:Vh,name:"disabling",active:Rh,apis:Nh}),Ph=(e,t,o,n)=>{const r=Gc(e.element,"."+t.highlightClass);z(r,(o=>{P(n,(e=>Je(e.element,o)))||(Hs(o,t.highlightClass),e.getSystem().getByDom(o).each((o=>{t.onDehighlight(e,o),Ri(o,Ni())})))}))},Ih=(e,t,o,n)=>{Ph(e,t,0,[n]),Fh(e,t,o,n)||(zs(n.element,t.highlightClass),t.onHighlight(e,n),Ri(n,Bi()))},Fh=(e,t,o,n)=>Zs(n.element,t.highlightClass),Lh=(e,t,o)=>pa(e.element,"."+t.itemClass).bind((t=>e.getSystem().getByDom(t).toOptional())),zh=(e,t,o)=>{const n=Gc(e.element,"."+t.itemClass);return(n.length>0?M.some(n[n.length-1]):M.none()).bind((t=>e.getSystem().getByDom(t).toOptional()))},Hh=(e,t,o,n)=>{const r=Gc(e.element,"."+t.itemClass);return W(r,(e=>Zs(e,t.highlightClass))).bind((t=>{const o=Ga(t,n,0,r.length-1);return e.getSystem().getByDom(r[o]).toOptional()}))},Zh=(e,t,o)=>{const n=Gc(e.element,"."+t.itemClass);return _e(L(n,(t=>e.getSystem().getByDom(t).toOptional())))};var jh=Object.freeze({__proto__:null,dehighlightAll:(e,t,o)=>Ph(e,t,0,[]),dehighlight:(e,t,o,n)=>{Fh(e,t,o,n)&&(Hs(n.element,t.highlightClass),t.onDehighlight(e,n),Ri(n,Ni()))},highlight:Ih,highlightFirst:(e,t,o)=>{Lh(e,t).each((n=>{Ih(e,t,o,n)}))},highlightLast:(e,t,o)=>{zh(e,t).each((n=>{Ih(e,t,o,n)}))},highlightAt:(e,t,o,n)=>{((e,t,o,n)=>{const r=Gc(e.element,"."+t.itemClass);return M.from(r[n]).fold((()=>rn.error(new Error("No element found with index "+n))),e.getSystem().getByDom)})(e,t,0,n).fold((e=>{throw e}),(n=>{Ih(e,t,o,n)}))},highlightBy:(e,t,o,n)=>{const r=Zh(e,t);$(r,n).each((n=>{Ih(e,t,o,n)}))},isHighlighted:Fh,getHighlighted:(e,t,o)=>pa(e.element,"."+t.highlightClass).bind((t=>e.getSystem().getByDom(t).toOptional())),getFirst:Lh,getLast:zh,getPrevious:(e,t,o)=>Hh(e,t,0,-1),getNext:(e,t,o)=>Hh(e,t,0,1),getCandidates:Zh}),Uh=[or("highlightClass"),or("itemClass"),Ba("onHighlight"),Ba("onDehighlight")];const $h=Sl({fields:Uh,name:"highlighting",apis:jh}),Wh=[8],qh=[9],Gh=[13],Yh=[27],Kh=[32],Xh=[37],Jh=[38],Qh=[39],em=[40],tm=(e,t,o)=>{const n=K(e.slice(0,t)),r=K(e.slice(t+1));return $(n.concat(r),o)},om=(e,t,o)=>{const n=K(e.slice(0,t));return $(n,o)},nm=(e,t,o)=>{const n=e.slice(0,t),r=e.slice(t+1);return $(r.concat(n),o)},rm=(e,t,o)=>{const n=e.slice(t+1);return $(n,o)},im=e=>t=>{const o=t.raw;return D(e,o.which)},sm=e=>t=>Y(e,(e=>e(t))),am=e=>!0===e.raw.shiftKey,lm=e=>!0===e.raw.ctrlKey,cm=k(am),dm=(e,t)=>({matches:e,classification:t}),um=(e,t,o)=>{t.exists((e=>o.exists((t=>Je(t,e)))))||Vi(e,Ti(),{prevFocus:t,newFocus:o})},hm=()=>{const e=e=>Dl(e.element);return{get:e,set:(t,o)=>{const n=e(t);t.getSystem().triggerFocus(o,t.element);const r=e(t);um(t,n,r)}}},mm=()=>{const e=e=>$h.getHighlighted(e).map((e=>e.element));return{get:e,set:(t,o)=>{const n=e(t);t.getSystem().getByDom(o).fold(v,(e=>{$h.highlight(t,e)}));const r=e(t);um(t,n,r)}}};var pm;!function(e){e.OnFocusMode="onFocus",e.OnEnterOrSpaceMode="onEnterOrSpace",e.OnApiMode="onApi"}(pm||(pm={}));const gm=(e,t,o,n,r)=>{const i=(e,t,o,n,r)=>{return(i=o(e,t,n,r),s=t.event,$(i,(e=>e.matches(s))).map((e=>e.classification))).bind((o=>o(e,t,n,r)));var i,s},s={schema:()=>e.concat([yr("focusManager",hm()),wr("focusInside","onFocus",$n((e=>D(["onFocus","onEnterOrSpace","onApi"],e)?rn.value(e):rn.error("Invalid value for focusInside")))),Da("handler",s),Da("state",t),Da("sendFocusIn",r)]),processKey:i,toEvents:(e,t)=>{const s=e.focusInside!==pm.OnFocusMode?M.none():r(e).map((o=>Zi(ai(),((n,r)=>{o(n,e,t),r.stop()})))),a=[Zi(Kr(),((n,s)=>{i(n,s,o,e,t).fold((()=>{((o,n)=>{const i=im(Kh.concat(Gh))(n.event);e.focusInside===pm.OnEnterOrSpaceMode&&i&&Dr(o,n)&&r(e).each((r=>{r(o,e,t),n.stop()}))})(n,s)}),(e=>{s.stop()}))})),Zi(Xr(),((o,r)=>{i(o,r,n,e,t).each((e=>{r.stop()}))}))];return Li(s.toArray().concat(a))}};return s},fm=e=>{const t=[ur("onEscape"),ur("onEnter"),yr("selector",'[data-alloy-tabstop="true"]:not(:disabled)'),yr("firstTabstop",0),yr("useTabstopAt",O),ur("visibilitySelector")].concat([e]),o=(e,t)=>{const o=e.visibilitySelector.bind((e=>ga(t,e))).getOr(t);return jt(o)>0},n=(e,t)=>t.focusManager.get(e).bind((e=>ga(e,t.selector))),r=(e,t,n)=>{((e,t)=>{const n=Gc(e.element,t.selector),r=Z(n,(e=>o(t,e)));return M.from(r[t.firstTabstop])})(e,t).each((o=>{t.focusManager.set(e,o)}))},i=(e,t,r,i)=>{const s=Gc(e.element,r.selector);return n(e,r).bind((t=>W(s,C(Je,t)).bind((t=>((e,t,n,r,i)=>i(t,n,(e=>((e,t)=>o(e,t)&&e.useTabstopAt(t))(r,e))).fold((()=>r.cyclic?M.some(!0):M.none()),(t=>(r.focusManager.set(e,t),M.some(!0)))))(e,s,t,r,i)))))},s=(e,t,o)=>{const n=o.cyclic?tm:om;return i(e,0,o,n)},a=(e,t,o)=>{const n=o.cyclic?nm:rm;return i(e,0,o,n)},l=w([dm(sm([am,im(qh)]),s),dm(im(qh),a),dm(sm([cm,im(Gh)]),((e,t,o)=>o.onEnter.bind((o=>o(e,t)))))]),c=w([dm(im(Yh),((e,t,o)=>o.onEscape.bind((o=>o(e,t))))),dm(im(qh),((e,t,o)=>n(e,o).filter((e=>!o.useTabstopAt(e))).bind((n=>((e=>(e=>rt(e))(e).bind(ct).exists((t=>Je(t,e))))(n)?s:a)(e,t,o)))))]);return gm(t,Ss.init,l,c,(()=>M.some(r)))};var vm=fm(er("cyclic",E)),bm=fm(er("cyclic",O));const ym=(e,t,o)=>bh(o)&&im(Kh)(t.event)?M.none():((e,t,o)=>(Pi(e,o,ui()),M.some(!0)))(e,0,o),wm=(e,t)=>M.some(!0),_m=[yr("execute",ym),yr("useSpace",!1),yr("useEnter",!0),yr("useControlEnter",!1),yr("useDown",!1)],xm=(e,t,o)=>o.execute(e,t,e.element);var Cm=gm(_m,Ss.init,((e,t,o,n)=>{const r=o.useSpace&&!bh(e.element)?Kh:[],i=o.useEnter?Gh:[],s=o.useDown?em:[],a=r.concat(i).concat(s);return[dm(im(a),xm)].concat(o.useControlEnter?[dm(sm([lm,im(Gh)]),xm)]:[])}),((e,t,o,n)=>o.useSpace&&!bh(e.element)?[dm(im(Kh),wm)]:[]),(()=>M.none()));const km=()=>{const e=Ql();return Ts({readState:()=>e.get().map((e=>({numRows:String(e.numRows),numColumns:String(e.numColumns)}))).getOr({numRows:"?",numColumns:"?"}),setGridSize:(t,o)=>{e.set({numRows:t,numColumns:o})},getNumRows:()=>e.get().map((e=>e.numRows)),getNumColumns:()=>e.get().map((e=>e.numColumns))})};var Sm=Object.freeze({__proto__:null,flatgrid:km,init:e=>e.state(e)});const Tm=e=>(t,o,n,r)=>{const i=e(t.element);return Am(i,t,o,n,r)},Em=(e,t)=>{const o=fc(e,t);return Tm(o)},Om=(e,t)=>{const o=fc(t,e);return Tm(o)},Mm=e=>(t,o,n,r)=>Am(e,t,o,n,r),Am=(e,t,o,n,r)=>n.focusManager.get(t).bind((o=>e(t.element,o,n,r))).map((e=>(n.focusManager.set(t,e),!0))),Bm=Mm,Nm=Mm,Rm=Mm,Vm=e=>!(e=>e.offsetWidth<=0&&e.offsetHeight<=0)(e.dom),Dm=(e,t,o)=>{const n=Gc(e,o);return((e,o)=>W(e,(e=>Je(e,t))).map((t=>({index:t,candidates:e}))))(Z(n,Vm))},Pm=(e,t)=>W(e,(e=>Je(t,e))),Im=(e,t,o,n)=>n(Math.floor(t/o),t%o).bind((t=>{const n=t.row*o+t.column;return n>=0&&nIm(e,t,n,((t,i)=>{const s=t===o-1?e.length-t*n:n,a=Ga(i,r,0,s-1);return M.some({row:t,column:a})})),Lm=(e,t,o,n,r)=>Im(e,t,n,((t,i)=>{const s=Ga(t,r,0,o-1),a=s===o-1?e.length-s*n:n,l=Ya(i,0,a-1);return M.some({row:s,column:l})})),zm=[or("selector"),yr("execute",ym),Na("onEscape"),yr("captureTab",!1),Ia()],Hm=(e,t,o)=>{pa(e.element,t.selector).each((o=>{t.focusManager.set(e,o)}))},Zm=e=>(t,o,n,r)=>Dm(t,o,n.selector).bind((t=>e(t.candidates,t.index,r.getNumRows().getOr(n.initSize.numRows),r.getNumColumns().getOr(n.initSize.numColumns)))),jm=(e,t,o)=>o.captureTab?M.some(!0):M.none(),Um=Zm(((e,t,o,n)=>Fm(e,t,o,n,-1))),$m=Zm(((e,t,o,n)=>Fm(e,t,o,n,1))),Wm=Zm(((e,t,o,n)=>Lm(e,t,o,n,-1))),qm=Zm(((e,t,o,n)=>Lm(e,t,o,n,1))),Gm=w([dm(im(Xh),Em(Um,$m)),dm(im(Qh),Om(Um,$m)),dm(im(Jh),Bm(Wm)),dm(im(em),Nm(qm)),dm(sm([am,im(qh)]),jm),dm(sm([cm,im(qh)]),jm),dm(im(Kh.concat(Gh)),((e,t,o,n)=>((e,t)=>t.focusManager.get(e).bind((e=>ga(e,t.selector))))(e,o).bind((n=>o.execute(e,t,n)))))]),Ym=w([dm(im(Yh),((e,t,o)=>o.onEscape(e,t))),dm(im(Kh),wm)]);var Km=gm(zm,km,Gm,Ym,(()=>M.some(Hm)));const Xm=(e,t,o,n,r)=>{const i=(e,t,o)=>r(e,t,n,0,o.length-1,o[t],(t=>{return n=o[t],"button"===Ze(n)&&"disabled"===St(n,"disabled")?i(e,t,o):M.from(o[t]);var n}));return Dm(e,o,t).bind((e=>{const t=e.index,o=e.candidates;return i(t,t,o)}))},Jm=(e,t,o,n)=>Xm(e,t,o,n,((e,t,o,n,r,i,s)=>{const a=Ya(t+o,n,r);return a===e?M.from(i):s(a)})),Qm=(e,t,o,n)=>Xm(e,t,o,n,((e,t,o,n,r,i,s)=>{const a=Ga(t,o,n,r);return a===e?M.none():s(a)})),ep=[or("selector"),yr("getInitial",M.none),yr("execute",ym),Na("onEscape"),yr("executeOnMove",!1),yr("allowVertical",!0),yr("allowHorizontal",!0),yr("cycles",!0)],tp=(e,t,o)=>((e,t)=>t.focusManager.get(e).bind((e=>ga(e,t.selector))))(e,o).bind((n=>o.execute(e,t,n))),op=(e,t,o)=>{t.getInitial(e).orThunk((()=>pa(e.element,t.selector))).each((o=>{t.focusManager.set(e,o)}))},np=(e,t,o)=>(o.cycles?Qm:Jm)(e,o.selector,t,-1),rp=(e,t,o)=>(o.cycles?Qm:Jm)(e,o.selector,t,1),ip=e=>(t,o,n,r)=>e(t,o,n,r).bind((()=>n.executeOnMove?tp(t,o,n):M.some(!0))),sp=w([dm(im(Kh),wm),dm(im(Yh),((e,t,o)=>o.onEscape(e,t)))]);var ap=gm(ep,Ss.init,((e,t,o,n)=>{const r=[...o.allowHorizontal?Xh:[]].concat(o.allowVertical?Jh:[]),i=[...o.allowHorizontal?Qh:[]].concat(o.allowVertical?em:[]);return[dm(im(r),ip(Em(np,rp))),dm(im(i),ip(Om(np,rp))),dm(im(Gh),tp),dm(im(Kh),tp)]}),sp,(()=>M.some(op)));const lp=(e,t,o)=>M.from(e[t]).bind((e=>M.from(e[o]).map((e=>({rowIndex:t,columnIndex:o,cell:e}))))),cp=(e,t,o,n)=>{const r=e[t].length,i=Ga(o,n,0,r-1);return lp(e,t,i)},dp=(e,t,o,n)=>{const r=Ga(o,n,0,e.length-1),i=e[r].length,s=Ya(t,0,i-1);return lp(e,r,s)},up=(e,t,o,n)=>{const r=e[t].length,i=Ya(o+n,0,r-1);return lp(e,t,i)},hp=(e,t,o,n)=>{const r=Ya(o+n,0,e.length-1),i=e[r].length,s=Ya(t,0,i-1);return lp(e,r,s)},mp=[lr("selectors",[or("row"),or("cell")]),yr("cycles",!0),yr("previousSelector",M.none),yr("execute",ym)],pp=(e,t,o)=>{t.previousSelector(e).orThunk((()=>{const o=t.selectors;return pa(e.element,o.cell)})).each((o=>{t.focusManager.set(e,o)}))},gp=(e,t)=>(o,n,r)=>{const i=r.cycles?e:t;return ga(n,r.selectors.row).bind((e=>{const t=Gc(e,r.selectors.cell);return Pm(t,n).bind((t=>{const n=Gc(o,r.selectors.row);return Pm(n,e).bind((e=>{const o=((e,t)=>L(e,(e=>Gc(e,t.selectors.cell))))(n,r);return i(o,e,t).map((e=>e.cell))}))}))}))},fp=gp(((e,t,o)=>cp(e,t,o,-1)),((e,t,o)=>up(e,t,o,-1))),vp=gp(((e,t,o)=>cp(e,t,o,1)),((e,t,o)=>up(e,t,o,1))),bp=gp(((e,t,o)=>dp(e,o,t,-1)),((e,t,o)=>hp(e,o,t,-1))),yp=gp(((e,t,o)=>dp(e,o,t,1)),((e,t,o)=>hp(e,o,t,1))),wp=w([dm(im(Xh),Em(fp,vp)),dm(im(Qh),Om(fp,vp)),dm(im(Jh),Bm(bp)),dm(im(em),Nm(yp)),dm(im(Kh.concat(Gh)),((e,t,o)=>Dl(e.element).bind((n=>o.execute(e,t,n)))))]),_p=w([dm(im(Kh),wm)]);var xp=gm(mp,Ss.init,wp,_p,(()=>M.some(pp)));const Cp=[or("selector"),yr("execute",ym),yr("moveOnTab",!1)],kp=(e,t,o)=>o.focusManager.get(e).bind((n=>o.execute(e,t,n))),Sp=(e,t,o)=>{pa(e.element,t.selector).each((o=>{t.focusManager.set(e,o)}))},Tp=(e,t,o)=>Qm(e,o.selector,t,-1),Ep=(e,t,o)=>Qm(e,o.selector,t,1),Op=w([dm(im(Jh),Rm(Tp)),dm(im(em),Rm(Ep)),dm(sm([am,im(qh)]),((e,t,o,n)=>o.moveOnTab?Rm(Tp)(e,t,o,n):M.none())),dm(sm([cm,im(qh)]),((e,t,o,n)=>o.moveOnTab?Rm(Ep)(e,t,o,n):M.none())),dm(im(Gh),kp),dm(im(Kh),kp)]),Mp=w([dm(im(Kh),wm)]);var Ap=gm(Cp,Ss.init,Op,Mp,(()=>M.some(Sp)));const Bp=[Na("onSpace"),Na("onEnter"),Na("onShiftEnter"),Na("onLeft"),Na("onRight"),Na("onTab"),Na("onShiftTab"),Na("onUp"),Na("onDown"),Na("onEscape"),yr("stopSpaceKeyup",!1),ur("focusIn")];var Np=gm(Bp,Ss.init,((e,t,o)=>[dm(im(Kh),o.onSpace),dm(sm([cm,im(Gh)]),o.onEnter),dm(sm([am,im(Gh)]),o.onShiftEnter),dm(sm([am,im(qh)]),o.onShiftTab),dm(sm([cm,im(qh)]),o.onTab),dm(im(Jh),o.onUp),dm(im(em),o.onDown),dm(im(Xh),o.onLeft),dm(im(Qh),o.onRight),dm(im(Kh),o.onSpace)]),((e,t,o)=>[...o.stopSpaceKeyup?[dm(im(Kh),wm)]:[],dm(im(Yh),o.onEscape)]),(e=>e.focusIn));const Rp=vm.schema(),Vp=bm.schema(),Dp=ap.schema(),Pp=Km.schema(),Ip=xp.schema(),Fp=Cm.schema(),Lp=Ap.schema(),zp=Np.schema(),Hp=El({branchKey:"mode",branches:Object.freeze({__proto__:null,acyclic:Rp,cyclic:Vp,flow:Dp,flatgrid:Pp,matrix:Ip,execution:Fp,menu:Lp,special:zp}),name:"keying",active:{events:(e,t)=>e.handler.toEvents(e,t)},apis:{focusIn:(e,t,o)=>{t.sendFocusIn(t).fold((()=>{e.getSystem().triggerFocus(e.element,e.element)}),(n=>{n(e,t,o)}))},setGridSize:(e,t,o,n,r)=>{(e=>ye(e,"setGridSize"))(o)?o.setGridSize(n,r):console.error("Layout does not support setGridSize")}},state:Sm}),Zp=(e,t)=>{Pl((()=>{((e,t,o)=>{const n=e.components();(e=>{z(e.components(),(e=>Ho(e.element))),zo(e.element),e.syncComponents()})(e);const r=o(t),i=X(n,r);z(i,(t=>{kd(t),e.getSystem().removeFromWorld(t)})),z(r,(t=>{Cd(t)?Od(e,t):(e.getSystem().addToWorld(t),Od(e,t),yt(e.element)&&Sd(t))})),e.syncComponents()})(e,t,(()=>L(t,e.getSystem().build)))}),e.element)},jp=(e,t)=>{Pl((()=>{((o,n,r)=>{const i=o.components(),s=G(n,(e=>Cs(e).toArray()));z(i,(e=>{D(s,e)||Ed(e)}));const a=((e,t,o)=>Ys(e,t,((t,n)=>Ks(e,n,t,o))))(e.element,t,e.getSystem().buildOrPatch),l=X(i,a);z(l,(e=>{Cd(e)&&Ed(e)})),z(a,(e=>{Cd(e)||Td(o,e)})),o.syncComponents()})(e,t)}),e.element)},Up=(e,t,o,n)=>{Ed(t);const r=Ks(e.element,o,n,e.getSystem().buildOrPatch);Td(e,r),e.syncComponents()},$p=(e,t,o)=>{const n=e.getSystem().build(o);Ad(e,n,t)},Wp=(e,t,o,n)=>{Nd(t),$p(e,((e,t)=>((e,t,o)=>{lt(e,o).fold((()=>{Fo(e,t)}),(e=>{Do(e,t)}))})(e,t,o)),n)},qp=(e,t)=>e.components(),Gp=(e,t,o,n,r)=>{const i=qp(e);return M.from(i[n]).map((o=>(r.fold((()=>Nd(o)),(r=>{(t.reuseDom?Up:Wp)(e,o,n,r)})),o)))};var Yp=Object.freeze({__proto__:null,append:(e,t,o,n)=>{$p(e,Fo,n)},prepend:(e,t,o,n)=>{$p(e,Io,n)},remove:(e,t,o,n)=>{const r=qp(e),i=$(r,(e=>Je(n.element,e.element)));i.each(Nd)},replaceAt:Gp,replaceBy:(e,t,o,n,r)=>{const i=qp(e);return W(i,n).bind((o=>Gp(e,t,0,o,r)))},set:(e,t,o,n)=>(t.reuseDom?jp:Zp)(e,n),contents:qp});const Kp=Sl({fields:[kr("reuseDom",!0)],name:"replacing",apis:Yp}),Xp=(e,t)=>{const o=((e,t)=>{const o=Li(t);return Sl({fields:[or("enabled")],name:e,active:{events:w(o)}})})(e,t);return{key:e,value:{config:{},me:o,configAsRaw:w({}),initialConfig:{},state:Ss}}},Jp=(e,t)=>{t.ignore||(Bl(e.element),t.onFocus(e))};var Qp=Object.freeze({__proto__:null,focus:Jp,blur:(e,t)=>{t.ignore||Nl(e.element)},isFocused:e=>Rl(e.element)}),eg=Object.freeze({__proto__:null,exhibit:(e,t)=>{const o=t.ignore?{}:{attributes:{tabindex:"-1"}};return Os(o)},events:e=>Li([Zi(ai(),((t,o)=>{Jp(t,e),o.stop()}))].concat(e.stopMousedown?[Zi(jr(),((e,t)=>{t.event.prevent()}))]:[]))}),tg=[Ba("onFocus"),yr("stopMousedown",!1),yr("ignore",!1)];const og=Sl({fields:tg,name:"focusing",active:eg,apis:Qp}),ng=(e,t,o,n)=>{const r=o.get();o.set(n),((e,t,o)=>{t.toggleClass.each((t=>{o.get()?zs(e.element,t):Hs(e.element,t)}))})(e,t,o),((e,t,o)=>{const n=t.aria;n.update(e,n,o.get())})(e,t,o),r!==n&&t.onToggled(e,n)},rg=(e,t,o)=>{ng(e,t,o,!o.get())},ig=(e,t,o)=>{ng(e,t,o,t.selected)};var sg=Object.freeze({__proto__:null,onLoad:ig,toggle:rg,isOn:(e,t,o)=>o.get(),on:(e,t,o)=>{ng(e,t,o,!0)},off:(e,t,o)=>{ng(e,t,o,!1)},set:ng}),ag=Object.freeze({__proto__:null,exhibit:()=>Os({}),events:(e,t)=>{const o=(n=e,r=t,i=rg,Qi((e=>{i(e,n,r)})));var n,r,i;const s=wl(e,t,ig);return Li(q([e.toggleOnExecute?[o]:[],[s]]))}});const lg=(e,t,o)=>{Ct(e.element,"aria-expanded",o)};var cg=[yr("selected",!1),ur("toggleClass"),yr("toggleOnExecute",!0),Ba("onToggled"),wr("aria",{mode:"none"},Xn("mode",{pressed:[yr("syncWithExpanded",!1),Da("update",((e,t,o)=>{Ct(e.element,"aria-pressed",o),t.syncWithExpanded&&lg(e,0,o)}))],checked:[Da("update",((e,t,o)=>{Ct(e.element,"aria-checked",o)}))],expanded:[Da("update",lg)],selected:[Da("update",((e,t,o)=>{Ct(e.element,"aria-selected",o)}))],none:[Da("update",v)]}))];const dg=Sl({fields:cg,name:"toggling",active:ag,apis:sg,state:(!1,{init:()=>{const e=Or(false);return{get:()=>e.get(),set:t=>e.set(t),clear:()=>e.set(false),readState:()=>e.get()}}})});const ug=()=>{const e=(e,t)=>{t.stop(),Di(e)};return[Zi(ei(),e),Zi(mi(),e),qi(Lr()),qi(jr())]},hg=e=>Li(q([e.map((e=>Qi(((t,o)=>{e(t),o.stop()})))).toArray(),ug()])),mg="alloy.item-hover",pg="alloy.item-focus",gg="alloy.item-toggled",fg=e=>{(Dl(e.element).isNone()||og.isFocused(e))&&(og.isFocused(e)||og.focus(e),Vi(e,mg,{item:e}))},vg=e=>{Vi(e,pg,{item:e})},bg=w(mg),yg=w(pg),wg=w(gg),_g=e=>e.toggling.map((e=>e.exclusive?"menuitemradio":"menuitemcheckbox")).getOr("menuitem"),xg=[or("data"),or("components"),or("dom"),yr("hasSubmenu",!1),ur("toggling"),bu("itemBehaviours",[dg,og,Hp,pu]),yr("ignoreFocus",!1),yr("domModification",{}),Da("builder",(e=>({dom:e.dom,domModification:{...e.domModification,attributes:{role:_g(e),...e.domModification.attributes,"aria-haspopup":e.hasSubmenu,...e.hasSubmenu?{"aria-expanded":!1}:{}}},behaviours:yu(e.itemBehaviours,[e.toggling.fold(dg.revoke,(e=>dg.config((e=>({aria:{mode:"checked"},...me(e,((e,t)=>"exclusive"!==t)),onToggled:(t,o)=>{p(e.onToggled)&&e.onToggled(t,o),((e,t)=>{Vi(e,gg,{item:e,state:t})})(t,o)}}))(e)))),og.config({ignore:e.ignoreFocus,stopMousedown:e.ignoreFocus,onFocus:e=>{vg(e)}}),Hp.config({mode:"execution"}),pu.config({store:{mode:"memory",initialValue:e.data}}),Xp("item-type-events",[...ug(),Zi(qr(),fg),Zi(hi(),og.focus)])]),components:e.components,eventOrder:e.eventOrder}))),yr("eventOrder",{})],Cg=[or("dom"),or("components"),Da("builder",(e=>({dom:e.dom,components:e.components,events:Li([Gi(hi())])})))],kg=w("item-widget"),Sg=w([Zu({name:"widget",overrides:e=>({behaviours:Cl([pu.config({store:{mode:"manual",getValue:t=>e.data,setValue:v}})])})})]),Tg=[or("uid"),or("data"),or("components"),or("dom"),yr("autofocus",!1),yr("ignoreFocus",!1),bu("widgetBehaviours",[pu,og,Hp]),yr("domModification",{}),ch(Sg()),Da("builder",(e=>{const t=eh(kg(),e,Sg()),o=th(kg(),e,t.internals()),n=t=>oh(t,e,"widget").map((e=>(Hp.focusIn(e),e))),r=(t,o)=>bh(o.event.target)?M.none():e.autofocus?(o.setSource(t.element),M.none()):M.none();return{dom:e.dom,components:o,domModification:e.domModification,events:Li([Qi(((e,t)=>{n(e).each((e=>{t.stop()}))})),Zi(qr(),fg),Zi(hi(),((t,o)=>{e.autofocus?n(t):og.focus(t)}))]),behaviours:yu(e.widgetBehaviours,[pu.config({store:{mode:"memory",initialValue:e.data}}),og.config({ignore:e.ignoreFocus,onFocus:e=>{vg(e)}}),Hp.config({mode:"special",focusIn:e.autofocus?e=>{n(e)}:Ol(),onLeft:r,onRight:r,onEscape:(t,o)=>og.isFocused(t)||e.autofocus?e.autofocus?(o.setSource(t.element),M.none()):M.none():(og.focus(t),M.some(!0))})])}}))],Eg=Xn("type",{widget:Tg,item:xg,separator:Cg}),Og=w([$u({factory:{sketch:e=>{const t=Yn("menu.spec item",Eg,e);return t.builder(t)}},name:"items",unit:"item",defaults:(e,t)=>be(t,"uid")?t:{...t,uid:gs("item")},overrides:(e,t)=>({type:t.type,ignoreFocus:e.fakeFocus,domModification:{classes:[e.markers.item]}})})]),Mg=w([or("value"),or("items"),or("dom"),or("components"),yr("eventOrder",{}),gu("menuBehaviours",[$h,pu,_h,Hp]),wr("movement",{mode:"menu",moveOnTab:!0},Xn("mode",{grid:[Ia(),Da("config",((e,t)=>({mode:"flatgrid",selector:"."+e.markers.item,initSize:{numColumns:t.initSize.numColumns,numRows:t.initSize.numRows},focusManager:e.focusManager})))],matrix:[Da("config",((e,t)=>({mode:"matrix",selectors:{row:t.rowSelector,cell:"."+e.markers.item},previousSelector:t.previousSelector,focusManager:e.focusManager}))),or("rowSelector"),yr("previousSelector",M.none)],menu:[yr("moveOnTab",!0),Da("config",((e,t)=>({mode:"menu",selector:"."+e.markers.item,moveOnTab:t.moveOnTab,focusManager:e.focusManager})))]})),nr("markers",Ta()),yr("fakeFocus",!1),yr("focusManager",hm()),Ba("onHighlight"),Ba("onDehighlight")]),Ag=w("alloy.menu-focus"),Bg=vh({name:"Menu",configFields:Mg(),partFields:Og(),factory:(e,t,o,n)=>({uid:e.uid,dom:e.dom,markers:e.markers,behaviours:vu(e.menuBehaviours,[$h.config({highlightClass:e.markers.selectedItem,itemClass:e.markers.item,onHighlight:e.onHighlight,onDehighlight:e.onDehighlight}),pu.config({store:{mode:"memory",initialValue:e.value}}),_h.config({find:M.some}),Hp.config(e.movement.config(e,e.movement))]),events:Li([Zi(yg(),((e,t)=>{const o=t.event;e.getSystem().getByDom(o.target).each((o=>{$h.highlight(e,o),t.stop(),Vi(e,Ag(),{menu:e,item:o})}))})),Zi(bg(),((e,t)=>{const o=t.event.item;$h.highlight(e,o)})),Zi(wg(),((e,t)=>{const{item:o,state:n}=t.event;n&&"menuitemradio"===St(o.element,"role")&&((e,t)=>{const o=Gc(e.element,'[role="menuitemradio"][aria-checked="true"]');z(o,(o=>{Je(o,t.element)||e.getSystem().getByDom(o).each((e=>{dg.off(e)}))}))})(e,o)}))]),components:t,eventOrder:e.eventOrder,domModification:{attributes:{role:"menu"}}})}),Ng=(e,t,o,n)=>ve(o,n).bind((n=>ve(e,n).bind((n=>{const r=Ng(e,t,o,n);return M.some([n].concat(r))})))).getOr([]),Rg=e=>"prepared"===e.type?M.some(e.menu):M.none(),Vg=()=>{const e=Or({}),t=Or({}),o=Or({}),n=Ql(),r=Or({}),i=e=>s(e).bind(Rg),s=e=>ve(t.get(),e),a=t=>ve(e.get(),t);return{setMenuBuilt:(e,o)=>{t.set({...t.get(),[e]:{type:"prepared",menu:o}})},setContents:(i,s,a,l)=>{n.set(i),e.set(a),t.set(s),r.set(l);const c=((e,t)=>{const o={};le(e,((e,t)=>{z(e,(e=>{o[e]=t}))}));const n=t,r=de(t,((e,t)=>({k:e,v:t}))),i=ce(r,((e,t)=>[t].concat(Ng(o,n,r,t))));return ce(o,(e=>ve(i,e).getOr([e])))})(l,a);o.set(c)},expand:t=>ve(e.get(),t).map((e=>{const n=ve(o.get(),t).getOr([]);return[e].concat(n)})),refresh:e=>ve(o.get(),e),collapse:e=>ve(o.get(),e).bind((e=>e.length>1?M.some(e.slice(1)):M.none())),lookupMenu:s,lookupItem:a,otherMenus:e=>{const t=r.get();return X(se(t),e)},getPrimary:()=>n.get().bind(i),getMenus:()=>t.get(),clear:()=>{e.set({}),t.set({}),o.set({}),n.clear()},isClear:()=>n.get().isNone(),getTriggeringPath:(t,r)=>{const s=Z(a(t).toArray(),(e=>i(e).isSome()));return ve(o.get(),t).bind((t=>{const o=K(s.concat(t));return(e=>{const t=[];for(let o=0;o((t,o,n)=>i(t).bind((r=>(t=>ge(e.get(),((e,o)=>e===t)))(t).bind((e=>o(e).map((e=>({triggeredMenu:r,triggeringItem:e,triggeringPath:n}))))))))(t,r,o.slice(0,s+1)).fold((()=>we(n.get(),t)?[]:[M.none()]),(e=>[M.some(e)])))))}))}}},Dg=Rg,Pg=ls("tiered-menu-item-highlight"),Ig=ls("tiered-menu-item-dehighlight");var Fg;!function(e){e[e.HighlightMenuAndItem=0]="HighlightMenuAndItem",e[e.HighlightJustMenu=1]="HighlightJustMenu",e[e.HighlightNone=2]="HighlightNone"}(Fg||(Fg={}));const Lg=w("collapse-item"),zg=fh({name:"TieredMenu",configFields:[Va("onExecute"),Va("onEscape"),Ra("onOpenMenu"),Ra("onOpenSubmenu"),Ba("onRepositionMenu"),Ba("onCollapseMenu"),yr("highlightOnOpen",Fg.HighlightMenuAndItem),lr("data",[or("primary"),or("menus"),or("expansions")]),yr("fakeFocus",!1),Ba("onHighlightItem"),Ba("onDehighlightItem"),Ba("onHover"),Oa(),or("dom"),yr("navigateOnHover",!0),yr("stayInDom",!1),gu("tmenuBehaviours",[Hp,$h,_h,Kp]),yr("eventOrder",{})],apis:{collapseMenu:(e,t)=>{e.collapseMenu(t)},highlightPrimary:(e,t)=>{e.highlightPrimary(t)},repositionMenus:(e,t)=>{e.repositionMenus(t)}},factory:(e,t)=>{const o=Ql(),n=Vg(),r=e=>pu.getValue(e).value,i=t=>ce(e.data.menus,((e,t)=>G(e.items,(e=>"separator"===e.type?[]:[e.data.value])))),s=$h.highlight,a=(t,o)=>{s(t,o),$h.getHighlighted(o).orThunk((()=>$h.getFirst(o))).each((n=>{e.fakeFocus?$h.highlight(o,n):Pi(t,n.element,hi())}))},l=(e,t)=>_e(L(t,(t=>e.lookupMenu(t).bind((e=>"prepared"===e.type?M.some(e.menu):M.none()))))),c=(t,o,n)=>{const r=l(o,o.otherMenus(n));z(r,(o=>{Us(o.element,[e.markers.backgroundMenu]),e.stayInDom||Kp.remove(t,o)}))},d=(t,n)=>{const i=(t=>o.get().getOrThunk((()=>{const n={},i=Gc(t.element,`.${e.markers.item}`),s=Z(i,(e=>"true"===St(e,"aria-haspopup")));return z(s,(e=>{t.getSystem().getByDom(e).each((e=>{const t=r(e);n[t]=e}))})),o.set(n),n})))(t);le(i,((e,t)=>{const o=D(n,t);Ct(e.element,"aria-expanded",o)}))},u=(t,o,n)=>M.from(n[0]).bind((r=>o.lookupMenu(r).bind((r=>{if("notbuilt"===r.type)return M.none();{const i=r.menu,s=l(o,n.slice(1));return z(s,(t=>{zs(t.element,e.markers.backgroundMenu)})),yt(i.element)||Kp.append(t,sa(i)),Us(i.element,[e.markers.backgroundMenu]),a(t,i),c(t,o,n),M.some(i)}}))));let h;!function(e){e[e.HighlightSubmenu=0]="HighlightSubmenu",e[e.HighlightParent=1]="HighlightParent"}(h||(h={}));const m=(t,o,i=h.HighlightSubmenu)=>{if(o.hasConfigured(Dh)&&Dh.isDisabled(o))return M.some(o);{const s=r(o);return n.expand(s).bind((r=>(d(t,r),M.from(r[0]).bind((s=>n.lookupMenu(s).bind((a=>{const l=((e,t,o)=>{if("notbuilt"===o.type){const r=e.getSystem().build(o.nbMenu());return n.setMenuBuilt(t,r),r}return o.menu})(t,s,a);return yt(l.element)||Kp.append(t,sa(l)),e.onOpenSubmenu(t,o,l,K(r)),i===h.HighlightSubmenu?($h.highlightFirst(l),u(t,n,r)):($h.dehighlightAll(l),M.some(o))})))))))}},p=(t,o)=>{const i=r(o);return n.collapse(i).bind((r=>(d(t,r),u(t,n,r).map((n=>(e.onCollapseMenu(t,o,n),n))))))},g=t=>(o,n)=>ga(n.getSource(),`.${e.markers.item}`).bind((e=>o.getSystem().getByDom(e).toOptional().bind((e=>t(o,e).map(O))))),f=Li([Zi(Ag(),((e,t)=>{const o=t.event.item;n.lookupItem(r(o)).each((()=>{const o=t.event.menu;$h.highlight(e,o);const i=r(t.event.item);n.refresh(i).each((t=>c(e,n,t)))}))})),Qi(((t,o)=>{const n=o.event.target;t.getSystem().getByDom(n).each((o=>{0===r(o).indexOf("collapse-item")&&p(t,o),m(t,o,h.HighlightSubmenu).fold((()=>{e.onExecute(t,o)}),v)}))})),Ki(((t,o)=>{(t=>{const o=((t,o,n)=>ce(n,((n,r)=>{const i=()=>Bg.sketch({...n,value:r,markers:e.markers,fakeFocus:e.fakeFocus,onHighlight:(e,t)=>{Vi(e,Pg,{menuComp:e,itemComp:t})},onDehighlight:(e,t)=>{Vi(e,Ig,{menuComp:e,itemComp:t})},focusManager:e.fakeFocus?mm():hm()});return r===o?{type:"prepared",menu:t.getSystem().build(i())}:{type:"notbuilt",nbMenu:i}})))(t,e.data.primary,e.data.menus),r=i();return n.setContents(e.data.primary,o,e.data.expansions,r),n.getPrimary()})(t).each((o=>{Kp.append(t,sa(o)),e.onOpenMenu(t,o),e.highlightOnOpen===Fg.HighlightMenuAndItem?a(t,o):e.highlightOnOpen===Fg.HighlightJustMenu&&s(t,o)}))})),Zi(Pg,((t,o)=>{e.onHighlightItem(t,o.event.menuComp,o.event.itemComp)})),Zi(Ig,((t,o)=>{e.onDehighlightItem(t,o.event.menuComp,o.event.itemComp)})),...e.navigateOnHover?[Zi(bg(),((t,o)=>{const i=o.event.item;((e,t)=>{const o=r(t);n.refresh(o).bind((t=>(d(e,t),u(e,n,t))))})(t,i),m(t,i,h.HighlightParent),e.onHover(t,i)}))]:[]]),b=e=>$h.getHighlighted(e).bind($h.getHighlighted),y={collapseMenu:e=>{b(e).each((t=>{p(e,t)}))},highlightPrimary:e=>{n.getPrimary().each((t=>{a(e,t)}))},repositionMenus:t=>{const o=n.getPrimary().bind((e=>b(t).bind((e=>{const t=r(e),o=fe(n.getMenus()),i=_e(L(o,Dg));return n.getTriggeringPath(t,(e=>((e,t,o)=>ie(t,(e=>{if(!e.getSystem().isConnected())return M.none();const t=$h.getCandidates(e);return $(t,(e=>r(e)===o))})))(0,i,e)))})).map((t=>({primary:e,triggeringPath:t})))));o.fold((()=>{(e=>M.from(e.components()[0]).filter((e=>"menu"===St(e.element,"role"))))(t).each((o=>{e.onRepositionMenu(t,o,[])}))}),(({primary:o,triggeringPath:n})=>{e.onRepositionMenu(t,o,n)}))}};return{uid:e.uid,dom:e.dom,markers:e.markers,behaviours:vu(e.tmenuBehaviours,[Hp.config({mode:"special",onRight:g(((e,t)=>bh(t.element)?M.none():m(e,t,h.HighlightSubmenu))),onLeft:g(((e,t)=>bh(t.element)?M.none():p(e,t))),onEscape:g(((t,o)=>p(t,o).orThunk((()=>e.onEscape(t,o).map((()=>t)))))),focusIn:(e,t)=>{n.getPrimary().each((t=>{Pi(e,t.element,hi())}))}}),$h.config({highlightClass:e.markers.selectedMenu,itemClass:e.markers.menu}),_h.config({find:e=>$h.getHighlighted(e)}),Kp.config({})]),eventOrder:e.eventOrder,apis:y,events:f}},extraApis:{tieredData:(e,t,o)=>({primary:e,menus:t,expansions:o}),singleData:(e,t)=>({primary:e,menus:Ar(e,t),expansions:{}}),collapseItem:e=>({value:ls(Lg()),meta:{text:e}})}}),Hg=fh({name:"InlineView",configFields:[or("lazySink"),Ba("onShow"),Ba("onHide"),fr("onEscape"),gu("inlineBehaviours",[Gd,pu,Ml]),br("fireDismissalEventInstead",[yr("event",ki())]),br("fireRepositionEventInstead",[yr("event",Si())]),yr("getRelated",M.none),yr("isExtraPart",E),yr("eventOrder",M.none)],factory:(e,t)=>{const o=(t,o,n,r)=>{const i=e.lazySink(t).getOrDie();Gd.openWhileCloaked(t,o,(()=>xd.positionWithinBounds(i,t,n,r()))),pu.setValue(t,M.some({mode:"position",config:n,getBounds:r}))},n=(t,o,n,r)=>{const i=((e,t,o,n,r)=>{const i=()=>e.lazySink(t),s="horizontal"===n.type?{layouts:{onLtr:()=>fl(),onRtl:()=>vl()}}:{},a=e=>(e=>2===e.length)(e)?s:{};return zg.sketch({dom:{tag:"div"},data:n.data,markers:n.menu.markers,highlightOnOpen:n.menu.highlightOnOpen,fakeFocus:n.menu.fakeFocus,onEscape:()=>(Gd.close(t),e.onEscape.map((e=>e(t))),M.some(!0)),onExecute:()=>M.some(!0),onOpenMenu:(e,t)=>{xd.positionWithinBounds(i().getOrDie(),t,o,r())},onOpenSubmenu:(e,t,o,n)=>{const r=i().getOrDie();xd.position(r,o,{anchor:{type:"submenu",item:t,...a(n)}})},onRepositionMenu:(e,t,n)=>{const s=i().getOrDie();xd.positionWithinBounds(s,t,o,r()),z(n,(e=>{const t=a(e.triggeringPath);xd.position(s,e.triggeredMenu,{anchor:{type:"submenu",item:e.triggeringItem,...t}})}))}})})(e,t,o,n,r);Gd.open(t,i),pu.setValue(t,M.some({mode:"menu",menu:i}))},r=t=>{Gd.isOpen(t)&&pu.getValue(t).each((o=>{switch(o.mode){case"menu":Gd.getState(t).each(zg.repositionMenus);break;case"position":const n=e.lazySink(t).getOrDie();xd.positionWithinBounds(n,t,o.config,o.getBounds())}}))},i={setContent:(e,t)=>{Gd.setContent(e,t)},showAt:(e,t,n)=>{const r=M.none;o(e,t,n,r)},showWithinBounds:o,showMenuAt:(e,t,o)=>{n(e,t,o,M.none)},showMenuWithinBounds:n,hide:e=>{Gd.isOpen(e)&&(pu.setValue(e,M.none()),Gd.close(e))},getContent:e=>Gd.getState(e),reposition:r,isOpen:Gd.isOpen};return{uid:e.uid,dom:e.dom,behaviours:vu(e.inlineBehaviours,[Gd.config({isPartOf:(t,o,n)=>ba(o,n)||((t,o)=>e.getRelated(t).exists((e=>ba(e,o))))(t,n),getAttachPoint:t=>e.lazySink(t).getOrDie(),onOpen:t=>{e.onShow(t)},onClose:t=>{e.onHide(t)}}),pu.config({store:{mode:"memory",initialValue:M.none()}}),Ml.config({channels:{...Qd({isExtraPart:t.isExtraPart,...e.fireDismissalEventInstead.map((e=>({fireEventInstead:{event:e.event}}))).getOr({})}),...tu({...e.fireRepositionEventInstead.map((e=>({fireEventInstead:{event:e.event}}))).getOr({}),doReposition:r})}})]),eventOrder:e.eventOrder,apis:i}},apis:{showAt:(e,t,o,n)=>{e.showAt(t,o,n)},showWithinBounds:(e,t,o,n,r)=>{e.showWithinBounds(t,o,n,r)},showMenuAt:(e,t,o,n)=>{e.showMenuAt(t,o,n)},showMenuWithinBounds:(e,t,o,n,r)=>{e.showMenuWithinBounds(t,o,n,r)},hide:(e,t)=>{e.hide(t)},isOpen:(e,t)=>e.isOpen(t),getContent:(e,t)=>e.getContent(t),setContent:(e,t,o)=>{e.setContent(t,o)},reposition:(e,t)=>{e.reposition(t)}}});var Zg=window.mailpoetTinymce.util.Tools.resolve("window.mailpoetTinymce.util.Delay");const jg=fh({name:"Button",factory:e=>{const t=hg(e.action),o=e.dom.tag,n=t=>ve(e.dom,"attributes").bind((e=>ve(e,t)));return{uid:e.uid,dom:e.dom,components:e.components,events:t,behaviours:yu(e.buttonBehaviours,[og.config({}),Hp.config({mode:"execution",useSpace:!0,useEnter:!0})]),domModification:{attributes:"button"===o?{type:n("type").getOr("button"),...n("role").map((e=>({role:e}))).getOr({})}:{role:e.role.getOr(n("role").getOr("button"))}},eventOrder:e.eventOrder}},configFields:[yr("uid",void 0),or("dom"),yr("components",[]),bu("buttonBehaviours",[og,Hp]),ur("action"),ur("role"),yr("eventOrder",{})]}),Ug=e=>{const t=Ve(e),o=at(t),n=(e=>{const t=void 0!==e.dom.attributes?e.dom.attributes:[];return U(t,((e,t)=>"class"===t.name?e:{...e,[t.name]:t.value}),{})})(t),r=(e=>Array.prototype.slice.call(e.dom.classList,0))(t),i=0===o.length?{}:{innerHtml:es(t)};return{tag:Ze(t),classes:r,attributes:n,...i}},$g=e=>{const t=(e=>void 0!==e.uid)(e)&&ye(e,"uid")?e.uid:gs("memento");return{get:e=>e.getSystem().getByUid(t).getOrDie(),getOpt:e=>e.getSystem().getByUid(t).toOptional(),asSpec:()=>({...e,uid:t})}};function Wg(e){return Wg="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Wg(e)}function qg(e,t){return qg=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},qg(e,t)}function Gg(e,t,o){return Gg=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct:function(e,t,o){var n=[null];n.push.apply(n,t);var r=new(Function.bind.apply(e,n));return o&&qg(r,o.prototype),r},Gg.apply(null,arguments)}function Yg(e){return function(e){if(Array.isArray(e))return Kg(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return Kg(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?Kg(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Kg(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,n=new Array(t);o1?o-1:0),r=1;r/gm),If=nf(/^data-[\-\w.\u00B7-\uFFFF]/),Ff=nf(/^aria-[\-\w]+$/),Lf=nf(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),zf=nf(/^(?:\w+script|data):/i),Hf=nf(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Zf=nf(/^html$/i),jf=function(){return"undefined"==typeof window?null:window},Uf=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:jf(),o=function(t){return e(t)};if(o.version="2.3.8",o.removed=[],!t||!t.document||9!==t.document.nodeType)return o.isSupported=!1,o;var n=t.document,r=t.document,i=t.DocumentFragment,s=t.HTMLTemplateElement,a=t.Node,l=t.Element,c=t.NodeFilter,d=t.NamedNodeMap,u=void 0===d?t.NamedNodeMap||t.MozNamedAttrMap:d,h=t.HTMLFormElement,m=t.DOMParser,p=t.trustedTypes,g=l.prototype,f=Cf(g,"cloneNode"),v=Cf(g,"nextSibling"),b=Cf(g,"childNodes"),y=Cf(g,"parentNode");if("function"==typeof s){var w=r.createElement("template");w.content&&w.content.ownerDocument&&(r=w.content.ownerDocument)}var _=function(e,t){if("object"!==Wg(e)||"function"!=typeof e.createPolicy)return null;var o=null,n="data-tt-policy-suffix";t.currentScript&&t.currentScript.hasAttribute(n)&&(o=t.currentScript.getAttribute(n));var r="dompurify"+(o?"#"+o:"");try{return e.createPolicy(r,{createHTML:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(p,n),x=_?_.createHTML(""):"",C=r,k=C.implementation,S=C.createNodeIterator,T=C.createDocumentFragment,E=C.getElementsByTagName,O=n.importNode,M={};try{M=xf(r).documentMode?r.documentMode:{}}catch(e){}var A={};o.isSupported="function"==typeof y&&k&&void 0!==k.createHTMLDocument&&9!==M;var B,N,R=Df,V=Pf,D=If,P=Ff,I=zf,F=Hf,L=Lf,z=null,H=_f({},[].concat(Yg(kf),Yg(Sf),Yg(Tf),Yg(Of),Yg(Af))),Z=null,j=_f({},[].concat(Yg(Bf),Yg(Nf),Yg(Rf),Yg(Vf))),U=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),$=null,W=null,q=!0,G=!0,Y=!1,K=!1,X=!1,J=!1,Q=!1,ee=!1,te=!1,oe=!1,ne=!0,re=!0,ie=!1,se={},ae=null,le=_f({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),ce=null,de=_f({},["audio","video","img","source","image","track"]),ue=null,he=_f({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),me="http://www.w3.org/1998/Math/MathML",pe="http://www.w3.org/2000/svg",ge="http://www.w3.org/1999/xhtml",fe=ge,ve=!1,be=["application/xhtml+xml","text/html"],ye=null,we=r.createElement("form"),_e=function(e){return e instanceof RegExp||e instanceof Function},xe=function(e){ye&&ye===e||(e&&"object"===Wg(e)||(e={}),e=xf(e),z="ALLOWED_TAGS"in e?_f({},e.ALLOWED_TAGS):H,Z="ALLOWED_ATTR"in e?_f({},e.ALLOWED_ATTR):j,ue="ADD_URI_SAFE_ATTR"in e?_f(xf(he),e.ADD_URI_SAFE_ATTR):he,ce="ADD_DATA_URI_TAGS"in e?_f(xf(de),e.ADD_DATA_URI_TAGS):de,ae="FORBID_CONTENTS"in e?_f({},e.FORBID_CONTENTS):le,$="FORBID_TAGS"in e?_f({},e.FORBID_TAGS):{},W="FORBID_ATTR"in e?_f({},e.FORBID_ATTR):{},se="USE_PROFILES"in e&&e.USE_PROFILES,q=!1!==e.ALLOW_ARIA_ATTR,G=!1!==e.ALLOW_DATA_ATTR,Y=e.ALLOW_UNKNOWN_PROTOCOLS||!1,K=e.SAFE_FOR_TEMPLATES||!1,X=e.WHOLE_DOCUMENT||!1,ee=e.RETURN_DOM||!1,te=e.RETURN_DOM_FRAGMENT||!1,oe=e.RETURN_TRUSTED_TYPE||!1,Q=e.FORCE_BODY||!1,ne=!1!==e.SANITIZE_DOM,re=!1!==e.KEEP_CONTENT,ie=e.IN_PLACE||!1,L=e.ALLOWED_URI_REGEXP||L,fe=e.NAMESPACE||ge,e.CUSTOM_ELEMENT_HANDLING&&_e(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(U.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&_e(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(U.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(U.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),B=B=-1===be.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,N="application/xhtml+xml"===B?function(e){return e}:mf,K&&(G=!1),te&&(ee=!0),se&&(z=_f({},Yg(Af)),Z=[],!0===se.html&&(_f(z,kf),_f(Z,Bf)),!0===se.svg&&(_f(z,Sf),_f(Z,Nf),_f(Z,Vf)),!0===se.svgFilters&&(_f(z,Tf),_f(Z,Nf),_f(Z,Vf)),!0===se.mathMl&&(_f(z,Of),_f(Z,Rf),_f(Z,Vf))),e.ADD_TAGS&&(z===H&&(z=xf(z)),_f(z,e.ADD_TAGS)),e.ADD_ATTR&&(Z===j&&(Z=xf(Z)),_f(Z,e.ADD_ATTR)),e.ADD_URI_SAFE_ATTR&&_f(ue,e.ADD_URI_SAFE_ATTR),e.FORBID_CONTENTS&&(ae===le&&(ae=xf(ae)),_f(ae,e.FORBID_CONTENTS)),re&&(z["#text"]=!0),X&&_f(z,["html","head","body"]),z.table&&(_f(z,["tbody"]),delete $.tbody),of&&of(e),ye=e)},Ce=_f({},["mi","mo","mn","ms","mtext"]),ke=_f({},["foreignobject","desc","title","annotation-xml"]),Se=_f({},["title","style","font","a","script"]),Te=_f({},Sf);_f(Te,Tf),_f(Te,Ef);var Ee=_f({},Of);_f(Ee,Mf);var Oe=function(e){hf(o.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=x}catch(t){e.remove()}}},Me=function(e,t){try{hf(o.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){hf(o.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!Z[e])if(ee||te)try{Oe(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Ae=function(e){var t,o;if(Q)e=" "+e;else{var n=pf(e,/^[\r\n\t ]+/);o=n&&n[0]}"application/xhtml+xml"===B&&(e=''+e+"");var i=_?_.createHTML(e):e;if(fe===ge)try{t=(new m).parseFromString(i,B)}catch(e){}if(!t||!t.documentElement){t=k.createDocument(fe,"template",null);try{t.documentElement.innerHTML=ve?"":i}catch(e){}}var s=t.body||t.documentElement;return e&&o&&s.insertBefore(r.createTextNode(o),s.childNodes[0]||null),fe===ge?E.call(t,X?"html":"body")[0]:X?t.documentElement:s},Be=function(e){return S.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT,null,!1)},Ne=function(e){return"object"===Wg(a)?e instanceof a:e&&"object"===Wg(e)&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},Re=function(e,t,n){A[e]&&df(A[e],(function(e){e.call(o,t,n,ye)}))},Ve=function(e){var t,n;if(Re("beforeSanitizeElements",e,null),(n=e)instanceof h&&("string"!=typeof n.nodeName||"string"!=typeof n.textContent||"function"!=typeof n.removeChild||!(n.attributes instanceof u)||"function"!=typeof n.removeAttribute||"function"!=typeof n.setAttribute||"string"!=typeof n.namespaceURI||"function"!=typeof n.insertBefore))return Oe(e),!0;if(bf(/[\u0080-\uFFFF]/,e.nodeName))return Oe(e),!0;var r=N(e.nodeName);if(Re("uponSanitizeElement",e,{tagName:r,allowedTags:z}),e.hasChildNodes()&&!Ne(e.firstElementChild)&&(!Ne(e.content)||!Ne(e.content.firstElementChild))&&bf(/<[/\w]/g,e.innerHTML)&&bf(/<[/\w]/g,e.textContent))return Oe(e),!0;if("select"===r&&bf(/=0;--a)i.insertBefore(f(s[a],!0),v(e))}return Oe(e),!0}return e instanceof l&&!function(e){var t=y(e);t&&t.tagName||(t={namespaceURI:ge,tagName:"template"});var o=mf(e.tagName),n=mf(t.tagName);return e.namespaceURI===pe?t.namespaceURI===ge?"svg"===o:t.namespaceURI===me?"svg"===o&&("annotation-xml"===n||Ce[n]):Boolean(Te[o]):e.namespaceURI===me?t.namespaceURI===ge?"math"===o:t.namespaceURI===pe?"math"===o&&ke[n]:Boolean(Ee[o]):e.namespaceURI===ge&&!(t.namespaceURI===pe&&!ke[n])&&!(t.namespaceURI===me&&!Ce[n])&&!Ee[o]&&(Se[o]||!Te[o])}(e)?(Oe(e),!0):"noscript"!==r&&"noembed"!==r||!bf(/<\/no(script|embed)/i,e.innerHTML)?(K&&3===e.nodeType&&(t=e.textContent,t=gf(t,R," "),t=gf(t,V," "),e.textContent!==t&&(hf(o.removed,{element:e.cloneNode()}),e.textContent=t)),Re("afterSanitizeElements",e,null),!1):(Oe(e),!0)},De=function(e,t,o){if(ne&&("id"===t||"name"===t)&&(o in r||o in we))return!1;if(G&&!W[t]&&bf(D,t));else if(q&&bf(P,t));else if(!Z[t]||W[t]){if(!(Pe(e)&&(U.tagNameCheck instanceof RegExp&&bf(U.tagNameCheck,e)||U.tagNameCheck instanceof Function&&U.tagNameCheck(e))&&(U.attributeNameCheck instanceof RegExp&&bf(U.attributeNameCheck,t)||U.attributeNameCheck instanceof Function&&U.attributeNameCheck(t))||"is"===t&&U.allowCustomizedBuiltInElements&&(U.tagNameCheck instanceof RegExp&&bf(U.tagNameCheck,o)||U.tagNameCheck instanceof Function&&U.tagNameCheck(o))))return!1}else if(ue[t]);else if(bf(L,gf(o,F,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==ff(o,"data:")||!ce[e])if(Y&&!bf(I,gf(o,F,"")));else if(o)return!1;return!0},Pe=function(e){return e.indexOf("-")>0},Ie=function(e){var t,o,n,r;Re("beforeSanitizeAttributes",e,null);var i=e.attributes;if(i){var s={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Z};for(r=i.length;r--;){var a=t=i[r],l=a.name,c=a.namespaceURI;o="value"===l?t.value:vf(t.value),n=N(l);var d=o;if(s.attrName=n,s.attrValue=o,s.keepAttr=!0,s.forceKeepAttr=void 0,Re("uponSanitizeAttribute",e,s),o=s.attrValue,!s.forceKeepAttr)if(s.keepAttr)if(bf(/\/>/i,o))Me(l,e);else{K&&(o=gf(o,R," "),o=gf(o,V," "));var u=N(e.nodeName);if(De(u,n,o)){if(o!==d)try{c?e.setAttributeNS(c,l,o):e.setAttribute(l,o)}catch(t){Me(l,e)}}else Me(l,e)}else Me(l,e)}Re("afterSanitizeAttributes",e,null)}},Fe=function e(t){var o,n=Be(t);for(Re("beforeSanitizeShadowDOM",t,null);o=n.nextNode();)Re("uponSanitizeShadowNode",o,null),Ve(o)||(o.content instanceof i&&e(o.content),Ie(o));Re("afterSanitizeShadowDOM",t,null)};return o.sanitize=function(e,r){var s,l,c,d,u;if((ve=!e)&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Ne(e)){if("function"!=typeof e.toString)throw yf("toString is not a function");if("string"!=typeof(e=e.toString()))throw yf("dirty is not a string, aborting")}if(!o.isSupported){if("object"===Wg(t.toStaticHTML)||"function"==typeof t.toStaticHTML){if("string"==typeof e)return t.toStaticHTML(e);if(Ne(e))return t.toStaticHTML(e.outerHTML)}return e}if(J||xe(r),o.removed=[],"string"==typeof e&&(ie=!1),ie){if(e.nodeName){var h=N(e.nodeName);if(!z[h]||$[h])throw yf("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof a)1===(l=(s=Ae("\x3c!----\x3e")).ownerDocument.importNode(e,!0)).nodeType&&"BODY"===l.nodeName||"HTML"===l.nodeName?s=l:s.appendChild(l);else{if(!ee&&!K&&!X&&-1===e.indexOf("<"))return _&&oe?_.createHTML(e):e;if(!(s=Ae(e)))return ee?null:oe?x:""}s&&Q&&Oe(s.firstChild);for(var m=Be(ie?e:s);c=m.nextNode();)3===c.nodeType&&c===d||Ve(c)||(c.content instanceof i&&Fe(c.content),Ie(c),d=c);if(d=null,ie)return e;if(ee){if(te)for(u=T.call(s.ownerDocument);s.firstChild;)u.appendChild(s.firstChild);else u=s;return Z.shadowroot&&(u=O.call(n,u,!0)),u}var p=X?s.outerHTML:s.innerHTML;return X&&z["!doctype"]&&s.ownerDocument&&s.ownerDocument.doctype&&s.ownerDocument.doctype.name&&bf(Zf,s.ownerDocument.doctype.name)&&(p="\n"+p),K&&(p=gf(p,R," "),p=gf(p,V," ")),_&&oe?_.createHTML(p):p},o.setConfig=function(e){xe(e),J=!0},o.clearConfig=function(){ye=null,J=!1},o.isValidAttribute=function(e,t,o){ye||xe({});var n=N(e),r=N(t);return De(n,r,o)},o.addHook=function(e,t){"function"==typeof t&&(A[e]=A[e]||[],hf(A[e],t))},o.removeHook=function(e){if(A[e])return uf(A[e])},o.removeHooks=function(e){A[e]&&(A[e]=[])},o.removeAllHooks=function(){A={}},o}();const $f=e=>Uf().sanitize(e);var Wf=window.mailpoetTinymce.util.Tools.resolve("window.mailpoetTinymce.util.I18n");const qf={indent:!0,outdent:!0,"table-insert-column-after":!0,"table-insert-column-before":!0,"paste-column-after":!0,"paste-column-before":!0,"unordered-list":!0,"list-bull-circle":!0,"list-bull-default":!0,"list-bull-square":!0},Gf="temporary-placeholder",Yf=e=>()=>ve(e,Gf).getOr("!not found!"),Kf=(e,t)=>{const o=e.toLowerCase();if(Wf.isRtl()){const e=((e,t)=>Me(e,t)?e:((e,t)=>e+t)(e,t))(o,"-rtl");return be(t,e)?e:o}return o},Xf=(e,t)=>ve(t,Kf(e,t)),Jf=(e,t)=>{const o=t();return Xf(e,o).getOrThunk(Yf(o))},Qf=()=>Xp("add-focusable",[Ki((e=>{ma(e.element,"svg").each((e=>Ct(e,"focusable","false")))}))]),ev=(e,t,o,n)=>{var r,i;const s=(e=>!!Wf.isRtl()&&be(qf,e))(t)?["tox-icon--flip"]:[],a=ve(o,Kf(t,o)).or(n).getOrThunk(Yf(o));return{dom:{tag:e.tag,attributes:null!==(r=e.attributes)&&void 0!==r?r:{},classes:e.classes.concat(s),innerHtml:a},behaviours:Cl([...null!==(i=e.behaviours)&&void 0!==i?i:[],Qf()])}},tv=(e,t,o,n=M.none())=>ev(t,e,o(),n),ov={success:"checkmark",error:"warning",err:"error",warning:"warning",warn:"warning",info:"info"},nv=fh({name:"Notification",factory:e=>{const t=$g({dom:Ug(`${$f(e.translationProvider(e.text))}
`),behaviours:Cl([Kp.config({})])}),o=e=>({dom:{tag:"div",classes:["tox-bar"],styles:{width:`${e}%`}}}),n=e=>({dom:{tag:"div",classes:["tox-text"],innerHtml:`${e}%`}}),r=$g({dom:{tag:"div",classes:e.progress?["tox-progress-bar","tox-progress-indicator"]:["tox-progress-bar"]},components:[{dom:{tag:"div",classes:["tox-bar-container"]},components:[o(0)]},n(0)],behaviours:Cl([Kp.config({})])}),i={updateProgress:(e,t)=>{e.getSystem().isConnected()&&r.getOpt(e).each((e=>{Kp.set(e,[{dom:{tag:"div",classes:["tox-bar-container"]},components:[o(t)]},n(t)])}))},updateText:(e,o)=>{if(e.getSystem().isConnected()){const n=t.get(e);Kp.set(n,[ta(o)])}}},s=q([e.icon.toArray(),e.level.toArray(),e.level.bind((e=>M.from(ov[e]))).toArray()]),a=$g(jg.sketch({dom:{tag:"button",classes:["tox-notification__dismiss","tox-button","tox-button--naked","tox-button--icon"]},components:[tv("close",{tag:"span",classes:["tox-icon"],attributes:{"aria-label":e.translationProvider("Close")}},e.iconProvider)],action:t=>{e.onAction(t)}})),l=((e,t,o)=>{const n=o(),r=$(e,(e=>be(n,Kf(e,n))));return ev({tag:"div",classes:["tox-notification__icon"]},r.getOr(Gf),n,M.none())})(s,0,e.iconProvider),c=[l,{dom:{tag:"div",classes:["tox-notification__body"]},components:[t.asSpec()],behaviours:Cl([Kp.config({})])}];return{uid:e.uid,dom:{tag:"div",attributes:{role:"alert"},classes:e.level.map((e=>["tox-notification","tox-notification--in",`tox-notification--${e}`])).getOr(["tox-notification","tox-notification--in"])},behaviours:Cl([og.config({}),Xp("notification-events",[Zi(Gr(),(e=>{a.getOpt(e).each(og.focus)}))])]),components:c.concat(e.progress?[r.asSpec()]:[]).concat(e.closeButton?[a.asSpec()]:[]),apis:i}},configFields:[ur("level"),or("progress"),ur("icon"),or("onAction"),or("text"),or("iconProvider"),or("translationProvider"),kr("closeButton",!0)],apis:{updateProgress:(e,t,o)=>{e.updateProgress(t,o)},updateText:(e,t,o)=>{e.updateText(t,o)}}});var rv,iv,sv=window.mailpoetTinymce.util.Tools.resolve("mailpoetTinymce.dom.DOMUtils"),av=window.mailpoetTinymce.util.Tools.resolve("mailpoetTinymce.EditorManager"),lv=window.mailpoetTinymce.util.Tools.resolve("mailpoetTinymce.Env");!function(e){e.default="wrap",e.floating="floating",e.sliding="sliding",e.scrolling="scrolling"}(rv||(rv={})),function(e){e.auto="auto",e.top="top",e.bottom="bottom"}(iv||(iv={}));const cv=e=>t=>t.options.get(e),dv=e=>t=>M.from(e(t)),uv=e=>{const t=lv.deviceType.isPhone(),o=lv.deviceType.isTablet()||t,n=e.options.register,r=e=>i(e)||!1===e,s=e=>i(e)||g(e);n("skin",{processor:e=>i(e)||!1===e,default:"oxide"}),n("skin_url",{processor:"string"}),n("height",{processor:s,default:Math.max(e.getElement().offsetHeight,400)}),n("width",{processor:s,default:sv.DOM.getStyle(e.getElement(),"width")}),n("min_height",{processor:"number",default:100}),n("min_width",{processor:"number"}),n("max_height",{processor:"number"}),n("max_width",{processor:"number"}),n("style_formats",{processor:"object[]"}),n("style_formats_merge",{processor:"boolean",default:!1}),n("style_formats_autohide",{processor:"boolean",default:!1}),n("line_height_formats",{processor:"string",default:"1 1.1 1.2 1.3 1.4 1.5 2"}),n("font_family_formats",{processor:"string",default:"Andale Mono=andale mono,monospace;Arial=arial,helvetica,sans-serif;Arial Black=arial black,sans-serif;Book Antiqua=book antiqua,palatino,serif;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,palatino,serif;Helvetica=helvetica,arial,sans-serif;Impact=impact,sans-serif;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco,monospace;Times New Roman=times new roman,times,serif;Trebuchet MS=trebuchet ms,geneva,sans-serif;Verdana=verdana,geneva,sans-serif;Webdings=webdings;Wingdings=wingdings,zapf dingbats"}),n("font_size_formats",{processor:"string",default:"8pt 10pt 12pt 14pt 18pt 24pt 36pt"}),n("font_size_input_default_unit",{processor:"string",default:"pt"}),n("block_formats",{processor:"string",default:"Paragraph=p;Heading 1=h1;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Preformatted=pre"}),n("content_langs",{processor:"object[]"}),n("removed_menuitems",{processor:"string",default:""}),n("menubar",{processor:e=>i(e)||d(e),default:!t}),n("menu",{processor:"object",default:{}}),n("toolbar",{processor:e=>d(e)||i(e)||l(e)?{value:e,valid:!0}:{valid:!1,message:"Must be a boolean, string or array."},default:!0}),I(9,(e=>{n("toolbar"+(e+1),{processor:"string"})})),n("toolbar_mode",{processor:"string",default:o?"scrolling":"floating"}),n("toolbar_groups",{processor:"object",default:{}}),n("toolbar_location",{processor:"string",default:iv.auto}),n("toolbar_persist",{processor:"boolean",default:!1}),n("toolbar_sticky",{processor:"boolean",default:e.inline}),n("toolbar_sticky_offset",{processor:"number",default:0}),n("fixed_toolbar_container",{processor:"string",default:""}),n("fixed_toolbar_container_target",{processor:"object"}),n("ui_mode",{processor:"string",default:"combined"}),n("file_picker_callback",{processor:"function"}),n("file_picker_validator_handler",{processor:"function"}),n("file_picker_types",{processor:"string"}),n("typeahead_urls",{processor:"boolean",default:!0}),n("anchor_top",{processor:r,default:"#top"}),n("anchor_bottom",{processor:r,default:"#bottom"}),n("draggable_modal",{processor:"boolean",default:!1}),n("statusbar",{processor:"boolean",default:!0}),n("elementpath",{processor:"boolean",default:!0}),n("branding",{processor:"boolean",default:!0}),n("promotion",{processor:"boolean",default:!0}),n("resize",{processor:e=>"both"===e||d(e),default:!lv.deviceType.isTouch()}),n("sidebar_show",{processor:"string"}),n("help_accessibility",{processor:"boolean",default:e.hasPlugin("help")})},hv=cv("readonly"),mv=cv("height"),pv=cv("width"),gv=dv(cv("min_width")),fv=dv(cv("min_height")),vv=dv(cv("max_width")),bv=dv(cv("max_height")),yv=dv(cv("style_formats")),wv=cv("style_formats_merge"),_v=cv("style_formats_autohide"),xv=cv("content_langs"),Cv=cv("removed_menuitems"),kv=cv("toolbar_mode"),Sv=cv("toolbar_groups"),Tv=cv("toolbar_location"),Ev=cv("fixed_toolbar_container"),Ov=cv("fixed_toolbar_container_target"),Mv=cv("toolbar_persist"),Av=cv("toolbar_sticky_offset"),Bv=cv("menubar"),Nv=cv("toolbar"),Rv=cv("file_picker_callback"),Vv=cv("file_picker_validator_handler"),Dv=cv("font_size_input_default_unit"),Pv=cv("file_picker_types"),Iv=cv("typeahead_urls"),Fv=cv("anchor_top"),Lv=cv("anchor_bottom"),zv=cv("draggable_modal"),Hv=cv("statusbar"),Zv=cv("elementpath"),jv=cv("branding"),Uv=cv("resize"),$v=cv("paste_as_text"),Wv=cv("sidebar_show"),qv=cv("promotion"),Gv=cv("help_accessibility"),Yv=e=>!1===e.options.get("skin"),Kv=e=>!1!==e.options.get("menubar"),Xv=e=>{const t=e.options.get("skin_url");if(Yv(e))return t;if(t)return e.documentBaseURI.toAbsolute(t);{const t=e.options.get("skin");return av.baseURL+"/skins/ui/"+t}},Jv=e=>e.options.get("line_height_formats").split(" "),Qv=e=>{const t=Nv(e),o=i(t),n=l(t)&&t.length>0;return!tb(e)&&(n||o||!0===t)},eb=e=>{const t=I(9,(t=>e.options.get("toolbar"+(t+1)))),o=Z(t,i);return ke(o.length>0,o)},tb=e=>eb(e).fold((()=>{const t=Nv(e);return f(t,i)&&t.length>0}),O),ob=e=>Tv(e)===iv.bottom,nb=e=>{var t;if(!e.inline)return M.none();const o=null!==(t=Ev(e))&&void 0!==t?t:"";if(o.length>0)return pa(wt(),o);const n=Ov(e);return m(n)?M.some(Ie(n)):M.none()},rb=e=>e.inline&&nb(e).isSome(),ib=e=>nb(e).getOrThunk((()=>ft(gt(Ie(e.getElement()))))),sb=e=>e.inline&&!Kv(e)&&!Qv(e)&&!tb(e),ab=e=>(e.options.get("toolbar_sticky")||e.inline)&&!rb(e)&&!sb(e),lb=e=>!rb(e)&&"split"===e.options.get("ui_mode"),cb=e=>{const t=e.options.get("menu");return ce(t,(e=>({...e,items:e.items})))};var db=Object.freeze({__proto__:null,get ToolbarMode(){return rv},get ToolbarLocation(){return iv},register:uv,getSkinUrl:Xv,isReadOnly:hv,isSkinDisabled:Yv,getHeightOption:mv,getWidthOption:pv,getMinWidthOption:gv,getMinHeightOption:fv,getMaxWidthOption:vv,getMaxHeightOption:bv,getUserStyleFormats:yv,shouldMergeStyleFormats:wv,shouldAutoHideStyleFormats:_v,getLineHeightFormats:Jv,getContentLanguages:xv,getRemovedMenuItems:Cv,isMenubarEnabled:Kv,isMultipleToolbars:tb,isToolbarEnabled:Qv,isToolbarPersist:Mv,getMultipleToolbarsOption:eb,getUiContainer:ib,useFixedContainer:rb,isSplitUiMode:lb,getToolbarMode:kv,isDraggableModal:zv,isDistractionFree:sb,isStickyToolbar:ab,getStickyToolbarOffset:Av,getToolbarLocation:Tv,isToolbarLocationBottom:ob,getToolbarGroups:Sv,getMenus:cb,getMenubar:Bv,getToolbar:Nv,getFilePickerCallback:Rv,getFilePickerTypes:Pv,useTypeaheadUrls:Iv,getAnchorTop:Fv,getAnchorBottom:Lv,getFilePickerValidatorHandler:Vv,getFontSizeInputDefaultUnit:Dv,useStatusBar:Hv,useElementPath:Zv,promotionEnabled:qv,useBranding:jv,getResize:Uv,getPasteAsText:$v,getSidebarShow:Wv,useHelpAccessibility:Gv});const ub="[data-mce-autocompleter]",hb=e=>ga(e,ub);var mb;!function(e){e[e.CLOSE_ON_EXECUTE=0]="CLOSE_ON_EXECUTE",e[e.BUBBLE_TO_SANDBOX=1]="BUBBLE_TO_SANDBOX"}(mb||(mb={}));var pb=mb;const gb="tox-menu-nav__js",fb="tox-collection__item",vb="tox-swatch",bb={normal:gb,color:vb},yb="tox-collection__item--enabled",wb="tox-collection__item-icon",_b="tox-collection__item-label",xb="tox-collection__item-caret",Cb="tox-collection__item--active",kb="tox-collection__item-container",Sb="tox-collection__item-container--row",Tb=e=>ve(bb,e).getOr(gb),Eb=e=>"color"===e?"tox-swatches":"tox-menu",Ob=e=>({backgroundMenu:"tox-background-menu",selectedMenu:"tox-selected-menu",selectedItem:"tox-collection__item--active",hasIcons:"tox-menu--has-icons",menu:Eb(e),tieredMenu:"tox-tiered-menu"}),Mb=e=>{const t=Ob(e);return{backgroundMenu:t.backgroundMenu,selectedMenu:t.selectedMenu,menu:t.menu,selectedItem:t.selectedItem,item:Tb(e)}},Ab=(e,t,o)=>{const n=Ob(o);return{tag:"div",classes:q([[n.menu,`tox-menu-${t}-column`],e?[n.hasIcons]:[]])}},Bb=[Bg.parts.items({})],Nb=(e,t,o)=>{const n=Ob(o);return{dom:{tag:"div",classes:q([[n.tieredMenu]])},markers:Mb(o)}},Rb=w([ur("data"),yr("inputAttributes",{}),yr("inputStyles",{}),yr("tag","input"),yr("inputClasses",[]),Ba("onSetValue"),yr("styles",{}),yr("eventOrder",{}),gu("inputBehaviours",[pu,og]),yr("selectOnFocus",!0)]),Vb=e=>Cl([og.config({onFocus:e.selectOnFocus?e=>{const t=e.element,o=Ws(t);t.dom.setSelectionRange(0,o.length)}:v})]),Db=e=>({...Vb(e),...vu(e.inputBehaviours,[pu.config({store:{mode:"manual",...e.data.map((e=>({initialValue:e}))).getOr({}),getValue:e=>Ws(e.element),setValue:(e,t)=>{Ws(e.element)!==t&&qs(e.element,t)}},onSetValue:e.onSetValue})])}),Pb=e=>({tag:e.tag,attributes:{type:"text",...e.inputAttributes},styles:e.inputStyles,classes:e.inputClasses}),Ib=fh({name:"Input",configFields:Rb(),factory:(e,t)=>({uid:e.uid,dom:Pb(e),components:[],behaviours:Db(e),eventOrder:e.eventOrder})}),Fb=ls("refetch-trigger-event"),Lb=ls("redirect-menu-item-interaction"),zb="tox-menu__searcher",Hb=e=>pa(e.element,`.${zb}`).bind((t=>e.getSystem().getByDom(t).toOptional())),Zb=Hb,jb=e=>({fetchPattern:pu.getValue(e),selectionStart:e.element.dom.selectionStart,selectionEnd:e.element.dom.selectionEnd}),Ub=e=>{const t=(e,t)=>(t.cut(),M.none()),o=(e,t)=>{const o={interactionEvent:t.event,eventType:t.event.raw.type};return Vi(e,Lb,o),M.some(!0)},n="searcher-events";return{dom:{tag:"div",classes:[fb]},components:[Ib.sketch({inputClasses:[zb,"tox-textfield"],inputAttributes:{...e.placeholder.map((t=>({placeholder:e.i18n(t)}))).getOr({}),type:"search","aria-autocomplete":"list"},inputBehaviours:Cl([Xp(n,[Zi(Jr(),(e=>{Ri(e,Fb)})),Zi(Kr(),((e,t)=>{"Escape"===t.event.raw.key&&t.stop()}))]),Hp.config({mode:"special",onLeft:t,onRight:t,onSpace:t,onEnter:o,onEscape:o,onUp:o,onDown:o})]),eventOrder:{keydown:[n,Hp.name()]}})]}},$b="tox-collection--results__js",Wb=e=>{var t;return e.dom?{...e,dom:{...e.dom,attributes:{...null!==(t=e.dom.attributes)&&void 0!==t?t:{},id:ls("aria-item-search-result-id"),"aria-selected":"false"}}}:e},qb=(e,t)=>o=>{const n=F(o,t);return L(n,(t=>({dom:e,components:t})))},Gb=(e,t)=>{const o=[];let n=[];return z(e,((e,r)=>{t(e,r)?(n.length>0&&o.push(n),n=[],(be(e.dom,"innerHtml")||e.components&&e.components.length>0)&&n.push(e)):n.push(e)})),n.length>0&&o.push(n),L(o,(e=>({dom:{tag:"div",classes:["tox-collection__group"]},components:e})))},Yb=(e,t,o)=>Bg.parts.items({preprocess:n=>{const r=L(n,o);return"auto"!==e&&e>1?qb({tag:"div",classes:["tox-collection__group"]},e)(r):Gb(r,((e,o)=>"separator"===t[o].type))}}),Kb=(e,t,o=!0)=>({dom:{tag:"div",classes:["tox-menu","tox-collection"].concat(1===e?["tox-collection--list"]:["tox-collection--grid"])},components:[Yb(e,t,_)]}),Xb=e=>P(e,(e=>"icon"in e&&void 0!==e.icon)),Jb=e=>(console.error(Kn(e)),console.log(e),M.none()),Qb=(e,t,o,n,r)=>{const i=(s=o,{dom:{tag:"div",classes:["tox-collection","tox-collection--horizontal"]},components:[Bg.parts.items({preprocess:e=>Gb(e,((e,t)=>"separator"===s[t].type))})]});var s;return{value:e,dom:i.dom,components:i.components,items:o}},ey=(e,t,o,n,r)=>{if("color"===r.menuType){const t=(e=>({dom:{tag:"div",classes:["tox-menu","tox-swatches-menu"]},components:[{dom:{tag:"div",classes:["tox-swatches"]},components:[Bg.parts.items({preprocess:"auto"!==e?qb({tag:"div",classes:["tox-swatches__row"]},e):_})]}]}))(n);return{value:e,dom:t.dom,components:t.components,items:o}}if("normal"===r.menuType&&"auto"===n){const t=Kb(n,o);return{value:e,dom:t.dom,components:t.components,items:o}}if("normal"===r.menuType||"searchable"===r.menuType){const t="searchable"!==r.menuType?Kb(n,o):"search-with-field"===r.searchMode.searchMode?((e,t,o)=>{const n=ls("aria-controls-search-results");return{dom:{tag:"div",classes:["tox-menu","tox-collection"].concat(1===e?["tox-collection--list"]:["tox-collection--grid"])},components:[Ub({i18n:Wf.translate,placeholder:o.placeholder}),{dom:{tag:"div",classes:[...1===e?["tox-collection--list"]:["tox-collection--grid"],$b],attributes:{id:n}},components:[Yb(e,t,Wb)]}]}})(n,o,r.searchMode):((e,t,o=!0)=>{const n=ls("aria-controls-search-results");return{dom:{tag:"div",classes:["tox-menu","tox-collection",$b].concat(1===e?["tox-collection--list"]:["tox-collection--grid"]),attributes:{id:n}},components:[Yb(e,t,Wb)]}})(n,o);return{value:e,dom:t.dom,components:t.components,items:o}}if("listpreview"===r.menuType&&"auto"!==n){const t=(e=>({dom:{tag:"div",classes:["tox-menu","tox-collection","tox-collection--toolbar","tox-collection--toolbar-lg"]},components:[Bg.parts.items({preprocess:qb({tag:"div",classes:["tox-collection__group"]},e)})]}))(n);return{value:e,dom:t.dom,components:t.components,items:o}}return{value:e,dom:Ab(t,n,r.menuType),components:Bb,items:o}},ty=ir("type"),oy=ir("name"),ny=ir("label"),ry=ir("text"),iy=ir("title"),sy=ir("icon"),ay=ir("value"),ly=ar("fetch"),cy=ar("getSubmenuItems"),dy=ar("onAction"),uy=ar("onItemAction"),hy=Sr("onSetup",(()=>v)),my=pr("name"),py=pr("text"),gy=pr("icon"),fy=pr("tooltip"),vy=pr("label"),by=pr("shortcut"),yy=fr("select"),wy=kr("active",!1),_y=kr("borderless",!1),xy=kr("enabled",!0),Cy=kr("primary",!1),ky=e=>yr("columns",e),Sy=yr("meta",{}),Ty=Sr("onAction",v),Ey=e=>xr("type",e),Oy=e=>Qn("name","name",bn((()=>ls(`${e}-name`))),Ln),My=Bn([ty,py]),Ay=Bn([Ey("autocompleteitem"),wy,xy,Sy,ay,py,gy]),By=[xy,fy,gy,py,hy],Ny=Bn([ty,dy].concat(By)),Ry=e=>qn("toolbarbutton",Ny,e),Vy=[wy].concat(By),Dy=Bn(Vy.concat([ty,dy])),Py=e=>qn("ToggleButton",Dy,e),Iy=[Sr("predicate",E),Cr("scope","node",["node","editor"]),Cr("position","selection",["node","selection","line"])],Fy=By.concat([Ey("contextformbutton"),Cy,dy,er("original",_)]),Ly=Vy.concat([Ey("contextformbutton"),Cy,dy,er("original",_)]),zy=By.concat([Ey("contextformbutton")]),Hy=Vy.concat([Ey("contextformtogglebutton")]),Zy=Xn("type",{contextformbutton:Fy,contextformtogglebutton:Ly}),jy=Bn([Ey("contextform"),Sr("initValue",w("")),vy,dr("commands",Zy),hr("launch",Xn("type",{contextformbutton:zy,contextformtogglebutton:Hy}))].concat(Iy)),Uy=Bn([Ey("contexttoolbar"),ir("items")].concat(Iy)),$y=[ty,ir("src"),pr("alt"),Tr("classes",[],Ln)],Wy=Bn($y),qy=[ty,ry,my,Tr("classes",["tox-collection__item-label"],Ln)],Gy=Bn(qy),Yy=On((()=>Un("type",{cardimage:Wy,cardtext:Gy,cardcontainer:Ky}))),Ky=Bn([ty,xr("direction","horizontal"),xr("align","left"),xr("valign","middle"),dr("items",Yy)]),Xy=[xy,py,by,("menuitem",Qn("value","value",bn((()=>ls("menuitem-value"))),Pn())),Sy];const Jy=Bn([ty,vy,dr("items",Yy),hy,Ty].concat(Xy)),Qy=Bn([ty,wy,gy].concat(Xy)),ew=[ty,ir("fancytype"),Ty],tw=[yr("initData",{})].concat(ew),ow=[fr("select"),Er("initData",{},[kr("allowCustomColors",!0),xr("storageKey","default"),vr("colors",Pn())])].concat(ew),nw=Xn("fancytype",{inserttable:tw,colorswatch:ow}),rw=Bn([ty,hy,Ty,gy].concat(Xy)),iw=Bn([ty,cy,hy,gy].concat(Xy)),sw=Bn([ty,gy,wy,hy,dy].concat(Xy)),aw=(e,t,o)=>{const n=Gc(e.element,"."+o);if(n.length>0){const e=W(n,(e=>{const o=e.dom.getBoundingClientRect().top,r=n[0].dom.getBoundingClientRect().top;return Math.abs(o-r)>t})).getOr(n.length);return M.some({numColumns:e,numRows:Math.ceil(n.length/e)})}return M.none()},lw=e=>((e,t)=>Cl([Xp(e,t)]))(ls("unnamed-events"),e),cw=ls("tooltip.exclusive"),dw=ls("tooltip.show"),uw=ls("tooltip.hide"),hw=(e,t,o)=>{e.getSystem().broadcastOn([cw],{})};var mw=Object.freeze({__proto__:null,hideAllExclusive:hw,setComponents:(e,t,o,n)=>{o.getTooltip().each((e=>{e.getSystem().isConnected()&&Kp.set(e,n)}))}}),pw=Object.freeze({__proto__:null,events:(e,t)=>{const o=o=>{t.getTooltip().each((n=>{Nd(n),e.onHide(o,n),t.clearTooltip()})),t.clearTimer()};return Li(q([[Zi(dw,(o=>{t.resetTimer((()=>{(o=>{if(!t.isShowing()){hw(o);const n=e.lazySink(o).getOrDie(),r=o.getSystem().build({dom:e.tooltipDom,components:e.tooltipComponents,events:Li("normal"===e.mode?[Zi(qr(),(e=>{Ri(o,dw)})),Zi($r(),(e=>{Ri(o,uw)}))]:[]),behaviours:Cl([Kp.config({})])});t.setTooltip(r),Md(n,r),e.onShow(o,r),xd.position(n,r,{anchor:e.anchor(o)})}})(o)}),e.delay)})),Zi(uw,(n=>{t.resetTimer((()=>{o(n)}),e.delay)})),Zi(di(),((e,t)=>{const n=t;n.universal||D(n.channels,cw)&&o(e)})),Xi((e=>{o(e)}))],"normal"===e.mode?[Zi(Gr(),(e=>{Ri(e,dw)})),Zi(li(),(e=>{Ri(e,uw)})),Zi(qr(),(e=>{Ri(e,dw)})),Zi($r(),(e=>{Ri(e,uw)}))]:[Zi(Bi(),((e,t)=>{Ri(e,dw)})),Zi(Ni(),(e=>{Ri(e,uw)}))]]))}}),gw=[or("lazySink"),or("tooltipDom"),yr("exclusive",!0),yr("tooltipComponents",[]),yr("delay",300),Cr("mode","normal",["normal","follow-highlight"]),yr("anchor",(e=>({type:"hotspot",hotspot:e,layouts:{onLtr:w([cl,ll,rl,sl,il,al]),onRtl:w([cl,ll,rl,sl,il,al])}}))),Ba("onHide"),Ba("onShow")],fw=Object.freeze({__proto__:null,init:()=>{const e=Ql(),t=Ql(),o=()=>{e.on(clearTimeout)},n=w("not-implemented");return Ts({getTooltip:t.get,isShowing:t.isSet,setTooltip:t.set,clearTooltip:t.clear,clearTimer:o,resetTimer:(t,n)=>{o(),e.set(setTimeout(t,n))},readState:n})}});const vw=Sl({fields:gw,name:"tooltipping",active:pw,state:fw,apis:mw}),bw="silver.readonly",yw=Bn([("readonly",nr("readonly",zn))]);const ww=(e,t)=>{const o=e.mainUi.outerContainer.element,n=[e.mainUi.mothership,...e.uiMotherships];t&&z(n,(e=>{e.broadcastOn([Yd()],{target:o})})),z(n,(e=>{e.broadcastOn([bw],{readonly:t})}))},_w=(e,t)=>{e.on("init",(()=>{e.mode.isReadOnly()&&ww(t,!0)})),e.on("SwitchMode",(()=>ww(t,e.mode.isReadOnly()))),hv(e)&&e.mode.set("readonly")},xw=()=>Ml.config({channels:{[bw]:{schema:yw,onReceive:(e,t)=>{Dh.set(e,t.readonly)}}}}),Cw=e=>Dh.config({disabled:e}),kw=e=>Dh.config({disabled:e,disableClass:"tox-tbtn--disabled"}),Sw=e=>Dh.config({disabled:e,disableClass:"tox-tbtn--disabled",useNative:!1}),Tw=(e,t)=>{const o=e.getApi(t);return e=>{e(o)}},Ew=(e,t)=>Ki((o=>{Tw(e,o)((o=>{const n=e.onSetup(o);p(n)&&t.set(n)}))})),Ow=(e,t)=>Xi((o=>Tw(e,o)(t.get()))),Mw=(e,t)=>Qi(((o,n)=>{Tw(e,o)(e.onAction),e.triggersSubmenu||t!==pb.CLOSE_ON_EXECUTE||(o.getSystem().isConnected()&&Ri(o,gi()),n.stop())})),Aw={[ui()]:["disabling","alloy.base.behaviour","toggling","item-events"]},Bw=_e,Nw=(e,t,o,n)=>{const r=Or(v);return{type:"item",dom:t.dom,components:Bw(t.optComponents),data:e.data,eventOrder:Aw,hasSubmenu:e.triggersSubmenu,itemBehaviours:Cl([Xp("item-events",[Mw(e,o),Ew(e,r),Ow(e,r)]),(i=()=>!e.enabled||n.isDisabled(),Dh.config({disabled:i,disableClass:"tox-collection__item--state-disabled"})),xw(),Kp.config({})].concat(e.itemBehaviours))};var i},Rw=e=>({value:e.value,meta:{text:e.text.getOr(""),...e.meta}}),Vw=e=>{const t=lv.os.isMacOS()||lv.os.isiOS(),o=t?{alt:"⌥",ctrl:"⌃",shift:"⇧",meta:"⌘",access:"⌃⌥"}:{meta:"Ctrl",access:"Shift+Alt"},n=e.split("+"),r=L(n,(e=>{const t=e.toLowerCase().trim();return be(o,t)?o[t]:e}));return t?r.join(""):r.join("+")},Dw=(e,t,o=[wb])=>tv(e,{tag:"div",classes:o},t),Pw=e=>({dom:{tag:"div",classes:[_b]},components:[ta(Wf.translate(e))]}),Iw=(e,t)=>({dom:{tag:"div",classes:t,innerHtml:e}}),Fw=(e,t)=>({dom:{tag:"div",classes:[_b]},components:[{dom:{tag:e.tag,styles:e.styles},components:[ta(Wf.translate(t))]}]}),Lw=e=>({dom:{tag:"div",classes:["tox-collection__item-accessory"]},components:[ta(Vw(e))]}),zw=e=>Dw("checkmark",e,["tox-collection__item-checkmark"]),Hw=e=>{const t=e.map((e=>({attributes:{title:Wf.translate(e),id:ls("menu-item")}}))).getOr({});return{tag:"div",classes:[gb,fb],...t}},Zw=(e,t,o,n=M.none())=>"color"===e.presets?((e,t,o)=>{const n=e.ariaLabel,r=e.value,i=e.iconContent.map((e=>((e,t,o)=>{const n=t();return Xf(e,n).or(o).getOrThunk(Yf(n))})(e,t.icons,o)));return{dom:(()=>{const e=vb,o=i.getOr(""),s=n.map((e=>({title:t.translate(e)}))).getOr({}),a={tag:"div",attributes:s,classes:[e]};return"custom"===r?{...a,tag:"button",classes:[...a.classes,"tox-swatches__picker-btn"],innerHtml:o}:"remove"===r?{...a,classes:[...a.classes,"tox-swatch--remove"],innerHtml:o}:m(r)?{...a,attributes:{...a.attributes,"data-mce-color":r},styles:{"background-color":r},innerHtml:o}:a})(),optComponents:[]}})(e,t,n):((e,t,o,n)=>{const r={tag:"div",classes:[wb]},i=o?e.iconContent.map((e=>tv(e,r,t.icons,n))).orThunk((()=>M.some({dom:r}))):M.none(),s=e.checkMark,a=M.from(e.meta).fold((()=>Pw),(e=>be(e,"style")?C(Fw,e.style):Pw)),l=e.htmlContent.fold((()=>e.textContent.map(a)),(e=>M.some(Iw(e,[_b]))));return{dom:Hw(e.ariaLabel),optComponents:[i,l,e.shortcutContent.map(Lw),s,e.caret]}})(e,t,o,n),jw=(e,t)=>ve(e,"tooltipWorker").map((e=>[vw.config({lazySink:t.getSink,tooltipDom:{tag:"div",classes:["tox-tooltip-worker-container"]},tooltipComponents:[],anchor:e=>({type:"submenu",item:e,overrides:{maxHeightFunction:cc}}),mode:"follow-highlight",onShow:(t,o)=>{e((e=>{vw.setComponents(t,[oa({element:Ie(e)})])}))}})])).getOr([]),Uw=(e,t)=>{const o=(e=>sv.DOM.encode(e))(Wf.translate(e));if(t.length>0){const e=new RegExp((e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))(t),"gi");return o.replace(e,(e=>`${e} `))}return o},$w=(e,t)=>L(e,(e=>{switch(e.type){case"cardcontainer":return((e,t)=>{const o="vertical"===e.direction?"tox-collection__item-container--column":Sb,n="left"===e.align?"tox-collection__item-container--align-left":"tox-collection__item-container--align-right";return{dom:{tag:"div",classes:[kb,o,n,(()=>{switch(e.valign){case"top":return"tox-collection__item-container--valign-top";case"middle":return"tox-collection__item-container--valign-middle";case"bottom":return"tox-collection__item-container--valign-bottom"}})()]},components:t}})(e,$w(e.items,t));case"cardimage":return((e,t,o)=>({dom:{tag:"img",classes:t,attributes:{src:e,alt:o.getOr("")}}}))(e.src,e.classes,e.alt);case"cardtext":const o=e.name.exists((e=>D(t.cardText.highlightOn,e))),n=o?M.from(t.cardText.matchText).getOr(""):"";return Iw(Uw(e.text,n),e.classes)}})),Ww=Yu(kg(),Sg()),qw=e=>({value:Xw(e)}),Gw=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,Yw=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,Kw=e=>Gw.test(e)||Yw.test(e),Xw=e=>Te(e,"#").toUpperCase(),Jw=e=>{const t=e.toString(16);return(1===t.length?"0"+t:t).toUpperCase()},Qw=e=>{const t=Jw(e.red)+Jw(e.green)+Jw(e.blue);return qw(t)},e_=Math.min,t_=Math.max,o_=Math.round,n_=/^\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/i,r_=/^\s*rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?(?:\.\d+)?)\s*\)\s*$/i,i_=(e,t,o,n)=>({red:e,green:t,blue:o,alpha:n}),s_=e=>{const t=parseInt(e,10);return t.toString()===e&&t>=0&&t<=255},a_=e=>{let t,o,n;const r=(e.hue||0)%360;let i=e.saturation/100,s=e.value/100;if(i=t_(0,e_(i,1)),s=t_(0,e_(s,1)),0===i)return t=o=n=o_(255*s),i_(t,o,n,1);const a=r/60,l=s*i,c=l*(1-Math.abs(a%2-1)),d=s-l;switch(Math.floor(a)){case 0:t=l,o=c,n=0;break;case 1:t=c,o=l,n=0;break;case 2:t=0,o=l,n=c;break;case 3:t=0,o=c,n=l;break;case 4:t=c,o=0,n=l;break;case 5:t=l,o=0,n=c;break;default:t=o=n=0}return t=o_(255*(t+d)),o=o_(255*(o+d)),n=o_(255*(n+d)),i_(t,o,n,1)},l_=e=>{const t=(e=>{const t=(e=>{const t=e.value.replace(Gw,((e,t,o,n)=>t+t+o+o+n+n));return{value:t}})(e),o=Yw.exec(t.value);return null===o?["FFFFFF","FF","FF","FF"]:o})(e),o=parseInt(t[1],16),n=parseInt(t[2],16),r=parseInt(t[3],16);return i_(o,n,r,1)},c_=(e,t,o,n)=>{const r=parseInt(e,10),i=parseInt(t,10),s=parseInt(o,10),a=parseFloat(n);return i_(r,i,s,a)},d_=e=>{if("transparent"===e)return M.some(i_(0,0,0,0));const t=n_.exec(e);if(null!==t)return M.some(c_(t[1],t[2],t[3],"1"));const o=r_.exec(e);return null!==o?M.some(c_(o[1],o[2],o[3],o[4])):M.none()},u_=e=>`rgba(${e.red},${e.green},${e.blue},${e.alpha})`,h_=i_(255,0,0,1),m_=(e,t)=>{e.dispatch("ResizeContent",t)},p_=(e,t)=>{e.dispatch("TextColorChange",t)},g_=(e,t)=>e.dispatch("ResolveName",{name:t.nodeName.toLowerCase(),target:t}),f_=(e,t)=>()=>{e(),t()},v_=e=>y_(e,"NodeChange",(t=>{t.setEnabled(e.selection.isEditable())})),b_=(e,t)=>o=>{const n=v_(e)(o),r=((e,t)=>o=>{const n=Jl(),r=()=>{o.setActive(e.formatter.match(t));const r=e.formatter.formatChanged(t,o.setActive);n.set(r)};return e.initialized?r():e.once("init",r),()=>{e.off("init",r),n.clear()}})(e,t)(o);return()=>{n(),r()}},y_=(e,t,o)=>n=>{const r=()=>o(n),i=()=>{o(n),e.on(t,r)};return e.initialized?i():e.once("init",i),()=>{e.off("init",i),e.off(t,r)}},w_=e=>t=>()=>{e.undoManager.transact((()=>{e.focus(),e.execCommand("mceToggleFormat",!1,t.format)}))},__=(e,t)=>()=>e.execCommand(t);var x_=window.mailpoetTinymce.util.Tools.resolve("window.mailpoetTinymce.util.LocalStorage");const C_={},k_=e=>ve(C_,e).getOrThunk((()=>{const t=`tinymce-custom-colors-${e}`,o=x_.getItem(t);if(h(o)){const e=x_.getItem("tinymce-custom-colors");x_.setItem(t,m(e)?e:"[]")}const n=((e,t=10)=>{const o=x_.getItem(e),n=i(o)?JSON.parse(o):[],r=t-(s=n).length<0?s.slice(0,t):s;var s;const a=e=>{r.splice(e,1)};return{add:o=>{V(r,o).each(a),r.unshift(o),r.length>t&&r.pop(),x_.setItem(e,JSON.stringify(r))},state:()=>r.slice(0)}})(t,10);return C_[e]=n,n})),S_=(e,t)=>{k_(e).add(t)},T_=(e,t,o)=>({hue:e,saturation:t,value:o}),E_=e=>{let t=0,o=0,n=0;const r=e.red/255,i=e.green/255,s=e.blue/255,a=Math.min(r,Math.min(i,s)),l=Math.max(r,Math.max(i,s));return a===l?(n=a,T_(0,0,100*n)):(t=r===a?3:s===a?1:5,t=60*(t-(r===a?i-s:s===a?r-i:s-r)/(l-a)),o=(l-a)/l,n=l,T_(Math.round(t),Math.round(100*o),Math.round(100*n)))},O_=e=>Qw(a_(e)),M_=e=>{return(t=e,Kw(t)?M.some({value:Xw(t)}):M.none()).orThunk((()=>d_(e).map(Qw))).getOrThunk((()=>{const t=document.createElement("canvas");t.height=1,t.width=1;const o=t.getContext("2d");o.clearRect(0,0,t.width,t.height),o.fillStyle="#FFFFFF",o.fillStyle=e,o.fillRect(0,0,1,1);const n=o.getImageData(0,0,1,1).data,r=n[0],i=n[1],s=n[2],a=n[3];return Qw(i_(r,i,s,a))}));var t},A_="forecolor",B_="hilitecolor",N_=e=>{const t=[];for(let o=0;ot=>t.options.get(e),V_="#000000",D_=(e,t)=>t===A_&&e.options.isSet("color_map_foreground")?R_("color_map_foreground")(e):t===B_&&e.options.isSet("color_map_background")?R_("color_map_background")(e):R_("color_map")(e),P_=(e,t="default")=>Math.max(5,Math.ceil(Math.sqrt(D_(e,t).length))),I_=(e,t)=>{const o=R_("color_cols")(e),n=P_(e,t);return o===P_(e)?n:o},F_=(e,t="default")=>Math.round(t===A_?R_("color_cols_foreground")(e):t===B_?R_("color_cols_background")(e):R_("color_cols")(e)),L_=R_("custom_colors"),z_=R_("color_default_foreground"),H_=R_("color_default_background"),Z_=(e,t)=>{const o=Ie(e.selection.getStart()),n="hilitecolor"===t?Vr(o,(e=>{if($e(e)){const t=Vt(e,"background-color");return ke(d_(t).exists((e=>0!==e.alpha)),t)}return M.none()})).getOr("rgba(0, 0, 0, 0)"):Vt(o,"color");return d_(n).map((e=>"#"+Qw(e).value))},j_=e=>{const t="choiceitem",o={type:t,text:"Remove color",icon:"color-swatch-remove-color",value:"remove"};return e?[o,{type:t,text:"Custom color",icon:"color-picker",value:"custom"}]:[o]},U_=(e,t,o,n)=>{"custom"===o?X_(e)((o=>{o.each((o=>{S_(t,o),e.execCommand("mceApplyTextcolor",t,o),n(o)}))}),Z_(e,t).getOr(V_)):"remove"===o?(n(""),e.execCommand("mceRemoveTextcolor",t)):(n(o),e.execCommand("mceApplyTextcolor",t,o))},$_=(e,t,o)=>e.concat((e=>L(k_(e).state(),(e=>({type:"choiceitem",text:e,icon:"checkmark",value:e}))))(t).concat(j_(o))),W_=(e,t,o)=>n=>{n($_(e,t,o))},q_=(e,t,o)=>{const n="forecolor"===t?"tox-icon-text-color__color":"tox-icon-highlight-bg-color__color";e.setIconFill(n,o)},G_=(e,t)=>o=>{const n=Z_(e,t);return we(n,o.toUpperCase())},Y_=(e,t,o,n,r)=>{e.ui.registry.addSplitButton(t,{tooltip:n,presets:"color",icon:"forecolor"===t?"text-color":"highlight-bg-color",select:G_(e,o),columns:F_(e,o),fetch:W_(D_(e,o),o,L_(e)),onAction:t=>{U_(e,o,r.get(),v)},onItemAction:(n,i)=>{U_(e,o,i,(o=>{r.set(o),p_(e,{name:t,color:o})}))},onSetup:o=>{q_(o,t,r.get());const n=e=>{e.name===t&&q_(o,e.name,e.color)};return e.on("TextColorChange",n),f_(v_(e)(o),(()=>{e.off("TextColorChange",n)}))}})},K_=(e,t,o,n,r)=>{e.ui.registry.addNestedMenuItem(t,{text:n,icon:"forecolor"===t?"text-color":"highlight-bg-color",onSetup:o=>(q_(o,t,r.get()),v_(e)(o)),getSubmenuItems:()=>[{type:"fancymenuitem",fancytype:"colorswatch",select:G_(e,o),initData:{storageKey:o},onAction:n=>{U_(e,o,n.value,(o=>{r.set(o),p_(e,{name:t,color:o})}))}}]})},X_=e=>(t,o)=>{let n=!1;const r={colorpicker:o};e.windowManager.open({title:"Color Picker",size:"normal",body:{type:"panel",items:[{type:"colorpicker",name:"colorpicker",label:"Color"}]},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:r,onAction:(e,t)=>{"hex-valid"===t.name&&(n=t.value)},onSubmit:o=>{const r=o.getData().colorpicker;n?(t(M.from(r)),o.close()):e.windowManager.alert(e.translate(["Invalid hex color code: {0}",r]))},onClose:v,onCancel:()=>{t(M.none())}})},J_=(e,t,o,n,r,i,s,a)=>{const l=Xb(t),c=Q_(t,o,n,"color"!==r?"normal":"color",i,s,a);return ey(e,l,c,n,{menuType:r})},Q_=(e,t,o,n,r,i,s)=>_e(L(e,(a=>{return"choiceitem"===a.type?(l=a,qn("choicemenuitem",Qy,l)).fold(Jb,(a=>M.some(((e,t,o,n,r,i,s,a=!0)=>{const l=Zw({presets:o,textContent:t?e.text:M.none(),htmlContent:M.none(),ariaLabel:e.text,iconContent:e.icon,shortcutContent:t?e.shortcut:M.none(),checkMark:t?M.some(zw(s.icons)):M.none(),caret:M.none(),value:e.value},s,a);return fn(Nw({data:Rw(e),enabled:e.enabled,getApi:e=>({setActive:t=>{dg.set(e,t)},isActive:()=>dg.isOn(e),isEnabled:()=>!Dh.isDisabled(e),setEnabled:t=>Dh.set(e,!t)}),onAction:t=>n(e.value),onSetup:e=>(e.setActive(r),v),triggersSubmenu:!1,itemBehaviours:[]},l,i,s),{toggling:{toggleClass:yb,toggleOnExecute:!1,selected:e.active,exclusive:!0}})})(a,1===o,n,t,i(a.value),r,s,Xb(e))))):M.none();var l}))),ex=(e,t)=>{const o=Mb(t);return 1===e?{mode:"menu",moveOnTab:!0}:"auto"===e?{mode:"grid",selector:"."+o.item,initSize:{numColumns:1,numRows:1}}:{mode:"matrix",rowSelector:"."+("color"===t?"tox-swatches__row":"tox-collection__group"),previousSelector:e=>"color"===t?pa(e.element,"[aria-checked=true]"):M.none()}},tx=ls("cell-over"),ox=ls("cell-execute"),nx=(e,t,o)=>{const n=o=>Vi(o,ox,{row:e,col:t}),r=(e,t)=>{t.stop(),n(e)};return ia({dom:{tag:"div",attributes:{role:"button","aria-label":o}},behaviours:Cl([Xp("insert-table-picker-cell",[Zi(qr(),og.focus),Zi(ui(),n),Zi(ei(),r),Zi(mi(),r)]),dg.config({toggleClass:"tox-insert-table-picker__selected",toggleOnExecute:!1}),og.config({onFocus:o=>Vi(o,tx,{row:e,col:t})})])})},rx=e=>G(e,(e=>L(e,sa))),ix=(e,t)=>ta(`${t}x${e}`),sx={inserttable:(e,t)=>{const o=(e=>(t,o)=>e.shared.providers.translate(`${o} columns, ${t} rows`))(t),n=((e,t,o)=>{const n=[];for(let t=0;t<10;t++){const o=[];for(let n=0;n<10;n++){const r=e(t+1,n+1);o.push(nx(t,n,r))}n.push(o)}return n})(o),r=ix(0,0),i=$g({dom:{tag:"span",classes:["tox-insert-table-picker__label"]},components:[r],behaviours:Cl([Kp.config({})])});return{type:"widget",data:{value:ls("widget-id")},dom:{tag:"div",classes:["tox-fancymenuitem"]},autofocus:!0,components:[Ww.widget({dom:{tag:"div",classes:["tox-insert-table-picker"]},components:rx(n).concat(i.asSpec()),behaviours:Cl([Xp("insert-table-picker",[Ki((e=>{Kp.set(i.get(e),[r])})),Wi(tx,((e,t,o)=>{const{row:r,col:s}=o.event;((e,t,o,n,r)=>{for(let n=0;n<10;n++)for(let r=0;r<10;r++)dg.set(e[n][r],n<=t&&r<=o)})(n,r,s),Kp.set(i.get(e),[ix(r+1,s+1)])})),Wi(ox,((t,o,n)=>{const{row:r,col:i}=n.event;e.onAction({numRows:r+1,numColumns:i+1}),Ri(t,gi())}))]),Hp.config({initSize:{numRows:10,numColumns:10},mode:"flatgrid",selector:'[role="button"]'})])})]}},colorswatch:(e,t)=>{const o=((e,t)=>{const o=e.initData.allowCustomColors&&t.colorinput.hasCustomColors();return e.initData.colors.fold((()=>$_(t.colorinput.getColors(e.initData.storageKey),e.initData.storageKey,o)),(e=>e.concat(j_(o))))})(e,t),n=t.colorinput.getColorCols(e.initData.storageKey),r="color",i={...J_(ls("menu-value"),o,(t=>{e.onAction({value:t})}),n,r,pb.CLOSE_ON_EXECUTE,e.select.getOr(E),t.shared.providers),markers:Mb(r),movement:ex(n,r)};return{type:"widget",data:{value:ls("widget-id")},dom:{tag:"div",classes:["tox-fancymenuitem"]},autofocus:!0,components:[Ww.widget(Bg.sketch(i))]}}},ax=e=>({type:"separator",dom:{tag:"div",classes:[fb,"tox-collection__group-heading"]},components:e.text.map(ta).toArray()});var lx=Object.freeze({__proto__:null,getCoupled:(e,t,o,n)=>o.getOrCreate(e,t,n),getExistingCoupled:(e,t,o,n)=>o.getExisting(e,t,n)}),cx=[nr("others",Wn(rn.value,Pn()))],dx=Object.freeze({__proto__:null,init:()=>{const e={},t=(t,o)=>{if(0===se(t.others).length)throw new Error("Cannot find any known coupled components");return ve(e,o)},o=w({});return Ts({readState:o,getExisting:(e,o,n)=>t(o,n).orThunk((()=>(ve(o.others,n).getOrDie("No information found for coupled component: "+n),M.none()))),getOrCreate:(o,n,r)=>t(n,r).getOrThunk((()=>{const t=ve(n.others,r).getOrDie("No information found for coupled component: "+r)(o),i=o.getSystem().build(t);return e[r]=i,i}))})}});const ux=Sl({fields:cx,name:"coupling",apis:lx,state:dx}),hx=e=>{let t=M.none(),o=[];const n=e=>{r()?i(e):o.push(e)},r=()=>t.isSome(),i=e=>{t.each((t=>{setTimeout((()=>{e(t)}),0)}))};return e((e=>{r()||(t=M.some(e),z(o,i),o=[])})),{get:n,map:e=>hx((t=>{n((o=>{t(e(o))}))})),isReady:r}},mx={nu:hx,pure:e=>hx((t=>{t(e)}))},px=e=>{setTimeout((()=>{throw e}),0)},gx=e=>{const t=t=>{e().then(t,px)};return{map:t=>gx((()=>e().then(t))),bind:t=>gx((()=>e().then((e=>t(e).toPromise())))),anonBind:t=>gx((()=>e().then((()=>t.toPromise())))),toLazy:()=>mx.nu(t),toCached:()=>{let t=null;return gx((()=>(null===t&&(t=e()),t)))},toPromise:e,get:t}},fx=e=>gx((()=>new Promise(e))),vx=e=>gx((()=>Promise.resolve(e))),bx=w("sink"),yx=w(Uu({name:bx(),overrides:w({dom:{tag:"div"},behaviours:Cl([xd.config({useFixed:O})]),events:Li([qi(Kr()),qi(jr()),qi(ei())])})})),wx=(e,t)=>{const o=e.getHotspot(t).getOr(t),n="hotspot",r=e.getAnchorOverrides();return e.layouts.fold((()=>({type:n,hotspot:o,overrides:r})),(e=>({type:n,hotspot:o,overrides:r,layouts:e})))},_x=(e,t,o,n,r,i,s)=>{const a=((e,t,o,n,r,i,s)=>{const a=((e,t,o)=>(0,e.fetch)(o).map(t))(e,t,n),l=kx(n,e);return a.map((e=>e.bind((e=>M.from(zg.sketch({...i.menu(),uid:gs(""),data:e,highlightOnOpen:s,onOpenMenu:(e,t)=>{const n=l().getOrDie();xd.position(n,t,{anchor:o}),Gd.decloak(r)},onOpenSubmenu:(e,t,o)=>{const n=l().getOrDie();xd.position(n,o,{anchor:{type:"submenu",item:t}}),Gd.decloak(r)},onRepositionMenu:(e,t,n)=>{const r=l().getOrDie();xd.position(r,t,{anchor:o}),z(n,(e=>{xd.position(r,e.triggeredMenu,{anchor:{type:"submenu",item:e.triggeringItem}})}))},onEscape:()=>(og.focus(n),Gd.close(r),M.some(!0))}))))))})(e,t,wx(e,o),o,n,r,s);return a.map((e=>(e.fold((()=>{Gd.isOpen(n)&&Gd.close(n)}),(e=>{Gd.cloak(n),Gd.open(n,e),i(n)})),n)))},xx=(e,t,o,n,r,i,s)=>(Gd.close(n),vx(n)),Cx=(e,t,o,n,r,i)=>{const s=ux.getCoupled(o,"sandbox");return(Gd.isOpen(s)?xx:_x)(e,t,o,s,n,r,i)},kx=(e,t)=>e.getSystem().getByUid(t.uid+"-"+bx()).map((e=>()=>rn.value(e))).getOrThunk((()=>t.lazySink.fold((()=>()=>rn.error(new Error("No internal sink is specified, nor could an external sink be found"))),(t=>()=>t(e))))),Sx=e=>{Gd.getState(e).each((e=>{zg.repositionMenus(e)}))},Tx=(e,t,o)=>{const n=va(),r=kx(t,e);return{dom:{tag:"div",classes:e.sandboxClasses,attributes:{id:n.id,role:"listbox"}},behaviours:yu(e.sandboxBehaviours,[pu.config({store:{mode:"memory",initialValue:t}}),Gd.config({onOpen:(r,i)=>{const s=wx(e,t);n.link(t.element),e.matchWidth&&((e,t,o)=>{const n=_h.getCurrent(t).getOr(t),r=Xt(e.element);o?Bt(n.element,"min-width",r+"px"):((e,t)=>{Kt.set(e,t)})(n.element,r)})(s.hotspot,i,e.useMinWidth),e.onOpen(s,r,i),void 0!==o&&void 0!==o.onOpen&&o.onOpen(r,i)},onClose:(e,r)=>{n.unlink(t.element),void 0!==o&&void 0!==o.onClose&&o.onClose(e,r)},isPartOf:(e,o,n)=>ba(o,n)||ba(t,n),getAttachPoint:()=>r().getOrDie()}),_h.config({find:e=>Gd.getState(e).bind((e=>_h.getCurrent(e)))}),Ml.config({channels:{...Qd({isExtraPart:E}),...tu({doReposition:Sx})}})])}},Ex=e=>{const t=ux.getCoupled(e,"sandbox");Sx(t)},Ox=()=>[yr("sandboxClasses",[]),bu("sandboxBehaviours",[_h,Ml,Gd,pu])],Mx=w([or("dom"),or("fetch"),Ba("onOpen"),Na("onExecute"),yr("getHotspot",M.some),yr("getAnchorOverrides",w({})),_c(),gu("dropdownBehaviours",[dg,ux,Hp,og]),or("toggleClass"),yr("eventOrder",{}),ur("lazySink"),yr("matchWidth",!1),yr("useMinWidth",!1),ur("role")].concat(Ox())),Ax=w([ju({schema:[Oa(),yr("fakeFocus",!1)],name:"menu",defaults:e=>({onExecute:e.onExecute})}),yx()]),Bx=vh({name:"Dropdown",configFields:Mx(),partFields:Ax(),factory:(e,t,o,n)=>{const r=e=>{Gd.getState(e).each((e=>{zg.highlightPrimary(e)}))},i=(t,o,r)=>Cx(e,_,t,n,o,r),s={expand:e=>{dg.isOn(e)||i(e,v,Fg.HighlightNone).get(v)},open:e=>{dg.isOn(e)||i(e,v,Fg.HighlightMenuAndItem).get(v)},refetch:t=>ux.getExistingCoupled(t,"sandbox").fold((()=>i(t,v,Fg.HighlightMenuAndItem).map(v)),(o=>_x(e,_,t,o,n,v,Fg.HighlightMenuAndItem).map(v))),isOpen:dg.isOn,close:e=>{dg.isOn(e)&&i(e,v,Fg.HighlightMenuAndItem).get(v)},repositionMenus:e=>{dg.isOn(e)&&Ex(e)}},a=(e,t)=>(Di(e),M.some(!0));return{uid:e.uid,dom:e.dom,components:t,behaviours:vu(e.dropdownBehaviours,[dg.config({toggleClass:e.toggleClass,aria:{mode:"expanded"}}),ux.config({others:{sandbox:t=>Tx(e,t,{onOpen:()=>dg.on(t),onClose:()=>dg.off(t)})}}),Hp.config({mode:"special",onSpace:a,onEnter:a,onDown:(e,t)=>{if(Bx.isOpen(e)){const t=ux.getCoupled(e,"sandbox");r(t)}else Bx.open(e);return M.some(!0)},onEscape:(e,t)=>Bx.isOpen(e)?(Bx.close(e),M.some(!0)):M.none()}),og.config({})]),events:hg(M.some((e=>{i(e,r,Fg.HighlightMenuAndItem).get(v)}))),eventOrder:{...e.eventOrder,[ui()]:["disabling","toggling","alloy.base.behaviour"]},apis:s,domModification:{attributes:{"aria-haspopup":"true",...e.role.fold((()=>({})),(e=>({role:e}))),..."button"===e.dom.tag?{type:("type",ve(e.dom,"attributes").bind((e=>ve(e,"type")))).getOr("button")}:{}}}}},apis:{open:(e,t)=>e.open(t),refetch:(e,t)=>e.refetch(t),expand:(e,t)=>e.expand(t),close:(e,t)=>e.close(t),isOpen:(e,t)=>e.isOpen(t),repositionMenus:(e,t)=>e.repositionMenus(t)}}),Nx=(e,t,o)=>{Zb(e).each((e=>{var n;((e,t)=>{Tt(t.element,"id").each((t=>Ct(e.element,"aria-activedescendant",t)))})(e,o),(Zs((n=t).element,$b)?M.some(n.element):pa(n.element,"."+$b)).each((t=>{Tt(t,"id").each((t=>Ct(e.element,"aria-controls",t)))}))})),Ct(o.element,"aria-selected","true")},Rx=(e,t,o)=>{Ct(o.element,"aria-selected","false")},Vx=e=>ux.getExistingCoupled(e,"sandbox").bind(Hb).map(jb).map((e=>e.fetchPattern)).getOr("");var Dx;!function(e){e[e.ContentFocus=0]="ContentFocus",e[e.UiFocus=1]="UiFocus"}(Dx||(Dx={}));const Px=(e,t,o,n,r)=>{const i=o.shared.providers,s=e=>r?{...e,shortcut:M.none(),icon:e.text.isSome()?M.none():e.icon}:e;switch(e.type){case"menuitem":return(a=e,qn("menuitem",rw,a)).fold(Jb,(e=>M.some(((e,t,o,n=!0)=>{const r=Zw({presets:"normal",iconContent:e.icon,textContent:e.text,htmlContent:M.none(),ariaLabel:e.text,caret:M.none(),checkMark:M.none(),shortcutContent:e.shortcut},o,n);return Nw({data:Rw(e),getApi:e=>({isEnabled:()=>!Dh.isDisabled(e),setEnabled:t=>Dh.set(e,!t)}),enabled:e.enabled,onAction:e.onAction,onSetup:e.onSetup,triggersSubmenu:!1,itemBehaviours:[]},r,t,o)})(s(e),t,i,n))));case"nestedmenuitem":return(e=>qn("nestedmenuitem",iw,e))(e).fold(Jb,(e=>M.some(((e,t,o,n=!0,r=!1)=>{const i=r?(s=o.icons,Dw("chevron-down",s,[xb])):(e=>Dw("chevron-right",e,[xb]))(o.icons);var s;const a=Zw({presets:"normal",iconContent:e.icon,textContent:e.text,htmlContent:M.none(),ariaLabel:e.text,caret:M.some(i),checkMark:M.none(),shortcutContent:e.shortcut},o,n);return Nw({data:Rw(e),getApi:e=>({isEnabled:()=>!Dh.isDisabled(e),setEnabled:t=>Dh.set(e,!t),setIconFill:(t,o)=>{pa(e.element,`svg path[class="${t}"], rect[class="${t}"]`).each((e=>{Ct(e,"fill",o)}))}}),enabled:e.enabled,onAction:v,onSetup:e.onSetup,triggersSubmenu:!0,itemBehaviours:[]},a,t,o)})(s(e),t,i,n,r))));case"togglemenuitem":return(e=>qn("togglemenuitem",sw,e))(e).fold(Jb,(e=>M.some(((e,t,o,n=!0)=>{const r=Zw({iconContent:e.icon,textContent:e.text,htmlContent:M.none(),ariaLabel:e.text,checkMark:M.some(zw(o.icons)),caret:M.none(),shortcutContent:e.shortcut,presets:"normal",meta:e.meta},o,n);return fn(Nw({data:Rw(e),enabled:e.enabled,getApi:e=>({setActive:t=>{dg.set(e,t)},isActive:()=>dg.isOn(e),isEnabled:()=>!Dh.isDisabled(e),setEnabled:t=>Dh.set(e,!t)}),onAction:e.onAction,onSetup:e.onSetup,triggersSubmenu:!1,itemBehaviours:[]},r,t,o),{toggling:{toggleClass:yb,toggleOnExecute:!1,selected:e.active}})})(s(e),t,i,n))));case"separator":return(e=>qn("separatormenuitem",My,e))(e).fold(Jb,(e=>M.some(ax(e))));case"fancymenuitem":return(e=>qn("fancymenuitem",nw,e))(e).fold(Jb,(e=>((e,t)=>ve(sx,e.fancytype).map((o=>o(e,t))))(e,o)));default:return console.error("Unknown item in general menu",e),M.none()}var a},Ix=(e,t,o,n,r,i,s)=>{const a=1===n,l=!a||Xb(e);return _e(L(e,(e=>{switch(e.type){case"separator":return(n=e,qn("Autocompleter.Separator",My,n)).fold(Jb,(e=>M.some(ax(e))));case"cardmenuitem":return(e=>qn("cardmenuitem",Jy,e))(e).fold(Jb,(e=>M.some(((e,t,o,n)=>{const r={dom:Hw(e.label),optComponents:[M.some({dom:{tag:"div",classes:[kb,Sb]},components:$w(e.items,n)})]};return Nw({data:Rw({text:M.none(),...e}),enabled:e.enabled,getApi:e=>({isEnabled:()=>!Dh.isDisabled(e),setEnabled:t=>{Dh.set(e,!t),z(Gc(e.element,"*"),(o=>{e.getSystem().getByDom(o).each((e=>{e.hasConfigured(Dh)&&Dh.set(e,!t)}))}))}}),onAction:e.onAction,onSetup:e.onSetup,triggersSubmenu:!1,itemBehaviours:M.from(n.itemBehaviours).getOr([])},r,t,o.providers)})({...e,onAction:t=>{e.onAction(t),o(e.value,e.meta)}},r,i,{itemBehaviours:jw(e.meta,i),cardText:{matchText:t,highlightOn:s}}))));default:return(e=>qn("Autocompleter.Item",Ay,e))(e).fold(Jb,(e=>M.some(((e,t,o,n,r,i,s,a=!0)=>{const l=Zw({presets:n,textContent:M.none(),htmlContent:o?e.text.map((e=>Uw(e,t))):M.none(),ariaLabel:e.text,iconContent:e.icon,shortcutContent:M.none(),checkMark:M.none(),caret:M.none(),value:e.value},s.providers,a,e.icon);return Nw({data:Rw(e),enabled:e.enabled,getApi:w({}),onAction:t=>r(e.value,e.meta),onSetup:w(v),triggersSubmenu:!1,itemBehaviours:jw(e.meta,s)},l,i,s.providers)})(e,t,a,"normal",o,r,i,l))))}var n})))},Fx=(e,t,o,n,r,i)=>{const s=Xb(t),a=_e(L(t,(e=>{const t=e=>Px(e,o,n,(e=>r?!be(e,"text"):s)(e),r);return"nestedmenuitem"===e.type&&e.getSubmenuItems().length<=0?t({...e,enabled:!1}):t(e)}))),l=(e=>"no-search"===e.searchMode?{menuType:"normal"}:{menuType:"searchable",searchMode:e})(i);return(r?Qb:ey)(e,s,a,1,l)},Lx=e=>zg.singleData(e.value,e),zx=(e,t)=>{const o=Or(!1),n=Or(!1),r=ia(Hg.sketch({dom:{tag:"div",classes:["tox-autocompleter"]},components:[],fireDismissalEventInstead:{},inlineBehaviours:Cl([Xp("dismissAutocompleter",[Zi(ki(),(()=>c()))])]),lazySink:t.getSink})),i=()=>Hg.isOpen(r),s=n.get,a=()=>{i()&&Hg.hide(r)},l=()=>Hg.getContent(r).bind((e=>te(e.components(),0))),c=()=>e.execCommand("mceAutocompleterClose"),d=n=>{const i=(n=>{const r=ie(n,(e=>M.from(e.columns))).getOr(1);return G(n,(n=>{const i=n.items;return Ix(i,n.matchText,((t,r)=>{const i=e.selection.getRng();((e,t)=>hb(Ie(t.startContainer)).map((t=>{const o=e.createRng();return o.selectNode(t.dom),o})))(e.dom,i).each((i=>{const s={hide:()=>c(),reload:t=>{a(),e.execCommand("mceAutocompleterReload",!1,{fetchOptions:t})}};o.set(!0),n.onAction(s,i,t,r),o.set(!1)}))}),r,pb.BUBBLE_TO_SANDBOX,t,n.highlightOn)}))})(n);i.length>0?((t,o)=>{var n;(n=Ie(e.getBody()),pa(n,ub)).each((n=>{const i=ie(t,(e=>M.from(e.columns))).getOr(1);Hg.showMenuAt(r,{anchor:{type:"node",root:Ie(e.getBody()),node:M.from(n)}},((e,t,o,n)=>{const r=ex(t,n),i=Mb(n);return{data:Lx({...e,movement:r,menuBehaviours:lw("auto"!==t?[]:[Ki(((e,t)=>{aw(e,4,i.item).each((({numColumns:t,numRows:o})=>{Hp.setGridSize(e,o,t)}))}))])}),menu:{markers:Mb(n),fakeFocus:o===Dx.ContentFocus}}})(ey("autocompleter-value",!0,o,i,{menuType:"normal"}),i,Dx.ContentFocus,"normal"))})),l().each($h.highlightFirst)})(n,i):a()};e.on("AutocompleterStart",(({lookupData:e})=>{n.set(!0),o.set(!1),d(e)})),e.on("AutocompleterUpdate",(({lookupData:e})=>d(e))),e.on("AutocompleterEnd",(()=>{a(),n.set(!1),o.set(!1)}));((e,t)=>{const o=(e,t)=>{Vi(e,Kr(),{raw:t})},n=()=>e.getMenu().bind($h.getHighlighted);t.on("keydown",(t=>{const r=t.which;e.isActive()&&(e.isMenuOpen()?13===r?(n().each(Di),t.preventDefault()):40===r?(n().fold((()=>{e.getMenu().each($h.highlightFirst)}),(e=>{o(e,t)})),t.preventDefault(),t.stopImmediatePropagation()):37!==r&&38!==r&&39!==r||n().each((e=>{o(e,t),t.preventDefault(),t.stopImmediatePropagation()})):13!==r&&38!==r&&40!==r||e.cancelIfNecessary())})),t.on("NodeChange",(t=>{e.isActive()&&!e.isProcessingAction()&&hb(Ie(t.element)).isNone()&&e.cancelIfNecessary()}))})({cancelIfNecessary:c,isMenuOpen:i,isActive:s,isProcessingAction:o.get,getMenu:l},e)},Hx=["visible","hidden","clip"],Zx=e=>Ae(e).length>0&&!D(Hx,e),jx=e=>{if(Ue(e)){const t=Vt(e,"overflow-x"),o=Vt(e,"overflow-y");return Zx(t)||Zx(o)}return!1},Ux=(e,t)=>lb(e)?(e=>{const t=qc(e,jx),o=0===t.length?vt(e).map(bt).map((e=>qc(e,jx))).getOr([]):t;return oe(o).map((e=>({element:e,others:o.slice(1)})))})(t):M.none(),$x=e=>{const t=[...L(e.others,Xo),en()];return((e,t)=>U(t,((e,t)=>Qo(e,t)),e))(Xo(e.element),t)},Wx=(e,t,o)=>ga(e,t,o).isSome(),qx=(e,t)=>{let o=null;return{cancel:()=>{null!==o&&(clearTimeout(o),o=null)},schedule:(...n)=>{o=setTimeout((()=>{e.apply(null,n),o=null}),t)}}},Gx=e=>{const t=e.raw;return void 0===t.touches||1!==t.touches.length?M.none():M.some(t.touches[0])},Yx=(e,t)=>{const o={stopBackspace:!0,...t},n=(e=>{const t=Ql(),o=Or(!1),n=qx((t=>{e.triggerEvent(pi(),t),o.set(!0)}),400),r=Br([{key:Lr(),value:e=>(Gx(e).each((r=>{n.cancel();const i={x:r.clientX,y:r.clientY,target:e.target};n.schedule(e),o.set(!1),t.set(i)})),M.none())},{key:zr(),value:e=>(n.cancel(),Gx(e).each((e=>{t.on((o=>{((e,t)=>{const o=Math.abs(e.clientX-t.x),n=Math.abs(e.clientY-t.y);return o>5||n>5})(e,o)&&t.clear()}))})),M.none())},{key:Hr(),value:r=>(n.cancel(),t.get().filter((e=>Je(e.target,r.target))).map((t=>o.get()?(r.prevent(),!1):e.triggerEvent(mi(),r))))}]);return{fireIfReady:(e,t)=>ve(r,t).bind((t=>t(e)))}})(o),r=L(["touchstart","touchmove","touchend","touchcancel","gesturestart","mousedown","mouseup","mouseover","mousemove","mouseout","click"].concat(["selectstart","input","contextmenu","change","transitionend","transitioncancel","drag","dragstart","dragend","dragenter","dragleave","dragover","drop","keyup"]),(t=>tc(e,t,(e=>{n.fireIfReady(e,t).each((t=>{t&&e.kill()})),o.triggerEvent(t,e)&&e.kill()})))),i=Ql(),s=tc(e,"paste",(e=>{n.fireIfReady(e,"paste").each((t=>{t&&e.kill()})),o.triggerEvent("paste",e)&&e.kill(),i.set(setTimeout((()=>{o.triggerEvent(ci(),e)}),0))})),a=tc(e,"keydown",(e=>{o.triggerEvent("keydown",e)?e.kill():o.stopBackspace&&(e=>e.raw.which===Wh[0]&&!D(["input","textarea"],Ze(e.target))&&!Wx(e.target,'[contenteditable="true"]'))(e)&&e.prevent()})),l=tc(e,"focusin",(e=>{o.triggerEvent("focusin",e)&&e.kill()})),c=Ql(),d=tc(e,"focusout",(e=>{o.triggerEvent("focusout",e)&&e.kill(),c.set(setTimeout((()=>{o.triggerEvent(li(),e)}),0))}));return{unbind:()=>{z(r,(e=>{e.unbind()})),a.unbind(),l.unbind(),d.unbind(),s.unbind(),i.on(clearTimeout),c.on(clearTimeout)}}},Kx=(e,t)=>{const o=ve(e,"target").getOr(t);return Or(o)},Xx=Mr([{stopped:[]},{resume:["element"]},{complete:[]}]),Jx=(e,t,o,n,r,i)=>{const s=e(t,n),a=((e,t)=>{const o=Or(!1),n=Or(!1);return{stop:()=>{o.set(!0)},cut:()=>{n.set(!0)},isStopped:o.get,isCut:n.get,event:e,setSource:t.set,getSource:t.get}})(o,r);return s.fold((()=>(i.logEventNoHandlers(t,n),Xx.complete())),(e=>{const o=e.descHandler;return Ms(o)(a),a.isStopped()?(i.logEventStopped(t,e.element,o.purpose),Xx.stopped()):a.isCut()?(i.logEventCut(t,e.element,o.purpose),Xx.complete()):rt(e.element).fold((()=>(i.logNoParent(t,e.element,o.purpose),Xx.complete())),(n=>(i.logEventResponse(t,e.element,o.purpose),Xx.resume(n))))}))},Qx=(e,t,o,n,r,i)=>Jx(e,t,o,n,r,i).fold(O,(n=>Qx(e,t,o,n,r,i)),E),eC=(e,t,o,n,r)=>{const i=Kx(o,n);return Qx(e,t,o,n,i,r)},tC=()=>{const e=(()=>{const e={};return{registerId:(t,o,n)=>{le(n,((n,r)=>{const i=void 0!==e[r]?e[r]:{};i[o]=((e,t)=>({cHandler:C.apply(void 0,[e.handler].concat(t)),purpose:e.purpose}))(n,t),e[r]=i}))},unregisterId:t=>{le(e,((e,o)=>{be(e,t)&&delete e[t]}))},filterByType:t=>ve(e,t).map((e=>pe(e,((e,t)=>((e,t)=>({id:e,descHandler:t}))(t,e))))).getOr([]),find:(t,o,n)=>ve(e,o).bind((e=>Vr(n,(t=>((e,t)=>ps(t).bind((t=>ve(e,t))).map((e=>((e,t)=>({element:e,descHandler:t}))(t,e))))(e,t)),t)))}})(),t={},o=o=>{ps(o.element).each((o=>{delete t[o],e.unregisterId(o)}))};return{find:(t,o,n)=>e.find(t,o,n),filter:t=>e.filterByType(t),register:n=>{const r=(e=>{const t=e.element;return ps(t).getOrThunk((()=>((e,t)=>{const o=ls(us+"uid-");return ms(t,o),o})(0,e.element)))})(n);ye(t,r)&&((e,n)=>{const r=t[n];if(r!==e)throw new Error('The tagId "'+n+'" is already used by: '+ns(r.element)+"\nCannot use it for: "+ns(e.element)+"\nThe conflicting element is"+(yt(r.element)?" ":" not ")+"already in the DOM");o(e)})(n,r);const i=[n];e.registerId(i,r,n.events),t[r]=n},unregister:o,getById:e=>ve(t,e)}},oC=fh({name:"Container",factory:e=>{const{attributes:t,...o}=e.dom;return{uid:e.uid,dom:{tag:"div",attributes:{role:"presentation",...t},...o},components:e.components,behaviours:fu(e.containerBehaviours),events:e.events,domModification:e.domModification,eventOrder:e.eventOrder}},configFields:[yr("components",[]),gu("containerBehaviours",[]),yr("events",{}),yr("domModification",{}),yr("eventOrder",{})]}),nC=e=>{const t=t=>rt(e.element).fold(O,(e=>Je(t,e))),o=tC(),n=(e,n)=>o.find(t,e,n),r=Yx(e.element,{triggerEvent:(e,t)=>xa(e,t.target,(o=>((e,t,o,n)=>eC(e,t,o,o.target,n))(n,e,t,o)))}),i={debugInfo:w("real"),triggerEvent:(e,t,o)=>{xa(e,t,(r=>eC(n,e,o,t,r)))},triggerFocus:(e,t)=>{ps(e).fold((()=>{Bl(e)}),(o=>{xa(ai(),e,(o=>(((e,t,o,n,r)=>{const i=Kx(o,n);Jx(e,t,o,n,i,r)})(n,ai(),{originator:t,kill:v,prevent:v,target:e},e,o),!1)))}))},triggerEscape:(e,t)=>{i.triggerEvent("keydown",e.element,t.event)},getByUid:e=>p(e),getByDom:e=>g(e),build:ia,buildOrPatch:ra,addToGui:e=>{l(e)},removeFromGui:e=>{c(e)},addToWorld:e=>{s(e)},removeFromWorld:e=>{a(e)},broadcast:e=>{u(e)},broadcastOn:(e,t)=>{h(e,t)},broadcastEvent:(e,t)=>{m(e,t)},isConnected:O},s=e=>{e.connect(i),We(e.element)||(o.register(e),z(e.components(),s),i.triggerEvent(vi(),e.element,{target:e.element}))},a=e=>{We(e.element)||(z(e.components(),a),o.unregister(e)),e.disconnect()},l=t=>{Md(e,t)},c=e=>{Nd(e)},d=e=>{const t=o.filter(di());z(t,(t=>{const o=t.descHandler;Ms(o)(e)}))},u=e=>{d({universal:!0,data:e})},h=(e,t)=>{d({universal:!1,channels:e,data:t})},m=(e,t)=>((e,t,o)=>{const n=(e=>{const t=Or(!1);return{stop:()=>{t.set(!0)},cut:v,isStopped:t.get,isCut:E,event:e,setSource:S("Cannot set source of a broadcasted event"),getSource:S("Cannot get source of a broadcasted event")}})(t);return z(e,(e=>{const t=e.descHandler;Ms(t)(n)})),n.isStopped()})(o.filter(e),t),p=e=>o.getById(e).fold((()=>rn.error(new Error('Could not find component with uid: "'+e+'" in system.'))),rn.value),g=e=>{const t=ps(e).getOr("not found");return p(t)};return s(e),{root:e,element:e.element,destroy:()=>{r.unbind(),Ho(e.element)},add:l,remove:c,getByUid:p,getByDom:g,addToWorld:s,removeFromWorld:a,broadcast:u,broadcastOn:h,broadcastEvent:m}},rC=w([yr("prefix","form-field"),gu("fieldBehaviours",[_h,pu])]),iC=w([Uu({schema:[or("dom")],name:"label"}),Uu({factory:{sketch:e=>({uid:e.uid,dom:{tag:"span",styles:{display:"none"},attributes:{"aria-hidden":"true"},innerHtml:e.text}})},schema:[or("text")],name:"aria-descriptor"}),Zu({factory:{sketch:e=>{const t=((e,t)=>{const o={};return le(e,((e,n)=>{D(t,n)||(o[n]=e)})),o})(e,["factory"]);return e.factory.sketch(t)}},schema:[or("factory")],name:"field"})]),sC=vh({name:"FormField",configFields:rC(),partFields:iC(),factory:(e,t,o,n)=>{const r=vu(e.fieldBehaviours,[_h.config({find:t=>oh(t,e,"field")}),pu.config({store:{mode:"manual",getValue:e=>_h.getCurrent(e).bind(pu.getValue),setValue:(e,t)=>{_h.getCurrent(e).each((e=>{pu.setValue(e,t)}))}}})]),i=Li([Ki(((t,o)=>{const n=rh(t,e,["label","field","aria-descriptor"]);n.field().each((t=>{const o=ls(e.prefix);n.label().each((e=>{Ct(e.element,"for",o),Ct(t.element,"id",o)})),n["aria-descriptor"]().each((o=>{const n=ls(e.prefix);Ct(o.element,"id",n),Ct(t.element,"aria-describedby",n)}))}))}))]),s={getField:t=>oh(t,e,"field"),getLabel:t=>oh(t,e,"label")};return{uid:e.uid,dom:e.dom,components:t,behaviours:r,events:i,apis:s}},apis:{getField:(e,t)=>e.getField(t),getLabel:(e,t)=>e.getLabel(t)}});var aC=Object.freeze({__proto__:null,exhibit:(e,t)=>Os({attributes:Br([{key:t.tabAttr,value:"true"}])})}),lC=[yr("tabAttr","data-alloy-tabstop")];const cC=Sl({fields:lC,name:"tabstopping",active:aC});var dC=window.mailpoetTinymce.util.Tools.resolve("mailpoetTinymce.html.Entities");const uC=(e,t,o,n)=>{const r=hC(e,t,o,n);return sC.sketch(r)},hC=(e,t,o,n)=>({dom:mC(o),components:e.toArray().concat([t]),fieldBehaviours:Cl(n)}),mC=e=>({tag:"div",classes:["tox-form__group"].concat(e)}),pC=(e,t)=>sC.parts.label({dom:{tag:"label",classes:["tox-label"]},components:[ta(t.translate(e))]}),gC=ls("form-component-change"),fC=ls("form-close"),vC=ls("form-cancel"),bC=ls("form-action"),yC=ls("form-submit"),wC=ls("form-block"),_C=ls("form-unblock"),xC=ls("form-tabchange"),CC=ls("form-resize"),kC=["input","textarea"],SC=e=>{const t=Ze(e);return D(kC,t)},TC=(e,t)=>{const o=t.getRoot(e).getOr(e.element);Hs(o,t.invalidClass),t.notify.each((t=>{SC(e.element)&&Ct(e.element,"aria-invalid",!1),t.getContainer(e).each((e=>{ts(e,t.validHtml)})),t.onValid(e)}))},EC=(e,t,o,n)=>{const r=t.getRoot(e).getOr(e.element);zs(r,t.invalidClass),t.notify.each((t=>{SC(e.element)&&Ct(e.element,"aria-invalid",!0),t.getContainer(e).each((e=>{ts(e,n)})),t.onInvalid(e,n)}))},OC=(e,t,o)=>t.validator.fold((()=>vx(rn.value(!0))),(t=>t.validate(e))),MC=(e,t,o)=>(t.notify.each((t=>{t.onValidate(e)})),OC(e,t).map((o=>e.getSystem().isConnected()?o.fold((o=>(EC(e,t,0,o),rn.error(o))),(o=>(TC(e,t),rn.value(o)))):rn.error("No longer in system"))));var AC=Object.freeze({__proto__:null,markValid:TC,markInvalid:EC,query:OC,run:MC,isInvalid:(e,t)=>{const o=t.getRoot(e).getOr(e.element);return Zs(o,t.invalidClass)}}),BC=Object.freeze({__proto__:null,events:(e,t)=>e.validator.map((t=>Li([Zi(t.onEvent,(t=>{MC(t,e).get(_)}))].concat(t.validateOnLoad?[Ki((t=>{MC(t,e).get(v)}))]:[])))).getOr({})}),NC=[or("invalidClass"),yr("getRoot",M.none),br("notify",[yr("aria","alert"),yr("getContainer",M.none),yr("validHtml",""),Ba("onValid"),Ba("onInvalid"),Ba("onValidate")]),br("validator",[or("validate"),yr("onEvent","input"),yr("validateOnLoad",!0)])];const RC=Sl({fields:NC,name:"invalidating",active:BC,apis:AC,extra:{validation:e=>t=>{const o=pu.getValue(t);return vx(e(o))}}}),VC=Sl({fields:[],name:"unselecting",active:Object.freeze({__proto__:null,events:()=>Li([zi(ri(),O)]),exhibit:()=>Os({styles:{"-webkit-user-select":"none","user-select":"none","-ms-user-select":"none","-moz-user-select":"-moz-none"},attributes:{unselectable:"on"}})})}),DC=ls("color-input-change"),PC=ls("color-swatch-change"),IC=ls("color-picker-cancel"),FC=Uu({schema:[or("dom")],name:"label"}),LC=e=>Uu({name:e+"-edge",overrides:t=>t.model.manager.edgeActions[e].fold((()=>({})),(e=>({events:Li([ji(Lr(),((t,o,n)=>e(t,n)),[t]),ji(jr(),((t,o,n)=>e(t,n)),[t]),ji(Ur(),((t,o,n)=>{n.mouseIsDown.get()&&e(t,n)}),[t])])})))}),zC=LC("top-left"),HC=LC("top"),ZC=LC("top-right"),jC=LC("right"),UC=LC("bottom-right"),$C=LC("bottom"),WC=LC("bottom-left");var qC=[FC,LC("left"),jC,HC,$C,zC,ZC,WC,UC,Zu({name:"thumb",defaults:w({dom:{styles:{position:"absolute"}}}),overrides:e=>({events:Li([$i(Lr(),e,"spectrum"),$i(zr(),e,"spectrum"),$i(Hr(),e,"spectrum"),$i(jr(),e,"spectrum"),$i(Ur(),e,"spectrum"),$i(Wr(),e,"spectrum")])})}),Zu({schema:[er("mouseIsDown",(()=>Or(!1)))],name:"spectrum",overrides:e=>{const t=e.model.manager,o=(o,n)=>t.getValueFromEvent(n).map((n=>t.setValueFrom(o,e,n)));return{behaviours:Cl([Hp.config({mode:"special",onLeft:o=>t.onLeft(o,e),onRight:o=>t.onRight(o,e),onUp:o=>t.onUp(o,e),onDown:o=>t.onDown(o,e)}),og.config({})]),events:Li([Zi(Lr(),o),Zi(zr(),o),Zi(jr(),o),Zi(Ur(),((t,n)=>{e.mouseIsDown.get()&&o(t,n)}))])}}})];const GC=w("slider.change.value"),YC=e=>{const t=e.event.raw;if((e=>-1!==e.type.indexOf("touch"))(t)){const e=t;return void 0!==e.touches&&1===e.touches.length?M.some(e.touches[0]).map((e=>Wt(e.clientX,e.clientY))):M.none()}{const e=t;return void 0!==e.clientX?M.some(e).map((e=>Wt(e.clientX,e.clientY))):M.none()}},KC=e=>e.model.minX,XC=e=>e.model.minY,JC=e=>e.model.minX-1,QC=e=>e.model.minY-1,ek=e=>e.model.maxX,tk=e=>e.model.maxY,ok=e=>e.model.maxX+1,nk=e=>e.model.maxY+1,rk=(e,t,o)=>t(e)-o(e),ik=e=>rk(e,ek,KC),sk=e=>rk(e,tk,XC),ak=e=>ik(e)/2,lk=e=>sk(e)/2,ck=e=>e.stepSize,dk=e=>e.snapToGrid,uk=e=>e.snapStart,hk=e=>e.rounded,mk=(e,t)=>void 0!==e[t+"-edge"],pk=e=>mk(e,"left"),gk=e=>mk(e,"right"),fk=e=>mk(e,"top"),vk=e=>mk(e,"bottom"),bk=e=>e.model.value.get(),yk=(e,t)=>({x:e,y:t}),wk=(e,t)=>{Vi(e,GC(),{value:t})},_k=(e,t,o,n)=>eo?o:e===t?t-1:Math.max(t,e-n),xk=(e,t,o,n)=>e>o?e:eMath.max(t,Math.min(o,e)),kk=e=>{const{min:t,max:o,range:n,value:r,step:i,snap:s,snapStart:a,rounded:l,hasMinEdge:c,hasMaxEdge:d,minBound:u,maxBound:h,screenRange:m}=e,p=c?t-1:t,g=d?o+1:o;if(rh)return g;{const e=((e,t,o)=>Math.min(o,Math.max(e,t))-t)(r,u,h),c=Ck(e/m*n+t,p,g);return s&&c>=t&&c<=o?((e,t,o,n,r)=>r.fold((()=>{const r=e-t,i=Math.round(r/n)*n;return Ck(t+i,t-1,o+1)}),(t=>{const r=(e-t)%n,i=Math.round(r/n),s=Math.floor((e-t)/n),a=Math.floor((o-t)/n),l=t+Math.min(a,s+i)*n;return Math.max(t,l)})))(c,t,o,i,a):l?Math.round(c):c}},Sk=e=>{const{min:t,max:o,range:n,value:r,hasMinEdge:i,hasMaxEdge:s,maxBound:a,maxOffset:l,centerMinEdge:c,centerMaxEdge:d}=e;return ro?s?a:d:(r-t)/n*l},Tk="top",Ek="right",Ok="bottom",Mk="left",Ak=e=>e.element.dom.getBoundingClientRect(),Bk=(e,t)=>e[t],Nk=e=>{const t=Ak(e);return Bk(t,Mk)},Rk=e=>{const t=Ak(e);return Bk(t,Ek)},Vk=e=>{const t=Ak(e);return Bk(t,Tk)},Dk=e=>{const t=Ak(e);return Bk(t,Ok)},Pk=e=>{const t=Ak(e);return Bk(t,"width")},Ik=e=>{const t=Ak(e);return Bk(t,"height")},Fk=(e,t,o)=>(e+t)/2-o,Lk=(e,t)=>{const o=Ak(e),n=Ak(t),r=Bk(o,Mk),i=Bk(o,Ek),s=Bk(n,Mk);return Fk(r,i,s)},zk=(e,t)=>{const o=Ak(e),n=Ak(t),r=Bk(o,Tk),i=Bk(o,Ok),s=Bk(n,Tk);return Fk(r,i,s)},Hk=(e,t)=>{Vi(e,GC(),{value:t})},Zk=(e,t,o)=>{const n={min:KC(t),max:ek(t),range:ik(t),value:o,step:ck(t),snap:dk(t),snapStart:uk(t),rounded:hk(t),hasMinEdge:pk(t),hasMaxEdge:gk(t),minBound:Nk(e),maxBound:Rk(e),screenRange:Pk(e)};return kk(n)},jk=e=>(t,o)=>((e,t,o)=>{const n=(e>0?xk:_k)(bk(o),KC(o),ek(o),ck(o));return Hk(t,n),M.some(n)})(e,t,o).map(O),Uk=(e,t,o,n,r,i)=>{const s=((e,t,o,n,r)=>{const i=Pk(e),s=n.bind((t=>M.some(Lk(t,e)))).getOr(0),a=r.bind((t=>M.some(Lk(t,e)))).getOr(i),l={min:KC(t),max:ek(t),range:ik(t),value:o,hasMinEdge:pk(t),hasMaxEdge:gk(t),minBound:Nk(e),minOffset:0,maxBound:Rk(e),maxOffset:i,centerMinEdge:s,centerMaxEdge:a};return Sk(l)})(t,i,o,n,r);return Nk(t)-Nk(e)+s},$k=jk(-1),Wk=jk(1),qk=M.none,Gk=M.none,Yk={"top-left":M.none(),top:M.none(),"top-right":M.none(),right:M.some(((e,t)=>{wk(e,ok(t))})),"bottom-right":M.none(),bottom:M.none(),"bottom-left":M.none(),left:M.some(((e,t)=>{wk(e,JC(t))}))};var Kk=Object.freeze({__proto__:null,setValueFrom:(e,t,o)=>{const n=Zk(e,t,o);return Hk(e,n),n},setToMin:(e,t)=>{const o=KC(t);Hk(e,o)},setToMax:(e,t)=>{const o=ek(t);Hk(e,o)},findValueOfOffset:Zk,getValueFromEvent:e=>YC(e).map((e=>e.left)),findPositionOfValue:Uk,setPositionFromValue:(e,t,o,n)=>{const r=bk(o),i=Uk(e,n.getSpectrum(e),r,n.getLeftEdge(e),n.getRightEdge(e),o),s=Xt(t.element)/2;Bt(t.element,"left",i-s+"px")},onLeft:$k,onRight:Wk,onUp:qk,onDown:Gk,edgeActions:Yk});const Xk=(e,t)=>{Vi(e,GC(),{value:t})},Jk=(e,t,o)=>{const n={min:XC(t),max:tk(t),range:sk(t),value:o,step:ck(t),snap:dk(t),snapStart:uk(t),rounded:hk(t),hasMinEdge:fk(t),hasMaxEdge:vk(t),minBound:Vk(e),maxBound:Dk(e),screenRange:Ik(e)};return kk(n)},Qk=e=>(t,o)=>((e,t,o)=>{const n=(e>0?xk:_k)(bk(o),XC(o),tk(o),ck(o));return Xk(t,n),M.some(n)})(e,t,o).map(O),eS=(e,t,o,n,r,i)=>{const s=((e,t,o,n,r)=>{const i=Ik(e),s=n.bind((t=>M.some(zk(t,e)))).getOr(0),a=r.bind((t=>M.some(zk(t,e)))).getOr(i),l={min:XC(t),max:tk(t),range:sk(t),value:o,hasMinEdge:fk(t),hasMaxEdge:vk(t),minBound:Vk(e),minOffset:0,maxBound:Dk(e),maxOffset:i,centerMinEdge:s,centerMaxEdge:a};return Sk(l)})(t,i,o,n,r);return Vk(t)-Vk(e)+s},tS=M.none,oS=M.none,nS=Qk(-1),rS=Qk(1),iS={"top-left":M.none(),top:M.some(((e,t)=>{wk(e,QC(t))})),"top-right":M.none(),right:M.none(),"bottom-right":M.none(),bottom:M.some(((e,t)=>{wk(e,nk(t))})),"bottom-left":M.none(),left:M.none()};var sS=Object.freeze({__proto__:null,setValueFrom:(e,t,o)=>{const n=Jk(e,t,o);return Xk(e,n),n},setToMin:(e,t)=>{const o=XC(t);Xk(e,o)},setToMax:(e,t)=>{const o=tk(t);Xk(e,o)},findValueOfOffset:Jk,getValueFromEvent:e=>YC(e).map((e=>e.top)),findPositionOfValue:eS,setPositionFromValue:(e,t,o,n)=>{const r=bk(o),i=eS(e,n.getSpectrum(e),r,n.getTopEdge(e),n.getBottomEdge(e),o),s=jt(t.element)/2;Bt(t.element,"top",i-s+"px")},onLeft:tS,onRight:oS,onUp:nS,onDown:rS,edgeActions:iS});const aS=(e,t)=>{Vi(e,GC(),{value:t})},lS=(e,t)=>({x:e,y:t}),cS=(e,t)=>(o,n)=>((e,t,o,n)=>{const r=e>0?xk:_k,i=t?bk(n).x:r(bk(n).x,KC(n),ek(n),ck(n)),s=t?r(bk(n).y,XC(n),tk(n),ck(n)):bk(n).y;return aS(o,lS(i,s)),M.some(i)})(e,t,o,n).map(O),dS=cS(-1,!1),uS=cS(1,!1),hS=cS(-1,!0),mS=cS(1,!0),pS={"top-left":M.some(((e,t)=>{wk(e,yk(JC(t),QC(t)))})),top:M.some(((e,t)=>{wk(e,yk(ak(t),QC(t)))})),"top-right":M.some(((e,t)=>{wk(e,yk(ok(t),QC(t)))})),right:M.some(((e,t)=>{wk(e,yk(ok(t),lk(t)))})),"bottom-right":M.some(((e,t)=>{wk(e,yk(ok(t),nk(t)))})),bottom:M.some(((e,t)=>{wk(e,yk(ak(t),nk(t)))})),"bottom-left":M.some(((e,t)=>{wk(e,yk(JC(t),nk(t)))})),left:M.some(((e,t)=>{wk(e,yk(JC(t),lk(t)))}))};var gS=Object.freeze({__proto__:null,setValueFrom:(e,t,o)=>{const n=Zk(e,t,o.left),r=Jk(e,t,o.top),i=lS(n,r);return aS(e,i),i},setToMin:(e,t)=>{const o=KC(t),n=XC(t);aS(e,lS(o,n))},setToMax:(e,t)=>{const o=ek(t),n=tk(t);aS(e,lS(o,n))},getValueFromEvent:e=>YC(e),setPositionFromValue:(e,t,o,n)=>{const r=bk(o),i=Uk(e,n.getSpectrum(e),r.x,n.getLeftEdge(e),n.getRightEdge(e),o),s=eS(e,n.getSpectrum(e),r.y,n.getTopEdge(e),n.getBottomEdge(e),o),a=Xt(t.element)/2,l=jt(t.element)/2;Bt(t.element,"left",i-a+"px"),Bt(t.element,"top",s-l+"px")},onLeft:dS,onRight:uS,onUp:hS,onDown:mS,edgeActions:pS});const fS=vh({name:"Slider",configFields:[yr("stepSize",1),yr("onChange",v),yr("onChoose",v),yr("onInit",v),yr("onDragStart",v),yr("onDragEnd",v),yr("snapToGrid",!1),yr("rounded",!0),ur("snapStart"),nr("model",Xn("mode",{x:[yr("minX",0),yr("maxX",100),er("value",(e=>Or(e.mode.minX))),or("getInitialValue"),Da("manager",Kk)],y:[yr("minY",0),yr("maxY",100),er("value",(e=>Or(e.mode.minY))),or("getInitialValue"),Da("manager",sS)],xy:[yr("minX",0),yr("maxX",100),yr("minY",0),yr("maxY",100),er("value",(e=>Or({x:e.mode.minX,y:e.mode.minY}))),or("getInitialValue"),Da("manager",gS)]})),gu("sliderBehaviours",[Hp,pu]),er("mouseIsDown",(()=>Or(!1)))],partFields:qC,factory:(e,t,o,n)=>{const r=t=>nh(t,e,"thumb"),i=t=>nh(t,e,"spectrum"),s=t=>oh(t,e,"left-edge"),a=t=>oh(t,e,"right-edge"),l=t=>oh(t,e,"top-edge"),c=t=>oh(t,e,"bottom-edge"),d=e.model,u=d.manager,h=(t,o)=>{u.setPositionFromValue(t,o,e,{getLeftEdge:s,getRightEdge:a,getTopEdge:l,getBottomEdge:c,getSpectrum:i})},m=(e,t)=>{d.value.set(t);const o=r(e);h(e,o)},p=t=>{const o=e.mouseIsDown.get();e.mouseIsDown.set(!1),o&&oh(t,e,"thumb").each((o=>{const n=d.value.get();e.onChoose(t,o,n)}))},g=(t,o)=>{o.stop(),e.mouseIsDown.set(!0),e.onDragStart(t,r(t))},f=(t,o)=>{o.stop(),e.onDragEnd(t,r(t)),p(t)};return{uid:e.uid,dom:e.dom,components:t,behaviours:vu(e.sliderBehaviours,[Hp.config({mode:"special",focusIn:t=>oh(t,e,"spectrum").map(Hp.focusIn).map(O)}),pu.config({store:{mode:"manual",getValue:e=>d.value.get(),setValue:m}}),Ml.config({channels:{[Xd()]:{onReceive:p}}})]),events:Li([Zi(GC(),((t,o)=>{((t,o)=>{m(t,o);const n=r(t);e.onChange(t,n,o),M.some(!0)})(t,o.event.value)})),Ki(((t,o)=>{const n=d.getInitialValue();d.value.set(n);const s=r(t);h(t,s);const a=i(t);e.onInit(t,s,a,d.value.get())})),Zi(Lr(),g),Zi(Hr(),f),Zi(jr(),g),Zi(Wr(),f)]),apis:{resetToMin:t=>{u.setToMin(t,e)},resetToMax:t=>{u.setToMax(t,e)},setValue:m,refresh:h},domModification:{styles:{position:"relative"}}}},apis:{setValue:(e,t,o)=>{e.setValue(t,o)},resetToMin:(e,t)=>{e.resetToMin(t)},resetToMax:(e,t)=>{e.resetToMax(t)},refresh:(e,t)=>{e.refresh(t)}}}),vS=ls("rgb-hex-update"),bS=ls("slider-update"),yS=ls("palette-update"),wS="form",_S=[gu("formBehaviours",[pu])],xS=e=>"",CS=(e,t)=>({uid:e.uid,dom:e.dom,components:t,behaviours:vu(e.formBehaviours,[pu.config({store:{mode:"manual",getValue:t=>{const o=ih(t,e);return ce(o,((e,t)=>e().bind((e=>{return o=_h.getCurrent(e),n=new Error(`Cannot find a current component to extract the value from for form part '${t}': `+ns(e.element)),o.fold((()=>rn.error(n)),rn.value);var o,n})).map(pu.getValue)))},setValue:(t,o)=>{le(o,((o,n)=>{oh(t,e,n).each((e=>{_h.getCurrent(e).each((e=>{pu.setValue(e,o)}))}))}))}}})]),apis:{getField:(t,o)=>oh(t,e,o).bind(_h.getCurrent)}}),kS={getField:ks(((e,t,o)=>e.getField(t,o))),sketch:e=>{const t=(()=>{const e=[];return{field:(t,o)=>(e.push(t),Xu(wS,xS(t),o)),record:w(e)}})(),o=e(t),n=t.record(),r=L(n,(e=>Zu({name:e,pname:xS(e)})));return hh(wS,_S,r,CS,o)}},SS=ls("valid-input"),TS=ls("invalid-input"),ES=ls("validating-input"),OS="colorcustom.rgb.",MS=(e,t,o,n)=>{const r=(o,n)=>RC.config({invalidClass:t("invalid"),notify:{onValidate:e=>{Vi(e,ES,{type:o})},onValid:e=>{Vi(e,SS,{type:o,value:pu.getValue(e)})},onInvalid:e=>{Vi(e,TS,{type:o,value:pu.getValue(e)})}},validator:{validate:t=>{const o=pu.getValue(t),r=n(o)?rn.value(!0):rn.error(e("aria.input.invalid"));return vx(r)},validateOnLoad:!1}}),i=(o,n,i,s,a)=>{const l=e(OS+"range"),c=sC.parts.label({dom:{tag:"label",attributes:{"aria-label":s}},components:[ta(i)]}),d=sC.parts.field({data:a,factory:Ib,inputAttributes:{type:"text",..."hex"===n?{"aria-live":"polite"}:{}},inputClasses:[t("textfield")],inputBehaviours:Cl([r(n,o),cC.config({})]),onSetValue:e=>{RC.isInvalid(e)&&RC.run(e).get(v)}}),u=[c,d],h="hex"!==n?[sC.parts["aria-descriptor"]({text:l})]:[];return{dom:{tag:"div",attributes:{role:"presentation"}},components:u.concat(h)}},s=(e,t)=>{const o=t.red,n=t.green,r=t.blue;pu.setValue(e,{red:o,green:n,blue:r})},a=$g({dom:{tag:"div",classes:[t("rgba-preview")],styles:{"background-color":"white"},attributes:{role:"presentation"}}}),l=(e,t)=>{a.getOpt(e).each((e=>{Bt(e.element,"background-color","#"+t.value)}))},c=fh({factory:()=>{const r={red:Or(M.some(255)),green:Or(M.some(255)),blue:Or(M.some(255)),hex:Or(M.some("ffffff"))},c=e=>r[e].get(),d=(e,t)=>{r[e].set(t)},u=e=>{const t=e.red,o=e.green,n=e.blue;d("red",M.some(t)),d("green",M.some(o)),d("blue",M.some(n))},h=(e,t)=>{const o=t.event;"hex"!==o.type?d(o.type,M.none()):n(e)},m=(e,t)=>{const n=t.event;(e=>"hex"===e.type)(n)?((e,t)=>{o(e);const n=qw(t);d("hex",M.some(n.value));const r=l_(n);s(e,r),u(r),Vi(e,vS,{hex:n}),l(e,n)})(e,n.value):((e,t,o)=>{const n=parseInt(o,10);d(t,M.some(n)),c("red").bind((e=>c("green").bind((t=>c("blue").map((o=>i_(e,t,o,1))))))).each((t=>{const o=((e,t)=>{const o=Qw(t);return kS.getField(e,"hex").each((t=>{og.isFocused(t)||pu.setValue(e,{hex:o.value})})),o})(e,t);Vi(e,vS,{hex:o}),l(e,o)}))})(e,n.type,n.value)},p=t=>({label:e(OS+t+".label"),description:e(OS+t+".description")}),g=p("red"),f=p("green"),v=p("blue"),b=p("hex");return fn(kS.sketch((o=>({dom:{tag:"form",classes:[t("rgb-form")],attributes:{"aria-label":e("aria.color.picker")}},components:[o.field("red",sC.sketch(i(s_,"red",g.label,g.description,255))),o.field("green",sC.sketch(i(s_,"green",f.label,f.description,255))),o.field("blue",sC.sketch(i(s_,"blue",v.label,v.description,255))),o.field("hex",sC.sketch(i(Kw,"hex",b.label,b.description,"ffffff"))),a.asSpec()],formBehaviours:Cl([RC.config({invalidClass:t("form-invalid")}),Xp("rgb-form-events",[Zi(SS,m),Zi(TS,h),Zi(ES,h)])])}))),{apis:{updateHex:(e,t)=>{pu.setValue(e,{hex:t.value}),((e,t)=>{const o=l_(t);s(e,o),u(o)})(e,t),l(e,t)}}})},name:"RgbForm",configFields:[],apis:{updateHex:(e,t,o)=>{e.updateHex(t,o)}},extraApis:{}});return c},AS=(e,t)=>{const o=fh({name:"ColourPicker",configFields:[or("dom"),yr("onValidHex",v),yr("onInvalidHex",v)],factory:o=>{const n=MS(e,t,o.onValidHex,o.onInvalidHex),r=((e,t)=>{const o=fS.parts.spectrum({dom:{tag:"canvas",attributes:{role:"presentation"},classes:[t("sv-palette-spectrum")]}}),n=fS.parts.thumb({dom:{tag:"div",attributes:{role:"presentation"},classes:[t("sv-palette-thumb")],innerHtml:`
`}}),r=(e,t)=>{const{width:o,height:n}=e,r=e.getContext("2d");if(null===r)return;r.fillStyle=t,r.fillRect(0,0,o,n);const i=r.createLinearGradient(0,0,o,0);i.addColorStop(0,"rgba(255,255,255,1)"),i.addColorStop(1,"rgba(255,255,255,0)"),r.fillStyle=i,r.fillRect(0,0,o,n);const s=r.createLinearGradient(0,0,0,n);s.addColorStop(0,"rgba(0,0,0,0)"),s.addColorStop(1,"rgba(0,0,0,1)"),r.fillStyle=s,r.fillRect(0,0,o,n)};return fh({factory:e=>{const i=w({x:0,y:0}),s=Cl([_h.config({find:M.some}),og.config({})]);return fS.sketch({dom:{tag:"div",attributes:{role:"presentation"},classes:[t("sv-palette")]},model:{mode:"xy",getInitialValue:i},rounded:!1,components:[o,n],onChange:(e,t,o)=>{Vi(e,yS,{value:o})},onInit:(e,t,o,n)=>{r(o.element.dom,u_(h_))},sliderBehaviours:s})},name:"SaturationBrightnessPalette",configFields:[],apis:{setHue:(e,t,o)=>{((e,t)=>{const o=e.components()[0].element.dom,n=T_(t,100,100),i=a_(n);r(o,u_(i))})(t,o)},setThumb:(e,t,o)=>{((e,t)=>{const o=E_(l_(t));fS.setValue(e,{x:o.saturation,y:100-o.value})})(t,o)}},extraApis:{}})})(0,t),i={paletteRgba:Or(h_),paletteHue:Or(0)},s=$g(((e,t)=>{const o=fS.parts.spectrum({dom:{tag:"div",classes:[t("hue-slider-spectrum")],attributes:{role:"presentation"}}}),n=fS.parts.thumb({dom:{tag:"div",classes:[t("hue-slider-thumb")],attributes:{role:"presentation"}}});return fS.sketch({dom:{tag:"div",classes:[t("hue-slider")],attributes:{role:"presentation"}},rounded:!1,model:{mode:"y",getInitialValue:w(0)},components:[o,n],sliderBehaviours:Cl([og.config({})]),onChange:(e,t,o)=>{Vi(e,bS,{value:o})}})})(0,t)),a=$g(r.sketch({})),l=$g(n.sketch({})),c=(e,t,o)=>{a.getOpt(e).each((e=>{r.setHue(e,o)}))},d=(e,t)=>{l.getOpt(e).each((e=>{n.updateHex(e,t)}))},u=(e,t,o)=>{s.getOpt(e).each((e=>{fS.setValue(e,(e=>100-e/360*100)(o))}))},h=(e,t)=>{a.getOpt(e).each((e=>{r.setThumb(e,t)}))},m=(e,t,o,n)=>{((e,t)=>{const o=l_(e);i.paletteRgba.set(o),i.paletteHue.set(t)})(t,o),z(n,(n=>{n(e,t,o)}))};return{uid:o.uid,dom:o.dom,components:[a.asSpec(),s.asSpec(),l.asSpec()],behaviours:Cl([Xp("colour-picker-events",[Zi(vS,(()=>{const e=[c,u,h];return(t,o)=>{const n=o.event.hex,r=(e=>E_(l_(e)))(n);m(t,n,r.hue,e)}})()),Zi(yS,(()=>{const e=[d];return(t,o)=>{const n=o.event.value,r=i.paletteHue.get(),s=T_(r,n.x,100-n.y),a=O_(s);m(t,a,r,e)}})()),Zi(bS,(()=>{const e=[c,d];return(t,o)=>{const n=(e=>(100-e)/100*360)(o.event.value),r=i.paletteRgba.get(),s=E_(r),a=T_(n,s.saturation,s.value),l=O_(a);m(t,l,n,e)}})())]),_h.config({find:e=>l.getOpt(e)}),Hp.config({mode:"acyclic"})])}}});return o},BS=()=>_h.config({find:M.some}),NS=e=>_h.config({find:t=>lt(t.element,e).bind((e=>t.getSystem().getByDom(e).toOptional()))}),RS=Bn([yr("preprocess",_),yr("postprocess",_)]),VS=(e,t)=>{const o=Yn("RepresentingConfigs.memento processors",RS,t);return pu.config({store:{mode:"manual",getValue:t=>{const n=e.get(t),r=pu.getValue(n);return o.postprocess(r)},setValue:(t,n)=>{const r=o.preprocess(n),i=e.get(t);pu.setValue(i,r)}}})},DS=(e,t,o)=>pu.config({store:{mode:"manual",...e.map((e=>({initialValue:e}))).getOr({}),getValue:t,setValue:o}}),PS=(e,t,o)=>DS(e,(e=>t(e.element)),((e,t)=>o(e.element,t))),IS=e=>pu.config({store:{mode:"memory",initialValue:e}}),FS={"colorcustom.rgb.red.label":"R","colorcustom.rgb.red.description":"Red component","colorcustom.rgb.green.label":"G","colorcustom.rgb.green.description":"Green component","colorcustom.rgb.blue.label":"B","colorcustom.rgb.blue.description":"Blue component","colorcustom.rgb.hex.label":"#","colorcustom.rgb.hex.description":"Hex color code","colorcustom.rgb.range":"Range 0 to 255","aria.color.picker":"Color Picker","aria.input.invalid":"Invalid input"};var LS=window.mailpoetTinymce.util.Tools.resolve("mailpoetTinymce.Resource"),zS=window.mailpoetTinymce.util.Tools.resolve("window.mailpoetTinymce.util.Tools");const HS=(e,t)=>{let o=null;const n=()=>{c(o)||(clearTimeout(o),o=null)};return{cancel:n,throttle:(...r)=>{n(),o=setTimeout((()=>{o=null,e.apply(null,r)}),t)}}},ZS=ls("alloy-fake-before-tabstop"),jS=ls("alloy-fake-after-tabstop"),US=e=>({dom:{tag:"div",styles:{width:"1px",height:"1px",outline:"none"},attributes:{tabindex:"0"},classes:e},behaviours:Cl([og.config({ignore:!0}),cC.config({})])}),$S=(e,t)=>({dom:{tag:"div",classes:["tox-navobj",...e.getOr([])]},components:[US([ZS]),t,US([jS])],behaviours:Cl([NS(1)])}),WS=(e,t)=>{Vi(e,Kr(),{raw:{which:9,shiftKey:t}})},qS=(e,t)=>{const o=t.element;Zs(o,ZS)?WS(e,!0):Zs(o,jS)&&WS(e,!1)},GS=e=>Wx(e,["."+ZS,"."+jS].join(","),E),YS=ls("update-dialog"),KS=ls("update-title"),XS=ls("update-body"),JS=ls("update-footer"),QS=ls("body-send-message"),eT=ls("dialog-focus-shifted"),tT=Bo().browser,oT=tT.isSafari(),nT=tT.isFirefox(),rT=oT||nT,iT=tT.isChromium(),sT=({scrollTop:e,scrollHeight:t,clientHeight:o})=>Math.ceil(e)+o>=t,aT=(e,t)=>e.scrollTo(0,"bottom"===t?99999999:t),lT=(e,t,o)=>{const n=e.dom;M.from(n.contentDocument).fold(o,(e=>{let o=0;const r=((e,t)=>{const o=e.body;return M.from(!/^1))?o:e.documentElement)})(e,t).map((e=>(o=e.scrollTop,e))).forall(sT),i=()=>{const e=n.contentWindow;m(e)&&(r?aT(e,"bottom"):!r&&rT&&0!==o&&aT(e,o))};oT&&n.addEventListener("load",i,{once:!0}),e.open(),e.write(t),e.close(),oT||i()}))},cT=ke(rT,oT?500:200).map((e=>((e,t)=>{let o=null,n=null;return{cancel:()=>{c(o)||(clearTimeout(o),o=null,n=null)},throttle:(...r)=>{n=r,c(o)&&(o=setTimeout((()=>{const t=n;o=null,n=null,e.apply(null,t)}),t))}}})(lT,e))),dT=ls("toolbar.button.execute"),uT=ls("common-button-display-events"),hT={[ui()]:["disabling","alloy.base.behaviour","toggling","toolbar-button-events"],[xi()]:["toolbar-button-events",uT],[jr()]:["focusing","alloy.base.behaviour",uT]},mT=e=>Bt(e.element,"width",Vt(e.element,"width")),pT=(e,t,o)=>tv(e,{tag:"span",classes:["tox-icon","tox-tbtn__icon-wrap"],behaviours:o},t),gT=(e,t)=>pT(e,t,[]),fT=(e,t)=>pT(e,t,[Kp.config({})]),vT=(e,t,o)=>({dom:{tag:"span",classes:[`${t}__select-label`]},components:[ta(o.translate(e))],behaviours:Cl([Kp.config({})])}),bT=ls("update-menu-text"),yT=ls("update-menu-icon"),wT=(e,t,o)=>{const n=Or(v),r=e.text.map((e=>$g(vT(e,t,o.providers)))),i=e.icon.map((e=>$g(fT(e,o.providers.icons)))),s=(e,t)=>{const o=pu.getValue(e);return og.focus(o),Vi(o,"keydown",{raw:t.event.raw}),Bx.close(o),M.some(!0)},a=e.role.fold((()=>({})),(e=>({role:e}))),l=e.tooltip.fold((()=>({})),(e=>{const t=o.providers.translate(e);return{title:t,"aria-label":t}})),c=tv("chevron-down",{tag:"div",classes:[`${t}__select-chevron`]},o.providers.icons),d=ls("common-button-display-events"),u=$g(Bx.sketch({...e.uid?{uid:e.uid}:{},...a,dom:{tag:"button",classes:[t,`${t}--select`].concat(L(e.classes,(e=>`${t}--${e}`))),attributes:{...l}},components:Bw([i.map((e=>e.asSpec())),r.map((e=>e.asSpec())),M.some(c)]),matchWidth:!0,useMinWidth:!0,onOpen:(t,o,n)=>{e.searchable&&(e=>{Zb(e).each((e=>og.focus(e)))})(n)},dropdownBehaviours:Cl([...e.dropdownBehaviours,Cw((()=>e.disabled||o.providers.isDisabled())),xw(),VC.config({}),Kp.config({}),Xp("dropdown-events",[Ew(e,n),Ow(e,n)]),Xp(d,[Ki(((e,t)=>mT(e)))]),Xp("menubutton-update-display-text",[Zi(bT,((e,t)=>{r.bind((t=>t.getOpt(e))).each((e=>{Kp.set(e,[ta(o.providers.translate(t.event.text))])}))})),Zi(yT,((e,t)=>{i.bind((t=>t.getOpt(e))).each((e=>{Kp.set(e,[fT(t.event.icon,o.providers.icons)])}))}))])]),eventOrder:fn(hT,{mousedown:["focusing","alloy.base.behaviour","item-type-events","normal-dropdown-events"],[xi()]:["toolbar-button-events","dropdown-events",d]}),sandboxBehaviours:Cl([Hp.config({mode:"special",onLeft:s,onRight:s}),Xp("dropdown-sandbox-events",[Zi(Fb,((e,t)=>{(e=>{const t=pu.getValue(e),o=Hb(e).map(jb);Bx.refetch(t).get((()=>{const e=ux.getCoupled(t,"sandbox");o.each((t=>Hb(e).each((e=>((e,t)=>{pu.setValue(e,t.fetchPattern),e.element.dom.selectionStart=t.selectionStart,e.element.dom.selectionEnd=t.selectionEnd})(e,t)))))}))})(e),t.stop()})),Zi(Lb,((e,t)=>{((e,t)=>{(e=>Gd.getState(e).bind($h.getHighlighted).bind($h.getHighlighted))(e).each((o=>{((e,t,o,n)=>{const r={...n,target:t};e.getSystem().triggerEvent(o,t,r)})(e,o.element,t.event.eventType,t.event.interactionEvent)}))})(e,t),t.stop()}))])]),lazySink:o.getSink,toggleClass:`${t}--active`,parts:{menu:{...Nb(0,e.columns,e.presets),fakeFocus:e.searchable,onHighlightItem:Nx,onCollapseMenu:(e,t,o)=>{$h.getHighlighted(o).each((t=>{Nx(e,o,t)}))},onDehighlightItem:Rx}},getAnchorOverrides:()=>({maxHeightFunction:(e,t)=>{lc()(e,t-10)}}),fetch:t=>fx(C(e.fetch,t))}));return u.asSpec()},_T=e=>"separator"===e.type,xT={type:"separator"},CT=(e,t)=>{const o=((e,t)=>{const o=U(e,((e,o)=>(e=>i(e))(o)?""===o?e:"|"===o?e.length>0&&!_T(e[e.length-1])?e.concat([xT]):e:be(t,o.toLowerCase())?e.concat([t[o.toLowerCase()]]):e:e.concat([o])),[]);return o.length>0&&_T(o[o.length-1])&&o.pop(),o})(i(e)?e.split(" "):e,t);return j(o,((e,o)=>{if((e=>be(e,"getSubmenuItems"))(o)){const n=(e=>{const t=ve(e,"value").getOrThunk((()=>ls("generated-menu-item")));return fn({value:t},e)})(o),r=((e,t)=>{const o=e.getSubmenuItems(),n=CT(o,t);return{item:e,menus:fn(n.menus,{[e.value]:n.items}),expansions:fn(n.expansions,{[e.value]:e.value})}})(n,t);return{menus:fn(e.menus,r.menus),items:[r.item,...e.items],expansions:fn(e.expansions,r.expansions)}}return{...e,items:[o,...e.items]}}),{menus:{},expansions:{},items:[]})},kT=(e,t,o,n)=>{const r=ls("primary-menu"),i=CT(e,o.shared.providers.menuItems());if(0===i.items.length)return M.none();const s=(e=>e.search.fold((()=>({searchMode:"no-search"})),(e=>({searchMode:"search-with-field",placeholder:e.placeholder}))))(n),a=Fx(r,i.items,t,o,n.isHorizontalMenu,s),l=(e=>e.search.fold((()=>({searchMode:"no-search"})),(e=>({searchMode:"search-with-results"}))))(n),c=ce(i.menus,((e,n)=>Fx(n,e,t,o,!1,l))),d=fn(c,Ar(r,a));return M.from(zg.tieredData(r,d,i.expansions))},ST=e=>!be(e,"items"),TT="data-value",ET=(e,t,o,n)=>L(o,(o=>ST(o)?{type:"togglemenuitem",text:o.text,value:o.value,active:o.value===n,onAction:()=>{pu.setValue(e,o.value),Vi(e,gC,{name:t}),og.focus(e)}}:{type:"nestedmenuitem",text:o.text,getSubmenuItems:()=>ET(e,t,o.items,n)})),OT=(e,t)=>ie(e,(e=>ST(e)?ke(e.value===t,e):OT(e.items,t))),MT=fh({name:"HtmlSelect",configFields:[or("options"),gu("selectBehaviours",[og,pu]),yr("selectClasses",[]),yr("selectAttributes",{}),ur("data")],factory:(e,t)=>{const o=L(e.options,(e=>({dom:{tag:"option",value:e.value,innerHtml:e.text}}))),n=e.data.map((e=>Ar("initialValue",e))).getOr({});return{uid:e.uid,dom:{tag:"select",classes:e.selectClasses,attributes:e.selectAttributes},components:o,behaviours:vu(e.selectBehaviours,[og.config({}),pu.config({store:{mode:"manual",getValue:e=>Ws(e.element),setValue:(t,o)=>{const n=oe(e.options);$(e.options,(e=>e.value===o)).isSome()?qs(t.element,o):-1===t.element.dom.selectedIndex&&""===o&&n.each((e=>qs(t.element,e.value)))},...n}})])}}}),AT=w([yr("field1Name","field1"),yr("field2Name","field2"),Ra("onLockedChange"),Ma(["lockClass"]),yr("locked",!1),bu("coupledFieldBehaviours",[_h,pu])]),BT=(e,t)=>Zu({factory:sC,name:e,overrides:e=>({fieldBehaviours:Cl([Xp("coupled-input-behaviour",[Zi(Jr(),(o=>{((e,t,o)=>oh(e,t,o).bind(_h.getCurrent))(o,e,t).each((t=>{oh(o,e,"lock").each((n=>{dg.isOn(n)&&e.onLockedChange(o,t,n)}))}))}))])])})}),NT=w([BT("field1","field2"),BT("field2","field1"),Zu({factory:jg,schema:[or("dom")],name:"lock",overrides:e=>({buttonBehaviours:Cl([dg.config({selected:e.locked,toggleClass:e.markers.lockClass,aria:{mode:"pressed"}})])})})]),RT=vh({name:"FormCoupledInputs",configFields:AT(),partFields:NT(),factory:(e,t,o,n)=>({uid:e.uid,dom:e.dom,components:t,behaviours:yu(e.coupledFieldBehaviours,[_h.config({find:M.some}),pu.config({store:{mode:"manual",getValue:t=>{const o=ah(t,e,["field1","field2"]);return{[e.field1Name]:pu.getValue(o.field1()),[e.field2Name]:pu.getValue(o.field2())}},setValue:(t,o)=>{const n=ah(t,e,["field1","field2"]);ye(o,e.field1Name)&&pu.setValue(n.field1(),o[e.field1Name]),ye(o,e.field2Name)&&pu.setValue(n.field2(),o[e.field2Name])}}})]),apis:{getField1:t=>oh(t,e,"field1"),getField2:t=>oh(t,e,"field2"),getLock:t=>oh(t,e,"lock")}}),apis:{getField1:(e,t)=>e.getField1(t),getField2:(e,t)=>e.getField2(t),getLock:(e,t)=>e.getLock(t)}}),VT=e=>{const t=/^\s*(\d+(?:\.\d+)?)\s*(|cm|mm|in|px|pt|pc|em|ex|ch|rem|vw|vh|vmin|vmax|%)\s*$/.exec(e);if(null!==t){const e=parseFloat(t[1]),o=t[2];return rn.value({value:e,unit:o})}return rn.error(e)},DT=(e,t)=>{const o={"":96,px:96,pt:72,cm:2.54,pc:12,mm:25.4,in:1},n=e=>be(o,e);return e.unit===t?M.some(e.value):n(e.unit)&&n(t)?o[e.unit]===o[t]?M.some(e.value):M.some(e.value/o[e.unit]*o[t]):M.none()},PT=e=>M.none(),IT=(e,t)=>{const o=e.label.map((e=>pC(e,t))),n=[Dh.config({disabled:()=>e.disabled||t.isDisabled()}),xw(),Hp.config({mode:"execution",useEnter:!0!==e.multiline,useControlEnter:!0===e.multiline,execute:e=>(Ri(e,yC),M.some(!0))}),Xp("textfield-change",[Zi(Jr(),((t,o)=>{Vi(t,gC,{name:e.name})})),Zi(ci(),((t,o)=>{Vi(t,gC,{name:e.name})}))]),cC.config({})],r=e.validation.map((e=>RC.config({getRoot:e=>it(e.element),invalidClass:"tox-invalid",validator:{validate:t=>{const o=pu.getValue(t),n=e.validator(o);return vx(!0===n?rn.value(o):rn.error(n))},validateOnLoad:e.validateOnLoad}}))).toArray(),i={...e.placeholder.fold(w({}),(e=>({placeholder:t.translate(e)}))),...e.inputMode.fold(w({}),(e=>({inputmode:e})))},s=sC.parts.field({tag:!0===e.multiline?"textarea":"input",...e.data.map((e=>({data:e}))).getOr({}),inputAttributes:i,inputClasses:[e.classname],inputBehaviours:Cl(q([n,r])),selectOnFocus:!1,factory:Ib}),a=e.multiline?{dom:{tag:"div",classes:["tox-textarea-wrap"]},components:[s]}:s,l=(e.flex?["tox-form__group--stretched"]:[]).concat(e.maximized?["tox-form-group--maximize"]:[]),c=[Dh.config({disabled:()=>e.disabled||t.isDisabled(),onDisabled:e=>{sC.getField(e).each(Dh.disable)},onEnabled:e=>{sC.getField(e).each(Dh.enable)}}),xw()];return uC(o,a,l,c)},FT=(e,t)=>t.getAnimationRoot.fold((()=>e.element),(t=>t(e))),LT=e=>e.dimension.property,zT=(e,t)=>e.dimension.getDimension(t),HT=(e,t)=>{const o=FT(e,t);Us(o,[t.shrinkingClass,t.growingClass])},ZT=(e,t)=>{Hs(e.element,t.openClass),zs(e.element,t.closedClass),Bt(e.element,LT(t),"0px"),zt(e.element)},jT=(e,t)=>{Hs(e.element,t.closedClass),zs(e.element,t.openClass),Lt(e.element,LT(t))},UT=(e,t,o,n)=>{o.setCollapsed(),Bt(e.element,LT(t),zT(t,e.element)),HT(e,t),ZT(e,t),t.onStartShrink(e),t.onShrunk(e)},$T=(e,t,o,n)=>{const r=n.getOrThunk((()=>zT(t,e.element)));o.setCollapsed(),Bt(e.element,LT(t),r),zt(e.element);const i=FT(e,t);Hs(i,t.growingClass),zs(i,t.shrinkingClass),ZT(e,t),t.onStartShrink(e)},WT=(e,t,o)=>{const n=zT(t,e.element);("0px"===n?UT:$T)(e,t,o,M.some(n))},qT=(e,t,o)=>{const n=FT(e,t),r=Zs(n,t.shrinkingClass),i=zT(t,e.element);jT(e,t);const s=zT(t,e.element);(r?()=>{Bt(e.element,LT(t),i),zt(e.element)}:()=>{ZT(e,t)})(),Hs(n,t.shrinkingClass),zs(n,t.growingClass),jT(e,t),Bt(e.element,LT(t),s),o.setExpanded(),t.onStartGrow(e)},GT=(e,t,o)=>{const n=FT(e,t);return!0===Zs(n,t.growingClass)},YT=(e,t,o)=>{const n=FT(e,t);return!0===Zs(n,t.shrinkingClass)};var KT=Object.freeze({__proto__:null,refresh:(e,t,o)=>{if(o.isExpanded()){Lt(e.element,LT(t));const o=zT(t,e.element);Bt(e.element,LT(t),o)}},grow:(e,t,o)=>{o.isExpanded()||qT(e,t,o)},shrink:(e,t,o)=>{o.isExpanded()&&WT(e,t,o)},immediateShrink:(e,t,o)=>{o.isExpanded()&&UT(e,t,o)},hasGrown:(e,t,o)=>o.isExpanded(),hasShrunk:(e,t,o)=>o.isCollapsed(),isGrowing:GT,isShrinking:YT,isTransitioning:(e,t,o)=>GT(e,t)||YT(e,t),toggleGrow:(e,t,o)=>{(o.isExpanded()?WT:qT)(e,t,o)},disableTransitions:HT,immediateGrow:(e,t,o)=>{o.isExpanded()||(jT(e,t),Bt(e.element,LT(t),zT(t,e.element)),HT(e,t),o.setExpanded(),t.onStartGrow(e),t.onGrown(e))}}),XT=Object.freeze({__proto__:null,exhibit:(e,t,o)=>{const n=t.expanded;return Os(n?{classes:[t.openClass],styles:{}}:{classes:[t.closedClass],styles:Ar(t.dimension.property,"0px")})},events:(e,t)=>Li([Yi(oi(),((o,n)=>{n.event.raw.propertyName===e.dimension.property&&(HT(o,e),t.isExpanded()&&Lt(o.element,e.dimension.property),(t.isExpanded()?e.onGrown:e.onShrunk)(o))}))])}),JT=[or("closedClass"),or("openClass"),or("shrinkingClass"),or("growingClass"),ur("getAnimationRoot"),Ba("onShrunk"),Ba("onStartShrink"),Ba("onGrown"),Ba("onStartGrow"),yr("expanded",!1),nr("dimension",Xn("property",{width:[Da("property","width"),Da("getDimension",(e=>Xt(e)+"px"))],height:[Da("property","height"),Da("getDimension",(e=>jt(e)+"px"))]}))];const QT=Sl({fields:JT,name:"sliding",active:XT,apis:KT,state:Object.freeze({__proto__:null,init:e=>{const t=Or(e.expanded);return Ts({isExpanded:()=>!0===t.get(),isCollapsed:()=>!1===t.get(),setCollapsed:C(t.set,!1),setExpanded:C(t.set,!0),readState:()=>"expanded: "+t.get()})}})}),eE=e=>({isEnabled:()=>!Dh.isDisabled(e),setEnabled:t=>Dh.set(e,!t),setActive:t=>{const o=e.element;t?(zs(o,"tox-tbtn--enabled"),Ct(o,"aria-pressed",!0)):(Hs(o,"tox-tbtn--enabled"),Ot(o,"aria-pressed"))},isActive:()=>Zs(e.element,"tox-tbtn--enabled"),setText:t=>{Vi(e,bT,{text:t})},setIcon:t=>Vi(e,yT,{icon:t})}),tE=(e,t,o,n,r=!0)=>wT({text:e.text,icon:e.icon,tooltip:e.tooltip,searchable:e.search.isSome(),role:n,fetch:(t,n)=>{const r={pattern:e.search.isSome()?Vx(t):""};e.fetch((t=>{n(kT(t,pb.CLOSE_ON_EXECUTE,o,{isHorizontalMenu:!1,search:e.search}))}),r,eE(t))},onSetup:e.onSetup,getApi:eE,columns:1,presets:"normal",classes:[],dropdownBehaviours:[...r?[cC.config({})]:[]]},t,o.shared),oE=(e,t,o)=>{const n=e=>n=>{const r=!n.isActive();n.setActive(r),e.storage.set(r),o.shared.getSink().each((o=>{t().getOpt(o).each((t=>{Bl(t.element),Vi(t,bC,{name:e.name,value:e.storage.get()})}))}))},r=e=>t=>{t.setActive(e.storage.get())};return t=>{t(L(e,(e=>{const t=e.text.fold((()=>({})),(e=>({text:e})));return{type:e.type,active:!1,...t,onAction:n(e),onSetup:r(e)}})))}},nE=e=>({dom:{tag:"span",classes:["tox-tree__label"],attributes:{title:e,"aria-label":e}},components:[ta(e)]}),rE=ls("leaf-label-event-id"),iE=({leaf:e,onLeafAction:t,visible:o,treeId:n,selectedId:r,backstage:i})=>{const s=e.menu.map((e=>tE(e,"tox-mbtn",i,M.none(),o))),a=[nE(e.title)];return s.each((e=>a.push(e))),jg.sketch({dom:{tag:"div",classes:["tox-tree--leaf__label","tox-trbtn"].concat(o?["tox-tree--leaf__label--visible"]:[])},components:a,role:"treeitem",action:o=>{t(e.id),o.getSystem().broadcastOn([`update-active-item-${n}`],{value:e.id})},eventOrder:{[Kr()]:[rE,"keying"]},buttonBehaviours:Cl([...o?[cC.config({})]:[],dg.config({toggleClass:"tox-trbtn--enabled",toggleOnExecute:!1,aria:{mode:"selected"}}),Ml.config({channels:{[`update-active-item-${n}`]:{onReceive:(t,o)=>{(o.value===e.id?dg.on:dg.off)(t)}}}}),Xp(rE,[Ki(((t,o)=>{r.each((o=>{(o===e.id?dg.on:dg.off)(t)}))})),Zi(Kr(),((e,t)=>{const o="ArrowLeft"===t.event.raw.code,n="ArrowRight"===t.event.raw.code;o?(ha(e.element,".tox-tree--directory").each((t=>{e.getSystem().getByDom(t).each((e=>{ma(t,".tox-tree--directory__label").each((t=>{e.getSystem().getByDom(t).each(og.focus)}))}))})),t.stop()):n&&t.stop()}))])])})},sE=ls("directory-label-event-id"),aE=({directory:e,visible:t,noChildren:o,backstage:n})=>{const r=e.menu.map((e=>tE(e,"tox-mbtn",n,M.none()))),i=[{dom:{tag:"div",classes:["tox-chevron"]},components:[(s="chevron-right",a=n.shared.providers.icons,((e,t,o)=>tv(e,{tag:"span",classes:["tox-tree__icon-wrap","tox-icon"],behaviours:[]},t))(s,a))]},nE(e.title)];var s,a;r.each((e=>{i.push(e)}));const l=t=>{ha(t.element,".tox-tree--directory").each((o=>{t.getSystem().getByDom(o).each((o=>{const n=!dg.isOn(o);dg.toggle(o),Vi(t,"expand-tree-node",{expanded:n,node:e.id})}))}))};return jg.sketch({dom:{tag:"div",classes:["tox-tree--directory__label","tox-trbtn"].concat(t?["tox-tree--directory__label--visible"]:[])},components:i,action:l,eventOrder:{[Kr()]:[sE,"keying"]},buttonBehaviours:Cl([...t?[cC.config({})]:[],Xp(sE,[Zi(Kr(),((e,t)=>{const n="ArrowRight"===t.event.raw.code,r="ArrowLeft"===t.event.raw.code;n&&o&&t.stop(),(n||r)&&ha(e.element,".tox-tree--directory").each((o=>{e.getSystem().getByDom(o).each((o=>{!dg.isOn(o)&&n||dg.isOn(o)&&r?(l(e),t.stop()):r&&!dg.isOn(o)&&(ha(o.element,".tox-tree--directory").each((e=>{ma(e,".tox-tree--directory__label").each((e=>{o.getSystem().getByDom(e).each(og.focus)}))})),t.stop())}))}))}))])])})},lE=({children:e,onLeafAction:t,visible:o,treeId:n,expandedIds:r,selectedId:i,backstage:s})=>({dom:{tag:"div",classes:["tox-tree--directory__children"]},components:e.map((e=>"leaf"===e.type?iE({leaf:e,selectedId:i,onLeafAction:t,visible:o,treeId:n,backstage:s}):dE({directory:e,expandedIds:r,selectedId:i,onLeafAction:t,labelTabstopping:o,treeId:n,backstage:s}))),behaviours:Cl([QT.config({dimension:{property:"height"},closedClass:"tox-tree--directory__children--closed",openClass:"tox-tree--directory__children--open",growingClass:"tox-tree--directory__children--growing",shrinkingClass:"tox-tree--directory__children--shrinking",expanded:o}),Kp.config({})])}),cE=ls("directory-event-id"),dE=({directory:e,onLeafAction:t,labelTabstopping:o,treeId:n,backstage:r,expandedIds:i,selectedId:s})=>{const{children:a}=e,l=Or(i),c=i.includes(e.id);return{dom:{tag:"div",classes:["tox-tree--directory"],attributes:{role:"treeitem"}},components:[aE({directory:e,visible:o,noChildren:0===e.children.length,backstage:r}),lE({children:a,expandedIds:i,selectedId:s,onLeafAction:t,visible:c,treeId:n,backstage:r})],behaviours:Cl([Xp(cE,[Ki(((e,t)=>{dg.set(e,c)})),Zi("expand-tree-node",((e,t)=>{const{expanded:o,node:n}=t.event;l.set(o?[...l.get(),n]:l.get().filter((e=>e!==n)))}))]),dg.config({...e.children.length>0?{aria:{mode:"expanded"}}:{},toggleClass:"tox-tree--directory--expanded",onToggled:(e,o)=>{const i=e.components()[1],c=(d=o,a.map((e=>"leaf"===e.type?iE({leaf:e,selectedId:s,onLeafAction:t,visible:d,treeId:n,backstage:r}):dE({directory:e,expandedIds:l.get(),selectedId:s,onLeafAction:t,labelTabstopping:d,treeId:n,backstage:r}))));var d;o?QT.grow(i):QT.shrink(i),Kp.set(i,c)}})])}},uE=ls("tree-event-id");var hE=Object.freeze({__proto__:null,events:(e,t)=>{const o=e.stream.streams.setup(e,t);return Li([Zi(e.event,o),Xi((()=>t.cancel()))].concat(e.cancelEvent.map((e=>[Zi(e,(()=>t.cancel()))])).getOr([])))}});const mE=e=>{const t=Or(null);return Ts({readState:()=>({timer:null!==t.get()?"set":"unset"}),setTimer:e=>{t.set(e)},cancel:()=>{const e=t.get();null!==e&&e.cancel()}})};var pE=Object.freeze({__proto__:null,throttle:mE,init:e=>e.stream.streams.state(e)}),gE=[nr("stream",Xn("mode",{throttle:[or("delay"),yr("stopEvent",!0),Da("streams",{setup:(e,t)=>{const o=e.stream,n=HS(e.onStream,o.delay);return t.setTimer(n),(e,t)=>{n.throttle(e,t),o.stopEvent&&t.stop()}},state:mE})]})),yr("event","input"),ur("cancelEvent"),Ra("onStream")];const fE=Sl({fields:gE,name:"streaming",active:hE,state:pE}),vE=(e,t,o)=>{const n=pu.getValue(o);pu.setValue(t,n),yE(t)},bE=(e,t)=>{const o=e.element,n=Ws(o),r=o.dom;"number"!==St(o,"type")&&t(r,n)},yE=e=>{bE(e,((e,t)=>e.setSelectionRange(t.length,t.length)))},wE=w("alloy.typeahead.itemexecute"),_E=w([ur("lazySink"),or("fetch"),yr("minChars",5),yr("responseTime",1e3),Ba("onOpen"),yr("getHotspot",M.some),yr("getAnchorOverrides",w({})),yr("layouts",M.none()),yr("eventOrder",{}),Er("model",{},[yr("getDisplayText",(e=>void 0!==e.meta&&void 0!==e.meta.text?e.meta.text:e.value)),yr("selectsOver",!0),yr("populateFromBrowse",!0)]),Ba("onSetValue"),Na("onExecute"),Ba("onItemExecute"),yr("inputClasses",[]),yr("inputAttributes",{}),yr("inputStyles",{}),yr("matchWidth",!0),yr("useMinWidth",!1),yr("dismissOnBlur",!0),Ma(["openClass"]),ur("initialData"),gu("typeaheadBehaviours",[og,pu,fE,Hp,dg,ux]),er("lazyTypeaheadComp",(()=>Or(M.none))),er("previewing",(()=>Or(!0)))].concat(Rb()).concat(Ox())),xE=w([ju({schema:[Oa()],name:"menu",overrides:e=>({fakeFocus:!0,onHighlightItem:(t,o,n)=>{e.previewing.get()?e.lazyTypeaheadComp.get().each((t=>{((e,t,o)=>{if(e.selectsOver){const n=pu.getValue(t),r=e.getDisplayText(n),i=pu.getValue(o);return 0===e.getDisplayText(i).indexOf(r)?M.some((()=>{vE(0,t,o),((e,t)=>{bE(e,((e,o)=>e.setSelectionRange(t,o.length)))})(t,r.length)})):M.none()}return M.none()})(e.model,t,n).fold((()=>{e.model.selectsOver?($h.dehighlight(o,n),e.previewing.set(!0)):e.previewing.set(!1)}),(t=>{t(),e.previewing.set(!1)}))})):e.lazyTypeaheadComp.get().each((t=>{e.model.populateFromBrowse&&vE(e.model,t,n),Tt(n.element,"id").each((e=>Ct(t.element,"aria-activedescendant",e)))}))},onExecute:(t,o)=>e.lazyTypeaheadComp.get().map((e=>(Vi(e,wE(),{item:o}),!0))),onHover:(t,o)=>{e.previewing.set(!1),e.lazyTypeaheadComp.get().each((t=>{e.model.populateFromBrowse&&vE(e.model,t,o)}))}})})]),CE=vh({name:"Typeahead",configFields:_E(),partFields:xE(),factory:(e,t,o,n)=>{const r=(t,o,r)=>{e.previewing.set(!1);const i=ux.getCoupled(t,"sandbox");if(Gd.isOpen(i))_h.getCurrent(i).each((e=>{$h.getHighlighted(e).fold((()=>{r(e)}),(()=>{Fi(i,e.element,"keydown",o)}))}));else{const o=e=>{_h.getCurrent(e).each(r)};_x(e,s(t),t,i,n,o,Fg.HighlightMenuAndItem).get(v)}},i=Vb(e),s=e=>t=>t.map((t=>{const o=fe(t.menus),n=G(o,(e=>Z(e.items,(e=>"item"===e.type))));return pu.getState(e).update(L(n,(e=>e.data))),t})),a=e=>_h.getCurrent(e),l="typeaheadevents",c=[og.config({}),pu.config({onSetValue:e.onSetValue,store:{mode:"dataset",getDataKey:e=>Ws(e.element),getFallbackEntry:e=>({value:e,meta:{}}),setValue:(t,o)=>{qs(t.element,e.model.getDisplayText(o))},...e.initialData.map((e=>Ar("initialValue",e))).getOr({})}}),fE.config({stream:{mode:"throttle",delay:e.responseTime,stopEvent:!1},onStream:(t,o)=>{const r=ux.getCoupled(t,"sandbox");if(og.isFocused(t)&&Ws(t.element).length>=e.minChars){const o=a(r).bind((e=>$h.getHighlighted(e).map(pu.getValue)));e.previewing.set(!0);const i=t=>{a(r).each((t=>{o.fold((()=>{e.model.selectsOver&&$h.highlightFirst(t)}),(e=>{$h.highlightBy(t,(t=>pu.getValue(t).value===e.value)),$h.getHighlighted(t).orThunk((()=>($h.highlightFirst(t),M.none())))}))}))};_x(e,s(t),t,r,n,i,Fg.HighlightJustMenu).get(v)}},cancelEvent:fi()}),Hp.config({mode:"special",onDown:(e,t)=>(r(e,t,$h.highlightFirst),M.some(!0)),onEscape:e=>{const t=ux.getCoupled(e,"sandbox");return Gd.isOpen(t)?(Gd.close(t),M.some(!0)):M.none()},onUp:(e,t)=>(r(e,t,$h.highlightLast),M.some(!0)),onEnter:t=>{const o=ux.getCoupled(t,"sandbox"),n=Gd.isOpen(o);if(n&&!e.previewing.get())return a(o).bind((e=>$h.getHighlighted(e))).map((e=>(Vi(t,wE(),{item:e}),!0)));{const r=pu.getValue(t);return Ri(t,fi()),e.onExecute(o,t,r),n&&Gd.close(o),M.some(!0)}}}),dg.config({toggleClass:e.markers.openClass,aria:{mode:"expanded"}}),ux.config({others:{sandbox:t=>Tx(e,t,{onOpen:()=>dg.on(t),onClose:()=>{e.lazyTypeaheadComp.get().each((e=>Ot(e.element,"aria-activedescendant"))),dg.off(t)}})}}),Xp(l,[Ki((t=>{e.lazyTypeaheadComp.set(M.some(t))})),Xi((t=>{e.lazyTypeaheadComp.set(M.none())})),Qi((t=>{const o=v;Cx(e,s(t),t,n,o,Fg.HighlightMenuAndItem).get(v)})),Zi(wE(),((t,o)=>{const n=ux.getCoupled(t,"sandbox");vE(e.model,t,o.event.item),Ri(t,fi()),e.onItemExecute(t,n,o.event.item,pu.getValue(t)),Gd.close(n),yE(t)}))].concat(e.dismissOnBlur?[Zi(li(),(e=>{const t=ux.getCoupled(e,"sandbox");Dl(t.element).isNone()&&Gd.close(t)}))]:[]))],d={[Ci()]:[pu.name(),fE.name(),l],...e.eventOrder};return{uid:e.uid,dom:Pb(fn(e,{inputAttributes:{role:"combobox","aria-autocomplete":"list","aria-haspopup":"true"}})),behaviours:{...i,...vu(e.typeaheadBehaviours,c)},eventOrder:d}}}),kE=e=>({...e,toCached:()=>kE(e.toCached()),bindFuture:t=>kE(e.bind((e=>e.fold((e=>vx(rn.error(e))),(e=>t(e)))))),bindResult:t=>kE(e.map((e=>e.bind(t)))),mapResult:t=>kE(e.map((e=>e.map(t)))),mapError:t=>kE(e.map((e=>e.mapError(t)))),foldResult:(t,o)=>e.map((e=>e.fold(t,o))),withTimeout:(t,o)=>kE(fx((n=>{let r=!1;const i=setTimeout((()=>{r=!0,n(rn.error(o()))}),t);e.get((e=>{r||(clearTimeout(i),n(e))}))})))}),SE=e=>kE(fx(e)),TE=(e,t,o=[],n,r,i)=>{const s=t.fold((()=>({})),(e=>({action:e}))),a={buttonBehaviours:Cl([Cw((()=>!e.enabled||i.isDisabled())),xw(),cC.config({}),Xp("button press",[Hi("click"),Hi("mousedown")])].concat(o)),eventOrder:{click:["button press","alloy.base.behaviour"],mousedown:["button press","alloy.base.behaviour"]},...s},l=fn(a,{dom:n});return fn(l,{components:r})},EE=(e,t,o,n=[])=>{const r={tag:"button",classes:["tox-tbtn"],attributes:e.tooltip.map((e=>({"aria-label":o.translate(e),title:o.translate(e)}))).getOr({})},i=e.icon.map((e=>gT(e,o.icons))),s=Bw([i]);return TE(e,t,n,r,s,o)},OE=e=>{switch(e){case"primary":return["tox-button"];case"toolbar":return["tox-tbtn"];default:return["tox-button","tox-button--secondary"]}},ME=(e,t,o,n=[],r=[])=>{const i=o.translate(e.text),s=e.icon.map((e=>gT(e,o.icons))),a=[s.getOrThunk((()=>ta(i)))],l=e.buttonType.getOr(e.primary||e.borderless?"primary":"secondary"),c=[...OE(l),...s.isSome()?["tox-button--icon"]:[],...e.borderless?["tox-button--naked"]:[],...r];return TE(e,t,n,{tag:"button",classes:c,attributes:{title:i}},a,o)},AE=(e,t,o,n=[],r=[])=>{const i=ME(e,M.some(t),o,n,r);return jg.sketch(i)},BE=(e,t)=>o=>{"custom"===t?Vi(o,bC,{name:e,value:{}}):"submit"===t?Ri(o,yC):"cancel"===t?Ri(o,vC):console.error("Unknown button type: ",t)},NE=(e,t,o)=>{if(((e,t)=>"menu"===t)(0,t)){const t=()=>i,n=e,r={...e,type:"menubutton",search:M.none(),onSetup:t=>(t.setEnabled(e.enabled),v),fetch:oE(n.items,t,o)},i=$g(tE(r,"tox-tbtn",o,M.none()));return i.asSpec()}if(((e,t)=>"custom"===t||"cancel"===t||"submit"===t)(0,t)){const n=BE(e.name,t),r={...e,borderless:!1};return AE(r,n,o.shared.providers,[])}if(((e,t)=>"togglebutton"===t)(0,t))return((e,t)=>{var o,n;const r=e.icon.map((e=>fT(e,t.icons))).map($g),i=e.buttonType.getOr(e.primary?"primary":"secondary"),s={...e,name:null!==(o=e.name)&&void 0!==o?o:"",primary:"primary"===i,tooltip:M.from(e.tooltip),enabled:null!==(n=e.enabled)&&void 0!==n&&n,borderless:!1},a=s.tooltip.map((e=>({"aria-label":t.translate(e),title:t.translate(e)}))).getOr({}),l=OE(null!=i?i:"secondary"),c=e.icon.isSome()&&e.text.isSome(),d={tag:"button",classes:[...l.concat(e.icon.isSome()?["tox-button--icon"]:[]),...e.active?["tox-button--enabled"]:[],...c?["tox-button--icon-and-text"]:[]],attributes:a},u=t.translate(e.text.getOr("")),h=ta(u),m=[...Bw([r.map((e=>e.asSpec()))]),...e.text.isSome()?[h]:[]],p=TE(s,M.some((o=>{Vi(o,bC,{name:e.name,value:{setIcon:e=>{r.map((n=>n.getOpt(o).each((o=>{Kp.set(o,[fT(e,t.icons)])}))))}}})})),[],d,m,t);return jg.sketch(p)})(e,o.shared.providers);throw console.error("Unknown footer button type: ",t),new Error("Unknown footer button type")},RE={type:"separator"},VE=e=>({type:"menuitem",value:e.url,text:e.title,meta:{attach:e.attach},onAction:v}),DE=(e,t)=>({type:"menuitem",value:t,text:e,meta:{attach:void 0},onAction:v}),PE=(e,t)=>(e=>L(e,VE))(((e,t)=>Z(t,(t=>t.type===e)))(e,t)),IE=e=>PE("header",e.targets),FE=e=>PE("anchor",e.targets),LE=e=>M.from(e.anchorTop).map((e=>DE("",e))).toArray(),zE=e=>M.from(e.anchorBottom).map((e=>DE("",e))).toArray(),HE=(e,t)=>{const o=e.toLowerCase();return Z(t,(e=>{var t;const n=void 0!==e.meta&&void 0!==e.meta.text?e.meta.text:e.text,r=null!==(t=e.value)&&void 0!==t?t:"";return Ee(n.toLowerCase(),o)||Ee(r.toLowerCase(),o)}))},ZE=ls("aria-invalid"),jE=(e,t)=>{e.dom.checked=t},UE=e=>e.dom.checked,$E=e=>(t,o,n,r)=>ve(o,"name").fold((()=>e(o,r,M.none())),(i=>t.field(i,e(o,r,ve(n,i))))),WE={bar:$E(((e,t)=>((e,t)=>({dom:{tag:"div",classes:["tox-bar","tox-form__controls-h-stack"]},components:L(e.items,t.interpreter)}))(e,t.shared))),collection:$E(((e,t,o)=>((e,t,o)=>{const n=e.label.map((e=>pC(e,t))),r=e=>(t,o)=>{ga(o.event.target,"[data-collection-item-value]").each((n=>{e(t,o,n,St(n,"data-collection-item-value"))}))},i=r(((o,n,r,i)=>{n.stop(),t.isDisabled()||Vi(o,bC,{name:e.name,value:i})})),s=[Zi(qr(),r(((e,t,o)=>{Bl(o)}))),Zi(ei(),i),Zi(mi(),i),Zi(Gr(),r(((e,t,o)=>{pa(e.element,"."+Cb).each((e=>{Hs(e,Cb)})),zs(o,Cb)}))),Zi(Yr(),r((e=>{pa(e.element,"."+Cb).each((e=>{Hs(e,Cb)}))}))),Qi(r(((t,o,n,r)=>{Vi(t,bC,{name:e.name,value:r})})))],a=(e,t)=>L(Gc(e.element,".tox-collection__item"),t),l=sC.parts.field({dom:{tag:"div",classes:["tox-collection"].concat(1!==e.columns?["tox-collection--grid"]:["tox-collection--list"])},components:[],factory:{sketch:_},behaviours:Cl([Dh.config({disabled:t.isDisabled,onDisabled:e=>{a(e,(e=>{zs(e,"tox-collection__item--state-disabled"),Ct(e,"aria-disabled",!0)}))},onEnabled:e=>{a(e,(e=>{Hs(e,"tox-collection__item--state-disabled"),Ot(e,"aria-disabled")}))}}),xw(),Kp.config({}),pu.config({store:{mode:"memory",initialValue:o.getOr([])},onSetValue:(o,n)=>{((o,n)=>{const r=L(n,(o=>{const n=Wf.translate(o.text),r=1===e.columns?`${n}
`:"",i=`${o.icon}
`,s={_:" "," - ":" ","-":" "},a=n.replace(/\_| \- |\-/g,(e=>s[e]));return`${i}${r}
`})),i="auto"!==e.columns&&e.columns>1?F(r,e.columns):[r],s=L(i,(e=>`${e.join("")}
`));ts(o.element,s.join(""))})(o,n),"auto"===e.columns&&aw(o,5,"tox-collection__item").each((({numRows:e,numColumns:t})=>{Hp.setGridSize(o,e,t)})),Ri(o,CC)}}),cC.config({}),Hp.config((c=e.columns,1===c?{mode:"menu",moveOnTab:!1,selector:".tox-collection__item"}:"auto"===c?{mode:"flatgrid",selector:".tox-collection__item",initSize:{numColumns:1,numRows:1}}:{mode:"matrix",selectors:{row:".tox-collection__group",cell:`.${fb}`}})),Xp("collection-events",s)]),eventOrder:{[ui()]:["disabling","alloy.base.behaviour","collection-events"]}});var c;return uC(n,l,["tox-form__group--collection"],[])})(e,t.shared.providers,o))),alertbanner:$E(((e,t)=>((e,t)=>{const o=Jf(e.icon,t.icons);return oC.sketch({dom:{tag:"div",attributes:{role:"alert"},classes:["tox-notification","tox-notification--in",`tox-notification--${e.level}`]},components:[{dom:{tag:"div",classes:["tox-notification__icon"],innerHtml:e.url?void 0:o},components:e.url?[jg.sketch({dom:{tag:"button",classes:["tox-button","tox-button--naked","tox-button--icon"],innerHtml:o,attributes:{title:t.translate(e.iconTooltip)}},action:t=>Vi(t,bC,{name:"alert-banner",value:e.url}),buttonBehaviours:Cl([Qf()])})]:void 0},{dom:{tag:"div",classes:["tox-notification__body"],innerHtml:t.translate(e.text)}}]})})(e,t.shared.providers))),input:$E(((e,t,o)=>((e,t,o)=>IT({name:e.name,multiline:!1,label:e.label,inputMode:e.inputMode,placeholder:e.placeholder,flex:!1,disabled:!e.enabled,classname:"tox-textfield",validation:M.none(),maximized:e.maximized,data:o},t))(e,t.shared.providers,o))),textarea:$E(((e,t,o)=>((e,t,o)=>IT({name:e.name,multiline:!0,label:e.label,inputMode:M.none(),placeholder:e.placeholder,flex:!0,disabled:!e.enabled,classname:"tox-textarea",validation:M.none(),maximized:e.maximized,data:o},t))(e,t.shared.providers,o))),label:$E(((e,t)=>((e,t)=>{const o="tox-label";return{dom:{tag:"div",classes:["tox-form__group"]},components:[{dom:{tag:"label",classes:[o,..."center"===e.align?[`${o}--center`]:[],..."end"===e.align?[`${o}--end`]:[]]},components:[ta(t.providers.translate(e.label))]},...L(e.items,t.interpreter)],behaviours:Cl([BS(),Kp.config({}),(n=M.none(),PS(n,es,ts)),Hp.config({mode:"acyclic"})])};var n})(e,t.shared))),iframe:(bM=(e,t,o)=>((e,t,o)=>{const n="tox-dialog__iframe",r=e.transparent?[]:[`${n}--opaque`],i=e.border?["tox-navobj-bordered"]:[],s={...e.label.map((e=>({title:e}))).getOr({}),...o.map((e=>({srcdoc:e}))).getOr({}),...e.sandboxed?{sandbox:"allow-scripts allow-same-origin"}:{}},a=((e,t)=>{const o=Or(e.getOr(""));return{getValue:e=>o.get(),setValue:(e,n)=>{if(o.get()!==n){const o=e.element,r=()=>Ct(o,"srcdoc",n);t?cT.fold(w(lT),(e=>e.throttle))(o,n,r):r()}o.set(n)}}})(o,e.streamContent),l=e.label.map((e=>pC(e,t))),c=sC.parts.field({factory:{sketch:e=>$S(M.from(i),{uid:e.uid,dom:{tag:"iframe",attributes:s,classes:[n,...r]},behaviours:Cl([cC.config({}),og.config({}),DS(o,a.getValue,a.setValue),Ml.config({channels:{[eT]:{onReceive:(e,t)=>{t.newFocus.each((t=>{it(e.element).each((o=>{(Je(e.element,t)?zs:Hs)(o,"tox-navobj-bordered-focus")}))}))}}}})])})}});return uC(l,c,["tox-form__group--stretched"],[])})(e,t.shared.providers,o),(e,t,o,n)=>{const r=fn(t,{source:"dynamic"});return $E(bM)(e,r,o,n)}),button:$E(((e,t)=>((e,t)=>{const o=BE(e.name,"custom");return n=M.none(),r=sC.parts.field({factory:jg,...ME(e,M.some(o),t,[IS(""),BS()])}),uC(n,r,[],[]);var n,r})(e,t.shared.providers))),checkbox:$E(((e,t,o)=>((e,t,o)=>{const n=e=>(e.element.dom.click(),M.some(!0)),r=sC.parts.field({factory:{sketch:_},dom:{tag:"input",classes:["tox-checkbox__input"],attributes:{type:"checkbox"}},behaviours:Cl([BS(),Dh.config({disabled:()=>!e.enabled||t.isDisabled(),onDisabled:e=>{it(e.element).each((e=>zs(e,"tox-checkbox--disabled")))},onEnabled:e=>{it(e.element).each((e=>Hs(e,"tox-checkbox--disabled")))}}),cC.config({}),og.config({}),PS(o,UE,jE),Hp.config({mode:"special",onEnter:n,onSpace:n,stopSpaceKeyup:!0}),Xp("checkbox-events",[Zi(Qr(),((t,o)=>{Vi(t,gC,{name:e.name})}))])])}),i=sC.parts.label({dom:{tag:"span",classes:["tox-checkbox__label"]},components:[ta(t.translate(e.label))],behaviours:Cl([VC.config({})])}),s=e=>tv("checked"===e?"selected":"unselected",{tag:"span",classes:["tox-icon","tox-checkbox-icon__"+e]},t.icons),a=$g({dom:{tag:"div",classes:["tox-checkbox__icons"]},components:[s("checked"),s("unchecked")]});return sC.sketch({dom:{tag:"label",classes:["tox-checkbox"]},components:[r,a.asSpec(),i],fieldBehaviours:Cl([Dh.config({disabled:()=>!e.enabled||t.isDisabled()}),xw()])})})(e,t.shared.providers,o))),colorinput:$E(((e,t,o)=>((e,t,o,n)=>{const r=sC.parts.field({factory:Ib,inputClasses:["tox-textfield"],data:n,onSetValue:e=>RC.run(e).get(v),inputBehaviours:Cl([Dh.config({disabled:t.providers.isDisabled}),xw(),cC.config({}),RC.config({invalidClass:"tox-textbox-field-invalid",getRoot:e=>it(e.element),notify:{onValid:e=>{const t=pu.getValue(e);Vi(e,DC,{color:t})}},validator:{validateOnLoad:!1,validate:e=>{const t=pu.getValue(e);if(0===t.length)return vx(rn.value(!0));{const e=De("span");Bt(e,"background-color",t);const o=Pt(e,"background-color").fold((()=>rn.error("blah")),(e=>rn.value(t)));return vx(o)}}}})]),selectOnFocus:!1}),i=e.label.map((e=>pC(e,t.providers))),s=(e,t)=>{Vi(e,PC,{value:t})},a=$g(((e,t)=>Bx.sketch({dom:e.dom,components:e.components,toggleClass:"mce-active",dropdownBehaviours:Cl([Cw(t.providers.isDisabled),xw(),VC.config({}),cC.config({})]),layouts:e.layouts,sandboxClasses:["tox-dialog__popups"],lazySink:t.getSink,fetch:o=>fx((t=>e.fetch(t))).map((n=>M.from(Lx(fn(J_(ls("menu-value"),n,(t=>{e.onItemAction(o,t)}),e.columns,e.presets,pb.CLOSE_ON_EXECUTE,E,t.providers),{movement:ex(e.columns,e.presets)}))))),parts:{menu:Nb(0,0,e.presets)}}))({dom:{tag:"span",attributes:{"aria-label":t.providers.translate("Color swatch")}},layouts:{onRtl:()=>[il,rl,cl],onLtr:()=>[rl,il,cl]},components:[],fetch:W_(o.getColors(e.storageKey),e.storageKey,o.hasCustomColors()),columns:o.getColorCols(e.storageKey),presets:"color",onItemAction:(t,n)=>{a.getOpt(t).each((t=>{"custom"===n?o.colorPicker((o=>{o.fold((()=>Ri(t,IC)),(o=>{s(t,o),S_(e.storageKey,o)}))}),"#ffffff"):s(t,"remove"===n?"":n)}))}},t));return sC.sketch({dom:{tag:"div",classes:["tox-form__group"]},components:i.toArray().concat([{dom:{tag:"div",classes:["tox-color-input"]},components:[r,a.asSpec()]}]),fieldBehaviours:Cl([Xp("form-field-events",[Zi(DC,((t,o)=>{a.getOpt(t).each((e=>{Bt(e.element,"background-color",o.event.color)})),Vi(t,gC,{name:e.name})})),Zi(PC,((e,t)=>{sC.getField(e).each((o=>{pu.setValue(o,t.event.value),_h.getCurrent(e).each(og.focus)}))})),Zi(IC,((e,t)=>{sC.getField(e).each((t=>{_h.getCurrent(e).each(og.focus)}))}))])])})})(e,t.shared,t.colorinput,o))),colorpicker:$E(((e,t,o)=>((e,t,o)=>{const n=e=>"tox-"+e,r=AS((e=>t=>e.translate(FS[t]))(t),n),i=$g(r.sketch({dom:{tag:"div",classes:[n("color-picker-container")],attributes:{role:"presentation"}},onValidHex:e=>{Vi(e,bC,{name:"hex-valid",value:!0})},onInvalidHex:e=>{Vi(e,bC,{name:"hex-valid",value:!1})}}));return{dom:{tag:"div"},components:[i.asSpec()],behaviours:Cl([DS(o,(e=>{const t=i.get(e);return _h.getCurrent(t).bind((e=>pu.getValue(e).hex)).map((e=>"#"+Te(e,"#"))).getOr("")}),((e,t)=>{const o=M.from(/^#([a-fA-F0-9]{3}(?:[a-fA-F0-9]{3})?)/.exec(t)).bind((e=>te(e,1))),n=i.get(e);_h.getCurrent(n).fold((()=>{console.log("Can not find form")}),(e=>{pu.setValue(e,{hex:o.getOr("")}),kS.getField(e,"hex").each((e=>{Ri(e,Jr())}))}))})),BS()])}})(0,t.shared.providers,o))),dropzone:$E(((e,t,o)=>((e,t,o)=>{const n=(e,t)=>{t.stop()},r=e=>(t,o)=>{z(e,(e=>{e(t,o)}))},i=(e,t)=>{var o;if(!Dh.isDisabled(e)){const n=t.event.raw;a(e,null===(o=n.dataTransfer)||void 0===o?void 0:o.files)}},s=(e,t)=>{const o=t.event.raw.target;a(e,o.files)},a=(o,n)=>{n&&(pu.setValue(o,((e,t)=>{const o=zS.explode(t.getOption("images_file_types"));return Z(re(e),(e=>P(o,(t=>Me(e.name.toLowerCase(),`.${t.toLowerCase()}`)))))})(n,t)),Vi(o,gC,{name:e.name}))},l=$g({dom:{tag:"input",attributes:{type:"file",accept:"image/*"},styles:{display:"none"}},behaviours:Cl([Xp("input-file-events",[qi(ei()),qi(mi())])])}),c=e.label.map((e=>pC(e,t))),d=sC.parts.field({factory:{sketch:e=>({uid:e.uid,dom:{tag:"div",classes:["tox-dropzone-container"]},behaviours:Cl([IS(o.getOr([])),BS(),Dh.config({}),dg.config({toggleClass:"dragenter",toggleOnExecute:!1}),Xp("dropzone-events",[Zi("dragenter",r([n,dg.toggle])),Zi("dragleave",r([n,dg.toggle])),Zi("dragover",n),Zi("drop",r([n,i])),Zi(Qr(),s)])]),components:[{dom:{tag:"div",classes:["tox-dropzone"],styles:{}},components:[{dom:{tag:"p"},components:[ta(t.translate("Drop an image here"))]},jg.sketch({dom:{tag:"button",styles:{position:"relative"},classes:["tox-button","tox-button--secondary"]},components:[ta(t.translate("Browse for an image")),l.asSpec()],action:e=>{l.get(e).element.dom.click()},buttonBehaviours:Cl([cC.config({}),Cw(t.isDisabled),xw()])})]}]})}});return uC(c,d,["tox-form__group--stretched"],[])})(e,t.shared.providers,o))),grid:$E(((e,t)=>((e,t)=>({dom:{tag:"div",classes:["tox-form__grid",`tox-form__grid--${e.columns}col`]},components:L(e.items,t.interpreter)}))(e,t.shared))),listbox:$E(((e,t,o)=>((e,t,o)=>{const n=t.shared.providers,r=o.bind((t=>OT(e.items,t))).orThunk((()=>oe(e.items).filter(ST))),i=e.label.map((e=>pC(e,n))),s=sC.parts.field({dom:{},factory:{sketch:o=>wT({uid:o.uid,text:r.map((e=>e.text)),icon:M.none(),tooltip:e.label,role:M.none(),fetch:(o,n)=>{const r=ET(o,e.name,e.items,pu.getValue(o));n(kT(r,pb.CLOSE_ON_EXECUTE,t,{isHorizontalMenu:!1,search:M.none()}))},onSetup:w(v),getApi:w({}),columns:1,presets:"normal",classes:[],dropdownBehaviours:[cC.config({}),DS(r.map((e=>e.value)),(e=>St(e.element,TT)),((t,o)=>{OT(e.items,o).each((e=>{Ct(t.element,TT,e.value),Vi(t,bT,{text:e.text})}))}))]},"tox-listbox",t.shared)}}),a={dom:{tag:"div",classes:["tox-listboxfield"]},components:[s]};return sC.sketch({dom:{tag:"div",classes:["tox-form__group"]},components:q([i.toArray(),[a]]),fieldBehaviours:Cl([Dh.config({disabled:w(!e.enabled),onDisabled:e=>{sC.getField(e).each(Dh.disable)},onEnabled:e=>{sC.getField(e).each(Dh.enable)}})])})})(e,t,o))),selectbox:$E(((e,t,o)=>((e,t,o)=>{const n=L(e.items,(e=>({text:t.translate(e.text),value:e.value}))),r=e.label.map((e=>pC(e,t))),i=sC.parts.field({dom:{},...o.map((e=>({data:e}))).getOr({}),selectAttributes:{size:e.size},options:n,factory:MT,selectBehaviours:Cl([Dh.config({disabled:()=>!e.enabled||t.isDisabled()}),cC.config({}),Xp("selectbox-change",[Zi(Qr(),((t,o)=>{Vi(t,gC,{name:e.name})}))])])}),s=e.size>1?M.none():M.some(tv("chevron-down",{tag:"div",classes:["tox-selectfield__icon-js"]},t.icons)),a={dom:{tag:"div",classes:["tox-selectfield"]},components:q([[i],s.toArray()])};return sC.sketch({dom:{tag:"div",classes:["tox-form__group"]},components:q([r.toArray(),[a]]),fieldBehaviours:Cl([Dh.config({disabled:()=>!e.enabled||t.isDisabled(),onDisabled:e=>{sC.getField(e).each(Dh.disable)},onEnabled:e=>{sC.getField(e).each(Dh.enable)}}),xw()])})})(e,t.shared.providers,o))),sizeinput:$E(((e,t)=>((e,t)=>{let o=PT;const n=ls("ratio-event"),r=e=>tv(e,{tag:"span",classes:["tox-icon","tox-lock-icon__"+e]},t.icons),i=RT.parts.lock({dom:{tag:"button",classes:["tox-lock","tox-button","tox-button--naked","tox-button--icon"],attributes:{title:t.translate(e.label.getOr("Constrain proportions"))}},components:[r("lock"),r("unlock")],buttonBehaviours:Cl([Dh.config({disabled:()=>!e.enabled||t.isDisabled()}),xw(),cC.config({})])}),s=e=>({dom:{tag:"div",classes:["tox-form__group"]},components:e}),a=o=>sC.parts.field({factory:Ib,inputClasses:["tox-textfield"],inputBehaviours:Cl([Dh.config({disabled:()=>!e.enabled||t.isDisabled()}),xw(),cC.config({}),Xp("size-input-events",[Zi(Gr(),((e,t)=>{Vi(e,n,{isField1:o})})),Zi(Qr(),((t,o)=>{Vi(t,gC,{name:e.name})}))])]),selectOnFocus:!1}),l=e=>({dom:{tag:"label",classes:["tox-label"]},components:[ta(t.translate(e))]}),c=RT.parts.field1(s([sC.parts.label(l("Width")),a(!0)])),d=RT.parts.field2(s([sC.parts.label(l("Height")),a(!1)]));return RT.sketch({dom:{tag:"div",classes:["tox-form__group"]},components:[{dom:{tag:"div",classes:["tox-form__controls-h-stack"]},components:[c,d,s([l(" "),i])]}],field1Name:"width",field2Name:"height",locked:!0,markers:{lockClass:"tox-locked"},onLockedChange:(e,t,n)=>{VT(pu.getValue(e)).each((e=>{o(e).each((e=>{pu.setValue(t,(e=>{const t={"":0,px:0,pt:1,mm:1,pc:2,ex:2,em:2,ch:2,rem:2,cm:3,in:4,"%":4};let o=e.value.toFixed((n=e.unit)in t?t[n]:1);var n;return-1!==o.indexOf(".")&&(o=o.replace(/\.?0*$/,"")),o+e.unit})(e))}))}))},coupledFieldBehaviours:Cl([Dh.config({disabled:()=>!e.enabled||t.isDisabled(),onDisabled:e=>{RT.getField1(e).bind(sC.getField).each(Dh.disable),RT.getField2(e).bind(sC.getField).each(Dh.disable),RT.getLock(e).each(Dh.disable)},onEnabled:e=>{RT.getField1(e).bind(sC.getField).each(Dh.enable),RT.getField2(e).bind(sC.getField).each(Dh.enable),RT.getLock(e).each(Dh.enable)}}),xw(),Xp("size-input-events2",[Zi(n,((e,t)=>{const n=t.event.isField1,r=n?RT.getField1(e):RT.getField2(e),i=n?RT.getField2(e):RT.getField1(e),s=r.map(pu.getValue).getOr(""),a=i.map(pu.getValue).getOr("");o=((e,t)=>{const o=VT(e).toOptional(),n=VT(t).toOptional();return xe(o,n,((e,t)=>DT(e,t.unit).map((e=>t.value/e)).map((e=>{return o=e,n=t.unit,e=>DT(e,n).map((e=>({value:e*o,unit:n})));var o,n})).getOr(PT))).getOr(PT)})(s,a)}))])])})})(e,t.shared.providers))),slider:$E(((e,t,o)=>((e,t,o)=>{const n=fS.parts.label({dom:{tag:"label",classes:["tox-label"]},components:[ta(t.translate(e.label))]}),r=fS.parts.spectrum({dom:{tag:"div",classes:["tox-slider__rail"],attributes:{role:"presentation"}}}),i=fS.parts.thumb({dom:{tag:"div",classes:["tox-slider__handle"],attributes:{role:"presentation"}}});return fS.sketch({dom:{tag:"div",classes:["tox-slider"],attributes:{role:"presentation"}},model:{mode:"x",minX:e.min,maxX:e.max,getInitialValue:w(o.getOrThunk((()=>(Math.abs(e.max)-Math.abs(e.min))/2)))},components:[n,r,i],sliderBehaviours:Cl([BS(),og.config({})]),onChoose:(t,o,n)=>{Vi(t,gC,{name:e.name,value:n})}})})(e,t.shared.providers,o))),urlinput:$E(((e,t,o)=>((e,t,o,n)=>{const r=t.shared.providers,i=t=>{const n=pu.getValue(t);o.addToHistory(n.value,e.filetype)},s={...n.map((e=>({initialData:e}))).getOr({}),dismissOnBlur:!0,inputClasses:["tox-textfield"],sandboxClasses:["tox-dialog__popups"],inputAttributes:{"aria-errormessage":ZE,type:"url"},minChars:0,responseTime:0,fetch:n=>{const r=((e,t,o)=>{var n,r;const i=pu.getValue(t),s=null!==(r=null===(n=null==i?void 0:i.meta)||void 0===n?void 0:n.text)&&void 0!==r?r:i.value;return o.getLinkInformation().fold((()=>[]),(t=>{const n=HE(s,(e=>L(e,(e=>DE(e,e))))(o.getHistory(e)));return"file"===e?(r=[n,HE(s,IE(t)),HE(s,q([LE(t),FE(t),zE(t)]))],U(r,((e,t)=>0===e.length||0===t.length?e.concat(t):e.concat(RE,t)),[])):n;var r}))})(e.filetype,n,o),i=kT(r,pb.BUBBLE_TO_SANDBOX,t,{isHorizontalMenu:!1,search:M.none()});return vx(i)},getHotspot:e=>m.getOpt(e),onSetValue:(e,t)=>{e.hasConfigured(RC)&&RC.run(e).get(v)},typeaheadBehaviours:Cl([...o.getValidationHandler().map((t=>RC.config({getRoot:e=>it(e.element),invalidClass:"tox-control-wrap--status-invalid",notify:{onInvalid:(e,t)=>{c.getOpt(e).each((e=>{Ct(e.element,"title",r.translate(t))}))}},validator:{validate:o=>{const n=pu.getValue(o);return SE((o=>{t({type:e.filetype,url:n.value},(e=>{if("invalid"===e.status){const t=rn.error(e.message);o(t)}else{const t=rn.value(e.message);o(t)}}))}))},validateOnLoad:!1}}))).toArray(),Dh.config({disabled:()=>!e.enabled||r.isDisabled()}),cC.config({}),Xp("urlinput-events",[Zi(Jr(),(t=>{const o=Ws(t.element),n=o.trim();n!==o&&qs(t.element,n),"file"===e.filetype&&Vi(t,gC,{name:e.name})})),Zi(Qr(),(t=>{Vi(t,gC,{name:e.name}),i(t)})),Zi(ci(),(t=>{Vi(t,gC,{name:e.name}),i(t)}))])]),eventOrder:{[Jr()]:["streaming","urlinput-events","invalidating"]},model:{getDisplayText:e=>e.value,selectsOver:!1,populateFromBrowse:!1},markers:{openClass:"tox-textfield--popup-open"},lazySink:t.shared.getSink,parts:{menu:Nb(0,0,"normal")},onExecute:(e,t,o)=>{Vi(t,yC,{})},onItemExecute:(t,o,n,r)=>{i(t),Vi(t,gC,{name:e.name})}},a=sC.parts.field({...s,factory:CE}),l=e.label.map((e=>pC(e,r))),c=$g(((e,t,o=e,n=e)=>tv(o,{tag:"div",classes:["tox-icon","tox-control-wrap__status-icon-"+e],attributes:{title:r.translate(n),"aria-live":"polite",...t.fold((()=>({})),(e=>({id:e})))}},r.icons))("invalid",M.some(ZE),"warning")),d=$g({dom:{tag:"div",classes:["tox-control-wrap__status-icon-wrap"]},components:[c.asSpec()]}),u=o.getUrlPicker(e.filetype),h=ls("browser.url.event"),m=$g({dom:{tag:"div",classes:["tox-control-wrap"]},components:[a,d.asSpec()],behaviours:Cl([Dh.config({disabled:()=>!e.enabled||r.isDisabled()})])}),p=$g(AE({name:e.name,icon:M.some("browse"),text:e.label.getOr(""),enabled:e.enabled,primary:!1,buttonType:M.none(),borderless:!0},(e=>Ri(e,h)),r,[],["tox-browse-url"]));return sC.sketch({dom:mC([]),components:l.toArray().concat([{dom:{tag:"div",classes:["tox-form__controls-h-stack"]},components:q([[m.asSpec()],u.map((()=>p.asSpec())).toArray()])}]),fieldBehaviours:Cl([Dh.config({disabled:()=>!e.enabled||r.isDisabled(),onDisabled:e=>{sC.getField(e).each(Dh.disable),p.getOpt(e).each(Dh.disable)},onEnabled:e=>{sC.getField(e).each(Dh.enable),p.getOpt(e).each(Dh.enable)}}),xw(),Xp("url-input-events",[Zi(h,(t=>{_h.getCurrent(t).each((o=>{const n=pu.getValue(o),r={fieldname:e.name,...n};u.each((n=>{n(r).get((n=>{pu.setValue(o,n),Vi(t,gC,{name:e.name})}))}))}))}))])])})})(e,t,t.urlinput,o))),customeditor:$E((e=>{const t=Ql(),o=$g({dom:{tag:e.tag}}),n=Ql();return{dom:{tag:"div",classes:["tox-custom-editor"]},behaviours:Cl([Xp("custom-editor-events",[Ki((r=>{o.getOpt(r).each((o=>{((e=>be(e,"init"))(e)?e.init(o.element.dom):LS.load(e.scriptId,e.scriptUrl).then((t=>t(o.element.dom,e.settings)))).then((e=>{n.on((t=>{e.setValue(t)})),n.clear(),t.set(e)}))}))}))]),DS(M.none(),(()=>t.get().fold((()=>n.get().getOr("")),(e=>e.getValue()))),((e,o)=>{t.get().fold((()=>n.set(o)),(e=>e.setValue(o)))})),BS()]),components:[o.asSpec()]}})),htmlpanel:$E((e=>"presentation"===e.presets?oC.sketch({dom:{tag:"div",classes:["tox-form__group"],innerHtml:e.html}}):oC.sketch({dom:{tag:"div",classes:["tox-form__group"],innerHtml:e.html,attributes:{role:"document"}},containerBehaviours:Cl([cC.config({}),og.config({})])}))),imagepreview:$E(((e,t,o)=>((e,t)=>{const o=Or(t.getOr({url:""})),n=$g({dom:{tag:"img",classes:["tox-imagepreview__image"],attributes:t.map((e=>({src:e.url}))).getOr({})}}),r=$g({dom:{tag:"div",classes:["tox-imagepreview__container"],attributes:{role:"presentation"}},components:[n.asSpec()]}),i={};e.height.each((e=>i.height=e));const s=t.map((e=>({url:e.url,zoom:M.from(e.zoom),cachedWidth:M.from(e.cachedWidth),cachedHeight:M.from(e.cachedHeight)})));return{dom:{tag:"div",classes:["tox-imagepreview"],styles:i,attributes:{role:"presentation"}},components:[r.asSpec()],behaviours:Cl([BS(),DS(s,(()=>o.get()),((e,t)=>{const i={url:t.url};t.zoom.each((e=>i.zoom=e)),t.cachedWidth.each((e=>i.cachedWidth=e)),t.cachedHeight.each((e=>i.cachedHeight=e)),o.set(i);const s=()=>{const{cachedWidth:t,cachedHeight:o,zoom:n}=i;if(!u(t)&&!u(o)){if(u(n)){const n=((e,t,o)=>{const n=Xt(e),r=jt(e);return Math.min(n/t,r/o,1)})(e.element,t,o);i.zoom=n}const s=((e,t,o,n,r)=>{const i=o*r,s=n*r,a=Math.max(0,e/2-i/2),l=Math.max(0,t/2-s/2);return{left:a.toString()+"px",top:l.toString()+"px",width:i.toString()+"px",height:s.toString()+"px"}})(Xt(e.element),jt(e.element),t,o,i.zoom);r.getOpt(e).each((e=>{Nt(e.element,s)}))}};n.getOpt(e).each((o=>{const n=o.element;var r;t.url!==St(n,"src")&&(Ct(n,"src",t.url),Hs(e.element,"tox-imagepreview__loaded")),s(),(r=n,new Promise(((e,t)=>{const o=()=>{i(),e(r)},n=[tc(r,"load",o),tc(r,"error",(()=>{i(),t("Unable to load data from image: "+r.dom.src)}))],i=()=>z(n,(e=>e.unbind()));r.dom.complete&&o()}))).then((t=>{e.getSystem().isConnected()&&(zs(e.element,"tox-imagepreview__loaded"),i.cachedWidth=t.dom.naturalWidth,i.cachedHeight=t.dom.naturalHeight,s())}))}))}))])}})(e,o))),table:$E(((e,t)=>((e,t)=>{const o=e=>({dom:{tag:"td",innerHtml:t.translate(e)}});return{dom:{tag:"table",classes:["tox-dialog__table"]},components:[(r=e.header,{dom:{tag:"thead"},components:[{dom:{tag:"tr"},components:L(r,(e=>({dom:{tag:"th",innerHtml:t.translate(e)}})))}]}),(n=e.cells,{dom:{tag:"tbody"},components:L(n,(e=>({dom:{tag:"tr"},components:L(e,o)})))})],behaviours:Cl([cC.config({}),og.config({})])};var n,r})(e,t.shared.providers))),tree:$E(((e,t)=>((e,t)=>{const o=e.onLeafAction.getOr(v),n=e.onToggleExpand.getOr(v),r=e.defaultExpandedIds,i=Or(r),s=Or(e.defaultSelectedId),a=ls("tree-id"),l=(n,r)=>e.items.map((e=>"leaf"===e.type?iE({leaf:e,selectedId:n,onLeafAction:o,visible:!0,treeId:a,backstage:t}):dE({directory:e,selectedId:n,onLeafAction:o,expandedIds:r,labelTabstopping:!0,treeId:a,backstage:t})));return{dom:{tag:"div",classes:["tox-tree"],attributes:{role:"tree"}},components:l(s.get(),i.get()),behaviours:Cl([Hp.config({mode:"flow",selector:".tox-tree--leaf__label--visible, .tox-tree--directory__label--visible",cycles:!1}),Xp(uE,[Zi("expand-tree-node",((e,t)=>{const{expanded:o,node:r}=t.event;i.set(o?[...i.get(),r]:i.get().filter((e=>e!==r))),n(i.get(),{expanded:o,node:r})}))]),Ml.config({channels:{[`update-active-item-${a}`]:{onReceive:(e,t)=>{s.set(M.some(t.value)),Kp.set(e,l(M.some(t.value),i.get()))}}}}),Kp.config({})])}})(e,t))),panel:$E(((e,t)=>((e,t)=>({dom:{tag:"div",classes:e.classes},components:L(e.items,t.shared.interpreter)}))(e,t)))},qE={field:(e,t)=>t,record:w([])},GE=(e,t,o,n)=>{const r=fn(n,{shared:{interpreter:t=>YE(e,t,o,r)}});return YE(e,t,o,r)},YE=(e,t,o,n)=>ve(WE,t.type).fold((()=>(console.error(`Unknown factory type "${t.type}", defaulting to container: `,t),t)),(r=>r(e,t,o,n))),KE=(e,t,o)=>YE(qE,e,t,o),XE="layout-inset",JE=e=>e.x,QE=(e,t)=>e.x+e.width/2-t.width/2,eO=(e,t)=>e.x+e.width-t.width,tO=e=>e.y,oO=(e,t)=>e.y+e.height-t.height,nO=(e,t)=>e.y+e.height/2-t.height/2,rO=(e,t,o)=>Fa(eO(e,t),oO(e,t),o.insetSouthwest(),ja(),"southwest",Ka(e,{right:0,bottom:3}),XE),iO=(e,t,o)=>Fa(JE(e),oO(e,t),o.insetSoutheast(),Za(),"southeast",Ka(e,{left:1,bottom:3}),XE),sO=(e,t,o)=>Fa(eO(e,t),tO(e),o.insetNorthwest(),Ha(),"northwest",Ka(e,{right:0,top:2}),XE),aO=(e,t,o)=>Fa(JE(e),tO(e),o.insetNortheast(),za(),"northeast",Ka(e,{left:1,top:2}),XE),lO=(e,t,o)=>Fa(QE(e,t),tO(e),o.insetNorth(),Ua(),"north",Ka(e,{top:2}),XE),cO=(e,t,o)=>Fa(QE(e,t),oO(e,t),o.insetSouth(),$a(),"south",Ka(e,{bottom:3}),XE),dO=(e,t,o)=>Fa(eO(e,t),nO(e,t),o.insetEast(),qa(),"east",Ka(e,{right:0}),XE),uO=(e,t,o)=>Fa(JE(e),nO(e,t),o.insetWest(),Wa(),"west",Ka(e,{left:1}),XE),hO=e=>{switch(e){case"north":return lO;case"northeast":return aO;case"northwest":return sO;case"south":return cO;case"southeast":return iO;case"southwest":return rO;case"east":return dO;case"west":return uO}},mO=(e,t,o,n,r)=>Gl(n).map(hO).getOr(lO)(e,t,o,n,r),pO=e=>{switch(e){case"north":return cO;case"northeast":return iO;case"northwest":return rO;case"south":return lO;case"southeast":return aO;case"southwest":return sO;case"east":return uO;case"west":return dO}},gO=(e,t,o,n,r)=>Gl(n).map(pO).getOr(lO)(e,t,o,n,r),fO={valignCentre:[],alignCentre:[],alignLeft:[],alignRight:[],right:[],left:[],bottom:[],top:[]},vO=(e,t,o)=>{const n={maxHeightFunction:cc()};return()=>o()?{type:"node",root:ft(gt(e())),node:M.from(e()),bubble:mc(12,12,fO),layouts:{onRtl:()=>[aO],onLtr:()=>[sO]},overrides:n}:{type:"hotspot",hotspot:t(),bubble:mc(-12,12,fO),layouts:{onRtl:()=>[rl,il,cl],onLtr:()=>[il,rl,cl]},overrides:n}},bO=(e,t,o,n)=>{const r={maxHeightFunction:cc()};return()=>n()?{type:"node",root:ft(gt(t())),node:M.from(t()),bubble:mc(12,12,fO),layouts:{onRtl:()=>[lO],onLtr:()=>[lO]},overrides:r}:e?{type:"node",root:ft(gt(t())),node:M.from(t()),bubble:mc(0,-Ut(t()),fO),layouts:{onRtl:()=>[ll],onLtr:()=>[ll]},overrides:r}:{type:"hotspot",hotspot:o(),bubble:mc(0,0,fO),layouts:{onRtl:()=>[ll],onLtr:()=>[ll]},overrides:r}},yO=(e,t,o)=>()=>o()?{type:"node",root:ft(gt(e())),node:M.from(e()),layouts:{onRtl:()=>[lO],onLtr:()=>[lO]}}:{type:"hotspot",hotspot:t(),layouts:{onRtl:()=>[cl],onLtr:()=>[cl]}},wO=(e,t)=>()=>({type:"selection",root:t(),getSelection:()=>{const t=e.selection.getRng(),o=e.model.table.getSelectedCells();if(o.length>1){const e=o[0],t=o[o.length-1],n={firstCell:Ie(e),lastCell:Ie(t)};return M.some(n)}return M.some(zc.range(Ie(t.startContainer),t.startOffset,Ie(t.endContainer),t.endOffset))}}),_O=e=>t=>({type:"node",root:e(),node:t}),xO=(e,t,o,n)=>{const r=rb(e),i=()=>Ie(e.getBody()),s=()=>Ie(e.getContentAreaContainer()),a=()=>r||!n();return{inlineDialog:vO(s,t,a),inlineBottomDialog:bO(e.inline,s,o,a),banner:yO(s,t,a),cursor:wO(e,i),node:_O(i)}},CO=e=>(t,o)=>{X_(e)(t,o)},kO=e=>()=>L_(e),SO=e=>t=>D_(e,t),TO=e=>t=>F_(e,t),EO=e=>()=>zv(e),OO=e=>ye(e,"items"),MO=e=>ye(e,"format"),AO=[{title:"Headings",items:[{title:"Heading 1",format:"h1"},{title:"Heading 2",format:"h2"},{title:"Heading 3",format:"h3"},{title:"Heading 4",format:"h4"},{title:"Heading 5",format:"h5"},{title:"Heading 6",format:"h6"}]},{title:"Inline",items:[{title:"Bold",format:"bold"},{title:"Italic",format:"italic"},{title:"Underline",format:"underline"},{title:"Strikethrough",format:"strikethrough"},{title:"Superscript",format:"superscript"},{title:"Subscript",format:"subscript"},{title:"Code",format:"code"}]},{title:"Blocks",items:[{title:"Paragraph",format:"p"},{title:"Blockquote",format:"blockquote"},{title:"Div",format:"div"},{title:"Pre",format:"pre"}]},{title:"Align",items:[{title:"Left",format:"alignleft"},{title:"Center",format:"aligncenter"},{title:"Right",format:"alignright"},{title:"Justify",format:"alignjustify"}]}],BO=e=>U(e,((e,t)=>{if(be(t,"items")){const o=BO(t.items);return{customFormats:e.customFormats.concat(o.customFormats),formats:e.formats.concat([{title:t.title,items:o.formats}])}}if(be(t,"inline")||(e=>be(e,"block"))(t)||(e=>be(e,"selector"))(t)){const o=`custom-${i(t.name)?t.name:t.title.toLowerCase()}`;return{customFormats:e.customFormats.concat([{name:o,format:t}]),formats:e.formats.concat([{title:t.title,format:o,icon:t.icon}])}}return{...e,formats:e.formats.concat(t)}}),{customFormats:[],formats:[]}),NO=e=>yv(e).map((t=>{const o=((e,t)=>{const o=BO(t),n=t=>{z(t,(t=>{e.formatter.has(t.name)||e.formatter.register(t.name,t.format)}))};return e.formatter?n(o.customFormats):e.on("init",(()=>{n(o.customFormats)})),o.formats})(e,t);return wv(e)?AO.concat(o):o})).getOr(AO),RO=(e,t,o)=>({...e,type:"formatter",isSelected:t(e.format),getStylePreview:o(e.format)}),VO=(e,t,o,n)=>{const r=t=>L(t,(t=>OO(t)?(e=>{const t=r(e.items);return{...e,type:"submenu",getStyleItems:w(t)}})(t):MO(t)?(e=>RO(e,o,n))(t):(e=>{const t=se(e);return 1===t.length&&D(t,"title")})(t)?{...t,type:"separator"}:(t=>{const r=i(t.name)?t.name:ls(t.title),s=`custom-${r}`,a={...t,type:"formatter",format:s,isSelected:o(s),getStylePreview:n(s)};return e.formatter.register(r,a),a})(t)));return r(t)},DO=zS.trim,PO=e=>t=>{if((e=>m(e)&&1===e.nodeType)(t)){if(t.contentEditable===e)return!0;if(t.getAttribute("data-mce-contenteditable")===e)return!0}return!1},IO=PO("true"),FO=PO("false"),LO=(e,t,o,n,r)=>({type:e,title:t,url:o,level:n,attach:r}),zO=e=>e.innerText||e.textContent,HO=e=>(e=>e&&"A"===e.nodeName&&void 0!==(e.id||e.name))(e)&&jO(e),ZO=e=>e&&/^(H[1-6])$/.test(e.nodeName),jO=e=>(e=>{let t=e;for(;t=t.parentNode;){const e=t.contentEditable;if(e&&"inherit"!==e)return IO(t)}return!1})(e)&&!FO(e),UO=e=>ZO(e)&&jO(e),$O=e=>{var t;const o=(e=>e.id?e.id:ls("h"))(e);return LO("header",null!==(t=zO(e))&&void 0!==t?t:"","#"+o,(e=>ZO(e)?parseInt(e.nodeName.substr(1),10):0)(e),(()=>{e.id=o}))},WO=e=>{const t=e.id||e.name,o=zO(e);return LO("anchor",o||"#"+t,"#"+t,0,v)},qO=e=>DO(e.title).length>0,GO=e=>{const t=(e=>{const t=L(Gc(Ie(e),"h1,h2,h3,h4,h5,h6,a:not([href])"),(e=>e.dom));return t})(e);return Z((e=>L(Z(e,UO),$O))(t).concat((e=>L(Z(e,HO),WO))(t)),qO)},YO="tinymce-url-history",KO=e=>i(e)&&/^https?/.test(e),XO=e=>s(e)&&ge(e,(e=>{return!(l(t=e)&&t.length<=5&&Y(t,KO));var t})).isNone(),JO=()=>{const e=x_.getItem(YO);if(null===e)return{};let t;try{t=JSON.parse(e)}catch(e){if(e instanceof SyntaxError)return console.log("Local storage "+YO+" was not valid JSON",e),{};throw e}return XO(t)?t:(console.log("Local storage "+YO+" was not valid format",t),{})},QO=e=>{const t=JO();return ve(t,e).getOr([])},eM=(e,t)=>{if(!KO(e))return;const o=JO(),n=ve(o,t).getOr([]),r=Z(n,(t=>t!==e));o[t]=[e].concat(r).slice(0,5),(e=>{if(!XO(e))throw new Error("Bad format for history:\n"+JSON.stringify(e));x_.setItem(YO,JSON.stringify(e))})(o)},tM=e=>!!e,oM=e=>ce(zS.makeMap(e,/[, ]/),tM),nM=e=>M.from(Rv(e)),rM=e=>M.from(e).filter(i).getOrUndefined(),iM=e=>({getHistory:QO,addToHistory:eM,getLinkInformation:()=>(e=>Iv(e)?M.some({targets:GO(e.getBody()),anchorTop:rM(Fv(e)),anchorBottom:rM(Lv(e))}):M.none())(e),getValidationHandler:()=>(e=>M.from(Vv(e)))(e),getUrlPicker:t=>((e,t)=>((e,t)=>{const o=(e=>{const t=M.from(Pv(e)).filter(tM).map(oM);return nM(e).fold(E,(e=>t.fold(O,(e=>se(e).length>0&&e))))})(e);return d(o)?o?nM(e):M.none():o[t]?nM(e):M.none()})(e,t).map((o=>n=>fx((r=>{const a={filetype:t,fieldname:n.fieldname,...M.from(n.meta).getOr({})};o.call(e,((e,t)=>{if(!i(e))throw new Error("Expected value to be string");if(void 0!==t&&!s(t))throw new Error("Expected meta to be a object");r({value:e,meta:t})}),n.value,a)})))))(e,t)}),sM=dh,aM=qu,lM=w([yr("shell",!1),or("makeItem"),yr("setupItem",v),bu("listBehaviours",[Kp])]),cM=Uu({name:"items",overrides:()=>({behaviours:Cl([Kp.config({})])})}),dM=w([cM]),uM=vh({name:w("CustomList")(),configFields:lM(),partFields:dM(),factory:(e,t,o,n)=>{const r=e.shell?{behaviours:[Kp.config({})],components:[]}:{behaviours:[],components:t};return{uid:e.uid,dom:e.dom,components:r.components,behaviours:vu(e.listBehaviours,r.behaviours),apis:{setItems:(t,o)=>{var n;(n=t,e.shell?M.some(n):oh(n,e,"items")).fold((()=>{throw console.error("Custom List was defined to not be a shell, but no item container was specified in components"),new Error("Custom List was defined to not be a shell, but no item container was specified in components")}),(n=>{const r=Kp.contents(n),i=o.length,s=i-r.length,a=s>0?I(s,(()=>e.makeItem())):[],l=r.slice(i);z(l,(e=>Kp.remove(n,e))),z(a,(e=>Kp.append(n,e)));const c=Kp.contents(n);z(c,((n,r)=>{e.setupItem(t,n,o[r],r)}))}))}}}},apis:{setItems:(e,t,o)=>{e.setItems(t,o)}}}),hM=w([or("dom"),yr("shell",!0),gu("toolbarBehaviours",[Kp])]),mM=w([Uu({name:"groups",overrides:()=>({behaviours:Cl([Kp.config({})])})})]),pM=vh({name:"Toolbar",configFields:hM(),partFields:mM(),factory:(e,t,o,n)=>{const r=e.shell?{behaviours:[Kp.config({})],components:[]}:{behaviours:[],components:t};return{uid:e.uid,dom:e.dom,components:r.components,behaviours:vu(e.toolbarBehaviours,r.behaviours),apis:{setGroups:(t,o)=>{var n;(n=t,e.shell?M.some(n):oh(n,e,"groups")).fold((()=>{throw console.error("Toolbar was defined to not be a shell, but no groups container was specified in components"),new Error("Toolbar was defined to not be a shell, but no groups container was specified in components")}),(e=>{Kp.set(e,o)}))},refresh:v},domModification:{attributes:{role:"group"}}}},apis:{setGroups:(e,t,o)=>{e.setGroups(t,o)}}}),gM=v,fM=E,vM=w([]);var bM,yM=Object.freeze({__proto__:null,setup:gM,isDocked:fM,getBehaviours:vM});const wM=e=>(we(Pt(e,"position"),"fixed")?M.none():st(e)).orThunk((()=>{const t=De("span");return rt(e).bind((e=>{Fo(e,t);const o=st(t);return Ho(t),o}))})),_M=e=>wM(e).map(Gt).getOrThunk((()=>Wt(0,0))),xM=(e,t)=>{const o=e.element;zs(o,t.transitionClass),Hs(o,t.fadeOutClass),zs(o,t.fadeInClass),t.onShow(e)},CM=(e,t)=>{const o=e.element;zs(o,t.transitionClass),Hs(o,t.fadeInClass),zs(o,t.fadeOutClass),t.onHide(e)},kM=(e,t)=>e.y>=t.y,SM=(e,t)=>e.bottom<=t.bottom,TM=(e,t,o)=>({location:"top",leftX:t,topY:o.bounds.y-e.y}),EM=(e,t,o)=>({location:"bottom",leftX:t,bottomY:e.bottom-o.bounds.bottom}),OM=e=>e.box.x-e.win.x,MM=(e,t,o)=>o.getInitialPos().map((o=>{const n=((e,t)=>{const o=t.optScrollEnv.fold(w(e.bounds.y),(t=>t.scrollElmTop+(e.bounds.y-t.currentScrollTop)));return Wt(e.bounds.x,o)})(o,t);return{box:Ko(n.left,n.top,Xt(e),jt(e)),location:o.location}})),AM=(e,t,o,n,r)=>{const i=((e,t)=>{const o=t.optScrollEnv.fold(w(e.y),(t=>e.y+t.currentScrollTop-t.scrollElmTop));return Wt(e.x,o)})(t,o),s=Ko(i.left,i.top,t.width,t.height);n.setInitialPos({style:It(e),position:Vt(e,"position")||"static",bounds:s,location:r.location})},BM=(e,t,o)=>o.getInitialPos().bind((n=>{var r;switch(o.clearInitialPos(),n.position){case"static":return M.some({morph:"static"});case"absolute":const o=wM(e).getOr(wt()),i=Xo(o),s=null!==(r=o.dom.scrollTop)&&void 0!==r?r:0;return M.some({morph:"absolute",positionCss:Il("absolute",ve(n.style,"left").map((e=>t.x-i.x)),ve(n.style,"top").map((e=>t.y-i.y+s)),ve(n.style,"right").map((e=>i.right-t.right)),ve(n.style,"bottom").map((e=>i.bottom-t.bottom)))});default:return M.none()}})),NM=e=>{switch(e.location){case"top":return M.some({morph:"fixed",positionCss:Il("fixed",M.some(e.leftX),M.some(e.topY),M.none(),M.none())});case"bottom":return M.some({morph:"fixed",positionCss:Il("fixed",M.some(e.leftX),M.none(),M.none(),M.some(e.bottomY))});default:return M.none()}},RM=(e,t,o)=>{const n=e.element;return we(Pt(n,"position"),"fixed")?((e,t,o)=>((e,t,o)=>MM(e,t,o).filter((({box:e})=>((e,t,o)=>Y(e,(e=>{switch(e){case"bottom":return SM(t,o.bounds);case"top":return kM(t,o.bounds)}})))(o.getModes(),e,t))).bind((({box:t})=>BM(e,t,o))))(e,t,o).orThunk((()=>t.optScrollEnv.bind((n=>MM(e,t,o))).bind((({box:e,location:o})=>{const n=en(),r=OM({win:n,box:e}),i="top"===o?TM(n,r,t):EM(n,r,t);return NM(i)})))))(n,t,o):((e,t,o)=>{const n=Xo(e),r=en(),i=((e,t,o)=>{const n=t.win,r=t.box,i=OM(t);return ie(e,(e=>{switch(e){case"bottom":return SM(r,o.bounds)?M.none():M.some(EM(n,i,o));case"top":return kM(r,o.bounds)?M.none():M.some(TM(n,i,o));default:return M.none()}})).getOr({location:"no-dock"})})(o.getModes(),{win:r,box:n},t);return"top"===i.location||"bottom"===i.location?(AM(e,n,t,o,i),NM(i)):M.none()})(n,t,o)},VM=(e,t,o)=>{o.setDocked(!1),z(["left","right","top","bottom","position"],(t=>Lt(e.element,t))),t.onUndocked(e)},DM=(e,t,o,n)=>{const r="fixed"===n.position;o.setDocked(r),Fl(e.element,n),(r?t.onDocked:t.onUndocked)(e)},PM=(e,t,o,n,r=!1)=>{t.contextual.each((t=>{t.lazyContext(e).each((i=>{const s=((e,t)=>e.yt.y)(i,n.bounds);s!==o.isVisible()&&(o.setVisible(s),r&&!s?(js(e.element,[t.fadeOutClass]),t.onHide(e)):(s?xM:CM)(e,t))}))}))},IM=(e,t,o,n,r)=>{PM(e,t,o,n,!0),DM(e,t,o,r.positionCss)},FM=(e,t,o)=>{e.getSystem().isConnected()&&((e,t,o)=>{const n=t.lazyViewport(e);PM(e,t,o,n),RM(e,n,o).each((r=>{((e,t,o,n,r)=>{switch(r.morph){case"static":return VM(e,t,o);case"absolute":return DM(e,t,o,r.positionCss);case"fixed":IM(e,t,o,n,r)}})(e,t,o,n,r)}))})(e,t,o)},LM=(e,t,o)=>{o.isDocked()&&((e,t,o)=>{const n=e.element;o.setDocked(!1);const r=t.lazyViewport(e);((e,t,o)=>{const n=e.element;return MM(n,t,o).bind((({box:e})=>BM(n,e,o)))})(e,r,o).each((n=>{switch(n.morph){case"static":VM(e,t,o);break;case"absolute":DM(e,t,o,n.positionCss)}})),o.setVisible(!0),t.contextual.each((t=>{Us(n,[t.fadeInClass,t.fadeOutClass,t.transitionClass]),t.onShow(e)})),FM(e,t,o)})(e,t,o)},zM=e=>(t,o,n)=>{const r=o.lazyViewport(t);((e,t,o,n)=>{const r=Xo(e),i=en(),s=n(i,OM({win:i,box:r}),t);return"bottom"===s.location||"top"===s.location?(((e,t,o,n,r)=>{n.getInitialPos().fold((()=>AM(e,t,o,n,r)),(()=>v))})(e,r,t,o,s),NM(s)):M.none()})(t.element,r,n,e).each((e=>{IM(t,o,n,r,e)}))},HM=zM(TM),ZM=zM(EM);var jM=Object.freeze({__proto__:null,refresh:FM,reset:LM,isDocked:(e,t,o)=>o.isDocked(),getModes:(e,t,o)=>o.getModes(),setModes:(e,t,o,n)=>o.setModes(n),forceDockToTop:HM,forceDockToBottom:ZM}),UM=Object.freeze({__proto__:null,events:(e,t)=>Li([Yi(oi(),((o,n)=>{e.contextual.each((e=>{Zs(o.element,e.transitionClass)&&(Us(o.element,[e.transitionClass,e.fadeInClass]),(t.isVisible()?e.onShown:e.onHidden)(o)),n.stop()}))})),Zi(wi(),((o,n)=>{FM(o,e,t)})),Zi(Oi(),((o,n)=>{FM(o,e,t)})),Zi(_i(),((o,n)=>{LM(o,e,t)}))])}),$M=[br("contextual",[ir("fadeInClass"),ir("fadeOutClass"),ir("transitionClass"),ar("lazyContext"),Ba("onShow"),Ba("onShown"),Ba("onHide"),Ba("onHidden")]),Sr("lazyViewport",(()=>({bounds:en(),optScrollEnv:M.none()}))),Tr("modes",["top","bottom"],Ln),Ba("onDocked"),Ba("onUndocked")];const WM=Sl({fields:$M,name:"docking",active:UM,apis:jM,state:Object.freeze({__proto__:null,init:e=>{const t=Or(!1),o=Or(!0),n=Ql(),r=Or(e.modes);return Ts({isDocked:t.get,setDocked:t.set,getInitialPos:n.get,setInitialPos:n.set,clearInitialPos:n.clear,isVisible:o.get,setVisible:o.set,getModes:r.get,setModes:r.set,readState:()=>`docked: ${t.get()}, visible: ${o.get()}, modes: ${r.get().join(",")}`})}})}),qM=w(ls("toolbar-height-change")),GM={fadeInClass:"tox-editor-dock-fadein",fadeOutClass:"tox-editor-dock-fadeout",transitionClass:"tox-editor-dock-transition"},YM="tox-tinymce--toolbar-sticky-on",KM="tox-tinymce--toolbar-sticky-off",XM=(e,t)=>D(WM.getModes(e),t),JM=e=>{const t=e.element;it(t).each((o=>{const n="padding-"+WM.getModes(e)[0];if(WM.isDocked(e)){const e=Xt(o);Bt(t,"width",e+"px"),Bt(o,n,(e=>Ut(e)+(parseInt(Vt(e,"margin-top"),10)||0)+(parseInt(Vt(e,"margin-bottom"),10)||0))(t)+"px")}else Lt(t,"width"),Lt(o,n)}))},QM=(e,t)=>{t?(Hs(e,GM.fadeOutClass),js(e,[GM.transitionClass,GM.fadeInClass])):(Hs(e,GM.fadeInClass),js(e,[GM.fadeOutClass,GM.transitionClass]))},eA=(e,t)=>{const o=Ie(e.getContainer());t?(zs(o,YM),Hs(o,KM)):(zs(o,KM),Hs(o,YM))},tA=(e,t)=>{const o=Ql(),n=t.getSink,r=e=>{n().each((t=>e(t.element)))},i=t=>{e.inline||JM(t),eA(e,WM.isDocked(t)),t.getSystem().broadcastOn([Kd()],{}),n().each((e=>e.getSystem().broadcastOn([Kd()],{})))},s=e.inline?[]:[Ml.config({channels:{[qM()]:{onReceive:JM}}})];return[og.config({}),WM.config({contextual:{lazyContext:t=>{const o=Ut(t.element),n=e.inline?e.getContentAreaContainer():e.getContainer();return M.from(n).map((n=>{const r=Xo(Ie(n));return Ux(e,t.element).fold((()=>{const e=r.height-o,n=r.y+(XM(t,"top")?0:o);return Ko(r.x,n,r.width,e)}),(e=>{const n=Qo(r,$x(e)),i=XM(t,"top")?n.y:n.y+o;return Ko(n.x,i,n.width,n.height-o)}))}))},onShow:()=>{r((e=>QM(e,!0)))},onShown:e=>{r((e=>Us(e,[GM.transitionClass,GM.fadeInClass]))),o.get().each((t=>{((e,t)=>{const o=et(t);Vl(o).filter((e=>!Je(t,e))).filter((t=>Je(t,Ie(o.dom.body))||Qe(e,t))).each((()=>Bl(t)))})(e.element,t),o.clear()}))},onHide:e=>{((e,t)=>Dl(e).orThunk((()=>t().toOptional().bind((e=>Dl(e.element))))))(e.element,n).fold(o.clear,o.set),r((e=>QM(e,!1)))},onHidden:()=>{r((e=>Us(e,[GM.transitionClass])))},...GM},lazyViewport:t=>Ux(e,t.element).fold((()=>{const o=en(),n=Av(e),r=o.y+(XM(t,"top")?n:0),i=o.height-(XM(t,"bottom")?n:0);return{bounds:Ko(o.x,r,o.width,i),optScrollEnv:M.none()}}),(e=>({bounds:$x(e),optScrollEnv:M.some({currentScrollTop:e.element.dom.scrollTop,scrollElmTop:Gt(e.element).top})}))),modes:[t.header.getDockingMode()],onDocked:i,onUndocked:i}),...s]};var oA=Object.freeze({__proto__:null,setup:(e,t,o)=>{e.inline||(t.header.isPositionedAtTop()||e.on("ResizeEditor",(()=>{o().each(WM.reset)})),e.on("ResizeWindow ResizeEditor",(()=>{o().each(JM)})),e.on("SkinLoaded",(()=>{o().each((e=>{WM.isDocked(e)?WM.reset(e):WM.refresh(e)}))})),e.on("FullscreenStateChanged",(()=>{o().each(WM.reset)}))),e.on("AfterScrollIntoView",(e=>{o().each((t=>{WM.refresh(t);const o=t.element;Vm(o)&&((e,t)=>{const o=et(t),n=nt(t).dom.innerHeight,r=Zo(o),i=Ie(e.elm),s=Jo(i),a=jt(i),l=s.y,c=l+a,d=Gt(t),u=jt(t),h=d.top,m=h+u,p=Math.abs(h-r.top)<2,g=Math.abs(m-(r.top+n))<2;if(p&&lh){const e=l-n+a+u;jo(r.left,e,o)}})(e,o)}))})),e.on("PostRender",(()=>{eA(e,!1)}))},isDocked:e=>e().map(WM.isDocked).getOr(!1),getBehaviours:tA});const nA=Bn([ty,nr("items",Rn([Dn([oy,dr("items",Ln)]),Ln]))].concat(By)),rA=[pr("text"),pr("tooltip"),pr("icon"),wr("search",!1,Rn([zn,Bn([pr("placeholder")])],(e=>d(e)?e?M.some({placeholder:M.none()}):M.none():M.some(e)))),ar("fetch"),Sr("onSetup",(()=>v))],iA=Bn([ty,...rA]),sA=e=>qn("menubutton",iA,e),aA=Bn([ty,fy,gy,py,yy,ly,hy,Cr("presets","normal",["normal","color","listpreview"]),ky(1),dy,uy]);var lA=fh({factory:(e,t)=>{const o={focus:Hp.focusIn,setMenus:(e,o)=>{const n=L(o,(e=>{const o={type:"menubutton",text:e.text,fetch:t=>{t(e.getItems())}},n=sA(o).mapError((e=>Kn(e))).getOrDie();return tE(n,"tox-mbtn",t.backstage,M.some("menuitem"))}));Kp.set(e,n)}};return{uid:e.uid,dom:e.dom,components:[],behaviours:Cl([Kp.config({}),Xp("menubar-events",[Ki((t=>{e.onSetup(t)})),Zi(qr(),((e,t)=>{pa(e.element,".tox-mbtn--active").each((o=>{ga(t.event.target,".tox-mbtn").each((t=>{Je(o,t)||e.getSystem().getByDom(o).each((o=>{e.getSystem().getByDom(t).each((e=>{Bx.expand(e),Bx.close(o),og.focus(e)}))}))}))}))})),Zi(Ti(),((e,t)=>{t.event.prevFocus.bind((t=>e.getSystem().getByDom(t).toOptional())).each((o=>{t.event.newFocus.bind((t=>e.getSystem().getByDom(t).toOptional())).each((e=>{Bx.isOpen(o)&&(Bx.expand(e),Bx.close(o))}))}))}))]),Hp.config({mode:"flow",selector:".tox-mbtn",onEscape:t=>(e.onEscape(t),M.some(!0))}),cC.config({})]),apis:o,domModification:{attributes:{role:"menubar"}}}},name:"silver.Menubar",configFields:[or("dom"),or("uid"),or("onEscape"),or("backstage"),yr("onSetup",v)],apis:{focus:(e,t)=>{e.focus(t)},setMenus:(e,t,o)=>{e.setMenus(t,o)}}});const cA="container",dA=[gu("slotBehaviours",[])],uA=e=>"",hA=(e,t)=>{const o=t=>sh(e),n=(t,o)=>(n,r)=>oh(n,e,r).map((e=>t(e,r))).getOr(o),r=(e,t)=>"true"!==St(e.element,"aria-hidden"),i=n(r,!1),s=n(((e,t)=>{if(r(e)){const o=e.element;Bt(o,"display","none"),Ct(o,"aria-hidden","true"),Vi(e,Ei(),{name:t,visible:!1})}})),a=(e=>(t,o)=>{z(o,(o=>e(t,o)))})(s),l=n(((e,t)=>{if(!r(e)){const o=e.element;Lt(o,"display"),Ot(o,"aria-hidden"),Vi(e,Ei(),{name:t,visible:!0})}})),c={getSlotNames:o,getSlot:(t,o)=>oh(t,e,o),isShowing:i,hideSlot:s,hideAllSlots:e=>a(e,o()),showSlot:l};return{uid:e.uid,dom:e.dom,components:t,behaviours:fu(e.slotBehaviours),apis:c}},mA=ce({getSlotNames:(e,t)=>e.getSlotNames(t),getSlot:(e,t,o)=>e.getSlot(t,o),isShowing:(e,t,o)=>e.isShowing(t,o),hideSlot:(e,t,o)=>e.hideSlot(t,o),hideAllSlots:(e,t)=>e.hideAllSlots(t),showSlot:(e,t,o)=>e.showSlot(t,o)},(e=>ks(e))),pA={...mA,sketch:e=>{const t=(()=>{const e=[];return{slot:(t,o)=>(e.push(t),Xu(cA,uA(t),o)),record:w(e)}})(),o=e(t),n=t.record(),r=L(n,(e=>Zu({name:e,pname:uA(e)})));return hh(cA,dA,r,hA,o)}},gA=Bn([gy,fy,Sr("onShow",v),Sr("onHide",v),hy]),fA=e=>({element:()=>e.element.dom}),vA=(e,t)=>{const o=L(se(t),(e=>{const o=t[e],n=Gn((e=>qn("sidebar",gA,e))(o));return{name:e,getApi:fA,onSetup:n.onSetup,onShow:n.onShow,onHide:n.onHide}}));return L(o,(t=>{const n=Or(v);return e.slot(t.name,{dom:{tag:"div",classes:["tox-sidebar__pane"]},behaviours:lw([Ew(t,n),Ow(t,n),Zi(Ei(),((e,t)=>{const n=t.event,r=$(o,(e=>e.name===n.name));r.each((t=>{(n.visible?t.onShow:t.onHide)(t.getApi(e))}))}))])})}))},bA=e=>pA.sketch((t=>({dom:{tag:"div",classes:["tox-sidebar__pane-container"]},components:vA(t,e),slotBehaviours:lw([Ki((e=>pA.hideAllSlots(e)))])}))),yA=(e,t)=>{Ct(e,"role",t)},wA=e=>_h.getCurrent(e).bind((e=>QT.isGrowing(e)||QT.hasGrown(e)?_h.getCurrent(e).bind((e=>$(pA.getSlotNames(e),(t=>pA.isShowing(e,t))))):M.none())),_A=ls("FixSizeEvent"),xA=ls("AutoSizeEvent");var CA=Object.freeze({__proto__:null,block:(e,t,o,n)=>{Ct(e.element,"aria-busy",!0);const r=t.getRoot(e).getOr(e),i=Cl([Hp.config({mode:"special",onTab:()=>M.some(!0),onShiftTab:()=>M.some(!0)}),og.config({})]),s=n(r,i),a=r.getSystem().build(s);Kp.append(r,sa(a)),a.hasConfigured(Hp)&&t.focus&&Hp.focusIn(a),o.isBlocked()||t.onBlock(e),o.blockWith((()=>Kp.remove(r,a)))},unblock:(e,t,o)=>{Ot(e.element,"aria-busy"),o.isBlocked()&&t.onUnblock(e),o.clear()},isBlocked:(e,t,o)=>o.isBlocked()}),kA=[Sr("getRoot",M.none),kr("focus",!0),Ba("onBlock"),Ba("onUnblock")];const SA=Sl({fields:kA,name:"blocking",apis:CA,state:Object.freeze({__proto__:null,init:()=>{const e=Xl((e=>e.destroy()));return Ts({readState:e.isSet,blockWith:t=>{e.set({destroy:t})},clear:e.clear,isBlocked:e.isSet})}})}),TA=e=>_h.getCurrent(e).each((e=>Bl(e.element))),EA=(e,t,o)=>{const n=Or(!1),r=Ql(),i=o=>{var r;n.get()&&(!(e=>"focusin"===e.type)(r=o)||!(r.composed?oe(r.composedPath()):M.from(r.target)).map(Ie).filter($e).exists((e=>Zs(e,"mce-pastebin"))))&&(o.preventDefault(),TA(t()),e.editorManager.setActive(e))};e.inline||e.on("PreInit",(()=>{e.dom.bind(e.getWin(),"focusin",i),e.on("BeforeExecCommand",(e=>{"mcefocus"===e.command.toLowerCase()&&!0!==e.value&&i(e)}))}));const s=r=>{r!==n.get()&&(n.set(r),((e,t,o,n)=>{const r=t.element;if(((e,t)=>{const o="tabindex",n=`data-mce-${o}`;M.from(e.iframeElement).map(Ie).each((e=>{t?(Tt(e,o).each((t=>Ct(e,n,t))),Ct(e,o,-1)):(Ot(e,o),Tt(e,n).each((t=>{Ct(e,o,t),Ot(e,n)})))}))})(e,o),o)SA.block(t,(e=>(t,o)=>({dom:{tag:"div",attributes:{"aria-label":e.translate("Loading..."),tabindex:"0"},classes:["tox-throbber__busy-spinner"]},components:[{dom:Ug('')}]}))(n)),Lt(r,"display"),Ot(r,"aria-hidden"),e.hasFocus()&&TA(t);else{const o=_h.getCurrent(t).exists((e=>Rl(e.element)));SA.unblock(t),Bt(r,"display","none"),Ct(r,"aria-hidden","true"),o&&e.focus()}})(e,t(),r,o.providers),((e,t)=>{e.dispatch("AfterProgressState",{state:t})})(e,r))};e.on("ProgressState",(t=>{if(r.on(clearTimeout),g(t.time)){const o=Zg.setEditorTimeout(e,(()=>s(t.state)),t.time);r.set(o)}else s(t.state),r.clear()}))},OA=(e,t,o)=>({within:e,extra:t,withinWidth:o}),MA=(e,t,o)=>{const n=U(e,((e,t)=>((e,t)=>{const n=o(e);return M.some({element:e,start:t,finish:t+n,width:n})})(t,e.len).fold(w(e),(t=>({len:t.finish,list:e.list.concat([t])})))),{len:0,list:[]}).list,r=Z(n,(e=>e.finish<=t)),i=j(r,((e,t)=>e+t.width),0);return{within:r,extra:n.slice(r.length),withinWidth:i}},AA=e=>L(e,(e=>e.element)),BA=(e,t)=>{const o=L(t,(e=>sa(e)));pM.setGroups(e,o)},NA=(e,t,o)=>{const n=t.builtGroups.get();if(0===n.length)return;const r=nh(e,t,"primary"),i=ux.getCoupled(e,"overflowGroup");Bt(r.element,"visibility","hidden");const s=n.concat([i]),a=ie(s,(e=>Dl(e.element).bind((t=>e.getSystem().getByDom(t).toOptional()))));o([]),BA(r,s);const l=((e,t,o,n)=>{const r=((e,t,o)=>{const n=MA(t,e,o);return 0===n.extra.length?M.some(n):M.none()})(e,t,o).getOrThunk((()=>MA(t,e-o(n),o))),i=r.within,s=r.extra,a=r.withinWidth;return 1===s.length&&s[0].width<=o(n)?((e,t,o)=>{const n=AA(e.concat(t));return OA(n,[],o)})(i,s,a):s.length>=1?((e,t,o,n)=>{const r=AA(e).concat([o]);return OA(r,AA(t),n)})(i,s,n,a):((e,t,o)=>OA(AA(e),[],o))(i,0,a)})(Xt(r.element),t.builtGroups.get(),(e=>Xt(e.element)),i);0===l.extra.length?(Kp.remove(r,i),o([])):(BA(r,l.within),o(l.extra)),Lt(r.element,"visibility"),zt(r.element),a.each(og.focus)},RA=w([gu("splitToolbarBehaviours",[ux]),er("builtGroups",(()=>Or([])))]),VA=w([Ma(["overflowToggledClass"]),fr("getOverflowBounds"),or("lazySink"),er("overflowGroups",(()=>Or([]))),Ba("onOpened"),Ba("onClosed")].concat(RA())),DA=w([Zu({factory:pM,schema:hM(),name:"primary"}),ju({schema:hM(),name:"overflow"}),ju({name:"overflow-button"}),ju({name:"overflow-group"})]),PA=w(((e,t)=>{((e,t)=>{const o=Kt.max(e,t,["margin-left","border-left-width","padding-left","padding-right","border-right-width","margin-right"]);Bt(e,"max-width",o+"px")})(e,Math.floor(t))})),IA=w([Ma(["toggledClass"]),or("lazySink"),ar("fetch"),fr("getBounds"),br("fireDismissalEventInstead",[yr("event",ki())]),_c(),Ba("onToggled")]),FA=w([ju({name:"button",overrides:e=>({dom:{attributes:{"aria-haspopup":"true"}},buttonBehaviours:Cl([dg.config({toggleClass:e.markers.toggledClass,aria:{mode:"expanded"},toggleOnExecute:!1,onToggled:e.onToggled})])})}),ju({factory:pM,schema:hM(),name:"toolbar",overrides:e=>({toolbarBehaviours:Cl([Hp.config({mode:"cyclic",onEscape:t=>(oh(t,e,"button").each(og.focus),M.none())})])})})]),LA=Ql(),zA=(e,t)=>{const o=ux.getCoupled(e,"toolbarSandbox");Gd.isOpen(o)?Gd.close(o):Gd.open(o,t.toolbar())},HA=(e,t,o,n)=>{const r=o.getBounds.map((e=>e())),i=o.lazySink(e).getOrDie();xd.positionWithinBounds(i,t,{anchor:{type:"hotspot",hotspot:e,layouts:n,overrides:{maxWidthFunction:PA()}}},r)},ZA=(e,t,o,n,r)=>{pM.setGroups(t,r),HA(e,t,o,n),dg.on(e)},jA=vh({name:"FloatingToolbarButton",factory:(e,t,o,n)=>({...jg.sketch({...n.button(),action:e=>{zA(e,n)},buttonBehaviours:yu({dump:n.button().buttonBehaviours},[ux.config({others:{toolbarSandbox:t=>((e,t,o)=>{const n=va();return{dom:{tag:"div",attributes:{id:n.id}},behaviours:Cl([Hp.config({mode:"special",onEscape:e=>(Gd.close(e),M.some(!0))}),Gd.config({onOpen:(r,i)=>{const s=LA.get().getOr(!1);o.fetch().get((r=>{ZA(e,i,o,t.layouts,r),n.link(e.element),s||Hp.focusIn(i)}))},onClose:()=>{dg.off(e),LA.get().getOr(!1)||og.focus(e),n.unlink(e.element)},isPartOf:(t,o,n)=>ba(o,n)||ba(e,n),getAttachPoint:()=>o.lazySink(e).getOrDie()}),Ml.config({channels:{...Qd({isExtraPart:E,...o.fireDismissalEventInstead.map((e=>({fireEventInstead:{event:e.event}}))).getOr({})}),...tu({doReposition:()=>{Gd.getState(ux.getCoupled(e,"toolbarSandbox")).each((n=>{HA(e,n,o,t.layouts)}))}})}})])}})(t,o,e)}})])}),apis:{setGroups:(t,n)=>{Gd.getState(ux.getCoupled(t,"toolbarSandbox")).each((r=>{ZA(t,r,e,o.layouts,n)}))},reposition:t=>{Gd.getState(ux.getCoupled(t,"toolbarSandbox")).each((n=>{HA(t,n,e,o.layouts)}))},toggle:e=>{zA(e,n)},toggleWithoutFocusing:e=>{((e,t)=>{LA.set(!0),zA(e,t),LA.clear()})(e,n)},getToolbar:e=>Gd.getState(ux.getCoupled(e,"toolbarSandbox")),isOpen:e=>Gd.isOpen(ux.getCoupled(e,"toolbarSandbox"))}}),configFields:IA(),partFields:FA(),apis:{setGroups:(e,t,o)=>{e.setGroups(t,o)},reposition:(e,t)=>{e.reposition(t)},toggle:(e,t)=>{e.toggle(t)},toggleWithoutFocusing:(e,t)=>{e.toggleWithoutFocusing(t)},getToolbar:(e,t)=>e.getToolbar(t),isOpen:(e,t)=>e.isOpen(t)}}),UA=w([or("items"),Ma(["itemSelector"]),gu("tgroupBehaviours",[Hp])]),$A=w([$u({name:"items",unit:"item"})]),WA=vh({name:"ToolbarGroup",configFields:UA(),partFields:$A(),factory:(e,t,o,n)=>({uid:e.uid,dom:e.dom,components:t,behaviours:vu(e.tgroupBehaviours,[Hp.config({mode:"flow",selector:e.markers.itemSelector})]),domModification:{attributes:{role:"toolbar"}}})}),qA=e=>L(e,(e=>sa(e))),GA=(e,t,o)=>{NA(e,o,(n=>{o.overflowGroups.set(n),t.getOpt(e).each((e=>{jA.setGroups(e,qA(n))}))}))},YA=vh({name:"SplitFloatingToolbar",configFields:VA(),partFields:DA(),factory:(e,t,o,n)=>{const r=$g(jA.sketch({fetch:()=>fx((t=>{t(qA(e.overflowGroups.get()))})),layouts:{onLtr:()=>[il,rl],onRtl:()=>[rl,il],onBottomLtr:()=>[al,sl],onBottomRtl:()=>[sl,al]},getBounds:o.getOverflowBounds,lazySink:e.lazySink,fireDismissalEventInstead:{},markers:{toggledClass:e.markers.overflowToggledClass},parts:{button:n["overflow-button"](),toolbar:n.overflow()},onToggled:(t,o)=>e[o?"onOpened":"onClosed"](t)}));return{uid:e.uid,dom:e.dom,components:t,behaviours:vu(e.splitToolbarBehaviours,[ux.config({others:{overflowGroup:()=>WA.sketch({...n["overflow-group"](),items:[r.asSpec()]})}})]),apis:{setGroups:(t,o)=>{e.builtGroups.set(L(o,t.getSystem().build)),GA(t,r,e)},refresh:t=>GA(t,r,e),toggle:e=>{r.getOpt(e).each((e=>{jA.toggle(e)}))},toggleWithoutFocusing:e=>{r.getOpt(e).each(jA.toggleWithoutFocusing)},isOpen:e=>r.getOpt(e).map(jA.isOpen).getOr(!1),reposition:e=>{r.getOpt(e).each((e=>{jA.reposition(e)}))},getOverflow:e=>r.getOpt(e).bind(jA.getToolbar)},domModification:{attributes:{role:"group"}}}},apis:{setGroups:(e,t,o)=>{e.setGroups(t,o)},refresh:(e,t)=>{e.refresh(t)},reposition:(e,t)=>{e.reposition(t)},toggle:(e,t)=>{e.toggle(t)},toggleWithoutFocusing:(e,t)=>{e.toggle(t)},isOpen:(e,t)=>e.isOpen(t),getOverflow:(e,t)=>e.getOverflow(t)}}),KA=w([Ma(["closedClass","openClass","shrinkingClass","growingClass","overflowToggledClass"]),Ba("onOpened"),Ba("onClosed")].concat(RA())),XA=w([Zu({factory:pM,schema:hM(),name:"primary"}),Zu({factory:pM,schema:hM(),name:"overflow",overrides:e=>({toolbarBehaviours:Cl([QT.config({dimension:{property:"height"},closedClass:e.markers.closedClass,openClass:e.markers.openClass,shrinkingClass:e.markers.shrinkingClass,growingClass:e.markers.growingClass,onShrunk:t=>{oh(t,e,"overflow-button").each((e=>{dg.off(e),og.focus(e)})),e.onClosed(t)},onGrown:t=>{Hp.focusIn(t),e.onOpened(t)},onStartGrow:t=>{oh(t,e,"overflow-button").each(dg.on)}}),Hp.config({mode:"acyclic",onEscape:t=>(oh(t,e,"overflow-button").each(og.focus),M.some(!0))})])})}),ju({name:"overflow-button",overrides:e=>({buttonBehaviours:Cl([dg.config({toggleClass:e.markers.overflowToggledClass,aria:{mode:"pressed"},toggleOnExecute:!1})])})}),ju({name:"overflow-group"})]),JA=(e,t)=>{oh(e,t,"overflow-button").bind((()=>oh(e,t,"overflow"))).each((o=>{QA(e,t),QT.toggleGrow(o)}))},QA=(e,t)=>{oh(e,t,"overflow").each((o=>{NA(e,t,(e=>{const t=L(e,(e=>sa(e)));pM.setGroups(o,t)})),oh(e,t,"overflow-button").each((e=>{QT.hasGrown(o)&&dg.on(e)})),QT.refresh(o)}))},eB=vh({name:"SplitSlidingToolbar",configFields:KA(),partFields:XA(),factory:(e,t,o,n)=>{const r="alloy.toolbar.toggle";return{uid:e.uid,dom:e.dom,components:t,behaviours:vu(e.splitToolbarBehaviours,[ux.config({others:{overflowGroup:e=>WA.sketch({...n["overflow-group"](),items:[jg.sketch({...n["overflow-button"](),action:t=>{Ri(e,r)}})]})}}),Xp("toolbar-toggle-events",[Zi(r,(t=>{JA(t,e)}))])]),apis:{setGroups:(t,o)=>{((t,o)=>{const n=L(o,t.getSystem().build);e.builtGroups.set(n)})(t,o),QA(t,e)},refresh:t=>QA(t,e),toggle:t=>JA(t,e),isOpen:t=>((e,t)=>oh(e,t,"overflow").map(QT.hasGrown).getOr(!1))(t,e)},domModification:{attributes:{role:"group"}}}},apis:{setGroups:(e,t,o)=>{e.setGroups(t,o)},refresh:(e,t)=>{e.refresh(t)},toggle:(e,t)=>{e.toggle(t)},isOpen:(e,t)=>e.isOpen(t)}}),tB=e=>{const t=e.title.fold((()=>({})),(e=>({attributes:{title:e}})));return{dom:{tag:"div",classes:["tox-toolbar__group"],...t},components:[WA.parts.items({})],items:e.items,markers:{itemSelector:"*:not(.tox-split-button) > .tox-tbtn:not([disabled]), .tox-split-button:not([disabled]), .tox-toolbar-nav-js:not([disabled]), .tox-number-input:not([disabled])"},tgroupBehaviours:Cl([cC.config({}),og.config({})])}},oB=e=>WA.sketch(tB(e)),nB=(e,t)=>{const o=Ki((t=>{const o=L(e.initGroups,oB);pM.setGroups(t,o)}));return Cl([Sw(e.providers.isDisabled),xw(),Hp.config({mode:t,onEscape:e.onEscape,selector:".tox-toolbar__group"}),Xp("toolbar-events",[o])])},rB=e=>{const t=e.cyclicKeying?"cyclic":"acyclic";return{uid:e.uid,dom:{tag:"div",classes:["tox-toolbar-overlord"]},parts:{"overflow-group":tB({title:M.none(),items:[]}),"overflow-button":EE({name:"more",icon:M.some("more-drawer"),enabled:!0,tooltip:M.some("Reveal or hide additional toolbar items"),primary:!1,buttonType:M.none(),borderless:!1},M.none(),e.providers)},splitToolbarBehaviours:nB(e,t)}},iB=e=>{const t=rB(e),o=YA.parts.primary({dom:{tag:"div",classes:["tox-toolbar__primary"]}});return YA.sketch({...t,lazySink:e.getSink,getOverflowBounds:()=>{const t=e.moreDrawerData.lazyHeader().element,o=Jo(t),n=ot(t),r=Jo(n),i=Math.max(n.dom.scrollHeight,r.height);return Ko(o.x+4,r.y,o.width-8,i)},parts:{...t.parts,overflow:{dom:{tag:"div",classes:["tox-toolbar__overflow"],attributes:e.attributes}}},components:[o],markers:{overflowToggledClass:"tox-tbtn--enabled"},onOpened:t=>e.onToggled(t,!0),onClosed:t=>e.onToggled(t,!1)})},sB=e=>{const t=eB.parts.primary({dom:{tag:"div",classes:["tox-toolbar__primary"]}}),o=eB.parts.overflow({dom:{tag:"div",classes:["tox-toolbar__overflow"]}}),n=rB(e);return eB.sketch({...n,components:[t,o],markers:{openClass:"tox-toolbar__overflow--open",closedClass:"tox-toolbar__overflow--closed",growingClass:"tox-toolbar__overflow--growing",shrinkingClass:"tox-toolbar__overflow--shrinking",overflowToggledClass:"tox-tbtn--enabled"},onOpened:t=>{t.getSystem().broadcastOn([qM()],{type:"opened"}),e.onToggled(t,!0)},onClosed:t=>{t.getSystem().broadcastOn([qM()],{type:"closed"}),e.onToggled(t,!1)}})},aB=e=>{const t=e.cyclicKeying?"cyclic":"acyclic";return pM.sketch({uid:e.uid,dom:{tag:"div",classes:["tox-toolbar"].concat(e.type===rv.scrolling?["tox-toolbar--scrolling"]:[])},components:[pM.parts.groups({})],toolbarBehaviours:nB(e,t)})},lB=[py,gy,pr("tooltip"),Cr("buttonType","secondary",["primary","secondary"]),kr("borderless",!1),ar("onAction")],cB={button:[...lB,ry,sr("type",["button"])],togglebutton:[...lB,kr("active",!1),sr("type",["togglebutton"])]},dB=[sr("type",["group"]),Tr("buttons",[],Xn("type",cB))],uB=Xn("type",{...cB,group:dB}),hB=Bn([Tr("buttons",[],uB),ar("onShow"),ar("onHide")]),mB=(e,t)=>((e,t)=>{var o,n;const r="togglebutton"===e.type,i=e.icon.map((e=>fT(e,t.icons))).map($g),s={...e,name:r?e.text.getOr(e.icon.getOr("")):null!==(o=e.text)&&void 0!==o?o:e.icon.getOr(""),primary:"primary"===e.buttonType,buttonType:M.from(e.buttonType),tooltip:e.tooltip,icon:e.icon,enabled:!0,borderless:e.borderless},a=OE(null!==(n=e.buttonType)&&void 0!==n?n:"secondary"),l=r?e.text.map(t.translate):M.some(t.translate(e.text)),c=l.map(ta),d=s.tooltip.or(l).map((e=>({"aria-label":t.translate(e),title:t.translate(e)}))).getOr({}),u=i.map((e=>e.asSpec())),h=Bw([u,c]),m=e.icon.isSome()&&c.isSome(),p={tag:"button",classes:a.concat(...e.icon.isSome()&&!m?["tox-button--icon"]:[]).concat(...m?["tox-button--icon-and-text"]:[]).concat(...e.borderless?["tox-button--naked"]:[]).concat(..."togglebutton"===e.type&&e.active?["tox-button--enabled"]:[]),attributes:d},g=TE(s,M.some((o=>{const n=e=>{i.map((n=>n.getOpt(o).each((o=>{Kp.set(o,[fT(e,t.icons)])}))))};return r?e.onAction({setIcon:n,setActive:e=>{const t=o.element;e?(zs(t,"tox-button--enabled"),Ct(t,"aria-pressed",!0)):(Hs(t,"tox-button--enabled"),Ot(t,"aria-pressed"))},isActive:()=>Zs(o.element,"tox-button--enabled")}):"button"===e.type?e.onAction({setIcon:n}):void 0})),[],p,h,t);return jg.sketch(g)})(e,t),pB=Bo().deviceType,gB=pB.isPhone(),fB=pB.isTablet();var vB=vh({name:"silver.View",configFields:[or("viewConfig")],partFields:[Uu({factory:{sketch:e=>{let t=!1;const o=L(e.buttons,(o=>"group"===o.type?(t=!0,((e,t)=>({dom:{tag:"div",classes:["tox-view__toolbar__group"]},components:L(e.buttons,(e=>mB(e,t)))}))(o,e.providers)):mB(o,e.providers)));return{uid:e.uid,dom:{tag:"div",classes:[t?"tox-view__toolbar":"tox-view__header",...gB||fB?["tox-view--mobile","tox-view--scrolling"]:[]]},behaviours:Cl([og.config({}),Hp.config({mode:"flow",selector:"button, .tox-button",focusInside:pm.OnEnterOrSpaceMode})]),components:t?o:[oC.sketch({dom:{tag:"div",classes:["tox-view__header-start"]},components:[]}),oC.sketch({dom:{tag:"div",classes:["tox-view__header-end"]},components:o})]}}},schema:[or("buttons"),or("providers")],name:"header"}),Uu({factory:{sketch:e=>({uid:e.uid,dom:{tag:"div",classes:["tox-view__pane"]}})},schema:[],name:"pane"})],factory:(e,t,o,n)=>{const r={getPane:t=>sM.getPart(t,e,"pane"),getOnShow:t=>e.viewConfig.onShow,getOnHide:t=>e.viewConfig.onHide};return{uid:e.uid,dom:e.dom,components:t,apis:r}},apis:{getPane:(e,t)=>e.getPane(t),getOnShow:(e,t)=>e.getOnShow(t),getOnHide:(e,t)=>e.getOnHide(t)}});const bB=(e,t,o)=>pe(t,((t,n)=>{const r=Gn(qn("view",hB,t));return e.slot(n,vB.sketch({dom:{tag:"div",classes:["tox-view"]},viewConfig:r,components:[...r.buttons.length>0?[vB.parts.header({buttons:r.buttons,providers:o})]:[],vB.parts.pane({})]}))})),yB=(e,t)=>pA.sketch((o=>({dom:{tag:"div",classes:["tox-view-wrap__slot-container"]},components:bB(o,e,t),slotBehaviours:lw([Ki((e=>pA.hideAllSlots(e)))])}))),wB=e=>$(pA.getSlotNames(e),(t=>pA.isShowing(e,t))),_B=(e,t,o)=>{pA.getSlot(e,t).each((e=>{vB.getPane(e).each((t=>{var n;o(e)((n=t.element.dom,{getContainer:w(n)}))}))}))};var xB=fh({factory:(e,t)=>{const o={setViews:(e,o)=>{Kp.set(e,[yB(o,t.backstage.shared.providers)])},whichView:e=>_h.getCurrent(e).bind(wB),toggleView:(e,t,o,n)=>_h.getCurrent(e).exists((r=>{const i=wB(r),s=i.exists((e=>n===e)),a=pA.getSlot(r,n).isSome();return a&&(pA.hideAllSlots(r),s?((e=>{const t=e.element;Bt(t,"display","none"),Ct(t,"aria-hidden","true")})(e),t()):(o(),(e=>{const t=e.element;Lt(t,"display"),Ot(t,"aria-hidden")})(e),pA.showSlot(r,n),((e,t)=>{_B(e,t,vB.getOnShow)})(r,n)),i.each((e=>((e,t)=>_B(e,t,vB.getOnHide))(r,e)))),a}))};return{uid:e.uid,dom:{tag:"div",classes:["tox-view-wrap"],attributes:{"aria-hidden":"true"},styles:{display:"none"}},components:[],behaviours:Cl([Kp.config({}),_h.config({find:e=>{const t=Kp.contents(e);return oe(t)}})]),apis:o}},name:"silver.ViewWrapper",configFields:[or("backstage")],apis:{setViews:(e,t,o)=>e.setViews(t,o),toggleView:(e,t,o,n,r)=>e.toggleView(t,o,n,r),whichView:(e,t)=>e.whichView(t)}});const CB=aM.optional({factory:lA,name:"menubar",schema:[or("backstage")]}),kB=aM.optional({factory:{sketch:e=>uM.sketch({uid:e.uid,dom:e.dom,listBehaviours:Cl([Hp.config({mode:"acyclic",selector:".tox-toolbar"})]),makeItem:()=>aB({type:e.type,uid:ls("multiple-toolbar-item"),cyclicKeying:!1,initGroups:[],providers:e.providers,onEscape:()=>(e.onEscape(),M.some(!0))}),setupItem:(e,t,o,n)=>{pM.setGroups(t,o)},shell:!0})},name:"multiple-toolbar",schema:[or("dom"),or("onEscape")]}),SB=aM.optional({factory:{sketch:e=>{const t=(e=>e.type===rv.sliding?sB:e.type===rv.floating?iB:aB)(e);return t({type:e.type,uid:e.uid,onEscape:()=>(e.onEscape(),M.some(!0)),onToggled:(t,o)=>e.onToolbarToggled(o),cyclicKeying:!1,initGroups:[],getSink:e.getSink,providers:e.providers,moreDrawerData:{lazyToolbar:e.lazyToolbar,lazyMoreButton:e.lazyMoreButton,lazyHeader:e.lazyHeader},attributes:e.attributes})}},name:"toolbar",schema:[or("dom"),or("onEscape"),or("getSink")]}),TB=aM.optional({factory:{sketch:e=>{const t=e.editor,o=e.sticky?tA:vM;return{uid:e.uid,dom:e.dom,components:e.components,behaviours:Cl(o(t,e.sharedBackstage))}}},name:"header",schema:[or("dom")]}),EB=aM.optional({factory:{sketch:e=>({uid:e.uid,dom:e.dom,components:[{dom:{tag:"a",attributes:{href:"https://www.tiny.cloud/tinymce-self-hosted-premium-features/?utm_source=TinyMCE&utm_medium=SPAP&utm_campaign=SPAP&utm_id=editorreferral",rel:"noopener",target:"_blank","aria-hidden":"true"},classes:["tox-promotion-link"],innerHtml:"⚡️Upgrade"}}]})},name:"promotion",schema:[or("dom")]}),OB=aM.optional({name:"socket",schema:[or("dom")]}),MB=aM.optional({factory:{sketch:e=>({uid:e.uid,dom:{tag:"div",classes:["tox-sidebar"],attributes:{role:"presentation"}},components:[{dom:{tag:"div",classes:["tox-sidebar__slider"]},components:[],behaviours:Cl([cC.config({}),og.config({}),QT.config({dimension:{property:"width"},closedClass:"tox-sidebar--sliding-closed",openClass:"tox-sidebar--sliding-open",shrinkingClass:"tox-sidebar--sliding-shrinking",growingClass:"tox-sidebar--sliding-growing",onShrunk:e=>{_h.getCurrent(e).each(pA.hideAllSlots),Ri(e,xA)},onGrown:e=>{Ri(e,xA)},onStartGrow:e=>{Vi(e,_A,{width:Pt(e.element,"width").getOr("")})},onStartShrink:e=>{Vi(e,_A,{width:Xt(e.element)+"px"})}}),Kp.config({}),_h.config({find:e=>{const t=Kp.contents(e);return oe(t)}})])}],behaviours:Cl([NS(0),Xp("sidebar-sliding-events",[Zi(_A,((e,t)=>{Bt(e.element,"width",t.event.width)})),Zi(xA,((e,t)=>{Lt(e.element,"width")}))])])})},name:"sidebar",schema:[or("dom")]}),AB=aM.optional({factory:{sketch:e=>({uid:e.uid,dom:{tag:"div",attributes:{"aria-hidden":"true"},classes:["tox-throbber"],styles:{display:"none"}},behaviours:Cl([Kp.config({}),SA.config({focus:!1}),_h.config({find:e=>oe(e.components())})]),components:[]})},name:"throbber",schema:[or("dom")]}),BB=aM.optional({factory:xB,name:"viewWrapper",schema:[or("backstage")]}),NB=aM.optional({factory:{sketch:e=>({uid:e.uid,dom:{tag:"div",classes:["tox-editor-container"]},components:e.components})},name:"editorContainer",schema:[]});var RB=vh({name:"OuterContainer",factory:(e,t,o)=>{let n=!1;const r={getSocket:t=>sM.getPart(t,e,"socket"),setSidebar:(t,o,n)=>{sM.getPart(t,e,"sidebar").each((e=>((e,t,o)=>{_h.getCurrent(e).each((n=>{Kp.set(n,[bA(t)]);const r=null==o?void 0:o.toLowerCase();i(r)&&be(t,r)&&_h.getCurrent(n).each((t=>{pA.showSlot(t,r),QT.immediateGrow(n),Lt(n.element,"width"),yA(e.element,"region")}))}))})(e,o,n)))},toggleSidebar:(t,o)=>{sM.getPart(t,e,"sidebar").each((e=>((e,t)=>{_h.getCurrent(e).each((o=>{_h.getCurrent(o).each((n=>{QT.hasGrown(o)?pA.isShowing(n,t)?(QT.shrink(o),yA(e.element,"presentation")):(pA.hideAllSlots(n),pA.showSlot(n,t),yA(e.element,"region")):(pA.hideAllSlots(n),pA.showSlot(n,t),QT.grow(o),yA(e.element,"region"))}))}))})(e,o)))},whichSidebar:t=>sM.getPart(t,e,"sidebar").bind(wA).getOrNull(),getHeader:t=>sM.getPart(t,e,"header"),getToolbar:t=>sM.getPart(t,e,"toolbar"),setToolbar:(t,o)=>{sM.getPart(t,e,"toolbar").each((e=>{const t=L(o,oB);e.getApis().setGroups(e,t)}))},setToolbars:(t,o)=>{sM.getPart(t,e,"multiple-toolbar").each((e=>{const t=L(o,(e=>L(e,oB)));uM.setItems(e,t)}))},refreshToolbar:t=>{sM.getPart(t,e,"toolbar").each((e=>e.getApis().refresh(e)))},toggleToolbarDrawer:t=>{sM.getPart(t,e,"toolbar").each((e=>{Ce(e.getApis().toggle,(t=>t(e)))}))},toggleToolbarDrawerWithoutFocusing:t=>{sM.getPart(t,e,"toolbar").each((e=>{Ce(e.getApis().toggleWithoutFocusing,(t=>t(e)))}))},isToolbarDrawerToggled:t=>sM.getPart(t,e,"toolbar").bind((e=>M.from(e.getApis().isOpen).map((t=>t(e))))).getOr(!1),getThrobber:t=>sM.getPart(t,e,"throbber"),focusToolbar:t=>{sM.getPart(t,e,"toolbar").orThunk((()=>sM.getPart(t,e,"multiple-toolbar"))).each((e=>{Hp.focusIn(e)}))},setMenubar:(t,o)=>{sM.getPart(t,e,"menubar").each((e=>{lA.setMenus(e,o)}))},focusMenubar:t=>{sM.getPart(t,e,"menubar").each((e=>{lA.focus(e)}))},setViews:(t,o)=>{sM.getPart(t,e,"viewWrapper").each((e=>{xB.setViews(e,o)}))},toggleView:(t,o)=>sM.getPart(t,e,"viewWrapper").exists((e=>xB.toggleView(e,(()=>r.showMainView(t)),(()=>r.hideMainView(t)),o))),whichView:t=>sM.getPart(t,e,"viewWrapper").bind(xB.whichView).getOrNull(),hideMainView:t=>{n=r.isToolbarDrawerToggled(t),n&&r.toggleToolbarDrawer(t),sM.getPart(t,e,"editorContainer").each((e=>{const t=e.element;Bt(t,"display","none"),Ct(t,"aria-hidden","true")}))},showMainView:t=>{n&&r.toggleToolbarDrawer(t),sM.getPart(t,e,"editorContainer").each((e=>{const t=e.element;Lt(t,"display"),Ot(t,"aria-hidden")}))}};return{uid:e.uid,dom:e.dom,components:t,apis:r,behaviours:e.behaviours}},configFields:[or("dom"),or("behaviours")],partFields:[TB,CB,SB,kB,OB,MB,EB,AB,BB,NB],apis:{getSocket:(e,t)=>e.getSocket(t),setSidebar:(e,t,o,n)=>{e.setSidebar(t,o,n)},toggleSidebar:(e,t,o)=>{e.toggleSidebar(t,o)},whichSidebar:(e,t)=>e.whichSidebar(t),getHeader:(e,t)=>e.getHeader(t),getToolbar:(e,t)=>e.getToolbar(t),setToolbar:(e,t,o)=>{e.setToolbar(t,o)},setToolbars:(e,t,o)=>{e.setToolbars(t,o)},refreshToolbar:(e,t)=>e.refreshToolbar(t),toggleToolbarDrawer:(e,t)=>{e.toggleToolbarDrawer(t)},toggleToolbarDrawerWithoutFocusing:(e,t)=>{e.toggleToolbarDrawerWithoutFocusing(t)},isToolbarDrawerToggled:(e,t)=>e.isToolbarDrawerToggled(t),getThrobber:(e,t)=>e.getThrobber(t),setMenubar:(e,t,o)=>{e.setMenubar(t,o)},focusMenubar:(e,t)=>{e.focusMenubar(t)},focusToolbar:(e,t)=>{e.focusToolbar(t)},setViews:(e,t,o)=>{e.setViews(t,o)},toggleView:(e,t,o)=>e.toggleView(t,o),whichView:(e,t)=>e.whichView(t)}});const VB={file:{title:"File",items:"newdocument restoredraft | preview | export print | deleteallconversations"},edit:{title:"Edit",items:"undo redo | cut copy paste pastetext | selectall | searchreplace"},view:{title:"View",items:"code | visualaid visualchars visualblocks | spellchecker | preview fullscreen | showcomments"},insert:{title:"Insert",items:"image link media addcomment pageembed template inserttemplate codesample inserttable accordion | charmap emoticons hr | pagebreak nonbreaking anchor tableofcontents footnotes | mergetags | insertdatetime"},format:{title:"Format",items:"bold italic underline strikethrough superscript subscript codeformat | styles blocks fontfamily fontsize align lineheight | forecolor backcolor | language | removeformat"},tools:{title:"Tools",items:"aidialog aishortcuts | spellchecker spellcheckerlanguage | autocorrect capitalization | a11ycheck code typography wordcount addtemplate"},table:{title:"Table",items:"inserttable | cell row column | advtablesort | tableprops deletetable"},help:{title:"Help",items:"help"}},DB=e=>e.split(" "),PB=(e,t)=>{const o={...VB,...t.menus},n=se(t.menus).length>0,r=void 0===t.menubar||!0===t.menubar?DB("file edit view insert format tools table help"):DB(!1===t.menubar?"":t.menubar),s=Z(r,(e=>{const o=be(VB,e);return n?o||ve(t.menus,e).exists((e=>be(e,"items"))):o})),a=L(s,(n=>{const r=o[n];return((e,t,o)=>{const n=Cv(o).split(/[ ,]/);return{text:e.title,getItems:()=>G(e.items,(e=>{const o=e.toLowerCase();return 0===o.trim().length||P(n,(e=>e===o))?[]:"separator"===o||"|"===o?[{type:"separator"}]:t.menuItems[o]?[t.menuItems[o]]:[]}))}})({title:r.title,items:DB(r.items)},t,e)}));return Z(a,(e=>e.getItems().length>0&&P(e.getItems(),(e=>i(e)||"separator"!==e.type))))},IB=e=>{const t=()=>{e._skinLoaded=!0,(e=>{e.dispatch("SkinLoaded")})(e)};return()=>{e.initialized?t():e.on("init",t)}},FB=(e,t,o)=>(e.on("remove",(()=>o.unload(t))),o.load(t)),LB=(e,t)=>FB(e,t+"/skin.min.css",e.ui.styleSheetLoader),zB=(e,t)=>{var o;return o=Ie(e.getElement()),vt(o).isSome()?FB(e,t+"/skin.shadowdom.min.css",sv.DOM.styleSheetLoader):Promise.resolve()},HB=(e,t)=>{const o=Xv(t);return o&&t.contentCSS.push(o+(e?"/content.inline":"/content")+".min.css"),!Yv(t)&&i(o)?Promise.all([LB(t,o),zB(t,o)]).then(IB(t),((e,t)=>()=>((e,t)=>{e.dispatch("SkinLoadError",t)})(e,{message:"Skin could not be loaded"}))(t)):Promise.resolve(IB(t)())},ZB=C(HB,!1),jB=C(HB,!0),UB=(e,t,o)=>{const n=(e,n,i,s)=>{const a=t.shared.providers.translate(e.title);if("separator"===e.type)return M.some({type:"separator",text:a});if("submenu"===e.type){const t=G(e.getStyleItems(),(e=>r(e,n,s)));return 0===n&&t.length<=0?M.none():M.some({type:"nestedmenuitem",text:a,enabled:t.length>0,getSubmenuItems:()=>G(e.getStyleItems(),(e=>r(e,n,s)))})}return M.some({type:"togglemenuitem",text:a,icon:e.icon,active:e.isSelected(s),enabled:!i,onAction:o.onAction(e),...e.getStylePreview().fold((()=>({})),(e=>({meta:{style:e}})))})},r=(e,t,r)=>{const i="formatter"===e.type&&o.isInvalid(e);return 0===t?i?[]:n(e,t,!1,r).toArray():n(e,t,i,r).toArray()},i=e=>{const t=o.getCurrentValue(),n=o.shouldHide?0:1;return G(e,(e=>r(e,n,t)))};return{validateItems:i,getFetch:(e,t)=>(o,n)=>{const r=t(),s=i(r);n(kT(s,pb.CLOSE_ON_EXECUTE,e,{isHorizontalMenu:!1,search:M.none()}))}}},$B=(e,t,o)=>{const n=o.dataset,r="basic"===n.type?()=>L(n.data,(e=>RO(e,o.isSelectedFor,o.getPreviewFor))):n.getData;return{items:UB(0,t,o),getStyleItems:r}},WB=(e,t,o)=>{const{items:n,getStyleItems:r}=$B(0,t,o),i=y_(e,"NodeChange",(t=>{const n=t.getComponent();o.updateText(n),Dh.set(t.getComponent(),!e.selection.isEditable())}));return wT({text:o.icon.isSome()?M.none():o.text,icon:o.icon,tooltip:M.from(o.tooltip),role:M.none(),fetch:n.getFetch(t,r),onSetup:i,getApi:e=>({getComponent:w(e)}),columns:1,presets:"normal",classes:o.icon.isSome()?[]:["bespoke"],dropdownBehaviours:[]},"tox-tbtn",t.shared)};var qB;!function(e){e[e.SemiColon=0]="SemiColon",e[e.Space=1]="Space"}(qB||(qB={}));const GB=(e,t,o)=>{const n=(r=((e,t)=>t===qB.SemiColon?e.replace(/;$/,"").split(";"):e.split(" "))(e.options.get(t),o),L(r,(e=>{let t=e,o=e;const n=e.split("=");return n.length>1&&(t=n[0],o=n[1]),{title:t,format:o}})));var r;return{type:"basic",data:n}},YB=[{title:"Left",icon:"align-left",format:"alignleft",command:"JustifyLeft"},{title:"Center",icon:"align-center",format:"aligncenter",command:"JustifyCenter"},{title:"Right",icon:"align-right",format:"alignright",command:"JustifyRight"},{title:"Justify",icon:"align-justify",format:"alignjustify",command:"JustifyFull"}],KB=e=>{const t={type:"basic",data:YB};return{tooltip:"Align",text:M.none(),icon:M.some("align-left"),isSelectedFor:t=>()=>e.formatter.match(t),getCurrentValue:M.none,getPreviewFor:e=>M.none,onAction:t=>()=>$(YB,(e=>e.format===t.format)).each((t=>e.execCommand(t.command))),updateText:t=>{const o=$(YB,(t=>e.formatter.match(t.format))).fold(w("left"),(e=>e.title.toLowerCase()));Vi(t,yT,{icon:`align-${o}`})},dataset:t,shouldHide:!1,isInvalid:t=>!e.formatter.canApply(t.format)}},XB=(e,t)=>{const o=t(),n=L(o,(e=>e.format));return M.from(e.formatter.closest(n)).bind((e=>$(o,(t=>t.format===e)))).orThunk((()=>ke(e.formatter.match("p"),{title:"Paragraph",format:"p"})))},JB=e=>{const t="Paragraph",o=GB(e,"block_formats",qB.SemiColon);return{tooltip:"Blocks",text:M.some(t),icon:M.none(),isSelectedFor:t=>()=>e.formatter.match(t),getCurrentValue:M.none,getPreviewFor:t=>()=>{const o=e.formatter.get(t);return o?M.some({tag:o.length>0&&(o[0].inline||o[0].block)||"div",styles:e.dom.parseStyle(e.formatter.getCssText(t))}):M.none()},onAction:w_(e),updateText:n=>{const r=XB(e,(()=>o.data)).fold(w(t),(e=>e.title));Vi(n,bT,{text:r})},dataset:o,shouldHide:!1,isInvalid:t=>!e.formatter.canApply(t.format)}},QB=["-apple-system","Segoe UI","Roboto","Helvetica Neue","sans-serif"],eN=e=>{const t=e.split(/\s*,\s*/);return L(t,(e=>e.replace(/^['"]+|['"]+$/g,"")))},tN=e=>{const t="System Font",o=()=>{const o=e=>e?eN(e)[0]:"",r=e.queryCommandValue("FontName"),i=n.data,s=r?r.toLowerCase():"",a=$(i,(e=>{const t=e.format;return t.toLowerCase()===s||o(t).toLowerCase()===o(s).toLowerCase()})).orThunk((()=>ke((e=>0===e.indexOf("-apple-system")&&(()=>{const t=eN(e.toLowerCase());return Y(QB,(e=>t.indexOf(e.toLowerCase())>-1))})())(s),{title:t,format:s})));return{matchOpt:a,font:r}},n=GB(e,"font_family_formats",qB.SemiColon);return{tooltip:"Fonts",text:M.some(t),icon:M.none(),isSelectedFor:e=>t=>t.exists((t=>t.format===e)),getCurrentValue:()=>{const{matchOpt:e}=o();return e},getPreviewFor:e=>()=>M.some({tag:"div",styles:-1===e.indexOf("dings")?{"font-family":e}:{}}),onAction:t=>()=>{e.undoManager.transact((()=>{e.focus(),e.execCommand("FontName",!1,t.format)}))},updateText:e=>{const{matchOpt:t,font:n}=o(),r=t.fold(w(n),(e=>e.title));Vi(e,bT,{text:r})},dataset:n,shouldHide:!1,isInvalid:E}},oN={unsupportedLength:["em","ex","cap","ch","ic","rem","lh","rlh","vw","vh","vi","vb","vmin","vmax","cm","mm","Q","in","pc","pt","px"],fixed:["px","pt"],relative:["%"],empty:[""]},nN=(()=>{const e="[0-9]+",t="[eE][+-]?"+e,o=e=>`(?:${e})?`,n=["Infinity",e+"\\."+o(e)+o(t),"\\."+e+o(t),e+o(t)].join("|");return new RegExp(`^([+-]?(?:${n}))(.*)$`)})(),rN=(e,t)=>M.from(nN.exec(e)).bind((e=>{const o=Number(e[1]),n=e[2];return((e,t)=>P(t,(t=>P(oN[t],(t=>e===t)))))(n,t)?M.some({value:o,unit:n}):M.none()})),iN={tab:w(9),escape:w(27),enter:w(13),backspace:w(8),delete:w(46),left:w(37),up:w(38),right:w(39),down:w(40),space:w(32),home:w(36),end:w(35),pageUp:w(33),pageDown:w(34)},sN={"8pt":"1","10pt":"2","12pt":"3","14pt":"4","18pt":"5","24pt":"6","36pt":"7"},aN={"xx-small":"7pt","x-small":"8pt",small:"10pt",medium:"12pt",large:"14pt","x-large":"18pt","xx-large":"24pt"},lN=(e,t)=>/[0-9.]+px$/.test(e)?((e,t)=>{const o=Math.pow(10,t);return Math.round(e*o)/o})(72*parseInt(e,10)/96,t||0)+"pt":ve(aN,e).getOr(e),cN=e=>ve(sN,e).getOr(""),dN=e=>{const t=()=>{let t=M.none();const o=n.data,r=e.queryCommandValue("FontSize");if(r)for(let e=3;t.isNone()&&e>=0;e--){const n=lN(r,e),i=cN(n);t=$(o,(e=>e.format===r||e.format===n||e.format===i))}return{matchOpt:t,size:r}},o=w(M.none),n=GB(e,"font_size_formats",qB.Space);return{tooltip:"Font sizes",text:M.some("12pt"),icon:M.none(),isSelectedFor:e=>t=>t.exists((t=>t.format===e)),getPreviewFor:o,getCurrentValue:()=>{const{matchOpt:e}=t();return e},onAction:t=>()=>{e.undoManager.transact((()=>{e.focus(),e.execCommand("FontSize",!1,t.format)}))},updateText:e=>{const{matchOpt:o,size:n}=t(),r=o.fold(w(n),(e=>e.title));Vi(e,bT,{text:r})},dataset:n,shouldHide:!1,isInvalid:E}},uN=(e,t)=>{const o="Paragraph";return{tooltip:"Formats",text:M.some(o),icon:M.none(),isSelectedFor:t=>()=>e.formatter.match(t),getCurrentValue:M.none,getPreviewFor:t=>()=>{const o=e.formatter.get(t);return void 0!==o?M.some({tag:o.length>0&&(o[0].inline||o[0].block)||"div",styles:e.dom.parseStyle(e.formatter.getCssText(t))}):M.none()},onAction:w_(e),updateText:t=>{const n=e=>OO(e)?G(e.items,n):MO(e)?[{title:e.title,format:e.format}]:[],r=G(NO(e),n),i=XB(e,w(r)).fold(w(o),(e=>e.title));Vi(t,bT,{text:i})},shouldHide:_v(e),isInvalid:t=>!e.formatter.canApply(t.format),dataset:t}},hN=w([or("toggleClass"),or("fetch"),Ra("onExecute"),yr("getHotspot",M.some),yr("getAnchorOverrides",w({})),_c(),Ra("onItemExecute"),ur("lazySink"),or("dom"),Ba("onOpen"),gu("splitDropdownBehaviours",[ux,Hp,og]),yr("matchWidth",!1),yr("useMinWidth",!1),yr("eventOrder",{}),ur("role")].concat(Ox())),mN=Zu({factory:jg,schema:[or("dom")],name:"arrow",defaults:()=>({buttonBehaviours:Cl([og.revoke()])}),overrides:e=>({dom:{tag:"span",attributes:{role:"presentation"}},action:t=>{t.getSystem().getByUid(e.uid).each(Di)},buttonBehaviours:Cl([dg.config({toggleOnExecute:!1,toggleClass:e.toggleClass})])})}),pN=Zu({factory:jg,schema:[or("dom")],name:"button",defaults:()=>({buttonBehaviours:Cl([og.revoke()])}),overrides:e=>({dom:{tag:"span",attributes:{role:"presentation"}},action:t=>{t.getSystem().getByUid(e.uid).each((o=>{e.onExecute(o,t)}))}})}),gN=w([mN,pN,Uu({factory:{sketch:e=>({uid:e.uid,dom:{tag:"span",styles:{display:"none"},attributes:{"aria-hidden":"true"},innerHtml:e.text}})},schema:[or("text")],name:"aria-descriptor"}),ju({schema:[Oa()],name:"menu",defaults:e=>({onExecute:(t,o)=>{t.getSystem().getByUid(e.uid).each((n=>{e.onItemExecute(n,t,o)}))}})}),yx()]),fN=vh({name:"SplitDropdown",configFields:hN(),partFields:gN(),factory:(e,t,o,n)=>{const r=e=>{_h.getCurrent(e).each((e=>{$h.highlightFirst(e),Hp.focusIn(e)}))},i=t=>{Cx(e,_,t,n,r,Fg.HighlightMenuAndItem).get(v)},s=t=>{const o=nh(t,e,"button");return Di(o),M.some(!0)},a={...Li([Ki(((t,o)=>{oh(t,e,"aria-descriptor").each((e=>{const o=ls("aria");Ct(e.element,"id",o),Ct(t.element,"aria-describedby",o)}))}))]),...hg(M.some(i))},l={repositionMenus:e=>{dg.isOn(e)&&Ex(e)}};return{uid:e.uid,dom:e.dom,components:t,apis:l,eventOrder:{...e.eventOrder,[ui()]:["disabling","toggling","alloy.base.behaviour"]},events:a,behaviours:vu(e.splitDropdownBehaviours,[ux.config({others:{sandbox:t=>{const o=nh(t,e,"arrow");return Tx(e,t,{onOpen:()=>{dg.on(o),dg.on(t)},onClose:()=>{dg.off(o),dg.off(t)}})}}}),Hp.config({mode:"special",onSpace:s,onEnter:s,onDown:e=>(i(e),M.some(!0))}),og.config({}),dg.config({toggleOnExecute:!1,aria:{mode:"expanded"}})]),domModification:{attributes:{role:e.role.getOr("button"),"aria-haspopup":!0}}}},apis:{repositionMenus:(e,t)=>e.repositionMenus(t)}}),vN=e=>({isEnabled:()=>!Dh.isDisabled(e),setEnabled:t=>Dh.set(e,!t),setText:t=>Vi(e,bT,{text:t}),setIcon:t=>Vi(e,yT,{icon:t})}),bN=e=>({setActive:t=>{dg.set(e,t)},isActive:()=>dg.isOn(e),isEnabled:()=>!Dh.isDisabled(e),setEnabled:t=>Dh.set(e,!t),setText:t=>Vi(e,bT,{text:t}),setIcon:t=>Vi(e,yT,{icon:t})}),yN=(e,t)=>e.map((e=>({"aria-label":t.translate(e),title:t.translate(e)}))).getOr({}),wN=ls("focus-button"),_N=(e,t,o,n,r)=>{const i=t.map((e=>$g(vT(e,"tox-tbtn",r)))),s=e.map((e=>$g(fT(e,r.icons))));return{dom:{tag:"button",classes:["tox-tbtn"].concat(t.isSome()?["tox-tbtn--select"]:[]),attributes:yN(o,r)},components:Bw([s.map((e=>e.asSpec())),i.map((e=>e.asSpec()))]),eventOrder:{[jr()]:["focusing","alloy.base.behaviour",uT],[xi()]:[uT,"toolbar-group-button-events"]},buttonBehaviours:Cl([Sw(r.isDisabled),xw(),Xp(uT,[Ki(((e,t)=>mT(e))),Zi(bT,((e,t)=>{i.bind((t=>t.getOpt(e))).each((e=>{Kp.set(e,[ta(r.translate(t.event.text))])}))})),Zi(yT,((e,t)=>{s.bind((t=>t.getOpt(e))).each((e=>{Kp.set(e,[fT(t.event.icon,r.icons)])}))})),Zi(jr(),((e,t)=>{t.event.prevent(),Ri(e,wN)}))])].concat(n.getOr([])))}},xN=(e,t,o)=>{var n;const r=Or(v),i=_N(e.icon,e.text,e.tooltip,M.none(),o);return jg.sketch({dom:i.dom,components:i.components,eventOrder:hT,buttonBehaviours:{...Cl([Xp("toolbar-button-events",[(s={onAction:e.onAction,getApi:t.getApi},Qi(((e,t)=>{Tw(s,e)((t=>{Vi(e,dT,{buttonApi:t}),s.onAction(t)}))}))),Ew(t,r),Ow(t,r)]),Sw((()=>!e.enabled||o.isDisabled())),xw()].concat(t.toolbarButtonBehaviours)),[uT]:null===(n=i.buttonBehaviours)||void 0===n?void 0:n[uT]}});var s},CN=(e,t,o)=>xN(e,{toolbarButtonBehaviours:o.length>0?[Xp("toolbarButtonWith",o)]:[],getApi:vN,onSetup:e.onSetup},t),kN=(e,t,o)=>xN(e,{toolbarButtonBehaviours:[Kp.config({}),dg.config({toggleClass:"tox-tbtn--enabled",aria:{mode:"pressed"},toggleOnExecute:!1})].concat(o.length>0?[Xp("toolbarToggleButtonWith",o)]:[]),getApi:bN,onSetup:e.onSetup},t),SN=(e,t,o)=>n=>fx((e=>t.fetch(e))).map((r=>M.from(Lx(fn(J_(ls("menu-value"),r,(o=>{t.onItemAction(e(n),o)}),t.columns,t.presets,pb.CLOSE_ON_EXECUTE,t.select.getOr(E),o),{movement:ex(t.columns,t.presets),menuBehaviours:lw("auto"!==t.columns?[]:[Ki(((e,o)=>{aw(e,4,Tb(t.presets)).each((({numRows:t,numColumns:o})=>{Hp.setGridSize(e,t,o)}))}))])}))))),TN=[{name:"history",items:["undo","redo"]},{name:"ai",items:["aidialog","aishortcuts"]},{name:"styles",items:["styles"]},{name:"formatting",items:["bold","italic"]},{name:"alignment",items:["alignleft","aligncenter","alignright","alignjustify"]},{name:"indentation",items:["outdent","indent"]},{name:"permanent pen",items:["permanentpen"]},{name:"comments",items:["addcomment"]}],EN=(e,t)=>(o,n,r)=>{const i=e(o).mapError((e=>Kn(e))).getOrDie();return t(i,n,r)},ON={button:EN(Ry,((e,t)=>{return o=e,n=t.shared.providers,CN(o,n,[]);var o,n})),togglebutton:EN(Py,((e,t)=>{return o=e,n=t.shared.providers,kN(o,n,[]);var o,n})),menubutton:EN(sA,((e,t)=>tE(e,"tox-tbtn",t,M.none(),!1))),splitbutton:EN((e=>qn("SplitButton",aA,e)),((e,t)=>((e,t)=>{const o=e=>({isEnabled:()=>!Dh.isDisabled(e),setEnabled:t=>Dh.set(e,!t),setIconFill:(t,o)=>{pa(e.element,`svg path[class="${t}"], rect[class="${t}"]`).each((e=>{Ct(e,"fill",o)}))},setActive:t=>{Ct(e.element,"aria-pressed",t),pa(e.element,"span").each((o=>{e.getSystem().getByDom(o).each((e=>dg.set(e,t)))}))},isActive:()=>pa(e.element,"span").exists((t=>e.getSystem().getByDom(t).exists(dg.isOn))),setText:t=>pa(e.element,"span").each((o=>e.getSystem().getByDom(o).each((e=>Vi(e,bT,{text:t}))))),setIcon:t=>pa(e.element,"span").each((o=>e.getSystem().getByDom(o).each((e=>Vi(e,yT,{icon:t})))))}),n=Or(v),r={getApi:o,onSetup:e.onSetup};return fN.sketch({dom:{tag:"div",classes:["tox-split-button"],attributes:{"aria-pressed":!1,...yN(e.tooltip,t.providers)}},onExecute:t=>{const n=o(t);n.isEnabled()&&e.onAction(n)},onItemExecute:(e,t,o)=>{},splitDropdownBehaviours:Cl([kw(t.providers.isDisabled),xw(),Xp("split-dropdown-events",[Ki(((e,t)=>mT(e))),Zi(wN,og.focus),Ew(r,n),Ow(r,n)]),VC.config({})]),eventOrder:{[xi()]:["alloy.base.behaviour","split-dropdown-events"]},toggleClass:"tox-tbtn--enabled",lazySink:t.getSink,fetch:SN(o,e,t.providers),parts:{menu:Nb(0,e.columns,e.presets)},components:[fN.parts.button(_N(e.icon,e.text,M.none(),M.some([dg.config({toggleClass:"tox-tbtn--enabled",toggleOnExecute:!1})]),t.providers)),fN.parts.arrow({dom:{tag:"button",classes:["tox-tbtn","tox-split-button__chevron"],innerHtml:Jf("chevron-down",t.providers.icons)},buttonBehaviours:Cl([kw(t.providers.isDisabled),xw(),Qf()])}),fN.parts["aria-descriptor"]({text:t.providers.translate("To open the popup, press Shift+Enter")})]})})(e,t.shared))),grouptoolbarbutton:EN((e=>qn("GroupToolbarButton",nA,e)),((e,t,o)=>{const n=o.ui.registry.getAll().buttons,r={[yc]:t.shared.header.isPositionedAtTop()?bc.TopToBottom:bc.BottomToTop};if(kv(o)===rv.floating)return((e,t,o,n)=>{const r=t.shared,i=Or(v),s={toolbarButtonBehaviours:[],getApi:vN,onSetup:e.onSetup},a=[Xp("toolbar-group-button-events",[Ew(s,i),Ow(s,i)])];return jA.sketch({lazySink:r.getSink,fetch:()=>fx((t=>{t(L(o(e.items),oB))})),markers:{toggledClass:"tox-tbtn--enabled"},parts:{button:_N(e.icon,e.text,e.tooltip,M.some(a),r.providers),toolbar:{dom:{tag:"div",classes:["tox-toolbar__overflow"],attributes:n}}}})})(e,t,(e=>AN(o,{buttons:n,toolbar:e,allowToolbarGroups:!1},t,M.none())),r);throw new Error("Toolbar groups are only supported when using floating toolbar mode")}))},MN={styles:(e,t)=>{const o={type:"advanced",...t.styles};return WB(e,t,uN(e,o))},fontsize:(e,t)=>WB(e,t,dN(e)),fontsizeinput:(e,t)=>((e,t,o)=>{let n=M.none();const r=y_(e,"NodeChange SwitchMode",(t=>{const r=t.getComponent();n=M.some(r),o.updateInputValue(r),Dh.set(r,!e.selection.isEditable())})),i=e=>({getComponent:w(e)}),s=Or(v),a=ls("custom-number-input-events"),l=(e,t,r)=>{const i=n.map((e=>pu.getValue(e))).getOr(""),s=o.getNewValue(i,e),a=i.length-`${s}`.length,l=n.map((e=>e.element.dom.selectionStart-a)),c=n.map((e=>e.element.dom.selectionEnd-a));o.onAction(s,r),n.each((e=>{pu.setValue(e,s),t&&(l.each((t=>e.element.dom.selectionStart=t)),c.each((t=>e.element.dom.selectionEnd=t)))}))},c=(e,t)=>l(((e,t)=>e-t),e,t),d=(e,t)=>l(((e,t)=>e+t),e,t),u=e=>it(e.element).fold(M.none,(e=>(Bl(e),M.some(!0)))),h=e=>Rl(e.element)?(ct(e.element).each((e=>Bl(e))),M.some(!0)):M.none(),m=(o,n,r,a)=>{const l=t.shared.providers.translate(r),c=ls("altExecuting"),d=y_(e,"NodeChange SwitchMode",(t=>{Dh.set(t.getComponent(),!e.selection.isEditable())})),u=e=>{Dh.isDisabled(e)||o(!0)};return jg.sketch({dom:{tag:"button",attributes:{title:l,"aria-label":l},classes:a.concat(n)},components:[gT(n,t.shared.providers.icons)],buttonBehaviours:Cl([Dh.config({}),Xp(c,[Ew({onSetup:d,getApi:i},s),Ow({getApi:i},s),Zi(Kr(),((e,t)=>{t.event.raw.keyCode!==iN.space()&&t.event.raw.keyCode!==iN.enter()||Dh.isDisabled(e)||o(!1)})),Zi(ei(),u),Zi(Hr(),u)])]),eventOrder:{[Kr()]:[c,"keying"],[ei()]:[c,"alloy.base.behaviour"],[Hr()]:[c,"alloy.base.behaviour"]}})},p=$g(m((e=>c(!1,e)),"minus","Decrease font size",["highlight-on-focus"])),g=$g(m((e=>d(!1,e)),"plus","Increase font size",["highlight-on-focus"])),f=$g({dom:{tag:"div",classes:["tox-input-wrapper","highlight-on-focus"]},components:[Ib.sketch({inputBehaviours:Cl([Dh.config({}),Xp(a,[Ew({onSetup:r,getApi:i},s),Ow({getApi:i},s)]),Xp("input-update-display-text",[Zi(bT,((e,t)=>{pu.setValue(e,t.event.text)})),Zi(Yr(),(e=>{o.onAction(pu.getValue(e))})),Zi(Qr(),(e=>{o.onAction(pu.getValue(e))}))]),Hp.config({mode:"special",onEnter:e=>(l(_,!0,!0),M.some(!0)),onEscape:u,onUp:e=>(d(!0,!1),M.some(!0)),onDown:e=>(c(!0,!1),M.some(!0)),onLeft:(e,t)=>(t.cut(),M.none()),onRight:(e,t)=>(t.cut(),M.none())})])})],behaviours:Cl([og.config({}),Hp.config({mode:"special",onEnter:h,onSpace:h,onEscape:u}),Xp("input-wrapper-events",[Zi(qr(),(e=>{z([p,g],(t=>{const o=Ie(t.get(e).element.dom);Rl(o)&&Nl(o)}))}))])])});return{dom:{tag:"div",classes:["tox-number-input"]},components:[p.asSpec(),f.asSpec(),g.asSpec()],behaviours:Cl([og.config({}),Hp.config({mode:"flow",focusInside:pm.OnEnterOrSpaceMode,cycles:!1,selector:"button, .tox-input-wrapper",onEscape:e=>Rl(e.element)?M.none():(Bl(e.element),M.some(!0))})])}})(e,t,(e=>{const t=()=>e.queryCommandValue("FontSize");return{updateInputValue:e=>Vi(e,bT,{text:t()}),onAction:(t,o)=>e.execCommand("FontSize",!1,t,{skip_focus:!o}),getNewValue:(o,n)=>{rN(o,["unsupportedLength","empty"]);const r=rN(o,["unsupportedLength","empty"]).or(rN(t(),["unsupportedLength","empty"])),i=r.map((e=>e.value)).getOr(16),s=Dv(e),a=r.map((e=>e.unit)).filter((e=>""!==e)).getOr(s),l=n(i,(e=>{var t;return null!==(t={em:{step:.1},cm:{step:.1},in:{step:.1},pc:{step:.1},ch:{step:.1},rem:{step:.1}}[e])&&void 0!==t?t:{step:1}})(a).step);return`${(e=>e>=0)(l)?l:i}${a}`}}})(e)),fontfamily:(e,t)=>WB(e,t,tN(e)),blocks:(e,t)=>WB(e,t,JB(e)),align:(e,t)=>WB(e,t,KB(e))},AN=(e,t,o,n)=>{const r=(e=>{const t=e.toolbar,o=e.buttons;return!1===t?[]:void 0===t||!0===t?(e=>{const t=L(TN,(t=>{const o=Z(t.items,(t=>be(e,t)||be(MN,t)));return{name:t.name,items:o}}));return Z(t,(e=>e.items.length>0))})(o):i(t)?(e=>{const t=e.split("|");return L(t,(e=>({items:e.trim().split(" ")})))})(t):(e=>f(e,(e=>be(e,"name")&&be(e,"items"))))(t)?t:(console.error("Toolbar type should be string, string[], boolean or ToolbarGroup[]"),[])})(t),s=L(r,(r=>{const i=G(r.items,(r=>0===r.trim().length?[]:((e,t,o,n,r,i)=>ve(t,o.toLowerCase()).orThunk((()=>i.bind((e=>ie(e,(e=>ve(t,e+o.toLowerCase()))))))).fold((()=>ve(MN,o.toLowerCase()).map((t=>t(e,r)))),(t=>"grouptoolbarbutton"!==t.type||n?((e,t,o)=>ve(ON,e.type).fold((()=>(console.error("skipping button defined by",e),M.none())),(n=>M.some(n(e,t,o)))))(t,r,e):(console.warn(`Ignoring the '${o}' toolbar button. Group toolbar buttons are only supported when using floating toolbar mode and cannot be nested.`),M.none()))))(e,t.buttons,r,t.allowToolbarGroups,o,n).toArray()));return{title:M.from(e.translate(r.name)),items:i}}));return Z(s,(e=>e.items.length>0))},BN=(e,t,o,n)=>{const r=t.mainUi.outerContainer,s=o.toolbar,a=o.buttons;if(f(s,i)){const t=s.map((t=>{const r={toolbar:t,buttons:a,allowToolbarGroups:o.allowToolbarGroups};return AN(e,r,n,M.none())}));RB.setToolbars(r,t)}else RB.setToolbar(r,AN(e,o,n,M.none()))},NN=Bo(),RN=NN.os.isiOS()&&NN.os.version.major<=12;var VN=Object.freeze({__proto__:null,render:(e,t,o,n,r)=>{const{mainUi:i,uiMotherships:s}=t,a=Or(0),l=i.outerContainer;e.on("SkinLoaded",(()=>{BN(e,t,o,n)})),ZB(e);const d=Ie(r.targetNode),u=ft(gt(d));Dd(d,i.mothership),((e,t,o)=>{lb(e)&&Dd(o.mainUi.mothership.element,o.popupUi.mothership),Vd(t,o.dialogUi.mothership)})(e,u,t),e.on("PostRender",(()=>{RB.setSidebar(l,o.sidebar,Wv(e)),BN(e,t,o,n),a.set(e.getWin().innerWidth),RB.setMenubar(l,PB(e,o)),RB.setViews(l,o.views),((e,t)=>{const{uiMotherships:o}=t,n=e.dom;let r=e.getWin();const i=e.getDoc().documentElement,s=Or(Wt(r.innerWidth,r.innerHeight)),a=Or(Wt(i.offsetWidth,i.offsetHeight)),l=()=>{const t=s.get();t.left===r.innerWidth&&t.top===r.innerHeight||(s.set(Wt(r.innerWidth,r.innerHeight)),m_(e))},c=()=>{const t=e.getDoc().documentElement,o=a.get();o.left===t.offsetWidth&&o.top===t.offsetHeight||(a.set(Wt(t.offsetWidth,t.offsetHeight)),m_(e))},d=t=>{((e,t)=>{e.dispatch("ScrollContent",t)})(e,t)};n.bind(r,"resize",l),n.bind(r,"scroll",d);const u=oc(Ie(e.getBody()),"load",c);e.on("hide",(()=>{z(o,(e=>{Bt(e.element,"display","none")}))})),e.on("show",(()=>{z(o,(e=>{Lt(e.element,"display")}))})),e.on("NodeChange",c),e.on("remove",(()=>{u.unbind(),n.unbind(r,"resize",l),n.unbind(r,"scroll",d),r=null}))})(e,t)}));const h=RB.getSocket(l).getOrDie("Could not find expected socket element");if(RN){Nt(h.element,{overflow:"scroll","-webkit-overflow-scrolling":"touch"});const t=((e,t)=>{let o=null;return{cancel:()=>{c(o)||(clearTimeout(o),o=null)},throttle:(...t)=>{c(o)&&(o=setTimeout((()=>{o=null,e.apply(null,t)}),20))}}})((()=>{e.dispatch("ScrollContent")})),o=tc(h.element,"scroll",t.throttle);e.on("remove",o.unbind)}_w(e,t),e.addCommand("ToggleSidebar",((t,o)=>{RB.toggleSidebar(l,o),e.dispatch("ToggleSidebar")})),e.addQueryValueHandler("ToggleSidebar",(()=>{var e;return null!==(e=RB.whichSidebar(l))&&void 0!==e?e:""})),e.addCommand("ToggleView",((t,o)=>{if(RB.toggleView(l,o)){const t=l.element;i.mothership.broadcastOn([Yd()],{target:t}),z(s,(e=>{e.broadcastOn([Yd()],{target:t})})),c(RB.whichView(l))&&(e.focus(),e.nodeChanged(),RB.refreshToolbar(l))}})),e.addQueryValueHandler("ToggleView",(()=>{var e;return null!==(e=RB.whichView(l))&&void 0!==e?e:""}));const m=kv(e);m!==rv.sliding&&m!==rv.floating||e.on("ResizeWindow ResizeEditor ResizeContent",(()=>{const o=e.getWin().innerWidth;o!==a.get()&&(RB.refreshToolbar(t.mainUi.outerContainer),a.set(o))}));const p={setEnabled:e=>{ww(t,!e)},isEnabled:()=>!Dh.isDisabled(l)};return{iframeContainer:h.element.dom,editorContainer:l.element.dom,api:p}}});const DN=e=>/^[0-9\.]+(|px)$/i.test(""+e)?M.some(parseInt(""+e,10)):M.none(),PN=e=>g(e)?e+"px":e,IN=(e,t,o)=>{const n=t.filter((t=>ee>t));return n.or(r).getOr(e)},FN=e=>{const t=pv(e),o=gv(e),n=vv(e);return DN(t).map((e=>IN(e,o,n)))},{ToolbarLocation:LN,ToolbarMode:zN}=db,HN=(e,t,o,n,r)=>{const{mainUi:i,uiMotherships:s}=o,a=sv.DOM,l=rb(e),c=ab(e),d=vv(e).or(FN(e)),u=n.shared.header,h=u.isPositionedAtTop,m=kv(e),p=m===zN.sliding||m===zN.floating,g=Or(!1),f=()=>g.get()&&!e.removed,v=e=>p?e.fold(w(0),(e=>e.components().length>1?jt(e.components()[1].element):0)):0,b=()=>{z(s,(e=>{e.broadcastOn([Kd()],{})}))},y=o=>{if(!f())return;l||r.on((e=>{const o=d.getOrThunk((()=>{const e=DN(Vt(wt(),"margin-left")).getOr(0);return Xt(wt())-Gt(t).left+e}));Bt(e.element,"max-width",o+"px")}));const n=l?M.none():(()=>{if(l)return M.none();if(Gt(i.outerContainer.element).left+Jt(i.outerContainer.element)>=window.innerWidth-40||Pt(i.outerContainer.element,"width").isSome()){Bt(i.outerContainer.element,"position","absolute"),Bt(i.outerContainer.element,"left","0px"),Lt(i.outerContainer.element,"width");const e=Jt(i.outerContainer.element);return M.some(e)}return M.none()})();p&&RB.refreshToolbar(i.outerContainer),l||(o=>{r.on((n=>{const r=RB.getToolbar(i.outerContainer),s=v(r),a=Xo(t),{top:l,left:c}=((e,t)=>lb(e)?wM(t):M.none())(e,i.outerContainer.element).fold((()=>({top:h()?Math.max(a.y-jt(n.element)+s,0):a.bottom,left:a.x})),(e=>{var t;const o=Xo(e),r=null!==(t=e.dom.scrollTop)&&void 0!==t?t:0,i=Je(e,wt()),l=i?Math.max(a.y-jt(n.element)+s,0):a.y-o.y+r-jt(n.element)+s;return{top:h()?l:a.bottom,left:i?a.x:a.x-o.x}})),d={position:"absolute",left:Math.round(c)+"px",top:Math.round(l)+"px"},u=o.map((e=>{const t=Zo(),o=window.innerWidth-(c-t.left);return{width:Math.max(Math.min(e,o),150)+"px"}})).getOr({});Nt(i.outerContainer.element,{...d,...u})}))})(n),c&&r.on(o),b()},_=()=>!(l||!c||!f())&&r.get().exists((o=>{const n=u.getDockingMode(),s=(o=>{switch(Tv(e)){case LN.auto:const e=RB.getToolbar(i.outerContainer),n=v(e),r=jt(o.element)-n,s=Xo(t);if(s.y>r)return"top";{const e=ot(t),o=Math.max(e.dom.scrollHeight,jt(e));return s.bottom{WM.setModes(e,[a]),u.setDockingMode(a);const t=h()?bc.TopToBottom:bc.BottomToTop;Ct(e.element,yc,t)})),!0);var a}));return{isVisible:f,isPositionedAtTop:h,show:()=>{g.set(!0),Bt(i.outerContainer.element,"display","flex"),a.addClass(e.getBody(),"mce-edit-focus"),z(s,(e=>{Lt(e.element,"display")})),_(),lb(e)?y((e=>WM.isDocked(e)?WM.reset(e):WM.refresh(e))):y(WM.refresh)},hide:()=>{g.set(!1),Bt(i.outerContainer.element,"display","none"),a.removeClass(e.getBody(),"mce-edit-focus"),z(s,(e=>{Bt(e.element,"display","none")}))},update:y,updateMode:()=>{_()&&y(WM.reset)},repositionPopups:b}},ZN=(e,t)=>{const o=Xo(e);return{pos:t?o.y:o.bottom,bounds:o}};var jN=Object.freeze({__proto__:null,render:(e,t,o,n,r)=>{const{mainUi:i}=t,s=Ql(),a=Ie(r.targetNode),l=HN(e,a,t,n,s),c=Mv(e);jB(e);const d=()=>{if(s.isSet())return void l.show();s.set(RB.getHeader(i.outerContainer).getOrDie());const r=ib(e);lb(e)?(Dd(a,i.mothership),Dd(a,t.popupUi.mothership)):Vd(r,i.mothership),Vd(r,t.dialogUi.mothership),BN(e,t,o,n),RB.setMenubar(i.outerContainer,PB(e,o)),l.show(),((e,t,o,n)=>{const r=Or(ZN(t,o.isPositionedAtTop())),i=n=>{const{pos:i,bounds:s}=ZN(t,o.isPositionedAtTop()),{pos:a,bounds:l}=r.get(),c=s.height!==l.height||s.width!==l.width;r.set({pos:i,bounds:s}),c&&m_(e,n),o.isVisible()&&(a!==i?o.update(WM.reset):c&&(o.updateMode(),o.repositionPopups()))};n||(e.on("activate",o.show),e.on("deactivate",o.hide)),e.on("SkinLoaded ResizeWindow",(()=>o.update(WM.reset))),e.on("NodeChange keydown",(e=>{requestAnimationFrame((()=>i(e)))}));let s=0;const a=HS((()=>o.update(WM.refresh)),33);e.on("ScrollWindow",(()=>{const e=Zo().left;e!==s&&(s=e,a.throttle()),o.updateMode()})),lb(e)&&e.on("ElementScroll",(e=>{o.update(WM.refresh)}));const l=Jl();l.set(oc(Ie(e.getBody()),"load",(e=>i(e.raw)))),e.on("remove",(()=>{l.clear()}))})(e,a,l,c),e.nodeChanged()};e.on("show",d),e.on("hide",l.hide),c||(e.on("focus",d),e.on("blur",l.hide)),e.on("init",(()=>{(e.hasFocus()||c)&&d()})),_w(e,t);const u={show:d,hide:l.hide,setEnabled:e=>{ww(t,!e)},isEnabled:()=>!Dh.isDisabled(i.outerContainer)};return{editorContainer:i.outerContainer.element.dom,api:u}}});const UN="contexttoolbar-hide",$N=(e,t)=>Zi(dT,((o,n)=>{const r=(e=>({hide:()=>Ri(e,gi()),getValue:()=>pu.getValue(e)}))(e.get(o));t.onAction(r,n.event.buttonApi)})),WN=(e,t)=>{const o=e.label.fold((()=>({})),(e=>({"aria-label":e}))),n=$g(Ib.sketch({inputClasses:["tox-toolbar-textfield","tox-toolbar-nav-js"],data:e.initValue(),inputAttributes:o,selectOnFocus:!0,inputBehaviours:Cl([Hp.config({mode:"special",onEnter:e=>r.findPrimary(e).map((e=>(Di(e),!0))),onLeft:(e,t)=>(t.cut(),M.none()),onRight:(e,t)=>(t.cut(),M.none())})])})),r=((e,t,o)=>{const n=L(t,(t=>$g(((e,t,o)=>(e=>"contextformtogglebutton"===e.type)(t)?((e,t,o)=>{const{primary:n,...r}=t.original,i=Gn(Py({...r,type:"togglebutton",onAction:v}));return kN(i,o,[$N(e,t)])})(e,t,o):((e,t,o)=>{const{primary:n,...r}=t.original,i=Gn(Ry({...r,type:"button",onAction:v}));return CN(i,o,[$N(e,t)])})(e,t,o))(e,t,o))));return{asSpecs:()=>L(n,(e=>e.asSpec())),findPrimary:e=>ie(t,((t,o)=>t.primary?M.from(n[o]).bind((t=>t.getOpt(e))).filter(k(Dh.isDisabled)):M.none()))}})(n,e.commands,t);return[{title:M.none(),items:[n.asSpec()]},{title:M.none(),items:r.asSpecs()}]},qN=(e,t,o)=>t.bottom-e.y>=o&&e.bottom-t.y>=o,GN=e=>{const t=(e=>{const t=e.getBoundingClientRect();if(t.height<=0&&t.width<=0){const o=ut(Ie(e.startContainer),e.startOffset).element;return(We(o)?rt(o):M.some(o)).filter($e).map((e=>e.dom.getBoundingClientRect())).getOr(t)}return t})(e.selection.getRng());if(e.inline){const e=Zo();return Ko(e.left+t.left,e.top+t.top,t.width,t.height)}{const o=Jo(Ie(e.getBody()));return Ko(o.x+t.left,o.y+t.top,t.width,t.height)}},YN=(e,t,o,n=0)=>{const r=$o(window),i=Xo(Ie(e.getContentAreaContainer())),s=Kv(e)||Qv(e)||tb(e),{x:a,width:l}=((e,t,o)=>{const n=Math.max(e.x+o,t.x);return{x:n,width:Math.min(e.right-o,t.right)-n}})(i,r,n);if(e.inline&&!s)return Ko(a,r.y,l,r.height);{const s=t.header.isPositionedAtTop(),{y:c,bottom:d}=((e,t,o,n,r,i)=>{const s=Ie(e.getContainer()),a=pa(s,".tox-editor-header").getOr(s),l=Xo(a),c=l.y>=t.bottom,d=n&&!c;if(e.inline&&d)return{y:Math.max(l.bottom+i,o.y),bottom:o.bottom};if(e.inline&&!d)return{y:o.y,bottom:Math.min(l.y-i,o.bottom)};const u="line"===r?Xo(s):t;return d?{y:Math.max(l.bottom+i,o.y),bottom:Math.min(u.bottom-i,o.bottom)}:{y:Math.max(u.y+i,o.y),bottom:Math.min(l.y-i,o.bottom)}})(e,i,r,s,o,n);return Ko(a,c,l,d-c)}},KN={valignCentre:[],alignCentre:[],alignLeft:["tox-pop--align-left"],alignRight:["tox-pop--align-right"],right:["tox-pop--right"],left:["tox-pop--left"],bottom:["tox-pop--bottom"],top:["tox-pop--top"],inset:["tox-pop--inset"]},XN={maxHeightFunction:cc(),maxWidthFunction:PA()},JN=e=>"node"===e,QN=(e,t,o,n,r)=>{const i=GN(e),s=n.lastElement().exists((e=>Je(o,e)));return((e,t)=>{const o=e.selection.getRng(),n=ut(Ie(o.startContainer),o.startOffset);return o.startContainer===o.endContainer&&o.startOffset===o.endOffset-1&&Je(n.element,t)})(e,o)?s?mO:lO:s?((e,o,r)=>{const s=Pt(e,"position");Bt(e,"position",o);const a=qN(i,Xo(t),-20)&&!n.isReposition()?gO:mO;return s.each((t=>Bt(e,"position",t))),a})(t,n.getMode()):("fixed"===n.getMode()?r.y+Zo().top:r.y)+(jt(t)+12)<=i.y?lO:cO},eR=(e,t,o,n)=>{const r=t=>(n,r,i,s,a)=>({...QN(e,s,t,o,a)({...n,y:a.y,height:a.height},r,i,s,a),alwaysFit:!0}),i=e=>JN(n)?[r(e)]:[];return t?{onLtr:e=>[cl,rl,il,sl,al,ll].concat(i(e)),onRtl:e=>[cl,il,rl,al,sl,ll].concat(i(e))}:{onLtr:e=>[ll,cl,sl,rl,al,il].concat(i(e)),onRtl:e=>[ll,cl,al,il,sl,rl].concat(i(e))}},tR=(e,t)=>{const o=Z(t,(t=>t.predicate(e.dom))),{pass:n,fail:r}=H(o,(e=>"contexttoolbar"===e.type));return{contextToolbars:n,contextForms:r}},oR=(e,t)=>{const o={},n=[],r=[],i={},s={},a=se(e);return z(a,(a=>{const l=e[a];"contextform"===l.type?((e,a)=>{const l=Gn(qn("ContextForm",jy,a));o[e]=l,l.launch.map((o=>{i["form:"+e]={...a.launch,type:"contextformtogglebutton"===o.type?"togglebutton":"button",onAction:()=>{t(l)}}})),"editor"===l.scope?r.push(l):n.push(l),s[e]=l})(a,l):"contexttoolbar"===l.type&&((e,t)=>{var o;(o=t,qn("ContextToolbar",Uy,o)).each((o=>{"editor"===t.scope?r.push(o):n.push(o),s[e]=o}))})(a,l)})),{forms:o,inNodeScope:n,inEditorScope:r,lookupTable:s,formNavigators:i}},nR=ls("forward-slide"),rR=ls("backward-slide"),iR=ls("change-slide-event"),sR="tox-pop--resizing",aR="tox-pop--transition",lR=(e,t,o,n)=>{const r=n.backstage,i=r.shared,s=Bo().deviceType.isTouch,a=Ql(),l=Ql(),c=Ql(),d=ia((e=>{const t=Or([]);return Hg.sketch({dom:{tag:"div",classes:["tox-pop"]},fireDismissalEventInstead:{event:"doNotDismissYet"},onShow:e=>{t.set([]),Hg.getContent(e).each((e=>{Lt(e.element,"visibility")})),Hs(e.element,sR),Lt(e.element,"width")},inlineBehaviours:Cl([Xp("context-toolbar-events",[Yi(oi(),((e,t)=>{"width"===t.event.raw.propertyName&&(Hs(e.element,sR),Lt(e.element,"width"))})),Zi(iR,((e,t)=>{const o=e.element;Lt(o,"width");const n=Xt(o);Hg.setContent(e,t.event.contents),zs(o,sR);const r=Xt(o);Bt(o,"width",n+"px"),Hg.getContent(e).each((e=>{t.event.focus.bind((e=>(Bl(e),Dl(o)))).orThunk((()=>(Hp.focusIn(e),Vl(gt(o)))))})),setTimeout((()=>{Bt(e.element,"width",r+"px")}),0)})),Zi(nR,((e,o)=>{Hg.getContent(e).each((o=>{t.set(t.get().concat([{bar:o,focus:Vl(gt(e.element))}]))})),Vi(e,iR,{contents:o.event.forwardContents,focus:M.none()})})),Zi(rR,((e,o)=>{ne(t.get()).each((o=>{t.set(t.get().slice(0,t.get().length-1)),Vi(e,iR,{contents:sa(o.bar),focus:o.focus})}))}))]),Hp.config({mode:"special",onEscape:o=>ne(t.get()).fold((()=>e.onEscape()),(e=>(Ri(o,rR),M.some(!0))))})]),lazySink:()=>rn.value(e.sink)})})({sink:o,onEscape:()=>(e.focus(),M.some(!0))})),u=()=>{const t=c.get().getOr("node"),o=JN(t)?1:0;return YN(e,i,t,o)},h=()=>!(e.removed||s()&&r.isContextMenuOpen()),m=()=>{if(h()){const t=u(),o=we(c.get(),"node")?((e,t)=>t.filter((e=>yt(e)&&Ue(e))).map(Jo).getOrThunk((()=>GN(e))))(e,a.get()):GN(e);return t.height<=0||!qN(o,t,.01)}return!0},p=()=>{a.clear(),l.clear(),c.clear(),Hg.hide(d)},g=()=>{if(Hg.isOpen(d)){const e=d.element;Lt(e,"display"),m()?Bt(e,"display","none"):(l.set(0),Hg.reposition(d))}},f=t=>({dom:{tag:"div",classes:["tox-pop__dialog"]},components:[t],behaviours:Cl([Hp.config({mode:"acyclic"}),Xp("pop-dialog-wrap-events",[Ki((t=>{e.shortcuts.add("ctrl+F9","focus statusbar",(()=>Hp.focusIn(t)))})),Xi((t=>{e.shortcuts.remove("ctrl+F9")}))])])}),b=Qt((()=>oR(t,(e=>{const t=y([e]);Vi(d,nR,{forwardContents:f(t)})})))),y=t=>{const{buttons:o}=e.ui.registry.getAll(),r={...o,...b().formNavigators},s=kv(e)===rv.scrolling?rv.scrolling:rv.default,a=q(L(t,(t=>"contexttoolbar"===t.type?((t,o)=>AN(e,{buttons:t,toolbar:o.items,allowToolbarGroups:!1},n.backstage,M.some(["form:"])))(r,t):((e,t)=>WN(e,t))(t,i.providers))));return aB({type:s,uid:ls("context-toolbar"),initGroups:a,onEscape:M.none,cyclicKeying:!0,providers:i.providers})},w=(t,n)=>{if(x.cancel(),!h())return;const r=y(t),p=t[0].position,g=((t,n)=>{const r="node"===t?i.anchors.node(n):i.anchors.cursor(),c=((e,t,o,n)=>"line"===t?{bubble:mc(12,0,KN),layouts:{onLtr:()=>[dl],onRtl:()=>[ul]},overrides:XN}:{bubble:mc(0,12,KN,1/12),layouts:eR(e,o,n,t),overrides:XN})(e,t,s(),{lastElement:a.get,isReposition:()=>we(l.get(),0),getMode:()=>xd.getMode(o)});return fn(r,c)})(p,n);c.set(p),l.set(1);const v=d.element;Lt(v,"display"),(e=>we(xe(e,a.get(),Je),!0))(n)||(Hs(v,aR),xd.reset(o,d)),Hg.showWithinBounds(d,f(r),{anchor:g,transition:{classes:[aR],mode:"placement"}},(()=>M.some(u()))),n.fold(a.clear,a.set),m()&&Bt(v,"display","none")};let _=!1;const x=HS((()=>{!e.hasFocus()||e.removed||_||(Zs(d.element,aR)?x.throttle():((e,t)=>{const o=Ie(t.getBody()),n=e=>Je(e,o),r=Ie(t.selection.getNode());return(e=>!n(e)&&!Qe(o,e))(r)?M.none():((e,t,o)=>{const n=tR(e,t);if(n.contextForms.length>0)return M.some({elem:e,toolbars:[n.contextForms[0]]});{const t=tR(e,o);if(t.contextForms.length>0)return M.some({elem:e,toolbars:[t.contextForms[0]]});if(n.contextToolbars.length>0||t.contextToolbars.length>0){const o=(e=>{if(e.length<=1)return e;{const t=t=>P(e,(e=>e.position===t)),o=t=>Z(e,(e=>e.position===t)),n=t("selection"),r=t("node");if(n||r){if(r&&n){const e=o("node"),t=L(o("selection"),(e=>({...e,position:"node"})));return e.concat(t)}return o(n?"selection":"node")}return o("line")}})(n.contextToolbars.concat(t.contextToolbars));return M.some({elem:e,toolbars:o})}return M.none()}})(r,e.inNodeScope,e.inEditorScope).orThunk((()=>((e,t,o)=>e(t)?M.none():Rr(t,(e=>{if($e(e)){const{contextToolbars:t,contextForms:n}=tR(e,o.inNodeScope),r=n.length>0?n:(e=>{if(e.length<=1)return e;{const t=t=>$(e,(e=>e.position===t));return t("selection").orThunk((()=>t("node"))).orThunk((()=>t("line"))).map((e=>e.position)).fold((()=>[]),(t=>Z(e,(e=>e.position===t))))}})(t);return r.length>0?M.some({elem:e,toolbars:r}):M.none()}return M.none()}),e))(n,r,e)))})(b(),e).fold(p,(e=>{w(e.toolbars,M.some(e.elem))})))}),17);e.on("init",(()=>{e.on("remove",p),e.on("ScrollContent ScrollWindow ObjectResized ResizeEditor longpress",g),e.on("click keyup focus SetContent",x.throttle),e.on(UN,p),e.on("contexttoolbar-show",(t=>{const o=b();ve(o.lookupTable,t.toolbarKey).each((o=>{w([o],ke(t.target!==e,t.target)),Hg.getContent(d).each(Hp.focusIn)}))})),e.on("focusout",(t=>{Zg.setEditorTimeout(e,(()=>{Dl(o.element).isNone()&&Dl(d.element).isNone()&&p()}),0)})),e.on("SwitchMode",(()=>{e.mode.isReadOnly()&&p()})),e.on("AfterProgressState",(t=>{t.state?p():e.hasFocus()&&x.throttle()})),e.on("dragstart",(()=>{_=!0})),e.on("dragend drop",(()=>{_=!1})),e.on("NodeChange",(e=>{Dl(d.element).fold(x.throttle,v)}))}))},cR=(e,t)=>{const o=()=>{const o=t.getOptions(e),n=t.getCurrent(e).map(t.hash),r=Ql();return L(o,(o=>({type:"togglemenuitem",text:t.display(o),onSetup:i=>{const s=e=>{e&&(r.on((e=>e.setActive(!1))),r.set(i)),i.setActive(e)};s(we(n,t.hash(o)));const a=t.watcher(e,o,s);return()=>{r.clear(),a()}},onAction:()=>t.setCurrent(e,o)})))};e.ui.registry.addMenuButton(t.name,{tooltip:t.text,icon:t.icon,fetch:e=>e(o()),onSetup:t.onToolbarSetup}),e.ui.registry.addNestedMenuItem(t.name,{type:"nestedmenuitem",text:t.text,getSubmenuItems:o,onSetup:t.onMenuSetup})},dR=e=>{cR(e,(e=>({name:"lineheight",text:"Line height",icon:"line-height",getOptions:Jv,hash:e=>((e,t)=>rN(e,["fixed","relative","empty"]).map((({value:e,unit:t})=>e+t)))(e).getOr(e),display:_,watcher:(e,t,o)=>e.formatter.formatChanged("lineheight",o,!1,{value:t}).unbind,getCurrent:e=>M.from(e.queryCommandValue("LineHeight")),setCurrent:(e,t)=>e.execCommand("LineHeight",!1,t),onToolbarSetup:v_(e),onMenuSetup:v_(e)}))(e)),(e=>M.from(xv(e)).map((t=>({name:"language",text:"Language",icon:"language",getOptions:w(t),hash:e=>u(e.customCode)?e.code:`${e.code}/${e.customCode}`,display:e=>e.title,watcher:(e,t,o)=>{var n;return e.formatter.formatChanged("lang",o,!1,{value:t.code,customValue:null!==(n=t.customCode)&&void 0!==n?n:null}).unbind},getCurrent:e=>{const t=Ie(e.selection.getNode());return Vr(t,(e=>M.some(e).filter($e).bind((e=>Tt(e,"lang").map((t=>({code:t,customCode:Tt(e,"data-mce-lang").getOrUndefined(),title:""})))))))},setCurrent:(e,t)=>e.execCommand("Lang",!1,t),onToolbarSetup:t=>{const o=Jl();return t.setActive(e.formatter.match("lang",{},void 0,!0)),o.set(e.formatter.formatChanged("lang",t.setActive,!0)),f_(o.clear,v_(e)(t))},onMenuSetup:v_(e)}))))(e).each((t=>cR(e,t)))},uR=e=>y_(e,"NodeChange",(t=>{t.setEnabled(e.queryCommandState("outdent")&&e.selection.isEditable())})),hR=(e,t)=>o=>{o.setActive(t.get());const n=e=>{t.set(e.state),o.setActive(e.state)};return e.on("PastePlainTextToggle",n),f_((()=>e.off("PastePlainTextToggle",n)),v_(e)(o))},mR=(e,t)=>()=>{e.execCommand("mceToggleFormat",!1,t)},pR=e=>{(e=>{(e=>{zS.each([{name:"bold",text:"Bold",icon:"bold"},{name:"italic",text:"Italic",icon:"italic"},{name:"underline",text:"Underline",icon:"underline"},{name:"strikethrough",text:"Strikethrough",icon:"strike-through"},{name:"subscript",text:"Subscript",icon:"subscript"},{name:"superscript",text:"Superscript",icon:"superscript"}],((t,o)=>{e.ui.registry.addToggleButton(t.name,{tooltip:t.text,icon:t.icon,onSetup:b_(e,t.name),onAction:mR(e,t.name)})}));for(let t=1;t<=6;t++){const o="h"+t;e.ui.registry.addToggleButton(o,{text:o.toUpperCase(),tooltip:"Heading "+t,onSetup:b_(e,o),onAction:mR(e,o)})}})(e),(e=>{zS.each([{name:"copy",text:"Copy",action:"Copy",icon:"copy"},{name:"help",text:"Help",action:"mceHelp",icon:"help"},{name:"selectall",text:"Select all",action:"SelectAll",icon:"select-all"},{name:"newdocument",text:"New document",action:"mceNewDocument",icon:"new-document"},{name:"print",text:"Print",action:"mcePrint",icon:"print"}],(t=>{e.ui.registry.addButton(t.name,{tooltip:t.text,icon:t.icon,onAction:__(e,t.action)})})),zS.each([{name:"cut",text:"Cut",action:"Cut",icon:"cut"},{name:"paste",text:"Paste",action:"Paste",icon:"paste"},{name:"removeformat",text:"Clear formatting",action:"RemoveFormat",icon:"remove-formatting"},{name:"remove",text:"Remove",action:"Delete",icon:"remove"},{name:"hr",text:"Horizontal line",action:"InsertHorizontalRule",icon:"horizontal-rule"}],(t=>{e.ui.registry.addButton(t.name,{tooltip:t.text,icon:t.icon,onSetup:v_(e),onAction:__(e,t.action)})}))})(e),(e=>{zS.each([{name:"blockquote",text:"Blockquote",action:"mceBlockQuote",icon:"quote"}],(t=>{e.ui.registry.addToggleButton(t.name,{tooltip:t.text,icon:t.icon,onAction:__(e,t.action),onSetup:b_(e,t.name)})}))})(e)})(e),(e=>{zS.each([{name:"newdocument",text:"New document",action:"mceNewDocument",icon:"new-document"},{name:"copy",text:"Copy",action:"Copy",icon:"copy",shortcut:"Meta+C"},{name:"selectall",text:"Select all",action:"SelectAll",icon:"select-all",shortcut:"Meta+A"},{name:"print",text:"Print...",action:"mcePrint",icon:"print",shortcut:"Meta+P"}],(t=>{e.ui.registry.addMenuItem(t.name,{text:t.text,icon:t.icon,shortcut:t.shortcut,onAction:__(e,t.action)})})),zS.each([{name:"bold",text:"Bold",action:"Bold",icon:"bold",shortcut:"Meta+B"},{name:"italic",text:"Italic",action:"Italic",icon:"italic",shortcut:"Meta+I"},{name:"underline",text:"Underline",action:"Underline",icon:"underline",shortcut:"Meta+U"},{name:"strikethrough",text:"Strikethrough",action:"Strikethrough",icon:"strike-through"},{name:"subscript",text:"Subscript",action:"Subscript",icon:"subscript"},{name:"superscript",text:"Superscript",action:"Superscript",icon:"superscript"},{name:"removeformat",text:"Clear formatting",action:"RemoveFormat",icon:"remove-formatting"},{name:"cut",text:"Cut",action:"Cut",icon:"cut",shortcut:"Meta+X"},{name:"paste",text:"Paste",action:"Paste",icon:"paste",shortcut:"Meta+V"},{name:"hr",text:"Horizontal line",action:"InsertHorizontalRule",icon:"horizontal-rule"}],(t=>{e.ui.registry.addMenuItem(t.name,{text:t.text,icon:t.icon,shortcut:t.shortcut,onSetup:v_(e),onAction:__(e,t.action)})})),e.ui.registry.addMenuItem("codeformat",{text:"Code",icon:"sourcecode",onSetup:v_(e),onAction:mR(e,"code")})})(e)},gR=(e,t)=>y_(e,"Undo Redo AddUndo TypingUndo ClearUndos SwitchMode",(o=>{o.setEnabled(!e.mode.isReadOnly()&&e.undoManager[t]())})),fR=e=>y_(e,"VisualAid",(t=>{t.setActive(e.hasVisual)})),vR=(e,t)=>{(e=>{z([{name:"alignleft",text:"Align left",cmd:"JustifyLeft",icon:"align-left"},{name:"aligncenter",text:"Align center",cmd:"JustifyCenter",icon:"align-center"},{name:"alignright",text:"Align right",cmd:"JustifyRight",icon:"align-right"},{name:"alignjustify",text:"Justify",cmd:"JustifyFull",icon:"align-justify"}],(t=>{e.ui.registry.addToggleButton(t.name,{tooltip:t.text,icon:t.icon,onAction:__(e,t.cmd),onSetup:b_(e,t.name)})})),e.ui.registry.addButton("alignnone",{tooltip:"No alignment",icon:"align-none",onSetup:v_(e),onAction:__(e,"JustifyNone")})})(e),pR(e),((e,t)=>{((e,t)=>{const o=$B(0,t,KB(e));e.ui.registry.addNestedMenuItem("align",{text:t.shared.providers.translate("Align"),onSetup:v_(e),getSubmenuItems:()=>o.items.validateItems(o.getStyleItems())})})(e,t),((e,t)=>{const o=$B(0,t,tN(e));e.ui.registry.addNestedMenuItem("fontfamily",{text:t.shared.providers.translate("Fonts"),onSetup:v_(e),getSubmenuItems:()=>o.items.validateItems(o.getStyleItems())})})(e,t),((e,t)=>{const o={type:"advanced",...t.styles},n=$B(0,t,uN(e,o));e.ui.registry.addNestedMenuItem("styles",{text:"Formats",onSetup:v_(e),getSubmenuItems:()=>n.items.validateItems(n.getStyleItems())})})(e,t),((e,t)=>{const o=$B(0,t,JB(e));e.ui.registry.addNestedMenuItem("blocks",{text:"Blocks",onSetup:v_(e),getSubmenuItems:()=>o.items.validateItems(o.getStyleItems())})})(e,t),((e,t)=>{const o=$B(0,t,dN(e));e.ui.registry.addNestedMenuItem("fontsize",{text:"Font sizes",onSetup:v_(e),getSubmenuItems:()=>o.items.validateItems(o.getStyleItems())})})(e,t)})(e,t),(e=>{(e=>{e.ui.registry.addMenuItem("undo",{text:"Undo",icon:"undo",shortcut:"Meta+Z",onSetup:gR(e,"hasUndo"),onAction:__(e,"undo")}),e.ui.registry.addMenuItem("redo",{text:"Redo",icon:"redo",shortcut:"Meta+Y",onSetup:gR(e,"hasRedo"),onAction:__(e,"redo")})})(e),(e=>{e.ui.registry.addButton("undo",{tooltip:"Undo",icon:"undo",enabled:!1,onSetup:gR(e,"hasUndo"),onAction:__(e,"undo")}),e.ui.registry.addButton("redo",{tooltip:"Redo",icon:"redo",enabled:!1,onSetup:gR(e,"hasRedo"),onAction:__(e,"redo")})})(e)})(e),(e=>{(e=>{e.addCommand("mceApplyTextcolor",((t,o)=>{((e,t,o)=>{e.undoManager.transact((()=>{e.focus(),e.formatter.apply(t,{value:o}),e.nodeChanged()}))})(e,t,o)})),e.addCommand("mceRemoveTextcolor",(t=>{((e,t)=>{e.undoManager.transact((()=>{e.focus(),e.formatter.remove(t,{value:null},void 0,!0),e.nodeChanged()}))})(e,t)}))})(e);const t=z_(e),o=H_(e),n=Or(t),r=Or(o);Y_(e,"forecolor","forecolor","Text color",n),Y_(e,"backcolor","hilitecolor","Background color",r),K_(e,"forecolor","forecolor","Text color",n),K_(e,"backcolor","hilitecolor","Background color",r)})(e),(e=>{(e=>{e.ui.registry.addButton("visualaid",{tooltip:"Visual aids",text:"Visual aids",onAction:__(e,"mceToggleVisualAid")})})(e),(e=>{e.ui.registry.addToggleMenuItem("visualaid",{text:"Visual aids",onSetup:fR(e),onAction:__(e,"mceToggleVisualAid")})})(e)})(e),(e=>{(e=>{e.ui.registry.addButton("outdent",{tooltip:"Decrease indent",icon:"outdent",onSetup:uR(e),onAction:__(e,"outdent")}),e.ui.registry.addButton("indent",{tooltip:"Increase indent",icon:"indent",onSetup:v_(e),onAction:__(e,"indent")})})(e)})(e),dR(e),(e=>{const t=Or($v(e)),o=()=>e.execCommand("mceTogglePlainTextPaste");e.ui.registry.addToggleButton("pastetext",{active:!1,icon:"paste-text",tooltip:"Paste as text",onAction:o,onSetup:hR(e,t)}),e.ui.registry.addToggleMenuItem("pastetext",{text:"Paste as text",icon:"paste-text",onAction:o,onSetup:hR(e,t)})})(e)},bR=e=>i(e)?e.split(/[ ,]/):e,yR=e=>t=>t.options.get(e),wR=yR("contextmenu_never_use_native"),_R=yR("contextmenu_avoid_overlap"),xR=e=>{const t=e.ui.registry.getAll().contextMenus,o=e.options.get("contextmenu");return e.options.isSet("contextmenu")?o:Z(o,(e=>be(t,e)))},CR=(e,t)=>({type:"makeshift",x:e,y:t}),kR=e=>"longpress"===e.type||0===e.type.indexOf("touch"),SR=(e,t)=>"contextmenu"===t.type||"longpress"===t.type?e.inline?(e=>{if(kR(e)){const t=e.touches[0];return CR(t.pageX,t.pageY)}return CR(e.pageX,e.pageY)})(t):((e,t)=>{const o=sv.DOM.getPos(e);return((e,t,o)=>CR(e.x+t,e.y+o))(t,o.x,o.y)})(e.getContentAreaContainer(),(e=>{if(kR(e)){const t=e.touches[0];return CR(t.clientX,t.clientY)}return CR(e.clientX,e.clientY)})(t)):TR(e),TR=e=>({type:"selection",root:Ie(e.selection.getNode())}),ER=(e,t,o)=>{switch(o){case"node":return(e=>({type:"node",node:M.some(Ie(e.selection.getNode())),root:Ie(e.getBody())}))(e);case"point":return SR(e,t);case"selection":return TR(e)}},OR=(e,t,o,n,r,i)=>{const s=o(),a=ER(e,t,i);kT(s,pb.CLOSE_ON_EXECUTE,n,{isHorizontalMenu:!1,search:M.none()}).map((e=>{t.preventDefault(),Hg.showMenuAt(r,{anchor:a},{menu:{markers:Mb("normal")},data:e})}))},MR={onLtr:()=>[cl,rl,il,sl,al,ll,lO,cO,aO,iO,sO,rO],onRtl:()=>[cl,il,rl,al,sl,ll,lO,cO,sO,rO,aO,iO]},AR={valignCentre:[],alignCentre:[],alignLeft:["tox-pop--align-left"],alignRight:["tox-pop--align-right"],right:["tox-pop--right"],left:["tox-pop--left"],bottom:["tox-pop--bottom"],top:["tox-pop--top"]},BR=(e,t,o,n,r,i)=>{const s=Bo(),a=s.os.isiOS(),l=s.os.isMacOS(),c=s.os.isAndroid(),d=s.deviceType.isTouch(),u=()=>{const s=o();((e,t,o,n,r,i,s)=>{const a=((e,t,o)=>{const n=ER(e,t,o);return{bubble:mc(0,"point"===o?12:0,AR),layouts:MR,overrides:{maxWidthFunction:PA(),maxHeightFunction:cc()},...n}})(e,t,i);kT(o,pb.CLOSE_ON_EXECUTE,n,{isHorizontalMenu:!0,search:M.none()}).map((o=>{t.preventDefault();const l=s?Fg.HighlightMenuAndItem:Fg.HighlightNone;Hg.showMenuWithinBounds(r,{anchor:a},{menu:{markers:Mb("normal"),highlightOnOpen:l},data:o,type:"horizontal"},(()=>M.some(YN(e,n.shared,"node"===i?"node":"selection")))),e.dispatch(UN)}))})(e,t,s,n,r,i,!(c||a||l&&d))};if((l||a)&&"node"!==i){const o=()=>{(e=>{const t=e.selection.getRng(),o=()=>{Zg.setEditorTimeout(e,(()=>{e.selection.setRng(t)}),10),i()};e.once("touchend",o);const n=e=>{e.preventDefault(),e.stopImmediatePropagation()};e.on("mousedown",n,!0);const r=()=>i();e.once("longpresscancel",r);const i=()=>{e.off("touchend",o),e.off("longpresscancel",r),e.off("mousedown",n)}})(e),u()};((e,t)=>{const o=e.selection;if(o.isCollapsed()||t.touches.length<1)return!1;{const n=t.touches[0],r=o.getRng();return Xc(e.getWin(),zc.domRange(r)).exists((e=>e.left<=n.clientX&&e.right>=n.clientX&&e.top<=n.clientY&&e.bottom>=n.clientY))}})(e,t)?o():(e.once("selectionchange",o),e.once("touchend",(()=>e.off("selectionchange",o))))}else u()},NR=e=>i(e)?"|"===e:"separator"===e.type,RR={type:"separator"},VR=e=>{const t=e=>({text:e.text,icon:e.icon,enabled:e.enabled,shortcut:e.shortcut});if(i(e))return e;switch(e.type){case"separator":return RR;case"submenu":return{type:"nestedmenuitem",...t(e),getSubmenuItems:()=>{const t=e.getSubmenuItems();return i(t)?t:L(t,VR)}};default:const o=e;return{type:"menuitem",...t(o),onAction:b(o.onAction)}}},DR=(e,t)=>{if(0===t.length)return e;const o=ne(e).filter((e=>!NR(e))).fold((()=>[]),(e=>[RR]));return e.concat(o).concat(t).concat([RR])},PR=(e,t)=>!(e=>"longpress"===e.type||be(e,"touches"))(t)&&(2!==t.button||t.target===e.getBody()&&""===t.pointerType),IR=(e,t)=>PR(e,t)?e.selection.getStart(!0):t.target,FR=(e,t,o)=>{const n=Bo().deviceType.isTouch,r=ia(Hg.sketch({dom:{tag:"div"},lazySink:t,onEscape:()=>e.focus(),onShow:()=>o.setContextMenuState(!0),onHide:()=>o.setContextMenuState(!1),fireDismissalEventInstead:{},inlineBehaviours:Cl([Xp("dismissContextMenu",[Zi(ki(),((t,o)=>{Gd.close(t),e.focus()}))])])})),s=()=>Hg.hide(r),a=t=>{if(wR(e)&&t.preventDefault(),((e,t)=>t.ctrlKey&&!wR(e))(e,t)||(e=>0===xR(e).length)(e))return;const s=((e,t)=>{const o=_R(e),n=PR(e,t)?"selection":"point";if(Be(o)){const r=IR(e,t);return Wx(Ie(r),o)?"node":n}return n})(e,t);(n()?BR:OR)(e,t,(()=>{const o=IR(e,t),n=e.ui.registry.getAll(),r=xR(e);return((e,t,o)=>{const n=U(t,((t,n)=>ve(e,n.toLowerCase()).map((e=>{const n=e.update(o);if(i(n)&&Be(Ae(n)))return DR(t,n.split(" "));if(l(n)&&n.length>0){const e=L(n,VR);return DR(t,e)}return t})).getOrThunk((()=>t.concat([n])))),[]);return n.length>0&&NR(n[n.length-1])&&n.pop(),n})(n.contextMenus,r,o)}),o,r,s)};e.on("init",(()=>{const t="ResizeEditor ScrollContent ScrollWindow longpresscancel"+(n()?"":" ResizeWindow");e.on(t,s),e.on("longpress contextmenu",a)}))},LR=Mr([{offset:["x","y"]},{absolute:["x","y"]},{fixed:["x","y"]}]),zR=e=>t=>t.translate(-e.left,-e.top),HR=e=>t=>t.translate(e.left,e.top),ZR=e=>(t,o)=>U(e,((e,t)=>t(e)),Wt(t,o)),jR=(e,t,o)=>e.fold(ZR([HR(o),zR(t)]),ZR([zR(t)]),ZR([])),UR=(e,t,o)=>e.fold(ZR([HR(o)]),ZR([]),ZR([HR(t)])),$R=(e,t,o)=>e.fold(ZR([]),ZR([zR(o)]),ZR([HR(t),zR(o)])),WR=(e,t,o)=>{const n=e.fold(((e,t)=>({position:M.some("absolute"),left:M.some(e+"px"),top:M.some(t+"px")})),((e,t)=>({position:M.some("absolute"),left:M.some(e-o.left+"px"),top:M.some(t-o.top+"px")})),((e,t)=>({position:M.some("fixed"),left:M.some(e+"px"),top:M.some(t+"px")})));return{right:M.none(),bottom:M.none(),...n}},qR=(e,t,o,n)=>{const r=(e,r)=>(i,s)=>{const a=e(t,o,n);return r(i.getOr(a.left),s.getOr(a.top))};return e.fold(r($R,GR),r(UR,YR),r(jR,KR))},GR=LR.offset,YR=LR.absolute,KR=LR.fixed,XR=(e,t)=>{const o=St(e,t);return u(o)?NaN:parseInt(o,10)},JR=(e,t,o,n,r,i)=>{const s=((e,t,o,n)=>((e,t)=>{const o=e.element,n=XR(o,t.leftAttr),r=XR(o,t.topAttr);return isNaN(n)||isNaN(r)?M.none():M.some(Wt(n,r))})(e,t).fold((()=>o),(e=>KR(e.left+n.left,e.top+n.top))))(e,t,o,n),a=t.mustSnap?eV(e,t,s,r,i):tV(e,t,s,r,i),l=jR(s,r,i);return((e,t,o)=>{const n=e.element;Ct(n,t.leftAttr,o.left+"px"),Ct(n,t.topAttr,o.top+"px")})(e,t,l),a.fold((()=>({coord:KR(l.left,l.top),extra:M.none()})),(e=>({coord:e.output,extra:e.extra})))},QR=(e,t,o,n)=>ie(e,(e=>{const r=e.sensor,i=((e,t,o,n,r,i)=>{const s=UR(e,r,i),a=UR(t,r,i);return Math.abs(s.left-a.left)<=o&&Math.abs(s.top-a.top)<=n})(t,r,e.range.left,e.range.top,o,n);return i?M.some({output:qR(e.output,t,o,n),extra:e.extra}):M.none()})),eV=(e,t,o,n,r)=>{const i=t.getSnapPoints(e);return QR(i,o,n,r).orThunk((()=>{const e=U(i,((e,t)=>{const i=t.sensor,s=((e,t,o,n,r,i)=>{const s=UR(e,r,i),a=UR(t,r,i),l=Math.abs(s.left-a.left),c=Math.abs(s.top-a.top);return Wt(l,c)})(o,i,t.range.left,t.range.top,n,r);return e.deltas.fold((()=>({deltas:M.some(s),snap:M.some(t)})),(o=>(s.left+s.top)/2<=(o.left+o.top)/2?{deltas:M.some(s),snap:M.some(t)}:e))}),{deltas:M.none(),snap:M.none()});return e.snap.map((e=>({output:qR(e.output,o,n,r),extra:e.extra})))}))},tV=(e,t,o,n,r)=>{const i=t.getSnapPoints(e);return QR(i,o,n,r)};var oV=Object.freeze({__proto__:null,snapTo:(e,t,o,n)=>{const r=t.getTarget(e.element);if(t.repositionTarget){const t=et(e.element),o=Zo(t),i=_M(r),s=((e,t,o)=>({coord:qR(e.output,e.output,t,o),extra:e.extra}))(n,o,i),a=WR(s.coord,0,i);Rt(r,a)}}});const nV="data-initial-z-index",rV=(e,t)=>{e.getSystem().addToGui(t),(e=>{rt(e.element).filter($e).each((t=>{Pt(t,"z-index").each((e=>{Ct(t,nV,e)})),Bt(t,"z-index",Vt(e.element,"z-index"))}))})(t)},iV=e=>{(e=>{rt(e.element).filter($e).each((e=>{Tt(e,nV).fold((()=>Lt(e,"z-index")),(t=>Bt(e,"z-index",t))),Ot(e,nV)}))})(e),e.getSystem().removeFromGui(e)},sV=(e,t,o)=>e.getSystem().build(oC.sketch({dom:{styles:{left:"0px",top:"0px",width:"100%",height:"100%",position:"fixed","z-index":"1000000000000000"},classes:[t]},events:o}));var aV=br("snaps",[or("getSnapPoints"),Ba("onSensor"),or("leftAttr"),or("topAttr"),yr("lazyViewport",en),yr("mustSnap",!1)]);const lV=[yr("useFixed",E),or("blockerClass"),yr("getTarget",_),yr("onDrag",v),yr("repositionTarget",!0),yr("onDrop",v),Sr("getBounds",en),aV],cV=e=>{return(t=Pt(e,"left"),o=Pt(e,"top"),n=Pt(e,"position"),t.isSome()&&o.isSome()&&n.isSome()?M.some(((e,t,o)=>("fixed"===o?KR:GR)(parseInt(e,10),parseInt(t,10)))(t.getOrDie(),o.getOrDie(),n.getOrDie())):M.none()).getOrThunk((()=>{const t=Gt(e);return YR(t.left,t.top)}));var t,o,n},dV=(e,t)=>({bounds:e.getBounds(),height:Ut(t.element),width:Jt(t.element)}),uV=(e,t,o,n,r)=>{const i=o.update(n,r),s=o.getStartData().getOrThunk((()=>dV(t,e)));i.each((o=>{((e,t,o,n)=>{const r=t.getTarget(e.element);if(t.repositionTarget){const i=et(e.element),s=Zo(i),a=_M(r),l=cV(r),c=((e,t,o,n,r,i,s)=>((e,t,o,n,r)=>{const i=r.bounds,s=UR(t,o,n),a=Ya(s.left,i.x,i.x+i.width-r.width),l=Ya(s.top,i.y,i.y+i.height-r.height),c=YR(a,l);return t.fold((()=>{const e=$R(c,o,n);return GR(e.left,e.top)}),w(c),(()=>{const e=jR(c,o,n);return KR(e.left,e.top)}))})(0,t.fold((()=>{const e=(t=o,s=i.left,a=i.top,t.fold(((e,t)=>GR(e+s,t+a)),((e,t)=>YR(e+s,t+a)),((e,t)=>KR(e+s,t+a))));var t,s,a;const l=jR(e,n,r);return KR(l.left,l.top)}),(t=>{const s=JR(e,t,o,i,n,r);return s.extra.each((o=>{t.onSensor(e,o)})),s.coord})),n,r,s))(e,t.snaps,l,s,a,n,o),d=WR(c,0,a);Rt(r,d)}t.onDrag(e,r,n)})(e,t,s,o)}))},hV=(e,t,o,n)=>{t.each(iV),o.snaps.each((t=>{((e,t)=>{((e,t)=>{const o=e.element;Ot(o,t.leftAttr),Ot(o,t.topAttr)})(e,t)})(e,t)}));const r=o.getTarget(e.element);n.reset(),o.onDrop(e,r)},mV=e=>(t,o)=>{const n=e=>{o.setStartData(dV(t,e))};return Li([Zi(wi(),(e=>{o.getStartData().each((()=>n(e)))})),...e(t,o,n)])};var pV=Object.freeze({__proto__:null,getData:e=>M.from(Wt(e.x,e.y)),getDelta:(e,t)=>Wt(t.left-e.left,t.top-e.top)});const gV=(e,t,o)=>[Zi(jr(),((n,r)=>{if(0!==r.event.raw.button)return;r.stop();const i=()=>hV(n,M.some(l),e,t),s=qx(i,200),a={drop:i,delayDrop:s.schedule,forceDrop:i,move:o=>{s.cancel(),uV(n,e,t,pV,o)}},l=sV(n,e.blockerClass,(e=>Li([Zi(jr(),e.forceDrop),Zi(Wr(),e.drop),Zi(Ur(),((t,o)=>{e.move(o.event)})),Zi($r(),e.delayDrop)]))(a));o(n),rV(n,l)}))],fV=[...lV,Da("dragger",{handlers:mV(gV)})];var vV=Object.freeze({__proto__:null,getData:e=>{const t=e.raw.touches;return 1===t.length?(e=>{const t=e[0];return M.some(Wt(t.clientX,t.clientY))})(t):M.none()},getDelta:(e,t)=>Wt(t.left-e.left,t.top-e.top)});const bV=(e,t,o)=>{const n=Ql(),r=o=>{hV(o,n.get(),e,t),n.clear()};return[Zi(Lr(),((i,s)=>{s.stop();const a=()=>r(i),l={drop:a,delayDrop:v,forceDrop:a,move:o=>{uV(i,e,t,vV,o)}},c=sV(i,e.blockerClass,(e=>Li([Zi(Lr(),e.forceDrop),Zi(Hr(),e.drop),Zi(Zr(),e.drop),Zi(zr(),((t,o)=>{e.move(o.event)}))]))(l));n.set(c),o(i),rV(i,c)})),Zi(zr(),((o,n)=>{n.stop(),uV(o,e,t,vV,n.event)})),Zi(Hr(),((e,t)=>{t.stop(),r(e)})),Zi(Zr(),r)]},yV=fV,wV=[...lV,Da("dragger",{handlers:mV(bV)})],_V=[...lV,Da("dragger",{handlers:mV(((e,t,o)=>[...gV(e,t,o),...bV(e,t,o)]))})];var xV=Object.freeze({__proto__:null,mouse:yV,touch:wV,mouseOrTouch:_V}),CV=Object.freeze({__proto__:null,init:()=>{let e=M.none(),t=M.none();const o=w({});return Ts({readState:o,reset:()=>{e=M.none(),t=M.none()},update:(t,o)=>t.getData(o).bind((o=>((t,o)=>{const n=e.map((e=>t.getDelta(e,o)));return e=M.some(o),n})(t,o))),getStartData:()=>t,setStartData:e=>{t=M.some(e)}})}});const kV=El({branchKey:"mode",branches:xV,name:"dragging",active:{events:(e,t)=>e.dragger.handlers(e,t)},extra:{snap:e=>({sensor:e.sensor,range:e.range,output:e.output,extra:M.from(e.extra)})},state:CV,apis:oV}),SV=(e,t,o,n,r,i)=>e.fold((()=>kV.snap({sensor:YR(o-20,n-20),range:Wt(r,i),output:YR(M.some(o),M.some(n)),extra:{td:t}})),(e=>{const r=o-20,i=n-20,s=e.element.dom.getBoundingClientRect();return kV.snap({sensor:YR(r,i),range:Wt(40,40),output:YR(M.some(o-s.width/2),M.some(n-s.height/2)),extra:{td:t}})})),TV=(e,t,o)=>({getSnapPoints:e,leftAttr:"data-drag-left",topAttr:"data-drag-top",onSensor:(e,n)=>{const r=n.td;((e,t)=>e.exists((e=>Je(e,t))))(t.get(),r)||(t.set(r),o(r))},mustSnap:!0}),EV=e=>$g(jg.sketch({dom:{tag:"div",classes:["tox-selector"]},buttonBehaviours:Cl([kV.config({mode:"mouseOrTouch",blockerClass:"blocker",snaps:e}),VC.config({})]),eventOrder:{mousedown:["dragging","alloy.base.behaviour"],touchstart:["dragging","alloy.base.behaviour"]}})),OV=(e,t)=>{const o=Or([]),n=Or([]),r=Or(!1),i=Ql(),s=Ql(),a=e=>{const o=Jo(e);return SV(u.getOpt(t),e,o.x,o.y,o.width,o.height)},l=e=>{const o=Jo(e);return SV(h.getOpt(t),e,o.right,o.bottom,o.width,o.height)},c=TV((()=>L(o.get(),(e=>a(e)))),i,(t=>{s.get().each((o=>{e.dispatch("TableSelectorChange",{start:t,finish:o})}))})),d=TV((()=>L(n.get(),(e=>l(e)))),s,(t=>{i.get().each((o=>{e.dispatch("TableSelectorChange",{start:o,finish:t})}))})),u=EV(c),h=EV(d),m=ia(u.asSpec()),p=ia(h.asSpec()),g=(t,o,n,r)=>{const i=n(o);kV.snapTo(t,i),((t,o,n,i)=>{const s=o.dom.getBoundingClientRect();Lt(t.element,"display");const a=nt(Ie(e.getBody())).dom.innerHeight,l=s[r]<0,c=((e,t)=>e[r]>t)(s,a);(l||c)&&Bt(t.element,"display","none")})(t,o)},f=e=>g(m,e,a,"top"),v=e=>g(p,e,l,"bottom");Bo().deviceType.isTouch()&&(e.on("TableSelectionChange",(e=>{r.get()||(Md(t,m),Md(t,p),r.set(!0)),i.set(e.start),s.set(e.finish),e.otherCells.each((t=>{o.set(t.upOrLeftCells),n.set(t.downOrRightCells),f(e.start),v(e.finish)}))})),e.on("ResizeEditor ResizeWindow ScrollContent",(()=>{i.get().each(f),s.get().each(v)})),e.on("TableSelectionClear",(()=>{r.get()&&(Nd(m),Nd(p),r.set(!1)),i.clear(),s.clear()})))},MV=(e,t,o)=>{var n;const r=null!==(n=t.delimiter)&&void 0!==n?n:"›";return{dom:{tag:"div",classes:["tox-statusbar__path"],attributes:{role:"navigation"}},behaviours:Cl([Hp.config({mode:"flow",selector:"div[role=button]"}),Dh.config({disabled:o.isDisabled}),xw(),cC.config({}),Kp.config({}),Xp("elementPathEvents",[Ki(((t,n)=>{e.shortcuts.add("alt+F11","focus statusbar elementpath",(()=>Hp.focusIn(t))),e.on("NodeChange",(n=>{const i=(t=>{const o=[];let n=t.length;for(;n-- >0;){const i=t[n];if(1===i.nodeType&&"BR"!==(r=i).nodeName&&!r.getAttribute("data-mce-bogus")&&"bookmark"!==r.getAttribute("data-mce-type")){const t=g_(e,i);if(t.isDefaultPrevented()||o.push({name:t.name,element:i}),t.isPropagationStopped())break}}var r;return o})(n.parents),s=i.length>0?U(i,((t,n,i)=>{const s=((t,n,r)=>jg.sketch({dom:{tag:"div",classes:["tox-statusbar__path-item"],attributes:{"data-index":r,"aria-level":r+1}},components:[ta(t)],action:t=>{e.focus(),e.selection.select(n),e.nodeChanged()},buttonBehaviours:Cl([Cw(o.isDisabled),xw()])}))(n.name,n.element,i);return 0===i?t.concat([s]):t.concat([{dom:{tag:"div",classes:["tox-statusbar__path-divider"],attributes:{"aria-hidden":!0}},components:[ta(` ${r} `)]},s])}),[]):[];Kp.set(t,s)}))}))])]),components:[]}};var AV;!function(e){e[e.None=0]="None",e[e.Both=1]="Both",e[e.Vertical=2]="Vertical"}(AV||(AV={}));const BV=(e,t,o)=>{const n=Ie(e.getContainer()),r=((e,t,o,n,r)=>{const i={height:IN(n+t.top,fv(e),bv(e))};return o===AV.Both&&(i.width=IN(r+t.left,gv(e),vv(e))),i})(e,t,o,jt(n),Xt(n));le(r,((e,t)=>{g(e)&&Bt(n,t,PN(e))})),(e=>{e.dispatch("ResizeEditor")})(e)},NV=(e,t,o,n)=>{const r=Wt(20*o,20*n);return BV(e,r,t),M.some(!0)},RV=(e,t)=>{const o=()=>{const o=[],n=Gv(e),r=Zv(e),i=jv(e)||e.hasPlugin("wordcount");return r&&o.push(MV(e,{},t)),n&&o.push((()=>{const e=Vw("Alt+0");return{dom:{tag:"div",classes:["tox-statusbar__help-text"]},components:[ta(Wf.translate(["Press {0} for help",e]))]}})()),i&&o.push((()=>{const o=[];return e.hasPlugin("wordcount")&&o.push(((e,t)=>{const o=(e,o,n)=>Kp.set(e,[ta(t.translate(["{0} "+n,o[n]]))]);return jg.sketch({dom:{tag:"button",classes:["tox-statusbar__wordcount"]},components:[],buttonBehaviours:Cl([Cw(t.isDisabled),xw(),cC.config({}),Kp.config({}),pu.config({store:{mode:"memory",initialValue:{mode:"words",count:{words:0,characters:0}}}}),Xp("wordcount-events",[Qi((e=>{const t=pu.getValue(e),n="words"===t.mode?"characters":"words";pu.setValue(e,{mode:n,count:t.count}),o(e,t.count,n)})),Ki((t=>{e.on("wordCountUpdate",(e=>{const{mode:n}=pu.getValue(t);pu.setValue(t,{mode:n,count:e.wordCount}),o(t,e.wordCount,n)}))}))])]),eventOrder:{[ui()]:["disabling","alloy.base.behaviour","wordcount-events"]}})})(e,t)),jv(e)&&o.push({dom:{tag:"span",classes:["tox-statusbar__branding"]},components:[{dom:{tag:"a",attributes:{href:"https://www.tiny.cloud/powered-by-tiny?utm_campaign=editor_referral&utm_medium=poweredby&utm_source=tinymce&utm_content=v6",rel:"noopener",target:"_blank","aria-label":Wf.translate(["Powered by {0}","Tiny"])},innerHtml:'\n \n \n'.trim()},behaviours:Cl([og.config({})])}]}),{dom:{tag:"div",classes:["tox-statusbar__right-container"]},components:o}})()),o.length>0?[{dom:{tag:"div",classes:["tox-statusbar__text-container",...(()=>{const e="tox-statusbar__text-container--flex-start",t="tox-statusbar__text-container--flex-end";if(n){const o="tox-statusbar__text-container-3-cols";return i||r?i&&!r?[o,t]:[o,e]:[o,"tox-statusbar__text-container--space-around"]}return[i&&!r?t:e]})()]},components:o}]:[]};return{dom:{tag:"div",classes:["tox-statusbar"]},components:(()=>{const n=o(),r=((e,t)=>{const o=(e=>{const t=Uv(e);return!1===t?AV.None:"both"===t?AV.Both:AV.Vertical})(e);if(o===AV.None)return M.none();const n=o===AV.Both?"Press the arrow keys to resize the editor.":"Press the Up and Down arrow keys to resize the editor.";return M.some(tv("resize-handle",{tag:"div",classes:["tox-statusbar__resize-handle"],attributes:{title:t.translate("Resize"),"aria-label":t.translate(n)},behaviours:[kV.config({mode:"mouse",repositionTarget:!1,onDrag:(t,n,r)=>BV(e,r,o),blockerClass:"tox-blocker"}),Hp.config({mode:"special",onLeft:()=>NV(e,o,-1,0),onRight:()=>NV(e,o,1,0),onUp:()=>NV(e,o,0,-1),onDown:()=>NV(e,o,0,1)}),cC.config({}),og.config({})]},t.icons))})(e,t);return n.concat(r.toArray())})()}},VV=(e,t)=>t.get().getOrDie(`UI for ${e} has not been rendered`),DV=(e,t)=>{const o=e.inline,n=o?jN:VN,r=ab(e)?oA:yM,i=(()=>{const e=Ql(),t=Ql(),o=Ql();return{dialogUi:e,popupUi:t,mainUi:o,getUiMotherships:()=>{const o=e.get().map((e=>e.mothership)),n=t.get().map((e=>e.mothership));return o.fold((()=>n.toArray()),(e=>n.fold((()=>[e]),(t=>Je(e.element,t.element)?[e]:[e,t]))))},lazyGetInOuterOrDie:(e,t)=>()=>o.get().bind((e=>t(e.outerContainer))).getOrDie(`Could not find ${e} element in OuterContainer`)}})(),s=Ql(),a=Ql(),l=Ql(),c=Bo().deviceType.isTouch()?["tox-platform-touch"]:[],d=ob(e),u=kv(e),h=$g({dom:{tag:"div",classes:["tox-anchorbar"]}}),m=$g({dom:{tag:"div",classes:["tox-bottom-anchorbar"]}}),p=()=>i.mainUi.get().map((e=>e.outerContainer)).bind(RB.getHeader),g=i.lazyGetInOuterOrDie("anchor bar",h.getOpt),f=i.lazyGetInOuterOrDie("bottom anchor bar",m.getOpt),v=i.lazyGetInOuterOrDie("toolbar",RB.getToolbar),b=i.lazyGetInOuterOrDie("throbber",RB.getThrobber),y=((e,t,o,n)=>{const r=Or(!1),i=(e=>{const t=Or(ob(e)?"bottom":"top");return{isPositionedAtTop:()=>"top"===t.get(),getDockingMode:t.get,setDockingMode:t.set}})(t),s={icons:()=>t.ui.registry.getAll().icons,menuItems:()=>t.ui.registry.getAll().menuItems,translate:Wf.translate,isDisabled:()=>t.mode.isReadOnly()||!t.ui.isEnabled(),getOption:t.options.get},a=iM(t),l=(e=>{const t=t=>()=>e.formatter.match(t),o=t=>()=>{const o=e.formatter.get(t);return void 0!==o?M.some({tag:o.length>0&&(o[0].inline||o[0].block)||"div",styles:e.dom.parseStyle(e.formatter.getCssText(t))}):M.none()},n=Or([]),r=Or([]),i=Or(!1);return e.on("PreInit",(r=>{const i=NO(e),s=VO(e,i,t,o);n.set(s)})),e.on("addStyleModifications",(n=>{const s=VO(e,n.items,t,o);r.set(s),i.set(n.replace)})),{getData:()=>{const e=i.get()?[]:n.get(),t=r.get();return e.concat(t)}}})(t),c=(e=>({colorPicker:CO(e),hasCustomColors:kO(e),getColors:SO(e),getColorCols:TO(e)}))(t),d=(e=>({isDraggableModal:EO(e)}))(t),u={shared:{providers:s,anchors:xO(t,o,n,i.isPositionedAtTop),header:i},urlinput:a,styles:l,colorinput:c,dialog:d,isContextMenuOpen:()=>r.get(),setContextMenuState:e=>r.set(e)},h={...u,shared:{...u.shared,interpreter:e=>KE(e,{},h),getSink:e.popup}},m={...u,shared:{...u.shared,interpreter:e=>KE(e,{},m),getSink:e.dialog}};return{popup:h,dialog:m}})({popup:()=>rn.fromOption(i.popupUi.get().map((e=>e.sink)),"(popup) UI has not been rendered"),dialog:()=>rn.fromOption(i.dialogUi.get().map((e=>e.sink)),"UI has not been rendered")},e,g,f),w=()=>{const t=(()=>{const t={attributes:{[yc]:d?bc.BottomToTop:bc.TopToBottom}},o=RB.parts.menubar({dom:{tag:"div",classes:["tox-menubar"]},backstage:y.popup,onEscape:()=>{e.focus()}}),n=RB.parts.toolbar({dom:{tag:"div",classes:["tox-toolbar"]},getSink:y.popup.shared.getSink,providers:y.popup.shared.providers,onEscape:()=>{e.focus()},onToolbarToggled:t=>{((e,t)=>{e.dispatch("ToggleToolbarDrawer",{state:t})})(e,t)},type:u,lazyToolbar:v,lazyHeader:()=>p().getOrDie("Could not find header element"),...t}),r=RB.parts["multiple-toolbar"]({dom:{tag:"div",classes:["tox-toolbar-overlord"]},providers:y.popup.shared.providers,onEscape:()=>{e.focus()},type:u}),i=tb(e),s=Qv(e),a=Kv(e),l=qv(e),c=RB.parts.promotion({dom:{tag:"div",classes:["tox-promotion"]}}),m=i||s||a,g=l?[c,o]:[o];return RB.parts.header({dom:{tag:"div",classes:["tox-editor-header"].concat(m?[]:["tox-editor-header--empty"]),...t},components:q([a?g:[],i?[r]:s?[n]:[],rb(e)?[]:[h.asSpec()]]),sticky:ab(e),editor:e,sharedBackstage:y.popup.shared})})(),n={dom:{tag:"div",classes:["tox-sidebar-wrap"]},components:[RB.parts.socket({dom:{tag:"div",classes:["tox-edit-area"]}}),RB.parts.sidebar({dom:{tag:"div",classes:["tox-sidebar"]}})]},r=RB.parts.throbber({dom:{tag:"div",classes:["tox-throbber"]},backstage:y.popup}),i=RB.parts.viewWrapper({backstage:y.popup}),a=Hv(e)&&!o?M.some(RV(e,y.popup.shared.providers)):M.none(),l=q([d?[]:[t],o?[]:[n],d?[t]:[]]),g=RB.parts.editorContainer({components:q([l,o?[]:[m.asSpec(),...a.toArray()]])}),f=sb(e),b={role:"application",...Wf.isRtl()?{dir:"rtl"}:{},...f?{"aria-hidden":"true"}:{}},w=ia(RB.sketch({dom:{tag:"div",classes:["tox","tox-tinymce"].concat(o?["tox-tinymce-inline"]:[]).concat(d?["tox-tinymce--toolbar-bottom"]:[]).concat(c),styles:{visibility:"hidden",...f?{opacity:"0",border:"0"}:{}},attributes:b},components:[g,...o?[]:[i],r],behaviours:Cl([xw(),Dh.config({disableClass:"tox-tinymce--disabled"}),Hp.config({mode:"cyclic",selector:".tox-menubar, .tox-toolbar, .tox-toolbar__primary, .tox-toolbar__overflow--open, .tox-sidebar__overflow--open, .tox-statusbar__path, .tox-statusbar__wordcount, .tox-statusbar__branding a, .tox-statusbar__resize-handle"})])})),_=nC(w);return s.set(_),{mothership:_,outerContainer:w}},_=t=>{const o=PN((e=>{const t=(e=>{const t=mv(e),o=fv(e),n=bv(e);return DN(t).map((e=>IN(e,o,n)))})(e);return t.getOr(mv(e))})(e)),n=PN((e=>FN(e).getOr(pv(e)))(e));return e.inline||(Ft("div","width",n)&&Bt(t.element,"width",n),Ft("div","height",o)?Bt(t.element,"height",o):Bt(t.element,"height","400px")),o};return{popups:{backstage:y.popup,getMothership:()=>VV("popups",l)},dialogs:{backstage:y.dialog,getMothership:()=>VV("dialogs",a)},renderUI:()=>{const o=w(),s=(()=>{const t=ib(e),o=Je(wt(),t)&&"grid"===Vt(t,"display"),n={dom:{tag:"div",classes:["tox","tox-silver-sink","tox-tinymce-aux"].concat(c),attributes:{...Wf.isRtl()?{dir:"rtl"}:{}}},behaviours:Cl([xd.config({useFixed:()=>r.isDocked(p)})])},i={dom:{styles:{width:document.body.clientWidth+"px"}},events:Li([Zi(_i(),(e=>{Bt(e.element,"width",document.body.clientWidth+"px")}))])},s=ia(fn(n,o?i:{})),l=nC(s);return a.set(l),{sink:s,mothership:l}})(),d=lb(e)?(()=>{const e={dom:{tag:"div",classes:["tox","tox-silver-sink","tox-silver-popup-sink","tox-tinymce-aux"].concat(c),attributes:{...Wf.isRtl()?{dir:"rtl"}:{}}},behaviours:Cl([xd.config({useFixed:()=>r.isDocked(p),getBounds:()=>t.getPopupSinkBounds()})])},o=ia(e),n=nC(o);return l.set(n),{sink:o,mothership:n}})():(e=>(l.set(e.mothership),e))(s);i.dialogUi.set(s),i.popupUi.set(d),i.mainUi.set(o);return(t=>{const{mainUi:o,popupUi:i,uiMotherships:s}=t;ce(Sv(e),((t,o)=>{e.ui.registry.addGroupToolbarButton(o,t)}));const{buttons:a,menuItems:l,contextToolbars:c,sidebars:d,views:h}=e.ui.registry.getAll(),m=eb(e),g={menuItems:l,menus:cb(e),menubar:Bv(e),toolbar:m.getOrThunk((()=>Nv(e))),allowToolbarGroups:u===rv.floating,buttons:a,sidebar:d,views:h};var f;f=o.outerContainer,e.addShortcut("alt+F9","focus menubar",(()=>{RB.focusMenubar(f)})),e.addShortcut("alt+F10","focus toolbar",(()=>{RB.focusToolbar(f)})),e.addCommand("ToggleToolbarDrawer",((e,t)=>{(null==t?void 0:t.skipFocus)?RB.toggleToolbarDrawerWithoutFocusing(f):RB.toggleToolbarDrawer(f)})),e.addQueryStateHandler("ToggleToolbarDrawer",(()=>RB.isToolbarDrawerToggled(f))),((e,t,o)=>{const n=(e,n)=>{z([t,...o],(t=>{t.broadcastEvent(e,n)}))},r=(e,n)=>{z([t,...o],(t=>{t.broadcastOn([e],n)}))},i=e=>r(Yd(),{target:e.target}),s=Wo(),a=tc(s,"touchstart",i),l=tc(s,"touchmove",(e=>n(bi(),e))),c=tc(s,"touchend",(e=>n(yi(),e))),d=tc(s,"mousedown",i),u=tc(s,"mouseup",(e=>{0===e.raw.button&&r(Xd(),{target:e.target})})),h=e=>r(Yd(),{target:Ie(e.target)}),m=e=>{0===e.button&&r(Xd(),{target:Ie(e.target)})},p=()=>{z(e.editorManager.get(),(t=>{e!==t&&t.dispatch("DismissPopups",{relatedTarget:e})}))},g=e=>n(wi(),nc(e)),f=e=>{r(Kd(),{}),n(_i(),nc(e))},v=gt(Ie(e.getElement())),b=oc(v,"scroll",(o=>{requestAnimationFrame((()=>{if(null!=e.getContainer()){const r=Ux(e,t.element).map((e=>[e.element,...e.others])).getOr([]);P(r,(e=>Je(e,o.target)))&&(e.dispatch("ElementScroll",{target:o.target.dom}),n(Oi(),o))}}))})),y=()=>r(Kd(),{}),w=t=>{t.state&&r(Yd(),{target:Ie(e.getContainer())})},_=e=>{r(Yd(),{target:Ie(e.relatedTarget.getContainer())})};e.on("PostRender",(()=>{e.on("click",h),e.on("tap",h),e.on("mouseup",m),e.on("mousedown",p),e.on("ScrollWindow",g),e.on("ResizeWindow",f),e.on("ResizeEditor",y),e.on("AfterProgressState",w),e.on("DismissPopups",_)})),e.on("remove",(()=>{e.off("click",h),e.off("tap",h),e.off("mouseup",m),e.off("mousedown",p),e.off("ScrollWindow",g),e.off("ResizeWindow",f),e.off("ResizeEditor",y),e.off("AfterProgressState",w),e.off("DismissPopups",_),d.unbind(),a.unbind(),l.unbind(),c.unbind(),u.unbind(),b.unbind()})),e.on("detach",(()=>{z([t,...o],Id),z([t,...o],(e=>e.destroy()))}))})(e,o.mothership,s),r.setup(e,y.popup.shared,p),vR(e,y.popup),FR(e,y.popup.shared.getSink,y.popup),(e=>{const{sidebars:t}=e.ui.registry.getAll();z(se(t),(o=>{const n=t[o],r=()=>we(M.from(e.queryCommandValue("ToggleSidebar")),o);e.ui.registry.addToggleButton(o,{icon:n.icon,tooltip:n.tooltip,onAction:t=>{e.execCommand("ToggleSidebar",!1,o),t.setActive(r())},onSetup:t=>{t.setActive(r());const o=()=>t.setActive(r());return e.on("ToggleSidebar",o),()=>{e.off("ToggleSidebar",o)}}})}))})(e),EA(e,b,y.popup.shared),lR(e,c,i.sink,{backstage:y.popup}),OV(e,i.sink);const v={targetNode:e.getElement(),height:_(o.outerContainer)};return n.render(e,t,g,y.popup,v)})({popupUi:d,dialogUi:s,mainUi:o,uiMotherships:i.getUiMotherships()})}}},PV=w([or("lazySink"),ur("dragBlockClass"),Sr("getBounds",en),yr("useTabstopAt",O),yr("firstTabstop",0),yr("eventOrder",{}),gu("modalBehaviours",[Hp]),Na("onExecute"),Va("onEscape")]),IV={sketch:_},FV=w([Uu({name:"draghandle",overrides:(e,t)=>({behaviours:Cl([kV.config({mode:"mouse",getTarget:e=>ha(e,'[role="dialog"]').getOr(e),blockerClass:e.dragBlockClass.getOrDie(new Error("The drag blocker class was not specified for a dialog with a drag handle: \n"+JSON.stringify(t,null,2)).message),getBounds:e.getDragBounds})])})}),Zu({schema:[or("dom")],name:"title"}),Zu({factory:IV,schema:[or("dom")],name:"close"}),Zu({factory:IV,schema:[or("dom")],name:"body"}),Uu({factory:IV,schema:[or("dom")],name:"footer"}),ju({factory:{sketch:(e,t)=>({...e,dom:t.dom,components:t.components})},schema:[yr("dom",{tag:"div",styles:{position:"fixed",left:"0px",top:"0px",right:"0px",bottom:"0px"}}),yr("components",[])],name:"blocker"})]),LV=vh({name:"ModalDialog",configFields:PV(),partFields:FV(),factory:(e,t,o,n)=>{const r=Ql(),i=ls("modal-events"),s={...e.eventOrder,[xi()]:[i].concat(e.eventOrder["alloy.system.attached"]||[])};return{uid:e.uid,dom:e.dom,components:t,apis:{show:t=>{r.set(t);const o=e.lazySink(t).getOrDie(),i=n.blocker(),s=o.getSystem().build({...i,components:i.components.concat([sa(t)]),behaviours:Cl([og.config({}),Xp("dialog-blocker-events",[Yi(Gr(),(()=>{SA.isBlocked(t)||Hp.focusIn(t)}))])])});Md(o,s),Hp.focusIn(t)},hide:e=>{r.clear(),rt(e.element).each((t=>{e.getSystem().getByDom(t).each((e=>{Nd(e)}))}))},getBody:t=>nh(t,e,"body"),getFooter:t=>oh(t,e,"footer"),setIdle:e=>{SA.unblock(e)},setBusy:(e,t)=>{SA.block(e,t)}},eventOrder:s,domModification:{attributes:{role:"dialog","aria-modal":"true"}},behaviours:vu(e.modalBehaviours,[Kp.config({}),Hp.config({mode:"cyclic",onEnter:e.onExecute,onEscape:e.onEscape,useTabstopAt:e.useTabstopAt,firstTabstop:e.firstTabstop}),SA.config({getRoot:r.get}),Xp(i,[Ki((t=>{((e,t)=>{const o=Tt(e,"id").fold((()=>{const e=ls("dialog-label");return Ct(t,"id",e),e}),_);Ct(e,"aria-labelledby",o)})(t.element,nh(t,e,"title").element)}))])])}},apis:{show:(e,t)=>{e.show(t)},hide:(e,t)=>{e.hide(t)},getBody:(e,t)=>e.getBody(t),getFooter:(e,t)=>e.getFooter(t),setBusy:(e,t,o)=>{e.setBusy(t,o)},setIdle:(e,t)=>{e.setIdle(t)}}}),zV=Bn([ty,oy].concat(Xy)),HV=zn,ZV=[Oy("button"),gy,Cr("align","end",["start","end"]),Cy,xy,gr("buttonType",["primary","secondary"])],jV=[...ZV,ry],UV=[sr("type",["submit","cancel","custom"]),...jV],$V=[sr("type",["menu"]),py,fy,gy,dr("items",zV),...ZV],WV=[...ZV,sr("type",["togglebutton"]),ir("tooltip"),gy,py,kr("active",!1)],qV=Xn("type",{submit:UV,cancel:UV,custom:UV,menu:$V,togglebutton:WV}),GV=[ty,ry,sr("level",["info","warn","error","success"]),sy,yr("url","")],YV=Bn(GV),KV=[ty,ry,xy,Oy("button"),gy,_y,gr("buttonType",["primary","secondary","toolbar"]),Cy],XV=Bn(KV),JV=[ty,oy],QV=JV.concat([vy]),eD=JV.concat([ny,xy]),tD=Bn(eD),oD=zn,nD=QV.concat([ky("auto")]),rD=Bn(nD),iD=Dn([ay,ry,sy]),sD=QV.concat([xr("storageKey","default")]),aD=Bn(sD),lD=Ln,cD=Bn(QV),dD=Ln,uD=JV.concat([xr("tag","textarea"),ir("scriptId"),ir("scriptUrl"),wr("settings",void 0,jn)]),hD=JV.concat([xr("tag","textarea"),ar("init")]),mD=$n((e=>qn("customeditor.old",An(hD),e).orThunk((()=>qn("customeditor.new",An(uD),e))))),pD=Ln,gD=Bn(QV),fD=Nn(Sn),vD=e=>[ty,rr("columns"),e],bD=[ty,ir("html"),Cr("presets","presentation",["presentation","document"])],yD=Bn(bD),wD=QV.concat([kr("border",!1),kr("sandboxed",!0),kr("streamContent",!1),kr("transparent",!0)]),_D=Bn(wD),xD=Ln,CD=Bn(JV.concat([pr("height")])),kD=Bn([ir("url"),mr("zoom"),mr("cachedWidth"),mr("cachedHeight")]),SD=QV.concat([pr("inputMode"),pr("placeholder"),kr("maximized",!1),xy]),TD=Bn(SD),ED=Ln,OD=e=>[ty,ny,e,Cr("align","start",["start","center","end"])],MD=[ry,ay],AD=[ry,dr("items",Jn(0,(()=>BD)))],BD=Rn([Bn(MD),Bn(AD)]),ND=QV.concat([dr("items",BD),xy]),RD=Bn(ND),VD=Ln,DD=QV.concat([cr("items",[ry,ay]),_r("size",1),xy]),PD=Bn(DD),ID=Ln,FD=QV.concat([kr("constrain",!0),xy]),LD=Bn(FD),zD=Bn([ir("width"),ir("height")]),HD=JV.concat([ny,_r("min",0),_r("max",0)]),ZD=Bn(HD),jD=Fn,UD=[ty,dr("header",Ln),dr("cells",Nn(Ln))],$D=Bn(UD),WD=QV.concat([pr("placeholder"),kr("maximized",!1),xy]),qD=Bn(WD),GD=Ln,YD=[sr("type",["directory","leaf"]),iy,ir("id"),hr("menu",iA)],KD=Bn(YD),XD=YD.concat([dr("children",Jn(0,(()=>Un("type",{directory:JD,leaf:KD}))))]),JD=Bn(XD),QD=Un("type",{directory:JD,leaf:KD}),eP=[ty,dr("items",QD),fr("onLeafAction"),fr("onToggleExpand"),Tr("defaultExpandedIds",[],Ln),pr("defaultSelectedId")],tP=Bn(eP),oP=QV.concat([Cr("filetype","file",["image","media","file"]),xy]),nP=Bn(oP),rP=Bn([ay,Sy]),iP=e=>Qn("items","items",{tag:"required",process:{}},Nn($n((t=>qn(`Checking item of ${e}`,sP,t).fold((e=>rn.error(Kn(e))),(e=>rn.value(e))))))),sP=On((()=>{return Un("type",{alertbanner:YV,bar:Bn((e=iP("bar"),[ty,e])),button:XV,checkbox:tD,colorinput:aD,colorpicker:cD,dropzone:gD,grid:Bn(vD(iP("grid"))),iframe:_D,input:TD,listbox:RD,selectbox:PD,sizeinput:LD,slider:ZD,textarea:qD,urlinput:nP,customeditor:mD,htmlpanel:yD,imagepreview:CD,collection:rD,label:Bn(OD(iP("label"))),table:$D,tree:tP,panel:lP});var e})),aP=[ty,yr("classes",[]),dr("items",sP)],lP=Bn(aP),cP=[Oy("tab"),iy,dr("items",sP)],dP=[ty,cr("tabs",cP)],uP=Bn(dP),hP=jV,mP=qV,pP=Bn([ir("title"),nr("body",Un("type",{panel:lP,tabpanel:uP})),xr("size","normal"),Tr("buttons",[],mP),yr("initialData",{}),Sr("onAction",v),Sr("onChange",v),Sr("onSubmit",v),Sr("onClose",v),Sr("onCancel",v),Sr("onTabChange",v)]),gP=Bn([sr("type",["cancel","custom"]),...hP]),fP=Bn([ir("title"),ir("url"),mr("height"),mr("width"),vr("buttons",gP),Sr("onAction",v),Sr("onCancel",v),Sr("onClose",v),Sr("onMessage",v)]),vP=e=>s(e)?[e].concat(G(fe(e),vP)):l(e)?G(e,vP):[],bP=e=>i(e.type)&&i(e.name),yP={checkbox:oD,colorinput:lD,colorpicker:dD,dropzone:fD,input:ED,iframe:xD,imagepreview:kD,selectbox:ID,sizeinput:zD,slider:jD,listbox:VD,size:zD,textarea:GD,urlinput:rP,customeditor:pD,collection:iD,togglemenuitem:HV},wP=e=>{const t=(e=>Z(vP(e),bP))(e),o=G(t,(e=>(e=>M.from(yP[e.type]))(e).fold((()=>[]),(t=>[nr(e.name,t)]))));return Bn(o)},_P=e=>{var t;return{internalDialog:Gn(qn("dialog",pP,e)),dataValidator:wP(e),initialData:null!==(t=e.initialData)&&void 0!==t?t:{}}},xP={open:(e,t)=>{const o=_P(t);return e(o.internalDialog,o.initialData,o.dataValidator)},openUrl:(e,t)=>e(Gn(qn("dialog",fP,t))),redial:e=>_P(e)};var CP=Object.freeze({__proto__:null,events:(e,t)=>{const o=(o,n)=>{e.updateState.each((e=>{const r=e(o,n);t.set(r)})),e.renderComponents.each((r=>{const i=r(n,t.get());(e.reuseDom?jp:Zp)(o,i)}))};return Li([Zi(di(),((t,n)=>{const r=n;if(!r.universal){const n=e.channel;D(r.channels,n)&&o(t,r.data)}})),Ki(((t,n)=>{e.initialData.each((e=>{o(t,e)}))}))])}}),kP=Object.freeze({__proto__:null,getState:(e,t,o)=>o}),SP=[or("channel"),ur("renderComponents"),ur("updateState"),ur("initialData"),kr("reuseDom",!0)];const TP=Sl({fields:SP,name:"reflecting",active:CP,apis:kP,state:Object.freeze({__proto__:null,init:()=>{const e=Or(M.none());return{readState:()=>e.get().getOr("none"),get:e.get,set:e.set,clear:()=>e.set(M.none())}}})}),EP=e=>{const t=[],o={};return le(e,((e,n)=>{e.fold((()=>{t.push(n)}),(e=>{o[n]=e}))})),t.length>0?rn.error(t):rn.value(o)},OP=(e,t,o)=>{const n=$g(kS.sketch((n=>({dom:{tag:"div",classes:["tox-form"].concat(e.classes)},components:L(e.items,(e=>GE(n,e,t,o)))}))));return{dom:{tag:"div",classes:["tox-dialog__body"]},components:[{dom:{tag:"div",classes:["tox-dialog__body-content"]},components:[n.asSpec()]}],behaviours:Cl([Hp.config({mode:"acyclic",useTabstopAt:k(GS)}),(r=n,_h.config({find:r.getOpt})),VS(n,{postprocess:e=>EP(e).fold((e=>(console.error(e),{})),_)}),Xp("dialog-body-panel",[Zi(Gr(),((e,t)=>{e.getSystem().broadcastOn([eT],{newFocus:M.some(t.event.target)})}))])])};var r},MP=fh({name:"TabButton",configFields:[yr("uid",void 0),or("value"),Qn("dom","dom",wn((()=>({attributes:{role:"tab",id:ls("aria"),"aria-selected":"false"}}))),Pn()),ur("action"),yr("domModification",{}),gu("tabButtonBehaviours",[og,Hp,pu]),or("view")],factory:(e,t)=>({uid:e.uid,dom:e.dom,components:e.components,events:hg(e.action),behaviours:vu(e.tabButtonBehaviours,[og.config({}),Hp.config({mode:"execution",useSpace:!0,useEnter:!0}),pu.config({store:{mode:"memory",initialValue:e.value}})]),domModification:e.domModification})}),AP=w([or("tabs"),or("dom"),yr("clickToDismiss",!1),gu("tabbarBehaviours",[$h,Hp]),Ma(["tabClass","selectedClass"])]),BP=$u({factory:MP,name:"tabs",unit:"tab",overrides:e=>{const t=(e,t)=>{$h.dehighlight(e,t),Vi(e,Ai(),{tabbar:e,button:t})},o=(e,t)=>{$h.highlight(e,t),Vi(e,Mi(),{tabbar:e,button:t})};return{action:n=>{const r=n.getSystem().getByUid(e.uid).getOrDie(),i=$h.isHighlighted(r,n);(i&&e.clickToDismiss?t:i?v:o)(r,n)},domModification:{classes:[e.markers.tabClass]}}}}),NP=w([BP]),RP=vh({name:"Tabbar",configFields:AP(),partFields:NP(),factory:(e,t,o,n)=>({uid:e.uid,dom:e.dom,components:t,"debug.sketcher":"Tabbar",domModification:{attributes:{role:"tablist"}},behaviours:vu(e.tabbarBehaviours,[$h.config({highlightClass:e.markers.selectedClass,itemClass:e.markers.tabClass,onHighlight:(e,t)=>{Ct(t.element,"aria-selected","true")},onDehighlight:(e,t)=>{Ct(t.element,"aria-selected","false")}}),Hp.config({mode:"flow",getInitial:e=>$h.getHighlighted(e).map((e=>e.element)),selector:"."+e.markers.tabClass,executeOnMove:!0})])})}),VP=fh({name:"Tabview",configFields:[gu("tabviewBehaviours",[Kp])],factory:(e,t)=>({uid:e.uid,dom:e.dom,behaviours:vu(e.tabviewBehaviours,[Kp.config({})]),domModification:{attributes:{role:"tabpanel"}}})}),DP=w([yr("selectFirst",!0),Ba("onChangeTab"),Ba("onDismissTab"),yr("tabs",[]),gu("tabSectionBehaviours",[])]),PP=Zu({factory:RP,schema:[or("dom"),lr("markers",[or("tabClass"),or("selectedClass")])],name:"tabbar",defaults:e=>({tabs:e.tabs})}),IP=Zu({factory:VP,name:"tabview"}),FP=w([PP,IP]),LP=vh({name:"TabSection",configFields:DP(),partFields:FP(),factory:(e,t,o,n)=>{const r=(t,o)=>{oh(t,e,"tabbar").each((e=>{o(e).each(Di)}))};return{uid:e.uid,dom:e.dom,components:t,behaviours:fu(e.tabSectionBehaviours),events:Li(q([e.selectFirst?[Ki(((e,t)=>{r(e,$h.getFirst)}))]:[],[Zi(Mi(),((t,o)=>{(t=>{const o=pu.getValue(t);oh(t,e,"tabview").each((n=>{$(e.tabs,(e=>e.value===o)).each((o=>{const r=o.view();Tt(t.element,"id").each((e=>{Ct(n.element,"aria-labelledby",e)})),Kp.set(n,r),e.onChangeTab(n,t,r)}))}))})(o.event.button)})),Zi(Ai(),((t,o)=>{const n=o.event.button;e.onDismissTab(t,n)}))]])),apis:{getViewItems:t=>oh(t,e,"tabview").map((e=>Kp.contents(e))).getOr([]),showTab:(e,t)=>{r(e,(e=>{const o=$h.getCandidates(e);return $(o,(e=>pu.getValue(e)===t)).filter((t=>!$h.isHighlighted(e,t)))}))}}}},apis:{getViewItems:(e,t)=>e.getViewItems(t),showTab:(e,t,o)=>{e.showTab(t,o)}}}),zP=(e,t)=>{Bt(e,"height",t+"px"),Bt(e,"flex-basis",t+"px")},HP=(e,t,o)=>{ha(e,'[role="dialog"]').each((e=>{pa(e,'[role="tablist"]').each((n=>{o.get().map((o=>(Bt(t,"height","0"),Bt(t,"flex-basis","0"),Math.min(o,((e,t,o)=>{const n=ot(e).dom,r=ha(e,".tox-dialog-wrap").getOr(e);let i;i="fixed"===Vt(r,"position")?Math.max(n.clientHeight,window.innerHeight):Math.max(n.offsetHeight,n.scrollHeight);const s=jt(t),a=t.dom.offsetLeft>=o.dom.offsetLeft+Xt(o)?Math.max(jt(o),s):s,l=parseInt(Vt(e,"margin-top"),10)||0,c=parseInt(Vt(e,"margin-bottom"),10)||0;return i-(jt(e)+l+c-a)})(e,t,n))))).each((e=>{zP(t,e)}))}))}))},ZP=e=>pa(e,'[role="tabpanel"]'),jP="send-data-to-section",UP="send-data-to-view",$P=(e,t,o)=>{const n=Or({}),r=e=>{const t=pu.getValue(e),o=EP(t).getOr({}),r=n.get(),i=fn(r,o);n.set(i)},i=e=>{const t=n.get();pu.setValue(e,t)},s=Or(null),a=L(e.tabs,(e=>({value:e.name,dom:{tag:"div",classes:["tox-dialog__body-nav-item"]},components:[ta(o.shared.providers.translate(e.title))],view:()=>[kS.sketch((n=>({dom:{tag:"div",classes:["tox-form"]},components:L(e.items,(e=>GE(n,e,t,o))),formBehaviours:Cl([Hp.config({mode:"acyclic",useTabstopAt:k(GS)}),Xp("TabView.form.events",[Ki(i),Xi(r)]),Ml.config({channels:Br([{key:jP,value:{onReceive:r}},{key:UP,value:{onReceive:i}}])})])})))]}))),l=(e=>{const t=Ql(),o=[Ki((o=>{const n=o.element;ZP(n).each((r=>{Bt(r,"visibility","hidden"),o.getSystem().getByDom(r).toOptional().each((o=>{const n=((e,t,o)=>L(e,((n,r)=>{Kp.set(o,e[r].view());const i=t.dom.getBoundingClientRect();return Kp.set(o,[]),i.height})))(e,r,o),i=(e=>oe(ee(e,((e,t)=>e>t?-1:e{oe(e).each((e=>LP.showTab(t,e.value)))})(e,o),requestAnimationFrame((()=>{HP(n,r,t)}))}))})),Zi(_i(),(e=>{const o=e.element;ZP(o).each((e=>{HP(o,e,t)}))})),Zi(CC,((e,o)=>{const n=e.element;ZP(n).each((e=>{const o=Vl(gt(e));Bt(e,"visibility","hidden");const r=Pt(e,"height").map((e=>parseInt(e,10)));Lt(e,"height"),Lt(e,"flex-basis");const i=e.dom.getBoundingClientRect().height;r.forall((e=>i>e))?(t.set(i),HP(n,e,t)):r.each((t=>{zP(e,t)})),Lt(e,"visibility"),o.each(Bl)}))}))];return{extraEvents:o,selectFirst:!1}})(a);return LP.sketch({dom:{tag:"div",classes:["tox-dialog__body"]},onChangeTab:(e,t,o)=>{const n=pu.getValue(t);Vi(e,xC,{name:n,oldName:s.get()}),s.set(n)},tabs:a,components:[LP.parts.tabbar({dom:{tag:"div",classes:["tox-dialog__body-nav"]},components:[RP.parts.tabs({})],markers:{tabClass:"tox-tab",selectedClass:"tox-dialog__body-nav-item--active"},tabbarBehaviours:Cl([cC.config({})])}),LP.parts.tabview({dom:{tag:"div",classes:["tox-dialog__body-content"]}})],selectFirst:l.selectFirst,tabSectionBehaviours:Cl([Xp("tabpanel",l.extraEvents),Hp.config({mode:"acyclic"}),_h.config({find:e=>oe(LP.getViewItems(e))}),DS(M.none(),(e=>(e.getSystem().broadcastOn([jP],{}),n.get())),((e,t)=>{n.set(t),e.getSystem().broadcastOn([UP],{})}))])})},WP=(e,t,o,n,r)=>({dom:{tag:"div",classes:["tox-dialog__content-js"],attributes:{...o.map((e=>({id:e}))).getOr({}),...r?{"aria-live":"polite"}:{}}},components:[],behaviours:Cl([NS(0),TP.config({channel:`${XS}-${t}`,updateState:(e,t)=>M.some({isTabPanel:()=>"tabpanel"===t.body.type}),renderComponents:e=>{const t=e.body;return"tabpanel"===t.type?[$P(t,e.initialData,n)]:[OP(t,e.initialData,n)]},initialData:e})])}),qP=lv.deviceType.isTouch(),GP=(e,t)=>({dom:{tag:"div",styles:{display:"none"},classes:["tox-dialog__header"]},components:[e,t]}),YP=(e,t)=>LV.parts.close(jg.sketch({dom:{tag:"button",classes:["tox-button","tox-button--icon","tox-button--naked"],attributes:{type:"button","aria-label":t.translate("Close")}},action:e,buttonBehaviours:Cl([cC.config({})])})),KP=()=>LV.parts.title({dom:{tag:"div",classes:["tox-dialog__title"],innerHtml:"",styles:{display:"none"}}}),XP=(e,t)=>LV.parts.body({dom:{tag:"div",classes:["tox-dialog__body"]},components:[{dom:{tag:"div",classes:["tox-dialog__body-content"]},components:[{dom:Ug(`${$f(t.translate(e))}
`)}]}]}),JP=e=>LV.parts.footer({dom:{tag:"div",classes:["tox-dialog__footer"]},components:e}),QP=(e,t)=>[oC.sketch({dom:{tag:"div",classes:["tox-dialog__footer-start"]},components:e}),oC.sketch({dom:{tag:"div",classes:["tox-dialog__footer-end"]},components:t})],eI=e=>{const t="tox-dialog",o=t+"-wrap",n=o+"__backdrop",r=t+"__disable-scroll";return LV.sketch({lazySink:e.lazySink,onEscape:t=>(e.onEscape(t),M.some(!0)),useTabstopAt:e=>!GS(e),firstTabstop:e.firstTabstop,dom:{tag:"div",classes:[t].concat(e.extraClasses),styles:{position:"relative",...e.extraStyles}},components:[e.header,e.body,...e.footer.toArray()],parts:{blocker:{dom:Ug(`
`),components:[{dom:{tag:"div",classes:qP?[n,n+"--opaque"]:[n]}}]}},dragBlockClass:o,modalBehaviours:Cl([og.config({}),Xp("dialog-events",e.dialogEvents.concat([Yi(Gr(),((e,t)=>{SA.isBlocked(e)||Hp.focusIn(e)})),Zi(Ti(),((e,t)=>{e.getSystem().broadcastOn([eT],{newFocus:t.event.newFocus})}))])),Xp("scroll-lock",[Ki((()=>{zs(wt(),r)})),Xi((()=>{Hs(wt(),r)}))]),...e.extraBehaviours]),eventOrder:{[ui()]:["dialog-events"],[xi()]:["scroll-lock","dialog-events","alloy.base.behaviour"],[Ci()]:["alloy.base.behaviour","dialog-events","scroll-lock"],...e.eventOrder}})},tI=e=>jg.sketch({dom:{tag:"button",classes:["tox-button","tox-button--icon","tox-button--naked"],attributes:{type:"button","aria-label":e.translate("Close"),title:e.translate("Close")}},buttonBehaviours:Cl([cC.config({})]),components:[tv("close",{tag:"span",classes:["tox-icon"]},e.icons)],action:e=>{Ri(e,vC)}}),oI=(e,t,o,n)=>({dom:{tag:"div",classes:["tox-dialog__title"],attributes:{...o.map((e=>({id:e}))).getOr({})}},components:[],behaviours:Cl([TP.config({channel:`${KS}-${t}`,initialData:e,renderComponents:e=>[ta(n.translate(e.title))]})])}),nI=()=>({dom:Ug('
')}),rI=(e,t,o)=>((e,t,o)=>{const n=LV.parts.title(oI(e,t,M.none(),o)),r=LV.parts.draghandle(nI()),i=LV.parts.close(tI(o)),s=[n].concat(e.draggable?[r]:[]).concat([i]);return oC.sketch({dom:Ug(''),components:s})})({title:o.shared.providers.translate(e),draggable:o.dialog.isDraggableModal()},t,o.shared.providers),iI=(e,t,o,n)=>({dom:{tag:"div",classes:["tox-dialog__busy-spinner"],attributes:{"aria-label":o.translate(e)},styles:{left:"0px",right:"0px",bottom:"0px",top:`${n.getOr(0)}px`,position:"absolute"}},behaviours:t,components:[{dom:Ug('')}]}),sI=(e,t,o)=>({onClose:()=>o.closeWindow(),onBlock:o=>{const n=pa(e().element,".tox-dialog__header").map((e=>jt(e)));LV.setBusy(e(),((e,r)=>iI(o.message,r,t,n)))},onUnblock:()=>{LV.setIdle(e())}}),aI=(e,t,o,n)=>ia(eI({...e,firstTabstop:1,lazySink:n.shared.getSink,extraBehaviours:[TP.config({channel:`${YS}-${e.id}`,updateState:(e,t)=>M.some(t),initialData:t}),IS({}),...e.extraBehaviours],onEscape:e=>{Ri(e,vC)},dialogEvents:o,eventOrder:{[di()]:[TP.name(),Ml.name()],[xi()]:["scroll-lock",TP.name(),"messages","dialog-events","alloy.base.behaviour"],[Ci()]:["alloy.base.behaviour","dialog-events","messages",TP.name(),"scroll-lock"]}})),lI=(e,t={})=>L(e,(e=>"menu"===e.type?(e=>{const o=L(e.items,(e=>{const o=ve(t,e.name).getOr(Or(!1));return{...e,storage:o}}));return{...e,items:o}})(e):e)),cI=e=>U(e,((e,t)=>"menu"===t.type?U(t.items,((e,t)=>(e[t.name]=t.storage,e)),e):e),{}),dI=(e,t)=>[Wi(Gr(),qS),e(fC,((e,o,n,r)=>{Vl(gt(r.element)).fold(v,Nl),t.onClose(),o.onClose()})),e(vC,((e,t,o,n)=>{t.onCancel(e),Ri(n,fC)})),Zi(_C,((e,o)=>t.onUnblock())),Zi(wC,((e,o)=>t.onBlock(o.event)))],uI=(e,t,o)=>{const n=(t,o)=>Zi(t,((t,n)=>{r(t,((r,i)=>{o(e(),r,n.event,t)}))})),r=(e,t)=>{TP.getState(e).get().each((o=>{t(o.internalDialog,e)}))};return[...dI(n,t),n(yC,((e,t)=>t.onSubmit(e))),n(gC,((e,t,o)=>{t.onChange(e,{name:o.name})})),n(bC,((e,t,n,r)=>{const i=()=>r.getSystem().isConnected()?Hp.focusIn(r):void 0,s=e=>Et(e,"disabled")||Tt(e,"aria-disabled").exists((e=>"true"===e)),a=gt(r.element),l=Vl(a);t.onAction(e,{name:n.name,value:n.value}),Vl(a).fold(i,(e=>{s(e)||l.exists((t=>Qe(e,t)&&s(t)))?i():o().toOptional().filter((t=>!Qe(t.element,e))).each(i)}))})),n(xC,((e,t,o)=>{t.onTabChange(e,{newTabName:o.name,oldTabName:o.oldName})})),Xi((t=>{const o=e();pu.setValue(t,o.getData())}))]},hI=(e,t)=>{const o=t.map((e=>e.footerButtons)).getOr([]),n=H(o,(e=>"start"===e.align)),r=(e,t)=>oC.sketch({dom:{tag:"div",classes:[`tox-dialog__footer-${e}`]},components:L(t,(e=>e.memento.asSpec()))});return[r("start",n.pass),r("end",n.fail)]},mI=(e,t,o)=>({dom:Ug(''),components:[],behaviours:Cl([TP.config({channel:`${JS}-${t}`,initialData:e,updateState:(e,t)=>{const n=L(t.buttons,(e=>{const t=$g(((e,t)=>NE(e,e.type,t))(e,o));return{name:e.name,align:e.align,memento:t}}));return M.some({lookupByName:t=>((e,t,o)=>$(t,(e=>e.name===o)).bind((t=>t.memento.getOpt(e))))(e,n,t),footerButtons:n})},renderComponents:hI})])}),pI=(e,t,o)=>LV.parts.footer(mI(e,t,o)),gI=(e,t)=>{if(e.getRoot().getSystem().isConnected()){const o=_h.getCurrent(e.getFormWrapper()).getOr(e.getFormWrapper());return kS.getField(o,t).orThunk((()=>{const o=e.getFooter().bind((e=>TP.getState(e).get()));return o.bind((e=>e.lookupByName(t)))}))}return M.none()},fI=(e,t,o)=>{const n=t=>{const o=e.getRoot();o.getSystem().isConnected()&&t(o)},r={getData:()=>{const t=e.getRoot(),n=t.getSystem().isConnected()?e.getFormWrapper():t;return{...pu.getValue(n),...ce(o,(e=>e.get()))}},setData:t=>{n((n=>{const i=r.getData(),s=fn(i,t),a=((e,t)=>{const o=e.getRoot();return TP.getState(o).get().map((e=>Gn(qn("data",e.dataValidator,t)))).getOr(t)})(e,s),l=e.getFormWrapper();pu.setValue(l,a),le(o,((e,t)=>{be(s,t)&&e.set(s[t])}))}))},setEnabled:(t,o)=>{gI(e,t).each(o?Dh.enable:Dh.disable)},focus:t=>{gI(e,t).each(og.focus)},block:e=>{if(!i(e))throw new Error("The dialogInstanceAPI.block function should be passed a blocking message of type string as an argument");n((t=>{Vi(t,wC,{message:e})}))},unblock:()=>{n((e=>{Ri(e,_C)}))},showTab:t=>{n((o=>{const n=e.getBody();TP.getState(n).get().exists((e=>e.isTabPanel()))&&_h.getCurrent(n).each((e=>{LP.showTab(e,t)}))}))},redial:i=>{n((n=>{const s=e.getId(),a=t(i),l=lI(a.internalDialog.buttons,o);n.getSystem().broadcastOn([`${YS}-${s}`],a),n.getSystem().broadcastOn([`${KS}-${s}`],a.internalDialog),n.getSystem().broadcastOn([`${XS}-${s}`],a.internalDialog),n.getSystem().broadcastOn([`${JS}-${s}`],{...a.internalDialog,buttons:l}),r.setData(a.initialData)}))},close:()=>{n((e=>{Ri(e,fC)}))},toggleFullscreen:e.toggleFullscreen};return r},vI=(e,t,o,n=!1)=>{const r=ls("dialog"),i=ls("dialog-label"),s=ls("dialog-content"),a=e.internalDialog,l="medium"===a.size?M.some("tox-dialog--width-md"):M.none(),c=$g(((e,t,o,n)=>oC.sketch({dom:Ug(''),components:[oI(e,t,M.some(o),n),nI(),tI(n)],containerBehaviours:Cl([kV.config({mode:"mouse",blockerClass:"blocker",getTarget:e=>ga(e,'[role="dialog"]').getOrDie(),snaps:{getSnapPoints:()=>[],leftAttr:"data-drag-left",topAttr:"data-drag-top"}})])}))({title:a.title,draggable:!0},r,i,o.shared.providers)),d=$g(((e,t,o,n,r)=>WP(e,t,M.some(o),n,r))({body:a.body,initialData:a.initialData},r,s,o,n)),u=lI(a.buttons),h=cI(u),m=ke(0!==u.length,$g(((e,t,o)=>mI(e,t,o))({buttons:u},r,o))),p=uI((()=>v),{onBlock:e=>{SA.block(f,((t,n)=>{const r=c.getOpt(f).map((e=>jt(e.element)));return iI(e.message,n,o.shared.providers,r)}))},onUnblock:()=>{SA.unblock(f)},onClose:()=>t.closeWindow()},o.shared.getSink),g="tox-dialog-inline",f=ia({dom:{tag:"div",classes:["tox-dialog",g,...l.toArray()],attributes:{role:"dialog","aria-labelledby":i}},eventOrder:{[di()]:[TP.name(),Ml.name()],[ui()]:["execute-on-form"],[xi()]:["reflecting","execute-on-form"]},behaviours:Cl([Hp.config({mode:"cyclic",onEscape:e=>(Ri(e,fC),M.some(!0)),useTabstopAt:e=>!GS(e)&&("button"!==Ze(e)||"disabled"!==St(e,"disabled")),firstTabstop:1}),TP.config({channel:`${YS}-${r}`,updateState:(e,t)=>M.some(t),initialData:e}),og.config({}),Xp("execute-on-form",p.concat([Yi(Gr(),((e,t)=>{Hp.focusIn(e)})),Zi(Ti(),((e,t)=>{e.getSystem().broadcastOn([eT],{newFocus:t.event.newFocus})}))])),SA.config({getRoot:()=>M.some(f)}),Kp.config({}),IS({})]),components:[c.asSpec(),d.asSpec(),...m.map((e=>e.asSpec())).toArray()]}),v=fI({getId:w(r),getRoot:w(f),getFooter:()=>m.map((e=>e.get(f))),getBody:()=>d.get(f),getFormWrapper:()=>{const e=d.get(f);return _h.getCurrent(e).getOr(e)},toggleFullscreen:()=>{const e="tox-dialog--fullscreen",t=Ie(f.element.dom);$s(t,[e])?(Us(t,[e]),js(t,[g])):(Us(t,[g]),js(t,[e]))}},t.redial,h);return{dialog:f,instanceApi:v}};var bI=window.mailpoetTinymce.util.Tools.resolve("window.mailpoetTinymce.util.URI");const yI=["insertContent","setContent","execCommand","close","block","unblock"],wI=e=>s(e)&&-1!==yI.indexOf(e.mceAction),_I=(e,t,o,n)=>{const r=ls("dialog"),a=rI(e.title,r,n),l=(e=>{const t={dom:{tag:"div",classes:["tox-dialog__content-js"]},components:[{dom:{tag:"div",classes:["tox-dialog__body-iframe"]},components:[$S(M.none(),{dom:{tag:"iframe",attributes:{src:e.url}},behaviours:Cl([cC.config({}),og.config({})])})]}],behaviours:Cl([Hp.config({mode:"acyclic",useTabstopAt:k(GS)})])};return LV.parts.body(t)})(e),c=e.buttons.bind((e=>0===e.length?M.none():M.some(pI({buttons:e},r,n)))),u=((e,t)=>{const o=(e,t)=>Zi(e,((e,o)=>{n(e,((n,r)=>{t(w,n,o.event,e)}))})),n=(e,t)=>{TP.getState(e).get().each((o=>{t(o,e)}))};return[...dI(o,t),o(bC,((e,t,o)=>{t.onAction(e,{name:o.name})}))]})(0,sI((()=>y),n.shared.providers,t)),h={...e.height.fold((()=>({})),(e=>({height:e+"px","max-height":e+"px"}))),...e.width.fold((()=>({})),(e=>({width:e+"px","max-width":e+"px"})))},p=e.width.isNone()&&e.height.isNone()?["tox-dialog--width-lg"]:[],g=new bI(e.url,{base_uri:new bI(window.location.href)}),f=`${g.protocol}://${g.host}${g.port?":"+g.port:""}`,v=Jl(),b=[Xp("messages",[Ki((()=>{const t=tc(Ie(window),"message",(t=>{if(g.isSameOrigin(new bI(t.raw.origin))){const n=t.raw.data;wI(n)?((e,t,o)=>{switch(o.mceAction){case"insertContent":e.insertContent(o.content);break;case"setContent":e.setContent(o.content);break;case"execCommand":const n=!!d(o.ui)&&o.ui;e.execCommand(o.cmd,n,o.value);break;case"close":t.close();break;case"block":t.block(o.message);break;case"unblock":t.unblock()}})(o,w,n):(e=>!wI(e)&&s(e)&&be(e,"mceAction"))(n)&&e.onMessage(w,n)}}));v.set(t)})),Xi(v.clear)]),Ml.config({channels:{[QS]:{onReceive:(e,t)=>{pa(e.element,"iframe").each((e=>{const o=e.dom.contentWindow;m(o)&&o.postMessage(t,f)}))}}}})],y=aI({id:r,header:a,body:l,footer:c,extraClasses:p,extraBehaviours:b,extraStyles:h},e,u,n),w=(e=>{const t=t=>{e.getSystem().isConnected()&&t(e)};return{block:e=>{if(!i(e))throw new Error("The urlDialogInstanceAPI.block function should be passed a blocking message of type string as an argument");t((t=>{Vi(t,wC,{message:e})}))},unblock:()=>{t((e=>{Ri(e,_C)}))},close:()=>{t((e=>{Ri(e,fC)}))},sendMessage:e=>{t((t=>{t.getSystem().broadcastOn([QS],e)}))}}})(y);return{dialog:y,instanceApi:w}},xI=(e,t)=>Gn(qn("data",t,e)),CI=e=>Wx(e,".tox-alert-dialog")||Wx(e,".tox-confirm-dialog"),kI=(e,t,o)=>t&&o?[]:[WM.config({contextual:{lazyContext:()=>M.some(Xo(Ie(e.getContentAreaContainer()))),fadeInClass:"tox-dialog-dock-fadein",fadeOutClass:"tox-dialog-dock-fadeout",transitionClass:"tox-dialog-dock-transition"},modes:["top"],lazyViewport:t=>Ux(e,t.element).map((e=>({bounds:$x(e),optScrollEnv:M.some({currentScrollTop:e.element.dom.scrollTop,scrollElmTop:Gt(e.element).top})}))).getOrThunk((()=>({bounds:en(),optScrollEnv:M.none()})))})],SI=e=>{const t=e.editor,o=ab(t),n=(e=>{const t=e.shared;return{open:(o,n)=>{const r=()=>{LV.hide(l),n()},i=$g(NE({name:"close-alert",text:"OK",primary:!0,buttonType:M.some("primary"),align:"end",enabled:!0,icon:M.none()},"cancel",e)),s=KP(),a=YP(r,t.providers),l=ia(eI({lazySink:()=>t.getSink(),header:GP(s,a),body:XP(o,t.providers),footer:M.some(JP(QP([],[i.asSpec()]))),onEscape:r,extraClasses:["tox-alert-dialog"],extraBehaviours:[],extraStyles:{},dialogEvents:[Zi(vC,r)],eventOrder:{}}));LV.show(l);const c=i.get(l);og.focus(c)}}})(e.backstages.dialog),r=(e=>{const t=e.shared;return{open:(o,n)=>{const r=e=>{LV.hide(c),n(e)},i=$g(NE({name:"yes",text:"Yes",primary:!0,buttonType:M.some("primary"),align:"end",enabled:!0,icon:M.none()},"submit",e)),s=NE({name:"no",text:"No",primary:!1,buttonType:M.some("secondary"),align:"end",enabled:!0,icon:M.none()},"cancel",e),a=KP(),l=YP((()=>r(!1)),t.providers),c=ia(eI({lazySink:()=>t.getSink(),header:GP(a,l),body:XP(o,t.providers),footer:M.some(JP(QP([],[s,i.asSpec()]))),onEscape:()=>r(!1),extraClasses:["tox-confirm-dialog"],extraBehaviours:[],extraStyles:{},dialogEvents:[Zi(vC,(()=>r(!1))),Zi(yC,(()=>r(!0)))],eventOrder:{}}));LV.show(c);const d=i.get(c);og.focus(d)}}})(e.backstages.dialog),i=(t,o)=>xP.open(((t,n,r)=>{const i=n,s=((e,t,o)=>{const n=ls("dialog"),r=e.internalDialog,i=rI(r.title,n,o),s=((e,t,o)=>{const n=WP(e,t,M.none(),o,!1);return LV.parts.body(n)})({body:r.body,initialData:r.initialData},n,o),a=lI(r.buttons),l=cI(a),c=ke(0!==a.length,pI({buttons:a},n,o)),d=uI((()=>p),sI((()=>h),o.shared.providers,t),o.shared.getSink),u=(e=>{switch(e){case"large":return["tox-dialog--width-lg"];case"medium":return["tox-dialog--width-md"];default:return[]}})(r.size),h=aI({id:n,header:i,body:s,footer:c,extraClasses:u,extraBehaviours:[],extraStyles:{}},e,d,o),m={getId:w(n),getRoot:w(h),getBody:()=>LV.getBody(h),getFooter:()=>LV.getFooter(h),getFormWrapper:()=>{const e=LV.getBody(h);return _h.getCurrent(e).getOr(e)},toggleFullscreen:()=>{const e="tox-dialog--fullscreen",t=Ie(h.element.dom);Zs(t,e)?(Hs(t,e),js(t,u)):(Us(t,u),zs(t,e))}},p=fI(m,t.redial,l);return{dialog:h,instanceApi:p}})({dataValidator:r,initialData:i,internalDialog:t},{redial:xP.redial,closeWindow:()=>{LV.hide(s.dialog),o(s.instanceApi)}},e.backstages.dialog);return LV.show(s.dialog),s.instanceApi.setData(i),s.instanceApi}),t),s=(n,r,i,s)=>xP.open(((n,a,l)=>{const c=xI(a,l),d=Ql(),u=e.backstages.popup.shared.header.isPositionedAtTop(),h=()=>d.on((e=>{Hg.reposition(e),WM.refresh(e)})),m=vI({dataValidator:l,initialData:c,internalDialog:n},{redial:xP.redial,closeWindow:()=>{d.on(Hg.hide),t.off("ResizeEditor",h),d.clear(),i(m.instanceApi)}},e.backstages.popup,s.ariaAttrs),p=ia(Hg.sketch({lazySink:e.backstages.popup.shared.getSink,dom:{tag:"div",classes:[]},fireDismissalEventInstead:s.persistent?{event:"doNotDismissYet"}:{},...u?{}:{fireRepositionEventInstead:{}},inlineBehaviours:Cl([Xp("window-manager-inline-events",[Zi(ki(),((e,t)=>{Ri(m.dialog,vC)}))]),...kI(t,o,u)]),isExtraPart:(e,t)=>CI(t)}));return d.set(p),Hg.showWithinBounds(p,sa(m.dialog),{anchor:r},(()=>{const e=t.inline?wt():Ie(t.getContainer()),o=Xo(e);return M.some(o)})),o&&u||(WM.refresh(p),t.on("ResizeEditor",h)),m.instanceApi.setData(c),Hp.focusIn(m.dialog),m.instanceApi}),n),a=(o,n,r,i)=>xP.open(((o,s,a)=>{const l=xI(s,a),c=Ql(),d=e.backstages.popup.shared.header.isPositionedAtTop(),u=()=>c.on((e=>{Hg.reposition(e),WM.refresh(e)})),h=vI({dataValidator:a,initialData:l,internalDialog:o},{redial:xP.redial,closeWindow:()=>{c.on(Hg.hide),t.off("ResizeEditor ScrollWindow ElementScroll",u),c.clear(),r(h.instanceApi)}},e.backstages.popup,i.ariaAttrs),m=ia(Hg.sketch({lazySink:e.backstages.popup.shared.getSink,dom:{tag:"div",classes:[]},fireDismissalEventInstead:i.persistent?{event:"doNotDismissYet"}:{},...d?{}:{fireRepositionEventInstead:{}},inlineBehaviours:Cl([Xp("window-manager-inline-events",[Zi(ki(),((e,t)=>{Ri(h.dialog,vC)}))]),WM.config({contextual:{lazyContext:()=>M.some(Xo(Ie(t.getContentAreaContainer()))),fadeInClass:"tox-dialog-dock-fadein",fadeOutClass:"tox-dialog-dock-fadeout",transitionClass:"tox-dialog-dock-transition"},modes:["top","bottom"],lazyViewport:e=>Ux(t,e.element).map((e=>({bounds:$x(e),optScrollEnv:M.some({currentScrollTop:e.element.dom.scrollTop,scrollElmTop:Gt(e.element).top})}))).getOrThunk((()=>({bounds:en(),optScrollEnv:M.none()})))})]),isExtraPart:(e,t)=>CI(t)}));return c.set(m),Hg.showWithinBounds(m,sa(h.dialog),{anchor:n},(()=>e.backstages.popup.shared.getSink().toOptional().bind((e=>{const o=Ux(t,e.element).map((e=>$x(e))).getOr(en()),n=Xo(Ie(t.getContentAreaContainer())),r=Qo(n,o);return M.some(Ko(r.x,r.y,r.width,r.height-15))})))),WM.refresh(m),t.on("ResizeEditor ScrollWindow ElementScroll",u),h.instanceApi.setData(l),Hp.focusIn(h.dialog),h.instanceApi}),o);return{open:(t,o,n)=>{if(!u(o)){if("toolbar"===o.inline)return s(t,e.backstages.popup.shared.anchors.inlineDialog(),n,o);if("bottom"===o.inline)return a(t,e.backstages.popup.shared.anchors.inlineBottomDialog(),n,o);if("cursor"===o.inline)return s(t,e.backstages.popup.shared.anchors.cursor(),n,o)}return i(t,n)},openUrl:(o,n)=>((o,n)=>xP.openUrl((o=>{const r=_I(o,{closeWindow:()=>{LV.hide(r.dialog),n(r.instanceApi)}},t,e.backstages.dialog);return LV.show(r.dialog),r.instanceApi}),o))(o,n),alert:(e,t)=>{n.open(e,t)},close:e=>{e.close()},confirm:(e,t)=>{r.open(e,t)}}};tn.add("silver",(e=>{(e=>{uv(e),(e=>{const t=e.options.register,o=e=>f(e,i)?{value:N_(e),valid:!0}:{valid:!1,message:"Must be an array of strings."},n=e=>g(e)&&e>0?{value:e,valid:!0}:{valid:!1,message:"Must be a positive number."};t("color_map",{processor:o,default:["#BFEDD2","Light Green","#FBEEB8","Light Yellow","#F8CAC6","Light Red","#ECCAFA","Light Purple","#C2E0F4","Light Blue","#2DC26B","Green","#F1C40F","Yellow","#E03E2D","Red","#B96AD9","Purple","#3598DB","Blue","#169179","Dark Turquoise","#E67E23","Orange","#BA372A","Dark Red","#843FA1","Dark Purple","#236FA1","Dark Blue","#ECF0F1","Light Gray","#CED4D9","Medium Gray","#95A5A6","Gray","#7E8C8D","Dark Gray","#34495E","Navy Blue","#000000","Black","#ffffff","White"]}),t("color_map_background",{processor:o}),t("color_map_foreground",{processor:o}),t("color_cols",{processor:n,default:P_(e)}),t("color_cols_foreground",{processor:n,default:I_(e,A_)}),t("color_cols_background",{processor:n,default:I_(e,B_)}),t("custom_colors",{processor:"boolean",default:!0}),t("color_default_foreground",{processor:"string",default:V_}),t("color_default_background",{processor:"string",default:V_})})(e),(e=>{const t=e.options.register;t("contextmenu_avoid_overlap",{processor:"string",default:""}),t("contextmenu_never_use_native",{processor:"boolean",default:!1}),t("contextmenu",{processor:e=>!1===e?{value:[],valid:!0}:i(e)||f(e,i)?{value:bR(e),valid:!0}:{valid:!1,message:"Must be false or a string."},default:"link linkchecker image editimage table spellchecker configurepermanentpen"})})(e)})(e);let t=()=>en();const{dialogs:o,popups:n,renderUI:r}=DV(e,{getPopupSinkBounds:()=>t()});zx(e,n.backstage.shared);const s=SI({editor:e,backstages:{popup:n.backstage,dialog:o.backstage}});return{renderUI:()=>{const o=r();return Ux(e,n.getMothership().element).each((e=>{t=()=>$x(e)})),o},getWindowManagerImpl:w(s),getNotificationManagerImpl:()=>((e,t,o)=>{const n=t.backstage.shared,r=()=>{const t=Xo(Ie(e.getContentAreaContainer())),o=en(),n=Ya(o.x,t.x,t.right),r=Ya(o.y,t.y,t.bottom),i=Math.max(t.right,o.right),s=Math.max(t.bottom,o.bottom);return M.some(Ko(n,r,i-n,s-r))};return{open:(t,i)=>{const s=()=>{i(),Hg.hide(l)},a=ia(nv.sketch({text:t.text,level:D(["success","error","warning","warn","info"],t.type)?t.type:void 0,progress:!0===t.progressBar,icon:t.icon,closeButton:t.closeButton,onAction:s,iconProvider:n.providers.icons,translationProvider:n.providers.translate})),l=ia(Hg.sketch({dom:{tag:"div",classes:["tox-notifications-container"]},lazySink:n.getSink,fireDismissalEventInstead:{},...n.header.isPositionedAtTop()?{}:{fireRepositionEventInstead:{}}}));o.add(l),g(t.timeout)&&t.timeout>0&&Zg.setEditorTimeout(e,(()=>{s()}),t.timeout);const c={close:s,reposition:()=>{const t=sa(a),o={maxHeightFunction:cc()},i=e.notificationManager.getNotifications();if(i[0]===c){const e={...n.anchors.banner(),overrides:o};Hg.showWithinBounds(l,t,{anchor:e},r)}else V(i,c).each((e=>{const n=i[e-1].getEl(),s={type:"node",root:wt(),node:M.some(Ie(n)),overrides:o,layouts:{onRtl:()=>[cl],onLtr:()=>[cl]}};Hg.showWithinBounds(l,t,{anchor:s},r)}))},text:e=>{nv.updateText(a,e)},settings:t,getEl:()=>a.element.dom,progressBar:{value:e=>{nv.updateProgress(a,e)}}};return c},close:e=>{e.close()},getArgs:e=>e.settings}})(e,{backstage:n.backstage},n.getMothership())}}))}()},3470:function(e){!function(){"use strict";var t=function(e){if(null===e)return"null";if(void 0===e)return"undefined";var t=typeof e;return"object"===t&&(Array.prototype.isPrototypeOf(e)||e.constructor&&"Array"===e.constructor.name)?"array":"object"===t&&(String.prototype.isPrototypeOf(e)||e.constructor&&"String"===e.constructor.name)?"string":t},o=function(e){return{eq:e}},n=o((function(e,t){return e===t})),r=function(e){return o((function(t,o){if(t.length!==o.length)return!1;for(var n=t.length,r=0;r{var n;return!!o(e,t.prototype)||(null===(n=e.constructor)||void 0===n?void 0:n.name)===t.name},c=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&l(e,String,((e,t)=>t.isPrototypeOf(e)))?"string":t})(t)===e,d=e=>t=>typeof t===e,u=e=>t=>e===t,h=(e,t)=>p(e)&&l(e,t,((e,t)=>a(e)===t)),m=c("string"),p=c("object"),g=e=>h(e,Object),f=c("array"),v=u(null),b=d("boolean"),y=u(void 0),w=e=>null==e,_=e=>!w(e),x=d("function"),C=d("number"),k=(e,t)=>{if(f(e)){for(let o=0,n=e.length;o{},T=(e,t)=>(...o)=>e(t.apply(null,o)),E=(e,t)=>o=>e(t(o)),O=e=>()=>e,M=e=>e,A=(e,t)=>e===t;function B(e,...t){return(...o)=>{const n=t.concat(o);return e.apply(null,n)}}const N=e=>t=>!e(t),R=e=>()=>{throw new Error(e)},V=e=>e(),D=e=>{e()},P=O(!1),I=O(!0);class F{constructor(e,t){this.tag=e,this.value=t}static some(e){return new F(!0,e)}static none(){return F.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?F.some(e(this.value)):F.none()}bind(e){return this.tag?e(this.value):F.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:F.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return _(e)?F.some(e):F.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}F.singletonNone=new F(!1);const L=Array.prototype.slice,z=Array.prototype.indexOf,H=Array.prototype.push,Z=(e,t)=>z.call(e,t),j=(e,t)=>Z(e,t)>-1,U=(e,t)=>{for(let o=0,n=e.length;o{const o=e.length,n=new Array(o);for(let r=0;r{for(let o=0,n=e.length;o{for(let o=e.length-1;o>=0;o--)t(e[o],o)},G=(e,t)=>{const o=[],n=[];for(let r=0,i=e.length;r{const o=[];for(let n=0,r=e.length;n(q(e,((e,n)=>{o=t(o,e,n)})),o),X=(e,t,o)=>(W(e,((e,n)=>{o=t(o,e,n)})),o),J=(e,t,o)=>{for(let n=0,r=e.length;nJ(e,t,P),ee=(e,t)=>{for(let o=0,n=e.length;o{const t=[];for(let o=0,n=e.length;ote($(e,t)),ne=(e,t)=>{for(let o=0,n=e.length;o{const t=L.call(e,0);return t.reverse(),t},ie=(e,t)=>Y(e,(e=>!j(t,e))),se=(e,t)=>{const o={};for(let n=0,r=e.length;n{const o=L.call(e,0);return o.sort(t),o},le=(e,t)=>t>=0&&tle(e,0),de=e=>le(e,e.length-1),ue=x(Array.from)?Array.from:e=>L.call(e),he=(e,t)=>{for(let o=0;o{const o=me(e);for(let n=0,r=o.length;nve(e,((e,o)=>({k:o,v:t(e,o)}))),ve=(e,t)=>{const o={};return ge(e,((e,n)=>{const r=t(e,n);o[r.k]=r.v})),o},be=e=>(t,o)=>{e[o]=t},ye=(e,t,o,n)=>{ge(e,((e,r)=>{(t(e,r)?o:n)(e,r)}))},we=(e,t)=>{const o={};return ye(e,t,be(o),S),o},_e=(e,t)=>{const o=[];return ge(e,((e,n)=>{o.push(t(e,n))})),o},xe=e=>_e(e,M),Ce=(e,t)=>ke(e,t)?F.from(e[t]):F.none(),ke=(e,t)=>pe.call(e,t),Se=(e,t)=>ke(e,t)&&void 0!==e[t]&&null!==e[t],Te=e=>{const t={};return W(e,(e=>{t[e]={}})),me(t)},Ee=e=>void 0!==e.length,Oe=Array.isArray,Me=(e,t,o)=>{if(!e)return!1;if(o=o||e,Ee(e)){for(let n=0,r=e.length;n{const o=[];return Me(e,((n,r)=>{o.push(t(n,r,e))})),o},Be=(e,t)=>{const o=[];return Me(e,((n,r)=>{t&&!t(n,r,e)||o.push(n)})),o},Ne=(e,t,o,n)=>{let r=y(o)?e[0]:o;for(let o=0;o{for(let n=0,r=e.length;ne[e.length-1],De=e=>{let t,o=!1;return(...n)=>(o||(o=!0,t=e.apply(null,n)),t)},Pe=()=>Ie(0,0),Ie=(e,t)=>({major:e,minor:t}),Fe={nu:Ie,detect:(e,t)=>{const o=String(t).toLowerCase();return 0===e.length?Pe():((e,t)=>{const o=((e,t)=>{for(let o=0;oNumber(t.replace(o,"$"+e));return Ie(n(1),n(2))})(e,o)},unknown:Pe},Le=(e,t)=>{const o=String(t).toLowerCase();return Q(e,(e=>e.search(o)))},ze=(e,t,o)=>""===t||e.length>=t.length&&e.substr(o,o+t.length)===t,He=(e,t)=>je(e,t)?((e,t)=>e.substring(t))(e,t.length):e,Ze=(e,t,o=0,n)=>{const r=e.indexOf(t,o);return-1!==r&&(!!y(n)||r+t.length<=n)},je=(e,t)=>ze(e,t,0),Ue=(e,t)=>ze(e,t,e.length-t.length),$e=e=>t=>t.replace(e,""),We=$e(/^\s+|\s+$/g),qe=$e(/^\s+/g),Ge=$e(/\s+$/g),Ye=e=>e.length>0,Ke=e=>!Ye(e),Xe=(e,t=10)=>{const o=parseInt(e,t);return isNaN(o)?F.none():F.some(o)},Je=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,Qe=e=>t=>Ze(t,e),et=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:e=>Ze(e,"edge/")&&Ze(e,"chrome")&&Ze(e,"safari")&&Ze(e,"applewebkit")},{name:"Chromium",brand:"Chromium",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,Je],search:e=>Ze(e,"chrome")&&!Ze(e,"chromeframe")},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:e=>Ze(e,"msie")||Ze(e,"trident")},{name:"Opera",versionRegexes:[Je,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:Qe("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:Qe("firefox")},{name:"Safari",versionRegexes:[Je,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:e=>(Ze(e,"safari")||Ze(e,"mobile/"))&&Ze(e,"applewebkit")}],tt=[{name:"Windows",search:Qe("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:e=>Ze(e,"iphone")||Ze(e,"ipad"),versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:Qe("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"macOS",search:Qe("mac os x"),versionRegexes:[/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:Qe("linux"),versionRegexes:[]},{name:"Solaris",search:Qe("sunos"),versionRegexes:[]},{name:"FreeBSD",search:Qe("freebsd"),versionRegexes:[]},{name:"ChromeOS",search:Qe("cros"),versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/]}],ot={browsers:O(et),oses:O(tt)},nt="Edge",rt="Chromium",it="Opera",st="Firefox",at="Safari",lt=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isEdge:n(nt),isChromium:n(rt),isIE:n("IE"),isOpera:n(it),isFirefox:n(st),isSafari:n(at)}},ct=()=>lt({current:void 0,version:Fe.unknown()}),dt=lt,ut=(O(nt),O(rt),O("IE"),O(it),O(st),O(at),"Windows"),ht="Android",mt="Linux",pt="macOS",gt="Solaris",ft="FreeBSD",vt="ChromeOS",bt=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isWindows:n(ut),isiOS:n("iOS"),isAndroid:n(ht),isMacOS:n(pt),isLinux:n(mt),isSolaris:n(gt),isFreeBSD:n(ft),isChromeOS:n(vt)}},yt=()=>bt({current:void 0,version:Fe.unknown()}),wt=bt,_t=(O(ut),O("iOS"),O(ht),O(mt),O(pt),O(gt),O(ft),O(vt),e=>window.matchMedia(e).matches);let xt=De((()=>((e,t,o)=>{const n=ot.browsers(),r=ot.oses(),i=t.bind((e=>((e,t)=>he(t.brands,(t=>{const o=t.brand.toLowerCase();return Q(e,(e=>{var t;return o===(null===(t=e.brand)||void 0===t?void 0:t.toLowerCase())})).map((e=>({current:e.name,version:Fe.nu(parseInt(t.version,10),0)})))})))(n,e))).orThunk((()=>((e,t)=>Le(e,t).map((e=>{const o=Fe.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(n,e))).fold(ct,dt),s=((e,t)=>Le(e,t).map((e=>{const o=Fe.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(r,e).fold(yt,wt),a=((e,t,o,n)=>{const r=e.isiOS()&&!0===/ipad/i.test(o),i=e.isiOS()&&!r,s=e.isiOS()||e.isAndroid(),a=s||n("(pointer:coarse)"),l=r||!i&&s&&n("(min-device-width:768px)"),c=i||s&&!l,d=t.isSafari()&&e.isiOS()&&!1===/safari/i.test(o),u=!c&&!l&&!d;return{isiPad:O(r),isiPhone:O(i),isTablet:O(l),isPhone:O(c),isTouch:O(a),isAndroid:e.isAndroid,isiOS:e.isiOS,isWebView:O(d),isDesktop:O(u)}})(s,i,e,o);return{browser:i,os:s,deviceType:a}})(navigator.userAgent,F.from(navigator.userAgentData),_t)));const Ct=()=>xt(),kt=navigator.userAgent,St=Ct(),Tt=St.browser,Et=St.os,Ot=St.deviceType,Mt=-1!==kt.indexOf("Windows Phone"),At={transparentSrc:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",documentMode:Tt.isIE()?document.documentMode||7:10,cacheSuffix:null,container:null,canHaveCSP:!Tt.isIE(),windowsPhone:Mt,browser:{current:Tt.current,version:Tt.version,isChromium:Tt.isChromium,isEdge:Tt.isEdge,isFirefox:Tt.isFirefox,isIE:Tt.isIE,isOpera:Tt.isOpera,isSafari:Tt.isSafari},os:{current:Et.current,version:Et.version,isAndroid:Et.isAndroid,isChromeOS:Et.isChromeOS,isFreeBSD:Et.isFreeBSD,isiOS:Et.isiOS,isLinux:Et.isLinux,isMacOS:Et.isMacOS,isSolaris:Et.isSolaris,isWindows:Et.isWindows},deviceType:{isDesktop:Ot.isDesktop,isiPad:Ot.isiPad,isiPhone:Ot.isiPhone,isPhone:Ot.isPhone,isTablet:Ot.isTablet,isTouch:Ot.isTouch,isWebView:Ot.isWebView}},Bt=/^\s*|\s*$/g,Nt=e=>w(e)?"":(""+e).replace(Bt,""),Rt=function(e,t,o,n){n=n||this,e&&(o&&(e=e[o]),Me(e,((e,r)=>!1!==t.call(n,e,r,o)&&(Rt(e,t,o,n),!0))))},Vt={trim:Nt,isArray:Oe,is:(e,t)=>t?!("array"!==t||!Oe(e))||typeof e===t:void 0!==e,toArray:e=>{if(Oe(e))return e;{const t=[];for(let o=0,n=e.length;o{const n=m(e)?e.split(t||","):e||[];let r=n.length;for(;r--;)o[n[r]]={};return o},each:Me,map:Ae,grep:Be,inArray:(e,t)=>{if(e)for(let o=0,n=e.length;o{for(let o=0;o{const o=e.split(".");for(let e=0,n=o.length;ef(e)?e:""===e?[]:Ae(e.split(t||","),Nt),_addCacheSuffix:e=>{const t=At.cacheSuffix;return t&&(e+=(-1===e.indexOf("?")?"?":"&")+t),e}},Dt=(e,t,o=A)=>e.exists((e=>o(e,t))),Pt=(e,t,o=A)=>It(e,t,o).getOr(e.isNone()&&t.isNone()),It=(e,t,o)=>e.isSome()&&t.isSome()?F.some(o(e.getOrDie(),t.getOrDie())):F.none(),Ft=(e,t)=>e?F.some(t):F.none(),Lt="undefined"!=typeof window?window:Function("return this;")(),zt=(e,t)=>((e,t)=>{let o=null!=t?t:Lt;for(let t=0;t{const t=zt("ownerDocument.defaultView",e);return p(e)&&((e=>((e,t)=>{const o=((e,t)=>zt(e,t))(e,t);if(null==o)throw new Error(e+" not available on this browser");return o})("HTMLElement",e))(t).prototype.isPrototypeOf(e)||/^HTML\w*Element$/.test(Ht(e).constructor.name))},jt=e=>e.dom.nodeName.toLowerCase(),Ut=e=>e.dom.nodeType,$t=e=>t=>Ut(t)===e,Wt=e=>qt(e)&&Zt(e.dom),qt=$t(1),Gt=$t(3),Yt=$t(9),Kt=$t(11),Xt=e=>t=>qt(t)&&jt(t)===e,Jt=(e,t,o)=>{if(!(m(o)||b(o)||C(o)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",o,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,o+"")},Qt=(e,t,o)=>{Jt(e.dom,t,o)},eo=(e,t)=>{const o=e.dom;ge(t,((e,t)=>{Jt(o,t,e)}))},to=(e,t)=>{const o=e.dom.getAttribute(t);return null===o?void 0:o},oo=(e,t)=>F.from(to(e,t)),no=(e,t)=>{const o=e.dom;return!(!o||!o.hasAttribute)&&o.hasAttribute(t)},ro=(e,t)=>{e.dom.removeAttribute(t)},io=e=>X(e.dom.attributes,((e,t)=>(e[t.name]=t.value,e)),{}),so=(e,t)=>{const o=to(e,t);return void 0===o||""===o?[]:o.split(" ")},ao=e=>void 0!==e.dom.classList,lo=e=>so(e,"class"),co=(e,t)=>((e,t,o)=>{const n=so(e,t).concat([o]);return Qt(e,t,n.join(" ")),!0})(e,"class",t),uo=(e,t)=>((e,t,o)=>{const n=Y(so(e,t),(e=>e!==o));return n.length>0?Qt(e,t,n.join(" ")):ro(e,t),!1})(e,"class",t),ho=(e,t)=>{ao(e)?e.dom.classList.add(t):co(e,t)},mo=e=>{0===(ao(e)?e.dom.classList:lo(e)).length&&ro(e,"class")},po=(e,t)=>{ao(e)?e.dom.classList.remove(t):uo(e,t),mo(e)},go=(e,t)=>ao(e)&&e.dom.classList.contains(t),fo=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},vo=(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return fo(o.childNodes[0])},bo=(e,t)=>{const o=(t||document).createElement(e);return fo(o)},yo=(e,t)=>{const o=(t||document).createTextNode(e);return fo(o)},wo=fo,_o=(e,t,o)=>F.from(e.dom.elementFromPoint(t,o)).map(fo),xo=(e,t)=>{const o=[],n=e=>(o.push(e),t(e));let r=t(e);do{r=r.bind(n)}while(r.isSome());return o},Co=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},ko=e=>1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType||0===e.childElementCount,So=(e,t)=>e.dom===t.dom,To=(e,t)=>{const o=e.dom,n=t.dom;return o!==n&&o.contains(n)},Eo=e=>wo(e.dom.ownerDocument),Oo=e=>Yt(e)?e:Eo(e),Mo=e=>wo(Oo(e).dom.defaultView),Ao=e=>F.from(e.dom.parentNode).map(wo),Bo=e=>F.from(e.dom.parentElement).map(wo),No=(e,t)=>{const o=x(t)?t:P;let n=e.dom;const r=[];for(;null!==n.parentNode&&void 0!==n.parentNode;){const e=n.parentNode,t=wo(e);if(r.push(t),!0===o(t))break;n=e}return r},Ro=e=>F.from(e.dom.previousSibling).map(wo),Vo=e=>F.from(e.dom.nextSibling).map(wo),Do=e=>re(xo(e,Ro)),Po=e=>xo(e,Vo),Io=e=>$(e.dom.childNodes,wo),Fo=(e,t)=>{const o=e.dom.childNodes;return F.from(o[t]).map(wo)},Lo=e=>Fo(e,0),zo=e=>Fo(e,e.dom.childNodes.length-1),Ho=e=>e.dom.childNodes.length,Zo=e=>Kt(e)&&_(e.dom.host),jo=x(Element.prototype.attachShadow)&&x(Node.prototype.getRootNode),Uo=O(jo),$o=jo?e=>wo(e.dom.getRootNode()):Oo,Wo=e=>Zo(e)?e:(e=>{const t=e.dom.head;if(null==t)throw new Error("Head is not available yet");return wo(t)})(Oo(e)),qo=e=>wo(e.dom.host),Go=e=>{if(Uo()&&_(e.target)){const t=wo(e.target);if(qt(t)&&Yo(t)&&e.composed&&e.composedPath){const t=e.composedPath();if(t)return ce(t)}}return F.from(e.target)},Yo=e=>_(e.dom.shadowRoot),Ko=e=>{const t=Gt(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return(e=>{const t=$o(e);return Zo(t)?F.some(t):F.none()})(wo(t)).fold((()=>o.body.contains(t)),E(Ko,qo))};var Xo=(e,t,o,n,r)=>e(o,n)?F.some(o):x(r)&&r(o)?F.none():t(o,n,r);const Jo=(e,t,o)=>{let n=e.dom;const r=x(o)?o:P;for(;n.parentNode;){n=n.parentNode;const e=wo(n);if(t(e))return F.some(e);if(r(e))break}return F.none()},Qo=(e,t,o)=>Xo(((e,t)=>t(e)),Jo,e,t,o),en=(e,t,o)=>Jo(e,(e=>Co(e,t)),o),tn=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return ko(o)?F.none():F.from(o.querySelector(e)).map(wo)})(t,e),on=(e,t,o)=>Xo(((e,t)=>Co(e,t)),en,e,t,o),nn=(e,t=!1)=>{return Ko(e)?e.dom.isContentEditable:(o=e,on(o,"[contenteditable]")).fold(O(t),(e=>"true"===rn(e)));var o},rn=e=>e.dom.contentEditable,sn=e=>void 0!==e.style&&x(e.style.getPropertyValue),an=(e,t,o)=>{if(!m(o))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",o,":: Element ",e),new Error("CSS value must be a string: "+o);sn(e)&&e.style.setProperty(t,o)},ln=(e,t,o)=>{const n=e.dom;an(n,t,o)},cn=(e,t)=>{const o=e.dom;ge(t,((e,t)=>{an(o,t,e)}))},dn=(e,t)=>{const o=e.dom,n=window.getComputedStyle(o).getPropertyValue(t);return""!==n||Ko(e)?n:un(o,t)},un=(e,t)=>sn(e)?e.style.getPropertyValue(t):"",hn=(e,t)=>{const o=e.dom,n=un(o,t);return F.from(n).filter((e=>e.length>0))},mn=e=>{const t={},o=e.dom;if(sn(o))for(let e=0;e{((e,t)=>{sn(e)&&e.style.removeProperty(t)})(e.dom,t),Dt(oo(e,"style").map(We),"")&&ro(e,"style")},gn=(e,t)=>{Ao(e).each((o=>{o.dom.insertBefore(t.dom,e.dom)}))},fn=(e,t)=>{Vo(e).fold((()=>{Ao(e).each((e=>{bn(e,t)}))}),(e=>{gn(e,t)}))},vn=(e,t)=>{Lo(e).fold((()=>{bn(e,t)}),(o=>{e.dom.insertBefore(t.dom,o.dom)}))},bn=(e,t)=>{e.dom.appendChild(t.dom)},yn=(e,t)=>{gn(e,t),bn(t,e)},wn=(e,t)=>{W(t,(t=>{bn(e,t)}))},_n=e=>{e.dom.textContent="",W(Io(e),(e=>{xn(e)}))},xn=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},Cn=e=>{const t=Io(e);var o,n;t.length>0&&(o=e,W(n=t,((e,t)=>{const r=0===t?o:n[t-1];fn(r,e)}))),xn(e)},kn=e=>$(e,wo),Sn=e=>e.dom.innerHTML,Tn=(e,t)=>{const o=Eo(e).dom,n=wo(o.createDocumentFragment()),r=((e,t)=>{const o=(t||document).createElement("div");return o.innerHTML=e,Io(wo(o))})(t,o);wn(n,r),_n(e),bn(e,n)},En=(e,t,o,n)=>((e,t,o,n,r)=>{const i=((e,t)=>o=>{e(o)&&t((e=>{const t=wo(Go(e).getOr(e.target)),o=()=>e.stopPropagation(),n=()=>e.preventDefault(),r=T(n,o);return((e,t,o,n,r,i,s)=>({target:e,x:t,y:o,stop:n,prevent:r,kill:i,raw:s}))(t,e.clientX,e.clientY,o,n,r,e)})(o))})(o,n);return e.dom.addEventListener(t,i,false),{unbind:B(On,e,t,i,false)}})(e,t,o,n),On=(e,t,o,n)=>{e.dom.removeEventListener(t,o,n)},Mn=(e,t)=>({left:e,top:t,translate:(o,n)=>Mn(e+o,t+n)}),An=Mn,Bn=(e,t)=>void 0!==e?e:void 0!==t?t:0,Nn=e=>{const t=e.dom,o=t.ownerDocument.body;return o===t?An(o.offsetLeft,o.offsetTop):Ko(e)?(e=>{const t=e.getBoundingClientRect();return An(t.left,t.top)})(t):An(0,0)},Rn=e=>{const t=void 0!==e?e.dom:document,o=t.body.scrollLeft||t.documentElement.scrollLeft,n=t.body.scrollTop||t.documentElement.scrollTop;return An(o,n)},Vn=(e,t,o)=>{const n=(void 0!==o?o.dom:document).defaultView;n&&n.scrollTo(e,t)},Dn=(e,t)=>{Ct().browser.isSafari()&&x(e.dom.scrollIntoViewIfNeeded)?e.dom.scrollIntoViewIfNeeded(!1):e.dom.scrollIntoView(t)},Pn=(e,t,o,n)=>({x:e,y:t,width:o,height:n,right:e+o,bottom:t+n}),In=e=>{const t=void 0===e?window:e,o=t.document,n=Rn(wo(o));return(e=>{const t=void 0===e?window:e;return Ct().browser.isFirefox()?F.none():F.from(t.visualViewport)})(t).fold((()=>{const e=t.document.documentElement,o=e.clientWidth,r=e.clientHeight;return Pn(n.left,n.top,o,r)}),(e=>Pn(Math.max(e.pageLeft,n.left),Math.max(e.pageTop,n.top),e.width,e.height)))},Fn=(e,t)=>{let o=[];return W(Io(e),(e=>{t(e)&&(o=o.concat([e])),o=o.concat(Fn(e,t))})),o},Ln=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return ko(o)?[]:$(o.querySelectorAll(e),wo)})(t,e),zn=(e,t,o)=>en(e,t,o).isSome();class Hn{constructor(e,t){this.node=e,this.rootNode=t,this.current=this.current.bind(this),this.next=this.next.bind(this),this.prev=this.prev.bind(this),this.prev2=this.prev2.bind(this)}current(){return this.node}next(e){return this.node=this.findSibling(this.node,"firstChild","nextSibling",e),this.node}prev(e){return this.node=this.findSibling(this.node,"lastChild","previousSibling",e),this.node}prev2(e){return this.node=this.findPreviousNode(this.node,e),this.node}findSibling(e,t,o,n){if(e){if(!n&&e[t])return e[t];if(e!==this.rootNode){let t=e[o];if(t)return t;for(let n=e.parentNode;n&&n!==this.rootNode;n=n.parentNode)if(t=n[o],t)return t}}}findPreviousNode(e,t){if(e){const o=e.previousSibling;if(this.rootNode&&o===this.rootNode)return;if(o){if(!t)for(let e=o.lastChild;e;e=e.lastChild)if(!e.lastChild)return e;return o}const n=e.parentNode;if(n&&n!==this.rootNode)return n}}}const Zn=e=>t=>!!t&&t.nodeType===e,jn=e=>!!e&&!Object.getPrototypeOf(e),Un=Zn(1),$n=e=>{const t=e.toLowerCase();return e=>_(e)&&e.nodeName.toLowerCase()===t},Wn=e=>{const t=e.map((e=>e.toLowerCase()));return e=>{if(e&&e.nodeName){const o=e.nodeName.toLowerCase();return j(t,o)}return!1}},qn=(e,t)=>{const o=t.toLowerCase().split(" ");return t=>{if(Un(t)){const n=t.ownerDocument.defaultView;if(n)for(let r=0;rt=>Un(t)&&t.hasAttribute(e),Yn=e=>Un(e)&&e.hasAttribute("data-mce-bogus"),Kn=e=>Un(e)&&"TABLE"===e.tagName,Xn=e=>t=>{if(Un(t)){if(t.contentEditable===e)return!0;if(t.getAttribute("data-mce-contenteditable")===e)return!0}return!1},Jn=Wn(["textarea","input"]),Qn=Zn(3),er=Zn(4),tr=Zn(7),or=Zn(8),nr=Zn(9),rr=Zn(11),ir=$n("br"),sr=$n("img"),ar=Xn("true"),lr=Xn("false"),cr=Wn(["td","th"]),dr=Wn(["td","th","caption"]),ur=Wn(["video","audio","object","embed"]),hr=$n("li"),mr=$n("details"),pr=$n("summary"),gr="\ufeff",fr=" ",vr=e=>e===gr,br=((e,t)=>{const o=t=>e(t)?F.from(t.dom.nodeValue):F.none();return{get:t=>{if(!e(t))throw new Error("Can only get text value of a text node");return o(t).getOr("")},getOption:o,set:(t,o)=>{if(!e(t))throw new Error("Can only set raw text value of a text node");t.dom.nodeValue=o}}})(Gt),yr=e=>br.get(e),wr=e=>br.getOption(e),_r=["pre"].concat(["h1","h2","h3","h4","h5","h6"]),xr=e=>{let t;return o=>(t=t||se(e,I),ke(t,jt(o)))},Cr=xr(["article","aside","details","div","dt","figcaption","footer","form","fieldset","header","hgroup","html","main","nav","section","summary","body","p","dl","multicol","dd","figure","address","center","blockquote","h1","h2","h3","h4","h5","h6","listing","xmp","pre","plaintext","menu","dir","ul","ol","li","hr","table","tbody","thead","tfoot","th","tr","td","caption"]),kr=e=>qt(e)&&!Cr(e),Sr=e=>qt(e)&&"br"===jt(e),Tr=xr(["h1","h2","h3","h4","h5","h6","p","div","address","pre","form","blockquote","center","dir","fieldset","header","footer","article","section","hgroup","aside","nav","figure"]),Er=xr(["ul","ol","dl"]),Or=xr(["li","dd","dt"]),Mr=xr(["thead","tbody","tfoot"]),Ar=xr(["td","th"]),Br=xr(["pre","script","textarea","style"]),Nr=xr(_r),Rr=e=>Nr(e)||kr(e),Vr=()=>{const e=bo("br");return Qt(e,"data-mce-bogus","1"),e},Dr=e=>{_n(e),bn(e,Vr())},Pr=e=>{zo(e).each((t=>{Ro(t).each((o=>{Cr(e)&&Sr(t)&&Cr(o)&&xn(t)}))}))},Ir=gr,Fr=vr,Lr=e=>e.replace(/\uFEFF/g,""),zr=Un,Hr=Qn,Zr=e=>(Hr(e)&&(e=e.parentNode),zr(e)&&e.hasAttribute("data-mce-caret")),jr=e=>Hr(e)&&Fr(e.data),Ur=e=>Zr(e)||jr(e),$r=e=>e.firstChild!==e.lastChild||!ir(e.firstChild),Wr=e=>{const t=e.container();return!!Qn(t)&&(t.data.charAt(e.offset())===Ir||e.isAtStart()&&jr(t.previousSibling))},qr=e=>{const t=e.container();return!!Qn(t)&&(t.data.charAt(e.offset()-1)===Ir||e.isAtEnd()&&jr(t.nextSibling))},Gr=e=>Hr(e)&&e.data[0]===Ir,Yr=e=>Hr(e)&&e.data[e.data.length-1]===Ir,Kr=e=>e&&e.hasAttribute("data-mce-caret")?((e=>{var t;const o=e.getElementsByTagName("br"),n=o[o.length-1];Yn(n)&&(null===(t=n.parentNode)||void 0===t||t.removeChild(n))})(e),e.removeAttribute("data-mce-caret"),e.removeAttribute("data-mce-bogus"),e.removeAttribute("style"),e.removeAttribute("data-mce-style"),e.removeAttribute("_moz_abspos"),e):null,Xr=e=>Zr(e.startContainer),Jr=ar,Qr=lr,ei=ir,ti=Qn,oi=Wn(["script","style","textarea"]),ni=Wn(["img","input","textarea","hr","iframe","video","audio","object","embed"]),ri=Wn(["table"]),ii=Ur,si=e=>!ii(e)&&(ti(e)?!oi(e.parentNode):ni(e)||ei(e)||ri(e)||ai(e)),ai=e=>!(e=>Un(e)&&"true"===e.getAttribute("unselectable"))(e)&&Qr(e),li=(e,t)=>si(e)&&((e,t)=>{for(let o=e.parentNode;o&&o!==t;o=o.parentNode){if(ai(o))return!1;if(Jr(o))return!0}return!0})(e,t),ci=/^[ \t\r\n]*$/,di=e=>ci.test(e),ui=e=>{for(const t of e)if(!vr(t))return!1;return!0},hi=e=>"\n"===e||"\r"===e,mi=(e,t=4,o=!0,n=!0)=>{const r=((e,t)=>t<=0?"":new Array(t+1).join(" "))(0,t),i=e.replace(/\t/g,r),s=X(i,((e,t)=>(e=>-1!==" \f\t\v".indexOf(e))(t)||t===fr?e.pcIsSpace||""===e.str&&o||e.str.length===i.length-1&&n||((e,t)=>t=0&&hi(e[t]))(i,e.str.length+1)?{pcIsSpace:!1,str:e.str+fr}:{pcIsSpace:!0,str:e.str+" "}:{pcIsSpace:hi(t),str:e.str+t}),{pcIsSpace:!1,str:""});return s.str},pi=(e,t)=>si(e)&&!((e,t)=>Qn(e)&&di(e.data)&&!((e,t)=>{const o=wo(t),n=wo(e);return zn(n,"pre,code",B(So,o))})(e,t))(e,t)||(e=>Un(e)&&"A"===e.nodeName&&!e.hasAttribute("href")&&(e.hasAttribute("name")||e.hasAttribute("id")))(e)||gi(e),gi=Gn("data-mce-bookmark"),fi=Gn("data-mce-bogus"),vi=("data-mce-bogus","all",e=>Un(e)&&"all"===e.getAttribute("data-mce-bogus"));const bi=(e,t=!0)=>((e,t)=>{let o=0;if(pi(e,e))return!1;{let n=e.firstChild;if(!n)return!0;const r=new Hn(n,e);do{if(t){if(vi(n)){n=r.next(!0);continue}if(fi(n)){n=r.next();continue}}if(ir(n))o++,n=r.next();else{if(pi(n,e))return!1;n=r.next()}}while(n);return o<=1}})(e.dom,t),yi="data-mce-block",wi=e=>(e=>Y(me(e),(e=>!/[A-Z]/.test(e))))(e).join(","),_i=(e,t)=>_(t.querySelector(e))?(t.setAttribute(yi,"true"),"inline-boundary"===t.getAttribute("data-mce-selected")&&t.removeAttribute("data-mce-selected"),!0):(t.removeAttribute(yi),!1),xi=(e,t)=>{const o=wi(e.getTransparentElements()),n=wi(e.getBlockElements());return Y(t.querySelectorAll(o),(e=>_i(n,e)))},Ci=(e,t)=>{var o;const n=t?"lastChild":"firstChild";for(let t=e[n];t;t=t[n])if(bi(wo(t)))return void(null===(o=t.parentNode)||void 0===o||o.removeChild(t))},ki=(e,t,o)=>{const n=e.getBlockElements(),r=wo(t),i=e=>jt(e)in n,s=e=>So(e,r);W(kn(o),(t=>{Jo(t,i,s).each((o=>{const n=((t,n)=>Y(Io(t),(t=>i(t)&&!e.isValidChild(jt(o),jt(t)))))(t);if(n.length>0){const t=Bo(o);W(n,(e=>{Jo(e,i,s).each((t=>{((e,t)=>{const o=document.createRange(),n=e.parentNode;if(n){o.setStartBefore(e),o.setEndBefore(t);const r=o.extractContents();Ci(r,!0),o.setStartAfter(t),o.setEndAfter(e);const i=o.extractContents();Ci(i,!1),bi(wo(r))||n.insertBefore(r,e),bi(wo(t))||n.insertBefore(t,e),bi(wo(i))||n.insertBefore(i,e),n.removeChild(e)}})(t.dom,e.dom)}))})),t.each((t=>xi(e,t.dom)))}}))}))},Si=(e,t)=>{const o=xi(e,t);ki(e,t,o),((e,t,o)=>{W([...o,...Ai(e,t)?[t]:[]],(t=>W(Ln(wo(t),t.nodeName.toLowerCase()),(t=>{Bi(e,t.dom)&&Cn(t)}))))})(e,t,o)},Ti=(e,t)=>{if(Mi(e,t)){const o=wi(e.getBlockElements());_i(o,t)}},Ei=e=>e.hasAttribute(yi),Oi=(e,t)=>ke(e.getTransparentElements(),t),Mi=(e,t)=>Un(t)&&Oi(e,t.nodeName),Ai=(e,t)=>Mi(e,t)&&Ei(t),Bi=(e,t)=>Mi(e,t)&&!Ei(t),Ni=(e,t)=>1===t.type&&Oi(e,t.name)&&m(t.attr(yi)),Ri=Ct().browser,Vi=e=>Q(e,qt),Di=(e,t)=>e.children&&j(e.children,t),Pi=(e,t={})=>{let o=0;const n={},r=wo(e),i=Oo(r),s=e=>new Promise(((s,a)=>{let l;const c=Vt._addCacheSuffix(e),d=(e=>Ce(n,e).getOrThunk((()=>({id:"mce-u"+o++,passed:[],failed:[],count:0}))))(c);n[c]=d,d.count++;const u=(e,t)=>{W(e,D),d.status=t,d.passed=[],d.failed=[],l&&(l.onload=null,l.onerror=null,l=null)},h=()=>u(d.passed,2),m=()=>u(d.failed,3);if(s&&d.passed.push(s),a&&d.failed.push(a),1===d.status)return;if(2===d.status)return void h();if(3===d.status)return void m();d.status=1;const p=bo("link",i.dom);var g;eo(p,{rel:"stylesheet",type:"text/css",id:d.id}),t.contentCssCors&&Qt(p,"crossOrigin","anonymous"),t.referrerPolicy&&Qt(p,"referrerpolicy",t.referrerPolicy),l=p.dom,l.onload=h,l.onerror=m,g=p,bn(Wo(r),g),Qt(p,"href",c)})),a=e=>{const t=Vt._addCacheSuffix(e);Ce(n,t).each((e=>{0==--e.count&&(delete n[t],(e=>{const t=Wo(r);tn(t,"#"+e).each(xn)})(e.id))}))};return{load:s,loadAll:e=>Promise.allSettled($(e,(e=>s(e).then(O(e))))).then((e=>{const t=G(e,(e=>"fulfilled"===e.status));return t.fail.length>0?Promise.reject($(t.fail,(e=>e.reason))):$(t.pass,(e=>e.value))})),unload:a,unloadAll:e=>{W(e,(e=>{a(e)}))},_setReferrerPolicy:e=>{t.referrerPolicy=e},_setContentCssCors:e=>{t.contentCssCors=e}}},Ii=(()=>{const e=new WeakMap;return{forElement:(t,o)=>{const n=$o(t).dom;return F.from(e.get(n)).getOrThunk((()=>{const t=Pi(n,o);return e.set(n,t),t}))}}})(),Fi=(e,t)=>_(e)&&(pi(e,t)||kr(wo(e))),Li=e=>(e=>"span"===e.nodeName.toLowerCase())(e)&&"bookmark"===e.getAttribute("data-mce-type"),zi=(e,t,o)=>{var n;const r=o||t;if(Un(t)&&Li(t))return t;const i=t.childNodes;for(let t=i.length-1;t>=0;t--)zi(e,i[t],r);if(Un(t)){const e=t.childNodes;1===e.length&&Li(e[0])&&(null===(n=t.parentNode)||void 0===n||n.insertBefore(e[0],t))}return(e=>rr(e)||nr(e))(t)||pi(t,r)||(e=>!!Un(e)&&e.childNodes.length>0)(t)||((e,t)=>Qn(e)&&e.data.length>0&&((e,t)=>{const o=new Hn(e,t).prev(!1),n=new Hn(e,t).next(!1),r=y(o)||Fi(o,t),i=y(n)||Fi(n,t);return r&&i})(e,t))(t,r)||e.remove(t),t},Hi=Vt.makeMap,Zi=/[&<>\"\u0060\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,ji=/[<>&\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Ui=/[<>&\"\']/g,$i=/([a-z0-9]+);?|&([a-z0-9]+);/gi,Wi={128:"€",130:"‚",131:"ƒ",132:"„",133:"…",134:"†",135:"‡",136:"ˆ",137:"‰",138:"Š",139:"‹",140:"Œ",142:"Ž",145:"‘",146:"’",147:"“",148:"”",149:"•",150:"–",151:"—",152:"˜",153:"™",154:"š",155:"›",156:"œ",158:"ž",159:"Ÿ"},qi={'"':""","'":"'","<":"<",">":">","&":"&","`":"`"},Gi={"<":"<",">":">","&":"&",""":'"',"'":"'"},Yi=(e,t)=>{const o={};if(e){const n=e.split(",");t=t||10;for(let e=0;ee.replace(t?Zi:ji,(e=>qi[e]||e)),Ji=(e,t)=>e.replace(t?Zi:ji,(e=>e.length>1?""+(1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320)+65536)+";":qi[e]||""+e.charCodeAt(0)+";")),Qi=(e,t,o)=>{const n=o||Ki;return e.replace(t?Zi:ji,(e=>qi[e]||n[e]||e))},es={encodeRaw:Xi,encodeAllRaw:e=>(""+e).replace(Ui,(e=>qi[e]||e)),encodeNumeric:Ji,encodeNamed:Qi,getEncodeFunc:(e,t)=>{const o=Yi(t)||Ki,n=Hi(e.replace(/\+/g,","));return n.named&&n.numeric?(e,t)=>e.replace(t?Zi:ji,(e=>void 0!==qi[e]?qi[e]:void 0!==o[e]?o[e]:e.length>1?""+(1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320)+65536)+";":""+e.charCodeAt(0)+";")):n.named?t?(e,t)=>Qi(e,t,o):Qi:n.numeric?Ji:Xi},decode:e=>e.replace($i,((e,t)=>t?(t="x"===t.charAt(0).toLowerCase()?parseInt(t.substr(1),16):parseInt(t,10))>65535?(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t))):Wi[t]||String.fromCharCode(t):Gi[e]||Ki[e]||(e=>{const t=bo("div").dom;return t.innerHTML=e,t.textContent||t.innerText||e})(e)))},ts=(e,t)=>(e=Vt.trim(e))?e.split(t||" "):[],os=e=>new RegExp("^"+e.replace(/([?+*])/g,".$1")+"$"),ns={},rs=Vt.makeMap,is=Vt.each,ss=Vt.extend,as=Vt.explode,ls=(e,t={})=>{const o=rs(e," ",rs(e.toUpperCase()," "));return ss(o,t)},cs=e=>ls("td th li dt dd figcaption caption details summary",e.getTextBlockElements()),ds=(e,t)=>{if(e){const o={};return m(e)&&(e={"*":e}),is(e,((e,n)=>{o[n]=o[n.toUpperCase()]="map"===t?rs(e,/[, ]/):as(e,/[, ]/)})),o}},us=(e={})=>{var t;const o={},n={};let r=[];const i={},s={},a=(t,o,n)=>{const r=e[t];if(r)return rs(r,/[, ]/,rs(r.toUpperCase(),/[, ]/));{let e=ns[t];return e||(e=ls(o,n),ns[t]=e),e}},l=null!==(t=e.schema)&&void 0!==t?t:"html5",c=(e=>{const{globalAttributes:t,phrasingContent:o,flowContent:n}=(e=>{let t,o,n,r;return t="id accesskey class dir lang style tabindex title role",o="address blockquote div dl fieldset form h1 h2 h3 h4 h5 h6 hr menu ol p pre table ul",n="a abbr b bdo br button cite code del dfn em embed i iframe img input ins kbd label map noscript object q s samp script select small span strong sub sup textarea u var #text #comment","html4"!==e&&(t+=" contenteditable contextmenu draggable dropzone hidden spellcheck translate",o+=" article aside details dialog figure main header footer hgroup section nav a ins del canvas map",n+=" audio canvas command datalist mark meter output picture progress time wbr video ruby bdi keygen"),"html5-strict"!==e&&(t+=" xml:lang",n=[n,"acronym applet basefont big font strike tt"].join(" "),o=[o,"center dir isindex noframes"].join(" "),r=[o,n].join(" ")),r=r||[o,n].join(" "),{globalAttributes:t,blockContent:o,phrasingContent:n,flowContent:r}})(e),r={},i=(e,o="",n="")=>{const i=ts(n),s=ts(e);let a=s.length;for(;a--;){const e=ts([t,o].join(" "));r[s[a]]={attributes:se(e,O({})),attributesOrder:e,children:se(i,O({}))}}},s=(e,t)=>{const o=ts(e),n=ts(t);let i=o.length;for(;i--;){const e=r[o[i]];for(let t=0,o=n.length;t{i(e,"",o)})),W(ts("center dir isindex noframes"),(e=>{i(e,"",n)}))),i("html","manifest","head body"),i("head","","base command link meta noscript script style title"),i("title hr noscript br"),i("base","href target"),i("link","href rel media hreflang type sizes hreflang"),i("meta","name http-equiv content charset"),i("style","media type scoped"),i("script","src async defer type charset"),i("body","onafterprint onbeforeprint onbeforeunload onblur onerror onfocus onhashchange onload onmessage onoffline ononline onpagehide onpageshow onpopstate onresize onscroll onstorage onunload",n),i("dd div","",n),i("address dt caption","","html4"===e?o:n),i("h1 h2 h3 h4 h5 h6 pre p abbr code var samp kbd sub sup i b u bdo span legend em strong small s cite dfn","",o),i("blockquote","cite",n),i("ol","reversed start type","li"),i("ul","","li"),i("li","value",n),i("dl","","dt dd"),i("a","href target rel media hreflang type","html4"===e?o:n),i("q","cite",o),i("ins del","cite datetime",n),i("img","src sizes srcset alt usemap ismap width height"),i("iframe","src name width height",n),i("embed","src type width height"),i("object","data type typemustmatch name usemap form width height",[n,"param"].join(" ")),i("param","name value"),i("map","name",[n,"area"].join(" ")),i("area","alt coords shape href target rel media hreflang type"),i("table","border","caption colgroup thead tfoot tbody tr"+("html4"===e?" col":"")),i("colgroup","span","col"),i("col","span"),i("tbody thead tfoot","","tr"),i("tr","","td th"),i("td","colspan rowspan headers",n),i("th","colspan rowspan headers scope abbr",n),i("form","accept-charset action autocomplete enctype method name novalidate target",n),i("fieldset","disabled form name",[n,"legend"].join(" ")),i("label","form for",o),i("input","accept alt autocomplete checked dirname disabled form formaction formenctype formmethod formnovalidate formtarget height list max maxlength min multiple name pattern readonly required size src step type value width"),i("button","disabled form formaction formenctype formmethod formnovalidate formtarget name type value","html4"===e?n:o),i("select","disabled form multiple name required size","option optgroup"),i("optgroup","disabled label","option"),i("option","disabled label selected value"),i("textarea","cols dirname disabled form maxlength name readonly required rows wrap"),i("menu","type label",[n,"li"].join(" ")),i("noscript","",n),"html4"!==e&&(i("wbr"),i("ruby","",[o,"rt rp"].join(" ")),i("figcaption","",n),i("mark rt rp summary bdi","",o),i("canvas","width height",n),i("video","src crossorigin poster preload autoplay mediagroup loop muted controls width height buffered",[n,"track source"].join(" ")),i("audio","src crossorigin preload autoplay mediagroup loop muted controls buffered volume",[n,"track source"].join(" ")),i("picture","","img source"),i("source","src srcset type media sizes"),i("track","kind src srclang label default"),i("datalist","",[o,"option"].join(" ")),i("article section nav aside main header footer","",n),i("hgroup","","h1 h2 h3 h4 h5 h6"),i("figure","",[n,"figcaption"].join(" ")),i("time","datetime",o),i("dialog","open",n),i("command","type label icon disabled checked radiogroup command"),i("output","for form name",o),i("progress","value max",o),i("meter","value min max low high optimum",o),i("details","open",[n,"summary"].join(" ")),i("keygen","autofocus challenge disabled form keytype name")),"html5-strict"!==e&&(s("script","language xml:space"),s("style","xml:space"),s("object","declare classid code codebase codetype archive standby align border hspace vspace"),s("embed","align name hspace vspace"),s("param","valuetype type"),s("a","charset name rev shape coords"),s("br","clear"),s("applet","codebase archive code object alt name width height align hspace vspace"),s("img","name longdesc align border hspace vspace"),s("iframe","longdesc frameborder marginwidth marginheight scrolling align"),s("font basefont","size color face"),s("input","usemap align"),s("select"),s("textarea"),s("h1 h2 h3 h4 h5 h6 div p legend caption","align"),s("ul","type compact"),s("li","type"),s("ol dl menu dir","compact"),s("pre","width xml:space"),s("hr","align noshade size width"),s("isindex","prompt"),s("table","summary width frame rules cellspacing cellpadding align bgcolor"),s("col","width align char charoff valign"),s("colgroup","width align char charoff valign"),s("thead","align char charoff valign"),s("tr","align char charoff valign bgcolor"),s("th","axis align char charoff valign nowrap bgcolor width height"),s("form","accept"),s("td","abbr axis scope align char charoff valign nowrap bgcolor width height"),s("tfoot","align char charoff valign"),s("tbody","align char charoff valign"),s("area","nohref"),s("body","background bgcolor text link vlink alink")),"html4"!==e&&(s("input button select textarea","autofocus"),s("input textarea","placeholder"),s("a","download"),s("link script img","crossorigin"),s("img","loading"),s("iframe","sandbox seamless allow allowfullscreen loading")),"html4"!==e&&W([r.video,r.audio],(e=>{delete e.children.audio,delete e.children.video})),W(ts("a form meter progress dfn"),(e=>{r[e]&&delete r[e].children[e]})),delete r.caption.children.table,delete r.script,r})(l);!1===e.verify_html&&(e.valid_elements="*[*]");const d=ds(e.valid_styles),u=ds(e.invalid_styles,"map"),h=ds(e.valid_classes,"map"),m=a("whitespace_elements","pre script noscript style textarea video audio iframe object code"),p=a("self_closing_elements","colgroup dd dt li option p td tfoot th thead tr"),g=a("void_elements","area base basefont br col frame hr img input isindex link meta param embed source wbr track"),f=a("boolean_attributes","checked compact declare defer disabled ismap multiple nohref noresize noshade nowrap readonly selected autoplay loop controls allowfullscreen"),v="td th iframe video audio object script code",b=a("non_empty_elements",v+" pre",g),y=a("move_caret_before_on_enter_elements",v+" table",g),w=a("text_block_elements","h1 h2 h3 h4 h5 h6 p div address pre form blockquote center dir fieldset header footer article section hgroup aside main nav figure"),_=a("block_elements","hr table tbody thead tfoot th tr td li ol ul caption dl dt dd noscript menu isindex option datalist select optgroup figcaption details summary",w),x=a("text_inline_elements","span strong b em i font s strike u var cite dfn code mark q sup sub samp"),C=a("transparent_elements","a ins del canvas map");is("script noscript iframe noframes noembed title style textarea xmp plaintext".split(" "),(e=>{s[e]=new RegExp(""+e+"[^>]*>","gi")}));const k=e=>{const t=F.from(o["@"]),n=/[*?+]/;W(((e,t)=>{const o=/^([#+\-])?([^\[!\/]+)(?:\/([^\[!]+))?(?:(!?)\[([^\]]+)])?$/;return oe(ts(t,","),(t=>{const n=o.exec(t);if(n){const t=n[1],o=n[2],r=n[3],i=n[4],s=n[5],a={attributes:{},attributesOrder:[]};if(e.each((e=>((e,t)=>{ge(e.attributes,((e,o)=>{t.attributes[o]=e})),t.attributesOrder.push(...e.attributesOrder)})(e,a))),"#"===t?a.paddEmpty=!0:"-"===t&&(a.removeEmpty=!0),"!"===i&&(a.removeEmptyAttrs=!0),s&&((e,t)=>{const o=/^([!\-])?(\w+[\\:]:\w+|[^=~<]+)?(?:([=~<])(.*))?$/,n=/[*?+]/,{attributes:r,attributesOrder:i}=t;W(ts(e,"|"),(e=>{const s=o.exec(e);if(s){const e={},o=s[1],a=s[2].replace(/[\\:]:/g,":"),l=s[3],c=s[4];if("!"===o&&(t.attributesRequired=t.attributesRequired||[],t.attributesRequired.push(a),e.required=!0),"-"===o)return delete r[a],void i.splice(Vt.inArray(i,a),1);if(l&&("="===l?(t.attributesDefault=t.attributesDefault||[],t.attributesDefault.push({name:a,value:c}),e.defaultValue=c):"~"===l?(t.attributesForced=t.attributesForced||[],t.attributesForced.push({name:a,value:c}),e.forcedValue=c):"<"===l&&(e.validValues=Vt.makeMap(c,"?"))),n.test(a)){const o=e;t.attributePatterns=t.attributePatterns||[],o.pattern=os(a),t.attributePatterns.push(o)}else r[a]||i.push(a),r[a]=e}}))})(s,a),r&&(a.outputName=o),"@"===o){if(!e.isNone())return[];e=F.some(a)}return[r?{name:o,element:a,aliasName:r}:{name:o,element:a}]}return[]}))})(t,null!=e?e:""),(({name:e,element:t,aliasName:i})=>{if(i&&(o[i]=t),n.test(e)){const o=t;o.pattern=os(e),r.push(o)}else o[e]=t}))},S=e=>{r=[],W(me(o),(e=>{delete o[e]})),k(e)},T=e=>{delete ns.text_block_elements,delete ns.block_elements,W((e=>{const t=/^(~)?(.+)$/;return oe(ts(e,","),(e=>{const o=t.exec(e);if(o){const e="~"===o[1];return[{inline:e,cloneName:e?"span":"div",name:o[2]}]}return[]}))})(null!=e?e:""),(({inline:e,name:t,cloneName:r})=>{if(n[t]=n[r],i[t]=r,b[t.toUpperCase()]={},b[t]={},e||(_[t.toUpperCase()]={},_[t]={}),!o[t]){let e=o[r];e=ss({},e),delete e.removeEmptyAttrs,delete e.removeEmpty,o[t]=e}ge(n,((e,o)=>{e[r]&&(n[o]=e=ss({},n[o]),e[t]=e[r])}))}))},E=e=>{W((e=>{const t=/^([+\-]?)([A-Za-z0-9_\-.\u00b7\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u037d\u037f-\u1fff\u200c-\u200d\u203f-\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]+)\[([^\]]+)]$/;return oe(ts(e,","),(e=>{const o=t.exec(e);if(o){const e=o[1],t=e?(e=>"-"===e?"remove":"add")(e):"replace";return[{operation:t,name:o[2],validChildren:ts(o[3],"|")}]}return[]}))})(null!=e?e:""),(({operation:e,name:t,validChildren:o})=>{const r="replace"===e?{"#comment":{}}:n[t];W(o,(t=>{"remove"===e?delete r[t]:r[t]={}})),n[t]=r}))},M=e=>{const t=o[e];if(t)return t;let n=r.length;for(;n--;){const t=r[n];if(t.pattern.test(e))return t}};e.valid_elements?(S(e.valid_elements),is(c,((e,t)=>{n[t]=e.children}))):(is(c,((e,t)=>{o[t]={attributes:e.attributes,attributesOrder:e.attributesOrder},n[t]=e.children})),is(ts("strong/b em/i"),(e=>{const t=ts(e,"/");o[t[1]].outputName=t[0]})),is(x,((t,n)=>{o[n]&&(e.padd_empty_block_inline_children&&(o[n].paddInEmptyBlock=!0),o[n].removeEmpty=!0)})),is(ts("ol ul blockquote a table tbody"),(e=>{o[e]&&(o[e].removeEmpty=!0)})),is(ts("p h1 h2 h3 h4 h5 h6 th td pre div address caption li summary"),(e=>{o[e]&&(o[e].paddEmpty=!0)})),is(ts("span"),(e=>{o[e].removeEmptyAttrs=!0}))),T(e.custom_elements),E(e.valid_children),k(e.extended_valid_elements),E("+ol[ul|ol],+ul[ul|ol]"),is({dd:"dl",dt:"dl",li:"ul ol",td:"tr",th:"tr",tr:"tbody thead tfoot",tbody:"table",thead:"table",tfoot:"table",legend:"fieldset",area:"map",param:"video audio object"},((e,t)=>{o[t]&&(o[t].parentsRequired=ts(e))})),e.invalid_elements&&is(as(e.invalid_elements),(e=>{o[e]&&delete o[e]})),M("span")||k("span[!data-mce-type|*]");const A=O(d),B=O(u),N=O(h),R=O(f),V=O(_),D=O(w),P=O(x),I=O(Object.seal(g)),L=O(p),z=O(b),H=O(y),Z=O(m),j=O(C),U=O(Object.seal(s)),$=O(i);return{type:l,children:n,elements:o,getValidStyles:A,getValidClasses:N,getBlockElements:V,getInvalidStyles:B,getVoidElements:I,getTextBlockElements:D,getTextInlineElements:P,getBoolAttrs:R,getElementRule:M,getSelfClosingElements:L,getNonEmptyElements:z,getMoveCaretBeforeOnEnterElements:H,getWhitespaceElements:Z,getTransparentElements:j,getSpecialElements:U,isValidChild:(e,t)=>{const o=n[e.toLowerCase()];return!(!o||!o[t.toLowerCase()])},isValid:(e,t)=>{const o=M(e);if(o){if(!t)return!0;{if(o.attributes[t])return!0;const e=o.attributePatterns;if(e){let o=e.length;for(;o--;)if(e[o].pattern.test(t))return!0}}}return!1},getCustomElements:$,addValidElements:k,setValidElements:S,addCustomElements:T,addValidChildren:E}},hs=(e={},t)=>{const o=/(?:url(?:(?:\(\s*\"([^\"]+)\"\s*\))|(?:\(\s*\'([^\']+)\'\s*\))|(?:\(\s*([^)\s]+)\s*\))))|(?:\'([^\']+)\')|(?:\"([^\"]+)\")/gi,n=/\s*([^:]+):\s*([^;]+);?/g,r=/\s+$/,i={};let s,a;const l=gr;t&&(s=t.getValidStyles(),a=t.getInvalidStyles());const c="\\\" \\' \\; \\: ; : \ufeff".split(" ");for(let e=0;e{const s={};let a=!1;const c=e.url_converter,u=e.url_converter_scope||d,h=(e,t,o)=>{const n=s[e+"-top"+t];if(!n)return;const r=s[e+"-right"+t];if(!r)return;const i=s[e+"-bottom"+t];if(!i)return;const a=s[e+"-left"+t];if(!a)return;const l=[n,r,i,a];let c=l.length-1;for(;c--&&l[c]===l[c+1];);c>-1&&o||(s[e+t]=-1===c?l[0]:l.join(" "),delete s[e+"-top"+t],delete s[e+"-right"+t],delete s[e+"-bottom"+t],delete s[e+"-left"+t])},m=e=>{const t=s[e];if(!t)return;const o=t.indexOf(",")>-1?[t]:t.split(" ");let n=o.length;for(;n--;)if(o[n]!==o[0])return!1;return s[e]=o[0],!0},p=e=>(a=!0,i[e]),g=(e,t)=>(a&&(e=e.replace(/\uFEFF[0-9]/g,(e=>i[e]))),t||(e=e.replace(/\\([\'\";:])/g,"$1")),e),f=e=>String.fromCharCode(parseInt(e.slice(1),16)),v=e=>e.replace(/\\[0-9a-f]+/gi,f),b=(t,o,n,r,i,s)=>{if(i=i||s)return"'"+(i=g(i)).replace(/\'/g,"\\'")+"'";if(o=g(o||n||r||""),!e.allow_script_urls){const t=o.replace(/[\s\r\n]+/g,"");if(/(java|vb)script:/i.test(t))return"";if(!e.allow_svg_data_urls&&/^data:image\/svg/i.test(t))return""}return c&&(o=c.call(u,o,"style")),"url('"+o.replace(/\'/g,"\\'")+"')"};if(t){let i;for(t=(t=t.replace(/[\u0000-\u001F]/g,"")).replace(/\\[\"\';:\uFEFF]/g,p).replace(/\"[^\"]+\"|\'[^\']+\'/g,(e=>e.replace(/[;:]/g,p)));i=n.exec(t);){n.lastIndex=i.index+i[0].length;let t=i[1].replace(r,"").toLowerCase(),c=i[2].replace(r,"");if(t&&c){if(t=v(t),c=v(c),-1!==t.indexOf(l)||-1!==t.indexOf('"'))continue;if(!e.allow_script_urls&&("behavior"===t||/expression\s*\(|\/\*|\*\//.test(c)))continue;"font-weight"===t&&"700"===c?c="bold":"color"!==t&&"background-color"!==t||(c=c.toLowerCase()),c=c.replace(o,b),s[t]=a?g(c,!0):c}}h("border","",!0),h("border","-width"),h("border","-color"),h("border","-style"),h("padding",""),h("margin",""),"border",w="border-style",_="border-color",m(y="border-width")&&m(w)&&m(_)&&(s.border=s[y]+" "+s[w]+" "+s[_],delete s[y],delete s[w],delete s[_]),"medium none"===s.border&&delete s.border,"none"===s["border-image"]&&delete s["border-image"]}var y,w,_;return s},serialize:(e,t)=>{let o="";const n=(t,n)=>{const r=n[t];if(r)for(let t=0,n=r.length;t0?" ":"")+n+": "+i+";")}};return t&&s?(n("*",s),n(t,s)):ge(e,((e,n)=>{e&&((e,t)=>{if(!a||!t)return!0;let o=a["*"];return!(o&&o[e]||(o=a[t],o&&o[e]))})(n,t)&&(o+=(o.length>0?" ":"")+n+": "+e+";")})),o}};return d},ms={keyLocation:!0,layerX:!0,layerY:!0,returnValue:!0,webkitMovementX:!0,webkitMovementY:!0,keyIdentifier:!0,mozPressure:!0},ps=(e,t)=>{const o=null!=t?t:{};for(const t in e)ke(ms,t)||(o[t]=e[t]);return _(e.composedPath)&&(o.composedPath=()=>e.composedPath()),_(e.getModifierState)&&(o.getModifierState=t=>e.getModifierState(t)),o},gs=(e,t,o,n)=>{var r;const i=ps(t,n);return i.type=e,w(i.target)&&(i.target=null!==(r=i.srcElement)&&void 0!==r?r:o),(e=>w(e.preventDefault)||(e=>e instanceof Event||x(e.initEvent))(e))(t)&&(i.preventDefault=()=>{i.defaultPrevented=!0,i.isDefaultPrevented=I,x(t.preventDefault)&&t.preventDefault()},i.stopPropagation=()=>{i.cancelBubble=!0,i.isPropagationStopped=I,x(t.stopPropagation)&&t.stopPropagation()},i.stopImmediatePropagation=()=>{i.isImmediatePropagationStopped=I,i.stopPropagation()},(e=>e.isDefaultPrevented===I||e.isDefaultPrevented===P)(i)||(i.isDefaultPrevented=!0===i.defaultPrevented?I:P,i.isPropagationStopped=!0===i.cancelBubble?I:P,i.isImmediatePropagationStopped=P)),i},fs=/^(?:mouse|contextmenu)|click/,vs=(e,t,o,n)=>{e.addEventListener(t,o,n||!1)},bs=(e,t,o,n)=>{e.removeEventListener(t,o,n||!1)},ys=(e,t)=>{const o=gs(e.type,e,document,t);if((e=>_(e)&&fs.test(e.type))(e)&&y(e.pageX)&&!y(e.clientX)){const t=o.target.ownerDocument||document,n=t.documentElement,r=t.body,i=o;i.pageX=e.clientX+(n&&n.scrollLeft||r&&r.scrollLeft||0)-(n&&n.clientLeft||r&&r.clientLeft||0),i.pageY=e.clientY+(n&&n.scrollTop||r&&r.scrollTop||0)-(n&&n.clientTop||r&&r.clientTop||0)}return o},ws=(e,t,o)=>{const n=e.document,r={type:"ready"};if(o.domLoaded)return void t(r);const i=()=>{bs(e,"DOMContentLoaded",i),bs(e,"load",i),o.domLoaded||(o.domLoaded=!0,t(r)),e=null};"complete"===n.readyState||"interactive"===n.readyState&&n.body?i():vs(e,"DOMContentLoaded",i),o.domLoaded||vs(e,"load",i)};class _s{constructor(){this.domLoaded=!1,this.events={},this.count=1,this.expando="mce-data-"+(+new Date).toString(32),this.hasFocusIn="onfocusin"in document.documentElement,this.count=1}bind(e,t,o,n){const r=this;let i;const s=window,a=e=>{r.executeHandlers(ys(e||s.event),l)};if(!e||Qn(e)||or(e))return o;let l;e[r.expando]?l=e[r.expando]:(l=r.count++,e[r.expando]=l,r.events[l]={}),n=n||e;const c=t.split(" ");let d=c.length;for(;d--;){let t=c[d],u=a,h=!1,m=!1;"DOMContentLoaded"===t&&(t="ready"),r.domLoaded&&"ready"===t&&"complete"===e.readyState?o.call(n,ys({type:t})):(r.hasFocusIn||"focusin"!==t&&"focusout"!==t||(h=!0,m="focusin"===t?"focus":"blur",u=e=>{const t=ys(e||s.event);t.type="focus"===t.type?"focusin":"focusout",r.executeHandlers(t,l)}),i=r.events[l][t],i?"ready"===t&&r.domLoaded?o(ys({type:t})):i.push({func:o,scope:n}):(r.events[l][t]=i=[{func:o,scope:n}],i.fakeName=m,i.capture=h,i.nativeHandler=u,"ready"===t?ws(e,u,r):vs(e,m||t,u,h)))}return e=i=null,o}unbind(e,t,o){if(!e||Qn(e)||or(e))return this;const n=e[this.expando];if(n){let r=this.events[n];if(t){const n=t.split(" ");let i=n.length;for(;i--;){const t=n[i],s=r[t];if(s){if(o){let e=s.length;for(;e--;)if(s[e].func===o){const o=s.nativeHandler,n=s.fakeName,i=s.capture,a=s.slice(0,e).concat(s.slice(e+1));a.nativeHandler=o,a.fakeName=n,a.capture=i,r[t]=a}}o&&0!==s.length||(delete r[t],bs(e,s.fakeName||t,s.nativeHandler,s.capture))}}}else ge(r,((t,o)=>{bs(e,t.fakeName||o,t.nativeHandler,t.capture)})),r={};for(const e in r)if(ke(r,e))return this;delete this.events[n];try{delete e[this.expando]}catch(t){e[this.expando]=null}}return this}fire(e,t,o){return this.dispatch(e,t,o)}dispatch(e,t,o){if(!e||Qn(e)||or(e))return this;const n=ys({type:t,target:e},o);do{const t=e[this.expando];t&&this.executeHandlers(n,t),e=e.parentNode||e.ownerDocument||e.defaultView||e.parentWindow}while(e&&!n.isPropagationStopped());return this}clean(e){if(!e||Qn(e)||or(e))return this;if(e[this.expando]&&this.unbind(e),e.getElementsByTagName||(e=e.document),e&&e.getElementsByTagName){this.unbind(e);const t=e.getElementsByTagName("*");let o=t.length;for(;o--;)(e=t[o])[this.expando]&&this.unbind(e)}return this}destroy(){this.events={}}cancel(e){return e&&(e.preventDefault(),e.stopImmediatePropagation()),!1}executeHandlers(e,t){const o=this.events[t],n=o&&o[e.type];if(n)for(let t=0,o=n.length;t{w(o)||""===o?ro(e,t):Qt(e,t,o)},Es=e=>e.replace(/[A-Z]/g,(e=>"-"+e.toLowerCase())),Os=(e,t)=>{let o=0;if(e)for(let n=e.nodeType,r=e.previousSibling;r;r=r.previousSibling){const e=r.nodeType;(!t||!Qn(r)||e!==n&&r.data.length)&&(o++,n=e)}return o},Ms=(e,t)=>{const o=to(t,"style"),n=e.serialize(e.parse(o),jt(t));Ts(t,ks,n)},As=(e,t,o)=>{const n=Es(t);w(o)||""===o?pn(e,n):ln(e,n,((e,t)=>C(e)?ke(Ss,t)?e+"":e+"px":e)(o,n))},Bs=(e,t={})=>{const o={},n=window,r={};let i=0;const s=Ii.forElement(wo(e),{contentCssCors:t.contentCssCors,referrerPolicy:t.referrerPolicy}),a=[],l=t.schema?t.schema:us({}),c=hs({url_converter:t.url_converter,url_converter_scope:t.url_converter_scope},t.schema),d=t.ownEvents?new _s:_s.Event,u=l.getBlockElements(),h=t=>t&&e&&m(t)?e.getElementById(t):t,p=e=>{const t=h(e);return _(t)?wo(t):null},g=(e,t,o="")=>{let n;const r=p(e);if(_(r)&&qt(r)){const e=Y[t];n=e&&e.get?e.get(r.dom,t):to(r,t)}return _(n)?n:o},v=e=>{const t=h(e);return w(t)?[]:t.attributes},b=(e,o,n)=>{B(e,(e=>{if(Un(e)){const r=wo(e),i=""===n?null:n,s=to(r,o),a=Y[o];a&&a.set?a.set(r.dom,i,o):Ts(r,o,i),s!==i&&t.onSetAttrib&&t.onSetAttrib({attrElm:r.dom,attrName:o,attrValue:i})}}))},y=()=>t.root_element||e.body,C=(t,o)=>((e,t,o)=>{let n=0,r=0;const i=e.ownerDocument;if(o=o||e,t){if(o===e&&t.getBoundingClientRect&&"static"===dn(wo(e),"position")){const o=t.getBoundingClientRect();return n=o.left+(i.documentElement.scrollLeft||e.scrollLeft)-i.documentElement.clientLeft,r=o.top+(i.documentElement.scrollTop||e.scrollTop)-i.documentElement.clientTop,{x:n,y:r}}let s=t;for(;s&&s!==o&&s.nodeType&&!Di(s,o);){const e=s;n+=e.offsetLeft||0,r+=e.offsetTop||0,s=e.offsetParent}for(s=t.parentNode;s&&s!==o&&s.nodeType&&!Di(s,o);)n-=s.scrollLeft||0,r-=s.scrollTop||0,s=s.parentNode;r+=(e=>Ri.isFirefox()&&"table"===jt(e)?Vi(Io(e)).filter((e=>"caption"===jt(e))).bind((e=>Vi(Po(e)).map((t=>{const o=t.dom.offsetTop,n=e.dom.offsetTop,r=e.dom.offsetHeight;return o<=n?-r:0})))).getOr(0):0)(wo(t))}return{x:n,y:r}})(e.body,h(t),o),k=(e,t,o)=>{const n=h(e);if(!w(n)&&Un(n))return o?dn(wo(n),Es(t)):("float"===(t=t.replace(/-(\D)/g,((e,t)=>t.toUpperCase())))&&(t="cssFloat"),n.style?n.style[t]:void 0)},T=e=>{const t=h(e);if(!t)return{w:0,h:0};let o=k(t,"width"),n=k(t,"height");return o&&-1!==o.indexOf("px")||(o="0"),n&&-1!==n.indexOf("px")||(n="0"),{w:parseInt(o,10)||t.offsetWidth||t.clientWidth,h:parseInt(n,10)||t.offsetHeight||t.clientHeight}},E=(e,t)=>{if(!e)return!1;const o=f(e)?e:[e];return U(o,(e=>Co(wo(e),t)))},M=(e,t,o,n)=>{const r=[];let i=h(e);n=void 0===n;const s=o||("BODY"!==y().nodeName?y().parentNode:null);if(m(t))if("*"===t)t=Un;else{const e=t;t=t=>E(t,e)}for(;i&&!(i===s||w(i.nodeType)||nr(i)||rr(i));){if(!t||t(i)){if(!n)return[i];r.push(i)}i=i.parentNode}return n?r:null},A=(e,t,o)=>{let n=t;if(e){m(t)&&(n=e=>E(e,t));for(let t=e[o];t;t=t[o])if(x(n)&&n(t))return t}return null},B=function(e,t,o){const n=null!=o?o:this;if(f(e)){const o=[];return xs(e,((e,r)=>{const i=h(e);i&&o.push(t.call(n,i,r))})),o}{const o=h(e);return!!o&&t.call(n,o)}},N=(e,t)=>{B(e,(e=>{ge(t,((t,o)=>{b(e,o,t)}))}))},R=(e,t)=>{B(e,(e=>{const o=wo(e);Tn(o,t)}))},V=(t,o,n,r,i)=>B(t,(t=>{const s=m(o)?e.createElement(o):o;return _(n)&&N(s,n),r&&(!m(r)&&r.nodeType?s.appendChild(r):m(r)&&R(s,r)),i?s:t.appendChild(s)})),D=(t,o,n)=>V(e.createElement(t),t,o,n,!0),P=es.encodeAllRaw,I=(e,t)=>B(e,(e=>{const o=wo(e);return t&&W(Io(o),(e=>{Gt(e)&&0===e.dom.length?xn(e):gn(o,e)})),xn(o),o.dom})),F=(e,t,o)=>{B(e,(e=>{if(Un(e)){const n=wo(e),r=t.split(" ");W(r,(e=>{_(o)?(o?ho:po)(n,e):((e,t)=>{const o=ao(e)?e.dom.classList.toggle(t):((e,t)=>j(lo(e),t)?uo(e,t):co(e,t))(e,t);mo(e)})(n,e)}))}}))},L=(e,t,o)=>B(t,(n=>{var r;const i=f(t)?e.cloneNode(!0):e;return o&&xs(Cs(n.childNodes),(e=>{i.appendChild(e)})),null===(r=n.parentNode)||void 0===r||r.replaceChild(i,n),n})),z=e=>{if(Un(e)){const t="a"===e.nodeName.toLowerCase()&&!g(e,"href")&&g(e,"id");if(g(e,"name")||g(e,"data-mce-bookmark")||t)return!0}return!1},H=()=>e.createRange(),Z=(o,r,i,s)=>{if(f(o)){let e=o.length;const t=[];for(;e--;)t[e]=Z(o[e],r,i,s);return t}return!t.collect||o!==e&&o!==n||a.push([o,r,i,s]),d.bind(o,r,i,s||G)},$=(t,o,r)=>{if(f(t)){let e=t.length;const n=[];for(;e--;)n[e]=$(t[e],o,r);return n}if(a.length>0&&(t===e||t===n)){let e=a.length;for(;e--;){const[n,i,s]=a[e];t!==n||o&&o!==i||r&&r!==s||d.unbind(n,i,s)}}return d.unbind(t,o,r)},q=e=>{if(e&&Un(e)){const t=e.getAttribute("data-mce-contenteditable");return t&&"inherit"!==t?t:"inherit"!==e.contentEditable?e.contentEditable:null}return null},G={doc:e,settings:t,win:n,files:r,stdMode:!0,boxModel:!0,styleSheetLoader:s,boundEvents:a,styles:c,schema:l,events:d,isBlock:e=>m(e)?ke(u,e):Un(e)&&(ke(u,e.nodeName)||Ai(l,e)),root:null,clone:(e,t)=>e.cloneNode(t),getRoot:y,getViewPort:e=>{const t=In(e);return{x:t.x,y:t.y,w:t.width,h:t.height}},getRect:e=>{const t=h(e),o=C(t),n=T(t);return{x:o.x,y:o.y,w:n.w,h:n.h}},getSize:T,getParent:(e,t,o)=>{const n=M(e,t,o,!1);return n&&n.length>0?n[0]:null},getParents:M,get:h,getNext:(e,t)=>A(e,t,"nextSibling"),getPrev:(e,t)=>A(e,t,"previousSibling"),select:(o,n)=>{var r,i;const s=null!==(i=null!==(r=h(n))&&void 0!==r?r:t.root_element)&&void 0!==i?i:e;return x(s.querySelectorAll)?ue(s.querySelectorAll(o)):[]},is:E,add:V,create:D,createHTML:(e,t,o="")=>{let n="<"+e;for(const e in t)Se(t,e)&&(n+=" "+e+'="'+P(t[e])+'"');return Ke(o)&&ke(l.getVoidElements(),e)?n+" />":n+">"+o+""+e+">"},createFragment:t=>{const o=e.createElement("div"),n=e.createDocumentFragment();let r;for(n.appendChild(o),t&&(o.innerHTML=t);r=o.firstChild;)n.appendChild(r);return n.removeChild(o),n},remove:I,setStyle:(e,o,n)=>{B(e,(e=>{const r=wo(e);As(r,o,n),t.update_styles&&Ms(c,r)}))},getStyle:k,setStyles:(e,o)=>{B(e,(e=>{const n=wo(e);ge(o,((e,t)=>{As(n,t,e)})),t.update_styles&&Ms(c,n)}))},removeAllAttribs:e=>B(e,(e=>{const t=e.attributes;for(let o=t.length-1;o>=0;o--)e.removeAttributeNode(t.item(o))})),setAttrib:b,setAttribs:N,getAttrib:g,getPos:C,parseStyle:e=>c.parse(e),serializeStyle:(e,t)=>c.serialize(e,t),addStyle:t=>{if(G!==Bs.DOM&&e===document){if(o[t])return;o[t]=!0}let n=e.getElementById("mceDefaultStyles");if(!n){n=e.createElement("style"),n.id="mceDefaultStyles",n.type="text/css";const t=e.head;t.firstChild?t.insertBefore(n,t.firstChild):t.appendChild(n)}n.styleSheet?n.styleSheet.cssText+=t:n.appendChild(e.createTextNode(t))},loadCSS:e=>{e||(e=""),W(e.split(","),(e=>{r[e]=!0,s.load(e).catch(S)}))},addClass:(e,t)=>{F(e,t,!0)},removeClass:(e,t)=>{F(e,t,!1)},hasClass:(e,t)=>{const o=p(e),n=t.split(" ");return _(o)&&ne(n,(e=>go(o,e)))},toggleClass:F,show:e=>{B(e,(e=>pn(wo(e),"display")))},hide:e=>{B(e,(e=>ln(wo(e),"display","none")))},isHidden:e=>{const t=p(e);return _(t)&&Dt(hn(t,"display"),"none")},uniqueId:e=>(e||"mce_")+i++,setHTML:R,getOuterHTML:e=>{const t=p(e);return _(t)?Un(t.dom)?t.dom.outerHTML:(e=>{const t=bo("div"),o=wo(e.dom.cloneNode(!0));return bn(t,o),Sn(t)})(t):""},setOuterHTML:(e,t)=>{B(e,(e=>{Un(e)&&(e.outerHTML=t)}))},decode:es.decode,encode:P,insertAfter:(e,t)=>{const o=h(t);return B(e,(e=>{const t=null==o?void 0:o.parentNode,n=null==o?void 0:o.nextSibling;return t&&(n?t.insertBefore(e,n):t.appendChild(e)),e}))},replace:L,rename:(e,t)=>{if(e.nodeName!==t.toUpperCase()){const o=D(t);return xs(v(e),(t=>{b(o,t.nodeName,g(e,t.nodeName))})),L(o,e,!0),o}return e},findCommonAncestor:(e,t)=>{let o=e;for(;o;){let e=t;for(;e&&o!==e;)e=e.parentNode;if(o===e)break;o=o.parentNode}return!o&&e.ownerDocument?e.ownerDocument.documentElement:o},run:B,getAttribs:v,isEmpty:(e,t,o)=>{let n=0;if(z(e))return!1;const r=e.firstChild;if(r){const i=new Hn(r,e),s=l?l.getWhitespaceElements():{},a=t||(l?l.getNonEmptyElements():null);let c=r;do{if(Un(c)){const e=c.getAttribute("data-mce-bogus");if(e){c=i.next("all"===e);continue}const t=c.nodeName.toLowerCase();if(a&&a[t]){if("br"===t){n++,c=i.next();continue}return!1}if(z(c))return!1}if(or(c))return!1;if(Qn(c)&&!di(c.data)&&(!(null==o?void 0:o.includeZwsp)||!ui(c.data)))return!1;if(Qn(c)&&c.parentNode&&s[c.parentNode.nodeName]&&di(c.data))return!1;c=i.next()}while(c)}return n<=1},createRng:H,nodeIndex:Os,split:(e,t,o)=>{let n,r,i=H();if(e&&t&&e.parentNode&&t.parentNode){const s=e.parentNode;return i.setStart(s,Os(e)),i.setEnd(t.parentNode,Os(t)),n=i.extractContents(),i=H(),i.setStart(t.parentNode,Os(t)+1),i.setEnd(s,Os(e)+1),r=i.extractContents(),s.insertBefore(zi(G,n),e),o?s.insertBefore(o,e):s.insertBefore(t,e),s.insertBefore(zi(G,r),e),I(e),o||t}},bind:Z,unbind:$,fire:(e,t,o)=>d.dispatch(e,t,o),dispatch:(e,t,o)=>d.dispatch(e,t,o),getContentEditable:q,getContentEditableParent:e=>{const t=y();let o=null;for(let n=e;n&&n!==t&&(o=q(n),null===o);n=n.parentNode);return o},isEditable:e=>{if(_(e)){const t=Un(e)?e:e.parentElement;return _(t)&&nn(wo(t))}return!1},destroy:()=>{if(a.length>0){let e=a.length;for(;e--;){const[t,o,n]=a[e];d.unbind(t,o,n)}}ge(r,((e,t)=>{s.unload(t),delete r[t]}))},isChildOf:(e,t)=>e===t||t.contains(e),dumpRng:e=>"startContainer: "+e.startContainer.nodeName+", startOffset: "+e.startOffset+", endContainer: "+e.endContainer.nodeName+", endOffset: "+e.endOffset},Y=((e,t,o)=>{const n=t.keep_values,r={set:(e,n,r)=>{const i=wo(e);x(t.url_converter)&&_(n)&&(n=t.url_converter.call(t.url_converter_scope||o(),String(n),r,e)),Ts(i,"data-mce-"+r,n),Ts(i,r,n)},get:(e,t)=>{const o=wo(e);return to(o,"data-mce-"+t)||to(o,t)}},i={style:{set:(t,o)=>{const r=wo(t);n&&Ts(r,ks,o),ro(r,"style"),m(o)&&cn(r,e.parse(o))},get:t=>{const o=wo(t),n=to(o,ks)||to(o,"style");return e.serialize(e.parse(n),jt(o))}}};return n&&(i.href=i.src=r),i})(c,t,O(G));return G};Bs.DOM=Bs(document),Bs.nodeIndex=Os;const Ns=Bs.DOM;class Rs{constructor(e={}){this.states={},this.queue=[],this.scriptLoadedCallbacks={},this.queueLoadedCallbacks=[],this.loading=!1,this.settings=e}_setReferrerPolicy(e){this.settings.referrerPolicy=e}loadScript(e){return new Promise(((t,o)=>{const n=Ns;let r;const i=()=>{n.remove(s),r&&(r.onerror=r.onload=r=null)},s=n.uniqueId();r=document.createElement("script"),r.id=s,r.type="text/javascript",r.src=Vt._addCacheSuffix(e),this.settings.referrerPolicy&&n.setAttrib(r,"referrerpolicy",this.settings.referrerPolicy),r.onload=()=>{i(),t()},r.onerror=()=>{i(),o("Failed to load script: "+e)},(document.getElementsByTagName("head")[0]||document.body).appendChild(r)}))}isDone(e){return 2===this.states[e]}markDone(e){this.states[e]=2}add(e){const t=this;return t.queue.push(e),void 0===t.states[e]&&(t.states[e]=0),new Promise(((o,n)=>{t.scriptLoadedCallbacks[e]||(t.scriptLoadedCallbacks[e]=[]),t.scriptLoadedCallbacks[e].push({resolve:o,reject:n})}))}load(e){return this.add(e)}remove(e){delete this.states[e],delete this.scriptLoadedCallbacks[e]}loadQueue(){const e=this.queue;return this.queue=[],this.loadScripts(e)}loadScripts(e){const t=this,o=(e,o)=>{Ce(t.scriptLoadedCallbacks,o).each((t=>{W(t,(t=>t[e](o)))})),delete t.scriptLoadedCallbacks[o]},n=e=>{const t=Y(e,(e=>"rejected"===e.status));return t.length>0?Promise.reject(oe(t,(({reason:e})=>f(e)?e:[e]))):Promise.resolve()},r=e=>Promise.allSettled($(e,(e=>2===t.states[e]?(o("resolve",e),Promise.resolve()):3===t.states[e]?(o("reject",e),Promise.reject(e)):(t.states[e]=1,t.loadScript(e).then((()=>{t.states[e]=2,o("resolve",e);const i=t.queue;return i.length>0?(t.queue=[],r(i).then(n)):Promise.resolve()}),(()=>(t.states[e]=3,o("reject",e),Promise.reject(e)))))))),i=e=>(t.loading=!0,r(e).then((e=>{t.loading=!1;const o=t.queueLoadedCallbacks.shift();return F.from(o).each(D),n(e)}))),s=Te(e);return t.loading?new Promise(((e,o)=>{t.queueLoadedCallbacks.push((()=>{i(s).then(e,o)}))})):i(s)}}Rs.ScriptLoader=new Rs;const Vs=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},Ds={},Ps=Vs("en"),Is=()=>Ce(Ds,Ps.get()),Fs={getData:()=>fe(Ds,(e=>({...e}))),setCode:e=>{e&&Ps.set(e)},getCode:()=>Ps.get(),add:(e,t)=>{let o=Ds[e];o||(Ds[e]=o={});const n=$(me(t),(e=>e.toLowerCase()));ge(t,((e,r)=>{const i=r.toLowerCase();i!==r&&((e,t)=>{const o=e.indexOf(t);return-1!==o&&e.indexOf(t,o+1)>o})(n,i)?(ke(t,i)||(o[i]=e),o[r]=e):o[i]=e}))},translate:e=>{const t=Is().getOr({}),o=e=>x(e)?Object.prototype.toString.call(e):n(e)?"":""+e,n=e=>""===e||null==e,r=e=>{const n=o(e);return ke(t,n)?o(t[n]):Ce(t,n.toLowerCase()).map(o).getOr(n)},i=e=>e.replace(/{context:\w+}$/,"");if(n(e))return"";if(p(s=e)&&ke(s,"raw"))return o(e.raw);var s;if((e=>f(e)&&e.length>1)(e)){const t=e.slice(1);return i(r(e[0]).replace(/\{([0-9]+)\}/g,((e,n)=>ke(t,n)?o(t[n]):e)))}return i(r(e))},isRtl:()=>Is().bind((e=>Ce(e,"_dir"))).exists((e=>"rtl"===e)),hasCode:e=>ke(Ds,e)},Ls=()=>{const e=[],t={},o={},n=[],r=(e,t)=>{const o=Y(n,(o=>o.name===e&&o.state===t));W(o,(e=>e.resolve()))},i=e=>ke(t,e),s=(e,o)=>{const n=Fs.getCode();!n||o&&-1===(","+(o||"")+",").indexOf(","+n+",")||Rs.ScriptLoader.add(t[e]+"/langs/"+n+".js")},a=(e,t="added")=>"added"===t&&(e=>ke(o,e))(e)||"loaded"===t&&i(e)?Promise.resolve():new Promise((o=>{n.push({name:e,state:t,resolve:o})}));return{items:e,urls:t,lookup:o,get:e=>{if(o[e])return o[e].instance},requireLangPack:(e,t)=>{!1!==Ls.languageLoad&&(i(e)?s(e,t):a(e,"loaded").then((()=>s(e,t))))},add:(t,n)=>(e.push(n),o[t]={instance:n},r(t,"added"),n),remove:e=>{delete t[e],delete o[e]},createUrl:(e,t)=>m(t)?m(e)?{prefix:"",resource:t,suffix:""}:{prefix:e.prefix,resource:t,suffix:e.suffix}:t,load:(e,n)=>{if(t[e])return Promise.resolve();let i=m(n)?n:n.prefix+n.resource+n.suffix;0!==i.indexOf("/")&&-1===i.indexOf("://")&&(i=Ls.baseURL+"/"+i),t[e]=i.substring(0,i.lastIndexOf("/"));const s=()=>(r(e,"loaded"),Promise.resolve());return o[e]?s():Rs.ScriptLoader.add(i).then(s)},waitFor:a}};Ls.languageLoad=!0,Ls.baseURL="",Ls.PluginManager=Ls(),Ls.ThemeManager=Ls(),Ls.ModelManager=Ls();const zs=e=>{const t=Vs(F.none()),o=()=>t.get().each((e=>clearInterval(e)));return{clear:()=>{o(),t.set(F.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:n=>{o(),t.set(F.some(setInterval(n,e)))}}},Hs=()=>{const e=(e=>{const t=Vs(F.none()),o=()=>t.get().each(e);return{clear:()=>{o(),t.set(F.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:e=>{o(),t.set(F.some(e))}}})(S);return{...e,on:t=>e.get().each(t)}},Zs=(e,t)=>{let o=null;return{cancel:()=>{v(o)||(clearTimeout(o),o=null)},throttle:(...n)=>{v(o)&&(o=setTimeout((()=>{o=null,e.apply(null,n)}),t))}}},js=(e,t)=>{let o=null;const n=()=>{v(o)||(clearTimeout(o),o=null)};return{cancel:n,throttle:(...r)=>{n(),o=setTimeout((()=>{o=null,e.apply(null,r)}),t)}}},Us=O("mce-annotation"),$s=O("data-mce-annotation"),Ws=O("data-mce-annotation-uid"),qs=O("data-mce-annotation-active"),Gs=O("data-mce-annotation-classes"),Ys=O("data-mce-annotation-attrs"),Ks=e=>t=>So(t,e),Xs=(e,t)=>{const o=e.selection.getRng(),n=wo(o.startContainer),r=wo(e.getBody()),i=t.fold((()=>"."+Us()),(e=>`[${$s()}="${e}"]`)),s=Fo(n,o.startOffset).getOr(n);return on(s,i,Ks(r)).bind((t=>oo(t,`${Ws()}`).bind((o=>oo(t,`${$s()}`).map((t=>{const n=Qs(e,o);return{uid:o,name:t,elements:n}}))))))},Js=(e,t)=>no(e,"data-mce-bogus")||zn(e,'[data-mce-bogus="all"]',Ks(t)),Qs=(e,t)=>{const o=wo(e.getBody()),n=Ln(o,`[${Ws()}="${t}"]`);return Y(n,(e=>!Js(e,o)))},ea=(e,t)=>{const o=wo(e.getBody()),n=Ln(o,`[${$s()}="${t}"]`),r={};return W(n,(e=>{if(!Js(e,o)){const t=to(e,Ws()),o=Ce(r,t).getOr([]);r[t]=o.concat([e])}})),r};let ta=0;const oa=e=>{const t=(new Date).getTime(),o=Math.floor(1e9*Math.random());return ta++,e+"_"+o+ta+String(t)},na=(e,t)=>wo(e.dom.cloneNode(t)),ra=e=>na(e,!1),ia=e=>na(e,!0),sa=(e,t,o=P)=>{const n=new Hn(e,t),r=e=>{let t;do{t=n[e]()}while(t&&!Qn(t)&&!o(t));return F.from(t).filter(Qn)};return{current:()=>F.from(n.current()).filter(Qn),next:()=>r("next"),prev:()=>r("prev"),prev2:()=>r("prev2")}},aa=(e,t)=>{const o=t||(t=>e.isBlock(t)||ir(t)||lr(t)),n=(e,t,o,r)=>{if(Qn(e)){const o=r(e,t,e.data);if(-1!==o)return F.some({container:e,offset:o})}return o().bind((e=>n(e.container,e.offset,o,r)))};return{backwards:(t,r,i,s)=>{const a=sa(t,null!=s?s:e.getRoot(),o);return n(t,r,(()=>a.prev().map((e=>({container:e,offset:e.length})))),i).getOrNull()},forwards:(t,r,i,s)=>{const a=sa(t,null!=s?s:e.getRoot(),o);return n(t,r,(()=>a.next().map((e=>({container:e,offset:0})))),i).getOrNull()}}},la=Math.round,ca=e=>e?{left:la(e.left),top:la(e.top),bottom:la(e.bottom),right:la(e.right),width:la(e.width),height:la(e.height)}:{left:0,top:0,bottom:0,right:0,width:0,height:0},da=(e,t)=>(e=ca(e),t||(e.left=e.left+e.width),e.right=e.left,e.width=0,e),ua=(e,t,o)=>e>=0&&e<=Math.min(t.height,o.height)/2,ha=(e,t)=>{const o=Math.min(t.height/2,e.height/2);return e.bottom-ot.bottom)&&ua(t.top-e.bottom,e,t)},ma=(e,t)=>e.top>t.bottom||!(e.bottom{const n=Math.max(Math.min(t,e.left+e.width),e.left),r=Math.max(Math.min(o,e.top+e.height),e.top);return Math.sqrt((t-n)*(t-n)+(o-r)*(o-r))},ga=e=>{const t=e.startContainer,o=e.startOffset;return t===e.endContainer&&t.hasChildNodes()&&e.endOffset===o+1?t.childNodes[o]:null},fa=(e,t)=>{if(Un(e)&&e.hasChildNodes()){const o=e.childNodes,n=((e,t,o)=>Math.min(Math.max(e,0),o))(t,0,o.length-1);return o[n]}return e},va=new RegExp("[̀-ͯ҃-҇҈-҉֑-ֽֿׁ-ׂׄ-ׇׅؐ-ًؚ-ٰٟۖ-ۜ۟-ۤۧ-۪ۨ-ܑۭܰ-݊ަ-ް߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣣ-ंऺ़ु-ै्॑-ॗॢ-ॣঁ়াু-ৄ্ৗৢ-ৣਁ-ਂ਼ੁ-ੂੇ-ੈੋ-੍ੑੰ-ੱੵઁ-ં઼ુ-ૅે-ૈ્ૢ-ૣଁ଼ାିୁ-ୄ୍ୖୗୢ-ୣஂாீ்ௗఀా-ీె-ైొ-్ౕ-ౖౢ-ౣಁ಼ಿೂೆೌ-್ೕ-ೖೢ-ೣഁാു-ൄ്ൗൢ-ൣ්ාි-ුූෟัิ-ฺ็-๎ັິ-ູົ-ຼ່-ໍ༘-ཱ༹༙༵༷-ཾྀ-྄྆-྇ྍ-ྗྙ-ྼ࿆ိ-ူဲ-့္-်ွ-ှၘ-ၙၞ-ၠၱ-ၴႂႅ-ႆႍႝ፝-፟ᜒ-᜔ᜲ-᜴ᝒ-ᝓᝲ-ᝳ឴-឵ិ-ួំ៉-៓៝᠋-᠍ᢩᤠ-ᤢᤧ-ᤨᤲ᤹-᤻ᨗ-ᨘᨛᩖᩘ-ᩞ᩠ᩢᩥ-ᩬᩳ-᩿᩼᪰-᪽᪾ᬀ-ᬃ᬴ᬶ-ᬺᬼᭂ᭫-᭳ᮀ-ᮁᮢ-ᮥᮨ-ᮩ᮫-ᮭ᯦ᯨ-ᯩᯭᯯ-ᯱᰬ-ᰳᰶ-᰷᳐-᳔᳒-᳢᳠-᳨᳭᳴᳸-᳹᷀-᷵᷼-᷿-⃐-⃜⃝-⃠⃡⃢-⃤⃥-⃰⳯-⵿⳱ⷠ-〪ⷿ-〭〮-゙〯-゚꙯꙰-꙲ꙴ-꙽ꚞ-ꚟ꛰-꛱ꠂ꠆ꠋꠥ-ꠦ꣄꣠-꣱ꤦ-꤭ꥇ-ꥑꦀ-ꦂ꦳ꦶ-ꦹꦼꧥꨩ-ꨮꨱ-ꨲꨵ-ꨶꩃꩌꩼꪰꪲ-ꪴꪷ-ꪸꪾ-꪿꫁ꫬ-ꫭ꫶ꯥꯨ꯭ﬞ︀-️︠-゙︯-゚]"),ba=e=>m(e)&&e.charCodeAt(0)>=768&&va.test(e),ya=Un,wa=si,_a=qn("display","block table"),xa=qn("float","left right"),Ca=((...e)=>t=>{for(let o=0;ot<0&&Un(e)&&e.hasChildNodes()?void 0:fa(e,t),Ma=e=>e?e.createRange():Bs.DOM.createRng(),Aa=e=>m(e)&&/[\r\n\t ]/.test(e),Ba=e=>!!e.setStart&&!!e.setEnd,Na=e=>{const t=e.startContainer,o=e.startOffset;if(Aa(e.toString())&&ka(t.parentNode)&&Qn(t)){const e=t.data;if(Aa(e[o-1])||Aa(e[o+1]))return!0}return!1},Ra=e=>0===e.left&&0===e.right&&0===e.top&&0===e.bottom,Va=e=>{var t;let o;const n=e.getClientRects();return o=n.length>0?ca(n[0]):ca(e.getBoundingClientRect()),!Ba(e)&&Ta(e)&&Ra(o)?(e=>{const t=e.ownerDocument,o=Ma(t),n=t.createTextNode(fr),r=e.parentNode;r.insertBefore(n,e),o.setStart(n,0),o.setEnd(n,1);const i=ca(o.getBoundingClientRect());return r.removeChild(n),i})(e):Ra(o)&&Ba(e)&&null!==(t=(e=>{const t=e.startContainer,o=e.endContainer,n=e.startOffset,r=e.endOffset;if(t===o&&Qn(o)&&0===n&&1===r){const t=e.cloneRange();return t.setEndAfter(o),Va(t)}return null})(e))&&void 0!==t?t:o},Da=(e,t)=>{const o=da(e,t);return o.width=1,o.right=o.left+1,o},Pa=(e,t,o)=>{const n=()=>(o||(o=(e=>{const t=[],o=e=>{var o,n;0!==e.height&&(t.length>0&&(o=e,n=t[t.length-1],o.left===n.left&&o.top===n.top&&o.bottom===n.bottom&&o.right===n.right)||t.push(e))},n=(e,t)=>{const n=Ma(e.ownerDocument);if(t0&&(n.setStart(e,t-1),n.setEnd(e,t),Na(n)||o(Da(Va(n),!1))),t{const o=Ma(e.ownerDocument);return o.setStart(e,t),o.setEnd(e,t),o},getClientRects:n,isVisible:()=>n().length>0,isAtStart:()=>(Sa(e),0===t),isAtEnd:()=>Sa(e)?t>=e.data.length:t>=e.childNodes.length,isEqual:o=>o&&e===o.container()&&t===o.offset(),getNode:o=>Oa(e,o?t-1:t)}};Pa.fromRangeStart=e=>Pa(e.startContainer,e.startOffset),Pa.fromRangeEnd=e=>Pa(e.endContainer,e.endOffset),Pa.after=e=>Pa(e.parentNode,Ea(e)+1),Pa.before=e=>Pa(e.parentNode,Ea(e)),Pa.isAbove=(e,t)=>It(ce(t.getClientRects()),de(e.getClientRects()),ha).getOr(!1),Pa.isBelow=(e,t)=>It(de(t.getClientRects()),ce(e.getClientRects()),ma).getOr(!1),Pa.isAtStart=e=>!!e&&e.isAtStart(),Pa.isAtEnd=e=>!!e&&e.isAtEnd(),Pa.isTextPosition=e=>!!e&&Qn(e.container()),Pa.isElementPosition=e=>!Pa.isTextPosition(e);const Ia=(e,t)=>{Qn(t)&&0===t.data.length&&e.remove(t)},Fa=(e,t,o)=>{rr(o)?((e,t,o)=>{const n=F.from(o.firstChild),r=F.from(o.lastChild);t.insertNode(o),n.each((t=>Ia(e,t.previousSibling))),r.each((t=>Ia(e,t.nextSibling)))})(e,t,o):((e,t,o)=>{t.insertNode(o),Ia(e,o.previousSibling),Ia(e,o.nextSibling)})(e,t,o)},La=Qn,za=Yn,Ha=Bs.nodeIndex,Za=e=>{const t=e.parentNode;return za(t)?Za(t):t},ja=e=>e?Ne(e.childNodes,((e,t)=>(za(t)&&"BR"!==t.nodeName?e=e.concat(ja(t)):e.push(t),e)),[]):[],Ua=e=>t=>e===t,$a=e=>(La(e)?"text()":e.nodeName.toLowerCase())+"["+(e=>{let t,o;t=ja(Za(e)),o=Re(t,Ua(e),e),t=t.slice(0,o+1);const n=Ne(t,((e,o,n)=>(La(o)&&La(t[n-1])&&e++,e)),0);return t=Be(t,Wn([e.nodeName])),o=Re(t,Ua(e),e),o-n})(e)+"]",Wa=(e,t)=>{let o,n=[],r=t.container(),i=t.offset();if(La(r))o=((e,t)=>{let o=e;for(;(o=o.previousSibling)&&La(o);)t+=o.data.length;return t})(r,i);else{const e=r.childNodes;i>=e.length?(o="after",i=e.length-1):o="before",r=e[i]}n.push($a(r));let s=((e,t,o)=>{const n=[];for(let o=t.parentNode;o&&o!==e;o=o.parentNode)n.push(o);return n})(e,r);return s=Be(s,N(Yn)),n=n.concat(Ae(s,(e=>$a(e)))),n.reverse().join("/")+","+o},qa=(e,t)=>{if(!t)return null;const o=t.split(","),n=o[0].split("/"),r=o.length>1?o[1]:"before",i=Ne(n,((e,t)=>{const o=/([\w\-\(\)]+)\[([0-9]+)\]/.exec(t);return o?("text()"===o[1]&&(o[1]="#text"),((e,t,o)=>{let n=ja(e);return n=Be(n,((e,t)=>!La(e)||!La(n[t-1]))),n=Be(n,Wn([t])),n[o]})(e,o[1],parseInt(o[2],10))):null}),e);if(!i)return null;if(!La(i)&&i.parentNode){let e;return e="after"===r?Ha(i)+1:Ha(i),Pa(i.parentNode,e)}return((e,t)=>{let o=e,n=0;for(;La(o);){const r=o.data.length;if(t>=n&&t<=n+r){e=o,t-=n;break}if(!La(o.nextSibling)){e=o,t=r;break}n+=r,o=o.nextSibling}return La(e)&&t>e.data.length&&(t=e.data.length),Pa(e,t)})(i,parseInt(r,10))},Ga=lr,Ya=(e,t,o,n,r)=>{const i=r?n.startContainer:n.endContainer;let s=r?n.startOffset:n.endOffset;const a=[],l=e.getRoot();if(Qn(i))a.push(o?((e,t,o)=>{let n=e(t.data.slice(0,o)).length;for(let o=t.previousSibling;o&&Qn(o);o=o.previousSibling)n+=e(o.data).length;return n})(t,i,s):s);else{let t=0;const n=i.childNodes;s>=n.length&&n.length&&(t=1,s=Math.max(0,n.length-1)),a.push(e.nodeIndex(n[s],o)+t)}for(let t=i;t&&t!==l;t=t.parentNode)a.push(e.nodeIndex(t,o));return a},Ka=(e,t,o)=>{let n=0;return Vt.each(e.select(t),(e=>"all"===e.getAttribute("data-mce-bogus")?void 0:e!==o&&void n++)),n},Xa=(e,t)=>{let o=t?e.startContainer:e.endContainer,n=t?e.startOffset:e.endOffset;if(Un(o)&&"TR"===o.nodeName){const r=o.childNodes;o=r[Math.min(t?n:n-1,r.length-1)],o&&(n=t?0:o.childNodes.length,t?e.setStart(o,n):e.setEnd(o,n))}},Ja=e=>(Xa(e,!0),Xa(e,!1),e),Qa=(e,t)=>{if(Un(e)&&(e=fa(e,t),Ga(e)))return e;if(Ur(e)){Qn(e)&&Zr(e)&&(e=e.parentNode);let t=e.previousSibling;if(Ga(t))return t;if(t=e.nextSibling,Ga(t))return t}},el=(e,t,o)=>{const n=o.getNode(),r=o.getRng();if("IMG"===n.nodeName||Ga(n)){const e=n.nodeName;return{name:e,index:Ka(o.dom,e,n)}}const i=(e=>Qa(e.startContainer,e.startOffset)||Qa(e.endContainer,e.endOffset))(r);if(i){const e=i.tagName;return{name:e,index:Ka(o.dom,e,i)}}return((e,t,o,n)=>{const r=t.dom,i=Ya(r,e,o,n,!0),s=t.isForward(),a=Xr(n)?{isFakeCaret:!0}:{};return t.isCollapsed()?{start:i,forward:s,...a}:{start:i,end:Ya(r,e,o,n,!1),forward:s,...a}})(e,o,t,r)},tl=(e,t,o)=>{const n={"data-mce-type":"bookmark",id:t,style:"overflow:hidden;line-height:0px"};return o?e.create("span",n,""):e.create("span",n)},ol=(e,t)=>{const o=e.dom;let n=e.getRng();const r=o.uniqueId(),i=e.isCollapsed(),s=e.getNode(),a=s.nodeName,l=e.isForward();if("IMG"===a)return{name:a,index:Ka(o,a,s)};const c=Ja(n.cloneRange());if(!i){c.collapse(!1);const e=tl(o,r+"_end",t);Fa(o,c,e)}n=Ja(n),n.collapse(!0);const d=tl(o,r+"_start",t);return Fa(o,n,d),e.moveToBookmark({id:r,keep:!0,forward:l}),{id:r,forward:l}},nl=B(el,M,!0),rl=e=>{const t=t=>t(e),o=O(e),n=()=>r,r={tag:!0,inner:e,fold:(t,o)=>o(e),isValue:I,isError:P,map:t=>sl.value(t(e)),mapError:n,bind:t,exists:t,forall:t,getOr:o,or:n,getOrThunk:o,orThunk:n,getOrDie:o,each:t=>{t(e)},toOptional:()=>F.some(e)};return r},il=e=>{const t=()=>o,o={tag:!1,inner:e,fold:(t,o)=>t(e),isValue:P,isError:I,map:t,mapError:t=>sl.error(t(e)),bind:t,exists:P,forall:I,getOr:M,or:M,getOrThunk:V,orThunk:V,getOrDie:R(String(e)),each:S,toOptional:F.none};return o},sl={value:rl,error:il,fromOption:(e,t)=>e.fold((()=>il(t)),rl)},al=e=>{if(!f(e))throw new Error("cases must be an array");if(0===e.length)throw new Error("there must be at least one case");const t=[],o={};return W(e,((n,r)=>{const i=me(n);if(1!==i.length)throw new Error("one and only one name per case");const s=i[0],a=n[s];if(void 0!==o[s])throw new Error("duplicate key detected:"+s);if("cata"===s)throw new Error("cannot have a case named cata (sorry)");if(!f(a))throw new Error("case arguments must be an array");t.push(s),o[s]=(...o)=>{const n=o.length;if(n!==a.length)throw new Error("Wrong number of arguments to case "+s+". Expected "+a.length+" ("+a+"), got "+n);return{fold:(...t)=>{if(t.length!==e.length)throw new Error("Wrong number of arguments to fold. Expected "+e.length+", got "+t.length);return t[r].apply(null,o)},match:e=>{const n=me(e);if(t.length!==n.length)throw new Error("Wrong number of arguments to match. Expected: "+t.join(",")+"\nActual: "+n.join(","));if(!ne(t,(e=>j(n,e))))throw new Error("Not all branches were specified when using match. Specified: "+n.join(", ")+"\nRequired: "+t.join(", "));return e[s].apply(null,o)},log:e=>{console.log(e,{constructors:t,constructor:s,params:o})}}}})),o};al([{bothErrors:["error1","error2"]},{firstError:["error1","value2"]},{secondError:["value1","error2"]},{bothValues:["value1","value2"]}]);const ll=e=>"inline-command"===e.type||"inline-format"===e.type,cl=e=>"block-command"===e.type||"block-format"===e.type,dl=e=>{const t=t=>sl.error({message:t,pattern:e}),o=(o,n,r)=>{if(void 0!==e.format){let r;if(f(e.format)){if(!ne(e.format,m))return t(o+" pattern has non-string items in the `format` array");r=e.format}else{if(!m(e.format))return t(o+" pattern has non-string `format` parameter");r=[e.format]}return sl.value(n(r))}return void 0!==e.cmd?m(e.cmd)?sl.value(r(e.cmd,e.value)):t(o+" pattern has non-string `cmd` parameter"):t(o+" pattern is missing both `format` and `cmd` parameters")};if(!p(e))return t("Raw pattern is not an object");if(!m(e.start))return t("Raw pattern is missing `start` parameter");if(void 0!==e.end){if(!m(e.end))return t("Inline pattern has non-string `end` parameter");if(0===e.start.length&&0===e.end.length)return t("Inline pattern has empty `start` and `end` parameters");let n=e.start,r=e.end;return 0===r.length&&(r=n,n=""),o("Inline",(e=>({type:"inline-format",start:n,end:r,format:e})),((e,t)=>({type:"inline-command",start:n,end:r,cmd:e,value:t})))}return void 0!==e.replacement?m(e.replacement)?0===e.start.length?t("Replacement pattern has empty `start` parameter"):sl.value({type:"inline-command",start:"",end:e.start,cmd:"mceInsertContent",value:e.replacement}):t("Replacement pattern has non-string `replacement` parameter"):0===e.start.length?t("Block pattern has empty `start` parameter"):o("Block",(t=>({type:"block-format",start:e.start,format:t[0]})),((t,o)=>({type:"block-command",start:e.start,cmd:t,value:o})))},ul=e=>Y(e,cl),hl=e=>Y(e,ll),ml=e=>{const t=(e=>{const t=[],o=[];return W(e,(e=>{e.fold((e=>{t.push(e)}),(e=>{o.push(e)}))})),{errors:t,values:o}})($(e,dl));return W(t.errors,(e=>console.error(e.message,e.pattern))),t.values},pl=Ct().deviceType,gl=pl.isTouch(),fl=Bs.DOM,vl=e=>h(e,RegExp),bl=e=>t=>t.options.get(e),yl=e=>m(e)||p(e),wl=(e,t="")=>o=>{const n=m(o);if(n){if(-1!==o.indexOf("=")){const r=(e=>{const t=e.indexOf("=")>0?e.split(/[;,](?![^=;,]*(?:[;,]|$))/):e.split(",");return X(t,((e,t)=>{const o=t.split("="),n=o[0],r=o.length>1?o[1]:n;return e[We(n)]=We(r),e}),{})})(o);return{value:Ce(r,e.id).getOr(t),valid:n}}return{value:o,valid:n}}return{valid:!1,message:"Must be a string."}},_l=bl("iframe_attrs"),xl=bl("doctype"),Cl=bl("document_base_url"),kl=bl("body_id"),Sl=bl("body_class"),Tl=bl("content_security_policy"),El=bl("br_in_pre"),Ol=bl("forced_root_block"),Ml=bl("forced_root_block_attrs"),Al=bl("newline_behavior"),Bl=bl("br_newline_selector"),Nl=bl("no_newline_selector"),Rl=bl("keep_styles"),Vl=bl("end_container_on_empty_block"),Dl=bl("automatic_uploads"),Pl=bl("images_reuse_filename"),Il=bl("images_replace_blob_uris"),Fl=bl("icons"),Ll=bl("icons_url"),zl=bl("images_upload_url"),Hl=bl("images_upload_base_path"),Zl=bl("images_upload_credentials"),jl=bl("images_upload_handler"),Ul=bl("content_css_cors"),$l=bl("referrer_policy"),Wl=bl("language"),ql=bl("language_url"),Gl=bl("indent_use_margin"),Yl=bl("indentation"),Kl=bl("content_css"),Xl=bl("content_style"),Jl=bl("font_css"),Ql=bl("directionality"),ec=bl("inline_boundaries_selector"),tc=bl("object_resizing"),oc=bl("resize_img_proportional"),nc=bl("placeholder"),rc=bl("event_root"),ic=bl("service_message"),sc=bl("theme"),ac=bl("theme_url"),lc=bl("model"),cc=bl("model_url"),dc=bl("inline_boundaries"),uc=bl("formats"),hc=bl("preview_styles"),mc=bl("format_empty_lines"),pc=bl("format_noneditable_selector"),gc=bl("custom_ui_selector"),fc=bl("inline"),vc=bl("hidden_input"),bc=bl("submit_patch"),yc=bl("add_form_submit_trigger"),wc=bl("add_unload_trigger"),_c=bl("custom_undo_redo_levels"),xc=bl("disable_nodechange"),Cc=bl("readonly"),kc=bl("editable_root"),Sc=bl("content_css_cors"),Tc=bl("plugins"),Ec=bl("external_plugins"),Oc=bl("block_unsupported_drop"),Mc=bl("visual"),Ac=bl("visual_table_class"),Bc=bl("visual_anchor_class"),Nc=bl("iframe_aria_text"),Rc=bl("setup"),Vc=bl("init_instance_callback"),Dc=bl("urlconverter_callback"),Pc=bl("auto_focus"),Ic=bl("browser_spellcheck"),Fc=bl("protect"),Lc=bl("paste_block_drop"),zc=bl("paste_data_images"),Hc=bl("paste_preprocess"),Zc=bl("paste_postprocess"),jc=bl("newdocument_content"),Uc=bl("paste_webkit_styles"),$c=bl("paste_remove_styles_if_webkit"),Wc=bl("paste_merge_formats"),qc=bl("smart_paste"),Gc=bl("paste_as_text"),Yc=bl("paste_tab_spaces"),Kc=bl("allow_html_data_urls"),Xc=bl("text_patterns"),Jc=bl("text_patterns_lookup"),Qc=bl("noneditable_class"),ed=bl("editable_class"),td=bl("noneditable_regexp"),od=bl("preserve_cdata"),nd=bl("highlight_on_focus"),rd=bl("xss_sanitization"),id=bl("init_content_sync"),sd=e=>Vt.explode(e.options.get("images_file_types")),ad=bl("table_tab_navigation"),ld=bl("details_initial_state"),cd=bl("details_serialized_state"),dd=Un,ud=Qn,hd=e=>{const t=e.parentNode;t&&t.removeChild(e)},md=e=>{const t=Lr(e);return{count:e.length-t.length,text:t}},pd=e=>{let t;for(;-1!==(t=e.data.lastIndexOf(Ir));)e.deleteData(t,1)},gd=(e,t)=>(vd(e),t),fd=(e,t)=>Pa.isTextPosition(t)?((e,t)=>ud(e)&&t.container()===e?((e,t)=>{const o=md(e.data.substr(0,t.offset())),n=md(e.data.substr(t.offset()));return(o.text+n.text).length>0?(pd(e),Pa(e,t.offset()-o.count)):t})(e,t):gd(e,t))(e,t):((e,t)=>t.container()===e.parentNode?((e,t)=>{const o=t.container(),n=((e,t)=>{const o=Z(e,t);return-1===o?F.none():F.some(o)})(ue(o.childNodes),e).map((e=>e{dd(e)&&Ur(e)&&($r(e)?e.removeAttribute("data-mce-caret"):hd(e)),ud(e)&&(pd(e),0===e.data.length&&hd(e))},bd=lr,yd=ur,wd=cr,_d=(e,t,o)=>{const n=da(t.getBoundingClientRect(),o);let r,i;if("BODY"===e.tagName){const t=e.ownerDocument.documentElement;r=e.scrollLeft||t.scrollLeft,i=e.scrollTop||t.scrollTop}else{const t=e.getBoundingClientRect();r=e.scrollLeft-t.left,i=e.scrollTop-t.top}n.left+=r,n.right+=r,n.top+=i,n.bottom+=i,n.width=1;let s=t.offsetWidth-t.clientWidth;return s>0&&(o&&(s*=-1),n.left+=s,n.right+=s),n},xd=(e,t,o,n)=>{const r=Hs();let i,s;const a=Ol(e),l=e.dom,c=()=>{(e=>{var t,o;const n=Ln(wo(e),"*[contentEditable=false],video,audio,embed,object");for(let e=0;e{l.remove(e.caret),r.clear()})),i&&(clearInterval(i),i=void 0)};return{show:(e,d)=>{let u;if(c(),wd(d))return null;if(!o(d))return s=((e,t)=>{var o;const n=(null!==(o=e.ownerDocument)&&void 0!==o?o:document).createTextNode(Ir),r=e.parentNode;if(t){const t=e.previousSibling;if(Hr(t)){if(Ur(t))return t;if(Yr(t))return t.splitText(t.data.length-1)}null==r||r.insertBefore(n,e)}else{const t=e.nextSibling;if(Hr(t)){if(Ur(t))return t;if(Gr(t))return t.splitText(1),t}e.nextSibling?null==r||r.insertBefore(n,e.nextSibling):null==r||r.appendChild(n)}return n})(d,e),u=d.ownerDocument.createRange(),kd(s.nextSibling)?(u.setStart(s,0),u.setEnd(s,0)):(u.setStart(s,1),u.setEnd(s,1)),u;{const o=((e,t,o)=>{var n;const r=(null!==(n=t.ownerDocument)&&void 0!==n?n:document).createElement(e);r.setAttribute("data-mce-caret",o?"before":"after"),r.setAttribute("data-mce-bogus","all"),r.appendChild(Vr().dom);const i=t.parentNode;return o?null==i||i.insertBefore(r,t):t.nextSibling?null==i||i.insertBefore(r,t.nextSibling):null==i||i.appendChild(r),r})(a,d,e),c=_d(t,d,e);l.setStyle(o,"top",c.top),s=o;const h=l.create("div",{class:"mce-visual-caret","data-mce-bogus":"all"});l.setStyles(h,{...c}),l.add(t,h),r.set({caret:h,element:d,before:e}),e&&l.addClass(h,"mce-visual-caret-before"),i=setInterval((()=>{r.on((e=>{n()?l.toggleClass(e.caret,"mce-visual-caret-hidden"):l.addClass(e.caret,"mce-visual-caret-hidden")}))}),500),u=d.ownerDocument.createRange(),u.setStart(o,0),u.setEnd(o,0)}return u},hide:c,getCss:()=>".mce-visual-caret {position: absolute;background-color: black;background-color: currentcolor;}.mce-visual-caret-hidden {display: none;}*[data-mce-caret] {position: absolute;left: -1000px;right: auto;top: 0;margin: 0;padding: 0;}",reposition:()=>{r.on((e=>{const o=_d(t,e.element,e.before);l.setStyles(e.caret,{...o})}))},destroy:()=>clearInterval(i)}},Cd=()=>At.browser.isFirefox(),kd=e=>bd(e)||yd(e),Sd=e=>(kd(e)||Kn(e)&&Cd())&&Bo(wo(e)).exists(nn),Td=ar,Ed=lr,Od=ur,Md=qn("display","block table table-cell table-caption list-item"),Ad=Ur,Bd=Zr,Nd=Un,Rd=Qn,Vd=si,Dd=e=>e>0,Pd=e=>e<0,Id=(e,t)=>{let o;for(;o=e(t);)if(!Bd(o))return o;return null},Fd=(e,t,o,n,r)=>{const i=new Hn(e,n),s=Ed(e)||Bd(e);let a;if(Pd(t)){if(s&&(a=Id(i.prev.bind(i),!0),o(a)))return a;for(;a=Id(i.prev.bind(i),r);)if(o(a))return a}if(Dd(t)){if(s&&(a=Id(i.next.bind(i),!0),o(a)))return a;for(;a=Id(i.next.bind(i),r);)if(o(a))return a}return null},Ld=(e,t)=>{for(;e&&e!==t;){if(Md(e))return e;e=e.parentNode}return null},zd=(e,t,o)=>Ld(e.container(),o)===Ld(t.container(),o),Hd=(e,t)=>{if(!t)return F.none();const o=t.container(),n=t.offset();return Nd(o)?F.from(o.childNodes[n+e]):F.none()},Zd=(e,t)=>{var o;const n=(null!==(o=t.ownerDocument)&&void 0!==o?o:document).createRange();return e?(n.setStartBefore(t),n.setEndBefore(t)):(n.setStartAfter(t),n.setEndAfter(t)),n},jd=(e,t,o)=>Ld(t,e)===Ld(o,e),Ud=(e,t,o)=>{const n=e?"previousSibling":"nextSibling";let r=o;for(;r&&r!==t;){let e=r[n];if(e&&Ad(e)&&(e=e[n]),Ed(e)||Od(e)){if(jd(t,e,r))return e;break}if(Vd(e))break;r=r.parentNode}return null},$d=B(Zd,!0),Wd=B(Zd,!1),qd=(e,t,o)=>{let n;const r=B(Ud,!0,t),i=B(Ud,!1,t),s=o.startContainer,a=o.startOffset;if(Zr(s)){const e=Rd(s)?s.parentNode:s,t=e.getAttribute("data-mce-caret");if("before"===t&&(n=e.nextSibling,Sd(n)))return $d(n);if("after"===t&&(n=e.previousSibling,Sd(n)))return Wd(n)}if(!o.collapsed)return o;if(Qn(s)){if(Ad(s)){if(1===e){if(n=i(s),n)return $d(n);if(n=r(s),n)return Wd(n)}if(-1===e){if(n=r(s),n)return Wd(n);if(n=i(s),n)return $d(n)}return o}if(Yr(s)&&a>=s.data.length-1)return 1===e&&(n=i(s),n)?$d(n):o;if(Gr(s)&&a<=1)return-1===e&&(n=r(s),n)?Wd(n):o;if(a===s.data.length)return n=i(s),n?$d(n):o;if(0===a)return n=r(s),n?Wd(n):o}return o},Gd=(e,t)=>Hd(e?0:-1,t).filter(Ed),Yd=(e,t,o)=>{const n=qd(e,t,o);return-1===e?Pa.fromRangeStart(n):Pa.fromRangeEnd(n)},Kd=e=>F.from(e.getNode()).map(wo),Xd=(e,t)=>{let o=t;for(;o=e(o);)if(o.isVisible())return o;return o},Jd=(e,t)=>{const o=zd(e,t);return!(o||!ir(e.getNode()))||o};var Qd;!function(e){e[e.Backwards=-1]="Backwards",e[e.Forwards=1]="Forwards"}(Qd||(Qd={}));const eu=lr,tu=Qn,ou=Un,nu=ir,ru=si,iu=e=>ni(e)||(e=>!!ai(e)&&!X(ue(e.getElementsByTagName("*")),((e,t)=>e||Jr(t)),!1))(e),su=li,au=(e,t)=>e.hasChildNodes()&&t{if(Dd(e)){if(ru(t.previousSibling)&&!tu(t.previousSibling))return Pa.before(t);if(tu(t))return Pa(t,0)}if(Pd(e)){if(ru(t.nextSibling)&&!tu(t.nextSibling))return Pa.after(t);if(tu(t))return Pa(t,t.data.length)}return Pd(e)?nu(t)?Pa.before(t):Pa.after(t):Pa.before(t)},cu=(e,t,o)=>{let n,r,i,s;if(!ou(o)||!t)return null;if(t.isEqual(Pa.after(o))&&o.lastChild){if(s=Pa.after(o.lastChild),Pd(e)&&ru(o.lastChild)&&ou(o.lastChild))return nu(o.lastChild)?Pa.before(o.lastChild):s}else s=t;const a=s.container();let l=s.offset();if(tu(a)){if(Pd(e)&&l>0)return Pa(a,--l);if(Dd(e)&&l0&&(r=au(a,l-1),ru(r)))return!iu(r)&&(i=Fd(r,e,su,r),i)?tu(i)?Pa(i,i.data.length):Pa.after(i):tu(r)?Pa(r,r.data.length):Pa.before(r);if(Dd(e)&&l{const o=t.nextSibling;return o&&ru(o)?tu(o)?Pa(o,0):Pa.before(o):cu(Qd.Forwards,Pa.after(t),e)})(o,r):!iu(r)&&(i=Fd(r,e,su,r),i)?tu(i)?Pa(i,0):Pa.before(i):tu(r)?Pa(r,0):Pa.after(r);n=r||s.getNode()}if(n&&(Dd(e)&&s.isAtEnd()||Pd(e)&&s.isAtStart())&&(n=Fd(n,e,I,o,!0),su(n,o)))return lu(e,n);r=n?Fd(n,e,su,o):n;const c=Ve(Y(((e,t)=>{const o=[];let n=e;for(;n&&n!==t;)o.push(n),n=n.parentNode;return o})(a,o),eu));return!c||r&&c.contains(r)?r?lu(e,r):null:(s=Dd(e)?Pa.after(c):Pa.before(c),s)},du=e=>({next:t=>cu(Qd.Forwards,t,e),prev:t=>cu(Qd.Backwards,t,e)}),uu=e=>Pa.isTextPosition(e)?0===e.offset():si(e.getNode()),hu=e=>{if(Pa.isTextPosition(e)){const t=e.container();return e.offset()===t.data.length}return si(e.getNode(!0))},mu=(e,t)=>!Pa.isTextPosition(e)&&!Pa.isTextPosition(t)&&e.getNode()===t.getNode(!0),pu=(e,t,o)=>{const n=du(t);return F.from(e?n.next(o):n.prev(o))},gu=(e,t,o)=>pu(e,t,o).bind((n=>zd(o,n,t)&&((e,t,o)=>{return e?!mu(t,o)&&(n=t,!(!Pa.isTextPosition(n)&&ir(n.getNode())))&&hu(t)&&uu(o):!mu(o,t)&&uu(t)&&hu(o);var n})(e,o,n)?pu(e,t,n):F.some(n))),fu=(e,t,o,n)=>gu(e,t,o).bind((o=>n(o)?fu(e,t,o,n):F.some(o))),vu=(e,t)=>{const o=e?t.firstChild:t.lastChild;return Qn(o)?F.some(Pa(o,e?0:o.data.length)):o?si(o)?F.some(e?Pa.before(o):ir(n=o)?Pa.before(n):Pa.after(n)):((e,t,o)=>{const n=e?Pa.before(o):Pa.after(o);return pu(e,t,n)})(e,t,o):F.none();var n},bu=B(pu,!0),yu=B(pu,!1),wu=B(vu,!0),_u=B(vu,!1),xu="_mce_caret",Cu=e=>Un(e)&&e.id===xu,ku=(e,t)=>{let o=t;for(;o&&o!==e;){if(Cu(o))return o;o=o.parentNode}return null},Su=e=>ke(e,"name"),Tu=e=>Vt.isArray(e.start),Eu=e=>!(!Su(e)&&b(e.forward))||e.forward,Ou=(e,t)=>(Un(t)&&e.isBlock(t)&&!t.innerHTML&&(t.innerHTML=' '),t),Mu=(e,t)=>_u(e).fold(P,(e=>(t.setStart(e.container(),e.offset()),t.setEnd(e.container(),e.offset()),!0))),Au=(e,t,o)=>!(!(e=>!e.hasChildNodes())(t)||!ku(e,t)||(((e,t)=>{var o;const n=(null!==(o=e.ownerDocument)&&void 0!==o?o:document).createTextNode(Ir);e.appendChild(n),t.setStart(n,0),t.setEnd(n,0)})(t,o),0)),Bu=(e,t,o,n)=>{const r=o[t?"start":"end"],i=e.getRoot();if(r){let e=i,o=r[0];for(let t=r.length-1;e&&t>=1;t--){const o=e.childNodes;if(Au(i,e,n))return!0;if(r[t]>o.length-1)return!!Au(i,e,n)||Mu(e,n);e=o[r[t]]}Qn(e)&&(o=Math.min(r[0],e.data.length)),Un(e)&&(o=Math.min(r[0],e.childNodes.length)),t?n.setStart(e,o):n.setEnd(e,o)}return!0},Nu=e=>Qn(e)&&e.data.length>0,Ru=(e,t,o)=>{const n=e.get(o.id+"_"+t),r=null==n?void 0:n.parentNode,i=o.keep;if(n&&r){let s,a;if("start"===t?i?n.hasChildNodes()?(s=n.firstChild,a=1):Nu(n.nextSibling)?(s=n.nextSibling,a=0):Nu(n.previousSibling)?(s=n.previousSibling,a=n.previousSibling.data.length):(s=r,a=e.nodeIndex(n)+1):(s=r,a=e.nodeIndex(n)):i?n.hasChildNodes()?(s=n.firstChild,a=1):Nu(n.previousSibling)?(s=n.previousSibling,a=n.previousSibling.data.length):(s=r,a=e.nodeIndex(n)):(s=r,a=e.nodeIndex(n)),!i){const r=n.previousSibling,i=n.nextSibling;let l;for(Vt.each(Vt.grep(n.childNodes),(e=>{Qn(e)&&(e.data=e.data.replace(/\uFEFF/g,""))}));l=e.get(o.id+"_"+t);)e.remove(l,!0);if(Qn(i)&&Qn(r)&&!At.browser.isOpera()){const t=r.data.length;r.appendData(i.data),e.remove(i),s=r,a=t}}return F.some(Pa(s,a))}return F.none()},Vu=(e,t,o)=>((e,t,o=!1)=>2===t?el(Lr,o,e):3===t?(e=>{const t=e.getRng();return{start:Wa(e.dom.getRoot(),Pa.fromRangeStart(t)),end:Wa(e.dom.getRoot(),Pa.fromRangeEnd(t)),forward:e.isForward()}})(e):t?(e=>({rng:e.getRng(),forward:e.isForward()}))(e):ol(e,!1))(e,t,o),Du=(e,t)=>{((e,t)=>{const o=e.dom;if(t){if(Tu(t))return((e,t)=>{const o=e.createRng();return Bu(e,!0,t,o)&&Bu(e,!1,t,o)?F.some({range:o,forward:Eu(t)}):F.none()})(o,t);if((e=>m(e.start))(t))return((e,t)=>{const o=F.from(qa(e.getRoot(),t.start)),n=F.from(qa(e.getRoot(),t.end));return It(o,n,((o,n)=>{const r=e.createRng();return r.setStart(o.container(),o.offset()),r.setEnd(n.container(),n.offset()),{range:r,forward:Eu(t)}}))})(o,t);if((e=>ke(e,"id"))(t))return((e,t)=>{const o=Ru(e,"start",t),n=Ru(e,"end",t);return It(o,n.or(o),((o,n)=>{const r=e.createRng();return r.setStart(Ou(e,o.container()),o.offset()),r.setEnd(Ou(e,n.container()),n.offset()),{range:r,forward:Eu(t)}}))})(o,t);if(Su(t))return((e,t)=>F.from(e.select(t.name)[t.index]).map((t=>{const o=e.createRng();return o.selectNode(t),{range:o,forward:!0}})))(o,t);if((e=>ke(e,"rng"))(t))return F.some({range:t.rng,forward:Eu(t)})}return F.none()})(e,t).each((({range:t,forward:o})=>{e.setRng(t,o)}))},Pu=e=>Un(e)&&"SPAN"===e.tagName&&"bookmark"===e.getAttribute("data-mce-type"),Iu=(Fu=fr,e=>Fu===e);var Fu;const Lu=e=>""!==e&&-1!==" \f\n\r\t\v".indexOf(e),zu=e=>!Lu(e)&&!Iu(e)&&!vr(e),Hu=e=>{const t=e.toString(16);return(1===t.length?"0"+t:t).toUpperCase()},Zu=e=>(e=>{return{value:(t=e,He(t,"#").toUpperCase())};var t})(Hu(e.red)+Hu(e.green)+Hu(e.blue)),ju=/^\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/i,Uu=/^\s*rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?(?:\.\d+)?)\s*\)\s*$/i,$u=(e,t,o,n)=>({red:e,green:t,blue:o,alpha:n}),Wu=(e,t,o,n)=>{const r=parseInt(e,10),i=parseInt(t,10),s=parseInt(o,10),a=parseFloat(n);return $u(r,i,s,a)},qu=e=>(e=>{if("transparent"===e)return F.some($u(0,0,0,0));const t=ju.exec(e);if(null!==t)return F.some(Wu(t[1],t[2],t[3],"1"));const o=Uu.exec(e);return null!==o?F.some(Wu(o[1],o[2],o[3],o[4])):F.none()})(e).map(Zu).map((e=>"#"+e.value)).getOr(e),Gu=e=>{const t=[];if(e)for(let o=0;o{const o=Ln(t,"td[data-mce-selected],th[data-mce-selected]");return o.length>0?o:(e=>Y((e=>oe(e,(e=>{const t=ga(e);return t?[wo(t)]:[]})))(e),Ar))(e)},Ku=e=>Yu(Gu(e.selection.getSel()),wo(e.getBody())),Xu=(e,t)=>en(e,"table",t),Ju=e=>Lo(e).fold(O([e]),(t=>[e].concat(Ju(t)))),Qu=e=>zo(e).fold(O([e]),(t=>"br"===jt(t)?Ro(t).map((t=>[e].concat(Qu(t)))).getOr([]):[e].concat(Qu(t)))),eh=(e,t)=>It((e=>{const t=e.startContainer,o=e.startOffset;return Qn(t)?0===o?F.some(wo(t)):F.none():F.from(t.childNodes[o]).map(wo)})(t),(e=>{const t=e.endContainer,o=e.endOffset;return Qn(t)?o===t.data.length?F.some(wo(t)):F.none():F.from(t.childNodes[o-1]).map(wo)})(t),((t,o)=>{const n=Q(Ju(e),B(So,t)),r=Q(Qu(e),B(So,o));return n.isSome()&&r.isSome()})).getOr(!1),th=(e,t,o,n)=>{const r=o,i=new Hn(o,r),s=we(e.schema.getMoveCaretBeforeOnEnterElements(),((e,t)=>!j(["td","th","table"],t.toLowerCase())));let a=o;do{if(Qn(a)&&0!==Vt.trim(a.data).length)return void(n?t.setStart(a,0):t.setEnd(a,a.data.length));if(s[a.nodeName])return void(n?t.setStartBefore(a):"BR"===a.nodeName?t.setEndBefore(a):t.setEndAfter(a))}while(a=n?i.next():i.prev());"BODY"===r.nodeName&&(n?t.setStart(r,0):t.setEnd(r,r.childNodes.length))},oh=e=>{const t=e.selection.getSel();return _(t)&&t.rangeCount>0},nh=(e,t)=>{const o=Ku(e);o.length>0?W(o,(o=>{const n=o.dom,r=e.dom.createRng();r.setStartBefore(n),r.setEndAfter(n),t(r,!0)})):t(e.selection.getRng(),!1)},rh=(e,t,o)=>{const n=ol(e,t);o(n),e.moveToBookmark(n)},ih=e=>C(null==e?void 0:e.nodeType),sh=e=>Un(e)&&!Pu(e)&&!Cu(e)&&!Yn(e),ah=e=>!0===e.isContentEditable,lh=(e,t,o)=>{const{selection:n,dom:r}=e,i=n.getNode(),s=lr(i);rh(n,!0,(()=>{t()})),s&&lr(i)&&r.isChildOf(i,e.getBody())?e.selection.select(i):o(n.getStart())&&ch(r,n)},ch=(e,t)=>{var o,n;const r=t.getRng(),{startContainer:i,startOffset:s}=r;if(!((e,t)=>{if(sh(t)&&!/^(TD|TH)$/.test(t.nodeName)){const o=e.getAttrib(t,"data-mce-selected"),n=parseInt(o,10);return!isNaN(n)&&n>0}return!1})(e,t.getNode())&&Un(i)){const a=i.childNodes,l=e.getRoot();let c;if(s{if(e){const n=t?"nextSibling":"previousSibling";for(e=o?e:e[n];e;e=e[n])if(Un(e)||!mh(e))return e}},uh=(e,t)=>!!e.getTextBlockElements()[t.nodeName.toLowerCase()]||Ai(e,t),hh=(e,t,o)=>e.schema.isValidChild(t,o),mh=(e,t=!1)=>{if(_(e)&&Qn(e)){const o=t?e.data.replace(/ /g," "):e.data;return di(o)}return!1},ph=(e,t)=>{const o=e.dom;return sh(t)&&"false"===o.getContentEditable(t)&&((e,t)=>{const o="[data-mce-cef-wrappable]",n=pc(e),r=Ke(n)?o:`${o},${n}`;return Co(wo(t),r)})(e,t)&&0===o.select('[contenteditable="true"]',t).length},gh=(e,t)=>x(e)?e(t):(_(t)&&(e=e.replace(/%(\w+)/g,((e,o)=>t[o]||e))),e),fh=(e,t)=>(t=t||"",e=""+((e=e||"").nodeName||e),t=""+(t.nodeName||t),e.toLowerCase()===t.toLowerCase()),vh=(e,t)=>{if(w(e))return null;{let o=String(e);return"color"!==t&&"backgroundColor"!==t||(o=qu(o)),"fontWeight"===t&&700===e&&(o="bold"),"fontFamily"===t&&(o=o.replace(/[\'\"]/g,"").replace(/,\s+/g,",")),o}},bh=(e,t,o)=>{const n=e.getStyle(t,o);return vh(n,o)},yh=(e,t)=>{let o;return e.getParent(t,(t=>!!Un(t)&&(o=e.getStyle(t,"text-decoration"),!!o&&"none"!==o))),o},wh=(e,t,o)=>e.getParents(t,o,e.getRoot()),_h=(e,t,o)=>{const n=e.formatter.get(t);return _(n)&&U(n,o)},xh=e=>Se(e,"block"),Ch=e=>Se(e,"selector"),kh=e=>Se(e,"inline"),Sh=e=>Ch(e)&&!1!==e.expand&&!kh(e),Th=Pu,Eh=wh,Oh=mh,Mh=uh,Ah=(e,t)=>{let o=t;for(;o;){if(Un(o)&&e.getContentEditable(o))return"false"===e.getContentEditable(o)?o:t;o=o.parentNode}return t},Bh=(e,t,o,n)=>{const r=t.data;if(e){for(let e=o;e>0;e--)if(n(r.charAt(e-1)))return e}else for(let e=o;eBh(e,t,o,(e=>Iu(e)||Lu(e))),Rh=(e,t,o)=>Bh(e,t,o,zu),Vh=(e,t,o,n,r,i)=>{let s;const a=e.getParent(o,e.isBlock)||t,l=(t,o,n)=>{const i=aa(e),l=r?i.backwards:i.forwards;return F.from(l(t,o,((e,t)=>Th(e.parentNode)?-1:(s=e,n(r,e,t))),a))};return l(o,n,Nh).bind((e=>i?l(e.container,e.offset+(r?-1:0),Rh):F.some(e))).orThunk((()=>s?F.some({container:s,offset:r?0:s.length}):F.none()))},Dh=(e,t,o,n,r)=>{const i=n[r];Qn(n)&&Ke(n.data)&&i&&(n=i);const s=Eh(e,n);for(let n=0;n{var r;let i=o;const s=e.getRoot(),a=t[0];if(xh(a)&&(i=a.wrapper?null:e.getParent(o,a.block,s)),!i){const t=null!==(r=e.getParent(o,"LI,TD,TH"))&&void 0!==r?r:s;i=e.getParent(Qn(o)?o.parentNode:o,(t=>t!==s&&Mh(e.schema,t)),t)}if(i&&xh(a)&&a.wrapper&&(i=Eh(e,i,"ul,ol").reverse()[0]||i),!i)for(i=o;i&&i[n]&&!e.isBlock(i[n])&&(i=i[n],!fh(i,"br")););return i||o},Ih=(e,t,o,n)=>{const r=o.parentNode;return!_(o[n])&&(!(r!==t&&!w(r)&&!e.isBlock(r))||Ih(e,t,r,n))},Fh=(e,t,o,n,r)=>{let i=o;const s=r?"previousSibling":"nextSibling",a=e.getRoot();if(Qn(o)&&!Oh(o)&&(r?n>0:nTh(e.parentNode)||Th(e),zh=(e,t,o,n=!1)=>{let{startContainer:r,startOffset:i,endContainer:s,endOffset:a}=t;const l=o[0];return Un(r)&&r.hasChildNodes()&&(r=fa(r,i),Qn(r)&&(i=0)),Un(s)&&s.hasChildNodes()&&(s=fa(s,t.collapsed?a:a-1),Qn(s)&&(a=s.data.length)),r=Ah(e,r),s=Ah(e,s),Lh(r)&&(r=Th(r)?r:r.parentNode,r=t.collapsed?r.previousSibling||r:r.nextSibling||r,Qn(r)&&(i=t.collapsed?r.length:0)),Lh(s)&&(s=Th(s)?s:s.parentNode,s=t.collapsed?s.nextSibling||s:s.previousSibling||s,Qn(s)&&(a=t.collapsed?0:s.length)),t.collapsed&&(Vh(e,e.getRoot(),r,i,!0,n).each((({container:e,offset:t})=>{r=e,i=t})),Vh(e,e.getRoot(),s,a,!1,n).each((({container:e,offset:t})=>{s=e,a=t}))),(kh(l)||l.block_expand)&&(kh(l)&&Qn(r)&&0!==i||(r=Fh(e,o,r,i,!0)),kh(l)&&Qn(s)&&a!==s.data.length||(s=Fh(e,o,s,a,!1))),Sh(l)&&(r=Dh(e,o,t,r,"previousSibling"),s=Dh(e,o,t,s,"nextSibling")),(xh(l)||Ch(l))&&(r=Ph(e,o,r,"previousSibling"),s=Ph(e,o,s,"nextSibling"),xh(l)&&(e.isBlock(r)||(r=Fh(e,o,r,i,!0)),e.isBlock(s)||(s=Fh(e,o,s,a,!1)))),Un(r)&&r.parentNode&&(i=e.nodeIndex(r),r=r.parentNode),Un(s)&&s.parentNode&&(a=e.nodeIndex(s)+1,s=s.parentNode),{startContainer:r,startOffset:i,endContainer:s,endOffset:a}},Hh=(e,t,o)=>{var n;const r=t.startOffset,i=fa(t.startContainer,r),s=t.endOffset,a=fa(t.endContainer,s-1),l=e=>{const t=e[0];Qn(t)&&t===i&&r>=t.data.length&&e.splice(0,1);const o=e[e.length-1];return 0===s&&e.length>0&&o===a&&Qn(o)&&e.splice(e.length-1,1),e},c=(e,t,o)=>{const n=[];for(;e&&e!==o;e=e[t])n.push(e);return n},d=(t,o)=>e.getParent(t,(e=>e.parentNode===o),o),u=(e,t,n)=>{const r=n?"nextSibling":"previousSibling";for(let i=e,s=i.parentNode;i&&i!==t;i=s){s=i.parentNode;const t=c(i===e?i:i[r],r);t.length&&(n||t.reverse(),o(l(t)))}};if(i===a)return o(l([i]));const h=null!==(n=e.findCommonAncestor(i,a))&&void 0!==n?n:e.getRoot();if(e.isChildOf(i,a))return u(i,h,!0);if(e.isChildOf(a,i))return u(a,h);const m=d(i,h)||i,p=d(a,h)||a;u(i,m,!0);const g=c(m===i?m:m.nextSibling,"nextSibling",p===a?p.nextSibling:p);g.length&&o(l(g)),u(a,p)},Zh=['pre[class*=language-][contenteditable="false"]',"figure.image","div[data-ephox-embed-iri]","div.tiny-pageembed","div.mce-toc","div[data-mce-toc]"],jh=(e,t,o,n,r,i)=>{const{uid:s=t,...a}=o;ho(e,Us()),Qt(e,`${Ws()}`,s),Qt(e,`${$s()}`,n);const{attributes:l={},classes:c=[]}=r(s,a);if(eo(e,l),((e,t)=>{W(t,(t=>{ho(e,t)}))})(e,c),i){c.length>0&&Qt(e,`${Gs()}`,c.join(","));const t=me(l);t.length>0&&Qt(e,`${Ys()}`,t.join(","))}},Uh=(e,t,o,n,r)=>{const i=bo("span",e);return jh(i,t,o,n,r,!1),i},$h=(e,t,o,n,r,i)=>{const s=[],a=Uh(e.getDoc(),o,i,n,r),l=Hs(),c=()=>{l.clear()},d=e=>{W(e,u)},u=t=>{switch(((e,t,o,n)=>Ao(t).fold((()=>"skipping"),(r=>"br"===n||(e=>Gt(e)&&yr(e)===Ir)(t)?"valid":(e=>qt(e)&&go(e,Us()))(t)?"existing":Cu(t.dom)?"caret":U(Zh,(e=>Co(t,e)))?"valid-block":hh(e,o,n)&&hh(e,jt(r),o)?"valid":"invalid-child")))(e,t,"span",jt(t))){case"invalid-child":{c();const e=Io(t);d(e),c();break}case"valid-block":c(),jh(t,o,i,n,r,!0);break;case"valid":{const e=l.get().getOrThunk((()=>{const e=ra(a);return s.push(e),l.set(e),e}));yn(t,e);break}}};return Hh(e.dom,t,(e=>{c(),(e=>{const t=$(e,wo);d(t)})(e)})),s},Wh=e=>{const t=(()=>{const e={};return{register:(t,o)=>{e[t]={name:t,settings:o}},lookup:t=>Ce(e,t).map((e=>e.settings)),getNames:()=>me(e)}})();((e,t)=>{const o=$s(),n=e=>F.from(e.attr(o)).bind(t.lookup),r=e=>{var t,o;e.attr(Ws(),null),e.attr($s(),null),e.attr(qs(),null);const n=F.from(e.attr(Ys())).map((e=>e.split(","))).getOr([]),r=F.from(e.attr(Gs())).map((e=>e.split(","))).getOr([]);W(n,(t=>e.attr(t,null)));const i=null!==(o=null===(t=e.attr("class"))||void 0===t?void 0:t.split(" "))&&void 0!==o?o:[],s=ie(i,[Us()].concat(r));e.attr("class",s.length>0?s.join(" "):null),e.attr(Gs(),null),e.attr(Ys(),null)};e.serializer.addTempAttr(qs()),e.serializer.addAttributeFilter(o,(e=>{for(const t of e)n(t).each((e=>{!1===e.persistent&&("span"===t.name?t.unwrap():r(t))}))}))})(e,t);const o=((e,t)=>{const o=Vs({}),n=()=>({listeners:[],previous:Hs()}),r=(e,t)=>{i(e,(e=>(t(e),e)))},i=(e,t)=>{const r=o.get(),i=t(Ce(r,e).getOrThunk(n));r[e]=i,o.set(r)},s=(t,o)=>{W(Qs(e,t),(e=>{o?Qt(e,qs(),"true"):ro(e,qs())}))},a=js((()=>{const o=ae(t.getNames());W(o,(t=>{i(t,(o=>{const n=o.previous.get();return Xs(e,F.some(t)).fold((()=>{n.each((e=>{(e=>{r(e,(t=>{W(t.listeners,(t=>t(!1,e)))}))})(t),o.previous.clear(),s(e,!1)}))}),(({uid:e,name:t,elements:i})=>{Dt(n,e)||(n.each((e=>s(e,!1))),((e,t,o)=>{r(e,(n=>{W(n.listeners,(n=>n(!0,e,{uid:t,nodes:$(o,(e=>e.dom))})))}))})(t,e,i),o.previous.set(e),s(e,!0))})),{previous:o.previous,listeners:o.listeners}}))}))}),30);return e.on("remove",(()=>{a.cancel()})),e.on("NodeChange",(()=>{a.throttle()})),{addListener:(e,t)=>{i(e,(e=>({previous:e.previous,listeners:e.listeners.concat([t])})))}}})(e,t),n=Xt("span"),r=e=>{W(e,(e=>{n(e)?Cn(e):(e=>{po(e,Us()),ro(e,`${Ws()}`),ro(e,`${$s()}`),ro(e,`${qs()}`);const t=oo(e,`${Ys()}`).map((e=>e.split(","))).getOr([]),o=oo(e,`${Gs()}`).map((e=>e.split(","))).getOr([]);var n;W(t,(t=>ro(e,t))),n=e,W(o,(e=>{po(n,e)})),ro(e,`${Gs()}`),ro(e,`${Ys()}`)})(e)}))};return{register:(e,o)=>{t.register(e,o)},annotate:(o,n)=>{t.lookup(o).each((t=>{((e,t,o,n)=>{e.undoManager.transact((()=>{const r=e.selection,i=r.getRng(),s=Ku(e).length>0,a=oa("mce-annotation");if(i.collapsed&&!s&&((e,t)=>{const o=zh(e.dom,t,[{inline:"span"}]);t.setStart(o.startContainer,o.startOffset),t.setEnd(o.endContainer,o.endOffset),e.selection.setRng(t)})(e,i),r.getRng().collapsed&&!s){const i=Uh(e.getDoc(),a,n,t,o.decorate);Tn(i,fr),r.getRng().insertNode(i.dom),r.select(i.dom)}else rh(r,!1,(()=>{nh(e,(r=>{$h(e,r,a,t,o.decorate,n)}))}))}))})(e,o,t,n)}))},annotationChanged:(e,t)=>{o.addListener(e,t)},remove:t=>{Xs(e,F.some(t)).each((({elements:t})=>{const o=e.selection.getBookmark();r(t),e.selection.moveToBookmark(o)}))},removeAll:t=>{const o=e.selection.getBookmark();ge(ea(e,t),((e,t)=>{r(e)})),e.selection.moveToBookmark(o)},getAll:t=>{const o=ea(e,t);return fe(o,(e=>$(e,(e=>e.dom))))}}},qh=e=>({getBookmark:B(Vu,e),moveToBookmark:B(Du,e)});qh.isBookmarkNode=Pu;const Gh=(e,t,o)=>!o.collapsed&&U(o.getClientRects(),(o=>((e,t,o)=>t>=e.left&&t<=e.right&&o>=e.top&&o<=e.bottom)(o,e,t))),Yh=(e,t,o)=>{e.dispatch(t,o)},Kh=(e,t,o,n)=>{e.dispatch("FormatApply",{format:t,node:o,vars:n})},Xh=(e,t,o,n)=>{e.dispatch("FormatRemove",{format:t,node:o,vars:n})},Jh=(e,t)=>e.dispatch("SetContent",t),Qh=(e,t)=>e.dispatch("GetContent",t),em=(e,t)=>e.dispatch("PastePlainTextToggle",{state:t}),tm={BACKSPACE:8,DELETE:46,DOWN:40,ENTER:13,ESC:27,LEFT:37,RIGHT:39,SPACEBAR:32,TAB:9,UP:38,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,modifierPressed:e=>e.shiftKey||e.ctrlKey||e.altKey||tm.metaKeyPressed(e),metaKeyPressed:e=>At.os.isMacOS()||At.os.isiOS()?e.metaKey:e.ctrlKey&&!e.altKey},om="data-mce-selected",nm=Math.abs,rm=Math.round,im={nw:[0,0,-1,-1],ne:[1,0,1,-1],se:[1,1,1,1],sw:[0,1,-1,1]},sm=(e,t)=>{const o=t.dom,n=t.getDoc(),r=document,i=t.getBody();let s,a,l,c,d,u,h,m,p,g,f,v,b,y,w;const x=e=>_(e)&&(sr(e)||o.is(e,"figure.image")),C=e=>ur(e)||o.hasClass(e,"mce-preview-object"),k=e=>{const o=e.target;((e,t)=>{if((e=>"longpress"===e.type||0===e.type.indexOf("touch"))(e)){const o=e.touches[0];return x(e.target)&&!Gh(o.clientX,o.clientY,t)}return x(e.target)&&!Gh(e.clientX,e.clientY,t)})(e,t.selection.getRng())&&!e.isDefaultPrevented()&&t.selection.select(o)},S=e=>o.hasClass(e,"mce-preview-object")&&_(e.firstElementChild)?[e,e.firstElementChild]:o.is(e,"figure.image")?[e.querySelector("img")]:[e],T=e=>{const n=tc(t);return!!n&&"false"!==e.getAttribute("data-mce-resize")&&e!==t.getBody()&&(o.hasClass(e,"mce-preview-object")&&_(e.firstElementChild)?Co(wo(e.firstElementChild),n):Co(wo(e),n))},E=(e,n,r)=>{if(_(r)){const i=S(e);W(i,(e=>{e.style[n]||!t.schema.isValid(e.nodeName.toLowerCase(),n)?o.setStyle(e,n,r):o.setAttrib(e,n,""+r)}))}},O=(e,t,o)=>{E(e,"width",t),E(e,"height",o)},M=e=>{let n,r,d,_,k;n=e.screenX-u,r=e.screenY-h,v=n*c[2]+m,b=r*c[3]+p,v=v<5?5:v,b=b<5?5:b,d=(x(s)||C(s))&&!1!==oc(t)?!tm.modifierPressed(e):tm.modifierPressed(e),d&&(nm(n)>nm(r)?(b=rm(v*g),v=rm(b/g)):(v=rm(b/g),b=rm(v*g))),O(a,v,b),_=c.startPos.x+n,k=c.startPos.y+r,_=_>0?_:0,k=k>0?k:0,o.setStyles(l,{left:_,top:k,display:"block"}),l.innerHTML=v+" × "+b,c[2]<0&&a.clientWidth<=v&&o.setStyle(a,"left",void 0+(m-v)),c[3]<0&&a.clientHeight<=b&&o.setStyle(a,"top",void 0+(p-b)),n=i.scrollWidth-y,r=i.scrollHeight-w,n+r!==0&&o.setStyles(l,{left:_-n,top:k-r}),f||(((e,t,o,n,r)=>{e.dispatch("ObjectResizeStart",{target:t,width:o,height:n,origin:r})})(t,s,m,p,"corner-"+c.name),f=!0)},A=()=>{const e=f;f=!1,e&&(E(s,"width",v),E(s,"height",b)),o.unbind(n,"mousemove",M),o.unbind(n,"mouseup",A),r!==n&&(o.unbind(r,"mousemove",M),o.unbind(r,"mouseup",A)),o.remove(a),o.remove(l),o.remove(d),B(s),e&&(((e,t,o,n,r)=>{e.dispatch("ObjectResized",{target:t,width:o,height:n,origin:r})})(t,s,v,b,"corner-"+c.name),o.setAttrib(s,"style",o.getAttrib(s,"style"))),t.nodeChanged()},B=e=>{P();const f=o.getPos(e,i),_=f.x,x=f.y,k=e.getBoundingClientRect(),E=k.width||k.right-k.left,B=k.height||k.bottom-k.top;s!==e&&(R(),s=e,v=b=0);const N=t.dispatch("ObjectSelected",{target:e});T(e)&&!N.isDefaultPrevented()?ge(im,((e,t)=>{let f=o.get("mceResizeHandle"+t);f&&o.remove(f),f=o.add(i,"div",{id:"mceResizeHandle"+t,"data-mce-bogus":"all",class:"mce-resizehandle",unselectable:!0,style:"cursor:"+t+"-resize; margin:0; padding:0"}),o.bind(f,"mousedown",(f=>{f.stopImmediatePropagation(),f.preventDefault(),(f=>{const v=S(s)[0];var b;u=f.screenX,h=f.screenY,m=v.clientWidth,p=v.clientHeight,g=p/m,c=e,c.name=t,c.startPos={x:E*e[0]+_,y:B*e[1]+x},y=i.scrollWidth,w=i.scrollHeight,d=o.add(i,"div",{class:"mce-resize-backdrop","data-mce-bogus":"all"}),o.setStyles(d,{position:"fixed",left:"0",top:"0",width:"100%",height:"100%"}),a=C(b=s)?o.create("img",{src:At.transparentSrc}):b.cloneNode(!0),o.addClass(a,"mce-clonedresizable"),o.setAttrib(a,"data-mce-bogus","all"),a.contentEditable="false",o.setStyles(a,{left:_,top:x,margin:0}),O(a,E,B),a.removeAttribute(om),i.appendChild(a),o.bind(n,"mousemove",M),o.bind(n,"mouseup",A),r!==n&&(o.bind(r,"mousemove",M),o.bind(r,"mouseup",A)),l=o.add(i,"div",{class:"mce-resize-helper","data-mce-bogus":"all"},m+" × "+p)})(f)})),e.elm=f,o.setStyles(f,{left:E*e[0]+_-f.offsetWidth/2,top:B*e[1]+x-f.offsetHeight/2})})):R(!1)},N=Zs(B,0),R=(e=!0)=>{N.cancel(),P(),s&&e&&s.removeAttribute(om),ge(im,((e,t)=>{const n=o.get("mceResizeHandle"+t);n&&(o.unbind(n),o.remove(n))}))},V=(e,t)=>o.isChildOf(e,t),D=n=>{if(f||t.removed||t.composing)return;const r="mousedown"===n.type?n.target:e.getNode(),s=on(wo(r),"table,img,figure.image,hr,video,span.mce-preview-object,details").map((e=>e.dom)).filter((e=>o.isEditable(e.parentElement))).getOrUndefined(),a=_(s)?o.getAttrib(s,om,"1"):"1";if(W(o.select(`img[${om}],hr[${om}]`),(e=>{e.removeAttribute(om)})),_(s)&&V(s,i)&&t.hasFocus()){I();const t=e.getStart(!0);if(V(t,s)&&V(e.getEnd(!0),s))return o.setAttrib(s,om,a),void N.throttle(s)}R()},P=()=>{ge(im,(e=>{e.elm&&(o.unbind(e.elm),delete e.elm)}))},I=()=>{try{t.getDoc().execCommand("enableObjectResizing",!1,"false")}catch(e){}};return t.on("init",(()=>{I(),t.on("NodeChange ResizeEditor ResizeWindow ResizeContent drop",D),t.on("keyup compositionend",(e=>{s&&"TABLE"===s.nodeName&&D(e)})),t.on("hide blur",R),t.on("contextmenu longpress",k,!0)})),t.on("remove",P),{isResizable:T,showResizeRect:B,hideResizeRect:R,updateResizeRect:D,destroy:()=>{N.cancel(),s=a=d=null}}},am=(e,t,o)=>{const n=e.document.createRange();var r;return r=n,t.fold((e=>{r.setStartBefore(e.dom)}),((e,t)=>{r.setStart(e.dom,t)}),(e=>{r.setStartAfter(e.dom)})),((e,t)=>{t.fold((t=>{e.setEndBefore(t.dom)}),((t,o)=>{e.setEnd(t.dom,o)}),(t=>{e.setEndAfter(t.dom)}))})(n,o),n},lm=(e,t,o,n,r)=>{const i=e.document.createRange();return i.setStart(t.dom,o),i.setEnd(n.dom,r),i},cm=al([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),dm=(e,t,o)=>t(wo(o.startContainer),o.startOffset,wo(o.endContainer),o.endOffset);cm.ltr,cm.rtl;const um=(e,t,o,n)=>({start:e,soffset:t,finish:o,foffset:n}),hm=document.caretPositionFromPoint?(e,t,o)=>{var n,r;return F.from(null===(r=(n=e.dom).caretPositionFromPoint)||void 0===r?void 0:r.call(n,t,o)).bind((t=>{if(null===t.offsetNode)return F.none();const o=e.dom.createRange();return o.setStart(t.offsetNode,t.offset),o.collapse(),F.some(o)}))}:document.caretRangeFromPoint?(e,t,o)=>{var n,r;return F.from(null===(r=(n=e.dom).caretRangeFromPoint)||void 0===r?void 0:r.call(n,t,o))}:F.none,mm=al([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),pm={before:mm.before,on:mm.on,after:mm.after,cata:(e,t,o,n)=>e.fold(t,o,n),getStart:e=>e.fold(M,M,M)},gm=al([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),fm={domRange:gm.domRange,relative:gm.relative,exact:gm.exact,exactFromRange:e=>gm.exact(e.start,e.soffset,e.finish,e.foffset),getWin:e=>{const t=(e=>e.match({domRange:e=>wo(e.startContainer),relative:(e,t)=>pm.getStart(e),exact:(e,t,o,n)=>e}))(e);return Mo(t)},range:um},vm=(e,t)=>{const o=jt(e);return"input"===o?pm.after(e):j(["br","img"],o)?0===t?pm.before(e):pm.after(e):pm.on(e,t)},bm=(e,t)=>{const o=e.fold(pm.before,vm,pm.after),n=t.fold(pm.before,vm,pm.after);return fm.relative(o,n)},ym=(e,t,o,n)=>{const r=vm(e,t),i=vm(o,n);return fm.relative(r,i)},wm=(e,t)=>{const o=(t||document).createDocumentFragment();return W(e,(e=>{o.appendChild(e.dom)})),wo(o)},_m=e=>{const t=fm.getWin(e).dom,o=(e,o,n,r)=>lm(t,e,o,n,r),n=(e=>e.match({domRange:e=>{const t=wo(e.startContainer),o=wo(e.endContainer);return ym(t,e.startOffset,o,e.endOffset)},relative:bm,exact:ym}))(e);return((e,t)=>{const o=((e,t)=>t.match({domRange:e=>({ltr:O(e),rtl:F.none}),relative:(t,o)=>({ltr:De((()=>am(e,t,o))),rtl:De((()=>F.some(am(e,o,t))))}),exact:(t,o,n,r)=>({ltr:De((()=>lm(e,t,o,n,r))),rtl:De((()=>F.some(lm(e,n,r,t,o))))})}))(e,t);return((e,t)=>{const o=t.ltr();return o.collapsed?t.rtl().filter((e=>!1===e.collapsed)).map((e=>cm.rtl(wo(e.endContainer),e.endOffset,wo(e.startContainer),e.startOffset))).getOrThunk((()=>dm(0,cm.ltr,o))):dm(0,cm.ltr,o)})(0,o)})(t,n).match({ltr:o,rtl:o})},xm=(e,t,o)=>((e,t,o)=>((e,t,o)=>{const n=wo(e.document);return hm(n,t,o).map((e=>um(wo(e.startContainer),e.startOffset,wo(e.endContainer),e.endOffset)))})(e,t,o))(Mo(wo(o)).dom,e,t).map((e=>{const t=o.createRange();return t.setStart(e.start.dom,e.soffset),t.setEnd(e.finish.dom,e.foffset),t})).getOrUndefined(),Cm=(e,t)=>_(e)&&_(t)&&e.startContainer===t.startContainer&&e.startOffset===t.startOffset&&e.endContainer===t.endContainer&&e.endOffset===t.endOffset,km=(e,t,o)=>null!==((e,t,o)=>{let n=e;for(;n&&n!==t;){if(o(n))return n;n=n.parentNode}return null})(e,t,o),Sm=(e,t,o)=>km(e,t,(e=>e.nodeName===o)),Tm=(e,t)=>Ur(e)&&!km(e,t,Cu),Em=(e,t,o)=>{const n=t.parentNode;if(n){const r=new Hn(t,e.getParent(n,e.isBlock)||e.getRoot());let i;for(;i=r[o?"prev":"next"]();)if(ir(i))return!0}return!1},Om=(e,t,o,n,r)=>{const i=e.getRoot(),s=e.schema.getNonEmptyElements(),a=r.parentNode;let l,c;if(!a)return F.none();const d=e.getParent(a,e.isBlock)||i;if(n&&ir(r)&&t&&e.isEmpty(d))return F.some(Pa(a,e.nodeIndex(r)));const u=new Hn(r,d);for(;c=u[n?"prev":"next"]();){if("false"===e.getContentEditableParent(c)||Tm(c,i))return F.none();if(Qn(c)&&c.data.length>0)return Sm(c,i,"A")?F.none():F.some(Pa(c,n?c.data.length:0));if(e.isBlock(c)||s[c.nodeName.toLowerCase()])return F.none();l=c}return or(l)?F.none():o&&l?F.some(Pa(l,0)):F.none()},Mm=(e,t,o,n)=>{const r=e.getRoot();let i,s=!1,a=o?n.startContainer:n.endContainer,l=o?n.startOffset:n.endOffset;const c=Un(a)&&l===a.childNodes.length,d=e.schema.getNonEmptyElements();let u=o;if(Ur(a))return F.none();if(Un(a)&&l>a.childNodes.length-1&&(u=!1),nr(a)&&(a=r,l=0),a===r){if(u&&(i=a.childNodes[l>0?l-1:0],i)){if(Ur(i))return F.none();if(d[i.nodeName]||Kn(i))return F.none()}if(a.hasChildNodes()){if(l=Math.min(!u&&l>0?l-1:l,a.childNodes.length-1),a=a.childNodes[l],l=Qn(a)&&c?a.data.length:0,!t&&a===r.lastChild&&Kn(a))return F.none();if(((e,t)=>{let o=t;for(;o&&o!==e;){if(lr(o))return!0;o=o.parentNode}return!1})(r,a)||Ur(a))return F.none();if(a.hasChildNodes()&&!Kn(a)){i=a;const t=new Hn(a,r);do{if(lr(i)||Ur(i)){s=!1;break}if(Qn(i)&&i.data.length>0){l=u?0:i.data.length,a=i,s=!0;break}if(d[i.nodeName.toLowerCase()]&&!dr(i)){l=e.nodeIndex(i),a=i.parentNode,u||l++,s=!0;break}}while(i=u?t.next():t.prev())}}}return t&&(Qn(a)&&0===l&&Om(e,c,t,!0,a).each((e=>{a=e.container(),l=e.offset(),s=!0})),Un(a)&&(i=a.childNodes[l],i||(i=a.childNodes[l-1]),!i||!ir(i)||((e,t)=>{var o;return"A"===(null===(o=e.previousSibling)||void 0===o?void 0:o.nodeName)})(i)||Em(e,i,!1)||Em(e,i,!0)||Om(e,c,t,!0,i).each((e=>{a=e.container(),l=e.offset(),s=!0})))),u&&!t&&Qn(a)&&l===a.data.length&&Om(e,c,t,!1,a).each((e=>{a=e.container(),l=e.offset(),s=!0})),s&&a?F.some(Pa(a,l)):F.none()},Am=(e,t)=>{const o=t.collapsed,n=t.cloneRange(),r=Pa.fromRangeStart(t);return Mm(e,o,!0,n).each((e=>{o&&Pa.isAbove(r,e)||n.setStart(e.container(),e.offset())})),o||Mm(e,o,!1,n).each((e=>{n.setEnd(e.container(),e.offset())})),o&&n.collapse(!0),Cm(t,n)?F.none():F.some(n)},Bm=(e,t)=>e.splitText(t),Nm=e=>{let t=e.startContainer,o=e.startOffset,n=e.endContainer,r=e.endOffset;if(t===n&&Qn(t)){if(o>0&&oo){r-=o;const e=Bm(n,r).previousSibling;t=n=e,r=e.data.length,o=0}else r=0}else if(Qn(t)&&o>0&&o0&&r({walk:(t,o)=>Hh(e,t,o),split:Nm,expand:(t,o={type:"word"})=>{if("word"===o.type){const o=zh(e,t,[{inline:"span"}]),n=e.createRng();return n.setStart(o.startContainer,o.startOffset),n.setEnd(o.endContainer,o.endOffset),n}return t},normalize:t=>Am(e,t).fold(P,(e=>(t.setStart(e.startContainer,e.startOffset),t.setEnd(e.endContainer,e.endOffset),!0)))});Rm.compareRanges=Cm,Rm.getCaretRangeFromPoint=xm,Rm.getSelectedNode=ga,Rm.getNode=fa;const Vm=((e,t)=>{const o=t=>{const o=(e=>{const t=e.dom;return Ko(e)?t.getBoundingClientRect().height:t.offsetHeight})(t);if(o<=0||null===o){const o=dn(t,e);return parseFloat(o)||0}return o},n=(e,t)=>X(t,((t,o)=>{const n=dn(e,o),r=void 0===n?0:parseInt(n,10);return isNaN(r)?t:t+r}),0);return{set:(t,o)=>{if(!C(o)&&!o.match(/^[0-9]+$/))throw new Error(e+".set accepts only positive integer values. Value was "+o);const n=t.dom;sn(n)&&(n.style[e]=o+"px")},get:o,getOuter:o,aggregate:n,max:(e,t,o)=>{const r=n(e,o);return t>r?t-r:0}}})("height"),Dm=()=>wo(document),Pm=(e,t)=>e.view(t).fold(O([]),(t=>{const o=e.owner(t),n=Pm(e,o);return[t].concat(n)}));var Im=Object.freeze({__proto__:null,view:e=>{var t;return(e.dom===document?F.none():F.from(null===(t=e.dom.defaultView)||void 0===t?void 0:t.frameElement)).map(wo)},owner:e=>Oo(e)});const Fm=e=>"textarea"===jt(e),Lm=(e,t)=>{const o=(e=>{const t=e.dom.ownerDocument,o=t.body,n=t.defaultView,r=t.documentElement;if(o===e.dom)return An(o.offsetLeft,o.offsetTop);const i=Bn(null==n?void 0:n.pageYOffset,r.scrollTop),s=Bn(null==n?void 0:n.pageXOffset,r.scrollLeft),a=Bn(r.clientTop,o.clientTop),l=Bn(r.clientLeft,o.clientLeft);return Nn(e).translate(s-l,i-a)})(e),n=(e=>Vm.get(e))(e);return{element:e,bottom:o.top+n,height:n,pos:o,cleanup:t}},zm=(e,t,o,n)=>{Um(e,((r,i)=>Zm(e,t,o,n)),o)},Hm=(e,t,o,n,r)=>{const i={elm:n.element.dom,alignToTop:r};((e,t)=>e.dispatch("ScrollIntoView",t).isDefaultPrevented())(e,i)||(o(e,t,Rn(t).top,n,r),((e,t)=>{e.dispatch("AfterScrollIntoView",t)})(e,i))},Zm=(e,t,o,n)=>{const r=wo(e.getBody()),i=wo(e.getDoc());r.dom.offsetWidth;const s=((e,t)=>{const o=((e,t)=>{const o=Io(e);if(0===o.length||Fm(e))return{element:e,offset:t};if(t\ufeff');return gn(o.element,n),Lm(n,(()=>xn(n)))})(wo(o.startContainer),o.startOffset);Hm(e,i,t,s,n),s.cleanup()},jm=(e,t,o,n)=>{const r=wo(e.getDoc());Hm(e,r,o,(e=>Lm(wo(e),S))(t),n)},Um=(e,t,o)=>{const n=o.startContainer,r=o.startOffset,i=o.endContainer,s=o.endOffset;t(wo(n),wo(i));const a=e.dom.createRng();a.setStart(n,r),a.setEnd(i,s),e.selection.setRng(o)},$m=(e,t,o,n,r)=>{const i=t.pos;if(n)Vn(i.left,i.top,r);else{const n=i.top-o+t.height;Vn(-e.getBody().getBoundingClientRect().left,n,r)}},Wm=(e,t,o,n,r,i)=>{const s=n+o,a=r.pos.top,l=r.bottom,c=l-a>=n;as?$m(e,r,n,c?!1!==i:!0===i,t):l>s&&!c&&$m(e,r,n,!0===i,t)},qm=(e,t,o,n,r)=>{const i=Mo(t).dom.innerHeight;Wm(e,t,o,i,n,r)},Gm=(e,t,o,n,r)=>{const i=Mo(t).dom.innerHeight;Wm(e,t,o,i,n,r);const s=(e=>{const t=Dm(),o=Rn(t),n=((e,t)=>{const o=t.owner(e);return Pm(t,o)})(e,Im),r=Nn(e),i=K(n,((e,t)=>{const o=Nn(t);return{left:e.left+o.left,top:e.top+o.top}}),{left:0,top:0});return An(i.left+r.left+o.left,i.top+r.top+o.top)})(n.element),a=In(window);s.topa.bottom&&Dn(n.element,!0===r)},Ym=(e,t,o)=>zm(e,qm,t,o),Km=(e,t,o)=>jm(e,t,qm,o),Xm=(e,t,o)=>zm(e,Gm,t,o),Jm=(e,t,o)=>jm(e,t,Gm,o),Qm=(e,t,o)=>{(e.inline?Ym:Xm)(e,t,o)},ep=e=>e.dom.focus(),tp=e=>{const t=$o(e).dom;return e.dom===t.activeElement},op=(e=Dm())=>F.from(e.dom.activeElement).map(wo),np=(e,t)=>{const o=Gt(t)?yr(t).length:Io(t).length+1;return e>o?o:e<0?0:e},rp=e=>fm.range(e.start,np(e.soffset,e.start),e.finish,np(e.foffset,e.finish)),ip=(e,t)=>!jn(t.dom)&&(To(e,t)||So(e,t)),sp=e=>t=>ip(e,t.start)&&ip(e,t.finish),ap=e=>fm.range(wo(e.startContainer),e.startOffset,wo(e.endContainer),e.endOffset),lp=e=>{const t=document.createRange();try{return t.setStart(e.start.dom,e.soffset),t.setEnd(e.finish.dom,e.foffset),F.some(t)}catch(e){return F.none()}},cp=e=>{const t=(e=>e.inline||At.browser.isFirefox())(e)?(o=wo(e.getBody()),(e=>{const t=e.getSelection();return(t&&0!==t.rangeCount?F.from(t.getRangeAt(0)):F.none()).map(ap)})(Mo(o).dom).filter(sp(o))):F.none();var o;e.bookmark=t.isSome()?t:e.bookmark},dp=e=>(e.bookmark?e.bookmark:F.none()).bind((t=>{return o=wo(e.getBody()),n=t,F.from(n).filter(sp(o)).map(rp);var o,n})).bind(lp),up={isEditorUIElement:e=>{const t=e.className.toString();return-1!==t.indexOf("tox-")||-1!==t.indexOf("mce-")}},hp={setEditorTimeout:(e,t,o)=>((e,t)=>(C(t)||(t=0),setTimeout(e,t)))((()=>{e.removed||t()}),o),setEditorInterval:(e,t,o)=>{const n=((e,t)=>(C(t)||(t=0),setInterval(e,t)))((()=>{e.removed?clearInterval(n):t()}),o);return n}};let mp;const pp=Bs.DOM,gp=e=>{const t=e.classList;return void 0!==t&&(t.contains("tox-edit-area")||t.contains("tox-edit-area__iframe")||t.contains("mce-content-body"))},fp=(e,t)=>{const o=gc(e),n=pp.getParent(t,(t=>(e=>Un(e)&&up.isEditorUIElement(e))(t)||!!o&&e.dom.is(t,o)));return null!==n},vp=e=>{try{const t=$o(wo(e.getElement()));return op(t).fold((()=>document.body),(e=>e.dom))}catch(e){return document.body}},bp=(e,t)=>{const o=t.editor;(e=>{const t=Zs((()=>{cp(e)}),0);e.on("init",(()=>{e.inline&&((e,t)=>{const o=()=>{t.throttle()};Bs.DOM.bind(document,"mouseup",o),e.on("remove",(()=>{Bs.DOM.unbind(document,"mouseup",o)}))})(e,t),((e,t)=>{((e,t)=>{e.on("mouseup touchend",(e=>{t.throttle()}))})(e,t),e.on("keyup NodeChange AfterSetSelectionRange",(t=>{(e=>"nodechange"===e.type&&e.selectionChange)(t)||cp(e)}))})(e,t)})),e.on("remove",(()=>{t.cancel()}))})(o);const n=(e,t)=>{nd(e)&&!0!==e.inline&&t(wo(e.getContainer()),"tox-edit-focus")};o.on("focusin",(()=>{const t=e.focusedEditor;gp(vp(o))&&n(o,ho),t!==o&&(t&&t.dispatch("blur",{focusedEditor:o}),e.setActive(o),e.focusedEditor=o,o.dispatch("focus",{blurredEditor:t}),o.focus(!0))})),o.on("focusout",(()=>{hp.setEditorTimeout(o,(()=>{const t=e.focusedEditor;gp(vp(o))&&t===o||n(o,po),fp(o,vp(o))||t!==o||(o.dispatch("blur",{focusedEditor:null}),e.focusedEditor=null)}))})),mp||(mp=t=>{const o=e.activeEditor;o&&Go(t).each((t=>{const n=t;n.ownerDocument===document&&(n===document.body||fp(o,n)||e.focusedEditor!==o||(o.dispatch("blur",{focusedEditor:null}),e.focusedEditor=null))}))},pp.bind(document,"focusin",mp))},yp=(e,t)=>{e.focusedEditor===t.editor&&(e.focusedEditor=null),!e.activeEditor&&mp&&(pp.unbind(document,"focusin",mp),mp=null)},wp=(e,t)=>{((e,t)=>(e=>e.collapsed?F.from(fa(e.startContainer,e.startOffset)).map(wo):F.none())(t).bind((t=>Mr(t)?F.some(t):To(e,t)?F.none():F.some(e))))(wo(e.getBody()),t).bind((e=>wu(e.dom))).fold((()=>{e.selection.normalize()}),(t=>e.selection.setRng(t.toRange())))},_p=e=>{if(e.setActive)try{e.setActive()}catch(t){e.focus()}else e.focus()},xp=e=>e.inline?(e=>{const t=e.getBody();return t&&(o=wo(t),tp(o)||(n=o,op($o(n)).filter((e=>n.dom.contains(e.dom)))).isSome());var o,n})(e):(e=>_(e.iframeElement)&&tp(wo(e.iframeElement)))(e),Cp=e=>e.editorManager.setActive(e),kp=(e,t,o,n,r)=>{const i=o?t.startContainer:t.endContainer,s=o?t.startOffset:t.endOffset;return F.from(i).map(wo).map((e=>n&&t.collapsed?e:Fo(e,r(e,s)).getOr(e))).bind((e=>qt(e)?F.some(e):Ao(e).filter(qt))).map((e=>e.dom)).getOr(e)},Sp=(e,t,o=!1)=>kp(e,t,!0,o,((e,t)=>Math.min(Ho(e),t))),Tp=(e,t,o=!1)=>kp(e,t,!1,o,((e,t)=>t>0?t-1:t)),Ep=(e,t)=>{const o=e;for(;e&&Qn(e)&&0===e.length;)e=t?e.nextSibling:e.previousSibling;return e||o},Op=(e,t)=>$(t,(t=>{const o=e.dispatch("GetSelectionRange",{range:t});return o.range!==t?o.range:t})),Mp=["img","br"],Ap=e=>{const t=wr(e).filter((e=>0!==e.trim().length||e.indexOf(fr)>-1)).isSome();return t||j(Mp,jt(e))||(e=>Wt(e)&&"false"===to(e,"contenteditable"))(e)},Bp="[data-mce-autocompleter]",Np=(e,t)=>{if(Rp(wo(e.getBody())).isNone()){const n=vo(' ',e.getDoc());bn(n,wo(t.extractContents())),t.insertNode(n.dom),Ao(n).each((e=>e.dom.normalize())),(o=n,((e,t)=>{const o=e=>{const n=Io(e);for(let e=n.length-1;e>=0;e--){const r=n[e];if(t(r))return F.some(r);const i=o(r);if(i.isSome())return i}return F.none()};return o(e)})(o,Ap)).map((t=>{e.selection.setCursorLocation(t.dom,(e=>"img"===jt(e)?1:wr(e).fold((()=>Io(e).length),(e=>e.length)))(t))}))}var o},Rp=e=>tn(e,Bp),Vp={"#text":3,"#comment":8,"#cdata":4,"#pi":7,"#doctype":10,"#document-fragment":11},Dp=(e,t,o)=>{const n=o?"lastChild":"firstChild",r=o?"prev":"next";if(e[n])return e[n];if(e!==t){let o=e[r];if(o)return o;for(let n=e.parent;n&&n!==t;n=n.parent)if(o=n[r],o)return o}},Pp=e=>{var t;const o=null!==(t=e.value)&&void 0!==t?t:"";if(!di(o))return!1;const n=e.parent;return!n||"span"===n.name&&!n.attr("style")||!/^[ ]+$/.test(o)},Ip=e=>{const t="a"===e.name&&!e.attr("href")&&e.attr("id");return e.attr("name")||e.attr("id")&&!e.firstChild||e.attr("data-mce-bookmark")||t};class Fp{static create(e,t){const o=new Fp(e,Vp[e]||1);return t&&ge(t,((e,t)=>{o.attr(t,e)})),o}constructor(e,t){this.name=e,this.type=t,1===t&&(this.attributes=[],this.attributes.map={})}replace(e){const t=this;return e.parent&&e.remove(),t.insert(e,t),t.remove(),t}attr(e,t){const o=this;if(!m(e))return _(e)&&ge(e,((e,t)=>{o.attr(t,e)})),o;const n=o.attributes;if(n){if(void 0!==t){if(null===t){if(e in n.map){delete n.map[e];let t=n.length;for(;t--;)if(n[t].name===e)return n.splice(t,1),o}return o}if(e in n.map){let o=n.length;for(;o--;)if(n[o].name===e){n[o].value=t;break}}else n.push({name:e,value:t});return n.map[e]=t,o}return n.map[e]}}clone(){const e=this,t=new Fp(e.name,e.type),o=e.attributes;if(o){const e=[];e.map={};for(let t=0,n=o.length;tm(e.nodeValue)&&e.nodeValue.includes(Ir),Hp=e=>(0===e.length?"":`${$(e,(e=>`[${e}]`)).join(",")},`)+'[data-mce-bogus="all"]',Zp=e=>document.createTreeWalker(e,NodeFilter.SHOW_COMMENT,(e=>zp(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP)),jp=e=>document.createTreeWalker(e,NodeFilter.SHOW_TEXT,(e=>{if(zp(e)){const t=e.parentNode;return t&&ke(Lp,t.nodeName)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}return NodeFilter.FILTER_SKIP})),Up=e=>null!==Zp(e).nextNode(),$p=e=>null!==jp(e).nextNode(),Wp=(e,t)=>null!==t.querySelector(Hp(e)),qp=(e,t)=>{W(((e,t)=>t.querySelectorAll(Hp(e)))(e,t),(t=>{const o=wo(t);"all"===to(o,"data-mce-bogus")?xn(o):W(e,(e=>{no(o,e)&&ro(o,e)}))}))},Gp=e=>{let t=e.nextNode();for(;null!==t;)t.nodeValue=null,t=e.nextNode()},Yp=T(Gp,Zp),Kp=T(Gp,jp),Xp=(e,t)=>{const o=[{condition:B(Wp,t),action:B(qp,t)},{condition:Up,action:Yp},{condition:$p,action:Kp}];let n=e,r=!1;return W(o,(({condition:t,action:o})=>{t(n)&&(r||(n=e.cloneNode(!0),r=!0),o(n))})),n},Jp=e=>{const t=Ln(e,"[data-mce-bogus]");W(t,(e=>{"all"===to(e,"data-mce-bogus")?xn(e):Sr(e)?(gn(e,yo(gr)),xn(e)):Cn(e)}))},Qp=e=>{const t=Ln(e,"input");W(t,(e=>{ro(e,"name")}))},eg=(e,t,o)=>{let n;return n="raw"===t.format?Vt.trim(Lr(Xp(o,e.serializer.getTempAttrs()).innerHTML)):"text"===t.format?((e,t)=>{const o=e.getDoc(),n=$o(wo(e.getBody())),r=bo("div",o);Qt(r,"data-mce-bogus","all"),cn(r,{position:"fixed",left:"-9999999px",top:"0"}),Tn(r,t.innerHTML),Jp(r),Qp(r);const i=(e=>Zo(e)?e:wo(Oo(e).dom.body))(n);bn(i,r);const s=Lr(r.dom.innerText);return xn(r),s})(e,o):"tree"===t.format?e.serializer.serialize(o,t):((e,t)=>{const o=Ol(e),n=new RegExp(`^(<${o}[^>]*>( | |\\s| | |)<\\/${o}>[\r\n]*| [\r\n]*)$`);return t.replace(n,"")})(e,e.serializer.serialize(o,t)),"text"!==t.format&&!Br(wo(o))&&m(n)?Vt.trim(n):n},tg=Vt.makeMap,og=e=>{const t=[],o=(e=e||{}).indent,n=tg(e.indent_before||""),r=tg(e.indent_after||""),i=es.getEncodeFunc(e.entity_encoding||"raw",e.entities),s="xhtml"!==e.element_format;return{start:(e,a,l)=>{if(o&&n[e]&&t.length>0){const e=t[t.length-1];e.length>0&&"\n"!==e&&t.push("\n")}if(t.push("<",e),a)for(let e=0,o=a.length;e":" />",l&&o&&r[e]&&t.length>0){const e=t[t.length-1];e.length>0&&"\n"!==e&&t.push("\n")}},end:e=>{let n;t.push("",e,">"),o&&r[e]&&t.length>0&&(n=t[t.length-1],n.length>0&&"\n"!==n&&t.push("\n"))},text:(e,o)=>{e.length>0&&(t[t.length]=o?e:i(e))},cdata:e=>{t.push("")},comment:e=>{t.push("\x3c!--",e,"--\x3e")},pi:(e,n)=>{n?t.push("",e," ",i(n),"?>"):t.push("",e,"?>"),o&&t.push("\n")},doctype:e=>{t.push("",o?"\n":"")},reset:()=>{t.length=0},getContent:()=>t.join("").replace(/\n$/,"")}},ng=(e={},t=us())=>{const o=og(e);return e.validate=!("validate"in e)||e.validate,{serialize:n=>{const r=e.validate,i={3:e=>{var t;o.text(null!==(t=e.value)&&void 0!==t?t:"",e.raw)},8:e=>{var t;o.comment(null!==(t=e.value)&&void 0!==t?t:"")},7:e=>{o.pi(e.name,e.value)},10:e=>{var t;o.doctype(null!==(t=e.value)&&void 0!==t?t:"")},4:e=>{var t;o.cdata(null!==(t=e.value)&&void 0!==t?t:"")},11:e=>{let t=e;if(t=t.firstChild)do{s(t)}while(t=t.next)}};o.reset();const s=e=>{var n;const a=i[e.type];if(a)a(e);else{const i=e.name,a=i in t.getVoidElements();let l=e.attributes;if(r&&l&&l.length>1){const o=[];o.map={};const n=t.getElementRule(e.name);if(n){for(let e=0,t=n.attributesOrder.length;e{rg.add(e)}));const ig=["font","text-decoration","text-emphasis"],sg=(e,t)=>me(e.parseStyle(e.getAttrib(t,"style"))),ag=(e,t,o)=>{const n=sg(e,t),r=sg(e,o),i=n=>{var r,i;const s=null!==(r=e.getStyle(t,n))&&void 0!==r?r:"",a=null!==(i=e.getStyle(o,n))&&void 0!==i?i:"";return Ye(s)&&Ye(a)&&s!==a};return U(n,(e=>{const t=t=>U(t,(t=>t===e));if(!t(r)&&t(ig)){const e=Y(r,(e=>U(ig,(t=>je(e,t)))));return U(e,i)}return i(e)}))},lg=(e,t,o)=>F.from(o.container()).filter(Qn).exists((n=>{const r=e?0:-1;return t(n.data.charAt(o.offset()+r))})),cg=B(lg,!0,Lu),dg=B(lg,!1,Lu),ug=e=>{const t=e.container();return Qn(t)&&(0===t.data.length||Fr(t.data)&&qh.isBookmarkNode(t.parentNode))},hg=(e,t)=>o=>Hd(e?0:-1,o).filter(t).isSome(),mg=e=>sr(e)&&"block"===dn(wo(e),"display"),pg=e=>lr(e)&&!(e=>Un(e)&&"all"===e.getAttribute("data-mce-bogus"))(e),gg=hg(!0,mg),fg=hg(!1,mg),vg=hg(!0,ur),bg=hg(!1,ur),yg=hg(!0,Kn),wg=hg(!1,Kn),_g=hg(!0,pg),xg=hg(!1,pg),Cg=(e,t)=>((e,t,o)=>To(t,e)?No(e,(e=>o(e)||So(e,t))).slice(0,-1):[])(e,t,P),kg=(e,t)=>[e].concat(Cg(e,t)),Sg=(e,t,o)=>fu(e,t,o,ug),Tg=(e,t)=>Q(kg(wo(t.container()),e),Cr),Eg=(e,t,o)=>Sg(e,t.dom,o).forall((e=>Tg(t,o).fold((()=>!zd(e,o,t.dom)),(n=>!zd(e,o,t.dom)&&To(n,wo(e.container())))))),Og=(e,t,o)=>Tg(t,o).fold((()=>Sg(e,t.dom,o).forall((e=>!zd(e,o,t.dom)))),(t=>Sg(e,t.dom,o).isNone())),Mg=B(Og,!1),Ag=B(Og,!0),Bg=B(Eg,!1),Ng=B(Eg,!0),Rg=e=>Kd(e).exists(Sr),Vg=(e,t,o)=>{const n=Y(kg(wo(o.container()),t),Cr),r=ce(n).getOr(t);return pu(e,r.dom,o).filter(Rg)},Dg=(e,t)=>Kd(t).exists(Sr)||Vg(!0,e,t).isSome(),Pg=(e,t)=>(e=>F.from(e.getNode(!0)).map(wo))(t).exists(Sr)||Vg(!1,e,t).isSome(),Ig=B(Vg,!1),Fg=B(Vg,!0),Lg=e=>Pa.isTextPosition(e)&&!e.isAtStart()&&!e.isAtEnd(),zg=(e,t)=>{const o=Y(kg(wo(t.container()),e),Cr);return ce(o).getOr(e)},Hg=(e,t)=>Lg(t)?dg(t):dg(t)||yu(zg(e,t).dom,t).exists(dg),Zg=(e,t)=>Lg(t)?cg(t):cg(t)||bu(zg(e,t).dom,t).exists(cg),jg=e=>Kd(e).bind((e=>Qo(e,qt))).exists((e=>(e=>j(["pre","pre-wrap"],e))(dn(e,"white-space")))),Ug=(e,t)=>o=>{return n=new Hn(o,e)[t](),_(n)&&lr(n)&&Md(n);var n},$g=(e,t)=>!jg(t)&&(((e,t)=>((e,t)=>yu(e.dom,t).isNone())(e,t)||((e,t)=>bu(e.dom,t).isNone())(e,t)||Mg(e,t)||Ag(e,t)||Pg(e,t)||Dg(e,t))(e,t)||Hg(e,t)||Zg(e,t)),Wg=(e,t)=>!jg(t)&&(Mg(e,t)||Bg(e,t)||Pg(e,t)||Hg(e,t)||((e,t)=>{const o=yu(e.dom,t).getOr(t),n=Ug(e.dom,"prev");return t.isAtStart()&&(n(t.container())||n(o.container()))})(e,t)),qg=(e,t)=>!jg(t)&&(Ag(e,t)||Ng(e,t)||Dg(e,t)||Zg(e,t)||((e,t)=>{const o=bu(e.dom,t).getOr(t),n=Ug(e.dom,"next");return t.isAtEnd()&&(n(t.container())||n(o.container()))})(e,t)),Gg=(e,t)=>Wg(e,t)||qg(e,(e=>{const t=e.container(),o=e.offset();return Qn(t)&&oIu(e.charAt(t)),Kg=(e,t)=>Lu(e.charAt(t)),Xg=(e,t,o)=>{const n=t.data,r=Pa(t,0);return o||!Yg(n,0)||Gg(e,r)?!!(o&&Kg(n,0)&&Wg(e,r))&&(t.data=fr+n.slice(1),!0):(t.data=" "+n.slice(1),!0)},Jg=(e,t,o)=>{const n=t.data,r=Pa(t,n.length-1);return o||!Yg(n,n.length-1)||Gg(e,r)?!!(o&&Kg(n,n.length-1)&&qg(e,r))&&(t.data=n.slice(0,-1)+fr,!0):(t.data=n.slice(0,-1)+" ",!0)},Qg=(e,t)=>{const o=t.container();if(!Qn(o))return F.none();if((e=>{const t=e.container();return Qn(t)&&Ze(t.data,fr)})(t)){const n=Xg(e,o,!1)||(e=>{const t=e.data,o=(e=>{const t=e.split("");return $(t,((e,o)=>Iu(e)&&o>0&&o{if(0===o)return;const n=wo(e),r=Jo(n,Cr).getOr(n),i=e.data.slice(t,t+o),s=t+o>=e.data.length&&qg(r,Pa(e,e.data.length)),a=0===t&&Wg(r,Pa(e,0));e.replaceData(t,o,mi(i,4,a,s))},tf=(e,t)=>{const o=e.data.slice(t),n=o.length-qe(o).length;ef(e,t,n)},of=(e,t)=>{const o=e.data.slice(0,t),n=o.length-Ge(o).length;ef(e,t-n,n)},nf=(e,t,o,n=!0)=>{const r=Ge(e.data).length,i=n?e:t,s=n?t:e;return n?i.appendData(s.data):i.insertData(0,s.data),xn(wo(s)),o&&tf(i,r),i},rf=(e,t)=>((e,t)=>{const o=e.container(),n=e.offset();return!Pa.isTextPosition(e)&&o===t.parentNode&&n>Pa.before(t).offset()})(t,e)?Pa(t.container(),t.offset()-1):t,sf=e=>{return si(e.previousSibling)?F.some((t=e.previousSibling,Qn(t)?Pa(t,t.data.length):Pa.after(t))):e.previousSibling?_u(e.previousSibling):F.none();var t},af=e=>{return si(e.nextSibling)?F.some((t=e.nextSibling,Qn(t)?Pa(t,0):Pa.before(t))):e.nextSibling?wu(e.nextSibling):F.none();var t},lf=(e,t,o)=>((e,t,o)=>e?((e,t)=>af(t).orThunk((()=>sf(t))).orThunk((()=>((e,t)=>bu(e,Pa.after(t)).orThunk((()=>yu(e,Pa.before(t)))))(e,t))))(t,o):((e,t)=>sf(t).orThunk((()=>af(t))).orThunk((()=>((e,t)=>F.from(t.previousSibling?t.previousSibling:t.parentNode).bind((t=>yu(e,Pa.before(t)))).orThunk((()=>bu(e,Pa.after(t)))))(e,t))))(t,o))(e,t,o).map(B(rf,o)),cf=(e,t,o)=>{o.fold((()=>{e.focus()}),(o=>{e.selection.setRng(o.toRange(),t)}))},df=(e,t)=>t&&ke(e.schema.getBlockElements(),jt(t)),uf=e=>{if(bi(e)){const t=vo(' ');return _n(e),bn(e,t),F.some(Pa.before(t.dom))}return F.none()},hf=(e,t,o,n=!0)=>{const r=lf(t,e.getBody(),o.dom),i=Jo(o,B(df,e),(s=e.getBody(),e=>e.dom===s));var s;const a=((e,t,o)=>{const n=Ro(e).filter(Gt),r=Vo(e).filter(Gt);return xn(e),(i=n,s=r,a=t,l=(e,t,n)=>{const r=e.dom,i=t.dom,s=r.data.length;return nf(r,i,o),n.container()===i?Pa(r,s):n},i.isSome()&&s.isSome()&&a.isSome()?F.some(l(i.getOrDie(),s.getOrDie(),a.getOrDie())):F.none()).orThunk((()=>(o&&(n.each((e=>of(e.dom,e.dom.length))),r.each((e=>tf(e.dom,0)))),t)));var i,s,a,l})(o,r,((e,t)=>ke(e.schema.getTextInlineElements(),jt(t)))(e,o));e.dom.isEmpty(e.getBody())?(e.setContent(""),e.selection.setCursorLocation()):i.bind(uf).fold((()=>{n&&cf(e,t,a)}),(o=>{n&&cf(e,t,F.some(o))}))},mf=/[\u0591-\u07FF\uFB1D-\uFDFF\uFE70-\uFEFC]/,pf=(e,t)=>Co(wo(t),ec(e))&&!Ai(e.schema,t)&&e.dom.isEditable(t),gf=e=>{var t;return"rtl"===Bs.DOM.getStyle(e,"direction",!0)||(e=>mf.test(e))(null!==(t=e.textContent)&&void 0!==t?t:"")},ff=(e,t,o)=>{const n=((e,t,o)=>Y(Bs.DOM.getParents(o.container(),"*",t),e))(e,t,o);return F.from(n[n.length-1])},vf=(e,t)=>{const o=t.container(),n=t.offset();return e?jr(o)?Qn(o.nextSibling)?Pa(o.nextSibling,0):Pa.after(o):Wr(t)?Pa(o,n+1):t:jr(o)?Qn(o.previousSibling)?Pa(o.previousSibling,o.previousSibling.data.length):Pa.before(o):qr(t)?Pa(o,n-1):t},bf=B(vf,!0),yf=B(vf,!1),wf=(e,t)=>{const o=e=>e.stopImmediatePropagation();e.on("beforeinput input",o,!0),e.getDoc().execCommand(t),e.off("beforeinput input",o)},_f=e=>wf(e,"Delete"),xf=e=>Tr(e)||Or(e),Cf=(e,t)=>To(e,t)?Qo(t,xf,(e=>t=>Dt(Ao(t),e,So))(e)):F.none(),kf=(e,t=!0)=>{e.dom.isEmpty(e.getBody())&&e.setContent("",{no_selection:!t})},Sf=(e,t,o)=>It(wu(o),_u(o),((n,r)=>{const i=vf(!0,n),s=vf(!1,r),a=vf(!1,t);return e?bu(o,a).exists((e=>e.isEqual(s)&&t.isEqual(i))):yu(o,a).exists((e=>e.isEqual(i)&&t.isEqual(s)))})).getOr(!0),Tf=e=>{var t;return(8===Ut(t=e)||"#comment"===jt(t)?Ro(e):zo(e)).bind(Tf).orThunk((()=>F.some(e)))},Ef=(e,t,o,n=!0)=>{var r;t.deleteContents();const i=Tf(o).getOr(o),s=wo(null!==(r=e.dom.getParent(i.dom,e.dom.isBlock))&&void 0!==r?r:o.dom);if(s.dom===e.getBody()?kf(e,n):bi(s)&&(Dr(s),n&&e.selection.setCursorLocation(s.dom,0)),!So(o,s)){const e=Dt(Ao(s),o)?[]:Ao(a=s).map(Io).map((e=>Y(e,(e=>!So(a,e))))).getOr([]);W(e.concat(Io(o)),(e=>{So(e,s)||To(e,s)||!bi(e)||xn(e)}))}var a},Of=e=>Ln(e,"td,th"),Mf=(e,t)=>({start:e,end:t}),Af=al([{singleCellTable:["rng","cell"]},{fullTable:["table"]},{partialTable:["cells","outsideDetails"]},{multiTable:["startTableCells","endTableCells","betweenRng"]}]),Bf=(e,t)=>on(wo(e),"td,th",t),Nf=e=>!So(e.start,e.end),Rf=(e,t)=>Xu(e.start,t).bind((o=>Xu(e.end,t).bind((e=>Ft(So(o,e),o))))),Vf=e=>t=>Rf(t,e).map((e=>((e,t,o)=>({rng:e,table:t,cells:o}))(t,e,Of(e)))),Df=(e,t,o,n)=>{if(o.collapsed||!e.forall(Nf))return F.none();if(t.isSameTable){const t=e.bind(Vf(n));return F.some({start:t,end:t})}{const e=Bf(o.startContainer,n),t=Bf(o.endContainer,n),r=e.bind((e=>t=>Xu(t,e).bind((e=>de(Of(e)).map((e=>Mf(t,e))))))(n)).bind(Vf(n)),i=t.bind((e=>t=>Xu(t,e).bind((e=>ce(Of(e)).map((e=>Mf(e,t))))))(n)).bind(Vf(n));return F.some({start:r,end:i})}},Pf=(e,t)=>ee(e,(e=>So(e,t))),If=e=>It(Pf(e.cells,e.rng.start),Pf(e.cells,e.rng.end),((t,o)=>e.cells.slice(t,o+1))),Ff=(e,t)=>{const{startTable:o,endTable:n}=t,r=e.cloneRange();return o.each((e=>r.setStartAfter(e.dom))),n.each((e=>r.setEndBefore(e.dom))),r},Lf=(e,t)=>{const o=(e=>t=>So(e,t))(e),n=((e,t)=>{const o=Bf(e.startContainer,t),n=Bf(e.endContainer,t);return It(o,n,Mf)})(t,o),r=((e,t)=>{const o=e=>Xu(wo(e),t),n=o(e.startContainer),r=o(e.endContainer),i=n.isSome(),s=r.isSome(),a=It(n,r,So).getOr(!1);return{startTable:n,endTable:r,isStartInTable:i,isEndInTable:s,isSameTable:a,isMultiTable:!a&&i&&s}})(t,o);return((e,t,o)=>e.exists((e=>((e,t)=>!Nf(e)&&Rf(e,t).exists((e=>{const t=e.dom.rows;return 1===t.length&&1===t[0].cells.length})))(e,o)&&eh(e.start,t))))(n,t,o)?n.map((e=>Af.singleCellTable(t,e.start))):r.isMultiTable?((e,t,o,n)=>Df(e,t,o,n).bind((({start:e,end:n})=>{const r=e.bind(If).getOr([]),i=n.bind(If).getOr([]);if(r.length>0&&i.length>0){const e=Ff(o,t);return F.some(Af.multiTable(r,i,e))}return F.none()})))(n,r,t,o):((e,t,o,n)=>Df(e,t,o,n).bind((({start:e,end:t})=>e.or(t))).bind((e=>{const{isSameTable:n}=t,r=If(e).getOr([]);if(n&&e.cells.length===r.length)return F.some(Af.fullTable(e.table));if(r.length>0){if(n)return F.some(Af.partialTable(r,F.none()));{const e=Ff(o,t);return F.some(Af.partialTable(r,F.some({...t,rng:e})))}}return F.none()})))(n,r,t,o)},zf=e=>W(e,(e=>{ro(e,"contenteditable"),Dr(e)})),Hf=(e,t,o,n)=>{const r=o.cloneRange();n?(r.setStart(o.startContainer,o.startOffset),r.setEndAfter(t.dom.lastChild)):(r.setStartBefore(t.dom.firstChild),r.setEnd(o.endContainer,o.endOffset)),$f(e,r,t,!1).each((e=>e()))},Zf=e=>{const t=Ku(e),o=wo(e.selection.getNode());cr(o.dom)&&bi(o)?e.selection.setCursorLocation(o.dom,0):e.selection.collapse(!0),t.length>1&&U(t,(e=>So(e,o)))&&Qt(o,"data-mce-selected","1")},jf=(e,t,o)=>F.some((()=>{const n=e.selection.getRng(),r=o.bind((({rng:o,isStartInTable:r})=>{const i=((e,t)=>F.from(e.dom.getParent(t,e.dom.isBlock)).map(wo))(e,r?o.endContainer:o.startContainer);o.deleteContents(),((e,t,o)=>{o.each((o=>{t?xn(o):(Dr(o),e.selection.setCursorLocation(o.dom,0))}))})(e,r,i.filter(bi));const s=r?t[0]:t[t.length-1];return Hf(e,s,n,r),bi(s)?F.none():F.some(r?t.slice(1):t.slice(0,-1))})).getOr(t);zf(r),Zf(e)})),Uf=(e,t,o,n)=>F.some((()=>{const r=e.selection.getRng(),i=t[0],s=o[o.length-1];Hf(e,i,r,!0),Hf(e,s,r,!1);const a=bi(i)?t:t.slice(1),l=bi(s)?o:o.slice(0,-1);zf(a.concat(l)),n.deleteContents(),Zf(e)})),$f=(e,t,o,n=!0)=>F.some((()=>{Ef(e,t,o,n)})),Wf=(e,t)=>F.some((()=>hf(e,!1,t))),qf=(e,t)=>Q(kg(t,e),Ar),Gf=(e,t)=>Q(kg(t,e),Xt("caption")),Yf=(e,t)=>F.some((()=>{Dr(t),e.selection.setCursorLocation(t.dom,0)})),Kf=(e,t)=>e?yg(t):wg(t),Xf=(e,t,o)=>{const n=wo(e.getBody());return Gf(n,o).fold((()=>((e,t,o,n)=>{const r=Pa.fromRangeStart(e.selection.getRng());return qf(o,n).bind((n=>bi(n)?Yf(e,n):((e,t,o,n,r)=>gu(o,e.getBody(),r).bind((e=>qf(t,wo(e.getNode())).bind((e=>So(e,n)?F.none():F.some(S))))))(e,o,t,n,r)))})(e,t,n,o).orThunk((()=>Ft(((e,t)=>{const o=Pa.fromRangeStart(e.selection.getRng());return Kf(t,o)||pu(t,e.getBody(),o).exists((e=>Kf(t,e)))})(e,t),S)))),(o=>((e,t,o,n)=>{const r=Pa.fromRangeStart(e.selection.getRng());return bi(n)?Yf(e,n):((e,t,o,n,r)=>gu(o,e.getBody(),r).fold((()=>F.some(S)),(i=>((e,t,o,n)=>wu(e.dom).bind((r=>_u(e.dom).map((e=>t?o.isEqual(r)&&n.isEqual(e):o.isEqual(e)&&n.isEqual(r))))).getOr(!0))(n,o,r,i)?((e,t)=>Yf(e,t))(e,n):((e,t,o)=>Gf(e,wo(o.getNode())).fold((()=>F.some(S)),(e=>Ft(!So(e,t),S))))(t,n,i))))(e,o,t,n,r)})(e,t,n,o)))},Jf=(e,t)=>{const o=wo(e.selection.getStart(!0)),n=Ku(e);return e.selection.isCollapsed()&&0===n.length?Xf(e,t,o):((e,t,o)=>{const n=wo(e.getBody()),r=e.selection.getRng();return 0!==o.length?jf(e,o,F.none()):((e,t,o,n)=>Gf(t,n).fold((()=>((e,t,o)=>Lf(t,o).bind((t=>t.fold(B($f,e),B(Wf,e),B(jf,e),B(Uf,e)))))(e,t,o)),(t=>((e,t)=>Yf(e,t))(e,t))))(e,n,r,t)})(e,o,n)},Qf=(e,t)=>{let o=t;for(;o&&o!==e;){if(ar(o)||lr(o))return o;o=o.parentNode}return null},ev=["data-ephox-","data-mce-","data-alloy-","data-snooker-","_"],tv=Vt.each,ov=e=>{const t=e.dom,o=new Set(e.serializer.getTempAttrs()),n=e=>U(ev,(t=>je(e,t)))||o.has(e);return{compare:(e,o)=>{if(e.nodeName!==o.nodeName||e.nodeType!==o.nodeType)return!1;const r=e=>{const o={};return tv(t.getAttribs(e),(r=>{const i=r.nodeName.toLowerCase();"style"===i||n(i)||(o[i]=t.getAttrib(e,i))})),o},i=(e,t)=>{for(const o in e)if(ke(e,o)){const n=t[o];if(y(n))return!1;if(e[o]!==n)return!1;delete t[o]}for(const e in t)if(ke(t,e))return!1;return!0};if(Un(e)&&Un(o)){if(!i(r(e),r(o)))return!1;if(!i(t.parseStyle(t.getAttrib(e,"style")),t.parseStyle(t.getAttrib(o,"style"))))return!1}return!Pu(e)&&!Pu(o)},isAttributeInternal:n}},nv=(e,t,o,n)=>{const r=o.name;for(let t=0,i=e.length;t{const o=(e,o)=>{ge(e,(e=>{const n=ue(e.nodes);W(e.filter.callbacks,(r=>{for(let t=n.length-1;t>=0;t--){const r=n[t];(o?void 0!==r.attr(e.filter.name):r.name===e.filter.name)&&!w(r.parent)||n.splice(t,1)}n.length>0&&r(n,e.filter.name,t)}))}))};o(e.nodes,!1),o(e.attributes,!0)},iv=(e,t,o,n={})=>{const r=((e,t,o)=>{const n={nodes:{},attributes:{}};return o.firstChild&&((o,r)=>{let i=o;for(;i=i.walk();)nv(e,t,i,n)})(o),n})(e,t,o);rv(r,n)},sv=(e,t,o,n)=>{if((e.pad_empty_with_br||t.insert)&&o(n)){const e=new Fp("br",1);t.insert&&e.attr("data-mce-bogus","1"),n.empty().append(e)}else n.empty().append(new Fp("#text",3)).value=fr},av=(e,t)=>{const o=null==e?void 0:e.firstChild;return _(o)&&o===e.lastChild&&o.name===t},lv=(e,t,o,n)=>n.isEmpty(t,o,(t=>((e,t)=>{const o=e.getElementRule(t.name);return!0===(null==o?void 0:o.paddEmpty)})(e,t))),cv=e=>{let t;for(let o=e;o;o=o.parent){const e=o.attr("contenteditable");if("false"===e)break;"true"===e&&(t=o)}return F.from(t)},dv=(e,t,o=e.parent)=>{if(t.getSpecialElements()[e.name])e.empty().remove();else{const n=e.children();for(const e of n)o&&!t.isValidChild(o.name,e.name)&&dv(e,t,o);e.unwrap()}},uv=(e,t,o,n=S)=>{const r=t.getTextBlockElements(),i=t.getNonEmptyElements(),s=t.getWhitespaceElements(),a=Vt.makeMap("tr,td,th,tbody,thead,tfoot,table,summary"),l=new Set,c=e=>e!==o&&!a[e.name];for(let o=0;o1)if(t.isValidChild(d.name,a.name)){m.reverse(),u=m[0].clone(),n(u);let e=u;for(let o=0;o0?(h=m[o].clone(),n(h),e.append(h)):h=e;for(let e=m[o].firstChild;e&&e!==m[o+1];){const t=e.next;h.append(e),e=t}e=h}lv(t,i,s,u)?d.insert(a,m[0],!0):(d.insert(u,m[0],!0),d.insert(a,u)),d=m[0],(lv(t,i,s,d)||av(d,"br"))&&d.empty().remove()}else dv(a,t);else if(a.parent){if("li"===a.name){let e=a.prev;if(e&&("ul"===e.name||"ol"===e.name)){e.append(a);continue}if(e=a.next,e&&("ul"===e.name||"ol"===e.name)&&e.firstChild){e.insert(a,e.firstChild,!0);continue}const t=new Fp("ul",1);n(t),a.wrap(t);continue}if(t.isValidChild(a.parent.name,"div")&&t.isValidChild("div",a.name)){const e=new Fp("div",1);n(e),a.wrap(e)}else dv(a,t)}}},hv=(e,t,o=t.parent)=>!(!o||!e.children[t.name]||e.isValidChild(o.name,t.name))||!(!o||"a"!==t.name||!((e,t)=>{let o=e;for(;o;){if("a"===o.name)return!0;o=o.parent}return!1})(o)),mv=e=>e.collapsed?e:(e=>{const t=Pa.fromRangeStart(e),o=Pa.fromRangeEnd(e),n=e.commonAncestorContainer;return pu(!1,n,o).map((r=>!zd(t,o,n)&&zd(t,r,n)?((e,t,o,n)=>{const r=document.createRange();return r.setStart(e,t),r.setEnd(o,n),r})(t.container(),t.offset(),r.container(),r.offset()):e)).getOr(e)})(e),pv=(e,t)=>{let o=t.firstChild,n=t.lastChild;return o&&"meta"===o.name&&(o=o.next),n&&"mce_marker"===n.attr("id")&&(n=n.prev),((e,t)=>{const o=e.getNonEmptyElements();return _(t)&&(t.isEmpty(o)||((e,t)=>e.getBlockElements()[t.name]&&(e=>_(e.firstChild)&&e.firstChild===e.lastChild)(t)&&(e=>"br"===e.name||e.value===fr)(t.firstChild))(e,t))})(e,n)&&(n=null==n?void 0:n.prev),!(!o||o!==n||"ul"!==o.name&&"ol"!==o.name)},gv=e=>{return e.length>0&&(!(o=e[e.length-1]).firstChild||_(null==(t=o)?void 0:t.firstChild)&&t.firstChild===t.lastChild&&(e=>e.data===fr||ir(e))(t.firstChild))?e.slice(0,-1):e;var t,o},fv=(e,t)=>{const o=e.getParent(t,e.isBlock);return o&&"LI"===o.nodeName?o:null},vv=(e,t)=>{const o=Pa.after(e),n=du(t).prev(o);return n?n.toRange():null},bv=(e,t,o,n)=>{const r=((e,t,o)=>{const n=t.serialize(o);return(e=>{var t,o;const n=e.firstChild,r=e.lastChild;return n&&"META"===n.nodeName&&(null===(t=n.parentNode)||void 0===t||t.removeChild(n)),r&&"mce_marker"===r.id&&(null===(o=r.parentNode)||void 0===o||o.removeChild(r)),e})(e.createFragment(n))})(t,e,n),i=fv(t,o.startContainer),s=gv((a=r.firstChild,Y(null!==(l=null==a?void 0:a.childNodes)&&void 0!==l?l:[],(e=>"LI"===e.nodeName))));var a,l;const c=t.getRoot(),d=e=>{const n=Pa.fromRangeStart(o),r=du(t.getRoot()),s=1===e?r.prev(n):r.next(n),a=null==s?void 0:s.getNode();return!a||fv(t,a)!==i};return i?d(1)?((e,t,o)=>{const n=e.parentNode;return n&&Vt.each(t,(t=>{n.insertBefore(t,e)})),((e,t)=>{const o=Pa.before(e),n=du(t).next(o);return n?n.toRange():null})(e,o)})(i,s,c):d(2)?((e,t,o,n)=>(n.insertAfter(t.reverse(),e),vv(t[0],o)))(i,s,c,t):((e,t,o,n)=>{const r=((e,t)=>{const o=t.cloneRange(),n=t.cloneRange();return o.setStartBefore(e),n.setEndAfter(e),[o.cloneContents(),n.cloneContents()]})(e,n),i=e.parentNode;return i&&(i.insertBefore(r[0],e),Vt.each(t,(t=>{i.insertBefore(t,e)})),i.insertBefore(r[1],e),i.removeChild(e)),vv(t[t.length-1],o)})(i,s,c,o):null},yv=["pre"],wv=cr,_v=(e,t,o)=>{var n,r;const i=e.selection,s=e.dom,a=e.parser,l=o.merge,c=ng({validate:!0},e.schema),d=' ';o.preserve_zwsp||(t=Lr(t)),-1===t.indexOf("{$caret}")&&(t+="{$caret}"),t=t.replace(/\{\$caret\}/,d);let u=i.getRng();const h=u.startContainer,m=e.getBody();h===m&&i.isCollapsed()&&s.isBlock(m.firstChild)&&((e,t)=>_(t)&&!e.schema.getVoidElements()[t.nodeName])(e,m.firstChild)&&s.isEmpty(m.firstChild)&&(u=s.createRng(),u.setStart(m.firstChild,0),u.setEnd(m.firstChild,0),i.setRng(u)),i.isCollapsed()||(e=>{const t=e.dom,o=mv(e.selection.getRng());e.selection.setRng(o);const n=t.getParent(o.startContainer,wv);((e,t,o)=>!!_(o)&&o===e.getParent(t.endContainer,wv)&&eh(wo(o),t))(t,o,n)?$f(e,o,wo(n)):o.startContainer===o.endContainer&&o.endOffset-o.startOffset==1&&Qn(o.startContainer.childNodes[o.startOffset])?o.deleteContents():e.getDoc().execCommand("Delete",!1)})(e);const p=i.getNode(),g={context:p.nodeName.toLowerCase(),data:o.data,insert:!0},f=a.parse(t,g);if(!0===o.paste&&pv(e.schema,f)&&((e,t)=>!!fv(e,t))(s,p))return u=bv(c,s,i.getRng(),f),u&&i.setRng(u),t;!0===o.paste&&((e,t,o,n)=>{var r;const i=t.firstChild,s=t.lastChild,a=i===("bookmark"===s.attr("data-mce-type")?s.prev:s),l=j(yv,i.name);if(a&&l){const t="false"!==i.attr("contenteditable"),s=(null===(r=e.getParent(o,e.isBlock))||void 0===r?void 0:r.nodeName.toLowerCase())===i.name,a=F.from(Qf(n,o)).forall(ar);return t&&s&&a}return!1})(s,f,p,e.getBody())&&(null===(n=f.firstChild)||void 0===n||n.unwrap()),(e=>{let t=e;for(;t=t.walk();)1===t.type&&t.attr("data-mce-fragment","1")})(f);let v=f.lastChild;if(v&&"mce_marker"===v.attr("id")){const t=v;for(v=v.prev;v;v=v.walk(!0))if(3===v.type||!s.isBlock(v.name)){v.parent&&e.schema.isValidChild(v.parent.name,"span")&&v.parent.insert(t,v,"br"===v.name);break}}if(e._selectionOverrides.showBlockCaretContainer(p),g.invalid){e.selection.setContent(d);let o,n=i.getNode();const l=e.getBody();for(nr(n)?n=o=l:o=n;o&&o!==l;)n=o,o=o.parentNode;t=n===l?l.innerHTML:s.getOuterHTML(n);const u=a.parse(t),h=(e=>{for(let t=e;t;t=t.walk())if("mce_marker"===t.attr("id"))return F.some(t);return F.none()})(u),m=h.bind(cv).getOr(u);h.each((e=>e.replace(f)));const p=f.children(),g=null!==(r=f.parent)&&void 0!==r?r:u;f.unwrap();const v=Y(p,(t=>hv(e.schema,t,g)));uv(v,e.schema,m),iv(a.getNodeFilters(),a.getAttributeFilters(),u),t=c.serialize(u),n===l?s.setHTML(l,t):s.setOuterHTML(n,t)}else t=c.serialize(f),((e,t,o)=>{var n;if("all"===o.getAttribute("data-mce-bogus"))null===(n=o.parentNode)||void 0===n||n.insertBefore(e.dom.createFragment(t),o);else{const n=o.firstChild,r=o.lastChild;!n||n===r&&"BR"===n.nodeName?e.dom.setHTML(o,t):e.selection.setContent(t,{no_events:!0})}})(e,t,p);var b;return((e,t)=>{const o=e.schema.getTextInlineElements(),n=e.dom;if(t){const t=e.getBody(),r=ov(e);Vt.each(n.select("*[data-mce-fragment]"),(e=>{if(_(o[e.nodeName.toLowerCase()])&&((e,t)=>ne(sg(e,t),(e=>!(e=>rg.has(e))(e))))(n,e))for(let o=e.parentElement;_(o)&&o!==t&&!ag(n,e,o);o=o.parentElement)if(r.compare(o,e)){n.remove(e,!0);break}}))}})(e,l),((e,t)=>{var o,n,r;let i;const s=e.dom,a=e.selection;if(!t)return;a.scrollIntoView(t);const l=Qf(e.getBody(),t);if(l&&"false"===s.getContentEditable(l))return s.remove(t),void a.select(l);let c=s.createRng();const d=t.previousSibling;if(Qn(d)){c.setStart(d,null!==(n=null===(o=d.nodeValue)||void 0===o?void 0:o.length)&&void 0!==n?n:0);const e=t.nextSibling;Qn(e)&&(d.appendData(e.data),null===(r=e.parentNode)||void 0===r||r.removeChild(e))}else c.setStartBefore(t),c.setEndBefore(t);const u=s.getParent(t,s.isBlock);if(s.remove(t),u&&s.isEmpty(u)){const t=wv(u);_n(wo(u)),c.setStart(u,0),c.setEnd(u,0),t||(e=>!!e.getAttribute("data-mce-fragment"))(u)||!(i=(t=>{let o=Pa.fromRangeStart(t);return o=du(e.getBody()).next(o),null==o?void 0:o.toRange()})(c))?s.add(u,s.create("br",t?{}:{"data-mce-bogus":"1"})):(c=i,s.remove(u))}a.setRng(c)})(e,s.get("mce_marker")),b=e.getBody(),Vt.each(b.getElementsByTagName("*"),(e=>{e.removeAttribute("data-mce-fragment")})),((e,t)=>{F.from(e.getParent(t,"td,th")).map(wo).each(Pr)})(s,i.getStart()),((e,t,o)=>{const n=No(wo(o),(e=>So(e,wo(t))));le(n,n.length-2).filter(qt).fold((()=>Si(e,t)),(t=>Si(e,t.dom)))})(e.schema,e.getBody(),i.getStart()),t},xv=e=>e instanceof Fp,Cv=(e,t,o)=>{e.dom.setHTML(e.getBody(),t),!0!==o&&(e=>{xp(e)&&wu(e.getBody()).each((t=>{const o=t.getNode(),n=Kn(o)?wu(o).getOr(t):t;e.selection.setRng(n.toRange())}))})(e)},kv=(e,t)=>((e,t)=>{const o=e.dom;return o.parentNode?((e,t)=>Q(e.dom.childNodes,(e=>t(wo(e)))).map(wo))(wo(o.parentNode),(o=>!So(e,o)&&t(o))):F.none()})(e,t).isSome(),Sv=e=>x(e)?e:P,Tv=(e,t,o)=>{const n=t(e),r=Sv(o);return n.orThunk((()=>r(e)?F.none():((e,t,o)=>{let n=e.dom;const r=Sv(o);for(;n.parentNode;){n=n.parentNode;const e=wo(n),o=t(e);if(o.isSome())return o;if(r(e))break}return F.none()})(e,t,r)))},Ev=fh,Ov=(e,t,o)=>{const n=e.formatter.get(o);if(n)for(let o=0;o{const i=e.dom.getRoot();if(t===i)return!1;const s=e.dom.getParent(t,(t=>!!Ov(e,t,o)||t.parentNode===i||!!Nv(e,t,o,n,!0)));return!!Nv(e,s,o,n,r)},Av=(e,t,o)=>!(!kh(o)||!Ev(t,o.inline))||!(!xh(o)||!Ev(t,o.block))||!!Ch(o)&&Un(t)&&e.is(t,o.selector),Bv=(e,t,o,n,r,i)=>{const s=o[n],a="attributes"===n;if(x(o.onmatch))return o.onmatch(t,o,n);if(s)if(Ee(s)){for(let o=0;o{const i=e.formatter.get(o),s=e.dom;if(i&&Un(t))for(let o=0;o{if(n)return Mv(e,n,t,o,r);if(n=e.selection.getNode(),Mv(e,n,t,o,r))return!0;const i=e.selection.getStart();return!(i===n||!Mv(e,i,t,o,r))},Vv=Ir,Dv=e=>(e=>{const t=[];let o=e;for(;o;){if(Qn(o)&&o.data!==Vv||o.childNodes.length>1)return[];Un(o)&&t.push(o),o=o.firstChild}return t})(e).length>0,Pv=e=>{if(e){const t=new Hn(e,e);for(let e=t.current();e;e=t.next())if(Qn(e))return e}return null},Iv=e=>{const t=bo("span");return eo(t,{id:xu,"data-mce-bogus":"1","data-mce-type":"format-caret"}),e&&bn(t,yo(Vv)),t},Fv=(e,t,o=!0)=>{const n=e.dom,r=e.selection;if(Dv(t))hf(e,!1,wo(t),o);else{const e=r.getRng(),o=n.getParent(t,n.isBlock),i=e.startContainer,s=e.startOffset,a=e.endContainer,l=e.endOffset,c=(e=>{const t=Pv(e);return t&&t.data.charAt(0)===Vv&&t.deleteData(0,1),t})(t);n.remove(t,!0),i===c&&s>0&&e.setStart(c,s-1),a===c&&l>0&&e.setEnd(c,l-1),o&&n.isEmpty(o)&&Dr(wo(o)),r.setRng(e)}},Lv=(e,t,o=!0)=>{const n=e.dom,r=e.selection;if(t)Fv(e,t,o);else if(!(t=ku(e.getBody(),r.getStart())))for(;t=n.get(xu);)Fv(e,t,o)},zv=(e,t)=>(e.appendChild(t),t),Hv=(e,t)=>{var o;const n=K(e,((e,t)=>zv(e,t.cloneNode(!1))),t),r=null!==(o=n.ownerDocument)&&void 0!==o?o:document;return zv(n,r.createTextNode(Vv))},Zv=(e,t,o,n)=>{const r=e.dom,a=e.selection;let l=!1;const c=e.formatter.get(t);if(!c)return;const d=a.getRng(),u=d.startContainer,h=d.startOffset;let m=u;Qn(u)&&(h!==u.data.length&&(l=!0),m=m.parentNode);const p=[];let g;for(;m;){if(Nv(e,m,t,o,n)){g=m;break}m.nextSibling&&(l=!0),p.push(m),m=m.parentNode}if(g)if(l){const i=a.getBookmark();d.collapse(!0);let s=zh(r,d,c,!0);s=Nm(s),e.formatter.remove(t,o,s,n),a.moveToBookmark(i)}else{const l=ku(e.getBody(),g),c=Iv(!1).dom;((e,t,o)=>{var n,r;const i=e.dom,s=i.getParent(o,B(uh,e.schema));s&&i.isEmpty(s)?null===(n=o.parentNode)||void 0===n||n.replaceChild(t,o):((e=>{const t=Ln(e,"br"),o=Y((e=>{const t=[];let o=e.dom;for(;o;)t.push(wo(o)),o=o.lastChild;return t})(e).slice(-1),Sr);t.length===o.length&&W(o,xn)})(wo(o)),i.isEmpty(o)?null===(r=o.parentNode)||void 0===r||r.replaceChild(t,o):i.insertAfter(t,o))})(e,c,null!=l?l:g);const d=((e,t,o,n,r,a)=>{const l=e.formatter,c=e.dom,d=Y(me(l.get()),(e=>e!==n&&!Ze(e,"removeformat"))),u=((e,t,o)=>X(o,((o,n)=>{const r=((e,t)=>_h(e,t,(e=>{const t=e=>x(e)||e.length>1&&"%"===e.charAt(0);return U(["styles","attributes"],(o=>Ce(e,o).exists((e=>{const o=f(e)?e:xe(e);return U(o,t)}))))})))(e,n);return e.formatter.matchNode(t,n,{},r)?o.concat([n]):o}),[]))(e,o,d);if(Y(u,(t=>!((e,t,o)=>{const n=["inline","block","selector","attributes","styles","classes"],r=e=>we(e,((e,t)=>U(n,(e=>e===t))));return _h(e,t,(t=>{const n=r(t);return _h(e,o,(e=>{const t=r(e);return((e,t,o=s)=>i(o).eq(e,t))(n,t)}))}))})(e,t,n))).length>0){const e=o.cloneNode(!1);return c.add(t,e),l.remove(n,r,e,a),c.remove(e),F.some(e)}return F.none()})(e,c,g,t,o,n),u=Hv(p.concat(d.toArray()),c);l&&Fv(e,l,!1),a.setCursorLocation(u,1),r.isEmpty(g)&&r.remove(g)}},jv=e=>{const t=Iv(!1),o=Hv(e,t.dom);return{caretContainer:t,caretPosition:Pa(o,0)}},Uv=(e,t)=>{const{caretContainer:o,caretPosition:n}=jv(t);return gn(wo(e),o),xn(wo(e)),n},$v=(e,t)=>{const o=e.schema.getTextInlineElements();return ke(o,jt(t))&&!Cu(t.dom)&&!Yn(t.dom)},Wv=e=>Cu(e.dom)&&Dv(e.dom),qv={},Gv=Wn(["pre"]);((e,t)=>{qv[e]||(qv[e]=[]),qv[e].push((e=>{if(!e.selection.getRng().collapsed){const t=e.selection.getSelectedBlocks(),o=Y(Y(t,Gv),(e=>t=>{const o=t.previousSibling;return Gv(o)&&j(e,o)})(t));W(o,(e=>{((e,t)=>{const o=wo(t),n=Oo(o).dom;xn(o),wn(wo(e),[bo("br",n),bo("br",n),...Io(o)])})(e.previousSibling,e)}))}}))})("pre");const Yv=["fontWeight","fontStyle","color","fontSize","fontFamily"],Kv=(e,t)=>{const o=e.get(t);return f(o)?Q(o,(e=>kh(e)&&"span"===e.inline&&(e=>p(e.styles)&&U(me(e.styles),(e=>j(Yv,e))))(e))):F.none()},Xv=(e,t)=>yu(t,Pa.fromRangeStart(e)).isNone(),Jv=(e,t)=>!1===bu(t,Pa.fromRangeEnd(e)).exists((e=>!ir(e.getNode())||bu(t,e).isSome())),Qv=e=>t=>hr(t)&&e.isEditable(t),eb=e=>Y(e.getSelectedBlocks(),Qv(e.dom)),tb=Vt.each,ob=e=>Un(e)&&!Pu(e)&&!Cu(e)&&!Yn(e),nb=(e,t)=>{for(let o=e;o;o=o[t]){if(Qn(o)&&Ye(o.data))return e;if(Un(o)&&!Pu(o))return o}return e},rb=(e,t,o)=>{const n=ov(e),r=Un(t)&&ah(t),i=Un(o)&&ah(o);if(r&&i){const r=nb(t,"previousSibling"),i=nb(o,"nextSibling");if(n.compare(r,i)){for(let e=r.nextSibling;e&&e!==i;){const t=e;e=e.nextSibling,r.appendChild(t)}return e.dom.remove(i),Vt.each(Vt.grep(i.childNodes),(e=>{r.appendChild(e)})),r}}return o},ib=(e,t,o,n)=>{var r;if(n&&!1!==t.merge_siblings){const t=null!==(r=rb(e,dh(n),n))&&void 0!==r?r:n;rb(e,t,dh(t,!0))}},sb=(e,t,o)=>{tb(e.childNodes,(e=>{ob(e)&&(t(e)&&o(e),e.hasChildNodes()&&sb(e,t,o))}))},ab=(e,t)=>o=>!(!o||!bh(e,o,t)),lb=(e,t,o)=>n=>{e.setStyle(n,t,o),""===n.getAttribute("style")&&n.removeAttribute("style"),((e,t)=>{"SPAN"===t.nodeName&&0===e.getAttribs(t).length&&e.remove(t,!0)})(e,n)},cb=al([{keep:[]},{rename:["name"]},{removed:[]}]),db=/^(src|href|style)$/,ub=Vt.each,hb=fh,mb=(e,t,o)=>e.isChildOf(t,o)&&t!==o&&!e.isBlock(o),pb=(e,t,o)=>{let n=t[o?"startContainer":"endContainer"],r=t[o?"startOffset":"endOffset"];if(Un(n)){const e=n.childNodes.length-1;!o&&r&&r--,n=n.childNodes[r>e?e:r]}return Qn(n)&&o&&r>=n.data.length&&(n=new Hn(n,e.getBody()).next()||n),Qn(n)&&!o&&0===r&&(n=new Hn(n,e.getBody()).prev()||n),n},gb=(e,t)=>{const o=t?"firstChild":"lastChild",n=e[o];return(e=>/^(TR|TH|TD)$/.test(e.nodeName))(e)&&n?"TR"===e.nodeName&&n[o]||n:e},fb=(e,t,o,n)=>{var r;const i=e.create(o,n);return null===(r=t.parentNode)||void 0===r||r.insertBefore(i,t),i.appendChild(t),i},vb=(e,t,o,n,r)=>{const i=wo(t),s=wo(e.create(n,r)),a=o?Po(i):Do(i);return wn(s,a),o?(gn(i,s),vn(s,i)):(fn(i,s),bn(s,i)),s.dom},bb=(e,t,o)=>{const n=t.parentNode;let r;const i=e.dom,s=Ol(e);xh(o)&&n===i.getRoot()&&(o.list_block&&hb(t,o.list_block)||W(ue(t.childNodes),(t=>{hh(e,s,t.nodeName.toLowerCase())?r?r.appendChild(t):(r=fb(i,t,s),i.setAttribs(r,Ml(e))):r=null}))),(e=>Ch(e)&&kh(e)&&Dt(Ce(e,"mixed"),!0))(o)&&!hb(o.inline,t)||i.remove(t,!0)},yb=(e,t,o)=>C(e)?{name:t,value:null}:{name:e,value:gh(t,o)},wb=(e,t)=>{""===e.getAttrib(t,"style")&&(t.removeAttribute("style"),t.removeAttribute("data-mce-style"))},_b=(e,t,o,n,r)=>{let i=!1;ub(o.styles,((s,a)=>{const{name:l,value:c}=yb(a,s,n),d=vh(c,l);(o.remove_similar||v(c)||!Un(r)||hb(bh(e,r,l),d))&&e.setStyle(t,l,""),i=!0})),i&&wb(e,t)},xb=(e,t,o,n,r)=>{const i=e.dom,s=ov(e),a=e.schema;if(kh(t)&&Oi(a,t.inline)&&Ai(a,n)&&n.parentElement===e.getBody())return bb(e,n,t),cb.removed();if(!t.ceFalseOverride&&n&&"false"===i.getContentEditableParent(n))return cb.keep();if(n&&!Av(i,n,t)&&!((e,t)=>t.links&&"A"===e.nodeName)(n,t))return cb.keep();const l=n,c=t.preserve_attributes;if(kh(t)&&"all"===t.remove&&f(c)){const e=Y(i.getAttribs(l),(e=>j(c,e.name.toLowerCase())));if(i.removeAllAttribs(l),W(e,(e=>i.setAttrib(l,e.name,e.value))),e.length>0)return cb.rename("span")}if("all"!==t.remove){_b(i,l,t,o,r),ub(t.attributes,((e,n)=>{const{name:s,value:a}=yb(n,e,o);if(t.remove_similar||v(a)||!Un(r)||hb(i.getAttrib(r,s),a)){if("class"===s){const e=i.getAttrib(l,s);if(e){let t="";if(W(e.split(/\s+/),(e=>{/mce\-\w+/.test(e)&&(t+=(t?" ":"")+e)})),t)return void i.setAttrib(l,s,t)}}if(db.test(s)&&l.removeAttribute("data-mce-"+s),"style"===s&&Wn(["li"])(l)&&"none"===i.getStyle(l,"list-style-type"))return l.removeAttribute(s),void i.setStyle(l,"list-style-type","none");"class"===s&&l.removeAttribute("className"),l.removeAttribute(s)}})),ub(t.classes,(e=>{e=gh(e,o),Un(r)&&!i.hasClass(r,e)||i.removeClass(l,e)}));const e=i.getAttribs(l);for(let t=0;txb(e,t,o,n,n).fold(O(n),(t=>(e.dom.createFragment().appendChild(n),e.dom.rename(n,t))),O(null)),kb=(e,t,o,n,r)=>{(n||e.selection.isEditable())&&((e,t,o,n,r)=>{const i=e.formatter.get(t),s=i[0],a=e.dom,l=e.selection,c=n=>{const a=((e,t,o,n,r)=>{let i;return t.parentNode&&W(wh(e.dom,t.parentNode).reverse(),(t=>{if(!i&&Un(t)&&"_start"!==t.id&&"_end"!==t.id){const s=Nv(e,t,o,n,r);s&&!1!==s.split&&(i=t)}})),i})(e,n,t,o,r);return((e,t,o,n,r,i,s,a)=>{var l,c;let d,u;const h=e.dom;if(o){const i=o.parentNode;for(let o=n.parentNode;o&&o!==i;o=o.parentNode){let n=h.clone(o,!1);for(let o=0;oU(i,(n=>Sb(e,n,o,t,t))),u=t=>{const o=ue(t.childNodes),n=d(t)||U(i,(e=>Av(a,t,e))),r=t.parentNode;if(!n&&_(r)&&Sh(s)&&d(r),s.deep&&o.length)for(let e=0;e{Un(t)&&e.dom.getStyle(t,"text-decoration")===o&&t.parentNode&&yh(a,t.parentNode)===o&&Sb(e,{deep:!1,exact:!0,inline:"span",styles:{textDecoration:o}},void 0,t)}))},h=e=>{const t=a.get(e?"_start":"_end");if(t){let o=t[e?"firstChild":"lastChild"];return(e=>Pu(e)&&Un(e)&&("_start"===e.id||"_end"===e.id))(o)&&(o=o[e?"firstChild":"lastChild"]),Qn(o)&&0===o.data.length&&(o=e?t.previousSibling||t.nextSibling:t.nextSibling||t.previousSibling),a.remove(t,!0),o}return null},m=t=>{let o,n,r=zh(a,t,i,t.collapsed);if(s.split){if(r=Nm(r),o=pb(e,r,!0),n=pb(e,r),o!==n){if(o=gb(o,!0),n=gb(n,!1),mb(a,o,n)){const e=F.from(o.firstChild).getOr(o);return c(vb(a,e,!0,"span",{id:"_start","data-mce-type":"bookmark"})),void h(!0)}if(mb(a,n,o)){const e=F.from(n.lastChild).getOr(n);return c(vb(a,e,!1,"span",{id:"_end","data-mce-type":"bookmark"})),void h(!1)}o=fb(a,o,"span",{id:"_start","data-mce-type":"bookmark"}),n=fb(a,n,"span",{id:"_end","data-mce-type":"bookmark"});const e=a.createRng();e.setStartAfter(o),e.setEndBefore(n),Hh(a,e,(e=>{W(e,(e=>{Pu(e)||Pu(e.parentNode)||c(e)}))})),c(o),c(n),o=h(!0),n=h()}else o=n=c(o);r.startContainer=o.parentNode?o.parentNode:o,r.startOffset=a.nodeIndex(o),r.endContainer=n.parentNode?n.parentNode:n,r.endOffset=a.nodeIndex(n)+1}Hh(a,r,(e=>{W(e,u)}))};if(n){if(ih(n)){const e=a.createRng();e.setStartBefore(n),e.setEndAfter(n),m(e)}else m(n);Xh(e,t,n,o)}else l.isCollapsed()&&kh(s)&&!Ku(e).length?Zv(e,t,o,r):(lh(e,(()=>nh(e,m)),(n=>kh(s)&&Rv(e,t,o,n))),e.nodeChanged()),((e,t,o)=>{"removeformat"===t?W(eb(e.selection),(t=>{W(Yv,(o=>e.dom.setStyle(t,o,""))),wb(e.dom,t)})):Kv(e.formatter,t).each((t=>{W(eb(e.selection),(n=>_b(e.dom,n,t,o,null)))}))})(e,t,o),Xh(e,t,n,o)})(e,t,o,n,r)},Sb=(e,t,o,n,r)=>xb(e,t,o,n,r).fold(P,(t=>(e.dom.rename(n,t),!0)),I),Tb=Vt.each,Eb=Vt.each,Ob=(e,t,o,n)=>{if(Eb(o.styles,((o,r)=>{e.setStyle(t,r,gh(o,n))})),o.styles){const o=e.getAttrib(t,"style");o&&e.setAttrib(t,"data-mce-style",o)}},Mb=(e,t,o,n)=>{const r=e.formatter.get(t),i=r[0],s=!n&&e.selection.isCollapsed(),a=e.dom,l=e.selection,c=(e,t=i)=>{x(t.onformat)&&t.onformat(e,t,o,n),Ob(a,e,t,o),Eb(t.attributes,((t,n)=>{a.setAttrib(e,n,gh(t,o))})),Eb(t.classes,(t=>{const n=gh(t,o);a.hasClass(e,n)||a.addClass(e,n)}))},d=(e,t)=>{let o=!1;return Eb(e,(e=>!(!Ch(e)||("false"!==a.getContentEditable(t)||e.ceFalseOverride)&&(!_(e.collapsed)||e.collapsed===s)&&a.is(t,e.selector)&&!Cu(t)&&(c(t,e),o=!0,1)))),o},u=e=>{if(m(e)){const t=a.create(e);return c(t),t}return null},h=(n,s,a)=>{const l=[];let h=!0;const m=i.inline||i.block,p=u(m);Hh(n,s,(s=>{let u;const g=s=>{let f=!1,v=h,b=!1;const y=s.parentNode,w=y.nodeName.toLowerCase(),x=n.getContentEditable(s);_(x)&&(v=h,h="true"===x,f=!0,b=ph(e,s));const C=h&&!f;if(ir(s)&&!((e,t,o,n)=>{if(mc(e)&&kh(t)&&o.parentNode){const t=cs(e.schema),r=kv(wo(o),(e=>Cu(e.dom)));return Se(t,n)&&bi(wo(o.parentNode),!1)&&!r}return!1})(e,i,s,w))return u=null,void(xh(i)&&n.remove(s));if((n=>(e=>xh(e)&&!0===e.wrapper)(i)&&Nv(e,n,t,o))(s))u=null;else{if(((t,o,n)=>{const r=(e=>xh(e)&&!0!==e.wrapper)(i)&&uh(e.schema,t)&&hh(e,o,m);return n&&r})(s,w,C)){const e=n.rename(s,m);return c(e),l.push(e),void(u=null)}if(Ch(i)){let e=d(r,s);if(!e&&_(y)&&Sh(i)&&(e=d(r,y)),!kh(i)||e)return void(u=null)}_(p)&&((t,o,r,s)=>{const l=t.nodeName.toLowerCase(),c=hh(e,m,l)&&hh(e,o,m),d=!a&&Qn(t)&&Fr(t.data),u=Cu(t),h=!kh(i)||!n.isBlock(t);return(r||s)&&c&&!d&&!u&&h})(s,w,C,b)?(u||(u=n.clone(p,!1),y.insertBefore(u,s),l.push(u)),b&&f&&(h=v),u.appendChild(s)):(u=null,W(ue(s.childNodes),g),f&&(h=v),u=null)}};W(s,g)})),!0===i.links&&W(l,(e=>{const t=e=>{"A"===e.nodeName&&c(e,i),W(ue(e.childNodes),t)};t(e)})),W(l,(s=>{const a=(e=>{let t=0;return W(e.childNodes,(e=>{(e=>_(e)&&Qn(e)&&0===e.length)(e)||Pu(e)||t++})),t})(s);!(l.length>1)&&n.isBlock(s)||0!==a?(kh(i)||xh(i)&&i.wrapper)&&(i.exact||1!==a||(s=(e=>{const t=Q(e.childNodes,sh).filter((e=>"false"!==n.getContentEditable(e)&&Av(n,e,i)));return t.map((t=>{const o=n.clone(t,!1);return c(o),n.replace(o,e,!0),n.remove(t,!0),o})).getOr(e)})(s)),((e,t,o,n)=>{Tb(t,(t=>{kh(t)&&Tb(e.dom.select(t.inline,n),(n=>{ob(n)&&Sb(e,t,o,n,t.exact?n:null)})),((e,t,o)=>{if(t.clear_child_styles){const n=t.links?"*:not(a)":"*";tb(e.select(n,o),(o=>{ob(o)&&ah(o)&&tb(t.styles,((t,n)=>{e.setStyle(o,n,"")}))}))}})(e.dom,t,n)}))})(e,r,o,s),((e,t,o,n,r)=>{const i=r.parentNode;Nv(e,i,o,n)&&Sb(e,t,n,r)||t.merge_with_parents&&i&&e.dom.getParent(i,(i=>!!Nv(e,i,o,n)&&(Sb(e,t,n,r),!0)))})(e,i,t,o,s),((e,t,o,n)=>{if(t.styles&&t.styles.backgroundColor){const r=ab(e,"fontSize");sb(n,(e=>r(e)&&ah(e)),lb(e,"backgroundColor",gh(t.styles.backgroundColor,o)))}})(n,i,o,s),((e,t,o,n)=>{const r=t=>{if(Un(t)&&Un(t.parentNode)&&ah(t)){const o=yh(e,t.parentNode);e.getStyle(t,"color")&&o?e.setStyle(t,"text-decoration",o):e.getStyle(t,"text-decoration")===o&&e.setStyle(t,"text-decoration",null)}};t.styles&&(t.styles.color||t.styles.textDecoration)&&(Vt.walk(n,r,"childNodes"),r(n))})(n,i,0,s),((e,t,o,n)=>{if(kh(t)&&("sub"===t.inline||"sup"===t.inline)){const o=ab(e,"fontSize");sb(n,(e=>o(e)&&ah(e)),lb(e,"fontSize",""));const r=Y(e.select("sup"===t.inline?"sub":"sup",n),ah);e.remove(r,!0)}})(n,i,0,s),ib(e,i,0,s)):n.remove(s,!0)}))},p=ih(n)?n:l.getNode();if("false"===a.getContentEditable(p)&&!ph(e,p))return d(r,n=p),void Kh(e,t,n,o);if(i){if(n)if(ih(n)){if(!d(r,n)){const e=a.createRng();e.setStartBefore(n),e.setEndAfter(n),h(a,zh(a,e,r),!0)}}else h(a,n,!0);else s&&kh(i)&&!Ku(e).length?((e,t,o)=>{let n;const r=e.selection,i=e.formatter.get(t);if(!i)return;const s=r.getRng();let a=s.startOffset;const l=s.startContainer.nodeValue;n=ku(e.getBody(),r.getStart());const c=/[^\s\u00a0\u00ad\u200b\ufeff]/;if(l&&a>0&&a{nh(e,((e,t)=>{const o=t?e:zh(a,e,r);h(a,o,!1)}))}),I),e.nodeChanged()),Kv(e.formatter,t).each((t=>{W((e=>Y((e=>{const t=e.getSelectedBlocks(),o=e.getRng();if(e.isCollapsed())return[];if(1===t.length)return Xv(o,t[0])&&Jv(o,t[0])?t:[];{const e=ce(t).filter((e=>Xv(o,e))).toArray(),n=de(t).filter((e=>Jv(o,e))).toArray(),r=t.slice(1,-1);return e.concat(r).concat(n)}})(e),Qv(e.dom)))(e.selection),(e=>Ob(a,e,t,o)))}));((e,t)=>{ke(qv,e)&&W(qv[e],(e=>{e(t)}))})(t,e)}Kh(e,t,n,o)},Ab=(e,t,o,n)=>{(n||e.selection.isEditable())&&Mb(e,t,o,n)},Bb=e=>ke(e,"vars"),Nb=e=>e.selection.getStart(),Rb=(e,t,o,n,r)=>J(t,(t=>{const i=e.formatter.matchNode(t,o,null!=r?r:{},n);return!y(i)}),(t=>!!Ov(e,t,o)||!n&&_(e.formatter.matchNode(t,o,r,!0)))),Vb=(e,t)=>{const o=null!=t?t:Nb(e);return Y(wh(e.dom,o),(e=>Un(e)&&!Yn(e)))},Db=(e,t,o)=>{const n=Vb(e,t);ge(o,((o,r)=>{const i=o=>{const i=Rb(e,n,r,o.similar,Bb(o)?o.vars:void 0),s=i.isSome();if(o.state.get()!==s){o.state.set(s);const e=i.getOr(t);Bb(o)?o.callback(s,{node:e,format:r,parents:n}):W(o.callbacks,(t=>t(s,{node:e,format:r,parents:n})))}};W([o.withSimilar,o.withoutSimilar],i),W(o.withVars,i)}))},Pb=Vt.explode,Ib=()=>{const e={};return{addFilter:(t,o)=>{W(Pb(t),(t=>{ke(e,t)||(e[t]={name:t,callbacks:[]}),e[t].callbacks.push(o)}))},getFilters:()=>xe(e),removeFilter:(t,o)=>{W(Pb(t),(t=>{if(ke(e,t))if(_(o)){const n=e[t],r=Y(n.callbacks,(e=>e!==o));r.length>0?n.callbacks=r:delete e[t]}else delete e[t]}))}}},Fb=(e,t,o)=>{var n;const r=hs();t.convert_fonts_to_spans&&((e,t,o)=>{e.addNodeFilter("font",(e=>{W(e,(e=>{const n=t.parse(e.attr("style")),r=e.attr("color"),i=e.attr("face"),s=e.attr("size");r&&(n.color=r),i&&(n["font-family"]=i),s&&Xe(s).each((e=>{n["font-size"]=o[e-1]})),e.name="span",e.attr("style",t.serialize(n)),((e,t)=>{W(["color","face","size"],(t=>{e.attr(t,null)}))})(e)}))}))})(e,r,Vt.explode(null!==(n=t.font_size_legacy_values)&&void 0!==n?n:"")),((e,t,o)=>{e.addNodeFilter("strike",(e=>{const n="html4"!==t.type;W(e,(e=>{if(n)e.name="s";else{const t=o.parse(e.attr("style"));t["text-decoration"]="line-through",e.name="span",e.attr("style",o.serialize(t))}}))}))})(e,o,r)},Lb=(e,t,o)=>{t.addNodeFilter("br",((t,n,r)=>{const i=Vt.extend({},o.getBlockElements()),s=o.getNonEmptyElements(),a=o.getWhitespaceElements();i.body=1;const l=e=>e.name in i||Ni(o,e);for(let n=0,c=t.length;n{const[t,...o]=e.split(","),n=o.join(","),r=/data:([^/]+\/[^;]+)(;.+)?/.exec(t);if(r){const e=";base64"===r[2],t=e?(e=>{const t=/([a-z0-9+\/=\s]+)/i.exec(e);return t?t[1]:""})(n):decodeURIComponent(n);return F.some({type:r[1],data:t,base64Encoded:e})}return F.none()},Hb=(e,t,o=!0)=>{let n=t;if(o)try{n=atob(t)}catch(e){return F.none()}const r=new Uint8Array(n.length);for(let e=0;enew Promise(((t,o)=>{const n=new FileReader;n.onloadend=()=>{t(n.result)},n.onerror=()=>{var e;o(null===(e=n.error)||void 0===e?void 0:e.message)},n.readAsDataURL(e)}));let jb=0;const Ub=(e,t,o)=>zb(e).bind((({data:e,type:n,base64Encoded:r})=>{if(t&&!r)return F.none();{const t=r?e:btoa(e);return o(t,n)}})),$b=(e,t,o)=>{const n=e.create("blobid"+jb++,t,o);return e.add(n),n},Wb=(e,t,o=!1)=>Ub(t,o,((t,o)=>F.from(e.getByData(t,o)).orThunk((()=>Hb(o,t).map((o=>$b(e,o,t))))))),qb=(e,t)=>{const o=e.schema;t.remove_trailing_brs&&Lb(t,e,o),e.addAttributeFilter("href",(e=>{let o=e.length;const n=e=>{const t=e?Vt.trim(e):"";return/\b(noopener)\b/g.test(t)?t:(e=>e.split(" ").filter((e=>e.length>0)).concat(["noopener"]).sort().join(" "))(t)};if(!t.allow_unsafe_link_target)for(;o--;){const t=e[o];"a"===t.name&&"_blank"===t.attr("target")&&t.attr("rel",n(t.attr("rel")))}})),t.allow_html_in_named_anchor||e.addAttributeFilter("id,name",(e=>{let t,o,n,r,i=e.length;for(;i--;)if(r=e[i],"a"===r.name&&r.firstChild&&!r.attr("href"))for(n=r.parent,t=r.lastChild;t&&n;)o=t.prev,n.insert(t,r),t=o})),t.fix_list_elements&&e.addNodeFilter("ul,ol",(e=>{let t,o,n=e.length;for(;n--;)if(t=e[n],o=t.parent,o&&("ul"===o.name||"ol"===o.name))if(t.prev&&"li"===t.prev.name)t.prev.append(t);else{const e=new Fp("li",1);e.attr("style","list-style-type: none"),t.wrap(e)}}));const n=o.getValidClasses();t.validate&&n&&e.addAttributeFilter("class",(e=>{var t;let o=e.length;for(;o--;){const r=e[o],i=null!==(t=r.attr("class"))&&void 0!==t?t:"",s=Vt.explode(i," ");let a="";for(let e=0;e{const{blob_cache:o}=t;if(o){const t=e=>{const t=e.attr("src");(e=>e.attr("src")===At.transparentSrc||_(e.attr("data-mce-placeholder")))(e)||(e=>_(e.attr("data-mce-bogus")))(e)||w(t)||Wb(o,t,!0).each((t=>{e.attr("src",t.blobUri())}))};e.addAttributeFilter("src",(e=>W(e,t)))}})(e,t)};function Gb(e){return Gb="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Gb(e)}function Yb(e,t){return Yb=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Yb(e,t)}function Kb(e,t,o){return Kb=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct:function(e,t,o){var n=[null];n.push.apply(n,t);var r=new(Function.bind.apply(e,n));return o&&Yb(r,o.prototype),r},Kb.apply(null,arguments)}function Xb(e){return function(e){if(Array.isArray(e))return Jb(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return Jb(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?Jb(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Jb(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,n=new Array(t);o1?o-1:0),r=1;r/gm),Fy=iy(/^data-[\-\w.\u00B7-\uFFFF]/),Ly=iy(/^aria-[\-\w]+$/),zy=iy(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Hy=iy(/^(?:\w+script|data):/i),Zy=iy(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),jy=iy(/^html$/i),Uy=function(){return"undefined"==typeof window?null:window},$y=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Uy(),o=function(t){return e(t)};if(o.version="2.3.8",o.removed=[],!t||!t.document||9!==t.document.nodeType)return o.isSupported=!1,o;var n=t.document,r=t.document,i=t.DocumentFragment,s=t.HTMLTemplateElement,a=t.Node,l=t.Element,c=t.NodeFilter,d=t.NamedNodeMap,u=void 0===d?t.NamedNodeMap||t.MozNamedAttrMap:d,h=t.HTMLFormElement,m=t.DOMParser,p=t.trustedTypes,g=l.prototype,f=ky(g,"cloneNode"),v=ky(g,"nextSibling"),b=ky(g,"childNodes"),y=ky(g,"parentNode");if("function"==typeof s){var w=r.createElement("template");w.content&&w.content.ownerDocument&&(r=w.content.ownerDocument)}var _=function(e,t){if("object"!==Gb(e)||"function"!=typeof e.createPolicy)return null;var o=null,n="data-tt-policy-suffix";t.currentScript&&t.currentScript.hasAttribute(n)&&(o=t.currentScript.getAttribute(n));var r="dompurify"+(o?"#"+o:"");try{return e.createPolicy(r,{createHTML:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(p,n),x=_?_.createHTML(""):"",C=r,k=C.implementation,S=C.createNodeIterator,T=C.createDocumentFragment,E=C.getElementsByTagName,O=n.importNode,M={};try{M=Cy(r).documentMode?r.documentMode:{}}catch(e){}var A={};o.isSupported="function"==typeof y&&k&&void 0!==k.createHTMLDocument&&9!==M;var B,N,R=Py,V=Iy,D=Fy,P=Ly,I=Hy,F=Zy,L=zy,z=null,H=xy({},[].concat(Xb(Sy),Xb(Ty),Xb(Ey),Xb(My),Xb(By))),Z=null,j=xy({},[].concat(Xb(Ny),Xb(Ry),Xb(Vy),Xb(Dy))),U=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),$=null,W=null,q=!0,G=!0,Y=!1,K=!1,X=!1,J=!1,Q=!1,ee=!1,te=!1,oe=!1,ne=!0,re=!0,ie=!1,se={},ae=null,le=xy({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),ce=null,de=xy({},["audio","video","img","source","image","track"]),ue=null,he=xy({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),me="http://www.w3.org/1998/Math/MathML",pe="http://www.w3.org/2000/svg",ge="http://www.w3.org/1999/xhtml",fe=ge,ve=!1,be=["application/xhtml+xml","text/html"],ye=null,we=r.createElement("form"),_e=function(e){return e instanceof RegExp||e instanceof Function},xe=function(e){ye&&ye===e||(e&&"object"===Gb(e)||(e={}),e=Cy(e),z="ALLOWED_TAGS"in e?xy({},e.ALLOWED_TAGS):H,Z="ALLOWED_ATTR"in e?xy({},e.ALLOWED_ATTR):j,ue="ADD_URI_SAFE_ATTR"in e?xy(Cy(he),e.ADD_URI_SAFE_ATTR):he,ce="ADD_DATA_URI_TAGS"in e?xy(Cy(de),e.ADD_DATA_URI_TAGS):de,ae="FORBID_CONTENTS"in e?xy({},e.FORBID_CONTENTS):le,$="FORBID_TAGS"in e?xy({},e.FORBID_TAGS):{},W="FORBID_ATTR"in e?xy({},e.FORBID_ATTR):{},se="USE_PROFILES"in e&&e.USE_PROFILES,q=!1!==e.ALLOW_ARIA_ATTR,G=!1!==e.ALLOW_DATA_ATTR,Y=e.ALLOW_UNKNOWN_PROTOCOLS||!1,K=e.SAFE_FOR_TEMPLATES||!1,X=e.WHOLE_DOCUMENT||!1,ee=e.RETURN_DOM||!1,te=e.RETURN_DOM_FRAGMENT||!1,oe=e.RETURN_TRUSTED_TYPE||!1,Q=e.FORCE_BODY||!1,ne=!1!==e.SANITIZE_DOM,re=!1!==e.KEEP_CONTENT,ie=e.IN_PLACE||!1,L=e.ALLOWED_URI_REGEXP||L,fe=e.NAMESPACE||ge,e.CUSTOM_ELEMENT_HANDLING&&_e(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(U.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&_e(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(U.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(U.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),B=B=-1===be.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,N="application/xhtml+xml"===B?function(e){return e}:py,K&&(G=!1),te&&(ee=!0),se&&(z=xy({},Xb(By)),Z=[],!0===se.html&&(xy(z,Sy),xy(Z,Ny)),!0===se.svg&&(xy(z,Ty),xy(Z,Ry),xy(Z,Dy)),!0===se.svgFilters&&(xy(z,Ey),xy(Z,Ry),xy(Z,Dy)),!0===se.mathMl&&(xy(z,My),xy(Z,Vy),xy(Z,Dy))),e.ADD_TAGS&&(z===H&&(z=Cy(z)),xy(z,e.ADD_TAGS)),e.ADD_ATTR&&(Z===j&&(Z=Cy(Z)),xy(Z,e.ADD_ATTR)),e.ADD_URI_SAFE_ATTR&&xy(ue,e.ADD_URI_SAFE_ATTR),e.FORBID_CONTENTS&&(ae===le&&(ae=Cy(ae)),xy(ae,e.FORBID_CONTENTS)),re&&(z["#text"]=!0),X&&xy(z,["html","head","body"]),z.table&&(xy(z,["tbody"]),delete $.tbody),ry&&ry(e),ye=e)},Ce=xy({},["mi","mo","mn","ms","mtext"]),ke=xy({},["foreignobject","desc","title","annotation-xml"]),Se=xy({},["title","style","font","a","script"]),Te=xy({},Ty);xy(Te,Ey),xy(Te,Oy);var Ee=xy({},My);xy(Ee,Ay);var Oe=function(e){my(o.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=x}catch(t){e.remove()}}},Me=function(e,t){try{my(o.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){my(o.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!Z[e])if(ee||te)try{Oe(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Ae=function(e){var t,o;if(Q)e=" "+e;else{var n=gy(e,/^[\r\n\t ]+/);o=n&&n[0]}"application/xhtml+xml"===B&&(e=''+e+"");var i=_?_.createHTML(e):e;if(fe===ge)try{t=(new m).parseFromString(i,B)}catch(e){}if(!t||!t.documentElement){t=k.createDocument(fe,"template",null);try{t.documentElement.innerHTML=ve?"":i}catch(e){}}var s=t.body||t.documentElement;return e&&o&&s.insertBefore(r.createTextNode(o),s.childNodes[0]||null),fe===ge?E.call(t,X?"html":"body")[0]:X?t.documentElement:s},Be=function(e){return S.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT,null,!1)},Ne=function(e){return"object"===Gb(a)?e instanceof a:e&&"object"===Gb(e)&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},Re=function(e,t,n){A[e]&&uy(A[e],(function(e){e.call(o,t,n,ye)}))},Ve=function(e){var t,n;if(Re("beforeSanitizeElements",e,null),(n=e)instanceof h&&("string"!=typeof n.nodeName||"string"!=typeof n.textContent||"function"!=typeof n.removeChild||!(n.attributes instanceof u)||"function"!=typeof n.removeAttribute||"function"!=typeof n.setAttribute||"string"!=typeof n.namespaceURI||"function"!=typeof n.insertBefore))return Oe(e),!0;if(yy(/[\u0080-\uFFFF]/,e.nodeName))return Oe(e),!0;var r=N(e.nodeName);if(Re("uponSanitizeElement",e,{tagName:r,allowedTags:z}),e.hasChildNodes()&&!Ne(e.firstElementChild)&&(!Ne(e.content)||!Ne(e.content.firstElementChild))&&yy(/<[/\w]/g,e.innerHTML)&&yy(/<[/\w]/g,e.textContent))return Oe(e),!0;if("select"===r&&yy(/=0;--a)i.insertBefore(f(s[a],!0),v(e))}return Oe(e),!0}return e instanceof l&&!function(e){var t=y(e);t&&t.tagName||(t={namespaceURI:ge,tagName:"template"});var o=py(e.tagName),n=py(t.tagName);return e.namespaceURI===pe?t.namespaceURI===ge?"svg"===o:t.namespaceURI===me?"svg"===o&&("annotation-xml"===n||Ce[n]):Boolean(Te[o]):e.namespaceURI===me?t.namespaceURI===ge?"math"===o:t.namespaceURI===pe?"math"===o&&ke[n]:Boolean(Ee[o]):e.namespaceURI===ge&&!(t.namespaceURI===pe&&!ke[n])&&!(t.namespaceURI===me&&!Ce[n])&&!Ee[o]&&(Se[o]||!Te[o])}(e)?(Oe(e),!0):"noscript"!==r&&"noembed"!==r||!yy(/<\/no(script|embed)/i,e.innerHTML)?(K&&3===e.nodeType&&(t=e.textContent,t=fy(t,R," "),t=fy(t,V," "),e.textContent!==t&&(my(o.removed,{element:e.cloneNode()}),e.textContent=t)),Re("afterSanitizeElements",e,null),!1):(Oe(e),!0)},De=function(e,t,o){if(ne&&("id"===t||"name"===t)&&(o in r||o in we))return!1;if(G&&!W[t]&&yy(D,t));else if(q&&yy(P,t));else if(!Z[t]||W[t]){if(!(Pe(e)&&(U.tagNameCheck instanceof RegExp&&yy(U.tagNameCheck,e)||U.tagNameCheck instanceof Function&&U.tagNameCheck(e))&&(U.attributeNameCheck instanceof RegExp&&yy(U.attributeNameCheck,t)||U.attributeNameCheck instanceof Function&&U.attributeNameCheck(t))||"is"===t&&U.allowCustomizedBuiltInElements&&(U.tagNameCheck instanceof RegExp&&yy(U.tagNameCheck,o)||U.tagNameCheck instanceof Function&&U.tagNameCheck(o))))return!1}else if(ue[t]);else if(yy(L,fy(o,F,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==vy(o,"data:")||!ce[e])if(Y&&!yy(I,fy(o,F,"")));else if(o)return!1;return!0},Pe=function(e){return e.indexOf("-")>0},Ie=function(e){var t,o,n,r;Re("beforeSanitizeAttributes",e,null);var i=e.attributes;if(i){var s={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Z};for(r=i.length;r--;){var a=t=i[r],l=a.name,c=a.namespaceURI;o="value"===l?t.value:by(t.value),n=N(l);var d=o;if(s.attrName=n,s.attrValue=o,s.keepAttr=!0,s.forceKeepAttr=void 0,Re("uponSanitizeAttribute",e,s),o=s.attrValue,!s.forceKeepAttr)if(s.keepAttr)if(yy(/\/>/i,o))Me(l,e);else{K&&(o=fy(o,R," "),o=fy(o,V," "));var u=N(e.nodeName);if(De(u,n,o)){if(o!==d)try{c?e.setAttributeNS(c,l,o):e.setAttribute(l,o)}catch(t){Me(l,e)}}else Me(l,e)}else Me(l,e)}Re("afterSanitizeAttributes",e,null)}},Fe=function e(t){var o,n=Be(t);for(Re("beforeSanitizeShadowDOM",t,null);o=n.nextNode();)Re("uponSanitizeShadowNode",o,null),Ve(o)||(o.content instanceof i&&e(o.content),Ie(o));Re("afterSanitizeShadowDOM",t,null)};return o.sanitize=function(e,r){var s,l,c,d,u;if((ve=!e)&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Ne(e)){if("function"!=typeof e.toString)throw wy("toString is not a function");if("string"!=typeof(e=e.toString()))throw wy("dirty is not a string, aborting")}if(!o.isSupported){if("object"===Gb(t.toStaticHTML)||"function"==typeof t.toStaticHTML){if("string"==typeof e)return t.toStaticHTML(e);if(Ne(e))return t.toStaticHTML(e.outerHTML)}return e}if(J||xe(r),o.removed=[],"string"==typeof e&&(ie=!1),ie){if(e.nodeName){var h=N(e.nodeName);if(!z[h]||$[h])throw wy("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof a)1===(l=(s=Ae("\x3c!----\x3e")).ownerDocument.importNode(e,!0)).nodeType&&"BODY"===l.nodeName||"HTML"===l.nodeName?s=l:s.appendChild(l);else{if(!ee&&!K&&!X&&-1===e.indexOf("<"))return _&&oe?_.createHTML(e):e;if(!(s=Ae(e)))return ee?null:oe?x:""}s&&Q&&Oe(s.firstChild);for(var m=Be(ie?e:s);c=m.nextNode();)3===c.nodeType&&c===d||Ve(c)||(c.content instanceof i&&Fe(c.content),Ie(c),d=c);if(d=null,ie)return e;if(ee){if(te)for(u=T.call(s.ownerDocument);s.firstChild;)u.appendChild(s.firstChild);else u=s;return Z.shadowroot&&(u=O.call(n,u,!0)),u}var p=X?s.outerHTML:s.innerHTML;return X&&z["!doctype"]&&s.ownerDocument&&s.ownerDocument.doctype&&s.ownerDocument.doctype.name&&yy(jy,s.ownerDocument.doctype.name)&&(p="\n"+p),K&&(p=fy(p,R," "),p=fy(p,V," ")),_&&oe?_.createHTML(p):p},o.setConfig=function(e){xe(e),J=!0},o.clearConfig=function(){ye=null,J=!1},o.isValidAttribute=function(e,t,o){ye||xe({});var n=N(e),r=N(t);return De(n,r,o)},o.addHook=function(e,t){"function"==typeof t&&(A[e]=A[e]||[],my(A[e],t))},o.removeHook=function(e){if(A[e])return hy(A[e])},o.removeHooks=function(e){A[e]&&(A[e]=[])},o.removeAllHooks=function(){A={}},o}();const Wy=Vt.each,qy=Vt.trim,Gy=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],Yy={ftp:21,http:80,https:443,mailto:25},Ky=["img","video"],Xy=(e,t,o)=>{const n=(e=>{try{return decodeURIComponent(e)}catch(t){return unescape(e)}})(t).replace(/\s/g,"");return!e.allow_script_urls&&(!!/((java|vb)script|mhtml):/i.test(n)||!e.allow_html_data_urls&&(/^data:image\//i.test(n)?((e,t)=>_(e)?!e:!_(t)||!j(Ky,t))(e.allow_svg_data_urls,o)&&/^data:image\/svg\+xml/i.test(n):/^data:/i.test(n)))};class Jy{static parseDataUri(e){let t;const o=decodeURIComponent(e).split(","),n=/data:([^;]+)/.exec(o[0]);return n&&(t=n[1]),{type:t,data:o[1]}}static isDomSafe(e,t,o={}){if(o.allow_script_urls)return!0;{const n=es.decode(e).replace(/[\s\u0000-\u001F]+/g,"");return!Xy(o,n,t)}}static getDocumentBaseUrl(e){var t;let o;return o=0!==e.protocol.indexOf("http")&&"file:"!==e.protocol?null!==(t=e.href)&&void 0!==t?t:"":e.protocol+"//"+e.host+e.pathname,/^[^:]+:\/\/\/?[^\/]+\//.test(o)&&(o=o.replace(/[\?#].*$/,"").replace(/[\/\\][^\/]+$/,""),/[\/\\]$/.test(o)||(o+="/")),o}constructor(e,t={}){this.path="",this.directory="",e=qy(e),this.settings=t;const o=t.base_uri,n=this;if(/^([\w\-]+):([^\/]{2})/i.test(e)||/^\s*#/.test(e))return void(n.source=e);const r=0===e.indexOf("//");if(0!==e.indexOf("/")||r||(e=(o&&o.protocol||"http")+"://mce_host"+e),!/^[\w\-]*:?\/\//.test(e)){const t=o?o.path:new Jy(document.location.href).directory;if(""===(null==o?void 0:o.protocol))e="//mce_host"+n.toAbsPath(t,e);else{const r=/([^#?]*)([#?]?.*)/.exec(e);r&&(e=(o&&o.protocol||"http")+"://mce_host"+n.toAbsPath(t,r[1])+r[2])}}e=e.replace(/@@/g,"(mce_at)");const i=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*):?([^:@\/]*))?@)?(\[[a-zA-Z0-9:.%]+\]|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(e);i&&Wy(Gy,((e,t)=>{let o=i[t];o&&(o=o.replace(/\(mce_at\)/g,"@@")),n[e]=o})),o&&(n.protocol||(n.protocol=o.protocol),n.userInfo||(n.userInfo=o.userInfo),n.port||"mce_host"!==n.host||(n.port=o.port),n.host&&"mce_host"!==n.host||(n.host=o.host),n.source=""),r&&(n.protocol="")}setPath(e){const t=/^(.*?)\/?(\w+)?$/.exec(e);t&&(this.path=t[0],this.directory=t[1],this.file=t[2]),this.source="",this.getURI()}toRelative(e){if("./"===e)return e;const t=new Jy(e,{base_uri:this});if("mce_host"!==t.host&&this.host!==t.host&&t.host||this.port!==t.port||this.protocol!==t.protocol&&""!==t.protocol)return t.getURI();const o=this.getURI(),n=t.getURI();if(o===n||"/"===o.charAt(o.length-1)&&o.substr(0,o.length-1)===n)return o;let r=this.toRelPath(this.path,t.path);return t.query&&(r+="?"+t.query),t.anchor&&(r+="#"+t.anchor),r}toAbsolute(e,t){const o=new Jy(e,{base_uri:this});return o.getURI(t&&this.isSameOrigin(o))}isSameOrigin(e){if(this.host==e.host&&this.protocol==e.protocol){if(this.port==e.port)return!0;const t=this.protocol?Yy[this.protocol]:null;if(t&&(this.port||t)==(e.port||t))return!0}return!1}toRelPath(e,t){let o,n,r=0,i="";const s=e.substring(0,e.lastIndexOf("/")).split("/"),a=t.split("/");if(s.length>=a.length)for(o=0,n=s.length;o=a.length||s[o]!==a[o]){r=o+1;break}if(s.length=s.length||s[o]!==a[o]){r=o+1;break}if(1===r)return t;for(o=0,n=s.length-(r-1);o{e&&s.push(e)}));const a=[];for(let e=i.length-1;e>=0;e--)0!==i[e].length&&"."!==i[e]&&(".."!==i[e]?o>0?o--:a.push(i[e]):o++);const l=s.length-o;let c;return c=l<=0?re(a).join("/"):s.slice(0,l).join("/")+"/"+re(a).join("/"),0!==c.indexOf("/")&&(c="/"+c),n&&c.lastIndexOf("/")!==c.length-1&&(c+=n),c}getURI(e=!1){let t;return this.source&&!e||(t="",e||(this.protocol?t+=this.protocol+"://":t+="//",this.userInfo&&(t+=this.userInfo+"@"),this.host&&(t+=this.host),this.port&&(t+=":"+this.port)),this.path&&(t+=this.path),this.query&&(t+="?"+this.query),this.anchor&&(t+="#"+this.anchor),this.source=t),this.source}}const Qy=Vt.makeMap("src,href,data,background,action,formaction,poster,xlink:href"),ew="data-mce-type";let tw=0;const ow=(e,t,o,n)=>{var r,i,s,a;const l=t.validate,c=o.getSpecialElements();8===e.nodeType&&!t.allow_conditional_comments&&/^\[if/i.test(null!==(r=e.nodeValue)&&void 0!==r?r:"")&&(e.nodeValue=" "+e.nodeValue);const d=null!==(i=null==n?void 0:n.tagName)&&void 0!==i?i:e.nodeName.toLowerCase();if(1!==e.nodeType||"body"===d)return;const u=wo(e),h=no(u,ew),p=to(u,"data-mce-bogus");if(!h&&m(p))return void("all"===p?xn(u):Cn(u));const g=o.getElementRule(d);if(!l||g){if(_(n)&&(n.allowedTags[d]=!0),l&&g&&!h){if(W(null!==(s=g.attributesForced)&&void 0!==s?s:[],(e=>{Qt(u,e.name,"{$uid}"===e.value?"mce_"+tw++:e.value)})),W(null!==(a=g.attributesDefault)&&void 0!==a?a:[],(e=>{no(u,e.name)||Qt(u,e.name,"{$uid}"===e.value?"mce_"+tw++:e.value)})),g.attributesRequired&&!U(g.attributesRequired,(e=>no(u,e))))return void Cn(u);if(g.removeEmptyAttrs&&(e=>{const t=e.dom.attributes;return null==t||0===t.length})(u))return void Cn(u);g.outputName&&g.outputName!==d&&((e,t)=>{const o=((e,t)=>{const o=bo(t),n=io(e);return eo(o,n),o})(e,t);fn(e,o);const n=Io(e);wn(o,n),xn(e)})(u,g.outputName)}}else ke(c,d)?xn(u):Cn(u)},nw=(e,t,o,n,r)=>!(n in Qy&&Xy(e,r,o))&&(!e.validate||t.isValid(o,n)||je(n,"data-")||je(n,"aria-")),rw=(e,t)=>e.hasAttribute(ew)&&("id"===t||"class"===t||"style"===t),iw=(e,t)=>e in t.getBoolAttrs(),sw=(e,t,o)=>{const{attributes:n}=e;for(let r=n.length-1;r>=0;r--){const i=n[r],s=i.name,a=i.value;nw(t,o,e.tagName.toLowerCase(),s,a)||rw(e,s)?iw(s,o)&&e.setAttribute(s,s):e.removeAttribute(s)}},aw=(e,t)=>{const o=$y();return o.addHook("uponSanitizeElement",((o,n)=>{ow(o,e,t,n)})),o.addHook("uponSanitizeAttribute",((o,n)=>{const r=o.tagName.toLowerCase(),{attrName:i,attrValue:s}=n;n.keepAttr=nw(e,t,r,i,s),n.keepAttr?(n.allowedAttributes[i]=!0,iw(i,t)&&(n.attrValue=i),e.allow_svg_data_urls&&je(s,"data:image/svg+xml")&&(n.forceKeepAttr=!0)):rw(o,i)&&(n.forceKeepAttr=!0)})),o},lw=Vt.makeMap,cw=Vt.extend,dw=(e,t,o)=>{const n=e.name,r=n in o&&"title"!==n&&"textarea"!==n,i=t.childNodes;for(let t=0,n=i.length;t{const o=Ib(),n=Ib(),r={validate:!0,root_name:"body",sanitize:!0,...e},i=new DOMParser,s=((e,t)=>{if(e.sanitize){const o=aw(e,t);return(t,n)=>{o.sanitize(t,((e,t)=>{const o={IN_PLACE:!0,ALLOW_UNKNOWN_PROTOCOLS:!0,ALLOWED_TAGS:["#comment","#cdata-section","body"],ALLOWED_ATTR:[]};return o.PARSER_MEDIA_TYPE=t,e.allow_script_urls?o.ALLOWED_URI_REGEXP=/.*/:e.allow_html_data_urls&&(o.ALLOWED_URI_REGEXP=/^(?!(\w+script|mhtml):)/i),o})(e,n)),o.removed=[]}}return(o,n)=>{const r=document.createNodeIterator(o,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT|NodeFilter.SHOW_TEXT);let i;for(;i=r.nextNode();)ow(i,e,t),Un(i)&&sw(i,e,t)}})(r,t),a=o.addFilter,l=o.getFilters,c=o.removeFilter,d=n.addFilter,u=n.getFilters,h=n.removeFilter,p=(e,o)=>{const n=m(o.attr(ew)),r=1===o.type&&!ke(e,o.name)&&!Ni(t,o);return 3===o.type||r&&!n},g={schema:t,addAttributeFilter:d,getAttributeFilters:u,removeAttributeFilter:h,addNodeFilter:a,getNodeFilters:l,removeNodeFilter:c,parse:(e,o={})=>{var n;const a=r.validate,c=null!==(n=o.context)&&void 0!==n?n:r.root_name,d=((e,o,n="html")=>{const r="xhtml"===n?"application/xhtml+xml":"text/html",a=ke(t.getSpecialElements(),o.toLowerCase()),l=a?`<${o}>${e}${o}>`:e,c="xhtml"===n?`${l}`:`${l}`,d=i.parseFromString(c,r).body;return s(d,r),a?d.firstChild:d})(e,c,o.format);Si(t,d);const h=new Fp(c,11);dw(h,d,t.getSpecialElements()),d.innerHTML="";const[m,g]=((e,t,o,n)=>{const r=o.validate,i=t.getNonEmptyElements(),s=t.getWhitespaceElements(),a=cw(lw("script,style,head,html,body,title,meta,param"),t.getBlockElements()),l=cs(t),c=/[ \t\r\n]+/g,d=/^[ \t\r\n]+/,u=/[ \t\r\n]+$/,h=e=>{let t=e.parent;for(;_(t);){if(t.name in s)return!0;t=t.parent}return!1},m=e=>e.name in a||Ni(t,e),p=(t,o)=>{const r=o?t.prev:t.next;return!_(r)&&!w(t.parent)&&m(t.parent)&&(t.parent!==e||!0===n.isRootContent)};return[e=>{var t;if(3===e.type&&!h(e)){let o=null!==(t=e.value)&&void 0!==t?t:"";o=o.replace(c," "),(((e,t)=>_(e)&&(t(e)||"br"===e.name))(e.prev,m)||p(e,!0))&&(o=o.replace(d,"")),0===o.length?e.remove():e.value=o}},e=>{var a;if(1===e.type){const a=t.getElementRule(e.name);if(r&&a){const r=lv(t,i,s,e);a.paddInEmptyBlock&&r&&(e=>{let o=e;for(;_(o);){if(o.name in l)return lv(t,i,s,o);o=o.parent}return!1})(e)?sv(o,n,m,e):a.removeEmpty&&r?m(e)?e.remove():e.unwrap():a.paddEmpty&&(r||(e=>{var t;return av(e,"#text")&&(null===(t=null==e?void 0:e.firstChild)||void 0===t?void 0:t.value)===fr})(e))&&sv(o,n,m,e)}}else if(3===e.type&&!h(e)){let t=null!==(a=e.value)&&void 0!==a?a:"";(e.next&&m(e.next)||p(e,!1))&&(t=t.replace(u,"")),0===t.length?e.remove():e.value=t}}]})(h,t,r,o),f=[],v=a?e=>((e,o)=>{hv(t,e)&&o.push(e)})(e,f):S,b={nodes:{},attributes:{}},y=e=>nv(l(),u(),e,b);if(((e,t,o)=>{const n=[];for(let o=e,r=o;o;r=o,o=o.walk()){const i=o;W(t,(e=>e(i))),w(i.parent)&&i!==e?o=r:n.push(i)}for(let e=n.length-1;e>=0;e--){const t=n[e];W(o,(e=>e(t)))}})(h,[m,y],[g,v]),f.reverse(),a&&f.length>0)if(o.context){const{pass:e,fail:n}=G(f,(e=>e.parent===h));uv(n,t,h,y),o.invalid=e.length>0}else uv(f,t,h,y);const x=((e,t)=>{var o;const n=null!==(o=t.forced_root_block)&&void 0!==o?o:e.forced_root_block;return!1===n?"":!0===n?"p":n})(r,o);return x&&("body"===h.name||o.isRootContent)&&((e,o)=>{const n=cw(lw("script,style,head,html,body,title,meta,param"),t.getBlockElements()),i=/^[ \t\r\n]+/,s=/[ \t\r\n]+$/;let a=e.firstChild,l=null;const c=e=>{var t,o;e&&(a=e.firstChild,a&&3===a.type&&(a.value=null===(t=a.value)||void 0===t?void 0:t.replace(i,"")),a=e.lastChild,a&&3===a.type&&(a.value=null===(o=a.value)||void 0===o?void 0:o.replace(s,"")))};if(t.isValidChild(e.name,o.toLowerCase())){for(;a;){const t=a.next;p(n,a)?(l||(l=new Fp(o,1),l.attr(r.forced_root_block_attrs),e.insert(l,a)),l.append(a)):(c(l),l=null),a=t}c(l)}})(h,x),o.invalid||rv(b,o),h}};return qb(g,r),((e,t,o)=>{t.inline_styles&&Fb(e,t,o)})(g,r,t),g},hw=(e,t,o)=>{const n=(e=>xv(e)?ng({validate:!1}).serialize(e):e)(e),r=t(n);if(r.isDefaultPrevented())return r;if(xv(e)){if(r.content!==n){const t=uw({validate:!1,forced_root_block:!1,sanitize:o}).parse(r.content,{context:e.name});return{...r,content:t}}return{...r,content:e}}return r},mw=(e,t)=>{if(t.no_events)return sl.value(t);{const o=((e,t)=>e.dispatch("BeforeGetContent",t))(e,t);return o.isDefaultPrevented()?sl.error(Qh(e,{content:"",...o}).content):sl.value(o)}},pw=(e,t,o)=>{if(o.no_events)return t;{const n=hw(t,(t=>Qh(e,{...o,content:t})),rd(e));return n.content}},gw=(e,t)=>{if(t.no_events)return sl.value(t);{const o=hw(t.content,(o=>((e,t)=>e.dispatch("BeforeSetContent",t))(e,{...t,content:o})),rd(e));return o.isDefaultPrevented()?(Jh(e,o),sl.error(void 0)):sl.value(o)}},fw=(e,t,o)=>{o.no_events||Jh(e,{...o,content:t})},vw=(e,t,o)=>({element:e,width:t,rows:o}),bw=(e,t)=>({element:e,cells:t}),yw=(e,t)=>({x:e,y:t}),ww=(e,t)=>oo(e,t).bind(Xe).getOr(1),_w=(e,t,o)=>{const n=e.rows;return!!(n[o]?n[o].cells:[])[t]},xw=e=>X(e,((e,t)=>t.cells.length>e?t.cells.length:e),0),Cw=(e,t)=>{const o=e.rows;for(let e=0;e{const i=[],s=e.rows;for(let e=o;e<=r;e++){const o=s[e].cells,r=t((e,t)=>{const o=ra(e.element),n=bo("tbody");return wn(n,t),bn(o,n),o})(e,(e=>$(e.rows,(e=>{const t=$(e.cells,(e=>{const t=ia(e);return ro(t,"colspan"),ro(t,"rowspan"),t})),o=ra(e.element);return wn(o,t),o})))(e)),Tw=(e,t)=>{const o=wo(t.commonAncestorContainer),n=kg(o,e),r=Y(n,Rr),i=((e,t)=>Q(e,(e=>"li"===jt(e)&&eh(e,t))).fold(O([]),(t=>(e=>Q(e,(e=>"ul"===jt(e)||"ol"===jt(e))))(e).map((e=>{const t=bo(jt(e)),o=we(mn(e),((e,t)=>je(t,"list-style")));return cn(t,o),[bo("li"),t]})).getOr([]))))(n,t),s=r.concat(i.length?i:(e=>Or(e)?Ao(e).filter(Er).fold(O([]),(t=>[e,t])):Er(e)?[e]:[])(o));return $(s,ra)},Ew=()=>wm([]),Ow=(e,t)=>((e,t)=>en(t,"table",B(So,e)))(e,t[0]).bind((e=>{const o=t[0],n=t[t.length-1],r=(e=>{const t=vw(ra(e),0,[]);return W(Ln(e,"tr"),((e,o)=>{W(Ln(e,"td,th"),((n,r)=>{((e,t,o,n,r)=>{const i=ww(r,"rowspan"),s=ww(r,"colspan"),a=e.rows;for(let e=o;e{for(;_w(e,t,o);)t++;return t})(t,r,o),o,e,n)}))})),vw(t.element,xw(t.rows),t.rows)})(e);return((e,t,o)=>Cw(e,t).bind((t=>Cw(e,o).map((o=>((e,t,o)=>{const n=t.x,r=t.y,i=o.x,s=o.y,a=rwm([Sw(e)])))})).getOrThunk(Ew),Mw=(e,t)=>{const o=Yu(t,e);return o.length>0?Ow(e,o):((e,t)=>t.length>0&&t[0].collapsed?Ew():((e,t)=>((e,t)=>{const o=X(t,((e,t)=>(bn(t,e),t)),e);return t.length>0?wm([o]):o})(wo(t.cloneContents()),Tw(e,t)))(e,t[0]))(e,t)},Aw=(e,t)=>t>=0&&t