import{ch as Q,r as n,b as W,u as X,d as O,G as Y,ci as Z,bu as ee,al as S,c as T,aC as E,bd as P,aN as ae}from"./app-DGDivIsO.js";import{d as te}from"./datatable-Cnt5bvOi.js";var se=Object.prototype,ne=se.hasOwnProperty;function oe(o,d){return o!=null&&ne.call(o,d)}function le(o,d){return o!=null&&Q(o,d,oe)}const ue=()=>{const{table:o,tableUrl:d,hashable:A,currentPage:u,handleTableChange:R,fetch:h,onTableSearch:V,onRowSelectChange:_,exportDetails:I}=te(),f=n(!1),i=n({}),r=n(""),s=n(""),g=n({}),b=n([]),x=n({}),m=n(!1),c=n("add"),$=n(""),v=n({}),{t:a}=W(),M=X(),N=e=>{f.value=!0,i.value=e},U=()=>{$.value=r.value,c.value="add",m.value=!0,i.value={}},j=()=>{w(),m.value=!1},y=()=>{f.value=!1,i.value={}},F=e=>{const t={};var p=x.value;Object.keys(g.value).forEach(l=>{if(le(p,l)){const L=p[l];t[l]=Z(e,L)}else ee(b.value,l)?t[l]=e[`x_${l}`]:t[l]=e[l]}),t._method="PUT",v.value=t,i.value=e,$.value=`${r.value}/${e.xid}`,c.value="edit",m.value=!0},C=()=>{M.dispatch("auth/updateVisibleSubscriptionModules")},K=e=>{D(e,"add-edit")},G=e=>{D(e,"add-new")},H=e=>{D(e,"add-continue")},D=(e,t="add-edit")=>{if(c.value=="add"){const p={...o.pagination};p.current=1,u.value=1,o.pagination=p}C(),(t=="add-edit"||t=="add-new")&&w(),h({page:c.value=="add"?1:u.value,limit:10}),t=="add-edit"&&(m.value=!1)},k=e=>{S.confirm({title:a("common.delete")+"?",icon:T(E),content:a(`${s.value}.delete_message`),centered:!0,okText:a("common.yes"),okType:"danger",cancelText:a("common.no"),onOk(){return axiosAdmin.delete(`${r.value}/${e}`).then(t=>{C(),h({page:u.value}),P.success({message:a("common.success"),description:a(`${s.value}.deleted`),placement:"bottomRight"})}).catch(()=>{})},onCancel(){}})},q=()=>{S.confirm({title:a("common.delete")+"?",icon:T(E),content:a(`${s.value}.selected_delete_message`),centered:!0,okText:a("common.yes"),okType:"danger",cancelText:a("common.no"),onOk(){const e=[];ae(o.selectedRowKeys,t=>{e.push(axiosAdmin.delete(`${r.value}/${t}`))}),Promise.all(e).then(t=>{C(),h({page:u.value}),P.success({message:a("common.success"),description:a(`${s.value}.deleted`),placement:"bottomRight"})})},onCancel(){}})},w=()=>{v.value={...g.value}},z=e=>{v.value={...v.value,...e}},B=O(()=>s.value!=""?c.value=="add"?a(`${s.value}.add`):a(`${s.value}.edit`):""),J=O(()=>s.value!=""?c.value=="add"?a(`${s.value}.created`):a(`${s.value}.updated`):"");return Y(b,(e,t)=>{A.value=e}),{detailsVisible:f,viewData:i,onCloseDetails:y,addEditVisible:m,addEditType:c,addEditUrl:$,currentPage:u,formData:v,initData:g,crudUrl:r,langKey:s,hashableColumns:b,multiDimensalObjectColumns:x,pageTitle:B,successMessage:J,viewItem:N,addItem:U,editItem:F,onCloseAddEdit:j,showDeleteConfirm:k,addEditSuccess:K,addAndNewSuccess:G,addAndContinueSuccess:H,restFormData:w,assignNewFormData:z,showSelectedDeleteConfirm:q,table:o,tableUrl:d,handleTableChange:R,fetch:h,onTableSearch:V,onRowSelectChange:_,exportDetails:I}};export{ue as c};
