dirk-cfx-react 1.1.93 → 1.1.94

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.
Files changed (63) hide show
  1. package/dist/chunk-3T2CCW5E.cjs +150 -0
  2. package/dist/chunk-3T2CCW5E.cjs.map +1 -0
  3. package/dist/chunk-4DE2IREA.cjs +9 -0
  4. package/dist/chunk-4DE2IREA.cjs.map +1 -0
  5. package/dist/chunk-E2SFEBBB.cjs +449 -0
  6. package/dist/chunk-E2SFEBBB.cjs.map +1 -0
  7. package/dist/chunk-GKSP5RIA.js +3 -0
  8. package/dist/chunk-GKSP5RIA.js.map +1 -0
  9. package/dist/chunk-HAB6H274.js +6646 -0
  10. package/dist/chunk-HAB6H274.js.map +1 -0
  11. package/dist/chunk-K3GDU6EY.cjs +6717 -0
  12. package/dist/chunk-K3GDU6EY.cjs.map +1 -0
  13. package/dist/chunk-KGLO3ZAS.js +431 -0
  14. package/dist/chunk-KGLO3ZAS.js.map +1 -0
  15. package/dist/chunk-LRGCBNZ7.cjs +4 -0
  16. package/dist/chunk-LRGCBNZ7.cjs.map +1 -0
  17. package/dist/chunk-MYNNCLMA.js +1375 -0
  18. package/dist/chunk-MYNNCLMA.js.map +1 -0
  19. package/dist/chunk-NVMOGS7Y.js +437 -0
  20. package/dist/chunk-NVMOGS7Y.js.map +1 -0
  21. package/dist/chunk-QOQQ3ERZ.cjs +445 -0
  22. package/dist/chunk-QOQQ3ERZ.cjs.map +1 -0
  23. package/dist/chunk-V6TY7KAL.js +7 -0
  24. package/dist/chunk-V6TY7KAL.js.map +1 -0
  25. package/dist/chunk-VKYONY7E.cjs +112 -0
  26. package/dist/chunk-VKYONY7E.cjs.map +1 -0
  27. package/dist/chunk-YA2PXBP6.cjs +1430 -0
  28. package/dist/chunk-YA2PXBP6.cjs.map +1 -0
  29. package/dist/chunk-Z7N5AQJW.js +146 -0
  30. package/dist/chunk-Z7N5AQJW.js.map +1 -0
  31. package/dist/chunk-ZPFW7C2A.js +108 -0
  32. package/dist/chunk-ZPFW7C2A.js.map +1 -0
  33. package/dist/components/index.cjs +282 -7760
  34. package/dist/components/index.cjs.map +1 -1
  35. package/dist/components/index.d.cts +39 -1
  36. package/dist/components/index.d.ts +39 -1
  37. package/dist/components/index.js +6 -7699
  38. package/dist/components/index.js.map +1 -1
  39. package/dist/hooks/index.cjs +75 -749
  40. package/dist/hooks/index.cjs.map +1 -1
  41. package/dist/hooks/index.js +5 -732
  42. package/dist/hooks/index.js.map +1 -1
  43. package/dist/index.cjs +572 -9091
  44. package/dist/index.cjs.map +1 -1
  45. package/dist/index.d.cts +2 -2
  46. package/dist/index.d.ts +2 -2
  47. package/dist/index.js +9 -8953
  48. package/dist/index.js.map +1 -1
  49. package/dist/modelNames-QIAIYORH.cjs +53910 -0
  50. package/dist/modelNames-QIAIYORH.cjs.map +1 -0
  51. package/dist/modelNames-WAUYJLL3.js +53908 -0
  52. package/dist/modelNames-WAUYJLL3.js.map +1 -0
  53. package/dist/providers/index.cjs +11 -590
  54. package/dist/providers/index.cjs.map +1 -1
  55. package/dist/providers/index.js +5 -590
  56. package/dist/providers/index.js.map +1 -1
  57. package/dist/utils/index.cjs +186 -1361
  58. package/dist/utils/index.cjs.map +1 -1
  59. package/dist/utils/index.d.cts +41 -1
  60. package/dist/utils/index.d.ts +41 -1
  61. package/dist/utils/index.js +2 -1324
  62. package/dist/utils/index.js.map +1 -1
  63. package/package.json +1 -1
