dirk-cfx-react 1.0.45 → 1.0.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,8 +1,12 @@
1
+ import { createContext, useEffect, useRef, useState, useContext, useMemo } from 'react';
2
+ import { create, useStore, createStore } from 'zustand';
1
3
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
2
- import { createTheme, Flex, Text, Image, MantineProvider, BackgroundImage, useMantineTheme, alpha } from '@mantine/core';
3
- import { createContext, useRef, useEffect, useContext, useMemo, useState } from 'react';
4
- import { create, createStore, useStore } from 'zustand';
5
- import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
4
+ import { Flex, Text, Image, createTheme, useMantineTheme, alpha, MantineProvider, BackgroundImage } from '@mantine/core';
5
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
+ import { motion, AnimatePresence, useMotionValue } from 'framer-motion';
7
+ import clickSoundUrl from './click_sound-PNCRRTM4.mp3';
8
+ import hoverSoundUrl from './hover_sound-NBUA222C.mp3';
9
+ import { useClickOutside } from '@mantine/hooks';
6
10
  import '@mantine/core/styles.css';
7
11
  import '@mantine/notifications/styles.css';
8
12
  import './styles/notify.css';
@@ -13,12 +17,6 @@ import { library } from '@fortawesome/fontawesome-svg-core';
13
17
  import { fab } from '@fortawesome/free-brands-svg-icons';
14
18
  import { far } from '@fortawesome/free-regular-svg-icons';
15
19
  import { fas } from '@fortawesome/free-solid-svg-icons';
16
- import { motion, AnimatePresence, useMotionValue } from 'framer-motion';
17
- import clickSoundUrl from './click_sound-PNCRRTM4.mp3';
18
- import hoverSoundUrl from './hover_sound-NBUA222C.mp3';
19
- import { useClickOutside } from '@mantine/hooks';
20
-
21
- // src/components/BorderedIcon.tsx
22
20
 
23
21
  // src/utils/colorWithAlpha.ts
24
22
  var colorNames = {
@@ -217,216 +215,7 @@ var openLink = (url) => {
217
215
  }
218
216
  };
219
217
 
