@nocios/crudify-ui 4.1.21 → 4.1.22

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.d.mts CHANGED
@@ -5,7 +5,7 @@ export { A as ApiError, C as CrudifyApiResponse, a as CrudifyTransactionResponse
5
5
  import { U as UseSessionOptions, T as TokenData, L as LoginResult } from './index-BwF68SOh.mjs';
6
6
  export { a as SessionConfig, S as SessionManager, d as SessionState, c as StorageType, b as TokenStorage, j as UseAuthReturn, l as UseDataReturn, g as UseUserDataOptions, f as UseUserDataReturn, h as UserData, i as useAuth, n as useCrudifyWithNotifications, k as useData, u as useSession, e as useUserData, m as useUserProfile } from './index-BwF68SOh.mjs';
7
7
  import * as react_jsx_runtime from 'react/jsx-runtime';
8
- import { ReactNode } from 'react';
8
+ import React, { ReactNode } from 'react';
9
9
  import { ThemeOptions } from '@mui/material';
10
10
  export { E as ERROR_CODES, j as ERROR_SEVERITY_MAP, n as ErrorCode, o as ErrorSeverity, q as ErrorTranslationConfig, P as ParsedError, m as createErrorTranslator, d as decodeJwtSafely, a as getCookie, g as getCurrentUserEmail, f as getErrorMessage, h as handleCrudifyError, i as isTokenExpired, p as parseApiError, e as parseJavaScriptError, c as parseTransactionError, b as secureLocalStorage, s as secureSessionStorage, l as translateError, t as translateErrorCode, k as translateErrorCodes } from './errorTranslation-DEn4aqs6.mjs';
11
11
  export { G as GlobalNotificationProvider, a as GlobalNotificationProviderProps, N as Notification, b as NotificationSeverity, u as useGlobalNotification } from './GlobalNotificationProvider-C3iWgM1z.mjs';
@@ -219,4 +219,406 @@ declare const validateInternalRedirect: (path: string, defaultPath?: string) =>
219
219
  */
220
220
  declare const extractSafeRedirectFromUrl: (searchParams: URLSearchParams | string, defaultPath?: string) => string;
221
221
 
222
- export { AuthRoute, type AuthRouteProps, CrudifyThemeProvider, type CrudifyThemeProviderProps, LoginResult, type NotificationOptions, ProtectedRoute, type ProtectedRouteProps, SessionDebugInfo, SessionLoadingScreen, type SessionLoadingScreenProps, SessionProvider, type SessionProviderProps, TokenData, UseSessionOptions, extractSafeRedirectFromUrl, useSessionContext, validateInternalRedirect };
222
+ interface TranslationsProviderProps {
223
+ children: React.ReactNode;
224
+ subscriberKey: string;
225
+ apiKey: string;
226
+ crudifyEnv?: "dev" | "stg" | "api" | "prod";
227
+ sections?: string[];
228
+ language?: string;
229
+ devTranslations?: Record<string, string>;
230
+ translationUrl?: string;
231
+ enableDebug?: boolean;
232
+ }
233
+ interface TranslationsContextValue {
234
+ t: (key: string, variables?: Record<string, any>) => string;
235
+ language: string;
236
+ availableLanguages: string[];
237
+ isLoading: boolean;
238
+ error: string | null;
239
+ refreshTranslations: () => Promise<void>;
240
+ }
241
+ /**
242
+ * TranslationsProvider
243
+ *
244
+ * Provides translation functionality to the application
245
+ * Handles fetching, caching, and fallback strategies
246
+ *
247
+ * @example
248
+ * ```tsx
249
+ * <TranslationsProvider
250
+ * subscriberKey="mycompany"
251
+ * apiKey="xxx"
252
+ * language="es"
253
+ * translationUrl="https://example.com/locales/es/translation.json"
254
+ * >
255
+ * <App />
256
+ * </TranslationsProvider>
257
+ * ```
258
+ */
259
+ declare const TranslationsProvider: React.FC<TranslationsProviderProps>;
260
+ /**
261
+ * Hook to use translations
262
+ *
263
+ * @example
264
+ * ```tsx
265
+ * const MyComponent = () => {
266
+ * const { t } = useTranslations();
267
+ * return <h1>{t('welcome.title')}</h1>;
268
+ * };
269
+ * ```
270
+ */
271
+ declare const useTranslations: () => TranslationsContextValue;
272
+
273
+ interface FetchTranslationsOptions {
274
+ subscriberKey: string;
275
+ apiKey: string;
276
+ crudifyEnv?: "dev" | "stg" | "api" | "prod";
277
+ sections?: string[];
278
+ urlTranslations?: Record<string, string>;
279
+ }
280
+ interface TranslationResponse {
281
+ subscriberKey: string;
282
+ languages: string[];
283
+ translations: Record<string, Record<string, string>>;
284
+ timestamp: string;
285
+ }
286
+ /**
287
+ * Translation Service
288
+ * Handles fetching, caching, and fallback strategies for translations
289
+ * Uses Crudify SDK for API calls
290
+ *
291
+ * Priority order (lowest to highest):
292
+ * 1. Critical bundle (fallback)
293
+ * 2. API translations (system + subscriber merged by backend)
294
+ * 3. URL translations (buildTranslations from config.json or translationUrl)
295
+ * 4. Dev translations (props override - handled by provider)
296
+ */
297
+ declare class TranslationService {
298
+ private static instance;
299
+ private isInitialized;
300
+ private constructor();
301
+ static getInstance(): TranslationService;
302
+ /**
303
+ * Initialize crudify SDK
304
+ */
305
+ private ensureInitialized;
306
+ /**
307
+ * Fetch translations with cache strategy
308
+ * 1. Try cache (if valid and not changed)
309
+ * 2. Try API fetch via crudify SDK
310
+ * 3. Try expired cache
311
+ * 4. Fall back to critical bundle
312
+ */
313
+ fetchTranslations(options: FetchTranslationsOptions): Promise<Record<string, Record<string, string>>>;
314
+ /**
315
+ * Fetch from API via crudify SDK
316
+ */
317
+ private fetchFromAPI;
318
+ /**
319
+ * Merge API translations with URL translations
320
+ * URL translations have higher priority
321
+ */
322
+ private mergeWithUrlTranslations;
323
+ /**
324
+ * Check if data has changed (compare timestamps or hash)
325
+ */
326
+ private hasDataChanged;
327
+ /**
328
+ * Simple hash function for data comparison
329
+ */
330
+ private hashData;
331
+ /**
332
+ * Save to localStorage
333
+ */
334
+ private saveToCache;
335
+ /**
336
+ * Read from localStorage
337
+ */
338
+ private getFromCache;
339
+ /**
340
+ * Refresh cache timestamp without changing data
341
+ */
342
+ private refreshCacheTimestamp;
343
+ /**
344
+ * Check if cache is expired
345
+ */
346
+ private isCacheExpired;
347
+ /**
348
+ * Generate cache key
349
+ */
350
+ private getCacheKey;
351
+ /**
352
+ * Get only critical translations from bundle
353
+ */
354
+ private getCriticalTranslationsOnly;
355
+ /**
356
+ * Invalidate cache (useful for testing/debugging)
357
+ */
358
+ invalidateCache(subscriberKey: string): void;
359
+ /**
360
+ * Prefetch translations in background
361
+ */
362
+ prefetchTranslations(options: FetchTranslationsOptions): Promise<void>;
363
+ /**
364
+ * Clear all translation caches
365
+ */
366
+ clearAllCaches(): void;
367
+ /**
368
+ * Shutdown crudify SDK
369
+ */
370
+ shutdown(): Promise<void>;
371
+ }
372
+ declare const translationService: TranslationService;
373
+
374
+ /**
375
+ * Critical translations bundle
376
+ * These translations are bundled with the application to ensure
377
+ * basic functionality (login, errors, loading) works even if the API is unavailable
378
+ *
379
+ * Total keys: 108
380
+ * - login.*: 15 keys
381
+ * - forgotPassword.*: 11 keys
382
+ * - checkCode.*: 11 keys
383
+ * - resetPassword.*: 19 keys
384
+ * - errors.*: 39 keys
385
+ * - loading.*: 5 keys
386
+ * - common (basic): 2 keys
387
+ * - footer.*: 2 keys
388
+ * - error.app.*: 4 keys
389
+ */
390
+ declare const CRITICAL_TRANSLATIONS: {
391
+ readonly es: {
392
+ readonly "checkCode.codeLabel": "Código de Verificación";
393
+ readonly "checkCode.codePlaceholder": "Ingresa el código de 6 dígitos";
394
+ readonly "checkCode.codeRequired": "El código es obligatorio";
395
+ readonly "checkCode.emailLabel": "Correo Electrónico";
396
+ readonly "checkCode.emailPlaceholder": "Ingresa tu correo electrónico";
397
+ readonly "checkCode.emailRequired": "El correo electrónico es obligatorio";
398
+ readonly "checkCode.instructions": "Ingresa el código de 6 dígitos que enviamos a tu correo electrónico.";
399
+ readonly "checkCode.invalidEmail": "Ingresa un correo electrónico válido";
400
+ readonly "checkCode.resendCodeLink": "Reenviar código";
401
+ readonly "checkCode.title": "Verificar Código";
402
+ readonly "checkCode.verifyButton": "Verificar Código";
403
+ readonly "common.back": "Volver";
404
+ readonly "common.backToLogin": "Volver";
405
+ readonly "error.app.config": "Error de Configuración: {{message}}";
406
+ readonly "error.app.initialization": "Error durante la inicialización final de la aplicación.";
407
+ readonly "error.transaction": "Error en la operación";
408
+ readonly "error.unknown": "Ocurrió un error desconocido.";
409
+ readonly "errors.DUPLICATE": "El campo <b>{{field}}</b> debe ser único.";
410
+ readonly "errors.FOREIGN_KEY_NOT_FOUND": "El campo <b>{{field}}</b> debe referenciar un ítem existente.";
411
+ readonly "errors.INVALID_EMAIL": "El campo <b>{{field}}</b> debe ser un correo electrónico válido.";
412
+ readonly "errors.INVALID_OBJECT_ID": "El campo <b>{{field}}</b> debe ser un valor válido.";
413
+ readonly "errors.IN_USE": "El ítem está en uso y no puede ser eliminado.";
414
+ readonly "errors.MAX_LENGTH": "El campo <b>{{field}}</b> no debe exceder los <b>{{length}}</b> caracteres.";
415
+ readonly "errors.MIN_LENGTH": "El campo <b>{{field}}</b> debe tener al menos <b>{{length}}</b> caracteres.";
416
+ readonly "errors.MUST_NOT_BE_EMAIL": "El campo <b>{{field}}</b> no debe ser un correo electrónico.";
417
+ readonly "errors.NO_PERMISSION": "No tienes permiso para realizar esta acción.";
418
+ readonly "errors.NO_SPACES": "El campo <b>{{field}}</b> no debe contener espacios.";
419
+ readonly "errors.ONE_OR_MORE_OPERATIONS_FAILED": "Error en la operación";
420
+ readonly "errors.REQUIRED": "El campo <b>{{field}}</b> es obligatorio.";
421
+ readonly "errors.TOKEN_HAS_EXPIRED": "La sesión ha expirado. Por favor, inicia sesión nuevamente.";
422
+ readonly "errors.TOO_MANY_REQUESTS": "Límite de solicitudes alcanzado. Por favor intenta más tarde.";
423
+ readonly "errors.UNAUTHORIZED": "No estás autorizado para realizar esta acción.";
424
+ readonly "errors.all_password_fields_required": "Todos los campos de contraseña son obligatorios";
425
+ readonly "errors.auth.INVALID_API_KEY": "Clave de API inválida";
426
+ readonly "errors.auth.INVALID_CREDENTIALS": "Usuario y/o contraseña incorrectos";
427
+ readonly "errors.auth.NO_PERMISSION": "No tienes permisos suficientes";
428
+ readonly "errors.auth.SESSION_EXPIRED": "Tu sesión ha expirado. Por favor, inicia sesión nuevamente.";
429
+ readonly "errors.auth.TOO_MANY_REQUESTS": "Demasiados intentos. Por favor espera 15 minutos e intenta nuevamente";
430
+ readonly "errors.auth.UNAUTHORIZED": "No tienes permisos para realizar esta acción";
431
+ readonly "errors.auth.USER_NOT_ACTIVE": "Usuario no activo";
432
+ readonly "errors.auth.USER_NOT_FOUND": "Usuario no encontrado";
433
+ readonly "errors.data.BAD_REQUEST": "Solicitud inválida";
434
+ readonly "errors.data.FIELD_ERROR": "Error en los datos ingresados";
435
+ readonly "errors.data.IN_USE": "El elemento está en uso y no puede ser eliminado";
436
+ readonly "errors.data.ITEM_NOT_FOUND": "El elemento solicitado no fue encontrado";
437
+ readonly "errors.data.NOT_FOUND": "No se encontró lo solicitado";
438
+ readonly "errors.internal_error_changing_password": "Error interno al cambiar la contraseña. Intenta nuevamente";
439
+ readonly "errors.password_min_length": "La contraseña debe tener al menos 8 caracteres";
440
+ readonly "errors.password_mismatch": "Las contraseñas no coinciden";
441
+ readonly "errors.password_must_be_different": "La nueva contraseña debe ser diferente a la actual";
442
+ readonly "errors.system.DATABASE_CONNECTION_ERROR": "Error de conexión. Verifica tu conexión a internet.";
443
+ readonly "errors.system.INTERNAL_SERVER_ERROR": "Error interno del servidor. Intenta nuevamente.";
444
+ readonly "errors.system.INVALID_CONFIGURATION": "Error de configuración del sistema";
445
+ readonly "errors.system.TOO_MANY_REQUESTS": "Demasiadas solicitudes. Por favor espera un momento e intenta nuevamente";
446
+ readonly "errors.system.UNKNOWN_OPERATION": "Operación no reconocida";
447
+ readonly "errors.users_module_not_configured": "Módulo de usuarios no configurado";
448
+ readonly "footer.copyright": "Nocios S.R.L. Todos los derechos reservados.";
449
+ readonly "footer.version": "Versión";
450
+ readonly "forgotPassword.checkEmailInstructions": "Revisa tu bandeja de entrada para el código de verificación";
451
+ readonly "forgotPassword.codeAlreadyExistsMessage": "Ya se envió un código y aún es válido";
452
+ readonly "forgotPassword.emailLabel": "Correo Electrónico";
453
+ readonly "forgotPassword.emailPlaceholder": "Ingresa tu correo electrónico";
454
+ readonly "forgotPassword.emailRequired": "El correo electrónico es obligatorio";
455
+ readonly "forgotPassword.emailSentMessage": "Código enviado exitosamente";
456
+ readonly "forgotPassword.enterCodeLink": "Ingresar Código";
457
+ readonly "forgotPassword.instructions": "Ingresa tu correo electrónico y te enviaremos un código para restablecer tu contraseña.";
458
+ readonly "forgotPassword.invalidEmail": "Ingresa un correo electrónico válido";
459
+ readonly "forgotPassword.sendCodeButton": "Enviar Código";
460
+ readonly "forgotPassword.title": "Recuperar Contraseña";
461
+ readonly "loading.app.configInitial": "Cargando configuración inicial...";
462
+ readonly "loading.app.generic": "Cargando...";
463
+ readonly "loading.app.starting": "Iniciando aplicación...";
464
+ readonly "loading.app.themeSetup": "Generando tema...";
465
+ readonly "loading.app.validatingSession": "Validando sesión...";
466
+ readonly "login.alreadyHaveCodeLink": "¿Ya tienes un código?";
467
+ readonly "login.forgotPasswordLink": "¿Olvidaste tu contraseña?";
468
+ readonly "login.initializationError": "Error de inicialización";
469
+ readonly "login.initializing": "Inicializando...";
470
+ readonly "login.loginButton": "Iniciar Sesión";
471
+ readonly "login.logoAlt": "Logotipo";
472
+ readonly "login.noAccountPrompt": "¿No tienes una cuenta?";
473
+ readonly "login.notInitialized": "Sistema no inicializado";
474
+ readonly "login.passwordLabel": "Contraseña";
475
+ readonly "login.passwordPlaceholder": "Ingresa tu contraseña";
476
+ readonly "login.passwordRequired": "Contraseña es obligatoria";
477
+ readonly "login.signUpLink": "Regístrate";
478
+ readonly "login.usernameOrEmailLabel": "Usuario o Correo Electrónico";
479
+ readonly "login.usernameOrEmailPlaceholder": "Ingresa tu usuario o correo electrónico";
480
+ readonly "login.usernameRequired": "Usuario o correo electrónico es obligatorio";
481
+ readonly "resetPassword.codeExpiredOrInvalid": "El código ha expirado o es inválido";
482
+ readonly "resetPassword.confirmPasswordLabel": "Confirmar Contraseña";
483
+ readonly "resetPassword.confirmPasswordPlaceholder": "Confirma tu nueva contraseña";
484
+ readonly "resetPassword.confirmPasswordRequired": "Confirma tu contraseña";
485
+ readonly "resetPassword.goToLoginButton": "Ir al Login";
486
+ readonly "resetPassword.instructions": "Ingresa tu nueva contraseña.";
487
+ readonly "resetPassword.invalidCode": "El código de verificación es inválido. Por favor, verifica el enlace o solicita uno nuevo.";
488
+ readonly "resetPassword.missingParameters": "Faltan parámetros obligatorios";
489
+ readonly "resetPassword.newPasswordLabel": "Nueva Contraseña";
490
+ readonly "resetPassword.newPasswordPlaceholder": "Ingresa tu nueva contraseña";
491
+ readonly "resetPassword.newPasswordRequired": "La nueva contraseña es obligatoria";
492
+ readonly "resetPassword.passwordTooShort": "La contraseña debe tener al menos 8 caracteres";
493
+ readonly "resetPassword.passwordsDoNotMatch": "Las contraseñas no coinciden";
494
+ readonly "resetPassword.requestNewCodeButton": "Solicitar Nuevo Código";
495
+ readonly "resetPassword.resetPasswordButton": "Restablecer Contraseña";
496
+ readonly "resetPassword.successInstructions": "Ahora puedes iniciar sesión con tu nueva contraseña";
497
+ readonly "resetPassword.successMessage": "Contraseña restablecida exitosamente";
498
+ readonly "resetPassword.title": "Nueva Contraseña";
499
+ readonly "resetPassword.validatingCode": "Validando código...";
500
+ };
501
+ readonly en: {
502
+ readonly "checkCode.codeLabel": "Verification Code";
503
+ readonly "checkCode.codePlaceholder": "Enter 6-digit code";
504
+ readonly "checkCode.codeRequired": "Code is required";
505
+ readonly "checkCode.emailLabel": "Email Address";
506
+ readonly "checkCode.emailPlaceholder": "Enter your email address";
507
+ readonly "checkCode.emailRequired": "Email address is required";
508
+ readonly "checkCode.instructions": "Enter the 6-digit code we sent to your email address.";
509
+ readonly "checkCode.invalidEmail": "Enter a valid email address";
510
+ readonly "checkCode.resendCodeLink": "Resend code";
511
+ readonly "checkCode.title": "Verify Code";
512
+ readonly "checkCode.verifyButton": "Verify Code";
513
+ readonly "common.back": "Back";
514
+ readonly "common.backToLogin": "Back to Login";
515
+ readonly "error.app.config": "Configuration Error: {{message}}";
516
+ readonly "error.app.initialization": "Error during final application initialization.";
517
+ readonly "error.transaction": "Operation error";
518
+ readonly "error.unknown": "An unknown error occurred.";
519
+ readonly "errors.DUPLICATE": "The field <b>{{field}}</b> must be unique.";
520
+ readonly "errors.FOREIGN_KEY_NOT_FOUND": "The field <b>{{field}}</b> must reference an existing item.";
521
+ readonly "errors.INVALID_EMAIL": "The field <b>{{field}}</b> must be a valid email address.";
522
+ readonly "errors.INVALID_OBJECT_ID": "The field <b>{{field}}</b> must be a valid value.";
523
+ readonly "errors.IN_USE": "The item is currently in use and cannot be deleted.";
524
+ readonly "errors.MAX_LENGTH": "The field <b>{{field}}</b> must not exceed <b>{{maxLength}}</b> characters.";
525
+ readonly "errors.MIN_LENGTH": "The field <b>{{field}}</b> must have at least <b>{{minLength}}</b> characters.";
526
+ readonly "errors.MUST_NOT_BE_EMAIL": "The field <b>{{field}}</b> must not be an email address.";
527
+ readonly "errors.NO_PERMISSION": "You do not have permission to perform this action.";
528
+ readonly "errors.NO_SPACES": "The field <b>{{field}}</b> must not contain spaces.";
529
+ readonly "errors.ONE_OR_MORE_OPERATIONS_FAILED": "Operation error";
530
+ readonly "errors.REQUIRED": "The field <b>{{field}}</b> is required.";
531
+ readonly "errors.TOKEN_HAS_EXPIRED": "Your session has expired, please log in again.";
532
+ readonly "errors.TOO_MANY_REQUESTS": "Request limit reached. Please try again later.";
533
+ readonly "errors.UNAUTHORIZED": "You are not authorized to perform this action.";
534
+ readonly "errors.all_password_fields_required": "All password fields are required";
535
+ readonly "errors.auth.INVALID_API_KEY": "Invalid API key";
536
+ readonly "errors.auth.INVALID_CREDENTIALS": "Incorrect username and/or password";
537
+ readonly "errors.auth.NO_PERMISSION": "Insufficient permissions";
538
+ readonly "errors.auth.SESSION_EXPIRED": "Your session has expired. Please log in again.";
539
+ readonly "errors.auth.TOO_MANY_REQUESTS": "Too many attempts. Please wait 15 minutes and try again";
540
+ readonly "errors.auth.UNAUTHORIZED": "You don't have permission to perform this action";
541
+ readonly "errors.auth.USER_NOT_ACTIVE": "User account is not active";
542
+ readonly "errors.auth.USER_NOT_FOUND": "User not found";
543
+ readonly "errors.data.BAD_REQUEST": "Invalid request";
544
+ readonly "errors.data.FIELD_ERROR": "Error in the provided data";
545
+ readonly "errors.data.IN_USE": "The item is in use and cannot be deleted";
546
+ readonly "errors.data.ITEM_NOT_FOUND": "The requested item was not found";
547
+ readonly "errors.data.NOT_FOUND": "The requested resource was not found";
548
+ readonly "errors.internal_error_changing_password": "Internal error changing password. Please try again";
549
+ readonly "errors.password_min_length": "Password must be at least 8 characters";
550
+ readonly "errors.password_mismatch": "Passwords do not match";
551
+ readonly "errors.password_must_be_different": "New password must be different from current password";
552
+ readonly "errors.system.DATABASE_CONNECTION_ERROR": "Connection error. Please check your internet connection.";
553
+ readonly "errors.system.INTERNAL_SERVER_ERROR": "Internal server error. Please try again.";
554
+ readonly "errors.system.INVALID_CONFIGURATION": "System configuration error";
555
+ readonly "errors.system.TOO_MANY_REQUESTS": "Too many requests. Please wait a moment and try again";
556
+ readonly "errors.system.UNKNOWN_OPERATION": "Unrecognized operation";
557
+ readonly "errors.users_module_not_configured": "Users module not configured";
558
+ readonly "footer.copyright": "Nocios S.R.L. All Rights Reserved.";
559
+ readonly "footer.version": "Version";
560
+ readonly "forgotPassword.checkEmailInstructions": "Check your inbox for the verification code";
561
+ readonly "forgotPassword.codeAlreadyExistsMessage": "A code was already sent and is still valid";
562
+ readonly "forgotPassword.emailLabel": "Email Address";
563
+ readonly "forgotPassword.emailPlaceholder": "Enter your email address";
564
+ readonly "forgotPassword.emailRequired": "Email address is required";
565
+ readonly "forgotPassword.emailSentMessage": "Code sent successfully";
566
+ readonly "forgotPassword.enterCodeLink": "Enter Code";
567
+ readonly "forgotPassword.instructions": "Enter your email address and we'll send you a code to reset your password.";
568
+ readonly "forgotPassword.invalidEmail": "Enter a valid email address";
569
+ readonly "forgotPassword.sendCodeButton": "Send Code";
570
+ readonly "forgotPassword.title": "Reset Password";
571
+ readonly "loading.app.configInitial": "Loading initial configuration...";
572
+ readonly "loading.app.generic": "Loading...";
573
+ readonly "loading.app.starting": "Starting application...";
574
+ readonly "loading.app.themeSetup": "Generating theme...";
575
+ readonly "loading.app.validatingSession": "Validating session...";
576
+ readonly "login.alreadyHaveCodeLink": "Already have a code?";
577
+ readonly "login.forgotPasswordLink": "Forgot Password?";
578
+ readonly "login.initializationError": "Initialization error";
579
+ readonly "login.initializing": "Initializing...";
580
+ readonly "login.loginButton": "Log In";
581
+ readonly "login.logoAlt": "Logo";
582
+ readonly "login.noAccountPrompt": "Don't have an account?";
583
+ readonly "login.notInitialized": "System not initialized";
584
+ readonly "login.passwordLabel": "Password";
585
+ readonly "login.passwordPlaceholder": "Enter your password";
586
+ readonly "login.passwordRequired": "Password is required";
587
+ readonly "login.signUpLink": "Sign up";
588
+ readonly "login.usernameOrEmailLabel": "Username or Email";
589
+ readonly "login.usernameOrEmailPlaceholder": "Enter your username or email";
590
+ readonly "login.usernameRequired": "Username or email is required";
591
+ readonly "resetPassword.codeExpiredOrInvalid": "Code expired or invalid";
592
+ readonly "resetPassword.confirmPasswordLabel": "Confirm Password";
593
+ readonly "resetPassword.confirmPasswordPlaceholder": "Confirm your new password";
594
+ readonly "resetPassword.confirmPasswordRequired": "Confirm your password";
595
+ readonly "resetPassword.goToLoginButton": "Go to Login";
596
+ readonly "resetPassword.instructions": "Enter your new password.";
597
+ readonly "resetPassword.invalidCode": "The verification code is invalid. Please check the link or request a new one.";
598
+ readonly "resetPassword.missingParameters": "Missing required parameters";
599
+ readonly "resetPassword.newPasswordLabel": "New Password";
600
+ readonly "resetPassword.newPasswordPlaceholder": "Enter your new password";
601
+ readonly "resetPassword.newPasswordRequired": "New password is required";
602
+ readonly "resetPassword.passwordTooShort": "Password must be at least 8 characters";
603
+ readonly "resetPassword.passwordsDoNotMatch": "Passwords do not match";
604
+ readonly "resetPassword.requestNewCodeButton": "Request New Code";
605
+ readonly "resetPassword.resetPasswordButton": "Reset Password";
606
+ readonly "resetPassword.successInstructions": "You can now log in with your new password";
607
+ readonly "resetPassword.successMessage": "Password reset successfully";
608
+ readonly "resetPassword.title": "New Password";
609
+ readonly "resetPassword.validatingCode": "Validating code...";
610
+ };
611
+ };
612
+ type CriticalTranslationKey = keyof typeof CRITICAL_TRANSLATIONS.es;
613
+ type SupportedLanguage = keyof typeof CRITICAL_TRANSLATIONS;
614
+ /**
615
+ * Get list of supported languages
616
+ */
617
+ declare const getCriticalLanguages: () => SupportedLanguage[];
618
+ /**
619
+ * Get critical translations for a specific language
620
+ * Falls back to Spanish if language not found
621
+ */
622
+ declare const getCriticalTranslations: (language: string) => Record<string, string>;
623
+
624
+ export { AuthRoute, type AuthRouteProps, CRITICAL_TRANSLATIONS, type CriticalTranslationKey, CrudifyThemeProvider, type CrudifyThemeProviderProps, type FetchTranslationsOptions, LoginResult, type NotificationOptions, ProtectedRoute, type ProtectedRouteProps, SessionDebugInfo, SessionLoadingScreen, type SessionLoadingScreenProps, SessionProvider, type SessionProviderProps, type SupportedLanguage, TokenData, type TranslationResponse, TranslationService, type TranslationsContextValue, TranslationsProvider, type TranslationsProviderProps, UseSessionOptions, extractSafeRedirectFromUrl, getCriticalLanguages, getCriticalTranslations, translationService, useSessionContext, useTranslations, validateInternalRedirect };
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export { A as ApiError, C as CrudifyApiResponse, a as CrudifyTransactionResponse
5
5
  import { U as UseSessionOptions, T as TokenData, L as LoginResult } from './index-Fkm9ErmY.js';
6
6
  export { a as SessionConfig, S as SessionManager, d as SessionState, c as StorageType, b as TokenStorage, j as UseAuthReturn, l as UseDataReturn, g as UseUserDataOptions, f as UseUserDataReturn, h as UserData, i as useAuth, n as useCrudifyWithNotifications, k as useData, u as useSession, e as useUserData, m as useUserProfile } from './index-Fkm9ErmY.js';
7
7
  import * as react_jsx_runtime from 'react/jsx-runtime';
8
- import { ReactNode } from 'react';
8
+ import React, { ReactNode } from 'react';
9
9
  import { ThemeOptions } from '@mui/material';
10
10
  export { E as ERROR_CODES, j as ERROR_SEVERITY_MAP, n as ErrorCode, o as ErrorSeverity, q as ErrorTranslationConfig, P as ParsedError, m as createErrorTranslator, d as decodeJwtSafely, a as getCookie, g as getCurrentUserEmail, f as getErrorMessage, h as handleCrudifyError, i as isTokenExpired, p as parseApiError, e as parseJavaScriptError, c as parseTransactionError, b as secureLocalStorage, s as secureSessionStorage, l as translateError, t as translateErrorCode, k as translateErrorCodes } from './errorTranslation-DdqZg8JD.js';
11
11
  export { G as GlobalNotificationProvider, a as GlobalNotificationProviderProps, N as Notification, b as NotificationSeverity, u as useGlobalNotification } from './GlobalNotificationProvider-C3iWgM1z.js';
@@ -219,4 +219,406 @@ declare const validateInternalRedirect: (path: string, defaultPath?: string) =>
219
219
  */
220
220
  declare const extractSafeRedirectFromUrl: (searchParams: URLSearchParams | string, defaultPath?: string) => string;
221
221
 
222
- export { AuthRoute, type AuthRouteProps, CrudifyThemeProvider, type CrudifyThemeProviderProps, LoginResult, type NotificationOptions, ProtectedRoute, type ProtectedRouteProps, SessionDebugInfo, SessionLoadingScreen, type SessionLoadingScreenProps, SessionProvider, type SessionProviderProps, TokenData, UseSessionOptions, extractSafeRedirectFromUrl, useSessionContext, validateInternalRedirect };
222
+ interface TranslationsProviderProps {
223
+ children: React.ReactNode;
224
+ subscriberKey: string;
225
+ apiKey: string;
226
+ crudifyEnv?: "dev" | "stg" | "api" | "prod";
227
+ sections?: string[];
228
+ language?: string;
229
+ devTranslations?: Record<string, string>;
230
+ translationUrl?: string;
231
+ enableDebug?: boolean;
232
+ }
233
+ interface TranslationsContextValue {
234
+ t: (key: string, variables?: Record<string, any>) => string;
235
+ language: string;
236
+ availableLanguages: string[];
237
+ isLoading: boolean;
238
+ error: string | null;
239
+ refreshTranslations: () => Promise<void>;
240
+ }
241
+ /**
242
+ * TranslationsProvider
243
+ *
244
+ * Provides translation functionality to the application
245
+ * Handles fetching, caching, and fallback strategies
246
+ *
247
+ * @example
248
+ * ```tsx
249
+ * <TranslationsProvider
250
+ * subscriberKey="mycompany"
251
+ * apiKey="xxx"
252
+ * language="es"
253
+ * translationUrl="https://example.com/locales/es/translation.json"
254
+ * >
255
+ * <App />
256
+ * </TranslationsProvider>
257
+ * ```
258
+ */
259
+ declare const TranslationsProvider: React.FC<TranslationsProviderProps>;
260
+ /**
261
+ * Hook to use translations
262
+ *
263
+ * @example
264
+ * ```tsx
265
+ * const MyComponent = () => {
266
+ * const { t } = useTranslations();
267
+ * return <h1>{t('welcome.title')}</h1>;
268
+ * };
269
+ * ```
270
+ */
271
+ declare const useTranslations: () => TranslationsContextValue;
272
+
273
+ interface FetchTranslationsOptions {
274
+ subscriberKey: string;
275
+ apiKey: string;
276
+ crudifyEnv?: "dev" | "stg" | "api" | "prod";
277
+ sections?: string[];
278
+ urlTranslations?: Record<string, string>;
279
+ }
280
+ interface TranslationResponse {
281
+ subscriberKey: string;
282
+ languages: string[];
283
+ translations: Record<string, Record<string, string>>;
284
+ timestamp: string;
285
+ }
286
+ /**
287
+ * Translation Service
288
+ * Handles fetching, caching, and fallback strategies for translations
289
+ * Uses Crudify SDK for API calls
290
+ *
291
+ * Priority order (lowest to highest):
292
+ * 1. Critical bundle (fallback)
293
+ * 2. API translations (system + subscriber merged by backend)
294
+ * 3. URL translations (buildTranslations from config.json or translationUrl)
295
+ * 4. Dev translations (props override - handled by provider)
296
+ */
297
+ declare class TranslationService {
298
+ private static instance;
299
+ private isInitialized;
300
+ private constructor();
301
+ static getInstance(): TranslationService;
302
+ /**
303
+ * Initialize crudify SDK
304
+ */
305
+ private ensureInitialized;
306
+ /**
307
+ * Fetch translations with cache strategy
308
+ * 1. Try cache (if valid and not changed)
309
+ * 2. Try API fetch via crudify SDK
310
+ * 3. Try expired cache
311
+ * 4. Fall back to critical bundle
312
+ */
313
+ fetchTranslations(options: FetchTranslationsOptions): Promise<Record<string, Record<string, string>>>;
314
+ /**
315
+ * Fetch from API via crudify SDK
316
+ */
317
+ private fetchFromAPI;
318
+ /**
319
+ * Merge API translations with URL translations
320
+ * URL translations have higher priority
321
+ */
322
+ private mergeWithUrlTranslations;
323
+ /**
324
+ * Check if data has changed (compare timestamps or hash)
325
+ */
326
+ private hasDataChanged;
327
+ /**
328
+ * Simple hash function for data comparison
329
+ */
330
+ private hashData;
331
+ /**
332
+ * Save to localStorage
333
+ */
334
+ private saveToCache;
335
+ /**
336
+ * Read from localStorage
337
+ */
338
+ private getFromCache;
339
+ /**
340
+ * Refresh cache timestamp without changing data
341
+ */
342
+ private refreshCacheTimestamp;
343
+ /**
344
+ * Check if cache is expired
345
+ */
346
+ private isCacheExpired;
347
+ /**
348
+ * Generate cache key
349
+ */
350
+ private getCacheKey;
351
+ /**
352
+ * Get only critical translations from bundle
353
+ */
354
+ private getCriticalTranslationsOnly;
355
+ /**
356
+ * Invalidate cache (useful for testing/debugging)
357
+ */
358
+ invalidateCache(subscriberKey: string): void;
359
+ /**
360
+ * Prefetch translations in background
361
+ */
362
+ prefetchTranslations(options: FetchTranslationsOptions): Promise<void>;
363
+ /**
364
+ * Clear all translation caches
365
+ */
366
+ clearAllCaches(): void;
367
+ /**
368
+ * Shutdown crudify SDK
369
+ */
370
+ shutdown(): Promise<void>;
371
+ }
372
+ declare const translationService: TranslationService;
373
+
374
+ /**
375
+ * Critical translations bundle
376
+ * These translations are bundled with the application to ensure
377
+ * basic functionality (login, errors, loading) works even if the API is unavailable
378
+ *
379
+ * Total keys: 108
380
+ * - login.*: 15 keys
381
+ * - forgotPassword.*: 11 keys
382
+ * - checkCode.*: 11 keys
383
+ * - resetPassword.*: 19 keys
384
+ * - errors.*: 39 keys
385
+ * - loading.*: 5 keys
386
+ * - common (basic): 2 keys
387
+ * - footer.*: 2 keys
388
+ * - error.app.*: 4 keys
389
+ */
390
+ declare const CRITICAL_TRANSLATIONS: {
391
+ readonly es: {
392
+ readonly "checkCode.codeLabel": "Código de Verificación";
393
+ readonly "checkCode.codePlaceholder": "Ingresa el código de 6 dígitos";
394
+ readonly "checkCode.codeRequired": "El código es obligatorio";
395
+ readonly "checkCode.emailLabel": "Correo Electrónico";
396
+ readonly "checkCode.emailPlaceholder": "Ingresa tu correo electrónico";
397
+ readonly "checkCode.emailRequired": "El correo electrónico es obligatorio";
398
+ readonly "checkCode.instructions": "Ingresa el código de 6 dígitos que enviamos a tu correo electrónico.";
399
+ readonly "checkCode.invalidEmail": "Ingresa un correo electrónico válido";
400
+ readonly "checkCode.resendCodeLink": "Reenviar código";
401
+ readonly "checkCode.title": "Verificar Código";
402
+ readonly "checkCode.verifyButton": "Verificar Código";
403
+ readonly "common.back": "Volver";
404
+ readonly "common.backToLogin": "Volver";
405
+ readonly "error.app.config": "Error de Configuración: {{message}}";
406
+ readonly "error.app.initialization": "Error durante la inicialización final de la aplicación.";
407
+ readonly "error.transaction": "Error en la operación";
408
+ readonly "error.unknown": "Ocurrió un error desconocido.";
409
+ readonly "errors.DUPLICATE": "El campo <b>{{field}}</b> debe ser único.";
410
+ readonly "errors.FOREIGN_KEY_NOT_FOUND": "El campo <b>{{field}}</b> debe referenciar un ítem existente.";
411
+ readonly "errors.INVALID_EMAIL": "El campo <b>{{field}}</b> debe ser un correo electrónico válido.";
412
+ readonly "errors.INVALID_OBJECT_ID": "El campo <b>{{field}}</b> debe ser un valor válido.";
413
+ readonly "errors.IN_USE": "El ítem está en uso y no puede ser eliminado.";
414
+ readonly "errors.MAX_LENGTH": "El campo <b>{{field}}</b> no debe exceder los <b>{{length}}</b> caracteres.";
415
+ readonly "errors.MIN_LENGTH": "El campo <b>{{field}}</b> debe tener al menos <b>{{length}}</b> caracteres.";
416
+ readonly "errors.MUST_NOT_BE_EMAIL": "El campo <b>{{field}}</b> no debe ser un correo electrónico.";
417
+ readonly "errors.NO_PERMISSION": "No tienes permiso para realizar esta acción.";
418
+ readonly "errors.NO_SPACES": "El campo <b>{{field}}</b> no debe contener espacios.";
419
+ readonly "errors.ONE_OR_MORE_OPERATIONS_FAILED": "Error en la operación";
420
+ readonly "errors.REQUIRED": "El campo <b>{{field}}</b> es obligatorio.";
421
+ readonly "errors.TOKEN_HAS_EXPIRED": "La sesión ha expirado. Por favor, inicia sesión nuevamente.";
422
+ readonly "errors.TOO_MANY_REQUESTS": "Límite de solicitudes alcanzado. Por favor intenta más tarde.";
423
+ readonly "errors.UNAUTHORIZED": "No estás autorizado para realizar esta acción.";
424
+ readonly "errors.all_password_fields_required": "Todos los campos de contraseña son obligatorios";
425
+ readonly "errors.auth.INVALID_API_KEY": "Clave de API inválida";
426
+ readonly "errors.auth.INVALID_CREDENTIALS": "Usuario y/o contraseña incorrectos";
427
+ readonly "errors.auth.NO_PERMISSION": "No tienes permisos suficientes";
428
+ readonly "errors.auth.SESSION_EXPIRED": "Tu sesión ha expirado. Por favor, inicia sesión nuevamente.";
429
+ readonly "errors.auth.TOO_MANY_REQUESTS": "Demasiados intentos. Por favor espera 15 minutos e intenta nuevamente";
430
+ readonly "errors.auth.UNAUTHORIZED": "No tienes permisos para realizar esta acción";
431
+ readonly "errors.auth.USER_NOT_ACTIVE": "Usuario no activo";
432
+ readonly "errors.auth.USER_NOT_FOUND": "Usuario no encontrado";
433
+ readonly "errors.data.BAD_REQUEST": "Solicitud inválida";
434
+ readonly "errors.data.FIELD_ERROR": "Error en los datos ingresados";
435
+ readonly "errors.data.IN_USE": "El elemento está en uso y no puede ser eliminado";
436
+ readonly "errors.data.ITEM_NOT_FOUND": "El elemento solicitado no fue encontrado";
437
+ readonly "errors.data.NOT_FOUND": "No se encontró lo solicitado";
438
+ readonly "errors.internal_error_changing_password": "Error interno al cambiar la contraseña. Intenta nuevamente";
439
+ readonly "errors.password_min_length": "La contraseña debe tener al menos 8 caracteres";
440
+ readonly "errors.password_mismatch": "Las contraseñas no coinciden";
441
+ readonly "errors.password_must_be_different": "La nueva contraseña debe ser diferente a la actual";
442
+ readonly "errors.system.DATABASE_CONNECTION_ERROR": "Error de conexión. Verifica tu conexión a internet.";
443
+ readonly "errors.system.INTERNAL_SERVER_ERROR": "Error interno del servidor. Intenta nuevamente.";
444
+ readonly "errors.system.INVALID_CONFIGURATION": "Error de configuración del sistema";
445
+ readonly "errors.system.TOO_MANY_REQUESTS": "Demasiadas solicitudes. Por favor espera un momento e intenta nuevamente";
446
+ readonly "errors.system.UNKNOWN_OPERATION": "Operación no reconocida";
447
+ readonly "errors.users_module_not_configured": "Módulo de usuarios no configurado";
448
+ readonly "footer.copyright": "Nocios S.R.L. Todos los derechos reservados.";
449
+ readonly "footer.version": "Versión";
450
+ readonly "forgotPassword.checkEmailInstructions": "Revisa tu bandeja de entrada para el código de verificación";
451
+ readonly "forgotPassword.codeAlreadyExistsMessage": "Ya se envió un código y aún es válido";
452
+ readonly "forgotPassword.emailLabel": "Correo Electrónico";
453
+ readonly "forgotPassword.emailPlaceholder": "Ingresa tu correo electrónico";
454
+ readonly "forgotPassword.emailRequired": "El correo electrónico es obligatorio";
455
+ readonly "forgotPassword.emailSentMessage": "Código enviado exitosamente";
456
+ readonly "forgotPassword.enterCodeLink": "Ingresar Código";
457
+ readonly "forgotPassword.instructions": "Ingresa tu correo electrónico y te enviaremos un código para restablecer tu contraseña.";
458
+ readonly "forgotPassword.invalidEmail": "Ingresa un correo electrónico válido";
459
+ readonly "forgotPassword.sendCodeButton": "Enviar Código";
460
+ readonly "forgotPassword.title": "Recuperar Contraseña";
461
+ readonly "loading.app.configInitial": "Cargando configuración inicial...";
462
+ readonly "loading.app.generic": "Cargando...";
463
+ readonly "loading.app.starting": "Iniciando aplicación...";
464
+ readonly "loading.app.themeSetup": "Generando tema...";
465
+ readonly "loading.app.validatingSession": "Validando sesión...";
466
+ readonly "login.alreadyHaveCodeLink": "¿Ya tienes un código?";
467
+ readonly "login.forgotPasswordLink": "¿Olvidaste tu contraseña?";
468
+ readonly "login.initializationError": "Error de inicialización";
469
+ readonly "login.initializing": "Inicializando...";
470
+ readonly "login.loginButton": "Iniciar Sesión";
471
+ readonly "login.logoAlt": "Logotipo";
472
+ readonly "login.noAccountPrompt": "¿No tienes una cuenta?";
473
+ readonly "login.notInitialized": "Sistema no inicializado";
474
+ readonly "login.passwordLabel": "Contraseña";
475
+ readonly "login.passwordPlaceholder": "Ingresa tu contraseña";
476
+ readonly "login.passwordRequired": "Contraseña es obligatoria";
477
+ readonly "login.signUpLink": "Regístrate";
478
+ readonly "login.usernameOrEmailLabel": "Usuario o Correo Electrónico";
479
+ readonly "login.usernameOrEmailPlaceholder": "Ingresa tu usuario o correo electrónico";
480
+ readonly "login.usernameRequired": "Usuario o correo electrónico es obligatorio";
481
+ readonly "resetPassword.codeExpiredOrInvalid": "El código ha expirado o es inválido";
482
+ readonly "resetPassword.confirmPasswordLabel": "Confirmar Contraseña";
483
+ readonly "resetPassword.confirmPasswordPlaceholder": "Confirma tu nueva contraseña";
484
+ readonly "resetPassword.confirmPasswordRequired": "Confirma tu contraseña";
485
+ readonly "resetPassword.goToLoginButton": "Ir al Login";
486
+ readonly "resetPassword.instructions": "Ingresa tu nueva contraseña.";
487
+ readonly "resetPassword.invalidCode": "El código de verificación es inválido. Por favor, verifica el enlace o solicita uno nuevo.";
488
+ readonly "resetPassword.missingParameters": "Faltan parámetros obligatorios";
489
+ readonly "resetPassword.newPasswordLabel": "Nueva Contraseña";
490
+ readonly "resetPassword.newPasswordPlaceholder": "Ingresa tu nueva contraseña";
491
+ readonly "resetPassword.newPasswordRequired": "La nueva contraseña es obligatoria";
492
+ readonly "resetPassword.passwordTooShort": "La contraseña debe tener al menos 8 caracteres";
493
+ readonly "resetPassword.passwordsDoNotMatch": "Las contraseñas no coinciden";
494
+ readonly "resetPassword.requestNewCodeButton": "Solicitar Nuevo Código";
495
+ readonly "resetPassword.resetPasswordButton": "Restablecer Contraseña";
496
+ readonly "resetPassword.successInstructions": "Ahora puedes iniciar sesión con tu nueva contraseña";
497
+ readonly "resetPassword.successMessage": "Contraseña restablecida exitosamente";
498
+ readonly "resetPassword.title": "Nueva Contraseña";
499
+ readonly "resetPassword.validatingCode": "Validando código...";
500
+ };
501
+ readonly en: {
502
+ readonly "checkCode.codeLabel": "Verification Code";
503
+ readonly "checkCode.codePlaceholder": "Enter 6-digit code";
504
+ readonly "checkCode.codeRequired": "Code is required";
505
+ readonly "checkCode.emailLabel": "Email Address";
506
+ readonly "checkCode.emailPlaceholder": "Enter your email address";
507
+ readonly "checkCode.emailRequired": "Email address is required";
508
+ readonly "checkCode.instructions": "Enter the 6-digit code we sent to your email address.";
509
+ readonly "checkCode.invalidEmail": "Enter a valid email address";
510
+ readonly "checkCode.resendCodeLink": "Resend code";
511
+ readonly "checkCode.title": "Verify Code";
512
+ readonly "checkCode.verifyButton": "Verify Code";
513
+ readonly "common.back": "Back";
514
+ readonly "common.backToLogin": "Back to Login";
515
+ readonly "error.app.config": "Configuration Error: {{message}}";
516
+ readonly "error.app.initialization": "Error during final application initialization.";
517
+ readonly "error.transaction": "Operation error";
518
+ readonly "error.unknown": "An unknown error occurred.";
519
+ readonly "errors.DUPLICATE": "The field <b>{{field}}</b> must be unique.";
520
+ readonly "errors.FOREIGN_KEY_NOT_FOUND": "The field <b>{{field}}</b> must reference an existing item.";
521
+ readonly "errors.INVALID_EMAIL": "The field <b>{{field}}</b> must be a valid email address.";
522
+ readonly "errors.INVALID_OBJECT_ID": "The field <b>{{field}}</b> must be a valid value.";
523
+ readonly "errors.IN_USE": "The item is currently in use and cannot be deleted.";
524
+ readonly "errors.MAX_LENGTH": "The field <b>{{field}}</b> must not exceed <b>{{maxLength}}</b> characters.";
525
+ readonly "errors.MIN_LENGTH": "The field <b>{{field}}</b> must have at least <b>{{minLength}}</b> characters.";
526
+ readonly "errors.MUST_NOT_BE_EMAIL": "The field <b>{{field}}</b> must not be an email address.";
527
+ readonly "errors.NO_PERMISSION": "You do not have permission to perform this action.";
528
+ readonly "errors.NO_SPACES": "The field <b>{{field}}</b> must not contain spaces.";
529
+ readonly "errors.ONE_OR_MORE_OPERATIONS_FAILED": "Operation error";
530
+ readonly "errors.REQUIRED": "The field <b>{{field}}</b> is required.";
531
+ readonly "errors.TOKEN_HAS_EXPIRED": "Your session has expired, please log in again.";
532
+ readonly "errors.TOO_MANY_REQUESTS": "Request limit reached. Please try again later.";
533
+ readonly "errors.UNAUTHORIZED": "You are not authorized to perform this action.";
534
+ readonly "errors.all_password_fields_required": "All password fields are required";
535
+ readonly "errors.auth.INVALID_API_KEY": "Invalid API key";
536
+ readonly "errors.auth.INVALID_CREDENTIALS": "Incorrect username and/or password";
537
+ readonly "errors.auth.NO_PERMISSION": "Insufficient permissions";
538
+ readonly "errors.auth.SESSION_EXPIRED": "Your session has expired. Please log in again.";
539
+ readonly "errors.auth.TOO_MANY_REQUESTS": "Too many attempts. Please wait 15 minutes and try again";
540
+ readonly "errors.auth.UNAUTHORIZED": "You don't have permission to perform this action";
541
+ readonly "errors.auth.USER_NOT_ACTIVE": "User account is not active";
542
+ readonly "errors.auth.USER_NOT_FOUND": "User not found";
543
+ readonly "errors.data.BAD_REQUEST": "Invalid request";
544
+ readonly "errors.data.FIELD_ERROR": "Error in the provided data";
545
+ readonly "errors.data.IN_USE": "The item is in use and cannot be deleted";
546
+ readonly "errors.data.ITEM_NOT_FOUND": "The requested item was not found";
547
+ readonly "errors.data.NOT_FOUND": "The requested resource was not found";
548
+ readonly "errors.internal_error_changing_password": "Internal error changing password. Please try again";
549
+ readonly "errors.password_min_length": "Password must be at least 8 characters";
550
+ readonly "errors.password_mismatch": "Passwords do not match";
551
+ readonly "errors.password_must_be_different": "New password must be different from current password";
552
+ readonly "errors.system.DATABASE_CONNECTION_ERROR": "Connection error. Please check your internet connection.";
553
+ readonly "errors.system.INTERNAL_SERVER_ERROR": "Internal server error. Please try again.";
554
+ readonly "errors.system.INVALID_CONFIGURATION": "System configuration error";
555
+ readonly "errors.system.TOO_MANY_REQUESTS": "Too many requests. Please wait a moment and try again";
556
+ readonly "errors.system.UNKNOWN_OPERATION": "Unrecognized operation";
557
+ readonly "errors.users_module_not_configured": "Users module not configured";
558
+ readonly "footer.copyright": "Nocios S.R.L. All Rights Reserved.";
559
+ readonly "footer.version": "Version";
560
+ readonly "forgotPassword.checkEmailInstructions": "Check your inbox for the verification code";
561
+ readonly "forgotPassword.codeAlreadyExistsMessage": "A code was already sent and is still valid";
562
+ readonly "forgotPassword.emailLabel": "Email Address";
563
+ readonly "forgotPassword.emailPlaceholder": "Enter your email address";
564
+ readonly "forgotPassword.emailRequired": "Email address is required";
565
+ readonly "forgotPassword.emailSentMessage": "Code sent successfully";
566
+ readonly "forgotPassword.enterCodeLink": "Enter Code";
567
+ readonly "forgotPassword.instructions": "Enter your email address and we'll send you a code to reset your password.";
568
+ readonly "forgotPassword.invalidEmail": "Enter a valid email address";
569
+ readonly "forgotPassword.sendCodeButton": "Send Code";
570
+ readonly "forgotPassword.title": "Reset Password";
571
+ readonly "loading.app.configInitial": "Loading initial configuration...";
572
+ readonly "loading.app.generic": "Loading...";
573
+ readonly "loading.app.starting": "Starting application...";
574
+ readonly "loading.app.themeSetup": "Generating theme...";
575
+ readonly "loading.app.validatingSession": "Validating session...";
576
+ readonly "login.alreadyHaveCodeLink": "Already have a code?";
577
+ readonly "login.forgotPasswordLink": "Forgot Password?";
578
+ readonly "login.initializationError": "Initialization error";
579
+ readonly "login.initializing": "Initializing...";
580
+ readonly "login.loginButton": "Log In";
581
+ readonly "login.logoAlt": "Logo";
582
+ readonly "login.noAccountPrompt": "Don't have an account?";
583
+ readonly "login.notInitialized": "System not initialized";
584
+ readonly "login.passwordLabel": "Password";
585
+ readonly "login.passwordPlaceholder": "Enter your password";
586
+ readonly "login.passwordRequired": "Password is required";
587
+ readonly "login.signUpLink": "Sign up";
588
+ readonly "login.usernameOrEmailLabel": "Username or Email";
589
+ readonly "login.usernameOrEmailPlaceholder": "Enter your username or email";
590
+ readonly "login.usernameRequired": "Username or email is required";
591
+ readonly "resetPassword.codeExpiredOrInvalid": "Code expired or invalid";
592
+ readonly "resetPassword.confirmPasswordLabel": "Confirm Password";
593
+ readonly "resetPassword.confirmPasswordPlaceholder": "Confirm your new password";
594
+ readonly "resetPassword.confirmPasswordRequired": "Confirm your password";
595
+ readonly "resetPassword.goToLoginButton": "Go to Login";
596
+ readonly "resetPassword.instructions": "Enter your new password.";
597
+ readonly "resetPassword.invalidCode": "The verification code is invalid. Please check the link or request a new one.";
598
+ readonly "resetPassword.missingParameters": "Missing required parameters";
599
+ readonly "resetPassword.newPasswordLabel": "New Password";
600
+ readonly "resetPassword.newPasswordPlaceholder": "Enter your new password";
601
+ readonly "resetPassword.newPasswordRequired": "New password is required";
602
+ readonly "resetPassword.passwordTooShort": "Password must be at least 8 characters";
603
+ readonly "resetPassword.passwordsDoNotMatch": "Passwords do not match";
604
+ readonly "resetPassword.requestNewCodeButton": "Request New Code";
605
+ readonly "resetPassword.resetPasswordButton": "Reset Password";
606
+ readonly "resetPassword.successInstructions": "You can now log in with your new password";
607
+ readonly "resetPassword.successMessage": "Password reset successfully";
608
+ readonly "resetPassword.title": "New Password";
609
+ readonly "resetPassword.validatingCode": "Validating code...";
610
+ };
611
+ };
612
+ type CriticalTranslationKey = keyof typeof CRITICAL_TRANSLATIONS.es;
613
+ type SupportedLanguage = keyof typeof CRITICAL_TRANSLATIONS;
614
+ /**
615
+ * Get list of supported languages
616
+ */
617
+ declare const getCriticalLanguages: () => SupportedLanguage[];
618
+ /**
619
+ * Get critical translations for a specific language
620
+ * Falls back to Spanish if language not found
621
+ */
622
+ declare const getCriticalTranslations: (language: string) => Record<string, string>;
623
+
624
+ export { AuthRoute, type AuthRouteProps, CRITICAL_TRANSLATIONS, type CriticalTranslationKey, CrudifyThemeProvider, type CrudifyThemeProviderProps, type FetchTranslationsOptions, LoginResult, type NotificationOptions, ProtectedRoute, type ProtectedRouteProps, SessionDebugInfo, SessionLoadingScreen, type SessionLoadingScreenProps, SessionProvider, type SessionProviderProps, type SupportedLanguage, TokenData, type TranslationResponse, TranslationService, type TranslationsContextValue, TranslationsProvider, type TranslationsProviderProps, UseSessionOptions, extractSafeRedirectFromUrl, getCriticalLanguages, getCriticalTranslations, translationService, useSessionContext, useTranslations, validateInternalRedirect };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkYQF2FVCXjs = require('./chunk-YQF2FVCX.js');var _chunkX3HSMDZ7js = require('./chunk-X3HSMDZ7.js');var _chunkTLGRXZCSjs = require('./chunk-TLGRXZCS.js');var _chunkNNY4A73Vjs = require('./chunk-NNY4A73V.js');var _chunkYIIUEOXCjs = require('./chunk-YIIUEOXC.js');var _chunkAT74WV5Wjs = require('./chunk-AT74WV5W.js');var _crudifybrowser = require('@nocios/crudify-browser'); var _crudifybrowser2 = _interopRequireDefault(_crudifybrowser); _createStarExport(_crudifybrowser);var _react = require('react');var _material = require('@mui/material');var _jsxruntime = require('react/jsx-runtime');var fe=(o={})=>{try{let e=_chunkAT74WV5Wjs.a.call(void 0, "theme");if(e){let r=JSON.parse(decodeURIComponent(e));return{...o,...r}}}catch(e){console.warn("Error parsing theme from cookie:",e)}return o};function de({children:o,defaultTheme:e={},disableCssBaseline:r=!1}){let t=_react.useMemo.call(void 0, ()=>{let i=fe(e);return _material.createTheme.call(void 0, i)},[e]);return _jsxruntime.jsxs.call(void 0, _material.ThemeProvider,{theme:t,children:[!r&&_jsxruntime.jsx.call(void 0, _material.CssBaseline,{}),o]})}var _reactrouterdom = require('react-router-dom');var ue={border:"5px solid rgba(0, 0, 0, 0.1)",borderTopColor:"#3B82F6",borderRadius:"50%",width:"50px",height:"50px",animation:"spin 1s linear infinite"},ge=()=>_jsxruntime.jsx.call(void 0, "style",{children:`
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkYQF2FVCXjs = require('./chunk-YQF2FVCX.js');var _chunkX3HSMDZ7js = require('./chunk-X3HSMDZ7.js');var _chunkTLGRXZCSjs = require('./chunk-TLGRXZCS.js');var _chunkNNY4A73Vjs = require('./chunk-NNY4A73V.js');var _chunkYIIUEOXCjs = require('./chunk-YIIUEOXC.js');var _chunkAT74WV5Wjs = require('./chunk-AT74WV5W.js');var _crudifybrowser = require('@nocios/crudify-browser'); var _crudifybrowser2 = _interopRequireDefault(_crudifybrowser); _createStarExport(_crudifybrowser);var _react = require('react');var _material = require('@mui/material');var _jsxruntime = require('react/jsx-runtime');var ke=(s={})=>{try{let r=_chunkAT74WV5Wjs.a.call(void 0, "theme");if(r){let e=JSON.parse(decodeURIComponent(r));return{...s,...e}}}catch(r){console.warn("Error parsing theme from cookie:",r)}return s};function Ue({children:s,defaultTheme:r={},disableCssBaseline:e=!1}){let o=_react.useMemo.call(void 0, ()=>{let t=ke(r);return _material.createTheme.call(void 0, t)},[r]);return _jsxruntime.jsxs.call(void 0, _material.ThemeProvider,{theme:o,children:[!e&&_jsxruntime.jsx.call(void 0, _material.CssBaseline,{}),s]})}var _reactrouterdom = require('react-router-dom');var Me={border:"5px solid rgba(0, 0, 0, 0.1)",borderTopColor:"#3B82F6",borderRadius:"50%",width:"50px",height:"50px",animation:"spin 1s linear infinite"},qe=()=>_jsxruntime.jsx.call(void 0, "style",{children:`
2
2
  @keyframes spin {
3
3
  0% { transform: rotate(0deg); }
4
4
  100% { transform: rotate(360deg); }
5
5
  }
6
- `});function m({stage:o="loading",message:e}){let t=e||{initializing:"Initializing application...","validating-session":"Validating session...",loading:"Loading..."}[o];return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, ge,{}),_jsxruntime.jsxs.call(void 0, "div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",width:"100vw",backgroundColor:"#f0f2f5",fontFamily:'"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',color:"#333",textAlign:"center",boxSizing:"border-box",padding:"20px",background:"#fff"},children:[_jsxruntime.jsx.call(void 0, "div",{style:ue}),_jsxruntime.jsx.call(void 0, "p",{style:{fontSize:"1.25em",fontWeight:"500",marginTop:"24px",color:"#1f2937"},children:t})]})]})}var Re=/^[a-zA-Z0-9\-_./\?=&%#]+$/,ye=[/^https?:\/\//i,/^ftp:\/\//i,/^\/\//,/javascript:/i,/data:/i,/vbscript:/i,/about:/i,/\.\.\//,/\.\.\\/,/%2e%2e%2f/i,/%2e%2e%5c/i,/%2f%2f/i,/%5c%5c/i,/[\x00-\x1f\x7f-\x9f]/,/\\/],c= exports.validateInternalRedirect =(o,e="/")=>{if(!o||typeof o!="string")return e;let r=o.trim();if(!r)return e;if(!r.startsWith("/"))return console.warn("\u{1F6A8} Open redirect blocked (relative path):",o),e;if(!Re.test(r))return console.warn("\u{1F6A8} Open redirect blocked (invalid characters):",o),e;let t=r.toLowerCase();for(let s of ye)if(s.test(t))return console.warn("\u{1F6A8} Open redirect blocked (dangerous pattern):",o),e;let i=r.split("?")[0].split("/").filter(Boolean);if(i.length===0)return r;for(let s of i)if(s===".."||s.includes(":")||s.length>100)return console.warn("\u{1F6A8} Open redirect blocked (suspicious path part):",s),e;return r},l= exports.extractSafeRedirectFromUrl =(o,e="/")=>{try{let t=(typeof o=="string"?new URLSearchParams(o):o).get("redirect");if(!t)return e;let i=decodeURIComponent(t);return c(i,e)}catch(r){return console.warn("\u{1F6A8} Error parsing redirect parameter:",r),e}};function R({children:o,loadingComponent:e,loginPath:r="/login"}){let{isAuthenticated:t,isLoading:i,isInitialized:s,tokens:n,error:h}=_chunkTLGRXZCSjs.g.call(void 0, ),u=_reactrouterdom.useLocation.call(void 0, );if(!s||i)return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e||_jsxruntime.jsx.call(void 0, m,{stage:"validating-session"})});let P=t&&_optionalChain([n, 'optionalAccess', _2 => _2.accessToken])&&n.accessToken.length>0;if(h||!t||!P){n&&(!n.accessToken||n.accessToken.length===0)&&localStorage.removeItem("crudify_tokens");let C=u.pathname+u.search,v=c(C),T=encodeURIComponent(v);return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:`${r}?redirect=${T}`,replace:!0})}return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:o})}function S({children:o,redirectTo:e="/"}){let{isAuthenticated:r}=_chunkTLGRXZCSjs.g.call(void 0, ),t=_reactrouterdom.useLocation.call(void 0, );if(r){let i=new URLSearchParams(t.search),s=l(i,e);return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:s,replace:!0})}return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:o})}exports.AuthRoute = S; exports.CrudifyLogin = _chunkYQF2FVCXjs.a; exports.CrudifyThemeProvider = de; exports.ERROR_CODES = _chunkYIIUEOXCjs.a; exports.ERROR_SEVERITY_MAP = _chunkYIIUEOXCjs.b; exports.GlobalNotificationProvider = _chunkTLGRXZCSjs.d; exports.LoginComponent = _chunkYQF2FVCXjs.f; exports.POLICY_ACTIONS = _chunkYQF2FVCXjs.c; exports.PREFERRED_POLICY_ORDER = _chunkYQF2FVCXjs.d; exports.Policies = _chunkYQF2FVCXjs.e; exports.ProtectedRoute = R; exports.SessionDebugInfo = _chunkTLGRXZCSjs.h; exports.SessionLoadingScreen = m; exports.SessionManager = _chunkTLGRXZCSjs.b; exports.SessionProvider = _chunkTLGRXZCSjs.f; exports.SessionStatus = _chunkYQF2FVCXjs.g; exports.TokenStorage = _chunkTLGRXZCSjs.a; exports.UserProfileDisplay = _chunkYQF2FVCXjs.b; exports.createErrorTranslator = _chunkAT74WV5Wjs.e; exports.crudify = _crudifybrowser2.default; exports.decodeJwtSafely = _chunkAT74WV5Wjs.h; exports.extractSafeRedirectFromUrl = l; exports.getCookie = _chunkAT74WV5Wjs.a; exports.getCurrentUserEmail = _chunkAT74WV5Wjs.i; exports.getErrorMessage = _chunkYIIUEOXCjs.e; exports.handleCrudifyError = _chunkYIIUEOXCjs.g; exports.isTokenExpired = _chunkAT74WV5Wjs.j; exports.parseApiError = _chunkYIIUEOXCjs.c; exports.parseJavaScriptError = _chunkYIIUEOXCjs.f; exports.parseTransactionError = _chunkYIIUEOXCjs.d; exports.secureLocalStorage = _chunkNNY4A73Vjs.b; exports.secureSessionStorage = _chunkNNY4A73Vjs.a; exports.translateError = _chunkAT74WV5Wjs.d; exports.translateErrorCode = _chunkAT74WV5Wjs.b; exports.translateErrorCodes = _chunkAT74WV5Wjs.c; exports.useAuth = _chunkX3HSMDZ7js.b; exports.useCrudifyWithNotifications = _chunkX3HSMDZ7js.d; exports.useData = _chunkX3HSMDZ7js.c; exports.useGlobalNotification = _chunkTLGRXZCSjs.e; exports.useSession = _chunkTLGRXZCSjs.c; exports.useSessionContext = _chunkTLGRXZCSjs.g; exports.useUserData = _chunkX3HSMDZ7js.a; exports.useUserProfile = _chunkTLGRXZCSjs.i; exports.validateInternalRedirect = c;
6
+ `});function L({stage:s="loading",message:r}){let o=r||{initializing:"Initializing application...","validating-session":"Validating session...",loading:"Loading..."}[s];return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, qe,{}),_jsxruntime.jsxs.call(void 0, "div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",width:"100vw",backgroundColor:"#f0f2f5",fontFamily:'"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',color:"#333",textAlign:"center",boxSizing:"border-box",padding:"20px",background:"#fff"},children:[_jsxruntime.jsx.call(void 0, "div",{style:Me}),_jsxruntime.jsx.call(void 0, "p",{style:{fontSize:"1.25em",fontWeight:"500",marginTop:"24px",color:"#1f2937"},children:o})]})]})}var ze=/^[a-zA-Z0-9\-_./\?=&%#]+$/,Be=[/^https?:\/\//i,/^ftp:\/\//i,/^\/\//,/javascript:/i,/data:/i,/vbscript:/i,/about:/i,/\.\.\//,/\.\.\\/,/%2e%2e%2f/i,/%2e%2e%5c/i,/%2f%2f/i,/%5c%5c/i,/[\x00-\x1f\x7f-\x9f]/,/\\/],y= exports.validateInternalRedirect =(s,r="/")=>{if(!s||typeof s!="string")return r;let e=s.trim();if(!e)return r;if(!e.startsWith("/"))return console.warn("\u{1F6A8} Open redirect blocked (relative path):",s),r;if(!ze.test(e))return console.warn("\u{1F6A8} Open redirect blocked (invalid characters):",s),r;let o=e.toLowerCase();for(let a of Be)if(a.test(o))return console.warn("\u{1F6A8} Open redirect blocked (dangerous pattern):",s),r;let t=e.split("?")[0].split("/").filter(Boolean);if(t.length===0)return e;for(let a of t)if(a===".."||a.includes(":")||a.length>100)return console.warn("\u{1F6A8} Open redirect blocked (suspicious path part):",a),r;return e},_= exports.extractSafeRedirectFromUrl =(s,r="/")=>{try{let o=(typeof s=="string"?new URLSearchParams(s):s).get("redirect");if(!o)return r;let t=decodeURIComponent(o);return y(t,r)}catch(e){return console.warn("\u{1F6A8} Error parsing redirect parameter:",e),r}};function M({children:s,loadingComponent:r,loginPath:e="/login"}){let{isAuthenticated:o,isLoading:t,isInitialized:a,tokens:d,error:n}=_chunkTLGRXZCSjs.g.call(void 0, ),g=_reactrouterdom.useLocation.call(void 0, );if(!a||t)return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:r||_jsxruntime.jsx.call(void 0, L,{stage:"validating-session"})});let c=o&&_optionalChain([d, 'optionalAccess', _2 => _2.accessToken])&&d.accessToken.length>0;if(n||!o||!c){d&&(!d.accessToken||d.accessToken.length===0)&&localStorage.removeItem("crudify_tokens");let m=g.pathname+g.search,T=y(m),R=encodeURIComponent(T);return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:`${e}?redirect=${R}`,replace:!0})}return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:s})}function V({children:s,redirectTo:r="/"}){let{isAuthenticated:e}=_chunkTLGRXZCSjs.g.call(void 0, ),o=_reactrouterdom.useLocation.call(void 0, );if(e){let t=new URLSearchParams(o.search),a=_(t,r);return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:a,replace:!0})}return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:s})}var p={es:{"checkCode.codeLabel":"C\xF3digo de Verificaci\xF3n","checkCode.codePlaceholder":"Ingresa el c\xF3digo de 6 d\xEDgitos","checkCode.codeRequired":"El c\xF3digo es obligatorio","checkCode.emailLabel":"Correo Electr\xF3nico","checkCode.emailPlaceholder":"Ingresa tu correo electr\xF3nico","checkCode.emailRequired":"El correo electr\xF3nico es obligatorio","checkCode.instructions":"Ingresa el c\xF3digo de 6 d\xEDgitos que enviamos a tu correo electr\xF3nico.","checkCode.invalidEmail":"Ingresa un correo electr\xF3nico v\xE1lido","checkCode.resendCodeLink":"Reenviar c\xF3digo","checkCode.title":"Verificar C\xF3digo","checkCode.verifyButton":"Verificar C\xF3digo","common.back":"Volver","common.backToLogin":"Volver","error.app.config":"Error de Configuraci\xF3n: {{message}}","error.app.initialization":"Error durante la inicializaci\xF3n final de la aplicaci\xF3n.","error.transaction":"Error en la operaci\xF3n","error.unknown":"Ocurri\xF3 un error desconocido.","errors.DUPLICATE":"El campo <b>{{field}}</b> debe ser \xFAnico.","errors.FOREIGN_KEY_NOT_FOUND":"El campo <b>{{field}}</b> debe referenciar un \xEDtem existente.","errors.INVALID_EMAIL":"El campo <b>{{field}}</b> debe ser un correo electr\xF3nico v\xE1lido.","errors.INVALID_OBJECT_ID":"El campo <b>{{field}}</b> debe ser un valor v\xE1lido.","errors.IN_USE":"El \xEDtem est\xE1 en uso y no puede ser eliminado.","errors.MAX_LENGTH":"El campo <b>{{field}}</b> no debe exceder los <b>{{length}}</b> caracteres.","errors.MIN_LENGTH":"El campo <b>{{field}}</b> debe tener al menos <b>{{length}}</b> caracteres.","errors.MUST_NOT_BE_EMAIL":"El campo <b>{{field}}</b> no debe ser un correo electr\xF3nico.","errors.NO_PERMISSION":"No tienes permiso para realizar esta acci\xF3n.","errors.NO_SPACES":"El campo <b>{{field}}</b> no debe contener espacios.","errors.ONE_OR_MORE_OPERATIONS_FAILED":"Error en la operaci\xF3n","errors.REQUIRED":"El campo <b>{{field}}</b> es obligatorio.","errors.TOKEN_HAS_EXPIRED":"La sesi\xF3n ha expirado. Por favor, inicia sesi\xF3n nuevamente.","errors.TOO_MANY_REQUESTS":"L\xEDmite de solicitudes alcanzado. Por favor intenta m\xE1s tarde.","errors.UNAUTHORIZED":"No est\xE1s autorizado para realizar esta acci\xF3n.","errors.all_password_fields_required":"Todos los campos de contrase\xF1a son obligatorios","errors.auth.INVALID_API_KEY":"Clave de API inv\xE1lida","errors.auth.INVALID_CREDENTIALS":"Usuario y/o contrase\xF1a incorrectos","errors.auth.NO_PERMISSION":"No tienes permisos suficientes","errors.auth.SESSION_EXPIRED":"Tu sesi\xF3n ha expirado. Por favor, inicia sesi\xF3n nuevamente.","errors.auth.TOO_MANY_REQUESTS":"Demasiados intentos. Por favor espera 15 minutos e intenta nuevamente","errors.auth.UNAUTHORIZED":"No tienes permisos para realizar esta acci\xF3n","errors.auth.USER_NOT_ACTIVE":"Usuario no activo","errors.auth.USER_NOT_FOUND":"Usuario no encontrado","errors.data.BAD_REQUEST":"Solicitud inv\xE1lida","errors.data.FIELD_ERROR":"Error en los datos ingresados","errors.data.IN_USE":"El elemento est\xE1 en uso y no puede ser eliminado","errors.data.ITEM_NOT_FOUND":"El elemento solicitado no fue encontrado","errors.data.NOT_FOUND":"No se encontr\xF3 lo solicitado","errors.internal_error_changing_password":"Error interno al cambiar la contrase\xF1a. Intenta nuevamente","errors.password_min_length":"La contrase\xF1a debe tener al menos 8 caracteres","errors.password_mismatch":"Las contrase\xF1as no coinciden","errors.password_must_be_different":"La nueva contrase\xF1a debe ser diferente a la actual","errors.system.DATABASE_CONNECTION_ERROR":"Error de conexi\xF3n. Verifica tu conexi\xF3n a internet.","errors.system.INTERNAL_SERVER_ERROR":"Error interno del servidor. Intenta nuevamente.","errors.system.INVALID_CONFIGURATION":"Error de configuraci\xF3n del sistema","errors.system.TOO_MANY_REQUESTS":"Demasiadas solicitudes. Por favor espera un momento e intenta nuevamente","errors.system.UNKNOWN_OPERATION":"Operaci\xF3n no reconocida","errors.users_module_not_configured":"M\xF3dulo de usuarios no configurado","footer.copyright":"Nocios S.R.L. Todos los derechos reservados.","footer.version":"Versi\xF3n","forgotPassword.checkEmailInstructions":"Revisa tu bandeja de entrada para el c\xF3digo de verificaci\xF3n","forgotPassword.codeAlreadyExistsMessage":"Ya se envi\xF3 un c\xF3digo y a\xFAn es v\xE1lido","forgotPassword.emailLabel":"Correo Electr\xF3nico","forgotPassword.emailPlaceholder":"Ingresa tu correo electr\xF3nico","forgotPassword.emailRequired":"El correo electr\xF3nico es obligatorio","forgotPassword.emailSentMessage":"C\xF3digo enviado exitosamente","forgotPassword.enterCodeLink":"Ingresar C\xF3digo","forgotPassword.instructions":"Ingresa tu correo electr\xF3nico y te enviaremos un c\xF3digo para restablecer tu contrase\xF1a.","forgotPassword.invalidEmail":"Ingresa un correo electr\xF3nico v\xE1lido","forgotPassword.sendCodeButton":"Enviar C\xF3digo","forgotPassword.title":"Recuperar Contrase\xF1a","loading.app.configInitial":"Cargando configuraci\xF3n inicial...","loading.app.generic":"Cargando...","loading.app.starting":"Iniciando aplicaci\xF3n...","loading.app.themeSetup":"Generando tema...","loading.app.validatingSession":"Validando sesi\xF3n...","login.alreadyHaveCodeLink":"\xBFYa tienes un c\xF3digo?","login.forgotPasswordLink":"\xBFOlvidaste tu contrase\xF1a?","login.initializationError":"Error de inicializaci\xF3n","login.initializing":"Inicializando...","login.loginButton":"Iniciar Sesi\xF3n","login.logoAlt":"Logotipo","login.noAccountPrompt":"\xBFNo tienes una cuenta?","login.notInitialized":"Sistema no inicializado","login.passwordLabel":"Contrase\xF1a","login.passwordPlaceholder":"Ingresa tu contrase\xF1a","login.passwordRequired":"Contrase\xF1a es obligatoria","login.signUpLink":"Reg\xEDstrate","login.usernameOrEmailLabel":"Usuario o Correo Electr\xF3nico","login.usernameOrEmailPlaceholder":"Ingresa tu usuario o correo electr\xF3nico","login.usernameRequired":"Usuario o correo electr\xF3nico es obligatorio","resetPassword.codeExpiredOrInvalid":"El c\xF3digo ha expirado o es inv\xE1lido","resetPassword.confirmPasswordLabel":"Confirmar Contrase\xF1a","resetPassword.confirmPasswordPlaceholder":"Confirma tu nueva contrase\xF1a","resetPassword.confirmPasswordRequired":"Confirma tu contrase\xF1a","resetPassword.goToLoginButton":"Ir al Login","resetPassword.instructions":"Ingresa tu nueva contrase\xF1a.","resetPassword.invalidCode":"El c\xF3digo de verificaci\xF3n es inv\xE1lido. Por favor, verifica el enlace o solicita uno nuevo.","resetPassword.missingParameters":"Faltan par\xE1metros obligatorios","resetPassword.newPasswordLabel":"Nueva Contrase\xF1a","resetPassword.newPasswordPlaceholder":"Ingresa tu nueva contrase\xF1a","resetPassword.newPasswordRequired":"La nueva contrase\xF1a es obligatoria","resetPassword.passwordTooShort":"La contrase\xF1a debe tener al menos 8 caracteres","resetPassword.passwordsDoNotMatch":"Las contrase\xF1as no coinciden","resetPassword.requestNewCodeButton":"Solicitar Nuevo C\xF3digo","resetPassword.resetPasswordButton":"Restablecer Contrase\xF1a","resetPassword.successInstructions":"Ahora puedes iniciar sesi\xF3n con tu nueva contrase\xF1a","resetPassword.successMessage":"Contrase\xF1a restablecida exitosamente","resetPassword.title":"Nueva Contrase\xF1a","resetPassword.validatingCode":"Validando c\xF3digo..."},en:{"checkCode.codeLabel":"Verification Code","checkCode.codePlaceholder":"Enter 6-digit code","checkCode.codeRequired":"Code is required","checkCode.emailLabel":"Email Address","checkCode.emailPlaceholder":"Enter your email address","checkCode.emailRequired":"Email address is required","checkCode.instructions":"Enter the 6-digit code we sent to your email address.","checkCode.invalidEmail":"Enter a valid email address","checkCode.resendCodeLink":"Resend code","checkCode.title":"Verify Code","checkCode.verifyButton":"Verify Code","common.back":"Back","common.backToLogin":"Back to Login","error.app.config":"Configuration Error: {{message}}","error.app.initialization":"Error during final application initialization.","error.transaction":"Operation error","error.unknown":"An unknown error occurred.","errors.DUPLICATE":"The field <b>{{field}}</b> must be unique.","errors.FOREIGN_KEY_NOT_FOUND":"The field <b>{{field}}</b> must reference an existing item.","errors.INVALID_EMAIL":"The field <b>{{field}}</b> must be a valid email address.","errors.INVALID_OBJECT_ID":"The field <b>{{field}}</b> must be a valid value.","errors.IN_USE":"The item is currently in use and cannot be deleted.","errors.MAX_LENGTH":"The field <b>{{field}}</b> must not exceed <b>{{maxLength}}</b> characters.","errors.MIN_LENGTH":"The field <b>{{field}}</b> must have at least <b>{{minLength}}</b> characters.","errors.MUST_NOT_BE_EMAIL":"The field <b>{{field}}</b> must not be an email address.","errors.NO_PERMISSION":"You do not have permission to perform this action.","errors.NO_SPACES":"The field <b>{{field}}</b> must not contain spaces.","errors.ONE_OR_MORE_OPERATIONS_FAILED":"Operation error","errors.REQUIRED":"The field <b>{{field}}</b> is required.","errors.TOKEN_HAS_EXPIRED":"Your session has expired, please log in again.","errors.TOO_MANY_REQUESTS":"Request limit reached. Please try again later.","errors.UNAUTHORIZED":"You are not authorized to perform this action.","errors.all_password_fields_required":"All password fields are required","errors.auth.INVALID_API_KEY":"Invalid API key","errors.auth.INVALID_CREDENTIALS":"Incorrect username and/or password","errors.auth.NO_PERMISSION":"Insufficient permissions","errors.auth.SESSION_EXPIRED":"Your session has expired. Please log in again.","errors.auth.TOO_MANY_REQUESTS":"Too many attempts. Please wait 15 minutes and try again","errors.auth.UNAUTHORIZED":"You don't have permission to perform this action","errors.auth.USER_NOT_ACTIVE":"User account is not active","errors.auth.USER_NOT_FOUND":"User not found","errors.data.BAD_REQUEST":"Invalid request","errors.data.FIELD_ERROR":"Error in the provided data","errors.data.IN_USE":"The item is in use and cannot be deleted","errors.data.ITEM_NOT_FOUND":"The requested item was not found","errors.data.NOT_FOUND":"The requested resource was not found","errors.internal_error_changing_password":"Internal error changing password. Please try again","errors.password_min_length":"Password must be at least 8 characters","errors.password_mismatch":"Passwords do not match","errors.password_must_be_different":"New password must be different from current password","errors.system.DATABASE_CONNECTION_ERROR":"Connection error. Please check your internet connection.","errors.system.INTERNAL_SERVER_ERROR":"Internal server error. Please try again.","errors.system.INVALID_CONFIGURATION":"System configuration error","errors.system.TOO_MANY_REQUESTS":"Too many requests. Please wait a moment and try again","errors.system.UNKNOWN_OPERATION":"Unrecognized operation","errors.users_module_not_configured":"Users module not configured","footer.copyright":"Nocios S.R.L. All Rights Reserved.","footer.version":"Version","forgotPassword.checkEmailInstructions":"Check your inbox for the verification code","forgotPassword.codeAlreadyExistsMessage":"A code was already sent and is still valid","forgotPassword.emailLabel":"Email Address","forgotPassword.emailPlaceholder":"Enter your email address","forgotPassword.emailRequired":"Email address is required","forgotPassword.emailSentMessage":"Code sent successfully","forgotPassword.enterCodeLink":"Enter Code","forgotPassword.instructions":"Enter your email address and we'll send you a code to reset your password.","forgotPassword.invalidEmail":"Enter a valid email address","forgotPassword.sendCodeButton":"Send Code","forgotPassword.title":"Reset Password","loading.app.configInitial":"Loading initial configuration...","loading.app.generic":"Loading...","loading.app.starting":"Starting application...","loading.app.themeSetup":"Generating theme...","loading.app.validatingSession":"Validating session...","login.alreadyHaveCodeLink":"Already have a code?","login.forgotPasswordLink":"Forgot Password?","login.initializationError":"Initialization error","login.initializing":"Initializing...","login.loginButton":"Log In","login.logoAlt":"Logo","login.noAccountPrompt":"Don't have an account?","login.notInitialized":"System not initialized","login.passwordLabel":"Password","login.passwordPlaceholder":"Enter your password","login.passwordRequired":"Password is required","login.signUpLink":"Sign up","login.usernameOrEmailLabel":"Username or Email","login.usernameOrEmailPlaceholder":"Enter your username or email","login.usernameRequired":"Username or email is required","resetPassword.codeExpiredOrInvalid":"Code expired or invalid","resetPassword.confirmPasswordLabel":"Confirm Password","resetPassword.confirmPasswordPlaceholder":"Confirm your new password","resetPassword.confirmPasswordRequired":"Confirm your password","resetPassword.goToLoginButton":"Go to Login","resetPassword.instructions":"Enter your new password.","resetPassword.invalidCode":"The verification code is invalid. Please check the link or request a new one.","resetPassword.missingParameters":"Missing required parameters","resetPassword.newPasswordLabel":"New Password","resetPassword.newPasswordPlaceholder":"Enter your new password","resetPassword.newPasswordRequired":"New password is required","resetPassword.passwordTooShort":"Password must be at least 8 characters","resetPassword.passwordsDoNotMatch":"Passwords do not match","resetPassword.requestNewCodeButton":"Request New Code","resetPassword.resetPasswordButton":"Reset Password","resetPassword.successInstructions":"You can now log in with your new password","resetPassword.successMessage":"Password reset successfully","resetPassword.title":"New Password","resetPassword.validatingCode":"Validating code..."}},Je= exports.getCriticalLanguages =()=>Object.keys(p),We= exports.getCriticalTranslations =s=>p[s]||p.es;var z="crudify_translations_",$e=3600*1e3,I= exports.TranslationService =class s{constructor(){this.isInitialized=!1}static getInstance(){return s.instance||(s.instance=new s),s.instance}async ensureInitialized(r,e="stg"){this.isInitialized||(_crudifybrowser2.default.config(e),await _crudifybrowser2.default.init(r),this.isInitialized=!0)}async fetchTranslations(r){let{subscriberKey:e,apiKey:o,sections:t,crudifyEnv:a="stg",urlTranslations:d}=r;await this.ensureInitialized(o,a);let n=this.getFromCache(e),g=n?this.isCacheExpired(n):!0;if(n&&!g)return console.log("\u{1F4E6} [TranslationService] Using cached translations"),this.mergeWithUrlTranslations(n.data.translations,d);try{console.log("\u{1F310} [TranslationService] Fetching from API via crudify SDK...");let c=await this.fetchFromAPI(t);return this.hasDataChanged(n,c)||!n?(console.log("\u{1F504} [TranslationService] Data changed, updating cache"),this.saveToCache(e,c)):(console.log("\u2705 [TranslationService] Data unchanged, refreshing cache timestamp"),this.refreshCacheTimestamp(e)),this.mergeWithUrlTranslations(c.translations,d)}catch(c){return console.error("\u274C [TranslationService] API fetch failed:",c),n?(console.warn("\u26A0\uFE0F [TranslationService] Using expired cache as fallback"),this.mergeWithUrlTranslations(n.data.translations,d)):(console.warn("\u26A0\uFE0F [TranslationService] Using critical bundle translations"),this.getCriticalTranslationsOnly())}}async fetchFromAPI(r){let e=await _crudifybrowser2.default.getTranslation(r);if(!e.success)throw new Error(`Crudify API error: ${e.errors?JSON.stringify(e.errors):"Unknown error"}`);if(!e.data)throw new Error("No translation data in response");return e.data}mergeWithUrlTranslations(r,e){if(!e||Object.keys(e).length===0)return r;let o={};return Object.keys(r).forEach(t=>{o[t]={...r[t],...e}}),o}hasDataChanged(r,e){if(!r||r.data.timestamp!==e.timestamp)return!0;let o=this.hashData(e.translations);return r.dataHash!==o}hashData(r){let e=JSON.stringify(r),o=0;for(let t=0;t<e.length;t++){let a=e.charCodeAt(t);o=(o<<5)-o+a,o=o&o}return o.toString(36)}saveToCache(r,e){try{let o=this.getCacheKey(r),t={data:e,cachedAt:Date.now(),dataHash:this.hashData(e.translations)};localStorage.setItem(o,JSON.stringify(t)),console.log("\u{1F4BE} [TranslationService] Saved to cache:",o)}catch(o){console.error("\u274C [TranslationService] Failed to save cache:",o)}}getFromCache(r){try{let e=this.getCacheKey(r),o=localStorage.getItem(e);return o?JSON.parse(o):null}catch(e){return console.error("\u274C [TranslationService] Failed to read cache:",e),null}}refreshCacheTimestamp(r){try{let e=this.getFromCache(r);if(e){e.cachedAt=Date.now();let o=this.getCacheKey(r);localStorage.setItem(o,JSON.stringify(e))}}catch(e){console.error("\u274C [TranslationService] Failed to refresh cache timestamp:",e)}}isCacheExpired(r){return Date.now()-r.cachedAt>$e}getCacheKey(r){return`${z}${r}`}getCriticalTranslationsOnly(){return p}invalidateCache(r){let e=this.getCacheKey(r);localStorage.removeItem(e),console.log("\u{1F5D1}\uFE0F [TranslationService] Cache invalidated:",e)}async prefetchTranslations(r){try{await this.fetchTranslations(r),console.log("\u2705 [TranslationService] Prefetch completed")}catch(e){console.error("\u274C [TranslationService] Prefetch failed:",e)}}clearAllCaches(){try{let e=Object.keys(localStorage).filter(o=>o.startsWith(z));e.forEach(o=>localStorage.removeItem(o)),console.log(`\u{1F5D1}\uFE0F [TranslationService] Cleared ${e.length} cache entries`)}catch(r){console.error("\u274C [TranslationService] Failed to clear caches:",r)}}async shutdown(){this.isInitialized&&(await _crudifybrowser2.default.shutdown(),this.isInitialized=!1)}},A= exports.translationService =I.getInstance();var Y=_react.createContext.call(void 0, null);function K(s,r,e){return{...s,...r,...e||{}}}var rr=({children:s,subscriberKey:r,apiKey:e,crudifyEnv:o="stg",sections:t,language:a="es",devTranslations:d,translationUrl:n,enableDebug:g=!1})=>{let[c,m]=_react.useState.call(void 0, {}),[T,R]=_react.useState.call(void 0, !0),[G,x]=_react.useState.call(void 0, null),[k,b]=_react.useState.call(void 0, void 0),U=_react.useCallback.call(void 0, async()=>{if(!n){b(void 0);return}try{g&&console.log(`\u{1F310} [TranslationsProvider] Fetching translations from URL: ${n}`);let i=await fetch(n);if(!i.ok)throw new Error(`Failed to fetch translations: ${i.statusText}`);let l=await i.json();b(l),g&&console.log("\u2705 [TranslationsProvider] URL translations loaded:",{keysCount:Object.keys(l).length})}catch(i){console.error("\u274C [TranslationsProvider] Failed to load URL translations:",i),b(void 0)}},[n,g]),E=_react.useCallback.call(void 0, async()=>{R(!0),x(null);try{await U();let i=await A.fetchTranslations({subscriberKey:r,apiKey:e,crudifyEnv:o,sections:t,urlTranslations:k}),l={};Object.keys(i).forEach(f=>{let u=p[f]||{},h=i[f]||{};l[f]=K(u,h,d)}),m(l),g&&console.log("\u2705 [TranslationsProvider] Loaded translations:",{languages:Object.keys(l),keysCount:Object.keys(l[a]||{}).length})}catch(i){console.error("\u274C [TranslationsProvider] Failed to load:",i),x(i.message);let l={};Object.keys(p).forEach(f=>{let u=p[f];l[f]=K(u,{},d)}),m(l)}finally{R(!1)}},[r,e,o,t,k,d,g,a,U]);_react.useEffect.call(void 0, ()=>{E();let i=setInterval(E,3600*1e3);return()=>clearInterval(i)},[E]);let j={t:_react.useMemo.call(void 0, ()=>(i,l)=>{let u=(c[a]||{})[i];if(!u){let h=Object.keys(c);for(let v of h)if(c[v][i]){u=c[v][i];break}}return u||(g&&console.warn(`\u26A0\uFE0F [TranslationsProvider] Missing translation: "${i}"`),u=i),l&&typeof u=="string"&&Object.entries(l).forEach(([h,v])=>{let J=new RegExp(`{{${h}}}`,"g");u=u.replace(J,String(v))}),u},[c,a,g]),language:a,availableLanguages:Object.keys(c),isLoading:T,error:G,refreshTranslations:E};if(T){let i=_optionalChain([p, 'access', _3 => _3[a], 'optionalAccess', _4 => _4.loading])||"Loading...";return _jsxruntime.jsx.call(void 0, "div",{children:i})}return _jsxruntime.jsx.call(void 0, Y.Provider,{value:j,children:s})},or= exports.useTranslations =()=>{let s=_react.useContext.call(void 0, Y);if(!s)throw new Error("useTranslations must be used within TranslationsProvider");return s};exports.AuthRoute = V; exports.CRITICAL_TRANSLATIONS = p; exports.CrudifyLogin = _chunkYQF2FVCXjs.a; exports.CrudifyThemeProvider = Ue; exports.ERROR_CODES = _chunkYIIUEOXCjs.a; exports.ERROR_SEVERITY_MAP = _chunkYIIUEOXCjs.b; exports.GlobalNotificationProvider = _chunkTLGRXZCSjs.d; exports.LoginComponent = _chunkYQF2FVCXjs.f; exports.POLICY_ACTIONS = _chunkYQF2FVCXjs.c; exports.PREFERRED_POLICY_ORDER = _chunkYQF2FVCXjs.d; exports.Policies = _chunkYQF2FVCXjs.e; exports.ProtectedRoute = M; exports.SessionDebugInfo = _chunkTLGRXZCSjs.h; exports.SessionLoadingScreen = L; exports.SessionManager = _chunkTLGRXZCSjs.b; exports.SessionProvider = _chunkTLGRXZCSjs.f; exports.SessionStatus = _chunkYQF2FVCXjs.g; exports.TokenStorage = _chunkTLGRXZCSjs.a; exports.TranslationService = I; exports.TranslationsProvider = rr; exports.UserProfileDisplay = _chunkYQF2FVCXjs.b; exports.createErrorTranslator = _chunkAT74WV5Wjs.e; exports.crudify = _crudifybrowser2.default; exports.decodeJwtSafely = _chunkAT74WV5Wjs.h; exports.extractSafeRedirectFromUrl = _; exports.getCookie = _chunkAT74WV5Wjs.a; exports.getCriticalLanguages = Je; exports.getCriticalTranslations = We; exports.getCurrentUserEmail = _chunkAT74WV5Wjs.i; exports.getErrorMessage = _chunkYIIUEOXCjs.e; exports.handleCrudifyError = _chunkYIIUEOXCjs.g; exports.isTokenExpired = _chunkAT74WV5Wjs.j; exports.parseApiError = _chunkYIIUEOXCjs.c; exports.parseJavaScriptError = _chunkYIIUEOXCjs.f; exports.parseTransactionError = _chunkYIIUEOXCjs.d; exports.secureLocalStorage = _chunkNNY4A73Vjs.b; exports.secureSessionStorage = _chunkNNY4A73Vjs.a; exports.translateError = _chunkAT74WV5Wjs.d; exports.translateErrorCode = _chunkAT74WV5Wjs.b; exports.translateErrorCodes = _chunkAT74WV5Wjs.c; exports.translationService = A; exports.useAuth = _chunkX3HSMDZ7js.b; exports.useCrudifyWithNotifications = _chunkX3HSMDZ7js.d; exports.useData = _chunkX3HSMDZ7js.c; exports.useGlobalNotification = _chunkTLGRXZCSjs.e; exports.useSession = _chunkTLGRXZCSjs.c; exports.useSessionContext = _chunkTLGRXZCSjs.g; exports.useTranslations = or; exports.useUserData = _chunkX3HSMDZ7js.a; exports.useUserProfile = _chunkTLGRXZCSjs.i; exports.validateInternalRedirect = y;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import{a as W,b as $,c as K,d as Z,e as Q,f as X,g as j}from"./chunk-ZA2SJDMK.mjs";import{a as ee,b as oe,c as re,d as se}from"./chunk-KNEHDX2M.mjs";import{a as E,b,c as N,d as I,e as _,f as F,g as a,h as M,i as Y}from"./chunk-CTDQEJAU.mjs";import{a as te,b as ie}from"./chunk-T2CPA46I.mjs";import{a as z,b as G,c as B,d as V,e as q,f as H,g as J}from"./chunk-BJ6PIVZR.mjs";import{a as d,b as L,c as A,d as k,e as U,h as O,i as D,j as w}from"./chunk-5JKS55SE.mjs";import{default as Qe}from"@nocios/crudify-browser";export*from"@nocios/crudify-browser";import{useMemo as ne}from"react";import{ThemeProvider as ae,createTheme as pe,CssBaseline as ce}from"@mui/material";import{jsx as me,jsxs as le}from"react/jsx-runtime";var fe=(o={})=>{try{let e=d("theme");if(e){let r=JSON.parse(decodeURIComponent(e));return{...o,...r}}}catch(e){console.warn("Error parsing theme from cookie:",e)}return o};function de({children:o,defaultTheme:e={},disableCssBaseline:r=!1}){let t=ne(()=>{let i=fe(e);return pe(i)},[e]);return le(ae,{theme:t,children:[!r&&me(ce,{}),o]})}import{Navigate as Se,useLocation as he}from"react-router-dom";import{Fragment as xe,jsx as p,jsxs as g}from"react/jsx-runtime";var ue={border:"5px solid rgba(0, 0, 0, 0.1)",borderTopColor:"#3B82F6",borderRadius:"50%",width:"50px",height:"50px",animation:"spin 1s linear infinite"},ge=()=>p("style",{children:`
1
+ import{a as he,b as Te,c as Re,d as Ee,e as ve,f as Ce,g as ye}from"./chunk-ZA2SJDMK.mjs";import{a as we,b as Se,c as Ie,d as Oe}from"./chunk-KNEHDX2M.mjs";import{a as W,b as ee,c as re,d as ae,e as ie,f as ne,g as P,h as ce,i as Pe}from"./chunk-CTDQEJAU.mjs";import{a as Ne,b as be}from"./chunk-T2CPA46I.mjs";import{a as de,b as le,c as ge,d as ue,e as pe,f as fe,g as me}from"./chunk-BJ6PIVZR.mjs";import{a as O,b as $,c as Q,d as X,e as Z,h as oe,i as se,j as te}from"./chunk-5JKS55SE.mjs";import{default as zr}from"@nocios/crudify-browser";export*from"@nocios/crudify-browser";import{useMemo as Le}from"react";import{ThemeProvider as _e,createTheme as Ae,CssBaseline as xe}from"@mui/material";import{jsx as De,jsxs as Fe}from"react/jsx-runtime";var ke=(s={})=>{try{let r=O("theme");if(r){let e=JSON.parse(decodeURIComponent(r));return{...s,...e}}}catch(r){console.warn("Error parsing theme from cookie:",r)}return s};function Ue({children:s,defaultTheme:r={},disableCssBaseline:e=!1}){let o=Le(()=>{let t=ke(r);return Ae(t)},[r]);return Fe(_e,{theme:o,children:[!e&&De(xe,{}),s]})}import{Navigate as Ke,useLocation as He}from"react-router-dom";import{Fragment as Ve,jsx as C,jsxs as D}from"react/jsx-runtime";var Me={border:"5px solid rgba(0, 0, 0, 0.1)",borderTopColor:"#3B82F6",borderRadius:"50%",width:"50px",height:"50px",animation:"spin 1s linear infinite"},qe=()=>C("style",{children:`
2
2
  @keyframes spin {
3
3
  0% { transform: rotate(0deg); }
4
4
  100% { transform: rotate(360deg); }
5
5
  }
6
- `});function m({stage:o="loading",message:e}){let t=e||{initializing:"Initializing application...","validating-session":"Validating session...",loading:"Loading..."}[o];return g(xe,{children:[p(ge,{}),g("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",width:"100vw",backgroundColor:"#f0f2f5",fontFamily:'"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',color:"#333",textAlign:"center",boxSizing:"border-box",padding:"20px",background:"#fff"},children:[p("div",{style:ue}),p("p",{style:{fontSize:"1.25em",fontWeight:"500",marginTop:"24px",color:"#1f2937"},children:t})]})]})}var Re=/^[a-zA-Z0-9\-_./\?=&%#]+$/,ye=[/^https?:\/\//i,/^ftp:\/\//i,/^\/\//,/javascript:/i,/data:/i,/vbscript:/i,/about:/i,/\.\.\//,/\.\.\\/,/%2e%2e%2f/i,/%2e%2e%5c/i,/%2f%2f/i,/%5c%5c/i,/[\x00-\x1f\x7f-\x9f]/,/\\/],c=(o,e="/")=>{if(!o||typeof o!="string")return e;let r=o.trim();if(!r)return e;if(!r.startsWith("/"))return console.warn("\u{1F6A8} Open redirect blocked (relative path):",o),e;if(!Re.test(r))return console.warn("\u{1F6A8} Open redirect blocked (invalid characters):",o),e;let t=r.toLowerCase();for(let s of ye)if(s.test(t))return console.warn("\u{1F6A8} Open redirect blocked (dangerous pattern):",o),e;let i=r.split("?")[0].split("/").filter(Boolean);if(i.length===0)return r;for(let s of i)if(s===".."||s.includes(":")||s.length>100)return console.warn("\u{1F6A8} Open redirect blocked (suspicious path part):",s),e;return r},l=(o,e="/")=>{try{let t=(typeof o=="string"?new URLSearchParams(o):o).get("redirect");if(!t)return e;let i=decodeURIComponent(t);return c(i,e)}catch(r){return console.warn("\u{1F6A8} Error parsing redirect parameter:",r),e}};import{Fragment as x,jsx as f}from"react/jsx-runtime";function R({children:o,loadingComponent:e,loginPath:r="/login"}){let{isAuthenticated:t,isLoading:i,isInitialized:s,tokens:n,error:h}=a(),u=he();if(!s||i)return f(x,{children:e||f(m,{stage:"validating-session"})});let P=t&&n?.accessToken&&n.accessToken.length>0;if(h||!t||!P){n&&(!n.accessToken||n.accessToken.length===0)&&localStorage.removeItem("crudify_tokens");let C=u.pathname+u.search,v=c(C),T=encodeURIComponent(v);return f(Se,{to:`${r}?redirect=${T}`,replace:!0})}return f(x,{children:o})}import{Navigate as Pe,useLocation as Ce}from"react-router-dom";import{Fragment as ve,jsx as y}from"react/jsx-runtime";function S({children:o,redirectTo:e="/"}){let{isAuthenticated:r}=a(),t=Ce();if(r){let i=new URLSearchParams(t.search),s=l(i,e);return y(Pe,{to:s,replace:!0})}return y(ve,{children:o})}export{S as AuthRoute,W as CrudifyLogin,de as CrudifyThemeProvider,z as ERROR_CODES,G as ERROR_SEVERITY_MAP,I as GlobalNotificationProvider,X as LoginComponent,K as POLICY_ACTIONS,Z as PREFERRED_POLICY_ORDER,Q as Policies,R as ProtectedRoute,M as SessionDebugInfo,m as SessionLoadingScreen,b as SessionManager,F as SessionProvider,j as SessionStatus,E as TokenStorage,$ as UserProfileDisplay,U as createErrorTranslator,Qe as crudify,O as decodeJwtSafely,l as extractSafeRedirectFromUrl,d as getCookie,D as getCurrentUserEmail,q as getErrorMessage,J as handleCrudifyError,w as isTokenExpired,B as parseApiError,H as parseJavaScriptError,V as parseTransactionError,ie as secureLocalStorage,te as secureSessionStorage,k as translateError,L as translateErrorCode,A as translateErrorCodes,oe as useAuth,se as useCrudifyWithNotifications,re as useData,_ as useGlobalNotification,N as useSession,a as useSessionContext,ee as useUserData,Y as useUserProfile,c as validateInternalRedirect};
6
+ `});function L({stage:s="loading",message:r}){let o=r||{initializing:"Initializing application...","validating-session":"Validating session...",loading:"Loading..."}[s];return D(Ve,{children:[C(qe,{}),D("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",width:"100vw",backgroundColor:"#f0f2f5",fontFamily:'"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',color:"#333",textAlign:"center",boxSizing:"border-box",padding:"20px",background:"#fff"},children:[C("div",{style:Me}),C("p",{style:{fontSize:"1.25em",fontWeight:"500",marginTop:"24px",color:"#1f2937"},children:o})]})]})}var ze=/^[a-zA-Z0-9\-_./\?=&%#]+$/,Be=[/^https?:\/\//i,/^ftp:\/\//i,/^\/\//,/javascript:/i,/data:/i,/vbscript:/i,/about:/i,/\.\.\//,/\.\.\\/,/%2e%2e%2f/i,/%2e%2e%5c/i,/%2f%2f/i,/%5c%5c/i,/[\x00-\x1f\x7f-\x9f]/,/\\/],y=(s,r="/")=>{if(!s||typeof s!="string")return r;let e=s.trim();if(!e)return r;if(!e.startsWith("/"))return console.warn("\u{1F6A8} Open redirect blocked (relative path):",s),r;if(!ze.test(e))return console.warn("\u{1F6A8} Open redirect blocked (invalid characters):",s),r;let o=e.toLowerCase();for(let a of Be)if(a.test(o))return console.warn("\u{1F6A8} Open redirect blocked (dangerous pattern):",s),r;let t=e.split("?")[0].split("/").filter(Boolean);if(t.length===0)return e;for(let a of t)if(a===".."||a.includes(":")||a.length>100)return console.warn("\u{1F6A8} Open redirect blocked (suspicious path part):",a),r;return e},_=(s,r="/")=>{try{let o=(typeof s=="string"?new URLSearchParams(s):s).get("redirect");if(!o)return r;let t=decodeURIComponent(o);return y(t,r)}catch(e){return console.warn("\u{1F6A8} Error parsing redirect parameter:",e),r}};import{Fragment as F,jsx as w}from"react/jsx-runtime";function M({children:s,loadingComponent:r,loginPath:e="/login"}){let{isAuthenticated:o,isLoading:t,isInitialized:a,tokens:d,error:n}=P(),g=He();if(!a||t)return w(F,{children:r||w(L,{stage:"validating-session"})});let c=o&&d?.accessToken&&d.accessToken.length>0;if(n||!o||!c){d&&(!d.accessToken||d.accessToken.length===0)&&localStorage.removeItem("crudify_tokens");let m=g.pathname+g.search,T=y(m),R=encodeURIComponent(T);return w(Ke,{to:`${e}?redirect=${R}`,replace:!0})}return w(F,{children:s})}import{Navigate as Ye,useLocation as Ge}from"react-router-dom";import{Fragment as je,jsx as q}from"react/jsx-runtime";function V({children:s,redirectTo:r="/"}){let{isAuthenticated:e}=P(),o=Ge();if(e){let t=new URLSearchParams(o.search),a=_(t,r);return q(Ye,{to:a,replace:!0})}return q(je,{children:s})}import{createContext as Qe,useContext as Xe,useEffect as Ze,useState as N,useMemo as er,useCallback as B}from"react";import S from"@nocios/crudify-browser";var p={es:{"checkCode.codeLabel":"C\xF3digo de Verificaci\xF3n","checkCode.codePlaceholder":"Ingresa el c\xF3digo de 6 d\xEDgitos","checkCode.codeRequired":"El c\xF3digo es obligatorio","checkCode.emailLabel":"Correo Electr\xF3nico","checkCode.emailPlaceholder":"Ingresa tu correo electr\xF3nico","checkCode.emailRequired":"El correo electr\xF3nico es obligatorio","checkCode.instructions":"Ingresa el c\xF3digo de 6 d\xEDgitos que enviamos a tu correo electr\xF3nico.","checkCode.invalidEmail":"Ingresa un correo electr\xF3nico v\xE1lido","checkCode.resendCodeLink":"Reenviar c\xF3digo","checkCode.title":"Verificar C\xF3digo","checkCode.verifyButton":"Verificar C\xF3digo","common.back":"Volver","common.backToLogin":"Volver","error.app.config":"Error de Configuraci\xF3n: {{message}}","error.app.initialization":"Error durante la inicializaci\xF3n final de la aplicaci\xF3n.","error.transaction":"Error en la operaci\xF3n","error.unknown":"Ocurri\xF3 un error desconocido.","errors.DUPLICATE":"El campo <b>{{field}}</b> debe ser \xFAnico.","errors.FOREIGN_KEY_NOT_FOUND":"El campo <b>{{field}}</b> debe referenciar un \xEDtem existente.","errors.INVALID_EMAIL":"El campo <b>{{field}}</b> debe ser un correo electr\xF3nico v\xE1lido.","errors.INVALID_OBJECT_ID":"El campo <b>{{field}}</b> debe ser un valor v\xE1lido.","errors.IN_USE":"El \xEDtem est\xE1 en uso y no puede ser eliminado.","errors.MAX_LENGTH":"El campo <b>{{field}}</b> no debe exceder los <b>{{length}}</b> caracteres.","errors.MIN_LENGTH":"El campo <b>{{field}}</b> debe tener al menos <b>{{length}}</b> caracteres.","errors.MUST_NOT_BE_EMAIL":"El campo <b>{{field}}</b> no debe ser un correo electr\xF3nico.","errors.NO_PERMISSION":"No tienes permiso para realizar esta acci\xF3n.","errors.NO_SPACES":"El campo <b>{{field}}</b> no debe contener espacios.","errors.ONE_OR_MORE_OPERATIONS_FAILED":"Error en la operaci\xF3n","errors.REQUIRED":"El campo <b>{{field}}</b> es obligatorio.","errors.TOKEN_HAS_EXPIRED":"La sesi\xF3n ha expirado. Por favor, inicia sesi\xF3n nuevamente.","errors.TOO_MANY_REQUESTS":"L\xEDmite de solicitudes alcanzado. Por favor intenta m\xE1s tarde.","errors.UNAUTHORIZED":"No est\xE1s autorizado para realizar esta acci\xF3n.","errors.all_password_fields_required":"Todos los campos de contrase\xF1a son obligatorios","errors.auth.INVALID_API_KEY":"Clave de API inv\xE1lida","errors.auth.INVALID_CREDENTIALS":"Usuario y/o contrase\xF1a incorrectos","errors.auth.NO_PERMISSION":"No tienes permisos suficientes","errors.auth.SESSION_EXPIRED":"Tu sesi\xF3n ha expirado. Por favor, inicia sesi\xF3n nuevamente.","errors.auth.TOO_MANY_REQUESTS":"Demasiados intentos. Por favor espera 15 minutos e intenta nuevamente","errors.auth.UNAUTHORIZED":"No tienes permisos para realizar esta acci\xF3n","errors.auth.USER_NOT_ACTIVE":"Usuario no activo","errors.auth.USER_NOT_FOUND":"Usuario no encontrado","errors.data.BAD_REQUEST":"Solicitud inv\xE1lida","errors.data.FIELD_ERROR":"Error en los datos ingresados","errors.data.IN_USE":"El elemento est\xE1 en uso y no puede ser eliminado","errors.data.ITEM_NOT_FOUND":"El elemento solicitado no fue encontrado","errors.data.NOT_FOUND":"No se encontr\xF3 lo solicitado","errors.internal_error_changing_password":"Error interno al cambiar la contrase\xF1a. Intenta nuevamente","errors.password_min_length":"La contrase\xF1a debe tener al menos 8 caracteres","errors.password_mismatch":"Las contrase\xF1as no coinciden","errors.password_must_be_different":"La nueva contrase\xF1a debe ser diferente a la actual","errors.system.DATABASE_CONNECTION_ERROR":"Error de conexi\xF3n. Verifica tu conexi\xF3n a internet.","errors.system.INTERNAL_SERVER_ERROR":"Error interno del servidor. Intenta nuevamente.","errors.system.INVALID_CONFIGURATION":"Error de configuraci\xF3n del sistema","errors.system.TOO_MANY_REQUESTS":"Demasiadas solicitudes. Por favor espera un momento e intenta nuevamente","errors.system.UNKNOWN_OPERATION":"Operaci\xF3n no reconocida","errors.users_module_not_configured":"M\xF3dulo de usuarios no configurado","footer.copyright":"Nocios S.R.L. Todos los derechos reservados.","footer.version":"Versi\xF3n","forgotPassword.checkEmailInstructions":"Revisa tu bandeja de entrada para el c\xF3digo de verificaci\xF3n","forgotPassword.codeAlreadyExistsMessage":"Ya se envi\xF3 un c\xF3digo y a\xFAn es v\xE1lido","forgotPassword.emailLabel":"Correo Electr\xF3nico","forgotPassword.emailPlaceholder":"Ingresa tu correo electr\xF3nico","forgotPassword.emailRequired":"El correo electr\xF3nico es obligatorio","forgotPassword.emailSentMessage":"C\xF3digo enviado exitosamente","forgotPassword.enterCodeLink":"Ingresar C\xF3digo","forgotPassword.instructions":"Ingresa tu correo electr\xF3nico y te enviaremos un c\xF3digo para restablecer tu contrase\xF1a.","forgotPassword.invalidEmail":"Ingresa un correo electr\xF3nico v\xE1lido","forgotPassword.sendCodeButton":"Enviar C\xF3digo","forgotPassword.title":"Recuperar Contrase\xF1a","loading.app.configInitial":"Cargando configuraci\xF3n inicial...","loading.app.generic":"Cargando...","loading.app.starting":"Iniciando aplicaci\xF3n...","loading.app.themeSetup":"Generando tema...","loading.app.validatingSession":"Validando sesi\xF3n...","login.alreadyHaveCodeLink":"\xBFYa tienes un c\xF3digo?","login.forgotPasswordLink":"\xBFOlvidaste tu contrase\xF1a?","login.initializationError":"Error de inicializaci\xF3n","login.initializing":"Inicializando...","login.loginButton":"Iniciar Sesi\xF3n","login.logoAlt":"Logotipo","login.noAccountPrompt":"\xBFNo tienes una cuenta?","login.notInitialized":"Sistema no inicializado","login.passwordLabel":"Contrase\xF1a","login.passwordPlaceholder":"Ingresa tu contrase\xF1a","login.passwordRequired":"Contrase\xF1a es obligatoria","login.signUpLink":"Reg\xEDstrate","login.usernameOrEmailLabel":"Usuario o Correo Electr\xF3nico","login.usernameOrEmailPlaceholder":"Ingresa tu usuario o correo electr\xF3nico","login.usernameRequired":"Usuario o correo electr\xF3nico es obligatorio","resetPassword.codeExpiredOrInvalid":"El c\xF3digo ha expirado o es inv\xE1lido","resetPassword.confirmPasswordLabel":"Confirmar Contrase\xF1a","resetPassword.confirmPasswordPlaceholder":"Confirma tu nueva contrase\xF1a","resetPassword.confirmPasswordRequired":"Confirma tu contrase\xF1a","resetPassword.goToLoginButton":"Ir al Login","resetPassword.instructions":"Ingresa tu nueva contrase\xF1a.","resetPassword.invalidCode":"El c\xF3digo de verificaci\xF3n es inv\xE1lido. Por favor, verifica el enlace o solicita uno nuevo.","resetPassword.missingParameters":"Faltan par\xE1metros obligatorios","resetPassword.newPasswordLabel":"Nueva Contrase\xF1a","resetPassword.newPasswordPlaceholder":"Ingresa tu nueva contrase\xF1a","resetPassword.newPasswordRequired":"La nueva contrase\xF1a es obligatoria","resetPassword.passwordTooShort":"La contrase\xF1a debe tener al menos 8 caracteres","resetPassword.passwordsDoNotMatch":"Las contrase\xF1as no coinciden","resetPassword.requestNewCodeButton":"Solicitar Nuevo C\xF3digo","resetPassword.resetPasswordButton":"Restablecer Contrase\xF1a","resetPassword.successInstructions":"Ahora puedes iniciar sesi\xF3n con tu nueva contrase\xF1a","resetPassword.successMessage":"Contrase\xF1a restablecida exitosamente","resetPassword.title":"Nueva Contrase\xF1a","resetPassword.validatingCode":"Validando c\xF3digo..."},en:{"checkCode.codeLabel":"Verification Code","checkCode.codePlaceholder":"Enter 6-digit code","checkCode.codeRequired":"Code is required","checkCode.emailLabel":"Email Address","checkCode.emailPlaceholder":"Enter your email address","checkCode.emailRequired":"Email address is required","checkCode.instructions":"Enter the 6-digit code we sent to your email address.","checkCode.invalidEmail":"Enter a valid email address","checkCode.resendCodeLink":"Resend code","checkCode.title":"Verify Code","checkCode.verifyButton":"Verify Code","common.back":"Back","common.backToLogin":"Back to Login","error.app.config":"Configuration Error: {{message}}","error.app.initialization":"Error during final application initialization.","error.transaction":"Operation error","error.unknown":"An unknown error occurred.","errors.DUPLICATE":"The field <b>{{field}}</b> must be unique.","errors.FOREIGN_KEY_NOT_FOUND":"The field <b>{{field}}</b> must reference an existing item.","errors.INVALID_EMAIL":"The field <b>{{field}}</b> must be a valid email address.","errors.INVALID_OBJECT_ID":"The field <b>{{field}}</b> must be a valid value.","errors.IN_USE":"The item is currently in use and cannot be deleted.","errors.MAX_LENGTH":"The field <b>{{field}}</b> must not exceed <b>{{maxLength}}</b> characters.","errors.MIN_LENGTH":"The field <b>{{field}}</b> must have at least <b>{{minLength}}</b> characters.","errors.MUST_NOT_BE_EMAIL":"The field <b>{{field}}</b> must not be an email address.","errors.NO_PERMISSION":"You do not have permission to perform this action.","errors.NO_SPACES":"The field <b>{{field}}</b> must not contain spaces.","errors.ONE_OR_MORE_OPERATIONS_FAILED":"Operation error","errors.REQUIRED":"The field <b>{{field}}</b> is required.","errors.TOKEN_HAS_EXPIRED":"Your session has expired, please log in again.","errors.TOO_MANY_REQUESTS":"Request limit reached. Please try again later.","errors.UNAUTHORIZED":"You are not authorized to perform this action.","errors.all_password_fields_required":"All password fields are required","errors.auth.INVALID_API_KEY":"Invalid API key","errors.auth.INVALID_CREDENTIALS":"Incorrect username and/or password","errors.auth.NO_PERMISSION":"Insufficient permissions","errors.auth.SESSION_EXPIRED":"Your session has expired. Please log in again.","errors.auth.TOO_MANY_REQUESTS":"Too many attempts. Please wait 15 minutes and try again","errors.auth.UNAUTHORIZED":"You don't have permission to perform this action","errors.auth.USER_NOT_ACTIVE":"User account is not active","errors.auth.USER_NOT_FOUND":"User not found","errors.data.BAD_REQUEST":"Invalid request","errors.data.FIELD_ERROR":"Error in the provided data","errors.data.IN_USE":"The item is in use and cannot be deleted","errors.data.ITEM_NOT_FOUND":"The requested item was not found","errors.data.NOT_FOUND":"The requested resource was not found","errors.internal_error_changing_password":"Internal error changing password. Please try again","errors.password_min_length":"Password must be at least 8 characters","errors.password_mismatch":"Passwords do not match","errors.password_must_be_different":"New password must be different from current password","errors.system.DATABASE_CONNECTION_ERROR":"Connection error. Please check your internet connection.","errors.system.INTERNAL_SERVER_ERROR":"Internal server error. Please try again.","errors.system.INVALID_CONFIGURATION":"System configuration error","errors.system.TOO_MANY_REQUESTS":"Too many requests. Please wait a moment and try again","errors.system.UNKNOWN_OPERATION":"Unrecognized operation","errors.users_module_not_configured":"Users module not configured","footer.copyright":"Nocios S.R.L. All Rights Reserved.","footer.version":"Version","forgotPassword.checkEmailInstructions":"Check your inbox for the verification code","forgotPassword.codeAlreadyExistsMessage":"A code was already sent and is still valid","forgotPassword.emailLabel":"Email Address","forgotPassword.emailPlaceholder":"Enter your email address","forgotPassword.emailRequired":"Email address is required","forgotPassword.emailSentMessage":"Code sent successfully","forgotPassword.enterCodeLink":"Enter Code","forgotPassword.instructions":"Enter your email address and we'll send you a code to reset your password.","forgotPassword.invalidEmail":"Enter a valid email address","forgotPassword.sendCodeButton":"Send Code","forgotPassword.title":"Reset Password","loading.app.configInitial":"Loading initial configuration...","loading.app.generic":"Loading...","loading.app.starting":"Starting application...","loading.app.themeSetup":"Generating theme...","loading.app.validatingSession":"Validating session...","login.alreadyHaveCodeLink":"Already have a code?","login.forgotPasswordLink":"Forgot Password?","login.initializationError":"Initialization error","login.initializing":"Initializing...","login.loginButton":"Log In","login.logoAlt":"Logo","login.noAccountPrompt":"Don't have an account?","login.notInitialized":"System not initialized","login.passwordLabel":"Password","login.passwordPlaceholder":"Enter your password","login.passwordRequired":"Password is required","login.signUpLink":"Sign up","login.usernameOrEmailLabel":"Username or Email","login.usernameOrEmailPlaceholder":"Enter your username or email","login.usernameRequired":"Username or email is required","resetPassword.codeExpiredOrInvalid":"Code expired or invalid","resetPassword.confirmPasswordLabel":"Confirm Password","resetPassword.confirmPasswordPlaceholder":"Confirm your new password","resetPassword.confirmPasswordRequired":"Confirm your password","resetPassword.goToLoginButton":"Go to Login","resetPassword.instructions":"Enter your new password.","resetPassword.invalidCode":"The verification code is invalid. Please check the link or request a new one.","resetPassword.missingParameters":"Missing required parameters","resetPassword.newPasswordLabel":"New Password","resetPassword.newPasswordPlaceholder":"Enter your new password","resetPassword.newPasswordRequired":"New password is required","resetPassword.passwordTooShort":"Password must be at least 8 characters","resetPassword.passwordsDoNotMatch":"Passwords do not match","resetPassword.requestNewCodeButton":"Request New Code","resetPassword.resetPasswordButton":"Reset Password","resetPassword.successInstructions":"You can now log in with your new password","resetPassword.successMessage":"Password reset successfully","resetPassword.title":"New Password","resetPassword.validatingCode":"Validating code..."}},Je=()=>Object.keys(p),We=s=>p[s]||p.es;var z="crudify_translations_",$e=3600*1e3,I=class s{constructor(){this.isInitialized=!1}static getInstance(){return s.instance||(s.instance=new s),s.instance}async ensureInitialized(r,e="stg"){this.isInitialized||(S.config(e),await S.init(r),this.isInitialized=!0)}async fetchTranslations(r){let{subscriberKey:e,apiKey:o,sections:t,crudifyEnv:a="stg",urlTranslations:d}=r;await this.ensureInitialized(o,a);let n=this.getFromCache(e),g=n?this.isCacheExpired(n):!0;if(n&&!g)return console.log("\u{1F4E6} [TranslationService] Using cached translations"),this.mergeWithUrlTranslations(n.data.translations,d);try{console.log("\u{1F310} [TranslationService] Fetching from API via crudify SDK...");let c=await this.fetchFromAPI(t);return this.hasDataChanged(n,c)||!n?(console.log("\u{1F504} [TranslationService] Data changed, updating cache"),this.saveToCache(e,c)):(console.log("\u2705 [TranslationService] Data unchanged, refreshing cache timestamp"),this.refreshCacheTimestamp(e)),this.mergeWithUrlTranslations(c.translations,d)}catch(c){return console.error("\u274C [TranslationService] API fetch failed:",c),n?(console.warn("\u26A0\uFE0F [TranslationService] Using expired cache as fallback"),this.mergeWithUrlTranslations(n.data.translations,d)):(console.warn("\u26A0\uFE0F [TranslationService] Using critical bundle translations"),this.getCriticalTranslationsOnly())}}async fetchFromAPI(r){let e=await S.getTranslation(r);if(!e.success)throw new Error(`Crudify API error: ${e.errors?JSON.stringify(e.errors):"Unknown error"}`);if(!e.data)throw new Error("No translation data in response");return e.data}mergeWithUrlTranslations(r,e){if(!e||Object.keys(e).length===0)return r;let o={};return Object.keys(r).forEach(t=>{o[t]={...r[t],...e}}),o}hasDataChanged(r,e){if(!r||r.data.timestamp!==e.timestamp)return!0;let o=this.hashData(e.translations);return r.dataHash!==o}hashData(r){let e=JSON.stringify(r),o=0;for(let t=0;t<e.length;t++){let a=e.charCodeAt(t);o=(o<<5)-o+a,o=o&o}return o.toString(36)}saveToCache(r,e){try{let o=this.getCacheKey(r),t={data:e,cachedAt:Date.now(),dataHash:this.hashData(e.translations)};localStorage.setItem(o,JSON.stringify(t)),console.log("\u{1F4BE} [TranslationService] Saved to cache:",o)}catch(o){console.error("\u274C [TranslationService] Failed to save cache:",o)}}getFromCache(r){try{let e=this.getCacheKey(r),o=localStorage.getItem(e);return o?JSON.parse(o):null}catch(e){return console.error("\u274C [TranslationService] Failed to read cache:",e),null}}refreshCacheTimestamp(r){try{let e=this.getFromCache(r);if(e){e.cachedAt=Date.now();let o=this.getCacheKey(r);localStorage.setItem(o,JSON.stringify(e))}}catch(e){console.error("\u274C [TranslationService] Failed to refresh cache timestamp:",e)}}isCacheExpired(r){return Date.now()-r.cachedAt>$e}getCacheKey(r){return`${z}${r}`}getCriticalTranslationsOnly(){return p}invalidateCache(r){let e=this.getCacheKey(r);localStorage.removeItem(e),console.log("\u{1F5D1}\uFE0F [TranslationService] Cache invalidated:",e)}async prefetchTranslations(r){try{await this.fetchTranslations(r),console.log("\u2705 [TranslationService] Prefetch completed")}catch(e){console.error("\u274C [TranslationService] Prefetch failed:",e)}}clearAllCaches(){try{let e=Object.keys(localStorage).filter(o=>o.startsWith(z));e.forEach(o=>localStorage.removeItem(o)),console.log(`\u{1F5D1}\uFE0F [TranslationService] Cleared ${e.length} cache entries`)}catch(r){console.error("\u274C [TranslationService] Failed to clear caches:",r)}}async shutdown(){this.isInitialized&&(await S.shutdown(),this.isInitialized=!1)}},A=I.getInstance();import{jsx as H}from"react/jsx-runtime";var Y=Qe(null);function K(s,r,e){return{...s,...r,...e||{}}}var rr=({children:s,subscriberKey:r,apiKey:e,crudifyEnv:o="stg",sections:t,language:a="es",devTranslations:d,translationUrl:n,enableDebug:g=!1})=>{let[c,m]=N({}),[T,R]=N(!0),[G,x]=N(null),[k,b]=N(void 0),U=B(async()=>{if(!n){b(void 0);return}try{g&&console.log(`\u{1F310} [TranslationsProvider] Fetching translations from URL: ${n}`);let i=await fetch(n);if(!i.ok)throw new Error(`Failed to fetch translations: ${i.statusText}`);let l=await i.json();b(l),g&&console.log("\u2705 [TranslationsProvider] URL translations loaded:",{keysCount:Object.keys(l).length})}catch(i){console.error("\u274C [TranslationsProvider] Failed to load URL translations:",i),b(void 0)}},[n,g]),E=B(async()=>{R(!0),x(null);try{await U();let i=await A.fetchTranslations({subscriberKey:r,apiKey:e,crudifyEnv:o,sections:t,urlTranslations:k}),l={};Object.keys(i).forEach(f=>{let u=p[f]||{},h=i[f]||{};l[f]=K(u,h,d)}),m(l),g&&console.log("\u2705 [TranslationsProvider] Loaded translations:",{languages:Object.keys(l),keysCount:Object.keys(l[a]||{}).length})}catch(i){console.error("\u274C [TranslationsProvider] Failed to load:",i),x(i.message);let l={};Object.keys(p).forEach(f=>{let u=p[f];l[f]=K(u,{},d)}),m(l)}finally{R(!1)}},[r,e,o,t,k,d,g,a,U]);Ze(()=>{E();let i=setInterval(E,3600*1e3);return()=>clearInterval(i)},[E]);let j={t:er(()=>(i,l)=>{let u=(c[a]||{})[i];if(!u){let h=Object.keys(c);for(let v of h)if(c[v][i]){u=c[v][i];break}}return u||(g&&console.warn(`\u26A0\uFE0F [TranslationsProvider] Missing translation: "${i}"`),u=i),l&&typeof u=="string"&&Object.entries(l).forEach(([h,v])=>{let J=new RegExp(`{{${h}}}`,"g");u=u.replace(J,String(v))}),u},[c,a,g]),language:a,availableLanguages:Object.keys(c),isLoading:T,error:G,refreshTranslations:E};if(T){let i=p[a]?.loading||"Loading...";return H("div",{children:i})}return H(Y.Provider,{value:j,children:s})},or=()=>{let s=Xe(Y);if(!s)throw new Error("useTranslations must be used within TranslationsProvider");return s};export{V as AuthRoute,p as CRITICAL_TRANSLATIONS,he as CrudifyLogin,Ue as CrudifyThemeProvider,de as ERROR_CODES,le as ERROR_SEVERITY_MAP,ae as GlobalNotificationProvider,Ce as LoginComponent,Re as POLICY_ACTIONS,Ee as PREFERRED_POLICY_ORDER,ve as Policies,M as ProtectedRoute,ce as SessionDebugInfo,L as SessionLoadingScreen,ee as SessionManager,ne as SessionProvider,ye as SessionStatus,W as TokenStorage,I as TranslationService,rr as TranslationsProvider,Te as UserProfileDisplay,Z as createErrorTranslator,zr as crudify,oe as decodeJwtSafely,_ as extractSafeRedirectFromUrl,O as getCookie,Je as getCriticalLanguages,We as getCriticalTranslations,se as getCurrentUserEmail,pe as getErrorMessage,me as handleCrudifyError,te as isTokenExpired,ge as parseApiError,fe as parseJavaScriptError,ue as parseTransactionError,be as secureLocalStorage,Ne as secureSessionStorage,X as translateError,$ as translateErrorCode,Q as translateErrorCodes,A as translationService,Se as useAuth,Oe as useCrudifyWithNotifications,Ie as useData,ie as useGlobalNotification,re as useSession,P as useSessionContext,or as useTranslations,we as useUserData,Pe as useUserProfile,y as validateInternalRedirect};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocios/crudify-ui",
3
- "version": "4.1.21",
3
+ "version": "4.1.22",
4
4
  "description": "Biblioteca de componentes UI para Crudify",
5
5
  "author": "Nocios",
6
6
  "license": "MIT",
@@ -39,7 +39,7 @@
39
39
  "prepublishOnly": "npm run build"
40
40
  },
41
41
  "dependencies": {
42
- "@nocios/crudify-browser": "^4.0.8",
42
+ "@nocios/crudify-browser": "^4.0.84",
43
43
  "crypto-js": "^4.2.0",
44
44
  "dompurify": "^3.2.7",
45
45
  "uuid": "^13.0.0"