"use strict";(self.webpackChunk_wintercms_wn_backend_module=self.webpackChunk_wintercms_wn_backend_module||[]).push([[794],{915:function(t,e,i){var n=i(591),s=i.n(n),o=i(969),a={insert:"head",singleton:!1};s()(o.A,a),o.A.locals;(t=>{class e extends t.PluginBase{construct(t){this.element=t,this.config=this.snowboard.dataConfig(this,t),this.clean=Boolean(t.dataset.clean),this.hidden=!0,this.input=t.querySelector("[data-input]"),this.toggle=t.querySelector("[data-toggle]"),this.icon=t.querySelector("[data-icon]"),this.loader=t.querySelector("[data-loader]"),this.copy=t.querySelector("[data-copy]"),this.events={input:()=>this.onInput(),toggle:()=>this.onToggle(),tabChange:()=>this.onTabChange(),copy:()=>this.onCopy()},this.attachEvents()}defaults(){return{readOnly:!1,disabled:!1,eventHandler:null,hideOnTabChange:!1}}attachEvents(){this.input.addEventListener("keydown",this.events.input),this.toggle.addEventListener("click",this.events.toggle),this.config.get("hideOnTabChange")&&document.addEventListener("visibilitychange",this.events.tabChange),this.copy&&this.copy.addEventListener("click",this.events.copy)}destruct(){this.input.removeEventListener("keydown",this.events.input),this.toggle.removeEventListener("click",this.events.toggle),this.config.get("hideOnTabChange")&&document.removeEventListener("visibilitychange",this.events.tabChange),this.copy&&this.copy.removeEventListener("click",this.events.copy),this.input=null,this.toggle=null,this.icon=null,this.loader=null,super.destruct()}onInput(){this.clean&&(this.clean=!1,this.input.value="")}onToggle(){""!==this.input.value&&this.clean?this.reveal():this.toggleVisibility()}onTabChange(){document.hidden&&!this.hidden&&this.toggleVisibility()}onCopy(){new Promise(((t,e)=>{""!==this.input.value&&this.clean?this.reveal(t).then((()=>t()),(()=>e())):t()})).then((()=>{const t=this.hidden;this.hidden&&this.toggleVisibility(),this.input.focus(),this.input.select();try{const t=new Blob([this.input.value],{type:"text/plain"}),e=new ClipboardItem({"text/plain":t});navigator.clipboard.write([e])}catch(t){this.snowboard.error(`Clipboard API not supported - ${t}`)}this.input.blur(),t&&this.toggleVisibility()}),(t=>{this.snowboard.error(`Unable to retrieve hidden value - ${t}`)}))}toggleVisibility(){this.input.setAttribute("type",this.hidden?"text":"password"),this.icon.classList.toggle("icon-eye"),this.icon.classList.toggle("icon-eye-slash"),this.hidden=!this.hidden}reveal(){return new Promise(((t,e)=>{this.icon.style.visibility="hidden",this.loader.classList.remove("hide"),this.snowboard.request(this.input,this.config.get("eventHandler"),{success:e=>{this.input.value=e.value,this.clean=!1,this.icon.style.visibility="visible",this.loader.classList.add("hide"),this.toggleVisibility(),t()},error:t=>{e(new Error(t))}})}))}}t.addPlugin("backend.formwidget.sensitive",e),t["backend.ui.widgethandler"]().register("sensitive","backend.formwidget.sensitive")})(window.Snowboard)},969:function(t,e,i){var n=i(935),s=i.n(n)()((function(t){return t[1]}));s.push([t.id,"div[data-control=sensitive] a[data-copy],div[data-control=sensitive] a[data-toggle]{border:1px solid #d1d6d9;border-left:0;box-shadow:none}",""]),e.A=s}},function(t){t.O(0,[429],(function(){return e=915,t(t.s=e);var e}));t.O()}]);