import{d as R,ar as z,A as p,r as J,bn as s,bo as h,a9 as t,bq as o,br as i,bu as m,aa as b,by as x,bp as A}from"./preload-helper.BAt0wiQU.js";import{f as K,p as D}from"../apps/settings/index.CwVZreOu.js";import{I as O,A as P}from"./index.CaM6juwS.js";import{j as V,S as I}from"./index.BZuLeNql.js";import{A as Q}from"./index.CIPBl7_V.js";import{A as L}from"./index.C74CZaRi.js";const W=["innerHTML"],X=["innerHTML"],te=R({__name:"GroupEditFields",props:{editableData:{type:Object,required:!0},fieldValue:{type:[String,Number,Array,Object,Boolean],required:!0},fieldData:{type:Object,required:!0}},emits:["fieldUpdatedData"],setup(T,{emit:B}){var w;const H=T,{editableData:k,fieldValue:M,fieldData:S}=z(H),v=B,u=S.value,n=p((w=u.type)!=null?w:"").value,j=K(n,M.value),a=p(j),f=p(n==="select"?u.options:[]),r=p([]),y=J({check:a.value==="yes"}),q=p(n==="switch"?u.options.yes:""),N=p(n==="switch"?u.options.no:"");n==="select"&&u.multiple&&(a.value=k==null?void 0:k.value[u.id]);const E=()=>{r.value[u.id]=a.value,v("fieldUpdatedData",r.value)},F=d=>{r.value[u.id]=d.target.value,v("fieldUpdatedData",r.value)},g=()=>{r.value[u.id]=Math.abs(a.value),v("fieldUpdatedData",r.value)},C=()=>{r.value[u.id]=a.value+"%",v("fieldUpdatedData",r.value)},U=d=>{a.value=d;let l=f.value[d];Array.isArray(d)&&(l=d.map(e=>f.value[e])),r.value[u.id]=a.value,typeof u.label_id<"u"&&u.label_id!==null&&(r.value[u.label_id]=l),v("fieldUpdatedData",r.value)},G=d=>{a.value=d?"yes":"no",r.value[u.id]=a.value,y.check=d,v("fieldUpdatedData",r.value)};return(d,l)=>(s(),h(b,null,[t(n)==="text"||t(n)==="email"?(s(),o(t(O),{key:0,value:a.value,"onUpdate:value":l[0]||(l[0]=e=>a.value=e),onInput:E},null,8,["value"])):i("",!0),t(n)==="checkbox"?(s(),o(t(O),{key:1,value:a.value,"onUpdate:value":l[1]||(l[1]=e=>a.value=e),onInput:l[2]||(l[2]=e=>F(e))},null,8,["value"])):i("",!0),t(n)==="number"?(s(),o(t(L),{key:2,value:a.value,"onUpdate:value":l[3]||(l[3]=e=>a.value=e),onInput:g,onChange:g},null,8,["value"])):i("",!0),t(n)==="percent"?(s(),o(t(L),{key:3,value:a.value,"onUpdate:value":l[4]||(l[4]=e=>a.value=e),onInput:C,onChange:C},null,8,["value"])):i("",!0),t(n)==="textarea"?(s(),o(t(P),{key:4,value:a.value,"onUpdate:value":l[5]||(l[5]=e=>a.value=e),rows:4},null,8,["value"])):i("",!0),t(n)==="select"&&t(u).multiple?(s(),o(t(I),{key:5,ref:"select",value:a.value,"onUpdate:value":l[6]||(l[6]=e=>a.value=e),mode:"multiple",style:{"max-width":"320px",width:"100%"},onChange:U},{default:m(()=>[(s(!0),h(b,null,x(f.value,(e,c)=>(s(),o(t(V),{key:c,value:c},{default:m(()=>[A("span",{innerHTML:t(D)(e)},null,8,W)]),_:2},1032,["value"]))),128))]),_:1},8,["value"])):t(n)==="select"?(s(),o(t(I),{key:6,ref:"select",value:a.value,"onUpdate:value":l[7]||(l[7]=e=>a.value=e),style:{"max-width":"320px",width:"100%"},onChange:U},{default:m(()=>[(s(!0),h(b,null,x(f.value,(e,c)=>(s(),o(t(V),{key:c,value:c},{default:m(()=>[A("span",{innerHTML:t(D)(e)},null,8,X)]),_:2},1032,["value"]))),128))]),_:1},8,["value"])):i("",!0),t(n)==="switch"?(s(),o(t(Q),{key:7,checked:y.check,"onUpdate:checked":l[8]||(l[8]=e=>y.check=e),"checked-children":q.value,"un-checked-children":N.value,onChange:l[9]||(l[9]=e=>G(e))},null,8,["checked","checked-children","un-checked-children"])):i("",!0)],64))}});export{te as _};