220
- // src/hooks/useNuiEvent.ts
221
- var useNuiEvent = (action, handler) => {
222
- const savedHandler = useRef(noop);
223
- useEffect(() => {
224
- savedHandler.current = handler;
225
- }, [handler]);
226
- useEffect(() => {
227
- const eventListener = (event) => {
228
- const { action: eventAction, data } = event.data;
229
- if (savedHandler.current) {
230
- if (eventAction === action) {
231
- savedHandler.current(data);
232
- }
233
- }
234
- };
235
- window.addEventListener("message", eventListener);
236
- return () => window.removeEventListener("message", eventListener);
237
- }, [action]);
238
- };
239
- function getNested(obj, path) {
240
- return path.split(".").reduce((acc, key) => acc ? acc[key] : void 0, obj);
241
- }
242
- function setNested(obj, path, value) {
243
- const keys = path.split(".");
244
- const newObj = { ...obj };
245
- let current = newObj;
246
- for (let i = 0; i < keys.length - 1; i++) {
247
- const key = keys[i];
248
- current[key] = { ...current[key] || {} };
249
- current = current[key];
250
- }
251
- current[keys[keys.length - 1]] = value;
252
- return newObj;
253
- }
254
- function deleteNested(obj, path) {
255
- const keys = path.split(".");
256
- const newObj = { ...obj };
257
- let current = newObj;
258
- for (let i = 0; i < keys.length - 1; i++) {
259
- const key = keys[i];
260
- if (!current[key]) return obj;
261
- current[key] = { ...current[key] };
262
- current = current[key];
263
- }
264
- delete current[keys[keys.length - 1]];
265
- return newObj;
266
- }
267
- function flattenRules(rules, prefix = "") {
268
- const result = {};
269
- for (const key in rules) {
270
- const fullPath = prefix ? `${prefix}.${key}` : key;
271
- const val = rules[key];
272
- if (typeof val === "function") result[fullPath] = val;
273
- else if (typeof val === "object")
274
- Object.assign(result, flattenRules(val, fullPath));
275
- }
276
- return result;
277
- }
278
- function createFormStore(initialValues, validationRules, onSubmit) {
279
- const flatRules = validationRules ? flattenRules(validationRules) : {};
280
- const history = [];
281
- const future = [];
282
- const changed = /* @__PURE__ */ new Set();
283
- return createStore((set, get) => ({
284
- initialValues,
285
- values: initialValues,
286
- errors: {},
287
- canBack: false,
288
- canForward: false,
289
- changedFields: [],
290
- changedCount: 0,
291
- onSubmit,
292
- submit: () => {
293
- const state = get();
294
- const isValid = state.validate();
295
- if (isValid && state.onSubmit) state.onSubmit(get());
296
- },
297
- resetChangeCount: () => {
298
- changed.clear();
299
- set(() => ({
300
- changedFields: [],
301
- changedCount: 0
302
- }));
303
- },
304
- setInitialValues: (newInitialValues) => set({ initialValues: newInitialValues }),
305
- setValue: (path, value) => {
306
- const currentValues = get().values;
307
- const newValues = setNested(currentValues, path, value);
308
- const oldValue = getNested(get().initialValues, path);
309
- history.push(currentValues);
310
- future.length = 0;
311
- if (value !== oldValue) changed.add(path);
312
- else changed.delete(path);
313
- set({
314
- values: newValues,
315
- canBack: history.length > 0,
316
- canForward: false,
317
- changedFields: Array.from(changed),
318
- changedCount: changed.size
319
- });
320
- const rule = flatRules[path];
321
- if (rule) {
322
- const error2 = rule(value, newValues);
323
- if (error2)
324
- set((state) => ({ errors: setNested(state.errors, path, error2) }));
325
- else set((state) => ({ errors: deleteNested(state.errors, path) }));
326
- }
327
- },
328
- setError: (path, message) => set((state) => ({ errors: setNested(state.errors, path, message) })),
329
- clearError: (path) => set((state) => ({ errors: deleteNested(state.errors, path) })),
330
- validateField: (path) => {
331
- const state = get();
332
- const rule = flatRules[path];
333
- if (!rule) return true;
334
- const value = getNested(state.values, path);
335
- const error2 = rule(value, state.values);
336
- if (error2) {
337
- set((state2) => ({ errors: setNested(state2.errors, path, error2) }));
338
- return false;
339
- } else {
340
- set((state2) => ({ errors: deleteNested(state2.errors, path) }));
341
- return true;
342
- }
343
- },
344
- validate: () => {
345
- const state = get();
346
- let isValid = true;
347
- let newErrors = {};
348
- for (const path in flatRules) {
349
- const rule = flatRules[path];
350
- const value = getNested(state.values, path);
351
- const error2 = rule(value, state.values);
352
- if (error2) {
353
- isValid = false;
354
- newErrors = setNested(newErrors, path, error2);
355
- }
356
- }
357
- set({ errors: newErrors });
358
- return isValid;
359
- },
360
- reset: () => {
361
- history.length = 0;
362
- future.length = 0;
363
- changed.clear();
364
- set({
365
- values: initialValues,
366
- errors: {},
367
- canBack: false,
368
- canForward: false,
369
- changedFields: [],
370
- changedCount: 0
371
- });
372
- },
373
- back: () => {
374
- const state = get();
375
- if (history.length === 0) return;
376
- const prev = history.pop();
377
- future.push(state.values);
378
- changed.clear();
379
- const current = prev;
380
- const initial = get().initialValues;
381
- for (const key in current) {
382
- if (JSON.stringify(current[key]) !== JSON.stringify(initial[key]))
383
- changed.add(key);
384
- }
385
- set({
386
- values: prev,
387
- canBack: history.length > 0,
388
- canForward: true,
389
- changedFields: Array.from(changed),
390
- changedCount: changed.size
391
- });
392
- },
393
- forward: () => {
394
- const state = get();
395
- if (future.length === 0) return;
396
- const next = future.pop();
397
- history.push(state.values);
398
- changed.clear();
399
- const current = next;
400
- const initial = get().initialValues;
401
- for (const key in current) {
402
- if (JSON.stringify(current[key]) !== JSON.stringify(initial[key]))
403
- changed.add(key);
404
- }
405
- set({
406
- values: next,
407
- canBack: true,
408
- canForward: future.length > 0,
409
- changedFields: Array.from(changed),
410
- changedCount: changed.size
411
- });
412
- }
413
- }));
414
- }
415
- var FormContext = createContext(null);
416
- function FormProvider({
417
- initialValues,
418
- validate,
419
- onSubmit,
420
- children
421
- }) {
422
- const storeRef = useRef(createFormStore(initialValues, validate, onSubmit));
423
- return /* @__PURE__ */ jsx(FormContext.Provider, { value: storeRef.current, children });
424
- }
425
- function useForm() {
426
- const store = useContext(FormContext);
427
- if (!store) throw new Error("useForm must be used inside a <FormProvider>");
428
- return useStore(store);
429
- }
218
+ // src/utils/fetchNui.ts
430
219
  async function fetchNui(eventName, data, mockData) {
431
220
  const options = {
432
221
  method: "post",
@@ -953,273 +742,15 @@ function createSkill(defaultSettings) {
953
742
  useSkill
954
743
  };
955
744
  }
956
- var label = {
957
- fontSize: "var(--mantine-font-size-xs)",
958
- fontFamily: "Akrobat Bold",
959
- letterSpacing: "0.05em",
960
- textTransform: "uppercase"
961
- };
962
- var error = {
963
- fontSize: "var(--mantine-font-size-xs)",
964
- fontFamily: "Akrobat Regular"
965
- };
966
- var theme = createTheme({
967
- primaryColor: "dirk",
968
- primaryShade: 9,
969
- defaultRadius: "xs",
970
- fontFamily: "Akrobat Regular, sans-serif",
971
- radius: {
972
- xxs: "0.2vh",
973
- xs: "0.4vh",
974
- sm: "0.75vh",
975
- md: "1vh",
976
- lg: "1.5vh",
977
- xl: "2vh",
978
- xxl: "3vh"
979
- },
980
- fontSizes: {
981
- xxs: "1.2vh",
982
- xs: "1.5vh",
983
- sm: "1.8vh",
984
- md: "2.2vh",
985
- lg: "2.8vh",
986
- xl: "3.3vh",
987
- xxl: "3.8vh"
988
- },
989
- lineHeights: {
990
- xxs: "1.4vh",
991
- xs: "1.8vh",
992
- sm: "2.2vh",
993
- md: "2.8vh",
994
- lg: "3.3vh",
995
- xl: "3.8vh"
996
- },
997
- spacing: {
998
- xxs: "0.5vh",
999
- xs: "0.75vh",
1000
- sm: "1.5vh",
1001
- md: "2vh",
1002
- lg: "3vh",
1003
- xl: "4vh",
1004
- xxl: "5vh"
1005
- },
1006
- components: {
1007
- Progress: {
1008
- styles: {
1009
- label: {
1010
- fontFamily: "Akrobat Bold",
1011
- letterSpacing: "0.05em",
1012
- textTransform: "uppercase"
1013
- },
1014
- root: {
1015
- backgroundColor: "rgba(77, 77, 77, 0.4)"
1016
- }
1017
- }
1018
- },
1019
- Textarea: {
1020
- styles: {
1021
- label,
1022
- error
1023
- }
1024
- },
1025
- Button: {
1026
- styles: {
1027
- root: {
1028
- fontSize: "var(--mantine-font-size-xs)"
1029
- }
1030
- }
1031
- },
1032
- Select: {
1033
- styles: {
1034
- input: {
1035
- padding: "var(--mantine-spacing-sm)"
1036
- }
1037
- }
1038
- },
1039
- Pill: {
1040
- styles: (theme2) => ({
1041
- root: {
1042
- display: "inline-flex",
1043
- alignItems: "center",
1044
- justifyContent: "space-between",
1045
- backgroundColor: "rgba(76, 76, 76, 0.3)",
1046
- height: "fit-content",
1047
- textTransform: "uppercase",
1048
- letterSpacing: "0.05em",
1049
- fontFamily: "Akrobat Bold",
1050
- fontSize: theme2.fontSizes.xs,
1051
- borderRadius: theme2.defaultRadius,
1052
- padding: `${theme2.spacing.xs} ${theme2.spacing.sm}`
1053
- }
1054
- })
1055
- },
1056
- Input: {
1057
- styles: {
1058
- label,
1059
- error,
1060
- input: {
1061
- padding: "var(--mantine-spacing-sm)",
1062
- backgroundColor: "rgba(76, 76, 76, 0.3)"
1063
- }
1064
- }
1065
- },
1066
- ColorInput: {
1067
- styles: {
1068
- label,
1069
- input: {
1070
- padding: "var(--mantine-spacing-sm)"
1071
- }
1072
- }
1073
- },
1074
- TextInput: {
1075
- styles: {
1076
- label,
1077
- wrapper: {},
1078
- section: {
1079
- marginRight: "0.2vh"
1080
- },
1081
- input: {
1082
- padding: "var(--mantine-spacing-sm)"
1083
- }
1084
- }
1085
- },
1086
- NumberInput: {
1087
- styles: {
1088
- label,
1089
- input: {
1090
- padding: "var(--mantine-spacing-sm)"
1091
- },
1092
- section: {
1093
- pointerEvents: "all"
1094
- }
1095
- }
1096
- }
1097
- },
1098
- colors: {
1099
- dirk: [
1100
- "#ffffff",
1101
- "#f3fce9",
1102
- "#dbf5bd",
1103
- "#c3ee91",
1104
- "#ace765",
1105
- "#94e039",
1106
- "#7ac61f",
1107
- "#5f9a18",
1108
- "#29420a",
1109
- "#446e11"
1110
- ]
1111
- }
1112
- });
1113
- var theme_default = theme;
1114
- library.add(fas, far, fab);
1115
- var useSettings = create((set) => ({
1116
- game: "fivem",
1117
- primaryColor: "dirk",
1118
- primaryShade: 9,
1119
- itemImgPath: "https://assets.dirkcfx.com/items/",
1120
- customTheme: {}
1121
- }));
1122
- function DirkProvider(props) {
1123
- const primaryColor = useSettings((data) => data.primaryColor);
1124
- const primaryShade = useSettings((data) => data.primaryShade);
1125
- const customTheme = useSettings((data) => data.customTheme);
1126
- const game = useSettings((data) => data.game);
1127
- const mergedTheme = useMemo(() => ({
1128
- ...theme_default,
1129
- primaryColor,
1130
- primaryShade,
1131
- colors: {
1132
- ...theme_default.colors,
1133
- ...customTheme
1134
- // Custom theme colors will override/extend base colors
1135
- }
1136
- }), [primaryColor, primaryShade, customTheme]);
1137
- useEffect(() => {
1138
- document.fonts.ready.then(() => {
1139
- document.body.style.fontFamily = game === "rdr3" ? '"Red Dead", sans-serif' : game === "fivem" ? '"Akrobat Regular", sans-serif' : "sans-serif";
1140
- console.log(`Game set to ${game}, applied corresponding font family.: ${document.body.style.fontFamily}`);
1141
- });
1142
- }, [game]);
1143
- useEffect(() => {
1144
- fetchNui("NUI_READY");
1145
- }, []);
1146
- useAutoFetcher();
1147
- return /* @__PURE__ */ jsx(MantineProvider, { theme: mergedTheme, defaultColorScheme: "dark", children: /* @__PURE__ */ jsx(Wrapper, { children: props.children }) });
1148
- }
1149
- function Wrapper({ children }) {
1150
- const game = useSettings((data) => data.game);
1151
- return isEnvBrowser() ? /* @__PURE__ */ jsx(
1152
- BackgroundImage,
1153
- {
1154
- w: "100vw",
1155
- h: "100vh",
1156
- style: { overflow: "hidden" },
1157
- src: game === "fivem" ? "https://i.ytimg.com/vi/TOxuNbXrO28/maxresdefault.jpg" : "https://raw.githubusercontent.com/Jump-On-Studios/RedM-jo_libs/refs/heads/main/source-repositories/Menu/public/assets/images/background_dev.jpg",
1158
- children
1159
- }
1160
- ) : /* @__PURE__ */ jsx(Fragment, { children });
1161
- }
1162
- function useTornEdges() {
1163
- const game = useSettings((state) => state.game);
1164
- return game === "rdr3" ? "torn-edge-wrapper" : "";
1165
- }
1166
- function TornEdgeSVGFilter() {
1167
- return /* @__PURE__ */ jsx(
1168
- "svg",
1169
- {
1170
- style: { position: "absolute", width: 0, height: 0, pointerEvents: "none" },
1171
- "aria-hidden": "true",
1172
- children: /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("filter", { id: "torn-edge-filter", x: "-50%", y: "-50%", width: "200%", height: "200%", children: [
1173
- /* @__PURE__ */ jsx(
1174
- "feTurbulence",
1175
- {
1176
- type: "fractalNoise",
1177
- baseFrequency: "0.018 0.022",
1178
- numOctaves: "5",
1179
- seed: "9",
1180
- result: "noise1"
1181
- }
1182
- ),
1183
- /* @__PURE__ */ jsx(
1184
- "feTurbulence",
1185
- {
1186
- type: "fractalNoise",
1187
- baseFrequency: "0.08 0.12",
1188
- numOctaves: "2",
1189
- seed: "3",
1190
- result: "noise2"
1191
- }
1192
- ),
1193
- /* @__PURE__ */ jsx("feBlend", { in: "noise1", in2: "noise2", mode: "multiply", result: "combinedNoise" }),
1194
- /* @__PURE__ */ jsx(
1195
- "feDisplacementMap",
1196
- {
1197
- in: "SourceGraphic",
1198
- in2: "combinedNoise",
1199
- scale: "52",
1200
- xChannelSelector: "R",
1201
- yChannelSelector: "G",
1202
- result: "displaced"
1203
- }
1204
- ),
1205
- /* @__PURE__ */ jsx("feGaussianBlur", { stdDeviation: "0.8", in: "displaced", result: "blurred" }),
1206
- /* @__PURE__ */ jsx("feComponentTransfer", { in: "blurred", result: "alphaFade", children: /* @__PURE__ */ jsx("feFuncA", { type: "gamma", amplitude: "1", exponent: "1.3", offset: "-0.05" }) }),
1207
- /* @__PURE__ */ jsx("feMorphology", { operator: "erode", radius: "0.4", in: "alphaFade", result: "eroded" }),
1208
- /* @__PURE__ */ jsx("feMerge", { children: /* @__PURE__ */ jsx("feMergeNode", { in: "eroded" }) })
1209
- ] }) })
1210
- }
1211
- );
1212
- }
1213
745
  function BorderedIcon(props) {
1214
746
  const theme2 = useMantineTheme();
1215
- const tornEdgeCSS = useTornEdges();
1216
747
  return /* @__PURE__ */ jsx(
1217
- Flex,
748
+ FontAwesomeIcon,
1218
749
  {
1219
- className: tornEdgeCSS,
1220
- justify: "center",
1221
- align: "center",
750
+ icon: props.icon,
751
+ color: colorWithAlpha(props.color ? props.color : theme2.colors[theme2.primaryColor][theme2.primaryShade], props.hovered ? 0.9 : 0.9),
1222
752
  style: {
753
+ // backgroundColor: colorWithAlpha(props.color ? props.color : theme.colors[theme.primaryColor][7 as number], (props.hoverable ? (props.hovered ? 0.3 : 0.2) : 0.2)),
1223
754
  backgroundColor: "rgba(0, 0, 0, 0.5)",
1224
755
  padding: props.p || theme2.spacing.xs,
1225
756
  transition: "all 0.2s ease-in-out",
@@ -1227,19 +758,9 @@ function BorderedIcon(props) {
1227
758
  fontSize: props.fontSize ? props.fontSize : "2.5vh",
1228
759
  borderRadius: theme2.radius.xs,
1229
760
  // border: `2px solid var(--mantine-primary-color-9)`,
1230
- // outline: `0.2vh solid ${colorWithAlpha(props.color ? props.color : theme.colors[theme.primaryColor][9], 0.8)}`,
761
+ outline: `0.2vh solid ${colorWithAlpha(props.color ? props.color : theme2.colors[theme2.primaryColor][9], 0.8)}`,
1231
762
  boxShadow: `inset 0 0 2vh ${colorWithAlpha(props.color ? props.color : theme2.colors[theme2.primaryColor][7], 0.5)}`
1232
- },
1233
- children: /* @__PURE__ */ jsx(
1234
- FontAwesomeIcon,
1235
- {
1236
- icon: props.icon,
1237
- color: colorWithAlpha(props.color ? props.color : theme2.colors[theme2.primaryColor][theme2.primaryShade], props.hovered ? 0.9 : 0.9),
1238
- style: {
1239
- // backgroundColor: colorWithAlpha(props.color ? props.color : theme.colors[theme.primaryColor][7 as number], (props.hoverable ? (props.hovered ? 0.3 : 0.2) : 0.2)),
1240
- }
1241
- }
1242
- )
763
+ }
1243
764
  }
1244
765
  );
1245
766
  }
