@dipusevilla/componentes-iu 1.1.32 → 1.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +2 -0
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -88,7 +88,7 @@ attempted value: ${i}
|
|
|
88
88
|
self.postMessage({ success: false, error: err.toString() });
|
|
89
89
|
}
|
|
90
90
|
};
|
|
91
|
-
`,d=new Blob([u],{type:"application/javascript"}),m=URL.createObjectURL(d),f=new Worker(m),h=setTimeout(()=>{f.terminate(),URL.revokeObjectURL(m),c(new Error("Timeout: La validación tardó demasiado."))},o);f.onmessage=p=>{clearTimeout(h),f.terminate(),URL.revokeObjectURL(m),p.data.success?i(p.data.result):(console.warn("Validation Script Error:",p.data.error),i("Error en script de validación"))},f.onerror=p=>{clearTimeout(h),f.terminate(),URL.revokeObjectURL(m),c(p)},f.postMessage({code:e,context:t,translations:l})})}const $M={fileUploader:{browse:"Document",dragDrop:"Drag your files here or click to browse",view:"View",remove:"Remove"},form:{fieldRequired:"Required field",invalidEmail:"Invalid email",submit:"Submit",sending:"Sending…",saveSuccess:"Saved successfully!",saveError:"There are errors in the form"},editor:{inspector:{field:"Field Inspector",tab:"Tab Inspector",section:"Section Inspector"},actions:{move:"Move",moveLeft:"Move left",moveRight:"Move right",add:"Add",addTab:"Tab to the right",addSection:"Add section",addRow:"Add row",addColumn:"Add column",delete:"Delete",deleteTab:"Delete tab",deleteColumn:"Remove last column",duplicate:"Duplicate",cancel:"Cancel"},confirmations:{deleteField:{title:"Delete field",message:"Are you sure you want to delete this field?"},deleteColumn:{title:"Delete column",message:"Are you sure you want to delete the last column? Fields it contains will be lost."},deleteRow:{title:"Delete row",message:"Are you sure you want to delete this row? All fields it contains will be lost."},deleteSection:{title:"Delete section",message:"Are you sure you want to delete this section? All fields it contains will be lost."}},title:"Form Schema Editor",context:"Context:",modes:{design:"Designer",preview:"Preview",code:"Code"},codeViewer:{copy:"Copy code",copied:"Copied",lines:"lines",format:"Format"},toolbar:{export:"Export",import:"Import JSON",shortcuts:"Shortcuts",showRelations:"Show relations",hideRelations:"Hide relations",toggleSidePanel:{open:"Open side panel",close:"Close side panel"}},importModal:{trigger:"Generate from object",triggerTitle:"Generate form from JSON or TypeScript",title:"Generate from JSON or TypeScript",labels:{formTitle:"Form Title",formId:"Form ID",layout:"Layout (cols)",input:"Input (paste JSON or TypeScript interface/type)"},placeholders:{layout:{auto:"Auto",col1:"1 column",col2:"2 columns",col3:"3 columns",col4:"4 columns"}},actions:{cancel:"Cancel",generate:"Generate Form",generating:"Generating..."},messages:{success:"Form generated successfully.",error:"Could not generate form."}}},fields:{defaults:{text:{label:"Text",placeholder:"Type…"},number:{label:"Number",placeholder:"0"},email:{label:"Email",placeholder:"user@domain.com"},password:{label:"Password",placeholder:"••••••••"},tel:{label:"Phone",placeholder:"600 000 000"},url:{label:"URL",placeholder:"https://example.com"},textarea:{label:"Comment",placeholder:"Write your comment…"},select:{label:"Select",placeholder:"Select an option"},checkbox:{label:"Checkbox"},date:{label:"Date"},file:{label:"File"},search:{label:"Search",placeholder:"Search...",noMatches:"No matches found"}},validation:{required:"Required field",invalidEmail:"Invalid email",invalidUrl:"Invalid URL",invalidPhone:"Invalid phone",invalidID:"Invalid identity document",invalidIBAN:"Invalid IBAN",minLength:"Minimum {{count}} characters",maxLength:"Maximum {{count}} characters",pattern:"Invalid format",numberMin:"Must be greater than or equal to {{min}}",numberMax:"Must be less than or equal to {{max}}",step:"Must be a multiple of {{step}}",integerOnly:"Must be an integer",positiveOnly:"Must be a positive number",selectMin:"Select at least {{count}} options",selectMax:"Select at most {{count}} options",dateMin:"Date must be after {{date}}",dateMax:"Date must be before {{date}}",disallowPast:"Past dates are not allowed",disallowFuture:"Future dates are not allowed",number:"Must be a number",date:"Invalid date",invalidOption:"Invalid option",mustCheck:"You must check this box",invalidFile:"Invalid file",invalidFileType:"File type not allowed",fileMaxCount:"Max. {{count}} file(s)",fileMaxSize:"File must not exceed {{size}}MB",minItems:"Minimum {{count}} items",maxItems:"Maximum {{count}} items"}}},IM={ds:$M},FM={fileUploader:{browse:"Documento",dragDrop:"Arrastra tus archivos aquí o haz clic para buscarlos",view:"Ver",remove:"Eliminar"},form:{fieldRequired:"Campo obligatorio",invalidEmail:"Email inválido",submit:"Enviar",sending:"Enviando…",saveSuccess:"¡Guardado con éxito!",saveError:"Hay errores en el formulario"},editor:{inspector:{field:"Inspector de campo",tab:"Inspector de pestaña",section:"Inspector de sección"},actions:{move:"Mover",moveLeft:"Mover a la izquierda",moveRight:"Mover a la derecha",add:"Añadir",addTab:"Pestaña a la derecha",addSection:"Añadir sección",addRow:"Añadir fila",addColumn:"Añadir columna",delete:"Eliminar",deleteTab:"Eliminar pestaña",deleteColumn:"Quitar última columna",duplicate:"Duplicar",cancel:"Cancelar"},confirmations:{deleteField:{title:"Eliminar campo",message:"¿Estás seguro de que quieres eliminar este campo?"},deleteColumn:{title:"Eliminar columna",message:"¿Estás seguro de que quieres eliminar la última columna? Se perderán los campos que contiene."},deleteRow:{title:"Eliminar fila",message:"¿Estás seguro de que quieres eliminar esta fila? Se perderán todos los campos que contiene."},deleteSection:{title:"Eliminar sección",message:"¿Estás seguro de que quieres eliminar esta sección? Se perderán todos los campos que contiene."}},title:"Editor de Esquema de Formulario",context:"Contexto:",modes:{design:"Diseñar",preview:"Vista Previa",code:"Código"},codeViewer:{copy:"Copiar código",copied:"Copiado",lines:"líneas",format:"Formato"},toolbar:{export:"Exportar",import:"Importar JSON",shortcuts:"Configurar atajos",showRelations:"Mostrar relaciones",hideRelations:"Ocultar relaciones",toggleSidePanel:{open:"Abrir panel lateral",close:"Cerrar panel lateral"}},importModal:{trigger:"Generar desde objeto",triggerTitle:"Generar formulario desde JSON o TypeScript",title:"Generar desde JSON o TypeScript",labels:{formTitle:"Título del formulario",formId:"ID del formulario",layout:"Distribución (cols)",input:"Entrada (pega JSON o una interface/type de TypeScript)"},placeholders:{layout:{auto:"Auto",col1:"1 columna",col2:"2 columnas",col3:"3 columnas",col4:"4 columnas"}},actions:{cancel:"Cancelar",generate:"Generar formulario",generating:"Generando..."},messages:{success:"Formulario generado correctamente.",error:"No se pudo generar el formulario."}}},fields:{defaults:{text:{label:"Texto",placeholder:"Escribe…"},number:{label:"Número",placeholder:"0"},email:{label:"Email",placeholder:"usuario@dominio.com"},password:{label:"Contraseña",placeholder:"••••••••"},tel:{label:"Teléfono",placeholder:"600 000 000"},url:{label:"URL",placeholder:"https://ejemplo.com"},textarea:{label:"Comentario",placeholder:"Escribe tu comentario…"},select:{label:"Seleccionar",placeholder:"Seleccione una opción"},checkbox:{label:"Casilla"},date:{label:"Fecha"},file:{label:"Archivo"},search:{label:"Búsqueda",placeholder:"Buscar...",noMatches:"No hay coincidencias"}},validation:{required:"Campo obligatorio",invalidEmail:"Email inválido",invalidUrl:"URL inválida",invalidPhone:"Teléfono inválido",invalidID:"Documento de identidad inválido",invalidIBAN:"IBAN inválido",minLength:"Mínimo {{count}} caracteres",maxLength:"Máximo {{count}} caracteres",pattern:"Formato inválido",numberMin:"Debe ser mayor o igual a {{min}}",numberMax:"Debe ser menor o igual a {{max}}",step:"Debe ser múltiplo de {{step}}",integerOnly:"Debe ser un número entero",positiveOnly:"Debe ser un número positivo",selectMin:"Selecciona al menos {{count}} opciones",selectMax:"Selecciona como máximo {{count}} opciones",dateMin:"La fecha debe ser posterior a {{date}}",dateMax:"La fecha debe ser anterior a {{date}}",disallowPast:"No se permiten fechas pasadas",disallowFuture:"No se permiten fechas futuras",number:"Debe ser un número",date:"Fecha inválida",invalidOption:"Opción inválida",mustCheck:"Debes marcar esta casilla",invalidFile:"Archivo inválido",invalidFileType:"Tipo de archivo no permitido",fileMaxCount:"Máx. {{count}} fichero(s)",fileMaxSize:"El archivo no debe superar {{size}}MB",minItems:"Mínimo {{count}} elementos",maxItems:"Máximo {{count}} elementos"}}},_M={ds:FM};He.use(MA).init({resources:{en:{translation:IM},es:{translation:_M}},lng:"es",fallbackLng:"es",interpolation:{escapeValue:!1}});const TM=e=>{He.changeLanguage(e)},J5="TRWAGMYFPDXBNJZSQVHLCKE",BM=["X","Y","Z"];function ZM(e){if(!/^\d{8}[A-Z]$/.test(e))return!1;const t=parseInt(e.substring(0,8),10),r=e.charAt(8),n=J5.charAt(t%23);return r===n}function VM(e){if(!/^[XYZ]\d{7}[A-Z]$/.test(e))return!1;const t=e.charAt(0),n=BM.indexOf(t).toString()+e.substring(1),o=parseInt(n.substring(0,8),10),l=e.charAt(8),i=J5.charAt(o%23);return l===i}function DM(e){if(!/^[A-Z]\d{7}[A-Z0-9]$/.test(e))return!1;const t=e.charAt(0),r=e.substring(1,8),n=e.charAt(8);let o=0;for(let m=0;m<7;m++){const f=parseInt(r.charAt(m),10);if(m%2===0){const h=f*2;o+=Math.floor(h/10)+h%10}else o+=f}const l=o%10,i=l===0?0:10-l,c="JABCDEFGHI".charAt(i);return["A","B","E","H"].includes(t)?n===i.toString():n===c||n===i.toString()}function PM(e){if(!e||e.length<9)return!1;const t=e.toUpperCase().replace(/\s+/g,"").replace(/[^A-Z0-9]/g,"");return/^\d{8}[A-Z]$/.test(t)?ZM(t):/^[XYZ]\d{7}[A-Z]$/.test(t)?VM(t):/^[A-Z]\d{7}[A-Z0-9]$/.test(t)?DM(t):!1}const zM=/^\s*(?:\+?\d{1,4}[\s-]*)?(?:\(?\d{2,4}\)?[\s-]*)?\d{3,4}[\s-]?\d{3,4}\s*$/;function Y5(e){return(e??"").toUpperCase().replace(/\s+/g,"").replace(/[^A-Z0-9]/g,"")}function HM(e){const t=Y5(e);if(t.length<15||t.length>34||!/^[A-Z]{2}\d{2}[A-Z0-9]+$/.test(t))return!1;const r=t.slice(4)+t.slice(0,4);let n=0;for(const o of r){const l=o.charCodeAt(0);if(l>=65&&l<=90){const i=String(l-55);for(let c=0;c<i.length;c++)n=(n*10+(i.charCodeAt(c)-48))%97}else n=(n*10+(o.charCodeAt(0)-48))%97}return n===1}function WM(e){return e.validation??{}}function UM(e){return!!e.multiple}function qM(e){const t=e.maxFiles;return typeof t=="number"?t:void 0}function GM(e){const t=e.options;return Array.isArray(t)?t.map(r=>r==null?void 0:r.value).filter(r=>r!==void 0):[]}function KM(e){if(!e)return{exts:[],mimes:[]};const t=e.split(",").map(o=>o.trim().toLowerCase()).filter(Boolean),r=[],n=[];for(const o of t)o.startsWith(".")?r.push(o):o.includes("/")&&n.push(o);return{exts:r,mimes:n}}function dt(e,t){const r=typeof e=="string"?e:t;return He.isInitialized&&(r.startsWith("forms.")||r.startsWith("ds."))?He.t(r):r}function Pt(e,t){let r=e;return t.required&&(r=r.required(dt(t.requiredMessage||(typeof t.required=="string"?t.required:void 0),"ds.fields.validation.required"))),t.customFn&&(r=r.test({name:"custom-script-validation",message:"${path} no es válido",test:async function(n,o){if(n==null||n==="")return!0;const l=o.parent;let i={};try{if(He.isInitialized){const c=He.getResourceBundle(He.language,"translation")||{},u=(d,m="")=>{for(const f of Object.keys(d)){const h=m?`${m}.${f}`:f,p=d[f];typeof p=="string"?i[h]=p:typeof p=="object"&&p!==null&&u(p,h)}};u(c)}}catch(c){console.warn("Error extracting translations for validation:",c)}try{const c=await K5(t.customFn,{value:n,form:l,customMessages:t.customMessages||{}},{translations:i});if(c===!0)return!0;if(typeof c=="string"){const u=He.isInitialized&&c.startsWith("forms.")?He.t(c):c;return this.createError({message:u})}return!1}catch(c){return console.error("Custom Validation Error",c),this.createError({message:"Error ejecutando validación: "+String(c)})}}})),r}function Pr(e,t){var n,o,l;let r=e;return((n=t.minLength)==null?void 0:n.value)!=null&&(r=r.min(t.minLength.value,dt(t.minLength.message,"ds.fields.validation.minLength"))),((o=t.maxLength)==null?void 0:o.value)!=null&&(r=r.max(t.maxLength.value,dt(t.maxLength.message,"ds.fields.validation.maxLength"))),((l=t.pattern)==null?void 0:l.value)instanceof RegExp&&(r=r.matches(t.pattern.value,dt(t.pattern.message,"ds.fields.validation.pattern"))),r}function JM(e,t){var n,o,l,i;let r=e;if(((n=t.numberMin)==null?void 0:n.value)!=null&&(r=r.min(t.numberMin.value,dt(t.numberMin.message,"ds.fields.validation.numberMin"))),((o=t.numberMax)==null?void 0:o.value)!=null&&(r=r.max(t.numberMax.value,dt(t.numberMax.message,"ds.fields.validation.numberMax"))),t.positiveOnly&&(r=r.moreThan(0,dt(t.positiveOnly,"ds.fields.validation.positiveOnly"))),t.integerOnly&&(r=r.integer(dt(t.integerOnly,"ds.fields.validation.integerOnly"))),((l=t.step)==null?void 0:l.value)!=null){const c=Number(t.step.value),u=t.step.message||"ds.fields.validation.step";r=r.test("step",u,d=>{if(d==null||Number.isNaN(d)||c===0)return!0;const m=d/c;return Math.abs(m-Math.round(m))<1e-9})}return((i=t.pattern)==null?void 0:i.value)instanceof RegExp&&(r=r.test("pattern-number",t.pattern.message||"ds.fields.validation.pattern",c=>c==null||t.pattern.value.test(String(c)))),r}function YM(e,t){var n,o;let r=e;return(n=t.dateMin)!=null&&n.value&&(r=r.min(new Date(t.dateMin.value),dt(t.dateMin.message,"ds.fields.validation.dateMin"))),(o=t.dateMax)!=null&&o.value&&(r=r.max(new Date(t.dateMax.value),dt(t.dateMax.message,"ds.fields.validation.dateMax"))),t.disallowPast&&(r=r.min(new Date,dt(t.disallowPast,"ds.fields.validation.disallowPast"))),t.disallowFuture&&(r=r.max(new Date,dt(t.disallowFuture,"ds.fields.validation.disallowFuture"))),r}function XM(e){var r,n,o,l;const t=WM(e);switch(e.type){case"text":case"password":case"textarea":case"search":{let i=Cr().trim();return i=Pr(i,t),Pt(i,t)}case"dni":{let i=Cr().trim();return i=Pr(i,t),i=i.test("dni-valid",dt("ds.fields.validation.invalidID","Documento de identidad inválido"),c=>c==null||c===""?!0:PM(c)),Pt(i,t)}case"email":{let i=Cr().trim().email(dt(t.emailMessage,"ds.fields.validation.invalidEmail"));return i=Pr(i,t),Pt(i,t)}case"url":{let i=Cr().trim().url(dt(t.urlMessage,"ds.fields.validation.invalidUrl"));return i=Pr(i,t),Pt(i,t)}case"tel":{let i=Cr().trim();return i=Pr(i,t),(r=t.pattern)!=null&&r.value||(i=i.matches(zM,dt(t.phoneMessage,"ds.fields.validation.invalidPhone"))),Pt(i,t)}case"iban":{let i=Cr().transform((c,u)=>u===""||u===null||u===void 0?"":typeof u=="string"?Y5(u):c);return i=Pr(i,t),i=i.test("iban-valid",dt("ds.fields.validation.invalidIBAN","IBAN inválido"),c=>c==null||c===""?!0:HM(String(c))),Pt(i,t)}case"number":{let i=P5().transform((c,u)=>{if(u===""||u===null||u===void 0)return;const d=typeof u=="string"?Number(u.replace(",",".")):c;return Number.isNaN(d)?NaN:d}).typeError(dt(t.typeError,"ds.fields.validation.number"));return i=JM(i,t),Pt(i,t)}case"date":{let i=yi().nullable().typeError(dt(t.typeError,"ds.fields.validation.date")).transform((c,u)=>u?new Date(u):null);return i=YM(i,t),Pt(i,t)}case"select":case"optionGroup":{const i=UM(e),c=GM(e);if(i){let u=Sl().of(c.length?Yn().oneOf(c,"ds.fields.validation.invalidOption"):Yn());return t.required&&(u=u.min(1,t.requiredMessage||(typeof t.required=="string"?t.required:"ds.fields.validation.required"))),u}else{let u=Cr().trim();return u=Pr(u,t),c.length&&(u=u.oneOf(c,"ds.fields.validation.invalidOption")),Pt(u,t)}}case"checkbox":{let i=Z5();return t.required&&(i=i.oneOf([!0],t.requiredMessage||"ds.fields.validation.mustCheck")),i}case"file":{const i=e,{exts:c,mimes:u}=KM(i.accept),d=qM(e);let m=Yn().test("file-shape","ds.fields.validation.invalidFile",f=>(f==null,!0));if((n=t.fileMaxSizeMB)!=null&&n.value){const f=Number(t.fileMaxSizeMB.value)*1024*1024,h=t.fileMaxSizeMB.message||"ds.fields.validation.fileMaxSize";m=m.test("file-max-size",h,p=>p?(Array.isArray(p)?p:typeof FileList<"u"&&p instanceof FileList?Array.from(p):[p].filter(Boolean)).every(v=>typeof(v==null?void 0:v.size)!="number"||v.size<=f):!0)}return(c.length||u.length)&&(m=m.test("file-accept","ds.fields.validation.invalidFileType",f=>f?(Array.isArray(f)?f:typeof FileList<"u"&&f instanceof FileList?Array.from(f):[f].filter(Boolean)).every(b=>{var y,R,j,E;const v=((R=(y=b==null?void 0:b.name)==null?void 0:y.toLowerCase)==null?void 0:R.call(y))||"",g=((E=(j=b==null?void 0:b.type)==null?void 0:j.toLowerCase)==null?void 0:E.call(j))||"",x=c.length===0||c.some(N=>v.endsWith(N)),w=u.length===0||u.includes(g);return x&&w}):!0)),typeof d=="number"&&(m=m.test("file-max-files","ds.fields.validation.fileMaxCount",f=>f?(Array.isArray(f)?f:typeof FileList<"u"&&f instanceof FileList?Array.from(f):[f].filter(Boolean)).length<=d:!0)),m=Pt(m,t),m}case"array":{const i=e,c=i.items||[],u=X5(c);let d=Sl().of(ji(u));t.required&&(d=d.min(1,t.requiredMessage||(typeof t.required=="string"?t.required:"ds.fields.validation.required")));const m=i.validation;return(o=m==null?void 0:m.min)!=null&&o.value&&(d=d.min(m.min.value,m.min.message||"ds.fields.validation.minItems")),(l=m==null?void 0:m.max)!=null&&l.value&&(d=d.max(m.max.value,m.max.message||"ds.fields.validation.maxItems")),d}default:{const i=Yn();return Pt(i,t)}}}function X5(e){const t={};for(const r of e){const n=r;n!=null&&n.name&&(t[n.name]=XM(n))}return t}function ki(e){const t=X5(e.fields);return ji(t)}const Qc=e=>{let t;const r=new Set,n=(d,m)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const h=t;t=m??(typeof f!="object"||f===null)?f:Object.assign({},t,f),r.forEach(p=>p(t,h))}},o=()=>t,c={setState:n,getState:o,getInitialState:()=>u,subscribe:d=>(r.add(d),()=>r.delete(d))},u=t=e(n,o,c);return c},QM=(e=>e?Qc(e):Qc),eO=e=>e;function tO(e,t=eO){const r=k.useSyncExternalStore(e.subscribe,k.useCallback(()=>t(e.getState()),[e,t]),k.useCallback(()=>t(e.getInitialState()),[e,t]));return k.useDebugValue(r),r}const e0=e=>{const t=QM(e),r=n=>tO(t,n);return Object.assign(r,t),r},Q5=(e=>e?e0(e):e0),Jr=Q5(e=>({isActive:!1,formValues:{},systemContext:{},setRuntimeState:t=>e(r=>({...r,...t})),reset:()=>e({isActive:!1,formValues:{},systemContext:{}})}));function Nl(e,t){return e?typeof e!="string"?String(e):e.replace(/\{\{([^}]+)\}\}/g,(r,n)=>{let l=n.trim().split(".").reduce((i,c)=>{if(!i)return;if(i[c]!==void 0)return i[c];const u=c.toLowerCase(),d=Object.keys(i).find(m=>m.toLowerCase()===u);return d?i[d]:void 0},t);return l!=null?String(l):r}):""}function xr({options:e,value:t,onChange:r,children:n,className:o,contentClassName:l}){const i=k.useRef(null),[c,u]=k.useState({left:0,width:0}),[d,m]=k.useState(!1),[f,h]=k.useState(!1),p=()=>{if(i.current){const{scrollLeft:v,scrollWidth:g,clientWidth:x}=i.current;m(v>0),h(v<g-x-1)}};k.useLayoutEffect(()=>{const v=i.current;if(!v)return;const g=()=>{const x=v.querySelector(`[data-value="${t}"]`);x&&u({left:x.offsetLeft,width:x.offsetWidth})};return g(),p(),window.addEventListener("resize",g),window.addEventListener("resize",p),()=>{window.removeEventListener("resize",g),window.removeEventListener("resize",p)}},[t,e]);const b=v=>{i.current&&i.current.scrollBy({left:v==="left"?-200:200,behavior:"smooth"})};return s.jsxs("div",{className:o,children:[s.jsxs("div",{className:"relative border-b border-[var(--color-ds-border-default-50)] group",children:[d&&s.jsx("div",{className:"absolute left-0 top-0 bottom-0 z-20 flex items-center bg-gradient-to-r from-[var(--color-ds-background-page)] to-transparent pr-4 pl-1 opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:s.jsx("button",{type:"button",onClick:()=>b("left"),className:"p-1 rounded-full bg-[var(--color-ds-background-surface)] shadow-sm border border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-primary)] hover:bg-[var(--color-ds-button-hover-bg)] hover:text-white transition-colors",children:s.jsx($d,{className:"w-4 h-4"})})}),s.jsx("div",{ref:i,onScroll:p,className:"overflow-x-auto scrollbar-hidden flex items-center w-full relative",style:{scrollBehavior:"smooth"},children:s.jsxs("div",{className:"relative flex min-w-full px-1",children:[e.map(v=>{const g=v.value===t;return s.jsxs("button",{"data-value":v.value,role:"tab","aria-selected":g,onClick:()=>!v.disabled&&r(v.value),type:"button",className:be("relative z-10 whitespace-nowrap px-4 py-2 transition-colors duration-150 ease-in-out font-medium text-sm focus:outline-none",g?"text-[var(--color-ds-background-accent)]":"text-[var(--color-ds-text-secondary)] hover:text-[var(--color-ds-text-primary)]",v.disabled&&"opacity-50 cursor-not-allowed"),disabled:v.disabled,children:[v.icon&&s.jsx("span",{className:"mr-2 -ml-1 inline-block align-text-bottom",children:v.icon}),v.label]},v.value)}),s.jsx("span",{className:"absolute bottom-0 h-0.5 bg-[var(--color-ds-background-accent)] transition-all duration-200 ease-in-out z-20",style:{left:c.left,width:c.width}})]})}),f&&s.jsx("div",{className:"absolute right-0 top-0 bottom-0 z-20 flex items-center bg-gradient-to-l from-[var(--color-ds-background-page)] to-transparent pl-4 pr-1 opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:s.jsx("button",{type:"button",onClick:()=>b("right"),className:"p-1 rounded-full bg-[var(--color-ds-background-surface)] shadow-sm border border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-primary)] hover:bg-[var(--color-ds-button-hover-bg)] hover:text-white transition-colors",children:s.jsx(qo,{className:"w-4 h-4"})})})]}),s.jsx("div",{className:be("mt-4",l),children:n[t]})]})}const dn={sm:"text-ds-sm",md:"text-ds-md",lg:"text-ds-lg"},Ga={sm:"h-5",md:"h-10",lg:"h-12"},Ka={sm:"px-2",md:"px-2.5",lg:"px-3"},Ja={sm:"1.5rem",md:"2.5rem",lg:"3rem"},Ya={sm:"pr-9",md:"pr-11",lg:"pr-12"},rO={sm:"h-6 w-6",md:"h-8 w-8",lg:"h-10 w-10"};function Xa({id:e,size:t,disabled:r,error:n,reserveErrorSpace:o,className:l,suffixButton:i,children:c,showDropdownIndicator:u}){var d;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:be("relative w-full",l),children:[c,u&&!i&&s.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-2 flex items-center",children:s.jsx(Kt,{className:"h-4 w-4 text-[var(--color-ds-text-secondary)]"})}),i&&s.jsx("div",{className:"pointer-events-none absolute flex items-center",style:{top:2,bottom:2,right:4},children:s.jsx("div",{className:"pointer-events-auto",children:k.isValidElement(i)?k.cloneElement(i,{className:be(rO[t],(d=i.props)==null?void 0:d.className)}):i})})]}),o?s.jsx("div",{className:"h-[1em]",children:n!=null&&n.message?s.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)] h-[1em]",children:n.message}):s.jsx("span",{"aria-hidden":"true",children:" "})}):n!=null&&n.message?s.jsx("div",{className:"pt-1",children:s.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)] h-[1em]",children:n.message})}):null]})}function t0(e,t){k.useEffect(()=>{const r=n=>{e.current&&(e.current.contains(n.target)||t())};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[t,e])}function Ue(e){const{control:t,name:r,rules:n,defaultValue:o,options:l=[],loadOptions:i,reloadDeps:c=[],value:u,onChange:d,size:m="sm",width:f="100%",label:h,labelHidden:p=!1,info:b,infoHeader:v,hasError:g=!1,errorMessage:x="",reserveErrorSpace:w,disableErrorPlaceholder:y,disabled:R=!1,className:j,suffixButton:E,loading:N=!1,coerceFirstValid:S=!0,mode:O="menu",renderTrigger:I,renderOption:Z,popupWidth:L,triggerClassName:V,onBlur:M,searchable:P=!1,searchPlaceholder:re="Buscar...",noOptionsText:Q="No se encontraron resultados"}=e,se=k.useId(),oe=r||se,[Y,A]=k.useState(l),[$,ne]=k.useState(!!i);k.useEffect(()=>{if(!i){A(l);return}ne(!0),i().then(ce=>A(ce)).finally(()=>ne(!1))},[i,...c]),k.useEffect(()=>{i||A(l)},[l,i]);const G=ce=>ce.find(xe=>xe.value!==""&&xe.value!==void 0)??ce[0],X=ce=>String(ce??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim(),me=(ce,xe)=>{const C=X(xe);return C?ce.filter(q=>[q.label,q.value,q.name,q.code,q.text,q.descripcion,q.description].map(X).join(" ").includes(C)):ce},pe=typeof w=="boolean"?w:!!t,ue=f&&(f.includes(" ")||f.startsWith("w-")||f.startsWith("max-w-")||f.startsWith("min-w-")),fe=ue?{maxWidth:"100%"}:{width:f,maxWidth:"100%"},ie=be("flex flex-col",ue&&f,j);if(t&&r){const{field:ce,fieldState:xe}=m5({name:r,control:t,rules:n,defaultValue:o});k.useEffect(()=>{if(!$&&Y.length>0&&S){const q=ce.value,te=Y.some(W=>String(W.value)===String(q));(q===void 0||!te)&&ce.onChange(G(Y).value)}},[Y,$,ce,S]);const C=h&&!p&&s.jsx(Gt,{id:oe,text:h,size:m,info:b,infoHeader:v});if((O??"native")==="menu"){const[q,te]=k.useState(!1),[W,H]=k.useState(""),K=k.useRef(null);t0(K,()=>{te(!1),H("")});const _=Y.find(B=>String(B.value)===String(ce.value)),U=P?me(Y,W):Y;return s.jsxs("div",{className:ie,style:fe,children:[C,N||$?s.jsx(pr,{width:"100%",height:Ja[m],variant:"rect",className:"rounded-lg"}):s.jsx(Xa,{id:oe,size:m,disabled:R,error:xe.error,reserveErrorSpace:typeof y=="boolean"?!y:pe,className:j,suffixButton:E,showDropdownIndicator:!0,children:s.jsxs("div",{className:"relative w-full",ref:K,children:[s.jsx("button",{type:"button",onClick:()=>{R||te(B=>{const T=!B;return T||H(""),T})},onBlur:()=>{ce.onBlur(),M==null||M()},className:be("box-border w-full rounded-lg border bg-[var(--color-ds-background-page)] outline-none transition appearance-none text-left flex items-center",dn[m],Ga[m],Ka[m],E&&Ya[m],xe.error?"border-[var(--color-ds-border-error)]":"border-[var(--color-ds-border-default)]",R?"bg-[var(--color-ds-background-disabled)] border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-primary)] cursor-not-allowed":"text-[var(--color-ds-text-primary)] hover:border-[var(--color-ds-border-default-hover)]",V),"aria-haspopup":"listbox","aria-expanded":q,children:I?I(_):(_==null?void 0:_.label)??"—"}),q&&s.jsxs("div",{role:"listbox",className:"custom-scroll absolute z-50 mt-1 rounded-xl border border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-page)] shadow-xl p-1 max-h-72 overflow-auto",style:{width:L??"100%"},children:[P&&s.jsx("div",{className:"sticky top-0 z-10 bg-[var(--color-ds-background-page)] p-1",children:s.jsx("input",{type:"text",value:W,onChange:B=>H(B.target.value),onClick:B=>B.stopPropagation(),placeholder:re,className:"w-full rounded-lg border border-[var(--color-ds-border-default)] bg-[var(--color-ds-background-page)] px-2 py-2 text-sm outline-none"})}),U.length>0?U.map(B=>{const T=String(B.value)===String(ce.value);return s.jsx("button",{role:"option","aria-selected":T,type:"button",onClick:()=>{ce.onChange(B.value),te(!1),H("")},className:be("w-full rounded-lg px-2 py-1.5 text-left transition-all duration-200",dn[m],T?"bg-[var(--color-ds-background-neutral)] font-medium text-[var(--color-ds-text-primary)]":"text-[var(--color-ds-text-secondary)] hover:bg-[var(--color-ds-background-neutral-hover)] hover:text-[var(--color-ds-text-primary)] hover:pl-3"),children:Z?Z(B,T):B.label},B.value)}):s.jsx("div",{className:"px-2 py-2 text-sm text-[var(--color-ds-text-secondary)]",children:Q})]})]})})]})}return s.jsxs("div",{className:ie,style:fe,children:[C,N||$?s.jsx(pr,{width:"100%",height:Ja[m],variant:"rect",className:"rounded-lg"}):s.jsx(Xa,{id:oe,size:m,disabled:R,error:xe.error,reserveErrorSpace:typeof y=="boolean"?!y:pe,className:j,suffixButton:E,showDropdownIndicator:!0,children:s.jsx("select",{id:oe,value:ce.value,onChange:q=>ce.onChange(q.target.value),onBlur:()=>{ce.onBlur(),M==null||M()},disabled:R,className:be("box-border w-full rounded-lg border bg-[var(--color-ds-background-page)] outline-none transition appearance-none leading-none",dn[m],Ga[m],Ka[m],E&&Ya[m],xe.error?"border-[var(--color-ds-border-error)]":"border-[var(--color-ds-border-default)]",R?"bg-[var(--color-ds-background-disabled)] border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-primary)] cursor-not-allowed":"text-[var(--color-ds-text-primary)]",V),children:Y.map(q=>s.jsx("option",{value:q.value,className:"bg-[var(--color-ds-background-page)] text-[var(--color-ds-text-primary)]",children:q.label},q.value))})})]})}k.useEffect(()=>{if(!t&&Y.length>0&&S){const ce=Y.some(C=>String(C.value)===String(u));(u===void 0||u===""||!ce)&&d&&d(G(Y).value)}},[Y,u,d,t,S]);const ke=h&&!p&&s.jsx(Gt,{id:oe,text:h,size:m,info:b,infoHeader:v});if((O??"native")==="menu"){const[ce,xe]=k.useState(!1),[C,q]=k.useState(""),te=k.useRef(null);t0(te,()=>{xe(!1),q("")});const W=Y.find(K=>String(K.value)===String(u)),H=P?me(Y,C):Y;return s.jsxs("div",{className:ie,style:fe,children:[ke,N||$?s.jsx(pr,{width:"100%",height:Ja[m],variant:"rect",className:"rounded-lg"}):s.jsx(Xa,{id:oe,size:m,disabled:R,error:g?{message:x}:void 0,reserveErrorSpace:typeof y=="boolean"?!y:!!(w??!1),className:j,suffixButton:E,showDropdownIndicator:!0,children:s.jsxs("div",{className:"relative w-full",ref:te,children:[s.jsx("button",{type:"button",onClick:()=>{R||xe(K=>{const _=!K;return _||q(""),_})},onBlur:M,className:be("box-border w-full rounded-lg border bg-[var(--color-ds-background-page)] outline-none transition appearance-none text-left flex items-center",dn[m],Ga[m],Ka[m],E&&Ya[m],g?"border-[var(--color-ds-border-error)]":"border-[var(--color-ds-border-default)]",R?"bg-[var(--color-ds-background-disabled)] border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-primary)] cursor-not-allowed":"text-[var(--color-ds-text-primary)] hover:border-[var(--color-ds-border-default-hover)]",V),"aria-haspopup":"listbox","aria-expanded":ce,children:I?I(W):(W==null?void 0:W.label)??"—"}),ce&&s.jsxs("div",{role:"listbox",className:"custom-scroll absolute z-50 mt-1 rounded-xl border border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-page)] shadow-xl p-1 max-h-72 overflow-auto",style:{width:L??"100%"},children:[P&&s.jsx("div",{className:"sticky top-0 z-10 bg-[var(--color-ds-background-page)] p-1",children:s.jsx("input",{type:"text",value:C,onChange:K=>q(K.target.value),onClick:K=>K.stopPropagation(),placeholder:re,className:"w-full rounded-lg border border-[var(--color-ds-border-default)] bg-[var(--color-ds-background-page)] px-2 py-2 text-sm outline-none"})}),H.length>0?H.map(K=>{const _=String(K.value)===String(u);return s.jsx("button",{role:"option","aria-selected":_,type:"button",onClick:()=>{d==null||d(K.value),xe(!1),q("")},className:be("w-full rounded-lg px-2 py-1.5 text-left transition-all duration-200",dn[m],_?"bg-[var(--color-ds-background-neutral)] font-medium text-[var(--color-ds-text-primary)]":"text-[var(--color-ds-text-secondary)] hover:bg-[var(--color-ds-background-neutral-hover)] hover:text-[var(--color-ds-text-primary)] hover:pl-3"),children:Z?Z(K,_):K.label},K.value)}):s.jsx("div",{className:"px-2 py-2 text-sm text-[var(--color-ds-text-secondary)]",children:Q})]})]})})]})}return s.jsxs("div",{className:ie,style:fe,children:[ke,N||$?s.jsx(pr,{width:"100%",height:Ja[m],variant:"rect",className:"rounded-lg"}):s.jsx(Xa,{id:oe,size:m,disabled:R,error:g?{message:x}:void 0,reserveErrorSpace:typeof y=="boolean"?!y:!!(w??!1),className:j,suffixButton:E,showDropdownIndicator:!0,children:s.jsx("select",{id:oe,value:u,onChange:ce=>d==null?void 0:d(ce.target.value),onBlur:M,disabled:R,className:be("box-border w-full rounded-lg border bg-[var(--color-ds-background-page)] outline-none transition appearance-none leading-none",dn[m],Ga[m],Ka[m],E&&Ya[m],g?"border-[var(--color-ds-border-error)]":"border-[var(--color-ds-border-default)]",R?"bg-[var(--color-ds-background-disabled)] border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-primary)] cursor-not-allowed":"text-[var(--color-ds-text-primary)]"),children:Y.map(ce=>s.jsx("option",{value:ce.value,className:"bg-[var(--color-ds-background-page)] text-[var(--color-ds-text-primary)]",children:ce.label},ce.value))})})]})}const r0={sm:"text-ds-sm",md:"text-ds-md",lg:"text-ds-lg"};function n0(e){var t;e.preventDefault(),e.stopPropagation(),(t=e.nativeEvent)!=null&&t.stopImmediatePropagation&&e.nativeEvent.stopImmediatePropagation()}function Ei({groupLabel:e,inputs:t=[],separator:r=s.jsx("span",{className:"px-1 select-none",children:"/"}),useSeparator:n=!1,className:o,showVisibleLabel:l=!1,size:i="sm",width:c,respectChildWidths:u=!1}){const d=t.length,m=c&&(c.includes(" ")||c.startsWith("w-")||c.startsWith("max-w-")||c.startsWith("min-w-")),f=m?void 0:c?{width:c}:void 0;return s.jsxs("div",{"data-input-group-root":!0,role:"group",className:be("flex flex-col w-full",m&&c,o),style:f,onDoubleClick:n0,onDoubleClickCapture:n0,onClickCapture:h=>{var v;const p=h.target;!!((v=p==null?void 0:p.closest)!=null&&v.call(p,'input,select,textarea,button,[data-interactive="true"]'))||h.stopPropagation()},children:[s.jsx("label",{className:be("sr-only pb-2",r0[i]),children:e}),l&&s.jsx("label",{className:be("pb-2",r0[i]),children:e}),s.jsx("div",{className:"flex items-stretch flex-nowrap w-full min-w-0",children:t.map((h,p)=>{const{width:b,className:v,options:g,loadOptions:x,info:w,infoHeader:y,...R}=h,j=Array.isArray(g)||typeof x=="function";let E="rounded-lg";!n&&d>1&&(p===0?E="rounded-l-lg rounded-r-none":p===d-1?E="rounded-r-lg rounded-l-none !rounded-l-none":E="rounded-none !rounded-l-none !rounded-r-none");const N=u?b:void 0,S=typeof N=="string"&&N.split(/\s+/).some(L=>L.startsWith("w-")||L.includes(":w-")),O=be("inline-flex items-stretch",N?"flex-shrink-0":"flex-1 min-w-0",typeof N=="string"&&S?N:void 0,!n&&d>1&&p>0?"-ml-px focus-within:z-10 relative":void 0),I=N?typeof N=="string"&&S?void 0:{width:N}:void 0,Z=be(v,"w-full",E);return s.jsxs(k.Fragment,{children:[s.jsx("div",{className:O,style:I,children:j?s.jsx(Ue,{...R,size:i,className:v,triggerClassName:be("w-full",E),options:g,loadOptions:x,"data-interactive":"true",info:w,infoHeader:y,mode:"menu",searchable:!0,searchPlaceholder:$c("ds.fields.defaults.search.placeholder"),noOptionsText:$c("ds.fields.defaults.search.noMatches")}):s.jsx(Ee,{...R,size:i,className:Z,"data-interactive":"true",info:w,infoHeader:y})}),n&&p<d-1&&s.jsx("div",{className:"flex items-center flex-shrink-0 px-1 select-none",children:r})]},p)})})]})}const nO={sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},aO={sm:"w-3 h-3",md:"w-3.5 h-3.5",lg:"w-4 h-4"};function ns({groupLabel:e,options:t,control:r,name:n,rules:o,defaultValue:l,multiple:i=!0,size:c="sm",vertical:u=!0,className:d,showVisibleLabel:m=!0,disabled:f=!1,hasError:h=!1,errorMessage:p}){return s.jsx(ht,{name:n,control:r,rules:o,defaultValue:l,render:({field:b,fieldState:v})=>{const{value:g,onChange:x}=b,w=v.error,y=N=>{var S;return i?Array.isArray(g)&&((S=g==null?void 0:g.includes)==null?void 0:S.call(g,N)):g===N},R=N=>{if(!f)if(i){const S=Array.isArray(g)?[...g]:[],O=S.indexOf(N);O>=0?S.splice(O,1):S.push(N),x(S)}else x(N)},j=h||!!w,E=(w==null?void 0:w.message)||p;return s.jsxs("fieldset",{className:be("w-full flex flex-col gap-1",d),"aria-invalid":j||void 0,disabled:f,children:[e&&s.jsx("legend",{className:be("mb-1 text-ds-sm text-[var(--color-ds-text-primary)]",!m&&"sr-only"),children:e}),s.jsx("div",{className:be(u?"flex flex-col gap-2":"flex flex-wrap gap-2"),children:t.map(N=>{const S=y(N.value),O=f||!!(N!=null&&N.disabled),I=be("inline-flex items-center justify-center border transition-all duration-150",i?"rounded-[6px]":"rounded-full",nO[c],"bg-[var(--color-ds-background-page)]","border-[var(--color-ds-border-default-50)]","shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-ds-border-default)20%,transparent)]","peer-focus-visible:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-[var(--color-ds-border-default)]","hover:border-[var(--color-ds-border-default)]",i&&S&&"bg-[var(--color-ds-button-primary-bg)] border-[var(--color-ds-button-primary-bg)]",!i&&S&&"border-[var(--color-ds-button-primary-bg)]",j&&"border-[var(--color-ds-border-error)] shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-ds-border-error)30%,transparent)]",O&&"opacity-60 cursor-not-allowed"),Z=be("text-ds-sm text-[var(--color-ds-text-primary)]",O&&"text-[var(--color-ds-text-secondary)]"),L=be(aO[c],"text-[var(--color-ds-button-primary-text)] transition-all duration-150",S?"opacity-100 scale-100":"opacity-0 scale-75"),V=be(c==="sm"?"w-2 h-2":c==="md"?"w-2.5 h-2.5":"w-3 h-3","rounded-full bg-[var(--color-ds-button-primary-bg)] transition-all duration-150",S?"opacity-100 scale-100":"opacity-0 scale-0");return s.jsxs("label",{className:be("inline-flex items-center gap-2 cursor-pointer select-none rounded-md px-1 py-1","hover:bg-[color-mix(in_srgb,var(--color-ds-border-default)6%,transparent)]",O&&"cursor-not-allowed hover:bg-transparent"),children:[s.jsxs("span",{className:"relative inline-flex items-center justify-center",children:[s.jsx("input",{type:i?"checkbox":"radio",name:n,value:N.value,checked:S,onChange:()=>R(N.value),disabled:O,className:"peer sr-only"}),s.jsx("span",{"aria-hidden":!0,className:I,children:i?s.jsx(vi,{className:L}):s.jsx("span",{className:V})})]}),s.jsx("span",{className:Z,children:N.label})]},String(N.value))})}),j&&!!E&&s.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)] mt-1",children:E})]})}})}function oO(e){function t(i){var c,u;for(const d of Object.keys(i)){if((c=i[d])!=null&&c.types||(u=i[d])!=null&&u.message)return d;if(typeof i[d]=="object"){const m=t(i[d]);if(m)return`${d}.${m}`}}return null}const r=t(e);if(!r)return;const n=`[name="${r}"]`,o=`[name^="${r}["], [name^="${r}."]`,l=document.querySelector(n)??document.querySelector(o);l&&(l.scrollIntoView({behavior:"smooth",block:"center"}),l.focus({preventScroll:!0}))}const sO={success:"bg-green-100 border-green-500 text-green-800",error:"bg-red-100 border-red-500 text-red-800",info:"bg-blue-100 border-blue-500 text-blue-800",warning:"bg-yellow-100 border-yellow-500 text-yellow-800"},e1=({id:e,message:t,variant:r="info",duration:n=5e3,onClose:o})=>(k.useEffect(()=>{const l=setTimeout(()=>o(e),n);return()=>clearTimeout(l)},[e,n,o]),s.jsxs("div",{className:be("w-80 max-w-full border-l-4 rounded shadow-md p-4 mb-2 flex justify-between items-start",sO[r]),role:"alert","aria-live":"assertive",children:[s.jsx("span",{className:"flex-1",children:t}),s.jsx("button",{onClick:()=>o(e),className:"ml-4 text-xl font-bold leading-none focus:outline-none",children:"×"})]})),mt=[];for(let e=0;e<256;++e)mt.push((e+256).toString(16).slice(1));function lO(e,t=0){return(mt[e[t+0]]+mt[e[t+1]]+mt[e[t+2]]+mt[e[t+3]]+"-"+mt[e[t+4]]+mt[e[t+5]]+"-"+mt[e[t+6]]+mt[e[t+7]]+"-"+mt[e[t+8]]+mt[e[t+9]]+"-"+mt[e[t+10]]+mt[e[t+11]]+mt[e[t+12]]+mt[e[t+13]]+mt[e[t+14]]+mt[e[t+15]]).toLowerCase()}let Fs;const iO=new Uint8Array(16);function cO(){if(!Fs){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Fs=crypto.getRandomValues.bind(crypto)}return Fs(iO)}const dO=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),a0={randomUUID:dO};function uO(e,t,r){var o;e=e||{};const n=e.random??((o=e.rng)==null?void 0:o.call(e))??cO();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,lO(n)}function fO(e,t,r){return a0.randomUUID&&!e?a0.randomUUID():uO(e)}const t1=k.createContext(null),Zr=()=>{const e=k.useContext(t1);if(!e)throw new Error("useToast debe usarse dentro de <ToastProvider>");return e},mO=({children:e})=>{const[t,r]=k.useState([]),n=(l,i="info",c=5e3)=>{const u=fO();r(d=>[...d,{id:u,message:l,variant:i,duration:c}])},o=l=>{r(i=>i.filter(c=>c.id!==l))};return s.jsxs(t1.Provider,{value:{show:n},children:[e,s.jsx("div",{className:"fixed top-4 right-4 z-50 flex flex-col items-end",children:t.map(l=>s.jsx(e1,{id:l.id,message:l.message,variant:l.variant,duration:l.duration,onClose:o},l.id))})]})},hO=e=>e.type==="inputGroup",pO=e=>e.type==="button",gO=e=>!hO(e)&&!pO(e);function r1(e){const t=Array.isArray(e)?e:[];return k.useMemo(()=>{const r={};for(const n of t)gO(n)&&n.name&&(r[n.name]=n);return r},[t])}const n1=k.createContext(null);function a1({children:e,value:t}){return s.jsx(n1.Provider,{value:t,children:e})}function At(){const e=k.useContext(n1);if(!e)throw new Error("useAdapters debe usarse dentro de <AdaptersProvider />");return e}const vO=e=>!!e&&typeof e.then=="function";function bO(e){return Array.isArray(e)?e.length>0&&typeof e[0]=="object"&&e[0]!==null?e.map(t=>{var o;if("label"in t&&"value"in t)return t;const n=(o=Object.entries(t)[0])==null?void 0:o[1];return{label:String(n??JSON.stringify(t)),value:String(n??"")}}):e.map(t=>({label:String(t),value:t})):[]}function o1(e){const{services:t}=At(),[r,n]=k.useState({}),[o,l]=k.useState(0),i=k.useRef(!0);k.useEffect(()=>(i.current=!0,()=>{i.current=!1}),[]);const c=k.useMemo(()=>e.filter(u=>u.type==="select"&&!u.options&&typeof u.optionSource=="string"&&u.name),[e]);return k.useEffect(()=>{if(c.length===0)return;let u=!1;return(async()=>{l(d=>d+1);try{const d=await Promise.all(c.map(async m=>{var g;const f=m.name,h=m.optionSource,p=(g=t==null?void 0:t.registry)==null?void 0:g[h];if(!p)return[f,[]];const b=vO(p)?await p:await p(),v=bO(b);return[f,v]}));if(u||!i.current)return;n(m=>{const f={...m};for(const[h,p]of d)f[h]=[...p];return f})}finally{!u&&i.current&&l(d=>Math.max(0,d-1))}})(),()=>{u=!0}},[c,t==null?void 0:t.registry]),{optionsMap:r,loadingCount:o}}const xO=e=>e.type==="inputGroup",wO=e=>e.type==="button",yO=e=>!xO(e)&&!wO(e);function jO(e){return typeof e=="object"&&e!==null}const kO=e=>{const t=e.disabledWhen;if(!jO(t))return!1;const r="watchField"in t,n="rule"in t;return r&&!n};function s1(e,t){const r=Array.isArray(e)?e:[],n=k.useMemo(()=>r.filter(yO).filter(kO),[r]),o=k.useMemo(()=>n.map(u=>u.disabledWhen.watchField),[n]),l=mi({control:t,name:o,compute:u=>u}),i=Array.isArray(l)?l:[],c={};return n.forEach((u,d)=>{const m=i[d];c[u.name??`__unnamed_${d}`]=m===u.disabledWhen.watchValue}),c}const EO={sm:"text-ds-sm",md:"text-ds-sm",lg:"text-ds-sm"},RO={sm:"px-2 py-1.5",md:"px-3 py-2",lg:"px-4 py-3"};function ar({control:e,name:t,rules:r,defaultValue:n,size:o="sm",width:l="100%",label:i,labelHidden:c=!1,hasError:u=!1,errorMessage:d="",maxLength:m,showCounter:f=!1,className:h,suffixButton:p,labelPrefixIcon:b,labelSuffixIcon:v,info:g,infoHeader:x,infoAriaLabel:w,prefixIcon:y,suffixIcon:R,reserveErrorSpace:j,disableErrorPlaceholder:E,id:N,...S}){const O=k.useId(),I=N||O,[Z,L]=k.useState(String(n??S.value??"")),V=typeof j=="boolean"?j:typeof E=="boolean"?!E:!!e,M=be("box-border bg-[var(--color-ds-background-page)] w-full rounded-lg border outline-none transition","placeholder-[var(--color-ds-text-secondary)] text-[var(--color-ds-text-primary)]",EO[o],RO[o],u?"border-[var(--color-ds-border-error)]":"border-[var(--color-ds-border-default)]",S.disabled&&"bg-[var(--color-ds-background-disabled)] border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-secondary)] cursor-not-allowed"),P=y?"pl-9":"",re=R?"pr-9":"",Q=A=>{var $;typeof m=="number"&&A.target.value.length>m||(L(A.target.value),($=S.onChange)==null||$.call(S,A))},se=l&&(l.includes(" ")||l.startsWith("w-")||l.startsWith("max-w-")||l.startsWith("min-w-")),oe=se?void 0:{width:l},Y=be("flex flex-col",se&&l,h);return k.useEffect(()=>{n!==void 0&&L(String(n??""))},[n]),e&&t?s.jsx(ht,{name:t,control:e,rules:r,defaultValue:n??"",render:({field:A,fieldState:$})=>{var ne;return s.jsxs("div",{className:Y,style:oe,children:[!c&&i&&s.jsx(Gt,{id:I,text:i,size:o,prefixIcon:b,suffixIcon:v,info:g,infoHeader:x,infoAriaLabel:w}),s.jsxs("div",{className:"flex items-stretch gap-2",children:[s.jsxs("div",{className:"relative w-full",children:[y&&s.jsx("span",{className:"absolute left-2 top-2.5",children:s.jsx(yt,{component:y,size:o,className:"text-[var(--color-ds-text-secondary)]"})}),s.jsx("textarea",{id:I,"aria-invalid":!!$.error,className:be(M,P,re),maxLength:m,...A,placeholder:S.disabled?"":S.placeholder,onChange:G=>{A.onChange(G),f&&L(G.target.value)}}),R&&s.jsx("span",{className:"absolute right-2 top-2.5",children:s.jsx(yt,{component:R,size:o,className:"text-[var(--color-ds-text-secondary)]"})})]}),p?s.jsx("div",{className:"shrink-0",children:p}):null]}),s.jsxs("div",{className:"flex justify-between pt-1 h-[1em]",children:[V?$.error?s.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)]",children:$.error.message}):s.jsx("span",{"aria-hidden":"true",children:" "}):$.error?s.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)]",children:$.error.message}):s.jsx("span",{"aria-hidden":"true",children:" "}),f&&typeof m=="number"&&s.jsxs("span",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:[((ne=A.value)==null?void 0:ne.length)??0,"/",m]})]})]})}}):s.jsxs("div",{className:Y,style:oe,children:[!c&&i&&s.jsx(Gt,{id:I,text:i,size:o,prefixIcon:b,suffixIcon:v,info:g,infoHeader:x,infoAriaLabel:w}),s.jsxs("div",{className:"flex items-stretch gap-2",children:[s.jsxs("div",{className:"relative w-full",children:[y&&s.jsx("span",{className:"absolute left-2 top-2.5",children:s.jsx(yt,{component:y,size:o,className:"text-[var(--color-ds-text-secondary)]"})}),s.jsx("textarea",{id:I,className:be(M,P,re),value:Z,onChange:Q,maxLength:m,...S,placeholder:S.disabled?"":S.placeholder}),R&&s.jsx("span",{className:"absolute right-2 top-2.5",children:s.jsx(yt,{component:R,size:o,className:"text-[var(--color-ds-text-secondary)]"})})]}),p?s.jsx("div",{className:"shrink-0",children:p}):null]}),s.jsxs("div",{className:"flex justify-between pt-1 h-[1em]",children:[V?u&&d?s.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)]",children:d}):s.jsx("span",{"aria-hidden":"true",children:" "}):u&&d?s.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)]",children:d}):s.jsx("span",{"aria-hidden":"true",children:" "}),f&&typeof m=="number"&&s.jsxs("span",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:[Z.length,"/",m]})]})]})}const CO={sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},SO={sm:"w-3 h-3",md:"w-3.5 h-3.5",lg:"w-4 h-4"};function tt({control:e=null,name:t,rules:r,defaultValue:n=!1,label:o,labelHidden:l=!1,disabled:i=!1,size:c="sm",className:u,hasError:d=!1,errorMessage:m="",reserveErrorSpace:f,disableErrorPlaceholder:h,checked:p,indeterminate:b,onChange:v}){const g=be("text-[var(--color-ds-text-primary)] text-ds-sm",i&&"text-[var(--color-ds-text-secondary)]",l&&"sr-only"),x=typeof f=="boolean"?f:typeof h=="boolean"?!h:!!e,w=(y,R,j)=>{const E=d||!!j,N=(j==null?void 0:j.message)||m,S=be("inline-flex items-center justify-center rounded-[6px] border transition-all duration-150",CO[c],"bg-[var(--color-ds-background-page)]","border-[var(--color-ds-border-default-50)]","shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-ds-border-default)20%,transparent)]","peer-focus-visible:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-[var(--color-ds-border-default)]","hover:border-[var(--color-ds-border-default)]",(y||b)&&"bg-[var(--color-ds-button-primary-bg)] border-[var(--color-ds-button-primary-bg)]",E&&"border-[var(--color-ds-border-error)] shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-ds-border-error)30%,transparent)]",i&&"opacity-60 cursor-not-allowed"),O=be(SO[c],"text-[var(--color-ds-button-primary-text)]","transition-all duration-150",y||b?"opacity-100 scale-100":"opacity-0 scale-75");return s.jsxs("div",{className:be("flex flex-col gap-1",u),children:[k.createElement(typeof o=="string"?"label":"div",{className:be("inline-flex items-center gap-2 cursor-pointer select-none",i&&"cursor-not-allowed")},s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"relative inline-flex items-center justify-center",children:[s.jsx("input",{id:t,type:"checkbox",className:"peer sr-only",checked:y,ref:I=>{I&&(I.indeterminate=!!b)},onChange:I=>R(I.target.checked),disabled:i}),s.jsx("span",{"aria-hidden":!0,className:S,children:b?s.jsx("div",{className:"bg-white h-0.5 w-[60%] rounded-full"}):s.jsx(vi,{className:O})})]}),o&&s.jsx("span",{className:g,children:o})]})),x?s.jsx("div",{className:"h-[1em]",children:E&&N?s.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)] h-[1em]",children:N}):s.jsx("span",{"aria-hidden":"true",children:" "})}):E&&N?s.jsx("div",{className:"pt-1",children:s.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)] h-[1em]",children:N})}):null]})};return e?s.jsx(ht,{name:t||"",control:e,rules:r,defaultValue:n,render:({field:y,fieldState:R})=>{const j=R.error;return w(!!y.value,E=>y.onChange(E),j)}}):w(!!p,y=>v==null?void 0:v(y))}function Ri({name:e,control:t,searchFn:r,resolveByValue:n,label:o,size:l="sm",width:i="100%",disabled:c=!1,searchMode:u="button",minChars:d=3,debounceMs:m=600,labelPrefixIcon:f,labelSuffixIcon:h,prefixIcon:p,suffixIcon:b,reserveErrorSpace:v,disableErrorPlaceholder:g}){const x=_r(),{watch:w,getValues:y,setValue:R}=x,j=mi({control:t,name:e}),[E,N]=k.useState([]),[S,O]=k.useState(!1),[I,Z]=k.useState(!1),[L,V]=k.useState(""),M=k.useRef(null),P=k.useRef(null),re=k.useRef(!1),Q=k.useRef(!1),se=k.useRef(!0),oe=k.useMemo(()=>{const fe=new Map;for(const ie of E)fe.set(String(ie.value).trim(),ie.label??"");return fe},[E]),Y=async fe=>{const ie=(fe??"").trim();if(!ie){N([]),Z(!1);return}O(!0);try{const ke=await r(ie,{watch:w,getValues:y});N(ke??[]),Z(!0)}finally{O(!1)}};k.useEffect(()=>{function fe(ie){M.current&&!M.current.contains(ie.target)&&Z(!1)}if(I)return document.addEventListener("mousedown",fe),()=>document.removeEventListener("mousedown",fe)},[I]);const[A,$]=k.useState({});k.useEffect(()=>{if(re.current)return;const ie=(j?String(j):"").trim();if(!ie){L!==""&&V(""),Z(!1);return}const ke=oe.get(ie);if(ke){L!==ke&&(V(ke),se.current=!0);return}const ce=A[ie];if(ce){L!==ce&&(V(ce),se.current=!0);return}let xe=!1;return n?(L!==ie&&V(ie),(async()=>{try{const C=await n(ie,{watch:w,getValues:y});if(xe)return;if(C){const q=C.label??String(C.value);$(te=>{const W={...te,[ie]:q};return V(q),se.current=!0,W})}else L!==ie&&(V(ie),se.current=!0)}catch{!xe&&L!==ie&&(V(ie),se.current=!0)}})()):L!==ie&&(V(ie),se.current=!0),()=>{xe=!0}},[j,oe,A,n,w,y]),k.useEffect(()=>{if(u!=="debounced"||c)return;if(se.current){se.current=!1;return}if(!Q.current)return;P.current&&(window.clearTimeout(P.current),P.current=null);const fe=(L||"").trim();return fe.length>=d?P.current=window.setTimeout(()=>{Y(fe)},m):(N([]),Z(!1)),()=>{P.current&&(window.clearTimeout(P.current),P.current=null)}},[L,u,d,m,c]);const ne=l==="sm"?"text-ds-sm":l==="md"?"text-ds-md":"text-ds-lg",G=l==="sm"?"h-6":l==="md"?"h-10":"h-12",X=fe=>{if(c)return;const ie=(L||"").trim();fe.key==="Enter"&&(fe.preventDefault(),u==="debounced"?ie.length>=d&&Y(ie):Y(ie)),fe.key==="Escape"&&Z(!1)},me=i&&(i.includes(" ")||i.startsWith("w-")||i.startsWith("max-w-")||i.startsWith("min-w-")),pe=me?void 0:{width:i},ue=`relative flex flex-col ${me?i:""}`;return s.jsx(ht,{name:e,control:t,render:({field:fe,fieldState:ie})=>{var ke;return s.jsxs("div",{ref:M,className:ue,style:pe,children:[o&&s.jsx(Gt,{id:e,text:o,size:l,prefixIcon:f,suffixIcon:h}),s.jsx(Ee,{className:u==="button"?"rounded-r-none":void 0,type:"text",size:l,width:"100%",value:L,prefixIcon:p,suffixIcon:b,onChange:ce=>{const xe=ce.target.value;re.current=!0,Q.current=!0,V(xe),(j?String(j):"").trim()&&R(e,"",{shouldDirty:!0})},onKeyDown:X,onBlur:()=>{re.current=!1},disabled:c,hasError:ie.invalid,errorMessage:(ke=ie.error)==null?void 0:ke.message,reserveErrorSpace:v,disableErrorPlaceholder:g,onFocus:()=>{if(re.current=!0,u==="button"&&Q.current){const ce=(L||"").trim();ce&&Y(ce)}},suffixButton:u==="button"?s.jsx(he,{type:"button",className:"!rounded-l-none",size:l,variant:"primary",onClick:()=>Y((L||"").trim()),disabled:c,children:"Buscar"}):void 0}),S&&s.jsx("div",{className:"absolute top-14 left-0 right-0 z-10",children:s.jsx(pr,{width:"100%",height:l==="sm"?"1.5rem":l==="md"?"2.5rem":"3rem",variant:"rect",className:"rounded-lg"})}),I&&!S&&E.length>0&&s.jsx("ul",{className:`
|
|
91
|
+
`,d=new Blob([u],{type:"application/javascript"}),m=URL.createObjectURL(d),f=new Worker(m),h=setTimeout(()=>{f.terminate(),URL.revokeObjectURL(m),c(new Error("Timeout: La validación tardó demasiado."))},o);f.onmessage=p=>{clearTimeout(h),f.terminate(),URL.revokeObjectURL(m),p.data.success?i(p.data.result):(console.warn("Validation Script Error:",p.data.error),i("Error en script de validación"))},f.onerror=p=>{clearTimeout(h),f.terminate(),URL.revokeObjectURL(m),c(p)},f.postMessage({code:e,context:t,translations:l})})}const $M={fileUploader:{browse:"Document",dragDrop:"Drag your files here or click to browse",view:"View",remove:"Remove"},form:{fieldRequired:"Required field",invalidEmail:"Invalid email",submit:"Submit",sending:"Sending…",saveSuccess:"Saved successfully!",saveError:"There are errors in the form"},editor:{inspector:{field:"Field Inspector",tab:"Tab Inspector",section:"Section Inspector"},actions:{move:"Move",moveLeft:"Move left",moveRight:"Move right",add:"Add",addTab:"Tab to the right",addSection:"Add section",addRow:"Add row",addColumn:"Add column",delete:"Delete",deleteTab:"Delete tab",deleteColumn:"Remove last column",duplicate:"Duplicate",cancel:"Cancel"},confirmations:{deleteField:{title:"Delete field",message:"Are you sure you want to delete this field?"},deleteColumn:{title:"Delete column",message:"Are you sure you want to delete the last column? Fields it contains will be lost."},deleteRow:{title:"Delete row",message:"Are you sure you want to delete this row? All fields it contains will be lost."},deleteSection:{title:"Delete section",message:"Are you sure you want to delete this section? All fields it contains will be lost."}},title:"Form Schema Editor",context:"Context:",modes:{design:"Designer",preview:"Preview",code:"Code"},codeViewer:{copy:"Copy code",copied:"Copied",lines:"lines",format:"Format"},toolbar:{export:"Export",import:"Import JSON",shortcuts:"Shortcuts",showRelations:"Show relations",hideRelations:"Hide relations",toggleSidePanel:{open:"Open side panel",close:"Close side panel"}},importModal:{trigger:"Generate from object",triggerTitle:"Generate form from JSON or TypeScript",title:"Generate from JSON or TypeScript",labels:{formTitle:"Form Title",formId:"Form ID",layout:"Layout (cols)",input:"Input (paste JSON or TypeScript interface/type)"},placeholders:{layout:{auto:"Auto",col1:"1 column",col2:"2 columns",col3:"3 columns",col4:"4 columns"}},actions:{cancel:"Cancel",generate:"Generate Form",generating:"Generating..."},messages:{success:"Form generated successfully.",error:"Could not generate form."}}},fields:{defaults:{text:{label:"Text",placeholder:"Type…"},number:{label:"Number",placeholder:"0"},email:{label:"Email",placeholder:"user@domain.com"},password:{label:"Password",placeholder:"••••••••"},tel:{label:"Phone",placeholder:"600 000 000"},url:{label:"URL",placeholder:"https://example.com"},textarea:{label:"Comment",placeholder:"Write your comment…"},select:{label:"Select",placeholder:"Select an option"},checkbox:{label:"Checkbox"},date:{label:"Date"},file:{label:"File"},search:{label:"Search",placeholder:"Search...",noMatches:"No matches found"}},validation:{required:"Required field",invalidEmail:"Invalid email",invalidUrl:"Invalid URL",invalidPhone:"Invalid phone",invalidID:"Invalid identity document",invalidIBAN:"Invalid IBAN",minLength:"Minimum {{count}} characters",maxLength:"Maximum {{count}} characters",pattern:"Invalid format",numberMin:"Must be greater than or equal to {{min}}",numberMax:"Must be less than or equal to {{max}}",step:"Must be a multiple of {{step}}",integerOnly:"Must be an integer",positiveOnly:"Must be a positive number",selectMin:"Select at least {{count}} options",selectMax:"Select at most {{count}} options",dateMin:"Date must be after {{date}}",dateMax:"Date must be before {{date}}",disallowPast:"Past dates are not allowed",disallowFuture:"Future dates are not allowed",number:"Must be a number",date:"Invalid date",invalidOption:"Invalid option",mustCheck:"You must check this box",invalidFile:"Invalid file",invalidFileType:"File type not allowed",fileMaxCount:"Max. {{count}} file(s)",fileMaxSize:"File must not exceed {{size}}MB",minItems:"Minimum {{count}} items",maxItems:"Maximum {{count}} items"}}},IM={ds:$M},FM={fileUploader:{browse:"Documento",dragDrop:"Arrastra tus archivos aquí o haz clic para buscarlos",view:"Ver",remove:"Eliminar"},form:{fieldRequired:"Campo obligatorio",invalidEmail:"Email inválido",submit:"Enviar",sending:"Enviando…",saveSuccess:"¡Guardado con éxito!",saveError:"Hay errores en el formulario"},editor:{inspector:{field:"Inspector de campo",tab:"Inspector de pestaña",section:"Inspector de sección"},actions:{move:"Mover",moveLeft:"Mover a la izquierda",moveRight:"Mover a la derecha",add:"Añadir",addTab:"Pestaña a la derecha",addSection:"Añadir sección",addRow:"Añadir fila",addColumn:"Añadir columna",delete:"Eliminar",deleteTab:"Eliminar pestaña",deleteColumn:"Quitar última columna",duplicate:"Duplicar",cancel:"Cancelar"},confirmations:{deleteField:{title:"Eliminar campo",message:"¿Estás seguro de que quieres eliminar este campo?"},deleteColumn:{title:"Eliminar columna",message:"¿Estás seguro de que quieres eliminar la última columna? Se perderán los campos que contiene."},deleteRow:{title:"Eliminar fila",message:"¿Estás seguro de que quieres eliminar esta fila? Se perderán todos los campos que contiene."},deleteSection:{title:"Eliminar sección",message:"¿Estás seguro de que quieres eliminar esta sección? Se perderán todos los campos que contiene."}},title:"Editor de Esquema de Formulario",context:"Contexto:",modes:{design:"Diseñar",preview:"Vista Previa",code:"Código"},codeViewer:{copy:"Copiar código",copied:"Copiado",lines:"líneas",format:"Formato"},toolbar:{export:"Exportar",import:"Importar JSON",shortcuts:"Configurar atajos",showRelations:"Mostrar relaciones",hideRelations:"Ocultar relaciones",toggleSidePanel:{open:"Abrir panel lateral",close:"Cerrar panel lateral"}},importModal:{trigger:"Generar desde objeto",triggerTitle:"Generar formulario desde JSON o TypeScript",title:"Generar desde JSON o TypeScript",labels:{formTitle:"Título del formulario",formId:"ID del formulario",layout:"Distribución (cols)",input:"Entrada (pega JSON o una interface/type de TypeScript)"},placeholders:{layout:{auto:"Auto",col1:"1 columna",col2:"2 columnas",col3:"3 columnas",col4:"4 columnas"}},actions:{cancel:"Cancelar",generate:"Generar formulario",generating:"Generando..."},messages:{success:"Formulario generado correctamente.",error:"No se pudo generar el formulario."}}},fields:{defaults:{text:{label:"Texto",placeholder:"Escribe…"},number:{label:"Número",placeholder:"0"},email:{label:"Email",placeholder:"usuario@dominio.com"},password:{label:"Contraseña",placeholder:"••••••••"},tel:{label:"Teléfono",placeholder:"600 000 000"},url:{label:"URL",placeholder:"https://ejemplo.com"},textarea:{label:"Comentario",placeholder:"Escribe tu comentario…"},select:{label:"Seleccionar",placeholder:"Seleccione una opción"},checkbox:{label:"Casilla"},date:{label:"Fecha"},file:{label:"Archivo"},search:{label:"Búsqueda",placeholder:"Buscar...",noMatches:"No hay coincidencias"}},validation:{required:"Campo obligatorio",invalidEmail:"Email inválido",invalidUrl:"URL inválida",invalidPhone:"Teléfono inválido",invalidID:"Documento de identidad inválido",invalidIBAN:"IBAN inválido",minLength:"Mínimo {{count}} caracteres",maxLength:"Máximo {{count}} caracteres",pattern:"Formato inválido",numberMin:"Debe ser mayor o igual a {{min}}",numberMax:"Debe ser menor o igual a {{max}}",step:"Debe ser múltiplo de {{step}}",integerOnly:"Debe ser un número entero",positiveOnly:"Debe ser un número positivo",selectMin:"Selecciona al menos {{count}} opciones",selectMax:"Selecciona como máximo {{count}} opciones",dateMin:"La fecha debe ser posterior a {{date}}",dateMax:"La fecha debe ser anterior a {{date}}",disallowPast:"No se permiten fechas pasadas",disallowFuture:"No se permiten fechas futuras",number:"Debe ser un número",date:"Fecha inválida",invalidOption:"Opción inválida",mustCheck:"Debes marcar esta casilla",invalidFile:"Archivo inválido",invalidFileType:"Tipo de archivo no permitido",fileMaxCount:"Máx. {{count}} fichero(s)",fileMaxSize:"El archivo no debe superar {{size}}MB",minItems:"Mínimo {{count}} elementos",maxItems:"Máximo {{count}} elementos"}}},_M={ds:FM};He.use(MA).init({resources:{en:{translation:IM},es:{translation:_M}},lng:"es",fallbackLng:"es",interpolation:{escapeValue:!1}});const TM=e=>{He.changeLanguage(e)},J5="TRWAGMYFPDXBNJZSQVHLCKE",BM=["X","Y","Z"];function ZM(e){if(!/^\d{8}[A-Z]$/.test(e))return!1;const t=parseInt(e.substring(0,8),10),r=e.charAt(8),n=J5.charAt(t%23);return r===n}function VM(e){if(!/^[XYZ]\d{7}[A-Z]$/.test(e))return!1;const t=e.charAt(0),n=BM.indexOf(t).toString()+e.substring(1),o=parseInt(n.substring(0,8),10),l=e.charAt(8),i=J5.charAt(o%23);return l===i}function DM(e){if(!/^[A-Z]\d{7}[A-Z0-9]$/.test(e))return!1;const t=e.charAt(0),r=e.substring(1,8),n=e.charAt(8);let o=0;for(let m=0;m<7;m++){const f=parseInt(r.charAt(m),10);if(m%2===0){const h=f*2;o+=Math.floor(h/10)+h%10}else o+=f}const l=o%10,i=l===0?0:10-l,c="JABCDEFGHI".charAt(i);return["A","B","E","H"].includes(t)?n===i.toString():n===c||n===i.toString()}function PM(e){if(!e||e.length<9)return!1;const t=e.toUpperCase().replace(/\s+/g,"").replace(/[^A-Z0-9]/g,"");return/^\d{8}[A-Z]$/.test(t)?ZM(t):/^[XYZ]\d{7}[A-Z]$/.test(t)?VM(t):/^[A-Z]\d{7}[A-Z0-9]$/.test(t)?DM(t):!1}const zM=/^\s*(?:\+?\d{1,4}[\s-]*)?(?:\(?\d{2,4}\)?[\s-]*)?\d{3,4}[\s-]?\d{3,4}\s*$/;function Y5(e){return(e??"").toUpperCase().replace(/\s+/g,"").replace(/[^A-Z0-9]/g,"")}function HM(e){const t=Y5(e);if(t.length<15||t.length>34||!/^[A-Z]{2}\d{2}[A-Z0-9]+$/.test(t))return!1;const r=t.slice(4)+t.slice(0,4);let n=0;for(const o of r){const l=o.charCodeAt(0);if(l>=65&&l<=90){const i=String(l-55);for(let c=0;c<i.length;c++)n=(n*10+(i.charCodeAt(c)-48))%97}else n=(n*10+(o.charCodeAt(0)-48))%97}return n===1}function WM(e){return e.validation??{}}function UM(e){return!!e.multiple}function qM(e){const t=e.maxFiles;return typeof t=="number"?t:void 0}function GM(e){const t=e.options;return Array.isArray(t)?t.map(r=>r==null?void 0:r.value).filter(r=>r!==void 0):[]}function KM(e){if(!e)return{exts:[],mimes:[]};const t=e.split(",").map(o=>o.trim().toLowerCase()).filter(Boolean),r=[],n=[];for(const o of t)o.startsWith(".")?r.push(o):o.includes("/")&&n.push(o);return{exts:r,mimes:n}}function dt(e,t){const r=typeof e=="string"?e:t;return He.isInitialized&&(r.startsWith("forms.")||r.startsWith("ds."))?He.t(r):r}function Pt(e,t){let r=e;return t.required&&(r=r.required(dt(t.requiredMessage||(typeof t.required=="string"?t.required:void 0),"ds.fields.validation.required"))),t.customFn&&(r=r.test({name:"custom-script-validation",message:"${path} no es válido",test:async function(n,o){if(n==null||n==="")return!0;const l=o.parent;let i={};try{if(He.isInitialized){const c=He.getResourceBundle(He.language,"translation")||{},u=(d,m="")=>{for(const f of Object.keys(d)){const h=m?`${m}.${f}`:f,p=d[f];typeof p=="string"?i[h]=p:typeof p=="object"&&p!==null&&u(p,h)}};u(c)}}catch(c){console.warn("Error extracting translations for validation:",c)}try{const c=await K5(t.customFn,{value:n,form:l,customMessages:t.customMessages||{}},{translations:i});if(c===!0)return!0;if(typeof c=="string"){const u=He.isInitialized&&c.startsWith("forms.")?He.t(c):c;return this.createError({message:u})}return!1}catch(c){return console.error("Custom Validation Error",c),this.createError({message:"Error ejecutando validación: "+String(c)})}}})),r}function Pr(e,t){var n,o,l;let r=e;return((n=t.minLength)==null?void 0:n.value)!=null&&(r=r.min(t.minLength.value,dt(t.minLength.message,"ds.fields.validation.minLength"))),((o=t.maxLength)==null?void 0:o.value)!=null&&(r=r.max(t.maxLength.value,dt(t.maxLength.message,"ds.fields.validation.maxLength"))),((l=t.pattern)==null?void 0:l.value)instanceof RegExp&&(r=r.matches(t.pattern.value,dt(t.pattern.message,"ds.fields.validation.pattern"))),r}function JM(e,t){var n,o,l,i;let r=e;if(((n=t.numberMin)==null?void 0:n.value)!=null&&(r=r.min(t.numberMin.value,dt(t.numberMin.message,"ds.fields.validation.numberMin"))),((o=t.numberMax)==null?void 0:o.value)!=null&&(r=r.max(t.numberMax.value,dt(t.numberMax.message,"ds.fields.validation.numberMax"))),t.positiveOnly&&(r=r.moreThan(0,dt(t.positiveOnly,"ds.fields.validation.positiveOnly"))),t.integerOnly&&(r=r.integer(dt(t.integerOnly,"ds.fields.validation.integerOnly"))),((l=t.step)==null?void 0:l.value)!=null){const c=Number(t.step.value),u=t.step.message||"ds.fields.validation.step";r=r.test("step",u,d=>{if(d==null||Number.isNaN(d)||c===0)return!0;const m=d/c;return Math.abs(m-Math.round(m))<1e-9})}return((i=t.pattern)==null?void 0:i.value)instanceof RegExp&&(r=r.test("pattern-number",t.pattern.message||"ds.fields.validation.pattern",c=>c==null||t.pattern.value.test(String(c)))),r}function YM(e,t){var n,o;let r=e;return(n=t.dateMin)!=null&&n.value&&(r=r.min(new Date(t.dateMin.value),dt(t.dateMin.message,"ds.fields.validation.dateMin"))),(o=t.dateMax)!=null&&o.value&&(r=r.max(new Date(t.dateMax.value),dt(t.dateMax.message,"ds.fields.validation.dateMax"))),t.disallowPast&&(r=r.min(new Date,dt(t.disallowPast,"ds.fields.validation.disallowPast"))),t.disallowFuture&&(r=r.max(new Date,dt(t.disallowFuture,"ds.fields.validation.disallowFuture"))),r}function XM(e){var r,n,o,l;const t=WM(e);switch(e.type){case"text":case"password":case"textarea":case"search":{let i=Cr().trim();return i=Pr(i,t),Pt(i,t)}case"dni":{let i=Cr().trim();return i=Pr(i,t),i=i.test("dni-valid",dt("ds.fields.validation.invalidID","Documento de identidad inválido"),c=>c==null||c===""?!0:PM(c)),Pt(i,t)}case"email":{let i=Cr().trim().email(dt(t.emailMessage,"ds.fields.validation.invalidEmail"));return i=Pr(i,t),Pt(i,t)}case"url":{let i=Cr().trim().url(dt(t.urlMessage,"ds.fields.validation.invalidUrl"));return i=Pr(i,t),Pt(i,t)}case"tel":{let i=Cr().trim();return i=Pr(i,t),(r=t.pattern)!=null&&r.value||(i=i.matches(zM,dt(t.phoneMessage,"ds.fields.validation.invalidPhone"))),Pt(i,t)}case"iban":{let i=Cr().transform((c,u)=>u===""||u===null||u===void 0?"":typeof u=="string"?Y5(u):c);return i=Pr(i,t),i=i.test("iban-valid",dt("ds.fields.validation.invalidIBAN","IBAN inválido"),c=>c==null||c===""?!0:HM(String(c))),Pt(i,t)}case"number":{let i=P5().transform((c,u)=>{if(u===""||u===null||u===void 0)return;const d=typeof u=="string"?Number(u.replace(",",".")):c;return Number.isNaN(d)?NaN:d}).typeError(dt(t.typeError,"ds.fields.validation.number"));return i=JM(i,t),Pt(i,t)}case"date":{let i=yi().nullable().typeError(dt(t.typeError,"ds.fields.validation.date")).transform((c,u)=>u?new Date(u):null);return i=YM(i,t),Pt(i,t)}case"select":case"optionGroup":{const i=UM(e),c=GM(e);if(i){let u=Sl().of(c.length?Yn().oneOf(c,"ds.fields.validation.invalidOption"):Yn());return t.required&&(u=u.min(1,t.requiredMessage||(typeof t.required=="string"?t.required:"ds.fields.validation.required"))),u}else{let u=Cr().trim();return u=Pr(u,t),c.length&&(u=u.oneOf(c,"ds.fields.validation.invalidOption")),Pt(u,t)}}case"checkbox":{let i=Z5();return t.required&&(i=i.oneOf([!0],t.requiredMessage||"ds.fields.validation.mustCheck")),i}case"file":{const i=e,{exts:c,mimes:u}=KM(i.accept),d=qM(e);let m=Yn().test("file-shape","ds.fields.validation.invalidFile",f=>(f==null,!0));if((n=t.fileMaxSizeMB)!=null&&n.value){const f=Number(t.fileMaxSizeMB.value)*1024*1024,h=t.fileMaxSizeMB.message||"ds.fields.validation.fileMaxSize";m=m.test("file-max-size",h,p=>p?(Array.isArray(p)?p:typeof FileList<"u"&&p instanceof FileList?Array.from(p):[p].filter(Boolean)).every(v=>typeof(v==null?void 0:v.size)!="number"||v.size<=f):!0)}return(c.length||u.length)&&(m=m.test("file-accept","ds.fields.validation.invalidFileType",f=>f?(Array.isArray(f)?f:typeof FileList<"u"&&f instanceof FileList?Array.from(f):[f].filter(Boolean)).every(b=>{var y,R,j,E;const v=((R=(y=b==null?void 0:b.name)==null?void 0:y.toLowerCase)==null?void 0:R.call(y))||"",g=((E=(j=b==null?void 0:b.type)==null?void 0:j.toLowerCase)==null?void 0:E.call(j))||"",x=c.length===0||c.some(N=>v.endsWith(N)),w=u.length===0||u.includes(g);return x&&w}):!0)),typeof d=="number"&&(m=m.test("file-max-files","ds.fields.validation.fileMaxCount",f=>f?(Array.isArray(f)?f:typeof FileList<"u"&&f instanceof FileList?Array.from(f):[f].filter(Boolean)).length<=d:!0)),m=Pt(m,t),m}case"array":{const i=e,c=i.items||[],u=X5(c);let d=Sl().of(ji(u));t.required&&(d=d.min(1,t.requiredMessage||(typeof t.required=="string"?t.required:"ds.fields.validation.required")));const m=i.validation;return(o=m==null?void 0:m.min)!=null&&o.value&&(d=d.min(m.min.value,m.min.message||"ds.fields.validation.minItems")),(l=m==null?void 0:m.max)!=null&&l.value&&(d=d.max(m.max.value,m.max.message||"ds.fields.validation.maxItems")),d}default:{const i=Yn();return Pt(i,t)}}}function X5(e){const t={};for(const r of e){const n=r;n!=null&&n.name&&(t[n.name]=XM(n))}return t}function ki(e){const t=X5(e.fields);return ji(t)}const Qc=e=>{let t;const r=new Set,n=(d,m)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const h=t;t=m??(typeof f!="object"||f===null)?f:Object.assign({},t,f),r.forEach(p=>p(t,h))}},o=()=>t,c={setState:n,getState:o,getInitialState:()=>u,subscribe:d=>(r.add(d),()=>r.delete(d))},u=t=e(n,o,c);return c},QM=(e=>e?Qc(e):Qc),eO=e=>e;function tO(e,t=eO){const r=k.useSyncExternalStore(e.subscribe,k.useCallback(()=>t(e.getState()),[e,t]),k.useCallback(()=>t(e.getInitialState()),[e,t]));return k.useDebugValue(r),r}const e0=e=>{const t=QM(e),r=n=>tO(t,n);return Object.assign(r,t),r},Q5=(e=>e?e0(e):e0),Jr=Q5(e=>({isActive:!1,formValues:{},systemContext:{},setRuntimeState:t=>e(r=>({...r,...t})),reset:()=>e({isActive:!1,formValues:{},systemContext:{}})}));function Nl(e,t){return e?typeof e!="string"?String(e):e.replace(/\{\{([^}]+)\}\}/g,(r,n)=>{let l=n.trim().split(".").reduce((i,c)=>{if(!i)return;if(i[c]!==void 0)return i[c];const u=c.toLowerCase(),d=Object.keys(i).find(m=>m.toLowerCase()===u);return d?i[d]:void 0},t);return l!=null?String(l):r}):""}function xr({options:e,value:t,onChange:r,children:n,className:o,contentClassName:l}){const i=k.useRef(null),[c,u]=k.useState({left:0,width:0}),[d,m]=k.useState(!1),[f,h]=k.useState(!1),p=()=>{if(i.current){const{scrollLeft:v,scrollWidth:g,clientWidth:x}=i.current;m(v>0),h(v<g-x-1)}};k.useLayoutEffect(()=>{const v=i.current;if(!v)return;const g=()=>{const x=v.querySelector(`[data-value="${t}"]`);x&&u({left:x.offsetLeft,width:x.offsetWidth})};return g(),p(),window.addEventListener("resize",g),window.addEventListener("resize",p),()=>{window.removeEventListener("resize",g),window.removeEventListener("resize",p)}},[t,e]);const b=v=>{i.current&&i.current.scrollBy({left:v==="left"?-200:200,behavior:"smooth"})};return s.jsxs("div",{className:o,children:[s.jsxs("div",{className:"relative border-b border-[var(--color-ds-border-default-50)] group",children:[d&&s.jsx("div",{className:"absolute left-0 top-0 bottom-0 z-20 flex items-center bg-gradient-to-r from-[var(--color-ds-background-page)] to-transparent pr-4 pl-1 opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:s.jsx("button",{type:"button",onClick:()=>b("left"),className:"p-1 rounded-full bg-[var(--color-ds-background-surface)] shadow-sm border border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-primary)] hover:bg-[var(--color-ds-button-hover-bg)] hover:text-white transition-colors",children:s.jsx($d,{className:"w-4 h-4"})})}),s.jsx("div",{ref:i,onScroll:p,className:"overflow-x-auto scrollbar-hidden flex items-center w-full relative",style:{scrollBehavior:"smooth"},children:s.jsxs("div",{className:"relative flex min-w-full px-1",children:[e.map(v=>{const g=v.value===t;return s.jsxs("button",{"data-value":v.value,role:"tab","aria-selected":g,onClick:()=>!v.disabled&&r(v.value),type:"button",className:be("relative z-10 whitespace-nowrap px-4 py-2 transition-colors duration-150 ease-in-out font-medium text-sm focus:outline-none",g?"text-[var(--color-ds-background-accent)]":"text-[var(--color-ds-text-secondary)] hover:text-[var(--color-ds-text-primary)]",v.disabled&&"opacity-50 cursor-not-allowed"),disabled:v.disabled,children:[v.icon&&s.jsx("span",{className:"mr-2 -ml-1 inline-block align-text-bottom",children:v.icon}),v.label]},v.value)}),s.jsx("span",{className:"absolute bottom-0 h-0.5 bg-[var(--color-ds-background-accent)] transition-all duration-200 ease-in-out z-20",style:{left:c.left,width:c.width}})]})}),f&&s.jsx("div",{className:"absolute right-0 top-0 bottom-0 z-20 flex items-center bg-gradient-to-l from-[var(--color-ds-background-page)] to-transparent pl-4 pr-1 opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:s.jsx("button",{type:"button",onClick:()=>b("right"),className:"p-1 rounded-full bg-[var(--color-ds-background-surface)] shadow-sm border border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-primary)] hover:bg-[var(--color-ds-button-hover-bg)] hover:text-white transition-colors",children:s.jsx(qo,{className:"w-4 h-4"})})})]}),s.jsx("div",{className:be("mt-4",l),children:n[t]})]})}const dn={sm:"text-ds-sm",md:"text-ds-md",lg:"text-ds-lg"},Ga={sm:"h-5",md:"h-10",lg:"h-12"},Ka={sm:"px-2",md:"px-2.5",lg:"px-3"},Ja={sm:"1.5rem",md:"2.5rem",lg:"3rem"},Ya={sm:"pr-9",md:"pr-11",lg:"pr-12"},rO={sm:"h-6 w-6",md:"h-8 w-8",lg:"h-10 w-10"};function Xa({id:e,size:t,disabled:r,error:n,reserveErrorSpace:o,className:l,suffixButton:i,children:c,showDropdownIndicator:u}){var d;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:be("relative w-full",l),children:[c,u&&!i&&s.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-2 flex items-center",children:s.jsx(Kt,{className:"h-4 w-4 text-[var(--color-ds-text-secondary)]"})}),i&&s.jsx("div",{className:"pointer-events-none absolute flex items-center",style:{top:2,bottom:2,right:4},children:s.jsx("div",{className:"pointer-events-auto",children:k.isValidElement(i)?k.cloneElement(i,{className:be(rO[t],(d=i.props)==null?void 0:d.className)}):i})})]}),o?s.jsx("div",{className:"h-[1em]",children:n!=null&&n.message?s.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)] h-[1em]",children:n.message}):s.jsx("span",{"aria-hidden":"true",children:" "})}):n!=null&&n.message?s.jsx("div",{className:"pt-1",children:s.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)] h-[1em]",children:n.message})}):null]})}function t0(e,t){k.useEffect(()=>{const r=n=>{e.current&&(e.current.contains(n.target)||t())};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[t,e])}function Ue(e){const{control:t,name:r,rules:n,defaultValue:o,options:l=[],loadOptions:i,reloadDeps:c=[],value:u,onChange:d,size:m="sm",width:f="100%",label:h,labelHidden:p=!1,info:b,infoHeader:v,hasError:g=!1,errorMessage:x="",reserveErrorSpace:w,disableErrorPlaceholder:y,disabled:R=!1,className:j,suffixButton:E,loading:N=!1,coerceFirstValid:S=!0,mode:O="menu",renderTrigger:I,renderOption:Z,popupWidth:L,triggerClassName:V,onBlur:M,searchable:P=!1,searchPlaceholder:re="Buscar...",noOptionsText:Q="No se encontraron resultados"}=e,se=k.useId(),oe=r||se,[Y,A]=k.useState(l),[$,ne]=k.useState(!!i);k.useEffect(()=>{if(!i){A(l);return}ne(!0),i().then(ce=>A(ce)).finally(()=>ne(!1))},[i,...c]),k.useEffect(()=>{i||A(l)},[l,i]);const G=ce=>ce.find(xe=>xe.value!==""&&xe.value!==void 0)??ce[0],X=ce=>String(ce??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim(),me=(ce,xe)=>{const C=X(xe);return C?ce.filter(q=>[q.label,q.value,q.name,q.code,q.text,q.descripcion,q.description].map(X).join(" ").includes(C)):ce},pe=typeof w=="boolean"?w:!!t,ue=f&&(f.includes(" ")||f.startsWith("w-")||f.startsWith("max-w-")||f.startsWith("min-w-")),fe=ue?{maxWidth:"100%"}:{width:f,maxWidth:"100%"},ie=be("flex flex-col",ue&&f,j);if(t&&r){const{field:ce,fieldState:xe}=m5({name:r,control:t,rules:n,defaultValue:o});k.useEffect(()=>{if(!$&&Y.length>0&&S){const q=ce.value,te=Y.some(W=>String(W.value)===String(q));(q===void 0||!te)&&ce.onChange(G(Y).value)}},[Y,$,ce,S]);const C=h&&!p&&s.jsx(Gt,{id:oe,text:h,size:m,info:b,infoHeader:v});if((O??"native")==="menu"){const[q,te]=k.useState(!1),[W,H]=k.useState(""),K=k.useRef(null);t0(K,()=>{te(!1),H("")});const _=Y.find(B=>String(B.value)===String(ce.value)),U=P?me(Y,W):Y;return s.jsxs("div",{className:ie,style:fe,children:[C,N||$?s.jsx(pr,{width:"100%",height:Ja[m],variant:"rect",className:"rounded-lg"}):s.jsx(Xa,{id:oe,size:m,disabled:R,error:xe.error,reserveErrorSpace:typeof y=="boolean"?!y:pe,className:j,suffixButton:E,showDropdownIndicator:!0,children:s.jsxs("div",{className:"relative w-full",ref:K,children:[s.jsx("button",{type:"button",onClick:()=>{R||te(B=>{const T=!B;return T||H(""),T})},onBlur:()=>{ce.onBlur(),M==null||M()},className:be("box-border w-full rounded-lg border bg-[var(--color-ds-background-page)] outline-none transition appearance-none text-left flex items-center",dn[m],Ga[m],Ka[m],E&&Ya[m],xe.error?"border-[var(--color-ds-border-error)]":"border-[var(--color-ds-border-default)]",R?"bg-[var(--color-ds-background-disabled)] border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-primary)] cursor-not-allowed":"text-[var(--color-ds-text-primary)] hover:border-[var(--color-ds-border-default-hover)]",V),"aria-haspopup":"listbox","aria-expanded":q,children:I?I(_):(_==null?void 0:_.label)??"—"}),q&&s.jsxs("div",{role:"listbox",className:"custom-scroll absolute z-50 mt-1 rounded-xl border border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-page)] shadow-xl p-1 max-h-72 overflow-auto",style:{width:L??"100%"},children:[P&&s.jsx("div",{className:"sticky top-0 z-10 bg-[var(--color-ds-background-page)] p-1",children:s.jsx("input",{type:"text",value:W,autoFocus:!0,onChange:B=>H(B.target.value),onClick:B=>B.stopPropagation(),onKeyDown:B=>B.stopPropagation(),placeholder:re,className:"w-full rounded-lg border border-[var(--color-ds-border-default)] bg-[var(--color-ds-background-page)] px-2 py-2 text-sm outline-none"})}),U.length>0?U.map(B=>{const T=String(B.value)===String(ce.value);return s.jsx("button",{role:"option","aria-selected":T,type:"button",onClick:()=>{ce.onChange(B.value),te(!1),H("")},className:be("w-full rounded-lg px-2 py-1.5 text-left transition-all duration-200",dn[m],T?"bg-[var(--color-ds-background-neutral)] font-medium text-[var(--color-ds-text-primary)]":"text-[var(--color-ds-text-secondary)] hover:bg-[var(--color-ds-background-neutral-hover)] hover:text-[var(--color-ds-text-primary)] hover:pl-3"),children:Z?Z(B,T):B.label},B.value)}):s.jsx("div",{className:"px-2 py-2 text-sm text-[var(--color-ds-text-secondary)]",children:Q})]})]})})]})}return s.jsxs("div",{className:ie,style:fe,children:[C,N||$?s.jsx(pr,{width:"100%",height:Ja[m],variant:"rect",className:"rounded-lg"}):s.jsx(Xa,{id:oe,size:m,disabled:R,error:xe.error,reserveErrorSpace:typeof y=="boolean"?!y:pe,className:j,suffixButton:E,showDropdownIndicator:!0,children:s.jsx("select",{id:oe,value:ce.value,onChange:q=>ce.onChange(q.target.value),onBlur:()=>{ce.onBlur(),M==null||M()},disabled:R,className:be("box-border w-full rounded-lg border bg-[var(--color-ds-background-page)] outline-none transition appearance-none leading-none",dn[m],Ga[m],Ka[m],E&&Ya[m],xe.error?"border-[var(--color-ds-border-error)]":"border-[var(--color-ds-border-default)]",R?"bg-[var(--color-ds-background-disabled)] border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-primary)] cursor-not-allowed":"text-[var(--color-ds-text-primary)]",V),children:Y.map(q=>s.jsx("option",{value:q.value,className:"bg-[var(--color-ds-background-page)] text-[var(--color-ds-text-primary)]",children:q.label},q.value))})})]})}k.useEffect(()=>{if(!t&&Y.length>0&&S){const ce=Y.some(C=>String(C.value)===String(u));(u===void 0||u===""||!ce)&&d&&d(G(Y).value)}},[Y,u,d,t,S]);const ke=h&&!p&&s.jsx(Gt,{id:oe,text:h,size:m,info:b,infoHeader:v});if((O??"native")==="menu"){const[ce,xe]=k.useState(!1),[C,q]=k.useState(""),te=k.useRef(null);t0(te,()=>{xe(!1),q("")});const W=Y.find(K=>String(K.value)===String(u)),H=P?me(Y,C):Y;return s.jsxs("div",{className:ie,style:fe,children:[ke,N||$?s.jsx(pr,{width:"100%",height:Ja[m],variant:"rect",className:"rounded-lg"}):s.jsx(Xa,{id:oe,size:m,disabled:R,error:g?{message:x}:void 0,reserveErrorSpace:typeof y=="boolean"?!y:!!(w??!1),className:j,suffixButton:E,showDropdownIndicator:!0,children:s.jsxs("div",{className:"relative w-full",ref:te,children:[s.jsx("button",{type:"button",onClick:()=>{R||xe(K=>{const _=!K;return _||q(""),_})},onBlur:M,className:be("box-border w-full rounded-lg border bg-[var(--color-ds-background-page)] outline-none transition appearance-none text-left flex items-center",dn[m],Ga[m],Ka[m],E&&Ya[m],g?"border-[var(--color-ds-border-error)]":"border-[var(--color-ds-border-default)]",R?"bg-[var(--color-ds-background-disabled)] border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-primary)] cursor-not-allowed":"text-[var(--color-ds-text-primary)] hover:border-[var(--color-ds-border-default-hover)]",V),"aria-haspopup":"listbox","aria-expanded":ce,children:I?I(W):(W==null?void 0:W.label)??"—"}),ce&&s.jsxs("div",{role:"listbox",className:"custom-scroll absolute z-50 mt-1 rounded-xl border border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-page)] shadow-xl p-1 max-h-72 overflow-auto",style:{width:L??"100%"},children:[P&&s.jsx("div",{className:"sticky top-0 z-10 bg-[var(--color-ds-background-page)] p-1",children:s.jsx("input",{type:"text",value:C,onChange:K=>q(K.target.value),onClick:K=>K.stopPropagation(),placeholder:re,className:"w-full rounded-lg border border-[var(--color-ds-border-default)] bg-[var(--color-ds-background-page)] px-2 py-2 text-sm outline-none"})}),H.length>0?H.map(K=>{const _=String(K.value)===String(u);return s.jsx("button",{role:"option","aria-selected":_,type:"button",onClick:()=>{d==null||d(K.value),xe(!1),q("")},className:be("w-full rounded-lg px-2 py-1.5 text-left transition-all duration-200",dn[m],_?"bg-[var(--color-ds-background-neutral)] font-medium text-[var(--color-ds-text-primary)]":"text-[var(--color-ds-text-secondary)] hover:bg-[var(--color-ds-background-neutral-hover)] hover:text-[var(--color-ds-text-primary)] hover:pl-3"),children:Z?Z(K,_):K.label},K.value)}):s.jsx("div",{className:"px-2 py-2 text-sm text-[var(--color-ds-text-secondary)]",children:Q})]})]})})]})}return s.jsxs("div",{className:ie,style:fe,children:[ke,N||$?s.jsx(pr,{width:"100%",height:Ja[m],variant:"rect",className:"rounded-lg"}):s.jsx(Xa,{id:oe,size:m,disabled:R,error:g?{message:x}:void 0,reserveErrorSpace:typeof y=="boolean"?!y:!!(w??!1),className:j,suffixButton:E,showDropdownIndicator:!0,children:s.jsx("select",{id:oe,value:u,onChange:ce=>d==null?void 0:d(ce.target.value),onBlur:M,disabled:R,className:be("box-border w-full rounded-lg border bg-[var(--color-ds-background-page)] outline-none transition appearance-none leading-none",dn[m],Ga[m],Ka[m],E&&Ya[m],g?"border-[var(--color-ds-border-error)]":"border-[var(--color-ds-border-default)]",R?"bg-[var(--color-ds-background-disabled)] border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-primary)] cursor-not-allowed":"text-[var(--color-ds-text-primary)]"),children:Y.map(ce=>s.jsx("option",{value:ce.value,className:"bg-[var(--color-ds-background-page)] text-[var(--color-ds-text-primary)]",children:ce.label},ce.value))})})]})}const r0={sm:"text-ds-sm",md:"text-ds-md",lg:"text-ds-lg"};function n0(e){var t;e.preventDefault(),e.stopPropagation(),(t=e.nativeEvent)!=null&&t.stopImmediatePropagation&&e.nativeEvent.stopImmediatePropagation()}function Ei({groupLabel:e,inputs:t=[],separator:r=s.jsx("span",{className:"px-1 select-none",children:"/"}),useSeparator:n=!1,className:o,showVisibleLabel:l=!1,size:i="sm",width:c,respectChildWidths:u=!1}){const d=t.length,m=c&&(c.includes(" ")||c.startsWith("w-")||c.startsWith("max-w-")||c.startsWith("min-w-")),f=m?void 0:c?{width:c}:void 0;return s.jsxs("div",{"data-input-group-root":!0,role:"group",className:be("flex flex-col w-full",m&&c,o),style:f,onDoubleClick:n0,onDoubleClickCapture:n0,onClickCapture:h=>{var v;const p=h.target;!!((v=p==null?void 0:p.closest)!=null&&v.call(p,'input,select,textarea,button,[data-interactive="true"]'))||h.stopPropagation()},children:[s.jsx("label",{className:be("sr-only pb-2",r0[i]),children:e}),l&&s.jsx("label",{className:be("pb-2",r0[i]),children:e}),s.jsx("div",{className:"flex items-stretch flex-nowrap w-full min-w-0",children:t.map((h,p)=>{const{width:b,className:v,options:g,loadOptions:x,info:w,infoHeader:y,...R}=h,j=Array.isArray(g)||typeof x=="function";let E="rounded-lg";!n&&d>1&&(p===0?E="rounded-l-lg rounded-r-none":p===d-1?E="rounded-r-lg rounded-l-none !rounded-l-none":E="rounded-none !rounded-l-none !rounded-r-none");const N=u?b:void 0,S=typeof N=="string"&&N.split(/\s+/).some(L=>L.startsWith("w-")||L.includes(":w-")),O=be("inline-flex items-stretch",N?"flex-shrink-0":"flex-1 min-w-0",typeof N=="string"&&S?N:void 0,!n&&d>1&&p>0?"-ml-px focus-within:z-10 relative":void 0),I=N?typeof N=="string"&&S?void 0:{width:N}:void 0,Z=be(v,"w-full",E);return s.jsxs(k.Fragment,{children:[s.jsx("div",{className:O,style:I,children:j?s.jsx(Ue,{...R,size:i,className:v,triggerClassName:be("w-full",E),options:g,loadOptions:x,"data-interactive":"true",info:w,infoHeader:y,mode:"menu",searchable:!0,searchPlaceholder:$c("ds.fields.defaults.search.placeholder"),noOptionsText:$c("ds.fields.defaults.search.noMatches")}):s.jsx(Ee,{...R,size:i,className:Z,"data-interactive":"true",info:w,infoHeader:y})}),n&&p<d-1&&s.jsx("div",{className:"flex items-center flex-shrink-0 px-1 select-none",children:r})]},p)})})]})}const nO={sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},aO={sm:"w-3 h-3",md:"w-3.5 h-3.5",lg:"w-4 h-4"};function ns({groupLabel:e,options:t,control:r,name:n,rules:o,defaultValue:l,multiple:i=!0,size:c="sm",vertical:u=!0,className:d,showVisibleLabel:m=!0,disabled:f=!1,hasError:h=!1,errorMessage:p}){return s.jsx(ht,{name:n,control:r,rules:o,defaultValue:l,render:({field:b,fieldState:v})=>{const{value:g,onChange:x}=b,w=v.error,y=N=>{var S;return i?Array.isArray(g)&&((S=g==null?void 0:g.includes)==null?void 0:S.call(g,N)):g===N},R=N=>{if(!f)if(i){const S=Array.isArray(g)?[...g]:[],O=S.indexOf(N);O>=0?S.splice(O,1):S.push(N),x(S)}else x(N)},j=h||!!w,E=(w==null?void 0:w.message)||p;return s.jsxs("fieldset",{className:be("w-full flex flex-col gap-1",d),"aria-invalid":j||void 0,disabled:f,children:[e&&s.jsx("legend",{className:be("mb-1 text-ds-sm text-[var(--color-ds-text-primary)]",!m&&"sr-only"),children:e}),s.jsx("div",{className:be(u?"flex flex-col gap-2":"flex flex-wrap gap-2"),children:t.map(N=>{const S=y(N.value),O=f||!!(N!=null&&N.disabled),I=be("inline-flex items-center justify-center border transition-all duration-150",i?"rounded-[6px]":"rounded-full",nO[c],"bg-[var(--color-ds-background-page)]","border-[var(--color-ds-border-default-50)]","shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-ds-border-default)20%,transparent)]","peer-focus-visible:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-[var(--color-ds-border-default)]","hover:border-[var(--color-ds-border-default)]",i&&S&&"bg-[var(--color-ds-button-primary-bg)] border-[var(--color-ds-button-primary-bg)]",!i&&S&&"border-[var(--color-ds-button-primary-bg)]",j&&"border-[var(--color-ds-border-error)] shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-ds-border-error)30%,transparent)]",O&&"opacity-60 cursor-not-allowed"),Z=be("text-ds-sm text-[var(--color-ds-text-primary)]",O&&"text-[var(--color-ds-text-secondary)]"),L=be(aO[c],"text-[var(--color-ds-button-primary-text)] transition-all duration-150",S?"opacity-100 scale-100":"opacity-0 scale-75"),V=be(c==="sm"?"w-2 h-2":c==="md"?"w-2.5 h-2.5":"w-3 h-3","rounded-full bg-[var(--color-ds-button-primary-bg)] transition-all duration-150",S?"opacity-100 scale-100":"opacity-0 scale-0");return s.jsxs("label",{className:be("inline-flex items-center gap-2 cursor-pointer select-none rounded-md px-1 py-1","hover:bg-[color-mix(in_srgb,var(--color-ds-border-default)6%,transparent)]",O&&"cursor-not-allowed hover:bg-transparent"),children:[s.jsxs("span",{className:"relative inline-flex items-center justify-center",children:[s.jsx("input",{type:i?"checkbox":"radio",name:n,value:N.value,checked:S,onChange:()=>R(N.value),disabled:O,className:"peer sr-only"}),s.jsx("span",{"aria-hidden":!0,className:I,children:i?s.jsx(vi,{className:L}):s.jsx("span",{className:V})})]}),s.jsx("span",{className:Z,children:N.label})]},String(N.value))})}),j&&!!E&&s.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)] mt-1",children:E})]})}})}function oO(e){function t(i){var c,u;for(const d of Object.keys(i)){if((c=i[d])!=null&&c.types||(u=i[d])!=null&&u.message)return d;if(typeof i[d]=="object"){const m=t(i[d]);if(m)return`${d}.${m}`}}return null}const r=t(e);if(!r)return;const n=`[name="${r}"]`,o=`[name^="${r}["], [name^="${r}."]`,l=document.querySelector(n)??document.querySelector(o);l&&(l.scrollIntoView({behavior:"smooth",block:"center"}),l.focus({preventScroll:!0}))}const sO={success:"bg-green-100 border-green-500 text-green-800",error:"bg-red-100 border-red-500 text-red-800",info:"bg-blue-100 border-blue-500 text-blue-800",warning:"bg-yellow-100 border-yellow-500 text-yellow-800"},e1=({id:e,message:t,variant:r="info",duration:n=5e3,onClose:o})=>(k.useEffect(()=>{const l=setTimeout(()=>o(e),n);return()=>clearTimeout(l)},[e,n,o]),s.jsxs("div",{className:be("w-80 max-w-full border-l-4 rounded shadow-md p-4 mb-2 flex justify-between items-start",sO[r]),role:"alert","aria-live":"assertive",children:[s.jsx("span",{className:"flex-1",children:t}),s.jsx("button",{onClick:()=>o(e),className:"ml-4 text-xl font-bold leading-none focus:outline-none",children:"×"})]})),mt=[];for(let e=0;e<256;++e)mt.push((e+256).toString(16).slice(1));function lO(e,t=0){return(mt[e[t+0]]+mt[e[t+1]]+mt[e[t+2]]+mt[e[t+3]]+"-"+mt[e[t+4]]+mt[e[t+5]]+"-"+mt[e[t+6]]+mt[e[t+7]]+"-"+mt[e[t+8]]+mt[e[t+9]]+"-"+mt[e[t+10]]+mt[e[t+11]]+mt[e[t+12]]+mt[e[t+13]]+mt[e[t+14]]+mt[e[t+15]]).toLowerCase()}let Fs;const iO=new Uint8Array(16);function cO(){if(!Fs){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Fs=crypto.getRandomValues.bind(crypto)}return Fs(iO)}const dO=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),a0={randomUUID:dO};function uO(e,t,r){var o;e=e||{};const n=e.random??((o=e.rng)==null?void 0:o.call(e))??cO();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,lO(n)}function fO(e,t,r){return a0.randomUUID&&!e?a0.randomUUID():uO(e)}const t1=k.createContext(null),Zr=()=>{const e=k.useContext(t1);if(!e)throw new Error("useToast debe usarse dentro de <ToastProvider>");return e},mO=({children:e})=>{const[t,r]=k.useState([]),n=(l,i="info",c=5e3)=>{const u=fO();r(d=>[...d,{id:u,message:l,variant:i,duration:c}])},o=l=>{r(i=>i.filter(c=>c.id!==l))};return s.jsxs(t1.Provider,{value:{show:n},children:[e,s.jsx("div",{className:"fixed top-4 right-4 z-50 flex flex-col items-end",children:t.map(l=>s.jsx(e1,{id:l.id,message:l.message,variant:l.variant,duration:l.duration,onClose:o},l.id))})]})},hO=e=>e.type==="inputGroup",pO=e=>e.type==="button",gO=e=>!hO(e)&&!pO(e);function r1(e){const t=Array.isArray(e)?e:[];return k.useMemo(()=>{const r={};for(const n of t)gO(n)&&n.name&&(r[n.name]=n);return r},[t])}const n1=k.createContext(null);function a1({children:e,value:t}){return s.jsx(n1.Provider,{value:t,children:e})}function At(){const e=k.useContext(n1);if(!e)throw new Error("useAdapters debe usarse dentro de <AdaptersProvider />");return e}const vO=e=>!!e&&typeof e.then=="function";function bO(e){return Array.isArray(e)?e.length>0&&typeof e[0]=="object"&&e[0]!==null?e.map(t=>{var o;if("label"in t&&"value"in t)return t;const n=(o=Object.entries(t)[0])==null?void 0:o[1];return{label:String(n??JSON.stringify(t)),value:String(n??"")}}):e.map(t=>({label:String(t),value:t})):[]}function o1(e){const{services:t}=At(),[r,n]=k.useState({}),[o,l]=k.useState(0),i=k.useRef(!0);k.useEffect(()=>(i.current=!0,()=>{i.current=!1}),[]);const c=k.useMemo(()=>e.filter(u=>u.type==="select"&&!u.options&&typeof u.optionSource=="string"&&u.name),[e]);return k.useEffect(()=>{if(c.length===0)return;let u=!1;return(async()=>{l(d=>d+1);try{const d=await Promise.all(c.map(async m=>{var g;const f=m.name,h=m.optionSource,p=(g=t==null?void 0:t.registry)==null?void 0:g[h];if(!p)return[f,[]];const b=vO(p)?await p:await p(),v=bO(b);return[f,v]}));if(u||!i.current)return;n(m=>{const f={...m};for(const[h,p]of d)f[h]=[...p];return f})}finally{!u&&i.current&&l(d=>Math.max(0,d-1))}})(),()=>{u=!0}},[c,t==null?void 0:t.registry]),{optionsMap:r,loadingCount:o}}const xO=e=>e.type==="inputGroup",wO=e=>e.type==="button",yO=e=>!xO(e)&&!wO(e);function jO(e){return typeof e=="object"&&e!==null}const kO=e=>{const t=e.disabledWhen;if(!jO(t))return!1;const r="watchField"in t,n="rule"in t;return r&&!n};function s1(e,t){const r=Array.isArray(e)?e:[],n=k.useMemo(()=>r.filter(yO).filter(kO),[r]),o=k.useMemo(()=>n.map(u=>u.disabledWhen.watchField),[n]),l=mi({control:t,name:o,compute:u=>u}),i=Array.isArray(l)?l:[],c={};return n.forEach((u,d)=>{const m=i[d];c[u.name??`__unnamed_${d}`]=m===u.disabledWhen.watchValue}),c}const EO={sm:"text-ds-sm",md:"text-ds-sm",lg:"text-ds-sm"},RO={sm:"px-2 py-1.5",md:"px-3 py-2",lg:"px-4 py-3"};function ar({control:e,name:t,rules:r,defaultValue:n,size:o="sm",width:l="100%",label:i,labelHidden:c=!1,hasError:u=!1,errorMessage:d="",maxLength:m,showCounter:f=!1,className:h,suffixButton:p,labelPrefixIcon:b,labelSuffixIcon:v,info:g,infoHeader:x,infoAriaLabel:w,prefixIcon:y,suffixIcon:R,reserveErrorSpace:j,disableErrorPlaceholder:E,id:N,...S}){const O=k.useId(),I=N||O,[Z,L]=k.useState(String(n??S.value??"")),V=typeof j=="boolean"?j:typeof E=="boolean"?!E:!!e,M=be("box-border bg-[var(--color-ds-background-page)] w-full rounded-lg border outline-none transition","placeholder-[var(--color-ds-text-secondary)] text-[var(--color-ds-text-primary)]",EO[o],RO[o],u?"border-[var(--color-ds-border-error)]":"border-[var(--color-ds-border-default)]",S.disabled&&"bg-[var(--color-ds-background-disabled)] border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-secondary)] cursor-not-allowed"),P=y?"pl-9":"",re=R?"pr-9":"",Q=A=>{var $;typeof m=="number"&&A.target.value.length>m||(L(A.target.value),($=S.onChange)==null||$.call(S,A))},se=l&&(l.includes(" ")||l.startsWith("w-")||l.startsWith("max-w-")||l.startsWith("min-w-")),oe=se?void 0:{width:l},Y=be("flex flex-col",se&&l,h);return k.useEffect(()=>{n!==void 0&&L(String(n??""))},[n]),e&&t?s.jsx(ht,{name:t,control:e,rules:r,defaultValue:n??"",render:({field:A,fieldState:$})=>{var ne;return s.jsxs("div",{className:Y,style:oe,children:[!c&&i&&s.jsx(Gt,{id:I,text:i,size:o,prefixIcon:b,suffixIcon:v,info:g,infoHeader:x,infoAriaLabel:w}),s.jsxs("div",{className:"flex items-stretch gap-2",children:[s.jsxs("div",{className:"relative w-full",children:[y&&s.jsx("span",{className:"absolute left-2 top-2.5",children:s.jsx(yt,{component:y,size:o,className:"text-[var(--color-ds-text-secondary)]"})}),s.jsx("textarea",{id:I,"aria-invalid":!!$.error,className:be(M,P,re),maxLength:m,...A,placeholder:S.disabled?"":S.placeholder,onChange:G=>{A.onChange(G),f&&L(G.target.value)}}),R&&s.jsx("span",{className:"absolute right-2 top-2.5",children:s.jsx(yt,{component:R,size:o,className:"text-[var(--color-ds-text-secondary)]"})})]}),p?s.jsx("div",{className:"shrink-0",children:p}):null]}),s.jsxs("div",{className:"flex justify-between pt-1 h-[1em]",children:[V?$.error?s.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)]",children:$.error.message}):s.jsx("span",{"aria-hidden":"true",children:" "}):$.error?s.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)]",children:$.error.message}):s.jsx("span",{"aria-hidden":"true",children:" "}),f&&typeof m=="number"&&s.jsxs("span",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:[((ne=A.value)==null?void 0:ne.length)??0,"/",m]})]})]})}}):s.jsxs("div",{className:Y,style:oe,children:[!c&&i&&s.jsx(Gt,{id:I,text:i,size:o,prefixIcon:b,suffixIcon:v,info:g,infoHeader:x,infoAriaLabel:w}),s.jsxs("div",{className:"flex items-stretch gap-2",children:[s.jsxs("div",{className:"relative w-full",children:[y&&s.jsx("span",{className:"absolute left-2 top-2.5",children:s.jsx(yt,{component:y,size:o,className:"text-[var(--color-ds-text-secondary)]"})}),s.jsx("textarea",{id:I,className:be(M,P,re),value:Z,onChange:Q,maxLength:m,...S,placeholder:S.disabled?"":S.placeholder}),R&&s.jsx("span",{className:"absolute right-2 top-2.5",children:s.jsx(yt,{component:R,size:o,className:"text-[var(--color-ds-text-secondary)]"})})]}),p?s.jsx("div",{className:"shrink-0",children:p}):null]}),s.jsxs("div",{className:"flex justify-between pt-1 h-[1em]",children:[V?u&&d?s.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)]",children:d}):s.jsx("span",{"aria-hidden":"true",children:" "}):u&&d?s.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)]",children:d}):s.jsx("span",{"aria-hidden":"true",children:" "}),f&&typeof m=="number"&&s.jsxs("span",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:[Z.length,"/",m]})]})]})}const CO={sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},SO={sm:"w-3 h-3",md:"w-3.5 h-3.5",lg:"w-4 h-4"};function tt({control:e=null,name:t,rules:r,defaultValue:n=!1,label:o,labelHidden:l=!1,disabled:i=!1,size:c="sm",className:u,hasError:d=!1,errorMessage:m="",reserveErrorSpace:f,disableErrorPlaceholder:h,checked:p,indeterminate:b,onChange:v}){const g=be("text-[var(--color-ds-text-primary)] text-ds-sm",i&&"text-[var(--color-ds-text-secondary)]",l&&"sr-only"),x=typeof f=="boolean"?f:typeof h=="boolean"?!h:!!e,w=(y,R,j)=>{const E=d||!!j,N=(j==null?void 0:j.message)||m,S=be("inline-flex items-center justify-center rounded-[6px] border transition-all duration-150",CO[c],"bg-[var(--color-ds-background-page)]","border-[var(--color-ds-border-default-50)]","shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-ds-border-default)20%,transparent)]","peer-focus-visible:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-[var(--color-ds-border-default)]","hover:border-[var(--color-ds-border-default)]",(y||b)&&"bg-[var(--color-ds-button-primary-bg)] border-[var(--color-ds-button-primary-bg)]",E&&"border-[var(--color-ds-border-error)] shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-ds-border-error)30%,transparent)]",i&&"opacity-60 cursor-not-allowed"),O=be(SO[c],"text-[var(--color-ds-button-primary-text)]","transition-all duration-150",y||b?"opacity-100 scale-100":"opacity-0 scale-75");return s.jsxs("div",{className:be("flex flex-col gap-1",u),children:[k.createElement(typeof o=="string"?"label":"div",{className:be("inline-flex items-center gap-2 cursor-pointer select-none",i&&"cursor-not-allowed")},s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"relative inline-flex items-center justify-center",children:[s.jsx("input",{id:t,type:"checkbox",className:"peer sr-only",checked:y,ref:I=>{I&&(I.indeterminate=!!b)},onChange:I=>R(I.target.checked),disabled:i}),s.jsx("span",{"aria-hidden":!0,className:S,children:b?s.jsx("div",{className:"bg-white h-0.5 w-[60%] rounded-full"}):s.jsx(vi,{className:O})})]}),o&&s.jsx("span",{className:g,children:o})]})),x?s.jsx("div",{className:"h-[1em]",children:E&&N?s.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)] h-[1em]",children:N}):s.jsx("span",{"aria-hidden":"true",children:" "})}):E&&N?s.jsx("div",{className:"pt-1",children:s.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)] h-[1em]",children:N})}):null]})};return e?s.jsx(ht,{name:t||"",control:e,rules:r,defaultValue:n,render:({field:y,fieldState:R})=>{const j=R.error;return w(!!y.value,E=>y.onChange(E),j)}}):w(!!p,y=>v==null?void 0:v(y))}function Ri({name:e,control:t,searchFn:r,resolveByValue:n,label:o,size:l="sm",width:i="100%",disabled:c=!1,searchMode:u="button",minChars:d=3,debounceMs:m=600,labelPrefixIcon:f,labelSuffixIcon:h,prefixIcon:p,suffixIcon:b,reserveErrorSpace:v,disableErrorPlaceholder:g}){const x=_r(),{watch:w,getValues:y,setValue:R}=x,j=mi({control:t,name:e}),[E,N]=k.useState([]),[S,O]=k.useState(!1),[I,Z]=k.useState(!1),[L,V]=k.useState(""),M=k.useRef(null),P=k.useRef(null),re=k.useRef(!1),Q=k.useRef(!1),se=k.useRef(!0),oe=k.useMemo(()=>{const fe=new Map;for(const ie of E)fe.set(String(ie.value).trim(),ie.label??"");return fe},[E]),Y=async fe=>{const ie=(fe??"").trim();if(!ie){N([]),Z(!1);return}O(!0);try{const ke=await r(ie,{watch:w,getValues:y});N(ke??[]),Z(!0)}finally{O(!1)}};k.useEffect(()=>{function fe(ie){M.current&&!M.current.contains(ie.target)&&Z(!1)}if(I)return document.addEventListener("mousedown",fe),()=>document.removeEventListener("mousedown",fe)},[I]);const[A,$]=k.useState({});k.useEffect(()=>{if(re.current)return;const ie=(j?String(j):"").trim();if(!ie){L!==""&&V(""),Z(!1);return}const ke=oe.get(ie);if(ke){L!==ke&&(V(ke),se.current=!0);return}const ce=A[ie];if(ce){L!==ce&&(V(ce),se.current=!0);return}let xe=!1;return n?(L!==ie&&V(ie),(async()=>{try{const C=await n(ie,{watch:w,getValues:y});if(xe)return;if(C){const q=C.label??String(C.value);$(te=>{const W={...te,[ie]:q};return V(q),se.current=!0,W})}else L!==ie&&(V(ie),se.current=!0)}catch{!xe&&L!==ie&&(V(ie),se.current=!0)}})()):L!==ie&&(V(ie),se.current=!0),()=>{xe=!0}},[j,oe,A,n,w,y]),k.useEffect(()=>{if(u!=="debounced"||c)return;if(se.current){se.current=!1;return}if(!Q.current)return;P.current&&(window.clearTimeout(P.current),P.current=null);const fe=(L||"").trim();return fe.length>=d?P.current=window.setTimeout(()=>{Y(fe)},m):(N([]),Z(!1)),()=>{P.current&&(window.clearTimeout(P.current),P.current=null)}},[L,u,d,m,c]);const ne=l==="sm"?"text-ds-sm":l==="md"?"text-ds-md":"text-ds-lg",G=l==="sm"?"h-6":l==="md"?"h-10":"h-12",X=fe=>{if(c)return;const ie=(L||"").trim();fe.key==="Enter"&&(fe.preventDefault(),u==="debounced"?ie.length>=d&&Y(ie):Y(ie)),fe.key==="Escape"&&Z(!1)},me=i&&(i.includes(" ")||i.startsWith("w-")||i.startsWith("max-w-")||i.startsWith("min-w-")),pe=me?void 0:{width:i},ue=`relative flex flex-col ${me?i:""}`;return s.jsx(ht,{name:e,control:t,render:({field:fe,fieldState:ie})=>{var ke;return s.jsxs("div",{ref:M,className:ue,style:pe,children:[o&&s.jsx(Gt,{id:e,text:o,size:l,prefixIcon:f,suffixIcon:h}),s.jsx(Ee,{className:u==="button"?"rounded-r-none":void 0,type:"text",size:l,width:"100%",value:L,prefixIcon:p,suffixIcon:b,onChange:ce=>{const xe=ce.target.value;re.current=!0,Q.current=!0,V(xe),(j?String(j):"").trim()&&R(e,"",{shouldDirty:!0})},onKeyDown:X,onBlur:()=>{re.current=!1},disabled:c,hasError:ie.invalid,errorMessage:(ke=ie.error)==null?void 0:ke.message,reserveErrorSpace:v,disableErrorPlaceholder:g,onFocus:()=>{if(re.current=!0,u==="button"&&Q.current){const ce=(L||"").trim();ce&&Y(ce)}},suffixButton:u==="button"?s.jsx(he,{type:"button",className:"!rounded-l-none",size:l,variant:"primary",onClick:()=>Y((L||"").trim()),disabled:c,children:"Buscar"}):void 0}),S&&s.jsx("div",{className:"absolute top-14 left-0 right-0 z-10",children:s.jsx(pr,{width:"100%",height:l==="sm"?"1.5rem":l==="md"?"2.5rem":"3rem",variant:"rect",className:"rounded-lg"})}),I&&!S&&E.length>0&&s.jsx("ul",{className:`
|
|
92
92
|
absolute top-14 left-0 right-0
|
|
93
93
|
border-[var(--color-ds-border-default)]
|
|
94
94
|
rounded-lg bg-[var(--color-ds-background-page)]
|
package/dist/index.es.js
CHANGED
|
@@ -25758,8 +25758,10 @@ function Xe(e) {
|
|
|
25758
25758
|
{
|
|
25759
25759
|
type: "text",
|
|
25760
25760
|
value: H,
|
|
25761
|
+
autoFocus: !0,
|
|
25761
25762
|
onChange: (T) => z(T.target.value),
|
|
25762
25763
|
onClick: (T) => T.stopPropagation(),
|
|
25764
|
+
onKeyDown: (T) => T.stopPropagation(),
|
|
25763
25765
|
placeholder: te,
|
|
25764
25766
|
className: "w-full rounded-lg border border-[var(--color-ds-border-default)] bg-[var(--color-ds-background-page)] px-2 py-2 text-sm outline-none"
|
|
25765
25767
|
}
|
package/dist/index.umd.js
CHANGED
|
@@ -89,7 +89,7 @@ attempted value: ${i}
|
|
|
89
89
|
self.postMessage({ success: false, error: err.toString() });
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
|
-
`,u=new Blob([d],{type:"application/javascript"}),f=URL.createObjectURL(u),h=new Worker(f),p=setTimeout(()=>{h.terminate(),URL.revokeObjectURL(f),c(new Error("Timeout: La validación tardó demasiado."))},a);h.onmessage=m=>{clearTimeout(p),h.terminate(),URL.revokeObjectURL(f),m.data.success?i(m.data.result):(console.warn("Validation Script Error:",m.data.error),i("Error en script de validación"))},h.onerror=m=>{clearTimeout(p),h.terminate(),URL.revokeObjectURL(f),c(m)},h.postMessage({code:e,context:t,translations:o})})}const O$={ds:{fileUploader:{browse:"Document",dragDrop:"Drag your files here or click to browse",view:"View",remove:"Remove"},form:{fieldRequired:"Required field",invalidEmail:"Invalid email",submit:"Submit",sending:"Sending…",saveSuccess:"Saved successfully!",saveError:"There are errors in the form"},editor:{inspector:{field:"Field Inspector",tab:"Tab Inspector",section:"Section Inspector"},actions:{move:"Move",moveLeft:"Move left",moveRight:"Move right",add:"Add",addTab:"Tab to the right",addSection:"Add section",addRow:"Add row",addColumn:"Add column",delete:"Delete",deleteTab:"Delete tab",deleteColumn:"Remove last column",duplicate:"Duplicate",cancel:"Cancel"},confirmations:{deleteField:{title:"Delete field",message:"Are you sure you want to delete this field?"},deleteColumn:{title:"Delete column",message:"Are you sure you want to delete the last column? Fields it contains will be lost."},deleteRow:{title:"Delete row",message:"Are you sure you want to delete this row? All fields it contains will be lost."},deleteSection:{title:"Delete section",message:"Are you sure you want to delete this section? All fields it contains will be lost."}},title:"Form Schema Editor",context:"Context:",modes:{design:"Designer",preview:"Preview",code:"Code"},codeViewer:{copy:"Copy code",copied:"Copied",lines:"lines",format:"Format"},toolbar:{export:"Export",import:"Import JSON",shortcuts:"Shortcuts",showRelations:"Show relations",hideRelations:"Hide relations",toggleSidePanel:{open:"Open side panel",close:"Close side panel"}},importModal:{trigger:"Generate from object",triggerTitle:"Generate form from JSON or TypeScript",title:"Generate from JSON or TypeScript",labels:{formTitle:"Form Title",formId:"Form ID",layout:"Layout (cols)",input:"Input (paste JSON or TypeScript interface/type)"},placeholders:{layout:{auto:"Auto",col1:"1 column",col2:"2 columns",col3:"3 columns",col4:"4 columns"}},actions:{cancel:"Cancel",generate:"Generate Form",generating:"Generating..."},messages:{success:"Form generated successfully.",error:"Could not generate form."}}},fields:{defaults:{text:{label:"Text",placeholder:"Type…"},number:{label:"Number",placeholder:"0"},email:{label:"Email",placeholder:"user@domain.com"},password:{label:"Password",placeholder:"••••••••"},tel:{label:"Phone",placeholder:"600 000 000"},url:{label:"URL",placeholder:"https://example.com"},textarea:{label:"Comment",placeholder:"Write your comment…"},select:{label:"Select",placeholder:"Select an option"},checkbox:{label:"Checkbox"},date:{label:"Date"},file:{label:"File"},search:{label:"Search",placeholder:"Search...",noMatches:"No matches found"}},validation:{required:"Required field",invalidEmail:"Invalid email",invalidUrl:"Invalid URL",invalidPhone:"Invalid phone",invalidID:"Invalid identity document",invalidIBAN:"Invalid IBAN",minLength:"Minimum {{count}} characters",maxLength:"Maximum {{count}} characters",pattern:"Invalid format",numberMin:"Must be greater than or equal to {{min}}",numberMax:"Must be less than or equal to {{max}}",step:"Must be a multiple of {{step}}",integerOnly:"Must be an integer",positiveOnly:"Must be a positive number",selectMin:"Select at least {{count}} options",selectMax:"Select at most {{count}} options",dateMin:"Date must be after {{date}}",dateMax:"Date must be before {{date}}",disallowPast:"Past dates are not allowed",disallowFuture:"Future dates are not allowed",number:"Must be a number",date:"Invalid date",invalidOption:"Invalid option",mustCheck:"You must check this box",invalidFile:"Invalid file",invalidFileType:"File type not allowed",fileMaxCount:"Max. {{count}} file(s)",fileMaxSize:"File must not exceed {{size}}MB",minItems:"Minimum {{count}} items",maxItems:"Maximum {{count}} items"}}}},L$={ds:{fileUploader:{browse:"Documento",dragDrop:"Arrastra tus archivos aquí o haz clic para buscarlos",view:"Ver",remove:"Eliminar"},form:{fieldRequired:"Campo obligatorio",invalidEmail:"Email inválido",submit:"Enviar",sending:"Enviando…",saveSuccess:"¡Guardado con éxito!",saveError:"Hay errores en el formulario"},editor:{inspector:{field:"Inspector de campo",tab:"Inspector de pestaña",section:"Inspector de sección"},actions:{move:"Mover",moveLeft:"Mover a la izquierda",moveRight:"Mover a la derecha",add:"Añadir",addTab:"Pestaña a la derecha",addSection:"Añadir sección",addRow:"Añadir fila",addColumn:"Añadir columna",delete:"Eliminar",deleteTab:"Eliminar pestaña",deleteColumn:"Quitar última columna",duplicate:"Duplicar",cancel:"Cancelar"},confirmations:{deleteField:{title:"Eliminar campo",message:"¿Estás seguro de que quieres eliminar este campo?"},deleteColumn:{title:"Eliminar columna",message:"¿Estás seguro de que quieres eliminar la última columna? Se perderán los campos que contiene."},deleteRow:{title:"Eliminar fila",message:"¿Estás seguro de que quieres eliminar esta fila? Se perderán todos los campos que contiene."},deleteSection:{title:"Eliminar sección",message:"¿Estás seguro de que quieres eliminar esta sección? Se perderán todos los campos que contiene."}},title:"Editor de Esquema de Formulario",context:"Contexto:",modes:{design:"Diseñar",preview:"Vista Previa",code:"Código"},codeViewer:{copy:"Copiar código",copied:"Copiado",lines:"líneas",format:"Formato"},toolbar:{export:"Exportar",import:"Importar JSON",shortcuts:"Configurar atajos",showRelations:"Mostrar relaciones",hideRelations:"Ocultar relaciones",toggleSidePanel:{open:"Abrir panel lateral",close:"Cerrar panel lateral"}},importModal:{trigger:"Generar desde objeto",triggerTitle:"Generar formulario desde JSON o TypeScript",title:"Generar desde JSON o TypeScript",labels:{formTitle:"Título del formulario",formId:"ID del formulario",layout:"Distribución (cols)",input:"Entrada (pega JSON o una interface/type de TypeScript)"},placeholders:{layout:{auto:"Auto",col1:"1 columna",col2:"2 columnas",col3:"3 columnas",col4:"4 columnas"}},actions:{cancel:"Cancelar",generate:"Generar formulario",generating:"Generando..."},messages:{success:"Formulario generado correctamente.",error:"No se pudo generar el formulario."}}},fields:{defaults:{text:{label:"Texto",placeholder:"Escribe…"},number:{label:"Número",placeholder:"0"},email:{label:"Email",placeholder:"usuario@dominio.com"},password:{label:"Contraseña",placeholder:"••••••••"},tel:{label:"Teléfono",placeholder:"600 000 000"},url:{label:"URL",placeholder:"https://ejemplo.com"},textarea:{label:"Comentario",placeholder:"Escribe tu comentario…"},select:{label:"Seleccionar",placeholder:"Seleccione una opción"},checkbox:{label:"Casilla"},date:{label:"Fecha"},file:{label:"Archivo"},search:{label:"Búsqueda",placeholder:"Buscar...",noMatches:"No hay coincidencias"}},validation:{required:"Campo obligatorio",invalidEmail:"Email inválido",invalidUrl:"URL inválida",invalidPhone:"Teléfono inválido",invalidID:"Documento de identidad inválido",invalidIBAN:"IBAN inválido",minLength:"Mínimo {{count}} caracteres",maxLength:"Máximo {{count}} caracteres",pattern:"Formato inválido",numberMin:"Debe ser mayor o igual a {{min}}",numberMax:"Debe ser menor o igual a {{max}}",step:"Debe ser múltiplo de {{step}}",integerOnly:"Debe ser un número entero",positiveOnly:"Debe ser un número positivo",selectMin:"Selecciona al menos {{count}} opciones",selectMax:"Selecciona como máximo {{count}} opciones",dateMin:"La fecha debe ser posterior a {{date}}",dateMax:"La fecha debe ser anterior a {{date}}",disallowPast:"No se permiten fechas pasadas",disallowFuture:"No se permiten fechas futuras",number:"Debe ser un número",date:"Fecha inválida",invalidOption:"Opción inválida",mustCheck:"Debes marcar esta casilla",invalidFile:"Archivo inválido",invalidFileType:"Tipo de archivo no permitido",fileMaxCount:"Máx. {{count}} fichero(s)",fileMaxSize:"El archivo no debe superar {{size}}MB",minItems:"Mínimo {{count}} elementos",maxItems:"Máximo {{count}} elementos"}}}};qe.use(RT).init({resources:{en:{translation:O$},es:{translation:L$}},lng:"es",fallbackLng:"es",interpolation:{escapeValue:!1}});const T$=e=>{qe.changeLanguage(e)},_2="TRWAGMYFPDXBNJZSQVHLCKE",$$=["X","Y","Z"];function I$(e){if(!/^\d{8}[A-Z]$/.test(e))return!1;const t=parseInt(e.substring(0,8),10),r=e.charAt(8),n=_2.charAt(t%23);return r===n}function B$(e){if(!/^[XYZ]\d{7}[A-Z]$/.test(e))return!1;const t=e.charAt(0),n=$$.indexOf(t).toString()+e.substring(1),a=parseInt(n.substring(0,8),10),o=e.charAt(8),i=_2.charAt(a%23);return o===i}function P$(e){if(!/^[A-Z]\d{7}[A-Z0-9]$/.test(e))return!1;const t=e.charAt(0),r=e.substring(1,8),n=e.charAt(8);let a=0;for(let f=0;f<7;f++){const h=parseInt(r.charAt(f),10);if(f%2===0){const p=h*2;a+=Math.floor(p/10)+p%10}else a+=h}const o=a%10,i=o===0?0:10-o,c="JABCDEFGHI".charAt(i);return["A","B","E","H"].includes(t)?n===i.toString():n===c||n===i.toString()}function V$(e){if(!e||e.length<9)return!1;const t=e.toUpperCase().replace(/\s+/g,"").replace(/[^A-Z0-9]/g,"");return/^\d{8}[A-Z]$/.test(t)?I$(t):/^[XYZ]\d{7}[A-Z]$/.test(t)?B$(t):/^[A-Z]\d{7}[A-Z0-9]$/.test(t)?P$(t):!1}const Z$=/^\s*(?:\+?\d{1,4}[\s-]*)?(?:\(?\d{2,4}\)?[\s-]*)?\d{3,4}[\s-]?\d{3,4}\s*$/;function M2(e){return(e??"").toUpperCase().replace(/\s+/g,"").replace(/[^A-Z0-9]/g,"")}function z$(e){const t=M2(e);if(t.length<15||t.length>34||!/^[A-Z]{2}\d{2}[A-Z0-9]+$/.test(t))return!1;const r=t.slice(4)+t.slice(0,4);let n=0;for(const a of r){const o=a.charCodeAt(0);if(o>=65&&o<=90){const i=String(o-55);for(let c=0;c<i.length;c++)n=(n*10+(i.charCodeAt(c)-48))%97}else n=(n*10+(a.charCodeAt(0)-48))%97}return n===1}function H$(e){return e.validation??{}}function W$(e){return!!e.multiple}function U$(e){const t=e.maxFiles;return typeof t=="number"?t:void 0}function q$(e){const t=e.options;return Array.isArray(t)?t.map(r=>r==null?void 0:r.value).filter(r=>r!==void 0):[]}function G$(e){if(!e)return{exts:[],mimes:[]};const t=e.split(",").map(a=>a.trim().toLowerCase()).filter(Boolean),r=[],n=[];for(const a of t)a.startsWith(".")?r.push(a):a.includes("/")&&n.push(a);return{exts:r,mimes:n}}function bt(e,t){const r=typeof e=="string"?e:t;return qe.isInitialized&&(r.startsWith("forms.")||r.startsWith("ds."))?qe.t(r):r}function br(e,t){let r=e;return t.required&&(r=r.required(bt(t.requiredMessage||(typeof t.required=="string"?t.required:void 0),"ds.fields.validation.required"))),t.customFn&&(r=r.test({name:"custom-script-validation",message:"${path} no es válido",test:async function(n,a){if(n==null||n==="")return!0;const o=a.parent;let i={};try{if(qe.isInitialized){const c=qe.getResourceBundle(qe.language,"translation")||{},d=(u,f="")=>{for(const h of Object.keys(u)){const p=f?`${f}.${h}`:h,m=u[h];typeof m=="string"?i[p]=m:typeof m=="object"&&m!==null&&d(m,p)}};d(c)}}catch(c){console.warn("Error extracting translations for validation:",c)}try{const c=await F2(t.customFn,{value:n,form:o,customMessages:t.customMessages||{}},{translations:i});if(c===!0)return!0;if(typeof c=="string"){const d=qe.isInitialized&&c.startsWith("forms.")?qe.t(c):c;return this.createError({message:d})}return!1}catch(c){return console.error("Custom Validation Error",c),this.createError({message:"Error ejecutando validación: "+String(c)})}}})),r}function zn(e,t){var n,a,o;let r=e;return((n=t.minLength)==null?void 0:n.value)!=null&&(r=r.min(t.minLength.value,bt(t.minLength.message,"ds.fields.validation.minLength"))),((a=t.maxLength)==null?void 0:a.value)!=null&&(r=r.max(t.maxLength.value,bt(t.maxLength.message,"ds.fields.validation.maxLength"))),((o=t.pattern)==null?void 0:o.value)instanceof RegExp&&(r=r.matches(t.pattern.value,bt(t.pattern.message,"ds.fields.validation.pattern"))),r}function K$(e,t){var n,a,o,i;let r=e;if(((n=t.numberMin)==null?void 0:n.value)!=null&&(r=r.min(t.numberMin.value,bt(t.numberMin.message,"ds.fields.validation.numberMin"))),((a=t.numberMax)==null?void 0:a.value)!=null&&(r=r.max(t.numberMax.value,bt(t.numberMax.message,"ds.fields.validation.numberMax"))),t.positiveOnly&&(r=r.moreThan(0,bt(t.positiveOnly,"ds.fields.validation.positiveOnly"))),t.integerOnly&&(r=r.integer(bt(t.integerOnly,"ds.fields.validation.integerOnly"))),((o=t.step)==null?void 0:o.value)!=null){const c=Number(t.step.value),d=t.step.message||"ds.fields.validation.step";r=r.test("step",d,u=>{if(u==null||Number.isNaN(u)||c===0)return!0;const f=u/c;return Math.abs(f-Math.round(f))<1e-9})}return((i=t.pattern)==null?void 0:i.value)instanceof RegExp&&(r=r.test("pattern-number",t.pattern.message||"ds.fields.validation.pattern",c=>c==null||t.pattern.value.test(String(c)))),r}function J$(e,t){var n,a;let r=e;return(n=t.dateMin)!=null&&n.value&&(r=r.min(new Date(t.dateMin.value),bt(t.dateMin.message,"ds.fields.validation.dateMin"))),(a=t.dateMax)!=null&&a.value&&(r=r.max(new Date(t.dateMax.value),bt(t.dateMax.message,"ds.fields.validation.dateMax"))),t.disallowPast&&(r=r.min(new Date,bt(t.disallowPast,"ds.fields.validation.disallowPast"))),t.disallowFuture&&(r=r.max(new Date,bt(t.disallowFuture,"ds.fields.validation.disallowFuture"))),r}function Y$(e){var r,n,a,o;const t=H$(e);switch(e.type){case"text":case"password":case"textarea":case"search":{let i=wn().trim();return i=zn(i,t),br(i,t)}case"dni":{let i=wn().trim();return i=zn(i,t),i=i.test("dni-valid",bt("ds.fields.validation.invalidID","Documento de identidad inválido"),c=>c==null||c===""?!0:V$(c)),br(i,t)}case"email":{let i=wn().trim().email(bt(t.emailMessage,"ds.fields.validation.invalidEmail"));return i=zn(i,t),br(i,t)}case"url":{let i=wn().trim().url(bt(t.urlMessage,"ds.fields.validation.invalidUrl"));return i=zn(i,t),br(i,t)}case"tel":{let i=wn().trim();return i=zn(i,t),(r=t.pattern)!=null&&r.value||(i=i.matches(Z$,bt(t.phoneMessage,"ds.fields.validation.invalidPhone"))),br(i,t)}case"iban":{let i=wn().transform((c,d)=>d===""||d===null||d===void 0?"":typeof d=="string"?M2(d):c);return i=zn(i,t),i=i.test("iban-valid",bt("ds.fields.validation.invalidIBAN","IBAN inválido"),c=>c==null||c===""?!0:z$(String(c))),br(i,t)}case"number":{let i=x2().transform((c,d)=>{if(d===""||d===null||d===void 0)return;const u=typeof d=="string"?Number(d.replace(",",".")):c;return Number.isNaN(u)?NaN:u}).typeError(bt(t.typeError,"ds.fields.validation.number"));return i=K$(i,t),br(i,t)}case"date":{let i=od().nullable().typeError(bt(t.typeError,"ds.fields.validation.date")).transform((c,d)=>d?new Date(d):null);return i=J$(i,t),br(i,t)}case"select":case"optionGroup":{const i=W$(e),c=q$(e);if(i){let d=id().of(c.length?Ao().oneOf(c,"ds.fields.validation.invalidOption"):Ao());return t.required&&(d=d.min(1,t.requiredMessage||(typeof t.required=="string"?t.required:"ds.fields.validation.required"))),d}else{let d=wn().trim();return d=zn(d,t),c.length&&(d=d.oneOf(c,"ds.fields.validation.invalidOption")),br(d,t)}}case"checkbox":{let i=v2();return t.required&&(i=i.oneOf([!0],t.requiredMessage||"ds.fields.validation.mustCheck")),i}case"file":{const i=e,{exts:c,mimes:d}=G$(i.accept),u=U$(e);let f=Ao().test("file-shape","ds.fields.validation.invalidFile",h=>(h==null,!0));if((n=t.fileMaxSizeMB)!=null&&n.value){const h=Number(t.fileMaxSizeMB.value)*1024*1024,p=t.fileMaxSizeMB.message||"ds.fields.validation.fileMaxSize";f=f.test("file-max-size",p,m=>m?(Array.isArray(m)?m:typeof FileList<"u"&&m instanceof FileList?Array.from(m):[m].filter(Boolean)).every(g=>typeof(g==null?void 0:g.size)!="number"||g.size<=h):!0)}return(c.length||d.length)&&(f=f.test("file-accept","ds.fields.validation.invalidFileType",h=>h?(Array.isArray(h)?h:typeof FileList<"u"&&h instanceof FileList?Array.from(h):[h].filter(Boolean)).every(v=>{var y,E,k,j;const g=((E=(y=v==null?void 0:v.name)==null?void 0:y.toLowerCase)==null?void 0:E.call(y))||"",b=((j=(k=v==null?void 0:v.type)==null?void 0:k.toLowerCase)==null?void 0:j.call(k))||"",x=c.length===0||c.some(A=>g.endsWith(A)),w=d.length===0||d.includes(b);return x&&w}):!0)),typeof u=="number"&&(f=f.test("file-max-files","ds.fields.validation.fileMaxCount",h=>h?(Array.isArray(h)?h:typeof FileList<"u"&&h instanceof FileList?Array.from(h):[h].filter(Boolean)).length<=u:!0)),f=br(f,t),f}case"array":{const i=e,c=i.items||[],d=R2(c);let u=id().of(sd(d));t.required&&(u=u.min(1,t.requiredMessage||(typeof t.required=="string"?t.required:"ds.fields.validation.required")));const f=i.validation;return(a=f==null?void 0:f.min)!=null&&a.value&&(u=u.min(f.min.value,f.min.message||"ds.fields.validation.minItems")),(o=f==null?void 0:f.max)!=null&&o.value&&(u=u.max(f.max.value,f.max.message||"ds.fields.validation.maxItems")),u}default:{const i=Ao();return br(i,t)}}}function R2(e){const t={};for(const r of e){const n=r;n!=null&&n.name&&(t[n.name]=Y$(n))}return t}function ld(e){const t=R2(e.fields);return sd(t)}const O2=e=>{let t;const r=new Set,n=(u,f)=>{const h=typeof u=="function"?u(t):u;if(!Object.is(h,t)){const p=t;t=f??(typeof h!="object"||h===null)?h:Object.assign({},t,h),r.forEach(m=>m(t,p))}},a=()=>t,c={setState:n,getState:a,getInitialState:()=>d,subscribe:u=>(r.add(u),()=>r.delete(u))},d=t=e(n,a,c);return c},X$=(e=>e?O2(e):O2),Q$=e=>e;function eI(e,t=Q$){const r=C.useSyncExternalStore(e.subscribe,C.useCallback(()=>t(e.getState()),[e,t]),C.useCallback(()=>t(e.getInitialState()),[e,t]));return C.useDebugValue(r),r}const L2=e=>{const t=X$(e),r=n=>eI(t,n);return Object.assign(r,t),r},T2=(e=>e?L2(e):L2),Hn=T2(e=>({isActive:!1,formValues:{},systemContext:{},setRuntimeState:t=>e(r=>({...r,...t})),reset:()=>e({isActive:!1,formValues:{},systemContext:{}})}));function cd(e,t){return e?typeof e!="string"?String(e):e.replace(/\{\{([^}]+)\}\}/g,(r,n)=>{let o=n.trim().split(".").reduce((i,c)=>{if(!i)return;if(i[c]!==void 0)return i[c];const d=c.toLowerCase(),u=Object.keys(i).find(f=>f.toLowerCase()===d);return u?i[u]:void 0},t);return o!=null?String(o):r}):""}function zr({options:e,value:t,onChange:r,children:n,className:a,contentClassName:o}){const i=C.useRef(null),[c,d]=C.useState({left:0,width:0}),[u,f]=C.useState(!1),[h,p]=C.useState(!1),m=()=>{if(i.current){const{scrollLeft:g,scrollWidth:b,clientWidth:x}=i.current;f(g>0),p(g<b-x-1)}};C.useLayoutEffect(()=>{const g=i.current;if(!g)return;const b=()=>{const x=g.querySelector(`[data-value="${t}"]`);x&&d({left:x.offsetLeft,width:x.offsetWidth})};return b(),m(),window.addEventListener("resize",b),window.addEventListener("resize",m),()=>{window.removeEventListener("resize",b),window.removeEventListener("resize",m)}},[t,e]);const v=g=>{i.current&&i.current.scrollBy({left:g==="left"?-200:200,behavior:"smooth"})};return l.jsxs("div",{className:a,children:[l.jsxs("div",{className:"relative border-b border-[var(--color-ds-border-default-50)] group",children:[u&&l.jsx("div",{className:"absolute left-0 top-0 bottom-0 z-20 flex items-center bg-gradient-to-r from-[var(--color-ds-background-page)] to-transparent pr-4 pl-1 opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:l.jsx("button",{type:"button",onClick:()=>v("left"),className:"p-1 rounded-full bg-[var(--color-ds-background-surface)] shadow-sm border border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-primary)] hover:bg-[var(--color-ds-button-hover-bg)] hover:text-white transition-colors",children:l.jsx(x1,{className:"w-4 h-4"})})}),l.jsx("div",{ref:i,onScroll:m,className:"overflow-x-auto scrollbar-hidden flex items-center w-full relative",style:{scrollBehavior:"smooth"},children:l.jsxs("div",{className:"relative flex min-w-full px-1",children:[e.map(g=>{const b=g.value===t;return l.jsxs("button",{"data-value":g.value,role:"tab","aria-selected":b,onClick:()=>!g.disabled&&r(g.value),type:"button",className:we("relative z-10 whitespace-nowrap px-4 py-2 transition-colors duration-150 ease-in-out font-medium text-sm focus:outline-none",b?"text-[var(--color-ds-background-accent)]":"text-[var(--color-ds-text-secondary)] hover:text-[var(--color-ds-text-primary)]",g.disabled&&"opacity-50 cursor-not-allowed"),disabled:g.disabled,children:[g.icon&&l.jsx("span",{className:"mr-2 -ml-1 inline-block align-text-bottom",children:g.icon}),g.label]},g.value)}),l.jsx("span",{className:"absolute bottom-0 h-0.5 bg-[var(--color-ds-background-accent)] transition-all duration-200 ease-in-out z-20",style:{left:c.left,width:c.width}})]})}),h&&l.jsx("div",{className:"absolute right-0 top-0 bottom-0 z-20 flex items-center bg-gradient-to-l from-[var(--color-ds-background-page)] to-transparent pl-4 pr-1 opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:l.jsx("button",{type:"button",onClick:()=>v("right"),className:"p-1 rounded-full bg-[var(--color-ds-background-surface)] shadow-sm border border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-primary)] hover:bg-[var(--color-ds-button-hover-bg)] hover:text-white transition-colors",children:l.jsx(Zs,{className:"w-4 h-4"})})})]}),l.jsx("div",{className:we("mt-4",o),children:n[t]})]})}const _a={sm:"text-ds-sm",md:"text-ds-md",lg:"text-ds-lg"},xi={sm:"h-5",md:"h-10",lg:"h-12"},yi={sm:"px-2",md:"px-2.5",lg:"px-3"},ki={sm:"1.5rem",md:"2.5rem",lg:"3rem"},Ei={sm:"pr-9",md:"pr-11",lg:"pr-12"},tI={sm:"h-6 w-6",md:"h-8 w-8",lg:"h-10 w-10"};function Ci({id:e,size:t,disabled:r,error:n,reserveErrorSpace:a,className:o,suffixButton:i,children:c,showDropdownIndicator:d}){var u;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:we("relative w-full",o),children:[c,d&&!i&&l.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-2 flex items-center",children:l.jsx(fr,{className:"h-4 w-4 text-[var(--color-ds-text-secondary)]"})}),i&&l.jsx("div",{className:"pointer-events-none absolute flex items-center",style:{top:2,bottom:2,right:4},children:l.jsx("div",{className:"pointer-events-auto",children:C.isValidElement(i)?C.cloneElement(i,{className:we(tI[t],(u=i.props)==null?void 0:u.className)}):i})})]}),a?l.jsx("div",{className:"h-[1em]",children:n!=null&&n.message?l.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)] h-[1em]",children:n.message}):l.jsx("span",{"aria-hidden":"true",children:" "})}):n!=null&&n.message?l.jsx("div",{className:"pt-1",children:l.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)] h-[1em]",children:n.message})}):null]})}function $2(e,t){C.useEffect(()=>{const r=n=>{e.current&&(e.current.contains(n.target)||t())};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[t,e])}function Je(e){const{control:t,name:r,rules:n,defaultValue:a,options:o=[],loadOptions:i,reloadDeps:c=[],value:d,onChange:u,size:f="sm",width:h="100%",label:p,labelHidden:m=!1,info:v,infoHeader:g,hasError:b=!1,errorMessage:x="",reserveErrorSpace:w,disableErrorPlaceholder:y,disabled:E=!1,className:k,suffixButton:j,loading:A=!1,coerceFirstValid:S=!0,mode:_="menu",renderTrigger:M,renderOption:P,popupWidth:R,triggerClassName:I,onBlur:F,searchable:V=!1,searchPlaceholder:te="Buscar...",noOptionsText:X="No se encontraron resultados"}=e,ne=C.useId(),se=r||ne,[G,N]=C.useState(o),[O,ae]=C.useState(!!i);C.useEffect(()=>{if(!i){N(o);return}ae(!0),i().then(ce=>N(ce)).finally(()=>ae(!1))},[i,...c]),C.useEffect(()=>{i||N(o)},[o,i]);const K=ce=>ce.find(xe=>xe.value!==""&&xe.value!==void 0)??ce[0],Q=ce=>String(ce??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim(),pe=(ce,xe)=>{const D=Q(xe);return D?ce.filter(q=>[q.label,q.value,q.name,q.code,q.text,q.descripcion,q.description].map(Q).join(" ").includes(D)):ce},ge=typeof w=="boolean"?w:!!t,ue=h&&(h.includes(" ")||h.startsWith("w-")||h.startsWith("max-w-")||h.startsWith("min-w-")),fe=ue?{maxWidth:"100%"}:{width:h,maxWidth:"100%"},le=we("flex flex-col",ue&&h,k);if(t&&r){const{field:ce,fieldState:xe}=o5({name:r,control:t,rules:n,defaultValue:a});C.useEffect(()=>{if(!O&&G.length>0&&S){const q=ce.value,re=G.some(W=>String(W.value)===String(q));(q===void 0||!re)&&ce.onChange(K(G).value)}},[G,O,ce,S]);const D=p&&!m&&l.jsx(gr,{id:se,text:p,size:f,info:v,infoHeader:g});if((_??"native")==="menu"){const[q,re]=C.useState(!1),[W,H]=C.useState(""),J=C.useRef(null);$2(J,()=>{re(!1),H("")});const T=G.find(B=>String(B.value)===String(ce.value)),U=V?pe(G,W):G;return l.jsxs("div",{className:le,style:fe,children:[D,A||O?l.jsx(Br,{width:"100%",height:ki[f],variant:"rect",className:"rounded-lg"}):l.jsx(Ci,{id:se,size:f,disabled:E,error:xe.error,reserveErrorSpace:typeof y=="boolean"?!y:ge,className:k,suffixButton:j,showDropdownIndicator:!0,children:l.jsxs("div",{className:"relative w-full",ref:J,children:[l.jsx("button",{type:"button",onClick:()=>{E||re(B=>{const $=!B;return $||H(""),$})},onBlur:()=>{ce.onBlur(),F==null||F()},className:we("box-border w-full rounded-lg border bg-[var(--color-ds-background-page)] outline-none transition appearance-none text-left flex items-center",_a[f],xi[f],yi[f],j&&Ei[f],xe.error?"border-[var(--color-ds-border-error)]":"border-[var(--color-ds-border-default)]",E?"bg-[var(--color-ds-background-disabled)] border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-primary)] cursor-not-allowed":"text-[var(--color-ds-text-primary)] hover:border-[var(--color-ds-border-default-hover)]",I),"aria-haspopup":"listbox","aria-expanded":q,children:M?M(T):(T==null?void 0:T.label)??"—"}),q&&l.jsxs("div",{role:"listbox",className:"custom-scroll absolute z-50 mt-1 rounded-xl border border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-page)] shadow-xl p-1 max-h-72 overflow-auto",style:{width:R??"100%"},children:[V&&l.jsx("div",{className:"sticky top-0 z-10 bg-[var(--color-ds-background-page)] p-1",children:l.jsx("input",{type:"text",value:W,onChange:B=>H(B.target.value),onClick:B=>B.stopPropagation(),placeholder:te,className:"w-full rounded-lg border border-[var(--color-ds-border-default)] bg-[var(--color-ds-background-page)] px-2 py-2 text-sm outline-none"})}),U.length>0?U.map(B=>{const $=String(B.value)===String(ce.value);return l.jsx("button",{role:"option","aria-selected":$,type:"button",onClick:()=>{ce.onChange(B.value),re(!1),H("")},className:we("w-full rounded-lg px-2 py-1.5 text-left transition-all duration-200",_a[f],$?"bg-[var(--color-ds-background-neutral)] font-medium text-[var(--color-ds-text-primary)]":"text-[var(--color-ds-text-secondary)] hover:bg-[var(--color-ds-background-neutral-hover)] hover:text-[var(--color-ds-text-primary)] hover:pl-3"),children:P?P(B,$):B.label},B.value)}):l.jsx("div",{className:"px-2 py-2 text-sm text-[var(--color-ds-text-secondary)]",children:X})]})]})})]})}return l.jsxs("div",{className:le,style:fe,children:[D,A||O?l.jsx(Br,{width:"100%",height:ki[f],variant:"rect",className:"rounded-lg"}):l.jsx(Ci,{id:se,size:f,disabled:E,error:xe.error,reserveErrorSpace:typeof y=="boolean"?!y:ge,className:k,suffixButton:j,showDropdownIndicator:!0,children:l.jsx("select",{id:se,value:ce.value,onChange:q=>ce.onChange(q.target.value),onBlur:()=>{ce.onBlur(),F==null||F()},disabled:E,className:we("box-border w-full rounded-lg border bg-[var(--color-ds-background-page)] outline-none transition appearance-none leading-none",_a[f],xi[f],yi[f],j&&Ei[f],xe.error?"border-[var(--color-ds-border-error)]":"border-[var(--color-ds-border-default)]",E?"bg-[var(--color-ds-background-disabled)] border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-primary)] cursor-not-allowed":"text-[var(--color-ds-text-primary)]",I),children:G.map(q=>l.jsx("option",{value:q.value,className:"bg-[var(--color-ds-background-page)] text-[var(--color-ds-text-primary)]",children:q.label},q.value))})})]})}C.useEffect(()=>{if(!t&&G.length>0&&S){const ce=G.some(D=>String(D.value)===String(d));(d===void 0||d===""||!ce)&&u&&u(K(G).value)}},[G,d,u,t,S]);const Ce=p&&!m&&l.jsx(gr,{id:se,text:p,size:f,info:v,infoHeader:g});if((_??"native")==="menu"){const[ce,xe]=C.useState(!1),[D,q]=C.useState(""),re=C.useRef(null);$2(re,()=>{xe(!1),q("")});const W=G.find(J=>String(J.value)===String(d)),H=V?pe(G,D):G;return l.jsxs("div",{className:le,style:fe,children:[Ce,A||O?l.jsx(Br,{width:"100%",height:ki[f],variant:"rect",className:"rounded-lg"}):l.jsx(Ci,{id:se,size:f,disabled:E,error:b?{message:x}:void 0,reserveErrorSpace:typeof y=="boolean"?!y:!!(w??!1),className:k,suffixButton:j,showDropdownIndicator:!0,children:l.jsxs("div",{className:"relative w-full",ref:re,children:[l.jsx("button",{type:"button",onClick:()=>{E||xe(J=>{const T=!J;return T||q(""),T})},onBlur:F,className:we("box-border w-full rounded-lg border bg-[var(--color-ds-background-page)] outline-none transition appearance-none text-left flex items-center",_a[f],xi[f],yi[f],j&&Ei[f],b?"border-[var(--color-ds-border-error)]":"border-[var(--color-ds-border-default)]",E?"bg-[var(--color-ds-background-disabled)] border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-primary)] cursor-not-allowed":"text-[var(--color-ds-text-primary)] hover:border-[var(--color-ds-border-default-hover)]",I),"aria-haspopup":"listbox","aria-expanded":ce,children:M?M(W):(W==null?void 0:W.label)??"—"}),ce&&l.jsxs("div",{role:"listbox",className:"custom-scroll absolute z-50 mt-1 rounded-xl border border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-page)] shadow-xl p-1 max-h-72 overflow-auto",style:{width:R??"100%"},children:[V&&l.jsx("div",{className:"sticky top-0 z-10 bg-[var(--color-ds-background-page)] p-1",children:l.jsx("input",{type:"text",value:D,onChange:J=>q(J.target.value),onClick:J=>J.stopPropagation(),placeholder:te,className:"w-full rounded-lg border border-[var(--color-ds-border-default)] bg-[var(--color-ds-background-page)] px-2 py-2 text-sm outline-none"})}),H.length>0?H.map(J=>{const T=String(J.value)===String(d);return l.jsx("button",{role:"option","aria-selected":T,type:"button",onClick:()=>{u==null||u(J.value),xe(!1),q("")},className:we("w-full rounded-lg px-2 py-1.5 text-left transition-all duration-200",_a[f],T?"bg-[var(--color-ds-background-neutral)] font-medium text-[var(--color-ds-text-primary)]":"text-[var(--color-ds-text-secondary)] hover:bg-[var(--color-ds-background-neutral-hover)] hover:text-[var(--color-ds-text-primary)] hover:pl-3"),children:P?P(J,T):J.label},J.value)}):l.jsx("div",{className:"px-2 py-2 text-sm text-[var(--color-ds-text-secondary)]",children:X})]})]})})]})}return l.jsxs("div",{className:le,style:fe,children:[Ce,A||O?l.jsx(Br,{width:"100%",height:ki[f],variant:"rect",className:"rounded-lg"}):l.jsx(Ci,{id:se,size:f,disabled:E,error:b?{message:x}:void 0,reserveErrorSpace:typeof y=="boolean"?!y:!!(w??!1),className:k,suffixButton:j,showDropdownIndicator:!0,children:l.jsx("select",{id:se,value:d,onChange:ce=>u==null?void 0:u(ce.target.value),onBlur:F,disabled:E,className:we("box-border w-full rounded-lg border bg-[var(--color-ds-background-page)] outline-none transition appearance-none leading-none",_a[f],xi[f],yi[f],j&&Ei[f],b?"border-[var(--color-ds-border-error)]":"border-[var(--color-ds-border-default)]",E?"bg-[var(--color-ds-background-disabled)] border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-primary)] cursor-not-allowed":"text-[var(--color-ds-text-primary)]"),children:G.map(ce=>l.jsx("option",{value:ce.value,className:"bg-[var(--color-ds-background-page)] text-[var(--color-ds-text-primary)]",children:ce.label},ce.value))})})]})}const I2={sm:"text-ds-sm",md:"text-ds-md",lg:"text-ds-lg"};function B2(e){var t;e.preventDefault(),e.stopPropagation(),(t=e.nativeEvent)!=null&&t.stopImmediatePropagation&&e.nativeEvent.stopImmediatePropagation()}function dd({groupLabel:e,inputs:t=[],separator:r=l.jsx("span",{className:"px-1 select-none",children:"/"}),useSeparator:n=!1,className:a,showVisibleLabel:o=!1,size:i="sm",width:c,respectChildWidths:d=!1}){const u=t.length,f=c&&(c.includes(" ")||c.startsWith("w-")||c.startsWith("max-w-")||c.startsWith("min-w-")),h=f?void 0:c?{width:c}:void 0;return l.jsxs("div",{"data-input-group-root":!0,role:"group",className:we("flex flex-col w-full",f&&c,a),style:h,onDoubleClick:B2,onDoubleClickCapture:B2,onClickCapture:p=>{var g;const m=p.target;!!((g=m==null?void 0:m.closest)!=null&&g.call(m,'input,select,textarea,button,[data-interactive="true"]'))||p.stopPropagation()},children:[l.jsx("label",{className:we("sr-only pb-2",I2[i]),children:e}),o&&l.jsx("label",{className:we("pb-2",I2[i]),children:e}),l.jsx("div",{className:"flex items-stretch flex-nowrap w-full min-w-0",children:t.map((p,m)=>{const{width:v,className:g,options:b,loadOptions:x,info:w,infoHeader:y,...E}=p,k=Array.isArray(b)||typeof x=="function";let j="rounded-lg";!n&&u>1&&(m===0?j="rounded-l-lg rounded-r-none":m===u-1?j="rounded-r-lg rounded-l-none !rounded-l-none":j="rounded-none !rounded-l-none !rounded-r-none");const A=d?v:void 0,S=typeof A=="string"&&A.split(/\s+/).some(R=>R.startsWith("w-")||R.includes(":w-")),_=we("inline-flex items-stretch",A?"flex-shrink-0":"flex-1 min-w-0",typeof A=="string"&&S?A:void 0,!n&&u>1&&m>0?"-ml-px focus-within:z-10 relative":void 0),M=A?typeof A=="string"&&S?void 0:{width:A}:void 0,P=we(g,"w-full",j);return l.jsxs(C.Fragment,{children:[l.jsx("div",{className:_,style:M,children:k?l.jsx(Je,{...E,size:i,className:g,triggerClassName:we("w-full",j),options:b,loadOptions:x,"data-interactive":"true",info:w,infoHeader:y,mode:"menu",searchable:!0,searchPlaceholder:P5("ds.fields.defaults.search.placeholder"),noOptionsText:P5("ds.fields.defaults.search.noMatches")}):l.jsx(De,{...E,size:i,className:P,"data-interactive":"true",info:w,infoHeader:y})}),n&&m<u-1&&l.jsx("div",{className:"flex items-center flex-shrink-0 px-1 select-none",children:r})]},m)})})]})}const rI={sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},nI={sm:"w-3 h-3",md:"w-3.5 h-3.5",lg:"w-4 h-4"};function ji({groupLabel:e,options:t,control:r,name:n,rules:a,defaultValue:o,multiple:i=!0,size:c="sm",vertical:d=!0,className:u,showVisibleLabel:f=!0,disabled:h=!1,hasError:p=!1,errorMessage:m}){return l.jsx(Ct,{name:n,control:r,rules:a,defaultValue:o,render:({field:v,fieldState:g})=>{const{value:b,onChange:x}=v,w=g.error,y=A=>{var S;return i?Array.isArray(b)&&((S=b==null?void 0:b.includes)==null?void 0:S.call(b,A)):b===A},E=A=>{if(!h)if(i){const S=Array.isArray(b)?[...b]:[],_=S.indexOf(A);_>=0?S.splice(_,1):S.push(A),x(S)}else x(A)},k=p||!!w,j=(w==null?void 0:w.message)||m;return l.jsxs("fieldset",{className:we("w-full flex flex-col gap-1",u),"aria-invalid":k||void 0,disabled:h,children:[e&&l.jsx("legend",{className:we("mb-1 text-ds-sm text-[var(--color-ds-text-primary)]",!f&&"sr-only"),children:e}),l.jsx("div",{className:we(d?"flex flex-col gap-2":"flex flex-wrap gap-2"),children:t.map(A=>{const S=y(A.value),_=h||!!(A!=null&&A.disabled),M=we("inline-flex items-center justify-center border transition-all duration-150",i?"rounded-[6px]":"rounded-full",rI[c],"bg-[var(--color-ds-background-page)]","border-[var(--color-ds-border-default-50)]","shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-ds-border-default)20%,transparent)]","peer-focus-visible:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-[var(--color-ds-border-default)]","hover:border-[var(--color-ds-border-default)]",i&&S&&"bg-[var(--color-ds-button-primary-bg)] border-[var(--color-ds-button-primary-bg)]",!i&&S&&"border-[var(--color-ds-button-primary-bg)]",k&&"border-[var(--color-ds-border-error)] shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-ds-border-error)30%,transparent)]",_&&"opacity-60 cursor-not-allowed"),P=we("text-ds-sm text-[var(--color-ds-text-primary)]",_&&"text-[var(--color-ds-text-secondary)]"),R=we(nI[c],"text-[var(--color-ds-button-primary-text)] transition-all duration-150",S?"opacity-100 scale-100":"opacity-0 scale-75"),I=we(c==="sm"?"w-2 h-2":c==="md"?"w-2.5 h-2.5":"w-3 h-3","rounded-full bg-[var(--color-ds-button-primary-bg)] transition-all duration-150",S?"opacity-100 scale-100":"opacity-0 scale-0");return l.jsxs("label",{className:we("inline-flex items-center gap-2 cursor-pointer select-none rounded-md px-1 py-1","hover:bg-[color-mix(in_srgb,var(--color-ds-border-default)6%,transparent)]",_&&"cursor-not-allowed hover:bg-transparent"),children:[l.jsxs("span",{className:"relative inline-flex items-center justify-center",children:[l.jsx("input",{type:i?"checkbox":"radio",name:n,value:A.value,checked:S,onChange:()=>E(A.value),disabled:_,className:"peer sr-only"}),l.jsx("span",{"aria-hidden":!0,className:M,children:i?l.jsx(Bc,{className:R}):l.jsx("span",{className:I})})]}),l.jsx("span",{className:P,children:A.label})]},String(A.value))})}),k&&!!j&&l.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)] mt-1",children:j})]})}})}function aI(e){function t(i){var c,d;for(const u of Object.keys(i)){if((c=i[u])!=null&&c.types||(d=i[u])!=null&&d.message)return u;if(typeof i[u]=="object"){const f=t(i[u]);if(f)return`${u}.${f}`}}return null}const r=t(e);if(!r)return;const n=`[name="${r}"]`,a=`[name^="${r}["], [name^="${r}."]`,o=document.querySelector(n)??document.querySelector(a);o&&(o.scrollIntoView({behavior:"smooth",block:"center"}),o.focus({preventScroll:!0}))}const oI={success:"bg-green-100 border-green-500 text-green-800",error:"bg-red-100 border-red-500 text-red-800",info:"bg-blue-100 border-blue-500 text-blue-800",warning:"bg-yellow-100 border-yellow-500 text-yellow-800"},P2=({id:e,message:t,variant:r="info",duration:n=5e3,onClose:a})=>(C.useEffect(()=>{const o=setTimeout(()=>a(e),n);return()=>clearTimeout(o)},[e,n,a]),l.jsxs("div",{className:we("w-80 max-w-full border-l-4 rounded shadow-md p-4 mb-2 flex justify-between items-start",oI[r]),role:"alert","aria-live":"assertive",children:[l.jsx("span",{className:"flex-1",children:t}),l.jsx("button",{onClick:()=>a(e),className:"ml-4 text-xl font-bold leading-none focus:outline-none",children:"×"})]})),jt=[];for(let e=0;e<256;++e)jt.push((e+256).toString(16).slice(1));function sI(e,t=0){return(jt[e[t+0]]+jt[e[t+1]]+jt[e[t+2]]+jt[e[t+3]]+"-"+jt[e[t+4]]+jt[e[t+5]]+"-"+jt[e[t+6]]+jt[e[t+7]]+"-"+jt[e[t+8]]+jt[e[t+9]]+"-"+jt[e[t+10]]+jt[e[t+11]]+jt[e[t+12]]+jt[e[t+13]]+jt[e[t+14]]+jt[e[t+15]]).toLowerCase()}let ud;const iI=new Uint8Array(16);function lI(){if(!ud){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ud=crypto.getRandomValues.bind(crypto)}return ud(iI)}const V2={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function cI(e,t,r){var a;e=e||{};const n=e.random??((a=e.rng)==null?void 0:a.call(e))??lI();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,sI(n)}function dI(e,t,r){return V2.randomUUID&&!e?V2.randomUUID():cI(e)}const Z2=C.createContext(null),xn=()=>{const e=C.useContext(Z2);if(!e)throw new Error("useToast debe usarse dentro de <ToastProvider>");return e},uI=({children:e})=>{const[t,r]=C.useState([]),n=(o,i="info",c=5e3)=>{const d=dI();r(u=>[...u,{id:d,message:o,variant:i,duration:c}])},a=o=>{r(i=>i.filter(c=>c.id!==o))};return l.jsxs(Z2.Provider,{value:{show:n},children:[e,l.jsx("div",{className:"fixed top-4 right-4 z-50 flex flex-col items-end",children:t.map(o=>l.jsx(P2,{id:o.id,message:o.message,variant:o.variant,duration:o.duration,onClose:a},o.id))})]})},fI=e=>e.type==="inputGroup",hI=e=>e.type==="button",pI=e=>!fI(e)&&!hI(e);function z2(e){const t=Array.isArray(e)?e:[];return C.useMemo(()=>{const r={};for(const n of t)pI(n)&&n.name&&(r[n.name]=n);return r},[t])}const H2=C.createContext(null);function W2({children:e,value:t}){return l.jsx(H2.Provider,{value:t,children:e})}function Zt(){const e=C.useContext(H2);if(!e)throw new Error("useAdapters debe usarse dentro de <AdaptersProvider />");return e}const mI=e=>!!e&&typeof e.then=="function";function gI(e){return Array.isArray(e)?e.length>0&&typeof e[0]=="object"&&e[0]!==null?e.map(t=>{var a;if("label"in t&&"value"in t)return t;const n=(a=Object.entries(t)[0])==null?void 0:a[1];return{label:String(n??JSON.stringify(t)),value:String(n??"")}}):e.map(t=>({label:String(t),value:t})):[]}function U2(e){const{services:t}=Zt(),[r,n]=C.useState({}),[a,o]=C.useState(0),i=C.useRef(!0);C.useEffect(()=>(i.current=!0,()=>{i.current=!1}),[]);const c=C.useMemo(()=>e.filter(d=>d.type==="select"&&!d.options&&typeof d.optionSource=="string"&&d.name),[e]);return C.useEffect(()=>{if(c.length===0)return;let d=!1;return(async()=>{o(u=>u+1);try{const u=await Promise.all(c.map(async f=>{var b;const h=f.name,p=f.optionSource,m=(b=t==null?void 0:t.registry)==null?void 0:b[p];if(!m)return[h,[]];const v=mI(m)?await m:await m(),g=gI(v);return[h,g]}));if(d||!i.current)return;n(f=>{const h={...f};for(const[p,m]of u)h[p]=[...m];return h})}finally{!d&&i.current&&o(u=>Math.max(0,u-1))}})(),()=>{d=!0}},[c,t==null?void 0:t.registry]),{optionsMap:r,loadingCount:a}}const vI=e=>e.type==="inputGroup",bI=e=>e.type==="button",wI=e=>!vI(e)&&!bI(e);function xI(e){return typeof e=="object"&&e!==null}const yI=e=>{const t=e.disabledWhen;if(!xI(t))return!1;const r="watchField"in t,n="rule"in t;return r&&!n};function q2(e,t){const r=Array.isArray(e)?e:[],n=C.useMemo(()=>r.filter(wI).filter(yI),[r]),a=C.useMemo(()=>n.map(d=>d.disabledWhen.watchField),[n]),o=Ec({control:t,name:a,compute:d=>d}),i=Array.isArray(o)?o:[],c={};return n.forEach((d,u)=>{const f=i[u];c[d.name??`__unnamed_${u}`]=f===d.disabledWhen.watchValue}),c}const kI={sm:"text-ds-sm",md:"text-ds-sm",lg:"text-ds-sm"},EI={sm:"px-2 py-1.5",md:"px-3 py-2",lg:"px-4 py-3"};function Dr({control:e,name:t,rules:r,defaultValue:n,size:a="sm",width:o="100%",label:i,labelHidden:c=!1,hasError:d=!1,errorMessage:u="",maxLength:f,showCounter:h=!1,className:p,suffixButton:m,labelPrefixIcon:v,labelSuffixIcon:g,info:b,infoHeader:x,infoAriaLabel:w,prefixIcon:y,suffixIcon:E,reserveErrorSpace:k,disableErrorPlaceholder:j,id:A,...S}){const _=C.useId(),M=A||_,[P,R]=C.useState(String(n??S.value??"")),I=typeof k=="boolean"?k:typeof j=="boolean"?!j:!!e,F=we("box-border bg-[var(--color-ds-background-page)] w-full rounded-lg border outline-none transition","placeholder-[var(--color-ds-text-secondary)] text-[var(--color-ds-text-primary)]",kI[a],EI[a],d?"border-[var(--color-ds-border-error)]":"border-[var(--color-ds-border-default)]",S.disabled&&"bg-[var(--color-ds-background-disabled)] border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-secondary)] cursor-not-allowed"),V=y?"pl-9":"",te=E?"pr-9":"",X=N=>{var O;typeof f=="number"&&N.target.value.length>f||(R(N.target.value),(O=S.onChange)==null||O.call(S,N))},ne=o&&(o.includes(" ")||o.startsWith("w-")||o.startsWith("max-w-")||o.startsWith("min-w-")),se=ne?void 0:{width:o},G=we("flex flex-col",ne&&o,p);return C.useEffect(()=>{n!==void 0&&R(String(n??""))},[n]),e&&t?l.jsx(Ct,{name:t,control:e,rules:r,defaultValue:n??"",render:({field:N,fieldState:O})=>{var ae;return l.jsxs("div",{className:G,style:se,children:[!c&&i&&l.jsx(gr,{id:M,text:i,size:a,prefixIcon:v,suffixIcon:g,info:b,infoHeader:x,infoAriaLabel:w}),l.jsxs("div",{className:"flex items-stretch gap-2",children:[l.jsxs("div",{className:"relative w-full",children:[y&&l.jsx("span",{className:"absolute left-2 top-2.5",children:l.jsx(_t,{component:y,size:a,className:"text-[var(--color-ds-text-secondary)]"})}),l.jsx("textarea",{id:M,"aria-invalid":!!O.error,className:we(F,V,te),maxLength:f,...N,placeholder:S.disabled?"":S.placeholder,onChange:K=>{N.onChange(K),h&&R(K.target.value)}}),E&&l.jsx("span",{className:"absolute right-2 top-2.5",children:l.jsx(_t,{component:E,size:a,className:"text-[var(--color-ds-text-secondary)]"})})]}),m?l.jsx("div",{className:"shrink-0",children:m}):null]}),l.jsxs("div",{className:"flex justify-between pt-1 h-[1em]",children:[I?O.error?l.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)]",children:O.error.message}):l.jsx("span",{"aria-hidden":"true",children:" "}):O.error?l.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)]",children:O.error.message}):l.jsx("span",{"aria-hidden":"true",children:" "}),h&&typeof f=="number"&&l.jsxs("span",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:[((ae=N.value)==null?void 0:ae.length)??0,"/",f]})]})]})}}):l.jsxs("div",{className:G,style:se,children:[!c&&i&&l.jsx(gr,{id:M,text:i,size:a,prefixIcon:v,suffixIcon:g,info:b,infoHeader:x,infoAriaLabel:w}),l.jsxs("div",{className:"flex items-stretch gap-2",children:[l.jsxs("div",{className:"relative w-full",children:[y&&l.jsx("span",{className:"absolute left-2 top-2.5",children:l.jsx(_t,{component:y,size:a,className:"text-[var(--color-ds-text-secondary)]"})}),l.jsx("textarea",{id:M,className:we(F,V,te),value:P,onChange:X,maxLength:f,...S,placeholder:S.disabled?"":S.placeholder}),E&&l.jsx("span",{className:"absolute right-2 top-2.5",children:l.jsx(_t,{component:E,size:a,className:"text-[var(--color-ds-text-secondary)]"})})]}),m?l.jsx("div",{className:"shrink-0",children:m}):null]}),l.jsxs("div",{className:"flex justify-between pt-1 h-[1em]",children:[I?d&&u?l.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)]",children:u}):l.jsx("span",{"aria-hidden":"true",children:" "}):d&&u?l.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)]",children:u}):l.jsx("span",{"aria-hidden":"true",children:" "}),h&&typeof f=="number"&&l.jsxs("span",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:[P.length,"/",f]})]})]})}const CI={sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},jI={sm:"w-3 h-3",md:"w-3.5 h-3.5",lg:"w-4 h-4"};function it({control:e=null,name:t,rules:r,defaultValue:n=!1,label:a,labelHidden:o=!1,disabled:i=!1,size:c="sm",className:d,hasError:u=!1,errorMessage:f="",reserveErrorSpace:h,disableErrorPlaceholder:p,checked:m,indeterminate:v,onChange:g}){const b=we("text-[var(--color-ds-text-primary)] text-ds-sm",i&&"text-[var(--color-ds-text-secondary)]",o&&"sr-only"),x=typeof h=="boolean"?h:typeof p=="boolean"?!p:!!e,w=(y,E,k)=>{const j=u||!!k,A=(k==null?void 0:k.message)||f,S=we("inline-flex items-center justify-center rounded-[6px] border transition-all duration-150",CI[c],"bg-[var(--color-ds-background-page)]","border-[var(--color-ds-border-default-50)]","shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-ds-border-default)20%,transparent)]","peer-focus-visible:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-[var(--color-ds-border-default)]","hover:border-[var(--color-ds-border-default)]",(y||v)&&"bg-[var(--color-ds-button-primary-bg)] border-[var(--color-ds-button-primary-bg)]",j&&"border-[var(--color-ds-border-error)] shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-ds-border-error)30%,transparent)]",i&&"opacity-60 cursor-not-allowed"),_=we(jI[c],"text-[var(--color-ds-button-primary-text)]","transition-all duration-150",y||v?"opacity-100 scale-100":"opacity-0 scale-75");return l.jsxs("div",{className:we("flex flex-col gap-1",d),children:[C.createElement(typeof a=="string"?"label":"div",{className:we("inline-flex items-center gap-2 cursor-pointer select-none",i&&"cursor-not-allowed")},l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"relative inline-flex items-center justify-center",children:[l.jsx("input",{id:t,type:"checkbox",className:"peer sr-only",checked:y,ref:M=>{M&&(M.indeterminate=!!v)},onChange:M=>E(M.target.checked),disabled:i}),l.jsx("span",{"aria-hidden":!0,className:S,children:v?l.jsx("div",{className:"bg-white h-0.5 w-[60%] rounded-full"}):l.jsx(Bc,{className:_})})]}),a&&l.jsx("span",{className:b,children:a})]})),x?l.jsx("div",{className:"h-[1em]",children:j&&A?l.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)] h-[1em]",children:A}):l.jsx("span",{"aria-hidden":"true",children:" "})}):j&&A?l.jsx("div",{className:"pt-1",children:l.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)] h-[1em]",children:A})}):null]})};return e?l.jsx(Ct,{name:t||"",control:e,rules:r,defaultValue:n,render:({field:y,fieldState:E})=>{const k=E.error;return w(!!y.value,j=>y.onChange(j),k)}}):w(!!m,y=>g==null?void 0:g(y))}function fd({name:e,control:t,searchFn:r,resolveByValue:n,label:a,size:o="sm",width:i="100%",disabled:c=!1,searchMode:d="button",minChars:u=3,debounceMs:f=600,labelPrefixIcon:h,labelSuffixIcon:p,prefixIcon:m,suffixIcon:v,reserveErrorSpace:g,disableErrorPlaceholder:b}){const x=gn(),{watch:w,getValues:y,setValue:E}=x,k=Ec({control:t,name:e}),[j,A]=C.useState([]),[S,_]=C.useState(!1),[M,P]=C.useState(!1),[R,I]=C.useState(""),F=C.useRef(null),V=C.useRef(null),te=C.useRef(!1),X=C.useRef(!1),ne=C.useRef(!0),se=C.useMemo(()=>{const fe=new Map;for(const le of j)fe.set(String(le.value).trim(),le.label??"");return fe},[j]),G=async fe=>{const le=(fe??"").trim();if(!le){A([]),P(!1);return}_(!0);try{const Ce=await r(le,{watch:w,getValues:y});A(Ce??[]),P(!0)}finally{_(!1)}};C.useEffect(()=>{function fe(le){F.current&&!F.current.contains(le.target)&&P(!1)}if(M)return document.addEventListener("mousedown",fe),()=>document.removeEventListener("mousedown",fe)},[M]);const[N,O]=C.useState({});C.useEffect(()=>{if(te.current)return;const le=(k?String(k):"").trim();if(!le){R!==""&&I(""),P(!1);return}const Ce=se.get(le);if(Ce){R!==Ce&&(I(Ce),ne.current=!0);return}const ce=N[le];if(ce){R!==ce&&(I(ce),ne.current=!0);return}let xe=!1;return n?(R!==le&&I(le),(async()=>{try{const D=await n(le,{watch:w,getValues:y});if(xe)return;if(D){const q=D.label??String(D.value);O(re=>{const W={...re,[le]:q};return I(q),ne.current=!0,W})}else R!==le&&(I(le),ne.current=!0)}catch{!xe&&R!==le&&(I(le),ne.current=!0)}})()):R!==le&&(I(le),ne.current=!0),()=>{xe=!0}},[k,se,N,n,w,y]),C.useEffect(()=>{if(d!=="debounced"||c)return;if(ne.current){ne.current=!1;return}if(!X.current)return;V.current&&(window.clearTimeout(V.current),V.current=null);const fe=(R||"").trim();return fe.length>=u?V.current=window.setTimeout(()=>{G(fe)},f):(A([]),P(!1)),()=>{V.current&&(window.clearTimeout(V.current),V.current=null)}},[R,d,u,f,c]);const ae=o==="sm"?"text-ds-sm":o==="md"?"text-ds-md":"text-ds-lg",K=o==="sm"?"h-6":o==="md"?"h-10":"h-12",Q=fe=>{if(c)return;const le=(R||"").trim();fe.key==="Enter"&&(fe.preventDefault(),d==="debounced"?le.length>=u&&G(le):G(le)),fe.key==="Escape"&&P(!1)},pe=i&&(i.includes(" ")||i.startsWith("w-")||i.startsWith("max-w-")||i.startsWith("min-w-")),ge=pe?void 0:{width:i},ue=`relative flex flex-col ${pe?i:""}`;return l.jsx(Ct,{name:e,control:t,render:({field:fe,fieldState:le})=>{var Ce;return l.jsxs("div",{ref:F,className:ue,style:ge,children:[a&&l.jsx(gr,{id:e,text:a,size:o,prefixIcon:h,suffixIcon:p}),l.jsx(De,{className:d==="button"?"rounded-r-none":void 0,type:"text",size:o,width:"100%",value:R,prefixIcon:m,suffixIcon:v,onChange:ce=>{const xe=ce.target.value;te.current=!0,X.current=!0,I(xe),(k?String(k):"").trim()&&E(e,"",{shouldDirty:!0})},onKeyDown:Q,onBlur:()=>{te.current=!1},disabled:c,hasError:le.invalid,errorMessage:(Ce=le.error)==null?void 0:Ce.message,reserveErrorSpace:g,disableErrorPlaceholder:b,onFocus:()=>{if(te.current=!0,d==="button"&&X.current){const ce=(R||"").trim();ce&&G(ce)}},suffixButton:d==="button"?l.jsx(me,{type:"button",className:"!rounded-l-none",size:o,variant:"primary",onClick:()=>G((R||"").trim()),disabled:c,children:"Buscar"}):void 0}),S&&l.jsx("div",{className:"absolute top-14 left-0 right-0 z-10",children:l.jsx(Br,{width:"100%",height:o==="sm"?"1.5rem":o==="md"?"2.5rem":"3rem",variant:"rect",className:"rounded-lg"})}),M&&!S&&j.length>0&&l.jsx("ul",{className:`
|
|
92
|
+
`,u=new Blob([d],{type:"application/javascript"}),f=URL.createObjectURL(u),h=new Worker(f),p=setTimeout(()=>{h.terminate(),URL.revokeObjectURL(f),c(new Error("Timeout: La validación tardó demasiado."))},a);h.onmessage=m=>{clearTimeout(p),h.terminate(),URL.revokeObjectURL(f),m.data.success?i(m.data.result):(console.warn("Validation Script Error:",m.data.error),i("Error en script de validación"))},h.onerror=m=>{clearTimeout(p),h.terminate(),URL.revokeObjectURL(f),c(m)},h.postMessage({code:e,context:t,translations:o})})}const O$={ds:{fileUploader:{browse:"Document",dragDrop:"Drag your files here or click to browse",view:"View",remove:"Remove"},form:{fieldRequired:"Required field",invalidEmail:"Invalid email",submit:"Submit",sending:"Sending…",saveSuccess:"Saved successfully!",saveError:"There are errors in the form"},editor:{inspector:{field:"Field Inspector",tab:"Tab Inspector",section:"Section Inspector"},actions:{move:"Move",moveLeft:"Move left",moveRight:"Move right",add:"Add",addTab:"Tab to the right",addSection:"Add section",addRow:"Add row",addColumn:"Add column",delete:"Delete",deleteTab:"Delete tab",deleteColumn:"Remove last column",duplicate:"Duplicate",cancel:"Cancel"},confirmations:{deleteField:{title:"Delete field",message:"Are you sure you want to delete this field?"},deleteColumn:{title:"Delete column",message:"Are you sure you want to delete the last column? Fields it contains will be lost."},deleteRow:{title:"Delete row",message:"Are you sure you want to delete this row? All fields it contains will be lost."},deleteSection:{title:"Delete section",message:"Are you sure you want to delete this section? All fields it contains will be lost."}},title:"Form Schema Editor",context:"Context:",modes:{design:"Designer",preview:"Preview",code:"Code"},codeViewer:{copy:"Copy code",copied:"Copied",lines:"lines",format:"Format"},toolbar:{export:"Export",import:"Import JSON",shortcuts:"Shortcuts",showRelations:"Show relations",hideRelations:"Hide relations",toggleSidePanel:{open:"Open side panel",close:"Close side panel"}},importModal:{trigger:"Generate from object",triggerTitle:"Generate form from JSON or TypeScript",title:"Generate from JSON or TypeScript",labels:{formTitle:"Form Title",formId:"Form ID",layout:"Layout (cols)",input:"Input (paste JSON or TypeScript interface/type)"},placeholders:{layout:{auto:"Auto",col1:"1 column",col2:"2 columns",col3:"3 columns",col4:"4 columns"}},actions:{cancel:"Cancel",generate:"Generate Form",generating:"Generating..."},messages:{success:"Form generated successfully.",error:"Could not generate form."}}},fields:{defaults:{text:{label:"Text",placeholder:"Type…"},number:{label:"Number",placeholder:"0"},email:{label:"Email",placeholder:"user@domain.com"},password:{label:"Password",placeholder:"••••••••"},tel:{label:"Phone",placeholder:"600 000 000"},url:{label:"URL",placeholder:"https://example.com"},textarea:{label:"Comment",placeholder:"Write your comment…"},select:{label:"Select",placeholder:"Select an option"},checkbox:{label:"Checkbox"},date:{label:"Date"},file:{label:"File"},search:{label:"Search",placeholder:"Search...",noMatches:"No matches found"}},validation:{required:"Required field",invalidEmail:"Invalid email",invalidUrl:"Invalid URL",invalidPhone:"Invalid phone",invalidID:"Invalid identity document",invalidIBAN:"Invalid IBAN",minLength:"Minimum {{count}} characters",maxLength:"Maximum {{count}} characters",pattern:"Invalid format",numberMin:"Must be greater than or equal to {{min}}",numberMax:"Must be less than or equal to {{max}}",step:"Must be a multiple of {{step}}",integerOnly:"Must be an integer",positiveOnly:"Must be a positive number",selectMin:"Select at least {{count}} options",selectMax:"Select at most {{count}} options",dateMin:"Date must be after {{date}}",dateMax:"Date must be before {{date}}",disallowPast:"Past dates are not allowed",disallowFuture:"Future dates are not allowed",number:"Must be a number",date:"Invalid date",invalidOption:"Invalid option",mustCheck:"You must check this box",invalidFile:"Invalid file",invalidFileType:"File type not allowed",fileMaxCount:"Max. {{count}} file(s)",fileMaxSize:"File must not exceed {{size}}MB",minItems:"Minimum {{count}} items",maxItems:"Maximum {{count}} items"}}}},L$={ds:{fileUploader:{browse:"Documento",dragDrop:"Arrastra tus archivos aquí o haz clic para buscarlos",view:"Ver",remove:"Eliminar"},form:{fieldRequired:"Campo obligatorio",invalidEmail:"Email inválido",submit:"Enviar",sending:"Enviando…",saveSuccess:"¡Guardado con éxito!",saveError:"Hay errores en el formulario"},editor:{inspector:{field:"Inspector de campo",tab:"Inspector de pestaña",section:"Inspector de sección"},actions:{move:"Mover",moveLeft:"Mover a la izquierda",moveRight:"Mover a la derecha",add:"Añadir",addTab:"Pestaña a la derecha",addSection:"Añadir sección",addRow:"Añadir fila",addColumn:"Añadir columna",delete:"Eliminar",deleteTab:"Eliminar pestaña",deleteColumn:"Quitar última columna",duplicate:"Duplicar",cancel:"Cancelar"},confirmations:{deleteField:{title:"Eliminar campo",message:"¿Estás seguro de que quieres eliminar este campo?"},deleteColumn:{title:"Eliminar columna",message:"¿Estás seguro de que quieres eliminar la última columna? Se perderán los campos que contiene."},deleteRow:{title:"Eliminar fila",message:"¿Estás seguro de que quieres eliminar esta fila? Se perderán todos los campos que contiene."},deleteSection:{title:"Eliminar sección",message:"¿Estás seguro de que quieres eliminar esta sección? Se perderán todos los campos que contiene."}},title:"Editor de Esquema de Formulario",context:"Contexto:",modes:{design:"Diseñar",preview:"Vista Previa",code:"Código"},codeViewer:{copy:"Copiar código",copied:"Copiado",lines:"líneas",format:"Formato"},toolbar:{export:"Exportar",import:"Importar JSON",shortcuts:"Configurar atajos",showRelations:"Mostrar relaciones",hideRelations:"Ocultar relaciones",toggleSidePanel:{open:"Abrir panel lateral",close:"Cerrar panel lateral"}},importModal:{trigger:"Generar desde objeto",triggerTitle:"Generar formulario desde JSON o TypeScript",title:"Generar desde JSON o TypeScript",labels:{formTitle:"Título del formulario",formId:"ID del formulario",layout:"Distribución (cols)",input:"Entrada (pega JSON o una interface/type de TypeScript)"},placeholders:{layout:{auto:"Auto",col1:"1 columna",col2:"2 columnas",col3:"3 columnas",col4:"4 columnas"}},actions:{cancel:"Cancelar",generate:"Generar formulario",generating:"Generando..."},messages:{success:"Formulario generado correctamente.",error:"No se pudo generar el formulario."}}},fields:{defaults:{text:{label:"Texto",placeholder:"Escribe…"},number:{label:"Número",placeholder:"0"},email:{label:"Email",placeholder:"usuario@dominio.com"},password:{label:"Contraseña",placeholder:"••••••••"},tel:{label:"Teléfono",placeholder:"600 000 000"},url:{label:"URL",placeholder:"https://ejemplo.com"},textarea:{label:"Comentario",placeholder:"Escribe tu comentario…"},select:{label:"Seleccionar",placeholder:"Seleccione una opción"},checkbox:{label:"Casilla"},date:{label:"Fecha"},file:{label:"Archivo"},search:{label:"Búsqueda",placeholder:"Buscar...",noMatches:"No hay coincidencias"}},validation:{required:"Campo obligatorio",invalidEmail:"Email inválido",invalidUrl:"URL inválida",invalidPhone:"Teléfono inválido",invalidID:"Documento de identidad inválido",invalidIBAN:"IBAN inválido",minLength:"Mínimo {{count}} caracteres",maxLength:"Máximo {{count}} caracteres",pattern:"Formato inválido",numberMin:"Debe ser mayor o igual a {{min}}",numberMax:"Debe ser menor o igual a {{max}}",step:"Debe ser múltiplo de {{step}}",integerOnly:"Debe ser un número entero",positiveOnly:"Debe ser un número positivo",selectMin:"Selecciona al menos {{count}} opciones",selectMax:"Selecciona como máximo {{count}} opciones",dateMin:"La fecha debe ser posterior a {{date}}",dateMax:"La fecha debe ser anterior a {{date}}",disallowPast:"No se permiten fechas pasadas",disallowFuture:"No se permiten fechas futuras",number:"Debe ser un número",date:"Fecha inválida",invalidOption:"Opción inválida",mustCheck:"Debes marcar esta casilla",invalidFile:"Archivo inválido",invalidFileType:"Tipo de archivo no permitido",fileMaxCount:"Máx. {{count}} fichero(s)",fileMaxSize:"El archivo no debe superar {{size}}MB",minItems:"Mínimo {{count}} elementos",maxItems:"Máximo {{count}} elementos"}}}};qe.use(RT).init({resources:{en:{translation:O$},es:{translation:L$}},lng:"es",fallbackLng:"es",interpolation:{escapeValue:!1}});const T$=e=>{qe.changeLanguage(e)},_2="TRWAGMYFPDXBNJZSQVHLCKE",$$=["X","Y","Z"];function I$(e){if(!/^\d{8}[A-Z]$/.test(e))return!1;const t=parseInt(e.substring(0,8),10),r=e.charAt(8),n=_2.charAt(t%23);return r===n}function B$(e){if(!/^[XYZ]\d{7}[A-Z]$/.test(e))return!1;const t=e.charAt(0),n=$$.indexOf(t).toString()+e.substring(1),a=parseInt(n.substring(0,8),10),o=e.charAt(8),i=_2.charAt(a%23);return o===i}function P$(e){if(!/^[A-Z]\d{7}[A-Z0-9]$/.test(e))return!1;const t=e.charAt(0),r=e.substring(1,8),n=e.charAt(8);let a=0;for(let f=0;f<7;f++){const h=parseInt(r.charAt(f),10);if(f%2===0){const p=h*2;a+=Math.floor(p/10)+p%10}else a+=h}const o=a%10,i=o===0?0:10-o,c="JABCDEFGHI".charAt(i);return["A","B","E","H"].includes(t)?n===i.toString():n===c||n===i.toString()}function V$(e){if(!e||e.length<9)return!1;const t=e.toUpperCase().replace(/\s+/g,"").replace(/[^A-Z0-9]/g,"");return/^\d{8}[A-Z]$/.test(t)?I$(t):/^[XYZ]\d{7}[A-Z]$/.test(t)?B$(t):/^[A-Z]\d{7}[A-Z0-9]$/.test(t)?P$(t):!1}const Z$=/^\s*(?:\+?\d{1,4}[\s-]*)?(?:\(?\d{2,4}\)?[\s-]*)?\d{3,4}[\s-]?\d{3,4}\s*$/;function M2(e){return(e??"").toUpperCase().replace(/\s+/g,"").replace(/[^A-Z0-9]/g,"")}function z$(e){const t=M2(e);if(t.length<15||t.length>34||!/^[A-Z]{2}\d{2}[A-Z0-9]+$/.test(t))return!1;const r=t.slice(4)+t.slice(0,4);let n=0;for(const a of r){const o=a.charCodeAt(0);if(o>=65&&o<=90){const i=String(o-55);for(let c=0;c<i.length;c++)n=(n*10+(i.charCodeAt(c)-48))%97}else n=(n*10+(a.charCodeAt(0)-48))%97}return n===1}function H$(e){return e.validation??{}}function W$(e){return!!e.multiple}function U$(e){const t=e.maxFiles;return typeof t=="number"?t:void 0}function q$(e){const t=e.options;return Array.isArray(t)?t.map(r=>r==null?void 0:r.value).filter(r=>r!==void 0):[]}function G$(e){if(!e)return{exts:[],mimes:[]};const t=e.split(",").map(a=>a.trim().toLowerCase()).filter(Boolean),r=[],n=[];for(const a of t)a.startsWith(".")?r.push(a):a.includes("/")&&n.push(a);return{exts:r,mimes:n}}function bt(e,t){const r=typeof e=="string"?e:t;return qe.isInitialized&&(r.startsWith("forms.")||r.startsWith("ds."))?qe.t(r):r}function br(e,t){let r=e;return t.required&&(r=r.required(bt(t.requiredMessage||(typeof t.required=="string"?t.required:void 0),"ds.fields.validation.required"))),t.customFn&&(r=r.test({name:"custom-script-validation",message:"${path} no es válido",test:async function(n,a){if(n==null||n==="")return!0;const o=a.parent;let i={};try{if(qe.isInitialized){const c=qe.getResourceBundle(qe.language,"translation")||{},d=(u,f="")=>{for(const h of Object.keys(u)){const p=f?`${f}.${h}`:h,m=u[h];typeof m=="string"?i[p]=m:typeof m=="object"&&m!==null&&d(m,p)}};d(c)}}catch(c){console.warn("Error extracting translations for validation:",c)}try{const c=await F2(t.customFn,{value:n,form:o,customMessages:t.customMessages||{}},{translations:i});if(c===!0)return!0;if(typeof c=="string"){const d=qe.isInitialized&&c.startsWith("forms.")?qe.t(c):c;return this.createError({message:d})}return!1}catch(c){return console.error("Custom Validation Error",c),this.createError({message:"Error ejecutando validación: "+String(c)})}}})),r}function zn(e,t){var n,a,o;let r=e;return((n=t.minLength)==null?void 0:n.value)!=null&&(r=r.min(t.minLength.value,bt(t.minLength.message,"ds.fields.validation.minLength"))),((a=t.maxLength)==null?void 0:a.value)!=null&&(r=r.max(t.maxLength.value,bt(t.maxLength.message,"ds.fields.validation.maxLength"))),((o=t.pattern)==null?void 0:o.value)instanceof RegExp&&(r=r.matches(t.pattern.value,bt(t.pattern.message,"ds.fields.validation.pattern"))),r}function K$(e,t){var n,a,o,i;let r=e;if(((n=t.numberMin)==null?void 0:n.value)!=null&&(r=r.min(t.numberMin.value,bt(t.numberMin.message,"ds.fields.validation.numberMin"))),((a=t.numberMax)==null?void 0:a.value)!=null&&(r=r.max(t.numberMax.value,bt(t.numberMax.message,"ds.fields.validation.numberMax"))),t.positiveOnly&&(r=r.moreThan(0,bt(t.positiveOnly,"ds.fields.validation.positiveOnly"))),t.integerOnly&&(r=r.integer(bt(t.integerOnly,"ds.fields.validation.integerOnly"))),((o=t.step)==null?void 0:o.value)!=null){const c=Number(t.step.value),d=t.step.message||"ds.fields.validation.step";r=r.test("step",d,u=>{if(u==null||Number.isNaN(u)||c===0)return!0;const f=u/c;return Math.abs(f-Math.round(f))<1e-9})}return((i=t.pattern)==null?void 0:i.value)instanceof RegExp&&(r=r.test("pattern-number",t.pattern.message||"ds.fields.validation.pattern",c=>c==null||t.pattern.value.test(String(c)))),r}function J$(e,t){var n,a;let r=e;return(n=t.dateMin)!=null&&n.value&&(r=r.min(new Date(t.dateMin.value),bt(t.dateMin.message,"ds.fields.validation.dateMin"))),(a=t.dateMax)!=null&&a.value&&(r=r.max(new Date(t.dateMax.value),bt(t.dateMax.message,"ds.fields.validation.dateMax"))),t.disallowPast&&(r=r.min(new Date,bt(t.disallowPast,"ds.fields.validation.disallowPast"))),t.disallowFuture&&(r=r.max(new Date,bt(t.disallowFuture,"ds.fields.validation.disallowFuture"))),r}function Y$(e){var r,n,a,o;const t=H$(e);switch(e.type){case"text":case"password":case"textarea":case"search":{let i=wn().trim();return i=zn(i,t),br(i,t)}case"dni":{let i=wn().trim();return i=zn(i,t),i=i.test("dni-valid",bt("ds.fields.validation.invalidID","Documento de identidad inválido"),c=>c==null||c===""?!0:V$(c)),br(i,t)}case"email":{let i=wn().trim().email(bt(t.emailMessage,"ds.fields.validation.invalidEmail"));return i=zn(i,t),br(i,t)}case"url":{let i=wn().trim().url(bt(t.urlMessage,"ds.fields.validation.invalidUrl"));return i=zn(i,t),br(i,t)}case"tel":{let i=wn().trim();return i=zn(i,t),(r=t.pattern)!=null&&r.value||(i=i.matches(Z$,bt(t.phoneMessage,"ds.fields.validation.invalidPhone"))),br(i,t)}case"iban":{let i=wn().transform((c,d)=>d===""||d===null||d===void 0?"":typeof d=="string"?M2(d):c);return i=zn(i,t),i=i.test("iban-valid",bt("ds.fields.validation.invalidIBAN","IBAN inválido"),c=>c==null||c===""?!0:z$(String(c))),br(i,t)}case"number":{let i=x2().transform((c,d)=>{if(d===""||d===null||d===void 0)return;const u=typeof d=="string"?Number(d.replace(",",".")):c;return Number.isNaN(u)?NaN:u}).typeError(bt(t.typeError,"ds.fields.validation.number"));return i=K$(i,t),br(i,t)}case"date":{let i=od().nullable().typeError(bt(t.typeError,"ds.fields.validation.date")).transform((c,d)=>d?new Date(d):null);return i=J$(i,t),br(i,t)}case"select":case"optionGroup":{const i=W$(e),c=q$(e);if(i){let d=id().of(c.length?Ao().oneOf(c,"ds.fields.validation.invalidOption"):Ao());return t.required&&(d=d.min(1,t.requiredMessage||(typeof t.required=="string"?t.required:"ds.fields.validation.required"))),d}else{let d=wn().trim();return d=zn(d,t),c.length&&(d=d.oneOf(c,"ds.fields.validation.invalidOption")),br(d,t)}}case"checkbox":{let i=v2();return t.required&&(i=i.oneOf([!0],t.requiredMessage||"ds.fields.validation.mustCheck")),i}case"file":{const i=e,{exts:c,mimes:d}=G$(i.accept),u=U$(e);let f=Ao().test("file-shape","ds.fields.validation.invalidFile",h=>(h==null,!0));if((n=t.fileMaxSizeMB)!=null&&n.value){const h=Number(t.fileMaxSizeMB.value)*1024*1024,p=t.fileMaxSizeMB.message||"ds.fields.validation.fileMaxSize";f=f.test("file-max-size",p,m=>m?(Array.isArray(m)?m:typeof FileList<"u"&&m instanceof FileList?Array.from(m):[m].filter(Boolean)).every(g=>typeof(g==null?void 0:g.size)!="number"||g.size<=h):!0)}return(c.length||d.length)&&(f=f.test("file-accept","ds.fields.validation.invalidFileType",h=>h?(Array.isArray(h)?h:typeof FileList<"u"&&h instanceof FileList?Array.from(h):[h].filter(Boolean)).every(v=>{var y,E,k,j;const g=((E=(y=v==null?void 0:v.name)==null?void 0:y.toLowerCase)==null?void 0:E.call(y))||"",b=((j=(k=v==null?void 0:v.type)==null?void 0:k.toLowerCase)==null?void 0:j.call(k))||"",x=c.length===0||c.some(A=>g.endsWith(A)),w=d.length===0||d.includes(b);return x&&w}):!0)),typeof u=="number"&&(f=f.test("file-max-files","ds.fields.validation.fileMaxCount",h=>h?(Array.isArray(h)?h:typeof FileList<"u"&&h instanceof FileList?Array.from(h):[h].filter(Boolean)).length<=u:!0)),f=br(f,t),f}case"array":{const i=e,c=i.items||[],d=R2(c);let u=id().of(sd(d));t.required&&(u=u.min(1,t.requiredMessage||(typeof t.required=="string"?t.required:"ds.fields.validation.required")));const f=i.validation;return(a=f==null?void 0:f.min)!=null&&a.value&&(u=u.min(f.min.value,f.min.message||"ds.fields.validation.minItems")),(o=f==null?void 0:f.max)!=null&&o.value&&(u=u.max(f.max.value,f.max.message||"ds.fields.validation.maxItems")),u}default:{const i=Ao();return br(i,t)}}}function R2(e){const t={};for(const r of e){const n=r;n!=null&&n.name&&(t[n.name]=Y$(n))}return t}function ld(e){const t=R2(e.fields);return sd(t)}const O2=e=>{let t;const r=new Set,n=(u,f)=>{const h=typeof u=="function"?u(t):u;if(!Object.is(h,t)){const p=t;t=f??(typeof h!="object"||h===null)?h:Object.assign({},t,h),r.forEach(m=>m(t,p))}},a=()=>t,c={setState:n,getState:a,getInitialState:()=>d,subscribe:u=>(r.add(u),()=>r.delete(u))},d=t=e(n,a,c);return c},X$=(e=>e?O2(e):O2),Q$=e=>e;function eI(e,t=Q$){const r=C.useSyncExternalStore(e.subscribe,C.useCallback(()=>t(e.getState()),[e,t]),C.useCallback(()=>t(e.getInitialState()),[e,t]));return C.useDebugValue(r),r}const L2=e=>{const t=X$(e),r=n=>eI(t,n);return Object.assign(r,t),r},T2=(e=>e?L2(e):L2),Hn=T2(e=>({isActive:!1,formValues:{},systemContext:{},setRuntimeState:t=>e(r=>({...r,...t})),reset:()=>e({isActive:!1,formValues:{},systemContext:{}})}));function cd(e,t){return e?typeof e!="string"?String(e):e.replace(/\{\{([^}]+)\}\}/g,(r,n)=>{let o=n.trim().split(".").reduce((i,c)=>{if(!i)return;if(i[c]!==void 0)return i[c];const d=c.toLowerCase(),u=Object.keys(i).find(f=>f.toLowerCase()===d);return u?i[u]:void 0},t);return o!=null?String(o):r}):""}function zr({options:e,value:t,onChange:r,children:n,className:a,contentClassName:o}){const i=C.useRef(null),[c,d]=C.useState({left:0,width:0}),[u,f]=C.useState(!1),[h,p]=C.useState(!1),m=()=>{if(i.current){const{scrollLeft:g,scrollWidth:b,clientWidth:x}=i.current;f(g>0),p(g<b-x-1)}};C.useLayoutEffect(()=>{const g=i.current;if(!g)return;const b=()=>{const x=g.querySelector(`[data-value="${t}"]`);x&&d({left:x.offsetLeft,width:x.offsetWidth})};return b(),m(),window.addEventListener("resize",b),window.addEventListener("resize",m),()=>{window.removeEventListener("resize",b),window.removeEventListener("resize",m)}},[t,e]);const v=g=>{i.current&&i.current.scrollBy({left:g==="left"?-200:200,behavior:"smooth"})};return l.jsxs("div",{className:a,children:[l.jsxs("div",{className:"relative border-b border-[var(--color-ds-border-default-50)] group",children:[u&&l.jsx("div",{className:"absolute left-0 top-0 bottom-0 z-20 flex items-center bg-gradient-to-r from-[var(--color-ds-background-page)] to-transparent pr-4 pl-1 opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:l.jsx("button",{type:"button",onClick:()=>v("left"),className:"p-1 rounded-full bg-[var(--color-ds-background-surface)] shadow-sm border border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-primary)] hover:bg-[var(--color-ds-button-hover-bg)] hover:text-white transition-colors",children:l.jsx(x1,{className:"w-4 h-4"})})}),l.jsx("div",{ref:i,onScroll:m,className:"overflow-x-auto scrollbar-hidden flex items-center w-full relative",style:{scrollBehavior:"smooth"},children:l.jsxs("div",{className:"relative flex min-w-full px-1",children:[e.map(g=>{const b=g.value===t;return l.jsxs("button",{"data-value":g.value,role:"tab","aria-selected":b,onClick:()=>!g.disabled&&r(g.value),type:"button",className:we("relative z-10 whitespace-nowrap px-4 py-2 transition-colors duration-150 ease-in-out font-medium text-sm focus:outline-none",b?"text-[var(--color-ds-background-accent)]":"text-[var(--color-ds-text-secondary)] hover:text-[var(--color-ds-text-primary)]",g.disabled&&"opacity-50 cursor-not-allowed"),disabled:g.disabled,children:[g.icon&&l.jsx("span",{className:"mr-2 -ml-1 inline-block align-text-bottom",children:g.icon}),g.label]},g.value)}),l.jsx("span",{className:"absolute bottom-0 h-0.5 bg-[var(--color-ds-background-accent)] transition-all duration-200 ease-in-out z-20",style:{left:c.left,width:c.width}})]})}),h&&l.jsx("div",{className:"absolute right-0 top-0 bottom-0 z-20 flex items-center bg-gradient-to-l from-[var(--color-ds-background-page)] to-transparent pl-4 pr-1 opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:l.jsx("button",{type:"button",onClick:()=>v("right"),className:"p-1 rounded-full bg-[var(--color-ds-background-surface)] shadow-sm border border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-primary)] hover:bg-[var(--color-ds-button-hover-bg)] hover:text-white transition-colors",children:l.jsx(Zs,{className:"w-4 h-4"})})})]}),l.jsx("div",{className:we("mt-4",o),children:n[t]})]})}const _a={sm:"text-ds-sm",md:"text-ds-md",lg:"text-ds-lg"},xi={sm:"h-5",md:"h-10",lg:"h-12"},yi={sm:"px-2",md:"px-2.5",lg:"px-3"},ki={sm:"1.5rem",md:"2.5rem",lg:"3rem"},Ei={sm:"pr-9",md:"pr-11",lg:"pr-12"},tI={sm:"h-6 w-6",md:"h-8 w-8",lg:"h-10 w-10"};function Ci({id:e,size:t,disabled:r,error:n,reserveErrorSpace:a,className:o,suffixButton:i,children:c,showDropdownIndicator:d}){var u;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:we("relative w-full",o),children:[c,d&&!i&&l.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-2 flex items-center",children:l.jsx(fr,{className:"h-4 w-4 text-[var(--color-ds-text-secondary)]"})}),i&&l.jsx("div",{className:"pointer-events-none absolute flex items-center",style:{top:2,bottom:2,right:4},children:l.jsx("div",{className:"pointer-events-auto",children:C.isValidElement(i)?C.cloneElement(i,{className:we(tI[t],(u=i.props)==null?void 0:u.className)}):i})})]}),a?l.jsx("div",{className:"h-[1em]",children:n!=null&&n.message?l.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)] h-[1em]",children:n.message}):l.jsx("span",{"aria-hidden":"true",children:" "})}):n!=null&&n.message?l.jsx("div",{className:"pt-1",children:l.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)] h-[1em]",children:n.message})}):null]})}function $2(e,t){C.useEffect(()=>{const r=n=>{e.current&&(e.current.contains(n.target)||t())};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[t,e])}function Je(e){const{control:t,name:r,rules:n,defaultValue:a,options:o=[],loadOptions:i,reloadDeps:c=[],value:d,onChange:u,size:f="sm",width:h="100%",label:p,labelHidden:m=!1,info:v,infoHeader:g,hasError:b=!1,errorMessage:x="",reserveErrorSpace:w,disableErrorPlaceholder:y,disabled:E=!1,className:k,suffixButton:j,loading:A=!1,coerceFirstValid:S=!0,mode:_="menu",renderTrigger:M,renderOption:P,popupWidth:R,triggerClassName:I,onBlur:F,searchable:V=!1,searchPlaceholder:te="Buscar...",noOptionsText:X="No se encontraron resultados"}=e,ne=C.useId(),se=r||ne,[G,N]=C.useState(o),[O,ae]=C.useState(!!i);C.useEffect(()=>{if(!i){N(o);return}ae(!0),i().then(ce=>N(ce)).finally(()=>ae(!1))},[i,...c]),C.useEffect(()=>{i||N(o)},[o,i]);const K=ce=>ce.find(xe=>xe.value!==""&&xe.value!==void 0)??ce[0],Q=ce=>String(ce??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim(),pe=(ce,xe)=>{const D=Q(xe);return D?ce.filter(q=>[q.label,q.value,q.name,q.code,q.text,q.descripcion,q.description].map(Q).join(" ").includes(D)):ce},ge=typeof w=="boolean"?w:!!t,ue=h&&(h.includes(" ")||h.startsWith("w-")||h.startsWith("max-w-")||h.startsWith("min-w-")),fe=ue?{maxWidth:"100%"}:{width:h,maxWidth:"100%"},le=we("flex flex-col",ue&&h,k);if(t&&r){const{field:ce,fieldState:xe}=o5({name:r,control:t,rules:n,defaultValue:a});C.useEffect(()=>{if(!O&&G.length>0&&S){const q=ce.value,re=G.some(W=>String(W.value)===String(q));(q===void 0||!re)&&ce.onChange(K(G).value)}},[G,O,ce,S]);const D=p&&!m&&l.jsx(gr,{id:se,text:p,size:f,info:v,infoHeader:g});if((_??"native")==="menu"){const[q,re]=C.useState(!1),[W,H]=C.useState(""),J=C.useRef(null);$2(J,()=>{re(!1),H("")});const T=G.find(B=>String(B.value)===String(ce.value)),U=V?pe(G,W):G;return l.jsxs("div",{className:le,style:fe,children:[D,A||O?l.jsx(Br,{width:"100%",height:ki[f],variant:"rect",className:"rounded-lg"}):l.jsx(Ci,{id:se,size:f,disabled:E,error:xe.error,reserveErrorSpace:typeof y=="boolean"?!y:ge,className:k,suffixButton:j,showDropdownIndicator:!0,children:l.jsxs("div",{className:"relative w-full",ref:J,children:[l.jsx("button",{type:"button",onClick:()=>{E||re(B=>{const $=!B;return $||H(""),$})},onBlur:()=>{ce.onBlur(),F==null||F()},className:we("box-border w-full rounded-lg border bg-[var(--color-ds-background-page)] outline-none transition appearance-none text-left flex items-center",_a[f],xi[f],yi[f],j&&Ei[f],xe.error?"border-[var(--color-ds-border-error)]":"border-[var(--color-ds-border-default)]",E?"bg-[var(--color-ds-background-disabled)] border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-primary)] cursor-not-allowed":"text-[var(--color-ds-text-primary)] hover:border-[var(--color-ds-border-default-hover)]",I),"aria-haspopup":"listbox","aria-expanded":q,children:M?M(T):(T==null?void 0:T.label)??"—"}),q&&l.jsxs("div",{role:"listbox",className:"custom-scroll absolute z-50 mt-1 rounded-xl border border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-page)] shadow-xl p-1 max-h-72 overflow-auto",style:{width:R??"100%"},children:[V&&l.jsx("div",{className:"sticky top-0 z-10 bg-[var(--color-ds-background-page)] p-1",children:l.jsx("input",{type:"text",value:W,autoFocus:!0,onChange:B=>H(B.target.value),onClick:B=>B.stopPropagation(),onKeyDown:B=>B.stopPropagation(),placeholder:te,className:"w-full rounded-lg border border-[var(--color-ds-border-default)] bg-[var(--color-ds-background-page)] px-2 py-2 text-sm outline-none"})}),U.length>0?U.map(B=>{const $=String(B.value)===String(ce.value);return l.jsx("button",{role:"option","aria-selected":$,type:"button",onClick:()=>{ce.onChange(B.value),re(!1),H("")},className:we("w-full rounded-lg px-2 py-1.5 text-left transition-all duration-200",_a[f],$?"bg-[var(--color-ds-background-neutral)] font-medium text-[var(--color-ds-text-primary)]":"text-[var(--color-ds-text-secondary)] hover:bg-[var(--color-ds-background-neutral-hover)] hover:text-[var(--color-ds-text-primary)] hover:pl-3"),children:P?P(B,$):B.label},B.value)}):l.jsx("div",{className:"px-2 py-2 text-sm text-[var(--color-ds-text-secondary)]",children:X})]})]})})]})}return l.jsxs("div",{className:le,style:fe,children:[D,A||O?l.jsx(Br,{width:"100%",height:ki[f],variant:"rect",className:"rounded-lg"}):l.jsx(Ci,{id:se,size:f,disabled:E,error:xe.error,reserveErrorSpace:typeof y=="boolean"?!y:ge,className:k,suffixButton:j,showDropdownIndicator:!0,children:l.jsx("select",{id:se,value:ce.value,onChange:q=>ce.onChange(q.target.value),onBlur:()=>{ce.onBlur(),F==null||F()},disabled:E,className:we("box-border w-full rounded-lg border bg-[var(--color-ds-background-page)] outline-none transition appearance-none leading-none",_a[f],xi[f],yi[f],j&&Ei[f],xe.error?"border-[var(--color-ds-border-error)]":"border-[var(--color-ds-border-default)]",E?"bg-[var(--color-ds-background-disabled)] border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-primary)] cursor-not-allowed":"text-[var(--color-ds-text-primary)]",I),children:G.map(q=>l.jsx("option",{value:q.value,className:"bg-[var(--color-ds-background-page)] text-[var(--color-ds-text-primary)]",children:q.label},q.value))})})]})}C.useEffect(()=>{if(!t&&G.length>0&&S){const ce=G.some(D=>String(D.value)===String(d));(d===void 0||d===""||!ce)&&u&&u(K(G).value)}},[G,d,u,t,S]);const Ce=p&&!m&&l.jsx(gr,{id:se,text:p,size:f,info:v,infoHeader:g});if((_??"native")==="menu"){const[ce,xe]=C.useState(!1),[D,q]=C.useState(""),re=C.useRef(null);$2(re,()=>{xe(!1),q("")});const W=G.find(J=>String(J.value)===String(d)),H=V?pe(G,D):G;return l.jsxs("div",{className:le,style:fe,children:[Ce,A||O?l.jsx(Br,{width:"100%",height:ki[f],variant:"rect",className:"rounded-lg"}):l.jsx(Ci,{id:se,size:f,disabled:E,error:b?{message:x}:void 0,reserveErrorSpace:typeof y=="boolean"?!y:!!(w??!1),className:k,suffixButton:j,showDropdownIndicator:!0,children:l.jsxs("div",{className:"relative w-full",ref:re,children:[l.jsx("button",{type:"button",onClick:()=>{E||xe(J=>{const T=!J;return T||q(""),T})},onBlur:F,className:we("box-border w-full rounded-lg border bg-[var(--color-ds-background-page)] outline-none transition appearance-none text-left flex items-center",_a[f],xi[f],yi[f],j&&Ei[f],b?"border-[var(--color-ds-border-error)]":"border-[var(--color-ds-border-default)]",E?"bg-[var(--color-ds-background-disabled)] border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-primary)] cursor-not-allowed":"text-[var(--color-ds-text-primary)] hover:border-[var(--color-ds-border-default-hover)]",I),"aria-haspopup":"listbox","aria-expanded":ce,children:M?M(W):(W==null?void 0:W.label)??"—"}),ce&&l.jsxs("div",{role:"listbox",className:"custom-scroll absolute z-50 mt-1 rounded-xl border border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-page)] shadow-xl p-1 max-h-72 overflow-auto",style:{width:R??"100%"},children:[V&&l.jsx("div",{className:"sticky top-0 z-10 bg-[var(--color-ds-background-page)] p-1",children:l.jsx("input",{type:"text",value:D,onChange:J=>q(J.target.value),onClick:J=>J.stopPropagation(),placeholder:te,className:"w-full rounded-lg border border-[var(--color-ds-border-default)] bg-[var(--color-ds-background-page)] px-2 py-2 text-sm outline-none"})}),H.length>0?H.map(J=>{const T=String(J.value)===String(d);return l.jsx("button",{role:"option","aria-selected":T,type:"button",onClick:()=>{u==null||u(J.value),xe(!1),q("")},className:we("w-full rounded-lg px-2 py-1.5 text-left transition-all duration-200",_a[f],T?"bg-[var(--color-ds-background-neutral)] font-medium text-[var(--color-ds-text-primary)]":"text-[var(--color-ds-text-secondary)] hover:bg-[var(--color-ds-background-neutral-hover)] hover:text-[var(--color-ds-text-primary)] hover:pl-3"),children:P?P(J,T):J.label},J.value)}):l.jsx("div",{className:"px-2 py-2 text-sm text-[var(--color-ds-text-secondary)]",children:X})]})]})})]})}return l.jsxs("div",{className:le,style:fe,children:[Ce,A||O?l.jsx(Br,{width:"100%",height:ki[f],variant:"rect",className:"rounded-lg"}):l.jsx(Ci,{id:se,size:f,disabled:E,error:b?{message:x}:void 0,reserveErrorSpace:typeof y=="boolean"?!y:!!(w??!1),className:k,suffixButton:j,showDropdownIndicator:!0,children:l.jsx("select",{id:se,value:d,onChange:ce=>u==null?void 0:u(ce.target.value),onBlur:F,disabled:E,className:we("box-border w-full rounded-lg border bg-[var(--color-ds-background-page)] outline-none transition appearance-none leading-none",_a[f],xi[f],yi[f],j&&Ei[f],b?"border-[var(--color-ds-border-error)]":"border-[var(--color-ds-border-default)]",E?"bg-[var(--color-ds-background-disabled)] border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-primary)] cursor-not-allowed":"text-[var(--color-ds-text-primary)]"),children:G.map(ce=>l.jsx("option",{value:ce.value,className:"bg-[var(--color-ds-background-page)] text-[var(--color-ds-text-primary)]",children:ce.label},ce.value))})})]})}const I2={sm:"text-ds-sm",md:"text-ds-md",lg:"text-ds-lg"};function B2(e){var t;e.preventDefault(),e.stopPropagation(),(t=e.nativeEvent)!=null&&t.stopImmediatePropagation&&e.nativeEvent.stopImmediatePropagation()}function dd({groupLabel:e,inputs:t=[],separator:r=l.jsx("span",{className:"px-1 select-none",children:"/"}),useSeparator:n=!1,className:a,showVisibleLabel:o=!1,size:i="sm",width:c,respectChildWidths:d=!1}){const u=t.length,f=c&&(c.includes(" ")||c.startsWith("w-")||c.startsWith("max-w-")||c.startsWith("min-w-")),h=f?void 0:c?{width:c}:void 0;return l.jsxs("div",{"data-input-group-root":!0,role:"group",className:we("flex flex-col w-full",f&&c,a),style:h,onDoubleClick:B2,onDoubleClickCapture:B2,onClickCapture:p=>{var g;const m=p.target;!!((g=m==null?void 0:m.closest)!=null&&g.call(m,'input,select,textarea,button,[data-interactive="true"]'))||p.stopPropagation()},children:[l.jsx("label",{className:we("sr-only pb-2",I2[i]),children:e}),o&&l.jsx("label",{className:we("pb-2",I2[i]),children:e}),l.jsx("div",{className:"flex items-stretch flex-nowrap w-full min-w-0",children:t.map((p,m)=>{const{width:v,className:g,options:b,loadOptions:x,info:w,infoHeader:y,...E}=p,k=Array.isArray(b)||typeof x=="function";let j="rounded-lg";!n&&u>1&&(m===0?j="rounded-l-lg rounded-r-none":m===u-1?j="rounded-r-lg rounded-l-none !rounded-l-none":j="rounded-none !rounded-l-none !rounded-r-none");const A=d?v:void 0,S=typeof A=="string"&&A.split(/\s+/).some(R=>R.startsWith("w-")||R.includes(":w-")),_=we("inline-flex items-stretch",A?"flex-shrink-0":"flex-1 min-w-0",typeof A=="string"&&S?A:void 0,!n&&u>1&&m>0?"-ml-px focus-within:z-10 relative":void 0),M=A?typeof A=="string"&&S?void 0:{width:A}:void 0,P=we(g,"w-full",j);return l.jsxs(C.Fragment,{children:[l.jsx("div",{className:_,style:M,children:k?l.jsx(Je,{...E,size:i,className:g,triggerClassName:we("w-full",j),options:b,loadOptions:x,"data-interactive":"true",info:w,infoHeader:y,mode:"menu",searchable:!0,searchPlaceholder:P5("ds.fields.defaults.search.placeholder"),noOptionsText:P5("ds.fields.defaults.search.noMatches")}):l.jsx(De,{...E,size:i,className:P,"data-interactive":"true",info:w,infoHeader:y})}),n&&m<u-1&&l.jsx("div",{className:"flex items-center flex-shrink-0 px-1 select-none",children:r})]},m)})})]})}const rI={sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},nI={sm:"w-3 h-3",md:"w-3.5 h-3.5",lg:"w-4 h-4"};function ji({groupLabel:e,options:t,control:r,name:n,rules:a,defaultValue:o,multiple:i=!0,size:c="sm",vertical:d=!0,className:u,showVisibleLabel:f=!0,disabled:h=!1,hasError:p=!1,errorMessage:m}){return l.jsx(Ct,{name:n,control:r,rules:a,defaultValue:o,render:({field:v,fieldState:g})=>{const{value:b,onChange:x}=v,w=g.error,y=A=>{var S;return i?Array.isArray(b)&&((S=b==null?void 0:b.includes)==null?void 0:S.call(b,A)):b===A},E=A=>{if(!h)if(i){const S=Array.isArray(b)?[...b]:[],_=S.indexOf(A);_>=0?S.splice(_,1):S.push(A),x(S)}else x(A)},k=p||!!w,j=(w==null?void 0:w.message)||m;return l.jsxs("fieldset",{className:we("w-full flex flex-col gap-1",u),"aria-invalid":k||void 0,disabled:h,children:[e&&l.jsx("legend",{className:we("mb-1 text-ds-sm text-[var(--color-ds-text-primary)]",!f&&"sr-only"),children:e}),l.jsx("div",{className:we(d?"flex flex-col gap-2":"flex flex-wrap gap-2"),children:t.map(A=>{const S=y(A.value),_=h||!!(A!=null&&A.disabled),M=we("inline-flex items-center justify-center border transition-all duration-150",i?"rounded-[6px]":"rounded-full",rI[c],"bg-[var(--color-ds-background-page)]","border-[var(--color-ds-border-default-50)]","shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-ds-border-default)20%,transparent)]","peer-focus-visible:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-[var(--color-ds-border-default)]","hover:border-[var(--color-ds-border-default)]",i&&S&&"bg-[var(--color-ds-button-primary-bg)] border-[var(--color-ds-button-primary-bg)]",!i&&S&&"border-[var(--color-ds-button-primary-bg)]",k&&"border-[var(--color-ds-border-error)] shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-ds-border-error)30%,transparent)]",_&&"opacity-60 cursor-not-allowed"),P=we("text-ds-sm text-[var(--color-ds-text-primary)]",_&&"text-[var(--color-ds-text-secondary)]"),R=we(nI[c],"text-[var(--color-ds-button-primary-text)] transition-all duration-150",S?"opacity-100 scale-100":"opacity-0 scale-75"),I=we(c==="sm"?"w-2 h-2":c==="md"?"w-2.5 h-2.5":"w-3 h-3","rounded-full bg-[var(--color-ds-button-primary-bg)] transition-all duration-150",S?"opacity-100 scale-100":"opacity-0 scale-0");return l.jsxs("label",{className:we("inline-flex items-center gap-2 cursor-pointer select-none rounded-md px-1 py-1","hover:bg-[color-mix(in_srgb,var(--color-ds-border-default)6%,transparent)]",_&&"cursor-not-allowed hover:bg-transparent"),children:[l.jsxs("span",{className:"relative inline-flex items-center justify-center",children:[l.jsx("input",{type:i?"checkbox":"radio",name:n,value:A.value,checked:S,onChange:()=>E(A.value),disabled:_,className:"peer sr-only"}),l.jsx("span",{"aria-hidden":!0,className:M,children:i?l.jsx(Bc,{className:R}):l.jsx("span",{className:I})})]}),l.jsx("span",{className:P,children:A.label})]},String(A.value))})}),k&&!!j&&l.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)] mt-1",children:j})]})}})}function aI(e){function t(i){var c,d;for(const u of Object.keys(i)){if((c=i[u])!=null&&c.types||(d=i[u])!=null&&d.message)return u;if(typeof i[u]=="object"){const f=t(i[u]);if(f)return`${u}.${f}`}}return null}const r=t(e);if(!r)return;const n=`[name="${r}"]`,a=`[name^="${r}["], [name^="${r}."]`,o=document.querySelector(n)??document.querySelector(a);o&&(o.scrollIntoView({behavior:"smooth",block:"center"}),o.focus({preventScroll:!0}))}const oI={success:"bg-green-100 border-green-500 text-green-800",error:"bg-red-100 border-red-500 text-red-800",info:"bg-blue-100 border-blue-500 text-blue-800",warning:"bg-yellow-100 border-yellow-500 text-yellow-800"},P2=({id:e,message:t,variant:r="info",duration:n=5e3,onClose:a})=>(C.useEffect(()=>{const o=setTimeout(()=>a(e),n);return()=>clearTimeout(o)},[e,n,a]),l.jsxs("div",{className:we("w-80 max-w-full border-l-4 rounded shadow-md p-4 mb-2 flex justify-between items-start",oI[r]),role:"alert","aria-live":"assertive",children:[l.jsx("span",{className:"flex-1",children:t}),l.jsx("button",{onClick:()=>a(e),className:"ml-4 text-xl font-bold leading-none focus:outline-none",children:"×"})]})),jt=[];for(let e=0;e<256;++e)jt.push((e+256).toString(16).slice(1));function sI(e,t=0){return(jt[e[t+0]]+jt[e[t+1]]+jt[e[t+2]]+jt[e[t+3]]+"-"+jt[e[t+4]]+jt[e[t+5]]+"-"+jt[e[t+6]]+jt[e[t+7]]+"-"+jt[e[t+8]]+jt[e[t+9]]+"-"+jt[e[t+10]]+jt[e[t+11]]+jt[e[t+12]]+jt[e[t+13]]+jt[e[t+14]]+jt[e[t+15]]).toLowerCase()}let ud;const iI=new Uint8Array(16);function lI(){if(!ud){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ud=crypto.getRandomValues.bind(crypto)}return ud(iI)}const V2={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function cI(e,t,r){var a;e=e||{};const n=e.random??((a=e.rng)==null?void 0:a.call(e))??lI();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,sI(n)}function dI(e,t,r){return V2.randomUUID&&!e?V2.randomUUID():cI(e)}const Z2=C.createContext(null),xn=()=>{const e=C.useContext(Z2);if(!e)throw new Error("useToast debe usarse dentro de <ToastProvider>");return e},uI=({children:e})=>{const[t,r]=C.useState([]),n=(o,i="info",c=5e3)=>{const d=dI();r(u=>[...u,{id:d,message:o,variant:i,duration:c}])},a=o=>{r(i=>i.filter(c=>c.id!==o))};return l.jsxs(Z2.Provider,{value:{show:n},children:[e,l.jsx("div",{className:"fixed top-4 right-4 z-50 flex flex-col items-end",children:t.map(o=>l.jsx(P2,{id:o.id,message:o.message,variant:o.variant,duration:o.duration,onClose:a},o.id))})]})},fI=e=>e.type==="inputGroup",hI=e=>e.type==="button",pI=e=>!fI(e)&&!hI(e);function z2(e){const t=Array.isArray(e)?e:[];return C.useMemo(()=>{const r={};for(const n of t)pI(n)&&n.name&&(r[n.name]=n);return r},[t])}const H2=C.createContext(null);function W2({children:e,value:t}){return l.jsx(H2.Provider,{value:t,children:e})}function Zt(){const e=C.useContext(H2);if(!e)throw new Error("useAdapters debe usarse dentro de <AdaptersProvider />");return e}const mI=e=>!!e&&typeof e.then=="function";function gI(e){return Array.isArray(e)?e.length>0&&typeof e[0]=="object"&&e[0]!==null?e.map(t=>{var a;if("label"in t&&"value"in t)return t;const n=(a=Object.entries(t)[0])==null?void 0:a[1];return{label:String(n??JSON.stringify(t)),value:String(n??"")}}):e.map(t=>({label:String(t),value:t})):[]}function U2(e){const{services:t}=Zt(),[r,n]=C.useState({}),[a,o]=C.useState(0),i=C.useRef(!0);C.useEffect(()=>(i.current=!0,()=>{i.current=!1}),[]);const c=C.useMemo(()=>e.filter(d=>d.type==="select"&&!d.options&&typeof d.optionSource=="string"&&d.name),[e]);return C.useEffect(()=>{if(c.length===0)return;let d=!1;return(async()=>{o(u=>u+1);try{const u=await Promise.all(c.map(async f=>{var b;const h=f.name,p=f.optionSource,m=(b=t==null?void 0:t.registry)==null?void 0:b[p];if(!m)return[h,[]];const v=mI(m)?await m:await m(),g=gI(v);return[h,g]}));if(d||!i.current)return;n(f=>{const h={...f};for(const[p,m]of u)h[p]=[...m];return h})}finally{!d&&i.current&&o(u=>Math.max(0,u-1))}})(),()=>{d=!0}},[c,t==null?void 0:t.registry]),{optionsMap:r,loadingCount:a}}const vI=e=>e.type==="inputGroup",bI=e=>e.type==="button",wI=e=>!vI(e)&&!bI(e);function xI(e){return typeof e=="object"&&e!==null}const yI=e=>{const t=e.disabledWhen;if(!xI(t))return!1;const r="watchField"in t,n="rule"in t;return r&&!n};function q2(e,t){const r=Array.isArray(e)?e:[],n=C.useMemo(()=>r.filter(wI).filter(yI),[r]),a=C.useMemo(()=>n.map(d=>d.disabledWhen.watchField),[n]),o=Ec({control:t,name:a,compute:d=>d}),i=Array.isArray(o)?o:[],c={};return n.forEach((d,u)=>{const f=i[u];c[d.name??`__unnamed_${u}`]=f===d.disabledWhen.watchValue}),c}const kI={sm:"text-ds-sm",md:"text-ds-sm",lg:"text-ds-sm"},EI={sm:"px-2 py-1.5",md:"px-3 py-2",lg:"px-4 py-3"};function Dr({control:e,name:t,rules:r,defaultValue:n,size:a="sm",width:o="100%",label:i,labelHidden:c=!1,hasError:d=!1,errorMessage:u="",maxLength:f,showCounter:h=!1,className:p,suffixButton:m,labelPrefixIcon:v,labelSuffixIcon:g,info:b,infoHeader:x,infoAriaLabel:w,prefixIcon:y,suffixIcon:E,reserveErrorSpace:k,disableErrorPlaceholder:j,id:A,...S}){const _=C.useId(),M=A||_,[P,R]=C.useState(String(n??S.value??"")),I=typeof k=="boolean"?k:typeof j=="boolean"?!j:!!e,F=we("box-border bg-[var(--color-ds-background-page)] w-full rounded-lg border outline-none transition","placeholder-[var(--color-ds-text-secondary)] text-[var(--color-ds-text-primary)]",kI[a],EI[a],d?"border-[var(--color-ds-border-error)]":"border-[var(--color-ds-border-default)]",S.disabled&&"bg-[var(--color-ds-background-disabled)] border-[var(--color-ds-border-muted)] text-[var(--color-ds-text-secondary)] cursor-not-allowed"),V=y?"pl-9":"",te=E?"pr-9":"",X=N=>{var O;typeof f=="number"&&N.target.value.length>f||(R(N.target.value),(O=S.onChange)==null||O.call(S,N))},ne=o&&(o.includes(" ")||o.startsWith("w-")||o.startsWith("max-w-")||o.startsWith("min-w-")),se=ne?void 0:{width:o},G=we("flex flex-col",ne&&o,p);return C.useEffect(()=>{n!==void 0&&R(String(n??""))},[n]),e&&t?l.jsx(Ct,{name:t,control:e,rules:r,defaultValue:n??"",render:({field:N,fieldState:O})=>{var ae;return l.jsxs("div",{className:G,style:se,children:[!c&&i&&l.jsx(gr,{id:M,text:i,size:a,prefixIcon:v,suffixIcon:g,info:b,infoHeader:x,infoAriaLabel:w}),l.jsxs("div",{className:"flex items-stretch gap-2",children:[l.jsxs("div",{className:"relative w-full",children:[y&&l.jsx("span",{className:"absolute left-2 top-2.5",children:l.jsx(_t,{component:y,size:a,className:"text-[var(--color-ds-text-secondary)]"})}),l.jsx("textarea",{id:M,"aria-invalid":!!O.error,className:we(F,V,te),maxLength:f,...N,placeholder:S.disabled?"":S.placeholder,onChange:K=>{N.onChange(K),h&&R(K.target.value)}}),E&&l.jsx("span",{className:"absolute right-2 top-2.5",children:l.jsx(_t,{component:E,size:a,className:"text-[var(--color-ds-text-secondary)]"})})]}),m?l.jsx("div",{className:"shrink-0",children:m}):null]}),l.jsxs("div",{className:"flex justify-between pt-1 h-[1em]",children:[I?O.error?l.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)]",children:O.error.message}):l.jsx("span",{"aria-hidden":"true",children:" "}):O.error?l.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)]",children:O.error.message}):l.jsx("span",{"aria-hidden":"true",children:" "}),h&&typeof f=="number"&&l.jsxs("span",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:[((ae=N.value)==null?void 0:ae.length)??0,"/",f]})]})]})}}):l.jsxs("div",{className:G,style:se,children:[!c&&i&&l.jsx(gr,{id:M,text:i,size:a,prefixIcon:v,suffixIcon:g,info:b,infoHeader:x,infoAriaLabel:w}),l.jsxs("div",{className:"flex items-stretch gap-2",children:[l.jsxs("div",{className:"relative w-full",children:[y&&l.jsx("span",{className:"absolute left-2 top-2.5",children:l.jsx(_t,{component:y,size:a,className:"text-[var(--color-ds-text-secondary)]"})}),l.jsx("textarea",{id:M,className:we(F,V,te),value:P,onChange:X,maxLength:f,...S,placeholder:S.disabled?"":S.placeholder}),E&&l.jsx("span",{className:"absolute right-2 top-2.5",children:l.jsx(_t,{component:E,size:a,className:"text-[var(--color-ds-text-secondary)]"})})]}),m?l.jsx("div",{className:"shrink-0",children:m}):null]}),l.jsxs("div",{className:"flex justify-between pt-1 h-[1em]",children:[I?d&&u?l.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)]",children:u}):l.jsx("span",{"aria-hidden":"true",children:" "}):d&&u?l.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)]",children:u}):l.jsx("span",{"aria-hidden":"true",children:" "}),h&&typeof f=="number"&&l.jsxs("span",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:[P.length,"/",f]})]})]})}const CI={sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},jI={sm:"w-3 h-3",md:"w-3.5 h-3.5",lg:"w-4 h-4"};function it({control:e=null,name:t,rules:r,defaultValue:n=!1,label:a,labelHidden:o=!1,disabled:i=!1,size:c="sm",className:d,hasError:u=!1,errorMessage:f="",reserveErrorSpace:h,disableErrorPlaceholder:p,checked:m,indeterminate:v,onChange:g}){const b=we("text-[var(--color-ds-text-primary)] text-ds-sm",i&&"text-[var(--color-ds-text-secondary)]",o&&"sr-only"),x=typeof h=="boolean"?h:typeof p=="boolean"?!p:!!e,w=(y,E,k)=>{const j=u||!!k,A=(k==null?void 0:k.message)||f,S=we("inline-flex items-center justify-center rounded-[6px] border transition-all duration-150",CI[c],"bg-[var(--color-ds-background-page)]","border-[var(--color-ds-border-default-50)]","shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-ds-border-default)20%,transparent)]","peer-focus-visible:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-[var(--color-ds-border-default)]","hover:border-[var(--color-ds-border-default)]",(y||v)&&"bg-[var(--color-ds-button-primary-bg)] border-[var(--color-ds-button-primary-bg)]",j&&"border-[var(--color-ds-border-error)] shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-ds-border-error)30%,transparent)]",i&&"opacity-60 cursor-not-allowed"),_=we(jI[c],"text-[var(--color-ds-button-primary-text)]","transition-all duration-150",y||v?"opacity-100 scale-100":"opacity-0 scale-75");return l.jsxs("div",{className:we("flex flex-col gap-1",d),children:[C.createElement(typeof a=="string"?"label":"div",{className:we("inline-flex items-center gap-2 cursor-pointer select-none",i&&"cursor-not-allowed")},l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"relative inline-flex items-center justify-center",children:[l.jsx("input",{id:t,type:"checkbox",className:"peer sr-only",checked:y,ref:M=>{M&&(M.indeterminate=!!v)},onChange:M=>E(M.target.checked),disabled:i}),l.jsx("span",{"aria-hidden":!0,className:S,children:v?l.jsx("div",{className:"bg-white h-0.5 w-[60%] rounded-full"}):l.jsx(Bc,{className:_})})]}),a&&l.jsx("span",{className:b,children:a})]})),x?l.jsx("div",{className:"h-[1em]",children:j&&A?l.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)] h-[1em]",children:A}):l.jsx("span",{"aria-hidden":"true",children:" "})}):j&&A?l.jsx("div",{className:"pt-1",children:l.jsx("span",{className:"text-xs text-[var(--color-ds-text-error)] h-[1em]",children:A})}):null]})};return e?l.jsx(Ct,{name:t||"",control:e,rules:r,defaultValue:n,render:({field:y,fieldState:E})=>{const k=E.error;return w(!!y.value,j=>y.onChange(j),k)}}):w(!!m,y=>g==null?void 0:g(y))}function fd({name:e,control:t,searchFn:r,resolveByValue:n,label:a,size:o="sm",width:i="100%",disabled:c=!1,searchMode:d="button",minChars:u=3,debounceMs:f=600,labelPrefixIcon:h,labelSuffixIcon:p,prefixIcon:m,suffixIcon:v,reserveErrorSpace:g,disableErrorPlaceholder:b}){const x=gn(),{watch:w,getValues:y,setValue:E}=x,k=Ec({control:t,name:e}),[j,A]=C.useState([]),[S,_]=C.useState(!1),[M,P]=C.useState(!1),[R,I]=C.useState(""),F=C.useRef(null),V=C.useRef(null),te=C.useRef(!1),X=C.useRef(!1),ne=C.useRef(!0),se=C.useMemo(()=>{const fe=new Map;for(const le of j)fe.set(String(le.value).trim(),le.label??"");return fe},[j]),G=async fe=>{const le=(fe??"").trim();if(!le){A([]),P(!1);return}_(!0);try{const Ce=await r(le,{watch:w,getValues:y});A(Ce??[]),P(!0)}finally{_(!1)}};C.useEffect(()=>{function fe(le){F.current&&!F.current.contains(le.target)&&P(!1)}if(M)return document.addEventListener("mousedown",fe),()=>document.removeEventListener("mousedown",fe)},[M]);const[N,O]=C.useState({});C.useEffect(()=>{if(te.current)return;const le=(k?String(k):"").trim();if(!le){R!==""&&I(""),P(!1);return}const Ce=se.get(le);if(Ce){R!==Ce&&(I(Ce),ne.current=!0);return}const ce=N[le];if(ce){R!==ce&&(I(ce),ne.current=!0);return}let xe=!1;return n?(R!==le&&I(le),(async()=>{try{const D=await n(le,{watch:w,getValues:y});if(xe)return;if(D){const q=D.label??String(D.value);O(re=>{const W={...re,[le]:q};return I(q),ne.current=!0,W})}else R!==le&&(I(le),ne.current=!0)}catch{!xe&&R!==le&&(I(le),ne.current=!0)}})()):R!==le&&(I(le),ne.current=!0),()=>{xe=!0}},[k,se,N,n,w,y]),C.useEffect(()=>{if(d!=="debounced"||c)return;if(ne.current){ne.current=!1;return}if(!X.current)return;V.current&&(window.clearTimeout(V.current),V.current=null);const fe=(R||"").trim();return fe.length>=u?V.current=window.setTimeout(()=>{G(fe)},f):(A([]),P(!1)),()=>{V.current&&(window.clearTimeout(V.current),V.current=null)}},[R,d,u,f,c]);const ae=o==="sm"?"text-ds-sm":o==="md"?"text-ds-md":"text-ds-lg",K=o==="sm"?"h-6":o==="md"?"h-10":"h-12",Q=fe=>{if(c)return;const le=(R||"").trim();fe.key==="Enter"&&(fe.preventDefault(),d==="debounced"?le.length>=u&&G(le):G(le)),fe.key==="Escape"&&P(!1)},pe=i&&(i.includes(" ")||i.startsWith("w-")||i.startsWith("max-w-")||i.startsWith("min-w-")),ge=pe?void 0:{width:i},ue=`relative flex flex-col ${pe?i:""}`;return l.jsx(Ct,{name:e,control:t,render:({field:fe,fieldState:le})=>{var Ce;return l.jsxs("div",{ref:F,className:ue,style:ge,children:[a&&l.jsx(gr,{id:e,text:a,size:o,prefixIcon:h,suffixIcon:p}),l.jsx(De,{className:d==="button"?"rounded-r-none":void 0,type:"text",size:o,width:"100%",value:R,prefixIcon:m,suffixIcon:v,onChange:ce=>{const xe=ce.target.value;te.current=!0,X.current=!0,I(xe),(k?String(k):"").trim()&&E(e,"",{shouldDirty:!0})},onKeyDown:Q,onBlur:()=>{te.current=!1},disabled:c,hasError:le.invalid,errorMessage:(Ce=le.error)==null?void 0:Ce.message,reserveErrorSpace:g,disableErrorPlaceholder:b,onFocus:()=>{if(te.current=!0,d==="button"&&X.current){const ce=(R||"").trim();ce&&G(ce)}},suffixButton:d==="button"?l.jsx(me,{type:"button",className:"!rounded-l-none",size:o,variant:"primary",onClick:()=>G((R||"").trim()),disabled:c,children:"Buscar"}):void 0}),S&&l.jsx("div",{className:"absolute top-14 left-0 right-0 z-10",children:l.jsx(Br,{width:"100%",height:o==="sm"?"1.5rem":o==="md"?"2.5rem":"3rem",variant:"rect",className:"rounded-lg"})}),M&&!S&&j.length>0&&l.jsx("ul",{className:`
|
|
93
93
|
absolute top-14 left-0 right-0
|
|
94
94
|
border-[var(--color-ds-border-default)]
|
|
95
95
|
rounded-lg bg-[var(--color-ds-background-page)]
|