@nocios/crudify-ui 4.4.94 → 4.4.96
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/{CrudiaMarkdownField-Cjz4--Dq.d.mts → CrudiaMarkdownField-8s252xsM.d.mts} +4 -2
- package/dist/{CrudiaMarkdownField-ULba-5oD.d.ts → CrudiaMarkdownField-Dy2dVkBO.d.ts} +4 -2
- package/dist/{chunk-OTCV6Y6D.js → chunk-452ZFITE.js} +1 -1
- package/dist/{chunk-DXIXGRHJ.mjs → chunk-AD5AA75O.mjs} +1 -1
- package/dist/{chunk-QJI47CHZ.mjs → chunk-CUSGL4AB.mjs} +1 -1
- package/dist/{chunk-VQONBUHN.mjs → chunk-P2NHZZZY.mjs} +1 -1
- package/dist/{chunk-PIJQW44J.js → chunk-RMN7APOF.js} +1 -1
- package/dist/{chunk-KCWS6BRD.js → chunk-VM6JVOLD.js} +1 -1
- package/dist/components.d.mts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/components.js +1 -1
- package/dist/components.mjs +1 -1
- package/dist/hooks.d.mts +1 -1
- package/dist/hooks.d.ts +1 -1
- package/dist/hooks.js +1 -1
- package/dist/hooks.mjs +1 -1
- package/dist/{index-e0fEu7Sq.d.mts → index-C4x7kAdv.d.mts} +2 -2
- package/dist/{index-By0tDIvO.d.ts → index-CEe4Y7WD.d.ts} +2 -2
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as Mr,c as ae,h as Wr,j as pe,l as Hr,m as qr,p as jr}from"./chunk-DXIXGRHJ.mjs";import{g as Y}from"./chunk-BJ6PIVZR.mjs";import{a as v,b as zr,c as Ur,h as Vr}from"./chunk-SUWV767V.mjs";var me={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":"Correo Electr\xF3nico","login.usernameOrEmailPlaceholder":"Ingresa tu correo electr\xF3nico","login.usernameRequired":"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...","modules.form.publicPolicies.fields.conditions.customEdit":"Edici\xF3n personalizada","file.clickToPreview":"Clic para ver imagen","file.clickToDownload":"Clic para descargar","file.privateFile":"Archivo privado","file.noPreview":"Sin vista previa","file.dropHere":"Suelta el archivo aqu\xED","file.dragOrClick":"Arrastra archivos aqu\xED o haz clic para seleccionar","file.uploading":"Subiendo archivos...","file.restore":"Restaurar","file.delete":"Eliminar","file.pendingDeletion":"Pendiente de eliminaci\xF3n","file.allowedTypes":"Tipos permitidos: {{types}}","file.maxSize":"M\xE1ximo {{size}} por archivo","file.maxFiles":"M\xE1ximo {{count}} archivos","file.validation.minFilesRequired":"Se requiere al menos un archivo","file.validation.minFilesRequiredPlural":"Se requieren al menos {{count}} archivos","file.validation.maxFilesExceeded":"M\xE1ximo {{count}} archivos permitidos","file.validation.filesWithErrors":"Algunos archivos tienen errores","file.confirmDelete.title":"Eliminar archivo","file.confirmDelete.message":"\xBFEst\xE1s seguro de que deseas eliminar este archivo? Esta acci\xF3n no se puede deshacer.","file.confirmDelete.confirm":"Eliminar","file.confirmDelete.cancel":"Cancelar","file.deleting":"Eliminando..."},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...","modules.form.publicPolicies.fields.conditions.customEdit":"Custom Edit","file.clickToPreview":"Click to preview","file.clickToDownload":"Click to download","file.privateFile":"Private file","file.noPreview":"No preview","file.dropHere":"Drop file here","file.dragOrClick":"Drag files here or click to select","file.uploading":"Uploading files...","file.restore":"Restore","file.delete":"Delete","file.pendingDeletion":"Pending deletion","file.allowedTypes":"Allowed types: {{types}}","file.maxSize":"Max {{size}} per file","file.maxFiles":"Max {{count}} files","file.validation.minFilesRequired":"At least one file is required","file.validation.minFilesRequiredPlural":"At least {{count}} files are required","file.validation.maxFilesExceeded":"Maximum {{count}} files allowed","file.validation.filesWithErrors":"Some files have errors","file.confirmDelete.title":"Delete file","file.confirmDelete.message":"Are you sure you want to delete this file? This action cannot be undone.","file.confirmDelete.confirm":"Delete","file.deleting":"Deleting...","file.confirmDelete.cancel":"Cancel"}},Gi=()=>Object.keys(me),Yi=e=>me[e]||me.es;import je from"@nocios/crudify-browser";var Kr="crudify_translations_",rt=3600*1e3;function $r(e){let r=0;for(let o=0;o<e.length;o++){let t=e.charCodeAt(o);r=(r<<5)-r+t,r=r&r}return Math.abs(r).toString(36)}var sr=class e{constructor(){this.enableDebug=!1;this.initializationPromise=null;this.isInitialized=!1}static getInstance(){return e.instance||(e.instance=new e),e.instance}setDebug(r){this.enableDebug=r}async ensureCrudifyInitialized(r,o){if(!this.isInitialized)return this.initializationPromise?(this.enableDebug&&v.debug("[TranslationService] Waiting for crudify initialization..."),this.initializationPromise):(this.enableDebug&&v.debug("[TranslationService] Initializing crudify SDK..."),this.initializationPromise=(async()=>{try{let t=je.getTokenData();if(t&&t.endpoint){this.enableDebug&&v.debug("[TranslationService] Crudify already initialized"),this.isInitialized=!0;return}je.config(o);let a=await je.init(r,this.enableDebug?"debug":"none");if(a.success===!1)throw new Error(`Failed to initialize crudify: ${JSON.stringify(a.errors||"Unknown error")}`);this.isInitialized=!0,this.enableDebug&&v.debug("[TranslationService] Crudify SDK initialized successfully")}catch(t){throw v.error("[TranslationService] Failed to initialize crudify",t instanceof Error?t:{message:String(t)}),this.initializationPromise=null,t}})(),this.initializationPromise)}async fetchTranslations(r){let{apiKey:o,featureKeys:t,crudifyEnv:a="stg",urlTranslations:i}=r;this.enableDebug&&v.debug("[TranslationService] fetchTranslations called with:",{apiKeyHash:$r(o),crudifyEnv:a,featureKeys:t,hasUrlTranslations:!!i});let n=this.getFromCache(o),s=n?this.isCacheExpired(n):!0;if(n&&!s)return this.enableDebug&&v.debug("[TranslationService] Using cached translations"),this.mergeWithUrlTranslations(n.data.translations,i);try{await this.ensureCrudifyInitialized(o,a)}catch(c){return v.error("[TranslationService] Failed to initialize crudify",c instanceof Error?c:{message:String(c)}),n?(v.warn("[TranslationService] Using expired cache (init failed)"),this.mergeWithUrlTranslations(n.data.translations,i)):(v.warn("[TranslationService] Using critical bundle (init failed)"),this.getCriticalTranslationsOnly())}try{this.enableDebug&&v.debug("[TranslationService] Fetching from API via crudify SDK");let c=await this.fetchFromAPI(t);this.hasDataChanged(n,c)||!n?this.saveToCache(o,c):this.refreshCacheTimestamp(o);let u=this.mergeWithUrlTranslations(c.translations,i);return this.enableDebug&&v.debug("[TranslationService] Translations loaded:",{languages:Object.keys(u),keysCount:u[Object.keys(u)[0]]?Object.keys(u[Object.keys(u)[0]]).length:0}),u}catch(c){return v.error("[TranslationService] API fetch failed",c instanceof Error?c:{message:String(c)}),n?(v.warn("[TranslationService] Using expired cache as fallback"),this.mergeWithUrlTranslations(n.data.translations,i)):(v.warn("[TranslationService] Using critical bundle translations"),this.getCriticalTranslationsOnly())}}async fetchFromAPI(r){let o=await je.getTranslation(r);if(!o.success)throw new Error(`Crudify API error: ${o.errors?JSON.stringify(o.errors):"Unknown error"}`);if(!o.data)throw new Error("No translation data in response");return o.data}mergeWithUrlTranslations(r,o){if(!o||Object.keys(o).length===0)return r;let t={};return Object.keys(r).forEach(a=>{t[a]={...r[a],...o}}),t}hasDataChanged(r,o){if(!r||r.data.timestamp!==o.timestamp)return!0;let t=this.hashData(o.translations);return r.dataHash!==t}hashData(r){let o=JSON.stringify(r),t=0;for(let a=0;a<o.length;a++){let i=o.charCodeAt(a);t=(t<<5)-t+i,t=t&t}return t.toString(36)}saveToCache(r,o){try{let t=this.getCacheKey(r),a={data:o,cachedAt:Date.now(),dataHash:this.hashData(o.translations)};localStorage.setItem(t,JSON.stringify(a)),this.enableDebug&&v.debug("[TranslationService] Saved to cache:",{cacheKey:t})}catch(t){v.error("[TranslationService] Failed to save cache",t instanceof Error?t:{message:String(t)})}}getFromCache(r){try{let o=this.getCacheKey(r),t=localStorage.getItem(o);return t?JSON.parse(t):null}catch(o){return v.error("[TranslationService] Failed to read cache",o instanceof Error?o:{message:String(o)}),null}}refreshCacheTimestamp(r){try{let o=this.getFromCache(r);if(o){o.cachedAt=Date.now();let t=this.getCacheKey(r);localStorage.setItem(t,JSON.stringify(o))}}catch(o){v.error("[TranslationService] Failed to refresh cache timestamp",o instanceof Error?o:{message:String(o)})}}isCacheExpired(r){return Date.now()-r.cachedAt>rt}hasValidCache(r){let o=this.getFromCache(r);return o?!this.isCacheExpired(o):!1}getCacheKey(r){return`${Kr}${$r(r)}`}getCriticalTranslationsOnly(){return me}invalidateCache(r){let o=this.getCacheKey(r);localStorage.removeItem(o),this.enableDebug&&v.debug("[TranslationService] Cache invalidated:",{cacheKey:o})}async prefetchTranslations(r){try{await this.fetchTranslations(r),this.enableDebug&&v.debug("[TranslationService] Prefetch completed")}catch(o){v.error("[TranslationService] Prefetch failed",o instanceof Error?o:{message:String(o)})}}clearAllCaches(){try{let o=Object.keys(localStorage).filter(t=>t.startsWith(Kr));o.forEach(t=>localStorage.removeItem(t)),this.enableDebug&&v.debug(`[TranslationService] Cleared ${o.length} cache entries`)}catch(r){v.error("[TranslationService] Failed to clear caches",r instanceof Error?r:{message:String(r)})}}},Ke=sr.getInstance();import{createContext as ot,useContext as tt,useEffect as Xr,useState as Ie,useMemo as Gr,useCallback as nt}from"react";import{Fragment as at,jsx as Ge}from"react/jsx-runtime";var $e=null,lr=!1,Jr=ot(null);function Yr(e,r,o){return{...e,...r,...o||{}}}function it(e,r,o,t,a){Xr(()=>{if(!t||!e||!r)return;let i=o||typeof window<"u"&&window.i18next||typeof window<"u"&&window.i18n;if(!i||!i.addResourceBundle){a&&v.debug("[TranslationsProvider] i18next not found, skipping auto-sync");return}a&&v.debug("[TranslationsProvider] Auto-syncing translations with i18next",{languages:Object.keys(e),currentLanguage:r}),Object.keys(e).forEach(n=>{e[n]&&Object.keys(e[n]).length>0&&(i.addResourceBundle(n,"translation",e[n],!0,!0),a&&v.debug(`[TranslationsProvider] Synced ${Object.keys(e[n]).length} keys for language: ${n}`))}),i.language!==r&&(i.changeLanguage(r),a&&v.debug(`[TranslationsProvider] Changed i18next language to: ${r}`))},[e,r,o,t,a])}var sa=({children:e,apiKey:r,crudifyEnv:o="prod",featureKeys:t,language:a="es",devTranslations:i,translationUrl:n,enableDebug:s=!1,skipAutoInit:c=!0,autoSyncI18n:y=!0,i18nInstance:u,loadingFallback:b,waitForInitialLoad:f=!0})=>{let l=Gr(()=>Ur({publicApiKey:r,env:o,featureKeys:t,enableDebug:s}),[r,o,t,s]),d=l.publicApiKey||"",w=l.env||o||"prod",m=l.featureKeys||t,[g,p]=Ie({}),[P,I]=Ie(!0),[M,x]=Ie(!0),[h,R]=Ie(null),[L,_]=Ie(void 0),[re,oe]=Ie(!1),de=nt(async()=>{if(!d){s&&v.debug("[TranslationsProvider] No apiKey - skipping translation fetch"),I(!1),x(!1);return}if(re){s&&v.debug("[TranslationsProvider] Skipping reload - using fallback translations");return}if(Ke.hasValidCache(d)&&M&&(s&&v.debug("[TranslationsProvider] Valid cache found - not blocking initial render"),x(!1)),lr&&$e){s&&v.debug("[TranslationsProvider] Fetch already in progress, waiting for existing promise");try{let S=await $e;p(S),I(!1);return}catch{s&&v.warn("[TranslationsProvider] Global fetch failed, retrying")}}lr=!0,I(!0),R(null);let N;if(n)try{s&&v.debug(`[TranslationsProvider] Fetching translations from URL: ${n}`);let S=await fetch(n);if(!S.ok)throw new Error(`Failed to fetch translations: ${S.statusText}`);N=await S.json(),_(N),s&&v.debug("[TranslationsProvider] URL translations loaded:",{keysCount:N?Object.keys(N).length:0})}catch(S){v.error("[TranslationsProvider] Failed to load URL translations",S instanceof Error?S:{message:String(S)}),N=void 0,_(void 0)}let ue=(async()=>{try{Ke.setDebug(s);let S=await Ke.fetchTranslations({apiKey:d,crudifyEnv:w,featureKeys:m,urlTranslations:N}),W={};return Object.keys(S).forEach(C=>{let k=me[C]||{},F=S[C]||{};W[C]=Yr(k,F,i)}),s&&v.debug("[TranslationsProvider] Loaded translations:",{languages:Object.keys(W),keysCount:Object.keys(W[a]||{}).length}),W}catch(S){v.error("[TranslationsProvider] Failed to load",S instanceof Error?S:{message:String(S)}),R(S instanceof Error?S.message:String(S)),oe(!0);let W={};return Object.keys(me).forEach(C=>{let k=me[C],F=N||L||{};W[C]=Yr(k,F,i)}),s&&v.debug("[TranslationsProvider] Using fallback translations (critical + URL)"),W}})();$e=ue;try{let S=await ue;p(S)}finally{I(!1),x(!1),lr=!1,setTimeout(()=>{$e=null},1e3)}},[d,w,m,n,i,s,a,re]);Xr(()=>{de();let j=setInterval(de,3600*1e3);return()=>clearInterval(j)},[de]);let Re=Gr(()=>(j,N)=>{let S=(g[a]||{})[j];if(!S){let W=Object.keys(g);for(let C of W)if(g[C][j]){S=g[C][j];break}}return S||(s&&v.warn(`[TranslationsProvider] Missing translation: "${j}"`),S=j),N&&typeof S=="string"&&Object.entries(N).forEach(([W,C])=>{let k=new RegExp(`{{${W}}}`,"g");S=S.replace(k,String(C))}),S},[g,a,s]);it(g,a,u,y,s);let D={t:Re,language:a,availableLanguages:Object.keys(g),translations:g,isLoading:P,error:h,refreshTranslations:de};return d?f&&M&&P?b||Ge("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh"},children:Ge("div",{children:"Loading translations..."})}):Ge(Jr.Provider,{value:D,children:e}):(s&&v.warn("[TranslationsProvider] No API key available. Skipping translations. Provide apiKey via props or ensure cookies are set by Lambda."),Ge(at,{children:e}))},_e=()=>{let e=tt(Jr);if(!e)throw new Error("useTranslations must be used within TranslationsProvider");return e};import{Box as jt,Typography as Kt}from"@mui/material";import{createContext as lt,useContext as ct,useMemo as dr}from"react";import{useState as cr,useEffect as st}from"react";var Qr=(e,r)=>{let[o,t]=cr({}),[a,i]=cr(!1),[n,s]=cr(null);return st(()=>{if(r&&Object.keys(r).length>0){t(r),i(!1),s(null);return}if(!e){t({}),i(!1),s(null);return}let c=!1;return i(!0),s(null),fetch(e).then(y=>{if(!y.ok)throw new Error(`Failed to load translations: ${y.status}`);return y.json()}).then(y=>{c||(t(y),i(!1))}).catch(y=>{c||(v.error("[I18nProvider] Failed to load translations from URL",y instanceof Error?y:{message:String(y),url:e}),s(y instanceof Error?y.message:String(y)),t({}),i(!1))}),()=>{c=!0}},[e,r]),{translations:o,loading:a,error:n}};import{jsx as Zr}from"react/jsx-runtime";var eo=lt(null),dt=()=>{try{return _e()}catch{return null}},ut=(e,r)=>{if(r.includes(".")){let o=r.split(".").reduce((t,a)=>t&&typeof t=="object"?t[a]:void 0,e);if(o!==void 0)return o}if(e&&e[r])return e[r]},ro=({children:e,translations:r,translationsUrl:o,language:t="en"})=>{let i=dt()?.translations?.[t]||{},{translations:n,loading:s}=Qr(o,r),c=dr(()=>({...i,...n,...r||{}}),[i,n,r]),y=dr(()=>(b,f)=>{let l=ut(c,b);return l==null&&(l=b),f&&typeof l=="string"&&Object.entries(f).forEach(([d,w])=>{l=l.replace(new RegExp(`{{${d}}}`,"g"),w)}),typeof l=="string"?l:b},[c]),u=dr(()=>({t:y,language:t}),[y,t]);return s?Zr("div",{children:"Loading translations..."}):Zr(eo.Provider,{value:u,children:e})},Z=()=>{let e=ct(eo);if(!e)throw new Error("useTranslation must be used within I18nProvider");return e};import{createContext as mt,useContext as gt,useReducer as ft,useEffect as oo}from"react";import{jsx as ht}from"react/jsx-runtime";var to={currentScreen:"login",searchParams:{},formData:{username:"",password:"",email:"",code:"",newPassword:"",confirmPassword:""},loading:!1,errors:{global:[]},emailSent:!1,codeAlreadyExists:!1,codeValidated:!1,fromCodeVerification:!1,config:{}};function pt(e,r){switch(r.type){case"SET_SCREEN":let o={...e,currentScreen:r.payload.screen,searchParams:r.payload.params||e.searchParams,errors:{global:[]}},t=new URLSearchParams(o.searchParams),a=t.toString()?`?${t.toString()}`:window.location.pathname;try{window.history.replaceState({},"",a)}catch{}return o;case"SET_SEARCH_PARAMS":return{...e,searchParams:r.payload};case"UPDATE_FORM_DATA":return{...e,formData:{...e.formData,...r.payload},errors:{...e.errors,...Object.keys(r.payload).reduce((i,n)=>({...i,[n]:void 0}),{})}};case"SET_LOADING":return{...e,loading:r.payload};case"SET_ERRORS":return{...e,errors:{...e.errors,...r.payload}};case"CLEAR_ERRORS":return{...e,errors:{global:[]}};case"SET_EMAIL_SENT":return{...e,emailSent:r.payload};case"SET_CODE_ALREADY_EXISTS":return{...e,codeAlreadyExists:r.payload};case"SET_CODE_VALIDATED":return{...e,codeValidated:r.payload};case"SET_FROM_CODE_VERIFICATION":return{...e,fromCodeVerification:r.payload};case"RESET_FORM":return{...e,formData:to.formData,errors:{global:[]},loading:!1,emailSent:!1,codeAlreadyExists:!1,codeValidated:!1,fromCodeVerification:!1};case"INIT_CONFIG":return{...e,config:r.payload};default:return e}}var no=mt(void 0),io=({children:e,initialScreen:r="login",config:o,autoReadFromCookies:t=!0})=>{let[a,i]=ft(pt,{...to,currentScreen:r});oo(()=>{i({type:"INIT_CONFIG",payload:(()=>{let l={};if(t)try{let d=zr("logo");if(d){let w=decodeURIComponent(d);w.startsWith("http")&&(l.logo=w)}}catch(d){v.error("Error reading configuration from cookies",d instanceof Error?d:{message:String(d)})}return{publicApiKey:o?.publicApiKey,env:o?.env,appName:o?.appName,logo:o?.logo||l.logo,loginActions:o?.loginActions}})()})},[o,t]),oo(()=>{let f=new URLSearchParams(window.location.search),l={};f.forEach((d,w)=>{l[w]=d}),Object.keys(l).length>0&&i({type:"SET_SEARCH_PARAMS",payload:l}),r==="checkCode"&&l.email&&i({type:"UPDATE_FORM_DATA",payload:{email:l.email,code:l.code||""}}),r==="resetPassword"&&l.link&&i({type:"SET_SEARCH_PARAMS",payload:l})},[r]);let b={state:a,dispatch:i,setScreen:(f,l)=>{i({type:"SET_SCREEN",payload:{screen:f,params:l}})},updateFormData:f=>{i({type:"UPDATE_FORM_DATA",payload:f})},setFieldError:(f,l)=>{i({type:"SET_ERRORS",payload:{[f]:l}})},clearErrors:()=>{i({type:"CLEAR_ERRORS"})},setLoading:f=>{i({type:"SET_LOADING",payload:f})}};return ht(no.Provider,{value:b,children:e})},Ye=()=>{let e=gt(no);if(e===void 0)throw new Error("useLoginState must be used within a LoginStateProvider");return e};import{useEffect as yt,useRef as bt}from"react";import{Typography as ur,TextField as ao,Button as wt,Box as Oe,CircularProgress as xt,Alert as vt,Link as so}from"@mui/material";import{Fragment as Pt,jsx as ee,jsxs as Be}from"react/jsx-runtime";var Ct=({onScreenChange:e,onExternalNavigate:r,onLoginSuccess:o,onError:t,redirectUrl:a="/"})=>{let{crudify:i}=ae(),{state:n,updateFormData:s,setFieldError:c,clearErrors:y,setLoading:u}=Ye(),{login:b}=pe(),f=Z(),{t:l}=f,d=f.i18n,w=bt(null),m=Vr(l,{currentLanguage:d?.language,enableDebug:!1}),g=()=>{if(n.searchParams.redirect)try{let h=decodeURIComponent(n.searchParams.redirect);if(h.startsWith("/")&&!h.startsWith("//"))return h}catch{}return a||"/"};yt(()=>{let h=setTimeout(()=>{w.current&&w.current.focus()},100);return()=>clearTimeout(h)},[]);let p=h=>m.translateError({code:h.code,message:h.message,field:h.field}),P=async()=>{if(!n.loading){if(!n.formData.username.trim()){c("username",l("login.usernameRequired"));return}if(!n.formData.password.trim()){c("password",l("login.passwordRequired"));return}y(),u(!0);try{let h=await b(n.formData.username,n.formData.password);if(u(!1),h.success){let R=g();o&&o(h.data,R)}else{let R=h.rawResponse||h;I(R)}}catch(h){u(!1);let L=Y(h).map(p);c("global",L),t&&t(L.join(", "))}}},I=h=>{let R=Y(h),L=[];R.forEach(_=>{_.field?c(_.field,p(_)):L.push(p(_))}),L.length>0&&c("global",L)};return Be(Pt,{children:[Be(Oe,{component:"form",noValidate:!0,onSubmit:h=>{h.preventDefault(),P()},onKeyDown:h=>{h.key==="Enter"&&!n.loading&&(h.preventDefault(),P())},sx:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[Be(Oe,{sx:{mb:1},children:[ee(ur,{variant:"body2",component:"label",htmlFor:"email",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:l("login.usernameOrEmailLabel")}),ee(ao,{fullWidth:!0,id:"email",name:"email",type:"email",value:n.formData.username,disabled:n.loading,onChange:h=>s({username:h.target.value}),error:!!n.errors.username,helperText:n.errors.username,autoComplete:"email",placeholder:l("login.usernameOrEmailPlaceholder"),inputRef:w,required:!0})]}),Be(Oe,{sx:{mb:1},children:[ee(ur,{variant:"body2",component:"label",htmlFor:"password",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:l("login.passwordLabel")}),ee(ao,{fullWidth:!0,id:"password",name:"password",type:"password",value:n.formData.password,disabled:n.loading,onChange:h=>s({password:h.target.value}),error:!!n.errors.password,helperText:n.errors.password,autoComplete:"current-password",placeholder:l("login.passwordPlaceholder"),required:!0})]}),n.config.loginActions?.includes("forgotPassword")&&ee(Oe,{sx:{display:"flex",justifyContent:"flex-end",alignItems:"center"},children:ee(so,{sx:{cursor:"pointer"},onClick:()=>{e?.("forgotPassword",n.searchParams)},variant:"body2",color:"secondary",children:l("login.forgotPasswordLink")})}),ee(wt,{disabled:n.loading,type:"submit",fullWidth:!0,variant:"contained",color:"primary",sx:{mt:1,mb:2},children:n.loading?ee(xt,{size:20}):l("login.loginButton")})]}),ee(Oe,{children:n.errors.global&&n.errors.global.length>0&&n.errors.global.map((h,R)=>ee(vt,{variant:"filled",sx:{mt:2},severity:"error",children:ee("div",{children:h})},R))}),n.config.loginActions?.includes("createUser")&&Be(ur,{variant:"body2",align:"center",sx:{color:"text.secondary",mt:3},children:[l("login.noAccountPrompt")," ",ee(so,{sx:{cursor:"pointer"},onClick:()=>{let R=`/public/users/create${Object.keys(n.searchParams).length>0?`?${new URLSearchParams(n.searchParams).toString()}`:""}`;r?.(R)},fontWeight:"medium",color:"secondary",children:l("login.signUpLink")})]})]})},lo=Ct;import{useState as ke,useEffect as Tt,useRef as Et}from"react";import{Typography as Le,TextField as Rt,Button as co,Box as he,CircularProgress as St,Alert as It,Link as mr}from"@mui/material";import{Fragment as uo,jsx as V,jsxs as Pe}from"react/jsx-runtime";var kt=({onScreenChange:e,onError:r})=>{let{crudify:o}=ae(),[t,a]=ke(""),[i,n]=ke(!1),[s,c]=ke([]),[y,u]=ke(null),[b,f]=ke(!1),[l,d]=ke(!1),w=Et(null),{t:m}=Z();Tt(()=>{w.current&&!b&&!l&&w.current.focus()},[b,l]);let g=h=>{let R=[`errors.auth.${h.code}`,`errors.data.${h.code}`,`errors.system.${h.code}`,`errors.${h.code}`,`forgotPassword.${h.code.toLowerCase()}`];for(let L of R){let _=m(L);if(_!==L)return _}return h.message||m("error.unknown")},p=h=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(h),P=async()=>{if(!(i||!o)){if(c([]),u(null),!t){u(m("forgotPassword.emailRequired"));return}if(!p(t)){u(m("forgotPassword.invalidEmail"));return}n(!0);try{let h=[{operation:"requestPasswordReset",data:{email:t}}],R=await o.transaction(h);if(R.success)R.data&&R.data.existingCodeValid?d(!0):f(!0);else{let _=Y(R).map(g);c(_)}}catch(h){let L=Y(h).map(g);c(L),r&&r(L.join(", "))}finally{n(!1)}}},I=()=>{e?.("login")},M=()=>{if(b||l){e?.("checkCode",{email:t});return}if(!t){u(m("forgotPassword.emailRequired"));return}if(!p(t)){u(m("forgotPassword.invalidEmail"));return}e?.("checkCode",{email:t})};return b||l?V(uo,{children:Pe(he,{sx:{width:"100%",display:"flex",flexDirection:"column",gap:2,textAlign:"center"},children:[Pe(he,{sx:{mb:2},children:[V(Le,{variant:"h5",component:"h1",sx:{mb:1,fontWeight:600},children:m(l?"forgotPassword.codeAlreadyExistsMessage":"forgotPassword.emailSentMessage")}),V(Le,{variant:"body2",sx:{color:l?"success.main":"grey.600"},children:m("forgotPassword.checkEmailInstructions")})]}),V(co,{type:"button",onClick:M,fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2},children:m("forgotPassword.enterCodeLink")}),V(he,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:V(mr,{sx:{cursor:"pointer"},onClick:I,variant:"body2",color:"secondary",children:m("common.back")})})]})}):Pe(uo,{children:[Pe(he,{component:"form",noValidate:!0,onSubmit:h=>{h.preventDefault(),P()},sx:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[Pe(he,{sx:{mb:2},children:[V(Le,{variant:"h5",component:"h1",sx:{mb:1,fontWeight:600},children:m("forgotPassword.title")}),V(Le,{variant:"body2",sx:{color:"grey.600"},children:m("forgotPassword.instructions")})]}),Pe(he,{sx:{mb:1},children:[V(Le,{variant:"body2",component:"label",htmlFor:"email",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:m("forgotPassword.emailLabel")}),V(Rt,{fullWidth:!0,id:"email",name:"email",type:"email",value:t,disabled:i,onChange:h=>a(h.target.value),error:!!y,helperText:y,autoComplete:"email",placeholder:m("forgotPassword.emailPlaceholder"),required:!0,autoFocus:!0,inputRef:w})]}),V(co,{disabled:i,type:"submit",fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2},children:i?V(St,{size:20}):m("forgotPassword.sendCodeButton")}),Pe(he,{sx:{display:"flex",justifyContent:"center",alignItems:"center",gap:2},children:[V(mr,{sx:{cursor:"pointer"},onClick:I,variant:"body2",color:"secondary",children:m("common.back")}),V(Le,{variant:"body2",sx:{color:"grey.400"},children:"\u2022"}),V(mr,{sx:{cursor:"pointer"},onClick:M,variant:"body2",color:"secondary",children:m("login.alreadyHaveCodeLink")})]})]}),V(he,{children:s.length>0&&s.map((h,R)=>V(It,{variant:"filled",sx:{mt:2},severity:"error",children:h},R))})]})},mo=kt;import{useState as J,useEffect as go}from"react";import{Typography as Xe,TextField as fo,Button as Lt,Box as ye,CircularProgress as po,Alert as ho,Link as At}from"@mui/material";import{Fragment as Dt,jsx as q,jsxs as Ne}from"react/jsx-runtime";var Ft=({onScreenChange:e,onError:r,searchParams:o,onResetSuccess:t})=>{let{crudify:a}=ae(),[i,n]=J(""),[s,c]=J(""),[y,u]=J(!1),[b,f]=J([]),[l,d]=J(null),[w,m]=J(null),[g,p]=J(""),[P,I]=J(""),[M,x]=J(!1),[h,R]=J(!0),[L,_]=J(!1),[re,oe]=J(null),[de,Re]=J(!1),{t:D}=Z(),j=C=>{let k=[`errors.auth.${C.code}`,`errors.data.${C.code}`,`errors.system.${C.code}`,`errors.${C.code}`,`resetPassword.${C.code.toLowerCase()}`];for(let F of k){let H=D(F);if(H!==F)return H}return C.message||D("error.unknown")},N=C=>o?o instanceof URLSearchParams?o.get(C):o[C]||null:null;go(()=>{if(o){if(o){let C=N("fromCodeVerification"),k=N("email"),F=N("code");if(C==="true"&&k&&F){p(k),I(F),x(!0),_(!0),R(!1);return}let H=N("link");if(H)try{let G=decodeURIComponent(H),[X,fe]=G.split("/");if(X&&fe&&X.length===6){I(X),p(fe),x(!1),oe({email:fe,code:X});return}}catch{}if(k&&F){p(k),I(F),x(!1),oe({email:k,code:F});return}}f([D("resetPassword.invalidCode")]),R(!1),setTimeout(()=>e?.("forgotPassword"),3e3)}},[o,a,D,e]),go(()=>{a&&re&&!de&&(Re(!0),(async(k,F)=>{try{let H=[{operation:"validatePasswordResetCode",data:{email:k,codePassword:F}}],G=await a.transaction(H);if(G.data&&Array.isArray(G.data)){let X=G.data[0];if(X&&X.response&&X.response.status==="OK"){_(!0);return}}if(G.success)_(!0);else{let fe=Y(G).map(j);f(fe),setTimeout(()=>e?.("forgotPassword"),3e3)}}catch(H){let X=Y(H).map(j);f(X),setTimeout(()=>e?.("forgotPassword"),3e3)}finally{R(!1),oe(null),Re(!1)}})(re.email,re.code))},[a,re,D,e]);let ue=C=>C.length<8?D("resetPassword.passwordTooShort"):null,S=async()=>{if(y||!a)return;f([]),d(null),m(null);let C=!1;if(!i)d(D("resetPassword.newPasswordRequired")),C=!0;else{let k=ue(i);k&&(d(k),C=!0)}if(s?i!==s&&(m(D("resetPassword.passwordsDoNotMatch")),C=!0):(m(D("resetPassword.confirmPasswordRequired")),C=!0),!C){u(!0);try{let k=[{operation:"validateAndResetPassword",data:{email:g,codePassword:P,newPassword:i}}],F=await a.transaction(k);if(F.success)f([]),setTimeout(()=>{t?.()},1e3);else{let G=Y(F).map(j);f(G)}}catch(k){let H=Y(k).map(j);f(H),r&&r(H.join(", "))}u(!1)}},W=()=>{M?e?.("checkCode",{email:g}):e?.("forgotPassword")};return h?q(ye,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"300px"},children:q(po,{})}):L?Ne(Dt,{children:[Ne(ye,{component:"form",noValidate:!0,sx:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[Ne(ye,{sx:{mb:2},children:[q(Xe,{variant:"h5",component:"h1",sx:{mb:1,fontWeight:600},children:D("resetPassword.title")}),q(Xe,{variant:"body2",sx:{color:"grey.600"},children:D("resetPassword.instructions")})]}),Ne(ye,{sx:{mb:1},children:[q(Xe,{variant:"body2",component:"label",htmlFor:"newPassword",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:D("resetPassword.newPasswordLabel")}),q(fo,{fullWidth:!0,id:"newPassword",name:"newPassword",type:"password",value:i,disabled:y,onChange:C=>n(C.target.value),error:!!l,helperText:l,autoComplete:"new-password",placeholder:D("resetPassword.newPasswordPlaceholder"),required:!0})]}),Ne(ye,{sx:{mb:1},children:[q(Xe,{variant:"body2",component:"label",htmlFor:"confirmPassword",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:D("resetPassword.confirmPasswordLabel")}),q(fo,{fullWidth:!0,id:"confirmPassword",name:"confirmPassword",type:"password",value:s,disabled:y,onChange:C=>c(C.target.value),error:!!w,helperText:w,autoComplete:"new-password",placeholder:D("resetPassword.confirmPasswordPlaceholder"),required:!0})]}),q(Lt,{disabled:y,type:"button",onClick:S,fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2},children:y?q(po,{size:20}):D("resetPassword.resetPasswordButton")}),q(ye,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:q(At,{sx:{cursor:"pointer"},onClick:W,variant:"body2",color:"secondary",children:D("common.back")})})]}),q(ye,{children:b.length>0&&b.map((C,k)=>q(ho,{variant:"filled",sx:{mt:2},severity:"error",children:C},k))})]}):q(ye,{children:b.length>0&&b.map((C,k)=>q(ho,{variant:"filled",sx:{mt:2},severity:"error",children:C},k))})},yo=Ft;import{useState as ze,useEffect as bo,useRef as _t}from"react";import{Typography as gr,TextField as Ot,Button as Bt,Box as Ue,CircularProgress as Nt,Alert as zt,Link as Ut}from"@mui/material";import{Fragment as Vt,jsx as se,jsxs as Je}from"react/jsx-runtime";var Mt=({onScreenChange:e,onError:r,searchParams:o})=>{let{crudify:t}=ae(),[a,i]=ze(""),[n,s]=ze(!1),[c,y]=ze([]),[u,b]=ze(null),[f,l]=ze(""),d=_t(null),{t:w}=Z(),m=x=>o?o instanceof URLSearchParams?o.get(x):o[x]||null:null,g=x=>{let h=[`errors.auth.${x.code}`,`errors.data.${x.code}`,`errors.system.${x.code}`,`errors.${x.code}`,`checkCode.${x.code.toLowerCase()}`];for(let R of h){let L=w(R);if(L!==R)return L}return x.message||w("error.unknown")};bo(()=>{let x=m("email");x?l(x):e?.("forgotPassword")},[o,e]),bo(()=>{d.current&&d.current.focus()},[]);let p=async()=>{if(!(n||!t)){if(y([]),b(null),!a){b(w("checkCode.codeRequired"));return}if(a.length!==6){b(w("checkCode.codeRequired"));return}s(!0);try{let x=[{operation:"validatePasswordResetCode",data:{email:f,codePassword:a}}],h=await t.transaction(x);if(h.success)e?.("resetPassword",{email:f,code:a,fromCodeVerification:"true"});else{let L=Y(h).map(g);y(L),s(!1)}}catch(x){let R=Y(x).map(g);y(R),s(!1),r&&r(R.join(", "))}}},P=()=>{e?.("forgotPassword")},I=x=>{let h=x.target.value.replace(/\D/g,"").slice(0,6);i(h)};return Je(Vt,{children:[Je(Ue,{component:"form",noValidate:!0,onSubmit:x=>{x.preventDefault(),p()},sx:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[Je(Ue,{sx:{mb:2},children:[se(gr,{variant:"h5",component:"h1",sx:{mb:1,fontWeight:600},children:w("checkCode.title")}),se(gr,{variant:"body2",sx:{color:"grey.600"},children:w("checkCode.instructions")})]}),Je(Ue,{sx:{mb:1},children:[se(gr,{variant:"body2",component:"label",htmlFor:"code",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:w("checkCode.codeLabel")}),se(Ot,{fullWidth:!0,id:"code",name:"code",type:"text",value:a,disabled:n,onChange:I,error:!!u,helperText:u,placeholder:w("checkCode.codePlaceholder"),inputProps:{maxLength:6,style:{textAlign:"center",fontSize:"1.5rem",letterSpacing:"0.4rem"}},required:!0,autoFocus:!0,inputRef:d})]}),se(Bt,{disabled:n||a.length!==6,type:"submit",fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2},children:n?se(Nt,{size:20}):w("checkCode.verifyButton")}),se(Ue,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:se(Ut,{sx:{cursor:"pointer"},onClick:P,variant:"body2",color:"secondary",children:w("common.back")})})]}),se(Ue,{children:c.length>0&&c.map((x,h)=>se(zt,{sx:{mt:2},severity:"error",children:x},h))})]})},wo=Mt;import{Box as Wt,CircularProgress as Ht,Alert as xo,Typography as fr}from"@mui/material";import{Fragment as qt,jsx as Ae,jsxs as vo}from"react/jsx-runtime";var Co=({children:e,fallback:r})=>{let{isLoading:o,error:t,isInitialized:a}=ae(),{t:i}=Z();return o?r||vo(Wt,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"200px",gap:2},children:[Ae(Ht,{}),Ae(fr,{variant:"body2",color:"text.secondary",children:i("login.initializing")!=="login.initializing"?i("login.initializing"):"Initializing..."})]}):t?Ae(xo,{severity:"error",sx:{mt:2},children:vo(fr,{variant:"body2",children:[i("login.initializationError")!=="login.initializationError"?i("login.initializationError"):"Initialization error",":"," ",t]})}):a?Ae(qt,{children:e}):Ae(xo,{severity:"warning",sx:{mt:2},children:Ae(fr,{variant:"body2",children:i("login.notInitialized")!=="login.notInitialized"?i("login.notInitialized"):"System not initialized"})})};import{jsx as te,jsxs as Yt}from"react/jsx-runtime";var $t=({onScreenChange:e,onExternalNavigate:r,onLoginSuccess:o,onError:t,redirectUrl:a="/"})=>{let{t:i}=Z(),{state:n,setScreen:s}=Ye(),{config:c}=pe(),{showNotification:y}=Wr(),u=(f,l)=>{let d=l;f==="login"?d={}:f==="forgotPassword"&&!l&&(d={}),s(f,d),e?.(f,d)},b=()=>{let f={onScreenChange:u,onExternalNavigate:r,onError:t,redirectUrl:a};switch(n.currentScreen){case"forgotPassword":return te(mo,{...f});case"checkCode":return te(wo,{...f,searchParams:n.searchParams});case"resetPassword":return te(yo,{...f,searchParams:n.searchParams,onResetSuccess:()=>{let l=i("resetPassword.successMessage");y(l,"success"),u("login")}});default:return te(lo,{...f,onLoginSuccess:o})}};return Yt(Co,{children:[te(jt,{sx:{display:"flex",justifyContent:"center",mb:3},children:te("img",{src:c.logo||"https://logos.crudia.com/nocios-default.png",alt:i("login.logoAlt"),style:{width:"100%",maxWidth:"150px",height:"auto"},onError:f=>{let l=f.target;l.src="https://logos.crudia.com/nocios-default.png"}})}),!c.logo&&c.appName&&te(Kt,{variant:"h6",component:"h1",sx:{textAlign:"center",mb:2},children:c.appName}),b()]})},Gt=({translations:e,translationsUrl:r,language:o="en",initialScreen:t="login",autoReadFromCookies:a=!0,...i})=>{let{config:n}=pe();return te(ro,{translations:e,translationsUrl:r,language:o,children:te(Mr,{config:n,children:te(io,{config:n,initialScreen:t,autoReadFromCookies:a,children:te($t,{...i})})})})},bs=Gt;import{Box as Q,Card as Po,CardContent as To,Typography as ne,Chip as Qe,Avatar as Xt,Divider as Jt,CircularProgress as Qt,Alert as Eo,List as Zt,ListItem as pr,ListItemText as hr,ListItemIcon as en,Collapse as rn,IconButton as yr}from"@mui/material";import{Person as on,Email as tn,Badge as nn,Security as an,Schedule as sn,AccountCircle as ln,ExpandMore as cn,ExpandLess as dn,Info as un}from"@mui/icons-material";import{useState as mn}from"react";import{Fragment as pn,jsx as E,jsxs as O}from"react/jsx-runtime";var gn=({showExtendedData:e=!0,showProfileCard:r=!0,autoRefresh:o=!0})=>{let{userProfile:t,loading:a,error:i,extendedData:n,refreshProfile:s}=Hr({autoFetch:o,retryOnError:!0,maxRetries:3}),[c,y]=mn(!1);if(a)return O(Q,{display:"flex",justifyContent:"center",alignItems:"center",p:3,children:[E(Qt,{}),E(ne,{variant:"body2",sx:{ml:2},children:"Cargando perfil de usuario..."})]});if(i)return O(Eo,{severity:"error",action:E(yr,{color:"inherit",size:"small",onClick:s,children:E(ne,{variant:"caption",children:"Reintentar"})}),children:["Error al cargar el perfil: ",i]});if(!t)return E(Eo,{severity:"warning",children:"No se encontr\xF3 informaci\xF3n del usuario"});let u=n?.displayData||{},b=n?.totalFields||0,f=p=>{if(!p)return"No disponible";try{return new Date(p).toLocaleString("es-ES",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return p}},l=(p,P)=>P==null?"No disponible":typeof P=="boolean"?P?"S\xED":"No":Array.isArray(P)?P.length>0?P.join(", "):"Ninguno":typeof P=="object"?JSON.stringify(P,null,2):String(P),d=[{key:"id",label:"ID",icon:E(nn,{})},{key:"email",label:"Email",icon:E(tn,{})},{key:"username",label:"Usuario",icon:E(on,{})},{key:"fullName",label:"Nombre completo",icon:E(ln,{})},{key:"role",label:"Rol",icon:E(an,{})}],w=[{key:"firstName",label:"Nombre"},{key:"lastName",label:"Apellido"},{key:"isActive",label:"Activo"},{key:"lastLogin",label:"\xDAltimo login"},{key:"createdAt",label:"Creado"},{key:"updatedAt",label:"Actualizado"}],m=[...d.map(p=>p.key),...w.map(p=>p.key),"permissions"],g=Object.keys(u).filter(p=>!m.includes(p)).map(p=>({key:p,label:p}));return O(Q,{children:[r&&E(Po,{sx:{mb:2},children:O(To,{children:[O(Q,{display:"flex",alignItems:"center",mb:2,children:[E(Xt,{src:u.avatar,sx:{width:56,height:56,mr:2},children:u.fullName?.[0]||u.username?.[0]||u.email?.[0]}),O(Q,{children:[E(ne,{variant:"h6",children:u.fullName||u.username||u.email}),E(ne,{variant:"body2",color:"text.secondary",children:u.role||"Usuario"}),u.isActive!==void 0&&E(Qe,{label:u.isActive?"Activo":"Inactivo",color:u.isActive?"success":"error",size:"small",sx:{mt:.5}})]})]}),E(Q,{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(250px, 1fr))",gap:2,children:d.map(({key:p,label:P,icon:I})=>u[p]?O(Q,{display:"flex",alignItems:"center",children:[E(Q,{sx:{mr:1,color:"text.secondary"},children:I}),O(Q,{children:[E(ne,{variant:"caption",color:"text.secondary",children:P}),E(ne,{variant:"body2",children:l(p,u[p])})]})]},p):null)}),u.permissions&&Array.isArray(u.permissions)&&u.permissions.length>0&&O(Q,{mt:2,children:[E(ne,{variant:"caption",color:"text.secondary",display:"block",children:"Permisos"}),O(Q,{display:"flex",flexWrap:"wrap",gap:.5,mt:.5,children:[u.permissions.slice(0,5).map((p,P)=>E(Qe,{label:p,size:"small",variant:"outlined"},P)),u.permissions.length>5&&E(Qe,{label:`+${u.permissions.length-5} m\xE1s`,size:"small"})]})]})]})}),e&&E(Po,{children:O(To,{children:[O(Q,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,children:[O(ne,{variant:"h6",display:"flex",alignItems:"center",children:[E(un,{sx:{mr:1}}),"Informaci\xF3n Detallada"]}),E(Qe,{label:`${b} campos totales`,size:"small"})]}),O(Zt,{dense:!0,children:[w.map(({key:p,label:P})=>u[p]!==void 0&&O(pr,{divider:!0,children:[E(en,{children:E(sn,{fontSize:"small"})}),E(hr,{primary:P,secondary:p.includes("At")||p.includes("Login")?f(u[p]):l(p,u[p])})]},p)),g.length>0&&O(pn,{children:[E(Jt,{sx:{my:1}}),E(pr,{children:E(hr,{primary:O(Q,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[O(ne,{variant:"subtitle2",children:["Campos Personalizados (",g.length,")"]}),E(yr,{size:"small",onClick:()=>y(!c),children:c?E(dn,{}):E(cn,{})})]})})}),E(rn,{in:c,children:g.map(({key:p,label:P})=>E(pr,{sx:{pl:4},children:E(hr,{primary:P,secondary:l(p,u[p])})},p))})]})]}),O(Q,{mt:2,display:"flex",justifyContent:"space-between",alignItems:"center",children:[O(ne,{variant:"caption",color:"text.secondary",children:["\xDAltima actualizaci\xF3n: ",f(u.updatedAt)]}),E(yr,{size:"small",onClick:s,disabled:a,children:E(ne,{variant:"caption",children:"Actualizar"})})]})]})})]})},fn=gn;var Ro=["create","read","update","delete"],So=["create","read","update","delete"];import{useRef as zn}from"react";import{useTranslation as Un}from"react-i18next";import{Box as rr,Typography as _o,Button as Mn,Stack as Vn,Alert as Oo,Divider as Wn}from"@mui/material";import{Add as Hn}from"@mui/icons-material";import{forwardRef as En}from"react";import{useTranslation as Rn}from"react-i18next";import{Box as Te,FormControl as Sn,InputLabel as In,Select as kn,MenuItem as Ln,IconButton as An,Typography as Fe,FormHelperText as Fn,Stack as er,Paper as Do,Divider as Dn,Button as vr}from"@mui/material";import{Delete as _n,SelectAll as On,ClearAll as Bn}from"@mui/icons-material";import{useState as Io,useEffect as ko,useRef as Lo}from"react";import{useTranslation as hn}from"react-i18next";import{Box as Ze,Typography as Me,Button as Ao,Stack as br,FormControlLabel as yn,FormHelperText as Fo,Switch as bn,ToggleButton as wr,ToggleButtonGroup as wn}from"@mui/material";import{CheckCircle as xn,Cancel as vn,SelectAll as Cn,ClearAll as Pn}from"@mui/icons-material";import{jsx as z,jsxs as be}from"react/jsx-runtime";var Tn=({value:e,onChange:r,availableFields:o,error:t,disabled:a=!1})=>{let{t:i}=hn(),[n,s]=Io("custom"),[c,y]=Io(!1),u=Lo(null);ko(()=>{c&&u.current?.scrollIntoView({behavior:"smooth",block:"start"})},[c]);let b=Lo(!1);ko(()=>{let m=e||{allow:[],owner_allow:[],deny:[]},g=new Set(o),p=(m.allow||[]).filter(x=>g.has(x)),P=(m.owner_allow||[]).filter(x=>g.has(x)),I=(m.deny||[]).filter(x=>g.has(x));o.forEach(x=>{!p.includes(x)&&!P.includes(x)&&!I.includes(x)&&I.push(x)});let M={allow:p,owner_allow:P,deny:I};JSON.stringify(M)!==JSON.stringify(m)&&r(M),p.length===o.length?s("all"):I.length===o.length?s("none"):s("custom")},[o,e]);let f=()=>{b.current=!0,r({allow:[...o],owner_allow:[],deny:[]}),s("all"),setTimeout(()=>{b.current=!1},0)},l=()=>{b.current=!0,r({allow:[],owner_allow:[],deny:[...o]}),s("none"),setTimeout(()=>{b.current=!1},0)},d=m=>e?.allow?.includes(m)?"allow":e?.owner_allow?.includes(m)?"owner_allow":"deny",w=(m,g)=>{b.current=!0;let p=new Set(e?.allow||[]),P=new Set(e?.owner_allow||[]),I=new Set(e?.deny||[]);p.delete(m),P.delete(m),I.delete(m),g==="allow"&&p.add(m),g==="owner_allow"&&P.add(m),g==="deny"&&I.add(m),r({allow:Array.from(p),owner_allow:Array.from(P),deny:Array.from(I)}),s("custom"),setTimeout(()=>{b.current=!1},0)};return o.length===0?be(Ze,{children:[z(Me,{variant:"body2",color:"text.secondary",sx:{mb:1},children:i("modules.form.publicPolicies.fields.conditions.label")}),z(Me,{variant:"body2",color:"text.secondary",sx:{fontStyle:"italic"},children:i("modules.form.publicPolicies.fields.conditions.noFieldsAvailable")}),t&&z(Fo,{error:!0,sx:{mt:1},children:t})]}):be(Ze,{children:[z(Me,{variant:"body2",color:"text.secondary",sx:{mb:2},children:i("modules.form.publicPolicies.fields.conditions.label")}),be(br,{direction:"row",spacing:1,alignItems:"center",sx:{mb:c?3:1},children:[z(Ao,{variant:n==="all"?"contained":"outlined",startIcon:z(Cn,{}),onClick:f,disabled:a,size:"small",sx:{minWidth:120,...n==="all"&&{backgroundColor:"#16a34a","&:hover":{backgroundColor:"#15803d"}}},children:i("modules.form.publicPolicies.fields.conditions.allFields")}),z(Ao,{variant:n==="none"?"contained":"outlined",startIcon:z(Pn,{}),onClick:l,disabled:a,size:"small",sx:{minWidth:120,...n==="none"&&{backgroundColor:"#cf222e","&:hover":{backgroundColor:"#bc1f2c"}}},children:i("modules.form.publicPolicies.fields.conditions.noFields")}),z(Ze,{sx:{display:"flex",alignItems:"center",px:1.5,py:.35,borderRadius:"999px",backgroundColor:"#f3f4f6",border:"1px solid #d1d9e0"},children:z(yn,{control:z(bn,{size:"small",checked:c,onChange:()=>y(m=>!m),disabled:a,color:"primary",sx:{transform:"scale(1.15)",transformOrigin:"center",m:0}}),label:i("modules.form.publicPolicies.fields.conditions.customEdit"),labelPlacement:"end",sx:{ml:0,".MuiFormControlLabel-label":{fontSize:"0.75rem"}}})})]}),c&&be(Ze,{ref:u,sx:{p:2,border:"1px solid #d1d9e0",borderRadius:1,backgroundColor:"#f6f8fa"},children:[z(Me,{variant:"body2",color:"text.secondary",sx:{mb:2},children:i("modules.form.publicPolicies.fields.conditions.help")}),z(br,{spacing:1,children:o.map(m=>{let g=d(m);return be(br,{direction:"row",spacing:1,alignItems:"center",children:[z(Me,{variant:"body2",sx:{minWidth:100,fontFamily:"monospace"},children:m}),be(wn,{value:g,exclusive:!0,size:"small",children:[be(wr,{value:"allow",onClick:()=>w(m,"allow"),disabled:a,sx:{px:2,color:g==="allow"?"#ffffff":"#6b7280",backgroundColor:g==="allow"?"#16a34a":"#f3f4f6",borderColor:g==="allow"?"#16a34a":"#d1d5db","&:hover":{backgroundColor:g==="allow"?"#15803d":"#e5e7eb",borderColor:g==="allow"?"#15803d":"#9ca3af"},"&.Mui-selected":{backgroundColor:"#16a34a",color:"#ffffff","&:hover":{backgroundColor:"#15803d"}}},children:[z(xn,{sx:{fontSize:16,mr:.5}}),i("modules.form.publicPolicies.fields.conditions.states.allow")]}),z(wr,{value:"owner_allow",onClick:()=>w(m,"owner_allow"),disabled:a,sx:{px:2,color:g==="owner_allow"?"#ffffff":"#6b7280",backgroundColor:g==="owner_allow"?"#0ea5e9":"#f3f4f6",borderColor:g==="owner_allow"?"#0ea5e9":"#d1d5db","&:hover":{backgroundColor:g==="owner_allow"?"#0284c7":"#e5e7eb",borderColor:g==="owner_allow"?"#0284c7":"#9ca3af"},"&.Mui-selected":{backgroundColor:"#0ea5e9",color:"#ffffff","&:hover":{backgroundColor:"#0284c7"}}},children:i("modules.form.publicPolicies.fields.conditions.states.ownerAllow")}),be(wr,{value:"deny",onClick:()=>w(m,"deny"),disabled:a,sx:{px:2,color:g==="deny"?"#ffffff":"#6b7280",backgroundColor:g==="deny"?"#dc2626":"#f3f4f6",borderColor:g==="deny"?"#dc2626":"#d1d5db","&:hover":{backgroundColor:g==="deny"?"#b91c1c":"#e5e7eb",borderColor:g==="deny"?"#b91c1c":"#9ca3af"},"&.Mui-selected":{backgroundColor:"#dc2626",color:"#ffffff","&:hover":{backgroundColor:"#b91c1c"}}},children:[z(vn,{sx:{fontSize:16,mr:.5}}),i("modules.form.publicPolicies.fields.conditions.states.deny")]})]})]},m)})})]}),t&&z(Fo,{error:!0,sx:{mt:1},children:t})]})},xr=Tn;import{jsx as U,jsxs as K}from"react/jsx-runtime";var Nn=En(({policy:e,onChange:r,onRemove:o,availableFields:t,isSubmitting:a=!1,usedActions:i,error:n},s)=>{let{t:c}=Rn(),y=new Set(Array.from(i||[]));y.delete(e.action);let u=Ro.map(b=>({value:b,label:c(`modules.form.publicPolicies.fields.action.options.${b}`)}));return K(Do,{ref:s,sx:{p:3,border:"1px solid #d1d9e0",borderRadius:2,position:"relative",backgroundColor:"#ffffff"},children:[K(Te,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:3},children:[U(Fe,{variant:"subtitle1",sx:{fontWeight:600,color:"#111418",fontSize:"1rem"},children:c("modules.form.publicPolicies.policyTitle")}),U(An,{onClick:o,size:"small",disabled:a,"aria-label":c("modules.form.publicPolicies.removePolicy"),sx:{color:"#656d76","&:hover":{color:"#cf222e",backgroundColor:"rgba(207, 34, 46, 0.1)"}},children:U(_n,{})})]}),K(er,{spacing:1,children:[U(er,{direction:{xs:"column",md:"row"},spacing:2,children:U(Te,{sx:{flex:1,minWidth:200},children:K(Sn,{fullWidth:!0,children:[U(In,{children:c("modules.form.publicPolicies.fields.action.label")}),U(kn,{value:e.action,label:c("modules.form.publicPolicies.fields.action.label"),disabled:a,onChange:b=>{let f=b.target.value,l={...e,action:f};f==="delete"?(l.permission="deny",delete l.fields):(l.fields={allow:[],owner_allow:[],deny:t},delete l.permission),r(l)},sx:{backgroundColor:"#ffffff","&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"#8c959f"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"#0969da",borderWidth:2}},children:u.map(b=>{let f=y.has(b.value);return U(Ln,{value:b.value,disabled:f,children:b.label},b.value)})}),n&&U(Fn,{error:!0,children:n})]})})}),e.action==="delete"?K(Te,{children:[U(Fe,{variant:"body2",color:"text.secondary",sx:{mb:2},children:c("modules.form.publicPolicies.fields.conditions.label")}),K(er,{direction:"row",spacing:1,sx:{mb:1},children:[U(vr,{variant:e.permission==="*"?"contained":"outlined",startIcon:U(On,{}),onClick:()=>r({...e,permission:"*"}),disabled:a,size:"small",sx:{minWidth:140,whiteSpace:"nowrap",...e.permission==="*"&&{backgroundColor:"#16a34a","&:hover":{backgroundColor:"#15803d"}}},children:c("modules.form.publicPolicies.fields.conditions.allFields")}),U(vr,{variant:e.permission==="owner"?"contained":"outlined",onClick:()=>r({...e,permission:"owner"}),disabled:a,size:"small",sx:{minWidth:140,whiteSpace:"nowrap",...e.permission==="owner"&&{backgroundColor:"#0ea5e9","&:hover":{backgroundColor:"#0284c7"}}},children:c("modules.form.publicPolicies.fields.conditions.states.ownerAllow")}),U(vr,{variant:e.permission==="deny"?"contained":"outlined",startIcon:U(Bn,{}),onClick:()=>r({...e,permission:"deny"}),disabled:a,size:"small",sx:{minWidth:140,whiteSpace:"nowrap",...e.permission==="deny"&&{backgroundColor:"#cf222e","&:hover":{backgroundColor:"#bc1f2c"}}},children:c("modules.form.publicPolicies.fields.conditions.noFields")})]})]}):U(xr,{value:e.fields||{allow:[],owner_allow:[],deny:[]},onChange:b=>r({...e,fields:b}),availableFields:t,disabled:a}),U(Do,{variant:"outlined",sx:{p:2,backgroundColor:"#f9fafb"},children:e.action==="delete"?K(Fe,{variant:"body2",sx:{fontFamily:"monospace",color:"text.secondary"},children:[K(Te,{component:"span",sx:{color:e.permission==="*"?"#16a34a":e.permission==="owner"?"#0ea5e9":"#dc2626"},children:[c("modules.form.publicPolicies.fields.conditions.states.allow"),":"]})," ",e.permission||"-"]}):K(er,{spacing:.5,divider:U(Dn,{sx:{borderColor:"#e5e7eb"}}),children:[K(Fe,{variant:"body2",sx:{fontFamily:"monospace",color:"text.secondary"},children:[K(Te,{component:"span",sx:{color:"#16a34a"},children:[c("modules.form.publicPolicies.fields.conditions.states.allow"),":"]})," ",(e?.fields?.allow||[]).join(", ")||"-"]}),K(Fe,{variant:"body2",sx:{fontFamily:"monospace",color:"text.secondary"},children:[K(Te,{component:"span",sx:{color:"#0ea5e9"},children:[c("modules.form.publicPolicies.fields.conditions.states.ownerAllow"),":"]})," ",(e?.fields?.owner_allow||[]).join(", ")||"-"]}),K(Fe,{variant:"body2",sx:{fontFamily:"monospace",color:"text.secondary"},children:[K(Te,{component:"span",sx:{color:"#dc2626"},children:[c("modules.form.publicPolicies.fields.conditions.states.deny"),":"]})," ",(e?.fields?.deny||[]).join(", ")||"-"]})]})})]})]})}),Cr=Nn;import{Fragment as Kn,jsx as le,jsxs as or}from"react/jsx-runtime";var qn=()=>{let e=globalThis?.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`},jn=({policies:e,onChange:r,availableFields:o,errors:t,isSubmitting:a=!1})=>{let{t:i}=Un(),n=zn({}),s=new Set((e||[]).map(d=>d.action).filter(Boolean)),c=So.filter(d=>!s.has(d)),y=c.length>0,u=()=>{let d=c[0]||"create",w={id:qn(),action:d};d==="delete"?w.permission="deny":w.fields={allow:[],owner_allow:[],deny:o};let m=[...e||[],w];r(m),setTimeout(()=>{let g=m.length-1,p=n.current[g];p&&p.scrollIntoView({behavior:"smooth",block:"center"})},100)},b=d=>{let w=[...e];w.splice(d,1),r(w)},f=(()=>{if(!t)return null;if(typeof t=="string")return t;let d=t._error;return typeof d=="string"?d:null})(),l=new Set((e||[]).map(d=>d.action));return or(Kn,{children:[le(Wn,{sx:{borderColor:"#e0e4e7"}}),or(rr,{children:[le(rr,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3,children:or(rr,{children:[le(_o,{variant:"h6",sx:{fontWeight:600,color:"#111418",mb:1},children:i("modules.form.publicPolicies.title")}),le(_o,{variant:"body2",color:"text.secondary",sx:{fontSize:"0.875rem"},children:i("modules.form.publicPolicies.description")})]})}),f&&le(Oo,{severity:"error",sx:{mb:3},children:f}),or(Vn,{spacing:3,children:[(e||[]).length===0?le(Oo,{severity:"info",children:i("modules.form.publicPolicies.noPolicies")}):e.map((d,w)=>le(Cr,{ref:m=>{n.current[w]=m},policy:d,onChange:m=>{let g=[...e];g[w]=m,r(g)},onRemove:()=>b(w),availableFields:o,isSubmitting:a,usedActions:l,error:typeof t=="object"&&t&&d.id in t?t[d.id]:void 0},d.id)),y&&le(rr,{children:le(Mn,{type:"button",variant:"outlined",startIcon:le(Hn,{}),onClick:u,disabled:a,sx:{borderColor:"#d0d7de",color:"#656d76","&:hover":{borderColor:"#8c959f",backgroundColor:"transparent"}},children:i("modules.form.publicPolicies.addPolicy")})})]})]})]})},ol=jn;import{useState as Pr}from"react";import{Button as tr,TextField as Bo,Box as De,Alert as Ve,Typography as we,CircularProgress as Tr}from"@mui/material";import{jsx as B,jsxs as ge}from"react/jsx-runtime";function cl(){let[e,r]=Pr(""),[o,t]=Pr(""),[a,i]=Pr(!1),{isAuthenticated:n,isLoading:s,error:c,login:y,logout:u,refreshTokens:b,clearError:f,isExpiringSoon:l,expiresIn:d}=pe(),w=async p=>{if(p.preventDefault(),!e||!o)return;(await y(e,o)).success&&(r(""),t(""),i(!1))},m=async()=>{await u()},g=async()=>{await b()};return n?ge(De,{sx:{maxWidth:600,mx:"auto",p:3},children:[B(we,{variant:"h4",gutterBottom:!0,children:"Welcome! \u{1F389}"}),B(Ve,{severity:"success",sx:{mb:3},children:"You are successfully logged in with Refresh Token Pattern enabled"}),ge(De,{sx:{mb:3,p:2,bgcolor:"background.paper",border:1,borderColor:"divider",borderRadius:1},children:[B(we,{variant:"h6",gutterBottom:!0,children:"Token Status"}),ge(we,{variant:"body2",color:"text.secondary",children:["Access Token expires in: ",Math.round(d/1e3/60)," minutes"]}),l&&B(Ve,{severity:"warning",sx:{mt:1},children:"Token expires soon - automatic refresh will happen"})]}),ge(De,{sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[B(tr,{variant:"contained",onClick:g,disabled:s,startIcon:s?B(Tr,{size:16}):null,children:"Refresh Tokens"}),B(tr,{variant:"outlined",color:"error",onClick:m,disabled:s,children:"Logout"})]}),c&&B(Ve,{severity:"error",sx:{mt:2},onClose:f,children:c})]}):ge(De,{sx:{maxWidth:400,mx:"auto",p:3},children:[B(we,{variant:"h4",gutterBottom:!0,align:"center",children:"Login with Refresh Tokens"}),B(Ve,{severity:"info",sx:{mb:3},children:"This demo shows the new Refresh Token Pattern with automatic session management"}),a?ge("form",{onSubmit:w,children:[B(Bo,{fullWidth:!0,label:"Email",type:"email",value:e,onChange:p=>r(p.target.value),margin:"normal",required:!0,autoComplete:"email"}),B(Bo,{fullWidth:!0,label:"Password",type:"password",value:o,onChange:p=>t(p.target.value),margin:"normal",required:!0,autoComplete:"current-password"}),B(tr,{type:"submit",fullWidth:!0,variant:"contained",size:"large",disabled:s,startIcon:s?B(Tr,{size:16}):null,sx:{mt:3,mb:2},children:s?"Logging in...":"Login"})]}):B(tr,{fullWidth:!0,variant:"contained",size:"large",onClick:()=>i(!0),sx:{mt:2},children:"Show Login Form"}),c&&B(Ve,{severity:"error",sx:{mt:2},onClose:f,children:c})]})}function dl(){let{isAuthenticated:e,isLoading:r,isExpiringSoon:o,expiresIn:t}=pe();return r?ge(De,{sx:{display:"flex",alignItems:"center",gap:1},children:[B(Tr,{size:16}),B(we,{variant:"caption",children:"Loading session..."})]}):e?ge(De,{children:[B(we,{variant:"caption",color:"success.main",children:"\u2713 Authenticated"}),o&&ge(we,{variant:"caption",color:"warning.main",display:"block",children:["\u26A0 Token expires in ",Math.round(t/1e3/60)," min"]})]}):B(we,{variant:"caption",color:"text.secondary",children:"Not logged in"})}import $n from"@mui/material/TextField";import Gn from"@mui/material/CircularProgress";import No from"@mui/material/InputAdornment";import Yn from"@mui/material/IconButton";import Xn from"@mui/icons-material/Refresh";import{jsx as xe}from"react/jsx-runtime";var Jn=e=>e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,""),Qn=({html:e})=>xe("span",{dangerouslySetInnerHTML:{__html:Jn(e)}}),wl=({config:e,value:r,onChange:o,label:t,error:a=!1,helperText:i,readOnly:n=!1,disabled:s=!1})=>{let{value:c,loading:y,error:u,regenerate:b}=qr(e,{autoFetch:!r,onSuccess:g=>{o?.(g)}}),f=r||c,l=a||!!u,d=u||i,w=l&&d&&(d.toLowerCase().includes("duplicate")||d.toLowerCase().includes("duplicado")||d.toLowerCase().includes("duplicada")||d.toLowerCase().includes("unique")||d.toLowerCase().includes("\xFAnico")||d.toLowerCase().includes("unico")||d.toLowerCase().includes("\xFAnica")||d.toLowerCase().includes("unica")||d.toLowerCase().includes("already exists")||d.toLowerCase().includes("ya existe")||d.toLowerCase().includes("e11000"));return xe($n,{label:t,fullWidth:!0,value:f,error:l,helperText:d?xe(Qn,{html:d}):" ",disabled:s,InputProps:{readOnly:!0,startAdornment:y?xe(No,{position:"start",children:xe(Gn,{size:20})}):void 0,endAdornment:w&&!y?xe(No,{position:"end",children:xe(Yn,{edge:"end",onClick:async()=>{!s&&!y&&await b()},disabled:s,size:"small",color:"error","aria-label":"regenerar c\xF3digo",title:"Regenerar c\xF3digo",children:xe(Xn,{})})}):void 0}})};import Er,{useCallback as ve,useRef as zo,useState as We}from"react";import Ee from"@mui/material/Box";import Ce from"@mui/material/Typography";import Rr from"@mui/material/IconButton";import Zn from"@mui/material/LinearProgress";import nr from"@mui/material/CircularProgress";import Mo from"@mui/material/Chip";import ei from"@mui/material/Paper";import ri from"@mui/material/List";import oi from"@mui/material/ListItem";import ti from"@mui/material/ListItemText";import ni from"@mui/material/ListItemSecondaryAction";import ii from"@mui/material/FormHelperText";import ai from"@mui/material/Dialog";import si from"@mui/material/DialogTitle";import li from"@mui/material/DialogContent";import ci from"@mui/material/DialogActions";import Uo from"@mui/material/Button";import di from"@mui/icons-material/CloudUpload";import ui from"@mui/icons-material/InsertDriveFile";import mi from"@mui/icons-material/Image";import gi from"@mui/icons-material/PictureAsPdf";import fi from"@mui/icons-material/Delete";import pi from"@mui/icons-material/Refresh";import hi from"@mui/icons-material/Restore";import yi from"@mui/icons-material/CheckCircle";import bi from"@mui/icons-material/Error";import Xl from"@mui/icons-material/BrokenImage";import{jsx as T,jsxs as ce}from"react/jsx-runtime";var wi=e=>e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,""),xi=e=>{if(e===0)return"0 B";let r=1024,o=["B","KB","MB","GB"],t=Math.floor(Math.log(e)/Math.log(r));return`${parseFloat((e/Math.pow(r,t)).toFixed(1))} ${o[t]}`},vi=e=>e.startsWith("image/")?T(mi,{color:"primary"}):e==="application/pdf"?T(gi,{color:"error"}):T(ui,{color:"action"}),Ci=(e,r)=>{switch(e){case"completed":return T(yi,{color:"success",fontSize:"small"});case"error":return T(bi,{color:"error",fontSize:"small"});case"uploading":case"pending":return T(nr,{size:16});case"removing":return T(nr,{size:16,color:"error"});case"pendingDeletion":return T(Mo,{label:r("file.pendingDeletion"),size:"small",color:"warning",variant:"outlined",sx:{fontSize:"0.65rem",height:20}});default:return null}},Pi=({file:e,baseUrl:r,disabled:o,onRemove:t,onRestore:a,onRetry:i})=>{let{t:n}=_e(),[s,c]=We(!1),y=e.status==="pendingDeletion",u=!o&&e.status!=="uploading"&&e.status!=="removing"&&!y,b=!o&&y,f=!o&&e.status==="error"&&e.file,l=e.contentType.startsWith("image/"),d=e.visibility==="public"||e.filePath?.startsWith("public/")||e.filePath?.startsWith(r),m=!e.filePath||!d?null:e.filePath.startsWith("http://")||e.filePath.startsWith("https://")||e.filePath.startsWith(r)?e.filePath:`${r}${e.filePath}`,g=e.status==="completed"&&m,p=()=>l&&g&&!s?T(Ee,{component:g?"a":"div",href:m||void 0,target:"_blank",rel:"noopener noreferrer",sx:{width:48,height:48,borderRadius:1,overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"grey.100",border:"1px solid",borderColor:"divider",cursor:g?"pointer":"default",transition:"all 0.2s ease",flexShrink:0,"&:hover":g?{borderColor:"primary.main",transform:"scale(1.05)"}:{}},children:T("img",{src:m,alt:e.name,style:{width:"100%",height:"100%",objectFit:"cover"},onError:()=>c(!0)})}):T(Ee,{component:g?"a":"div",href:m||void 0,target:"_blank",rel:"noopener noreferrer",sx:{width:48,height:48,borderRadius:1,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"grey.50",border:"1px solid",borderColor:"divider",cursor:g?"pointer":"default",transition:"all 0.2s ease",flexShrink:0,textDecoration:"none","&:hover":g?{borderColor:"primary.main",bgcolor:"action.hover"}:{}},children:vi(e.contentType)});return ce(oi,{sx:{borderRadius:1,mb:.5,bgcolor:e.status==="error"?"error.lighter":"background.paper",border:"1px solid",borderColor:e.status==="error"?"error.light":"divider",gap:1.5},children:[p(),T(ti,{primary:ce(Ee,{sx:{display:"flex",alignItems:"center",gap:1},children:[T(Ce,{variant:"body2",noWrap:!0,sx:{maxWidth:200,overflow:"hidden",textOverflow:"ellipsis",textDecoration:y?"line-through":"none",opacity:y?.6:1},children:e.name}),Ci(e.status,n)]}),secondary:ce(Ee,{sx:{opacity:y?.6:1},children:[e.size>0&&T(Ce,{variant:"caption",color:"text.secondary",children:xi(e.size)}),e.status==="uploading"&&T(Zn,{variant:"determinate",value:e.progress,sx:{mt:.5,height:4,borderRadius:2}}),e.status==="error"&&e.errorMessage&&T(Ce,{variant:"caption",color:"error",display:"block",children:e.errorMessage}),g&&T(Ce,{variant:"caption",color:"primary",display:"block",component:"a",href:m||void 0,target:"_blank",rel:"noopener noreferrer",sx:{cursor:"pointer",textDecoration:"underline","&:hover":{textDecoration:"none"}},children:n(l?"file.clickToPreview":"file.clickToDownload")})]})}),ce(ni,{children:[f&&T(Rr,{edge:"end",size:"small",onClick:()=>i(e.id),color:"primary",title:n("file.restore"),children:T(pi,{fontSize:"small"})}),b&&T(Rr,{edge:"end",size:"small",onClick:()=>a(e.id),color:"primary",title:n("file.restore"),children:T(hi,{fontSize:"small"})}),u&&T(Rr,{edge:"end",size:"small",onClick:()=>t(e.id),color:"error",title:n("file.delete"),children:T(fi,{fontSize:"small"})})]})]})};var Zl=({label:e,accept:r,maxFileSize:o=10*1024*1024,multiple:t=!1,maxFiles:a,minFiles:i=0,required:n=!1,disabled:s=!1,error:c=!1,helperText:y,onChange:u,onValidation:b,initialFiles:f,placeholder:l,showFileList:d=!0,visibility:w="private",showPreview:m=!0,baseUrl:g,onDeletionHandlersReady:p,mode:P="create"})=>{let{t:I}=_e(),M=zo(null),[x,h]=We(!1),[R,L]=We(!1),[_,re]=We(null),[oe,de]=We(!1),Re=t?a:1,D=n?Math.max(i,1):i,j={acceptedTypes:r,maxFileSize:o,maxFiles:Re,minFiles:D,visibility:w,mode:P,onFilesChange:A=>{let ie=A.filter(qe=>qe.status==="completed"&&qe.filePath).map(qe=>{let Se=qe.filePath;return Se.startsWith(g)||Se.startsWith("http://")||Se.startsWith("https://")?Se:g?`${g}${Se}`:Se});u?.(ie)}},{files:N,isUploading:ue,addFiles:S,removeFile:W,restoreFile:C,retryUpload:k,isValid:F,validationError:H,validationErrorKey:G,validationErrorParams:X,initializeFiles:fe,isTouched:qi,markAsTouched:He,isSubmitted:qo,markAsSubmitted:Ir,getPreviewUrl:ji,commitDeletions:kr,restorePendingDeletions:Lr,hasPendingDeletions:Ar,deleteFileImmediately:Fr,activeFiles:Ki,activeFileCount:jo,waitForUploads:Dr}=jr(j),_r=zo(!1);Er.useEffect(()=>{f&&f.length>0&&!_r.current&&(_r.current=!0,fe(f,g))},[f,fe,g]),Er.useEffect(()=>{b?.(F,H)},[F,H,b]),Er.useEffect(()=>{p?.({commitDeletions:kr,restorePendingDeletions:Lr,hasPendingDeletions:Ar,markAsSubmitted:Ir,isValid:F,isUploading:ue,waitForUploads:Dr})},[p,kr,Lr,Ar,Ir,F,ue,Dr]);let Ko=ve(A=>{He();let ie=A.target.files;ie&&ie.length>0&&S(ie),M.current&&(M.current.value="")},[S,He]),$o=ve(()=>{s||M.current?.click()},[s]),Go=ve(A=>{A.preventDefault(),A.stopPropagation(),s||h(!0)},[s]),Yo=ve(A=>{A.preventDefault(),A.stopPropagation(),h(!1)},[]),Xo=ve(A=>{if(A.preventDefault(),A.stopPropagation(),h(!1),s)return;He();let ie=A.dataTransfer.files;ie&&ie.length>0&&S(ie)},[s,S,He]),Jo=ve(async A=>{(await W(A)).needsConfirmation&&(re(A),L(!0))},[W]),Qo=ve(async()=>{if(_){de(!0);try{let A=await Fr(_);A.success||console.error("Error deleting file:",A.error)}finally{de(!1),L(!1),re(null)}}},[_,Fr]),Or=ve(()=>{L(!1),re(null)},[]),Zo=r?.join(",")||"",et=!s&&(t||jo===0),Br=qo&&!F,ar=c||Br,Nr=y||(Br&&G?I(G,X):null);return ce(Ee,{sx:{width:"100%"},children:[e&&ce(Ce,{variant:"body2",sx:{mb:1,fontWeight:500,color:ar?"error.main":"text.primary"},children:[e,n&&T("span",{style:{color:"red"},children:" *"})]}),T("input",{ref:M,type:"file",accept:Zo,multiple:t,onChange:Ko,disabled:s,style:{display:"none"}}),et&&ce(ei,{variant:"outlined",onClick:$o,onDragOver:Go,onDragLeave:Yo,onDrop:Xo,sx:{p:3,textAlign:"center",cursor:s?"not-allowed":"pointer",borderStyle:"dashed",borderWidth:2,borderColor:x?"primary.main":ar?"error.main":"divider",bgcolor:x?"primary.lighter":s?"action.disabledBackground":"background.paper",transition:"all 0.2s ease","&:hover":s?{}:{borderColor:"primary.main",bgcolor:"action.hover"}},children:[T(di,{sx:{fontSize:48,color:x?"primary.main":s?"action.disabled":"action.active",mb:1}}),T(Ce,{variant:"body2",color:s?"text.disabled":"text.secondary",children:l||I(x?"file.dropHere":"file.dragOrClick")}),r&&r.length>0&&!x&&T(Ee,{sx:{mt:1,display:"flex",gap:.5,justifyContent:"center",flexWrap:"wrap"},children:r.map(A=>T(Mo,{label:A.split("/")[1]?.toUpperCase()||A,size:"small",variant:"outlined",sx:{fontSize:"0.7rem"}},A))})]}),d&&N.length>0&&T(ri,{dense:!0,sx:{mt:1,p:0},children:N.map(A=>T(Pi,{file:A,baseUrl:g,disabled:s,onRemove:Jo,onRestore:C,onRetry:k},A.id))}),ue&&ce(Ee,{sx:{display:"flex",alignItems:"center",gap:1,mt:1},children:[T(nr,{size:16}),T(Ce,{variant:"caption",color:"text.secondary",children:I("file.uploading")})]}),Nr&&T(ii,{error:ar,sx:{mt:.5},dangerouslySetInnerHTML:{__html:wi(Nr)}}),ce(ai,{open:R,onClose:oe?void 0:Or,children:[T(si,{children:I("file.confirmDelete.title")}),T(li,{children:T(Ce,{children:I("file.confirmDelete.message")})}),ce(ci,{children:[T(Uo,{onClick:Or,disabled:oe,children:I("file.confirmDelete.cancel")}),T(Uo,{onClick:Qo,color:"error",variant:"contained",disabled:oe,startIcon:oe?T(nr,{size:16,color:"inherit"}):void 0,children:I(oe?"file.deleting":"file.confirmDelete.confirm")})]})]})]})};import{useCallback as Ti,useRef as Ei,useEffect as Ri}from"react";import Vo from"@mui/material/Box";import Wo from"@mui/material/Typography";import Ho from"@mui/material/FormHelperText";import{MDXEditor as Si,headingsPlugin as Ii,listsPlugin as ki,quotePlugin as Li,thematicBreakPlugin as Ai,markdownShortcutPlugin as Fi,linkPlugin as Di,linkDialogPlugin as _i,tablePlugin as Oi,toolbarPlugin as Bi,UndoRedo as Ni,BoldItalicUnderlineToggles as zi,BlockTypeSelect as Ui,CreateLink as Mi,InsertTable as Vi,ListsToggle as Wi,Separator as ir}from"@mdxeditor/editor";import"@mdxeditor/editor/style.css";import{Fragment as Hi,jsx as $,jsxs as Sr}from"react/jsx-runtime";var cc=({label:e,value:r="",onChange:o,required:t=!1,disabled:a=!1,error:i=!1,helperText:n,placeholder:s="Write here...",minHeight:c=200,maxHeight:y=500})=>{let u=Ei(null);Ri(()=>{u.current&&u.current.getMarkdown()!==r&&u.current.setMarkdown(r||"")},[r]);let b=Ti(f=>{o?.(f)},[o]);return Sr(Vo,{sx:{width:"100%"},children:[e&&Sr(Wo,{component:"label",sx:{display:"block",mb:.5,fontSize:"0.875rem",fontWeight:500,color:i?"error.main":"text.primary"},children:[e,t&&$(Wo,{component:"span",color:"error.main",sx:{ml:.5},children:"*"})]}),$(Vo,{sx:{border:1,borderColor:i?"error.main":"divider",borderRadius:1,overflow:"hidden",opacity:a?.6:1,pointerEvents:a?"none":"auto","& .mdxeditor":{minHeight:c,maxHeight:y,overflow:"auto"},"& .mdxeditor-toolbar":{borderBottom:1,borderColor:"divider",backgroundColor:"background.default"},"& .mdxeditor-root-contenteditable":{padding:2,minHeight:c-50}},children:$(Si,{ref:u,markdown:r||"",onChange:b,placeholder:s,readOnly:a,plugins:[Ii(),ki(),Li(),Ai(),Fi(),Di(),_i(),Oi(),Bi({toolbarContents:()=>Sr(Hi,{children:[$(Ni,{}),$(ir,{}),$(zi,{}),$(ir,{}),$(Ui,{}),$(ir,{}),$(Wi,{}),$(ir,{}),$(Mi,{}),$(Vi,{})]})})]})}),n&&$(Ho,{error:i,sx:{mx:0,mt:.5},children:n}),!n&&$(Ho,{sx:{mx:0,mt:.5},children:"\xA0"})]})};export{me as a,Gi as b,Yi as c,sr as d,Ke as e,sa as f,_e as g,bs as h,fn as i,Ro as j,So as k,ol as l,cl as m,dl as n,wl as o,Zl as p,cc as q};
|
|
1
|
+
import{b as Wr,c as ae,h as qr,j as he,l as jr,m as Kr,p as $r}from"./chunk-AD5AA75O.mjs";import{g as Y}from"./chunk-BJ6PIVZR.mjs";import{a as v,b as Mr,c as Vr,h as Hr}from"./chunk-SUWV767V.mjs";var me={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":"Correo Electr\xF3nico","login.usernameOrEmailPlaceholder":"Ingresa tu correo electr\xF3nico","login.usernameRequired":"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...","modules.form.publicPolicies.fields.conditions.customEdit":"Edici\xF3n personalizada","file.clickToPreview":"Clic para ver imagen","file.clickToDownload":"Clic para descargar","file.privateFile":"Archivo privado","file.noPreview":"Sin vista previa","file.dropHere":"Suelta el archivo aqu\xED","file.dragOrClick":"Arrastra archivos aqu\xED o haz clic para seleccionar","file.uploading":"Subiendo archivos...","file.restore":"Restaurar","file.delete":"Eliminar","file.pendingDeletion":"Pendiente de eliminaci\xF3n","file.allowedTypes":"Tipos permitidos: {{types}}","file.maxSize":"M\xE1ximo {{size}} por archivo","file.maxFiles":"M\xE1ximo {{count}} archivos","file.validation.minFilesRequired":"Se requiere al menos un archivo","file.validation.minFilesRequiredPlural":"Se requieren al menos {{count}} archivos","file.validation.maxFilesExceeded":"M\xE1ximo {{count}} archivos permitidos","file.validation.filesWithErrors":"Algunos archivos tienen errores","file.confirmDelete.title":"Eliminar archivo","file.confirmDelete.message":"\xBFEst\xE1s seguro de que deseas eliminar este archivo? Esta acci\xF3n no se puede deshacer.","file.confirmDelete.confirm":"Eliminar","file.confirmDelete.cancel":"Cancelar","file.deleting":"Eliminando..."},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...","modules.form.publicPolicies.fields.conditions.customEdit":"Custom Edit","file.clickToPreview":"Click to preview","file.clickToDownload":"Click to download","file.privateFile":"Private file","file.noPreview":"No preview","file.dropHere":"Drop file here","file.dragOrClick":"Drag files here or click to select","file.uploading":"Uploading files...","file.restore":"Restore","file.delete":"Delete","file.pendingDeletion":"Pending deletion","file.allowedTypes":"Allowed types: {{types}}","file.maxSize":"Max {{size}} per file","file.maxFiles":"Max {{count}} files","file.validation.minFilesRequired":"At least one file is required","file.validation.minFilesRequiredPlural":"At least {{count}} files are required","file.validation.maxFilesExceeded":"Maximum {{count}} files allowed","file.validation.filesWithErrors":"Some files have errors","file.confirmDelete.title":"Delete file","file.confirmDelete.message":"Are you sure you want to delete this file? This action cannot be undone.","file.confirmDelete.confirm":"Delete","file.deleting":"Deleting...","file.confirmDelete.cancel":"Cancel"}},Xi=()=>Object.keys(me),Ji=e=>me[e]||me.es;import je from"@nocios/crudify-browser";var Gr="crudify_translations_",tt=3600*1e3;function Yr(e){let r=0;for(let o=0;o<e.length;o++){let t=e.charCodeAt(o);r=(r<<5)-r+t,r=r&r}return Math.abs(r).toString(36)}var sr=class e{constructor(){this.enableDebug=!1;this.initializationPromise=null;this.isInitialized=!1}static getInstance(){return e.instance||(e.instance=new e),e.instance}setDebug(r){this.enableDebug=r}async ensureCrudifyInitialized(r,o){if(!this.isInitialized)return this.initializationPromise?(this.enableDebug&&v.debug("[TranslationService] Waiting for crudify initialization..."),this.initializationPromise):(this.enableDebug&&v.debug("[TranslationService] Initializing crudify SDK..."),this.initializationPromise=(async()=>{try{let t=je.getTokenData();if(t&&t.endpoint){this.enableDebug&&v.debug("[TranslationService] Crudify already initialized"),this.isInitialized=!0;return}je.config(o);let a=await je.init(r,this.enableDebug?"debug":"none");if(a.success===!1)throw new Error(`Failed to initialize crudify: ${JSON.stringify(a.errors||"Unknown error")}`);this.isInitialized=!0,this.enableDebug&&v.debug("[TranslationService] Crudify SDK initialized successfully")}catch(t){throw v.error("[TranslationService] Failed to initialize crudify",t instanceof Error?t:{message:String(t)}),this.initializationPromise=null,t}})(),this.initializationPromise)}async fetchTranslations(r){let{apiKey:o,featureKeys:t,crudifyEnv:a="stg",urlTranslations:i}=r;this.enableDebug&&v.debug("[TranslationService] fetchTranslations called with:",{apiKeyHash:Yr(o),crudifyEnv:a,featureKeys:t,hasUrlTranslations:!!i});let n=this.getFromCache(o),s=n?this.isCacheExpired(n):!0;if(n&&!s)return this.enableDebug&&v.debug("[TranslationService] Using cached translations"),this.mergeWithUrlTranslations(n.data.translations,i);try{await this.ensureCrudifyInitialized(o,a)}catch(c){return v.error("[TranslationService] Failed to initialize crudify",c instanceof Error?c:{message:String(c)}),n?(v.warn("[TranslationService] Using expired cache (init failed)"),this.mergeWithUrlTranslations(n.data.translations,i)):(v.warn("[TranslationService] Using critical bundle (init failed)"),this.getCriticalTranslationsOnly())}try{this.enableDebug&&v.debug("[TranslationService] Fetching from API via crudify SDK");let c=await this.fetchFromAPI(t);this.hasDataChanged(n,c)||!n?this.saveToCache(o,c):this.refreshCacheTimestamp(o);let u=this.mergeWithUrlTranslations(c.translations,i);return this.enableDebug&&v.debug("[TranslationService] Translations loaded:",{languages:Object.keys(u),keysCount:u[Object.keys(u)[0]]?Object.keys(u[Object.keys(u)[0]]).length:0}),u}catch(c){return v.error("[TranslationService] API fetch failed",c instanceof Error?c:{message:String(c)}),n?(v.warn("[TranslationService] Using expired cache as fallback"),this.mergeWithUrlTranslations(n.data.translations,i)):(v.warn("[TranslationService] Using critical bundle translations"),this.getCriticalTranslationsOnly())}}async fetchFromAPI(r){let o=await je.getTranslation(r);if(!o.success)throw new Error(`Crudify API error: ${o.errors?JSON.stringify(o.errors):"Unknown error"}`);if(!o.data)throw new Error("No translation data in response");return o.data}mergeWithUrlTranslations(r,o){if(!o||Object.keys(o).length===0)return r;let t={};return Object.keys(r).forEach(a=>{t[a]={...r[a],...o}}),t}hasDataChanged(r,o){if(!r||r.data.timestamp!==o.timestamp)return!0;let t=this.hashData(o.translations);return r.dataHash!==t}hashData(r){let o=JSON.stringify(r),t=0;for(let a=0;a<o.length;a++){let i=o.charCodeAt(a);t=(t<<5)-t+i,t=t&t}return t.toString(36)}saveToCache(r,o){try{let t=this.getCacheKey(r),a={data:o,cachedAt:Date.now(),dataHash:this.hashData(o.translations)};localStorage.setItem(t,JSON.stringify(a)),this.enableDebug&&v.debug("[TranslationService] Saved to cache:",{cacheKey:t})}catch(t){v.error("[TranslationService] Failed to save cache",t instanceof Error?t:{message:String(t)})}}getFromCache(r){try{let o=this.getCacheKey(r),t=localStorage.getItem(o);return t?JSON.parse(t):null}catch(o){return v.error("[TranslationService] Failed to read cache",o instanceof Error?o:{message:String(o)}),null}}refreshCacheTimestamp(r){try{let o=this.getFromCache(r);if(o){o.cachedAt=Date.now();let t=this.getCacheKey(r);localStorage.setItem(t,JSON.stringify(o))}}catch(o){v.error("[TranslationService] Failed to refresh cache timestamp",o instanceof Error?o:{message:String(o)})}}isCacheExpired(r){return Date.now()-r.cachedAt>tt}hasValidCache(r){let o=this.getFromCache(r);return o?!this.isCacheExpired(o):!1}getCacheKey(r){return`${Gr}${Yr(r)}`}getCriticalTranslationsOnly(){return me}invalidateCache(r){let o=this.getCacheKey(r);localStorage.removeItem(o),this.enableDebug&&v.debug("[TranslationService] Cache invalidated:",{cacheKey:o})}async prefetchTranslations(r){try{await this.fetchTranslations(r),this.enableDebug&&v.debug("[TranslationService] Prefetch completed")}catch(o){v.error("[TranslationService] Prefetch failed",o instanceof Error?o:{message:String(o)})}}clearAllCaches(){try{let o=Object.keys(localStorage).filter(t=>t.startsWith(Gr));o.forEach(t=>localStorage.removeItem(t)),this.enableDebug&&v.debug(`[TranslationService] Cleared ${o.length} cache entries`)}catch(r){v.error("[TranslationService] Failed to clear caches",r instanceof Error?r:{message:String(r)})}}},Ke=sr.getInstance();import{createContext as nt,useContext as it,useEffect as Qr,useState as Ie,useMemo as Xr,useCallback as at}from"react";import{Fragment as lt,jsx as Ge}from"react/jsx-runtime";var $e=null,lr=!1,Zr=nt(null);function Jr(e,r,o){return{...e,...r,...o||{}}}function st(e,r,o,t,a){Qr(()=>{if(!t||!e||!r)return;let i=o||typeof window<"u"&&window.i18next||typeof window<"u"&&window.i18n;if(!i||!i.addResourceBundle){a&&v.debug("[TranslationsProvider] i18next not found, skipping auto-sync");return}a&&v.debug("[TranslationsProvider] Auto-syncing translations with i18next",{languages:Object.keys(e),currentLanguage:r}),Object.keys(e).forEach(n=>{e[n]&&Object.keys(e[n]).length>0&&(i.addResourceBundle(n,"translation",e[n],!0,!0),a&&v.debug(`[TranslationsProvider] Synced ${Object.keys(e[n]).length} keys for language: ${n}`))}),i.language!==r&&(i.changeLanguage(r),a&&v.debug(`[TranslationsProvider] Changed i18next language to: ${r}`))},[e,r,o,t,a])}var ca=({children:e,apiKey:r,crudifyEnv:o="prod",featureKeys:t,language:a="es",devTranslations:i,translationUrl:n,enableDebug:s=!1,skipAutoInit:c=!0,autoSyncI18n:y=!0,i18nInstance:u,loadingFallback:b,waitForInitialLoad:f=!0})=>{let l=Xr(()=>Vr({publicApiKey:r,env:o,featureKeys:t,enableDebug:s}),[r,o,t,s]),d=l.publicApiKey||"",w=l.env||o||"prod",m=l.featureKeys||t,[g,p]=Ie({}),[P,I]=Ie(!0),[M,x]=Ie(!0),[h,R]=Ie(null),[L,_]=Ie(void 0),[re,oe]=Ie(!1),de=at(async()=>{if(!d){s&&v.debug("[TranslationsProvider] No apiKey - skipping translation fetch"),I(!1),x(!1);return}if(re){s&&v.debug("[TranslationsProvider] Skipping reload - using fallback translations");return}if(Ke.hasValidCache(d)&&M&&(s&&v.debug("[TranslationsProvider] Valid cache found - not blocking initial render"),x(!1)),lr&&$e){s&&v.debug("[TranslationsProvider] Fetch already in progress, waiting for existing promise");try{let S=await $e;p(S),I(!1);return}catch{s&&v.warn("[TranslationsProvider] Global fetch failed, retrying")}}lr=!0,I(!0),R(null);let N;if(n)try{s&&v.debug(`[TranslationsProvider] Fetching translations from URL: ${n}`);let S=await fetch(n);if(!S.ok)throw new Error(`Failed to fetch translations: ${S.statusText}`);N=await S.json(),_(N),s&&v.debug("[TranslationsProvider] URL translations loaded:",{keysCount:N?Object.keys(N).length:0})}catch(S){v.error("[TranslationsProvider] Failed to load URL translations",S instanceof Error?S:{message:String(S)}),N=void 0,_(void 0)}let ue=(async()=>{try{Ke.setDebug(s);let S=await Ke.fetchTranslations({apiKey:d,crudifyEnv:w,featureKeys:m,urlTranslations:N}),W={};return Object.keys(S).forEach(C=>{let k=me[C]||{},F=S[C]||{};W[C]=Jr(k,F,i)}),s&&v.debug("[TranslationsProvider] Loaded translations:",{languages:Object.keys(W),keysCount:Object.keys(W[a]||{}).length}),W}catch(S){v.error("[TranslationsProvider] Failed to load",S instanceof Error?S:{message:String(S)}),R(S instanceof Error?S.message:String(S)),oe(!0);let W={};return Object.keys(me).forEach(C=>{let k=me[C],F=N||L||{};W[C]=Jr(k,F,i)}),s&&v.debug("[TranslationsProvider] Using fallback translations (critical + URL)"),W}})();$e=ue;try{let S=await ue;p(S)}finally{I(!1),x(!1),lr=!1,setTimeout(()=>{$e=null},1e3)}},[d,w,m,n,i,s,a,re]);Qr(()=>{de();let j=setInterval(de,3600*1e3);return()=>clearInterval(j)},[de]);let Re=Xr(()=>(j,N)=>{let S=(g[a]||{})[j];if(!S){let W=Object.keys(g);for(let C of W)if(g[C][j]){S=g[C][j];break}}return S||(s&&v.warn(`[TranslationsProvider] Missing translation: "${j}"`),S=j),N&&typeof S=="string"&&Object.entries(N).forEach(([W,C])=>{let k=new RegExp(`{{${W}}}`,"g");S=S.replace(k,String(C))}),S},[g,a,s]);st(g,a,u,y,s);let D={t:Re,language:a,availableLanguages:Object.keys(g),translations:g,isLoading:P,error:h,refreshTranslations:de};return d?f&&M&&P?b||Ge("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh"},children:Ge("div",{children:"Loading translations..."})}):Ge(Zr.Provider,{value:D,children:e}):(s&&v.warn("[TranslationsProvider] No API key available. Skipping translations. Provide apiKey via props or ensure cookies are set by Lambda."),Ge(lt,{children:e}))},_e=()=>{let e=it(Zr);if(!e)throw new Error("useTranslations must be used within TranslationsProvider");return e};import{Box as $t,Typography as Gt}from"@mui/material";import{createContext as dt,useContext as ut,useMemo as dr}from"react";import{useState as cr,useEffect as ct}from"react";var eo=(e,r)=>{let[o,t]=cr({}),[a,i]=cr(!1),[n,s]=cr(null);return ct(()=>{if(r&&Object.keys(r).length>0){t(r),i(!1),s(null);return}if(!e){t({}),i(!1),s(null);return}let c=!1;return i(!0),s(null),fetch(e).then(y=>{if(!y.ok)throw new Error(`Failed to load translations: ${y.status}`);return y.json()}).then(y=>{c||(t(y),i(!1))}).catch(y=>{c||(v.error("[I18nProvider] Failed to load translations from URL",y instanceof Error?y:{message:String(y),url:e}),s(y instanceof Error?y.message:String(y)),t({}),i(!1))}),()=>{c=!0}},[e,r]),{translations:o,loading:a,error:n}};import{jsx as ro}from"react/jsx-runtime";var oo=dt(null),mt=()=>{try{return _e()}catch{return null}},gt=(e,r)=>{if(r.includes(".")){let o=r.split(".").reduce((t,a)=>t&&typeof t=="object"?t[a]:void 0,e);if(o!==void 0)return o}if(e&&e[r])return e[r]},to=({children:e,translations:r,translationsUrl:o,language:t="en"})=>{let i=mt()?.translations?.[t]||{},{translations:n,loading:s}=eo(o,r),c=dr(()=>({...i,...n,...r||{}}),[i,n,r]),y=dr(()=>(b,f)=>{let l=gt(c,b);return l==null&&(l=b),f&&typeof l=="string"&&Object.entries(f).forEach(([d,w])=>{l=l.replace(new RegExp(`{{${d}}}`,"g"),w)}),typeof l=="string"?l:b},[c]),u=dr(()=>({t:y,language:t}),[y,t]);return s?ro("div",{children:"Loading translations..."}):ro(oo.Provider,{value:u,children:e})},Z=()=>{let e=ut(oo);if(!e)throw new Error("useTranslation must be used within I18nProvider");return e};import{createContext as ft,useContext as pt,useReducer as ht,useEffect as no}from"react";import{jsx as bt}from"react/jsx-runtime";var io={currentScreen:"login",searchParams:{},formData:{username:"",password:"",email:"",code:"",newPassword:"",confirmPassword:""},loading:!1,errors:{global:[]},emailSent:!1,codeAlreadyExists:!1,codeValidated:!1,fromCodeVerification:!1,config:{}};function yt(e,r){switch(r.type){case"SET_SCREEN":let o={...e,currentScreen:r.payload.screen,searchParams:r.payload.params||e.searchParams,errors:{global:[]}},t=new URLSearchParams(o.searchParams),a=t.toString()?`?${t.toString()}`:window.location.pathname;try{window.history.replaceState({},"",a)}catch{}return o;case"SET_SEARCH_PARAMS":return{...e,searchParams:r.payload};case"UPDATE_FORM_DATA":return{...e,formData:{...e.formData,...r.payload},errors:{...e.errors,...Object.keys(r.payload).reduce((i,n)=>({...i,[n]:void 0}),{})}};case"SET_LOADING":return{...e,loading:r.payload};case"SET_ERRORS":return{...e,errors:{...e.errors,...r.payload}};case"CLEAR_ERRORS":return{...e,errors:{global:[]}};case"SET_EMAIL_SENT":return{...e,emailSent:r.payload};case"SET_CODE_ALREADY_EXISTS":return{...e,codeAlreadyExists:r.payload};case"SET_CODE_VALIDATED":return{...e,codeValidated:r.payload};case"SET_FROM_CODE_VERIFICATION":return{...e,fromCodeVerification:r.payload};case"RESET_FORM":return{...e,formData:io.formData,errors:{global:[]},loading:!1,emailSent:!1,codeAlreadyExists:!1,codeValidated:!1,fromCodeVerification:!1};case"INIT_CONFIG":return{...e,config:r.payload};default:return e}}var ao=ft(void 0),so=({children:e,initialScreen:r="login",config:o,autoReadFromCookies:t=!0})=>{let[a,i]=ht(yt,{...io,currentScreen:r});no(()=>{i({type:"INIT_CONFIG",payload:(()=>{let l={};if(t)try{let d=Mr("logo");if(d){let w=decodeURIComponent(d);w.startsWith("http")&&(l.logo=w)}}catch(d){v.error("Error reading configuration from cookies",d instanceof Error?d:{message:String(d)})}return{publicApiKey:o?.publicApiKey,env:o?.env,appName:o?.appName,logo:o?.logo||l.logo,loginActions:o?.loginActions}})()})},[o,t]),no(()=>{let f=new URLSearchParams(window.location.search),l={};f.forEach((d,w)=>{l[w]=d}),Object.keys(l).length>0&&i({type:"SET_SEARCH_PARAMS",payload:l}),r==="checkCode"&&l.email&&i({type:"UPDATE_FORM_DATA",payload:{email:l.email,code:l.code||""}}),r==="resetPassword"&&l.link&&i({type:"SET_SEARCH_PARAMS",payload:l})},[r]);let b={state:a,dispatch:i,setScreen:(f,l)=>{i({type:"SET_SCREEN",payload:{screen:f,params:l}})},updateFormData:f=>{i({type:"UPDATE_FORM_DATA",payload:f})},setFieldError:(f,l)=>{i({type:"SET_ERRORS",payload:{[f]:l}})},clearErrors:()=>{i({type:"CLEAR_ERRORS"})},setLoading:f=>{i({type:"SET_LOADING",payload:f})}};return bt(ao.Provider,{value:b,children:e})},Ye=()=>{let e=pt(ao);if(e===void 0)throw new Error("useLoginState must be used within a LoginStateProvider");return e};import{useEffect as wt,useRef as xt}from"react";import{Typography as ur,TextField as lo,Button as vt,Box as Oe,CircularProgress as Ct,Alert as Pt,Link as co}from"@mui/material";import{Fragment as Et,jsx as ee,jsxs as Be}from"react/jsx-runtime";var Tt=({onScreenChange:e,onExternalNavigate:r,onLoginSuccess:o,onError:t,redirectUrl:a="/"})=>{let{crudify:i}=ae(),{state:n,updateFormData:s,setFieldError:c,clearErrors:y,setLoading:u}=Ye(),{login:b}=he(),f=Z(),{t:l}=f,d=f.i18n,w=xt(null),m=Hr(l,{currentLanguage:d?.language,enableDebug:!1}),g=()=>{if(n.searchParams.redirect)try{let h=decodeURIComponent(n.searchParams.redirect);if(h.startsWith("/")&&!h.startsWith("//"))return h}catch{}return a||"/"};wt(()=>{let h=setTimeout(()=>{w.current&&w.current.focus()},100);return()=>clearTimeout(h)},[]);let p=h=>m.translateError({code:h.code,message:h.message,field:h.field}),P=async()=>{if(!n.loading){if(!n.formData.username.trim()){c("username",l("login.usernameRequired"));return}if(!n.formData.password.trim()){c("password",l("login.passwordRequired"));return}y(),u(!0);try{let h=await b(n.formData.username,n.formData.password);if(u(!1),h.success){let R=g();o&&o(h.data,R)}else{let R=h.rawResponse||h;I(R)}}catch(h){u(!1);let L=Y(h).map(p);c("global",L),t&&t(L.join(", "))}}},I=h=>{let R=Y(h),L=[];R.forEach(_=>{_.field?c(_.field,p(_)):L.push(p(_))}),L.length>0&&c("global",L)};return Be(Et,{children:[Be(Oe,{component:"form",noValidate:!0,onSubmit:h=>{h.preventDefault(),P()},onKeyDown:h=>{h.key==="Enter"&&!n.loading&&(h.preventDefault(),P())},sx:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[Be(Oe,{sx:{mb:1},children:[ee(ur,{variant:"body2",component:"label",htmlFor:"email",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:l("login.usernameOrEmailLabel")}),ee(lo,{fullWidth:!0,id:"email",name:"email",type:"email",value:n.formData.username,disabled:n.loading,onChange:h=>s({username:h.target.value}),error:!!n.errors.username,helperText:n.errors.username,autoComplete:"email",placeholder:l("login.usernameOrEmailPlaceholder"),inputRef:w,required:!0})]}),Be(Oe,{sx:{mb:1},children:[ee(ur,{variant:"body2",component:"label",htmlFor:"password",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:l("login.passwordLabel")}),ee(lo,{fullWidth:!0,id:"password",name:"password",type:"password",value:n.formData.password,disabled:n.loading,onChange:h=>s({password:h.target.value}),error:!!n.errors.password,helperText:n.errors.password,autoComplete:"current-password",placeholder:l("login.passwordPlaceholder"),required:!0})]}),n.config.loginActions?.includes("forgotPassword")&&ee(Oe,{sx:{display:"flex",justifyContent:"flex-end",alignItems:"center"},children:ee(co,{sx:{cursor:"pointer"},onClick:()=>{e?.("forgotPassword",n.searchParams)},variant:"body2",color:"secondary",children:l("login.forgotPasswordLink")})}),ee(vt,{disabled:n.loading,type:"submit",fullWidth:!0,variant:"contained",color:"primary",sx:{mt:1,mb:2},children:n.loading?ee(Ct,{size:20}):l("login.loginButton")})]}),ee(Oe,{children:n.errors.global&&n.errors.global.length>0&&n.errors.global.map((h,R)=>ee(Pt,{variant:"filled",sx:{mt:2},severity:"error",children:ee("div",{children:h})},R))}),n.config.loginActions?.includes("createUser")&&Be(ur,{variant:"body2",align:"center",sx:{color:"text.secondary",mt:3},children:[l("login.noAccountPrompt")," ",ee(co,{sx:{cursor:"pointer"},onClick:()=>{let R=`/public/users/create${Object.keys(n.searchParams).length>0?`?${new URLSearchParams(n.searchParams).toString()}`:""}`;r?.(R)},fontWeight:"medium",color:"secondary",children:l("login.signUpLink")})]})]})},uo=Tt;import{useState as ke,useEffect as Rt,useRef as St}from"react";import{Typography as Le,TextField as It,Button as mo,Box as ye,CircularProgress as kt,Alert as Lt,Link as mr}from"@mui/material";import{Fragment as go,jsx as V,jsxs as Pe}from"react/jsx-runtime";var At=({onScreenChange:e,onError:r})=>{let{crudify:o}=ae(),[t,a]=ke(""),[i,n]=ke(!1),[s,c]=ke([]),[y,u]=ke(null),[b,f]=ke(!1),[l,d]=ke(!1),w=St(null),{t:m}=Z();Rt(()=>{w.current&&!b&&!l&&w.current.focus()},[b,l]);let g=h=>{let R=[`errors.auth.${h.code}`,`errors.data.${h.code}`,`errors.system.${h.code}`,`errors.${h.code}`,`forgotPassword.${h.code.toLowerCase()}`];for(let L of R){let _=m(L);if(_!==L)return _}return h.message||m("error.unknown")},p=h=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(h),P=async()=>{if(!(i||!o)){if(c([]),u(null),!t){u(m("forgotPassword.emailRequired"));return}if(!p(t)){u(m("forgotPassword.invalidEmail"));return}n(!0);try{let h=[{operation:"requestPasswordReset",data:{email:t}}],R=await o.transaction(h);if(R.success)R.data&&R.data.existingCodeValid?d(!0):f(!0);else{let _=Y(R).map(g);c(_)}}catch(h){let L=Y(h).map(g);c(L),r&&r(L.join(", "))}finally{n(!1)}}},I=()=>{e?.("login")},M=()=>{if(b||l){e?.("checkCode",{email:t});return}if(!t){u(m("forgotPassword.emailRequired"));return}if(!p(t)){u(m("forgotPassword.invalidEmail"));return}e?.("checkCode",{email:t})};return b||l?V(go,{children:Pe(ye,{sx:{width:"100%",display:"flex",flexDirection:"column",gap:2,textAlign:"center"},children:[Pe(ye,{sx:{mb:2},children:[V(Le,{variant:"h5",component:"h1",sx:{mb:1,fontWeight:600},children:m(l?"forgotPassword.codeAlreadyExistsMessage":"forgotPassword.emailSentMessage")}),V(Le,{variant:"body2",sx:{color:l?"success.main":"grey.600"},children:m("forgotPassword.checkEmailInstructions")})]}),V(mo,{type:"button",onClick:M,fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2},children:m("forgotPassword.enterCodeLink")}),V(ye,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:V(mr,{sx:{cursor:"pointer"},onClick:I,variant:"body2",color:"secondary",children:m("common.back")})})]})}):Pe(go,{children:[Pe(ye,{component:"form",noValidate:!0,onSubmit:h=>{h.preventDefault(),P()},sx:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[Pe(ye,{sx:{mb:2},children:[V(Le,{variant:"h5",component:"h1",sx:{mb:1,fontWeight:600},children:m("forgotPassword.title")}),V(Le,{variant:"body2",sx:{color:"grey.600"},children:m("forgotPassword.instructions")})]}),Pe(ye,{sx:{mb:1},children:[V(Le,{variant:"body2",component:"label",htmlFor:"email",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:m("forgotPassword.emailLabel")}),V(It,{fullWidth:!0,id:"email",name:"email",type:"email",value:t,disabled:i,onChange:h=>a(h.target.value),error:!!y,helperText:y,autoComplete:"email",placeholder:m("forgotPassword.emailPlaceholder"),required:!0,autoFocus:!0,inputRef:w})]}),V(mo,{disabled:i,type:"submit",fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2},children:i?V(kt,{size:20}):m("forgotPassword.sendCodeButton")}),Pe(ye,{sx:{display:"flex",justifyContent:"center",alignItems:"center",gap:2},children:[V(mr,{sx:{cursor:"pointer"},onClick:I,variant:"body2",color:"secondary",children:m("common.back")}),V(Le,{variant:"body2",sx:{color:"grey.400"},children:"\u2022"}),V(mr,{sx:{cursor:"pointer"},onClick:M,variant:"body2",color:"secondary",children:m("login.alreadyHaveCodeLink")})]})]}),V(ye,{children:s.length>0&&s.map((h,R)=>V(Lt,{variant:"filled",sx:{mt:2},severity:"error",children:h},R))})]})},fo=At;import{useState as J,useEffect as po}from"react";import{Typography as Xe,TextField as ho,Button as Ft,Box as be,CircularProgress as yo,Alert as bo,Link as Dt}from"@mui/material";import{Fragment as Ot,jsx as q,jsxs as Ne}from"react/jsx-runtime";var _t=({onScreenChange:e,onError:r,searchParams:o,onResetSuccess:t})=>{let{crudify:a}=ae(),[i,n]=J(""),[s,c]=J(""),[y,u]=J(!1),[b,f]=J([]),[l,d]=J(null),[w,m]=J(null),[g,p]=J(""),[P,I]=J(""),[M,x]=J(!1),[h,R]=J(!0),[L,_]=J(!1),[re,oe]=J(null),[de,Re]=J(!1),{t:D}=Z(),j=C=>{let k=[`errors.auth.${C.code}`,`errors.data.${C.code}`,`errors.system.${C.code}`,`errors.${C.code}`,`resetPassword.${C.code.toLowerCase()}`];for(let F of k){let H=D(F);if(H!==F)return H}return C.message||D("error.unknown")},N=C=>o?o instanceof URLSearchParams?o.get(C):o[C]||null:null;po(()=>{if(o){if(o){let C=N("fromCodeVerification"),k=N("email"),F=N("code");if(C==="true"&&k&&F){p(k),I(F),x(!0),_(!0),R(!1);return}let H=N("link");if(H)try{let G=decodeURIComponent(H),[X,pe]=G.split("/");if(X&&pe&&X.length===6){I(X),p(pe),x(!1),oe({email:pe,code:X});return}}catch{}if(k&&F){p(k),I(F),x(!1),oe({email:k,code:F});return}}f([D("resetPassword.invalidCode")]),R(!1),setTimeout(()=>e?.("forgotPassword"),3e3)}},[o,a,D,e]),po(()=>{a&&re&&!de&&(Re(!0),(async(k,F)=>{try{let H=[{operation:"validatePasswordResetCode",data:{email:k,codePassword:F}}],G=await a.transaction(H);if(G.data&&Array.isArray(G.data)){let X=G.data[0];if(X&&X.response&&X.response.status==="OK"){_(!0);return}}if(G.success)_(!0);else{let pe=Y(G).map(j);f(pe),setTimeout(()=>e?.("forgotPassword"),3e3)}}catch(H){let X=Y(H).map(j);f(X),setTimeout(()=>e?.("forgotPassword"),3e3)}finally{R(!1),oe(null),Re(!1)}})(re.email,re.code))},[a,re,D,e]);let ue=C=>C.length<8?D("resetPassword.passwordTooShort"):null,S=async()=>{if(y||!a)return;f([]),d(null),m(null);let C=!1;if(!i)d(D("resetPassword.newPasswordRequired")),C=!0;else{let k=ue(i);k&&(d(k),C=!0)}if(s?i!==s&&(m(D("resetPassword.passwordsDoNotMatch")),C=!0):(m(D("resetPassword.confirmPasswordRequired")),C=!0),!C){u(!0);try{let k=[{operation:"validateAndResetPassword",data:{email:g,codePassword:P,newPassword:i}}],F=await a.transaction(k);if(F.success)f([]),setTimeout(()=>{t?.()},1e3);else{let G=Y(F).map(j);f(G)}}catch(k){let H=Y(k).map(j);f(H),r&&r(H.join(", "))}u(!1)}},W=()=>{M?e?.("checkCode",{email:g}):e?.("forgotPassword")};return h?q(be,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"300px"},children:q(yo,{})}):L?Ne(Ot,{children:[Ne(be,{component:"form",noValidate:!0,sx:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[Ne(be,{sx:{mb:2},children:[q(Xe,{variant:"h5",component:"h1",sx:{mb:1,fontWeight:600},children:D("resetPassword.title")}),q(Xe,{variant:"body2",sx:{color:"grey.600"},children:D("resetPassword.instructions")})]}),Ne(be,{sx:{mb:1},children:[q(Xe,{variant:"body2",component:"label",htmlFor:"newPassword",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:D("resetPassword.newPasswordLabel")}),q(ho,{fullWidth:!0,id:"newPassword",name:"newPassword",type:"password",value:i,disabled:y,onChange:C=>n(C.target.value),error:!!l,helperText:l,autoComplete:"new-password",placeholder:D("resetPassword.newPasswordPlaceholder"),required:!0})]}),Ne(be,{sx:{mb:1},children:[q(Xe,{variant:"body2",component:"label",htmlFor:"confirmPassword",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:D("resetPassword.confirmPasswordLabel")}),q(ho,{fullWidth:!0,id:"confirmPassword",name:"confirmPassword",type:"password",value:s,disabled:y,onChange:C=>c(C.target.value),error:!!w,helperText:w,autoComplete:"new-password",placeholder:D("resetPassword.confirmPasswordPlaceholder"),required:!0})]}),q(Ft,{disabled:y,type:"button",onClick:S,fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2},children:y?q(yo,{size:20}):D("resetPassword.resetPasswordButton")}),q(be,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:q(Dt,{sx:{cursor:"pointer"},onClick:W,variant:"body2",color:"secondary",children:D("common.back")})})]}),q(be,{children:b.length>0&&b.map((C,k)=>q(bo,{variant:"filled",sx:{mt:2},severity:"error",children:C},k))})]}):q(be,{children:b.length>0&&b.map((C,k)=>q(bo,{variant:"filled",sx:{mt:2},severity:"error",children:C},k))})},wo=_t;import{useState as ze,useEffect as xo,useRef as Bt}from"react";import{Typography as gr,TextField as Nt,Button as zt,Box as Ue,CircularProgress as Ut,Alert as Mt,Link as Vt}from"@mui/material";import{Fragment as Ht,jsx as se,jsxs as Je}from"react/jsx-runtime";var Wt=({onScreenChange:e,onError:r,searchParams:o})=>{let{crudify:t}=ae(),[a,i]=ze(""),[n,s]=ze(!1),[c,y]=ze([]),[u,b]=ze(null),[f,l]=ze(""),d=Bt(null),{t:w}=Z(),m=x=>o?o instanceof URLSearchParams?o.get(x):o[x]||null:null,g=x=>{let h=[`errors.auth.${x.code}`,`errors.data.${x.code}`,`errors.system.${x.code}`,`errors.${x.code}`,`checkCode.${x.code.toLowerCase()}`];for(let R of h){let L=w(R);if(L!==R)return L}return x.message||w("error.unknown")};xo(()=>{let x=m("email");x?l(x):e?.("forgotPassword")},[o,e]),xo(()=>{d.current&&d.current.focus()},[]);let p=async()=>{if(!(n||!t)){if(y([]),b(null),!a){b(w("checkCode.codeRequired"));return}if(a.length!==6){b(w("checkCode.codeRequired"));return}s(!0);try{let x=[{operation:"validatePasswordResetCode",data:{email:f,codePassword:a}}],h=await t.transaction(x);if(h.success)e?.("resetPassword",{email:f,code:a,fromCodeVerification:"true"});else{let L=Y(h).map(g);y(L),s(!1)}}catch(x){let R=Y(x).map(g);y(R),s(!1),r&&r(R.join(", "))}}},P=()=>{e?.("forgotPassword")},I=x=>{let h=x.target.value.replace(/\D/g,"").slice(0,6);i(h)};return Je(Ht,{children:[Je(Ue,{component:"form",noValidate:!0,onSubmit:x=>{x.preventDefault(),p()},sx:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[Je(Ue,{sx:{mb:2},children:[se(gr,{variant:"h5",component:"h1",sx:{mb:1,fontWeight:600},children:w("checkCode.title")}),se(gr,{variant:"body2",sx:{color:"grey.600"},children:w("checkCode.instructions")})]}),Je(Ue,{sx:{mb:1},children:[se(gr,{variant:"body2",component:"label",htmlFor:"code",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:w("checkCode.codeLabel")}),se(Nt,{fullWidth:!0,id:"code",name:"code",type:"text",value:a,disabled:n,onChange:I,error:!!u,helperText:u,placeholder:w("checkCode.codePlaceholder"),inputProps:{maxLength:6,style:{textAlign:"center",fontSize:"1.5rem",letterSpacing:"0.4rem"}},required:!0,autoFocus:!0,inputRef:d})]}),se(zt,{disabled:n||a.length!==6,type:"submit",fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2},children:n?se(Ut,{size:20}):w("checkCode.verifyButton")}),se(Ue,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:se(Vt,{sx:{cursor:"pointer"},onClick:P,variant:"body2",color:"secondary",children:w("common.back")})})]}),se(Ue,{children:c.length>0&&c.map((x,h)=>se(Mt,{sx:{mt:2},severity:"error",children:x},h))})]})},vo=Wt;import{Box as qt,CircularProgress as jt,Alert as Co,Typography as fr}from"@mui/material";import{Fragment as Kt,jsx as Ae,jsxs as Po}from"react/jsx-runtime";var To=({children:e,fallback:r})=>{let{isLoading:o,error:t,isInitialized:a}=ae(),{t:i}=Z();return o?r||Po(qt,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"200px",gap:2},children:[Ae(jt,{}),Ae(fr,{variant:"body2",color:"text.secondary",children:i("login.initializing")!=="login.initializing"?i("login.initializing"):"Initializing..."})]}):t?Ae(Co,{severity:"error",sx:{mt:2},children:Po(fr,{variant:"body2",children:[i("login.initializationError")!=="login.initializationError"?i("login.initializationError"):"Initialization error",":"," ",t]})}):a?Ae(Kt,{children:e}):Ae(Co,{severity:"warning",sx:{mt:2},children:Ae(fr,{variant:"body2",children:i("login.notInitialized")!=="login.notInitialized"?i("login.notInitialized"):"System not initialized"})})};import{jsx as te,jsxs as Jt}from"react/jsx-runtime";var Yt=({onScreenChange:e,onExternalNavigate:r,onLoginSuccess:o,onError:t,redirectUrl:a="/"})=>{let{t:i}=Z(),{state:n,setScreen:s}=Ye(),{config:c}=he(),{showNotification:y}=qr(),u=(f,l)=>{let d=l;f==="login"?d={}:f==="forgotPassword"&&!l&&(d={}),s(f,d),e?.(f,d)},b=()=>{let f={onScreenChange:u,onExternalNavigate:r,onError:t,redirectUrl:a};switch(n.currentScreen){case"forgotPassword":return te(fo,{...f});case"checkCode":return te(vo,{...f,searchParams:n.searchParams});case"resetPassword":return te(wo,{...f,searchParams:n.searchParams,onResetSuccess:()=>{let l=i("resetPassword.successMessage");y(l,"success"),u("login")}});default:return te(uo,{...f,onLoginSuccess:o})}};return Jt(To,{children:[te($t,{sx:{display:"flex",justifyContent:"center",mb:3},children:te("img",{src:c.logo||"https://logos.crudia.com/nocios-default.png",alt:i("login.logoAlt"),style:{width:"100%",maxWidth:"150px",height:"auto"},onError:f=>{let l=f.target;l.src="https://logos.crudia.com/nocios-default.png"}})}),!c.logo&&c.appName&&te(Gt,{variant:"h6",component:"h1",sx:{textAlign:"center",mb:2},children:c.appName}),b()]})},Xt=({translations:e,translationsUrl:r,language:o="en",initialScreen:t="login",autoReadFromCookies:a=!0,...i})=>{let{config:n}=he();return te(to,{translations:e,translationsUrl:r,language:o,children:te(Wr,{config:n,children:te(so,{config:n,initialScreen:t,autoReadFromCookies:a,children:te(Yt,{...i})})})})},xs=Xt;import{Box as Q,Card as Eo,CardContent as Ro,Typography as ne,Chip as Qe,Avatar as Qt,Divider as Zt,CircularProgress as en,Alert as So,List as rn,ListItem as pr,ListItemText as hr,ListItemIcon as on,Collapse as tn,IconButton as yr}from"@mui/material";import{Person as nn,Email as an,Badge as sn,Security as ln,Schedule as cn,AccountCircle as dn,ExpandMore as un,ExpandLess as mn,Info as gn}from"@mui/icons-material";import{useState as fn}from"react";import{Fragment as yn,jsx as E,jsxs as O}from"react/jsx-runtime";var pn=({showExtendedData:e=!0,showProfileCard:r=!0,autoRefresh:o=!0})=>{let{userProfile:t,loading:a,error:i,extendedData:n,refreshProfile:s}=jr({autoFetch:o,retryOnError:!0,maxRetries:3}),[c,y]=fn(!1);if(a)return O(Q,{display:"flex",justifyContent:"center",alignItems:"center",p:3,children:[E(en,{}),E(ne,{variant:"body2",sx:{ml:2},children:"Cargando perfil de usuario..."})]});if(i)return O(So,{severity:"error",action:E(yr,{color:"inherit",size:"small",onClick:s,children:E(ne,{variant:"caption",children:"Reintentar"})}),children:["Error al cargar el perfil: ",i]});if(!t)return E(So,{severity:"warning",children:"No se encontr\xF3 informaci\xF3n del usuario"});let u=n?.displayData||{},b=n?.totalFields||0,f=p=>{if(!p)return"No disponible";try{return new Date(p).toLocaleString("es-ES",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return p}},l=(p,P)=>P==null?"No disponible":typeof P=="boolean"?P?"S\xED":"No":Array.isArray(P)?P.length>0?P.join(", "):"Ninguno":typeof P=="object"?JSON.stringify(P,null,2):String(P),d=[{key:"id",label:"ID",icon:E(sn,{})},{key:"email",label:"Email",icon:E(an,{})},{key:"username",label:"Usuario",icon:E(nn,{})},{key:"fullName",label:"Nombre completo",icon:E(dn,{})},{key:"role",label:"Rol",icon:E(ln,{})}],w=[{key:"firstName",label:"Nombre"},{key:"lastName",label:"Apellido"},{key:"isActive",label:"Activo"},{key:"lastLogin",label:"\xDAltimo login"},{key:"createdAt",label:"Creado"},{key:"updatedAt",label:"Actualizado"}],m=[...d.map(p=>p.key),...w.map(p=>p.key),"permissions"],g=Object.keys(u).filter(p=>!m.includes(p)).map(p=>({key:p,label:p}));return O(Q,{children:[r&&E(Eo,{sx:{mb:2},children:O(Ro,{children:[O(Q,{display:"flex",alignItems:"center",mb:2,children:[E(Qt,{src:u.avatar,sx:{width:56,height:56,mr:2},children:u.fullName?.[0]||u.username?.[0]||u.email?.[0]}),O(Q,{children:[E(ne,{variant:"h6",children:u.fullName||u.username||u.email}),E(ne,{variant:"body2",color:"text.secondary",children:u.role||"Usuario"}),u.isActive!==void 0&&E(Qe,{label:u.isActive?"Activo":"Inactivo",color:u.isActive?"success":"error",size:"small",sx:{mt:.5}})]})]}),E(Q,{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(250px, 1fr))",gap:2,children:d.map(({key:p,label:P,icon:I})=>u[p]?O(Q,{display:"flex",alignItems:"center",children:[E(Q,{sx:{mr:1,color:"text.secondary"},children:I}),O(Q,{children:[E(ne,{variant:"caption",color:"text.secondary",children:P}),E(ne,{variant:"body2",children:l(p,u[p])})]})]},p):null)}),u.permissions&&Array.isArray(u.permissions)&&u.permissions.length>0&&O(Q,{mt:2,children:[E(ne,{variant:"caption",color:"text.secondary",display:"block",children:"Permisos"}),O(Q,{display:"flex",flexWrap:"wrap",gap:.5,mt:.5,children:[u.permissions.slice(0,5).map((p,P)=>E(Qe,{label:p,size:"small",variant:"outlined"},P)),u.permissions.length>5&&E(Qe,{label:`+${u.permissions.length-5} m\xE1s`,size:"small"})]})]})]})}),e&&E(Eo,{children:O(Ro,{children:[O(Q,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,children:[O(ne,{variant:"h6",display:"flex",alignItems:"center",children:[E(gn,{sx:{mr:1}}),"Informaci\xF3n Detallada"]}),E(Qe,{label:`${b} campos totales`,size:"small"})]}),O(rn,{dense:!0,children:[w.map(({key:p,label:P})=>u[p]!==void 0&&O(pr,{divider:!0,children:[E(on,{children:E(cn,{fontSize:"small"})}),E(hr,{primary:P,secondary:p.includes("At")||p.includes("Login")?f(u[p]):l(p,u[p])})]},p)),g.length>0&&O(yn,{children:[E(Zt,{sx:{my:1}}),E(pr,{children:E(hr,{primary:O(Q,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[O(ne,{variant:"subtitle2",children:["Campos Personalizados (",g.length,")"]}),E(yr,{size:"small",onClick:()=>y(!c),children:c?E(mn,{}):E(un,{})})]})})}),E(tn,{in:c,children:g.map(({key:p,label:P})=>E(pr,{sx:{pl:4},children:E(hr,{primary:P,secondary:l(p,u[p])})},p))})]})]}),O(Q,{mt:2,display:"flex",justifyContent:"space-between",alignItems:"center",children:[O(ne,{variant:"caption",color:"text.secondary",children:["\xDAltima actualizaci\xF3n: ",f(u.updatedAt)]}),E(yr,{size:"small",onClick:s,disabled:a,children:E(ne,{variant:"caption",children:"Actualizar"})})]})]})})]})},hn=pn;var Io=["create","read","update","delete"],ko=["create","read","update","delete"];import{useRef as Mn}from"react";import{useTranslation as Vn}from"react-i18next";import{Box as rr,Typography as Bo,Button as Wn,Stack as Hn,Alert as No,Divider as qn}from"@mui/material";import{Add as jn}from"@mui/icons-material";import{forwardRef as Sn}from"react";import{useTranslation as In}from"react-i18next";import{Box as Te,FormControl as kn,InputLabel as Ln,Select as An,MenuItem as Fn,IconButton as Dn,Typography as Fe,FormHelperText as _n,Stack as er,Paper as Oo,Divider as On,Button as vr}from"@mui/material";import{Delete as Bn,SelectAll as Nn,ClearAll as zn}from"@mui/icons-material";import{useState as Lo,useEffect as Ao,useRef as Fo}from"react";import{useTranslation as bn}from"react-i18next";import{Box as Ze,Typography as Me,Button as Do,Stack as br,FormControlLabel as wn,FormHelperText as _o,Switch as xn,ToggleButton as wr,ToggleButtonGroup as vn}from"@mui/material";import{CheckCircle as Cn,Cancel as Pn,SelectAll as Tn,ClearAll as En}from"@mui/icons-material";import{jsx as z,jsxs as we}from"react/jsx-runtime";var Rn=({value:e,onChange:r,availableFields:o,error:t,disabled:a=!1})=>{let{t:i}=bn(),[n,s]=Lo("custom"),[c,y]=Lo(!1),u=Fo(null);Ao(()=>{c&&u.current?.scrollIntoView({behavior:"smooth",block:"start"})},[c]);let b=Fo(!1);Ao(()=>{let m=e||{allow:[],owner_allow:[],deny:[]},g=new Set(o),p=(m.allow||[]).filter(x=>g.has(x)),P=(m.owner_allow||[]).filter(x=>g.has(x)),I=(m.deny||[]).filter(x=>g.has(x));o.forEach(x=>{!p.includes(x)&&!P.includes(x)&&!I.includes(x)&&I.push(x)});let M={allow:p,owner_allow:P,deny:I};JSON.stringify(M)!==JSON.stringify(m)&&r(M),p.length===o.length?s("all"):I.length===o.length?s("none"):s("custom")},[o,e]);let f=()=>{b.current=!0,r({allow:[...o],owner_allow:[],deny:[]}),s("all"),setTimeout(()=>{b.current=!1},0)},l=()=>{b.current=!0,r({allow:[],owner_allow:[],deny:[...o]}),s("none"),setTimeout(()=>{b.current=!1},0)},d=m=>e?.allow?.includes(m)?"allow":e?.owner_allow?.includes(m)?"owner_allow":"deny",w=(m,g)=>{b.current=!0;let p=new Set(e?.allow||[]),P=new Set(e?.owner_allow||[]),I=new Set(e?.deny||[]);p.delete(m),P.delete(m),I.delete(m),g==="allow"&&p.add(m),g==="owner_allow"&&P.add(m),g==="deny"&&I.add(m),r({allow:Array.from(p),owner_allow:Array.from(P),deny:Array.from(I)}),s("custom"),setTimeout(()=>{b.current=!1},0)};return o.length===0?we(Ze,{children:[z(Me,{variant:"body2",color:"text.secondary",sx:{mb:1},children:i("modules.form.publicPolicies.fields.conditions.label")}),z(Me,{variant:"body2",color:"text.secondary",sx:{fontStyle:"italic"},children:i("modules.form.publicPolicies.fields.conditions.noFieldsAvailable")}),t&&z(_o,{error:!0,sx:{mt:1},children:t})]}):we(Ze,{children:[z(Me,{variant:"body2",color:"text.secondary",sx:{mb:2},children:i("modules.form.publicPolicies.fields.conditions.label")}),we(br,{direction:"row",spacing:1,alignItems:"center",sx:{mb:c?3:1},children:[z(Do,{variant:n==="all"?"contained":"outlined",startIcon:z(Tn,{}),onClick:f,disabled:a,size:"small",sx:{minWidth:120,...n==="all"&&{backgroundColor:"#16a34a","&:hover":{backgroundColor:"#15803d"}}},children:i("modules.form.publicPolicies.fields.conditions.allFields")}),z(Do,{variant:n==="none"?"contained":"outlined",startIcon:z(En,{}),onClick:l,disabled:a,size:"small",sx:{minWidth:120,...n==="none"&&{backgroundColor:"#cf222e","&:hover":{backgroundColor:"#bc1f2c"}}},children:i("modules.form.publicPolicies.fields.conditions.noFields")}),z(Ze,{sx:{display:"flex",alignItems:"center",px:1.5,py:.35,borderRadius:"999px",backgroundColor:"#f3f4f6",border:"1px solid #d1d9e0"},children:z(wn,{control:z(xn,{size:"small",checked:c,onChange:()=>y(m=>!m),disabled:a,color:"primary",sx:{transform:"scale(1.15)",transformOrigin:"center",m:0}}),label:i("modules.form.publicPolicies.fields.conditions.customEdit"),labelPlacement:"end",sx:{ml:0,".MuiFormControlLabel-label":{fontSize:"0.75rem"}}})})]}),c&&we(Ze,{ref:u,sx:{p:2,border:"1px solid #d1d9e0",borderRadius:1,backgroundColor:"#f6f8fa"},children:[z(Me,{variant:"body2",color:"text.secondary",sx:{mb:2},children:i("modules.form.publicPolicies.fields.conditions.help")}),z(br,{spacing:1,children:o.map(m=>{let g=d(m);return we(br,{direction:"row",spacing:1,alignItems:"center",children:[z(Me,{variant:"body2",sx:{minWidth:100,fontFamily:"monospace"},children:m}),we(vn,{value:g,exclusive:!0,size:"small",children:[we(wr,{value:"allow",onClick:()=>w(m,"allow"),disabled:a,sx:{px:2,color:g==="allow"?"#ffffff":"#6b7280",backgroundColor:g==="allow"?"#16a34a":"#f3f4f6",borderColor:g==="allow"?"#16a34a":"#d1d5db","&:hover":{backgroundColor:g==="allow"?"#15803d":"#e5e7eb",borderColor:g==="allow"?"#15803d":"#9ca3af"},"&.Mui-selected":{backgroundColor:"#16a34a",color:"#ffffff","&:hover":{backgroundColor:"#15803d"}}},children:[z(Cn,{sx:{fontSize:16,mr:.5}}),i("modules.form.publicPolicies.fields.conditions.states.allow")]}),z(wr,{value:"owner_allow",onClick:()=>w(m,"owner_allow"),disabled:a,sx:{px:2,color:g==="owner_allow"?"#ffffff":"#6b7280",backgroundColor:g==="owner_allow"?"#0ea5e9":"#f3f4f6",borderColor:g==="owner_allow"?"#0ea5e9":"#d1d5db","&:hover":{backgroundColor:g==="owner_allow"?"#0284c7":"#e5e7eb",borderColor:g==="owner_allow"?"#0284c7":"#9ca3af"},"&.Mui-selected":{backgroundColor:"#0ea5e9",color:"#ffffff","&:hover":{backgroundColor:"#0284c7"}}},children:i("modules.form.publicPolicies.fields.conditions.states.ownerAllow")}),we(wr,{value:"deny",onClick:()=>w(m,"deny"),disabled:a,sx:{px:2,color:g==="deny"?"#ffffff":"#6b7280",backgroundColor:g==="deny"?"#dc2626":"#f3f4f6",borderColor:g==="deny"?"#dc2626":"#d1d5db","&:hover":{backgroundColor:g==="deny"?"#b91c1c":"#e5e7eb",borderColor:g==="deny"?"#b91c1c":"#9ca3af"},"&.Mui-selected":{backgroundColor:"#dc2626",color:"#ffffff","&:hover":{backgroundColor:"#b91c1c"}}},children:[z(Pn,{sx:{fontSize:16,mr:.5}}),i("modules.form.publicPolicies.fields.conditions.states.deny")]})]})]},m)})})]}),t&&z(_o,{error:!0,sx:{mt:1},children:t})]})},xr=Rn;import{jsx as U,jsxs as K}from"react/jsx-runtime";var Un=Sn(({policy:e,onChange:r,onRemove:o,availableFields:t,isSubmitting:a=!1,usedActions:i,error:n},s)=>{let{t:c}=In(),y=new Set(Array.from(i||[]));y.delete(e.action);let u=Io.map(b=>({value:b,label:c(`modules.form.publicPolicies.fields.action.options.${b}`)}));return K(Oo,{ref:s,sx:{p:3,border:"1px solid #d1d9e0",borderRadius:2,position:"relative",backgroundColor:"#ffffff"},children:[K(Te,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:3},children:[U(Fe,{variant:"subtitle1",sx:{fontWeight:600,color:"#111418",fontSize:"1rem"},children:c("modules.form.publicPolicies.policyTitle")}),U(Dn,{onClick:o,size:"small",disabled:a,"aria-label":c("modules.form.publicPolicies.removePolicy"),sx:{color:"#656d76","&:hover":{color:"#cf222e",backgroundColor:"rgba(207, 34, 46, 0.1)"}},children:U(Bn,{})})]}),K(er,{spacing:1,children:[U(er,{direction:{xs:"column",md:"row"},spacing:2,children:U(Te,{sx:{flex:1,minWidth:200},children:K(kn,{fullWidth:!0,children:[U(Ln,{children:c("modules.form.publicPolicies.fields.action.label")}),U(An,{value:e.action,label:c("modules.form.publicPolicies.fields.action.label"),disabled:a,onChange:b=>{let f=b.target.value,l={...e,action:f};f==="delete"?(l.permission="deny",delete l.fields):(l.fields={allow:[],owner_allow:[],deny:t},delete l.permission),r(l)},sx:{backgroundColor:"#ffffff","&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"#8c959f"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"#0969da",borderWidth:2}},children:u.map(b=>{let f=y.has(b.value);return U(Fn,{value:b.value,disabled:f,children:b.label},b.value)})}),n&&U(_n,{error:!0,children:n})]})})}),e.action==="delete"?K(Te,{children:[U(Fe,{variant:"body2",color:"text.secondary",sx:{mb:2},children:c("modules.form.publicPolicies.fields.conditions.label")}),K(er,{direction:"row",spacing:1,sx:{mb:1},children:[U(vr,{variant:e.permission==="*"?"contained":"outlined",startIcon:U(Nn,{}),onClick:()=>r({...e,permission:"*"}),disabled:a,size:"small",sx:{minWidth:140,whiteSpace:"nowrap",...e.permission==="*"&&{backgroundColor:"#16a34a","&:hover":{backgroundColor:"#15803d"}}},children:c("modules.form.publicPolicies.fields.conditions.allFields")}),U(vr,{variant:e.permission==="owner"?"contained":"outlined",onClick:()=>r({...e,permission:"owner"}),disabled:a,size:"small",sx:{minWidth:140,whiteSpace:"nowrap",...e.permission==="owner"&&{backgroundColor:"#0ea5e9","&:hover":{backgroundColor:"#0284c7"}}},children:c("modules.form.publicPolicies.fields.conditions.states.ownerAllow")}),U(vr,{variant:e.permission==="deny"?"contained":"outlined",startIcon:U(zn,{}),onClick:()=>r({...e,permission:"deny"}),disabled:a,size:"small",sx:{minWidth:140,whiteSpace:"nowrap",...e.permission==="deny"&&{backgroundColor:"#cf222e","&:hover":{backgroundColor:"#bc1f2c"}}},children:c("modules.form.publicPolicies.fields.conditions.noFields")})]})]}):U(xr,{value:e.fields||{allow:[],owner_allow:[],deny:[]},onChange:b=>r({...e,fields:b}),availableFields:t,disabled:a}),U(Oo,{variant:"outlined",sx:{p:2,backgroundColor:"#f9fafb"},children:e.action==="delete"?K(Fe,{variant:"body2",sx:{fontFamily:"monospace",color:"text.secondary"},children:[K(Te,{component:"span",sx:{color:e.permission==="*"?"#16a34a":e.permission==="owner"?"#0ea5e9":"#dc2626"},children:[c("modules.form.publicPolicies.fields.conditions.states.allow"),":"]})," ",e.permission||"-"]}):K(er,{spacing:.5,divider:U(On,{sx:{borderColor:"#e5e7eb"}}),children:[K(Fe,{variant:"body2",sx:{fontFamily:"monospace",color:"text.secondary"},children:[K(Te,{component:"span",sx:{color:"#16a34a"},children:[c("modules.form.publicPolicies.fields.conditions.states.allow"),":"]})," ",(e?.fields?.allow||[]).join(", ")||"-"]}),K(Fe,{variant:"body2",sx:{fontFamily:"monospace",color:"text.secondary"},children:[K(Te,{component:"span",sx:{color:"#0ea5e9"},children:[c("modules.form.publicPolicies.fields.conditions.states.ownerAllow"),":"]})," ",(e?.fields?.owner_allow||[]).join(", ")||"-"]}),K(Fe,{variant:"body2",sx:{fontFamily:"monospace",color:"text.secondary"},children:[K(Te,{component:"span",sx:{color:"#dc2626"},children:[c("modules.form.publicPolicies.fields.conditions.states.deny"),":"]})," ",(e?.fields?.deny||[]).join(", ")||"-"]})]})})]})]})}),Cr=Un;import{Fragment as Gn,jsx as le,jsxs as or}from"react/jsx-runtime";var Kn=()=>{let e=globalThis?.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`},$n=({policies:e,onChange:r,availableFields:o,errors:t,isSubmitting:a=!1})=>{let{t:i}=Vn(),n=Mn({}),s=new Set((e||[]).map(d=>d.action).filter(Boolean)),c=ko.filter(d=>!s.has(d)),y=c.length>0,u=()=>{let d=c[0]||"create",w={id:Kn(),action:d};d==="delete"?w.permission="deny":w.fields={allow:[],owner_allow:[],deny:o};let m=[...e||[],w];r(m),setTimeout(()=>{let g=m.length-1,p=n.current[g];p&&p.scrollIntoView({behavior:"smooth",block:"center"})},100)},b=d=>{let w=[...e];w.splice(d,1),r(w)},f=(()=>{if(!t)return null;if(typeof t=="string")return t;let d=t._error;return typeof d=="string"?d:null})(),l=new Set((e||[]).map(d=>d.action));return or(Gn,{children:[le(qn,{sx:{borderColor:"#e0e4e7"}}),or(rr,{children:[le(rr,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3,children:or(rr,{children:[le(Bo,{variant:"h6",sx:{fontWeight:600,color:"#111418",mb:1},children:i("modules.form.publicPolicies.title")}),le(Bo,{variant:"body2",color:"text.secondary",sx:{fontSize:"0.875rem"},children:i("modules.form.publicPolicies.description")})]})}),f&&le(No,{severity:"error",sx:{mb:3},children:f}),or(Hn,{spacing:3,children:[(e||[]).length===0?le(No,{severity:"info",children:i("modules.form.publicPolicies.noPolicies")}):e.map((d,w)=>le(Cr,{ref:m=>{n.current[w]=m},policy:d,onChange:m=>{let g=[...e];g[w]=m,r(g)},onRemove:()=>b(w),availableFields:o,isSubmitting:a,usedActions:l,error:typeof t=="object"&&t&&d.id in t?t[d.id]:void 0},d.id)),y&&le(rr,{children:le(Wn,{type:"button",variant:"outlined",startIcon:le(jn,{}),onClick:u,disabled:a,sx:{borderColor:"#d0d7de",color:"#656d76","&:hover":{borderColor:"#8c959f",backgroundColor:"transparent"}},children:i("modules.form.publicPolicies.addPolicy")})})]})]})]})},nl=$n;import{useState as Pr}from"react";import{Button as tr,TextField as zo,Box as De,Alert as Ve,Typography as xe,CircularProgress as Tr}from"@mui/material";import{jsx as B,jsxs as ge}from"react/jsx-runtime";function ul(){let[e,r]=Pr(""),[o,t]=Pr(""),[a,i]=Pr(!1),{isAuthenticated:n,isLoading:s,error:c,login:y,logout:u,refreshTokens:b,clearError:f,isExpiringSoon:l,expiresIn:d}=he(),w=async p=>{if(p.preventDefault(),!e||!o)return;(await y(e,o)).success&&(r(""),t(""),i(!1))},m=async()=>{await u()},g=async()=>{await b()};return n?ge(De,{sx:{maxWidth:600,mx:"auto",p:3},children:[B(xe,{variant:"h4",gutterBottom:!0,children:"Welcome! \u{1F389}"}),B(Ve,{severity:"success",sx:{mb:3},children:"You are successfully logged in with Refresh Token Pattern enabled"}),ge(De,{sx:{mb:3,p:2,bgcolor:"background.paper",border:1,borderColor:"divider",borderRadius:1},children:[B(xe,{variant:"h6",gutterBottom:!0,children:"Token Status"}),ge(xe,{variant:"body2",color:"text.secondary",children:["Access Token expires in: ",Math.round(d/1e3/60)," minutes"]}),l&&B(Ve,{severity:"warning",sx:{mt:1},children:"Token expires soon - automatic refresh will happen"})]}),ge(De,{sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[B(tr,{variant:"contained",onClick:g,disabled:s,startIcon:s?B(Tr,{size:16}):null,children:"Refresh Tokens"}),B(tr,{variant:"outlined",color:"error",onClick:m,disabled:s,children:"Logout"})]}),c&&B(Ve,{severity:"error",sx:{mt:2},onClose:f,children:c})]}):ge(De,{sx:{maxWidth:400,mx:"auto",p:3},children:[B(xe,{variant:"h4",gutterBottom:!0,align:"center",children:"Login with Refresh Tokens"}),B(Ve,{severity:"info",sx:{mb:3},children:"This demo shows the new Refresh Token Pattern with automatic session management"}),a?ge("form",{onSubmit:w,children:[B(zo,{fullWidth:!0,label:"Email",type:"email",value:e,onChange:p=>r(p.target.value),margin:"normal",required:!0,autoComplete:"email"}),B(zo,{fullWidth:!0,label:"Password",type:"password",value:o,onChange:p=>t(p.target.value),margin:"normal",required:!0,autoComplete:"current-password"}),B(tr,{type:"submit",fullWidth:!0,variant:"contained",size:"large",disabled:s,startIcon:s?B(Tr,{size:16}):null,sx:{mt:3,mb:2},children:s?"Logging in...":"Login"})]}):B(tr,{fullWidth:!0,variant:"contained",size:"large",onClick:()=>i(!0),sx:{mt:2},children:"Show Login Form"}),c&&B(Ve,{severity:"error",sx:{mt:2},onClose:f,children:c})]})}function ml(){let{isAuthenticated:e,isLoading:r,isExpiringSoon:o,expiresIn:t}=he();return r?ge(De,{sx:{display:"flex",alignItems:"center",gap:1},children:[B(Tr,{size:16}),B(xe,{variant:"caption",children:"Loading session..."})]}):e?ge(De,{children:[B(xe,{variant:"caption",color:"success.main",children:"\u2713 Authenticated"}),o&&ge(xe,{variant:"caption",color:"warning.main",display:"block",children:["\u26A0 Token expires in ",Math.round(t/1e3/60)," min"]})]}):B(xe,{variant:"caption",color:"text.secondary",children:"Not logged in"})}import Yn from"@mui/material/TextField";import Xn from"@mui/material/CircularProgress";import Uo from"@mui/material/InputAdornment";import Jn from"@mui/material/IconButton";import Qn from"@mui/icons-material/Refresh";import{jsx as ve}from"react/jsx-runtime";var Zn=e=>e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,""),ei=({html:e})=>ve("span",{dangerouslySetInnerHTML:{__html:Zn(e)}}),vl=({config:e,value:r,onChange:o,label:t,error:a=!1,helperText:i,readOnly:n=!1,disabled:s=!1})=>{let{value:c,loading:y,error:u,regenerate:b}=Kr(e,{autoFetch:!r,onSuccess:g=>{o?.(g)}}),f=r||c,l=a||!!u,d=u||i,w=l&&d&&(d.toLowerCase().includes("duplicate")||d.toLowerCase().includes("duplicado")||d.toLowerCase().includes("duplicada")||d.toLowerCase().includes("unique")||d.toLowerCase().includes("\xFAnico")||d.toLowerCase().includes("unico")||d.toLowerCase().includes("\xFAnica")||d.toLowerCase().includes("unica")||d.toLowerCase().includes("already exists")||d.toLowerCase().includes("ya existe")||d.toLowerCase().includes("e11000"));return ve(Yn,{label:t,fullWidth:!0,value:f,error:l,helperText:d?ve(ei,{html:d}):" ",disabled:s,InputProps:{readOnly:!0,startAdornment:y?ve(Uo,{position:"start",children:ve(Xn,{size:20})}):void 0,endAdornment:w&&!y?ve(Uo,{position:"end",children:ve(Jn,{edge:"end",onClick:async()=>{!s&&!y&&await b()},disabled:s,size:"small",color:"error","aria-label":"regenerar c\xF3digo",title:"Regenerar c\xF3digo",children:ve(Qn,{})})}):void 0}})};import Er,{useCallback as fe,useRef as Mo,useState as We}from"react";import Ee from"@mui/material/Box";import Ce from"@mui/material/Typography";import Rr from"@mui/material/IconButton";import ri from"@mui/material/LinearProgress";import nr from"@mui/material/CircularProgress";import Wo from"@mui/material/Chip";import oi from"@mui/material/Paper";import ti from"@mui/material/List";import ni from"@mui/material/ListItem";import ii from"@mui/material/ListItemText";import ai from"@mui/material/ListItemSecondaryAction";import si from"@mui/material/FormHelperText";import li from"@mui/material/Dialog";import ci from"@mui/material/DialogTitle";import di from"@mui/material/DialogContent";import ui from"@mui/material/DialogActions";import Vo from"@mui/material/Button";import mi from"@mui/icons-material/CloudUpload";import gi from"@mui/icons-material/InsertDriveFile";import fi from"@mui/icons-material/Image";import pi from"@mui/icons-material/PictureAsPdf";import hi from"@mui/icons-material/Delete";import yi from"@mui/icons-material/Refresh";import bi from"@mui/icons-material/Restore";import wi from"@mui/icons-material/CheckCircle";import xi from"@mui/icons-material/Error";import Ql from"@mui/icons-material/BrokenImage";import{jsx as T,jsxs as ce}from"react/jsx-runtime";var vi=e=>e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,""),Ci=e=>{if(e===0)return"0 B";let r=1024,o=["B","KB","MB","GB"],t=Math.floor(Math.log(e)/Math.log(r));return`${parseFloat((e/Math.pow(r,t)).toFixed(1))} ${o[t]}`},Pi=e=>e.startsWith("image/")?T(fi,{color:"primary"}):e==="application/pdf"?T(pi,{color:"error"}):T(gi,{color:"action"}),Ti=(e,r)=>{switch(e){case"completed":return T(wi,{color:"success",fontSize:"small"});case"error":return T(xi,{color:"error",fontSize:"small"});case"uploading":case"pending":return T(nr,{size:16});case"removing":return T(nr,{size:16,color:"error"});case"pendingDeletion":return T(Wo,{label:r("file.pendingDeletion"),size:"small",color:"warning",variant:"outlined",sx:{fontSize:"0.65rem",height:20}});default:return null}},Ei=({file:e,baseUrl:r,disabled:o,onRemove:t,onRestore:a,onRetry:i})=>{let{t:n}=_e(),[s,c]=We(!1),y=e.status==="pendingDeletion",u=!o&&e.status!=="uploading"&&e.status!=="removing"&&!y,b=!o&&y,f=!o&&e.status==="error"&&e.file,l=e.contentType.startsWith("image/"),d=e.visibility==="public"||e.filePath?.startsWith("public/")||e.filePath?.startsWith(r),m=!e.filePath||!d?null:e.filePath.startsWith("http://")||e.filePath.startsWith("https://")||e.filePath.startsWith(r)?e.filePath:`${r}${e.filePath}`,g=e.status==="completed"&&m,p=()=>l&&g&&!s?T(Ee,{component:g?"a":"div",href:m||void 0,target:"_blank",rel:"noopener noreferrer",sx:{width:48,height:48,borderRadius:1,overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"grey.100",border:"1px solid",borderColor:"divider",cursor:g?"pointer":"default",transition:"all 0.2s ease",flexShrink:0,"&:hover":g?{borderColor:"primary.main",transform:"scale(1.05)"}:{}},children:T("img",{src:m,alt:e.name,style:{width:"100%",height:"100%",objectFit:"cover"},onError:()=>c(!0)})}):T(Ee,{component:g?"a":"div",href:m||void 0,target:"_blank",rel:"noopener noreferrer",sx:{width:48,height:48,borderRadius:1,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"grey.50",border:"1px solid",borderColor:"divider",cursor:g?"pointer":"default",transition:"all 0.2s ease",flexShrink:0,textDecoration:"none","&:hover":g?{borderColor:"primary.main",bgcolor:"action.hover"}:{}},children:Pi(e.contentType)});return ce(ni,{sx:{borderRadius:1,mb:.5,bgcolor:e.status==="error"?"error.lighter":"background.paper",border:"1px solid",borderColor:e.status==="error"?"error.light":"divider",gap:1.5},children:[p(),T(ii,{primary:ce(Ee,{sx:{display:"flex",alignItems:"center",gap:1},children:[T(Ce,{variant:"body2",noWrap:!0,sx:{maxWidth:200,overflow:"hidden",textOverflow:"ellipsis",textDecoration:y?"line-through":"none",opacity:y?.6:1},children:e.name}),Ti(e.status,n)]}),secondary:ce(Ee,{sx:{opacity:y?.6:1},children:[e.size>0&&T(Ce,{variant:"caption",color:"text.secondary",children:Ci(e.size)}),e.status==="uploading"&&T(ri,{variant:"determinate",value:e.progress,sx:{mt:.5,height:4,borderRadius:2}}),e.status==="error"&&e.errorMessage&&T(Ce,{variant:"caption",color:"error",display:"block",children:e.errorMessage}),g&&T(Ce,{variant:"caption",color:"primary",display:"block",component:"a",href:m||void 0,target:"_blank",rel:"noopener noreferrer",sx:{cursor:"pointer",textDecoration:"underline","&:hover":{textDecoration:"none"}},children:n(l?"file.clickToPreview":"file.clickToDownload")})]})}),ce(ai,{children:[f&&T(Rr,{edge:"end",size:"small",onClick:()=>i(e.id),color:"primary",title:n("file.restore"),children:T(yi,{fontSize:"small"})}),b&&T(Rr,{edge:"end",size:"small",onClick:()=>a(e.id),color:"primary",title:n("file.restore"),children:T(bi,{fontSize:"small"})}),u&&T(Rr,{edge:"end",size:"small",onClick:()=>t(e.id),color:"error",title:n("file.delete"),children:T(hi,{fontSize:"small"})})]})]})};var rc=({label:e,accept:r,maxFileSize:o=10*1024*1024,multiple:t=!1,maxFiles:a,minFiles:i=0,required:n=!1,disabled:s=!1,error:c=!1,helperText:y,onChange:u,onValidation:b,initialFiles:f,placeholder:l,showFileList:d=!0,visibility:w="private",showPreview:m=!0,baseUrl:g,onDeletionHandlersReady:p,mode:P="create"})=>{let{t:I}=_e(),M=Mo(null),[x,h]=We(!1),[R,L]=We(!1),[_,re]=We(null),[oe,de]=We(!1),Re=t?a:1,D=n?Math.max(i,1):i,j={acceptedTypes:r,maxFileSize:o,maxFiles:Re,minFiles:D,visibility:w,mode:P,onFilesChange:A=>{let ie=A.filter(qe=>qe.status==="completed"&&qe.filePath).map(qe=>{let Se=qe.filePath;return Se.startsWith(g)||Se.startsWith("http://")||Se.startsWith("https://")?Se:g?`${g}${Se}`:Se});u?.(ie)}},{files:N,isUploading:ue,addFiles:S,removeFile:W,restoreFile:C,retryUpload:k,isValid:F,validationError:H,validationErrorKey:G,validationErrorParams:X,initializeFiles:pe,isTouched:Ki,markAsTouched:He,isSubmitted:Ko,markAsSubmitted:Ir,getPreviewUrl:$i,commitDeletions:kr,restorePendingDeletions:Lr,hasPendingDeletions:Ar,deleteFileImmediately:Fr,activeFiles:Gi,activeFileCount:$o,waitForUploads:Dr,completedFilePaths:_r}=$r(j),Or=fe(()=>_r,[_r]),Br=Mo(!1);Er.useEffect(()=>{f&&f.length>0&&!Br.current&&(Br.current=!0,pe(f,g))},[f,pe,g]),Er.useEffect(()=>{b?.(F,H)},[F,H,b]),Er.useEffect(()=>{p?.({commitDeletions:kr,restorePendingDeletions:Lr,hasPendingDeletions:Ar,markAsSubmitted:Ir,isValid:F,isUploading:ue,waitForUploads:Dr,getCompletedFilePaths:Or})},[p,kr,Lr,Ar,Ir,F,ue,Dr,Or]);let Go=fe(A=>{He();let ie=A.target.files;ie&&ie.length>0&&S(ie),M.current&&(M.current.value="")},[S,He]),Yo=fe(()=>{s||M.current?.click()},[s]),Xo=fe(A=>{A.preventDefault(),A.stopPropagation(),s||h(!0)},[s]),Jo=fe(A=>{A.preventDefault(),A.stopPropagation(),h(!1)},[]),Qo=fe(A=>{if(A.preventDefault(),A.stopPropagation(),h(!1),s)return;He();let ie=A.dataTransfer.files;ie&&ie.length>0&&S(ie)},[s,S,He]),Zo=fe(async A=>{(await W(A)).needsConfirmation&&(re(A),L(!0))},[W]),et=fe(async()=>{if(_){de(!0);try{let A=await Fr(_);A.success||console.error("Error deleting file:",A.error)}finally{de(!1),L(!1),re(null)}}},[_,Fr]),Nr=fe(()=>{L(!1),re(null)},[]),rt=r?.join(",")||"",ot=!s&&(t||$o===0),zr=Ko&&!F,ar=c||zr,Ur=y||(zr&&G?I(G,X):null);return ce(Ee,{sx:{width:"100%"},children:[e&&ce(Ce,{variant:"body2",sx:{mb:1,fontWeight:500,color:ar?"error.main":"text.primary"},children:[e,n&&T("span",{style:{color:"red"},children:" *"})]}),T("input",{ref:M,type:"file",accept:rt,multiple:t,onChange:Go,disabled:s,style:{display:"none"}}),ot&&ce(oi,{variant:"outlined",onClick:Yo,onDragOver:Xo,onDragLeave:Jo,onDrop:Qo,sx:{p:3,textAlign:"center",cursor:s?"not-allowed":"pointer",borderStyle:"dashed",borderWidth:2,borderColor:x?"primary.main":ar?"error.main":"divider",bgcolor:x?"primary.lighter":s?"action.disabledBackground":"background.paper",transition:"all 0.2s ease","&:hover":s?{}:{borderColor:"primary.main",bgcolor:"action.hover"}},children:[T(mi,{sx:{fontSize:48,color:x?"primary.main":s?"action.disabled":"action.active",mb:1}}),T(Ce,{variant:"body2",color:s?"text.disabled":"text.secondary",children:l||I(x?"file.dropHere":"file.dragOrClick")}),r&&r.length>0&&!x&&T(Ee,{sx:{mt:1,display:"flex",gap:.5,justifyContent:"center",flexWrap:"wrap"},children:r.map(A=>T(Wo,{label:A.split("/")[1]?.toUpperCase()||A,size:"small",variant:"outlined",sx:{fontSize:"0.7rem"}},A))})]}),d&&N.length>0&&T(ti,{dense:!0,sx:{mt:1,p:0},children:N.map(A=>T(Ei,{file:A,baseUrl:g,disabled:s,onRemove:Zo,onRestore:C,onRetry:k},A.id))}),ue&&ce(Ee,{sx:{display:"flex",alignItems:"center",gap:1,mt:1},children:[T(nr,{size:16}),T(Ce,{variant:"caption",color:"text.secondary",children:I("file.uploading")})]}),Ur&&T(si,{error:ar,sx:{mt:.5},dangerouslySetInnerHTML:{__html:vi(Ur)}}),ce(li,{open:R,onClose:oe?void 0:Nr,children:[T(ci,{children:I("file.confirmDelete.title")}),T(di,{children:T(Ce,{children:I("file.confirmDelete.message")})}),ce(ui,{children:[T(Vo,{onClick:Nr,disabled:oe,children:I("file.confirmDelete.cancel")}),T(Vo,{onClick:et,color:"error",variant:"contained",disabled:oe,startIcon:oe?T(nr,{size:16,color:"inherit"}):void 0,children:I(oe?"file.deleting":"file.confirmDelete.confirm")})]})]})]})};import{useCallback as Ri,useRef as Si,useEffect as Ii}from"react";import Ho from"@mui/material/Box";import qo from"@mui/material/Typography";import jo from"@mui/material/FormHelperText";import{MDXEditor as ki,headingsPlugin as Li,listsPlugin as Ai,quotePlugin as Fi,thematicBreakPlugin as Di,markdownShortcutPlugin as _i,linkPlugin as Oi,linkDialogPlugin as Bi,tablePlugin as Ni,toolbarPlugin as zi,UndoRedo as Ui,BoldItalicUnderlineToggles as Mi,BlockTypeSelect as Vi,CreateLink as Wi,InsertTable as Hi,ListsToggle as qi,Separator as ir}from"@mdxeditor/editor";import"@mdxeditor/editor/style.css";import{Fragment as ji,jsx as $,jsxs as Sr}from"react/jsx-runtime";var uc=({label:e,value:r="",onChange:o,required:t=!1,disabled:a=!1,error:i=!1,helperText:n,placeholder:s="Write here...",minHeight:c=200,maxHeight:y=500})=>{let u=Si(null);Ii(()=>{u.current&&u.current.getMarkdown()!==r&&u.current.setMarkdown(r||"")},[r]);let b=Ri(f=>{o?.(f)},[o]);return Sr(Ho,{sx:{width:"100%"},children:[e&&Sr(qo,{component:"label",sx:{display:"block",mb:.5,fontSize:"0.875rem",fontWeight:500,color:i?"error.main":"text.primary"},children:[e,t&&$(qo,{component:"span",color:"error.main",sx:{ml:.5},children:"*"})]}),$(Ho,{sx:{border:1,borderColor:i?"error.main":"divider",borderRadius:1,overflow:"hidden",opacity:a?.6:1,pointerEvents:a?"none":"auto","& .mdxeditor":{minHeight:c,maxHeight:y,overflow:"auto"},"& .mdxeditor-toolbar":{borderBottom:1,borderColor:"divider",backgroundColor:"background.default"},"& .mdxeditor-root-contenteditable":{padding:2,minHeight:c-50}},children:$(ki,{ref:u,markdown:r||"",onChange:b,placeholder:s,readOnly:a,plugins:[Li(),Ai(),Fi(),Di(),_i(),Oi(),Bi(),Ni(),zi({toolbarContents:()=>Sr(ji,{children:[$(Ui,{}),$(ir,{}),$(Mi,{}),$(ir,{}),$(Vi,{}),$(ir,{}),$(qi,{}),$(ir,{}),$(Wi,{}),$(Hi,{})]})})]})}),n&&$(jo,{error:i,sx:{mx:0,mt:.5},children:n}),!n&&$(jo,{sx:{mx:0,mt:.5},children:"\xA0"})]})};export{me as a,Xi as b,Ji as c,sr as d,Ke as e,ca as f,_e as g,xs as h,hn as i,Io as j,ko as k,nl as l,ul as m,ml as n,vl as o,rc as p,uc as q};
|