dirk-cfx-react 1.0.5 → 1.0.6

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,1214 +1,3 @@
1
- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
2
- import { Flex, Text, Image, createTheme, useMantineTheme, MantineProvider, BackgroundImage } from '@mantine/core';
3
- import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
4
- import { motion, AnimatePresence, useMotionValue } from 'framer-motion';
5
- import { createContext, useRef, useState, useEffect, useContext } from 'react';
6
- import { create, useStore } from 'zustand';
7
- import clickSoundUrl from './click_sound-PNCRRTM4.mp3';
8
- import hoverSoundUrl from './hover_sound-NBUA222C.mp3';
9
- import '@mantine/core/styles.css';
10
- import '@mantine/notifications/styles.css';
11
- import './styles/niceFont.css';
12
- import './styles/scrollBar.css';
13
- import { library } from '@fortawesome/fontawesome-svg-core';
14
- import { fab } from '@fortawesome/free-brands-svg-icons';
15
- import { far } from '@fortawesome/free-regular-svg-icons';
16
- import { fas } from '@fortawesome/free-solid-svg-icons';
17
1
 
18
- // src/components/BorderedIcon.tsx
19
-
20
- // src/utils/colorWithAlpha.ts
21
- var colorNames = {
22
- AliceBlue: { r: 240, g: 248, b: 255 },
23
- AntiqueWhite: { r: 250, g: 235, b: 215 },
24
- Aqua: { r: 0, g: 255, b: 255 },
25
- Aquamarine: { r: 127, g: 255, b: 212 },
26
- Azure: { r: 240, g: 255, b: 255 },
27
- Beige: { r: 245, g: 245, b: 220 },
28
- Bisque: { r: 255, g: 228, b: 196 },
29
- Black: { r: 0, g: 0, b: 0 },
30
- BlanchedAlmond: { r: 255, g: 235, b: 205 },
31
- Blue: { r: 0, g: 0, b: 255 },
32
- BlueViolet: { r: 138, g: 43, b: 226 },
33
- Brown: { r: 165, g: 42, b: 42 },
34
- BurlyWood: { r: 222, g: 184, b: 135 },
35
- CadetBlue: { r: 95, g: 158, b: 160 },
36
- Chartreuse: { r: 127, g: 255, b: 0 },
37
- Chocolate: { r: 210, g: 105, b: 30 },
38
- Coral: { r: 255, g: 127, b: 80 },
39
- CornflowerBlue: { r: 100, g: 149, b: 237 },
40
- Cornsilk: { r: 255, g: 248, b: 220 },
41
- Crimson: { r: 220, g: 20, b: 60 },
42
- Cyan: { r: 0, g: 255, b: 255 },
43
- DarkBlue: { r: 0, g: 0, b: 139 },
44
- DarkCyan: { r: 0, g: 139, b: 139 },
45
- DarkGoldenRod: { r: 184, g: 134, b: 11 },
46
- DarkGray: { r: 169, g: 169, b: 169 },
47
- DarkGreen: { r: 0, g: 100, b: 0 },
48
- DarkKhaki: { r: 189, g: 183, b: 107 },
49
- DarkMagenta: { r: 139, g: 0, b: 139 },
50
- DarkOliveGreen: { r: 85, g: 107, b: 47 },
51
- DarkOrange: { r: 255, g: 140, b: 0 },
52
- DarkOrchid: { r: 153, g: 50, b: 204 },
53
- DarkRed: { r: 139, g: 0, b: 0 },
54
- DarkSalmon: { r: 233, g: 150, b: 122 },
55
- DarkSeaGreen: { r: 143, g: 188, b: 143 },
56
- DarkSlateBlue: { r: 72, g: 61, b: 139 },
57
- DarkSlateGray: { r: 47, g: 79, b: 79 },
58
- DarkTurquoise: { r: 0, g: 206, b: 209 },
59
- DarkViolet: { r: 148, g: 0, b: 211 },
60
- DeepPink: { r: 255, g: 20, b: 147 },
61
- DeepSkyBlue: { r: 0, g: 191, b: 255 },
62
- DimGray: { r: 105, g: 105, b: 105 },
63
- DodgerBlue: { r: 30, g: 144, b: 255 },
64
- FireBrick: { r: 178, g: 34, b: 34 },
65
- FloralWhite: { r: 255, g: 250, b: 240 },
66
- ForestGreen: { r: 34, g: 139, b: 34 },
67
- Fuchsia: { r: 255, g: 0, b: 255 },
68
- Gainsboro: { r: 220, g: 220, b: 220 },
69
- GhostWhite: { r: 248, g: 248, b: 255 },
70
- Gold: { r: 255, g: 215, b: 0 },
71
- GoldenRod: { r: 218, g: 165, b: 32 },
72
- Gray: { r: 128, g: 128, b: 128 },
73
- Green: { r: 0, g: 128, b: 0 },
74
- GreenYellow: { r: 173, g: 255, b: 47 },
75
- HoneyDew: { r: 240, g: 255, b: 240 },
76
- HotPink: { r: 255, g: 105, b: 180 },
77
- IndianRed: { r: 205, g: 92, b: 92 },
78
- Indigo: { r: 75, g: 0, b: 130 },
79
- Ivory: { r: 255, g: 255, b: 240 },
80
- Khaki: { r: 240, g: 230, b: 140 },
81
- Lavender: { r: 230, g: 230, b: 250 },
82
- LavenderBlush: { r: 255, g: 240, b: 245 },
83
- LawnGreen: { r: 124, g: 252, b: 0 },
84
- LemonChiffon: { r: 255, g: 250, b: 205 },
85
- LightBlue: { r: 173, g: 216, b: 230 },
86
- LightCoral: { r: 240, g: 128, b: 128 },
87
- LightCyan: { r: 224, g: 255, b: 255 },
88
- LightGoldenRodYellow: { r: 250, g: 250, b: 210 },
89
- LightGray: { r: 211, g: 211, b: 211 },
90
- LightGreen: { r: 144, g: 238, b: 144 },
91
- LightPink: { r: 255, g: 182, b: 193 },
92
- LightSalmon: { r: 255, g: 160, b: 122 },
93
- LightSeaGreen: { r: 32, g: 178, b: 170 },
94
- LightSkyBlue: { r: 135, g: 206, b: 250 },
95
- LightSlateGray: { r: 119, g: 136, b: 153 },
96
- LightSteelBlue: { r: 176, g: 196, b: 222 },
97
- LightYellow: { r: 255, g: 255, b: 224 },
98
- Lime: { r: 0, g: 255, b: 0 },
99
- LimeGreen: { r: 50, g: 205, b: 50 },
100
- Linen: { r: 250, g: 240, b: 230 },
101
- Magenta: { r: 255, g: 0, b: 255 },
102
- Maroon: { r: 128, g: 0, b: 0 },
103
- // Maroon
104
- MediumAquaMarine: { r: 102, g: 205, b: 170 },
105
- MediumBlue: { r: 0, g: 0, b: 205 },
106
- MediumOrchid: { r: 186, g: 85, b: 211 },
107
- MediumPurple: { r: 147, g: 112, b: 219 },
108
- MediumSeaGreen: { r: 60, g: 179, b: 113 },
109
- MediumSlateBlue: { r: 123, g: 104, b: 238 },
110
- MediumSpringGreen: { r: 0, g: 250, b: 154 },
111
- MediumTurquoise: { r: 72, g: 209, b: 204 },
112
- MediumVioletRed: { r: 199, g: 21, b: 133 },
113
- MidnightBlue: { r: 25, g: 25, b: 112 },
114
- MintCream: { r: 245, g: 255, b: 250 },
115
- MistyRose: { r: 255, g: 228, b: 225 },
116
- Moccasin: { r: 255, g: 228, b: 181 },
117
- NavajoWhite: { r: 255, g: 222, b: 173 },
118
- Navy: { r: 0, g: 0, b: 128 },
119
- OldLace: { r: 253, g: 245, b: 230 },
120
- Olive: { r: 128, g: 128, b: 0 },
121
- OliveDrab: { r: 107, g: 142, b: 35 },
122
- Orange: { r: 255, g: 165, b: 0 },
123
- OrangeRed: { r: 255, g: 69, b: 0 },
124
- Orchid: { r: 218, g: 112, b: 214 },
125
- PaleGoldenRod: { r: 238, g: 232, b: 170 },
126
- PaleGreen: { r: 152, g: 251, b: 152 },
127
- PaleTurquoise: { r: 175, g: 238, b: 238 },
128
- PaleVioletRed: { r: 219, g: 112, b: 147 },
129
- PapayaWhip: { r: 255, g: 239, b: 213 },
130
- PeachPuff: { r: 255, g: 218, b: 185 },
131
- Peru: { r: 205, g: 133, b: 63 },
132
- Pink: { r: 255, g: 192, b: 203 },
133
- Plum: { r: 221, g: 160, b: 221 },
134
- PowderBlue: { r: 176, g: 224, b: 230 },
135
- Purple: { r: 128, g: 0, b: 128 },
136
- RebeccaPurple: { r: 102, g: 51, b: 153 },
137
- Red: { r: 255, g: 0, b: 0 },
138
- RosyBrown: { r: 188, g: 143, b: 143 },
139
- RoyalBlue: { r: 65, g: 105, b: 225 },
140
- SaddleBrown: { r: 139, g: 69, b: 19 },
141
- Salmon: { r: 250, g: 128, b: 114 },
142
- SandyBrown: { r: 244, g: 164, b: 96 },
143
- SeaGreen: { r: 46, g: 139, b: 87 },
144
- SeaShell: { r: 255, g: 245, b: 238 },
145
- Sienna: { r: 160, g: 82, b: 45 },
146
- Silver: { r: 192, g: 192, b: 192 },
147
- SkyBlue: { r: 135, g: 206, b: 235 },
148
- SlateBlue: { r: 106, g: 90, b: 205 },
149
- SlateGray: { r: 112, g: 128, b: 144 },
150
- Snow: { r: 255, g: 250, b: 250 },
151
- SpringGreen: { r: 0, g: 255, b: 127 },
152
- SteelBlue: { r: 70, g: 130, b: 180 },
153
- Tan: { r: 210, g: 180, b: 140 },
154
- Teal: { r: 0, g: 128, b: 128 },
155
- Thistle: { r: 216, g: 191, b: 216 },
156
- Tomato: { r: 255, g: 99, b: 71 },
157
- Turquoise: { r: 64, g: 224, b: 208 },
158
- Violet: { r: 238, g: 130, b: 238 },
159
- Wheat: { r: 245, g: 222, b: 179 },
160
- White: { r: 255, g: 255, b: 255 },
161
- WhiteSmoke: { r: 245, g: 245, b: 245 },
162
- Yellow: { r: 255, g: 255, b: 0 },
163
- YellowGreen: { r: 154, g: 205, b: 50 }
164
- };
165
- function colorWithAlpha(color, alpha) {
166
- const lowerCasedColor = color.toLowerCase();
167
- if (colorNames[lowerCasedColor]) {
168
- const rgb = colorNames[lowerCasedColor];
169
- return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha})`;
170
- }
171
- if (/^#([A-Fa-f0-9]{6})$/.test(color)) {
172
- const hex = color.slice(1);
173
- const bigint = parseInt(hex, 16);
174
- const r = bigint >> 16 & 255;
175
- const g = bigint >> 8 & 255;
176
- const b = bigint & 255;
177
- return `rgba(${r}, ${g}, ${b}, ${alpha})`;
178
- }
179
- if (/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/.test(color)) {
180
- const result = color.match(/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/);
181
- if (result) {
182
- return `rgba(${result[1]}, ${result[2]}, ${result[3]}, ${alpha})`;
183
- }
184
- }
185
- return color;
186
- }
187
- function BorderedIcon(props) {
188
- const theme2 = useMantineTheme();
189
- return /* @__PURE__ */ jsx(
190
- FontAwesomeIcon,
191
- {
192
- icon: props.icon,
193
- color: colorWithAlpha(props.color ? props.color : theme2.colors[theme2.primaryColor][theme2.primaryShade], props.hovered ? 0.9 : 0.9),
194
- style: {
195
- // backgroundColor: colorWithAlpha(props.color ? props.color : theme.colors[theme.primaryColor][7 as number], (props.hoverable ? (props.hovered ? 0.3 : 0.2) : 0.2)),
196
- backgroundColor: "rgba(0, 0, 0, 0.5)",
197
- padding: props.p || theme2.spacing.xs,
198
- transition: "all 0.2s ease-in-out",
199
- aspectRatio: "1/1",
200
- fontSize: props.fontSize ? props.fontSize : "2.5vh",
201
- borderRadius: theme2.radius.xs,
202
- // border: `2px solid var(--mantine-primary-color-9)`,
203
- outline: `0.2vh solid ${colorWithAlpha(props.color ? props.color : theme2.colors[theme2.primaryColor][9], 0.8)}`,
204
- boxShadow: `inset 0 0 2vh ${colorWithAlpha(props.color ? props.color : theme2.colors[theme2.primaryColor][7], 0.5)}`
205
- }
206
- }
207
- );
208
- }
209
- var MotionFlex = motion(Flex);
210
- var MotionText = motion(Text);
211
- var MotionIcon = motion(FontAwesomeIcon);
212
- var MotionImage = motion(Image);
213
- function Counter(props) {
214
- return /* @__PURE__ */ jsx(AnimatePresence, { children: props.count > 0 && /* @__PURE__ */ jsx(
215
- MotionFlex,
216
- {
217
- initial: { opacity: 0 },
218
- animate: { opacity: 1 },
219
- exit: { opacity: 0 },
220
- fz: "1.25vh",
221
- h: "1.75vh",
222
- justify: "center",
223
- align: "center",
224
- bg: props.color || "rgba(0, 0, 0, 0.51)",
225
- style: {
226
- borderRadius: "50%",
227
- aspectRatio: "1/1",
228
- marginBottom: "0.3vh",
229
- fontFamily: "Akrobat Bold",
230
- boxShadow: "0 0 5px rgba(0, 0, 0, 0.3)"
231
- },
232
- children: props.count
233
- },
234
- "counter"
235
- ) });
236
- }
237
- var FloatingParticles = ({
238
- icons = [],
239
- particleCount = 55,
240
- color = "#00a552ff",
241
- size = 32,
242
- speed = "slow",
243
- opacity = 0.3,
244
- style = {},
245
- mouseRepelDistance = 150,
246
- mouseRepelStrength = 50,
247
- backgroundColor = "transparent"
248
- }) => {
249
- const containerRef = useRef(null);
250
- const [particles, setParticles] = useState([]);
251
- const mouseX = useMotionValue(0);
252
- const mouseY = useMotionValue(0);
253
- const durationMap = {
254
- slow: { base: 10, variance: 10 },
255
- medium: { base: 2, variance: 2 },
256
- fast: { base: 4, variance: 2 }
257
- };
258
- const duration = durationMap[speed];
259
- const seededRandom = (seed) => {
260
- const x = Math.sin(seed) * 1e4;
261
- return x - Math.floor(x);
262
- };
263
- useEffect(() => {
264
- if (!containerRef.current) return;
265
- const bounds = containerRef.current.getBoundingClientRect();
266
- const newParticles = [...Array(particleCount)].map((_, i) => {
267
- const seedX = i * 123.456;
268
- const seedY = i * 789.012;
269
- const seedDuration = i * 345.678;
270
- const baseX = seededRandom(seedX) * bounds.width;
271
- const baseY = seededRandom(seedY) * bounds.height;
272
- return {
273
- id: i,
274
- baseX,
275
- baseY,
276
- currentX: baseX,
277
- currentY: baseY,
278
- icon: icons.length > 0 ? icons[i % icons.length] : null,
279
- animationDuration: duration.base + seededRandom(seedDuration) * duration.variance
280
- };
281
- });
282
- setParticles(newParticles);
283
- }, [particleCount, icons.length, duration.base, duration.variance]);
284
- useEffect(() => {
285
- if (!containerRef.current) return;
286
- const handleMouseMove = (e) => {
287
- const bounds = containerRef.current.getBoundingClientRect();
288
- const x = e.clientX - bounds.left;
289
- const y = e.clientY - bounds.top;
290
- mouseX.set(x);
291
- mouseY.set(y);
292
- setParticles(
293
- (prevParticles) => prevParticles.map((particle) => {
294
- const dx = x - particle.baseX;
295
- const dy = y - particle.baseY;
296
- const distance = Math.sqrt(dx * dx + dy * dy);
297
- if (distance < mouseRepelDistance && distance > 0) {
298
- const force = (mouseRepelDistance - distance) / mouseRepelDistance;
299
- const repelX = dx / distance * force * mouseRepelStrength * -1;
300
- const repelY = dy / distance * force * mouseRepelStrength * -1;
301
- return {
302
- ...particle,
303
- currentX: particle.baseX + repelX,
304
- currentY: particle.baseY + repelY
305
- };
306
- } else {
307
- return {
308
- ...particle,
309
- currentX: particle.baseX,
310
- currentY: particle.baseY
311
- };
312
- }
313
- })
314
- );
315
- };
316
- const handleMouseLeave = () => {
317
- setParticles(
318
- (prevParticles) => prevParticles.map((particle) => ({
319
- ...particle,
320
- currentX: particle.baseX,
321
- currentY: particle.baseY
322
- }))
323
- );
324
- };
325
- const container = containerRef.current;
326
- container.addEventListener("mousemove", handleMouseMove);
327
- container.addEventListener("mouseleave", handleMouseLeave);
328
- return () => {
329
- container.removeEventListener("mousemove", handleMouseMove);
330
- container.removeEventListener("mouseleave", handleMouseLeave);
331
- };
332
- }, [mouseX, mouseY, mouseRepelDistance, mouseRepelStrength]);
333
- useEffect(() => {
334
- const handleResize = () => {
335
- if (!containerRef.current) return;
336
- const bounds = containerRef.current.getBoundingClientRect();
337
- setParticles(
338
- (prevParticles) => prevParticles.map((particle, i) => {
339
- const seedX = i * 123.456 + bounds.width;
340
- const seedY = i * 789.012 + bounds.height;
341
- const newBaseX = seededRandom(seedX) * bounds.width;
342
- const newBaseY = seededRandom(seedY) * bounds.height;
343
- return {
344
- ...particle,
345
- baseX: newBaseX,
346
- baseY: newBaseY,
347
- currentX: newBaseX,
348
- currentY: newBaseY
349
- };
350
- })
351
- );
352
- };
353
- window.addEventListener("resize", handleResize);
354
- return () => window.removeEventListener("resize", handleResize);
355
- }, []);
356
- return /* @__PURE__ */ jsx(
357
- "div",
358
- {
359
- ref: containerRef,
360
- style: {
361
- position: "absolute",
362
- overflow: "hidden",
363
- width: "100%",
364
- height: "100%",
365
- zIndex: -1,
366
- backgroundColor,
367
- ...style
368
- },
369
- children: /* @__PURE__ */ jsx("div", { style: { position: "absolute", inset: 0, pointerEvents: "none" }, children: particles.map((particle) => /* @__PURE__ */ jsx(
370
- motion.div,
371
- {
372
- style: {
373
- position: "absolute",
374
- width: size,
375
- height: size,
376
- color,
377
- opacity,
378
- left: 0,
379
- top: 0
380
- },
381
- animate: {
382
- x: particle.currentX,
383
- y: particle.currentY,
384
- scale: [0.8, 1.1, 0.8],
385
- opacity: [opacity * 0.5, opacity, opacity * 0.5],
386
- // random rotate between 0 and 360 so that not all particles rotate the same
387
- rotate: particle.id % 2 === 0 ? [0, 360] : [360, 0]
388
- },
389
- transition: {
390
- x: { type: "spring", stiffness: 150, damping: 20 },
391
- y: { type: "spring", stiffness: 150, damping: 20 },
392
- rotate: {
393
- duration: particle.animationDuration,
394
- repeat: Infinity,
395
- ease: "linear"
396
- },
397
- scale: {
398
- duration: particle.animationDuration,
399
- repeat: Infinity,
400
- delay: seededRandom(particle.id * 111.222) * 5,
401
- ease: "easeInOut"
402
- },
403
- opacity: {
404
- duration: particle.animationDuration,
405
- repeat: Infinity,
406
- delay: seededRandom(particle.id * 333.444) * 5,
407
- ease: "easeInOut"
408
- }
409
- },
410
- children: particle.icon ? /* @__PURE__ */ jsx("div", { style: { width: "100%", height: "100%", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ jsx(FontAwesomeIcon, { icon: particle.icon, style: { width: "70%", height: "70%" } }) }) : /* @__PURE__ */ jsx(
411
- "div",
412
- {
413
- style: {
414
- width: "100%",
415
- height: "100%",
416
- borderRadius: "50%",
417
- backgroundColor: color
418
- }
419
- }
420
- )
421
- },
422
- particle.id
423
- )) })
424
- }
425
- );
426
- };
427
- function Icon(props) {
428
- return /* @__PURE__ */ jsx(Fragment, {});
429
- }
430
- function InfoBox(props) {
431
- const theme2 = useMantineTheme();
432
- return /* @__PURE__ */ jsxs(
433
- Flex,
434
- {
435
- w: "fit-content",
436
- h: "fit-content",
437
- style: {
438
- borderRadius: theme2.radius.xs,
439
- overflow: "hidden",
440
- border: `0.2vh solid rgba(77,77,77,0.3)`
441
- },
442
- align: "center",
443
- children: [
444
- /* @__PURE__ */ jsx(
445
- Flex,
446
- {
447
- miw: "4vh",
448
- p: "xxs",
449
- bg: "rgba(77,77,77,0.2)",
450
- direction: "column",
451
- justify: "center",
452
- align: "center",
453
- children: /* @__PURE__ */ jsx(
454
- Text,
455
- {
456
- c: "lightgrey",
457
- size: "xxs",
458
- style: {
459
- fontFamily: "Akrobat Bold",
460
- letterSpacing: "0.05em",
461
- textTransform: "uppercase"
462
- },
463
- children: props.leftSide
464
- }
465
- )
466
- }
467
- ),
468
- /* @__PURE__ */ jsx(
469
- Flex,
470
- {
471
- p: "xxs",
472
- flex: 1,
473
- miw: "4vh",
474
- bg: "rgba(77,77,77,0.5)",
475
- direction: "column",
476
- align: "center",
477
- justify: "center",
478
- children: /* @__PURE__ */ jsx(
479
- Text,
480
- {
481
- c: "lightgrey",
482
- size: "xxs",
483
- style: {
484
- fontFamily: "Akrobat Bold",
485
- letterSpacing: "0.05em",
486
- textTransform: "uppercase"
487
- },
488
- children: props.rightSide
489
- }
490
- )
491
- }
492
- )
493
- ]
494
- }
495
- );
496
- }
497
- function InputContainer(props) {
498
- const theme2 = useMantineTheme();
499
- return /* @__PURE__ */ jsxs(
500
- MotionFlex,
501
- {
502
- w: props.w || "100%",
503
- flex: props.flex,
504
- direction: "column",
505
- h: props.h,
506
- gap: props.title ? "xs" : 0,
507
- bg: props.bg || "rgba(69, 69, 69, 0.42)",
508
- p: "sm",
509
- style: {
510
- borderRadius: theme2.radius.xs,
511
- boxShadow: theme2.shadows.sm,
512
- overflow: "hidden",
513
- outline: props.error ? `1px solid rgba(255, 100, 100, 0.8)` : "none"
514
- },
515
- variants: props.variants,
516
- children: [
517
- /* @__PURE__ */ jsxs(
518
- Flex,
519
- {
520
- align: "center",
521
- gap: "xs",
522
- children: [
523
- /* @__PURE__ */ jsxs(
524
- Flex,
525
- {
526
- direction: "column",
527
- gap: "xxs",
528
- children: [
529
- props.title && /* @__PURE__ */ jsx(
530
- Text,
531
- {
532
- size: "sm",
533
- style: {
534
- lineHeight: "1.25vh",
535
- fontFamily: "Akrobat Bold",
536
- letterSpacing: "0.05em",
537
- textTransform: "uppercase"
538
- },
539
- children: props.title
540
- }
541
- ),
542
- props.description && /* @__PURE__ */ jsx(
543
- Text,
544
- {
545
- size: "xs",
546
- c: "rgba(255, 255, 255, 0.8)",
547
- fw: 400,
548
- children: props.description
549
- }
550
- )
551
- ]
552
- }
553
- ),
554
- props.error && /* @__PURE__ */ jsx(
555
- Text,
556
- {
557
- size: "xs",
558
- c: theme2.colors.red[9],
559
- fw: 600,
560
- mb: "auto",
561
- lh: "0.8",
562
- children: props.error
563
- }
564
- ),
565
- /* @__PURE__ */ jsx(
566
- Flex,
567
- {
568
- ml: "auto",
569
- children: props.rightSection
570
- }
571
- )
572
- ]
573
- }
574
- ),
575
- props.children
576
- ]
577
- }
578
- );
579
- }
580
- var useAudio = create(() => {
581
- const audioRefs = {};
582
- const sounds = {
583
- click: clickSoundUrl,
584
- hover: hoverSoundUrl
585
- };
586
- for (const [key, src] of Object.entries(sounds)) {
587
- audioRefs[key] = new Audio(src);
588
- }
589
- return {
590
- play: (sound) => {
591
- const audio = audioRefs[sound];
592
- if (!audio) return console.warn(`Sound '${sound}' not found.`);
593
- audio.currentTime = 0;
594
- audio.volume = 0.1;
595
- audio.play();
596
- },
597
- stop: (sound) => {
598
- const audio = audioRefs[sound];
599
- if (!audio) return console.warn(`Sound '${sound}' not found.`);
600
- audio.pause();
601
- audio.currentTime = 0;
602
- }
603
- };
604
- });
605
-
606
- // src/utils/misc.ts
607
- var isEnvBrowser = () => !window.invokeNative;
608
- var noop = () => {
609
- };
610
- var splitFAString = (faString) => {
611
- const [prefix, newIcon] = faString.split("-");
612
- if (!prefix || !newIcon) return { prefix: "fas", newIcon: "question" };
613
- return { prefix, newIcon };
614
- };
615
- var numberToRoman = (num) => {
616
- const romanNumerals = ["I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII", "XIII", "XIV", "XV", "XVI", "XVII", "XVIII", "XIX", "XX"];
617
- return romanNumerals[num];
618
- };
619
- var copyToClipboard = (text) => {
620
- const el = document.createElement("textarea");
621
- el.value = text;
622
- document.body.appendChild(el);
623
- el.select();
624
- document.execCommand("copy");
625
- document.body.removeChild(el);
626
- };
627
- var openLink = (url) => {
628
- if (isEnvBrowser()) {
629
- window.open(url, "_blank");
630
- } else {
631
- window.invokeNative("openLink", url);
632
- }
633
- };
634
-
635
- // src/utils/fetchNui.ts
636
- async function fetchNui(eventName, data, mockData) {
637
- const options = {
638
- method: "post",
639
- headers: {
640
- "Content-Type": "application/json; charset=UTF-8"
641
- },
642
- body: JSON.stringify(data)
643
- };
644
- console.log("Mock Data:", mockData);
645
- console.log("Is Env Browser:", isEnvBrowser());
646
- if (isEnvBrowser() && mockData !== void 0) return mockData;
647
- const resourceName = window.GetParentResourceName ? window.GetParentResourceName() : "nui-frame-app";
648
- const resp = await fetch(`https://${resourceName}/${eventName}`, options);
649
- const respFormatted = await resp.json();
650
- return respFormatted;
651
- }
652
- function fetchOnLoad(eventName, data, mockData) {
653
- return fetchNui(eventName, data, mockData).catch((err) => {
654
- console.error(`[fetchOnLoad] Failed for ${eventName}:`, err);
655
- throw err;
656
- });
657
- }
658
- var fetchLuaTable = (tableName) => () => {
659
- if (isEnvBrowser()) {
660
- return Promise.resolve({});
661
- }
662
- return fetchNui("GET_LUA_TABLE", { tableName });
663
- };
664
-
665
- // src/utils/internalEvent.ts
666
- var internalEvent = (events, timer = 1e3) => {
667
- if (isEnvBrowser()) {
668
- for (const event of events) {
669
- setTimeout(() => {
670
- window.dispatchEvent(
671
- new MessageEvent("message", {
672
- data: {
673
- action: event.action,
674
- data: event.data
675
- }
676
- })
677
- );
678
- }, timer);
679
- }
680
- }
681
- };
682
- var localeStore = create((set, get) => {
683
- return {
684
- locales: {
685
- "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."
686
- },
687
- locale: (key, ...args) => {
688
- const exists = get().locales[key];
689
- let translation = exists || key;
690
- if (args.length) {
691
- translation = translation.replace(/%s/g, () => String(args.shift() || ""));
692
- }
693
- return translation;
694
- }
695
- };
696
- });
697
- var locale = localeStore.getState().locale;
698
- fetchOnLoad("GET_LOCALES").then((data) => {
699
- localeStore.setState({ locales: data });
700
- });
701
- function SegmentedControl(props) {
702
- const theme2 = useMantineTheme();
703
- const play = useAudio((state) => state.play);
704
- const handleChange = (newValue) => {
705
- if (props.sounds) play("click");
706
- if (props.onChange) {
707
- props.onChange(newValue);
708
- }
709
- };
710
- return /* @__PURE__ */ jsx(
711
- Flex,
712
- {
713
- bg: "rgba(33, 33, 33, 0.6)",
714
- w: props.w || "fit-content",
715
- style: {
716
- borderRadius: theme2.radius.xs,
717
- overflow: "hidden"
718
- },
719
- ...props,
720
- children: props.items.map((item, index) => /* @__PURE__ */ jsx(
721
- motion.div,
722
- {
723
- initial: { x: -100, opacity: 0 },
724
- animate: { x: 0, opacity: 1 },
725
- transition: { duration: 0.3, delay: index * 0.1, ease: "easeInOut" },
726
- style: {
727
- display: "flex",
728
- flexDirection: "row",
729
- alignItems: "center",
730
- flex: 1
731
- },
732
- children: /* @__PURE__ */ jsx(
733
- Segment,
734
- {
735
- label: item.label,
736
- value: item.value,
737
- icon: item.icon,
738
- rightSection: item.rightSection,
739
- fz: props.fz,
740
- selected: !props.multi ? props.value === item.value : Array.isArray(props.value) && props.value.includes(item.value),
741
- onClick: () => {
742
- if (props.multi) {
743
- const newValue = Array.isArray(props.value) ? props.value.includes(item.value) ? props.value.filter((v) => v !== item.value) : [...props.value, item.value] : [item.value];
744
- handleChange(newValue);
745
- } else {
746
- handleChange(item.value);
747
- }
748
- }
749
- },
750
- item.value
751
- )
752
- },
753
- index
754
- ))
755
- }
756
- );
757
- }
758
- function Segment(props) {
759
- const theme2 = useMantineTheme();
760
- return /* @__PURE__ */ jsxs(
761
- MotionFlex,
762
- {
763
- onClick: props.onClick,
764
- w: "100%",
765
- direction: "column",
766
- align: "center",
767
- h: "100%",
768
- bg: props.selected ? colorWithAlpha(theme2.colors[theme2.primaryColor][theme2.primaryShade], 0.2) : "transparent",
769
- pos: "relative",
770
- style: {
771
- // position: "relative",
772
- cursor: "pointer"
773
- },
774
- justify: "center",
775
- whileHover: { scale: 1.05 },
776
- whileTap: { scale: 0.95 },
777
- children: [
778
- /* @__PURE__ */ jsxs(
779
- Flex,
780
- {
781
- align: "center",
782
- gap: "xs",
783
- p: "xs",
784
- children: [
785
- props.icon && /* @__PURE__ */ jsx(
786
- MotionIcon,
787
- {
788
- icon: props.icon,
789
- initial: {
790
- color: props.selected ? theme2.colors[theme2.primaryColor][5] : "inherit"
791
- },
792
- animate: {
793
- color: props.selected ? theme2.colors[theme2.primaryColor][5] : "inherit"
794
- },
795
- exit: {
796
- color: "inherit"
797
- },
798
- style: {
799
- fontSize: theme2.fontSizes.xs,
800
- marginBottom: "0.2vh"
801
- }
802
- }
803
- ),
804
- /* @__PURE__ */ jsx(
805
- MotionText,
806
- {
807
- size: props.fz || "xs",
808
- initial: {
809
- color: props.selected ? theme2.colors[theme2.primaryColor][5] : "inherit"
810
- },
811
- animate: {
812
- color: props.selected ? theme2.colors[theme2.primaryColor][5] : "inherit"
813
- },
814
- exit: {
815
- color: "inherit"
816
- },
817
- style: {
818
- fontFamily: "Akrobat Bold",
819
- letterSpacing: "0.1em",
820
- textTransform: "uppercase"
821
- },
822
- children: props.label.toUpperCase()
823
- }
824
- ),
825
- props.rightSection
826
- ]
827
- }
828
- ),
829
- /* @__PURE__ */ jsx(
830
- motion.div,
831
- {
832
- initial: false,
833
- animate: {
834
- scaleX: props.selected ? 1 : 0,
835
- opacity: props.selected ? 1 : 0
836
- },
837
- transition: {
838
- duration: 0.3,
839
- ease: [0.4, 0, 0.2, 1]
840
- // Custom easing curve for smooth feel
841
- },
842
- style: {
843
- position: "absolute",
844
- bottom: 0,
845
- left: 0,
846
- right: 0,
847
- height: "0.2vh",
848
- backgroundColor: theme2.colors[theme2.primaryColor][5],
849
- transformOrigin: "center"
850
- }
851
- }
852
- )
853
- ]
854
- }
855
- );
856
- }
857
- var NavigationContext = createContext(null);
858
- function useNavigation(selector) {
859
- const navigation = useContext(NavigationContext);
860
- if (!navigation) {
861
- throw new Error("useNavigation must be used within a NavigationProvider");
862
- }
863
- return useStore(navigation, selector);
864
- }
865
- function useNavigationStore() {
866
- const navigation = useContext(NavigationContext);
867
- if (!navigation) {
868
- throw new Error("useNavigationStore must be used within a NavigationProvider");
869
- }
870
- return navigation;
871
- }
872
- function NavigationProvider({ children, defaultPage }) {
873
- const storeRef = useRef(
874
- create(() => ({
875
- pageId: defaultPage || "home"
876
- }))
877
- );
878
- return /* @__PURE__ */ jsx(NavigationContext.Provider, { value: storeRef.current, children });
879
- }
880
- function NavBar(props) {
881
- const pageId = useNavigation((state) => state.pageId);
882
- const store = useNavigationStore();
883
- return /* @__PURE__ */ jsx(
884
- SegmentedControl,
885
- {
886
- sounds: true,
887
- w: "100%",
888
- value: pageId,
889
- items: props.items,
890
- onChange: (value) => {
891
- store.setState({ pageId: value });
892
- }
893
- }
894
- );
895
- }
896
- var containerVariants = {
897
- hidden: { opacity: 0 },
898
- visible: {
899
- opacity: 1,
900
- transition: {
901
- staggerChildren: 0.1,
902
- delayChildren: 0.05
903
- }
904
- },
905
- exit: {
906
- opacity: 0,
907
- transition: {
908
- staggerChildren: 0.05,
909
- staggerDirection: -1
910
- }
911
- }
912
- };
913
- var itemVariants = {
914
- hidden: {
915
- opacity: 0,
916
- x: 20,
917
- scale: 0.95
918
- },
919
- visible: {
920
- opacity: 1,
921
- x: 0,
922
- scale: 1,
923
- transition: {
924
- type: "spring",
925
- stiffness: 300,
926
- damping: 24
927
- }
928
- },
929
- exit: {
930
- opacity: 0,
931
- x: -10,
932
- scale: 0.95,
933
- transition: {
934
- duration: 0.2
935
- }
936
- }
937
- };
938
- function SegmentedProgress(props) {
939
- const progressPerSegment = 100 / props.segments;
940
- const filledSegments = Math.floor(props.progress / progressPerSegment);
941
- const partialFill = props.progress % progressPerSegment / progressPerSegment;
942
- return /* @__PURE__ */ jsx(
943
- MotionFlex,
944
- {
945
- w: "100%",
946
- h: props.size || "1vh",
947
- gap: "xs",
948
- initial: "hidden",
949
- animate: "visible",
950
- variants: containerVariants,
951
- children: [...Array(props.segments)].map((_, index) => {
952
- const isFilled = index < filledSegments;
953
- const isPartial = index === filledSegments;
954
- return /* @__PURE__ */ jsx(
955
- motion.div,
956
- {
957
- variants: itemVariants,
958
- style: {
959
- width: `${100 / props.segments}%`,
960
- // Ensures equal width distribution
961
- height: "100%",
962
- background: isFilled ? "rgba(255, 255, 255, 0.8)" : isPartial ? `linear-gradient(to right, rgba(255, 255, 255, 0.8) ${partialFill * 100}%, rgba(255, 255, 255, 0.2) ${partialFill * 100}%)` : "rgba(255, 255, 255, 0.2)",
963
- transition: "background 0.3s ease"
964
- }
965
- },
966
- index
967
- );
968
- })
969
- }
970
- );
971
- }
972
- function Title(props) {
973
- const theme2 = useMantineTheme();
974
- return /* @__PURE__ */ jsx(
975
- Flex,
976
- {
977
- mt: props.mt,
978
- direction: "column",
979
- bg: props.bg || "transparent",
980
- gap: "xs",
981
- w: props.w || "100%",
982
- p: props.p || "0",
983
- style: {
984
- userSelect: "none",
985
- borderBottom: props.removeBorder ? "none" : `0.2vh solid ${props.borderColor || colorWithAlpha(theme2.colors[theme2.primaryColor][9], 0.5)}`
986
- },
987
- children: /* @__PURE__ */ jsxs(
988
- Flex,
989
- {
990
- align: "center",
991
- justify: "center",
992
- children: [
993
- /* @__PURE__ */ jsxs(
994
- Flex,
995
- {
996
- align: "center",
997
- gap: "sm",
998
- pr: "xs",
999
- children: [
1000
- /* @__PURE__ */ jsx(
1001
- BorderedIcon,
1002
- {
1003
- icon: props.icon,
1004
- fontSize: theme2.fontSizes.md,
1005
- color: props.iconColor
1006
- }
1007
- ),
1008
- /* @__PURE__ */ jsxs(
1009
- Flex,
1010
- {
1011
- direction: "column",
1012
- gap: "0.25vh",
1013
- children: [
1014
- /* @__PURE__ */ jsx(Text, { p: "0", size: "sm", style: {
1015
- lineHeight: theme2.fontSizes.md,
1016
- fontFamily: "Akrobat Bold",
1017
- letterSpacing: "0.05em",
1018
- textTransform: "uppercase"
1019
- }, children: props.title }),
1020
- /* @__PURE__ */ jsx(
1021
- Text,
1022
- {
1023
- size: "xs",
1024
- c: "grey",
1025
- style: { whiteSpace: "normal", wordWrap: "break-word" },
1026
- children: props.description
1027
- }
1028
- )
1029
- ]
1030
- }
1031
- )
1032
- ]
1033
- }
1034
- ),
1035
- /* @__PURE__ */ jsx(
1036
- Flex,
1037
- {
1038
- ml: "auto",
1039
- align: "center",
1040
- gap: "xs",
1041
- children: props.rightSection
1042
- }
1043
- )
1044
- ]
1045
- }
1046
- )
1047
- }
1048
- );
1049
- }
1050
- var useNuiEvent = (action, handler) => {
1051
- const savedHandler = useRef(noop);
1052
- useEffect(() => {
1053
- savedHandler.current = handler;
1054
- }, [handler]);
1055
- useEffect(() => {
1056
- const eventListener = (event) => {
1057
- const { action: eventAction, data } = event.data;
1058
- if (savedHandler.current) {
1059
- if (eventAction === action) {
1060
- savedHandler.current(data);
1061
- }
1062
- }
1063
- };
1064
- window.addEventListener("message", eventListener);
1065
- return () => window.removeEventListener("message", eventListener);
1066
- }, [action]);
1067
- };
1068
- var theme = createTheme({
1069
- primaryColor: "dirk",
1070
- primaryShade: 9,
1071
- defaultRadius: "xxs",
1072
- fontFamily: "Akrobat Regular, sans-serif",
1073
- radius: {
1074
- xxs: "0.2vh",
1075
- xs: "0.4vh",
1076
- sm: "0.75vh",
1077
- md: "1vh",
1078
- lg: "1.5vh",
1079
- xl: "2vh",
1080
- xxl: "3vh"
1081
- },
1082
- fontSizes: {
1083
- xxs: "1.2vh",
1084
- xs: "1.5vh",
1085
- sm: "1.8vh",
1086
- md: "2.2vh",
1087
- lg: "2.8vh",
1088
- xl: "3.3vh",
1089
- xxl: "3.8vh"
1090
- },
1091
- spacing: {
1092
- xxs: "0.5vh",
1093
- xs: "0.75vh",
1094
- sm: "1.5vh",
1095
- md: "2vh",
1096
- lg: "3vh",
1097
- xl: "4vh",
1098
- xxl: "5vh"
1099
- },
1100
- components: {
1101
- Progress: {
1102
- styles: {
1103
- root: {
1104
- backgroundColor: "rgba(77, 77, 77, 0.4)"
1105
- }
1106
- }
1107
- },
1108
- Select: {
1109
- styles: {
1110
- dropdown: {
1111
- borderRadius: "var(--mantine-radius-xxs)"
1112
- },
1113
- input: {
1114
- padding: "var(--mantine-spacing-sm)"
1115
- },
1116
- item: {
1117
- borderRadius: "var(--mantine-radius-xxs)"
1118
- },
1119
- wrapper: {
1120
- borderRadius: "var(--mantine-radius-xxs)"
1121
- },
1122
- option: {
1123
- borderRadius: "var(--mantine-radius-xxs)"
1124
- }
1125
- }
1126
- },
1127
- MultiSelect: {
1128
- styles: {
1129
- dropdown: {
1130
- borderRadius: "var(--mantine-radius-xxs)"
1131
- },
1132
- pill: {
1133
- borderRadius: "var(--mantine-radius-xxs)"
1134
- },
1135
- item: {
1136
- borderRadius: "var(--mantine-radius-xxs)"
1137
- },
1138
- wrapper: {
1139
- borderRadius: "var(--mantine-radius-xxs)"
1140
- },
1141
- option: {
1142
- borderRadius: "var(--mantine-radius-xxs)"
1143
- }
1144
- }
1145
- },
1146
- TextInput: {
1147
- styles: {
1148
- section: {
1149
- marginRight: "0.2vh"
1150
- },
1151
- input: {
1152
- padding: "var(--mantine-spacing-sm)"
1153
- }
1154
- }
1155
- }
1156
- },
1157
- colors: {
1158
- dark: [
1159
- "#ffffff",
1160
- "#e2e2e2",
1161
- "#c6c6c6",
1162
- "#aaaaaa",
1163
- "#8d8d8d",
1164
- "#717171",
1165
- "#555555",
1166
- "#393939",
1167
- "#1c1c1c",
1168
- "#000000"
1169
- ],
1170
- dirk: [
1171
- "#ffffff",
1172
- "#f3fce9",
1173
- "#dbf5bd",
1174
- "#c3ee91",
1175
- "#ace765",
1176
- "#94e039",
1177
- "#7ac61f",
1178
- "#5f9a18",
1179
- "#29420a",
1180
- "#446e11"
1181
- ]
1182
- }
1183
- });
1184
- var theme_default = theme;
1185
- library.add(fas, far, fab);
1186
- var useSettings = create((set) => ({
1187
- game: "rdr3",
1188
- primaryColor: "teal",
1189
- primaryShade: 6,
1190
- customTheme: {}
1191
- }));
1192
- function DirkProvider(props) {
1193
- useSettings((data) => data.primaryColor);
1194
- useSettings((data) => data.primaryShade);
1195
- useSettings((data) => data.customTheme);
1196
- return /* @__PURE__ */ jsx(MantineProvider, { theme: theme_default, defaultColorScheme: "dark", children: /* @__PURE__ */ jsx(Wrapper, { children: props.children }) });
1197
- }
1198
- function Wrapper({ children }) {
1199
- const game = useSettings((data) => data.game);
1200
- return isEnvBrowser() ? /* @__PURE__ */ jsx(
1201
- BackgroundImage,
1202
- {
1203
- w: "100vw",
1204
- h: "100vh",
1205
- style: { overflow: "hidden" },
1206
- 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",
1207
- children
1208
- }
1209
- ) : /* @__PURE__ */ jsx(Fragment, { children });
1210
- }
1211
-
1212
- export { BorderedIcon, Counter, DirkProvider, FloatingParticles, Icon, InfoBox, InputContainer, MotionFlex, MotionIcon, MotionImage, MotionText, NavBar, NavigationContext, NavigationProvider, Segment, SegmentedControl, SegmentedProgress, Title, colorWithAlpha, copyToClipboard, fetchLuaTable, fetchNui, fetchOnLoad, internalEvent, isEnvBrowser, locale, localeStore, noop, numberToRoman, openLink, splitFAString, useNavigation, useNavigationStore, useNuiEvent, useSettings };
1213
2
  //# sourceMappingURL=index.js.map
1214
3
  //# sourceMappingURL=index.js.map