import{T as a,U as u,H as c,a3 as p}from"./index-C5GbdPxY.js";import{u as f}from"./confirmDialog-CDDTmj30.js";function m(e,t=!1){return a.get(`/v1/tables/${e}`,{params:{return_all_translations:t}})}function b(e,t){return a.put(`/v1/tables/${e}`,t)}function g(e){return a.post("/v1/tables",e)}function v(e,t){return a.get("/v1/tables/form/meta",{params:{branch_id:e,floor_id:t}})}function d(){return a.get("/v1/tables/viewer")}function _(e){return a.get(`/v1/tables/viewer/${e}`)}function w(e,t){return a.patch(`/v1/tables/viewer/${e}/assign-waiter`,t)}function T(e){return a.patch(`/v1/tables/viewer/${e}/make-available`)}function h(e,t){return a.post(`/v1/tables/viewer/${e}/merge`,t)}function y(e){return a.post(`/v1/tables/viewer/${e}/split`)}function $(e){return a.get(`/v1/tables/viewer/${e}/merge/meta`)}function M(){const e=u(),{t}=c(),o=p({makeAvailable:!1,split:!1});return{getShowData:async(l,s=!1)=>{var r,n;try{return{status:200,data:(await m(l,s)).data.body}}catch(i){return((r=i==null?void 0:i.response)==null?void 0:r.status)!==404&&e.error(t("core::errors.an_unexpected_error_occurred")),{status:(n=i==null?void 0:i.response)==null?void 0:n.status}}},update:b,store:g,getFormMeta:v,getTableViewer:d,getTableViewerDetails:_,assignWaiter:w,updateStatusToAvailable:async l=>{var s,r;try{o.makeAvailable=!0,e.success((await T(l)).data.message)}catch(n){e.error(((r=(s=n.response)==null?void 0:s.data)==null?void 0:r.message)||t("core::errors.an_unexpected_error_occurred"))}finally{o.makeAvailable=!1}},loadings:o,getMergeMeta:$,splitTable:async l=>{var s,r;if(await f({title:t("seatingplan::tables.split_confirmation.title"),message:t("seatingplan::tables.split_confirmation.message"),confirmButtonText:t("seatingplan::tables.split_confirmation.confirm_button_text")}))try{return o.split=!0,e.success((await y(l)).data.message),!0}catch(n){e.error(((r=(s=n.response)==null?void 0:s.data)==null?void 0:r.message)||t("core::errors.an_unexpected_error_occurred"))}finally{o.split=!1}return!1},merge:h}}export{M as u};
