limbo-component 3.6.3 → 3.7.0
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/limbo.cjs.js +1 -1
- package/dist/limbo.cjs.map +1 -1
- package/dist/limbo.css +1 -1
- package/dist/limbo.es.js +156 -152
- package/dist/limbo.es.map +1 -1
- package/dist/limbo.min.js +1 -1
- package/dist/limbo.min.js.map +1 -1
- package/dist/limbo.umd.js +1 -1
- package/dist/limbo.umd.js.map +1 -1
- package/dist/types/App.d.ts.map +1 -1
- package/dist/types/components/FolderSelector.d.ts.map +1 -1
- package/dist/types/components/Gallery.d.ts +2 -1
- package/dist/types/components/Gallery.d.ts.map +1 -1
- package/dist/types/components/ImageCard.d.ts +6 -1
- package/dist/types/components/ImageCard.d.ts.map +1 -1
- package/dist/types/components/ImagePreview.d.ts.map +1 -1
- package/dist/types/utils/helpers.d.ts +14 -0
- package/dist/types/utils/helpers.d.ts.map +1 -1
- package/package.json +19 -21
package/dist/limbo.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Limbo={})}(this,function(e){"use strict";const t={jpg:["image/jpeg"],jpeg:["image/jpeg"],png:["image/png"],gif:["image/gif"],webp:["image/webp"],svg:["image/svg+xml"],mp4:["video/mp4"],webm:["video/webm"],mov:["video/quicktime"],avi:["video/x-msvideo"],mkv:["video/x-matroska"],pdf:["application/pdf"],doc:["application/msword"],docx:["application/vnd.openxmlformats-officedocument.wordprocessingml.document"],xls:["application/vnd.ms-excel"],xlsx:["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],ppt:["application/vnd.ms-powerpoint"],pptx:["application/vnd.openxmlformats-officedocument.presentationml.presentation"],txt:["text/plain"],csv:["text/csv"],json:["application/json"],xml:["application/xml","text/xml"],html:["text/html"],css:["text/css"],js:["text/javascript","application/javascript"],md:["text/markdown"],mp3:["audio/mpeg"],wav:["audio/wav"],ogg:["audio/ogg"],aac:["audio/aac"],flac:["audio/flac"]},n={image:["image/jpeg","image/png","image/webp","image/svg+xml"],video:["image/gif","video/mp4","video/webm","video/quicktime","video/x-msvideo","video/x-matroska"],document:["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/plain","text/csv"],audio:["audio/mpeg","audio/wav","audio/ogg","audio/webm","audio/aac","audio/flac"]},l=new Set(["jpg","jpeg","png","webp","svg","bmp","tiff","ico"]),r=new Set(["mp4","webm","mov","avi","mkv","gif"]),a=Object.freeze({categories:[],extensions:[],mimeTypes:[],acceptString:"",includesImages:!0,includesVideos:!0,isAllTypes:!0,raw:null});function i(e){if(!e)return a;const i=Array.isArray(e)?e.join(","):String(e),o=i.split(",").map(e=>e.trim()).filter(Boolean);if(0===o.length)return a;const s=[],c=[],u=new Set;for(const l of o)if(l.endsWith("/*")){const e=l.replace("/*","");n[e]&&(s.push(e),n[e].forEach(e=>u.add(e)))}else if(l.startsWith(".")){const e=l.slice(1).toLowerCase();c.push(e),(t[e]||[]).forEach(e=>u.add(e))}else l.includes("/")&&u.add(l);const d=s.includes("image")||c.some(e=>l.has(e)),b=s.includes("video")||c.some(e=>r.has(e));return{categories:s,extensions:c,mimeTypes:[...u],acceptString:[...u].join(","),includesImages:d,includesVideos:b,isAllTypes:!1,raw:i}}function o(e){if(!e||e.isAllTypes)return"Todos los formatos";const t=new Set;for(const n of e.categories)switch(n){case"image":t.add("Imágenes");break;case"video":t.add("Videos");break;case"document":t.add("Documentos");break;case"audio":t.add("Audio")}for(const n of e.extensions)t.add(n.toUpperCase());return[...t].join(", ")||"Todos los formatos"}const s={es:{"button.select":"Seleccionar","button.upload":"Subir archivo","button.cancel":"Cancelar","button.close":"Cerrar","button.save":"Guardar","button.delete":"Eliminar","button.download":"Descargar","button.copy":"Copiar URL","button.crop":"Recortar","button.apply":"Aplicar","button.reset":"Reiniciar","button.back":"Volver","button.next":"Siguiente","button.previous":"Anterior","tab.gallery":"Galería","tab.upload":"Subir","tab.ia":"IA","tab.stock":"Stock","tab.cropper":"Recortar","message.loading":"Cargando...","message.uploading":"Subiendo archivo...","message.processing":"Procesando...","message.no_images":"No hay archivos disponibles","message.upload_success":"Archivo subido correctamente","message.upload_error":"Error al subir el archivo","message.delete_confirm":"¿Estás seguro de que deseas eliminar este archivo? Esta acción también eliminará todos sus recortes.","message.copy_success":"URL copiada al portapapeles","message.copy_error":"Error al copiar URL","error.file_too_large":"El archivo es demasiado grande","error.invalid_format":"Formato de archivo no válido","error.upload_failed":"Error al subir el archivo","error.network":"Error de conexión","error.unknown":"Error desconocido","error.api_key_missing":"API Key no proporcionada","placeholder.search":"Buscar archivos...","placeholder.prompt":"Describe la imagen que quieres generar...","label.file_name":"Nombre del archivo","label.file_size":"Tamaño","label.dimensions":"Dimensiones","label.format":"Formato","label.uploaded_by":"Subido por","label.uploaded_at":"Fecha de subida","preset.square":"Cuadrado","preset.landscape":"Paisaje","preset.portrait":"Retrato","preset.thumbnail":"Miniatura","preset.medium":"Medio","preset.large":"Grande","preset.custom":"Personalizado"},en:{"button.select":"Select","button.upload":"Upload file","button.cancel":"Cancel","button.close":"Close","button.save":"Save","button.delete":"Delete","button.download":"Download","button.copy":"Copy URL","button.crop":"Crop","button.apply":"Apply","button.reset":"Reset","button.back":"Back","button.next":"Next","button.previous":"Previous","tab.gallery":"Gallery","tab.upload":"Upload","tab.ia":"AI","tab.stock":"Stock","tab.cropper":"Crop","message.loading":"Loading...","message.uploading":"Uploading file...","message.processing":"Processing...","message.no_images":"No files available","message.upload_success":"File uploaded successfully","message.upload_error":"Error uploading file","message.delete_confirm":"Are you sure you want to delete this file?","message.copy_success":"URL copied to clipboard","message.copy_error":"Error copying URL","error.file_too_large":"File is too large","error.invalid_format":"Invalid file format","error.upload_failed":"Upload failed","error.network":"Network error","error.unknown":"Unknown error","error.api_key_missing":"API Key not provided","placeholder.search":"Search files...","placeholder.prompt":"Describe the image you want to generate...","label.file_name":"File name","label.file_size":"Size","label.dimensions":"Dimensions","label.format":"Format","label.uploaded_by":"Uploaded by","label.uploaded_at":"Upload date","preset.square":"Square","preset.landscape":"Landscape","preset.portrait":"Portrait","preset.thumbnail":"Thumbnail","preset.medium":"Medium","preset.large":"Large","preset.custom":"Custom"}};class c{constructor(e="es",t={}){this.locale=e,this.messages=this._mergeMessages(t)}_mergeMessages(e){const t={...s};return Object.keys(e).forEach(n=>{t[n]={...t[n]||{},...e[n]}}),t}t(e,t={}){let n=(this.messages[this.locale]||this.messages.es)[e]||e;return Object.keys(t).forEach(e=>{n=n.replace(`{${e}}`,t[e])}),n}setLocale(e){this.messages[e]?this.locale=e:console.warn(`Locale ${e} not available, keeping ${this.locale}`)}getLocale(){return this.locale}getAvailableLocales(){return Object.keys(this.messages)}addMessages(e,t){this.messages[e]={...this.messages[e]||{},...t}}hasKey(e){return e in(this.messages[this.locale]||this.messages.es)}}new c;class u{constructor(){this.globalConfig={},this.defaults={container:"#limbo-default",mode:"embed",modeUI:"full",features:["gallery","upload","cropper"],ui:{showActions:["select","download","copy","delete","crop"],hideActions:[],theme:"light",language:"es",compactMode:!1,showTabs:!0,showPreview:!0},cropper:{quality:.9,format:"webp",aspectRatio:null,lockAspectRatio:!1,showFreeAspectRatio:!0,showDimensionInputs:!1,enableEditMode:!0,showDownloadInCropper:!1,showCropName:!1,mandatoryCrops:[],allowCustomCrops:!0},gallery:{filters:{showNameFilter:!0,showUploadedByFilter:!1,showDateFilter:!0,showTypeFilter:!1,enabledFilters:["name","date"],customFilters:[]},loading:{showPlaceholders:!0,placeholderCount:10,showSpinner:!0},pagination:{itemsPerPage:20,showPageSize:!0}},validation:{accept:null,maxSize:"10MB",formats:["jpg","jpeg","png","webp","gif"],minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,allowedCategories:null},folders:{include:[],exclude:[],includeNoFolder:!0,showFolderSelector:!0,showFolderFilter:!0,showFolderInfo:!0,allowMoveFolder:!0,allowCreateFolder:!0,defaultFolder:null},downloadFormat:"webp",return:{format:"url",autoAssign:!0,includeMetadata:!1},autoInputs:{dataset:"data-limbo-input-file",buttonText:"Seleccionar archivo",buttonStyle:"primary",buttonClass:"limbo-auto-button",scanOnLoad:!0,observeChanges:!0},presets:{aspects:[{name:"square",ratio:"1:1",label:"Cuadrado"},{name:"landscape",ratio:"16:9",label:"Paisaje"},{name:"portrait",ratio:"9:16",label:"Retrato"}],sizes:[{name:"thumbnail",width:300,height:300,fit:"cover",label:"Miniatura"},{name:"medium",width:800,height:600,fit:"cover",label:"Medio"},{name:"large",width:1920,height:1080,fit:"cover",label:"Grande"}],required:[],lockUserCrop:!1,allowArbitrary:!0,defaultAspect:"square",defaultSize:"medium"},modal:{size:"medium",title:"Limbo Image Manager",backdrop:!0,closeOnEscape:!0,closeOnBackdrop:!0,showCloseButton:!0},callbacks:{onUpload:null,onSelect:null,onDelete:null,onCropsSaved:null,onCropperComplete:null,onCropperCancelled:null,onCropperError:null},autoDestroy:!1,autoHideOnComplete:!1,debug:!1,apiEndpoint:null,auth:{apiKey:null,publicKey:null,portal:null,authMode:"jwt",tokenStorage:"memory",autoRefresh:!0,refreshBuffer:30},apiKey:null}}setGlobal(e){return this.globalConfig={...this.globalConfig,...e},this}getGlobal(){return{...this.globalConfig}}merge(e={}){return this._deepMerge(this.defaults,this.globalConfig,e)}_deepMerge(...e){const t={};return e.forEach(e=>{e&&"object"==typeof e&&Object.keys(e).forEach(n=>{e[n]&&"object"==typeof e[n]&&!Array.isArray(e[n])?t[n]=this._deepMerge(t[n]||{},e[n]):t[n]=e[n]})}),t}setDefaults(e){return this.defaults=this._deepMerge(this.defaults,e),this}getDefaults(){return JSON.parse(JSON.stringify(this.defaults))}resetDefaults(){return this.defaults=this._getOriginalDefaults(),this}get(e,t=null){const n=t||this.merge();return this._getValueByPath(n,e)}set(e,t){return this._setValueByPath(this.globalConfig,e,t),this}_getValueByPath(e,t){return t.split(".").reduce((e,t)=>e&&void 0!==e[t]?e[t]:void 0,e)}_setValueByPath(e,t,n){const l=t.split("."),r=l.pop();l.reduce((e,t)=>(e[t]&&"object"==typeof e[t]||(e[t]={}),e[t]),e)[r]=n}_getOriginalDefaults(){return{container:"#limbo-default",mode:"embed",modeUI:"full",features:["gallery","upload","cropper"],ui:{showActions:["select","download","copy","delete","crop"],hideActions:[],theme:"light",language:"es",compactMode:!1,showTabs:!0,showPreview:!0},interaction:{allowSelection:!1,allowCropping:!0,requiresCropping:!1,selectionMode:"direct"},cropper:{quality:.9,format:"webp",aspectRatio:null,lockAspectRatio:!1,showFreeAspectRatio:!0,showDimensionInputs:!1,enableEditMode:!0,showDownloadInCropper:!1,showCropName:!1,mandatoryCrops:[],allowCustomCrops:!0},gallery:{filters:{showNameFilter:!0,showUploadedByFilter:!1,showDateFilter:!0,showTypeFilter:!1,enabledFilters:["name","date"],customFilters:[]},loading:{showPlaceholders:!0,placeholderCount:10,showSpinner:!0},pagination:{itemsPerPage:20,showPageSize:!0}},validation:{accept:null,maxSize:"10MB",formats:["jpg","jpeg","png","webp","gif"],minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,allowedCategories:null},folders:{include:[],exclude:[],includeNoFolder:!0,showFolderSelector:!1,showFolderFilter:!1,showFolderInfo:!0,allowMoveFolder:!0,allowCreateFolder:!0,defaultFolder:null},return:{format:"url",autoAssign:!0,includeMetadata:!1},autoInputs:{dataset:"data-limbo-input-file",buttonText:"Seleccionar archivo",buttonStyle:"primary",buttonClass:"limbo-auto-button",scanOnLoad:!0,observeChanges:!0},modal:{size:"medium",title:"Limbo Image Manager",backdrop:!0,closeOnEscape:!0,closeOnBackdrop:!0,showCloseButton:!0},i18n:{locale:"es",messages:{},autoDetect:!0},theme:{colors:{},spacing:{},typography:{},borderRadius:{},shadows:{},customProperties:{}},callbacks:{onUpload:null,onSelect:null,onDelete:null,onCropsSaved:null,onCropperComplete:null,onCropperCancelled:null,onCropperError:null},autoDestroy:!1,autoHideOnComplete:!1,debug:!1,apiEndpoint:null,auth:{apiKey:null,publicKey:null,portal:null,authMode:"jwt",tokenStorage:"memory",autoRefresh:!0,refreshBuffer:30},apiKey:null}}_validatePresets(e){const t=[];if(e.aspects&&e.aspects.forEach((e,n)=>{e.name&&e.ratio||t.push(`Aspect preset ${n}: name and ratio are required`),e.ratio&&!/^\d+:\d+$/.test(e.ratio)&&t.push(`Aspect preset ${e.name}: ratio must be in format "w:h"`)}),e.sizes&&e.sizes.forEach((e,n)=>{e.name&&e.width||t.push(`Size preset ${n}: name and width are required`),e.width&&e.width<=0&&t.push(`Size preset ${e.name}: width must be positive`),e.height&&e.height<=0&&t.push(`Size preset ${e.name}: height must be positive`)}),e.required&&Array.isArray(e.required)){const n=[...e.aspects?.map(e=>e.name)||[],...e.sizes?.map(e=>e.name)||[]];e.required.forEach(e=>{n.includes(e)||t.push(`Required preset "${e}" not found in available presets`)})}return t}getPreset(e,t,n="aspect"){const l=e.presets||this.defaults.presets;return"aspect"===n?l.aspects?.find(e=>e.name===t):"size"===n?l.sizes?.find(e=>e.name===t):null}isPresetRequired(e,t){const n=e.presets||this.defaults.presets;return n.required?.includes(t)||!1}getAvailableAspects(e){return(e.presets||this.defaults.presets).aspects||[]}getAvailableSizes(e){return(e.presets||this.defaults.presets).sizes||[]}createI18n(e){const t=e.i18n||this.defaults.i18n;let n=t.locale;if(t.autoDetect&&"auto"===n){const e=(navigator.language||navigator.userLanguage).split("-")[0];n=["es","en"].includes(e)?e:"es"}else t.autoDetect&&!n&&(n="es");return new c(n,t.messages)}validate(e){const t=[],n=this._deepMerge(this.globalConfig.auth||{},e.auth||{}),l=e.apiKey||this.globalConfig.apiKey;if("jwt"!==n.authMode&&l||n.apiKey||t.push("auth.apiKey es requerido para autenticación JWT"),"legacy"!==n.authMode||l||t.push("apiKey es requerido para modo legacy"),n.apiKey||l||t.push("Se requiere configuración de autenticación (auth.apiKey o apiKey legacy)"),e.mode&&!["embed","modal","button"].includes(e.mode)&&t.push("mode debe ser: embed, modal o button"),e.features&&!Array.isArray(e.features)&&t.push("features debe ser un array"),e.presets){const n=this._validatePresets(e.presets);t.push(...n)}return{isValid:0===t.length,errors:t}}setJWTAuth(e,t=null,n={}){const l={apiKey:e,publicKey:t,authMode:"jwt",tokenStorage:n.tokenStorage||"memory",autoRefresh:!1!==n.autoRefresh,refreshBuffer:n.refreshBuffer||30,portal:n.portal||null,...n};return this.set("auth",l),this}getAuthConfig(e=null){const t=e||this.merge();return{authMode:t.auth?.authMode||(t.apiKey?"legacy":"jwt"),apiKey:t.auth?.apiKey||t.apiKey,publicKey:t.auth?.publicKey,portal:t.auth?.portal,tokenStorage:t.auth?.tokenStorage||"memory",autoRefresh:!1!==t.auth?.autoRefresh,refreshBuffer:t.auth?.refreshBuffer||30}}isJWTMode(e=null){return"jwt"===this.getAuthConfig(e).authMode}isLegacyMode(e=null){return"legacy"===this.getAuthConfig(e).authMode}migrateToJWT(e=null){const t=e||this.globalConfig.apiKey;if(!t)throw new Error("No hay apiKey para migrar a JWT");return this.setJWTAuth(t),this}getMandatoryCrops(e=null){const t=e||this.merge();return t.cropper?.mandatoryCrops||[]}hasMandatoryCrops(e=null){return this.getMandatoryCrops(e).length>0}isEditModeEnabled(e=null){const t=e||this.merge();return!1!==t.cropper?.enableEditMode}showDimensionInputs(e=null){const t=e||this.merge();return!0===t.cropper?.showDimensionInputs}showDownloadInCropper(e=null){const t=e||this.merge();return!0===t.cropper?.showDownloadInCropper}showCropName(e=null){const t=e||this.merge();return!0===t.cropper?.showCropName}allowCustomCrops(e=null){const t=e||this.merge();return!1!==t.cropper?.allowCustomCrops}getGalleryFilters(e=null){const t=e||this.merge();return t.gallery?.filters||this.defaults.gallery.filters}isGalleryFilterEnabled(e,t=null){const n=this.getGalleryFilters(t);return n.enabledFilters?.includes(e)||!1}getCustomGalleryFilters(e=null){return this.getGalleryFilters(e).customFilters||[]}getGalleryLoadingConfig(e=null){const t=e||this.merge();return t.gallery?.loading||this.defaults.gallery.loading}showGalleryPlaceholders(e=null){return!1!==this.getGalleryLoadingConfig(e).showPlaceholders}getPlaceholderCount(e=null){return this.getGalleryLoadingConfig(e).placeholderCount||10}showGallerySpinner(e=null){return!1!==this.getGalleryLoadingConfig(e).showSpinner}getGalleryPagination(e=null){const t=e||this.merge();return t.gallery?.pagination||this.defaults.gallery.pagination}getItemsPerPage(e=null){return this.getGalleryPagination(e).itemsPerPage||20}getFolderConfig(e=null){return(e||this.merge()).folders||this.defaults.folders}hasFolderFilters(e=null){const t=this.getFolderConfig(e);return t.include?.length>0||t.exclude?.length>0}getFolderApiParams(e=null){const t=this.getFolderConfig(e),n={};return t.include?.length>0?n.folders_include=t.include.join(","):t.exclude?.length>0&&(n.folders_exclude=t.exclude.join(",")),this.hasFolderFilters(e)&&void 0!==t.includeNoFolder&&(n.include_no_folder=t.includeNoFolder?"1":"0"),n}showFolderSelectorInUpload(e=null){const t=e||this.merge();return!0===t.folders?.showFolderSelector}showFolderFilterInGallery(e=null){const t=e||this.merge();return!0===t.folders?.showFolderFilter}canCreateFolder(e=null){const t=e||this.merge();return!1!==t.folders?.allowCreateFolder}getDefaultUploadFolder(e=null){const t=e||this.merge();return t.folders?.defaultFolder||null}getAllowedFolderSlugs(e=null){const t=e||this.merge(),n=t.folders?.include;return n&&n.length>0?n:null}getAllowedCategories(e=null){const t=e||this.merge();return t.validation?.allowedCategories||null}isCategoryAllowed(e,t=null){const n=this.getAllowedCategories(t);return null===n||n.includes(e)}isMultiTypeEnabled(e=null){const t=this.getAllowedCategories(e);return null===t||(t.length>1||1===t.length&&"image"!==t[0])}showTypeFilter(e=null){const t=e||this.merge();return!0===t.gallery?.filters?.showTypeFilter}getTypeFilterOptions(e=null){const t=this.getAllowedCategories(e),n=[{value:"",label:"Todos los tipos"},{value:"image",label:"Imágenes"},{value:"video",label:"Videos"},{value:"document",label:"Documentos"},{value:"audio",label:"Audio"}];return null===t?n:n.filter(e=>""===e.value||t.includes(e.value))}getResolvedAccept(e=null){const t=e||this.merge();return t.validation?.accept?i(t.validation.accept):t.validation?.allowedCategories?i(t.validation.allowedCategories.map(e=>`${e}/*`).join(",")):i(null)}}function d(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var b,m,h={exports:{}},p={};function f(){if(b)return p;b=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),i=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),s=Symbol.for("react.suspense"),c=Symbol.for("react.memo"),u=Symbol.for("react.lazy"),d=Symbol.for("react.activity"),m=Symbol.iterator;var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},f=Object.assign,g={};function y(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||h}function v(){}function x(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||h}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},v.prototype=y.prototype;var w=x.prototype=new v;w.constructor=x,f(w,y.prototype),w.isPureReactComponent=!0;var k=Array.isArray;function C(){}var S={H:null,A:null,T:null,S:null},j=Object.prototype.hasOwnProperty;function N(t,n,l){var r=l.ref;return{$$typeof:e,type:t,key:n,ref:void 0!==r?r:null,props:l}}function E(t){return"object"==typeof t&&null!==t&&t.$$typeof===e}var $=/\/+/g;function _(e,t){return"object"==typeof e&&null!==e&&null!=e.key?(n=""+e.key,l={"=":"=0",":":"=2"},"$"+n.replace(/[=:]/g,function(e){return l[e]})):t.toString(36);var n,l}function T(n,l,r,a,i){var o=typeof n;"undefined"!==o&&"boolean"!==o||(n=null);var s,c,d=!1;if(null===n)d=!0;else switch(o){case"bigint":case"string":case"number":d=!0;break;case"object":switch(n.$$typeof){case e:case t:d=!0;break;case u:return T((d=n._init)(n._payload),l,r,a,i)}}if(d)return i=i(n),d=""===a?"."+_(n,0):a,k(i)?(r="",null!=d&&(r=d.replace($,"$&/")+"/"),T(i,l,r,"",function(e){return e})):null!=i&&(E(i)&&(s=i,c=r+(null==i.key||n&&n.key===i.key?"":(""+i.key).replace($,"$&/")+"/")+d,i=N(s.type,c,s.props)),l.push(i)),1;d=0;var b,h=""===a?".":a+":";if(k(n))for(var p=0;p<n.length;p++)d+=T(a=n[p],l,r,o=h+_(a,p),i);else if("function"==typeof(p=null===(b=n)||"object"!=typeof b?null:"function"==typeof(b=m&&b[m]||b["@@iterator"])?b:null))for(n=p.call(n),p=0;!(a=n.next()).done;)d+=T(a=a.value,l,r,o=h+_(a,p++),i);else if("object"===o){if("function"==typeof n.then)return T(function(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch("string"==typeof e.status?e.then(C,C):(e.status="pending",e.then(function(t){"pending"===e.status&&(e.status="fulfilled",e.value=t)},function(t){"pending"===e.status&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}(n),l,r,a,i);throw l=String(n),Error("Objects are not valid as a React child (found: "+("[object Object]"===l?"object with keys {"+Object.keys(n).join(", ")+"}":l)+"). If you meant to render a collection of children, use an array instead.")}return d}function z(e,t,n){if(null==e)return e;var l=[],r=0;return T(e,l,"","",function(e){return t.call(n,e,r++)}),l}function L(e){if(-1===e._status){var t=e._result;(t=t()).then(function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)},function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)}),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var A="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"==typeof process&&"function"==typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)},M={map:z,forEach:function(e,t,n){z(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return z(e,function(){t++}),t},toArray:function(e){return z(e,function(e){return e})||[]},only:function(e){if(!E(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};return p.Activity=d,p.Children=M,p.Component=y,p.Fragment=n,p.Profiler=r,p.PureComponent=x,p.StrictMode=l,p.Suspense=s,p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=S,p.__COMPILER_RUNTIME={__proto__:null,c:function(e){return S.H.useMemoCache(e)}},p.cache=function(e){return function(){return e.apply(null,arguments)}},p.cacheSignal=function(){return null},p.cloneElement=function(e,t,n){if(null==e)throw Error("The argument must be a React element, but you passed "+e+".");var l=f({},e.props),r=e.key;if(null!=t)for(a in void 0!==t.key&&(r=""+t.key),t)!j.call(t,a)||"key"===a||"__self"===a||"__source"===a||"ref"===a&&void 0===t.ref||(l[a]=t[a]);var a=arguments.length-2;if(1===a)l.children=n;else if(1<a){for(var i=Array(a),o=0;o<a;o++)i[o]=arguments[o+2];l.children=i}return N(e.type,r,l)},p.createContext=function(e){return(e={$$typeof:i,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider=e,e.Consumer={$$typeof:a,_context:e},e},p.createElement=function(e,t,n){var l,r={},a=null;if(null!=t)for(l in void 0!==t.key&&(a=""+t.key),t)j.call(t,l)&&"key"!==l&&"__self"!==l&&"__source"!==l&&(r[l]=t[l]);var i=arguments.length-2;if(1===i)r.children=n;else if(1<i){for(var o=Array(i),s=0;s<i;s++)o[s]=arguments[s+2];r.children=o}if(e&&e.defaultProps)for(l in i=e.defaultProps)void 0===r[l]&&(r[l]=i[l]);return N(e,a,r)},p.createRef=function(){return{current:null}},p.forwardRef=function(e){return{$$typeof:o,render:e}},p.isValidElement=E,p.lazy=function(e){return{$$typeof:u,_payload:{_status:-1,_result:e},_init:L}},p.memo=function(e,t){return{$$typeof:c,type:e,compare:void 0===t?null:t}},p.startTransition=function(e){var t=S.T,n={};S.T=n;try{var l=e(),r=S.S;null!==r&&r(n,l),"object"==typeof l&&null!==l&&"function"==typeof l.then&&l.then(C,A)}catch(a){A(a)}finally{null!==t&&null!==n.types&&(t.types=n.types),S.T=t}},p.unstable_useCacheRefresh=function(){return S.H.useCacheRefresh()},p.use=function(e){return S.H.use(e)},p.useActionState=function(e,t,n){return S.H.useActionState(e,t,n)},p.useCallback=function(e,t){return S.H.useCallback(e,t)},p.useContext=function(e){return S.H.useContext(e)},p.useDebugValue=function(){},p.useDeferredValue=function(e,t){return S.H.useDeferredValue(e,t)},p.useEffect=function(e,t){return S.H.useEffect(e,t)},p.useEffectEvent=function(e){return S.H.useEffectEvent(e)},p.useId=function(){return S.H.useId()},p.useImperativeHandle=function(e,t,n){return S.H.useImperativeHandle(e,t,n)},p.useInsertionEffect=function(e,t){return S.H.useInsertionEffect(e,t)},p.useLayoutEffect=function(e,t){return S.H.useLayoutEffect(e,t)},p.useMemo=function(e,t){return S.H.useMemo(e,t)},p.useOptimistic=function(e,t){return S.H.useOptimistic(e,t)},p.useReducer=function(e,t,n){return S.H.useReducer(e,t,n)},p.useRef=function(e){return S.H.useRef(e)},p.useState=function(e){return S.H.useState(e)},p.useSyncExternalStore=function(e,t,n){return S.H.useSyncExternalStore(e,t,n)},p.useTransition=function(){return S.H.useTransition()},p.version="19.2.4",p}function g(){return m||(m=1,h.exports=f()),h.exports}var y=g();const v=d(y);var x,w,k={exports:{}},C={},S={exports:{}},j={};function N(){return w||(w=1,S.exports=(x||(x=1,function(e){function t(e,t){var n=e.length;e.push(t);e:for(;0<n;){var l=n-1>>>1,a=e[l];if(!(0<r(a,t)))break e;e[l]=t,e[n]=a,n=l}}function n(e){return 0===e.length?null:e[0]}function l(e){if(0===e.length)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var l=0,a=e.length,i=a>>>1;l<i;){var o=2*(l+1)-1,s=e[o],c=o+1,u=e[c];if(0>r(s,n))c<a&&0>r(u,s)?(e[l]=u,e[c]=n,l=c):(e[l]=s,e[o]=n,l=o);else{if(!(c<a&&0>r(u,n)))break e;e[l]=u,e[c]=n,l=c}}}return t}function r(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if(e.unstable_now=void 0,"object"==typeof performance&&"function"==typeof performance.now){var a=performance;e.unstable_now=function(){return a.now()}}else{var i=Date,o=i.now();e.unstable_now=function(){return i.now()-o}}var s=[],c=[],u=1,d=null,b=3,m=!1,h=!1,p=!1,f=!1,g="function"==typeof setTimeout?setTimeout:null,y="function"==typeof clearTimeout?clearTimeout:null,v="undefined"!=typeof setImmediate?setImmediate:null;function x(e){for(var r=n(c);null!==r;){if(null===r.callback)l(c);else{if(!(r.startTime<=e))break;l(c),r.sortIndex=r.expirationTime,t(s,r)}r=n(c)}}function w(e){if(p=!1,x(e),!h)if(null!==n(s))h=!0,C||(C=!0,k());else{var t=n(c);null!==t&&z(w,t.startTime-e)}}var k,C=!1,S=-1,j=5,N=-1;function E(){return!(!f&&e.unstable_now()-N<j)}function $(){if(f=!1,C){var t=e.unstable_now();N=t;var r=!0;try{e:{h=!1,p&&(p=!1,y(S),S=-1),m=!0;var a=b;try{t:{for(x(t),d=n(s);null!==d&&!(d.expirationTime>t&&E());){var i=d.callback;if("function"==typeof i){d.callback=null,b=d.priorityLevel;var o=i(d.expirationTime<=t);if(t=e.unstable_now(),"function"==typeof o){d.callback=o,x(t),r=!0;break t}d===n(s)&&l(s),x(t)}else l(s);d=n(s)}if(null!==d)r=!0;else{var u=n(c);null!==u&&z(w,u.startTime-t),r=!1}}break e}finally{d=null,b=a,m=!1}r=void 0}}finally{r?k():C=!1}}}if("function"==typeof v)k=function(){v($)};else if("undefined"!=typeof MessageChannel){var _=new MessageChannel,T=_.port2;_.port1.onmessage=$,k=function(){T.postMessage(null)}}else k=function(){g($,0)};function z(t,n){S=g(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):j=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_next=function(e){switch(b){case 1:case 2:case 3:var t=3;break;default:t=b}var n=b;b=t;try{return e()}finally{b=n}},e.unstable_requestPaint=function(){f=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=b;b=e;try{return t()}finally{b=n}},e.unstable_scheduleCallback=function(l,r,a){var i=e.unstable_now();switch(a="object"==typeof a&&null!==a&&"number"==typeof(a=a.delay)&&0<a?i+a:i,l){case 1:var o=-1;break;case 2:o=250;break;case 5:o=1073741823;break;case 4:o=1e4;break;default:o=5e3}return l={id:u++,callback:r,priorityLevel:l,startTime:a,expirationTime:o=a+o,sortIndex:-1},a>i?(l.sortIndex=a,t(c,l),null===n(s)&&l===n(c)&&(p?(y(S),S=-1):p=!0,z(w,a-i))):(l.sortIndex=o,t(s,l),h||m||(h=!0,C||(C=!0,k()))),l},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=b;return function(){var n=b;b=t;try{return e.apply(this,arguments)}finally{b=n}}}}(j)),j)),S.exports}var E,$,_,T,z={exports:{}},L={};function A(){if(E)return L;E=1;var e=g();function t(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var l={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},r=Symbol.for("react.portal");var a=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function i(e,t){return"font"===e?"":"string"==typeof t?"use-credentials"===t?t:"":void 0}return L.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=l,L.createPortal=function(e,n){var l=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!n||1!==n.nodeType&&9!==n.nodeType&&11!==n.nodeType)throw Error(t(299));return function(e,t,n){var l=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:r,key:null==l?null:""+l,children:e,containerInfo:t,implementation:n}}(e,n,null,l)},L.flushSync=function(e){var t=a.T,n=l.p;try{if(a.T=null,l.p=2,e)return e()}finally{a.T=t,l.p=n,l.d.f()}},L.preconnect=function(e,t){"string"==typeof e&&(t?t="string"==typeof(t=t.crossOrigin)?"use-credentials"===t?t:"":void 0:t=null,l.d.C(e,t))},L.prefetchDNS=function(e){"string"==typeof e&&l.d.D(e)},L.preinit=function(e,t){if("string"==typeof e&&t&&"string"==typeof t.as){var n=t.as,r=i(n,t.crossOrigin),a="string"==typeof t.integrity?t.integrity:void 0,o="string"==typeof t.fetchPriority?t.fetchPriority:void 0;"style"===n?l.d.S(e,"string"==typeof t.precedence?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):"script"===n&&l.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:"string"==typeof t.nonce?t.nonce:void 0})}},L.preinitModule=function(e,t){if("string"==typeof e)if("object"==typeof t&&null!==t){if(null==t.as||"script"===t.as){var n=i(t.as,t.crossOrigin);l.d.M(e,{crossOrigin:n,integrity:"string"==typeof t.integrity?t.integrity:void 0,nonce:"string"==typeof t.nonce?t.nonce:void 0})}}else null==t&&l.d.M(e)},L.preload=function(e,t){if("string"==typeof e&&"object"==typeof t&&null!==t&&"string"==typeof t.as){var n=t.as,r=i(n,t.crossOrigin);l.d.L(e,n,{crossOrigin:r,integrity:"string"==typeof t.integrity?t.integrity:void 0,nonce:"string"==typeof t.nonce?t.nonce:void 0,type:"string"==typeof t.type?t.type:void 0,fetchPriority:"string"==typeof t.fetchPriority?t.fetchPriority:void 0,referrerPolicy:"string"==typeof t.referrerPolicy?t.referrerPolicy:void 0,imageSrcSet:"string"==typeof t.imageSrcSet?t.imageSrcSet:void 0,imageSizes:"string"==typeof t.imageSizes?t.imageSizes:void 0,media:"string"==typeof t.media?t.media:void 0})}},L.preloadModule=function(e,t){if("string"==typeof e)if(t){var n=i(t.as,t.crossOrigin);l.d.m(e,{as:"string"==typeof t.as&&"script"!==t.as?t.as:void 0,crossOrigin:n,integrity:"string"==typeof t.integrity?t.integrity:void 0})}else l.d.m(e)},L.requestFormReset=function(e){l.d.r(e)},L.unstable_batchedUpdates=function(e,t){return e(t)},L.useFormState=function(e,t,n){return a.H.useFormState(e,t,n)},L.useFormStatus=function(){return a.H.useHostTransitionStatus()},L.version="19.2.4",L}function M(){if(_)return C;_=1;var e=N(),t=g(),n=($||($=1,function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}(),z.exports=A()),z.exports);function l(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType)}function a(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do{!!(4098&(t=e).flags)&&(n=t.return),e=t.return}while(e)}return 3===t.tag?n:null}function i(e){if(13===e.tag){var t=e.memoizedState;if(null===t&&(null!==(e=e.alternate)&&(t=e.memoizedState)),null!==t)return t.dehydrated}return null}function o(e){if(31===e.tag){var t=e.memoizedState;if(null===t&&(null!==(e=e.alternate)&&(t=e.memoizedState)),null!==t)return t.dehydrated}return null}function s(e){if(a(e)!==e)throw Error(l(188))}function c(e){var t=e.tag;if(5===t||26===t||27===t||6===t)return e;for(e=e.child;null!==e;){if(null!==(t=c(e)))return t;e=e.sibling}return null}var u=Object.assign,d=Symbol.for("react.element"),b=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),p=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),y=Symbol.for("react.consumer"),v=Symbol.for("react.context"),x=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),E=Symbol.for("react.activity"),T=Symbol.for("react.memo_cache_sentinel"),L=Symbol.iterator;function M(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=L&&e[L]||e["@@iterator"])?e:null}var P=Symbol.for("react.client.reference");function I(e){if(null==e)return null;if("function"==typeof e)return e.$$typeof===P?null:e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case h:return"Fragment";case f:return"Profiler";case p:return"StrictMode";case w:return"Suspense";case k:return"SuspenseList";case E:return"Activity"}if("object"==typeof e)switch(e.$$typeof){case m:return"Portal";case v:return e.displayName||"Context";case y:return(e._context.displayName||"Context")+".Consumer";case x:var t=e.render;return(e=e.displayName)||(e=""!==(e=t.displayName||t.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case S:return null!==(t=e.displayName||null)?t:I(e.type)||"Memo";case j:t=e._payload,e=e._init;try{return I(e(t))}catch(n){}}return null}var D=Array.isArray,O=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F={pending:!1,data:null,method:null,action:null},U=[],B=-1;function W(e){return{current:e}}function q(e){0>B||(e.current=U[B],U[B]=null,B--)}function V(e,t){B++,U[B]=e.current,e.current=t}var H,K,G=W(null),Q=W(null),X=W(null),Y=W(null);function J(e,t){switch(V(X,t),V(Q,e),V(G,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?wd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)e=kd(t=wd(t),e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}q(G),V(G,e)}function Z(){q(G),q(Q),q(X)}function ee(e){null!==e.memoizedState&&V(Y,e);var t=G.current,n=kd(t,e.type);t!==n&&(V(Q,e),V(G,n))}function te(e){Q.current===e&&(q(G),q(Q)),Y.current===e&&(q(Y),hb._currentValue=F)}function ne(e){if(void 0===H)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);H=t&&t[1]||"",K=-1<n.stack.indexOf("\n at")?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return"\n"+H+e+K}var le=!1;function re(e,t){if(!e||le)return"";le=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(n,[])}catch(r){var l=r}Reflect.construct(e,[],n)}else{try{n.call()}catch(a){l=a}e.call(n.prototype)}}else{try{throw Error()}catch(i){l=i}(n=e())&&"function"==typeof n.catch&&n.catch(function(){})}}catch(o){if(o&&l&&"string"==typeof o.stack)return[o.stack,l.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var r=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");r&&r.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var a=l.DetermineComponentFrameRoot(),i=a[0],o=a[1];if(i&&o){var s=i.split("\n"),c=o.split("\n");for(r=l=0;l<s.length&&!s[l].includes("DetermineComponentFrameRoot");)l++;for(;r<c.length&&!c[r].includes("DetermineComponentFrameRoot");)r++;if(l===s.length||r===c.length)for(l=s.length-1,r=c.length-1;1<=l&&0<=r&&s[l]!==c[r];)r--;for(;1<=l&&0<=r;l--,r--)if(s[l]!==c[r]){if(1!==l||1!==r)do{if(l--,0>--r||s[l]!==c[r]){var u="\n"+s[l].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}}while(1<=l&&0<=r);break}}}finally{le=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?ne(n):""}function ae(e,t){switch(e.tag){case 26:case 27:case 5:return ne(e.type);case 16:return ne("Lazy");case 13:return e.child!==t&&null!==t?ne("Suspense Fallback"):ne("Suspense");case 19:return ne("SuspenseList");case 0:case 15:return re(e.type,!1);case 11:return re(e.type.render,!1);case 1:return re(e.type,!0);case 31:return ne("Activity");default:return""}}function ie(e){try{var t="",n=null;do{t+=ae(e,n),n=e,e=e.return}while(e);return t}catch(l){return"\nError generating stack: "+l.message+"\n"+l.stack}}var oe=Object.prototype.hasOwnProperty,se=e.unstable_scheduleCallback,ce=e.unstable_cancelCallback,ue=e.unstable_shouldYield,de=e.unstable_requestPaint,be=e.unstable_now,me=e.unstable_getCurrentPriorityLevel,he=e.unstable_ImmediatePriority,pe=e.unstable_UserBlockingPriority,fe=e.unstable_NormalPriority,ge=e.unstable_LowPriority,ye=e.unstable_IdlePriority,ve=e.log,xe=e.unstable_setDisableYieldValue,we=null,ke=null;function Ce(e){if("function"==typeof ve&&xe(e),ke&&"function"==typeof ke.setStrictMode)try{ke.setStrictMode(we,e)}catch(t){}}var Se=Math.clz32?Math.clz32:function(e){return 0===(e>>>=0)?32:31-(je(e)/Ne|0)|0},je=Math.log,Ne=Math.LN2;var Ee=256,$e=262144,_e=4194304;function Te(e){var t=42&e;if(0!==t)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return 261888&e;case 262144:case 524288:case 1048576:case 2097152:return 3932160&e;case 4194304:case 8388608:case 16777216:case 33554432:return 62914560&e;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function ze(e,t,n){var l=e.pendingLanes;if(0===l)return 0;var r=0,a=e.suspendedLanes,i=e.pingedLanes;e=e.warmLanes;var o=134217727&l;return 0!==o?0!==(l=o&~a)?r=Te(l):0!==(i&=o)?r=Te(i):n||0!==(n=o&~e)&&(r=Te(n)):0!==(o=l&~a)?r=Te(o):0!==i?r=Te(i):n||0!==(n=l&~e)&&(r=Te(n)),0===r?0:0!==t&&t!==r&&0===(t&a)&&((a=r&-r)>=(n=t&-t)||32===a&&4194048&n)?t:r}function Le(e,t){return 0===(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)}function Ae(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;default:return-1}}function Me(){var e=_e;return!(62914560&(_e<<=1))&&(_e=4194304),e}function Pe(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Ie(e,t){e.pendingLanes|=t,268435456!==t&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function De(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var l=31-Se(t);e.entangledLanes|=t,e.entanglements[l]=1073741824|e.entanglements[l]|261930&n}function Oe(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var l=31-Se(n),r=1<<l;r&t|e[l]&t&&(e[l]|=t),n&=~r}}function Re(e,t){var n=t&-t;return 0!==((n=42&n?1:Fe(n))&(e.suspendedLanes|t))?0:n}function Fe(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Ue(e){return 2<(e&=-e)?8<e?134217727&e?32:268435456:8:2}function Be(){var e=R.p;return 0!==e?e:void 0===(e=window.event)?32:Tb(e.type)}function We(e,t){var n=R.p;try{return R.p=e,t()}finally{R.p=n}}var qe=Math.random().toString(36).slice(2),Ve="__reactFiber$"+qe,He="__reactProps$"+qe,Ke="__reactContainer$"+qe,Ge="__reactEvents$"+qe,Qe="__reactListeners$"+qe,Xe="__reactHandles$"+qe,Ye="__reactResources$"+qe,Je="__reactMarker$"+qe;function Ze(e){delete e[Ve],delete e[He],delete e[Ge],delete e[Qe],delete e[Xe]}function et(e){var t=e[Ve];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Ke]||n[Ve]){if(n=t.alternate,null!==t.child||null!==n&&null!==n.child)for(e=Fd(e);null!==e;){if(n=e[Ve])return n;e=Fd(e)}return t}n=(e=n).parentNode}return null}function tt(e){if(e=e[Ve]||e[Ke]){var t=e.tag;if(5===t||6===t||13===t||31===t||26===t||27===t||3===t)return e}return null}function nt(e){var t=e.tag;if(5===t||26===t||27===t||6===t)return e.stateNode;throw Error(l(33))}function lt(e){var t=e[Ye];return t||(t=e[Ye]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function rt(e){e[Je]=!0}var at=new Set,it={};function ot(e,t){st(e,t),st(e+"Capture",t)}function st(e,t){for(it[e]=t,e=0;e<t.length;e++)at.add(t[e])}var ct=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),ut={},dt={};function bt(e,t,n){if(r=t,oe.call(dt,r)||!oe.call(ut,r)&&(ct.test(r)?dt[r]=!0:(ut[r]=!0,0)))if(null===n)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":return void e.removeAttribute(t);case"boolean":var l=t.toLowerCase().slice(0,5);if("data-"!==l&&"aria-"!==l)return void e.removeAttribute(t)}e.setAttribute(t,""+n)}var r}function mt(e,t,n){if(null===n)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(t)}e.setAttribute(t,""+n)}}function ht(e,t,n,l){if(null===l)e.removeAttribute(n);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(n)}e.setAttributeNS(t,n,""+l)}}function pt(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":case"object":return e;default:return""}}function ft(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function gt(e){if(!e._valueTracker){var t=ft(e)?"checked":"value";e._valueTracker=function(e,t,n){var l=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&void 0!==l&&"function"==typeof l.get&&"function"==typeof l.set){var r=l.get,a=l.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return r.call(this)},set:function(e){n=""+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:l.enumerable}),{getValue:function(){return n},setValue:function(e){n=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e,t,""+e[t])}}function yt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),l="";return e&&(l=ft(e)?e.checked?"true":"false":e.value),(e=l)!==n&&(t.setValue(e),!0)}function vt(e){if(void 0===(e=e||("undefined"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}var xt=/[\n"\\]/g;function wt(e){return e.replace(xt,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})}function kt(e,t,n,l,r,a,i,o){e.name="",null!=i&&"function"!=typeof i&&"symbol"!=typeof i&&"boolean"!=typeof i?e.type=i:e.removeAttribute("type"),null!=t?"number"===i?(0===t&&""===e.value||e.value!=t)&&(e.value=""+pt(t)):e.value!==""+pt(t)&&(e.value=""+pt(t)):"submit"!==i&&"reset"!==i||e.removeAttribute("value"),null!=t?St(e,i,pt(t)):null!=n?St(e,i,pt(n)):null!=l&&e.removeAttribute("value"),null==r&&null!=a&&(e.defaultChecked=!!a),null!=r&&(e.checked=r&&"function"!=typeof r&&"symbol"!=typeof r),null!=o&&"function"!=typeof o&&"symbol"!=typeof o&&"boolean"!=typeof o?e.name=""+pt(o):e.removeAttribute("name")}function Ct(e,t,n,l,r,a,i,o){if(null!=a&&"function"!=typeof a&&"symbol"!=typeof a&&"boolean"!=typeof a&&(e.type=a),null!=t||null!=n){if(("submit"===a||"reset"===a)&&null==t)return void gt(e);n=null!=n?""+pt(n):"",t=null!=t?""+pt(t):n,o||t===e.value||(e.value=t),e.defaultValue=t}l="function"!=typeof(l=null!=l?l:r)&&"symbol"!=typeof l&&!!l,e.checked=o?e.checked:!!l,e.defaultChecked=!!l,null!=i&&"function"!=typeof i&&"symbol"!=typeof i&&"boolean"!=typeof i&&(e.name=i),gt(e)}function St(e,t,n){"number"===t&&vt(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function jt(e,t,n,l){if(e=e.options,t){t={};for(var r=0;r<n.length;r++)t["$"+n[r]]=!0;for(n=0;n<e.length;n++)r=t.hasOwnProperty("$"+e[n].value),e[n].selected!==r&&(e[n].selected=r),r&&l&&(e[n].defaultSelected=!0)}else{for(n=""+pt(n),t=null,r=0;r<e.length;r++){if(e[r].value===n)return e[r].selected=!0,void(l&&(e[r].defaultSelected=!0));null!==t||e[r].disabled||(t=e[r])}null!==t&&(t.selected=!0)}}function Nt(e,t,n){null==t||((t=""+pt(t))!==e.value&&(e.value=t),null!=n)?e.defaultValue=null!=n?""+pt(n):"":e.defaultValue!==t&&(e.defaultValue=t)}function Et(e,t,n,r){if(null==t){if(null!=r){if(null!=n)throw Error(l(92));if(D(r)){if(1<r.length)throw Error(l(93));r=r[0]}n=r}null==n&&(n=""),t=n}n=pt(t),e.defaultValue=n,(r=e.textContent)===n&&""!==r&&null!==r&&(e.value=r),gt(e)}function $t(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t}var _t=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Tt(e,t,n){var l=0===t.indexOf("--");null==n||"boolean"==typeof n||""===n?l?e.setProperty(t,""):"float"===t?e.cssFloat="":e[t]="":l?e.setProperty(t,n):"number"!=typeof n||0===n||_t.has(t)?"float"===t?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function zt(e,t,n){if(null!=t&&"object"!=typeof t)throw Error(l(62));if(e=e.style,null!=n){for(var r in n)!n.hasOwnProperty(r)||null!=t&&t.hasOwnProperty(r)||(0===r.indexOf("--")?e.setProperty(r,""):"float"===r?e.cssFloat="":e[r]="");for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&Tt(e,a,r)}else for(var i in t)t.hasOwnProperty(i)&&Tt(e,i,t[i])}function Lt(e){if(-1===e.indexOf("-"))return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var At=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Mt=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Pt(e){return Mt.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function It(){}var Dt=null;function Ot(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var Rt=null,Ft=null;function Ut(e){var t=tt(e);if(t&&(e=t.stateNode)){var n=e[He]||null;e:switch(e=t.stateNode,t.type){case"input":if(kt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,"radio"===n.type&&null!=t){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll('input[name="'+wt(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[He]||null;if(!a)throw Error(l(90));kt(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)(r=n[t]).form===e.form&&yt(r)}break e;case"textarea":Nt(e,n.value,n.defaultValue);break e;case"select":null!=(t=n.value)&&jt(e,!!n.multiple,t,!1)}}}var Bt=!1;function Wt(e,t,n){if(Bt)return e(t,n);Bt=!0;try{return e(t)}finally{if(Bt=!1,(null!==Rt||null!==Ft)&&(lu(),Rt&&(t=Rt,e=Ft,Ft=Rt=null,Ut(t),e)))for(t=0;t<e.length;t++)Ut(e[t])}}function qt(e,t){var n=e.stateNode;if(null===n)return null;var r=n[He]||null;if(null===r)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(r=!("button"===(e=e.type)||"input"===e||"select"===e||"textarea"===e)),e=!r;break e;default:e=!1}if(e)return null;if(n&&"function"!=typeof n)throw Error(l(231,t,typeof n));return n}var Vt=!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement),Ht=!1;if(Vt)try{var Kt={};Object.defineProperty(Kt,"passive",{get:function(){Ht=!0}}),window.addEventListener("test",Kt,Kt),window.removeEventListener("test",Kt,Kt)}catch(tm){Ht=!1}var Gt=null,Qt=null,Xt=null;function Yt(){if(Xt)return Xt;var e,t,n=Qt,l=n.length,r="value"in Gt?Gt.value:Gt.textContent,a=r.length;for(e=0;e<l&&n[e]===r[e];e++);var i=l-e;for(t=1;t<=i&&n[l-t]===r[a-t];t++);return Xt=r.slice(e,1<t?1-t:void 0)}function Jt(e){var t=e.keyCode;return"charCode"in e?0===(e=e.charCode)&&13===t&&(e=13):e=t,10===e&&(e=13),32<=e||13===e?e:0}function Zt(){return!0}function en(){return!1}function tn(e){function t(t,n,l,r,a){for(var i in this._reactName=t,this._targetInst=l,this.type=n,this.nativeEvent=r,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(i)&&(t=e[i],this[i]=t?t(r):r[i]);return this.isDefaultPrevented=(null!=r.defaultPrevented?r.defaultPrevented:!1===r.returnValue)?Zt:en,this.isPropagationStopped=en,this}return u(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=Zt)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=Zt)},persist:function(){},isPersistent:Zt}),t}var nn,ln,rn,an={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},on=tn(an),sn=u({},an,{view:0,detail:0}),cn=tn(sn),un=u({},sn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:wn,button:0,buttons:0,relatedTarget:function(e){return void 0===e.relatedTarget?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==rn&&(rn&&"mousemove"===e.type?(nn=e.screenX-rn.screenX,ln=e.screenY-rn.screenY):ln=nn=0,rn=e),nn)},movementY:function(e){return"movementY"in e?e.movementY:ln}}),dn=tn(un),bn=tn(u({},un,{dataTransfer:0})),mn=tn(u({},sn,{relatedTarget:0})),hn=tn(u({},an,{animationName:0,elapsedTime:0,pseudoElement:0})),pn=tn(u({},an,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}})),fn=tn(u({},an,{data:0})),gn={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},yn={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},vn={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function xn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=vn[e])&&!!t[e]}function wn(){return xn}var kn=tn(u({},sn,{key:function(e){if(e.key){var t=gn[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?13===(e=Jt(e))?"Enter":String.fromCharCode(e):"keydown"===e.type||"keyup"===e.type?yn[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:wn,charCode:function(e){return"keypress"===e.type?Jt(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?Jt(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}})),Cn=tn(u({},un,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Sn=tn(u({},sn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:wn})),jn=tn(u({},an,{propertyName:0,elapsedTime:0,pseudoElement:0})),Nn=tn(u({},un,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),En=tn(u({},an,{newState:0,oldState:0})),$n=[9,13,27,32],_n=Vt&&"CompositionEvent"in window,Tn=null;Vt&&"documentMode"in document&&(Tn=document.documentMode);var zn=Vt&&"TextEvent"in window&&!Tn,Ln=Vt&&(!_n||Tn&&8<Tn&&11>=Tn),An=String.fromCharCode(32),Mn=!1;function Pn(e,t){switch(e){case"keyup":return-1!==$n.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function In(e){return"object"==typeof(e=e.detail)&&"data"in e?e.data:null}var Dn=!1;var On={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Rn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!On[e.type]:"textarea"===t}function Fn(e,t,n,l){Rt?Ft?Ft.push(l):Ft=[l]:Rt=l,0<(t=od(t,"onChange")).length&&(n=new on("onChange","change",null,n,l),e.push({event:n,listeners:t}))}var Un=null,Bn=null;function Wn(e){Zu(e,0)}function qn(e){if(yt(nt(e)))return e}function Vn(e,t){if("change"===e)return t}var Hn=!1;if(Vt){var Kn;if(Vt){var Gn="oninput"in document;if(!Gn){var Qn=document.createElement("div");Qn.setAttribute("oninput","return;"),Gn="function"==typeof Qn.oninput}Kn=Gn}else Kn=!1;Hn=Kn&&(!document.documentMode||9<document.documentMode)}function Xn(){Un&&(Un.detachEvent("onpropertychange",Yn),Bn=Un=null)}function Yn(e){if("value"===e.propertyName&&qn(Bn)){var t=[];Fn(t,Bn,e,Ot(e)),Wt(Wn,t)}}function Jn(e,t,n){"focusin"===e?(Xn(),Bn=n,(Un=t).attachEvent("onpropertychange",Yn)):"focusout"===e&&Xn()}function Zn(e){if("selectionchange"===e||"keyup"===e||"keydown"===e)return qn(Bn)}function el(e,t){if("click"===e)return qn(t)}function tl(e,t){if("input"===e||"change"===e)return qn(t)}var nl="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t};function ll(e,t){if(nl(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),l=Object.keys(t);if(n.length!==l.length)return!1;for(l=0;l<n.length;l++){var r=n[l];if(!oe.call(t,r)||!nl(e[r],t[r]))return!1}return!0}function rl(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function al(e,t){var n,l=rl(e);for(e=0;l;){if(3===l.nodeType){if(n=e+l.textContent.length,e<=t&&n>=t)return{node:l,offset:t-e};e=n}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=rl(l)}}function il(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?il(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function ol(e){for(var t=vt((e=null!=e&&null!=e.ownerDocument&&null!=e.ownerDocument.defaultView?e.ownerDocument.defaultView:window).document);t instanceof e.HTMLIFrameElement;){try{var n="string"==typeof t.contentWindow.location.href}catch(l){n=!1}if(!n)break;t=vt((e=t.contentWindow).document)}return t}function sl(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}var cl=Vt&&"documentMode"in document&&11>=document.documentMode,ul=null,dl=null,bl=null,ml=!1;function hl(e,t,n){var l=n.window===n?n.document:9===n.nodeType?n:n.ownerDocument;ml||null==ul||ul!==vt(l)||("selectionStart"in(l=ul)&&sl(l)?l={start:l.selectionStart,end:l.selectionEnd}:l={anchorNode:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset},bl&&ll(bl,l)||(bl=l,0<(l=od(dl,"onSelect")).length&&(t=new on("onSelect","select",null,t,n),e.push({event:t,listeners:l}),t.target=ul)))}function pl(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var fl={animationend:pl("Animation","AnimationEnd"),animationiteration:pl("Animation","AnimationIteration"),animationstart:pl("Animation","AnimationStart"),transitionrun:pl("Transition","TransitionRun"),transitionstart:pl("Transition","TransitionStart"),transitioncancel:pl("Transition","TransitionCancel"),transitionend:pl("Transition","TransitionEnd")},gl={},yl={};function vl(e){if(gl[e])return gl[e];if(!fl[e])return e;var t,n=fl[e];for(t in n)if(n.hasOwnProperty(t)&&t in yl)return gl[e]=n[t];return e}Vt&&(yl=document.createElement("div").style,"AnimationEvent"in window||(delete fl.animationend.animation,delete fl.animationiteration.animation,delete fl.animationstart.animation),"TransitionEvent"in window||delete fl.transitionend.transition);var xl=vl("animationend"),wl=vl("animationiteration"),kl=vl("animationstart"),Cl=vl("transitionrun"),Sl=vl("transitionstart"),jl=vl("transitioncancel"),Nl=vl("transitionend"),El=new Map,$l="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function _l(e,t){El.set(e,t),ot(t,[e])}$l.push("scrollEnd");var Tl="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"==typeof process&&"function"==typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)},zl=[],Ll=0,Al=0;function Ml(){for(var e=Ll,t=Al=Ll=0;t<e;){var n=zl[t];zl[t++]=null;var l=zl[t];zl[t++]=null;var r=zl[t];zl[t++]=null;var a=zl[t];if(zl[t++]=null,null!==l&&null!==r){var i=l.pending;null===i?r.next=r:(r.next=i.next,i.next=r),l.pending=r}0!==a&&Ol(n,r,a)}}function Pl(e,t,n,l){zl[Ll++]=e,zl[Ll++]=t,zl[Ll++]=n,zl[Ll++]=l,Al|=l,e.lanes|=l,null!==(e=e.alternate)&&(e.lanes|=l)}function Il(e,t,n,l){return Pl(e,t,n,l),Rl(e)}function Dl(e,t){return Pl(e,null,null,t),Rl(e)}function Ol(e,t,n){e.lanes|=n;var l=e.alternate;null!==l&&(l.lanes|=n);for(var r=!1,a=e.return;null!==a;)a.childLanes|=n,null!==(l=a.alternate)&&(l.childLanes|=n),22===a.tag&&(null===(e=a.stateNode)||1&e._visibility||(r=!0)),e=a,a=a.return;return 3===e.tag?(a=e.stateNode,r&&null!==t&&(r=31-Se(n),null===(l=(e=a.hiddenUpdates)[r])?e[r]=[t]:l.push(t),t.lane=536870912|n),a):null}function Rl(e){if(50<Gc)throw Gc=0,Qc=null,Error(l(185));for(var t=e.return;null!==t;)t=(e=t).return;return 3===e.tag?e.stateNode:null}var Fl={};function Ul(e,t,n,l){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Bl(e,t,n,l){return new Ul(e,t,n,l)}function Wl(e){return!(!(e=e.prototype)||!e.isReactComponent)}function ql(e,t){var n=e.alternate;return null===n?((n=Bl(e.tag,t,e.key,e.mode)).elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=65011712&e.flags,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Vl(e,t){e.flags&=65011714;var n=e.alternate;return null===n?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Hl(e,t,n,r,a,i){var o=0;if(r=e,"function"==typeof e)Wl(e)&&(o=1);else if("string"==typeof e)o=function(e,t,n){if(1===n||null!=t.itemProp)return!1;switch(e){case"meta":case"title":return!0;case"style":if("string"!=typeof t.precedence||"string"!=typeof t.href||""===t.href)break;return!0;case"link":if("string"!=typeof t.rel||"string"!=typeof t.href||""===t.href||t.onLoad||t.onError)break;return"stylesheet"!==t.rel||(e=t.disabled,"string"==typeof t.precedence&&null==e);case"script":if(t.async&&"function"!=typeof t.async&&"symbol"!=typeof t.async&&!t.onLoad&&!t.onError&&t.src&&"string"==typeof t.src)return!0}return!1}(e,n,G.current)?26:"html"===e||"head"===e||"body"===e?27:5;else e:switch(e){case E:return(e=Bl(31,n,t,a)).elementType=E,e.lanes=i,e;case h:return Kl(n.children,a,i,t);case p:o=8,a|=24;break;case f:return(e=Bl(12,n,t,2|a)).elementType=f,e.lanes=i,e;case w:return(e=Bl(13,n,t,a)).elementType=w,e.lanes=i,e;case k:return(e=Bl(19,n,t,a)).elementType=k,e.lanes=i,e;default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case v:o=10;break e;case y:o=9;break e;case x:o=11;break e;case S:o=14;break e;case j:o=16,r=null;break e}o=29,n=Error(l(130,null===e?"null":typeof e,"")),r=null}return(t=Bl(o,n,t,a)).elementType=e,t.type=r,t.lanes=i,t}function Kl(e,t,n,l){return(e=Bl(7,e,l,t)).lanes=n,e}function Gl(e,t,n){return(e=Bl(6,e,null,t)).lanes=n,e}function Ql(e){var t=Bl(18,null,null,0);return t.stateNode=e,t}function Xl(e,t,n){return(t=Bl(4,null!==e.children?e.children:[],e.key,t)).lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Yl=new WeakMap;function Jl(e,t){if("object"==typeof e&&null!==e){var n=Yl.get(e);return void 0!==n?n:(t={value:e,source:t,stack:ie(t)},Yl.set(e,t),t)}return{value:e,source:t,stack:ie(t)}}var Zl=[],er=0,tr=null,nr=0,lr=[],rr=0,ar=null,ir=1,or="";function sr(e,t){Zl[er++]=nr,Zl[er++]=tr,tr=e,nr=t}function cr(e,t,n){lr[rr++]=ir,lr[rr++]=or,lr[rr++]=ar,ar=e;var l=ir;e=or;var r=32-Se(l)-1;l&=~(1<<r),n+=1;var a=32-Se(t)+r;if(30<a){var i=r-r%5;a=(l&(1<<i)-1).toString(32),l>>=i,r-=i,ir=1<<32-Se(t)+r|n<<r|l,or=a+e}else ir=1<<a|n<<r|l,or=e}function ur(e){null!==e.return&&(sr(e,1),cr(e,1,0))}function dr(e){for(;e===tr;)tr=Zl[--er],Zl[er]=null,nr=Zl[--er],Zl[er]=null;for(;e===ar;)ar=lr[--rr],lr[rr]=null,or=lr[--rr],lr[rr]=null,ir=lr[--rr],lr[rr]=null}function br(e,t){lr[rr++]=ir,lr[rr++]=or,lr[rr++]=ar,ir=t.id,or=t.overflow,ar=e}var mr=null,hr=null,pr=!1,fr=null,gr=!1,yr=Error(l(519));function vr(e){throw jr(Jl(Error(l(418,1<arguments.length&&void 0!==arguments[1]&&arguments[1]?"text":"HTML","")),e)),yr}function xr(e){var t=e.stateNode,n=e.type,l=e.memoizedProps;switch(t[Ve]=e,t[He]=l,n){case"dialog":ed("cancel",t),ed("close",t);break;case"iframe":case"object":case"embed":ed("load",t);break;case"video":case"audio":for(n=0;n<Yu.length;n++)ed(Yu[n],t);break;case"source":ed("error",t);break;case"img":case"image":case"link":ed("error",t),ed("load",t);break;case"details":ed("toggle",t);break;case"input":ed("invalid",t),Ct(t,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":ed("invalid",t);break;case"textarea":ed("invalid",t),Et(t,l.value,l.defaultValue,l.children)}"string"!=typeof(n=l.children)&&"number"!=typeof n&&"bigint"!=typeof n||t.textContent===""+n||!0===l.suppressHydrationWarning||md(t.textContent,n)?(null!=l.popover&&(ed("beforetoggle",t),ed("toggle",t)),null!=l.onScroll&&ed("scroll",t),null!=l.onScrollEnd&&ed("scrollend",t),null!=l.onClick&&(t.onclick=It),t=!0):t=!1,t||vr(e,!0)}function wr(e){for(mr=e.return;mr;)switch(mr.tag){case 5:case 31:case 13:return void(gr=!1);case 27:case 3:return void(gr=!0);default:mr=mr.return}}function kr(e){if(e!==mr)return!1;if(!pr)return wr(e),pr=!0,!1;var t,n=e.tag;if((t=3!==n&&27!==n)&&((t=5===n)&&(t=!("form"!==(t=e.type)&&"button"!==t)||Cd(e.type,e.memoizedProps)),t=!t),t&&hr&&vr(e),wr(e),13===n){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(l(317));hr=Rd(e)}else if(31===n){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(l(317));hr=Rd(e)}else 27===n?(n=hr,Td(e.type)?(e=Od,Od=null,hr=e):hr=n):hr=mr?Dd(e.stateNode.nextSibling):null;return!0}function Cr(){hr=mr=null,pr=!1}function Sr(){var e=fr;return null!==e&&(null===Mc?Mc=e:Mc.push.apply(Mc,e),fr=null),e}function jr(e){null===fr?fr=[e]:fr.push(e)}var Nr=W(null),Er=null,$r=null;function _r(e,t,n){V(Nr,t._currentValue),t._currentValue=n}function Tr(e){e._currentValue=Nr.current,q(Nr)}function zr(e,t,n){for(;null!==e;){var l=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,null!==l&&(l.childLanes|=t)):null!==l&&(l.childLanes&t)!==t&&(l.childLanes|=t),e===n)break;e=e.return}}function Lr(e,t,n,r){var a=e.child;for(null!==a&&(a.return=e);null!==a;){var i=a.dependencies;if(null!==i){var o=a.child;i=i.firstContext;e:for(;null!==i;){var s=i;i=a;for(var c=0;c<t.length;c++)if(s.context===t[c]){i.lanes|=n,null!==(s=i.alternate)&&(s.lanes|=n),zr(i.return,n,e),r||(o=null);break e}i=s.next}}else if(18===a.tag){if(null===(o=a.return))throw Error(l(341));o.lanes|=n,null!==(i=o.alternate)&&(i.lanes|=n),zr(o,n,e),o=null}else o=a.child;if(null!==o)o.return=a;else for(o=a;null!==o;){if(o===e){o=null;break}if(null!==(a=o.sibling)){a.return=o.return,o=a;break}o=o.return}a=o}}function Ar(e,t,n,r){e=null;for(var a=t,i=!1;null!==a;){if(!i)if(524288&a.flags)i=!0;else if(262144&a.flags)break;if(10===a.tag){var o=a.alternate;if(null===o)throw Error(l(387));if(null!==(o=o.memoizedProps)){var s=a.type;nl(a.pendingProps.value,o.value)||(null!==e?e.push(s):e=[s])}}else if(a===Y.current){if(null===(o=a.alternate))throw Error(l(387));o.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(null!==e?e.push(hb):e=[hb])}a=a.return}null!==e&&Lr(t,e,n,r),t.flags|=262144}function Mr(e){for(e=e.firstContext;null!==e;){if(!nl(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Pr(e){Er=e,$r=null,null!==(e=e.dependencies)&&(e.firstContext=null)}function Ir(e){return Or(Er,e)}function Dr(e,t){return null===Er&&Pr(e),Or(e,t)}function Or(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},null===$r){if(null===e)throw Error(l(308));$r=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else $r=$r.next=t;return n}var Rr="undefined"!=typeof AbortController?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Fr=e.unstable_scheduleCallback,Ur=e.unstable_NormalPriority,Br={$$typeof:v,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Wr(){return{controller:new Rr,data:new Map,refCount:0}}function qr(e){e.refCount--,0===e.refCount&&Fr(Ur,function(){e.controller.abort()})}var Vr=null,Hr=0,Kr=0,Gr=null;function Qr(){if(0===--Hr&&null!==Vr){null!==Gr&&(Gr.status="fulfilled");var e=Vr;Vr=null,Kr=0,Gr=null;for(var t=0;t<e.length;t++)(0,e[t])()}}var Xr=O.S;O.S=function(e,t){Dc=be(),"object"==typeof t&&null!==t&&"function"==typeof t.then&&function(e,t){if(null===Vr){var n=Vr=[];Hr=0,Kr=Hu(),Gr={status:"pending",value:void 0,then:function(e){n.push(e)}}}Hr++,t.then(Qr,Qr)}(0,t),null!==Xr&&Xr(e,t)};var Yr=W(null);function Jr(){var e=Yr.current;return null!==e?e:yc.pooledCache}function Zr(e,t){V(Yr,null===t?Yr.current:t.pool)}function ea(){var e=Jr();return null===e?null:{parent:Br._currentValue,pool:e}}var ta=Error(l(460)),na=Error(l(474)),la=Error(l(542)),ra={then:function(){}};function aa(e){return"fulfilled"===(e=e.status)||"rejected"===e}function ia(e,t,n){switch(void 0===(n=e[n])?e.push(t):n!==t&&(t.then(It,It),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw ua(e=t.reason),e;default:if("string"==typeof t.status)t.then(It,It);else{if(null!==(e=yc)&&100<e.shellSuspendCounter)throw Error(l(482));(e=t).status="pending",e.then(function(e){if("pending"===t.status){var n=t;n.status="fulfilled",n.value=e}},function(e){if("pending"===t.status){var n=t;n.status="rejected",n.reason=e}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw ua(e=t.reason),e}throw sa=t,ta}}function oa(e){try{return(0,e._init)(e._payload)}catch(t){if(null!==t&&"object"==typeof t&&"function"==typeof t.then)throw sa=t,ta;throw t}}var sa=null;function ca(){if(null===sa)throw Error(l(459));var e=sa;return sa=null,e}function ua(e){if(e===ta||e===la)throw Error(l(483))}var da=null,ba=0;function ma(e){var t=ba;return ba+=1,null===da&&(da=[]),ia(da,e,t)}function ha(e,t){t=t.props.ref,e.ref=void 0!==t?t:null}function pa(e,t){if(t.$$typeof===d)throw Error(l(525));throw e=Object.prototype.toString.call(t),Error(l(31,"[object Object]"===e?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function fa(e){function t(t,n){if(e){var l=t.deletions;null===l?(t.deletions=[n],t.flags|=16):l.push(n)}}function n(n,l){if(!e)return null;for(;null!==l;)t(n,l),l=l.sibling;return null}function r(e){for(var t=new Map;null!==e;)null!==e.key?t.set(e.key,e):t.set(e.index,e),e=e.sibling;return t}function a(e,t){return(e=ql(e,t)).index=0,e.sibling=null,e}function i(t,n,l){return t.index=l,e?null!==(l=t.alternate)?(l=l.index)<n?(t.flags|=67108866,n):l:(t.flags|=67108866,n):(t.flags|=1048576,n)}function o(t){return e&&null===t.alternate&&(t.flags|=67108866),t}function s(e,t,n,l){return null===t||6!==t.tag?((t=Gl(n,e.mode,l)).return=e,t):((t=a(t,n)).return=e,t)}function c(e,t,n,l){var r=n.type;return r===h?d(e,t,n.props.children,l,n.key):null!==t&&(t.elementType===r||"object"==typeof r&&null!==r&&r.$$typeof===j&&oa(r)===t.type)?(ha(t=a(t,n.props),n),t.return=e,t):(ha(t=Hl(n.type,n.key,n.props,null,e.mode,l),n),t.return=e,t)}function u(e,t,n,l){return null===t||4!==t.tag||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?((t=Xl(n,e.mode,l)).return=e,t):((t=a(t,n.children||[])).return=e,t)}function d(e,t,n,l,r){return null===t||7!==t.tag?((t=Kl(n,e.mode,l,r)).return=e,t):((t=a(t,n)).return=e,t)}function p(e,t,n){if("string"==typeof t&&""!==t||"number"==typeof t||"bigint"==typeof t)return(t=Gl(""+t,e.mode,n)).return=e,t;if("object"==typeof t&&null!==t){switch(t.$$typeof){case b:return ha(n=Hl(t.type,t.key,t.props,null,e.mode,n),t),n.return=e,n;case m:return(t=Xl(t,e.mode,n)).return=e,t;case j:return p(e,t=oa(t),n)}if(D(t)||M(t))return(t=Kl(t,e.mode,n,null)).return=e,t;if("function"==typeof t.then)return p(e,ma(t),n);if(t.$$typeof===v)return p(e,Dr(e,t),n);pa(e,t)}return null}function f(e,t,n,l){var r=null!==t?t.key:null;if("string"==typeof n&&""!==n||"number"==typeof n||"bigint"==typeof n)return null!==r?null:s(e,t,""+n,l);if("object"==typeof n&&null!==n){switch(n.$$typeof){case b:return n.key===r?c(e,t,n,l):null;case m:return n.key===r?u(e,t,n,l):null;case j:return f(e,t,n=oa(n),l)}if(D(n)||M(n))return null!==r?null:d(e,t,n,l,null);if("function"==typeof n.then)return f(e,t,ma(n),l);if(n.$$typeof===v)return f(e,t,Dr(e,n),l);pa(e,n)}return null}function g(e,t,n,l,r){if("string"==typeof l&&""!==l||"number"==typeof l||"bigint"==typeof l)return s(t,e=e.get(n)||null,""+l,r);if("object"==typeof l&&null!==l){switch(l.$$typeof){case b:return c(t,e=e.get(null===l.key?n:l.key)||null,l,r);case m:return u(t,e=e.get(null===l.key?n:l.key)||null,l,r);case j:return g(e,t,n,l=oa(l),r)}if(D(l)||M(l))return d(t,e=e.get(n)||null,l,r,null);if("function"==typeof l.then)return g(e,t,n,ma(l),r);if(l.$$typeof===v)return g(e,t,n,Dr(t,l),r);pa(t,l)}return null}function y(s,c,u,d){if("object"==typeof u&&null!==u&&u.type===h&&null===u.key&&(u=u.props.children),"object"==typeof u&&null!==u){switch(u.$$typeof){case b:e:{for(var x=u.key;null!==c;){if(c.key===x){if((x=u.type)===h){if(7===c.tag){n(s,c.sibling),(d=a(c,u.props.children)).return=s,s=d;break e}}else if(c.elementType===x||"object"==typeof x&&null!==x&&x.$$typeof===j&&oa(x)===c.type){n(s,c.sibling),ha(d=a(c,u.props),u),d.return=s,s=d;break e}n(s,c);break}t(s,c),c=c.sibling}u.type===h?((d=Kl(u.props.children,s.mode,d,u.key)).return=s,s=d):(ha(d=Hl(u.type,u.key,u.props,null,s.mode,d),u),d.return=s,s=d)}return o(s);case m:e:{for(x=u.key;null!==c;){if(c.key===x){if(4===c.tag&&c.stateNode.containerInfo===u.containerInfo&&c.stateNode.implementation===u.implementation){n(s,c.sibling),(d=a(c,u.children||[])).return=s,s=d;break e}n(s,c);break}t(s,c),c=c.sibling}(d=Xl(u,s.mode,d)).return=s,s=d}return o(s);case j:return y(s,c,u=oa(u),d)}if(D(u))return function(l,a,o,s){for(var c=null,u=null,d=a,b=a=0,m=null;null!==d&&b<o.length;b++){d.index>b?(m=d,d=null):m=d.sibling;var h=f(l,d,o[b],s);if(null===h){null===d&&(d=m);break}e&&d&&null===h.alternate&&t(l,d),a=i(h,a,b),null===u?c=h:u.sibling=h,u=h,d=m}if(b===o.length)return n(l,d),pr&&sr(l,b),c;if(null===d){for(;b<o.length;b++)null!==(d=p(l,o[b],s))&&(a=i(d,a,b),null===u?c=d:u.sibling=d,u=d);return pr&&sr(l,b),c}for(d=r(d);b<o.length;b++)null!==(m=g(d,l,b,o[b],s))&&(e&&null!==m.alternate&&d.delete(null===m.key?b:m.key),a=i(m,a,b),null===u?c=m:u.sibling=m,u=m);return e&&d.forEach(function(e){return t(l,e)}),pr&&sr(l,b),c}(s,c,u,d);if(M(u)){if("function"!=typeof(x=M(u)))throw Error(l(150));return function(a,o,s,c){if(null==s)throw Error(l(151));for(var u=null,d=null,b=o,m=o=0,h=null,y=s.next();null!==b&&!y.done;m++,y=s.next()){b.index>m?(h=b,b=null):h=b.sibling;var v=f(a,b,y.value,c);if(null===v){null===b&&(b=h);break}e&&b&&null===v.alternate&&t(a,b),o=i(v,o,m),null===d?u=v:d.sibling=v,d=v,b=h}if(y.done)return n(a,b),pr&&sr(a,m),u;if(null===b){for(;!y.done;m++,y=s.next())null!==(y=p(a,y.value,c))&&(o=i(y,o,m),null===d?u=y:d.sibling=y,d=y);return pr&&sr(a,m),u}for(b=r(b);!y.done;m++,y=s.next())null!==(y=g(b,a,m,y.value,c))&&(e&&null!==y.alternate&&b.delete(null===y.key?m:y.key),o=i(y,o,m),null===d?u=y:d.sibling=y,d=y);return e&&b.forEach(function(e){return t(a,e)}),pr&&sr(a,m),u}(s,c,u=x.call(u),d)}if("function"==typeof u.then)return y(s,c,ma(u),d);if(u.$$typeof===v)return y(s,c,Dr(s,u),d);pa(s,u)}return"string"==typeof u&&""!==u||"number"==typeof u||"bigint"==typeof u?(u=""+u,null!==c&&6===c.tag?(n(s,c.sibling),(d=a(c,u)).return=s,s=d):(n(s,c),(d=Gl(u,s.mode,d)).return=s,s=d),o(s)):n(s,c)}return function(e,t,n,l){try{ba=0;var r=y(e,t,n,l);return da=null,r}catch(i){if(i===ta||i===la)throw i;var a=Bl(29,i,null,e.mode);return a.lanes=l,a.return=e,a}}}var ga=fa(!0),ya=fa(!1),va=!1;function xa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function wa(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function ka(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Ca(e,t,n){var l=e.updateQueue;if(null===l)return null;if(l=l.shared,2&gc){var r=l.pending;return null===r?t.next=t:(t.next=r.next,r.next=t),l.pending=t,t=Rl(e),Ol(e,null,n),t}return Pl(e,l,t,n),Rl(e)}function Sa(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,4194048&n)){var l=t.lanes;n|=l&=e.pendingLanes,t.lanes=n,Oe(e,n)}}function ja(e,t){var n=e.updateQueue,l=e.alternate;if(null!==l&&n===(l=l.updateQueue)){var r=null,a=null;if(null!==(n=n.firstBaseUpdate)){do{var i={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};null===a?r=a=i:a=a.next=i,n=n.next}while(null!==n);null===a?r=a=t:a=a.next=t}else r=a=t;return n={baseState:l.baseState,firstBaseUpdate:r,lastBaseUpdate:a,shared:l.shared,callbacks:l.callbacks},void(e.updateQueue=n)}null===(e=n.lastBaseUpdate)?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Na=!1;function Ea(){if(Na){if(null!==Gr)throw Gr}}function $a(e,t,n,l){Na=!1;var r=e.updateQueue;va=!1;var a=r.firstBaseUpdate,i=r.lastBaseUpdate,o=r.shared.pending;if(null!==o){r.shared.pending=null;var s=o,c=s.next;s.next=null,null===i?a=c:i.next=c,i=s;var d=e.alternate;null!==d&&((o=(d=d.updateQueue).lastBaseUpdate)!==i&&(null===o?d.firstBaseUpdate=c:o.next=c,d.lastBaseUpdate=s))}if(null!==a){var b=r.baseState;for(i=0,d=c=s=null,o=a;;){var m=-536870913&o.lane,h=m!==o.lane;if(h?(xc&m)===m:(l&m)===m){0!==m&&m===Kr&&(Na=!0),null!==d&&(d=d.next={lane:0,tag:o.tag,payload:o.payload,callback:null,next:null});e:{var p=e,f=o;m=t;var g=n;switch(f.tag){case 1:if("function"==typeof(p=f.payload)){b=p.call(g,b,m);break e}b=p;break e;case 3:p.flags=-65537&p.flags|128;case 0:if(null==(m="function"==typeof(p=f.payload)?p.call(g,b,m):p))break e;b=u({},b,m);break e;case 2:va=!0}}null!==(m=o.callback)&&(e.flags|=64,h&&(e.flags|=8192),null===(h=r.callbacks)?r.callbacks=[m]:h.push(m))}else h={lane:m,tag:o.tag,payload:o.payload,callback:o.callback,next:null},null===d?(c=d=h,s=b):d=d.next=h,i|=m;if(null===(o=o.next)){if(null===(o=r.shared.pending))break;o=(h=o).next,h.next=null,r.lastBaseUpdate=h,r.shared.pending=null}}null===d&&(s=b),r.baseState=s,r.firstBaseUpdate=c,r.lastBaseUpdate=d,null===a&&(r.shared.lanes=0),$c|=i,e.lanes=i,e.memoizedState=b}}function _a(e,t){if("function"!=typeof e)throw Error(l(191,e));e.call(t)}function Ta(e,t){var n=e.callbacks;if(null!==n)for(e.callbacks=null,e=0;e<n.length;e++)_a(n[e],t)}var za=W(null),La=W(0);function Aa(e,t){V(La,e=Nc),V(za,t),Nc=e|t.baseLanes}function Ma(){V(La,Nc),V(za,za.current)}function Pa(){Nc=La.current,q(za),q(La)}var Ia=W(null),Da=null;function Oa(e){var t=e.alternate;V(Wa,1&Wa.current),V(Ia,e),null===Da&&(null===t||null!==za.current||null!==t.memoizedState)&&(Da=e)}function Ra(e){V(Wa,Wa.current),V(Ia,e),null===Da&&(Da=e)}function Fa(e){22===e.tag?(V(Wa,Wa.current),V(Ia,e),null===Da&&(Da=e)):Ua()}function Ua(){V(Wa,Wa.current),V(Ia,Ia.current)}function Ba(e){q(Ia),Da===e&&(Da=null),q(Wa)}var Wa=W(0);function qa(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||Pd(n)||Id(n)))return t}else if(19!==t.tag||"forwards"!==t.memoizedProps.revealOrder&&"backwards"!==t.memoizedProps.revealOrder&&"unstable_legacy-backwards"!==t.memoizedProps.revealOrder&&"together"!==t.memoizedProps.revealOrder){if(null!==t.child){t.child.return=t,t=t.child;continue}}else if(128&t.flags)return t;if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Va=0,Ha=null,Ka=null,Ga=null,Qa=!1,Xa=!1,Ya=!1,Ja=0,Za=0,ei=null,ti=0;function ni(){throw Error(l(321))}function li(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!nl(e[n],t[n]))return!1;return!0}function ri(e,t,n,l,r,a){return Va=a,Ha=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,O.H=null===e||null===e.memoizedState?xo:wo,Ya=!1,a=n(l,r),Ya=!1,Xa&&(a=ii(t,n,l,r)),ai(e),a}function ai(e){O.H=vo;var t=null!==Ka&&null!==Ka.next;if(Va=0,Ga=Ka=Ha=null,Qa=!1,Za=0,ei=null,t)throw Error(l(300));null===e||Do||null!==(e=e.dependencies)&&Mr(e)&&(Do=!0)}function ii(e,t,n,r){Ha=e;var a=0;do{if(Xa&&(ei=null),Za=0,Xa=!1,25<=a)throw Error(l(301));if(a+=1,Ga=Ka=null,null!=e.updateQueue){var i=e.updateQueue;i.lastEffect=null,i.events=null,i.stores=null,null!=i.memoCache&&(i.memoCache.index=0)}O.H=ko,i=t(n,r)}while(Xa);return i}function oi(){var e=O.H,t=e.useState()[0];return t="function"==typeof t.then?mi(t):t,e=e.useState()[0],(null!==Ka?Ka.memoizedState:null)!==e&&(Ha.flags|=1024),t}function si(){var e=0!==Ja;return Ja=0,e}function ci(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function ui(e){if(Qa){for(e=e.memoizedState;null!==e;){var t=e.queue;null!==t&&(t.pending=null),e=e.next}Qa=!1}Va=0,Ga=Ka=Ha=null,Xa=!1,Za=Ja=0,ei=null}function di(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===Ga?Ha.memoizedState=Ga=e:Ga=Ga.next=e,Ga}function bi(){if(null===Ka){var e=Ha.alternate;e=null!==e?e.memoizedState:null}else e=Ka.next;var t=null===Ga?Ha.memoizedState:Ga.next;if(null!==t)Ga=t,Ka=e;else{if(null===e){if(null===Ha.alternate)throw Error(l(467));throw Error(l(310))}e={memoizedState:(Ka=e).memoizedState,baseState:Ka.baseState,baseQueue:Ka.baseQueue,queue:Ka.queue,next:null},null===Ga?Ha.memoizedState=Ga=e:Ga=Ga.next=e}return Ga}function mi(e){var t=Za;return Za+=1,null===ei&&(ei=[]),e=ia(ei,e,t),t=Ha,null===(null===Ga?t.memoizedState:Ga.next)&&(t=t.alternate,O.H=null===t||null===t.memoizedState?xo:wo),e}function hi(e){if(null!==e&&"object"==typeof e){if("function"==typeof e.then)return mi(e);if(e.$$typeof===v)return Ir(e)}throw Error(l(438,String(e)))}function pi(e){var t=null,n=Ha.updateQueue;if(null!==n&&(t=n.memoCache),null==t){var l=Ha.alternate;null!==l&&(null!==(l=l.updateQueue)&&(null!=(l=l.memoCache)&&(t={data:l.data.map(function(e){return e.slice()}),index:0})))}if(null==t&&(t={data:[],index:0}),null===n&&(n={lastEffect:null,events:null,stores:null,memoCache:null},Ha.updateQueue=n),n.memoCache=t,void 0===(n=t.data[t.index]))for(n=t.data[t.index]=Array(e),l=0;l<e;l++)n[l]=T;return t.index++,n}function fi(e,t){return"function"==typeof t?t(e):t}function gi(e){return yi(bi(),Ka,e)}function yi(e,t,n){var r=e.queue;if(null===r)throw Error(l(311));r.lastRenderedReducer=n;var a=e.baseQueue,i=r.pending;if(null!==i){if(null!==a){var o=a.next;a.next=i.next,i.next=o}t.baseQueue=a=i,r.pending=null}if(i=e.baseState,null===a)e.memoizedState=i;else{var s=o=null,c=null,u=t=a.next,d=!1;do{var b=-536870913&u.lane;if(b!==u.lane?(xc&b)===b:(Va&b)===b){var m=u.revertLane;if(0===m)null!==c&&(c=c.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),b===Kr&&(d=!0);else{if((Va&m)===m){u=u.next,m===Kr&&(d=!0);continue}b={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(s=c=b,o=i):c=c.next=b,Ha.lanes|=m,$c|=m}b=u.action,Ya&&n(i,b),i=u.hasEagerState?u.eagerState:n(i,b)}else m={lane:b,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(s=c=m,o=i):c=c.next=m,Ha.lanes|=b,$c|=b;u=u.next}while(null!==u&&u!==t);if(null===c?o=i:c.next=s,!nl(i,e.memoizedState)&&(Do=!0,d&&null!==(n=Gr)))throw n;e.memoizedState=i,e.baseState=o,e.baseQueue=c,r.lastRenderedState=i}return null===a&&(r.lanes=0),[e.memoizedState,r.dispatch]}function vi(e){var t=bi(),n=t.queue;if(null===n)throw Error(l(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,i=t.memoizedState;if(null!==a){n.pending=null;var o=a=a.next;do{i=e(i,o.action),o=o.next}while(o!==a);nl(i,t.memoizedState)||(Do=!0),t.memoizedState=i,null===t.baseQueue&&(t.baseState=i),n.lastRenderedState=i}return[i,r]}function xi(e,t,n){var r=Ha,a=bi(),i=pr;if(i){if(void 0===n)throw Error(l(407));n=n()}else n=t();var o=!nl((Ka||a).memoizedState,n);if(o&&(a.memoizedState=n,Do=!0),a=a.queue,Vi(Ci.bind(null,r,a,e),[e]),a.getSnapshot!==t||o||null!==Ga&&1&Ga.memoizedState.tag){if(r.flags|=2048,Fi(9,{destroy:void 0},ki.bind(null,r,a,n,t),null),null===yc)throw Error(l(349));i||127&Va||wi(r,t,n)}return n}function wi(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},null===(t=Ha.updateQueue)?(t={lastEffect:null,events:null,stores:null,memoCache:null},Ha.updateQueue=t,t.stores=[e]):null===(n=t.stores)?t.stores=[e]:n.push(e)}function ki(e,t,n,l){t.value=n,t.getSnapshot=l,Si(t)&&ji(e)}function Ci(e,t,n){return n(function(){Si(t)&&ji(e)})}function Si(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!nl(e,n)}catch(l){return!0}}function ji(e){var t=Dl(e,2);null!==t&&Jc(t,e,2)}function Ni(e){var t=di();if("function"==typeof e){var n=e;if(e=n(),Ya){Ce(!0);try{n()}finally{Ce(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:fi,lastRenderedState:e},t}function Ei(e,t,n,l){return e.baseState=n,yi(e,Ka,"function"==typeof l?l:fi)}function $i(e,t,n,r,a){if(fo(e))throw Error(l(485));if(null!==(e=t.action)){var i={payload:a,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(e){i.listeners.push(e)}};null!==O.T?n(!0):i.isTransition=!1,r(i),null===(n=t.pending)?(i.next=t.pending=i,_i(t,i)):(i.next=n.next,t.pending=n.next=i)}}function _i(e,t){var n=t.action,l=t.payload,r=e.state;if(t.isTransition){var a=O.T,i={};O.T=i;try{var o=n(r,l),s=O.S;null!==s&&s(i,o),Ti(e,t,o)}catch(c){Li(e,t,c)}finally{null!==a&&null!==i.types&&(a.types=i.types),O.T=a}}else try{Ti(e,t,a=n(r,l))}catch(u){Li(e,t,u)}}function Ti(e,t,n){null!==n&&"object"==typeof n&&"function"==typeof n.then?n.then(function(n){zi(e,t,n)},function(n){return Li(e,t,n)}):zi(e,t,n)}function zi(e,t,n){t.status="fulfilled",t.value=n,Ai(t),e.state=n,null!==(t=e.pending)&&((n=t.next)===t?e.pending=null:(n=n.next,t.next=n,_i(e,n)))}function Li(e,t,n){var l=e.pending;if(e.pending=null,null!==l){l=l.next;do{t.status="rejected",t.reason=n,Ai(t),t=t.next}while(t!==l)}e.action=null}function Ai(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Mi(e,t){return t}function Pi(e,t){if(pr){var n=yc.formState;if(null!==n){e:{var l=Ha;if(pr){if(hr){t:{for(var r=hr,a=gr;8!==r.nodeType;){if(!a){r=null;break t}if(null===(r=Dd(r.nextSibling))){r=null;break t}}r="F!"===(a=r.data)||"F"===a?r:null}if(r){hr=Dd(r.nextSibling),l="F!"===r.data;break e}}vr(l)}l=!1}l&&(t=n[0])}}return(n=di()).memoizedState=n.baseState=t,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Mi,lastRenderedState:t},n.queue=l,n=mo.bind(null,Ha,l),l.dispatch=n,l=Ni(!1),a=po.bind(null,Ha,!1,l.queue),r={state:t,dispatch:null,action:e,pending:null},(l=di()).queue=r,n=$i.bind(null,Ha,r,a,n),r.dispatch=n,l.memoizedState=e,[t,n,!1]}function Ii(e){return Di(bi(),Ka,e)}function Di(e,t,n){if(t=yi(e,t,Mi)[0],e=gi(fi)[0],"object"==typeof t&&null!==t&&"function"==typeof t.then)try{var l=mi(t)}catch(i){if(i===ta)throw la;throw i}else l=t;var r=(t=bi()).queue,a=r.dispatch;return n!==t.memoizedState&&(Ha.flags|=2048,Fi(9,{destroy:void 0},Oi.bind(null,r,n),null)),[l,a,e]}function Oi(e,t){e.action=t}function Ri(e){var t=bi(),n=Ka;if(null!==n)return Di(t,n,e);bi(),t=t.memoizedState;var l=(n=bi()).queue.dispatch;return n.memoizedState=e,[t,l,!1]}function Fi(e,t,n,l){return e={tag:e,create:n,deps:l,inst:t,next:null},null===(t=Ha.updateQueue)&&(t={lastEffect:null,events:null,stores:null,memoCache:null},Ha.updateQueue=t),null===(n=t.lastEffect)?t.lastEffect=e.next=e:(l=n.next,n.next=e,e.next=l,t.lastEffect=e),e}function Ui(){return bi().memoizedState}function Bi(e,t,n,l){var r=di();Ha.flags|=e,r.memoizedState=Fi(1|t,{destroy:void 0},n,void 0===l?null:l)}function Wi(e,t,n,l){var r=bi();l=void 0===l?null:l;var a=r.memoizedState.inst;null!==Ka&&null!==l&&li(l,Ka.memoizedState.deps)?r.memoizedState=Fi(t,a,n,l):(Ha.flags|=e,r.memoizedState=Fi(1|t,a,n,l))}function qi(e,t){Bi(8390656,8,e,t)}function Vi(e,t){Wi(2048,8,e,t)}function Hi(e){var t=bi().memoizedState;return function(e){Ha.flags|=4;var t=Ha.updateQueue;if(null===t)t={lastEffect:null,events:null,stores:null,memoCache:null},Ha.updateQueue=t,t.events=[e];else{var n=t.events;null===n?t.events=[e]:n.push(e)}}({ref:t,nextImpl:e}),function(){if(2&gc)throw Error(l(440));return t.impl.apply(void 0,arguments)}}function Ki(e,t){return Wi(4,2,e,t)}function Gi(e,t){return Wi(4,4,e,t)}function Qi(e,t){if("function"==typeof t){e=e();var n=t(e);return function(){"function"==typeof n?n():t(null)}}if(null!=t)return e=e(),t.current=e,function(){t.current=null}}function Xi(e,t,n){n=null!=n?n.concat([e]):null,Wi(4,4,Qi.bind(null,t,e),n)}function Yi(){}function Ji(e,t){var n=bi();t=void 0===t?null:t;var l=n.memoizedState;return null!==t&&li(t,l[1])?l[0]:(n.memoizedState=[e,t],e)}function Zi(e,t){var n=bi();t=void 0===t?null:t;var l=n.memoizedState;if(null!==t&&li(t,l[1]))return l[0];if(l=e(),Ya){Ce(!0);try{e()}finally{Ce(!1)}}return n.memoizedState=[l,t],l}function eo(e,t,n){return void 0===n||1073741824&Va&&!(261930&xc)?e.memoizedState=t:(e.memoizedState=n,e=Yc(),Ha.lanes|=e,$c|=e,n)}function to(e,t,n,l){return nl(n,t)?n:null!==za.current?(e=eo(e,n,l),nl(e,t)||(Do=!0),e):42&Va&&(!(1073741824&Va)||261930&xc)?(e=Yc(),Ha.lanes|=e,$c|=e,t):(Do=!0,e.memoizedState=n)}function no(e,t,n,l,r){var a=R.p;R.p=0!==a&&8>a?a:8;var i,o,s,c=O.T,u={};O.T=u,po(e,!1,t,n);try{var d=r(),b=O.S;if(null!==b&&b(u,d),null!==d&&"object"==typeof d&&"function"==typeof d.then)ho(e,t,(i=l,o=[],s={status:"pending",value:null,reason:null,then:function(e){o.push(e)}},d.then(function(){s.status="fulfilled",s.value=i;for(var e=0;e<o.length;e++)(0,o[e])(i)},function(e){for(s.status="rejected",s.reason=e,e=0;e<o.length;e++)(0,o[e])(void 0)}),s),Xc());else ho(e,t,l,Xc())}catch(m){ho(e,t,{then:function(){},status:"rejected",reason:m},Xc())}finally{R.p=a,null!==c&&null!==u.types&&(c.types=u.types),O.T=c}}function lo(){}function ro(e,t,n,r){if(5!==e.tag)throw Error(l(476));var a=ao(e).queue;no(e,a,t,F,null===n?lo:function(){return io(e),n(r)})}function ao(e){var t=e.memoizedState;if(null!==t)return t;var n={};return(t={memoizedState:F,baseState:F,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:fi,lastRenderedState:F},next:null}).next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:fi,lastRenderedState:n},next:null},e.memoizedState=t,null!==(e=e.alternate)&&(e.memoizedState=t),t}function io(e){var t=ao(e);null===t.next&&(t=e.alternate.memoizedState),ho(e,t.next.queue,{},Xc())}function oo(){return Ir(hb)}function so(){return bi().memoizedState}function co(){return bi().memoizedState}function uo(e){for(var t=e.return;null!==t;){switch(t.tag){case 24:case 3:var n=Xc(),l=Ca(t,e=ka(n),n);return null!==l&&(Jc(l,t,n),Sa(l,t,n)),t={cache:Wr()},void(e.payload=t)}t=t.return}}function bo(e,t,n){var l=Xc();n={lane:l,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},fo(e)?go(t,n):null!==(n=Il(e,t,n,l))&&(Jc(n,e,l),yo(n,t,l))}function mo(e,t,n){ho(e,t,n,Xc())}function ho(e,t,n,l){var r={lane:l,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(fo(e))go(t,r);else{var a=e.alternate;if(0===e.lanes&&(null===a||0===a.lanes)&&null!==(a=t.lastRenderedReducer))try{var i=t.lastRenderedState,o=a(i,n);if(r.hasEagerState=!0,r.eagerState=o,nl(o,i))return Pl(e,t,r,0),null===yc&&Ml(),!1}catch(s){}if(null!==(n=Il(e,t,r,l)))return Jc(n,e,l),yo(n,t,l),!0}return!1}function po(e,t,n,r){if(r={lane:2,revertLane:Hu(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},fo(e)){if(t)throw Error(l(479))}else null!==(t=Il(e,n,r,2))&&Jc(t,e,2)}function fo(e){var t=e.alternate;return e===Ha||null!==t&&t===Ha}function go(e,t){Xa=Qa=!0;var n=e.pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function yo(e,t,n){if(4194048&n){var l=t.lanes;n|=l&=e.pendingLanes,t.lanes=n,Oe(e,n)}}var vo={readContext:Ir,use:hi,useCallback:ni,useContext:ni,useEffect:ni,useImperativeHandle:ni,useLayoutEffect:ni,useInsertionEffect:ni,useMemo:ni,useReducer:ni,useRef:ni,useState:ni,useDebugValue:ni,useDeferredValue:ni,useTransition:ni,useSyncExternalStore:ni,useId:ni,useHostTransitionStatus:ni,useFormState:ni,useActionState:ni,useOptimistic:ni,useMemoCache:ni,useCacheRefresh:ni};vo.useEffectEvent=ni;var xo={readContext:Ir,use:hi,useCallback:function(e,t){return di().memoizedState=[e,void 0===t?null:t],e},useContext:Ir,useEffect:qi,useImperativeHandle:function(e,t,n){n=null!=n?n.concat([e]):null,Bi(4194308,4,Qi.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Bi(4194308,4,e,t)},useInsertionEffect:function(e,t){Bi(4,2,e,t)},useMemo:function(e,t){var n=di();t=void 0===t?null:t;var l=e();if(Ya){Ce(!0);try{e()}finally{Ce(!1)}}return n.memoizedState=[l,t],l},useReducer:function(e,t,n){var l=di();if(void 0!==n){var r=n(t);if(Ya){Ce(!0);try{n(t)}finally{Ce(!1)}}}else r=t;return l.memoizedState=l.baseState=r,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:r},l.queue=e,e=e.dispatch=bo.bind(null,Ha,e),[l.memoizedState,e]},useRef:function(e){return e={current:e},di().memoizedState=e},useState:function(e){var t=(e=Ni(e)).queue,n=mo.bind(null,Ha,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Yi,useDeferredValue:function(e,t){return eo(di(),e,t)},useTransition:function(){var e=Ni(!1);return e=no.bind(null,Ha,e.queue,!0,!1),di().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=Ha,a=di();if(pr){if(void 0===n)throw Error(l(407));n=n()}else{if(n=t(),null===yc)throw Error(l(349));127&xc||wi(r,t,n)}a.memoizedState=n;var i={value:n,getSnapshot:t};return a.queue=i,qi(Ci.bind(null,r,i,e),[e]),r.flags|=2048,Fi(9,{destroy:void 0},ki.bind(null,r,i,n,t),null),n},useId:function(){var e=di(),t=yc.identifierPrefix;if(pr){var n=or;t="_"+t+"R_"+(n=(ir&~(1<<32-Se(ir)-1)).toString(32)+n),0<(n=Ja++)&&(t+="H"+n.toString(32)),t+="_"}else t="_"+t+"r_"+(n=ti++).toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:oo,useFormState:Pi,useActionState:Pi,useOptimistic:function(e){var t=di();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=po.bind(null,Ha,!0,n),n.dispatch=t,[e,t]},useMemoCache:pi,useCacheRefresh:function(){return di().memoizedState=uo.bind(null,Ha)},useEffectEvent:function(e){var t=di(),n={impl:e};return t.memoizedState=n,function(){if(2&gc)throw Error(l(440));return n.impl.apply(void 0,arguments)}}},wo={readContext:Ir,use:hi,useCallback:Ji,useContext:Ir,useEffect:Vi,useImperativeHandle:Xi,useInsertionEffect:Ki,useLayoutEffect:Gi,useMemo:Zi,useReducer:gi,useRef:Ui,useState:function(){return gi(fi)},useDebugValue:Yi,useDeferredValue:function(e,t){return to(bi(),Ka.memoizedState,e,t)},useTransition:function(){var e=gi(fi)[0],t=bi().memoizedState;return["boolean"==typeof e?e:mi(e),t]},useSyncExternalStore:xi,useId:so,useHostTransitionStatus:oo,useFormState:Ii,useActionState:Ii,useOptimistic:function(e,t){return Ei(bi(),0,e,t)},useMemoCache:pi,useCacheRefresh:co};wo.useEffectEvent=Hi;var ko={readContext:Ir,use:hi,useCallback:Ji,useContext:Ir,useEffect:Vi,useImperativeHandle:Xi,useInsertionEffect:Ki,useLayoutEffect:Gi,useMemo:Zi,useReducer:vi,useRef:Ui,useState:function(){return vi(fi)},useDebugValue:Yi,useDeferredValue:function(e,t){var n=bi();return null===Ka?eo(n,e,t):to(n,Ka.memoizedState,e,t)},useTransition:function(){var e=vi(fi)[0],t=bi().memoizedState;return["boolean"==typeof e?e:mi(e),t]},useSyncExternalStore:xi,useId:so,useHostTransitionStatus:oo,useFormState:Ri,useActionState:Ri,useOptimistic:function(e,t){var n=bi();return null!==Ka?Ei(n,0,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:pi,useCacheRefresh:co};function Co(e,t,n,l){n=null==(n=n(l,t=e.memoizedState))?t:u({},t,n),e.memoizedState=n,0===e.lanes&&(e.updateQueue.baseState=n)}ko.useEffectEvent=Hi;var So={enqueueSetState:function(e,t,n){e=e._reactInternals;var l=Xc(),r=ka(l);r.payload=t,null!=n&&(r.callback=n),null!==(t=Ca(e,r,l))&&(Jc(t,e,l),Sa(t,e,l))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var l=Xc(),r=ka(l);r.tag=1,r.payload=t,null!=n&&(r.callback=n),null!==(t=Ca(e,r,l))&&(Jc(t,e,l),Sa(t,e,l))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Xc(),l=ka(n);l.tag=2,null!=t&&(l.callback=t),null!==(t=Ca(e,l,n))&&(Jc(t,e,n),Sa(t,e,n))}};function jo(e,t,n,l,r,a,i){return"function"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(l,a,i):!t.prototype||!t.prototype.isPureReactComponent||(!ll(n,l)||!ll(r,a))}function No(e,t,n,l){e=t.state,"function"==typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,l),"function"==typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,l),t.state!==e&&So.enqueueReplaceState(t,t.state,null)}function Eo(e,t){var n=t;if("ref"in t)for(var l in n={},t)"ref"!==l&&(n[l]=t[l]);if(e=e.defaultProps)for(var r in n===t&&(n=u({},n)),e)void 0===n[r]&&(n[r]=e[r]);return n}function $o(e){Tl(e)}function _o(e){console.error(e)}function To(e){Tl(e)}function zo(e,t){try{(0,e.onUncaughtError)(t.value,{componentStack:t.stack})}catch(n){setTimeout(function(){throw n})}}function Lo(e,t,n){try{(0,e.onCaughtError)(n.value,{componentStack:n.stack,errorBoundary:1===t.tag?t.stateNode:null})}catch(l){setTimeout(function(){throw l})}}function Ao(e,t,n){return(n=ka(n)).tag=3,n.payload={element:null},n.callback=function(){zo(e,t)},n}function Mo(e){return(e=ka(e)).tag=3,e}function Po(e,t,n,l){var r=n.type.getDerivedStateFromError;if("function"==typeof r){var a=l.value;e.payload=function(){return r(a)},e.callback=function(){Lo(t,n,l)}}var i=n.stateNode;null!==i&&"function"==typeof i.componentDidCatch&&(e.callback=function(){Lo(t,n,l),"function"!=typeof r&&(null===Fc?Fc=new Set([this]):Fc.add(this));var e=l.stack;this.componentDidCatch(l.value,{componentStack:null!==e?e:""})})}var Io=Error(l(461)),Do=!1;function Oo(e,t,n,l){t.child=null===e?ya(t,null,n,l):ga(t,e.child,n,l)}function Ro(e,t,n,l,r){n=n.render;var a=t.ref;if("ref"in l){var i={};for(var o in l)"ref"!==o&&(i[o]=l[o])}else i=l;return Pr(t),l=ri(e,t,n,i,a,r),o=si(),null===e||Do?(pr&&o&&ur(t),t.flags|=1,Oo(e,t,l,r),t.child):(ci(e,t,r),ss(e,t,r))}function Fo(e,t,n,l,r){if(null===e){var a=n.type;return"function"!=typeof a||Wl(a)||void 0!==a.defaultProps||null!==n.compare?((e=Hl(n.type,null,l,t,t.mode,r)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=a,Uo(e,t,a,l,r))}if(a=e.child,!cs(e,r)){var i=a.memoizedProps;if((n=null!==(n=n.compare)?n:ll)(i,l)&&e.ref===t.ref)return ss(e,t,r)}return t.flags|=1,(e=ql(a,l)).ref=t.ref,e.return=t,t.child=e}function Uo(e,t,n,l,r){if(null!==e){var a=e.memoizedProps;if(ll(a,l)&&e.ref===t.ref){if(Do=!1,t.pendingProps=l=a,!cs(e,r))return t.lanes=e.lanes,ss(e,t,r);131072&e.flags&&(Do=!0)}}return Go(e,t,n,l,r)}function Bo(e,t,n,l){var r=l.children,a=null!==e?e.memoizedState:null;if(null===e&&null===t.stateNode&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),"hidden"===l.mode){if(128&t.flags){if(a=null!==a?a.baseLanes|n:n,null!==e){for(l=t.child=e.child,r=0;null!==l;)r=r|l.lanes|l.childLanes,l=l.sibling;l=r&~a}else l=0,t.child=null;return qo(e,t,a,n,l)}if(!(536870912&n))return l=t.lanes=536870912,qo(e,t,null!==a?a.baseLanes|n:n,n,l);t.memoizedState={baseLanes:0,cachePool:null},null!==e&&Zr(0,null!==a?a.cachePool:null),null!==a?Aa(t,a):Ma(),Fa(t)}else null!==a?(Zr(0,a.cachePool),Aa(t,a),Ua(),t.memoizedState=null):(null!==e&&Zr(0,null),Ma(),Ua());return Oo(e,t,r,n),t.child}function Wo(e,t){return null!==e&&22===e.tag||null!==t.stateNode||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function qo(e,t,n,l,r){var a=Jr();return a=null===a?null:{parent:Br._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},null!==e&&Zr(0,null),Ma(),Fa(t),null!==e&&Ar(e,t,l,!0),t.childLanes=r,null}function Vo(e,t){return(t=ls({mode:t.mode,children:t.children},e.mode)).ref=e.ref,e.child=t,t.return=e,t}function Ho(e,t,n){return ga(t,e.child,null,n),(e=Vo(t,t.pendingProps)).flags|=2,Ba(t),t.memoizedState=null,e}function Ko(e,t){var n=t.ref;if(null===n)null!==e&&null!==e.ref&&(t.flags|=4194816);else{if("function"!=typeof n&&"object"!=typeof n)throw Error(l(284));null!==e&&e.ref===n||(t.flags|=4194816)}}function Go(e,t,n,l,r){return Pr(t),n=ri(e,t,n,l,void 0,r),l=si(),null===e||Do?(pr&&l&&ur(t),t.flags|=1,Oo(e,t,n,r),t.child):(ci(e,t,r),ss(e,t,r))}function Qo(e,t,n,l,r,a){return Pr(t),t.updateQueue=null,n=ii(t,l,n,r),ai(e),l=si(),null===e||Do?(pr&&l&&ur(t),t.flags|=1,Oo(e,t,n,a),t.child):(ci(e,t,a),ss(e,t,a))}function Xo(e,t,n,l,r){if(Pr(t),null===t.stateNode){var a=Fl,i=n.contextType;"object"==typeof i&&null!==i&&(a=Ir(i)),a=new n(l,a),t.memoizedState=null!==a.state&&void 0!==a.state?a.state:null,a.updater=So,t.stateNode=a,a._reactInternals=t,(a=t.stateNode).props=l,a.state=t.memoizedState,a.refs={},xa(t),i=n.contextType,a.context="object"==typeof i&&null!==i?Ir(i):Fl,a.state=t.memoizedState,"function"==typeof(i=n.getDerivedStateFromProps)&&(Co(t,n,i,l),a.state=t.memoizedState),"function"==typeof n.getDerivedStateFromProps||"function"==typeof a.getSnapshotBeforeUpdate||"function"!=typeof a.UNSAFE_componentWillMount&&"function"!=typeof a.componentWillMount||(i=a.state,"function"==typeof a.componentWillMount&&a.componentWillMount(),"function"==typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount(),i!==a.state&&So.enqueueReplaceState(a,a.state,null),$a(t,l,a,r),Ea(),a.state=t.memoizedState),"function"==typeof a.componentDidMount&&(t.flags|=4194308),l=!0}else if(null===e){a=t.stateNode;var o=t.memoizedProps,s=Eo(n,o);a.props=s;var c=a.context,u=n.contextType;i=Fl,"object"==typeof u&&null!==u&&(i=Ir(u));var d=n.getDerivedStateFromProps;u="function"==typeof d||"function"==typeof a.getSnapshotBeforeUpdate,o=t.pendingProps!==o,u||"function"!=typeof a.UNSAFE_componentWillReceiveProps&&"function"!=typeof a.componentWillReceiveProps||(o||c!==i)&&No(t,a,l,i),va=!1;var b=t.memoizedState;a.state=b,$a(t,l,a,r),Ea(),c=t.memoizedState,o||b!==c||va?("function"==typeof d&&(Co(t,n,d,l),c=t.memoizedState),(s=va||jo(t,n,s,l,b,c,i))?(u||"function"!=typeof a.UNSAFE_componentWillMount&&"function"!=typeof a.componentWillMount||("function"==typeof a.componentWillMount&&a.componentWillMount(),"function"==typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount()),"function"==typeof a.componentDidMount&&(t.flags|=4194308)):("function"==typeof a.componentDidMount&&(t.flags|=4194308),t.memoizedProps=l,t.memoizedState=c),a.props=l,a.state=c,a.context=i,l=s):("function"==typeof a.componentDidMount&&(t.flags|=4194308),l=!1)}else{a=t.stateNode,wa(e,t),u=Eo(n,i=t.memoizedProps),a.props=u,d=t.pendingProps,b=a.context,c=n.contextType,s=Fl,"object"==typeof c&&null!==c&&(s=Ir(c)),(c="function"==typeof(o=n.getDerivedStateFromProps)||"function"==typeof a.getSnapshotBeforeUpdate)||"function"!=typeof a.UNSAFE_componentWillReceiveProps&&"function"!=typeof a.componentWillReceiveProps||(i!==d||b!==s)&&No(t,a,l,s),va=!1,b=t.memoizedState,a.state=b,$a(t,l,a,r),Ea();var m=t.memoizedState;i!==d||b!==m||va||null!==e&&null!==e.dependencies&&Mr(e.dependencies)?("function"==typeof o&&(Co(t,n,o,l),m=t.memoizedState),(u=va||jo(t,n,u,l,b,m,s)||null!==e&&null!==e.dependencies&&Mr(e.dependencies))?(c||"function"!=typeof a.UNSAFE_componentWillUpdate&&"function"!=typeof a.componentWillUpdate||("function"==typeof a.componentWillUpdate&&a.componentWillUpdate(l,m,s),"function"==typeof a.UNSAFE_componentWillUpdate&&a.UNSAFE_componentWillUpdate(l,m,s)),"function"==typeof a.componentDidUpdate&&(t.flags|=4),"function"==typeof a.getSnapshotBeforeUpdate&&(t.flags|=1024)):("function"!=typeof a.componentDidUpdate||i===e.memoizedProps&&b===e.memoizedState||(t.flags|=4),"function"!=typeof a.getSnapshotBeforeUpdate||i===e.memoizedProps&&b===e.memoizedState||(t.flags|=1024),t.memoizedProps=l,t.memoizedState=m),a.props=l,a.state=m,a.context=s,l=u):("function"!=typeof a.componentDidUpdate||i===e.memoizedProps&&b===e.memoizedState||(t.flags|=4),"function"!=typeof a.getSnapshotBeforeUpdate||i===e.memoizedProps&&b===e.memoizedState||(t.flags|=1024),l=!1)}return a=l,Ko(e,t),l=!!(128&t.flags),a||l?(a=t.stateNode,n=l&&"function"!=typeof n.getDerivedStateFromError?null:a.render(),t.flags|=1,null!==e&&l?(t.child=ga(t,e.child,null,r),t.child=ga(t,null,n,r)):Oo(e,t,n,r),t.memoizedState=a.state,e=t.child):e=ss(e,t,r),e}function Yo(e,t,n,l){return Cr(),t.flags|=256,Oo(e,t,n,l),t.child}var Jo={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Zo(e){return{baseLanes:e,cachePool:ea()}}function es(e,t,n){return e=null!==e?e.childLanes&~n:0,t&&(e|=zc),e}function ts(e,t,n){var r,a=t.pendingProps,i=!1,o=!!(128&t.flags);if((r=o)||(r=(null===e||null!==e.memoizedState)&&!!(2&Wa.current)),r&&(i=!0,t.flags&=-129),r=!!(32&t.flags),t.flags&=-33,null===e){if(pr){if(i?Oa(t):Ua(),(e=hr)?null!==(e=null!==(e=Md(e,gr))&&"&"!==e.data?e:null)&&(t.memoizedState={dehydrated:e,treeContext:null!==ar?{id:ir,overflow:or}:null,retryLane:536870912,hydrationErrors:null},(n=Ql(e)).return=t,t.child=n,mr=t,hr=null):e=null,null===e)throw vr(t);return Id(e)?t.lanes=32:t.lanes=536870912,null}var s=a.children;return a=a.fallback,i?(Ua(),s=ls({mode:"hidden",children:s},i=t.mode),a=Kl(a,i,n,null),s.return=t,a.return=t,s.sibling=a,t.child=s,(a=t.child).memoizedState=Zo(n),a.childLanes=es(e,r,n),t.memoizedState=Jo,Wo(null,a)):(Oa(t),ns(t,s))}var c=e.memoizedState;if(null!==c&&null!==(s=c.dehydrated)){if(o)256&t.flags?(Oa(t),t.flags&=-257,t=rs(e,t,n)):null!==t.memoizedState?(Ua(),t.child=e.child,t.flags|=128,t=null):(Ua(),s=a.fallback,i=t.mode,a=ls({mode:"visible",children:a.children},i),(s=Kl(s,i,n,null)).flags|=2,a.return=t,s.return=t,a.sibling=s,t.child=a,ga(t,e.child,null,n),(a=t.child).memoizedState=Zo(n),a.childLanes=es(e,r,n),t.memoizedState=Jo,t=Wo(null,a));else if(Oa(t),Id(s)){if(r=s.nextSibling&&s.nextSibling.dataset)var u=r.dgst;r=u,(a=Error(l(419))).stack="",a.digest=r,jr({value:a,source:null,stack:null}),t=rs(e,t,n)}else if(Do||Ar(e,t,n,!1),r=0!==(n&e.childLanes),Do||r){if(null!==(r=yc)&&(0!==(a=Re(r,n))&&a!==c.retryLane))throw c.retryLane=a,Dl(e,a),Jc(r,e,a),Io;Pd(s)||uu(),t=rs(e,t,n)}else Pd(s)?(t.flags|=192,t.child=e.child,t=null):(e=c.treeContext,hr=Dd(s.nextSibling),mr=t,pr=!0,fr=null,gr=!1,null!==e&&br(t,e),(t=ns(t,a.children)).flags|=4096);return t}return i?(Ua(),s=a.fallback,i=t.mode,u=(c=e.child).sibling,(a=ql(c,{mode:"hidden",children:a.children})).subtreeFlags=65011712&c.subtreeFlags,null!==u?s=ql(u,s):(s=Kl(s,i,n,null)).flags|=2,s.return=t,a.return=t,a.sibling=s,t.child=a,Wo(null,a),a=t.child,null===(s=e.child.memoizedState)?s=Zo(n):(null!==(i=s.cachePool)?(c=Br._currentValue,i=i.parent!==c?{parent:c,pool:c}:i):i=ea(),s={baseLanes:s.baseLanes|n,cachePool:i}),a.memoizedState=s,a.childLanes=es(e,r,n),t.memoizedState=Jo,Wo(e.child,a)):(Oa(t),e=(n=e.child).sibling,(n=ql(n,{mode:"visible",children:a.children})).return=t,n.sibling=null,null!==e&&(null===(r=t.deletions)?(t.deletions=[e],t.flags|=16):r.push(e)),t.child=n,t.memoizedState=null,n)}function ns(e,t){return(t=ls({mode:"visible",children:t},e.mode)).return=e,e.child=t}function ls(e,t){return(e=Bl(22,e,null,t)).lanes=0,e}function rs(e,t,n){return ga(t,e.child,null,n),(e=ns(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function as(e,t,n){e.lanes|=t;var l=e.alternate;null!==l&&(l.lanes|=t),zr(e.return,t,n)}function is(e,t,n,l,r,a){var i=e.memoizedState;null===i?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:l,tail:n,tailMode:r,treeForkCount:a}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=l,i.tail=n,i.tailMode=r,i.treeForkCount=a)}function os(e,t,n){var l=t.pendingProps,r=l.revealOrder,a=l.tail;l=l.children;var i=Wa.current,o=!!(2&i);if(o?(i=1&i|2,t.flags|=128):i&=1,V(Wa,i),Oo(e,t,l,n),l=pr?nr:0,!o&&null!==e&&128&e.flags)e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&as(e,n,t);else if(19===e.tag)as(e,n,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(r){case"forwards":for(n=t.child,r=null;null!==n;)null!==(e=n.alternate)&&null===qa(e)&&(r=n),n=n.sibling;null===(n=r)?(r=t.child,t.child=null):(r=n.sibling,n.sibling=null),is(t,!1,r,n,a,l);break;case"backwards":case"unstable_legacy-backwards":for(n=null,r=t.child,t.child=null;null!==r;){if(null!==(e=r.alternate)&&null===qa(e)){t.child=r;break}e=r.sibling,r.sibling=n,n=r,r=e}is(t,!0,n,null,a,l);break;case"together":is(t,!1,null,null,void 0,l);break;default:t.memoizedState=null}return t.child}function ss(e,t,n){if(null!==e&&(t.dependencies=e.dependencies),$c|=t.lanes,0===(n&t.childLanes)){if(null===e)return null;if(Ar(e,t,n,!1),0===(n&t.childLanes))return null}if(null!==e&&t.child!==e.child)throw Error(l(153));if(null!==t.child){for(n=ql(e=t.child,e.pendingProps),t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=ql(e,e.pendingProps)).return=t;n.sibling=null}return t.child}function cs(e,t){return 0!==(e.lanes&t)||!(null===(e=e.dependencies)||!Mr(e))}function us(e,t,n){if(null!==e)if(e.memoizedProps!==t.pendingProps)Do=!0;else{if(!(cs(e,n)||128&t.flags))return Do=!1,function(e,t,n){switch(t.tag){case 3:J(t,t.stateNode.containerInfo),_r(0,Br,e.memoizedState.cache),Cr();break;case 27:case 5:ee(t);break;case 4:J(t,t.stateNode.containerInfo);break;case 10:_r(0,t.type,t.memoizedProps.value);break;case 31:if(null!==t.memoizedState)return t.flags|=128,Ra(t),null;break;case 13:var l=t.memoizedState;if(null!==l)return null!==l.dehydrated?(Oa(t),t.flags|=128,null):0!==(n&t.child.childLanes)?ts(e,t,n):(Oa(t),null!==(e=ss(e,t,n))?e.sibling:null);Oa(t);break;case 19:var r=!!(128&e.flags);if((l=0!==(n&t.childLanes))||(Ar(e,t,n,!1),l=0!==(n&t.childLanes)),r){if(l)return os(e,t,n);t.flags|=128}if(null!==(r=t.memoizedState)&&(r.rendering=null,r.tail=null,r.lastEffect=null),V(Wa,Wa.current),l)break;return null;case 22:return t.lanes=0,Bo(e,t,n,t.pendingProps);case 24:_r(0,Br,e.memoizedState.cache)}return ss(e,t,n)}(e,t,n);Do=!!(131072&e.flags)}else Do=!1,pr&&1048576&t.flags&&cr(t,nr,t.index);switch(t.lanes=0,t.tag){case 16:e:{var r=t.pendingProps;if(e=oa(t.elementType),t.type=e,"function"!=typeof e){if(null!=e){var a=e.$$typeof;if(a===x){t.tag=11,t=Ro(null,t,e,r,n);break e}if(a===S){t.tag=14,t=Fo(null,t,e,r,n);break e}}throw t=I(e)||e,Error(l(306,t,""))}Wl(e)?(r=Eo(e,r),t.tag=1,t=Xo(null,t,e,r,n)):(t.tag=0,t=Go(null,t,e,r,n))}return t;case 0:return Go(e,t,t.type,t.pendingProps,n);case 1:return Xo(e,t,r=t.type,a=Eo(r,t.pendingProps),n);case 3:e:{if(J(t,t.stateNode.containerInfo),null===e)throw Error(l(387));r=t.pendingProps;var i=t.memoizedState;a=i.element,wa(e,t),$a(t,r,null,n);var o=t.memoizedState;if(r=o.cache,_r(0,Br,r),r!==i.cache&&Lr(t,[Br],n,!0),Ea(),r=o.element,i.isDehydrated){if(i={element:r,isDehydrated:!1,cache:o.cache},t.updateQueue.baseState=i,t.memoizedState=i,256&t.flags){t=Yo(e,t,r,n);break e}if(r!==a){jr(a=Jl(Error(l(424)),t)),t=Yo(e,t,r,n);break e}if(9===(e=t.stateNode.containerInfo).nodeType)e=e.body;else e="HTML"===e.nodeName?e.ownerDocument.body:e;for(hr=Dd(e.firstChild),mr=t,pr=!0,fr=null,gr=!0,n=ya(t,null,r,n),t.child=n;n;)n.flags=-3&n.flags|4096,n=n.sibling}else{if(Cr(),r===a){t=ss(e,t,n);break e}Oo(e,t,r,n)}t=t.child}return t;case 26:return Ko(e,t),null===e?(n=Qd(t.type,null,t.pendingProps,null))?t.memoizedState=n:pr||(n=t.type,e=t.pendingProps,(r=xd(X.current).createElement(n))[Ve]=t,r[He]=e,fd(r,n,e),rt(r),t.stateNode=r):t.memoizedState=Qd(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return ee(t),null===e&&pr&&(r=t.stateNode=Ud(t.type,t.pendingProps,X.current),mr=t,gr=!0,a=hr,Td(t.type)?(Od=a,hr=Dd(r.firstChild)):hr=a),Oo(e,t,t.pendingProps.children,n),Ko(e,t),null===e&&(t.flags|=4194304),t.child;case 5:return null===e&&pr&&((a=r=hr)&&(null!==(r=function(e,t,n,l){for(;1===e.nodeType;){var r=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!l&&("INPUT"!==e.nodeName||"hidden"!==e.type))break}else if(l){if(!e[Je])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if("stylesheet"===(a=e.getAttribute("rel"))&&e.hasAttribute("data-precedence"))break;if(a!==r.rel||e.getAttribute("href")!==(null==r.href||""===r.href?null:r.href)||e.getAttribute("crossorigin")!==(null==r.crossOrigin?null:r.crossOrigin)||e.getAttribute("title")!==(null==r.title?null:r.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(((a=e.getAttribute("src"))!==(null==r.src?null:r.src)||e.getAttribute("type")!==(null==r.type?null:r.type)||e.getAttribute("crossorigin")!==(null==r.crossOrigin?null:r.crossOrigin))&&a&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else{if("input"!==t||"hidden"!==e.type)return e;var a=null==r.name?null:""+r.name;if("hidden"===r.type&&e.getAttribute("name")===a)return e}if(null===(e=Dd(e.nextSibling)))break}return null}(r,t.type,t.pendingProps,gr))?(t.stateNode=r,mr=t,hr=Dd(r.firstChild),gr=!1,a=!0):a=!1),a||vr(t)),ee(t),a=t.type,i=t.pendingProps,o=null!==e?e.memoizedProps:null,r=i.children,Cd(a,i)?r=null:null!==o&&Cd(a,o)&&(t.flags|=32),null!==t.memoizedState&&(a=ri(e,t,oi,null,null,n),hb._currentValue=a),Ko(e,t),Oo(e,t,r,n),t.child;case 6:return null===e&&pr&&((e=n=hr)&&(null!==(n=function(e,t,n){if(""===t)return null;for(;3!==e.nodeType;){if((1!==e.nodeType||"INPUT"!==e.nodeName||"hidden"!==e.type)&&!n)return null;if(null===(e=Dd(e.nextSibling)))return null}return e}(n,t.pendingProps,gr))?(t.stateNode=n,mr=t,hr=null,e=!0):e=!1),e||vr(t)),null;case 13:return ts(e,t,n);case 4:return J(t,t.stateNode.containerInfo),r=t.pendingProps,null===e?t.child=ga(t,null,r,n):Oo(e,t,r,n),t.child;case 11:return Ro(e,t,t.type,t.pendingProps,n);case 7:return Oo(e,t,t.pendingProps,n),t.child;case 8:case 12:return Oo(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,_r(0,t.type,r.value),Oo(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,Pr(t),r=r(a=Ir(a)),t.flags|=1,Oo(e,t,r,n),t.child;case 14:return Fo(e,t,t.type,t.pendingProps,n);case 15:return Uo(e,t,t.type,t.pendingProps,n);case 19:return os(e,t,n);case 31:return function(e,t,n){var r=t.pendingProps,a=!!(128&t.flags);if(t.flags&=-129,null===e){if(pr){if("hidden"===r.mode)return e=Vo(t,r),t.lanes=536870912,Wo(null,e);if(Ra(t),(e=hr)?null!==(e=null!==(e=Md(e,gr))&&"&"===e.data?e:null)&&(t.memoizedState={dehydrated:e,treeContext:null!==ar?{id:ir,overflow:or}:null,retryLane:536870912,hydrationErrors:null},(n=Ql(e)).return=t,t.child=n,mr=t,hr=null):e=null,null===e)throw vr(t);return t.lanes=536870912,null}return Vo(t,r)}var i=e.memoizedState;if(null!==i){var o=i.dehydrated;if(Ra(t),a)if(256&t.flags)t.flags&=-257,t=Ho(e,t,n);else{if(null===t.memoizedState)throw Error(l(558));t.child=e.child,t.flags|=128,t=null}else if(Do||Ar(e,t,n,!1),a=0!==(n&e.childLanes),Do||a){if(null!==(r=yc)&&0!==(o=Re(r,n))&&o!==i.retryLane)throw i.retryLane=o,Dl(e,o),Jc(r,e,o),Io;uu(),t=Ho(e,t,n)}else e=i.treeContext,hr=Dd(o.nextSibling),mr=t,pr=!0,fr=null,gr=!1,null!==e&&br(t,e),(t=Vo(t,r)).flags|=4096;return t}return(e=ql(e.child,{mode:r.mode,children:r.children})).ref=t.ref,t.child=e,e.return=t,e}(e,t,n);case 22:return Bo(e,t,n,t.pendingProps);case 24:return Pr(t),r=Ir(Br),null===e?(null===(a=Jr())&&(a=yc,i=Wr(),a.pooledCache=i,i.refCount++,null!==i&&(a.pooledCacheLanes|=n),a=i),t.memoizedState={parent:r,cache:a},xa(t),_r(0,Br,a)):(0!==(e.lanes&n)&&(wa(e,t),$a(t,null,null,n),Ea()),a=e.memoizedState,i=t.memoizedState,a.parent!==r?(a={parent:r,cache:r},t.memoizedState=a,0===t.lanes&&(t.memoizedState=t.updateQueue.baseState=a),_r(0,Br,r)):(r=i.cache,_r(0,Br,r),r!==a.cache&&Lr(t,[Br],n,!0))),Oo(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(l(156,t.tag))}function ds(e){e.flags|=4}function bs(e,t,n,l,r){if((t=!!(32&e.mode))&&(t=!1),t){if(e.flags|=16777216,(335544128&r)===r)if(e.stateNode.complete)e.flags|=8192;else{if(!ou())throw sa=ra,na;e.flags|=8192}}else e.flags&=-16777217}function ms(e,t){if("stylesheet"!==t.type||4&t.state.loading)e.flags&=-16777217;else if(e.flags|=16777216,!sb(t)){if(!ou())throw sa=ra,na;e.flags|=8192}}function hs(e,t){null!==t&&(e.flags|=4),16384&e.flags&&(t=22!==e.tag?Me():536870912,e.lanes|=t,Lc|=t)}function ps(e,t){if(!pr)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var l=null;null!==n;)null!==n.alternate&&(l=n),n=n.sibling;null===l?t||null===e.tail?e.tail=null:e.tail.sibling=null:l.sibling=null}}function fs(e){var t=null!==e.alternate&&e.alternate.child===e.child,n=0,l=0;if(t)for(var r=e.child;null!==r;)n|=r.lanes|r.childLanes,l|=65011712&r.subtreeFlags,l|=65011712&r.flags,r.return=e,r=r.sibling;else for(r=e.child;null!==r;)n|=r.lanes|r.childLanes,l|=r.subtreeFlags,l|=r.flags,r.return=e,r=r.sibling;return e.subtreeFlags|=l,e.childLanes=n,t}function gs(e,t,n){var r=t.pendingProps;switch(dr(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:case 1:return fs(t),null;case 3:return n=t.stateNode,r=null,null!==e&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Tr(Br),Z(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),null!==e&&null!==e.child||(kr(t)?ds(t):null===e||e.memoizedState.isDehydrated&&!(256&t.flags)||(t.flags|=1024,Sr())),fs(t),null;case 26:var a=t.type,i=t.memoizedState;return null===e?(ds(t),null!==i?(fs(t),ms(t,i)):(fs(t),bs(t,a,0,0,n))):i?i!==e.memoizedState?(ds(t),fs(t),ms(t,i)):(fs(t),t.flags&=-16777217):((e=e.memoizedProps)!==r&&ds(t),fs(t),bs(t,a,0,0,n)),null;case 27:if(te(t),n=X.current,a=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==r&&ds(t);else{if(!r){if(null===t.stateNode)throw Error(l(166));return fs(t),null}e=G.current,kr(t)?xr(t):(e=Ud(a,r,n),t.stateNode=e,ds(t))}return fs(t),null;case 5:if(te(t),a=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==r&&ds(t);else{if(!r){if(null===t.stateNode)throw Error(l(166));return fs(t),null}if(i=G.current,kr(t))xr(t);else{var o=xd(X.current);switch(i){case 1:i=o.createElementNS("http://www.w3.org/2000/svg",a);break;case 2:i=o.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;default:switch(a){case"svg":i=o.createElementNS("http://www.w3.org/2000/svg",a);break;case"math":i=o.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;case"script":(i=o.createElement("div")).innerHTML="<script><\/script>",i=i.removeChild(i.firstChild);break;case"select":i="string"==typeof r.is?o.createElement("select",{is:r.is}):o.createElement("select"),r.multiple?i.multiple=!0:r.size&&(i.size=r.size);break;default:i="string"==typeof r.is?o.createElement(a,{is:r.is}):o.createElement(a)}}i[Ve]=t,i[He]=r;e:for(o=t.child;null!==o;){if(5===o.tag||6===o.tag)i.appendChild(o.stateNode);else if(4!==o.tag&&27!==o.tag&&null!==o.child){o.child.return=o,o=o.child;continue}if(o===t)break e;for(;null===o.sibling;){if(null===o.return||o.return===t)break e;o=o.return}o.sibling.return=o.return,o=o.sibling}t.stateNode=i;e:switch(fd(i,a,r),a){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}r&&ds(t)}}return fs(t),bs(t,t.type,null===e||e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&null!=t.stateNode)e.memoizedProps!==r&&ds(t);else{if("string"!=typeof r&&null===t.stateNode)throw Error(l(166));if(e=X.current,kr(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,null!==(a=mr))switch(a.tag){case 27:case 5:r=a.memoizedProps}e[Ve]=t,(e=!!(e.nodeValue===n||null!==r&&!0===r.suppressHydrationWarning||md(e.nodeValue,n)))||vr(t,!0)}else(e=xd(e).createTextNode(r))[Ve]=t,t.stateNode=e}return fs(t),null;case 31:if(n=t.memoizedState,null===e||null!==e.memoizedState){if(r=kr(t),null!==n){if(null===e){if(!r)throw Error(l(318));if(!(e=null!==(e=t.memoizedState)?e.dehydrated:null))throw Error(l(557));e[Ve]=t}else Cr(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;fs(t),e=!1}else n=Sr(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return 256&t.flags?(Ba(t),t):(Ba(t),null);if(128&t.flags)throw Error(l(558))}return fs(t),null;case 13:if(r=t.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(a=kr(t),null!==r&&null!==r.dehydrated){if(null===e){if(!a)throw Error(l(318));if(!(a=null!==(a=t.memoizedState)?a.dehydrated:null))throw Error(l(317));a[Ve]=t}else Cr(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;fs(t),a=!1}else a=Sr(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return 256&t.flags?(Ba(t),t):(Ba(t),null)}return Ba(t),128&t.flags?(t.lanes=n,t):(n=null!==r,e=null!==e&&null!==e.memoizedState,n&&(a=null,null!==(r=t.child).alternate&&null!==r.alternate.memoizedState&&null!==r.alternate.memoizedState.cachePool&&(a=r.alternate.memoizedState.cachePool.pool),i=null,null!==r.memoizedState&&null!==r.memoizedState.cachePool&&(i=r.memoizedState.cachePool.pool),i!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),hs(t,t.updateQueue),fs(t),null);case 4:return Z(),null===e&&ld(t.stateNode.containerInfo),fs(t),null;case 10:return Tr(t.type),fs(t),null;case 19:if(q(Wa),null===(r=t.memoizedState))return fs(t),null;if(a=!!(128&t.flags),null===(i=r.rendering))if(a)ps(r,!1);else{if(0!==Ec||null!==e&&128&e.flags)for(e=t.child;null!==e;){if(null!==(i=qa(e))){for(t.flags|=128,ps(r,!1),e=i.updateQueue,t.updateQueue=e,hs(t,e),t.subtreeFlags=0,e=n,n=t.child;null!==n;)Vl(n,e),n=n.sibling;return V(Wa,1&Wa.current|2),pr&&sr(t,r.treeForkCount),t.child}e=e.sibling}null!==r.tail&&be()>Oc&&(t.flags|=128,a=!0,ps(r,!1),t.lanes=4194304)}else{if(!a)if(null!==(e=qa(i))){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,hs(t,e),ps(r,!0),null===r.tail&&"hidden"===r.tailMode&&!i.alternate&&!pr)return fs(t),null}else 2*be()-r.renderingStartTime>Oc&&536870912!==n&&(t.flags|=128,a=!0,ps(r,!1),t.lanes=4194304);r.isBackwards?(i.sibling=t.child,t.child=i):(null!==(e=r.last)?e.sibling=i:t.child=i,r.last=i)}return null!==r.tail?(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=be(),e.sibling=null,n=Wa.current,V(Wa,a?1&n|2:1&n),pr&&sr(t,r.treeForkCount),e):(fs(t),null);case 22:case 23:return Ba(t),Pa(),r=null!==t.memoizedState,null!==e?null!==e.memoizedState!==r&&(t.flags|=8192):r&&(t.flags|=8192),r?!!(536870912&n)&&!(128&t.flags)&&(fs(t),6&t.subtreeFlags&&(t.flags|=8192)):fs(t),null!==(n=t.updateQueue)&&hs(t,n.retryQueue),n=null,null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),r=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),null!==e&&q(Yr),null;case 24:return n=null,null!==e&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Tr(Br),fs(t),null;case 25:case 30:return null}throw Error(l(156,t.tag))}function ys(e,t){switch(dr(t),t.tag){case 1:return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return Tr(Br),Z(),65536&(e=t.flags)&&!(128&e)?(t.flags=-65537&e|128,t):null;case 26:case 27:case 5:return te(t),null;case 31:if(null!==t.memoizedState){if(Ba(t),null===t.alternate)throw Error(l(340));Cr()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 13:if(Ba(t),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(l(340));Cr()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return q(Wa),null;case 4:return Z(),null;case 10:return Tr(t.type),null;case 22:case 23:return Ba(t),Pa(),null!==e&&q(Yr),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 24:return Tr(Br),null;default:return null}}function vs(e,t){switch(dr(t),t.tag){case 3:Tr(Br),Z();break;case 26:case 27:case 5:te(t);break;case 4:Z();break;case 31:null!==t.memoizedState&&Ba(t);break;case 13:Ba(t);break;case 19:q(Wa);break;case 10:Tr(t.type);break;case 22:case 23:Ba(t),Pa(),null!==e&&q(Yr);break;case 24:Tr(Br)}}function xs(e,t){try{var n=t.updateQueue,l=null!==n?n.lastEffect:null;if(null!==l){var r=l.next;n=r;do{if((n.tag&e)===e){l=void 0;var a=n.create,i=n.inst;l=a(),i.destroy=l}n=n.next}while(n!==r)}}catch(o){Eu(t,t.return,o)}}function ws(e,t,n){try{var l=t.updateQueue,r=null!==l?l.lastEffect:null;if(null!==r){var a=r.next;l=a;do{if((l.tag&e)===e){var i=l.inst,o=i.destroy;if(void 0!==o){i.destroy=void 0,r=t;var s=n,c=o;try{c()}catch(u){Eu(r,s,u)}}}l=l.next}while(l!==a)}}catch(u){Eu(t,t.return,u)}}function ks(e){var t=e.updateQueue;if(null!==t){var n=e.stateNode;try{Ta(t,n)}catch(l){Eu(e,e.return,l)}}}function Cs(e,t,n){n.props=Eo(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(l){Eu(e,t,l)}}function Ss(e,t){try{var n=e.ref;if(null!==n){switch(e.tag){case 26:case 27:case 5:var l=e.stateNode;break;default:l=e.stateNode}"function"==typeof n?e.refCleanup=n(l):n.current=l}}catch(r){Eu(e,t,r)}}function js(e,t){var n=e.ref,l=e.refCleanup;if(null!==n)if("function"==typeof l)try{l()}catch(r){Eu(e,t,r)}finally{e.refCleanup=null,null!=(e=e.alternate)&&(e.refCleanup=null)}else if("function"==typeof n)try{n(null)}catch(a){Eu(e,t,a)}else n.current=null}function Ns(e){var t=e.type,n=e.memoizedProps,l=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&l.focus();break e;case"img":n.src?l.src=n.src:n.srcSet&&(l.srcset=n.srcSet)}}catch(r){Eu(e,e.return,r)}}function Es(e,t,n){try{var r=e.stateNode;!function(e,t,n,r){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var a=null,i=null,o=null,s=null,c=null,u=null,d=null;for(h in n){var b=n[h];if(n.hasOwnProperty(h)&&null!=b)switch(h){case"checked":case"value":break;case"defaultValue":c=b;default:r.hasOwnProperty(h)||hd(e,t,h,null,r,b)}}for(var m in r){var h=r[m];if(b=n[m],r.hasOwnProperty(m)&&(null!=h||null!=b))switch(m){case"type":i=h;break;case"name":a=h;break;case"checked":u=h;break;case"defaultChecked":d=h;break;case"value":o=h;break;case"defaultValue":s=h;break;case"children":case"dangerouslySetInnerHTML":if(null!=h)throw Error(l(137,t));break;default:h!==b&&hd(e,t,m,h,r,b)}}return void kt(e,o,s,c,u,d,i,a);case"select":for(i in h=o=s=m=null,n)if(c=n[i],n.hasOwnProperty(i)&&null!=c)switch(i){case"value":break;case"multiple":h=c;default:r.hasOwnProperty(i)||hd(e,t,i,null,r,c)}for(a in r)if(i=r[a],c=n[a],r.hasOwnProperty(a)&&(null!=i||null!=c))switch(a){case"value":m=i;break;case"defaultValue":s=i;break;case"multiple":o=i;default:i!==c&&hd(e,t,a,i,r,c)}return t=s,n=o,r=h,void(null!=m?jt(e,!!n,m,!1):!!r!=!!n&&(null!=t?jt(e,!!n,t,!0):jt(e,!!n,n?[]:"",!1)));case"textarea":for(s in h=m=null,n)if(a=n[s],n.hasOwnProperty(s)&&null!=a&&!r.hasOwnProperty(s))switch(s){case"value":case"children":break;default:hd(e,t,s,null,r,a)}for(o in r)if(a=r[o],i=n[o],r.hasOwnProperty(o)&&(null!=a||null!=i))switch(o){case"value":m=a;break;case"defaultValue":h=a;break;case"children":break;case"dangerouslySetInnerHTML":if(null!=a)throw Error(l(91));break;default:a!==i&&hd(e,t,o,a,r,i)}return void Nt(e,m,h);case"option":for(var p in n)if(m=n[p],n.hasOwnProperty(p)&&null!=m&&!r.hasOwnProperty(p))if("selected"===p)e.selected=!1;else hd(e,t,p,null,r,m);for(c in r)if(m=r[c],h=n[c],r.hasOwnProperty(c)&&m!==h&&(null!=m||null!=h))if("selected"===c)e.selected=m&&"function"!=typeof m&&"symbol"!=typeof m;else hd(e,t,c,m,r,h);return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var f in n)m=n[f],n.hasOwnProperty(f)&&null!=m&&!r.hasOwnProperty(f)&&hd(e,t,f,null,r,m);for(u in r)if(m=r[u],h=n[u],r.hasOwnProperty(u)&&m!==h&&(null!=m||null!=h))switch(u){case"children":case"dangerouslySetInnerHTML":if(null!=m)throw Error(l(137,t));break;default:hd(e,t,u,m,r,h)}return;default:if(Lt(t)){for(var g in n)m=n[g],n.hasOwnProperty(g)&&void 0!==m&&!r.hasOwnProperty(g)&&pd(e,t,g,void 0,r,m);for(d in r)m=r[d],h=n[d],!r.hasOwnProperty(d)||m===h||void 0===m&&void 0===h||pd(e,t,d,m,r,h);return}}for(var y in n)m=n[y],n.hasOwnProperty(y)&&null!=m&&!r.hasOwnProperty(y)&&hd(e,t,y,null,r,m);for(b in r)m=r[b],h=n[b],!r.hasOwnProperty(b)||m===h||null==m&&null==h||hd(e,t,b,m,r,h)}(r,e.type,n,t),r[He]=t}catch(a){Eu(e,e.return,a)}}function $s(e){return 5===e.tag||3===e.tag||26===e.tag||27===e.tag&&Td(e.type)||4===e.tag}function _s(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||$s(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(27===e.tag&&Td(e.type))continue e;if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function Ts(e,t,n){var l=e.tag;if(5===l||6===l)e=e.stateNode,t?(9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).insertBefore(e,t):((t=9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).appendChild(e),null!=(n=n._reactRootContainer)||null!==t.onclick||(t.onclick=It));else if(4!==l&&(27===l&&Td(e.type)&&(n=e.stateNode,t=null),null!==(e=e.child)))for(Ts(e,t,n),e=e.sibling;null!==e;)Ts(e,t,n),e=e.sibling}function zs(e,t,n){var l=e.tag;if(5===l||6===l)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==l&&(27===l&&Td(e.type)&&(n=e.stateNode),null!==(e=e.child)))for(zs(e,t,n),e=e.sibling;null!==e;)zs(e,t,n),e=e.sibling}function Ls(e){var t=e.stateNode,n=e.memoizedProps;try{for(var l=e.type,r=t.attributes;r.length;)t.removeAttributeNode(r[0]);fd(t,l,n),t[Ve]=e,t[He]=n}catch(a){Eu(e,e.return,a)}}var As=!1,Ms=!1,Ps=!1,Is="function"==typeof WeakSet?WeakSet:Set,Ds=null;function Os(e,t,n){var l=n.flags;switch(n.tag){case 0:case 11:case 15:Js(e,n),4&l&&xs(5,n);break;case 1:if(Js(e,n),4&l)if(e=n.stateNode,null===t)try{e.componentDidMount()}catch(i){Eu(n,n.return,i)}else{var r=Eo(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(r,t,e.__reactInternalSnapshotBeforeUpdate)}catch(o){Eu(n,n.return,o)}}64&l&&ks(n),512&l&&Ss(n,n.return);break;case 3:if(Js(e,n),64&l&&null!==(e=n.updateQueue)){if(t=null,null!==n.child)switch(n.child.tag){case 27:case 5:case 1:t=n.child.stateNode}try{Ta(e,t)}catch(i){Eu(n,n.return,i)}}break;case 27:null===t&&4&l&&Ls(n);case 26:case 5:Js(e,n),null===t&&4&l&&Ns(n),512&l&&Ss(n,n.return);break;case 12:Js(e,n);break;case 31:Js(e,n),4&l&&qs(e,n);break;case 13:Js(e,n),4&l&&Vs(e,n),64&l&&(null!==(e=n.memoizedState)&&(null!==(e=e.dehydrated)&&function(e,t){var n=e.ownerDocument;if("$~"===e.data)e._reactRetry=t;else if("$?"!==e.data||"loading"!==n.readyState)t();else{var l=function(){t(),n.removeEventListener("DOMContentLoaded",l)};n.addEventListener("DOMContentLoaded",l),e._reactRetry=l}}(e,n=zu.bind(null,n))));break;case 22:if(!(l=null!==n.memoizedState||As)){t=null!==t&&null!==t.memoizedState||Ms,r=As;var a=Ms;As=l,(Ms=t)&&!a?ec(e,n,!!(8772&n.subtreeFlags)):Js(e,n),As=r,Ms=a}break;case 30:break;default:Js(e,n)}}function Rs(e){var t=e.alternate;null!==t&&(e.alternate=null,Rs(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&(null!==(t=e.stateNode)&&Ze(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var Fs=null,Us=!1;function Bs(e,t,n){for(n=n.child;null!==n;)Ws(e,t,n),n=n.sibling}function Ws(e,t,n){if(ke&&"function"==typeof ke.onCommitFiberUnmount)try{ke.onCommitFiberUnmount(we,n)}catch(a){}switch(n.tag){case 26:Ms||js(n,t),Bs(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode).parentNode.removeChild(n);break;case 27:Ms||js(n,t);var l=Fs,r=Us;Td(n.type)&&(Fs=n.stateNode,Us=!1),Bs(e,t,n),Bd(n.stateNode),Fs=l,Us=r;break;case 5:Ms||js(n,t);case 6:if(l=Fs,r=Us,Fs=null,Bs(e,t,n),Us=r,null!==(Fs=l))if(Us)try{(9===Fs.nodeType?Fs.body:"HTML"===Fs.nodeName?Fs.ownerDocument.body:Fs).removeChild(n.stateNode)}catch(i){Eu(n,t,i)}else try{Fs.removeChild(n.stateNode)}catch(i){Eu(n,t,i)}break;case 18:null!==Fs&&(Us?(zd(9===(e=Fs).nodeType?e.body:"HTML"===e.nodeName?e.ownerDocument.body:e,n.stateNode),Gb(e)):zd(Fs,n.stateNode));break;case 4:l=Fs,r=Us,Fs=n.stateNode.containerInfo,Us=!0,Bs(e,t,n),Fs=l,Us=r;break;case 0:case 11:case 14:case 15:ws(2,n,t),Ms||ws(4,n,t),Bs(e,t,n);break;case 1:Ms||(js(n,t),"function"==typeof(l=n.stateNode).componentWillUnmount&&Cs(n,t,l)),Bs(e,t,n);break;case 21:Bs(e,t,n);break;case 22:Ms=(l=Ms)||null!==n.memoizedState,Bs(e,t,n),Ms=l;break;default:Bs(e,t,n)}}function qs(e,t){if(null===t.memoizedState&&(null!==(e=t.alternate)&&null!==(e=e.memoizedState))){e=e.dehydrated;try{Gb(e)}catch(n){Eu(t,t.return,n)}}}function Vs(e,t){if(null===t.memoizedState&&(null!==(e=t.alternate)&&(null!==(e=e.memoizedState)&&null!==(e=e.dehydrated))))try{Gb(e)}catch(n){Eu(t,t.return,n)}}function Hs(e,t){var n=function(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return null===t&&(t=e.stateNode=new Is),t;case 22:return null===(t=(e=e.stateNode)._retryCache)&&(t=e._retryCache=new Is),t;default:throw Error(l(435,e.tag))}}(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var l=Lu.bind(null,e,t);t.then(l,l)}})}function Ks(e,t){var n=t.deletions;if(null!==n)for(var r=0;r<n.length;r++){var a=n[r],i=e,o=t,s=o;e:for(;null!==s;){switch(s.tag){case 27:if(Td(s.type)){Fs=s.stateNode,Us=!1;break e}break;case 5:Fs=s.stateNode,Us=!1;break e;case 3:case 4:Fs=s.stateNode.containerInfo,Us=!0;break e}s=s.return}if(null===Fs)throw Error(l(160));Ws(i,o,a),Fs=null,Us=!1,null!==(i=a.alternate)&&(i.return=null),a.return=null}if(13886&t.subtreeFlags)for(t=t.child;null!==t;)Qs(t,e),t=t.sibling}var Gs=null;function Qs(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Ks(t,e),Xs(e),4&r&&(ws(3,e,e.return),xs(3,e),ws(5,e,e.return));break;case 1:Ks(t,e),Xs(e),512&r&&(Ms||null===n||js(n,n.return)),64&r&&As&&(null!==(e=e.updateQueue)&&(null!==(r=e.callbacks)&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=null===n?r:n.concat(r))));break;case 26:var a=Gs;if(Ks(t,e),Xs(e),512&r&&(Ms||null===n||js(n,n.return)),4&r){var i=null!==n?n.memoizedState:null;if(r=e.memoizedState,null===n)if(null===r)if(null===e.stateNode){e:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;t:switch(r){case"title":(!(i=a.getElementsByTagName("title")[0])||i[Je]||i[Ve]||"http://www.w3.org/2000/svg"===i.namespaceURI||i.hasAttribute("itemprop"))&&(i=a.createElement(r),a.head.insertBefore(i,a.querySelector("head > title"))),fd(i,r,n),i[Ve]=e,rt(i),r=i;break e;case"link":var o=ib("link","href",a).get(r+(n.href||""));if(o)for(var s=0;s<o.length;s++)if((i=o[s]).getAttribute("href")===(null==n.href||""===n.href?null:n.href)&&i.getAttribute("rel")===(null==n.rel?null:n.rel)&&i.getAttribute("title")===(null==n.title?null:n.title)&&i.getAttribute("crossorigin")===(null==n.crossOrigin?null:n.crossOrigin)){o.splice(s,1);break t}fd(i=a.createElement(r),r,n),a.head.appendChild(i);break;case"meta":if(o=ib("meta","content",a).get(r+(n.content||"")))for(s=0;s<o.length;s++)if((i=o[s]).getAttribute("content")===(null==n.content?null:""+n.content)&&i.getAttribute("name")===(null==n.name?null:n.name)&&i.getAttribute("property")===(null==n.property?null:n.property)&&i.getAttribute("http-equiv")===(null==n.httpEquiv?null:n.httpEquiv)&&i.getAttribute("charset")===(null==n.charSet?null:n.charSet)){o.splice(s,1);break t}fd(i=a.createElement(r),r,n),a.head.appendChild(i);break;default:throw Error(l(468,r))}i[Ve]=e,rt(i),r=i}e.stateNode=r}else ob(a,e.type,e.stateNode);else e.stateNode=tb(a,r,e.memoizedProps);else i!==r?(null===i?null!==n.stateNode&&(n=n.stateNode).parentNode.removeChild(n):i.count--,null===r?ob(a,e.type,e.stateNode):tb(a,r,e.memoizedProps)):null===r&&null!==e.stateNode&&Es(e,e.memoizedProps,n.memoizedProps)}break;case 27:Ks(t,e),Xs(e),512&r&&(Ms||null===n||js(n,n.return)),null!==n&&4&r&&Es(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Ks(t,e),Xs(e),512&r&&(Ms||null===n||js(n,n.return)),32&e.flags){a=e.stateNode;try{$t(a,"")}catch(p){Eu(e,e.return,p)}}4&r&&null!=e.stateNode&&Es(e,a=e.memoizedProps,null!==n?n.memoizedProps:a),1024&r&&(Ps=!0);break;case 6:if(Ks(t,e),Xs(e),4&r){if(null===e.stateNode)throw Error(l(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(p){Eu(e,e.return,p)}}break;case 3:if(ab=null,a=Gs,Gs=Vd(t.containerInfo),Ks(t,e),Gs=a,Xs(e),4&r&&null!==n&&n.memoizedState.isDehydrated)try{Gb(t.containerInfo)}catch(p){Eu(e,e.return,p)}Ps&&(Ps=!1,Ys(e));break;case 4:r=Gs,Gs=Vd(e.stateNode.containerInfo),Ks(t,e),Xs(e),Gs=r;break;case 12:default:Ks(t,e),Xs(e);break;case 31:case 19:Ks(t,e),Xs(e),4&r&&(null!==(r=e.updateQueue)&&(e.updateQueue=null,Hs(e,r)));break;case 13:Ks(t,e),Xs(e),8192&e.child.flags&&null!==e.memoizedState!=(null!==n&&null!==n.memoizedState)&&(Ic=be()),4&r&&(null!==(r=e.updateQueue)&&(e.updateQueue=null,Hs(e,r)));break;case 22:a=null!==e.memoizedState;var c=null!==n&&null!==n.memoizedState,u=As,d=Ms;if(As=u||a,Ms=d||c,Ks(t,e),Ms=d,As=u,Xs(e),8192&r)e:for(t=e.stateNode,t._visibility=a?-2&t._visibility:1|t._visibility,a&&(null===n||c||As||Ms||Zs(e)),n=null,t=e;;){if(5===t.tag||26===t.tag){if(null===n){c=n=t;try{if(i=c.stateNode,a)"function"==typeof(o=i.style).setProperty?o.setProperty("display","none","important"):o.display="none";else{s=c.stateNode;var b=c.memoizedProps.style,m=null!=b&&b.hasOwnProperty("display")?b.display:null;s.style.display=null==m||"boolean"==typeof m?"":(""+m).trim()}}catch(p){Eu(c,c.return,p)}}}else if(6===t.tag){if(null===n){c=t;try{c.stateNode.nodeValue=a?"":c.memoizedProps}catch(p){Eu(c,c.return,p)}}}else if(18===t.tag){if(null===n){c=t;try{var h=c.stateNode;a?Ld(h,!0):Ld(c.stateNode,!1)}catch(p){Eu(c,c.return,p)}}}else if((22!==t.tag&&23!==t.tag||null===t.memoizedState||t===e)&&null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;null===t.sibling;){if(null===t.return||t.return===e)break e;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}4&r&&(null!==(r=e.updateQueue)&&(null!==(n=r.retryQueue)&&(r.retryQueue=null,Hs(e,n))));case 30:case 21:}}function Xs(e){var t=e.flags;if(2&t){try{for(var n,r=e.return;null!==r;){if($s(r)){n=r;break}r=r.return}if(null==n)throw Error(l(160));switch(n.tag){case 27:var a=n.stateNode;zs(e,_s(e),a);break;case 5:var i=n.stateNode;32&n.flags&&($t(i,""),n.flags&=-33),zs(e,_s(e),i);break;case 3:case 4:var o=n.stateNode.containerInfo;Ts(e,_s(e),o);break;default:throw Error(l(161))}}catch(s){Eu(e,e.return,s)}e.flags&=-3}4096&t&&(e.flags&=-4097)}function Ys(e){if(1024&e.subtreeFlags)for(e=e.child;null!==e;){var t=e;Ys(t),5===t.tag&&1024&t.flags&&t.stateNode.reset(),e=e.sibling}}function Js(e,t){if(8772&t.subtreeFlags)for(t=t.child;null!==t;)Os(e,t.alternate,t),t=t.sibling}function Zs(e){for(e=e.child;null!==e;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:ws(4,t,t.return),Zs(t);break;case 1:js(t,t.return);var n=t.stateNode;"function"==typeof n.componentWillUnmount&&Cs(t,t.return,n),Zs(t);break;case 27:Bd(t.stateNode);case 26:case 5:js(t,t.return),Zs(t);break;case 22:null===t.memoizedState&&Zs(t);break;default:Zs(t)}e=e.sibling}}function ec(e,t,n){for(n=n&&!!(8772&t.subtreeFlags),t=t.child;null!==t;){var l=t.alternate,r=e,a=t,i=a.flags;switch(a.tag){case 0:case 11:case 15:ec(r,a,n),xs(4,a);break;case 1:if(ec(r,a,n),"function"==typeof(r=(l=a).stateNode).componentDidMount)try{r.componentDidMount()}catch(c){Eu(l,l.return,c)}if(null!==(r=(l=a).updateQueue)){var o=l.stateNode;try{var s=r.shared.hiddenCallbacks;if(null!==s)for(r.shared.hiddenCallbacks=null,r=0;r<s.length;r++)_a(s[r],o)}catch(c){Eu(l,l.return,c)}}n&&64&i&&ks(a),Ss(a,a.return);break;case 27:Ls(a);case 26:case 5:ec(r,a,n),n&&null===l&&4&i&&Ns(a),Ss(a,a.return);break;case 12:ec(r,a,n);break;case 31:ec(r,a,n),n&&4&i&&qs(r,a);break;case 13:ec(r,a,n),n&&4&i&&Vs(r,a);break;case 22:null===a.memoizedState&&ec(r,a,n),Ss(a,a.return);break;case 30:break;default:ec(r,a,n)}t=t.sibling}}function tc(e,t){var n=null;null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),e=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(e=t.memoizedState.cachePool.pool),e!==n&&(null!=e&&e.refCount++,null!=n&&qr(n))}function nc(e,t){e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&qr(e))}function lc(e,t,n,l){if(10256&t.subtreeFlags)for(t=t.child;null!==t;)rc(e,t,n,l),t=t.sibling}function rc(e,t,n,l){var r=t.flags;switch(t.tag){case 0:case 11:case 15:lc(e,t,n,l),2048&r&&xs(9,t);break;case 1:case 31:case 13:default:lc(e,t,n,l);break;case 3:lc(e,t,n,l),2048&r&&(e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&qr(e)));break;case 12:if(2048&r){lc(e,t,n,l),e=t.stateNode;try{var a=t.memoizedProps,i=a.id,o=a.onPostCommit;"function"==typeof o&&o(i,null===t.alternate?"mount":"update",e.passiveEffectDuration,-0)}catch(s){Eu(t,t.return,s)}}else lc(e,t,n,l);break;case 23:break;case 22:a=t.stateNode,i=t.alternate,null!==t.memoizedState?2&a._visibility?lc(e,t,n,l):ic(e,t):2&a._visibility?lc(e,t,n,l):(a._visibility|=2,ac(e,t,n,l,!!(10256&t.subtreeFlags)||!1)),2048&r&&tc(i,t);break;case 24:lc(e,t,n,l),2048&r&&nc(t.alternate,t)}}function ac(e,t,n,l,r){for(r=r&&(!!(10256&t.subtreeFlags)||!1),t=t.child;null!==t;){var a=e,i=t,o=n,s=l,c=i.flags;switch(i.tag){case 0:case 11:case 15:ac(a,i,o,s,r),xs(8,i);break;case 23:break;case 22:var u=i.stateNode;null!==i.memoizedState?2&u._visibility?ac(a,i,o,s,r):ic(a,i):(u._visibility|=2,ac(a,i,o,s,r)),r&&2048&c&&tc(i.alternate,i);break;case 24:ac(a,i,o,s,r),r&&2048&c&&nc(i.alternate,i);break;default:ac(a,i,o,s,r)}t=t.sibling}}function ic(e,t){if(10256&t.subtreeFlags)for(t=t.child;null!==t;){var n=e,l=t,r=l.flags;switch(l.tag){case 22:ic(n,l),2048&r&&tc(l.alternate,l);break;case 24:ic(n,l),2048&r&&nc(l.alternate,l);break;default:ic(n,l)}t=t.sibling}}var oc=8192;function sc(e,t,n){if(e.subtreeFlags&oc)for(e=e.child;null!==e;)cc(e,t,n),e=e.sibling}function cc(e,t,n){switch(e.tag){case 26:sc(e,t,n),e.flags&oc&&null!==e.memoizedState&&function(e,t,n,l){if(!("stylesheet"!==n.type||"string"==typeof l.media&&!1===matchMedia(l.media).matches||4&n.state.loading)){if(null===n.instance){var r=Xd(l.href),a=t.querySelector(Yd(r));if(a)return null!==(t=a._p)&&"object"==typeof t&&"function"==typeof t.then&&(e.count++,e=ub.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,void rt(a);a=t.ownerDocument||t,l=Jd(l),(r=Wd.get(r))&&lb(l,r),rt(a=a.createElement("link"));var i=a;i._p=new Promise(function(e,t){i.onload=e,i.onerror=t}),fd(a,"link",l),n.instance=a}null===e.stylesheets&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(3&n.state.loading)&&(e.count++,n=ub.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}(n,Gs,e.memoizedState,e.memoizedProps);break;case 5:default:sc(e,t,n);break;case 3:case 4:var l=Gs;Gs=Vd(e.stateNode.containerInfo),sc(e,t,n),Gs=l;break;case 22:null===e.memoizedState&&(null!==(l=e.alternate)&&null!==l.memoizedState?(l=oc,oc=16777216,sc(e,t,n),oc=l):sc(e,t,n))}}function uc(e){var t=e.alternate;if(null!==t&&null!==(e=t.child)){t.child=null;do{t=e.sibling,e.sibling=null,e=t}while(null!==e)}}function dc(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var n=0;n<t.length;n++){var l=t[n];Ds=l,hc(l,e)}uc(e)}if(10256&e.subtreeFlags)for(e=e.child;null!==e;)bc(e),e=e.sibling}function bc(e){switch(e.tag){case 0:case 11:case 15:dc(e),2048&e.flags&&ws(9,e,e.return);break;case 3:case 12:default:dc(e);break;case 22:var t=e.stateNode;null!==e.memoizedState&&2&t._visibility&&(null===e.return||13!==e.return.tag)?(t._visibility&=-3,mc(e)):dc(e)}}function mc(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var n=0;n<t.length;n++){var l=t[n];Ds=l,hc(l,e)}uc(e)}for(e=e.child;null!==e;){switch((t=e).tag){case 0:case 11:case 15:ws(8,t,t.return),mc(t);break;case 22:2&(n=t.stateNode)._visibility&&(n._visibility&=-3,mc(t));break;default:mc(t)}e=e.sibling}}function hc(e,t){for(;null!==Ds;){var n=Ds;switch(n.tag){case 0:case 11:case 15:ws(8,n,t);break;case 23:case 22:if(null!==n.memoizedState&&null!==n.memoizedState.cachePool){var l=n.memoizedState.cachePool.pool;null!=l&&l.refCount++}break;case 24:qr(n.memoizedState.cache)}if(null!==(l=n.child))l.return=n,Ds=l;else e:for(n=e;null!==Ds;){var r=(l=Ds).sibling,a=l.return;if(Rs(l),l===n){Ds=null;break e}if(null!==r){r.return=a,Ds=r;break e}Ds=a}}}var pc={getCacheForType:function(e){var t=Ir(Br),n=t.data.get(e);return void 0===n&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Ir(Br).controller.signal}},fc="function"==typeof WeakMap?WeakMap:Map,gc=0,yc=null,vc=null,xc=0,wc=0,kc=null,Cc=!1,Sc=!1,jc=!1,Nc=0,Ec=0,$c=0,_c=0,Tc=0,zc=0,Lc=0,Ac=null,Mc=null,Pc=!1,Ic=0,Dc=0,Oc=1/0,Rc=null,Fc=null,Uc=0,Bc=null,Wc=null,qc=0,Vc=0,Hc=null,Kc=null,Gc=0,Qc=null;function Xc(){return 2&gc&&0!==xc?xc&-xc:null!==O.T?Hu():Be()}function Yc(){if(0===zc)if(536870912&xc&&!pr)zc=536870912;else{var e=$e;!(3932160&($e<<=1))&&($e=262144),zc=e}return null!==(e=Ia.current)&&(e.flags|=32),zc}function Jc(e,t,n){(e!==yc||2!==wc&&9!==wc)&&null===e.cancelPendingCommit||(au(e,0),nu(e,xc,zc,!1)),Ie(e,n),2&gc&&e===yc||(e===yc&&(!(2&gc)&&(_c|=n),4===Ec&&nu(e,xc,zc,!1)),Ru(e))}function Zc(e,t,n){if(6&gc)throw Error(l(327));for(var r=!n&&!(127&t)&&0===(t&e.expiredLanes)||Le(e,t),a=r?function(e,t){var n=gc;gc|=2;var r=su(),a=cu();yc!==e||xc!==t?(Rc=null,Oc=be()+500,au(e,t)):Sc=Le(e,t);e:for(;;)try{if(0!==wc&&null!==vc){t=vc;var i=kc;t:switch(wc){case 1:wc=0,kc=null,fu(e,t,i,1);break;case 2:case 9:if(aa(i)){wc=0,kc=null,pu(t);break}t=function(){2!==wc&&9!==wc||yc!==e||(wc=7),Ru(e)},i.then(t,t);break e;case 3:wc=7;break e;case 4:wc=5;break e;case 7:aa(i)?(wc=0,kc=null,pu(t)):(wc=0,kc=null,fu(e,t,i,7));break;case 5:var o=null;switch(vc.tag){case 26:o=vc.memoizedState;case 5:case 27:var s=vc;if(o?sb(o):s.stateNode.complete){wc=0,kc=null;var c=s.sibling;if(null!==c)vc=c;else{var u=s.return;null!==u?(vc=u,gu(u)):vc=null}break t}}wc=0,kc=null,fu(e,t,i,5);break;case 6:wc=0,kc=null,fu(e,t,i,6);break;case 8:ru(),Ec=6;break e;default:throw Error(l(462))}}mu();break}catch(d){iu(e,d)}return $r=Er=null,O.H=r,O.A=a,gc=n,null!==vc?0:(yc=null,xc=0,Ml(),Ec)}(e,t):du(e,t,!0),i=r;;){if(0===a){Sc&&!r&&nu(e,t,0,!1);break}if(n=e.current.alternate,!i||tu(n)){if(2===a){if(i=t,e.errorRecoveryDisabledLanes&i)var o=0;else o=0!==(o=-536870913&e.pendingLanes)?o:536870912&o?536870912:0;if(0!==o){t=o;e:{var s=e;a=Ac;var c=s.current.memoizedState.isDehydrated;if(c&&(au(s,o).flags|=256),2!==(o=du(s,o,!1))){if(jc&&!c){s.errorRecoveryDisabledLanes|=i,_c|=i,a=4;break e}i=Mc,Mc=a,null!==i&&(null===Mc?Mc=i:Mc.push.apply(Mc,i))}a=o}if(i=!1,2!==a)continue}}if(1===a){au(e,0),nu(e,t,0,!0);break}e:{switch(r=e,i=a){case 0:case 1:throw Error(l(345));case 4:if((4194048&t)!==t)break;case 6:nu(r,t,zc,!Cc);break e;case 2:Mc=null;break;case 3:case 5:break;default:throw Error(l(329))}if((62914560&t)===t&&10<(a=Ic+300-be())){if(nu(r,t,zc,!Cc),0!==ze(r,0,!0))break e;qc=t,r.timeoutHandle=jd(eu.bind(null,r,n,Mc,Rc,Pc,t,zc,_c,Lc,Cc,i,"Throttled",-0,0),a)}else eu(r,n,Mc,Rc,Pc,t,zc,_c,Lc,Cc,i,null,-0,0)}break}a=du(e,t,!1),i=!1}Ru(e)}function eu(e,t,n,l,r,a,i,o,s,c,u,d,b,m){if(e.timeoutHandle=-1,8192&(d=t.subtreeFlags)||!(16785408&~d)){cc(t,a,d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:It});var h=(62914560&a)===a?Ic-be():(4194048&a)===a?Dc-be():0;if(null!==(h=function(e,t){return e.stylesheets&&0===e.count&&bb(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var l=setTimeout(function(){if(e.stylesheets&&bb(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&0===cb&&(cb=62500*function(){if("function"==typeof performance.getEntriesByType){for(var e=0,t=0,n=performance.getEntriesByType("resource"),l=0;l<n.length;l++){var r=n[l],a=r.transferSize,i=r.initiatorType,o=r.duration;if(a&&o&&gd(i)){for(i=0,o=r.responseEnd,l+=1;l<n.length;l++){var s=n[l],c=s.startTime;if(c>o)break;var u=s.transferSize,d=s.initiatorType;u&&gd(d)&&(i+=u*((s=s.responseEnd)<o?1:(o-c)/(s-c)))}if(--l,t+=8*(a+i)/(r.duration/1e3),10<++e)break}}if(0<e)return t/e/1e6}return navigator.connection&&"number"==typeof(e=navigator.connection.downlink)?e:5}());var r=setTimeout(function(){if(e.waitingForImages=!1,0===e.count&&(e.stylesheets&&bb(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>cb?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(l),clearTimeout(r)}}:null}(d,h)))return qc=a,e.cancelPendingCommit=h(vu.bind(null,e,t,a,n,l,r,i,o,s,u,d,null,b,m)),void nu(e,a,i,!c)}vu(e,t,a,n,l,r,i,o,s)}function tu(e){for(var t=e;;){var n=t.tag;if((0===n||11===n||15===n)&&16384&t.flags&&(null!==(n=t.updateQueue)&&null!==(n=n.stores)))for(var l=0;l<n.length;l++){var r=n[l],a=r.getSnapshot;r=r.value;try{if(!nl(a(),r))return!1}catch(i){return!1}}if(n=t.child,16384&t.subtreeFlags&&null!==n)n.return=t,t=n;else{if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function nu(e,t,n,l){t&=~Tc,t&=~_c,e.suspendedLanes|=t,e.pingedLanes&=~t,l&&(e.warmLanes|=t),l=e.expirationTimes;for(var r=t;0<r;){var a=31-Se(r),i=1<<a;l[a]=-1,r&=~i}0!==n&&De(e,n,t)}function lu(){return!!(6&gc)||(Fu(0),!1)}function ru(){if(null!==vc){if(0===wc)var e=vc.return;else $r=Er=null,ui(e=vc),da=null,ba=0,e=vc;for(;null!==e;)vs(e.alternate,e),e=e.return;vc=null}}function au(e,t){var n=e.timeoutHandle;-1!==n&&(e.timeoutHandle=-1,Nd(n)),null!==(n=e.cancelPendingCommit)&&(e.cancelPendingCommit=null,n()),qc=0,ru(),yc=e,vc=n=ql(e.current,null),xc=t,wc=0,kc=null,Cc=!1,Sc=Le(e,t),jc=!1,Lc=zc=Tc=_c=$c=Ec=0,Mc=Ac=null,Pc=!1,8&t&&(t|=32&t);var l=e.entangledLanes;if(0!==l)for(e=e.entanglements,l&=t;0<l;){var r=31-Se(l),a=1<<r;t|=e[r],l&=~a}return Nc=t,Ml(),n}function iu(e,t){Ha=null,O.H=vo,t===ta||t===la?(t=ca(),wc=3):t===na?(t=ca(),wc=4):wc=t===Io?8:null!==t&&"object"==typeof t&&"function"==typeof t.then?6:1,kc=t,null===vc&&(Ec=1,zo(e,Jl(t,e.current)))}function ou(){var e=Ia.current;return null===e||((4194048&xc)===xc?null===Da:!!((62914560&xc)===xc||536870912&xc)&&e===Da)}function su(){var e=O.H;return O.H=vo,null===e?vo:e}function cu(){var e=O.A;return O.A=pc,e}function uu(){Ec=4,Cc||(4194048&xc)!==xc&&null!==Ia.current||(Sc=!0),!(134217727&$c)&&!(134217727&_c)||null===yc||nu(yc,xc,zc,!1)}function du(e,t,n){var l=gc;gc|=2;var r=su(),a=cu();yc===e&&xc===t||(Rc=null,au(e,t)),t=!1;var i=Ec;e:for(;;)try{if(0!==wc&&null!==vc){var o=vc,s=kc;switch(wc){case 8:ru(),i=6;break e;case 3:case 2:case 9:case 6:null===Ia.current&&(t=!0);var c=wc;if(wc=0,kc=null,fu(e,o,s,c),n&&Sc){i=0;break e}break;default:c=wc,wc=0,kc=null,fu(e,o,s,c)}}bu(),i=Ec;break}catch(u){iu(e,u)}return t&&e.shellSuspendCounter++,$r=Er=null,gc=l,O.H=r,O.A=a,null===vc&&(yc=null,xc=0,Ml()),i}function bu(){for(;null!==vc;)hu(vc)}function mu(){for(;null!==vc&&!ue();)hu(vc)}function hu(e){var t=us(e.alternate,e,Nc);e.memoizedProps=e.pendingProps,null===t?gu(e):vc=t}function pu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Qo(n,t,t.pendingProps,t.type,void 0,xc);break;case 11:t=Qo(n,t,t.pendingProps,t.type.render,t.ref,xc);break;case 5:ui(t);default:vs(n,t),t=us(n,t=vc=Vl(t,Nc),Nc)}e.memoizedProps=e.pendingProps,null===t?gu(e):vc=t}function fu(e,t,n,r){$r=Er=null,ui(t),da=null,ba=0;var a=t.return;try{if(function(e,t,n,r,a){if(n.flags|=32768,null!==r&&"object"==typeof r&&"function"==typeof r.then){if(null!==(t=n.alternate)&&Ar(t,n,a,!0),null!==(n=Ia.current)){switch(n.tag){case 31:case 13:return null===Da?uu():null===n.alternate&&0===Ec&&(Ec=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===ra?n.flags|=16384:(null===(t=n.updateQueue)?n.updateQueue=new Set([r]):t.add(r),$u(e,r,a)),!1;case 22:return n.flags|=65536,r===ra?n.flags|=16384:(null===(t=n.updateQueue)?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):null===(n=t.retryQueue)?t.retryQueue=new Set([r]):n.add(r),$u(e,r,a)),!1}throw Error(l(435,n.tag))}return $u(e,r,a),uu(),!1}if(pr)return null!==(t=Ia.current)?(!(65536&t.flags)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==yr&&jr(Jl(e=Error(l(422),{cause:r}),n))):(r!==yr&&jr(Jl(t=Error(l(423),{cause:r}),n)),(e=e.current.alternate).flags|=65536,a&=-a,e.lanes|=a,r=Jl(r,n),ja(e,a=Ao(e.stateNode,r,a)),4!==Ec&&(Ec=2)),!1;var i=Error(l(520),{cause:r});if(i=Jl(i,n),null===Ac?Ac=[i]:Ac.push(i),4!==Ec&&(Ec=2),null===t)return!0;r=Jl(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,ja(n,e=Ao(n.stateNode,r,e)),!1;case 1:if(t=n.type,i=n.stateNode,!(128&n.flags||"function"!=typeof t.getDerivedStateFromError&&(null===i||"function"!=typeof i.componentDidCatch||null!==Fc&&Fc.has(i))))return n.flags|=65536,a&=-a,n.lanes|=a,Po(a=Mo(a),e,n,r),ja(n,a),!1}n=n.return}while(null!==n);return!1}(e,a,t,n,xc))return Ec=1,zo(e,Jl(n,e.current)),void(vc=null)}catch(i){if(null!==a)throw vc=a,i;return Ec=1,zo(e,Jl(n,e.current)),void(vc=null)}32768&t.flags?(pr||1===r?e=!0:Sc||536870912&xc?e=!1:(Cc=e=!0,(2===r||9===r||3===r||6===r)&&(null!==(r=Ia.current)&&13===r.tag&&(r.flags|=16384))),yu(t,e)):gu(t)}function gu(e){var t=e;do{if(32768&t.flags)return void yu(t,Cc);e=t.return;var n=gs(t.alternate,t,Nc);if(null!==n)return void(vc=n);if(null!==(t=t.sibling))return void(vc=t);vc=t=e}while(null!==t);0===Ec&&(Ec=5)}function yu(e,t){do{var n=ys(e.alternate,e);if(null!==n)return n.flags&=32767,void(vc=n);if(null!==(n=e.return)&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&null!==(e=e.sibling))return void(vc=e);vc=e=n}while(null!==e);Ec=6,vc=null}function vu(e,t,n,r,a,i,o,s,c){e.cancelPendingCommit=null;do{Su()}while(0!==Uc);if(6&gc)throw Error(l(327));if(null!==t){if(t===e.current)throw Error(l(177));if(i=t.lanes|t.childLanes,function(e,t,n,l,r,a){var i=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var o=e.entanglements,s=e.expirationTimes,c=e.hiddenUpdates;for(n=i&~n;0<n;){var u=31-Se(n),d=1<<u;o[u]=0,s[u]=-1;var b=c[u];if(null!==b)for(c[u]=null,u=0;u<b.length;u++){var m=b[u];null!==m&&(m.lane&=-536870913)}n&=~d}0!==l&&De(e,l,0),0!==a&&0===r&&0!==e.tag&&(e.suspendedLanes|=a&~(i&~t))}(e,n,i|=Al,o,s,c),e===yc&&(vc=yc=null,xc=0),Wc=t,Bc=e,qc=n,Vc=i,Hc=a,Kc=r,10256&t.subtreeFlags||10256&t.flags?(e.callbackNode=null,e.callbackPriority=0,se(fe,function(){return ju(),null})):(e.callbackNode=null,e.callbackPriority=0),r=!!(13878&t.flags),13878&t.subtreeFlags||r){r=O.T,O.T=null,a=R.p,R.p=2,o=gc,gc|=4;try{!function(e,t){if(e=e.containerInfo,yd=Cb,sl(e=ol(e))){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{var r=(n=(n=e.ownerDocument)&&n.defaultView||window).getSelection&&n.getSelection();if(r&&0!==r.rangeCount){n=r.anchorNode;var a=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch(f){n=null;break e}var o=0,s=-1,c=-1,u=0,d=0,b=e,m=null;t:for(;;){for(var h;b!==n||0!==a&&3!==b.nodeType||(s=o+a),b!==i||0!==r&&3!==b.nodeType||(c=o+r),3===b.nodeType&&(o+=b.nodeValue.length),null!==(h=b.firstChild);)m=b,b=h;for(;;){if(b===e)break t;if(m===n&&++u===a&&(s=o),m===i&&++d===r&&(c=o),null!==(h=b.nextSibling))break;m=(b=m).parentNode}b=h}n=-1===s||-1===c?null:{start:s,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(vd={focusedElem:e,selectionRange:n},Cb=!1,Ds=t;null!==Ds;)if(e=(t=Ds).child,1028&t.subtreeFlags&&null!==e)e.return=t,Ds=e;else for(;null!==Ds;){switch(i=(t=Ds).alternate,e=t.flags,t.tag){case 0:if(4&e&&null!==(e=null!==(e=t.updateQueue)?e.events:null))for(n=0;n<e.length;n++)(a=e[n]).ref.impl=a.nextImpl;break;case 11:case 15:case 5:case 26:case 27:case 6:case 4:case 17:break;case 1:if(1024&e&&null!==i){e=void 0,n=t,a=i.memoizedProps,i=i.memoizedState,r=n.stateNode;try{var p=Eo(n.type,a);e=r.getSnapshotBeforeUpdate(p,i),r.__reactInternalSnapshotBeforeUpdate=e}catch(g){Eu(n,n.return,g)}}break;case 3:if(1024&e)if(9===(n=(e=t.stateNode.containerInfo).nodeType))Ad(e);else if(1===n)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Ad(e);break;default:e.textContent=""}break;default:if(1024&e)throw Error(l(163))}if(null!==(e=t.sibling)){e.return=t.return,Ds=e;break}Ds=t.return}}(e,t)}finally{gc=o,R.p=a,O.T=r}}Uc=1,xu(),wu(),ku()}}function xu(){if(1===Uc){Uc=0;var e=Bc,t=Wc,n=!!(13878&t.flags);if(13878&t.subtreeFlags||n){n=O.T,O.T=null;var l=R.p;R.p=2;var r=gc;gc|=4;try{Qs(t,e);var a=vd,i=ol(e.containerInfo),o=a.focusedElem,s=a.selectionRange;if(i!==o&&o&&o.ownerDocument&&il(o.ownerDocument.documentElement,o)){if(null!==s&&sl(o)){var c=s.start,u=s.end;if(void 0===u&&(u=c),"selectionStart"in o)o.selectionStart=c,o.selectionEnd=Math.min(u,o.value.length);else{var d=o.ownerDocument||document,b=d&&d.defaultView||window;if(b.getSelection){var m=b.getSelection(),h=o.textContent.length,p=Math.min(s.start,h),f=void 0===s.end?p:Math.min(s.end,h);!m.extend&&p>f&&(i=f,f=p,p=i);var g=al(o,p),y=al(o,f);if(g&&y&&(1!==m.rangeCount||m.anchorNode!==g.node||m.anchorOffset!==g.offset||m.focusNode!==y.node||m.focusOffset!==y.offset)){var v=d.createRange();v.setStart(g.node,g.offset),m.removeAllRanges(),p>f?(m.addRange(v),m.extend(y.node,y.offset)):(v.setEnd(y.node,y.offset),m.addRange(v))}}}}for(d=[],m=o;m=m.parentNode;)1===m.nodeType&&d.push({element:m,left:m.scrollLeft,top:m.scrollTop});for("function"==typeof o.focus&&o.focus(),o=0;o<d.length;o++){var x=d[o];x.element.scrollLeft=x.left,x.element.scrollTop=x.top}}Cb=!!yd,vd=yd=null}finally{gc=r,R.p=l,O.T=n}}e.current=t,Uc=2}}function wu(){if(2===Uc){Uc=0;var e=Bc,t=Wc,n=!!(8772&t.flags);if(8772&t.subtreeFlags||n){n=O.T,O.T=null;var l=R.p;R.p=2;var r=gc;gc|=4;try{Os(e,t.alternate,t)}finally{gc=r,R.p=l,O.T=n}}Uc=3}}function ku(){if(4===Uc||3===Uc){Uc=0,de();var e=Bc,t=Wc,n=qc,l=Kc;10256&t.subtreeFlags||10256&t.flags?Uc=5:(Uc=0,Wc=Bc=null,Cu(e,e.pendingLanes));var r=e.pendingLanes;if(0===r&&(Fc=null),Ue(n),t=t.stateNode,ke&&"function"==typeof ke.onCommitFiberRoot)try{ke.onCommitFiberRoot(we,t,void 0,!(128&~t.current.flags))}catch(s){}if(null!==l){t=O.T,r=R.p,R.p=2,O.T=null;try{for(var a=e.onRecoverableError,i=0;i<l.length;i++){var o=l[i];a(o.value,{componentStack:o.stack})}}finally{O.T=t,R.p=r}}3&qc&&Su(),Ru(e),r=e.pendingLanes,261930&n&&42&r?e===Qc?Gc++:(Gc=0,Qc=e):Gc=0,Fu(0)}}function Cu(e,t){0===(e.pooledCacheLanes&=t)&&(null!=(t=e.pooledCache)&&(e.pooledCache=null,qr(t)))}function Su(){return xu(),wu(),ku(),ju()}function ju(){if(5!==Uc)return!1;var e=Bc,t=Vc;Vc=0;var n=Ue(qc),r=O.T,a=R.p;try{R.p=32>n?32:n,O.T=null,n=Hc,Hc=null;var i=Bc,o=qc;if(Uc=0,Wc=Bc=null,qc=0,6&gc)throw Error(l(331));var s=gc;if(gc|=4,bc(i.current),rc(i,i.current,o,n),gc=s,Fu(0,!1),ke&&"function"==typeof ke.onPostCommitFiberRoot)try{ke.onPostCommitFiberRoot(we,i)}catch(c){}return!0}finally{R.p=a,O.T=r,Cu(e,t)}}function Nu(e,t,n){t=Jl(n,t),null!==(e=Ca(e,t=Ao(e.stateNode,t,2),2))&&(Ie(e,2),Ru(e))}function Eu(e,t,n){if(3===e.tag)Nu(e,e,n);else for(;null!==t;){if(3===t.tag){Nu(t,e,n);break}if(1===t.tag){var l=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof l.componentDidCatch&&(null===Fc||!Fc.has(l))){e=Jl(n,e),null!==(l=Ca(t,n=Mo(2),2))&&(Po(n,l,t,e),Ie(l,2),Ru(l));break}}t=t.return}}function $u(e,t,n){var l=e.pingCache;if(null===l){l=e.pingCache=new fc;var r=new Set;l.set(t,r)}else void 0===(r=l.get(t))&&(r=new Set,l.set(t,r));r.has(n)||(jc=!0,r.add(n),e=_u.bind(null,e,t,n),t.then(e,e))}function _u(e,t,n){var l=e.pingCache;null!==l&&l.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,yc===e&&(xc&n)===n&&(4===Ec||3===Ec&&(62914560&xc)===xc&&300>be()-Ic?!(2&gc)&&au(e,0):Tc|=n,Lc===xc&&(Lc=0)),Ru(e)}function Tu(e,t){0===t&&(t=Me()),null!==(e=Dl(e,t))&&(Ie(e,t),Ru(e))}function zu(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),Tu(e,n)}function Lu(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;null!==a&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(l(314))}null!==r&&r.delete(t),Tu(e,n)}var Au=null,Mu=null,Pu=!1,Iu=!1,Du=!1,Ou=0;function Ru(e){e!==Mu&&null===e.next&&(null===Mu?Au=Mu=e:Mu=Mu.next=e),Iu=!0,Pu||(Pu=!0,$d(function(){6&gc?se(he,Uu):Bu()}))}function Fu(e,t){if(!Du&&Iu){Du=!0;do{for(var n=!1,l=Au;null!==l;){if(0!==e){var r=l.pendingLanes;if(0===r)var a=0;else{var i=l.suspendedLanes,o=l.pingedLanes;a=(1<<31-Se(42|e)+1)-1,a=201326741&(a&=r&~(i&~o))?201326741&a|1:a?2|a:0}0!==a&&(n=!0,Vu(l,a))}else a=xc,!(3&(a=ze(l,l===yc?a:0,null!==l.cancelPendingCommit||-1!==l.timeoutHandle)))||Le(l,a)||(n=!0,Vu(l,a));l=l.next}}while(n);Du=!1}}function Uu(){Bu()}function Bu(){Iu=Pu=!1;var e=0;0!==Ou&&function(){var e=window.event;if(e&&"popstate"===e.type)return e!==Sd&&(Sd=e,!0);return Sd=null,!1}()&&(e=Ou);for(var t=be(),n=null,l=Au;null!==l;){var r=l.next,a=Wu(l,t);0===a?(l.next=null,null===n?Au=r:n.next=r,null===r&&(Mu=n)):(n=l,(0!==e||3&a)&&(Iu=!0)),l=r}0!==Uc&&5!==Uc||Fu(e),0!==Ou&&(Ou=0)}function Wu(e,t){for(var n=e.suspendedLanes,l=e.pingedLanes,r=e.expirationTimes,a=-62914561&e.pendingLanes;0<a;){var i=31-Se(a),o=1<<i,s=r[i];-1===s?0!==(o&n)&&0===(o&l)||(r[i]=Ae(o,t)):s<=t&&(e.expiredLanes|=o),a&=~o}if(n=xc,n=ze(e,e===(t=yc)?n:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle),l=e.callbackNode,0===n||e===t&&(2===wc||9===wc)||null!==e.cancelPendingCommit)return null!==l&&null!==l&&ce(l),e.callbackNode=null,e.callbackPriority=0;if(!(3&n)||Le(e,n)){if((t=n&-n)===e.callbackPriority)return t;switch(null!==l&&ce(l),Ue(n)){case 2:case 8:n=pe;break;case 32:default:n=fe;break;case 268435456:n=ye}return l=qu.bind(null,e),n=se(n,l),e.callbackPriority=t,e.callbackNode=n,t}return null!==l&&null!==l&&ce(l),e.callbackPriority=2,e.callbackNode=null,2}function qu(e,t){if(0!==Uc&&5!==Uc)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Su()&&e.callbackNode!==n)return null;var l=xc;return 0===(l=ze(e,e===yc?l:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle))?null:(Zc(e,l,t),Wu(e,be()),null!=e.callbackNode&&e.callbackNode===n?qu.bind(null,e):null)}function Vu(e,t){if(Su())return null;Zc(e,t,!0)}function Hu(){if(0===Ou){var e=Kr;0===e&&(e=Ee,!(261888&(Ee<<=1))&&(Ee=256)),Ou=e}return Ou}function Ku(e){return null==e||"symbol"==typeof e||"boolean"==typeof e?null:"function"==typeof e?e:Pt(""+e)}function Gu(e,t){var n=t.ownerDocument.createElement("input");return n.name=t.name,n.value=t.value,e.id&&n.setAttribute("form",e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}for(var Qu=0;Qu<$l.length;Qu++){var Xu=$l[Qu];_l(Xu.toLowerCase(),"on"+(Xu[0].toUpperCase()+Xu.slice(1)))}_l(xl,"onAnimationEnd"),_l(wl,"onAnimationIteration"),_l(kl,"onAnimationStart"),_l("dblclick","onDoubleClick"),_l("focusin","onFocus"),_l("focusout","onBlur"),_l(Cl,"onTransitionRun"),_l(Sl,"onTransitionStart"),_l(jl,"onTransitionCancel"),_l(Nl,"onTransitionEnd"),st("onMouseEnter",["mouseout","mouseover"]),st("onMouseLeave",["mouseout","mouseover"]),st("onPointerEnter",["pointerout","pointerover"]),st("onPointerLeave",["pointerout","pointerover"]),ot("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ot("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ot("onBeforeInput",["compositionend","keypress","textInput","paste"]),ot("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ot("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ot("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Yu="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Ju=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Yu));function Zu(e,t){t=!!(4&t);for(var n=0;n<e.length;n++){var l=e[n],r=l.event;l=l.listeners;e:{var a=void 0;if(t)for(var i=l.length-1;0<=i;i--){var o=l[i],s=o.instance,c=o.currentTarget;if(o=o.listener,s!==a&&r.isPropagationStopped())break e;a=o,r.currentTarget=c;try{a(r)}catch(u){Tl(u)}r.currentTarget=null,a=s}else for(i=0;i<l.length;i++){if(s=(o=l[i]).instance,c=o.currentTarget,o=o.listener,s!==a&&r.isPropagationStopped())break e;a=o,r.currentTarget=c;try{a(r)}catch(u){Tl(u)}r.currentTarget=null,a=s}}}}function ed(e,t){var n=t[Ge];void 0===n&&(n=t[Ge]=new Set);var l=e+"__bubble";n.has(l)||(rd(t,e,2,!1),n.add(l))}function td(e,t,n){var l=0;t&&(l|=4),rd(n,e,l,t)}var nd="_reactListening"+Math.random().toString(36).slice(2);function ld(e){if(!e[nd]){e[nd]=!0,at.forEach(function(t){"selectionchange"!==t&&(Ju.has(t)||td(t,!1,e),td(t,!0,e))});var t=9===e.nodeType?e:e.ownerDocument;null===t||t[nd]||(t[nd]=!0,td("selectionchange",!1,t))}}function rd(e,t,n,l){switch(Tb(t)){case 2:var r=Sb;break;case 8:r=jb;break;default:r=Nb}n=r.bind(null,t,n,e),r=void 0,!Ht||"touchstart"!==t&&"touchmove"!==t&&"wheel"!==t||(r=!0),l?void 0!==r?e.addEventListener(t,n,{capture:!0,passive:r}):e.addEventListener(t,n,!0):void 0!==r?e.addEventListener(t,n,{passive:r}):e.addEventListener(t,n,!1)}function ad(e,t,n,l,r){var i=l;if(!(1&t||2&t||null===l))e:for(;;){if(null===l)return;var o=l.tag;if(3===o||4===o){var s=l.stateNode.containerInfo;if(s===r)break;if(4===o)for(o=l.return;null!==o;){var c=o.tag;if((3===c||4===c)&&o.stateNode.containerInfo===r)return;o=o.return}for(;null!==s;){if(null===(o=et(s)))return;if(5===(c=o.tag)||6===c||26===c||27===c){l=i=o;continue e}s=s.parentNode}}l=l.return}Wt(function(){var l=i,r=Ot(n),o=[];e:{var s=El.get(e);if(void 0!==s){var c=on,u=e;switch(e){case"keypress":if(0===Jt(n))break e;case"keydown":case"keyup":c=kn;break;case"focusin":u="focus",c=mn;break;case"focusout":u="blur",c=mn;break;case"beforeblur":case"afterblur":c=mn;break;case"click":if(2===n.button)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":c=dn;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":c=bn;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":c=Sn;break;case xl:case wl:case kl:c=hn;break;case Nl:c=jn;break;case"scroll":case"scrollend":c=cn;break;case"wheel":c=Nn;break;case"copy":case"cut":case"paste":c=pn;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":c=Cn;break;case"toggle":case"beforetoggle":c=En}var d=!!(4&t),b=!d&&("scroll"===e||"scrollend"===e),m=d?null!==s?s+"Capture":null:s;d=[];for(var h,p=l;null!==p;){var f=p;if(h=f.stateNode,5!==(f=f.tag)&&26!==f&&27!==f||null===h||null===m||null!=(f=qt(p,m))&&d.push(id(p,f,h)),b)break;p=p.return}0<d.length&&(s=new c(s,u,null,n,r),o.push({event:s,listeners:d}))}}if(!(7&t)){if(c="mouseout"===e||"pointerout"===e,(!(s="mouseover"===e||"pointerover"===e)||n===Dt||!(u=n.relatedTarget||n.fromElement)||!et(u)&&!u[Ke])&&(c||s)&&(s=r.window===r?r:(s=r.ownerDocument)?s.defaultView||s.parentWindow:window,c?(c=l,null!==(u=(u=n.relatedTarget||n.toElement)?et(u):null)&&(b=a(u),d=u.tag,u!==b||5!==d&&27!==d&&6!==d)&&(u=null)):(c=null,u=l),c!==u)){if(d=dn,f="onMouseLeave",m="onMouseEnter",p="mouse","pointerout"!==e&&"pointerover"!==e||(d=Cn,f="onPointerLeave",m="onPointerEnter",p="pointer"),b=null==c?s:nt(c),h=null==u?s:nt(u),(s=new d(f,p+"leave",c,n,r)).target=b,s.relatedTarget=h,f=null,et(r)===l&&((d=new d(m,p+"enter",u,n,r)).target=h,d.relatedTarget=b,f=d),b=f,c&&u)e:{for(d=sd,p=u,h=0,f=m=c;f;f=d(f))h++;f=0;for(var g=p;g;g=d(g))f++;for(;0<h-f;)m=d(m),h--;for(;0<f-h;)p=d(p),f--;for(;h--;){if(m===p||null!==p&&m===p.alternate){d=m;break e}m=d(m),p=d(p)}d=null}else d=null;null!==c&&cd(o,s,c,d,!1),null!==u&&null!==b&&cd(o,b,u,d,!0)}if("select"===(c=(s=l?nt(l):window).nodeName&&s.nodeName.toLowerCase())||"input"===c&&"file"===s.type)var y=Vn;else if(Rn(s))if(Hn)y=tl;else{y=Zn;var v=Jn}else!(c=s.nodeName)||"input"!==c.toLowerCase()||"checkbox"!==s.type&&"radio"!==s.type?l&&Lt(l.elementType)&&(y=Vn):y=el;switch(y&&(y=y(e,l))?Fn(o,y,n,r):(v&&v(e,s,l),"focusout"===e&&l&&"number"===s.type&&null!=l.memoizedProps.value&&St(s,"number",s.value)),v=l?nt(l):window,e){case"focusin":(Rn(v)||"true"===v.contentEditable)&&(ul=v,dl=l,bl=null);break;case"focusout":bl=dl=ul=null;break;case"mousedown":ml=!0;break;case"contextmenu":case"mouseup":case"dragend":ml=!1,hl(o,n,r);break;case"selectionchange":if(cl)break;case"keydown":case"keyup":hl(o,n,r)}var x;if(_n)e:{switch(e){case"compositionstart":var w="onCompositionStart";break e;case"compositionend":w="onCompositionEnd";break e;case"compositionupdate":w="onCompositionUpdate";break e}w=void 0}else Dn?Pn(e,n)&&(w="onCompositionEnd"):"keydown"===e&&229===n.keyCode&&(w="onCompositionStart");w&&(Ln&&"ko"!==n.locale&&(Dn||"onCompositionStart"!==w?"onCompositionEnd"===w&&Dn&&(x=Yt()):(Qt="value"in(Gt=r)?Gt.value:Gt.textContent,Dn=!0)),0<(v=od(l,w)).length&&(w=new fn(w,e,null,n,r),o.push({event:w,listeners:v}),x?w.data=x:null!==(x=In(n))&&(w.data=x))),(x=zn?function(e,t){switch(e){case"compositionend":return In(t);case"keypress":return 32!==t.which?null:(Mn=!0,An);case"textInput":return(e=t.data)===An&&Mn?null:e;default:return null}}(e,n):function(e,t){if(Dn)return"compositionend"===e||!_n&&Pn(e,t)?(e=Yt(),Xt=Qt=Gt=null,Dn=!1,e):null;switch(e){case"paste":default:return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Ln&&"ko"!==t.locale?null:t.data}}(e,n))&&(0<(w=od(l,"onBeforeInput")).length&&(v=new fn("onBeforeInput","beforeinput",null,n,r),o.push({event:v,listeners:w}),v.data=x)),function(e,t,n,l,r){if("submit"===t&&n&&n.stateNode===r){var a=Ku((r[He]||null).action),i=l.submitter;i&&null!==(t=(t=i[He]||null)?Ku(t.formAction):i.getAttribute("formAction"))&&(a=t,i=null);var o=new on("action","action",null,l,r);e.push({event:o,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(0!==Ou){var e=i?Gu(r,i):new FormData(r);ro(n,{pending:!0,data:e,method:r.method,action:a},null,e)}}else"function"==typeof a&&(o.preventDefault(),e=i?Gu(r,i):new FormData(r),ro(n,{pending:!0,data:e,method:r.method,action:a},a,e))},currentTarget:r}]})}}(o,e,l,n,r)}Zu(o,t)})}function id(e,t,n){return{instance:e,listener:t,currentTarget:n}}function od(e,t){for(var n=t+"Capture",l=[];null!==e;){var r=e,a=r.stateNode;if(5!==(r=r.tag)&&26!==r&&27!==r||null===a||(null!=(r=qt(e,n))&&l.unshift(id(e,r,a)),null!=(r=qt(e,t))&&l.push(id(e,r,a))),3===e.tag)return l;e=e.return}return[]}function sd(e){if(null===e)return null;do{e=e.return}while(e&&5!==e.tag&&27!==e.tag);return e||null}function cd(e,t,n,l,r){for(var a=t._reactName,i=[];null!==n&&n!==l;){var o=n,s=o.alternate,c=o.stateNode;if(o=o.tag,null!==s&&s===l)break;5!==o&&26!==o&&27!==o||null===c||(s=c,r?null!=(c=qt(n,a))&&i.unshift(id(n,c,s)):r||null!=(c=qt(n,a))&&i.push(id(n,c,s))),n=n.return}0!==i.length&&e.push({event:t,listeners:i})}var ud=/\r\n?/g,dd=/\u0000|\uFFFD/g;function bd(e){return("string"==typeof e?e:""+e).replace(ud,"\n").replace(dd,"")}function md(e,t){return t=bd(t),bd(e)===t}function hd(e,t,n,r,a,i){switch(n){case"children":"string"==typeof r?"body"===t||"textarea"===t&&""===r||$t(e,r):("number"==typeof r||"bigint"==typeof r)&&"body"!==t&&$t(e,""+r);break;case"className":mt(e,"class",r);break;case"tabIndex":mt(e,"tabindex",r);break;case"dir":case"role":case"viewBox":case"width":case"height":mt(e,n,r);break;case"style":zt(e,r,i);break;case"data":if("object"!==t){mt(e,"data",r);break}case"src":case"href":if(""===r&&("a"!==t||"href"!==n)){e.removeAttribute(n);break}if(null==r||"function"==typeof r||"symbol"==typeof r||"boolean"==typeof r){e.removeAttribute(n);break}r=Pt(""+r),e.setAttribute(n,r);break;case"action":case"formAction":if("function"==typeof r){e.setAttribute(n,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}if("function"==typeof i&&("formAction"===n?("input"!==t&&hd(e,t,"name",a.name,a,null),hd(e,t,"formEncType",a.formEncType,a,null),hd(e,t,"formMethod",a.formMethod,a,null),hd(e,t,"formTarget",a.formTarget,a,null)):(hd(e,t,"encType",a.encType,a,null),hd(e,t,"method",a.method,a,null),hd(e,t,"target",a.target,a,null))),null==r||"symbol"==typeof r||"boolean"==typeof r){e.removeAttribute(n);break}r=Pt(""+r),e.setAttribute(n,r);break;case"onClick":null!=r&&(e.onclick=It);break;case"onScroll":null!=r&&ed("scroll",e);break;case"onScrollEnd":null!=r&&ed("scrollend",e);break;case"dangerouslySetInnerHTML":if(null!=r){if("object"!=typeof r||!("__html"in r))throw Error(l(61));if(null!=(n=r.__html)){if(null!=a.children)throw Error(l(60));e.innerHTML=n}}break;case"multiple":e.multiple=r&&"function"!=typeof r&&"symbol"!=typeof r;break;case"muted":e.muted=r&&"function"!=typeof r&&"symbol"!=typeof r;break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":case"autoFocus":break;case"xlinkHref":if(null==r||"function"==typeof r||"boolean"==typeof r||"symbol"==typeof r){e.removeAttribute("xlink:href");break}n=Pt(""+r),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":null!=r&&"function"!=typeof r&&"symbol"!=typeof r?e.setAttribute(n,""+r):e.removeAttribute(n);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":r&&"function"!=typeof r&&"symbol"!=typeof r?e.setAttribute(n,""):e.removeAttribute(n);break;case"capture":case"download":!0===r?e.setAttribute(n,""):!1!==r&&null!=r&&"function"!=typeof r&&"symbol"!=typeof r?e.setAttribute(n,r):e.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":null!=r&&"function"!=typeof r&&"symbol"!=typeof r&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case"rowSpan":case"start":null==r||"function"==typeof r||"symbol"==typeof r||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case"popover":ed("beforetoggle",e),ed("toggle",e),bt(e,"popover",r);break;case"xlinkActuate":ht(e,"http://www.w3.org/1999/xlink","xlink:actuate",r);break;case"xlinkArcrole":ht(e,"http://www.w3.org/1999/xlink","xlink:arcrole",r);break;case"xlinkRole":ht(e,"http://www.w3.org/1999/xlink","xlink:role",r);break;case"xlinkShow":ht(e,"http://www.w3.org/1999/xlink","xlink:show",r);break;case"xlinkTitle":ht(e,"http://www.w3.org/1999/xlink","xlink:title",r);break;case"xlinkType":ht(e,"http://www.w3.org/1999/xlink","xlink:type",r);break;case"xmlBase":ht(e,"http://www.w3.org/XML/1998/namespace","xml:base",r);break;case"xmlLang":ht(e,"http://www.w3.org/XML/1998/namespace","xml:lang",r);break;case"xmlSpace":ht(e,"http://www.w3.org/XML/1998/namespace","xml:space",r);break;case"is":bt(e,"is",r);break;case"innerText":case"textContent":break;default:(!(2<n.length)||"o"!==n[0]&&"O"!==n[0]||"n"!==n[1]&&"N"!==n[1])&&bt(e,n=At.get(n)||n,r)}}function pd(e,t,n,r,a,i){switch(n){case"style":zt(e,r,i);break;case"dangerouslySetInnerHTML":if(null!=r){if("object"!=typeof r||!("__html"in r))throw Error(l(61));if(null!=(n=r.__html)){if(null!=a.children)throw Error(l(60));e.innerHTML=n}}break;case"children":"string"==typeof r?$t(e,r):("number"==typeof r||"bigint"==typeof r)&&$t(e,""+r);break;case"onScroll":null!=r&&ed("scroll",e);break;case"onScrollEnd":null!=r&&ed("scrollend",e);break;case"onClick":null!=r&&(e.onclick=It);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":case"innerText":case"textContent":break;default:it.hasOwnProperty(n)||("o"!==n[0]||"n"!==n[1]||(a=n.endsWith("Capture"),t=n.slice(2,a?n.length-7:void 0),"function"==typeof(i=null!=(i=e[He]||null)?i[n]:null)&&e.removeEventListener(t,i,a),"function"!=typeof r)?n in e?e[n]=r:!0===r?e.setAttribute(n,""):bt(e,n,r):("function"!=typeof i&&null!==i&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a)))}}function fd(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":ed("error",e),ed("load",e);var r,a=!1,i=!1;for(r in n)if(n.hasOwnProperty(r)){var o=n[r];if(null!=o)switch(r){case"src":a=!0;break;case"srcSet":i=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(l(137,t));default:hd(e,t,r,o,n,null)}}return i&&hd(e,t,"srcSet",n.srcSet,n,null),void(a&&hd(e,t,"src",n.src,n,null));case"input":ed("invalid",e);var s=r=o=i=null,c=null,u=null;for(a in n)if(n.hasOwnProperty(a)){var d=n[a];if(null!=d)switch(a){case"name":i=d;break;case"type":o=d;break;case"checked":c=d;break;case"defaultChecked":u=d;break;case"value":r=d;break;case"defaultValue":s=d;break;case"children":case"dangerouslySetInnerHTML":if(null!=d)throw Error(l(137,t));break;default:hd(e,t,a,d,n,null)}}return void Ct(e,r,s,c,u,o,i,!1);case"select":for(i in ed("invalid",e),a=o=r=null,n)if(n.hasOwnProperty(i)&&null!=(s=n[i]))switch(i){case"value":r=s;break;case"defaultValue":o=s;break;case"multiple":a=s;default:hd(e,t,i,s,n,null)}return t=r,n=o,e.multiple=!!a,void(null!=t?jt(e,!!a,t,!1):null!=n&&jt(e,!!a,n,!0));case"textarea":for(o in ed("invalid",e),r=i=a=null,n)if(n.hasOwnProperty(o)&&null!=(s=n[o]))switch(o){case"value":a=s;break;case"defaultValue":i=s;break;case"children":r=s;break;case"dangerouslySetInnerHTML":if(null!=s)throw Error(l(91));break;default:hd(e,t,o,s,n,null)}return void Et(e,a,i,r);case"option":for(c in n)if(n.hasOwnProperty(c)&&null!=(a=n[c]))if("selected"===c)e.selected=a&&"function"!=typeof a&&"symbol"!=typeof a;else hd(e,t,c,a,n,null);return;case"dialog":ed("beforetoggle",e),ed("toggle",e),ed("cancel",e),ed("close",e);break;case"iframe":case"object":ed("load",e);break;case"video":case"audio":for(a=0;a<Yu.length;a++)ed(Yu[a],e);break;case"image":ed("error",e),ed("load",e);break;case"details":ed("toggle",e);break;case"embed":case"source":case"link":ed("error",e),ed("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(u in n)if(n.hasOwnProperty(u)&&null!=(a=n[u]))switch(u){case"children":case"dangerouslySetInnerHTML":throw Error(l(137,t));default:hd(e,t,u,a,n,null)}return;default:if(Lt(t)){for(d in n)n.hasOwnProperty(d)&&(void 0!==(a=n[d])&&pd(e,t,d,a,n,void 0));return}}for(s in n)n.hasOwnProperty(s)&&(null!=(a=n[s])&&hd(e,t,s,a,n,null))}function gd(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}var yd=null,vd=null;function xd(e){return 9===e.nodeType?e:e.ownerDocument}function wd(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function kd(e,t){if(0===e)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return 1===e&&"foreignObject"===t?0:e}function Cd(e,t){return"textarea"===e||"noscript"===e||"string"==typeof t.children||"number"==typeof t.children||"bigint"==typeof t.children||"object"==typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&null!=t.dangerouslySetInnerHTML.__html}var Sd=null;var jd="function"==typeof setTimeout?setTimeout:void 0,Nd="function"==typeof clearTimeout?clearTimeout:void 0,Ed="function"==typeof Promise?Promise:void 0,$d="function"==typeof queueMicrotask?queueMicrotask:void 0!==Ed?function(e){return Ed.resolve(null).then(e).catch(_d)}:jd;function _d(e){setTimeout(function(){throw e})}function Td(e){return"head"===e}function zd(e,t){var n=t,l=0;do{var r=n.nextSibling;if(e.removeChild(n),r&&8===r.nodeType)if("/$"===(n=r.data)||"/&"===n){if(0===l)return e.removeChild(r),void Gb(t);l--}else if("$"===n||"$?"===n||"$~"===n||"$!"===n||"&"===n)l++;else if("html"===n)Bd(e.ownerDocument.documentElement);else if("head"===n){Bd(n=e.ownerDocument.head);for(var a=n.firstChild;a;){var i=a.nextSibling,o=a.nodeName;a[Je]||"SCRIPT"===o||"STYLE"===o||"LINK"===o&&"stylesheet"===a.rel.toLowerCase()||n.removeChild(a),a=i}}else"body"===n&&Bd(e.ownerDocument.body);n=r}while(n);Gb(t)}function Ld(e,t){var n=e;e=0;do{var l=n.nextSibling;if(1===n.nodeType?t?(n._stashedDisplay=n.style.display,n.style.display="none"):(n.style.display=n._stashedDisplay||"",""===n.getAttribute("style")&&n.removeAttribute("style")):3===n.nodeType&&(t?(n._stashedText=n.nodeValue,n.nodeValue=""):n.nodeValue=n._stashedText||""),l&&8===l.nodeType)if("/$"===(n=l.data)){if(0===e)break;e--}else"$"!==n&&"$?"!==n&&"$~"!==n&&"$!"!==n||e++;n=l}while(n)}function Ad(e){var t=e.firstChild;for(t&&10===t.nodeType&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case"HTML":case"HEAD":case"BODY":Ad(n),Ze(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if("stylesheet"===n.rel.toLowerCase())continue}e.removeChild(n)}}function Md(e,t){for(;8!==e.nodeType;){if((1!==e.nodeType||"INPUT"!==e.nodeName||"hidden"!==e.type)&&!t)return null;if(null===(e=Dd(e.nextSibling)))return null}return e}function Pd(e){return"$?"===e.data||"$~"===e.data}function Id(e){return"$!"===e.data||"$?"===e.data&&"loading"!==e.ownerDocument.readyState}function Dd(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break;if(8===t){if("$"===(t=e.data)||"$!"===t||"$?"===t||"$~"===t||"&"===t||"F!"===t||"F"===t)break;if("/$"===t||"/&"===t)return null}}return e}var Od=null;function Rd(e){e=e.nextSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("/$"===n||"/&"===n){if(0===t)return Dd(e.nextSibling);t--}else"$"!==n&&"$!"!==n&&"$?"!==n&&"$~"!==n&&"&"!==n||t++}e=e.nextSibling}return null}function Fd(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("$"===n||"$!"===n||"$?"===n||"$~"===n||"&"===n){if(0===t)return e;t--}else"/$"!==n&&"/&"!==n||t++}e=e.previousSibling}return null}function Ud(e,t,n){switch(t=xd(n),e){case"html":if(!(e=t.documentElement))throw Error(l(452));return e;case"head":if(!(e=t.head))throw Error(l(453));return e;case"body":if(!(e=t.body))throw Error(l(454));return e;default:throw Error(l(451))}}function Bd(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Ze(e)}var Wd=new Map,qd=new Set;function Vd(e){return"function"==typeof e.getRootNode?e.getRootNode():9===e.nodeType?e:e.ownerDocument}var Hd=R.d;R.d={f:function(){var e=Hd.f(),t=lu();return e||t},r:function(e){var t=tt(e);null!==t&&5===t.tag&&"form"===t.type?io(t):Hd.r(e)},D:function(e){Hd.D(e),Gd("dns-prefetch",e,null)},C:function(e,t){Hd.C(e,t),Gd("preconnect",e,t)},L:function(e,t,n){Hd.L(e,t,n);var l=Kd;if(l&&e&&t){var r='link[rel="preload"][as="'+wt(t)+'"]';"image"===t&&n&&n.imageSrcSet?(r+='[imagesrcset="'+wt(n.imageSrcSet)+'"]',"string"==typeof n.imageSizes&&(r+='[imagesizes="'+wt(n.imageSizes)+'"]')):r+='[href="'+wt(e)+'"]';var a=r;switch(t){case"style":a=Xd(e);break;case"script":a=Zd(e)}Wd.has(a)||(e=u({rel:"preload",href:"image"===t&&n&&n.imageSrcSet?void 0:e,as:t},n),Wd.set(a,e),null!==l.querySelector(r)||"style"===t&&l.querySelector(Yd(a))||"script"===t&&l.querySelector(eb(a))||(fd(t=l.createElement("link"),"link",e),rt(t),l.head.appendChild(t)))}},m:function(e,t){Hd.m(e,t);var n=Kd;if(n&&e){var l=t&&"string"==typeof t.as?t.as:"script",r='link[rel="modulepreload"][as="'+wt(l)+'"][href="'+wt(e)+'"]',a=r;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":a=Zd(e)}if(!Wd.has(a)&&(e=u({rel:"modulepreload",href:e},t),Wd.set(a,e),null===n.querySelector(r))){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(eb(a)))return}fd(l=n.createElement("link"),"link",e),rt(l),n.head.appendChild(l)}}},X:function(e,t){Hd.X(e,t);var n=Kd;if(n&&e){var l=lt(n).hoistableScripts,r=Zd(e),a=l.get(r);a||((a=n.querySelector(eb(r)))||(e=u({src:e,async:!0},t),(t=Wd.get(r))&&rb(e,t),rt(a=n.createElement("script")),fd(a,"link",e),n.head.appendChild(a)),a={type:"script",instance:a,count:1,state:null},l.set(r,a))}},S:function(e,t,n){Hd.S(e,t,n);var l=Kd;if(l&&e){var r=lt(l).hoistableStyles,a=Xd(e);t=t||"default";var i=r.get(a);if(!i){var o={loading:0,preload:null};if(i=l.querySelector(Yd(a)))o.loading=5;else{e=u({rel:"stylesheet",href:e,"data-precedence":t},n),(n=Wd.get(a))&&lb(e,n);var s=i=l.createElement("link");rt(s),fd(s,"link",e),s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),s.addEventListener("load",function(){o.loading|=1}),s.addEventListener("error",function(){o.loading|=2}),o.loading|=4,nb(i,t,l)}i={type:"stylesheet",instance:i,count:1,state:o},r.set(a,i)}}},M:function(e,t){Hd.M(e,t);var n=Kd;if(n&&e){var l=lt(n).hoistableScripts,r=Zd(e),a=l.get(r);a||((a=n.querySelector(eb(r)))||(e=u({src:e,async:!0,type:"module"},t),(t=Wd.get(r))&&rb(e,t),rt(a=n.createElement("script")),fd(a,"link",e),n.head.appendChild(a)),a={type:"script",instance:a,count:1,state:null},l.set(r,a))}}};var Kd="undefined"==typeof document?null:document;function Gd(e,t,n){var l=Kd;if(l&&"string"==typeof t&&t){var r=wt(t);r='link[rel="'+e+'"][href="'+r+'"]',"string"==typeof n&&(r+='[crossorigin="'+n+'"]'),qd.has(r)||(qd.add(r),e={rel:e,crossOrigin:n,href:t},null===l.querySelector(r)&&(fd(t=l.createElement("link"),"link",e),rt(t),l.head.appendChild(t)))}}function Qd(e,t,n,r){var a,i,o,s,c=(c=X.current)?Vd(c):null;if(!c)throw Error(l(446));switch(e){case"meta":case"title":return null;case"style":return"string"==typeof n.precedence&&"string"==typeof n.href?(t=Xd(n.href),(r=(n=lt(c).hoistableStyles).get(t))||(r={type:"style",instance:null,count:0,state:null},n.set(t,r)),r):{type:"void",instance:null,count:0,state:null};case"link":if("stylesheet"===n.rel&&"string"==typeof n.href&&"string"==typeof n.precedence){e=Xd(n.href);var u=lt(c).hoistableStyles,d=u.get(e);if(d||(c=c.ownerDocument||c,d={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(e,d),(u=c.querySelector(Yd(e)))&&!u._p&&(d.instance=u,d.state.loading=5),Wd.has(e)||(n={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},Wd.set(e,n),u||(a=c,i=e,o=n,s=d.state,a.querySelector('link[rel="preload"][as="style"]['+i+"]")?s.loading=1:(i=a.createElement("link"),s.preload=i,i.addEventListener("load",function(){return s.loading|=1}),i.addEventListener("error",function(){return s.loading|=2}),fd(i,"link",o),rt(i),a.head.appendChild(i))))),t&&null===r)throw Error(l(528,""));return d}if(t&&null!==r)throw Error(l(529,""));return null;case"script":return t=n.async,"string"==typeof(n=n.src)&&t&&"function"!=typeof t&&"symbol"!=typeof t?(t=Zd(n),(r=(n=lt(c).hoistableScripts).get(t))||(r={type:"script",instance:null,count:0,state:null},n.set(t,r)),r):{type:"void",instance:null,count:0,state:null};default:throw Error(l(444,e))}}function Xd(e){return'href="'+wt(e)+'"'}function Yd(e){return'link[rel="stylesheet"]['+e+"]"}function Jd(e){return u({},e,{"data-precedence":e.precedence,precedence:null})}function Zd(e){return'[src="'+wt(e)+'"]'}function eb(e){return"script[async]"+e}function tb(e,t,n){if(t.count++,null===t.instance)switch(t.type){case"style":var r=e.querySelector('style[data-href~="'+wt(n.href)+'"]');if(r)return t.instance=r,rt(r),r;var a=u({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return rt(r=(e.ownerDocument||e).createElement("style")),fd(r,"style",a),nb(r,n.precedence,e),t.instance=r;case"stylesheet":a=Xd(n.href);var i=e.querySelector(Yd(a));if(i)return t.state.loading|=4,t.instance=i,rt(i),i;r=Jd(n),(a=Wd.get(a))&&lb(r,a),rt(i=(e.ownerDocument||e).createElement("link"));var o=i;return o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),fd(i,"link",r),t.state.loading|=4,nb(i,n.precedence,e),t.instance=i;case"script":return i=Zd(n.src),(a=e.querySelector(eb(i)))?(t.instance=a,rt(a),a):(r=n,(a=Wd.get(i))&&rb(r=u({},n),a),rt(a=(e=e.ownerDocument||e).createElement("script")),fd(a,"link",r),e.head.appendChild(a),t.instance=a);case"void":return null;default:throw Error(l(443,t.type))}else"stylesheet"===t.type&&!(4&t.state.loading)&&(r=t.instance,t.state.loading|=4,nb(r,n.precedence,e));return t.instance}function nb(e,t,n){for(var l=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),r=l.length?l[l.length-1]:null,a=r,i=0;i<l.length;i++){var o=l[i];if(o.dataset.precedence===t)a=o;else if(a!==r)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=9===n.nodeType?n.head:n).insertBefore(e,t.firstChild)}function lb(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.title&&(e.title=t.title)}function rb(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.integrity&&(e.integrity=t.integrity)}var ab=null;function ib(e,t,n){if(null===ab){var l=new Map,r=ab=new Map;r.set(n,l)}else(l=(r=ab).get(n))||(l=new Map,r.set(n,l));if(l.has(e))return l;for(l.set(e,null),n=n.getElementsByTagName(e),r=0;r<n.length;r++){var a=n[r];if(!(a[Je]||a[Ve]||"link"===e&&"stylesheet"===a.getAttribute("rel"))&&"http://www.w3.org/2000/svg"!==a.namespaceURI){var i=a.getAttribute(t)||"";i=e+i;var o=l.get(i);o?o.push(a):l.set(i,[a])}}return l}function ob(e,t,n){(e=e.ownerDocument||e).head.insertBefore(n,"title"===t?e.querySelector("head > title"):null)}function sb(e){return!!("stylesheet"!==e.type||3&e.state.loading)}var cb=0;function ub(){if(this.count--,0===this.count&&(0===this.imgCount||!this.waitingForImages))if(this.stylesheets)bb(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}var db=null;function bb(e,t){e.stylesheets=null,null!==e.unsuspend&&(e.count++,db=new Map,t.forEach(mb,e),db=null,ub.call(e))}function mb(e,t){if(!(4&t.state.loading)){var n=db.get(e);if(n)var l=n.get(null);else{n=new Map,db.set(e,n);for(var r=e.querySelectorAll("link[data-precedence],style[data-precedence]"),a=0;a<r.length;a++){var i=r[a];"LINK"!==i.nodeName&&"not all"===i.getAttribute("media")||(n.set(i.dataset.precedence,i),l=i)}l&&n.set(null,l)}i=(r=t.instance).getAttribute("data-precedence"),(a=n.get(i)||l)===l&&n.set(null,r),n.set(i,r),this.count++,l=ub.bind(this),r.addEventListener("load",l),r.addEventListener("error",l),a?a.parentNode.insertBefore(r,a.nextSibling):(e=9===e.nodeType?e.head:e).insertBefore(r,e.firstChild),t.state.loading|=4}}var hb={$$typeof:v,Provider:null,Consumer:null,_currentValue:F,_currentValue2:F,_threadCount:0};function pb(e,t,n,l,r,a,i,o,s){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Pe(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Pe(0),this.hiddenUpdates=Pe(null),this.identifierPrefix=l,this.onUncaughtError=r,this.onCaughtError=a,this.onRecoverableError=i,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=s,this.incompleteTransitions=new Map}function fb(e,t,n,l,r,a,i,o,s,c,u,d){return e=new pb(e,t,n,i,s,c,u,d,o),t=1,!0===a&&(t|=24),a=Bl(3,null,null,t),e.current=a,a.stateNode=e,(t=Wr()).refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:l,isDehydrated:n,cache:t},xa(a),e}function gb(e){return e?e=Fl:Fl}function yb(e,t,n,l,r,a){r=gb(r),null===l.context?l.context=r:l.pendingContext=r,(l=ka(t)).payload={element:n},null!==(a=void 0===a?null:a)&&(l.callback=a),null!==(n=Ca(e,l,t))&&(Jc(n,0,t),Sa(n,e,t))}function vb(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n<t?n:t}}function xb(e,t){vb(e,t),(e=e.alternate)&&vb(e,t)}function wb(e){if(13===e.tag||31===e.tag){var t=Dl(e,67108864);null!==t&&Jc(t,0,67108864),xb(e,67108864)}}function kb(e){if(13===e.tag||31===e.tag){var t=Xc(),n=Dl(e,t=Fe(t));null!==n&&Jc(n,0,t),xb(e,t)}}var Cb=!0;function Sb(e,t,n,l){var r=O.T;O.T=null;var a=R.p;try{R.p=2,Nb(e,t,n,l)}finally{R.p=a,O.T=r}}function jb(e,t,n,l){var r=O.T;O.T=null;var a=R.p;try{R.p=8,Nb(e,t,n,l)}finally{R.p=a,O.T=r}}function Nb(e,t,n,l){if(Cb){var r=Eb(l);if(null===r)ad(e,t,l,$b,n),Rb(e,l);else if(function(e,t,n,l,r){switch(t){case"focusin":return Lb=Fb(Lb,e,t,n,l,r),!0;case"dragenter":return Ab=Fb(Ab,e,t,n,l,r),!0;case"mouseover":return Mb=Fb(Mb,e,t,n,l,r),!0;case"pointerover":var a=r.pointerId;return Pb.set(a,Fb(Pb.get(a)||null,e,t,n,l,r)),!0;case"gotpointercapture":return a=r.pointerId,Ib.set(a,Fb(Ib.get(a)||null,e,t,n,l,r)),!0}return!1}(r,e,t,n,l))l.stopPropagation();else if(Rb(e,l),4&t&&-1<Ob.indexOf(e)){for(;null!==r;){var a=tt(r);if(null!==a)switch(a.tag){case 3:if((a=a.stateNode).current.memoizedState.isDehydrated){var i=Te(a.pendingLanes);if(0!==i){var o=a;for(o.pendingLanes|=2,o.entangledLanes|=2;i;){var s=1<<31-Se(i);o.entanglements[1]|=s,i&=~s}Ru(a),!(6&gc)&&(Oc=be()+500,Fu(0))}}break;case 31:case 13:null!==(o=Dl(a,2))&&Jc(o,0,2),lu(),xb(a,2)}if(null===(a=Eb(l))&&ad(e,t,l,$b,n),a===r)break;r=a}null!==r&&l.stopPropagation()}else ad(e,t,l,null,n)}}function Eb(e){return _b(e=Ot(e))}var $b=null;function _b(e){if($b=null,null!==(e=et(e))){var t=a(e);if(null===t)e=null;else{var n=t.tag;if(13===n){if(null!==(e=i(t)))return e;e=null}else if(31===n){if(null!==(e=o(t)))return e;e=null}else if(3===n){if(t.stateNode.current.memoizedState.isDehydrated)return 3===t.tag?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return $b=e,null}function Tb(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(me()){case he:return 2;case pe:return 8;case fe:case ge:return 32;case ye:return 268435456;default:return 32}default:return 32}}var zb=!1,Lb=null,Ab=null,Mb=null,Pb=new Map,Ib=new Map,Db=[],Ob="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Rb(e,t){switch(e){case"focusin":case"focusout":Lb=null;break;case"dragenter":case"dragleave":Ab=null;break;case"mouseover":case"mouseout":Mb=null;break;case"pointerover":case"pointerout":Pb.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ib.delete(t.pointerId)}}function Fb(e,t,n,l,r,a){return null===e||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:l,nativeEvent:a,targetContainers:[r]},null!==t&&(null!==(t=tt(t))&&wb(t)),e):(e.eventSystemFlags|=l,t=e.targetContainers,null!==r&&-1===t.indexOf(r)&&t.push(r),e)}function Ub(e){var t=et(e.target);if(null!==t){var n=a(t);if(null!==n)if(13===(t=n.tag)){if(null!==(t=i(n)))return e.blockedOn=t,void We(e.priority,function(){kb(n)})}else if(31===t){if(null!==(t=o(n)))return e.blockedOn=t,void We(e.priority,function(){kb(n)})}else if(3===t&&n.stateNode.current.memoizedState.isDehydrated)return void(e.blockedOn=3===n.tag?n.stateNode.containerInfo:null)}e.blockedOn=null}function Bb(e){if(null!==e.blockedOn)return!1;for(var t=e.targetContainers;0<t.length;){var n=Eb(e.nativeEvent);if(null!==n)return null!==(t=tt(n))&&wb(t),e.blockedOn=n,!1;var l=new(n=e.nativeEvent).constructor(n.type,n);Dt=l,n.target.dispatchEvent(l),Dt=null,t.shift()}return!0}function Wb(e,t,n){Bb(e)&&n.delete(t)}function qb(){zb=!1,null!==Lb&&Bb(Lb)&&(Lb=null),null!==Ab&&Bb(Ab)&&(Ab=null),null!==Mb&&Bb(Mb)&&(Mb=null),Pb.forEach(Wb),Ib.forEach(Wb)}function Vb(t,n){t.blockedOn===n&&(t.blockedOn=null,zb||(zb=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,qb)))}var Hb=null;function Kb(t){Hb!==t&&(Hb=t,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Hb===t&&(Hb=null);for(var e=0;e<t.length;e+=3){var n=t[e],l=t[e+1],r=t[e+2];if("function"!=typeof l){if(null===_b(l||n))continue;break}var a=tt(n);null!==a&&(t.splice(e,3),e-=3,ro(a,{pending:!0,data:r,method:n.method,action:l},l,r))}}))}function Gb(e){function t(t){return Vb(t,e)}null!==Lb&&Vb(Lb,e),null!==Ab&&Vb(Ab,e),null!==Mb&&Vb(Mb,e),Pb.forEach(t),Ib.forEach(t);for(var n=0;n<Db.length;n++){var l=Db[n];l.blockedOn===e&&(l.blockedOn=null)}for(;0<Db.length&&null===(n=Db[0]).blockedOn;)Ub(n),null===n.blockedOn&&Db.shift();if(null!=(n=(e.ownerDocument||e).$$reactFormReplay))for(l=0;l<n.length;l+=3){var r=n[l],a=n[l+1],i=r[He]||null;if("function"==typeof a)i||Kb(n);else if(i){var o=null;if(a&&a.hasAttribute("formAction")){if(r=a,i=a[He]||null)o=i.formAction;else if(null!==_b(r))continue}else o=i.action;"function"==typeof o?n[l+1]=o:(n.splice(l,3),l-=3),Kb(n)}}}function Qb(){function e(e){e.canIntercept&&"react-transition"===e.info&&e.intercept({handler:function(){return new Promise(function(e){return r=e})},focusReset:"manual",scroll:"manual"})}function t(){null!==r&&(r(),r=null),l||setTimeout(n,20)}function n(){if(!l&&!navigation.transition){var e=navigation.currentEntry;e&&null!=e.url&&navigation.navigate(e.url,{state:e.getState(),info:"react-transition",history:"replace"})}}if("object"==typeof navigation){var l=!1,r=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(n,100),function(){l=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),null!==r&&(r(),r=null)}}}function Xb(e){this._internalRoot=e}function Yb(e){this._internalRoot=e}Yb.prototype.render=Xb.prototype.render=function(e){var t=this._internalRoot;if(null===t)throw Error(l(409));yb(t.current,Xc(),e,t,null,null)},Yb.prototype.unmount=Xb.prototype.unmount=function(){var e=this._internalRoot;if(null!==e){this._internalRoot=null;var t=e.containerInfo;yb(e.current,2,null,e,null,null),lu(),t[Ke]=null}},Yb.prototype.unstable_scheduleHydration=function(e){if(e){var t=Be();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Db.length&&0!==t&&t<Db[n].priority;n++);Db.splice(n,0,e),0===n&&Ub(e)}};var Jb=t.version;if("19.2.4"!==Jb)throw Error(l(527,Jb,"19.2.4"));R.findDOMNode=function(e){var t=e._reactInternals;if(void 0===t){if("function"==typeof e.render)throw Error(l(188));throw e=Object.keys(e).join(","),Error(l(268,e))}return e=function(e){var t=e.alternate;if(!t){if(null===(t=a(e)))throw Error(l(188));return t!==e?null:e}for(var n=e,r=t;;){var i=n.return;if(null===i)break;var o=i.alternate;if(null===o){if(null!==(r=i.return)){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return s(i),e;if(o===r)return s(i),t;o=o.sibling}throw Error(l(188))}if(n.return!==r.return)n=i,r=o;else{for(var c=!1,u=i.child;u;){if(u===n){c=!0,n=i,r=o;break}if(u===r){c=!0,r=i,n=o;break}u=u.sibling}if(!c){for(u=o.child;u;){if(u===n){c=!0,n=o,r=i;break}if(u===r){c=!0,r=o,n=i;break}u=u.sibling}if(!c)throw Error(l(189))}}if(n.alternate!==r)throw Error(l(190))}if(3!==n.tag)throw Error(l(188));return n.stateNode.current===n?e:t}(t),e=null===(e=null!==e?c(e):null)?null:e.stateNode};var Zb={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:O,reconcilerVersion:"19.2.4"};if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var em=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!em.isDisabled&&em.supportsFiber)try{we=em.inject(Zb),ke=em}catch(nm){}}return C.createRoot=function(e,t){if(!r(e))throw Error(l(299));var n=!1,a="",i=$o,o=_o,s=To;return null!=t&&(!0===t.unstable_strictMode&&(n=!0),void 0!==t.identifierPrefix&&(a=t.identifierPrefix),void 0!==t.onUncaughtError&&(i=t.onUncaughtError),void 0!==t.onCaughtError&&(o=t.onCaughtError),void 0!==t.onRecoverableError&&(s=t.onRecoverableError)),t=fb(e,1,!1,null,0,n,a,null,i,o,s,Qb),e[Ke]=t.current,ld(e),new Xb(t)},C.hydrateRoot=function(e,t,n){if(!r(e))throw Error(l(299));var a=!1,i="",o=$o,s=_o,c=To,u=null;return null!=n&&(!0===n.unstable_strictMode&&(a=!0),void 0!==n.identifierPrefix&&(i=n.identifierPrefix),void 0!==n.onUncaughtError&&(o=n.onUncaughtError),void 0!==n.onCaughtError&&(s=n.onCaughtError),void 0!==n.onRecoverableError&&(c=n.onRecoverableError),void 0!==n.formState&&(u=n.formState)),(t=fb(e,1,!0,t,0,a,i,u,o,s,c,Qb)).context=gb(null),n=t.current,(i=ka(a=Fe(a=Xc()))).callback=null,Ca(n,i,a),n=a,t.current.lanes=n,Ie(t,n),Ru(t),e[Ke]=t.current,ld(e),new Yb(t)},C.version="19.2.4",C}var P,I,D=(T||(T=1,function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}(),k.exports=M()),k.exports),O={exports:{}},R={};var F=(I||(I=1,O.exports=function(){if(P)return R;P=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(t,n,l){var r=null;if(void 0!==l&&(r=""+l),void 0!==n.key&&(r=""+n.key),"key"in n)for(var a in l={},n)"key"!==a&&(l[a]=n[a]);else l=n;return n=l.ref,{$$typeof:e,type:t,key:r,ref:void 0!==n?n:null,props:l}}return R.Fragment=t,R.jsx=n,R.jsxs=n,R}()),O.exports);const U=new class{constructor(){this.supportsContainerQueries=this.detectContainerQueries(),this.init()}detectContainerQueries(){if("undefined"==typeof window)return!1;try{if("CSS"in window&&"supports"in window.CSS)return window.CSS.supports("container-type","inline-size");const e=document.createElement("div");return e.style.containerType="inline-size","inline-size"===e.style.containerType}catch{return!1}}init(){"undefined"!=typeof window&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>this.applyClasses()):this.applyClasses())}applyClasses(){document.querySelectorAll(".limbo-component-container-wrapper").forEach(e=>{this.supportsContainerQueries?(e.classList.add("container-queries-supported"),e.classList.remove("container-queries-fallback")):(e.classList.add("container-queries-fallback"),e.classList.remove("container-queries-supported"))}),this.supportsContainerQueries?(document.body.classList.add("container-queries-supported"),document.body.classList.remove("container-queries-fallback")):(document.body.classList.add("container-queries-fallback"),document.body.classList.remove("container-queries-supported"))}getContainerWidth(e){if(!e)return window.innerWidth;let t=e.closest(".limbo-component-container-wrapper");return t||(t=e.closest(".limbo-modal-content")),t||(t=e.closest(".limbo-modal")),t||(t=document.body),t.offsetWidth||t.clientWidth}shouldUseMobileStyles(e,t=768){return this.getContainerWidth(e)<=t}applyResponsiveClasses(e){if(this.supportsContainerQueries)return;const t=this.shouldUseMobileStyles(e),n=this.shouldUseMobileStyles(e,1024)&&!t;e.classList.toggle("limbo-mobile-fallback",t),e.classList.toggle("limbo-tablet-fallback",n),e.classList.toggle("limbo-desktop-fallback",!t&&!n)}observeResize(){if(!this.supportsContainerQueries)if("ResizeObserver"in window){const e=new ResizeObserver(e=>{e.forEach(e=>{this.applyResponsiveClasses(e.target)})});document.querySelectorAll(".limbo-component-container-wrapper").forEach(t=>{e.observe(t)})}else window.addEventListener("resize",()=>{document.querySelectorAll(".limbo-component-container-wrapper").forEach(e=>{this.applyResponsiveClasses(e)})})}};function B(e={}){const{useContainerQuery:t=!1,containerElement:n=null}=e,[l,r]=y.useState(()=>{const e=t&&n?U.getContainerWidth(n):"undefined"!=typeof window?window.innerWidth:0,l="undefined"!=typeof window&&(e<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)),r="undefined"!=typeof window&&("ontouchstart"in window||navigator.maxTouchPoints>0);return{isMobile:l,isTouch:r,isTablet:"undefined"!=typeof window&&(e>768&&e<=1024&&r),orientation:"undefined"!=typeof window?window.innerHeight>window.innerWidth?"portrait":"landscape":"portrait",viewport:{width:"undefined"!=typeof window?window.innerWidth:0,height:"undefined"!=typeof window?window.innerHeight:0},container:{width:e,supportsContainerQueries:U.supportsContainerQueries}}});y.useEffect(()=>{if("undefined"==typeof window)return;const e=()=>{const e=window.innerWidth,l=window.innerHeight,a=t&&n?U.getContainerWidth(n):e,i=a<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),o="ontouchstart"in window||navigator.maxTouchPoints>0;r({isMobile:i,isTouch:o,isTablet:a>768&&a<=1024&&o,orientation:l>e?"portrait":"landscape",viewport:{width:e,height:l},container:{width:a,supportsContainerQueries:U.supportsContainerQueries}})};let l;const a=()=>{clearTimeout(l),l=setTimeout(e,150)};return window.addEventListener("resize",a),window.addEventListener("orientationchange",()=>{setTimeout(e,100)}),()=>{clearTimeout(l),window.removeEventListener("resize",a),window.removeEventListener("orientationchange",e)}},[t,n]);const a="portrait"===l.orientation,i="landscape"===l.orientation,o=l.isMobile||l.isTablet&&a;return{...l,isPortrait:a,isLandscape:i,isCompactMode:o,isMobileSize:l.viewport.width<=640,isTabletSize:l.viewport.width>640&&l.viewport.width<=1024,isDesktopSize:l.viewport.width>1024,deviceClass:l.isMobile?"mobile":l.isTablet?"tablet":"desktop"}}function W({tabs:e,active:t,onChange:n}){const{isMobile:l,isTouch:r}=B(),a=["limbo-tabs","lb:flex","lb:gap-4","lb:border-b-2","lb:border-brand-blue-200","lb:mb-6",l&&"lb:overflow-x-auto lb:scrollbar-none"].filter(Boolean).join(" "),i=e=>{const t=["limbo-tab","lb:relative","lb:px-6","lb:py-2","lb:font-medium","lb:text-brand-blue-1000","lb:bg-transparent","lb:border-0","lb:border-b-2","lb:cursor-pointer","lb:transition-all","lb:duration-200","lb:hover:text-pink-1000","lb:focus:outline-none","lb:focus-visible:ring-2","lb:focus-visible:ring-brand-blue-400","lb:focus-visible:ring-offset-2"];return e?t.push("lb:border-b-brand-blue-1000","lb:font-semibold","limbo-active"):t.push("lb:border-b-transparent"),l&&t.push("lb:min-w-[120px]","lb:min-h-[44px]","lb:text-base","lb:shrink-0"),r&&t.push("lb:touch-manipulation"),t.join(" ")};return F.jsx("div",{className:a,role:"tablist","aria-label":"Opciones de navegación",style:l?{WebkitOverflowScrolling:"touch",scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,children:e.map(l=>{const a=t===l.id;return!a&&l.hideNonActive?null:F.jsx("button",{"data-tab-id":l.id,onClick:()=>n(l.id),onKeyDown:t=>((t,l)=>{const r=e.findIndex(e=>e.id===l);let a=r;switch(t.key){case"ArrowLeft":case"ArrowUp":t.preventDefault(),a=r>0?r-1:e.length-1;break;case"ArrowRight":case"ArrowDown":t.preventDefault(),a=r<e.length-1?r+1:0;break;case"Home":t.preventDefault(),a=0;break;case"End":t.preventDefault(),a=e.length-1;break;case"Enter":case" ":return t.preventDefault(),void n(l);default:return}const i=e[a];i&&!i.hideNonActive&&(n(i.id),setTimeout(()=>{const e=document.querySelector(`[data-tab-id="${i.id}"]`);e&&e.focus()},0))})(t,l.id),className:i(a),role:"tab","aria-selected":a,"aria-controls":`tabpanel-${l.id}`,tabIndex:a?0:-1,id:`tab-${l.id}`,style:r?{WebkitTapHighlightColor:"transparent"}:void 0,children:l.label},l.id)})})}const q=new Map,V=new Map,H=18e5,K=async e=>{if(!e)return Promise.reject(new Error("No URL provided"));const t=q.get(e);if(t&&Date.now()-t.timestamp<H)return t.blobUrl;if(V.has(e))return V.get(e);const n=(async()=>{try{let n,l,r=0;for(;r<2;)try{if(n=await fetch(e),!n.ok)throw new Error(`Failed to fetch image: ${n.status}`);break}catch(t){if(l=t,r+=1,r>=2)throw l}const a=await n.blob(),i=URL.createObjectURL(a);return q.set(e,{blobUrl:i,timestamp:Date.now(),size:a.size}),i}finally{V.delete(e)}})();return V.set(e,n),n},G=e=>{const t=q.get(e);return t&&Date.now()-t.timestamp<H?t.blobUrl:e},Q=e=>{const t=q.get(e);return t&&Date.now()-t.timestamp<H},X=async(e,t=4)=>{const n=new Map,l=e.filter(e=>!Q(e));if(0===l.length)return e.forEach(e=>{n.set(e,G(e))}),n;const r=[];for(let a=0;a<l.length;a+=t)r.push(l.slice(a,a+t));for(const a of r){(await Promise.allSettled(a.map(async e=>({url:e,blobUrl:await K(e)})))).forEach(e=>{"fulfilled"===e.status&&n.set(e.value.url,e.value.blobUrl)})}return n},Y="https://led-dev-limbo-dev.eu.els.local",J="https://limbo.lefebvre.es";let Z={publicKey:null,token:null,authMode:null,tokenEndpoint:null,tokenProvider:null,prod:!1};function ee({prod:e=!1}={}){return e?J:Y}function te(){return{...Z}}async function ne({endpoint:e,method:t="GET",body:n=null,prod:l=!1,basePath:r="",customHeaders:a={},isFormData:i=!1,useJWT:o=!0}){try{const s=l||Z.prod,c=await async function({isFormData:e=!1,useJWT:t=!0,customHeaders:n={}}={}){const l={"Access-Control-Allow-Origin":`${window.location.hostname||"*"}`};e||(l["Content-Type"]="application/json");let r=Z.token;if(t){if("jwt"===Z.authMode&&Z.tokenProvider&&!r)try{console.log("🔑 Calling tokenProvider..."),r=await Z.tokenProvider(),console.log("✅ Token obtained from tokenProvider"),Z.token=r}catch(a){throw console.error("❌ tokenProvider failed:",a),new Error("Failed to obtain token from tokenProvider: "+a.message)}else if("session"===Z.authMode&&!r)try{const e=ee(Z),t=Z.tokenEndpoint||"/auth/token",n=await fetch(`${e}${t}`,{method:"POST",headers:{"Content-Type":"application/json","Access-Control-Allow-Origin":`${window.location.hostname||"*"}`},body:JSON.stringify({public_key:Z.publicKey}),credentials:"include"});if(!n.ok)throw new Error(`Session auth failed: ${n.status}`);r=(await n.json()).token,Z.token=r}catch(a){throw console.error("❌ Session authentication failed:",a),new Error("Failed to authenticate with session. User must be logged in.")}r?l.Authorization=`Bearer ${r}`:console.warn("⚠️ No JWT token available:",{authMode:Z.authMode,hasPublicKey:!!Z.publicKey,hasTokenProvider:!!Z.tokenProvider})}return e&&delete l["Content-Type"],{...l,...n}}({isFormData:i,useJWT:o,customHeaders:a});"GET"===t&&!n&&c["Content-Type"]&&delete c["Content-Type"];const u=await fetch(`${ee({prod:s})}${r}${e}`,{method:t,headers:c,body:n?i?n:JSON.stringify(n):void 0,credentials:"include"});if(204===u.status)return{success:!0,data:null,message:"No content",httpCode:204,timestamp:(new Date).toISOString()};if(!u.ok){let e=`HTTP ${u.status}: ${u.statusText}`,t=null;try{const n=await u.json();t=n,n.error?e=`${n.error.code}: ${n.error.message}`:n.message&&(e=n.message)}catch{}throw 401===u.status&&t&&("token_expired"===t.error||t.message&&t.message.includes("expired")||t.message&&t.message.includes("caducado")||t.error&&t.error.includes("expired"))&&window.dispatchEvent(new CustomEvent("tokenExpiredError",{detail:{error:{response:{status:401,data:t}}}})),new Error(e)}return u.json()}catch(s){throw new Error(`API Error: ${s.message}`)}}function le(){const e=te();return e?.prod||!1?"https://limbo.lefebvre.es":"https://led-dev-limbo-dev.eu.els.local"}function re(e){if(!e?.id)return null;return`${le()}/api/assets/${e.id}/download`}function ae(e){if(!e)return null;if(e.startsWith("http://")||e.startsWith("https://"))return e;if(e.startsWith("/")){return`${le()}${e}`}return e}function ie(e){if(!e?.success||!e?.data)return{result:null};const t=e.data;return{result:{id:t.id,filename:t.filename||t.original_filename,mime_type:t.mime_type,file_size:t.file_size,width:t.width,height:t.height,upload_date:t.upload_date||t.created_at,processed_date:t.processed_date,processing_status:t.processing_status||t.status,url:ae(t.url)||re(t),url_webp:ae(t.url_webp),url_original:ae(t.url_original),format:t.format,format_original:t.format_original,permanent:t.permanent??!0,expires_at:t.expires_at,metadata:t.metadata||{},asset_type:t.asset_type||null,asset_subtype:t.asset_subtype||null,thumbnail_url:ae(t.thumbnail_url)||null,variants:oe(t.variants||[]),variants_count:t.variants_count||t.variants?.length||0}}}function oe(e){return Array.isArray(e)?e.map(e=>({id:e.id,name:e.name,width:e.width,height:e.height,format:e.format||e.output_format,file_size:e.file_size,crop_params:e.crop_params,url:ae(e.url),permanent:e.permanent??!0,expires_at:e.expires_at,created_at:e.created_at})):[]}function se(e){if(!e?.success||!e?.data)return{result:null};const t=e.data;if(t.id&&t.url&&t.name&&!t.processing_mode&&!t.variants)return console.log("[adaptVariantGenerationFromV2] Detectado formato de /variants/upload"),{result:{id:t.id,name:t.name,width:t.width,height:t.height,format:t.format,file_size:t.file_size,url:t.url,urlSigned:t.url,status:"completed",created_at:t.created_at||(new Date).toISOString()}};if("sync"===t.processing_mode&&t.variants&&t.variants.length>0){const e=t.variants[0];return{result:{id:e.id||null,name:e.name,width:parseInt(e.size?.split("x")[0])||e.width,height:parseInt(e.size?.split("x")[1])||e.height,format:e.format,file_size:e.file_size,url:e.url,urlSigned:e.url,status:e.status,asset_id:t.asset_id,created_at:e.created_at||(new Date).toISOString(),all_variants:t.variants}}}return{result:{job_id:t.job_id,asset_id:t.asset_id,variants_requested:t.variants_requested||[],processing_mode:t.processing_mode||"async",estimated_completion:t.estimated_completion,variant_statuses:(t.variant_statuses||t.variants||[]).map(e=>({name:e.name,status:e.status,size:e.expected_size||e.size,format:e.format}))}}}function ce(e){if(e.message&&!e.message.includes("API Error:"))return e;let t=e.message||"Unknown API error";return t.startsWith("API Error: ")&&(t=t.substring(11)),new Error(t)}const ue="/api";async function de(e={}){try{const t={url_expires:"0",...e},n=`/assets?${new URLSearchParams(t).toString()}`;return function(e){if(!e?.success||!Array.isArray(e?.data?.data))return{result:[]};const t={result:e.data.data.map(e=>({id:e.id,filename:e.filename||e.original_filename,mime_type:e.mime_type,file_size:e.file_size,width:e.width,height:e.height,upload_date:e.upload_date||e.created_at,processing_status:e.processing_status||e.status,variants:e.variants_count&&(oe(e.variants)||oe(e.image_variants))||[],url:ae(e.url)||re(e),url_webp:ae(e.url_webp),format:e.format,permanent:e.permanent??!0,expires_at:e.expires_at,folder:e.folder||null,asset_type:e.asset_type||null,asset_subtype:e.asset_subtype||null,thumbnail_url:ae(e.thumbnail_url)||null,metadata:e.metadata||{},variants_count:e.variants_count||0}))};return e.data.pagination&&(t.pagination={page:e.data.pagination.page,limit:e.data.pagination.limit,total:e.data.pagination.total,pages:e.data.pagination.pages}),t}(await ne({endpoint:n,method:"GET",basePath:ue,useJWT:!0}))}catch(t){throw ce(t)}}async function be(e,t=null,n=!1,l=null){try{const r=new FormData;r.append("file",e),t&&r.append("uploaded_by",t),n&&r.append("store_original",n.toString()),l&&r.append("folder",l);return function(e){if(!e?.success||!e?.data)return{result:null};const t=e.data;return{result:{id:t.id,filename:t.filename||t.original_filename,mime_type:t.mime_type,file_size:t.file_size,width:t.width,height:t.height,status:t.status,upload_date:t.created_at,url:ae(t.url),url_webp:ae(t.url_webp),url_original:ae(t.url_original),format:t.format,format_original:t.format_original,permanent:t.permanent??!0,folder:t.folder||null,processing:t.processing||{master_webp:"processing"===t.status?"queued":"completed",variants:"processing"===t.status?"queued":"completed"},asset_type:t.asset_type||null,asset_subtype:t.asset_subtype||null,thumbnail_url:ae(t.thumbnail_url)||null,checksum:t.checksum,storage_path:t.storage_path_base,metadata:t.metadata||{}}}}(await ne({endpoint:"/assets",method:"POST",body:r,basePath:ue,isFormData:!0,useJWT:!0}))}catch(r){throw ce(r)}}async function me(e,t=0){try{const l=new URLSearchParams({url_expires:t.toString()}),r=await ne({endpoint:`/assets/${e}/variants?${l}`,method:"GET",basePath:ue,useJWT:!0});return n=r,n?.success&&Array.isArray(n?.data?.variants)?{result:n.data.variants.map(e=>({id:e.id,name:e.filename||e.name||`Variante ${e.id}`,filename:e.filename,mime_type:e.mime_type,format:e.format||e.output_format||(e.mime_type?e.mime_type.split("/")[1]:"jpg"),file_size:e.file_size,width:e.width,height:e.height,upload_date:e.upload_date||e.created_at,processing_status:e.processing_status||e.status,url:ae(e.url)||re(e),permanent:e.permanent??!0,expires_at:e.expires_at,metadata:e.metadata||{},crop_data:e.crop_data||{},crop_params:e.crop_params||e.crop_data||{},parent_asset_id:e.parent_asset_id||n.data.asset_id,variant_type:e.variant_type||"crop"}))}:{result:[]}}catch(l){throw ce(l)}var n}function he(){const[e,t]=y.useState({}),[n,l]=y.useState({}),[r,a]=y.useState({}),i=y.useCallback(async r=>{if(r&&!n[r]){if(e[r])return e[r];l(e=>({...e,[r]:!0})),a(e=>({...e,[r]:null}));try{const e=await me(r),n=e?.result||[];return t(e=>({...e,[r]:n})),n}catch(i){return console.error("Error loading variants:",i),a(e=>({...e,[r]:i.message})),[]}finally{l(e=>({...e,[r]:!1}))}}},[e,n]),o=y.useCallback(t=>e[t]||[],[e]),s=y.useCallback(e=>n[e]||!1,[n]),c=y.useCallback(e=>r[e]||null,[r]),u=y.useCallback(e=>{t(t=>{const n={...t};return delete n[e],n}),l(t=>{const n={...t};return delete n[e],n}),a(t=>{const n={...t};return delete n[e],n})},[]),d=y.useCallback(async e=>(u(e),await i(e)),[u,i]),b=y.useCallback(async(e,n)=>{try{return await async function(e,t){try{return await ne({endpoint:`/assets/${e}/variants/${t}`,method:"DELETE",basePath:ue,useJWT:!0})}catch(n){throw ce(n)}}(e,n),t(t=>{const l=t[e]||[];return{...t,[e]:l.filter(e=>e.id!==n)}}),{success:!0}}catch(l){return console.error("Error deleting variant:",l),{success:!1,error:l.message}}},[]);return{loadVariants:i,getVariants:o,isLoading:s,getError:c,clearVariants:u,refreshVariants:d,removeVariant:b}}function pe({isOpen:e=!1,onClose:t,title:n="",subtitle:l="",headerActions:r=null,footerHints:a=null,ariaLabel:i="Visor de archivo",children:o}){const s=y.useRef(null),c=y.useCallback(e=>{"Escape"===e.key&&(e.preventDefault(),t?.())},[t]);return y.useEffect(()=>{if(e)return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[e,c]),y.useEffect(()=>(document.body.style.overflow=e?"hidden":"",()=>{document.body.style.overflow=""}),[e]),e?F.jsxs("div",{className:"lb:fixed lb:inset-0 lb:bg-black/95 lb:z-[10000] lb:flex lb:flex-col",role:"dialog","aria-modal":"true","aria-label":i,children:[F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between lb:px-4 lb:py-3 lb:bg-black/50 lb:backdrop-blur-sm",children:[F.jsxs("div",{className:"lb:flex-1 lb:min-w-0",children:[n&&F.jsx("h2",{className:"lb:text-white lb:font-medium lb:text-sm lb:truncate",children:n.includes(".")?n.split(".").slice(0,-1).join("."):n}),l&&F.jsx("p",{className:"lb:text-gray-400 lb:text-xs lb:mt-0.5 lb:truncate",children:l})]}),r&&F.jsx("div",{className:"lb:flex lb:items-center lb:gap-2 lb:mx-4",children:r}),F.jsx("button",{type:"button",onClick:t,className:"lb:w-10 lb:h-10 lb:flex lb:items-center lb:justify-center lb:rounded-lg lb:bg-white/10 lb:hover:bg-red-1000/80 lb:text-white lb:transition-colors","aria-label":"Cerrar visor (ESC)",title:"Cerrar (ESC)",children:F.jsx("svg",{className:"lb:w-6 lb:h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),F.jsx("div",{ref:s,className:"lb:flex-1 lb:overflow-hidden lb:flex lb:items-center lb:justify-center",onClick:e=>{e.target===s.current&&t?.()},children:o}),a&&F.jsx("div",{className:"lb:px-4 lb:py-2 lb:bg-black/50 lb:backdrop-blur-sm lb:text-center",children:F.jsx("p",{className:"lb:text-gray-400 lb:text-xs",children:a})})]}):null}function fe({isOpen:e=!1,src:t,title:n="",subtitle:l="",onClose:r}){const[a,i]=y.useState(!1),[o,s]=y.useState(!0),c=y.useRef(null);y.useEffect(()=>{e&&(i(!1),s(!0))},[e]);const u=y.useCallback(e=>{" "===e.key&&c.current&&(e.preventDefault(),c.current.paused?c.current.play():c.current.pause())},[]);y.useEffect(()=>{if(e)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,u]);const d=F.jsxs("button",{type:"button",onClick:async()=>{if(t)try{const e=await fetch(t,{mode:"cors"});if(!e.ok)throw new Error(`HTTP ${e.status}`);const l=await e.blob(),r=URL.createObjectURL(l),a=document.createElement("a");a.href=r,a.download=n||"video",a.style.display="none",document.body.appendChild(a),a.click(),setTimeout(()=>{URL.revokeObjectURL(r),document.body.removeChild(a)},100)}catch{window.open(t,"_blank")}},className:"lb:flex lb:items-center lb:gap-2 lb:px-3 lb:py-1.5 lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:text-sm lb:transition-colors","aria-label":"Descargar video",title:"Descargar video",children:[F.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),F.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Descargar"})]}),b=F.jsxs("span",{children:[F.jsxs("span",{className:"lb:hidden lb:sm:inline",children:[F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"Espacio"})," ","para pausar/reproducir •"," "]}),F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]});return F.jsx(pe,{isOpen:e,onClose:r,title:n,subtitle:l,ariaLabel:"Visor de video",headerActions:d,footerHints:b,children:a?F.jsxs("div",{className:"lb:text-center lb:text-white",children:[F.jsx("svg",{className:"lb:w-16 lb:h-16 lb:mx-auto lb:mb-4 lb:text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),F.jsx("p",{className:"lb:text-lg lb:font-medium",children:"No se puede reproducir el video"}),F.jsx("p",{className:"lb:text-gray-400 lb:text-sm lb:mt-2",children:n})]}):F.jsxs("div",{className:"lb:relative lb:w-full lb:max-w-5xl lb:max-h-full lb:flex lb:items-center lb:justify-center lb:px-4",children:[o&&F.jsx("div",{className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center",children:F.jsx("div",{className:"lb:w-12 lb:h-12 lb:border-4 lb:border-white/20 lb:border-t-white lb:rounded-full lb:animate-spin"})}),F.jsx("video",{ref:c,src:t,className:"lb:max-w-full lb:max-h-[calc(100vh-140px)] lb:h-full lb:w-full lb:rounded-lg",controls:!0,autoPlay:!0,preload:"metadata",onCanPlay:()=>s(!1),onError:()=>{i(!0),s(!1)},children:"Tu navegador no soporta la reproduccion de video."})]})})}function ge({isOpen:e=!1,src:t,title:n="",subtitle:l="",onClose:r}){const[a,i]=y.useState(!1),[o,s]=y.useState(!1),[c,u]=y.useState(0),[d,b]=y.useState(0),m=y.useRef(null);y.useEffect(()=>{e&&(s(!1),i(!1),u(0),b(0))},[e]);const h=y.useCallback(()=>{m.current&&(m.current.paused?m.current.play():m.current.pause())},[]),p=y.useCallback(e=>{" "===e.key&&(e.preventDefault(),h())},[h]);y.useEffect(()=>{if(e)return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[e,p]);const f=e=>{if(!e||isNaN(e))return"0:00";return`${Math.floor(e/60)}:${Math.floor(e%60).toString().padStart(2,"0")}`},g=F.jsxs("button",{type:"button",onClick:async()=>{if(t)try{const e=await fetch(t,{mode:"cors"});if(!e.ok)throw new Error(`HTTP ${e.status}`);const l=await e.blob(),r=URL.createObjectURL(l),a=document.createElement("a");a.href=r,a.download=n||"audio",a.style.display="none",document.body.appendChild(a),a.click(),setTimeout(()=>{URL.revokeObjectURL(r),document.body.removeChild(a)},100)}catch{window.open(t,"_blank")}},className:"lb:flex lb:items-center lb:gap-2 lb:px-3 lb:py-1.5 lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:text-sm lb:transition-colors","aria-label":"Descargar audio",title:"Descargar audio",children:[F.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),F.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Descargar"})]}),v=F.jsxs("span",{children:[F.jsxs("span",{className:"lb:hidden lb:sm:inline",children:[F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"Espacio"})," ","para pausar/reproducir •"," "]}),F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]});return F.jsx(pe,{isOpen:e,onClose:r,title:n,subtitle:l,ariaLabel:"Visor de audio",headerActions:g,footerHints:v,children:o?F.jsxs("div",{className:"lb:text-center lb:text-white",children:[F.jsx("svg",{className:"lb:w-16 lb:h-16 lb:mx-auto lb:mb-4 lb:text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),F.jsx("p",{className:"lb:text-lg lb:font-medium",children:"No se puede reproducir el audio"}),F.jsx("p",{className:"lb:text-gray-400 lb:text-sm lb:mt-2",children:n})]}):F.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-8 lb:w-full lb:max-w-md lb:px-4",children:[F.jsxs("div",{className:"lb:relative",children:[F.jsx("div",{className:"lb:w-40 lb:h-40 lb:flex lb:items-center lb:justify-center lb:rounded-full lb:bg-linear-to-br lb:from-purple-600/30 lb:to-blue-600/30 lb:border-2 lb:border-white/10 "+(a?"lb:animate-pulse":""),children:F.jsx("span",{className:"icon icon-audio lb:text-white lb:w-16 lb:h-16"})}),F.jsx("button",{type:"button",onClick:h,className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center lb:rounded-full lb:bg-black/0 lb:hover:bg-white/10 lb:transition-colors lb:cursor-pointer","aria-label":a?"Pausar":"Reproducir",children:F.jsx("div",{className:"lb:w-14 lb:h-14 lb:rounded-full lb:bg-white/90 lb:flex lb:items-center lb:justify-center lb:shadow-lg",children:F.jsx("span",{className:`icon ${a?"icon-pause":"icon-play"} icon--lg lb:text-gray-800 ${a?"":"lb:ml-0.5"}`})})})]}),F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-3 lb:text-white lb:text-sm",children:[F.jsx("span",{className:"lb:font-mono lb:min-w-[3ch] lb:text-right",children:f(d)}),F.jsx("div",{className:"lb:w-64 lb:h-2 lb:bg-white/20 lb:rounded-full lb:cursor-pointer lb:relative",onClick:e=>{if(!m.current||!c)return;const t=e.currentTarget.getBoundingClientRect(),n=(e.clientX-t.left)/t.width;m.current.currentTime=n*c},role:"slider","aria-label":"Progreso de audio","aria-valuenow":d,"aria-valuemin":0,"aria-valuemax":c,tabIndex:0,children:F.jsx("div",{className:"lb:h-full lb:bg-purple-500 lb:rounded-full lb:transition-all lb:duration-100",style:{width:c>0?d/c*100+"%":"0%"}})}),F.jsx("span",{className:"lb:font-mono lb:min-w-[3ch] lb:text-gray-400",children:f(c)})]}),F.jsx("audio",{ref:m,src:t,onPlay:()=>i(!0),onPause:()=>i(!1),onTimeUpdate:()=>b(m.current?.currentTime||0),onLoadedMetadata:()=>u(m.current?.duration||0),onEnded:()=>{i(!1),b(0)},onError:()=>s(!0),preload:"metadata"})]})})}function ye({isOpen:e=!1,src:t,title:n="",subtitle:l="",onClose:r}){const[a,i]=y.useState(!0),[o,s]=y.useState(!1),[c,u]=y.useState(null),d=y.useRef(null);y.useEffect(()=>{if(!e||!t)return;let n=!1;return i(!0),s(!1),fetch(t).then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.blob()}).then(e=>{if(n)return;d.current&&URL.revokeObjectURL(d.current);const t=URL.createObjectURL(e);d.current=t,u(t)}).catch(()=>{n||(s(!0),i(!1))}),()=>{n=!0}},[t,e]),y.useEffect(()=>()=>{d.current&&(URL.revokeObjectURL(d.current),d.current=null)},[]);const b=()=>{if(!t)return;const e=document.createElement("a");e.href=t,e.download=n||"document.pdf",e.target="_blank",document.body.appendChild(e),e.click(),document.body.removeChild(e)},m=F.jsxs("button",{type:"button",onClick:b,className:"lb:flex lb:items-center lb:gap-2 lb:px-3 lb:py-1.5 lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:text-sm lb:transition-colors","aria-label":"Abrir PDF en nueva pestaña",title:"Abrir PDF en nueva pestaña",children:[F.jsx("span",{className:"icon icon-arrow-left-white lb:rotate-40 lb:me-0 lb:pe-0 icon--sm"}),F.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Abrir en nueva pestaña"})]}),h=F.jsxs("span",{children:[F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]});return F.jsx(pe,{isOpen:e,onClose:r,title:n,subtitle:l,ariaLabel:"Visor de PDF",headerActions:m,footerHints:h,children:o?F.jsxs("div",{className:"lb:text-center lb:text-white",children:[F.jsx("svg",{className:"lb:w-16 lb:h-16 lb:mx-auto lb:mb-4 lb:text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),F.jsx("p",{className:"lb:text-lg lb:font-medium",children:"No se puede mostrar el PDF"}),F.jsx("p",{className:"lb:text-gray-400 lb:text-sm lb:mt-2",children:n}),F.jsx("button",{type:"button",onClick:b,className:"lb:mt-4 lb:px-6 lb:py-2.5 lb:bg-white lb:text-gray-900 lb:rounded-lg lb:font-medium lb:text-sm lb:hover:bg-gray-100 lb:transition-colors",children:"Descargar PDF"})]}):F.jsxs("div",{className:"lb:relative lb:w-full lb:h-full lb:px-4 lb:py-2",children:[a&&F.jsx("div",{className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center lb:z-10",children:F.jsx("div",{className:"lb:w-12 lb:h-12 lb:border-4 lb:border-white/20 lb:border-t-white lb:rounded-full lb:animate-spin"})}),c&&F.jsx("iframe",{src:c,title:n||"PDF Viewer",className:"lb:w-full lb:h-full lb:rounded-lg lb:bg-white",onLoad:()=>i(!1),onError:()=>{s(!0),i(!1)}})]})})}const ve={"application/pdf":{symbol:"icon-doc-pdf",label:"PDF",color:"#dc2626"},"application/msword":{symbol:"icon-doc-word",label:"DOC",color:"#2563eb"},"application/vnd.openxmlformats-officedocument.wordprocessingml.document":{symbol:"icon-doc-word",label:"DOCX",color:"#2563eb"},"application/vnd.ms-excel":{symbol:"icon-doc-xls",label:"XLS",color:"#16a34a"},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":{symbol:"icon-doc-xls",label:"XLSX",color:"#16a34a"},"application/vnd.ms-powerpoint":{symbol:"icon-doc-ppt",label:"PPT",color:"#ea580c"},"application/vnd.openxmlformats-officedocument.presentationml.presentation":{symbol:"icon-doc-ppt",label:"PPTX",color:"#ea580c"},"text/plain":{symbol:"icon-doc-text",label:"TXT",color:"#6b7280"},"text/csv":{symbol:"icon-doc-report",label:"CSV",color:"#16a34a"},"audio/mp3":{symbol:"icon-support-person",label:"MP3",color:"#0891b2"},"audio/mpeg":{symbol:"icon-support-person",label:"MP3",color:"#0891b2"},"audio/wav":{symbol:"icon-support-person",label:"WAV",color:"#0891b2"},"audio/ogg":{symbol:"icon-support-person",label:"OGG",color:"#0891b2"},"video/mp4":{symbol:"icon-video",label:"MP4",color:"#7c3aed"},"video/x-msvideo":{symbol:"icon-video",label:"AVI",color:"#7c3aed"},"video/x-matroska":{symbol:"icon-video",label:"MKV",color:"#7c3aed"},default:{symbol:"icon-clip",label:"FILE",color:"#6b7280"}},xe={video:{symbol:"🎬",label:"VIDEO",color:"#7c3aed"},audio:{symbol:"🎵",label:"AUDIO",color:"#0891b2"},document:{symbol:"📄",label:"DOC",color:"#6b7280"},image:{symbol:"🖼️",label:"IMG",color:"#0ea5e9"}};function we(e,t){return ve[e]?ve[e]:t&&xe[t]?xe[t]:e?.startsWith("video/")?xe.video:e?.startsWith("audio/")?xe.audio:e?.startsWith("image/")?xe.image:ve.default}function ke(e){if(!e||0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(1024));return Math.round(e/Math.pow(1024,t)*100)/100+" "+["Bytes","KB","MB","GB"][t]}function Ce({file:e,mimeType:t,category:n}){const l=we(t,n),r=e?.name||"archivo",a=ke(e?.size);return F.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:justify-center lb:min-h-50",children:[F.jsx("div",{className:"lb:w-24 lb:h-24 lb:flex lb:items-center lb:justify-center lb:bg-gray-100 lb:rounded-xl lb:mb-4",children:F.jsx("span",{className:`icon ${l.symbol} lb:h-[55%] lb:w-[55%] lb:max-h-50 lb:max-w-50`,"aria-hidden":"true"})}),F.jsx("p",{className:"lb:text-sm lb:font-medium lb:text-gray-800 lb:text-center lb:max-w-full lb:truncate lb:px-4",children:r}),F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2 lb:mt-3",children:[F.jsx("span",{className:"lb:text-xs lb:text-gray-500",children:a}),F.jsx("span",{className:"lb:text-xs lb:font-bold lb:uppercase lb:px-2 lb:py-0.5 lb:rounded",style:{backgroundColor:l.color,color:"white"},children:l.label})]})]})}function Se({isOpen:e=!1,src:t,title:n="",subtitle:l="",mimeType:r="",fileSize:a=0,onClose:i}){const o=we(r),s=F.jsxs("span",{children:[F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]});return F.jsx(pe,{isOpen:e,onClose:i,title:n,subtitle:l,ariaLabel:"Visor de documento",footerHints:s,children:F.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-6 lb:text-center lb:px-4",children:[F.jsx("div",{className:"lb:w-32 lb:h-32 lb:flex lb:items-center lb:justify-center lb:bg-white/5 lb:rounded-2xl lb:border lb:border-white/10",children:F.jsx("span",{className:`icon ${o.symbol}-white lb:min-w-16 lb:min-h-16`,"aria-hidden":"true"})}),F.jsx("span",{className:"lb:text-sm lb:font-bold lb:uppercase lb:px-4 lb:py-1.5 lb:rounded-full",style:{backgroundColor:o.color,color:"white"},children:o.label}),F.jsxs("div",{children:[F.jsx("p",{className:"lb:text-white lb:font-medium lb:text-lg lb:max-w-md lb:truncate",children:n}),a>0&&F.jsx("p",{className:"lb:text-gray-400 lb:text-sm lb:mt-1",children:ke(a)})]}),F.jsx("p",{className:"lb:text-gray-500 lb:text-sm",children:"Este tipo de archivo no se puede previsualizar"}),F.jsxs("button",{type:"button",onClick:async()=>{if(t)try{const e=await fetch(t,{mode:"cors"});if(!e.ok)throw new Error(`HTTP ${e.status}`);const l=await e.blob(),r=URL.createObjectURL(l),a=document.createElement("a");a.href=r,a.download=n||"document",a.style.display="none",document.body.appendChild(a),a.click(),setTimeout(()=>{URL.revokeObjectURL(r),document.body.removeChild(a)},100)}catch{window.open(t,"_blank")}},className:"lb:flex lb:items-center lb:gap-2 lb:px-8 lb:py-3 lb:bg-white lb:text-gray-900 lb:rounded-lg lb:font-medium lb:text-sm lb:hover:bg-gray-100 lb:transition-colors lb:shadow-lg","aria-label":"Descargar archivo",children:[F.jsx("svg",{className:"lb:w-5 lb:h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),"Descargar archivo"]})]})})}const je=2097152;function Ne({isOpen:e=!1,src:t,title:n="",subtitle:l="",mimeType:r="",fileSize:a=0,onClose:i}){const[o,s]=y.useState(!0),[c,u]=y.useState(!1),[d,b]=y.useState(""),[m,h]=y.useState(!1);y.useEffect(()=>{if(!e||!t)return;let l=!1;return s(!0),u(!1),b(""),h(!1),fetch(t).then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.blob()}).then(e=>{if(l)return;const t=e.size>je?e.slice(0,je):e;return e.size>je&&h(!0),t.text()}).then(e=>{if(!l){if("application/json"===r||n.endsWith(".json"))try{const t=JSON.parse(e);e=JSON.stringify(t,null,2)}catch{}b(e),s(!1)}}).catch(()=>{l||(u(!0),s(!1))}),()=>{l=!0}},[t,e,r,n]);const p=async()=>{if(t)try{const e=await fetch(t,{mode:"cors"});if(!e.ok)throw new Error(`HTTP ${e.status}`);const l=await e.blob(),r=URL.createObjectURL(l),a=document.createElement("a");a.href=r,a.download=n||"file.txt",a.style.display="none",document.body.appendChild(a),a.click(),setTimeout(()=>{URL.revokeObjectURL(r),document.body.removeChild(a)},100)}catch{window.open(t,"_blank")}},f=d?d.split("\n").length:0,g=F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2",children:[f>0&&F.jsxs("span",{className:"lb:text-gray-400 lb:text-xs",children:[f," ",1===f?"linea":"lineas"]}),F.jsxs("button",{type:"button",onClick:p,className:"lb:flex lb:items-center lb:gap-2 lb:px-3 lb:py-1.5 lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:text-sm lb:transition-colors","aria-label":"Descargar archivo",title:"Descargar archivo",children:[F.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),F.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Descargar"})]})]}),v=F.jsxs("span",{children:[F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]});return F.jsx(pe,{isOpen:e,onClose:i,title:n,subtitle:l,ariaLabel:"Visor de texto",headerActions:g,footerHints:v,children:c?F.jsxs("div",{className:"lb:text-center lb:text-white",children:[F.jsx("svg",{className:"lb:w-16 lb:h-16 lb:mx-auto lb:mb-4 lb:text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),F.jsx("p",{className:"lb:text-lg lb:font-medium",children:"No se puede mostrar el archivo"}),F.jsx("p",{className:"lb:text-gray-400 lb:text-sm lb:mt-2",children:n}),F.jsx("button",{type:"button",onClick:p,className:"lb:mt-4 lb:px-6 lb:py-2.5 lb:bg-white lb:text-gray-900 lb:rounded-lg lb:font-medium lb:text-sm lb:hover:bg-gray-100 lb:transition-colors",children:"Descargar archivo"})]}):o?F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("div",{className:"lb:w-12 lb:h-12 lb:border-4 lb:border-white/20 lb:border-t-white lb:rounded-full lb:animate-spin"})}):F.jsxs("div",{className:"lb:relative lb:w-full lb:h-full lb:px-4 lb:py-2 lb:overflow-hidden lb:flex lb:flex-col",children:[m&&F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2 lb:px-4 lb:py-2 lb:bg-yellow-900/50 lb:border lb:border-yellow-700/50 lb:rounded-lg lb:mb-2 lb:shrink-0",children:[F.jsx("svg",{className:"lb:w-4 lb:h-4 lb:text-yellow-400 lb:shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01"})}),F.jsx("span",{className:"lb:text-yellow-300 lb:text-xs",children:"Archivo truncado (mostrando primeros 2MB). Descarga el archivo completo para ver todo el contenido."})]}),F.jsx("div",{className:"lb:flex-1 lb:overflow-auto lb:rounded-lg lb:bg-gray-900/80 lb:border lb:border-white/10",children:F.jsx("pre",{className:"lb:p-4 lb:text-sm lb:text-gray-200 lb:font-mono lb:whitespace-pre-wrap lb:break-words lb:leading-relaxed lb:m-0",children:d})})]})})}function Ee({src:e,alt:t="Imagen",title:n="",subtitle:l="",onClose:r,isOpen:a=!1}){const[i,o]=y.useState(1),[s,c]=y.useState({x:0,y:0}),[u,d]=y.useState(!1),[b,m]=y.useState(!1),[h,p]=y.useState({x:0,y:0}),[f,g]=y.useState(!1),[v,x]=y.useState(!1),w=y.useRef(null),k=y.useRef(null);y.useEffect(()=>{a&&(o(1),c({x:0,y:0}),g(!1),x(!1))},[a]);const C=y.useCallback(()=>{o(e=>Math.min(e+.25,5)),c({x:0,y:0})},[]),S=y.useCallback(()=>{o(e=>Math.max(e-.25,.25)),c({x:0,y:0})},[]),j=y.useCallback(()=>{o(1),c({x:0,y:0})},[]),N=y.useCallback(()=>{o(1),c({x:0,y:0})},[]),E=y.useCallback(e=>{if((e.ctrlKey||e.metaKey)&&("+"===e.key||"="===e.key))return e.preventDefault(),void C();if((e.ctrlKey||e.metaKey)&&"-"===e.key)return e.preventDefault(),void S();if((e.ctrlKey||e.metaKey)&&"0"===e.key)return e.preventDefault(),void j();if(i>1){const t=50;switch(e.key){case"ArrowUp":e.preventDefault(),c(e=>({...e,y:e.y+t}));break;case"ArrowDown":e.preventDefault(),c(e=>({...e,y:e.y-t}));break;case"ArrowLeft":e.preventDefault(),c(e=>({...e,x:e.x+t}));break;case"ArrowRight":e.preventDefault(),c(e=>({...e,x:e.x-t}))}}},[C,S,j,i]),$=y.useCallback(e=>{(e.ctrlKey||e.metaKey)&&(e.preventDefault(),e.deltaY<0?C():S())},[C,S]),_=y.useCallback(e=>{i>1&&0===e.button&&(e.preventDefault(),d(!0),m(!1),p({x:e.clientX-s.x,y:e.clientY-s.y}))},[i,s]),T=y.useCallback(e=>{u&&(m(!0),c({x:e.clientX-h.x,y:e.clientY-h.y}))},[u,h]),z=y.useCallback(()=>{d(!1)},[]),L=y.useCallback(e=>{e.stopPropagation(),1!==i||b||(o(2),c({x:0,y:0})),m(!1)},[i,b]),A=y.useCallback(e=>{e.stopPropagation(),1===i?(o(2),c({x:0,y:0})):j()},[i,j]);y.useEffect(()=>{if(!a)return;document.addEventListener("keydown",E),document.addEventListener("mouseup",z),document.addEventListener("mousemove",T);const e=e=>{!e.ctrlKey&&!e.metaKey||"+"!==e.key&&"-"!==e.key&&"="!==e.key&&"0"!==e.key||e.preventDefault()};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",E),document.removeEventListener("mouseup",z),document.removeEventListener("mousemove",T),document.removeEventListener("keydown",e)}},[a,E,z,T]);const M=Math.round(100*i),P=F.jsxs(F.Fragment,{children:[F.jsx("button",{type:"button",onClick:S,disabled:i<=.25,className:"lb:w-8 lb:h-8 lb:flex lb:items-center lb:justify-center lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:disabled:opacity-30 lb:disabled:cursor-not-allowed lb:transition-colors","aria-label":"Reducir zoom",title:"Reducir zoom (Ctrl -)",children:F.jsx("svg",{className:"lb:w-5 lb:h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})}),F.jsxs("div",{className:"lb:w-20 lb:text-center lb:text-white lb:text-sm lb:font-medium lb:bg-white/10 lb:rounded-lg lb:px-2 lb:py-1.5 lb:cursor-pointer lb:hover:bg-white/20 lb:transition-colors",onClick:j,title:"Click para restablecer zoom",role:"button",tabIndex:0,onKeyDown:e=>"Enter"===e.key&&j(),children:[M,"%"]}),F.jsx("button",{type:"button",onClick:C,disabled:i>=5,className:"lb:w-8 lb:h-8 lb:flex lb:items-center lb:justify-center lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:disabled:opacity-30 lb:disabled:cursor-not-allowed lb:transition-colors","aria-label":"Aumentar zoom",title:"Aumentar zoom (Ctrl +)",children:F.jsx("svg",{className:"lb:w-5 lb:h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),F.jsx("button",{type:"button",onClick:N,className:"lb:w-8 lb:h-8 lb:flex lb:items-center lb:justify-center lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:transition-colors lb:ml-2","aria-label":"Ajustar a pantalla",title:"Ajustar a pantalla (Ctrl 0)",children:F.jsx("svg",{className:"lb:w-5 lb:h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})})]}),I=F.jsxs(F.Fragment,{children:[F.jsxs("span",{className:"lb:hidden lb:sm:inline",children:[F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"Ctrl"})," ","+ rueda para zoom •"," ",F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"Ctrl"})," ","+"," ",F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"+"})," ","/"," ",F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"-"})," ","zoom • Click para zoom • Doble click para restablecer • Flechas para mover •"," ",F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]}),F.jsx("span",{className:"lb:sm:hidden",children:"Click para zoom • Doble click para restablecer • ESC para cerrar"})]});return F.jsx(pe,{isOpen:a,onClose:r,title:n,subtitle:l,ariaLabel:"Visor de imagen",headerActions:P,footerHints:I,children:F.jsxs("div",{ref:w,className:`lb:w-full lb:h-full lb:overflow-hidden lb:flex lb:items-center lb:justify-center ${i>1?"lb:cursor-grab":"lb:cursor-zoom-in"} ${u?"lb:cursor-grabbing":""}`,onClick:e=>{e.target===w.current&&r?.()},onWheel:$,onMouseDown:_,children:[!f&&!v&&F.jsx("div",{className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center",children:F.jsx("div",{className:"lb:w-12 lb:h-12 lb:border-4 lb:border-white/20 lb:border-t-white lb:rounded-full lb:animate-spin"})}),v&&F.jsxs("div",{className:"lb:text-center lb:text-white",children:[F.jsx("svg",{className:"lb:w-16 lb:h-16 lb:mx-auto lb:mb-4 lb:text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),F.jsx("p",{className:"lb:text-lg lb:font-medium",children:"Error al cargar la imagen"}),F.jsx("p",{className:"lb:text-gray-400 lb:text-sm lb:mt-2",children:"No se pudo cargar la imagen"})]}),F.jsx("img",{ref:k,src:e,alt:t,className:"lb:max-w-full lb:max-h-full lb:object-contain lb:transition-opacity lb:duration-200 lb:select-none "+(f?"lb:opacity-100":"lb:opacity-0"),style:{transform:`scale(${i}) translate(${s.x/i}px, ${s.y/i}px)`,transition:u?"none":"transform 0.2s ease-out"},onLoad:()=>g(!0),onError:()=>x(!0),onClick:L,onDoubleClick:A,draggable:!1})]})})}function $e({image:e,isOpen:t,onClose:n,onSelect:l,onDelete:r,onCrop:a,onVariantDeleted:i,allowedActions:o={select:!0,download:!0,copy:!0,delete:!0,crop:!0}}){const{loadVariants:s,getVariants:c,isLoading:u,getError:d,removeVariant:b}=he(),m=window.limboCore?.accessibilityManager,[h,p]=v.useState(null),[f,g]=v.useState(null),[x,w]=y.useState(null),[k,C]=y.useState(null),[S,j]=y.useState({}),[N,E]=y.useState({}),$=(window.limboCore?.config?.getGlobal()||{}).interaction||{allowSelection:!1,allowCropping:!0},_=$.allowSelection&&o.select&&l,T=$.allowCropping&&o.crop&&a,z=o.download,L=o.copy,A=o.delete,[M,P]=v.useState(new Set),[I,D]=v.useState(new Set),[O,R]=y.useState({}),[U,B]=y.useState(!1),W=y.useRef(null),H=y.useRef(null),Y=y.useCallback(e=>{if("Escape"===e.key){if(x)return;e.preventDefault(),n?.()}if("Tab"===e.key&&W.current){const t=W.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),n=t[0],l=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),l?.focus()):e.shiftKey||document.activeElement!==l||(e.preventDefault(),n?.focus())}},[n,x]);y.useEffect(()=>{if(t)return H.current?.focus(),document.addEventListener("keydown",Y),()=>document.removeEventListener("keydown",Y)},[t,Y]);const J=v.useMemo(()=>e?.variants||[],[e?.variants]),Z=c(e?.id),ee=(J.length>0?J:Z).filter(e=>!I.has(e.id)),te=0===J.length&&u(e?.id),ne=0===J.length?d(e?.id):null;y.useEffect(()=>{!t||!e?.id||e?.variants&&0!==e.variants.length||s(e.id)},[t,e?.id,e?.variants,s]),v.useEffect(()=>{t&&(P(new Set),D(new Set),R({}),j({}),E({}))},[t]),v.useEffect(()=>{if(t&&I.size>0&&0===ee.length){const t=setTimeout(()=>{document.dispatchEvent(new CustomEvent("limbo:variantsCleared",{detail:{assetId:e?.id}})),n?.()},1200);return()=>clearTimeout(t)}},[t,I.size,ee.length,e?.id,n]);const le=ee.map(e=>e.id).join(",");y.useEffect(()=>{if(!t||!e?.url)return;let n=!1;return(async()=>{const t={},l={},r={},a="original",i=Q(e.url);if(i?(l[a]=!0,t[a]=!1,r.original=G(e.url)):(t[a]=!0,l[a]=!1),ee.forEach(e=>{Q(e.url)?(l[e.id]=!0,t[e.id]=!1,r[e.id]=G(e.url)):(t[e.id]=!0,l[e.id]=!1)}),j(t),E(l),Object.keys(r).length>0&&R(r),!i){const t=await K(e.url);if(n)return;t&&(R(e=>({...e,original:t})),j(e=>({...e,[a]:!1})),E(e=>({...e,[a]:!0})))}if(ee.length>0){const e=ee.filter(e=>!Q(e.url));if(e.length>0){const t=e.map(e=>e.url),l=await X(t,4);if(n)return;const r={},a={},i={};e.forEach((e,t)=>{l[t]&&(r[e.id]=l[t],a[e.id]=!1,i[e.id]=!0)}),Object.keys(r).length>0&&(R(e=>({...e,...r})),j(e=>({...e,...a})),E(e=>({...e,...i})))}}})(),()=>{n=!0}},[t,e?.url,le]);if(!t)return null;const re=e=>{m?.announce(`Abriendo visor de imagen: ${e.name}`);const t=O[e.id]||G(e.url);w({src:t,title:e.name||e.filename||"Recorte",subtitle:`${e.width}×${e.height} · ${Math.round((e.file_size||0)/1024)}KB`})},ae=()=>{m?.announce(`Abriendo visor de imagen: ${e.filename}`);const t=O.original||G(e.url);w({src:t,title:e.filename||"Original",subtitle:`${e.width}×${e.height} · ${Math.round((e.file_size||0)/1024)}KB`})},ie=async t=>{if(window.confirm(`¿Estás seguro de que deseas eliminar el recorte "${t.name||t.filename}"?`)){B(!0),m?.announce(`Eliminando recorte ${t.name||t.filename}`);try{const n=await b(e.id,t.id);n.success?(D(e=>new Set([...e,t.id])),t.url&&(e=>{if(!e)return;const t=q.get(e);if(t){try{URL.revokeObjectURL(t.blobUrl)}catch{}q.delete(e)}V.delete(e)})(t.url),p("Recorte eliminado correctamente"),g("success"),m?.announce("Recorte eliminado correctamente"),i?.(),document.dispatchEvent(new CustomEvent("limbo:variantDeleted",{detail:{assetId:e?.id,variantId:t.id}})),setTimeout(()=>{p(null),g(null)},3e3)):(p(`Error al eliminar recorte: ${n.error}`),g("error"),m?.announceError(`Error al eliminar recorte: ${n.error}`),setTimeout(()=>{p(null),g(null)},5e3))}finally{B(!1)}}},oe=[{...e,isOriginal:!0},...ee.map(e=>({...e,isOriginal:!1}))];return F.jsxs("div",{className:"lb:fixed lb:inset-0 lb:bg-black/85 lb:flex lb:items-center lb:justify-center lb:z-[1000] lb:p-4",onClick:()=>{x||n?.()},role:"dialog","aria-modal":"true","aria-labelledby":"variants-modal-title","aria-describedby":"variants-modal-description",children:[F.jsxs("div",{ref:W,className:"lb:relative lb:bg-white lb:rounded-xl lb:max-w-[95vw] lb:max-h-[90vh] lb:overflow-hidden lb:shadow-2xl lb:flex lb:flex-col lb:w-[900px]",onClick:e=>e.stopPropagation(),children:[F.jsxs("div",{className:"lb:px-5 lb:py-4 lb:border-b lb:border-gray-200 lb:flex lb:justify-between lb:items-center lb:bg-gray-50",children:[F.jsxs("div",{className:"lb:flex-1 lb:min-w-0 lb:pr-4",children:[F.jsx("h2",{id:"variants-modal-title",className:"lb:m-0 lb:text-lg lb:font-semibold lb:text-gray-900 lb:truncate",children:e?.filename}),F.jsxs("p",{id:"variants-modal-description",className:"lb:text-sm lb:text-gray-500 lb:mt-1",children:["Imagen original y ",ee.length," recorte",1!==ee.length?"s":""," disponible",1!==ee.length?"s":""]})]}),F.jsx("button",{ref:H,className:"lb:w-10 lb:h-10 lb:flex lb:items-center lb:justify-center lb:rounded-lg lb:bg-gray-100 lb:hover:bg-red-200 lb:text-gray-500 lb:hover:text-red-1000 lb:transition-colors lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400",onClick:n,"aria-label":"Cerrar modal (ESC)",title:"Cerrar (ESC)",children:F.jsx("svg",{className:"lb:w-5 lb:h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),U&&F.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-white/80 lb:flex lb:flex-col lb:items-center lb:justify-center lb:z-50 lb:rounded-xl",children:[F.jsx("div",{className:"lb:w-12 lb:h-12 lb:border-4 lb:border-gray-200 lb:border-t-brand-blue-800 lb:rounded-full lb:animate-spin lb:mb-4"}),F.jsx("p",{className:"lb:text-base lb:font-medium lb:text-gray-700",children:"Eliminando recorte..."})]}),h&&F.jsx("div",{className:"lb:mx-2 lb:mt-2 lb:px-2 lb:py-1.5 lb:rounded lb:text-xs "+("success"===f?"lb:bg-green-50 lb:text-green-1000":"lb:bg-red-50 lb:text-red-1000"),role:"alert",children:h}),F.jsx("div",{className:"lb:p-5 lb:overflow-y-auto lb:flex-1 lb:bg-gray-50/50",children:te?F.jsxs("div",{className:"lb:text-center lb:py-16 lb:text-gray-500",role:"status","aria-live":"polite",children:[F.jsx("div",{className:"lb:w-12 lb:h-12 lb:border-4 lb:border-gray-200 lb:border-t-brand-blue-800 lb:rounded-full lb:animate-spin lb:mx-auto lb:mb-4"}),F.jsx("p",{className:"lb:text-base",children:"Cargando variantes..."})]}):ne?F.jsxs("div",{className:"lb:text-center lb:py-16 lb:text-red-1000",role:"alert",children:[F.jsx("svg",{className:"lb:w-12 lb:h-12 lb:mx-auto lb:mb-4 lb:text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),F.jsxs("p",{className:"lb:text-base lb:font-medium",children:["Error: ",ne]}),F.jsx("button",{onClick:()=>s(e.id),className:"lb:mt-4 lb:text-sm lb:px-5 lb:py-2.5 lb:rounded-lg lb:bg-brand-blue-800 lb:text-white lb:hover:bg-brand-blue-1000 lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400 lb:focus:ring-offset-2",children:"Reintentar"})]}):0===ee.length?F.jsxs("div",{className:"lb:text-center lb:py-16 lb:text-gray-500",children:[F.jsx("svg",{className:"lb:w-12 lb:h-12 lb:mx-auto lb:mb-4 lb:text-gray-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),F.jsx("p",{className:"lb:text-base",children:"No hay recortes disponibles"})]}):F.jsx("div",{className:"lb:grid lb:grid-cols-2 lb:lg:grid-cols-3 lb:gap-5",role:"list","aria-label":"Lista de imágenes",children:oe.map((t,i)=>{const o=t.isOriginal,s=!o&&M.has(t.id);t.url;const c=o?O.original||G(t.url):O[t.id]||G(t.url),u=o?"Original":t.name||t.filename||`Recorte ${i}`,d=o?e.width:t.width,b=o?e.height:t.height,h=o?e.file_size:t.file_size||0,p=o?"original":t.id,f=S[p]&&!s,g=N[p];return F.jsxs("article",{role:"listitem","aria-label":`${u} - ${d}×${b} píxeles`,className:`lb:rounded-xl lb:overflow-hidden lb:transition-all lb:shadow-sm lb:hover:shadow-lg ${o?"lb:ring-2 lb:ring-brand-blue-800 lb:ring-offset-2 lb:bg-white":"lb:border lb:border-gray-200 lb:bg-white lb:hover:border-brand-blue-400"} lb:focus-within:ring-2 lb:focus-within:ring-brand-blue-400`,children:[F.jsxs("button",{type:"button",title:_?"Click para seleccionar":"Click para ampliar con zoom",className:"lb:relative lb:w-full lb:cursor-pointer lb:aspect-square lb:flex lb:items-center lb:justify-center lb:overflow-hidden lb:bg-gray-100 lb:focus:outline-none lb:group",onClick:s?void 0:()=>{_?o?(l?.(e),n?.()):(t=>{const r={id:t.id,filename:`${e.filename}_${t.name}`,url:t.url,width:t.width,height:t.height,mime_type:`image/${t.format}`,file_size:t.file_size,upload_date:t.created_at,processing_status:"completed",is_variant:!0,parent_asset_id:e.id,variant_info:t};m?.announce(`Recorte seleccionado: ${t.name}`),l?.(r),n?.()})(t):o?ae():re(t)},"aria-label":_?`Seleccionar ${u}`:`Ver ${u} en tamaño completo con zoom`,disabled:s,children:[f&&!s&&F.jsx("div",{className:"lb:w-full lb:aspect-square lb:rounded lb:bg-neutral-gray-200 lb:animate-pulse lb:flex lb:items-center lb:justify-center lb:absolute lb:inset-0 lb:z-10",children:F.jsx("span",{className:"icon icon-spinner lb:w-8 lb:h-8 lb:animate-spin"})}),s?F.jsxs("div",{className:"lb:text-center lb:text-gray-400",children:[F.jsx("svg",{className:"lb:w-10 lb:h-10 lb:mx-auto lb:mb-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),F.jsx("span",{className:"lb:text-sm",children:"Error al cargar"})]}):F.jsxs(F.Fragment,{children:[F.jsx("img",{src:c,alt:`${u} - ${d}×${b}px`,loading:o?"eager":"lazy",onLoad:()=>{E(e=>e[p]?e:{...e,[p]:!0}),j(e=>e[p]?{...e,[p]:!1}:e)},onError:o?void 0:()=>{return e=t.id,void P(t=>new Set([...t,e]));var e},className:"lb:w-full lb:h-full lb:object-contain lb:p-3 lb:transition-all lb:duration-300 lb:group-hover:scale-105 "+(g?"lb:opacity-100":"lb:opacity-0")}),F.jsx("div",{className:"lb:absolute lb:inset-0 lb:bg-black/0 lb:group-hover:bg-black/10 lb:transition-colors lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"lb:opacity-0 lb:group-hover:opacity-100 lb:transition-opacity lb:bg-black/60 lb:text-white lb:px-3 lb:py-1.5 lb:rounded-full lb:text-xs lb:font-medium lb:flex lb:items-center lb:gap-1.5",children:_?F.jsxs(F.Fragment,{children:[F.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Seleccionar"]}):F.jsxs(F.Fragment,{children:[F.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM10 7v3m0 0v3m0-3h3m-3 0H7"})}),"Ampliar"]})})})]}),o&&F.jsx("span",{className:"lb:absolute lb:top-3 lb:left-3 lb:bg-brand-blue-800 lb:text-white lb:text-xs lb:font-bold lb:px-3 lb:py-1.5 lb:rounded-lg lb:shadow-lg lb:z-20",children:"ORIGINAL"})]}),F.jsxs("div",{className:"lb:px-4 lb:py-3 lb:border-t lb:border-gray-100 lb:bg-white",children:[F.jsx("h3",{className:"lb:text-sm lb:font-semibold lb:text-gray-900 lb:truncate lb:mb-2",title:u,children:u}),F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between",children:[F.jsxs("span",{className:"lb:text-xs lb:text-gray-500 lb:font-medium",children:[d,"×",b," ·"," ",Math.round(h/1024),"KB"]}),F.jsxs("div",{className:"lb:flex lb:gap-2",role:"group","aria-label":`Acciones para ${u}`,children:[o&&T&&F.jsx("button",{type:"button",className:"lb:w-8 lb:h-8 lb:rounded-lg lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:cursor-pointer lb:text-white lb:flex lb:items-center lb:justify-center lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400 lb:focus:ring-offset-1 lb:transition-colors lb:shadow-sm",onClick:t=>{t.stopPropagation(),a&&(m?.announce(`Abriendo herramienta de recorte para ${e.filename}`),a(e),n?.())},"aria-label":"Crear nuevo recorte",title:"Recortar",children:F.jsx("span",{className:"icon icon-scissors-white icon--sm"})}),L&&F.jsx("button",{type:"button",className:"lb:w-8 lb:h-8 lb:rounded-lg lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:cursor-pointer lb:text-white lb:flex lb:items-center lb:justify-center lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400 lb:focus:ring-offset-1 lb:transition-colors lb:shadow-sm",onClick:n=>{n.stopPropagation();(async(e,t,n)=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(t);else{const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),document.body.removeChild(e)}C(e),m?.announce(`URL de ${n} copiada al portapapeles`),setTimeout(()=>C(null),2e3)}catch(l){console.error("Error al copiar URL:",l),m?.announceError(`Error al copiar URL de ${n}. Inténtalo de nuevo.`)}})(o?"original":t.id,o?e.url||e.path:t.url,u)},"aria-label":k===(o?"original":t.id)?"¡Copiado!":`Copiar URL de ${u}`,title:k===(o?"original":t.id)?"¡Copiado!":"Copiar URL",children:F.jsx("span",{className:`icon ${k===(o?"original":t.id)?"icon-copied-white":"icon-copy-white"} icon--sm`})}),z&&F.jsx("button",{type:"button",className:"lb:w-8 lb:h-8 lb:rounded-lg lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:cursor-pointer lb:text-white lb:flex lb:items-center lb:justify-center lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400 lb:focus:ring-offset-1 lb:transition-colors lb:shadow-sm",onClick:n=>{n.stopPropagation(),o?(async()=>{const{downloadImage:t}=await Promise.resolve().then(()=>Zn);await t(e.url||e.path,e.filename||"limbo-image",{originalFormat:e.format,accessibilityManager:m})})():(async e=>{const{downloadImage:t}=await Promise.resolve().then(()=>Zn);await t(e.url,e.name||"limbo-variant",{originalFormat:e.format||e.output_format,accessibilityManager:m})})(t)},"aria-label":`Descargar ${u}`,title:"Descargar",children:F.jsx("span",{className:"icon icon-download-white icon--sm"})}),A&&(!o||r)&&F.jsx("button",{type:"button",className:"lb:w-8 lb:h-8 lb:rounded-lg lb:bg-red-1000 lb:hover:bg-red-800 lb:cursor-pointer lb:text-white lb:flex lb:items-center lb:justify-center lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-red-800 lb:focus:ring-offset-1 lb:transition-colors lb:shadow-sm",onClick:l=>{l.stopPropagation(),o?(async()=>{if(!r)return;window.confirm(`¿Estás seguro de que deseas eliminar "${e.filename}"? Esta acción también eliminará todos sus recortes.`)&&(m?.announce(`Eliminando imagen ${e.filename}`),await r(e.id),n?.())})():ie(t)},"aria-label":`Eliminar ${u}`,title:"Eliminar",children:F.jsx("span",{className:"icon icon-close-small-white icon--sm"})}),_&&F.jsx("button",{type:"button",className:"lb:w-8 lb:h-8 lb:cursor-pointer lb:rounded-lg lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:text-white lb:flex lb:items-center lb:justify-center lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400 lb:focus:ring-offset-1 lb:transition-colors lb:shadow-sm",onClick:e=>{e.stopPropagation(),o?ae():re(t)},"aria-label":`Ampliar ${u}`,title:"Ampliar",children:F.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM10 7v3m0 0v3m0-3h3m-3 0H7"})})})]})]})]})]},o?"original":t.id)})})})]}),F.jsx(Ee,{isOpen:!!x,src:x?.src||"",alt:x?.title||"Imagen",title:x?.title,subtitle:x?.subtitle,onClose:()=>w(null)})]})}const _e="/api";let Te={data:null,timestamp:0,pending:null};const ze=new Set;function Le(){Te.data=null,Te.timestamp=0,Te.pending=null,ze.forEach(e=>e())}async function Ae(e={}){return Te.data&&Date.now()-Te.timestamp<3e5?Te.data:(Te.pending||(Te.pending=async function(e={}){try{const t={include_counts:"true",...e},n=`/folders?${new URLSearchParams(t).toString()}`;return function(e){if(!e?.success||!e?.data)return{folders:[],total:0};const t=(e.data.folders||[]).map(e=>({id:e.id,name:e.name,slug:e.slug,description:e.description,visibility:e.visibility||"public",sort_order:e.sort_order||0,assets_count:e.assets_count||0,created_at:e.created_at,updated_at:e.updated_at}));return{folders:t,total:e.data.total||t.length}}(await ne({endpoint:n,method:"GET",basePath:_e,useJWT:!0}))}catch(t){throw ce(t)}}(e).then(e=>(Te.data=e,Te.timestamp=Date.now(),Te.pending=null,e)).catch(e=>{throw Te.pending=null,e})),Te.pending)}function Me(e={}){const{autoFetch:t=!0,visibility:n=null,allowedSlugs:l=null,excludeSlugs:r=null}=e,[a,i]=y.useState([]),[o,s]=y.useState(!1),[c,u]=y.useState(null),[d,b]=y.useState(!1),m=y.useRef(null),h=y.useCallback(e=>{let t=[...e];return l&&l.length>0&&(t=t.filter(e=>l.includes(e.slug))),r&&r.length>0&&(t=t.filter(e=>!r.includes(e.slug))),t.sort((e,t)=>e.sort_order!==t.sort_order?e.sort_order-t.sort_order:e.name.localeCompare(t.name)),t},[l,r]),p=y.useCallback(async(e={})=>{s(!0),u(null);try{const t={...n&&{visibility:n},...e},l=await Ae(t),r=h(l.folders||[]);return i(r),r}catch(t){return u(t.message),[]}finally{s(!1)}},[n,h]),f=y.useCallback(()=>(Le(),p()),[p]),g=y.useCallback(async e=>{b(!0),u(null);try{const t=await async function(e){try{return function(e){if(!e?.success||!e?.data)return{folder:null};const t=e.data;return{folder:{id:t.id,name:t.name,slug:t.slug,description:t.description,visibility:t.visibility||"public",sort_order:t.sort_order||0,assets_count:t.assets_count||0,created_at:t.created_at,updated_at:t.updated_at}}}(await ne({endpoint:"/folders",method:"POST",body:{name:e.name,...e.slug&&{slug:e.slug},...e.description&&{description:e.description},...e.visibility&&{visibility:e.visibility}},basePath:_e,useJWT:!0}))}catch(c){throw ce(c)}}(e),n=t.folder;return n&&(Le(),i(e=>{const t=[...e,n];return t.sort((e,t)=>e.sort_order!==t.sort_order?e.sort_order-t.sort_order:e.name.localeCompare(t.name)),t})),n}catch(t){return u(t.message),null}finally{b(!1)}},[]),v=y.useCallback(e=>a.find(t=>t.slug===e)||null,[a]),x=y.useCallback(e=>a.find(t=>t.id===e)||null,[a]);return m.current=p,y.useEffect(()=>{const e=()=>m.current?.();return ze.add(e),()=>ze.delete(e)},[]),y.useEffect(()=>{t&&p()},[t,p]),{folders:a,loading:o,error:c,creating:d,fetchFolders:p,create:g,refresh:f,findBySlug:v,findById:x,hasLoaded:!o&&a.length>=0}}function Pe({value:e=null,onChange:t,allowCreate:n=!0,placeholder:l="Sin carpeta",label:r=null,disabled:a=!1,className:i="",showAssetCount:o=!1,includeNoFolder:s=!0,allowedSlugs:c=null,excludeSlugs:u=null,mode:d="upload"}){const b=y.useId(),[m,h]=y.useState(!1),[p,f]=y.useState(""),[g,v]=y.useState(null),{folders:x,loading:w,error:k,creating:C,create:S,refresh:j}=Me({autoFetch:!0,allowedSlugs:c,excludeSlugs:u}),N=async e=>{if(e.preventDefault(),v(null),!p.trim())return void v("El nombre es requerido");const n=await S({name:p.trim()});n?(t?.(n),h(!1),f("")):v("Error al crear la carpeta")},E=()=>{h(!1),f(""),v(null)};if(m)return F.jsxs("div",{className:`limbo-folder-selector limbo-folder-selector--creating ${i}`,children:[r&&F.jsxs("label",{className:"limbo-filter-label lb:block lb:mb-1",children:[r," ",C&&F.jsx("span",{className:"limbo-filter-searching","aria-hidden":"true",children:F.jsx("span",{className:"icon icon-spinner lb:animate-spin lb:w-3 lb:h-3"})})]}),F.jsxs("form",{onSubmit:N,className:"lb:flex lb:gap-2 lb:items-center",children:[F.jsx("input",{type:"text",value:p,onChange:e=>f(e.target.value),placeholder:"Nombre de la carpeta...",className:"limbo-filter-input lb:flex-1",autoFocus:!0,disabled:C}),F.jsx("button",{type:"submit",disabled:C||!p.trim(),className:"limbo-btn limbo-btn--primary lb:px-3 lb:py-1.5 lb:text-sm lb:rounded lb:bg-brand-blue-1000 lb:text-white lb:border-0 lb:cursor-pointer disabled:lb:opacity-50 disabled:lb:cursor-not-allowed",children:C?"...":"Crear"}),F.jsx("button",{type:"button",onClick:E,disabled:C,className:"limbo-btn limbo-btn--ghost lb:px-2 lb:py-1.5 lb:text-sm lb:rounded lb:bg-transparent lb:border lb:border-gray-300 lb:cursor-pointer",children:"Cancelar"})]}),g&&F.jsx("p",{className:"lb:text-red-600 lb:text-xs lb:mt-1",children:g})]});const $="filter"===d?"Todas las carpetas":l;return F.jsxs("div",{className:`limbo-folder-selector ${i}`,children:[r&&F.jsxs("label",{htmlFor:b,className:"limbo-filter-label lb:block lb:mb-1",children:[r,w&&F.jsx("span",{className:"limbo-filter-searching","aria-hidden":"true",children:F.jsx("span",{className:"icon icon-spinner lb:animate-spin lb:w-3 lb:h-3"})})]}),F.jsx("div",{className:"lb:relative",children:F.jsxs("select",{id:b,value:e||"",onChange:e=>{const n=e.target.value;if("__create__"===n)return void h(!0);if(""===n||"__none__"===n)return void t?.(null);const l=x.find(e=>e.slug===n);t?.(l||null)},disabled:a||w,className:"limbo-filter-input limbo-filter-select lb:w-full",children:[s&&F.jsx("option",{value:"",children:$}),w&&F.jsx("option",{value:"",disabled:!0,children:"Cargando carpetas..."}),k&&!w&&F.jsx("option",{value:"",disabled:!0,children:"Error al cargar carpetas"}),!w&&!k&&x.map(e=>F.jsxs("option",{value:e.slug,children:[e.name,o&&` (${e.assets_count})`]},e.id)),n&&!w&&!k&&F.jsxs(F.Fragment,{children:[F.jsx("option",{disabled:!0,children:"──────────────"}),F.jsx("option",{value:"__create__",children:"+ Crear nueva carpeta..."})]})]})}),k&&F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2 lb:mt-1",children:[F.jsx("p",{className:"lb:text-red-600 lb:text-xs",children:k}),F.jsx("button",{type:"button",onClick:j,className:"lb:text-xs lb:text-brand-blue-1000 lb:underline lb:cursor-pointer",children:"Reintentar"})]})]})}const Ie={pdf:{symbol:"icon-doc-pdf",color:"#dc2626"},doc:{symbol:"icon-doc-word",color:"#2563eb"},docx:{symbol:"icon-doc-word",color:"#2563eb"},xls:{symbol:"icon-doc-xls",color:"#16a34a"},xlsx:{symbol:"icon-doc-xls",color:"#16a34a"},ppt:{symbol:"icon-doc-ppt",color:"#ea580c"},pptx:{symbol:"icon-doc-ppt",color:"#ea580c"},txt:{symbol:"icon-doc-text",color:"#6b7280"},csv:{symbol:"icon-doc-report",color:"#16a34a"},mp4:{symbol:"icon-video",color:"#7c3aed"},webm:{symbol:"icon-video",color:"#7c3aed"},mov:{symbol:"icon-video",color:"#7c3aed"},avi:{symbol:"icon-video",color:"#7c3aed"},mkv:{symbol:"icon-video",color:"#7c3aed"},gif:{symbol:"icon-video",color:"#7a3f2d"},mp3:{symbol:"icon-support-person",color:"#0891b2"},mpeg:{symbol:"icon-support-person",color:"#0891b2"},wav:{symbol:"icon-support-person",color:"#0891b2"},ogg:{symbol:"icon-support-person",color:"#0891b2"},aac:{symbol:"icon-support-person",color:"#0891b2"},flac:{symbol:"icon-support-person",color:"#0891b2"},default:{symbol:"icon-clip",color:"#6b7280"}},De=new Set(["text/plain","text/csv","text/html","text/xml","text/css","text/javascript","text/markdown","application/json","application/xml","application/javascript"]);function Oe({image:e,onDelete:t,onCrop:n,onSelect:l,onFolderChange:r,thumbnailSize:a=32,isDeleting:i=!1,showFolderInfo:o=!0,allowMoveFolder:s=!0,allowedFolderSlugs:c=null,excludedFolderSlugs:u=null,allowCreateFolder:d=!1,allowedActions:b={select:!0,download:!0,copy:!0,delete:!0,crop:!0,variants:!0}}){const[m,h]=y.useState(!1),[p,f]=y.useState(!1),[g,x]=y.useState(!1),[w,k]=y.useState(e.variants_count||0),[C,S]=y.useState(!1),[j,N]=y.useState(!1);y.useEffect(()=>{if(!C)return;const e=e=>{e.target.closest(".limbo-image-card-wrapper")||S(!1)};return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[C]);const E=y.useMemo(()=>(e=>{if(e.asset_type)return e.asset_type;const t=e.mime_type||e.original_mime||"";return"image/gif"===t?"video":t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":t.includes("pdf")||t.includes("document")||t.includes("spreadsheet")||t.includes("presentation")||t.includes("text/")?"document":"unknown"})(e),[e]),$="image"===E,_=(e.mime_type||e.original_mime||"").includes("image/gif"),T=$||_,z=y.useMemo(()=>(e=>{if(!e)return"";const t=e.split(".");return t.length>1?t.pop().toLowerCase():""})(e.filename),[e.filename]),L=Ie[z]||Ie.default,A=e.url||e.path,M=T&&e.thumbnail_url?e.thumbnail_url:A,[P,I]=y.useState(()=>G(M)),[D,O]=y.useState(()=>!Q(M)),[R,U]=y.useState(!1),[W,q]=y.useState(()=>Q(M)),{isMobile:V,isTouch:H}=B(),X=window.limboCore?.accessibilityManager,Y=(window.limboCore?.config?.getGlobal()||{}).interaction||{allowSelection:!1,allowCropping:!0},J=n=>{n.stopPropagation(),X?.announce(`Eliminando imagen ${e.filename}`,"assertive"),t?.(e)},Z=async t=>{t.stopPropagation();let n=e.url||e.path;try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(n);else{const e=document.createElement("textarea");e.value=n,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),document.body.removeChild(e)}h(!0),X?.announce(`URL de ${e.filename} copiada al portapapeles. Nota: La URL puede tener un tiempo de validez limitado.`),setTimeout(()=>h(!1),2e3)}catch(l){console.error("Error al copiar URL:",l),X?.announce(`Error al copiar URL de ${e.filename}. Inténtalo de nuevo.`),alert(`Error al copiar URL de ${e.filename}. Por favor, inténtalo de nuevo.`)}},ee=async t=>{t.preventDefault(),t.stopPropagation();const n=e.url||e.path,l=e.filename||"limbo-file";if(!$){try{X?.announce(`Descargando ${l}`);const e=await fetch(n,{mode:"cors"});if(!e.ok)throw new Error(`HTTP error: ${e.status}`);const t=await e.blob(),r=window.URL.createObjectURL(t),a=document.createElement("a");a.href=r,a.download=l,a.style.display="none",document.body.appendChild(a),a.click(),setTimeout(()=>{window.URL.revokeObjectURL(r),document.body.removeChild(a)},100),X?.announce(`${l} descargado correctamente`)}catch(a){console.error("Error downloading file:",a),X?.announce(`Error al descargar ${l}`)}return}const{downloadImage:r}=await Promise.resolve().then(()=>Zn);await r(n,l,{originalFormat:e.format,accessibilityManager:X})},te=t=>{t.stopPropagation(),X?.announce(`Editando imagen ${e.filename}`),n?.(e)},ne=$&&(e.variants&&e.variants.length>0||w>0),le=w,re=v.useCallback(()=>{k(e=>Math.max(0,e-1))},[]);v.useEffect(()=>{k(e.variants_count||0)},[e.variants_count]),y.useEffect(()=>{if(!T)return O(!1),void q(!0);if(e.thumbnail_url)return I(e.thumbnail_url),O(!0),U(!1),void q(!1);const t=e.url||e.path;if(Q(t))return I(G(t)),O(!1),U(!1),void q(!0);O(!0),U(!1),q(!1),K(t).then(e=>{I(e),O(!1),q(!0)}).catch(()=>{I(t),O(!1),U(!0)})},[e.url,e.path,e.thumbnail_url,T]);const ae=Y.allowSelection&&b.select&&l,ie=_?A:null,oe=$&&!_&&Y.allowCropping&&b.crop&&n,se=()=>{ae?(X?.announce(`Seleccionando ${e.filename} para el portal`),l?.(e)):ne?(X?.announce(`Mostrando recortes de ${e.filename}`),f(!0)):(X?.announce(`Abriendo visor de ${e.filename}`),x(!0))};return F.jsxs(F.Fragment,{children:[F.jsxs("div",{className:`limbo-image-card-wrapper lb:relative lb:cursor-pointer ${i?"lb:opacity-50":""} ${V?"limbo-image-card-wrapper--mobile":""}`,onClick:se,onKeyDown:l=>{switch(l.key){case"Enter":case" ":l.preventDefault(),se();break;case"d":case"D":b.download&&(l.preventDefault(),ee(l));break;case"c":case"C":b.copy&&(l.preventDefault(),Z(l));break;case"Delete":case"Backspace":b.delete&&t&&(l.preventDefault(),J(l));break;case"x":case"X":b.crop&&n&&(l.preventDefault(),te(l));break;case"v":case"V":b.variants&&(l.preventDefault(),(t=>{t.stopPropagation(),X?.announce(`Mostrando recortes de ${e.filename}`),f(!0)})(l))}},onMouseEnter:ie?()=>{ie&&e.thumbnail_url&&I(ie)}:void 0,onMouseLeave:ie?()=>{ie&&e.thumbnail_url&&I(e.thumbnail_url)}:void 0,title:ne?`Ver ${le} recorte${1!==le?"s":""} de ${e.filename}`:T?V?"Toque para ampliar imagen":"Click para ampliar imagen con zoom":V?"Toque para previsualizar":"Click para previsualizar",role:"button",tabIndex:0,"aria-label":T?`${_?"GIF":"Imagen"} ${e.filename}. ${e.width}x${e.height} px`:`Archivo ${e.filename}. Tipo: ${E}`,style:{...H&&{touchAction:"manipulation",WebkitTapHighlightColor:"transparent"}},children:[j&&F.jsxs("div",{className:"limbo-moving-overlay",children:[F.jsx("span",{className:"icon icon-spinner lb:animate-spin lb:w-6 lb:h-6"}),F.jsx("span",{className:"lb:text-xs lb:text-gray-600 lb:font-medium",children:"Moviendo..."})]}),F.jsxs("div",{className:`limbo-image-actions ${C?"limbo-image-actions--expanded":""} ${V?"limbo-image-actions--mobile":""}`,children:[F.jsxs("div",{className:"limbo-image-actions__buttons",children:[(ae||!T)&&F.jsx("button",{type:"button",title:ne?`Ver ${le} recortes`:T?"Ampliar imagen":"Previsualizar archivo",className:"limbo-action-btn lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:border lb:border-brand-blue-1000 "+(V?"lb:btn--touch":""),onClick:t=>{t?.stopPropagation(),ne?(X?.announce(`Mostrando recortes de ${e.filename}`),f(!0)):(X?.announce(`Abriendo visor de ${e.filename}`),x(!0))},tabIndex:-1,style:{...V&&{width:"40px",height:"40px"}},children:F.jsx("span",{className:`icon ${T?"icon-zoom-in-white":"icon-search-white"} icon--sm`,"aria-hidden":"true"})}),oe&&F.jsx("button",{type:"button",title:"Editar imagen",className:"limbo-action-btn limbo-btn-crop lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:border lb:border-brand-blue-1000 "+(V?"lb:btn--touch":""),onClick:te,tabIndex:-1,style:{...V&&{width:"40px",height:"40px"}},children:F.jsx("span",{className:"icon icon-scissors-white icon--sm","aria-hidden":"true"})}),b.copy&&F.jsx("button",{type:"button",title:m?"¡Copiado!":"Copiar URL",className:"limbo-action-btn limbo-btn-copy lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:border lb:border-brand-blue-1000 "+(V?"lb:btn--touch":""),onClick:Z,tabIndex:-1,style:{...V&&{width:"40px",height:"40px"}},children:F.jsx("span",{className:`icon ${m?"icon-copied-white":"icon-copy-white"} icon--sm`,"aria-hidden":"true"})}),b.download&&F.jsx("button",{type:"button",title:"Descargar",className:"limbo-action-btn limbo-btn-download lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:border lb:border-brand-blue-1000 "+(V?"lb:btn--touch":""),onClick:ee,tabIndex:-1,style:{...V&&{width:"40px",height:"40px"}},children:F.jsx("span",{className:"icon icon-download-white icon--sm","aria-hidden":"true"})}),s&&r&&F.jsx("button",{type:"button",title:e.folder?`Mover de carpeta (${e.folder?.name||e.folder?.slug||""})`:"Asignar a carpeta",className:"limbo-action-btn limbo-btn-folder lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:border lb:border-brand-blue-1000 "+(V?"lb:btn--touch":""),onClick:e=>{e.stopPropagation(),S(!C)},tabIndex:-1,style:{...V&&{width:"40px",height:"40px"}},children:F.jsx("span",{className:"icon icon-folder-white icon--sm","aria-hidden":"true"})}),b.delete&&t&&F.jsx("button",{onClick:J,disabled:i,className:"limbo-action-btn limbo-btn-delete lb:bg-red-800 lb:hover:bg-red-700 lb:border lb:border-red-700 "+(V?"lb:btn--touch lb:active:lb:bg-red-800":""),title:"Eliminar archivo",tabIndex:-1,style:{...V&&{width:"40px",height:"40px"}},children:i?"…":F.jsx("span",{className:"icon icon-close-small-white icon--sm","aria-hidden":"true"})})]}),C&&s&&r&&F.jsx("div",{className:"limbo-image-actions__folder",onClick:e=>e.stopPropagation(),children:F.jsx(Pe,{value:e.folder?.slug||null,onChange:async t=>{if(!j){N(!0);try{const n=t?.slug||null;await(r?.(e,n)),Le(),X?.announce(t?`${e.filename} movido a carpeta ${t.name}`:`${e.filename} movido a Sin carpeta`)}catch(n){console.error("Error moving to folder:",n),X?.announce(`Error al mover ${e.filename}`)}finally{N(!1),S(!1)}}},allowCreate:d,placeholder:"Sin carpeta",label:"Mover a carpeta",includeNoFolder:!0,allowedSlugs:c,excludeSlugs:u,disabled:j,mode:"upload"})})]}),F.jsxs("div",{className:"limbo-image-card "+(V?"limbo-image-card--mobile":""),children:[!T&&(e.thumbnail_url?F.jsxs("div",{className:"lb:relative lb:w-full lb:h-full lb:rounded lb:overflow-hidden lb:border lb:border-neutral-300",style:{...V&&{minHeight:`${Math.max(3*a,80)}px`}},children:[F.jsx("img",{src:e.thumbnail_url,alt:e.filename,className:"lb:w-full lb:h-full lb:object-cover lb:aspect-square",loading:"lazy",decoding:"async",draggable:!1,onError:e=>{e.target.style.display="none",e.target.nextElementSibling?.classList.remove("lb:hidden")}}),F.jsx("div",{className:"lb:hidden lb:absolute lb:inset-0 lb:bg-linear-to-br lb:from-neutral-100 lb:to-neutral-200 lb:flex lb:flex-col lb:items-center lb:justify-center",children:F.jsx("span",{className:"lb:mb-2 lb:h-[25%] lb:w-[25%]","aria-hidden":"true",children:F.jsx("span",{className:`icon ${L.symbol} lb:min-w-full lb:min-h-full`})})}),F.jsx("span",{className:"lb:absolute lb:bottom-1.5 lb:right-1.5 lb:text-[10px] lb:uppercase lb:font-bold lb:tracking-wide lb:px-1.5 lb:py-0.5 lb:rounded lb:shadow-sm",style:{backgroundColor:L.color,color:"white"},children:z||E})]}):F.jsxs("div",{className:"lb:w-full lb:h-full lb:rounded lb:bg-linear-to-br lb:from-neutral-100 lb:to-neutral-200 lb:flex lb:flex-col lb:items-center lb:justify-center lb:border lb:border-neutral-300",style:{...V&&{minHeight:`${Math.max(3*a,80)}px`}},children:[F.jsx("span",{className:"lb:mb-2 lb:h-[25%] lb:w-[25%]","aria-hidden":"true",children:F.jsx("span",{className:`icon ${L.symbol} lb:min-w-full lb:min-h-full`})}),F.jsx("span",{className:"lb:text-xs lb:uppercase lb:font-bold lb:tracking-wide lb:px-2 lb:py-0.5 lb:rounded",style:{backgroundColor:L.color,color:"white"},children:z||E})]})),T&&F.jsxs(F.Fragment,{children:[D&&!R&&F.jsx("div",{className:"lb:w-full lb:aspect-square lb:rounded lb:bg-neutral-200 lb:animate-pulse lb:flex lb:items-center lb:justify-center lb:absolute lb:inset-0 lb:z-10 "+(ne?"lb:ring-2 lb:ring-brand-blue-400 lb:ring-offset-2":""),style:{...V&&{minHeight:`${Math.max(3*a,80)}px`}},children:F.jsx("span",{className:"icon icon-spinner lb:w-8 lb:h-8 lb:animate-spin"})}),R&&F.jsxs("div",{className:"lb:z-0 lb:absolute lb:top-0 lb:left-0 lb:w-full lb:aspect-square lb:rounded lb:bg-neutral-100 lb:flex lb:flex-col lb:items-center lb:justify-center lb:text-neutral-400",style:{...V&&{minHeight:`${Math.max(3*a,80)}px`}},children:[F.jsx("span",{className:"icon icon-close icon--lg lb:mb-1","aria-hidden":"true"}),F.jsx("span",{className:"lb:text-xs",children:"Error al cargar"})]}),F.jsx("img",{src:P,loading:"lazy",decoding:"async",alt:e.filename.split(".")[0]??e.filename,className:`lb:z-1 lb:w-full lb:object-cover lb:rounded lb:aspect-square lb:transition-opacity lb:duration-300 ${ne?"lb:ring-2 lb:ring-brand-blue-400 lb:ring-offset-2":""} ${W?"lb:opacity-100":"lb:opacity-0"}`,sizes:`height: ${6*a}px,width: ${6*a}px`,draggable:!1,onLoad:()=>{O(!1),q(!0)},onError:()=>{O(!1),U(!0)},style:{...V&&{minHeight:`${Math.max(3*a,80)}px`,height:"auto",aspectRatio:"1 / 1",objectFit:"cover"}}}),_&&F.jsx("span",{className:"lb:absolute lb:bottom-1.5 lb:right-1.5 lb:text-[10px] lb:uppercase lb:font-bold lb:tracking-wide lb:px-1.5 lb:py-0.5 lb:rounded lb:shadow-sm",style:{backgroundColor:L.color,color:"white"},children:z||E})]}),F.jsxs("div",{className:"limbo-card-info-overlay "+(V?"limbo-card-info-overlay--mobile":""),children:[F.jsxs("span",{className:"limbo-card-info-name lb:truncate lb:max-w-full",children:[e.filename.split(".")[0]??e.filename,ne&&F.jsx("span",{className:"limbo-variants-indicator",style:{marginLeft:"4px",padding:"1px 6px",backgroundColor:"#dc2626",color:"white",borderRadius:"10px",fontSize:"10px",fontWeight:"700",display:"inline-block"},title:`${le} recorte${1!==le?"s":""}`,children:le})]}),o&&e.folder&&F.jsxs("span",{className:"limbo-card-info-folder lb:flex lb:items-center lb:gap-1 lb:bg-brand-blue-50 lb:rounded-md lb:px-1",title:`Carpeta: ${e.folder?.name||e.folder?.slug||e.folder}`,children:[F.jsx("span",{className:"icon icon-folder icon--sm"}),F.jsx("span",{className:"lb:truncate lb:max-w-20",children:e.folder?.name||e.folder?.slug||("string"==typeof e.folder?e.folder:"Sin carpeta")})]})]})]})]}),F.jsx($e,{image:e,isOpen:p,onClose:()=>f(!1),onSelect:l,onDelete:t,onCrop:n,onVariantDeleted:re,allowedActions:{select:b.select,download:b.download,copy:b.copy,delete:b.delete,crop:b.crop}}),g&&(()=>{const t=e.url||e.path,n=()=>x(!1),l=e.file_size?`${Math.round(e.file_size/1024)}KB`:"",r=e.mime_type||"";return T?F.jsx(Ee,{isOpen:!0,src:t,alt:e.filename,title:e.filename,subtitle:`${e.width||"?"}×${e.height||"?"} · ${l}`,onClose:n}):"video"===E?F.jsx(fe,{isOpen:!0,src:t,title:e.filename,subtitle:`${z.toUpperCase()} · ${l}`,onClose:n}):"audio"===E?F.jsx(ge,{isOpen:!0,src:t,title:e.filename,subtitle:`${z.toUpperCase()} · ${l}`,onClose:n}):r.includes("pdf")?F.jsx(ye,{isOpen:!0,src:t,title:e.filename,subtitle:l,onClose:n}):(e=>!(!e||!De.has(e)&&!e.startsWith("text/")))(r)?F.jsx(Ne,{isOpen:!0,src:t,title:e.filename,subtitle:`${z.toUpperCase()} · ${l}`,mimeType:r,fileSize:e.file_size||0,onClose:n}):F.jsx(Se,{isOpen:!0,src:t,title:e.filename,subtitle:`${z.toUpperCase()} · ${l}`,mimeType:r,fileSize:e.file_size||0,onClose:n})})()]})}function Re(){return F.jsxs("div",{className:"limbo-image-card lb:animate-pulse",role:"status","aria-label":"Cargando imágen...",children:[F.jsx("div",{className:"lb:w-full lb:aspect-square lb:bg-neutral-gray-200 lb:rounded-md lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-spinner"})}),F.jsx("div",{className:"limbo-image-card-name lb:opacity-100 position-relative lb:bottom-0 lb:p-2",children:F.jsx("div",{className:"lb:h-4 lb:bg-neutral-gray-200 lb:rounded lb:w-3/4"})}),F.jsx("span",{className:"sr-only",children:"Cargando imágen..."})]})}function Fe({variant:e="info",toast:t=!1,fixed:n=!1,onClose:l,className:r="",children:a,role:i}){const[o,s]=y.useState(!1);if(y.useEffect(()=>{s(!1)},[a]),o)return null;const c=t||n?`${n?"lb:fixed lb:top-4 lb:right-4 lb:z-10000":t?"lb:absolute lb:top-5 lb:right-5 lb:w-fit lb:m-4 lb:z-50":""} ${{success:"lb:bg-green-600",danger:"lb:bg-red-500",warning:"lb:bg-yellow-500",info:"lb:bg-blue-500"}[e]||"lb:bg-gray-600"} lb:text-white lb:px-5 lb:py-3 lb:rounded-lg lb:shadow-lg lb:transition-all lb:duration-300 lb:animate-fade-in`:`limbo-alert limbo-alert-${e}`;return F.jsxs("div",{className:`${c} lb:pr-8 ${r}`,role:i||"alert",children:[a,F.jsx("button",{type:"button",onClick:e=>{e.stopPropagation(),l?l():s(!0)},className:"lb:absolute lb:top-1/2 lb:-translate-y-1/2 lb:right-2 lb:p-1 lb:rounded-full lb:opacity-60 lb:hover:opacity-100 lb:transition-opacity lb:cursor-pointer","aria-label":"Cerrar",children:F.jsx("span",{className:"icon icon-close-small-white icon--sm","aria-hidden":"true"})})]})}const Ue=[{value:"",label:"Todos los tipos"},{value:"image",label:"Imágenes"},{value:"video",label:"Videos"},{value:"document",label:"Documentos"},{value:"audio",label:"Audio"}];function Be({onSelect:e,onCrop:l,onDelete:r,deletingId:a,images:i,loading:o,error:s,filters:c={name:"",dateFrom:"",dateTo:"",uploadedBy:"",assetType:"",folder:""},debouncedFilters:u=null,onFiltersChange:d,filterConfig:b={showNameFilter:!0,showUploadedByFilter:!1,showDateFilter:!0,showTypeFilter:!1},loadingConfig:m={showPlaceholders:!0,placeholderCount:10,showSpinner:!0},allowedActions:h={select:!0,download:!0,copy:!0,delete:!0,crop:!0,variants:!0},allowedCategories:p=null,resolvedAccept:f=null,folderConfig:g=null,onFolderChange:v=null}){const{isSearching:x,searchPending:w}=function(e,t,n){const[l,r]=y.useState(!1),a=y.useRef(null);return y.useEffect(()=>(Object.keys(e).some(n=>e[n]!==t[n])?a.current=setTimeout(()=>{r(!0)},150):(a.current&&clearTimeout(a.current),r(!1)),()=>{a.current&&clearTimeout(a.current)}),[e,t]),{isSearching:l||n,searchPending:l}}(c,u||c,o),k=!1!==b.showNameFilter,C=!0===b.showUploadedByFilter,S=!1!==b.showDateFilter,j=!1!==b.showTypeFilter,N=!0===g?.showFolderFilter,E=g?.include?.length>0?g.include:null,$=g?.exclude?.length>0?g.exclude:null,_=!1!==g?.showFolderInfo,T=!1!==g?.allowMoveFolder&&!!v,z=!0===g?.allowCreateFolder,L=y.useMemo(()=>{const e=f&&!f.isAllTypes?function(e){if(!e||e.isAllTypes)return null;const l=new Set(e.categories);for(const r of e.extensions){const e=t[r]||[];for(const t of e)for(const[e,r]of Object.entries(n))r.includes(t)&&l.add(e)}for(const t of e.mimeTypes)for(const[e,r]of Object.entries(n))(r.includes(t)||t.startsWith(e+"/"))&&l.add(e);return l.size>0?[...l]:null}(f):p;return e?Ue.filter(t=>""===t.value||e.includes(t.value)):Ue},[f,p]),A=y.useRef(null),M=window.limboCore?.accessibilityManager;y.useEffect(()=>{if(A.current&&window.limboCore?.keyboardManager){const e="gallery-grid";A.current.setAttribute("data-grid-id",e),window.limboCore.keyboardManager.setupGridNavigation(A.current,{itemSelector:".limbo-image-card",gridId:e,columns:"auto"})}},[i]),y.useEffect(()=>{if(!o&&i.length>0){const e=i.slice(0,12).map(e=>e.url||e.path).filter(Boolean);e.length>0&&X(e,4)}},[o,i]);const P=y.useMemo(()=>{if(!c.assetType)return"archivos";return{image:"imágenes",video:"videos",document:"documentos",audio:"archivos de audio"}[c.assetType]||"archivos"},[c.assetType]);y.useEffect(()=>{o?M?.announceLoading(!0,"galería"):o||s?s&&M?.announceError(s,"galería"):(M?.announceLoading(!1,"galería"),i.length>0&&M?.announce(`Se encontraron ${i.length} ${P} en la galería`))},[o,s,i.length,M,P]),y.useEffect(()=>{w&&M?.announce("Buscando...","polite")},[w,M]);const I=e=>{const{name:t,value:n}=e.target;d&&d({...c,[t]:n})},D=c.name||c.dateFrom||c.dateTo||c.uploadedBy||c.assetType||c.folder,O=x&&i.length>0&&!o;return F.jsxs("div",{className:"lb:w-full lb:max-w-full lb:py-2 lb:overflow-x-hidden lb:box-border",children:[F.jsx("div",{className:"lb:px-2 lb:mb-3 lb:mx-2 lb:max-w-full lb:overflow-x-hidden lb:box-border",children:F.jsxs("form",{className:"limbo-filters flex items-stretch content-stretch flex-row",onSubmit:e=>e.preventDefault(),role:"search","aria-label":"Filtrar archivos",children:[k&&F.jsxs("div",{className:"limbo-filter-group limbo-filter-group--name",children:[F.jsxs("label",{htmlFor:"name",className:"limbo-filter-label",children:["Nombre",w&&F.jsx("span",{className:"limbo-filter-searching","aria-hidden":"true",children:F.jsx("span",{className:"icon icon-spinner lb:animate-spin lb:w-3 lb:h-3"})})]}),F.jsx("input",{type:"text",name:"name",id:"name",placeholder:"Buscar...",value:c.name,onChange:I,className:"limbo-filter-input",autoComplete:"off"})]}),S&&F.jsxs("div",{className:"limbo-filter-dates",children:[F.jsxs("div",{className:"limbo-filter-group limbo-filter-group--date",children:[F.jsx("label",{htmlFor:"dateFrom",className:"limbo-filter-label",children:"Desde"}),F.jsx("input",{type:"date",name:"dateFrom",id:"dateFrom",value:c.dateFrom,onChange:I,className:"limbo-filter-input"})]}),F.jsxs("div",{className:"limbo-filter-group limbo-filter-group--date",children:[F.jsx("label",{htmlFor:"dateTo",className:"limbo-filter-label",children:"Hasta"}),F.jsx("input",{type:"date",name:"dateTo",id:"dateTo",value:c.dateTo,onChange:I,className:"limbo-filter-input"})]})]}),j&&L.length>1&&F.jsxs("div",{className:"limbo-filter-group limbo-filter-group--type",children:[F.jsx("label",{htmlFor:"assetType",className:"limbo-filter-label",children:"Tipo"}),F.jsx("select",{name:"assetType",id:"assetType",value:c.assetType||"",onChange:I,className:"limbo-filter-input limbo-filter-select",children:L.map(e=>F.jsx("option",{value:e.value,children:e.label},e.value))})]}),N&&F.jsx("div",{className:"limbo-filter-group limbo-filter-group--folder",children:F.jsx(Pe,{value:c.folder||"",onChange:e=>I({target:{name:"folder",value:e?.slug||""}}),allowCreate:!1,label:"Carpeta",showAssetCount:!0,includeNoFolder:!0,allowedSlugs:E,excludeSlugs:$,mode:"filter"})}),C&&F.jsxs("div",{className:"limbo-filter-group",children:[F.jsx("label",{htmlFor:"uploadedBy",className:"limbo-filter-label",children:"Subido por"}),F.jsx("input",{type:"text",name:"uploadedBy",id:"uploadedBy",placeholder:"Usuario...",value:c.uploadedBy,onChange:I,className:"limbo-filter-input",style:{minWidth:"100px",maxWidth:"140px"}})]}),F.jsxs("div",{children:[F.jsx("span",{className:"lb:h-[37%] block"}),F.jsxs("button",{type:"button",onClick:()=>{d&&d({name:"",uploadedBy:"",dateFrom:"",dateTo:"",assetType:"",folder:""})},disabled:!D,className:"limbo-filter-clear-btn","aria-label":"Limpiar todos los filtros",title:"Limpiar filtros",children:[F.jsx("span",{className:"icon icon-close-small"}),"Limpiar"]})]})]})}),o?F.jsxs("div",{className:"lb:relative",children:[F.jsx("div",{className:"lb:relative lb:inset-0 lb:flex lb:items-center lb:justify-center lb:bg-white/80 lb:z-10 lb:min-h-75",children:F.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-3",children:[F.jsx("span",{className:"icon icon-spinner lb:p-4 lb:animate-spin"}),F.jsxs("span",{className:"lb:text-sm lb:text-gray-600 lb:font-medium",children:["Cargando ",P,"..."]})]})}),m.showPlaceholders&&F.jsx("div",{ref:A,className:"limbo-gallery lb:opacity-30","data-limbo-responsive":!0,role:"grid","aria-label":`Cargando ${P} de la galería`,"aria-busy":"true",children:Array.from({length:m.placeholderCount}).map((e,t)=>F.jsx("div",{role:"gridcell","aria-posinset":t+1,"aria-setsize":m.placeholderCount,className:"lb:min-w-0",children:F.jsx(Re,{})},`skeleton-${t}`))})]}):s?F.jsx(Fe,{variant:"danger",className:"lb:text-center",children:s}):F.jsxs("div",{className:"lb:relative",children:[O&&F.jsx("div",{className:"limbo-search-overlay",role:"status","aria-live":"polite","aria-label":"Buscando archivos",children:F.jsxs("div",{className:"limbo-search-overlay__content",children:[F.jsx("span",{className:"icon icon-spinner lb:animate-spin"}),F.jsx("span",{children:"Buscando..."})]})}),F.jsx("div",{ref:A,className:"limbo-gallery lb:px-3 lb:pt-4 lb:box-border lb:max-w-full "+(O?"lb:opacity-50 lb:pointer-events-none":""),"data-limbo-responsive":!0,"data-grid-id":"gallery-grid",role:"grid","aria-label":`Galería de ${P}. Use las flechas para navegar`,"aria-busy":O,children:i.length>0?i.map((t,n)=>F.jsx("div",{role:"gridcell","aria-posinset":n+1,"aria-setsize":i.length,className:"lb:min-w-0",children:F.jsx(Oe,{image:t,onSelect:e,onCrop:l,onDelete:h.delete&&r?()=>r(t.id):null,onFolderChange:v,thumbnailSize:32,isDeleting:a===t.id,showFolderInfo:_,allowMoveFolder:T,allowedFolderSlugs:E,excludedFolderSlugs:$,allowCreateFolder:z,allowedActions:h})},t.id)):F.jsx("div",{className:"lb:col-span-full lb:text-center lb:text-gray-500 lb:py-8",role:"status","aria-live":"polite",children:F.jsxs("p",{children:["No se han encontrado ",P]})})})]})]})}function We({previewUrl:e,fileName:t}){const[n,l]=y.useState(!1),[r,a]=y.useState(!1),i=y.useRef(null);return r?F.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:justify-center lb:p-8 lb:min-h-[200px] lb:bg-gray-100 lb:rounded-lg",children:[F.jsx("span",{className:"icon icon-video icon--xl lb:text-gray-400 lb:mb-4"}),F.jsx("p",{className:"lb:text-sm lb:text-gray-600",children:"No se puede reproducir el video"}),F.jsx("p",{className:"lb:text-xs lb:text-gray-500 lb:mt-1",children:t})]}):F.jsxs("div",{className:"lb:relative lb:w-full lb:min-w-65 lb:max-w-md lb:aspect-video lb:bg-black lb:rounded-lg lb:overflow-hidden",children:[F.jsx("video",{ref:i,src:e,className:"lb:absolute lb:inset-0 lb:w-full lb:h-full lb:object-contain",onEnded:()=>{l(!1)},onError:()=>{a(!0)},onPlay:()=>l(!0),onPause:()=>l(!1),controls:!0,preload:"metadata",children:"Tu navegador no soporta la reproduccion de video."}),!n&&F.jsx("button",{type:"button",onClick:()=>{i.current&&(n?i.current.pause():i.current.play(),l(!n))},className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center lb:bg-black/30 lb:hover:bg-black/40 lb:transition-colors lb:cursor-pointer","aria-label":"Reproducir video",children:F.jsx("div",{className:"lb:w-16 lb:h-16 lb:rounded-full lb:bg-white/90 lb:flex lb:items-center lb:justify-center lb:shadow-lg",children:F.jsx("span",{className:"icon icon-play icon--lg lb:text-gray-800 lb:ml-1"})})}),F.jsxs("div",{className:"lb:absolute lb:top-2 lb:right-2 lb:bg-black/60 lb:text-white lb:px-2 lb:py-1 lb:rounded lb:text-xs lb:flex lb:items-center lb:gap-1",children:[F.jsx("span",{className:"icon icon-video icon--xs"}),F.jsx("span",{children:"VIDEO"})]})]})}function qe({previewUrl:e,fileName:t,fileSize:n}){const[l,r]=y.useState(!1),[a,i]=y.useState(!1),[o,s]=y.useState(0),[c,u]=y.useState(0),d=y.useRef(null),b=e=>{if(!e||isNaN(e))return"0:00";return`${Math.floor(e/60)}:${Math.floor(e%60).toString().padStart(2,"0")}`};return a?F.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:justify-center lb:p-8 lb:min-h-50 lb:bg-gray-100 lb:rounded-lg",children:[F.jsx("span",{className:"icon icon-audio icon--xl lb:text-gray-400 lb:mb-4"}),F.jsx("p",{className:"lb:text-sm lb:text-gray-600",children:"No se puede reproducir el audio"}),F.jsx("p",{className:"lb:text-xs lb:text-gray-500 lb:mt-1",children:t})]}):F.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:justify-center lb:p-6 lb:min-h-50",children:[F.jsxs("div",{className:"lb:relative lb:mb-4",children:[F.jsx("div",{className:"lb:w-24 lb:h-24 lb:flex lb:items-center lb:justify-center lb:bg-linear-to-br lb:from-purple-100 lb:to-blue-100 lb:rounded-full",children:F.jsx("span",{className:"icon icon-audio icon--xl lb:text-purple-600"})}),F.jsx("button",{type:"button",onClick:()=>{d.current&&(l?d.current.pause():d.current.play())},className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center lb:rounded-full lb:bg-black/0 lb:hover:bg-black/10 lb:transition-colors lb:cursor-pointer","aria-label":l?"Pausar":"Reproducir",children:F.jsx("div",{className:"lb:w-10 lb:h-10 lb:rounded-full lb:bg-white lb:shadow-md lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:`icon ${l?"icon-pause":"icon-play"} icon--md lb:text-gray-800 ${l?"":"lb:ml-0.5"}`})})})]}),F.jsx("p",{className:"lb:text-sm lb:font-medium lb:text-gray-800 lb:text-center lb:max-w-full lb:truncate lb:px-4",children:t}),F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2 lb:mt-2 lb:text-xs lb:text-gray-500",children:[F.jsx("span",{children:b(c)}),F.jsx("span",{children:"/"}),F.jsx("span",{children:b(o)}),n&&F.jsxs(F.Fragment,{children:[F.jsx("span",{children:"•"}),F.jsx("span",{children:ke(n)})]})]}),F.jsx("div",{className:"lb:w-full lb:max-w-xs lb:mt-3",children:F.jsx("div",{className:"lb:h-1.5 lb:bg-gray-200 lb:rounded-full lb:overflow-hidden lb:cursor-pointer",onClick:e=>{if(!d.current||!o)return;const t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left;d.current.currentTime=n/t.width*o},role:"slider","aria-label":"Progreso de audio","aria-valuenow":c,"aria-valuemin":0,"aria-valuemax":o,tabIndex:0,children:F.jsx("div",{className:"lb:h-full lb:bg-purple-500 lb:rounded-full lb:transition-all lb:duration-100 lb:pointer-events-none",style:{width:o>0?c/o*100+"%":"0%"}})})}),F.jsx("audio",{ref:d,src:e,onPlay:()=>r(!0),onPause:()=>r(!1),onTimeUpdate:()=>{d.current&&u(d.current.currentTime)},onLoadedMetadata:()=>{d.current&&s(d.current.duration)},onEnded:()=>{r(!1),u(0)},onError:()=>{i(!0)},preload:"metadata"})]})}function Ve({file:e,image:t,onDiscard:n,onRetry:l,onDownload:r,onSelect:a,showRetry:i=!1,disabled:o=!1,showCropButton:s,selectedFolder:c=null,onFolderChange:u=null,folderConfig:d=null}){const b=e||t,[m,h]=y.useState(null),[p,f]=y.useState({name:"",size:"",type:"",category:"unknown"}),[g,v]=y.useState(!1),[x,w]=y.useState(!1),[k,C]=y.useState(""),S="image"===p.category,j="video"===p.category,N="audio"===p.category,E=void 0!==s?s:S;y.useEffect(()=>{if(!b)return void h(null);const e=URL.createObjectURL(b);h(e);const t=b.name||"archivo",n=b.type||"",l=(e=>e?e.startsWith("image/")?"image":e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":"application/pdf"===e||e.includes("document")||e.includes("msword")||e.includes("spreadsheet")||e.includes("presentation")||e.startsWith("text/")?"document":"unknown":"unknown")(n),r=(e=>{const t=e?.split(".")[0]?.toLowerCase()||"";return["ai-image","ai_image","generated","imagen-ia","imagen_ia"].some(e=>t.startsWith(e))})(t);if(f({name:t,size:ke(b.size||0),type:n,category:l}),r)C(""),w(!1);else{const e=t.split(".")[0];C(e)}return()=>{URL.revokeObjectURL(e)}},[b]);if(!b||!m)return null;return F.jsxs("div",{className:"lb:w-full lb:max-w-full lb:bg-white lb:border lb:border-gray-200 lb:rounded-lg lb:px-1 lb:sm:px-3 lb:py-2 lb:m-0 lb:shadow-sm lb:overflow-hidden lb:box-border",children:[F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between lb:mb-4 lb:px-1",children:[F.jsx("h3",{className:"lb:text-sm lb:font-medium lb:text-gray-700",children:(()=>{switch(p.category){case"image":return"Vista previa de imagen";case"video":return"Vista previa de video";case"audio":return"Vista previa de audio";case"document":return"Vista previa de documento";default:return"Vista previa de archivo"}})()}),F.jsx("button",{type:"button",onClick:n,disabled:o,className:"lb:p-1.5 lb:text-gray-400 lb:cursor-pointer lb:hover:text-gray-600 lb:hover:bg-red-300 lb:rounded lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed","aria-label":"Descartar archivo",title:"Descartar archivo",children:F.jsx("span",{className:"icon icon-close-small icon--md"})})]}),F.jsx("div",{className:"lb:flex lb:justify-center lb:content-stretch lb:items-stretch",children:F.jsxs("div",{className:"lb:flex lb:flex-col lb:justify-stretch lb:content-stretch",children:[d?.showFolderSelector&&u&&F.jsx("div",{className:"lb:mb-4 lb:px-1 lb:flex lb:items-stretch lb:justify-stretch",children:F.jsx(Pe,{value:c?.slug||c,onChange:u,allowCreate:!1!==d?.allowCreateFolder,label:"Guardar en carpeta",showAssetCount:!0,className:"lb:w-full",allowedSlugs:d?.include?.length>0?d.include:null,mode:"upload",disabled:o})}),F.jsxs("div",{className:"lb:flex lb:flex-col lb:justify-center lb:md:flex-row lb:gap-2 lb:md:gap-6",children:[F.jsxs("div",{className:"lb:flex-1 lb:flex lb:flex-col lb:items-center lb:justify-center"+(S?" lb:min-w-100":""),children:[S?F.jsxs("div",{className:"lb:relative lb:w-full lb:max-w-md lb:aspect-video lb:bg-gray-100 lb:rounded-lg lb:overflow-hidden lb:cursor-zoom-in lb:hover:ring-2 lb:hover:ring-brand-blue-800 lb:transition-all",onClick:()=>v(!0),role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),v(!0))},"aria-label":"Click para ver imagen en tamano completo",title:"Click para ver en tamano completo",children:[F.jsx("img",{src:m,alt:"Vista previa",className:"lb:absolute lb:inset-0 lb:w-full lb:h-full lb:object-contain"}),F.jsxs("div",{className:"lb:absolute lb:top-2 lb:right-2 lb:bg-black/50 lb:text-white lb:px-2 lb:py-1 lb:rounded lb:text-xs lb:flex lb:items-center lb:gap-1",children:[F.jsx("span",{className:"icon icon-search-white icon--xs"}),F.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Ampliar"})]})]}):j?F.jsx(We,{previewUrl:m,fileName:p.name}):N?F.jsx(qe,{previewUrl:m,fileName:p.name,fileSize:b?.size}):F.jsx(Ce,{file:b,mimeType:p.type,category:p.category}),S&&F.jsx("div",{className:"lb:mt-3 lb:text-center lb:space-y-1 lb:w-full",children:F.jsx("div",{className:"lb:rounded-sm lb:w-fit lb:gap-0.5 lb:p-0.5 lb:min-w-fit lb:mx-auto",children:F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-center lb:gap-3 lb:text-xs lb:text-gray-500",children:[F.jsx("span",{children:p.size}),F.jsx("span",{children:"•"}),F.jsx("span",{children:p.type.split("/")[1]?.toUpperCase()||"FILE"})]})})})]}),F.jsxs("div",{className:"lb:flex lb:flex-row lb:md:flex-col lb:gap-2 lb:justify-items-stretch lb:justify-center lb:md:justify-start lb:items-stretch lb:md:min-w-35",children:[F.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-1",children:[F.jsxs("label",{htmlFor:"assetPreviewNameInput",className:"lb:flex lb:items-center lb:w-fit",children:[F.jsx("span",{className:"lb:me-1 lb:text-sm",children:"Nombre:"}),F.jsx("input",{id:"assetPreviewNameInput",onChange:e=>(e=>{const t=e.target.value.trim();C(e.target.value),t.length>0&&w(!1);const n=p.name,l=n.lastIndexOf("."),r=-1!==l?n.substring(l):"";f(e=>({...e,name:t?t+r:r}))})(e),value:k,className:"limbo-input-image-name lb:w-fit lb:px-1 lb:text-sm lb:font-medium lb:text-gray-800 lb:border lb:rounded lb:truncate lb:focus:outline lb:focus:outline-neutral-gray-100 lb:focus:transform-none lb:focus:shadow-none lb:focus:opacity-100 "+(x?"lb:border-red-1000 lb:bg-red-50":"lb:border-gray-300"),placeholder:"Escribe un nombre...",title:"El nombre es obligatorio",required:!0})]}),x&&F.jsx("span",{className:"lb:text-xs lb:text-red-1000 lb:ml-1",children:"El nombre es obligatorio"})]}),i&&l&&F.jsxs("button",{type:"button",onClick:l,disabled:o,className:"lb:flex-1 lb:md:flex-none lb:flex lb:items-center lb:justify-center lb:gap-2 lb:px-4 lb:py-2.5 lb:bg-white lb:border lb:border-gray-300 lb:text-gray-700 lb:rounded-lg lb:hover:bg-gray-50 lb:cursor-pointer lb:hover:border-gray-400 lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed lb:text-sm lb:font-medium","aria-label":"Intentarlo de nuevo",title:"Generar de nuevo con el mismo prompt",children:[F.jsx("span",{className:"icon icon-refresh icon--sm"}),F.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Reintentar"}),F.jsx("span",{className:"lb:sm:hidden",children:"Retry"})]}),F.jsxs("button",{type:"button",onClick:()=>{if(!m||o)return;const e=document.createElement("a");e.href=m,e.download=p.name,document.body.appendChild(e),e.click(),document.body.removeChild(e),r&&r()},disabled:o,className:"lb:flex-1 lb:cursor-pointer lb:md:flex-none lb:flex lb:items-center lb:justify-center lb:gap-2 lb:px-4 lb:py-2.5 lb:bg-white lb:border lb:border-gray-300 lb:text-gray-700 lb:rounded-lg lb:hover:bg-gray-50 lb:hover:border-gray-400 lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed lb:text-sm lb:font-medium","aria-label":"Descargar archivo",children:[F.jsx("span",{className:"icon icon-download icon--sm"}),F.jsx("span",{children:"Descargar"})]}),F.jsxs("button",{type:"button",onClick:()=>{k.trim()?(w(!1),a&&a(p.name)):w(!0)},disabled:o,className:"lb:flex-1 lb:md:flex-none lb:flex lb:items-center lb:justify-center lb:gap-2 lb:px-4 lb:py-2.5 lb:bg-brand-blue-800 lb:border lb:border-brand-blue-800 lb:text-white lb:rounded-lg lb:hover:bg-brand-blue-1000 lb:cursor-pointer lb:hover:border-brand-blue-1000 lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed lb:text-sm lb:font-medium lb:shadow-sm","aria-label":E?"Seleccionar para recortar":"Seleccionar archivo",children:[F.jsx("span",{className:"icon icon-tick-white icon--sm"}),F.jsx("span",{children:"Seleccionar"})]})]})]})]})}),S&&F.jsx(Ee,{isOpen:g,src:m,alt:p.name,title:p.name,subtitle:`${p.size} • ${p.type.split("/")[1]?.toUpperCase()||"IMAGE"}`,onClose:()=>v(!1)})]})}const He={image:["image/jpeg","image/png","image/webp","image/svg+xml"],video:["image/gif","video/mp4","video/webm","video/quicktime","video/x-msvideo"],document:["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","text/plain","text/csv","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation"],audio:["audio/mpeg","audio/wav","audio/ogg","audio/webm"]},Ke={image:"JPG, PNG, SVG, WebP, GIF",video:"GIF, MP4, WebM, MOV, AVI",document:"PDF, DOC, DOCX, XLS, XLSX, TXT, PPT, PPTX",audio:"MP3, WAV, OGG"},Ge=["image","video","document","audio"];function Qe({file:e,setFile:t,previewUrl:n,setPreviewUrl:l,fileInputRef:r,onSelect:a,disabled:i,allowedCategories:s=null,resolvedAccept:c=null,selectedFolder:u=null,onFolderChange:d=null,folderConfig:b=null}){const[m,h]=y.useState(!1),{acceptAttribute:p,allowedMimeTypes:f,formatLabels:g,categories:v}=y.useMemo(()=>{if(c&&!c.isAllTypes)return{acceptAttribute:c.acceptString,allowedMimeTypes:new Set(c.mimeTypes),formatLabels:o(c),categories:c.categories.length>0?c.categories:Ge};const e=null===s?Ge:s,t=[],n=[];return e.forEach(e=>{He[e]&&(t.push(...He[e]),Ke[e]&&n.push(Ke[e]))}),{acceptAttribute:t.join(","),allowedMimeTypes:new Set(t),formatLabels:n.join(", "),categories:e}},[s,c]),x=c&&!c.isAllTypes?c.includesImages&&1===c.categories.length&&"image"===c.categories[0]:1===v.length&&"image"===v[0],w=e=>{if(t(e),e){const t=URL.createObjectURL(e);l(t)}else l(null)};return F.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-6","aria-label":x?"Subir imagen desde dispositivo":"Subir archivo desde dispositivo",children:[F.jsxs("label",{htmlFor:"file-input",className:"lb:w-full lb:max-w-full lb:flex lb:flex-col lb:items-center lb:justify-center lb:border-2 lb:border-dashed lb:rounded-xl lb:p-8 lb:cursor-pointer lb:transition lb:box-border "+(m?"lb:border-brand-blue-1000 lb:bg-brand-blue-100 lb:scale-[1.02]":"lb:border-brand-blue-200 lb:hover:border-brand-blue-1000 lb:hover:to-bright-blue-200 lb:hover:from-brand-blue-50 lb:focus-within:border-brand-blue-800 lb:from-bright-blue-50 lb:to-brand-blue-50 lb:bg-linear-to-br"),tabIndex:0,style:{outline:"none"},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),i||h(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),e.currentTarget.contains(e.relatedTarget)||h(!1)},onDrop:e=>{if(e.preventDefault(),e.stopPropagation(),h(!1),i)return;const t=e.dataTransfer?.files;if(t&&t.length>0){const e=t[0];(e=>{if(!e||!e.type)return!1;if(c&&!c.isAllTypes)return function(e,t){if(!t||t.isAllTypes)return!0;if(!e)return!1;if(t.mimeTypes.includes(e))return!0;for(const n of t.categories)if(e.startsWith(n+"/"))return!0;return!1}(e.type,c);if(f.has(e.type))return!0;for(const t of v)if("image"===t&&e.type.startsWith("image/")||"video"===t&&e.type.startsWith("video/")||"audio"===t&&e.type.startsWith("audio/"))return!0;return!1})(e)&&w(e)}},children:[F.jsx("span",{className:"icon icon-upload icon--lg lb:mb-2","aria-hidden":"true"}),F.jsx("span",{className:"lb:font-medium lb:text-brand-blue-1000 lb:mb-1",children:x?"Haz clic o arrastra una imagen aqui":"Haz clic o arrastra un archivo aqui"}),F.jsxs("span",{className:"lb:text-sm lb:text-neutral-700",children:["Formatos permitidos: ",F.jsx("span",{className:"lb:truncate lb:wrap-",children:g})]}),F.jsx("input",{id:"file-input",ref:r,type:"file",accept:p,onChange:e=>{const t=e.target.files[0];w(t)},disabled:i,className:"lb:sr-only","aria-label":x?"Seleccionar imagen":"Seleccionar archivo"})]}),e&&F.jsx(Ve,{file:e,onDiscard:()=>{t(null),l(null),r.current&&(r.current.value="")},onDownload:()=>{},onSelect:t=>{if(e&&!i&&a)if(t&&t!==e.name){const n=new File([e],t,{type:e.type});a(n)}else a(e)},showRetry:!1,disabled:i,selectedFolder:u,onFolderChange:d,folderConfig:b})]})}const Xe="/api";const Ye=new Map;function Je(e=!1){const[t,n]=y.useState([]),[l,r]=y.useState(!0),[a,i]=y.useState(null);y.useEffect(()=>{const t=`ai-services-${e}`,l=Ye.get(t),a=Date.now();if(l&&a-l.timestamp<864e5)return n(l.data),void r(!1);let o=!0;return(async()=>{try{const l=await function(e=!1){return ne({endpoint:"/ai/services",prod:e,basePath:Xe})}(e);if(!o)return;const r=l?.data||l?.result||[],i=Array.isArray(r)?r.map(e=>({label:e.name||e.label,slug:e.slug,type:e.type,description:e.description,image:e.image,costInfo:e.cost_info||null,supportsImageInput:e.supports_image_input||!1})):Object.entries(r).map(([e,t])=>({label:e,slug:t,type:"image_generation",description:null,image:null,costInfo:null,supportsImageInput:!1}));n(i),Ye.set(t,{data:i,timestamp:a})}catch(l){o&&i(l.message)}finally{o&&r(!1)}})(),()=>{o=!1}},[e]);return{services:t,loading:l,error:a,invalidateCache:()=>{Ye.delete(`ai-services-${e}`)}}}const Ze=new Map;function et(e=!1){const[t,n]=y.useState(null),[l,r]=y.useState(!1),[a,i]=y.useState(null);return{params:t,loading:l,error:a,fetchParams:async t=>{r(!0),i(null);const l=`${e}-${t}`,a=Date.now(),o=Ze.get(l);if(o&&a-o.timestamp<864e5)return n(o.data),r(!1),o.data;try{const r=await function({services:e=null,form:t=!1}={},n=!1){const l={};return e&&(l.services=e),!1!==t&&(l.form=t),ne({endpoint:"/ai/params"+(Object.keys(l).length?"?"+new URLSearchParams(l).toString():""),method:"GET",prod:n,basePath:"/api/atenea"})}({services:t,form:!1},e),i=r?.result?.data||r?.data||r?.result||r;return n(i),Ze.set(l,{data:i,timestamp:a}),i}catch(s){return i(s.message),n(null),null}finally{r(!1)}},reset:()=>{i(null),n(null)}}}function tt({show:e=!1,message:t="Cargando...",className:n=""}){return e?F.jsx("div",{className:`lb:absolute lb:inset-0 lb:min-h-50 lb:bg-white/80 lb:backdrop-blur-sm lb:z-50 lb:flex lb:flex-col lb:items-center lb:justify-center ${n}`,"aria-live":"polite","aria-busy":"true",role:"status",children:F.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-4",children:[F.jsx("span",{className:"icon icon-spinner lb:p-4 lb:animate-spin"}),F.jsx("p",{className:"lb:text-brand-blue-1000 lb:font-medium lb:text-lg",children:t})]})}):null}function nt({image:e,onDiscard:t,onRetry:n,onDownload:l,onSelect:r,showRetry:a=!1,disabled:i=!1,selectedFolder:o=null,onFolderChange:s=null,folderConfig:c=null}){const[u,d]=y.useState(null),[b,m]=y.useState({name:"",size:"",type:""}),[h,p]=y.useState(!1),[f,g]=y.useState(!1),[v,x]=y.useState("");y.useEffect(()=>{if(!e)return void d(null);const t=URL.createObjectURL(e);d(t);const n=e.name||"imagen.webp",l=(e=>{const t=e?.split(".")[0]?.toLowerCase()||"";return["ai-image","ai_image","generated","imagen-ia","imagen_ia"].some(e=>t.startsWith(e))})(n);return m({name:n,size:w(e.size||0),type:e.type||"image/webp"}),l?(x(""),g(!1)):x(n.split(".")[0]),()=>{URL.revokeObjectURL(t)}},[e]);const w=e=>{if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(1024));return Math.round(e/Math.pow(1024,t)*100)/100+" "+["Bytes","KB","MB","GB"][t]};return e&&u?F.jsxs("div",{className:"lb:w-full lb:max-w-full lb:bg-white lb:border lb:border-gray-200 lb:rounded-lg lb:px-1 lb:sm:px-3 lb:py-2 lb:m-0 lb:shadow-sm lb:overflow-hidden lb:box-border",children:[F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between lb:mb-4 lb:px-1",children:[F.jsx("h3",{className:"lb:text-sm lb:font-medium lb:text-gray-700",children:"Vista previa de imagen"}),F.jsx("button",{type:"button",onClick:t,disabled:i,className:"lb:p-1.5 lb:text-gray-400 lb:cursor-pointer lb:hover:text-gray-600 lb:hover:bg-red-300 lb:rounded lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed","aria-label":"Descartar imagen",title:"Descartar imagen",children:F.jsx("span",{className:"icon icon-close-small icon--md"})})]}),c?.showFolderSelector&&s&&F.jsx("div",{className:"lb:mb-4 lb:px-1",children:F.jsx(Pe,{value:o?.slug||o,onChange:s,allowCreate:!1!==c?.allowCreateFolder,label:"Guardar en carpeta",showAssetCount:!0,allowedSlugs:c?.include?.length>0?c.include:null,mode:"upload",disabled:i})}),F.jsxs("div",{className:"lb:flex lb:flex-col lb:justify-center lb:md:flex-row lb:gap-2 lb:md:gap-6",children:[F.jsxs("div",{className:"lb:flex-1 lb:md:flex-[0.4] lb:flex lb:flex-col lb:items-center lb:justify-center",children:[F.jsxs("div",{className:"lb:relative lb:w-full lb:max-w-md lb:aspect-video lb:bg-gray-100 lb:rounded-lg lb:overflow-hidden lb:cursor-zoom-in lb:hover:ring-2 lb:hover:ring-brand-blue-800 lb:transition-all",onClick:()=>p(!0),role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),p(!0))},"aria-label":"Click para ver imagen en tamaño completo",title:"Click para ver en tamaño completo",children:[F.jsx("img",{src:u,alt:"Vista previa",className:"lb:absolute lb:inset-0 lb:w-full lb:h-full lb:object-contain"}),F.jsxs("div",{className:"lb:absolute lb:top-2 lb:right-2 lb:bg-black/50 lb:text-white lb:px-2 lb:py-1 lb:rounded lb:text-xs lb:flex lb:items-center lb:gap-1",children:[F.jsx("span",{className:"icon icon-search-white icon--xs"}),F.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Ampliar"})]})]}),F.jsx("div",{className:"lb:mt-3 lb:text-center lb:space-y-1 lb:w-full",children:F.jsx("div",{className:"lb:rounded-sm lb:w-fit lb:gap-0.5 lb:p-0.5 lb:min-w-fit lb:mx-auto",children:F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-center lb:gap-3 lb:text-xs lb:text-gray-500",children:[F.jsx("span",{children:b.size}),F.jsx("span",{children:"•"}),F.jsx("span",{children:b.type.split("/")[1]?.toUpperCase()||"IMAGE"})]})})})]}),F.jsxs("div",{className:"lb:flex lb:flex-row lb:md:flex-col lb:gap-2 lb:justify-items-stretch lb:justify-center lb:md:justify-start lb:items-stretch lb:md:min-w-35",children:[F.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-1",children:[F.jsxs("label",{htmlFor:"uploadImageId",className:"lb:flex lb:items-center lb:w-fit",children:[F.jsx("span",{className:"lb:me-1 lb:text-sm",children:"Nombre:"}),F.jsx("input",{id:"uploadImageId",onChange:e=>(e=>{const t=e.target.value.trim();x(e.target.value),t.length>0&&g(!1);const n=b.name,l=n.lastIndexOf("."),r=-1!==l?n.substring(l):".webp";m(e=>({...e,name:t?t+r:r}))})(e),value:v,className:"limbo-input-image-name lb:w-fit lb:px-1 lb:text-sm lb:font-medium lb:text-gray-800 lb:border lb:rounded lb:truncate lb:focus:outline lb:focus:outline-neutral-gray-100 lb:focus:transform-none lb:focus:shadow-none lb:focus:opacity-100 "+(f?"lb:border-red-1000 lb:bg-red-50":"lb:border-gray-300"),placeholder:"Escribe un nombre...",title:"El nombre es obligatorio",required:!0})]}),f&&F.jsx("span",{className:"lb:text-xs lb:text-red-1000 lb:ml-1",children:"El nombre es obligatorio"})]}),a&&n&&F.jsxs("button",{type:"button",onClick:n,disabled:i,className:"lb:flex-1 lb:md:flex-none lb:flex lb:items-center lb:justify-center lb:gap-2 lb:px-4 lb:py-2.5 lb:bg-white lb:border lb:border-gray-300 lb:text-gray-700 lb:rounded-lg lb:hover:bg-gray-50 lb:cursor-pointer lb:hover:border-gray-400 lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed lb:text-sm lb:font-medium","aria-label":"Intentarlo de nuevo",title:"Generar de nuevo con el mismo prompt",children:[F.jsx("span",{className:"icon icon-refresh icon--sm"}),F.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Reintentar"}),F.jsx("span",{className:"lb:sm:hidden",children:"Retry"})]}),F.jsxs("button",{type:"button",onClick:()=>{if(!u||i)return;const e=document.createElement("a");e.href=u,e.download=b.name,document.body.appendChild(e),e.click(),document.body.removeChild(e),l&&l()},disabled:i,className:"lb:flex-1 lb:cursor-pointer lb:md:flex-none lb:flex lb:items-center lb:justify-center lb:gap-2 lb:px-4 lb:py-2.5 lb:bg-white lb:border lb:border-gray-300 lb:text-gray-700 lb:rounded-lg lb:hover:bg-gray-50 lb:hover:border-gray-400 lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed lb:text-sm lb:font-medium","aria-label":"Descargar imagen",children:[F.jsx("span",{className:"icon icon-download icon--sm"}),F.jsx("span",{children:"Descargar"})]}),F.jsxs("button",{type:"button",onClick:()=>{v.trim()?(g(!1),r&&r(b.name)):g(!0)},disabled:i,className:"lb:flex-1 lb:md:flex-none lb:flex lb:items-center lb:justify-center lb:gap-2 lb:px-4 lb:py-2.5 lb:bg-brand-blue-800 lb:border lb:border-brand-blue-800 lb:text-white lb:rounded-lg lb:hover:bg-brand-blue-1000 lb:cursor-pointer lb:hover:border-brand-blue-1000 lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed lb:text-sm lb:font-medium lb:shadow-sm","aria-label":"Seleccionar imagen para recortar",children:[F.jsx("span",{className:"icon icon-tick-white icon--sm"}),F.jsx("span",{children:"Seleccionar"})]})]})]}),F.jsx(Ee,{isOpen:h,src:u,alt:b.name,title:b.name,subtitle:`${b.size} • ${b.type.split("/")[1]?.toUpperCase()||"IMAGE"}`,onClose:()=>p(!1)})]}):null}function lt({prod:e,disabled:t,onSelect:n,selectedFolder:l,onFolderChange:r,folderConfig:a}){const i=Je(e),o=et(e),[s,c]=y.useState(""),[u,d]=y.useState(""),[b,m]=y.useState({}),[h,p]=y.useState(!1),[f,g]=y.useState(null),[x,w]=y.useState(null),[k,C]=y.useState(null),[S,j]=y.useState(!0),[N,E]=y.useState(!1),[$,_]=y.useState(null),[T,z]=y.useState(null),[L,A]=y.useState(!1),M=v.useRef(null),P=v.useRef(0);v.useEffect(()=>{if(!i.loading&&1===i.services.length){const e=i.services[0];d(e.slug),j(!1),o.fetchParams(e.slug,!0)}},[i.loading,i.services]),v.useEffect(()=>{if(!u)return;const e=o.params?.[u]?.parameters;if(e){const t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default??""]));t.service=u,m(t)}},[u,o.params]);const I=v.useMemo(()=>{const e=i.services.find(e=>e.slug===u);if(e?.supportsImageInput)return!0;const t=o.params?.[u]?.parameters;return!!t&&Object.entries(t).some(([e,t])=>"image"===t.type||"file"===t.type||"image_data"===e||"image"===e||"reference_image"===e)},[u,i.services,o.params]),D=e=>{e&&(["image/jpeg","image/png","image/webp"].includes(e.type)?e.size>4194304?g("La imagen de referencia no puede superar los 4MB."):(_(e),z(URL.createObjectURL(e)),g(null)):g("Formato no soportado. Usa JPG, PNG o WebP."))},O=e=>{D(e.target.files?.[0])},R=e=>{e.preventDefault(),e.stopPropagation(),P.current++,A(!0)},U=e=>{e.preventDefault(),e.stopPropagation(),P.current--,0===P.current&&A(!1)},B=e=>{e.preventDefault(),e.stopPropagation()},W=e=>{e.preventDefault(),e.stopPropagation(),P.current=0,A(!1);const t=e.dataTransfer?.files?.[0];D(t)},q=()=>{_(null),T&&URL.revokeObjectURL(T),z(null),M.current&&(M.current.value="")};v.useEffect(()=>()=>{T&&URL.revokeObjectURL(T)},[T]);const V=e=>{const{name:t,value:n}=e.target;m(e=>({...e,[t]:n}))},H=async(t,n=!1)=>{t.preventDefault(),p(!0),g(null),w(null);try{n?b.prompt=s:c(b.prompt||"");let t={...b};$&&(t.image=await(l=$,new Promise((e,t)=>{const n=new FileReader;n.onload=()=>e(n.result),n.onerror=t,n.readAsDataURL(l)})));const a=await function(e,t=!1){return ne({endpoint:"/ai/generate",method:"POST",body:e,prod:t,basePath:Xe})}(t,e);let i=null;if(a?.data?.images&&Array.isArray(a.data.images)&&a.data.images.length>0?i=a.data.images[0]:a?.result?.images&&Array.isArray(a.result.images)&&a.result.images.length>0?i=a.result.images[0]:Array.isArray(a)&&a.length>0?i=a[0]:"string"==typeof a&&(i=a),!i)throw new Error("No se pudo extraer la imagen de la respuesta");if(i.startsWith("http"))try{const e=`${window.limboCore?.config?.getGlobal()?.prod?"https://limbo.lefebvre.es":"https://led-dev-limbo-dev.eu.els.local"}/api/atenea/proxy?url=${encodeURIComponent(i)}`,t=await fetch(e,{credentials:"include",headers:{Authorization:`Bearer ${window.limboCore?.apiClient?.token||""}`}});if(!t.ok)throw new Error(`Failed to download image: ${t.status}`);const n=await t.blob(),l=new File([n],"ai-image.webp",{type:n.type||"image/webp"});C(l)}catch(r){throw new Error(`Error downloading image via proxy: ${r.message}`)}else{const e=i.replace(/^data:image\/\w+;base64,/,""),t=atob(e),n=new Array(t.length);for(let a=0;a<t.length;a++)n[a]=t.charCodeAt(a);const l=new Uint8Array(n),r=new File([l],"ai-image.webp",{type:"image/webp"});C(r)}w(a?.data?.images||a?.result?.images||null)}catch(a){g(a.message||"Error al generar la imagen")}finally{p(!1)}var l};return i.loading?F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-center lb:py-8",children:[F.jsx("span",{className:"limbo-loader lb:mr-2"})," Cargando servicios IA..."]}):i.services.length?F.jsx("div",{className:"lb:flex lb:flex-col lb:mx-4 lb:pb-2",children:S?F.jsxs(F.Fragment,{children:[F.jsx("h3",{id:"aiSelectDescription",className:"lb:text-2xl lb:font-semibold lb:text-brand-blue-1000 lb:mb-3",children:"Selecciona el modelo IA"}),i.error&&F.jsx(Fe,{variant:"danger",children:i.error}),F.jsx("div",{className:"lb:flex lb:flex-row lb:flex-wrap lb:justify-around lb:items-stretch lb:justify-items-stretch lb:content-stretch lb:gap-3 lb:w-full lb:max-w-7xl",children:i.services.map(e=>F.jsxs("button",{type:"button",onClick:()=>{d(e.slug),j(!1),m({}),w(null),g(null),C(null),o.fetchParams(e.slug,!0)},disabled:i.loading||t,className:`lb:group lb:relative lb:p-4 lb:rounded-lg lb:border-2 lb:transition-all lb:duration-200 lb:overflow-hidden lb:flex lb:flex-col lb:items-center lb:justify-center lb:min-h-30 lb:grow basis-sm lb:min-w-70 lb:border-gray-200 lb:hover:border-brand-blue-800 lb:hover:shadow-md lb:hover:text-black lb:lg:w-min ${i.loading||t?"lb:opacity-50 lb:cursor-not-allowed":"lb:cursor-pointer"} `,style:{position:"relative"},children:[e.image&&F.jsx("div",{className:"lb:absolute lb:inset-0 lb:bg-cover lb:bg-center lb:transition-opacity lb:duration-200 lb:group-hover:opacity-35",style:{backgroundImage:`url(${e.image})`,opacity:.2}}),F.jsxs("div",{className:"lb:relative lb:z-10 lb:flex lb:flex-col lb:items-center lb:justify-center lb:gap-2 lb:text-center",children:[F.jsx("span",{className:"lb:text-base lb:font-semibold lb:text-neutral-black-000",children:e.label}),e.description&&F.jsx("span",{className:"lb:text-sm lb:text-gray-950 lb:line-clamp-2 lb:drop-shadow lb:drop-shadow-neutral-white-000",children:e.description})]}),e.costInfo&&F.jsx("span",{className:"lb:absolute lb:top-0 lb:left-1 lb:inline-flex lb:items-center lb:gap-1 lb:py-0 lb:px-1 lb:mt-1 lb:text-xs lb:font-medium lb:text-warning-1000 lb:rounded-md lb:group-hover:bg-white/90",style:{zoom:"82%"},children:e.costInfo})]},e.slug))})]}):F.jsxs(F.Fragment,{children:[F.jsxs("div",{className:"lb:flex lb:flex-wrap lb:items-center lb:gap-3 lb:mb-2",children:[F.jsx("h3",{className:"lb:text-2xl lb:font-semibold lb:text-brand-blue-1000",children:i.services.find(e=>e.slug===u)?.label||"Generación IA"}),i.services.find(e=>e.slug===u)?.costInfo&&F.jsxs("div",{title:"Coste estimado por imagen que le cuesta a la empresa, este coste depende de la calidad de la imagen generada y puede variar según el proveedor IA, ten en cuenta este coste para hacer un uso más responsable del servicio IA",className:"lb:flex lb:items-center lb:gap-1","aria-description":"Coste estimado por imagen que le cuesta a la empresa, este coste depende de la calidad de la imagen generada y puede variar según el proveedor IA, ten en cuenta este coste para hacer un uso más responsable del servicio IA",children:[F.jsxs("span",{className:"lb:inline-flex lb:items-center lb:gap-1 lb:px-2 lb:py-0.5 lb:text-xs lb:font-medium lb:text-warning-1000 lb:bg-yellow-200/60 lb:rounded-full lb:border lb:border-warning-1000 lb:select-none",children:[F.jsx("span",{className:"icon icon-euro-blue icon--2sm icon--warning",style:{filter:"var(--limbo-icon-warning-dark)"}}),"Coste:"," ",i.services.find(e=>e.slug===u)?.costInfo]}),F.jsx("span",{className:"icon icon-info lb:cursor-help"})]})]}),o.loading&&F.jsx("div",{children:"Cargando parámetros..."}),o.error&&F.jsx(Fe,{variant:"danger",children:o.error}),u&&(()=>{const e=o.params?.[u]?.parameters;if(!e)return null;const n=Object.entries(e).filter(([e,t])=>!t.hidden&&"image"!==t.type&&"file"!==t.type),l=n.filter(([e])=>e.toLowerCase().includes("prompt")||e.toLowerCase().includes("query")),r=n.filter(([e])=>!e.toLowerCase().includes("prompt")&&!e.toLowerCase().includes("query")),a=(e,n)=>{let l=n.placeholder||"";l||(l="integer"===n.type?n.minValue&&n.maxValue?`Entre ${n.minValue} y ${n.maxValue}`:n.minValue?`Mínimo ${n.minValue}`:n.maxValue?`Máximo ${n.maxValue}`:"Introduce un número":e.toLowerCase().includes("prompt")?"Describe la imagen que deseas generar...":e.toLowerCase().includes("negative")?"Elementos a evitar en la imagen...":`Introduce ${(n.label||e).toLowerCase()}`);const r=e.toLowerCase().includes("prompt")||e.toLowerCase().includes("query");return F.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-1",children:[F.jsxs("label",{htmlFor:`ai-${e}`,className:"lb:text-xs lb:font-medium lb:text-brand-blue-1000",children:[n.label||e,n.required&&F.jsx("span",{className:"lb:text-red-1000 lb:ml-1",children:"*"})]}),n.options?F.jsx("select",{id:`ai-${e}`,name:e,value:b[e]??"",onChange:V,className:"limbo-input",disabled:t,title:n.label||e,children:n.options.map(e=>F.jsx("option",{value:e,children:e},e))}):r?F.jsx("textarea",{id:`ai-${e}`,name:e,value:b[e]??"",onChange:V,className:"limbo-input lb:resize-none lb:overflow-y-auto",disabled:t,required:n.required,placeholder:l,title:n.label||e,rows:3,style:{maxHeight:"9rem",minHeight:"3rem"},onInput:e=>{e.target.style.height="auto";const t=Math.min(e.target.scrollHeight,144);e.target.style.height=`${t}px`}}):F.jsx("input",{id:`ai-${e}`,type:"integer"===n.type?"number":"text",name:e,value:b[e]??"",onChange:V,className:"limbo-input",disabled:t,required:n.required,min:n.minValue,max:n.maxValue,placeholder:l,title:n.label||e})]},e)};return F.jsxs("div",{className:"lb:h-fit lb:w-full",children:[i.services.length>1&&F.jsxs("button",{type:"button",onClick:()=>{j(!0),d(""),m({}),w(null),g(null),C(null),q()},className:"lb:flex lb:cursor-pointer lb:items-center lb:gap-2 lb:text-brand-blue-800 lb:hover:text-brand-blue-1000 lb:mb-4 lb:font-medium",children:[F.jsx("span",{className:"icon icon-arrow-left"}),"Volver al menú de servicios"]}),F.jsxs("div",{className:"lb:relative",children:[F.jsxs("form",{onSubmit:H,"data-type":"ai",className:"lb:flex lb:flex-col lb:gap-3 lb:mt-4 lb:border-t lb:pt-4 lb:border-brand-blue-200","aria-label":"Formulario generación IA",children:[f&&F.jsx(Fe,{variant:"danger",className:"lb:mb-2",children:f}),F.jsx("div",{className:"lb:flex lb:flex-col lb:gap-3",children:l.map(([e,t])=>a(e,t))}),I&&F.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-2 lb:mt-1",children:[F.jsxs("label",{className:"lb:text-xs lb:font-medium lb:text-brand-blue-1000",children:["Imagen de referencia",F.jsx("span",{className:"lb:text-neutral-gray-500 lb:ml-1 lb:font-normal",children:"(opcional)"})]}),$?F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-3 lb:p-2 lb:bg-neutral-gray-50 lb:border lb:border-neutral-gray-200 lb:rounded-lg",children:[F.jsx("div",{className:"lb:w-16 lb:h-16 lb:rounded lb:overflow-hidden lb:shrink-0 lb:bg-neutral-gray-100",children:F.jsx("img",{src:T,alt:"Referencia",className:"lb:w-full lb:h-full lb:object-cover"})}),F.jsxs("div",{className:"lb:flex-1 lb:min-w-0",children:[F.jsx("p",{className:"lb:text-sm lb:text-neutral-gray-700 lb:truncate",children:$.name}),F.jsxs("p",{className:"lb:text-xs lb:text-neutral-gray-500",children:[($.size/1024).toFixed(0)," KB"]})]}),F.jsx("button",{type:"button",onClick:q,disabled:t||h,className:"lb:p-1.5 lb:text-neutral-gray-500 lb:cursor-pointer lb:hover:text-red-1000 lb:hover:bg-red-50 lb:rounded lb:transition-colors",title:"Quitar imagen de referencia",children:F.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[F.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),F.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):F.jsxs("label",{className:"lb:flex lb:items-center lb:justify-center lb:gap-2 lb:px-3 lb:py-2.5 lb:border lb:border-dashed lb:rounded-lg lb:cursor-pointer lb:transition-colors lb:text-sm "+(L?"lb:border-brand-blue-800 lb:bg-brand-blue-50/50 lb:text-brand-blue-800":"lb:border-neutral-gray-300 lb:text-neutral-gray-700 lb:hover:border-brand-blue-800 lb:hover:bg-brand-blue-50/30"),onDragEnter:R,onDragLeave:U,onDragOver:B,onDrop:W,children:[F.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[F.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),F.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),F.jsx("polyline",{points:"21 15 16 10 5 21"})]}),L?"Suelta la imagen aquí":"Subir imagen de referencia",F.jsx("input",{ref:M,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:O,disabled:t||h,className:"lb:sr-only"})]})]}),r.length>0&&F.jsxs("div",{className:"lb:border-t lb:border-gray-200 lb:pt-3",children:[F.jsxs("button",{type:"button",onClick:()=>E(!N),className:"lb:flex lb:items-center lb:gap-2 lb:text-sm lb:font-medium lb:text-brand-blue-800 lb:hover:text-brand-blue-1000 lb:mb-3 lb:transition-colors",children:[F.jsx("svg",{className:"lb:w-4 lb:h-4 lb:transition-transform "+(N?"lb:rotate-90":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),"Opciones avanzadas",!N&&F.jsxs("span",{className:"lb:text-xs lb:text-gray-500",children:["(",r.length," opciones)"]})]}),N&&F.jsx("div",{className:"lb:grid lb:grid-cols-2 lb:lg:grid-cols-3 lb:xl:grid-cols-4 lb:gap-3 lb:animate-fadeIn",children:r.map(([e,t])=>a(e,t))})]}),F.jsx("button",{type:"submit",disabled:h||t,title:h?"Generando imagen...":k?"Generar otra imagen":"Generar imagen",className:"limbo-btn lb:w-full lb:mt-2 "+(h?"lb:cursor-not-allowed limbo-btn-disabled":"limbo-btn-primary"),style:{minHeight:44},children:h?"Generando imagen...":k?"Generar otra imagen":"Generar imagen"})]}),F.jsx(tt,{show:h,message:"Generando imagen con IA..."})]})]})})(),k&&F.jsx("div",{className:"lb:mt-6 lb:md:w-full lb:mx-auto",children:F.jsx(nt,{image:k,onDiscard:()=>{C(null),w(null),g(null)},onRetry:e=>H(e,!0),onDownload:()=>{},onSelect:e=>{if(n){const t=k||x;if(e&&t&&e!==t.name){const l=new File([t],e,{type:t.type});n(l)}else n(t)}},showRetry:!0,disabled:h||t,selectedFolder:l,onFolderChange:r,folderConfig:a})})]})}):F.jsx(Fe,{variant:"warning",children:"No hay servicios IA disponibles."})}const rt="/api";const at=new Map;function it(e=!1){const[t,n]=y.useState([]),[l,r]=y.useState(!0),[a,i]=y.useState(null);y.useEffect(()=>{const t=`stock-services-${e}`,l=at.get(t),a=Date.now();if(l&&a-l.timestamp<864e5)return n(l.data),void r(!1);let o=!0;return(async()=>{try{const l=await function(e=!1){return ne({endpoint:"/stock/services",prod:e,basePath:rt})}(e);if(!o)return;if(204===l?.httpCode||null===l?.data)return n([]),i("No hay servicios de stock disponibles en este momento"),void at.set(t,{data:[],timestamp:a});const r=l?.data||l?.result||[],s=Array.isArray(r)?r.map(e=>({label:e.name||e.label,slug:e.slug,type:e.type,description:e.description,image:e.image})):Object.entries(r).map(([e,t])=>({label:e,slug:t,type:"stock_image",description:null,image:null}));n(s),at.set(t,{data:s,timestamp:a})}catch(l){o&&i(l.message)}finally{o&&r(!1)}})(),()=>{o=!1}},[e]);return{services:t,loading:l,error:a,invalidateCache:()=>{at.delete(`stock-services-${e}`)}}}function ot({prod:e,disabled:t,onSelect:n,selectedFolder:l,onFolderChange:r,folderConfig:a}){const i=v.useRef(null),o=it(e),s=(e,t)=>{try{const n=sessionStorage.getItem(`limbo_stock_${e}`);return n?JSON.parse(n):t}catch{return t}},[c,u]=y.useState(()=>s("selectedService","")),[d,b]=y.useState(()=>s("dynamicForm",{})),[m,h]=y.useState(()=>s("stockImages",[])),[p,f]=y.useState(()=>s("currentPage",1)),[g,x]=y.useState(()=>s("paginationInfo",null)),[w,k]=y.useState(null),C=et(e),[S,j]=y.useState(!1),[N,E]=y.useState(null),[$,_]=y.useState(null),[T,z]=y.useState(!0),[L,A]=y.useState(!1),[M,P]=y.useState(null);v.useEffect(()=>{sessionStorage.setItem("limbo_stock_selectedService",JSON.stringify(c))},[c]),v.useEffect(()=>{sessionStorage.setItem("limbo_stock_dynamicForm",JSON.stringify(d))},[d]),v.useEffect(()=>{sessionStorage.setItem("limbo_stock_stockImages",JSON.stringify(m))},[m]),v.useEffect(()=>{sessionStorage.setItem("limbo_stock_currentPage",JSON.stringify(p))},[p]),v.useEffect(()=>{sessionStorage.setItem("limbo_stock_paginationInfo",JSON.stringify(g))},[g]),v.useEffect(()=>{if(!o.loading&&1===o.services.length){const e=o.services[0];u(e.slug),z(!1),C.fetchParams(e.slug,!0)}},[o.loading,o.services]),v.useEffect(()=>{if(!c)return;const e=C.params?.[c]?.parameters;if(e){const t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default??""]));t.service=c,b(t)}},[c,C.params]);const I=e=>{const{name:t,value:n}=e.target;b(e=>({...e,[t]:n}))},D=async(t=1)=>{j(!0),E(null),1===t&&h([]);try{let n;if(1===t){const e=C.params?.[c]?.parameters,l={...d};Object.entries(e||{}).forEach(([e,t])=>{e in l||(l[e]=t.default??"")}),l.per_page=parseInt(l.per_page),l.service=c,l.page=t,n=l,i.current={...l}}else n={...i.current,page:t};const l=await function(e,t=!1){return ne({endpoint:"/stock/search",method:"POST",body:e,prod:t,basePath:rt})}(n,e),r=l?.data?.images||[];let a=l?.data?.pagination||null,o=null;a&&(o={total:a.total_count??a.total??r.length,per_page:a.per_page??(Array.isArray(r)?r.length:0),current_page:a.page??a.current_page??t}),h(O(Array.isArray(r)?r:[])),x(o),f(o?.current_page||t)}catch(n){E(n.message||"Error al buscar imágenes")}finally{j(!1)}},O=e=>{const t=new Set,n=[];return(e||[]).forEach((e,l)=>{const r=e.url||e.preview_url||e.full||e.preview;r&&!t.has(r)&&(t.add(r),n.push({...e,preview:e.preview_url||e.preview||e.url||e.full,full:e.url||e.full||e.preview_url,id:e.id||l,title:e.title||e.filename||`Imagen ${l+1}`,source:e.service||c,sourceTitle:o.services.find(e=>e.slug===c)?.label||c}))}),n},R=async e=>{e.preventDefault();const t=d.query||d.search||d.term||"";t.trim().length<5?E("La búsqueda debe tener al menos 5 caracteres"):(k(t),await D(1))},U=e=>{e<1||D(e)},B=async t=>{_(t.id),E(null);try{const n={service:c,image_id:t.id},l=await function(e,t=!1){return ne({endpoint:"/stock/download",method:"POST",body:e,prod:t,basePath:rt})}(n,e),r=l?.result?.url||l?.result?.download_url||l?.data?.images?.url||l?.data?.url||l?.images?.url||l?.url;if(!r)throw console.error("Download response structure:",l),new Error("No se pudo obtener la URL de descarga");{const n=`${ee({prod:e})}/api/atenea/proxy?url=${encodeURIComponent(r)}`,a=await fetch(n,{credentials:"include",headers:{Authorization:`Bearer ${te().token||""}`}});if(!a.ok)throw new Error(`Error al descargar imagen: ${a.status}`);const i=await a.blob(),o=l?.result?.filename||l?.data?.images?.filename||l?.data?.filename||`stock-${t.id}.jpg`,s=new File([i],o,{type:i.type||"image/jpeg"});P(s)}}catch(n){E(n.message||"No se pudo recuperar la imagen seleccionada")}finally{_(null)}};return o.loading?F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-center lb:py-8",children:[F.jsx("span",{className:"limbo-loader lb:mr-2"})," Cargando servicios de Stock..."]}):o.services.length?F.jsx("div",{className:"lb:flex lb:flex-col lb:mx-4 lb:pb-2",children:T?F.jsxs(F.Fragment,{children:[F.jsx("h3",{className:"lb:text-2xl lb:font-semibold lb:text-brand-blue-1000 lb:mb-3",children:"Selecciona el servicio de Stock"}),o.error&&F.jsx(Fe,{variant:"danger",children:o.error}),F.jsx("div",{className:"lb:grid lb:grid-cols-2 lb:md:grid-cols-3 lb:gap-3",children:o.services.map(e=>F.jsxs("button",{type:"button",onClick:()=>{u(e.slug),z(!1),b({}),h([]),f(1),x(null),E(null),C.fetchParams(e.slug,!0)},disabled:o.loading||t,className:`lb:group lb:relative lb:p-4 lb:rounded-lg lb:border-2 lb:transition-all lb:duration-200 lb:overflow-hidden lb:flex lb:flex-col lb:items-center lb:justify-center lb:min-h-30 lb:border-gray-200 lb:hover:border-brand-blue-300 lb:hover:shadow-md lb:lg:w-min ${o.loading||t?"lb:opacity-50 lb:cursor-not-allowed":"lb:cursor-pointer"} `,style:{position:"relative"},children:[e.image&&F.jsx("div",{className:"lb:absolute lb:inset-0 lb:bg-cover lb:bg-center lb:transition-opacity lb:duration-200 lb:group-hover:opacity-35",style:{backgroundImage:`url(${e.image})`,opacity:.2}}),F.jsxs("div",{className:"lb:relative lb:z-10 lb:flex lb:flex-col lb:items-center lb:justify-center lb:gap-2 lb:text-center",children:[F.jsx("span",{className:"lb:text-base lb:font-semibold lb:text-neutral-black-000",children:e.label}),e.description&&F.jsx("span",{className:"lb:text-sm lb:text-gray-950 lb:line-clamp-2 lb:drop-shadow lb:drop-shadow-neutral-white-000",children:e.description})]})]},e.slug))})]}):F.jsxs(F.Fragment,{children:[F.jsx("h3",{className:"lb:text-2xl lb:font-semibold lb:text-brand-blue-1000",children:o.services.find(e=>e.slug===c)?.label||"Búsqueda Stock"}),C.loading&&F.jsx("div",{children:"Cargando parámetros..."}),C.error&&F.jsx(Fe,{variant:"danger",children:C.error}),c&&(()=>{const e=C.params?.[c]?.parameters;if(!e)return null;const n=Object.entries(e).filter(([,e])=>!e.hidden),l=n.filter(([e])=>e.toLowerCase().includes("query")||e.toLowerCase().includes("search")||e.toLowerCase().includes("term")),r=n.filter(([e])=>!e.toLowerCase().includes("query")&&!e.toLowerCase().includes("search")&&!e.toLowerCase().includes("term")),a=(e,n)=>{let l=n.placeholder||"";l||(l="integer"===n.type?n.minValue&&n.maxValue?`Entre ${n.minValue} y ${n.maxValue}`:n.minValue?`Mínimo ${n.minValue}`:n.maxValue?`Máximo ${n.maxValue}`:"Introduce un número":e.toLowerCase().includes("query")||e.toLowerCase().includes("search")||e.toLowerCase().includes("term")?"Buscar imágenes...":`Introduce ${(n.label||e).toLowerCase()}`);const r=e.toLowerCase().includes("query")||e.toLowerCase().includes("search")||e.toLowerCase().includes("term");return F.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-1",children:[F.jsxs("label",{htmlFor:`stock-${e}`,className:"lb:text-xs lb:font-medium lb:text-brand-blue-1000",children:[n.label||e,n.required&&F.jsx("span",{className:"lb:text-red-1000 lb:ml-1",children:"*"})]}),n.options&&n.multiple?F.jsx("div",{className:"lb:flex lb:flex-wrap lb:gap-2 lb:min-h-[50px] lb:px-2 lb:justify-between lb:border-2 lb:border-gray-transparent-500 lb:rounded-lg",children:n.options.map(n=>F.jsxs("label",{className:"lb:flex lb:items-center lb:gap-1",children:[F.jsx("input",{type:"checkbox",name:`stock-${e}`,value:n,checked:Array.isArray(d[e])&&d[e].includes(n),onChange:()=>((e,t)=>{b(n=>{const l=Array.isArray(n[e])?n[e]:[];return l.includes(t)?{...n,[e]:l.filter(e=>e!==t)}:{...n,[e]:[...l,t]}})})(e,n),disabled:t}),F.jsx("span",{className:"lb:text-xs",children:n})]},n))}):n.options?F.jsx("select",{id:`stock-${e}`,name:e,value:d[e]??"",onChange:I,className:"limbo-input",disabled:t,title:n.label||e,children:n.options.map(e=>F.jsx("option",{value:e,children:e},e))}):r?F.jsx("textarea",{id:`stock-${e}`,name:e,value:d[e]??"",onChange:I,className:"limbo-input lb:resize-none lb:overflow-y-auto",disabled:t,required:n.required,placeholder:l,title:n.label||e,rows:3,style:{maxHeight:"9rem",minHeight:"3rem"},onInput:e=>{e.target.style.height="auto";const t=Math.min(e.target.scrollHeight,144);e.target.style.height=`${t}px`}}):F.jsx("input",{id:`stock-${e}`,type:"integer"===n.type?"number":"text",name:e,value:d[e]??"",onChange:I,className:"limbo-input",disabled:t,required:n.required,min:n.minValue,max:n.maxValue,placeholder:l,title:n.label||e})]},e)};return F.jsxs("div",{children:[o.services.length>1&&F.jsxs("button",{type:"button",onClick:()=>{z(!0),u(""),b({}),h([]),f(1),x(null),E(null)},className:"lb:flex lb:cursor-pointer lb:items-center lb:gap-2 lb:text-brand-blue-800 lb:hover:text-brand-blue-1000 lb:mb-4 lb:font-medium",children:[F.jsx("span",{className:"icon icon-arrow-left"}),"Volver al menú de servicios"]}),F.jsxs("div",{className:"lb:relative",children:[F.jsxs("form",{onSubmit:R,"data-type":"stock",className:"lb:flex lb:flex-col lb:gap-3 lb:mt-4 lb:border-t-1 lb:pt-4 lb:border-brand-blue-200","aria-label":"Formulario búsqueda de imágenes de Stock",children:[N&&F.jsx(Fe,{variant:"danger",className:"lb:mt-4",children:N}),F.jsx("div",{className:"lb:flex lb:flex-col lb:gap-3",children:l.map(([e,t])=>a(e,t))}),r.length>0&&F.jsxs("div",{className:"lb:border-t lb:border-gray-200 lb:pt-3",children:[F.jsxs("button",{type:"button",onClick:()=>A(!L),className:"lb:flex lb:items-center lb:gap-2 lb:text-sm lb:font-medium lb:text-brand-blue-800 lb:hover:text-brand-blue-1000 lb:mb-3 lb:transition-colors",children:[F.jsx("svg",{className:"lb:w-4 lb:h-4 lb:transition-transform "+(L?"lb:rotate-90":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),"Opciones avanzadas",!L&&F.jsxs("span",{className:"lb:text-xs lb:text-gray-500",children:["(",r.length," opciones)"]})]}),L&&F.jsx("div",{className:"lb:grid lb:grid-cols-1 lb:md:grid-cols-2 lb:gap-3 lb:animate-fadeIn",children:r.map(([e,t])=>a(e,t))})]}),F.jsx("button",{type:"submit",disabled:S||t,className:"limbo-btn lb:w-full lb:mt-2 "+(S?"lb:cursor-not-allowed limbo-btn-disabled":"limbo-btn-primary"),style:{minHeight:44},children:S?"Buscando...":"Buscar imágenes"})]}),F.jsx(tt,{show:S&&!m.length,message:"Buscando imágenes..."})]})]})})(),M&&F.jsx("div",{className:"lb:mt-6 lb:md:w-full lb:mx-auto",children:F.jsx(nt,{image:M,onDiscard:()=>{P(null),E(null)},onDownload:()=>{},onSelect:e=>{if(n)if(e&&M&&e!==M.name){const t=new File([M],e,{type:M.type});n(t)}else n(M)},showRetry:!1,disabled:t,selectedFolder:l,onFolderChange:r,folderConfig:a})}),!M&&m.length>0&&F.jsxs(F.Fragment,{children:[F.jsxs("div",{className:"lb:mt-6 lb:grid lb:grid-cols-2 lb:md:grid-cols-3 lb:lg:grid-cols-4 lb:gap-1 lb:relative","aria-live":"polite",children:[F.jsx(tt,{show:S,message:"Cargando imágenes..."}),m.map((e,n)=>F.jsx("div",{className:"lb:group lb:border lb:border-brand-blue-200 lb:rounded-sm lb:overflow-hidden lb:bg-white lb:shadow-sm lb:hover:shadow-md lb:transition-all lb:duration-200 lb:cursor-pointer",title:"Seleccionar imagen",onClick:()=>!$&&!S&&!t&&B(e),children:F.jsxs("div",{className:"lb:relative lb:aspect-video lb:bg-neutral-100",children:[F.jsx("img",{src:e.preview||e.thumbnail||e.url,alt:e.title||`Resultado ${n+1}`,className:"lb:object-cover lb:w-full lb:h-full",loading:"lazy"}),$===e.id?F.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-white/90 lb:flex lb:flex-col lb:items-center lb:justify-center lb:gap-2",children:[F.jsxs("div",{className:"lb:relative lb:w-10 lb:h-10",children:[F.jsx("div",{className:"lb:absolute lb:inset-0 lb:border-4 lb:border-brand-blue-200 lb:rounded-full"}),F.jsx("div",{className:"lb:absolute lb:inset-0 lb:border-4 lb:border-brand-blue-800 lb:rounded-full lb:border-t-transparent lb:animate-spin"})]}),F.jsx("span",{className:"lb:text-sm lb:font-medium lb:text-brand-blue-1000",children:"Descargando..."})]}):F.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-brand-blue-800/0 lb:group-hover:bg-brand-blue-800/50 lb:transition-colors lb:duration-200 lb:flex lb:items-center lb:justify-center lb:flex-col",children:[F.jsx("span",{className:"icon icon-round-check-filled-blue icon--2xl lb:max-w-full lb:max-h-full lb:opacity-0 lb:group-hover:opacity-100 lb:transition-opacity lb:duration-200"}),F.jsx("span",{style:{textShadow:"1px 0 #001978, -1px 0 #001978, 0 1px #001978, 0 -0.5px #001978, 0.5px 0.5px #001978, -1px -1px #001978, 1px -1px #001978, -1px 1px #001978"},className:"lb:max-w-full lb:max-h-full lb:opacity-0 lb:group-hover:opacity-100 lb:transition-opacity lb:duration-200 lb:text-neutral-white-000",children:"Seleccionar"})]})]})},e.id||n))]}),g&&F.jsxs("div",{className:"lb:mt-6 lb:flex lb:items-center lb:justify-center lb:gap-2",children:[F.jsxs("button",{onClick:()=>U(g.current_page-1),disabled:g.current_page<=1||S,className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(g.current_page<=1||S?" pointer-events-none cursor-default":" limbo-btn-primary"),children:[F.jsx("span",{className:"icon icon-arrow-left-white icon--sm"})," ","Anterior"]}),F.jsxs("span",{className:"lb:px-4 lb:py-2 lb:text-sm lb:text-neutral-700",children:["Página ",g.current_page," de"," ",Math.max(1,Math.ceil(g.total/g.per_page)),F.jsxs("span",{className:"lb:text-xs lb:text-neutral-500 lb:block",children:["(",g.total," imágenes totales)"]})]}),F.jsxs("button",{onClick:()=>U(g.current_page+1),disabled:S||g.current_page>=Math.ceil(g.total/g.per_page),className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(S||g.current_page>=Math.ceil(g.total/g.per_page)?" pointer-events-none cursor-default":" limbo-btn-primary"),children:["Siguiente"," ",F.jsx("span",{className:"icon icon-arrow-right-white icon--sm"})]})]})]}),!S&&0===m.length&&c&&w&&F.jsxs("div",{className:"lb:mt-6 lb:text-center lb:text-neutral-600 lb:py-8 lb:bg-neutral-50 lb:rounded-lg",children:[F.jsx("span",{className:"icon icon-search icon--lg lb:mb-2"}),F.jsxs("p",{children:['No se encontraron imágenes para "',d.query,'"']}),F.jsx("p",{className:"lb:text-sm lb:mt-1",children:"Intenta con otros términos de búsqueda"})]})]})}):F.jsx(Fe,{variant:"warning",children:"No hay servicios de Stock disponibles."})}const st="/api";const ct=new Map;function ut(e=!1){const[t,n]=y.useState([]),[l,r]=y.useState(!0),[a,i]=y.useState(null);y.useEffect(()=>{const t=`portal-sources-${e}`,l=ct.get(t),a=Date.now();if(l&&a-l.timestamp<864e5)return n(l.data),void r(!1);let o=!0;return(async()=>{try{const l=await function(e=!1,t=!0){const n=new URLSearchParams;return n.set("active",t?"true":"false"),ne({endpoint:`/external/portals?${n.toString()}`,method:"GET",prod:e,basePath:st})}(e,!0);if(!o)return;let r=l?.data||[];Array.isArray(r)||(r=[]);const i=r.map(e=>({id:e.slug||e.id,numericId:e.id,name:e.name,title:e.name,slug:e.slug,url:e.website_url,image:e.logo_url,isActive:e.is_active}));n(i),ct.set(t,{data:i,timestamp:a})}catch(l){o&&i(l.message)}finally{o&&r(!1)}})(),()=>{o=!1}},[e]);return{sources:t,loading:l,error:a,invalidateCache:()=>{ct.delete(`portal-sources-${e}`)}}}function dt({isOpen:e=!1,video:t,onClose:n,onSelect:l=null}){const[r,a]=y.useState(!1),i=y.useMemo(()=>t?"youtube"===t.platform&&t.video_id?`https://www.youtube.com/embed/${t.video_id}?autoplay=1&rel=0`:"vimeo"===t.platform&&t.video_id?`https://player.vimeo.com/video/${t.video_id}?autoplay=1`:t.embed_url||null:null,[t]),o=y.useMemo(()=>t&&(t.player_url||t.embed_url||t.post_url)||"",[t]),s=y.useCallback(async()=>{if(o)try{await navigator.clipboard.writeText(o),a(!0),setTimeout(()=>a(!1),2e3)}catch{const e=document.createElement("textarea");e.value=o,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e),a(!0),setTimeout(()=>a(!1),2e3)}},[o]),c=y.useCallback(()=>{l&&t&&l(t)},[l,t]);if(!t)return null;const u=[t.portal_name,t.platform].filter(Boolean).join(" · "),d=l?F.jsxs("button",{type:"button",onClick:c,className:"lb:flex lb:items-center lb:gap-2 lb:px-4 lb:py-1.5 lb:rounded-lg lb:bg-brand-blue-800 lb:hover:bg-brand-blue-900 lb:text-white lb:text-sm lb:font-medium lb:transition-colors","aria-label":"Seleccionar video",children:[F.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),F.jsx("span",{children:"Seleccionar"})]}):F.jsx("button",{type:"button",onClick:s,disabled:!o,className:"lb:flex lb:items-center lb:gap-2 lb:px-4 lb:py-1.5 lb:rounded-lg lb:text-sm lb:font-medium lb:transition-colors "+(r?"lb:bg-green-600 lb:text-white":"lb:bg-white/10 lb:hover:bg-white/20 lb:text-white"),"aria-label":"Copiar URL del video",children:r?F.jsxs(F.Fragment,{children:[F.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),F.jsx("span",{children:"Copiado"})]}):F.jsxs(F.Fragment,{children:[F.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"})}),F.jsx("span",{children:"Copiar URL"})]})}),b=F.jsxs("span",{children:[F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]});return F.jsx(pe,{isOpen:e,onClose:n,title:t.title||"Video",subtitle:u,ariaLabel:"Vista previa de video externo",headerActions:d,footerHints:b,children:F.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-3 lb:w-full lb:max-w-5xl lb:px-4",children:[F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2 lb:px-4 lb:py-2 lb:bg-amber-500/20 lb:border lb:border-amber-500/40 lb:rounded-lg lb:text-amber-200 lb:text-sm",children:[F.jsx("svg",{className:"lb:w-5 lb:h-5 lb:shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),F.jsxs("span",{children:["Este video no se puede guardar en Limbo — alojado en"," ",F.jsx("strong",{className:"lb:capitalize",children:t.platform||"plataforma externa"})]})]}),F.jsx("div",{className:"lb:relative lb:w-full lb:aspect-video lb:bg-black lb:rounded-lg lb:overflow-hidden",children:i?F.jsx("iframe",{src:i,className:"lb:absolute lb:inset-0 lb:w-full lb:h-full",allow:"autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0,title:t.title||"Video"}):F.jsxs("div",{className:"lb:absolute lb:inset-0 lb:flex lb:flex-col lb:items-center lb:justify-center lb:text-white lb:gap-3",children:[F.jsx("svg",{className:"lb:w-16 lb:h-16 lb:text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"})}),F.jsx("p",{className:"lb:text-sm lb:text-gray-400",children:"No se puede previsualizar este video"}),o&&F.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"lb:text-sm lb:text-brand-blue-400 lb:hover:text-brand-blue-300 lb:underline",children:"Abrir en nueva pestaña"})]})}),o&&F.jsx("p",{className:"lb:text-xs lb:text-gray-500 lb:truncate lb:max-w-full lb:px-2",children:o})]})})}const bt=({src:e,fallbackSrc:t,alt:n,className:l,onError:r})=>{const[a,i]=v.useState("loading"),[o,s]=v.useState(e),[c,u]=v.useState(!1);return"error"===a?null:F.jsxs("div",{className:"lb:relative lb:w-full lb:h-full",children:["loading"===a&&F.jsx("div",{className:"lb:absolute lb:inset-0 lb:bg-linear-to-r lb:from-gray-200 lb:via-gray-100 lb:to-gray-200 lb:animate-pulse lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-spinner lb:w-8 lb:h-8 lb:text-gray-400 lb:animate-spin"})}),F.jsx("img",{src:o,alt:n,className:`${l} ${"loading"===a?"lb:opacity-0":"lb:opacity-100"} lb:transition-opacity lb:duration-300`,loading:"lazy",onLoad:()=>{i("loaded")},onError:()=>{t&&!c?(u(!0),s(t),i("loading")):(i("error"),r&&r())}})]})};function mt({prod:e,disabled:t,onSelect:n,onVideoSelect:l,selectedFolder:r,onFolderChange:a,folderConfig:i,resolvedAccept:o=null,returnConfig:s=null}){const{sources:c,loading:u,error:d}=ut(e),b=y.useMemo(()=>{if(!o||o.isAllTypes)return[{value:"images",label:"Imágenes"},{value:"videos",label:"Vídeos"},{value:"all",label:"Todo"}];const e=[];return o.includesImages&&e.push({value:"images",label:"Imágenes"}),o.includesVideos&&e.push({value:"videos",label:"Vídeos"}),e.length>1&&e.push({value:"all",label:"Todo"}),e.length>0?e:[{value:"images",label:"Imágenes"}]},[o]),m=b[0]?.value||"images",[h,p]=y.useState(null),[f,g]=y.useState(m),[v,x]=y.useState(""),[w,k]=y.useState([]),[C,S]=y.useState(1),[j,N]=y.useState(null),[E,$]=y.useState(!1),[_,T]=y.useState(null),[z,L]=y.useState(null),[A,M]=y.useState(null),[P,I]=y.useState(new Set),[D,O]=y.useState(!1),[R,U]=y.useState(null),B=!!s&&"url"===s.format,W=y.useRef({}),q=y.useCallback((e,t,n,l)=>`${e}_${t}_${n}_${l}`,[]),V=y.useCallback(async(t,n,l,r)=>{const a=q(t,n,l,r),i=W.current[a];if(i)return k(i.items),N(i.pagination),S(r),T(null),void O(!0);$(!0),T(null);try{const i={portal:t,media_type:n,page:r,per_page:20};l.trim()&&(i.search=l.trim());const o=await function(e,t=!1){const n=new URLSearchParams;return e.portal&&n.set("portal",e.portal),e.media_type&&n.set("media_type",e.media_type),e.page&&n.set("page",String(e.page)),n.set("per_page",String(e.per_page)),e.search&&n.set("search",e.search),e.order&&n.set("order",e.order),ne({endpoint:`/external/media?${n.toString()}`,method:"GET",prod:t,basePath:st})}(i,e),s=o?.data||{},c=s.items||[],u=s.pagination||{total_items:c.length,total_pages:1,current_page:r,per_page:20};W.current[a]={items:c,pagination:u},k(c),N(u),S(r),I(new Set),O(!0),0===c.length&&T("No se encontraron resultados para este portal.")}catch(o){T(o.message||"Error al cargar media del portal"),k([]),N(null),O(!0)}finally{$(!1)}},[e,q]),H=y.useCallback(e=>{e!==h&&(p(e),x(""),g(m),k([]),N(null),T(null),L(null),U(null),I(new Set),O(!1),W.current={})},[h,m]),K=y.useCallback(()=>{p(null),k([]),N(null),T(null),x(""),L(null),U(null),I(new Set),O(!1),W.current={}},[]),G=y.useCallback(()=>{h&&(W.current={},V(h,f,v,1))},[h,f,v,V]),Q=y.useCallback(e=>{"Enter"===e.key&&(e.preventDefault(),G())},[G]),X=y.useCallback(e=>{e<1||!h||V(h,f,v,e)},[h,f,v,V]),Y=y.useCallback(e=>{U(null),l?l(e):n&&n(e)},[l,n]),J=y.useCallback(async t=>{if("video"===t.type){const e={type:"video",source:"portal",title:t.title||"",thumbnail:t.thumbnail||t.url,embed_url:t.embed_url||null,player_url:t.player_url||null,post_url:t.post_url||null,platform:t.platform||null,video_id:t.video_id||null,portal_slug:t.portal_slug||h,portal_name:t.portal_name||c.find(e=>e.slug===h)?.name||null,date_published:t.date_published||null,author:t.author||null};return void U(e)}const n=t.url||t.thumbnail;if(n){M(n),T(null);try{let l=null;try{const e=await fetch(n,{mode:"cors"});e.ok&&(l=await e.blob())}catch{}if(!l){const t=`${ee({prod:e})}/api/external/proxy?url=${encodeURIComponent(n)}`,r=await fetch(t);if(!r.ok)throw new Error(`Error al descargar: ${r.status}`);l=await r.blob()}const r=t.title?`${t.title.substring(0,80)}.${"image/png"===t.mime_type?"png":"jpg"}`:`portal-${Date.now()}.jpg`,a=new File([l],r,{type:l.type||t.mime_type||"image/jpeg"});L(a)}catch(l){T(l.message||"No se pudo recuperar la imagen del portal")}finally{M(null)}}else T("No se encontró URL de la imagen")},[e,h,c]);if(u)return F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-center lb:py-8",children:[F.jsx("span",{className:"limbo-loader lb:mr-2"})," Cargando portales disponibles..."]});if(!c.length)return F.jsx(Fe,{variant:"warning",children:"No hay portales externos disponibles."});if(!h)return F.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-4",children:[F.jsx("h3",{className:"lb:text-lg lb:font-semibold lb:text-brand-blue-1000",children:"Selecciona un Portal"}),d&&F.jsx(Fe,{variant:"danger",children:d}),F.jsx("div",{className:"lb:grid lb:grid-cols-2 lb:md:grid-cols-3 lb:gap-3",children:c.map(e=>F.jsx("button",{type:"button",onClick:()=>H(e.slug),disabled:t,className:"lb:relative lb:p-4 lb:rounded-lg lb:border-2 lb:transition-all lb:duration-200 lb:flex lb:flex-col lb:items-center lb:justify-center lb:min-h-25 lb:gap-2 lb:max-h-27.5 lb:box-border lb:border-gray-200 lb:bg-white lb:hover:border-brand-blue-350 lb:hover:shadow-md "+(t?"lb:opacity-50 lb:cursor-not-allowed":"lb:cursor-pointer"),children:e.image?F.jsx("img",{className:"lb:object-auto lb:bg-no-repeat lb:bg-center lb:max-h-full",src:e.image,alt:e.title}):F.jsx("span",{className:"lb:text-sm lb:font-medium lb:text-brand-blue-800",children:e.name})},e.slug))})]});const Z=c.find(e=>e.slug===h),te=ee({prod:e});return F.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-3",children:[F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-3",children:[F.jsxs("button",{type:"button",onClick:K,className:"lb:flex lb:items-center lb:gap-1 lb:text-sm lb:text-brand-blue-800 lb:hover:text-brand-blue-1000 lb:font-medium lb:transition-colors",children:[F.jsx("span",{className:"icon icon-arrow-left icon--sm"}),"Portales"]}),F.jsx("span",{className:"lb:text-gray-300",children:"|"}),F.jsx("h3",{className:"lb:text-lg lb:font-semibold lb:text-brand-blue-1000",children:Z?.name||h})]}),F.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-3 lb:border-t lb:pt-3 lb:border-brand-blue-200",children:[b.length>1&&F.jsx("div",{className:"lb:flex lb:gap-2",children:b.map(({value:e,label:n})=>F.jsx("button",{type:"button",onClick:()=>g(e),disabled:t||E,className:"lb:px-3 lb:py-1.5 lb:text-sm lb:rounded-md lb:font-medium lb:transition-colors "+(f===e?"lb:bg-brand-blue-800 lb:text-white":"lb:bg-gray-100 lb:text-gray-700 lb:hover:bg-gray-200"),children:n},e))}),F.jsxs("div",{className:"lb:flex lb:gap-2",children:[F.jsx("input",{type:"text",value:v,onChange:e=>x(e.target.value),onKeyDown:Q,className:"limbo-input lb:flex-1",placeholder:"Buscar en el portal...",disabled:t||E}),F.jsxs("button",{type:"button",onClick:G,disabled:t||E,className:"limbo-btn limbo-btn-primary lb:px-4 lb:py-2 lb:text-sm lb:font-medium lb:whitespace-nowrap lb:flex lb:items-center lb:gap-1.5",children:[E?F.jsx("span",{className:"limbo-loader limbo-loader--sm"}):F.jsx("span",{className:"icon icon-search-white icon--sm"}),"Buscar"]})]})]}),_&&!E&&F.jsx(Fe,{variant:"warning",children:_}),z&&F.jsx("div",{className:"lb:mt-2 lb:md:w-full lb:mx-auto",children:F.jsx(nt,{image:z,onDiscard:()=>{L(null),T(null)},onDownload:()=>{},onSelect:e=>{if(n)if(e&&z&&e!==z.name){const t=new File([z],e,{type:z.type});n(t)}else n(z)},showRetry:!1,disabled:t,selectedFolder:r,onFolderChange:a,folderConfig:i})}),!z&&F.jsxs(F.Fragment,{children:[F.jsxs("div",{className:"lb:relative lb:min-h-50","aria-live":"polite",children:[E&&F.jsx("div",{className:"lb:absolute lb:inset-0 lb:bg-white/80 lb:z-10 lb:flex lb:items-center lb:justify-center lb:rounded-lg",children:F.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-2",children:[F.jsx("span",{className:"limbo-loader"}),F.jsx("span",{className:"lb:text-sm lb:text-brand-blue-800",children:"Cargando media..."})]})}),w.length>0&&F.jsxs("div",{className:"lb:relative lb:grid lb:grid-cols-2 lb:md:grid-cols-3 lb:lg:grid-cols-4 lb:gap-2",children:[F.jsx(tt,{show:E,message:"Cargando media..."}),w.map((e,n)=>{const l=`${e.portal_slug}-${e.id||n}`,r=e.thumbnail||e.url;if(P.has(l)||!r)return null;const a=`${te}/api/external/proxy?url=${encodeURIComponent(r)}`;return F.jsxs("div",{className:"lb:group lb:border lb:border-brand-blue-200 lb:rounded-lg lb:overflow-hidden lb:bg-white lb:shadow-sm lb:hover:shadow-md lb:transition-all lb:duration-200 lb:cursor-pointer",onClick:()=>!A&&!E&&!t&&J(e),children:[F.jsxs("div",{className:"lb:relative lb:aspect-video lb:bg-neutral-100",children:[F.jsx(bt,{src:r,fallbackSrc:a,alt:e.alt||e.title||`Media ${n+1}`,className:"lb:object-cover lb:w-full lb:h-full",onError:()=>{I(e=>{const t=new Set(e);return t.add(l),t})}}),"video"===e.type&&F.jsx("span",{className:"lb:absolute lb:top-1 lb:left-1 lb:bg-black/60 lb:text-white lb:text-xs lb:px-2 lb:py-1 lb:rounded",children:"Video"}),A===(e.url||e.thumbnail)?F.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-white/90 lb:flex lb:flex-col lb:items-center lb:justify-center lb:gap-2",children:[F.jsxs("div",{className:"lb:relative lb:w-10 lb:h-10",children:[F.jsx("div",{className:"lb:absolute lb:inset-0 lb:border-4 lb:border-brand-blue-200 lb:rounded-full"}),F.jsx("div",{className:"lb:absolute lb:inset-0 lb:border-4 lb:border-brand-blue-800 lb:rounded-full lb:border-t-transparent lb:animate-spin"})]}),F.jsx("span",{className:"lb:text-sm lb:font-medium lb:text-brand-blue-1000",children:"Descargando..."})]}):"video"===e.type?F.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-black/0 lb:group-hover:bg-black/60 lb:transition-colors lb:duration-200 lb:flex lb:items-center lb:justify-center lb:flex-col lb:gap-1",children:[F.jsx("svg",{className:"lb:w-10 lb:h-10 lb:opacity-0 lb:group-hover:opacity-100 lb:transition-opacity lb:duration-200 lb:text-white",viewBox:"0 0 24 24",fill:"currentColor",children:F.jsx("path",{d:"M8 5v14l11-7z"})}),F.jsx("span",{className:"lb:text-sm lb:font-medium lb:text-white lb:opacity-0 lb:group-hover:opacity-100 lb:transition-opacity lb:duration-200",children:"Seleccionar vídeo"})]}):F.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-brand-blue-800/0 lb:group-hover:bg-brand-blue-800/50 lb:transition-colors lb:duration-200 lb:flex lb:items-center lb:justify-center lb:flex-col",children:[F.jsx("span",{className:"icon icon-round-check-filled-blue icon--2xl lb:max-w-full lb:max-h-full lb:opacity-0 lb:group-hover:opacity-100 lb:transition-opacity lb:duration-200"}),F.jsx("span",{style:{textShadow:"1px 0 #001978, -1px 0 #001978, 0 1px #001978, 0 -0.5px #001978, 0.5px 0.5px #001978, -1px -1px #001978, 1px -1px #001978, -1px 1px #001978"},className:"lb:max-w-full lb:max-h-full lb:opacity-0 lb:group-hover:opacity-100 lb:transition-opacity lb:duration-200 lb:text-neutral-white-000",children:"Seleccionar"})]})]}),e.title&&F.jsx("div",{className:"lb:px-2 lb:pb-2 lb:pt-1",children:F.jsx("p",{className:"lb:text-xs lb:text-gray-600 lb:truncate",title:e.title,children:e.title})})]},l)})]}),!D&&!E&&0===w.length&&!_&&F.jsxs("div",{className:"lb:text-center lb:text-neutral-600 lb:py-10 lb:bg-neutral-50 lb:rounded-lg",children:[F.jsx("p",{className:"lb:font-medium lb:text-brand-blue-800",children:"Selecciona los filtros y pulsa Buscar"}),F.jsx("p",{className:"lb:text-sm lb:mt-1 lb:text-neutral-500",children:"Elige el tipo de contenido y escribe un término de búsqueda"})]}),D&&!E&&0===w.length&&!_&&F.jsxs("div",{className:"lb:text-center lb:text-neutral-600 lb:py-8 lb:bg-neutral-50 lb:rounded-lg",children:[F.jsx("span",{className:"icon icon-search icon--lg lb:mb-2"}),F.jsx("p",{children:"No se encontraron resultados"}),v&&F.jsx("p",{className:"lb:text-sm lb:mt-1",children:"Intenta con otros términos de búsqueda"})]})]}),j&&j.total_pages>1&&F.jsxs("div",{className:"lb:mt-4 lb:flex lb:items-center lb:justify-center lb:gap-2",children:[F.jsxs("button",{onClick:()=>X(C-1),disabled:1===C||E,className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(1===C||E?" pointer-events-none cursor-default":" limbo-btn-primary"),children:[F.jsx("span",{className:"icon icon-arrow-left-white icon--sm"})," ","Anterior"]}),F.jsxs("span",{className:"lb:px-4 lb:py-2 lb:text-sm lb:text-neutral-700",children:["Página ",C," de ",j.total_pages,F.jsxs("span",{className:"lb:text-xs lb:text-neutral-500 lb:block",children:["(",j.total_items," resultados)"]})]}),F.jsxs("button",{onClick:()=>X(C+1),disabled:E||C>=j.total_pages,className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(E||C>=j.total_pages?" pointer-events-none cursor-default":" limbo-btn-primary"),children:["Siguiente"," ",F.jsx("span",{className:"icon icon-arrow-right-white icon--sm"})]})]})]}),F.jsx(dt,{isOpen:!!R,video:R,onClose:()=>U(null),onSelect:B?Y:null})]})}const ht=[{id:"upload",label:"Subir archivo"},{id:"ai",label:"Generar"},{id:"stock",label:"Buscar en Stock"},{id:"portals",label:"Otros portales"}];function pt({onSelect:e,onVideoSelect:t,disabled:n=!1,apiKey:l,prod:r=!1,allowedCategories:a=null,resolvedAccept:i=null,returnConfig:o=null,folderConfig:s=null,selectedFolder:c=null,onFolderChange:u=null}){const{isMobile:d,isTouch:b}=B(),m=y.useMemo(()=>!i||i.isAllTypes||i.includesImages?ht:i.includesVideos?ht.filter(e=>"upload"===e.id||"portals"===e.id):ht.filter(e=>"upload"===e.id),[i]),[h,p]=y.useState("upload"),[f,g]=y.useState(null),[v,x]=y.useState(null),w=y.useRef(),k=["limbo-tabs","lb:flex","lb:gap-4","lb:border-b-2","lb:border-brand-blue-200","lb:mb-4",d&&"lb:overflow-x-auto lb:scrollbar-none"].filter(Boolean).join(" "),C=e=>{const t=["limbo-tab","lb:relative","lb:px-4","lb:py-2","lb:font-medium","lb:text-brand-blue-1000","lb:bg-transparent","lb:border-0","lb:border-b-2","lb:cursor-pointer","lb:transition-all","lb:duration-200","lb:hover:text-pink-1000","lb:focus:outline-none","lb:focus-visible:ring-2","lb:focus-visible:ring-brand-blue-400","lb:focus-visible:ring-offset-2","lb:text-nowrap"];return e?t.push("lb:border-b-brand-blue-1000","lb:font-semibold","limbo-active"):t.push("lb:border-b-transparent"),d&&t.push("lb:min-w-[100px]","lb:min-h-[44px]","lb:text-sm","lb:shrink-0"),b&&t.push("lb:touch-manipulation"),t.join(" ")};return F.jsxs("div",{className:"limbo-upload-form lb:py-4 lb:min-w-fit lb:max-w-7xl lb:mx-auto",children:[m.length>1&&F.jsx("div",{className:k,role:"tablist","aria-label":"Opciones de subida",style:d?{WebkitOverflowScrolling:"touch",scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,children:m.map(e=>{const t=h===e.id;return F.jsxs("button",{type:"button","data-upload-tab-id":e.id,className:C(t),"aria-current":t?"page":void 0,"aria-selected":t,role:"tab",tabIndex:t?0:-1,onClick:()=>p(e.id),onKeyDown:t=>((e,t)=>{const n=m.findIndex(e=>e.id===t);let l=n;switch(e.key){case"ArrowLeft":e.preventDefault(),l=n>0?n-1:m.length-1;break;case"ArrowRight":e.preventDefault(),l=n<m.length-1?n+1:0;break;case"Home":e.preventDefault(),l=0;break;case"End":e.preventDefault(),l=m.length-1;break;case"Enter":case" ":return e.preventDefault(),void p(t);default:return}const r=m[l];r&&(p(r.id),setTimeout(()=>{const e=document.querySelector(`[data-upload-tab-id="${r.id}"]`);e&&e.focus()},0))})(t,e.id),id:`upload-tab-${e.id}`,"aria-controls":`upload-tabpanel-${e.id}`,style:b?{WebkitTapHighlightColor:"transparent"}:void 0,children:["ai"===e.id?F.jsx("span",{className:"icon icon-ia lb:me-1"}):null,e.label]},e.id)})}),F.jsxs("div",{className:"limbo-tab-content lb:px-2 lb:py-2",role:"tabpanel",id:`upload-tabpanel-${h}`,"aria-labelledby":`upload-tab-${h}`,children:["upload"===h&&F.jsx(Qe,{file:f,setFile:g,previewUrl:v,setPreviewUrl:x,fileInputRef:w,onSelect:e,disabled:n,allowedCategories:a,resolvedAccept:i,selectedFolder:c,onFolderChange:u,folderConfig:s}),"ai"===h&&F.jsx(lt,{apiKey:l,prod:r,disabled:n,onSelect:e,selectedFolder:c,onFolderChange:u,folderConfig:s}),"stock"===h&&F.jsx(ot,{apiKey:l,prod:r,disabled:n,onSelect:e,selectedFolder:c,onFolderChange:u,folderConfig:s}),"portals"===h&&F.jsx(mt,{apiKey:l,prod:r,disabled:n,onSelect:e,onVideoSelect:t,resolvedAccept:i,returnConfig:o,selectedFolder:c,onFolderChange:u,folderConfig:s})]})]})}const ft="undefined"!=typeof window&&void 0!==window.document,gt=ft?window:{},yt=!!ft&&"ontouchstart"in gt.document.documentElement,vt=!!ft&&"PointerEvent"in gt,xt="cropper",wt=`${xt}-canvas`,kt=`${xt}-crosshair`,Ct=`${xt}-grid`,St=`${xt}-handle`,jt=`${xt}-image`,Nt=`${xt}-selection`,Et=`${xt}-shade`,$t=`${xt}-viewer`,_t="select",Tt="move",zt="scale",Lt="rotate",At="transform",Mt="none",Pt="n-resize",It="e-resize",Dt="s-resize",Ot="w-resize",Rt="ne-resize",Ft="nw-resize",Ut="se-resize",Bt="sw-resize",Wt=vt?"pointerdown":yt?"touchstart":"mousedown",qt=vt?"pointermove":yt?"touchmove":"mousemove",Vt=vt?"pointerup pointercancel":yt?"touchend touchcancel":"mouseup",Ht="error",Kt="keydown",Gt="load",Qt="wheel",Xt="action",Yt="actionend",Jt="actionstart",Zt="change",en="transform";const tn=Number.isNaN||gt.isNaN;function nn(e){return"number"==typeof e&&!tn(e)}function ln(e){return nn(e)&&e>0&&e<1/0}function rn(e){return"object"==typeof e&&null!==e}const{hasOwnProperty:an}=Object.prototype;function on(e){if(!rn(e))return!1;try{const{constructor:t}=e,{prototype:n}=t;return t&&n&&an.call(n,"isPrototypeOf")}catch(t){return!1}}function sn(e){return"function"==typeof e}function cn(e){return"object"==typeof e&&null!==e&&1===e.nodeType}const un=/([a-z\d])([A-Z])/g;function dn(e){return String(e).replace(un,"$1-$2").toLowerCase()}const bn=/-[A-z\d]/g;function mn(e){return e.replace(bn,e=>e.slice(1).toUpperCase())}const hn=/\s\s*/;function pn(e,t,n,l){t.trim().split(hn).forEach(t=>{e.removeEventListener(t,n,l)})}function fn(e,t,n,l){t.trim().split(hn).forEach(t=>{e.addEventListener(t,n,l)})}function gn(e,t,n,l){fn(e,t,n,Object.assign(Object.assign({},l),{once:!0}))}const yn={bubbles:!0,cancelable:!0,composed:!0};const vn=Promise.resolve();function xn(e){const{documentElement:t}=e.ownerDocument,n=e.getBoundingClientRect();return{left:n.left+(gt.pageXOffset-t.clientLeft),top:n.top+(gt.pageYOffset-t.clientTop)}}const wn=/deg|g?rad|turn$/i;function kn(e){const t=parseFloat(e)||0;if(0!==t){const[n="rad"]=String(e).match(wn)||[];switch(n.toLowerCase()){case"deg":return t/360*(2*Math.PI);case"grad":return t/400*(2*Math.PI);case"turn":return t*(2*Math.PI)}}return t}const Cn="contain";function Sn(e,t=Cn){const{aspectRatio:n}=e;let{width:l,height:r}=e;const a=ln(l),i=ln(r);if(a&&i){const e=r*n;t===Cn&&e>l||"cover"===t&&e<l?r=l/n:l=r*n}else a?r=l/n:i&&(l=r*n);return{width:l,height:r}}function jn(e,...t){if(0===t.length)return e;const[n,l,r,a,i,o]=e,[s,c,u,d,b,m]=t[0];return jn(e=[n*s+r*c,l*s+a*c,n*u+r*d,l*u+a*d,n*b+r*m+i,l*b+a*m+o],...t.slice(1))}const Nn=/left|top|width|height/i,En="open",$n=new WeakMap,_n=new WeakMap,Tn=new Map,zn=gt.document&&Array.isArray(gt.document.adoptedStyleSheets)&&"replaceSync"in gt.CSSStyleSheet.prototype;class Ln extends HTMLElement{get $sharedStyle(){return(this.themeColor?`:host{--theme-color: ${this.themeColor};}`:"")+":host([hidden]){display:none!important}"}constructor(){var e,t;super(),this.shadowRootMode=En,this.slottable=!0;const n=null===(t=null===(e=Object.getPrototypeOf(this))||void 0===e?void 0:e.constructor)||void 0===t?void 0:t.$name;n&&Tn.set(n,this.tagName.toLowerCase())}static get observedAttributes(){return["shadow-root-mode","slottable","theme-color"]}attributeChangedCallback(e,t,n){if(Object.is(n,t))return;const l=mn(e);let r=n;switch(typeof this[l]){case"boolean":r=null!==n&&"false"!==n;break;case"number":r=Number(n)}switch(this[l]=r,e){case"theme-color":{const e=_n.get(this),t=this.$sharedStyle;e&&t&&(zn?e.replaceSync(t):e.textContent=t);break}}}$propertyChangedCallback(e,t,n){if(!Object.is(n,t))switch(e=dn(e),typeof n){case"boolean":!0===n?this.hasAttribute(e)||this.setAttribute(e,""):this.removeAttribute(e);break;case"number":n=tn(n)?"":String(n);default:n?this.getAttribute(e)!==n&&this.setAttribute(e,n):this.removeAttribute(e)}}connectedCallback(){Object.getPrototypeOf(this).constructor.observedAttributes.forEach(e=>{const t=mn(e);let n=this[t];(function(e){return void 0===e})(n)||this.$propertyChangedCallback(t,void 0,n),Object.defineProperty(this,t,{enumerable:!0,configurable:!0,get:()=>n,set(e){const l=n;n=e,this.$propertyChangedCallback(t,l,e)}})});const e=this.shadowRoot||this.attachShadow({mode:this.shadowRootMode||En});if($n.set(this,e),_n.set(this,this.$addStyles(this.$sharedStyle)),this.$style&&this.$addStyles(this.$style),this.$template){const t=document.createElement("template");t.innerHTML=this.$template,e.appendChild(t.content)}if(this.slottable){const t=document.createElement("slot");e.appendChild(t)}}disconnectedCallback(){_n.has(this)&&_n.delete(this),$n.has(this)&&$n.delete(this)}$getTagNameOf(e){var t;return null!==(t=Tn.get(e))&&void 0!==t?t:e}$setStyles(e){return Object.keys(e).forEach(t=>{let n=e[t];nn(n)&&(n=0!==n&&Nn.test(t)?`${n}px`:String(n)),this.style[t]=n}),this}$getShadowRoot(){return this.shadowRoot||$n.get(this)}$addStyles(e){let t;const n=this.$getShadowRoot();return zn?(t=new CSSStyleSheet,t.replaceSync(e),n.adoptedStyleSheets=n.adoptedStyleSheets.concat(t)):(t=document.createElement("style"),t.textContent=e,n.appendChild(t)),t}$emit(e,t,n){return function(e,t,n,l){return e.dispatchEvent(new CustomEvent(t,Object.assign(Object.assign(Object.assign({},yn),{detail:n}),l)))}(this,e,t,n)}$nextTick(e){return function(e,t){return t?vn.then(e?t.bind(e):t):vn}(this,e)}static $define(e,t){rn(e)&&(t=e,e=""),e||(e=this.$name||this.name),e=dn(e),ft&>.customElements&&!gt.customElements.get(e)&&customElements.define(e,this,t)}}Ln.$version="2.1.0";class An extends Ln{constructor(){super(...arguments),this.$onPointerDown=null,this.$onPointerMove=null,this.$onPointerUp=null,this.$onWheel=null,this.$wheeling=!1,this.$pointers=new Map,this.$style=':host{display:block;min-height:100px;min-width:200px;overflow:hidden;position:relative;touch-action:none;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}:host([background]){background-color:#fff;background-image:repeating-linear-gradient(45deg,#ccc 25%,transparent 0,transparent 75%,#ccc 0,#ccc),repeating-linear-gradient(45deg,#ccc 25%,transparent 0,transparent 75%,#ccc 0,#ccc);background-image:repeating-conic-gradient(#ccc 0 25%,#fff 0 50%);background-position:0 0,.5rem .5rem;background-size:1rem 1rem}:host([disabled]){pointer-events:none}:host([disabled]):after{bottom:0;content:"";cursor:not-allowed;display:block;left:0;pointer-events:none;position:absolute;right:0;top:0}',this.$action=Mt,this.background=!1,this.disabled=!1,this.scaleStep=.1,this.themeColor="#39f"}static get observedAttributes(){return super.observedAttributes.concat(["background","disabled","scale-step"])}connectedCallback(){super.connectedCallback(),this.disabled||this.$bind()}disconnectedCallback(){this.disabled||this.$unbind(),super.disconnectedCallback()}$propertyChangedCallback(e,t,n){if(!Object.is(n,t)&&(super.$propertyChangedCallback(e,t,n),"disabled"===e))n?this.$unbind():this.$bind()}$bind(){this.$onPointerDown||(this.$onPointerDown=this.$handlePointerDown.bind(this),fn(this,Wt,this.$onPointerDown)),this.$onPointerMove||(this.$onPointerMove=this.$handlePointerMove.bind(this),fn(this.ownerDocument,qt,this.$onPointerMove)),this.$onPointerUp||(this.$onPointerUp=this.$handlePointerUp.bind(this),fn(this.ownerDocument,Vt,this.$onPointerUp)),this.$onWheel||(this.$onWheel=this.$handleWheel.bind(this),fn(this,Qt,this.$onWheel,{passive:!1,capture:!0}))}$unbind(){this.$onPointerDown&&(pn(this,Wt,this.$onPointerDown),this.$onPointerDown=null),this.$onPointerMove&&(pn(this.ownerDocument,qt,this.$onPointerMove),this.$onPointerMove=null),this.$onPointerUp&&(pn(this.ownerDocument,Vt,this.$onPointerUp),this.$onPointerUp=null),this.$onWheel&&(pn(this,Qt,this.$onWheel,{capture:!0}),this.$onWheel=null)}$handlePointerDown(e){const{buttons:t,button:n,type:l}=e;if(this.disabled||("pointerdown"===l&&"mouse"===e.pointerType||"mousedown"===l)&&(nn(t)&&1!==t||nn(n)&&0!==n||e.ctrlKey))return;const{$pointers:r}=this;let a="";if(e.changedTouches)Array.from(e.changedTouches).forEach(({identifier:e,pageX:t,pageY:n})=>{r.set(e,{startX:t,startY:n,endX:t,endY:n})});else{const{pointerId:t=0,pageX:n,pageY:l}=e;r.set(t,{startX:n,startY:l,endX:n,endY:l})}r.size>1?a=At:cn(e.target)&&(a=e.target.action||e.target.getAttribute("action")||""),!1!==this.$emit(Jt,{action:a,relatedEvent:e})&&(e.preventDefault(),this.$action=a,this.style.willChange="transform")}$handlePointerMove(e){const{$action:t,$pointers:n}=this;if(this.disabled||t===Mt||0===n.size)return;if(!1===this.$emit("actionmove",{action:t,relatedEvent:e}))return;if(e.preventDefault(),e.changedTouches)Array.from(e.changedTouches).forEach(({identifier:e,pageX:t,pageY:l})=>{const r=n.get(e);r&&Object.assign(r,{endX:t,endY:l})});else{const{pointerId:t=0,pageX:l,pageY:r}=e,a=n.get(t);a&&Object.assign(a,{endX:l,endY:r})}const l={action:t,relatedEvent:e};if(t===At){const t=new Map(n);let r=0,a=0,i=0,o=0,s=e.pageX,c=e.pageY;n.forEach((e,n)=>{t.delete(n),t.forEach(t=>{let n=t.startX-e.startX,l=t.startY-e.startY,u=t.endX-e.endX,d=t.endY-e.endY,b=0,m=0,h=0,p=0;if(0===n?l<0?h=2*Math.PI:l>0&&(h=Math.PI):n>0?h=Math.PI/2+Math.atan(l/n):n<0&&(h=1.5*Math.PI+Math.atan(l/n)),0===u?d<0?p=2*Math.PI:d>0&&(p=Math.PI):u>0?p=Math.PI/2+Math.atan(d/u):u<0&&(p=1.5*Math.PI+Math.atan(d/u)),p>0||h>0){const n=p-h,l=Math.abs(n);l>r&&(r=l,i=n,s=(e.startX+t.startX)/2,c=(e.startY+t.startY)/2)}if(n=Math.abs(n),l=Math.abs(l),u=Math.abs(u),d=Math.abs(d),n>0&&l>0?b=Math.sqrt(n*n+l*l):n>0?b=n:l>0&&(b=l),u>0&&d>0?m=Math.sqrt(u*u+d*d):u>0?m=u:d>0&&(m=d),b>0&&m>0){const n=(m-b)/b,l=Math.abs(n);l>a&&(a=l,o=n,s=(e.startX+t.startX)/2,c=(e.startY+t.startY)/2)}})});const u=r>0,d=a>0;u&&d?(l.rotate=i,l.scale=o,l.centerX=s,l.centerY=c):u?(l.action=Lt,l.rotate=i,l.centerX=s,l.centerY=c):d?(l.action=zt,l.scale=o,l.centerX=s,l.centerY=c):l.action=Mt}else{const[e]=Array.from(n.values());Object.assign(l,e)}n.forEach(e=>{e.startX=e.endX,e.startY=e.endY}),l.action!==Mt&&this.$emit(Xt,l,{cancelable:!1})}$handlePointerUp(e){const{$action:t,$pointers:n}=this;if(!this.disabled&&t!==Mt&&!1!==this.$emit(Yt,{action:t,relatedEvent:e})){if(e.preventDefault(),e.changedTouches)Array.from(e.changedTouches).forEach(({identifier:e})=>{n.delete(e)});else{const{pointerId:t=0}=e;n.delete(t)}0===n.size&&(this.style.willChange="",this.$action=Mt)}}$handleWheel(e){if(this.disabled)return;if(e.preventDefault(),this.$wheeling)return;this.$wheeling=!0,setTimeout(()=>{this.$wheeling=!1},50);const t=(e.deltaY>0?-1:1)*this.scaleStep;this.$emit(Xt,{action:zt,scale:t,relatedEvent:e},{cancelable:!1})}$setAction(e){return"string"==typeof e&&(this.$action=e),this}$toCanvas(e){return new Promise((t,n)=>{if(!this.isConnected)return void n(new Error("The current element is not connected to the DOM."));const l=document.createElement("canvas");let r=this.offsetWidth,a=this.offsetHeight,i=1;on(e)&&(ln(e.width)||ln(e.height))&&(({width:r,height:a}=Sn({aspectRatio:r/a,width:e.width,height:e.height})),i=r/this.offsetWidth),l.width=r,l.height=a;const o=this.querySelector(this.$getTagNameOf(jt));o?o.$ready().then(n=>{const s=l.getContext("2d");if(s){const[t,c,u,d,b,m]=o.$getTransform();let h=b,p=m,f=n.naturalWidth,g=n.naturalHeight;1!==i&&(h*=i,p*=i,f*=i,g*=i);const y=f/2,v=g/2;s.fillStyle="transparent",s.fillRect(0,0,r,a),on(e)&&sn(e.beforeDraw)&&e.beforeDraw.call(this,s,l),s.save(),s.translate(y,v),s.transform(t,c,u,d,h,p),s.translate(-y,-v),s.drawImage(n,0,0,f,g),s.restore()}t(l)}).catch(n):t(l)})}}An.$name=wt,An.$version="2.1.0";const Mn=new WeakMap,Pn=["alt","crossorigin","decoding","elementtiming","fetchpriority","loading","referrerpolicy","sizes","src","srcset"];class In extends Ln{constructor(){super(...arguments),this.$matrix=[1,0,0,1,0,0],this.$onLoad=null,this.$onCanvasAction=null,this.$onCanvasActionEnd=null,this.$onCanvasActionStart=null,this.$actionStartTarget=null,this.$style=":host{display:inline-block}img{display:block;height:100%;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;width:100%}",this.$image=new Image,this.initialCenterSize="contain",this.rotatable=!1,this.scalable=!1,this.skewable=!1,this.slottable=!1,this.translatable=!1,this.alt="",this.crossorigin="",this.decoding="",this.elementtiming="",this.fetchpriority="",this.loading="",this.referrerpolicy="",this.sizes="",this.src="",this.srcset=""}set $canvas(e){Mn.set(this,e)}get $canvas(){return Mn.get(this)}static get observedAttributes(){return super.observedAttributes.concat(Pn,["initial-center-size","rotatable","scalable","skewable","translatable"])}attributeChangedCallback(e,t,n){Object.is(n,t)||(super.attributeChangedCallback(e,t,n),Pn.includes(e)&&this.$image.setAttribute(e,n))}$propertyChangedCallback(e,t,n){if(!Object.is(n,t)&&(super.$propertyChangedCallback(e,t,n),"initialCenterSize"===e))this.$nextTick(()=>{this.$center(n)})}connectedCallback(){super.connectedCallback();const{$image:e}=this,t=this.closest(this.$getTagNameOf(wt));t&&(this.$canvas=t,this.$setStyles({display:"block",position:"absolute"}),this.$onCanvasActionStart=e=>{var t,n;this.$actionStartTarget=null===(n=null===(t=e.detail)||void 0===t?void 0:t.relatedEvent)||void 0===n?void 0:n.target},this.$onCanvasActionEnd=()=>{this.$actionStartTarget=null},this.$onCanvasAction=this.$handleAction.bind(this),fn(t,Jt,this.$onCanvasActionStart),fn(t,Yt,this.$onCanvasActionEnd),fn(t,Xt,this.$onCanvasAction)),this.$onLoad=this.$handleLoad.bind(this),fn(e,Gt,this.$onLoad),this.$getShadowRoot().appendChild(e)}disconnectedCallback(){const{$image:e,$canvas:t}=this;t&&(this.$onCanvasActionStart&&(pn(t,Jt,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(pn(t,Yt,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasAction&&(pn(t,Xt,this.$onCanvasAction),this.$onCanvasAction=null)),e&&this.$onLoad&&(pn(e,Gt,this.$onLoad),this.$onLoad=null),this.$getShadowRoot().removeChild(e),super.disconnectedCallback()}$handleLoad(){const{$image:e}=this;this.$setStyles({width:e.naturalWidth,height:e.naturalHeight}),this.$canvas&&this.$center(this.initialCenterSize)}$handleAction(e){if(this.hidden||!(this.rotatable||this.scalable||this.translatable))return;const{$canvas:t}=this,{detail:n}=e;if(n){const{relatedEvent:e}=n;let{action:l}=n;switch(l!==At||this.rotatable&&this.scalable||(l=this.rotatable?Lt:this.scalable?zt:Mt),l){case Tt:if(this.translatable){let l=null;e&&(l=e.target.closest(this.$getTagNameOf(Nt))),l||(l=t.querySelector(this.$getTagNameOf(Nt))),l&&l.multiple&&!l.active&&(l=t.querySelector(`${this.$getTagNameOf(Nt)}[active]`)),l&&!l.hidden&&l.movable&&!l.dynamic&&this.$actionStartTarget&&l.contains(this.$actionStartTarget)||this.$move(n.endX-n.startX,n.endY-n.startY)}break;case Lt:if(this.rotatable)if(e){const{x:t,y:l}=this.getBoundingClientRect();this.$rotate(n.rotate,e.clientX-t,e.clientY-l)}else this.$rotate(n.rotate);break;case zt:if(this.scalable)if(e){const t=e.target.closest(this.$getTagNameOf(Nt));if(!t||!t.zoomable||t.zoomable&&t.dynamic){const{x:t,y:l}=this.getBoundingClientRect();this.$zoom(n.scale,e.clientX-t,e.clientY-l)}}else this.$zoom(n.scale);break;case At:if(this.rotatable&&this.scalable){const{rotate:t}=n;let{scale:l}=n;l<0?l=1/(1-l):l+=1;const r=Math.cos(t),a=Math.sin(t),[i,o,s,c]=[r*l,a*l,-a*l,r*l];if(e){const t=this.getBoundingClientRect(),n=e.clientX-t.x,l=e.clientY-t.y,[r,a,u,d]=this.$matrix,b=n-t.width/2,m=l-t.height/2,h=(b*d-u*m)/(r*d-u*a),p=(m*r-a*b)/(r*d-u*a);this.$transform(i,o,s,c,h*(1-i)+p*s,p*(1-c)+h*o)}else this.$transform(i,o,s,c,0,0)}}}}$ready(e){const{$image:t}=this,n=new Promise((e,n)=>{const l=new Error("Failed to load the image source");if(t.complete)t.naturalWidth>0&&t.naturalHeight>0?e(t):n(l);else{const r=()=>{pn(t,Ht,a),setTimeout(()=>{e(t)})},a=()=>{pn(t,Gt,r),n(l)};gn(t,Gt,r),gn(t,Ht,a)}});return sn(e)&&n.then(t=>(e(t),t)),n}$center(e){const{parentElement:t}=this;if(!t)return this;const n=t.getBoundingClientRect(),l=n.width,r=n.height,{x:a,y:i,width:o,height:s}=this.getBoundingClientRect(),c=a+o/2,u=i+s/2,d=n.x+l/2,b=n.y+r/2;if(this.$move(d-c,b-u),e&&(o!==l||s!==r)){const t=l/o,n=r/s;switch(e){case"cover":this.$scale(Math.max(t,n));break;case"contain":this.$scale(Math.min(t,n))}}return this}$move(e,t=e){if(this.translatable&&nn(e)&&nn(t)){const[n,l,r,a]=this.$matrix,i=(e*a-r*t)/(n*a-r*l),o=(t*n-l*e)/(n*a-r*l);this.$translate(i,o)}return this}$moveTo(e,t=e){if(this.translatable&&nn(e)&&nn(t)){const[n,l,r,a]=this.$matrix,i=(e*a-r*t)/(n*a-r*l),o=(t*n-l*e)/(n*a-r*l);this.$setTransform(n,l,r,a,i,o)}return this}$rotate(e,t,n){if(this.rotatable){const l=kn(e),r=Math.cos(l),a=Math.sin(l),[i,o,s,c]=[r,a,-a,r];if(nn(t)&&nn(n)){const[e,l,r,a]=this.$matrix,{width:u,height:d}=this.getBoundingClientRect(),b=t-u/2,m=n-d/2,h=(b*a-r*m)/(e*a-r*l),p=(m*e-l*b)/(e*a-r*l);this.$transform(i,o,s,c,h*(1-i)-p*s,p*(1-c)-h*o)}else this.$transform(i,o,s,c,0,0)}return this}$zoom(e,t,n){if(!this.scalable||0===e)return this;if(e<0?e=1/(1-e):e+=1,nn(t)&&nn(n)){const[l,r,a,i]=this.$matrix,{width:o,height:s}=this.getBoundingClientRect(),c=t-o/2,u=n-s/2,d=(c*i-a*u)/(l*i-a*r),b=(u*l-r*c)/(l*i-a*r);this.$transform(e,0,0,e,d*(1-e),b*(1-e))}else this.$scale(e);return this}$scale(e,t=e){return this.scalable&&this.$transform(e,0,0,t,0,0),this}$skew(e,t=0){if(this.skewable){const n=kn(e),l=kn(t);this.$transform(1,Math.tan(l),Math.tan(n),1,0,0)}return this}$translate(e,t=e){return this.translatable&&nn(e)&&nn(t)&&this.$transform(1,0,0,1,e,t),this}$transform(e,t,n,l,r,a){return nn(e)&&nn(t)&&nn(n)&&nn(l)&&nn(r)&&nn(a)?this.$setTransform(jn(this.$matrix,[e,t,n,l,r,a])):this}$setTransform(e,t,n,l,r,a){if((this.rotatable||this.scalable||this.skewable||this.translatable)&&(Array.isArray(e)&&([e,t,n,l,r,a]=e),nn(e)&&nn(t)&&nn(n)&&nn(l)&&nn(r)&&nn(a))){const i=[...this.$matrix],o=[e,t,n,l,r,a];if(!1===this.$emit(en,{matrix:o,oldMatrix:i}))return this;this.$matrix=o,this.style.transform=`matrix(${o.join(", ")})`}return this}$getTransform(){return this.$matrix.slice()}$resetTransform(){return this.$setTransform([1,0,0,1,0,0])}}In.$name=jt,In.$version="2.1.0";const Dn=new WeakMap;class On extends Ln{constructor(){super(...arguments),this.$onCanvasActionEnd=null,this.$onCanvasActionStart=null,this.$onSelectionChange=null,this.$style=":host{display:block;height:0;left:0;outline:var(--theme-color) solid 1px;position:relative;top:0;width:0}:host([transparent]){outline-color:transparent}",this.x=0,this.y=0,this.width=0,this.height=0,this.slottable=!1,this.themeColor="rgba(0, 0, 0, 0.65)"}set $canvas(e){Dn.set(this,e)}get $canvas(){return Dn.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["height","width","x","y"])}connectedCallback(){super.connectedCallback();const e=this.closest(this.$getTagNameOf(wt));if(e){this.$canvas=e,this.style.position="absolute";const t=e.querySelector(this.$getTagNameOf(Nt));t&&(this.$onCanvasActionStart=e=>{t.hidden&&e.detail.action===_t&&(this.hidden=!1)},this.$onCanvasActionEnd=e=>{t.hidden&&e.detail.action===_t&&(this.hidden=!0)},this.$onSelectionChange=e=>{const{x:n,y:l,width:r,height:a}=e.defaultPrevented?t:e.detail;this.$change(n,l,r,a),(t.hidden||0===n&&0===l&&0===r&&0===a)&&(this.hidden=!0)},fn(e,Jt,this.$onCanvasActionStart),fn(e,Yt,this.$onCanvasActionEnd),fn(e,Zt,this.$onSelectionChange))}this.$render()}disconnectedCallback(){const{$canvas:e}=this;e&&(this.$onCanvasActionStart&&(pn(e,Jt,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(pn(e,Yt,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onSelectionChange&&(pn(e,Zt,this.$onSelectionChange),this.$onSelectionChange=null)),super.disconnectedCallback()}$change(e,t,n=this.width,l=this.height){return nn(e)&&nn(t)&&nn(n)&&nn(l)&&(e!==this.x||t!==this.y||n!==this.width||l!==this.height)?(this.hidden&&(this.hidden=!1),this.x=e,this.y=t,this.width=n,this.height=l,this.$render()):this}$reset(){return this.$change(0,0,0,0)}$render(){return this.$setStyles({transform:`translate(${this.x}px, ${this.y}px)`,width:this.width,height:this.height,outlineWidth:gt.innerWidth})}}On.$name=Et,On.$version="2.1.0";class Rn extends Ln{constructor(){super(...arguments),this.$onCanvasCropEnd=null,this.$onCanvasCropStart=null,this.$style=':host{background-color:var(--theme-color);display:block}:host([action=move]),:host([action=select]){height:100%;left:0;position:absolute;top:0;width:100%}:host([action=move]){cursor:move}:host([action=select]){cursor:crosshair}:host([action$=-resize]){background-color:transparent;height:15px;position:absolute;width:15px}:host([action$=-resize]):after{background-color:var(--theme-color);content:"";display:block;height:5px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:5px}:host([action=n-resize]),:host([action=s-resize]){cursor:ns-resize;left:50%;transform:translateX(-50%);width:100%}:host([action=n-resize]){top:-8px}:host([action=s-resize]){bottom:-8px}:host([action=e-resize]),:host([action=w-resize]){cursor:ew-resize;height:100%;top:50%;transform:translateY(-50%)}:host([action=e-resize]){right:-8px}:host([action=w-resize]){left:-8px}:host([action=ne-resize]){cursor:nesw-resize;right:-8px;top:-8px}:host([action=nw-resize]){cursor:nwse-resize;left:-8px;top:-8px}:host([action=se-resize]){bottom:-8px;cursor:nwse-resize;right:-8px}:host([action=se-resize]):after{height:15px;width:15px}@media (pointer:coarse){:host([action=se-resize]):after{height:10px;width:10px}}@media (pointer:fine){:host([action=se-resize]):after{height:5px;width:5px}}:host([action=sw-resize]){bottom:-8px;cursor:nesw-resize;left:-8px}:host([plain]){background-color:transparent}',this.action=Mt,this.plain=!1,this.slottable=!1,this.themeColor="rgba(51, 153, 255, 0.5)"}static get observedAttributes(){return super.observedAttributes.concat(["action","plain"])}}Rn.$name=St,Rn.$version="2.1.0";const Fn=new WeakMap;class Un extends Ln{constructor(){super(...arguments),this.$onCanvasAction=null,this.$onCanvasActionStart=null,this.$onCanvasActionEnd=null,this.$onDocumentKeyDown=null,this.$action="",this.$actionStartTarget=null,this.$changing=!1,this.$style=':host{display:block;left:0;position:relative;right:0}:host([outlined]){outline:1px solid var(--theme-color)}:host([multiple]){outline:1px dashed hsla(0,0%,100%,.5)}:host([multiple]):after{bottom:0;content:"";cursor:pointer;display:block;left:0;position:absolute;right:0;top:0}:host([multiple][active]){outline-color:var(--theme-color);z-index:1}:host([multiple])>*{visibility:hidden}:host([multiple][active])>*{visibility:visible}:host([multiple][active]):after{display:none}',this.$initialSelection={x:0,y:0,width:0,height:0},this.x=0,this.y=0,this.width=0,this.height=0,this.aspectRatio=NaN,this.initialAspectRatio=NaN,this.initialCoverage=NaN,this.active=!1,this.linked=!1,this.dynamic=!1,this.movable=!1,this.resizable=!1,this.zoomable=!1,this.multiple=!1,this.keyboard=!1,this.outlined=!1,this.precise=!1}set $canvas(e){Fn.set(this,e)}get $canvas(){return Fn.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["active","aspect-ratio","dynamic","height","initial-aspect-ratio","initial-coverage","keyboard","linked","movable","multiple","outlined","precise","resizable","width","x","y","zoomable"])}$propertyChangedCallback(e,t,n){if(!Object.is(n,t))switch(super.$propertyChangedCallback(e,t,n),e){case"x":case"y":case"width":case"height":this.$changing||this.$nextTick(()=>{this.$change(this.x,this.y,this.width,this.height,this.aspectRatio,!0)});break;case"aspectRatio":case"initialAspectRatio":this.$nextTick(()=>{this.$initSelection()});break;case"initialCoverage":this.$nextTick(()=>{ln(n)&&n<=1&&this.$initSelection(!0,!0)});break;case"keyboard":this.$nextTick(()=>{this.$canvas&&(n?this.$onDocumentKeyDown||(this.$onDocumentKeyDown=this.$handleKeyDown.bind(this),fn(this.ownerDocument,Kt,this.$onDocumentKeyDown)):this.$onDocumentKeyDown&&(pn(this.ownerDocument,Kt,this.$onDocumentKeyDown),this.$onDocumentKeyDown=null))});break;case"multiple":this.$nextTick(()=>{if(this.$canvas){const e=this.$getSelections();n?(e.forEach(e=>{e.active=!1}),this.active=!0,this.$emit(Zt,{x:this.x,y:this.y,width:this.width,height:this.height})):(this.active=!1,e.slice(1).forEach(e=>{this.$removeSelection(e)}))}});break;case"precise":this.$nextTick(()=>{this.$change(this.x,this.y)});break;case"linked":n&&(this.dynamic=!0)}}connectedCallback(){super.connectedCallback();const e=this.closest(this.$getTagNameOf(wt));e?(this.$canvas=e,this.$setStyles({position:"absolute",transform:`translate(${this.x}px, ${this.y}px)`}),this.hidden||this.$render(),this.$initSelection(!0),this.$onCanvasActionStart=this.$handleActionStart.bind(this),this.$onCanvasActionEnd=this.$handleActionEnd.bind(this),this.$onCanvasAction=this.$handleAction.bind(this),fn(e,Jt,this.$onCanvasActionStart),fn(e,Yt,this.$onCanvasActionEnd),fn(e,Xt,this.$onCanvasAction)):this.$render()}disconnectedCallback(){const{$canvas:e}=this;e&&(this.$onCanvasActionStart&&(pn(e,Jt,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(pn(e,Yt,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasAction&&(pn(e,Xt,this.$onCanvasAction),this.$onCanvasAction=null)),super.disconnectedCallback()}$getSelections(){let e=[];return this.parentElement&&(e=Array.from(this.parentElement.querySelectorAll(this.$getTagNameOf(Nt)))),e}$initSelection(e=!1,t=!1){const{initialCoverage:n,parentElement:l}=this;if(ln(n)&&l){const r=this.aspectRatio||this.initialAspectRatio;let a=(t?0:this.width)||l.offsetWidth*n,i=(t?0:this.height)||l.offsetHeight*n;ln(r)&&({width:a,height:i}=Sn({aspectRatio:r,width:a,height:i})),this.$change(this.x,this.y,a,i),e&&this.$center(),this.$initialSelection={x:this.x,y:this.y,width:this.width,height:this.height}}}$createSelection(){const e=this.cloneNode(!0);return this.hasAttribute("id")&&e.removeAttribute("id"),e.initialCoverage=NaN,this.active=!1,this.parentElement&&this.parentElement.insertBefore(e,this.nextSibling),e}$removeSelection(e=this){if(this.parentElement){const t=this.$getSelections();if(t.length>1){const n=t.indexOf(e),l=t[n+1]||t[n-1];l&&(e.active=!1,this.parentElement.removeChild(e),l.active=!0,l.$emit(Zt,{x:l.x,y:l.y,width:l.width,height:l.height}))}else this.$clear()}}$handleActionStart(e){var t,n;const l=null===(n=null===(t=e.detail)||void 0===t?void 0:t.relatedEvent)||void 0===n?void 0:n.target;this.$action="",this.$actionStartTarget=l,!this.hidden&&this.multiple&&!this.active&&l===this&&this.parentElement&&(this.$getSelections().forEach(e=>{e.active=!1}),this.active=!0,this.$emit(Zt,{x:this.x,y:this.y,width:this.width,height:this.height}))}$handleAction(e){const{currentTarget:t,detail:n}=e;if(!t||!n)return;const{relatedEvent:l}=n;let{action:r}=n;const a=l?function(e){if("function"==typeof e.composedPath)return e.composedPath().find(cn)||e.target;return e.target}(l):null;if(!r&&this.multiple&&(r=this.$action||(null==a?void 0:a.action),this.$action=r),!r||this.hidden&&r!==_t||this.multiple&&!this.active&&r!==zt)return;const{width:i,height:o}=this;let s=n.endX-n.startX,c=n.endY-n.startY,{aspectRatio:u}=this;switch(!ln(u)&&l.shiftKey&&(u=ln(i)&&ln(o)?i/o:1),r){case _t:if(0!==s||0!==c){0===s?s=c:0===c&&(c=s);const{$canvas:e}=this,l=xn(t);(this.multiple&&!this.hidden?this.$createSelection():this).$change(n.startX-l.left,n.startY-l.top,Math.abs(s),Math.abs(c),u),s<0?c<0?r=Ft:c>0&&(r=Bt):s>0&&(c<0?r=Rt:c>0&&(r=Ut)),e&&(e.$action=r)}break;case Tt:this.movable&&(this.dynamic||this.$actionStartTarget&&this.contains(this.$actionStartTarget))&&this.$move(s,c);break;case zt:if(l&&this.zoomable&&(this.dynamic||this.contains(l.target))){const e=xn(t);this.$zoom(n.scale,l.pageX-e.left,l.pageY-e.top)}break;default:this.$resize(r,s,c,u)}}$handleActionEnd(){this.$action="",this.$actionStartTarget=null}$handleKeyDown(e){if(this.hidden||!this.keyboard||this.multiple&&!this.active||e.defaultPrevented)return;const{activeElement:t}=document;if(!t||!["INPUT","TEXTAREA"].includes(t.tagName)&&!["true","plaintext-only"].includes(t.contentEditable))switch(e.key){case"Backspace":e.metaKey&&(e.preventDefault(),this.$removeSelection());break;case"Delete":e.preventDefault(),this.$removeSelection();break;case"ArrowLeft":e.preventDefault(),this.$move(-1,0);break;case"ArrowRight":e.preventDefault(),this.$move(1,0);break;case"ArrowUp":e.preventDefault(),this.$move(0,-1);break;case"ArrowDown":e.preventDefault(),this.$move(0,1);break;case"+":e.preventDefault(),this.$zoom(.1);break;case"-":e.preventDefault(),this.$zoom(-.1)}}$center(){const{parentElement:e}=this;if(!e)return this;const t=(e.offsetWidth-this.width)/2,n=(e.offsetHeight-this.height)/2;return this.$change(t,n)}$move(e,t=e){return this.$moveTo(this.x+e,this.y+t)}$moveTo(e,t=e){return this.movable?this.$change(e,t):this}$resize(e,t=0,n=0,l=this.aspectRatio){if(!this.resizable)return this;const r=ln(l),{$canvas:a}=this;let{x:i,y:o,width:s,height:c}=this;switch(e){case Pt:o+=n,c-=n,c<0&&(e=Dt,c=-c,o-=c),r&&(i+=(t=n*l)/2,s-=t,s<0&&(s=-s,i-=s));break;case It:s+=t,s<0&&(e=Ot,s=-s,i-=s),r&&(o-=(n=t/l)/2,c+=n,c<0&&(c=-c,o-=c));break;case Dt:c+=n,c<0&&(e=Pt,c=-c,o-=c),r&&(i-=(t=n*l)/2,s+=t,s<0&&(s=-s,i-=s));break;case Ot:i+=t,s-=t,s<0&&(e=It,s=-s,i-=s),r&&(o+=(n=t/l)/2,c-=n,c<0&&(c=-c,o-=c));break;case Rt:r&&(n=-t/l),o+=n,c-=n,s+=t,s<0&&c<0?(e=Bt,s=-s,c=-c,i-=s,o-=c):s<0?(e=Ft,s=-s,i-=s):c<0&&(e=Ut,c=-c,o-=c);break;case Ft:r&&(n=t/l),i+=t,o+=n,s-=t,c-=n,s<0&&c<0?(e=Ut,s=-s,c=-c,i-=s,o-=c):s<0?(e=Rt,s=-s,i-=s):c<0&&(e=Bt,c=-c,o-=c);break;case Ut:r&&(n=t/l),s+=t,c+=n,s<0&&c<0?(e=Ft,s=-s,c=-c,i-=s,o-=c):s<0?(e=Bt,s=-s,i-=s):c<0&&(e=Rt,c=-c,o-=c);break;case Bt:r&&(n=-t/l),i+=t,s-=t,c+=n,s<0&&c<0?(e=Rt,s=-s,c=-c,i-=s,o-=c):s<0?(e=Ut,s=-s,i-=s):c<0&&(e=Ft,c=-c,o-=c)}return a&&a.$setAction(e),this.$change(i,o,s,c)}$zoom(e,t,n){if(!this.zoomable||0===e)return this;e<0?e=1/(1-e):e+=1;const{width:l,height:r}=this,a=l*e,i=r*e;let o=this.x,s=this.y;return nn(t)&&nn(n)?(o-=(a-l)*((t-this.x)/l),s-=(i-r)*((n-this.y)/r)):(o-=(a-l)/2,s-=(i-r)/2),this.$change(o,s,a,i)}$change(e,t,n=this.width,l=this.height,r=this.aspectRatio,a=!1){return this.$changing||!nn(e)||!nn(t)||!nn(n)||!nn(l)||n<0||l<0?this:(ln(r)&&({width:n,height:l}=Sn({aspectRatio:r,width:n,height:l},"cover")),this.precise||(e=Math.round(e),t=Math.round(t),n=Math.round(n),l=Math.round(l)),e===this.x&&t===this.y&&n===this.width&&l===this.height&&Object.is(r,this.aspectRatio)&&!a?this:(this.hidden&&(this.hidden=!1),!1===this.$emit(Zt,{x:e,y:t,width:n,height:l})?this:(this.$changing=!0,this.x=e,this.y=t,this.width=n,this.height=l,this.$changing=!1,this.$render())))}$reset(){const{x:e,y:t,width:n,height:l}=this.$initialSelection;return this.$change(e,t,n,l)}$clear(){return this.$change(0,0,0,0,NaN,!0),this.hidden=!0,this}$render(){return this.$setStyles({transform:`translate(${this.x}px, ${this.y}px)`,width:this.width,height:this.height})}$toCanvas(e){return new Promise((t,n)=>{if(!this.isConnected)return void n(new Error("The current element is not connected to the DOM."));const l=document.createElement("canvas");let{width:r,height:a}=this,i=1;if(on(e)&&(ln(e.width)||ln(e.height))&&(({width:r,height:a}=Sn({aspectRatio:r/a,width:e.width,height:e.height})),i=r/this.width),l.width=r,l.height=a,!this.$canvas)return void t(l);const o=this.$canvas.querySelector(this.$getTagNameOf(jt));o?o.$ready().then(n=>{const s=l.getContext("2d");if(s){const[t,c,u,d,b,m]=o.$getTransform(),h=-this.x,p=-this.y,f=(h*d-u*p)/(t*d-u*c),g=(p*t-c*h)/(t*d-u*c);let y=t*f+u*g+b,v=c*f+d*g+m,x=n.naturalWidth,w=n.naturalHeight;1!==i&&(y*=i,v*=i,x*=i,w*=i);const k=x/2,C=w/2;s.fillStyle="transparent",s.fillRect(0,0,r,a),on(e)&&sn(e.beforeDraw)&&e.beforeDraw.call(this,s,l),s.save(),s.translate(k,C),s.transform(t,c,u,d,y,v),s.translate(-k,-C),s.drawImage(n,0,0,x,w),s.restore()}t(l)}).catch(n):t(l)})}}Un.$name=Nt,Un.$version="2.1.0";class Bn extends Ln{constructor(){super(...arguments),this.$style=":host{display:flex;flex-direction:column;position:relative;touch-action:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}:host([bordered]){border:1px dashed var(--theme-color)}:host([covered]){bottom:0;left:0;position:absolute;right:0;top:0}:host>span{display:flex;flex:1}:host>span+span{border-top:1px dashed var(--theme-color)}:host>span>span{flex:1}:host>span>span+span{border-left:1px dashed var(--theme-color)}",this.bordered=!1,this.columns=3,this.covered=!1,this.rows=3,this.slottable=!1,this.themeColor="rgba(238, 238, 238, 0.5)"}static get observedAttributes(){return super.observedAttributes.concat(["bordered","columns","covered","rows"])}$propertyChangedCallback(e,t,n){Object.is(n,t)||(super.$propertyChangedCallback(e,t,n),"rows"!==e&&"columns"!==e||this.$nextTick(()=>{this.$render()}))}connectedCallback(){super.connectedCallback(),this.$render()}$render(){const e=this.$getShadowRoot(),t=document.createDocumentFragment();for(let n=0;n<this.rows;n+=1){const e=document.createElement("span");e.setAttribute("role","row");for(let t=0;t<this.columns;t+=1){const t=document.createElement("span");t.setAttribute("role","gridcell"),e.appendChild(t)}t.appendChild(e)}e&&(e.innerHTML="",e.appendChild(t))}}Bn.$name=Ct,Bn.$version="2.1.0";class Wn extends Ln{constructor(){super(...arguments),this.$style=':host{display:inline-block;height:1em;position:relative;touch-action:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;vertical-align:middle;width:1em}:host:after,:host:before{background-color:var(--theme-color);content:"";display:block;position:absolute}:host:before{height:1px;left:0;top:50%;transform:translateY(-50%);width:100%}:host:after{height:100%;left:50%;top:0;transform:translateX(-50%);width:1px}:host([centered]){left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}',this.centered=!1,this.slottable=!1,this.themeColor="rgba(238, 238, 238, 0.5)"}static get observedAttributes(){return super.observedAttributes.concat(["centered"])}}Wn.$name=kt,Wn.$version="2.1.0";const qn=new WeakMap,Vn=new WeakMap,Hn=new WeakMap,Kn=new WeakMap,Gn="vertical";class Qn extends Ln{constructor(){super(...arguments),this.$onSelectionChange=null,this.$onSourceImageLoad=null,this.$onSourceImageTransform=null,this.$scale=1,this.$style=":host{display:block;height:100%;overflow:hidden;position:relative;width:100%}",this.resize=Gn,this.selection="",this.slottable=!1}set $image(e){Vn.set(this,e)}get $image(){return Vn.get(this)}set $sourceImage(e){Kn.set(this,e)}get $sourceImage(){return Kn.get(this)}set $canvas(e){qn.set(this,e)}get $canvas(){return qn.get(this)}set $selection(e){Hn.set(this,e)}get $selection(){return Hn.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["resize","selection"])}connectedCallback(){var e,t;super.connectedCallback();let n=null;if(n=this.selection?null!==(t=null===(e=function(e){const t=e.getRootNode();switch(t.nodeType){case 1:return t.ownerDocument;case 9:case 11:return t}return null}(this))||void 0===e?void 0:e.querySelector(this.selection))&&void 0!==t?t:null:this.closest(this.$getTagNameOf(Nt)),cn(n)){this.$selection=n,this.$onSelectionChange=this.$handleSelectionChange.bind(this),fn(n,Zt,this.$onSelectionChange);const e=n.closest(this.$getTagNameOf(wt));if(e){this.$canvas=e;const t=e.querySelector(this.$getTagNameOf(jt));t&&(this.$sourceImage=t,this.$image=t.cloneNode(!0),this.$getShadowRoot().appendChild(this.$image),this.$onSourceImageLoad=this.$handleSourceImageLoad.bind(this),this.$onSourceImageTransform=this.$handleSourceImageTransform.bind(this),fn(t.$image,Gt,this.$onSourceImageLoad),fn(t,en,this.$onSourceImageTransform))}this.$render()}}disconnectedCallback(){const{$selection:e,$sourceImage:t}=this;e&&this.$onSelectionChange&&(pn(e,Zt,this.$onSelectionChange),this.$onSelectionChange=null),t&&this.$onSourceImageLoad&&(pn(t.$image,Gt,this.$onSourceImageLoad),this.$onSourceImageLoad=null),t&&this.$onSourceImageTransform&&(pn(t,en,this.$onSourceImageTransform),this.$onSourceImageTransform=null),super.disconnectedCallback()}$handleSelectionChange(e){this.$render(e.defaultPrevented?this.$selection:e.detail)}$handleSourceImageLoad(){const{$image:e,$sourceImage:t}=this,n=e.getAttribute("src"),l=t.getAttribute("src");l&&l!==n&&(e.setAttribute("src",l),e.$ready(()=>{this.$render()}))}$handleSourceImageTransform(e){this.$render(void 0,e.detail.matrix)}$render(e,t){const{$canvas:n,$selection:l}=this;e||l.hidden||(e=l),(!e||0===e.x&&0===e.y&&0===e.width&&0===e.height)&&(e={x:0,y:0,width:n.offsetWidth,height:n.offsetHeight});const{x:r,y:a,width:i,height:o}=e,s={},{clientWidth:c,clientHeight:u}=this;let d=c,b=u,m=NaN;switch(this.resize){case"both":m=1,d=i,b=o,s.width=i,s.height=o;break;case"horizontal":m=o>0?u/o:0,d=i*m,s.width=d;break;case Gn:m=i>0?c/i:0,b=o*m,s.height=b;break;default:c>0?m=i>0?c/i:0:u>0&&(m=o>0?u/o:0)}this.$scale=m,this.$setStyles(s),this.$sourceImage&&setTimeout(()=>{this.$transformImageByOffset(null!=t?t:this.$sourceImage.$getTransform(),-r,-a)})}$transformImageByOffset(e,t,n){const{$image:l,$scale:r,$sourceImage:a}=this;if(a&&l&&r>=0){const[a,i,o,s,c,u]=e,d=(t*s-o*n)/(a*s-o*i),b=(n*a-i*t)/(a*s-o*i),m=a*d+o*b+c,h=i*d+s*b+u;l.$ready(e=>{this.$setStyles.call(l,{width:e.naturalWidth*r,height:e.naturalHeight*r})}),l.$setTransform(a,i,o,s,m*r,h*r)}}}function Xn(){const[e,t]=y.useState(!1),[n,l]=y.useState(null),[r,a]=y.useState(null),i=async(e,r)=>{if(!e||!r)return l("ID de asset y configuración de variante son requeridos"),null;t(!0),l(null),a(null);try{const t=await async function(e,{variant_name:t,width:l,height:r,crop_params:a,preset_aspect:i=null,preset_size:o=null,output_format:s="webp"}){try{const n=[{name:t,width:l,height:r,output_format:s,crop_params:a}];return i&&(n[0].preset_aspect=i),o&&(n[0].preset_size=o),se(await ne({endpoint:`/assets/${e}/variants`,method:"POST",body:{variants:n,async:!1},basePath:ue,useJWT:!0}))}catch(n){throw ce(n)}}(e,{variant_name:r.name,width:r.width,height:r.height,crop_params:r.crop_params,preset_aspect:r.preset_aspect,preset_size:r.preset_size,output_format:r.output_format});if(t?.result)return a(t.result),t.result;throw new Error("No se pudo crear la variante")}catch(i){return console.error("Error creating variant:",i),l(i.message||"Error desconocido al crear variante"),null}finally{t(!1)}};return{createVariant:i,createCropVariant:async(e,t,n={})=>{const l={name:n.name||`crop_${Date.now()}`,width:n.width||800,height:n.height||600,output_format:n.format||"webp",crop_params:{x:t.x||0,y:t.y||0,width:t.width||1,height:t.height||1}};return await i(e,l)},createVariantFromBlob:async(e,r,i={})=>{if(!e||!r)return l("ID de asset y blob son requeridos"),null;t(!0),l(null),a(null);try{const t=await async function(e,t,l={}){try{const n=new FormData,r=l.format||"webp",a=`${l.name||"variant"}.${r}`;return n.append("file",t,a),n.append("variant_name",l.name||"variant"),n.append("width",String(l.width||0)),n.append("height",String(l.height||0)),n.append("output_format",l.format||"webp"),n.append("permanent_url",!1!==l.permanentUrl?"true":"false"),se(await ne({endpoint:`/assets/${e}/variants/upload`,method:"POST",body:n,basePath:ue,isFormData:!0,useJWT:!0}))}catch(n){throw ce(n)}}(e,r,{name:i.name||`crop_${Date.now()}`,width:i.width||0,height:i.height||0,format:i.format||"webp"});if(t?.result)return a(t.result),t.result;throw new Error("No se pudo crear la variante")}catch(o){return console.error("Error creating variant from blob:",o),l(o.message||"Error desconocido al crear variante"),null}finally{t(!1)}},loading:e,error:n,createdVariant:r,reset:()=>{l(null),a(null)}}}Qn.$name=$t,Qn.$version="2.1.0",An.$define(),Wn.$define(),Bn.$define(),Rn.$define(),In.$define(),Un.$define(),On.$define(),Qn.$define();class Yn{constructor(e,t,n){this.canvasRef=e,this.imageRef=t,this.selectionRef=n}get canvasElement(){return this.canvasRef?.current}get image(){return this.imageRef?.current}get selectionElement(){return this.selectionRef?.current}get isReady(){return!!(this.canvasElement&&this.image&&this.selectionElement)}transform={move:(e,t)=>{if(!this.image)return!1;try{return this.image.$move(e,t),!0}catch(n){return console.warn("Error moving image:",n),!1}},moveTo:(e,t)=>{if(!this.image)return!1;try{return this.image.$moveTo(e,t),!0}catch(n){return console.warn("Error moving image to position:",n),!1}},zoom:e=>{if(!this.image)return!1;try{return this.image.$zoom(e),!0}catch(t){return console.warn("Error zooming image:",t),!1}},rotate:e=>{if(!this.image)return!1;try{const t=e*Math.PI/180;return this.image.$rotate(t),!0}catch(t){return console.warn("Error rotating image:",t),!1}},scale:(e,t=e)=>{if(!this.image)return!1;try{return this.image.$scale(e,t),!0}catch(n){return console.warn("Error scaling image:",n),!1}},center:(e="contain")=>{if(!this.image)return!1;try{return this.image.$center(e),!0}catch(t){return console.warn("Error centering image:",t),!1}},reset:()=>{if(!this.image)return!1;try{return this.image.$resetTransform(),!0}catch(e){return console.warn("Error resetting transform:",e),!1}},getTransform:()=>{if(!this.image)return null;try{return this.image.$getTransform()}catch(e){return console.warn("Error getting transform:",e),null}},setTransform:(e,t,n,l,r,a)=>{if(!this.image)return!1;try{return this.image.$setTransform(e,t,n,l,r,a),!0}catch(i){return console.warn("Error setting transform:",i),!1}},resetZoom:()=>{if(!this.image)return!1;try{const e=this.image.$getTransform();if(!e)return!1;const[t,n,l,r,a,i]=e,o=Math.sqrt(t*t+n*n),s=Math.sqrt(l*l+r*r),c=t/o,u=n/o,d=l/s,b=r/s;return this.image.$setTransform(c,u,d,b,a,i),!0}catch(e){return console.warn("Error resetting zoom:",e),!1}},setZoom:e=>{if(!this.image||e<=0)return!1;try{const t=this.image.$getTransform();if(!t)return!1;const[n,l,r,a,i,o]=t,s=Math.sqrt(n*n+l*l),c=Math.sqrt(r*r+a*a),u=n/s*e,d=l/s*e,b=r/c*e,m=a/c*e;return this.image.$setTransform(u,d,b,m,i,o),!0}catch(t){return console.warn("Error setting zoom level:",t),!1}},getZoom:()=>{if(!this.image)return 1;try{const e=this.image.$getTransform();if(!e)return 1;const[t,n]=e;return Math.sqrt(t*t+n*n)}catch(e){return console.warn("Error getting zoom level:",e),1}},fitToCanvas:(e=.1)=>{if(!this.image||!this.canvasElement)return!1;try{const t=this.canvasElement.getBoundingClientRect();let n=this.image.querySelector("img")||this.image;if(!n?.naturalWidth||!n?.naturalHeight)return!1;const l=1-e,r=t.width*l/n.naturalWidth,a=t.height*l/n.naturalHeight,i=Math.min(r,a,1);return this.transform.setZoom(i)}catch(t){return console.warn("Error fitting to canvas:",t),!1}}};selection={center:()=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$center(),!0}catch(e){return console.warn("Error centering selection:",e),!1}},reset:()=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$reset(),!0}catch(e){return console.warn("Error resetting selection:",e),!1}},setCoverage:e=>{if(!this.selectionElement||e<0||e>1)return!1;try{return this.selectionElement.initialCoverage=e,this.selectionElement.$reset(),!0}catch(t){return console.warn("Error setting coverage:",t),!1}},setAspectRatio:e=>{if(!this.selectionElement)return!1;try{let t;if(""===e||null==e)t=NaN;else if("number"==typeof e)t=e;else{if("string"!=typeof e)return console.warn("Unsupported aspect ratio type:",typeof e,e),!1;if(e.includes("/")){const[n,l]=e.split("/").map(e=>parseFloat(e.trim()));if(isNaN(n)||isNaN(l)||0===l)return console.warn("Invalid aspect ratio format:",e),!1;t=n/l}else if(t=parseFloat(e),isNaN(t))return console.warn("Invalid aspect ratio format:",e),!1}return this.selectionElement.aspectRatio=t,this.selectionElement.$render(),!0}catch(t){return console.warn("Error setting aspect ratio:",t),!1}},move:(e,t)=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$move(e,t),!0}catch(n){return console.warn("Error moving selection:",n),!1}},zoom:e=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$zoom(e),!0}catch(t){return console.warn("Error zooming selection:",t),!1}},change:(e,t,n,l,r)=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$change(e,t,n,l,r),!0}catch(a){return console.warn("Error changing selection:",a),!1}},set:(e,t,n,l)=>{if(!this.selectionElement)return!1;try{return this.selectionElement.x=e,this.selectionElement.y=t,this.selectionElement.width=n,this.selectionElement.height=l,this.selectionElement.$render(),!0}catch(r){return console.warn("Error setting selection:",r),!1}},toCanvas:async(e={})=>{if(!this.selectionElement)return null;try{const t={width:800,height:600,imageSmoothingEnabled:!0,imageSmoothingQuality:"high",...e};return await this.selectionElement.$toCanvas(t)}catch(t){return console.warn("Error exporting to canvas:",t),null}},getData:()=>{if(!this.selectionElement)return null;try{return{x:this.selectionElement.x,y:this.selectionElement.y,width:this.selectionElement.width,height:this.selectionElement.height,aspectRatio:this.selectionElement.aspectRatio}}catch(e){return console.warn("Error getting selection data:",e),null}}};canvas={setBackground:e=>{if(!this.canvasElement)return!1;try{return this.canvasElement.background=e,!0}catch(t){return console.warn("Error setting background:",t),!1}},setScaleStep:e=>{if(!this.canvasElement)return!1;try{return this.canvasElement.scaleStep=e,!0}catch(t){return console.warn("Error setting scale step:",t),!1}},setDisabled:e=>{if(!this.canvasElement)return!1;try{return this.canvasElement.disabled=e,!0}catch(t){return console.warn("Error setting disabled state:",t),!1}}};utils={flipHorizontal:()=>{const e=this.transform.getTransform();if(!e)return!1;const[t,n,l,r,a,i]=e;return this.transform.setTransform(-t,n,l,r,a,i)},flipVertical:()=>{const e=this.transform.getTransform();if(!e)return!1;const[t,n,l,r,a,i]=e;return this.transform.setTransform(t,n,l,-r,a,i)},setupInitialView:async(e={})=>{const{paspartuFactor:t=.85,retries:n=3,retryDelay:l=200}=e;return new Promise(e=>{const r=(a=0)=>{if(!this.isReady)return a<n?void setTimeout(()=>r(a+1),l):void e(!1);try{const i=this.canvasElement.getBoundingClientRect();let o=this.image.querySelector("img")||this.image;if(!o?.naturalWidth||!o?.naturalHeight)return a<n?void setTimeout(()=>r(a+1),l):(this.transform.center(),void e(!1));if(i.width>0&&i.height>0){const n=i.width*t/o.naturalWidth,l=i.height*t/o.naturalHeight,r=Math.min(n,l,1);this.transform.setTransform(r,0,0,r,0,0)?setTimeout(()=>{this.transform.center(),this.selection.center(),e(!0)},100):(this.transform.reset(),setTimeout(()=>{r<1&&this.transform.scale(r),setTimeout(()=>{this.transform.center(),this.selection.center(),e(!0)},100)},100))}else this.transform.center(),e(!1)}catch(i){console.warn("Error in setup:",i),this.transform.center(),e(!1)}};r()})},resetAll:()=>{const e={transform:this.transform.reset(),selection:this.selection.reset(),center:!1};return setTimeout(()=>{e.center=this.transform.center()&&this.selection.center()},100),e},checkExportability:async()=>{try{return!!(await this.selection.toCanvas({width:1,height:1}))}catch{return!1}},resetZoomOnly:()=>this.transform.resetZoom(),getZoomInfo:()=>{const e=this.transform.getZoom();return{current:e,isZoomedIn:e>1,isZoomedOut:e<1,percentage:Math.round(100*e)}},setBackground:e=>this.canvas.setBackground(e)};setupEventListeners(e={}){const{onSelectionChange:t,onImageTransform:n,onAction:l,onActionStart:r,onActionMove:a,onActionEnd:i}=e,o=[];if(t&&this.selectionElement){const e=e=>{t({x:e.detail.x,y:e.detail.y,width:e.detail.width,height:e.detail.height})};this.selectionElement.addEventListener("change",e),o.push(()=>{this.selectionElement&&this.selectionElement.removeEventListener("change",e)})}if(n&&this.image){const e=e=>{n({matrix:e.detail.matrix,oldMatrix:e.detail.oldMatrix})};this.image.addEventListener("transform",e),o.push(()=>{this.image&&this.image.removeEventListener("transform",e)})}if(this.canvasElement){if(l){const e=e=>l(e.detail);this.canvasElement.addEventListener("action",e),o.push(()=>{this.canvasElement&&this.canvasElement.removeEventListener("action",e)})}if(r){const e=e=>r(e.detail);this.canvasElement.addEventListener("actionstart",e),o.push(()=>{this.canvasElement&&this.canvasElement.removeEventListener("actionstart",e)})}if(a){const e=e=>a(e.detail);this.canvasElement.addEventListener("actionmove",e),o.push(()=>{this.canvasElement&&this.canvasElement.removeEventListener("actionmove",e)})}if(i){const e=e=>i(e.detail);this.canvasElement.addEventListener("actionend",e),o.push(()=>{this.canvasElement&&this.canvasElement.removeEventListener("actionend",e)})}}return()=>{o.forEach(e=>e())}}}async function Jn(e,t,n={}){const{format:l=null,originalFormat:r="webp",onSuccess:a=null,onError:i=null,accessibilityManager:o=null}=n;try{const n=window.limboCore?.config?.getGlobal(),i=l||n?.downloadFormat||r||"webp",c=`${t.split(".")[0]}.${i}`;if(o&&o.announce(`Descargando ${c}`),e.startsWith("data:image/"))return function(e,t){const n=document.createElement("a");n.href=e,n.download=t,n.style.display="none",document.body.appendChild(n),n.click(),setTimeout(()=>{document.body.removeChild(n)},100)}(e,c),a&&a(c),o&&o.announce(`${c} descargado correctamente`),!0;let u;try{if(u=await fetch(e,{mode:"cors"}),!u.ok)throw new Error(`HTTP error! status: ${u.status}`)}catch(s){if(!e.startsWith("http"))throw s;{const t=(window.limboCore?.config?.getGlobal()||{}).prod?"https://limbo.lefebvre.es":"https://led-dev-limbo-dev.eu.els.local",n=window.limboCore?.apiClient?.token||"",l=`${t}/api/atenea/proxy?url=${encodeURIComponent(e)}`;if(u=await fetch(l,{credentials:"include",headers:{Authorization:`Bearer ${n}`}}),!u.ok)throw new Error(`Proxy error: ${u.status}`)}}const d=await u.blob();let b=d;const m=d.type;m!==`image/${"jpg"===i?"jpeg":i}`&&function(e){return["webp","jpeg","jpg","png"].includes(e.toLowerCase())}(i)&&(b=await async function(e,t){return new Promise((n,l)=>{const r=new Image,a=URL.createObjectURL(e);r.onload=()=>{try{const l=document.createElement("canvas");l.width=r.width,l.height=r.height;l.getContext("2d").drawImage(r,0,0);const i=`image/${"jpg"===t?"jpeg":t}`,o="png"===t?void 0:.92;l.toBlob(t=>{URL.revokeObjectURL(a),n(t||e)},i,o)}catch(l){URL.revokeObjectURL(a),n(e)}},r.onerror=()=>{URL.revokeObjectURL(a),n(e)},r.src=a})}(d,i));const h=window.URL.createObjectURL(b),p=document.createElement("a");return p.href=h,p.download=c,p.style.display="none",document.body.appendChild(p),p.click(),setTimeout(()=>{window.URL.revokeObjectURL(h),document.body.removeChild(p)},100),a&&a(c),o&&o.announce(`${c} descargado correctamente`),!0}catch(c){return console.error("Error downloading image:",c),i&&i(c),o&&o.announce(`Error al descargar la imagen: ${c.message}`),!1}}const Zn=Object.freeze(Object.defineProperty({__proto__:null,default:Jn,downloadImage:Jn},Symbol.toStringTag,{value:"Module"}));function el({image:e,onSave:t,onCancel:n,onDelete:l,onError:r=null,deleting:a=!1,onVariantCreated:i=null,onUpload:o=null,uploading:s=!1,cropperConfig:c=null}){const[u,d]=y.useState(!1),[b,m]=y.useState(null),[h,p]=y.useState(!1),[f,g]=y.useState(!0),[v,x]=y.useState(!0),[w,k]=y.useState({x:20,y:100}),[C,S]=y.useState(!1),[j,N]=y.useState({x:0,y:0}),[E,$]=y.useState(!1),[_,T]=y.useState(!0),[z,L]=y.useState(!1),[A,M]=y.useState({horizontal:!1,vertical:!1}),[P,I]=y.useState(!1),[D,O]=y.useState(!1),[R,U]=y.useState(!1),[B,W]=y.useState(!1),[q]=y.useState(()=>{if(!e||!e.filename)return"image";const[t]=e.filename.split(".");return t}),V=y.useMemo(()=>{if(c)return{mandatoryCrops:c.mandatoryCrops||[],allowCustomCrops:!1!==c.allowAdditionalCrops,showDimensionInputs:!0===c.showDimensionInputs,maxCrops:c.maxCrops||null,localCropsOnly:!0===c.localCropsOnly,existingCrops:c.existingCrops||null};const e=window.limboCore?.config?.getGlobal()||{};return{mandatoryCrops:e.cropper?.mandatoryCrops||[],allowCustomCrops:!1!==e.cropper?.allowCustomCrops,showDimensionInputs:!0===e.cropper?.showDimensionInputs,maxCrops:e.cropper?.maxCrops||null,localCropsOnly:!0===e.cropper?.localCropsOnly,existingCrops:e.cropper?.existingCrops||null}},[c]),[H,K]=y.useState(()=>V.mandatoryCrops.length>0?V.mandatoryCrops.map((e,t)=>({id:`crop-${t}`,label:e.label,width:e.width,height:e.height,required:!1!==e.required,isCustom:!1,confirmed:!1,lockDimensions:!(!e.width||!e.height),format:e.format||null,savedState:null})):[{id:"crop-default-0",label:q,width:e.width||1920,height:e.height||1080,required:!1,isCustom:!0,confirmed:!1,savedState:null}]),[G,Q]=y.useState(0),X=H[G],Y=y.useMemo(()=>X&&X.width&&X.height?X.width/X.height:"",[X]),J=y.useMemo(()=>{const e=50;if(!Y||""===Y)return{minWidth:e,minHeight:e};if(Y>=1){return{minWidth:e,minHeight:e/Y}}return{minWidth:e*Y,minHeight:e}},[Y]),[Z,ee]=y.useState(!1),[te,ne]=y.useState([]),[le,re]=y.useState(null),ae=window.limboCore?.accessibilityManager,{createVariantFromBlob:ie,loading:oe,error:se}=Xn(),ce=((e,t={})=>{const n=y.useRef(null),l=y.useRef(null),r=y.useRef(null),a=y.useRef(null),[i,o]=y.useState(null),[s,c]=y.useState(null),[u,d]=y.useState(!1),[b,m]=y.useState(!0),[h,p]=y.useState(0),f={aspectRatio:"",shade:!0,paspartuFactor:.85,...t};y.useEffect(()=>{n.current&&l.current&&r.current&&(a.current=new Yn(n,l,r),d(!0))},[]),y.useEffect(()=>{if(a.current)return a.current.setupEventListeners({onSelectionChange:e=>{o(e)},onImageTransform:()=>{p(e=>e+1)}})},[u]),y.useEffect(()=>{a.current&&e&&(async()=>{a.current.selection.setAspectRatio(f.aspectRatio),a.current.canvas.setBackground(f.shade),await a.current.utils.setupInitialView({paspartuFactor:f.paspartuFactor});const e=await a.current.utils.checkExportability();m(e);const t=l.current?.querySelector("img")||l.current;t?.naturalWidth&&t?.naturalHeight&&c({naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight,currentWidth:t.width,currentHeight:t.height})})()},[e]),y.useEffect(()=>{a.current&&u&&a.current.selection.setAspectRatio(f.aspectRatio)},[f.aspectRatio,u]),y.useEffect(()=>{a.current&&u&&a.current.canvas.setBackground(f.shade)},[f.shade,u]);const g=y.useCallback(()=>({move:(e,t)=>a.current?.transform.move(e,t)||!1,zoom:e=>a.current?.transform.zoom(e)||!1,rotate:e=>a.current?.transform.rotate(e)||!1,center:()=>a.current?.transform.center()||!1,reset:()=>a.current?.transform.reset()||!1,resetZoom:()=>a.current?.transform.resetZoom()||!1,setZoom:e=>a.current?.transform.setZoom(e)||!1,getZoom:()=>a.current?.transform.getZoom()||1,fitToCanvas:e=>a.current?.transform.fitToCanvas(e)||!1,flipHorizontal:()=>a.current?.utils.flipHorizontal()||!1,flipVertical:()=>a.current?.utils.flipVertical()||!1}),[]),v=y.useCallback(()=>({center:()=>a.current?.selection.center()||!1,reset:()=>a.current?.selection.reset()||!1,setCoverage:e=>a.current?.selection.setCoverage(e)||!1,setAspectRatio:e=>a.current?.selection.setAspectRatio(e)||!1,toCanvas:e=>a.current?.selection.toCanvas(e)||Promise.resolve(null)}),[]),x=y.useCallback(()=>({resetAll:()=>{if(a.current){const e=a.current.utils.resetAll();return o(null),e}return!1},setBackground:e=>a.current?.canvas.setBackground(e)||!1,resetZoomOnly:()=>a.current?.utils.resetZoomOnly()||!1,getZoomInfo:()=>a.current?.utils.getZoomInfo()||{current:1,percentage:100,isZoomedIn:!1,isZoomedOut:!1}}),[]);return{refs:{canvasRef:n,imageRef:l,selectionRef:r},state:{cropData:i,imageInfo:s,isReady:u,canExport:b,transformVersion:h},transform:g(),selection:v(),utils:x(),manager:a.current}})(e,{aspectRatio:Y||null,showGrid:f,shade:v,initialCoverage:.5,paspartuFactor:.85}),{refs:ue,state:de,transform:be,selection:me,utils:he}=ce,{canvasRef:pe,imageRef:fe,selectionRef:ge}=ue,{cropData:ye,imageInfo:ve,canExport:xe,transformVersion:we}=de,ke=y.useMemo(()=>ve||{naturalWidth:e.width||1920,naturalHeight:e.height||1080,currentWidth:e.width||1920,currentHeight:e.height||1080},[ve,e.width,e.height]),Ce=y.useCallback(()=>g(e=>!e),[]),Se=y.useCallback(()=>x(e=>!e),[]),je=y.useCallback(()=>O(e=>!e),[]),Ne=y.useCallback(()=>U(e=>!e),[]),$e=y.useCallback(()=>W(e=>!e),[]),_e=y.useCallback(()=>be.center(),[be]),Te=y.useCallback(()=>me.center(),[me]),ze=y.useCallback(()=>me.reset(),[me]),Le=y.useCallback((e,t)=>be.move(e,t),[be]),Ae=y.useCallback(e=>be.zoom(e),[be]),Me=y.useCallback(e=>be.rotate(e),[be]),Pe=y.useCallback(e=>{me.setCoverage(e)},[me]),Ie=y.useCallback(()=>{M(e=>{const t=!e.horizontal;return be.flipHorizontal(),{...e,horizontal:t}})},[be]),De=y.useCallback(()=>{M(e=>{const t=!e.vertical;return be.flipVertical(),{...e,vertical:t}})},[be]),Oe=y.useCallback(()=>{if(!ce.manager||!de.isReady)return null;try{const e=ye?{...ye}:null;let t=null;if(ge.current){const e=ge.current;t={x:e.x??0,y:e.y??0,width:e.width??0,height:e.height??0}}let n=null;if(fe.current){const e=fe.current.$getTransform?.();e&&Array.isArray(e)&&(n=[...e])}const l={cropData:e,selectorState:t,imageTransform:n,flipState:{horizontal:A.horizontal,vertical:A.vertical}};return console.log(`[CropperView] 💾 Guardando estado del crop ${G}:`,l),K(e=>e.map((e,t)=>t===G?{...e,savedState:l}:e)),l}catch(e){return console.warn("Error saving crop state:",e),null}},[ce.manager,de.isReady,ye,A,G,fe,ge]),Re=y.useCallback(e=>{const t=H[e];if(!t||!t.savedState)return console.log(`[CropperView] ℹ️ No hay estado guardado para crop ${e}, centrando...`),void setTimeout(()=>{_e(),setTimeout(()=>Te(),100)},100);if(ce.manager&&de.isReady)try{const{savedState:n}=t;if(console.log(`[CropperView] ♻️ Restaurando estado del crop ${e}:`,n),n.imageTransform&&fe.current&&Array.isArray(n.imageTransform)&&setTimeout(()=>{if(fe.current&&fe.current.$setTransform){const[e,t,l,r,a,i]=n.imageTransform;fe.current.$setTransform(e,t,l,r,a,i),console.log(`[CropperView] ✅ Imagen restaurada: transform(${e.toFixed(2)}, ${t.toFixed(2)}, ${l.toFixed(2)}, ${r.toFixed(2)}, ${a.toFixed(0)}, ${i.toFixed(0)})`)}},100),n.selectorState&&ge.current){const{x:e,y:t,width:l,height:r}=n.selectorState;setTimeout(()=>{ge.current&&(ge.current.x=e,ge.current.y=t,ge.current.width=l,ge.current.height=r,ge.current.$render&&ge.current.$render(),console.log(`[CropperView] ✅ Selector restaurado: ${l}×${r} en (${e}, ${t})`))},150)}n.flipState&&M({horizontal:n.flipState.horizontal??!1,vertical:n.flipState.vertical??!1}),console.log("[CropperView] ✨ Estado restaurado completamente")}catch(n){console.error("Error restoring crop state:",n),setTimeout(()=>{_e(),setTimeout(()=>Te(),100)},100)}else console.warn("Cropper not ready for state restoration")},[H,ce.manager,de.isReady,_e,Te,ge,fe]),Ue=y.useCallback(()=>{for(let e=0;e<H.length;e++){const t=H[e];if(!t.label||""===t.label.trim())return e}return-1},[H]),Be=y.useCallback(async e=>{e!==G&&(L(!0),Oe(),await new Promise(e=>setTimeout(e,100)),Q(e),await new Promise(e=>setTimeout(e,250)),Re(e),await new Promise(e=>setTimeout(e,200)),L(!1))},[G,Oe,Re]),We=y.useCallback(()=>{if(!V.allowCustomCrops)return void alert("No se pueden añadir recortes personalizados en este modo.");const t={id:`crop-custom-${Date.now()}`,label:`Recorte ${H.length+1}`,width:e.width||1920,height:e.height||1080,required:!1,isCustom:!0,confirmed:!1,savedState:null};K(e=>[...e,t]),ae?.announce(`Nuevo recorte personalizado añadido: ${t.label}. Selecciónalo para editarlo.`)},[V.allowCustomCrops,H.length,e.width,e.height,ae]),qe=y.useCallback((e,t)=>{const n=parseInt(t,10);""===t||isNaN(n)||K(t=>t.map((t,l)=>l===G?{...t,[e]:n}:t))},[G]),Ve=y.useCallback(e=>{const t=X[e];let n=100;if(pe.current&&ve){const e=pe.current.getBoundingClientRect(),t=Math.min(e.width,e.height);n=Math.max(100,Math.round(.05*t))}const l=Math.max(n,Math.min(5e3,t));l!==t&&K(t=>t.map((t,n)=>n===G?{...t,[e]:l}:t));const r={...X,[e]:l},a=r.width/r.height,i=me.getData?.();me.setAspectRatio(a),i&&void 0!==i.x&&setTimeout(()=>{me.set?.(i.x,i.y,i.width,i.height)},50)},[G,X,me,pe,ve]),He=y.useCallback(e=>{K(t=>t.map((t,n)=>n===G?{...t,label:e}:t))},[G]),Ke=y.useCallback((e,t=null)=>{t=t||H[e].label;if(!window.confirm(`¿Estás seguro de que deseas eliminar "${t||"este recorte"}"? Esta acción también eliminará todos sus recortes.`))return;const n=H[e];if(n.required)alert("No se puede eliminar un recorte obligatorio.");else if(1!==H.length){if(K(t=>t.filter((t,n)=>n!==e)),e===G){const t=Math.max(0,e-1);Q(t)}else e<G&&Q(e=>e-1);ae?.announce(`Recorte ${n.label} eliminado`)}else alert("Debe haber al menos un recorte.")},[H,G,ae]),Ge=y.useCallback(async()=>{if(!xe)return null;try{const t=await me.toCanvas({width:800,height:600,imageSmoothingEnabled:!0,imageSmoothingQuality:"high"});return t?t.toDataURL(`image/${globalThis.downloadFormat||e.mime_type.split("/")[1]||"webp"}`,.9):null}catch(t){return console.warn("Error generating preview:",t),null}},[xe,e.mime_type,me]),Qe=y.useCallback(async()=>{if(u)return d(!1),m(null),void p(!1);if(xe){d(!0),p(!0);try{const e=await Ge();e?m(e):(d(!1),alert("No se puede exportar el recorte por restricciones de CORS en la imagen original."))}finally{p(!1)}}else alert("No se puede exportar el recorte por restricciones de CORS en la imagen original.")},[xe,Ge,u]),Xe=y.useCallback(e=>{e.target.closest(".limbo-preview-modal-header")&&(S(!0),N({x:e.clientX-w.x,y:e.clientY-w.y}))},[w]),Ye=y.useCallback(e=>{C&&(e.preventDefault(),k({x:e.clientX-j.x,y:e.clientY-j.y}))},[C,j]),Je=y.useCallback(()=>{S(!1)},[]),Ze=y.useCallback(e=>{if(!e.target.closest(".limbo-preview-modal-header"))return;const t=e.touches[0];S(!0),N({x:t.clientX-w.x,y:t.clientY-w.y})},[w]),et=y.useCallback(e=>{if(!C)return;e.preventDefault();const t=e.touches[0];k({x:t.clientX-j.x,y:t.clientY-j.y})},[C,j]),nt=y.useCallback(()=>{S(!1)},[]);y.useEffect(()=>{if(C)return document.addEventListener("mousemove",Ye),document.addEventListener("mouseup",Je),document.addEventListener("touchmove",et,{passive:!1}),document.addEventListener("touchend",nt),()=>{document.removeEventListener("mousemove",Ye),document.removeEventListener("mouseup",Je),document.removeEventListener("touchmove",et),document.removeEventListener("touchend",nt)}},[C,Ye,Je,et,nt]),y.useEffect(()=>{if(!E)return;const e=e=>{"Escape"===e.key&&$(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[E]);const lt=y.useCallback(async(t,n=null)=>{const l=H[t];if(!l)throw new Error(`Crop ${t} no encontrado`);if(!l.savedState&&t!==G)throw new Error(`El recorte "${l.label}" aún no ha sido configurado`);const r={index:G,imageTransform:fe.current?.$getTransform?.(),selectorState:ge.current?{x:ge.current.x,y:ge.current.y,width:ge.current.width,height:ge.current.height}:null};try{if(t!==G&&l.savedState){if(console.log(`[CropperView] 🔄 Restaurando temporalmente crop ${t} para guardado...`),l.savedState.imageTransform&&fe.current?.$setTransform){const[e,t,n,r,a,i]=l.savedState.imageTransform;fe.current.$setTransform(e,t,n,r,a,i)}if(l.savedState.selectorState&&ge.current){const{x:e,y:t,width:n,height:r}=l.savedState.selectorState;ge.current.x=e,ge.current.y=t,ge.current.width=n,ge.current.height=r,ge.current.$render?.()}await new Promise(e=>setTimeout(e,100))}const r=Math.min(l.width,5e3),s=Math.min(l.height,5e3),c=await me.toCanvas({width:r,height:s,imageSmoothingEnabled:!0,imageSmoothingQuality:"high"});if(!c)throw new Error(`No se pudo generar el canvas para "${l.label}"`);const u=l.format||globalThis.downloadFormat||"webp",d="webp"===u?"image/webp":"png"===u?"image/png":"image/jpeg",b=.9,m=await new Promise((e,t)=>{c.toBlob(n=>{n?e(n):t(new Error("No se pudo convertir el canvas a blob"))},d,b)});console.log("[CropperView] Canvas convertido a blob:",{size:m.size,type:m.type,dimensions:`${r}x${s}`});const h=`${l.label||"crop"}_${r}_${s}`,p=n||e.id,f=!p||"string"==typeof p&&p.startsWith("external"),g=(f||V.localCropsOnly)&&!o;if(f&&o&&!V.localCropsOnly){console.log("[CropperView] 📤 Imagen externa con onUpload disponible, subiendo crop como nuevo asset...");try{const e=new File([m],`${h}.${u}`,{type:d}),t=await o(e);if(t&&(t.id||t.url)){console.log("[CropperView] ✅ Crop subido exitosamente:",t);const e=l.savedState||{selectorState:ge.current?{x:ge.current.x,y:ge.current.y,width:ge.current.width,height:ge.current.height}:null,imageTransform:fe.current?.$getTransform?.()||null,flipState:{horizontal:A.horizontal,vertical:A.vertical}},n={id:t.id||`uploaded-${Date.now()}`,name:h,filename:`${h}.${u}`,url:t.urlSigned||t.url,urlSigned:t.urlSigned||t.url,width:r,height:s,format:u,size:m.size,mime_type:d,isLocal:!1,originalAssetId:null,uploadedAssetId:t.id,cropState:e};return ae?.announceSuccess(`Recorte guardado: ${h}`),n}}catch(a){console.error("[CropperView] ❌ Error subiendo crop, fallback a local:",a)}}if(g){console.log(`[CropperView] 🌐 Generando resultado local (isExternal: ${f}, localCropsOnly: ${V.localCropsOnly})`);const e=URL.createObjectURL(m),t=l.savedState||{selectorState:ge.current?{x:ge.current.x,y:ge.current.y,width:ge.current.width,height:ge.current.height}:null,imageTransform:fe.current?.$getTransform?.()||null,flipState:{horizontal:A.horizontal,vertical:A.vertical}},n={id:`local-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:h,filename:`${h}.${u}`,url:e,urlSigned:e,width:r,height:s,format:u,size:m.size,mime_type:d,blob:m,isLocal:!0,originalAssetId:p||null,cropState:t};return ae?.announceSuccess(`Recorte creado localmente: ${h}`),n}const y=l.savedState||{selectorState:ge.current?{x:ge.current.x,y:ge.current.y,width:ge.current.width,height:ge.current.height}:null,imageTransform:fe.current?.$getTransform?.()||null,flipState:{horizontal:A.horizontal,vertical:A.vertical}},v=await ie(p,m,{name:h,width:r,height:s,format:u});if(v)return v.cropState=y,ae?.announceSuccess(`Recorte creado: ${h}`),i?.(p,v),v;throw new Error("No se pudo crear la variante")}finally{if(t!==G&&r.imageTransform&&fe.current?.$setTransform){console.log(`[CropperView] ↩️ Restaurando estado original del crop ${r.index}...`);const[e,t,n,l,a,i]=r.imageTransform;if(fe.current.$setTransform(e,t,n,l,a,i),r.selectorState&&ge.current){const{x:e,y:t,width:n,height:l}=r.selectorState;ge.current.x=e,ge.current.y=t,ge.current.width=n,ge.current.height=l,ge.current.$render?.()}}}},[H,G,me,ie,e.id,i,ae,fe,ge]),rt=y.useCallback(async()=>{if(!xe){const e="No se puede exportar el recorte por restricciones de CORS en la imagen original.";return ae?.announceError(e),void alert(e)}if(!de.isReady){const e="El cropper aún no está inicializado. Espera un momento e inténtalo de nuevo.";return ae?.announceError(e),void alert(e)}Oe(),ae?.announce("Creando recorte de la imagen");try{let n=e.id,l=null;if(e.file&&o){ae?.announce("Subiendo imagen...");const t=await o(e.file);if(!t||!t.id)throw new Error("No se pudo subir la imagen al servidor");n=t.id,l=t,ae?.announceSuccess("Imagen subida correctamente")}const r=await lt(G,n);r&&t(l?{crops:[r],asset:l}:r)}catch(n){console.warn("Error creating crop variant:",n);const e=n.message||"No se pudo crear el recorte. Inténtalo de nuevo.";ae?.announceError(e),alert(e),r?.(n)}},[xe,de.isReady,ae,Oe,lt,G,t,r,e.file,e.id,o]),at=y.useCallback(async n=>{Oe(),ae?.announce(`Guardando ${n.length} recortes...`);try{let r=e.id,a=null;if(e.file&&o){ae?.announce("Subiendo imagen...");const t=await o(e.file);if(!t||!t.id)throw new Error("No se pudo subir la imagen al servidor");r=t.id,a=t,ae?.announceSuccess("Imagen subida correctamente")}const i=[],s=[];for(const e of n)try{const t=await lt(e,r);t&&i.push(t)}catch(l){s.push({crop:H[e]?.label||`Crop ${e}`,error:l.message})}if(i.length>0&&(ae?.announceSuccess(`${i.length} recorte(s) guardado(s) correctamente`),t(a?{crops:i,asset:a}:i)),s.length>0){const e=`Errores al guardar algunos recortes:\n${s.map(e=>`- ${e.crop}: ${e.error}`).join("\n")}`;ae?.announceError(e),alert(e)}}catch(l){const e=l.message||"Error al procesar los recortes";ae?.announceError(e),alert(e),r?.(l)}},[Oe,lt,H,ae,t,e.file,e.id,o,r]),it=y.useCallback(async()=>{const e=Ue();if(-1!==e){const t=H[e];return alert(`El recorte "${t.label||t||"(sin nombre)"}" debe tener un nombre válido.`),void Q(e)}const t=H.findIndex((e,t)=>e.required&&!e.savedState&&t!==G);if(-1!==t){const e=H[t];return alert(`El recorte obligatorio "${e.label}" aún no ha sido configurado.\n\nPor favor, configura todos los recortes obligatorios antes de guardar.`),Q(t),void ae?.announce(`Recorte obligatorio "${e.label}" sin configurar. Por favor, configúralo.`,"assertive")}if(H.length>1){re("save");const e=H.map((e,t)=>({crop:e,index:t})).filter(({crop:e,index:t})=>e.required||e.savedState||t===G).map(({index:e})=>e);return ne(e),void ee(!0)}await rt()},[Ue,H,rt,G,ae]),ot=y.useCallback(async t=>{const n=H[t];if(!n)throw new Error(`Crop ${t} no encontrado`);if(!n.savedState&&t!==G)throw new Error(`El recorte "${n.label}" aún no ha sido configurado`);const l={index:G,imageTransform:fe.current?.$getTransform?.(),selectorState:ge.current?{x:ge.current.x,y:ge.current.y,width:ge.current.width,height:ge.current.height}:null};try{if(t!==G&&n.savedState){if(console.log(`[CropperView] 🔄 Restaurando temporalmente crop ${t} para descarga...`),n.savedState.imageTransform&&fe.current?.$setTransform){const[e,t,l,r,a,i]=n.savedState.imageTransform;fe.current.$setTransform(e,t,l,r,a,i)}if(n.savedState.selectorState&&ge.current){const{x:e,y:t,width:l,height:r}=n.savedState.selectorState;ge.current.x=e,ge.current.y=t,ge.current.width=l,ge.current.height=r,ge.current.$render?.()}await new Promise(e=>setTimeout(e,100))}const l=await me.toCanvas({width:n.width,height:n.height,imageSmoothingEnabled:!0,imageSmoothingQuality:"high"});if(!l)throw new Error(`No se pudo generar el canvas para "${n.label}"`);const r=l.toDataURL(`image/${globalThis.downloadFormat||e.mime_type.split("/")[1]||"webp"}`,.9),a=`${(n.label||"crop").replace(/\.[^/.]+$/,"").replace(/\s+/g,"-").trim()}_${n.width}_${n.height}`;return await Jn(r,a,{accessibilityManager:ae,onSuccess:e=>{console.log(`✅ Descargado: ${e}`)},onError:e=>{throw new Error(`Error al descargar "${n.label}": ${e.message}`)}}),{crop:n.label,filename:a}}finally{if(t!==G&&l.imageTransform&&fe.current?.$setTransform){console.log(`[CropperView] ↩️ Restaurando estado original del crop ${l.index}...`);const[e,t,n,r,a,i]=l.imageTransform;if(fe.current.$setTransform(e,t,n,r,a,i),l.selectorState&&ge.current){const{x:e,y:t,width:n,height:r}=l.selectorState;ge.current.x=e,ge.current.y=t,ge.current.width=n,ge.current.height=r,ge.current.$render?.()}}}},[H,G,me,e.mime_type,ae,fe,ge]),st=y.useCallback(async e=>{Oe(),ae?.announce(`Descargando ${e.length} recortes...`);const t=[],n=[];for(const r of e)try{const e=await ot(r);e&&t.push(e)}catch(l){n.push({crop:H[r]?.label||`Crop ${r}`,error:l.message})}if(t.length>0&&ae?.announceSuccess(`${t.length} recorte(s) descargado(s) correctamente`),n.length>0){const e=`Errores al descargar algunos recortes:\n${n.map(e=>`- ${e.crop}: ${e.error}`).join("\n")}`;ae?.announceError(e),alert(e)}},[Oe,ot,H,ae]),ct=y.useCallback(async()=>{if(!xe){const e="No se puede descargar el recorte por restricciones de CORS en la imagen original.";return ae?.announceError(e),void alert(e)}Oe(),ae?.announce("Preparando descarga del recorte");try{await ot(G),ae?.announceSuccess("Recorte descargado correctamente")}catch(e){console.error("Error downloading crop:",e);const t=e.message||"Error al descargar el recorte";ae?.announceError(t),alert(t)}},[xe,ae,Oe,ot,G]),ut=y.useCallback(async()=>{const e=Ue();if(-1!==e){const t=H[e];return alert(`El recorte "${t.label||t||"(sin nombre)"}" debe tener un nombre válido.`),void Q(e)}if(H.length>1){re("download");const e=H.map((e,t)=>({crop:e,index:t})).filter(({crop:e,index:t})=>e.savedState||t===G).map(({index:e})=>e);return ne(e),void ee(!0)}await ct()},[Ue,H,ct,G]),dt=y.useMemo(()=>!!e.file||(!e.id||!("string"!=typeof e.id||!e.id.startsWith("external"))),[e.file,e.id]),bt=y.useCallback(async()=>{try{if(e.file&&o){ae?.announce("Subiendo imagen original...");const n=await o(e.file);if(!n||!n.id)throw new Error("No se pudo subir la imagen al servidor");return ae?.announceSuccess("Imagen guardada correctamente"),void t({asset:n,crops:[]})}if(dt){ae?.announce("Conservando imagen original...");const n={id:`local-original-${Date.now()}`,name:e.filename||"original",filename:e.filename||"image.jpg",url:e.url,urlSigned:e.url,width:e.width||ve?.naturalWidth||1920,height:e.height||ve?.naturalHeight||1080,mime_type:e.mime_type||"image/jpeg",isLocal:!0,isOriginal:!0};return ae?.announceSuccess("Imagen original conservada"),void t({crops:[n]})}if(e.id&&!e.id.startsWith("external")){ae?.announce("Seleccionando imagen original...");const n={id:e.id,name:e.filename||"original",filename:e.filename||"image.jpg",url:e.url,urlSigned:e.urlSigned||e.url,width:e.width||ve?.naturalWidth||1920,height:e.height||ve?.naturalHeight||1080,mime_type:e.mime_type||"image/jpeg",isOriginal:!0};return ae?.announceSuccess("Imagen original seleccionada"),void t({crops:[n],assetId:e.id})}n()}catch(l){console.error("Error guardando imagen original:",l);const e=l.message||"No se pudo guardar la imagen. Inténtalo de nuevo.";ae?.announceError(e),alert(e),r?.(l)}},[e,ve,o,n,t,r,ae,dt]);return y.useEffect(()=>{d(!1),m(null)},[e]),y.useEffect(()=>{if(!ce.manager||!de.isReady||!_)return;console.log("[CropperView] Carga inicial completada, centrando imagen y selector...");const e=V.existingCrops?.[0],t=e?.cropState;setTimeout(()=>{_e(),setTimeout(()=>{if(t){if(console.log("[CropperView] 🔄 Restaurando estado del crop existente:",t),t.imageTransform&&fe.current?.$setTransform){const[e,n,l,r,a,i]=t.imageTransform;fe.current.$setTransform(e,n,l,r,a,i),console.log("[CropperView] ✅ Transformación de imagen restaurada")}if(t.selectorState&&ge.current){const{x:e,y:n,width:l,height:r}=t.selectorState;ge.current.x=e,ge.current.y=n,ge.current.width=l,ge.current.height=r,ge.current.$render?.(),console.log("[CropperView] ✅ Posición del selector restaurada:",t.selectorState)}t.flipState&&(M(t.flipState),console.log("[CropperView] ✅ Estado de flip restaurado:",t.flipState))}else Te();T(!1),console.log("[CropperView] Carga inicial finalizada")},100)},50)},[ce.manager,de.isReady,_,_e,Te,V.existingCrops]),y.useEffect(()=>{ce.manager&&de.isReady&&(Y&&me.setAspectRatio(Y),he.setBackground(v))},[Y,v,ce.manager,de.isReady,me,he]),y.useEffect(()=>{if(!ve||!de.isReady||V.mandatoryCrops.length>0)return;const e=H[0];if(e&&"crop-default-0"===e.id&&(1920===e.width||1080===e.height)){const t=Math.min(ve.naturalWidth,5e3),n=Math.min(ve.naturalHeight,5e3);K([{...e,width:t,height:n}]),console.log(`[CropperView] Crop por defecto actualizado a ${t}×${n}px`)}},[ve,de.isReady,V.mandatoryCrops.length,H]),y.useEffect(()=>{if(!u||!xe)return;const e=setTimeout(async()=>{p(e=>!b&&!e||e);try{const e=await Ge();e&&m(e)}finally{p(!1)}},300);return()=>{clearTimeout(e),p(!1)}},[ye,we,u,xe,Ge,Y,A,b]),y.useEffect(()=>{const e=pe.current,t=t=>{if("Delete"===t.key||"Backspace"===t.key||"Backspace"===t.key&&t.metaKey||"Backspace"===t.key&&t.ctrlKey){const n=t.target;if(e&&(n===e||n===document.body||n===document.documentElement||"CROPPER-CANVAS"===n.tagName||"CROPPER-SELECTION"===n.tagName||"CROPPER-IMAGE"===n.tagName||"CROPPER-HANDLE"===n.tagName||"CROPPER-GRID"===n.tagName||n.closest("cropper-canvas")||e.contains(n)))return t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),!1}};return document.addEventListener("keydown",t,!0),document.addEventListener("keyup",t,!0),window.addEventListener("keydown",t,!0),e&&e.addEventListener("keydown",t,!0),()=>{document.removeEventListener("keydown",t,!0),document.removeEventListener("keyup",t,!0),window.removeEventListener("keydown",t,!0),e&&e.removeEventListener("keydown",t,!0)}},[pe]),e?F.jsxs("div",{className:"limbo-cropper-view lb:px-2 lb:border-2 lb:border-gray-200/50 lb:rounded-lg lb:max-w-7xl lb:mx-auto lb:w-full lb:min-w-full lb:h-full lb:min-h-full lb:flex lb:flex-col",children:[F.jsxs("div",{className:"limbo-cropper-header lb:flex lb:flex-row lb:justify-between lb:items-start lb:flex-wrap lb:mx-2 lb:py-2 lb:border-b lb:border-gray-200 lb:bg-white lb:z-10 lb:shrink-0 lb:lg:gap-2",children:[F.jsxs("div",{className:"lb:flex-1 lb:min-w-fit lb:space-y-2 lb:max-w-fit",children:[F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2",children:[F.jsx("h2",{className:"lb:text-lg lb:sm:text-xl lb:font-extrabold lb:text-gray-800",children:"Generar recortes"}),H.length>1&&F.jsx("span",{className:"lb:px-2 lb:py-0.5 lb:bg-blue-100 lb:text-blue-800 lb:text-xs lb:font-semibold lb:rounded",children:X.label})]}),F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2",children:[F.jsx("label",{className:"lb:text-xs lb:text-gray-500 lb:whitespace-nowrap lb:w-fit",children:"Nombre:"}),F.jsx("div",{className:"",children:q+"."+(globalThis.downloadFormat||e.mime_type.split("/")[1]||"webp")})]})]}),F.jsxs("div",{className:"lb:flex lb:flex-row lb:self-end lb:gap-2 lb:w-full lb:max-w-fit lb:sm:w-auto lb:flex-wrap",children:[F.jsxs("button",{onClick:()=>{window.confirm("Si cancelas, perderás todos los cambios realizados. ¿Deseas continuar?")&&n()},disabled:oe,className:"lb:flex lb:flex-row lb:items-center lb:gap-1 lb:self-end lb:w-full lb:max-w-fit lb:sm:w-auto lb:px-3 lb:cursor-pointer lb:py-1.5 lb:text-sm lb:rounded lb:bg-neutral-gray-500 lb:hover:bg-neutral-gray-700 lb:transition-colors lb:text-white lb:disabled:opacity-50 lb:disabled:cursor-not-allowed","aria-label":"Cancelar y volver",title:"Cancelar y volver",children:[F.jsx("span",{className:"icon icon-arrow-left-white icon--sm lb:m-0 lb:p-0"})," ","Cancelar"]}),l&&F.jsxs("button",{onClick:()=>l(e),disabled:a|oe,className:"lb:flex lb:flex-row lb:items-center lb:gap-1 lb:self-end lb:w-full lb:max-w-fit lb:sm:w-auto lb:px-3 lb:cursor-pointer lb:py-1.5 lb:text-sm lb:rounded lb:bg-red-800 lb:hover:bg-red-1000 lb:transition-colors lb:text-white lb:disabled:opacity-50 lb:disabled:cursor-not-allowed","aria-label":`Eliminar imagen ${e.filename}`,title:`Eliminar imagen ${e.filename}`,children:[F.jsx("span",{className:"icon icon-close-small-white icon--sm lb:m-0 lb:p-0"}),a?"Eliminando...":"Eliminar"]})]})]}),F.jsxs("div",{className:"limbo-cropper-status lb:bg-white lb:border-gray-100 lb:py-0 lb:pb-0 lb:flex-shrink-0",children:[se&&F.jsxs(Fe,{variant:"danger",className:"lb:mb-2 lb:text-sm",children:[F.jsx("strong",{children:"Error:"})," ",se]}),ve&&F.jsxs(Fe,{variant:"info",className:"lb:mb-2 lb:text-sm",role:"status",children:[F.jsx("strong",{children:"Original:"})," ",ve.naturalWidth," ×"," ",ve.naturalHeight," px",ve.currentWidth!==ve.naturalWidth&&F.jsxs("span",{className:"lb:ml-2 lb:sm:ml-3 lb:text-xs lb:block lb:sm:inline",children:["(Mostrada: ",Math.round(ve.currentWidth)," ×"," ",Math.round(ve.currentHeight)," px)"]})]}),!xe&&F.jsx(Fe,{variant:"warning",className:"lb:mb-2 lb:text-sm",children:"No se puede exportar por restricciones CORS"}),F.jsxs("div",{className:"lb:bg-white lb:border-b lb:border-gray-200 lb:py-2 lb:mx-2 lb:shrink-0 lb:sticky lb:top-0 lb:z-10 lb:mb-1",children:[F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between lb:mb-2",children:[F.jsxs("h3",{className:"lb:text-sm lb:font-semibold lb:text-gray-700",children:["Recortes ",H.length>1&&`(${H.length})`]}),V.allowCustomCrops&&F.jsxs("button",{onClick:We,disabled:oe,className:"lb:text-xs lb:cursor-pointer lb:px-2 lb:py-1 lb:bg-brand-blue-50 lb:hover:bg-brand-blue-200 lb:text-brand-blue-1000 lb:rounded lb:border lb:border-brand-blue-200 lb:transition-colors lb:flex lb:items-center lb:gap-1",title:"Añadir recorte personalizado",children:[F.jsx("span",{className:"icon icon-add icon--sm",style:{filter:"var(--limbo-icon-blue)"}}),"Añadir recorte"]})]}),F.jsx("div",{className:"lb:grid lb:grid-cols-2 lb:md:grid-cols-3 lb:lg:grid-cols-4 lb:xl:grid-cols-5 lb:gap-1.5 lb:max-h-48 lb:overflow-y-auto",children:H.map((e,t)=>{const n=e.savedState||t===G;return F.jsxs("label",{className:"lb:h-fit lb:flex lb:flex-col lb:p-1.5 lb:rounded lb:border lb:cursor-pointer lb:transition-colors lb:min-h-17.5 lb:w-full "+(G===t?"lb:bg-blue-50 lb:border-blue-300":n?"lb:bg-gray-50 lb:border-gray-200 lb:hover:bg-gray-100":"lb:bg-orange-50 lb:border-orange-300 lb:hover:bg-orange-100"),children:[F.jsx("input",{type:"radio",name:"active-crop",checked:G===t,onChange:()=>Be(t),disabled:oe,className:"lb:hidden"}),F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-1 lb:mb-1",children:[F.jsx("div",{className:"lb:flex-1 lb:min-w-0",children:F.jsxs("div",{className:"lb:flex lb:flex-wrap lb:items-center lb:gap-1 lb:min-h-",children:[G!==t||e.required?F.jsx("span",{className:"lb:text-xs lb:font-medium lb:text-gray-800 lb:truncate",children:e.label}):F.jsx("input",{type:"text",value:e.label,onChange:e=>He(e.target.value),disabled:oe,className:"lb:w-full lb:max-h-fit lb:text-xs lb:px-1 lb:py-0.5 lb:border lb:border-gray-300 lb:rounded lb:focus:outline-none lb:focus:ring-1 lb:focus:ring-blue-500 lb:h-1",placeholder:"Nombre",maxLength:25,onClick:e=>e.stopPropagation()}),e.required&&F.jsx("span",{className:"lb:text-[10px] lb:px-1 lb:py-0.5 lb:bg-red-200 lb:text-red-1000 lb:rounded lb:whitespace-nowrap lb:truncate",children:"Obligatorio"})]})}),!e.required&&H.length>1&&F.jsx("button",{onClick:n=>{n.preventDefault(),n.stopPropagation(),Ke(t,e.label)},className:"lb:shrink-0 lb:hover:bg-red-500/70 lb:text-red-1000 lb:p-1 lb:rounded lb:max-h-fit lb:aspect-square lb:cursor-pointer lb:flex",title:"Eliminar",children:F.jsx("span",{className:"icon icon-close-small icon--xs"})})]}),F.jsx("div",{className:"lb:flex lb:items-center lb:gap-1 lb:mt-auto",children:G===t?F.jsxs(F.Fragment,{children:[F.jsx("input",{type:"number",min:"100",max:"5000",value:e.width,onChange:e=>qe("width",e.target.value),onBlur:()=>Ve("width"),disabled:oe||e.lockDimensions,className:"lb:max-h-fit lb:flex-1 lb:text-xs lb:px-1 lb:py-0.5 lb:border lb:rounded lb:focus:outline-none lb:focus:ring-1 lb:focus:ring-blue-500 "+(e.lockDimensions?"lb:border-gray-200 lb:bg-gray-100 lb:text-gray-500 lb:cursor-not-allowed":"lb:border-gray-300"),placeholder:"W",onClick:e=>e.stopPropagation(),title:e.lockDimensions?"Dimensiones bloqueadas (recorte obligatorio)":"Ancho en píxeles"}),F.jsx("span",{className:"lb:text-gray-400 lb:text-xs",children:"×"}),F.jsx("input",{type:"number",min:"100",max:"5000",value:e.height,onChange:e=>qe("height",e.target.value),onBlur:()=>Ve("height"),disabled:oe||e.lockDimensions,className:"lb:max-h-fit lb:flex-1 lb:text-xs lb:px-1 lb:py-0.5 lb:border lb:rounded lb:focus:outline-none lb:focus:ring-1 lb:focus:ring-blue-500 "+(e.lockDimensions?"lb:border-gray-200 lb:bg-gray-100 lb:text-gray-500 lb:cursor-not-allowed":"lb:border-gray-300"),placeholder:"H",onClick:e=>e.stopPropagation(),title:e.lockDimensions?"Dimensiones bloqueadas (recorte obligatorio)":"Alto en píxeles"})]}):F.jsxs("span",{className:"lb:text-xs lb:text-gray-500",children:[e.width," × ",e.height," px"]})}),!n&&F.jsx("div",{className:"lb:text-xs lb:px-1 lb:py-0.5 lb:bg-orange-300 lb:text-neutral-gray-25 lb:text-shadow-xs lb:font-semibold lb:rounded lb:text-center lb:mt-1",children:"Sin configurar"})]},e.id)})})]})]}),F.jsxs("div",{className:"lb:flex lb:flex-col lb:lg:flex-row lb:flex-1 lb:w-full lb:overflow-hidden lb:lg:max-h-130 lb:mx-2 lb:py-1",children:[F.jsx("div",{className:"lb:relative lb:flex-1 lg:flex-2 lb:h-full lb:shrink-0 lb:grow-1 lb:order-0 lb:min-h-100 lb:lg:min-h-130",children:F.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-white lb:rounded-lg lb:border-2 lb:border-gray-200 lb:overflow-hidden",children:[F.jsx(tt,{show:_,message:"Cargando recortador..."}),F.jsx(tt,{show:z,message:`Cambiando a: ${H[G]?.label||"recorte"}...`}),F.jsxs("cropper-canvas",{ref:pe,style:{width:"100%",height:"100%",display:"block"},background:!!v||void 0,id:"limbo-cropperjs-canvas",tabindex:"-1",onKeyDown:e=>{"Delete"!==e.key&&"Backspace"!==e.key||(e.preventDefault(),e.stopPropagation())},children:[F.jsx("cropper-image",{ref:fe,src:e.url||e.path,alt:e.filename,id:"limbo-cropperjs-image",action:"move",crossOrigin:"anonymous",rotatable:!0,scalable:!0,skewable:!0,translatable:!0}),F.jsxs("cropper-selection",{ref:ge,"initial-coverage":"0.5",movable:!0,resizable:!0,keyboard:"true",action:"move",style:{cursor:"move",minWidth:`${J.minWidth}px`,minHeight:`${J.minHeight}px`},"data-prevent-delete":"true",tabindex:"-1",children:[f&&F.jsx("cropper-grid",{role:"grid",action:"move",covered:!0,bordered:!0}),F.jsx("cropper-handle",{action:"move",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"32px",height:"32px",zIndex:"10"}}),F.jsx("cropper-handle",{action:"n-resize"}),F.jsx("cropper-handle",{action:"e-resize"}),F.jsx("cropper-handle",{action:"s-resize"}),F.jsx("cropper-handle",{action:"w-resize"}),F.jsx("cropper-handle",{action:"ne-resize"}),F.jsx("cropper-handle",{action:"nw-resize"}),F.jsx("cropper-handle",{action:"se-resize"}),F.jsx("cropper-handle",{action:"sw-resize"})]})]})]})}),F.jsx("div",{className:"lb:w-full lb:lg:max-w-80 lb:mt-2 lb:lg:my-0 lb:overflow-y-auto lb:bg-white lb:border-t lb:lg:border-t-0 lb:lg:border-l lb:border-gray-200 lb:shrink-0",children:F.jsxs("div",{className:"lb:h-full lb:mt-2 lb:lg:my-0 lb:me-2 lb:lg:mx-2 lb:space-y-2 lb:grid lb:grid-cols-2 lb:md:grid-cols-3 lb:flex-wrap lb:md:flex-nowrap lb:items-start lb:flex-row lb:gap-2 lb:lg:gap-0 lb:lg:block",children:[F.jsxs("div",{className:"lb:bg-white lb:rounded lb:border lb:w-full lb:border-gray-200 lb:mb-2",children:[F.jsx("button",{onClick:$e,className:"lb:hidden lb:sm:block lb:w-full lb:p-2 lb:mb-05 lb:cursor-pointer lb:hover:bg-neutral-gray-050/50 lb:transition-colors lb:rounded-t-sm","aria-expanded":B,"aria-label":"Mostrar/ocultar opciones de visualización",children:F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between",children:[F.jsx("h3",{className:"lb:text-sm lb:font-semibold lb:text-gray-700",children:"Transformar imagen"}),F.jsx("div",{className:"lb:text-center",children:F.jsx("span",{className:`icon ${B?"icon-chevron-up":"icon-chevron-down"} lb:text-center icon--xs`})})]})}),F.jsxs("div",{className:"lb:p-2 lb:space-y-2 lb:justify-items-stretch lb:static "+(B?"lb:block":"lb:sm:hidden"),children:[F.jsx("div",{className:"lb:mb-3 lb:block",children:F.jsxs("div",{className:"lb:grid lb:grid-cols-5 lb:gap-1 lb:content-center lb:h-fit lb:mx-auto",children:[F.jsx("button",{onClick:()=>Ae(-.2),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Alejar",disabled:oe,"aria-label":"Alejar imagen",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-zoom-out-blue"})})}),F.jsx("button",{onClick:()=>Le(-10,-10),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover arriba-izquierda",disabled:oe,"aria-label":"Mover imagen hacia arriba-izquierda",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-arrow-up-blue icon--md lb:-rotate-45"})})}),F.jsx("button",{onClick:()=>Le(0,-10),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover arriba",disabled:oe,"aria-label":"Mover imagen hacia arriba",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-arrow-up-blue icon--md"})})}),F.jsx("button",{onClick:()=>Le(10,-10),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover arriba-derecha",disabled:oe,"aria-label":"Mover imagen hacia arriba-derecha",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-arrow-up-blue icon--md lb:rotate-45"})})}),F.jsx("button",{onClick:()=>Ae(.2),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Acercar 20%",disabled:oe,"aria-label":"Acercar imagen",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-zoom-in-blue"})})}),F.jsx("button",{onClick:()=>Me(-45),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Rotar -45°",disabled:oe,"aria-label":"Rotar imagen 45 grados a la izquierda",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"lb:text-brand-blue-1000 lb:font-medium",children:"-45°"})})}),F.jsx("button",{onClick:()=>Le(-10,0),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover izquierda",disabled:oe,"aria-label":"Mover imagen hacia la izquierda",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-arrow-left-blue"})})}),F.jsx("button",{onClick:_e,className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Centrar y ajustar imagen",disabled:oe,"aria-label":"Centrar y ajustar imagen",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-radio-button-blue icon-md"})})}),F.jsx("button",{onClick:()=>Le(10,0),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover derecha",disabled:oe,"aria-label":"Mover imagen hacia la derecha",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-arrow-right-blue"})})}),F.jsx("button",{onClick:()=>Me(45),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Rotar +45°",disabled:oe,"aria-label":"Rotar imagen 45 grados a la derecha",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"lb:text-brand-blue-1000 lb:font-medium",children:"+45°"})})}),F.jsx("button",{onClick:Ie,className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:aspect-square "+(A.horizontal?"lb:bg-blue-100 lb:border lb:border-blue-300 lb:text-blue-800":"lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200"),title:"Voltear horizontalmente "+(A.horizontal?"(activo)":""),disabled:oe,"aria-label":"Voltear imagen horizontalmente","aria-pressed":A.horizontal,children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center lb:gap-2",children:F.jsx("span",{className:"icon icon-arrow-left-right-blue lb:border lb:border-brand-blue-1000 lb:rounded"})})}),F.jsx("button",{onClick:()=>Le(-10,10),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover abajo-izquierda",disabled:oe,"aria-label":"Mover imagen hacia abajo-izquierda",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-arrow-up-blue icon--md lb:-rotate-145"})})}),F.jsx("button",{onClick:()=>Le(0,10),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover abajo",disabled:oe,"aria-label":"Mover imagen hacia abajo",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-arrow-down-blue"})})}),F.jsx("button",{onClick:()=>Le(10,10),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover abajo-derecha",disabled:oe,"aria-label":"Mover imagen hacia abajo-derecha",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-arrow-up-blue icon--md lb:rotate-145"})})}),F.jsx("button",{onClick:De,className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:aspect-square lb:text-sm "+(A.vertical?"lb:bg-blue-100 lb:border lb:border-blue-300 lb:text-blue-800":"lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200"),title:"Voltear verticalmente "+(A.vertical?"(activo)":""),disabled:oe,"aria-label":"Voltear imagen verticalmente","aria-pressed":A.vertical,children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-arrow-up-down-blue lb:border lb:border-brand-blue-1000 lb:rounded"})})})]})}),F.jsx("div",{className:"lb:flex lb:flex-col lb:gap-2",children:F.jsx("button",{onClick:()=>{be.reset(),M({horizontal:!1,vertical:!1})},className:"lb:w-full lb:p-2 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",title:"Reiniciar transformaciones",disabled:oe,"aria-label":"Reiniciar todas las transformaciones de la imagen",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsxs("span",{children:[F.jsx("span",{className:"icon icon-refresh-blue icon--sm lb:align-[middle!important] "})," ","Reiniciar ajustes"]})})})})]})]}),F.jsxs("div",{className:"lb:bg-white lb:rounded lb:border lb:border-gray-200 lb:w-full"+(R?"":" lb:bg-neutral-gray-50/50"),children:[F.jsx("button",{onClick:Ne,className:"lb:hidden lb:sm:block lb:w-full lb:cursor-pointer lb:hover:bg-neutral-gray-050/50 lb:p-2 lb:mb-05 lb:transition-colors lb:rounded-t-sm","aria-expanded":R,"aria-label":"Mostrar/ocultar opciones de visualizción",children:F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between",children:[F.jsx("h3",{className:"lb:text-sm lb:font-semibold lb:text-gray-700",children:"Ajustes del selector"}),F.jsx("div",{className:"lb:text-center",children:F.jsx("span",{className:`icon ${R?"icon-chevron-up":"icon-chevron-down"} lb:text-center icon--xs`})})]})}),F.jsxs("div",{className:"lb:p-2 lb:space-y-2 lb:justify-items-stretch lb:static "+(R?"lb:block":"lb:sm:hidden"),children:[F.jsx("div",{children:F.jsxs("div",{className:"lb:grid lb:grid-cols-2 lb:gap-2",children:[F.jsx("button",{onClick:()=>Pe(.5),className:"lb:p-1 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-xs lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",disabled:oe,"aria-label":"Selección 50%",title:"Tamaño de selector 50%",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{children:"50%"})})}),F.jsx("button",{onClick:()=>Pe(.7),className:"lb:p-1 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-xs lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",disabled:oe,"aria-label":"Selección 70%",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{children:"70%"})})}),F.jsx("button",{onClick:()=>Pe(.9),className:"lb:p-1 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-xs lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",disabled:oe,"aria-label":"Selección 90%",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{children:"90%"})})}),F.jsx("button",{onClick:()=>Pe(1),className:"lb:p-1 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-xs lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",disabled:oe,"aria-label":"Selección completa",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{children:"100%"})})})]})}),F.jsxs("div",{className:"lb:space-y-2 lb:pt-2",children:[F.jsx("button",{onClick:Te,className:"lb:w-full lb:p-1 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",title:"Centrar selección",disabled:oe,"aria-label":"Centrar área de selección",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsxs("span",{children:[F.jsx("span",{className:"icon icon-radio-button icon--sm lb:align-[middle!important] "})," ","Centrar selección"]})})}),F.jsx("button",{onClick:ze,className:"lb:w-full lb:p-1 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",title:"Reiniciar selección",disabled:oe,"aria-label":"Reiniciar área de selección",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsxs("span",{children:[F.jsx("span",{className:"icon icon-refresh icon--sm lb:align-[middle!important]"})," ","Reset selección"]})})})]})]})]}),F.jsxs("div",{className:"lb:bg-white lb:rounded lb:border lb:border-gray-200 lb:w-full",children:[F.jsx("button",{onClick:je,className:"lb:hidden lb:sm:block lb:w-full lb:cursor-pointer lb:hover:bg-neutral-gray-050/50 lb:transition-colors lb:rounded-t-sm lb:mb-05 lb:p-2","aria-expanded":D,"aria-label":"Mostrar/ocultar opciones de visualización",children:F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between",children:[F.jsx("h3",{className:"lb:text-sm lb:font-semibold lb:text-gray-700",children:"Visualización"}),F.jsx("div",{className:"lb:text-center",children:F.jsx("span",{className:`icon ${D?"icon-chevron-up":"icon-chevron-down"} lb:text-center icon--xs`})})]})}),F.jsxs("div",{className:"lb:py-2 lb:space-y-2 lb:justify-items-stretch lb:static "+(D?"lb:block":"lb:sm:hidden"),children:[F.jsxs("button",{onClick:Ce,className:"lb:w-auto lb:flex lb:cursor-pointer lb:items-center lb:justify-between lb:mx-2 lb:p-1 lb:rounded lb:transition-colors "+(f?"lb:bg-blue-100 lb:border lb:border-blue-300 lb:text-blue-800":"lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200"),disabled:oe,"aria-pressed":f,title:"Mostrar/ocultar cuadrícula de la regla de los tercios en el selector","aria-label":"Activar/desactivar grid",children:[F.jsxs("span",{className:"lb:text-sm lb:flex lb:items-center",children:[F.jsx("span",{className:"icon icon-area-blue lb:me-1"})," ","Cuadrícula"]}),F.jsx("span",{className:"lb:text-xs",children:f?F.jsxs(F.Fragment,{children:[F.jsx("span",{className:"icon icon-tick icon--xs lb:align-[middle!important] lb:-mt-0.5"})," ","Activo"]}):"Inactivo"})]}),F.jsxs("button",{onClick:Se,className:"lb:w-auto lb:flex lb:cursor-pointer lb:items-center lb:justify-between lb:mx-2 lb:p-1 lb:rounded lb:transition-colors "+(v?"lb:bg-blue-100 lb:border lb:border-blue-300 lb:text-blue-800":"lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200"),disabled:oe,"aria-pressed":v,"aria-label":"Activar/desactivar sombreado",children:[F.jsxs("span",{className:"lb:text-sm lb:flex lb:items-center",children:[F.jsx("span",{className:"icon icon-comparison-blue lb:me-1"})," ","Tablero"]}),F.jsx("span",{className:"lb:text-xs",children:v?F.jsxs(F.Fragment,{children:[F.jsx("span",{className:"icon icon-tick icon--xs lb:align-[middle!important] lb:-mt-0.5"})," ","Activo"]}):"Inactivo"})]})]})]})]})})]}),F.jsxs("div",{className:"lb:flex lb:justify-between lb:shrink-0 lb:border-t lb:border-gray-200 lb:bg-white lb:mx-2 lb:mt-1 lb:py-2 lb:lg:gap-0",children:[F.jsxs("button",{onClick:()=>I(!0),className:"lb:text-nowrap lb:block lb:cursor-pointer lb:lg:flex lb:items-center lb:gap-2 lb:px-2 lb:py-1 lb:bg-gradient-to-br lb:from-brand-blue-50 lb:to-green-50 lb:hover:from-brand-blue-100 lb:hover:to-green-100 lb:border lb:border-blue-200 lb:rounded-lg lb:shadow-sm lb:transition-colors","aria-label":"Abrir guía de uso",children:[F.jsx("span",{className:"icon icon-lightbulb lb:text-yellow-500"}),F.jsx("span",{className:"lb:text-sm lb:font-semibold lb:text-blue-800",children:"Guía de uso"}),F.jsx("span",{className:"icon icon-arrow-down lb:scale-75 lb:-rotate-145"})]}),F.jsx("button",{onClick:Qe,disabled:oe||!xe,className:`lb:px-3 lb:cursor-pointer lb:py-1.5 lb:text-sm lb:rounded lb:transition-colors ${u?"lb:bg-red-1000 lb:hover:bg-red-800 lb:text-white":"lb:bg-brand-blue-800 lb:hover:bg-brand-blue-1000 lb:text-white"} lb:disabled:opacity-50 lb:disabled:cursor-not-allowed`,"aria-label":"Vista previa",title:"Mostrar/Ocultar vista previa",children:F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-1",children:[F.jsx("span",{className:"icon icon-search-white icon--sm"}),F.jsx("span",{className:"lb:hidden lb:sm:inline lb:whitespace-nowrap",children:u?"Cerrar previa":"Vista previa"})]})}),F.jsxs("div",{className:"lb:flex lb:flex-row lb:gap-1 lb:lg:gap-2 lb:items-center lb:justify-end",children:[F.jsx("button",{onClick:ut,disabled:oe||!xe,className:"lb:cursor-pointer lb:px-3 lb:py-1.5 lb:text-sm lb:rounded lb:bg-brand-blue-800 lb:hover:bg-brand-blue-1000 lb:text-white lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed","aria-label":"Descargar",title:"Descargar recorte sin guardar",children:F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-1",children:[F.jsx("span",{className:"icon icon-download-white icon--sm"}),F.jsx("span",{className:"lb:hidden lb:md:inline lb:whitespace-nowrap",children:"Descargar"})]})}),F.jsx("button",{onClick:bt,disabled:oe||s,className:"lb:px-3 lb:cursor-pointer lb:py-1.5 lb:text-sm lb:rounded lb:bg-teal-600 lb:hover:bg-teal-700 lb:text-white lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed","aria-label":"Conservar solo imagen original sin crear recortes",title:e.file?"Subir y guardar la imagen original sin crear recortes":"Seleccionar la imagen original sin crear recortes",children:F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-1",children:[F.jsx("span",{className:"icon icon-tick-white icon--sm"}),F.jsx("span",{className:"lb:hidden lb:md:inline lb:whitespace-nowrap",children:"Guardar sin recortar"})]})}),F.jsx("button",{onClick:it,disabled:oe||!ye||!ke||!xe||!de.isReady,className:"lb:px-3 lb:cursor-pointer lb:py-1.5 lb:text-sm lb:rounded lb:bg-green-600 lb:hover:bg-green-700 lb:text-white lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed",title:"Guardar imagen recortada",children:F.jsx("div",{className:"lb:flex lb:items-center lb:gap-1",children:oe?F.jsxs(F.Fragment,{children:[F.jsx("span",{className:"icon icon-save-white icon--sm"}),F.jsx("span",{children:"Guardando..."})]}):F.jsxs(F.Fragment,{children:[F.jsx("span",{className:"icon icon-save-white icon--sm"}),F.jsx("span",{className:"lb:hidden lb:md:inline lb:whitespace-nowrap",children:"Guardar recorte"})]})})})]})]}),Z&&F.jsx("div",{className:"lb:fixed lb:inset-0 lb:bg-black lb:bg-opacity-50 lb:flex lb:items-center lb:justify-center lb:z-[9999] lb:p-4",children:F.jsxs("div",{className:"lb:bg-white lb:rounded-lg lb:shadow-xl lb:max-w-lg lb:w-full lb:max-h-[80vh] lb:overflow-hidden lb:flex lb:flex-col",children:[F.jsxs("div",{className:"lb:px-6 lb:py-4 lb:border-b lb:border-gray-200",children:[F.jsx("h3",{className:"lb:text-lg lb:font-semibold lb:text-gray-800",children:"save"===le?"Seleccionar recortes a guardar":"Seleccionar recortes a descargar"}),F.jsxs("p",{className:"lb:text-sm lb:text-gray-600 lb:mt-1",children:["Marca los recortes que deseas"," ","save"===le?"guardar":"descargar"]})]}),F.jsx("div",{className:"lb:px-6 lb:py-4 lb:overflow-y-auto lb:flex-1",children:F.jsx("div",{className:"lb:space-y-2",children:H.map((e,t)=>{const n=e.savedState||t===G,l=!e.required&&!n,r=e.required&&"save"===le;return F.jsxs("label",{className:`lb:flex lb:items-center lb:gap-3 lb:p-3 lb:rounded lb:border lb:transition-colors ${te.includes(t)?"lb:bg-blue-50 lb:border-blue-300":l?"lb:bg-gray-100 lb:border-gray-300 lb:opacity-60":"lb:bg-gray-50 lb:border-gray-200 lb:hover:bg-gray-100"} ${l||r?"lb:cursor-not-allowed":"lb:cursor-pointer"}`,title:r?"Este recorte es obligatorio y debe ser guardado":"",children:[F.jsx("input",{type:"checkbox",checked:te.includes(t),disabled:l||r,onChange:e=>{e.target.checked?ne(e=>[...e,t]):ne(e=>e.filter(e=>e!==t))},className:"lb:w-4 lb:h-4 lb:text-blue-600"}),F.jsxs("div",{className:"lb:flex-1 lb:min-w-0",children:[F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2 lb:flex-wrap",children:[F.jsxs("span",{title:"Nombre del archivo a descargar",className:"lb:text-sm lb:font-medium lb:text-gray-800 lb:truncate",children:[e.label,"_",e.width,"_",e.height]}),e.required&&F.jsx("span",{className:"lb:text-xs lb:px-1.5 lb:py-0.5 lb:bg-red-200 lb:text-red-1000 lb:rounded lb:whitespace-nowrap",children:"Obligatorio"}),!n&&!e.required&&F.jsx("span",{className:"lb:text-xs lb:px-1.5 lb:py-0.5 lb:bg-orange-100 lb:text-orange-700 lb:rounded lb:whitespace-nowrap",children:"Sin configurar"})]}),F.jsxs("span",{title:"Dimensiones del recorte",className:"lb:text-xs lb:text-gray-500",children:[e.width," × ",e.height," px"]})]})]},e.id)})})}),F.jsxs("div",{className:"lb:px-6 lb:py-4 lb:border-t lb:border-gray-200 lb:flex lb:gap-3 lb:justify-end",children:[F.jsx("button",{onClick:()=>{ee(!1),re(null),ne([])},className:"limbo-btn limbo-btn-secondary lb:px-4 lb:py-2",children:"Cancelar"}),F.jsxs("button",{onClick:async()=>{if(ee(!1),"save"===le)if(1===te.length){const e=G;Q(te[0]),await new Promise(e=>setTimeout(e,100)),await rt(),Q(e)}else await at(te);else if(1===te.length){const e=G;Q(te[0]),await new Promise(e=>setTimeout(e,100)),await ct(),Q(e)}else await st(te);re(null),ne([])},disabled:0===te.length,className:"limbo-btn limbo-btn-primary lb:px-4 lb:py-2 lb:disabled:opacity-50 lb:disabled:cursor-not-allowed",children:["save"===le?"Guardar":"Descargar"," (",te.length,")"]})]})]})}),P&&F.jsx("div",{className:"lb:fixed lb:inset-0 lb:bg-black/50 lb:flex lb:items-center lb:justify-center lb:z-[9999] lb:p-4",children:F.jsxs("div",{className:"lb:bg-white lb:rounded-lg lb:shadow-xl lb:max-w-5xl lb:w-full lb:max-h-[90vh] lb:overflow-hidden lb:flex lb:flex-col",children:[F.jsx("div",{className:"lb:px-6 lb:py-4 lb:border-b lb:border-gray-200 lb:bg-brand-blue-50",children:F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between",children:[F.jsxs("h3",{className:"lb:text-xl lb:font-semibold lb:text-brand-blue-1000 lb:flex lb:items-center lb:gap-2",children:[F.jsx("span",{className:"icon icon-lightbulb lb:text-yellow-500"}),"Guía de uso del Cropper"]}),F.jsx("button",{onClick:()=>I(!1),className:"lb:text-gray-400 lb:hover:text-gray-600 lb:p-1 lb:rounded-full lb:hover:bg-gray-100 lb:transition-colors","aria-label":"Cerrar modal",children:F.jsx("span",{className:"icon icon-close-small icon--lg"})})]})}),F.jsxs("div",{className:"lb:px-6 lb:py-4 lb:overflow-y-auto lb:flex-1 lb:space-y-4",children:[F.jsxs("div",{className:"lb:bg-brand-blue-50 lb:rounded-lg lb:p-4 lb:border-l-4 lb:border-brand-blue-400",children:[F.jsx("h4",{className:"lb:font-semibold lb:text-brand-blue-1000 lb:mb-3 lb:text-base lb:flex lb:items-center lb:gap-2",children:"🖱️ Navegación básica"}),F.jsxs("div",{className:"lb:text-sm lb:text-brand-blue-800 lb:space-y-2",children:[F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Arrastra la imagen:"})," Haz clic sobre la imagen dentro del área de selección y arrástrala para reposicionarla"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Zoom:"})," Usa la rueda del ratón sobre el canvas (fuera del área de selección) para hacer zoom"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Vista completa:"}),' Botón "Reset zoom" para ajustar automáticamente al tamaño óptimo']})]})]})]}),F.jsxs("div",{className:"lb:bg-brand-blue-50 lb:rounded-lg lb:p-4 lb:border-l-4 lb:border-brand-blue-400",children:[F.jsx("h4",{className:"lb:font-semibold lb:text-brand-blue-1000 lb:mb-3 lb:text-base lb:flex lb:items-center lb:gap-2",children:"✂️ Área de selección"}),F.jsxs("div",{className:"lb:text-sm lb:text-brand-blue-800 lb:space-y-2",children:[F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Mover selección:"})," Arrastra desde el centro",F.jsx("span",{className:"icon lb:bg-white icon-move lb:inline-block lb:mx-1 lb:align-middle lb:border lb:border-brand-blue-400 lb:rounded-full"}),"para reposicionar el área de recorte"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Redimensionar:"})," Arrastra desde las esquinas o bordes para cambiar el tamaño del área"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Tamaños rápidos:"})," Usa los botones de porcentaje (50%, 70%, 90%, 100%) para ajustar rápidamente el tamaño"]})]})]})]}),F.jsxs("div",{className:"lb:bg-brand-blue-50 lb:rounded-lg lb:p-4 lb:border-l-4 lb:border-brand-blue-400",children:[F.jsx("h4",{className:"lb:font-semibold lb:text-brand-blue-1000 lb:mb-3 lb:text-base lb:flex lb:items-center lb:gap-2",children:"⌨️ Atajos de teclado"}),F.jsxs("div",{className:"lb:text-sm lb:text-brand-blue-800 lb:space-y-2",children:[F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Flechas:"}),F.jsxs("span",{className:"lb:inline-flex lb:gap-1 lb:mx-1",children:[F.jsx("span",{className:"icon icon-arrow-right-box lb:rotate-180 icon--sm"}),F.jsx("span",{className:"icon icon-arrow-right-box icon--sm"}),F.jsx("span",{className:"icon icon-arrow-right-box lb:-rotate-90 icon--sm"}),F.jsx("span",{className:"icon icon-arrow-right-box lb:rotate-90 icon--sm"})]}),"Mueven la selección en incrementos de 10px"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Shift + Arrastrar:"})," Mantiene las proporciones al redimensionar el área de selección"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Ctrl + Rueda:"})," Control de zoom más preciso y fino"]})]})]})]}),F.jsxs("div",{className:"lb:bg-teal-50 lb:rounded-lg lb:p-4 lb:border-l-4 lb:border-teal-800",children:[F.jsx("h4",{className:"lb:font-semibold lb:text-teal-1000 lb:mb-3 lb:text-base lb:flex lb:items-center lb:gap-2",children:"👁️ Opciones de visualización"}),F.jsxs("div",{className:"lb:text-sm lb:text-teal-800 lb:space-y-2",children:[F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Cuadrícula:"})," Muestra la regla de los tercios para mejorar la composición de tus recortes"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Tablero:"})," Patrón de cuadros para alinear mejor las medidas o ver imágenes con transparencia"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Vista previa:"})," Muestra cómo quedará el recorte final antes de guardarlo"]})]})]})]}),F.jsxs("div",{className:"lb:bg-amber-50 lb:rounded-lg lb:p-4 lb:border-l-4 lb:border-amber-400",children:[F.jsx("h4",{className:"lb:font-semibold lb:text-amber-800 lb:mb-3 lb:text-base lb:flex lb:items-center lb:gap-2",children:"💡 Consejos profesionales"}),F.jsxs("div",{className:"lb:text-sm lb:text-amber-700 lb:space-y-2",children:[F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Orden de trabajo:"})," Primero aplica transformaciones (rotar, voltear), luego haz el recorte final"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Múltiples recortes:"})," Si tienes varios recortes configurados, revisa cada uno antes de guardar"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Calidad:"})," Las imágenes se exportan en alta calidad (JPEG 90%) manteniendo la mayor nitidez posible"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Proporciones:"})," Usa Shift al redimensionar para mantener el aspecto ratio original"]})]})]})]}),F.jsxs("div",{className:"lb:bg-orange-50 lb:rounded-lg lb:p-4 lb:border-l-4 lb:border-orange-500",children:[F.jsx("h4",{className:"lb:font-semibold lb:text-orange-800 lb:mb-3 lb:text-base lb:flex lb:items-center lb:gap-2",children:"⚠️ Notas importantes"}),F.jsxs("div",{className:"lb:text-sm lb:text-orange-700 lb:space-y-2",children:[F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Recortes grandes:"})," Imágenes de alta resolución pueden tardar más en procesarse"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Calidad de escala:"})," Evita ampliar demasiado áreas pequeñas, ya que puede afectar la nitidez"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Cambios pendientes:"})," Recuerda guardar tus cambios antes de cerrar o cambiar de imagen"]})]})]})]})]}),F.jsx("div",{className:"lb:px-6 lb:py-4 lb:border-t lb:border-gray-200 lb:bg-gray-50",children:F.jsx("button",{onClick:()=>I(!1),className:"limbo-btn limbo-btn-primary lb:w-full",children:"Entendido"})})]})}),u&&F.jsx("div",{className:"lb:min-w-[90%] lb:fixed lb:md:absolute lb:inset-0 lb:md:inset-auto lb:bg-black/50 lb:md:bg-transparent lb:flex lb:items-center lb:justify-center lb:md:block lb:z-9999 lb:md:z-50 lb:pointer-events-none",onClick:e=>{e.target===e.currentTarget&&window.innerWidth<768&&(d(!1),m(null))},children:F.jsxs("div",{className:"lb:pointer-events-auto lb:bg-white lb:rounded-lg lb:shadow-2xl lb:border-2 lb:border-brand-blue-800 lb:overflow-hidden lb:flex lb:flex-col lb:max-w-md lb:w-full lb:mx-4 lb:md:mx-0 lb:max-h-[80vh] lb:md:max-h-[600px]",style:{...window.innerWidth>=768?{position:"absolute",left:`${w.x}px`,top:`${w.y}px`,width:"420px",cursor:C?"grabbing":"default"}:{}},onMouseDown:Xe,onTouchStart:Ze,children:[F.jsxs("div",{className:"limbo-preview-modal-header lb:px-4 lb:py-3 lb:bg-linear-to-r lb:from-brand-blue-800 lb:to-brand-blue-1000 lb:text-white lb:flex lb:items-center lb:justify-between lb:cursor-grab lb:active:cursor-grabbing lb:select-none",style:{cursor:C?"grabbing":"grab"},children:[F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2",children:[F.jsx("span",{className:"icon icon-search-white icon--sm"}),F.jsx("h3",{className:"lb:text-sm lb:font-semibold lb:text-white",children:"Vista previa"})]}),F.jsx("button",{onClick:()=>{d(!1),m(null)},className:"lb:flex lb:p-1 lb:hover:bg-white/20 lb:rounded lb:transition-colors lb:cursor-pointer lb:aspect-square lb:min-w-fit lb:min-h-fit","aria-label":"Cerrar vista previa",title:"Cerrar vista previa",children:F.jsx("span",{className:"icon icon-close-small-white icon--sm lb:p-0 lb:m-0 lb:py-auto lb:my-auto lb:mx-auto"})})]}),F.jsx("div",{className:"lb:flex-1 lb:overflow-auto lb:bg-gray-50 lb:p-4",children:h?F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center lb:h-full lb:min-h-[200px]",children:F.jsxs("div",{className:"lb:text-center",children:[F.jsx("div",{className:"lb:animate-spin lb:rounded-full lb:h-12 lb:w-12 lb:border-b-2 lb:border-blue-600 lb:mx-auto lb:mb-3"}),F.jsx("p",{className:"lb:text-sm lb:text-gray-600",children:"Generando vista previa..."})]})}):b?F.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-3",children:[F.jsxs("div",{className:"lb:relative lb:w-full lb:bg-white lb:rounded-lg lb:border lb:border-gray-200 lb:overflow-hidden lb:shadow-sm lb:cursor-zoom-in lb:hover:ring-2 lb:hover:ring-brand-blue-800 lb:transition-all",onClick:()=>$(!0),role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),$(!0))},"aria-label":"Click para ver recorte en tamaño completo",title:"Click para ampliar",children:[F.jsx("img",{src:b,alt:"Vista previa del recorte",className:"lb:w-full lb:h-auto lb:object-contain lb:max-h-[400px]"}),F.jsxs("div",{className:"lb:absolute lb:top-2 lb:right-2 lb:bg-black/60 lb:text-white lb:px-2 lb:py-1 lb:rounded lb:text-xs lb:flex lb:items-center lb:gap-1",children:[F.jsx("span",{className:"icon icon-search-white icon--xs"}),F.jsx("span",{children:"Ampliar"})]})]}),F.jsxs("div",{className:"lb:text-center lb:text-xs lb:text-gray-500",children:[F.jsx("p",{className:"lb:font-medium lb:text-gray-700 lb:mb-1",children:X?.label||"Recorte"}),F.jsxs("p",{children:[X?.width," × ",X?.height," px"]})]})]}):F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center lb:h-full lb:min-h-[200px]",children:F.jsx("p",{className:"lb:text-sm lb:text-gray-500",children:"No se pudo generar la vista previa"})})}),F.jsx("div",{className:"lb:px-4 lb:py-2 lb:bg-gray-100 lb:border-t lb:border-gray-200",children:F.jsxs("p",{className:"lb:text-xs lb:text-gray-600 lb:text-center",children:[F.jsxs("span",{className:"lb:hidden lb:md:inline",children:["Arrastra desde el título para mover •"," "]}),"Actualización automática al editar"]})})]})}),F.jsx(Ee,{src:b,alt:"Vista previa del recorte",title:X?.label||"Recorte",subtitle:`${X?.width||0} × ${X?.height||0} px`,isOpen:E&&!!b,onClose:()=>$(!1)})]}):null}function tl({currentPage:e,totalPages:t,onPageChange:n,disabled:l=!1}){if(!t||t<=1)return null;const r=(()=>{const n=[],l=[],r=Math.max(1,e-2),a=Math.min(t,e+2);for(let e=r;e<=a;e++)n.push(e);return r>1&&(l.push(1),r>2&&l.push("...")),l.push(...n),a<t&&(a<t-1&&l.push("..."),l.push(t)),l})();return F.jsx("div",{className:"lb:flex lb:flex-col lb:items-center lb:justify-center lb:space-x-2 lb:py-4",children:F.jsxs("div",{className:"lb:flex lb:space-x-2 lb:mt-2",children:[F.jsxs("button",{onClick:()=>{e>1&&n(e-1)},disabled:l||e<=1,className:` lb:px-3 lb:py-2 lb:text-sm lb:font-medium lb:rounded-md lb:transition-colors lb:disabled:cursor-default lb:cursor-pointer ${l||e<=1?"lb:text-gray-400 lb:bg-gray-100 lb:cursor-not-allowed":"lb:text-gray-700 lb:bg-white lb:border lb:border-gray-300 lb:hover:bg-gray-50 lb:focus:ring-2 lb:focus:ring-blue-500"} `,children:[F.jsx("span",{className:"icon icon-arrow-left icon--sm"})," Anterior"]}),F.jsx("div",{className:"lb:flex lb:space-x-1",children:r.map((t,r)=>F.jsx(v.Fragment,{children:"..."===t?F.jsx("span",{className:"lb:px-3 lb:py-2 lb:text-sm lb:text-gray-500",children:"..."}):F.jsx("button",{onClick:()=>(t=>{t!==e&&n(t)})(t),disabled:l,className:` lb:px-3 lb:py-2 lb:text-sm lb:font-medium lb:rounded-md lb:transition-colors lb:disabled:cursor-default lb:cursor-pointer ${t===e?"lb:bg-brand-blue-800 lb:text-white lb:border lb:border-brand-blue-1000":l?"lb:text-gray-400 lb:bg-gray-100 lb:cursor-not-allowed":"lb:text-gray-700 lb:bg-white lb:border lb:border-gray-300 lb:hover:bg-gray-50 lb:focus:ring-2 lb:focus:ring-blue-500"} `,children:t})},`page-${t}-${r}`))}),F.jsxs("button",{onClick:()=>{e<t&&n(e+1)},disabled:l||e>=t,className:` lb:px-3 lb:py-2 lb:text-sm lb:font-medium lb:rounded-md lb:transition-colors lb:disabled:cursor-default lb:cursor-pointer ${l||e>=t?"lb:text-gray-400 lb:bg-gray-100 lb:cursor-not-allowed":"lb:text-gray-700 lb:bg-white lb:border lb:border-gray-300 lb:hover:bg-gray-50 lb:focus:ring-2 lb:focus:ring-blue-500"} `,children:["Siguiente ",F.jsx("span",{className:"icon icon-arrow-right icon--sm"})]})]})})}function nl({text:e="Cargando..."}){return F.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-neutral-gray-1000/20 lb:z-10 lb:flex lb:flex-col lb:items-center lb:justify-center lb:py-8 lb:text-gray-600",role:"status","aria-live":"polite","aria-label":e,children:[F.jsx("span",{className:"limbo-filter-searching","aria-hidden":"true",children:F.jsx("span",{className:"icon icon-spinner lb:animate-spin lb:min-w-7 lb:min-h-7"})}),F.jsx("p",{className:"lb:text-sm",id:"loader-text",children:e})]})}function ll({isOpen:e,onClose:t}){return e?F.jsx("div",{className:"lb:fixed lb:inset-0 lb:bg-black lb:bg-opacity-50 lb:flex lb:items-center lb:justify-center lb:z-50",style:{zIndex:9999},children:F.jsxs("div",{className:"lb:bg-white lb:rounded-lg lb:p-6 lb:max-w-md lb:mx-4 lb:shadow-xl",children:[F.jsxs("div",{className:"lb:flex lb:items-center lb:mb-4",children:[F.jsx("svg",{className:"lb:w-6 lb:h-6 lb:text-red-1000 lb:mr-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"})}),F.jsx("h3",{className:"lb:text-lg lb:font-semibold lb:text-gray-900",children:"Sesión Expirada"})]}),F.jsxs("div",{className:"lb:mb-6",children:[F.jsx("p",{className:"lb:text-gray-600 lb:mb-2",children:"Su sesión ha expirado por seguridad."}),F.jsx("p",{className:"lb:text-gray-600",children:"Es necesario recargar la página para obtener un nuevo token de acceso."})]}),F.jsx("div",{className:"lb:flex lb:justify-end lb:space-x-3",children:F.jsx("button",{onClick:t,className:"lb:px-4 lb:py-2 lb:bg-blue-600 lb:text-white lb:rounded-md lb:hover:bg-blue-700 lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-blue-500 lb:focus:ring-offset-2 lb:transition-colors",children:"Recargar Página"})})]})}):null}function rl(){const[e,t]=y.useState(!1),[n,l]=y.useState(null);return{deleteImg:async e=>{if(!e)return l("ID de imagen no proporcionado"),!1;t(!0),l(null);try{const t=await async function(e){try{return await ne({endpoint:`/assets/${e}`,method:"DELETE",basePath:ue,useJWT:!0})}catch(n){throw ce(n)}}(e);return!1!==t.success}catch(r){return l(r.message),!1}finally{t(!1)}},loading:e,error:n,reset:()=>{l(null)}}}const al=new Map,il=6e5,ol="limbo_gallery_cache";function sl(e,t=!1,n={},l=!0){const r=y.useMemo(()=>JSON.stringify(n),[n]),a=y.useRef((()=>{const e=r,t=al.get(e),n=Date.now();return t&&n-t.timestamp<il?{images:t.data,pagination:t.pagination||null,loading:!1}:{images:[],pagination:null,loading:l}})()),[i,o]=y.useState(a.current.images),[s,c]=y.useState(a.current.loading),[u,d]=y.useState(null),[b,m]=y.useState(a.current.pagination),[h,p]=y.useState(0),[f,g]=y.useState(0);y.useEffect(()=>{if(!l)return void c(!1);const e=`${r}`,t=al.get(e),a=Date.now();if(t&&a-t.timestamp<il)return o(t.data),m(t.pagination||null),void c(!1);let i=!0;return(async()=>{if(h>=3)i&&(d("Error de autenticación: Verifica tus credenciales API"),c(!1));else try{const t=await de(n);if(!i)return;const l=t.result||t.data||[],r=t.pagination||null;o(l),m(r),d(null),p(0),al.set(e,{data:l,pagination:r,timestamp:a}),(()=>{try{const e={};al.forEach((t,n)=>{e[n]=t}),sessionStorage.setItem(ol,JSON.stringify(e))}catch{}})()}catch(t){i&&(d(t.message),p(e=>e+1))}finally{i&&c(!1)}})(),()=>{i=!1}},[e,t,r,h,n,l,f]);return{images:i,loading:s,error:u,pagination:b,setImages:o,invalidateCache:()=>{al.clear();try{sessionStorage.removeItem(ol)}catch{}},refetch:()=>{al.clear();try{sessionStorage.removeItem(ol)}catch{}c(!0),g(e=>e+1)}}}function cl(e,t=500){const[n,l]=y.useState(e);return y.useEffect(()=>{const n=setTimeout(()=>{l(e)},t);return()=>{clearTimeout(n)}},[e,t]),n}function ul(){return F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-center lb:gap-2 lb:py-2 lb:px-4 lb:border-t lb:h-8 lb:border-brand-purple-200 lb:bg-brand-purple-50 lb:rounded-b-md lb:mt-3",style:{background:"linear-gradient(90deg,#001978,#2134f1 50%,#f81bbd 95%)",color:"white"},children:[F.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 52",fill:"currentColor",className:"lb:w-5 lb:h-5 lb:text-white","aria-hidden":"true",children:[F.jsx("path",{d:"M29.0863 15.2704H24.9419V36.7321H37.5259V33.1048H29.0863V15.2704Z"}),F.jsx("path",{d:"M18.1601 33.1048H9.72056V36.7321H22.3045V15.2704H18.1601V33.1048Z"}),F.jsx("path",{d:"M44.0063 51.846L3.16483 50.1834C1.35636 50.1834 0 48.5965 0 46.8584V4.99294C0 3.33041 1.65777 1.8946 3.31554 1.81903L44.157 0.1565C46.2669 0.0809304 48 1.74346 48 3.8594V47.8408C48 50.0323 46.1915 51.846 43.9309 51.7704H44.0063V51.846ZM4.89796 46.405L42.9513 47.4629C43.4788 47.4629 44.0063 47.0095 44.0063 46.4805V5.21965C44.0063 4.69066 43.6295 4.31282 43.102 4.31282L4.82261 5.67307C4.14443 5.67307 3.61695 6.27762 3.61695 6.95775V45.1203C3.61695 45.8004 4.14443 46.3294 4.82261 46.405H4.89796Z"})]}),F.jsxs("span",{className:"lb:text-xs lb:text-neutral-50",children:["Powered by ",F.jsx("span",{className:"lb:font-semibold lb:text-white",children:"Limbo"})]})]})}function dl({apiKey:e,prod:t=!1,url:n=!0,features:l=["gallery","upload","cropper"],modeUI:r="full",ui:a={showActions:["select","download","copy","delete","crop","variants"],hideActions:[],theme:"light",language:"es",compactMode:!1,showTabs:!0},callbacks:o={},instanceId:s=null,itemsPerPage:c=30,_externalImage:u=null,cropperConfig:d=null,folderConfig:b={include:[],exclude:[],includeNoFolder:!0,showFolderSelector:!0,showFolderFilter:!0,showFolderInfo:!0,allowMoveFolder:!0,allowCreateFolder:!0,defaultFolder:null},allowedCategories:m=null,accept:h=null,returnConfig:p=null}){sessionStorage.removeItem("limbo_stock_selectedService"),sessionStorage.removeItem("limbo_stock_dynamicForm"),sessionStorage.removeItem("limbo_stock_stockImages"),sessionStorage.removeItem("limbo_stock_currentPage"),sessionStorage.removeItem("limbo_stock_paginationInfo"),sessionStorage.removeItem("limbo_portals_searchName"),sessionStorage.removeItem("limbo_portals_limit"),sessionStorage.removeItem("limbo_portals_currentPage"),sessionStorage.removeItem("limbo_portals_images"),sessionStorage.removeItem("limbo_portals_portalResults"),sessionStorage.removeItem("limbo_portals_paginationInfo");const[f,g]=y.useState({name:"",uploadedBy:"",dateFrom:"",dateTo:"",assetType:"",folder:""}),[x,w]=y.useState(b?.defaultFolder||null),k=cl(f.name,400),C=cl(f.uploadedBy,400),S=v.useMemo(()=>i(h||(m?m.map(e=>`${e}/*`).join(","):null)),[h,m]),j=e=>!!e&&(e.startsWith("image/")&&"image/gif"!==e),N=(()=>{let e;switch(r){case"gallery-only":e=["gallery"];break;case"upload-only":e=["upload","cropper"];break;case"crop-only":e=["cropper"];break;case"ia-only":e=["ia"];break;default:e=[...l]}return S.isAllTypes||S.includesImages||(e=e.filter(e=>"cropper"!==e)),e})(),E=()=>N.includes("gallery")?"gallery":N.includes("upload")?"upload":N.includes("cropper")?"cropper":N.includes("ia")?"ia":N[0]||"gallery",[$,_]=y.useState(E()),[T,z]=y.useState(null),[L,A]=y.useState(null);y.useEffect(()=>{u&&(console.log("📸 Imagen externa detectada:",u),z(u),_("cropper"))},[u]),y.useEffect(()=>{const e=()=>{console.log("[App] Modal cerrado, reseteando estado..."),z(null),_(E())};return window.limboCore?.events&&window.limboCore.events.on("modal:closed",e),()=>{window.limboCore?.events&&window.limboCore.events.off("modal:closed",e)}},[]);const[M,P]=y.useState(1),{isTokenExpired:I,handleTokenExpiredClose:D}=function(){const[e,t]=y.useState(!1),n=y.useCallback(e=>{if(401===e?.response?.status){const n=e.response.data;if("token_expired"===n?.error||n?.message?.includes("expired")||n?.message?.includes("caducado")||n?.error?.includes("expired"))return t(!0),!0}return!1},[]),l=y.useCallback(()=>{t(!1),alert("El token ha expirado. La página se recargará para obtener un nuevo token."),window.location.reload()},[]);return y.useEffect(()=>{const e=e=>{e.detail&&e.detail.error&&n(e.detail.error)};return window.addEventListener("tokenExpiredError",e),()=>{window.removeEventListener("tokenExpiredError",e)}},[n]),{isTokenExpired:e,checkTokenExpiration:n,handleTokenExpiredClose:l}}(),{upload:O,loading:R,error:U,uploadedImage:B,reset:q}=function(){const[e,t]=y.useState(!1),[n,l]=y.useState(null),[r,a]=y.useState(null);return{upload:async(e,n=null,r=null)=>{if(!e)return l("No se ha proporcionado ningún archivo"),null;t(!0),l(null),a(null);try{const t="object"==typeof r?r?.slug:r,l=await be(e,n,!1,t),i=l.result||l;return a(i),i}catch(i){return l(i.message),null}finally{t(!1)}},loading:e,error:n,uploadedImage:r,reset:()=>{l(null),a(null)}}}(),{deleteImg:V,loading:H,error:K,reset:G}=rl(),Q={limit:c,page:M,...k&&{name:k},...C&&{uploadedBy:C},...f.dateFrom&&{dateFrom:f.dateFrom},...f.dateTo&&{dateTo:f.dateTo},...f.assetType&&{asset_type:f.assetType},...!S.isAllTypes&&S.raw&&{accept:S.raw},...f.folder&&{folder:f.folder},...b.include?.length>0&&{folders_include:b.include.join(",")},...0===b.include?.length&&b.exclude?.length>0&&{folders_exclude:b.exclude.join(",")},...(b.include?.length>0||b.exclude?.length>0)&&void 0!==b.includeNoFolder&&{include_no_folder:b.includeNoFolder?"1":"0"}},X=N.includes("gallery"),{images:Y,loading:J,error:Z,pagination:ee,invalidateCache:te,setImages:le,refetch:re}=sl(e,t,Q,X);y.useEffect(()=>{const e=()=>{re()};return document.addEventListener("limbo:variantsCleared",e),document.addEventListener("limbo:variantDeleted",e),()=>{document.removeEventListener("limbo:variantsCleared",e),document.removeEventListener("limbo:variantDeleted",e)}},[re]);const{refreshVariants:ae}=he(),oe=y.useCallback((e,t=null)=>O(e,t,x?.slug||x),[O,x]),se=e=>!a.hideActions?.includes(e)&&(!!a.showActions?.includes(e)||!(a.showActions?.length>0)),de=[{id:"gallery",label:"Galería",feature:"gallery"},{id:"upload",label:"Subir",feature:"upload"},{id:"cropper",label:"Recortador",hideNonActive:!0,feature:"cropper"}].filter(e=>N.includes(e.feature)),me=async e=>{if(!(e.type?.startsWith("image/")&&"image/gif"!==e.type)){const t=x?.slug||x,n=await O(e,null,t);return void(n&&(te(),P(1),le(e=>[n,...e]),N.includes("gallery")&&_("gallery"),o.onUpload&&o.onUpload({assetId:n.id,url:n.url,fileName:n.filename,mime:n.mime_type,width:n.width,height:n.height,instanceId:s})))}const t=URL.createObjectURL(e),n=await new Promise(e=>{const n=new Image;n.onload=()=>{e({width:n.naturalWidth,height:n.naturalHeight}),URL.revokeObjectURL(t)},n.onerror=()=>{e({width:1920,height:1080}),URL.revokeObjectURL(t)},n.src=t}),l={file:e,filename:e.name,mime_type:e.type,url:URL.createObjectURL(e),width:n.width,height:n.height};if(z(l),N.includes("cropper"))_("cropper");else{const t=x?.slug||x,n=await O(e,null,t);n&&(te(),P(1),le(e=>[n,...e]),_("gallery"),o.onUpload&&o.onUpload({assetId:n.id,url:n.url,fileName:n.filename,mime:n.mime_type,width:n.width,height:n.height,instanceId:s}))}},pe=y.useCallback(e=>{const t={...e,instanceId:s};o.onSelect&&o.onSelect(t),window.limboCore?.events&&window.limboCore.events.emit("select",t);"modal"===((window.limboCore?.config?.getGlobal()||{}).mode||"embed")&&window.limboCore?.modals?.closeAllModals(),A(`Vídeo seleccionado: ${e.title||"Sin título"}`),setTimeout(()=>A(null),3e3)},[o,s]),fe=async e=>{if(!confirm("¿Estás seguro de que deseas eliminar este archivo? Esta acción también eliminará todos sus recortes."))return;await V(e)&&(te(),P(1),le(t=>t.filter(t=>t.id!==e)),T&&T.id===e&&(z(null),_("gallery")))},ge=e=>{j(e.mime_type||e.original_mime)?(z(e),N.includes("cropper")&&_("cropper")):console.log("[App] ⚠️ Archivo no recortable:",e.mime_type||e.original_mime,"- saltando cropper")},ye=()=>"crop-only"===r||1===N.length&&"cropper"===N[0]?"crop-only":N.includes("gallery")?"with-gallery":N.includes("upload")&&!N.includes("gallery")?"upload-only":"with-gallery";return F.jsxs(F.Fragment,{children:[a.showTabs&&"cropper"!=$&&F.jsx(W,{tabs:de,active:$,onChange:e=>{_(e),"upload"!==e&&q(),"gallery"!==e&&G()}}),Z&&F.jsxs(Fe,{variant:"danger",children:["Error al cargar archivos: ",Z]}),K&&F.jsxs(Fe,{variant:"danger",children:["Error al eliminar archivo: ",K]}),L&&F.jsx(Fe,{variant:"success",fixed:!0,onClose:()=>A(null),children:L}),"gallery"===$&&F.jsxs(F.Fragment,{children:[H&&F.jsx(nl,{text:"Eliminando archivo..."}),B&&F.jsxs(Fe,{variant:"success",toast:!0,onClose:q,children:[F.jsx("span",{className:"icon icon-tick-white icon--2sm"})," Archivo subido correctamente: ",B.filename]}),F.jsx(Be,{onSelect:e=>{const t=d?.mandatoryCrops?.length>0,n=j(e.mime_type||e.original_mime);if(t&&n&&N.includes("cropper"))return console.log("[App] 📐 MandatoryCrops detectados, navegando al cropper primero"),void ge(e);o.onSelect&&o.onSelect({assetId:e.id,url:e.url,fileName:e.filename,mime:e.mime_type,width:e.width,height:e.height,instanceId:s})},onCrop:ge,onDelete:se("delete")?fe:null,deletingId:H,images:Y,loading:J,error:Z,filters:f,debouncedFilters:{name:k,uploadedBy:C,dateFrom:f.dateFrom,dateTo:f.dateTo,assetType:f.assetType,folder:f.folder},onFiltersChange:e=>{g(e),P(1)},filterConfig:a.galleryFilters||{},loadingConfig:a.galleryLoading||{},allowedActions:{select:se("select"),download:se("download"),copy:se("copy"),delete:se("delete"),crop:se("crop")},resolvedAccept:S,allowedCategories:m,folderConfig:b,onFolderChange:async(e,t)=>{try{const n=await async function(e,t){try{return ie(await ne({endpoint:`/assets/${e}`,method:"PATCH",body:t,basePath:ue,useJWT:!0}))}catch(n){throw ce(n)}}(e.id,{folder:t});return te(),le(t=>t.map(t=>t.id===e.id?{...t,folder:n.folder||null}:t)),n}catch(n){throw console.error("Error al cambiar carpeta:",n),n}}}),ee&&!J&&F.jsx(tl,{currentPage:ee.page||M,totalPages:ee.pages||1,onPageChange:e=>{P(e)},disabled:J||H})]}),"upload"===$&&F.jsxs("div",{children:[R&&F.jsx(nl,{text:"Subiendo archivo..."}),U&&F.jsxs(Fe,{variant:"danger",toast:!0,onClose:q,children:["Error al subir archivo: ",U]}),B&&F.jsxs(Fe,{variant:"success",toast:!0,onClose:q,children:[F.jsx("span",{className:"icon icon-tick-white icon--2sm"})," Archivo subido correctamente: ",B.filename]}),F.jsx(pt,{onSelect:me,onVideoSelect:pe,disabled:R,apiKey:e,prod:t,allowedCategories:m,resolvedAccept:S,returnConfig:p,folderConfig:b,selectedFolder:x,onFolderChange:w})]}),"cropper"===$&&T&&F.jsx(el,{image:T,onSave:e=>{const t=ye(),n=window.limboCore?.config?.getGlobal()||{},l=n.mode||"embed",r=n.autoHideOnComplete||!1;let a=[],i=null;e.crops&&e.asset?(a=e.crops,i=e.asset):a=e.crops&&Array.isArray(e.crops)?e.crops:Array.isArray(e)?e:[e],i&&"with-gallery"===t&&(le(e=>[i,...e]),P(1),o.onUpload&&o.onUpload({assetId:i.id,url:i.url,fileName:i.filename,mime:i.mime_type,width:i.width,height:i.height,instanceId:s})),"with-gallery"===t&&te();const c=i||T,u=a.some(e=>!0===e.isLocal),d={crops:a,assetId:c?.id,instanceId:s,localCrops:u,asset:c?{id:c.id,url:c.url||c.urlSigned,width:c.width,height:c.height,filename:c.filename,mime_type:c.mime_type}:null};console.log("[App] handleCropSave - callbackPayload:",d),console.log("[App] handleCropSave - crops:",a),console.log("[App] handleCropSave - crops[0]?.url:",a[0]?.url),console.log("[App] handleCropSave - asset:",d.asset),console.log("[App] handleCropSave - callbacks.onCropsSaved existe:",!!o.onCropsSaved),o.onCropsSaved?(console.log("[App] Llamando callbacks.onCropsSaved..."),o.onCropsSaved(d),console.log("[App] callbacks.onCropsSaved ejecutado")):console.warn("[App] ⚠️ callbacks.onCropsSaved NO existe"),window.limboCore?.events&&window.limboCore.events.emit("cropsSaved",d);const b=a.length;switch(A(`✅ ${b} recorte${1!==b?"s":""} guardado${1!==b?"s":""} correctamente`),setTimeout(()=>A(null),3e3),t){case"with-gallery":"modal"===l?o.onCropsSaved||(window.limboCore?.modals?.closeAllModals(),z(null),_("gallery")):(z(null),_("gallery"));break;case"upload-only":"modal"===l?o.onCropsSaved||(window.limboCore?.modals?.closeAllModals(),z(null),_("upload")):(z(null),_("upload"));break;case"crop-only":if("modal"===l)o.onCropperComplete&&o.onCropperComplete({crops:a,instanceId:s}),window.limboCore?.events&&window.limboCore.events.emit("cropperComplete",{crops:a,instanceId:s}),window.limboCore?.modals?.closeAllModals();else if(o.onCropperComplete&&o.onCropperComplete({crops:a,instanceId:s}),window.limboCore?.events&&window.limboCore.events.emit("cropperComplete",{crops:a,instanceId:s}),r){const e=document.querySelector(`#limbo-instance-${s}`);e&&(e.style.display="none")}}},onCancel:()=>{const e=ye(),t=(window.limboCore?.config?.getGlobal()||{}).mode||"embed";switch(o.onCropperCancelled&&o.onCropperCancelled({assetId:T?.id,instanceId:s}),window.limboCore?.events&&window.limboCore.events.emit("cropperCancelled",{assetId:T?.id,instanceId:s}),e){case"with-gallery":z(null),_("gallery");break;case"upload-only":"modal"===t?window.limboCore?.modals?.closeAllModals():(z(null),_("upload"));break;case"crop-only":"modal"===t?window.limboCore?.modals?.closeAllModals():window.limboCore?.events&&window.limboCore.events.emit("cropperClosed",{instanceId:s,reason:"cancelled"})}},onDelete:T?.id&&se("delete")?()=>fe(T.id):null,onError:e=>{o.onCropperError&&o.onCropperError(e,s),window.limboCore?.events&&window.limboCore.events.emit("cropperError",{error:e,assetId:T?.id,instanceId:s}),console.error("Cropper error:",e)},deleting:H,onVariantCreated:(e,t)=>{ae(e),te()},onUpload:oe,uploading:R,cropperConfig:d}),"cropper"===$&&!T&&("crop-only"===r?F.jsxs("div",{children:[R&&F.jsx(nl,{text:"Subiendo archivo..."}),U&&F.jsxs(Fe,{variant:"danger",toast:!0,onClose:q,children:["Error al subir archivo: ",U]}),F.jsx(pt,{onSelect:me,onVideoSelect:pe,disabled:R,apiKey:e,prod:t,allowedCategories:m,resolvedAccept:S,returnConfig:p,folderConfig:b,selectedFolder:x,onFolderChange:w})]}):F.jsxs("div",{className:"limbo-empty-state lb:flex lb:flex-col lb:items-center lb:justify-center lb:py-12 lb:px-6 lb:text-center",children:[F.jsx("div",{className:"lb:text-gray-400 lb:mb-4",children:F.jsx("svg",{className:"lb:w-16 lb:h-16 lb:mx-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),F.jsx("p",{className:"lb:text-gray-600 lb:mb-4",children:"Selecciona una imagen de la galería para comenzar a recortar."})]})),F.jsx(ul,{}),F.jsx(ll,{isOpen:I,onClose:D})]})}(()=>{try{const e=sessionStorage.getItem(ol);if(e){const t=JSON.parse(e),n=Date.now();Object.entries(t).forEach(([e,t])=>{t.timestamp&&n-t.timestamp<il&&al.set(e,t)})}}catch{}})();class bl{constructor(e,t,n,l){this.id=e,this.config=t,this.eventManager=n,this.modalManager=l,this.root=null,this.container=null,this.modal=null,this.mounted=!1,this.destroyed=!1,this.button=null,this._validateConfig(),this._initialize()}_initialize(){"embed"===this.config.mode?this.mount():"button"===this.config.mode&&this._createButton(),this._emitDOMEvent("ready",{instance:this,config:this.config,timestamp:Date.now()})}mount(){if(this.mounted||this.destroyed)return this;if(this.container=this._resolveContainer(),!this.container)return this.eventManager.emit("error",{instanceId:this.id,error:"Container not found"}),this;try{this.root=D.createRoot(this.container),this.root.render(this._renderApp()),this.mounted=!0,this.eventManager.emit("ready",{instance:this})}catch(e){this.eventManager.emit("error",{instanceId:this.id,error:e.message})}return this}unmount(){return this.mounted?(this.root&&(this.root.unmount(),this.root=null),"button"===this.config.mode&&this.button,this.mounted=!1,this):this}open(){return"modal"!==this.config.mode&&"button"!==this.config.mode||(this.modal||this._createModal(),this.modal&&!this.modal.isOpened()&&(this.modal.open(),this.eventManager.emit("modal:open",{instance:this}))),this}close(){return this.modal&&this.modal.isOpened()&&(this.eventManager?.emit("modal:close",{instance:this}),this.modal.close()),this}updateConfig(e){return this.config={...this.config,...e},this.mounted&&this.root.render(this._renderApp()),this.eventManager.emit("config:updated",{instance:this,newConfig:e}),this}destroy(){this.destroyed||(this.unmount(),this.modal&&(this.modal.destroy(),this.modal=null),this.button&&this.button.parentNode&&(this.button.parentNode.removeChild(this.button),this.button=null),this.eventManager.emit("destroy",{instance:this}),this.container=null,this.config=null,this.eventManager=null,this.modalManager=null,this.destroyed=!0)}getId(){return this.id}getMode(){return this.config.mode}isMounted(){return this.mounted}isDestroyed(){return this.destroyed}getContainer(){return this.container}getConfig(){return{...this.config}}isContainerInDOM(){return this.container&&document.contains(this.container)}_createModal(){if(this.modalManager&&"modal"===this.config.mode&&(this.modal=this.modalManager.createModal({title:this.config.title||"Limbo Image Manager",size:this.config.modalSize||"large",onOpen:()=>{const e={instance:this,mode:"modal",timestamp:Date.now()};this._emitDOMEvent("modal:open",e),this.config.callbacks?.onOpen&&this.config.callbacks.onOpen(e)},onClose:()=>{const e={instance:this,mode:"modal",timestamp:Date.now()};this._emitDOMEvent("modal:close",e),this.config.callbacks?.onClose&&this.config.callbacks.onClose(e),this.config.autoDestroy&&this.destroy()},onDestroy:()=>{this.modal=null}}),this.modal)){const e=this.modal.getBodyContainer();this.root=D.createRoot(e),this.root.render(this._renderApp()),this.mounted=!0}}_createButton(){if(this.container||(this.container=this._resolveContainer()),!this.container)return void this.eventManager.emit("error",{instanceId:this.id,error:"Container not found for button mode"});const e=document.createElement("button");e.type="button",e.className="limbo-trigger-button",e.textContent=this.config.buttonText||"Abrir Limbo",e.style.cssText="\n background: #001978;\n color: white;\n border: none;\n padding: 10px 20px;\n border-radius: 6px;\n cursor: pointer;\n font-family: inherit;\n font-size: 14px;\n font-weight: 500;\n transition: all 0.2s ease;\n ",e.addEventListener("mouseenter",()=>{e.style.backgroundColor="#334793",e.style.transform="translateY(-1px)"}),e.addEventListener("mouseleave",()=>{e.style.backgroundColor="#001978",e.style.transform="translateY(0)"}),e.addEventListener("click",()=>{this.open()}),this.container.appendChild(e),this.button=e,this.mounted=!0}_resolveContainer(){const{container:e}=this.config;return e?"string"==typeof e?document.querySelector(e):e instanceof Element?e:null:null}_renderApp(){return v.createElement("div",{id:`limbo-component-container-${this.id}`,className:"limbo-scope limbo-instance limbo-component-container-wrapper lb:h-full lb:w-full lb:py-2 lb:pb-0 lb:bg-white","data-limbo-id":this.id,"data-limbo-mode":this.config.mode,"data-limbo-version":"3.5.9","data-limbo-isolated":"true","aria-label":"Limbo Image Manager",role:"region"},v.createElement(dl,{apiKey:this.config.apiKey||null,publicKey:this.config.publicKey||null,token:this.config.token||null,prod:this.config.prod||!1,url:this.config.url,features:this.config.features,modeUI:this.config.modeUI||"full",ui:this.config.ui,callbacks:this._createCallbacks(),instanceId:this.id,authMode:this.config.authMode||(this.config.publicKey?"session":"manual"),_externalImage:this.config._externalImage||null,cropperConfig:this.config.cropper||null,allowedCategories:this.config.validation?.allowedCategories||null,accept:this.config.validation?.accept||null,returnConfig:this.config.returnConfig||null,folderConfig:this.config.folders||{include:[],exclude:[],includeNoFolder:!0}}))}_createCallbacks(){return{onSelect:e=>{const t=this.config?.callbacks?.onSelect,n=this._createStandardPayload(e,"select");t&&Promise.resolve(t(n)).catch(e=>{console.error("[LimboInstance] Error en onSelect callback:",e)}),this.destroyed||this._emitDOMEvent("select",n)},onUpload:e=>{const t=this.config?.callbacks?.onUpload,n=this._createStandardPayload(e,"upload");t&&Promise.resolve(t(n)).catch(e=>{console.error("[LimboInstance] Error en onUpload callback:",e)}),this.destroyed||this._emitDOMEvent("upload",n)},onError:e=>{const t=this.config?.callbacks?.onError,n={instance:this,error:{message:e.message||"Unknown error",code:e.code||"UNKNOWN",timestamp:Date.now()}};t&&t(n.error),this.destroyed||this._emitDOMEvent("error",n)},onClose:()=>{const e=this.config?.callbacks?.onClose,t={instance:this,timestamp:Date.now()};e&&e(),this.destroyed||this._emitDOMEvent("close",t)},onCropsSaved:e=>{console.log("[LimboInstance] onCropsSaved recibido:",e),console.log("[LimboInstance] this.config?.callbacks:",this.config?.callbacks);const t=this.config?.callbacks?.onCropsSaved;console.log("[LimboInstance] userCallback existe:",!!t);const n={instance:this,eventType:"cropsSaved",timestamp:Date.now(),instanceId:this.id,...e};if(console.log("[LimboInstance] payload.crops:",n.crops),t){console.log("[LimboInstance] Llamando userCallback onCropsSaved");try{t(n),console.log("[LimboInstance] userCallback ejecutado correctamente")}catch(l){console.error("[LimboInstance] Error en userCallback:",l)}}else console.warn("[LimboInstance] ⚠️ userCallback onCropsSaved NO existe");this.destroyed||this._emitDOMEvent("cropsSaved",n)},onCropperComplete:e=>{console.log("[LimboInstance] onCropperComplete recibido:",e);const t=this.config?.callbacks?.onCropperComplete,n={instance:this,eventType:"cropperComplete",timestamp:Date.now(),instanceId:this.id,...e};t&&(console.log("[LimboInstance] Llamando userCallback onCropperComplete"),t(n)),this.destroyed||this._emitDOMEvent("cropperComplete",n)}}}_createStandardPayload(e,t){const n={instance:this,eventType:t,timestamp:Date.now(),instanceId:this.id,mode:this.config?.mode,features:this.config?.features};return e&&(e.assetId||e.id?(n.assetId=e.assetId||e.id,n.variants=e.variants||[],n.master=e.master||{urlSigned:e.url||e.urlSigned,width:e.width,height:e.height,mime:e.mime||e.mimeType},n.fileName=e.fileName||e.name,n.mime=e.mime||e.mimeType,n.width=e.width,n.height=e.height,n.fileBlob=e.fileBlob||e.file,n.metadata={uploadedBy:e.uploadedBy,uploadedAt:e.uploadedAt||e.timestamp,size:e.size,...e.metadata}):Object.assign(n,e)),n}_emitDOMEvent(e,t){if(this.destroyed)return;const n=new CustomEvent(`limbo:${e}`,{detail:t,bubbles:!0,cancelable:!0});(this.getContainer()||document).dispatchEvent(n),this.eventManager?.emit(e,t)}_validateConfig(){const e=te();if(!(this.config.auth?.apiKey||this.config.auth?.publicKey||this.config.auth?.token||this.config.apiKey||this.config.publicKey||this.config.token||this.config.tokenProvider||this.config.auth?.tokenProvider||e.token||e.publicKey||e.tokenProvider))throw new Error(`LimboInstance ${this.id}: Authentication is required. Provide either auth.publicKey (recommended), auth.apiKey (for server-side only), token, or tokenProvider`);if((this.config.auth?.apiKey||this.config.apiKey)&&"undefined"!=typeof window&&console.warn("⚠️ SECURITY WARNING: API Key detected in client-side code.\nThis is a security risk! Use publicKey instead for client applications.\nAPI Keys should only be used in server-side environments."),!["embed","modal","button"].includes(this.config.mode))throw new Error(`LimboInstance ${this.id}: invalid mode ${this.config.mode}`);if("embed"===this.config.mode&&!this.config.container)throw new Error(`LimboInstance ${this.id}: container is required for embed mode`);if("button"===this.config.mode&&!this.config.container)throw new Error(`LimboInstance ${this.id}: container is required for button mode`)}}class ml{constructor(){this.instances=new Map,this.counter=0}create(e,t,n){const l="limbo-"+ ++this.counter,r=new bl(l,e,t,n);return this.instances.set(l,r),r}get(e){return this.instances.get(e)}getAll(){return Array.from(this.instances.values())}getActive(){return this.getAll().filter(e=>e.isMounted())}destroy(e){const t=this.instances.get(e);return!!t&&(t.destroy(),this.instances.delete(e),!0)}destroyAll(){this.instances.forEach(e=>e.destroy()),this.instances.clear()}cleanupOrphans(){const e=[];return this.instances.forEach((t,n)=>{t.isContainerInDOM()||e.push(n)}),e.forEach(e=>this.destroy(e)),e.length}getStats(){const e=this.getAll();return{total:e.length,active:e.filter(e=>e.isMounted()).length,embed:e.filter(e=>"embed"===e.getMode()).length,modal:e.filter(e=>"modal"===e.getMode()).length,button:e.filter(e=>"button"===e.getMode()).length}}}class hl{constructor(){this.config=null,this.instances=new Map,this.observer=null,this.initialized=!1}configure(e,t,n){return this.config={selector:e.selector||null,dataset:e.dataset||"data-limbo-input-file",return:e.return||e.returnType||"json",mode:e.mode||"modal",features:e.features||["gallery","upload","cropper"],crop:e.crop||"free",quality:e.quality||.9,format:e.format||"webp",modeUI:e.modeUI||"full",modalSize:e.modalSize||"fullscreen",theme:e.theme||"light",compact:e.compact||!1,maxSize:e.maxSize||"10MB",formats:e.formats||["jpg","jpeg","png","webp"],minWidth:e.minWidth||null,minHeight:e.minHeight||null,maxWidth:e.maxWidth||null,maxHeight:e.maxHeight||null,buttonText:e.buttonText||"Seleccionar archivo",buttonClass:e.buttonClass||"limbo-auto-button",buttonStyle:e.buttonStyle||"primary",showPreview:!1!==e.showPreview,allowMultiple:e.allowMultiple||!1,autoAssign:!1!==e.autoAssign,localCropsOnly:e.localCropsOnly||!1,...e},this.configManager=t,this.eventManager=n,this._initialize(),this}cleanup(){this.observer&&(this.observer.disconnect(),this.observer=null),this.instances.forEach(({input:e,button:t})=>{this._restoreInput(e,t)}),this.instances.clear(),this.config=null,this.initialized=!1}getStats(){return{configured:null!==this.config,totalInputs:this.instances.size,dataset:this.config?.dataset,returnType:this.config?.return}}_initialize(){this.initialized||(this._scanExistingInputs(),this._setupObserver(),this.initialized=!0,this.eventManager.emit("autoInputs:initialized",{config:this.config,inputsFound:this.instances.size}))}_scanExistingInputs(){const e=this.config.selector||`input[${this.config.dataset}]`;document.querySelectorAll(e).forEach(e=>this._processInput(e))}_processInput(e){const t=this._getInputId(e);if(this.instances.has(t))return;if(!this._validateInput(e))return;const n=this._createButton(e);this._hideInput(e),this._insertButton(e,n),this.instances.set(t,{input:e,button:n,config:this._getInputConfig(e)}),this.eventManager.emit("autoInputs:processed",{inputId:t,input:e,button:n})}_createButton(e){const t=document.createElement("button"),n=this._getInputConfig(e);t.type="button",t.textContent=n.buttonText||this.config.buttonText;const l=[this.config.buttonClass];return n.buttonClass&&n.buttonClass!==this.config.buttonClass&&l.push(n.buttonClass),t.className=l.join(" "),this._styleButton(t,n),this._attachButtonEvents(t,e),t.setAttribute("aria-label",n.buttonText||this.config.buttonText),t.setAttribute("data-limbo-trigger","true"),t.setAttribute("data-limbo-input-id",n.inputId),n.disabled&&(t.disabled=!0),t}_styleButton(e,t){const n=t.buttonStyle||this.config.buttonStyle,l=t.theme||this.config.theme,r=t.compact||this.config.compact,a={border:"none",borderRadius:"8px",cursor:"pointer",fontFamily:"inherit",fontSize:r?"12px":"14px",fontWeight:"500",transition:"all 0.2s ease",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:r?"6px 12px":"8px 16px",textDecoration:"none",userSelect:"none"},i={primary:{backgroundColor:"dark"===l?"#3b82f6":"#001978",color:"white",hoverBg:"dark"===l?"#2563eb":"#334793"},secondary:{backgroundColor:"dark"===l?"#374151":"#f3f4f6",color:"dark"===l?"#f9fafb":"#374151",border:"1px solid "+("dark"===l?"#4b5563":"#d1d5db"),hoverBg:"dark"===l?"#4b5563":"#e5e7eb"},outline:{backgroundColor:"transparent",color:"dark"===l?"#3b82f6":"#001978",border:"2px solid "+("dark"===l?"#3b82f6":"#001978"),hoverBg:"dark"===l?"#3b82f6":"#001978",hoverColor:"white"},ghost:{backgroundColor:"transparent",color:"dark"===l?"#f9fafb":"#374151",hoverBg:"dark"===l?"#374151":"#f3f4f6"}},o=i[n]||i.primary;Object.assign(e.style,{...a,...o});const s=o.backgroundColor,c=o.color;e.addEventListener("mouseenter",()=>{e.style.backgroundColor=o.hoverBg||o.backgroundColor,o.hoverColor&&(e.style.color=o.hoverColor),e.style.transform="translateY(-1px)",e.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.15)"}),e.addEventListener("mouseleave",()=>{e.style.backgroundColor=s,e.style.color=c,e.style.transform="translateY(0)",e.style.boxShadow="none"}),t.disabled&&(e.style.opacity="0.5",e.style.cursor="not-allowed")}_attachButtonEvents(e,t){e.addEventListener("click",e=>{e.preventDefault(),this._handleButtonClick(t)})}_handleButtonClick(e){const t=this._getInputConfig(e),n=this._createModalConfig(t);this.eventManager.emit("autoInputs:modalRequest",{input:e,config:n,callback:async t=>await this._handleImageSelection(e,t)})}async _handleImageSelection(e,t){const n=this._getInputConfig(e);let l=t;try{if(!t.original&&!t.images&&(t.id||t.assetId)){console.log("[AutoInputManager] 🔗 Selección directa detectada, obteniendo URL permanente...");const e=t.id||t.assetId;try{const n=await async function(e,t=!0,n=!0,l=0){try{const r=new URLSearchParams({include_variants:t.toString(),include_metadata:n.toString(),url_expires:l.toString()});return ie(await ne({endpoint:`/assets/${e}?${r}`,method:"GET",basePath:ue,useJWT:!0}))}catch(r){throw ce(r)}}(e,!1,!1,!0);n?.result?.url?(console.log("[AutoInputManager] ✅ URL permanente obtenida:",n.result.url),l={original:{url:n.result.url,width:n.result.width||t.width,height:n.result.height||t.height,assetId:e},images:[]}):(console.warn("[AutoInputManager] ⚠️ No se pudo obtener URL permanente, usando URL temporal"),l={original:{url:t.url||t.path,width:t.width,height:t.height,assetId:e},images:[]})}catch(r){console.error("[AutoInputManager] Error obteniendo URL permanente:",r),l={original:{url:t.url||t.path,width:t.width,height:t.height,assetId:e},images:[]}}}const a=await this._formatImageData(l,n);console.log("[AutoInputManager] Valor formateado:",a),console.log("[AutoInputManager] Tipo de valor:",typeof a),!1!==n.autoAssign&&(e.value=a,console.log("[AutoInputManager] Valor asignado al input:",e.value)),this._updateButtonFeedback(e,l),e.dispatchEvent(new Event("change",{bubbles:!0})),e.dispatchEvent(new CustomEvent("limbo:resultReady",{detail:{imageData:l,input:e,value:a,config:n,assignment:{format:n.return,smartAssign:!1!==n.smartAssign,autoAssign:!1!==n.autoAssign},legacy:{imageData:l,formatted:this._createFormattedResult(l,n)}},bubbles:!0})),e.dispatchEvent(new CustomEvent("limbo:imageSelected",{detail:{imageData:l,input:e,value:a,config:n,formatted:this._createFormattedResult(l,n)},bubbles:!0})),this.eventManager.emit("autoInputs:imageSelected",{input:e,imageData:l,value:a,config:n})}catch(a){console.error("Error handling image selection:",a),e.dispatchEvent(new CustomEvent("limbo:error",{detail:{error:a.message,input:e,imageData:l,config:n},bubbles:!0})),this._handleImageSelectionLegacy(e,t)}}_updateButtonFeedback(e,t){const n=this._getInputId(e),l=this.instances.get(n);if(!l||!l.button)return;const r=l.button,a=r.nextElementSibling;a&&a.classList.contains("limbo-button-feedback")&&a.remove();const i=document.createElement("span");i.className="limbo-button-feedback",i.style.cssText="\n display: inline-flex;\n align-items: center;\n gap: 6px;\n margin-left: 8px;\n padding: 4px 8px;\n background: #10b981;\n color: white;\n border-radius: 6px;\n font-size: 12px;\n font-weight: 500;\n animation: limbo-fade-in 0.3s ease-out;\n ";const o=t.images&&t.images.length>0,s=o?t.images.length:0;i.innerHTML=o?`\n <svg width="14" height="14" viewBox="0 0 20 20" fill="currentColor">\n <path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd"/>\n </svg>\n <span>${s} recorte${1!==s?"s":""} configurado${1!==s?"s":""}</span>\n `:'\n <svg width="14" height="14" viewBox="0 0 20 20" fill="currentColor">\n <path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd"/>\n </svg>\n <span>Archivo seleccionado</span>\n ',r.parentNode.insertBefore(i,r.nextSibling);let c=r.parentNode.querySelector(".limbo-powered-by");c||(c=document.createElement("div"),c.className="limbo-powered-by",c.innerHTML='<span style="display:block;margin-top:2px;font-size:10px;color:#aaa;text-align:left;font-family:inherit;opacity:0.7;">Powered by <b>Limbo</b></span>',r.parentNode.insertBefore(c,i.nextSibling)),r.style.backgroundColor="#10b981",r.textContent="Cambiar archivo"}async _handleImageSelectionLegacy(e,t){const n=this._getInputConfig(e),l=await this._formatImageData(t,n);!1!==n.autoAssign&&(e.value=l),e.dispatchEvent(new Event("change",{bubbles:!0})),e.dispatchEvent(new CustomEvent("limbo:imageSelected",{detail:{imageData:t,input:e,value:l,config:n,formatted:this._createFormattedResult(t,n)},bubbles:!0})),this.eventManager.emit("autoInputs:imageSelected",{input:e,imageData:t,value:l,config:n})}_createFormattedResult(e,t){return{url:e.url||e.path||"",base64:e.base64||e.dataUrl||"",assetId:e.assetId||e.id||"",fileName:e.fileName||e.filename||"",object:{url:e.url||e.path,assetId:e.assetId||e.id,fileName:e.fileName||e.filename,mime:e.mime||e.mime_type,width:e.width,height:e.height,size:e.size||e.file_size,created:e.created_at||e.created,metadata:e.metadata||{}},json:JSON.stringify({url:e.url||e.path,assetId:e.assetId||e.id,fileName:e.fileName||e.filename,mime:e.mime||e.mime_type,width:e.width,height:e.height,size:e.size||e.file_size}),metadata:{width:e.width,height:e.height,size:e.size||e.file_size,format:e.format||e.mime_type,quality:t.quality||this.config.quality,aspectRatio:e.width&&e.height?e.width/e.height:null}}}async _formatImageData(e,t=null){const n=(t||{}).return||this.config.return||"json",l=void 0!==e.original;switch(n){case"url":return l?e.images?.[0]?.url||e.original?.url||"":e.url||e.path||"";case"base64":return e.base64||e.dataUrl||"";case"assetId":return l?e.original?.assetId||"":e.assetId||e.id||"";case"fileName":return e.fileName||e.filename||"";default:try{if(l){const t={original:e.original?{url:e.original.url||e.original.urlSigned,width:e.original.width,height:e.original.height,assetId:e.original.assetId||e.original.id}:null,images:Array.isArray(e.images)?e.images.map(e=>{const t={url:e.url||e.urlSigned,width:e.width,height:e.height,name:e.name||e.filename||e.label};return e.cropState&&(t.cropState={selectorState:e.cropState.selectorState||null,imageTransform:e.cropState.imageTransform||null,flipState:e.cropState.flipState||null}),t}):[]};console.log("[AutoInputManager] Datos limpios para JSON:",t);const n=JSON.stringify(t);return console.log("[AutoInputManager] JSON generado:",n),n}const t={original:{url:e.url||e.path,width:e.width,height:e.height,assetId:e.assetId||e.id}};return console.log("[AutoInputManager] Datos legacy para JSON:",t),JSON.stringify(t)}catch(r){return console.error("[AutoInputManager] Error al serializar JSON:",r),console.error("[AutoInputManager] imageData problemático:",e),"{}"}}}_createModalConfig(e){return{mode:e.mode||this.config.mode||"modal",modeUI:e.modeUI||this.config.modeUI||"full",features:e.features||this.config.features,modalSize:e.modalSize||this.config.modalSize||"fullscreen",title:e.description||this.config.title||"Seleccionar archivo",cropper:this._getCropperConfig(e),ui:{showActions:this._getUIActions(e),hideActions:[],showTabs:this._shouldShowTabs(e),theme:e.theme||this.config.theme,compact:e.compact||this.config.compact,showPreview:void 0!==e.showPreview?e.showPreview:this.config.showPreview},validation:{accept:e.accept||null,maxSize:e.maxSize||this.config.maxSize,formats:e.formats||this.config.formats,minWidth:e.minWidth||this.config.minWidth,minHeight:e.minHeight||this.config.minHeight,maxWidth:e.maxWidth||this.config.maxWidth,maxHeight:e.maxHeight||this.config.maxHeight,required:e.required||!1},behavior:{allowMultiple:e.allowMultiple||this.config.allowMultiple,closeOnSelect:!0,autoAssign:void 0!==e.autoAssign?e.autoAssign:this.config.autoAssign,allowSelectNew:!1!==e.allowSelectNew},initialImageUrl:e.initialImageUrl||null,existingCrops:e.existingCrops||null,existingData:e.existingData||null,returnConfig:{format:e.return||this.config.return,quality:e.quality||this.config.quality,outputFormat:e.format||this.config.format},inputMeta:{inputId:e.inputId,inputName:e.inputName,inputType:e.inputType,placeholder:e.placeholder}}}_getCropperConfig(e){const t=e.crop||this.config.crop,n={quality:e.quality||this.config.quality,format:e.format||this.config.format,mandatoryCrops:e.mandatoryCrops||[],allowAdditionalCrops:!1!==e.allowAdditionalCrops,maxCrops:e.maxCrops||null,localCropsOnly:e.localCropsOnly??this.config.localCropsOnly??!1,existingCrops:e.existingCrops||null};if(e.mandatoryCrops&&e.mandatoryCrops.length>0)return{...n,aspectRatio:null};if(!t||"none"===t||"false"===t)return null;if("free"===t)return{...n,aspectRatio:null};const l={"1:1":1,"16:9":16/9,"4:3":4/3,"3:2":1.5,"2:1":2,square:1,landscape:16/9,portrait:3/4};if(l[t])return{...n,aspectRatio:l[t],minCropBoxWidth:e.minWidth||this.config.minWidth,minCropBoxHeight:e.minHeight||this.config.minHeight};if("string"==typeof t&&t.includes(":")){const[e,l]=t.split(":").map(Number);if(!isNaN(e)&&!isNaN(l)&&0!==l)return{...n,aspectRatio:e/l}}const r=parseFloat(t);return!isNaN(r)&&r>0?{...n,aspectRatio:r}:"object"==typeof t?{...n,...t}:null}_shouldShowTabs(e){const t=e.modeUI||this.config.modeUI||"full",n=e.features||this.config.features;return!["gallery-only","upload-only","crop-only","ia-only"].includes(t)&&(n&&n.length>1)}_getUIActions(e){const t=e.modeUI||this.config.modeUI||"full",n=e.features||this.config.features;let l=[];switch(t){case"gallery-only":case"upload-only":l=["select"];break;case"crop-only":l=["select","crop"];break;default:l=["select"],n.includes("cropper")&&l.push("crop"),n.includes("gallery")&&(l.push("download","copy"),this.config.allowDelete&&l.push("delete"))}return l}_getInputId(e){if(e.id)return e.id;if(e.name)return e.name;let t=e.getAttribute("data-limbo-uid");return t||(t=`limbo-auto-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,e.setAttribute("data-limbo-uid",t)),t}_validateInput(e){return e instanceof HTMLInputElement}_getInputConfig(e){const t=e=>e?e.split(",").map(e=>e.trim()):null,n=e=>{if(!e)return null;const t=e.match(/^(\d+(?:\.\d+)?)(MB|KB|B)?$/i);if(!t)return null;const n=parseFloat(t[1]);switch((t[2]||"B").toUpperCase()){case"MB":return 1024*n*1024;case"KB":return 1024*n;default:return n}},l=(e,t=!1)=>null===e?t:"true"===e||"1"===e||""===e,r=e=>e?parseFloat(e):null,a=e=>{if(!e)return null;try{return JSON.parse(e)}catch(t){return console.warn("[Limbo AutoInputManager] Error parsing JSON attribute:",t),null}},i=a(e.dataset.mandatorycrops)||a(e.dataset.mandatoryCrops)||a(e.getAttribute("data-mandatory-crops"))||a(e.getAttribute("data-limbo-mandatory-crops"))||null;return{return:e.dataset.returntype||e.getAttribute("data-limbo-return")||this.config.return,mode:e.dataset.mode||e.getAttribute("data-limbo-mode")||this.config.mode,features:t(e.dataset.features)||t(e.getAttribute("data-limbo-features"))||this.config.features,crop:e.dataset.crop||e.getAttribute("data-limbo-crop")||this.config.crop,quality:r(e.dataset.quality)||r(e.getAttribute("data-limbo-quality"))||this.config.quality,format:e.dataset.format||e.getAttribute("data-limbo-format")||this.config.format,modeUI:e.dataset.modeui||e.dataset.modeUI||e.getAttribute("data-limbo-mode-ui")||this.config.modeUI,modalSize:e.dataset.modalsize||e.getAttribute("data-limbo-modal-size")||this.config.modalSize,theme:e.dataset.theme||e.getAttribute("data-limbo-theme")||this.config.theme,compact:l(e.dataset.compact,null)??l(e.getAttribute("data-limbo-compact"),this.config.compact),maxSize:n(e.getAttribute("data-limbo-max-size"))||n(this.config.maxSize),formats:t(e.getAttribute("data-limbo-formats"))||this.config.formats,minWidth:r(e.getAttribute("data-limbo-min-width"))||this.config.minWidth,minHeight:r(e.getAttribute("data-limbo-min-height"))||this.config.minHeight,maxWidth:r(e.getAttribute("data-limbo-max-width"))||this.config.maxWidth,maxHeight:r(e.getAttribute("data-limbo-max-height"))||this.config.maxHeight,buttonText:e.dataset.buttontext||e.getAttribute("data-limbo-button-text")||this.config.buttonText,buttonStyle:e.dataset.buttonstyle||e.getAttribute("data-limbo-button-style")||this.config.buttonStyle,buttonClass:e.dataset.buttonclass||e.getAttribute("data-limbo-button-class")||this.config.buttonClass,showPreview:l(e.getAttribute("data-limbo-show-preview"),this.config.showPreview),allowMultiple:l(e.getAttribute("data-limbo-allow-multiple"),this.config.allowMultiple),autoAssign:l(e.getAttribute("data-limbo-auto-assign"),this.config.autoAssign),placeholder:e.getAttribute("data-limbo-placeholder"),description:e.getAttribute("data-limbo-description"),required:l(e.getAttribute("data-limbo-required"),!1),disabled:l(e.getAttribute("data-limbo-disabled"),!1),inputId:this._getInputId(e),inputName:e.name,inputType:e.type,mandatoryCrops:i,allowAdditionalCrops:l(e.dataset.allowadditionalcrops,null)??l(e.getAttribute("data-limbo-allow-additional-crops"),!0),maxCrops:r(e.dataset.maxcrops)||r(e.getAttribute("data-limbo-max-crops"))||null,accept:e.dataset.accept||e.getAttribute("data-limbo-accept")||null,allowSelectNew:l(e.dataset.allowselectnew,null)??l(e.getAttribute("data-limbo-allow-select-new"),!0),...this._parseExistingInputValue(e.value)}}_parseExistingInputValue(e){if(!e||""===e.trim())return{initialImageUrl:null,existingCrops:null,existingData:null};try{const t=JSON.parse(e);return t.original&&t.original.url?(console.log("[AutoInputManager] Valor existente parseado:",t),{initialImageUrl:t.original.url,existingCrops:t.images||null,existingData:t}):t.url?{initialImageUrl:t.url,existingCrops:null,existingData:t}:{initialImageUrl:null,existingCrops:null,existingData:t}}catch(t){return e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")?{initialImageUrl:e,existingCrops:null,existingData:null}:{initialImageUrl:null,existingCrops:null,existingData:null}}}_generateInputId(){return`limbo-auto-input-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}_hideInput(e){e.style.display="none"}_insertButton(e,t){e.parentNode.insertBefore(t,e.nextSibling)}_restoreInput(e,t){e.style.display="",t&&t.parentNode&&t.parentNode.removeChild(t)}_setupObserver(){this.observer=new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&this._scanNodeForInputs(e)})})}),this.observer.observe(document.body,{childList:!0,subtree:!0})}_scanNodeForInputs(e){const t=this.config.selector||`input[${this.config.dataset}]`;e.matches&&e.matches(t)&&this._processInput(e);const n=e.querySelectorAll&&e.querySelectorAll(t);n&&n.forEach(e=>this._processInput(e))}}class pl{constructor(){this.listeners=new Map}emit(e,t={}){this._emitDOMEvent(e,t),this._executeListeners(e,t)}on(e,t){return this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t),()=>this.off(e,t)}off(e,t){const n=this.listeners.get(e);if(n){const e=n.indexOf(t);e>-1&&n.splice(e,1)}}cleanup(){this.listeners.clear()}_emitDOMEvent(e,t){const n=new CustomEvent(`limbo:${e}`,{detail:{...t,timestamp:Date.now()},bubbles:!0,cancelable:!0});(t.instance?.getContainer()||document).dispatchEvent(n)}_executeListeners(e,t){const n=this.listeners.get(e);n&&n.forEach(n=>{try{n(t)}catch(l){console.error(`Error executing listener for ${e}:`,l)}})}getStats(){const e={};return this.listeners.forEach((t,n)=>{e[n]=t.length}),e}}class fl{constructor(){this.activeModals=new Set,this.zIndexBase=1e4,this.focusableSelectors=["button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"]):not([disabled])',"a[href]"].join(", "),this.initialized=!1,this._initGlobalListeners()}createModal(e){const t=new gl(this._generateModalId(),e,this);return this.activeModals.add(t),t}closeModal(e){const t=this._findModal(e);return!!t&&(t.close(),!0)}closeAllModals(){this.activeModals.forEach(e=>e.close()),this.activeModals.clear()}getActiveModal(){return Array.from(this.activeModals).pop()||null}getStats(){return{active:this.activeModals.size,nextZIndex:this._getNextZIndex()}}_generateModalId(){return`limbo-modal-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}_findModal(e){return Array.from(this.activeModals).find(t=>t.getId()===e)}_getNextZIndex(){return this.zIndexBase+10*this.activeModals.size}_removeModal(e){this.activeModals.delete(e),window.limboCore?.events&&window.limboCore.events.emit("modal:closed",{modalId:e.getId(),remainingModals:this.activeModals.size})}_handleGlobalKeydown(e){const t=this.getActiveModal();t&&("Escape"===e.key&&(e.preventDefault(),t.close()),"Tab"===e.key&&this._handleTabTrap(e,t))}_handleTabTrap(e,t){const n=t.getFocusableElements();if(0===n.length)return;const l=n[0],r=n[n.length-1];e.shiftKey?document.activeElement===l&&(e.preventDefault(),r.focus()):document.activeElement===r&&(e.preventDefault(),l.focus())}_initGlobalListeners(){this.initialized||(this.globalKeydownHandler=e=>this._handleGlobalKeydown(e),document.addEventListener("keydown",this.globalKeydownHandler),this.initialized=!0)}destroy(){this.closeAllModals(),this.initialized&&this.globalKeydownHandler&&(document.removeEventListener("keydown",this.globalKeydownHandler),this.initialized=!1,this.globalKeydownHandler=null)}}class gl{constructor(e,t,n){this.id=e,this.config={title:t.title||"Limbo",content:t.content||null,showCloseButton:!1!==t.showCloseButton,backdrop:!1!==t.backdrop,keyboard:!1!==t.keyboard,focus:!1!==t.focus,animation:!1!==t.animation,size:t.size||"large",onOpen:t.onOpen||null,onClose:t.onClose||null,onDestroy:t.onDestroy||null,...t},this.manager=n,this.element=null,this.backdrop=null,this.isOpen=!1,this.previousFocus=null,this._create()}_create(){this._createBackdrop(),this._createModal(),this._attachEvents()}_createBackdrop(){this.config.backdrop&&(this.backdrop=document.createElement("div"),this.backdrop.className="limbo-modal-backdrop",this.backdrop.style.cssText=`\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.5);\n z-index: ${this.manager._getNextZIndex()};\n opacity: 0;\n transition: opacity 0.3s ease;\n `,this.backdrop.addEventListener("click",e=>{e.target===this.backdrop&&this.close()}))}_createModal(){this.element=document.createElement("div"),this.element.className=`limbo-scope limbo-modal limbo-modal--${this.config.size}`,this.element.id=this.id,this.element.role="dialog",this.element.setAttribute("aria-modal","true"),this.element.setAttribute("aria-labelledby",`${this.id}-title`),this.element.tabIndex=-1;const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),t={small:e?"width: 100%; height: 100%;":"max-width: 500px; min-height: 400px;",medium:e?"width: 100%; height: 100%;":"max-width: 800px; min-height: 500px;",large:e?"width: 100%; height: 100%;":"max-width: 1400px; min-height: 700px;",xlarge:e?"width: 100%; height: 100%;":"max-width: 95dvw; min-height: 85vh;",fullscreen:"width: 100%; height: 100%; max-width: 100%; max-height: 100%; border-radius: 0;"},n="fullscreen"===this.config.size,l=e||n?`\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n transform: ${e?"translateY(100%)":"scale(0.95)"};\n width: 100%;\n height: 100%;\n max-width: none;\n max-height: none;\n border-radius: 0;\n background: white;\n z-index: ${this.manager._getNextZIndex()+1};\n opacity: ${e?"1":"0"};\n transition: ${e?"transform":"all"} 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n overflow: hidden;\n display: flex;\n flex-direction: column;\n padding-top: env(safe-area-inset-top);\n padding-left: env(safe-area-inset-left);\n padding-right: env(safe-area-inset-right);\n padding-bottom: env(safe-area-inset-bottom);\n `:`\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%) scale(0.8);\n ${t[this.config.size]}\n width: 90%;\n max-height: 90vh;\n background: white;\n border-radius: 16px;\n box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);\n z-index: ${this.manager._getNextZIndex()+1};\n opacity: 0;\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n overflow: hidden;\n display: flex;\n flex-direction: column;\n `;this.element.style.cssText=l,this._createHeader(),this._createBody(),document.body.appendChild(this.backdrop),document.body.appendChild(this.element)}_createHeader(){const e=document.createElement("div");e.className="limbo-modal-header";const t=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);e.style.cssText=`\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: ${t?"16px 20px":"20px 24px"};\n border-bottom: 1px solid #e9ecef;\n background: #f8f9fa;\n ${t?"position: sticky; top: 0; z-index: 10;":""}\n min-height: ${t?"60px":"auto"};\n `;const n=document.createElement("h2");if(n.id=`${this.id}-title`,n.className="limbo-modal-title",n.textContent=this.config.title,n.style.cssText="\n margin: 0;\n font-size: 18px;\n font-weight: 600;\n color: #001978;\n flex: 1;\n margin-right: 16px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n ",e.appendChild(n),this.config.showCloseButton){const n=document.createElement("button");n.type="button",n.className="limbo-modal-close",n.innerHTML="✕",n.setAttribute("aria-label","Cerrar modal"),n.style.cssText=`\n background: none;\n border: none;\n font-size: ${t?"28px":"24px"};\n color: #6c757d;\n cursor: pointer;\n padding: ${t?"8px":"4px"};\n border-radius: 4px;\n transition: all 0.2s ease;\n min-width: ${t?"44px":"auto"};\n min-height: ${t?"44px":"auto"};\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n `,n.addEventListener("mouseenter",()=>{n.style.backgroundColor="#f8f9fa",n.style.color="#001978"}),n.addEventListener("mouseleave",()=>{n.style.backgroundColor="transparent",n.style.color="#6c757d"}),n.addEventListener("click",()=>this.close()),e.appendChild(n)}this.element.appendChild(e)}_createBody(){const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),t=document.createElement("div");t.className="limbo-modal-body",t.id=`${this.id}-body`,t.style.cssText=`\n flex: 1;\n overflow-y: auto;\n padding: 0;\n -webkit-overflow-scrolling: touch;\n ${e?"height: 100%; overscroll-behavior: contain;":""}\n `,this.config.content&&("string"==typeof this.config.content?t.innerHTML=this.config.content:this.config.content instanceof Element&&t.appendChild(this.config.content)),this.element.appendChild(t)}_attachEvents(){this._originalBodyOverflow=document.body.style.overflow}open(){if(this.isOpen)return this;window.limbo&&window.limbo.core&&window.limbo.core.keyboard?(window.limbo.core.keyboard.pushFocus(document.activeElement),window.limbo.core.keyboard.setActiveModal(this.element)):this.previousFocus=document.activeElement,document.body.style.overflow="hidden";const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),t="fullscreen"===this.config.size;return requestAnimationFrame(()=>{this.backdrop&&(this.backdrop.style.opacity="1"),this.element.style.opacity="1",this.element.style.transform=e?"translateY(0%)":t?"scale(1)":"translate(-50%, -50%) scale(1)"}),this.isOpen=!0,this.config.focus&&setTimeout(()=>{if(window.limbo&&window.limbo.core&&window.limbo.core.keyboard)window.limbo.core.keyboard.focusFirst(this.element);else{const e=this.getFocusableElements()[0];e&&e.focus()}},300),this.config.onOpen&&this.config.onOpen(this),this}close(){if(!this.isOpen)return this;const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),t="fullscreen"===this.config.size;return this.backdrop&&(this.backdrop.style.opacity="0"),this.element.style.opacity="0",this.element.style.transform=e?"translateY(100%)":t?"scale(0.95)":"translate(-50%, -50%) scale(0.8)",setTimeout(()=>{this._cleanup()},300),this.isOpen=!1,window.limbo&&window.limbo.core&&window.limbo.core.keyboard&&(window.limbo.core.keyboard.setActiveModal(null),window.limbo.core.keyboard.releaseFocus()),this.config.onClose&&this.config.onClose(this),this}destroy(){this.close(),this.manager._removeModal(this),this.config.onDestroy&&this.config.onDestroy(this)}getBodyContainer(){return this.element.querySelector(".limbo-modal-body")}getFocusableElements(){return Array.from(this.element.querySelectorAll(this.manager.focusableSelectors))}getId(){return this.id}isOpened(){return this.isOpen}getConfig(){return{...this.config}}_cleanup(){document.body.style.overflow=this._originalBodyOverflow||"",this.previousFocus&&"function"==typeof this.previousFocus.focus&&this.previousFocus.focus(),this.backdrop&&this.backdrop.parentNode&&this.backdrop.parentNode.removeChild(this.backdrop),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}class yl{constructor(){this.currentTheme=null,this.customThemes=new Map,this.config=this._getDefaultConfig(),this.isInitialized=!1,this.isCompactMode=!1,this.compactBreakpoint=null,this.compactObserver=null,this.mediaQueryObserver=null,this.mutationObserver=null,this.storageListener=null,this.themeCache=new Map,this.appliedStyles=new Set,this.changeCallbacks=new Set}_getDefaultConfig(){return{theme:{auto:!0,storage:!0,inherit:!0,smooth:!0,detectSystem:!0},compact:{enabled:!1,auto:!0,breakpoint:768,forceOnMobile:!0,persistPreference:!0},presets:{light:{name:"light",displayName:"Claro",variables:{"--limbo-primary":"#3b82f6","--limbo-primary-hover":"#2563eb","--limbo-primary-light":"#dbeafe","--limbo-primary-dark":"#1e40af","--limbo-bg-primary":"#ffffff","--limbo-bg-secondary":"#f8fafc","--limbo-bg-tertiary":"#f1f5f9","--limbo-bg-overlay":"rgba(0, 0, 0, 0.5)","--limbo-bg-card":"#ffffff","--limbo-bg-input":"#ffffff","--limbo-text-primary":"#0f172a","--limbo-text-secondary":"#475569","--limbo-text-tertiary":"#64748b","--limbo-text-inverse":"#ffffff","--limbo-text-muted":"#94a3b8","--limbo-border-light":"#e2e8f0","--limbo-border-medium":"#cbd5e1","--limbo-border-strong":"#94a3b8","--limbo-border-focus":"#3b82f6","--limbo-success":"#10b981","--limbo-success-light":"#d1fae5","--limbo-error":"#ef4444","--limbo-error-light":"#fee2e2","--limbo-warning":"#f59e0b","--limbo-warning-light":"#fef3c7","--limbo-info":"#3b82f6","--limbo-info-light":"#dbeafe","--limbo-shadow-sm":"0 1px 2px 0 rgba(0, 0, 0, 0.05)","--limbo-shadow-md":"0 4px 6px -1px rgba(0, 0, 0, 0.1)","--limbo-shadow-lg":"0 10px 15px -3px rgba(0, 0, 0, 0.1)","--limbo-shadow-xl":"0 20px 25px -5px rgba(0, 0, 0, 0.1)","--limbo-radius-sm":"4px","--limbo-radius-md":"6px","--limbo-radius-lg":"8px","--limbo-radius-xl":"12px","--limbo-font-family":"system-ui, -apple-system, sans-serif","--limbo-font-size-xs":"12px","--limbo-font-size-sm":"14px","--limbo-font-size-md":"16px","--limbo-font-size-lg":"18px","--limbo-font-size-xl":"20px","--limbo-z-dropdown":"1000","--limbo-z-sticky":"1020","--limbo-z-fixed":"1030","--limbo-z-modal":"1050","--limbo-z-tooltip":"1070","--limbo-transition-fast":"150ms cubic-bezier(0.4, 0, 0.2, 1)","--limbo-transition-normal":"300ms cubic-bezier(0.4, 0, 0.2, 1)","--limbo-transition-slow":"500ms cubic-bezier(0.4, 0, 0.2, 1)","--limbo-spacing-compact":"0.5rem","--limbo-spacing-compact-sm":"0.25rem","--limbo-spacing-compact-lg":"0.75rem","--limbo-font-size-compact-xs":"11px","--limbo-font-size-compact-sm":"12px","--limbo-font-size-compact-md":"14px","--limbo-font-size-compact-lg":"16px","--limbo-radius-compact":"4px","--limbo-radius-compact-sm":"3px","--limbo-radius-compact-lg":"6px","--limbo-button-height-compact":"32px","--limbo-input-height-compact":"36px","--limbo-modal-padding-compact":"12px","--limbo-card-padding-compact":"12px","--limbo-gap-compact":"8px","--limbo-gap-compact-sm":"4px","--limbo-gap-compact-lg":"12px"}},dark:{name:"dark",displayName:"Oscuro",variables:{"--limbo-primary":"#60a5fa","--limbo-primary-hover":"#3b82f6","--limbo-primary-light":"#1e293b","--limbo-primary-dark":"#93c5fd","--limbo-bg-primary":"#0f172a","--limbo-bg-secondary":"#1e293b","--limbo-bg-tertiary":"#334155","--limbo-bg-overlay":"rgba(0, 0, 0, 0.8)","--limbo-bg-card":"#1e293b","--limbo-bg-input":"#334155","--limbo-text-primary":"#f8fafc","--limbo-text-secondary":"#cbd5e1","--limbo-text-tertiary":"#94a3b8","--limbo-text-inverse":"#0f172a","--limbo-text-muted":"#64748b","--limbo-border-light":"#334155","--limbo-border-medium":"#475569","--limbo-border-strong":"#64748b","--limbo-border-focus":"#60a5fa","--limbo-success":"#34d399","--limbo-success-light":"#064e3b","--limbo-error":"#f87171","--limbo-error-light":"#7f1d1d","--limbo-warning":"#fbbf24","--limbo-warning-light":"#78350f","--limbo-info":"#60a5fa","--limbo-info-light":"#1e3a8a","--limbo-shadow-sm":"0 1px 2px 0 rgba(0, 0, 0, 0.2)","--limbo-shadow-md":"0 4px 6px -1px rgba(0, 0, 0, 0.3)","--limbo-shadow-lg":"0 10px 15px -3px rgba(0, 0, 0, 0.4)","--limbo-shadow-xl":"0 20px 25px -5px rgba(0, 0, 0, 0.5)","--limbo-radius-sm":"4px","--limbo-radius-md":"6px","--limbo-radius-lg":"8px","--limbo-radius-xl":"12px","--limbo-font-family":"system-ui, -apple-system, sans-serif","--limbo-font-size-xs":"12px","--limbo-font-size-sm":"14px","--limbo-font-size-md":"16px","--limbo-font-size-lg":"18px","--limbo-font-size-xl":"20px","--limbo-z-dropdown":"1000","--limbo-z-sticky":"1020","--limbo-z-fixed":"1030","--limbo-z-modal":"1050","--limbo-z-tooltip":"1070","--limbo-transition-fast":"150ms cubic-bezier(0.4, 0, 0.2, 1)","--limbo-transition-normal":"300ms cubic-bezier(0.4, 0, 0.2, 1)","--limbo-transition-slow":"500ms cubic-bezier(0.4, 0, 0.2, 1)","--limbo-spacing-compact":"0.5rem","--limbo-spacing-compact-sm":"0.25rem","--limbo-spacing-compact-lg":"0.75rem","--limbo-font-size-compact-xs":"11px","--limbo-font-size-compact-sm":"12px","--limbo-font-size-compact-md":"14px","--limbo-font-size-compact-lg":"16px","--limbo-radius-compact":"4px","--limbo-radius-compact-sm":"3px","--limbo-radius-compact-lg":"6px","--limbo-button-height-compact":"32px","--limbo-input-height-compact":"36px","--limbo-modal-padding-compact":"12px","--limbo-card-padding-compact":"12px","--limbo-gap-compact":"8px","--limbo-gap-compact-sm":"4px","--limbo-gap-compact-lg":"12px"}},auto:{name:"auto",displayName:"Automático",variables:{}}},inheritance:{portalSelectors:["body","[data-theme]",".theme-light",".theme-dark",".light-theme",".dark-theme"],variablePrefix:"--",fallbackTheme:"light"},transitions:{duration:"300ms",easing:"cubic-bezier(0.4, 0, 0.2, 1)",properties:["background-color","border-color","color","fill","stroke","box-shadow"]}}}initialize(e={}){this.isInitialized?console.warn("ThemeManager already initialized"):(this.config=this._deepMerge(this.config,e),this._loadCustomThemes(),this.config.theme.inherit&&this._inheritPortalTheme(),this._applyInitialTheme(),this._applyInitialCompactMode(),this._setupObservers(),this._injectBaseStyles(),this.isInitialized=!0)}_injectBaseStyles(){if(document.getElementById("limbo-theme-styles"))return;const e=`\n :root {\n /* Variables de transición para cambios de tema */\n color-scheme: light dark;\n }\n \n [data-limbo-theme] {\n transition: ${this.config.transitions.properties.map(e=>`${e} ${this.config.transitions.duration} ${this.config.transitions.easing}`).join(", ")};\n }\n \n /* Clases de utilidad para temas */\n .limbo-theme-light {\n color-scheme: light;\n }\n \n .limbo-theme-dark {\n color-scheme: dark;\n }\n \n .limbo-theme-auto {\n color-scheme: light dark;\n }\n \n /* Estilos para elementos del componente con variables CSS */\n .limbo-component {\n background-color: var(--limbo-bg-primary);\n color: var(--limbo-text-primary);\n border-color: var(--limbo-border-light);\n border-radius: var(--limbo-radius-md);\n font-family: var(--limbo-font-family);\n font-size: var(--limbo-font-size-md);\n transition: var(--limbo-transition-normal);\n }\n \n .limbo-card {\n background-color: var(--limbo-bg-card);\n border: 1px solid var(--limbo-border-light);\n border-radius: var(--limbo-radius-lg);\n box-shadow: var(--limbo-shadow-md);\n color: var(--limbo-text-primary);\n }\n \n .limbo-input {\n background-color: var(--limbo-bg-input);\n border: 1px solid var(--limbo-border-medium);\n border-radius: var(--limbo-radius-md);\n color: var(--limbo-text-primary);\n font-family: var(--limbo-font-family);\n font-size: var(--limbo-font-size-md);\n transition: var(--limbo-transition-fast);\n }\n \n .limbo-input:focus {\n border-color: var(--limbo-border-focus);\n box-shadow: 0 0 0 3px var(--limbo-primary-light);\n outline: none;\n }\n \n .limbo-button {\n background-color: var(--limbo-primary);\n border: 1px solid var(--limbo-primary);\n border-radius: var(--limbo-radius-md);\n color: var(--limbo-text-inverse);\n font-family: var(--limbo-font-family);\n font-size: var(--limbo-font-size-md);\n transition: var(--limbo-transition-fast);\n cursor: pointer;\n }\n \n .limbo-button:hover {\n background-color: var(--limbo-primary-hover);\n border-color: var(--limbo-primary-hover);\n }\n \n .limbo-button.secondary {\n background-color: var(--limbo-bg-secondary);\n border-color: var(--limbo-border-medium);\n color: var(--limbo-text-primary);\n }\n \n .limbo-button.secondary:hover {\n background-color: var(--limbo-bg-tertiary);\n }\n \n /* Estados de feedback con variables */\n .limbo-state-success {\n background-color: var(--limbo-success-light);\n border-color: var(--limbo-success);\n color: var(--limbo-success);\n }\n \n .limbo-state-error {\n background-color: var(--limbo-error-light);\n border-color: var(--limbo-error);\n color: var(--limbo-error);\n }\n \n .limbo-state-warning {\n background-color: var(--limbo-warning-light);\n border-color: var(--limbo-warning);\n color: var(--limbo-warning);\n }\n \n .limbo-state-info {\n background-color: var(--limbo-info-light);\n border-color: var(--limbo-info);\n color: var(--limbo-info);\n }\n \n /* Overlay y modal con variables */\n .limbo-overlay {\n background-color: var(--limbo-bg-overlay);\n backdrop-filter: blur(4px);\n }\n \n .limbo-modal {\n background-color: var(--limbo-bg-card);\n border-radius: var(--limbo-radius-xl);\n box-shadow: var(--limbo-shadow-xl);\n color: var(--limbo-text-primary);\n }\n \n /* Responsive design con variables */\n @media (max-width: 640px) {\n .limbo-component {\n font-size: var(--limbo-font-size-sm);\n }\n }\n \n /* Modo reducido de movimiento */\n @media (prefers-reduced-motion: reduce) {\n [data-limbo-theme] {\n transition: none;\n }\n \n .limbo-component,\n .limbo-input,\n .limbo-button {\n transition: none;\n }\n }\n \n /* Esquemas de color automático */\n @media (prefers-color-scheme: dark) {\n :root:not([data-limbo-theme]) {\n color-scheme: dark;\n }\n }\n \n @media (prefers-color-scheme: light) {\n :root:not([data-limbo-theme]) {\n color-scheme: light;\n }\n }\n \n /* ===================================\n MODO COMPACTO - ESTILOS ESPECÍFICOS \n =================================== */\n \n /* Activación del modo compacto por atributo o clase */\n [data-limbo-compact="true"],\n .limbo-compact-mode {\n /* Componentes base más pequeños */\n --limbo-font-size-md: var(--limbo-font-size-compact-md);\n --limbo-font-size-sm: var(--limbo-font-size-compact-sm);\n --limbo-font-size-lg: var(--limbo-font-size-compact-lg);\n --limbo-spacing: var(--limbo-spacing-compact);\n --limbo-radius-md: var(--limbo-radius-compact);\n --limbo-gap: var(--limbo-gap-compact);\n }\n \n /* Botones compactos */\n [data-limbo-compact="true"] .limbo-button,\n .limbo-compact-mode .limbo-button {\n height: var(--limbo-button-height-compact);\n padding: var(--limbo-spacing-compact-sm) var(--limbo-spacing-compact);\n font-size: var(--limbo-font-size-compact-sm);\n border-radius: var(--limbo-radius-compact);\n min-width: auto;\n }\n \n /* Inputs compactos */\n [data-limbo-compact="true"] .limbo-input,\n .limbo-compact-mode .limbo-input {\n height: var(--limbo-input-height-compact);\n padding: var(--limbo-spacing-compact-sm) var(--limbo-spacing-compact);\n font-size: var(--limbo-font-size-compact-md);\n border-radius: var(--limbo-radius-compact);\n }\n \n /* Cards compactas */\n [data-limbo-compact="true"] .limbo-card,\n .limbo-compact-mode .limbo-card {\n padding: var(--limbo-card-padding-compact);\n border-radius: var(--limbo-radius-compact-lg);\n }\n \n /* Modales compactos */\n [data-limbo-compact="true"] .limbo-modal,\n .limbo-compact-mode .limbo-modal {\n padding: var(--limbo-modal-padding-compact);\n border-radius: var(--limbo-radius-compact-lg);\n max-width: 90vw;\n max-height: 90vh;\n }\n \n /* Tabs compactas */\n [data-limbo-compact="true"] .limbo-tabs,\n .limbo-compact-mode .limbo-tabs {\n gap: var(--limbo-gap-compact-sm);\n }\n \n [data-limbo-compact="true"] .limbo-tab,\n .limbo-compact-mode .limbo-tab {\n padding: var(--limbo-spacing-compact-sm) var(--limbo-spacing-compact);\n font-size: var(--limbo-font-size-compact-sm);\n border-radius: var(--limbo-radius-compact-sm);\n }\n \n /* Gallery compacta */\n [data-limbo-compact="true"] .limbo-gallery,\n .limbo-compact-mode .limbo-gallery {\n gap: var(--limbo-gap-compact-sm);\n }\n \n [data-limbo-compact="true"] .limbo-gallery-item,\n .limbo-compact-mode .limbo-gallery-item {\n border-radius: var(--limbo-radius-compact);\n min-height: 120px; /* Más pequeño para móviles */\n }\n \n /* Notificaciones compactas */\n [data-limbo-compact="true"] .limbo-notification,\n .limbo-compact-mode .limbo-notification {\n padding: var(--limbo-spacing-compact-sm) var(--limbo-spacing-compact);\n font-size: var(--limbo-font-size-compact-sm);\n border-radius: var(--limbo-radius-compact);\n }\n \n /* Progress indicators compactos */\n [data-limbo-compact="true"] .limbo-progress,\n .limbo-compact-mode .limbo-progress {\n height: 3px; /* Más delgado */\n }\n \n [data-limbo-compact="true"] .limbo-progress-circular,\n .limbo-compact-mode .limbo-progress-circular {\n width: 20px;\n height: 20px;\n }\n \n /* Auto-activación en pantallas pequeñas */\n @media (max-width: 768px) {\n :root[data-limbo-compact="auto"],\n .limbo-component[data-limbo-compact="auto"] {\n /* Aplicar automáticamente estilos compactos */\n --limbo-font-size-md: var(--limbo-font-size-compact-md);\n --limbo-font-size-sm: var(--limbo-font-size-compact-sm);\n --limbo-spacing: var(--limbo-spacing-compact);\n --limbo-radius-md: var(--limbo-radius-compact);\n --limbo-gap: var(--limbo-gap-compact);\n }\n \n /* Modal full-screen en móvil cuando es compacto */\n [data-limbo-compact="auto"] .limbo-modal,\n [data-limbo-compact="true"] .limbo-modal {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100vw;\n height: 100vh;\n max-width: 100vw;\n max-height: 100vh;\n border-radius: 0;\n margin: 0;\n }\n \n /* Tabs en accordion en móvil */\n [data-limbo-compact="auto"] .limbo-tabs,\n [data-limbo-compact="true"] .limbo-tabs {\n flex-direction: column;\n width: 100%;\n }\n \n /* Gallery de 2 columnas en móvil */\n [data-limbo-compact="auto"] .limbo-gallery,\n [data-limbo-compact="true"] .limbo-gallery {\n grid-template-columns: 1fr 1fr;\n gap: var(--limbo-gap-compact);\n }\n }\n \n /* Touch targets más grandes en móviles */\n @media (max-width: 768px) and (pointer: coarse) {\n [data-limbo-compact="auto"] .limbo-button,\n [data-limbo-compact="true"] .limbo-button {\n min-height: 44px; /* Tamaño mínimo de toque recomendado */\n padding: var(--limbo-spacing-compact) var(--limbo-spacing-compact-lg);\n }\n \n [data-limbo-compact="auto"] .limbo-tab,\n [data-limbo-compact="true"] .limbo-tab {\n min-height: 44px;\n }\n }\n `,t=document.createElement("style");t.id="limbo-theme-styles",t.textContent=e,document.head.appendChild(t)}applyTheme(e,t={}){const n=this._getTheme(e);if(!n)return console.warn(`Theme '${e}' not found`),!1;const l=this.currentTheme;return this._applyThemeVariables(n,t.scope),this._updateThemeAttributes(n.name),this.config.theme.storage&&!t.temporary&&this._saveThemePreference(n.name),this.currentTheme=n.name,this._triggerChangeCallbacks(n.name,l),!0}toggleTheme(e="light",t="dark"){const n=this.currentTheme===e?t:e;return this.applyTheme(n)}applyAutoTheme(){const e=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";return this.applyTheme(e)}registerTheme(e,t){const n={name:e,displayName:t.displayName||e,variables:t.variables||{},extends:t.extends||null,...t};if(n.extends){const e=this._getTheme(n.extends);e&&(n.variables={...e.variables,...n.variables})}return this.customThemes.set(e,n),this}removeTheme(e){if(this.config.presets[e])return console.warn(`Cannot remove predefined theme: ${e}`),!1;const t=this.customThemes.delete(e);return t&&this.currentTheme===e&&this.applyTheme(this.config.inheritance.fallbackTheme),t}getAvailableThemes(){const e=Object.keys(this.config.presets),t=Array.from(this.customThemes.keys());return{presets:e,custom:t,all:[...e,...t]}}getCurrentTheme(){return{name:this.currentTheme,theme:this._getTheme(this.currentTheme),isCustom:this.customThemes.has(this.currentTheme),variables:this._getCurrentVariables()}}enableCompactMode(e={}){const t={element:document.documentElement,persist:!0,...e};return t.element.setAttribute("data-limbo-compact","true"),t.element.classList.add("limbo-compact-mode"),this.isCompactMode=!0,t.persist&&this.config.compact.persistPreference&&this._saveCompactPreference(!0),this._triggerCompactChange(!0),this}disableCompactMode(e={}){const t={element:document.documentElement,persist:!0,...e};return t.element.setAttribute("data-limbo-compact","false"),t.element.classList.remove("limbo-compact-mode"),this.isCompactMode=!1,t.persist&&this.config.compact.persistPreference&&this._saveCompactPreference(!1),this._triggerCompactChange(!1),this}toggleCompactMode(e={}){return this.isCompactMode?this.disableCompactMode(e):this.enableCompactMode(e)}applyAutoCompactMode(){const e=this._shouldUseCompactMode();return e&&!this.isCompactMode?this.enableCompactMode({persist:!1}):!e&&this.isCompactMode&&this.disableCompactMode({persist:!1}),this}getCompactState(){return{isEnabled:this.isCompactMode,isAuto:this.config.compact.auto,breakpoint:this.config.compact.breakpoint,currentViewport:window.innerWidth,shouldBeCompact:this._shouldUseCompactMode()}}_shouldUseCompactMode(){if(!this.config.compact.auto)return this.config.compact.enabled;const e=window.innerWidth<=this.config.compact.breakpoint,t=/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),n="ontouchstart"in window||navigator.maxTouchPoints>0;return!(!this.config.compact.forceOnMobile||!t&&!n)||e}_saveCompactPreference(e){try{localStorage.setItem("limbo-compact-preference",e.toString())}catch(t){console.warn("Could not save compact preference:",t)}}_loadCompactPreference(){try{return"true"===localStorage.getItem("limbo-compact-preference")}catch(e){return console.warn("Could not load compact preference:",e),null}}_triggerCompactChange(e){this.changeCallbacks.forEach(t=>{try{t({type:"compact",isCompact:e,viewport:window.innerWidth,timestamp:Date.now()})}catch(n){console.error("Error in compact mode change callback:",n)}})}_inheritPortalTheme(){const e=this._detectPortalTheme();return e?(this.registerTheme("portal-inherited",e),"portal-inherited"):null}_detectPortalTheme(){const e={name:"portal-detected",displayName:"Tema del Portal",variables:{}};for(const t of this.config.inheritance.portalSelectors){const n=document.querySelector(t);if(n){const t=this._extractCSSVariables(n);Object.keys(t).length>0&&(e.variables={...e.variables,...t});const l=n.getAttribute("data-theme")||n.getAttribute("class")?.match(/theme-(\w+)/)||n.getAttribute("class")?.match(/(\w+)-theme/);l&&(e.detectedName=Array.isArray(l)?l[1]:l)}}return Object.keys(e.variables).length>0?e:null}_extractCSSVariables(e){const t={},n=getComputedStyle(e);["primary","primary-hover","primary-light","primary-dark","bg-primary","bg-secondary","bg-tertiary","bg-card","bg-input","text-primary","text-secondary","text-tertiary","text-inverse","border-light","border-medium","border-strong","border-focus","success","error","warning","info","shadow-sm","shadow-md","shadow-lg","shadow-xl","radius-sm","radius-md","radius-lg","radius-xl"].forEach(e=>{const l=`--limbo-${e}`,r=n.getPropertyValue(l).trim();r&&(t[l]=r)});return["--primary-color","--background-color","--text-color","--border-color","--accent-color","--surface-color"].forEach(e=>{const l=n.getPropertyValue(e).trim();if(l){const n=this._mapGenericToLimbo(e,l);n&&Object.assign(t,n)}}),t}_mapGenericToLimbo(e,t){return{"--primary-color":{"--limbo-primary":t},"--background-color":{"--limbo-bg-primary":t},"--text-color":{"--limbo-text-primary":t},"--border-color":{"--limbo-border-light":t},"--accent-color":{"--limbo-primary":t},"--surface-color":{"--limbo-bg-card":t}}[e]||null}_applyInitialTheme(){let e=this.config.inheritance.fallbackTheme;if(this.config.theme.storage){const t=this._loadThemePreference();t&&this._getTheme(t)&&(e=t)}const t=document.documentElement.getAttribute("data-limbo-theme");t&&this._getTheme(t)&&(e=t);const n=this._inheritPortalTheme();n&&(e=n),this.config.theme.auto&&"auto"===e&&(e=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),this.applyTheme(e,{temporary:!1})}_applyInitialCompactMode(){let e=!1;if(this.config.compact.persistPreference){const t=this._loadCompactPreference();null!==t&&(e=t)}const t=document.documentElement.getAttribute("data-limbo-compact");"true"===t?e=!0:"false"===t&&(e=!1),("auto"===t||this.config.compact.auto)&&(e=this._shouldUseCompactMode()),e?this.enableCompactMode({persist:!1}):this.disableCompactMode({persist:!1})}_applyThemeVariables(e,t=document.documentElement){const n="string"==typeof t?document.querySelector(t):t;n?(Object.entries(e.variables).forEach(([e,t])=>{n.style.setProperty(e,t),this.appliedStyles.add(`${n.tagName}:${e}`)}),this.themeCache.set(e.name,{theme:e,appliedAt:Date.now(),scope:n})):console.warn("Theme scope element not found")}_updateThemeAttributes(e){document.documentElement.setAttribute("data-limbo-theme",e),document.documentElement.classList.remove("limbo-theme-light","limbo-theme-dark","limbo-theme-auto"),document.documentElement.classList.add(`limbo-theme-${e}`),this._updateMetaThemeColor(e)}_updateMetaThemeColor(e){const t=this._getTheme(e);if(!t)return;const n=t.variables["--limbo-primary"]||"#3b82f6";let l=document.querySelector('meta[name="theme-color"]');l||(l=document.createElement("meta"),l.name="theme-color",document.head.appendChild(l)),l.content=n}_getTheme(e){return this.config.presets[e]?this.config.presets[e]:this.customThemes.has(e)?this.customThemes.get(e):null}_getCurrentVariables(){const e=this._getTheme(this.currentTheme);if(!e)return{};const t=getComputedStyle(document.documentElement),n={};return Object.keys(e.variables).forEach(e=>{n[e]=t.getPropertyValue(e).trim()}),n}_saveThemePreference(e){try{localStorage.setItem("limbo-theme-preference",e)}catch(t){console.warn("Could not save theme preference:",t)}}_loadThemePreference(){try{return localStorage.getItem("limbo-theme-preference")}catch(e){return console.warn("Could not load theme preference:",e),null}}_loadCustomThemes(){try{const e=localStorage.getItem("limbo-custom-themes");if(e){const t=JSON.parse(e);Object.entries(t).forEach(([e,t])=>{this.customThemes.set(e,t)})}}catch(e){console.warn("Could not load custom themes:",e)}}_saveCustomThemes(){try{const e=Object.fromEntries(this.customThemes);localStorage.setItem("limbo-custom-themes",JSON.stringify(e))}catch(e){console.warn("Could not save custom themes:",e)}}_setupObservers(){this.config.theme.detectSystem&&this._setupSystemObserver(),this.config.theme.storage&&this._setupStorageObserver(),this._setupMutationObserver(),this.config.compact.auto&&this._setupViewportObserver()}_setupSystemObserver(){const e=window.matchMedia("(prefers-color-scheme: dark)");e.addEventListener("change",e=>{if("auto"===this.currentTheme||this.config.theme.auto){const t=e.matches?"dark":"light";this.applyTheme(t,{temporary:!0})}}),this.mediaQueryObserver=e}_setupStorageObserver(){const e=e=>{"limbo-theme-preference"===e.key&&e.newValue!==this.currentTheme&&this._getTheme(e.newValue)&&this.applyTheme(e.newValue)};window.addEventListener("storage",e),this.storageListener=e}_setupMutationObserver(){const e=new MutationObserver(e=>{e.forEach(e=>{if("attributes"===e.type&&"data-limbo-theme"===e.attributeName){const t=e.target.getAttribute("data-limbo-theme");t&&t!==this.currentTheme&&this._getTheme(t)&&this.applyTheme(t)}})});e.observe(document.documentElement,{attributes:!0,attributeFilter:["data-limbo-theme"]}),this.mutationObserver=e}_setupViewportObserver(){const e=`(max-width: ${this.config.compact.breakpoint}px)`,t=window.matchMedia(e);t.addEventListener("change",()=>{("auto"===document.documentElement.getAttribute("data-limbo-compact")||this.config.compact.auto)&&this.applyAutoCompactMode()}),this.compactObserver=t,window.addEventListener("orientationchange",()=>{setTimeout(()=>{("auto"===document.documentElement.getAttribute("data-limbo-compact")||this.config.compact.auto)&&this.applyAutoCompactMode()},100)})}onThemeChange(e){return this.changeCallbacks.add(e),()=>this.changeCallbacks.delete(e)}_triggerChangeCallbacks(e,t){this.changeCallbacks.forEach(n=>{try{n({theme:e,previousTheme:t,themeData:this._getTheme(e),variables:this._getCurrentVariables()})}catch(l){console.error("Error in theme change callback:",l)}})}generateThemeFromColors(e,t){const n={name:e,displayName:e,variables:{}};t.primary&&(n.variables["--limbo-primary"]=t.primary,n.variables["--limbo-primary-hover"]=this._darkenColor(t.primary,10),n.variables["--limbo-primary-light"]=this._lightenColor(t.primary,40),n.variables["--limbo-primary-dark"]=this._darkenColor(t.primary,20)),t.background&&(n.variables["--limbo-bg-primary"]=t.background,n.variables["--limbo-bg-secondary"]=this._lightenColor(t.background,5),n.variables["--limbo-bg-tertiary"]=this._lightenColor(t.background,10),n.variables["--limbo-bg-card"]=t.background),t.text&&(n.variables["--limbo-text-primary"]=t.text,n.variables["--limbo-text-secondary"]=this._lightenColor(t.text,20),n.variables["--limbo-text-tertiary"]=this._lightenColor(t.text,40));const l=this._getTheme(this.config.inheritance.fallbackTheme);return l&&(n.variables={...l.variables,...n.variables}),this.registerTheme(e,n),n}_darkenColor(e,t){const n=parseInt(e.replace("#",""),16),l=Math.round(2.55*t),r=(n>>16)-l,a=(n>>8&255)-l,i=(255&n)-l;return"#"+(16777216+65536*(r<255?r<1?0:r:255)+256*(a<255?a<1?0:a:255)+(i<255?i<1?0:i:255)).toString(16).slice(1)}_lightenColor(e,t){const n=parseInt(e.replace("#",""),16),l=Math.round(2.55*t),r=(n>>16)+l,a=(n>>8&255)+l,i=(255&n)+l;return"#"+(16777216+65536*(r<255?r<1?0:r:255)+256*(a<255?a<1?0:a:255)+(i<255?i<1?0:i:255)).toString(16).slice(1)}_deepMerge(e,t){const n={...e};return Object.keys(t).forEach(l=>{t[l]&&"object"==typeof t[l]&&!Array.isArray(t[l])?n[l]=this._deepMerge(e[l]||{},t[l]):n[l]=t[l]}),n}getThemeInfo(){return{current:this.getCurrentTheme(),available:this.getAvailableThemes(),compact:this.getCompactState(),config:this.config,isInitialized:this.isInitialized,cache:{themes:this.themeCache.size,applied:this.appliedStyles.size},observers:{system:!!this.mediaQueryObserver,storage:!!this.storageListener,mutation:!!this.mutationObserver,viewport:!!this.compactObserver}}}debug(){return console.table(this.getThemeInfo()),this.getThemeInfo()}destroy(){this.mediaQueryObserver&&this.mediaQueryObserver.removeEventListener("change",this._setupSystemObserver),this.storageListener&&window.removeEventListener("storage",this.storageListener),this.mutationObserver&&this.mutationObserver.disconnect(),this.compactObserver&&this.compactObserver.removeEventListener("change",this._setupViewportObserver),this.changeCallbacks.clear(),this.themeCache.clear(),this.appliedStyles.clear(),this._saveCustomThemes();const e=document.getElementById("limbo-theme-styles");e&&e.remove(),this.isInitialized=!1}}const vl={DEV:"https://led-dev-limbo-dev.eu.els.local",PROD:"https://limbo.lefebvre.es"};function xl(e,t=!1){if(!e)return"";if(e.startsWith("/files/")){return(t?vl.PROD:vl.DEV)+e}return e}function wl(e){return"string"!=typeof e?e:e.replace(/"/g,'"').replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/'/g,"'")}function kl(e){return!(!e||"string"!=typeof e)&&!e.startsWith("blob:")}function Cl(e,t={}){if(!e)return"";const{prefer:n="crop",isProd:l=!1}=t,r=wl(e);try{const e=JSON.parse(r),t=()=>{if(e.images&&Array.isArray(e.images))for(const t of e.images)if(t&&kl(t.url))return t.url;return null},a=e.original?.url,i=t();if("crop"===n){if(i)return xl(i,l);if(kl(a))return xl(a,l)}else{if(kl(a))return xl(a,l);if(i)return xl(i,l)}return kl(e.url)?xl(e.url,l):""}catch{if("string"==typeof r){if(r.startsWith("blob:"))return"";if(r.startsWith("/files/"))return xl(r,l);if(r.startsWith("http")||r.startsWith("/"))return r}}return"string"==typeof e&&(e.startsWith("{")||e.startsWith("["))?"":e}const Sl=new class{constructor(){this.config=new u,this.instances=new ml,this.autoInputs=new hl,this.events=new pl,this.modals=new fl,this.theme=new yl,this.containerQueryDetector=U,this._setupInternalListeners(),this._initializeContainerQueries()}configure(e){var t;return this.config.setGlobal(e),t={publicKey:e.publicKey,apiKey:e.apiKey,token:e.token,authMode:e.authMode||"manual",tokenProvider:e.tokenProvider,prod:Boolean(e.prod)||!1,mode:e.mode||"embed",callbacks:e.callbacks||null},Z={...Z,...t},Z.authMode||(Z.token?Z.authMode="manual":Z.authMode="session"),this.config}setToken(e){return function(e){Z.token=e}(e),this.config.setGlobal({token:e}),this}create(e){const t=this.config.merge(e);return this.instances.create(t,this.events,this.modals)}configureAutoInputs(e){return this.autoInputs.configure(e,this.config,this.events)}setTheme(e){return e&&(this.config.set("theme",e),this.theme.setTheme(e),this.events.emit("theme:changed",{theme:e})),this}getTheme(){return this.theme.getCurrentTheme()}scanAndActivate(e=null){const t=this.autoInputs.config?.dataset||"data-limbo-input-file",n=e||`[${t}]`,l=document.querySelectorAll(n);if(0===l.length)return{found:0,processed:0,skipped:0};let r=0,a=0;return l.forEach(e=>{try{this.autoInputs._processInput(e),r++}catch(t){console.warn(`⚠️ Limbo: Error procesando input ${e.id||e.name}:`,t),a++}}),this.events.emit("limbo:scanCompleted",{found:l.length,processed:r,skipped:a,inputs:Array.from(l)}),{found:l.length,processed:r,skipped:a}}_initializeContainerQueries(){this.containerQueryDetector.observeResize(),setTimeout(()=>{document.querySelectorAll(".limbo-component-container-wrapper").forEach(e=>{this.containerQueryDetector.applyResponsiveClasses(e)})},100)}rescan(e=document){const t=this.autoInputs.config?.dataset||"data-limbo-input-file",n=e.querySelectorAll(`[${t}]`);let l=0;return n.forEach(e=>{if(!this.autoInputs.instances.has(this.autoInputs._getInputId(e)))try{this.autoInputs._processInput(e),l++}catch(t){console.warn("⚠️ Limbo: Error procesando nuevo input:",t)}}),l}init(e){const t=this._mapLegacyOptions(e);return this.create(t)}getInstances(){return this.instances.getAll()}destroy(){this.instances.destroyAll(),this.autoInputs.cleanup(),this.events.cleanup(),this.theme.removeTheme()}_mapLegacyOptions(e){return{container:e.container||"#image-manager",mode:"embed",features:["gallery","upload","cropper"],apiKey:e.apiKey,prod:e.prod||!1,url:void 0===e.url||e.url}}_setupInternalListeners(){this.events.on("autoInputs:modalRequest",({config:e,callback:t,input:n})=>{this._handleAutoInputModalRequest({config:e,callback:t,input:n})})}_handleAutoInputModalRequest({config:e,callback:t,input:n}){const l=n,r=async n=>{let r={};if(n.crops&&n.crops.length>0){const e=n.asset||n.original;r.original={url:e?.url||e?.urlSigned||n.originalUrl,width:e?.width||n.originalWidth,height:e?.height||n.originalHeight,assetId:e?.id||n.assetId},r.images=n.crops.map(e=>({url:e.url||e.urlSigned,width:e.width,height:e.height,name:e.name||e.filename}))}else n.asset?r.original={url:n.asset.url||n.asset.urlSigned,width:n.asset.width,height:n.asset.height,assetId:n.asset.id}:n.master?.urlSigned||n.master?.url?r.original={url:n.master.urlSigned||n.master.url,width:n.master.width||n.width,height:n.master.height||n.height,assetId:n.assetId}:n.url||n.urlSigned?r.original={url:n.url||n.urlSigned,width:n.width,height:n.height,assetId:n.assetId||n.id}:(console.warn("[Limbo] handleResult: formato de datos no reconocido",n),r=n);if(l){var a=e?.returnConfig?.format||"json",i="";i="url"===a?r.images?.[0]?.url||r.original?.url||"":"assetId"===a?r.original?.assetId||"":JSON.stringify(r),l.value=i,l.dispatchEvent(new Event("change",{bubbles:!0})),console.log("[Limbo] ✅ Valor asignado al input:",l.value?.substring(0,80))}try{await t(r)}catch(o){}u.close()},a={...e,mode:"modal",autoDestroy:!0,interaction:{allowSelection:!0,allowCropping:!0,...e.interaction},callbacks:{onSelect:e=>{r(e)},onCropsSaved:e=>{r(e)},onCropperComplete:e=>{r(e)},onUpload:t=>{"upload-only"!==e.modeUI||e.features?.includes("cropper")||r(t)},onClose:()=>{}}},o=e.validation?.accept||null,s=o?i(o):null,c=!s||s.isAllTypes||s.includesImages;if(e.initialImageUrl&&c){const t=this._extractAssetIdFromUrl(e.initialImageUrl)||e.existingData?.original?.assetId||null;t&&(a._externalImage={url:e.initialImageUrl,filename:e.initialImageUrl.split("/").pop()?.split("?")[0]||"image.jpg",width:1920,height:1080,mime_type:"image/jpeg",id:t})}e.cropper&&(a.cropper=e.cropper),this.config.setGlobal({interaction:{allowSelection:!0,allowCropping:!0,...e.interaction}});const u=this.create(a);u.open()}_extractAssetIdFromUrl(e){if(!e)return null;try{const t=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,n=e.match(t);return n&&n.length>=2?n[1]:n&&1===n.length?n[0]:null}catch(t){return console.warn("Error extracting asset ID from URL:",t),null}}openGallery(e={}){const t=this.create({mode:"modal",modeUI:"gallery-only",features:["gallery"],autoDestroy:!0,modal:{title:e.title||"Seleccionar Imagen",size:e.size||"large"},validation:{accept:e.accept||null},callbacks:{onSelect:n=>{e.onSelect?.(n),!1!==e.autoClose&&t.close()}},...e});return t.open(),t}openUploader(e={}){const t=!1!==e.redirectToGallery?["upload","gallery"]:["upload"],n=this.create({mode:"modal",modeUI:!1!==e.redirectToGallery?"full":"upload-only",features:t,autoDestroy:!0,modal:{title:e.title||"Subir Imagen",size:e.size||"medium"},validation:{accept:e.accept||null},callbacks:{onUpload:t=>{e.onUpload?.(t),!1===e.autoClose||e.redirectToGallery||n.close()}},...e});return n.open(),n}openCropper(e,t={}){if(!e)throw new Error("Limbo.openCropper: imageUrl es requerido");const n={url:e,filename:t.filename||"image.jpg",width:t.width||1920,height:t.height||1080,mime_type:t.mimeType||"image/jpeg",id:t.assetId||`external-${Date.now()}`},l=this.create({mode:"modal",modeUI:"crop-only",features:["cropper"],autoDestroy:!0,modal:{title:t.title||"Recortar Imagen",size:"xlarge"},cropper:{mandatoryCrops:t.mandatoryCrops||[],allowCustomCrops:!1!==t.allowCustomCrops,enforceRequiredCrops:!1!==t.enforceRequiredCrops},callbacks:{onCropperComplete:e=>{t.onComplete?.(e),!1!==t.autoClose&&l.close()},onCropperCancelled:e=>{t.onCancelled?.(e),!1!==t.autoClose&&l.close()},onCropperError:e=>{t.onError?.(e)}},_externalImage:n,...t});return l.open(),l}createInlineGallery(e,t={}){return this.create({container:e,mode:"embed",modeUI:"gallery-only",features:["gallery"],validation:{accept:t.accept||null},callbacks:{onSelect:t.onSelect,onDelete:t.onDelete},...t})}createInlineUploader(e,t={}){return this.create({container:e,mode:"embed",modeUI:"upload-only",features:["upload"],validation:{accept:t.accept||null},callbacks:{onUpload:t.onUpload},...t})}createStandaloneCropper(e,t,n={}){if(!e)throw new Error("Limbo.createStandaloneCropper: container es requerido");if(!t)throw new Error("Limbo.createStandaloneCropper: imageUrl es requerido");const l={url:t,filename:n.filename||"image.jpg",width:n.width||1920,height:n.height||1080,mime_type:n.mimeType||"image/jpeg",id:n.assetId||`external-${Date.now()}`};return this.create({container:e,mode:"embed",modeUI:"crop-only",features:["cropper"],autoHideOnComplete:!1!==n.autoHideOnComplete,cropper:{mandatoryCrops:n.mandatoryCrops||[],allowCustomCrops:!1!==n.allowCustomCrops,enforceRequiredCrops:!1!==n.enforceRequiredCrops},callbacks:{onCropperComplete:n.onComplete,onCropperCancelled:n.onCancelled,onCropperError:n.onError},_externalImage:l,...n})}createFullSelector(e,t={}){return this.create({container:e,mode:t.mode||"embed",modeUI:"full",features:["gallery","upload","cropper"],validation:{accept:t.accept||null},callbacks:{onSelect:t.onSelect,onUpload:t.onUpload,onDelete:t.onDelete,onCropsSaved:t.onCropsSaved},...t})}};"undefined"!=typeof window&&(window.Limbo=Sl,window.limboCore=Sl);"undefined"!=typeof window&&document.querySelector("#root")&&(Sl.configure({prod:!1,publicKey:"pk_e464fd744106b7a8d63d453c4bd02582",authMode:"session"}),Sl.create({container:"#root",mode:"embed",modeUI:"full",features:["gallery","upload","cropper"],title:"Limbo Image Manager - Development",url:!0}),Sl.configureAutoInputs({dataset:"data-limbo-input-file",return:"json",features:["gallery","upload","cropper"],modeUI:"full",modalSize:"large",title:"Seleccionar archivo",crops:"free",allowDelete:!1})),e.LIMBO_BASE_URL=vl,e.decodeHtmlEntities=wl,e.default=Sl,e.extractImageUrl=Cl,e.isValidImageUrl=kl,e.parseImageData=function(e,t={}){const{isProd:n=!1}=t;if(!e)return{original:null,images:[],url:""};try{const t=JSON.parse(wl(e)),l=t.original?{...t.original,url:xl(t.original.url,n)}:null,r=(t.images||[]).map(e=>({...e,url:xl(e.url,n)}));return{original:l,images:r,url:r[0]?.url||l?.url||xl(t.url,n)||""}}catch{return{original:null,images:[],url:xl(e,n)}}},e.prepareImageFieldsForPreview=function(e,t={}){const{isProd:n=!1}=t;if(!e?.fields)return e;const l=e.fields.map(e=>{if("image"===e.type&&"string"==typeof e.example_value){const t=Cl(e.example_value,{isProd:n});return{...e,example_value:t||e.example_value}}return e});return{...e,fields:l}},e.resolveUrl=xl,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Limbo={})}(this,function(e){"use strict";const t={jpg:["image/jpeg"],jpeg:["image/jpeg"],png:["image/png"],gif:["image/gif"],webp:["image/webp"],svg:["image/svg+xml"],mp4:["video/mp4"],webm:["video/webm"],mov:["video/quicktime"],avi:["video/x-msvideo"],mkv:["video/x-matroska"],pdf:["application/pdf"],doc:["application/msword"],docx:["application/vnd.openxmlformats-officedocument.wordprocessingml.document"],xls:["application/vnd.ms-excel"],xlsx:["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],ppt:["application/vnd.ms-powerpoint"],pptx:["application/vnd.openxmlformats-officedocument.presentationml.presentation"],txt:["text/plain"],csv:["text/csv"],json:["application/json"],xml:["application/xml","text/xml"],html:["text/html"],css:["text/css"],js:["text/javascript","application/javascript"],md:["text/markdown"],mp3:["audio/mpeg"],wav:["audio/wav"],ogg:["audio/ogg"],aac:["audio/aac"],flac:["audio/flac"]},n={image:["image/jpeg","image/png","image/webp","image/svg+xml"],video:["image/gif","video/mp4","video/webm","video/quicktime","video/x-msvideo","video/x-matroska"],document:["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/plain","text/csv"],audio:["audio/mpeg","audio/wav","audio/ogg","audio/webm","audio/aac","audio/flac"]},l=new Set(["jpg","jpeg","png","webp","svg","bmp","tiff","ico"]),r=new Set(["mp4","webm","mov","avi","mkv","gif"]),a=Object.freeze({categories:[],extensions:[],mimeTypes:[],acceptString:"",includesImages:!0,includesVideos:!0,isAllTypes:!0,raw:null});function o(e){if(!e)return a;const o=Array.isArray(e)?e.join(","):String(e),i=o.split(",").map(e=>e.trim()).filter(Boolean);if(0===i.length)return a;const s=[],c=[],u=new Set;for(const l of i)if(l.endsWith("/*")){const e=l.replace("/*","");n[e]&&(s.push(e),n[e].forEach(e=>u.add(e)))}else if(l.startsWith(".")){const e=l.slice(1).toLowerCase();c.push(e),(t[e]||[]).forEach(e=>u.add(e))}else l.includes("/")&&u.add(l);const d=s.includes("image")||c.some(e=>l.has(e)),b=s.includes("video")||c.some(e=>r.has(e));return{categories:s,extensions:c,mimeTypes:[...u],acceptString:[...u].join(","),includesImages:d,includesVideos:b,isAllTypes:!1,raw:o}}function i(e){if(!e||e.isAllTypes)return"Todos los formatos";const t=new Set;for(const n of e.categories)switch(n){case"image":t.add("Imágenes");break;case"video":t.add("Videos");break;case"document":t.add("Documentos");break;case"audio":t.add("Audio")}for(const n of e.extensions)t.add(n.toUpperCase());return[...t].join(", ")||"Todos los formatos"}const s={es:{"button.select":"Seleccionar","button.upload":"Subir archivo","button.cancel":"Cancelar","button.close":"Cerrar","button.save":"Guardar","button.delete":"Eliminar","button.download":"Descargar","button.copy":"Copiar URL","button.crop":"Recortar","button.apply":"Aplicar","button.reset":"Reiniciar","button.back":"Volver","button.next":"Siguiente","button.previous":"Anterior","tab.gallery":"Galería","tab.upload":"Subir","tab.ia":"IA","tab.stock":"Stock","tab.cropper":"Recortar","message.loading":"Cargando...","message.uploading":"Subiendo archivo...","message.processing":"Procesando...","message.no_images":"No hay archivos disponibles","message.upload_success":"Archivo subido correctamente","message.upload_error":"Error al subir el archivo","message.delete_confirm":"¿Estás seguro de que deseas eliminar este archivo? Esta acción también eliminará todos sus recortes.","message.copy_success":"URL copiada al portapapeles","message.copy_error":"Error al copiar URL","error.file_too_large":"El archivo es demasiado grande","error.invalid_format":"Formato de archivo no válido","error.upload_failed":"Error al subir el archivo","error.network":"Error de conexión","error.unknown":"Error desconocido","error.api_key_missing":"API Key no proporcionada","placeholder.search":"Buscar archivos...","placeholder.prompt":"Describe la imagen que quieres generar...","label.file_name":"Nombre del archivo","label.file_size":"Tamaño","label.dimensions":"Dimensiones","label.format":"Formato","label.uploaded_by":"Subido por","label.uploaded_at":"Fecha de subida","preset.square":"Cuadrado","preset.landscape":"Paisaje","preset.portrait":"Retrato","preset.thumbnail":"Miniatura","preset.medium":"Medio","preset.large":"Grande","preset.custom":"Personalizado"},en:{"button.select":"Select","button.upload":"Upload file","button.cancel":"Cancel","button.close":"Close","button.save":"Save","button.delete":"Delete","button.download":"Download","button.copy":"Copy URL","button.crop":"Crop","button.apply":"Apply","button.reset":"Reset","button.back":"Back","button.next":"Next","button.previous":"Previous","tab.gallery":"Gallery","tab.upload":"Upload","tab.ia":"AI","tab.stock":"Stock","tab.cropper":"Crop","message.loading":"Loading...","message.uploading":"Uploading file...","message.processing":"Processing...","message.no_images":"No files available","message.upload_success":"File uploaded successfully","message.upload_error":"Error uploading file","message.delete_confirm":"Are you sure you want to delete this file?","message.copy_success":"URL copied to clipboard","message.copy_error":"Error copying URL","error.file_too_large":"File is too large","error.invalid_format":"Invalid file format","error.upload_failed":"Upload failed","error.network":"Network error","error.unknown":"Unknown error","error.api_key_missing":"API Key not provided","placeholder.search":"Search files...","placeholder.prompt":"Describe the image you want to generate...","label.file_name":"File name","label.file_size":"Size","label.dimensions":"Dimensions","label.format":"Format","label.uploaded_by":"Uploaded by","label.uploaded_at":"Upload date","preset.square":"Square","preset.landscape":"Landscape","preset.portrait":"Portrait","preset.thumbnail":"Thumbnail","preset.medium":"Medium","preset.large":"Large","preset.custom":"Custom"}};class c{constructor(e="es",t={}){this.locale=e,this.messages=this._mergeMessages(t)}_mergeMessages(e){const t={...s};return Object.keys(e).forEach(n=>{t[n]={...t[n]||{},...e[n]}}),t}t(e,t={}){let n=(this.messages[this.locale]||this.messages.es)[e]||e;return Object.keys(t).forEach(e=>{n=n.replace(`{${e}}`,t[e])}),n}setLocale(e){this.messages[e]?this.locale=e:console.warn(`Locale ${e} not available, keeping ${this.locale}`)}getLocale(){return this.locale}getAvailableLocales(){return Object.keys(this.messages)}addMessages(e,t){this.messages[e]={...this.messages[e]||{},...t}}hasKey(e){return e in(this.messages[this.locale]||this.messages.es)}}new c;class u{constructor(){this.globalConfig={},this.defaults={container:"#limbo-default",mode:"embed",modeUI:"full",features:["gallery","upload","cropper"],ui:{showActions:["select","download","copy","delete","crop"],hideActions:[],theme:"light",language:"es",compactMode:!1,showTabs:!0,showPreview:!0},cropper:{quality:.9,format:"webp",aspectRatio:null,lockAspectRatio:!1,showFreeAspectRatio:!0,showDimensionInputs:!1,enableEditMode:!0,showDownloadInCropper:!1,showCropName:!1,mandatoryCrops:[],allowCustomCrops:!0},gallery:{filters:{showNameFilter:!0,showUploadedByFilter:!1,showDateFilter:!0,showTypeFilter:!1,enabledFilters:["name","date"],customFilters:[]},loading:{showPlaceholders:!0,placeholderCount:10,showSpinner:!0},pagination:{itemsPerPage:20,showPageSize:!0}},validation:{accept:null,maxSize:"10MB",formats:["jpg","jpeg","png","webp","gif"],minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,allowedCategories:null},folders:{include:[],exclude:[],includeNoFolder:!0,showFolderSelector:!0,showFolderFilter:!0,showFolderInfo:!0,allowMoveFolder:!0,allowCreateFolder:!0,defaultFolder:null},downloadFormat:"webp",return:{format:"url",autoAssign:!0,includeMetadata:!1},autoInputs:{dataset:"data-limbo-input-file",buttonText:"Seleccionar archivo",buttonStyle:"primary",buttonClass:"limbo-auto-button",scanOnLoad:!0,observeChanges:!0},presets:{aspects:[{name:"square",ratio:"1:1",label:"Cuadrado"},{name:"landscape",ratio:"16:9",label:"Paisaje"},{name:"portrait",ratio:"9:16",label:"Retrato"}],sizes:[{name:"thumbnail",width:300,height:300,fit:"cover",label:"Miniatura"},{name:"medium",width:800,height:600,fit:"cover",label:"Medio"},{name:"large",width:1920,height:1080,fit:"cover",label:"Grande"}],required:[],lockUserCrop:!1,allowArbitrary:!0,defaultAspect:"square",defaultSize:"medium"},modal:{size:"medium",title:"Limbo Image Manager",backdrop:!0,closeOnEscape:!0,closeOnBackdrop:!0,showCloseButton:!0},callbacks:{onUpload:null,onSelect:null,onDelete:null,onCropsSaved:null,onCropperComplete:null,onCropperCancelled:null,onCropperError:null},autoDestroy:!1,autoHideOnComplete:!1,debug:!1,apiEndpoint:null,auth:{apiKey:null,publicKey:null,portal:null,authMode:"jwt",tokenStorage:"memory",autoRefresh:!0,refreshBuffer:30},apiKey:null}}setGlobal(e){return this.globalConfig={...this.globalConfig,...e},this}getGlobal(){return{...this.globalConfig}}merge(e={}){return this._deepMerge(this.defaults,this.globalConfig,e)}_deepMerge(...e){const t={};return e.forEach(e=>{e&&"object"==typeof e&&Object.keys(e).forEach(n=>{e[n]&&"object"==typeof e[n]&&!Array.isArray(e[n])?t[n]=this._deepMerge(t[n]||{},e[n]):t[n]=e[n]})}),t}setDefaults(e){return this.defaults=this._deepMerge(this.defaults,e),this}getDefaults(){return JSON.parse(JSON.stringify(this.defaults))}resetDefaults(){return this.defaults=this._getOriginalDefaults(),this}get(e,t=null){const n=t||this.merge();return this._getValueByPath(n,e)}set(e,t){return this._setValueByPath(this.globalConfig,e,t),this}_getValueByPath(e,t){return t.split(".").reduce((e,t)=>e&&void 0!==e[t]?e[t]:void 0,e)}_setValueByPath(e,t,n){const l=t.split("."),r=l.pop();l.reduce((e,t)=>(e[t]&&"object"==typeof e[t]||(e[t]={}),e[t]),e)[r]=n}_getOriginalDefaults(){return{container:"#limbo-default",mode:"embed",modeUI:"full",features:["gallery","upload","cropper"],ui:{showActions:["select","download","copy","delete","crop"],hideActions:[],theme:"light",language:"es",compactMode:!1,showTabs:!0,showPreview:!0},interaction:{allowSelection:!1,allowCropping:!0,requiresCropping:!1,selectionMode:"direct"},cropper:{quality:.9,format:"webp",aspectRatio:null,lockAspectRatio:!1,showFreeAspectRatio:!0,showDimensionInputs:!1,enableEditMode:!0,showDownloadInCropper:!1,showCropName:!1,mandatoryCrops:[],allowCustomCrops:!0},gallery:{filters:{showNameFilter:!0,showUploadedByFilter:!1,showDateFilter:!0,showTypeFilter:!1,enabledFilters:["name","date"],customFilters:[]},loading:{showPlaceholders:!0,placeholderCount:10,showSpinner:!0},pagination:{itemsPerPage:20,showPageSize:!0}},validation:{accept:null,maxSize:"10MB",formats:["jpg","jpeg","png","webp","gif"],minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,allowedCategories:null},folders:{include:[],exclude:[],includeNoFolder:!0,showFolderSelector:!1,showFolderFilter:!1,showFolderInfo:!0,allowMoveFolder:!0,allowCreateFolder:!0,defaultFolder:null},return:{format:"url",autoAssign:!0,includeMetadata:!1},autoInputs:{dataset:"data-limbo-input-file",buttonText:"Seleccionar archivo",buttonStyle:"primary",buttonClass:"limbo-auto-button",scanOnLoad:!0,observeChanges:!0},modal:{size:"medium",title:"Limbo Image Manager",backdrop:!0,closeOnEscape:!0,closeOnBackdrop:!0,showCloseButton:!0},i18n:{locale:"es",messages:{},autoDetect:!0},theme:{colors:{},spacing:{},typography:{},borderRadius:{},shadows:{},customProperties:{}},callbacks:{onUpload:null,onSelect:null,onDelete:null,onCropsSaved:null,onCropperComplete:null,onCropperCancelled:null,onCropperError:null},autoDestroy:!1,autoHideOnComplete:!1,debug:!1,apiEndpoint:null,auth:{apiKey:null,publicKey:null,portal:null,authMode:"jwt",tokenStorage:"memory",autoRefresh:!0,refreshBuffer:30},apiKey:null}}_validatePresets(e){const t=[];if(e.aspects&&e.aspects.forEach((e,n)=>{e.name&&e.ratio||t.push(`Aspect preset ${n}: name and ratio are required`),e.ratio&&!/^\d+:\d+$/.test(e.ratio)&&t.push(`Aspect preset ${e.name}: ratio must be in format "w:h"`)}),e.sizes&&e.sizes.forEach((e,n)=>{e.name&&e.width||t.push(`Size preset ${n}: name and width are required`),e.width&&e.width<=0&&t.push(`Size preset ${e.name}: width must be positive`),e.height&&e.height<=0&&t.push(`Size preset ${e.name}: height must be positive`)}),e.required&&Array.isArray(e.required)){const n=[...e.aspects?.map(e=>e.name)||[],...e.sizes?.map(e=>e.name)||[]];e.required.forEach(e=>{n.includes(e)||t.push(`Required preset "${e}" not found in available presets`)})}return t}getPreset(e,t,n="aspect"){const l=e.presets||this.defaults.presets;return"aspect"===n?l.aspects?.find(e=>e.name===t):"size"===n?l.sizes?.find(e=>e.name===t):null}isPresetRequired(e,t){const n=e.presets||this.defaults.presets;return n.required?.includes(t)||!1}getAvailableAspects(e){return(e.presets||this.defaults.presets).aspects||[]}getAvailableSizes(e){return(e.presets||this.defaults.presets).sizes||[]}createI18n(e){const t=e.i18n||this.defaults.i18n;let n=t.locale;if(t.autoDetect&&"auto"===n){const e=(navigator.language||navigator.userLanguage).split("-")[0];n=["es","en"].includes(e)?e:"es"}else t.autoDetect&&!n&&(n="es");return new c(n,t.messages)}validate(e){const t=[],n=this._deepMerge(this.globalConfig.auth||{},e.auth||{}),l=e.apiKey||this.globalConfig.apiKey;if("jwt"!==n.authMode&&l||n.apiKey||t.push("auth.apiKey es requerido para autenticación JWT"),"legacy"!==n.authMode||l||t.push("apiKey es requerido para modo legacy"),n.apiKey||l||t.push("Se requiere configuración de autenticación (auth.apiKey o apiKey legacy)"),e.mode&&!["embed","modal","button"].includes(e.mode)&&t.push("mode debe ser: embed, modal o button"),e.features&&!Array.isArray(e.features)&&t.push("features debe ser un array"),e.presets){const n=this._validatePresets(e.presets);t.push(...n)}return{isValid:0===t.length,errors:t}}setJWTAuth(e,t=null,n={}){const l={apiKey:e,publicKey:t,authMode:"jwt",tokenStorage:n.tokenStorage||"memory",autoRefresh:!1!==n.autoRefresh,refreshBuffer:n.refreshBuffer||30,portal:n.portal||null,...n};return this.set("auth",l),this}getAuthConfig(e=null){const t=e||this.merge();return{authMode:t.auth?.authMode||(t.apiKey?"legacy":"jwt"),apiKey:t.auth?.apiKey||t.apiKey,publicKey:t.auth?.publicKey,portal:t.auth?.portal,tokenStorage:t.auth?.tokenStorage||"memory",autoRefresh:!1!==t.auth?.autoRefresh,refreshBuffer:t.auth?.refreshBuffer||30}}isJWTMode(e=null){return"jwt"===this.getAuthConfig(e).authMode}isLegacyMode(e=null){return"legacy"===this.getAuthConfig(e).authMode}migrateToJWT(e=null){const t=e||this.globalConfig.apiKey;if(!t)throw new Error("No hay apiKey para migrar a JWT");return this.setJWTAuth(t),this}getMandatoryCrops(e=null){const t=e||this.merge();return t.cropper?.mandatoryCrops||[]}hasMandatoryCrops(e=null){return this.getMandatoryCrops(e).length>0}isEditModeEnabled(e=null){const t=e||this.merge();return!1!==t.cropper?.enableEditMode}showDimensionInputs(e=null){const t=e||this.merge();return!0===t.cropper?.showDimensionInputs}showDownloadInCropper(e=null){const t=e||this.merge();return!0===t.cropper?.showDownloadInCropper}showCropName(e=null){const t=e||this.merge();return!0===t.cropper?.showCropName}allowCustomCrops(e=null){const t=e||this.merge();return!1!==t.cropper?.allowCustomCrops}getGalleryFilters(e=null){const t=e||this.merge();return t.gallery?.filters||this.defaults.gallery.filters}isGalleryFilterEnabled(e,t=null){const n=this.getGalleryFilters(t);return n.enabledFilters?.includes(e)||!1}getCustomGalleryFilters(e=null){return this.getGalleryFilters(e).customFilters||[]}getGalleryLoadingConfig(e=null){const t=e||this.merge();return t.gallery?.loading||this.defaults.gallery.loading}showGalleryPlaceholders(e=null){return!1!==this.getGalleryLoadingConfig(e).showPlaceholders}getPlaceholderCount(e=null){return this.getGalleryLoadingConfig(e).placeholderCount||10}showGallerySpinner(e=null){return!1!==this.getGalleryLoadingConfig(e).showSpinner}getGalleryPagination(e=null){const t=e||this.merge();return t.gallery?.pagination||this.defaults.gallery.pagination}getItemsPerPage(e=null){return this.getGalleryPagination(e).itemsPerPage||20}getFolderConfig(e=null){return(e||this.merge()).folders||this.defaults.folders}hasFolderFilters(e=null){const t=this.getFolderConfig(e);return t.include?.length>0||t.exclude?.length>0}getFolderApiParams(e=null){const t=this.getFolderConfig(e),n={};return t.include?.length>0?n.folders_include=t.include.join(","):t.exclude?.length>0&&(n.folders_exclude=t.exclude.join(",")),this.hasFolderFilters(e)&&void 0!==t.includeNoFolder&&(n.include_no_folder=t.includeNoFolder?"1":"0"),n}showFolderSelectorInUpload(e=null){const t=e||this.merge();return!0===t.folders?.showFolderSelector}showFolderFilterInGallery(e=null){const t=e||this.merge();return!0===t.folders?.showFolderFilter}canCreateFolder(e=null){const t=e||this.merge();return!1!==t.folders?.allowCreateFolder}getDefaultUploadFolder(e=null){const t=e||this.merge();return t.folders?.defaultFolder||null}getAllowedFolderSlugs(e=null){const t=e||this.merge(),n=t.folders?.include;return n&&n.length>0?n:null}getAllowedCategories(e=null){const t=e||this.merge();return t.validation?.allowedCategories||null}isCategoryAllowed(e,t=null){const n=this.getAllowedCategories(t);return null===n||n.includes(e)}isMultiTypeEnabled(e=null){const t=this.getAllowedCategories(e);return null===t||(t.length>1||1===t.length&&"image"!==t[0])}showTypeFilter(e=null){const t=e||this.merge();return!0===t.gallery?.filters?.showTypeFilter}getTypeFilterOptions(e=null){const t=this.getAllowedCategories(e),n=[{value:"",label:"Todos los tipos"},{value:"image",label:"Imágenes"},{value:"video",label:"Videos"},{value:"document",label:"Documentos"},{value:"audio",label:"Audio"}];return null===t?n:n.filter(e=>""===e.value||t.includes(e.value))}getResolvedAccept(e=null){const t=e||this.merge();return t.validation?.accept?o(t.validation.accept):t.validation?.allowedCategories?o(t.validation.allowedCategories.map(e=>`${e}/*`).join(",")):o(null)}}function d(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var b,m,h={exports:{}},p={};function f(){if(b)return p;b=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),o=Symbol.for("react.context"),i=Symbol.for("react.forward_ref"),s=Symbol.for("react.suspense"),c=Symbol.for("react.memo"),u=Symbol.for("react.lazy"),d=Symbol.for("react.activity"),m=Symbol.iterator;var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},f=Object.assign,g={};function y(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||h}function v(){}function x(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||h}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},v.prototype=y.prototype;var w=x.prototype=new v;w.constructor=x,f(w,y.prototype),w.isPureReactComponent=!0;var k=Array.isArray;function C(){}var S={H:null,A:null,T:null,S:null},j=Object.prototype.hasOwnProperty;function N(t,n,l){var r=l.ref;return{$$typeof:e,type:t,key:n,ref:void 0!==r?r:null,props:l}}function E(t){return"object"==typeof t&&null!==t&&t.$$typeof===e}var $=/\/+/g;function _(e,t){return"object"==typeof e&&null!==e&&null!=e.key?(n=""+e.key,l={"=":"=0",":":"=2"},"$"+n.replace(/[=:]/g,function(e){return l[e]})):t.toString(36);var n,l}function T(n,l,r,a,o){var i=typeof n;"undefined"!==i&&"boolean"!==i||(n=null);var s,c,d=!1;if(null===n)d=!0;else switch(i){case"bigint":case"string":case"number":d=!0;break;case"object":switch(n.$$typeof){case e:case t:d=!0;break;case u:return T((d=n._init)(n._payload),l,r,a,o)}}if(d)return o=o(n),d=""===a?"."+_(n,0):a,k(o)?(r="",null!=d&&(r=d.replace($,"$&/")+"/"),T(o,l,r,"",function(e){return e})):null!=o&&(E(o)&&(s=o,c=r+(null==o.key||n&&n.key===o.key?"":(""+o.key).replace($,"$&/")+"/")+d,o=N(s.type,c,s.props)),l.push(o)),1;d=0;var b,h=""===a?".":a+":";if(k(n))for(var p=0;p<n.length;p++)d+=T(a=n[p],l,r,i=h+_(a,p),o);else if("function"==typeof(p=null===(b=n)||"object"!=typeof b?null:"function"==typeof(b=m&&b[m]||b["@@iterator"])?b:null))for(n=p.call(n),p=0;!(a=n.next()).done;)d+=T(a=a.value,l,r,i=h+_(a,p++),o);else if("object"===i){if("function"==typeof n.then)return T(function(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch("string"==typeof e.status?e.then(C,C):(e.status="pending",e.then(function(t){"pending"===e.status&&(e.status="fulfilled",e.value=t)},function(t){"pending"===e.status&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}(n),l,r,a,o);throw l=String(n),Error("Objects are not valid as a React child (found: "+("[object Object]"===l?"object with keys {"+Object.keys(n).join(", ")+"}":l)+"). If you meant to render a collection of children, use an array instead.")}return d}function z(e,t,n){if(null==e)return e;var l=[],r=0;return T(e,l,"","",function(e){return t.call(n,e,r++)}),l}function L(e){if(-1===e._status){var t=e._result;(t=t()).then(function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)},function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)}),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var A="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"==typeof process&&"function"==typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)},M={map:z,forEach:function(e,t,n){z(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return z(e,function(){t++}),t},toArray:function(e){return z(e,function(e){return e})||[]},only:function(e){if(!E(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};return p.Activity=d,p.Children=M,p.Component=y,p.Fragment=n,p.Profiler=r,p.PureComponent=x,p.StrictMode=l,p.Suspense=s,p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=S,p.__COMPILER_RUNTIME={__proto__:null,c:function(e){return S.H.useMemoCache(e)}},p.cache=function(e){return function(){return e.apply(null,arguments)}},p.cacheSignal=function(){return null},p.cloneElement=function(e,t,n){if(null==e)throw Error("The argument must be a React element, but you passed "+e+".");var l=f({},e.props),r=e.key;if(null!=t)for(a in void 0!==t.key&&(r=""+t.key),t)!j.call(t,a)||"key"===a||"__self"===a||"__source"===a||"ref"===a&&void 0===t.ref||(l[a]=t[a]);var a=arguments.length-2;if(1===a)l.children=n;else if(1<a){for(var o=Array(a),i=0;i<a;i++)o[i]=arguments[i+2];l.children=o}return N(e.type,r,l)},p.createContext=function(e){return(e={$$typeof:o,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider=e,e.Consumer={$$typeof:a,_context:e},e},p.createElement=function(e,t,n){var l,r={},a=null;if(null!=t)for(l in void 0!==t.key&&(a=""+t.key),t)j.call(t,l)&&"key"!==l&&"__self"!==l&&"__source"!==l&&(r[l]=t[l]);var o=arguments.length-2;if(1===o)r.children=n;else if(1<o){for(var i=Array(o),s=0;s<o;s++)i[s]=arguments[s+2];r.children=i}if(e&&e.defaultProps)for(l in o=e.defaultProps)void 0===r[l]&&(r[l]=o[l]);return N(e,a,r)},p.createRef=function(){return{current:null}},p.forwardRef=function(e){return{$$typeof:i,render:e}},p.isValidElement=E,p.lazy=function(e){return{$$typeof:u,_payload:{_status:-1,_result:e},_init:L}},p.memo=function(e,t){return{$$typeof:c,type:e,compare:void 0===t?null:t}},p.startTransition=function(e){var t=S.T,n={};S.T=n;try{var l=e(),r=S.S;null!==r&&r(n,l),"object"==typeof l&&null!==l&&"function"==typeof l.then&&l.then(C,A)}catch(a){A(a)}finally{null!==t&&null!==n.types&&(t.types=n.types),S.T=t}},p.unstable_useCacheRefresh=function(){return S.H.useCacheRefresh()},p.use=function(e){return S.H.use(e)},p.useActionState=function(e,t,n){return S.H.useActionState(e,t,n)},p.useCallback=function(e,t){return S.H.useCallback(e,t)},p.useContext=function(e){return S.H.useContext(e)},p.useDebugValue=function(){},p.useDeferredValue=function(e,t){return S.H.useDeferredValue(e,t)},p.useEffect=function(e,t){return S.H.useEffect(e,t)},p.useEffectEvent=function(e){return S.H.useEffectEvent(e)},p.useId=function(){return S.H.useId()},p.useImperativeHandle=function(e,t,n){return S.H.useImperativeHandle(e,t,n)},p.useInsertionEffect=function(e,t){return S.H.useInsertionEffect(e,t)},p.useLayoutEffect=function(e,t){return S.H.useLayoutEffect(e,t)},p.useMemo=function(e,t){return S.H.useMemo(e,t)},p.useOptimistic=function(e,t){return S.H.useOptimistic(e,t)},p.useReducer=function(e,t,n){return S.H.useReducer(e,t,n)},p.useRef=function(e){return S.H.useRef(e)},p.useState=function(e){return S.H.useState(e)},p.useSyncExternalStore=function(e,t,n){return S.H.useSyncExternalStore(e,t,n)},p.useTransition=function(){return S.H.useTransition()},p.version="19.2.3",p}function g(){return m||(m=1,h.exports=f()),h.exports}var y=g();const v=d(y);var x,w,k={exports:{}},C={},S={exports:{}},j={};function N(){return w||(w=1,S.exports=(x||(x=1,function(e){function t(e,t){var n=e.length;e.push(t);e:for(;0<n;){var l=n-1>>>1,a=e[l];if(!(0<r(a,t)))break e;e[l]=t,e[n]=a,n=l}}function n(e){return 0===e.length?null:e[0]}function l(e){if(0===e.length)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var l=0,a=e.length,o=a>>>1;l<o;){var i=2*(l+1)-1,s=e[i],c=i+1,u=e[c];if(0>r(s,n))c<a&&0>r(u,s)?(e[l]=u,e[c]=n,l=c):(e[l]=s,e[i]=n,l=i);else{if(!(c<a&&0>r(u,n)))break e;e[l]=u,e[c]=n,l=c}}}return t}function r(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if(e.unstable_now=void 0,"object"==typeof performance&&"function"==typeof performance.now){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,i=o.now();e.unstable_now=function(){return o.now()-i}}var s=[],c=[],u=1,d=null,b=3,m=!1,h=!1,p=!1,f=!1,g="function"==typeof setTimeout?setTimeout:null,y="function"==typeof clearTimeout?clearTimeout:null,v="undefined"!=typeof setImmediate?setImmediate:null;function x(e){for(var r=n(c);null!==r;){if(null===r.callback)l(c);else{if(!(r.startTime<=e))break;l(c),r.sortIndex=r.expirationTime,t(s,r)}r=n(c)}}function w(e){if(p=!1,x(e),!h)if(null!==n(s))h=!0,C||(C=!0,k());else{var t=n(c);null!==t&&z(w,t.startTime-e)}}var k,C=!1,S=-1,j=5,N=-1;function E(){return!(!f&&e.unstable_now()-N<j)}function $(){if(f=!1,C){var t=e.unstable_now();N=t;var r=!0;try{e:{h=!1,p&&(p=!1,y(S),S=-1),m=!0;var a=b;try{t:{for(x(t),d=n(s);null!==d&&!(d.expirationTime>t&&E());){var o=d.callback;if("function"==typeof o){d.callback=null,b=d.priorityLevel;var i=o(d.expirationTime<=t);if(t=e.unstable_now(),"function"==typeof i){d.callback=i,x(t),r=!0;break t}d===n(s)&&l(s),x(t)}else l(s);d=n(s)}if(null!==d)r=!0;else{var u=n(c);null!==u&&z(w,u.startTime-t),r=!1}}break e}finally{d=null,b=a,m=!1}r=void 0}}finally{r?k():C=!1}}}if("function"==typeof v)k=function(){v($)};else if("undefined"!=typeof MessageChannel){var _=new MessageChannel,T=_.port2;_.port1.onmessage=$,k=function(){T.postMessage(null)}}else k=function(){g($,0)};function z(t,n){S=g(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):j=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_next=function(e){switch(b){case 1:case 2:case 3:var t=3;break;default:t=b}var n=b;b=t;try{return e()}finally{b=n}},e.unstable_requestPaint=function(){f=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=b;b=e;try{return t()}finally{b=n}},e.unstable_scheduleCallback=function(l,r,a){var o=e.unstable_now();switch(a="object"==typeof a&&null!==a&&"number"==typeof(a=a.delay)&&0<a?o+a:o,l){case 1:var i=-1;break;case 2:i=250;break;case 5:i=1073741823;break;case 4:i=1e4;break;default:i=5e3}return l={id:u++,callback:r,priorityLevel:l,startTime:a,expirationTime:i=a+i,sortIndex:-1},a>o?(l.sortIndex=a,t(c,l),null===n(s)&&l===n(c)&&(p?(y(S),S=-1):p=!0,z(w,a-o))):(l.sortIndex=i,t(s,l),h||m||(h=!0,C||(C=!0,k()))),l},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=b;return function(){var n=b;b=t;try{return e.apply(this,arguments)}finally{b=n}}}}(j)),j)),S.exports}var E,$,_,T,z={exports:{}},L={};function A(){if(E)return L;E=1;var e=g();function t(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var l={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},r=Symbol.for("react.portal");var a=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function o(e,t){return"font"===e?"":"string"==typeof t?"use-credentials"===t?t:"":void 0}return L.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=l,L.createPortal=function(e,n){var l=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!n||1!==n.nodeType&&9!==n.nodeType&&11!==n.nodeType)throw Error(t(299));return function(e,t,n){var l=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:r,key:null==l?null:""+l,children:e,containerInfo:t,implementation:n}}(e,n,null,l)},L.flushSync=function(e){var t=a.T,n=l.p;try{if(a.T=null,l.p=2,e)return e()}finally{a.T=t,l.p=n,l.d.f()}},L.preconnect=function(e,t){"string"==typeof e&&(t?t="string"==typeof(t=t.crossOrigin)?"use-credentials"===t?t:"":void 0:t=null,l.d.C(e,t))},L.prefetchDNS=function(e){"string"==typeof e&&l.d.D(e)},L.preinit=function(e,t){if("string"==typeof e&&t&&"string"==typeof t.as){var n=t.as,r=o(n,t.crossOrigin),a="string"==typeof t.integrity?t.integrity:void 0,i="string"==typeof t.fetchPriority?t.fetchPriority:void 0;"style"===n?l.d.S(e,"string"==typeof t.precedence?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:i}):"script"===n&&l.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:i,nonce:"string"==typeof t.nonce?t.nonce:void 0})}},L.preinitModule=function(e,t){if("string"==typeof e)if("object"==typeof t&&null!==t){if(null==t.as||"script"===t.as){var n=o(t.as,t.crossOrigin);l.d.M(e,{crossOrigin:n,integrity:"string"==typeof t.integrity?t.integrity:void 0,nonce:"string"==typeof t.nonce?t.nonce:void 0})}}else null==t&&l.d.M(e)},L.preload=function(e,t){if("string"==typeof e&&"object"==typeof t&&null!==t&&"string"==typeof t.as){var n=t.as,r=o(n,t.crossOrigin);l.d.L(e,n,{crossOrigin:r,integrity:"string"==typeof t.integrity?t.integrity:void 0,nonce:"string"==typeof t.nonce?t.nonce:void 0,type:"string"==typeof t.type?t.type:void 0,fetchPriority:"string"==typeof t.fetchPriority?t.fetchPriority:void 0,referrerPolicy:"string"==typeof t.referrerPolicy?t.referrerPolicy:void 0,imageSrcSet:"string"==typeof t.imageSrcSet?t.imageSrcSet:void 0,imageSizes:"string"==typeof t.imageSizes?t.imageSizes:void 0,media:"string"==typeof t.media?t.media:void 0})}},L.preloadModule=function(e,t){if("string"==typeof e)if(t){var n=o(t.as,t.crossOrigin);l.d.m(e,{as:"string"==typeof t.as&&"script"!==t.as?t.as:void 0,crossOrigin:n,integrity:"string"==typeof t.integrity?t.integrity:void 0})}else l.d.m(e)},L.requestFormReset=function(e){l.d.r(e)},L.unstable_batchedUpdates=function(e,t){return e(t)},L.useFormState=function(e,t,n){return a.H.useFormState(e,t,n)},L.useFormStatus=function(){return a.H.useHostTransitionStatus()},L.version="19.2.3",L}function M(){if(_)return C;_=1;var e=N(),t=g(),n=($||($=1,function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}(),z.exports=A()),z.exports);function l(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType)}function a(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do{!!(4098&(t=e).flags)&&(n=t.return),e=t.return}while(e)}return 3===t.tag?n:null}function o(e){if(13===e.tag){var t=e.memoizedState;if(null===t&&(null!==(e=e.alternate)&&(t=e.memoizedState)),null!==t)return t.dehydrated}return null}function i(e){if(31===e.tag){var t=e.memoizedState;if(null===t&&(null!==(e=e.alternate)&&(t=e.memoizedState)),null!==t)return t.dehydrated}return null}function s(e){if(a(e)!==e)throw Error(l(188))}function c(e){var t=e.tag;if(5===t||26===t||27===t||6===t)return e;for(e=e.child;null!==e;){if(null!==(t=c(e)))return t;e=e.sibling}return null}var u=Object.assign,d=Symbol.for("react.element"),b=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),p=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),y=Symbol.for("react.consumer"),v=Symbol.for("react.context"),x=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),E=Symbol.for("react.activity"),T=Symbol.for("react.memo_cache_sentinel"),L=Symbol.iterator;function M(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=L&&e[L]||e["@@iterator"])?e:null}var P=Symbol.for("react.client.reference");function I(e){if(null==e)return null;if("function"==typeof e)return e.$$typeof===P?null:e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case h:return"Fragment";case f:return"Profiler";case p:return"StrictMode";case w:return"Suspense";case k:return"SuspenseList";case E:return"Activity"}if("object"==typeof e)switch(e.$$typeof){case m:return"Portal";case v:return e.displayName||"Context";case y:return(e._context.displayName||"Context")+".Consumer";case x:var t=e.render;return(e=e.displayName)||(e=""!==(e=t.displayName||t.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case S:return null!==(t=e.displayName||null)?t:I(e.type)||"Memo";case j:t=e._payload,e=e._init;try{return I(e(t))}catch(n){}}return null}var D=Array.isArray,O=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F={pending:!1,data:null,method:null,action:null},U=[],B=-1;function W(e){return{current:e}}function q(e){0>B||(e.current=U[B],U[B]=null,B--)}function V(e,t){B++,U[B]=e.current,e.current=t}var H,K,G=W(null),Q=W(null),X=W(null),Y=W(null);function J(e,t){switch(V(X,t),V(Q,e),V(G,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?wd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)e=kd(t=wd(t),e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}q(G),V(G,e)}function Z(){q(G),q(Q),q(X)}function ee(e){null!==e.memoizedState&&V(Y,e);var t=G.current,n=kd(t,e.type);t!==n&&(V(Q,e),V(G,n))}function te(e){Q.current===e&&(q(G),q(Q)),Y.current===e&&(q(Y),hb._currentValue=F)}function ne(e){if(void 0===H)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);H=t&&t[1]||"",K=-1<n.stack.indexOf("\n at")?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return"\n"+H+e+K}var le=!1;function re(e,t){if(!e||le)return"";le=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(n,[])}catch(r){var l=r}Reflect.construct(e,[],n)}else{try{n.call()}catch(a){l=a}e.call(n.prototype)}}else{try{throw Error()}catch(o){l=o}(n=e())&&"function"==typeof n.catch&&n.catch(function(){})}}catch(i){if(i&&l&&"string"==typeof i.stack)return[i.stack,l.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var r=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");r&&r.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var a=l.DetermineComponentFrameRoot(),o=a[0],i=a[1];if(o&&i){var s=o.split("\n"),c=i.split("\n");for(r=l=0;l<s.length&&!s[l].includes("DetermineComponentFrameRoot");)l++;for(;r<c.length&&!c[r].includes("DetermineComponentFrameRoot");)r++;if(l===s.length||r===c.length)for(l=s.length-1,r=c.length-1;1<=l&&0<=r&&s[l]!==c[r];)r--;for(;1<=l&&0<=r;l--,r--)if(s[l]!==c[r]){if(1!==l||1!==r)do{if(l--,0>--r||s[l]!==c[r]){var u="\n"+s[l].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}}while(1<=l&&0<=r);break}}}finally{le=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?ne(n):""}function ae(e,t){switch(e.tag){case 26:case 27:case 5:return ne(e.type);case 16:return ne("Lazy");case 13:return e.child!==t&&null!==t?ne("Suspense Fallback"):ne("Suspense");case 19:return ne("SuspenseList");case 0:case 15:return re(e.type,!1);case 11:return re(e.type.render,!1);case 1:return re(e.type,!0);case 31:return ne("Activity");default:return""}}function oe(e){try{var t="",n=null;do{t+=ae(e,n),n=e,e=e.return}while(e);return t}catch(l){return"\nError generating stack: "+l.message+"\n"+l.stack}}var ie=Object.prototype.hasOwnProperty,se=e.unstable_scheduleCallback,ce=e.unstable_cancelCallback,ue=e.unstable_shouldYield,de=e.unstable_requestPaint,be=e.unstable_now,me=e.unstable_getCurrentPriorityLevel,he=e.unstable_ImmediatePriority,pe=e.unstable_UserBlockingPriority,fe=e.unstable_NormalPriority,ge=e.unstable_LowPriority,ye=e.unstable_IdlePriority,ve=e.log,xe=e.unstable_setDisableYieldValue,we=null,ke=null;function Ce(e){if("function"==typeof ve&&xe(e),ke&&"function"==typeof ke.setStrictMode)try{ke.setStrictMode(we,e)}catch(t){}}var Se=Math.clz32?Math.clz32:function(e){return 0===(e>>>=0)?32:31-(je(e)/Ne|0)|0},je=Math.log,Ne=Math.LN2;var Ee=256,$e=262144,_e=4194304;function Te(e){var t=42&e;if(0!==t)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return 261888&e;case 262144:case 524288:case 1048576:case 2097152:return 3932160&e;case 4194304:case 8388608:case 16777216:case 33554432:return 62914560&e;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function ze(e,t,n){var l=e.pendingLanes;if(0===l)return 0;var r=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var i=134217727&l;return 0!==i?0!==(l=i&~a)?r=Te(l):0!==(o&=i)?r=Te(o):n||0!==(n=i&~e)&&(r=Te(n)):0!==(i=l&~a)?r=Te(i):0!==o?r=Te(o):n||0!==(n=l&~e)&&(r=Te(n)),0===r?0:0!==t&&t!==r&&0===(t&a)&&((a=r&-r)>=(n=t&-t)||32===a&&4194048&n)?t:r}function Le(e,t){return 0===(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)}function Ae(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;default:return-1}}function Me(){var e=_e;return!(62914560&(_e<<=1))&&(_e=4194304),e}function Pe(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Ie(e,t){e.pendingLanes|=t,268435456!==t&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function De(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var l=31-Se(t);e.entangledLanes|=t,e.entanglements[l]=1073741824|e.entanglements[l]|261930&n}function Oe(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var l=31-Se(n),r=1<<l;r&t|e[l]&t&&(e[l]|=t),n&=~r}}function Re(e,t){var n=t&-t;return 0!==((n=42&n?1:Fe(n))&(e.suspendedLanes|t))?0:n}function Fe(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Ue(e){return 2<(e&=-e)?8<e?134217727&e?32:268435456:8:2}function Be(){var e=R.p;return 0!==e?e:void 0===(e=window.event)?32:Tb(e.type)}function We(e,t){var n=R.p;try{return R.p=e,t()}finally{R.p=n}}var qe=Math.random().toString(36).slice(2),Ve="__reactFiber$"+qe,He="__reactProps$"+qe,Ke="__reactContainer$"+qe,Ge="__reactEvents$"+qe,Qe="__reactListeners$"+qe,Xe="__reactHandles$"+qe,Ye="__reactResources$"+qe,Je="__reactMarker$"+qe;function Ze(e){delete e[Ve],delete e[He],delete e[Ge],delete e[Qe],delete e[Xe]}function et(e){var t=e[Ve];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Ke]||n[Ve]){if(n=t.alternate,null!==t.child||null!==n&&null!==n.child)for(e=Fd(e);null!==e;){if(n=e[Ve])return n;e=Fd(e)}return t}n=(e=n).parentNode}return null}function tt(e){if(e=e[Ve]||e[Ke]){var t=e.tag;if(5===t||6===t||13===t||31===t||26===t||27===t||3===t)return e}return null}function nt(e){var t=e.tag;if(5===t||26===t||27===t||6===t)return e.stateNode;throw Error(l(33))}function lt(e){var t=e[Ye];return t||(t=e[Ye]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function rt(e){e[Je]=!0}var at=new Set,ot={};function it(e,t){st(e,t),st(e+"Capture",t)}function st(e,t){for(ot[e]=t,e=0;e<t.length;e++)at.add(t[e])}var ct=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),ut={},dt={};function bt(e,t,n){if(r=t,ie.call(dt,r)||!ie.call(ut,r)&&(ct.test(r)?dt[r]=!0:(ut[r]=!0,0)))if(null===n)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":return void e.removeAttribute(t);case"boolean":var l=t.toLowerCase().slice(0,5);if("data-"!==l&&"aria-"!==l)return void e.removeAttribute(t)}e.setAttribute(t,""+n)}var r}function mt(e,t,n){if(null===n)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(t)}e.setAttribute(t,""+n)}}function ht(e,t,n,l){if(null===l)e.removeAttribute(n);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(n)}e.setAttributeNS(t,n,""+l)}}function pt(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":case"object":return e;default:return""}}function ft(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function gt(e){if(!e._valueTracker){var t=ft(e)?"checked":"value";e._valueTracker=function(e,t,n){var l=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&void 0!==l&&"function"==typeof l.get&&"function"==typeof l.set){var r=l.get,a=l.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return r.call(this)},set:function(e){n=""+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:l.enumerable}),{getValue:function(){return n},setValue:function(e){n=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e,t,""+e[t])}}function yt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),l="";return e&&(l=ft(e)?e.checked?"true":"false":e.value),(e=l)!==n&&(t.setValue(e),!0)}function vt(e){if(void 0===(e=e||("undefined"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}var xt=/[\n"\\]/g;function wt(e){return e.replace(xt,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})}function kt(e,t,n,l,r,a,o,i){e.name="",null!=o&&"function"!=typeof o&&"symbol"!=typeof o&&"boolean"!=typeof o?e.type=o:e.removeAttribute("type"),null!=t?"number"===o?(0===t&&""===e.value||e.value!=t)&&(e.value=""+pt(t)):e.value!==""+pt(t)&&(e.value=""+pt(t)):"submit"!==o&&"reset"!==o||e.removeAttribute("value"),null!=t?St(e,o,pt(t)):null!=n?St(e,o,pt(n)):null!=l&&e.removeAttribute("value"),null==r&&null!=a&&(e.defaultChecked=!!a),null!=r&&(e.checked=r&&"function"!=typeof r&&"symbol"!=typeof r),null!=i&&"function"!=typeof i&&"symbol"!=typeof i&&"boolean"!=typeof i?e.name=""+pt(i):e.removeAttribute("name")}function Ct(e,t,n,l,r,a,o,i){if(null!=a&&"function"!=typeof a&&"symbol"!=typeof a&&"boolean"!=typeof a&&(e.type=a),null!=t||null!=n){if(("submit"===a||"reset"===a)&&null==t)return void gt(e);n=null!=n?""+pt(n):"",t=null!=t?""+pt(t):n,i||t===e.value||(e.value=t),e.defaultValue=t}l="function"!=typeof(l=null!=l?l:r)&&"symbol"!=typeof l&&!!l,e.checked=i?e.checked:!!l,e.defaultChecked=!!l,null!=o&&"function"!=typeof o&&"symbol"!=typeof o&&"boolean"!=typeof o&&(e.name=o),gt(e)}function St(e,t,n){"number"===t&&vt(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function jt(e,t,n,l){if(e=e.options,t){t={};for(var r=0;r<n.length;r++)t["$"+n[r]]=!0;for(n=0;n<e.length;n++)r=t.hasOwnProperty("$"+e[n].value),e[n].selected!==r&&(e[n].selected=r),r&&l&&(e[n].defaultSelected=!0)}else{for(n=""+pt(n),t=null,r=0;r<e.length;r++){if(e[r].value===n)return e[r].selected=!0,void(l&&(e[r].defaultSelected=!0));null!==t||e[r].disabled||(t=e[r])}null!==t&&(t.selected=!0)}}function Nt(e,t,n){null==t||((t=""+pt(t))!==e.value&&(e.value=t),null!=n)?e.defaultValue=null!=n?""+pt(n):"":e.defaultValue!==t&&(e.defaultValue=t)}function Et(e,t,n,r){if(null==t){if(null!=r){if(null!=n)throw Error(l(92));if(D(r)){if(1<r.length)throw Error(l(93));r=r[0]}n=r}null==n&&(n=""),t=n}n=pt(t),e.defaultValue=n,(r=e.textContent)===n&&""!==r&&null!==r&&(e.value=r),gt(e)}function $t(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t}var _t=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Tt(e,t,n){var l=0===t.indexOf("--");null==n||"boolean"==typeof n||""===n?l?e.setProperty(t,""):"float"===t?e.cssFloat="":e[t]="":l?e.setProperty(t,n):"number"!=typeof n||0===n||_t.has(t)?"float"===t?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function zt(e,t,n){if(null!=t&&"object"!=typeof t)throw Error(l(62));if(e=e.style,null!=n){for(var r in n)!n.hasOwnProperty(r)||null!=t&&t.hasOwnProperty(r)||(0===r.indexOf("--")?e.setProperty(r,""):"float"===r?e.cssFloat="":e[r]="");for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&Tt(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&Tt(e,o,t[o])}function Lt(e){if(-1===e.indexOf("-"))return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var At=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Mt=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Pt(e){return Mt.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function It(){}var Dt=null;function Ot(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var Rt=null,Ft=null;function Ut(e){var t=tt(e);if(t&&(e=t.stateNode)){var n=e[He]||null;e:switch(e=t.stateNode,t.type){case"input":if(kt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,"radio"===n.type&&null!=t){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll('input[name="'+wt(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[He]||null;if(!a)throw Error(l(90));kt(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)(r=n[t]).form===e.form&&yt(r)}break e;case"textarea":Nt(e,n.value,n.defaultValue);break e;case"select":null!=(t=n.value)&&jt(e,!!n.multiple,t,!1)}}}var Bt=!1;function Wt(e,t,n){if(Bt)return e(t,n);Bt=!0;try{return e(t)}finally{if(Bt=!1,(null!==Rt||null!==Ft)&&(lu(),Rt&&(t=Rt,e=Ft,Ft=Rt=null,Ut(t),e)))for(t=0;t<e.length;t++)Ut(e[t])}}function qt(e,t){var n=e.stateNode;if(null===n)return null;var r=n[He]||null;if(null===r)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(r=!("button"===(e=e.type)||"input"===e||"select"===e||"textarea"===e)),e=!r;break e;default:e=!1}if(e)return null;if(n&&"function"!=typeof n)throw Error(l(231,t,typeof n));return n}var Vt=!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement),Ht=!1;if(Vt)try{var Kt={};Object.defineProperty(Kt,"passive",{get:function(){Ht=!0}}),window.addEventListener("test",Kt,Kt),window.removeEventListener("test",Kt,Kt)}catch(tm){Ht=!1}var Gt=null,Qt=null,Xt=null;function Yt(){if(Xt)return Xt;var e,t,n=Qt,l=n.length,r="value"in Gt?Gt.value:Gt.textContent,a=r.length;for(e=0;e<l&&n[e]===r[e];e++);var o=l-e;for(t=1;t<=o&&n[l-t]===r[a-t];t++);return Xt=r.slice(e,1<t?1-t:void 0)}function Jt(e){var t=e.keyCode;return"charCode"in e?0===(e=e.charCode)&&13===t&&(e=13):e=t,10===e&&(e=13),32<=e||13===e?e:0}function Zt(){return!0}function en(){return!1}function tn(e){function t(t,n,l,r,a){for(var o in this._reactName=t,this._targetInst=l,this.type=n,this.nativeEvent=r,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(r):r[o]);return this.isDefaultPrevented=(null!=r.defaultPrevented?r.defaultPrevented:!1===r.returnValue)?Zt:en,this.isPropagationStopped=en,this}return u(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=Zt)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=Zt)},persist:function(){},isPersistent:Zt}),t}var nn,ln,rn,an={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},on=tn(an),sn=u({},an,{view:0,detail:0}),cn=tn(sn),un=u({},sn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:wn,button:0,buttons:0,relatedTarget:function(e){return void 0===e.relatedTarget?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==rn&&(rn&&"mousemove"===e.type?(nn=e.screenX-rn.screenX,ln=e.screenY-rn.screenY):ln=nn=0,rn=e),nn)},movementY:function(e){return"movementY"in e?e.movementY:ln}}),dn=tn(un),bn=tn(u({},un,{dataTransfer:0})),mn=tn(u({},sn,{relatedTarget:0})),hn=tn(u({},an,{animationName:0,elapsedTime:0,pseudoElement:0})),pn=tn(u({},an,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}})),fn=tn(u({},an,{data:0})),gn={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},yn={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},vn={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function xn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=vn[e])&&!!t[e]}function wn(){return xn}var kn=tn(u({},sn,{key:function(e){if(e.key){var t=gn[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?13===(e=Jt(e))?"Enter":String.fromCharCode(e):"keydown"===e.type||"keyup"===e.type?yn[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:wn,charCode:function(e){return"keypress"===e.type?Jt(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?Jt(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}})),Cn=tn(u({},un,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Sn=tn(u({},sn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:wn})),jn=tn(u({},an,{propertyName:0,elapsedTime:0,pseudoElement:0})),Nn=tn(u({},un,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),En=tn(u({},an,{newState:0,oldState:0})),$n=[9,13,27,32],_n=Vt&&"CompositionEvent"in window,Tn=null;Vt&&"documentMode"in document&&(Tn=document.documentMode);var zn=Vt&&"TextEvent"in window&&!Tn,Ln=Vt&&(!_n||Tn&&8<Tn&&11>=Tn),An=String.fromCharCode(32),Mn=!1;function Pn(e,t){switch(e){case"keyup":return-1!==$n.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function In(e){return"object"==typeof(e=e.detail)&&"data"in e?e.data:null}var Dn=!1;var On={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Rn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!On[e.type]:"textarea"===t}function Fn(e,t,n,l){Rt?Ft?Ft.push(l):Ft=[l]:Rt=l,0<(t=id(t,"onChange")).length&&(n=new on("onChange","change",null,n,l),e.push({event:n,listeners:t}))}var Un=null,Bn=null;function Wn(e){Zu(e,0)}function qn(e){if(yt(nt(e)))return e}function Vn(e,t){if("change"===e)return t}var Hn=!1;if(Vt){var Kn;if(Vt){var Gn="oninput"in document;if(!Gn){var Qn=document.createElement("div");Qn.setAttribute("oninput","return;"),Gn="function"==typeof Qn.oninput}Kn=Gn}else Kn=!1;Hn=Kn&&(!document.documentMode||9<document.documentMode)}function Xn(){Un&&(Un.detachEvent("onpropertychange",Yn),Bn=Un=null)}function Yn(e){if("value"===e.propertyName&&qn(Bn)){var t=[];Fn(t,Bn,e,Ot(e)),Wt(Wn,t)}}function Jn(e,t,n){"focusin"===e?(Xn(),Bn=n,(Un=t).attachEvent("onpropertychange",Yn)):"focusout"===e&&Xn()}function Zn(e){if("selectionchange"===e||"keyup"===e||"keydown"===e)return qn(Bn)}function el(e,t){if("click"===e)return qn(t)}function tl(e,t){if("input"===e||"change"===e)return qn(t)}var nl="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t};function ll(e,t){if(nl(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),l=Object.keys(t);if(n.length!==l.length)return!1;for(l=0;l<n.length;l++){var r=n[l];if(!ie.call(t,r)||!nl(e[r],t[r]))return!1}return!0}function rl(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function al(e,t){var n,l=rl(e);for(e=0;l;){if(3===l.nodeType){if(n=e+l.textContent.length,e<=t&&n>=t)return{node:l,offset:t-e};e=n}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=rl(l)}}function ol(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?ol(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function il(e){for(var t=vt((e=null!=e&&null!=e.ownerDocument&&null!=e.ownerDocument.defaultView?e.ownerDocument.defaultView:window).document);t instanceof e.HTMLIFrameElement;){try{var n="string"==typeof t.contentWindow.location.href}catch(l){n=!1}if(!n)break;t=vt((e=t.contentWindow).document)}return t}function sl(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}var cl=Vt&&"documentMode"in document&&11>=document.documentMode,ul=null,dl=null,bl=null,ml=!1;function hl(e,t,n){var l=n.window===n?n.document:9===n.nodeType?n:n.ownerDocument;ml||null==ul||ul!==vt(l)||("selectionStart"in(l=ul)&&sl(l)?l={start:l.selectionStart,end:l.selectionEnd}:l={anchorNode:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset},bl&&ll(bl,l)||(bl=l,0<(l=id(dl,"onSelect")).length&&(t=new on("onSelect","select",null,t,n),e.push({event:t,listeners:l}),t.target=ul)))}function pl(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var fl={animationend:pl("Animation","AnimationEnd"),animationiteration:pl("Animation","AnimationIteration"),animationstart:pl("Animation","AnimationStart"),transitionrun:pl("Transition","TransitionRun"),transitionstart:pl("Transition","TransitionStart"),transitioncancel:pl("Transition","TransitionCancel"),transitionend:pl("Transition","TransitionEnd")},gl={},yl={};function vl(e){if(gl[e])return gl[e];if(!fl[e])return e;var t,n=fl[e];for(t in n)if(n.hasOwnProperty(t)&&t in yl)return gl[e]=n[t];return e}Vt&&(yl=document.createElement("div").style,"AnimationEvent"in window||(delete fl.animationend.animation,delete fl.animationiteration.animation,delete fl.animationstart.animation),"TransitionEvent"in window||delete fl.transitionend.transition);var xl=vl("animationend"),wl=vl("animationiteration"),kl=vl("animationstart"),Cl=vl("transitionrun"),Sl=vl("transitionstart"),jl=vl("transitioncancel"),Nl=vl("transitionend"),El=new Map,$l="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function _l(e,t){El.set(e,t),it(t,[e])}$l.push("scrollEnd");var Tl="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"==typeof process&&"function"==typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)},zl=[],Ll=0,Al=0;function Ml(){for(var e=Ll,t=Al=Ll=0;t<e;){var n=zl[t];zl[t++]=null;var l=zl[t];zl[t++]=null;var r=zl[t];zl[t++]=null;var a=zl[t];if(zl[t++]=null,null!==l&&null!==r){var o=l.pending;null===o?r.next=r:(r.next=o.next,o.next=r),l.pending=r}0!==a&&Ol(n,r,a)}}function Pl(e,t,n,l){zl[Ll++]=e,zl[Ll++]=t,zl[Ll++]=n,zl[Ll++]=l,Al|=l,e.lanes|=l,null!==(e=e.alternate)&&(e.lanes|=l)}function Il(e,t,n,l){return Pl(e,t,n,l),Rl(e)}function Dl(e,t){return Pl(e,null,null,t),Rl(e)}function Ol(e,t,n){e.lanes|=n;var l=e.alternate;null!==l&&(l.lanes|=n);for(var r=!1,a=e.return;null!==a;)a.childLanes|=n,null!==(l=a.alternate)&&(l.childLanes|=n),22===a.tag&&(null===(e=a.stateNode)||1&e._visibility||(r=!0)),e=a,a=a.return;return 3===e.tag?(a=e.stateNode,r&&null!==t&&(r=31-Se(n),null===(l=(e=a.hiddenUpdates)[r])?e[r]=[t]:l.push(t),t.lane=536870912|n),a):null}function Rl(e){if(50<Gc)throw Gc=0,Qc=null,Error(l(185));for(var t=e.return;null!==t;)t=(e=t).return;return 3===e.tag?e.stateNode:null}var Fl={};function Ul(e,t,n,l){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Bl(e,t,n,l){return new Ul(e,t,n,l)}function Wl(e){return!(!(e=e.prototype)||!e.isReactComponent)}function ql(e,t){var n=e.alternate;return null===n?((n=Bl(e.tag,t,e.key,e.mode)).elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=65011712&e.flags,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Vl(e,t){e.flags&=65011714;var n=e.alternate;return null===n?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Hl(e,t,n,r,a,o){var i=0;if(r=e,"function"==typeof e)Wl(e)&&(i=1);else if("string"==typeof e)i=function(e,t,n){if(1===n||null!=t.itemProp)return!1;switch(e){case"meta":case"title":return!0;case"style":if("string"!=typeof t.precedence||"string"!=typeof t.href||""===t.href)break;return!0;case"link":if("string"!=typeof t.rel||"string"!=typeof t.href||""===t.href||t.onLoad||t.onError)break;return"stylesheet"!==t.rel||(e=t.disabled,"string"==typeof t.precedence&&null==e);case"script":if(t.async&&"function"!=typeof t.async&&"symbol"!=typeof t.async&&!t.onLoad&&!t.onError&&t.src&&"string"==typeof t.src)return!0}return!1}(e,n,G.current)?26:"html"===e||"head"===e||"body"===e?27:5;else e:switch(e){case E:return(e=Bl(31,n,t,a)).elementType=E,e.lanes=o,e;case h:return Kl(n.children,a,o,t);case p:i=8,a|=24;break;case f:return(e=Bl(12,n,t,2|a)).elementType=f,e.lanes=o,e;case w:return(e=Bl(13,n,t,a)).elementType=w,e.lanes=o,e;case k:return(e=Bl(19,n,t,a)).elementType=k,e.lanes=o,e;default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case v:i=10;break e;case y:i=9;break e;case x:i=11;break e;case S:i=14;break e;case j:i=16,r=null;break e}i=29,n=Error(l(130,null===e?"null":typeof e,"")),r=null}return(t=Bl(i,n,t,a)).elementType=e,t.type=r,t.lanes=o,t}function Kl(e,t,n,l){return(e=Bl(7,e,l,t)).lanes=n,e}function Gl(e,t,n){return(e=Bl(6,e,null,t)).lanes=n,e}function Ql(e){var t=Bl(18,null,null,0);return t.stateNode=e,t}function Xl(e,t,n){return(t=Bl(4,null!==e.children?e.children:[],e.key,t)).lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Yl=new WeakMap;function Jl(e,t){if("object"==typeof e&&null!==e){var n=Yl.get(e);return void 0!==n?n:(t={value:e,source:t,stack:oe(t)},Yl.set(e,t),t)}return{value:e,source:t,stack:oe(t)}}var Zl=[],er=0,tr=null,nr=0,lr=[],rr=0,ar=null,or=1,ir="";function sr(e,t){Zl[er++]=nr,Zl[er++]=tr,tr=e,nr=t}function cr(e,t,n){lr[rr++]=or,lr[rr++]=ir,lr[rr++]=ar,ar=e;var l=or;e=ir;var r=32-Se(l)-1;l&=~(1<<r),n+=1;var a=32-Se(t)+r;if(30<a){var o=r-r%5;a=(l&(1<<o)-1).toString(32),l>>=o,r-=o,or=1<<32-Se(t)+r|n<<r|l,ir=a+e}else or=1<<a|n<<r|l,ir=e}function ur(e){null!==e.return&&(sr(e,1),cr(e,1,0))}function dr(e){for(;e===tr;)tr=Zl[--er],Zl[er]=null,nr=Zl[--er],Zl[er]=null;for(;e===ar;)ar=lr[--rr],lr[rr]=null,ir=lr[--rr],lr[rr]=null,or=lr[--rr],lr[rr]=null}function br(e,t){lr[rr++]=or,lr[rr++]=ir,lr[rr++]=ar,or=t.id,ir=t.overflow,ar=e}var mr=null,hr=null,pr=!1,fr=null,gr=!1,yr=Error(l(519));function vr(e){throw jr(Jl(Error(l(418,1<arguments.length&&void 0!==arguments[1]&&arguments[1]?"text":"HTML","")),e)),yr}function xr(e){var t=e.stateNode,n=e.type,l=e.memoizedProps;switch(t[Ve]=e,t[He]=l,n){case"dialog":ed("cancel",t),ed("close",t);break;case"iframe":case"object":case"embed":ed("load",t);break;case"video":case"audio":for(n=0;n<Yu.length;n++)ed(Yu[n],t);break;case"source":ed("error",t);break;case"img":case"image":case"link":ed("error",t),ed("load",t);break;case"details":ed("toggle",t);break;case"input":ed("invalid",t),Ct(t,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":ed("invalid",t);break;case"textarea":ed("invalid",t),Et(t,l.value,l.defaultValue,l.children)}"string"!=typeof(n=l.children)&&"number"!=typeof n&&"bigint"!=typeof n||t.textContent===""+n||!0===l.suppressHydrationWarning||md(t.textContent,n)?(null!=l.popover&&(ed("beforetoggle",t),ed("toggle",t)),null!=l.onScroll&&ed("scroll",t),null!=l.onScrollEnd&&ed("scrollend",t),null!=l.onClick&&(t.onclick=It),t=!0):t=!1,t||vr(e,!0)}function wr(e){for(mr=e.return;mr;)switch(mr.tag){case 5:case 31:case 13:return void(gr=!1);case 27:case 3:return void(gr=!0);default:mr=mr.return}}function kr(e){if(e!==mr)return!1;if(!pr)return wr(e),pr=!0,!1;var t,n=e.tag;if((t=3!==n&&27!==n)&&((t=5===n)&&(t=!("form"!==(t=e.type)&&"button"!==t)||Cd(e.type,e.memoizedProps)),t=!t),t&&hr&&vr(e),wr(e),13===n){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(l(317));hr=Rd(e)}else if(31===n){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(l(317));hr=Rd(e)}else 27===n?(n=hr,Td(e.type)?(e=Od,Od=null,hr=e):hr=n):hr=mr?Dd(e.stateNode.nextSibling):null;return!0}function Cr(){hr=mr=null,pr=!1}function Sr(){var e=fr;return null!==e&&(null===Mc?Mc=e:Mc.push.apply(Mc,e),fr=null),e}function jr(e){null===fr?fr=[e]:fr.push(e)}var Nr=W(null),Er=null,$r=null;function _r(e,t,n){V(Nr,t._currentValue),t._currentValue=n}function Tr(e){e._currentValue=Nr.current,q(Nr)}function zr(e,t,n){for(;null!==e;){var l=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,null!==l&&(l.childLanes|=t)):null!==l&&(l.childLanes&t)!==t&&(l.childLanes|=t),e===n)break;e=e.return}}function Lr(e,t,n,r){var a=e.child;for(null!==a&&(a.return=e);null!==a;){var o=a.dependencies;if(null!==o){var i=a.child;o=o.firstContext;e:for(;null!==o;){var s=o;o=a;for(var c=0;c<t.length;c++)if(s.context===t[c]){o.lanes|=n,null!==(s=o.alternate)&&(s.lanes|=n),zr(o.return,n,e),r||(i=null);break e}o=s.next}}else if(18===a.tag){if(null===(i=a.return))throw Error(l(341));i.lanes|=n,null!==(o=i.alternate)&&(o.lanes|=n),zr(i,n,e),i=null}else i=a.child;if(null!==i)i.return=a;else for(i=a;null!==i;){if(i===e){i=null;break}if(null!==(a=i.sibling)){a.return=i.return,i=a;break}i=i.return}a=i}}function Ar(e,t,n,r){e=null;for(var a=t,o=!1;null!==a;){if(!o)if(524288&a.flags)o=!0;else if(262144&a.flags)break;if(10===a.tag){var i=a.alternate;if(null===i)throw Error(l(387));if(null!==(i=i.memoizedProps)){var s=a.type;nl(a.pendingProps.value,i.value)||(null!==e?e.push(s):e=[s])}}else if(a===Y.current){if(null===(i=a.alternate))throw Error(l(387));i.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(null!==e?e.push(hb):e=[hb])}a=a.return}null!==e&&Lr(t,e,n,r),t.flags|=262144}function Mr(e){for(e=e.firstContext;null!==e;){if(!nl(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Pr(e){Er=e,$r=null,null!==(e=e.dependencies)&&(e.firstContext=null)}function Ir(e){return Or(Er,e)}function Dr(e,t){return null===Er&&Pr(e),Or(e,t)}function Or(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},null===$r){if(null===e)throw Error(l(308));$r=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else $r=$r.next=t;return n}var Rr="undefined"!=typeof AbortController?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Fr=e.unstable_scheduleCallback,Ur=e.unstable_NormalPriority,Br={$$typeof:v,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Wr(){return{controller:new Rr,data:new Map,refCount:0}}function qr(e){e.refCount--,0===e.refCount&&Fr(Ur,function(){e.controller.abort()})}var Vr=null,Hr=0,Kr=0,Gr=null;function Qr(){if(0===--Hr&&null!==Vr){null!==Gr&&(Gr.status="fulfilled");var e=Vr;Vr=null,Kr=0,Gr=null;for(var t=0;t<e.length;t++)(0,e[t])()}}var Xr=O.S;O.S=function(e,t){Dc=be(),"object"==typeof t&&null!==t&&"function"==typeof t.then&&function(e,t){if(null===Vr){var n=Vr=[];Hr=0,Kr=Hu(),Gr={status:"pending",value:void 0,then:function(e){n.push(e)}}}Hr++,t.then(Qr,Qr)}(0,t),null!==Xr&&Xr(e,t)};var Yr=W(null);function Jr(){var e=Yr.current;return null!==e?e:yc.pooledCache}function Zr(e,t){V(Yr,null===t?Yr.current:t.pool)}function ea(){var e=Jr();return null===e?null:{parent:Br._currentValue,pool:e}}var ta=Error(l(460)),na=Error(l(474)),la=Error(l(542)),ra={then:function(){}};function aa(e){return"fulfilled"===(e=e.status)||"rejected"===e}function oa(e,t,n){switch(void 0===(n=e[n])?e.push(t):n!==t&&(t.then(It,It),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw ua(e=t.reason),e;default:if("string"==typeof t.status)t.then(It,It);else{if(null!==(e=yc)&&100<e.shellSuspendCounter)throw Error(l(482));(e=t).status="pending",e.then(function(e){if("pending"===t.status){var n=t;n.status="fulfilled",n.value=e}},function(e){if("pending"===t.status){var n=t;n.status="rejected",n.reason=e}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw ua(e=t.reason),e}throw sa=t,ta}}function ia(e){try{return(0,e._init)(e._payload)}catch(t){if(null!==t&&"object"==typeof t&&"function"==typeof t.then)throw sa=t,ta;throw t}}var sa=null;function ca(){if(null===sa)throw Error(l(459));var e=sa;return sa=null,e}function ua(e){if(e===ta||e===la)throw Error(l(483))}var da=null,ba=0;function ma(e){var t=ba;return ba+=1,null===da&&(da=[]),oa(da,e,t)}function ha(e,t){t=t.props.ref,e.ref=void 0!==t?t:null}function pa(e,t){if(t.$$typeof===d)throw Error(l(525));throw e=Object.prototype.toString.call(t),Error(l(31,"[object Object]"===e?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function fa(e){function t(t,n){if(e){var l=t.deletions;null===l?(t.deletions=[n],t.flags|=16):l.push(n)}}function n(n,l){if(!e)return null;for(;null!==l;)t(n,l),l=l.sibling;return null}function r(e){for(var t=new Map;null!==e;)null!==e.key?t.set(e.key,e):t.set(e.index,e),e=e.sibling;return t}function a(e,t){return(e=ql(e,t)).index=0,e.sibling=null,e}function o(t,n,l){return t.index=l,e?null!==(l=t.alternate)?(l=l.index)<n?(t.flags|=67108866,n):l:(t.flags|=67108866,n):(t.flags|=1048576,n)}function i(t){return e&&null===t.alternate&&(t.flags|=67108866),t}function s(e,t,n,l){return null===t||6!==t.tag?((t=Gl(n,e.mode,l)).return=e,t):((t=a(t,n)).return=e,t)}function c(e,t,n,l){var r=n.type;return r===h?d(e,t,n.props.children,l,n.key):null!==t&&(t.elementType===r||"object"==typeof r&&null!==r&&r.$$typeof===j&&ia(r)===t.type)?(ha(t=a(t,n.props),n),t.return=e,t):(ha(t=Hl(n.type,n.key,n.props,null,e.mode,l),n),t.return=e,t)}function u(e,t,n,l){return null===t||4!==t.tag||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?((t=Xl(n,e.mode,l)).return=e,t):((t=a(t,n.children||[])).return=e,t)}function d(e,t,n,l,r){return null===t||7!==t.tag?((t=Kl(n,e.mode,l,r)).return=e,t):((t=a(t,n)).return=e,t)}function p(e,t,n){if("string"==typeof t&&""!==t||"number"==typeof t||"bigint"==typeof t)return(t=Gl(""+t,e.mode,n)).return=e,t;if("object"==typeof t&&null!==t){switch(t.$$typeof){case b:return ha(n=Hl(t.type,t.key,t.props,null,e.mode,n),t),n.return=e,n;case m:return(t=Xl(t,e.mode,n)).return=e,t;case j:return p(e,t=ia(t),n)}if(D(t)||M(t))return(t=Kl(t,e.mode,n,null)).return=e,t;if("function"==typeof t.then)return p(e,ma(t),n);if(t.$$typeof===v)return p(e,Dr(e,t),n);pa(e,t)}return null}function f(e,t,n,l){var r=null!==t?t.key:null;if("string"==typeof n&&""!==n||"number"==typeof n||"bigint"==typeof n)return null!==r?null:s(e,t,""+n,l);if("object"==typeof n&&null!==n){switch(n.$$typeof){case b:return n.key===r?c(e,t,n,l):null;case m:return n.key===r?u(e,t,n,l):null;case j:return f(e,t,n=ia(n),l)}if(D(n)||M(n))return null!==r?null:d(e,t,n,l,null);if("function"==typeof n.then)return f(e,t,ma(n),l);if(n.$$typeof===v)return f(e,t,Dr(e,n),l);pa(e,n)}return null}function g(e,t,n,l,r){if("string"==typeof l&&""!==l||"number"==typeof l||"bigint"==typeof l)return s(t,e=e.get(n)||null,""+l,r);if("object"==typeof l&&null!==l){switch(l.$$typeof){case b:return c(t,e=e.get(null===l.key?n:l.key)||null,l,r);case m:return u(t,e=e.get(null===l.key?n:l.key)||null,l,r);case j:return g(e,t,n,l=ia(l),r)}if(D(l)||M(l))return d(t,e=e.get(n)||null,l,r,null);if("function"==typeof l.then)return g(e,t,n,ma(l),r);if(l.$$typeof===v)return g(e,t,n,Dr(t,l),r);pa(t,l)}return null}function y(s,c,u,d){if("object"==typeof u&&null!==u&&u.type===h&&null===u.key&&(u=u.props.children),"object"==typeof u&&null!==u){switch(u.$$typeof){case b:e:{for(var x=u.key;null!==c;){if(c.key===x){if((x=u.type)===h){if(7===c.tag){n(s,c.sibling),(d=a(c,u.props.children)).return=s,s=d;break e}}else if(c.elementType===x||"object"==typeof x&&null!==x&&x.$$typeof===j&&ia(x)===c.type){n(s,c.sibling),ha(d=a(c,u.props),u),d.return=s,s=d;break e}n(s,c);break}t(s,c),c=c.sibling}u.type===h?((d=Kl(u.props.children,s.mode,d,u.key)).return=s,s=d):(ha(d=Hl(u.type,u.key,u.props,null,s.mode,d),u),d.return=s,s=d)}return i(s);case m:e:{for(x=u.key;null!==c;){if(c.key===x){if(4===c.tag&&c.stateNode.containerInfo===u.containerInfo&&c.stateNode.implementation===u.implementation){n(s,c.sibling),(d=a(c,u.children||[])).return=s,s=d;break e}n(s,c);break}t(s,c),c=c.sibling}(d=Xl(u,s.mode,d)).return=s,s=d}return i(s);case j:return y(s,c,u=ia(u),d)}if(D(u))return function(l,a,i,s){for(var c=null,u=null,d=a,b=a=0,m=null;null!==d&&b<i.length;b++){d.index>b?(m=d,d=null):m=d.sibling;var h=f(l,d,i[b],s);if(null===h){null===d&&(d=m);break}e&&d&&null===h.alternate&&t(l,d),a=o(h,a,b),null===u?c=h:u.sibling=h,u=h,d=m}if(b===i.length)return n(l,d),pr&&sr(l,b),c;if(null===d){for(;b<i.length;b++)null!==(d=p(l,i[b],s))&&(a=o(d,a,b),null===u?c=d:u.sibling=d,u=d);return pr&&sr(l,b),c}for(d=r(d);b<i.length;b++)null!==(m=g(d,l,b,i[b],s))&&(e&&null!==m.alternate&&d.delete(null===m.key?b:m.key),a=o(m,a,b),null===u?c=m:u.sibling=m,u=m);return e&&d.forEach(function(e){return t(l,e)}),pr&&sr(l,b),c}(s,c,u,d);if(M(u)){if("function"!=typeof(x=M(u)))throw Error(l(150));return function(a,i,s,c){if(null==s)throw Error(l(151));for(var u=null,d=null,b=i,m=i=0,h=null,y=s.next();null!==b&&!y.done;m++,y=s.next()){b.index>m?(h=b,b=null):h=b.sibling;var v=f(a,b,y.value,c);if(null===v){null===b&&(b=h);break}e&&b&&null===v.alternate&&t(a,b),i=o(v,i,m),null===d?u=v:d.sibling=v,d=v,b=h}if(y.done)return n(a,b),pr&&sr(a,m),u;if(null===b){for(;!y.done;m++,y=s.next())null!==(y=p(a,y.value,c))&&(i=o(y,i,m),null===d?u=y:d.sibling=y,d=y);return pr&&sr(a,m),u}for(b=r(b);!y.done;m++,y=s.next())null!==(y=g(b,a,m,y.value,c))&&(e&&null!==y.alternate&&b.delete(null===y.key?m:y.key),i=o(y,i,m),null===d?u=y:d.sibling=y,d=y);return e&&b.forEach(function(e){return t(a,e)}),pr&&sr(a,m),u}(s,c,u=x.call(u),d)}if("function"==typeof u.then)return y(s,c,ma(u),d);if(u.$$typeof===v)return y(s,c,Dr(s,u),d);pa(s,u)}return"string"==typeof u&&""!==u||"number"==typeof u||"bigint"==typeof u?(u=""+u,null!==c&&6===c.tag?(n(s,c.sibling),(d=a(c,u)).return=s,s=d):(n(s,c),(d=Gl(u,s.mode,d)).return=s,s=d),i(s)):n(s,c)}return function(e,t,n,l){try{ba=0;var r=y(e,t,n,l);return da=null,r}catch(o){if(o===ta||o===la)throw o;var a=Bl(29,o,null,e.mode);return a.lanes=l,a.return=e,a}}}var ga=fa(!0),ya=fa(!1),va=!1;function xa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function wa(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function ka(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Ca(e,t,n){var l=e.updateQueue;if(null===l)return null;if(l=l.shared,2&gc){var r=l.pending;return null===r?t.next=t:(t.next=r.next,r.next=t),l.pending=t,t=Rl(e),Ol(e,null,n),t}return Pl(e,l,t,n),Rl(e)}function Sa(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,4194048&n)){var l=t.lanes;n|=l&=e.pendingLanes,t.lanes=n,Oe(e,n)}}function ja(e,t){var n=e.updateQueue,l=e.alternate;if(null!==l&&n===(l=l.updateQueue)){var r=null,a=null;if(null!==(n=n.firstBaseUpdate)){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};null===a?r=a=o:a=a.next=o,n=n.next}while(null!==n);null===a?r=a=t:a=a.next=t}else r=a=t;return n={baseState:l.baseState,firstBaseUpdate:r,lastBaseUpdate:a,shared:l.shared,callbacks:l.callbacks},void(e.updateQueue=n)}null===(e=n.lastBaseUpdate)?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Na=!1;function Ea(){if(Na){if(null!==Gr)throw Gr}}function $a(e,t,n,l){Na=!1;var r=e.updateQueue;va=!1;var a=r.firstBaseUpdate,o=r.lastBaseUpdate,i=r.shared.pending;if(null!==i){r.shared.pending=null;var s=i,c=s.next;s.next=null,null===o?a=c:o.next=c,o=s;var d=e.alternate;null!==d&&((i=(d=d.updateQueue).lastBaseUpdate)!==o&&(null===i?d.firstBaseUpdate=c:i.next=c,d.lastBaseUpdate=s))}if(null!==a){var b=r.baseState;for(o=0,d=c=s=null,i=a;;){var m=-536870913&i.lane,h=m!==i.lane;if(h?(xc&m)===m:(l&m)===m){0!==m&&m===Kr&&(Na=!0),null!==d&&(d=d.next={lane:0,tag:i.tag,payload:i.payload,callback:null,next:null});e:{var p=e,f=i;m=t;var g=n;switch(f.tag){case 1:if("function"==typeof(p=f.payload)){b=p.call(g,b,m);break e}b=p;break e;case 3:p.flags=-65537&p.flags|128;case 0:if(null==(m="function"==typeof(p=f.payload)?p.call(g,b,m):p))break e;b=u({},b,m);break e;case 2:va=!0}}null!==(m=i.callback)&&(e.flags|=64,h&&(e.flags|=8192),null===(h=r.callbacks)?r.callbacks=[m]:h.push(m))}else h={lane:m,tag:i.tag,payload:i.payload,callback:i.callback,next:null},null===d?(c=d=h,s=b):d=d.next=h,o|=m;if(null===(i=i.next)){if(null===(i=r.shared.pending))break;i=(h=i).next,h.next=null,r.lastBaseUpdate=h,r.shared.pending=null}}null===d&&(s=b),r.baseState=s,r.firstBaseUpdate=c,r.lastBaseUpdate=d,null===a&&(r.shared.lanes=0),$c|=o,e.lanes=o,e.memoizedState=b}}function _a(e,t){if("function"!=typeof e)throw Error(l(191,e));e.call(t)}function Ta(e,t){var n=e.callbacks;if(null!==n)for(e.callbacks=null,e=0;e<n.length;e++)_a(n[e],t)}var za=W(null),La=W(0);function Aa(e,t){V(La,e=Nc),V(za,t),Nc=e|t.baseLanes}function Ma(){V(La,Nc),V(za,za.current)}function Pa(){Nc=La.current,q(za),q(La)}var Ia=W(null),Da=null;function Oa(e){var t=e.alternate;V(Wa,1&Wa.current),V(Ia,e),null===Da&&(null===t||null!==za.current||null!==t.memoizedState)&&(Da=e)}function Ra(e){V(Wa,Wa.current),V(Ia,e),null===Da&&(Da=e)}function Fa(e){22===e.tag?(V(Wa,Wa.current),V(Ia,e),null===Da&&(Da=e)):Ua()}function Ua(){V(Wa,Wa.current),V(Ia,Ia.current)}function Ba(e){q(Ia),Da===e&&(Da=null),q(Wa)}var Wa=W(0);function qa(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||Pd(n)||Id(n)))return t}else if(19!==t.tag||"forwards"!==t.memoizedProps.revealOrder&&"backwards"!==t.memoizedProps.revealOrder&&"unstable_legacy-backwards"!==t.memoizedProps.revealOrder&&"together"!==t.memoizedProps.revealOrder){if(null!==t.child){t.child.return=t,t=t.child;continue}}else if(128&t.flags)return t;if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Va=0,Ha=null,Ka=null,Ga=null,Qa=!1,Xa=!1,Ya=!1,Ja=0,Za=0,eo=null,to=0;function no(){throw Error(l(321))}function lo(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!nl(e[n],t[n]))return!1;return!0}function ro(e,t,n,l,r,a){return Va=a,Ha=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,O.H=null===e||null===e.memoizedState?xi:wi,Ya=!1,a=n(l,r),Ya=!1,Xa&&(a=oo(t,n,l,r)),ao(e),a}function ao(e){O.H=vi;var t=null!==Ka&&null!==Ka.next;if(Va=0,Ga=Ka=Ha=null,Qa=!1,Za=0,eo=null,t)throw Error(l(300));null===e||Di||null!==(e=e.dependencies)&&Mr(e)&&(Di=!0)}function oo(e,t,n,r){Ha=e;var a=0;do{if(Xa&&(eo=null),Za=0,Xa=!1,25<=a)throw Error(l(301));if(a+=1,Ga=Ka=null,null!=e.updateQueue){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,null!=o.memoCache&&(o.memoCache.index=0)}O.H=ki,o=t(n,r)}while(Xa);return o}function io(){var e=O.H,t=e.useState()[0];return t="function"==typeof t.then?ho(t):t,e=e.useState()[0],(null!==Ka?Ka.memoizedState:null)!==e&&(Ha.flags|=1024),t}function so(){var e=0!==Ja;return Ja=0,e}function co(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function uo(e){if(Qa){for(e=e.memoizedState;null!==e;){var t=e.queue;null!==t&&(t.pending=null),e=e.next}Qa=!1}Va=0,Ga=Ka=Ha=null,Xa=!1,Za=Ja=0,eo=null}function bo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===Ga?Ha.memoizedState=Ga=e:Ga=Ga.next=e,Ga}function mo(){if(null===Ka){var e=Ha.alternate;e=null!==e?e.memoizedState:null}else e=Ka.next;var t=null===Ga?Ha.memoizedState:Ga.next;if(null!==t)Ga=t,Ka=e;else{if(null===e){if(null===Ha.alternate)throw Error(l(467));throw Error(l(310))}e={memoizedState:(Ka=e).memoizedState,baseState:Ka.baseState,baseQueue:Ka.baseQueue,queue:Ka.queue,next:null},null===Ga?Ha.memoizedState=Ga=e:Ga=Ga.next=e}return Ga}function ho(e){var t=Za;return Za+=1,null===eo&&(eo=[]),e=oa(eo,e,t),t=Ha,null===(null===Ga?t.memoizedState:Ga.next)&&(t=t.alternate,O.H=null===t||null===t.memoizedState?xi:wi),e}function po(e){if(null!==e&&"object"==typeof e){if("function"==typeof e.then)return ho(e);if(e.$$typeof===v)return Ir(e)}throw Error(l(438,String(e)))}function fo(e){var t=null,n=Ha.updateQueue;if(null!==n&&(t=n.memoCache),null==t){var l=Ha.alternate;null!==l&&(null!==(l=l.updateQueue)&&(null!=(l=l.memoCache)&&(t={data:l.data.map(function(e){return e.slice()}),index:0})))}if(null==t&&(t={data:[],index:0}),null===n&&(n={lastEffect:null,events:null,stores:null,memoCache:null},Ha.updateQueue=n),n.memoCache=t,void 0===(n=t.data[t.index]))for(n=t.data[t.index]=Array(e),l=0;l<e;l++)n[l]=T;return t.index++,n}function go(e,t){return"function"==typeof t?t(e):t}function yo(e){return vo(mo(),Ka,e)}function vo(e,t,n){var r=e.queue;if(null===r)throw Error(l(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(null!==o){if(null!==a){var i=a.next;a.next=o.next,o.next=i}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,null===a)e.memoizedState=o;else{var s=i=null,c=null,u=t=a.next,d=!1;do{var b=-536870913&u.lane;if(b!==u.lane?(xc&b)===b:(Va&b)===b){var m=u.revertLane;if(0===m)null!==c&&(c=c.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),b===Kr&&(d=!0);else{if((Va&m)===m){u=u.next,m===Kr&&(d=!0);continue}b={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(s=c=b,i=o):c=c.next=b,Ha.lanes|=m,$c|=m}b=u.action,Ya&&n(o,b),o=u.hasEagerState?u.eagerState:n(o,b)}else m={lane:b,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(s=c=m,i=o):c=c.next=m,Ha.lanes|=b,$c|=b;u=u.next}while(null!==u&&u!==t);if(null===c?i=o:c.next=s,!nl(o,e.memoizedState)&&(Di=!0,d&&null!==(n=Gr)))throw n;e.memoizedState=o,e.baseState=i,e.baseQueue=c,r.lastRenderedState=o}return null===a&&(r.lanes=0),[e.memoizedState,r.dispatch]}function xo(e){var t=mo(),n=t.queue;if(null===n)throw Error(l(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(null!==a){n.pending=null;var i=a=a.next;do{o=e(o,i.action),i=i.next}while(i!==a);nl(o,t.memoizedState)||(Di=!0),t.memoizedState=o,null===t.baseQueue&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function wo(e,t,n){var r=Ha,a=mo(),o=pr;if(o){if(void 0===n)throw Error(l(407));n=n()}else n=t();var i=!nl((Ka||a).memoizedState,n);if(i&&(a.memoizedState=n,Di=!0),a=a.queue,Ho(So.bind(null,r,a,e),[e]),a.getSnapshot!==t||i||null!==Ga&&1&Ga.memoizedState.tag){if(r.flags|=2048,Uo(9,{destroy:void 0},Co.bind(null,r,a,n,t),null),null===yc)throw Error(l(349));o||127&Va||ko(r,t,n)}return n}function ko(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},null===(t=Ha.updateQueue)?(t={lastEffect:null,events:null,stores:null,memoCache:null},Ha.updateQueue=t,t.stores=[e]):null===(n=t.stores)?t.stores=[e]:n.push(e)}function Co(e,t,n,l){t.value=n,t.getSnapshot=l,jo(t)&&No(e)}function So(e,t,n){return n(function(){jo(t)&&No(e)})}function jo(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!nl(e,n)}catch(l){return!0}}function No(e){var t=Dl(e,2);null!==t&&Jc(t,e,2)}function Eo(e){var t=bo();if("function"==typeof e){var n=e;if(e=n(),Ya){Ce(!0);try{n()}finally{Ce(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:go,lastRenderedState:e},t}function $o(e,t,n,l){return e.baseState=n,vo(e,Ka,"function"==typeof l?l:go)}function _o(e,t,n,r,a){if(fi(e))throw Error(l(485));if(null!==(e=t.action)){var o={payload:a,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};null!==O.T?n(!0):o.isTransition=!1,r(o),null===(n=t.pending)?(o.next=t.pending=o,To(t,o)):(o.next=n.next,t.pending=n.next=o)}}function To(e,t){var n=t.action,l=t.payload,r=e.state;if(t.isTransition){var a=O.T,o={};O.T=o;try{var i=n(r,l),s=O.S;null!==s&&s(o,i),zo(e,t,i)}catch(c){Ao(e,t,c)}finally{null!==a&&null!==o.types&&(a.types=o.types),O.T=a}}else try{zo(e,t,a=n(r,l))}catch(u){Ao(e,t,u)}}function zo(e,t,n){null!==n&&"object"==typeof n&&"function"==typeof n.then?n.then(function(n){Lo(e,t,n)},function(n){return Ao(e,t,n)}):Lo(e,t,n)}function Lo(e,t,n){t.status="fulfilled",t.value=n,Mo(t),e.state=n,null!==(t=e.pending)&&((n=t.next)===t?e.pending=null:(n=n.next,t.next=n,To(e,n)))}function Ao(e,t,n){var l=e.pending;if(e.pending=null,null!==l){l=l.next;do{t.status="rejected",t.reason=n,Mo(t),t=t.next}while(t!==l)}e.action=null}function Mo(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Po(e,t){return t}function Io(e,t){if(pr){var n=yc.formState;if(null!==n){e:{var l=Ha;if(pr){if(hr){t:{for(var r=hr,a=gr;8!==r.nodeType;){if(!a){r=null;break t}if(null===(r=Dd(r.nextSibling))){r=null;break t}}r="F!"===(a=r.data)||"F"===a?r:null}if(r){hr=Dd(r.nextSibling),l="F!"===r.data;break e}}vr(l)}l=!1}l&&(t=n[0])}}return(n=bo()).memoizedState=n.baseState=t,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Po,lastRenderedState:t},n.queue=l,n=mi.bind(null,Ha,l),l.dispatch=n,l=Eo(!1),a=pi.bind(null,Ha,!1,l.queue),r={state:t,dispatch:null,action:e,pending:null},(l=bo()).queue=r,n=_o.bind(null,Ha,r,a,n),r.dispatch=n,l.memoizedState=e,[t,n,!1]}function Do(e){return Oo(mo(),Ka,e)}function Oo(e,t,n){if(t=vo(e,t,Po)[0],e=yo(go)[0],"object"==typeof t&&null!==t&&"function"==typeof t.then)try{var l=ho(t)}catch(o){if(o===ta)throw la;throw o}else l=t;var r=(t=mo()).queue,a=r.dispatch;return n!==t.memoizedState&&(Ha.flags|=2048,Uo(9,{destroy:void 0},Ro.bind(null,r,n),null)),[l,a,e]}function Ro(e,t){e.action=t}function Fo(e){var t=mo(),n=Ka;if(null!==n)return Oo(t,n,e);mo(),t=t.memoizedState;var l=(n=mo()).queue.dispatch;return n.memoizedState=e,[t,l,!1]}function Uo(e,t,n,l){return e={tag:e,create:n,deps:l,inst:t,next:null},null===(t=Ha.updateQueue)&&(t={lastEffect:null,events:null,stores:null,memoCache:null},Ha.updateQueue=t),null===(n=t.lastEffect)?t.lastEffect=e.next=e:(l=n.next,n.next=e,e.next=l,t.lastEffect=e),e}function Bo(){return mo().memoizedState}function Wo(e,t,n,l){var r=bo();Ha.flags|=e,r.memoizedState=Uo(1|t,{destroy:void 0},n,void 0===l?null:l)}function qo(e,t,n,l){var r=mo();l=void 0===l?null:l;var a=r.memoizedState.inst;null!==Ka&&null!==l&&lo(l,Ka.memoizedState.deps)?r.memoizedState=Uo(t,a,n,l):(Ha.flags|=e,r.memoizedState=Uo(1|t,a,n,l))}function Vo(e,t){Wo(8390656,8,e,t)}function Ho(e,t){qo(2048,8,e,t)}function Ko(e){var t=mo().memoizedState;return function(e){Ha.flags|=4;var t=Ha.updateQueue;if(null===t)t={lastEffect:null,events:null,stores:null,memoCache:null},Ha.updateQueue=t,t.events=[e];else{var n=t.events;null===n?t.events=[e]:n.push(e)}}({ref:t,nextImpl:e}),function(){if(2&gc)throw Error(l(440));return t.impl.apply(void 0,arguments)}}function Go(e,t){return qo(4,2,e,t)}function Qo(e,t){return qo(4,4,e,t)}function Xo(e,t){if("function"==typeof t){e=e();var n=t(e);return function(){"function"==typeof n?n():t(null)}}if(null!=t)return e=e(),t.current=e,function(){t.current=null}}function Yo(e,t,n){n=null!=n?n.concat([e]):null,qo(4,4,Xo.bind(null,t,e),n)}function Jo(){}function Zo(e,t){var n=mo();t=void 0===t?null:t;var l=n.memoizedState;return null!==t&&lo(t,l[1])?l[0]:(n.memoizedState=[e,t],e)}function ei(e,t){var n=mo();t=void 0===t?null:t;var l=n.memoizedState;if(null!==t&&lo(t,l[1]))return l[0];if(l=e(),Ya){Ce(!0);try{e()}finally{Ce(!1)}}return n.memoizedState=[l,t],l}function ti(e,t,n){return void 0===n||1073741824&Va&&!(261930&xc)?e.memoizedState=t:(e.memoizedState=n,e=Yc(),Ha.lanes|=e,$c|=e,n)}function ni(e,t,n,l){return nl(n,t)?n:null!==za.current?(e=ti(e,n,l),nl(e,t)||(Di=!0),e):42&Va&&(!(1073741824&Va)||261930&xc)?(e=Yc(),Ha.lanes|=e,$c|=e,t):(Di=!0,e.memoizedState=n)}function li(e,t,n,l,r){var a=R.p;R.p=0!==a&&8>a?a:8;var o,i,s,c=O.T,u={};O.T=u,pi(e,!1,t,n);try{var d=r(),b=O.S;if(null!==b&&b(u,d),null!==d&&"object"==typeof d&&"function"==typeof d.then)hi(e,t,(o=l,i=[],s={status:"pending",value:null,reason:null,then:function(e){i.push(e)}},d.then(function(){s.status="fulfilled",s.value=o;for(var e=0;e<i.length;e++)(0,i[e])(o)},function(e){for(s.status="rejected",s.reason=e,e=0;e<i.length;e++)(0,i[e])(void 0)}),s),Xc());else hi(e,t,l,Xc())}catch(m){hi(e,t,{then:function(){},status:"rejected",reason:m},Xc())}finally{R.p=a,null!==c&&null!==u.types&&(c.types=u.types),O.T=c}}function ri(){}function ai(e,t,n,r){if(5!==e.tag)throw Error(l(476));var a=oi(e).queue;li(e,a,t,F,null===n?ri:function(){return ii(e),n(r)})}function oi(e){var t=e.memoizedState;if(null!==t)return t;var n={};return(t={memoizedState:F,baseState:F,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:go,lastRenderedState:F},next:null}).next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:go,lastRenderedState:n},next:null},e.memoizedState=t,null!==(e=e.alternate)&&(e.memoizedState=t),t}function ii(e){var t=oi(e);null===t.next&&(t=e.alternate.memoizedState),hi(e,t.next.queue,{},Xc())}function si(){return Ir(hb)}function ci(){return mo().memoizedState}function ui(){return mo().memoizedState}function di(e){for(var t=e.return;null!==t;){switch(t.tag){case 24:case 3:var n=Xc(),l=Ca(t,e=ka(n),n);return null!==l&&(Jc(l,t,n),Sa(l,t,n)),t={cache:Wr()},void(e.payload=t)}t=t.return}}function bi(e,t,n){var l=Xc();n={lane:l,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},fi(e)?gi(t,n):null!==(n=Il(e,t,n,l))&&(Jc(n,e,l),yi(n,t,l))}function mi(e,t,n){hi(e,t,n,Xc())}function hi(e,t,n,l){var r={lane:l,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(fi(e))gi(t,r);else{var a=e.alternate;if(0===e.lanes&&(null===a||0===a.lanes)&&null!==(a=t.lastRenderedReducer))try{var o=t.lastRenderedState,i=a(o,n);if(r.hasEagerState=!0,r.eagerState=i,nl(i,o))return Pl(e,t,r,0),null===yc&&Ml(),!1}catch(s){}if(null!==(n=Il(e,t,r,l)))return Jc(n,e,l),yi(n,t,l),!0}return!1}function pi(e,t,n,r){if(r={lane:2,revertLane:Hu(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},fi(e)){if(t)throw Error(l(479))}else null!==(t=Il(e,n,r,2))&&Jc(t,e,2)}function fi(e){var t=e.alternate;return e===Ha||null!==t&&t===Ha}function gi(e,t){Xa=Qa=!0;var n=e.pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function yi(e,t,n){if(4194048&n){var l=t.lanes;n|=l&=e.pendingLanes,t.lanes=n,Oe(e,n)}}var vi={readContext:Ir,use:po,useCallback:no,useContext:no,useEffect:no,useImperativeHandle:no,useLayoutEffect:no,useInsertionEffect:no,useMemo:no,useReducer:no,useRef:no,useState:no,useDebugValue:no,useDeferredValue:no,useTransition:no,useSyncExternalStore:no,useId:no,useHostTransitionStatus:no,useFormState:no,useActionState:no,useOptimistic:no,useMemoCache:no,useCacheRefresh:no};vi.useEffectEvent=no;var xi={readContext:Ir,use:po,useCallback:function(e,t){return bo().memoizedState=[e,void 0===t?null:t],e},useContext:Ir,useEffect:Vo,useImperativeHandle:function(e,t,n){n=null!=n?n.concat([e]):null,Wo(4194308,4,Xo.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Wo(4194308,4,e,t)},useInsertionEffect:function(e,t){Wo(4,2,e,t)},useMemo:function(e,t){var n=bo();t=void 0===t?null:t;var l=e();if(Ya){Ce(!0);try{e()}finally{Ce(!1)}}return n.memoizedState=[l,t],l},useReducer:function(e,t,n){var l=bo();if(void 0!==n){var r=n(t);if(Ya){Ce(!0);try{n(t)}finally{Ce(!1)}}}else r=t;return l.memoizedState=l.baseState=r,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:r},l.queue=e,e=e.dispatch=bi.bind(null,Ha,e),[l.memoizedState,e]},useRef:function(e){return e={current:e},bo().memoizedState=e},useState:function(e){var t=(e=Eo(e)).queue,n=mi.bind(null,Ha,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Jo,useDeferredValue:function(e,t){return ti(bo(),e,t)},useTransition:function(){var e=Eo(!1);return e=li.bind(null,Ha,e.queue,!0,!1),bo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=Ha,a=bo();if(pr){if(void 0===n)throw Error(l(407));n=n()}else{if(n=t(),null===yc)throw Error(l(349));127&xc||ko(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,Vo(So.bind(null,r,o,e),[e]),r.flags|=2048,Uo(9,{destroy:void 0},Co.bind(null,r,o,n,t),null),n},useId:function(){var e=bo(),t=yc.identifierPrefix;if(pr){var n=ir;t="_"+t+"R_"+(n=(or&~(1<<32-Se(or)-1)).toString(32)+n),0<(n=Ja++)&&(t+="H"+n.toString(32)),t+="_"}else t="_"+t+"r_"+(n=to++).toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:si,useFormState:Io,useActionState:Io,useOptimistic:function(e){var t=bo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=pi.bind(null,Ha,!0,n),n.dispatch=t,[e,t]},useMemoCache:fo,useCacheRefresh:function(){return bo().memoizedState=di.bind(null,Ha)},useEffectEvent:function(e){var t=bo(),n={impl:e};return t.memoizedState=n,function(){if(2&gc)throw Error(l(440));return n.impl.apply(void 0,arguments)}}},wi={readContext:Ir,use:po,useCallback:Zo,useContext:Ir,useEffect:Ho,useImperativeHandle:Yo,useInsertionEffect:Go,useLayoutEffect:Qo,useMemo:ei,useReducer:yo,useRef:Bo,useState:function(){return yo(go)},useDebugValue:Jo,useDeferredValue:function(e,t){return ni(mo(),Ka.memoizedState,e,t)},useTransition:function(){var e=yo(go)[0],t=mo().memoizedState;return["boolean"==typeof e?e:ho(e),t]},useSyncExternalStore:wo,useId:ci,useHostTransitionStatus:si,useFormState:Do,useActionState:Do,useOptimistic:function(e,t){return $o(mo(),0,e,t)},useMemoCache:fo,useCacheRefresh:ui};wi.useEffectEvent=Ko;var ki={readContext:Ir,use:po,useCallback:Zo,useContext:Ir,useEffect:Ho,useImperativeHandle:Yo,useInsertionEffect:Go,useLayoutEffect:Qo,useMemo:ei,useReducer:xo,useRef:Bo,useState:function(){return xo(go)},useDebugValue:Jo,useDeferredValue:function(e,t){var n=mo();return null===Ka?ti(n,e,t):ni(n,Ka.memoizedState,e,t)},useTransition:function(){var e=xo(go)[0],t=mo().memoizedState;return["boolean"==typeof e?e:ho(e),t]},useSyncExternalStore:wo,useId:ci,useHostTransitionStatus:si,useFormState:Fo,useActionState:Fo,useOptimistic:function(e,t){var n=mo();return null!==Ka?$o(n,0,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:fo,useCacheRefresh:ui};function Ci(e,t,n,l){n=null==(n=n(l,t=e.memoizedState))?t:u({},t,n),e.memoizedState=n,0===e.lanes&&(e.updateQueue.baseState=n)}ki.useEffectEvent=Ko;var Si={enqueueSetState:function(e,t,n){e=e._reactInternals;var l=Xc(),r=ka(l);r.payload=t,null!=n&&(r.callback=n),null!==(t=Ca(e,r,l))&&(Jc(t,e,l),Sa(t,e,l))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var l=Xc(),r=ka(l);r.tag=1,r.payload=t,null!=n&&(r.callback=n),null!==(t=Ca(e,r,l))&&(Jc(t,e,l),Sa(t,e,l))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Xc(),l=ka(n);l.tag=2,null!=t&&(l.callback=t),null!==(t=Ca(e,l,n))&&(Jc(t,e,n),Sa(t,e,n))}};function ji(e,t,n,l,r,a,o){return"function"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(l,a,o):!t.prototype||!t.prototype.isPureReactComponent||(!ll(n,l)||!ll(r,a))}function Ni(e,t,n,l){e=t.state,"function"==typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,l),"function"==typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,l),t.state!==e&&Si.enqueueReplaceState(t,t.state,null)}function Ei(e,t){var n=t;if("ref"in t)for(var l in n={},t)"ref"!==l&&(n[l]=t[l]);if(e=e.defaultProps)for(var r in n===t&&(n=u({},n)),e)void 0===n[r]&&(n[r]=e[r]);return n}function $i(e){Tl(e)}function _i(e){console.error(e)}function Ti(e){Tl(e)}function zi(e,t){try{(0,e.onUncaughtError)(t.value,{componentStack:t.stack})}catch(n){setTimeout(function(){throw n})}}function Li(e,t,n){try{(0,e.onCaughtError)(n.value,{componentStack:n.stack,errorBoundary:1===t.tag?t.stateNode:null})}catch(l){setTimeout(function(){throw l})}}function Ai(e,t,n){return(n=ka(n)).tag=3,n.payload={element:null},n.callback=function(){zi(e,t)},n}function Mi(e){return(e=ka(e)).tag=3,e}function Pi(e,t,n,l){var r=n.type.getDerivedStateFromError;if("function"==typeof r){var a=l.value;e.payload=function(){return r(a)},e.callback=function(){Li(t,n,l)}}var o=n.stateNode;null!==o&&"function"==typeof o.componentDidCatch&&(e.callback=function(){Li(t,n,l),"function"!=typeof r&&(null===Fc?Fc=new Set([this]):Fc.add(this));var e=l.stack;this.componentDidCatch(l.value,{componentStack:null!==e?e:""})})}var Ii=Error(l(461)),Di=!1;function Oi(e,t,n,l){t.child=null===e?ya(t,null,n,l):ga(t,e.child,n,l)}function Ri(e,t,n,l,r){n=n.render;var a=t.ref;if("ref"in l){var o={};for(var i in l)"ref"!==i&&(o[i]=l[i])}else o=l;return Pr(t),l=ro(e,t,n,o,a,r),i=so(),null===e||Di?(pr&&i&&ur(t),t.flags|=1,Oi(e,t,l,r),t.child):(co(e,t,r),ss(e,t,r))}function Fi(e,t,n,l,r){if(null===e){var a=n.type;return"function"!=typeof a||Wl(a)||void 0!==a.defaultProps||null!==n.compare?((e=Hl(n.type,null,l,t,t.mode,r)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=a,Ui(e,t,a,l,r))}if(a=e.child,!cs(e,r)){var o=a.memoizedProps;if((n=null!==(n=n.compare)?n:ll)(o,l)&&e.ref===t.ref)return ss(e,t,r)}return t.flags|=1,(e=ql(a,l)).ref=t.ref,e.return=t,t.child=e}function Ui(e,t,n,l,r){if(null!==e){var a=e.memoizedProps;if(ll(a,l)&&e.ref===t.ref){if(Di=!1,t.pendingProps=l=a,!cs(e,r))return t.lanes=e.lanes,ss(e,t,r);131072&e.flags&&(Di=!0)}}return Gi(e,t,n,l,r)}function Bi(e,t,n,l){var r=l.children,a=null!==e?e.memoizedState:null;if(null===e&&null===t.stateNode&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),"hidden"===l.mode){if(128&t.flags){if(a=null!==a?a.baseLanes|n:n,null!==e){for(l=t.child=e.child,r=0;null!==l;)r=r|l.lanes|l.childLanes,l=l.sibling;l=r&~a}else l=0,t.child=null;return qi(e,t,a,n,l)}if(!(536870912&n))return l=t.lanes=536870912,qi(e,t,null!==a?a.baseLanes|n:n,n,l);t.memoizedState={baseLanes:0,cachePool:null},null!==e&&Zr(0,null!==a?a.cachePool:null),null!==a?Aa(t,a):Ma(),Fa(t)}else null!==a?(Zr(0,a.cachePool),Aa(t,a),Ua(),t.memoizedState=null):(null!==e&&Zr(0,null),Ma(),Ua());return Oi(e,t,r,n),t.child}function Wi(e,t){return null!==e&&22===e.tag||null!==t.stateNode||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function qi(e,t,n,l,r){var a=Jr();return a=null===a?null:{parent:Br._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},null!==e&&Zr(0,null),Ma(),Fa(t),null!==e&&Ar(e,t,l,!0),t.childLanes=r,null}function Vi(e,t){return(t=ls({mode:t.mode,children:t.children},e.mode)).ref=e.ref,e.child=t,t.return=e,t}function Hi(e,t,n){return ga(t,e.child,null,n),(e=Vi(t,t.pendingProps)).flags|=2,Ba(t),t.memoizedState=null,e}function Ki(e,t){var n=t.ref;if(null===n)null!==e&&null!==e.ref&&(t.flags|=4194816);else{if("function"!=typeof n&&"object"!=typeof n)throw Error(l(284));null!==e&&e.ref===n||(t.flags|=4194816)}}function Gi(e,t,n,l,r){return Pr(t),n=ro(e,t,n,l,void 0,r),l=so(),null===e||Di?(pr&&l&&ur(t),t.flags|=1,Oi(e,t,n,r),t.child):(co(e,t,r),ss(e,t,r))}function Qi(e,t,n,l,r,a){return Pr(t),t.updateQueue=null,n=oo(t,l,n,r),ao(e),l=so(),null===e||Di?(pr&&l&&ur(t),t.flags|=1,Oi(e,t,n,a),t.child):(co(e,t,a),ss(e,t,a))}function Xi(e,t,n,l,r){if(Pr(t),null===t.stateNode){var a=Fl,o=n.contextType;"object"==typeof o&&null!==o&&(a=Ir(o)),a=new n(l,a),t.memoizedState=null!==a.state&&void 0!==a.state?a.state:null,a.updater=Si,t.stateNode=a,a._reactInternals=t,(a=t.stateNode).props=l,a.state=t.memoizedState,a.refs={},xa(t),o=n.contextType,a.context="object"==typeof o&&null!==o?Ir(o):Fl,a.state=t.memoizedState,"function"==typeof(o=n.getDerivedStateFromProps)&&(Ci(t,n,o,l),a.state=t.memoizedState),"function"==typeof n.getDerivedStateFromProps||"function"==typeof a.getSnapshotBeforeUpdate||"function"!=typeof a.UNSAFE_componentWillMount&&"function"!=typeof a.componentWillMount||(o=a.state,"function"==typeof a.componentWillMount&&a.componentWillMount(),"function"==typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount(),o!==a.state&&Si.enqueueReplaceState(a,a.state,null),$a(t,l,a,r),Ea(),a.state=t.memoizedState),"function"==typeof a.componentDidMount&&(t.flags|=4194308),l=!0}else if(null===e){a=t.stateNode;var i=t.memoizedProps,s=Ei(n,i);a.props=s;var c=a.context,u=n.contextType;o=Fl,"object"==typeof u&&null!==u&&(o=Ir(u));var d=n.getDerivedStateFromProps;u="function"==typeof d||"function"==typeof a.getSnapshotBeforeUpdate,i=t.pendingProps!==i,u||"function"!=typeof a.UNSAFE_componentWillReceiveProps&&"function"!=typeof a.componentWillReceiveProps||(i||c!==o)&&Ni(t,a,l,o),va=!1;var b=t.memoizedState;a.state=b,$a(t,l,a,r),Ea(),c=t.memoizedState,i||b!==c||va?("function"==typeof d&&(Ci(t,n,d,l),c=t.memoizedState),(s=va||ji(t,n,s,l,b,c,o))?(u||"function"!=typeof a.UNSAFE_componentWillMount&&"function"!=typeof a.componentWillMount||("function"==typeof a.componentWillMount&&a.componentWillMount(),"function"==typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount()),"function"==typeof a.componentDidMount&&(t.flags|=4194308)):("function"==typeof a.componentDidMount&&(t.flags|=4194308),t.memoizedProps=l,t.memoizedState=c),a.props=l,a.state=c,a.context=o,l=s):("function"==typeof a.componentDidMount&&(t.flags|=4194308),l=!1)}else{a=t.stateNode,wa(e,t),u=Ei(n,o=t.memoizedProps),a.props=u,d=t.pendingProps,b=a.context,c=n.contextType,s=Fl,"object"==typeof c&&null!==c&&(s=Ir(c)),(c="function"==typeof(i=n.getDerivedStateFromProps)||"function"==typeof a.getSnapshotBeforeUpdate)||"function"!=typeof a.UNSAFE_componentWillReceiveProps&&"function"!=typeof a.componentWillReceiveProps||(o!==d||b!==s)&&Ni(t,a,l,s),va=!1,b=t.memoizedState,a.state=b,$a(t,l,a,r),Ea();var m=t.memoizedState;o!==d||b!==m||va||null!==e&&null!==e.dependencies&&Mr(e.dependencies)?("function"==typeof i&&(Ci(t,n,i,l),m=t.memoizedState),(u=va||ji(t,n,u,l,b,m,s)||null!==e&&null!==e.dependencies&&Mr(e.dependencies))?(c||"function"!=typeof a.UNSAFE_componentWillUpdate&&"function"!=typeof a.componentWillUpdate||("function"==typeof a.componentWillUpdate&&a.componentWillUpdate(l,m,s),"function"==typeof a.UNSAFE_componentWillUpdate&&a.UNSAFE_componentWillUpdate(l,m,s)),"function"==typeof a.componentDidUpdate&&(t.flags|=4),"function"==typeof a.getSnapshotBeforeUpdate&&(t.flags|=1024)):("function"!=typeof a.componentDidUpdate||o===e.memoizedProps&&b===e.memoizedState||(t.flags|=4),"function"!=typeof a.getSnapshotBeforeUpdate||o===e.memoizedProps&&b===e.memoizedState||(t.flags|=1024),t.memoizedProps=l,t.memoizedState=m),a.props=l,a.state=m,a.context=s,l=u):("function"!=typeof a.componentDidUpdate||o===e.memoizedProps&&b===e.memoizedState||(t.flags|=4),"function"!=typeof a.getSnapshotBeforeUpdate||o===e.memoizedProps&&b===e.memoizedState||(t.flags|=1024),l=!1)}return a=l,Ki(e,t),l=!!(128&t.flags),a||l?(a=t.stateNode,n=l&&"function"!=typeof n.getDerivedStateFromError?null:a.render(),t.flags|=1,null!==e&&l?(t.child=ga(t,e.child,null,r),t.child=ga(t,null,n,r)):Oi(e,t,n,r),t.memoizedState=a.state,e=t.child):e=ss(e,t,r),e}function Yi(e,t,n,l){return Cr(),t.flags|=256,Oi(e,t,n,l),t.child}var Ji={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Zi(e){return{baseLanes:e,cachePool:ea()}}function es(e,t,n){return e=null!==e?e.childLanes&~n:0,t&&(e|=zc),e}function ts(e,t,n){var r,a=t.pendingProps,o=!1,i=!!(128&t.flags);if((r=i)||(r=(null===e||null!==e.memoizedState)&&!!(2&Wa.current)),r&&(o=!0,t.flags&=-129),r=!!(32&t.flags),t.flags&=-33,null===e){if(pr){if(o?Oa(t):Ua(),(e=hr)?null!==(e=null!==(e=Md(e,gr))&&"&"!==e.data?e:null)&&(t.memoizedState={dehydrated:e,treeContext:null!==ar?{id:or,overflow:ir}:null,retryLane:536870912,hydrationErrors:null},(n=Ql(e)).return=t,t.child=n,mr=t,hr=null):e=null,null===e)throw vr(t);return Id(e)?t.lanes=32:t.lanes=536870912,null}var s=a.children;return a=a.fallback,o?(Ua(),s=ls({mode:"hidden",children:s},o=t.mode),a=Kl(a,o,n,null),s.return=t,a.return=t,s.sibling=a,t.child=s,(a=t.child).memoizedState=Zi(n),a.childLanes=es(e,r,n),t.memoizedState=Ji,Wi(null,a)):(Oa(t),ns(t,s))}var c=e.memoizedState;if(null!==c&&null!==(s=c.dehydrated)){if(i)256&t.flags?(Oa(t),t.flags&=-257,t=rs(e,t,n)):null!==t.memoizedState?(Ua(),t.child=e.child,t.flags|=128,t=null):(Ua(),s=a.fallback,o=t.mode,a=ls({mode:"visible",children:a.children},o),(s=Kl(s,o,n,null)).flags|=2,a.return=t,s.return=t,a.sibling=s,t.child=a,ga(t,e.child,null,n),(a=t.child).memoizedState=Zi(n),a.childLanes=es(e,r,n),t.memoizedState=Ji,t=Wi(null,a));else if(Oa(t),Id(s)){if(r=s.nextSibling&&s.nextSibling.dataset)var u=r.dgst;r=u,(a=Error(l(419))).stack="",a.digest=r,jr({value:a,source:null,stack:null}),t=rs(e,t,n)}else if(Di||Ar(e,t,n,!1),r=0!==(n&e.childLanes),Di||r){if(null!==(r=yc)&&(0!==(a=Re(r,n))&&a!==c.retryLane))throw c.retryLane=a,Dl(e,a),Jc(r,e,a),Ii;Pd(s)||uu(),t=rs(e,t,n)}else Pd(s)?(t.flags|=192,t.child=e.child,t=null):(e=c.treeContext,hr=Dd(s.nextSibling),mr=t,pr=!0,fr=null,gr=!1,null!==e&&br(t,e),(t=ns(t,a.children)).flags|=4096);return t}return o?(Ua(),s=a.fallback,o=t.mode,u=(c=e.child).sibling,(a=ql(c,{mode:"hidden",children:a.children})).subtreeFlags=65011712&c.subtreeFlags,null!==u?s=ql(u,s):(s=Kl(s,o,n,null)).flags|=2,s.return=t,a.return=t,a.sibling=s,t.child=a,Wi(null,a),a=t.child,null===(s=e.child.memoizedState)?s=Zi(n):(null!==(o=s.cachePool)?(c=Br._currentValue,o=o.parent!==c?{parent:c,pool:c}:o):o=ea(),s={baseLanes:s.baseLanes|n,cachePool:o}),a.memoizedState=s,a.childLanes=es(e,r,n),t.memoizedState=Ji,Wi(e.child,a)):(Oa(t),e=(n=e.child).sibling,(n=ql(n,{mode:"visible",children:a.children})).return=t,n.sibling=null,null!==e&&(null===(r=t.deletions)?(t.deletions=[e],t.flags|=16):r.push(e)),t.child=n,t.memoizedState=null,n)}function ns(e,t){return(t=ls({mode:"visible",children:t},e.mode)).return=e,e.child=t}function ls(e,t){return(e=Bl(22,e,null,t)).lanes=0,e}function rs(e,t,n){return ga(t,e.child,null,n),(e=ns(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function as(e,t,n){e.lanes|=t;var l=e.alternate;null!==l&&(l.lanes|=t),zr(e.return,t,n)}function os(e,t,n,l,r,a){var o=e.memoizedState;null===o?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:l,tail:n,tailMode:r,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=l,o.tail=n,o.tailMode=r,o.treeForkCount=a)}function is(e,t,n){var l=t.pendingProps,r=l.revealOrder,a=l.tail;l=l.children;var o=Wa.current,i=!!(2&o);if(i?(o=1&o|2,t.flags|=128):o&=1,V(Wa,o),Oi(e,t,l,n),l=pr?nr:0,!i&&null!==e&&128&e.flags)e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&as(e,n,t);else if(19===e.tag)as(e,n,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(r){case"forwards":for(n=t.child,r=null;null!==n;)null!==(e=n.alternate)&&null===qa(e)&&(r=n),n=n.sibling;null===(n=r)?(r=t.child,t.child=null):(r=n.sibling,n.sibling=null),os(t,!1,r,n,a,l);break;case"backwards":case"unstable_legacy-backwards":for(n=null,r=t.child,t.child=null;null!==r;){if(null!==(e=r.alternate)&&null===qa(e)){t.child=r;break}e=r.sibling,r.sibling=n,n=r,r=e}os(t,!0,n,null,a,l);break;case"together":os(t,!1,null,null,void 0,l);break;default:t.memoizedState=null}return t.child}function ss(e,t,n){if(null!==e&&(t.dependencies=e.dependencies),$c|=t.lanes,0===(n&t.childLanes)){if(null===e)return null;if(Ar(e,t,n,!1),0===(n&t.childLanes))return null}if(null!==e&&t.child!==e.child)throw Error(l(153));if(null!==t.child){for(n=ql(e=t.child,e.pendingProps),t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=ql(e,e.pendingProps)).return=t;n.sibling=null}return t.child}function cs(e,t){return 0!==(e.lanes&t)||!(null===(e=e.dependencies)||!Mr(e))}function us(e,t,n){if(null!==e)if(e.memoizedProps!==t.pendingProps)Di=!0;else{if(!(cs(e,n)||128&t.flags))return Di=!1,function(e,t,n){switch(t.tag){case 3:J(t,t.stateNode.containerInfo),_r(0,Br,e.memoizedState.cache),Cr();break;case 27:case 5:ee(t);break;case 4:J(t,t.stateNode.containerInfo);break;case 10:_r(0,t.type,t.memoizedProps.value);break;case 31:if(null!==t.memoizedState)return t.flags|=128,Ra(t),null;break;case 13:var l=t.memoizedState;if(null!==l)return null!==l.dehydrated?(Oa(t),t.flags|=128,null):0!==(n&t.child.childLanes)?ts(e,t,n):(Oa(t),null!==(e=ss(e,t,n))?e.sibling:null);Oa(t);break;case 19:var r=!!(128&e.flags);if((l=0!==(n&t.childLanes))||(Ar(e,t,n,!1),l=0!==(n&t.childLanes)),r){if(l)return is(e,t,n);t.flags|=128}if(null!==(r=t.memoizedState)&&(r.rendering=null,r.tail=null,r.lastEffect=null),V(Wa,Wa.current),l)break;return null;case 22:return t.lanes=0,Bi(e,t,n,t.pendingProps);case 24:_r(0,Br,e.memoizedState.cache)}return ss(e,t,n)}(e,t,n);Di=!!(131072&e.flags)}else Di=!1,pr&&1048576&t.flags&&cr(t,nr,t.index);switch(t.lanes=0,t.tag){case 16:e:{var r=t.pendingProps;if(e=ia(t.elementType),t.type=e,"function"!=typeof e){if(null!=e){var a=e.$$typeof;if(a===x){t.tag=11,t=Ri(null,t,e,r,n);break e}if(a===S){t.tag=14,t=Fi(null,t,e,r,n);break e}}throw t=I(e)||e,Error(l(306,t,""))}Wl(e)?(r=Ei(e,r),t.tag=1,t=Xi(null,t,e,r,n)):(t.tag=0,t=Gi(null,t,e,r,n))}return t;case 0:return Gi(e,t,t.type,t.pendingProps,n);case 1:return Xi(e,t,r=t.type,a=Ei(r,t.pendingProps),n);case 3:e:{if(J(t,t.stateNode.containerInfo),null===e)throw Error(l(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,wa(e,t),$a(t,r,null,n);var i=t.memoizedState;if(r=i.cache,_r(0,Br,r),r!==o.cache&&Lr(t,[Br],n,!0),Ea(),r=i.element,o.isDehydrated){if(o={element:r,isDehydrated:!1,cache:i.cache},t.updateQueue.baseState=o,t.memoizedState=o,256&t.flags){t=Yi(e,t,r,n);break e}if(r!==a){jr(a=Jl(Error(l(424)),t)),t=Yi(e,t,r,n);break e}if(9===(e=t.stateNode.containerInfo).nodeType)e=e.body;else e="HTML"===e.nodeName?e.ownerDocument.body:e;for(hr=Dd(e.firstChild),mr=t,pr=!0,fr=null,gr=!0,n=ya(t,null,r,n),t.child=n;n;)n.flags=-3&n.flags|4096,n=n.sibling}else{if(Cr(),r===a){t=ss(e,t,n);break e}Oi(e,t,r,n)}t=t.child}return t;case 26:return Ki(e,t),null===e?(n=Qd(t.type,null,t.pendingProps,null))?t.memoizedState=n:pr||(n=t.type,e=t.pendingProps,(r=xd(X.current).createElement(n))[Ve]=t,r[He]=e,fd(r,n,e),rt(r),t.stateNode=r):t.memoizedState=Qd(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return ee(t),null===e&&pr&&(r=t.stateNode=Ud(t.type,t.pendingProps,X.current),mr=t,gr=!0,a=hr,Td(t.type)?(Od=a,hr=Dd(r.firstChild)):hr=a),Oi(e,t,t.pendingProps.children,n),Ki(e,t),null===e&&(t.flags|=4194304),t.child;case 5:return null===e&&pr&&((a=r=hr)&&(null!==(r=function(e,t,n,l){for(;1===e.nodeType;){var r=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!l&&("INPUT"!==e.nodeName||"hidden"!==e.type))break}else if(l){if(!e[Je])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if("stylesheet"===(a=e.getAttribute("rel"))&&e.hasAttribute("data-precedence"))break;if(a!==r.rel||e.getAttribute("href")!==(null==r.href||""===r.href?null:r.href)||e.getAttribute("crossorigin")!==(null==r.crossOrigin?null:r.crossOrigin)||e.getAttribute("title")!==(null==r.title?null:r.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(((a=e.getAttribute("src"))!==(null==r.src?null:r.src)||e.getAttribute("type")!==(null==r.type?null:r.type)||e.getAttribute("crossorigin")!==(null==r.crossOrigin?null:r.crossOrigin))&&a&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else{if("input"!==t||"hidden"!==e.type)return e;var a=null==r.name?null:""+r.name;if("hidden"===r.type&&e.getAttribute("name")===a)return e}if(null===(e=Dd(e.nextSibling)))break}return null}(r,t.type,t.pendingProps,gr))?(t.stateNode=r,mr=t,hr=Dd(r.firstChild),gr=!1,a=!0):a=!1),a||vr(t)),ee(t),a=t.type,o=t.pendingProps,i=null!==e?e.memoizedProps:null,r=o.children,Cd(a,o)?r=null:null!==i&&Cd(a,i)&&(t.flags|=32),null!==t.memoizedState&&(a=ro(e,t,io,null,null,n),hb._currentValue=a),Ki(e,t),Oi(e,t,r,n),t.child;case 6:return null===e&&pr&&((e=n=hr)&&(null!==(n=function(e,t,n){if(""===t)return null;for(;3!==e.nodeType;){if((1!==e.nodeType||"INPUT"!==e.nodeName||"hidden"!==e.type)&&!n)return null;if(null===(e=Dd(e.nextSibling)))return null}return e}(n,t.pendingProps,gr))?(t.stateNode=n,mr=t,hr=null,e=!0):e=!1),e||vr(t)),null;case 13:return ts(e,t,n);case 4:return J(t,t.stateNode.containerInfo),r=t.pendingProps,null===e?t.child=ga(t,null,r,n):Oi(e,t,r,n),t.child;case 11:return Ri(e,t,t.type,t.pendingProps,n);case 7:return Oi(e,t,t.pendingProps,n),t.child;case 8:case 12:return Oi(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,_r(0,t.type,r.value),Oi(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,Pr(t),r=r(a=Ir(a)),t.flags|=1,Oi(e,t,r,n),t.child;case 14:return Fi(e,t,t.type,t.pendingProps,n);case 15:return Ui(e,t,t.type,t.pendingProps,n);case 19:return is(e,t,n);case 31:return function(e,t,n){var r=t.pendingProps,a=!!(128&t.flags);if(t.flags&=-129,null===e){if(pr){if("hidden"===r.mode)return e=Vi(t,r),t.lanes=536870912,Wi(null,e);if(Ra(t),(e=hr)?null!==(e=null!==(e=Md(e,gr))&&"&"===e.data?e:null)&&(t.memoizedState={dehydrated:e,treeContext:null!==ar?{id:or,overflow:ir}:null,retryLane:536870912,hydrationErrors:null},(n=Ql(e)).return=t,t.child=n,mr=t,hr=null):e=null,null===e)throw vr(t);return t.lanes=536870912,null}return Vi(t,r)}var o=e.memoizedState;if(null!==o){var i=o.dehydrated;if(Ra(t),a)if(256&t.flags)t.flags&=-257,t=Hi(e,t,n);else{if(null===t.memoizedState)throw Error(l(558));t.child=e.child,t.flags|=128,t=null}else if(Di||Ar(e,t,n,!1),a=0!==(n&e.childLanes),Di||a){if(null!==(r=yc)&&0!==(i=Re(r,n))&&i!==o.retryLane)throw o.retryLane=i,Dl(e,i),Jc(r,e,i),Ii;uu(),t=Hi(e,t,n)}else e=o.treeContext,hr=Dd(i.nextSibling),mr=t,pr=!0,fr=null,gr=!1,null!==e&&br(t,e),(t=Vi(t,r)).flags|=4096;return t}return(e=ql(e.child,{mode:r.mode,children:r.children})).ref=t.ref,t.child=e,e.return=t,e}(e,t,n);case 22:return Bi(e,t,n,t.pendingProps);case 24:return Pr(t),r=Ir(Br),null===e?(null===(a=Jr())&&(a=yc,o=Wr(),a.pooledCache=o,o.refCount++,null!==o&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},xa(t),_r(0,Br,a)):(0!==(e.lanes&n)&&(wa(e,t),$a(t,null,null,n),Ea()),a=e.memoizedState,o=t.memoizedState,a.parent!==r?(a={parent:r,cache:r},t.memoizedState=a,0===t.lanes&&(t.memoizedState=t.updateQueue.baseState=a),_r(0,Br,r)):(r=o.cache,_r(0,Br,r),r!==a.cache&&Lr(t,[Br],n,!0))),Oi(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(l(156,t.tag))}function ds(e){e.flags|=4}function bs(e,t,n,l,r){if((t=!!(32&e.mode))&&(t=!1),t){if(e.flags|=16777216,(335544128&r)===r)if(e.stateNode.complete)e.flags|=8192;else{if(!iu())throw sa=ra,na;e.flags|=8192}}else e.flags&=-16777217}function ms(e,t){if("stylesheet"!==t.type||4&t.state.loading)e.flags&=-16777217;else if(e.flags|=16777216,!sb(t)){if(!iu())throw sa=ra,na;e.flags|=8192}}function hs(e,t){null!==t&&(e.flags|=4),16384&e.flags&&(t=22!==e.tag?Me():536870912,e.lanes|=t,Lc|=t)}function ps(e,t){if(!pr)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var l=null;null!==n;)null!==n.alternate&&(l=n),n=n.sibling;null===l?t||null===e.tail?e.tail=null:e.tail.sibling=null:l.sibling=null}}function fs(e){var t=null!==e.alternate&&e.alternate.child===e.child,n=0,l=0;if(t)for(var r=e.child;null!==r;)n|=r.lanes|r.childLanes,l|=65011712&r.subtreeFlags,l|=65011712&r.flags,r.return=e,r=r.sibling;else for(r=e.child;null!==r;)n|=r.lanes|r.childLanes,l|=r.subtreeFlags,l|=r.flags,r.return=e,r=r.sibling;return e.subtreeFlags|=l,e.childLanes=n,t}function gs(e,t,n){var r=t.pendingProps;switch(dr(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:case 1:return fs(t),null;case 3:return n=t.stateNode,r=null,null!==e&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Tr(Br),Z(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),null!==e&&null!==e.child||(kr(t)?ds(t):null===e||e.memoizedState.isDehydrated&&!(256&t.flags)||(t.flags|=1024,Sr())),fs(t),null;case 26:var a=t.type,o=t.memoizedState;return null===e?(ds(t),null!==o?(fs(t),ms(t,o)):(fs(t),bs(t,a,0,0,n))):o?o!==e.memoizedState?(ds(t),fs(t),ms(t,o)):(fs(t),t.flags&=-16777217):((e=e.memoizedProps)!==r&&ds(t),fs(t),bs(t,a,0,0,n)),null;case 27:if(te(t),n=X.current,a=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==r&&ds(t);else{if(!r){if(null===t.stateNode)throw Error(l(166));return fs(t),null}e=G.current,kr(t)?xr(t):(e=Ud(a,r,n),t.stateNode=e,ds(t))}return fs(t),null;case 5:if(te(t),a=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==r&&ds(t);else{if(!r){if(null===t.stateNode)throw Error(l(166));return fs(t),null}if(o=G.current,kr(t))xr(t);else{var i=xd(X.current);switch(o){case 1:o=i.createElementNS("http://www.w3.org/2000/svg",a);break;case 2:o=i.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;default:switch(a){case"svg":o=i.createElementNS("http://www.w3.org/2000/svg",a);break;case"math":o=i.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;case"script":(o=i.createElement("div")).innerHTML="<script><\/script>",o=o.removeChild(o.firstChild);break;case"select":o="string"==typeof r.is?i.createElement("select",{is:r.is}):i.createElement("select"),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o="string"==typeof r.is?i.createElement(a,{is:r.is}):i.createElement(a)}}o[Ve]=t,o[He]=r;e:for(i=t.child;null!==i;){if(5===i.tag||6===i.tag)o.appendChild(i.stateNode);else if(4!==i.tag&&27!==i.tag&&null!==i.child){i.child.return=i,i=i.child;continue}if(i===t)break e;for(;null===i.sibling;){if(null===i.return||i.return===t)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}t.stateNode=o;e:switch(fd(o,a,r),a){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}r&&ds(t)}}return fs(t),bs(t,t.type,null===e||e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&null!=t.stateNode)e.memoizedProps!==r&&ds(t);else{if("string"!=typeof r&&null===t.stateNode)throw Error(l(166));if(e=X.current,kr(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,null!==(a=mr))switch(a.tag){case 27:case 5:r=a.memoizedProps}e[Ve]=t,(e=!!(e.nodeValue===n||null!==r&&!0===r.suppressHydrationWarning||md(e.nodeValue,n)))||vr(t,!0)}else(e=xd(e).createTextNode(r))[Ve]=t,t.stateNode=e}return fs(t),null;case 31:if(n=t.memoizedState,null===e||null!==e.memoizedState){if(r=kr(t),null!==n){if(null===e){if(!r)throw Error(l(318));if(!(e=null!==(e=t.memoizedState)?e.dehydrated:null))throw Error(l(557));e[Ve]=t}else Cr(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;fs(t),e=!1}else n=Sr(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return 256&t.flags?(Ba(t),t):(Ba(t),null);if(128&t.flags)throw Error(l(558))}return fs(t),null;case 13:if(r=t.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(a=kr(t),null!==r&&null!==r.dehydrated){if(null===e){if(!a)throw Error(l(318));if(!(a=null!==(a=t.memoizedState)?a.dehydrated:null))throw Error(l(317));a[Ve]=t}else Cr(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;fs(t),a=!1}else a=Sr(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return 256&t.flags?(Ba(t),t):(Ba(t),null)}return Ba(t),128&t.flags?(t.lanes=n,t):(n=null!==r,e=null!==e&&null!==e.memoizedState,n&&(a=null,null!==(r=t.child).alternate&&null!==r.alternate.memoizedState&&null!==r.alternate.memoizedState.cachePool&&(a=r.alternate.memoizedState.cachePool.pool),o=null,null!==r.memoizedState&&null!==r.memoizedState.cachePool&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),hs(t,t.updateQueue),fs(t),null);case 4:return Z(),null===e&&ld(t.stateNode.containerInfo),fs(t),null;case 10:return Tr(t.type),fs(t),null;case 19:if(q(Wa),null===(r=t.memoizedState))return fs(t),null;if(a=!!(128&t.flags),null===(o=r.rendering))if(a)ps(r,!1);else{if(0!==Ec||null!==e&&128&e.flags)for(e=t.child;null!==e;){if(null!==(o=qa(e))){for(t.flags|=128,ps(r,!1),e=o.updateQueue,t.updateQueue=e,hs(t,e),t.subtreeFlags=0,e=n,n=t.child;null!==n;)Vl(n,e),n=n.sibling;return V(Wa,1&Wa.current|2),pr&&sr(t,r.treeForkCount),t.child}e=e.sibling}null!==r.tail&&be()>Oc&&(t.flags|=128,a=!0,ps(r,!1),t.lanes=4194304)}else{if(!a)if(null!==(e=qa(o))){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,hs(t,e),ps(r,!0),null===r.tail&&"hidden"===r.tailMode&&!o.alternate&&!pr)return fs(t),null}else 2*be()-r.renderingStartTime>Oc&&536870912!==n&&(t.flags|=128,a=!0,ps(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(null!==(e=r.last)?e.sibling=o:t.child=o,r.last=o)}return null!==r.tail?(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=be(),e.sibling=null,n=Wa.current,V(Wa,a?1&n|2:1&n),pr&&sr(t,r.treeForkCount),e):(fs(t),null);case 22:case 23:return Ba(t),Pa(),r=null!==t.memoizedState,null!==e?null!==e.memoizedState!==r&&(t.flags|=8192):r&&(t.flags|=8192),r?!!(536870912&n)&&!(128&t.flags)&&(fs(t),6&t.subtreeFlags&&(t.flags|=8192)):fs(t),null!==(n=t.updateQueue)&&hs(t,n.retryQueue),n=null,null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),r=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),null!==e&&q(Yr),null;case 24:return n=null,null!==e&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Tr(Br),fs(t),null;case 25:case 30:return null}throw Error(l(156,t.tag))}function ys(e,t){switch(dr(t),t.tag){case 1:return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return Tr(Br),Z(),65536&(e=t.flags)&&!(128&e)?(t.flags=-65537&e|128,t):null;case 26:case 27:case 5:return te(t),null;case 31:if(null!==t.memoizedState){if(Ba(t),null===t.alternate)throw Error(l(340));Cr()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 13:if(Ba(t),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(l(340));Cr()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return q(Wa),null;case 4:return Z(),null;case 10:return Tr(t.type),null;case 22:case 23:return Ba(t),Pa(),null!==e&&q(Yr),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 24:return Tr(Br),null;default:return null}}function vs(e,t){switch(dr(t),t.tag){case 3:Tr(Br),Z();break;case 26:case 27:case 5:te(t);break;case 4:Z();break;case 31:null!==t.memoizedState&&Ba(t);break;case 13:Ba(t);break;case 19:q(Wa);break;case 10:Tr(t.type);break;case 22:case 23:Ba(t),Pa(),null!==e&&q(Yr);break;case 24:Tr(Br)}}function xs(e,t){try{var n=t.updateQueue,l=null!==n?n.lastEffect:null;if(null!==l){var r=l.next;n=r;do{if((n.tag&e)===e){l=void 0;var a=n.create,o=n.inst;l=a(),o.destroy=l}n=n.next}while(n!==r)}}catch(i){Eu(t,t.return,i)}}function ws(e,t,n){try{var l=t.updateQueue,r=null!==l?l.lastEffect:null;if(null!==r){var a=r.next;l=a;do{if((l.tag&e)===e){var o=l.inst,i=o.destroy;if(void 0!==i){o.destroy=void 0,r=t;var s=n,c=i;try{c()}catch(u){Eu(r,s,u)}}}l=l.next}while(l!==a)}}catch(u){Eu(t,t.return,u)}}function ks(e){var t=e.updateQueue;if(null!==t){var n=e.stateNode;try{Ta(t,n)}catch(l){Eu(e,e.return,l)}}}function Cs(e,t,n){n.props=Ei(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(l){Eu(e,t,l)}}function Ss(e,t){try{var n=e.ref;if(null!==n){switch(e.tag){case 26:case 27:case 5:var l=e.stateNode;break;default:l=e.stateNode}"function"==typeof n?e.refCleanup=n(l):n.current=l}}catch(r){Eu(e,t,r)}}function js(e,t){var n=e.ref,l=e.refCleanup;if(null!==n)if("function"==typeof l)try{l()}catch(r){Eu(e,t,r)}finally{e.refCleanup=null,null!=(e=e.alternate)&&(e.refCleanup=null)}else if("function"==typeof n)try{n(null)}catch(a){Eu(e,t,a)}else n.current=null}function Ns(e){var t=e.type,n=e.memoizedProps,l=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&l.focus();break e;case"img":n.src?l.src=n.src:n.srcSet&&(l.srcset=n.srcSet)}}catch(r){Eu(e,e.return,r)}}function Es(e,t,n){try{var r=e.stateNode;!function(e,t,n,r){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var a=null,o=null,i=null,s=null,c=null,u=null,d=null;for(h in n){var b=n[h];if(n.hasOwnProperty(h)&&null!=b)switch(h){case"checked":case"value":break;case"defaultValue":c=b;default:r.hasOwnProperty(h)||hd(e,t,h,null,r,b)}}for(var m in r){var h=r[m];if(b=n[m],r.hasOwnProperty(m)&&(null!=h||null!=b))switch(m){case"type":o=h;break;case"name":a=h;break;case"checked":u=h;break;case"defaultChecked":d=h;break;case"value":i=h;break;case"defaultValue":s=h;break;case"children":case"dangerouslySetInnerHTML":if(null!=h)throw Error(l(137,t));break;default:h!==b&&hd(e,t,m,h,r,b)}}return void kt(e,i,s,c,u,d,o,a);case"select":for(o in h=i=s=m=null,n)if(c=n[o],n.hasOwnProperty(o)&&null!=c)switch(o){case"value":break;case"multiple":h=c;default:r.hasOwnProperty(o)||hd(e,t,o,null,r,c)}for(a in r)if(o=r[a],c=n[a],r.hasOwnProperty(a)&&(null!=o||null!=c))switch(a){case"value":m=o;break;case"defaultValue":s=o;break;case"multiple":i=o;default:o!==c&&hd(e,t,a,o,r,c)}return t=s,n=i,r=h,void(null!=m?jt(e,!!n,m,!1):!!r!=!!n&&(null!=t?jt(e,!!n,t,!0):jt(e,!!n,n?[]:"",!1)));case"textarea":for(s in h=m=null,n)if(a=n[s],n.hasOwnProperty(s)&&null!=a&&!r.hasOwnProperty(s))switch(s){case"value":case"children":break;default:hd(e,t,s,null,r,a)}for(i in r)if(a=r[i],o=n[i],r.hasOwnProperty(i)&&(null!=a||null!=o))switch(i){case"value":m=a;break;case"defaultValue":h=a;break;case"children":break;case"dangerouslySetInnerHTML":if(null!=a)throw Error(l(91));break;default:a!==o&&hd(e,t,i,a,r,o)}return void Nt(e,m,h);case"option":for(var p in n)if(m=n[p],n.hasOwnProperty(p)&&null!=m&&!r.hasOwnProperty(p))if("selected"===p)e.selected=!1;else hd(e,t,p,null,r,m);for(c in r)if(m=r[c],h=n[c],r.hasOwnProperty(c)&&m!==h&&(null!=m||null!=h))if("selected"===c)e.selected=m&&"function"!=typeof m&&"symbol"!=typeof m;else hd(e,t,c,m,r,h);return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var f in n)m=n[f],n.hasOwnProperty(f)&&null!=m&&!r.hasOwnProperty(f)&&hd(e,t,f,null,r,m);for(u in r)if(m=r[u],h=n[u],r.hasOwnProperty(u)&&m!==h&&(null!=m||null!=h))switch(u){case"children":case"dangerouslySetInnerHTML":if(null!=m)throw Error(l(137,t));break;default:hd(e,t,u,m,r,h)}return;default:if(Lt(t)){for(var g in n)m=n[g],n.hasOwnProperty(g)&&void 0!==m&&!r.hasOwnProperty(g)&&pd(e,t,g,void 0,r,m);for(d in r)m=r[d],h=n[d],!r.hasOwnProperty(d)||m===h||void 0===m&&void 0===h||pd(e,t,d,m,r,h);return}}for(var y in n)m=n[y],n.hasOwnProperty(y)&&null!=m&&!r.hasOwnProperty(y)&&hd(e,t,y,null,r,m);for(b in r)m=r[b],h=n[b],!r.hasOwnProperty(b)||m===h||null==m&&null==h||hd(e,t,b,m,r,h)}(r,e.type,n,t),r[He]=t}catch(a){Eu(e,e.return,a)}}function $s(e){return 5===e.tag||3===e.tag||26===e.tag||27===e.tag&&Td(e.type)||4===e.tag}function _s(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||$s(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(27===e.tag&&Td(e.type))continue e;if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function Ts(e,t,n){var l=e.tag;if(5===l||6===l)e=e.stateNode,t?(9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).insertBefore(e,t):((t=9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).appendChild(e),null!=(n=n._reactRootContainer)||null!==t.onclick||(t.onclick=It));else if(4!==l&&(27===l&&Td(e.type)&&(n=e.stateNode,t=null),null!==(e=e.child)))for(Ts(e,t,n),e=e.sibling;null!==e;)Ts(e,t,n),e=e.sibling}function zs(e,t,n){var l=e.tag;if(5===l||6===l)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==l&&(27===l&&Td(e.type)&&(n=e.stateNode),null!==(e=e.child)))for(zs(e,t,n),e=e.sibling;null!==e;)zs(e,t,n),e=e.sibling}function Ls(e){var t=e.stateNode,n=e.memoizedProps;try{for(var l=e.type,r=t.attributes;r.length;)t.removeAttributeNode(r[0]);fd(t,l,n),t[Ve]=e,t[He]=n}catch(a){Eu(e,e.return,a)}}var As=!1,Ms=!1,Ps=!1,Is="function"==typeof WeakSet?WeakSet:Set,Ds=null;function Os(e,t,n){var l=n.flags;switch(n.tag){case 0:case 11:case 15:Js(e,n),4&l&&xs(5,n);break;case 1:if(Js(e,n),4&l)if(e=n.stateNode,null===t)try{e.componentDidMount()}catch(o){Eu(n,n.return,o)}else{var r=Ei(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(r,t,e.__reactInternalSnapshotBeforeUpdate)}catch(i){Eu(n,n.return,i)}}64&l&&ks(n),512&l&&Ss(n,n.return);break;case 3:if(Js(e,n),64&l&&null!==(e=n.updateQueue)){if(t=null,null!==n.child)switch(n.child.tag){case 27:case 5:case 1:t=n.child.stateNode}try{Ta(e,t)}catch(o){Eu(n,n.return,o)}}break;case 27:null===t&&4&l&&Ls(n);case 26:case 5:Js(e,n),null===t&&4&l&&Ns(n),512&l&&Ss(n,n.return);break;case 12:Js(e,n);break;case 31:Js(e,n),4&l&&qs(e,n);break;case 13:Js(e,n),4&l&&Vs(e,n),64&l&&(null!==(e=n.memoizedState)&&(null!==(e=e.dehydrated)&&function(e,t){var n=e.ownerDocument;if("$~"===e.data)e._reactRetry=t;else if("$?"!==e.data||"loading"!==n.readyState)t();else{var l=function(){t(),n.removeEventListener("DOMContentLoaded",l)};n.addEventListener("DOMContentLoaded",l),e._reactRetry=l}}(e,n=zu.bind(null,n))));break;case 22:if(!(l=null!==n.memoizedState||As)){t=null!==t&&null!==t.memoizedState||Ms,r=As;var a=Ms;As=l,(Ms=t)&&!a?ec(e,n,!!(8772&n.subtreeFlags)):Js(e,n),As=r,Ms=a}break;case 30:break;default:Js(e,n)}}function Rs(e){var t=e.alternate;null!==t&&(e.alternate=null,Rs(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&(null!==(t=e.stateNode)&&Ze(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var Fs=null,Us=!1;function Bs(e,t,n){for(n=n.child;null!==n;)Ws(e,t,n),n=n.sibling}function Ws(e,t,n){if(ke&&"function"==typeof ke.onCommitFiberUnmount)try{ke.onCommitFiberUnmount(we,n)}catch(a){}switch(n.tag){case 26:Ms||js(n,t),Bs(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode).parentNode.removeChild(n);break;case 27:Ms||js(n,t);var l=Fs,r=Us;Td(n.type)&&(Fs=n.stateNode,Us=!1),Bs(e,t,n),Bd(n.stateNode),Fs=l,Us=r;break;case 5:Ms||js(n,t);case 6:if(l=Fs,r=Us,Fs=null,Bs(e,t,n),Us=r,null!==(Fs=l))if(Us)try{(9===Fs.nodeType?Fs.body:"HTML"===Fs.nodeName?Fs.ownerDocument.body:Fs).removeChild(n.stateNode)}catch(o){Eu(n,t,o)}else try{Fs.removeChild(n.stateNode)}catch(o){Eu(n,t,o)}break;case 18:null!==Fs&&(Us?(zd(9===(e=Fs).nodeType?e.body:"HTML"===e.nodeName?e.ownerDocument.body:e,n.stateNode),Gb(e)):zd(Fs,n.stateNode));break;case 4:l=Fs,r=Us,Fs=n.stateNode.containerInfo,Us=!0,Bs(e,t,n),Fs=l,Us=r;break;case 0:case 11:case 14:case 15:ws(2,n,t),Ms||ws(4,n,t),Bs(e,t,n);break;case 1:Ms||(js(n,t),"function"==typeof(l=n.stateNode).componentWillUnmount&&Cs(n,t,l)),Bs(e,t,n);break;case 21:Bs(e,t,n);break;case 22:Ms=(l=Ms)||null!==n.memoizedState,Bs(e,t,n),Ms=l;break;default:Bs(e,t,n)}}function qs(e,t){if(null===t.memoizedState&&(null!==(e=t.alternate)&&null!==(e=e.memoizedState))){e=e.dehydrated;try{Gb(e)}catch(n){Eu(t,t.return,n)}}}function Vs(e,t){if(null===t.memoizedState&&(null!==(e=t.alternate)&&(null!==(e=e.memoizedState)&&null!==(e=e.dehydrated))))try{Gb(e)}catch(n){Eu(t,t.return,n)}}function Hs(e,t){var n=function(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return null===t&&(t=e.stateNode=new Is),t;case 22:return null===(t=(e=e.stateNode)._retryCache)&&(t=e._retryCache=new Is),t;default:throw Error(l(435,e.tag))}}(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var l=Lu.bind(null,e,t);t.then(l,l)}})}function Ks(e,t){var n=t.deletions;if(null!==n)for(var r=0;r<n.length;r++){var a=n[r],o=e,i=t,s=i;e:for(;null!==s;){switch(s.tag){case 27:if(Td(s.type)){Fs=s.stateNode,Us=!1;break e}break;case 5:Fs=s.stateNode,Us=!1;break e;case 3:case 4:Fs=s.stateNode.containerInfo,Us=!0;break e}s=s.return}if(null===Fs)throw Error(l(160));Ws(o,i,a),Fs=null,Us=!1,null!==(o=a.alternate)&&(o.return=null),a.return=null}if(13886&t.subtreeFlags)for(t=t.child;null!==t;)Qs(t,e),t=t.sibling}var Gs=null;function Qs(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Ks(t,e),Xs(e),4&r&&(ws(3,e,e.return),xs(3,e),ws(5,e,e.return));break;case 1:Ks(t,e),Xs(e),512&r&&(Ms||null===n||js(n,n.return)),64&r&&As&&(null!==(e=e.updateQueue)&&(null!==(r=e.callbacks)&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=null===n?r:n.concat(r))));break;case 26:var a=Gs;if(Ks(t,e),Xs(e),512&r&&(Ms||null===n||js(n,n.return)),4&r){var o=null!==n?n.memoizedState:null;if(r=e.memoizedState,null===n)if(null===r)if(null===e.stateNode){e:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;t:switch(r){case"title":(!(o=a.getElementsByTagName("title")[0])||o[Je]||o[Ve]||"http://www.w3.org/2000/svg"===o.namespaceURI||o.hasAttribute("itemprop"))&&(o=a.createElement(r),a.head.insertBefore(o,a.querySelector("head > title"))),fd(o,r,n),o[Ve]=e,rt(o),r=o;break e;case"link":var i=ob("link","href",a).get(r+(n.href||""));if(i)for(var s=0;s<i.length;s++)if((o=i[s]).getAttribute("href")===(null==n.href||""===n.href?null:n.href)&&o.getAttribute("rel")===(null==n.rel?null:n.rel)&&o.getAttribute("title")===(null==n.title?null:n.title)&&o.getAttribute("crossorigin")===(null==n.crossOrigin?null:n.crossOrigin)){i.splice(s,1);break t}fd(o=a.createElement(r),r,n),a.head.appendChild(o);break;case"meta":if(i=ob("meta","content",a).get(r+(n.content||"")))for(s=0;s<i.length;s++)if((o=i[s]).getAttribute("content")===(null==n.content?null:""+n.content)&&o.getAttribute("name")===(null==n.name?null:n.name)&&o.getAttribute("property")===(null==n.property?null:n.property)&&o.getAttribute("http-equiv")===(null==n.httpEquiv?null:n.httpEquiv)&&o.getAttribute("charset")===(null==n.charSet?null:n.charSet)){i.splice(s,1);break t}fd(o=a.createElement(r),r,n),a.head.appendChild(o);break;default:throw Error(l(468,r))}o[Ve]=e,rt(o),r=o}e.stateNode=r}else ib(a,e.type,e.stateNode);else e.stateNode=tb(a,r,e.memoizedProps);else o!==r?(null===o?null!==n.stateNode&&(n=n.stateNode).parentNode.removeChild(n):o.count--,null===r?ib(a,e.type,e.stateNode):tb(a,r,e.memoizedProps)):null===r&&null!==e.stateNode&&Es(e,e.memoizedProps,n.memoizedProps)}break;case 27:Ks(t,e),Xs(e),512&r&&(Ms||null===n||js(n,n.return)),null!==n&&4&r&&Es(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Ks(t,e),Xs(e),512&r&&(Ms||null===n||js(n,n.return)),32&e.flags){a=e.stateNode;try{$t(a,"")}catch(p){Eu(e,e.return,p)}}4&r&&null!=e.stateNode&&Es(e,a=e.memoizedProps,null!==n?n.memoizedProps:a),1024&r&&(Ps=!0);break;case 6:if(Ks(t,e),Xs(e),4&r){if(null===e.stateNode)throw Error(l(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(p){Eu(e,e.return,p)}}break;case 3:if(ab=null,a=Gs,Gs=Vd(t.containerInfo),Ks(t,e),Gs=a,Xs(e),4&r&&null!==n&&n.memoizedState.isDehydrated)try{Gb(t.containerInfo)}catch(p){Eu(e,e.return,p)}Ps&&(Ps=!1,Ys(e));break;case 4:r=Gs,Gs=Vd(e.stateNode.containerInfo),Ks(t,e),Xs(e),Gs=r;break;case 12:default:Ks(t,e),Xs(e);break;case 31:case 19:Ks(t,e),Xs(e),4&r&&(null!==(r=e.updateQueue)&&(e.updateQueue=null,Hs(e,r)));break;case 13:Ks(t,e),Xs(e),8192&e.child.flags&&null!==e.memoizedState!=(null!==n&&null!==n.memoizedState)&&(Ic=be()),4&r&&(null!==(r=e.updateQueue)&&(e.updateQueue=null,Hs(e,r)));break;case 22:a=null!==e.memoizedState;var c=null!==n&&null!==n.memoizedState,u=As,d=Ms;if(As=u||a,Ms=d||c,Ks(t,e),Ms=d,As=u,Xs(e),8192&r)e:for(t=e.stateNode,t._visibility=a?-2&t._visibility:1|t._visibility,a&&(null===n||c||As||Ms||Zs(e)),n=null,t=e;;){if(5===t.tag||26===t.tag){if(null===n){c=n=t;try{if(o=c.stateNode,a)"function"==typeof(i=o.style).setProperty?i.setProperty("display","none","important"):i.display="none";else{s=c.stateNode;var b=c.memoizedProps.style,m=null!=b&&b.hasOwnProperty("display")?b.display:null;s.style.display=null==m||"boolean"==typeof m?"":(""+m).trim()}}catch(p){Eu(c,c.return,p)}}}else if(6===t.tag){if(null===n){c=t;try{c.stateNode.nodeValue=a?"":c.memoizedProps}catch(p){Eu(c,c.return,p)}}}else if(18===t.tag){if(null===n){c=t;try{var h=c.stateNode;a?Ld(h,!0):Ld(c.stateNode,!1)}catch(p){Eu(c,c.return,p)}}}else if((22!==t.tag&&23!==t.tag||null===t.memoizedState||t===e)&&null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;null===t.sibling;){if(null===t.return||t.return===e)break e;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}4&r&&(null!==(r=e.updateQueue)&&(null!==(n=r.retryQueue)&&(r.retryQueue=null,Hs(e,n))));case 30:case 21:}}function Xs(e){var t=e.flags;if(2&t){try{for(var n,r=e.return;null!==r;){if($s(r)){n=r;break}r=r.return}if(null==n)throw Error(l(160));switch(n.tag){case 27:var a=n.stateNode;zs(e,_s(e),a);break;case 5:var o=n.stateNode;32&n.flags&&($t(o,""),n.flags&=-33),zs(e,_s(e),o);break;case 3:case 4:var i=n.stateNode.containerInfo;Ts(e,_s(e),i);break;default:throw Error(l(161))}}catch(s){Eu(e,e.return,s)}e.flags&=-3}4096&t&&(e.flags&=-4097)}function Ys(e){if(1024&e.subtreeFlags)for(e=e.child;null!==e;){var t=e;Ys(t),5===t.tag&&1024&t.flags&&t.stateNode.reset(),e=e.sibling}}function Js(e,t){if(8772&t.subtreeFlags)for(t=t.child;null!==t;)Os(e,t.alternate,t),t=t.sibling}function Zs(e){for(e=e.child;null!==e;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:ws(4,t,t.return),Zs(t);break;case 1:js(t,t.return);var n=t.stateNode;"function"==typeof n.componentWillUnmount&&Cs(t,t.return,n),Zs(t);break;case 27:Bd(t.stateNode);case 26:case 5:js(t,t.return),Zs(t);break;case 22:null===t.memoizedState&&Zs(t);break;default:Zs(t)}e=e.sibling}}function ec(e,t,n){for(n=n&&!!(8772&t.subtreeFlags),t=t.child;null!==t;){var l=t.alternate,r=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:ec(r,a,n),xs(4,a);break;case 1:if(ec(r,a,n),"function"==typeof(r=(l=a).stateNode).componentDidMount)try{r.componentDidMount()}catch(c){Eu(l,l.return,c)}if(null!==(r=(l=a).updateQueue)){var i=l.stateNode;try{var s=r.shared.hiddenCallbacks;if(null!==s)for(r.shared.hiddenCallbacks=null,r=0;r<s.length;r++)_a(s[r],i)}catch(c){Eu(l,l.return,c)}}n&&64&o&&ks(a),Ss(a,a.return);break;case 27:Ls(a);case 26:case 5:ec(r,a,n),n&&null===l&&4&o&&Ns(a),Ss(a,a.return);break;case 12:ec(r,a,n);break;case 31:ec(r,a,n),n&&4&o&&qs(r,a);break;case 13:ec(r,a,n),n&&4&o&&Vs(r,a);break;case 22:null===a.memoizedState&&ec(r,a,n),Ss(a,a.return);break;case 30:break;default:ec(r,a,n)}t=t.sibling}}function tc(e,t){var n=null;null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),e=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(e=t.memoizedState.cachePool.pool),e!==n&&(null!=e&&e.refCount++,null!=n&&qr(n))}function nc(e,t){e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&qr(e))}function lc(e,t,n,l){if(10256&t.subtreeFlags)for(t=t.child;null!==t;)rc(e,t,n,l),t=t.sibling}function rc(e,t,n,l){var r=t.flags;switch(t.tag){case 0:case 11:case 15:lc(e,t,n,l),2048&r&&xs(9,t);break;case 1:case 31:case 13:default:lc(e,t,n,l);break;case 3:lc(e,t,n,l),2048&r&&(e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&qr(e)));break;case 12:if(2048&r){lc(e,t,n,l),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,i=a.onPostCommit;"function"==typeof i&&i(o,null===t.alternate?"mount":"update",e.passiveEffectDuration,-0)}catch(s){Eu(t,t.return,s)}}else lc(e,t,n,l);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,null!==t.memoizedState?2&a._visibility?lc(e,t,n,l):oc(e,t):2&a._visibility?lc(e,t,n,l):(a._visibility|=2,ac(e,t,n,l,!!(10256&t.subtreeFlags)||!1)),2048&r&&tc(o,t);break;case 24:lc(e,t,n,l),2048&r&&nc(t.alternate,t)}}function ac(e,t,n,l,r){for(r=r&&(!!(10256&t.subtreeFlags)||!1),t=t.child;null!==t;){var a=e,o=t,i=n,s=l,c=o.flags;switch(o.tag){case 0:case 11:case 15:ac(a,o,i,s,r),xs(8,o);break;case 23:break;case 22:var u=o.stateNode;null!==o.memoizedState?2&u._visibility?ac(a,o,i,s,r):oc(a,o):(u._visibility|=2,ac(a,o,i,s,r)),r&&2048&c&&tc(o.alternate,o);break;case 24:ac(a,o,i,s,r),r&&2048&c&&nc(o.alternate,o);break;default:ac(a,o,i,s,r)}t=t.sibling}}function oc(e,t){if(10256&t.subtreeFlags)for(t=t.child;null!==t;){var n=e,l=t,r=l.flags;switch(l.tag){case 22:oc(n,l),2048&r&&tc(l.alternate,l);break;case 24:oc(n,l),2048&r&&nc(l.alternate,l);break;default:oc(n,l)}t=t.sibling}}var ic=8192;function sc(e,t,n){if(e.subtreeFlags&ic)for(e=e.child;null!==e;)cc(e,t,n),e=e.sibling}function cc(e,t,n){switch(e.tag){case 26:sc(e,t,n),e.flags&ic&&null!==e.memoizedState&&function(e,t,n,l){if(!("stylesheet"!==n.type||"string"==typeof l.media&&!1===matchMedia(l.media).matches||4&n.state.loading)){if(null===n.instance){var r=Xd(l.href),a=t.querySelector(Yd(r));if(a)return null!==(t=a._p)&&"object"==typeof t&&"function"==typeof t.then&&(e.count++,e=ub.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,void rt(a);a=t.ownerDocument||t,l=Jd(l),(r=Wd.get(r))&&lb(l,r),rt(a=a.createElement("link"));var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),fd(a,"link",l),n.instance=a}null===e.stylesheets&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(3&n.state.loading)&&(e.count++,n=ub.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}(n,Gs,e.memoizedState,e.memoizedProps);break;case 5:default:sc(e,t,n);break;case 3:case 4:var l=Gs;Gs=Vd(e.stateNode.containerInfo),sc(e,t,n),Gs=l;break;case 22:null===e.memoizedState&&(null!==(l=e.alternate)&&null!==l.memoizedState?(l=ic,ic=16777216,sc(e,t,n),ic=l):sc(e,t,n))}}function uc(e){var t=e.alternate;if(null!==t&&null!==(e=t.child)){t.child=null;do{t=e.sibling,e.sibling=null,e=t}while(null!==e)}}function dc(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var n=0;n<t.length;n++){var l=t[n];Ds=l,hc(l,e)}uc(e)}if(10256&e.subtreeFlags)for(e=e.child;null!==e;)bc(e),e=e.sibling}function bc(e){switch(e.tag){case 0:case 11:case 15:dc(e),2048&e.flags&&ws(9,e,e.return);break;case 3:case 12:default:dc(e);break;case 22:var t=e.stateNode;null!==e.memoizedState&&2&t._visibility&&(null===e.return||13!==e.return.tag)?(t._visibility&=-3,mc(e)):dc(e)}}function mc(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var n=0;n<t.length;n++){var l=t[n];Ds=l,hc(l,e)}uc(e)}for(e=e.child;null!==e;){switch((t=e).tag){case 0:case 11:case 15:ws(8,t,t.return),mc(t);break;case 22:2&(n=t.stateNode)._visibility&&(n._visibility&=-3,mc(t));break;default:mc(t)}e=e.sibling}}function hc(e,t){for(;null!==Ds;){var n=Ds;switch(n.tag){case 0:case 11:case 15:ws(8,n,t);break;case 23:case 22:if(null!==n.memoizedState&&null!==n.memoizedState.cachePool){var l=n.memoizedState.cachePool.pool;null!=l&&l.refCount++}break;case 24:qr(n.memoizedState.cache)}if(null!==(l=n.child))l.return=n,Ds=l;else e:for(n=e;null!==Ds;){var r=(l=Ds).sibling,a=l.return;if(Rs(l),l===n){Ds=null;break e}if(null!==r){r.return=a,Ds=r;break e}Ds=a}}}var pc={getCacheForType:function(e){var t=Ir(Br),n=t.data.get(e);return void 0===n&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Ir(Br).controller.signal}},fc="function"==typeof WeakMap?WeakMap:Map,gc=0,yc=null,vc=null,xc=0,wc=0,kc=null,Cc=!1,Sc=!1,jc=!1,Nc=0,Ec=0,$c=0,_c=0,Tc=0,zc=0,Lc=0,Ac=null,Mc=null,Pc=!1,Ic=0,Dc=0,Oc=1/0,Rc=null,Fc=null,Uc=0,Bc=null,Wc=null,qc=0,Vc=0,Hc=null,Kc=null,Gc=0,Qc=null;function Xc(){return 2&gc&&0!==xc?xc&-xc:null!==O.T?Hu():Be()}function Yc(){if(0===zc)if(536870912&xc&&!pr)zc=536870912;else{var e=$e;!(3932160&($e<<=1))&&($e=262144),zc=e}return null!==(e=Ia.current)&&(e.flags|=32),zc}function Jc(e,t,n){(e!==yc||2!==wc&&9!==wc)&&null===e.cancelPendingCommit||(au(e,0),nu(e,xc,zc,!1)),Ie(e,n),2&gc&&e===yc||(e===yc&&(!(2&gc)&&(_c|=n),4===Ec&&nu(e,xc,zc,!1)),Ru(e))}function Zc(e,t,n){if(6&gc)throw Error(l(327));for(var r=!n&&!(127&t)&&0===(t&e.expiredLanes)||Le(e,t),a=r?function(e,t){var n=gc;gc|=2;var r=su(),a=cu();yc!==e||xc!==t?(Rc=null,Oc=be()+500,au(e,t)):Sc=Le(e,t);e:for(;;)try{if(0!==wc&&null!==vc){t=vc;var o=kc;t:switch(wc){case 1:wc=0,kc=null,fu(e,t,o,1);break;case 2:case 9:if(aa(o)){wc=0,kc=null,pu(t);break}t=function(){2!==wc&&9!==wc||yc!==e||(wc=7),Ru(e)},o.then(t,t);break e;case 3:wc=7;break e;case 4:wc=5;break e;case 7:aa(o)?(wc=0,kc=null,pu(t)):(wc=0,kc=null,fu(e,t,o,7));break;case 5:var i=null;switch(vc.tag){case 26:i=vc.memoizedState;case 5:case 27:var s=vc;if(i?sb(i):s.stateNode.complete){wc=0,kc=null;var c=s.sibling;if(null!==c)vc=c;else{var u=s.return;null!==u?(vc=u,gu(u)):vc=null}break t}}wc=0,kc=null,fu(e,t,o,5);break;case 6:wc=0,kc=null,fu(e,t,o,6);break;case 8:ru(),Ec=6;break e;default:throw Error(l(462))}}mu();break}catch(d){ou(e,d)}return $r=Er=null,O.H=r,O.A=a,gc=n,null!==vc?0:(yc=null,xc=0,Ml(),Ec)}(e,t):du(e,t,!0),o=r;;){if(0===a){Sc&&!r&&nu(e,t,0,!1);break}if(n=e.current.alternate,!o||tu(n)){if(2===a){if(o=t,e.errorRecoveryDisabledLanes&o)var i=0;else i=0!==(i=-536870913&e.pendingLanes)?i:536870912&i?536870912:0;if(0!==i){t=i;e:{var s=e;a=Ac;var c=s.current.memoizedState.isDehydrated;if(c&&(au(s,i).flags|=256),2!==(i=du(s,i,!1))){if(jc&&!c){s.errorRecoveryDisabledLanes|=o,_c|=o,a=4;break e}o=Mc,Mc=a,null!==o&&(null===Mc?Mc=o:Mc.push.apply(Mc,o))}a=i}if(o=!1,2!==a)continue}}if(1===a){au(e,0),nu(e,t,0,!0);break}e:{switch(r=e,o=a){case 0:case 1:throw Error(l(345));case 4:if((4194048&t)!==t)break;case 6:nu(r,t,zc,!Cc);break e;case 2:Mc=null;break;case 3:case 5:break;default:throw Error(l(329))}if((62914560&t)===t&&10<(a=Ic+300-be())){if(nu(r,t,zc,!Cc),0!==ze(r,0,!0))break e;qc=t,r.timeoutHandle=jd(eu.bind(null,r,n,Mc,Rc,Pc,t,zc,_c,Lc,Cc,o,"Throttled",-0,0),a)}else eu(r,n,Mc,Rc,Pc,t,zc,_c,Lc,Cc,o,null,-0,0)}break}a=du(e,t,!1),o=!1}Ru(e)}function eu(e,t,n,l,r,a,o,i,s,c,u,d,b,m){if(e.timeoutHandle=-1,8192&(d=t.subtreeFlags)||!(16785408&~d)){cc(t,a,d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:It});var h=(62914560&a)===a?Ic-be():(4194048&a)===a?Dc-be():0;if(null!==(h=function(e,t){return e.stylesheets&&0===e.count&&bb(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var l=setTimeout(function(){if(e.stylesheets&&bb(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&0===cb&&(cb=62500*function(){if("function"==typeof performance.getEntriesByType){for(var e=0,t=0,n=performance.getEntriesByType("resource"),l=0;l<n.length;l++){var r=n[l],a=r.transferSize,o=r.initiatorType,i=r.duration;if(a&&i&&gd(o)){for(o=0,i=r.responseEnd,l+=1;l<n.length;l++){var s=n[l],c=s.startTime;if(c>i)break;var u=s.transferSize,d=s.initiatorType;u&&gd(d)&&(o+=u*((s=s.responseEnd)<i?1:(i-c)/(s-c)))}if(--l,t+=8*(a+o)/(r.duration/1e3),10<++e)break}}if(0<e)return t/e/1e6}return navigator.connection&&"number"==typeof(e=navigator.connection.downlink)?e:5}());var r=setTimeout(function(){if(e.waitingForImages=!1,0===e.count&&(e.stylesheets&&bb(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>cb?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(l),clearTimeout(r)}}:null}(d,h)))return qc=a,e.cancelPendingCommit=h(vu.bind(null,e,t,a,n,l,r,o,i,s,u,d,null,b,m)),void nu(e,a,o,!c)}vu(e,t,a,n,l,r,o,i,s)}function tu(e){for(var t=e;;){var n=t.tag;if((0===n||11===n||15===n)&&16384&t.flags&&(null!==(n=t.updateQueue)&&null!==(n=n.stores)))for(var l=0;l<n.length;l++){var r=n[l],a=r.getSnapshot;r=r.value;try{if(!nl(a(),r))return!1}catch(o){return!1}}if(n=t.child,16384&t.subtreeFlags&&null!==n)n.return=t,t=n;else{if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function nu(e,t,n,l){t&=~Tc,t&=~_c,e.suspendedLanes|=t,e.pingedLanes&=~t,l&&(e.warmLanes|=t),l=e.expirationTimes;for(var r=t;0<r;){var a=31-Se(r),o=1<<a;l[a]=-1,r&=~o}0!==n&&De(e,n,t)}function lu(){return!!(6&gc)||(Fu(0),!1)}function ru(){if(null!==vc){if(0===wc)var e=vc.return;else $r=Er=null,uo(e=vc),da=null,ba=0,e=vc;for(;null!==e;)vs(e.alternate,e),e=e.return;vc=null}}function au(e,t){var n=e.timeoutHandle;-1!==n&&(e.timeoutHandle=-1,Nd(n)),null!==(n=e.cancelPendingCommit)&&(e.cancelPendingCommit=null,n()),qc=0,ru(),yc=e,vc=n=ql(e.current,null),xc=t,wc=0,kc=null,Cc=!1,Sc=Le(e,t),jc=!1,Lc=zc=Tc=_c=$c=Ec=0,Mc=Ac=null,Pc=!1,8&t&&(t|=32&t);var l=e.entangledLanes;if(0!==l)for(e=e.entanglements,l&=t;0<l;){var r=31-Se(l),a=1<<r;t|=e[r],l&=~a}return Nc=t,Ml(),n}function ou(e,t){Ha=null,O.H=vi,t===ta||t===la?(t=ca(),wc=3):t===na?(t=ca(),wc=4):wc=t===Ii?8:null!==t&&"object"==typeof t&&"function"==typeof t.then?6:1,kc=t,null===vc&&(Ec=1,zi(e,Jl(t,e.current)))}function iu(){var e=Ia.current;return null===e||((4194048&xc)===xc?null===Da:!!((62914560&xc)===xc||536870912&xc)&&e===Da)}function su(){var e=O.H;return O.H=vi,null===e?vi:e}function cu(){var e=O.A;return O.A=pc,e}function uu(){Ec=4,Cc||(4194048&xc)!==xc&&null!==Ia.current||(Sc=!0),!(134217727&$c)&&!(134217727&_c)||null===yc||nu(yc,xc,zc,!1)}function du(e,t,n){var l=gc;gc|=2;var r=su(),a=cu();yc===e&&xc===t||(Rc=null,au(e,t)),t=!1;var o=Ec;e:for(;;)try{if(0!==wc&&null!==vc){var i=vc,s=kc;switch(wc){case 8:ru(),o=6;break e;case 3:case 2:case 9:case 6:null===Ia.current&&(t=!0);var c=wc;if(wc=0,kc=null,fu(e,i,s,c),n&&Sc){o=0;break e}break;default:c=wc,wc=0,kc=null,fu(e,i,s,c)}}bu(),o=Ec;break}catch(u){ou(e,u)}return t&&e.shellSuspendCounter++,$r=Er=null,gc=l,O.H=r,O.A=a,null===vc&&(yc=null,xc=0,Ml()),o}function bu(){for(;null!==vc;)hu(vc)}function mu(){for(;null!==vc&&!ue();)hu(vc)}function hu(e){var t=us(e.alternate,e,Nc);e.memoizedProps=e.pendingProps,null===t?gu(e):vc=t}function pu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Qi(n,t,t.pendingProps,t.type,void 0,xc);break;case 11:t=Qi(n,t,t.pendingProps,t.type.render,t.ref,xc);break;case 5:uo(t);default:vs(n,t),t=us(n,t=vc=Vl(t,Nc),Nc)}e.memoizedProps=e.pendingProps,null===t?gu(e):vc=t}function fu(e,t,n,r){$r=Er=null,uo(t),da=null,ba=0;var a=t.return;try{if(function(e,t,n,r,a){if(n.flags|=32768,null!==r&&"object"==typeof r&&"function"==typeof r.then){if(null!==(t=n.alternate)&&Ar(t,n,a,!0),null!==(n=Ia.current)){switch(n.tag){case 31:case 13:return null===Da?uu():null===n.alternate&&0===Ec&&(Ec=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===ra?n.flags|=16384:(null===(t=n.updateQueue)?n.updateQueue=new Set([r]):t.add(r),$u(e,r,a)),!1;case 22:return n.flags|=65536,r===ra?n.flags|=16384:(null===(t=n.updateQueue)?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):null===(n=t.retryQueue)?t.retryQueue=new Set([r]):n.add(r),$u(e,r,a)),!1}throw Error(l(435,n.tag))}return $u(e,r,a),uu(),!1}if(pr)return null!==(t=Ia.current)?(!(65536&t.flags)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==yr&&jr(Jl(e=Error(l(422),{cause:r}),n))):(r!==yr&&jr(Jl(t=Error(l(423),{cause:r}),n)),(e=e.current.alternate).flags|=65536,a&=-a,e.lanes|=a,r=Jl(r,n),ja(e,a=Ai(e.stateNode,r,a)),4!==Ec&&(Ec=2)),!1;var o=Error(l(520),{cause:r});if(o=Jl(o,n),null===Ac?Ac=[o]:Ac.push(o),4!==Ec&&(Ec=2),null===t)return!0;r=Jl(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,ja(n,e=Ai(n.stateNode,r,e)),!1;case 1:if(t=n.type,o=n.stateNode,!(128&n.flags||"function"!=typeof t.getDerivedStateFromError&&(null===o||"function"!=typeof o.componentDidCatch||null!==Fc&&Fc.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,Pi(a=Mi(a),e,n,r),ja(n,a),!1}n=n.return}while(null!==n);return!1}(e,a,t,n,xc))return Ec=1,zi(e,Jl(n,e.current)),void(vc=null)}catch(o){if(null!==a)throw vc=a,o;return Ec=1,zi(e,Jl(n,e.current)),void(vc=null)}32768&t.flags?(pr||1===r?e=!0:Sc||536870912&xc?e=!1:(Cc=e=!0,(2===r||9===r||3===r||6===r)&&(null!==(r=Ia.current)&&13===r.tag&&(r.flags|=16384))),yu(t,e)):gu(t)}function gu(e){var t=e;do{if(32768&t.flags)return void yu(t,Cc);e=t.return;var n=gs(t.alternate,t,Nc);if(null!==n)return void(vc=n);if(null!==(t=t.sibling))return void(vc=t);vc=t=e}while(null!==t);0===Ec&&(Ec=5)}function yu(e,t){do{var n=ys(e.alternate,e);if(null!==n)return n.flags&=32767,void(vc=n);if(null!==(n=e.return)&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&null!==(e=e.sibling))return void(vc=e);vc=e=n}while(null!==e);Ec=6,vc=null}function vu(e,t,n,r,a,o,i,s,c){e.cancelPendingCommit=null;do{Su()}while(0!==Uc);if(6&gc)throw Error(l(327));if(null!==t){if(t===e.current)throw Error(l(177));if(o=t.lanes|t.childLanes,function(e,t,n,l,r,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var i=e.entanglements,s=e.expirationTimes,c=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-Se(n),d=1<<u;i[u]=0,s[u]=-1;var b=c[u];if(null!==b)for(c[u]=null,u=0;u<b.length;u++){var m=b[u];null!==m&&(m.lane&=-536870913)}n&=~d}0!==l&&De(e,l,0),0!==a&&0===r&&0!==e.tag&&(e.suspendedLanes|=a&~(o&~t))}(e,n,o|=Al,i,s,c),e===yc&&(vc=yc=null,xc=0),Wc=t,Bc=e,qc=n,Vc=o,Hc=a,Kc=r,10256&t.subtreeFlags||10256&t.flags?(e.callbackNode=null,e.callbackPriority=0,se(fe,function(){return ju(),null})):(e.callbackNode=null,e.callbackPriority=0),r=!!(13878&t.flags),13878&t.subtreeFlags||r){r=O.T,O.T=null,a=R.p,R.p=2,i=gc,gc|=4;try{!function(e,t){if(e=e.containerInfo,yd=Cb,sl(e=il(e))){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{var r=(n=(n=e.ownerDocument)&&n.defaultView||window).getSelection&&n.getSelection();if(r&&0!==r.rangeCount){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch(f){n=null;break e}var i=0,s=-1,c=-1,u=0,d=0,b=e,m=null;t:for(;;){for(var h;b!==n||0!==a&&3!==b.nodeType||(s=i+a),b!==o||0!==r&&3!==b.nodeType||(c=i+r),3===b.nodeType&&(i+=b.nodeValue.length),null!==(h=b.firstChild);)m=b,b=h;for(;;){if(b===e)break t;if(m===n&&++u===a&&(s=i),m===o&&++d===r&&(c=i),null!==(h=b.nextSibling))break;m=(b=m).parentNode}b=h}n=-1===s||-1===c?null:{start:s,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(vd={focusedElem:e,selectionRange:n},Cb=!1,Ds=t;null!==Ds;)if(e=(t=Ds).child,1028&t.subtreeFlags&&null!==e)e.return=t,Ds=e;else for(;null!==Ds;){switch(o=(t=Ds).alternate,e=t.flags,t.tag){case 0:if(4&e&&null!==(e=null!==(e=t.updateQueue)?e.events:null))for(n=0;n<e.length;n++)(a=e[n]).ref.impl=a.nextImpl;break;case 11:case 15:case 5:case 26:case 27:case 6:case 4:case 17:break;case 1:if(1024&e&&null!==o){e=void 0,n=t,a=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var p=Ei(n.type,a);e=r.getSnapshotBeforeUpdate(p,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(g){Eu(n,n.return,g)}}break;case 3:if(1024&e)if(9===(n=(e=t.stateNode.containerInfo).nodeType))Ad(e);else if(1===n)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Ad(e);break;default:e.textContent=""}break;default:if(1024&e)throw Error(l(163))}if(null!==(e=t.sibling)){e.return=t.return,Ds=e;break}Ds=t.return}}(e,t)}finally{gc=i,R.p=a,O.T=r}}Uc=1,xu(),wu(),ku()}}function xu(){if(1===Uc){Uc=0;var e=Bc,t=Wc,n=!!(13878&t.flags);if(13878&t.subtreeFlags||n){n=O.T,O.T=null;var l=R.p;R.p=2;var r=gc;gc|=4;try{Qs(t,e);var a=vd,o=il(e.containerInfo),i=a.focusedElem,s=a.selectionRange;if(o!==i&&i&&i.ownerDocument&&ol(i.ownerDocument.documentElement,i)){if(null!==s&&sl(i)){var c=s.start,u=s.end;if(void 0===u&&(u=c),"selectionStart"in i)i.selectionStart=c,i.selectionEnd=Math.min(u,i.value.length);else{var d=i.ownerDocument||document,b=d&&d.defaultView||window;if(b.getSelection){var m=b.getSelection(),h=i.textContent.length,p=Math.min(s.start,h),f=void 0===s.end?p:Math.min(s.end,h);!m.extend&&p>f&&(o=f,f=p,p=o);var g=al(i,p),y=al(i,f);if(g&&y&&(1!==m.rangeCount||m.anchorNode!==g.node||m.anchorOffset!==g.offset||m.focusNode!==y.node||m.focusOffset!==y.offset)){var v=d.createRange();v.setStart(g.node,g.offset),m.removeAllRanges(),p>f?(m.addRange(v),m.extend(y.node,y.offset)):(v.setEnd(y.node,y.offset),m.addRange(v))}}}}for(d=[],m=i;m=m.parentNode;)1===m.nodeType&&d.push({element:m,left:m.scrollLeft,top:m.scrollTop});for("function"==typeof i.focus&&i.focus(),i=0;i<d.length;i++){var x=d[i];x.element.scrollLeft=x.left,x.element.scrollTop=x.top}}Cb=!!yd,vd=yd=null}finally{gc=r,R.p=l,O.T=n}}e.current=t,Uc=2}}function wu(){if(2===Uc){Uc=0;var e=Bc,t=Wc,n=!!(8772&t.flags);if(8772&t.subtreeFlags||n){n=O.T,O.T=null;var l=R.p;R.p=2;var r=gc;gc|=4;try{Os(e,t.alternate,t)}finally{gc=r,R.p=l,O.T=n}}Uc=3}}function ku(){if(4===Uc||3===Uc){Uc=0,de();var e=Bc,t=Wc,n=qc,l=Kc;10256&t.subtreeFlags||10256&t.flags?Uc=5:(Uc=0,Wc=Bc=null,Cu(e,e.pendingLanes));var r=e.pendingLanes;if(0===r&&(Fc=null),Ue(n),t=t.stateNode,ke&&"function"==typeof ke.onCommitFiberRoot)try{ke.onCommitFiberRoot(we,t,void 0,!(128&~t.current.flags))}catch(s){}if(null!==l){t=O.T,r=R.p,R.p=2,O.T=null;try{for(var a=e.onRecoverableError,o=0;o<l.length;o++){var i=l[o];a(i.value,{componentStack:i.stack})}}finally{O.T=t,R.p=r}}3&qc&&Su(),Ru(e),r=e.pendingLanes,261930&n&&42&r?e===Qc?Gc++:(Gc=0,Qc=e):Gc=0,Fu(0)}}function Cu(e,t){0===(e.pooledCacheLanes&=t)&&(null!=(t=e.pooledCache)&&(e.pooledCache=null,qr(t)))}function Su(){return xu(),wu(),ku(),ju()}function ju(){if(5!==Uc)return!1;var e=Bc,t=Vc;Vc=0;var n=Ue(qc),r=O.T,a=R.p;try{R.p=32>n?32:n,O.T=null,n=Hc,Hc=null;var o=Bc,i=qc;if(Uc=0,Wc=Bc=null,qc=0,6&gc)throw Error(l(331));var s=gc;if(gc|=4,bc(o.current),rc(o,o.current,i,n),gc=s,Fu(0,!1),ke&&"function"==typeof ke.onPostCommitFiberRoot)try{ke.onPostCommitFiberRoot(we,o)}catch(c){}return!0}finally{R.p=a,O.T=r,Cu(e,t)}}function Nu(e,t,n){t=Jl(n,t),null!==(e=Ca(e,t=Ai(e.stateNode,t,2),2))&&(Ie(e,2),Ru(e))}function Eu(e,t,n){if(3===e.tag)Nu(e,e,n);else for(;null!==t;){if(3===t.tag){Nu(t,e,n);break}if(1===t.tag){var l=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof l.componentDidCatch&&(null===Fc||!Fc.has(l))){e=Jl(n,e),null!==(l=Ca(t,n=Mi(2),2))&&(Pi(n,l,t,e),Ie(l,2),Ru(l));break}}t=t.return}}function $u(e,t,n){var l=e.pingCache;if(null===l){l=e.pingCache=new fc;var r=new Set;l.set(t,r)}else void 0===(r=l.get(t))&&(r=new Set,l.set(t,r));r.has(n)||(jc=!0,r.add(n),e=_u.bind(null,e,t,n),t.then(e,e))}function _u(e,t,n){var l=e.pingCache;null!==l&&l.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,yc===e&&(xc&n)===n&&(4===Ec||3===Ec&&(62914560&xc)===xc&&300>be()-Ic?!(2&gc)&&au(e,0):Tc|=n,Lc===xc&&(Lc=0)),Ru(e)}function Tu(e,t){0===t&&(t=Me()),null!==(e=Dl(e,t))&&(Ie(e,t),Ru(e))}function zu(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),Tu(e,n)}function Lu(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;null!==a&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(l(314))}null!==r&&r.delete(t),Tu(e,n)}var Au=null,Mu=null,Pu=!1,Iu=!1,Du=!1,Ou=0;function Ru(e){e!==Mu&&null===e.next&&(null===Mu?Au=Mu=e:Mu=Mu.next=e),Iu=!0,Pu||(Pu=!0,$d(function(){6&gc?se(he,Uu):Bu()}))}function Fu(e,t){if(!Du&&Iu){Du=!0;do{for(var n=!1,l=Au;null!==l;){if(0!==e){var r=l.pendingLanes;if(0===r)var a=0;else{var o=l.suspendedLanes,i=l.pingedLanes;a=(1<<31-Se(42|e)+1)-1,a=201326741&(a&=r&~(o&~i))?201326741&a|1:a?2|a:0}0!==a&&(n=!0,Vu(l,a))}else a=xc,!(3&(a=ze(l,l===yc?a:0,null!==l.cancelPendingCommit||-1!==l.timeoutHandle)))||Le(l,a)||(n=!0,Vu(l,a));l=l.next}}while(n);Du=!1}}function Uu(){Bu()}function Bu(){Iu=Pu=!1;var e=0;0!==Ou&&function(){var e=window.event;if(e&&"popstate"===e.type)return e!==Sd&&(Sd=e,!0);return Sd=null,!1}()&&(e=Ou);for(var t=be(),n=null,l=Au;null!==l;){var r=l.next,a=Wu(l,t);0===a?(l.next=null,null===n?Au=r:n.next=r,null===r&&(Mu=n)):(n=l,(0!==e||3&a)&&(Iu=!0)),l=r}0!==Uc&&5!==Uc||Fu(e),0!==Ou&&(Ou=0)}function Wu(e,t){for(var n=e.suspendedLanes,l=e.pingedLanes,r=e.expirationTimes,a=-62914561&e.pendingLanes;0<a;){var o=31-Se(a),i=1<<o,s=r[o];-1===s?0!==(i&n)&&0===(i&l)||(r[o]=Ae(i,t)):s<=t&&(e.expiredLanes|=i),a&=~i}if(n=xc,n=ze(e,e===(t=yc)?n:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle),l=e.callbackNode,0===n||e===t&&(2===wc||9===wc)||null!==e.cancelPendingCommit)return null!==l&&null!==l&&ce(l),e.callbackNode=null,e.callbackPriority=0;if(!(3&n)||Le(e,n)){if((t=n&-n)===e.callbackPriority)return t;switch(null!==l&&ce(l),Ue(n)){case 2:case 8:n=pe;break;case 32:default:n=fe;break;case 268435456:n=ye}return l=qu.bind(null,e),n=se(n,l),e.callbackPriority=t,e.callbackNode=n,t}return null!==l&&null!==l&&ce(l),e.callbackPriority=2,e.callbackNode=null,2}function qu(e,t){if(0!==Uc&&5!==Uc)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Su()&&e.callbackNode!==n)return null;var l=xc;return 0===(l=ze(e,e===yc?l:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle))?null:(Zc(e,l,t),Wu(e,be()),null!=e.callbackNode&&e.callbackNode===n?qu.bind(null,e):null)}function Vu(e,t){if(Su())return null;Zc(e,t,!0)}function Hu(){if(0===Ou){var e=Kr;0===e&&(e=Ee,!(261888&(Ee<<=1))&&(Ee=256)),Ou=e}return Ou}function Ku(e){return null==e||"symbol"==typeof e||"boolean"==typeof e?null:"function"==typeof e?e:Pt(""+e)}function Gu(e,t){var n=t.ownerDocument.createElement("input");return n.name=t.name,n.value=t.value,e.id&&n.setAttribute("form",e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}for(var Qu=0;Qu<$l.length;Qu++){var Xu=$l[Qu];_l(Xu.toLowerCase(),"on"+(Xu[0].toUpperCase()+Xu.slice(1)))}_l(xl,"onAnimationEnd"),_l(wl,"onAnimationIteration"),_l(kl,"onAnimationStart"),_l("dblclick","onDoubleClick"),_l("focusin","onFocus"),_l("focusout","onBlur"),_l(Cl,"onTransitionRun"),_l(Sl,"onTransitionStart"),_l(jl,"onTransitionCancel"),_l(Nl,"onTransitionEnd"),st("onMouseEnter",["mouseout","mouseover"]),st("onMouseLeave",["mouseout","mouseover"]),st("onPointerEnter",["pointerout","pointerover"]),st("onPointerLeave",["pointerout","pointerover"]),it("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),it("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),it("onBeforeInput",["compositionend","keypress","textInput","paste"]),it("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),it("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),it("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Yu="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Ju=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Yu));function Zu(e,t){t=!!(4&t);for(var n=0;n<e.length;n++){var l=e[n],r=l.event;l=l.listeners;e:{var a=void 0;if(t)for(var o=l.length-1;0<=o;o--){var i=l[o],s=i.instance,c=i.currentTarget;if(i=i.listener,s!==a&&r.isPropagationStopped())break e;a=i,r.currentTarget=c;try{a(r)}catch(u){Tl(u)}r.currentTarget=null,a=s}else for(o=0;o<l.length;o++){if(s=(i=l[o]).instance,c=i.currentTarget,i=i.listener,s!==a&&r.isPropagationStopped())break e;a=i,r.currentTarget=c;try{a(r)}catch(u){Tl(u)}r.currentTarget=null,a=s}}}}function ed(e,t){var n=t[Ge];void 0===n&&(n=t[Ge]=new Set);var l=e+"__bubble";n.has(l)||(rd(t,e,2,!1),n.add(l))}function td(e,t,n){var l=0;t&&(l|=4),rd(n,e,l,t)}var nd="_reactListening"+Math.random().toString(36).slice(2);function ld(e){if(!e[nd]){e[nd]=!0,at.forEach(function(t){"selectionchange"!==t&&(Ju.has(t)||td(t,!1,e),td(t,!0,e))});var t=9===e.nodeType?e:e.ownerDocument;null===t||t[nd]||(t[nd]=!0,td("selectionchange",!1,t))}}function rd(e,t,n,l){switch(Tb(t)){case 2:var r=Sb;break;case 8:r=jb;break;default:r=Nb}n=r.bind(null,t,n,e),r=void 0,!Ht||"touchstart"!==t&&"touchmove"!==t&&"wheel"!==t||(r=!0),l?void 0!==r?e.addEventListener(t,n,{capture:!0,passive:r}):e.addEventListener(t,n,!0):void 0!==r?e.addEventListener(t,n,{passive:r}):e.addEventListener(t,n,!1)}function ad(e,t,n,l,r){var o=l;if(!(1&t||2&t||null===l))e:for(;;){if(null===l)return;var i=l.tag;if(3===i||4===i){var s=l.stateNode.containerInfo;if(s===r)break;if(4===i)for(i=l.return;null!==i;){var c=i.tag;if((3===c||4===c)&&i.stateNode.containerInfo===r)return;i=i.return}for(;null!==s;){if(null===(i=et(s)))return;if(5===(c=i.tag)||6===c||26===c||27===c){l=o=i;continue e}s=s.parentNode}}l=l.return}Wt(function(){var l=o,r=Ot(n),i=[];e:{var s=El.get(e);if(void 0!==s){var c=on,u=e;switch(e){case"keypress":if(0===Jt(n))break e;case"keydown":case"keyup":c=kn;break;case"focusin":u="focus",c=mn;break;case"focusout":u="blur",c=mn;break;case"beforeblur":case"afterblur":c=mn;break;case"click":if(2===n.button)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":c=dn;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":c=bn;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":c=Sn;break;case xl:case wl:case kl:c=hn;break;case Nl:c=jn;break;case"scroll":case"scrollend":c=cn;break;case"wheel":c=Nn;break;case"copy":case"cut":case"paste":c=pn;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":c=Cn;break;case"toggle":case"beforetoggle":c=En}var d=!!(4&t),b=!d&&("scroll"===e||"scrollend"===e),m=d?null!==s?s+"Capture":null:s;d=[];for(var h,p=l;null!==p;){var f=p;if(h=f.stateNode,5!==(f=f.tag)&&26!==f&&27!==f||null===h||null===m||null!=(f=qt(p,m))&&d.push(od(p,f,h)),b)break;p=p.return}0<d.length&&(s=new c(s,u,null,n,r),i.push({event:s,listeners:d}))}}if(!(7&t)){if(c="mouseout"===e||"pointerout"===e,(!(s="mouseover"===e||"pointerover"===e)||n===Dt||!(u=n.relatedTarget||n.fromElement)||!et(u)&&!u[Ke])&&(c||s)&&(s=r.window===r?r:(s=r.ownerDocument)?s.defaultView||s.parentWindow:window,c?(c=l,null!==(u=(u=n.relatedTarget||n.toElement)?et(u):null)&&(b=a(u),d=u.tag,u!==b||5!==d&&27!==d&&6!==d)&&(u=null)):(c=null,u=l),c!==u)){if(d=dn,f="onMouseLeave",m="onMouseEnter",p="mouse","pointerout"!==e&&"pointerover"!==e||(d=Cn,f="onPointerLeave",m="onPointerEnter",p="pointer"),b=null==c?s:nt(c),h=null==u?s:nt(u),(s=new d(f,p+"leave",c,n,r)).target=b,s.relatedTarget=h,f=null,et(r)===l&&((d=new d(m,p+"enter",u,n,r)).target=h,d.relatedTarget=b,f=d),b=f,c&&u)e:{for(d=sd,p=u,h=0,f=m=c;f;f=d(f))h++;f=0;for(var g=p;g;g=d(g))f++;for(;0<h-f;)m=d(m),h--;for(;0<f-h;)p=d(p),f--;for(;h--;){if(m===p||null!==p&&m===p.alternate){d=m;break e}m=d(m),p=d(p)}d=null}else d=null;null!==c&&cd(i,s,c,d,!1),null!==u&&null!==b&&cd(i,b,u,d,!0)}if("select"===(c=(s=l?nt(l):window).nodeName&&s.nodeName.toLowerCase())||"input"===c&&"file"===s.type)var y=Vn;else if(Rn(s))if(Hn)y=tl;else{y=Zn;var v=Jn}else!(c=s.nodeName)||"input"!==c.toLowerCase()||"checkbox"!==s.type&&"radio"!==s.type?l&&Lt(l.elementType)&&(y=Vn):y=el;switch(y&&(y=y(e,l))?Fn(i,y,n,r):(v&&v(e,s,l),"focusout"===e&&l&&"number"===s.type&&null!=l.memoizedProps.value&&St(s,"number",s.value)),v=l?nt(l):window,e){case"focusin":(Rn(v)||"true"===v.contentEditable)&&(ul=v,dl=l,bl=null);break;case"focusout":bl=dl=ul=null;break;case"mousedown":ml=!0;break;case"contextmenu":case"mouseup":case"dragend":ml=!1,hl(i,n,r);break;case"selectionchange":if(cl)break;case"keydown":case"keyup":hl(i,n,r)}var x;if(_n)e:{switch(e){case"compositionstart":var w="onCompositionStart";break e;case"compositionend":w="onCompositionEnd";break e;case"compositionupdate":w="onCompositionUpdate";break e}w=void 0}else Dn?Pn(e,n)&&(w="onCompositionEnd"):"keydown"===e&&229===n.keyCode&&(w="onCompositionStart");w&&(Ln&&"ko"!==n.locale&&(Dn||"onCompositionStart"!==w?"onCompositionEnd"===w&&Dn&&(x=Yt()):(Qt="value"in(Gt=r)?Gt.value:Gt.textContent,Dn=!0)),0<(v=id(l,w)).length&&(w=new fn(w,e,null,n,r),i.push({event:w,listeners:v}),x?w.data=x:null!==(x=In(n))&&(w.data=x))),(x=zn?function(e,t){switch(e){case"compositionend":return In(t);case"keypress":return 32!==t.which?null:(Mn=!0,An);case"textInput":return(e=t.data)===An&&Mn?null:e;default:return null}}(e,n):function(e,t){if(Dn)return"compositionend"===e||!_n&&Pn(e,t)?(e=Yt(),Xt=Qt=Gt=null,Dn=!1,e):null;switch(e){case"paste":default:return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Ln&&"ko"!==t.locale?null:t.data}}(e,n))&&(0<(w=id(l,"onBeforeInput")).length&&(v=new fn("onBeforeInput","beforeinput",null,n,r),i.push({event:v,listeners:w}),v.data=x)),function(e,t,n,l,r){if("submit"===t&&n&&n.stateNode===r){var a=Ku((r[He]||null).action),o=l.submitter;o&&null!==(t=(t=o[He]||null)?Ku(t.formAction):o.getAttribute("formAction"))&&(a=t,o=null);var i=new on("action","action",null,l,r);e.push({event:i,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(0!==Ou){var e=o?Gu(r,o):new FormData(r);ai(n,{pending:!0,data:e,method:r.method,action:a},null,e)}}else"function"==typeof a&&(i.preventDefault(),e=o?Gu(r,o):new FormData(r),ai(n,{pending:!0,data:e,method:r.method,action:a},a,e))},currentTarget:r}]})}}(i,e,l,n,r)}Zu(i,t)})}function od(e,t,n){return{instance:e,listener:t,currentTarget:n}}function id(e,t){for(var n=t+"Capture",l=[];null!==e;){var r=e,a=r.stateNode;if(5!==(r=r.tag)&&26!==r&&27!==r||null===a||(null!=(r=qt(e,n))&&l.unshift(od(e,r,a)),null!=(r=qt(e,t))&&l.push(od(e,r,a))),3===e.tag)return l;e=e.return}return[]}function sd(e){if(null===e)return null;do{e=e.return}while(e&&5!==e.tag&&27!==e.tag);return e||null}function cd(e,t,n,l,r){for(var a=t._reactName,o=[];null!==n&&n!==l;){var i=n,s=i.alternate,c=i.stateNode;if(i=i.tag,null!==s&&s===l)break;5!==i&&26!==i&&27!==i||null===c||(s=c,r?null!=(c=qt(n,a))&&o.unshift(od(n,c,s)):r||null!=(c=qt(n,a))&&o.push(od(n,c,s))),n=n.return}0!==o.length&&e.push({event:t,listeners:o})}var ud=/\r\n?/g,dd=/\u0000|\uFFFD/g;function bd(e){return("string"==typeof e?e:""+e).replace(ud,"\n").replace(dd,"")}function md(e,t){return t=bd(t),bd(e)===t}function hd(e,t,n,r,a,o){switch(n){case"children":"string"==typeof r?"body"===t||"textarea"===t&&""===r||$t(e,r):("number"==typeof r||"bigint"==typeof r)&&"body"!==t&&$t(e,""+r);break;case"className":mt(e,"class",r);break;case"tabIndex":mt(e,"tabindex",r);break;case"dir":case"role":case"viewBox":case"width":case"height":mt(e,n,r);break;case"style":zt(e,r,o);break;case"data":if("object"!==t){mt(e,"data",r);break}case"src":case"href":if(""===r&&("a"!==t||"href"!==n)){e.removeAttribute(n);break}if(null==r||"function"==typeof r||"symbol"==typeof r||"boolean"==typeof r){e.removeAttribute(n);break}r=Pt(""+r),e.setAttribute(n,r);break;case"action":case"formAction":if("function"==typeof r){e.setAttribute(n,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}if("function"==typeof o&&("formAction"===n?("input"!==t&&hd(e,t,"name",a.name,a,null),hd(e,t,"formEncType",a.formEncType,a,null),hd(e,t,"formMethod",a.formMethod,a,null),hd(e,t,"formTarget",a.formTarget,a,null)):(hd(e,t,"encType",a.encType,a,null),hd(e,t,"method",a.method,a,null),hd(e,t,"target",a.target,a,null))),null==r||"symbol"==typeof r||"boolean"==typeof r){e.removeAttribute(n);break}r=Pt(""+r),e.setAttribute(n,r);break;case"onClick":null!=r&&(e.onclick=It);break;case"onScroll":null!=r&&ed("scroll",e);break;case"onScrollEnd":null!=r&&ed("scrollend",e);break;case"dangerouslySetInnerHTML":if(null!=r){if("object"!=typeof r||!("__html"in r))throw Error(l(61));if(null!=(n=r.__html)){if(null!=a.children)throw Error(l(60));e.innerHTML=n}}break;case"multiple":e.multiple=r&&"function"!=typeof r&&"symbol"!=typeof r;break;case"muted":e.muted=r&&"function"!=typeof r&&"symbol"!=typeof r;break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":case"autoFocus":break;case"xlinkHref":if(null==r||"function"==typeof r||"boolean"==typeof r||"symbol"==typeof r){e.removeAttribute("xlink:href");break}n=Pt(""+r),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":null!=r&&"function"!=typeof r&&"symbol"!=typeof r?e.setAttribute(n,""+r):e.removeAttribute(n);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":r&&"function"!=typeof r&&"symbol"!=typeof r?e.setAttribute(n,""):e.removeAttribute(n);break;case"capture":case"download":!0===r?e.setAttribute(n,""):!1!==r&&null!=r&&"function"!=typeof r&&"symbol"!=typeof r?e.setAttribute(n,r):e.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":null!=r&&"function"!=typeof r&&"symbol"!=typeof r&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case"rowSpan":case"start":null==r||"function"==typeof r||"symbol"==typeof r||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case"popover":ed("beforetoggle",e),ed("toggle",e),bt(e,"popover",r);break;case"xlinkActuate":ht(e,"http://www.w3.org/1999/xlink","xlink:actuate",r);break;case"xlinkArcrole":ht(e,"http://www.w3.org/1999/xlink","xlink:arcrole",r);break;case"xlinkRole":ht(e,"http://www.w3.org/1999/xlink","xlink:role",r);break;case"xlinkShow":ht(e,"http://www.w3.org/1999/xlink","xlink:show",r);break;case"xlinkTitle":ht(e,"http://www.w3.org/1999/xlink","xlink:title",r);break;case"xlinkType":ht(e,"http://www.w3.org/1999/xlink","xlink:type",r);break;case"xmlBase":ht(e,"http://www.w3.org/XML/1998/namespace","xml:base",r);break;case"xmlLang":ht(e,"http://www.w3.org/XML/1998/namespace","xml:lang",r);break;case"xmlSpace":ht(e,"http://www.w3.org/XML/1998/namespace","xml:space",r);break;case"is":bt(e,"is",r);break;case"innerText":case"textContent":break;default:(!(2<n.length)||"o"!==n[0]&&"O"!==n[0]||"n"!==n[1]&&"N"!==n[1])&&bt(e,n=At.get(n)||n,r)}}function pd(e,t,n,r,a,o){switch(n){case"style":zt(e,r,o);break;case"dangerouslySetInnerHTML":if(null!=r){if("object"!=typeof r||!("__html"in r))throw Error(l(61));if(null!=(n=r.__html)){if(null!=a.children)throw Error(l(60));e.innerHTML=n}}break;case"children":"string"==typeof r?$t(e,r):("number"==typeof r||"bigint"==typeof r)&&$t(e,""+r);break;case"onScroll":null!=r&&ed("scroll",e);break;case"onScrollEnd":null!=r&&ed("scrollend",e);break;case"onClick":null!=r&&(e.onclick=It);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":case"innerText":case"textContent":break;default:ot.hasOwnProperty(n)||("o"!==n[0]||"n"!==n[1]||(a=n.endsWith("Capture"),t=n.slice(2,a?n.length-7:void 0),"function"==typeof(o=null!=(o=e[He]||null)?o[n]:null)&&e.removeEventListener(t,o,a),"function"!=typeof r)?n in e?e[n]=r:!0===r?e.setAttribute(n,""):bt(e,n,r):("function"!=typeof o&&null!==o&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a)))}}function fd(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":ed("error",e),ed("load",e);var r,a=!1,o=!1;for(r in n)if(n.hasOwnProperty(r)){var i=n[r];if(null!=i)switch(r){case"src":a=!0;break;case"srcSet":o=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(l(137,t));default:hd(e,t,r,i,n,null)}}return o&&hd(e,t,"srcSet",n.srcSet,n,null),void(a&&hd(e,t,"src",n.src,n,null));case"input":ed("invalid",e);var s=r=i=o=null,c=null,u=null;for(a in n)if(n.hasOwnProperty(a)){var d=n[a];if(null!=d)switch(a){case"name":o=d;break;case"type":i=d;break;case"checked":c=d;break;case"defaultChecked":u=d;break;case"value":r=d;break;case"defaultValue":s=d;break;case"children":case"dangerouslySetInnerHTML":if(null!=d)throw Error(l(137,t));break;default:hd(e,t,a,d,n,null)}}return void Ct(e,r,s,c,u,i,o,!1);case"select":for(o in ed("invalid",e),a=i=r=null,n)if(n.hasOwnProperty(o)&&null!=(s=n[o]))switch(o){case"value":r=s;break;case"defaultValue":i=s;break;case"multiple":a=s;default:hd(e,t,o,s,n,null)}return t=r,n=i,e.multiple=!!a,void(null!=t?jt(e,!!a,t,!1):null!=n&&jt(e,!!a,n,!0));case"textarea":for(i in ed("invalid",e),r=o=a=null,n)if(n.hasOwnProperty(i)&&null!=(s=n[i]))switch(i){case"value":a=s;break;case"defaultValue":o=s;break;case"children":r=s;break;case"dangerouslySetInnerHTML":if(null!=s)throw Error(l(91));break;default:hd(e,t,i,s,n,null)}return void Et(e,a,o,r);case"option":for(c in n)if(n.hasOwnProperty(c)&&null!=(a=n[c]))if("selected"===c)e.selected=a&&"function"!=typeof a&&"symbol"!=typeof a;else hd(e,t,c,a,n,null);return;case"dialog":ed("beforetoggle",e),ed("toggle",e),ed("cancel",e),ed("close",e);break;case"iframe":case"object":ed("load",e);break;case"video":case"audio":for(a=0;a<Yu.length;a++)ed(Yu[a],e);break;case"image":ed("error",e),ed("load",e);break;case"details":ed("toggle",e);break;case"embed":case"source":case"link":ed("error",e),ed("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(u in n)if(n.hasOwnProperty(u)&&null!=(a=n[u]))switch(u){case"children":case"dangerouslySetInnerHTML":throw Error(l(137,t));default:hd(e,t,u,a,n,null)}return;default:if(Lt(t)){for(d in n)n.hasOwnProperty(d)&&(void 0!==(a=n[d])&&pd(e,t,d,a,n,void 0));return}}for(s in n)n.hasOwnProperty(s)&&(null!=(a=n[s])&&hd(e,t,s,a,n,null))}function gd(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}var yd=null,vd=null;function xd(e){return 9===e.nodeType?e:e.ownerDocument}function wd(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function kd(e,t){if(0===e)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return 1===e&&"foreignObject"===t?0:e}function Cd(e,t){return"textarea"===e||"noscript"===e||"string"==typeof t.children||"number"==typeof t.children||"bigint"==typeof t.children||"object"==typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&null!=t.dangerouslySetInnerHTML.__html}var Sd=null;var jd="function"==typeof setTimeout?setTimeout:void 0,Nd="function"==typeof clearTimeout?clearTimeout:void 0,Ed="function"==typeof Promise?Promise:void 0,$d="function"==typeof queueMicrotask?queueMicrotask:void 0!==Ed?function(e){return Ed.resolve(null).then(e).catch(_d)}:jd;function _d(e){setTimeout(function(){throw e})}function Td(e){return"head"===e}function zd(e,t){var n=t,l=0;do{var r=n.nextSibling;if(e.removeChild(n),r&&8===r.nodeType)if("/$"===(n=r.data)||"/&"===n){if(0===l)return e.removeChild(r),void Gb(t);l--}else if("$"===n||"$?"===n||"$~"===n||"$!"===n||"&"===n)l++;else if("html"===n)Bd(e.ownerDocument.documentElement);else if("head"===n){Bd(n=e.ownerDocument.head);for(var a=n.firstChild;a;){var o=a.nextSibling,i=a.nodeName;a[Je]||"SCRIPT"===i||"STYLE"===i||"LINK"===i&&"stylesheet"===a.rel.toLowerCase()||n.removeChild(a),a=o}}else"body"===n&&Bd(e.ownerDocument.body);n=r}while(n);Gb(t)}function Ld(e,t){var n=e;e=0;do{var l=n.nextSibling;if(1===n.nodeType?t?(n._stashedDisplay=n.style.display,n.style.display="none"):(n.style.display=n._stashedDisplay||"",""===n.getAttribute("style")&&n.removeAttribute("style")):3===n.nodeType&&(t?(n._stashedText=n.nodeValue,n.nodeValue=""):n.nodeValue=n._stashedText||""),l&&8===l.nodeType)if("/$"===(n=l.data)){if(0===e)break;e--}else"$"!==n&&"$?"!==n&&"$~"!==n&&"$!"!==n||e++;n=l}while(n)}function Ad(e){var t=e.firstChild;for(t&&10===t.nodeType&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case"HTML":case"HEAD":case"BODY":Ad(n),Ze(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if("stylesheet"===n.rel.toLowerCase())continue}e.removeChild(n)}}function Md(e,t){for(;8!==e.nodeType;){if((1!==e.nodeType||"INPUT"!==e.nodeName||"hidden"!==e.type)&&!t)return null;if(null===(e=Dd(e.nextSibling)))return null}return e}function Pd(e){return"$?"===e.data||"$~"===e.data}function Id(e){return"$!"===e.data||"$?"===e.data&&"loading"!==e.ownerDocument.readyState}function Dd(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break;if(8===t){if("$"===(t=e.data)||"$!"===t||"$?"===t||"$~"===t||"&"===t||"F!"===t||"F"===t)break;if("/$"===t||"/&"===t)return null}}return e}var Od=null;function Rd(e){e=e.nextSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("/$"===n||"/&"===n){if(0===t)return Dd(e.nextSibling);t--}else"$"!==n&&"$!"!==n&&"$?"!==n&&"$~"!==n&&"&"!==n||t++}e=e.nextSibling}return null}function Fd(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("$"===n||"$!"===n||"$?"===n||"$~"===n||"&"===n){if(0===t)return e;t--}else"/$"!==n&&"/&"!==n||t++}e=e.previousSibling}return null}function Ud(e,t,n){switch(t=xd(n),e){case"html":if(!(e=t.documentElement))throw Error(l(452));return e;case"head":if(!(e=t.head))throw Error(l(453));return e;case"body":if(!(e=t.body))throw Error(l(454));return e;default:throw Error(l(451))}}function Bd(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Ze(e)}var Wd=new Map,qd=new Set;function Vd(e){return"function"==typeof e.getRootNode?e.getRootNode():9===e.nodeType?e:e.ownerDocument}var Hd=R.d;R.d={f:function(){var e=Hd.f(),t=lu();return e||t},r:function(e){var t=tt(e);null!==t&&5===t.tag&&"form"===t.type?ii(t):Hd.r(e)},D:function(e){Hd.D(e),Gd("dns-prefetch",e,null)},C:function(e,t){Hd.C(e,t),Gd("preconnect",e,t)},L:function(e,t,n){Hd.L(e,t,n);var l=Kd;if(l&&e&&t){var r='link[rel="preload"][as="'+wt(t)+'"]';"image"===t&&n&&n.imageSrcSet?(r+='[imagesrcset="'+wt(n.imageSrcSet)+'"]',"string"==typeof n.imageSizes&&(r+='[imagesizes="'+wt(n.imageSizes)+'"]')):r+='[href="'+wt(e)+'"]';var a=r;switch(t){case"style":a=Xd(e);break;case"script":a=Zd(e)}Wd.has(a)||(e=u({rel:"preload",href:"image"===t&&n&&n.imageSrcSet?void 0:e,as:t},n),Wd.set(a,e),null!==l.querySelector(r)||"style"===t&&l.querySelector(Yd(a))||"script"===t&&l.querySelector(eb(a))||(fd(t=l.createElement("link"),"link",e),rt(t),l.head.appendChild(t)))}},m:function(e,t){Hd.m(e,t);var n=Kd;if(n&&e){var l=t&&"string"==typeof t.as?t.as:"script",r='link[rel="modulepreload"][as="'+wt(l)+'"][href="'+wt(e)+'"]',a=r;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":a=Zd(e)}if(!Wd.has(a)&&(e=u({rel:"modulepreload",href:e},t),Wd.set(a,e),null===n.querySelector(r))){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(eb(a)))return}fd(l=n.createElement("link"),"link",e),rt(l),n.head.appendChild(l)}}},X:function(e,t){Hd.X(e,t);var n=Kd;if(n&&e){var l=lt(n).hoistableScripts,r=Zd(e),a=l.get(r);a||((a=n.querySelector(eb(r)))||(e=u({src:e,async:!0},t),(t=Wd.get(r))&&rb(e,t),rt(a=n.createElement("script")),fd(a,"link",e),n.head.appendChild(a)),a={type:"script",instance:a,count:1,state:null},l.set(r,a))}},S:function(e,t,n){Hd.S(e,t,n);var l=Kd;if(l&&e){var r=lt(l).hoistableStyles,a=Xd(e);t=t||"default";var o=r.get(a);if(!o){var i={loading:0,preload:null};if(o=l.querySelector(Yd(a)))i.loading=5;else{e=u({rel:"stylesheet",href:e,"data-precedence":t},n),(n=Wd.get(a))&&lb(e,n);var s=o=l.createElement("link");rt(s),fd(s,"link",e),s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),s.addEventListener("load",function(){i.loading|=1}),s.addEventListener("error",function(){i.loading|=2}),i.loading|=4,nb(o,t,l)}o={type:"stylesheet",instance:o,count:1,state:i},r.set(a,o)}}},M:function(e,t){Hd.M(e,t);var n=Kd;if(n&&e){var l=lt(n).hoistableScripts,r=Zd(e),a=l.get(r);a||((a=n.querySelector(eb(r)))||(e=u({src:e,async:!0,type:"module"},t),(t=Wd.get(r))&&rb(e,t),rt(a=n.createElement("script")),fd(a,"link",e),n.head.appendChild(a)),a={type:"script",instance:a,count:1,state:null},l.set(r,a))}}};var Kd="undefined"==typeof document?null:document;function Gd(e,t,n){var l=Kd;if(l&&"string"==typeof t&&t){var r=wt(t);r='link[rel="'+e+'"][href="'+r+'"]',"string"==typeof n&&(r+='[crossorigin="'+n+'"]'),qd.has(r)||(qd.add(r),e={rel:e,crossOrigin:n,href:t},null===l.querySelector(r)&&(fd(t=l.createElement("link"),"link",e),rt(t),l.head.appendChild(t)))}}function Qd(e,t,n,r){var a,o,i,s,c=(c=X.current)?Vd(c):null;if(!c)throw Error(l(446));switch(e){case"meta":case"title":return null;case"style":return"string"==typeof n.precedence&&"string"==typeof n.href?(t=Xd(n.href),(r=(n=lt(c).hoistableStyles).get(t))||(r={type:"style",instance:null,count:0,state:null},n.set(t,r)),r):{type:"void",instance:null,count:0,state:null};case"link":if("stylesheet"===n.rel&&"string"==typeof n.href&&"string"==typeof n.precedence){e=Xd(n.href);var u=lt(c).hoistableStyles,d=u.get(e);if(d||(c=c.ownerDocument||c,d={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(e,d),(u=c.querySelector(Yd(e)))&&!u._p&&(d.instance=u,d.state.loading=5),Wd.has(e)||(n={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},Wd.set(e,n),u||(a=c,o=e,i=n,s=d.state,a.querySelector('link[rel="preload"][as="style"]['+o+"]")?s.loading=1:(o=a.createElement("link"),s.preload=o,o.addEventListener("load",function(){return s.loading|=1}),o.addEventListener("error",function(){return s.loading|=2}),fd(o,"link",i),rt(o),a.head.appendChild(o))))),t&&null===r)throw Error(l(528,""));return d}if(t&&null!==r)throw Error(l(529,""));return null;case"script":return t=n.async,"string"==typeof(n=n.src)&&t&&"function"!=typeof t&&"symbol"!=typeof t?(t=Zd(n),(r=(n=lt(c).hoistableScripts).get(t))||(r={type:"script",instance:null,count:0,state:null},n.set(t,r)),r):{type:"void",instance:null,count:0,state:null};default:throw Error(l(444,e))}}function Xd(e){return'href="'+wt(e)+'"'}function Yd(e){return'link[rel="stylesheet"]['+e+"]"}function Jd(e){return u({},e,{"data-precedence":e.precedence,precedence:null})}function Zd(e){return'[src="'+wt(e)+'"]'}function eb(e){return"script[async]"+e}function tb(e,t,n){if(t.count++,null===t.instance)switch(t.type){case"style":var r=e.querySelector('style[data-href~="'+wt(n.href)+'"]');if(r)return t.instance=r,rt(r),r;var a=u({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return rt(r=(e.ownerDocument||e).createElement("style")),fd(r,"style",a),nb(r,n.precedence,e),t.instance=r;case"stylesheet":a=Xd(n.href);var o=e.querySelector(Yd(a));if(o)return t.state.loading|=4,t.instance=o,rt(o),o;r=Jd(n),(a=Wd.get(a))&&lb(r,a),rt(o=(e.ownerDocument||e).createElement("link"));var i=o;return i._p=new Promise(function(e,t){i.onload=e,i.onerror=t}),fd(o,"link",r),t.state.loading|=4,nb(o,n.precedence,e),t.instance=o;case"script":return o=Zd(n.src),(a=e.querySelector(eb(o)))?(t.instance=a,rt(a),a):(r=n,(a=Wd.get(o))&&rb(r=u({},n),a),rt(a=(e=e.ownerDocument||e).createElement("script")),fd(a,"link",r),e.head.appendChild(a),t.instance=a);case"void":return null;default:throw Error(l(443,t.type))}else"stylesheet"===t.type&&!(4&t.state.loading)&&(r=t.instance,t.state.loading|=4,nb(r,n.precedence,e));return t.instance}function nb(e,t,n){for(var l=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),r=l.length?l[l.length-1]:null,a=r,o=0;o<l.length;o++){var i=l[o];if(i.dataset.precedence===t)a=i;else if(a!==r)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=9===n.nodeType?n.head:n).insertBefore(e,t.firstChild)}function lb(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.title&&(e.title=t.title)}function rb(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.integrity&&(e.integrity=t.integrity)}var ab=null;function ob(e,t,n){if(null===ab){var l=new Map,r=ab=new Map;r.set(n,l)}else(l=(r=ab).get(n))||(l=new Map,r.set(n,l));if(l.has(e))return l;for(l.set(e,null),n=n.getElementsByTagName(e),r=0;r<n.length;r++){var a=n[r];if(!(a[Je]||a[Ve]||"link"===e&&"stylesheet"===a.getAttribute("rel"))&&"http://www.w3.org/2000/svg"!==a.namespaceURI){var o=a.getAttribute(t)||"";o=e+o;var i=l.get(o);i?i.push(a):l.set(o,[a])}}return l}function ib(e,t,n){(e=e.ownerDocument||e).head.insertBefore(n,"title"===t?e.querySelector("head > title"):null)}function sb(e){return!!("stylesheet"!==e.type||3&e.state.loading)}var cb=0;function ub(){if(this.count--,0===this.count&&(0===this.imgCount||!this.waitingForImages))if(this.stylesheets)bb(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}var db=null;function bb(e,t){e.stylesheets=null,null!==e.unsuspend&&(e.count++,db=new Map,t.forEach(mb,e),db=null,ub.call(e))}function mb(e,t){if(!(4&t.state.loading)){var n=db.get(e);if(n)var l=n.get(null);else{n=new Map,db.set(e,n);for(var r=e.querySelectorAll("link[data-precedence],style[data-precedence]"),a=0;a<r.length;a++){var o=r[a];"LINK"!==o.nodeName&&"not all"===o.getAttribute("media")||(n.set(o.dataset.precedence,o),l=o)}l&&n.set(null,l)}o=(r=t.instance).getAttribute("data-precedence"),(a=n.get(o)||l)===l&&n.set(null,r),n.set(o,r),this.count++,l=ub.bind(this),r.addEventListener("load",l),r.addEventListener("error",l),a?a.parentNode.insertBefore(r,a.nextSibling):(e=9===e.nodeType?e.head:e).insertBefore(r,e.firstChild),t.state.loading|=4}}var hb={$$typeof:v,Provider:null,Consumer:null,_currentValue:F,_currentValue2:F,_threadCount:0};function pb(e,t,n,l,r,a,o,i,s){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Pe(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Pe(0),this.hiddenUpdates=Pe(null),this.identifierPrefix=l,this.onUncaughtError=r,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=s,this.incompleteTransitions=new Map}function fb(e,t,n,l,r,a,o,i,s,c,u,d){return e=new pb(e,t,n,o,s,c,u,d,i),t=1,!0===a&&(t|=24),a=Bl(3,null,null,t),e.current=a,a.stateNode=e,(t=Wr()).refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:l,isDehydrated:n,cache:t},xa(a),e}function gb(e){return e?e=Fl:Fl}function yb(e,t,n,l,r,a){r=gb(r),null===l.context?l.context=r:l.pendingContext=r,(l=ka(t)).payload={element:n},null!==(a=void 0===a?null:a)&&(l.callback=a),null!==(n=Ca(e,l,t))&&(Jc(n,0,t),Sa(n,e,t))}function vb(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n<t?n:t}}function xb(e,t){vb(e,t),(e=e.alternate)&&vb(e,t)}function wb(e){if(13===e.tag||31===e.tag){var t=Dl(e,67108864);null!==t&&Jc(t,0,67108864),xb(e,67108864)}}function kb(e){if(13===e.tag||31===e.tag){var t=Xc(),n=Dl(e,t=Fe(t));null!==n&&Jc(n,0,t),xb(e,t)}}var Cb=!0;function Sb(e,t,n,l){var r=O.T;O.T=null;var a=R.p;try{R.p=2,Nb(e,t,n,l)}finally{R.p=a,O.T=r}}function jb(e,t,n,l){var r=O.T;O.T=null;var a=R.p;try{R.p=8,Nb(e,t,n,l)}finally{R.p=a,O.T=r}}function Nb(e,t,n,l){if(Cb){var r=Eb(l);if(null===r)ad(e,t,l,$b,n),Rb(e,l);else if(function(e,t,n,l,r){switch(t){case"focusin":return Lb=Fb(Lb,e,t,n,l,r),!0;case"dragenter":return Ab=Fb(Ab,e,t,n,l,r),!0;case"mouseover":return Mb=Fb(Mb,e,t,n,l,r),!0;case"pointerover":var a=r.pointerId;return Pb.set(a,Fb(Pb.get(a)||null,e,t,n,l,r)),!0;case"gotpointercapture":return a=r.pointerId,Ib.set(a,Fb(Ib.get(a)||null,e,t,n,l,r)),!0}return!1}(r,e,t,n,l))l.stopPropagation();else if(Rb(e,l),4&t&&-1<Ob.indexOf(e)){for(;null!==r;){var a=tt(r);if(null!==a)switch(a.tag){case 3:if((a=a.stateNode).current.memoizedState.isDehydrated){var o=Te(a.pendingLanes);if(0!==o){var i=a;for(i.pendingLanes|=2,i.entangledLanes|=2;o;){var s=1<<31-Se(o);i.entanglements[1]|=s,o&=~s}Ru(a),!(6&gc)&&(Oc=be()+500,Fu(0))}}break;case 31:case 13:null!==(i=Dl(a,2))&&Jc(i,0,2),lu(),xb(a,2)}if(null===(a=Eb(l))&&ad(e,t,l,$b,n),a===r)break;r=a}null!==r&&l.stopPropagation()}else ad(e,t,l,null,n)}}function Eb(e){return _b(e=Ot(e))}var $b=null;function _b(e){if($b=null,null!==(e=et(e))){var t=a(e);if(null===t)e=null;else{var n=t.tag;if(13===n){if(null!==(e=o(t)))return e;e=null}else if(31===n){if(null!==(e=i(t)))return e;e=null}else if(3===n){if(t.stateNode.current.memoizedState.isDehydrated)return 3===t.tag?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return $b=e,null}function Tb(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(me()){case he:return 2;case pe:return 8;case fe:case ge:return 32;case ye:return 268435456;default:return 32}default:return 32}}var zb=!1,Lb=null,Ab=null,Mb=null,Pb=new Map,Ib=new Map,Db=[],Ob="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Rb(e,t){switch(e){case"focusin":case"focusout":Lb=null;break;case"dragenter":case"dragleave":Ab=null;break;case"mouseover":case"mouseout":Mb=null;break;case"pointerover":case"pointerout":Pb.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ib.delete(t.pointerId)}}function Fb(e,t,n,l,r,a){return null===e||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:l,nativeEvent:a,targetContainers:[r]},null!==t&&(null!==(t=tt(t))&&wb(t)),e):(e.eventSystemFlags|=l,t=e.targetContainers,null!==r&&-1===t.indexOf(r)&&t.push(r),e)}function Ub(e){var t=et(e.target);if(null!==t){var n=a(t);if(null!==n)if(13===(t=n.tag)){if(null!==(t=o(n)))return e.blockedOn=t,void We(e.priority,function(){kb(n)})}else if(31===t){if(null!==(t=i(n)))return e.blockedOn=t,void We(e.priority,function(){kb(n)})}else if(3===t&&n.stateNode.current.memoizedState.isDehydrated)return void(e.blockedOn=3===n.tag?n.stateNode.containerInfo:null)}e.blockedOn=null}function Bb(e){if(null!==e.blockedOn)return!1;for(var t=e.targetContainers;0<t.length;){var n=Eb(e.nativeEvent);if(null!==n)return null!==(t=tt(n))&&wb(t),e.blockedOn=n,!1;var l=new(n=e.nativeEvent).constructor(n.type,n);Dt=l,n.target.dispatchEvent(l),Dt=null,t.shift()}return!0}function Wb(e,t,n){Bb(e)&&n.delete(t)}function qb(){zb=!1,null!==Lb&&Bb(Lb)&&(Lb=null),null!==Ab&&Bb(Ab)&&(Ab=null),null!==Mb&&Bb(Mb)&&(Mb=null),Pb.forEach(Wb),Ib.forEach(Wb)}function Vb(t,n){t.blockedOn===n&&(t.blockedOn=null,zb||(zb=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,qb)))}var Hb=null;function Kb(t){Hb!==t&&(Hb=t,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Hb===t&&(Hb=null);for(var e=0;e<t.length;e+=3){var n=t[e],l=t[e+1],r=t[e+2];if("function"!=typeof l){if(null===_b(l||n))continue;break}var a=tt(n);null!==a&&(t.splice(e,3),e-=3,ai(a,{pending:!0,data:r,method:n.method,action:l},l,r))}}))}function Gb(e){function t(t){return Vb(t,e)}null!==Lb&&Vb(Lb,e),null!==Ab&&Vb(Ab,e),null!==Mb&&Vb(Mb,e),Pb.forEach(t),Ib.forEach(t);for(var n=0;n<Db.length;n++){var l=Db[n];l.blockedOn===e&&(l.blockedOn=null)}for(;0<Db.length&&null===(n=Db[0]).blockedOn;)Ub(n),null===n.blockedOn&&Db.shift();if(null!=(n=(e.ownerDocument||e).$$reactFormReplay))for(l=0;l<n.length;l+=3){var r=n[l],a=n[l+1],o=r[He]||null;if("function"==typeof a)o||Kb(n);else if(o){var i=null;if(a&&a.hasAttribute("formAction")){if(r=a,o=a[He]||null)i=o.formAction;else if(null!==_b(r))continue}else i=o.action;"function"==typeof i?n[l+1]=i:(n.splice(l,3),l-=3),Kb(n)}}}function Qb(){function e(e){e.canIntercept&&"react-transition"===e.info&&e.intercept({handler:function(){return new Promise(function(e){return r=e})},focusReset:"manual",scroll:"manual"})}function t(){null!==r&&(r(),r=null),l||setTimeout(n,20)}function n(){if(!l&&!navigation.transition){var e=navigation.currentEntry;e&&null!=e.url&&navigation.navigate(e.url,{state:e.getState(),info:"react-transition",history:"replace"})}}if("object"==typeof navigation){var l=!1,r=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(n,100),function(){l=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),null!==r&&(r(),r=null)}}}function Xb(e){this._internalRoot=e}function Yb(e){this._internalRoot=e}Yb.prototype.render=Xb.prototype.render=function(e){var t=this._internalRoot;if(null===t)throw Error(l(409));yb(t.current,Xc(),e,t,null,null)},Yb.prototype.unmount=Xb.prototype.unmount=function(){var e=this._internalRoot;if(null!==e){this._internalRoot=null;var t=e.containerInfo;yb(e.current,2,null,e,null,null),lu(),t[Ke]=null}},Yb.prototype.unstable_scheduleHydration=function(e){if(e){var t=Be();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Db.length&&0!==t&&t<Db[n].priority;n++);Db.splice(n,0,e),0===n&&Ub(e)}};var Jb=t.version;if("19.2.3"!==Jb)throw Error(l(527,Jb,"19.2.3"));R.findDOMNode=function(e){var t=e._reactInternals;if(void 0===t){if("function"==typeof e.render)throw Error(l(188));throw e=Object.keys(e).join(","),Error(l(268,e))}return e=function(e){var t=e.alternate;if(!t){if(null===(t=a(e)))throw Error(l(188));return t!==e?null:e}for(var n=e,r=t;;){var o=n.return;if(null===o)break;var i=o.alternate;if(null===i){if(null!==(r=o.return)){n=r;continue}break}if(o.child===i.child){for(i=o.child;i;){if(i===n)return s(o),e;if(i===r)return s(o),t;i=i.sibling}throw Error(l(188))}if(n.return!==r.return)n=o,r=i;else{for(var c=!1,u=o.child;u;){if(u===n){c=!0,n=o,r=i;break}if(u===r){c=!0,r=o,n=i;break}u=u.sibling}if(!c){for(u=i.child;u;){if(u===n){c=!0,n=i,r=o;break}if(u===r){c=!0,r=i,n=o;break}u=u.sibling}if(!c)throw Error(l(189))}}if(n.alternate!==r)throw Error(l(190))}if(3!==n.tag)throw Error(l(188));return n.stateNode.current===n?e:t}(t),e=null===(e=null!==e?c(e):null)?null:e.stateNode};var Zb={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:O,reconcilerVersion:"19.2.3"};if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var em=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!em.isDisabled&&em.supportsFiber)try{we=em.inject(Zb),ke=em}catch(nm){}}return C.createRoot=function(e,t){if(!r(e))throw Error(l(299));var n=!1,a="",o=$i,i=_i,s=Ti;return null!=t&&(!0===t.unstable_strictMode&&(n=!0),void 0!==t.identifierPrefix&&(a=t.identifierPrefix),void 0!==t.onUncaughtError&&(o=t.onUncaughtError),void 0!==t.onCaughtError&&(i=t.onCaughtError),void 0!==t.onRecoverableError&&(s=t.onRecoverableError)),t=fb(e,1,!1,null,0,n,a,null,o,i,s,Qb),e[Ke]=t.current,ld(e),new Xb(t)},C.hydrateRoot=function(e,t,n){if(!r(e))throw Error(l(299));var a=!1,o="",i=$i,s=_i,c=Ti,u=null;return null!=n&&(!0===n.unstable_strictMode&&(a=!0),void 0!==n.identifierPrefix&&(o=n.identifierPrefix),void 0!==n.onUncaughtError&&(i=n.onUncaughtError),void 0!==n.onCaughtError&&(s=n.onCaughtError),void 0!==n.onRecoverableError&&(c=n.onRecoverableError),void 0!==n.formState&&(u=n.formState)),(t=fb(e,1,!0,t,0,a,o,u,i,s,c,Qb)).context=gb(null),n=t.current,(o=ka(a=Fe(a=Xc()))).callback=null,Ca(n,o,a),n=a,t.current.lanes=n,Ie(t,n),Ru(t),e[Ke]=t.current,ld(e),new Yb(t)},C.version="19.2.3",C}var P,I,D=(T||(T=1,function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}(),k.exports=M()),k.exports),O={exports:{}},R={};var F=(I||(I=1,O.exports=function(){if(P)return R;P=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(t,n,l){var r=null;if(void 0!==l&&(r=""+l),void 0!==n.key&&(r=""+n.key),"key"in n)for(var a in l={},n)"key"!==a&&(l[a]=n[a]);else l=n;return n=l.ref,{$$typeof:e,type:t,key:r,ref:void 0!==n?n:null,props:l}}return R.Fragment=t,R.jsx=n,R.jsxs=n,R}()),O.exports);const U=new class{constructor(){this.supportsContainerQueries=this.detectContainerQueries(),this.init()}detectContainerQueries(){if("undefined"==typeof window)return!1;try{if("CSS"in window&&"supports"in window.CSS)return window.CSS.supports("container-type","inline-size");const e=document.createElement("div");return e.style.containerType="inline-size","inline-size"===e.style.containerType}catch{return!1}}init(){"undefined"!=typeof window&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>this.applyClasses()):this.applyClasses())}applyClasses(){document.querySelectorAll(".limbo-component-container-wrapper").forEach(e=>{this.supportsContainerQueries?(e.classList.add("container-queries-supported"),e.classList.remove("container-queries-fallback")):(e.classList.add("container-queries-fallback"),e.classList.remove("container-queries-supported"))}),this.supportsContainerQueries?(document.body.classList.add("container-queries-supported"),document.body.classList.remove("container-queries-fallback")):(document.body.classList.add("container-queries-fallback"),document.body.classList.remove("container-queries-supported"))}getContainerWidth(e){if(!e)return window.innerWidth;let t=e.closest(".limbo-component-container-wrapper");return t||(t=e.closest(".limbo-modal-content")),t||(t=e.closest(".limbo-modal")),t||(t=document.body),t.offsetWidth||t.clientWidth}shouldUseMobileStyles(e,t=768){return this.getContainerWidth(e)<=t}applyResponsiveClasses(e){if(this.supportsContainerQueries)return;const t=this.shouldUseMobileStyles(e),n=this.shouldUseMobileStyles(e,1024)&&!t;e.classList.toggle("limbo-mobile-fallback",t),e.classList.toggle("limbo-tablet-fallback",n),e.classList.toggle("limbo-desktop-fallback",!t&&!n)}observeResize(){if(!this.supportsContainerQueries)if("ResizeObserver"in window){const e=new ResizeObserver(e=>{e.forEach(e=>{this.applyResponsiveClasses(e.target)})});document.querySelectorAll(".limbo-component-container-wrapper").forEach(t=>{e.observe(t)})}else window.addEventListener("resize",()=>{document.querySelectorAll(".limbo-component-container-wrapper").forEach(e=>{this.applyResponsiveClasses(e)})})}};function B(e={}){const{useContainerQuery:t=!1,containerElement:n=null}=e,[l,r]=y.useState(()=>{const e=t&&n?U.getContainerWidth(n):"undefined"!=typeof window?window.innerWidth:0,l="undefined"!=typeof window&&(e<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)),r="undefined"!=typeof window&&("ontouchstart"in window||navigator.maxTouchPoints>0);return{isMobile:l,isTouch:r,isTablet:"undefined"!=typeof window&&(e>768&&e<=1024&&r),orientation:"undefined"!=typeof window?window.innerHeight>window.innerWidth?"portrait":"landscape":"portrait",viewport:{width:"undefined"!=typeof window?window.innerWidth:0,height:"undefined"!=typeof window?window.innerHeight:0},container:{width:e,supportsContainerQueries:U.supportsContainerQueries}}});y.useEffect(()=>{if("undefined"==typeof window)return;const e=()=>{const e=window.innerWidth,l=window.innerHeight,a=t&&n?U.getContainerWidth(n):e,o=a<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),i="ontouchstart"in window||navigator.maxTouchPoints>0;r({isMobile:o,isTouch:i,isTablet:a>768&&a<=1024&&i,orientation:l>e?"portrait":"landscape",viewport:{width:e,height:l},container:{width:a,supportsContainerQueries:U.supportsContainerQueries}})};let l;const a=()=>{clearTimeout(l),l=setTimeout(e,150)};return window.addEventListener("resize",a),window.addEventListener("orientationchange",()=>{setTimeout(e,100)}),()=>{clearTimeout(l),window.removeEventListener("resize",a),window.removeEventListener("orientationchange",e)}},[t,n]);const a="portrait"===l.orientation,o="landscape"===l.orientation,i=l.isMobile||l.isTablet&&a;return{...l,isPortrait:a,isLandscape:o,isCompactMode:i,isMobileSize:l.viewport.width<=640,isTabletSize:l.viewport.width>640&&l.viewport.width<=1024,isDesktopSize:l.viewport.width>1024,deviceClass:l.isMobile?"mobile":l.isTablet?"tablet":"desktop"}}function W({tabs:e,active:t,onChange:n}){const{isMobile:l,isTouch:r}=B(),a=["limbo-tabs","lb:flex","lb:gap-4","lb:border-b-2","lb:border-brand-blue-200","lb:mb-6",l&&"lb:overflow-x-auto lb:scrollbar-none"].filter(Boolean).join(" "),o=e=>{const t=["limbo-tab","lb:relative","lb:px-6","lb:py-2","lb:font-medium","lb:text-brand-blue-1000","lb:bg-transparent","lb:border-0","lb:border-b-2","lb:cursor-pointer","lb:transition-all","lb:duration-200","lb:hover:text-pink-1000","lb:focus:outline-none","lb:focus-visible:ring-2","lb:focus-visible:ring-brand-blue-400","lb:focus-visible:ring-offset-2"];return e?t.push("lb:border-b-brand-blue-1000","lb:font-semibold","limbo-active"):t.push("lb:border-b-transparent"),l&&t.push("lb:min-w-[120px]","lb:min-h-[44px]","lb:text-base","lb:shrink-0"),r&&t.push("lb:touch-manipulation"),t.join(" ")};return F.jsx("div",{className:a,role:"tablist","aria-label":"Opciones de navegación",style:l?{WebkitOverflowScrolling:"touch",scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,children:e.map(l=>{const a=t===l.id;return!a&&l.hideNonActive?null:F.jsx("button",{"data-tab-id":l.id,onClick:()=>n(l.id),onKeyDown:t=>((t,l)=>{const r=e.findIndex(e=>e.id===l);let a=r;switch(t.key){case"ArrowLeft":case"ArrowUp":t.preventDefault(),a=r>0?r-1:e.length-1;break;case"ArrowRight":case"ArrowDown":t.preventDefault(),a=r<e.length-1?r+1:0;break;case"Home":t.preventDefault(),a=0;break;case"End":t.preventDefault(),a=e.length-1;break;case"Enter":case" ":return t.preventDefault(),void n(l);default:return}const o=e[a];o&&!o.hideNonActive&&(n(o.id),setTimeout(()=>{const e=document.querySelector(`[data-tab-id="${o.id}"]`);e&&e.focus()},0))})(t,l.id),className:o(a),role:"tab","aria-selected":a,"aria-controls":`tabpanel-${l.id}`,tabIndex:a?0:-1,id:`tab-${l.id}`,style:r?{WebkitTapHighlightColor:"transparent"}:void 0,children:l.label},l.id)})})}const q={DEV:"https://led-dev-limbo-dev.eu.els.local",PROD:"https://limbo.lefebvre.es"};function V(e,t=!1){if(!e)return"";if(e.startsWith("/files/")){return(t?q.PROD:q.DEV)+e}return e}function H(e){return"string"!=typeof e?e:e.replace(/"/g,'"').replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/'/g,"'")}function K(e){return!(!e||"string"!=typeof e)&&!e.startsWith("blob:")}function G(e,t={}){if(!e)return"";const{prefer:n="crop",isProd:l=!1}=t,r=H(e);try{const e=JSON.parse(r),t=()=>{if(e.images&&Array.isArray(e.images))for(const t of e.images)if(t&&K(t.url))return t.url;return null},a=e.original?.url,o=t();if("crop"===n){if(o)return V(o,l);if(K(a))return V(a,l)}else{if(K(a))return V(a,l);if(o)return V(o,l)}return K(e.url)?V(e.url,l):""}catch{if("string"==typeof r){if(r.startsWith("blob:"))return"";if(r.startsWith("/files/"))return V(r,l);if(r.startsWith("http")||r.startsWith("/"))return r}}return"string"==typeof e&&(e.startsWith("{")||e.startsWith("["))?"":e}const Q=[{regex:/^php/i,reason:'El nombre no puede empezar por "php"'},{regex:/\.(php\d?|phtml|phar)$/i,reason:"Extensión no permitida (.php)"},{regex:/\.(asp|aspx|ashx|asmx)$/i,reason:"Extensión no permitida (.asp)"},{regex:/\.(jsp|jspx|jspf)$/i,reason:"Extensión no permitida (.jsp)"},{regex:/\.(exe|bat|cmd|sh|ps1|vbs|cgi)$/i,reason:"Extensión ejecutable no permitida"},{regex:/<script/i,reason:"El nombre contiene código no permitido"},{regex:/\.\./,reason:"El nombre contiene rutas relativas no permitidas"}];function X(e){if(!e||"string"!=typeof e)return{valid:!1,error:"El nombre no puede estar vacío"};const t=e.trim();if(0===t.length)return{valid:!1,error:"El nombre no puede estar vacío"};if(t.length>255)return{valid:!1,error:"El nombre es demasiado largo (máx. 255 caracteres)"};for(const{regex:n,reason:l}of Q)if(n.test(t))return{valid:!1,error:l};return{valid:!0}}const Y=new Map,J=new Map,Z=18e5,ee=async e=>{if(!e)return Promise.reject(new Error("No URL provided"));const t=Y.get(e);if(t&&Date.now()-t.timestamp<Z)return t.blobUrl;if(J.has(e))return J.get(e);const n=(async()=>{try{let n,l,r=0;for(;r<2;)try{if(n=await fetch(e),!n.ok)throw new Error(`Failed to fetch image: ${n.status}`);break}catch(t){if(l=t,r+=1,r>=2)throw l}const a=await n.blob(),o=URL.createObjectURL(a);return Y.set(e,{blobUrl:o,timestamp:Date.now(),size:a.size}),o}finally{J.delete(e)}})();return J.set(e,n),n},te=e=>{const t=Y.get(e);return t&&Date.now()-t.timestamp<Z?t.blobUrl:e},ne=e=>{const t=Y.get(e);return t&&Date.now()-t.timestamp<Z},le=async(e,t=4)=>{const n=new Map,l=e.filter(e=>!ne(e));if(0===l.length)return e.forEach(e=>{n.set(e,te(e))}),n;const r=[];for(let a=0;a<l.length;a+=t)r.push(l.slice(a,a+t));for(const a of r){(await Promise.allSettled(a.map(async e=>({url:e,blobUrl:await ee(e)})))).forEach(e=>{"fulfilled"===e.status&&n.set(e.value.url,e.value.blobUrl)})}return n},re="https://led-dev-limbo-dev.eu.els.local",ae="https://limbo.lefebvre.es";let oe={publicKey:null,token:null,authMode:null,tokenEndpoint:null,tokenProvider:null,prod:!1};function ie({prod:e=!1}={}){return e?ae:re}function se(){return{...oe}}async function ce({endpoint:e,method:t="GET",body:n=null,prod:l=!1,basePath:r="",customHeaders:a={},isFormData:o=!1,useJWT:i=!0}){try{const s=l||oe.prod,c=await async function({isFormData:e=!1,useJWT:t=!0,customHeaders:n={}}={}){const l={"Access-Control-Allow-Origin":`${window.location.hostname||"*"}`};e||(l["Content-Type"]="application/json");let r=oe.token;if(t){if("jwt"===oe.authMode&&oe.tokenProvider&&!r)try{console.log("🔑 Calling tokenProvider..."),r=await oe.tokenProvider(),console.log("✅ Token obtained from tokenProvider"),oe.token=r}catch(a){throw console.error("❌ tokenProvider failed:",a),new Error("Failed to obtain token from tokenProvider: "+a.message)}else if("session"===oe.authMode&&!r)try{const e=ie(oe),t=oe.tokenEndpoint||"/auth/token",n=await fetch(`${e}${t}`,{method:"POST",headers:{"Content-Type":"application/json","Access-Control-Allow-Origin":`${window.location.hostname||"*"}`},body:JSON.stringify({public_key:oe.publicKey}),credentials:"include"});if(!n.ok)throw new Error(`Session auth failed: ${n.status}`);r=(await n.json()).token,oe.token=r}catch(a){throw console.error("❌ Session authentication failed:",a),new Error("Failed to authenticate with session. User must be logged in.")}r?l.Authorization=`Bearer ${r}`:console.warn("⚠️ No JWT token available:",{authMode:oe.authMode,hasPublicKey:!!oe.publicKey,hasTokenProvider:!!oe.tokenProvider})}return e&&delete l["Content-Type"],{...l,...n}}({isFormData:o,useJWT:i,customHeaders:a});"GET"===t&&!n&&c["Content-Type"]&&delete c["Content-Type"];const u=await fetch(`${ie({prod:s})}${r}${e}`,{method:t,headers:c,body:n?o?n:JSON.stringify(n):void 0,credentials:"include"});if(204===u.status)return{success:!0,data:null,message:"No content",httpCode:204,timestamp:(new Date).toISOString()};if(!u.ok){let e=`HTTP ${u.status}: ${u.statusText}`,t=null;try{const n=await u.json();t=n,n.error?e=`${n.error.code}: ${n.error.message}`:n.message&&(e=n.message)}catch{}throw 401===u.status&&t&&("token_expired"===t.error||t.message&&t.message.includes("expired")||t.message&&t.message.includes("caducado")||t.error&&t.error.includes("expired"))&&window.dispatchEvent(new CustomEvent("tokenExpiredError",{detail:{error:{response:{status:401,data:t}}}})),new Error(e)}return u.json()}catch(s){throw new Error(`API Error: ${s.message}`)}}function ue(){const e=se();return e?.prod||!1?"https://limbo.lefebvre.es":"https://led-dev-limbo-dev.eu.els.local"}function de(e){if(!e?.id)return null;return`${ue()}/api/assets/${e.id}/download`}function be(e){if(!e)return null;if(e.startsWith("http://")||e.startsWith("https://"))return e;if(e.startsWith("/")){return`${ue()}${e}`}return e}function me(e){if(!e?.success||!e?.data)return{result:null};const t=e.data;return{result:{id:t.id,filename:t.filename||t.original_filename,mime_type:t.mime_type,file_size:t.file_size,width:t.width,height:t.height,upload_date:t.upload_date||t.created_at,processed_date:t.processed_date,processing_status:t.processing_status||t.status,url:be(t.url)||de(t),url_webp:be(t.url_webp),url_original:be(t.url_original),format:t.format,format_original:t.format_original,permanent:t.permanent??!0,expires_at:t.expires_at,metadata:t.metadata||{},asset_type:t.asset_type||null,asset_subtype:t.asset_subtype||null,thumbnail_url:be(t.thumbnail_url)||null,variants:he(t.variants||[]),variants_count:t.variants_count||t.variants?.length||0}}}function he(e){return Array.isArray(e)?e.map(e=>({id:e.id,name:e.name,width:e.width,height:e.height,format:e.format||e.output_format,file_size:e.file_size,crop_params:e.crop_params,url:be(e.url),permanent:e.permanent??!0,expires_at:e.expires_at,created_at:e.created_at})):[]}function pe(e){if(!e?.success||!e?.data)return{result:null};const t=e.data;if(t.id&&t.url&&t.name&&!t.processing_mode&&!t.variants)return console.log("[adaptVariantGenerationFromV2] Detectado formato de /variants/upload"),{result:{id:t.id,name:t.name,width:t.width,height:t.height,format:t.format,file_size:t.file_size,url:t.url,urlSigned:t.url,status:"completed",created_at:t.created_at||(new Date).toISOString()}};if("sync"===t.processing_mode&&t.variants&&t.variants.length>0){const e=t.variants[0];return{result:{id:e.id||null,name:e.name,width:parseInt(e.size?.split("x")[0])||e.width,height:parseInt(e.size?.split("x")[1])||e.height,format:e.format,file_size:e.file_size,url:e.url,urlSigned:e.url,status:e.status,asset_id:t.asset_id,created_at:e.created_at||(new Date).toISOString(),all_variants:t.variants}}}return{result:{job_id:t.job_id,asset_id:t.asset_id,variants_requested:t.variants_requested||[],processing_mode:t.processing_mode||"async",estimated_completion:t.estimated_completion,variant_statuses:(t.variant_statuses||t.variants||[]).map(e=>({name:e.name,status:e.status,size:e.expected_size||e.size,format:e.format}))}}}function fe(e){if(e.message&&!e.message.includes("API Error:"))return e;let t=e.message||"Unknown API error";return t.startsWith("API Error: ")&&(t=t.substring(11)),new Error(t)}const ge="/api";async function ye(e={}){try{const t={url_expires:"0",...e},n=`/assets?${new URLSearchParams(t).toString()}`;return function(e){if(!e?.success||!Array.isArray(e?.data?.data))return{result:[]};const t={result:e.data.data.map(e=>({id:e.id,filename:e.filename||e.original_filename,mime_type:e.mime_type,file_size:e.file_size,width:e.width,height:e.height,upload_date:e.upload_date||e.created_at,processing_status:e.processing_status||e.status,variants:e.variants_count&&(he(e.variants)||he(e.image_variants))||[],url:be(e.url)||de(e),url_webp:be(e.url_webp),format:e.format,permanent:e.permanent??!0,expires_at:e.expires_at,folder:e.folder||null,asset_type:e.asset_type||null,asset_subtype:e.asset_subtype||null,thumbnail_url:be(e.thumbnail_url)||null,metadata:e.metadata||{},variants_count:e.variants_count||0}))};return e.data.pagination&&(t.pagination={page:e.data.pagination.page,limit:e.data.pagination.limit,total:e.data.pagination.total,pages:e.data.pagination.pages}),t}(await ce({endpoint:n,method:"GET",basePath:ge,useJWT:!0}))}catch(t){throw fe(t)}}async function ve(e,t=null,n=!1,l=null){try{const r=new FormData;r.append("file",e),t&&r.append("uploaded_by",t),n&&r.append("store_original",n.toString()),l&&r.append("folder",l);return function(e){if(!e?.success||!e?.data)return{result:null};const t=e.data;return{result:{id:t.id,filename:t.filename||t.original_filename,mime_type:t.mime_type,file_size:t.file_size,width:t.width,height:t.height,status:t.status,upload_date:t.created_at,url:be(t.url),url_webp:be(t.url_webp),url_original:be(t.url_original),format:t.format,format_original:t.format_original,permanent:t.permanent??!0,folder:t.folder||null,processing:t.processing||{master_webp:"processing"===t.status?"queued":"completed",variants:"processing"===t.status?"queued":"completed"},asset_type:t.asset_type||null,asset_subtype:t.asset_subtype||null,thumbnail_url:be(t.thumbnail_url)||null,checksum:t.checksum,storage_path:t.storage_path_base,metadata:t.metadata||{}}}}(await ce({endpoint:"/assets",method:"POST",body:r,basePath:ge,isFormData:!0,useJWT:!0}))}catch(r){throw fe(r)}}async function xe(e,t){try{return me(await ce({endpoint:`/assets/${e}`,method:"PATCH",body:t,basePath:ge,useJWT:!0}))}catch(n){throw fe(n)}}async function we(e,t=0){try{const l=new URLSearchParams({url_expires:t.toString()}),r=await ce({endpoint:`/assets/${e}/variants?${l}`,method:"GET",basePath:ge,useJWT:!0});return n=r,n?.success&&Array.isArray(n?.data?.variants)?{result:n.data.variants.map(e=>({id:e.id,name:e.filename||e.name||`Variante ${e.id}`,filename:e.filename,mime_type:e.mime_type,format:e.format||e.output_format||(e.mime_type?e.mime_type.split("/")[1]:"jpg"),file_size:e.file_size,width:e.width,height:e.height,upload_date:e.upload_date||e.created_at,processing_status:e.processing_status||e.status,url:be(e.url)||de(e),permanent:e.permanent??!0,expires_at:e.expires_at,metadata:e.metadata||{},crop_data:e.crop_data||{},crop_params:e.crop_params||e.crop_data||{},parent_asset_id:e.parent_asset_id||n.data.asset_id,variant_type:e.variant_type||"crop"}))}:{result:[]}}catch(l){throw fe(l)}var n}function ke(){const[e,t]=y.useState({}),[n,l]=y.useState({}),[r,a]=y.useState({}),o=y.useCallback(async r=>{if(r&&!n[r]){if(e[r])return e[r];l(e=>({...e,[r]:!0})),a(e=>({...e,[r]:null}));try{const e=await we(r),n=e?.result||[];return t(e=>({...e,[r]:n})),n}catch(o){return console.error("Error loading variants:",o),a(e=>({...e,[r]:o.message})),[]}finally{l(e=>({...e,[r]:!1}))}}},[e,n]),i=y.useCallback(t=>e[t]||[],[e]),s=y.useCallback(e=>n[e]||!1,[n]),c=y.useCallback(e=>r[e]||null,[r]),u=y.useCallback(e=>{t(t=>{const n={...t};return delete n[e],n}),l(t=>{const n={...t};return delete n[e],n}),a(t=>{const n={...t};return delete n[e],n})},[]),d=y.useCallback(async e=>(u(e),await o(e)),[u,o]),b=y.useCallback(async(e,n)=>{try{return await async function(e,t){try{return await ce({endpoint:`/assets/${e}/variants/${t}`,method:"DELETE",basePath:ge,useJWT:!0})}catch(n){throw fe(n)}}(e,n),t(t=>{const l=t[e]||[];return{...t,[e]:l.filter(e=>e.id!==n)}}),{success:!0}}catch(l){return console.error("Error deleting variant:",l),{success:!1,error:l.message}}},[]);return{loadVariants:o,getVariants:i,isLoading:s,getError:c,clearVariants:u,refreshVariants:d,removeVariant:b}}function Ce({isOpen:e=!1,onClose:t,title:n="",subtitle:l="",headerActions:r=null,footerHints:a=null,ariaLabel:o="Visor de archivo",children:i}){const s=y.useRef(null),c=y.useCallback(e=>{"Escape"===e.key&&(e.preventDefault(),t?.())},[t]);return y.useEffect(()=>{if(e)return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[e,c]),y.useEffect(()=>(document.body.style.overflow=e?"hidden":"",()=>{document.body.style.overflow=""}),[e]),e?F.jsxs("div",{className:"lb:fixed lb:inset-0 lb:bg-black/95 lb:z-[10000] lb:flex lb:flex-col",role:"dialog","aria-modal":"true","aria-label":o,children:[F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between lb:px-4 lb:py-3 lb:bg-black/50 lb:backdrop-blur-sm",children:[F.jsxs("div",{className:"lb:flex-1 lb:min-w-0",children:[n&&F.jsx("h2",{className:"lb:text-white lb:font-medium lb:text-sm lb:truncate",children:n.includes(".")?n.split(".").slice(0,-1).join("."):n}),l&&F.jsx("p",{className:"lb:text-gray-400 lb:text-xs lb:mt-0.5 lb:truncate",children:l})]}),r&&F.jsx("div",{className:"lb:flex lb:items-center lb:gap-2 lb:mx-4",children:r}),F.jsx("button",{type:"button",onClick:t,className:"lb:w-10 lb:h-10 lb:flex lb:items-center lb:justify-center lb:rounded-lg lb:bg-white/10 lb:hover:bg-red-1000/80 lb:text-white lb:transition-colors","aria-label":"Cerrar visor (ESC)",title:"Cerrar (ESC)",children:F.jsx("svg",{className:"lb:w-6 lb:h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),F.jsx("div",{ref:s,className:"lb:flex-1 lb:overflow-hidden lb:flex lb:items-center lb:justify-center",onClick:e=>{e.target===s.current&&t?.()},children:i}),a&&F.jsx("div",{className:"lb:px-4 lb:py-2 lb:bg-black/50 lb:backdrop-blur-sm lb:text-center",children:F.jsx("p",{className:"lb:text-gray-400 lb:text-xs",children:a})})]}):null}function Se({isOpen:e=!1,src:t,title:n="",subtitle:l="",onClose:r}){const[a,o]=y.useState(!1),[i,s]=y.useState(!0),c=y.useRef(null);y.useEffect(()=>{e&&(o(!1),s(!0))},[e]);const u=y.useCallback(e=>{" "===e.key&&c.current&&(e.preventDefault(),c.current.paused?c.current.play():c.current.pause())},[]);y.useEffect(()=>{if(e)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,u]);const d=F.jsxs("button",{type:"button",onClick:async()=>{if(t)try{const e=await fetch(t,{mode:"cors"});if(!e.ok)throw new Error(`HTTP ${e.status}`);const l=await e.blob(),r=URL.createObjectURL(l),a=document.createElement("a");a.href=r,a.download=n||"video",a.style.display="none",document.body.appendChild(a),a.click(),setTimeout(()=>{URL.revokeObjectURL(r),document.body.removeChild(a)},100)}catch{window.open(t,"_blank")}},className:"lb:flex lb:items-center lb:gap-2 lb:px-3 lb:py-1.5 lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:text-sm lb:transition-colors","aria-label":"Descargar video",title:"Descargar video",children:[F.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),F.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Descargar"})]}),b=F.jsxs("span",{children:[F.jsxs("span",{className:"lb:hidden lb:sm:inline",children:[F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"Espacio"})," ","para pausar/reproducir •"," "]}),F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]});return F.jsx(Ce,{isOpen:e,onClose:r,title:n,subtitle:l,ariaLabel:"Visor de video",headerActions:d,footerHints:b,children:a?F.jsxs("div",{className:"lb:text-center lb:text-white",children:[F.jsx("svg",{className:"lb:w-16 lb:h-16 lb:mx-auto lb:mb-4 lb:text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),F.jsx("p",{className:"lb:text-lg lb:font-medium",children:"No se puede reproducir el video"}),F.jsx("p",{className:"lb:text-gray-400 lb:text-sm lb:mt-2",children:n})]}):F.jsxs("div",{className:"lb:relative lb:w-full lb:max-w-5xl lb:max-h-full lb:flex lb:items-center lb:justify-center lb:px-4",children:[i&&F.jsx("div",{className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center",children:F.jsx("div",{className:"lb:w-12 lb:h-12 lb:border-4 lb:border-white/20 lb:border-t-white lb:rounded-full lb:animate-spin"})}),F.jsx("video",{ref:c,src:t,className:"lb:max-w-full lb:max-h-[calc(100vh-140px)] lb:h-full lb:w-full lb:rounded-lg",controls:!0,autoPlay:!0,preload:"metadata",onCanPlay:()=>s(!1),onError:()=>{o(!0),s(!1)},children:"Tu navegador no soporta la reproduccion de video."})]})})}function je({isOpen:e=!1,src:t,title:n="",subtitle:l="",onClose:r}){const[a,o]=y.useState(!1),[i,s]=y.useState(!1),[c,u]=y.useState(0),[d,b]=y.useState(0),m=y.useRef(null);y.useEffect(()=>{e&&(s(!1),o(!1),u(0),b(0))},[e]);const h=y.useCallback(()=>{m.current&&(m.current.paused?m.current.play():m.current.pause())},[]),p=y.useCallback(e=>{" "===e.key&&(e.preventDefault(),h())},[h]);y.useEffect(()=>{if(e)return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[e,p]);const f=e=>{if(!e||isNaN(e))return"0:00";return`${Math.floor(e/60)}:${Math.floor(e%60).toString().padStart(2,"0")}`},g=F.jsxs("button",{type:"button",onClick:async()=>{if(t)try{const e=await fetch(t,{mode:"cors"});if(!e.ok)throw new Error(`HTTP ${e.status}`);const l=await e.blob(),r=URL.createObjectURL(l),a=document.createElement("a");a.href=r,a.download=n||"audio",a.style.display="none",document.body.appendChild(a),a.click(),setTimeout(()=>{URL.revokeObjectURL(r),document.body.removeChild(a)},100)}catch{window.open(t,"_blank")}},className:"lb:flex lb:items-center lb:gap-2 lb:px-3 lb:py-1.5 lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:text-sm lb:transition-colors","aria-label":"Descargar audio",title:"Descargar audio",children:[F.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),F.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Descargar"})]}),v=F.jsxs("span",{children:[F.jsxs("span",{className:"lb:hidden lb:sm:inline",children:[F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"Espacio"})," ","para pausar/reproducir •"," "]}),F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]});return F.jsx(Ce,{isOpen:e,onClose:r,title:n,subtitle:l,ariaLabel:"Visor de audio",headerActions:g,footerHints:v,children:i?F.jsxs("div",{className:"lb:text-center lb:text-white",children:[F.jsx("svg",{className:"lb:w-16 lb:h-16 lb:mx-auto lb:mb-4 lb:text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),F.jsx("p",{className:"lb:text-lg lb:font-medium",children:"No se puede reproducir el audio"}),F.jsx("p",{className:"lb:text-gray-400 lb:text-sm lb:mt-2",children:n})]}):F.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-8 lb:w-full lb:max-w-md lb:px-4",children:[F.jsxs("div",{className:"lb:relative",children:[F.jsx("div",{className:"lb:w-40 lb:h-40 lb:flex lb:items-center lb:justify-center lb:rounded-full lb:bg-linear-to-br lb:from-purple-600/30 lb:to-blue-600/30 lb:border-2 lb:border-white/10 "+(a?"lb:animate-pulse":""),children:F.jsx("span",{className:"icon icon-audio lb:text-white lb:w-16 lb:h-16"})}),F.jsx("button",{type:"button",onClick:h,className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center lb:rounded-full lb:bg-black/0 lb:hover:bg-white/10 lb:transition-colors lb:cursor-pointer","aria-label":a?"Pausar":"Reproducir",children:F.jsx("div",{className:"lb:w-14 lb:h-14 lb:rounded-full lb:bg-white/90 lb:flex lb:items-center lb:justify-center lb:shadow-lg",children:F.jsx("span",{className:`icon ${a?"icon-pause":"icon-play"} icon--lg lb:text-gray-800 ${a?"":"lb:ml-0.5"}`})})})]}),F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-3 lb:text-white lb:text-sm",children:[F.jsx("span",{className:"lb:font-mono lb:min-w-[3ch] lb:text-right",children:f(d)}),F.jsx("div",{className:"lb:w-64 lb:h-2 lb:bg-white/20 lb:rounded-full lb:cursor-pointer lb:relative",onClick:e=>{if(!m.current||!c)return;const t=e.currentTarget.getBoundingClientRect(),n=(e.clientX-t.left)/t.width;m.current.currentTime=n*c},role:"slider","aria-label":"Progreso de audio","aria-valuenow":d,"aria-valuemin":0,"aria-valuemax":c,tabIndex:0,children:F.jsx("div",{className:"lb:h-full lb:bg-purple-500 lb:rounded-full lb:transition-all lb:duration-100",style:{width:c>0?d/c*100+"%":"0%"}})}),F.jsx("span",{className:"lb:font-mono lb:min-w-[3ch] lb:text-gray-400",children:f(c)})]}),F.jsx("audio",{ref:m,src:t,onPlay:()=>o(!0),onPause:()=>o(!1),onTimeUpdate:()=>b(m.current?.currentTime||0),onLoadedMetadata:()=>u(m.current?.duration||0),onEnded:()=>{o(!1),b(0)},onError:()=>s(!0),preload:"metadata"})]})})}function Ne({isOpen:e=!1,src:t,title:n="",subtitle:l="",onClose:r}){const[a,o]=y.useState(!0),[i,s]=y.useState(!1),[c,u]=y.useState(null),d=y.useRef(null);y.useEffect(()=>{if(!e||!t)return;let n=!1;return o(!0),s(!1),fetch(t).then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.blob()}).then(e=>{if(n)return;d.current&&URL.revokeObjectURL(d.current);const t=URL.createObjectURL(e);d.current=t,u(t)}).catch(()=>{n||(s(!0),o(!1))}),()=>{n=!0}},[t,e]),y.useEffect(()=>()=>{d.current&&(URL.revokeObjectURL(d.current),d.current=null)},[]);const b=()=>{if(!t)return;const e=document.createElement("a");e.href=t,e.download=n||"document.pdf",e.target="_blank",document.body.appendChild(e),e.click(),document.body.removeChild(e)},m=F.jsxs("button",{type:"button",onClick:b,className:"lb:flex lb:items-center lb:gap-2 lb:px-3 lb:py-1.5 lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:text-sm lb:transition-colors","aria-label":"Abrir PDF en nueva pestaña",title:"Abrir PDF en nueva pestaña",children:[F.jsx("span",{className:"icon icon-arrow-left-white lb:rotate-40 lb:me-0 lb:pe-0 icon--sm"}),F.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Abrir en nueva pestaña"})]}),h=F.jsxs("span",{children:[F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]});return F.jsx(Ce,{isOpen:e,onClose:r,title:n,subtitle:l,ariaLabel:"Visor de PDF",headerActions:m,footerHints:h,children:i?F.jsxs("div",{className:"lb:text-center lb:text-white",children:[F.jsx("svg",{className:"lb:w-16 lb:h-16 lb:mx-auto lb:mb-4 lb:text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),F.jsx("p",{className:"lb:text-lg lb:font-medium",children:"No se puede mostrar el PDF"}),F.jsx("p",{className:"lb:text-gray-400 lb:text-sm lb:mt-2",children:n}),F.jsx("button",{type:"button",onClick:b,className:"lb:mt-4 lb:px-6 lb:py-2.5 lb:bg-white lb:text-gray-900 lb:rounded-lg lb:font-medium lb:text-sm lb:hover:bg-gray-100 lb:transition-colors",children:"Descargar PDF"})]}):F.jsxs("div",{className:"lb:relative lb:w-full lb:h-full lb:px-4 lb:py-2",children:[a&&F.jsx("div",{className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center lb:z-10",children:F.jsx("div",{className:"lb:w-12 lb:h-12 lb:border-4 lb:border-white/20 lb:border-t-white lb:rounded-full lb:animate-spin"})}),c&&F.jsx("iframe",{src:c,title:n||"PDF Viewer",className:"lb:w-full lb:h-full lb:rounded-lg lb:bg-white",onLoad:()=>o(!1),onError:()=>{s(!0),o(!1)}})]})})}const Ee={"application/pdf":{symbol:"icon-doc-pdf",label:"PDF",color:"#dc2626"},"application/msword":{symbol:"icon-doc-word",label:"DOC",color:"#2563eb"},"application/vnd.openxmlformats-officedocument.wordprocessingml.document":{symbol:"icon-doc-word",label:"DOCX",color:"#2563eb"},"application/vnd.ms-excel":{symbol:"icon-doc-xls",label:"XLS",color:"#16a34a"},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":{symbol:"icon-doc-xls",label:"XLSX",color:"#16a34a"},"application/vnd.ms-powerpoint":{symbol:"icon-doc-ppt",label:"PPT",color:"#ea580c"},"application/vnd.openxmlformats-officedocument.presentationml.presentation":{symbol:"icon-doc-ppt",label:"PPTX",color:"#ea580c"},"text/plain":{symbol:"icon-doc-text",label:"TXT",color:"#6b7280"},"text/csv":{symbol:"icon-doc-report",label:"CSV",color:"#16a34a"},"audio/mp3":{symbol:"icon-support-person",label:"MP3",color:"#0891b2"},"audio/mpeg":{symbol:"icon-support-person",label:"MP3",color:"#0891b2"},"audio/wav":{symbol:"icon-support-person",label:"WAV",color:"#0891b2"},"audio/ogg":{symbol:"icon-support-person",label:"OGG",color:"#0891b2"},"video/mp4":{symbol:"icon-video",label:"MP4",color:"#7c3aed"},"video/x-msvideo":{symbol:"icon-video",label:"AVI",color:"#7c3aed"},"video/x-matroska":{symbol:"icon-video",label:"MKV",color:"#7c3aed"},default:{symbol:"icon-clip",label:"FILE",color:"#6b7280"}},$e={video:{symbol:"🎬",label:"VIDEO",color:"#7c3aed"},audio:{symbol:"🎵",label:"AUDIO",color:"#0891b2"},document:{symbol:"📄",label:"DOC",color:"#6b7280"},image:{symbol:"🖼️",label:"IMG",color:"#0ea5e9"}};function _e(e,t){return Ee[e]?Ee[e]:t&&$e[t]?$e[t]:e?.startsWith("video/")?$e.video:e?.startsWith("audio/")?$e.audio:e?.startsWith("image/")?$e.image:Ee.default}function Te(e){if(!e||0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(1024));return Math.round(e/Math.pow(1024,t)*100)/100+" "+["Bytes","KB","MB","GB"][t]}function ze({file:e,mimeType:t,category:n}){const l=_e(t,n),r=e?.name||"archivo",a=Te(e?.size);return F.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:justify-center lb:min-h-50",children:[F.jsx("div",{className:"lb:w-24 lb:h-24 lb:flex lb:items-center lb:justify-center lb:bg-gray-100 lb:rounded-xl lb:mb-4",children:F.jsx("span",{className:`icon ${l.symbol} lb:h-[55%] lb:w-[55%] lb:max-h-50 lb:max-w-50`,"aria-hidden":"true"})}),F.jsx("p",{className:"lb:text-sm lb:font-medium lb:text-gray-800 lb:text-center lb:max-w-full lb:truncate lb:px-4",children:r}),F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2 lb:mt-3",children:[F.jsx("span",{className:"lb:text-xs lb:text-gray-500",children:a}),F.jsx("span",{className:"lb:text-xs lb:font-bold lb:uppercase lb:px-2 lb:py-0.5 lb:rounded",style:{backgroundColor:l.color,color:"white"},children:l.label})]})]})}function Le({isOpen:e=!1,src:t,title:n="",subtitle:l="",mimeType:r="",fileSize:a=0,onClose:o}){const i=_e(r),s=F.jsxs("span",{children:[F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]});return F.jsx(Ce,{isOpen:e,onClose:o,title:n,subtitle:l,ariaLabel:"Visor de documento",footerHints:s,children:F.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-6 lb:text-center lb:px-4",children:[F.jsx("div",{className:"lb:w-32 lb:h-32 lb:flex lb:items-center lb:justify-center lb:bg-white/5 lb:rounded-2xl lb:border lb:border-white/10",children:F.jsx("span",{className:`icon ${i.symbol}-white lb:min-w-16 lb:min-h-16`,"aria-hidden":"true"})}),F.jsx("span",{className:"lb:text-sm lb:font-bold lb:uppercase lb:px-4 lb:py-1.5 lb:rounded-full",style:{backgroundColor:i.color,color:"white"},children:i.label}),F.jsxs("div",{children:[F.jsx("p",{className:"lb:text-white lb:font-medium lb:text-lg lb:max-w-md lb:truncate",children:n}),a>0&&F.jsx("p",{className:"lb:text-gray-400 lb:text-sm lb:mt-1",children:Te(a)})]}),F.jsx("p",{className:"lb:text-gray-500 lb:text-sm",children:"Este tipo de archivo no se puede previsualizar"}),F.jsxs("button",{type:"button",onClick:async()=>{if(t)try{const e=await fetch(t,{mode:"cors"});if(!e.ok)throw new Error(`HTTP ${e.status}`);const l=await e.blob(),r=URL.createObjectURL(l),a=document.createElement("a");a.href=r,a.download=n||"document",a.style.display="none",document.body.appendChild(a),a.click(),setTimeout(()=>{URL.revokeObjectURL(r),document.body.removeChild(a)},100)}catch{window.open(t,"_blank")}},className:"lb:flex lb:items-center lb:gap-2 lb:px-8 lb:py-3 lb:bg-white lb:text-gray-900 lb:rounded-lg lb:font-medium lb:text-sm lb:hover:bg-gray-100 lb:transition-colors lb:shadow-lg","aria-label":"Descargar archivo",children:[F.jsx("svg",{className:"lb:w-5 lb:h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),"Descargar archivo"]})]})})}const Ae=2097152;function Me({isOpen:e=!1,src:t,title:n="",subtitle:l="",mimeType:r="",fileSize:a=0,onClose:o}){const[i,s]=y.useState(!0),[c,u]=y.useState(!1),[d,b]=y.useState(""),[m,h]=y.useState(!1);y.useEffect(()=>{if(!e||!t)return;let l=!1;return s(!0),u(!1),b(""),h(!1),fetch(t).then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.blob()}).then(e=>{if(l)return;const t=e.size>Ae?e.slice(0,Ae):e;return e.size>Ae&&h(!0),t.text()}).then(e=>{if(!l){if("application/json"===r||n.endsWith(".json"))try{const t=JSON.parse(e);e=JSON.stringify(t,null,2)}catch{}b(e),s(!1)}}).catch(()=>{l||(u(!0),s(!1))}),()=>{l=!0}},[t,e,r,n]);const p=async()=>{if(t)try{const e=await fetch(t,{mode:"cors"});if(!e.ok)throw new Error(`HTTP ${e.status}`);const l=await e.blob(),r=URL.createObjectURL(l),a=document.createElement("a");a.href=r,a.download=n||"file.txt",a.style.display="none",document.body.appendChild(a),a.click(),setTimeout(()=>{URL.revokeObjectURL(r),document.body.removeChild(a)},100)}catch{window.open(t,"_blank")}},f=d?d.split("\n").length:0,g=F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2",children:[f>0&&F.jsxs("span",{className:"lb:text-gray-400 lb:text-xs",children:[f," ",1===f?"linea":"lineas"]}),F.jsxs("button",{type:"button",onClick:p,className:"lb:flex lb:items-center lb:gap-2 lb:px-3 lb:py-1.5 lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:text-sm lb:transition-colors","aria-label":"Descargar archivo",title:"Descargar archivo",children:[F.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),F.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Descargar"})]})]}),v=F.jsxs("span",{children:[F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]});return F.jsx(Ce,{isOpen:e,onClose:o,title:n,subtitle:l,ariaLabel:"Visor de texto",headerActions:g,footerHints:v,children:c?F.jsxs("div",{className:"lb:text-center lb:text-white",children:[F.jsx("svg",{className:"lb:w-16 lb:h-16 lb:mx-auto lb:mb-4 lb:text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),F.jsx("p",{className:"lb:text-lg lb:font-medium",children:"No se puede mostrar el archivo"}),F.jsx("p",{className:"lb:text-gray-400 lb:text-sm lb:mt-2",children:n}),F.jsx("button",{type:"button",onClick:p,className:"lb:mt-4 lb:px-6 lb:py-2.5 lb:bg-white lb:text-gray-900 lb:rounded-lg lb:font-medium lb:text-sm lb:hover:bg-gray-100 lb:transition-colors",children:"Descargar archivo"})]}):i?F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("div",{className:"lb:w-12 lb:h-12 lb:border-4 lb:border-white/20 lb:border-t-white lb:rounded-full lb:animate-spin"})}):F.jsxs("div",{className:"lb:relative lb:w-full lb:h-full lb:px-4 lb:py-2 lb:overflow-hidden lb:flex lb:flex-col",children:[m&&F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2 lb:px-4 lb:py-2 lb:bg-yellow-900/50 lb:border lb:border-yellow-700/50 lb:rounded-lg lb:mb-2 lb:shrink-0",children:[F.jsx("svg",{className:"lb:w-4 lb:h-4 lb:text-yellow-400 lb:shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01"})}),F.jsx("span",{className:"lb:text-yellow-300 lb:text-xs",children:"Archivo truncado (mostrando primeros 2MB). Descarga el archivo completo para ver todo el contenido."})]}),F.jsx("div",{className:"lb:flex-1 lb:overflow-auto lb:rounded-lg lb:bg-gray-900/80 lb:border lb:border-white/10",children:F.jsx("pre",{className:"lb:p-4 lb:text-sm lb:text-gray-200 lb:font-mono lb:whitespace-pre-wrap lb:break-words lb:leading-relaxed lb:m-0",children:d})})]})})}function Pe({src:e,alt:t="Imagen",title:n="",subtitle:l="",onClose:r,isOpen:a=!1}){const[o,i]=y.useState(1),[s,c]=y.useState({x:0,y:0}),[u,d]=y.useState(!1),[b,m]=y.useState(!1),[h,p]=y.useState({x:0,y:0}),[f,g]=y.useState(!1),[v,x]=y.useState(!1),w=y.useRef(null),k=y.useRef(null);y.useEffect(()=>{a&&(i(1),c({x:0,y:0}),g(!1),x(!1))},[a]);const C=y.useCallback(()=>{i(e=>Math.min(e+.25,5)),c({x:0,y:0})},[]),S=y.useCallback(()=>{i(e=>Math.max(e-.25,.25)),c({x:0,y:0})},[]),j=y.useCallback(()=>{i(1),c({x:0,y:0})},[]),N=y.useCallback(()=>{i(1),c({x:0,y:0})},[]),E=y.useCallback(e=>{if((e.ctrlKey||e.metaKey)&&("+"===e.key||"="===e.key))return e.preventDefault(),void C();if((e.ctrlKey||e.metaKey)&&"-"===e.key)return e.preventDefault(),void S();if((e.ctrlKey||e.metaKey)&&"0"===e.key)return e.preventDefault(),void j();if(o>1){const t=50;switch(e.key){case"ArrowUp":e.preventDefault(),c(e=>({...e,y:e.y+t}));break;case"ArrowDown":e.preventDefault(),c(e=>({...e,y:e.y-t}));break;case"ArrowLeft":e.preventDefault(),c(e=>({...e,x:e.x+t}));break;case"ArrowRight":e.preventDefault(),c(e=>({...e,x:e.x-t}))}}},[C,S,j,o]),$=y.useCallback(e=>{(e.ctrlKey||e.metaKey)&&(e.preventDefault(),e.deltaY<0?C():S())},[C,S]),_=y.useCallback(e=>{o>1&&0===e.button&&(e.preventDefault(),d(!0),m(!1),p({x:e.clientX-s.x,y:e.clientY-s.y}))},[o,s]),T=y.useCallback(e=>{u&&(m(!0),c({x:e.clientX-h.x,y:e.clientY-h.y}))},[u,h]),z=y.useCallback(()=>{d(!1)},[]),L=y.useCallback(e=>{e.stopPropagation(),1!==o||b||(i(2),c({x:0,y:0})),m(!1)},[o,b]),A=y.useCallback(e=>{e.stopPropagation(),1===o?(i(2),c({x:0,y:0})):j()},[o,j]);y.useEffect(()=>{if(!a)return;document.addEventListener("keydown",E),document.addEventListener("mouseup",z),document.addEventListener("mousemove",T);const e=e=>{!e.ctrlKey&&!e.metaKey||"+"!==e.key&&"-"!==e.key&&"="!==e.key&&"0"!==e.key||e.preventDefault()};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",E),document.removeEventListener("mouseup",z),document.removeEventListener("mousemove",T),document.removeEventListener("keydown",e)}},[a,E,z,T]);const M=Math.round(100*o),P=F.jsxs(F.Fragment,{children:[F.jsx("button",{type:"button",onClick:S,disabled:o<=.25,className:"lb:w-8 lb:h-8 lb:flex lb:items-center lb:justify-center lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:disabled:opacity-30 lb:disabled:cursor-not-allowed lb:transition-colors","aria-label":"Reducir zoom",title:"Reducir zoom (Ctrl -)",children:F.jsx("svg",{className:"lb:w-5 lb:h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})}),F.jsxs("div",{className:"lb:w-20 lb:text-center lb:text-white lb:text-sm lb:font-medium lb:bg-white/10 lb:rounded-lg lb:px-2 lb:py-1.5 lb:cursor-pointer lb:hover:bg-white/20 lb:transition-colors",onClick:j,title:"Click para restablecer zoom",role:"button",tabIndex:0,onKeyDown:e=>"Enter"===e.key&&j(),children:[M,"%"]}),F.jsx("button",{type:"button",onClick:C,disabled:o>=5,className:"lb:w-8 lb:h-8 lb:flex lb:items-center lb:justify-center lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:disabled:opacity-30 lb:disabled:cursor-not-allowed lb:transition-colors","aria-label":"Aumentar zoom",title:"Aumentar zoom (Ctrl +)",children:F.jsx("svg",{className:"lb:w-5 lb:h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),F.jsx("button",{type:"button",onClick:N,className:"lb:w-8 lb:h-8 lb:flex lb:items-center lb:justify-center lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:transition-colors lb:ml-2","aria-label":"Ajustar a pantalla",title:"Ajustar a pantalla (Ctrl 0)",children:F.jsx("svg",{className:"lb:w-5 lb:h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})})]}),I=F.jsxs(F.Fragment,{children:[F.jsxs("span",{className:"lb:hidden lb:sm:inline",children:[F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"Ctrl"})," ","+ rueda para zoom •"," ",F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"Ctrl"})," ","+"," ",F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"+"})," ","/"," ",F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"-"})," ","zoom • Click para zoom • Doble click para restablecer • Flechas para mover •"," ",F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]}),F.jsx("span",{className:"lb:sm:hidden",children:"Click para zoom • Doble click para restablecer • ESC para cerrar"})]});return F.jsx(Ce,{isOpen:a,onClose:r,title:n,subtitle:l,ariaLabel:"Visor de imagen",headerActions:P,footerHints:I,children:F.jsxs("div",{ref:w,className:`lb:w-full lb:h-full lb:overflow-hidden lb:flex lb:items-center lb:justify-center ${o>1?"lb:cursor-grab":"lb:cursor-zoom-in"} ${u?"lb:cursor-grabbing":""}`,onClick:e=>{e.target===w.current&&r?.()},onWheel:$,onMouseDown:_,children:[!f&&!v&&F.jsx("div",{className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center",children:F.jsx("div",{className:"lb:w-12 lb:h-12 lb:border-4 lb:border-white/20 lb:border-t-white lb:rounded-full lb:animate-spin"})}),v&&F.jsxs("div",{className:"lb:text-center lb:text-white",children:[F.jsx("svg",{className:"lb:w-16 lb:h-16 lb:mx-auto lb:mb-4 lb:text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),F.jsx("p",{className:"lb:text-lg lb:font-medium",children:"Error al cargar la imagen"}),F.jsx("p",{className:"lb:text-gray-400 lb:text-sm lb:mt-2",children:"No se pudo cargar la imagen"})]}),F.jsx("img",{ref:k,src:e,alt:t,className:"lb:max-w-full lb:max-h-full lb:object-contain lb:transition-opacity lb:duration-200 lb:select-none "+(f?"lb:opacity-100":"lb:opacity-0"),style:{transform:`scale(${o}) translate(${s.x/o}px, ${s.y/o}px)`,transition:u?"none":"transform 0.2s ease-out"},onLoad:()=>g(!0),onError:()=>x(!0),onClick:L,onDoubleClick:A,draggable:!1})]})})}function Ie({image:e,isOpen:t,onClose:n,onSelect:l,onDelete:r,onCrop:a,onVariantDeleted:o,allowedActions:i={select:!0,download:!0,copy:!0,delete:!0,crop:!0}}){const{loadVariants:s,getVariants:c,isLoading:u,getError:d,removeVariant:b}=ke(),m=window.limboCore?.accessibilityManager,[h,p]=v.useState(null),[f,g]=v.useState(null),[x,w]=y.useState(null),[k,C]=y.useState(null),[S,j]=y.useState({}),[N,E]=y.useState({}),$=(window.limboCore?.config?.getGlobal()||{}).interaction||{allowSelection:!1,allowCropping:!0},_=$.allowSelection&&i.select&&l,T=$.allowCropping&&i.crop&&a,z=i.download,L=i.copy,A=i.delete,[M,P]=v.useState(new Set),[I,D]=v.useState(new Set),[O,R]=y.useState({}),[U,B]=y.useState(!1),W=y.useRef(null),q=y.useRef(null),V=y.useCallback(e=>{if("Escape"===e.key){if(x)return;e.preventDefault(),n?.()}if("Tab"===e.key&&W.current){const t=W.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),n=t[0],l=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),l?.focus()):e.shiftKey||document.activeElement!==l||(e.preventDefault(),n?.focus())}},[n,x]);y.useEffect(()=>{if(t)return q.current?.focus(),document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[t,V]);const H=v.useMemo(()=>e?.variants||[],[e?.variants]),K=c(e?.id),G=(H.length>0?H:K).filter(e=>!I.has(e.id)),Q=0===H.length&&u(e?.id),X=0===H.length?d(e?.id):null;y.useEffect(()=>{!t||!e?.id||e?.variants&&0!==e.variants.length||s(e.id)},[t,e?.id,e?.variants,s]),v.useEffect(()=>{t&&(P(new Set),D(new Set),R({}),j({}),E({}))},[t]),v.useEffect(()=>{if(t&&I.size>0&&0===G.length){const t=setTimeout(()=>{document.dispatchEvent(new CustomEvent("limbo:variantsCleared",{detail:{assetId:e?.id}})),n?.()},1200);return()=>clearTimeout(t)}},[t,I.size,G.length,e?.id,n]);const Z=G.map(e=>e.id).join(",");y.useEffect(()=>{if(!t||!e?.url)return;let n=!1;return(async()=>{const t={},l={},r={},a="original",o=ne(e.url);if(o?(l[a]=!0,t[a]=!1,r.original=te(e.url)):(t[a]=!0,l[a]=!1),G.forEach(e=>{ne(e.url)?(l[e.id]=!0,t[e.id]=!1,r[e.id]=te(e.url)):(t[e.id]=!0,l[e.id]=!1)}),j(t),E(l),Object.keys(r).length>0&&R(r),!o){const t=await ee(e.url);if(n)return;t&&(R(e=>({...e,original:t})),j(e=>({...e,[a]:!1})),E(e=>({...e,[a]:!0})))}if(G.length>0){const e=G.filter(e=>!ne(e.url));if(e.length>0){const t=e.map(e=>e.url),l=await le(t,4);if(n)return;const r={},a={},o={};e.forEach((e,t)=>{l[t]&&(r[e.id]=l[t],a[e.id]=!1,o[e.id]=!0)}),Object.keys(r).length>0&&(R(e=>({...e,...r})),j(e=>({...e,...a})),E(e=>({...e,...o})))}}})(),()=>{n=!0}},[t,e?.url,Z]);if(!t)return null;const re=e=>{m?.announce(`Abriendo visor de imagen: ${e.name}`);const t=O[e.id]||te(e.url);w({src:t,title:e.name||e.filename||"Recorte",subtitle:`${e.width}×${e.height} · ${Math.round((e.file_size||0)/1024)}KB`})},ae=()=>{m?.announce(`Abriendo visor de imagen: ${e.filename}`);const t=O.original||te(e.url);w({src:t,title:e.filename||"Original",subtitle:`${e.width}×${e.height} · ${Math.round((e.file_size||0)/1024)}KB`})},oe=async t=>{if(window.confirm(`¿Estás seguro de que deseas eliminar el recorte "${t.name||t.filename}"?`)){B(!0),m?.announce(`Eliminando recorte ${t.name||t.filename}`);try{const n=await b(e.id,t.id);n.success?(D(e=>new Set([...e,t.id])),t.url&&(e=>{if(!e)return;const t=Y.get(e);if(t){try{URL.revokeObjectURL(t.blobUrl)}catch{}Y.delete(e)}J.delete(e)})(t.url),p("Recorte eliminado correctamente"),g("success"),m?.announce("Recorte eliminado correctamente"),o?.(),document.dispatchEvent(new CustomEvent("limbo:variantDeleted",{detail:{assetId:e?.id,variantId:t.id}})),setTimeout(()=>{p(null),g(null)},3e3)):(p(`Error al eliminar recorte: ${n.error}`),g("error"),m?.announceError(`Error al eliminar recorte: ${n.error}`),setTimeout(()=>{p(null),g(null)},5e3))}finally{B(!1)}}},ie=[{...e,isOriginal:!0},...G.map(e=>({...e,isOriginal:!1}))];return F.jsxs("div",{className:"lb:fixed lb:inset-0 lb:bg-black/85 lb:flex lb:items-center lb:justify-center lb:z-[1000] lb:p-4",onClick:()=>{x||n?.()},role:"dialog","aria-modal":"true","aria-labelledby":"variants-modal-title","aria-describedby":"variants-modal-description",children:[F.jsxs("div",{ref:W,className:"lb:relative lb:bg-white lb:rounded-xl lb:max-w-[95vw] lb:max-h-[90vh] lb:overflow-hidden lb:shadow-2xl lb:flex lb:flex-col lb:w-[900px]",onClick:e=>e.stopPropagation(),children:[F.jsxs("div",{className:"lb:px-5 lb:py-4 lb:border-b lb:border-gray-200 lb:flex lb:justify-between lb:items-center lb:bg-gray-50",children:[F.jsxs("div",{className:"lb:flex-1 lb:min-w-0 lb:pr-4",children:[F.jsx("h2",{id:"variants-modal-title",className:"lb:m-0 lb:text-lg lb:font-semibold lb:text-gray-900 lb:truncate",children:e?.filename}),F.jsxs("p",{id:"variants-modal-description",className:"lb:text-sm lb:text-gray-500 lb:mt-1",children:["Imagen original y ",G.length," recorte",1!==G.length?"s":""," disponible",1!==G.length?"s":""]})]}),F.jsx("button",{ref:q,className:"lb:w-10 lb:h-10 lb:flex lb:items-center lb:justify-center lb:rounded-lg lb:bg-gray-100 lb:hover:bg-red-200 lb:text-gray-500 lb:hover:text-red-1000 lb:transition-colors lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400",onClick:n,"aria-label":"Cerrar modal (ESC)",title:"Cerrar (ESC)",children:F.jsx("svg",{className:"lb:w-5 lb:h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),U&&F.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-white/80 lb:flex lb:flex-col lb:items-center lb:justify-center lb:z-50 lb:rounded-xl",children:[F.jsx("div",{className:"lb:w-12 lb:h-12 lb:border-4 lb:border-gray-200 lb:border-t-brand-blue-800 lb:rounded-full lb:animate-spin lb:mb-4"}),F.jsx("p",{className:"lb:text-base lb:font-medium lb:text-gray-700",children:"Eliminando recorte..."})]}),h&&F.jsx("div",{className:"lb:mx-2 lb:mt-2 lb:px-2 lb:py-1.5 lb:rounded lb:text-xs "+("success"===f?"lb:bg-green-50 lb:text-green-1000":"lb:bg-red-50 lb:text-red-1000"),role:"alert",children:h}),F.jsx("div",{className:"lb:p-5 lb:overflow-y-auto lb:flex-1 lb:bg-gray-50/50",children:Q?F.jsxs("div",{className:"lb:text-center lb:py-16 lb:text-gray-500",role:"status","aria-live":"polite",children:[F.jsx("div",{className:"lb:w-12 lb:h-12 lb:border-4 lb:border-gray-200 lb:border-t-brand-blue-800 lb:rounded-full lb:animate-spin lb:mx-auto lb:mb-4"}),F.jsx("p",{className:"lb:text-base",children:"Cargando variantes..."})]}):X?F.jsxs("div",{className:"lb:text-center lb:py-16 lb:text-red-1000",role:"alert",children:[F.jsx("svg",{className:"lb:w-12 lb:h-12 lb:mx-auto lb:mb-4 lb:text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),F.jsxs("p",{className:"lb:text-base lb:font-medium",children:["Error: ",X]}),F.jsx("button",{onClick:()=>s(e.id),className:"lb:mt-4 lb:text-sm lb:px-5 lb:py-2.5 lb:rounded-lg lb:bg-brand-blue-800 lb:text-white lb:hover:bg-brand-blue-1000 lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400 lb:focus:ring-offset-2",children:"Reintentar"})]}):0===G.length?F.jsxs("div",{className:"lb:text-center lb:py-16 lb:text-gray-500",children:[F.jsx("svg",{className:"lb:w-12 lb:h-12 lb:mx-auto lb:mb-4 lb:text-gray-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),F.jsx("p",{className:"lb:text-base",children:"No hay recortes disponibles"})]}):F.jsx("div",{className:"lb:grid lb:grid-cols-2 lb:lg:grid-cols-3 lb:gap-5",role:"list","aria-label":"Lista de imágenes",children:ie.map((t,o)=>{const i=t.isOriginal,s=!i&&M.has(t.id);t.url;const c=i?O.original||te(t.url):O[t.id]||te(t.url),u=i?"Original":t.name||t.filename||`Recorte ${o}`,d=i?e.width:t.width,b=i?e.height:t.height,h=i?e.file_size:t.file_size||0,p=i?"original":t.id,f=S[p]&&!s,g=N[p];return F.jsxs("article",{role:"listitem","aria-label":`${u} - ${d}×${b} píxeles`,className:`lb:rounded-xl lb:overflow-hidden lb:transition-all lb:shadow-sm lb:hover:shadow-lg ${i?"lb:ring-2 lb:ring-brand-blue-800 lb:ring-offset-2 lb:bg-white":"lb:border lb:border-gray-200 lb:bg-white lb:hover:border-brand-blue-400"} lb:focus-within:ring-2 lb:focus-within:ring-brand-blue-400`,children:[F.jsxs("button",{type:"button",title:_?"Click para seleccionar":"Click para ampliar con zoom",className:"lb:relative lb:w-full lb:cursor-pointer lb:aspect-square lb:flex lb:items-center lb:justify-center lb:overflow-hidden lb:bg-gray-100 lb:focus:outline-none lb:group",onClick:s?void 0:()=>{_?i?(l?.(e),n?.()):(t=>{const r={id:t.id,filename:`${e.filename}_${t.name}`,url:t.url,width:t.width,height:t.height,mime_type:`image/${t.format}`,file_size:t.file_size,upload_date:t.created_at,processing_status:"completed",is_variant:!0,parent_asset_id:e.id,variant_info:t};m?.announce(`Recorte seleccionado: ${t.name}`),l?.(r),n?.()})(t):i?ae():re(t)},"aria-label":_?`Seleccionar ${u}`:`Ver ${u} en tamaño completo con zoom`,disabled:s,children:[f&&!s&&F.jsx("div",{className:"lb:w-full lb:aspect-square lb:rounded lb:bg-neutral-gray-200 lb:animate-pulse lb:flex lb:items-center lb:justify-center lb:absolute lb:inset-0 lb:z-10",children:F.jsx("span",{className:"icon icon-spinner lb:w-8 lb:h-8 lb:animate-spin"})}),s?F.jsxs("div",{className:"lb:text-center lb:text-gray-400",children:[F.jsx("svg",{className:"lb:w-10 lb:h-10 lb:mx-auto lb:mb-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),F.jsx("span",{className:"lb:text-sm",children:"Error al cargar"})]}):F.jsxs(F.Fragment,{children:[F.jsx("img",{src:c,alt:`${u} - ${d}×${b}px`,loading:i?"eager":"lazy",onLoad:()=>{E(e=>e[p]?e:{...e,[p]:!0}),j(e=>e[p]?{...e,[p]:!1}:e)},onError:i?void 0:()=>{return e=t.id,void P(t=>new Set([...t,e]));var e},className:"lb:w-full lb:h-full lb:object-contain lb:p-3 lb:transition-all lb:duration-300 lb:group-hover:scale-105 "+(g?"lb:opacity-100":"lb:opacity-0")}),F.jsx("div",{className:"lb:absolute lb:inset-0 lb:bg-black/0 lb:group-hover:bg-black/10 lb:transition-colors lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"lb:opacity-0 lb:group-hover:opacity-100 lb:transition-opacity lb:bg-black/60 lb:text-white lb:px-3 lb:py-1.5 lb:rounded-full lb:text-xs lb:font-medium lb:flex lb:items-center lb:gap-1.5",children:_?F.jsxs(F.Fragment,{children:[F.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Seleccionar"]}):F.jsxs(F.Fragment,{children:[F.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM10 7v3m0 0v3m0-3h3m-3 0H7"})}),"Ampliar"]})})})]}),i&&F.jsx("span",{className:"lb:absolute lb:top-3 lb:left-3 lb:bg-brand-blue-800 lb:text-white lb:text-xs lb:font-bold lb:px-3 lb:py-1.5 lb:rounded-lg lb:shadow-lg lb:z-20",children:"ORIGINAL"})]}),F.jsxs("div",{className:"lb:px-4 lb:py-3 lb:border-t lb:border-gray-100 lb:bg-white",children:[F.jsx("h3",{className:"lb:text-sm lb:font-semibold lb:text-gray-900 lb:truncate lb:mb-2",title:u,children:u}),F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between",children:[F.jsxs("span",{className:"lb:text-xs lb:text-gray-500 lb:font-medium",children:[d,"×",b," ·"," ",Math.round(h/1024),"KB"]}),F.jsxs("div",{className:"lb:flex lb:gap-2",role:"group","aria-label":`Acciones para ${u}`,children:[i&&T&&F.jsx("button",{type:"button",className:"lb:w-8 lb:h-8 lb:rounded-lg lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:cursor-pointer lb:text-white lb:flex lb:items-center lb:justify-center lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400 lb:focus:ring-offset-1 lb:transition-colors lb:shadow-sm",onClick:t=>{t.stopPropagation(),a&&(m?.announce(`Abriendo herramienta de recorte para ${e.filename}`),a(e),n?.())},"aria-label":"Crear nuevo recorte",title:"Recortar",children:F.jsx("span",{className:"icon icon-scissors-white icon--sm"})}),L&&F.jsx("button",{type:"button",className:"lb:w-8 lb:h-8 lb:rounded-lg lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:cursor-pointer lb:text-white lb:flex lb:items-center lb:justify-center lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400 lb:focus:ring-offset-1 lb:transition-colors lb:shadow-sm",onClick:n=>{n.stopPropagation();(async(e,t,n)=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(t);else{const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),document.body.removeChild(e)}C(e),m?.announce(`URL de ${n} copiada al portapapeles`),setTimeout(()=>C(null),2e3)}catch(l){console.error("Error al copiar URL:",l),m?.announceError(`Error al copiar URL de ${n}. Inténtalo de nuevo.`)}})(i?"original":t.id,i?e.url||e.path:t.url,u)},"aria-label":k===(i?"original":t.id)?"¡Copiado!":`Copiar URL de ${u}`,title:k===(i?"original":t.id)?"¡Copiado!":"Copiar URL",children:F.jsx("span",{className:`icon ${k===(i?"original":t.id)?"icon-copied-white":"icon-copy-white"} icon--sm`})}),z&&F.jsx("button",{type:"button",className:"lb:w-8 lb:h-8 lb:rounded-lg lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:cursor-pointer lb:text-white lb:flex lb:items-center lb:justify-center lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400 lb:focus:ring-offset-1 lb:transition-colors lb:shadow-sm",onClick:n=>{n.stopPropagation(),i?(async()=>{const{downloadImage:t}=await Promise.resolve().then(()=>il);await t(e.url||e.path,e.filename||"limbo-image",{originalFormat:e.format,accessibilityManager:m})})():(async e=>{const{downloadImage:t}=await Promise.resolve().then(()=>il);await t(e.url,e.name||"limbo-variant",{originalFormat:e.format||e.output_format,accessibilityManager:m})})(t)},"aria-label":`Descargar ${u}`,title:"Descargar",children:F.jsx("span",{className:"icon icon-download-white icon--sm"})}),A&&(!i||r)&&F.jsx("button",{type:"button",className:"lb:w-8 lb:h-8 lb:rounded-lg lb:bg-red-1000 lb:hover:bg-red-800 lb:cursor-pointer lb:text-white lb:flex lb:items-center lb:justify-center lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-red-800 lb:focus:ring-offset-1 lb:transition-colors lb:shadow-sm",onClick:l=>{l.stopPropagation(),i?(async()=>{if(!r)return;window.confirm(`¿Estás seguro de que deseas eliminar "${e.filename}"? Esta acción también eliminará todos sus recortes.`)&&(m?.announce(`Eliminando imagen ${e.filename}`),await r(e.id),n?.())})():oe(t)},"aria-label":`Eliminar ${u}`,title:"Eliminar",children:F.jsx("span",{className:"icon icon-close-small-white icon--sm"})}),_&&F.jsx("button",{type:"button",className:"lb:w-8 lb:h-8 lb:cursor-pointer lb:rounded-lg lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:text-white lb:flex lb:items-center lb:justify-center lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400 lb:focus:ring-offset-1 lb:transition-colors lb:shadow-sm",onClick:e=>{e.stopPropagation(),i?ae():re(t)},"aria-label":`Ampliar ${u}`,title:"Ampliar",children:F.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM10 7v3m0 0v3m0-3h3m-3 0H7"})})})]})]})]})]},i?"original":t.id)})})})]}),F.jsx(Pe,{isOpen:!!x,src:x?.src||"",alt:x?.title||"Imagen",title:x?.title,subtitle:x?.subtitle,onClose:()=>w(null)})]})}const De="/api";let Oe={data:null,timestamp:0,pending:null};const Re=new Set;function Fe(){Oe.data=null,Oe.timestamp=0,Oe.pending=null,Re.forEach(e=>e())}async function Ue(e={}){return Oe.data&&Date.now()-Oe.timestamp<3e5?Oe.data:(Oe.pending||(Oe.pending=async function(e={}){try{const t={include_counts:"true",...e},n=`/folders?${new URLSearchParams(t).toString()}`;return function(e){if(!e?.success||!e?.data)return{folders:[],total:0};const t=(e.data.folders||[]).map(e=>({id:e.id,name:e.name,slug:e.slug,description:e.description,visibility:e.visibility||"public",sort_order:e.sort_order||0,assets_count:e.assets_count||0,created_at:e.created_at,updated_at:e.updated_at}));return{folders:t,total:e.data.total||t.length}}(await ce({endpoint:n,method:"GET",basePath:De,useJWT:!0}))}catch(t){throw fe(t)}}(e).then(e=>(Oe.data=e,Oe.timestamp=Date.now(),Oe.pending=null,e)).catch(e=>{throw Oe.pending=null,e})),Oe.pending)}function Be(e={}){const{autoFetch:t=!0,visibility:n=null,allowedSlugs:l=null,excludeSlugs:r=null}=e,[a,o]=y.useState([]),[i,s]=y.useState(!1),[c,u]=y.useState(null),[d,b]=y.useState(!1),m=y.useRef(null),h=y.useCallback(e=>{let t=[...e];return l&&l.length>0&&(t=t.filter(e=>l.includes(e.slug))),r&&r.length>0&&(t=t.filter(e=>!r.includes(e.slug))),t.sort((e,t)=>e.sort_order!==t.sort_order?e.sort_order-t.sort_order:e.name.localeCompare(t.name)),t},[l,r]),p=y.useCallback(async(e={})=>{s(!0),u(null);try{const t={...n&&{visibility:n},...e},l=await Ue(t),r=h(l.folders||[]);return o(r),r}catch(t){return u(t.message),[]}finally{s(!1)}},[n,h]),f=y.useCallback(()=>(Fe(),p()),[p]),g=y.useCallback(async e=>{b(!0),u(null);try{const t=await async function(e){try{return function(e){if(!e?.success||!e?.data)return{folder:null};const t=e.data;return{folder:{id:t.id,name:t.name,slug:t.slug,description:t.description,visibility:t.visibility||"public",sort_order:t.sort_order||0,assets_count:t.assets_count||0,created_at:t.created_at,updated_at:t.updated_at}}}(await ce({endpoint:"/folders",method:"POST",body:{name:e.name,...e.slug&&{slug:e.slug},...e.description&&{description:e.description},...e.visibility&&{visibility:e.visibility}},basePath:De,useJWT:!0}))}catch(c){throw fe(c)}}(e),n=t.folder;return n&&(Fe(),o(e=>{const t=[...e,n];return t.sort((e,t)=>e.sort_order!==t.sort_order?e.sort_order-t.sort_order:e.name.localeCompare(t.name)),t})),n}catch(t){return u(t.message),null}finally{b(!1)}},[]),v=y.useCallback(e=>a.find(t=>t.slug===e)||null,[a]),x=y.useCallback(e=>a.find(t=>t.id===e)||null,[a]);return m.current=p,y.useEffect(()=>{const e=()=>m.current?.();return Re.add(e),()=>Re.delete(e)},[]),y.useEffect(()=>{t&&p()},[t,p]),{folders:a,loading:i,error:c,creating:d,fetchFolders:p,create:g,refresh:f,findBySlug:v,findById:x,hasLoaded:!i&&a.length>=0}}function We({value:e=null,onChange:t,allowCreate:n=!0,placeholder:l="Sin carpeta",label:r=null,disabled:a=!1,className:o="",showAssetCount:i=!1,includeNoFolder:s=!0,allowedSlugs:c=null,excludeSlugs:u=null,mode:d="upload"}){const b=y.useId(),[m,h]=y.useState(!1),[p,f]=y.useState(""),[g,v]=y.useState(null),{folders:x,loading:w,error:k,creating:C,create:S,refresh:j}=Be({autoFetch:!0,allowedSlugs:c,excludeSlugs:u}),N=async e=>{if(e.preventDefault(),v(null),!p.trim())return void v("El nombre es requerido");const n=await S({name:p.trim()});n?(t?.(n),h(!1),f("")):v("Error al crear la carpeta")},E=()=>{h(!1),f(""),v(null)};if(m)return F.jsxs("div",{className:`limbo-folder-selector limbo-folder-selector--creating ${o}`,children:[r&&F.jsxs("label",{className:"limbo-filter-label lb:block lb:mb-1",children:[r," ",C&&F.jsx("span",{className:"limbo-filter-searching","aria-hidden":"true",children:F.jsx("span",{className:"icon icon-spinner lb:animate-spin lb:w-3 lb:h-3"})})]}),F.jsxs("form",{onSubmit:N,className:"lb:flex lb:gap-2 lb:items-center lb:flex-col",children:[F.jsx("div",{children:F.jsx("input",{type:"text",value:p,onChange:e=>f(e.target.value),placeholder:"Nombre de la carpeta...",className:"limbo-filter-input lb:flex-1",autoFocus:!0,disabled:C})}),F.jsxs("div",{className:"lb:flex lb:gap-2",children:[F.jsx("button",{type:"submit",disabled:C||!p.trim(),className:"limbo-btn limbo-btn--primary lb:px-3 lb:py-1.5 lb:text-sm lb:rounded lb:bg-brand-blue-1000 lb:text-white lb:border-0 lb:cursor-pointer disabled:lb:opacity-50 disabled:lb:cursor-not-allowed",children:C?"...":"Crear"}),F.jsx("button",{type:"button",onClick:E,disabled:C,className:"limbo-btn limbo-btn--ghost lb:px-2 lb:py-1.5 lb:text-sm lb:rounded lb:bg-transparent lb:border lb:border-gray-300 lb:cursor-pointer",children:"Cancelar"})]})]}),g&&F.jsx("p",{className:"lb:text-red-600 lb:text-xs lb:mt-1",children:g})]});const $="filter"===d?"Todas las carpetas":l;return F.jsxs("div",{className:`limbo-folder-selector ${o}`,children:[r&&F.jsxs("label",{htmlFor:b,className:"limbo-filter-label lb:block lb:mb-1",children:[r,w&&F.jsx("span",{className:"limbo-filter-searching","aria-hidden":"true",children:F.jsx("span",{className:"icon icon-spinner lb:animate-spin lb:w-3 lb:h-3"})})]}),F.jsx("div",{className:"lb:relative",children:F.jsxs("select",{id:b,value:e||"",onChange:e=>{const n=e.target.value;if("__create__"===n)return void h(!0);if(""===n||"__none__"===n)return void t?.(null);const l=x.find(e=>e.slug===n);t?.(l||null)},disabled:a||w,className:"limbo-filter-input limbo-filter-select lb:w-full",children:[s&&F.jsx("option",{value:"",children:$}),w&&F.jsx("option",{value:"",disabled:!0,children:"Cargando carpetas..."}),k&&!w&&F.jsx("option",{value:"",disabled:!0,children:"Error al cargar carpetas"}),!w&&!k&&x.map(e=>F.jsxs("option",{value:e.slug,children:[e.name,i&&` (${e.assets_count})`]},e.id)),n&&!w&&!k&&F.jsxs(F.Fragment,{children:[F.jsx("option",{disabled:!0,children:"──────────────"}),F.jsx("option",{value:"__create__",children:"+ Crear nueva carpeta..."})]})]})}),k&&F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2 lb:mt-1",children:[F.jsx("p",{className:"lb:text-red-600 lb:text-xs",children:k}),F.jsx("button",{type:"button",onClick:j,className:"lb:text-xs lb:text-brand-blue-1000 lb:underline lb:cursor-pointer",children:"Reintentar"})]})]})}const qe={pdf:{symbol:"icon-doc-pdf",color:"#dc2626"},doc:{symbol:"icon-doc-word",color:"#2563eb"},docx:{symbol:"icon-doc-word",color:"#2563eb"},xls:{symbol:"icon-doc-xls",color:"#16a34a"},xlsx:{symbol:"icon-doc-xls",color:"#16a34a"},ppt:{symbol:"icon-doc-ppt",color:"#ea580c"},pptx:{symbol:"icon-doc-ppt",color:"#ea580c"},txt:{symbol:"icon-doc-text",color:"#6b7280"},csv:{symbol:"icon-doc-report",color:"#16a34a"},mp4:{symbol:"icon-video",color:"#7c3aed"},webm:{symbol:"icon-video",color:"#7c3aed"},mov:{symbol:"icon-video",color:"#7c3aed"},avi:{symbol:"icon-video",color:"#7c3aed"},mkv:{symbol:"icon-video",color:"#7c3aed"},gif:{symbol:"icon-video",color:"#7a3f2d"},mp3:{symbol:"icon-support-person",color:"#0891b2"},mpeg:{symbol:"icon-support-person",color:"#0891b2"},wav:{symbol:"icon-support-person",color:"#0891b2"},ogg:{symbol:"icon-support-person",color:"#0891b2"},aac:{symbol:"icon-support-person",color:"#0891b2"},flac:{symbol:"icon-support-person",color:"#0891b2"},default:{symbol:"icon-clip",color:"#6b7280"}},Ve=new Set(["text/plain","text/csv","text/html","text/xml","text/css","text/javascript","text/markdown","application/json","application/xml","application/javascript"]);const He=v.memo(function({image:e,onDelete:t,onCrop:n,onSelect:l,onFolderChange:r,thumbnailSize:a=32,isDeleting:o=!1,showFolderInfo:i=!0,allowMoveFolder:s=!0,allowedFolderSlugs:c=null,excludedFolderSlugs:u=null,allowCreateFolder:d=!1,allowedActions:b={select:!0,download:!0,copy:!0,delete:!0,crop:!0,variants:!0,rename:!0},onRename:m=null}){const[h,p]=y.useState(!1),[f,g]=y.useState(!1),[x,w]=y.useState(!1),[k,C]=y.useState(e.variants_count||0),[S,j]=y.useState(!1),[N,E]=y.useState(!1),[$,_]=y.useState(!1),[T,z]=y.useState(""),[L,A]=y.useState(null),[M,P]=y.useState(!1),I=y.useRef(null);y.useEffect(()=>{if(!S)return;const e=e=>{e.target.closest(".limbo-image-card-wrapper")||j(!1)};return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[S]);const D=y.useMemo(()=>(e=>{if(e.asset_type)return e.asset_type;const t=e.mime_type||e.original_mime||"";return"image/gif"===t?"video":t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":t.includes("pdf")||t.includes("document")||t.includes("spreadsheet")||t.includes("presentation")||t.includes("text/")?"document":"unknown"})(e),[e]),O="image"===D,R=(e.mime_type||e.original_mime||"").includes("image/gif"),U=O||R,W=y.useMemo(()=>(e=>{if(!e)return"";const t=e.split(".");return t.length>1?t.pop().toLowerCase():""})(e.filename),[e.filename]),q=qe[W]||qe.default,V=e.url||e.path,H=U&&e.thumbnail_url?e.thumbnail_url:V,[K,G]=y.useState(()=>te(H)),[Q,Y]=y.useState(()=>!ne(H)),[J,Z]=y.useState(!1),[le,re]=y.useState(()=>ne(H)),{isMobile:ae,isTouch:oe}=B(),ie=window.limboCore?.accessibilityManager,se=(window.limboCore?.config?.getGlobal()||{}).interaction||{allowSelection:!1,allowCropping:!0},ce=n=>{n.stopPropagation(),ie?.announce(`Eliminando imagen ${e.filename}`,"assertive"),t?.(e)},ue=async t=>{t.stopPropagation();let n=e.url||e.path;try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(n);else{const e=document.createElement("textarea");e.value=n,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),document.body.removeChild(e)}p(!0),ie?.announce(`URL de ${e.filename} copiada al portapapeles. Nota: La URL puede tener un tiempo de validez limitado.`),setTimeout(()=>p(!1),2e3)}catch(l){console.error("Error al copiar URL:",l),ie?.announce(`Error al copiar URL de ${e.filename}. Inténtalo de nuevo.`),alert(`Error al copiar URL de ${e.filename}. Por favor, inténtalo de nuevo.`)}},de=async t=>{t.preventDefault(),t.stopPropagation();const n=e.url||e.path,l=e.filename||"limbo-file";if(!O){try{ie?.announce(`Descargando ${l}`);const e=await fetch(n,{mode:"cors"});if(!e.ok)throw new Error(`HTTP error: ${e.status}`);const t=await e.blob(),r=window.URL.createObjectURL(t),a=document.createElement("a");a.href=r,a.download=l,a.style.display="none",document.body.appendChild(a),a.click(),setTimeout(()=>{window.URL.revokeObjectURL(r),document.body.removeChild(a)},100),ie?.announce(`${l} descargado correctamente`)}catch(a){console.error("Error downloading file:",a),ie?.announce(`Error al descargar ${l}`)}return}const{downloadImage:r}=await Promise.resolve().then(()=>il);await r(n,l,{originalFormat:e.format,accessibilityManager:ie})},be=t=>{t.stopPropagation(),ie?.announce(`Editando imagen ${e.filename}`),n?.(e)},me=y.useCallback(t=>{t.stopPropagation();const n=e.filename.replace(/\.[^.]+$/,"");z(n),A(null),_(!0),setTimeout(()=>I.current?.select(),0)},[e.filename]),he=y.useCallback(e=>{e?.stopPropagation(),_(!1),A(null)},[]),pe=y.useCallback(e=>{const t=e.target.value;z(t);const n=X(t||"_");A(n.valid?null:n.error)},[]),fe=y.useCallback(async t=>{t?.preventDefault(),t?.stopPropagation();const n=T.trim(),l=X(n);if(!l.valid)return void A(l.error);const r=n+(e.filename.includes(".")?"."+e.filename.split(".").pop():"");if(r!==e.filename){P(!0);try{await(m?.(e,r)),_(!1)}catch{A("Error al renombrar. Inténtalo de nuevo.")}finally{P(!1)}}else _(!1)},[T,e,m]),ge=O&&(e.variants&&e.variants.length>0||k>0),ye=k,ve=v.useCallback(()=>{C(e=>Math.max(0,e-1))},[]);v.useEffect(()=>{C(e.variants_count||0)},[e.variants_count]),y.useEffect(()=>{if(!U)return Y(!1),void re(!0);if(e.thumbnail_url)return G(e.thumbnail_url),Y(!0),Z(!1),void re(!1);const t=e.url||e.path;if(ne(t))return G(te(t)),Y(!1),Z(!1),void re(!0);Y(!0),Z(!1),re(!1),ee(t).then(e=>{G(e),Y(!1),re(!0)}).catch(()=>{G(t),Y(!1),Z(!0)})},[e.url,e.path,e.thumbnail_url,U]);const xe=se.allowSelection&&b.select&&l,we=R?V:null,ke=O&&!R&&se.allowCropping&&b.crop&&n,Ce=()=>{xe?(ie?.announce(`Seleccionando ${e.filename} para el portal`),l?.(e)):ge?(ie?.announce(`Mostrando recortes de ${e.filename}`),g(!0)):(ie?.announce(`Abriendo visor de ${e.filename}`),w(!0))};return F.jsxs(F.Fragment,{children:[F.jsxs("div",{className:`limbo-image-card-wrapper lb:relative lb:cursor-pointer ${o?"lb:opacity-50":""} ${ae?"limbo-image-card-wrapper--mobile":""}`,onClick:Ce,onKeyDown:l=>{switch(l.key){case"Enter":case" ":l.preventDefault(),Ce();break;case"d":case"D":b.download&&(l.preventDefault(),de(l));break;case"c":case"C":b.copy&&(l.preventDefault(),ue(l));break;case"Delete":case"Backspace":b.delete&&t&&(l.preventDefault(),ce(l));break;case"x":case"X":b.crop&&n&&(l.preventDefault(),be(l));break;case"v":case"V":b.variants&&(l.preventDefault(),(t=>{t.stopPropagation(),ie?.announce(`Mostrando recortes de ${e.filename}`),g(!0)})(l))}},onMouseEnter:we?()=>{we&&e.thumbnail_url&&G(we)}:void 0,onMouseLeave:we?()=>{we&&e.thumbnail_url&&G(e.thumbnail_url)}:void 0,title:ge?`Ver ${ye} recorte${1!==ye?"s":""} de ${e.filename}`:U?ae?"Toque para ampliar imagen":"Click para ampliar imagen con zoom":ae?"Toque para previsualizar":"Click para previsualizar",role:"button",tabIndex:0,"aria-label":U?`${R?"GIF":"Imagen"} ${e.filename}. ${e.width}x${e.height} px`:`Archivo ${e.filename}. Tipo: ${D}`,style:{...oe&&{touchAction:"manipulation",WebkitTapHighlightColor:"transparent"}},children:[N&&F.jsxs("div",{className:"limbo-moving-overlay",children:[F.jsx("span",{className:"icon icon-spinner lb:animate-spin lb:w-6 lb:h-6"}),F.jsx("span",{className:"lb:text-xs lb:text-gray-600 lb:font-medium",children:"Moviendo..."})]}),F.jsxs("div",{className:`limbo-image-actions ${S?"limbo-image-actions--expanded":""} ${ae?"limbo-image-actions--mobile":""}`,children:[F.jsxs("div",{className:"limbo-image-actions__buttons",children:[(xe||!U)&&F.jsx("button",{type:"button",title:ge?`Ver ${ye} recortes`:U?"Ampliar imagen":"Previsualizar archivo",className:"limbo-action-btn lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:border lb:border-brand-blue-1000 "+(ae?"lb:btn--touch":""),onClick:t=>{t?.stopPropagation(),ge?(ie?.announce(`Mostrando recortes de ${e.filename}`),g(!0)):(ie?.announce(`Abriendo visor de ${e.filename}`),w(!0))},tabIndex:-1,style:{...ae&&{width:"40px",height:"40px"}},children:F.jsx("span",{className:`icon ${U?"icon-zoom-in-white":"icon-search-white"} icon--sm`,"aria-hidden":"true"})}),ke&&F.jsx("button",{type:"button",title:"Nuevo recorte",className:"limbo-action-btn limbo-btn-crop lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:border lb:border-brand-blue-1000 "+(ae?"lb:btn--touch":""),onClick:be,tabIndex:-1,style:{...ae&&{width:"40px",height:"40px"}},children:F.jsx("span",{className:"icon icon-scissors-white icon--sm","aria-hidden":"true"})}),b.copy&&F.jsx("button",{type:"button",title:h?"¡Copiado!":"Copiar URL",className:"limbo-action-btn limbo-btn-copy lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:border lb:border-brand-blue-1000 "+(ae?"lb:btn--touch":""),onClick:ue,tabIndex:-1,style:{...ae&&{width:"40px",height:"40px"}},children:F.jsx("span",{className:`icon ${h?"icon-copied-white":"icon-copy-white"} icon--sm`,"aria-hidden":"true"})}),b.download&&F.jsx("button",{type:"button",title:"Descargar",className:"limbo-action-btn limbo-btn-download lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:border lb:border-brand-blue-1000 "+(ae?"lb:btn--touch":""),onClick:de,tabIndex:-1,style:{...ae&&{width:"40px",height:"40px"}},children:F.jsx("span",{className:"icon icon-download-white icon--sm","aria-hidden":"true"})}),s&&r&&F.jsx("button",{type:"button",title:e.folder?`Mover de carpeta (${e.folder?.name||e.folder?.slug||""})`:"Asignar a carpeta",className:"limbo-action-btn limbo-btn-folder lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:border lb:border-brand-blue-1000 "+(ae?"lb:btn--touch":""),onClick:e=>{e.stopPropagation(),j(!S)},tabIndex:-1,style:{...ae&&{width:"40px",height:"40px"}},children:F.jsx("span",{className:"icon icon-folder-white icon--sm","aria-hidden":"true"})}),b.rename&&m&&F.jsx("button",{type:"button",title:"Renombrar archivo",className:"limbo-action-btn limbo-btn-rename lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:border lb:border-brand-blue-1000 "+(ae?"lb:btn--touch":""),onClick:me,tabIndex:-1,style:{...ae&&{width:"40px",height:"40px"}},children:F.jsx("span",{className:"icon icon-edit-white icon--sm","aria-hidden":"true"})}),b.delete&&t&&F.jsx("button",{onClick:ce,disabled:o,className:"limbo-action-btn limbo-btn-delete lb:bg-red-800 lb:hover:bg-red-700 lb:border lb:border-red-700 "+(ae?"lb:btn--touch lb:active:lb:bg-red-800":""),title:"Eliminar archivo",tabIndex:-1,style:{...ae&&{width:"40px",height:"40px"}},children:o?"…":F.jsx("span",{className:"icon icon-close-small-white icon--sm","aria-hidden":"true"})})]}),S&&s&&r&&F.jsx("div",{className:"limbo-image-actions__folder",onClick:e=>e.stopPropagation(),children:F.jsx(We,{value:e.folder?.slug||null,onChange:async t=>{if(!N){E(!0);try{const n=t?.slug||null;await(r?.(e,n)),Fe(),ie?.announce(t?`${e.filename} movido a carpeta ${t.name}`:`${e.filename} movido a Sin carpeta`)}catch(n){console.error("Error moving to folder:",n),ie?.announce(`Error al mover ${e.filename}`)}finally{E(!1),j(!1)}}},allowCreate:d,placeholder:"Sin carpeta",label:"Mover a carpeta",includeNoFolder:!0,allowedSlugs:c,excludeSlugs:u,disabled:N,mode:"upload"})})]}),F.jsxs("div",{className:"limbo-image-card "+(ae?"limbo-image-card--mobile":""),children:[!U&&(e.thumbnail_url?F.jsxs("div",{className:"lb:relative lb:w-full lb:h-full lb:rounded lb:overflow-hidden lb:border lb:border-neutral-300",style:{...ae&&{minHeight:`${Math.max(3*a,80)}px`}},children:[F.jsx("img",{src:e.thumbnail_url,alt:e.filename,className:"lb:w-full lb:h-full lb:object-cover lb:aspect-square",loading:"lazy",decoding:"async",draggable:!1,onError:e=>{e.target.style.display="none",e.target.nextElementSibling?.classList.remove("lb:hidden")}}),F.jsx("div",{className:(e.thumbnail_url?"lb:flex":"lb:hidden")+"lb:absolute lb:inset-0 lb:bg-linear-to-br lb:from-neutral-100 lb:to-neutral-200 lb:flex-col lb:items-center lb:justify-center",children:F.jsx("span",{className:"lb:mb-2 lb:h-[25%] lb:w-[25%]","aria-hidden":"true",children:F.jsx("span",{className:`icon ${q.symbol} lb:min-w-full lb:min-h-full`})})}),F.jsx("span",{className:"lb:absolute lb:bottom-1.5 lb:right-1.5 lb:text-[10px] lb:uppercase lb:font-bold lb:tracking-wide lb:px-1.5 lb:py-0.5 lb:rounded lb:shadow-sm",style:{backgroundColor:q.color,color:"white"},children:W||D})]}):F.jsxs("div",{className:"lb:w-full lb:h-full lb:rounded lb:bg-linear-to-br lb:from-neutral-100 lb:to-neutral-200 lb:flex lb:flex-col lb:items-center lb:justify-center lb:border lb:border-neutral-300",style:{...ae&&{minHeight:`${Math.max(3*a,80)}px`}},children:[F.jsx("span",{className:"lb:mb-2 lb:h-[25%] lb:w-[25%]","aria-hidden":"true",children:F.jsx("span",{className:`icon ${q.symbol} lb:min-w-full lb:min-h-full`})}),F.jsx("span",{className:"lb:text-xs lb:uppercase lb:font-bold lb:tracking-wide lb:px-2 lb:py-0.5 lb:rounded",style:{backgroundColor:q.color,color:"white"},children:W||D})]})),U&&F.jsxs(F.Fragment,{children:[Q&&!J&&F.jsx("div",{className:"lb:w-full lb:aspect-square lb:rounded lb:bg-neutral-200 lb:animate-pulse lb:flex lb:items-center lb:justify-center lb:absolute lb:inset-0 lb:z-10 "+(ge?"lb:ring-2 lb:ring-brand-blue-400 lb:ring-offset-2":""),style:{...ae&&{minHeight:`${Math.max(3*a,80)}px`}},children:F.jsx("span",{className:"icon icon-spinner lb:w-8 lb:h-8 lb:animate-spin"})}),J&&F.jsxs("div",{className:"lb:z-0 lb:absolute lb:top-0 lb:left-0 lb:w-full lb:aspect-square lb:rounded lb:bg-neutral-100 lb:flex lb:flex-col lb:items-center lb:justify-center lb:text-neutral-400",style:{...ae&&{minHeight:`${Math.max(3*a,80)}px`}},children:[F.jsx("span",{className:"icon icon-close icon--lg lb:mb-1","aria-hidden":"true"}),F.jsx("span",{className:"lb:text-xs",children:"Error al cargar"})]}),F.jsx("img",{src:K,loading:"lazy",decoding:"async",alt:e.filename.split(".")[0]??e.filename,className:`lb:z-1 lb:w-full lb:object-cover lb:rounded lb:aspect-square lb:transition-opacity lb:duration-300 ${ge?"lb:ring-2 lb:ring-brand-blue-400 lb:ring-offset-2":""} ${le?"lb:opacity-100":"lb:opacity-0"}`,sizes:`height: ${6*a}px,width: ${6*a}px`,draggable:!1,onLoad:()=>{Y(!1),re(!0)},onError:()=>{Y(!1),Z(!0)},style:{...ae&&{minHeight:`${Math.max(3*a,80)}px`,height:"auto",aspectRatio:"1 / 1",objectFit:"cover"}}}),R&&F.jsx("span",{className:"lb:absolute lb:bottom-1.5 lb:right-1.5 lb:text-[10px] lb:uppercase lb:font-bold lb:tracking-wide lb:px-1.5 lb:py-0.5 lb:rounded lb:shadow-sm",style:{backgroundColor:q.color,color:"white"},children:W||D})]}),F.jsxs("div",{className:"limbo-card-info-overlay "+(ae?"limbo-card-info-overlay--mobile":""),children:[$?F.jsxs("form",{className:"lb:flex lb:flex-col lb:w-full lb:gap-1",onSubmit:fe,onClick:e=>e.stopPropagation(),children:[F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-1 lb:w-full",children:[F.jsx("input",{ref:I,type:"text",value:T,onChange:pe,onKeyDown:e=>"Escape"===e.key&&he(e),className:`lb:flex-1 lb:min-w-0 lb:px-1 lb:py-0.5 lb:text-xs lb:rounded lb:border ${L?"lb:border-red-400":"lb:border-gray-400"} lb:bg-white lb:text-gray-900 lb:outline-none`,placeholder:"Nuevo nombre",disabled:M,autoFocus:!0}),F.jsx("button",{type:"submit",disabled:M||!!L,className:"lb:px-1.5 lb:py-0.5 lb:text-xs lb:bg-brand-blue-400 lb:text-white lb:rounded lb:shrink-0 lb:disabled:opacity-40",title:"Guardar nombre",children:M?"…":"✓"}),F.jsx("button",{type:"button",onClick:he,className:"lb:px-1.5 lb:py-0.5 lb:text-xs lb:bg-gray-500 lb:text-white lb:rounded lb:shrink-0",title:"Cancelar",children:"✕"})]}),L&&F.jsx("span",{className:"lb:text-xs lb:text-red-300 lb:leading-tight",children:L})]}):F.jsxs("span",{className:"limbo-card-info-name lb:truncate lb:max-w-full",children:[e.filename.split(".")[0]??e.filename,ge&&F.jsx("span",{className:"limbo-variants-indicator",style:{marginLeft:"4px",padding:"1px 6px",backgroundColor:"#dc2626",color:"white",borderRadius:"10px",fontSize:"10px",fontWeight:"700",display:"inline-block"},title:`${ye} recorte${1!==ye?"s":""}`,children:ye})]}),i&&e.folder&&F.jsxs("span",{className:"limbo-card-info-folder lb:flex lb:items-center lb:gap-1 lb:bg-brand-blue-50 lb:rounded-md lb:px-1",title:`Carpeta: ${e.folder?.name||e.folder?.slug||e.folder}`,children:[F.jsx("span",{className:"icon icon-folder icon--sm"}),F.jsx("span",{className:"lb:truncate lb:max-w-20",children:e.folder?.name||e.folder?.slug||("string"==typeof e.folder?e.folder:"Sin carpeta")})]})]})]})]}),F.jsx(Ie,{image:e,isOpen:f,onClose:()=>g(!1),onSelect:l,onDelete:t,onCrop:n,onVariantDeleted:ve,allowedActions:{select:b.select,download:b.download,copy:b.copy,delete:b.delete,crop:b.crop}}),x&&(()=>{const t=e.url||e.path,n=()=>w(!1),l=e.file_size?`${Math.round(e.file_size/1024)}KB`:"",r=e.mime_type||"";return U?F.jsx(Pe,{isOpen:!0,src:t,alt:e.filename,title:e.filename,subtitle:`${e.width||"?"}×${e.height||"?"} · ${l}`,onClose:n}):"video"===D?F.jsx(Se,{isOpen:!0,src:t,title:e.filename,subtitle:`${W.toUpperCase()} · ${l}`,onClose:n}):"audio"===D?F.jsx(je,{isOpen:!0,src:t,title:e.filename,subtitle:`${W.toUpperCase()} · ${l}`,onClose:n}):r.includes("pdf")?F.jsx(Ne,{isOpen:!0,src:t,title:e.filename,subtitle:l,onClose:n}):(e=>!(!e||!Ve.has(e)&&!e.startsWith("text/")))(r)?F.jsx(Me,{isOpen:!0,src:t,title:e.filename,subtitle:`${W.toUpperCase()} · ${l}`,mimeType:r,fileSize:e.file_size||0,onClose:n}):F.jsx(Le,{isOpen:!0,src:t,title:e.filename,subtitle:`${W.toUpperCase()} · ${l}`,mimeType:r,fileSize:e.file_size||0,onClose:n})})()]})});function Ke(){return F.jsxs("div",{className:"limbo-image-card lb:animate-pulse",role:"status","aria-label":"Cargando imágen...",children:[F.jsx("div",{className:"lb:w-full lb:aspect-square lb:bg-neutral-gray-200 lb:rounded-md lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-spinner"})}),F.jsx("div",{className:"limbo-image-card-name lb:opacity-100 position-relative lb:bottom-0 lb:p-2",children:F.jsx("div",{className:"lb:h-4 lb:bg-neutral-gray-200 lb:rounded lb:w-3/4"})}),F.jsx("span",{className:"sr-only",children:"Cargando imágen..."})]})}function Ge({variant:e="info",toast:t=!1,fixed:n=!1,onClose:l,className:r="",children:a,role:o}){const[i,s]=y.useState(!1);if(y.useEffect(()=>{s(!1)},[a]),i)return null;const c=t||n?`${n?"lb:fixed lb:top-4 lb:right-4 lb:z-10000":t?"lb:absolute lb:top-5 lb:right-5 lb:w-fit lb:m-4 lb:z-50":""} ${{success:"lb:bg-green-600",danger:"lb:bg-red-500",warning:"lb:bg-yellow-500",info:"lb:bg-blue-500"}[e]||"lb:bg-gray-600"} lb:text-white lb:px-5 lb:py-3 lb:rounded-lg lb:shadow-lg lb:transition-all lb:duration-300 lb:animate-fade-in`:`limbo-alert limbo-alert-${e}`;return F.jsxs("div",{className:`${c} lb:pr-8 ${r}`,role:o||"alert",children:[a,F.jsx("button",{type:"button",onClick:e=>{e.stopPropagation(),l?l():s(!0)},className:"lb:absolute lb:top-1/2 lb:-translate-y-1/2 lb:right-2 lb:p-1 lb:rounded-full lb:opacity-60 lb:hover:opacity-100 lb:transition-opacity lb:cursor-pointer","aria-label":"Cerrar",children:F.jsx("span",{className:"icon icon-close-small-white icon--sm","aria-hidden":"true"})})]})}const Qe=[{value:"",label:"Todos los tipos"},{value:"image",label:"Imágenes"},{value:"video",label:"Videos"},{value:"document",label:"Documentos"},{value:"audio",label:"Audio"}];function Xe({onSelect:e,onCrop:l,onDelete:r,deletingId:a,images:o,loading:i,error:s,filters:c={name:"",dateFrom:"",dateTo:"",uploadedBy:"",assetType:"",folder:""},debouncedFilters:u=null,onFiltersChange:d,filterConfig:b={showNameFilter:!0,showUploadedByFilter:!1,showDateFilter:!0,showTypeFilter:!1},loadingConfig:m={showPlaceholders:!0,placeholderCount:10,showSpinner:!0},allowedActions:h={select:!0,download:!0,copy:!0,delete:!0,crop:!0,variants:!0},allowedCategories:p=null,resolvedAccept:f=null,folderConfig:g=null,onFolderChange:v=null,onRename:x=null}){const{isSearching:w,searchPending:k}=function(e,t,n){const[l,r]=y.useState(!1),a=y.useRef(null);return y.useEffect(()=>(Object.keys(e).some(n=>e[n]!==t[n])?a.current=setTimeout(()=>{r(!0)},150):(a.current&&clearTimeout(a.current),r(!1)),()=>{a.current&&clearTimeout(a.current)}),[e,t]),{isSearching:l||n,searchPending:l}}(c,u||c,i),C=!1!==b.showNameFilter,S=!0===b.showUploadedByFilter,j=!1!==b.showDateFilter,N=!1!==b.showTypeFilter,E=!0===g?.showFolderFilter,$=g?.include?.length>0?g.include:null,_=g?.exclude?.length>0?g.exclude:null,T=!1!==g?.showFolderInfo,z=!1!==g?.allowMoveFolder&&!!v,L=!0===g?.allowCreateFolder,A=y.useMemo(()=>{const e=f&&!f.isAllTypes?function(e){if(!e||e.isAllTypes)return null;const l=new Set(e.categories);for(const r of e.extensions){const e=t[r]||[];for(const t of e)for(const[e,r]of Object.entries(n))r.includes(t)&&l.add(e)}for(const t of e.mimeTypes)for(const[e,r]of Object.entries(n))(r.includes(t)||t.startsWith(e+"/"))&&l.add(e);return l.size>0?[...l]:null}(f):p;return e?Qe.filter(t=>""===t.value||e.includes(t.value)):Qe},[f,p]),M=y.useRef(null),P=window.limboCore?.accessibilityManager;y.useEffect(()=>{if(M.current&&window.limboCore?.keyboardManager){const e="gallery-grid";M.current.setAttribute("data-grid-id",e),window.limboCore.keyboardManager.setupGridNavigation(M.current,{itemSelector:".limbo-image-card",gridId:e,columns:"auto"})}},[o]),y.useEffect(()=>{if(!i&&o.length>0){const e=o.slice(0,12).map(e=>e.url||e.path).filter(Boolean);e.length>0&&le(e,4)}},[i,o]);const I=y.useMemo(()=>{if(!c.assetType)return"archivos";return{image:"imágenes",video:"videos",document:"documentos",audio:"archivos de audio"}[c.assetType]||"archivos"},[c.assetType]);y.useEffect(()=>{i?P?.announceLoading(!0,"galería"):i||s?s&&P?.announceError(s,"galería"):(P?.announceLoading(!1,"galería"),o.length>0&&P?.announce(`Se encontraron ${o.length} ${I} en la galería`))},[i,s,o.length,P,I]),y.useEffect(()=>{k&&P?.announce("Buscando...","polite")},[k,P]);const D=e=>{const{name:t,value:n}=e.target;d&&d({...c,[t]:n})},O=c.name||c.dateFrom||c.dateTo||c.uploadedBy||c.assetType||c.folder,R=w&&o.length>0&&!i;return F.jsxs("div",{className:"lb:w-full lb:max-w-full lb:py-2 lb:overflow-x-hidden lb:box-border",children:[F.jsx("div",{className:"lb:px-2 lb:mb-3 lb:mx-2 lb:max-w-full lb:overflow-x-hidden lb:box-border",children:F.jsxs("form",{className:"limbo-filters flex items-stretch content-stretch flex-row",onSubmit:e=>e.preventDefault(),role:"search","aria-label":"Filtrar archivos",children:[C&&F.jsxs("div",{className:"limbo-filter-group limbo-filter-group--name",children:[F.jsxs("label",{htmlFor:"name",className:"limbo-filter-label",children:["Nombre",k&&F.jsx("span",{className:"limbo-filter-searching","aria-hidden":"true",children:F.jsx("span",{className:"icon icon-spinner lb:animate-spin lb:w-3 lb:h-3"})})]}),F.jsx("input",{type:"text",name:"name",id:"name",placeholder:"Buscar...",value:c.name,onChange:D,className:"limbo-filter-input",autoComplete:"off"})]}),j&&F.jsxs("div",{className:"limbo-filter-dates",children:[F.jsxs("div",{className:"limbo-filter-group limbo-filter-group--date",children:[F.jsx("label",{htmlFor:"dateFrom",className:"limbo-filter-label",children:"Desde"}),F.jsx("input",{type:"date",name:"dateFrom",id:"dateFrom",value:c.dateFrom,onChange:D,className:"limbo-filter-input"})]}),F.jsxs("div",{className:"limbo-filter-group limbo-filter-group--date",children:[F.jsx("label",{htmlFor:"dateTo",className:"limbo-filter-label",children:"Hasta"}),F.jsx("input",{type:"date",name:"dateTo",id:"dateTo",value:c.dateTo,onChange:D,className:"limbo-filter-input"})]})]}),N&&A.length>1&&F.jsxs("div",{className:"limbo-filter-group limbo-filter-group--type",children:[F.jsx("label",{htmlFor:"assetType",className:"limbo-filter-label",children:"Tipo"}),F.jsx("select",{name:"assetType",id:"assetType",value:c.assetType||"",onChange:D,className:"limbo-filter-input limbo-filter-select",children:A.map(e=>F.jsx("option",{value:e.value,children:e.label},e.value))})]}),E&&F.jsx("div",{className:"limbo-filter-group limbo-filter-group--folder",children:F.jsx(We,{value:c.folder||"",onChange:e=>D({target:{name:"folder",value:e?.slug||""}}),allowCreate:!1,label:"Carpeta",showAssetCount:!0,includeNoFolder:!0,allowedSlugs:$,excludeSlugs:_,mode:"filter"})}),S&&F.jsxs("div",{className:"limbo-filter-group",children:[F.jsx("label",{htmlFor:"uploadedBy",className:"limbo-filter-label",children:"Subido por"}),F.jsx("input",{type:"text",name:"uploadedBy",id:"uploadedBy",placeholder:"Usuario...",value:c.uploadedBy,onChange:D,className:"limbo-filter-input",style:{minWidth:"100px",maxWidth:"140px"}})]}),F.jsxs("div",{children:[F.jsx("span",{className:"lb:h-[37%] block"}),F.jsxs("button",{type:"button",onClick:()=>{d&&d({name:"",uploadedBy:"",dateFrom:"",dateTo:"",assetType:"",folder:""})},disabled:!O,className:"limbo-filter-clear-btn","aria-label":"Limpiar todos los filtros",title:"Limpiar filtros",children:[F.jsx("span",{className:"icon icon-close-small"}),"Limpiar"]})]})]})}),i?F.jsxs("div",{className:"lb:relative",children:[F.jsx("div",{className:"lb:relative lb:inset-0 lb:flex lb:items-center lb:justify-center lb:bg-white/80 lb:z-10 lb:min-h-75",children:F.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-3",children:[F.jsx("span",{className:"icon icon-spinner lb:p-4 lb:animate-spin"}),F.jsxs("span",{className:"lb:text-sm lb:text-gray-600 lb:font-medium",children:["Cargando ",I,"..."]})]})}),m.showPlaceholders&&F.jsx("div",{ref:M,className:"limbo-gallery lb:opacity-30","data-limbo-responsive":!0,role:"grid","aria-label":`Cargando ${I} de la galería`,"aria-busy":"true",children:Array.from({length:m.placeholderCount}).map((e,t)=>F.jsx("div",{role:"gridcell","aria-posinset":t+1,"aria-setsize":m.placeholderCount,className:"lb:min-w-0",children:F.jsx(Ke,{})},`skeleton-${t}`))})]}):s?F.jsx(Ge,{variant:"danger",className:"lb:text-center",children:s}):F.jsxs("div",{className:"lb:relative",children:[R&&F.jsx("div",{className:"limbo-search-overlay",role:"status","aria-live":"polite","aria-label":"Buscando archivos",children:F.jsxs("div",{className:"limbo-search-overlay__content",children:[F.jsx("span",{className:"icon icon-spinner lb:animate-spin"}),F.jsx("span",{children:"Buscando..."})]})}),F.jsx("div",{ref:M,className:"limbo-gallery lb:px-3 lb:pt-4 lb:box-border lb:max-w-full "+(R?"lb:opacity-50 lb:pointer-events-none":""),"data-limbo-responsive":!0,"data-grid-id":"gallery-grid",role:"grid","aria-label":`Galería de ${I}. Use las flechas para navegar`,"aria-busy":R,children:o.length>0?o.map((t,n)=>F.jsx("div",{role:"gridcell","aria-posinset":n+1,"aria-setsize":o.length,className:"lb:min-w-0",children:F.jsx(He,{image:t,onSelect:e,onCrop:l,onDelete:h.delete&&r?()=>r(t.id):null,onFolderChange:v,onRename:x,thumbnailSize:32,isDeleting:a===t.id,showFolderInfo:T,allowMoveFolder:z,allowedFolderSlugs:$,excludedFolderSlugs:_,allowCreateFolder:L,allowedActions:h})},t.id)):F.jsx("div",{className:"lb:col-span-full lb:text-center lb:text-gray-500 lb:py-8",role:"status","aria-live":"polite",children:F.jsxs("p",{children:["No se han encontrado ",I]})})})]})]})}function Ye({previewUrl:e,fileName:t}){const[n,l]=y.useState(!1),[r,a]=y.useState(!1),o=y.useRef(null);return r?F.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:justify-center lb:p-8 lb:min-h-[200px] lb:bg-gray-100 lb:rounded-lg",children:[F.jsx("span",{className:"icon icon-video icon--xl lb:text-gray-400 lb:mb-4"}),F.jsx("p",{className:"lb:text-sm lb:text-gray-600",children:"No se puede reproducir el video"}),F.jsx("p",{className:"lb:text-xs lb:text-gray-500 lb:mt-1",children:t})]}):F.jsxs("div",{className:"lb:relative lb:w-full lb:min-w-65 lb:max-w-md lb:aspect-video lb:bg-black lb:rounded-lg lb:overflow-hidden",children:[F.jsx("video",{ref:o,src:e,className:"lb:absolute lb:inset-0 lb:w-full lb:h-full lb:object-contain",onEnded:()=>{l(!1)},onError:()=>{a(!0)},onPlay:()=>l(!0),onPause:()=>l(!1),controls:!0,preload:"metadata",children:"Tu navegador no soporta la reproduccion de video."}),!n&&F.jsx("button",{type:"button",onClick:()=>{o.current&&(n?o.current.pause():o.current.play(),l(!n))},className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center lb:bg-black/30 lb:hover:bg-black/40 lb:transition-colors lb:cursor-pointer","aria-label":"Reproducir video",children:F.jsx("div",{className:"lb:w-16 lb:h-16 lb:rounded-full lb:bg-white/90 lb:flex lb:items-center lb:justify-center lb:shadow-lg",children:F.jsx("span",{className:"icon icon-play icon--lg lb:text-gray-800 lb:ml-1"})})}),F.jsxs("div",{className:"lb:absolute lb:top-2 lb:right-2 lb:bg-black/60 lb:text-white lb:px-2 lb:py-1 lb:rounded lb:text-xs lb:flex lb:items-center lb:gap-1",children:[F.jsx("span",{className:"icon icon-video icon--xs"}),F.jsx("span",{children:"VIDEO"})]})]})}function Je({previewUrl:e,fileName:t,fileSize:n}){const[l,r]=y.useState(!1),[a,o]=y.useState(!1),[i,s]=y.useState(0),[c,u]=y.useState(0),d=y.useRef(null),b=e=>{if(!e||isNaN(e))return"0:00";return`${Math.floor(e/60)}:${Math.floor(e%60).toString().padStart(2,"0")}`};return a?F.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:justify-center lb:p-8 lb:min-h-50 lb:bg-gray-100 lb:rounded-lg",children:[F.jsx("span",{className:"icon icon-audio icon--xl lb:text-gray-400 lb:mb-4"}),F.jsx("p",{className:"lb:text-sm lb:text-gray-600",children:"No se puede reproducir el audio"}),F.jsx("p",{className:"lb:text-xs lb:text-gray-500 lb:mt-1",children:t})]}):F.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:justify-center lb:p-6 lb:min-h-50",children:[F.jsxs("div",{className:"lb:relative lb:mb-4",children:[F.jsx("div",{className:"lb:w-24 lb:h-24 lb:flex lb:items-center lb:justify-center lb:bg-linear-to-br lb:from-purple-100 lb:to-blue-100 lb:rounded-full",children:F.jsx("span",{className:"icon icon-audio icon--xl lb:text-purple-600"})}),F.jsx("button",{type:"button",onClick:()=>{d.current&&(l?d.current.pause():d.current.play())},className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center lb:rounded-full lb:bg-black/0 lb:hover:bg-black/10 lb:transition-colors lb:cursor-pointer","aria-label":l?"Pausar":"Reproducir",children:F.jsx("div",{className:"lb:w-10 lb:h-10 lb:rounded-full lb:bg-white lb:shadow-md lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:`icon ${l?"icon-pause":"icon-play"} icon--md lb:text-gray-800 ${l?"":"lb:ml-0.5"}`})})})]}),F.jsx("p",{className:"lb:text-sm lb:font-medium lb:text-gray-800 lb:text-center lb:max-w-full lb:truncate lb:px-4",children:t}),F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2 lb:mt-2 lb:text-xs lb:text-gray-500",children:[F.jsx("span",{children:b(c)}),F.jsx("span",{children:"/"}),F.jsx("span",{children:b(i)}),n&&F.jsxs(F.Fragment,{children:[F.jsx("span",{children:"•"}),F.jsx("span",{children:Te(n)})]})]}),F.jsx("div",{className:"lb:w-full lb:max-w-xs lb:mt-3",children:F.jsx("div",{className:"lb:h-1.5 lb:bg-gray-200 lb:rounded-full lb:overflow-hidden lb:cursor-pointer",onClick:e=>{if(!d.current||!i)return;const t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left;d.current.currentTime=n/t.width*i},role:"slider","aria-label":"Progreso de audio","aria-valuenow":c,"aria-valuemin":0,"aria-valuemax":i,tabIndex:0,children:F.jsx("div",{className:"lb:h-full lb:bg-purple-500 lb:rounded-full lb:transition-all lb:duration-100 lb:pointer-events-none",style:{width:i>0?c/i*100+"%":"0%"}})})}),F.jsx("audio",{ref:d,src:e,onPlay:()=>r(!0),onPause:()=>r(!1),onTimeUpdate:()=>{d.current&&u(d.current.currentTime)},onLoadedMetadata:()=>{d.current&&s(d.current.duration)},onEnded:()=>{r(!1),u(0)},onError:()=>{o(!0)},preload:"metadata"})]})}function Ze({file:e,image:t,onDiscard:n,onRetry:l,onDownload:r,onSelect:a,showRetry:o=!1,disabled:i=!1,showCropButton:s,selectedFolder:c=null,onFolderChange:u=null,folderConfig:d=null}){const b=e||t,[m,h]=y.useState(null),[p,f]=y.useState({name:"",size:"",type:"",category:"unknown"}),[g,v]=y.useState(!1),[x,w]=y.useState(!1),[k,C]=y.useState(""),S="image"===p.category,j="video"===p.category,N="audio"===p.category,E=void 0!==s?s:S;y.useEffect(()=>{if(!b)return void h(null);const e=URL.createObjectURL(b);h(e);const t=b.name||"archivo",n=b.type||"",l=(e=>e?e.startsWith("image/")?"image":e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":"application/pdf"===e||e.includes("document")||e.includes("msword")||e.includes("spreadsheet")||e.includes("presentation")||e.startsWith("text/")?"document":"unknown":"unknown")(n),r=(e=>{const t=e?.split(".")[0]?.toLowerCase()||"";return["ai-image","ai_image","generated","imagen-ia","imagen_ia"].some(e=>t.startsWith(e))})(t);if(f({name:t,size:Te(b.size||0),type:n,category:l}),r)C(""),w(!1);else{const e=t.split(".")[0];C(e)}return()=>{URL.revokeObjectURL(e)}},[b]);if(!b||!m)return null;return F.jsxs("div",{className:"lb:w-full lb:max-w-full lb:bg-white lb:border lb:border-gray-200 lb:rounded-lg lb:px-1 lb:sm:px-3 lb:py-2 lb:m-0 lb:shadow-sm lb:overflow-hidden lb:box-border",children:[F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between lb:mb-4 lb:px-1",children:[F.jsx("h3",{className:"lb:text-sm lb:font-medium lb:text-gray-700",children:(()=>{switch(p.category){case"image":return"Vista previa de imagen";case"video":return"Vista previa de video";case"audio":return"Vista previa de audio";case"document":return"Vista previa de documento";default:return"Vista previa de archivo"}})()}),F.jsx("button",{type:"button",onClick:n,disabled:i,className:"lb:p-1.5 lb:text-gray-400 lb:cursor-pointer lb:hover:text-gray-600 lb:hover:bg-red-300 lb:rounded lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed","aria-label":"Descartar archivo",title:"Descartar archivo",children:F.jsx("span",{className:"icon icon-close-small icon--md"})})]}),F.jsx("div",{className:"lb:flex lb:justify-center lb:content-stretch lb:items-stretch",children:F.jsxs("div",{className:"lb:flex lb:flex-col lb:justify-stretch lb:content-stretch",children:[d?.showFolderSelector&&u&&F.jsx("div",{className:"lb:mb-4 lb:px-1 lb:flex lb:items-stretch lb:justify-stretch",children:F.jsx(We,{value:c?.slug||c,onChange:u,allowCreate:!1!==d?.allowCreateFolder,label:"Guardar en carpeta",showAssetCount:!0,className:"lb:w-full",allowedSlugs:d?.include?.length>0?d.include:null,mode:"upload",disabled:i})}),F.jsxs("div",{className:"lb:flex lb:flex-col lb:justify-center lb:md:flex-row lb:gap-2 lb:md:gap-6",children:[F.jsxs("div",{className:"lb:flex-1 lb:flex lb:flex-col lb:items-center lb:justify-center"+(S?" lb:min-w-100":""),children:[S?F.jsxs("div",{className:"lb:relative lb:w-full lb:max-w-md lb:aspect-video lb:bg-gray-100 lb:rounded-lg lb:overflow-hidden lb:cursor-zoom-in lb:hover:ring-2 lb:hover:ring-brand-blue-800 lb:transition-all",onClick:()=>v(!0),role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),v(!0))},"aria-label":"Click para ver imagen en tamano completo",title:"Click para ver en tamano completo",children:[F.jsx("img",{src:m,alt:"Vista previa",className:"lb:absolute lb:inset-0 lb:w-full lb:h-full lb:object-contain"}),F.jsxs("div",{className:"lb:absolute lb:top-2 lb:right-2 lb:bg-black/50 lb:text-white lb:px-2 lb:py-1 lb:rounded lb:text-xs lb:flex lb:items-center lb:gap-1",children:[F.jsx("span",{className:"icon icon-search-white icon--xs"}),F.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Ampliar"})]})]}):j?F.jsx(Ye,{previewUrl:m,fileName:p.name}):N?F.jsx(Je,{previewUrl:m,fileName:p.name,fileSize:b?.size}):F.jsx(ze,{file:b,mimeType:p.type,category:p.category}),S&&F.jsx("div",{className:"lb:mt-3 lb:text-center lb:space-y-1 lb:w-full",children:F.jsx("div",{className:"lb:rounded-sm lb:w-fit lb:gap-0.5 lb:p-0.5 lb:min-w-fit lb:mx-auto",children:F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-center lb:gap-3 lb:text-xs lb:text-gray-500",children:[F.jsx("span",{children:p.size}),F.jsx("span",{children:"•"}),F.jsx("span",{children:p.type.split("/")[1]?.toUpperCase()||"FILE"})]})})})]}),F.jsxs("div",{className:"lb:flex lb:flex-row lb:md:flex-col lb:gap-2 lb:justify-items-stretch lb:justify-center lb:md:justify-start lb:items-stretch lb:md:min-w-35",children:[F.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-1",children:[F.jsxs("label",{htmlFor:"assetPreviewNameInput",className:"lb:flex lb:items-center lb:w-fit",children:[F.jsx("span",{className:"lb:me-1 lb:text-sm",children:"Nombre:"}),F.jsx("input",{id:"assetPreviewNameInput",onChange:e=>(e=>{const t=e.target.value.trim();C(e.target.value),t.length>0&&w(!1);const n=p.name,l=n.lastIndexOf("."),r=-1!==l?n.substring(l):"";f(e=>({...e,name:t?t+r:r}))})(e),value:k,className:"limbo-input-image-name lb:w-fit lb:px-1 lb:text-sm lb:font-medium lb:text-gray-800 lb:border lb:rounded lb:truncate lb:focus:outline lb:focus:outline-neutral-gray-100 lb:focus:transform-none lb:focus:shadow-none lb:focus:opacity-100 "+(x?"lb:border-red-1000 lb:bg-red-50":"lb:border-gray-300"),placeholder:"Escribe un nombre...",title:"El nombre es obligatorio",required:!0})]}),x&&F.jsx("span",{className:"lb:text-xs lb:text-red-1000 lb:ml-1",children:"El nombre es obligatorio"})]}),o&&l&&F.jsxs("button",{type:"button",onClick:l,disabled:i,className:"lb:flex-1 lb:md:flex-none lb:flex lb:items-center lb:justify-center lb:gap-2 lb:px-4 lb:py-2.5 lb:bg-white lb:border lb:border-gray-300 lb:text-gray-700 lb:rounded-lg lb:hover:bg-gray-50 lb:cursor-pointer lb:hover:border-gray-400 lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed lb:text-sm lb:font-medium","aria-label":"Intentarlo de nuevo",title:"Generar de nuevo con el mismo prompt",children:[F.jsx("span",{className:"icon icon-refresh icon--sm"}),F.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Reintentar"}),F.jsx("span",{className:"lb:sm:hidden",children:"Retry"})]}),F.jsxs("button",{type:"button",onClick:()=>{if(!m||i)return;const e=document.createElement("a");e.href=m,e.download=p.name,document.body.appendChild(e),e.click(),document.body.removeChild(e),r&&r()},disabled:i,className:"lb:flex-1 lb:cursor-pointer lb:md:flex-none lb:flex lb:items-center lb:justify-center lb:gap-2 lb:px-4 lb:py-2.5 lb:bg-white lb:border lb:border-gray-300 lb:text-gray-700 lb:rounded-lg lb:hover:bg-gray-50 lb:hover:border-gray-400 lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed lb:text-sm lb:font-medium","aria-label":"Descargar archivo",children:[F.jsx("span",{className:"icon icon-download icon--sm"}),F.jsx("span",{children:"Descargar"})]}),F.jsxs("button",{type:"button",onClick:()=>{k.trim()?(w(!1),a&&a(p.name)):w(!0)},disabled:i,className:"lb:flex-1 lb:md:flex-none lb:flex lb:items-center lb:justify-center lb:gap-2 lb:px-4 lb:py-2.5 lb:bg-brand-blue-800 lb:border lb:border-brand-blue-800 lb:text-white lb:rounded-lg lb:hover:bg-brand-blue-1000 lb:cursor-pointer lb:hover:border-brand-blue-1000 lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed lb:text-sm lb:font-medium lb:shadow-sm","aria-label":E?"Seleccionar para recortar":"Seleccionar archivo",children:[F.jsx("span",{className:"icon icon-tick-white icon--sm"}),F.jsx("span",{children:"Seleccionar"})]})]})]})]})}),S&&F.jsx(Pe,{isOpen:g,src:m,alt:p.name,title:p.name,subtitle:`${p.size} • ${p.type.split("/")[1]?.toUpperCase()||"IMAGE"}`,onClose:()=>v(!1)})]})}const et={image:["image/jpeg","image/png","image/webp","image/svg+xml"],video:["image/gif","video/mp4","video/webm","video/quicktime","video/x-msvideo"],document:["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","text/plain","text/csv","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation"],audio:["audio/mpeg","audio/wav","audio/ogg","audio/webm"]},tt={image:"JPG, PNG, SVG, WebP, GIF",video:"GIF, MP4, WebM, MOV, AVI",document:"PDF, DOC, DOCX, XLS, XLSX, TXT, PPT, PPTX",audio:"MP3, WAV, OGG"},nt=["image","video","document","audio"];function lt({file:e,setFile:t,previewUrl:n,setPreviewUrl:l,fileInputRef:r,onSelect:a,disabled:o,allowedCategories:s=null,resolvedAccept:c=null,selectedFolder:u=null,onFolderChange:d=null,folderConfig:b=null}){const[m,h]=y.useState(!1),{acceptAttribute:p,allowedMimeTypes:f,formatLabels:g,categories:v}=y.useMemo(()=>{if(c&&!c.isAllTypes)return{acceptAttribute:c.acceptString,allowedMimeTypes:new Set(c.mimeTypes),formatLabels:i(c),categories:c.categories.length>0?c.categories:nt};const e=null===s?nt:s,t=[],n=[];return e.forEach(e=>{et[e]&&(t.push(...et[e]),tt[e]&&n.push(tt[e]))}),{acceptAttribute:t.join(","),allowedMimeTypes:new Set(t),formatLabels:n.join(", "),categories:e}},[s,c]),x=c&&!c.isAllTypes?c.includesImages&&1===c.categories.length&&"image"===c.categories[0]:1===v.length&&"image"===v[0],w=e=>{if(t(e),e){const t=URL.createObjectURL(e);l(t)}else l(null)};return F.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-6","aria-label":x?"Subir imagen desde dispositivo":"Subir archivo desde dispositivo",children:[F.jsxs("label",{htmlFor:"file-input",className:"lb:w-full lb:max-w-full lb:flex lb:flex-col lb:items-center lb:justify-center lb:border-2 lb:border-dashed lb:rounded-xl lb:p-8 lb:cursor-pointer lb:transition lb:box-border "+(m?"lb:border-brand-blue-1000 lb:bg-brand-blue-100 lb:scale-[1.02]":"lb:border-brand-blue-200 lb:hover:border-brand-blue-1000 lb:hover:to-bright-blue-200 lb:hover:from-brand-blue-50 lb:focus-within:border-brand-blue-800 lb:from-bright-blue-50 lb:to-brand-blue-50 lb:bg-linear-to-br"),tabIndex:0,style:{outline:"none"},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),o||h(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),e.currentTarget.contains(e.relatedTarget)||h(!1)},onDrop:e=>{if(e.preventDefault(),e.stopPropagation(),h(!1),o)return;const t=e.dataTransfer?.files;if(t&&t.length>0){const e=t[0];(e=>{if(!e||!e.type)return!1;if(c&&!c.isAllTypes)return function(e,t){if(!t||t.isAllTypes)return!0;if(!e)return!1;if(t.mimeTypes.includes(e))return!0;for(const n of t.categories)if(e.startsWith(n+"/"))return!0;return!1}(e.type,c);if(f.has(e.type))return!0;for(const t of v)if("image"===t&&e.type.startsWith("image/")||"video"===t&&e.type.startsWith("video/")||"audio"===t&&e.type.startsWith("audio/"))return!0;return!1})(e)&&w(e)}},children:[F.jsx("span",{className:"icon icon-upload icon--lg lb:mb-2","aria-hidden":"true"}),F.jsx("span",{className:"lb:font-medium lb:text-brand-blue-1000 lb:mb-1",children:x?"Haz clic o arrastra una imagen aqui":"Haz clic o arrastra un archivo aqui"}),F.jsxs("span",{className:"lb:text-sm lb:text-neutral-700",children:["Formatos permitidos: ",F.jsx("span",{className:"lb:truncate lb:wrap-",children:g})]}),F.jsx("input",{id:"file-input",ref:r,type:"file",accept:p,onChange:e=>{const t=e.target.files[0];w(t)},disabled:o,className:"lb:sr-only","aria-label":x?"Seleccionar imagen":"Seleccionar archivo"})]}),e&&F.jsx(Ze,{file:e,onDiscard:()=>{t(null),l(null),r.current&&(r.current.value="")},onDownload:()=>{},onSelect:t=>{if(e&&!o&&a)if(t&&t!==e.name){const n=new File([e],t,{type:e.type});a(n)}else a(e)},showRetry:!1,disabled:o,selectedFolder:u,onFolderChange:d,folderConfig:b})]})}const rt="/api";const at=new Map;function ot(e=!1){const[t,n]=y.useState([]),[l,r]=y.useState(!0),[a,o]=y.useState(null);y.useEffect(()=>{const t=`ai-services-${e}`,l=at.get(t),a=Date.now();if(l&&a-l.timestamp<864e5)return n(l.data),void r(!1);let i=!0;return(async()=>{try{const l=await function(e=!1){return ce({endpoint:"/ai/services",prod:e,basePath:rt})}(e);if(!i)return;const r=l?.data||l?.result||[],o=Array.isArray(r)?r.map(e=>({label:e.name||e.label,slug:e.slug,type:e.type,description:e.description,image:e.image,costInfo:e.cost_info||null,supportsImageInput:e.supports_image_input||!1})):Object.entries(r).map(([e,t])=>({label:e,slug:t,type:"image_generation",description:null,image:null,costInfo:null,supportsImageInput:!1}));n(o),at.set(t,{data:o,timestamp:a})}catch(l){i&&o(l.message)}finally{i&&r(!1)}})(),()=>{i=!1}},[e]);return{services:t,loading:l,error:a,invalidateCache:()=>{at.delete(`ai-services-${e}`)}}}const it=new Map;function st(e=!1){const[t,n]=y.useState(null),[l,r]=y.useState(!1),[a,o]=y.useState(null);return{params:t,loading:l,error:a,fetchParams:async t=>{r(!0),o(null);const l=`${e}-${t}`,a=Date.now(),i=it.get(l);if(i&&a-i.timestamp<864e5)return n(i.data),r(!1),i.data;try{const r=await function({services:e=null,form:t=!1}={},n=!1){const l={};return e&&(l.services=e),!1!==t&&(l.form=t),ce({endpoint:"/ai/params"+(Object.keys(l).length?"?"+new URLSearchParams(l).toString():""),method:"GET",prod:n,basePath:"/api/atenea"})}({services:t,form:!1},e),o=r?.result?.data||r?.data||r?.result||r;return n(o),it.set(l,{data:o,timestamp:a}),o}catch(s){return o(s.message),n(null),null}finally{r(!1)}},reset:()=>{o(null),n(null)}}}function ct({show:e=!1,message:t="Cargando...",className:n=""}){return e?F.jsx("div",{className:`lb:absolute lb:inset-0 lb:min-h-50 lb:bg-white/80 lb:backdrop-blur-sm lb:z-50 lb:flex lb:flex-col lb:items-center lb:justify-center ${n}`,"aria-live":"polite","aria-busy":"true",role:"status",children:F.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-4",children:[F.jsx("span",{className:"icon icon-spinner lb:p-4 lb:animate-spin"}),F.jsx("p",{className:"lb:text-brand-blue-1000 lb:font-medium lb:text-lg",children:t})]})}):null}function ut({image:e,onDiscard:t,onRetry:n,onDownload:l,onSelect:r,showRetry:a=!1,disabled:o=!1,selectedFolder:i=null,onFolderChange:s=null,folderConfig:c=null}){const[u,d]=y.useState(null),[b,m]=y.useState({name:"",size:"",type:""}),[h,p]=y.useState(!1),[f,g]=y.useState(!1),[v,x]=y.useState("");y.useEffect(()=>{if(!e)return void d(null);const t=URL.createObjectURL(e);d(t);const n=e.name||"imagen.webp",l=(e=>{const t=e?.split(".")[0]?.toLowerCase()||"";return["ai-image","ai_image","generated","imagen-ia","imagen_ia"].some(e=>t.startsWith(e))})(n);return m({name:n,size:w(e.size||0),type:e.type||"image/webp"}),l?(x(""),g(!1)):x(n.split(".")[0]),()=>{URL.revokeObjectURL(t)}},[e]);const w=e=>{if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(1024));return Math.round(e/Math.pow(1024,t)*100)/100+" "+["Bytes","KB","MB","GB"][t]};return e&&u?F.jsxs("div",{className:"lb:w-full lb:max-w-full lb:bg-white lb:border lb:border-gray-200 lb:rounded-lg lb:px-1 lb:sm:px-3 lb:py-2 lb:m-0 lb:shadow-sm lb:overflow-hidden lb:box-border",children:[F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between lb:mb-4 lb:px-1",children:[F.jsx("h3",{className:"lb:text-sm lb:font-medium lb:text-gray-700",children:"Vista previa de imagen"}),F.jsx("button",{type:"button",onClick:t,disabled:o,className:"lb:p-1.5 lb:text-gray-400 lb:cursor-pointer lb:hover:text-gray-600 lb:hover:bg-red-300 lb:rounded lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed","aria-label":"Descartar imagen",title:"Descartar imagen",children:F.jsx("span",{className:"icon icon-close-small icon--md"})})]}),c?.showFolderSelector&&s&&F.jsx("div",{className:"lb:mb-4 lb:px-1",children:F.jsx(We,{value:i?.slug||i,onChange:s,allowCreate:!1!==c?.allowCreateFolder,label:"Guardar en carpeta",showAssetCount:!0,allowedSlugs:c?.include?.length>0?c.include:null,mode:"upload",disabled:o})}),F.jsxs("div",{className:"lb:flex lb:flex-col lb:justify-center lb:md:flex-row lb:gap-2 lb:md:gap-6",children:[F.jsxs("div",{className:"lb:flex-1 lb:md:flex-[0.4] lb:flex lb:flex-col lb:items-center lb:justify-center",children:[F.jsxs("div",{className:"lb:relative lb:w-full lb:max-w-md lb:aspect-video lb:bg-gray-100 lb:rounded-lg lb:overflow-hidden lb:cursor-zoom-in lb:hover:ring-2 lb:hover:ring-brand-blue-800 lb:transition-all",onClick:()=>p(!0),role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),p(!0))},"aria-label":"Click para ver imagen en tamaño completo",title:"Click para ver en tamaño completo",children:[F.jsx("img",{src:u,alt:"Vista previa",className:"lb:absolute lb:inset-0 lb:w-full lb:h-full lb:object-contain"}),F.jsxs("div",{className:"lb:absolute lb:top-2 lb:right-2 lb:bg-black/50 lb:text-white lb:px-2 lb:py-1 lb:rounded lb:text-xs lb:flex lb:items-center lb:gap-1",children:[F.jsx("span",{className:"icon icon-search-white icon--xs"}),F.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Ampliar"})]})]}),F.jsx("div",{className:"lb:mt-3 lb:text-center lb:space-y-1 lb:w-full",children:F.jsx("div",{className:"lb:rounded-sm lb:w-fit lb:gap-0.5 lb:p-0.5 lb:min-w-fit lb:mx-auto",children:F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-center lb:gap-3 lb:text-xs lb:text-gray-500",children:[F.jsx("span",{children:b.size}),F.jsx("span",{children:"•"}),F.jsx("span",{children:b.type.split("/")[1]?.toUpperCase()||"IMAGE"})]})})})]}),F.jsxs("div",{className:"lb:flex lb:flex-row lb:md:flex-col lb:gap-2 lb:justify-items-stretch lb:justify-center lb:md:justify-start lb:items-stretch lb:md:min-w-35",children:[F.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-1",children:[F.jsxs("label",{htmlFor:"uploadImageId",className:"lb:flex lb:items-center lb:w-fit",children:[F.jsx("span",{className:"lb:me-1 lb:text-sm",children:"Nombre:"}),F.jsx("input",{id:"uploadImageId",onChange:e=>(e=>{const t=e.target.value.trim();x(e.target.value);const n=X(t||"_");n.valid?t.length>0&&g(!1):g(n.error);const l=b.name,r=l.lastIndexOf("."),a=-1!==r?l.substring(r):".webp";m(e=>({...e,name:t?t+a:a}))})(e),value:v,className:"limbo-input-image-name lb:w-fit lb:px-1 lb:text-sm lb:font-medium lb:text-gray-800 lb:border lb:rounded lb:truncate lb:focus:outline lb:focus:outline-neutral-gray-100 lb:focus:transform-none lb:focus:shadow-none lb:focus:opacity-100 "+(f?"lb:border-red-1000 lb:bg-red-50":"lb:border-gray-300"),placeholder:"Escribe un nombre...",title:"El nombre es obligatorio",required:!0})]}),f&&F.jsx("span",{className:"lb:text-xs lb:text-red-1000 lb:ml-1",children:"string"==typeof f?f:"El nombre es obligatorio"})]}),a&&n&&F.jsxs("button",{type:"button",onClick:n,disabled:o,className:"lb:flex-1 lb:md:flex-none lb:flex lb:items-center lb:justify-center lb:gap-2 lb:px-4 lb:py-2.5 lb:bg-white lb:border lb:border-gray-300 lb:text-gray-700 lb:rounded-lg lb:hover:bg-gray-50 lb:cursor-pointer lb:hover:border-gray-400 lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed lb:text-sm lb:font-medium","aria-label":"Intentarlo de nuevo",title:"Generar de nuevo con el mismo prompt",children:[F.jsx("span",{className:"icon icon-refresh icon--sm"}),F.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Reintentar"}),F.jsx("span",{className:"lb:sm:hidden",children:"Retry"})]}),F.jsxs("button",{type:"button",onClick:()=>{if(!u||o)return;const e=document.createElement("a");e.href=u,e.download=b.name,document.body.appendChild(e),e.click(),document.body.removeChild(e),l&&l()},disabled:o,className:"lb:flex-1 lb:cursor-pointer lb:md:flex-none lb:flex lb:items-center lb:justify-center lb:gap-2 lb:px-4 lb:py-2.5 lb:bg-white lb:border lb:border-gray-300 lb:text-gray-700 lb:rounded-lg lb:hover:bg-gray-50 lb:hover:border-gray-400 lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed lb:text-sm lb:font-medium","aria-label":"Descargar imagen",children:[F.jsx("span",{className:"icon icon-download icon--sm"}),F.jsx("span",{children:"Descargar"})]}),F.jsxs("button",{type:"button",onClick:()=>{const e=v.trim();if(!e)return void g("El nombre no puede estar vacío");const t=X(e);t.valid?(g(!1),r&&r(b.name)):g(t.error)},disabled:o,className:"lb:flex-1 lb:md:flex-none lb:flex lb:items-center lb:justify-center lb:gap-2 lb:px-4 lb:py-2.5 lb:bg-brand-blue-800 lb:border lb:border-brand-blue-800 lb:text-white lb:rounded-lg lb:hover:bg-brand-blue-1000 lb:cursor-pointer lb:hover:border-brand-blue-1000 lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed lb:text-sm lb:font-medium lb:shadow-sm","aria-label":"Seleccionar imagen para recortar",children:[F.jsx("span",{className:"icon icon-tick-white icon--sm"}),F.jsx("span",{children:"Seleccionar"})]})]})]}),F.jsx(Pe,{isOpen:h,src:u,alt:b.name,title:b.name,subtitle:`${b.size} • ${b.type.split("/")[1]?.toUpperCase()||"IMAGE"}`,onClose:()=>p(!1)})]}):null}function dt({prod:e,disabled:t,onSelect:n,selectedFolder:l,onFolderChange:r,folderConfig:a}){const o=ot(e),i=st(e),[s,c]=y.useState(""),[u,d]=y.useState(""),[b,m]=y.useState({}),[h,p]=y.useState(!1),[f,g]=y.useState(null),[x,w]=y.useState(null),[k,C]=y.useState(null),[S,j]=y.useState(!0),[N,E]=y.useState(!1),[$,_]=y.useState(null),[T,z]=y.useState(null),[L,A]=y.useState(!1),M=v.useRef(null),P=v.useRef(0);v.useEffect(()=>{if(!o.loading&&1===o.services.length){const e=o.services[0];d(e.slug),j(!1),i.fetchParams(e.slug,!0)}},[o.loading,o.services]),v.useEffect(()=>{if(!u)return;const e=i.params?.[u]?.parameters;if(e){const t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default??""]));t.service=u,m(t)}},[u,i.params]);const I=v.useMemo(()=>{const e=o.services.find(e=>e.slug===u);if(e?.supportsImageInput)return!0;const t=i.params?.[u]?.parameters;return!!t&&Object.entries(t).some(([e,t])=>"image"===t.type||"file"===t.type||"image_data"===e||"image"===e||"reference_image"===e)},[u,o.services,i.params]),D=e=>{e&&(["image/jpeg","image/png","image/webp"].includes(e.type)?e.size>4194304?g("La imagen de referencia no puede superar los 4MB."):(_(e),z(URL.createObjectURL(e)),g(null)):g("Formato no soportado. Usa JPG, PNG o WebP."))},O=e=>{D(e.target.files?.[0])},R=e=>{e.preventDefault(),e.stopPropagation(),P.current++,A(!0)},U=e=>{e.preventDefault(),e.stopPropagation(),P.current--,0===P.current&&A(!1)},B=e=>{e.preventDefault(),e.stopPropagation()},W=e=>{e.preventDefault(),e.stopPropagation(),P.current=0,A(!1);const t=e.dataTransfer?.files?.[0];D(t)},q=()=>{_(null),T&&URL.revokeObjectURL(T),z(null),M.current&&(M.current.value="")};v.useEffect(()=>()=>{T&&URL.revokeObjectURL(T)},[T]);const V=e=>{const{name:t,value:n}=e.target;m(e=>({...e,[t]:n}))},H=async(t,n=!1)=>{t.preventDefault(),p(!0),g(null),w(null);try{n?b.prompt=s:c(b.prompt||"");let t={...b};$&&(t.image=await(l=$,new Promise((e,t)=>{const n=new FileReader;n.onload=()=>e(n.result),n.onerror=t,n.readAsDataURL(l)})));const a=await function(e,t=!1){return ce({endpoint:"/ai/generate",method:"POST",body:e,prod:t,basePath:rt})}(t,e);let o=null;if(a?.data?.images&&Array.isArray(a.data.images)&&a.data.images.length>0?o=a.data.images[0]:a?.result?.images&&Array.isArray(a.result.images)&&a.result.images.length>0?o=a.result.images[0]:Array.isArray(a)&&a.length>0?o=a[0]:"string"==typeof a&&(o=a),!o)throw new Error("No se pudo extraer la imagen de la respuesta");if(o.startsWith("http"))try{const e=`${window.limboCore?.config?.getGlobal()?.prod?"https://limbo.lefebvre.es":"https://led-dev-limbo-dev.eu.els.local"}/api/atenea/proxy?url=${encodeURIComponent(o)}`,t=await fetch(e,{credentials:"include",headers:{Authorization:`Bearer ${window.limboCore?.apiClient?.token||""}`}});if(!t.ok)throw new Error(`Failed to download image: ${t.status}`);const n=await t.blob(),l=new File([n],"ai-image.webp",{type:n.type||"image/webp"});C(l)}catch(r){throw new Error(`Error downloading image via proxy: ${r.message}`)}else{const e=o.replace(/^data:image\/\w+;base64,/,""),t=atob(e),n=new Array(t.length);for(let a=0;a<t.length;a++)n[a]=t.charCodeAt(a);const l=new Uint8Array(n),r=new File([l],"ai-image.webp",{type:"image/webp"});C(r)}w(a?.data?.images||a?.result?.images||null)}catch(a){g(a.message||"Error al generar la imagen")}finally{p(!1)}var l};return o.loading?F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-center lb:py-8",children:[F.jsx("span",{className:"limbo-loader lb:mr-2"})," Cargando servicios IA..."]}):o.services.length?F.jsx("div",{className:"lb:flex lb:flex-col lb:mx-4 lb:pb-2",children:S?F.jsxs(F.Fragment,{children:[F.jsx("h3",{id:"aiSelectDescription",className:"lb:text-2xl lb:font-semibold lb:text-brand-blue-1000 lb:mb-3",children:"Selecciona el modelo IA"}),o.error&&F.jsx(Ge,{variant:"danger",children:o.error}),F.jsx("div",{className:"lb:flex lb:flex-row lb:flex-wrap lb:justify-around lb:items-stretch lb:justify-items-stretch lb:content-stretch lb:gap-3 lb:w-full lb:max-w-7xl",children:o.services.map(e=>F.jsxs("button",{type:"button",onClick:()=>{d(e.slug),j(!1),m({}),w(null),g(null),C(null),i.fetchParams(e.slug,!0)},disabled:o.loading||t,className:`lb:group lb:relative lb:p-4 lb:rounded-lg lb:border-2 lb:transition-all lb:duration-200 lb:overflow-hidden lb:flex lb:flex-col lb:items-center lb:justify-center lb:min-h-30 lb:grow basis-sm lb:min-w-70 lb:border-gray-200 lb:hover:border-brand-blue-800 lb:hover:shadow-md lb:hover:text-black lb:lg:w-min ${o.loading||t?"lb:opacity-50 lb:cursor-not-allowed":"lb:cursor-pointer"} `,style:{position:"relative"},children:[e.image&&F.jsx("div",{className:"lb:absolute lb:inset-0 lb:bg-cover lb:bg-center lb:transition-opacity lb:duration-200 lb:group-hover:opacity-35",style:{backgroundImage:`url(${e.image})`,opacity:.2}}),F.jsxs("div",{className:"lb:relative lb:z-10 lb:flex lb:flex-col lb:items-center lb:justify-center lb:gap-2 lb:text-center",children:[F.jsx("span",{className:"lb:text-base lb:font-semibold lb:text-neutral-black-000",children:e.label}),e.description&&F.jsx("span",{className:"lb:text-sm lb:text-gray-950 lb:line-clamp-2 lb:drop-shadow lb:drop-shadow-neutral-white-000",children:e.description})]}),e.costInfo&&F.jsx("span",{className:"lb:absolute lb:top-0 lb:left-1 lb:inline-flex lb:items-center lb:gap-1 lb:py-0 lb:px-1 lb:mt-1 lb:text-xs lb:font-medium lb:text-warning-1000 lb:rounded-md lb:group-hover:bg-white/90",style:{zoom:"82%"},children:e.costInfo})]},e.slug))})]}):F.jsxs(F.Fragment,{children:[F.jsxs("div",{className:"lb:flex lb:flex-wrap lb:items-center lb:gap-3 lb:mb-2",children:[F.jsx("h3",{className:"lb:text-2xl lb:font-semibold lb:text-brand-blue-1000",children:o.services.find(e=>e.slug===u)?.label||"Generación IA"}),o.services.find(e=>e.slug===u)?.costInfo&&F.jsxs("div",{title:"Coste estimado por imagen que le cuesta a la empresa, este coste depende de la calidad de la imagen generada y puede variar según el proveedor IA, ten en cuenta este coste para hacer un uso más responsable del servicio IA",className:"lb:flex lb:items-center lb:gap-1","aria-description":"Coste estimado por imagen que le cuesta a la empresa, este coste depende de la calidad de la imagen generada y puede variar según el proveedor IA, ten en cuenta este coste para hacer un uso más responsable del servicio IA",children:[F.jsxs("span",{className:"lb:inline-flex lb:items-center lb:gap-1 lb:px-2 lb:py-0.5 lb:text-xs lb:font-medium lb:text-warning-1000 lb:bg-yellow-200/60 lb:rounded-full lb:border lb:border-warning-1000 lb:select-none",children:[F.jsx("span",{className:"icon icon-euro-blue icon--2sm icon--warning",style:{filter:"var(--limbo-icon-warning-dark)"}}),"Coste:"," ",o.services.find(e=>e.slug===u)?.costInfo]}),F.jsx("span",{className:"icon icon-info lb:cursor-help"})]})]}),i.loading&&F.jsx("div",{children:"Cargando parámetros..."}),i.error&&F.jsx(Ge,{variant:"danger",children:i.error}),u&&(()=>{const e=i.params?.[u]?.parameters;if(!e)return null;const n=Object.entries(e).filter(([e,t])=>!t.hidden&&"image"!==t.type&&"file"!==t.type),l=n.filter(([e])=>e.toLowerCase().includes("prompt")||e.toLowerCase().includes("query")),r=n.filter(([e])=>!e.toLowerCase().includes("prompt")&&!e.toLowerCase().includes("query")),a=(e,n)=>{let l=n.placeholder||"";l||(l="integer"===n.type?n.minValue&&n.maxValue?`Entre ${n.minValue} y ${n.maxValue}`:n.minValue?`Mínimo ${n.minValue}`:n.maxValue?`Máximo ${n.maxValue}`:"Introduce un número":e.toLowerCase().includes("prompt")?"Describe la imagen que deseas generar...":e.toLowerCase().includes("negative")?"Elementos a evitar en la imagen...":`Introduce ${(n.label||e).toLowerCase()}`);const r=e.toLowerCase().includes("prompt")||e.toLowerCase().includes("query");return F.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-1",children:[F.jsxs("label",{htmlFor:`ai-${e}`,className:"lb:text-xs lb:font-medium lb:text-brand-blue-1000",children:[n.label||e,n.required&&F.jsx("span",{className:"lb:text-red-1000 lb:ml-1",children:"*"})]}),n.options?F.jsx("select",{id:`ai-${e}`,name:e,value:b[e]??"",onChange:V,className:"limbo-input",disabled:t,title:n.label||e,children:n.options.map(e=>F.jsx("option",{value:e,children:e},e))}):r?F.jsx("textarea",{id:`ai-${e}`,name:e,value:b[e]??"",onChange:V,className:"limbo-input lb:resize-none lb:overflow-y-auto",disabled:t,required:n.required,placeholder:l,title:n.label||e,rows:3,style:{maxHeight:"9rem",minHeight:"3rem"},onInput:e=>{e.target.style.height="auto";const t=Math.min(e.target.scrollHeight,144);e.target.style.height=`${t}px`}}):F.jsx("input",{id:`ai-${e}`,type:"integer"===n.type?"number":"text",name:e,value:b[e]??"",onChange:V,className:"limbo-input",disabled:t,required:n.required,min:n.minValue,max:n.maxValue,placeholder:l,title:n.label||e})]},e)};return F.jsxs("div",{className:"lb:h-fit lb:w-full",children:[o.services.length>1&&F.jsxs("button",{type:"button",onClick:()=>{j(!0),d(""),m({}),w(null),g(null),C(null),q()},className:"lb:flex lb:cursor-pointer lb:items-center lb:gap-2 lb:text-brand-blue-800 lb:hover:text-brand-blue-1000 lb:mb-4 lb:font-medium",children:[F.jsx("span",{className:"icon icon-arrow-left"}),"Volver al menú de servicios"]}),F.jsxs("div",{className:"lb:relative",children:[F.jsxs("form",{onSubmit:H,"data-type":"ai",className:"lb:flex lb:flex-col lb:gap-3 lb:mt-4 lb:border-t lb:pt-4 lb:border-brand-blue-200","aria-label":"Formulario generación IA",children:[f&&F.jsx(Ge,{variant:"danger",className:"lb:mb-2",children:f}),F.jsx("div",{className:"lb:flex lb:flex-col lb:gap-3",children:l.map(([e,t])=>a(e,t))}),I&&F.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-2 lb:mt-1",children:[F.jsxs("label",{className:"lb:text-xs lb:font-medium lb:text-brand-blue-1000",children:["Imagen de referencia",F.jsx("span",{className:"lb:text-neutral-gray-500 lb:ml-1 lb:font-normal",children:"(opcional)"})]}),$?F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-3 lb:p-2 lb:bg-neutral-gray-50 lb:border lb:border-neutral-gray-200 lb:rounded-lg",children:[F.jsx("div",{className:"lb:w-16 lb:h-16 lb:rounded lb:overflow-hidden lb:shrink-0 lb:bg-neutral-gray-100",children:F.jsx("img",{src:T,alt:"Referencia",className:"lb:w-full lb:h-full lb:object-cover"})}),F.jsxs("div",{className:"lb:flex-1 lb:min-w-0",children:[F.jsx("p",{className:"lb:text-sm lb:text-neutral-gray-700 lb:truncate",children:$.name}),F.jsxs("p",{className:"lb:text-xs lb:text-neutral-gray-500",children:[($.size/1024).toFixed(0)," KB"]})]}),F.jsx("button",{type:"button",onClick:q,disabled:t||h,className:"lb:p-1.5 lb:text-neutral-gray-500 lb:cursor-pointer lb:hover:text-red-1000 lb:hover:bg-red-50 lb:rounded lb:transition-colors",title:"Quitar imagen de referencia",children:F.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[F.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),F.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):F.jsxs("label",{className:"lb:flex lb:items-center lb:justify-center lb:gap-2 lb:px-3 lb:py-2.5 lb:border lb:border-dashed lb:rounded-lg lb:cursor-pointer lb:transition-colors lb:text-sm "+(L?"lb:border-brand-blue-800 lb:bg-brand-blue-50/50 lb:text-brand-blue-800":"lb:border-neutral-gray-300 lb:text-neutral-gray-700 lb:hover:border-brand-blue-800 lb:hover:bg-brand-blue-50/30"),onDragEnter:R,onDragLeave:U,onDragOver:B,onDrop:W,children:[F.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[F.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),F.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),F.jsx("polyline",{points:"21 15 16 10 5 21"})]}),L?"Suelta la imagen aquí":"Subir imagen de referencia",F.jsx("input",{ref:M,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:O,disabled:t||h,className:"lb:sr-only"})]})]}),r.length>0&&F.jsxs("div",{className:"lb:border-t lb:border-gray-200 lb:pt-3",children:[F.jsxs("button",{type:"button",onClick:()=>E(!N),className:"lb:flex lb:items-center lb:gap-2 lb:text-sm lb:font-medium lb:text-brand-blue-800 lb:hover:text-brand-blue-1000 lb:mb-3 lb:transition-colors",children:[F.jsx("svg",{className:"lb:w-4 lb:h-4 lb:transition-transform "+(N?"lb:rotate-90":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),"Opciones avanzadas",!N&&F.jsxs("span",{className:"lb:text-xs lb:text-gray-500",children:["(",r.length," opciones)"]})]}),N&&F.jsx("div",{className:"lb:grid lb:grid-cols-2 lb:lg:grid-cols-3 lb:xl:grid-cols-4 lb:gap-3 lb:animate-fadeIn",children:r.map(([e,t])=>a(e,t))})]}),F.jsx("button",{type:"submit",disabled:h||t,title:h?"Generando imagen...":k?"Generar otra imagen":"Generar imagen",className:"limbo-btn lb:w-full lb:mt-2 "+(h?"lb:cursor-not-allowed limbo-btn-disabled":"limbo-btn-primary"),style:{minHeight:44},children:h?"Generando imagen...":k?"Generar otra imagen":"Generar imagen"})]}),F.jsx(ct,{show:h,message:"Generando imagen con IA..."})]})]})})(),k&&F.jsx("div",{className:"lb:mt-6 lb:md:w-full lb:mx-auto",children:F.jsx(ut,{image:k,onDiscard:()=>{C(null),w(null),g(null)},onRetry:e=>H(e,!0),onDownload:()=>{},onSelect:e=>{if(n){const t=k||x;if(e&&t&&e!==t.name){const l=new File([t],e,{type:t.type});n(l)}else n(t)}},showRetry:!0,disabled:h||t,selectedFolder:l,onFolderChange:r,folderConfig:a})})]})}):F.jsx(Ge,{variant:"warning",children:"No hay servicios IA disponibles."})}const bt="/api";const mt=new Map;function ht(e=!1){const[t,n]=y.useState([]),[l,r]=y.useState(!0),[a,o]=y.useState(null);y.useEffect(()=>{const t=`stock-services-${e}`,l=mt.get(t),a=Date.now();if(l&&a-l.timestamp<864e5)return n(l.data),void r(!1);let i=!0;return(async()=>{try{const l=await function(e=!1){return ce({endpoint:"/stock/services",prod:e,basePath:bt})}(e);if(!i)return;if(204===l?.httpCode||null===l?.data)return n([]),o("No hay servicios de stock disponibles en este momento"),void mt.set(t,{data:[],timestamp:a});const r=l?.data||l?.result||[],s=Array.isArray(r)?r.map(e=>({label:e.name||e.label,slug:e.slug,type:e.type,description:e.description,image:e.image})):Object.entries(r).map(([e,t])=>({label:e,slug:t,type:"stock_image",description:null,image:null}));n(s),mt.set(t,{data:s,timestamp:a})}catch(l){i&&o(l.message)}finally{i&&r(!1)}})(),()=>{i=!1}},[e]);return{services:t,loading:l,error:a,invalidateCache:()=>{mt.delete(`stock-services-${e}`)}}}function pt({prod:e,disabled:t,onSelect:n,selectedFolder:l,onFolderChange:r,folderConfig:a}){const o=v.useRef(null),i=ht(e),s=(e,t)=>{try{const n=sessionStorage.getItem(`limbo_stock_${e}`);return n?JSON.parse(n):t}catch{return t}},[c,u]=y.useState(()=>s("selectedService","")),[d,b]=y.useState(()=>s("dynamicForm",{})),[m,h]=y.useState(()=>s("stockImages",[])),[p,f]=y.useState(()=>s("currentPage",1)),[g,x]=y.useState(()=>s("paginationInfo",null)),[w,k]=y.useState(null),C=st(e),[S,j]=y.useState(!1),[N,E]=y.useState(null),[$,_]=y.useState(null),[T,z]=y.useState(!0),[L,A]=y.useState(!1),[M,P]=y.useState(null);v.useEffect(()=>{sessionStorage.setItem("limbo_stock_selectedService",JSON.stringify(c))},[c]),v.useEffect(()=>{sessionStorage.setItem("limbo_stock_dynamicForm",JSON.stringify(d))},[d]),v.useEffect(()=>{sessionStorage.setItem("limbo_stock_stockImages",JSON.stringify(m))},[m]),v.useEffect(()=>{sessionStorage.setItem("limbo_stock_currentPage",JSON.stringify(p))},[p]),v.useEffect(()=>{sessionStorage.setItem("limbo_stock_paginationInfo",JSON.stringify(g))},[g]),v.useEffect(()=>{if(!i.loading&&1===i.services.length){const e=i.services[0];u(e.slug),z(!1),C.fetchParams(e.slug,!0)}},[i.loading,i.services]),v.useEffect(()=>{if(!c)return;const e=C.params?.[c]?.parameters;if(e){const t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default??""]));t.service=c,b(t)}},[c,C.params]);const I=e=>{const{name:t,value:n}=e.target;b(e=>({...e,[t]:n}))},D=async(t=1)=>{j(!0),E(null),1===t&&h([]);try{let n;if(1===t){const e=C.params?.[c]?.parameters,l={...d};Object.entries(e||{}).forEach(([e,t])=>{e in l||(l[e]=t.default??"")}),l.per_page=parseInt(l.per_page),l.service=c,l.page=t,n=l,o.current={...l}}else n={...o.current,page:t};const l=await function(e,t=!1){return ce({endpoint:"/stock/search",method:"POST",body:e,prod:t,basePath:bt})}(n,e),r=l?.data?.images||[];let a=l?.data?.pagination||null,i=null;a&&(i={total:a.total_count??a.total??r.length,per_page:a.per_page??(Array.isArray(r)?r.length:0),current_page:a.page??a.current_page??t}),h(O(Array.isArray(r)?r:[])),x(i),f(i?.current_page||t)}catch(n){E(n.message||"Error al buscar imágenes")}finally{j(!1)}},O=e=>{const t=new Set,n=[];return(e||[]).forEach((e,l)=>{const r=e.url||e.preview_url||e.full||e.preview;r&&!t.has(r)&&(t.add(r),n.push({...e,preview:e.preview_url||e.preview||e.url||e.full,full:e.url||e.full||e.preview_url,id:e.id||l,title:e.title||e.filename||`Imagen ${l+1}`,source:e.service||c,sourceTitle:i.services.find(e=>e.slug===c)?.label||c}))}),n},R=async e=>{e.preventDefault();const t=d.query||d.search||d.term||"";t.trim().length<5?E("La búsqueda debe tener al menos 5 caracteres"):(k(t),await D(1))},U=e=>{e<1||D(e)},B=async t=>{_(t.id),E(null);try{const n={service:c,image_id:t.id},l=await function(e,t=!1){return ce({endpoint:"/stock/download",method:"POST",body:e,prod:t,basePath:bt})}(n,e),r=l?.result?.url||l?.result?.download_url||l?.data?.images?.url||l?.data?.url||l?.images?.url||l?.url;if(!r)throw console.error("Download response structure:",l),new Error("No se pudo obtener la URL de descarga");{const n=`${ie({prod:e})}/api/atenea/proxy?url=${encodeURIComponent(r)}`,a=await fetch(n,{credentials:"include",headers:{Authorization:`Bearer ${se().token||""}`}});if(!a.ok)throw new Error(`Error al descargar imagen: ${a.status}`);const o=await a.blob(),i=l?.result?.filename||l?.data?.images?.filename||l?.data?.filename||`stock-${t.id}.jpg`,s=new File([o],i,{type:o.type||"image/jpeg"});P(s)}}catch(n){E(n.message||"No se pudo recuperar la imagen seleccionada")}finally{_(null)}};return i.loading?F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-center lb:py-8",children:[F.jsx("span",{className:"limbo-loader lb:mr-2"})," Cargando servicios de Stock..."]}):i.services.length?F.jsx("div",{className:"lb:flex lb:flex-col lb:mx-4 lb:pb-2",children:T?F.jsxs(F.Fragment,{children:[F.jsx("h3",{className:"lb:text-2xl lb:font-semibold lb:text-brand-blue-1000 lb:mb-3",children:"Selecciona el servicio de Stock"}),i.error&&F.jsx(Ge,{variant:"danger",children:i.error}),F.jsx("div",{className:"lb:grid lb:grid-cols-2 lb:md:grid-cols-3 lb:gap-3",children:i.services.map(e=>F.jsxs("button",{type:"button",onClick:()=>{u(e.slug),z(!1),b({}),h([]),f(1),x(null),E(null),C.fetchParams(e.slug,!0)},disabled:i.loading||t,className:`lb:group lb:relative lb:p-4 lb:rounded-lg lb:border-2 lb:transition-all lb:duration-200 lb:overflow-hidden lb:flex lb:flex-col lb:items-center lb:justify-center lb:min-h-30 lb:border-gray-200 lb:hover:border-brand-blue-300 lb:hover:shadow-md lb:lg:w-min ${i.loading||t?"lb:opacity-50 lb:cursor-not-allowed":"lb:cursor-pointer"} `,style:{position:"relative"},children:[e.image&&F.jsx("div",{className:"lb:absolute lb:inset-0 lb:bg-cover lb:bg-center lb:transition-opacity lb:duration-200 lb:group-hover:opacity-35",style:{backgroundImage:`url(${e.image})`,opacity:.2}}),F.jsxs("div",{className:"lb:relative lb:z-10 lb:flex lb:flex-col lb:items-center lb:justify-center lb:gap-2 lb:text-center",children:[F.jsx("span",{className:"lb:text-base lb:font-semibold lb:text-neutral-black-000",children:e.label}),e.description&&F.jsx("span",{className:"lb:text-sm lb:text-gray-950 lb:line-clamp-2 lb:drop-shadow lb:drop-shadow-neutral-white-000",children:e.description})]})]},e.slug))})]}):F.jsxs(F.Fragment,{children:[F.jsx("h3",{className:"lb:text-2xl lb:font-semibold lb:text-brand-blue-1000",children:i.services.find(e=>e.slug===c)?.label||"Búsqueda Stock"}),C.loading&&F.jsx("div",{children:"Cargando parámetros..."}),C.error&&F.jsx(Ge,{variant:"danger",children:C.error}),c&&(()=>{const e=C.params?.[c]?.parameters;if(!e)return null;const n=Object.entries(e).filter(([,e])=>!e.hidden),l=n.filter(([e])=>e.toLowerCase().includes("query")||e.toLowerCase().includes("search")||e.toLowerCase().includes("term")),r=n.filter(([e])=>!e.toLowerCase().includes("query")&&!e.toLowerCase().includes("search")&&!e.toLowerCase().includes("term")),a=(e,n)=>{let l=n.placeholder||"";l||(l="integer"===n.type?n.minValue&&n.maxValue?`Entre ${n.minValue} y ${n.maxValue}`:n.minValue?`Mínimo ${n.minValue}`:n.maxValue?`Máximo ${n.maxValue}`:"Introduce un número":e.toLowerCase().includes("query")||e.toLowerCase().includes("search")||e.toLowerCase().includes("term")?"Buscar imágenes...":`Introduce ${(n.label||e).toLowerCase()}`);const r=e.toLowerCase().includes("query")||e.toLowerCase().includes("search")||e.toLowerCase().includes("term");return F.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-1",children:[F.jsxs("label",{htmlFor:`stock-${e}`,className:"lb:text-xs lb:font-medium lb:text-brand-blue-1000",children:[n.label||e,n.required&&F.jsx("span",{className:"lb:text-red-1000 lb:ml-1",children:"*"})]}),n.options&&n.multiple?F.jsx("div",{className:"lb:flex lb:flex-wrap lb:gap-2 lb:min-h-[50px] lb:px-2 lb:justify-between lb:border-2 lb:border-gray-transparent-500 lb:rounded-lg",children:n.options.map(n=>F.jsxs("label",{className:"lb:flex lb:items-center lb:gap-1",children:[F.jsx("input",{type:"checkbox",name:`stock-${e}`,value:n,checked:Array.isArray(d[e])&&d[e].includes(n),onChange:()=>((e,t)=>{b(n=>{const l=Array.isArray(n[e])?n[e]:[];return l.includes(t)?{...n,[e]:l.filter(e=>e!==t)}:{...n,[e]:[...l,t]}})})(e,n),disabled:t}),F.jsx("span",{className:"lb:text-xs",children:n})]},n))}):n.options?F.jsx("select",{id:`stock-${e}`,name:e,value:d[e]??"",onChange:I,className:"limbo-input",disabled:t,title:n.label||e,children:n.options.map(e=>F.jsx("option",{value:e,children:e},e))}):r?F.jsx("textarea",{id:`stock-${e}`,name:e,value:d[e]??"",onChange:I,className:"limbo-input lb:resize-none lb:overflow-y-auto",disabled:t,required:n.required,placeholder:l,title:n.label||e,rows:3,style:{maxHeight:"9rem",minHeight:"3rem"},onInput:e=>{e.target.style.height="auto";const t=Math.min(e.target.scrollHeight,144);e.target.style.height=`${t}px`}}):F.jsx("input",{id:`stock-${e}`,type:"integer"===n.type?"number":"text",name:e,value:d[e]??"",onChange:I,className:"limbo-input",disabled:t,required:n.required,min:n.minValue,max:n.maxValue,placeholder:l,title:n.label||e})]},e)};return F.jsxs("div",{children:[i.services.length>1&&F.jsxs("button",{type:"button",onClick:()=>{z(!0),u(""),b({}),h([]),f(1),x(null),E(null)},className:"lb:flex lb:cursor-pointer lb:items-center lb:gap-2 lb:text-brand-blue-800 lb:hover:text-brand-blue-1000 lb:mb-4 lb:font-medium",children:[F.jsx("span",{className:"icon icon-arrow-left"}),"Volver al menú de servicios"]}),F.jsxs("div",{className:"lb:relative",children:[F.jsxs("form",{onSubmit:R,"data-type":"stock",className:"lb:flex lb:flex-col lb:gap-3 lb:mt-4 lb:border-t-1 lb:pt-4 lb:border-brand-blue-200","aria-label":"Formulario búsqueda de imágenes de Stock",children:[N&&F.jsx(Ge,{variant:"danger",className:"lb:mt-4",children:N}),F.jsx("div",{className:"lb:flex lb:flex-col lb:gap-3",children:l.map(([e,t])=>a(e,t))}),r.length>0&&F.jsxs("div",{className:"lb:border-t lb:border-gray-200 lb:pt-3",children:[F.jsxs("button",{type:"button",onClick:()=>A(!L),className:"lb:flex lb:items-center lb:gap-2 lb:text-sm lb:font-medium lb:text-brand-blue-800 lb:hover:text-brand-blue-1000 lb:mb-3 lb:transition-colors",children:[F.jsx("svg",{className:"lb:w-4 lb:h-4 lb:transition-transform "+(L?"lb:rotate-90":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),"Opciones avanzadas",!L&&F.jsxs("span",{className:"lb:text-xs lb:text-gray-500",children:["(",r.length," opciones)"]})]}),L&&F.jsx("div",{className:"lb:grid lb:grid-cols-1 lb:md:grid-cols-2 lb:gap-3 lb:animate-fadeIn",children:r.map(([e,t])=>a(e,t))})]}),F.jsx("button",{type:"submit",disabled:S||t,className:"limbo-btn lb:w-full lb:mt-2 "+(S?"lb:cursor-not-allowed limbo-btn-disabled":"limbo-btn-primary"),style:{minHeight:44},children:S?"Buscando...":"Buscar imágenes"})]}),F.jsx(ct,{show:S&&!m.length,message:"Buscando imágenes..."})]})]})})(),M&&F.jsx("div",{className:"lb:mt-6 lb:md:w-full lb:mx-auto",children:F.jsx(ut,{image:M,onDiscard:()=>{P(null),E(null)},onDownload:()=>{},onSelect:e=>{if(n)if(e&&M&&e!==M.name){const t=new File([M],e,{type:M.type});n(t)}else n(M)},showRetry:!1,disabled:t,selectedFolder:l,onFolderChange:r,folderConfig:a})}),!M&&m.length>0&&F.jsxs(F.Fragment,{children:[F.jsxs("div",{className:"lb:mt-6 lb:grid lb:grid-cols-2 lb:md:grid-cols-3 lb:lg:grid-cols-4 lb:gap-1 lb:relative","aria-live":"polite",children:[F.jsx(ct,{show:S,message:"Cargando imágenes..."}),m.map((e,n)=>F.jsx("div",{className:"lb:group lb:border lb:border-brand-blue-200 lb:rounded-sm lb:overflow-hidden lb:bg-white lb:shadow-sm lb:hover:shadow-md lb:transition-all lb:duration-200 lb:cursor-pointer",title:"Seleccionar imagen",onClick:()=>!$&&!S&&!t&&B(e),children:F.jsxs("div",{className:"lb:relative lb:aspect-video lb:bg-neutral-100",children:[F.jsx("img",{src:e.preview||e.thumbnail||e.url,alt:e.title||`Resultado ${n+1}`,className:"lb:object-cover lb:w-full lb:h-full",loading:"lazy"}),$===e.id?F.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-white/90 lb:flex lb:flex-col lb:items-center lb:justify-center lb:gap-2",children:[F.jsxs("div",{className:"lb:relative lb:w-10 lb:h-10",children:[F.jsx("div",{className:"lb:absolute lb:inset-0 lb:border-4 lb:border-brand-blue-200 lb:rounded-full"}),F.jsx("div",{className:"lb:absolute lb:inset-0 lb:border-4 lb:border-brand-blue-800 lb:rounded-full lb:border-t-transparent lb:animate-spin"})]}),F.jsx("span",{className:"lb:text-sm lb:font-medium lb:text-brand-blue-1000",children:"Descargando..."})]}):F.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-brand-blue-800/0 lb:group-hover:bg-brand-blue-800/50 lb:transition-colors lb:duration-200 lb:flex lb:items-center lb:justify-center lb:flex-col",children:[F.jsx("span",{className:"icon icon-round-check-filled-blue icon--2xl lb:max-w-full lb:max-h-full lb:opacity-0 lb:group-hover:opacity-100 lb:transition-opacity lb:duration-200"}),F.jsx("span",{style:{textShadow:"1px 0 #001978, -1px 0 #001978, 0 1px #001978, 0 -0.5px #001978, 0.5px 0.5px #001978, -1px -1px #001978, 1px -1px #001978, -1px 1px #001978"},className:"lb:max-w-full lb:max-h-full lb:opacity-0 lb:group-hover:opacity-100 lb:transition-opacity lb:duration-200 lb:text-neutral-white-000",children:"Seleccionar"})]})]})},e.id||n))]}),g&&F.jsxs("div",{className:"lb:mt-6 lb:flex lb:items-center lb:justify-center lb:gap-2",children:[F.jsxs("button",{onClick:()=>U(g.current_page-1),disabled:g.current_page<=1||S,className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(g.current_page<=1||S?" pointer-events-none cursor-default":" limbo-btn-primary"),children:[F.jsx("span",{className:"icon icon-arrow-left-white icon--sm"})," ","Anterior"]}),F.jsxs("span",{className:"lb:px-4 lb:py-2 lb:text-sm lb:text-neutral-700",children:["Página ",g.current_page," de"," ",Math.max(1,Math.ceil(g.total/g.per_page)),F.jsxs("span",{className:"lb:text-xs lb:text-neutral-500 lb:block",children:["(",g.total," imágenes totales)"]})]}),F.jsxs("button",{onClick:()=>U(g.current_page+1),disabled:S||g.current_page>=Math.ceil(g.total/g.per_page),className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(S||g.current_page>=Math.ceil(g.total/g.per_page)?" pointer-events-none cursor-default":" limbo-btn-primary"),children:["Siguiente"," ",F.jsx("span",{className:"icon icon-arrow-right-white icon--sm"})]})]})]}),!S&&0===m.length&&c&&w&&F.jsxs("div",{className:"lb:mt-6 lb:text-center lb:text-neutral-600 lb:py-8 lb:bg-neutral-50 lb:rounded-lg",children:[F.jsx("span",{className:"icon icon-search icon--lg lb:mb-2"}),F.jsxs("p",{children:['No se encontraron imágenes para "',d.query,'"']}),F.jsx("p",{className:"lb:text-sm lb:mt-1",children:"Intenta con otros términos de búsqueda"})]})]})}):F.jsx(Ge,{variant:"warning",children:"No hay servicios de Stock disponibles."})}const ft="/api";const gt=new Map;function yt(e=!1){const[t,n]=y.useState([]),[l,r]=y.useState(!0),[a,o]=y.useState(null);y.useEffect(()=>{const t=`portal-sources-${e}`,l=gt.get(t),a=Date.now();if(l&&a-l.timestamp<864e5)return n(l.data),void r(!1);let i=!0;return(async()=>{try{const l=await function(e=!1,t=!0){const n=new URLSearchParams;return n.set("active",t?"true":"false"),ce({endpoint:`/external/portals?${n.toString()}`,method:"GET",prod:e,basePath:ft})}(e,!0);if(!i)return;let r=l?.data||[];Array.isArray(r)||(r=[]);const o=r.map(e=>({id:e.slug||e.id,numericId:e.id,name:e.name,title:e.name,slug:e.slug,url:e.website_url,image:e.logo_url,isActive:e.is_active}));n(o),gt.set(t,{data:o,timestamp:a})}catch(l){i&&o(l.message)}finally{i&&r(!1)}})(),()=>{i=!1}},[e]);return{sources:t,loading:l,error:a,invalidateCache:()=>{gt.delete(`portal-sources-${e}`)}}}function vt({isOpen:e=!1,video:t,onClose:n,onSelect:l=null}){const[r,a]=y.useState(!1),o=y.useMemo(()=>t?"youtube"===t.platform&&t.video_id?`https://www.youtube.com/embed/${t.video_id}?autoplay=1&rel=0`:"vimeo"===t.platform&&t.video_id?`https://player.vimeo.com/video/${t.video_id}?autoplay=1`:t.embed_url||null:null,[t]),i=y.useMemo(()=>t&&(t.player_url||t.embed_url||t.post_url)||"",[t]),s=y.useCallback(async()=>{if(i)try{await navigator.clipboard.writeText(i),a(!0),setTimeout(()=>a(!1),2e3)}catch{const e=document.createElement("textarea");e.value=i,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e),a(!0),setTimeout(()=>a(!1),2e3)}},[i]),c=y.useCallback(()=>{l&&t&&l(t)},[l,t]);if(!t)return null;const u=[t.portal_name,t.platform].filter(Boolean).join(" · "),d=l?F.jsxs("button",{type:"button",onClick:c,className:"lb:flex lb:items-center lb:gap-2 lb:px-4 lb:py-1.5 lb:rounded-lg lb:bg-brand-blue-800 lb:hover:bg-brand-blue-900 lb:text-white lb:text-sm lb:font-medium lb:transition-colors","aria-label":"Seleccionar video",children:[F.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),F.jsx("span",{children:"Seleccionar"})]}):F.jsx("button",{type:"button",onClick:s,disabled:!i,className:"lb:flex lb:items-center lb:gap-2 lb:px-4 lb:py-1.5 lb:rounded-lg lb:text-sm lb:font-medium lb:transition-colors "+(r?"lb:bg-green-600 lb:text-white":"lb:bg-white/10 lb:hover:bg-white/20 lb:text-white"),"aria-label":"Copiar URL del video",children:r?F.jsxs(F.Fragment,{children:[F.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),F.jsx("span",{children:"Copiado"})]}):F.jsxs(F.Fragment,{children:[F.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"})}),F.jsx("span",{children:"Copiar URL"})]})}),b=F.jsxs("span",{children:[F.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]});return F.jsx(Ce,{isOpen:e,onClose:n,title:t.title||"Video",subtitle:u,ariaLabel:"Vista previa de video externo",headerActions:d,footerHints:b,children:F.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-3 lb:w-full lb:max-w-5xl lb:px-4",children:[F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2 lb:px-4 lb:py-2 lb:bg-amber-500/20 lb:border lb:border-amber-500/40 lb:rounded-lg lb:text-amber-200 lb:text-sm",children:[F.jsx("svg",{className:"lb:w-5 lb:h-5 lb:shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),F.jsxs("span",{children:["Este video no se puede guardar en Limbo — alojado en"," ",F.jsx("strong",{className:"lb:capitalize",children:t.platform||"plataforma externa"})]})]}),F.jsx("div",{className:"lb:relative lb:w-full lb:aspect-video lb:bg-black lb:rounded-lg lb:overflow-hidden",children:o?F.jsx("iframe",{src:o,className:"lb:absolute lb:inset-0 lb:w-full lb:h-full",allow:"autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0,title:t.title||"Video"}):F.jsxs("div",{className:"lb:absolute lb:inset-0 lb:flex lb:flex-col lb:items-center lb:justify-center lb:text-white lb:gap-3",children:[F.jsx("svg",{className:"lb:w-16 lb:h-16 lb:text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"})}),F.jsx("p",{className:"lb:text-sm lb:text-gray-400",children:"No se puede previsualizar este video"}),i&&F.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"lb:text-sm lb:text-brand-blue-400 lb:hover:text-brand-blue-300 lb:underline",children:"Abrir en nueva pestaña"})]})}),i&&F.jsx("p",{className:"lb:text-xs lb:text-gray-500 lb:truncate lb:max-w-full lb:px-2",children:i})]})})}const xt=({src:e,fallbackSrc:t,alt:n,className:l,onError:r})=>{const[a,o]=v.useState("loading"),[i,s]=v.useState(e),[c,u]=v.useState(!1);return"error"===a?null:F.jsxs("div",{className:"lb:relative lb:w-full lb:h-full",children:["loading"===a&&F.jsx("div",{className:"lb:absolute lb:inset-0 lb:bg-linear-to-r lb:from-gray-200 lb:via-gray-100 lb:to-gray-200 lb:animate-pulse lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-spinner lb:w-8 lb:h-8 lb:text-gray-400 lb:animate-spin"})}),F.jsx("img",{src:i,alt:n,className:`${l} ${"loading"===a?"lb:opacity-0":"lb:opacity-100"} lb:transition-opacity lb:duration-300`,loading:"lazy",onLoad:()=>{o("loaded")},onError:()=>{t&&!c?(u(!0),s(t),o("loading")):(o("error"),r&&r())}})]})};function wt({prod:e,disabled:t,onSelect:n,onVideoSelect:l,selectedFolder:r,onFolderChange:a,folderConfig:o,resolvedAccept:i=null,returnConfig:s=null}){const{sources:c,loading:u,error:d}=yt(e),b=y.useMemo(()=>{if(!i||i.isAllTypes)return[{value:"images",label:"Imágenes"},{value:"videos",label:"Vídeos"},{value:"all",label:"Todo"}];const e=[];return i.includesImages&&e.push({value:"images",label:"Imágenes"}),i.includesVideos&&e.push({value:"videos",label:"Vídeos"}),e.length>1&&e.push({value:"all",label:"Todo"}),e.length>0?e:[{value:"images",label:"Imágenes"}]},[i]),m=b[0]?.value||"images",[h,p]=y.useState(null),[f,g]=y.useState(m),[v,x]=y.useState(""),[w,k]=y.useState([]),[C,S]=y.useState(1),[j,N]=y.useState(null),[E,$]=y.useState(!1),[_,T]=y.useState(null),[z,L]=y.useState(null),[A,M]=y.useState(null),[P,I]=y.useState(new Set),[D,O]=y.useState(!1),[R,U]=y.useState(null),B=!!s&&"url"===s.format,W=y.useRef({}),q=y.useCallback((e,t,n,l)=>`${e}_${t}_${n}_${l}`,[]),V=y.useCallback(async(t,n,l,r)=>{const a=q(t,n,l,r),o=W.current[a];if(o)return k(o.items),N(o.pagination),S(r),T(null),void O(!0);$(!0),T(null);try{const o={portal:t,media_type:n,page:r,per_page:20};l.trim()&&(o.search=l.trim());const i=await function(e,t=!1){const n=new URLSearchParams;return e.portal&&n.set("portal",e.portal),e.media_type&&n.set("media_type",e.media_type),e.page&&n.set("page",String(e.page)),n.set("per_page",String(e.per_page)),e.search&&n.set("search",e.search),e.order&&n.set("order",e.order),ce({endpoint:`/external/media?${n.toString()}`,method:"GET",prod:t,basePath:ft})}(o,e),s=i?.data||{},c=s.items||[],u=s.pagination||{total_items:c.length,total_pages:1,current_page:r,per_page:20};W.current[a]={items:c,pagination:u},k(c),N(u),S(r),I(new Set),O(!0),0===c.length&&T("No se encontraron resultados para este portal.")}catch(i){T(i.message||"Error al cargar media del portal"),k([]),N(null),O(!0)}finally{$(!1)}},[e,q]),H=y.useCallback(e=>{e!==h&&(p(e),x(""),g(m),k([]),N(null),T(null),L(null),U(null),I(new Set),O(!1),W.current={})},[h,m]),K=y.useCallback(()=>{p(null),k([]),N(null),T(null),x(""),L(null),U(null),I(new Set),O(!1),W.current={}},[]),G=y.useCallback(()=>{h&&(W.current={},V(h,f,v,1))},[h,f,v,V]),Q=y.useCallback(e=>{"Enter"===e.key&&(e.preventDefault(),G())},[G]),X=y.useCallback(e=>{e<1||!h||V(h,f,v,e)},[h,f,v,V]),Y=y.useCallback(e=>{U(null),l?l(e):n&&n(e)},[l,n]),J=y.useCallback(async t=>{if("video"===t.type){const e={type:"video",source:"portal",title:t.title||"",thumbnail:t.thumbnail||t.url,embed_url:t.embed_url||null,player_url:t.player_url||null,post_url:t.post_url||null,platform:t.platform||null,video_id:t.video_id||null,portal_slug:t.portal_slug||h,portal_name:t.portal_name||c.find(e=>e.slug===h)?.name||null,date_published:t.date_published||null,author:t.author||null};return void U(e)}const n=t.url||t.thumbnail;if(n){M(n),T(null);try{let l=null;try{const e=await fetch(n,{mode:"cors"});e.ok&&(l=await e.blob())}catch{}if(!l){const t=`${ie({prod:e})}/api/external/proxy?url=${encodeURIComponent(n)}`,r=await fetch(t);if(!r.ok)throw new Error(`Error al descargar: ${r.status}`);l=await r.blob()}const r=t.title?`${t.title.substring(0,80)}.${"image/png"===t.mime_type?"png":"jpg"}`:`portal-${Date.now()}.jpg`,a=new File([l],r,{type:l.type||t.mime_type||"image/jpeg"});L(a)}catch(l){T(l.message||"No se pudo recuperar la imagen del portal")}finally{M(null)}}else T("No se encontró URL de la imagen")},[e,h,c]);if(u)return F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-center lb:py-8",children:[F.jsx("span",{className:"limbo-loader lb:mr-2"})," Cargando portales disponibles..."]});if(!c.length)return F.jsx(Ge,{variant:"warning",children:"No hay portales externos disponibles."});if(!h)return F.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-4",children:[F.jsx("h3",{className:"lb:text-lg lb:font-semibold lb:text-brand-blue-1000",children:"Selecciona un Portal"}),d&&F.jsx(Ge,{variant:"danger",children:d}),F.jsx("div",{className:"lb:grid lb:grid-cols-2 lb:md:grid-cols-3 lb:gap-3",children:c.map(e=>F.jsx("button",{type:"button",onClick:()=>H(e.slug),disabled:t,className:"lb:relative lb:p-4 lb:rounded-lg lb:border-2 lb:transition-all lb:duration-200 lb:flex lb:flex-col lb:items-center lb:justify-center lb:min-h-25 lb:gap-2 lb:max-h-27.5 lb:box-border lb:border-gray-200 lb:bg-white lb:hover:border-brand-blue-350 lb:hover:shadow-md "+(t?"lb:opacity-50 lb:cursor-not-allowed":"lb:cursor-pointer"),children:e.image?F.jsx("img",{className:"lb:object-auto lb:bg-no-repeat lb:bg-center lb:max-h-full",src:e.image,alt:e.title}):F.jsx("span",{className:"lb:text-sm lb:font-medium lb:text-brand-blue-800",children:e.name})},e.slug))})]});const Z=c.find(e=>e.slug===h),ee=ie({prod:e});return F.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-3",children:[F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-3",children:[F.jsxs("button",{type:"button",onClick:K,className:"lb:flex lb:items-center lb:gap-1 lb:text-sm lb:text-brand-blue-800 lb:hover:text-brand-blue-1000 lb:font-medium lb:transition-colors",children:[F.jsx("span",{className:"icon icon-arrow-left icon--sm"}),"Portales"]}),F.jsx("span",{className:"lb:text-gray-300",children:"|"}),F.jsx("h3",{className:"lb:text-lg lb:font-semibold lb:text-brand-blue-1000",children:Z?.name||h})]}),F.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-3 lb:border-t lb:pt-3 lb:border-brand-blue-200",children:[b.length>1&&F.jsx("div",{className:"lb:flex lb:gap-2",children:b.map(({value:e,label:n})=>F.jsx("button",{type:"button",onClick:()=>g(e),disabled:t||E,className:"lb:px-3 lb:py-1.5 lb:text-sm lb:rounded-md lb:font-medium lb:transition-colors "+(f===e?"lb:bg-brand-blue-800 lb:text-white":"lb:bg-gray-100 lb:text-gray-700 lb:hover:bg-gray-200"),children:n},e))}),F.jsxs("div",{className:"lb:flex lb:gap-2",children:[F.jsx("input",{type:"text",value:v,onChange:e=>x(e.target.value),onKeyDown:Q,className:"limbo-input lb:flex-1",placeholder:"Buscar en el portal...",disabled:t||E}),F.jsxs("button",{type:"button",onClick:G,disabled:t||E,className:"limbo-btn limbo-btn-primary lb:px-4 lb:py-2 lb:text-sm lb:font-medium lb:whitespace-nowrap lb:flex lb:items-center lb:gap-1.5",children:[E?F.jsx("span",{className:"limbo-loader limbo-loader--sm"}):F.jsx("span",{className:"icon icon-search-white icon--sm"}),"Buscar"]})]})]}),_&&!E&&F.jsx(Ge,{variant:"warning",children:_}),z&&F.jsx("div",{className:"lb:mt-2 lb:md:w-full lb:mx-auto",children:F.jsx(ut,{image:z,onDiscard:()=>{L(null),T(null)},onDownload:()=>{},onSelect:e=>{if(n)if(e&&z&&e!==z.name){const t=new File([z],e,{type:z.type});n(t)}else n(z)},showRetry:!1,disabled:t,selectedFolder:r,onFolderChange:a,folderConfig:o})}),!z&&F.jsxs(F.Fragment,{children:[F.jsxs("div",{className:"lb:relative lb:min-h-50","aria-live":"polite",children:[E&&F.jsx("div",{className:"lb:absolute lb:inset-0 lb:bg-white/80 lb:z-10 lb:flex lb:items-center lb:justify-center lb:rounded-lg",children:F.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-2",children:[F.jsx("span",{className:"limbo-loader"}),F.jsx("span",{className:"lb:text-sm lb:text-brand-blue-800",children:"Cargando media..."})]})}),w.length>0&&F.jsxs("div",{className:"lb:relative lb:grid lb:grid-cols-2 lb:md:grid-cols-3 lb:lg:grid-cols-4 lb:gap-2",children:[F.jsx(ct,{show:E,message:"Cargando media..."}),w.map((e,n)=>{const l=`${e.portal_slug}-${e.id||n}`,r=e.thumbnail||e.url;if(P.has(l)||!r)return null;const a=`${ee}/api/external/proxy?url=${encodeURIComponent(r)}`;return F.jsxs("div",{className:"lb:group lb:border lb:border-brand-blue-200 lb:rounded-lg lb:overflow-hidden lb:bg-white lb:shadow-sm lb:hover:shadow-md lb:transition-all lb:duration-200 lb:cursor-pointer",onClick:()=>!A&&!E&&!t&&J(e),children:[F.jsxs("div",{className:"lb:relative lb:aspect-video lb:bg-neutral-100",children:[F.jsx(xt,{src:r,fallbackSrc:a,alt:e.alt||e.title||`Media ${n+1}`,className:"lb:object-cover lb:w-full lb:h-full",onError:()=>{I(e=>{const t=new Set(e);return t.add(l),t})}}),"video"===e.type&&F.jsx("span",{className:"lb:absolute lb:top-1 lb:left-1 lb:bg-black/60 lb:text-white lb:text-xs lb:px-2 lb:py-1 lb:rounded",children:"Video"}),A===(e.url||e.thumbnail)?F.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-white/90 lb:flex lb:flex-col lb:items-center lb:justify-center lb:gap-2",children:[F.jsxs("div",{className:"lb:relative lb:w-10 lb:h-10",children:[F.jsx("div",{className:"lb:absolute lb:inset-0 lb:border-4 lb:border-brand-blue-200 lb:rounded-full"}),F.jsx("div",{className:"lb:absolute lb:inset-0 lb:border-4 lb:border-brand-blue-800 lb:rounded-full lb:border-t-transparent lb:animate-spin"})]}),F.jsx("span",{className:"lb:text-sm lb:font-medium lb:text-brand-blue-1000",children:"Descargando..."})]}):"video"===e.type?F.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-black/0 lb:group-hover:bg-black/60 lb:transition-colors lb:duration-200 lb:flex lb:items-center lb:justify-center lb:flex-col lb:gap-1",children:[F.jsx("svg",{className:"lb:w-10 lb:h-10 lb:opacity-0 lb:group-hover:opacity-100 lb:transition-opacity lb:duration-200 lb:text-white",viewBox:"0 0 24 24",fill:"currentColor",children:F.jsx("path",{d:"M8 5v14l11-7z"})}),F.jsx("span",{className:"lb:text-sm lb:font-medium lb:text-white lb:opacity-0 lb:group-hover:opacity-100 lb:transition-opacity lb:duration-200",children:"Seleccionar vídeo"})]}):F.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-brand-blue-800/0 lb:group-hover:bg-brand-blue-800/50 lb:transition-colors lb:duration-200 lb:flex lb:items-center lb:justify-center lb:flex-col",children:[F.jsx("span",{className:"icon icon-round-check-filled-blue icon--2xl lb:max-w-full lb:max-h-full lb:opacity-0 lb:group-hover:opacity-100 lb:transition-opacity lb:duration-200"}),F.jsx("span",{style:{textShadow:"1px 0 #001978, -1px 0 #001978, 0 1px #001978, 0 -0.5px #001978, 0.5px 0.5px #001978, -1px -1px #001978, 1px -1px #001978, -1px 1px #001978"},className:"lb:max-w-full lb:max-h-full lb:opacity-0 lb:group-hover:opacity-100 lb:transition-opacity lb:duration-200 lb:text-neutral-white-000",children:"Seleccionar"})]})]}),e.title&&F.jsx("div",{className:"lb:px-2 lb:pb-2 lb:pt-1",children:F.jsx("p",{className:"lb:text-xs lb:text-gray-600 lb:truncate",title:e.title,children:e.title})})]},l)})]}),!D&&!E&&0===w.length&&!_&&F.jsxs("div",{className:"lb:text-center lb:text-neutral-600 lb:py-10 lb:bg-neutral-50 lb:rounded-lg",children:[F.jsx("p",{className:"lb:font-medium lb:text-brand-blue-800",children:"Selecciona los filtros y pulsa Buscar"}),F.jsx("p",{className:"lb:text-sm lb:mt-1 lb:text-neutral-500",children:"Elige el tipo de contenido y escribe un término de búsqueda"})]}),D&&!E&&0===w.length&&!_&&F.jsxs("div",{className:"lb:text-center lb:text-neutral-600 lb:py-8 lb:bg-neutral-50 lb:rounded-lg",children:[F.jsx("span",{className:"icon icon-search icon--lg lb:mb-2"}),F.jsx("p",{children:"No se encontraron resultados"}),v&&F.jsx("p",{className:"lb:text-sm lb:mt-1",children:"Intenta con otros términos de búsqueda"})]})]}),j&&j.total_pages>1&&F.jsxs("div",{className:"lb:mt-4 lb:flex lb:items-center lb:justify-center lb:gap-2",children:[F.jsxs("button",{onClick:()=>X(C-1),disabled:1===C||E,className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(1===C||E?" pointer-events-none cursor-default":" limbo-btn-primary"),children:[F.jsx("span",{className:"icon icon-arrow-left-white icon--sm"})," ","Anterior"]}),F.jsxs("span",{className:"lb:px-4 lb:py-2 lb:text-sm lb:text-neutral-700",children:["Página ",C," de ",j.total_pages,F.jsxs("span",{className:"lb:text-xs lb:text-neutral-500 lb:block",children:["(",j.total_items," resultados)"]})]}),F.jsxs("button",{onClick:()=>X(C+1),disabled:E||C>=j.total_pages,className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(E||C>=j.total_pages?" pointer-events-none cursor-default":" limbo-btn-primary"),children:["Siguiente"," ",F.jsx("span",{className:"icon icon-arrow-right-white icon--sm"})]})]})]}),F.jsx(vt,{isOpen:!!R,video:R,onClose:()=>U(null),onSelect:B?Y:null})]})}const kt=[{id:"upload",label:"Subir archivo"},{id:"ai",label:"Generar"},{id:"stock",label:"Buscar en Stock"},{id:"portals",label:"Otros portales"}];function Ct({onSelect:e,onVideoSelect:t,disabled:n=!1,apiKey:l,prod:r=!1,allowedCategories:a=null,resolvedAccept:o=null,returnConfig:i=null,folderConfig:s=null,selectedFolder:c=null,onFolderChange:u=null}){const{isMobile:d,isTouch:b}=B(),m=y.useMemo(()=>!o||o.isAllTypes||o.includesImages?kt:o.includesVideos?kt.filter(e=>"upload"===e.id||"portals"===e.id):kt.filter(e=>"upload"===e.id),[o]),[h,p]=y.useState("upload"),[f,g]=y.useState(null),[v,x]=y.useState(null),w=y.useRef(),k=["limbo-tabs","lb:flex","lb:gap-4","lb:border-b-2","lb:border-brand-blue-200","lb:mb-4",d&&"lb:overflow-x-auto lb:scrollbar-none"].filter(Boolean).join(" "),C=e=>{const t=["limbo-tab","lb:relative","lb:px-4","lb:py-2","lb:font-medium","lb:text-brand-blue-1000","lb:bg-transparent","lb:border-0","lb:border-b-2","lb:cursor-pointer","lb:transition-all","lb:duration-200","lb:hover:text-pink-1000","lb:focus:outline-none","lb:focus-visible:ring-2","lb:focus-visible:ring-brand-blue-400","lb:focus-visible:ring-offset-2","lb:text-nowrap"];return e?t.push("lb:border-b-brand-blue-1000","lb:font-semibold","limbo-active"):t.push("lb:border-b-transparent"),d&&t.push("lb:min-w-[100px]","lb:min-h-[44px]","lb:text-sm","lb:shrink-0"),b&&t.push("lb:touch-manipulation"),t.join(" ")};return F.jsxs("div",{className:"limbo-upload-form lb:py-4 lb:min-w-fit lb:max-w-7xl lb:mx-auto",children:[m.length>1&&F.jsx("div",{className:k,role:"tablist","aria-label":"Opciones de subida",style:d?{WebkitOverflowScrolling:"touch",scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,children:m.map(e=>{const t=h===e.id;return F.jsxs("button",{type:"button","data-upload-tab-id":e.id,className:C(t),"aria-current":t?"page":void 0,"aria-selected":t,role:"tab",tabIndex:t?0:-1,onClick:()=>p(e.id),onKeyDown:t=>((e,t)=>{const n=m.findIndex(e=>e.id===t);let l=n;switch(e.key){case"ArrowLeft":e.preventDefault(),l=n>0?n-1:m.length-1;break;case"ArrowRight":e.preventDefault(),l=n<m.length-1?n+1:0;break;case"Home":e.preventDefault(),l=0;break;case"End":e.preventDefault(),l=m.length-1;break;case"Enter":case" ":return e.preventDefault(),void p(t);default:return}const r=m[l];r&&(p(r.id),setTimeout(()=>{const e=document.querySelector(`[data-upload-tab-id="${r.id}"]`);e&&e.focus()},0))})(t,e.id),id:`upload-tab-${e.id}`,"aria-controls":`upload-tabpanel-${e.id}`,style:b?{WebkitTapHighlightColor:"transparent"}:void 0,children:["ai"===e.id?F.jsx("span",{className:"icon icon-ia lb:me-1"}):null,e.label]},e.id)})}),F.jsxs("div",{className:"limbo-tab-content lb:px-2 lb:py-2",role:"tabpanel",id:`upload-tabpanel-${h}`,"aria-labelledby":`upload-tab-${h}`,children:["upload"===h&&F.jsx(lt,{file:f,setFile:g,previewUrl:v,setPreviewUrl:x,fileInputRef:w,onSelect:e,disabled:n,allowedCategories:a,resolvedAccept:o,selectedFolder:c,onFolderChange:u,folderConfig:s}),"ai"===h&&F.jsx(dt,{apiKey:l,prod:r,disabled:n,onSelect:e,selectedFolder:c,onFolderChange:u,folderConfig:s}),"stock"===h&&F.jsx(pt,{apiKey:l,prod:r,disabled:n,onSelect:e,selectedFolder:c,onFolderChange:u,folderConfig:s}),"portals"===h&&F.jsx(wt,{apiKey:l,prod:r,disabled:n,onSelect:e,onVideoSelect:t,resolvedAccept:o,returnConfig:i,selectedFolder:c,onFolderChange:u,folderConfig:s})]})]})}const St="undefined"!=typeof window&&void 0!==window.document,jt=St?window:{},Nt=!!St&&"ontouchstart"in jt.document.documentElement,Et=!!St&&"PointerEvent"in jt,$t="cropper",_t=`${$t}-canvas`,Tt=`${$t}-crosshair`,zt=`${$t}-grid`,Lt=`${$t}-handle`,At=`${$t}-image`,Mt=`${$t}-selection`,Pt=`${$t}-shade`,It=`${$t}-viewer`,Dt="select",Ot="move",Rt="scale",Ft="rotate",Ut="transform",Bt="none",Wt="n-resize",qt="e-resize",Vt="s-resize",Ht="w-resize",Kt="ne-resize",Gt="nw-resize",Qt="se-resize",Xt="sw-resize",Yt=Et?"pointerdown":Nt?"touchstart":"mousedown",Jt=Et?"pointermove":Nt?"touchmove":"mousemove",Zt=Et?"pointerup pointercancel":Nt?"touchend touchcancel":"mouseup",en="error",tn="keydown",nn="load",ln="wheel",rn="action",an="actionend",on="actionstart",sn="change",cn="transform";const un=Number.isNaN||jt.isNaN;function dn(e){return"number"==typeof e&&!un(e)}function bn(e){return dn(e)&&e>0&&e<1/0}function mn(e){return"object"==typeof e&&null!==e}const{hasOwnProperty:hn}=Object.prototype;function pn(e){if(!mn(e))return!1;try{const{constructor:t}=e,{prototype:n}=t;return t&&n&&hn.call(n,"isPrototypeOf")}catch(t){return!1}}function fn(e){return"function"==typeof e}function gn(e){return"object"==typeof e&&null!==e&&1===e.nodeType}const yn=/([a-z\d])([A-Z])/g;function vn(e){return String(e).replace(yn,"$1-$2").toLowerCase()}const xn=/-[A-z\d]/g;function wn(e){return e.replace(xn,e=>e.slice(1).toUpperCase())}const kn=/\s\s*/;function Cn(e,t,n,l){t.trim().split(kn).forEach(t=>{e.removeEventListener(t,n,l)})}function Sn(e,t,n,l){t.trim().split(kn).forEach(t=>{e.addEventListener(t,n,l)})}function jn(e,t,n,l){Sn(e,t,n,Object.assign(Object.assign({},l),{once:!0}))}const Nn={bubbles:!0,cancelable:!0,composed:!0};const En=Promise.resolve();function $n(e){const{documentElement:t}=e.ownerDocument,n=e.getBoundingClientRect();return{left:n.left+(jt.pageXOffset-t.clientLeft),top:n.top+(jt.pageYOffset-t.clientTop)}}const _n=/deg|g?rad|turn$/i;function Tn(e){const t=parseFloat(e)||0;if(0!==t){const[n="rad"]=String(e).match(_n)||[];switch(n.toLowerCase()){case"deg":return t/360*(2*Math.PI);case"grad":return t/400*(2*Math.PI);case"turn":return t*(2*Math.PI)}}return t}const zn="contain";function Ln(e,t=zn){const{aspectRatio:n}=e;let{width:l,height:r}=e;const a=bn(l),o=bn(r);if(a&&o){const e=r*n;t===zn&&e>l||"cover"===t&&e<l?r=l/n:l=r*n}else a?r=l/n:o&&(l=r*n);return{width:l,height:r}}function An(e,...t){if(0===t.length)return e;const[n,l,r,a,o,i]=e,[s,c,u,d,b,m]=t[0];return An(e=[n*s+r*c,l*s+a*c,n*u+r*d,l*u+a*d,n*b+r*m+o,l*b+a*m+i],...t.slice(1))}const Mn=/left|top|width|height/i,Pn="open",In=new WeakMap,Dn=new WeakMap,On=new Map,Rn=jt.document&&Array.isArray(jt.document.adoptedStyleSheets)&&"replaceSync"in jt.CSSStyleSheet.prototype;class Fn extends HTMLElement{get $sharedStyle(){return(this.themeColor?`:host{--theme-color: ${this.themeColor};}`:"")+":host([hidden]){display:none!important}"}constructor(){var e,t;super(),this.shadowRootMode=Pn,this.slottable=!0;const n=null===(t=null===(e=Object.getPrototypeOf(this))||void 0===e?void 0:e.constructor)||void 0===t?void 0:t.$name;n&&On.set(n,this.tagName.toLowerCase())}static get observedAttributes(){return["shadow-root-mode","slottable","theme-color"]}attributeChangedCallback(e,t,n){if(Object.is(n,t))return;const l=wn(e);let r=n;switch(typeof this[l]){case"boolean":r=null!==n&&"false"!==n;break;case"number":r=Number(n)}switch(this[l]=r,e){case"theme-color":{const e=Dn.get(this),t=this.$sharedStyle;e&&t&&(Rn?e.replaceSync(t):e.textContent=t);break}}}$propertyChangedCallback(e,t,n){if(!Object.is(n,t))switch(e=vn(e),typeof n){case"boolean":!0===n?this.hasAttribute(e)||this.setAttribute(e,""):this.removeAttribute(e);break;case"number":n=un(n)?"":String(n);default:n?this.getAttribute(e)!==n&&this.setAttribute(e,n):this.removeAttribute(e)}}connectedCallback(){Object.getPrototypeOf(this).constructor.observedAttributes.forEach(e=>{const t=wn(e);let n=this[t];(function(e){return void 0===e})(n)||this.$propertyChangedCallback(t,void 0,n),Object.defineProperty(this,t,{enumerable:!0,configurable:!0,get:()=>n,set(e){const l=n;n=e,this.$propertyChangedCallback(t,l,e)}})});const e=this.shadowRoot||this.attachShadow({mode:this.shadowRootMode||Pn});if(In.set(this,e),Dn.set(this,this.$addStyles(this.$sharedStyle)),this.$style&&this.$addStyles(this.$style),this.$template){const t=document.createElement("template");t.innerHTML=this.$template,e.appendChild(t.content)}if(this.slottable){const t=document.createElement("slot");e.appendChild(t)}}disconnectedCallback(){Dn.has(this)&&Dn.delete(this),In.has(this)&&In.delete(this)}$getTagNameOf(e){var t;return null!==(t=On.get(e))&&void 0!==t?t:e}$setStyles(e){return Object.keys(e).forEach(t=>{let n=e[t];dn(n)&&(n=0!==n&&Mn.test(t)?`${n}px`:String(n)),this.style[t]=n}),this}$getShadowRoot(){return this.shadowRoot||In.get(this)}$addStyles(e){let t;const n=this.$getShadowRoot();return Rn?(t=new CSSStyleSheet,t.replaceSync(e),n.adoptedStyleSheets=n.adoptedStyleSheets.concat(t)):(t=document.createElement("style"),t.textContent=e,n.appendChild(t)),t}$emit(e,t,n){return function(e,t,n,l){return e.dispatchEvent(new CustomEvent(t,Object.assign(Object.assign(Object.assign({},Nn),{detail:n}),l)))}(this,e,t,n)}$nextTick(e){return function(e,t){return t?En.then(e?t.bind(e):t):En}(this,e)}static $define(e,t){mn(e)&&(t=e,e=""),e||(e=this.$name||this.name),e=vn(e),St&&jt.customElements&&!jt.customElements.get(e)&&customElements.define(e,this,t)}}Fn.$version="2.1.0";class Un extends Fn{constructor(){super(...arguments),this.$onPointerDown=null,this.$onPointerMove=null,this.$onPointerUp=null,this.$onWheel=null,this.$wheeling=!1,this.$pointers=new Map,this.$style=':host{display:block;min-height:100px;min-width:200px;overflow:hidden;position:relative;touch-action:none;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}:host([background]){background-color:#fff;background-image:repeating-linear-gradient(45deg,#ccc 25%,transparent 0,transparent 75%,#ccc 0,#ccc),repeating-linear-gradient(45deg,#ccc 25%,transparent 0,transparent 75%,#ccc 0,#ccc);background-image:repeating-conic-gradient(#ccc 0 25%,#fff 0 50%);background-position:0 0,.5rem .5rem;background-size:1rem 1rem}:host([disabled]){pointer-events:none}:host([disabled]):after{bottom:0;content:"";cursor:not-allowed;display:block;left:0;pointer-events:none;position:absolute;right:0;top:0}',this.$action=Bt,this.background=!1,this.disabled=!1,this.scaleStep=.1,this.themeColor="#39f"}static get observedAttributes(){return super.observedAttributes.concat(["background","disabled","scale-step"])}connectedCallback(){super.connectedCallback(),this.disabled||this.$bind()}disconnectedCallback(){this.disabled||this.$unbind(),super.disconnectedCallback()}$propertyChangedCallback(e,t,n){if(!Object.is(n,t)&&(super.$propertyChangedCallback(e,t,n),"disabled"===e))n?this.$unbind():this.$bind()}$bind(){this.$onPointerDown||(this.$onPointerDown=this.$handlePointerDown.bind(this),Sn(this,Yt,this.$onPointerDown)),this.$onPointerMove||(this.$onPointerMove=this.$handlePointerMove.bind(this),Sn(this.ownerDocument,Jt,this.$onPointerMove)),this.$onPointerUp||(this.$onPointerUp=this.$handlePointerUp.bind(this),Sn(this.ownerDocument,Zt,this.$onPointerUp)),this.$onWheel||(this.$onWheel=this.$handleWheel.bind(this),Sn(this,ln,this.$onWheel,{passive:!1,capture:!0}))}$unbind(){this.$onPointerDown&&(Cn(this,Yt,this.$onPointerDown),this.$onPointerDown=null),this.$onPointerMove&&(Cn(this.ownerDocument,Jt,this.$onPointerMove),this.$onPointerMove=null),this.$onPointerUp&&(Cn(this.ownerDocument,Zt,this.$onPointerUp),this.$onPointerUp=null),this.$onWheel&&(Cn(this,ln,this.$onWheel,{capture:!0}),this.$onWheel=null)}$handlePointerDown(e){const{buttons:t,button:n,type:l}=e;if(this.disabled||("pointerdown"===l&&"mouse"===e.pointerType||"mousedown"===l)&&(dn(t)&&1!==t||dn(n)&&0!==n||e.ctrlKey))return;const{$pointers:r}=this;let a="";if(e.changedTouches)Array.from(e.changedTouches).forEach(({identifier:e,pageX:t,pageY:n})=>{r.set(e,{startX:t,startY:n,endX:t,endY:n})});else{const{pointerId:t=0,pageX:n,pageY:l}=e;r.set(t,{startX:n,startY:l,endX:n,endY:l})}r.size>1?a=Ut:gn(e.target)&&(a=e.target.action||e.target.getAttribute("action")||""),!1!==this.$emit(on,{action:a,relatedEvent:e})&&(e.preventDefault(),this.$action=a,this.style.willChange="transform")}$handlePointerMove(e){const{$action:t,$pointers:n}=this;if(this.disabled||t===Bt||0===n.size)return;if(!1===this.$emit("actionmove",{action:t,relatedEvent:e}))return;if(e.preventDefault(),e.changedTouches)Array.from(e.changedTouches).forEach(({identifier:e,pageX:t,pageY:l})=>{const r=n.get(e);r&&Object.assign(r,{endX:t,endY:l})});else{const{pointerId:t=0,pageX:l,pageY:r}=e,a=n.get(t);a&&Object.assign(a,{endX:l,endY:r})}const l={action:t,relatedEvent:e};if(t===Ut){const t=new Map(n);let r=0,a=0,o=0,i=0,s=e.pageX,c=e.pageY;n.forEach((e,n)=>{t.delete(n),t.forEach(t=>{let n=t.startX-e.startX,l=t.startY-e.startY,u=t.endX-e.endX,d=t.endY-e.endY,b=0,m=0,h=0,p=0;if(0===n?l<0?h=2*Math.PI:l>0&&(h=Math.PI):n>0?h=Math.PI/2+Math.atan(l/n):n<0&&(h=1.5*Math.PI+Math.atan(l/n)),0===u?d<0?p=2*Math.PI:d>0&&(p=Math.PI):u>0?p=Math.PI/2+Math.atan(d/u):u<0&&(p=1.5*Math.PI+Math.atan(d/u)),p>0||h>0){const n=p-h,l=Math.abs(n);l>r&&(r=l,o=n,s=(e.startX+t.startX)/2,c=(e.startY+t.startY)/2)}if(n=Math.abs(n),l=Math.abs(l),u=Math.abs(u),d=Math.abs(d),n>0&&l>0?b=Math.sqrt(n*n+l*l):n>0?b=n:l>0&&(b=l),u>0&&d>0?m=Math.sqrt(u*u+d*d):u>0?m=u:d>0&&(m=d),b>0&&m>0){const n=(m-b)/b,l=Math.abs(n);l>a&&(a=l,i=n,s=(e.startX+t.startX)/2,c=(e.startY+t.startY)/2)}})});const u=r>0,d=a>0;u&&d?(l.rotate=o,l.scale=i,l.centerX=s,l.centerY=c):u?(l.action=Ft,l.rotate=o,l.centerX=s,l.centerY=c):d?(l.action=Rt,l.scale=i,l.centerX=s,l.centerY=c):l.action=Bt}else{const[e]=Array.from(n.values());Object.assign(l,e)}n.forEach(e=>{e.startX=e.endX,e.startY=e.endY}),l.action!==Bt&&this.$emit(rn,l,{cancelable:!1})}$handlePointerUp(e){const{$action:t,$pointers:n}=this;if(!this.disabled&&t!==Bt&&!1!==this.$emit(an,{action:t,relatedEvent:e})){if(e.preventDefault(),e.changedTouches)Array.from(e.changedTouches).forEach(({identifier:e})=>{n.delete(e)});else{const{pointerId:t=0}=e;n.delete(t)}0===n.size&&(this.style.willChange="",this.$action=Bt)}}$handleWheel(e){if(this.disabled)return;if(e.preventDefault(),this.$wheeling)return;this.$wheeling=!0,setTimeout(()=>{this.$wheeling=!1},50);const t=(e.deltaY>0?-1:1)*this.scaleStep;this.$emit(rn,{action:Rt,scale:t,relatedEvent:e},{cancelable:!1})}$setAction(e){return"string"==typeof e&&(this.$action=e),this}$toCanvas(e){return new Promise((t,n)=>{if(!this.isConnected)return void n(new Error("The current element is not connected to the DOM."));const l=document.createElement("canvas");let r=this.offsetWidth,a=this.offsetHeight,o=1;pn(e)&&(bn(e.width)||bn(e.height))&&(({width:r,height:a}=Ln({aspectRatio:r/a,width:e.width,height:e.height})),o=r/this.offsetWidth),l.width=r,l.height=a;const i=this.querySelector(this.$getTagNameOf(At));i?i.$ready().then(n=>{const s=l.getContext("2d");if(s){const[t,c,u,d,b,m]=i.$getTransform();let h=b,p=m,f=n.naturalWidth,g=n.naturalHeight;1!==o&&(h*=o,p*=o,f*=o,g*=o);const y=f/2,v=g/2;s.fillStyle="transparent",s.fillRect(0,0,r,a),pn(e)&&fn(e.beforeDraw)&&e.beforeDraw.call(this,s,l),s.save(),s.translate(y,v),s.transform(t,c,u,d,h,p),s.translate(-y,-v),s.drawImage(n,0,0,f,g),s.restore()}t(l)}).catch(n):t(l)})}}Un.$name=_t,Un.$version="2.1.0";const Bn=new WeakMap,Wn=["alt","crossorigin","decoding","elementtiming","fetchpriority","loading","referrerpolicy","sizes","src","srcset"];class qn extends Fn{constructor(){super(...arguments),this.$matrix=[1,0,0,1,0,0],this.$onLoad=null,this.$onCanvasAction=null,this.$onCanvasActionEnd=null,this.$onCanvasActionStart=null,this.$actionStartTarget=null,this.$style=":host{display:inline-block}img{display:block;height:100%;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;width:100%}",this.$image=new Image,this.initialCenterSize="contain",this.rotatable=!1,this.scalable=!1,this.skewable=!1,this.slottable=!1,this.translatable=!1,this.alt="",this.crossorigin="",this.decoding="",this.elementtiming="",this.fetchpriority="",this.loading="",this.referrerpolicy="",this.sizes="",this.src="",this.srcset=""}set $canvas(e){Bn.set(this,e)}get $canvas(){return Bn.get(this)}static get observedAttributes(){return super.observedAttributes.concat(Wn,["initial-center-size","rotatable","scalable","skewable","translatable"])}attributeChangedCallback(e,t,n){Object.is(n,t)||(super.attributeChangedCallback(e,t,n),Wn.includes(e)&&this.$image.setAttribute(e,n))}$propertyChangedCallback(e,t,n){if(!Object.is(n,t)&&(super.$propertyChangedCallback(e,t,n),"initialCenterSize"===e))this.$nextTick(()=>{this.$center(n)})}connectedCallback(){super.connectedCallback();const{$image:e}=this,t=this.closest(this.$getTagNameOf(_t));t&&(this.$canvas=t,this.$setStyles({display:"block",position:"absolute"}),this.$onCanvasActionStart=e=>{var t,n;this.$actionStartTarget=null===(n=null===(t=e.detail)||void 0===t?void 0:t.relatedEvent)||void 0===n?void 0:n.target},this.$onCanvasActionEnd=()=>{this.$actionStartTarget=null},this.$onCanvasAction=this.$handleAction.bind(this),Sn(t,on,this.$onCanvasActionStart),Sn(t,an,this.$onCanvasActionEnd),Sn(t,rn,this.$onCanvasAction)),this.$onLoad=this.$handleLoad.bind(this),Sn(e,nn,this.$onLoad),this.$getShadowRoot().appendChild(e)}disconnectedCallback(){const{$image:e,$canvas:t}=this;t&&(this.$onCanvasActionStart&&(Cn(t,on,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(Cn(t,an,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasAction&&(Cn(t,rn,this.$onCanvasAction),this.$onCanvasAction=null)),e&&this.$onLoad&&(Cn(e,nn,this.$onLoad),this.$onLoad=null),this.$getShadowRoot().removeChild(e),super.disconnectedCallback()}$handleLoad(){const{$image:e}=this;this.$setStyles({width:e.naturalWidth,height:e.naturalHeight}),this.$canvas&&this.$center(this.initialCenterSize)}$handleAction(e){if(this.hidden||!(this.rotatable||this.scalable||this.translatable))return;const{$canvas:t}=this,{detail:n}=e;if(n){const{relatedEvent:e}=n;let{action:l}=n;switch(l!==Ut||this.rotatable&&this.scalable||(l=this.rotatable?Ft:this.scalable?Rt:Bt),l){case Ot:if(this.translatable){let l=null;e&&(l=e.target.closest(this.$getTagNameOf(Mt))),l||(l=t.querySelector(this.$getTagNameOf(Mt))),l&&l.multiple&&!l.active&&(l=t.querySelector(`${this.$getTagNameOf(Mt)}[active]`)),l&&!l.hidden&&l.movable&&!l.dynamic&&this.$actionStartTarget&&l.contains(this.$actionStartTarget)||this.$move(n.endX-n.startX,n.endY-n.startY)}break;case Ft:if(this.rotatable)if(e){const{x:t,y:l}=this.getBoundingClientRect();this.$rotate(n.rotate,e.clientX-t,e.clientY-l)}else this.$rotate(n.rotate);break;case Rt:if(this.scalable)if(e){const t=e.target.closest(this.$getTagNameOf(Mt));if(!t||!t.zoomable||t.zoomable&&t.dynamic){const{x:t,y:l}=this.getBoundingClientRect();this.$zoom(n.scale,e.clientX-t,e.clientY-l)}}else this.$zoom(n.scale);break;case Ut:if(this.rotatable&&this.scalable){const{rotate:t}=n;let{scale:l}=n;l<0?l=1/(1-l):l+=1;const r=Math.cos(t),a=Math.sin(t),[o,i,s,c]=[r*l,a*l,-a*l,r*l];if(e){const t=this.getBoundingClientRect(),n=e.clientX-t.x,l=e.clientY-t.y,[r,a,u,d]=this.$matrix,b=n-t.width/2,m=l-t.height/2,h=(b*d-u*m)/(r*d-u*a),p=(m*r-a*b)/(r*d-u*a);this.$transform(o,i,s,c,h*(1-o)+p*s,p*(1-c)+h*i)}else this.$transform(o,i,s,c,0,0)}}}}$ready(e){const{$image:t}=this,n=new Promise((e,n)=>{const l=new Error("Failed to load the image source");if(t.complete)t.naturalWidth>0&&t.naturalHeight>0?e(t):n(l);else{const r=()=>{Cn(t,en,a),setTimeout(()=>{e(t)})},a=()=>{Cn(t,nn,r),n(l)};jn(t,nn,r),jn(t,en,a)}});return fn(e)&&n.then(t=>(e(t),t)),n}$center(e){const{parentElement:t}=this;if(!t)return this;const n=t.getBoundingClientRect(),l=n.width,r=n.height,{x:a,y:o,width:i,height:s}=this.getBoundingClientRect(),c=a+i/2,u=o+s/2,d=n.x+l/2,b=n.y+r/2;if(this.$move(d-c,b-u),e&&(i!==l||s!==r)){const t=l/i,n=r/s;switch(e){case"cover":this.$scale(Math.max(t,n));break;case"contain":this.$scale(Math.min(t,n))}}return this}$move(e,t=e){if(this.translatable&&dn(e)&&dn(t)){const[n,l,r,a]=this.$matrix,o=(e*a-r*t)/(n*a-r*l),i=(t*n-l*e)/(n*a-r*l);this.$translate(o,i)}return this}$moveTo(e,t=e){if(this.translatable&&dn(e)&&dn(t)){const[n,l,r,a]=this.$matrix,o=(e*a-r*t)/(n*a-r*l),i=(t*n-l*e)/(n*a-r*l);this.$setTransform(n,l,r,a,o,i)}return this}$rotate(e,t,n){if(this.rotatable){const l=Tn(e),r=Math.cos(l),a=Math.sin(l),[o,i,s,c]=[r,a,-a,r];if(dn(t)&&dn(n)){const[e,l,r,a]=this.$matrix,{width:u,height:d}=this.getBoundingClientRect(),b=t-u/2,m=n-d/2,h=(b*a-r*m)/(e*a-r*l),p=(m*e-l*b)/(e*a-r*l);this.$transform(o,i,s,c,h*(1-o)-p*s,p*(1-c)-h*i)}else this.$transform(o,i,s,c,0,0)}return this}$zoom(e,t,n){if(!this.scalable||0===e)return this;if(e<0?e=1/(1-e):e+=1,dn(t)&&dn(n)){const[l,r,a,o]=this.$matrix,{width:i,height:s}=this.getBoundingClientRect(),c=t-i/2,u=n-s/2,d=(c*o-a*u)/(l*o-a*r),b=(u*l-r*c)/(l*o-a*r);this.$transform(e,0,0,e,d*(1-e),b*(1-e))}else this.$scale(e);return this}$scale(e,t=e){return this.scalable&&this.$transform(e,0,0,t,0,0),this}$skew(e,t=0){if(this.skewable){const n=Tn(e),l=Tn(t);this.$transform(1,Math.tan(l),Math.tan(n),1,0,0)}return this}$translate(e,t=e){return this.translatable&&dn(e)&&dn(t)&&this.$transform(1,0,0,1,e,t),this}$transform(e,t,n,l,r,a){return dn(e)&&dn(t)&&dn(n)&&dn(l)&&dn(r)&&dn(a)?this.$setTransform(An(this.$matrix,[e,t,n,l,r,a])):this}$setTransform(e,t,n,l,r,a){if((this.rotatable||this.scalable||this.skewable||this.translatable)&&(Array.isArray(e)&&([e,t,n,l,r,a]=e),dn(e)&&dn(t)&&dn(n)&&dn(l)&&dn(r)&&dn(a))){const o=[...this.$matrix],i=[e,t,n,l,r,a];if(!1===this.$emit(cn,{matrix:i,oldMatrix:o}))return this;this.$matrix=i,this.style.transform=`matrix(${i.join(", ")})`}return this}$getTransform(){return this.$matrix.slice()}$resetTransform(){return this.$setTransform([1,0,0,1,0,0])}}qn.$name=At,qn.$version="2.1.0";const Vn=new WeakMap;class Hn extends Fn{constructor(){super(...arguments),this.$onCanvasActionEnd=null,this.$onCanvasActionStart=null,this.$onSelectionChange=null,this.$style=":host{display:block;height:0;left:0;outline:var(--theme-color) solid 1px;position:relative;top:0;width:0}:host([transparent]){outline-color:transparent}",this.x=0,this.y=0,this.width=0,this.height=0,this.slottable=!1,this.themeColor="rgba(0, 0, 0, 0.65)"}set $canvas(e){Vn.set(this,e)}get $canvas(){return Vn.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["height","width","x","y"])}connectedCallback(){super.connectedCallback();const e=this.closest(this.$getTagNameOf(_t));if(e){this.$canvas=e,this.style.position="absolute";const t=e.querySelector(this.$getTagNameOf(Mt));t&&(this.$onCanvasActionStart=e=>{t.hidden&&e.detail.action===Dt&&(this.hidden=!1)},this.$onCanvasActionEnd=e=>{t.hidden&&e.detail.action===Dt&&(this.hidden=!0)},this.$onSelectionChange=e=>{const{x:n,y:l,width:r,height:a}=e.defaultPrevented?t:e.detail;this.$change(n,l,r,a),(t.hidden||0===n&&0===l&&0===r&&0===a)&&(this.hidden=!0)},Sn(e,on,this.$onCanvasActionStart),Sn(e,an,this.$onCanvasActionEnd),Sn(e,sn,this.$onSelectionChange))}this.$render()}disconnectedCallback(){const{$canvas:e}=this;e&&(this.$onCanvasActionStart&&(Cn(e,on,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(Cn(e,an,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onSelectionChange&&(Cn(e,sn,this.$onSelectionChange),this.$onSelectionChange=null)),super.disconnectedCallback()}$change(e,t,n=this.width,l=this.height){return dn(e)&&dn(t)&&dn(n)&&dn(l)&&(e!==this.x||t!==this.y||n!==this.width||l!==this.height)?(this.hidden&&(this.hidden=!1),this.x=e,this.y=t,this.width=n,this.height=l,this.$render()):this}$reset(){return this.$change(0,0,0,0)}$render(){return this.$setStyles({transform:`translate(${this.x}px, ${this.y}px)`,width:this.width,height:this.height,outlineWidth:jt.innerWidth})}}Hn.$name=Pt,Hn.$version="2.1.0";class Kn extends Fn{constructor(){super(...arguments),this.$onCanvasCropEnd=null,this.$onCanvasCropStart=null,this.$style=':host{background-color:var(--theme-color);display:block}:host([action=move]),:host([action=select]){height:100%;left:0;position:absolute;top:0;width:100%}:host([action=move]){cursor:move}:host([action=select]){cursor:crosshair}:host([action$=-resize]){background-color:transparent;height:15px;position:absolute;width:15px}:host([action$=-resize]):after{background-color:var(--theme-color);content:"";display:block;height:5px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:5px}:host([action=n-resize]),:host([action=s-resize]){cursor:ns-resize;left:50%;transform:translateX(-50%);width:100%}:host([action=n-resize]){top:-8px}:host([action=s-resize]){bottom:-8px}:host([action=e-resize]),:host([action=w-resize]){cursor:ew-resize;height:100%;top:50%;transform:translateY(-50%)}:host([action=e-resize]){right:-8px}:host([action=w-resize]){left:-8px}:host([action=ne-resize]){cursor:nesw-resize;right:-8px;top:-8px}:host([action=nw-resize]){cursor:nwse-resize;left:-8px;top:-8px}:host([action=se-resize]){bottom:-8px;cursor:nwse-resize;right:-8px}:host([action=se-resize]):after{height:15px;width:15px}@media (pointer:coarse){:host([action=se-resize]):after{height:10px;width:10px}}@media (pointer:fine){:host([action=se-resize]):after{height:5px;width:5px}}:host([action=sw-resize]){bottom:-8px;cursor:nesw-resize;left:-8px}:host([plain]){background-color:transparent}',this.action=Bt,this.plain=!1,this.slottable=!1,this.themeColor="rgba(51, 153, 255, 0.5)"}static get observedAttributes(){return super.observedAttributes.concat(["action","plain"])}}Kn.$name=Lt,Kn.$version="2.1.0";const Gn=new WeakMap;class Qn extends Fn{constructor(){super(...arguments),this.$onCanvasAction=null,this.$onCanvasActionStart=null,this.$onCanvasActionEnd=null,this.$onDocumentKeyDown=null,this.$action="",this.$actionStartTarget=null,this.$changing=!1,this.$style=':host{display:block;left:0;position:relative;right:0}:host([outlined]){outline:1px solid var(--theme-color)}:host([multiple]){outline:1px dashed hsla(0,0%,100%,.5)}:host([multiple]):after{bottom:0;content:"";cursor:pointer;display:block;left:0;position:absolute;right:0;top:0}:host([multiple][active]){outline-color:var(--theme-color);z-index:1}:host([multiple])>*{visibility:hidden}:host([multiple][active])>*{visibility:visible}:host([multiple][active]):after{display:none}',this.$initialSelection={x:0,y:0,width:0,height:0},this.x=0,this.y=0,this.width=0,this.height=0,this.aspectRatio=NaN,this.initialAspectRatio=NaN,this.initialCoverage=NaN,this.active=!1,this.linked=!1,this.dynamic=!1,this.movable=!1,this.resizable=!1,this.zoomable=!1,this.multiple=!1,this.keyboard=!1,this.outlined=!1,this.precise=!1}set $canvas(e){Gn.set(this,e)}get $canvas(){return Gn.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["active","aspect-ratio","dynamic","height","initial-aspect-ratio","initial-coverage","keyboard","linked","movable","multiple","outlined","precise","resizable","width","x","y","zoomable"])}$propertyChangedCallback(e,t,n){if(!Object.is(n,t))switch(super.$propertyChangedCallback(e,t,n),e){case"x":case"y":case"width":case"height":this.$changing||this.$nextTick(()=>{this.$change(this.x,this.y,this.width,this.height,this.aspectRatio,!0)});break;case"aspectRatio":case"initialAspectRatio":this.$nextTick(()=>{this.$initSelection()});break;case"initialCoverage":this.$nextTick(()=>{bn(n)&&n<=1&&this.$initSelection(!0,!0)});break;case"keyboard":this.$nextTick(()=>{this.$canvas&&(n?this.$onDocumentKeyDown||(this.$onDocumentKeyDown=this.$handleKeyDown.bind(this),Sn(this.ownerDocument,tn,this.$onDocumentKeyDown)):this.$onDocumentKeyDown&&(Cn(this.ownerDocument,tn,this.$onDocumentKeyDown),this.$onDocumentKeyDown=null))});break;case"multiple":this.$nextTick(()=>{if(this.$canvas){const e=this.$getSelections();n?(e.forEach(e=>{e.active=!1}),this.active=!0,this.$emit(sn,{x:this.x,y:this.y,width:this.width,height:this.height})):(this.active=!1,e.slice(1).forEach(e=>{this.$removeSelection(e)}))}});break;case"precise":this.$nextTick(()=>{this.$change(this.x,this.y)});break;case"linked":n&&(this.dynamic=!0)}}connectedCallback(){super.connectedCallback();const e=this.closest(this.$getTagNameOf(_t));e?(this.$canvas=e,this.$setStyles({position:"absolute",transform:`translate(${this.x}px, ${this.y}px)`}),this.hidden||this.$render(),this.$initSelection(!0),this.$onCanvasActionStart=this.$handleActionStart.bind(this),this.$onCanvasActionEnd=this.$handleActionEnd.bind(this),this.$onCanvasAction=this.$handleAction.bind(this),Sn(e,on,this.$onCanvasActionStart),Sn(e,an,this.$onCanvasActionEnd),Sn(e,rn,this.$onCanvasAction)):this.$render()}disconnectedCallback(){const{$canvas:e}=this;e&&(this.$onCanvasActionStart&&(Cn(e,on,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(Cn(e,an,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasAction&&(Cn(e,rn,this.$onCanvasAction),this.$onCanvasAction=null)),super.disconnectedCallback()}$getSelections(){let e=[];return this.parentElement&&(e=Array.from(this.parentElement.querySelectorAll(this.$getTagNameOf(Mt)))),e}$initSelection(e=!1,t=!1){const{initialCoverage:n,parentElement:l}=this;if(bn(n)&&l){const r=this.aspectRatio||this.initialAspectRatio;let a=(t?0:this.width)||l.offsetWidth*n,o=(t?0:this.height)||l.offsetHeight*n;bn(r)&&({width:a,height:o}=Ln({aspectRatio:r,width:a,height:o})),this.$change(this.x,this.y,a,o),e&&this.$center(),this.$initialSelection={x:this.x,y:this.y,width:this.width,height:this.height}}}$createSelection(){const e=this.cloneNode(!0);return this.hasAttribute("id")&&e.removeAttribute("id"),e.initialCoverage=NaN,this.active=!1,this.parentElement&&this.parentElement.insertBefore(e,this.nextSibling),e}$removeSelection(e=this){if(this.parentElement){const t=this.$getSelections();if(t.length>1){const n=t.indexOf(e),l=t[n+1]||t[n-1];l&&(e.active=!1,this.parentElement.removeChild(e),l.active=!0,l.$emit(sn,{x:l.x,y:l.y,width:l.width,height:l.height}))}else this.$clear()}}$handleActionStart(e){var t,n;const l=null===(n=null===(t=e.detail)||void 0===t?void 0:t.relatedEvent)||void 0===n?void 0:n.target;this.$action="",this.$actionStartTarget=l,!this.hidden&&this.multiple&&!this.active&&l===this&&this.parentElement&&(this.$getSelections().forEach(e=>{e.active=!1}),this.active=!0,this.$emit(sn,{x:this.x,y:this.y,width:this.width,height:this.height}))}$handleAction(e){const{currentTarget:t,detail:n}=e;if(!t||!n)return;const{relatedEvent:l}=n;let{action:r}=n;const a=l?function(e){if("function"==typeof e.composedPath)return e.composedPath().find(gn)||e.target;return e.target}(l):null;if(!r&&this.multiple&&(r=this.$action||(null==a?void 0:a.action),this.$action=r),!r||this.hidden&&r!==Dt||this.multiple&&!this.active&&r!==Rt)return;const{width:o,height:i}=this;let s=n.endX-n.startX,c=n.endY-n.startY,{aspectRatio:u}=this;switch(!bn(u)&&l.shiftKey&&(u=bn(o)&&bn(i)?o/i:1),r){case Dt:if(0!==s||0!==c){0===s?s=c:0===c&&(c=s);const{$canvas:e}=this,l=$n(t);(this.multiple&&!this.hidden?this.$createSelection():this).$change(n.startX-l.left,n.startY-l.top,Math.abs(s),Math.abs(c),u),s<0?c<0?r=Gt:c>0&&(r=Xt):s>0&&(c<0?r=Kt:c>0&&(r=Qt)),e&&(e.$action=r)}break;case Ot:this.movable&&(this.dynamic||this.$actionStartTarget&&this.contains(this.$actionStartTarget))&&this.$move(s,c);break;case Rt:if(l&&this.zoomable&&(this.dynamic||this.contains(l.target))){const e=$n(t);this.$zoom(n.scale,l.pageX-e.left,l.pageY-e.top)}break;default:this.$resize(r,s,c,u)}}$handleActionEnd(){this.$action="",this.$actionStartTarget=null}$handleKeyDown(e){if(this.hidden||!this.keyboard||this.multiple&&!this.active||e.defaultPrevented)return;const{activeElement:t}=document;if(!t||!["INPUT","TEXTAREA"].includes(t.tagName)&&!["true","plaintext-only"].includes(t.contentEditable))switch(e.key){case"Backspace":e.metaKey&&(e.preventDefault(),this.$removeSelection());break;case"Delete":e.preventDefault(),this.$removeSelection();break;case"ArrowLeft":e.preventDefault(),this.$move(-1,0);break;case"ArrowRight":e.preventDefault(),this.$move(1,0);break;case"ArrowUp":e.preventDefault(),this.$move(0,-1);break;case"ArrowDown":e.preventDefault(),this.$move(0,1);break;case"+":e.preventDefault(),this.$zoom(.1);break;case"-":e.preventDefault(),this.$zoom(-.1)}}$center(){const{parentElement:e}=this;if(!e)return this;const t=(e.offsetWidth-this.width)/2,n=(e.offsetHeight-this.height)/2;return this.$change(t,n)}$move(e,t=e){return this.$moveTo(this.x+e,this.y+t)}$moveTo(e,t=e){return this.movable?this.$change(e,t):this}$resize(e,t=0,n=0,l=this.aspectRatio){if(!this.resizable)return this;const r=bn(l),{$canvas:a}=this;let{x:o,y:i,width:s,height:c}=this;switch(e){case Wt:i+=n,c-=n,c<0&&(e=Vt,c=-c,i-=c),r&&(o+=(t=n*l)/2,s-=t,s<0&&(s=-s,o-=s));break;case qt:s+=t,s<0&&(e=Ht,s=-s,o-=s),r&&(i-=(n=t/l)/2,c+=n,c<0&&(c=-c,i-=c));break;case Vt:c+=n,c<0&&(e=Wt,c=-c,i-=c),r&&(o-=(t=n*l)/2,s+=t,s<0&&(s=-s,o-=s));break;case Ht:o+=t,s-=t,s<0&&(e=qt,s=-s,o-=s),r&&(i+=(n=t/l)/2,c-=n,c<0&&(c=-c,i-=c));break;case Kt:r&&(n=-t/l),i+=n,c-=n,s+=t,s<0&&c<0?(e=Xt,s=-s,c=-c,o-=s,i-=c):s<0?(e=Gt,s=-s,o-=s):c<0&&(e=Qt,c=-c,i-=c);break;case Gt:r&&(n=t/l),o+=t,i+=n,s-=t,c-=n,s<0&&c<0?(e=Qt,s=-s,c=-c,o-=s,i-=c):s<0?(e=Kt,s=-s,o-=s):c<0&&(e=Xt,c=-c,i-=c);break;case Qt:r&&(n=t/l),s+=t,c+=n,s<0&&c<0?(e=Gt,s=-s,c=-c,o-=s,i-=c):s<0?(e=Xt,s=-s,o-=s):c<0&&(e=Kt,c=-c,i-=c);break;case Xt:r&&(n=-t/l),o+=t,s-=t,c+=n,s<0&&c<0?(e=Kt,s=-s,c=-c,o-=s,i-=c):s<0?(e=Qt,s=-s,o-=s):c<0&&(e=Gt,c=-c,i-=c)}return a&&a.$setAction(e),this.$change(o,i,s,c)}$zoom(e,t,n){if(!this.zoomable||0===e)return this;e<0?e=1/(1-e):e+=1;const{width:l,height:r}=this,a=l*e,o=r*e;let i=this.x,s=this.y;return dn(t)&&dn(n)?(i-=(a-l)*((t-this.x)/l),s-=(o-r)*((n-this.y)/r)):(i-=(a-l)/2,s-=(o-r)/2),this.$change(i,s,a,o)}$change(e,t,n=this.width,l=this.height,r=this.aspectRatio,a=!1){return this.$changing||!dn(e)||!dn(t)||!dn(n)||!dn(l)||n<0||l<0?this:(bn(r)&&({width:n,height:l}=Ln({aspectRatio:r,width:n,height:l},"cover")),this.precise||(e=Math.round(e),t=Math.round(t),n=Math.round(n),l=Math.round(l)),e===this.x&&t===this.y&&n===this.width&&l===this.height&&Object.is(r,this.aspectRatio)&&!a?this:(this.hidden&&(this.hidden=!1),!1===this.$emit(sn,{x:e,y:t,width:n,height:l})?this:(this.$changing=!0,this.x=e,this.y=t,this.width=n,this.height=l,this.$changing=!1,this.$render())))}$reset(){const{x:e,y:t,width:n,height:l}=this.$initialSelection;return this.$change(e,t,n,l)}$clear(){return this.$change(0,0,0,0,NaN,!0),this.hidden=!0,this}$render(){return this.$setStyles({transform:`translate(${this.x}px, ${this.y}px)`,width:this.width,height:this.height})}$toCanvas(e){return new Promise((t,n)=>{if(!this.isConnected)return void n(new Error("The current element is not connected to the DOM."));const l=document.createElement("canvas");let{width:r,height:a}=this,o=1;if(pn(e)&&(bn(e.width)||bn(e.height))&&(({width:r,height:a}=Ln({aspectRatio:r/a,width:e.width,height:e.height})),o=r/this.width),l.width=r,l.height=a,!this.$canvas)return void t(l);const i=this.$canvas.querySelector(this.$getTagNameOf(At));i?i.$ready().then(n=>{const s=l.getContext("2d");if(s){const[t,c,u,d,b,m]=i.$getTransform(),h=-this.x,p=-this.y,f=(h*d-u*p)/(t*d-u*c),g=(p*t-c*h)/(t*d-u*c);let y=t*f+u*g+b,v=c*f+d*g+m,x=n.naturalWidth,w=n.naturalHeight;1!==o&&(y*=o,v*=o,x*=o,w*=o);const k=x/2,C=w/2;s.fillStyle="transparent",s.fillRect(0,0,r,a),pn(e)&&fn(e.beforeDraw)&&e.beforeDraw.call(this,s,l),s.save(),s.translate(k,C),s.transform(t,c,u,d,y,v),s.translate(-k,-C),s.drawImage(n,0,0,x,w),s.restore()}t(l)}).catch(n):t(l)})}}Qn.$name=Mt,Qn.$version="2.1.0";class Xn extends Fn{constructor(){super(...arguments),this.$style=":host{display:flex;flex-direction:column;position:relative;touch-action:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}:host([bordered]){border:1px dashed var(--theme-color)}:host([covered]){bottom:0;left:0;position:absolute;right:0;top:0}:host>span{display:flex;flex:1}:host>span+span{border-top:1px dashed var(--theme-color)}:host>span>span{flex:1}:host>span>span+span{border-left:1px dashed var(--theme-color)}",this.bordered=!1,this.columns=3,this.covered=!1,this.rows=3,this.slottable=!1,this.themeColor="rgba(238, 238, 238, 0.5)"}static get observedAttributes(){return super.observedAttributes.concat(["bordered","columns","covered","rows"])}$propertyChangedCallback(e,t,n){Object.is(n,t)||(super.$propertyChangedCallback(e,t,n),"rows"!==e&&"columns"!==e||this.$nextTick(()=>{this.$render()}))}connectedCallback(){super.connectedCallback(),this.$render()}$render(){const e=this.$getShadowRoot(),t=document.createDocumentFragment();for(let n=0;n<this.rows;n+=1){const e=document.createElement("span");e.setAttribute("role","row");for(let t=0;t<this.columns;t+=1){const t=document.createElement("span");t.setAttribute("role","gridcell"),e.appendChild(t)}t.appendChild(e)}e&&(e.innerHTML="",e.appendChild(t))}}Xn.$name=zt,Xn.$version="2.1.0";class Yn extends Fn{constructor(){super(...arguments),this.$style=':host{display:inline-block;height:1em;position:relative;touch-action:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;vertical-align:middle;width:1em}:host:after,:host:before{background-color:var(--theme-color);content:"";display:block;position:absolute}:host:before{height:1px;left:0;top:50%;transform:translateY(-50%);width:100%}:host:after{height:100%;left:50%;top:0;transform:translateX(-50%);width:1px}:host([centered]){left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}',this.centered=!1,this.slottable=!1,this.themeColor="rgba(238, 238, 238, 0.5)"}static get observedAttributes(){return super.observedAttributes.concat(["centered"])}}Yn.$name=Tt,Yn.$version="2.1.0";const Jn=new WeakMap,Zn=new WeakMap,el=new WeakMap,tl=new WeakMap,nl="vertical";class ll extends Fn{constructor(){super(...arguments),this.$onSelectionChange=null,this.$onSourceImageLoad=null,this.$onSourceImageTransform=null,this.$scale=1,this.$style=":host{display:block;height:100%;overflow:hidden;position:relative;width:100%}",this.resize=nl,this.selection="",this.slottable=!1}set $image(e){Zn.set(this,e)}get $image(){return Zn.get(this)}set $sourceImage(e){tl.set(this,e)}get $sourceImage(){return tl.get(this)}set $canvas(e){Jn.set(this,e)}get $canvas(){return Jn.get(this)}set $selection(e){el.set(this,e)}get $selection(){return el.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["resize","selection"])}connectedCallback(){var e,t;super.connectedCallback();let n=null;if(n=this.selection?null!==(t=null===(e=function(e){const t=e.getRootNode();switch(t.nodeType){case 1:return t.ownerDocument;case 9:case 11:return t}return null}(this))||void 0===e?void 0:e.querySelector(this.selection))&&void 0!==t?t:null:this.closest(this.$getTagNameOf(Mt)),gn(n)){this.$selection=n,this.$onSelectionChange=this.$handleSelectionChange.bind(this),Sn(n,sn,this.$onSelectionChange);const e=n.closest(this.$getTagNameOf(_t));if(e){this.$canvas=e;const t=e.querySelector(this.$getTagNameOf(At));t&&(this.$sourceImage=t,this.$image=t.cloneNode(!0),this.$getShadowRoot().appendChild(this.$image),this.$onSourceImageLoad=this.$handleSourceImageLoad.bind(this),this.$onSourceImageTransform=this.$handleSourceImageTransform.bind(this),Sn(t.$image,nn,this.$onSourceImageLoad),Sn(t,cn,this.$onSourceImageTransform))}this.$render()}}disconnectedCallback(){const{$selection:e,$sourceImage:t}=this;e&&this.$onSelectionChange&&(Cn(e,sn,this.$onSelectionChange),this.$onSelectionChange=null),t&&this.$onSourceImageLoad&&(Cn(t.$image,nn,this.$onSourceImageLoad),this.$onSourceImageLoad=null),t&&this.$onSourceImageTransform&&(Cn(t,cn,this.$onSourceImageTransform),this.$onSourceImageTransform=null),super.disconnectedCallback()}$handleSelectionChange(e){this.$render(e.defaultPrevented?this.$selection:e.detail)}$handleSourceImageLoad(){const{$image:e,$sourceImage:t}=this,n=e.getAttribute("src"),l=t.getAttribute("src");l&&l!==n&&(e.setAttribute("src",l),e.$ready(()=>{this.$render()}))}$handleSourceImageTransform(e){this.$render(void 0,e.detail.matrix)}$render(e,t){const{$canvas:n,$selection:l}=this;e||l.hidden||(e=l),(!e||0===e.x&&0===e.y&&0===e.width&&0===e.height)&&(e={x:0,y:0,width:n.offsetWidth,height:n.offsetHeight});const{x:r,y:a,width:o,height:i}=e,s={},{clientWidth:c,clientHeight:u}=this;let d=c,b=u,m=NaN;switch(this.resize){case"both":m=1,d=o,b=i,s.width=o,s.height=i;break;case"horizontal":m=i>0?u/i:0,d=o*m,s.width=d;break;case nl:m=o>0?c/o:0,b=i*m,s.height=b;break;default:c>0?m=o>0?c/o:0:u>0&&(m=i>0?u/i:0)}this.$scale=m,this.$setStyles(s),this.$sourceImage&&setTimeout(()=>{this.$transformImageByOffset(null!=t?t:this.$sourceImage.$getTransform(),-r,-a)})}$transformImageByOffset(e,t,n){const{$image:l,$scale:r,$sourceImage:a}=this;if(a&&l&&r>=0){const[a,o,i,s,c,u]=e,d=(t*s-i*n)/(a*s-i*o),b=(n*a-o*t)/(a*s-i*o),m=a*d+i*b+c,h=o*d+s*b+u;l.$ready(e=>{this.$setStyles.call(l,{width:e.naturalWidth*r,height:e.naturalHeight*r})}),l.$setTransform(a,o,i,s,m*r,h*r)}}}function rl(){const[e,t]=y.useState(!1),[n,l]=y.useState(null),[r,a]=y.useState(null),o=async(e,r)=>{if(!e||!r)return l("ID de asset y configuración de variante son requeridos"),null;t(!0),l(null),a(null);try{const t=await async function(e,{variant_name:t,width:l,height:r,crop_params:a,preset_aspect:o=null,preset_size:i=null,output_format:s="webp"}){try{const n=[{name:t,width:l,height:r,output_format:s,crop_params:a}];return o&&(n[0].preset_aspect=o),i&&(n[0].preset_size=i),pe(await ce({endpoint:`/assets/${e}/variants`,method:"POST",body:{variants:n,async:!1},basePath:ge,useJWT:!0}))}catch(n){throw fe(n)}}(e,{variant_name:r.name,width:r.width,height:r.height,crop_params:r.crop_params,preset_aspect:r.preset_aspect,preset_size:r.preset_size,output_format:r.output_format});if(t?.result)return a(t.result),t.result;throw new Error("No se pudo crear la variante")}catch(o){return console.error("Error creating variant:",o),l(o.message||"Error desconocido al crear variante"),null}finally{t(!1)}};return{createVariant:o,createCropVariant:async(e,t,n={})=>{const l={name:n.name||`crop_${Date.now()}`,width:n.width||800,height:n.height||600,output_format:n.format||"webp",crop_params:{x:t.x||0,y:t.y||0,width:t.width||1,height:t.height||1}};return await o(e,l)},createVariantFromBlob:async(e,r,o={})=>{if(!e||!r)return l("ID de asset y blob son requeridos"),null;t(!0),l(null),a(null);try{const t=await async function(e,t,l={}){try{const n=new FormData,r=l.format||"webp",a=`${l.name||"variant"}.${r}`;return n.append("file",t,a),n.append("variant_name",l.name||"variant"),n.append("width",String(l.width||0)),n.append("height",String(l.height||0)),n.append("output_format",l.format||"webp"),n.append("permanent_url",!1!==l.permanentUrl?"true":"false"),pe(await ce({endpoint:`/assets/${e}/variants/upload`,method:"POST",body:n,basePath:ge,isFormData:!0,useJWT:!0}))}catch(n){throw fe(n)}}(e,r,{name:o.name||`crop_${Date.now()}`,width:o.width||0,height:o.height||0,format:o.format||"webp"});if(t?.result)return a(t.result),t.result;throw new Error("No se pudo crear la variante")}catch(i){return console.error("Error creating variant from blob:",i),l(i.message||"Error desconocido al crear variante"),null}finally{t(!1)}},loading:e,error:n,createdVariant:r,reset:()=>{l(null),a(null)}}}ll.$name=It,ll.$version="2.1.0",Un.$define(),Yn.$define(),Xn.$define(),Kn.$define(),qn.$define(),Qn.$define(),Hn.$define(),ll.$define();class al{constructor(e,t,n){this.canvasRef=e,this.imageRef=t,this.selectionRef=n}get canvasElement(){return this.canvasRef?.current}get image(){return this.imageRef?.current}get selectionElement(){return this.selectionRef?.current}get isReady(){return!!(this.canvasElement&&this.image&&this.selectionElement)}transform={move:(e,t)=>{if(!this.image)return!1;try{return this.image.$move(e,t),!0}catch(n){return console.warn("Error moving image:",n),!1}},moveTo:(e,t)=>{if(!this.image)return!1;try{return this.image.$moveTo(e,t),!0}catch(n){return console.warn("Error moving image to position:",n),!1}},zoom:e=>{if(!this.image)return!1;try{return this.image.$zoom(e),!0}catch(t){return console.warn("Error zooming image:",t),!1}},rotate:e=>{if(!this.image)return!1;try{const t=e*Math.PI/180;return this.image.$rotate(t),!0}catch(t){return console.warn("Error rotating image:",t),!1}},scale:(e,t=e)=>{if(!this.image)return!1;try{return this.image.$scale(e,t),!0}catch(n){return console.warn("Error scaling image:",n),!1}},center:(e="contain")=>{if(!this.image)return!1;try{return this.image.$center(e),!0}catch(t){return console.warn("Error centering image:",t),!1}},reset:()=>{if(!this.image)return!1;try{return this.image.$resetTransform(),!0}catch(e){return console.warn("Error resetting transform:",e),!1}},getTransform:()=>{if(!this.image)return null;try{return this.image.$getTransform()}catch(e){return console.warn("Error getting transform:",e),null}},setTransform:(e,t,n,l,r,a)=>{if(!this.image)return!1;try{return this.image.$setTransform(e,t,n,l,r,a),!0}catch(o){return console.warn("Error setting transform:",o),!1}},resetZoom:()=>{if(!this.image)return!1;try{const e=this.image.$getTransform();if(!e)return!1;const[t,n,l,r,a,o]=e,i=Math.sqrt(t*t+n*n),s=Math.sqrt(l*l+r*r),c=t/i,u=n/i,d=l/s,b=r/s;return this.image.$setTransform(c,u,d,b,a,o),!0}catch(e){return console.warn("Error resetting zoom:",e),!1}},setZoom:e=>{if(!this.image||e<=0)return!1;try{const t=this.image.$getTransform();if(!t)return!1;const[n,l,r,a,o,i]=t,s=Math.sqrt(n*n+l*l),c=Math.sqrt(r*r+a*a),u=n/s*e,d=l/s*e,b=r/c*e,m=a/c*e;return this.image.$setTransform(u,d,b,m,o,i),!0}catch(t){return console.warn("Error setting zoom level:",t),!1}},getZoom:()=>{if(!this.image)return 1;try{const e=this.image.$getTransform();if(!e)return 1;const[t,n]=e;return Math.sqrt(t*t+n*n)}catch(e){return console.warn("Error getting zoom level:",e),1}},fitToCanvas:(e=.1)=>{if(!this.image||!this.canvasElement)return!1;try{const t=this.canvasElement.getBoundingClientRect();let n=this.image.querySelector("img")||this.image;if(!n?.naturalWidth||!n?.naturalHeight)return!1;const l=1-e,r=t.width*l/n.naturalWidth,a=t.height*l/n.naturalHeight,o=Math.min(r,a,1);return this.transform.setZoom(o)}catch(t){return console.warn("Error fitting to canvas:",t),!1}}};selection={center:()=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$center(),!0}catch(e){return console.warn("Error centering selection:",e),!1}},reset:()=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$reset(),!0}catch(e){return console.warn("Error resetting selection:",e),!1}},setCoverage:e=>{if(!this.selectionElement||e<0||e>1)return!1;try{return this.selectionElement.initialCoverage=e,this.selectionElement.$reset(),!0}catch(t){return console.warn("Error setting coverage:",t),!1}},setAspectRatio:e=>{if(!this.selectionElement)return!1;try{let t;if(""===e||null==e)t=NaN;else if("number"==typeof e)t=e;else{if("string"!=typeof e)return console.warn("Unsupported aspect ratio type:",typeof e,e),!1;if(e.includes("/")){const[n,l]=e.split("/").map(e=>parseFloat(e.trim()));if(isNaN(n)||isNaN(l)||0===l)return console.warn("Invalid aspect ratio format:",e),!1;t=n/l}else if(t=parseFloat(e),isNaN(t))return console.warn("Invalid aspect ratio format:",e),!1}return this.selectionElement.aspectRatio=t,this.selectionElement.$render(),!0}catch(t){return console.warn("Error setting aspect ratio:",t),!1}},move:(e,t)=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$move(e,t),!0}catch(n){return console.warn("Error moving selection:",n),!1}},zoom:e=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$zoom(e),!0}catch(t){return console.warn("Error zooming selection:",t),!1}},change:(e,t,n,l,r)=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$change(e,t,n,l,r),!0}catch(a){return console.warn("Error changing selection:",a),!1}},set:(e,t,n,l)=>{if(!this.selectionElement)return!1;try{return this.selectionElement.x=e,this.selectionElement.y=t,this.selectionElement.width=n,this.selectionElement.height=l,this.selectionElement.$render(),!0}catch(r){return console.warn("Error setting selection:",r),!1}},toCanvas:async(e={})=>{if(!this.selectionElement)return null;try{const t={width:800,height:600,imageSmoothingEnabled:!0,imageSmoothingQuality:"high",...e};return await this.selectionElement.$toCanvas(t)}catch(t){return console.warn("Error exporting to canvas:",t),null}},getData:()=>{if(!this.selectionElement)return null;try{return{x:this.selectionElement.x,y:this.selectionElement.y,width:this.selectionElement.width,height:this.selectionElement.height,aspectRatio:this.selectionElement.aspectRatio}}catch(e){return console.warn("Error getting selection data:",e),null}}};canvas={setBackground:e=>{if(!this.canvasElement)return!1;try{return this.canvasElement.background=e,!0}catch(t){return console.warn("Error setting background:",t),!1}},setScaleStep:e=>{if(!this.canvasElement)return!1;try{return this.canvasElement.scaleStep=e,!0}catch(t){return console.warn("Error setting scale step:",t),!1}},setDisabled:e=>{if(!this.canvasElement)return!1;try{return this.canvasElement.disabled=e,!0}catch(t){return console.warn("Error setting disabled state:",t),!1}}};utils={flipHorizontal:()=>{const e=this.transform.getTransform();if(!e)return!1;const[t,n,l,r,a,o]=e;return this.transform.setTransform(-t,n,l,r,a,o)},flipVertical:()=>{const e=this.transform.getTransform();if(!e)return!1;const[t,n,l,r,a,o]=e;return this.transform.setTransform(t,n,l,-r,a,o)},setupInitialView:async(e={})=>{const{paspartuFactor:t=.85,retries:n=3,retryDelay:l=200}=e;return new Promise(e=>{const r=(a=0)=>{if(!this.isReady)return a<n?void setTimeout(()=>r(a+1),l):void e(!1);try{const o=this.canvasElement.getBoundingClientRect();let i=this.image.querySelector("img")||this.image;if(!i?.naturalWidth||!i?.naturalHeight)return a<n?void setTimeout(()=>r(a+1),l):(this.transform.center(),void e(!1));if(o.width>0&&o.height>0){const n=o.width*t/i.naturalWidth,l=o.height*t/i.naturalHeight,r=Math.min(n,l,1);this.transform.setTransform(r,0,0,r,0,0)?setTimeout(()=>{this.transform.center(),this.selection.center(),e(!0)},100):(this.transform.reset(),setTimeout(()=>{r<1&&this.transform.scale(r),setTimeout(()=>{this.transform.center(),this.selection.center(),e(!0)},100)},100))}else this.transform.center(),e(!1)}catch(o){console.warn("Error in setup:",o),this.transform.center(),e(!1)}};r()})},resetAll:()=>{const e={transform:this.transform.reset(),selection:this.selection.reset(),center:!1};return setTimeout(()=>{e.center=this.transform.center()&&this.selection.center()},100),e},checkExportability:async()=>{try{return!!(await this.selection.toCanvas({width:1,height:1}))}catch{return!1}},resetZoomOnly:()=>this.transform.resetZoom(),getZoomInfo:()=>{const e=this.transform.getZoom();return{current:e,isZoomedIn:e>1,isZoomedOut:e<1,percentage:Math.round(100*e)}},setBackground:e=>this.canvas.setBackground(e)};setupEventListeners(e={}){const{onSelectionChange:t,onImageTransform:n,onAction:l,onActionStart:r,onActionMove:a,onActionEnd:o}=e,i=[];if(t&&this.selectionElement){const e=e=>{t({x:e.detail.x,y:e.detail.y,width:e.detail.width,height:e.detail.height})};this.selectionElement.addEventListener("change",e),i.push(()=>{this.selectionElement&&this.selectionElement.removeEventListener("change",e)})}if(n&&this.image){const e=e=>{n({matrix:e.detail.matrix,oldMatrix:e.detail.oldMatrix})};this.image.addEventListener("transform",e),i.push(()=>{this.image&&this.image.removeEventListener("transform",e)})}if(this.canvasElement){if(l){const e=e=>l(e.detail);this.canvasElement.addEventListener("action",e),i.push(()=>{this.canvasElement&&this.canvasElement.removeEventListener("action",e)})}if(r){const e=e=>r(e.detail);this.canvasElement.addEventListener("actionstart",e),i.push(()=>{this.canvasElement&&this.canvasElement.removeEventListener("actionstart",e)})}if(a){const e=e=>a(e.detail);this.canvasElement.addEventListener("actionmove",e),i.push(()=>{this.canvasElement&&this.canvasElement.removeEventListener("actionmove",e)})}if(o){const e=e=>o(e.detail);this.canvasElement.addEventListener("actionend",e),i.push(()=>{this.canvasElement&&this.canvasElement.removeEventListener("actionend",e)})}}return()=>{i.forEach(e=>e())}}}async function ol(e,t,n={}){const{format:l=null,originalFormat:r="webp",onSuccess:a=null,onError:o=null,accessibilityManager:i=null}=n;try{const n=window.limboCore?.config?.getGlobal(),o=l||n?.downloadFormat||r||"webp",c=`${t.split(".")[0]}.${o}`;if(i&&i.announce(`Descargando ${c}`),e.startsWith("data:image/"))return function(e,t){const n=document.createElement("a");n.href=e,n.download=t,n.style.display="none",document.body.appendChild(n),n.click(),setTimeout(()=>{document.body.removeChild(n)},100)}(e,c),a&&a(c),i&&i.announce(`${c} descargado correctamente`),!0;let u;try{if(u=await fetch(e,{mode:"cors"}),!u.ok)throw new Error(`HTTP error! status: ${u.status}`)}catch(s){if(!e.startsWith("http"))throw s;{const t=(window.limboCore?.config?.getGlobal()||{}).prod?"https://limbo.lefebvre.es":"https://led-dev-limbo-dev.eu.els.local",n=window.limboCore?.apiClient?.token||"",l=`${t}/api/atenea/proxy?url=${encodeURIComponent(e)}`;if(u=await fetch(l,{credentials:"include",headers:{Authorization:`Bearer ${n}`}}),!u.ok)throw new Error(`Proxy error: ${u.status}`)}}const d=await u.blob();let b=d;const m=d.type;m!==`image/${"jpg"===o?"jpeg":o}`&&function(e){return["webp","jpeg","jpg","png"].includes(e.toLowerCase())}(o)&&(b=await async function(e,t){return new Promise((n,l)=>{const r=new Image,a=URL.createObjectURL(e);r.onload=()=>{try{const l=document.createElement("canvas");l.width=r.width,l.height=r.height;l.getContext("2d").drawImage(r,0,0);const o=`image/${"jpg"===t?"jpeg":t}`,i="png"===t?void 0:.92;l.toBlob(t=>{URL.revokeObjectURL(a),n(t||e)},o,i)}catch(l){URL.revokeObjectURL(a),n(e)}},r.onerror=()=>{URL.revokeObjectURL(a),n(e)},r.src=a})}(d,o));const h=window.URL.createObjectURL(b),p=document.createElement("a");return p.href=h,p.download=c,p.style.display="none",document.body.appendChild(p),p.click(),setTimeout(()=>{window.URL.revokeObjectURL(h),document.body.removeChild(p)},100),a&&a(c),i&&i.announce(`${c} descargado correctamente`),!0}catch(c){return console.error("Error downloading image:",c),o&&o(c),i&&i.announce(`Error al descargar la imagen: ${c.message}`),!1}}const il=Object.freeze(Object.defineProperty({__proto__:null,default:ol,downloadImage:ol},Symbol.toStringTag,{value:"Module"}));function sl({image:e,onSave:t,onCancel:n,onDelete:l,onError:r=null,deleting:a=!1,onVariantCreated:o=null,onUpload:i=null,uploading:s=!1,cropperConfig:c=null}){const[u,d]=y.useState(!1),[b,m]=y.useState(null),[h,p]=y.useState(!1),[f,g]=y.useState(!0),[v,x]=y.useState(!0),[w,k]=y.useState({x:20,y:100}),[C,S]=y.useState(!1),[j,N]=y.useState({x:0,y:0}),[E,$]=y.useState(!1),[_,T]=y.useState(!0),[z,L]=y.useState(!1),[A,M]=y.useState({horizontal:!1,vertical:!1}),[P,I]=y.useState(!1),[D,O]=y.useState(!1),[R,U]=y.useState(!1),[B,W]=y.useState(!1),[q]=y.useState(()=>{if(!e||!e.filename)return"image";const[t]=e.filename.split(".");return t}),V=y.useMemo(()=>{if(c)return{mandatoryCrops:c.mandatoryCrops||[],allowCustomCrops:!1!==c.allowAdditionalCrops,showDimensionInputs:!0===c.showDimensionInputs,maxCrops:c.maxCrops||null,localCropsOnly:!0===c.localCropsOnly,existingCrops:c.existingCrops||null};const e=window.limboCore?.config?.getGlobal()||{};return{mandatoryCrops:e.cropper?.mandatoryCrops||[],allowCustomCrops:!1!==e.cropper?.allowCustomCrops,showDimensionInputs:!0===e.cropper?.showDimensionInputs,maxCrops:e.cropper?.maxCrops||null,localCropsOnly:!0===e.cropper?.localCropsOnly,existingCrops:e.cropper?.existingCrops||null}},[c]),[H,K]=y.useState(()=>V.mandatoryCrops.length>0?V.mandatoryCrops.map((e,t)=>({id:`crop-${t}`,label:e.label,width:e.width,height:e.height,required:!1!==e.required,isCustom:!1,confirmed:!1,lockDimensions:!(!e.width||!e.height),format:e.format||null,savedState:null})):[{id:"crop-default-0",label:q,width:e.width||1920,height:e.height||1080,required:!1,isCustom:!0,confirmed:!1,savedState:null}]),[G,Q]=y.useState(0),X=H[G],Y=y.useMemo(()=>X&&X.width&&X.height?X.width/X.height:"",[X]),J=y.useMemo(()=>{const e=50;if(!Y||""===Y)return{minWidth:e,minHeight:e};if(Y>=1){return{minWidth:e,minHeight:e/Y}}return{minWidth:e*Y,minHeight:e}},[Y]),[Z,ee]=y.useState(!1),[te,ne]=y.useState([]),[le,re]=y.useState(null),ae=window.limboCore?.accessibilityManager,{createVariantFromBlob:oe,loading:ie,error:se}=rl(),ce=((e,t={})=>{const n=y.useRef(null),l=y.useRef(null),r=y.useRef(null),a=y.useRef(null),[o,i]=y.useState(null),[s,c]=y.useState(null),[u,d]=y.useState(!1),[b,m]=y.useState(!0),[h,p]=y.useState(0),f={aspectRatio:"",shade:!0,paspartuFactor:.85,...t};y.useEffect(()=>{n.current&&l.current&&r.current&&(a.current=new al(n,l,r),d(!0))},[]),y.useEffect(()=>{if(a.current)return a.current.setupEventListeners({onSelectionChange:e=>{i(e)},onImageTransform:()=>{p(e=>e+1)}})},[u]),y.useEffect(()=>{a.current&&e&&(async()=>{a.current.selection.setAspectRatio(f.aspectRatio),a.current.canvas.setBackground(f.shade),await a.current.utils.setupInitialView({paspartuFactor:f.paspartuFactor});const e=await a.current.utils.checkExportability();m(e);const t=l.current?.querySelector("img")||l.current;t?.naturalWidth&&t?.naturalHeight&&c({naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight,currentWidth:t.width,currentHeight:t.height})})()},[e]),y.useEffect(()=>{a.current&&u&&a.current.selection.setAspectRatio(f.aspectRatio)},[f.aspectRatio,u]),y.useEffect(()=>{a.current&&u&&a.current.canvas.setBackground(f.shade)},[f.shade,u]);const g=y.useCallback(()=>({move:(e,t)=>a.current?.transform.move(e,t)||!1,zoom:e=>a.current?.transform.zoom(e)||!1,rotate:e=>a.current?.transform.rotate(e)||!1,center:()=>a.current?.transform.center()||!1,reset:()=>a.current?.transform.reset()||!1,resetZoom:()=>a.current?.transform.resetZoom()||!1,setZoom:e=>a.current?.transform.setZoom(e)||!1,getZoom:()=>a.current?.transform.getZoom()||1,fitToCanvas:e=>a.current?.transform.fitToCanvas(e)||!1,flipHorizontal:()=>a.current?.utils.flipHorizontal()||!1,flipVertical:()=>a.current?.utils.flipVertical()||!1}),[]),v=y.useCallback(()=>({center:()=>a.current?.selection.center()||!1,reset:()=>a.current?.selection.reset()||!1,setCoverage:e=>a.current?.selection.setCoverage(e)||!1,setAspectRatio:e=>a.current?.selection.setAspectRatio(e)||!1,toCanvas:e=>a.current?.selection.toCanvas(e)||Promise.resolve(null)}),[]),x=y.useCallback(()=>({resetAll:()=>{if(a.current){const e=a.current.utils.resetAll();return i(null),e}return!1},setBackground:e=>a.current?.canvas.setBackground(e)||!1,resetZoomOnly:()=>a.current?.utils.resetZoomOnly()||!1,getZoomInfo:()=>a.current?.utils.getZoomInfo()||{current:1,percentage:100,isZoomedIn:!1,isZoomedOut:!1}}),[]);return{refs:{canvasRef:n,imageRef:l,selectionRef:r},state:{cropData:o,imageInfo:s,isReady:u,canExport:b,transformVersion:h},transform:g(),selection:v(),utils:x(),manager:a.current}})(e,{aspectRatio:Y||null,showGrid:f,shade:v,initialCoverage:.5,paspartuFactor:.85}),{refs:ue,state:de,transform:be,selection:me,utils:he}=ce,{canvasRef:pe,imageRef:fe,selectionRef:ge}=ue,{cropData:ye,imageInfo:ve,canExport:xe,transformVersion:we}=de,ke=y.useMemo(()=>ve||{naturalWidth:e.width||1920,naturalHeight:e.height||1080,currentWidth:e.width||1920,currentHeight:e.height||1080},[ve,e.width,e.height]),Ce=y.useCallback(()=>g(e=>!e),[]),Se=y.useCallback(()=>x(e=>!e),[]),je=y.useCallback(()=>O(e=>!e),[]),Ne=y.useCallback(()=>U(e=>!e),[]),Ee=y.useCallback(()=>W(e=>!e),[]),$e=y.useCallback(()=>be.center(),[be]),_e=y.useCallback(()=>me.center(),[me]),Te=y.useCallback(()=>me.reset(),[me]),ze=y.useCallback((e,t)=>be.move(e,t),[be]),Le=y.useCallback(e=>be.zoom(e),[be]),Ae=y.useCallback(e=>be.rotate(e),[be]),Me=y.useCallback(e=>{me.setCoverage(e)},[me]),Ie=y.useCallback(()=>{M(e=>{const t=!e.horizontal;return be.flipHorizontal(),{...e,horizontal:t}})},[be]),De=y.useCallback(()=>{M(e=>{const t=!e.vertical;return be.flipVertical(),{...e,vertical:t}})},[be]),Oe=y.useCallback(()=>{if(!ce.manager||!de.isReady)return null;try{const e=ye?{...ye}:null;let t=null;if(ge.current){const e=ge.current;t={x:e.x??0,y:e.y??0,width:e.width??0,height:e.height??0}}let n=null;if(fe.current){const e=fe.current.$getTransform?.();e&&Array.isArray(e)&&(n=[...e])}const l={cropData:e,selectorState:t,imageTransform:n,flipState:{horizontal:A.horizontal,vertical:A.vertical}};return console.log(`[CropperView] 💾 Guardando estado del crop ${G}:`,l),K(e=>e.map((e,t)=>t===G?{...e,savedState:l}:e)),l}catch(e){return console.warn("Error saving crop state:",e),null}},[ce.manager,de.isReady,ye,A,G,fe,ge]),Re=y.useCallback(e=>{const t=H[e];if(!t||!t.savedState)return console.log(`[CropperView] ℹ️ No hay estado guardado para crop ${e}, centrando...`),void setTimeout(()=>{$e(),setTimeout(()=>_e(),100)},100);if(ce.manager&&de.isReady)try{const{savedState:n}=t;if(console.log(`[CropperView] ♻️ Restaurando estado del crop ${e}:`,n),n.imageTransform&&fe.current&&Array.isArray(n.imageTransform)&&setTimeout(()=>{if(fe.current&&fe.current.$setTransform){const[e,t,l,r,a,o]=n.imageTransform;fe.current.$setTransform(e,t,l,r,a,o),console.log(`[CropperView] ✅ Imagen restaurada: transform(${e.toFixed(2)}, ${t.toFixed(2)}, ${l.toFixed(2)}, ${r.toFixed(2)}, ${a.toFixed(0)}, ${o.toFixed(0)})`)}},100),n.selectorState&&ge.current){const{x:e,y:t,width:l,height:r}=n.selectorState;setTimeout(()=>{ge.current&&(ge.current.x=e,ge.current.y=t,ge.current.width=l,ge.current.height=r,ge.current.$render&&ge.current.$render(),console.log(`[CropperView] ✅ Selector restaurado: ${l}×${r} en (${e}, ${t})`))},150)}n.flipState&&M({horizontal:n.flipState.horizontal??!1,vertical:n.flipState.vertical??!1}),console.log("[CropperView] ✨ Estado restaurado completamente")}catch(n){console.error("Error restoring crop state:",n),setTimeout(()=>{$e(),setTimeout(()=>_e(),100)},100)}else console.warn("Cropper not ready for state restoration")},[H,ce.manager,de.isReady,$e,_e,ge,fe]),Fe=y.useCallback(()=>{for(let e=0;e<H.length;e++){const t=H[e];if(!t.label||""===t.label.trim())return e}return-1},[H]),Ue=y.useCallback(async e=>{e!==G&&(L(!0),Oe(),await new Promise(e=>setTimeout(e,100)),Q(e),await new Promise(e=>setTimeout(e,250)),Re(e),await new Promise(e=>setTimeout(e,200)),L(!1))},[G,Oe,Re]),Be=y.useCallback(()=>{if(!V.allowCustomCrops)return void alert("No se pueden añadir recortes personalizados en este modo.");const t={id:`crop-custom-${Date.now()}`,label:`Recorte ${H.length+1}`,width:e.width||1920,height:e.height||1080,required:!1,isCustom:!0,confirmed:!1,savedState:null};K(e=>[...e,t]),ae?.announce(`Nuevo recorte personalizado añadido: ${t.label}. Selecciónalo para editarlo.`)},[V.allowCustomCrops,H.length,e.width,e.height,ae]),We=y.useCallback((e,t)=>{const n=parseInt(t,10);""===t||isNaN(n)||K(t=>t.map((t,l)=>l===G?{...t,[e]:n}:t))},[G]),qe=y.useCallback(e=>{const t=X[e];let n=100;if(pe.current&&ve){const e=pe.current.getBoundingClientRect(),t=Math.min(e.width,e.height);n=Math.max(100,Math.round(.05*t))}const l=Math.max(n,Math.min(5e3,t));l!==t&&K(t=>t.map((t,n)=>n===G?{...t,[e]:l}:t));const r={...X,[e]:l},a=r.width/r.height,o=me.getData?.();me.setAspectRatio(a),o&&void 0!==o.x&&setTimeout(()=>{me.set?.(o.x,o.y,o.width,o.height)},50)},[G,X,me,pe,ve]),Ve=y.useCallback(e=>{K(t=>t.map((t,n)=>n===G?{...t,label:e}:t))},[G]),He=y.useCallback((e,t=null)=>{t=t||H[e].label;if(!window.confirm(`¿Estás seguro de que deseas eliminar "${t||"este recorte"}"? Esta acción también eliminará todos sus recortes.`))return;const n=H[e];if(n.required)alert("No se puede eliminar un recorte obligatorio.");else if(1!==H.length){if(K(t=>t.filter((t,n)=>n!==e)),e===G){const t=Math.max(0,e-1);Q(t)}else e<G&&Q(e=>e-1);ae?.announce(`Recorte ${n.label} eliminado`)}else alert("Debe haber al menos un recorte.")},[H,G,ae]),Ke=y.useCallback(async()=>{if(!xe)return null;try{const t=await me.toCanvas({width:800,height:600,imageSmoothingEnabled:!0,imageSmoothingQuality:"high"});return t?t.toDataURL(`image/${globalThis.downloadFormat||e.mime_type.split("/")[1]||"webp"}`,.9):null}catch(t){return console.warn("Error generating preview:",t),null}},[xe,e.mime_type,me]),Qe=y.useCallback(async()=>{if(u)return d(!1),m(null),void p(!1);if(xe){d(!0),p(!0);try{const e=await Ke();e?m(e):(d(!1),alert("No se puede exportar el recorte por restricciones de CORS en la imagen original."))}finally{p(!1)}}else alert("No se puede exportar el recorte por restricciones de CORS en la imagen original.")},[xe,Ke,u]),Xe=y.useCallback(e=>{e.target.closest(".limbo-preview-modal-header")&&(S(!0),N({x:e.clientX-w.x,y:e.clientY-w.y}))},[w]),Ye=y.useCallback(e=>{C&&(e.preventDefault(),k({x:e.clientX-j.x,y:e.clientY-j.y}))},[C,j]),Je=y.useCallback(()=>{S(!1)},[]),Ze=y.useCallback(e=>{if(!e.target.closest(".limbo-preview-modal-header"))return;const t=e.touches[0];S(!0),N({x:t.clientX-w.x,y:t.clientY-w.y})},[w]),et=y.useCallback(e=>{if(!C)return;e.preventDefault();const t=e.touches[0];k({x:t.clientX-j.x,y:t.clientY-j.y})},[C,j]),tt=y.useCallback(()=>{S(!1)},[]);y.useEffect(()=>{if(C)return document.addEventListener("mousemove",Ye),document.addEventListener("mouseup",Je),document.addEventListener("touchmove",et,{passive:!1}),document.addEventListener("touchend",tt),()=>{document.removeEventListener("mousemove",Ye),document.removeEventListener("mouseup",Je),document.removeEventListener("touchmove",et),document.removeEventListener("touchend",tt)}},[C,Ye,Je,et,tt]),y.useEffect(()=>{if(!E)return;const e=e=>{"Escape"===e.key&&$(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[E]);const nt=y.useCallback(async(t,n=null)=>{const l=H[t];if(!l)throw new Error(`Crop ${t} no encontrado`);if(!l.savedState&&t!==G)throw new Error(`El recorte "${l.label}" aún no ha sido configurado`);const r={index:G,imageTransform:fe.current?.$getTransform?.(),selectorState:ge.current?{x:ge.current.x,y:ge.current.y,width:ge.current.width,height:ge.current.height}:null};try{if(t!==G&&l.savedState){if(console.log(`[CropperView] 🔄 Restaurando temporalmente crop ${t} para guardado...`),l.savedState.imageTransform&&fe.current?.$setTransform){const[e,t,n,r,a,o]=l.savedState.imageTransform;fe.current.$setTransform(e,t,n,r,a,o)}if(l.savedState.selectorState&&ge.current){const{x:e,y:t,width:n,height:r}=l.savedState.selectorState;ge.current.x=e,ge.current.y=t,ge.current.width=n,ge.current.height=r,ge.current.$render?.()}await new Promise(e=>setTimeout(e,100))}const r=Math.min(l.width,5e3),s=Math.min(l.height,5e3),c=await me.toCanvas({width:r,height:s,imageSmoothingEnabled:!0,imageSmoothingQuality:"high"});if(!c)throw new Error(`No se pudo generar el canvas para "${l.label}"`);const u=l.format||globalThis.downloadFormat||"webp",d="webp"===u?"image/webp":"png"===u?"image/png":"image/jpeg",b=.9,m=await new Promise((e,t)=>{c.toBlob(n=>{n?e(n):t(new Error("No se pudo convertir el canvas a blob"))},d,b)});console.log("[CropperView] Canvas convertido a blob:",{size:m.size,type:m.type,dimensions:`${r}x${s}`});const h=`${l.label||"crop"}_${r}_${s}`,p=n||e.id,f=!p||"string"==typeof p&&p.startsWith("external"),g=(f||V.localCropsOnly)&&!i;if(f&&i&&!V.localCropsOnly){console.log("[CropperView] 📤 Imagen externa con onUpload disponible, subiendo crop como nuevo asset...");try{const e=new File([m],`${h}.${u}`,{type:d}),t=await i(e);if(t&&(t.id||t.url)){console.log("[CropperView] ✅ Crop subido exitosamente:",t);const e=l.savedState||{selectorState:ge.current?{x:ge.current.x,y:ge.current.y,width:ge.current.width,height:ge.current.height}:null,imageTransform:fe.current?.$getTransform?.()||null,flipState:{horizontal:A.horizontal,vertical:A.vertical}},n={id:t.id||`uploaded-${Date.now()}`,name:h,filename:`${h}.${u}`,url:t.urlSigned||t.url,urlSigned:t.urlSigned||t.url,width:r,height:s,format:u,size:m.size,mime_type:d,isLocal:!1,originalAssetId:null,uploadedAssetId:t.id,cropState:e};return ae?.announceSuccess(`Recorte guardado: ${h}`),n}}catch(a){console.error("[CropperView] ❌ Error subiendo crop, fallback a local:",a)}}if(g){console.log(`[CropperView] 🌐 Generando resultado local (isExternal: ${f}, localCropsOnly: ${V.localCropsOnly})`);const e=URL.createObjectURL(m),t=l.savedState||{selectorState:ge.current?{x:ge.current.x,y:ge.current.y,width:ge.current.width,height:ge.current.height}:null,imageTransform:fe.current?.$getTransform?.()||null,flipState:{horizontal:A.horizontal,vertical:A.vertical}},n={id:`local-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:h,filename:`${h}.${u}`,url:e,urlSigned:e,width:r,height:s,format:u,size:m.size,mime_type:d,blob:m,isLocal:!0,originalAssetId:p||null,cropState:t};return ae?.announceSuccess(`Recorte creado localmente: ${h}`),n}const y=l.savedState||{selectorState:ge.current?{x:ge.current.x,y:ge.current.y,width:ge.current.width,height:ge.current.height}:null,imageTransform:fe.current?.$getTransform?.()||null,flipState:{horizontal:A.horizontal,vertical:A.vertical}},v=await oe(p,m,{name:h,width:r,height:s,format:u});if(v)return v.cropState=y,ae?.announceSuccess(`Recorte creado: ${h}`),o?.(p,v),v;throw new Error("No se pudo crear la variante")}finally{if(t!==G&&r.imageTransform&&fe.current?.$setTransform){console.log(`[CropperView] ↩️ Restaurando estado original del crop ${r.index}...`);const[e,t,n,l,a,o]=r.imageTransform;if(fe.current.$setTransform(e,t,n,l,a,o),r.selectorState&&ge.current){const{x:e,y:t,width:n,height:l}=r.selectorState;ge.current.x=e,ge.current.y=t,ge.current.width=n,ge.current.height=l,ge.current.$render?.()}}}},[H,G,me,oe,e.id,o,ae,fe,ge]),lt=y.useCallback(async()=>{if(!xe){const e="No se puede exportar el recorte por restricciones de CORS en la imagen original.";return ae?.announceError(e),void alert(e)}if(!de.isReady){const e="El cropper aún no está inicializado. Espera un momento e inténtalo de nuevo.";return ae?.announceError(e),void alert(e)}Oe(),ae?.announce("Creando recorte de la imagen");try{let n=e.id,l=null;if(e.file&&i){ae?.announce("Subiendo imagen...");const t=await i(e.file);if(!t||!t.id)throw new Error("No se pudo subir la imagen al servidor");n=t.id,l=t,ae?.announceSuccess("Imagen subida correctamente")}const r=await nt(G,n);r&&t(l?{crops:[r],asset:l}:r)}catch(n){console.warn("Error creating crop variant:",n);const e=n.message||"No se pudo crear el recorte. Inténtalo de nuevo.";ae?.announceError(e),alert(e),r?.(n)}},[xe,de.isReady,ae,Oe,nt,G,t,r,e.file,e.id,i]),rt=y.useCallback(async n=>{Oe(),ae?.announce(`Guardando ${n.length} recortes...`);try{let r=e.id,a=null;if(e.file&&i){ae?.announce("Subiendo imagen...");const t=await i(e.file);if(!t||!t.id)throw new Error("No se pudo subir la imagen al servidor");r=t.id,a=t,ae?.announceSuccess("Imagen subida correctamente")}const o=[],s=[];for(const e of n)try{const t=await nt(e,r);t&&o.push(t)}catch(l){s.push({crop:H[e]?.label||`Crop ${e}`,error:l.message})}if(o.length>0&&(ae?.announceSuccess(`${o.length} recorte(s) guardado(s) correctamente`),t(a?{crops:o,asset:a}:o)),s.length>0){const e=`Errores al guardar algunos recortes:\n${s.map(e=>`- ${e.crop}: ${e.error}`).join("\n")}`;ae?.announceError(e),alert(e)}}catch(l){const e=l.message||"Error al procesar los recortes";ae?.announceError(e),alert(e),r?.(l)}},[Oe,nt,H,ae,t,e.file,e.id,i,r]),at=y.useCallback(async()=>{const e=Fe();if(-1!==e){const t=H[e];return alert(`El recorte "${t.label||t||"(sin nombre)"}" debe tener un nombre válido.`),void Q(e)}const t=H.findIndex((e,t)=>e.required&&!e.savedState&&t!==G);if(-1!==t){const e=H[t];return alert(`El recorte obligatorio "${e.label}" aún no ha sido configurado.\n\nPor favor, configura todos los recortes obligatorios antes de guardar.`),Q(t),void ae?.announce(`Recorte obligatorio "${e.label}" sin configurar. Por favor, configúralo.`,"assertive")}if(H.length>1){re("save");const e=H.map((e,t)=>({crop:e,index:t})).filter(({crop:e,index:t})=>e.required||e.savedState||t===G).map(({index:e})=>e);return ne(e),void ee(!0)}await lt()},[Fe,H,lt,G,ae]),ot=y.useCallback(async t=>{const n=H[t];if(!n)throw new Error(`Crop ${t} no encontrado`);if(!n.savedState&&t!==G)throw new Error(`El recorte "${n.label}" aún no ha sido configurado`);const l={index:G,imageTransform:fe.current?.$getTransform?.(),selectorState:ge.current?{x:ge.current.x,y:ge.current.y,width:ge.current.width,height:ge.current.height}:null};try{if(t!==G&&n.savedState){if(console.log(`[CropperView] 🔄 Restaurando temporalmente crop ${t} para descarga...`),n.savedState.imageTransform&&fe.current?.$setTransform){const[e,t,l,r,a,o]=n.savedState.imageTransform;fe.current.$setTransform(e,t,l,r,a,o)}if(n.savedState.selectorState&&ge.current){const{x:e,y:t,width:l,height:r}=n.savedState.selectorState;ge.current.x=e,ge.current.y=t,ge.current.width=l,ge.current.height=r,ge.current.$render?.()}await new Promise(e=>setTimeout(e,100))}const l=await me.toCanvas({width:n.width,height:n.height,imageSmoothingEnabled:!0,imageSmoothingQuality:"high"});if(!l)throw new Error(`No se pudo generar el canvas para "${n.label}"`);const r=l.toDataURL(`image/${globalThis.downloadFormat||e.mime_type.split("/")[1]||"webp"}`,.9),a=`${(n.label||"crop").replace(/\.[^/.]+$/,"").replace(/\s+/g,"-").trim()}_${n.width}_${n.height}`;return await ol(r,a,{accessibilityManager:ae,onSuccess:e=>{console.log(`✅ Descargado: ${e}`)},onError:e=>{throw new Error(`Error al descargar "${n.label}": ${e.message}`)}}),{crop:n.label,filename:a}}finally{if(t!==G&&l.imageTransform&&fe.current?.$setTransform){console.log(`[CropperView] ↩️ Restaurando estado original del crop ${l.index}...`);const[e,t,n,r,a,o]=l.imageTransform;if(fe.current.$setTransform(e,t,n,r,a,o),l.selectorState&&ge.current){const{x:e,y:t,width:n,height:r}=l.selectorState;ge.current.x=e,ge.current.y=t,ge.current.width=n,ge.current.height=r,ge.current.$render?.()}}}},[H,G,me,e.mime_type,ae,fe,ge]),it=y.useCallback(async e=>{Oe(),ae?.announce(`Descargando ${e.length} recortes...`);const t=[],n=[];for(const r of e)try{const e=await ot(r);e&&t.push(e)}catch(l){n.push({crop:H[r]?.label||`Crop ${r}`,error:l.message})}if(t.length>0&&ae?.announceSuccess(`${t.length} recorte(s) descargado(s) correctamente`),n.length>0){const e=`Errores al descargar algunos recortes:\n${n.map(e=>`- ${e.crop}: ${e.error}`).join("\n")}`;ae?.announceError(e),alert(e)}},[Oe,ot,H,ae]),st=y.useCallback(async()=>{if(!xe){const e="No se puede descargar el recorte por restricciones de CORS en la imagen original.";return ae?.announceError(e),void alert(e)}Oe(),ae?.announce("Preparando descarga del recorte");try{await ot(G),ae?.announceSuccess("Recorte descargado correctamente")}catch(e){console.error("Error downloading crop:",e);const t=e.message||"Error al descargar el recorte";ae?.announceError(t),alert(t)}},[xe,ae,Oe,ot,G]),ut=y.useCallback(async()=>{const e=Fe();if(-1!==e){const t=H[e];return alert(`El recorte "${t.label||t||"(sin nombre)"}" debe tener un nombre válido.`),void Q(e)}if(H.length>1){re("download");const e=H.map((e,t)=>({crop:e,index:t})).filter(({crop:e,index:t})=>e.savedState||t===G).map(({index:e})=>e);return ne(e),void ee(!0)}await st()},[Fe,H,st,G]),dt=y.useMemo(()=>!!e.file||(!e.id||!("string"!=typeof e.id||!e.id.startsWith("external"))),[e.file,e.id]),bt=y.useCallback(async()=>{try{if(e.file&&i){ae?.announce("Subiendo imagen original...");const n=await i(e.file);if(!n||!n.id)throw new Error("No se pudo subir la imagen al servidor");return ae?.announceSuccess("Imagen guardada correctamente"),void t({asset:n,crops:[]})}if(dt){ae?.announce("Conservando imagen original...");const n={id:`local-original-${Date.now()}`,name:e.filename||"original",filename:e.filename||"image.jpg",url:e.url,urlSigned:e.url,width:e.width||ve?.naturalWidth||1920,height:e.height||ve?.naturalHeight||1080,mime_type:e.mime_type||"image/jpeg",isLocal:!0,isOriginal:!0};return ae?.announceSuccess("Imagen original conservada"),void t({crops:[n]})}if(e.id&&!e.id.startsWith("external")){ae?.announce("Seleccionando imagen original...");const n={id:e.id,name:e.filename||"original",filename:e.filename||"image.jpg",url:e.url,urlSigned:e.urlSigned||e.url,width:e.width||ve?.naturalWidth||1920,height:e.height||ve?.naturalHeight||1080,mime_type:e.mime_type||"image/jpeg",isOriginal:!0};return ae?.announceSuccess("Imagen original seleccionada"),void t({crops:[n],assetId:e.id})}n()}catch(l){console.error("Error guardando imagen original:",l);const e=l.message||"No se pudo guardar la imagen. Inténtalo de nuevo.";ae?.announceError(e),alert(e),r?.(l)}},[e,ve,i,n,t,r,ae,dt]);return y.useEffect(()=>{d(!1),m(null)},[e]),y.useEffect(()=>{if(!ce.manager||!de.isReady||!_)return;console.log("[CropperView] Carga inicial completada, centrando imagen y selector...");const e=V.existingCrops?.[0],t=e?.cropState;setTimeout(()=>{$e(),setTimeout(()=>{if(t){if(console.log("[CropperView] 🔄 Restaurando estado del crop existente:",t),t.imageTransform&&fe.current?.$setTransform){const[e,n,l,r,a,o]=t.imageTransform;fe.current.$setTransform(e,n,l,r,a,o),console.log("[CropperView] ✅ Transformación de imagen restaurada")}if(t.selectorState&&ge.current){const{x:e,y:n,width:l,height:r}=t.selectorState;ge.current.x=e,ge.current.y=n,ge.current.width=l,ge.current.height=r,ge.current.$render?.(),console.log("[CropperView] ✅ Posición del selector restaurada:",t.selectorState)}t.flipState&&(M(t.flipState),console.log("[CropperView] ✅ Estado de flip restaurado:",t.flipState))}else _e();T(!1),console.log("[CropperView] Carga inicial finalizada")},100)},50)},[ce.manager,de.isReady,_,$e,_e,V.existingCrops]),y.useEffect(()=>{ce.manager&&de.isReady&&(Y&&me.setAspectRatio(Y),he.setBackground(v))},[Y,v,ce.manager,de.isReady,me,he]),y.useEffect(()=>{if(!ve||!de.isReady||V.mandatoryCrops.length>0)return;const e=H[0];if(e&&"crop-default-0"===e.id&&(1920===e.width||1080===e.height)){const t=Math.min(ve.naturalWidth,5e3),n=Math.min(ve.naturalHeight,5e3);K([{...e,width:t,height:n}]),console.log(`[CropperView] Crop por defecto actualizado a ${t}×${n}px`)}},[ve,de.isReady,V.mandatoryCrops.length,H]),y.useEffect(()=>{if(!u||!xe)return;const e=setTimeout(async()=>{p(e=>!b&&!e||e);try{const e=await Ke();e&&m(e)}finally{p(!1)}},300);return()=>{clearTimeout(e),p(!1)}},[ye,we,u,xe,Ke,Y,A,b]),y.useEffect(()=>{const e=pe.current,t=t=>{if("Delete"===t.key||"Backspace"===t.key||"Backspace"===t.key&&t.metaKey||"Backspace"===t.key&&t.ctrlKey){const n=t.target;if(e&&(n===e||n===document.body||n===document.documentElement||"CROPPER-CANVAS"===n.tagName||"CROPPER-SELECTION"===n.tagName||"CROPPER-IMAGE"===n.tagName||"CROPPER-HANDLE"===n.tagName||"CROPPER-GRID"===n.tagName||n.closest("cropper-canvas")||e.contains(n)))return t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),!1}};return document.addEventListener("keydown",t,!0),document.addEventListener("keyup",t,!0),window.addEventListener("keydown",t,!0),e&&e.addEventListener("keydown",t,!0),()=>{document.removeEventListener("keydown",t,!0),document.removeEventListener("keyup",t,!0),window.removeEventListener("keydown",t,!0),e&&e.removeEventListener("keydown",t,!0)}},[pe]),e?F.jsxs("div",{className:"limbo-cropper-view lb:px-2 lb:border-2 lb:border-gray-200/50 lb:rounded-lg lb:max-w-7xl lb:mx-auto lb:w-full lb:min-w-full lb:h-full lb:min-h-full lb:flex lb:flex-col",children:[F.jsxs("div",{className:"limbo-cropper-header lb:flex lb:flex-row lb:justify-between lb:items-start lb:flex-wrap lb:mx-2 lb:py-2 lb:border-b lb:border-gray-200 lb:bg-white lb:z-10 lb:shrink-0 lb:lg:gap-2",children:[F.jsxs("div",{className:"lb:flex-1 lb:min-w-fit lb:space-y-2 lb:max-w-fit",children:[F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2",children:[F.jsx("h2",{className:"lb:text-lg lb:sm:text-xl lb:font-extrabold lb:text-gray-800",children:"Generar recortes"}),H.length>1&&F.jsx("span",{className:"lb:px-2 lb:py-0.5 lb:bg-blue-100 lb:text-blue-800 lb:text-xs lb:font-semibold lb:rounded",children:X.label})]}),F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2",children:[F.jsx("label",{className:"lb:text-xs lb:text-gray-500 lb:whitespace-nowrap lb:w-fit",children:"Nombre:"}),F.jsx("div",{className:"",children:q+"."+(globalThis.downloadFormat||e.mime_type.split("/")[1]||"webp")})]})]}),F.jsxs("div",{className:"lb:flex lb:flex-row lb:self-end lb:gap-2 lb:w-full lb:max-w-fit lb:sm:w-auto lb:flex-wrap",children:[F.jsxs("button",{onClick:()=>{window.confirm("Si cancelas, perderás todos los cambios realizados. ¿Deseas continuar?")&&n()},disabled:ie,className:"lb:flex lb:flex-row lb:items-center lb:gap-1 lb:self-end lb:w-full lb:max-w-fit lb:sm:w-auto lb:px-3 lb:cursor-pointer lb:py-1.5 lb:text-sm lb:rounded lb:bg-neutral-gray-500 lb:hover:bg-neutral-gray-700 lb:transition-colors lb:text-white lb:disabled:opacity-50 lb:disabled:cursor-not-allowed","aria-label":"Cancelar y volver",title:"Cancelar y volver",children:[F.jsx("span",{className:"icon icon-arrow-left-white icon--sm lb:m-0 lb:p-0"})," ","Cancelar"]}),l&&F.jsxs("button",{onClick:()=>l(e),disabled:a|ie,className:"lb:flex lb:flex-row lb:items-center lb:gap-1 lb:self-end lb:w-full lb:max-w-fit lb:sm:w-auto lb:px-3 lb:cursor-pointer lb:py-1.5 lb:text-sm lb:rounded lb:bg-red-800 lb:hover:bg-red-1000 lb:transition-colors lb:text-white lb:disabled:opacity-50 lb:disabled:cursor-not-allowed","aria-label":`Eliminar imagen ${e.filename}`,title:`Eliminar imagen ${e.filename}`,children:[F.jsx("span",{className:"icon icon-close-small-white icon--sm lb:m-0 lb:p-0"}),a?"Eliminando...":"Eliminar"]})]})]}),F.jsxs("div",{className:"limbo-cropper-status lb:bg-white lb:border-gray-100 lb:py-0 lb:pb-0 lb:flex-shrink-0",children:[se&&F.jsxs(Ge,{variant:"danger",className:"lb:mb-2 lb:text-sm",children:[F.jsx("strong",{children:"Error:"})," ",se]}),ve&&F.jsxs(Ge,{variant:"info",className:"lb:mb-2 lb:text-sm",role:"status",children:[F.jsx("strong",{children:"Original:"})," ",ve.naturalWidth," ×"," ",ve.naturalHeight," px",ve.currentWidth!==ve.naturalWidth&&F.jsxs("span",{className:"lb:ml-2 lb:sm:ml-3 lb:text-xs lb:block lb:sm:inline",children:["(Mostrada: ",Math.round(ve.currentWidth)," ×"," ",Math.round(ve.currentHeight)," px)"]})]}),!xe&&F.jsx(Ge,{variant:"warning",className:"lb:mb-2 lb:text-sm",children:"No se puede exportar por restricciones CORS"}),F.jsxs("div",{className:"lb:bg-white lb:border-b lb:border-gray-200 lb:py-2 lb:mx-2 lb:shrink-0 lb:sticky lb:top-0 lb:z-10 lb:mb-1",children:[F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between lb:mb-2",children:[F.jsxs("h3",{className:"lb:text-sm lb:font-semibold lb:text-gray-700",children:["Recortes ",H.length>1&&`(${H.length})`]}),V.allowCustomCrops&&F.jsxs("button",{onClick:Be,disabled:ie,className:"lb:text-xs lb:cursor-pointer lb:px-2 lb:py-1 lb:bg-brand-blue-50 lb:hover:bg-brand-blue-200 lb:text-brand-blue-1000 lb:rounded lb:border lb:border-brand-blue-200 lb:transition-colors lb:flex lb:items-center lb:gap-1",title:"Añadir recorte personalizado",children:[F.jsx("span",{className:"icon icon-add icon--sm",style:{filter:"var(--limbo-icon-blue)"}}),"Añadir recorte"]})]}),F.jsx("div",{className:"lb:grid lb:grid-cols-2 lb:md:grid-cols-3 lb:lg:grid-cols-4 lb:xl:grid-cols-5 lb:gap-1.5 lb:max-h-48 lb:overflow-y-auto",children:H.map((e,t)=>{const n=e.savedState||t===G;return F.jsxs("label",{className:"lb:h-fit lb:flex lb:flex-col lb:p-1.5 lb:rounded lb:border lb:cursor-pointer lb:transition-colors lb:min-h-17.5 lb:w-full "+(G===t?"lb:bg-blue-50 lb:border-blue-300":n?"lb:bg-gray-50 lb:border-gray-200 lb:hover:bg-gray-100":"lb:bg-orange-50 lb:border-orange-300 lb:hover:bg-orange-100"),children:[F.jsx("input",{type:"radio",name:"active-crop",checked:G===t,onChange:()=>Ue(t),disabled:ie,className:"lb:hidden"}),F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-1 lb:mb-1",children:[F.jsx("div",{className:"lb:flex-1 lb:min-w-0",children:F.jsxs("div",{className:"lb:flex lb:flex-wrap lb:items-center lb:gap-1 lb:min-h-",children:[G!==t||e.required?F.jsx("span",{className:"lb:text-xs lb:font-medium lb:text-gray-800 lb:truncate",children:e.label}):F.jsx("input",{type:"text",value:e.label,onChange:e=>Ve(e.target.value),disabled:ie,className:"lb:w-full lb:max-h-fit lb:text-xs lb:px-1 lb:py-0.5 lb:border lb:border-gray-300 lb:rounded lb:focus:outline-none lb:focus:ring-1 lb:focus:ring-blue-500 lb:h-1",placeholder:"Nombre",maxLength:25,onClick:e=>e.stopPropagation()}),e.required&&F.jsx("span",{className:"lb:text-[10px] lb:px-1 lb:py-0.5 lb:bg-red-200 lb:text-red-1000 lb:rounded lb:whitespace-nowrap lb:truncate",children:"Obligatorio"})]})}),!e.required&&H.length>1&&F.jsx("button",{onClick:n=>{n.preventDefault(),n.stopPropagation(),He(t,e.label)},className:"lb:shrink-0 lb:hover:bg-red-500/70 lb:text-red-1000 lb:p-1 lb:rounded lb:max-h-fit lb:aspect-square lb:cursor-pointer lb:flex",title:"Eliminar",children:F.jsx("span",{className:"icon icon-close-small icon--xs"})})]}),F.jsx("div",{className:"lb:flex lb:items-center lb:gap-1 lb:mt-auto",children:G===t?F.jsxs(F.Fragment,{children:[F.jsx("input",{type:"number",min:"100",max:"5000",value:e.width,onChange:e=>We("width",e.target.value),onBlur:()=>qe("width"),disabled:ie||e.lockDimensions,className:"lb:max-h-fit lb:flex-1 lb:text-xs lb:px-1 lb:py-0.5 lb:border lb:rounded lb:focus:outline-none lb:focus:ring-1 lb:focus:ring-blue-500 "+(e.lockDimensions?"lb:border-gray-200 lb:bg-gray-100 lb:text-gray-500 lb:cursor-not-allowed":"lb:border-gray-300"),placeholder:"W",onClick:e=>e.stopPropagation(),title:e.lockDimensions?"Dimensiones bloqueadas (recorte obligatorio)":"Ancho en píxeles"}),F.jsx("span",{className:"lb:text-gray-400 lb:text-xs",children:"×"}),F.jsx("input",{type:"number",min:"100",max:"5000",value:e.height,onChange:e=>We("height",e.target.value),onBlur:()=>qe("height"),disabled:ie||e.lockDimensions,className:"lb:max-h-fit lb:flex-1 lb:text-xs lb:px-1 lb:py-0.5 lb:border lb:rounded lb:focus:outline-none lb:focus:ring-1 lb:focus:ring-blue-500 "+(e.lockDimensions?"lb:border-gray-200 lb:bg-gray-100 lb:text-gray-500 lb:cursor-not-allowed":"lb:border-gray-300"),placeholder:"H",onClick:e=>e.stopPropagation(),title:e.lockDimensions?"Dimensiones bloqueadas (recorte obligatorio)":"Alto en píxeles"})]}):F.jsxs("span",{className:"lb:text-xs lb:text-gray-500",children:[e.width," × ",e.height," px"]})}),!n&&F.jsx("div",{className:"lb:text-xs lb:px-1 lb:py-0.5 lb:bg-orange-300 lb:text-neutral-gray-25 lb:text-shadow-xs lb:font-semibold lb:rounded lb:text-center lb:mt-1",children:"Sin configurar"})]},e.id)})})]})]}),F.jsxs("div",{className:"lb:flex lb:flex-col lb:lg:flex-row lb:flex-1 lb:w-full lb:overflow-hidden lb:lg:max-h-130 lb:mx-2 lb:py-1",children:[F.jsx("div",{className:"lb:relative lb:flex-1 lg:flex-2 lb:h-full lb:shrink-0 lb:grow-1 lb:order-0 lb:min-h-100 lb:lg:min-h-130",children:F.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-white lb:rounded-lg lb:border-2 lb:border-gray-200 lb:overflow-hidden",children:[F.jsx(ct,{show:_,message:"Cargando recortador..."}),F.jsx(ct,{show:z,message:`Cambiando a: ${H[G]?.label||"recorte"}...`}),F.jsxs("cropper-canvas",{ref:pe,style:{width:"100%",height:"100%",display:"block"},background:!!v||void 0,id:"limbo-cropperjs-canvas",tabindex:"-1",onKeyDown:e=>{"Delete"!==e.key&&"Backspace"!==e.key||(e.preventDefault(),e.stopPropagation())},children:[F.jsx("cropper-image",{ref:fe,src:e.url||e.path,alt:e.filename,id:"limbo-cropperjs-image",action:"move",crossOrigin:"anonymous",rotatable:!0,scalable:!0,skewable:!0,translatable:!0}),F.jsxs("cropper-selection",{ref:ge,"initial-coverage":"0.5",movable:!0,resizable:!0,keyboard:"true",action:"move",style:{cursor:"move",minWidth:`${J.minWidth}px`,minHeight:`${J.minHeight}px`},"data-prevent-delete":"true",tabindex:"-1",children:[f&&F.jsx("cropper-grid",{role:"grid",action:"move",covered:!0,bordered:!0}),F.jsx("cropper-handle",{action:"move",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"32px",height:"32px",zIndex:"10"}}),F.jsx("cropper-handle",{action:"n-resize"}),F.jsx("cropper-handle",{action:"e-resize"}),F.jsx("cropper-handle",{action:"s-resize"}),F.jsx("cropper-handle",{action:"w-resize"}),F.jsx("cropper-handle",{action:"ne-resize"}),F.jsx("cropper-handle",{action:"nw-resize"}),F.jsx("cropper-handle",{action:"se-resize"}),F.jsx("cropper-handle",{action:"sw-resize"})]})]})]})}),F.jsx("div",{className:"lb:w-full lb:lg:max-w-80 lb:mt-2 lb:lg:my-0 lb:overflow-y-auto lb:bg-white lb:border-t lb:lg:border-t-0 lb:lg:border-l lb:border-gray-200 lb:shrink-0",children:F.jsxs("div",{className:"lb:h-full lb:mt-2 lb:lg:my-0 lb:me-2 lb:lg:mx-2 lb:space-y-2 lb:grid lb:grid-cols-2 lb:md:grid-cols-3 lb:flex-wrap lb:md:flex-nowrap lb:items-start lb:flex-row lb:gap-2 lb:lg:gap-0 lb:lg:block",children:[F.jsxs("div",{className:"lb:bg-white lb:rounded lb:border lb:w-full lb:border-gray-200 lb:mb-2",children:[F.jsx("button",{onClick:Ee,className:"lb:hidden lb:sm:block lb:w-full lb:p-2 lb:mb-05 lb:cursor-pointer lb:hover:bg-neutral-gray-050/50 lb:transition-colors lb:rounded-t-sm","aria-expanded":B,"aria-label":"Mostrar/ocultar opciones de visualización",children:F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between",children:[F.jsx("h3",{className:"lb:text-sm lb:font-semibold lb:text-gray-700",children:"Transformar imagen"}),F.jsx("div",{className:"lb:text-center",children:F.jsx("span",{className:`icon ${B?"icon-chevron-up":"icon-chevron-down"} lb:text-center icon--xs`})})]})}),F.jsxs("div",{className:"lb:p-2 lb:space-y-2 lb:justify-items-stretch lb:static "+(B?"lb:block":"lb:sm:hidden"),children:[F.jsx("div",{className:"lb:mb-3 lb:block",children:F.jsxs("div",{className:"lb:grid lb:grid-cols-5 lb:gap-1 lb:content-center lb:h-fit lb:mx-auto",children:[F.jsx("button",{onClick:()=>Le(-.2),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Alejar",disabled:ie,"aria-label":"Alejar imagen",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-zoom-out-blue"})})}),F.jsx("button",{onClick:()=>ze(-10,-10),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover arriba-izquierda",disabled:ie,"aria-label":"Mover imagen hacia arriba-izquierda",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-arrow-up-blue icon--md lb:-rotate-45"})})}),F.jsx("button",{onClick:()=>ze(0,-10),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover arriba",disabled:ie,"aria-label":"Mover imagen hacia arriba",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-arrow-up-blue icon--md"})})}),F.jsx("button",{onClick:()=>ze(10,-10),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover arriba-derecha",disabled:ie,"aria-label":"Mover imagen hacia arriba-derecha",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-arrow-up-blue icon--md lb:rotate-45"})})}),F.jsx("button",{onClick:()=>Le(.2),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Acercar 20%",disabled:ie,"aria-label":"Acercar imagen",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-zoom-in-blue"})})}),F.jsx("button",{onClick:()=>Ae(-45),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Rotar -45°",disabled:ie,"aria-label":"Rotar imagen 45 grados a la izquierda",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"lb:text-brand-blue-1000 lb:font-medium",children:"-45°"})})}),F.jsx("button",{onClick:()=>ze(-10,0),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover izquierda",disabled:ie,"aria-label":"Mover imagen hacia la izquierda",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-arrow-left-blue"})})}),F.jsx("button",{onClick:$e,className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Centrar y ajustar imagen",disabled:ie,"aria-label":"Centrar y ajustar imagen",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-radio-button-blue icon-md"})})}),F.jsx("button",{onClick:()=>ze(10,0),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover derecha",disabled:ie,"aria-label":"Mover imagen hacia la derecha",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-arrow-right-blue"})})}),F.jsx("button",{onClick:()=>Ae(45),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Rotar +45°",disabled:ie,"aria-label":"Rotar imagen 45 grados a la derecha",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"lb:text-brand-blue-1000 lb:font-medium",children:"+45°"})})}),F.jsx("button",{onClick:Ie,className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:aspect-square "+(A.horizontal?"lb:bg-blue-100 lb:border lb:border-blue-300 lb:text-blue-800":"lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200"),title:"Voltear horizontalmente "+(A.horizontal?"(activo)":""),disabled:ie,"aria-label":"Voltear imagen horizontalmente","aria-pressed":A.horizontal,children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center lb:gap-2",children:F.jsx("span",{className:"icon icon-arrow-left-right-blue lb:border lb:border-brand-blue-1000 lb:rounded"})})}),F.jsx("button",{onClick:()=>ze(-10,10),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover abajo-izquierda",disabled:ie,"aria-label":"Mover imagen hacia abajo-izquierda",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-arrow-up-blue icon--md lb:-rotate-145"})})}),F.jsx("button",{onClick:()=>ze(0,10),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover abajo",disabled:ie,"aria-label":"Mover imagen hacia abajo",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-arrow-down-blue"})})}),F.jsx("button",{onClick:()=>ze(10,10),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover abajo-derecha",disabled:ie,"aria-label":"Mover imagen hacia abajo-derecha",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-arrow-up-blue icon--md lb:rotate-145"})})}),F.jsx("button",{onClick:De,className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:aspect-square lb:text-sm "+(A.vertical?"lb:bg-blue-100 lb:border lb:border-blue-300 lb:text-blue-800":"lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200"),title:"Voltear verticalmente "+(A.vertical?"(activo)":""),disabled:ie,"aria-label":"Voltear imagen verticalmente","aria-pressed":A.vertical,children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{className:"icon icon-arrow-up-down-blue lb:border lb:border-brand-blue-1000 lb:rounded"})})})]})}),F.jsx("div",{className:"lb:flex lb:flex-col lb:gap-2",children:F.jsx("button",{onClick:()=>{be.reset(),M({horizontal:!1,vertical:!1})},className:"lb:w-full lb:p-2 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",title:"Reiniciar transformaciones",disabled:ie,"aria-label":"Reiniciar todas las transformaciones de la imagen",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsxs("span",{children:[F.jsx("span",{className:"icon icon-refresh-blue icon--sm lb:align-[middle!important] "})," ","Reiniciar ajustes"]})})})})]})]}),F.jsxs("div",{className:"lb:bg-white lb:rounded lb:border lb:border-gray-200 lb:w-full"+(R?"":" lb:bg-neutral-gray-50/50"),children:[F.jsx("button",{onClick:Ne,className:"lb:hidden lb:sm:block lb:w-full lb:cursor-pointer lb:hover:bg-neutral-gray-050/50 lb:p-2 lb:mb-05 lb:transition-colors lb:rounded-t-sm","aria-expanded":R,"aria-label":"Mostrar/ocultar opciones de visualizción",children:F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between",children:[F.jsx("h3",{className:"lb:text-sm lb:font-semibold lb:text-gray-700",children:"Ajustes del selector"}),F.jsx("div",{className:"lb:text-center",children:F.jsx("span",{className:`icon ${R?"icon-chevron-up":"icon-chevron-down"} lb:text-center icon--xs`})})]})}),F.jsxs("div",{className:"lb:p-2 lb:space-y-2 lb:justify-items-stretch lb:static "+(R?"lb:block":"lb:sm:hidden"),children:[F.jsx("div",{children:F.jsxs("div",{className:"lb:grid lb:grid-cols-2 lb:gap-2",children:[F.jsx("button",{onClick:()=>Me(.5),className:"lb:p-1 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-xs lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",disabled:ie,"aria-label":"Selección 50%",title:"Tamaño de selector 50%",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{children:"50%"})})}),F.jsx("button",{onClick:()=>Me(.7),className:"lb:p-1 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-xs lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",disabled:ie,"aria-label":"Selección 70%",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{children:"70%"})})}),F.jsx("button",{onClick:()=>Me(.9),className:"lb:p-1 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-xs lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",disabled:ie,"aria-label":"Selección 90%",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{children:"90%"})})}),F.jsx("button",{onClick:()=>Me(1),className:"lb:p-1 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-xs lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",disabled:ie,"aria-label":"Selección completa",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsx("span",{children:"100%"})})})]})}),F.jsxs("div",{className:"lb:space-y-2 lb:pt-2",children:[F.jsx("button",{onClick:_e,className:"lb:w-full lb:p-1 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",title:"Centrar selección",disabled:ie,"aria-label":"Centrar área de selección",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsxs("span",{children:[F.jsx("span",{className:"icon icon-radio-button icon--sm lb:align-[middle!important] "})," ","Centrar selección"]})})}),F.jsx("button",{onClick:Te,className:"lb:w-full lb:p-1 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",title:"Reiniciar selección",disabled:ie,"aria-label":"Reiniciar área de selección",children:F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:F.jsxs("span",{children:[F.jsx("span",{className:"icon icon-refresh icon--sm lb:align-[middle!important]"})," ","Reset selección"]})})})]})]})]}),F.jsxs("div",{className:"lb:bg-white lb:rounded lb:border lb:border-gray-200 lb:w-full",children:[F.jsx("button",{onClick:je,className:"lb:hidden lb:sm:block lb:w-full lb:cursor-pointer lb:hover:bg-neutral-gray-050/50 lb:transition-colors lb:rounded-t-sm lb:mb-05 lb:p-2","aria-expanded":D,"aria-label":"Mostrar/ocultar opciones de visualización",children:F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between",children:[F.jsx("h3",{className:"lb:text-sm lb:font-semibold lb:text-gray-700",children:"Visualización"}),F.jsx("div",{className:"lb:text-center",children:F.jsx("span",{className:`icon ${D?"icon-chevron-up":"icon-chevron-down"} lb:text-center icon--xs`})})]})}),F.jsxs("div",{className:"lb:py-2 lb:space-y-2 lb:justify-items-stretch lb:static "+(D?"lb:block":"lb:sm:hidden"),children:[F.jsxs("button",{onClick:Ce,className:"lb:w-auto lb:flex lb:cursor-pointer lb:items-center lb:justify-between lb:mx-2 lb:p-1 lb:rounded lb:transition-colors "+(f?"lb:bg-blue-100 lb:border lb:border-blue-300 lb:text-blue-800":"lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200"),disabled:ie,"aria-pressed":f,title:"Mostrar/ocultar cuadrícula de la regla de los tercios en el selector","aria-label":"Activar/desactivar grid",children:[F.jsxs("span",{className:"lb:text-sm lb:flex lb:items-center",children:[F.jsx("span",{className:"icon icon-area-blue lb:me-1"})," ","Cuadrícula"]}),F.jsx("span",{className:"lb:text-xs",children:f?F.jsxs(F.Fragment,{children:[F.jsx("span",{className:"icon icon-tick icon--xs lb:align-[middle!important] lb:-mt-0.5"})," ","Activo"]}):"Inactivo"})]}),F.jsxs("button",{onClick:Se,className:"lb:w-auto lb:flex lb:cursor-pointer lb:items-center lb:justify-between lb:mx-2 lb:p-1 lb:rounded lb:transition-colors "+(v?"lb:bg-blue-100 lb:border lb:border-blue-300 lb:text-blue-800":"lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200"),disabled:ie,"aria-pressed":v,"aria-label":"Activar/desactivar sombreado",children:[F.jsxs("span",{className:"lb:text-sm lb:flex lb:items-center",children:[F.jsx("span",{className:"icon icon-comparison-blue lb:me-1"})," ","Tablero"]}),F.jsx("span",{className:"lb:text-xs",children:v?F.jsxs(F.Fragment,{children:[F.jsx("span",{className:"icon icon-tick icon--xs lb:align-[middle!important] lb:-mt-0.5"})," ","Activo"]}):"Inactivo"})]})]})]})]})})]}),F.jsxs("div",{className:"lb:flex lb:justify-between lb:shrink-0 lb:border-t lb:border-gray-200 lb:bg-white lb:mx-2 lb:mt-1 lb:py-2 lb:lg:gap-0",children:[F.jsxs("button",{onClick:()=>I(!0),className:"lb:text-nowrap lb:block lb:cursor-pointer lb:lg:flex lb:items-center lb:gap-2 lb:px-2 lb:py-1 lb:bg-gradient-to-br lb:from-brand-blue-50 lb:to-green-50 lb:hover:from-brand-blue-100 lb:hover:to-green-100 lb:border lb:border-blue-200 lb:rounded-lg lb:shadow-sm lb:transition-colors","aria-label":"Abrir guía de uso",children:[F.jsx("span",{className:"icon icon-lightbulb lb:text-yellow-500"}),F.jsx("span",{className:"lb:text-sm lb:font-semibold lb:text-blue-800",children:"Guía de uso"}),F.jsx("span",{className:"icon icon-arrow-down lb:scale-75 lb:-rotate-145"})]}),F.jsx("button",{onClick:Qe,disabled:ie||!xe,className:`lb:px-3 lb:cursor-pointer lb:py-1.5 lb:text-sm lb:rounded lb:transition-colors ${u?"lb:bg-red-1000 lb:hover:bg-red-800 lb:text-white":"lb:bg-brand-blue-800 lb:hover:bg-brand-blue-1000 lb:text-white"} lb:disabled:opacity-50 lb:disabled:cursor-not-allowed`,"aria-label":"Vista previa",title:"Mostrar/Ocultar vista previa",children:F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-1",children:[F.jsx("span",{className:"icon icon-search-white icon--sm"}),F.jsx("span",{className:"lb:hidden lb:sm:inline lb:whitespace-nowrap",children:u?"Cerrar previa":"Vista previa"})]})}),F.jsxs("div",{className:"lb:flex lb:flex-row lb:gap-1 lb:lg:gap-2 lb:items-center lb:justify-end",children:[F.jsx("button",{onClick:ut,disabled:ie||!xe,className:"lb:cursor-pointer lb:px-3 lb:py-1.5 lb:text-sm lb:rounded lb:bg-brand-blue-800 lb:hover:bg-brand-blue-1000 lb:text-white lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed","aria-label":"Descargar",title:"Descargar recorte sin guardar",children:F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-1",children:[F.jsx("span",{className:"icon icon-download-white icon--sm"}),F.jsx("span",{className:"lb:hidden lb:md:inline lb:whitespace-nowrap",children:"Descargar"})]})}),F.jsx("button",{onClick:bt,disabled:ie||s,className:"lb:px-3 lb:cursor-pointer lb:py-1.5 lb:text-sm lb:rounded lb:bg-teal-600 lb:hover:bg-teal-700 lb:text-white lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed","aria-label":"Conservar solo imagen original sin crear recortes",title:e.file?"Subir y guardar la imagen original sin crear recortes":"Seleccionar la imagen original sin crear recortes",children:F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-1",children:[F.jsx("span",{className:"icon icon-tick-white icon--sm"}),F.jsx("span",{className:"lb:hidden lb:md:inline lb:whitespace-nowrap",children:"Guardar sin recortar"})]})}),F.jsx("button",{onClick:at,disabled:ie||!ye||!ke||!xe||!de.isReady,className:"lb:px-3 lb:cursor-pointer lb:py-1.5 lb:text-sm lb:rounded lb:bg-green-600 lb:hover:bg-green-700 lb:text-white lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed",title:"Guardar imagen recortada",children:F.jsx("div",{className:"lb:flex lb:items-center lb:gap-1",children:ie?F.jsxs(F.Fragment,{children:[F.jsx("span",{className:"icon icon-save-white icon--sm"}),F.jsx("span",{children:"Guardando..."})]}):F.jsxs(F.Fragment,{children:[F.jsx("span",{className:"icon icon-save-white icon--sm"}),F.jsx("span",{className:"lb:hidden lb:md:inline lb:whitespace-nowrap",children:"Guardar recorte"})]})})})]})]}),Z&&F.jsx("div",{className:"lb:fixed lb:inset-0 lb:bg-black lb:bg-opacity-50 lb:flex lb:items-center lb:justify-center lb:z-[9999] lb:p-4",children:F.jsxs("div",{className:"lb:bg-white lb:rounded-lg lb:shadow-xl lb:max-w-lg lb:w-full lb:max-h-[80vh] lb:overflow-hidden lb:flex lb:flex-col",children:[F.jsxs("div",{className:"lb:px-6 lb:py-4 lb:border-b lb:border-gray-200",children:[F.jsx("h3",{className:"lb:text-lg lb:font-semibold lb:text-gray-800",children:"save"===le?"Seleccionar recortes a guardar":"Seleccionar recortes a descargar"}),F.jsxs("p",{className:"lb:text-sm lb:text-gray-600 lb:mt-1",children:["Marca los recortes que deseas"," ","save"===le?"guardar":"descargar"]})]}),F.jsx("div",{className:"lb:px-6 lb:py-4 lb:overflow-y-auto lb:flex-1",children:F.jsx("div",{className:"lb:space-y-2",children:H.map((e,t)=>{const n=e.savedState||t===G,l=!e.required&&!n,r=e.required&&"save"===le;return F.jsxs("label",{className:`lb:flex lb:items-center lb:gap-3 lb:p-3 lb:rounded lb:border lb:transition-colors ${te.includes(t)?"lb:bg-blue-50 lb:border-blue-300":l?"lb:bg-gray-100 lb:border-gray-300 lb:opacity-60":"lb:bg-gray-50 lb:border-gray-200 lb:hover:bg-gray-100"} ${l||r?"lb:cursor-not-allowed":"lb:cursor-pointer"}`,title:r?"Este recorte es obligatorio y debe ser guardado":"",children:[F.jsx("input",{type:"checkbox",checked:te.includes(t),disabled:l||r,onChange:e=>{e.target.checked?ne(e=>[...e,t]):ne(e=>e.filter(e=>e!==t))},className:"lb:w-4 lb:h-4 lb:text-blue-600"}),F.jsxs("div",{className:"lb:flex-1 lb:min-w-0",children:[F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2 lb:flex-wrap",children:[F.jsxs("span",{title:"Nombre del archivo a descargar",className:"lb:text-sm lb:font-medium lb:text-gray-800 lb:truncate",children:[e.label,"_",e.width,"_",e.height]}),e.required&&F.jsx("span",{className:"lb:text-xs lb:px-1.5 lb:py-0.5 lb:bg-red-200 lb:text-red-1000 lb:rounded lb:whitespace-nowrap",children:"Obligatorio"}),!n&&!e.required&&F.jsx("span",{className:"lb:text-xs lb:px-1.5 lb:py-0.5 lb:bg-orange-100 lb:text-orange-700 lb:rounded lb:whitespace-nowrap",children:"Sin configurar"})]}),F.jsxs("span",{title:"Dimensiones del recorte",className:"lb:text-xs lb:text-gray-500",children:[e.width," × ",e.height," px"]})]})]},e.id)})})}),F.jsxs("div",{className:"lb:px-6 lb:py-4 lb:border-t lb:border-gray-200 lb:flex lb:gap-3 lb:justify-end",children:[F.jsx("button",{onClick:()=>{ee(!1),re(null),ne([])},className:"limbo-btn limbo-btn-secondary lb:px-4 lb:py-2",children:"Cancelar"}),F.jsxs("button",{onClick:async()=>{if(ee(!1),"save"===le)if(1===te.length){const e=G;Q(te[0]),await new Promise(e=>setTimeout(e,100)),await lt(),Q(e)}else await rt(te);else if(1===te.length){const e=G;Q(te[0]),await new Promise(e=>setTimeout(e,100)),await st(),Q(e)}else await it(te);re(null),ne([])},disabled:0===te.length,className:"limbo-btn limbo-btn-primary lb:px-4 lb:py-2 lb:disabled:opacity-50 lb:disabled:cursor-not-allowed",children:["save"===le?"Guardar":"Descargar"," (",te.length,")"]})]})]})}),P&&F.jsx("div",{className:"lb:fixed lb:inset-0 lb:bg-black/50 lb:flex lb:items-center lb:justify-center lb:z-[9999] lb:p-4",children:F.jsxs("div",{className:"lb:bg-white lb:rounded-lg lb:shadow-xl lb:max-w-5xl lb:w-full lb:max-h-[90vh] lb:overflow-hidden lb:flex lb:flex-col",children:[F.jsx("div",{className:"lb:px-6 lb:py-4 lb:border-b lb:border-gray-200 lb:bg-brand-blue-50",children:F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between",children:[F.jsxs("h3",{className:"lb:text-xl lb:font-semibold lb:text-brand-blue-1000 lb:flex lb:items-center lb:gap-2",children:[F.jsx("span",{className:"icon icon-lightbulb lb:text-yellow-500"}),"Guía de uso del Cropper"]}),F.jsx("button",{onClick:()=>I(!1),className:"lb:text-gray-400 lb:hover:text-gray-600 lb:p-1 lb:rounded-full lb:hover:bg-gray-100 lb:transition-colors","aria-label":"Cerrar modal",children:F.jsx("span",{className:"icon icon-close-small icon--lg"})})]})}),F.jsxs("div",{className:"lb:px-6 lb:py-4 lb:overflow-y-auto lb:flex-1 lb:space-y-4",children:[F.jsxs("div",{className:"lb:bg-brand-blue-50 lb:rounded-lg lb:p-4 lb:border-l-4 lb:border-brand-blue-400",children:[F.jsx("h4",{className:"lb:font-semibold lb:text-brand-blue-1000 lb:mb-3 lb:text-base lb:flex lb:items-center lb:gap-2",children:"🖱️ Navegación básica"}),F.jsxs("div",{className:"lb:text-sm lb:text-brand-blue-800 lb:space-y-2",children:[F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Arrastra la imagen:"})," Haz clic sobre la imagen dentro del área de selección y arrástrala para reposicionarla"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Zoom:"})," Usa la rueda del ratón sobre el canvas (fuera del área de selección) para hacer zoom"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Vista completa:"}),' Botón "Reset zoom" para ajustar automáticamente al tamaño óptimo']})]})]})]}),F.jsxs("div",{className:"lb:bg-brand-blue-50 lb:rounded-lg lb:p-4 lb:border-l-4 lb:border-brand-blue-400",children:[F.jsx("h4",{className:"lb:font-semibold lb:text-brand-blue-1000 lb:mb-3 lb:text-base lb:flex lb:items-center lb:gap-2",children:"✂️ Área de selección"}),F.jsxs("div",{className:"lb:text-sm lb:text-brand-blue-800 lb:space-y-2",children:[F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Mover selección:"})," Arrastra desde el centro",F.jsx("span",{className:"icon lb:bg-white icon-move lb:inline-block lb:mx-1 lb:align-middle lb:border lb:border-brand-blue-400 lb:rounded-full"}),"para reposicionar el área de recorte"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Redimensionar:"})," Arrastra desde las esquinas o bordes para cambiar el tamaño del área"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Tamaños rápidos:"})," Usa los botones de porcentaje (50%, 70%, 90%, 100%) para ajustar rápidamente el tamaño"]})]})]})]}),F.jsxs("div",{className:"lb:bg-brand-blue-50 lb:rounded-lg lb:p-4 lb:border-l-4 lb:border-brand-blue-400",children:[F.jsx("h4",{className:"lb:font-semibold lb:text-brand-blue-1000 lb:mb-3 lb:text-base lb:flex lb:items-center lb:gap-2",children:"⌨️ Atajos de teclado"}),F.jsxs("div",{className:"lb:text-sm lb:text-brand-blue-800 lb:space-y-2",children:[F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Flechas:"}),F.jsxs("span",{className:"lb:inline-flex lb:gap-1 lb:mx-1",children:[F.jsx("span",{className:"icon icon-arrow-right-box lb:rotate-180 icon--sm"}),F.jsx("span",{className:"icon icon-arrow-right-box icon--sm"}),F.jsx("span",{className:"icon icon-arrow-right-box lb:-rotate-90 icon--sm"}),F.jsx("span",{className:"icon icon-arrow-right-box lb:rotate-90 icon--sm"})]}),"Mueven la selección en incrementos de 10px"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Shift + Arrastrar:"})," Mantiene las proporciones al redimensionar el área de selección"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Ctrl + Rueda:"})," Control de zoom más preciso y fino"]})]})]})]}),F.jsxs("div",{className:"lb:bg-teal-50 lb:rounded-lg lb:p-4 lb:border-l-4 lb:border-teal-800",children:[F.jsx("h4",{className:"lb:font-semibold lb:text-teal-1000 lb:mb-3 lb:text-base lb:flex lb:items-center lb:gap-2",children:"👁️ Opciones de visualización"}),F.jsxs("div",{className:"lb:text-sm lb:text-teal-800 lb:space-y-2",children:[F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Cuadrícula:"})," Muestra la regla de los tercios para mejorar la composición de tus recortes"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Tablero:"})," Patrón de cuadros para alinear mejor las medidas o ver imágenes con transparencia"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Vista previa:"})," Muestra cómo quedará el recorte final antes de guardarlo"]})]})]})]}),F.jsxs("div",{className:"lb:bg-amber-50 lb:rounded-lg lb:p-4 lb:border-l-4 lb:border-amber-400",children:[F.jsx("h4",{className:"lb:font-semibold lb:text-amber-800 lb:mb-3 lb:text-base lb:flex lb:items-center lb:gap-2",children:"💡 Consejos profesionales"}),F.jsxs("div",{className:"lb:text-sm lb:text-amber-700 lb:space-y-2",children:[F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Orden de trabajo:"})," Primero aplica transformaciones (rotar, voltear), luego haz el recorte final"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Múltiples recortes:"})," Si tienes varios recortes configurados, revisa cada uno antes de guardar"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Calidad:"})," Las imágenes se exportan en alta calidad (JPEG 90%) manteniendo la mayor nitidez posible"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Proporciones:"})," Usa Shift al redimensionar para mantener el aspecto ratio original"]})]})]})]}),F.jsxs("div",{className:"lb:bg-orange-50 lb:rounded-lg lb:p-4 lb:border-l-4 lb:border-orange-500",children:[F.jsx("h4",{className:"lb:font-semibold lb:text-orange-800 lb:mb-3 lb:text-base lb:flex lb:items-center lb:gap-2",children:"⚠️ Notas importantes"}),F.jsxs("div",{className:"lb:text-sm lb:text-orange-700 lb:space-y-2",children:[F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Recortes grandes:"})," Imágenes de alta resolución pueden tardar más en procesarse"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Calidad de escala:"})," Evita ampliar demasiado áreas pequeñas, ya que puede afectar la nitidez"]})]}),F.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[F.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),F.jsxs("div",{children:[F.jsx("strong",{children:"Cambios pendientes:"})," Recuerda guardar tus cambios antes de cerrar o cambiar de imagen"]})]})]})]})]}),F.jsx("div",{className:"lb:px-6 lb:py-4 lb:border-t lb:border-gray-200 lb:bg-gray-50",children:F.jsx("button",{onClick:()=>I(!1),className:"limbo-btn limbo-btn-primary lb:w-full",children:"Entendido"})})]})}),u&&F.jsx("div",{className:"lb:min-w-[90%] lb:fixed lb:md:absolute lb:inset-0 lb:md:inset-auto lb:bg-black/50 lb:md:bg-transparent lb:flex lb:items-center lb:justify-center lb:md:block lb:z-9999 lb:md:z-50 lb:pointer-events-none",onClick:e=>{e.target===e.currentTarget&&window.innerWidth<768&&(d(!1),m(null))},children:F.jsxs("div",{className:"lb:pointer-events-auto lb:bg-white lb:rounded-lg lb:shadow-2xl lb:border-2 lb:border-brand-blue-800 lb:overflow-hidden lb:flex lb:flex-col lb:max-w-md lb:w-full lb:mx-4 lb:md:mx-0 lb:max-h-[80vh] lb:md:max-h-[600px]",style:{...window.innerWidth>=768?{position:"absolute",left:`${w.x}px`,top:`${w.y}px`,width:"420px",cursor:C?"grabbing":"default"}:{}},onMouseDown:Xe,onTouchStart:Ze,children:[F.jsxs("div",{className:"limbo-preview-modal-header lb:px-4 lb:py-3 lb:bg-linear-to-r lb:from-brand-blue-800 lb:to-brand-blue-1000 lb:text-white lb:flex lb:items-center lb:justify-between lb:cursor-grab lb:active:cursor-grabbing lb:select-none",style:{cursor:C?"grabbing":"grab"},children:[F.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2",children:[F.jsx("span",{className:"icon icon-search-white icon--sm"}),F.jsx("h3",{className:"lb:text-sm lb:font-semibold lb:text-white",children:"Vista previa"})]}),F.jsx("button",{onClick:()=>{d(!1),m(null)},className:"lb:flex lb:p-1 lb:hover:bg-white/20 lb:rounded lb:transition-colors lb:cursor-pointer lb:aspect-square lb:min-w-fit lb:min-h-fit","aria-label":"Cerrar vista previa",title:"Cerrar vista previa",children:F.jsx("span",{className:"icon icon-close-small-white icon--sm lb:p-0 lb:m-0 lb:py-auto lb:my-auto lb:mx-auto"})})]}),F.jsx("div",{className:"lb:flex-1 lb:overflow-auto lb:bg-gray-50 lb:p-4",children:h?F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center lb:h-full lb:min-h-[200px]",children:F.jsxs("div",{className:"lb:text-center",children:[F.jsx("div",{className:"lb:animate-spin lb:rounded-full lb:h-12 lb:w-12 lb:border-b-2 lb:border-blue-600 lb:mx-auto lb:mb-3"}),F.jsx("p",{className:"lb:text-sm lb:text-gray-600",children:"Generando vista previa..."})]})}):b?F.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-3",children:[F.jsxs("div",{className:"lb:relative lb:w-full lb:bg-white lb:rounded-lg lb:border lb:border-gray-200 lb:overflow-hidden lb:shadow-sm lb:cursor-zoom-in lb:hover:ring-2 lb:hover:ring-brand-blue-800 lb:transition-all",onClick:()=>$(!0),role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),$(!0))},"aria-label":"Click para ver recorte en tamaño completo",title:"Click para ampliar",children:[F.jsx("img",{src:b,alt:"Vista previa del recorte",className:"lb:w-full lb:h-auto lb:object-contain lb:max-h-[400px]"}),F.jsxs("div",{className:"lb:absolute lb:top-2 lb:right-2 lb:bg-black/60 lb:text-white lb:px-2 lb:py-1 lb:rounded lb:text-xs lb:flex lb:items-center lb:gap-1",children:[F.jsx("span",{className:"icon icon-search-white icon--xs"}),F.jsx("span",{children:"Ampliar"})]})]}),F.jsxs("div",{className:"lb:text-center lb:text-xs lb:text-gray-500",children:[F.jsx("p",{className:"lb:font-medium lb:text-gray-700 lb:mb-1",children:X?.label||"Recorte"}),F.jsxs("p",{children:[X?.width," × ",X?.height," px"]})]})]}):F.jsx("div",{className:"lb:flex lb:items-center lb:justify-center lb:h-full lb:min-h-[200px]",children:F.jsx("p",{className:"lb:text-sm lb:text-gray-500",children:"No se pudo generar la vista previa"})})}),F.jsx("div",{className:"lb:px-4 lb:py-2 lb:bg-gray-100 lb:border-t lb:border-gray-200",children:F.jsxs("p",{className:"lb:text-xs lb:text-gray-600 lb:text-center",children:[F.jsxs("span",{className:"lb:hidden lb:md:inline",children:["Arrastra desde el título para mover •"," "]}),"Actualización automática al editar"]})})]})}),F.jsx(Pe,{src:b,alt:"Vista previa del recorte",title:X?.label||"Recorte",subtitle:`${X?.width||0} × ${X?.height||0} px`,isOpen:E&&!!b,onClose:()=>$(!1)})]}):null}function cl({currentPage:e,totalPages:t,onPageChange:n,disabled:l=!1}){if(!t||t<=1)return null;const r=(()=>{const n=[],l=[],r=Math.max(1,e-2),a=Math.min(t,e+2);for(let e=r;e<=a;e++)n.push(e);return r>1&&(l.push(1),r>2&&l.push("...")),l.push(...n),a<t&&(a<t-1&&l.push("..."),l.push(t)),l})();return F.jsx("div",{className:"lb:flex lb:flex-col lb:items-center lb:justify-center lb:space-x-2 lb:py-4",children:F.jsxs("div",{className:"lb:flex lb:space-x-2 lb:mt-2",children:[F.jsxs("button",{onClick:()=>{e>1&&n(e-1)},disabled:l||e<=1,className:` lb:px-3 lb:py-2 lb:text-sm lb:font-medium lb:rounded-md lb:transition-colors lb:disabled:cursor-default lb:cursor-pointer ${l||e<=1?"lb:text-gray-400 lb:bg-gray-100 lb:cursor-not-allowed":"lb:text-gray-700 lb:bg-white lb:border lb:border-gray-300 lb:hover:bg-gray-50 lb:focus:ring-2 lb:focus:ring-blue-500"} `,children:[F.jsx("span",{className:"icon icon-arrow-left icon--sm"})," Anterior"]}),F.jsx("div",{className:"lb:flex lb:space-x-1",children:r.map((t,r)=>F.jsx(v.Fragment,{children:"..."===t?F.jsx("span",{className:"lb:px-3 lb:py-2 lb:text-sm lb:text-gray-500",children:"..."}):F.jsx("button",{onClick:()=>(t=>{t!==e&&n(t)})(t),disabled:l,className:` lb:px-3 lb:py-2 lb:text-sm lb:font-medium lb:rounded-md lb:transition-colors lb:disabled:cursor-default lb:cursor-pointer ${t===e?"lb:bg-brand-blue-800 lb:text-white lb:border lb:border-brand-blue-1000":l?"lb:text-gray-400 lb:bg-gray-100 lb:cursor-not-allowed":"lb:text-gray-700 lb:bg-white lb:border lb:border-gray-300 lb:hover:bg-gray-50 lb:focus:ring-2 lb:focus:ring-blue-500"} `,children:t})},`page-${t}-${r}`))}),F.jsxs("button",{onClick:()=>{e<t&&n(e+1)},disabled:l||e>=t,className:` lb:px-3 lb:py-2 lb:text-sm lb:font-medium lb:rounded-md lb:transition-colors lb:disabled:cursor-default lb:cursor-pointer ${l||e>=t?"lb:text-gray-400 lb:bg-gray-100 lb:cursor-not-allowed":"lb:text-gray-700 lb:bg-white lb:border lb:border-gray-300 lb:hover:bg-gray-50 lb:focus:ring-2 lb:focus:ring-blue-500"} `,children:["Siguiente ",F.jsx("span",{className:"icon icon-arrow-right icon--sm"})]})]})})}function ul({text:e="Cargando..."}){return F.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-neutral-gray-1000/20 lb:z-10 lb:flex lb:flex-col lb:items-center lb:justify-center lb:py-8 lb:text-gray-600",role:"status","aria-live":"polite","aria-label":e,children:[F.jsx("span",{className:"limbo-filter-searching","aria-hidden":"true",children:F.jsx("span",{className:"icon icon-spinner lb:animate-spin lb:min-w-7 lb:min-h-7"})}),F.jsx("p",{className:"lb:text-sm",id:"loader-text",children:e})]})}function dl({isOpen:e,onClose:t}){return e?F.jsx("div",{className:"lb:fixed lb:inset-0 lb:bg-black lb:bg-opacity-50 lb:flex lb:items-center lb:justify-center lb:z-50",style:{zIndex:9999},children:F.jsxs("div",{className:"lb:bg-white lb:rounded-lg lb:p-6 lb:max-w-md lb:mx-4 lb:shadow-xl",children:[F.jsxs("div",{className:"lb:flex lb:items-center lb:mb-4",children:[F.jsx("svg",{className:"lb:w-6 lb:h-6 lb:text-red-1000 lb:mr-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"})}),F.jsx("h3",{className:"lb:text-lg lb:font-semibold lb:text-gray-900",children:"Sesión Expirada"})]}),F.jsxs("div",{className:"lb:mb-6",children:[F.jsx("p",{className:"lb:text-gray-600 lb:mb-2",children:"Su sesión ha expirado por seguridad."}),F.jsx("p",{className:"lb:text-gray-600",children:"Es necesario recargar la página para obtener un nuevo token de acceso."})]}),F.jsx("div",{className:"lb:flex lb:justify-end lb:space-x-3",children:F.jsx("button",{onClick:t,className:"lb:px-4 lb:py-2 lb:bg-blue-600 lb:text-white lb:rounded-md lb:hover:bg-blue-700 lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-blue-500 lb:focus:ring-offset-2 lb:transition-colors",children:"Recargar Página"})})]})}):null}function bl(){const[e,t]=y.useState(!1),[n,l]=y.useState(null);return{deleteImg:async e=>{if(!e)return l("ID de imagen no proporcionado"),!1;t(!0),l(null);try{const t=await async function(e){try{return await ce({endpoint:`/assets/${e}`,method:"DELETE",basePath:ge,useJWT:!0})}catch(n){throw fe(n)}}(e);return!1!==t.success}catch(r){return l(r.message),!1}finally{t(!1)}},loading:e,error:n,reset:()=>{l(null)}}}const ml=new Map,hl=6e5,pl="limbo_gallery_cache";function fl(e,t=!1,n={},l=!0){const r=y.useMemo(()=>JSON.stringify(n),[n]),a=y.useRef((()=>{const e=r,t=ml.get(e),n=Date.now();return t&&n-t.timestamp<hl?{images:t.data,pagination:t.pagination||null,loading:!1}:{images:[],pagination:null,loading:l}})()),[o,i]=y.useState(a.current.images),[s,c]=y.useState(a.current.loading),[u,d]=y.useState(null),[b,m]=y.useState(a.current.pagination),[h,p]=y.useState(0),[f,g]=y.useState(0);y.useEffect(()=>{if(!l)return void c(!1);const e=`${r}`,t=ml.get(e),a=Date.now();if(t&&a-t.timestamp<hl)return i(t.data),m(t.pagination||null),void c(!1);let o=!0;return(async()=>{if(h>=3)o&&(d("Error de autenticación: Verifica tus credenciales API"),c(!1));else try{const t=await ye(n);if(!o)return;const l=t.result||t.data||[],r=t.pagination||null;i(l),m(r),d(null),p(0),ml.set(e,{data:l,pagination:r,timestamp:a}),(()=>{try{const e={};ml.forEach((t,n)=>{e[n]=t}),sessionStorage.setItem(pl,JSON.stringify(e))}catch{}})()}catch(t){o&&(d(t.message),p(e=>e+1))}finally{o&&c(!1)}})(),()=>{o=!1}},[e,t,r,h,n,l,f]);return{images:o,loading:s,error:u,pagination:b,setImages:i,invalidateCache:()=>{ml.clear();try{sessionStorage.removeItem(pl)}catch{}},refetch:()=>{ml.clear();try{sessionStorage.removeItem(pl)}catch{}c(!0),g(e=>e+1)}}}function gl(e,t=500){const[n,l]=y.useState(e);return y.useEffect(()=>{const n=setTimeout(()=>{l(e)},t);return()=>{clearTimeout(n)}},[e,t]),n}function yl(){return F.jsxs("div",{className:"lb:flex lb:items-center lb:justify-center lb:gap-2 lb:py-2 lb:px-4 lb:border-t lb:h-8 lb:border-brand-purple-200 lb:bg-brand-purple-50 lb:rounded-b-md lb:mt-3",style:{background:"linear-gradient(90deg,#001978,#2134f1 50%,#f81bbd 95%)",color:"white"},children:[F.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 52",fill:"currentColor",className:"lb:w-5 lb:h-5 lb:text-white","aria-hidden":"true",children:[F.jsx("path",{d:"M29.0863 15.2704H24.9419V36.7321H37.5259V33.1048H29.0863V15.2704Z"}),F.jsx("path",{d:"M18.1601 33.1048H9.72056V36.7321H22.3045V15.2704H18.1601V33.1048Z"}),F.jsx("path",{d:"M44.0063 51.846L3.16483 50.1834C1.35636 50.1834 0 48.5965 0 46.8584V4.99294C0 3.33041 1.65777 1.8946 3.31554 1.81903L44.157 0.1565C46.2669 0.0809304 48 1.74346 48 3.8594V47.8408C48 50.0323 46.1915 51.846 43.9309 51.7704H44.0063V51.846ZM4.89796 46.405L42.9513 47.4629C43.4788 47.4629 44.0063 47.0095 44.0063 46.4805V5.21965C44.0063 4.69066 43.6295 4.31282 43.102 4.31282L4.82261 5.67307C4.14443 5.67307 3.61695 6.27762 3.61695 6.95775V45.1203C3.61695 45.8004 4.14443 46.3294 4.82261 46.405H4.89796Z"})]}),F.jsxs("span",{className:"lb:text-xs lb:text-neutral-50",children:["Powered by ",F.jsx("span",{className:"lb:font-semibold lb:text-white",children:"Limbo"})]})]})}function vl({apiKey:e,prod:t=!1,url:n=!0,features:l=["gallery","upload","cropper"],modeUI:r="full",ui:a={showActions:["select","download","copy","delete","crop","variants"],hideActions:[],theme:"light",language:"es",compactMode:!1,showTabs:!0},callbacks:i={},instanceId:s=null,itemsPerPage:c=30,_externalImage:u=null,cropperConfig:d=null,folderConfig:b={include:[],exclude:[],includeNoFolder:!0,showFolderSelector:!0,showFolderFilter:!0,showFolderInfo:!0,allowMoveFolder:!0,allowCreateFolder:!0,defaultFolder:null},allowedCategories:m=null,accept:h=null,returnConfig:p=null}){sessionStorage.removeItem("limbo_stock_selectedService"),sessionStorage.removeItem("limbo_stock_dynamicForm"),sessionStorage.removeItem("limbo_stock_stockImages"),sessionStorage.removeItem("limbo_stock_currentPage"),sessionStorage.removeItem("limbo_stock_paginationInfo"),sessionStorage.removeItem("limbo_portals_searchName"),sessionStorage.removeItem("limbo_portals_limit"),sessionStorage.removeItem("limbo_portals_currentPage"),sessionStorage.removeItem("limbo_portals_images"),sessionStorage.removeItem("limbo_portals_portalResults"),sessionStorage.removeItem("limbo_portals_paginationInfo");const[f,g]=y.useState({name:"",uploadedBy:"",dateFrom:"",dateTo:"",assetType:"",folder:""}),[x,w]=y.useState(b?.defaultFolder||null),k=gl(f.name,400),C=gl(f.uploadedBy,400),S=v.useMemo(()=>o(h||(m?m.map(e=>`${e}/*`).join(","):null)),[h,m]),j=e=>!!e&&(e.startsWith("image/")&&"image/gif"!==e),N=(()=>{let e;switch(r){case"gallery-only":e=["gallery"];break;case"upload-only":e=["upload","cropper"];break;case"crop-only":e=["cropper"];break;case"ia-only":e=["ia"];break;default:e=[...l]}return S.isAllTypes||S.includesImages||(e=e.filter(e=>"cropper"!==e)),e})(),E=()=>N.includes("gallery")?"gallery":N.includes("upload")?"upload":N.includes("cropper")?"cropper":N.includes("ia")?"ia":N[0]||"gallery",[$,_]=y.useState(E()),[T,z]=y.useState(null),L=y.useRef(null);y.useEffect(()=>{!T&&L.current&&(URL.revokeObjectURL(L.current),L.current=null)},[T]);const[A,M]=y.useState(null);y.useEffect(()=>{u&&(console.log("📸 Imagen externa detectada:",u),z(u),_("cropper"))},[u]),y.useEffect(()=>{const e=()=>{console.log("[App] Modal cerrado, reseteando estado..."),z(null),_(E())};return window.limboCore?.events&&window.limboCore.events.on("modal:closed",e),()=>{window.limboCore?.events&&window.limboCore.events.off("modal:closed",e)}},[]);const[P,I]=y.useState(1),{isTokenExpired:D,handleTokenExpiredClose:O}=function(){const[e,t]=y.useState(!1),n=y.useCallback(e=>{if(401===e?.response?.status){const n=e.response.data;if("token_expired"===n?.error||n?.message?.includes("expired")||n?.message?.includes("caducado")||n?.error?.includes("expired"))return t(!0),!0}return!1},[]),l=y.useCallback(()=>{t(!1),alert("El token ha expirado. La página se recargará para obtener un nuevo token."),window.location.reload()},[]);return y.useEffect(()=>{const e=e=>{e.detail&&e.detail.error&&n(e.detail.error)};return window.addEventListener("tokenExpiredError",e),()=>{window.removeEventListener("tokenExpiredError",e)}},[n]),{isTokenExpired:e,checkTokenExpiration:n,handleTokenExpiredClose:l}}(),{upload:R,loading:U,error:B,uploadedImage:q,reset:V}=function(){const[e,t]=y.useState(!1),[n,l]=y.useState(null),[r,a]=y.useState(null);return{upload:async(e,n=null,r=null)=>{if(!e)return l("No se ha proporcionado ningún archivo"),null;t(!0),l(null),a(null);try{const t="object"==typeof r?r?.slug:r,l=await ve(e,n,!1,t),o=l.result||l;return a(o),o}catch(o){return l(o.message),null}finally{t(!1)}},loading:e,error:n,uploadedImage:r,reset:()=>{l(null),a(null)}}}(),{deleteImg:H,loading:K,error:G,reset:Q}=bl(),X={limit:c,page:P,...k&&{name:k},...C&&{uploadedBy:C},...f.dateFrom&&{dateFrom:f.dateFrom},...f.dateTo&&{dateTo:f.dateTo},...f.assetType&&{asset_type:f.assetType},...!S.isAllTypes&&S.raw&&{accept:S.raw},...f.folder&&{folder:f.folder},...b.include?.length>0&&{folders_include:b.include.join(",")},...0===b.include?.length&&b.exclude?.length>0&&{folders_exclude:b.exclude.join(",")},...(b.include?.length>0||b.exclude?.length>0)&&void 0!==b.includeNoFolder&&{include_no_folder:b.includeNoFolder?"1":"0"}},Y=N.includes("gallery"),{images:J,loading:Z,error:ee,pagination:te,invalidateCache:ne,setImages:le,refetch:re}=fl(e,t,X,Y);y.useEffect(()=>{const e=()=>{re()};return document.addEventListener("limbo:variantsCleared",e),document.addEventListener("limbo:variantDeleted",e),()=>{document.removeEventListener("limbo:variantsCleared",e),document.removeEventListener("limbo:variantDeleted",e)}},[re]);const{refreshVariants:ae}=ke(),oe=y.useCallback((e,t=null)=>R(e,t,x?.slug||x),[R,x]),ie=e=>!a.hideActions?.includes(e)&&(!!a.showActions?.includes(e)||!(a.showActions?.length>0)),se=[{id:"gallery",label:"Galería",feature:"gallery"},{id:"upload",label:"Subir",feature:"upload"},{id:"cropper",label:"Recortador",hideNonActive:!0,feature:"cropper"}].filter(e=>N.includes(e.feature)),ce=async e=>{if(!(e.type?.startsWith("image/")&&"image/gif"!==e.type)){const t=x?.slug||x,n=await R(e,null,t);return void(n&&(ne(),I(1),le(e=>[n,...e]),N.includes("gallery")&&_("gallery"),i.onUpload&&i.onUpload({assetId:n.id,url:n.url,fileName:n.filename,mime:n.mime_type,width:n.width,height:n.height,instanceId:s})))}const t=URL.createObjectURL(e),n=await new Promise(e=>{const n=new Image;n.onload=()=>{e({width:n.naturalWidth,height:n.naturalHeight}),URL.revokeObjectURL(t)},n.onerror=()=>{e({width:1920,height:1080}),URL.revokeObjectURL(t)},n.src=t}),l={file:e,filename:e.name,mime_type:e.type,url:(()=>{const t=URL.createObjectURL(e);return L.current=t,t})(),width:n.width,height:n.height};if(z(l),N.includes("cropper"))_("cropper");else{const t=x?.slug||x,n=await R(e,null,t);n&&(ne(),I(1),le(e=>[n,...e]),_("gallery"),i.onUpload&&i.onUpload({assetId:n.id,url:n.url,fileName:n.filename,mime:n.mime_type,width:n.width,height:n.height,instanceId:s}))}},ue=y.useCallback(e=>{const t={...e,instanceId:s};i.onSelect&&i.onSelect(t),window.limboCore?.events&&window.limboCore.events.emit("select",t);"modal"===((window.limboCore?.config?.getGlobal()||{}).mode||"embed")&&window.limboCore?.modals?.closeAllModals(),M(`Vídeo seleccionado: ${e.title||"Sin título"}`),setTimeout(()=>M(null),3e3)},[i,s]),de=async e=>{if(!confirm("¿Estás seguro de que deseas eliminar este archivo? Esta acción también eliminará todos sus recortes."))return;await H(e)&&(ne(),I(1),le(t=>t.filter(t=>t.id!==e)),T&&T.id===e&&(z(null),_("gallery")))},be=y.useCallback(async(e,t)=>{const n=await xe(e.id,{original_filename:t});return le(l=>l.map(l=>l.id===e.id?{...l,filename:n.filename??t}:l)),n},[]),me=e=>{j(e.mime_type||e.original_mime)?(z(e),N.includes("cropper")&&_("cropper")):console.log("[App] ⚠️ Archivo no recortable:",e.mime_type||e.original_mime,"- saltando cropper")},he=()=>"crop-only"===r||1===N.length&&"cropper"===N[0]?"crop-only":N.includes("gallery")?"with-gallery":N.includes("upload")&&!N.includes("gallery")?"upload-only":"with-gallery";return F.jsxs(F.Fragment,{children:[a.showTabs&&"cropper"!=$&&F.jsx(W,{tabs:se,active:$,onChange:e=>{_(e),"upload"!==e&&V(),"gallery"!==e&&Q()}}),ee&&F.jsxs(Ge,{variant:"danger",children:["Error al cargar archivos: ",ee]}),G&&F.jsxs(Ge,{variant:"danger",children:["Error al eliminar archivo: ",G]}),A&&F.jsx(Ge,{variant:"success",fixed:!0,onClose:()=>M(null),children:A}),"gallery"===$&&F.jsxs(F.Fragment,{children:[K&&F.jsx(ul,{text:"Eliminando archivo..."}),q&&F.jsxs(Ge,{variant:"success",toast:!0,onClose:V,children:[F.jsx("span",{className:"icon icon-tick-white icon--2sm"})," Archivo subido correctamente: ",q.filename]}),F.jsx(Xe,{onSelect:e=>{const t=d?.mandatoryCrops?.length>0,n=j(e.mime_type||e.original_mime);if(t&&n&&N.includes("cropper"))return console.log("[App] 📐 MandatoryCrops detectados, navegando al cropper primero"),void me(e);i.onSelect&&i.onSelect({assetId:e.id,url:e.url,fileName:e.filename,mime:e.mime_type,width:e.width,height:e.height,instanceId:s})},onCrop:me,onDelete:ie("delete")?de:null,deletingId:K,images:J,loading:Z,error:ee,filters:f,debouncedFilters:{name:k,uploadedBy:C,dateFrom:f.dateFrom,dateTo:f.dateTo,assetType:f.assetType,folder:f.folder},onFiltersChange:e=>{g(e),I(1)},filterConfig:a.galleryFilters||{},loadingConfig:a.galleryLoading||{},allowedActions:{select:ie("select"),download:ie("download"),copy:ie("copy"),delete:ie("delete"),crop:ie("crop"),rename:ie("rename")},resolvedAccept:S,allowedCategories:m,folderConfig:b,onFolderChange:async(e,t)=>{try{const n=await xe(e.id,{folder:t});return ne(),le(t=>t.map(t=>t.id===e.id?{...t,folder:n.folder||null}:t)),n}catch(n){throw console.error("Error al cambiar carpeta:",n),n}},onRename:be}),te&&!Z&&F.jsx(cl,{currentPage:te.page||P,totalPages:te.pages||1,onPageChange:e=>{I(e)},disabled:Z||K})]}),"upload"===$&&F.jsxs("div",{children:[U&&F.jsx(ul,{text:"Subiendo archivo..."}),B&&F.jsxs(Ge,{variant:"danger",toast:!0,onClose:V,children:["Error al subir archivo: ",B]}),q&&F.jsxs(Ge,{variant:"success",toast:!0,onClose:V,children:[F.jsx("span",{className:"icon icon-tick-white icon--2sm"})," Archivo subido correctamente: ",q.filename]}),F.jsx(Ct,{onSelect:ce,onVideoSelect:ue,disabled:U,apiKey:e,prod:t,allowedCategories:m,resolvedAccept:S,returnConfig:p,folderConfig:b,selectedFolder:x,onFolderChange:w})]}),"cropper"===$&&T&&F.jsx(sl,{image:T,onSave:e=>{const t=he(),n=window.limboCore?.config?.getGlobal()||{},l=n.mode||"embed",r=n.autoHideOnComplete||!1;let a=[],o=null;e.crops&&e.asset?(a=e.crops,o=e.asset):a=e.crops&&Array.isArray(e.crops)?e.crops:Array.isArray(e)?e:[e],o&&"with-gallery"===t&&(le(e=>[o,...e]),I(1),i.onUpload&&i.onUpload({assetId:o.id,url:o.url,fileName:o.filename,mime:o.mime_type,width:o.width,height:o.height,instanceId:s})),"with-gallery"===t&&ne();const c=o||T,u=a.some(e=>!0===e.isLocal),d={crops:a,assetId:c?.id,instanceId:s,localCrops:u,asset:c?{id:c.id,url:c.url||c.urlSigned,width:c.width,height:c.height,filename:c.filename,mime_type:c.mime_type}:null};console.log("[App] handleCropSave - callbackPayload:",d),console.log("[App] handleCropSave - crops:",a),console.log("[App] handleCropSave - crops[0]?.url:",a[0]?.url),console.log("[App] handleCropSave - asset:",d.asset),console.log("[App] handleCropSave - callbacks.onCropsSaved existe:",!!i.onCropsSaved),i.onCropsSaved?(console.log("[App] Llamando callbacks.onCropsSaved..."),i.onCropsSaved(d),console.log("[App] callbacks.onCropsSaved ejecutado")):console.warn("[App] ⚠️ callbacks.onCropsSaved NO existe"),window.limboCore?.events&&window.limboCore.events.emit("cropsSaved",d);const b=a.length;switch(M(`✅ ${b} recorte${1!==b?"s":""} guardado${1!==b?"s":""} correctamente`),setTimeout(()=>M(null),3e3),t){case"with-gallery":"modal"===l?i.onCropsSaved||(window.limboCore?.modals?.closeAllModals(),z(null),_("gallery")):(z(null),_("gallery"));break;case"upload-only":"modal"===l?i.onCropsSaved||(window.limboCore?.modals?.closeAllModals(),z(null),_("upload")):(z(null),_("upload"));break;case"crop-only":if("modal"===l)i.onCropperComplete&&i.onCropperComplete({crops:a,instanceId:s}),window.limboCore?.events&&window.limboCore.events.emit("cropperComplete",{crops:a,instanceId:s}),window.limboCore?.modals?.closeAllModals();else if(i.onCropperComplete&&i.onCropperComplete({crops:a,instanceId:s}),window.limboCore?.events&&window.limboCore.events.emit("cropperComplete",{crops:a,instanceId:s}),r){const e=document.querySelector(`#limbo-instance-${s}`);e&&(e.style.display="none")}}},onCancel:()=>{const e=he(),t=(window.limboCore?.config?.getGlobal()||{}).mode||"embed";switch(i.onCropperCancelled&&i.onCropperCancelled({assetId:T?.id,instanceId:s}),window.limboCore?.events&&window.limboCore.events.emit("cropperCancelled",{assetId:T?.id,instanceId:s}),e){case"with-gallery":z(null),_("gallery");break;case"upload-only":"modal"===t?window.limboCore?.modals?.closeAllModals():(z(null),_("upload"));break;case"crop-only":"modal"===t?window.limboCore?.modals?.closeAllModals():window.limboCore?.events&&window.limboCore.events.emit("cropperClosed",{instanceId:s,reason:"cancelled"})}},onDelete:T?.id&&ie("delete")?()=>de(T.id):null,onError:e=>{i.onCropperError&&i.onCropperError(e,s),window.limboCore?.events&&window.limboCore.events.emit("cropperError",{error:e,assetId:T?.id,instanceId:s}),console.error("Cropper error:",e)},deleting:K,onVariantCreated:(e,t)=>{ae(e),ne()},onUpload:oe,uploading:U,cropperConfig:d}),"cropper"===$&&!T&&("crop-only"===r?F.jsxs("div",{children:[U&&F.jsx(ul,{text:"Subiendo archivo..."}),B&&F.jsxs(Ge,{variant:"danger",toast:!0,onClose:V,children:["Error al subir archivo: ",B]}),F.jsx(Ct,{onSelect:ce,onVideoSelect:ue,disabled:U,apiKey:e,prod:t,allowedCategories:m,resolvedAccept:S,returnConfig:p,folderConfig:b,selectedFolder:x,onFolderChange:w})]}):F.jsxs("div",{className:"limbo-empty-state lb:flex lb:flex-col lb:items-center lb:justify-center lb:py-12 lb:px-6 lb:text-center",children:[F.jsx("div",{className:"lb:text-gray-400 lb:mb-4",children:F.jsx("svg",{className:"lb:w-16 lb:h-16 lb:mx-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:F.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),F.jsx("p",{className:"lb:text-gray-600 lb:mb-4",children:"Selecciona una imagen de la galería para comenzar a recortar."})]})),F.jsx(yl,{}),F.jsx(dl,{isOpen:D,onClose:O})]})}(()=>{try{const e=sessionStorage.getItem(pl);if(e){const t=JSON.parse(e),n=Date.now();Object.entries(t).forEach(([e,t])=>{t.timestamp&&n-t.timestamp<hl&&ml.set(e,t)})}}catch{}})();class xl{constructor(e,t,n,l){this.id=e,this.config=t,this.eventManager=n,this.modalManager=l,this.root=null,this.container=null,this.modal=null,this.mounted=!1,this.destroyed=!1,this.button=null,this._validateConfig(),this._initialize()}_initialize(){"embed"===this.config.mode?this.mount():"button"===this.config.mode&&this._createButton(),this._emitDOMEvent("ready",{instance:this,config:this.config,timestamp:Date.now()})}mount(){if(this.mounted||this.destroyed)return this;if(this.container=this._resolveContainer(),!this.container)return this.eventManager.emit("error",{instanceId:this.id,error:"Container not found"}),this;try{this.root=D.createRoot(this.container),this.root.render(this._renderApp()),this.mounted=!0,this.eventManager.emit("ready",{instance:this})}catch(e){this.eventManager.emit("error",{instanceId:this.id,error:e.message})}return this}unmount(){return this.mounted?(this.root&&(this.root.unmount(),this.root=null),"button"===this.config.mode&&this.button,this.mounted=!1,this):this}open(){return"modal"!==this.config.mode&&"button"!==this.config.mode||(this.modal||this._createModal(),this.modal&&!this.modal.isOpened()&&(this.modal.open(),this.eventManager.emit("modal:open",{instance:this}))),this}close(){return this.modal&&this.modal.isOpened()&&(this.eventManager?.emit("modal:close",{instance:this}),this.modal.close()),this}updateConfig(e){return this.config={...this.config,...e},this.mounted&&this.root.render(this._renderApp()),this.eventManager.emit("config:updated",{instance:this,newConfig:e}),this}destroy(){this.destroyed||(this.unmount(),this.modal&&(this.modal.destroy(),this.modal=null),this.button&&this.button.parentNode&&(this.button.parentNode.removeChild(this.button),this.button=null),this.eventManager.emit("destroy",{instance:this}),this.container=null,this.config=null,this.eventManager=null,this.modalManager=null,this.destroyed=!0)}getId(){return this.id}getMode(){return this.config.mode}isMounted(){return this.mounted}isDestroyed(){return this.destroyed}getContainer(){return this.container}getConfig(){return{...this.config}}isContainerInDOM(){return this.container&&document.contains(this.container)}_createModal(){if(this.modalManager&&"modal"===this.config.mode&&(this.modal=this.modalManager.createModal({title:this.config.title||"Limbo Image Manager",size:this.config.modalSize||"large",onOpen:()=>{const e={instance:this,mode:"modal",timestamp:Date.now()};this._emitDOMEvent("modal:open",e),this.config.callbacks?.onOpen&&this.config.callbacks.onOpen(e)},onClose:()=>{const e={instance:this,mode:"modal",timestamp:Date.now()};this._emitDOMEvent("modal:close",e),this.config.callbacks?.onClose&&this.config.callbacks.onClose(e),this.config.autoDestroy&&this.destroy()},onDestroy:()=>{this.modal=null}}),this.modal)){const e=this.modal.getBodyContainer();this.root=D.createRoot(e),this.root.render(this._renderApp()),this.mounted=!0}}_createButton(){if(this.container||(this.container=this._resolveContainer()),!this.container)return void this.eventManager.emit("error",{instanceId:this.id,error:"Container not found for button mode"});const e=document.createElement("button");e.type="button",e.className="limbo-trigger-button",e.textContent=this.config.buttonText||"Abrir Limbo",e.style.cssText="\n background: #001978;\n color: white;\n border: none;\n padding: 10px 20px;\n border-radius: 6px;\n cursor: pointer;\n font-family: inherit;\n font-size: 14px;\n font-weight: 500;\n transition: all 0.2s ease;\n ",e.addEventListener("mouseenter",()=>{e.style.backgroundColor="#334793",e.style.transform="translateY(-1px)"}),e.addEventListener("mouseleave",()=>{e.style.backgroundColor="#001978",e.style.transform="translateY(0)"}),e.addEventListener("click",()=>{this.open()}),this.container.appendChild(e),this.button=e,this.mounted=!0}_resolveContainer(){const{container:e}=this.config;return e?"string"==typeof e?document.querySelector(e):e instanceof Element?e:null:null}_renderApp(){return v.createElement("div",{id:`limbo-component-container-${this.id}`,className:"limbo-scope limbo-instance limbo-component-container-wrapper lb:h-full lb:w-full lb:py-2 lb:pb-0 lb:bg-white","data-limbo-id":this.id,"data-limbo-mode":this.config.mode,"data-limbo-version":"3.7.0","data-limbo-isolated":"true","aria-label":"Limbo Image Manager",role:"region"},v.createElement(vl,{apiKey:this.config.apiKey||null,publicKey:this.config.publicKey||null,token:this.config.token||null,prod:this.config.prod||!1,url:this.config.url,features:this.config.features,modeUI:this.config.modeUI||"full",ui:this.config.ui,callbacks:this._createCallbacks(),instanceId:this.id,authMode:this.config.authMode||(this.config.publicKey?"session":"manual"),_externalImage:this.config._externalImage||null,cropperConfig:this.config.cropper||null,allowedCategories:this.config.validation?.allowedCategories||null,accept:this.config.validation?.accept||null,returnConfig:this.config.returnConfig||null,folderConfig:this.config.folders||{include:[],exclude:[],includeNoFolder:!0}}))}_createCallbacks(){return{onSelect:e=>{const t=this.config?.callbacks?.onSelect,n=this._createStandardPayload(e,"select");t&&Promise.resolve(t(n)).catch(e=>{console.error("[LimboInstance] Error en onSelect callback:",e)}),this.destroyed||this._emitDOMEvent("select",n)},onUpload:e=>{const t=this.config?.callbacks?.onUpload,n=this._createStandardPayload(e,"upload");t&&Promise.resolve(t(n)).catch(e=>{console.error("[LimboInstance] Error en onUpload callback:",e)}),this.destroyed||this._emitDOMEvent("upload",n)},onError:e=>{const t=this.config?.callbacks?.onError,n={instance:this,error:{message:e.message||"Unknown error",code:e.code||"UNKNOWN",timestamp:Date.now()}};t&&t(n.error),this.destroyed||this._emitDOMEvent("error",n)},onClose:()=>{const e=this.config?.callbacks?.onClose,t={instance:this,timestamp:Date.now()};e&&e(),this.destroyed||this._emitDOMEvent("close",t)},onCropsSaved:e=>{console.log("[LimboInstance] onCropsSaved recibido:",e),console.log("[LimboInstance] this.config?.callbacks:",this.config?.callbacks);const t=this.config?.callbacks?.onCropsSaved;console.log("[LimboInstance] userCallback existe:",!!t);const n={instance:this,eventType:"cropsSaved",timestamp:Date.now(),instanceId:this.id,...e};if(console.log("[LimboInstance] payload.crops:",n.crops),t){console.log("[LimboInstance] Llamando userCallback onCropsSaved");try{t(n),console.log("[LimboInstance] userCallback ejecutado correctamente")}catch(l){console.error("[LimboInstance] Error en userCallback:",l)}}else console.warn("[LimboInstance] ⚠️ userCallback onCropsSaved NO existe");this.destroyed||this._emitDOMEvent("cropsSaved",n)},onCropperComplete:e=>{console.log("[LimboInstance] onCropperComplete recibido:",e);const t=this.config?.callbacks?.onCropperComplete,n={instance:this,eventType:"cropperComplete",timestamp:Date.now(),instanceId:this.id,...e};t&&(console.log("[LimboInstance] Llamando userCallback onCropperComplete"),t(n)),this.destroyed||this._emitDOMEvent("cropperComplete",n)}}}_createStandardPayload(e,t){const n={instance:this,eventType:t,timestamp:Date.now(),instanceId:this.id,mode:this.config?.mode,features:this.config?.features};return e&&(e.assetId||e.id?(n.assetId=e.assetId||e.id,n.variants=e.variants||[],n.master=e.master||{urlSigned:e.url||e.urlSigned,width:e.width,height:e.height,mime:e.mime||e.mimeType},n.fileName=e.fileName||e.name,n.mime=e.mime||e.mimeType,n.width=e.width,n.height=e.height,n.fileBlob=e.fileBlob||e.file,n.metadata={uploadedBy:e.uploadedBy,uploadedAt:e.uploadedAt||e.timestamp,size:e.size,...e.metadata}):Object.assign(n,e)),n}_emitDOMEvent(e,t){if(this.destroyed)return;const n=new CustomEvent(`limbo:${e}`,{detail:t,bubbles:!0,cancelable:!0});(this.getContainer()||document).dispatchEvent(n),this.eventManager?.emit(e,t)}_validateConfig(){const e=se();if(!(this.config.auth?.apiKey||this.config.auth?.publicKey||this.config.auth?.token||this.config.apiKey||this.config.publicKey||this.config.token||this.config.tokenProvider||this.config.auth?.tokenProvider||e.token||e.publicKey||e.tokenProvider))throw new Error(`LimboInstance ${this.id}: Authentication is required. Provide either auth.publicKey (recommended), auth.apiKey (for server-side only), token, or tokenProvider`);if((this.config.auth?.apiKey||this.config.apiKey)&&"undefined"!=typeof window&&console.warn("⚠️ SECURITY WARNING: API Key detected in client-side code.\nThis is a security risk! Use publicKey instead for client applications.\nAPI Keys should only be used in server-side environments."),!["embed","modal","button"].includes(this.config.mode))throw new Error(`LimboInstance ${this.id}: invalid mode ${this.config.mode}`);if("embed"===this.config.mode&&!this.config.container)throw new Error(`LimboInstance ${this.id}: container is required for embed mode`);if("button"===this.config.mode&&!this.config.container)throw new Error(`LimboInstance ${this.id}: container is required for button mode`)}}class wl{constructor(){this.instances=new Map,this.counter=0}create(e,t,n){const l="limbo-"+ ++this.counter,r=new xl(l,e,t,n);return this.instances.set(l,r),r}get(e){return this.instances.get(e)}getAll(){return Array.from(this.instances.values())}getActive(){return this.getAll().filter(e=>e.isMounted())}destroy(e){const t=this.instances.get(e);return!!t&&(t.destroy(),this.instances.delete(e),!0)}destroyAll(){this.instances.forEach(e=>e.destroy()),this.instances.clear()}cleanupOrphans(){const e=[];return this.instances.forEach((t,n)=>{t.isContainerInDOM()||e.push(n)}),e.forEach(e=>this.destroy(e)),e.length}getStats(){const e=this.getAll();return{total:e.length,active:e.filter(e=>e.isMounted()).length,embed:e.filter(e=>"embed"===e.getMode()).length,modal:e.filter(e=>"modal"===e.getMode()).length,button:e.filter(e=>"button"===e.getMode()).length}}}class kl{constructor(){this.config=null,this.instances=new Map,this.observer=null,this.initialized=!1}configure(e,t,n){return this.config={selector:e.selector||null,dataset:e.dataset||"data-limbo-input-file",return:e.return||e.returnType||"json",mode:e.mode||"modal",features:e.features||["gallery","upload","cropper"],crop:e.crop||"free",quality:e.quality||.9,format:e.format||"webp",modeUI:e.modeUI||"full",modalSize:e.modalSize||"fullscreen",theme:e.theme||"light",compact:e.compact||!1,maxSize:e.maxSize||"10MB",formats:e.formats||["jpg","jpeg","png","webp"],minWidth:e.minWidth||null,minHeight:e.minHeight||null,maxWidth:e.maxWidth||null,maxHeight:e.maxHeight||null,buttonText:e.buttonText||"Seleccionar archivo",buttonClass:e.buttonClass||"limbo-auto-button",buttonStyle:e.buttonStyle||"primary",showPreview:!1!==e.showPreview,allowMultiple:e.allowMultiple||!1,autoAssign:!1!==e.autoAssign,localCropsOnly:e.localCropsOnly||!1,...e},this.configManager=t,this.eventManager=n,this._initialize(),this}cleanup(){this.observer&&(this.observer.disconnect(),this.observer=null),this.instances.forEach(({input:e,button:t})=>{this._restoreInput(e,t)}),this.instances.clear(),this.config=null,this.initialized=!1}getStats(){return{configured:null!==this.config,totalInputs:this.instances.size,dataset:this.config?.dataset,returnType:this.config?.return}}_initialize(){this.initialized||(this._scanExistingInputs(),this._setupObserver(),this.initialized=!0,this.eventManager.emit("autoInputs:initialized",{config:this.config,inputsFound:this.instances.size}))}_scanExistingInputs(){const e=this.config.selector||`input[${this.config.dataset}]`;document.querySelectorAll(e).forEach(e=>this._processInput(e))}_processInput(e){const t=this._getInputId(e);if(this.instances.has(t))return;if(!this._validateInput(e))return;const n=this._createButton(e);this._hideInput(e),this._insertButton(e,n),this.instances.set(t,{input:e,button:n,config:this._getInputConfig(e)}),this.eventManager.emit("autoInputs:processed",{inputId:t,input:e,button:n})}_createButton(e){const t=document.createElement("button"),n=this._getInputConfig(e);t.type="button",t.textContent=n.buttonText||this.config.buttonText;const l=[this.config.buttonClass];return n.buttonClass&&n.buttonClass!==this.config.buttonClass&&l.push(n.buttonClass),t.className=l.join(" "),this._styleButton(t,n),this._attachButtonEvents(t,e),t.setAttribute("aria-label",n.buttonText||this.config.buttonText),t.setAttribute("data-limbo-trigger","true"),t.setAttribute("data-limbo-input-id",n.inputId),n.disabled&&(t.disabled=!0),t}_styleButton(e,t){const n=t.buttonStyle||this.config.buttonStyle,l=t.theme||this.config.theme,r=t.compact||this.config.compact,a={border:"none",borderRadius:"8px",cursor:"pointer",fontFamily:"inherit",fontSize:r?"12px":"14px",fontWeight:"500",transition:"all 0.2s ease",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:r?"6px 12px":"8px 16px",textDecoration:"none",userSelect:"none"},o={primary:{backgroundColor:"dark"===l?"#3b82f6":"#001978",color:"white",hoverBg:"dark"===l?"#2563eb":"#334793"},secondary:{backgroundColor:"dark"===l?"#374151":"#f3f4f6",color:"dark"===l?"#f9fafb":"#374151",border:"1px solid "+("dark"===l?"#4b5563":"#d1d5db"),hoverBg:"dark"===l?"#4b5563":"#e5e7eb"},outline:{backgroundColor:"transparent",color:"dark"===l?"#3b82f6":"#001978",border:"2px solid "+("dark"===l?"#3b82f6":"#001978"),hoverBg:"dark"===l?"#3b82f6":"#001978",hoverColor:"white"},ghost:{backgroundColor:"transparent",color:"dark"===l?"#f9fafb":"#374151",hoverBg:"dark"===l?"#374151":"#f3f4f6"}},i=o[n]||o.primary;Object.assign(e.style,{...a,...i});const s=i.backgroundColor,c=i.color;e.addEventListener("mouseenter",()=>{e.style.backgroundColor=i.hoverBg||i.backgroundColor,i.hoverColor&&(e.style.color=i.hoverColor),e.style.transform="translateY(-1px)",e.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.15)"}),e.addEventListener("mouseleave",()=>{e.style.backgroundColor=s,e.style.color=c,e.style.transform="translateY(0)",e.style.boxShadow="none"}),t.disabled&&(e.style.opacity="0.5",e.style.cursor="not-allowed")}_attachButtonEvents(e,t){e.addEventListener("click",e=>{e.preventDefault(),this._handleButtonClick(t)})}_handleButtonClick(e){const t=this._getInputConfig(e),n=this._createModalConfig(t);this.eventManager.emit("autoInputs:modalRequest",{input:e,config:n,callback:async t=>await this._handleImageSelection(e,t)})}async _handleImageSelection(e,t){const n=this._getInputConfig(e);let l=t;try{if(!t.original&&!t.images&&(t.id||t.assetId)){console.log("[AutoInputManager] 🔗 Selección directa detectada, obteniendo URL permanente...");const e=t.id||t.assetId;try{const n=await async function(e,t=!0,n=!0,l=0){try{const r=new URLSearchParams({include_variants:t.toString(),include_metadata:n.toString(),url_expires:l.toString()});return me(await ce({endpoint:`/assets/${e}?${r}`,method:"GET",basePath:ge,useJWT:!0}))}catch(r){throw fe(r)}}(e,!1,!1,!0);n?.result?.url?(console.log("[AutoInputManager] ✅ URL permanente obtenida:",n.result.url),l={original:{url:n.result.url,width:n.result.width||t.width,height:n.result.height||t.height,assetId:e},images:[]}):(console.warn("[AutoInputManager] ⚠️ No se pudo obtener URL permanente, usando URL temporal"),l={original:{url:t.url||t.path,width:t.width,height:t.height,assetId:e},images:[]})}catch(r){console.error("[AutoInputManager] Error obteniendo URL permanente:",r),l={original:{url:t.url||t.path,width:t.width,height:t.height,assetId:e},images:[]}}}const a=await this._formatImageData(l,n);console.log("[AutoInputManager] Valor formateado:",a),console.log("[AutoInputManager] Tipo de valor:",typeof a),!1!==n.autoAssign&&(e.value=a,console.log("[AutoInputManager] Valor asignado al input:",e.value)),this._updateButtonFeedback(e,l),e.dispatchEvent(new Event("change",{bubbles:!0})),e.dispatchEvent(new CustomEvent("limbo:resultReady",{detail:{imageData:l,input:e,value:a,config:n,assignment:{format:n.return,smartAssign:!1!==n.smartAssign,autoAssign:!1!==n.autoAssign},legacy:{imageData:l,formatted:this._createFormattedResult(l,n)}},bubbles:!0})),e.dispatchEvent(new CustomEvent("limbo:imageSelected",{detail:{imageData:l,input:e,value:a,config:n,formatted:this._createFormattedResult(l,n)},bubbles:!0})),this.eventManager.emit("autoInputs:imageSelected",{input:e,imageData:l,value:a,config:n})}catch(a){console.error("Error handling image selection:",a),e.dispatchEvent(new CustomEvent("limbo:error",{detail:{error:a.message,input:e,imageData:l,config:n},bubbles:!0})),this._handleImageSelectionLegacy(e,t)}}_updateButtonFeedback(e,t){const n=this._getInputId(e),l=this.instances.get(n);if(!l||!l.button)return;const r=l.button,a=r.nextElementSibling;a&&a.classList.contains("limbo-button-feedback")&&a.remove();const o=document.createElement("span");o.className="limbo-button-feedback",o.style.cssText="\n display: inline-flex;\n align-items: center;\n gap: 6px;\n margin-left: 8px;\n padding: 4px 8px;\n background: #10b981;\n color: white;\n border-radius: 6px;\n font-size: 12px;\n font-weight: 500;\n animation: limbo-fade-in 0.3s ease-out;\n ";const i=t.images&&t.images.length>0,s=i?t.images.length:0;o.innerHTML=i?`\n <svg width="14" height="14" viewBox="0 0 20 20" fill="currentColor">\n <path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd"/>\n </svg>\n <span>${s} recorte${1!==s?"s":""} configurado${1!==s?"s":""}</span>\n `:'\n <svg width="14" height="14" viewBox="0 0 20 20" fill="currentColor">\n <path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd"/>\n </svg>\n <span>Archivo seleccionado</span>\n ',r.parentNode.insertBefore(o,r.nextSibling);let c=r.parentNode.querySelector(".limbo-powered-by");c||(c=document.createElement("div"),c.className="limbo-powered-by",c.innerHTML='<span style="display:block;margin-top:2px;font-size:10px;color:#aaa;text-align:left;font-family:inherit;opacity:0.7;">Powered by <b>Limbo</b></span>',r.parentNode.insertBefore(c,o.nextSibling)),r.style.backgroundColor="#10b981",r.textContent="Cambiar archivo"}async _handleImageSelectionLegacy(e,t){const n=this._getInputConfig(e),l=await this._formatImageData(t,n);!1!==n.autoAssign&&(e.value=l),e.dispatchEvent(new Event("change",{bubbles:!0})),e.dispatchEvent(new CustomEvent("limbo:imageSelected",{detail:{imageData:t,input:e,value:l,config:n,formatted:this._createFormattedResult(t,n)},bubbles:!0})),this.eventManager.emit("autoInputs:imageSelected",{input:e,imageData:t,value:l,config:n})}_createFormattedResult(e,t){return{url:e.url||e.path||"",base64:e.base64||e.dataUrl||"",assetId:e.assetId||e.id||"",fileName:e.fileName||e.filename||"",object:{url:e.url||e.path,assetId:e.assetId||e.id,fileName:e.fileName||e.filename,mime:e.mime||e.mime_type,width:e.width,height:e.height,size:e.size||e.file_size,created:e.created_at||e.created,metadata:e.metadata||{}},json:JSON.stringify({url:e.url||e.path,assetId:e.assetId||e.id,fileName:e.fileName||e.filename,mime:e.mime||e.mime_type,width:e.width,height:e.height,size:e.size||e.file_size}),metadata:{width:e.width,height:e.height,size:e.size||e.file_size,format:e.format||e.mime_type,quality:t.quality||this.config.quality,aspectRatio:e.width&&e.height?e.width/e.height:null}}}async _formatImageData(e,t=null){const n=(t||{}).return||this.config.return||"json",l=void 0!==e.original;switch(n){case"url":return l?e.images?.[0]?.url||e.original?.url||"":e.url||e.path||"";case"base64":return e.base64||e.dataUrl||"";case"assetId":return l?e.original?.assetId||"":e.assetId||e.id||"";case"fileName":return e.fileName||e.filename||"";default:try{if(l){const t={original:e.original?{url:e.original.url||e.original.urlSigned,width:e.original.width,height:e.original.height,assetId:e.original.assetId||e.original.id}:null,images:Array.isArray(e.images)?e.images.map(e=>{const t={url:e.url||e.urlSigned,width:e.width,height:e.height,name:e.name||e.filename||e.label};return e.cropState&&(t.cropState={selectorState:e.cropState.selectorState||null,imageTransform:e.cropState.imageTransform||null,flipState:e.cropState.flipState||null}),t}):[]};console.log("[AutoInputManager] Datos limpios para JSON:",t);const n=JSON.stringify(t);return console.log("[AutoInputManager] JSON generado:",n),n}const t={original:{url:e.url||e.path,width:e.width,height:e.height,assetId:e.assetId||e.id}};return console.log("[AutoInputManager] Datos legacy para JSON:",t),JSON.stringify(t)}catch(r){return console.error("[AutoInputManager] Error al serializar JSON:",r),console.error("[AutoInputManager] imageData problemático:",e),"{}"}}}_createModalConfig(e){return{mode:e.mode||this.config.mode||"modal",modeUI:e.modeUI||this.config.modeUI||"full",features:e.features||this.config.features,modalSize:e.modalSize||this.config.modalSize||"fullscreen",title:e.description||this.config.title||"Seleccionar archivo",cropper:this._getCropperConfig(e),ui:{showActions:this._getUIActions(e),hideActions:[],showTabs:this._shouldShowTabs(e),theme:e.theme||this.config.theme,compact:e.compact||this.config.compact,showPreview:void 0!==e.showPreview?e.showPreview:this.config.showPreview},validation:{accept:e.accept||null,maxSize:e.maxSize||this.config.maxSize,formats:e.formats||this.config.formats,minWidth:e.minWidth||this.config.minWidth,minHeight:e.minHeight||this.config.minHeight,maxWidth:e.maxWidth||this.config.maxWidth,maxHeight:e.maxHeight||this.config.maxHeight,required:e.required||!1},behavior:{allowMultiple:e.allowMultiple||this.config.allowMultiple,closeOnSelect:!0,autoAssign:void 0!==e.autoAssign?e.autoAssign:this.config.autoAssign,allowSelectNew:!1!==e.allowSelectNew},initialImageUrl:e.initialImageUrl||null,existingCrops:e.existingCrops||null,existingData:e.existingData||null,returnConfig:{format:e.return||this.config.return,quality:e.quality||this.config.quality,outputFormat:e.format||this.config.format},inputMeta:{inputId:e.inputId,inputName:e.inputName,inputType:e.inputType,placeholder:e.placeholder}}}_getCropperConfig(e){const t=e.crop||this.config.crop,n={quality:e.quality||this.config.quality,format:e.format||this.config.format,mandatoryCrops:e.mandatoryCrops||[],allowAdditionalCrops:!1!==e.allowAdditionalCrops,maxCrops:e.maxCrops||null,localCropsOnly:e.localCropsOnly??this.config.localCropsOnly??!1,existingCrops:e.existingCrops||null};if(e.mandatoryCrops&&e.mandatoryCrops.length>0)return{...n,aspectRatio:null};if(!t||"none"===t||"false"===t)return null;if("free"===t)return{...n,aspectRatio:null};const l={"1:1":1,"16:9":16/9,"4:3":4/3,"3:2":1.5,"2:1":2,square:1,landscape:16/9,portrait:3/4};if(l[t])return{...n,aspectRatio:l[t],minCropBoxWidth:e.minWidth||this.config.minWidth,minCropBoxHeight:e.minHeight||this.config.minHeight};if("string"==typeof t&&t.includes(":")){const[e,l]=t.split(":").map(Number);if(!isNaN(e)&&!isNaN(l)&&0!==l)return{...n,aspectRatio:e/l}}const r=parseFloat(t);return!isNaN(r)&&r>0?{...n,aspectRatio:r}:"object"==typeof t?{...n,...t}:null}_shouldShowTabs(e){const t=e.modeUI||this.config.modeUI||"full",n=e.features||this.config.features;return!["gallery-only","upload-only","crop-only","ia-only"].includes(t)&&(n&&n.length>1)}_getUIActions(e){const t=e.modeUI||this.config.modeUI||"full",n=e.features||this.config.features;let l=[];switch(t){case"gallery-only":case"upload-only":l=["select"];break;case"crop-only":l=["select","crop"];break;default:l=["select"],n.includes("cropper")&&l.push("crop"),n.includes("gallery")&&(l.push("download","copy"),this.config.allowDelete&&l.push("delete"))}return l}_getInputId(e){if(e.id)return e.id;if(e.name)return e.name;let t=e.getAttribute("data-limbo-uid");return t||(t=`limbo-auto-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,e.setAttribute("data-limbo-uid",t)),t}_validateInput(e){return e instanceof HTMLInputElement}_getInputConfig(e){const t=e=>e?e.split(",").map(e=>e.trim()):null,n=e=>{if(!e)return null;const t=e.match(/^(\d+(?:\.\d+)?)(MB|KB|B)?$/i);if(!t)return null;const n=parseFloat(t[1]);switch((t[2]||"B").toUpperCase()){case"MB":return 1024*n*1024;case"KB":return 1024*n;default:return n}},l=(e,t=!1)=>null===e?t:"true"===e||"1"===e||""===e,r=e=>e?parseFloat(e):null,a=e=>{if(!e)return null;try{return JSON.parse(e)}catch(t){return console.warn("[Limbo AutoInputManager] Error parsing JSON attribute:",t),null}},o=a(e.dataset.mandatorycrops)||a(e.dataset.mandatoryCrops)||a(e.getAttribute("data-mandatory-crops"))||a(e.getAttribute("data-limbo-mandatory-crops"))||null;return{return:e.dataset.returntype||e.getAttribute("data-limbo-return")||this.config.return,mode:e.dataset.mode||e.getAttribute("data-limbo-mode")||this.config.mode,features:t(e.dataset.features)||t(e.getAttribute("data-limbo-features"))||this.config.features,crop:e.dataset.crop||e.getAttribute("data-limbo-crop")||this.config.crop,quality:r(e.dataset.quality)||r(e.getAttribute("data-limbo-quality"))||this.config.quality,format:e.dataset.format||e.getAttribute("data-limbo-format")||this.config.format,modeUI:e.dataset.modeui||e.dataset.modeUI||e.getAttribute("data-limbo-mode-ui")||this.config.modeUI,modalSize:e.dataset.modalsize||e.getAttribute("data-limbo-modal-size")||this.config.modalSize,theme:e.dataset.theme||e.getAttribute("data-limbo-theme")||this.config.theme,compact:l(e.dataset.compact,null)??l(e.getAttribute("data-limbo-compact"),this.config.compact),maxSize:n(e.getAttribute("data-limbo-max-size"))||n(this.config.maxSize),formats:t(e.getAttribute("data-limbo-formats"))||this.config.formats,minWidth:r(e.getAttribute("data-limbo-min-width"))||this.config.minWidth,minHeight:r(e.getAttribute("data-limbo-min-height"))||this.config.minHeight,maxWidth:r(e.getAttribute("data-limbo-max-width"))||this.config.maxWidth,maxHeight:r(e.getAttribute("data-limbo-max-height"))||this.config.maxHeight,buttonText:e.dataset.buttontext||e.getAttribute("data-limbo-button-text")||this.config.buttonText,buttonStyle:e.dataset.buttonstyle||e.getAttribute("data-limbo-button-style")||this.config.buttonStyle,buttonClass:e.dataset.buttonclass||e.getAttribute("data-limbo-button-class")||this.config.buttonClass,showPreview:l(e.getAttribute("data-limbo-show-preview"),this.config.showPreview),allowMultiple:l(e.getAttribute("data-limbo-allow-multiple"),this.config.allowMultiple),autoAssign:l(e.getAttribute("data-limbo-auto-assign"),this.config.autoAssign),placeholder:e.getAttribute("data-limbo-placeholder"),description:e.getAttribute("data-limbo-description"),required:l(e.getAttribute("data-limbo-required"),!1),disabled:l(e.getAttribute("data-limbo-disabled"),!1),inputId:this._getInputId(e),inputName:e.name,inputType:e.type,mandatoryCrops:o,allowAdditionalCrops:l(e.dataset.allowadditionalcrops,null)??l(e.getAttribute("data-limbo-allow-additional-crops"),!0),maxCrops:r(e.dataset.maxcrops)||r(e.getAttribute("data-limbo-max-crops"))||null,accept:e.dataset.accept||e.getAttribute("data-limbo-accept")||null,allowSelectNew:l(e.dataset.allowselectnew,null)??l(e.getAttribute("data-limbo-allow-select-new"),!0),...this._parseExistingInputValue(e.value)}}_parseExistingInputValue(e){if(!e||""===e.trim())return{initialImageUrl:null,existingCrops:null,existingData:null};try{const t=JSON.parse(e);return t.original&&t.original.url?(console.log("[AutoInputManager] Valor existente parseado:",t),{initialImageUrl:t.original.url,existingCrops:t.images||null,existingData:t}):t.url?{initialImageUrl:t.url,existingCrops:null,existingData:t}:{initialImageUrl:null,existingCrops:null,existingData:t}}catch(t){return e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")?{initialImageUrl:e,existingCrops:null,existingData:null}:{initialImageUrl:null,existingCrops:null,existingData:null}}}_generateInputId(){return`limbo-auto-input-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}_hideInput(e){e.style.display="none"}_insertButton(e,t){e.parentNode.insertBefore(t,e.nextSibling)}_restoreInput(e,t){e.style.display="",t&&t.parentNode&&t.parentNode.removeChild(t)}_setupObserver(){this.observer=new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&this._scanNodeForInputs(e)})})}),this.observer.observe(document.body,{childList:!0,subtree:!0})}_scanNodeForInputs(e){const t=this.config.selector||`input[${this.config.dataset}]`;e.matches&&e.matches(t)&&this._processInput(e);const n=e.querySelectorAll&&e.querySelectorAll(t);n&&n.forEach(e=>this._processInput(e))}}class Cl{constructor(){this.listeners=new Map}emit(e,t={}){this._emitDOMEvent(e,t),this._executeListeners(e,t)}on(e,t){return this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t),()=>this.off(e,t)}off(e,t){const n=this.listeners.get(e);if(n){const e=n.indexOf(t);e>-1&&n.splice(e,1)}}cleanup(){this.listeners.clear()}_emitDOMEvent(e,t){const n=new CustomEvent(`limbo:${e}`,{detail:{...t,timestamp:Date.now()},bubbles:!0,cancelable:!0});(t.instance?.getContainer()||document).dispatchEvent(n)}_executeListeners(e,t){const n=this.listeners.get(e);n&&n.forEach(n=>{try{n(t)}catch(l){console.error(`Error executing listener for ${e}:`,l)}})}getStats(){const e={};return this.listeners.forEach((t,n)=>{e[n]=t.length}),e}}class Sl{constructor(){this.activeModals=new Set,this.zIndexBase=1e4,this.focusableSelectors=["button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"]):not([disabled])',"a[href]"].join(", "),this.initialized=!1,this._initGlobalListeners()}createModal(e){const t=new jl(this._generateModalId(),e,this);return this.activeModals.add(t),t}closeModal(e){const t=this._findModal(e);return!!t&&(t.close(),!0)}closeAllModals(){this.activeModals.forEach(e=>e.close()),this.activeModals.clear()}getActiveModal(){return Array.from(this.activeModals).pop()||null}getStats(){return{active:this.activeModals.size,nextZIndex:this._getNextZIndex()}}_generateModalId(){return`limbo-modal-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}_findModal(e){return Array.from(this.activeModals).find(t=>t.getId()===e)}_getNextZIndex(){return this.zIndexBase+10*this.activeModals.size}_removeModal(e){this.activeModals.delete(e),window.limboCore?.events&&window.limboCore.events.emit("modal:closed",{modalId:e.getId(),remainingModals:this.activeModals.size})}_handleGlobalKeydown(e){const t=this.getActiveModal();t&&("Escape"===e.key&&(e.preventDefault(),t.close()),"Tab"===e.key&&this._handleTabTrap(e,t))}_handleTabTrap(e,t){const n=t.getFocusableElements();if(0===n.length)return;const l=n[0],r=n[n.length-1];e.shiftKey?document.activeElement===l&&(e.preventDefault(),r.focus()):document.activeElement===r&&(e.preventDefault(),l.focus())}_initGlobalListeners(){this.initialized||(this.globalKeydownHandler=e=>this._handleGlobalKeydown(e),document.addEventListener("keydown",this.globalKeydownHandler),this.initialized=!0)}destroy(){this.closeAllModals(),this.initialized&&this.globalKeydownHandler&&(document.removeEventListener("keydown",this.globalKeydownHandler),this.initialized=!1,this.globalKeydownHandler=null)}}class jl{constructor(e,t,n){this.id=e,this.config={title:t.title||"Limbo",content:t.content||null,showCloseButton:!1!==t.showCloseButton,backdrop:!1!==t.backdrop,keyboard:!1!==t.keyboard,focus:!1!==t.focus,animation:!1!==t.animation,size:t.size||"large",onOpen:t.onOpen||null,onClose:t.onClose||null,onDestroy:t.onDestroy||null,...t},this.manager=n,this.element=null,this.backdrop=null,this.isOpen=!1,this.previousFocus=null,this._create()}_create(){this._createBackdrop(),this._createModal(),this._attachEvents()}_createBackdrop(){this.config.backdrop&&(this.backdrop=document.createElement("div"),this.backdrop.className="limbo-modal-backdrop",this.backdrop.style.cssText=`\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.5);\n z-index: ${this.manager._getNextZIndex()};\n opacity: 0;\n transition: opacity 0.3s ease;\n `,this.backdrop.addEventListener("click",e=>{e.target===this.backdrop&&this.close()}))}_createModal(){this.element=document.createElement("div"),this.element.className=`limbo-scope limbo-modal limbo-modal--${this.config.size}`,this.element.id=this.id,this.element.role="dialog",this.element.setAttribute("aria-modal","true"),this.element.setAttribute("aria-labelledby",`${this.id}-title`),this.element.tabIndex=-1;const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),t={small:e?"width: 100%; height: 100%;":"max-width: 500px; min-height: 400px;",medium:e?"width: 100%; height: 100%;":"max-width: 800px; min-height: 500px;",large:e?"width: 100%; height: 100%;":"max-width: 1400px; min-height: 700px;",xlarge:e?"width: 100%; height: 100%;":"max-width: 95dvw; min-height: 85vh;",fullscreen:"width: 100%; height: 100%; max-width: 100%; max-height: 100%; border-radius: 0;"},n="fullscreen"===this.config.size,l=e||n?`\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n transform: ${e?"translateY(100%)":"scale(0.95)"};\n width: 100%;\n height: 100%;\n max-width: none;\n max-height: none;\n border-radius: 0;\n background: white;\n z-index: ${this.manager._getNextZIndex()+1};\n opacity: ${e?"1":"0"};\n transition: ${e?"transform":"all"} 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n overflow: hidden;\n display: flex;\n flex-direction: column;\n padding-top: env(safe-area-inset-top);\n padding-left: env(safe-area-inset-left);\n padding-right: env(safe-area-inset-right);\n padding-bottom: env(safe-area-inset-bottom);\n `:`\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%) scale(0.8);\n ${t[this.config.size]}\n width: 90%;\n max-height: 90vh;\n background: white;\n border-radius: 16px;\n box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);\n z-index: ${this.manager._getNextZIndex()+1};\n opacity: 0;\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n overflow: hidden;\n display: flex;\n flex-direction: column;\n `;this.element.style.cssText=l,this._createHeader(),this._createBody(),document.body.appendChild(this.backdrop),document.body.appendChild(this.element)}_createHeader(){const e=document.createElement("div");e.className="limbo-modal-header";const t=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);e.style.cssText=`\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: ${t?"16px 20px":"20px 24px"};\n border-bottom: 1px solid #e9ecef;\n background: #f8f9fa;\n ${t?"position: sticky; top: 0; z-index: 10;":""}\n min-height: ${t?"60px":"auto"};\n `;const n=document.createElement("h2");if(n.id=`${this.id}-title`,n.className="limbo-modal-title",n.textContent=this.config.title,n.style.cssText="\n margin: 0;\n font-size: 18px;\n font-weight: 600;\n color: #001978;\n flex: 1;\n margin-right: 16px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n ",e.appendChild(n),this.config.showCloseButton){const n=document.createElement("button");n.type="button",n.className="limbo-modal-close",n.innerHTML="✕",n.setAttribute("aria-label","Cerrar modal"),n.style.cssText=`\n background: none;\n border: none;\n font-size: ${t?"28px":"24px"};\n color: #6c757d;\n cursor: pointer;\n padding: ${t?"8px":"4px"};\n border-radius: 4px;\n transition: all 0.2s ease;\n min-width: ${t?"44px":"auto"};\n min-height: ${t?"44px":"auto"};\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n `,n.addEventListener("mouseenter",()=>{n.style.backgroundColor="#f8f9fa",n.style.color="#001978"}),n.addEventListener("mouseleave",()=>{n.style.backgroundColor="transparent",n.style.color="#6c757d"}),n.addEventListener("click",()=>this.close()),e.appendChild(n)}this.element.appendChild(e)}_createBody(){const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),t=document.createElement("div");t.className="limbo-modal-body",t.id=`${this.id}-body`,t.style.cssText=`\n flex: 1;\n overflow-y: auto;\n padding: 0;\n -webkit-overflow-scrolling: touch;\n ${e?"height: 100%; overscroll-behavior: contain;":""}\n `,this.config.content&&("string"==typeof this.config.content?t.innerHTML=this.config.content:this.config.content instanceof Element&&t.appendChild(this.config.content)),this.element.appendChild(t)}_attachEvents(){this._originalBodyOverflow=document.body.style.overflow}open(){if(this.isOpen)return this;window.limbo&&window.limbo.core&&window.limbo.core.keyboard?(window.limbo.core.keyboard.pushFocus(document.activeElement),window.limbo.core.keyboard.setActiveModal(this.element)):this.previousFocus=document.activeElement,document.body.style.overflow="hidden";const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),t="fullscreen"===this.config.size;return requestAnimationFrame(()=>{this.backdrop&&(this.backdrop.style.opacity="1"),this.element.style.opacity="1",this.element.style.transform=e?"translateY(0%)":t?"scale(1)":"translate(-50%, -50%) scale(1)"}),this.isOpen=!0,this.config.focus&&setTimeout(()=>{if(window.limbo&&window.limbo.core&&window.limbo.core.keyboard)window.limbo.core.keyboard.focusFirst(this.element);else{const e=this.getFocusableElements()[0];e&&e.focus()}},300),this.config.onOpen&&this.config.onOpen(this),this}close(){if(!this.isOpen)return this;const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),t="fullscreen"===this.config.size;return this.backdrop&&(this.backdrop.style.opacity="0"),this.element.style.opacity="0",this.element.style.transform=e?"translateY(100%)":t?"scale(0.95)":"translate(-50%, -50%) scale(0.8)",setTimeout(()=>{this._cleanup()},300),this.isOpen=!1,window.limbo&&window.limbo.core&&window.limbo.core.keyboard&&(window.limbo.core.keyboard.setActiveModal(null),window.limbo.core.keyboard.releaseFocus()),this.config.onClose&&this.config.onClose(this),this}destroy(){this.close(),this.manager._removeModal(this),this.config.onDestroy&&this.config.onDestroy(this)}getBodyContainer(){return this.element.querySelector(".limbo-modal-body")}getFocusableElements(){return Array.from(this.element.querySelectorAll(this.manager.focusableSelectors))}getId(){return this.id}isOpened(){return this.isOpen}getConfig(){return{...this.config}}_cleanup(){document.body.style.overflow=this._originalBodyOverflow||"",this.previousFocus&&"function"==typeof this.previousFocus.focus&&this.previousFocus.focus(),this.backdrop&&this.backdrop.parentNode&&this.backdrop.parentNode.removeChild(this.backdrop),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}class Nl{constructor(){this.currentTheme=null,this.customThemes=new Map,this.config=this._getDefaultConfig(),this.isInitialized=!1,this.isCompactMode=!1,this.compactBreakpoint=null,this.compactObserver=null,this.mediaQueryObserver=null,this.mutationObserver=null,this.storageListener=null,this.themeCache=new Map,this.appliedStyles=new Set,this.changeCallbacks=new Set}_getDefaultConfig(){return{theme:{auto:!0,storage:!0,inherit:!0,smooth:!0,detectSystem:!0},compact:{enabled:!1,auto:!0,breakpoint:768,forceOnMobile:!0,persistPreference:!0},presets:{light:{name:"light",displayName:"Claro",variables:{"--limbo-primary":"#3b82f6","--limbo-primary-hover":"#2563eb","--limbo-primary-light":"#dbeafe","--limbo-primary-dark":"#1e40af","--limbo-bg-primary":"#ffffff","--limbo-bg-secondary":"#f8fafc","--limbo-bg-tertiary":"#f1f5f9","--limbo-bg-overlay":"rgba(0, 0, 0, 0.5)","--limbo-bg-card":"#ffffff","--limbo-bg-input":"#ffffff","--limbo-text-primary":"#0f172a","--limbo-text-secondary":"#475569","--limbo-text-tertiary":"#64748b","--limbo-text-inverse":"#ffffff","--limbo-text-muted":"#94a3b8","--limbo-border-light":"#e2e8f0","--limbo-border-medium":"#cbd5e1","--limbo-border-strong":"#94a3b8","--limbo-border-focus":"#3b82f6","--limbo-success":"#10b981","--limbo-success-light":"#d1fae5","--limbo-error":"#ef4444","--limbo-error-light":"#fee2e2","--limbo-warning":"#f59e0b","--limbo-warning-light":"#fef3c7","--limbo-info":"#3b82f6","--limbo-info-light":"#dbeafe","--limbo-shadow-sm":"0 1px 2px 0 rgba(0, 0, 0, 0.05)","--limbo-shadow-md":"0 4px 6px -1px rgba(0, 0, 0, 0.1)","--limbo-shadow-lg":"0 10px 15px -3px rgba(0, 0, 0, 0.1)","--limbo-shadow-xl":"0 20px 25px -5px rgba(0, 0, 0, 0.1)","--limbo-radius-sm":"4px","--limbo-radius-md":"6px","--limbo-radius-lg":"8px","--limbo-radius-xl":"12px","--limbo-font-family":"system-ui, -apple-system, sans-serif","--limbo-font-size-xs":"12px","--limbo-font-size-sm":"14px","--limbo-font-size-md":"16px","--limbo-font-size-lg":"18px","--limbo-font-size-xl":"20px","--limbo-z-dropdown":"1000","--limbo-z-sticky":"1020","--limbo-z-fixed":"1030","--limbo-z-modal":"1050","--limbo-z-tooltip":"1070","--limbo-transition-fast":"150ms cubic-bezier(0.4, 0, 0.2, 1)","--limbo-transition-normal":"300ms cubic-bezier(0.4, 0, 0.2, 1)","--limbo-transition-slow":"500ms cubic-bezier(0.4, 0, 0.2, 1)","--limbo-spacing-compact":"0.5rem","--limbo-spacing-compact-sm":"0.25rem","--limbo-spacing-compact-lg":"0.75rem","--limbo-font-size-compact-xs":"11px","--limbo-font-size-compact-sm":"12px","--limbo-font-size-compact-md":"14px","--limbo-font-size-compact-lg":"16px","--limbo-radius-compact":"4px","--limbo-radius-compact-sm":"3px","--limbo-radius-compact-lg":"6px","--limbo-button-height-compact":"32px","--limbo-input-height-compact":"36px","--limbo-modal-padding-compact":"12px","--limbo-card-padding-compact":"12px","--limbo-gap-compact":"8px","--limbo-gap-compact-sm":"4px","--limbo-gap-compact-lg":"12px"}},dark:{name:"dark",displayName:"Oscuro",variables:{"--limbo-primary":"#60a5fa","--limbo-primary-hover":"#3b82f6","--limbo-primary-light":"#1e293b","--limbo-primary-dark":"#93c5fd","--limbo-bg-primary":"#0f172a","--limbo-bg-secondary":"#1e293b","--limbo-bg-tertiary":"#334155","--limbo-bg-overlay":"rgba(0, 0, 0, 0.8)","--limbo-bg-card":"#1e293b","--limbo-bg-input":"#334155","--limbo-text-primary":"#f8fafc","--limbo-text-secondary":"#cbd5e1","--limbo-text-tertiary":"#94a3b8","--limbo-text-inverse":"#0f172a","--limbo-text-muted":"#64748b","--limbo-border-light":"#334155","--limbo-border-medium":"#475569","--limbo-border-strong":"#64748b","--limbo-border-focus":"#60a5fa","--limbo-success":"#34d399","--limbo-success-light":"#064e3b","--limbo-error":"#f87171","--limbo-error-light":"#7f1d1d","--limbo-warning":"#fbbf24","--limbo-warning-light":"#78350f","--limbo-info":"#60a5fa","--limbo-info-light":"#1e3a8a","--limbo-shadow-sm":"0 1px 2px 0 rgba(0, 0, 0, 0.2)","--limbo-shadow-md":"0 4px 6px -1px rgba(0, 0, 0, 0.3)","--limbo-shadow-lg":"0 10px 15px -3px rgba(0, 0, 0, 0.4)","--limbo-shadow-xl":"0 20px 25px -5px rgba(0, 0, 0, 0.5)","--limbo-radius-sm":"4px","--limbo-radius-md":"6px","--limbo-radius-lg":"8px","--limbo-radius-xl":"12px","--limbo-font-family":"system-ui, -apple-system, sans-serif","--limbo-font-size-xs":"12px","--limbo-font-size-sm":"14px","--limbo-font-size-md":"16px","--limbo-font-size-lg":"18px","--limbo-font-size-xl":"20px","--limbo-z-dropdown":"1000","--limbo-z-sticky":"1020","--limbo-z-fixed":"1030","--limbo-z-modal":"1050","--limbo-z-tooltip":"1070","--limbo-transition-fast":"150ms cubic-bezier(0.4, 0, 0.2, 1)","--limbo-transition-normal":"300ms cubic-bezier(0.4, 0, 0.2, 1)","--limbo-transition-slow":"500ms cubic-bezier(0.4, 0, 0.2, 1)","--limbo-spacing-compact":"0.5rem","--limbo-spacing-compact-sm":"0.25rem","--limbo-spacing-compact-lg":"0.75rem","--limbo-font-size-compact-xs":"11px","--limbo-font-size-compact-sm":"12px","--limbo-font-size-compact-md":"14px","--limbo-font-size-compact-lg":"16px","--limbo-radius-compact":"4px","--limbo-radius-compact-sm":"3px","--limbo-radius-compact-lg":"6px","--limbo-button-height-compact":"32px","--limbo-input-height-compact":"36px","--limbo-modal-padding-compact":"12px","--limbo-card-padding-compact":"12px","--limbo-gap-compact":"8px","--limbo-gap-compact-sm":"4px","--limbo-gap-compact-lg":"12px"}},auto:{name:"auto",displayName:"Automático",variables:{}}},inheritance:{portalSelectors:["body","[data-theme]",".theme-light",".theme-dark",".light-theme",".dark-theme"],variablePrefix:"--",fallbackTheme:"light"},transitions:{duration:"300ms",easing:"cubic-bezier(0.4, 0, 0.2, 1)",properties:["background-color","border-color","color","fill","stroke","box-shadow"]}}}initialize(e={}){this.isInitialized?console.warn("ThemeManager already initialized"):(this.config=this._deepMerge(this.config,e),this._loadCustomThemes(),this.config.theme.inherit&&this._inheritPortalTheme(),this._applyInitialTheme(),this._applyInitialCompactMode(),this._setupObservers(),this._injectBaseStyles(),this.isInitialized=!0)}_injectBaseStyles(){if(document.getElementById("limbo-theme-styles"))return;const e=`\n :root {\n /* Variables de transición para cambios de tema */\n color-scheme: light dark;\n }\n \n [data-limbo-theme] {\n transition: ${this.config.transitions.properties.map(e=>`${e} ${this.config.transitions.duration} ${this.config.transitions.easing}`).join(", ")};\n }\n \n /* Clases de utilidad para temas */\n .limbo-theme-light {\n color-scheme: light;\n }\n \n .limbo-theme-dark {\n color-scheme: dark;\n }\n \n .limbo-theme-auto {\n color-scheme: light dark;\n }\n \n /* Estilos para elementos del componente con variables CSS */\n .limbo-component {\n background-color: var(--limbo-bg-primary);\n color: var(--limbo-text-primary);\n border-color: var(--limbo-border-light);\n border-radius: var(--limbo-radius-md);\n font-family: var(--limbo-font-family);\n font-size: var(--limbo-font-size-md);\n transition: var(--limbo-transition-normal);\n }\n \n .limbo-card {\n background-color: var(--limbo-bg-card);\n border: 1px solid var(--limbo-border-light);\n border-radius: var(--limbo-radius-lg);\n box-shadow: var(--limbo-shadow-md);\n color: var(--limbo-text-primary);\n }\n \n .limbo-input {\n background-color: var(--limbo-bg-input);\n border: 1px solid var(--limbo-border-medium);\n border-radius: var(--limbo-radius-md);\n color: var(--limbo-text-primary);\n font-family: var(--limbo-font-family);\n font-size: var(--limbo-font-size-md);\n transition: var(--limbo-transition-fast);\n }\n \n .limbo-input:focus {\n border-color: var(--limbo-border-focus);\n box-shadow: 0 0 0 3px var(--limbo-primary-light);\n outline: none;\n }\n \n .limbo-button {\n background-color: var(--limbo-primary);\n border: 1px solid var(--limbo-primary);\n border-radius: var(--limbo-radius-md);\n color: var(--limbo-text-inverse);\n font-family: var(--limbo-font-family);\n font-size: var(--limbo-font-size-md);\n transition: var(--limbo-transition-fast);\n cursor: pointer;\n }\n \n .limbo-button:hover {\n background-color: var(--limbo-primary-hover);\n border-color: var(--limbo-primary-hover);\n }\n \n .limbo-button.secondary {\n background-color: var(--limbo-bg-secondary);\n border-color: var(--limbo-border-medium);\n color: var(--limbo-text-primary);\n }\n \n .limbo-button.secondary:hover {\n background-color: var(--limbo-bg-tertiary);\n }\n \n /* Estados de feedback con variables */\n .limbo-state-success {\n background-color: var(--limbo-success-light);\n border-color: var(--limbo-success);\n color: var(--limbo-success);\n }\n \n .limbo-state-error {\n background-color: var(--limbo-error-light);\n border-color: var(--limbo-error);\n color: var(--limbo-error);\n }\n \n .limbo-state-warning {\n background-color: var(--limbo-warning-light);\n border-color: var(--limbo-warning);\n color: var(--limbo-warning);\n }\n \n .limbo-state-info {\n background-color: var(--limbo-info-light);\n border-color: var(--limbo-info);\n color: var(--limbo-info);\n }\n \n /* Overlay y modal con variables */\n .limbo-overlay {\n background-color: var(--limbo-bg-overlay);\n backdrop-filter: blur(4px);\n }\n \n .limbo-modal {\n background-color: var(--limbo-bg-card);\n border-radius: var(--limbo-radius-xl);\n box-shadow: var(--limbo-shadow-xl);\n color: var(--limbo-text-primary);\n }\n \n /* Responsive design con variables */\n @media (max-width: 640px) {\n .limbo-component {\n font-size: var(--limbo-font-size-sm);\n }\n }\n \n /* Modo reducido de movimiento */\n @media (prefers-reduced-motion: reduce) {\n [data-limbo-theme] {\n transition: none;\n }\n \n .limbo-component,\n .limbo-input,\n .limbo-button {\n transition: none;\n }\n }\n \n /* Esquemas de color automático */\n @media (prefers-color-scheme: dark) {\n :root:not([data-limbo-theme]) {\n color-scheme: dark;\n }\n }\n \n @media (prefers-color-scheme: light) {\n :root:not([data-limbo-theme]) {\n color-scheme: light;\n }\n }\n \n /* ===================================\n MODO COMPACTO - ESTILOS ESPECÍFICOS \n =================================== */\n \n /* Activación del modo compacto por atributo o clase */\n [data-limbo-compact="true"],\n .limbo-compact-mode {\n /* Componentes base más pequeños */\n --limbo-font-size-md: var(--limbo-font-size-compact-md);\n --limbo-font-size-sm: var(--limbo-font-size-compact-sm);\n --limbo-font-size-lg: var(--limbo-font-size-compact-lg);\n --limbo-spacing: var(--limbo-spacing-compact);\n --limbo-radius-md: var(--limbo-radius-compact);\n --limbo-gap: var(--limbo-gap-compact);\n }\n \n /* Botones compactos */\n [data-limbo-compact="true"] .limbo-button,\n .limbo-compact-mode .limbo-button {\n height: var(--limbo-button-height-compact);\n padding: var(--limbo-spacing-compact-sm) var(--limbo-spacing-compact);\n font-size: var(--limbo-font-size-compact-sm);\n border-radius: var(--limbo-radius-compact);\n min-width: auto;\n }\n \n /* Inputs compactos */\n [data-limbo-compact="true"] .limbo-input,\n .limbo-compact-mode .limbo-input {\n height: var(--limbo-input-height-compact);\n padding: var(--limbo-spacing-compact-sm) var(--limbo-spacing-compact);\n font-size: var(--limbo-font-size-compact-md);\n border-radius: var(--limbo-radius-compact);\n }\n \n /* Cards compactas */\n [data-limbo-compact="true"] .limbo-card,\n .limbo-compact-mode .limbo-card {\n padding: var(--limbo-card-padding-compact);\n border-radius: var(--limbo-radius-compact-lg);\n }\n \n /* Modales compactos */\n [data-limbo-compact="true"] .limbo-modal,\n .limbo-compact-mode .limbo-modal {\n padding: var(--limbo-modal-padding-compact);\n border-radius: var(--limbo-radius-compact-lg);\n max-width: 90vw;\n max-height: 90vh;\n }\n \n /* Tabs compactas */\n [data-limbo-compact="true"] .limbo-tabs,\n .limbo-compact-mode .limbo-tabs {\n gap: var(--limbo-gap-compact-sm);\n }\n \n [data-limbo-compact="true"] .limbo-tab,\n .limbo-compact-mode .limbo-tab {\n padding: var(--limbo-spacing-compact-sm) var(--limbo-spacing-compact);\n font-size: var(--limbo-font-size-compact-sm);\n border-radius: var(--limbo-radius-compact-sm);\n }\n \n /* Gallery compacta */\n [data-limbo-compact="true"] .limbo-gallery,\n .limbo-compact-mode .limbo-gallery {\n gap: var(--limbo-gap-compact-sm);\n }\n \n [data-limbo-compact="true"] .limbo-gallery-item,\n .limbo-compact-mode .limbo-gallery-item {\n border-radius: var(--limbo-radius-compact);\n min-height: 120px; /* Más pequeño para móviles */\n }\n \n /* Notificaciones compactas */\n [data-limbo-compact="true"] .limbo-notification,\n .limbo-compact-mode .limbo-notification {\n padding: var(--limbo-spacing-compact-sm) var(--limbo-spacing-compact);\n font-size: var(--limbo-font-size-compact-sm);\n border-radius: var(--limbo-radius-compact);\n }\n \n /* Progress indicators compactos */\n [data-limbo-compact="true"] .limbo-progress,\n .limbo-compact-mode .limbo-progress {\n height: 3px; /* Más delgado */\n }\n \n [data-limbo-compact="true"] .limbo-progress-circular,\n .limbo-compact-mode .limbo-progress-circular {\n width: 20px;\n height: 20px;\n }\n \n /* Auto-activación en pantallas pequeñas */\n @media (max-width: 768px) {\n :root[data-limbo-compact="auto"],\n .limbo-component[data-limbo-compact="auto"] {\n /* Aplicar automáticamente estilos compactos */\n --limbo-font-size-md: var(--limbo-font-size-compact-md);\n --limbo-font-size-sm: var(--limbo-font-size-compact-sm);\n --limbo-spacing: var(--limbo-spacing-compact);\n --limbo-radius-md: var(--limbo-radius-compact);\n --limbo-gap: var(--limbo-gap-compact);\n }\n \n /* Modal full-screen en móvil cuando es compacto */\n [data-limbo-compact="auto"] .limbo-modal,\n [data-limbo-compact="true"] .limbo-modal {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100vw;\n height: 100vh;\n max-width: 100vw;\n max-height: 100vh;\n border-radius: 0;\n margin: 0;\n }\n \n /* Tabs en accordion en móvil */\n [data-limbo-compact="auto"] .limbo-tabs,\n [data-limbo-compact="true"] .limbo-tabs {\n flex-direction: column;\n width: 100%;\n }\n \n /* Gallery de 2 columnas en móvil */\n [data-limbo-compact="auto"] .limbo-gallery,\n [data-limbo-compact="true"] .limbo-gallery {\n grid-template-columns: 1fr 1fr;\n gap: var(--limbo-gap-compact);\n }\n }\n \n /* Touch targets más grandes en móviles */\n @media (max-width: 768px) and (pointer: coarse) {\n [data-limbo-compact="auto"] .limbo-button,\n [data-limbo-compact="true"] .limbo-button {\n min-height: 44px; /* Tamaño mínimo de toque recomendado */\n padding: var(--limbo-spacing-compact) var(--limbo-spacing-compact-lg);\n }\n \n [data-limbo-compact="auto"] .limbo-tab,\n [data-limbo-compact="true"] .limbo-tab {\n min-height: 44px;\n }\n }\n `,t=document.createElement("style");t.id="limbo-theme-styles",t.textContent=e,document.head.appendChild(t)}applyTheme(e,t={}){const n=this._getTheme(e);if(!n)return console.warn(`Theme '${e}' not found`),!1;const l=this.currentTheme;return this._applyThemeVariables(n,t.scope),this._updateThemeAttributes(n.name),this.config.theme.storage&&!t.temporary&&this._saveThemePreference(n.name),this.currentTheme=n.name,this._triggerChangeCallbacks(n.name,l),!0}toggleTheme(e="light",t="dark"){const n=this.currentTheme===e?t:e;return this.applyTheme(n)}applyAutoTheme(){const e=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";return this.applyTheme(e)}registerTheme(e,t){const n={name:e,displayName:t.displayName||e,variables:t.variables||{},extends:t.extends||null,...t};if(n.extends){const e=this._getTheme(n.extends);e&&(n.variables={...e.variables,...n.variables})}return this.customThemes.set(e,n),this}removeTheme(e){if(this.config.presets[e])return console.warn(`Cannot remove predefined theme: ${e}`),!1;const t=this.customThemes.delete(e);return t&&this.currentTheme===e&&this.applyTheme(this.config.inheritance.fallbackTheme),t}getAvailableThemes(){const e=Object.keys(this.config.presets),t=Array.from(this.customThemes.keys());return{presets:e,custom:t,all:[...e,...t]}}getCurrentTheme(){return{name:this.currentTheme,theme:this._getTheme(this.currentTheme),isCustom:this.customThemes.has(this.currentTheme),variables:this._getCurrentVariables()}}enableCompactMode(e={}){const t={element:document.documentElement,persist:!0,...e};return t.element.setAttribute("data-limbo-compact","true"),t.element.classList.add("limbo-compact-mode"),this.isCompactMode=!0,t.persist&&this.config.compact.persistPreference&&this._saveCompactPreference(!0),this._triggerCompactChange(!0),this}disableCompactMode(e={}){const t={element:document.documentElement,persist:!0,...e};return t.element.setAttribute("data-limbo-compact","false"),t.element.classList.remove("limbo-compact-mode"),this.isCompactMode=!1,t.persist&&this.config.compact.persistPreference&&this._saveCompactPreference(!1),this._triggerCompactChange(!1),this}toggleCompactMode(e={}){return this.isCompactMode?this.disableCompactMode(e):this.enableCompactMode(e)}applyAutoCompactMode(){const e=this._shouldUseCompactMode();return e&&!this.isCompactMode?this.enableCompactMode({persist:!1}):!e&&this.isCompactMode&&this.disableCompactMode({persist:!1}),this}getCompactState(){return{isEnabled:this.isCompactMode,isAuto:this.config.compact.auto,breakpoint:this.config.compact.breakpoint,currentViewport:window.innerWidth,shouldBeCompact:this._shouldUseCompactMode()}}_shouldUseCompactMode(){if(!this.config.compact.auto)return this.config.compact.enabled;const e=window.innerWidth<=this.config.compact.breakpoint,t=/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),n="ontouchstart"in window||navigator.maxTouchPoints>0;return!(!this.config.compact.forceOnMobile||!t&&!n)||e}_saveCompactPreference(e){try{localStorage.setItem("limbo-compact-preference",e.toString())}catch(t){console.warn("Could not save compact preference:",t)}}_loadCompactPreference(){try{return"true"===localStorage.getItem("limbo-compact-preference")}catch(e){return console.warn("Could not load compact preference:",e),null}}_triggerCompactChange(e){this.changeCallbacks.forEach(t=>{try{t({type:"compact",isCompact:e,viewport:window.innerWidth,timestamp:Date.now()})}catch(n){console.error("Error in compact mode change callback:",n)}})}_inheritPortalTheme(){const e=this._detectPortalTheme();return e?(this.registerTheme("portal-inherited",e),"portal-inherited"):null}_detectPortalTheme(){const e={name:"portal-detected",displayName:"Tema del Portal",variables:{}};for(const t of this.config.inheritance.portalSelectors){const n=document.querySelector(t);if(n){const t=this._extractCSSVariables(n);Object.keys(t).length>0&&(e.variables={...e.variables,...t});const l=n.getAttribute("data-theme")||n.getAttribute("class")?.match(/theme-(\w+)/)||n.getAttribute("class")?.match(/(\w+)-theme/);l&&(e.detectedName=Array.isArray(l)?l[1]:l)}}return Object.keys(e.variables).length>0?e:null}_extractCSSVariables(e){const t={},n=getComputedStyle(e);["primary","primary-hover","primary-light","primary-dark","bg-primary","bg-secondary","bg-tertiary","bg-card","bg-input","text-primary","text-secondary","text-tertiary","text-inverse","border-light","border-medium","border-strong","border-focus","success","error","warning","info","shadow-sm","shadow-md","shadow-lg","shadow-xl","radius-sm","radius-md","radius-lg","radius-xl"].forEach(e=>{const l=`--limbo-${e}`,r=n.getPropertyValue(l).trim();r&&(t[l]=r)});return["--primary-color","--background-color","--text-color","--border-color","--accent-color","--surface-color"].forEach(e=>{const l=n.getPropertyValue(e).trim();if(l){const n=this._mapGenericToLimbo(e,l);n&&Object.assign(t,n)}}),t}_mapGenericToLimbo(e,t){return{"--primary-color":{"--limbo-primary":t},"--background-color":{"--limbo-bg-primary":t},"--text-color":{"--limbo-text-primary":t},"--border-color":{"--limbo-border-light":t},"--accent-color":{"--limbo-primary":t},"--surface-color":{"--limbo-bg-card":t}}[e]||null}_applyInitialTheme(){let e=this.config.inheritance.fallbackTheme;if(this.config.theme.storage){const t=this._loadThemePreference();t&&this._getTheme(t)&&(e=t)}const t=document.documentElement.getAttribute("data-limbo-theme");t&&this._getTheme(t)&&(e=t);const n=this._inheritPortalTheme();n&&(e=n),this.config.theme.auto&&"auto"===e&&(e=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),this.applyTheme(e,{temporary:!1})}_applyInitialCompactMode(){let e=!1;if(this.config.compact.persistPreference){const t=this._loadCompactPreference();null!==t&&(e=t)}const t=document.documentElement.getAttribute("data-limbo-compact");"true"===t?e=!0:"false"===t&&(e=!1),("auto"===t||this.config.compact.auto)&&(e=this._shouldUseCompactMode()),e?this.enableCompactMode({persist:!1}):this.disableCompactMode({persist:!1})}_applyThemeVariables(e,t=document.documentElement){const n="string"==typeof t?document.querySelector(t):t;n?(Object.entries(e.variables).forEach(([e,t])=>{n.style.setProperty(e,t),this.appliedStyles.add(`${n.tagName}:${e}`)}),this.themeCache.set(e.name,{theme:e,appliedAt:Date.now(),scope:n})):console.warn("Theme scope element not found")}_updateThemeAttributes(e){document.documentElement.setAttribute("data-limbo-theme",e),document.documentElement.classList.remove("limbo-theme-light","limbo-theme-dark","limbo-theme-auto"),document.documentElement.classList.add(`limbo-theme-${e}`),this._updateMetaThemeColor(e)}_updateMetaThemeColor(e){const t=this._getTheme(e);if(!t)return;const n=t.variables["--limbo-primary"]||"#3b82f6";let l=document.querySelector('meta[name="theme-color"]');l||(l=document.createElement("meta"),l.name="theme-color",document.head.appendChild(l)),l.content=n}_getTheme(e){return this.config.presets[e]?this.config.presets[e]:this.customThemes.has(e)?this.customThemes.get(e):null}_getCurrentVariables(){const e=this._getTheme(this.currentTheme);if(!e)return{};const t=getComputedStyle(document.documentElement),n={};return Object.keys(e.variables).forEach(e=>{n[e]=t.getPropertyValue(e).trim()}),n}_saveThemePreference(e){try{localStorage.setItem("limbo-theme-preference",e)}catch(t){console.warn("Could not save theme preference:",t)}}_loadThemePreference(){try{return localStorage.getItem("limbo-theme-preference")}catch(e){return console.warn("Could not load theme preference:",e),null}}_loadCustomThemes(){try{const e=localStorage.getItem("limbo-custom-themes");if(e){const t=JSON.parse(e);Object.entries(t).forEach(([e,t])=>{this.customThemes.set(e,t)})}}catch(e){console.warn("Could not load custom themes:",e)}}_saveCustomThemes(){try{const e=Object.fromEntries(this.customThemes);localStorage.setItem("limbo-custom-themes",JSON.stringify(e))}catch(e){console.warn("Could not save custom themes:",e)}}_setupObservers(){this.config.theme.detectSystem&&this._setupSystemObserver(),this.config.theme.storage&&this._setupStorageObserver(),this._setupMutationObserver(),this.config.compact.auto&&this._setupViewportObserver()}_setupSystemObserver(){const e=window.matchMedia("(prefers-color-scheme: dark)");e.addEventListener("change",e=>{if("auto"===this.currentTheme||this.config.theme.auto){const t=e.matches?"dark":"light";this.applyTheme(t,{temporary:!0})}}),this.mediaQueryObserver=e}_setupStorageObserver(){const e=e=>{"limbo-theme-preference"===e.key&&e.newValue!==this.currentTheme&&this._getTheme(e.newValue)&&this.applyTheme(e.newValue)};window.addEventListener("storage",e),this.storageListener=e}_setupMutationObserver(){const e=new MutationObserver(e=>{e.forEach(e=>{if("attributes"===e.type&&"data-limbo-theme"===e.attributeName){const t=e.target.getAttribute("data-limbo-theme");t&&t!==this.currentTheme&&this._getTheme(t)&&this.applyTheme(t)}})});e.observe(document.documentElement,{attributes:!0,attributeFilter:["data-limbo-theme"]}),this.mutationObserver=e}_setupViewportObserver(){const e=`(max-width: ${this.config.compact.breakpoint}px)`,t=window.matchMedia(e);t.addEventListener("change",()=>{("auto"===document.documentElement.getAttribute("data-limbo-compact")||this.config.compact.auto)&&this.applyAutoCompactMode()}),this.compactObserver=t,window.addEventListener("orientationchange",()=>{setTimeout(()=>{("auto"===document.documentElement.getAttribute("data-limbo-compact")||this.config.compact.auto)&&this.applyAutoCompactMode()},100)})}onThemeChange(e){return this.changeCallbacks.add(e),()=>this.changeCallbacks.delete(e)}_triggerChangeCallbacks(e,t){this.changeCallbacks.forEach(n=>{try{n({theme:e,previousTheme:t,themeData:this._getTheme(e),variables:this._getCurrentVariables()})}catch(l){console.error("Error in theme change callback:",l)}})}generateThemeFromColors(e,t){const n={name:e,displayName:e,variables:{}};t.primary&&(n.variables["--limbo-primary"]=t.primary,n.variables["--limbo-primary-hover"]=this._darkenColor(t.primary,10),n.variables["--limbo-primary-light"]=this._lightenColor(t.primary,40),n.variables["--limbo-primary-dark"]=this._darkenColor(t.primary,20)),t.background&&(n.variables["--limbo-bg-primary"]=t.background,n.variables["--limbo-bg-secondary"]=this._lightenColor(t.background,5),n.variables["--limbo-bg-tertiary"]=this._lightenColor(t.background,10),n.variables["--limbo-bg-card"]=t.background),t.text&&(n.variables["--limbo-text-primary"]=t.text,n.variables["--limbo-text-secondary"]=this._lightenColor(t.text,20),n.variables["--limbo-text-tertiary"]=this._lightenColor(t.text,40));const l=this._getTheme(this.config.inheritance.fallbackTheme);return l&&(n.variables={...l.variables,...n.variables}),this.registerTheme(e,n),n}_darkenColor(e,t){const n=parseInt(e.replace("#",""),16),l=Math.round(2.55*t),r=(n>>16)-l,a=(n>>8&255)-l,o=(255&n)-l;return"#"+(16777216+65536*(r<255?r<1?0:r:255)+256*(a<255?a<1?0:a:255)+(o<255?o<1?0:o:255)).toString(16).slice(1)}_lightenColor(e,t){const n=parseInt(e.replace("#",""),16),l=Math.round(2.55*t),r=(n>>16)+l,a=(n>>8&255)+l,o=(255&n)+l;return"#"+(16777216+65536*(r<255?r<1?0:r:255)+256*(a<255?a<1?0:a:255)+(o<255?o<1?0:o:255)).toString(16).slice(1)}_deepMerge(e,t){const n={...e};return Object.keys(t).forEach(l=>{t[l]&&"object"==typeof t[l]&&!Array.isArray(t[l])?n[l]=this._deepMerge(e[l]||{},t[l]):n[l]=t[l]}),n}getThemeInfo(){return{current:this.getCurrentTheme(),available:this.getAvailableThemes(),compact:this.getCompactState(),config:this.config,isInitialized:this.isInitialized,cache:{themes:this.themeCache.size,applied:this.appliedStyles.size},observers:{system:!!this.mediaQueryObserver,storage:!!this.storageListener,mutation:!!this.mutationObserver,viewport:!!this.compactObserver}}}debug(){return console.table(this.getThemeInfo()),this.getThemeInfo()}destroy(){this.mediaQueryObserver&&this.mediaQueryObserver.removeEventListener("change",this._setupSystemObserver),this.storageListener&&window.removeEventListener("storage",this.storageListener),this.mutationObserver&&this.mutationObserver.disconnect(),this.compactObserver&&this.compactObserver.removeEventListener("change",this._setupViewportObserver),this.changeCallbacks.clear(),this.themeCache.clear(),this.appliedStyles.clear(),this._saveCustomThemes();const e=document.getElementById("limbo-theme-styles");e&&e.remove(),this.isInitialized=!1}}const El=new class{constructor(){this.config=new u,this.instances=new wl,this.autoInputs=new kl,this.events=new Cl,this.modals=new Sl,this.theme=new Nl,this.containerQueryDetector=U,this._setupInternalListeners(),this._initializeContainerQueries()}configure(e){var t;return this.config.setGlobal(e),t={publicKey:e.publicKey,apiKey:e.apiKey,token:e.token,authMode:e.authMode||"manual",tokenProvider:e.tokenProvider,prod:Boolean(e.prod)||!1,mode:e.mode||"embed",callbacks:e.callbacks||null},oe={...oe,...t},oe.authMode||(oe.token?oe.authMode="manual":oe.authMode="session"),this.config}setToken(e){return function(e){oe.token=e}(e),this.config.setGlobal({token:e}),this}create(e){const t=this.config.merge(e);return this.instances.create(t,this.events,this.modals)}configureAutoInputs(e){return this.autoInputs.configure(e,this.config,this.events)}setTheme(e){return e&&(this.config.set("theme",e),this.theme.setTheme(e),this.events.emit("theme:changed",{theme:e})),this}getTheme(){return this.theme.getCurrentTheme()}scanAndActivate(e=null){const t=this.autoInputs.config?.dataset||"data-limbo-input-file",n=e||`[${t}]`,l=document.querySelectorAll(n);if(0===l.length)return{found:0,processed:0,skipped:0};let r=0,a=0;return l.forEach(e=>{try{this.autoInputs._processInput(e),r++}catch(t){console.warn(`⚠️ Limbo: Error procesando input ${e.id||e.name}:`,t),a++}}),this.events.emit("limbo:scanCompleted",{found:l.length,processed:r,skipped:a,inputs:Array.from(l)}),{found:l.length,processed:r,skipped:a}}_initializeContainerQueries(){this.containerQueryDetector.observeResize(),setTimeout(()=>{document.querySelectorAll(".limbo-component-container-wrapper").forEach(e=>{this.containerQueryDetector.applyResponsiveClasses(e)})},100)}rescan(e=document){const t=this.autoInputs.config?.dataset||"data-limbo-input-file",n=e.querySelectorAll(`[${t}]`);let l=0;return n.forEach(e=>{if(!this.autoInputs.instances.has(this.autoInputs._getInputId(e)))try{this.autoInputs._processInput(e),l++}catch(t){console.warn("⚠️ Limbo: Error procesando nuevo input:",t)}}),l}init(e){const t=this._mapLegacyOptions(e);return this.create(t)}getInstances(){return this.instances.getAll()}destroy(){this.instances.destroyAll(),this.autoInputs.cleanup(),this.events.cleanup(),this.theme.removeTheme()}_mapLegacyOptions(e){return{container:e.container||"#image-manager",mode:"embed",features:["gallery","upload","cropper"],apiKey:e.apiKey,prod:e.prod||!1,url:void 0===e.url||e.url}}_setupInternalListeners(){this.events.on("autoInputs:modalRequest",({config:e,callback:t,input:n})=>{this._handleAutoInputModalRequest({config:e,callback:t,input:n})})}_handleAutoInputModalRequest({config:e,callback:t,input:n}){const l=n,r=async n=>{let r={};if(n.crops&&n.crops.length>0){const e=n.asset||n.original;r.original={url:e?.url||e?.urlSigned||n.originalUrl,width:e?.width||n.originalWidth,height:e?.height||n.originalHeight,assetId:e?.id||n.assetId},r.images=n.crops.map(e=>({url:e.url||e.urlSigned,width:e.width,height:e.height,name:e.name||e.filename}))}else n.asset?r.original={url:n.asset.url||n.asset.urlSigned,width:n.asset.width,height:n.asset.height,assetId:n.asset.id}:n.master?.urlSigned||n.master?.url?r.original={url:n.master.urlSigned||n.master.url,width:n.master.width||n.width,height:n.master.height||n.height,assetId:n.assetId}:n.url||n.urlSigned?r.original={url:n.url||n.urlSigned,width:n.width,height:n.height,assetId:n.assetId||n.id}:(console.warn("[Limbo] handleResult: formato de datos no reconocido",n),r=n);if(l){var a=e?.returnConfig?.format||"json",o="";o="url"===a?r.images?.[0]?.url||r.original?.url||"":"assetId"===a?r.original?.assetId||"":JSON.stringify(r),l.value=o,l.dispatchEvent(new Event("change",{bubbles:!0})),console.log("[Limbo] ✅ Valor asignado al input:",l.value?.substring(0,80))}try{await t(r)}catch(i){}u.close()},a={...e,mode:"modal",autoDestroy:!0,interaction:{allowSelection:!0,allowCropping:!0,...e.interaction},callbacks:{onSelect:e=>{r(e)},onCropsSaved:e=>{r(e)},onCropperComplete:e=>{r(e)},onUpload:t=>{"upload-only"!==e.modeUI||e.features?.includes("cropper")||r(t)},onClose:()=>{}}},i=e.validation?.accept||null,s=i?o(i):null,c=!s||s.isAllTypes||s.includesImages;if(e.initialImageUrl&&c){const t=this._extractAssetIdFromUrl(e.initialImageUrl)||e.existingData?.original?.assetId||null;t&&(a._externalImage={url:e.initialImageUrl,filename:e.initialImageUrl.split("/").pop()?.split("?")[0]||"image.jpg",width:1920,height:1080,mime_type:"image/jpeg",id:t})}e.cropper&&(a.cropper=e.cropper),this.config.setGlobal({interaction:{allowSelection:!0,allowCropping:!0,...e.interaction}});const u=this.create(a);u.open()}_extractAssetIdFromUrl(e){if(!e)return null;try{const t=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,n=e.match(t);return n&&n.length>=2?n[1]:n&&1===n.length?n[0]:null}catch(t){return console.warn("Error extracting asset ID from URL:",t),null}}openGallery(e={}){const t=this.create({mode:"modal",modeUI:"gallery-only",features:["gallery"],autoDestroy:!0,modal:{title:e.title||"Seleccionar Imagen",size:e.size||"large"},validation:{accept:e.accept||null},callbacks:{onSelect:n=>{e.onSelect?.(n),!1!==e.autoClose&&t.close()}},...e});return t.open(),t}openUploader(e={}){const t=!1!==e.redirectToGallery?["upload","gallery"]:["upload"],n=this.create({mode:"modal",modeUI:!1!==e.redirectToGallery?"full":"upload-only",features:t,autoDestroy:!0,modal:{title:e.title||"Subir Imagen",size:e.size||"medium"},validation:{accept:e.accept||null},callbacks:{onUpload:t=>{e.onUpload?.(t),!1===e.autoClose||e.redirectToGallery||n.close()}},...e});return n.open(),n}openCropper(e,t={}){if(!e)throw new Error("Limbo.openCropper: imageUrl es requerido");const n={url:e,filename:t.filename||"image.jpg",width:t.width||1920,height:t.height||1080,mime_type:t.mimeType||"image/jpeg",id:t.assetId||`external-${Date.now()}`},l=this.create({mode:"modal",modeUI:"crop-only",features:["cropper"],autoDestroy:!0,modal:{title:t.title||"Recortar Imagen",size:"xlarge"},cropper:{mandatoryCrops:t.mandatoryCrops||[],allowCustomCrops:!1!==t.allowCustomCrops,enforceRequiredCrops:!1!==t.enforceRequiredCrops},callbacks:{onCropperComplete:e=>{t.onComplete?.(e),!1!==t.autoClose&&l.close()},onCropperCancelled:e=>{t.onCancelled?.(e),!1!==t.autoClose&&l.close()},onCropperError:e=>{t.onError?.(e)}},_externalImage:n,...t});return l.open(),l}createInlineGallery(e,t={}){return this.create({container:e,mode:"embed",modeUI:"gallery-only",features:["gallery"],validation:{accept:t.accept||null},callbacks:{onSelect:t.onSelect,onDelete:t.onDelete},...t})}createInlineUploader(e,t={}){return this.create({container:e,mode:"embed",modeUI:"upload-only",features:["upload"],validation:{accept:t.accept||null},callbacks:{onUpload:t.onUpload},...t})}createStandaloneCropper(e,t,n={}){if(!e)throw new Error("Limbo.createStandaloneCropper: container es requerido");if(!t)throw new Error("Limbo.createStandaloneCropper: imageUrl es requerido");const l={url:t,filename:n.filename||"image.jpg",width:n.width||1920,height:n.height||1080,mime_type:n.mimeType||"image/jpeg",id:n.assetId||`external-${Date.now()}`};return this.create({container:e,mode:"embed",modeUI:"crop-only",features:["cropper"],autoHideOnComplete:!1!==n.autoHideOnComplete,cropper:{mandatoryCrops:n.mandatoryCrops||[],allowCustomCrops:!1!==n.allowCustomCrops,enforceRequiredCrops:!1!==n.enforceRequiredCrops},callbacks:{onCropperComplete:n.onComplete,onCropperCancelled:n.onCancelled,onCropperError:n.onError},_externalImage:l,...n})}createFullSelector(e,t={}){return this.create({container:e,mode:t.mode||"embed",modeUI:"full",features:["gallery","upload","cropper"],validation:{accept:t.accept||null},callbacks:{onSelect:t.onSelect,onUpload:t.onUpload,onDelete:t.onDelete,onCropsSaved:t.onCropsSaved},...t})}};"undefined"!=typeof window&&(window.Limbo=El,window.limboCore=El);"undefined"!=typeof window&&document.querySelector("#root")&&(El.configure({prod:!1,publicKey:"pk_e464fd744106b7a8d63d453c4bd02582",authMode:"session"}),El.create({container:"#root",mode:"embed",modeUI:"full",features:["gallery","upload","cropper"],title:"Limbo Image Manager - Development",url:!0}),El.configureAutoInputs({dataset:"data-limbo-input-file",return:"json",features:["gallery","upload","cropper"],modeUI:"full",modalSize:"large",title:"Seleccionar archivo",crops:"free",allowDelete:!1})),e.LIMBO_BASE_URL=q,e.decodeHtmlEntities=H,e.default=El,e.extractImageUrl=G,e.isValidImageUrl=K,e.parseImageData=function(e,t={}){const{isProd:n=!1}=t;if(!e)return{original:null,images:[],url:""};try{const t=JSON.parse(H(e)),l=t.original?{...t.original,url:V(t.original.url,n)}:null,r=(t.images||[]).map(e=>({...e,url:V(e.url,n)}));return{original:l,images:r,url:r[0]?.url||l?.url||V(t.url,n)||""}}catch{return{original:null,images:[],url:V(e,n)}}},e.prepareImageFieldsForPreview=function(e,t={}){const{isProd:n=!1}=t;if(!e?.fields)return e;const l=e.fields.map(e=>{if("image"===e.type&&"string"==typeof e.example_value){const t=G(e.example_value,{isProd:n});return{...e,example_value:t||e.example_value}}return e});return{...e,fields:l}},e.resolveUrl=V,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
2
2
|
//# sourceMappingURL=limbo.umd.map
|