@birhaus/primitives
Version:
BIRHAUS Primitive Components - Enhanced base UI components with DataTable, FilterBar, BulkActions, and cognitive load reduction
7 lines • 284 kB
JavaScript
'use strict';var ct=require('react'),lucideReact=require('lucide-react'),jsxRuntime=require('react/jsx-runtime'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),framerMotion=require('framer-motion'),reactVirtual=require('@tanstack/react-virtual'),reactDom=require('react-dom');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var ct__namespace=/*#__PURE__*/_interopNamespace(ct);function Cr(e,t){return e in t&&Object.prototype.hasOwnProperty.call(t,e)}function re(e,t,s){return Cr(t,e)?e[t]:s}function ze(e,t,s){return t>=0&&t<e.length?e[t]:s}function Sr(e,t,s){return t.includes(e)?e:s}function Xn(e,t,s){return Cr(t,e)?e[t]:s}var sa=["default","primary","secondary","success","warning","error","info"],ra=["sm","md","lg","xl"];function qn(e){return Sr(e,sa,"default")}function Jn(e){return Sr(e,ra,"md")}function Qn(e,t,s){return re(e,t,s)}function ni(...e){return e.filter(Boolean).join(" ")}var rt=ct.forwardRef(({label:e,labelEs:t,labelEn:s,variant:r="secondary",size:a="md",isPrimaryAction:i=false,loading:n=false,loadingText:c,loadingTextEs:d,loadingTextEn:o,destructive:h=false,undoAction:v,undoTimeoutMs:g=1e4,showSuccessState:l=false,successText:y,successTextEs:R,successTextEn:b,describedBy:W,describedByEs:L,describedByEn:Z,icon:k,iconPosition:le="left",fullWidth:se=false,trackCognitiveLoad:X=false,cognitiveLoadLevel:w="medium",className:m,disabled:C,onClick:V,children:K,...u},z)=>{let[I,P]=ct.useState(false),[N,M]=ct.useState(false),[D,te]=ct.useState(false),S=ct.useRef(),A=($,p,q)=>$||t||p||s||q||"",H=A(t,s,e),_=A(d||"Procesando...",o||"Processing...",c),O=A(R||"Completado",b||"Completed",y),G=A(L,Z,W),j=`
inline-flex items-center justify-center gap-2 rounded-lg font-medium
transition-all duration-200 ease-in-out
focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2
disabled:pointer-events-none disabled:opacity-50
${se?"w-full":""}
`.trim(),f={xs:"h-7 px-2 text-xs",sm:"h-8 px-3 text-sm",md:"h-10 px-4 text-sm",lg:"h-11 px-6 text-base",xl:"h-12 px-8 text-base"},T={primary:i?"bg-blue-600 text-white hover:bg-blue-700 focus-visible:ring-blue-500 shadow-md hover:shadow-lg":"bg-blue-600 text-white hover:bg-blue-700 focus-visible:ring-blue-500",secondary:"bg-white border border-gray-300 text-gray-700 hover:bg-gray-50 focus-visible:ring-gray-500",destructive:"bg-red-600 text-white hover:bg-red-700 focus-visible:ring-red-500",outline:"border border-gray-300 bg-transparent text-gray-700 hover:bg-gray-50 focus-visible:ring-gray-500",ghost:"text-gray-600 hover:text-gray-900 hover:bg-gray-100 focus-visible:ring-gray-500"},Q=X?re({low:"ring-1 ring-green-300",medium:"ring-1 ring-yellow-300",high:"ring-1 ring-red-300"},w,""):"",F=async $=>{if(h&&v&&!I){await V?.($),P(true),S.current=setTimeout(()=>{P(false);},g);return}let p=V?.($);if(l&&p&&typeof p=="object"&&"then"in p)try{await p,te(!0),setTimeout(()=>te(!1),2e3);}catch(q){console.error("Action failed:",q);}},E=async()=>{if(v){M(true);try{await v(),P(!1),S.current&&clearTimeout(S.current);}catch($){console.error("Undo failed:",$);}finally{M(false);}}};return ct.useEffect(()=>()=>{S.current&&clearTimeout(S.current);},[]),I?jsxRuntime.jsxs("div",{className:"inline-flex items-center gap-2 p-2 bg-red-50 border border-red-200 rounded-lg",children:[jsxRuntime.jsx(lucideReact.AlertTriangle,{className:"h-4 w-4 text-red-600"}),jsxRuntime.jsx("span",{className:"text-sm text-red-800",children:"Acci\xF3n completada"}),jsxRuntime.jsxs("button",{onClick:E,disabled:N,className:"inline-flex items-center gap-1 px-3 py-1 text-sm font-medium text-red-700 bg-white border border-red-300 rounded hover:bg-red-50 disabled:opacity-50",children:[jsxRuntime.jsx(lucideReact.Undo2,{className:"h-3 w-3"}),N?"Deshaciendo...":"Deshacer"]})]}):jsxRuntime.jsxs("button",{ref:z,className:ni(j,re(f,a,f.md),re(T,r,T.primary),Q,m),disabled:C||n,onClick:F,"aria-describedby":G?`${u.id}-desc`:void 0,"data-birhaus-component":"button","data-birhaus-variant":r,"data-birhaus-primary":i,"data-cognitive-load":X?w:void 0,...u,children:[n&&jsxRuntime.jsx(lucideReact.Loader2,{className:"h-4 w-4 animate-spin"}),D&&jsxRuntime.jsx(lucideReact.Check,{className:"h-4 w-4 text-green-600"}),k&&le==="left"&&!n&&!D&&jsxRuntime.jsx("span",{className:"flex-shrink-0",children:k}),jsxRuntime.jsx("span",{children:n?_:D?O:K||H}),k&&le==="right"&&!n&&!D&&jsxRuntime.jsx("span",{className:"flex-shrink-0",children:k}),G&&jsxRuntime.jsx("span",{id:`${u.id}-desc`,className:"sr-only",children:G})]})});rt.displayName="BirhausButton";function ii(){let[e,t]=ct.useState(false),[s,r]=ct.useState(false);return {loading:e,success:s,executeAction:async i=>{t(true);try{await i(),r(!0),setTimeout(()=>r(!1),2e3);}catch(n){throw console.error("Button action failed:",n),n}finally{t(false);}},setLoading:t,setSuccess:r}}function ge(...e){return tailwindMerge.twMerge(clsx.clsx(e))}var Br={default:"bg-gray-100 text-gray-800",success:"bg-green-100 text-green-800",warning:"bg-yellow-100 text-yellow-800",error:"bg-red-100 text-red-800",info:"bg-blue-100 text-blue-800"},kr={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-sm",lg:"px-3 py-1.5 text-base"};function os({variant:e="default",size:t="md",className:s,children:r,...a}){let i=e in Br?e:"default",n=t in kr?t:"md";return jsxRuntime.jsx("span",{className:ge("inline-flex items-center rounded-full font-medium",re(Br,i,Br.default),re(kr,n,kr.md),s),...a,children:r})}function Ar(...e){return e.filter(Boolean).join(" ")}var nr=ct.forwardRef(({label:e,labelEs:t,labelEn:s,description:r,descriptionEs:a,descriptionEn:i,error:n,errorEs:c,errorEn:d,solution:o,solutionEs:h,solutionEn:v,autoSave:g=false,autoSaveDelay:l=1e3,onAutoSave:y,validateOnChange:R=true,validateOnBlur:b=true,validationRules:W=[],size:L="md",variant:Z="default",prefix:k,suffix:le,showPasswordToggle:se=false,showClearButton:X=false,helpText:w,helpTextEs:m,helpTextEn:C,loading:V=false,success:K=false,fieldPriority:u="optional",cognitiveWeight:z=1,className:I,type:P="text",value:N,defaultValue:M,onChange:D,onBlur:te,onFocus:S,disabled:A,required:H,..._},O)=>{let[G,j]=ct.useState(N||M||""),[f,T]=ct.useState(false),[Q,F]=ct.useState(false),[E,$]=ct.useState(""),[p,q]=ct.useState(""),[ne,x]=ct.useState("idle"),J=ct.useRef(),ee=ct.useRef(null),de=(tt,ft,Ts)=>tt||ft||Ts||"",be=de(t,s,e),fe=de(a,i,r),ce=de(c,d,n)||E,Y=de(h,v,o)||p,B=de(m,C,w),U=tt=>{if(W.length){for(let ft of W)if(!ft.test(tt)){$(ft.errorEs||ft.errorEn||""),q(ft.solutionEs||ft.solutionEn||"");return}$(""),q("");}},ue=tt=>{!g||!y||(J.current&&clearTimeout(J.current),J.current=setTimeout(async()=>{x("saving");try{await y(tt),x("saved"),setTimeout(()=>x("idle"),2e3);}catch{x("error"),setTimeout(()=>x("idle"),3e3);}},l));},oe=tt=>{let ft=tt.target.value;j(ft),R&&U(ft),g&&ue(ft),D?.(tt);},he=tt=>{F(false),b&&U(G),te?.(tt);},Ne=tt=>{F(true),S?.(tt);},me=()=>{j(""),$(""),q(""),ee.current&&ee.current.focus();};ct.useEffect(()=>()=>{J.current&&clearTimeout(J.current);},[]);let ie={sm:"h-8 px-3 text-sm",md:"h-10 px-4 text-sm",lg:"h-12 px-4 text-base"},ve={default:"border border-gray-300 bg-white",filled:"border-0 bg-gray-100",minimal:"border-0 border-b border-gray-300 bg-transparent rounded-none"},ae=!!(ce||n),pe=K&&!ae,Ce=ae?"border-red-500 focus:border-red-500 focus:ring-red-500":pe?"border-green-500 focus:border-green-500 focus:ring-green-500":"focus:border-blue-500 focus:ring-blue-500",Ue={required:"ring-2 ring-red-100",optional:"",progressive:"ring-1 ring-blue-100"},Wt=Ar("w-full rounded-lg transition-all duration-200","focus:outline-none focus:ring-2 focus:ring-offset-1","disabled:cursor-not-allowed disabled:opacity-50","placeholder:text-gray-400",ie[L],ve[Z],Ce,Ue[u],I);return jsxRuntime.jsxs("div",{className:"space-y-2",children:[be&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("label",{htmlFor:_.id,className:Ar("block text-sm font-medium text-gray-700",H&&"after:content-['*'] after:ml-1 after:text-red-500"),children:[be,u==="required"&&jsxRuntime.jsx("span",{className:"ml-1 text-xs text-red-600",children:"(requerido)"}),u==="optional"&&jsxRuntime.jsx("span",{className:"ml-1 text-xs text-gray-500",children:"(opcional)"})]}),g&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[ne==="saving"&&jsxRuntime.jsx("span",{className:"text-blue-600",children:"Guardando..."}),ne==="saved"&&jsxRuntime.jsxs("span",{className:"text-green-600 flex items-center gap-1",children:[jsxRuntime.jsx(lucideReact.CheckCircle2,{className:"h-3 w-3"}),"Guardado"]}),ne==="error"&&jsxRuntime.jsx("span",{className:"text-red-600",children:"Error al guardar"})]})]}),fe&&jsxRuntime.jsx("p",{className:"text-sm text-gray-600",children:fe}),jsxRuntime.jsxs("div",{className:"relative",children:[k&&jsxRuntime.jsx("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400",children:k}),jsxRuntime.jsx("input",{ref:O||ee,type:se?f?"text":"password":P,value:N||G,onChange:oe,onBlur:he,onFocus:Ne,disabled:A||V,required:H,className:Ar(Wt,k?"pl-10":"",le||se||X?"pr-10":""),"data-birhaus-component":"input","data-birhaus-priority":u,"data-cognitive-weight":z,..._}),V&&jsxRuntime.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:jsxRuntime.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"})}),pe&&jsxRuntime.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:jsxRuntime.jsx(lucideReact.CheckCircle2,{className:"h-4 w-4 text-green-500"})}),ae&&jsxRuntime.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-4 w-4 text-red-500"})}),se&&P==="password"&&!V&&!ae&&!pe&&jsxRuntime.jsx("button",{type:"button",onClick:()=>T(!f),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600","aria-label":f?"Ocultar contrase\xF1a":"Mostrar contrase\xF1a",children:f?jsxRuntime.jsx(lucideReact.EyeOff,{className:"h-4 w-4"}):jsxRuntime.jsx(lucideReact.Eye,{className:"h-4 w-4"})}),X&&G&&!V&&!ae&&!se&&jsxRuntime.jsx("button",{type:"button",onClick:me,className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600","aria-label":"Limpiar campo",children:jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4"})}),le&&!se&&!X&&!V&&!ae&&!pe&&jsxRuntime.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400",children:le})]}),ce&&jsxRuntime.jsxs("div",{className:"flex items-start gap-2 p-3 bg-red-50 border border-red-200 rounded-lg",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-4 w-4 text-red-600 mt-0.5 flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1 text-sm",children:[jsxRuntime.jsxs("p",{className:"text-red-800 font-medium",children:["Qu\xE9 pas\xF3: ",ce]}),Y&&jsxRuntime.jsxs("p",{className:"text-red-700 mt-1",children:["C\xF3mo resolver: ",Y]})]})]}),B&&!ce&&jsxRuntime.jsxs("div",{className:"flex items-start gap-2 text-sm text-gray-600",children:[jsxRuntime.jsx(lucideReact.Info,{className:"h-4 w-4 mt-0.5 flex-shrink-0"}),jsxRuntime.jsx("p",{children:B})]})]})});nr.displayName="BirhausInput";var fi={required:e=>({test:t=>t.trim().length>0,errorEs:`${e} es requerido`,errorEn:`${e} is required`,solutionEs:`Ingrese un valor para ${e.toLowerCase()}`,solutionEn:`Enter a value for ${e.toLowerCase()}`}),email:()=>({test:e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),errorEs:"El formato del email no es v\xE1lido",errorEn:"Email format is not valid",solutionEs:"Use el formato: usuario@ejemplo.com",solutionEn:"Use the format: user@example.com"}),minLength:e=>({test:t=>t.length>=e,errorEs:`Debe tener al menos ${e} caracteres`,errorEn:`Must be at least ${e} characters`,solutionEs:`Agregue al menos ${e} caracteres`,solutionEn:`Add at least ${e} characters`}),paraguayPhone:()=>({test:e=>/^(\+595|0)(9[0-9]{8}|[2-9][1-8][0-9]{5,6})$/.test(e.replace(/\s/g,"")),errorEs:"El n\xFAmero de tel\xE9fono no es v\xE1lido para Paraguay",errorEn:"Phone number is not valid for Paraguay",solutionEs:"Use el formato: 0981123456 o +595981123456",solutionEn:"Use the format: 0981123456 or +595981123456"}),ruc:()=>({test:e=>/^[0-9]{1,8}-[0-9]$/.test(e),errorEs:"El formato de RUC no es v\xE1lido",errorEn:"RUC format is not valid",solutionEs:"Use el formato: 12345678-9",solutionEn:"Use the format: 12345678-9"})};function zs(...e){return e.filter(Boolean).join(" ")}var da=ct.forwardRef(({label:e,labelEs:t,labelEn:s,description:r,descriptionEs:a,descriptionEn:i,options:n=[],value:c,defaultValue:d,onChange:o,error:h,errorEs:v,errorEn:g,placeholder:l,placeholderEs:y,placeholderEn:R,multiple:b=false,maxSelections:W,searchable:L=false,searchPlaceholder:Z,searchPlaceholderEs:k,searchPlaceholderEn:le,size:se="md",variant:X="default",helpText:w,helpTextEs:m,helpTextEn:C,disabled:V=false,required:K=false,loading:u=false,cognitiveLoadLevel:z="medium",showCognitiveWarning:I=true,clearable:P=false,closeOnSelect:N=true,className:M,id:D},te)=>{let[S,A]=ct.useState(false),[H,_]=ct.useState(""),[O,G]=ct.useState(Array.isArray(c)?c:Array.isArray(d)?d:c?[c]:d?[d]:[]),j=ct.useRef(null),f=ct.useRef(null),T=(me,ie,ve)=>me||ie||ve||"",Q=T(t,s,e),F=T(a,i,r),E=T(v,g,h),$=T(y||"Seleccionar opci\xF3n...",R||"Select option...",l),p=T(k||"Buscar opciones...",le||"Search options...",Z),q=T(m,C,w),ne=7,x=n.filter(me=>H===""||me.label.toLowerCase().includes(H.toLowerCase())||me.labelEs?.toLowerCase().includes(H.toLowerCase())||me.labelEn?.toLowerCase().includes(H.toLowerCase())),J=x.slice(0,L?x.length:ne),ee=x.length>ne,de=n.length>ne?"high":n.length>4?"medium":"low",be=me=>{let ie;if(b)if(O.includes(me))ie=O.filter(ve=>ve!==me);else {if(W&&O.length>=W)return;ie=[...O,me];}else ie=[me],N&&A(false);G(ie),o?.(b?ie:ie[0]||"");},fe=()=>{G([]),o?.(b?[]:"");};ct.useEffect(()=>{let me=ie=>{j.current&&!j.current.contains(ie.target)&&A(false);};return document.addEventListener("mousedown",me),()=>document.removeEventListener("mousedown",me)},[]),ct.useEffect(()=>{S&&L&&f.current&&f.current.focus();},[S,L]);let Y=O.map(me=>{let ie=n.find(ve=>ve.value===me);return ie?ie.labelEs||ie.label:me}),B=Y.length>0?Y.join(", "):$,U={sm:"h-8 px-3 text-sm",md:"h-10 px-4 text-sm",lg:"h-12 px-4 text-base"},ue={default:"border border-gray-300 bg-white",filled:"border-0 bg-gray-100",minimal:"border-0 border-b border-gray-300 bg-transparent rounded-none"},he=!!E?"border-red-500 focus:border-red-500 focus:ring-red-500":"focus:border-blue-500 focus:ring-blue-500",Ne=zs("w-full rounded-lg transition-all duration-200 flex items-center justify-between","focus:outline-none focus:ring-2 focus:ring-offset-1","disabled:cursor-not-allowed disabled:opacity-50",re(U,se,U.md),re(ue,X,ue.default),he,M);return jsxRuntime.jsxs("div",{className:"space-y-2",children:[(Q||I&&de==="high")&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[Q&&jsxRuntime.jsx("label",{htmlFor:D,className:zs("block text-sm font-medium text-gray-700",K&&"after:content-['*'] after:ml-1 after:text-red-500"),children:Q}),I&&de==="high"&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-3 w-3"}),jsxRuntime.jsxs("span",{children:["+",n.length-ne," opciones (considera agrupar)"]})]})]}),F&&jsxRuntime.jsx("p",{className:"text-sm text-gray-600",children:F}),jsxRuntime.jsxs("div",{ref:j,className:"relative",children:[jsxRuntime.jsxs("button",{ref:te,type:"button",onClick:()=>A(!S),disabled:V||u,className:Ne,"data-birhaus-component":"select","data-cognitive-load":de,"aria-expanded":S,"aria-haspopup":"listbox",id:D,children:[jsxRuntime.jsx("span",{className:zs("truncate text-left",O.length===0&&"text-gray-400"),children:B}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[P&&O.length>0&&jsxRuntime.jsx("button",{type:"button",onClick:me=>{me.stopPropagation(),fe();},className:"text-gray-400 hover:text-gray-600","aria-label":"Limpiar selecci\xF3n",children:jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4"})}),u?jsxRuntime.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"}):jsxRuntime.jsx(lucideReact.ChevronDown,{className:zs("h-4 w-4 text-gray-400 transition-transform duration-200",S&&"rotate-180")})]})]}),S&&jsxRuntime.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-white border border-gray-300 rounded-lg shadow-lg max-h-60 overflow-hidden",children:[L&&jsxRuntime.jsx("div",{className:"p-2 border-b border-gray-200",children:jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(lucideReact.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),jsxRuntime.jsx("input",{ref:f,type:"text",value:H,onChange:me=>_(me.target.value),placeholder:p,className:"w-full pl-9 pr-3 py-2 text-sm border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]})}),jsxRuntime.jsxs("div",{className:"max-h-48 overflow-y-auto",children:[J.length===0?jsxRuntime.jsx("div",{className:"p-3 text-sm text-gray-500 text-center",children:H?"No se encontraron opciones":"No hay opciones disponibles"}):J.map(me=>{let ie=O.includes(me.value),ve=me.labelEs||me.label,ae=me.descriptionEs||me.description;return jsxRuntime.jsxs("button",{type:"button",onClick:()=>be(me.value),disabled:me.disabled,className:zs("w-full px-3 py-2 text-left flex items-center gap-3 hover:bg-gray-50","focus:outline-none focus:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",ie&&"bg-blue-50 text-blue-700"),role:"option","aria-selected":ie,children:[me.icon&&jsxRuntime.jsx("span",{className:"flex-shrink-0",children:me.icon}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium truncate",children:ve}),ie&&jsxRuntime.jsx(lucideReact.Check,{className:"h-4 w-4 text-blue-600"})]}),ae&&jsxRuntime.jsx("p",{className:"text-xs text-gray-500 truncate",children:ae})]})]},me.value)}),ee&&!L&&jsxRuntime.jsxs("div",{className:"p-2 border-t border-gray-200 bg-gray-50 text-center",children:[jsxRuntime.jsxs("p",{className:"text-xs text-gray-600",children:["+",x.length-ne," opciones m\xE1s"]}),jsxRuntime.jsx("p",{className:"text-xs text-gray-500",children:"Habilita b\xFAsqueda para ver todas"})]})]})]})]}),E&&jsxRuntime.jsxs("div",{className:"flex items-start gap-2 p-3 bg-red-50 border border-red-200 rounded-lg",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-4 w-4 text-red-600 mt-0.5 flex-shrink-0"}),jsxRuntime.jsx("p",{className:"text-sm text-red-800",children:E})]}),q&&!E&&jsxRuntime.jsxs("div",{className:"flex items-start gap-2 text-sm text-gray-600",children:[jsxRuntime.jsx(lucideReact.Info,{className:"h-4 w-4 mt-0.5 flex-shrink-0"}),jsxRuntime.jsx("p",{children:q})]}),b&&O.length>0&&jsxRuntime.jsxs("div",{className:"text-xs text-gray-600",children:[O.length," de ",W||"\u221E"," seleccionado",O.length!==1?"s":""]})]})});da.displayName="BirhausSelect";function wi(){let[e,t]=ct.useState(""),[s,r]=ct.useState(false);return {value:e,isOpen:s,handleChange:n=>{t(n);},clear:()=>{t(Array.isArray(e)?[]:"");},setValue:t,setIsOpen:r}}function Ci(e,t){let s={};return e.forEach(r=>{let a=t(r);re(s,a,[])||(s[a]=[]);let n=s[a];Array.isArray(n)&&n.push(r);}),Object.entries(s).forEach(([r,a])=>{a.length>7&&console.warn(`BIRHAUS Miller's Law Warning: Group "${r}" has ${a.length} options (max recommended: 7)`);}),s}function ir(...e){return e.filter(Boolean).join(" ")}var ma=ct.forwardRef(({title:e,titleEs:t,titleEn:s,subtitle:r,subtitleEs:a,subtitleEn:i,description:n,descriptionEs:c,descriptionEn:d,children:o,header:h,footer:v,aside:g,primaryAction:l,secondaryActions:y=[],collapsible:R=false,defaultExpanded:b=true,expandedContent:W,status:L="neutral",statusMessage:Z,statusMessageEs:k,statusMessageEn:le,variant:se="default",size:X="md",loading:w=false,skeleton:m=false,lazyLoad:C=false,selectable:V=false,selected:K=false,onSelect:u,badge:z,badgeVariant:I="neutral",timestamp:P,author:N,category:M,informationDensity:D="medium",className:te,...S},A)=>{let[H,_]=ct.useState(b),O=(J,ee,de)=>J||ee||de||"",G=O(t,s,e),j=O(a,i,r),f=O(c,d,n),T=O(k,le,Z),Q=(l?1:0)+y.length;Q>4&&console.warn(`BIRHAUS 4-3-1 Rule Warning: Card has ${Q} actions (recommended: max 4)`);let F={sm:"p-4",md:"p-6",lg:"p-8"},E={default:"bg-white border border-gray-200 shadow-sm",elevated:"bg-white border border-gray-200 shadow-md hover:shadow-lg transition-shadow",outlined:"bg-white border-2 border-gray-300",minimal:"bg-transparent border-0"},$={neutral:"",success:"border-green-200 bg-green-50",warning:"border-yellow-200 bg-yellow-50",error:"border-red-200 bg-red-50",info:"border-blue-200 bg-blue-50"},p={neutral:null,success:jsxRuntime.jsx(lucideReact.CheckCircle2,{className:"h-4 w-4 text-green-600"}),warning:jsxRuntime.jsx(lucideReact.AlertTriangle,{className:"h-4 w-4 text-yellow-600"}),error:jsxRuntime.jsx(lucideReact.AlertTriangle,{className:"h-4 w-4 text-red-600"}),info:jsxRuntime.jsx(lucideReact.Info,{className:"h-4 w-4 text-blue-600"})},q={neutral:"bg-gray-100 text-gray-800",success:"bg-green-100 text-green-800",warning:"bg-yellow-100 text-yellow-800",error:"bg-red-100 text-red-800"},ne={low:"space-y-6",medium:"space-y-4",high:"space-y-2"},x=ir("rounded-lg transition-all duration-200",re(F,X,F.md),re(E,se,E.default),L!=="neutral"&&re($,L,""),V&&"cursor-pointer hover:border-blue-300",K&&"ring-2 ring-blue-500 border-blue-300",D&&re(ne,D,ne.medium),te);return m||w?jsxRuntime.jsx("div",{ref:A,className:x,...S,children:jsxRuntime.jsxs("div",{className:"animate-pulse space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("div",{className:"h-4 bg-gray-200 rounded w-3/4"}),jsxRuntime.jsx("div",{className:"h-3 bg-gray-200 rounded w-1/2"})]}),jsxRuntime.jsx("div",{className:"h-8 w-8 bg-gray-200 rounded"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("div",{className:"h-3 bg-gray-200 rounded"}),jsxRuntime.jsx("div",{className:"h-3 bg-gray-200 rounded w-5/6"})]}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx("div",{className:"h-8 w-16 bg-gray-200 rounded"}),jsxRuntime.jsx("div",{className:"h-8 w-20 bg-gray-200 rounded"})]})]})}):jsxRuntime.jsxs("div",{ref:A,className:x,onClick:V?u:void 0,"data-birhaus-component":"card","data-information-density":D,"data-selected":K,...S,children:[h&&jsxRuntime.jsx("div",{className:"mb-4 pb-4 border-b border-gray-200",children:h}),jsxRuntime.jsxs("div",{className:"flex items-start justify-between mb-4",children:[jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[z&&jsxRuntime.jsx("div",{className:"mb-2",children:jsxRuntime.jsx("span",{className:ir("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",re(q,I,q.neutral)),children:z})}),G&&jsxRuntime.jsx("h3",{className:"text-lg font-semibold text-gray-900 truncate",children:G}),j&&jsxRuntime.jsx("p",{className:"text-sm text-gray-600 mt-1",children:j}),(P||N||M)&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mt-2 text-xs text-gray-500",children:[P&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx(lucideReact.Clock,{className:"h-3 w-3"}),jsxRuntime.jsx("span",{children:P.toLocaleDateString("es-ES")})]}),N&&jsxRuntime.jsxs("span",{children:["por ",N]}),M&&jsxRuntime.jsx("span",{className:"px-2 py-0.5 bg-gray-100 rounded-full",children:M})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[l&&jsxRuntime.jsxs("button",{onClick:l.onClick,disabled:l.disabled||l.loading,className:ir("inline-flex items-center gap-2 px-3 py-1.5 text-sm font-medium rounded-md transition-colors","focus:outline-none focus:ring-2 focus:ring-offset-2","disabled:pointer-events-none disabled:opacity-50",l.variant==="primary"&&"bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500",l.variant==="destructive"&&"bg-red-600 text-white hover:bg-red-700 focus:ring-red-500",(!l.variant||l.variant==="secondary")&&"bg-gray-100 text-gray-700 hover:bg-gray-200 focus:ring-gray-500"),children:[l.loading?jsxRuntime.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-current"}):l.icon,l.labelEs||l.label]}),y.length>0&&jsxRuntime.jsx("div",{className:"relative",children:jsxRuntime.jsx("button",{className:"p-1 text-gray-400 hover:text-gray-600 focus:outline-none focus:ring-2 focus:ring-gray-500 rounded","aria-label":"M\xE1s acciones",children:jsxRuntime.jsx(lucideReact.MoreVertical,{className:"h-4 w-4"})})}),R&&jsxRuntime.jsx("button",{onClick:()=>_(!H),className:"p-1 text-gray-400 hover:text-gray-600 focus:outline-none focus:ring-2 focus:ring-gray-500 rounded","aria-label":H?"Contraer":"Expandir",children:H?jsxRuntime.jsx(lucideReact.ChevronUp,{className:"h-4 w-4"}):jsxRuntime.jsx(lucideReact.ChevronDown,{className:"h-4 w-4"})})]})]}),T&&jsxRuntime.jsxs("div",{className:ir("flex items-center gap-2 p-3 rounded-lg mb-4 text-sm",L==="success"&&"bg-green-100 text-green-800",L==="warning"&&"bg-yellow-100 text-yellow-800",L==="error"&&"bg-red-100 text-red-800",L==="info"&&"bg-blue-100 text-blue-800"),children:[re(p,L,p.info),jsxRuntime.jsx("span",{children:T})]}),f&&jsxRuntime.jsx("p",{className:"text-gray-600 text-sm mb-4",children:f}),g&&jsxRuntime.jsx("div",{className:"mb-4 p-3 bg-gray-50 rounded-lg",children:g}),o&&jsxRuntime.jsx("div",{className:"mb-4",children:o}),R&&W&&H&&jsxRuntime.jsx("div",{className:"border-t border-gray-200 pt-4 mt-4",children:W}),v&&jsxRuntime.jsx("div",{className:"mt-4 pt-4 border-t border-gray-200",children:v})]})});ma.displayName="BirhausCard";function Ri(){let[e,t]=ct.useState(false),[s,r]=ct.useState(false),[a,i]=ct.useState(false);return {expanded:e,selected:s,loading:a,setExpanded:t,setSelected:r,setLoading:i,toggleExpanded:()=>t(d=>!d),toggleSelected:()=>r(d=>!d)}}function Di(e,t,s,r){return {id:e,label:t,labelEs:t,labelEn:r?.labelEn,onClick:s,icon:r?.icon,variant:r?.variant||"secondary",disabled:r?.disabled||false,loading:false}}function ps(...e){return e.filter(Boolean).join(" ")}var fa=ct.forwardRef(({open:e=false,onOpenChange:t,title:s,titleEs:r,titleEn:a,description:i,descriptionEs:n,descriptionEn:c,children:d,undoConfig:o,variant:h="default",size:v="md",position:g="center",closeOnOverlayClick:l=true,closeOnEscape:y=true,persistent:R=false,primaryAction:b,secondaryActions:W=[],role:L="dialog",ariaLabelledBy:Z,ariaDescribedBy:k,className:le,overlayClassName:se},X)=>{let[w,m]=ct.useState(false),[C,V]=ct.useState(0),[K,u]=ct.useState(false),z=(_,O,G)=>_||O||G||"",I=z(r,a,s),P=z(n,c,i);ct.useEffect(()=>{if(!w||!o?.enabled)return;let _=o.timeoutMs||1e4;V(_);let O=setInterval(()=>{V(G=>G<=1e3?(m(false),clearInterval(O),0):G-1e3);},1e3);return ()=>clearInterval(O)},[w,o?.enabled,o?.timeoutMs]),ct.useEffect(()=>{if(!e)return;let _=O=>{O.key==="Escape"&&y&&!R&&t?.(false);};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[e,y,R,t]);let N=async()=>{if(o?.undoAction){u(true);try{await o.undoAction(),m(!1),t?.(!1);}catch(_){console.error("BIRHAUS Dialog: Undo action failed:",_);}finally{u(false);}}},M=async _=>{if(!(_.disabled||_.loading))try{await _.onClick(),_.variant==="destructive"&&o?.enabled?m(!0):t?.(!1);}catch(O){console.error("BIRHAUS Dialog: Action failed:",O);}},D=(b?1:0)+W.length;D>4&&console.warn(`BIRHAUS 4-3-1 Rule Warning: Dialog has ${D} actions (recommended: max 4)`);let te={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl",full:"max-w-full mx-4"},S={center:"items-center justify-center",top:"items-start justify-center pt-16",bottom:"items-end justify-center pb-16"},A={default:{icon:null,headerBg:"bg-gray-50",borderColor:"border-gray-200"},success:{icon:jsxRuntime.jsx(lucideReact.CheckCircle2,{className:"h-5 w-5 text-green-600"}),headerBg:"bg-green-50",borderColor:"border-green-200"},warning:{icon:jsxRuntime.jsx(lucideReact.AlertTriangle,{className:"h-5 w-5 text-yellow-600"}),headerBg:"bg-yellow-50",borderColor:"border-yellow-200"},error:{icon:jsxRuntime.jsx(lucideReact.AlertTriangle,{className:"h-5 w-5 text-red-600"}),headerBg:"bg-red-50",borderColor:"border-red-200"},info:{icon:jsxRuntime.jsx(lucideReact.Info,{className:"h-5 w-5 text-blue-600"}),headerBg:"bg-blue-50",borderColor:"border-blue-200"}},H=re(A,h,A.default);if(!e)return null;if(w&&o?.enabled){let _=z(o.messageEs,o.messageEn,"Acci\xF3n completada. Presiona deshacer si fue un error."),O=z(o.labelEs,o.labelEn,"Deshacer");return jsxRuntime.jsx("div",{className:"fixed inset-0 z-50 bg-black/50 flex items-center justify-center p-4",children:jsxRuntime.jsx("div",{ref:X,className:ps("bg-white rounded-lg shadow-lg border-2 border-green-200 p-6 max-w-md w-full",le),role:"alertdialog","aria-labelledby":"undo-title","aria-describedby":"undo-description",children:jsxRuntime.jsxs("div",{className:"flex items-start gap-4",children:[jsxRuntime.jsx("div",{className:"flex-shrink-0",children:jsxRuntime.jsx(lucideReact.CheckCircle2,{className:"h-6 w-6 text-green-600"})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("h3",{id:"undo-title",className:"text-lg font-semibold text-gray-900 mb-2",children:"\xA1Acci\xF3n completada!"}),jsxRuntime.jsx("p",{id:"undo-description",className:"text-sm text-gray-600 mb-4",children:_}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("button",{onClick:N,disabled:K,className:ps("inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-md","bg-red-600 text-white hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500","disabled:pointer-events-none disabled:opacity-50"),children:[K?jsxRuntime.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}):jsxRuntime.jsx(lucideReact.Undo2,{className:"h-4 w-4"}),K?"Deshaciendo...":O]}),jsxRuntime.jsxs("div",{className:"text-sm text-gray-500",children:["Auto-cierre en ",Math.ceil(C/1e3),"s"]})]})]})]})})})}return jsxRuntime.jsx("div",{className:ps("fixed inset-0 z-50 bg-black/50 flex",re(S,g,S.center),se),onClick:l?()=>t?.(false):void 0,children:jsxRuntime.jsxs("div",{ref:X,className:ps("bg-white rounded-lg shadow-xl border",re(te,v,te.md),H.borderColor,"w-full overflow-hidden",le),onClick:_=>_.stopPropagation(),role:L,"aria-labelledby":Z||"dialog-title","aria-describedby":k||"dialog-description","data-birhaus-component":"dialog","data-variant":h,children:[(I||H.icon)&&jsxRuntime.jsx("div",{className:ps("px-6 py-4 border-b border-gray-200",H.headerBg),children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[H.icon,I&&jsxRuntime.jsx("h2",{id:Z||"dialog-title",className:"text-lg font-semibold text-gray-900",children:I})]}),!R&&jsxRuntime.jsx("button",{onClick:()=>t?.(false),className:"text-gray-400 hover:text-gray-600 focus:outline-none focus:ring-2 focus:ring-gray-500 rounded p-1","aria-label":"Cerrar di\xE1logo",children:jsxRuntime.jsx(lucideReact.X,{className:"h-5 w-5"})})]})}),jsxRuntime.jsxs("div",{className:"px-6 py-4",children:[P&&jsxRuntime.jsx("p",{id:k||"dialog-description",className:"text-gray-600 mb-4",children:P}),d]}),(b||W.length>0)&&jsxRuntime.jsx("div",{className:"px-6 py-4 bg-gray-50 border-t border-gray-200",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-3",children:[W.map(_=>jsxRuntime.jsxs("button",{onClick:()=>M(_),disabled:_.disabled||_.loading,className:ps("inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-md","border border-gray-300 bg-white text-gray-700 hover:bg-gray-50","focus:outline-none focus:ring-2 focus:ring-gray-500","disabled:pointer-events-none disabled:opacity-50"),children:[_.loading?jsxRuntime.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-current"}):_.icon,_.labelEs||_.label]},_.id)),b&&jsxRuntime.jsxs("button",{onClick:()=>M(b),disabled:b.disabled||b.loading,className:ps("inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-md","focus:outline-none focus:ring-2 focus:ring-offset-2","disabled:pointer-events-none disabled:opacity-50",b.variant==="primary"&&"bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500",b.variant==="destructive"&&"bg-red-600 text-white hover:bg-red-700 focus:ring-red-500",(!b.variant||b.variant==="secondary")&&"bg-gray-600 text-white hover:bg-gray-700 focus:ring-gray-500"),children:[b.loading?jsxRuntime.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-current"}):b.icon,b.labelEs||b.label]})]})})]})})});fa.displayName="BirhausDialog";function Hi(){let[e,t]=ct.useState(false),[s,r]=ct.useState(false);return {open:e,undoActive:s,openDialog:()=>t(true),closeDialog:()=>t(false),activateUndo:()=>r(true),deactivateUndo:()=>r(false),setOpen:t}}function _i(e,t,s,r){return {id:e,label:t,labelEs:t,labelEn:r?.labelEn,onClick:s,icon:r?.icon,variant:r?.variant||"secondary",disabled:r?.disabled||false,loading:false}}function js(...e){return e.filter(Boolean).join(" ")}var ha=ct.forwardRef(({data:e,columns:t,emptyMessage:s,emptyMessageEs:r,emptyMessageEn:a,loadingMessage:i,loadingMessageEs:n,loadingMessageEn:c,maxVisibleColumns:d=7,showCognitiveWarning:o=true,sortable:h=true,filterable:v=false,searchable:g=false,selectable:l=false,loading:y=false,selectedRows:R=new Set,onRowSelect:b,onRowsSelect:W,pagination:L,sortConfig:Z,onSort:k,filters:le={},onFilter:se,searchValue:X="",onSearch:w,getRowId:m=(I,P)=>P,rowActions:C=[],variant:V="default",size:K="md",className:u},z)=>{let[I,P]=ct.useState(new Set),[N,M]=ct.useState(X),[D,te]=ct.useState(Z),S=(p,q,ne)=>p||q||ne||"",A=S(r,a,s||"No hay datos disponibles"),H=S(n,c,i||"Cargando datos..."),{visibleColumns:_,hiddenColumnCount:O,cognitiveLoad:G}=ct.useMemo(()=>{let p={high:1,medium:2,low:3},q=[...t].sort((be,fe)=>{let ce=p[be.priority||"medium"],Y=p[fe.priority||"medium"];if(ce!==Y)return ce-Y;let B=be.cognitiveWeight||5,U=fe.cognitiveWeight||5;return B-U}),ne=q.filter(be=>!I.has(be.id)).slice(0,d),x=q.length-ne.length,ee=ne.reduce((be,fe)=>be+(fe.cognitiveWeight||5),0)/ne.length,de=ne.length>7?"high":ne.length>5?"medium":"low";return {visibleColumns:ne,hiddenColumnCount:x,cognitiveLoad:de,avgCognitiveWeight:ee}},[t,I,d]);o&&_.length>7&&console.warn(`BIRHAUS Miller's Law Warning: Table shows ${_.length} columns (recommended: max 7)`);let j=p=>{if(!t.find(J=>J.id===p)?.sortable)return;let ne=D?.key===p&&D.direction==="asc"?"desc":"asc";te({key:p,direction:ne}),k?.(p,ne);},f=(p,q)=>{b?.(p,q);},T=p=>{let q=e.map((ne,x)=>m(ne,x));W?.(q,p);},Q=(p,q)=>typeof q.accessor=="function"?q.accessor(p):p[q.accessor],F=(p,q,ne)=>q.cell?q.cell(p,ne):q.isCurrency&&typeof p=="number"?new Intl.NumberFormat("es-PY",{style:"currency",currency:"PYG",minimumFractionDigits:0}).format(p):q.isPercentage&&typeof p=="number"?`${(p*100).toFixed(1)}%`:q.isDate&&p?new Date(p).toLocaleDateString("es-ES"):p?.toString()||"",E={sm:"text-xs",md:"text-sm",lg:"text-base"},$={default:"border border-gray-200",striped:"border border-gray-200",bordered:"border-2 border-gray-300",minimal:"border-0"};return y?jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsxs("div",{className:"animate-pulse space-y-4",children:[jsxRuntime.jsx("div",{className:"h-10 bg-gray-200 rounded"}),[...Array(5)].map((p,q)=>jsxRuntime.jsx("div",{className:"h-8 bg-gray-100 rounded"},q))]}),jsxRuntime.jsx("p",{className:"text-center text-gray-500 mt-4",children:H})]}):e.length===0?jsxRuntime.jsx("div",{className:"w-full text-center py-12",children:jsxRuntime.jsx("p",{className:"text-gray-500 text-lg",children:A})}):jsxRuntime.jsxs("div",{className:"w-full space-y-4",children:[o&&G==="high"&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-3 bg-yellow-50 border border-yellow-200 rounded-lg",children:[jsxRuntime.jsx(lucideReact.AlertTriangle,{className:"h-4 w-4 text-yellow-600"}),jsxRuntime.jsxs("span",{className:"text-sm text-yellow-800",children:["Mostrando ",_.length," columnas (m\xE1ximo recomendado: 7).",O>0&&` ${O} columnas ocultas.`]})]}),(g||v||O>0)&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-4",children:[g&&jsxRuntime.jsxs("div",{className:"relative flex-1 max-w-sm",children:[jsxRuntime.jsx(lucideReact.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),jsxRuntime.jsx("input",{type:"text",value:N,onChange:p=>{M(p.target.value),w?.(p.target.value);},placeholder:"Buscar...",className:"w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]}),O>0&&jsxRuntime.jsxs("button",{onClick:()=>P(new Set),className:"inline-flex items-center gap-2 px-3 py-2 text-sm border border-gray-300 rounded-lg hover:bg-gray-50",children:[jsxRuntime.jsx(lucideReact.MoreHorizontal,{className:"h-4 w-4"}),"Mostrar ",O," columnas m\xE1s"]})]}),jsxRuntime.jsx("div",{className:"overflow-x-auto rounded-lg border border-gray-200",children:jsxRuntime.jsxs("table",{ref:z,className:js("w-full table-auto",E[K],$[V],u),"data-birhaus-component":"table","data-cognitive-load":G,"data-visible-columns":_.length,children:[jsxRuntime.jsx("thead",{className:"bg-gray-50",children:jsxRuntime.jsxs("tr",{children:[l&&jsxRuntime.jsx("th",{className:"px-4 py-3 text-left",children:jsxRuntime.jsx("input",{type:"checkbox",onChange:p=>T(p.target.checked),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"})}),_.map(p=>jsxRuntime.jsx("th",{className:js("px-4 py-3 font-medium text-gray-900",p.align==="center"&&"text-center",p.align==="right"&&"text-right",p.sortable&&"cursor-pointer hover:bg-gray-100"),style:{width:p.width},onClick:()=>p.sortable&&j(p.id),children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{children:p.headerEs||p.header}),p.sortable&&D?.key===p.id&&(D.direction==="asc"?jsxRuntime.jsx(lucideReact.ChevronUp,{className:"h-4 w-4"}):jsxRuntime.jsx(lucideReact.ChevronDown,{className:"h-4 w-4"}))]})},p.id)),C.length>0&&jsxRuntime.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-900",children:"Acciones"})]})}),jsxRuntime.jsx("tbody",{className:"divide-y divide-gray-200",children:e.map((p,q)=>{let ne=m(p,q),x=R.has(ne);return jsxRuntime.jsxs("tr",{className:js("hover:bg-gray-50",V==="striped"&&q%2===1&&"bg-gray-50",x&&"bg-blue-50"),children:[l&&jsxRuntime.jsx("td",{className:"px-4 py-3",children:jsxRuntime.jsx("input",{type:"checkbox",checked:x,onChange:J=>f(ne,J.target.checked),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"})}),_.map(J=>{let ee=Q(p,J),de=F(ee,J,p);return jsxRuntime.jsx("td",{className:js("px-4 py-3 text-gray-900",J.align==="center"&&"text-center",J.align==="right"&&"text-right",J.isCurrency&&"font-mono"),children:de},J.id)}),C.length>0&&jsxRuntime.jsx("td",{className:"px-4 py-3 text-right",children:jsxRuntime.jsx("div",{className:"flex items-center justify-end gap-2",children:C.map(J=>jsxRuntime.jsxs("button",{onClick:()=>J.onClick(p),disabled:J.disabled?.(p),className:js("inline-flex items-center gap-1 px-2 py-1 text-xs font-medium rounded","focus:outline-none focus:ring-2 focus:ring-offset-1","disabled:pointer-events-none disabled:opacity-50",J.variant==="primary"&&"bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500",J.variant==="destructive"&&"bg-red-600 text-white hover:bg-red-700 focus:ring-red-500",(!J.variant||J.variant==="secondary")&&"bg-gray-100 text-gray-700 hover:bg-gray-200 focus:ring-gray-500"),children:[J.icon,J.labelEs||J.label]},J.id))})})]},ne)})})]})}),L&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"text-sm text-gray-700",children:["Mostrando ",(L.page-1)*L.pageSize+1," a"," ",Math.min(L.page*L.pageSize,L.total)," de"," ",L.total," resultados"]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("button",{onClick:()=>L.onPageChange(L.page-1),disabled:L.page===1,className:"px-3 py-1 text-sm border border-gray-300 rounded hover:bg-gray-50 disabled:opacity-50",children:"Anterior"}),jsxRuntime.jsx("span",{className:"px-3 py-1 text-sm",children:L.page}),jsxRuntime.jsx("button",{onClick:()=>L.onPageChange(L.page+1),disabled:L.page*L.pageSize>=L.total,className:"px-3 py-1 text-sm border border-gray-300 rounded hover:bg-gray-50 disabled:opacity-50",children:"Siguiente"})]})]})]})});ha.displayName="BirhausTable";function Wi(e=[]){let[t,s]=ct.useState(e),[r,a]=ct.useState(new Set),[i,n]=ct.useState(),[c,d]=ct.useState({}),[o,h]=ct.useState("");return {data:t,setData:s,selectedRows:r,setSelectedRows:a,sortConfig:i,setSortConfig:n,filters:c,setFilters:d,searchValue:o,setSearchValue:h,handleRowSelect:(y,R)=>{let b=new Set(r);R?b.add(y):b.delete(y),a(b);},handleRowsSelect:(y,R)=>{let b=new Set(r);y.forEach(W=>{R?b.add(W):b.delete(W);}),a(b);},clearSelection:()=>a(new Set)}}function nt(...e){return e.filter(Boolean).join(" ")}var fs=ct.forwardRef(({label:e,labelEs:t,labelEn:s,description:r,descriptionEs:a,descriptionEn:i,indeterminate:n=false,variant:c="default",size:d="md",labelPosition:o="right",showStateIcon:h=true,error:v=false,errorMessage:g,errorMessageEs:l,errorMessageEn:y,success:R=false,successMessage:b,successMessageEs:W,successMessageEn:L,checked:Z,disabled:k,onChange:le,className:se,labelClassName:X,...w},m)=>{let[C,V]=ct.useState(Z||false),K=Z!==void 0?Z:C,u=Z!==void 0,z=(j,f,T)=>j||f||T||"",I=z(t,s,e),P=z(a,i,r),N=z(l,y,g),M=z(W,L,b),D=j=>{if(!k){let f=j.target.checked;u||V(f),le?.(j);}},te={sm:{checkbox:"h-4 w-4",icon:"h-3 w-3",label:"text-sm",description:"text-xs"},md:{checkbox:"h-5 w-5",icon:"h-4 w-4",label:"text-base",description:"text-sm"},lg:{checkbox:"h-6 w-6",icon:"h-5 w-5",label:"text-lg",description:"text-base"}},S={default:{border:"border-gray-300",checked:"bg-blue-600 border-blue-600",focus:"focus:ring-blue-500"},success:{border:"border-green-300",checked:"bg-green-600 border-green-600",focus:"focus:ring-green-500"},warning:{border:"border-yellow-300",checked:"bg-yellow-600 border-yellow-600",focus:"focus:ring-yellow-500"},error:{border:"border-red-300",checked:"bg-red-600 border-red-600",focus:"focus:ring-red-500"}},A=te[d],H=S[v?"error":R?"success":c],_=nt("relative rounded border-2 transition-colors duration-200","focus:outline-none focus:ring-2 focus:ring-offset-2",A.checkbox,H.focus,K||n?H.checked:nt("bg-white",H.border),k&&"opacity-50 cursor-not-allowed",!k&&"cursor-pointer hover:border-gray-400"),O=nt("font-medium text-gray-900",A.label,k&&"text-gray-400",X),G=nt("flex items-start gap-3",o==="left"&&"flex-row-reverse",se);return jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("label",{className:G,children:[jsxRuntime.jsx("input",{ref:m,type:"checkbox",checked:K,onChange:D,disabled:k,className:"sr-only",...w}),jsxRuntime.jsx("div",{className:_,children:(K||n)&&h&&jsxRuntime.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:n?jsxRuntime.jsx(lucideReact.Minus,{className:nt(A.icon,"text-white")}):jsxRuntime.jsx(lucideReact.Check,{className:nt(A.icon,"text-white")})})}),(I||P)&&jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[I&&jsxRuntime.jsx("div",{className:O,children:I}),P&&jsxRuntime.jsx("div",{className:nt("text-gray-600 mt-1",A.description,k&&"text-gray-400"),children:P})]})]}),v&&N&&jsxRuntime.jsx("div",{className:nt("text-red-600 flex items-center gap-1",A.description),children:jsxRuntime.jsx("span",{children:N})}),R&&M&&jsxRuntime.jsx("div",{className:nt("text-green-600 flex items-center gap-1",A.description),children:jsxRuntime.jsx("span",{children:M})})]})});fs.displayName="BirhausCheckbox";var xa=ct.forwardRef(({label:e,labelEs:t,labelEn:s,description:r,descriptionEs:a,descriptionEn:i,showLabels:n=false,onLabel:c="S\xED",onLabelEs:d="S\xED",onLabelEn:o="Yes",offLabel:h="No",offLabelEs:v="No",offLabelEn:g="No",variant:l="default",size:y="md",labelPosition:R="right",error:b=false,errorMessage:W,errorMessageEs:L,errorMessageEn:Z,success:k=false,successMessage:le,successMessageEs:se,successMessageEn:X,checked:w,disabled:m,onChange:C,className:V,labelClassName:K,...u},z)=>{let[I,P]=ct.useState(w||false),N=w!==void 0?w:I,M=w!==void 0,D=(p,q,ne)=>p||q||ne||"",te=D(t,s,e),S=D(a,i,r),A=D(L,Z,W),H=D(se,X,le),_=D(d,o,c),O=D(v,g,h),G=p=>{if(!m){let q=p.target.checked;M||P(q),C?.(p);}},j={sm:{track:"h-5 w-9",thumb:"h-4 w-4",translate:"translate-x-4",label:"text-sm",description:"text-xs",switchLabel:"text-xs"},md:{track:"h-6 w-11",thumb:"h-5 w-5",translate:"translate-x-5",label:"text-base",description:"text-sm",switchLabel:"text-xs"},lg:{track:"h-7 w-13",thumb:"h-6 w-6",translate:"translate-x-6",label:"text-lg",description:"text-base",switchLabel:"text-sm"}},f={default:{trackOff:"bg-gray-200",trackOn:"bg-blue-600",focus:"focus:ring-blue-500"},success:{trackOff:"bg-gray-200",trackOn:"bg-green-600",focus:"focus:ring-green-500"},warning:{trackOff:"bg-gray-200",trackOn:"bg-yellow-600",focus:"focus:ring-yellow-500"},error:{trackOff:"bg-gray-200",trackOn:"bg-red-600",focus:"focus:ring-red-500"}},T=j[y],Q=f[b?"error":k?"success":l],F=nt("flex items-start gap-3",R==="left"&&"flex-row-reverse",V),E=nt("relative inline-flex items-center rounded-full border-2 border-transparent transition-colors duration-200","focus:outline-none focus:ring-2 focus:ring-offset-2",T.track,Q.focus,N?Q.trackOn:Q.trackOff,m?"opacity-50 cursor-not-allowed":"cursor-pointer"),$=nt("inline-block bg-white rounded-full shadow-lg transform transition-transform duration-200",T.thumb,N?T.translate:"translate-x-0");return jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("label",{className:F,children:[jsxRuntime.jsx("input",{ref:z,type:"checkbox",checked:N,onChange:G,disabled:m,className:"sr-only",role:"switch","aria-checked":N,...u}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[n&&jsxRuntime.jsx("span",{className:nt(T.switchLabel,"text-gray-600",!N&&"font-medium text-gray-900"),children:O}),jsxRuntime.jsx("div",{className:E,children:jsxRuntime.jsx("div",{className:$})}),n&&jsxRuntime.jsx("span",{className:nt(T.switchLabel,"text-gray-600",N&&"font-medium text-gray-900"),children:_})]}),(te||S)&&jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[te&&jsxRuntime.jsx("div",{className:nt("font-medium text-gray-900",T.label,m&&"text-gray-400",K),children:te}),S&&jsxRuntime.jsx("div",{className:nt("text-gray-600 mt-1",T.description,m&&"text-gray-400"),children:S})]})]}),b&&A&&jsxRuntime.jsx("div",{className:nt("text-red-600 flex items-center gap-1",T.description),children:jsxRuntime.jsx("span",{children:A})}),k&&H&&jsxRuntime.jsx("div",{className:nt("text-green-600 flex items-center gap-1",T.description),children:jsxRuntime.jsx("span",{children:H})})]})});xa.displayName="BirhausSwitch";function Ji(e=false){let[t,s]=ct.useState(e),[r,a]=ct.useState(false),[i,n]=ct.useState(false);return {checked:t,setChecked:s,error:r,setError:a,success:i,setSuccess:n,toggle:()=>s(o=>!o),reset:()=>{s(e),a(false),n(false);}}}function hs(...e){return e.filter(Boolean).join(" ")}var ya=ct.forwardRef(({tabs:e,activeTab:t,onTabChange:s,maxVisibleTabs:r=4,showCognitiveWarning:a=true,variant:i="default",size:n="md",orientation:c="horizontal",activateOnHover:d=false,lazy:o=false,overflowBehavior:h="dropdown",contentPadding:v=true,className:g,tabListClassName:l,tabClassName:y,contentClassName:R},b)=>{let[W,L]=ct.useState(e[0]?.id||""),[Z,k]=ct.useState(false),le=t!==void 0?t:W,se=t!==void 0,X=(S,A,H)=>S||A||H||"",{visibleTabs:w,overflowTabs:m,cognitiveLoad:C}=ct.useMemo(()=>{let A=[...e.filter(G=>!G.disabled)].sort((G,j)=>{let f=G.cognitiveWeight||5,T=j.cognitiveWeight||5;return f-T}),H=A.slice(0,r),_=A.slice(r),O=H.length>4?"high":H.length>3?"medium":"low";return {visibleTabs:H,overflowTabs:_,cognitiveLoad:O}},[e,r]);a&&w.length>4&&console.warn(`BIRHAUS 4-3-1 Rule Warning: Tabs show ${w.length} items (recommended: max 4)`);let V=S=>{let A=e.find(H=>H.id===S);A&&!A.disabled&&(se||L(S),s?.(S),k(false));},K=S=>{d&&V(S);},u=e.find(S=>S.id===le),z={sm:{tab:"px-3 py-1.5 text-sm",content:"p-3",badge:"text-xs px-1.5 py-0.5"},md:{tab:"px-4 py-2 text-base",content:"p-4",badge:"text-xs px-2 py-1"},lg:{tab:"px-6 py-3 text-lg",content:"p-6",badge:"text-sm px-2.5 py-1"}},I={default:{tabList:"border-b border-gray-200",tab:"border-b-2 border-transparent hover:border-gray-300",activeTab:"border-blue-600 text-blue-600",inactiveTab:"text-gray-500 hover:text-gray-700"},pills:{tabList:"bg-gray-100 rounded-lg p-1",tab:"rounded-md transition-colors",activeTab:"bg-white text-gray-900 shadow-sm",inactiveTab:"text-gray-600 hover:text-gray-900 hover:bg-white/50"},underline:{tabList:"",tab:"border-b-2 border-transparent",activeTab:"border-blue-600 text-blue-600",inactiveTab:"text-gray-500 hover:text-gray-700 hover:border-gray-300"},bordered:{tabList:"border border-gray-200 rounded-t-lg",tab:"border-r border-gray-200 last:border-r-0",activeTab:"bg-white text-gray-900 border-b-white",inactiveTab:"bg-gray-50 text-gray-600 hover:bg-gray-100"}},P={horizontal:{container:"w-full",tabList:"flex",content:"w-full"},vertical:{container:"flex gap-4",tabList:"flex flex-col min-w-48",content:"flex-1"}},N=re(z,n,z.md),M=re(I,i,I.default),D=re(P,c,P.horizontal),te=(S,A)=>{let H=X(S.labelEs,S.labelEn,S.label);return jsxRuntime.jsxs("button",{onClick:()=>V(S.id),onMouseEnter:()=>K(S.id),disabled:S.disabled,className:hs("relative inline-flex items-center gap-2 font-medium transition-colors duration-200","focus:outline-none focus:ring-2 focus:ring-blue-500 focus