@@ -1747,13 +1268,13 @@ function Segment(props) {
1747
1268
  {
1748
1269
  size: props.fz || "xs",
1749
1270
  initial: {
1750
- color: props.selected ? props.color || theme2.colors[theme2.primaryColor][5] : "inherit"
1271
+ color: props.selected ? props.color || theme2.colors[theme2.primaryColor][5] : "rgba(255, 255, 255, 0.7)"
1751
1272
  },
1752
1273
  animate: {
1753
- color: props.selected ? props.color || theme2.colors[theme2.primaryColor][5] : "inherit"
1274
+ color: props.selected ? props.color || theme2.colors[theme2.primaryColor][5] : "rgba(255, 255, 255, 0.7)"
1754
1275
  },
1755
1276
  exit: {
1756
- color: "inherit"
1277
+ color: "rgba(255, 255, 255, 0.7)"
1757
1278
  },
1758
1279
  style: {
1759
1280
  fontFamily: "Akrobat Bold",
@@ -2137,6 +1658,472 @@ function Modal() {
2137
1658
  }
2138
1659
  ) });
2139
1660
  }
1661
+ var useNuiEvent = (action, handler) => {
1662
+ const savedHandler = useRef(noop);
1663
+ useEffect(() => {
1664
+ savedHandler.current = handler;
1665
+ }, [handler]);
1666
+ useEffect(() => {
1667
+ const eventListener = (event) => {
1668
+ const { action: eventAction, data } = event.data;
1669
+ if (savedHandler.current) {
1670
+ if (eventAction === action) {
1671
+ savedHandler.current(data);
1672
+ }
1673
+ }
1674
+ };
1675
+ window.addEventListener("message", eventListener);
1676
+ return () => window.removeEventListener("message", eventListener);
1677
+ }, [action]);
1678
+ };
1679
+ function getNested(obj, path) {
1680
+ return path.split(".").reduce((acc, key) => acc ? acc[key] : void 0, obj);
1681
+ }
1682
+ function setNested(obj, path, value) {
1683
+ const keys = path.split(".");
1684
+ const newObj = { ...obj };
1685
+ let current = newObj;
1686
+ for (let i = 0; i < keys.length - 1; i++) {
1687
+ const key = keys[i];
1688
+ current[key] = { ...current[key] || {} };
1689
+ current = current[key];
1690
+ }
1691
+ current[keys[keys.length - 1]] = value;
1692
+ return newObj;
1693
+ }
1694
+ function deleteNested(obj, path) {
1695
+ const keys = path.split(".");
1696
+ const newObj = { ...obj };
1697
+ let current = newObj;
1698
+ for (let i = 0; i < keys.length - 1; i++) {
1699
+ const key = keys[i];
1700
+ if (!current[key]) return obj;
1701
+ current[key] = { ...current[key] };
1702
+ current = current[key];
1703
+ }
1704
+ delete current[keys[keys.length - 1]];
1705
+ return newObj;
1706
+ }
1707
+ function flattenRules(rules, prefix = "") {
1708
+ const result = {};
1709
+ for (const key in rules) {
1710
+ const fullPath = prefix ? `${prefix}.${key}` : key;
1711
+ const val = rules[key];
1712
+ if (typeof val === "function") result[fullPath] = val;
1713
+ else if (typeof val === "object")
1714
+ Object.assign(result, flattenRules(val, fullPath));
1715
+ }
1716
+ return result;
1717
+ }
1718
+ function createFormStore(initialValues, validationRules, onSubmit) {
1719
+ const flatRules = validationRules ? flattenRules(validationRules) : {};
1720
+ const history = [];
1721
+ const future = [];
1722
+ const changed = /* @__PURE__ */ new Set();
1723
+ return createStore((set, get) => ({
1724
+ initialValues,
1725
+ values: initialValues,
1726
+ errors: {},
1727
+ canBack: false,
1728
+ canForward: false,
1729
+ changedFields: [],
1730
+ changedCount: 0,
1731
+ onSubmit,
1732
+ submit: () => {
1733
+ const state = get();
1734
+ const isValid = state.validate();
1735
+ if (isValid && state.onSubmit) state.onSubmit(get());
1736
+ },
1737
+ resetChangeCount: () => {
1738
+ changed.clear();
1739
+ set(() => ({
1740
+ changedFields: [],
1741
+ changedCount: 0
1742
+ }));
1743
+ },
1744
+ setInitialValues: (newInitialValues) => set({ initialValues: newInitialValues }),
1745
+ setValue: (path, value) => {
1746
+ const currentValues = get().values;
1747
+ const newValues = setNested(currentValues, path, value);
1748
+ const oldValue = getNested(get().initialValues, path);
1749
+ history.push(currentValues);
1750
+ future.length = 0;
1751
+ if (value !== oldValue) changed.add(path);
1752
+ else changed.delete(path);
1753
+ set({
1754
+ values: newValues,
1755
+ canBack: history.length > 0,
1756
+ canForward: false,
1757
+ changedFields: Array.from(changed),
1758
+ changedCount: changed.size
1759
+ });
1760
+ const rule = flatRules[path];
1761
+ if (rule) {
1762
+ const error2 = rule(value, newValues);
1763
+ if (error2)
1764
+ set((state) => ({ errors: setNested(state.errors, path, error2) }));
1765
+ else set((state) => ({ errors: deleteNested(state.errors, path) }));
1766
+ }
1767
+ },
1768
+ setError: (path, message) => set((state) => ({ errors: setNested(state.errors, path, message) })),
1769
+ clearError: (path) => set((state) => ({ errors: deleteNested(state.errors, path) })),
1770
+ validateField: (path) => {
1771
+ const state = get();
1772
+ const rule = flatRules[path];
1773
+ if (!rule) return true;
1774
+ const value = getNested(state.values, path);
1775
+ const error2 = rule(value, state.values);
1776
+ if (error2) {
1777
+ set((state2) => ({ errors: setNested(state2.errors, path, error2) }));
1778
+ return false;
1779
+ } else {
1780
+ set((state2) => ({ errors: deleteNested(state2.errors, path) }));
1781
+ return true;
1782
+ }
1783
+ },
1784
+ validate: () => {
1785
+ const state = get();
1786
+ let isValid = true;
1787
+ let newErrors = {};
1788
+ for (const path in flatRules) {
1789
+ const rule = flatRules[path];
1790
+ const value = getNested(state.values, path);
1791
+ const error2 = rule(value, state.values);
1792
+ if (error2) {
1793
+ isValid = false;
1794
+ newErrors = setNested(newErrors, path, error2);
1795
+ }
1796
+ }
1797
+ set({ errors: newErrors });
1798
+ return isValid;
1799
+ },
1800
+ reset: () => {
1801
+ history.length = 0;
1802
+ future.length = 0;
1803
+ changed.clear();
1804
+ set({
1805
+ values: initialValues,
1806
+ errors: {},
1807
+ canBack: false,
1808
+ canForward: false,
1809
+ changedFields: [],
1810
+ changedCount: 0
1811
+ });
1812
+ },
1813
+ back: () => {
1814
+ const state = get();
1815
+ if (history.length === 0) return;
1816
+ const prev = history.pop();
1817
+ future.push(state.values);
1818
+ changed.clear();
1819
+ const current = prev;
1820
+ const initial = get().initialValues;
1821
+ for (const key in current) {
1822
+ if (JSON.stringify(current[key]) !== JSON.stringify(initial[key]))
1823
+ changed.add(key);
1824
+ }
1825
+ set({
1826
+ values: prev,
1827
+ canBack: history.length > 0,
1828
+ canForward: true,
1829
+ changedFields: Array.from(changed),
1830
+ changedCount: changed.size
1831
+ });
1832
+ },
1833
+ forward: () => {
1834
+ const state = get();
1835
+ if (future.length === 0) return;
1836
+ const next = future.pop();
1837
+ history.push(state.values);
1838
+ changed.clear();
1839
+ const current = next;
1840
+ const initial = get().initialValues;
1841
+ for (const key in current) {
1842
+ if (JSON.stringify(current[key]) !== JSON.stringify(initial[key]))
1843
+ changed.add(key);
1844
+ }
1845
+ set({
1846
+ values: next,
1847
+ canBack: true,
1848
+ canForward: future.length > 0,
1849
+ changedFields: Array.from(changed),
1850
+ changedCount: changed.size
1851
+ });
1852
+ }
1853
+ }));
1854
+ }
1855
+ var FormContext = createContext(null);
1856
+ function FormProvider({
1857
+ initialValues,
1858
+ validate,
1859
+ onSubmit,
1860
+ children
1861
+ }) {
1862
+ const storeRef = useRef(createFormStore(initialValues, validate, onSubmit));
1863
+ return /* @__PURE__ */ jsx(FormContext.Provider, { value: storeRef.current, children });
1864
+ }
1865
+ function useForm() {
1866
+ const store = useContext(FormContext);
1867
+ if (!store) throw new Error("useForm must be used inside a <FormProvider>");
1868
+ return useStore(store);
1869
+ }
1870
+ var label = {
1871
+ fontSize: "var(--mantine-font-size-xs)",
1872
+ fontFamily: "Akrobat Bold",
1873
+ letterSpacing: "0.05em",
1874
+ textTransform: "uppercase"
1875
+ };
1876
+ var error = {
1877
+ fontSize: "var(--mantine-font-size-xs)",
1878
+ fontFamily: "Akrobat Regular"
1879
+ };
1880
+ var theme = createTheme({
1881
+ primaryColor: "dirk",
1882
+ primaryShade: 9,
1883
+ defaultRadius: "xs",
1884
+ fontFamily: "Akrobat Regular, sans-serif",
1885
+ radius: {
1886
+ xxs: "0.2vh",
1887
+ xs: "0.4vh",
1888
+ sm: "0.75vh",
1889
+ md: "1vh",
1890
+ lg: "1.5vh",
1891
+ xl: "2vh",
1892
+ xxl: "3vh"
1893
+ },
1894
+ fontSizes: {
1895
+ xxs: "1.2vh",
1896
+ xs: "1.5vh",
1897
+ sm: "1.8vh",
1898
+ md: "2.2vh",
1899
+ lg: "2.8vh",
1900
+ xl: "3.3vh",
1901
+ xxl: "3.8vh"
1902
+ },
1903
+ lineHeights: {
1904
+ xxs: "1.4vh",
1905
+ xs: "1.8vh",
1906
+ sm: "2.2vh",
1907
+ md: "2.8vh",
1908
+ lg: "3.3vh",
1909
+ xl: "3.8vh"
1910
+ },
1911
+ spacing: {
1912
+ xxs: "0.5vh",
1913
+ xs: "0.75vh",
1914
+ sm: "1.5vh",
1915
+ md: "2vh",
1916
+ lg: "3vh",
1917
+ xl: "4vh",
1918
+ xxl: "5vh"
1919
+ },
1920
+ components: {
1921
+ Progress: {
1922
+ styles: {
1923
+ label: {
1924
+ fontFamily: "Akrobat Bold",
1925
+ letterSpacing: "0.05em",
1926
+ textTransform: "uppercase"
1927
+ },
1928
+ root: {
1929
+ backgroundColor: "rgba(77, 77, 77, 0.4)"
1930
+ }
1931
+ }
1932
+ },
1933
+ Textarea: {
1934
+ styles: {
1935
+ label,
1936
+ error
1937
+ }
1938
+ },
1939
+ Button: {
1940
+ styles: {
1941
+ root: {
1942
+ fontSize: "var(--mantine-font-size-xs)"
1943
+ }
1944
+ }
1945
+ },
1946
+ Select: {
1947
+ styles: {
1948
+ input: {
1949
+ padding: "var(--mantine-spacing-sm)"
1950
+ }
1951
+ }
1952
+ },
1953
+ Pill: {
1954
+ styles: (theme2) => ({
1955
+ root: {
1956
+ display: "inline-flex",
1957
+ alignItems: "center",
1958
+ justifyContent: "space-between",
1959
+ backgroundColor: "rgba(76, 76, 76, 0.3)",
1960
+ height: "fit-content",
1961
+ textTransform: "uppercase",
1962
+ letterSpacing: "0.05em",
1963
+ fontFamily: "Akrobat Bold",
1964
+ fontSize: theme2.fontSizes.xs,
1965
+ borderRadius: theme2.defaultRadius,
1966
+ padding: `${theme2.spacing.xs} ${theme2.spacing.sm}`
1967
+ }
1968
+ })
1969
+ },
1970
+ Input: {
1971
+ styles: {
1972
+ label,
1973
+ error,
1974
+ input: {
1975
+ padding: "var(--mantine-spacing-sm)",
1976
+ backgroundColor: "rgba(76, 76, 76, 0.3)"
1977
+ }
1978
+ }
1979
+ },
1980
+ ColorInput: {
1981
+ styles: {
1982
+ label,
1983
+ input: {
1984
+ padding: "var(--mantine-spacing-sm)"
1985
+ }
1986
+ }
1987
+ },
1988
+ TextInput: {
1989
+ styles: {
1990
+ label,
1991
+ wrapper: {},
1992
+ section: {
1993
+ marginRight: "0.2vh"
1994
+ },
1995
+ input: {
1996
+ padding: "var(--mantine-spacing-sm)"
1997
+ }
1998
+ }
1999
+ },
2000
+ NumberInput: {
2001
+ styles: {
2002
+ label,
2003
+ input: {
2004
+ padding: "var(--mantine-spacing-sm)"
2005
+ },
2006
+ section: {
2007
+ pointerEvents: "all"
2008
+ }
2009
+ }
2010
+ }
2011
+ },
2012
+ colors: {
2013
+ dirk: [
2014
+ "#ffffff",
2015
+ "#f3fce9",
2016
+ "#dbf5bd",
2017
+ "#c3ee91",
2018
+ "#ace765",
2019
+ "#94e039",
2020
+ "#7ac61f",
2021
+ "#5f9a18",
2022
+ "#29420a",
2023
+ "#446e11"
2024
+ ]
2025
+ }
2026
+ });
2027
+ var theme_default = theme;
2028
+ library.add(fas, far, fab);
2029
+ var useSettings = create((set) => ({
2030
+ game: "fivem",
2031
+ primaryColor: "dirk",
2032
+ primaryShade: 9,
2033
+ itemImgPath: "https://assets.dirkcfx.com/items/",
2034
+ customTheme: {}
2035
+ }));
2036
+ function DirkProvider(props) {
2037
+ const primaryColor = useSettings((data) => data.primaryColor);
2038
+ const primaryShade = useSettings((data) => data.primaryShade);
2039
+ const customTheme = useSettings((data) => data.customTheme);
2040
+ const game = useSettings((data) => data.game);
2041
+ const mergedTheme = useMemo(() => ({
2042
+ ...theme_default,
2043
+ primaryColor,
2044
+ primaryShade,
2045
+ colors: {
2046
+ ...theme_default.colors,
2047
+ ...customTheme
2048
+ // Custom theme colors will override/extend base colors
2049
+ }
2050
+ }), [primaryColor, primaryShade, customTheme]);
2051
+ useEffect(() => {
2052
+ document.fonts.ready.then(() => {
2053
+ document.body.style.fontFamily = game === "rdr3" ? '"Red Dead", sans-serif' : game === "fivem" ? '"Akrobat Regular", sans-serif' : "sans-serif";
2054
+ console.log(`Game set to ${game}, applied corresponding font family.: ${document.body.style.fontFamily}`);
2055
+ });
2056
+ }, [game]);
2057
+ useEffect(() => {
2058
+ fetchNui("NUI_READY");
2059
+ }, []);
2060
+ useAutoFetcher();
2061
+ return /* @__PURE__ */ jsx(MantineProvider, { theme: mergedTheme, defaultColorScheme: "dark", children: /* @__PURE__ */ jsx(Wrapper, { children: props.children }) });
2062
+ }
2063
+ function Wrapper({ children }) {
2064
+ const game = useSettings((data) => data.game);
2065
+ return isEnvBrowser() ? /* @__PURE__ */ jsx(
2066
+ BackgroundImage,
2067
+ {
2068
+ w: "100vw",
2069
+ h: "100vh",
2070
+ style: { overflow: "hidden" },
2071
+ src: game === "fivem" ? "https://i.ytimg.com/vi/TOxuNbXrO28/maxresdefault.jpg" : "https://raw.githubusercontent.com/Jump-On-Studios/RedM-jo_libs/refs/heads/main/source-repositories/Menu/public/assets/images/background_dev.jpg",
2072
+ children
2073
+ }
2074
+ ) : /* @__PURE__ */ jsx(Fragment, { children });
2075
+ }
2076
+ function useTornEdges() {
2077
+ const game = useSettings((state) => state.game);
2078
+ return game === "rdr3" ? "torn-edge-wrapper" : "";
2079
+ }
2080
+ function TornEdgeSVGFilter() {
2081
+ return /* @__PURE__ */ jsx(
2082
+ "svg",
2083
+ {
2084
+ style: { position: "absolute", width: 0, height: 0, pointerEvents: "none" },
2085
+ "aria-hidden": "true",
2086
+ children: /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("filter", { id: "torn-edge-filter", x: "-50%", y: "-50%", width: "200%", height: "200%", children: [
2087
+ /* @__PURE__ */ jsx(
2088
+ "feTurbulence",
2089
+ {
2090
+ type: "fractalNoise",
2091
+ baseFrequency: "0.018 0.022",
2092
+ numOctaves: "5",
2093
+ seed: "9",
2094
+ result: "noise1"
2095
+ }
2096
+ ),
2097
+ /* @__PURE__ */ jsx(
2098
+ "feTurbulence",
2099
+ {
2100
+ type: "fractalNoise",
2101
+ baseFrequency: "0.08 0.12",
2102
+ numOctaves: "2",
2103
+ seed: "3",
2104
+ result: "noise2"
2105
+ }
2106
+ ),
2107
+ /* @__PURE__ */ jsx("feBlend", { in: "noise1", in2: "noise2", mode: "multiply", result: "combinedNoise" }),
2108
+ /* @__PURE__ */ jsx(
2109
+ "feDisplacementMap",
2110
+ {
2111
+ in: "SourceGraphic",
2112
+ in2: "combinedNoise",
2113
+ scale: "52",
2114
+ xChannelSelector: "R",
2115
+ yChannelSelector: "G",
2116
+ result: "displaced"
2117
+ }
2118
+ ),
2119
+ /* @__PURE__ */ jsx("feGaussianBlur", { stdDeviation: "0.8", in: "displaced", result: "blurred" }),
2120
+ /* @__PURE__ */ jsx("feComponentTransfer", { in: "blurred", result: "alphaFade", children: /* @__PURE__ */ jsx("feFuncA", { type: "gamma", amplitude: "1", exponent: "1.3", offset: "-0.05" }) }),
2121
+ /* @__PURE__ */ jsx("feMorphology", { operator: "erode", radius: "0.4", in: "alphaFade", result: "eroded" }),
2122
+ /* @__PURE__ */ jsx("feMerge", { children: /* @__PURE__ */ jsx("feMergeNode", { in: "eroded" }) })
2123
+ ] }) })
2124
+ }
2125
+ );
2126
+ }
2140
2127
 
2141
2128
  export { BorderedIcon, Counter, DirkProvider, FloatingParticles, FormProvider, InfoBox, InputContainer, ModalContext, ModalProvider, MotionFlex, MotionIcon, MotionImage, MotionText, NavBar, NavigationContext, NavigationProvider, SegmentedControl, SegmentedProgress, Title, TornEdgeSVGFilter, colorWithAlpha, copyToClipboard, createFormStore, createSkill, fetchNui, initialFetches, internalEvent, isEnvBrowser, isProfanity, locale, localeStore, noop, numberToRoman, openLink, registerInitialFetch, runFetches, splitFAString, useAutoFetcher, useForm, useModal, useModalActions, useNavigation, useNavigationStore, useNuiEvent, useProfanityStore, useSettings, useTornEdges };
2142
2129
  //# sourceMappingURL=index.js.map