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