import{d as S,j as $,s as U,m as p,T as x,r as D,c as d,o as i,a as e,b as r,t as a,F as _,g as E,n as A,u as n,w as F,_ as I}from"./app-Do7K7VDV.js";import{_ as N}from"./Paginate-BZTS8QtF.js";import{_ as T}from"./NoDataFound-oJx-Mfyi.js";import{S as f}from"./SelectField-DAcqRSwh.js";import{_ as b}from"./InputField-CxqwqE0d.js";import{_ as j}from"./AdminLayout-DeT_GLTC.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./AssetModal-C18ToIEK.js";import"./InputFieldError-0BmYlL24.js";import"./ToastrContainer-CtYDvNPN.js";const B={class:"table"},M={class:"!text-right"},P={key:0},z={class:"text-end"},L={class:"dropdown dropdown-end","data-placement":"bottom-start"},q={class:"dropdown-toggle btn btn-square btn-ghost",type:"button"},O={class:"dropdown-content w-40"},R={class:"dropdown-list"},G={class:"dropdown-list-item"},H=["onClick"],J={class:"dropdown-list-item"},K=["onClick"],Q={key:1},W={colspan:"7",class:"py-4 text-center"},X={class:"space-y-2"},Y=S({layout:j}),ie=Object.assign(Y,{__name:"Index",props:["models","providers"],setup(u){const c=$(),{deleteRow:k}=U(),g=u,v=p(()=>!!t.id),w=o=>{t.id=o.id,t.provider=o.provider,t.name=o.name,t.code=o.code,t.max_token=o.max_token,t.status=o.status,c.open("createModal")},h=p(()=>g.models.data),V=p(()=>h.value.length>0),t=x({id:"",provider:"",name:"",code:"",max_token:0,status:"active"}),y=()=>{if(t.id){t.put(route("admin.ai-models.update",t.id),{onSuccess:()=>{t.reset(),c.close("createModal")}});return}t.post(route("admin.ai-models.store"),{onSuccess:()=>{t.reset(),c.close("createModal")}})};return(o,l)=>{const m=D("Icon");return i(),d(_,null,[e("table",B,[e("thead",null,[e("tr",null,[e("th",null,a(o.trans("Provider")),1),e("th",null,a(o.trans("Name")),1),e("th",null,a(o.trans("Model")),1),e("th",null,a(o.trans("Max Token")),1),e("th",null,a(o.trans("Status")),1),e("th",null,a(o.trans("Created At")),1),e("th",M,a(o.trans("Action")),1)])]),V.value?(i(),d("tbody",P,[(i(!0),d(_,null,E(h.value,s=>(i(),d("tr",{key:s.id},[e("td",null,a(s.provider),1),e("td",null,a(s.name),1),e("td",null,a(s.code),1),e("td",null,a(s.max_token),1),e("td",null,[e("span",{class:A(["inline-block rounded-full px-2 py-1 text-xs font-semibold leading-none",s.status=="active"?"bg-green-100 text-green-800":"bg-red-100 text-red-800"])},a(s.status=="active"?o.trans("Active"):o.trans("Inactive")),3)]),e("td",null,a(new Date(s.created_at).toLocaleDateString()),1),e("td",z,[e("div",L,[e("button",q,[r(m,{class:"h-5 w-5",icon:"bx:dots-horizontal-rounded"})]),e("div",O,[e("ul",R,[e("li",G,[e("a",{href:"javascript:void(0)",class:"dropdown-link",onClick:C=>w(s)},[r(m,{class:"h-5 w-5",icon:"fe:edit"}),e("span",null,a(o.trans("Edit")),1)],8,H)]),e("li",J,[e("button",{type:"button",class:"dropdown-link",onClick:C=>n(k)(o.route("admin.ai-models.destroy",s))},[r(m,{class:"h-5 w-5",icon:"fe:trash"}),e("span",null,a(o.trans("Delete")),1)],8,K)])])])])])]))),128))])):(i(),d("tbody",Q,[e("tr",null,[e("td",W,[r(T,{forTable:!0})])])]))]),r(N,{links:u.models.links},null,8,["links"]),r(I,{state:"createModal","header-state":!0,"header-title":v.value?o.trans("Edit Model"):o.trans("Create Model"),"action-btn-state":!0,"action-btn-text":v.value?"Update":"Create","action-processing":n(t).processing,onAction:y,onClose:l[5]||(l[5]=s=>n(t).reset())},{default:F(()=>[e("div",X,[r(f,{label:"Provider",modelValue:n(t).provider,"onUpdate:modelValue":l[0]||(l[0]=s=>n(t).provider=s),options:u.providers,placeholder:o.trans("Select Provider"),error:n(t).errors.provider},null,8,["modelValue","options","placeholder","error"]),r(b,{modelValue:n(t).name,"onUpdate:modelValue":l[1]||(l[1]=s=>n(t).name=s),label:o.trans("Name"),error:n(t).errors.name},null,8,["modelValue","label","error"]),r(b,{modelValue:n(t).code,"onUpdate:modelValue":l[2]||(l[2]=s=>n(t).code=s),label:o.trans("Model"),error:n(t).errors.code},null,8,["modelValue","label","error"]),r(b,{modelValue:n(t).max_token,"onUpdate:modelValue":l[3]||(l[3]=s=>n(t).max_token=s),label:o.trans("Max Token"),error:n(t).errors.max_token},null,8,["modelValue","label","error"]),r(f,{label:"Status",modelValue:n(t).status,"onUpdate:modelValue":l[4]||(l[4]=s=>n(t).status=s),options:["active","inactive"],placeholder:o.trans("Select Status"),error:n(t).errors.status},null,8,["modelValue","placeholder","error"])])]),_:1},8,["header-title","action-btn-text","action-processing"])],64)}}});export{ie as default};
