import {r as f, u as Gt, ad as X, f as K, O as _, j as e, aD as lt, aF as Mt, b3 as Et, b4 as Zt, ac as D, a1 as he, a2 as E, e as N, X as Z, a3 as q, a4 as $, a5 as ut, a6 as ge, as as cn, a7 as U, t as Q, b5 as dn, b6 as Ee, b7 as rt, b8 as un, ai as ue, x as ye, b9 as st, aM as ht, ba as W, bb as _e, bc as za, bd as Re, be as hn, B as Y, bf as gn, bg as La, bh as Ua, bi as Dt, I as mn, bj as Oa, bk as pn, bl as It, bm as $a, S as fn, G as De, z as qe, D as Va, y as Ha, F as Rt, w as ke, bn as Fa, bo as en, aa as xn, bp as de, aO as Ka, bq as _a, n as A, br as we, bs as Qe, V as At, bt as qa, aj as bn, bu as Cn, bv as vn, bw as Nt, i as jn, bx as Qa, C as Ne, by as Xa, bz as Ja, bA as Ya, bB as Ga, W as Za, bC as eo, bD as to, bE as no, bF as ao, bG as oo, bH as so, av as ro, bI as Bt, bJ as io, bK as tn, bL as Wt, ay as lo, $ as co, s as uo, bM as ho, bN as go, c as mo} from "./index-CdMy-Rhi.js"; import {u as it, I as po} from "./IconPlayerPause-CiILB2ws.js"; function fo(t, n="use-local-storage") { try { return JSON.stringify(t) } catch { throw new Error(`@mantine/hooks ${n}: Failed to serialize the value`) } } function xo(t) { try { return t && JSON.parse(t) } catch { return t } } function bo(t) { return { getItem: r => { try { return window[t].getItem(r) } catch { return console.warn("use-local-storage: Failed to get value from storage, localStorage is blocked"), null } } , setItem: (r, l) => { try { window[t].setItem(r, l) } catch { console.warn("use-local-storage: Failed to set value to storage, localStorage is blocked") } } , removeItem: r => { try { window[t].removeItem(r) } catch { console.warn("use-local-storage: Failed to remove value from storage, localStorage is blocked") } } } } function Co(t, n) { const a = "mantine-local-storage" , {getItem: o, setItem: r, removeItem: l} = bo(t); return function({key: s, defaultValue: d, getInitialValueInEffect: g=!0, deserialize: c=xo, serialize: u=h => fo(h, n)}) { const h = f.useCallback(p => { let v; try { v = typeof window > "u" || !(t in window) || window[t] === null || !!p } catch { v = !0 } if (v) return d; const k = o(s); return k !== null ? c(k) : d } , [s, d]) , [m,b] = f.useState(h(g)) , P = f.useCallback(p => { p instanceof Function ? b(v => { const k = p(v); return r(s, u(k)), window.dispatchEvent(new CustomEvent(a,{ detail: { key: s, value: p(v) } })), k } ) : (r(s, u(p)), window.dispatchEvent(new CustomEvent(a,{ detail: { key: s, value: p } })), b(p)) } , [s]) , T = f.useCallback( () => { l(s), window.dispatchEvent(new CustomEvent(a,{ detail: { key: s, value: d } })) } , []); return Gt("storage", p => { p.storageArea === window[t] && p.key === s && b(c(p.newValue ?? void 0)) } ), Gt(a, p => { p.detail.key === s && b(p.detail.value) } ), f.useEffect( () => { d !== void 0 && m === void 0 && P(d) } , [d, m, P]), f.useEffect( () => { const p = h(); p !== void 0 && P(p) } , []), [m === void 0 ? d : m, P, T] } } function Pt(t) { return Co("localStorage", "use-local-storage")(t) } /** * @license @tabler/icons-react v3.21.0 - MIT * * This source code is licensed under the MIT license. * See the LICENSE file in the root directory of this source tree. */ var vo = X("outline", "briefcase", "IconBriefcase", [["path", { d: "M3 7m0 2a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v9a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2z", key: "svg-0" }], ["path", { d: "M8 7v-2a2 2 0 0 1 2 -2h4a2 2 0 0 1 2 2v2", key: "svg-1" }], ["path", { d: "M12 12l0 .01", key: "svg-2" }], ["path", { d: "M3 13a20 20 0 0 0 18 0", key: "svg-3" }]]); /** * @license @tabler/icons-react v3.21.0 - MIT * * This source code is licensed under the MIT license. * See the LICENSE file in the root directory of this source tree. */ var jo = X("outline", "building", "IconBuilding", [["path", { d: "M3 21l18 0", key: "svg-0" }], ["path", { d: "M9 8l1 0", key: "svg-1" }], ["path", { d: "M9 12l1 0", key: "svg-2" }], ["path", { d: "M9 16l1 0", key: "svg-3" }], ["path", { d: "M14 8l1 0", key: "svg-4" }], ["path", { d: "M14 12l1 0", key: "svg-5" }], ["path", { d: "M14 16l1 0", key: "svg-6" }], ["path", { d: "M5 21v-16a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v16", key: "svg-7" }]]); /** * @license @tabler/icons-react v3.21.0 - MIT * * This source code is licensed under the MIT license. * See the LICENSE file in the root directory of this source tree. */ var ko = X("outline", "buildings", "IconBuildings", [["path", { d: "M4 21v-15c0 -1 1 -2 2 -2h5c1 0 2 1 2 2v15", key: "svg-0" }], ["path", { d: "M16 8h2c1 0 2 1 2 2v11", key: "svg-1" }], ["path", { d: "M3 21h18", key: "svg-2" }], ["path", { d: "M10 12v0", key: "svg-3" }], ["path", { d: "M10 16v0", key: "svg-4" }], ["path", { d: "M10 8v0", key: "svg-5" }], ["path", { d: "M7 12v0", key: "svg-6" }], ["path", { d: "M7 16v0", key: "svg-7" }], ["path", { d: "M7 8v0", key: "svg-8" }], ["path", { d: "M17 12v0", key: "svg-9" }], ["path", { d: "M17 16v0", key: "svg-10" }]]); /** * @license @tabler/icons-react v3.21.0 - MIT * * This source code is licensed under the MIT license. * See the LICENSE file in the root directory of this source tree. */ var yo = X("outline", "businessplan", "IconBusinessplan", [["path", { d: "M16 6m-5 0a5 3 0 1 0 10 0a5 3 0 1 0 -10 0", key: "svg-0" }], ["path", { d: "M11 6v4c0 1.657 2.239 3 5 3s5 -1.343 5 -3v-4", key: "svg-1" }], ["path", { d: "M11 10v4c0 1.657 2.239 3 5 3s5 -1.343 5 -3v-4", key: "svg-2" }], ["path", { d: "M11 14v4c0 1.657 2.239 3 5 3s5 -1.343 5 -3v-4", key: "svg-3" }], ["path", { d: "M7 9h-2.5a1.5 1.5 0 0 0 0 3h1a1.5 1.5 0 0 1 0 3h-2.5", key: "svg-4" }], ["path", { d: "M5 15v1m0 -8v1", key: "svg-5" }]]); /** * @license @tabler/icons-react v3.21.0 - MIT * * This source code is licensed under the MIT license. * See the LICENSE file in the root directory of this source tree. */ var wo = X("outline", "calendar-event", "IconCalendarEvent", [["path", { d: "M4 5m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z", key: "svg-0" }], ["path", { d: "M16 3l0 4", key: "svg-1" }], ["path", { d: "M8 3l0 4", key: "svg-2" }], ["path", { d: "M4 11l16 0", key: "svg-3" }], ["path", { d: "M8 15h2v2h-2z", key: "svg-4" }]]); /** * @license @tabler/icons-react v3.21.0 - MIT * * This source code is licensed under the MIT license. * See the LICENSE file in the root directory of this source tree. */ var So = X("outline", "coins", "IconCoins", [["path", { d: "M9 14c0 1.657 2.686 3 6 3s6 -1.343 6 -3s-2.686 -3 -6 -3s-6 1.343 -6 3z", key: "svg-0" }], ["path", { d: "M9 14v4c0 1.656 2.686 3 6 3s6 -1.344 6 -3v-4", key: "svg-1" }], ["path", { d: "M3 6c0 1.072 1.144 2.062 3 2.598s4.144 .536 6 0c1.856 -.536 3 -1.526 3 -2.598c0 -1.072 -1.144 -2.062 -3 -2.598s-4.144 -.536 -6 0c-1.856 .536 -3 1.526 -3 2.598z", key: "svg-2" }], ["path", { d: "M3 6v10c0 .888 .772 1.45 2 2", key: "svg-3" }], ["path", { d: "M3 11c0 .888 .772 1.45 2 2", key: "svg-4" }]]); /** * @license @tabler/icons-react v3.21.0 - MIT * * This source code is licensed under the MIT license. * See the LICENSE file in the root directory of this source tree. */ var Po = X("outline", "currency-dollar", "IconCurrencyDollar", [["path", { d: "M16.7 8a3 3 0 0 0 -2.7 -2h-4a3 3 0 0 0 0 6h4a3 3 0 0 1 0 6h-4a3 3 0 0 1 -2.7 -2", key: "svg-0" }], ["path", { d: "M12 3v3m0 12v3", key: "svg-1" }]]); /** * @license @tabler/icons-react v3.21.0 - MIT * * This source code is licensed under the MIT license. * See the LICENSE file in the root directory of this source tree. */ var To = X("outline", "history", "IconHistory", [["path", { d: "M12 8l0 4l2 2", key: "svg-0" }], ["path", { d: "M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5", key: "svg-1" }]]); /** * @license @tabler/icons-react v3.21.0 - MIT * * This source code is licensed under the MIT license. * See the LICENSE file in the root directory of this source tree. */ var Mo = X("outline", "player-play", "IconPlayerPlay", [["path", { d: "M7 4v16l13 -8z", key: "svg-0" }]]); /** * @license @tabler/icons-react v3.21.0 - MIT * * This source code is licensed under the MIT license. * See the LICENSE file in the root directory of this source tree. */ var Io = X("outline", "playlist-add", "IconPlaylistAdd", [["path", { d: "M19 8h-14", key: "svg-0" }], ["path", { d: "M5 12h9", key: "svg-1" }], ["path", { d: "M11 16h-6", key: "svg-2" }], ["path", { d: "M15 16h6", key: "svg-3" }], ["path", { d: "M18 13v6", key: "svg-4" }]]); /** * @license @tabler/icons-react v3.21.0 - MIT * * This source code is licensed under the MIT license. * See the LICENSE file in the root directory of this source tree. */ var Ro = X("outline", "sitemap", "IconSitemap", [["path", { d: "M3 15m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2z", key: "svg-0" }], ["path", { d: "M15 15m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2z", key: "svg-1" }], ["path", { d: "M9 3m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2z", key: "svg-2" }], ["path", { d: "M6 15v-1a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v1", key: "svg-3" }], ["path", { d: "M12 9l0 3", key: "svg-4" }]]); /** * @license @tabler/icons-react v3.21.0 - MIT * * This source code is licensed under the MIT license. * See the LICENSE file in the root directory of this source tree. */ var No = X("outline", "topology-star-3", "IconTopologyStar3", [["path", { d: "M10 19a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z", key: "svg-0" }], ["path", { d: "M18 5a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z", key: "svg-1" }], ["path", { d: "M10 5a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z", key: "svg-2" }], ["path", { d: "M6 12a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z", key: "svg-3" }], ["path", { d: "M18 19a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z", key: "svg-4" }], ["path", { d: "M14 12a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z", key: "svg-5" }], ["path", { d: "M22 12a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z", key: "svg-6" }], ["path", { d: "M6 12h4", key: "svg-7" }], ["path", { d: "M14 12h4", key: "svg-8" }], ["path", { d: "M15 7l-2 3", key: "svg-9" }], ["path", { d: "M9 7l2 3", key: "svg-10" }], ["path", { d: "M11 14l-2 3", key: "svg-11" }], ["path", { d: "M13 14l2 3", key: "svg-12" }]]); /** * @license @tabler/icons-react v3.21.0 - MIT * * This source code is licensed under the MIT license. * See the LICENSE file in the root directory of this source tree. */ var Eo = X("outline", "user-plus", "IconUserPlus", [["path", { d: "M8 7a4 4 0 1 0 8 0a4 4 0 0 0 -8 0", key: "svg-0" }], ["path", { d: "M16 19h6", key: "svg-1" }], ["path", { d: "M19 16v6", key: "svg-2" }], ["path", { d: "M6 21v-2a4 4 0 0 1 4 -4h4", key: "svg-3" }]]); /** * @license @tabler/icons-react v3.21.0 - MIT * * This source code is licensed under the MIT license. * See the LICENSE file in the root directory of this source tree. */ var Do = X("outline", "users", "IconUsers", [["path", { d: "M9 7m-4 0a4 4 0 1 0 8 0a4 4 0 1 0 -8 0", key: "svg-0" }], ["path", { d: "M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2", key: "svg-1" }], ["path", { d: "M16 3.13a4 4 0 0 1 0 7.75", key: "svg-2" }], ["path", { d: "M21 21v-2a4 4 0 0 0 -3 -3.85", key: "svg-3" }]]); class kn { static getTimeTrackingRecords({requestBody: n}) { return K(_, { method: "POST", url: "/time-tracking/get-records", body: n, mediaType: "application/json", errors: { 422: "Validation Error" } }) } static updateTimeTrackingRecord({requestBody: n}) { return K(_, { method: "POST", url: "/time-tracking/update-record", body: n, mediaType: "application/json", errors: { 422: "Validation Error" } }) } } class ie { static generateQrCode({userId: n}) { return K(_, { method: "GET", url: "/work-shifts/generate-qr-code/{user_id}", path: { user_id: n }, errors: { 422: "Validation Error" } }) } static startShift({userId: n}) { return K(_, { method: "POST", url: "/work-shifts/start-shift/{user_id}", path: { user_id: n }, errors: { 422: "Validation Error" } }) } static finishShift({userId: n}) { return K(_, { method: "POST", url: "/work-shifts/finish-shift/{user_id}", path: { user_id: n }, errors: { 422: "Validation Error" } }) } static finishWorkShiftById({shiftId: n}) { return K(_, { method: "POST", url: "/work-shifts/finish-shift-by-id/{shift_id}", path: { shift_id: n }, errors: { 422: "Validation Error" } }) } static getShifts({isActive: n, page: a, itemsPerPage: o}) { return K(_, { method: "GET", url: "/work-shifts/get-shifts/{is_active}", path: { is_active: n }, query: { page: a, items_per_page: o }, errors: { 422: "Validation Error" } }) } static deleteWorkShift({shiftId: n}) { return K(_, { method: "DELETE", url: "/work-shifts/delete-shift/{shift_id}", path: { shift_id: n }, errors: { 422: "Validation Error" } }) } static startPauseByShiftId({shiftId: n}) { return K(_, { method: "POST", url: "/work-shifts/pause/start/{shift_id}", path: { shift_id: n }, errors: { 422: "Validation Error" } }) } static startPauseByUserId({userId: n}) { return K(_, { method: "POST", url: "/work-shifts/pause/start/for-user/{user_id}", path: { user_id: n }, errors: { 422: "Validation Error" } }) } static finishPauseByShiftId({shiftId: n}) { return K(_, { method: "POST", url: "/work-shifts/pause/finish/{shift_id}", path: { shift_id: n }, errors: { 422: "Validation Error" } }) } static finishPauseByUserId({userId: n}) { return K(_, { method: "POST", url: "/work-shifts/pause/finish/for-user/{shift_id}", query: { user_id: n }, errors: { 422: "Validation Error" } }) } } class nn { static getWorkShifts({requestBody: n}) { return K(_, { method: "POST", url: "/work-shifts-planning/", body: n, mediaType: "application/json", errors: { 422: "Validation Error" } }) } static updateWorkShift({requestBody: n}) { return K(_, { method: "POST", url: "/work-shifts-planning/update", body: n, mediaType: "application/json", errors: { 422: "Validation Error" } }) } } const Ao = "_container_1t4rs_1" , Bo = { container: Ao } , Wo = () => f.useMemo( () => [{ header: "ФИО", Cell: ({row: t}) => `${t.original.secondName} ${t.original.firstName} ${t.original.patronymic}` }, { accessorKey: "phoneNumber", header: "Номер телефона" }, { accessorKey: "passportData", header: "Серия и номер паспорта" }, { accessorKey: "role.name", header: "Роль" }, { accessorKey: "position.name", header: "Должность" }, { accessorKey: "payRate.name", header: "Тариф" }, { accessorKey: "comment", header: "Дополнительная информация" }, { accessorKey: "isAdmin", header: "Администратор", Cell: ({row: t}) => t.original.isAdmin ? e.jsx(lt, {}) : e.jsx(Mt, {}), size: 10 }, { accessorKey: "isBlocked", header: "Заблокирован", Cell: ({row: t}) => t.original.isBlocked ? e.jsx(lt, {}) : e.jsx(Mt, {}), size: 10 }], []) , yn = f.createContext(void 0) , zo = () => { const {objects: t, refetch: n} = Et() , a = i => { var s; Zt.updateUser({ requestBody: { data: { ...i, positionKey: (s = i.position) == null ? void 0 : s.key, roleKey: i.role.key } } }).then(async ({ok: d, message: g}) => { D.guess(d, { message: g }), d && await n() } ) } ; return { usersCrud: { items: t, onCreate: i => { Zt.createUser({ requestBody: { data: { ...i, telegramId: -1 } } }).then(async ({ok: s, message: d}) => { D.guess(s, { message: d }), s && await n() } ) } , onDelete: async i => { a({ ...i, isDeleted: !0 }) } , onChange: a }, refetch: n } } , Lo = ({children: t}) => { const n = zo(); return e.jsx(yn.Provider, { value: n, children: t }) } , Uo = () => { const t = f.useContext(yn); if (!t) throw new Error("useUsersTabContext must be used within a UsersTabContextProvider"); return t } , Oo = () => { const t = Wo() , {usersCrud: {items: n, onChange: a, onCreate: o, onDelete: r}, refetch: l} = Uo() , i = c => { a && (console.log(c), U.openContextModal({ modal: "userFormModal", title: "Редактирование пользователя", withCloseButton: !1, innerProps: { onChange: a, element: c, refetch: l }, size: "md" })) } , s = c => { r && U.openConfirmModal({ title: "Удаление пользователя", children: e.jsxs(Q, { size: "sm", children: ["Вы уверены что хотите удалить пользователя ", c.firstName, " ", c.secondName] }), labels: { confirm: "Да", cancel: "Нет" }, confirmProps: { color: "red" }, onConfirm: () => r(c) }) } , d = () => { o && U.openContextModal({ modal: "userFormModal", title: "Редактирование пользователя", withCloseButton: !1, innerProps: { onCreate: o, refetch: l }, size: "md" }) } , g = c => { const u = window.open(`/api/v1/work-shifts/generate-qr-code/${c.id}`); u && u.print() } ; return e.jsx(he, { data: n, columns: t, restProps: { enableSorting: !1, enableColumnActions: !1, enableTopToolbar: !0, renderTopToolbar: e.jsx(E, { p: N(10), children: e.jsx(Z, { variant: "default", onClick: () => d(), children: "Создать пользователя" }) }), enableRowActions: !0, renderRowActions: ({row: c}) => e.jsxs(E, { gap: "md", children: [e.jsx(q, { onClick: () => { i(c.original) } , label: "Редактировать", children: e.jsx($, { variant: "default", children: e.jsx(ut, {}) }) }), e.jsx(q, { onClick: () => { s(c.original) } , label: "Удалить", children: e.jsx($, { variant: "default", children: e.jsx(ge, {}) }) }), e.jsx(q, { onClick: () => { g(c.original) } , label: "QR-код", children: e.jsx($, { variant: "default", children: e.jsx(cn, {}) }) })] }) } }) } , $o = () => e.jsx(Lo, { children: e.jsx(Oo, {}) }) , Vo = () => f.useMemo( () => [{ accessorKey: "name", header: "Название тарифа" }, { accessorKey: "payrollScheme.name", header: "Система оплаты" }, { accessorKey: "baseRate", header: "Базовая ставка", Cell: ({row: t}) => `${t.original.baseRate.toLocaleString("ru")}₽` }, { accessorKey: "overtimeThreshold", header: "Порог сверхурочных" }, { accessorKey: "overtimeRate", header: "Сверхурочная ставка", Cell: ({row: t}) => t.original.overtimeRate && `${t.original.overtimeRate.toLocaleString("ru")}₽` }], []) , Ho = ({items: t, onCreate: n, onChange: a, onDelete: o}) => { const r = Vo() , l = () => { n && U.openContextModal({ modal: "payRateForm", withCloseButton: !1, innerProps: { onCreate: n } }) } , i = d => { a && U.openContextModal({ modal: "payRateForm", withCloseButton: !1, innerProps: { onChange: g => a({ ...g, id: d.id }), element: d } }) } , s = d => { o && U.openConfirmModal({ title: "Удаление тарифа", children: e.jsxs(Q, { size: "sm", children: ["Вы уверены что хотите удалить тариф ", d.name] }), labels: { confirm: "Да", cancel: "Нет" }, confirmProps: { color: "red" }, onConfirm: () => o(d) }) } ; return e.jsx(he, { data: t, columns: r, restProps: { enableSorting: !1, enableColumnActions: !1, enableTopToolbar: !0, renderTopToolbar: e.jsx(E, { p: N(10), children: e.jsx(Z, { variant: "default", onClick: () => l(), children: "Создать тариф" }) }), enableRowActions: !0, renderRowActions: ({row: d}) => e.jsxs(E, { gap: "md", children: [e.jsx(q, { label: "Редактировать", children: e.jsx($, { onClick: () => i(d.original), variant: "default", children: e.jsx(ut, {}) }) }), e.jsx(q, { label: "Удалить", children: e.jsx($, { onClick: () => s(d.original), variant: "default", children: e.jsx(ge, {}) }) })] }) } }) } , Fo = t => dn({ queryFn: () => Ee.getPaymentRecords(t), queryKey: "getPaymentRecords", getObjectsFn: n => n.paymentRecords, pagination: t }) , Ko = () => { const t = s => st(s, "месяц", "месяца", "месяцев") , n = s => st(s, "день", "дня", "дней") , a = s => st(s, "час", "часа", "часов") , o = s => st(s, "минута", "минуты", "минут") , r = s => { const d = s.payrollScheme; return d.key === rt.DAILY ? n(s.workUnits) : d.key === rt.MONTHLY ? t(s.workUnits) : "" } , l = s => { if (s.payrollScheme.key === rt.HOURLY) { const [g,c] = un(s.workUnits) , u = a(g); if (c === 0) return `${g} ${u}`; const h = o(c); return `${g} ${u} ${c} ${h}` } return `${s.workUnits} ${r(s)}` } , i = s => s.endDate && !ue.isEqual(s.startDate, s.endDate) ? `${ye(s.startDate)} - ${ye(s.endDate)}` : `${ye(s.startDate)}`; return f.useMemo( () => [{ header: "Дата начисления", Cell: ({row: s}) => new Date(s.original.createdAt).toLocaleString("ru-RU") }, { header: "Получил начисление", Cell: ({row: s}) => `${s.original.user.firstName} ${s.original.user.secondName}` }, { header: "Создал начисление", Cell: ({row: s}) => `${s.original.createdByUser.firstName} ${s.original.createdByUser.secondName}` }, { header: "Количество", Cell: ({row: s}) => l(s.original) }, { header: "Сумма начисления", Cell: ({row: s}) => Math.round(s.original.amount).toLocaleString("ru-RU") }, { header: "Временной промежуток", Cell: ({row: s}) => i(s.original) }], []) } , _o = () => { const [t,n] = f.useState(10) , [a,o] = f.useState(1) , {pagination: r, objects: l, refetch: i} = Fo({ page: a, itemsPerPage: 10 }); f.useEffect( () => { r && n(r.totalPages) } , [r]); const s = h => { Ee.createPaymentRecord({ requestBody: { data: h } }).then(async ({ok: m, message: b}) => { D.guess(m, { message: b }), m && await i() } ) } , d = () => { U.openContextModal({ modal: "createPaymentRecord", title: "Создание начисления", innerProps: { onCreate: s } }) } , g = h => { Ee.deletePaymentRecord({ requestBody: { paymentRecordId: h.id } }).then(async ({ok: m, message: b}) => { D.guess(m, { message: b }), m && await i() } ) } , c = h => { U.openConfirmModal({ title: "Удаление начисления", children: e.jsxs(Q, { size: "sm", children: ["Вы уверены что хотите удалить начисление пользователю", " ", h.user.firstName, " ", h.user.secondName, " от", " ", ye(h.createdAt)] }), labels: { confirm: "Да", cancel: "Нет" }, confirmProps: { color: "red" }, onConfirm: () => g(h) }) } , u = Ko(); return e.jsxs(E, { direction: "column", h: "100%", gap: N(10), children: [e.jsx(he, { data: l, columns: u, restProps: { enableSorting: !1, enableColumnActions: !1, enableTopToolbar: !0, renderTopToolbar: e.jsx(E, { p: N(10), children: e.jsx(Z, { variant: "default", onClick: () => d(), children: "Создать начисление" }) }), enableRowActions: !0, renderRowActions: ({row: h}) => e.jsx(E, { gap: "md", children: e.jsx(q, { label: "Удалить", children: e.jsx($, { onClick: () => c(h.original), variant: "default", children: e.jsx(ge, {}) }) }) }) } }), t > 1 && e.jsx(ht, { style: { alignSelf: "flex-end" }, withEdges: !0, onChange: h => o(h), value: a, total: t })] }) } , qo = () => { const {objects: t, refetch: n} = za(); return { items: t, onCreate: l => { Ee.createPayRate({ requestBody: { data: l } }).then(async ({ok: i, message: s}) => { D.guess(i, { message: s }), i && await n() } ) } , onChange: l => { Ee.updatePayRate({ requestBody: { data: l } }).then(async ({ok: i, message: s}) => { D.guess(i, { message: s }), i && await n() } ) } , onDelete: l => { Ee.deletePayRate({ requestBody: { payRateId: l.id } }).then(async ({ok: i, message: s}) => { D.guess(i, { message: s }), i && await n() } ) } } } , Qo = () => { const t = qo(); return e.jsx(e.Fragment, { children: e.jsxs(W, { keepMounted: !1, defaultValue: "paymentRecords", color: "gray.6", children: [e.jsxs(W.List, { justify: "center", grow: !0, children: [e.jsx(W.Tab, { value: "paymentRecords", leftSection: e.jsx(To, {}), children: "Начисления" }), e.jsx(W.Tab, { value: "tariffs", leftSection: e.jsx(yo, {}), children: "Тарифы" })] }), e.jsx(W.Panel, { value: "tariffs", children: e.jsx(_e.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: .2 }, children: e.jsx(Ho, { ...t }) }) }), e.jsx(W.Panel, { value: "paymentRecords", children: e.jsx(_e.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: .2 }, children: e.jsx(_o, {}) }) })] }) }) } , an = t => { var n; return [Re(t)[0].toDate(), (n = ue.last(Re(t))) == null ? void 0 : n.toDate()] } , Xo = () => { const [t,n] = f.useState(new Date(new Date().getFullYear(),new Date().getMonth(),1)) , [a,o] = f.useState([]) , [r,l] = f.useState(an(t)) , i = async () => kn.getTimeTrackingRecords({ requestBody: { date: hn(t), userIds: [] } }).then(s => o(s.records)); return f.useEffect( () => { i().then(s => { l(an(t)) } ) } , [t]), { month: t, setMonth: n, refetch: i, trackingRecords: a, dateBoundaries: r } } ; function on(t) { const [n,a] = t.split("_").map(Number); return { row: n, col: a } } function Jo(t) { return `${t.row}_${t.col}` } function Yo(t) { const n = []; for (let a = 0; a < t.length - 1; a++) { const o = t[a] , r = t[a + 1]; if (n.push(o), o.row === r.row) for (let l = o.col + 1; l < r.col; l++) n.push({ row: o.row, col: l }) } return n.push(t[t.length - 1]), n } function Go(t, n) { const a = on(n); let o = Yo([...t, n].map(on).sort( (s, d) => s.col - d.col)); const r = ue.maxBy(o, s => s.col) , l = ue.minBy(o, s => s.col) , i = o.findIndex(s => s.col === a.col && s.row === a.row); return l && r && a.col > l.col && a.col < r.col && (i >= o.length / 2 ? o = o.slice(0, i) : o = o.slice(i)), o.map(Jo) } const Zo = ({month: t, onUpdate: n, data: a, selectedCells: o, setSelectedCells: r, selectedBoundaries: l, range: i}) => { const s = f.useMemo( () => a.reduce( (c, u) => { if (u.data) { const h = u.data.reduce( (m, b) => m + b.amount, 0); return c + h } return c } , 0), [a, t, o, l]) , d = c => o.length <= 1 ? {} : o[0] === c ? { borderTopLeftRadius: N(20), borderBottomLeftRadius: N(20) } : ue.last(o) === c ? { borderTopRightRadius: N(20), borderBottomRightRadius: N(20) } : {} , g = c => { const [u,h] = un(c) , m = String(u).padStart(2, "0") , b = String(h).padStart(2, "0"); return `${m}:${b}` } ; return f.useMemo( () => [{ accessorKey: "name", header: "ФИО", Cell: ({row: c}) => e.jsxs(E, { direction: "column", children: [e.jsx(Q, { size: "sm", children: c.original.name }), e.jsx(Q, { size: "xs", children: c.original.comment })] }) }, ...i.map(c => ({ size: 100, accessorKey: c.date().toString(), header: c.date().toString(), enableSorting: !1, enableColumnActions: !1, Header: e.jsxs(E, { align: "center", direction: "column", children: [e.jsx(Y, { children: c.date() }), e.jsx(Y, { children: gn(c.day()) })] }), mantineTableBodyCellProps: ({cell: u}) => ({ style: o.includes(u.id) ? { backgroundColor: "var(--mantine-primary-color-filled)", ...d(u.id) } : {}, onClick: () => { const h = Go(o, u.id); r(h) } }), Cell: ({cell: u, row: h}) => e.jsx(E, { direction: "column", children: e.jsx(La, { component: Ua, mask: "00:00", onChange: m => /^\d\d:\d\d$/.test(m.currentTarget.value) && n(c.toDate(), h.original.userId, m.currentTarget.value), styles: { input: { textAlign: "center" } }, value: g(u.renderValue()) }) }) })), { header: "Всего времени", Cell: ({row: c}) => g(Object.entries(c.original).reduce( (u, [h,m]) => (isNaN(parseInt(h)) || !ue.isNumber(m) || (u += m), u), 0)) }, { accessorKey: "totalAmount", header: "Итоговая сумма заработка", Cell: ({row: c}) => Math.floor((c.original.data || []).reduce( (u, h) => (u += h.amount, u), 0)), Footer: e.jsxs(E, { children: ["Всего: ", Math.floor(s).toLocaleString("ru-RU")] }) }], [t, o, l, s]) } , es = () => { const [t,n] = f.useState([]) , {dateBoundaries: a, month: o, setMonth: r, trackingRecords: l, refetch: i} = Xo() , [s,d] = it([]) , [g,c] = f.useState([null, null]) , u = Et().objects.filter(p => { var v; return ((v = p.payRate) == null ? void 0 : v.payrollScheme.key) === rt.HOURLY } ) , m = ( () => { const p = g[0] , v = g[1]; return p && v ? It(p, v) : Re(o) } )() , b = p => { if (!o) return []; const v = m.map(w => w.date()); p = p.map(w => ({ ...w, data: w.data.filter(M => v.includes(new Date(M.date).getDate())) })); const k = p.map(w => w.user.id) , j = p.map(w => ({ name: `${w.user.firstName} ${w.user.secondName}`, comment: w.user.comment, userId: w.user.id, totalAmount: w.totalAmount, data: w.data, ...Object.fromEntries(Re(o).reduce( (M, B) => M.set(B.date().toString(), 0), new Map)), ...Object.fromEntries(w.data.reduce( (M, B) => M.set(new Date(B.date).getDate().toString(), B.hours), new Map)) })) , x = u.filter(w => !k.includes(w.id)).map(w => ({ name: `${w.firstName} ${w.secondName}`, userId: w.id, comment: w.comment, totalAmount: 0, ...Object.fromEntries(Re(o).reduce( (M, B) => M.set(B.date().toString(), 0), new Map)) })) , y = s.map(w => w.id) , C = j.concat(x).filter(w => y.includes(w.userId)) , S = g[0] , I = g[1]; if (S && I) { const w = Re(o).map(O => O.date().toString()) , M = It(S, I).map(O => O.date().toString()) , B = ue.difference(w, M); return C.map(O => ue.omit(O, B)) } return C.sort( (w, M) => w.userId - M.userId) } , T = Zo({ month: o, selectedBoundaries: g, data: t, onUpdate: (p, v, k) => { const j = u.find(y => y.id === v); if (!j) return; console.log(k); const x = $a(k); console.log(x), x !== -1 && (n(y => y.map(C => (C.userId !== v || (C[p.getDate()] = k), C))), kn.updateTimeTrackingRecord({ requestBody: { date: hn(p), hours: x, userId: j.id } }).then(async ({ok: y, message: C}) => { y || D.guess(y, { message: C }), await i() } )) } , selectedCells: [], setSelectedCells: () => {} , range: m }); return f.useEffect( () => { n(b(l)) } , [l, s, g]), f.useEffect( () => { c([null, null]) } , [o]), e.jsxs(E, { direction: "column", p: N(10), gap: N(10), children: [e.jsxs(E, { align: "center", justify: "space-between", gap: N(10), children: [e.jsx(Dt, { data: u.map(p => ({ label: `${p.firstName} ${p.secondName}`, value: p.id.toString() })), onChange: p => d.setState(u.filter(v => p.includes(v.id.toString()))), value: s.map(p => p.id.toString()), placeholder: s.length > 0 ? "" : "Показанные пользователи", searchable: !0 }), e.jsxs(E, { gap: N(10), children: [e.jsx(mn, { styles: { input: { textAlign: "center" } }, miw: N(80), valueFormat: "DD", type: "range", minDate: a[0], maxDate: a[1], value: g, onChange: c, placeholder: "Даты" }), e.jsx(Oa, { allowDeselect: !1, onChange: p => p && r(p), value: o, placeholder: "Выберите месяц" })] })] }), e.jsx(E, { children: e.jsx(he, { data: t, columns: T, restProps: { enableColumnActions: !1, enableSorting: !1, enableRowActions: !0, renderRowActions: ({row: p}) => e.jsx(E, { gap: "md", children: e.jsx(q, { label: "Скрыть", children: e.jsx($, { onClick: () => { d.filter(v => v.id !== p.original.userId) } , variant: "default", children: e.jsx(pn, {}) }) }) }) } }) })] }) } , ts = ({isActiveShiftsTable: t}) => { const n = o => { const r = Math.floor(o / 3600) , l = Math.floor(o % 3600 / 60); return r === 0 ? `${l} мин.` : `${r} ч. ${l} мин.` } , a = () => t ? [] : [{ header: "Конец смены", accessorKey: "workShift.finishedAt", Cell: ({row: o}) => o.original.workShift.finishedAt && new Date(o.original.workShift.finishedAt).toLocaleString("ru-RU") }, { header: "Длительность смены", accessorKey: "totalHours", Cell: ({row: o}) => n(o.original.totalHours ?? 0) }, { header: "Перерывы", accessorKey: "pauseHours", Cell: ({row: o}) => n(o.original.pauseHours ?? 0) }, { header: "Отработано", Cell: ({row: o}) => n((o.original.totalHours ?? 0) - (o.original.pauseHours ?? 0)) }]; return f.useMemo( () => [{ header: "ФИО", Cell: ({row: o}) => `${o.original.workShift.user.firstName} ${o.original.workShift.user.secondName}` }, { header: "Роль", accessorKey: "workShift.user.role.name" }, { header: "Должность", accessorKey: "workShift.user.position.name" }, { header: "Начало смены", accessorKey: "workShift.startedAt", Cell: ({row: o}) => new Date(o.original.workShift.startedAt).toLocaleString("ru-RU") }, ...a()], [t]) } ; var ct = (t => (t[t.ACTIVE = 0] = "ACTIVE", t[t.HISTORY = 1] = "HISTORY", t))(ct || {}); const ns = [{ label: "Активные смены", value: "0" }, { label: "Завершенные смены", value: "1" }] , as = t => e.jsx(fn, { data: ns, ...t }) , os = ({shifts: t, fetchShifts: n, shiftsTableType: a}) => { const o = a === ct.ACTIVE , r = ts({ isActiveShiftsTable: o }) , l = m => { ie.deleteWorkShift({ shiftId: m.workShift.id }).then( ({ok: b, message: P}) => { D.guess(b, { message: P }), n() } ).catch(b => console.log(b)) } , i = m => { U.openConfirmModal({ title: "Удаление смены", children: e.jsxs(Q, { size: "sm", children: ["Вы уверены что хотите удалить смену работника", " ", m.workShift.user.firstName, " ", m.workShift.user.secondName, " от", " ", ye(m.workShift.startedAt)] }), labels: { confirm: "Да", cancel: "Нет" }, confirmProps: { color: "red" }, onConfirm: () => l(m) }) } , s = m => { ie.finishWorkShiftById({ shiftId: m.workShift.id }).then( ({ok: b, message: P}) => { D.guess(b, { message: P }), n() } ).catch(b => console.log(b)) } , d = m => { U.openConfirmModal({ title: "Завершение смены", children: e.jsxs(Q, { size: "sm", children: ["Вы уверены что хотите завершить смену работника", " ", m.workShift.user.firstName, " ", m.workShift.user.secondName, " от", " ", ye(m.workShift.startedAt)] }), labels: { confirm: "Да", cancel: "Нет" }, confirmProps: { color: "red" }, onConfirm: () => s(m) }) } , g = m => { ie.startPauseByShiftId({ shiftId: m.workShift.id }).then( ({ok: b, message: P}) => { D.guess(b, { message: P }), n() } ).catch(b => console.log(b)) } , c = m => { ie.finishPauseByShiftId({ shiftId: m.workShift.id }).then( ({ok: b, message: P}) => { D.guess(b, { message: P }), n() } ).catch(b => console.log(b)) } , u = (m, b, P) => e.jsx(q, { label: m, children: e.jsx($, { onClick: b, variant: "default", children: P }) }) , h = m => { const b = [u("Удалить", () => i(m.original), e.jsx(ge, {}))]; return o && (b.push(u("Завершить смену", () => d(m.original), e.jsx(lt, {}))), m.original.workShift.isPaused ? b.push(u("Продолжить смену", () => c(m.original), e.jsx(Mo, {}))) : b.push(u("Поставить смену на паузу", () => g(m.original), e.jsx(po, {})))), b } ; return e.jsx(he, { data: t, columns: r, restProps: { enableRowActions: !0, enableSorting: !1, enableColumnActions: !1, renderRowActions: ({row: m}) => e.jsxs(E, { gap: "md", children: [...h(m)] }) } }) } , ss = () => { const [t,n] = f.useState(1) , [a,o] = f.useState(1) , [r,l] = f.useState([]) , [i,s] = f.useState(ct.ACTIVE) , [d,g] = f.useState(!1) , c = () => { g(!0), ie.getShifts({ isActive: i === ct.ACTIVE, page: a, itemsPerPage: 10 }).then(u => { l(u.shifts), n(u.paginationInfo.totalPages) } ).catch(u => console.log(u)).finally( () => g(!1)) } ; return f.useEffect( () => { c() } , [i, a]), { shifts: r, shiftsTableType: i, setShiftsTableType: s, totalPages: t, page: a, setPage: o, fetchShifts: c, isLoading: d } } , rs = ({fetchShifts: t}) => { let n = 0; const a = { 0: ie.startShift, 1: ie.finishShift, 2: ie.finishPauseByUserId, 3: ie.startPauseByUserId } , o = g => { const c = parseInt(g); if (isNaN(c)) { D.error({ message: "Ошибка, некорректные данные в QR-коде" }); return } a[n]({ userId: c }).then(async ({ok: u, message: h}) => { D.guess(u, { message: h }), t() } ).catch(u => console.log(u)) } , r = () => { U.openContextModal({ modal: "scanningModal", innerProps: { label: "Отсканируйте QR-код", onScan: o, closeOnScan: !0 }, withCloseButton: !1 }) } ; return { onShiftStart: () => { n = 0, r() } , onShiftFinish: () => { n = 1, r() } , onShiftResume: () => { n = 2, r() } , onShiftPause: () => { n = 3, r() } } } , is = ({fetchShifts: t}) => { const {onShiftStart: n, onShiftFinish: a, onShiftResume: o, onShiftPause: r} = rs({ fetchShifts: t }); return e.jsxs(De, { ml: "xs", my: "xs", children: [e.jsx(Z, { variant: "default", onClick: n, children: "Начать смену" }), e.jsx(Z, { variant: "default", onClick: a, children: "Закончить смену" }), e.jsx(Z, { variant: "default", onClick: r, children: "Начать перерыв" }), e.jsx(Z, { variant: "default", onClick: o, children: "Закончить перерыв" })] }) } , ls = () => { const {shifts: t, shiftsTableType: n, setShiftsTableType: a, totalPages: o, page: r, setPage: l, fetchShifts: i, isLoading: s} = ss(); return e.jsxs(qe, { gap: 0, children: [e.jsx(is, { fetchShifts: i }), e.jsx(Va, {}), e.jsx(as, { value: n.toString(), onChange: d => { l(1), a(parseInt(d)) } }), e.jsx(Ha, { visible: s, children: e.jsxs(E, { gap: N(10), direction: "column", children: [e.jsx(os, { shiftsTableType: n, shifts: t, fetchShifts: i }), o > 1 && e.jsx(ht, { style: { alignSelf: "flex-end" }, withEdges: !0, onChange: d => l(d), value: r, total: o })] }) })] }) } , cs = t => dn({ queryFn: () => Rt.getAllTransactions({ requestBody: { isIncome: t.isIncome }, ...t }), queryKey: "getTransactions", getObjectsFn: n => n.transactions, pagination: t }) , ds = () => f.useMemo( () => [{ accessorKey: "spentDate", header: "Дата", Cell: ({row: t}) => ye(t.original.spentDate) }, { accessorKey: "name", header: "Наименование" }, { accessorKey: "comment", header: "Комментарий" }, { accessorKey: "amount", header: "Сумма" }, { accessorKey: "tags", header: "Теги", Cell: ({row: t}) => t.original.tags.map(n => n.name).join(", ") }, { accessorKey: "createdByUser", header: "Создал запись", Cell: ({row: t}) => `${t.original.createdByUser.firstName} ${t.original.createdByUser.secondName}` }], []); var Ke = (t => (t[t.EXPENSE = 0] = "EXPENSE", t[t.INCOME = 1] = "INCOME", t))(Ke || {}); const us = [{ label: "Расходы", value: "0" }, { label: "Доходы", value: "1" }] , hs = t => e.jsx(fn, { data: us, ...t }) , gs = () => { const [t,n] = f.useState(Ke.EXPENSE) , a = t === Ke.INCOME , [o,r] = f.useState(10) , [l,i] = f.useState(1) , {pagination: s, objects: d, refetch: g} = cs({ page: l, itemsPerPage: 10, isIncome: a }) , c = ds(); f.useEffect( () => { s && (s.totalPages ? r(s.totalPages) : r(0)) } , [s]); const u = j => { Rt.updateTransaction({ requestBody: { transaction: { ...j, spentDate: ke(new Date(j.spentDate)) ?? "", isIncome: a } } }).then(async ({ok: x, message: y}) => { D.guess(x, { message: y }), await g() } ).catch(x => console.log(x)) } , h = a ? "доходах" : "расходах" , m = () => { U.openContextModal({ modal: "transactionFormModal", title: `Создание записи о ${h}`, withCloseButton: !1, innerProps: { onCreate: u, isIncome: a } }) } , b = j => { const x = { ...j, tags: j.tags.map(y => y.name) }; U.openContextModal({ modal: "transactionFormModal", title: `Редактирование записи о ${h}`, withCloseButton: !1, innerProps: { onChange: u, element: x, isIncome: a } }) } , P = j => { Rt.deleteTransaction({ transactionId: j.id }).then(async ({ok: x, message: y}) => { D.guess(x, { message: y }), await g() } ).catch(x => console.log(x)) } , T = async () => { await g() } , p = () => { U.openContextModal({ modal: "transactionTagsModal", title: "Редактирование тегов", withCloseButton: !1, innerProps: { onChange: T, isIncome: a } }) } , v = () => t === Ke.EXPENSE ? "Создать запись о расходах" : "Создать запись о доходах" , k = () => t === Ke.EXPENSE ? "Редактировать теги для расходов" : "Редактировать теги для доходов"; return e.jsxs(E, { direction: "column", h: "100%", gap: 0, children: [e.jsx(hs, { value: t.toString(), onChange: j => { i(1), n(parseInt(j)) } }), e.jsx(he, { data: d, columns: c, restProps: { enableTopToolbar: !0, enableRowActions: !0, enableSorting: !1, enableColumnActions: !1, renderTopToolbar: e.jsxs(E, { p: N(10), gap: N(10), children: [e.jsx(Z, { variant: "default", onClick: () => m(), children: v() }), e.jsx(Z, { variant: "default", onClick: () => p(), children: k() })] }), renderRowActions: ({row: j}) => e.jsxs(E, { gap: "md", children: [e.jsx(q, { label: "Редактировать", children: e.jsx($, { onClick: () => b(j.original), variant: "default", children: e.jsx(ut, {}) }) }), e.jsx(q, { label: "Удалить", children: e.jsx($, { onClick: () => P(j.original), variant: "default", children: e.jsx(ge, {}) }) })] }) } }), o > 1 && e.jsx(ht, { style: { alignSelf: "flex-end" }, withEdges: !0, onChange: j => i(j), value: l, total: o })] }) } , ms = () => f.useMemo( () => [{ accessorKey: "name", header: "Название должности" }, { accessorKey: "key", header: "Ключ" }], []) , ps = ({items: t, onCreate: n, onDelete: a}) => { const o = ms() , r = () => { n && U.openContextModal({ modal: "positionForm", withCloseButton: !1, innerProps: { onCreate: n } }) } , l = i => { a && U.openConfirmModal({ title: "Удаление должности", children: e.jsxs(Q, { size: "sm", children: ["Вы уверены что хотите удалить должность ", i.name] }), labels: { confirm: "Да", cancel: "Нет" }, confirmProps: { color: "red" }, onConfirm: () => a(i) }) } ; return e.jsx(he, { data: t, columns: o, restProps: { enableTopToolbar: !0, enableSorting: !1, enableColumnActions: !1, enableRowActions: !0, renderTopToolbar: e.jsx(E, { p: N(10), children: e.jsx(Z, { variant: "default", onClick: () => r(), children: "Создать должность" }) }), renderRowActions: ({row: i}) => e.jsx(E, { gap: "md", children: e.jsx(q, { label: "Удалить", children: e.jsx($, { onClick: () => l(i.original), variant: "default", children: e.jsx(ge, {}) }) }) }) } }) } , fs = () => { const {objects: t, refetch: n} = Fa() , a = r => { en.createPosition({ requestBody: { data: r } }).then(async ({ok: l, message: i}) => { D.guess(l, { message: i }), l && await n() } ) } , o = r => { en.deletePosition({ requestBody: { positionKey: r.key } }).then(async ({ok: l, message: i}) => { D.guess(l, { message: i }), l && await n() } ) } ; return e.jsx(ps, { items: t, onCreate: a, onDelete: o }) } , xs = ({fetchDepartments: t}) => xn({ onChange: n => { de.updateDepartment({ requestBody: { department: n } }).then( ({ok: a, message: o}) => { D.guess(a, { message: o }), t() } ).catch(a => console.log(a)) } , onCreate: n => { de.createDepartment({ requestBody: { department: n } }).then( ({ok: a, message: o}) => { D.guess(a, { message: o }), t() } ).catch(a => console.log(a)) } , onDelete: n => { de.deleteDepartment({ departmentId: n.id }).then( ({ok: a, message: o}) => { D.guess(a, { message: o }), t() } ).catch(a => console.log(a)) } }) , bs = ({fetchDepartments: t}) => xn({ onChange: n => { de.updateSection({ requestBody: { section: n } }).then( ({ok: a, message: o}) => { D.guess(a, { message: o }), t() } ).catch(a => console.log(a)) } , onCreate: n => { de.createSection({ requestBody: { section: n } }).then( ({ok: a, message: o}) => { D.guess(a, { message: o }), t() } ).catch(a => console.log(a)) } , onDelete: n => { de.deleteSection({ sectionId: n.id }).then( ({ok: a, message: o}) => { D.guess(a, { message: o }), t() } ).catch(a => console.log(a)) } }) , wn = f.createContext(void 0) , Cs = () => { const [t,n] = f.useState([]) , a = () => { de.getDepartments().then(c => { n(c.departments) } ).catch(c => console.log(c)) } , o = xs({ fetchDepartments: a }) , r = bs({ fetchDepartments: a }); f.useEffect( () => { a() } , []); const l = (c, u, h) => { U.openContextModal({ modal: "departmentModal", title: c, withCloseButton: !1, innerProps: { departmentsCrud: o, departmentSectionsCrud: r, isDepartmentSection: u, element: h, allDepartments: t } }) } ; return { departments: t, fetchDepartments: a, onCreateDepartmentClick: (c, u) => { l(c ? "Создание отдела" : "Создание департамента", c, u) } , onUpdateDepartmentClick: (c, u) => { l(u ? "Редактирование отдела" : "Редактирование департамента", u, c) } , onDeleteDepartmentClick: (c, u) => { U.openConfirmModal({ title: "Удаление " + (u ? "отдела" : "департамента"), children: e.jsxs(Q, { size: "sm", children: ["Вы уверены что хотите удалить ", u ? "отдел" : "департамент", " ", c.name, "?"] }), labels: { confirm: "Да", cancel: "Нет" }, confirmProps: { color: "red" }, onConfirm: () => { u ? r.onDelete(c) : o.onDelete(c) } }) } , onAddUserClick: c => { U.openContextModal({ modal: "addUserToDepartmentModal", title: `Добавление пользователя в отдел ${c.name}`, withCloseButton: !1, innerProps: { departmentSection: c, fetchDepartments: a } }) } } } , vs = ({children: t}) => { const n = Cs(); return e.jsx(wn.Provider, { value: n, children: t }) } , gt = () => { const t = f.useContext(wn); if (!t) throw new Error("useDepartmentContext must be used within a DepartmentContextProvider"); return t } ; var [js,zt] = Ka("useDataTableColumnsContext must be used within DataTableColumnProvider") , sn = t => { let {children: n, columnsOrder: a, setColumnsOrder: o, columnsToggle: r, setColumnsToggle: l, resetColumnsOrder: i, resetColumnsToggle: s, setColumnWidth: d, resetColumnsWidth: g} = t , [c,u] = f.useState("") , [h,m] = f.useState(""); return e.jsx(js, { value: { sourceColumn: c, setSourceColumn: u, targetColumn: h, setTargetColumn: m, columnsToggle: r, setColumnsToggle: l, swapColumns: () => { if (!a || !o || !c || !h) return; let b = a.indexOf(c) , P = a.indexOf(h); if (b !== -1 && P !== -1) { let T = a.splice(b, 1)[0]; a.splice(P, 0, T), o([...a]) } } , resetColumnsOrder: i, resetColumnsToggle: s, setColumnWidth: d, resetColumnsWidth: g }, children: n }) } ; function ks() { return e.jsx("tr", { className: "mantine-datatable-empty-row", children: e.jsx("td", {}) }) } function ys() { return e.jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round", children: [e.jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), e.jsx("path", { d: "M12.983 8.978c3.955 -.182 7.017 -1.446 7.017 -2.978c0 -1.657 -3.582 -3 -8 -3c-1.661 0 -3.204 .19 -4.483 .515m-2.783 1.228c-.471 .382 -.734 .808 -.734 1.257c0 1.22 1.944 2.271 4.734 2.74" }), e.jsx("path", { d: "M4 6v6c0 1.657 3.582 3 8 3c.986 0 1.93 -.067 2.802 -.19m3.187 -.82c1.251 -.53 2.011 -1.228 2.011 -1.99v-6" }), e.jsx("path", { d: "M4 12v6c0 1.657 3.582 3 8 3c3.217 0 5.991 -.712 7.261 -1.74m.739 -3.26v-4" }), e.jsx("path", { d: "M3 3l18 18" })] }) } function ws({icon: t, text: n, pt: a, pb: o, active: r, children: l}) { return e.jsx(Ne, { pt: a, pb: o, className: "mantine-datatable-empty-state", "data-active": r || void 0, children: l || e.jsxs(e.Fragment, { children: [t || e.jsx("div", { className: "mantine-datatable-empty-state-icon", children: e.jsx(ys, {}) }), e.jsx(Q, { component: "div", size: "sm", c: "dimmed", children: n })] }) }) } var Ss = ({key: t, columns: n=[], getInitialValueInEffect: a=!0}) => { function o(x, y) { let C = []; return x.forEach(S => { y.find(I => I.accessor === S) && C.push(S) } ), y.forEach(S => { C.includes(S.accessor) || C.push(S.accessor) } ), C } function r(x, y) { let C = []; return x.forEach(S => { y.find(I => I.accessor === S.accessor) && C.push(S) } ), y.forEach(S => { C.find(I => I.accessor === S.accessor) || C.push({ accessor: S.accessor, defaultToggle: S.defaultToggle || !0, toggleable: S.toggleable, toggled: S.defaultToggle === void 0 ? !0 : S.defaultToggle }) } ), C } function l(x, y) { let C = []; return x.forEach(S => { let I = Object.keys(S)[0]; y.find(w => w.accessor === I) && C.push(S) } ), y.forEach(S => { let I = S.accessor; if (!C.find(w => Object.keys(w)[0] === I)) { let w = {}; w[I] = "", C.push(w) } } ), C } function i() { let[x,y] = Pt({ key: t ? `${t}-columns-order` : "", defaultValue: t ? g : void 0, getInitialValueInEffect: a }); function C(w) { t && y(w) } if (!t) return [x, C]; let S = o(x, n) , I = JSON.stringify(x); return JSON.stringify(S) !== I && C(S), [S, C] } function s() { let[x,y] = Pt({ key: t ? `${t}-columns-toggle` : "", defaultValue: t ? u : void 0, getInitialValueInEffect: a }); function C(w) { t && y(w) } if (!t) return [x, C]; let S = r(x, n) , I = JSON.stringify(x); return JSON.stringify(S) !== I && C(S), [r(x, n), C] } function d() { let[x,y] = Pt({ key: t ? `${t}-columns-width` : "", defaultValue: t ? c : void 0, getInitialValueInEffect: a }); function C(w) { t && y(w) } if (!t) return [x, C]; let S = l(x, n) , I = JSON.stringify(x); return JSON.stringify(S) !== I && C(S), [l(x, n), C] } let g = n && n.map(x => x.accessor) || [] , c = n && n.map(x => ({ [x.accessor]: x.width ?? "initial" })) || [] , u = n && n.map(x => ({ accessor: x.accessor, defaultToggle: x.defaultToggle || !0, toggleable: x.toggleable, toggled: x.defaultToggle === void 0 ? !0 : x.defaultToggle })) , [h,m] = i() , [b,P] = s() , [T,p] = d() , v = () => m(g) , k = () => { P(u) } , j = () => p(c); return { effectiveColumns: f.useMemo( () => h ? h.map(x => n.find(y => y.accessor === x)).map(x => { var y; return { ...x, hidden: (x == null ? void 0 : x.hidden) || !((y = b.find(C => C.accessor === (x == null ? void 0 : x.accessor))) != null && y.toggled) } } ).map(x => { var y; return { ...x, width: (y = T.find(C => C[x == null ? void 0 : x.accessor])) == null ? void 0 : y[x == null ? void 0 : x.accessor] } } ) : n, [n, h, b, T]), setColumnsOrder: m, columnsOrder: h, resetColumnsOrder: v, columnsToggle: b, setColumnsToggle: P, resetColumnsToggle: k, columnsWidth: T, setColumnsWidth: p, setColumnWidth: (x, y) => { let C = T.map(S => S[x] ? { [x]: y } : S); p(C) } , resetColumnsWidth: j } } ; function Ie() { var o; let[t] = oo() , {width: n, height: a} = ((o = t.current) == null ? void 0 : o.getBoundingClientRect()) || { width: 0, height: 0 }; return { ref: t, width: n, height: a } } var Ps = typeof window < "u" ? f.useLayoutEffect : f.useEffect; function Ts(t) { let[n,a] = f.useState(null) , o = (t == null ? void 0 : t.join(":")) || ""; return f.useEffect( () => { a(null) } , [o]), { lastSelectionChangeIndex: n, setLastSelectionChangeIndex: a } } function Ms(t, n) { let a = () => { n(t.map(r => r.matches)) } , o = t.map(r => { try { return r.addEventListener("change", a), () => r.removeEventListener("change", a) } catch { return r.addListener(a), () => r.removeListener(a) } } ); return () => { o.forEach(r => r()) } } function Is(t, n) { return n || (typeof window < "u" && "matchMedia"in window ? t.map(a => window.matchMedia(a).matches) : t.map( () => !1)) } function Rs(t, n, {getInitialValueInEffect: a}={ getInitialValueInEffect: !0 }) { let[o,r] = f.useState(a ? n : Is(t, n)) , l = f.useRef(null); return f.useEffect( () => { if ("matchMedia"in window) return l.current = t.map(i => window.matchMedia(i)), r(l.current.map(i => i.matches)), Ms(l.current, i => { r(i) } ) } , [t]), o } function Ns(t) { let n = jn() , a = f.useMemo( () => t.map(r => (typeof r == "function" ? r(n) : r) ?? ""), [t, n]) , o = f.useMemo( () => t.map( () => !0), [t]); return Rs(a, o) } function mt(t) { let n = jn() , a = typeof t == "function" ? t(n) : t; return Qa(a || "", !0) } function Lt(t) { let n = t.replace(/([a-z\d])([A-Z]+)/g, "$1 $2").replace(/\W|_/g, " ").trim().toLowerCase(); return `${n.charAt(0).toUpperCase()}${n.slice(1)}` } function Es(t, n, a) { return t.filter(o => !n.map(a).includes(a(o))) } function Tt(t, n) { return t.filter( (a, o, r) => o === r.findIndex(l => n(a) === n(l))) } function Sn(t, n) { return n ? n.match(/([^[.\]])+/g).reduce( (a, o) => a && a[o], t) : void 0 } function F(t, n) { return typeof n == "string" ? Sn(t, n) : n(t) } function Ds({rowExpansion: t, records: n, idAccessor: a}) { let o = []; if (t && n) { let {trigger: s, allowMultiple: d, initiallyExpanded: g} = t; n && s === "always" ? o = n.map(c => F(c, a)) : g && (o = n.filter( (c, u) => g({ record: c, index: u })).map(c => F(c, a)), d || (o = [o[0]])) } let r, l, i = f.useState(o); if (t) { let {expandable: s, trigger: d, allowMultiple: g, collapseProps: c, content: u} = t; t.expanded ? {recordIds: r, onRecordIdsChange: l} = t.expanded : [r,l] = i; let h = m => l == null ? void 0 : l(r.filter(b => b !== F(m, a))); return { expandOnClick: d !== "always" && d !== "never", isRowExpanded: m => d === "always" ? !0 : r.includes(F(m, a)), isExpandable: ({record: m, index: b}) => s ? s({ record: m, index: b }) : !0, expandRow: m => { let b = F(m, a); l == null || l(g ? [...r, b] : [b]) } , collapseRow: h, collapseProps: c, content: ({record: m, index: b}) => () => u({ record: m, index: b, collapse: () => h(m) }) } } } function As(t, n) { let[a,o] = f.useState(t) , [r,l] = f.useState(t) , i = tn( () => o(!0), 0) , s = tn( () => l(!1), n || 200); return f.useEffect( () => { t ? (s.clear(), l(!0), i.start()) : (i.clear(), o(!1), s.start()) } , [i, s, t]), { expanded: a, visible: r } } var Ut = "mantine-datatable-nowrap" , Ot = "mantine-datatable-ellipsis" , Ae = "mantine-datatable-pointer-cursor" , Pn = "mantine-datatable-context-menu-cursor" , Bs = "mantine-datatable-text-selection-disabled" , pt = "mantine-datatable-text-align-left" , ft = "mantine-datatable-text-align-center" , xt = "mantine-datatable-text-align-right"; function Ws({className: t, style: n, visibleMediaQuery: a, title: o, noWrap: r, ellipsis: l, textAlign: i, width: s}) { return mt(a) ? e.jsx(Qe, { className: A({ [Ut]: r || l, [Ot]: l, [pt]: i === "left", [ft]: i === "center", [xt]: i === "right" }, t), style: [{ width: s, minWidth: s, maxWidth: s }, n], children: o }) : null } function zs({shadowVisible: t}) { return e.jsx(Qe, { className: "mantine-datatable-footer-selector-placeholder-cell", "data-shadow-visible": t || void 0 }) } var Ls = f.forwardRef(function({className: t, style: n, columns: a, defaultColumnProps: o, selectionVisible: r, selectorCellShadowVisible: l, scrollDiff: i}, s) { let d = i < 0; return e.jsx(_a, { ref: s, className: A("mantine-datatable-footer", t), style: [{ position: d ? "relative" : "sticky", bottom: N(d ? i : 0) }, n], children: e.jsxs(we, { children: [r && e.jsx(zs, { shadowVisible: l }), a.map( ({hidden: g, ...c}) => { if (g) return null; let {accessor: u, visibleMediaQuery: h, textAlign: m, width: b, footer: P, footerClassName: T, footerStyle: p, noWrap: v, ellipsis: k} = { ...o, ...c }; return e.jsx(Ws, { className: T, style: p, visibleMediaQuery: h, textAlign: m, width: b, title: P, noWrap: v, ellipsis: k }, u) } )] }) }) }); function Us({group: {id: t, columns: n, title: a, textAlign: o, className: r, style: l}}) { let i = f.useMemo( () => n.map( ({visibleMediaQuery: g}) => g), [n]) , s = Ns(i) , d = f.useMemo( () => n.filter( ({hidden: g}, c) => !g && (s == null ? void 0 : s[c])).length, [n, s]); return d > 0 ? e.jsx(Qe, { colSpan: d, className: A("mantine-datatable-column-group-header-cell", { [pt]: o === "left", [ft]: o === "center", [xt]: o === "right" }, r), style: l, children: a ?? Lt(t) }) : null } function Os() { return e.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round", children: [e.jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), e.jsx("path", { d: "M4 4h16v2.172a2 2 0 0 1 -.586 1.414l-4.414 4.414v7l-6 2v-8.5l-4.48 -4.928a2 2 0 0 1 -.52 -1.345v-2.227z" })] }) } function $s() { return e.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round", children: [e.jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), e.jsx("path", { d: "M20 3h-16a1 1 0 0 0 -1 1v2.227l.008 .223a3 3 0 0 0 .772 1.795l4.22 4.641v8.114a1 1 0 0 0 1.316 .949l6 -2l.108 -.043a1 1 0 0 0 .576 -.906v-6.586l4.121 -4.12a3 3 0 0 0 .879 -2.123v-2.171a1 1 0 0 0 -1 -1z", strokeWidth: "0", fill: "currentColor" })] }) } function Vs({children: t, isActive: n, filterPopoverProps: a}) { let[o,{close: r, toggle: l}] = Za(!1) , i = n ? $s : Os , s = eo(r); return e.jsxs(bn, { withArrow: !0, shadow: "md", opened: o, onClose: r, trapFocus: !0, ...a, children: [e.jsx(Cn, { children: e.jsx($, { className: "mantine-datatable-header-cell-filter-action-icon", "data-active": n || void 0, size: "sm", variant: "default", onClick: d => { d.preventDefault(), l() } , onKeyDown: d => d.stopPropagation(), children: e.jsx(i, {}) }) }), e.jsx(vn, { ref: s, onClick: d => d.stopPropagation(), onKeyDown: d => d.stopPropagation(), children: typeof t == "function" ? t({ close: r }) : t })] }) } var Hs = t => { let {accessor: n, columnRef: a} = t , o = f.useRef(null) , [r,l] = f.useState(0) , {setColumnWidth: i} = zt() , s = c => { c.preventDefault(), c.stopPropagation(), document.addEventListener("mousemove", d), document.addEventListener("mouseup", g), document.body.style.cursor = "col-resize" } , d = c => { if (!a.current) return; let u = c.clientX - a.current.getBoundingClientRect().right , h = `${a.current.getBoundingClientRect().width + u}px`; a.current.style.width = h, i(n, a.current.style.width), l(-u) } , g = () => { a.current && (document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", g), document.body.style.cursor = "initial", i(n, a.current.style.width), l(0)) } ; return e.jsx("div", { ref: o, onClick: c => c.stopPropagation(), onMouseDown: s, onDoubleClick: () => { a.current && (a.current.style.maxWidth = "initial", a.current.style.minWidth = "initial", a.current.style.width = "initial", i(n, "initial")) } , className: "mantine-datatable-header-resizable-handle", style: { right: N(r) } }) } ; function Fs() { return e.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round", children: [e.jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), e.jsx("path", { d: "M12 5l0 14" }), e.jsx("path", { d: "M16 9l-4 -4" }), e.jsx("path", { d: "M8 9l4 -4" })] }) } function Ks() { return e.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round", children: [e.jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), e.jsx("path", { d: "M8 7l4 -4l4 4" }), e.jsx("path", { d: "M8 17l4 4l4 -4" }), e.jsx("path", { d: "M12 3l0 18" })] }) } function _s() { return e.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round", children: [e.jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), e.jsx("path", { d: "M9 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }), e.jsx("path", { d: "M9 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }), e.jsx("path", { d: "M9 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }), e.jsx("path", { d: "M15 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }), e.jsx("path", { d: "M15 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }), e.jsx("path", { d: "M15 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" })] }) } function qs() { return e.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round", children: [e.jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), e.jsx("path", { d: "M18 6l-12 12" }), e.jsx("path", { d: "M6 6l12 12" })] }) } function Qs({className: t, style: n, accessor: a, visibleMediaQuery: o, title: r, sortable: l, draggable: i, toggleable: s, resizable: d, sortIcons: g, textAlign: c, width: u, sortStatus: h, onSortStatusChange: m, filter: b, filterPopoverProps: P, filtering: T, sortKey: p}) { let {setSourceColumn: v, setTargetColumn: k, swapColumns: j, setColumnsToggle: x} = zt() , [y,C] = f.useState(!1) , S = f.useRef(null); if (!mt(o)) return null; let I = r ?? Lt(a) , w = typeof I == "string" ? I : void 0 , M = l && m ? z => { z != null && z.defaultPrevented || m({ sortKey: p, columnAccessor: a, direction: (h == null ? void 0 : h.columnAccessor) === a ? h.direction === "asc" ? "desc" : "asc" : (h == null ? void 0 : h.direction) ?? "asc" }) } : void 0 , B = z => { z.stopPropagation(), v(a), C(!1) } , O = z => { z.preventDefault(), k(a), C(!0) } , te = () => { k(a), C(!1), j() } , ne = () => { C(!0) } , le = () => { C(!1) } , ae = z => { z.stopPropagation(), x(ce => ce.map(se => se.accessor === a ? { ...se, toggled: !1 } : se)) } ; return e.jsxs(Qe, { className: A({ "mantine-datatable-header-cell-sortable": l, "mantine-datatable-header-cell-toggleable": s, "mantine-datatable-header-cell-resizable": d }, t), style: [{ width: u, ...d ? { minWidth: "1px" } : { minWidth: u, maxWidth: u } }, n], role: l ? "button" : void 0, tabIndex: l ? 0 : void 0, onClick: M, onKeyDown: z => z.key === "Enter" && (M == null ? void 0 : M()), ref: S, children: [e.jsxs(De, { className: "mantine-datatable-header-cell-sortable-group", justify: "space-between", wrap: "nowrap", children: [e.jsxs(E, { align: "center", w: "100%", className: A({ "mantine-datatable-header-cell-draggable": i, "mantine-datatable-header-cell-drag-over": y }), draggable: i, onDragStart: i ? B : void 0, onDragEnter: i ? ne : void 0, onDragOver: i ? O : void 0, onDrop: i ? te : void 0, onDragLeave: i ? le : void 0, children: [i ? e.jsx(Ne, { role: "img", "aria-label": "Drag column", children: e.jsx($, { className: "mantine-datatable-header-cell-draggable-action-icon", variant: "subtle", size: "xs", onClick: z => { z.stopPropagation() } , children: e.jsx(_s, {}) }) }) : null, e.jsx(Y, { className: A("mantine-datatable-header-cell-sortable-text", { [pt]: c === "left", [ft]: c === "center", [xt]: c === "right" }, Ut, Ot), title: w, children: I })] }), s ? e.jsx(Ne, { className: "mantine-datatable-header-cell-toggleable-icon", role: "img", "aria-label": "Toggle column", children: e.jsx($, { size: "xs", variant: "light", onClick: ae, children: e.jsx(qs, {}) }) }) : null, l || (h == null ? void 0 : h.columnAccessor) === a ? e.jsx(e.Fragment, { children: (h == null ? void 0 : h.columnAccessor) === a ? e.jsx(Ne, { className: A("mantine-datatable-header-cell-sortable-icon", { "mantine-datatable-header-cell-sortable-icon-reversed": h.direction === "desc" }), role: "img", "aria-label": `Sorted ${h.direction === "desc" ? "descending" : "ascending"}`, children: (g == null ? void 0 : g.sorted) || e.jsx(Fs, {}) }) : e.jsx(Ne, { className: "mantine-datatable-header-cell-sortable-unsorted-icon", role: "img", "aria-label": "Not sorted", children: (g == null ? void 0 : g.unsorted) || e.jsx(Ks, {}) }) }) : null, b ? e.jsx(Vs, { filterPopoverProps: P, isActive: !!T, children: b }) : null] }), d ? e.jsx(Hs, { accessor: a, columnRef: S }) : null] }) } var Xs = f.forwardRef(function({className: t, style: n, trigger: a, shadowVisible: o, checked: r, indeterminate: l, checkboxProps: i, onChange: s, rowSpan: d}, g) { let c = !i.disabled; return e.jsx(Qe, { ref: g, className: A("mantine-datatable-header-selector-cell", { [Ae]: a === "cell" && c }, t), style: n, rowSpan: d, "data-shadow-visible": o || void 0, onClick: a === "cell" && c ? s : void 0, children: e.jsx(At, { classNames: c ? { input: Ae } : void 0, checked: r, indeterminate: l, onChange: s, ...i, disabled: !(s || i.onChange) || i.disabled }) }) }) , Js = f.forwardRef(function({selectionColumnHeaderRef: t, className: n, style: a, sortStatus: o, sortIcons: r, onSortStatusChange: l, columns: i, defaultColumnProps: s, groups: d, selectionTrigger: g, selectionVisible: c, selectionChecked: u, selectionIndeterminate: h, onSelectionChange: m, selectionCheckboxProps: b, selectorCellShadowVisible: P, selectionColumnClassName: T, selectionColumnStyle: p}, v) { let k = c ? e.jsx(Xs, { ref: t, className: T, style: p, trigger: g, shadowVisible: P, checked: u, indeterminate: h, checkboxProps: b, onChange: m, rowSpan: d ? 2 : void 0 }) : null , {columnsToggle: j, setColumnsToggle: x} = zt() , [y,C] = f.useState(!1) , S = i.some(M => M.toggleable) , I = S ? Object.fromEntries(i.map( ({accessor: M, title: B}) => [M, B ?? Lt(String(M))])) : void 0 , w = e.jsxs(qa, { className: A("mantine-datatable-header", n), style: a, ref: v, onContextMenu: S ? M => { M.preventDefault(), C(B => !B) } : void 0, children: [d && e.jsxs(we, { children: [k, d.map(M => e.jsx(Us, { group: M }, M.id))] }), e.jsxs(we, { children: [!d && k, i.map( ({hidden: M, ...B}, O) => { if (M) return null; let {accessor: te, visibleMediaQuery: ne, textAlign: le, width: ae, title: z, sortable: ce, draggable: se, toggleable: Be, resizable: We, titleClassName: ze, titleStyle: Le, filter: Ue, filterPopoverProps: me, filtering: pe, sortKey: Oe} = { ...s, ...B }; return e.jsx(Qs, { accessor: te, className: ze, style: Le, visibleMediaQuery: ne, textAlign: le, width: ae, title: z, sortable: ce, draggable: se, toggleable: Be, resizable: We && O < i.length - 1, sortStatus: o, sortIcons: r, sortKey: Oe, onSortStatusChange: l, filter: Ue, filterPopoverProps: me, filtering: pe }, te) } )] })] }); return S ? e.jsxs(bn, { position: "bottom", withArrow: !0, shadow: "md", opened: y, onChange: C, children: [e.jsx(Cn, { children: w }), e.jsx(vn, { children: e.jsx(qe, { children: j.filter(M => M.toggleable).map(M => e.jsx(De, { children: e.jsx(At, { classNames: { label: "mantine-datatable-header-column-toggle-checkbox-label" }, size: "xs", label: I[M.accessor], checked: M.toggled, onChange: B => { x(j.map(O => O.accessor === M.accessor ? { ...O, toggled: B.currentTarget.checked } : O)) } }) }, M.accessor)) }) })] }) : w }); function Ys({pt: t, pb: n, fetching: a, customContent: o, backgroundBlur: r, size: l, type: i, color: s}) { return e.jsx(Ne, { pt: t, pb: n, className: A("mantine-datatable-loader", { "mantine-datatable-loader-fetching": a }), style: [{ backdropFilter: r ? `blur(${r}px)` : void 0 }], children: a && (o || e.jsx(so, { size: l, type: i, color: s })) }) } function L(t, n, a) { return t ? to({ color: typeof t == "object" ? t[a] : t, theme: n }).value : void 0 } function Gs({theme: t, c: n, backgroundColor: a, borderColor: o, rowBorderColor: r, stripedColor: l, highlightOnHoverColor: i}) { return { "--mantine-datatable-color-light": L(n, t, "light"), "--mantine-datatable-color-dark": L(n, t, "dark"), "--mantine-datatable-background-color-light": L(a, t, "light"), "--mantine-datatable-background-color-dark": L(a, t, "dark"), "--mantine-datatable-border-color-light": L(o, t, "light"), "--mantine-datatable-border-color-dark": L(o, t, "dark"), "--mantine-datatable-row-border-color-light": L(r, t, "light"), "--mantine-datatable-row-border-color-dark": L(r, t, "dark"), "--mantine-datatable-striped-color-light": L(l, t, "light"), "--mantine-datatable-striped-color-dark": L(l, t, "dark"), "--mantine-datatable-highlight-on-hover-color-light": L(i, t, "light"), "--mantine-datatable-highlight-on-hover-color-dark": L(i, t, "dark") } } function Tn({theme: t, paginationActiveTextColor: n, paginationActiveBackgroundColor: a}) { return { "--mantine-datatable-pagination-active-text-color-light": L(n, t, "light"), "--mantine-datatable-pagination-active-text-color-dark": L(n, t, "dark"), "--mantine-datatable-pagination-active-background-color-light": L(a, t, "light"), "--mantine-datatable-pagination-active-background-color-dark": L(a, t, "dark") } } function Zs({theme: t, color: n, backgroundColor: a}) { return { "--mantine-datatable-row-color-light": L(n, t, "light"), "--mantine-datatable-row-color-dark": L(n, t, "dark"), "--mantine-datatable-row-background-color-light": L(a, t, "light"), "--mantine-datatable-row-background-color-dark": L(a, t, "dark") } } function er() { return e.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round", children: [e.jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), e.jsx("path", { d: "M8 9l4 -4l4 4" }), e.jsx("path", { d: "M16 15l-4 4l-4 -4" })] }) } var rn = { xs: N(22), sm: N(26), md: N(32), lg: N(38), xl: N(44) }; function tr({size: t, label: n, values: a, value: o, activeTextColor: r, activeBackgroundColor: l, onChange: i}) { return e.jsxs(De, { gap: "xs", children: [e.jsx(Q, { component: "div", size: t, children: n }), e.jsxs(Xa, { withinPortal: !0, withArrow: !0, classNames: { arrow: "mantine-datatable-page-size-selector-menu-arrow" }, children: [e.jsx(Ja, { children: e.jsx(Z, { size: t, variant: "default", classNames: { section: "mantine-datatable-page-size-selector-button-icon" }, rightSection: e.jsx(er, {}), style: [{ fontWeight: "normal" }, s => ({ height: rn[t], paddingLeft: s.spacing[t], paddingRight: s.spacing[t] })], children: o }) }), e.jsx(Ya, { children: a.map(s => { let d = s === o; return e.jsx(Ga, { className: A({ "mantine-datatable-page-size-selector-active": d }), style: [{ height: rn[t] }, d && (r || l) ? g => Tn({ theme: g, paginationActiveTextColor: r, paginationActiveBackgroundColor: l }) : void 0], disabled: d, onClick: () => i(s), children: e.jsx(Q, { component: "div", size: t, children: s }) }, s) } ) })] })] }) } var nr = f.forwardRef(function({className: t, style: n, fetching: a, page: o, onPageChange: r, paginationWithEdges: l, paginationWithControls: i, paginationActiveTextColor: s, paginationActiveBackgroundColor: d, paginationSize: g, loadingText: c, noRecordsText: u, paginationText: h, totalRecords: m, recordsPerPage: b, onRecordsPerPageChange: P, recordsPerPageLabel: T, recordsPerPageOptions: p, recordsLength: v, horizontalSpacing: k, paginationWrapBreakpoint: j, getPaginationControlProps: x}, y) { let C; if (m) { let I = (o - 1) * b + 1 , w = I + (v || 0) - 1; C = h({ from: I, to: w, totalRecords: m }) } else C = a ? c : u; let S = mt( ({breakpoints: I}) => `(min-width: ${typeof j == "number" ? `${N(j)}rem` : I[j] || j})`); return e.jsxs(Y, { ref: y, px: k ?? "xs", py: "xs", className: A("mantine-datatable-pagination", t), style: [{ flexDirection: S ? "row" : "column" }, n], children: [e.jsx(Q, { component: "div", className: "mantine-datatable-pagination-text", size: g, children: C }), p && e.jsx(tr, { activeTextColor: s, activeBackgroundColor: d, size: g, label: T, values: p, value: b, onChange: P }), e.jsx(ht, { classNames: { root: A("mantine-datatable-pagination-pages", { "mantine-datatable-pagination-pages-fetching": a || !v }), control: "mantine-datatable-pagination-pages-control" }, style: s || d ? I => Tn({ theme: I, paginationActiveTextColor: s, paginationActiveBackgroundColor: d }) : void 0, withEdges: l, withControls: i, value: o, onChange: r, size: g, total: Math.ceil(m / b), getControlProps: x })] }) }); function ar({className: t, style: n, visibleMediaQuery: a, record: o, index: r, onClick: l, onDoubleClick: i, onContextMenu: s, noWrap: d, ellipsis: g, textAlign: c, width: u, accessor: h, render: m, defaultRender: b, customCellAttributes: P}) { return mt(a) ? e.jsx(Bt, { className: A({ [Ut]: d || g, [Ot]: g, [Ae]: l || i, [Pn]: s, [pt]: c === "left", [ft]: c === "center", [xt]: c === "right" }, t), style: [{ width: u, minWidth: u, maxWidth: u }, n], onClick: l, onDoubleClick: i, onContextMenu: s, ...P == null ? void 0 : P(o, r), children: m ? m(o, r) : b ? b(o, r, h) : Sn(o, h) }) : null } function or({open: t, colSpan: n, content: a, collapseProps: o}) { let {expanded: r, visible: l} = As(t, o == null ? void 0 : o.transitionDuration); return l ? e.jsxs(e.Fragment, { children: [e.jsx(we, {}), e.jsx(we, { children: e.jsx(Bt, { className: "mantine-datatable-row-expansion-cell", colSpan: n, children: e.jsx(io, { in: r, ...o, children: e.jsx("div", { className: "mantine-datatable-row-expansion-cell-content", children: a() }) }) }) })] }) : null } function sr({className: t, style: n, record: a, index: o, trigger: r, onChange: l, withRightShadow: i, checkboxProps: s, getCheckboxProps: d, ...g}) { let c = { ...s, ...d(a, o) } , u = !g.disabled && !c.disabled , h = m => { m.stopPropagation(), r === "cell" && u && (l == null || l(m)) } ; return e.jsx(Bt, { className: A("mantine-datatable-row-selector-cell", { [Ae]: r === "cell" && u }, t), style: n, "data-shadow-visible": i || void 0, onClick: h, children: e.jsx(At, { classNames: u ? { input: Ae } : void 0, onChange: l, ...g, ...c }) }) } function rr({record: t, index: n, columns: a, defaultColumnProps: o, defaultColumnRender: r, selectionTrigger: l, selectionVisible: i, selectionChecked: s, onSelectionChange: d, isRecordSelectable: g, selectionCheckboxProps: c, getSelectionCheckboxProps: u, onClick: h, onDoubleClick: m, onContextMenu: b, onCellClick: P, onCellDoubleClick: T, onCellContextMenu: p, expansion: v, customAttributes: k, color: j, backgroundColor: x, className: y, style: C, selectorCellShadowVisible: S, selectionColumnClassName: I, selectionColumnStyle: w, rowFactory: M}) { let B = e.jsxs(e.Fragment, { children: [i && e.jsx(sr, { className: I, style: w, record: t, index: n, trigger: l, withRightShadow: S, checked: s, disabled: !d || (g ? !g(t, n) : !1), onChange: d, checkboxProps: c, getCheckboxProps: u }), a.map( ({hidden: ne, hiddenContent: le, ...ae}, z) => { if (ne || le) return null; let {accessor: ce, visibleMediaQuery: se, textAlign: Be, noWrap: We, ellipsis: ze, width: Le, render: Ue, cellsClassName: me, cellsStyle: pe, customCellAttributes: Oe} = { ...o, ...ae }; return e.jsx(ar, { className: typeof me == "function" ? me(t, n) : me, style: pe == null ? void 0 : pe(t, n), visibleMediaQuery: se, record: t, index: n, onClick: P ? fe => P({ event: fe, record: t, index: n, column: ae, columnIndex: z }) : void 0, onDoubleClick: T ? fe => T({ event: fe, record: t, index: n, column: ae, columnIndex: z }) : void 0, onContextMenu: p ? fe => p({ event: fe, record: t, index: n, column: ae, columnIndex: z }) : void 0, accessor: ce, textAlign: Be, noWrap: We, ellipsis: ze, width: Le, render: Ue, defaultRender: r, customCellAttributes: Oe }, ce) } )] }) , O = v && e.jsx(or, { colSpan: a.filter( ({hidden: ne}) => !ne).length + (i ? 1 : 0), open: v.isRowExpanded(t), content: v.content({ record: t, index: n }), collapseProps: v.collapseProps }) , te = ir({ record: t, index: n, selectionChecked: s, onClick: h, onDoubleClick: m, onContextMenu: b, expansion: v, customAttributes: k, color: j, backgroundColor: x, className: y, style: C }); return M ? M({ record: t, index: n, rowProps: te, children: B, expandedElement: O }) : e.jsxs(e.Fragment, { children: [e.jsx(we, { ...te, children: B }), O] }) } function ir({record: t, index: n, selectionChecked: a, onClick: o, onDoubleClick: r, onContextMenu: l, expansion: i, customAttributes: s, color: d, backgroundColor: g, className: c, style: u}) { return { className: A("mantine-datatable-row", { [Ae]: o || r || (i == null ? void 0 : i.isExpandable({ record: t, index: n })) && (i == null ? void 0 : i.expandOnClick) }, { [Pn]: l }, typeof c == "function" ? c(t, n) : c), "data-selected": a || void 0, onClick: h => { if (i) { let {isExpandable: m, isRowExpanded: b, expandOnClick: P, expandRow: T, collapseRow: p} = i; m({ record: t, index: n }) && P && (b(t) ? p(t) : T(t)) } o == null || o({ event: h, record: t, index: n }) } , onDoubleClick: r ? h => r({ event: h, record: t, index: n }) : void 0, onContextMenu: l ? h => l({ event: h, record: t, index: n }) : void 0, style: [d || g ? h => { let m = d == null ? void 0 : d(t, n) , b = g == null ? void 0 : g(t, n); return Zs({ theme: h, color: m, backgroundColor: b }) } : void 0, u == null ? void 0 : u(t, n)], ...(s == null ? void 0 : s(t, n)) ?? {} } } function lr({topShadowVisible: t, leftShadowVisible: n, leftShadowBehind: a, rightShadowVisible: o, rightShadowBehind: r, bottomShadowVisible: l, headerHeight: i, footerHeight: s, onScrollPositionChange: d, children: g, viewportRef: c, scrollAreaProps: u}) { return e.jsxs(ro, { ...u, viewportRef: c, classNames: { root: "mantine-datatable-scroll-area", scrollbar: "mantine-datatable-scroll-area-scrollbar", thumb: "mantine-datatable-scroll-area-thumb", corner: "mantine-datatable-scroll-area-corner" }, onScrollPositionChange: d, children: [g, e.jsx(Y, { className: A("mantine-datatable-scroll-area-shadow", "mantine-datatable-scroll-area-top-shadow", { "mantine-datatable-scroll-area-shadow-visible": t }), style: { top: i ? N(i) : 0 } }), e.jsx("div", { className: A("mantine-datatable-scroll-area-shadow", "mantine-datatable-scroll-area-left-shadow", { "mantine-datatable-scroll-area-shadow-visible": n, "mantine-datatable-scroll-area-shadow-behind": a }) }), e.jsx("div", { className: A("mantine-datatable-scroll-area-shadow", "mantine-datatable-scroll-area-right-shadow", { "mantine-datatable-scroll-area-shadow-visible": o, "mantine-datatable-scroll-area-shadow-behind": r }) }), e.jsx(Y, { className: A("mantine-datatable-scroll-area-shadow", "mantine-datatable-scroll-area-bottom-shadow", { "mantine-datatable-scroll-area-shadow-visible": l }), style: { bottom: s ? N(s + 1) : 0 } })] }) } function dt({withTableBorder: t, borderRadius: n, textSelectionDisabled: a, height: o="100%", minHeight: r, maxHeight: l, shadow: i, verticalAlign: s="center", fetching: d, columns: g, storeColumnsKey: c, groups: u, pinFirstColumn: h, pinLastColumn: m, defaultColumnProps: b, defaultColumnRender: P, idAccessor: T="id", records: p, selectionTrigger: v="checkbox", selectedRecords: k, onSelectedRecordsChange: j, selectionColumnClassName: x, selectionColumnStyle: y, isRecordSelectable: C, selectionCheckboxProps: S, allRecordsSelectionCheckboxProps: I={ "aria-label": "Select all records" }, getRecordSelectionCheckboxProps: w= (G, xe) => ({ "aria-label": `Select record ${xe + 1}` }), sortStatus: M, sortIcons: B, onSortStatusChange: O, horizontalSpacing: te, page: ne, onPageChange: le, totalRecords: ae, recordsPerPage: z, onRecordsPerPageChange: ce, recordsPerPageOptions: se, recordsPerPageLabel: Be="Records per page", paginationWithEdges: We, paginationWithControls: ze, paginationActiveTextColor: Le, paginationActiveBackgroundColor: Ue, paginationSize: me="sm", paginationText: pe= ({from: G, to: xe, totalRecords: be}) => `${G} - ${xe} / ${be}`, paginationWrapBreakpoint: Oe="sm", getPaginationControlProps: fe=G => G === "previous" ? { "aria-label": "Previous page" } : G === "next" ? { "aria-label": "Next page" } : {}, loaderBackgroundBlur: Nn, customLoader: En, loaderSize: Dn, loaderType: An, loaderColor: Bn, loadingText: Wn="...", emptyState: zn, noRecordsText: $t="No records", noRecordsIcon: Ln, highlightOnHover: Un, striped: On, noHeader: $n, onRowClick: Vn, onRowDoubleClick: Hn, onRowContextMenu: Fn, onCellClick: Kn, onCellDoubleClick: _n, onCellContextMenu: qn, onScroll: Xe, onScrollToTop: Je, onScrollToBottom: Ye, onScrollToLeft: Ge, onScrollToRight: Ze, c: Qn, backgroundColor: Xn, borderColor: Jn, rowBorderColor: Yn, stripedColor: Gn, highlightOnHoverColor: Zn, rowColor: ea, rowBackgroundColor: ta, rowExpansion: na, rowClassName: aa, rowStyle: oa, customRowAttributes: sa, scrollViewportRef: ra, scrollAreaProps: ia, tableRef: la, bodyRef: ca, m: da, my: ua, mx: ha, mt: ga, mb: ma, ml: pa, mr: fa, className: xa, classNames: V, style: ba, styles: H, rowFactory: Ca, tableWrapper: Ct, ...Vt}) { let {ref: G, width: xe, height: be} = Ie() , $e = f.useMemo( () => (u == null ? void 0 : u.flatMap(R => R.columns)) ?? g, [g, u]) , Ht = Ss({ key: c, columns: $e }) , {ref: va, height: vt} = Ie() , {ref: ja, width: jt, height: Ve} = Ie() , {ref: ka, height: ya} = Ie() , {ref: wa, height: Ft} = Ie() , {ref: Sa, width: Pa} = Ie() , Ta = Nt(ja, la) , Ma = Nt(G, ra) , [kt,Kt] = f.useState(!0) , [yt,_t] = f.useState(!0) , [He,qt] = f.useState(!0) , [et,Qt] = f.useState(!0) , Ia = Ds({ rowExpansion: na, records: p, idAccessor: T }) , wt = f.useCallback( () => { var Pe, Te; let R = ((Pe = G.current) == null ? void 0 : Pe.scrollTop) ?? 0 , ee = ((Te = G.current) == null ? void 0 : Te.scrollLeft) ?? 0; if (d || Ve <= be) Kt(!0), _t(!0); else { let oe = R === 0 , re = Ve - R - be < 1; Kt(oe), _t(re), oe && oe !== kt && (Je == null || Je()), re && re !== yt && (Ye == null || Ye()) } if (d || jt === xe) qt(!0), Qt(!0); else { let oe = ee === 0 , re = jt - ee - xe < 1; qt(oe), Qt(re), oe && oe !== He && (Ge == null || Ge()), re && re !== et && (Ze == null || Ze()) } } , [d, Ye, Ge, Ze, Je, be, G, xe, yt, He, et, kt, Ve, jt]); Ps(wt, [wt]); let Xt = no(wt, 50) , Ra = f.useCallback(R => { Xe == null || Xe(R), Xt() } , [Xt, Xe]) , Na = f.useCallback(R => { var ee; (ee = G.current) == null || ee.scrollTo({ top: 0, left: 0 }), le(R) } , [le, G]) , tt = p == null ? void 0 : p.length , Jt = p == null ? void 0 : p.map(R => F(R, T)) , Se = !!k , Ce = k == null ? void 0 : k.map(R => F(R, T)) , Yt = Jt !== void 0 && Ce !== void 0 && Ce.length > 0 , Fe = C ? p == null ? void 0 : p.filter(C) : p , nt = Fe == null ? void 0 : Fe.map(R => F(R, T)) , at = Yt && nt.every(R => Ce.includes(R)) , Ea = Yt && nt.some(R => Ce.includes(R)) , Da = f.useCallback( () => { k && j && j(at ? k.filter(R => !nt.includes(F(R, T))) : Tt([...k, ...Fe], R => F(R, T))) } , [at, T, j, nt, Fe, k]) , {lastSelectionChangeIndex: ot, setLastSelectionChangeIndex: Aa} = Ts(Jt) , St = Se && !He && !h , Ba = { m: da, my: ua, mx: ha, mt: ga, mb: ma, ml: pa, mr: fa } , Wa = f.useCallback( ({children: R}) => Ct ? Ct({ children: R }) : R, [Ct]); return e.jsx(sn, { ...Ht, children: e.jsxs(Y, { ...Ba, className: A("mantine-datatable", { "mantine-datatable-with-border": t }, xa, V == null ? void 0 : V.root), style: [R => ({ ...Gs({ theme: R, c: Qn, backgroundColor: Xn, borderColor: Jn, rowBorderColor: Yn, stripedColor: Gn, highlightOnHoverColor: Zn }), borderRadius: R.radius[n] || n, boxShadow: R.shadows[i] || i, height: o, minHeight: r, maxHeight: l }), ba, H == null ? void 0 : H.root, { position: "relative" }], children: [e.jsx(lr, { viewportRef: Ma, topShadowVisible: !kt, leftShadowVisible: !He, leftShadowBehind: Se || !!h, rightShadowVisible: !et, rightShadowBehind: m, bottomShadowVisible: !yt, headerHeight: vt, footerHeight: ya, onScrollPositionChange: Ra, scrollAreaProps: ia, children: e.jsx(Wa, { children: e.jsxs(ao, { ref: Ta, horizontalSpacing: te, className: A("mantine-datatable-table", { [Bs]: a, "mantine-datatable-vertical-align-top": s === "top", "mantine-datatable-vertical-align-bottom": s === "bottom", "mantine-datatable-last-row-border-bottom-visible": Vt.withRowBorders && Ve < be, "mantine-datatable-pin-last-column": m, "mantine-datatable-pin-last-column-scrolled": !et && m, "mantine-datatable-selection-column-visible": Se, "mantine-datatable-pin-first-column": h, "mantine-datatable-pin-first-column-scrolled": !He && h }, V == null ? void 0 : V.table), style: { ...H == null ? void 0 : H.table, "--mantine-datatable-selection-column-width": `${Pa}px` }, "data-striped": tt && On || void 0, "data-highlight-on-hover": Un || void 0, ...Vt, children: [$n ? null : e.jsx(sn, { ...Ht, children: e.jsx(Js, { ref: va, selectionColumnHeaderRef: Sa, className: V == null ? void 0 : V.header, style: H == null ? void 0 : H.header, columns: $e, defaultColumnProps: b, groups: u, sortStatus: M, sortIcons: B, onSortStatusChange: O, selectionTrigger: v, selectionVisible: Se, selectionChecked: at, selectionIndeterminate: Ea && !at, onSelectionChange: Da, selectionCheckboxProps: { ...S, ...I }, selectorCellShadowVisible: St, selectionColumnClassName: x, selectionColumnStyle: y }) }), e.jsx("tbody", { ref: ca, children: tt ? p.map( (R, ee) => { let Pe = F(R, T), Te = (Ce == null ? void 0 : Ce.includes(Pe)) || !1, oe; return j && k && (oe = re => { if (re.nativeEvent.shiftKey && ot !== null) { let Me = p.filter(ee > ot ? (ve, je) => je >= ot && je <= ee && (C ? C(ve, je) : !0) : (ve, je) => je >= ee && je <= ot && (C ? C(ve, je) : !0)); j(Te ? Es(k, Me, ve => F(ve, T)) : Tt([...k, ...Me], ve => F(ve, T))) } else j(Te ? k.filter(Me => F(Me, T) !== Pe) : Tt([...k, R], Me => F(Me, T))); Aa(ee) } ), e.jsx(rr, { record: R, index: ee, columns: $e, defaultColumnProps: b, defaultColumnRender: P, selectionTrigger: v, selectionVisible: Se, selectionChecked: Te, onSelectionChange: oe, isRecordSelectable: C, selectionCheckboxProps: S, getSelectionCheckboxProps: w, onClick: Vn, onDoubleClick: Hn, onCellClick: Kn, onCellDoubleClick: _n, onContextMenu: Fn, onCellContextMenu: qn, expansion: Ia, color: ea, backgroundColor: ta, className: aa, style: oa, customAttributes: sa, selectorCellShadowVisible: St, selectionColumnClassName: x, selectionColumnStyle: y, idAccessor: T, rowFactory: Ca }, Pe) } ) : e.jsx(ks, {}) }), $e.some( ({footer: R}) => R) && e.jsx(Ls, { ref: ka, className: V == null ? void 0 : V.footer, style: H == null ? void 0 : H.footer, columns: $e, defaultColumnProps: b, selectionVisible: Se, selectorCellShadowVisible: St, scrollDiff: Ve - be })] }) }) }), ne && e.jsx(nr, { ref: wa, className: V == null ? void 0 : V.pagination, style: H == null ? void 0 : H.pagination, horizontalSpacing: te, fetching: d, page: ne, onPageChange: Na, totalRecords: ae, recordsPerPage: z, onRecordsPerPageChange: ce, recordsPerPageOptions: se, recordsPerPageLabel: Be, paginationWithEdges: We, paginationWithControls: ze, paginationActiveTextColor: Le, paginationActiveBackgroundColor: Ue, paginationSize: me, paginationText: pe, paginationWrapBreakpoint: Oe, getPaginationControlProps: fe, noRecordsText: $t, loadingText: Wn, recordsLength: tt }), e.jsx(Ys, { pt: vt, pb: Ft, fetching: d, backgroundBlur: Nn, customContent: En, size: Dn, type: An, color: Bn }), e.jsx(ws, { pt: vt, pb: Ft, icon: Ln, text: $t, active: !d && !tt, children: zn })] }) }) } var cr = f.forwardRef(function({children: t, isDragging: n, ...a}, o) { let r = f.useRef(null) , l = Nt(r, o); return f.useEffect( () => { if (!r.current || !n) return; let i = r.current.parentElement.parentElement.children[0].children[0]; for (let s = 0; s < i.children.length; s++) { let d = i.children[s].getBoundingClientRect() , g = r.current.children[s]; g.style.height = d.height + "px", g.style.width = d.width + "px", g.style.minWidth = d.width + "px", g.style.maxWidth = d.width + "px" } } , [n, t]), e.jsx(we, { "data-is-dragging": n, ref: l, ...a, children: t }) }); cr.displayName = "DataTableDraggableRow"; const dr = "_icon_1t3nk_1" , ur = "_expandIcon_1t3nk_8" , hr = "_expandIconRotated_1t3nk_12" , gr = "_usersTableBorder_1t3nk_16" , J = { icon: dr, expandIcon: ur, expandIconRotated: hr, usersTableBorder: gr } , Mn = ({element: t, isSection: n, level: a=1}) => { const {onCreateDepartmentClick: o, onUpdateDepartmentClick: r, onDeleteDepartmentClick: l, onAddUserClick: i} = gt() , s = (g, c, u) => e.jsx(q, { label: g, children: e.jsx($, { variant: "default", onClick: h => { h.stopPropagation(), c() } , children: u }) }, g) , d = [n && s("Добавить пользователя в отдел", () => i(t), e.jsx(Eo, {})), a < 9 && s("Добавить отдел", () => o(!0, { departmentId: n ? null : t.id, parentDepartmentSectionId: n ? t.id : null, name: "" }), e.jsx(Io, {})), s("Редактировать", () => r(t, n), e.jsx(ut, {})), s("Удалить", () => l(t, n), e.jsx(ge, {}))]; return e.jsxs(E, { gap: "md", mx: "md", direction: "row", children: [...d] }) } , mr = ({sectionId: t}) => { const {fetchDepartments: n} = gt() , a = o => { de.deleteUser({ requestBody: { sectionId: t, userId: o } }).then( ({ok: r, message: l}) => { n(), !r && D.error({ message: l }) } ).catch(r => console.log(r)) } ; return [{ title: "ФИО", accessor: "user.secondName", render: o => e.jsx(Y, { component: "span", children: e.jsxs("span", { children: [o.user.secondName, " ", o.user.firstName, " ", o.user.patronymic] }) }) }, { accessor: "user.role.name", title: "Роль" }, { accessor: "user.position.name", title: "Должность" }, { accessor: "user.comment", title: "Доп. информация" }, { accessor: "isChief", title: "Является руководителем", render: o => o.isChief ? e.jsx(lt, {}) : e.jsx(Mt, {}) }, { accessor: "actions", title: "", width: "0%", render: o => e.jsx(E, { gap: "md", mx: "md", children: e.jsx(q, { label: "Удалить", children: e.jsx($, { onClick: () => a(o.user.id), variant: "default", children: e.jsx(ge, {}) }) }) }) }] } , pr = ({users: t, sectionId: n, level: a}) => { const o = mr({ sectionId: n }) , [r,l] = f.useState([1]) , i = [{ id: 1, title: "Пользователи" }]; return e.jsx(dt, { noHeader: !0, withColumnBorders: !0, className: A(J.usersTableBorder), columns: [{ accessor: "title", noWrap: !0, render: ({id: s, title: d}) => e.jsxs(Y, { component: "span", ml: 20 * a, children: [e.jsx(Wt, { className: A(J.icon, J.expandIcon, { [J.expandIconRotated]: r.includes(s) }) }), e.jsx(Do, { className: J.icon }), e.jsx("span", { children: d })] }) }], records: i, rowExpansion: { allowMultiple: !0, expanded: { recordIds: r, onRecordIdsChange: l }, content: () => e.jsx(Y, { pl: 20 * (a + 2.5), children: e.jsx(dt, { withTableBorder: !0, withColumnBorders: !0, columns: o, records: t }) }) } }) } , In = ({parentItem: t, level: n}) => { var r, l; const [a,o] = f.useState(((r = t.sections) == null ? void 0 : r.map(i => i.id)) ?? []); return e.jsx(dt, { noHeader: !0, columns: [{ accessor: "name", noWrap: !0, render: ({id: i, name: s}) => e.jsxs(Y, { component: "span", ml: 20 * n, children: [e.jsx(Wt, { className: A(J.icon, J.expandIcon, { [J.expandIconRotated]: a.includes(i) }) }), e.jsx(jo, { className: J.icon }), e.jsx("span", { children: s })] }) }, { accessor: "actions", title: "", width: "0%", render: i => e.jsx(Mn, { element: i, isSection: !0, level: n }) }], records: (l = t.sections) == null ? void 0 : l.sort( (i, s) => i.id - s.id), rowExpansion: { allowMultiple: !0, expanded: { recordIds: a, onRecordIdsChange: o }, content: ({record: i}) => e.jsxs(qe, { gap: 0, children: [i.users && i.users.length > 0 && e.jsx(pr, { sectionId: i.id, users: i.users, level: n + 1 }, `1 ${i.id}`), i.sections && i.sections.length > 0 && e.jsx(In, { parentItem: i, level: n + 1 }, `2 ${i.id}`)] }) } }) } , fr = () => { const {departments: t} = gt() , [n,a] = f.useState([]); let o = !0; return f.useEffect( () => { o && t && (o = !1, a(t.map(r => r.id))) } , [t]), e.jsx(dt, { noHeader: !0, withTableBorder: !0, columns: [{ accessor: "name", title: "Департамент", noWrap: !0, render: ({id: r, name: l}) => e.jsxs(e.Fragment, { children: [e.jsx(Wt, { className: A(J.icon, J.expandIcon, { [J.expandIconRotated]: n == null ? void 0 : n.includes(r) }) }), e.jsx(ko, { className: J.icon }), e.jsx("span", { children: l })] }) }, { accessor: "actions", title: "", width: "0%", render: r => e.jsx(Mn, { element: r, isSection: !1 }) }], records: t.sort( (r, l) => r.id - l.id), rowExpansion: { allowMultiple: !0, expanded: { recordIds: n, onRecordIdsChange: a }, content: ({record: r}) => e.jsx(In, { parentItem: r, level: 1 }) } }) } , xr = () => { const {onCreateDepartmentClick: t} = gt(); return e.jsx(De, { gap: "md", children: e.jsx(Z, { variant: "default", onClick: () => t(!1), children: e.jsxs(De, { gap: N(10), children: [e.jsx(lo, {}), "Добавить департамент"] }) }) }) } , br = () => e.jsx(vs, { children: e.jsxs(qe, { mt: "md", children: [e.jsx(xr, {}), e.jsx(fr, {})] }) }) , Cr = () => e.jsxs(W, { keepMounted: !1, defaultValue: "departments", color: "gray.6", children: [e.jsxs(W.List, { justify: "center", grow: !0, children: [e.jsx(W.Tab, { value: "departments", leftSection: e.jsx(Ro, {}), children: "Департаменты и отделы" }), e.jsx(W.Tab, { value: "positions", leftSection: e.jsx(vo, {}), children: "Должности" })] }), e.jsx(W.Panel, { value: "departments", children: e.jsx(_e.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: .2 }, children: e.jsx(br, {}) }) }), e.jsx(W.Panel, { value: "positions", children: e.jsx(_e.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: .2 }, children: e.jsx(fs, {}) }) })] }) , vr = 14 , ln = t => { const n = t ?? new Date; return n.setDate(n.getDate() + vr), n } , Rn = f.createContext(void 0) , jr = () => { const [t,n] = it([]) , [a,o] = it([]) , [r,l] = f.useState([new Date, ln()]) , {objects: i} = Et() , [s,d] = it([]) , g = new Map(i.map(p => [p.id, p.position ? [p.position] : []])) , c = (p, v) => { d.setState(p), v || (v = t), o.setState(v.filter(k => p.findIndex(j => j.id === k.user.id) !== -1)) } , u = p => { c(p) } , h = p => { const v = []; p.forEach(j => { const x = { user: j.user, ...Object.fromEntries(j.shifts.reduce( (y, C) => y.set(ke(new Date(C.shiftDate)) ?? "", C.positions), new Map)) }; v.push(x) } ), n.setState(v); let k = s; k.length === 0 && (k = v.map(j => j.user)), i.forEach(j => { v.findIndex(x => x.user.id === j.id) === -1 && v.push({ user: j }) } ), v.sort( (j, x) => j.user.id - x.user.id), c(k, v) } , m = () => { const p = ke(r[0]) , v = ke(r[1]); p && v && nn.getWorkShifts({ requestBody: { dateFrom: p, dateTo: v } }).then(k => { h(k.shifts) } ).catch(k => console.log(k)) } , b = (p, v, k) => { const j = ke(v); j && nn.updateWorkShift({ requestBody: { userId: p, shiftDate: j, positionKeys: k } }).then( ({ok: x, message: y}) => { x || D.error({ message: y }), m() } ).catch(x => console.log(x)) } ; f.useEffect( () => { m() } , [r]); const T = ( () => { const p = r[0]; if (!p) return []; const v = r[1] ?? ln(new Date(p)); return It(p, v).map(j => j.toDate()) } )(); return { dateRange: r, setDateRange: l, tableRows: a, onUpdate: b, users: i, shownUsers: s, setShownUsers: u, userPositions: g, range: T } } , kr = ({children: t}) => { const n = jr(); return e.jsx(Rn.Provider, { value: n, children: t }) } , bt = () => { const t = f.useContext(Rn); if (!t) throw new Error("useWorkShiftsPlanningContext must be used within a WorkShiftsPlanningContextProvider"); return t } , yr = ({date: t, positions: n, user: a}) => { var l; const {onUpdate: o, userPositions: r} = bt(); return e.jsx(Dt, { data: (l = r.get(a.id)) == null ? void 0 : l.map(i => ({ value: i.key, label: i.name })), onChange: i => { o(a.id, t, i) } , value: (n == null ? void 0 : n.map(i => i.key)) ?? [], miw: N(140) }) } , wr = () => { const {range: t} = bt(); return f.useMemo( () => [{ accessorKey: "name", header: "ФИО", Cell: ({row: n}) => e.jsx(E, { direction: "column", children: e.jsxs(Q, { size: "sm", children: [n.original.user.firstName, " ", n.original.user.secondName] }) }) }, ...t.map(n => ({ size: 100, accessorKey: ke(n) ?? "", header: ke(n) ?? "", enableSorting: !1, enableColumnActions: !1, Header: e.jsxs(E, { direction: "column", children: [e.jsx(Y, { children: n.toLocaleString("ru").substring(0, 10) }), e.jsx(Y, { children: gn(n.getDay()) })] }), Cell: ({cell: a}) => e.jsx(E, { direction: "column", children: e.jsx(yr, { date: n, positions: a.getValue(), user: a.row.original.user }) }) }))], [t]) } , Sr = () => { const {tableRows: t, shownUsers: n, setShownUsers: a} = bt() , o = wr(); return e.jsx(he, { data: t, columns: o, restProps: { enableColumnActions: !1, enableSorting: !1, enableRowActions: !0, renderRowActions: ({row: r}) => e.jsx(E, { gap: "md", children: e.jsx(q, { label: "Скрыть", children: e.jsx($, { onClick: () => { a(n.filter(l => l.id !== r.original.user.id)) } , variant: "default", children: e.jsx(pn, {}) }) }) }) } }) } , Pr = ({shownUsers: t, setShownUsers: n, users: a}) => e.jsx(Dt, { data: a.map(o => ({ label: `${o.firstName} ${o.secondName}`, value: o.id.toString() })), onChange: o => n(a.filter(r => o.includes(r.id.toString()))), value: t.map(o => o.id.toString()), placeholder: t.length > 0 ? "" : "Показанные пользователи", searchable: !0 }) , Tr = () => { const {dateRange: t, setDateRange: n, users: a, shownUsers: o, setShownUsers: r} = bt(); return e.jsxs(E, { align: "center", justify: "space-between", gap: N(10), children: [e.jsx(Pr, { shownUsers: o, setShownUsers: r, users: a }), e.jsx(mn, { placeholder: "Выберите временной промежуток", type: "range", value: t, onChange: l => { n(l) } })] }) } , Mr = () => e.jsx(kr, { children: e.jsxs(qe, { p: N(10), gap: N(10), children: [e.jsx(Tr, {}), e.jsx(Sr, {})] }) }) , Ir = () => { const n = co(o => { console.log(o); return o.auth.role }) === "admin" , a = (o, r) => e.jsx(W.Panel, { value: o, children: e.jsx(_e.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: .2 }, children: r }) }); return e.jsx("div", { className: Bo.container, children: e.jsx(uo, { fullHeight: !0, children: e.jsxs(W, { variant: "outline", keepMounted: !1, defaultValue: "users", children: [e.jsxs(W.List, { children: [e.jsx(W.Tab, { value: "users", leftSection: e.jsx(ho, {}), children: "Пользователи" }), n && e.jsx(W.Tab, { value: "finances", leftSection: e.jsx(Po, {}), children: "Финансы" }), e.jsx(W.Tab, { value: "rolesAndPositions", leftSection: e.jsx(No, {}), children: "Организационная структура" }), n && e.jsx(W.Tab, { value: "workTimeTable", leftSection: e.jsx(go, {}), children: "Рабочее время" }), e.jsx(W.Tab, { value: "workShiftsPlanning", leftSection: e.jsx(wo, {}), children: "Планирование смен" }), e.jsx(W.Tab, { value: "workShifts", leftSection: e.jsx(cn, {}), children: "Смены" }), n && e.jsx(W.Tab, { value: "transactions", leftSection: e.jsx(So, {}), children: "Доходы и расходы" })] }), a("users", e.jsx($o, {})), a("rolesAndPositions", e.jsx(Cr, {})), a("finances", e.jsx(Qo, {})), a("workTimeTable", e.jsx(es, {})), a("workShiftsPlanning", e.jsx(Mr, {})), a("workShifts", e.jsx(ls, {})), a("transactions", e.jsx(gs, {}))] }) }) }) } , Er = mo("/admin")({ component: Ir }); export {Er as Route};