"use strict";(self["webpackChunkplatypush"]=self["webpackChunkplatypush"]||[]).push([[8203],{98203:function(e,l,t){t.r(l),t.d(l,{default:function(){return D}});var a=t(20641),s=t(90033),i=t(53751);const n={class:"entity variable-container"},o={class:"icon"},u={class:"label"},r=["textContent"],d=["textContent"],c={class:"row"},h={class:"row"},v={class:"col-9"},p=["disabled"],k={class:"col-3 pull-right"},f=["disabled"],b=["disabled"],m=["disabled"];function g(e,l,t,g,C,y){const L=(0,a.g2)("EntityIcon"),$=(0,a.g2)("ConfirmDialog");return(0,a.uX)(),(0,a.CE)("div",n,[(0,a.Lk)("div",{class:(0,s.C4)(["head",{collapsed:e.collapsed}])},[(0,a.Lk)("div",o,[(0,a.bF)(L,{entity:e.value,loading:e.loading,error:e.error},null,8,["entity","loading","error"])]),(0,a.Lk)("div",u,[(0,a.Lk)("div",{class:"name",textContent:(0,s.v_)(e.value.name)},null,8,r)]),(0,a.Lk)("div",{class:"value-and-toggler",onClick:l[1]||(l[1]=(0,i.D$)(l=>e.collapsed=!e.collapsed,["stop"]))},[(0,a.Lk)("div",{class:(0,s.C4)(["value",{truncated:e.collapsed}]),textContent:(0,s.v_)(e.value.value)},null,10,d),(0,a.Lk)("div",{class:"collapse-toggler",onClick:l[0]||(l[0]=(0,i.D$)(l=>e.collapsed=!e.collapsed,["stop"]))},[(0,a.Lk)("i",{class:(0,s.C4)(["fas",{"fa-chevron-down":e.collapsed,"fa-chevron-up":!e.collapsed}])},null,2)])])],2),e.collapsed?(0,a.Q3)("",!0):((0,a.uX)(),(0,a.CE)("div",{key:0,class:"body",onClick:l[6]||(l[6]=(0,i.D$)((...l)=>e.prevent&&e.prevent(...l),["stop"]))},[(0,a.Lk)("div",c,[(0,a.Lk)("form",{onSubmit:l[5]||(l[5]=(0,i.D$)((...e)=>y.setValue&&y.setValue(...e),["prevent"]))},[(0,a.Lk)("div",h,[(0,a.Lk)("div",v,[(0,a.bo)((0,a.Lk)("textarea",{"onUpdate:modelValue":l[2]||(l[2]=l=>e.value_=l),placeholder:"Variable value",disabled:e.loading,ref:"text",rows:"1"},null,8,p),[[i.Jo,e.value_]])]),(0,a.Lk)("div",k,[(0,a.Lk)("button",{type:"button",title:"Delete Variable",onClick:l[3]||(l[3]=(0,i.D$)((...e)=>y.showDeleteConfirm&&y.showDeleteConfirm(...e),["stop"])),disabled:e.loading},[...l[7]||(l[7]=[(0,a.Lk)("i",{class:"fas fa-trash"},null,-1)])],8,f),(0,a.Lk)("button",{type:"button",title:"Clear Value",onClick:l[4]||(l[4]=(0,i.D$)((...e)=>y.clearValue&&y.clearValue(...e),["stop"])),disabled:e.loading},[...l[8]||(l[8]=[(0,a.Lk)("i",{class:"fas fa-eraser"},null,-1)])],8,b),(0,a.Lk)("button",{type:"submit",title:"Save",disabled:e.loading},[...l[9]||(l[9]=[(0,a.Lk)("i",{class:"fas fa-check"},null,-1)])],8,m)])])],32)])])),(0,a.bF)($,{ref:"deleteConfirmDialog",onInput:y.deleteVariable},{default:(0,a.k6)(()=>[l[10]||(l[10]=(0,a.eW)(" Are you sure you want to delete this variable?",-1)),l[11]||(l[11]=(0,a.Lk)("br",null,null,-1)),l[12]||(l[12]=(0,a.Lk)("br",null,null,-1)),(0,a.Lk)("b",null,(0,s.v_)(e.value.name),1)]),_:1},8,["onInput"])])}var C=t(35128),y=t(14897),L=t(73818),$={name:"Variable",components:{ConfirmDialog:C.A,EntityIcon:L["default"]},mixins:[y["default"]],emits:["loading"],data:function(){return{collapsed:!0,value_:null}},computed:{isCollapsed(){return this.collapsed}},methods:{autoResizeTextarea(){const e=this.$refs.text;e&&(e.style.height="auto",e.style.height=Math.min(e.scrollHeight,300)+"px")},showDeleteConfirm(){this.$refs.deleteConfirmDialog.show()},async deleteVariable(){this.$emit("loading",!0);try{await this.request("entities.delete",[this.value.id]),this.$refs.deleteConfirmDialog?.close()}finally{this.$emit("loading",!1)}},async clearValue(){this.$emit("loading",!0);try{await this.request("variable.unset",{name:this.value.name})}finally{this.$emit("loading",!1)}},async setValue(){const e=this.value_;if(!e?.length)return await this.clearValue();this.$emit("loading",!0);try{const l={};l[this.value.name]=e,await this.request("variable.set",l)}finally{this.$emit("loading",!1)}}},mounted(){this.value_=this.value.value,this.$watch(()=>this.value.value,e=>{this.value_=e,this.$nextTick(()=>this.autoResizeTextarea())}),this.$watch(()=>this.value_,()=>{this.$nextTick(()=>this.autoResizeTextarea())}),this.$watch(()=>this.collapsed,e=>{e||this.$nextTick(()=>this.autoResizeTextarea())})}},w=t(66262);const x=(0,w.A)($,[["render",g],["__scopeId","data-v-90b595d2"]]);var D=x}}]);
//# sourceMappingURL=8203.0de0b2c9.js.map