import{Q as i}from"./format-BV5vqOBN.js";import{R as c,a5 as m,W as o,X as r,j as _,ab as V,U as a,T as u,Z as h,V as v,a9 as y,aa as g,a4 as p}from"./index-CRkL0E25.js";import{_ as k}from"./_plugin-vue_export-helper-DlAUqK2U.js";const b={name:"ComponentKeyValue",props:{modelValue:{type:Object},labelKey:{type:String,default(){return"key"}},labelValue:{type:String,default(){return"value"}},title:{type:String,default(){return"Title"}},help:{type:String}},emits:["update:modelValue"],computed:{value:{get(){return Object.entries(this.modelValue||{}).map(e=>({key:e[0],value:e[1]}))},set(e){this.$emit("update:modelValue",Object.fromEntries(e.map(s=>[s.key,s.value])))}}},methods:{addItem(){this.value.push({key:"",value:""}),this.changeModel()},removeItem(e){this.value=this.value.filter((s,t)=>t!=e)},changeModel(){this.$emit("update:modelValue",Object.fromEntries(this.value.map(e=>[e.key,e.value])))}}},q={class:"row"},B={class:"text-subtitle2 col-6 q-px-xs"},w={class:"col-6 q-px-xs"},C={class:"row border"},$={class:"col-5 col-sm-4 q-px-xs"},S={class:"col-5 col-sm-7 q-px-xs"},j={class:"col-2 col-sm-1 q-pt-sm"};function I(e,s,t,K,U,d){return c(),m("div",q,[o("div",B,r(e.$t(t.title)),1),o("div",w,[_(a(v,{flat:"",round:"",color:"warning",size:"sm",icon:"help_outline",class:"q-ml-sm float-right",onClick:s[0]||(s[0]=n=>e.$store.showHelp(e.$t(t.title),t.help))},{default:u(()=>[a(i,null,{default:u(()=>[h(r(e.$t("click_see_help")),1)]),_:1})]),_:1},512),[[V,t.help]]),a(v,{flat:"",round:"",color:"positive",size:"sm",icon:"add",class:"q-ml-sm float-right",onClick:d.addItem},{default:u(()=>[a(i,null,{default:u(()=>[h(r(e.$t("add")),1)]),_:1})]),_:1},8,["onClick"])]),(c(!0),m(y,null,g(d.value,(n,f)=>(c(),m("div",{class:"col-12",key:f},[o("div",C,[o("div",$,[a(p,{outlined:"",dense:"",modelValue:n.key,"onUpdate:modelValue":l=>n.key=l,label:e.$t(t.labelKey),rules:[l=>l&&l.length||e.$t("field_required")],onBlur:d.changeModel},null,8,["modelValue","onUpdate:modelValue","label","rules","onBlur"])]),o("div",S,[a(p,{outlined:"",dense:"",modelValue:n.value,"onUpdate:modelValue":l=>n.value=l,label:e.$t(t.labelValue),"lazy-rules":"",rules:[l=>l&&l.length||e.$t("field_required")],onBlur:d.changeModel},null,8,["modelValue","onUpdate:modelValue","label","rules","onBlur"])]),o("div",j,[a(v,{onClick:l=>d.removeItem(f),flat:"",round:"",color:"negative",size:"sm",icon:"remove",class:"float-left"},{default:u(()=>[a(i,null,{default:u(()=>[h(r(e.$t("remove")),1)]),_:1})]),_:1},8,["onClick"])])])]))),128))])}const Q=k(b,[["render",I]]);export{Q as K};
