autoforma
Version:
AutoForma is a dynamic form builder based on Mantine and React
1,621 lines • 737 kB
JavaScript
var op = Object.defineProperty;
var ip = (n, e, t) => e in n ? op(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
var Ba = (n, e, t) => ip(n, typeof e != "symbol" ? e + "" : e, t);
import ht, { useLayoutEffect as Al, useEffect as Ge, useState as ke, useRef as xe, useCallback as Q, createContext as Co, useContext as Fu, forwardRef as $t, createElement as ai, useImperativeHandle as Yi, useDebugValue as Bu, useMemo as zu } from "react";
import { Grid as Vu, Group as Mo, Stack as wo, Box as ze, Paper as lp, Button as Os, Divider as ap, Checkbox as za, factory as Ce, useProps as ve, useResolvedStylesApi as _n, InputBase as Nl, createSafeContext as Hu, UnstyledButton as Ot, ScrollArea as qi, SimpleGrid as Rl, useStyles as vt, createVarsResolver as Fn, Popover as rt, CloseButton as cp, getFontSize as cr, getSize as To, getSpacing as up, AccordionChevron as Va, useInputProps as $u, Input as Zt, Modal as dp, ActionIcon as vn, CheckIcon as fp, NumberInput as Ha, Typography as hp, TextInput as Ki, Tooltip as Wu, rem as tt, ColorSwatch as Ui, ColorPicker as pp, Select as $a, Switch as Wa, TagsInput as Ya, Text as Zr, LoadingOverlay as mp } from "@mantine/core";
import N from "dayjs";
import gp from "react-dom";
function Ll(n) {
return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
}
var es = { exports: {} }, fr = {};
/**
* @license React
* react-jsx-runtime.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var qa;
function yp() {
if (qa) return fr;
qa = 1;
var n = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
function t(r, s, o) {
var i = null;
if (o !== void 0 && (i = "" + o), s.key !== void 0 && (i = "" + s.key), "key" in s) {
o = {};
for (var l in s)
l !== "key" && (o[l] = s[l]);
} else o = s;
return s = o.ref, {
$$typeof: n,
type: r,
key: i,
ref: s !== void 0 ? s : null,
props: o
};
}
return fr.Fragment = e, fr.jsx = t, fr.jsxs = t, fr;
}
var hr = {};
/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var Ka;
function bp() {
return Ka || (Ka = 1, process.env.NODE_ENV !== "production" && function() {
function n(k) {
if (k == null) return null;
if (typeof k == "function")
return k.$$typeof === $ ? null : k.displayName || k.name || null;
if (typeof k == "string") return k;
switch (k) {
case g:
return "Fragment";
case x:
return "Profiler";
case b:
return "StrictMode";
case v:
return "Suspense";
case M:
return "SuspenseList";
case P:
return "Activity";
}
if (typeof k == "object")
switch (typeof k.tag == "number" && console.error(
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
), k.$$typeof) {
case y:
return "Portal";
case w:
return k.displayName || "Context";
case S:
return (k._context.displayName || "Context") + ".Consumer";
case C:
var E = k.render;
return k = k.displayName, k || (k = E.displayName || E.name || "", k = k !== "" ? "ForwardRef(" + k + ")" : "ForwardRef"), k;
case T:
return E = k.displayName || null, E !== null ? E : n(k.type) || "Memo";
case O:
E = k._payload, k = k._init;
try {
return n(k(E));
} catch {
}
}
return null;
}
function e(k) {
return "" + k;
}
function t(k) {
try {
e(k);
var E = !1;
} catch {
E = !0;
}
if (E) {
E = console;
var D = E.error, j = typeof Symbol == "function" && Symbol.toStringTag && k[Symbol.toStringTag] || k.constructor.name || "Object";
return D.call(
E,
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
j
), e(k);
}
}
function r(k) {
if (k === g) return "<>";
if (typeof k == "object" && k !== null && k.$$typeof === O)
return "<...>";
try {
var E = n(k);
return E ? "<" + E + ">" : "<...>";
} catch {
return "<...>";
}
}
function s() {
var k = V.A;
return k === null ? null : k.getOwner();
}
function o() {
return Error("react-stack-top-frame");
}
function i(k) {
if (_.call(k, "key")) {
var E = Object.getOwnPropertyDescriptor(k, "key").get;
if (E && E.isReactWarning) return !1;
}
return k.key !== void 0;
}
function l(k, E) {
function D() {
Y || (Y = !0, console.error(
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
E
));
}
D.isReactWarning = !0, Object.defineProperty(k, "key", {
get: D,
configurable: !0
});
}
function a() {
var k = n(this.type);
return K[k] || (K[k] = !0, console.error(
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
)), k = this.props.ref, k !== void 0 ? k : null;
}
function c(k, E, D, j, W, ue) {
var A = D.ref;
return k = {
$$typeof: m,
type: k,
key: E,
props: D,
_owner: j
}, (A !== void 0 ? A : null) !== null ? Object.defineProperty(k, "ref", {
enumerable: !1,
get: a
}) : Object.defineProperty(k, "ref", { enumerable: !1, value: null }), k._store = {}, Object.defineProperty(k._store, "validated", {
configurable: !1,
enumerable: !1,
writable: !0,
value: 0
}), Object.defineProperty(k, "_debugInfo", {
configurable: !1,
enumerable: !1,
writable: !0,
value: null
}), Object.defineProperty(k, "_debugStack", {
configurable: !1,
enumerable: !1,
writable: !0,
value: W
}), Object.defineProperty(k, "_debugTask", {
configurable: !1,
enumerable: !1,
writable: !0,
value: ue
}), Object.freeze && (Object.freeze(k.props), Object.freeze(k)), k;
}
function u(k, E, D, j, W, ue) {
var A = E.children;
if (A !== void 0)
if (j)
if (q(A)) {
for (j = 0; j < A.length; j++)
d(A[j]);
Object.freeze && Object.freeze(A);
} else
console.error(
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
);
else d(A);
if (_.call(E, "key")) {
A = n(k);
var U = Object.keys(E).filter(function(X) {
return X !== "key";
});
j = 0 < U.length ? "{key: someKey, " + U.join(": ..., ") + ": ...}" : "{key: someKey}", L[A + j] || (U = 0 < U.length ? "{" + U.join(": ..., ") + ": ...}" : "{}", console.error(
`A props object containing a "key" prop is being spread into JSX:
let props = %s;
<%s {...props} />
React keys must be passed directly to JSX without using spread:
let props = %s;
<%s key={someKey} {...props} />`,
j,
A,
U,
A
), L[A + j] = !0);
}
if (A = null, D !== void 0 && (t(D), A = "" + D), i(E) && (t(E.key), A = "" + E.key), "key" in E) {
D = {};
for (var se in E)
se !== "key" && (D[se] = E[se]);
} else D = E;
return A && l(
D,
typeof k == "function" ? k.displayName || k.name || "Unknown" : k
), c(
k,
A,
D,
s(),
W,
ue
);
}
function d(k) {
f(k) ? k._store && (k._store.validated = 1) : typeof k == "object" && k !== null && k.$$typeof === O && (k._payload.status === "fulfilled" ? f(k._payload.value) && k._payload.value._store && (k._payload.value._store.validated = 1) : k._store && (k._store.validated = 1));
}
function f(k) {
return typeof k == "object" && k !== null && k.$$typeof === m;
}
var h = ht, m = Symbol.for("react.transitional.element"), y = Symbol.for("react.portal"), g = Symbol.for("react.fragment"), b = Symbol.for("react.strict_mode"), x = Symbol.for("react.profiler"), S = Symbol.for("react.consumer"), w = Symbol.for("react.context"), C = Symbol.for("react.forward_ref"), v = Symbol.for("react.suspense"), M = Symbol.for("react.suspense_list"), T = Symbol.for("react.memo"), O = Symbol.for("react.lazy"), P = Symbol.for("react.activity"), $ = Symbol.for("react.client.reference"), V = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, _ = Object.prototype.hasOwnProperty, q = Array.isArray, Z = console.createTask ? console.createTask : function() {
return null;
};
h = {
react_stack_bottom_frame: function(k) {
return k();
}
};
var Y, K = {}, z = h.react_stack_bottom_frame.bind(
h,
o
)(), H = Z(r(o)), L = {};
hr.Fragment = g, hr.jsx = function(k, E, D) {
var j = 1e4 > V.recentlyCreatedOwnerStacks++;
return u(
k,
E,
D,
!1,
j ? Error("react-stack-top-frame") : z,
j ? Z(r(k)) : H
);
}, hr.jsxs = function(k, E, D) {
var j = 1e4 > V.recentlyCreatedOwnerStacks++;
return u(
k,
E,
D,
!0,
j ? Error("react-stack-top-frame") : z,
j ? Z(r(k)) : H
);
};
}()), hr;
}
var Ua;
function xp() {
return Ua || (Ua = 1, process.env.NODE_ENV === "production" ? es.exports = yp() : es.exports = bp()), es.exports;
}
var p = xp();
function kp(n) {
if (!/^[0-9a-zA-Z-]+$/.test(n))
throw new Error(
`[@mantine/use-form] Form name "${n}" is invalid, it should contain only letters, numbers and dashes`
);
}
const vp = typeof window < "u" ? Al : Ge;
function He(n, e) {
vp(() => {
if (n)
return window.addEventListener(n, e), () => window.removeEventListener(n, e);
}, [n]);
}
function Sp(n, e) {
n && kp(n), He(
`mantine-form:${n}:set-field-value`,
(t) => e.setFieldValue(t.detail.path, t.detail.value)
), He(
`mantine-form:${n}:set-values`,
(t) => e.setValues(t.detail)
), He(
`mantine-form:${n}:set-initial-values`,
(t) => e.setInitialValues(t.detail)
), He(
`mantine-form:${n}:set-errors`,
(t) => e.setErrors(t.detail)
), He(
`mantine-form:${n}:set-field-error`,
(t) => e.setFieldError(t.detail.path, t.detail.error)
), He(
`mantine-form:${n}:clear-field-error`,
(t) => e.clearFieldError(t.detail)
), He(`mantine-form:${n}:clear-errors`, e.clearErrors), He(`mantine-form:${n}:reset`, e.reset), He(`mantine-form:${n}:validate`, e.validate), He(
`mantine-form:${n}:validate-field`,
(t) => e.validateField(t.detail)
), He(
`mantine-form:${n}:reorder-list-item`,
(t) => e.reorderListItem(t.detail.path, t.detail.payload)
), He(
`mantine-form:${n}:remove-list-item`,
(t) => e.removeListItem(t.detail.path, t.detail.index)
), He(
`mantine-form:${n}:insert-list-item`,
(t) => e.insertListItem(t.detail.path, t.detail.item, t.detail.index)
), He(
`mantine-form:${n}:set-dirty`,
(t) => e.setDirty(t.detail)
), He(
`mantine-form:${n}:set-touched`,
(t) => e.setTouched(t.detail)
), He(
`mantine-form:${n}:reset-dirty`,
(t) => e.resetDirty(t.detail)
), He(`mantine-form:${n}:reset-touched`, e.resetTouched);
}
function Cp(n) {
return (e) => {
if (!e)
n(e);
else if (typeof e == "function")
n(e);
else if (typeof e == "object" && "nativeEvent" in e) {
const { currentTarget: t } = e;
t instanceof HTMLInputElement ? t.type === "checkbox" ? n(t.checked) : n(t.value) : (t instanceof HTMLTextAreaElement || t instanceof HTMLSelectElement) && n(t.value);
} else
n(e);
};
}
function Ji(n) {
return n === null || typeof n != "object" ? {} : Object.keys(n).reduce((e, t) => {
const r = n[t];
return r != null && r !== !1 && (e[t] = r), e;
}, {});
}
function Mp(n) {
const [e, t] = ke(Ji(n)), r = xe(e), s = Q((a) => {
t((c) => {
const u = Ji(typeof a == "function" ? a(c) : a);
return r.current = u, u;
});
}, []), o = Q(() => s({}), []), i = Q(
(a) => {
r.current[a] !== void 0 && s((c) => {
const u = { ...c };
return delete u[a], u;
});
},
[e]
), l = Q(
(a, c) => {
c == null || c === !1 ? i(a) : r.current[a] !== c && s((u) => ({ ...u, [a]: c }));
},
[e]
);
return {
errorsState: e,
setErrors: s,
clearErrors: o,
setFieldError: l,
clearFieldError: i
};
}
function Gi(n, e) {
if (e === null || typeof e != "object")
return {};
const t = { ...e };
return Object.keys(e).forEach((r) => {
r.includes(`${String(n)}.`) && delete t[r];
}), t;
}
function Ja(n, e) {
const t = n.substring(e.length + 1).split(".")[0];
return parseInt(t, 10);
}
function Ga(n, e, t, r) {
if (e === void 0)
return t;
const s = `${String(n)}`;
let o = t;
r === -1 && (o = Gi(`${s}.${e}`, o));
const i = { ...o }, l = /* @__PURE__ */ new Set();
return Object.entries(o).filter(([a]) => {
if (!a.startsWith(`${s}.`))
return !1;
const c = Ja(a, s);
return Number.isNaN(c) ? !1 : c >= e;
}).forEach(([a, c]) => {
const u = Ja(a, s), d = a.replace(
`${s}.${u}`,
`${s}.${u + r}`
);
i[d] = c, l.add(d), l.has(a) || delete i[a];
}), i;
}
function wp(n, { from: e, to: t }, r) {
const s = `${n}.${e}`, o = `${n}.${t}`, i = { ...r }, l = /* @__PURE__ */ new Set();
return Object.keys(r).forEach((a) => {
if (l.has(a))
return;
let c, u;
if (a.startsWith(s) ? (c = a, u = a.replace(s, o)) : a.startsWith(o) && (c = a.replace(o, s), u = a), c && u) {
const d = i[c], f = i[u];
f === void 0 ? delete i[c] : i[c] = f, d === void 0 ? delete i[u] : i[u] = d, l.add(c), l.add(u);
}
}), i;
}
function Xa(n, e, t) {
typeof t.value == "object" && (t.value = Zn(t.value)), !t.enumerable || t.get || t.set || !t.configurable || !t.writable || e === "__proto__" ? Object.defineProperty(n, e, t) : n[e] = t.value;
}
function Zn(n) {
if (typeof n != "object") return n;
var e = 0, t, r, s, o = Object.prototype.toString.call(n);
if (o === "[object Object]" ? s = Object.create(n.__proto__ || null) : o === "[object Array]" ? s = Array(n.length) : o === "[object Set]" ? (s = /* @__PURE__ */ new Set(), n.forEach(function(i) {
s.add(Zn(i));
})) : o === "[object Map]" ? (s = /* @__PURE__ */ new Map(), n.forEach(function(i, l) {
s.set(Zn(l), Zn(i));
})) : o === "[object Date]" ? s = /* @__PURE__ */ new Date(+n) : o === "[object RegExp]" ? s = new RegExp(n.source, n.flags) : o === "[object DataView]" ? s = new n.constructor(Zn(n.buffer)) : o === "[object ArrayBuffer]" ? s = n.slice(0) : o.slice(-6) === "Array]" && (s = new n.constructor(n)), s) {
for (r = Object.getOwnPropertySymbols(n); e < r.length; e++)
Xa(s, r[e], Object.getOwnPropertyDescriptor(n, r[e]));
for (e = 0, r = Object.getOwnPropertyNames(n); e < r.length; e++)
Object.hasOwnProperty.call(s, t = r[e]) && s[t] === n[t] || Xa(s, t, Object.getOwnPropertyDescriptor(n, t));
}
return s || n;
}
function Yu(n) {
return typeof n != "string" ? [] : n.split(".");
}
function je(n, e) {
const t = Yu(n);
if (t.length === 0 || typeof e != "object" || e === null)
return;
let r = e[t[0]];
for (let s = 1; s < t.length && r != null; s += 1)
r = r[t[s]];
return r;
}
function qr(n, e, t) {
const r = Yu(n);
if (r.length === 0)
return t;
const s = Zn(t);
if (r.length === 1)
return s[r[0]] = e, s;
let o = s[r[0]];
for (let i = 1; i < r.length - 1; i += 1) {
if (o === void 0)
return s;
o = o[r[i]];
}
return o[r[r.length - 1]] = e, s;
}
function Tp(n, { from: e, to: t }, r) {
const s = je(n, r);
if (!Array.isArray(s))
return r;
const o = [...s], i = s[e];
return o.splice(e, 1), o.splice(t, 0, i), qr(n, o, r);
}
function Ep(n, e, t, r) {
const s = je(n, r);
if (!Array.isArray(s))
return r;
const o = [...s];
return o.splice(typeof t == "number" ? t : o.length, 0, e), qr(n, o, r);
}
function Op(n, e, t) {
const r = je(n, t);
return Array.isArray(r) ? qr(
n,
r.filter((s, o) => o !== e),
t
) : t;
}
function Dp(n, e, t, r) {
const s = je(n, r);
if (!Array.isArray(s) || s.length <= t)
return r;
const o = [...s];
return o[t] = e, qr(n, o, r);
}
function Ap({
$values: n,
$errors: e,
$status: t
}) {
const r = Q((l, a) => {
t.clearFieldDirty(l), e.setErrors((c) => wp(l, a, c)), n.setValues({
values: Tp(l, a, n.refValues.current),
updateState: !0
});
}, []), s = Q((l, a) => {
t.clearFieldDirty(l), e.setErrors((c) => Ga(l, a, c, -1)), n.setValues({
values: Op(l, a, n.refValues.current),
updateState: !0
});
}, []), o = Q((l, a, c) => {
t.clearFieldDirty(l), e.setErrors((u) => Ga(l, c, u, 1)), n.setValues({
values: Ep(l, a, c, n.refValues.current),
updateState: !0
});
}, []), i = Q((l, a, c) => {
t.clearFieldDirty(l), n.setValues({
values: Dp(l, c, a, n.refValues.current),
updateState: !0
});
}, []);
return { reorderListItem: r, removeListItem: s, insertListItem: o, replaceListItem: i };
}
var ci, Qa;
function Np() {
return Qa || (Qa = 1, ci = function n(e, t) {
if (e === t) return !0;
if (e && t && typeof e == "object" && typeof t == "object") {
if (e.constructor !== t.constructor) return !1;
var r, s, o;
if (Array.isArray(e)) {
if (r = e.length, r != t.length) return !1;
for (s = r; s-- !== 0; )
if (!n(e[s], t[s])) return !1;
return !0;
}
if (e.constructor === RegExp) return e.source === t.source && e.flags === t.flags;
if (e.valueOf !== Object.prototype.valueOf) return e.valueOf() === t.valueOf();
if (e.toString !== Object.prototype.toString) return e.toString() === t.toString();
if (o = Object.keys(e), r = o.length, r !== Object.keys(t).length) return !1;
for (s = r; s-- !== 0; )
if (!Object.prototype.hasOwnProperty.call(t, o[s])) return !1;
for (s = r; s-- !== 0; ) {
var i = o[s];
if (!n(e[i], t[i])) return !1;
}
return !0;
}
return e !== e && t !== t;
}), ci;
}
var Rp = Np();
const ts = /* @__PURE__ */ Ll(Rp);
function pr(n, e) {
const t = Object.keys(n);
if (typeof e == "string") {
const r = t.filter((s) => s.startsWith(`${e}.`));
return n[e] || r.some((s) => n[s]) || !1;
}
return t.some((r) => n[r]);
}
function Lp({
initialDirty: n,
initialTouched: e,
mode: t,
$values: r
}) {
const [s, o] = ke(e), [i, l] = ke(n), a = xe(e), c = xe(n), u = Q((v) => {
const M = typeof v == "function" ? v(a.current) : v;
a.current = M, t === "controlled" && o(M);
}, []), d = Q(
(v, M = !1) => {
const T = typeof v == "function" ? v(c.current) : v;
c.current = T, (t === "controlled" || M) && l(T);
},
[]
), f = Q(() => u({}), []), h = Q((v) => {
const M = v ? { ...r.refValues.current, ...v } : r.refValues.current;
r.setValuesSnapshot(M), d({});
}, []), m = Q((v, M) => {
u((T) => pr(T, v) === M ? T : { ...T, [v]: M });
}, []), y = Q((v, M, T) => {
d((O) => pr(O, v) === M ? O : { ...O, [v]: M }, T);
}, []), g = Q((v, M) => {
const T = pr(c.current, v), O = !ts(je(v, r.getValuesSnapshot()), M), P = Gi(v, c.current);
P[v] = O, d(P, T !== O);
}, []), b = Q(
(v) => pr(a.current, v),
[]
), x = Q(
(v) => d((M) => {
if (typeof v != "string")
return M;
const T = Gi(v, M);
return delete T[v], ts(T, M) ? M : T;
}),
[]
), S = Q((v) => {
if (v) {
const T = je(v, c.current);
if (typeof T == "boolean")
return T;
const O = je(v, r.refValues.current), P = je(v, r.valuesSnapshot.current);
return !ts(O, P);
}
return Object.keys(c.current).length > 0 ? pr(c.current) : !ts(r.refValues.current, r.valuesSnapshot.current);
}, []), w = Q(() => c.current, []), C = Q(() => a.current, []);
return {
touchedState: s,
dirtyState: i,
touchedRef: a,
dirtyRef: c,
setTouched: u,
setDirty: d,
resetDirty: h,
resetTouched: f,
isTouched: b,
setFieldTouched: m,
setFieldDirty: y,
setTouchedState: o,
setDirtyState: l,
clearFieldDirty: x,
isDirty: S,
getDirty: w,
getTouched: C,
setCalculatedFieldDirty: g
};
}
function jp({
initialValues: n,
onValuesChange: e,
mode: t
}) {
const r = xe(!1), [s, o] = ke(n || {}), i = xe(s), l = xe(s), a = Q(
({
values: g,
subscribers: b,
updateState: x = !0,
mergeWithPreviousValues: S = !0
}) => {
const w = i.current, C = g instanceof Function ? g(i.current) : g, v = S ? { ...w, ...C } : C;
i.current = v, x && (o(v), t === "uncontrolled" && (i.current = v)), e == null || e(v, w), b == null || b.filter(Boolean).forEach((M) => M({ updatedValues: v, previousValues: w }));
},
[e]
), c = Q(
(g) => {
var S;
const b = je(g.path, i.current), x = g.value instanceof Function ? g.value(b) : g.value;
if (b !== x) {
const w = i.current, C = qr(g.path, x, i.current);
a({ values: C, updateState: g.updateState }), (S = g.subscribers) == null || S.filter(Boolean).forEach(
(v) => v({ path: g.path, updatedValues: C, previousValues: w })
);
}
},
[a]
), u = Q((g) => {
l.current = g;
}, []), d = Q(
(g, b) => {
r.current || (r.current = !0, a({ values: g, updateState: t === "controlled" }), u(g), b());
},
[a]
), f = Q(() => {
a({
values: l.current,
updateState: !0,
mergeWithPreviousValues: !1
});
}, [a]), h = Q(() => i.current, []), m = Q(() => l.current, []), y = Q(
(g, b) => {
const x = je(g, l.current);
typeof x > "u" || c({
path: g,
value: x,
updateState: t === "controlled",
subscribers: b
});
},
[c, t]
);
return {
initialized: r,
stateValues: s,
refValues: i,
valuesSnapshot: l,
setValues: a,
setFieldValue: c,
resetValues: f,
setValuesSnapshot: u,
initialize: d,
getValues: h,
getValuesSnapshot: m,
resetField: y
};
}
function Ip({
$status: n,
cascadeUpdates: e
}) {
const t = xe(
{}
), r = Q((o, i) => {
Ge(() => (t.current[o] = t.current[o] || [], t.current[o].push(i), () => {
t.current[o] = t.current[o].filter((l) => l !== i);
}), [i]);
}, []), s = Q((o) => {
var l;
const i = ((l = t.current[o]) == null ? void 0 : l.map(
(a) => (c) => a({
previousValue: je(o, c.previousValues),
value: je(o, c.updatedValues),
touched: n.isTouched(o),
dirty: n.isDirty(o)
})
)) ?? [];
if (e)
for (const a in t.current)
(a.startsWith(`${o}.`) || o.startsWith(`${a}.`)) && i.push(
...t.current[a].map(
(c) => (u) => c({
previousValue: je(a, u.previousValues),
value: je(a, u.updatedValues),
touched: n.isTouched(a),
dirty: n.isDirty(a)
})
)
);
return i;
}, []);
return {
subscribers: t,
watch: r,
getFieldSubscribers: s
};
}
function Za(n, e) {
return n ? `${n}-${e.toString()}` : e.toString();
}
const ns = Symbol("root-rule");
function ec(n) {
const e = Ji(n);
return { hasErrors: Object.keys(e).length > 0, errors: e };
}
function Xi(n, e, t = "", r = {}) {
return typeof n != "object" || n === null ? r : Object.keys(n).reduce((s, o) => {
const i = n[o], l = `${t === "" ? "" : `${t}.`}${o}`, a = je(l, e);
let c = !1;
return typeof i == "function" && (s[l] = i(a, e, l)), typeof i == "object" && Array.isArray(a) && (c = !0, a.forEach(
(u, d) => Xi(i, e, `${l}.${d}`, s)
), ns in i && (s[l] = i[ns](a, e, l))), typeof i == "object" && typeof a == "object" && a !== null && (c || Xi(i, e, l, s), ns in i && (s[l] = i[ns](a, e, l))), s;
}, r);
}
function Qi(n, e) {
return ec(typeof n == "function" ? n(e) : Xi(n, e));
}
function rs(n, e, t) {
if (typeof n != "string")
return { hasError: !1, error: null };
const r = Qi(e, t), s = Object.keys(r.errors).find(
(o) => n.split(".").every((i, l) => i === o.split(".")[l])
);
return { hasError: !!s, error: s ? r.errors[s] : null };
}
const Pp = "__MANTINE_FORM_INDEX__";
function tc(n, e) {
return e ? typeof e == "boolean" ? e : Array.isArray(e) ? e.includes(n.replace(/[.][0-9]+/g, `.${Pp}`)) : !1 : !1;
}
function _p({
name: n,
mode: e = "controlled",
initialValues: t,
initialErrors: r = {},
initialDirty: s = {},
initialTouched: o = {},
clearInputErrorOnChange: i = !0,
validateInputOnChange: l = !1,
validateInputOnBlur: a = !1,
onValuesChange: c,
transformValues: u = (g) => g,
enhanceGetInputProps: d,
validate: f,
onSubmitPreventDefault: h = "always",
touchTrigger: m = "change",
cascadeUpdates: y = !1
} = {}) {
const g = Mp(r), b = jp({ initialValues: t, onValuesChange: c, mode: e }), x = Lp({ initialDirty: s, initialTouched: o, $values: b, mode: e }), S = Ap({ $values: b, $errors: g, $status: x }), w = Ip({ $status: x, cascadeUpdates: y }), [C, v] = ke(0), [M, T] = ke({}), [O, P] = ke(!1), $ = Q(() => {
b.resetValues(), g.clearErrors(), x.resetDirty(), x.resetTouched(), e === "uncontrolled" && v((A) => A + 1);
}, []), V = Q(
(A) => {
i && g.clearErrors(), e === "uncontrolled" && v((U) => U + 1), Object.keys(w.subscribers.current).forEach((U) => {
const se = je(U, b.refValues.current), X = je(U, A);
se !== X && w.getFieldSubscribers(U).forEach((pe) => pe({ previousValues: A, updatedValues: b.refValues.current }));
});
},
[i]
), _ = Q(
(A) => {
const U = b.refValues.current;
b.initialize(A, () => e === "uncontrolled" && v((se) => se + 1)), V(U);
},
[V]
), q = Q(
(A, U, se) => {
const X = tc(A, l), pe = U instanceof Function ? U(je(A, b.refValues.current)) : U;
x.setCalculatedFieldDirty(A, pe), m === "change" && x.setFieldTouched(A, !0), !X && i && g.clearFieldError(A), b.setFieldValue({
path: A,
value: U,
updateState: e === "controlled",
subscribers: [
...w.getFieldSubscribers(A),
X ? (he) => {
const le = rs(A, f, he.updatedValues);
le.hasError ? g.setFieldError(A, le.error) : g.clearFieldError(A);
} : null,
(se == null ? void 0 : se.forceUpdate) !== !1 && e !== "controlled" ? () => T((he) => ({
...he,
[A]: (he[A] || 0) + 1
})) : null
]
});
},
[c, f]
), Z = Q(
(A) => {
const U = b.refValues.current;
b.setValues({ values: A, updateState: e === "controlled" }), V(U);
},
[c, V]
), Y = Q(() => {
const A = Qi(f, b.refValues.current);
return g.setErrors(A.errors), A;
}, [f]), K = Q(
(A) => {
const U = rs(A, f, b.refValues.current);
return U.hasError ? g.setFieldError(A, U.error) : g.clearFieldError(A), U;
},
[f]
), z = (A, { type: U = "input", withError: se = !0, withFocus: X = !0, ...pe } = {}) => {
const le = { onChange: Cp(
(ne) => q(A, ne, { forceUpdate: !1 })
), "data-path": Za(n, A) };
return se && (le.error = g.errorsState[A]), U === "checkbox" ? le[e === "controlled" ? "checked" : "defaultChecked"] = je(
A,
b.refValues.current
) : le[e === "controlled" ? "value" : "defaultValue"] = je(
A,
b.refValues.current
), X && (le.onFocus = () => x.setFieldTouched(A, !0), le.onBlur = () => {
if (tc(A, a)) {
const ne = rs(A, f, b.refValues.current);
ne.hasError ? g.setFieldError(A, ne.error) : g.clearFieldError(A);
}
}), Object.assign(
le,
d == null ? void 0 : d({
inputProps: le,
field: A,
options: { type: U, withError: se, withFocus: X, ...pe },
form: ue
})
);
}, H = (A, U) => (se) => {
h === "always" && (se == null || se.preventDefault());
const X = Y();
if (X.hasErrors)
h === "validation-failed" && (se == null || se.preventDefault()), U == null || U(X.errors, b.refValues.current, se);
else {
const pe = A == null ? void 0 : A(
u(b.refValues.current),
se
);
pe instanceof Promise && (P(!0), pe.finally(() => P(!1)));
}
}, L = (A) => u(A || b.refValues.current), k = Q((A) => {
A.preventDefault(), $();
}, []), E = Q(
(A) => A ? !rs(A, f, b.refValues.current).hasError : !Qi(f, b.refValues.current).hasErrors,
[f]
), D = (A) => `${C}-${String(A)}-${M[String(A)] || 0}`, j = Q(
(A) => document.querySelector(`[data-path="${Za(n, A)}"]`),
[]
), W = Q(
(A) => {
b.resetField(A, [
e !== "controlled" ? () => T((U) => ({
...U,
[A]: (U[A] || 0) + 1
})) : null
]);
},
[b.resetField, e, T]
), ue = {
watch: w.watch,
initialized: b.initialized.current,
values: e === "uncontrolled" ? b.refValues.current : b.stateValues,
getValues: b.getValues,
getInitialValues: b.getValuesSnapshot,
setInitialValues: b.setValuesSnapshot,
resetField: W,
initialize: _,
setValues: Z,
setFieldValue: q,
submitting: O,
setSubmitting: P,
errors: g.errorsState,
setErrors: g.setErrors,
setFieldError: g.setFieldError,
clearFieldError: g.clearFieldError,
clearErrors: g.clearErrors,
resetDirty: x.resetDirty,
setTouched: x.setTouched,
setDirty: x.setDirty,
isTouched: x.isTouched,
resetTouched: x.resetTouched,
isDirty: x.isDirty,
getTouched: x.getTouched,
getDirty: x.getDirty,
reorderListItem: S.reorderListItem,
insertListItem: S.insertListItem,
removeListItem: S.removeListItem,
replaceListItem: S.replaceListItem,
reset: $,
validate: Y,
validateField: K,
getInputProps: z,
onSubmit: H,
onReset: k,
isValid: E,
getTransformedValues: L,
key: D,
getInputNode: j
};
return Sp(n, ue), ue;
}
const jl = {
vertical: (n) => /* @__PURE__ */ p.jsx(wo, { gap: "md", children: n }),
horizontal: (n) => /* @__PURE__ */ p.jsx(Mo, { wrap: "wrap", gap: "md", children: n }),
grid: (n) => /* @__PURE__ */ p.jsx(Vu, { gutter: "md", children: n })
}, Zi = (n) => {
switch (n) {
case "number":
return 0;
case "array":
return [];
case "checkbox":
return !1;
case "object":
return {};
case "select":
case "date":
case "datetime":
return null;
default:
return "";
}
};
function Mr(n, e = {}) {
const t = {};
for (const r of n)
r.type === "object" && r.fields ? t[r.name] = Mr(
r.fields,
e == null ? void 0 : e[r.name]
) : t[r.name] = (e == null ? void 0 : e[r.name]) ?? r.initialValue ?? Zi(r.type);
return t;
}
function el(n, e) {
const t = {};
for (const r of n) {
const s = (e == null ? void 0 : e[r.name]) ?? Zi(r.type);
if (r.required)
if (r.type === "object") {
Object.values(s).length || (t[r.name] = `${r.label || r.name} is required`);
const o = el(r.fields, s);
for (const [i, l] of Object.entries(o))
t[`${r.name}.${i}`] = l;
} else r.type === "array" ? (s.length || (t[r.name] = `${r.label || r.name} is required`), s.forEach((o, i) => {
const l = el(r.fields, o);
for (const [a, c] of Object.entries(l))
t[`${r.name}.${i}.${a}`] = c;
})) : s === Zi(r.type) && (t[r.name] = `${r.label || r.name} is required`);
}
return t;
}
function Il({
field: n,
layout: e,
children: t
}) {
if (e === "grid") {
const r = n.column ?? 6;
return /* @__PURE__ */ p.jsx(
Vu.Col,
{
span: {
base: 12,
md: r
},
children: t
}
);
}
return e === "horizontal" ? /* @__PURE__ */ p.jsx(ze, { style: { display: "flex", alignItems: "center", gap: 12 }, children: t }) : /* @__PURE__ */ p.jsx(wo, { gap: "xs", children: t });
}
function Fp({ field: n, form: e, layout: t = "grid" }) {
const r = n, s = e.getInputProps(r.name), o = s.value ?? [], i = r.readOnly === !0, l = r.disabled === !0;
function a() {
s.onFieldChange([
...o,
Mr(r.fields)
]);
}
function c(u) {
s.onFieldChange(o.filter((d, f) => f !== u));
}
return /* @__PURE__ */ p.jsxs(wo, { gap: "md", children: [
o.map((u, d) => {
var f;
return /* @__PURE__ */ p.jsxs(
lp,
{
withBorder: !0,
radius: "md",
p: "md",
shadow: "xs",
children: [
jl[t](
(f = r.fields) == null ? void 0 : f.map((h) => /* @__PURE__ */ p.jsx(
Il,
{
field: h,
layout: t,
children: /* @__PURE__ */ p.jsx(
ja,
{
field: {
...h,
name: `${n.name}.${d}.${h.name}`,
disabled: l || h.disabled,
readOnly: i || h.readOnly
},
form: e,
layout: t
}
)
},
`${n.name}.${d}.${h.name}`
))
),
!i && !l && /* @__PURE__ */ p.jsx(Mo, { justify: "flex-end", mt: "xs", children: /* @__PURE__ */ p.jsx(
Os,
{
color: "red",
variant: "light",
onClick: () => c(d),
children: "Remove"
}
) })
]
},
`${r.name}.${d}`
);
}),
!i && !l && /* @__PURE__ */ p.jsxs(p.Fragment, { children: [
o.length > 0 && /* @__PURE__ */ p.jsx(ap, { my: "sm" }),
/* @__PURE__ */ p.jsx(Os, { onClick: a, variant: "default", children: "Add Row" })
] })
] });
}
function Bp({ field: n, form: e }) {
const t = e.getInputProps(n.name), r = n.readOnly === !0, s = n.disabled === !0;
return r || s ? /* @__PURE__ */ p.jsx(
za,
{
value: t.value,
readOnly: r,
disabled: s,
required: n.required,
placeholder: n.placeholder,
variant: r ? "filled" : "default",
error: void 0,
checked: t.value
}
) : /* @__PURE__ */ p.jsx(
za,
{
...t,
checked: t.value,
onChange: (o) => t.onFieldChange(o.target.checked),
required: n.required,
placeholder: n.placeholder,
error: void 0
}
);
}
function zp({ direction: n, levelIndex: e, rowIndex: t, cellIndex: r, size: s }) {
switch (n) {
case "up":
return e === 0 && t === 0 ? null : t === 0 ? {
levelIndex: e - 1,
rowIndex: r <= s[e - 1][s[e - 1].length - 1] - 1 ? s[e - 1].length - 1 : s[e - 1].length - 2,
cellIndex: r
} : {
levelIndex: e,
rowIndex: t - 1,
cellIndex: r
};
case "down":
return t === s[e].length - 1 ? {
levelIndex: e + 1,
rowIndex: 0,
cellIndex: r
} : t === s[e].length - 2 && r >= s[e][s[e].length - 1] ? {
levelIndex: e + 1,
rowIndex: 0,
cellIndex: r
} : {
levelIndex: e,
rowIndex: t + 1,
cellIndex: r
};
case "left":
return e === 0 && t === 0 && r === 0 ? null : t === 0 && r === 0 ? {
levelIndex: e - 1,
rowIndex: s[e - 1].length - 1,
cellIndex: s[e - 1][s[e - 1].length - 1] - 1
} : r === 0 ? {
levelIndex: e,
rowIndex: t - 1,
cellIndex: s[e][t - 1] - 1
} : {
levelIndex: e,
rowIndex: t,
cellIndex: r - 1
};
case "right":
return t === s[e].length - 1 && r === s[e][t] - 1 ? {
levelIndex: e + 1,
rowIndex: 0,
cellIndex: 0
} : r === s[e][t] - 1 ? {
levelIndex: e,
rowIndex: t + 1,
cellIndex: 0
} : {
levelIndex: e,
rowIndex: t,
cellIndex: r + 1
};
default:
return { levelIndex: e, rowIndex: t, cellIndex: r };
}
}
function qu({
controlsRef: n,
direction: e,
levelIndex: t,
rowIndex: r,
cellIndex: s,
size: o
}) {
var a, c, u;
const i = zp({ direction: e, size: o, rowIndex: r, cellIndex: s, levelIndex: t });
if (!i)
return;
const l = (u = (c = (a = n.current) == null ? void 0 : a[i.levelIndex]) == null ? void 0 : c[i.rowIndex]) == null ? void 0 : u[i.cellIndex];
l && (l.disabled || l.getAttribute("data-hidden") || l.getAttribute("data-outside") ? qu({
controlsRef: n,
direction: e,
levelIndex: i.levelIndex,
cellIndex: i.cellIndex,
rowIndex: i.rowIndex,
size: o
}) : l.focus());
}
function Vp(n) {
switch (n) {
case "ArrowDown":
return "down";
case "ArrowUp":
return "up";
case "ArrowRight":
return "right";
case "ArrowLeft":
return "left";
default:
return null;
}
}
function Hp(n) {
var e;
return (e = n.current) == null ? void 0 : e.map((t) => t.map((r) => r.length));
}
function Pl({
controlsRef: n,
levelIndex: e,
rowIndex: t,
cellIndex: r,
event: s
}) {
const o = Vp(s.key);
if (o) {
s.preventDefault();
const i = Hp(n);
qu({
controlsRef: n,
direction: o,
levelIndex: e,
rowIndex: t,
cellIndex: r,
size: i
});
}
}
function nc(n, e) {
let t = n ? N(n) : N();
if (e === "")
return t.format("YYYY-MM-DD HH:mm:ss");
const [r, s, o = 0] = e.split(":").map(Number);
return t = t.set("hour", r), t = t.set("minute", s), t = t.set("second", o), t = t.set("millisecond", 0), t.format("YYYY-MM-DD HH:mm:ss");
}
function Ue(n) {
return n == null || n === "" ? n : N(n).format("YYYY-MM-DD");
}
function er(n) {
return n == null || n === "" ? n : N(n).format("YYYY-MM-DD HH:mm:ss");
}
function $p({
minDate: n,
maxDate: e
}) {
const t = N();
return !n && !e ? Ue(t) : n && N(t).isBefore(n) ? Ue(n) : e && N(t).isAfter(e) ? Ue(e) : Ue(t);
}
function ui(n, e, t) {
return !n && !e ? er(t) : n && N(t).isBefore(n) ? er(n) : e && N(t).isAfter(e) ? er(e) : er(t);
}
const Wp = {
locale: "en",
firstDayOfWeek: 1,
weekendDays: [0, 6],
labelSeparator: "–",
consistentWeeks: !1
}, Yp = Co(Wp);
function Wt() {
const n = Fu(Yp), e = Q((o) => o || n.locale, [n.locale]), t = Q(
(o) => typeof o == "number" ? o : n.firstDayOfWeek,
[n.firstDayOfWeek]
), r = Q(
(o) => Array.isArray(o) ? o : n.weekendDays,
[n.weekendDays]
), s = Q(
(o) => typeof o == "string" ? o : n.labelSeparator,
[n.labelSeparator]
);
return {
...n,
getLocale: e,
getFirstDayOfWeek: t,
getWeekendDays: r,
getLabelSeparator: s
};
}
function qp({ value: n, type: e, withTime: t }) {
const r = t ? er : Ue;
if (e === "range" && Array.isArray(n)) {
const s = r(n[0]), o = r(n[1]);
return s ? o ? `${s} – ${o}` : `${s} –` : "";
}
return e === "multiple" && Array.isArray(n) ? n.filter(Boolean).join(", ") : !Array.isArray(n) && n ? r(n) : "";
}
function _l({
value: n,
type: e,
name: t,
form: r,
withTime: s = !1
}) {
return /* @__PURE__ */ p.jsx("input", { type: "hidden", value: qp({ value: n, type: e, withTime: s }), name: t, form: r });
}
_l.displayName = "@mantine/dates/HiddenDatesInput";
function Ku(n) {
var e, t, r = "";
if (typeof n == "string" || typeof n == "number") r += n;
else if (typeof n == "object") if (Array.isArray(n)) {
var s = n.length;
for (e = 0; e < s; e++) n[e] && (t = Ku(n[e])) && (r && (r += " "), r += t);
} else for (t in n) n[t] && (r && (r += " "), r += t);
return r;
}
function Uu() {
for (var n, e, t = 0, r = "", s = arguments.length; t < s; t++) (n = arguments[t]) && (e = Ku(n)) && (r && (r += " "), r += e);
return r;
}
var Kp = { input: "m_468e7eda" };
const Ds = Ce((n, e) => {
const t = ve("TimeInput", null, n), {
classNames: r,
styles: s,
unstyled: o,
vars: i,
withSeconds: l,
minTime: a,
maxTime: c,
value: u,
onChange: d,
step: f,
...h
} = t, { resolvedClassNames: m, resolvedStyles: y } = _n({
classNames: r,
styles: s,
props: t
}), g = (x) => {
if (a !== void 0 || c !== void 0) {
const [S, w, C] = x.split(":").map(Number);
if (a) {
const [v, M, T] = a.split(":").map(Number);
if (S < v || S === v && w < M || l && S === v && w === M && C < T)
return -1;
}
if (c) {
const [v, M, T] = c.split(":").map(Number);
if (S > v || S === v && w > M || l && S === v && w === M && C > T)
return 1;
}
}
return 0;
}, b = (x) => {
var S, w, C;
if ((S = t.onBlur) == null || S.call(t, x), a !== void 0 || c !== void 0) {
const v = x.currentTarget.value;
if (v) {
const M = g(v);
M === 1 ? (c && (x.currentTarget.value = c), (w = t.onChange) == null || w.call(t, x)) : M === -1 && (a && (x.currentTarget.value = a), (C = t.onChange) == null || C.call(t, x));
}
}
};
return /* @__PURE__ */ p.jsx(
Nl,
{
classNames: { ...m, input: Uu(Kp.input, m == null ? void 0 : m.input) },
styles: y,
unstyled: o,
ref: e,
value: u,
step: f ?? (l ? 1 : 60),
...h,
onChange: d,
onBlur: b,
type: "time",
__staticSelector: "TimeInput"
}
);
});
Ds.classes = Nl.classes;
Ds.displayName = "@mantine/dates/TimeInput";
function ys(n, e, t) {
return e === void 0 && t === void 0 ? n : e !== void 0 && t === void 0 ? Math.max(n, e) : Math.min(e === void 0 && t !== void 0 ? n : Math.max(n, e), t);
}
function Up(n = "mantine-") {
return `${n}${Math.random().toString(36).slice(2, 11)}`;
}
const Jp = ["mousedown", "touchstart"];
function Gp(n, e, t) {
const r = xe(null), s = Jp;
return Ge(() => {
const o = (i) => {
const { target: l } = i ?? {};
if (Array.isArray(t)) {
const a = !document.body.contains(l) && (l == null ? void 0 : l.tagName) !== "HTML";
t.every((u) => !!u && !i.composedPath().includes(u)) && !a && n(i);
} else r.current && !r.current.contains(l) && n(i);
};
return s.forEach((i) => document.addEventListener(i, o)), () => {
s.forEach((i) => document.removeEventListener(i, o));
};
}, [r, n, t]), r;
}
const Xp = typeof document < "u" ? Al : Ge;
function As(n, e) {
const t = xe(!1);
Ge(
() => () => {
t.current = !1;
},
[]
), Ge(() => {
if (t.current)
return n();
t.current = !0;
}, e);
}
const Qp = ht.useId || (() => {
});
function Zp() {
const n = Qp();
return n ? `mantine-${n.replace(/:/g, "")}` : "";
}
function em(n) {
const e = Zp(), [t, r] = ke(e);
return Xp(() => {
r(Up());
}, []), typeof window > "u" ? e : t;
}
function tm(n, e, t) {
Ge(() => (window.addEventListener(n, e, t), () => window.removeEventListener(n, e, t)), [n, e]);
}
function rc(n, e) {
if (typeof n == "function")
return n(e);
typeof n == "object" && n !== null && "current" in n && (n.current = e);
}
function nm(...n) {
const e = /* @__PURE__ */ new Map();
return (t) => {
if (n.forEach((r) => {
const s = rc(r, t);
s && e.set(r, s);
}), e.size > 0)
return () => {
n.forEach((r) => {
const s = e.get(r);
s && typeof s == "function" ? s() : rc(r, null);
}), e.clear();
};
};
}
function br(...n) {
return Q(nm(...n), n);
}
function Ju({
value: n,
defaultValue: e,
finalValue: t,
onChange: r = () => {
}
}) {
const [s, o] = ke(
e !== void 0 ? e : t
), i = (l, ...a) => {
o(l), r == null || r(l, ...a);
};
return n !== void 0 ? [n, r, !0] : [s, i, !1];
}
function rm(n) {
return (e) => {
if (!e)
n(e);
else if (typeof e == "function")
n(e);
else if (typeof e == "object" && "nativeEvent" in e) {
const { currentTarget: t } = e;
t.type === "checkbox" ? n(t.checked) : n(t.value);
} else
n(e);
};
}
function sm(n) {
const [e, t] = ke(n);
return [e, rm(t)];
}
function Fl(n = !1, e = {}) {
const [t, r] = ke(n), s = Q(() => {
r((l) => {
var a;
return l || ((a = e.onOpen) == null || a.call(e), !0);
});
}, [e.onOpen]), o = Q(() => {
r((l) => {
var a;
return l && ((a = e.onClose) == null || a.call(e), !1);
});
}, [e.onClose]), i = Q(() => {
t ? o() : s();
}, [o, s, t]);
return [t, { open: s, close: o, toggle: i }];
}
function Ke(n) {
return n < 10 ? `0${n}` : `${n}`;
}
const om = (n) => Number(n.toFixed(0)[0]), bs = $t(
({
value: n,
min: e,
max: t,
onChange: r,
focusable: s,
step: o,
onNextInput: i,
onPreviousInput: l,
onFocus: a,
readOnly: c,
allowTemporaryZero: u = !1,
...d
}, f) => {
const h = om(t), m = t + 1 - o, y = (b) => {
if (c)
return;
const x = b.replace(/\D/g, "");
if (x !== "") {
const S = parseInt(x, 10), w = u && S === 0 && e > 0 ? 0 : ys(S, e, t);
r(w), (w > h || b.startsWith("00")) && (i == null || i());
}
}, g = (b) => {
if (!c) {
if ((b.key === "0" || b.key === "Num0") && n === 0 && (b.preventDefault(), i == null || i()), b.key === "Home" && (b.preventDefault(), r(e)), b.key === "End" && (b.preventDefault(), r(t)), (b.key === "Backspace" || b.key === "Delete") && (b.preventDefault(), n !== null ? r(null) : l == null || l()), b.key === "ArrowRight" && (b.preventDefault(), i == null || i()), b.key === "ArrowLeft" && (b.preventDefault(), l == null || l()), b.key === "ArrowUp") {
b.preventDefault();
const x = n === null ? e : ys(n + o, e, m);
r(x);
}
if (b.key === "ArrowDown") {
b.preventDefault();
const x = n === null ? m : ys(n - o, e, m);
r(x);
}
}
};
return /* @__PURE__ */ p.jsx(
"input",
{
ref: f,
type: "text",
role: "spinbutton",
"aria-valuemin": e,
"aria-valuemax": t,
"aria-valuenow": n === null ? 0 : n,
"data-empty": n === null || void 0,
inputMode: "numeric",
placeholder: "--",
value: n === null ? "" : Ke(n),
onChange: (b) => y(b.currentTarget.value),
onKeyDown: g,
onFocus: (b) => {
b.currentTarget.select(), a == null || a(b);
},
onClick: (b) => {
b.stopPropagation(), b.currentTarget.select();
},
onMouseDown: (b) => b.stopPropagation(),
...d
}
);
}
);
bs.displayName = "@mantine/dates/SpinInput";
const [im, Bn] = Hu(
"TimeInput component was not found in the component tree"
), Gu = $t(
({
labels: n,
value: e,
onChange: t,
className: r,
style: s,
onPreviousInput: o,
readOnly: i,
onMouseDown: l,
onTouchStart: a,
inputType: c,
...u
}, d) => {
const f = Bn(), h = (m) => {
i || (m.key === "Home" && (m.preventDefault(), t(n.am)), m.key === "End" && (m.preventDefault(), t(n.pm)), (m.key === "Backspace" || m.key === "Delete") && (m.preventDefault(), e === null ? o == null || o() : t(null)), m.key === "ArrowLeft" && (m.preventDefault(), o == null || o()), (m.key === "ArrowUp" || m.key === "ArrowDown") && (m.preventDefault(), t(e === n.am ? n.pm : n.am)), m.code === "KeyA" && (m.preventDefault(), t(n.am)), m.code === "KeyP" && (m.preventDefault(), t(n.pm)));
};
if (c === "input") {
const m = e || "--", y = m.length + 1;
return /* @__PURE__ */ p.jsx(
"input",
{
...f.getStyles("field", { className: r, style: s }),
ref: d,
value: m,
size: y,
onChange: (g) => !i && t(g.target.value || null),
onClick: (g) => g.stopPropagation(),
onKeyDown: h,
onMouseDown: (g) => {
g.stopPropagation(), l == null || l(g);
},
"data-am-pm": !0,
...u
}
);
}
return /* @__PURE__ */ p.jsxs(
"select",
{
...f.getStyles("field", { className: r, style: s }),
ref: d,
value: e || "",
onChange: (m) => !i && t(m.target.value || null),
onClick: (m) => m.stopPropagation(),
onKeyDown: h,
onMouseDown: (m) => {
m.stopPropagation(), l == null || l(m);
},
"data-am-pm": !0,
...u,
children: [
/* @__PURE__ */ p.jsx("option", { value: "", children: "--" }),
/* @__PURE__ */ p.jsx("option", { value: n.am, children: n.am }),
/* @__PURE__ */ p.jsx("option", { value: n.pm, children: n.pm })
]
}
);
}
);
Gu.displayNam