@@ -1,599 +1,20 @@
1
1
  'use strict';
2
2
 
3
- require('@mantine/core/styles.css');
4
- require('@mantine/notifications/styles.css');
5
- require('./styles/fonts.css');
6
- require('./styles/notify.css');
7
- require('./styles/scrollBar.css');
8
- require('./styles/tornEdge.css');
9
- var fontawesomeSvgCore = require('@fortawesome/fontawesome-svg-core');
10
- var freeBrandsSvgIcons = require('@fortawesome/free-brands-svg-icons');
11
- var freeRegularSvgIcons = require('@fortawesome/free-regular-svg-icons');
12
- var freeSolidSvgIcons = require('@fortawesome/free-solid-svg-icons');
13
- var core = require('@mantine/core');
14
- var React = require('react');
15
- var zustand = require('zustand');
16
- var zod = require('zod');
17
- var jsxRuntime = require('react/jsx-runtime');
18
- var reactQuery = require('@tanstack/react-query');
3
+ require('../chunk-LRGCBNZ7.cjs');
4
+ var chunkQOQQ3ERZ_cjs = require('../chunk-QOQQ3ERZ.cjs');
5
+ require('../chunk-3T2CCW5E.cjs');
6
+ require('../chunk-YA2PXBP6.cjs');
7
+ require('../chunk-4DE2IREA.cjs');
19
8
 
20
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
21
9
 
22
- var React__default = /*#__PURE__*/_interopDefault(React);
23
10
 
