@putkoff/abstract-utilities 0.1.220 → 0.1.223

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.
@@ -0,0 +1,1758 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+
6
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
7
+ function getSafeDocument() {
8
+ return typeof document !== 'undefined' ? document : undefined;
9
+ }
10
+ function getDocumentProp(...keys) {
11
+ let obj = getSafeDocument();
12
+ for (const k of keys) {
13
+ if (obj == null || typeof obj !== 'object')
14
+ return undefined;
15
+ obj = obj[k];
16
+ }
17
+ return obj;
18
+ }
19
+
20
+ /**
21
+ * Safely walk `globalThis` (or window/document) by a chain of property names.
22
+ * Returns `undefined` if any step is missing.
23
+ */
24
+ function safeGlobalProp(...path) {
25
+ let obj = globalThis;
26
+ for (const key of path) {
27
+ if (obj == null || typeof obj !== "object" || !(key in obj)) {
28
+ return undefined;
29
+ }
30
+ obj = obj[key];
31
+ }
32
+ return obj;
33
+ }
34
+
35
+ /**
36
+ * Returns `window` if running in a browser, otherwise `undefined`.
37
+ */
38
+ function getSafeLocalStorage() {
39
+ if (typeof window === 'undefined')
40
+ return undefined;
41
+ try {
42
+ return window.localStorage;
43
+ }
44
+ catch (_a) {
45
+ return undefined; // e.g. Safari private-mode block
46
+ }
47
+ }
48
+ /**
49
+ * Call a Storage method by name, silencing any errors or missing storage.
50
+ *
51
+ * @param method One of the keys of the Storage interface: "getItem", "setItem", etc.
52
+ * @param args The arguments you’d normally pass to that method.
53
+ * @returns The method’s return value, or undefined if storage/method isn’t available.
54
+ */
55
+ function callStorage(method, ...args) {
56
+ const storage = getSafeLocalStorage();
57
+ if (!storage)
58
+ return undefined;
59
+ const fn = storage[method];
60
+ if (typeof fn !== 'function')
61
+ return undefined;
62
+ try {
63
+ // @ts-ignore – TS can’t infer that this is callable
64
+ return fn.apply(storage, args);
65
+ }
66
+ catch (_a) {
67
+ return undefined;
68
+ }
69
+ }
70
+ /**
71
+ * Safely call storage methods (`localStorage` or `sessionStorage`) without blowing up.
72
+ * Returns `undefined` on any error.
73
+ */
74
+ function safeStorage(storageName, method, ...args) {
75
+ try {
76
+ const store = safeGlobalProp(storageName);
77
+ if (!store || typeof store[method] !== "function")
78
+ return undefined;
79
+ // @ts-ignore
80
+ return store[method](...args);
81
+ }
82
+ catch (_a) {
83
+ return undefined;
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Returns the global window object if it exists, otherwise undefined.
89
+ */
90
+ function getSafeWindow() {
91
+ return typeof window !== 'undefined' ? window : undefined;
92
+ }
93
+ /**
94
+ * Safely call a method on window by name.
95
+ *
96
+ * @param method The Window method to call (e.g. "alert", "open", etc.).
97
+ * @param args Arguments to pass to that method.
98
+ * @returns The method’s return value, or undefined if
99
+ * window/method isn’t available or throws.
100
+ */
101
+ function callWindowMethod(method, ...args) {
102
+ const w = getSafeWindow();
103
+ if (!w)
104
+ return undefined;
105
+ const fn = w[method];
106
+ if (typeof fn !== 'function')
107
+ return undefined;
108
+ try {
109
+ // cast to any so TS doesn’t complain about apply/invoke
110
+ return fn(...args);
111
+ }
112
+ catch (_a) {
113
+ return undefined;
114
+ }
115
+ }
116
+ /** implementation */
117
+ function getWindowProp(...keys) {
118
+ let obj = getSafeWindow();
119
+ for (const k of keys) {
120
+ if (obj == null || typeof obj !== 'object')
121
+ return undefined;
122
+ obj = obj[k];
123
+ }
124
+ return obj;
125
+ }
126
+ function getWindowHost() {
127
+ return getWindowProp('location', 'host');
128
+ }
129
+
130
+ /**
131
+ ***Changes**:
132
+ *- Updated import path for `InputProps` to `../../types/interfaces`.
133
+ *
134
+ *3. **Token Utilities** (`src/functions/auth/token_utils.ts`):
135
+ * Copy from `/var/www/abstractendeavors/my-login-app/src/functions/auth_utils/token_utils.ts`.
136
+ *
137
+ */
138
+ /** Read raw JWT from LocalStorage (or null if absent) */
139
+ function getToken() {
140
+ return callStorage('getItem', 'token');
141
+ }
142
+ function isLoggedIn() {
143
+ const tok = getToken();
144
+ return !!tok && !isTokenExpired(tok !== null && tok !== void 0 ? tok : "");
145
+ }
146
+ function removeToken() {
147
+ let is_logged = isLoggedIn();
148
+ if (is_logged) {
149
+ callStorage('removeItem', "token");
150
+ }
151
+ is_logged = isLoggedIn();
152
+ if (is_logged) {
153
+ return false;
154
+ }
155
+ return true;
156
+ }
157
+ /**
158
+ * Add a Bearer Authorization header.
159
+ * A shallow copy of headers is returned so callers can keep chaining.
160
+ */
161
+ function getAuthorizationHeader(headers = {}, token = null) {
162
+ token = token !== null && token !== void 0 ? token : getToken();
163
+ headers = headers || {};
164
+ if (token)
165
+ headers["Authorization"] = `Bearer ${token}`;
166
+ return Object.assign({}, headers);
167
+ }
168
+ /** Throw + redirect if there’s no valid token; otherwise return it. */
169
+ function requireToken() {
170
+ const tok = getToken();
171
+ if (!tok || isTokenExpired(tok)) {
172
+ console.warn("→ No token or expired token, redirecting to login…");
173
+ removeToken();
174
+ window.location.href = '/';
175
+ throw new Error("Redirecting to login…");
176
+ }
177
+ return tok;
178
+ }
179
+ /** True if token is structurally bad or its exp ≤ now. */
180
+ function isTokenExpired(token) {
181
+ try {
182
+ const payload = decodeJwt(token);
183
+ return Date.now() / 1000 >= payload.exp;
184
+ }
185
+ catch (_a) {
186
+ return true; // treat malformed token as expired
187
+ }
188
+ }
189
+ /** Convenience wrapper: return username from the JWT (or null). */
190
+ function currentUsername() {
191
+ const token = getToken();
192
+ let uName = null;
193
+ if (token) {
194
+ const decodedJwt = decodeJwt(token) || {};
195
+ uName = (decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.username) || null;
196
+ }
197
+ return uName;
198
+ }
199
+ function currentUsernames() {
200
+ var _a;
201
+ const tok = getToken();
202
+ if (!tok)
203
+ return null;
204
+ try {
205
+ const parts = tok.split(".");
206
+ if (parts.length !== 3)
207
+ return null;
208
+ let b64 = parts[1].replace(/-/g, "+").replace(/_/g, "/");
209
+ b64 = b64.padEnd(Math.ceil(b64.length / 4) * 4, "=");
210
+ const jsonText = atob(b64);
211
+ const payload = JSON.parse(jsonText);
212
+ return (_a = payload.username) !== null && _a !== void 0 ? _a : null;
213
+ }
214
+ catch (_b) {
215
+ return null;
216
+ }
217
+ }
218
+ /* ------------------------------------------------------------------ */
219
+ /* internals */
220
+ /* ------------------------------------------------------------------ */
221
+ function decodeJwt(token) {
222
+ const [header, payload, signature] = token.split(".");
223
+ if (!header || !payload || !signature) {
224
+ throw new Error("Malformed JWT");
225
+ }
226
+ // Handle URL-safe Base64
227
+ let b64 = payload.replace(/-/g, "+").replace(/_/g, "/");
228
+ // Add padding if necessary
229
+ b64 = b64.padEnd(Math.ceil(b64.length / 4) * 4, "=");
230
+ const jsonText = atob(b64);
231
+ return JSON.parse(jsonText);
232
+ }
233
+
234
+ const PROTOCOL = 'https://';
235
+ const DOMAIN_NAME = 'abstractendeavors';
236
+ const BASE_URL = `${PROTOCOL}${DOMAIN_NAME}.com`;
237
+ const SUB_DIR = 'secure-files';
238
+ const PROD_PREFIX = `/${SUB_DIR}/`;
239
+ const API_PREFIX = `/${SUB_DIR}/api`;
240
+ const DEV_PREFIX = `/${SUB_DIR}-dev/`;
241
+
242
+ function get_window() {
243
+ try {
244
+ if (typeof window !== 'undefined') {
245
+ return window;
246
+ }
247
+ }
248
+ catch (err) {
249
+ alert(err);
250
+ }
251
+ return null;
252
+ }
253
+ function get_window_location() {
254
+ try {
255
+ const Window = get_window();
256
+ if (!Window) {
257
+ return BASE_URL;
258
+ }
259
+ return Window.location;
260
+ }
261
+ catch (err) {
262
+ alert(err);
263
+ }
264
+ return null;
265
+ }
266
+ function get_window_pathname() {
267
+ try {
268
+ const Window = get_window();
269
+ if (!Window) {
270
+ return DEV_PREFIX;
271
+ }
272
+ return Window.location.pathname;
273
+ }
274
+ catch (err) {
275
+ alert(err);
276
+ }
277
+ return null;
278
+ }
279
+ function get_window_parts() {
280
+ try {
281
+ return get_window_location();
282
+ }
283
+ catch (err) {
284
+ alert(err);
285
+ }
286
+ return null;
287
+ }
288
+
289
+ /******************************************************************************
290
+ Copyright (c) Microsoft Corporation.
291
+
292
+ Permission to use, copy, modify, and/or distribute this software for any
293
+ purpose with or without fee is hereby granted.
294
+
295
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
296
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
297
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
298
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
299
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
300
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
301
+ PERFORMANCE OF THIS SOFTWARE.
302
+ ***************************************************************************** */
303
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
304
+
305
+
306
+ function __rest(s, e) {
307
+ var t = {};
308
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
309
+ t[p] = s[p];
310
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
311
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
312
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
313
+ t[p[i]] = s[p[i]];
314
+ }
315
+ return t;
316
+ }
317
+
318
+ function __awaiter(thisArg, _arguments, P, generator) {
319
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
320
+ return new (P || (P = Promise))(function (resolve, reject) {
321
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
322
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
323
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
324
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
325
+ });
326
+ }
327
+
328
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
329
+ var e = new Error(message);
330
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
331
+ };
332
+
333
+ // src/functions/read_utils/src/read_utils.ts
334
+ /**
335
+ * Reads a JSON file, either via Node’s fs (if available)
336
+ * or via window.fetch in the browser. Never throws — returns
337
+ * the parsed object or null on any error.
338
+ */
339
+ function readJsonFile(relativeOrAbsolutePath) {
340
+ return __awaiter(this, void 0, void 0, function* () {
341
+ if (typeof window === 'undefined') {
342
+ try {
343
+ const { readFile } = yield import('fs/promises');
344
+ const { isAbsolute, resolve } = yield import('path');
345
+ const filePath = isAbsolute(relativeOrAbsolutePath)
346
+ ? relativeOrAbsolutePath
347
+ : resolve((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)) ? new URL('.', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href))).pathname : '', relativeOrAbsolutePath);
348
+ const text = yield readFile(filePath, 'utf8');
349
+ return JSON.parse(text);
350
+ }
351
+ catch (_a) {
352
+ return null;
353
+ }
354
+ }
355
+ // Browser fallback
356
+ const fetchFn = safeGlobalProp('fetch');
357
+ if (typeof fetchFn !== 'function')
358
+ return null;
359
+ let url = relativeOrAbsolutePath;
360
+ const baseURI = safeGlobalProp('document', 'baseURI');
361
+ if (baseURI) {
362
+ try {
363
+ url = new URL(relativeOrAbsolutePath, baseURI).href;
364
+ }
365
+ catch (_b) { }
366
+ }
367
+ try {
368
+ const res = yield fetchFn(url);
369
+ if (!res.ok)
370
+ return null;
371
+ return yield res.json();
372
+ }
373
+ catch (_c) {
374
+ return null;
375
+ }
376
+ });
377
+ }
378
+ function getConfigContent() {
379
+ return __awaiter(this, void 0, void 0, function* () {
380
+ try {
381
+ // `readJsonFile` should throw if the file isn’t there or isn’t valid JSON
382
+ const cfg = yield readJsonFile('./config.json');
383
+ return cfg;
384
+ }
385
+ catch (_a) {
386
+ // swallow errors & return null so callers can detect “no config”
387
+ return null;
388
+ }
389
+ });
390
+ }
391
+ // 2) Pull a single key out of that object
392
+ function getConfigVar() {
393
+ return __awaiter(this, arguments, void 0, function* (key = null) {
394
+ const cfg = yield getConfigContent();
395
+ if (cfg && typeof cfg === 'object' && key in cfg) {
396
+ return cfg[key];
397
+ }
398
+ return undefined;
399
+ });
400
+ }
401
+
402
+ /**
403
+ * Unwraps nested { result } fields until you hit a non-object or no more "result" keys.
404
+ */
405
+ function getResult(obj) {
406
+ let current = obj;
407
+ while (current &&
408
+ typeof current === "object" &&
409
+ Object.prototype.hasOwnProperty.call(current, "result")) {
410
+ current = current.result;
411
+ }
412
+ return current;
413
+ }
414
+ // Determines HTTP method, defaults to GET or POST based on body
415
+ function getMethod(method = null, body = null) {
416
+ const validMethods = ['GET', 'POST', 'PUT', 'PATCH', 'PULL'];
417
+ method = (method || '').toUpperCase();
418
+ if (!validMethods.includes(method)) {
419
+ method = body ? 'POST' : 'GET';
420
+ }
421
+ return method;
422
+ }
423
+ // Gets headers, skips JSON headers when body is FormData
424
+ function getHeaders(headers = {}, method = null, body = null) {
425
+ const result = Object.assign({}, headers);
426
+ // inject auth if missing
427
+ if (!result.Authorization) {
428
+ const token = getToken();
429
+ Object.assign(result, getAuthorizationHeader(result, token));
430
+ }
431
+ method = getMethod(method, body);
432
+ // if it’s a multipart FormData, let the browser set the boundary header
433
+ if (body instanceof FormData) {
434
+ return result;
435
+ }
436
+ // otherwise for POST/PUT/PATCH default to JSON
437
+ if (['POST', 'PUT', 'PATCH'].includes(method) && !result['Content-Type']) {
438
+ result['Content-Type'] = 'application/json';
439
+ }
440
+ return result;
441
+ }
442
+ // Prepares request body, serializes to JSON for non-GET requests
443
+ function getBody(body = null, method = null) {
444
+ method = getMethod(method, body);
445
+ if (method === 'GET') {
446
+ return undefined;
447
+ }
448
+ if (body) {
449
+ try {
450
+ return JSON.stringify(body);
451
+ }
452
+ catch (err) {
453
+ return body;
454
+ }
455
+ }
456
+ return undefined;
457
+ }
458
+ // Prepares fetch variables, passes FormData intact
459
+ function getFetchVars(headers = null, method = null, body = null) {
460
+ method = getMethod(method, body);
461
+ headers = getHeaders(headers || {}, method, body);
462
+ // only JSON-stringify non-FormData bodies
463
+ if (!(body instanceof FormData)) {
464
+ body = getBody(body, method);
465
+ }
466
+ return { method, headers, body };
467
+ }
468
+ /*
469
+ * parseResult no longer needs to worry about JSON vs HTML redirect errors;
470
+ * all 401/403 have already been handled above.
471
+ */
472
+ function parseResult(res) {
473
+ return __awaiter(this, void 0, void 0, function* () {
474
+ // runs checkResponse first, will throw if session is expired
475
+ res = checkResponse(res);
476
+ if (!res.ok) {
477
+ // for any other non-401 errors, you can still surface them
478
+ const errorText = yield res.text();
479
+ throw new Error(errorText || res.statusText);
480
+ }
481
+ // now safely parse JSON
482
+ return res.json();
483
+ });
484
+ }
485
+ /**
486
+ * Intercept 401/403 and force a clean redirect to login
487
+ * without ever showing an alert.
488
+ */
489
+ function checkResponse(res) {
490
+ if (res.status === 401 || res.status === 403) {
491
+ // 1) clear out the stale token
492
+ localStorage.removeItem("token");
493
+ // 2) replace history so "back" doesn’t re-trigger the protected route
494
+ window.history.replaceState({}, "", "/secure-files");
495
+ // 3) short-circuit all further fetch logic
496
+ throw new Error("SessionExpired");
497
+ }
498
+ return res;
499
+ }
500
+
501
+ function fetchIt(endpoint_1) {
502
+ return __awaiter(this, arguments, void 0, function* (endpoint, body = null, method = null, headers = null, blob = false, configUrl = false, withCredentials = true, returnJson = true, returnResult = true) {
503
+ method = (method || "GET").toUpperCase();
504
+ // 2) choose the URL
505
+ let url = endpoint;
506
+ // 3) prepare headers & body
507
+ headers = Object.assign(Object.assign(Object.assign({}, (body instanceof FormData ? {} : { "Content-Type": "application/json" })), getAuthorizationHeader()), headers);
508
+ const opts = {
509
+ method,
510
+ credentials: withCredentials ? "include" : "same-origin",
511
+ headers,
512
+ body: body instanceof FormData
513
+ ? body
514
+ : body != null && method !== "GET"
515
+ ? JSON.stringify(body)
516
+ : undefined,
517
+ };
518
+ console.debug("➡️ secureFetchIt →", url, opts);
519
+ let res = yield fetch(url, opts);
520
+ if (!res.ok) {
521
+ const err = yield res.text();
522
+ throw new Error(`HTTP ${res.status}: ${err}`);
523
+ }
524
+ if (blob)
525
+ return res.blob();
526
+ if (returnResult || returnJson) {
527
+ let JsonRes = parseResult(res);
528
+ if (returnResult) {
529
+ JsonRes = getResult(JsonRes);
530
+ }
531
+ return JsonRes;
532
+ }
533
+ return res;
534
+ });
535
+ }
536
+ // Constructs HTML directory path
537
+ function getHtmlDirectory(directory, filename) {
538
+ return `${directory}/${filename}.html`;
539
+ }
540
+ // Fetches HTML content
541
+ function fetchIndexHtml(filename_1) {
542
+ return __awaiter(this, arguments, void 0, function* (filename, directory = 'sf_index', base = 'html') {
543
+ const url = `/${base}/${directory}/${filename}.html`;
544
+ const response = yield fetch(url);
545
+ return yield response.text();
546
+ });
547
+ }
548
+ // Fetches and injects HTML content into container
549
+ function fetchIndexHtmlContainer(filename_1) {
550
+ return __awaiter(this, arguments, void 0, function* (filename, doc = document, directory = 'html') {
551
+ const container = `${filename}-container`;
552
+ const html = yield fetchIndexHtml(filename, directory);
553
+ const el = doc.getElementById(container);
554
+ if (el) {
555
+ el.innerHTML = html;
556
+ }
557
+ else {
558
+ console.warn(`⚠️ No container found for: #${container}`);
559
+ }
560
+ });
561
+ }
562
+
563
+ function assertPath(path) {
564
+ if (typeof path !== 'string') {
565
+ throw new TypeError('Path must be a string. Received ' + JSON.stringify(path));
566
+ }
567
+ }
568
+
569
+ // Resolves . and .. elements in a path with directory names
570
+ function normalizeStringPosix(path, allowAboveRoot) {
571
+ var res = '';
572
+ var lastSegmentLength = 0;
573
+ var lastSlash = -1;
574
+ var dots = 0;
575
+ var code;
576
+ for (var i = 0; i <= path.length; ++i) {
577
+ if (i < path.length)
578
+ code = path.charCodeAt(i);
579
+ else if (code === 47 /*/*/)
580
+ break;
581
+ else
582
+ code = 47 /*/*/;
583
+ if (code === 47 /*/*/) {
584
+ if (lastSlash === i - 1 || dots === 1) ; else if (lastSlash !== i - 1 && dots === 2) {
585
+ if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 /*.*/ || res.charCodeAt(res.length - 2) !== 46 /*.*/) {
586
+ if (res.length > 2) {
587
+ var lastSlashIndex = res.lastIndexOf('/');
588
+ if (lastSlashIndex !== res.length - 1) {
589
+ if (lastSlashIndex === -1) {
590
+ res = '';
591
+ lastSegmentLength = 0;
592
+ } else {
593
+ res = res.slice(0, lastSlashIndex);
594
+ lastSegmentLength = res.length - 1 - res.lastIndexOf('/');
595
+ }
596
+ lastSlash = i;
597
+ dots = 0;
598
+ continue;
599
+ }
600
+ } else if (res.length === 2 || res.length === 1) {
601
+ res = '';
602
+ lastSegmentLength = 0;
603
+ lastSlash = i;
604
+ dots = 0;
605
+ continue;
606
+ }
607
+ }
608
+ if (allowAboveRoot) {
609
+ if (res.length > 0)
610
+ res += '/..';
611
+ else
612
+ res = '..';
613
+ lastSegmentLength = 2;
614
+ }
615
+ } else {
616
+ if (res.length > 0)
617
+ res += '/' + path.slice(lastSlash + 1, i);
618
+ else
619
+ res = path.slice(lastSlash + 1, i);
620
+ lastSegmentLength = i - lastSlash - 1;
621
+ }
622
+ lastSlash = i;
623
+ dots = 0;
624
+ } else if (code === 46 /*.*/ && dots !== -1) {
625
+ ++dots;
626
+ } else {
627
+ dots = -1;
628
+ }
629
+ }
630
+ return res;
631
+ }
632
+
633
+ function _format(sep, pathObject) {
634
+ var dir = pathObject.dir || pathObject.root;
635
+ var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || '');
636
+ if (!dir) {
637
+ return base;
638
+ }
639
+ if (dir === pathObject.root) {
640
+ return dir + base;
641
+ }
642
+ return dir + sep + base;
643
+ }
644
+
645
+ var posix = {
646
+ // path.resolve([from ...], to)
647
+ resolve: function resolve() {
648
+ var resolvedPath = '';
649
+ var resolvedAbsolute = false;
650
+ var cwd;
651
+
652
+ for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
653
+ var path;
654
+ if (i >= 0)
655
+ path = arguments[i];
656
+ else {
657
+ if (cwd === undefined)
658
+ cwd = process.cwd();
659
+ path = cwd;
660
+ }
661
+
662
+ assertPath(path);
663
+
664
+ // Skip empty entries
665
+ if (path.length === 0) {
666
+ continue;
667
+ }
668
+
669
+ resolvedPath = path + '/' + resolvedPath;
670
+ resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/;
671
+ }
672
+
673
+ // At this point the path should be resolved to a full absolute path, but
674
+ // handle relative paths to be safe (might happen when process.cwd() fails)
675
+
676
+ // Normalize the path
677
+ resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
678
+
679
+ if (resolvedAbsolute) {
680
+ if (resolvedPath.length > 0)
681
+ return '/' + resolvedPath;
682
+ else
683
+ return '/';
684
+ } else if (resolvedPath.length > 0) {
685
+ return resolvedPath;
686
+ } else {
687
+ return '.';
688
+ }
689
+ },
690
+
691
+ normalize: function normalize(path) {
692
+ assertPath(path);
693
+
694
+ if (path.length === 0) return '.';
695
+
696
+ var isAbsolute = path.charCodeAt(0) === 47 /*/*/;
697
+ var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/;
698
+
699
+ // Normalize the path
700
+ path = normalizeStringPosix(path, !isAbsolute);
701
+
702
+ if (path.length === 0 && !isAbsolute) path = '.';
703
+ if (path.length > 0 && trailingSeparator) path += '/';
704
+
705
+ if (isAbsolute) return '/' + path;
706
+ return path;
707
+ },
708
+
709
+ isAbsolute: function isAbsolute(path) {
710
+ assertPath(path);
711
+ return path.length > 0 && path.charCodeAt(0) === 47 /*/*/;
712
+ },
713
+
714
+ join: function join() {
715
+ if (arguments.length === 0)
716
+ return '.';
717
+ var joined;
718
+ for (var i = 0; i < arguments.length; ++i) {
719
+ var arg = arguments[i];
720
+ assertPath(arg);
721
+ if (arg.length > 0) {
722
+ if (joined === undefined)
723
+ joined = arg;
724
+ else
725
+ joined += '/' + arg;
726
+ }
727
+ }
728
+ if (joined === undefined)
729
+ return '.';
730
+ return posix.normalize(joined);
731
+ },
732
+
733
+ relative: function relative(from, to) {
734
+ assertPath(from);
735
+ assertPath(to);
736
+
737
+ if (from === to) return '';
738
+
739
+ from = posix.resolve(from);
740
+ to = posix.resolve(to);
741
+
742
+ if (from === to) return '';
743
+
744
+ // Trim any leading backslashes
745
+ var fromStart = 1;
746
+ for (; fromStart < from.length; ++fromStart) {
747
+ if (from.charCodeAt(fromStart) !== 47 /*/*/)
748
+ break;
749
+ }
750
+ var fromEnd = from.length;
751
+ var fromLen = fromEnd - fromStart;
752
+
753
+ // Trim any leading backslashes
754
+ var toStart = 1;
755
+ for (; toStart < to.length; ++toStart) {
756
+ if (to.charCodeAt(toStart) !== 47 /*/*/)
757
+ break;
758
+ }
759
+ var toEnd = to.length;
760
+ var toLen = toEnd - toStart;
761
+
762
+ // Compare paths to find the longest common path from root
763
+ var length = fromLen < toLen ? fromLen : toLen;
764
+ var lastCommonSep = -1;
765
+ var i = 0;
766
+ for (; i <= length; ++i) {
767
+ if (i === length) {
768
+ if (toLen > length) {
769
+ if (to.charCodeAt(toStart + i) === 47 /*/*/) {
770
+ // We get here if `from` is the exact base path for `to`.
771
+ // For example: from='/foo/bar'; to='/foo/bar/baz'
772
+ return to.slice(toStart + i + 1);
773
+ } else if (i === 0) {
774
+ // We get here if `from` is the root
775
+ // For example: from='/'; to='/foo'
776
+ return to.slice(toStart + i);
777
+ }
778
+ } else if (fromLen > length) {
779
+ if (from.charCodeAt(fromStart + i) === 47 /*/*/) {
780
+ // We get here if `to` is the exact base path for `from`.
781
+ // For example: from='/foo/bar/baz'; to='/foo/bar'
782
+ lastCommonSep = i;
783
+ } else if (i === 0) {
784
+ // We get here if `to` is the root.
785
+ // For example: from='/foo'; to='/'
786
+ lastCommonSep = 0;
787
+ }
788
+ }
789
+ break;
790
+ }
791
+ var fromCode = from.charCodeAt(fromStart + i);
792
+ var toCode = to.charCodeAt(toStart + i);
793
+ if (fromCode !== toCode)
794
+ break;
795
+ else if (fromCode === 47 /*/*/)
796
+ lastCommonSep = i;
797
+ }
798
+
799
+ var out = '';
800
+ // Generate the relative path based on the path difference between `to`
801
+ // and `from`
802
+ for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
803
+ if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) {
804
+ if (out.length === 0)
805
+ out += '..';
806
+ else
807
+ out += '/..';
808
+ }
809
+ }
810
+
811
+ // Lastly, append the rest of the destination (`to`) path that comes after
812
+ // the common path parts
813
+ if (out.length > 0)
814
+ return out + to.slice(toStart + lastCommonSep);
815
+ else {
816
+ toStart += lastCommonSep;
817
+ if (to.charCodeAt(toStart) === 47 /*/*/)
818
+ ++toStart;
819
+ return to.slice(toStart);
820
+ }
821
+ },
822
+
823
+ _makeLong: function _makeLong(path) {
824
+ return path;
825
+ },
826
+
827
+ dirname: function dirname(path) {
828
+ assertPath(path);
829
+ if (path.length === 0) return '.';
830
+ var code = path.charCodeAt(0);
831
+ var hasRoot = code === 47 /*/*/;
832
+ var end = -1;
833
+ var matchedSlash = true;
834
+ for (var i = path.length - 1; i >= 1; --i) {
835
+ code = path.charCodeAt(i);
836
+ if (code === 47 /*/*/) {
837
+ if (!matchedSlash) {
838
+ end = i;
839
+ break;
840
+ }
841
+ } else {
842
+ // We saw the first non-path separator
843
+ matchedSlash = false;
844
+ }
845
+ }
846
+
847
+ if (end === -1) return hasRoot ? '/' : '.';
848
+ if (hasRoot && end === 1) return '//';
849
+ return path.slice(0, end);
850
+ },
851
+
852
+ basename: function basename(path, ext) {
853
+ if (ext !== undefined && typeof ext !== 'string') throw new TypeError('"ext" argument must be a string');
854
+ assertPath(path);
855
+
856
+ var start = 0;
857
+ var end = -1;
858
+ var matchedSlash = true;
859
+ var i;
860
+
861
+ if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
862
+ if (ext.length === path.length && ext === path) return '';
863
+ var extIdx = ext.length - 1;
864
+ var firstNonSlashEnd = -1;
865
+ for (i = path.length - 1; i >= 0; --i) {
866
+ var code = path.charCodeAt(i);
867
+ if (code === 47 /*/*/) {
868
+ // If we reached a path separator that was not part of a set of path
869
+ // separators at the end of the string, stop now
870
+ if (!matchedSlash) {
871
+ start = i + 1;
872
+ break;
873
+ }
874
+ } else {
875
+ if (firstNonSlashEnd === -1) {
876
+ // We saw the first non-path separator, remember this index in case
877
+ // we need it if the extension ends up not matching
878
+ matchedSlash = false;
879
+ firstNonSlashEnd = i + 1;
880
+ }
881
+ if (extIdx >= 0) {
882
+ // Try to match the explicit extension
883
+ if (code === ext.charCodeAt(extIdx)) {
884
+ if (--extIdx === -1) {
885
+ // We matched the extension, so mark this as the end of our path
886
+ // component
887
+ end = i;
888
+ }
889
+ } else {
890
+ // Extension does not match, so our result is the entire path
891
+ // component
892
+ extIdx = -1;
893
+ end = firstNonSlashEnd;
894
+ }
895
+ }
896
+ }
897
+ }
898
+
899
+ if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length;
900
+ return path.slice(start, end);
901
+ } else {
902
+ for (i = path.length - 1; i >= 0; --i) {
903
+ if (path.charCodeAt(i) === 47 /*/*/) {
904
+ // If we reached a path separator that was not part of a set of path
905
+ // separators at the end of the string, stop now
906
+ if (!matchedSlash) {
907
+ start = i + 1;
908
+ break;
909
+ }
910
+ } else if (end === -1) {
911
+ // We saw the first non-path separator, mark this as the end of our
912
+ // path component
913
+ matchedSlash = false;
914
+ end = i + 1;
915
+ }
916
+ }
917
+
918
+ if (end === -1) return '';
919
+ return path.slice(start, end);
920
+ }
921
+ },
922
+
923
+ extname: function extname(path) {
924
+ assertPath(path);
925
+ var startDot = -1;
926
+ var startPart = 0;
927
+ var end = -1;
928
+ var matchedSlash = true;
929
+ // Track the state of characters (if any) we see before our first dot and
930
+ // after any path separator we find
931
+ var preDotState = 0;
932
+ for (var i = path.length - 1; i >= 0; --i) {
933
+ var code = path.charCodeAt(i);
934
+ if (code === 47 /*/*/) {
935
+ // If we reached a path separator that was not part of a set of path
936
+ // separators at the end of the string, stop now
937
+ if (!matchedSlash) {
938
+ startPart = i + 1;
939
+ break;
940
+ }
941
+ continue;
942
+ }
943
+ if (end === -1) {
944
+ // We saw the first non-path separator, mark this as the end of our
945
+ // extension
946
+ matchedSlash = false;
947
+ end = i + 1;
948
+ }
949
+ if (code === 46 /*.*/) {
950
+ // If this is our first dot, mark it as the start of our extension
951
+ if (startDot === -1)
952
+ startDot = i;
953
+ else if (preDotState !== 1)
954
+ preDotState = 1;
955
+ } else if (startDot !== -1) {
956
+ // We saw a non-dot and non-path separator before our dot, so we should
957
+ // have a good chance at having a non-empty extension
958
+ preDotState = -1;
959
+ }
960
+ }
961
+
962
+ if (startDot === -1 || end === -1 ||
963
+ // We saw a non-dot character immediately before the dot
964
+ preDotState === 0 ||
965
+ // The (right-most) trimmed path component is exactly '..'
966
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
967
+ return '';
968
+ }
969
+ return path.slice(startDot, end);
970
+ },
971
+
972
+ format: function format(pathObject) {
973
+ if (pathObject === null || typeof pathObject !== 'object') {
974
+ throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
975
+ }
976
+ return _format('/', pathObject);
977
+ },
978
+
979
+ parse: function parse(path) {
980
+ assertPath(path);
981
+
982
+ var ret = { root: '', dir: '', base: '', ext: '', name: '' };
983
+ if (path.length === 0) return ret;
984
+ var code = path.charCodeAt(0);
985
+ var isAbsolute = code === 47 /*/*/;
986
+ var start;
987
+ if (isAbsolute) {
988
+ ret.root = '/';
989
+ start = 1;
990
+ } else {
991
+ start = 0;
992
+ }
993
+ var startDot = -1;
994
+ var startPart = 0;
995
+ var end = -1;
996
+ var matchedSlash = true;
997
+ var i = path.length - 1;
998
+
999
+ // Track the state of characters (if any) we see before our first dot and
1000
+ // after any path separator we find
1001
+ var preDotState = 0;
1002
+
1003
+ // Get non-dir info
1004
+ for (; i >= start; --i) {
1005
+ code = path.charCodeAt(i);
1006
+ if (code === 47 /*/*/) {
1007
+ // If we reached a path separator that was not part of a set of path
1008
+ // separators at the end of the string, stop now
1009
+ if (!matchedSlash) {
1010
+ startPart = i + 1;
1011
+ break;
1012
+ }
1013
+ continue;
1014
+ }
1015
+ if (end === -1) {
1016
+ // We saw the first non-path separator, mark this as the end of our
1017
+ // extension
1018
+ matchedSlash = false;
1019
+ end = i + 1;
1020
+ }
1021
+ if (code === 46 /*.*/) {
1022
+ // If this is our first dot, mark it as the start of our extension
1023
+ if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1;
1024
+ } else if (startDot !== -1) {
1025
+ // We saw a non-dot and non-path separator before our dot, so we should
1026
+ // have a good chance at having a non-empty extension
1027
+ preDotState = -1;
1028
+ }
1029
+ }
1030
+
1031
+ if (startDot === -1 || end === -1 ||
1032
+ // We saw a non-dot character immediately before the dot
1033
+ preDotState === 0 ||
1034
+ // The (right-most) trimmed path component is exactly '..'
1035
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
1036
+ if (end !== -1) {
1037
+ if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end);
1038
+ }
1039
+ } else {
1040
+ if (startPart === 0 && isAbsolute) {
1041
+ ret.name = path.slice(1, startDot);
1042
+ ret.base = path.slice(1, end);
1043
+ } else {
1044
+ ret.name = path.slice(startPart, startDot);
1045
+ ret.base = path.slice(startPart, end);
1046
+ }
1047
+ ret.ext = path.slice(startDot, end);
1048
+ }
1049
+
1050
+ if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/';
1051
+
1052
+ return ret;
1053
+ },
1054
+
1055
+ sep: '/',
1056
+ delimiter: ':',
1057
+ win32: null,
1058
+ posix: null
1059
+ };
1060
+
1061
+ posix.posix = posix;
1062
+
1063
+ var pathBrowserify = posix;
1064
+
1065
+ function ensure_list(obj) {
1066
+ const objArray = Array.isArray(obj) ? obj : [obj];
1067
+ return objArray;
1068
+ }
1069
+ function assureString(obj) {
1070
+ return String(obj);
1071
+ }
1072
+ function cleanArray(obj) {
1073
+ obj = assureArray(obj);
1074
+ return Array.from(new Set(obj));
1075
+ }
1076
+ function assureArray(input) {
1077
+ if (typeof input === 'string') {
1078
+ return [input];
1079
+ }
1080
+ if (Array.isArray(input)) {
1081
+ return input.map(item => assureString(item));
1082
+ }
1083
+ return [];
1084
+ }
1085
+ // Constrain T so 'in obj' is allowed
1086
+ function get_key_value(obj, key) {
1087
+ // we cast to any for the indexing, since TS can’t infer arbitrary string keys
1088
+ if (key in obj && obj[key] != null) {
1089
+ return obj[key];
1090
+ }
1091
+ return null;
1092
+ }
1093
+ function get(obj, keys, defaultValue = null) {
1094
+ const keyArray = assureArray(keys);
1095
+ if (!obj || keyArray.length === 0) {
1096
+ return defaultValue;
1097
+ }
1098
+ for (const key of keyArray) {
1099
+ const val = get_key_value(obj, key);
1100
+ if (val != null) {
1101
+ return val;
1102
+ }
1103
+ }
1104
+ return defaultValue;
1105
+ }
1106
+ function cleanText(input) {
1107
+ // Replace delimiters with spaces and split
1108
+ const str = assureString(input);
1109
+ const words = str.replace(/[_.-]/g, ' '); // Replace _, -, . with space
1110
+ return words;
1111
+ }
1112
+ function getCleanArray(obj) {
1113
+ obj = obj.split(/\s+/) // Split on any whitespace
1114
+ .filter((item) => typeof item === 'string' && item !== '');
1115
+ // Get basename
1116
+ // Remove duplicates using Set
1117
+ const uniqueWords = cleanArray(obj);
1118
+ return uniqueWords;
1119
+ }
1120
+ function isStrInString(obj, string) {
1121
+ const obj_str = assureString(obj).toLowerCase;
1122
+ string = assureString(string).toLowerCase;
1123
+ if (string.includes(obj_str)) {
1124
+ return true;
1125
+ }
1126
+ return false;
1127
+ }
1128
+ function getChar(i, string) {
1129
+ if (string.length >= i) {
1130
+ return assureString(string)[i];
1131
+ }
1132
+ }
1133
+ function isType(obj, type) {
1134
+ if (typeof obj === type) {
1135
+ return true;
1136
+ }
1137
+ return false;
1138
+ }
1139
+ function getNums() {
1140
+ return '0123456789';
1141
+ }
1142
+ function isNum(obj) {
1143
+ const is_num = isType(obj, 'number');
1144
+ if (is_num) {
1145
+ return is_num;
1146
+ }
1147
+ return isStrInString(obj, getNums());
1148
+ }
1149
+ function ensure_number(object) {
1150
+ if (isNum(object)) {
1151
+ return Number(object);
1152
+ }
1153
+ let nuString = '';
1154
+ const object_str = assureString(object);
1155
+ const str_spl = object_str.split('');
1156
+ for (const obj in str_spl) {
1157
+ if (isNum(obj)) {
1158
+ nuString += obj;
1159
+ }
1160
+ }
1161
+ if (nuString != '') {
1162
+ return Number(nuString);
1163
+ }
1164
+ return null;
1165
+ }
1166
+ function getAlphas() {
1167
+ return 'abcdefghijklmnopqrstuvwxyz';
1168
+ }
1169
+ function getAlphaNum(obj) {
1170
+ const is_num = isNum(obj);
1171
+ const alphas = getAlphas();
1172
+ if (is_num) {
1173
+ return getChar(obj, alphas);
1174
+ }
1175
+ if (isStrInString(obj, alphas)) {
1176
+ return getChar(obj, alphas);
1177
+ }
1178
+ }
1179
+
1180
+ function getSubstring(obj, maxLength = null, minLength = null) {
1181
+ const objLength = obj.length;
1182
+ const effectiveMaxLength = maxLength !== null && maxLength !== void 0 ? maxLength : objLength; // Use nullish coalescing for clarity
1183
+ const effectiveMinLength = minLength !== null && minLength !== void 0 ? minLength : 0;
1184
+ // Ensure bounds are valid
1185
+ const clampedMaxLength = Math.min(Math.max(effectiveMaxLength, 0), objLength);
1186
+ const clampedMinLength = Math.min(Math.max(effectiveMinLength, 0), objLength);
1187
+ // If minLength exceeds maxLength, return empty string or adjust logic as needed
1188
+ if (clampedMinLength >= clampedMaxLength) {
1189
+ return '';
1190
+ }
1191
+ return obj.substring(clampedMinLength, clampedMaxLength);
1192
+ }
1193
+ function truncateString(obj, maxLength = 20) {
1194
+ const objLength = obj.length;
1195
+ if (objLength > maxLength && maxLength) {
1196
+ obj = getSubstring(obj, maxLength) + '...';
1197
+ }
1198
+ return obj;
1199
+ }
1200
+ function capitalize_str(string) {
1201
+ string = assureString(string);
1202
+ const string_len = string.length;
1203
+ let init_char = string.toUpperCase();
1204
+ if (string_len > 0) {
1205
+ init_char = string[0].toUpperCase();
1206
+ }
1207
+ let rest_chars = '';
1208
+ if (string_len > 1) {
1209
+ rest_chars = string.slice(1).toLowerCase();
1210
+ }
1211
+ const fin_chars = `${init_char}${rest_chars}`;
1212
+ return fin_chars;
1213
+ }
1214
+ function capitalize(string) {
1215
+ let nu_string = '';
1216
+ string = assureString(string);
1217
+ let objs = string.replace('-', '_').split('_');
1218
+ for (const obj of objs) {
1219
+ let str_obj = capitalize_str(obj);
1220
+ nu_string = `${nu_string} ${str_obj}`;
1221
+ }
1222
+ return eatAll(nu_string, [' ']);
1223
+ }
1224
+ // string_utils/src/string_utils.ts
1225
+ function stripPrefixes(str, bases = []) {
1226
+ /* NEW: coerce whatever arrives into a string */
1227
+ str = String(str);
1228
+ const prefixes = (Array.isArray(bases) ? bases : [bases])
1229
+ .filter(Boolean)
1230
+ .sort((a, b) => b.length - a.length); // longest first
1231
+ let changed = true;
1232
+ while (changed) {
1233
+ changed = false;
1234
+ for (const prefix of prefixes) {
1235
+ if (str.startsWith(prefix)) {
1236
+ str = str.slice(prefix.length);
1237
+ changed = true;
1238
+ break; // restart from longest prefix
1239
+ }
1240
+ }
1241
+ }
1242
+ return str;
1243
+ }
1244
+ /**
1245
+ * Removes characters from the beginning of the string
1246
+ * if they are found in the list of characters.
1247
+ *
1248
+ * @param str - The input string.
1249
+ * @param listObjects - A string or an array of characters to remove.
1250
+ * @returns The modified string.
1251
+ */
1252
+ function eatInner(str, listObjects) {
1253
+ if (!Array.isArray(listObjects)) {
1254
+ listObjects = [listObjects];
1255
+ }
1256
+ // Ensure str is a string
1257
+ str = String(str);
1258
+ // Remove characters from the beginning while they are in listObjects
1259
+ while (str.length > 0 && listObjects.includes(str[0])) {
1260
+ str = str.slice(1);
1261
+ }
1262
+ return str;
1263
+ }
1264
+ /**
1265
+ * Removes characters from the end of the string
1266
+ * if they are found in the list of characters.
1267
+ *
1268
+ * @param str - The input string.
1269
+ * @param listObjects - A string or an array of characters to remove.
1270
+ * @returns The modified string.
1271
+ */
1272
+ function eatOuter(str, listObjects) {
1273
+ if (!Array.isArray(listObjects)) {
1274
+ listObjects = [listObjects];
1275
+ }
1276
+ // Ensure str is a string
1277
+ str = String(str);
1278
+ // Remove characters from the end while they are in listObjects
1279
+ while (str.length > 0 && listObjects.includes(str[str.length - 1])) {
1280
+ str = str.slice(0, -1);
1281
+ }
1282
+ return str;
1283
+ }
1284
+ /**
1285
+ * Removes characters from both the beginning and the end of the string
1286
+ * if they are found in the list of characters.
1287
+ *
1288
+ * @param str - The input string.
1289
+ * @param listObjects - A string or an array of characters to remove.
1290
+ * @returns The modified string.
1291
+ */
1292
+ function eatAll(str, listObjects) {
1293
+ return eatOuter(eatInner(str, listObjects), listObjects);
1294
+ }
1295
+ function eatEnd(obj, endings = ['/']) {
1296
+ let result = obj;
1297
+ let modified = true;
1298
+ while (modified) {
1299
+ modified = false;
1300
+ for (const ending of endings) {
1301
+ if (result.endsWith(ending)) {
1302
+ result = result.slice(0, -ending.length);
1303
+ modified = true;
1304
+ break;
1305
+ }
1306
+ }
1307
+ }
1308
+ return result;
1309
+ }
1310
+ function tryParse(obj) {
1311
+ try {
1312
+ obj = JSON.stringify(obj);
1313
+ }
1314
+ catch (err) {
1315
+ try {
1316
+ obj = JSON.parse(obj);
1317
+ }
1318
+ catch (err) {
1319
+ }
1320
+ }
1321
+ return obj;
1322
+ }
1323
+ function create_list_string(array_obj) {
1324
+ let string = '';
1325
+ for (const obj in array_obj) {
1326
+ const array_value = array_obj[obj];
1327
+ const parsed_value = tryParse(array_value);
1328
+ string += `${obj} == ${parsed_value}\n`;
1329
+ }
1330
+ return string;
1331
+ }
1332
+
1333
+ /**
1334
+ * In the browser we already have a WHATWG URL constructor on window.
1335
+ * Here we re-export it as “url” so other modules can import it.
1336
+ */
1337
+ /**
1338
+ * Minimal fileURLToPath implementation for browser-side code.
1339
+ * If you only ever need to strip off “file://” in development, this is enough.
1340
+ */
1341
+ function fileURLToPath(fileUrl) {
1342
+ // e.g. fileUrl = "file:///Users/foo/bar.txt"
1343
+ try {
1344
+ const u = new URL(fileUrl);
1345
+ return u.pathname;
1346
+ }
1347
+ catch (_a) {
1348
+ // fallback: just strip file://
1349
+ return fileUrl.replace(/^file:\/\//, '');
1350
+ }
1351
+ }
1352
+ function getAbsolutePath() {
1353
+ if (typeof window !== 'undefined')
1354
+ return '';
1355
+ return fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)));
1356
+ }
1357
+
1358
+ // path_utils.browser.ts
1359
+ function get_dirname(filePath) {
1360
+ if (!filePath)
1361
+ return '';
1362
+ return pathBrowserify.dirname(filePath);
1363
+ }
1364
+ function get_basename(filePath) {
1365
+ if (!filePath)
1366
+ return '';
1367
+ return pathBrowserify.basename(filePath);
1368
+ }
1369
+ function get_filename(file_path) {
1370
+ const ext = pathBrowserify.extname(file_path);
1371
+ return pathBrowserify.basename(file_path, ext);
1372
+ }
1373
+ function get_extname(filePath) {
1374
+ if (!filePath)
1375
+ return '';
1376
+ return pathBrowserify.extname(filePath);
1377
+ }
1378
+ function get_splitext(filePath) {
1379
+ if (!filePath)
1380
+ return { filename: '', extname: '' };
1381
+ const ext = pathBrowserify.extname(filePath);
1382
+ // Get the basename without the extension
1383
+ const filename = pathBrowserify.basename(filePath, ext);
1384
+ return { filename, ext };
1385
+ }
1386
+ /**
1387
+ * Join multiple path segments, normalizing leading/trailing slashes.
1388
+ *
1389
+ * Usage:
1390
+ * make_path('/foo','bar','baz')
1391
+ * make_path(['/foo','bar','baz'])
1392
+ */
1393
+ function make_path(...paths) {
1394
+ // If someone passed a single array, unwrap it:
1395
+ const pathArray = (paths.length === 1 && Array.isArray(paths[0])
1396
+ ? paths[0]
1397
+ : paths);
1398
+ let real_path = '';
1399
+ for (let i = 0; i < pathArray.length; i++) {
1400
+ let segment = pathArray[i];
1401
+ if (i === 0) {
1402
+ real_path = segment;
1403
+ }
1404
+ else {
1405
+ // remove any leading slash on this segment
1406
+ segment = segment.replace(/^\/+/, '');
1407
+ // remove any trailing slash on the accumulator
1408
+ real_path = real_path.replace(/\/+$/, '');
1409
+ real_path = `${real_path}/${segment}`;
1410
+ }
1411
+ }
1412
+ return real_path;
1413
+ }
1414
+ function sanitizeFilename(filename) {
1415
+ return filename
1416
+ .toLowerCase()
1417
+ .replace(/\s+|-/g, '-') // Replace spaces and hyphens with single hyphen
1418
+ .replace(/_/g, '-') // Replace underscores with hyphens
1419
+ .replace(/[^a-z0-9-.]/g, '') // Remove all non-alphanumeric chars except hyphen and dot
1420
+ .replace(/-+/g, '-') // Collapse multiple hyphens into one
1421
+ .replace(/^-|-$/, ''); // Remove leading/trailing hyphens
1422
+ }
1423
+ function make_sanitized_path(...paths) {
1424
+ let real_path = '';
1425
+ for (let i = 0; i < paths.length; i++) {
1426
+ const sanitized = sanitizeFilename(eatInner(paths[i], ['/']));
1427
+ if (i === 0) {
1428
+ real_path = sanitized;
1429
+ }
1430
+ else if (sanitized) { // Only append if there's a non-empty segment
1431
+ real_path = `${real_path}/${sanitized}`;
1432
+ }
1433
+ }
1434
+ return real_path || '';
1435
+ }
1436
+ function normalizeUrl(base, p) {
1437
+ if (!p)
1438
+ return base;
1439
+ const cleanBase = base.replace(/\/+$/, ''); // regex literal
1440
+ const cleanPath = p.replace(/^\/+/, '');
1441
+ // collapse multiple “//” into one, but keep the “://” after protocol
1442
+ return `${cleanBase}/${cleanPath}`.replace(/([^:])\/{2,}/g, '$1/');
1443
+ }
1444
+
1445
+ /**
1446
+ * Returns the absolute path of the current file.
1447
+ */
1448
+ function getAbsDir() {
1449
+ return get_dirname(getAbsolutePath());
1450
+ }
1451
+ function getAbsPath(subPath) {
1452
+ return make_path(getAbsDir(), subPath);
1453
+ }
1454
+
1455
+ function getFunctionsDir() {
1456
+ return get_dirname(getAbsDir());
1457
+ }
1458
+ function geAuthsUtilsDirectory() {
1459
+ return make_path(getFunctionsDir(), 'auths');
1460
+ }
1461
+ function geBackupsUtilsDirectory() {
1462
+ return make_path(getFunctionsDir(), 'backups');
1463
+ }
1464
+ function geConstantsUtilsDirectory() {
1465
+ return make_path(getFunctionsDir(), 'constants');
1466
+ }
1467
+ function geEnvUtilsDirectory() {
1468
+ return make_path(getFunctionsDir(), 'env_utils');
1469
+ }
1470
+ function geFetchUtilsDirectory() {
1471
+ return make_path(getFunctionsDir(), 'fetch_utils');
1472
+ }
1473
+ function geFileUtilsDirectory() {
1474
+ return make_path(getFunctionsDir(), 'file_utils');
1475
+ }
1476
+ function gePathUtilsDirectory() {
1477
+ return make_path(getFunctionsDir(), 'path_utils');
1478
+ }
1479
+ function geStringUtilsDirectory() {
1480
+ return make_path(getFunctionsDir(), 'string_utils');
1481
+ }
1482
+ function geTypeUtilsDirectory() {
1483
+ return make_path(getFunctionsDir(), 'type_utils');
1484
+ }
1485
+
1486
+ function getSrcDir() {
1487
+ return get_dirname(getFunctionsDir());
1488
+ }
1489
+ function geStaticDirectory() {
1490
+ return make_path(getSrcDir(), 'static');
1491
+ }
1492
+ function getLibUtilsDirectory() {
1493
+ return make_path(getSrcDir(), 'lib');
1494
+ }
1495
+ function getHooksUtilsDirectory() {
1496
+ return make_path(getSrcDir(), 'hooks');
1497
+ }
1498
+ function getFunctionsUtilsDirectory() {
1499
+ return make_path(getSrcDir(), 'functions');
1500
+ }
1501
+ function getComponentsUtilsDirectory() {
1502
+ return make_path(getSrcDir(), 'components');
1503
+ }
1504
+
1505
+ function getBaseDir() {
1506
+ return get_dirname(getSrcDir());
1507
+ }
1508
+ function getPublicDir() {
1509
+ return make_path(getBaseDir(), 'public');
1510
+ }
1511
+ function getDistDir() {
1512
+ return make_path(getBaseDir(), 'dist');
1513
+ }
1514
+ function getEnvDir() {
1515
+ return make_path(getBaseDir(), '.env');
1516
+ }
1517
+
1518
+ function getEnvPath(string = '.env') {
1519
+ return make_path(getEnvDir(), string);
1520
+ }
1521
+ function getDbConfigsPath() {
1522
+ return make_path(getBaseDir(), 'dbConfigs');
1523
+ }
1524
+ function getSchemasPath() {
1525
+ return make_path(getDbConfigsPath(), 'schemas');
1526
+ }
1527
+ function getSchemasDirPath(subPath) {
1528
+ return make_path(getSchemasPath(), subPath);
1529
+ }
1530
+
1531
+ // src/functions/rndm_utils/utils.ts
1532
+ function alertit(obj = null) {
1533
+ let msg;
1534
+ try {
1535
+ msg = JSON.stringify(obj);
1536
+ }
1537
+ catch (_a) {
1538
+ // If JSON.stringify fails (circular refs, etc.), fall back to a simple string
1539
+ msg = String(obj);
1540
+ }
1541
+ alert(msg);
1542
+ }
1543
+
1544
+ function Button(_a) {
1545
+ var { children, color = 'gray', variant = 'default', className = '' } = _a, rest = __rest(_a, ["children", "color", "variant", "className"]);
1546
+ const base = 'rounded px-3 py-1 text-sm font-medium focus:outline-none focus:ring-2 focus:ring-offset-2 transition-colors duration-150';
1547
+ const variantStyles = {
1548
+ default: '',
1549
+ icon: 'p-1 bg-transparent hover:bg-gray-100',
1550
+ primary: 'text-white',
1551
+ secondary: '',
1552
+ };
1553
+ const palette = {
1554
+ gray: variant === 'primary'
1555
+ ? 'bg-gray-600 hover:bg-gray-700 focus:ring-gray-500'
1556
+ : 'bg-gray-200 hover:bg-gray-300 focus:ring-gray-400',
1557
+ green: 'bg-green-600 text-white hover:bg-green-700 focus:ring-green-500',
1558
+ blue: variant === 'primary'
1559
+ ? 'bg-blue-600 hover:bg-blue-700 focus:ring-blue-500'
1560
+ : 'bg-blue-200 hover:bg-blue-300 focus:ring-blue-400',
1561
+ };
1562
+ return (jsxRuntime.jsx("button", Object.assign({ className: `${base} ${variantStyles[variant]} ${palette[color]} ${className}` }, rest, { children: children })));
1563
+ }
1564
+
1565
+ function Checkbox(_a) {
1566
+ var { label } = _a, rest = __rest(_a, ["label"]);
1567
+ return (jsxRuntime.jsxs("label", { className: 'flex items-center gap-2 mb-4', children: [jsxRuntime.jsx("input", Object.assign({ type: 'checkbox' }, rest)), jsxRuntime.jsx("span", { children: label })] }));
1568
+ }
1569
+
1570
+ function Input(_a) {
1571
+ var { label, trailing } = _a, rest = __rest(_a, ["label", "trailing"]);
1572
+ return (jsxRuntime.jsxs("label", { className: 'mb-4 block', children: [jsxRuntime.jsx("span", { className: 'block text-sm font-medium mb-1', children: label }), jsxRuntime.jsxs("div", { className: 'flex gap-2', children: [jsxRuntime.jsx("input", Object.assign({ className: 'flex-1 rounded border px-2 py-1 disabled:bg-gray-100' }, rest)), trailing] })] }));
1573
+ }
1574
+
1575
+ function Spinner() {
1576
+ return (jsxRuntime.jsx("p", { className: 'animate-pulse', children: "Loading\u2026" }));
1577
+ }
1578
+
1579
+ // src/functions/config_utils/src/config_utils.ts
1580
+ /**
1581
+ * Attempt to load config.json if present, otherwise return empty object.
1582
+ */
1583
+ function getConfigJson() {
1584
+ return __awaiter(this, void 0, void 0, function* () {
1585
+ try {
1586
+ return (yield readJsonFile('config.json')) || {};
1587
+ }
1588
+ catch (_a) {
1589
+ return {};
1590
+ }
1591
+ });
1592
+ }
1593
+
1594
+ /**
1595
+ * Processes keywords by checking if keywords is a string and splitting it.
1596
+ * Then cleans each keyword using `eatAll` with a set of characters to remove.
1597
+ *
1598
+ * @param keywords - The keywords as a comma-separated string or as an array.
1599
+ * @returns An array of cleaned keywords.
1600
+ */
1601
+ function processKeywords(keywords) {
1602
+ let keywordArray;
1603
+ // If keywords is a string, split it on commas
1604
+ if (typeof keywords === "string") {
1605
+ keywordArray = keywords.split(",");
1606
+ }
1607
+ else {
1608
+ keywordArray = keywords;
1609
+ }
1610
+ // Clean each keyword by removing unwanted characters
1611
+ return keywordArray.map(keyword => eatAll(keyword, [",", "\n", "\t", " ", "#"]));
1612
+ }
1613
+ /**
1614
+ * Constructs a keyword string where each keyword is prefixed with a hash (#).
1615
+ *
1616
+ * @param keywords - An array of keywords.
1617
+ * @returns A string with each keyword prefixed by '#'.
1618
+ */
1619
+ function get_keyword_string(keywords) {
1620
+ keywords = processKeywords(keywords);
1621
+ let allString = "";
1622
+ for (const keyword of keywords) {
1623
+ allString += ` #${keyword}`;
1624
+ }
1625
+ return allString;
1626
+ }
1627
+
1628
+ Object.defineProperty(exports, "useCallback", {
1629
+ enumerable: true,
1630
+ get: function () { return react.useCallback; }
1631
+ });
1632
+ Object.defineProperty(exports, "useEffect", {
1633
+ enumerable: true,
1634
+ get: function () { return react.useEffect; }
1635
+ });
1636
+ Object.defineProperty(exports, "useRef", {
1637
+ enumerable: true,
1638
+ get: function () { return react.useRef; }
1639
+ });
1640
+ Object.defineProperty(exports, "useState", {
1641
+ enumerable: true,
1642
+ get: function () { return react.useState; }
1643
+ });
1644
+ exports.API_PREFIX = API_PREFIX;
1645
+ exports.BASE_URL = BASE_URL;
1646
+ exports.Button = Button;
1647
+ exports.Checkbox = Checkbox;
1648
+ exports.DEV_PREFIX = DEV_PREFIX;
1649
+ exports.DOMAIN_NAME = DOMAIN_NAME;
1650
+ exports.Input = Input;
1651
+ exports.PROD_PREFIX = PROD_PREFIX;
1652
+ exports.PROTOCOL = PROTOCOL;
1653
+ exports.SUB_DIR = SUB_DIR;
1654
+ exports.Spinner = Spinner;
1655
+ exports.alertit = alertit;
1656
+ exports.assureArray = assureArray;
1657
+ exports.assureString = assureString;
1658
+ exports.callStorage = callStorage;
1659
+ exports.callWindowMethod = callWindowMethod;
1660
+ exports.capitalize = capitalize;
1661
+ exports.capitalize_str = capitalize_str;
1662
+ exports.checkResponse = checkResponse;
1663
+ exports.cleanArray = cleanArray;
1664
+ exports.cleanText = cleanText;
1665
+ exports.create_list_string = create_list_string;
1666
+ exports.currentUsername = currentUsername;
1667
+ exports.currentUsernames = currentUsernames;
1668
+ exports.decodeJwt = decodeJwt;
1669
+ exports.eatAll = eatAll;
1670
+ exports.eatEnd = eatEnd;
1671
+ exports.eatInner = eatInner;
1672
+ exports.eatOuter = eatOuter;
1673
+ exports.ensure_list = ensure_list;
1674
+ exports.ensure_number = ensure_number;
1675
+ exports.fetchIndexHtml = fetchIndexHtml;
1676
+ exports.fetchIndexHtmlContainer = fetchIndexHtmlContainer;
1677
+ exports.fetchIt = fetchIt;
1678
+ exports.geAuthsUtilsDirectory = geAuthsUtilsDirectory;
1679
+ exports.geBackupsUtilsDirectory = geBackupsUtilsDirectory;
1680
+ exports.geConstantsUtilsDirectory = geConstantsUtilsDirectory;
1681
+ exports.geEnvUtilsDirectory = geEnvUtilsDirectory;
1682
+ exports.geFetchUtilsDirectory = geFetchUtilsDirectory;
1683
+ exports.geFileUtilsDirectory = geFileUtilsDirectory;
1684
+ exports.gePathUtilsDirectory = gePathUtilsDirectory;
1685
+ exports.geStaticDirectory = geStaticDirectory;
1686
+ exports.geStringUtilsDirectory = geStringUtilsDirectory;
1687
+ exports.geTypeUtilsDirectory = geTypeUtilsDirectory;
1688
+ exports.get = get;
1689
+ exports.getAbsDir = getAbsDir;
1690
+ exports.getAbsPath = getAbsPath;
1691
+ exports.getAlphaNum = getAlphaNum;
1692
+ exports.getAlphas = getAlphas;
1693
+ exports.getAuthorizationHeader = getAuthorizationHeader;
1694
+ exports.getBaseDir = getBaseDir;
1695
+ exports.getBody = getBody;
1696
+ exports.getChar = getChar;
1697
+ exports.getCleanArray = getCleanArray;
1698
+ exports.getComponentsUtilsDirectory = getComponentsUtilsDirectory;
1699
+ exports.getConfigContent = getConfigContent;
1700
+ exports.getConfigJson = getConfigJson;
1701
+ exports.getConfigVar = getConfigVar;
1702
+ exports.getDbConfigsPath = getDbConfigsPath;
1703
+ exports.getDistDir = getDistDir;
1704
+ exports.getDocumentProp = getDocumentProp;
1705
+ exports.getEnvDir = getEnvDir;
1706
+ exports.getEnvPath = getEnvPath;
1707
+ exports.getFetchVars = getFetchVars;
1708
+ exports.getFunctionsDir = getFunctionsDir;
1709
+ exports.getFunctionsUtilsDirectory = getFunctionsUtilsDirectory;
1710
+ exports.getHeaders = getHeaders;
1711
+ exports.getHooksUtilsDirectory = getHooksUtilsDirectory;
1712
+ exports.getHtmlDirectory = getHtmlDirectory;
1713
+ exports.getLibUtilsDirectory = getLibUtilsDirectory;
1714
+ exports.getMethod = getMethod;
1715
+ exports.getNums = getNums;
1716
+ exports.getPublicDir = getPublicDir;
1717
+ exports.getResult = getResult;
1718
+ exports.getSafeDocument = getSafeDocument;
1719
+ exports.getSafeLocalStorage = getSafeLocalStorage;
1720
+ exports.getSafeWindow = getSafeWindow;
1721
+ exports.getSchemasDirPath = getSchemasDirPath;
1722
+ exports.getSchemasPath = getSchemasPath;
1723
+ exports.getSrcDir = getSrcDir;
1724
+ exports.getSubstring = getSubstring;
1725
+ exports.getToken = getToken;
1726
+ exports.getWindowHost = getWindowHost;
1727
+ exports.getWindowProp = getWindowProp;
1728
+ exports.get_basename = get_basename;
1729
+ exports.get_dirname = get_dirname;
1730
+ exports.get_extname = get_extname;
1731
+ exports.get_filename = get_filename;
1732
+ exports.get_key_value = get_key_value;
1733
+ exports.get_keyword_string = get_keyword_string;
1734
+ exports.get_splitext = get_splitext;
1735
+ exports.get_window = get_window;
1736
+ exports.get_window_location = get_window_location;
1737
+ exports.get_window_parts = get_window_parts;
1738
+ exports.get_window_pathname = get_window_pathname;
1739
+ exports.isLoggedIn = isLoggedIn;
1740
+ exports.isNum = isNum;
1741
+ exports.isStrInString = isStrInString;
1742
+ exports.isTokenExpired = isTokenExpired;
1743
+ exports.isType = isType;
1744
+ exports.make_path = make_path;
1745
+ exports.make_sanitized_path = make_sanitized_path;
1746
+ exports.normalizeUrl = normalizeUrl;
1747
+ exports.parseResult = parseResult;
1748
+ exports.processKeywords = processKeywords;
1749
+ exports.readJsonFile = readJsonFile;
1750
+ exports.removeToken = removeToken;
1751
+ exports.requireToken = requireToken;
1752
+ exports.safeGlobalProp = safeGlobalProp;
1753
+ exports.safeStorage = safeStorage;
1754
+ exports.sanitizeFilename = sanitizeFilename;
1755
+ exports.stripPrefixes = stripPrefixes;
1756
+ exports.truncateString = truncateString;
1757
+ exports.tryParse = tryParse;
1758
+ //# sourceMappingURL=index.js.map