var d=(m,p,r)=>new Promise((a,t)=>{var l=s=>{try{o(r.next(s))}catch(c){t(c)}},n=s=>{try{o(r.throw(s))}catch(c){t(c)}},o=s=>s.done?a(s.value):Promise.resolve(s.value).then(l,n);o((r=r.apply(m,p)).next())});import{bi as v,b6 as e,cH as u}from"./bootstrap-Bqxdt4iG.js";import{u as C}from"./useEntityForm-CMwp7TbN.js";import{u as w}from"./currencies-Bq32ahPb.js";import{S as N,s as S}from"./tms-services-Bd2kvCwx.js";import{a1 as _,L as x,aa as I,E as R,ap as q,aj as E,p as F,a9 as L}from"../jse/index-index-BUJ_4tQs.js";const O={class:"service-form"},A=_({__name:"service-form",props:{service:{default:null},mode:{}},emits:["cancel","submit"],setup(m,{expose:p,emit:r}){const a=m,t=r,l=w(),n=x([]);I(()=>d(null,null,function*(){n.value=yield l.fetchOptions()}));const o={code:"",description:"",salesPrice:0,currencyId:"",currency:N.MYR,estimatedCost:0,sst:0},s=R(()=>[{component:"Input",componentProps:{"data-testid":"service-form-code-input",id:"service-form-code-input",placeholder:e("page.tms.services.form.codePlaceholder"),maxlength:50},fieldName:"code",label:e("page.tms.services.form.code"),rules:v().min(1,e("page.tms.services.form.codeRequired"))},{component:"Textarea",componentProps:{"data-testid":"service-form-description-input",placeholder:e("page.tms.services.form.descriptionPlaceholder"),maxlength:500,autoSize:{minRows:2}},fieldName:"description",label:e("page.tms.services.form.description"),rules:v().min(1,e("page.tms.services.form.descriptionRequired"))},{component:"InputNumber",componentProps:{"data-testid":"service-form-price-input",placeholder:e("page.tms.services.form.pricePlaceholder"),min:0,precision:2,style:{width:"100%"}},fieldName:"salesPrice",label:e("page.tms.services.form.price"),rules:u().min(0,e("page.tms.services.form.priceRequired"))},{component:"Select",componentProps:{placeholder:e("page.tms.services.form.currencyPlaceholder"),options:n.value,showSearch:!0,filterOption:(i,f)=>f.label.toLowerCase().includes(i.toLowerCase())},fieldName:"currencyId",label:e("page.tms.services.form.currency"),rules:"selectRequired"},{component:"Select",componentProps:{"data-testid":"service-form-currency-select",options:S,placeholder:e("page.tms.services.form.currencyPlaceholder")},fieldName:"currency",label:`${e("page.tms.services.form.currency")} (Legacy)`,rules:"selectRequired"},{component:"InputNumber",componentProps:{placeholder:e("page.tms.services.form.estimatedCostPlaceholder"),min:0,precision:2,style:{width:"100%"}},fieldName:"estimatedCost",label:e("page.tms.services.form.estimatedCost"),rules:u().min(0)},{component:"InputNumber",componentProps:{"data-testid":"service-form-sst-input",placeholder:e("page.tms.services.form.sstPlaceholder"),min:0,max:100,precision:0,style:{width:"100%"},addonAfter:"%"},fieldName:"sst",label:e("page.tms.services.form.sst"),rules:u().min(0).max(100)}]),{Form:c,focus:h,isDirty:y,resetForm:g,submitForm:b,watchEntity:P}=C({emptyValues:o,firstInputId:"service-form-code-input",schema:s,wrapperClass:"grid-cols-1"});return P(()=>a.service,()=>a.mode),p({cancel:()=>{t("cancel")},focus:h,isDirty:y,resetForm:g,submit:()=>d(null,null,function*(){const i=yield b();i&&t("submit",i)})}),(i,f)=>(E(),q("div",O,[F(L(c))]))}});export{A as _};
