',closeButtonTemplate:`
${e(49370)}
`,helpButtonTemplate:'
',helpActionsMod:"tv-dialog__section--actions_with-help"},v={default:"tv-button tv-button--default",primary:"tv-button tv-button--primary",success:"tv-button tv-button--success",danger:"tv-button tv-button--danger",warning:"tv-button tv-button--warning",link:"tv-button tv-button--link",checkbox:"tv-control-checkbox tv-control-checkbox--in-actions","default-ghost":"tv-button tv-button--default_ghost","primary-ghost":"tv-button tv-button--primary_ghost","success-ghost":"tv-button tv-button--success_ghost","danger-ghost":"tv-button tv-button--danger_ghost","warning-ghost":"tv-button tv-button--warning_ghost"},_={_default:'
{{ text }}
',"submit-primary":'
',"submit-success":'
'};class m extends(l()){constructor(t={}){if(super(),this.manager=t.manager||(0,d.getRootOverlapManager)(t.ownerDocument),this._id=p++,this.loadingActions=[],this.disabledActions=[],this.firstFocusControl=null,this.options={...f,...t},this.$el=h(c.render(this.options.template,{title:this.options.title,closeButton:this.options.closeButton})),this.$el.addClass("js-dialog"),this.el=this.$el[0],this.options.dataset)for(const[t,s]of Object.entries(this.options.dataset))"string"==typeof s&&this.el.setAttribute("data-"+t,s);for(this.options.addClass&&this.$el.addClass(this.options.addClass),this.options.width&&this.$el.css({width:"100%","max-width":this.options.width}),this.on("beforeOpen",()=>{this.$wrap=this.manager.ensureWindow(this._id)}),this.on("afterClose",()=>{this.$wrap=null,this.manager.unregisterWindow(this._id)}),this.options.title&&(this.$title=h(c.render(this.options.titleTemplate,{title:this.options.title})).appendTo(this.$el)),this.$content=h(this.options.contentWrapTemplate).appendTo(this.$el),this.$contentIn=this.$content;this.$contentIn.length;)this.$contentIn=this.$contentIn.children();if(this.$contentIn=this.$contentIn.end(),
this.options.content&&this.renderContent(this.options.content),(this.options.actions||this.options.help)&&(this.$content.hasClass("tv-dialog__section")&&this.$content.addClass("tv-dialog__section--no-padding_bottom"),this.$actions=h(this.options.actionsWrapTemplate).appendTo(this.$el)),this.options.actions){this.actions={},this.$el.on("click",".js-dialog__action-click",t=>{t.preventDefault(),this.actionDispatcher(h(t.currentTarget).data("name"))});for(let t=this.options.actions.length-1;t>=0;t--){const s=this.options.actions[t];if(s.type||(s.type="default"),s.class||(s.class=v[s.type]?v[s.type]:v.default),"checkbox"===s.type){const t=new n.default({labelRight:s.text,name:s.name,checked:s.checked});this.actions[s.name]=t.$el.appendTo(this.$actions),this.actions[s.name].on("change",()=>{setTimeout(()=>this.actionDispatcher(s.name,t.checked))})}else this.actions[s.name]=h(c.render(s.template?s.template:_[s.type]||_._default,s,s)).appendTo(this.$actions);if(s.method&&"function"==typeof this[s.method]&&this.on("action:"+s.name,this[s.method].bind(this)),s.addClass&&this.actions[s.name].addClass(s.addClass),s.key)if("string"==typeof s.key&&s.key.split("+").length>1){let t=[];const e=s.key.split("+"),i=s=>{t=[]},o=i=>{const o=""+i.keyCode;-1!==e.indexOf(o)&&t.indexOf(o)&&t.push(o),this._focused&&t.length===e.length&&(t=[],this.actionDispatcher(s.name))};this.on("afterOpen",()=>{g.on("keydown",o),g.on("keyup",i)}),this.on("beforeClose",()=>{g.off("keydown",o),g.off("keyup",i)})}else{const t=h.isArray(s.key)?s.key:[s.key],e=e=>{!e.isDefaultPrevented()&&this._focused&&-1!==t.indexOf(e.keyCode)&&this.actionDispatcher(s.name)};this.on("afterOpen",()=>g.on("keydown",e)),this.on("beforeClose",()=>g.off("keydown",e))}}}if(this.options.help&&h(c.render(this.options.helpButtonTemplate,this.options.help)).prependTo(this.$actions.addClass(this.options.helpActionsMod)),this.options.closeButton){const t=h(this.options.closeButtonTemplate);t.addClass(this.options.closeButtonAddClass||"");let s=this.$el;1===this.$el.find(".js-close-button-place").length&&(s=this.$el.find(".js-close-button-place")),t.appendTo(s)}this.setZIndex(110+b.length),t.errorMod&&(this.errorMod=t.errorMod),this.on("afterOpen",()=>{this.$el.focus(),this.options.focusFirstControl&&!i.mobiletouch&&(this.firstFocusControl||this.$el.find('input:not([type="hidden"]), textarea').first()).focus()}),this.$el.on("click",".js-dialog__close",this.close.bind(this)),this.$el.on("mousedown touchstart",this.focus.bind(this)),b.push(this)}renderContent(t){return this.$contentIn.html("function"==typeof t?t(this):t),this}setDestroyOnClose(t){this.options.destroyOnClose=t}setZIndex(t){return this.zIndex=t,this.trigger("change:zIndex",[this]),this}toTop(){for(let t=b.length-1;t>=0;t--)b[t].zIndex>this.zIndex&&b[t].setZIndex(b[t].zIndex-1);return this.setZIndex(110+b.length),this.manager.moveToTop(this._id),this._hotkeys&&this._hotkeys.promote(),this}isEventOut(t){if(this.options.isClickOutFn){const s=this.options.isClickOutFn(t);if(void 0!==s)return s}let s=!0;const e=h(t.target)
;return e.get(0)!==this.$el.get(0)&&(h(">*",this.$el).each((function(){e.get(0)===h(this).get(0)&&(s=!1),0===e.closest("HTML",h(this).get(0)).length&&(s=!1)})),s)}focus(){u&&u!==this&&u.unfocus(),this._setFocused(),this._focused=!0,this.$el.addClass(this.options.focusClass),this.trigger("focus",[this]),setTimeout(()=>{g.on("mousedown.tv-dialog-unfocus-"+this._id,t=>{this.isEventOut(t)&&(this.unfocus(),g.off("mousedown.tv-dialog-unfocus-"+this._id))})},20)}_setFocused(){u!==this&&(u=this)}_setUnfocused(){u===this&&(u=void 0)}unfocus(){u===this&&(this._setUnfocused(),this._focused=!1,this.$el.removeClass(this.options.focusClass).find(":focus").blur(),this.trigger("unfocus",[this]))}isFocused(){return this._focused}setTitle(t,s=!1){return this.$title.toggleClass("tv-dialog__section--one-line apply-overflow-tooltip",s),this.$title.html(t),this}setTitleText(t){this.$title.find(".js-title-text").text(t)}actionDispatcher(t,...s){this.disabledActions.includes(t)||this.loadingActions.includes(t)||this.trigger("action:"+t,[this,...s])}toggleAction(t,s){return s||this.disabledActions.includes(t)?s&&this.disabledActions.includes(t)&&(this.disabledActions=r.without(this.disabledActions,t)):this.disabledActions.push(t),this.actions[t].toggleClass("i-disabled",!s),this}actionLoader(t,s="init"){return this.actions[t].tvButtonLoader(s),"init"===s&&(this.actions[t].off("tv-button-loader:start.dialog-action").on("tv-button-loader:start.dialog-action",()=>{this.loadingActions.push(t)}),this.actions[t].off("tv-button-loader:stop.dialog-action").on("tv-button-loader:stop.dialog-action",()=>{this.loadingActions=r.without(this.loadingActions,t)})),this}error(t){const s=h(c.render(this.options.errorTemplate,{error:t,errorMod:this.errorMod})).appendTo(this.$el);return setTimeout(()=>s.removeClass("i-slided"),20),g.one("touchstart mousedown keydown",()=>{s.addClass("i-slided"),setTimeout(()=>s.remove(),.75*o.dur)}),this.trigger("error",[this,s]),this}destroy(){this.$wrap=null,this.manager.unregisterWindow(this._id),this._hotkeys&&this._hotkeys.destroy(),b=r.without(b,this);for(let t=0;t
{t.exports=''}}]);