import{I as g}from"./iconify-p99pbjf9.js";import{d as q,aa as I,w as $,i as z,j as e,aC as A,t as s,C as u,c as y,g as v,J as n,P as d,B as i,am as k,_ as w,aO as E,A as h,L as R,au as F,an as C,K as J,O as M,Q}from"./index-DOFLUERq.js";import{L as j}from"./LinkField-CPzmuCgV.js";import{_ as K}from"./_plugin-vue_export-helper-DlAUqK2U.js";const Y={class:"dialog-content"},G={class:"form-field"},H={class:"field-label"},W={class:"form-field"},X={class:"field-label"},Z={class:"links-table"},ee={class:"table-header"},ae={class:"col-type"},le={class:"col-link"},te={class:"col-label"},se={class:"col-type"},ne={class:"col-link"},oe={class:"col-label"},ie={class:"col-actions"},re={key:0,class:"empty-row"},de=q({__name:"CardDialog",props:{show:{type:Boolean},values:{}},emits:["update:show","submit"],setup(L,{emit:T}){const r=L,b=T,m=I(),p=y({get:()=>r.show,set:l=>b("update:show",l)}),_=y(()=>!!r.values?.name),P=[{label:"PageType",value:"PageType"},{label:"Page",value:"Page"},{label:"Report",value:"Report"}],a=Q({label:"",description:"",links:[],name:""});function N(l){switch(l){case"PageType":return"PageType";case"Page":return"Page";case"Report":return"Report";default:return"PageType"}}function x(l){return l==="PageType"?{filters:{istable:0}}:{}}function U(l){a.links[l].link_to=""}function S(){a.links.push({link_type:"PageType",link_to:"",label:""})}function V(l){a.links.splice(l,1)}function B(l){if(!l)return[];if(typeof l=="string")try{return JSON.parse(l)}catch{return[]}return l}$(()=>r.show,l=>{l&&(r.values?(a.label=r.values.label||"",a.description=r.values.description||"",a.links=B(r.values.links),a.name=r.values.name||""):(a.label="",a.description="",a.links=[],a.name=""))},{immediate:!0});function D(){if(a.links.length===0)return m.error(s("You must add at least one link")),!1;for(let o=0;o<a.links.length;o++){const t=a.links[o];if(!t.link_type)return m.error(s("Link Type is required in row")+` ${o+1}`),!1;if(!t.link_to)return m.error(s("Link To is required in row")+` ${o+1}`),!1;t.label||(t.label=t.link_to)}const l={label:a.label,description:a.description,links:JSON.stringify(a.links),name:a.name};return!_.value&&!l.name&&(l.name=`card-${a.label||"card"}-${Math.random().toString(36).substring(2,12)}`),b("submit",l),p.value=!1,!0}function O(){p.value=!1}return(l,o)=>(v(),z(e(A),{show:p.value,"onUpdate:show":o[2]||(o[2]=t=>p.value=t),preset:"dialog",title:_.value?e(s)("Edit Card"):e(s)("Add Card"),"positive-text":_.value?e(s)("Save"):e(s)("Add"),"negative-text":e(s)("Cancel"),onPositiveClick:D,onNegativeClick:O,style:{width:"800px"}},{default:u(()=>[n("div",Y,[n("div",G,[n("label",H,d(e(s)("Label")),1),i(e(k),{value:a.label,"onUpdate:value":o[0]||(o[0]=t=>a.label=t),placeholder:e(s)("Enter card label")},null,8,["value","placeholder"])]),n("div",W,[n("label",X,d(e(s)("Description")),1),i(e(k),{value:a.description,"onUpdate:value":o[1]||(o[1]=t=>a.description=t),type:"textarea",rows:3,placeholder:e(s)("Enter description (optional)")},null,8,["value","placeholder"])]),i(e(E),null,{default:u(()=>[w(d(e(s)("Card Links")),1)]),_:1}),n("div",Z,[n("div",ee,[n("span",ae,d(e(s)("Link Type")),1),n("span",le,d(e(s)("Link To")),1),n("span",te,d(e(s)("Label")),1),o[3]||(o[3]=n("span",{class:"col-actions"},null,-1))]),(v(!0),h(J,null,R(a.links,(t,f)=>(v(),h("div",{key:f,class:"table-row"},[n("div",se,[i(e(F),{value:t.link_type,"onUpdate:value":[c=>t.link_type=c,()=>U(f)],options:P,size:"small"},null,8,["value","onUpdate:value"])]),n("div",ne,[i(j,{modelValue:t.link_to,"onUpdate:modelValue":c=>t.link_to=c,options:N(t.link_type),placeholder:e(s)("Select"),"get-query":()=>x(t.link_type)},null,8,["modelValue","onUpdate:modelValue","options","placeholder","get-query"])]),n("div",oe,[i(e(k),{value:t.label,"onUpdate:value":c=>t.label=c,size:"small",placeholder:e(s)("Label")},null,8,["value","onUpdate:value","placeholder"])]),n("div",ie,[i(e(C),{size:"small",quaternary:"",type:"error",onClick:c=>V(f)},{icon:u(()=>[i(e(g),{icon:"mdi:close"})]),_:1},8,["onClick"])])]))),128)),a.links.length===0?(v(),h("div",re,d(e(s)("No Items Found")),1)):M("",!0),i(e(C),{class:"add-link-btn",size:"small",dashed:"",onClick:S},{icon:u(()=>[i(e(g),{icon:"mdi:plus"})]),default:u(()=>[w(" "+d(e(s)("Add")),1)]),_:1})])])]),_:1},8,["show","title","positive-text","negative-text"]))}}),me=K(de,[["__scopeId","data-v-ac78745c"]]);export{me as default};
