import{s as S,l as D,T as $,m as p,h as j,c as b,b as e,a as o,t as n,u as s,F as h,r as V,i as B,e as F,w as f,d as g,v,g as L,o as c,p as t,q as w,O as q}from"./app-13978987.js";import{_ as E}from"./AdminLayout-bd13ff9d.js";import{_ as I}from"./PageHeader-8c638686.js";import{d as u}from"./drawer-fe4c5e1a.js";import{_ as y}from"./SpinnerBtn-cb152833.js";import{_ as M}from"./NoDataFound-bc81d7fa.js";import"./dropdown-45d66330.js";const O={class:"container flex-grow p-4 sm:p-6"},A={class:"space-y-6"},T={class:"table-responsive whitespace-nowrap rounded-primary"},U={class:"table"},P={class:"col-2"},R={class:"flex justify-end"},z={class:"text-left"},G={class:"flex justify-end gap-3"},H=["onClick"],J=["onClick"],K={id:"addNewCurrencyDrawer",class:"drawer drawer-right"},Q={class:"drawer-header"},W={type:"button",class:"btn btn-plain-secondary dark:text-slate-300 dark:hover:bg-slate-700 dark:focus:bg-slate-700","data-dismiss":"drawer"},X={class:"drawer-body"},Y={class:"mb-2"},Z={class:"drawer-footer"},ee={class:"flex justify-between gap-2"},se={type:"button",class:"btn btn-secondary w-full","data-dismiss":"drawer"},te={id:"editCurrencyDrawer",class:"drawer drawer-right"},ae={class:"drawer-header"},ne={type:"button",class:"btn btn-plain-secondary dark:text-slate-300 dark:hover:bg-slate-700 dark:focus:bg-slate-700","data-dismiss":"drawer"},oe={class:"drawer-body"},re={class:"mb-2"},le={class:"label mb-2"},de={class:"drawer-footer"},ie={class:"flex justify-between gap-2"},ce={type:"button",class:"btn btn-secondary w-full","data-dismiss":"drawer"},ue=L({layout:E}),we=Object.assign(ue,{__name:"Index",props:["languages","buttons","segments"],setup(m){const{deleteRow:x}=S();D(()=>{u.init()});const d=$({name:""}),r=p({}),_=p(!1),C=()=>{d.post(route("admin.ai-language.store"),{preserveScroll:!0,onSuccess:()=>{d.reset(),w.success(t("Language has been added successfully")),u.of("#addNewCurrencyDrawer").hide()}})},k=()=>{_.value=!0,q.patch(route("admin.ai-language.update",r.value.id),r.value,{preserveScroll:!0,onSuccess:()=>{r.value={},w.success(t("Language has been updated successfully")),u.of("#editCurrencyDrawer").hide()},onFinish:()=>_.value=!1})};return(N,l)=>{const i=j("Icon");return c(),b(h,null,[e("main",O,[o(I,{title:"Create a Language",buttons:m.buttons},null,8,["buttons"]),e("div",A,[e("div",T,[e("table",U,[e("thead",null,[e("tr",null,[e("th",P,n(s(t)("Name")),1),e("th",R,n(s(t)("Action")),1)])]),e("tbody",null,[(c(!0),b(h,null,V(m.languages,a=>(c(),b("tr",{key:a.code},[e("td",z,n(a.name),1),e("td",G,[e("button",{type:"button",class:"btn btn-dark",onClick:()=>{r.value={...a},s(u).of("#editCurrencyDrawer").show()}},[o(i,{icon:"fe:edit"})],8,H),e("button",{type:"button",class:"btn btn-danger",onClick:me=>s(x)(N.route("admin.ai-language.destroy",a.id))},[o(i,{icon:"fe:trash"})],8,J)])]))),128))]),m.languages.length<1?(c(),B(M,{key:0,"for-table":"true"})):F("",!0)])])])]),e("div",K,[e("form",{onSubmit:l[1]||(l[1]=f(a=>C(),["prevent"]))},[e("div",Q,[e("h5",null,n(s(t)("Add New language")),1),e("button",W,[o(i,{class:"text-xl",icon:"mdi:close"})])]),e("div",X,[e("div",Y,[e("label",null,n(s(t)("Name")),1),g(e("input",{"onUpdate:modelValue":l[0]||(l[0]=a=>s(d).name=a),type:"text",name:"name",class:"input",required:"",placeholder:"English"},null,512),[[v,s(d).name]])])]),e("div",Z,[e("div",ee,[e("button",se,[e("span",null,n(s(t)("Close")),1)]),o(y,{classes:"btn w-full btn-primary",processing:s(d).processing,"btn-text":s(t)("Create")},null,8,["processing","btn-text"])])])],32)]),e("div",te,[e("form",{onSubmit:f(k,["prevent"])},[e("div",ae,[e("h5",null,n(s(t)("Edit language")),1),e("button",ne,[o(i,{class:"text-xl",icon:"mdi:close"})])]),e("div",oe,[e("div",re,[e("label",le,n(s(t)("Name")),1),g(e("input",{"onUpdate:modelValue":l[2]||(l[2]=a=>r.value.name=a),type:"text",name:"name",class:"input",required:""},null,512),[[v,r.value.name]])])]),e("div",de,[e("div",ie,[e("button",ce,[e("span",null,n(s(t)("Close")),1)]),o(y,{processing:_.value,classes:"btn w-full btn-primary","btn-text":s(t)("Save Changes")},null,8,["processing","btn-text"])])])],32)])],64)}}});export{we as default};
