1import{_ as le}from"./C2a92Tni.js";import{_ as ie}from"./Sv7ZciDH.js";import{_ as re}from"./BZQy6ovt.js";import{_ as de}from"./D6rveY3N.js";import{f as ce,u as ue,c as me,r as pe,s as E,t as be,v as e,q as _e,x as c,y as i,z as r,F as C,A as I,B as m,C as n,D as d,G,E as f,H as h,I as x,J as N,K as F,M as fe,O as ve,i as ge}from"./D5MLA-hU.js";import{I as ke}from"./GRymhyKZ.js";import{I as he}from"./DlZaLOuR.js";import{I as xe}from"./d_9JiB03.js";import{I as ye}from"./CecOVL8Q.js";import{I as we}from"./CuOLYiG3.js";import{I as Ce}from"./wK2tYji8.js";import{u as Ie}from"./CbqWd3-v.js";import{u as De}from"./DtaMcMgl.js";import{u as Me}from"./DOZv0An5.js";import{u as Ve}from"./CflD_7cx.js";import"./3EBg3iUg.js";import"./B1_oImu8.js";import"./DxbuN_IJ.js";import"./D_rngVSp.js";import"./Buzkb953.js";import"./DzA_gxR7.js";import"./BdbZa608.js";import"./wgDUu9Q_.js";import"./DO7ZADv0.js";import"./pnh8EOCJ.js";import"./CTcA32qb.js";import"./GhFrNfLP.js";import"./DU6cNFPH.js";import"./Dv4Z5I8w.js";import"./D06dgW5T.js";import"./BnqRJifm.js";import"./B0pY3uqs.js";import"./B_CZSOLB.js";import"./CUlMz9Sl.js";import"./BLoYK7Cq.js";import"./DhOByWcj.js";import"./BZMDioPG.js";import"./CuyeCgjt.js";import"./B4f5qzlA.js";import"./BsSRCWlq.js";(function(){try{var b=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new b.Error().stack;o&&(b._sentryDebugIds=b._sentryDebugIds||{},b._sentryDebugIds[o]="736a49fe-be17-4abb-8634-4ef33bff6725",b._sentryDebugIdIdentifier="sentry-dbid-736a49fe-be17-4abb-8634-4ef33bff6725")}catch{}})();const Be={key:0,class:"space-y-4"},Te={key:1,class:"space-y-4"},je={class:"flex items-start justify-between gap-3"},Ge={class:"flex min-w-0 items-start gap-3"},Ne={class:"grid h-10 w-10 shrink-0 place-items-center rounded-xl bg-brand-50 text-brand-600"},Oe={class:"min-w-0"},Pe={class:"font-semibold text-ink-900"},Ue={class:"mt-0.5 text-xs text-slate-500"},Se={class:"flex shrink-0 gap-1"},$e=["aria-label","onClick"],Ae=["aria-label","onClick"],Ee=["onClick"],Fe={key:0,class:"rounded-2xl border border-dashed border-slate-200 bg-slate-50/60 px-6 py-12 text-center text-sm text-slate-500"},ze={key:1,class:"rounded-2xl border border-brand-100 bg-brand-50/30 p-5"},He={class:"font-semibold text-ink-900"},Le={class:"mt-4 space-y-3"},Re=["placeholder"],qe={class:"grid gap-3 sm:grid-cols-2"},Je={value:void 0},Ke=["value"],Qe=["disabled"],We={value:void 0},Xe=["value"],Ye={class:"text-xs text-slate-500"},Ze={class:"grid gap-3 sm:grid-cols-2"},et=["placeholder"],tt=["placeholder"],ot={key:0,class:"mt-3 text-xs text-red-600"},at={class:"mt-4 flex gap-2"},nt=["disabled"],y="w-full rounded-xl border border-slate-200 bg-white px-4 py-2.5 text-sm text-ink-900 placeholder:text-slate-400 transition-colors focus:border-brand-400 focus:outline-none focus:ring-2 focus:ring-brand-100",Rt=ce({__name:"perangkat",setup(b){const{t:o}=ue();Ie({title:o("perangkat.seoTitle"),description:o("perangkat.seoDesc"),robots:"noindex, nofollow"});const{gadgets:D,createGadget:z,updateGadget:H,deleteGadget:L}=De(),{fetchMe:R}=me(),{fetchModels:q}=Me(),{brands:J}=Ve(),_=c([]),M=c(!0),v=c(!1),p=c(""),u=c(null),l=ve({nickname:"",serial_no:"",color:"",brand_id:void 0,device_model_id:void 0}),g=c([]),w=c(!1);async function K(a){if(g.value=[],!!a){w.value=!0;try{g.value=await q({brandId:a})}catch{g.value=[]}finally{w.value=!1}}}async function O(a=!1){a||(l.device_model_id=void 0),await K(l.brand_id)}const V=a=>[a.brand?.name,a.model?.name].filter(Boolean).join(" ");async function Q(){if(M.value=!0,!await R()){await _e("/masuk");return}try{_.value=(await D()).data??[]}catch{}M.value=!1}pe(Q);function W(){Object.assign(l,{nickname:"",serial_no:"",color:"",brand_id:void 0,device_model_id:void 0}),g.value=[],u.value=0,p.value=""}async function X(a){Object.assign(l,{nickname:a.nickname||"",serial_no:a.serial_no||"",color:a.color||"",brand_id:a.brand?.id??void 0,device_model_id:a.model?.id??void 0}),u.value=a.id,p.value="",await O(!0)}function P(){u.value=null}async function Y(){if(!l.nickname.trim()&&!l.serial_no.trim()&&!l.device_model_id){p.value=o("perangkat.needName");return}if(!v.value){p.value="",v.value=!0;try{u.value&&u.value>0?await H(u.value,{...l}):await z({...l}),_.value=(await D()).data??[],P()}catch(a){const s=a;p.value=(s.data?.errors?Object.values(s.data.errors)[0]?.[0]:"")||s.data?.message||o("perangkat.saveFailed")}finally{v.value=!1}}}const k=c(null),B=c(!1),T=ge({get:()=>!!k.value,set:a=>{a||(k.value=null)}});function Z(a){k.value=a}async function ee(){const a=k.value;if(a){B.value=!0;try{await L(a.id),_.value=_.value.filter(s=>s.id!==a.id),k.value=null}catch{}finally{B.value=!1}}}const j=c(!1),U=c(),S=c(),$=c();function te(a){U.value=V(a)||a.nickname||"",S.value=a.model?.id??void 0,$.value=a.brand?.id??void 0,j.value=!0}return(a,s)=>{const oe=le,ae=ie,ne=re,se=de;return i(),E(se,{title:e(o)("perangkat.title"),subtitle:e(o)("perangkat.subtitle"),"back-label":e(o)("perangkat.back")},{default:be(()=>[e(M)?(i(),r("div",Be,[(i(),r(C,null,I(3,t=>m(oe,{key:t,class:"h-28 w-full rounded-2xl"})),64))])):(i(),r("div",Te,[(i(!0),r(C,null,I(e(_),t=>(i(),r("div",{key:t.id,class:"rounded-2xl border border-slate-100 bg-white p-5 shadow-sm ring-1 ring-black/[0.02]"},[n("div",je,[n("div",Ge,[n("span",Ne,[m(e(ke),{class:"h-5 w-5"})]),n("div",Oe,[n("p",Pe,d(t.nickname||V(t)||e(o)("perangkat.unnamed")),1),n("p",Ue,d([V(t),t.color,t.serial_no].filter(
1Boolean).join(" · ")||"-"),1)])]),n("div",Se,[n("button",{"aria-label":e(o)("perangkat.edit"),class:"grid h-8 w-8 place-items-center rounded-lg text-slate-400 transition-colors hover:bg-slate-100 hover:text-ink-900",onClick:A=>X(t)},[m(e(xe),{class:"h-4 w-4"})],8,$e),n("button",{"aria-label":e(o)("perangkat.delete"),class:"grid h-8 w-8 place-items-center rounded-lg text-slate-400 transition-colors hover:bg-red-50 hover:text-red-600",onClick:A=>Z(t)},[m(e(Ce),{class:"h-4 w-4"})],8,Ae)])]),t.model?.id?(i(),r("button",{key:0,type:"button",class:"mt-3 inline-flex items-center gap-1.5 rounded-full bg-brand-50 px-4 py-2 text-xs font-semibold text-brand-700 transition-colors hover:bg-brand-100",onClick:A=>te(t)},[m(e(we),{class:"h-3.5 w-3.5"}),G(" "+d(e(o)("perangkat.book")),1)],8,Ee)):f("",!0)]))),128)),!e(_).length&&e(u)===null?(i(),r("div",Fe,d(e(o)("perangkat.empty")),1)):f("",!0),e(u)!==null?(i(),r("div",ze,[n("h3",He,d(e(u)&&e(u)>0?e(o)("perangkat.editTitle"):e(o)("perangkat.addTitle")),1),n("div",Le,[h(n("input",{"onUpdate:modelValue":s[0]||(s[0]=t=>e(l).nickname=t),placeholder:e(o)("perangkat.nicknamePlaceholder"),class:x(y)},null,8,Re),[[N,e(l).nickname]]),n("div",qe,[h(n("select",{"onUpdate:modelValue":s[1]||(s[1]=t=>e(l).brand_id=t),class:x(y),onChange:s[2]||(s[2]=t=>O())},[n("option",Je,d(e(o)("perangkat.selectBrand")),1),(i(!0),r(C,null,I(e(J),t=>(i(),r("option",{key:t.beId,value:t.beId},d(t.name),9,Ke))),128))],544),[[F,e(l).brand_id,void 0,{number:!0}]]),h(n("select",{"onUpdate:modelValue":s[3]||(s[3]=t=>e(l).device_model_id=t),class:x(y),disabled:!e(l).brand_id||e(w)},[n("option",We,d(e(w)?e(o)("perangkat.loadingModels"):e(o)("perangkat.selectModel")),1),(i(!0),r(C,null,I(e(g),t=>(i(),r("option",{key:t.id,value:t.id},d(t.name),9,Xe))),128))],8,Qe),[[F,e(l).device_model_id,void 0,{number:!0}]])]),n("p",Ye,d(e(o)("perangkat.modelHint")),1),n("div",Ze,[h(n("input",{"onUpdate:modelValue":s[4]||(s[4]=t=>e(l).serial_no=t),placeholder:e(o)("perangkat.serialPlaceholder"),class:x(y)},null,8,et),[[N,e(l).serial_no]]),h(n("input",{"onUpdate:modelValue":s[5]||(s[5]=t=>e(l).color=t),placeholder:e(o)("perangkat.colorPlaceholder"),class:x(y)},null,8,tt),[[N,e(l).color]])])]),e(p)?(i(),r("p",ot,d(e(p)),1)):f("",!0),n("div",at,[n("button",{type:"button",disabled:e(v),class:"inline-flex items-center gap-2 rounded-full bg-brand-500 px-5 py-2.5 text-sm font-semibold text-white transition-colors hover:bg-brand-600 disabled:opacity-50",onClick:Y},[e(v)?(i(),E(e(he),{key:0,class:"h-4 w-4 animate-spin"})):f("",!0),G(" "+d(e(o)("perangkat.save")),1)],8,nt),n("button",{type:"button",class:"rounded-full border border-slate-200 px-5 py-2.5 text-sm font-semibold text-ink-700 transition-colors hover:bg-white",onClick:P},d(e(o)("perangkat.cancel")),1)])])):f("",!0),e(u)===null?(i(),r("button",{key:2,type:"button",class:"flex w-full items-center justify-center gap-2 rounded-2xl border border-dashed border-brand-200 py-4 text-sm font-semibold text-brand-600 transition-colors hover:bg-brand-50",onClick:W},[m(e(ye),{class:"h-5 w-5"}),G(" "+d(e(o)("perangkat.add")),1)])):f("",!0)])),m(ae,{open:e(j),device:e(U),"device-model-id":e(S),"brand-id":e($),onClose:s[6]||(s[6]=t=>j.value=!1)},null,8,["open","device","device-model-id","brand-id"]),m(ne,{modelValue:e(T),"onUpdate:modelValue":s[7]||(s[7]=t=>fe(T)?T.value=t:null),danger:"",title:e(o)("perangkat.deleteConfirm"),message:e(o)("perangkat.deleteMessage"),"confirm-label":e(o)("perangkat.delete"),"cancel-label":e(o)("perangkat.cancel"),loading:e(B),onConfirm:ee},null,8,["modelValue","title","message","confirm-label","cancel-label","loading"])]),_:1},8,["title","subtitle","back-label"])}}});export{Rt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.