import{d as C,aa as w,w as x,i as N,j as t,aC as S,t as l,C as D,c as m,g as $,J as u,B as c,P as k,am as y,Q as B,e as V,aI as M}from"./index-DOFLUERq.js";import{L as I}from"./LinkField-CPzmuCgV.js";import{_ as L}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./iconify-p99pbjf9.js";const P={class:"dialog-content"},U={class:"form-field"},A={class:"field-label"},T=C({__name:"ChartDialog",props:{show:{type:Boolean},values:{}},emits:["update:show","submit"],setup(h,{emit:p}){const v=V(),o=h,d=p,f=w(),r=m({get:()=>o.show,set:a=>d("update:show",a)}),i=m(()=>!!o.values?.name),e=B({chart_name:"",label:"",name:""});x(()=>o.show,a=>{a&&(o.values?(e.chart_name=o.values.chart_name||"",e.label=o.values.label||"",e.name=o.values.name||""):(e.chart_name="",e.label="",e.name=""))},{immediate:!0});function b(){if(!e.chart_name)return f.error(l("Please select a chart")),!1;const a={...e,label:e.label||e.chart_name};return!i.value&&!a.name&&(a.name=`chart-${e.label||e.chart_name}-${Math.random().toString(36).substring(2,12)}`),d("submit",a),r.value=!1,!0}function g(){r.value=!1}function _(){r.value=!1;const a=M("Dashboard Chart"),s=Math.random().toString(36).substring(2,12),n=`new-${a}-${s}`;v.push(`/app/${a}/${n}`)}return(a,s)=>($(),N(t(S),{show:r.value,"onUpdate:show":s[2]||(s[2]=n=>r.value=n),preset:"dialog",title:i.value?t(l)("Edit Chart"):t(l)("Add Chart"),"positive-text":i.value?t(l)("Save"):t(l)("Add"),"negative-text":t(l)("Cancel"),onPositiveClick:b,onNegativeClick:g,style:{width:"500px"}},{default:D(()=>[u("div",P,[c(I,{modelValue:e.chart_name,"onUpdate:modelValue":s[0]||(s[0]=n=>e.chart_name=n),options:"Dashboard Chart",label:t(l)("Chart Name"),required:!0,placeholder:"","enable-create":!0,onCreate:_},null,8,["modelValue","label"]),u("div",U,[u("label",A,k(t(l)("Label")),1),c(t(y),{value:e.label,"onUpdate:value":s[1]||(s[1]=n=>e.label=n),placeholder:""},null,8,["value"])])])]),_:1},8,["show","title","positive-text","negative-text"]))}}),J=L(T,[["__scopeId","data-v-12699dd8"]]);export{J as default};