24
- var __defProp = Object.defineProperty;
25
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
26
- var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
27
- var label = {
28
- fontSize: "var(--mantine-font-size-xs)",
29
- fontFamily: "Akrobat Bold",
30
- letterSpacing: "0.05em",
31
- textTransform: "uppercase"
32
- };
33
- var error = {
34
- fontSize: "var(--mantine-font-size-xs)",
35
- fontFamily: "Akrobat Regular"
36
- };
37
- var description = {
38
- fontSize: "var(--mantine-font-size-xs)"
39
- };
40
- var genericInputStyles = {
41
- styles: {
42
- label,
43
- error,
44
- description,
45
- input: {
46
- background: "rgba(255,255,255,0.04)",
47
- border: "0.1vh solid rgba(255,255,255,0.08)",
48
- color: "rgba(255,255,255,0.85)",
49
- minHeight: "4vh"
50
- }
51
- }
52
- };
53
- var theme = core.createTheme({
54
- primaryColor: "dirk",
55
- primaryShade: 9,
56
- defaultRadius: "xs",
57
- fontFamily: "Akrobat Regular, sans-serif",
58
- radius: {
59
- xxs: "0.3vh",
60
- xs: "0.5vh",
61
- sm: "0.75vh",
62
- md: "1vh",
63
- lg: "1.5vh",
64
- xl: "2vh",
65
- xxl: "3vh"
66
- },
67
- fontSizes: {
68
- xxs: "1.2vh",
69
- xs: "1.5vh",
70
- sm: "1.8vh",
71
- md: "2.2vh",
72
- lg: "2.8vh",
73
- xl: "3.3vh",
74
- xxl: "3.8vh"
75
- },
76
- lineHeights: {
77
- xxs: "1.4vh",
78
- xs: "1.8vh",
79
- sm: "2.2vh",
80
- md: "2.8vh",
81
- lg: "3.3vh",
82
- xl: "3.8vh"
83
- },
84
- spacing: {
85
- xxs: "0.5vh",
86
- xs: "0.75vh",
87
- sm: "1.5vh",
88
- md: "2vh",
89
- lg: "3vh",
90
- xl: "4vh",
91
- xxl: "5vh"
92
- },
93
- components: {
94
- Progress: {
95
- styles: {
96
- label: {
97
- fontFamily: "Akrobat Bold",
98
- letterSpacing: "0.05em",
99
- textTransform: "uppercase"
100
- },
101
- root: {
102
- backgroundColor: "rgba(77, 77, 77, 0.4)"
103
- }
104
- }
105
- },
106
- Input: genericInputStyles,
107
- TextInput: genericInputStyles,
108
- NumberInput: genericInputStyles,
109
- Select: genericInputStyles,
110
- MultiSelect: genericInputStyles,
111
- Textarea: genericInputStyles,
112
- ColorInput: genericInputStyles,
113
- DateInput: genericInputStyles,
114
- // Mantine's <Button> defaults to rem-based heights (xs ≈ 1.875rem)
115
- // which doesn't match this theme's vh-based input min-heights, so
116
- // `<Button size="xs">` rendered next to `<TextInput size="xs">` ends
117
- // up visibly shorter. Pin the button heights to the same vh values
118
- // the inputs use so xs-everything lines up out of the box.
119
- Button: {
120
- styles: {
121
- label: {
122
- fontFamily: "Akrobat Bold",
123
- letterSpacing: "0.05em",
124
- textTransform: "uppercase"
125
- },
126
- root: {
127
- // Mantine maps these to --button-height per size; setting them
128
- // directly here keeps native Button sizing logic intact.
129
- }
130
- },
131
- vars: (_theme, props) => {
132
- const heights = {
133
- xs: "4vh",
134
- sm: "4.5vh",
135
- md: "5vh",
136
- lg: "5.5vh",
137
- xl: "6vh"
138
- };
139
- const h = heights[props.size ?? "sm"] ?? "4.5vh";
140
- return {
141
- root: {
142
- "--button-height": h
143
- }
144
- };
145
- }
146
- },
147
- Pill: {
148
- styles: (theme2) => ({
149
- root: {
150
- display: "inline-flex",
151
- alignItems: "center",
152
- justifyContent: "space-between",
153
- backgroundColor: "rgba(76, 76, 76, 0.3)",
154
- height: "fit-content",
155
- textTransform: "uppercase",
156
- letterSpacing: "0.05em",
157
- fontFamily: "Akrobat Bold",
158
- fontSize: "1.25vh",
159
- borderRadius: theme2.defaultRadius,
160
- paddingBottom: "0.5vh",
161
- paddingTop: "0.5vh"
162
- }
163
- })
164
- },
165
- // Mantine's <Tooltip> defaults to a white card with black text — looks
166
- // jarring against every dirk consumer's dark configurator. Every script
167
- // used to hand-paste this dark style block per Tooltip; centralised here
168
- // so consumers get the right look automatically and never need to think
169
- // about it again.
170
- Tooltip: {
171
- styles: (theme2) => ({
172
- tooltip: {
173
- background: core.alpha(theme2.colors.dark[7], 0.95),
174
- border: "0.1vh solid rgba(255,255,255,0.1)",
175
- color: "rgba(255,255,255,0.75)",
176
- fontFamily: "Akrobat Bold",
177
- fontSize: "1.3vh",
178
- lineHeight: 1.3,
179
- padding: "0.6vh 0.8vh",
180
- letterSpacing: "0.03em"
181
- }
182
- })
183
- }
184
- },
185
- colors: {
186
- dirk: [
187
- "#ffffff",
188
- "#f3fce9",
189
- "#dbf5bd",
190
- "#c3ee91",
191
- "#ace765",
192
- "#94e039",
193
- "#7ac61f",
194
- "#5f9a18",
195
- "#29420a",
196
- "#446e11"
197
- ]
198
- }
11
+ Object.defineProperty(exports, "DirkProvider", {
12
+ enumerable: true,
13
+ get: function () { return chunkQOQQ3ERZ_cjs.DirkProvider; }
199
14
  });
200
- var theme_default = theme;
201
-
202
- // src/utils/misc.ts
203
- var isEnvBrowser = () => !window.invokeNative;
204
- var noop = () => {
205
- };
206
-
207
- // src/hooks/useNuiEvent.ts
208
- var useNuiEvent = (action, handler) => {
209
- const savedHandler = React.useRef(noop);
210
- React.useEffect(() => {
211
- savedHandler.current = handler;
212
- }, [handler]);
213
- React.useEffect(() => {
214
- const eventListener = (event) => {
215
- const { action: eventAction, data } = event.data;
216
- if (savedHandler.current) {
217
- if (eventAction === action) {
218
- savedHandler.current(data);
219
- }
220
- }
221
- };
222
- window.addEventListener("message", eventListener);
223
- return () => window.removeEventListener("message", eventListener);
224
- }, [action]);
225
- };
226
- var DEFAULT_PALETTE = [
227
- "#f0f4ff",
228
- "#d9e3ff",
229
- "#bfcfff",
230
- "#a6bbff",
231
- "#8ca7ff",
232
- "#7393ff",
233
- "#5a7fff",
234
- "#406bff",
235
- "#2547ff",
236
- "#0b33ff"
237
- ];
238
- zod.z.object({
239
- useOverride: zod.z.boolean(),
240
- primaryColor: zod.z.string(),
241
- primaryShade: zod.z.number(),
242
- customTheme: zod.z.array(zod.z.string())
243
- });
244
-
245
- // src/utils/useSettings.ts
246
- var useSettings = zustand.create(() => ({
247
- currency: "$",
248
- game: "fivem",
249
- primaryColor: "dirk",
250
- primaryShade: 9,
251
- itemImgPath: "",
252
- resourceVersion: "dev",
253
- customTheme: DEFAULT_PALETTE
254
- }));
255
-
256
- // src/utils/fetchNui.ts
257
- async function fetchNui(eventName, data, mockData) {
258
- const options = {
259
- method: "post",
260
- headers: {
261
- "Content-Type": "application/json; charset=UTF-8"
262
- },
263
- body: JSON.stringify(data)
264
- };
265
- if (isEnvBrowser() && mockData !== void 0) return mockData;
266
- if (isEnvBrowser() && mockData === void 0) {
267
- console.warn(
268
- `[fetchNui] Called fetchNui for event "${eventName}" in browser environment without mockData. Returning empty object.`
269
- );
270
- return {};
271
- }
272
- const overrideResourceName = useSettings.getState().overideResourceName;
273
- const hasResourceContext = typeof window.GetParentResourceName === "function" || !!overrideResourceName;
274
- if (!hasResourceContext) {
275
- return mockData ?? {};
276
- }
277
- const resourceName = window.GetParentResourceName ? window.GetParentResourceName() : overrideResourceName;
278
- try {
279
- const resp = await fetch(`https://${resourceName}/${eventName}`, options);
280
- return await resp.json();
281
- } catch {
282
- return mockData ?? {};
283
- }
284
- }
285
- async function registerInitialFetch(eventName, data, mockData) {
286
- const fetcher = () => fetchNui(eventName, data, mockData);
287
- return fetcher();
288
- }
289
- var reportedMissing = /* @__PURE__ */ new Set();
290
- function reportMissingLocale(key) {
291
- if (!key || reportedMissing.has(key)) return;
292
- reportedMissing.add(key);
293
- fetchNui("REPORT_MISSING_LOCALE", { key }).catch(() => {
294
- });
295
- }
296
- var PACKAGE_DEFAULTS = {
297
- "OccupantsDesc": "Here you can view and manage the occupants of your traphouse. These occupants can be used mainly for selling drugs to the NPCs surrounding your traphouse. However they have other uses to so be careful who you add as an occupant.",
298
- "cfgpanel_discard": "Discard",
299
- "cfgpanel_manual_edit": "Manual Edit",
300
- "cfgpanel_reset_defaults": "Reset Defaults",
301
- "cfgpanel_version": "Version",
302
- "cfgpanel_back_title": "Back to script list",
303
- "cfgpanel_undo": "Undo",
304
- "cfgpanel_redo": "Redo",
305
- "cfgpanel_save": "Save",
306
- "cfgpanel_saving": "Saving...",
307
- "cfgpanel_history": "History",
308
- "cfgpanel_reset_title": "Reset to Defaults",
309
- "cfgpanel_reset_desc": "This will permanently reset ALL config back to the defaults. Every value you have configured will be overwritten. This cannot be undone.",
310
- "cfgpanel_reset_confirm": "Reset Config",
311
- "cfgpanel_discard_title": "Discard Unsaved Changes?",
312
- "cfgpanel_discard_desc_back": "You have unsaved changes. Going back now will discard them.",
313
- "cfgpanel_discard_desc_close": "You have unsaved changes. Closing now will discard them.",
314
- "cfgpanel_discard_confirm_back": "Go Back Without Saving",
315
- "cfgpanel_discard_confirm_close": "Close Without Saving",
316
- "cfgpanel_json_title": "Config JSON",
317
- "cfgpanel_cancel": "Cancel",
318
- "cfgpanel_apply": "Apply",
319
- "cfgpanel_history_title": "Config History",
320
- "cfgpanel_close": "Close"
321
- };
322
- var localeStore = zustand.create((set, get) => {
323
- return {
324
- locales: { ...PACKAGE_DEFAULTS },
325
- locale: (key, ...args) => {
326
- const exists = get().locales[key];
327
- if (!exists) reportMissingLocale(key);
328
- let translation = exists || key;
329
- if (args.length) {
330
- translation = translation.replace(/%s/g, () => String(args.shift() || ""));
331
- }
332
- return translation;
333
- }
334
- };
15
+ Object.defineProperty(exports, "dirkQueryClient", {
16
+ enumerable: true,
17
+ get: function () { return chunkQOQQ3ERZ_cjs.dirkQueryClient; }
335
18
  });
336
- localeStore.getState().locale;
337
- registerInitialFetch("GET_LOCALES", void 0).then((data) => {
338
- localeStore.setState({ locales: { ...PACKAGE_DEFAULTS, ...data } });
339
- }).catch(() => {
340
- });
341
- if (typeof window !== "undefined") {
342
- window.addEventListener("message", (event) => {
343
- const msg = event.data;
344
- if (!msg || msg.action !== "UPDATE_DIRK_LIB_LOCALES") return;
345
- if (!msg.data || typeof msg.data !== "object") return;
346
- if (Object.keys(msg.data).length === 0) return;
347
- localeStore.setState({ locales: { ...PACKAGE_DEFAULTS, ...msg.data } });
348
- });
349
- }
350
-
351
- // src/utils/mergeMantineTheme.ts
352
- var isValidColorScale = (v) => Array.isArray(v) && v.length === 10 && v.every((shade) => typeof shade === "string");
353
- function mergeMantineThemeSafe(base, custom, override) {
354
- const colors = { ...base.colors };
355
- if (custom && isValidColorScale(custom)) {
356
- colors["custom"] = custom;
357
- } else if (!colors["custom"]) {
358
- const fallback = base.colors && base.colors.dirk;
359
- if (fallback && isValidColorScale(fallback)) {
360
- colors["custom"] = fallback;
361
- }
362
- }
363
- return {
364
- ...base,
365
- ...override,
366
- colors: {
367
- ...colors,
368
- ...override?.colors ?? {}
369
- }
370
- };
371
- }
372
- function getScriptConfigInstance() {
373
- throw new Error("[dirk-cfx-react] createScriptConfig must be called before using ConfigPanel");
374
- }
375
- var DirkErrorBoundary = class extends React__default.default.Component {
376
- constructor() {
377
- super(...arguments);
378
- __publicField(this, "state", { error: null, stack: void 0 });
379
- }
380
- static getDerivedStateFromError(error2) {
381
- return { error: error2 };
382
- }
383
- componentDidCatch(error2, info) {
384
- console.group("\u{1F525} Dirk UI Crash");
385
- console.error("Error:", error2);
386
- console.error("Component Stack:", info.componentStack);
387
- console.groupEnd();
388
- }
389
- render() {
390
- if (!this.state.error) return this.props.children;
391
- return /* @__PURE__ */ jsxRuntime.jsx(
392
- core.Box,
393
- {
394
- style: {
395
- position: "fixed",
396
- inset: 0,
397
- width: "100vw",
398
- height: "100vh",
399
- background: "rgba(10, 10, 12, 0.92)",
400
- display: "flex",
401
- alignItems: "center",
402
- justifyContent: "center",
403
- padding: "2rem",
404
- zIndex: 999999
405
- },
406
- children: /* @__PURE__ */ jsxRuntime.jsx(
407
- core.Box,
408
- {
409
- maw: 900,
410
- w: "100%",
411
- p: "lg",
412
- style: {
413
- background: "rgba(20,20,24,0.75)",
414
- border: "1px solid rgba(255,255,255,0.08)",
415
- borderRadius: "10px",
416
- boxShadow: "0 10px 40px rgba(0,0,0,0.6)"
417
- },
418
- children: /* @__PURE__ */ jsxRuntime.jsxs(core.Stack, { gap: "sm", children: [
419
- /* @__PURE__ */ jsxRuntime.jsx(core.Title, { order: 2, c: "red.5", children: "Dirk UI Crash" }),
420
- /* @__PURE__ */ jsxRuntime.jsx(core.Text, { c: "dimmed", size: "sm", children: "The interface encountered a fatal error and stopped rendering." }),
421
- /* @__PURE__ */ jsxRuntime.jsx(core.Code, { block: true, style: { maxHeight: 150, overflow: "auto" }, children: this.state.error?.message }),
422
- /* @__PURE__ */ jsxRuntime.jsx(core.Text, { size: "xs", c: "dimmed", children: "Check console for full stack trace" })
423
- ] })
424
- }
425
- )
426
- }
427
- );
428
- }
429
- };
430
- var useAdminToolStore = zustand.create((set, get) => ({
431
- active: null,
432
- begin: (spec) => new Promise((resolve) => {
433
- const prev = get().active;
434
- if (prev) prev.resolve(null);
435
- set({ active: { ...spec, resolve } });
436
- }),
437
- resolveActive: (value) => {
438
- const cur = get().active;
439
- if (!cur) return;
440
- cur.resolve(value);
441
- set({ active: null });
442
- },
443
- cancelActive: () => {
444
- const cur = get().active;
445
- if (!cur) return;
446
- cur.resolve(null);
447
- set({ active: null });
448
- }
449
- }));
450
-
451
- // src/components/AdminTools/AdminOverlays.tsx
452
- var listenerInstalled = false;
453
- function installNuiListener() {
454
- if (listenerInstalled || typeof window === "undefined") return;
455
- listenerInstalled = true;
456
- window.addEventListener("message", (e) => {
457
- const msg = e?.data;
458
- if (!msg || typeof msg !== "object" || typeof msg.action !== "string") return;
459
- const action = msg.action;
460
- const cur = useAdminToolStore.getState().active;
461
- if (!cur) return;
462
- if (action === `${cur.id}_RESULT`) {
463
- useAdminToolStore.getState().resolveActive(msg.data ?? null);
464
- } else if (action === `${cur.id}_CANCELLED`) {
465
- useAdminToolStore.getState().cancelActive();
466
- }
467
- });
468
- }
469
- var BODY_HIDE_STYLE_ID = "dirk-instruction-panel-style";
470
- var BODY_HIDE_ATTR = "data-dirk-instruction-active";
471
- var OVERLAY_ATTR = "data-dirk-instruction-overlay";
472
- function ensureBodyHideStyle() {
473
- if (typeof document === "undefined") return;
474
- if (document.getElementById(BODY_HIDE_STYLE_ID)) return;
475
- const el = document.createElement("style");
476
- el.id = BODY_HIDE_STYLE_ID;
477
- el.textContent = `
478
- body[${BODY_HIDE_ATTR}] > *:not([${OVERLAY_ATTR}]) {
479
- visibility: hidden !important;
480
- opacity: 0 !important;
481
- pointer-events: none !important;
482
- }
483
- `;
484
- document.head.appendChild(el);
485
- }
486
- function AdminOverlays() {
487
- const active = useAdminToolStore((s) => s.active);
488
- React.useEffect(() => {
489
- installNuiListener();
490
- }, []);
491
- React.useEffect(() => {
492
- if (!active || typeof document === "undefined") return;
493
- ensureBodyHideStyle();
494
- document.body.setAttribute(BODY_HIDE_ATTR, "");
495
- return () => {
496
- document.body.removeAttribute(BODY_HIDE_ATTR);
497
- };
498
- }, [active]);
499
- return null;
500
- }
501
- fontawesomeSvgCore.library.add(freeSolidSvgIcons.fas, freeRegularSvgIcons.far, freeBrandsSvgIcons.fab);
502
- var dirkQueryClient = new reactQuery.QueryClient({
503
- defaultOptions: { queries: { staleTime: 3e4, gcTime: 5 * 6e4 } }
504
- });
505
- function DirkProvider({ children, overideResourceName, themeOverride }) {
506
- const {
507
- primaryColor,
508
- primaryShade,
509
- customTheme,
510
- game
511
- } = useSettings();
512
- localeStore((s) => s.locales);
513
- const [scTheme, setScTheme] = React.useState(null);
514
- React.useLayoutEffect(() => {
515
- useSettings.setState({
516
- overideResourceName
517
- });
518
- }, [overideResourceName]);
519
- React.useEffect(() => {
520
- fetchNui("NUI_READY").catch(() => {
521
- });
522
- Promise.all([
523
- fetchNui("GET_SETTINGS"),
524
- fetchNui("GET_RESOURCE_VERSION", void 0, { version: "dev" })
525
- ]).then(([data, resourceInfo]) => {
526
- useSettings.setState({
527
- ...data,
528
- resourceVersion: resourceInfo?.version || "dev"
529
- });
530
- }).catch((err) => {
531
- console.error("Failed to fetch initial settings within dirk-cfx-react:", err);
532
- });
533
- }, []);
534
- useNuiEvent("UPDATE_DIRK_LIB_SETTINGS", (data) => {
535
- if (!data || typeof data !== "object") return;
536
- useSettings.setState(data);
537
- });
538
- useNuiEvent(
539
- "UPDATE_SCRIPT_CONFIG",
540
- (data) => {
541
- if (!data || !data.config || typeof data.config !== "object") return;
542
- try {
543
- const inst = getScriptConfigInstance();
544
- inst.store.setState((prev) => ({ ...prev, ...data.config }));
545
- } catch {
546
- }
547
- }
548
- );
549
- React.useEffect(() => {
550
- let unsubscribe;
551
- try {
552
- const inst = getScriptConfigInstance();
553
- setScTheme(inst.store.getState()?.theme ?? null);
554
- const subscribable = inst.store;
555
- if (typeof subscribable.subscribe === "function") {
556
- unsubscribe = subscribable.subscribe((s) => {
557
- setScTheme(s?.theme ?? null);
558
- });
559
- }
560
- } catch {
561
- }
562
- return () => {
563
- unsubscribe?.();
564
- };
565
- }, []);
566
- const overrideActive = scTheme?.useOverride === true;
567
- const effectivePrimaryColor = overrideActive ? scTheme.primaryColor ?? primaryColor : primaryColor;
568
- const effectivePrimaryShade = overrideActive ? scTheme.primaryShade ?? primaryShade : primaryShade;
569
- const effectiveCustomTheme = overrideActive ? scTheme.customTheme ?? customTheme : customTheme;
570
- const mergedTheme = React.useMemo(
571
- () => mergeMantineThemeSafe(
572
- { ...theme_default, primaryColor: effectivePrimaryColor, primaryShade: effectivePrimaryShade },
573
- effectiveCustomTheme,
574
- themeOverride
575
- ),
576
- [effectivePrimaryColor, effectivePrimaryShade, effectiveCustomTheme, themeOverride]
577
- );
578
- React.useEffect(() => {
579
- document.body.style.fontFamily = game === "rdr3" ? '"Red Dead", sans-serif' : '"Akrobat Regular", sans-serif';
580
- }, [game]);
581
- const content = isEnvBrowser() ? /* @__PURE__ */ jsxRuntime.jsx(
582
- core.BackgroundImage,
583
- {
584
- w: "100vw",
585
- h: "100vh",
586
- 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",
587
- children
588
- }
589
- ) : children;
590
- return /* @__PURE__ */ jsxRuntime.jsx(reactQuery.QueryClientProvider, { client: dirkQueryClient, children: /* @__PURE__ */ jsxRuntime.jsx(core.MantineProvider, { theme: mergedTheme, defaultColorScheme: "dark", children: /* @__PURE__ */ jsxRuntime.jsxs(DirkErrorBoundary, { children: [
591
- content,
592
- /* @__PURE__ */ jsxRuntime.jsx(AdminOverlays, {})
593
- ] }) }) });
594
- }
595
-
596
- exports.DirkProvider = DirkProvider;
597
- exports.dirkQueryClient = dirkQueryClient;
598
19
  //# sourceMappingURL=index.cjs.map
599
20
  //# sourceMappingURL=index.cjs.map