bonsaif-ui 0.1.2 → 0.1.4

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.
@@ -1 +1 @@
1
- (function(T,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react"),require("react-icons/hi2"),require("overlayscrollbars"),require("react-dom"),require("react-icons/md"),require("overlayscrollbars-react"),require("react-day-picker"),require("react-day-picker/dist/style.css"),require("react-icons/fi"),require("sonner")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-icons/hi2","overlayscrollbars","react-dom","react-icons/md","overlayscrollbars-react","react-day-picker","react-day-picker/dist/style.css","react-icons/fi","sonner"],e):(T=typeof globalThis<"u"?globalThis:T||self,e(T.BonsaifUI={},T.jsxRuntime,T.React,T.ReactIconsHi2,T.OverlayScrollbarsGlobal,T.ReactDOM,T.ReactIconsMd,T.OverlayScrollbarsReact,T.ReactDayPicker,T.ReactDayPickerStyles,T.ReactIconsFi,T.Sonner))})(this,(function(T,e,s,g,Je,Le,Er,Ve,Ke,zt,Mr,$r){"use strict";"use client";function Ze(...r){return r.filter(Boolean).join(" ")}function Tr({variant:r="primary",className:t,type:a="button",children:n,...l}){return e.jsx("button",{className:Ze("bonsaif-ui-button",`bonsaif-ui-button--${r}`,t),type:a,...l,children:n})}function Qe({value:r,onChange:t,placeholder:a,className:n="",autoFocus:l=!1,forceExpanded:f=!1,onEscape:d,size:h="default",inputTabIndex:u}){const b=s.useRef(null),[N,k]=s.useState(!1),y=f||N||r.trim().length>0,p=h==="sm"?"h-9 rounded-md":"h-11 rounded-lg";s.useEffect(()=>{var c;l&&(k(!0),(c=b.current)==null||c.focus())},[l]);const x=()=>{var c;k(!0),(c=b.current)==null||c.focus()};return e.jsxs("div",{className:`relative flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${y?n||"w-full":"w-28"}`,onMouseDown:c=>{y||(c.preventDefault(),x())},children:[e.jsx(g.HiMagnifyingGlass,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none transition-colors duration-200",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:b,type:"text",tabIndex:u,"aria-label":a,value:r,onChange:c=>t(c.target.value),onKeyDown:c=>{c.key==="Escape"&&(d==null||d())},placeholder:y?a:"Buscar",className:`${p} w-full py-0 text-sm placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${y?"pl-9 pr-9":"cursor-pointer pl-9 pr-3"}`,style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"},onFocus:c=>{k(!0),c.currentTarget.style.borderColor="var(--primary)",c.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:c=>{k(!1),c.currentTarget.style.borderColor="var(--border)",c.currentTarget.style.boxShadow="none"}}),r&&e.jsx("button",{type:"button",onClick:()=>t(""),className:"absolute right-2 top-1/2 flex !h-6 !w-6 -translate-y-1/2 items-center justify-center rounded-full !p-0 leading-none transition-colors hover:bg-black/5",style:{color:"var(--text-muted)"},"aria-label":"Limpiar búsqueda",children:e.jsx(g.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}function Re(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}const Dr="inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap leading-none font-medium transition-all duration-150 focus:outline-none disabled:opacity-50 rounded-lg",Br={primary:"border border-[var(--border)] text-[var(--text-main)] hover:border-[var(--border)] hover:bg-[var(--bg-input)] active:scale-[0.98] transition-colors",secondary:"border border-[var(--border)] text-[var(--text-main)] hover:border-[var(--border)] hover:bg-[var(--bg-input)] active:scale-[0.98] transition-colors",danger:"border border-[var(--border)] text-[var(--danger)] hover:border-[var(--danger)] hover:bg-[var(--danger-bg)] active:scale-[0.98] transition-colors",ghost:"text-[var(--text-secondary)] hover:opacity-70",icon:"h-9 w-9 text-[var(--text-muted)] hover:text-[var(--primary)] hover:bg-primary/5"},Hr={sm:"h-9 px-3.5 text-xs",md:"h-11 px-4 text-sm",lg:"h-12 px-5 text-sm font-semibold"},Lr={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function fe({variant:r="primary",size:t="md",loading:a=!1,icon:n,height:l,padding:f,children:d,className:h="",disabled:u,style:b,...N}){const k=r==="icon";return e.jsxs("button",{...N,"data-variant":r,"data-size":t,"data-icon":k?"true":void 0,disabled:u||a,className:`${Dr} ${Br[r]} ${k?"":Hr[t]} ${h}`,style:{...Lr[r],height:Re(l),padding:Re(f),...b},children:[a?e.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):n,d]})}function er({variant:r="page",title:t="Cargando...",rows:a=6,children:n}){return r==="table"?e.jsx(rr,{rows:a}):r==="sections"?e.jsx(Ir,{rows:a}):r==="cards"?e.jsx(Or,{rows:a}):e.jsx("div",{className:"flex min-h-[240px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[e.jsx("div",{className:"h-9 w-9 animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:t}),n&&e.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:n})]})]})})}function Ir({rows:r}){return e.jsx("div",{className:"space-y-4",children:Array.from({length:Math.max(2,Math.min(r,4))}).map((t,a)=>e.jsxs("section",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-pulse rounded bg-[var(--bg-input)]"}),e.jsx("div",{className:"h-4 w-32 animate-pulse rounded bg-[var(--bg-input)]"}),e.jsx("div",{className:"h-5 w-20 animate-pulse rounded-full bg-[var(--bg-input)]"})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"h-8 w-8 animate-pulse rounded-md bg-[var(--bg-input)]"}),e.jsx("div",{className:"h-8 w-8 animate-pulse rounded-md bg-[var(--bg-input)]"})]})]}),e.jsx(rr,{rows:a===0?r:Math.max(3,r-2),compact:!0})]},a))})}function Or({rows:r}){return e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:Array.from({length:r}).map((t,a)=>e.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[e.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded bg-[var(--bg-input)]"}),e.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded bg-[var(--bg-input)]"}),e.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded bg-[var(--bg-input)]"})]},a))})}function rr({rows:r,compact:t=!1}){const a=t?5:6;return e.jsxs("div",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",children:[e.jsx("div",{className:"grid border-b border-[var(--border)]",style:{gridTemplateColumns:`repeat(${a}, minmax(0, 1fr))`},children:Array.from({length:a}).map((n,l)=>e.jsx("div",{className:"px-3 py-3",children:e.jsx("div",{className:"h-3 w-2/3 animate-pulse rounded bg-[var(--bg-input)]"})},l))}),Array.from({length:r}).map((n,l)=>e.jsx("div",{className:"grid border-b border-[var(--border)] last:border-b-0",style:{gridTemplateColumns:`repeat(${a}, minmax(0, 1fr))`},children:Array.from({length:a}).map((f,d)=>e.jsx("div",{className:"px-3 py-3",children:e.jsx("div",{className:"h-3.5 animate-pulse rounded-full bg-[var(--bg-input)]",style:{width:`${52+(l*13+d*11)%36}%`}})},d))},l))]})}function tr(r){const t=r.split("/").filter(Boolean);return(t[t.length-1]??r).replace(/^lv_/,"").split(/[-_]/).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function ar(r){return r.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function Ar(r){return[r.label,tr(r.service),r.description,r.service].filter(Boolean).join(" ")}function zr(r){return typeof r=="function"?r:r.default}function Pr(r,t){return e.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 text-center",children:e.jsxs("div",{className:"max-w-md",children:[e.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:"No se pudo cargar este modulo"}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:r.message}),e.jsx(fe,{className:"mt-4",height:36,padding:"0 14px",onClick:t,children:"Reintentar"})]})})}function _r({parentPanel:r,parentPanelComponent:t,renderParentPanel:a,parent:n,context:l,links:f,moduleRegistry:d,loadModule:h,activeService:u,initialService:b,onActiveServiceChange:N,canAccess:k,keepAlive:y=!0,title:p,subtitle:x,emptyState:c,loadingState:M,errorState:L=Pr,renderTabLabel:Z,searchableTabs:W="auto",tabsSearchThreshold:$=6,tabsSearchPlaceholder:H="Buscar modulo...",tabsSearchValue:I,onTabsSearchChange:B,emptySearchState:U,showTabCount:D=!0,className:C="",parentClassName:F="",contentClassName:V="",tabsClassName:P=""}){var de;const j=s.useMemo(()=>f.filter(m=>!m.hidden&&((k==null?void 0:k(m,l))??!0)),[k,l,f]),Y=(de=j.find(m=>!m.disabled))==null?void 0:de.service,[Q,o]=s.useState(b??Y??""),[w,_]=s.useState({}),[G,X]=s.useState({}),[ee,ue]=s.useState(""),[re,be]=s.useState(!1),pe=s.useRef(G),ve=s.useRef(0),ce=I??ee,S=ar(ce),z=W===!0||W==="auto"&&j.length>=$,J=z&&ce.trim().length>0,ae=s.useMemo(()=>S?j.filter(m=>ar(Ar(m)).includes(S)):j,[S,j]),le=u??Q,O=j.find(m=>m.service===le)??j.find(m=>!m.disabled);s.useEffect(()=>{!O&&Y&&o(Y)},[Y,O]),s.useEffect(()=>{pe.current=G},[G]);const we=m=>{m.disabled||(u||o(m.service),N==null||N(m.service,m))},Ae=m=>{I===void 0&&ue(m),B==null||B(m)},me=(m,K)=>{const oe=ae.filter(se=>!se.disabled),ke=oe.findIndex(se=>se.service===K.service);ke<0||((m.key==="ArrowRight"||m.key==="ArrowDown")&&(m.preventDefault(),we(oe[(ke+1)%oe.length])),(m.key==="ArrowLeft"||m.key==="ArrowUp")&&(m.preventDefault(),we(oe[(ke-1+oe.length)%oe.length])),m.key==="Home"&&(m.preventDefault(),we(oe[0])),m.key==="End"&&(m.preventDefault(),we(oe[oe.length-1])))},De=s.useCallback(()=>{if(!O)return;const m=O.service,K=pe.current[m];if(K!=null&&K.loading||K!=null&&K.component&&y)return;const oe=(d==null?void 0:d[m])??h;if(!oe){X(se=>({...se,[m]:{loading:!1,error:new Error(`No module loader found for service "${m}".`)}}));return}const ke=++ve.current;X(se=>({...se,[m]:{...se[m],loading:!0,error:void 0}})),oe(O,l).then(se=>{if(ke!==ve.current&&!y)return;const Se=zr(se);X(Ee=>({...Ee,[m]:{component:Se,loading:!1}}))}).catch(se=>{const Se=se instanceof Error?se:new Error(String(se));X(Ee=>({...Ee,[m]:{...Ee[m],loading:!1,error:Se}}))})},[l,y,h,d,O]);s.useEffect(De,[De]);const ze=O?w[O.service]??null:null,ne=O?G[O.service]:void 0,Ce=ne==null?void 0:ne.component,Be=m=>{O&&_(K=>({...K,[O.service]:m}))},Pe=()=>{O&&_(m=>({...m,[O.service]:null}))},ge={context:l,parent:n,links:f,visibleLinks:j,filteredLinks:ae,selectedLink:O,selectedService:O==null?void 0:O.service,activeItemId:ze,tabsSearch:ce,onSelectService:we,onOpenDetail:Be,onBackToList:Pe},xe=a?a(ge):t?e.jsx(t,{...ge}):r;return e.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${C}`,children:[e.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${F}`,children:xe}),e.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${V}`,children:[(p||x||z||D)&&e.jsx("div",{className:"relative border-b border-[var(--border)] px-4 py-3",children:e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[p&&e.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:p}),x&&e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:x})]}),(z||D)&&e.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[D&&e.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[ae.length," / ",j.length]}),z&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${re?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!re,children:e.jsx(Qe,{value:ce,onChange:Ae,placeholder:H,className:"w-full",autoFocus:re,forceExpanded:!0,onEscape:()=>be(!1),size:"sm",inputTabIndex:re?0:-1})}),e.jsx("button",{type:"button","aria-label":re?"Cerrar busqueda":"Buscar tabs","aria-expanded":re,onClick:()=>{re&&ce&&Ae(""),be(m=>!m)},className:`inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border transition-all duration-200 hover:scale-[1.03] active:scale-95 ${re||J?"border-[var(--primary)] bg-[var(--bg-input)] text-[var(--text-main)] shadow-sm":"border-[var(--border)] text-[var(--text-muted)] hover:bg-[var(--bg-input)] hover:text-[var(--text-main)]"}`,children:e.jsx("span",{className:"grid h-4 w-4 place-items-center transition-transform duration-200",children:re||J?e.jsx(g.HiXMark,{className:"h-4 w-4"}):e.jsx(g.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),e.jsx("div",{role:"tablist","aria-label":p??"Modulos relacionados",className:`flex gap-1 overflow-x-auto border-b border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 transition-colors duration-200 ${P}`,children:ae.length>0?ae.map(m=>{const K=m.service===(O==null?void 0:O.service);return e.jsx("button",{type:"button",role:"tab","aria-selected":K,disabled:m.disabled,onClick:()=>we(m),onKeyDown:oe=>me(oe,m),className:`inline-flex h-9 min-w-max items-center gap-2 rounded-md border px-3 text-xs font-semibold transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-50 ${K?"border-[var(--primary)] bg-[var(--bg-card)] text-[var(--text-main)] shadow-sm":"border-transparent text-[var(--text-muted)] hover:bg-[var(--bg-card)] hover:text-[var(--text-main)]"}`,children:Z?Z(m,K):e.jsxs(e.Fragment,{children:[m.icon,e.jsx("span",{children:m.label??tr(m.service)}),m.badge&&e.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:m.badge})]})},m.service)}):e.jsx("div",{className:"flex min-h-9 flex-1 items-center rounded-md border border-dashed border-[var(--border)] px-3 text-xs text-[var(--text-muted)]",children:U??"No hay modulos que coincidan con la busqueda."})}),(O==null?void 0:O.description)&&e.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:O.description}),e.jsxs("div",{className:"min-h-[420px] p-4",children:[!O&&(c??e.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-dashed border-[var(--border)] text-sm text-[var(--text-muted)]",children:"No hay modulos disponibles."})),O&&(ne==null?void 0:ne.loading)&&(M??e.jsx(er,{title:"Cargando modulo..."})),O&&(ne==null?void 0:ne.error)&&L(ne.error,De),O&&Ce&&!(ne!=null&&ne.loading)&&!(ne!=null&&ne.error)&&e.jsx(Ce,{context:l,parent:n,link:O,activeItemId:ze,onOpenDetail:Be,onBackToList:Pe})]})]})]})}const nr=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],Fr=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],Wr=["Do","Lu","Ma","Mi","Ju","Vi","Sá"],_e=6;function Fe(r,t,a){return`${r}-${String(t).padStart(2,"0")}-${String(a).padStart(2,"0")}`}function jr(){const r=new Date;return Fe(r.getFullYear(),r.getMonth()+1,r.getDate())}function or(r){const[t,a,n]=r.split("-").map(Number);return{year:t,month:a,day:n}}function Ur(r){if(!r)return"Seleccionar fecha";const{year:t,month:a,day:n}=or(r);return!t||!a||!n?"Seleccionar fecha":`${String(n).padStart(2,"0")} ${nr[a-1]} ${t}`}function qr({value:r,onChange:t,minDate:a,displayMode:n="inline"}){const l=jr(),d=or(r||l),h=n==="popover",[u,b]=s.useState(!1),N=s.useRef(null),[k,y]=s.useState({horizontal:"left",vertical:"bottom"}),[p,x]=s.useState(d.year),[c,M]=s.useState(d.month),[L,Z]=s.useState("days"),W=16,[$,H]=s.useState(0),I=p-7+$,B=Array.from({length:W},(o,w)=>I+w);s.useEffect(()=>{if(!h||!u||!N.current)return;const o=N.current.getBoundingClientRect(),w=8,_=280,G=340,X=o.left+_>window.innerWidth-w,ee=o.right-_>=w,ue=o.bottom+8+G>window.innerHeight-w,re=o.top-8-G>=w;y({horizontal:X&&ee?"right":"left",vertical:ue&&re?"top":"bottom"})},[h,u]),s.useEffect(()=>{if(!h||!u)return;function o(_){N.current&&(N.current.contains(_.target)||b(!1))}function w(_){_.key==="Escape"&&b(!1)}return document.addEventListener("mousedown",o),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("keydown",w)}},[h,u]);function U(){c===1?(x(o=>o-1),M(12)):M(o=>o-1)}function D(){c===12?(x(o=>o+1),M(1)):M(o=>o+1)}const C=new Date(p,c-1,1).getDay(),F=new Date(p,c,0).getDate(),V=[...Array(C).fill(null),...Array.from({length:F},(o,w)=>w+1)];for(;V.length<_e*7;)V.push(null);const P=V.slice(0,_e*7);function j(o){const w=Fe(p,c,o);a&&w<a||(t(w),h&&b(!1))}const Y={background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,borderRadius:6,display:"flex",alignItems:"center"},Q=e.jsxs("div",{style:{background:"var(--bg-input)",border:"1px solid var(--border)",borderRadius:10,overflow:"hidden",userSelect:"none",width:280},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 12px",borderBottom:"1px solid var(--border)"},children:L==="days"?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:U,style:Y,title:"Mes anterior",children:e.jsx(g.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>{Z("years"),H(0)},style:{background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:4,fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[nr[c-1]," ",p,e.jsx(g.HiChevronDown,{size:13,style:{color:"var(--text-muted)"}})]}),e.jsx("button",{type:"button",onClick:D,style:Y,title:"Mes siguiente",children:e.jsx(g.HiChevronRight,{size:16})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>H(o=>o-W),style:Y,children:e.jsx(g.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>Z("days"),style:{background:"none",border:"none",cursor:"pointer",fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[B[0]," – ",B[B.length-1]]}),e.jsx("button",{type:"button",onClick:()=>H(o=>o+W),style:Y,children:e.jsx(g.HiChevronRight,{size:16})})]})}),L==="years"&&e.jsxs("div",{style:{padding:"8px 10px 10px"},children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3,marginBottom:8},children:Fr.map((o,w)=>{const _=w+1===c;return e.jsx("button",{type:"button",onClick:()=>M(w+1),style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:11,fontWeight:_?700:400,padding:"4px 0",background:_?"var(--primary)":"transparent",color:_?"var(--primary-fg, #ffffff)":"var(--text-secondary)"},children:o},o)})}),e.jsx("div",{style:{height:1,background:"var(--border)",marginBottom:8}}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3},children:B.map(o=>{const w=o===p;return e.jsx("button",{type:"button",onClick:()=>{x(o),Z("days")},style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:12,fontWeight:w?700:400,padding:"6px 0",background:w?"var(--primary)":"transparent",color:w?"var(--primary-fg, #ffffff)":"var(--text-main)",outline:o===new Date().getFullYear()&&!w?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:o},o)})})]}),L==="days"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",padding:"6px 8px 0"},children:Wr.map(o=>e.jsx("div",{style:{textAlign:"center",fontSize:10,fontWeight:700,color:"var(--text-muted)",padding:"2px 0",textTransform:"uppercase"},children:o},o))}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",gridTemplateRows:`repeat(${_e},1fr)`,padding:"4px 8px 10px",gap:2},children:P.map((o,w)=>{if(o===null)return e.jsx("div",{style:{aspectRatio:"1"}},w);const _=Fe(p,c,o),G=_===r,X=_===l,ee=!!(a&&_<a);return e.jsx("button",{type:"button",onClick:()=>!ee&&j(o),style:{width:"100%",aspectRatio:"1",borderRadius:6,border:"none",cursor:ee?"not-allowed":"pointer",fontSize:12,fontWeight:G||X?700:400,background:G?"var(--primary)":"transparent",color:G?"var(--primary-fg, #ffffff)":ee?"var(--text-muted)":"var(--text-main)",opacity:ee?.4:1,outline:X&&!G?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:o},w)})})]})]});return h?e.jsxs("div",{ref:N,className:"relative w-full",children:[e.jsxs("button",{type:"button",onClick:()=>b(o=>!o),className:"flex h-11 w-full items-center justify-between gap-2 rounded-lg px-3 py-0 text-sm transition-all duration-150 focus:outline-none",style:{background:"var(--bg-input)",border:`1px solid ${u?"var(--primary)":"var(--border)"}`,color:"var(--text-main)",boxShadow:u?"0 0 0 3px rgba(59,130,246,0.12)":"none"},children:[e.jsxs("span",{className:"inline-flex items-center gap-2 min-w-0",children:[e.jsx(g.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),e.jsx("span",{className:"truncate",children:Ur(r)})]}),e.jsx(g.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${u?"rotate-180":""}`})]}),u&&e.jsx("div",{className:"absolute z-50",style:{...k.horizontal==="left"?{left:0}:{right:0},...k.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:Q})]}):Q}function sr(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function We({value:r,onChange:t,options:a,placeholder:n="Seleccionar…",emptyLabel:l,disabled:f=!1,className:d="",style:h,height:u=44,padding:b="0 12px",searchable:N=!0,minOptionsForSearch:k=6}){const[y,p]=s.useState(!1),[x,c]=s.useState(""),[M,L]=s.useState(-1),[Z,W]=s.useState(!1),[$,H]=s.useState({}),I=s.useRef(null),B=s.useRef(null),U=s.useRef(null),D=s.useRef(null),C=N&&a.length>=k,F=a.find(o=>o.value===r)??null,V=C&&x.trim()?a.filter(o=>{var w;return o.label.toLowerCase().includes(x.toLowerCase())||((w=o.sublabel)==null?void 0:w.toLowerCase().includes(x.toLowerCase()))}):a,P=s.useCallback(()=>{const o=I.current;if(!o)return;const w=o.getBoundingClientRect(),_=C?272:212,G=window.innerHeight-w.bottom,X=G<_&&w.top>G;H({position:"fixed",left:w.left,top:X?void 0:w.bottom+4,bottom:X?window.innerHeight-w.top+4:void 0,width:w.width,zIndex:9999})},[C]);s.useEffect(()=>W(!0),[]),s.useEffect(()=>{if(!y)return;function o(w){var G,X;const _=w.target;!((G=I.current)!=null&&G.contains(_))&&!((X=B.current)!=null&&X.contains(_))&&(p(!1),c(""))}return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[y]),s.useEffect(()=>{y&&(L(-1),P(),C&&setTimeout(()=>{var o;return(o=U.current)==null?void 0:o.focus()},0))},[y,C,P]),s.useEffect(()=>{if(y)return window.addEventListener("resize",P),window.addEventListener("scroll",P,!0),()=>{window.removeEventListener("resize",P),window.removeEventListener("scroll",P,!0)}},[y,P]),s.useEffect(()=>{if(M<0||!D.current)return;const o=D.current.children[M];o==null||o.scrollIntoView({block:"nearest"})},[M]);const j=s.useCallback(o=>{t(o),p(!1),c("")},[t]);function Y(o){if(!y){(o.key==="Enter"||o.key===" "||o.key==="ArrowDown")&&(o.preventDefault(),p(!0));return}o.key==="Escape"?(o.preventDefault(),p(!1),c("")):o.key==="ArrowDown"?(o.preventDefault(),L(w=>Math.min(w+1,V.length-1))):o.key==="ArrowUp"?(o.preventDefault(),L(w=>Math.max(w-1,l?-1:0))):o.key==="Enter"&&(o.preventDefault(),M===-1&&l?j(""):V[M]&&j(V[M].value))}const Q=e.jsxs("div",{ref:B,className:"rounded-xl shadow-xl overflow-hidden",style:{...$,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[C&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(g.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:U,value:x,onChange:o=>{c(o.target.value),L(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),x&&e.jsx("button",{type:"button",onMouseDown:o=>{o.preventDefault(),c("")},children:e.jsx(g.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),e.jsxs("ul",{ref:D,role:"listbox",className:"overflow-y-auto",style:{maxHeight:C?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[l&&e.jsx("li",{role:"option","aria-selected":r==="",onMouseDown:o=>{o.preventDefault(),j("")},onMouseEnter:()=>L(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:M===-1?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:l}),V.map((o,w)=>{const G=w===M,X=o.value===r;return e.jsxs("li",{role:"option","aria-selected":X,onMouseDown:ee=>{ee.preventDefault(),o.disabled||j(o.value)},onMouseEnter:()=>!o.disabled&&L(w),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:G?"var(--bg-hover)":X?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:o.disabled?"var(--text-muted)":"var(--text-main)",cursor:o.disabled?"not-allowed":"pointer",boxShadow:X?"inset 2px 0 0 var(--primary)":void 0},children:[o.color&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:o.color}}),e.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:o.label}),o.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:o.sublabel})]}),o.badge&&e.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:o.badge})]},o.value)}),V.length===0&&e.jsx("li",{className:"px-3 py-4 text-sm text-center",style:{color:"var(--text-muted)"},children:"Sin resultados"})]})]});return e.jsxs("div",{ref:I,className:`relative ${d||"w-full"}`,style:h,onKeyDown:Y,children:[e.jsxs("button",{type:"button",disabled:f,onClick:()=>!f&&p(o=>!o),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:sr(u),padding:sr(b),background:"var(--bg-input)",color:F?"var(--text-main)":"var(--text-muted)",border:y?"1px solid var(--primary)":"1px solid var(--border)",opacity:f?.5:1,cursor:f?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":y,children:[(F==null?void 0:F.color)&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:F.color}}),e.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:F?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"truncate",children:F.label}),F.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:F.sublabel})]}):e.jsx("span",{className:"truncate",children:n})}),F&&l?e.jsx("span",{role:"button",tabIndex:-1,onMouseDown:o=>{o.preventDefault(),o.stopPropagation(),j("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(g.HiXMark,{className:"w-3 h-3"})}):e.jsx(g.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:y?"rotate(180deg)":"rotate(0deg)"}})]}),y&&Z&&Le.createPortal(Q,document.body)]})}function Ie(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Yr({value:r,onChange:t,placeholder:a="Buscar...",className:n="",height:l=44,padding:f="0 12px 0 34px",iconLeft:d=12}){return e.jsxs("div",{className:`relative ${n}`,children:[e.jsx(g.HiMagnifyingGlass,{className:"absolute top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[var(--text-muted)] pointer-events-none",style:{left:Ie(d)}}),e.jsx("input",{type:"text",value:r,onChange:h=>t(h.target.value),placeholder:a,className:"w-full rounded-lg border border-[var(--border)] [background:var(--bg-card)] text-sm text-[var(--text-main)] placeholder:text-[var(--text-muted)] outline-none transition-[border-color,box-shadow] focus:border-primary focus:ring-2 focus:ring-primary/20",style:{height:Ie(l),padding:Ie(f)}})]})}function Gr({value:r,onChange:t,options:a,placeholder:n,icon:l,className:f="",height:d=44,padding:h,iconLeft:u=12,searchable:b=!0}){const N=l?a.map((k,y)=>y===0&&!k.color?{...k,sublabel:k.sublabel??void 0}:k):a;return e.jsxs("div",{className:`relative ${f}`,children:[l&&e.jsx("span",{className:"pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--text-muted)]",style:{left:Ie(u)},children:l}),e.jsx(We,{value:r,onChange:t,options:N,placeholder:n,searchable:b,minOptionsForSearch:5,height:d,padding:h??(l?"0 12px 0 34px":"0 12px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const Xr={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},Oe=180;function ir({open:r,onClose:t,title:a,subtitle:n,leadingIcon:l,headerActions:f,footer:d,children:h,size:u="md",maxWidth:b,zIndex:N=1e3,closeOnBackdrop:k=!0,closeOnEscape:y=!0,showCloseButton:p=!0,placement:x="center",bodyClassName:c="px-6 py-5",panelClassName:M="",backdropClassName:L="bg-black/50 backdrop-blur-sm",contentClassName:Z="p-4",ariaLabel:W,frameless:$=!1}){const[H,I]=s.useState(!1),[B,U]=s.useState(!1),D=s.useRef(null);if(s.useEffect(()=>(r?(D.current&&clearTimeout(D.current),I(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>U(!0)))):(U(!1),D.current=setTimeout(()=>I(!1),Oe+40)),()=>{D.current&&clearTimeout(D.current)}),[r]),s.useEffect(()=>{if(r)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[r]),s.useEffect(()=>{if(!r||!y)return;const Y=Q=>{Q.key==="Escape"&&t()};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[y,t,r]),!H)return null;const C=a||n||l||f||p,F=b??Xr[u],V=x==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",P=x==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",j=B?"translateY(0) scale(1)":x==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return Le.createPortal(e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":W??a,className:`fixed inset-0 flex ${V} ${Z}`,style:{zIndex:N},children:[e.jsx("div",{className:`absolute inset-0 ${L}`,onClick:k?t:void 0,style:{opacity:B?1:0,transition:`opacity ${Oe}ms ease`}}),e.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${$?"shadow-none":"shadow-2xl"} ${P} ${M}`,style:{maxWidth:F,background:$?"transparent":"var(--bg-card)",border:$?"none":"1px solid var(--border)",opacity:B?1:0,transform:j,transition:`opacity ${Oe}ms ease, transform ${Oe}ms ease`},onClick:Y=>Y.stopPropagation(),children:[C&&e.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between gap-3 px-6 py-4",style:{borderBottom:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[l&&e.jsx("div",{className:"flex-shrink-0",children:l}),(a||n)&&e.jsxs("div",{className:"min-w-0",children:[a&&e.jsx("h2",{className:"truncate text-base font-semibold",style:{color:"var(--text-main)"},children:a}),n&&e.jsx("p",{className:"truncate text-xs",style:{color:"var(--text-muted)"},children:n})]})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[f,p&&e.jsx(fe,{variant:"icon",onClick:t,title:"Cerrar",children:e.jsx(g.HiXMark,{className:"h-5 w-5"})})]})]}),e.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${c}`,children:h}),d&&e.jsx("div",{className:"flex flex-shrink-0 justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:d})]})]}),document.body)}const Jr={danger:{iconBg:"rgba(239,68,68,0.12)",iconColor:"var(--danger)",btnBg:"var(--danger)",btnColor:"#fff"},warning:{iconBg:"rgba(245,158,11,0.12)",iconColor:"var(--warning)",btnBg:"var(--warning)",btnColor:"#fff"},primary:{iconBg:"rgba(59,130,246,0.12)",iconColor:"var(--primary)",btnBg:"var(--primary)",btnColor:"#fff"}};function Vr({open:r,title:t,description:a,confirmLabel:n="Confirmar",cancelLabel:l="Cancelar",variant:f="danger",onConfirm:d,onCancel:h}){const u=Jr[f];return e.jsxs(ir,{open:r,onClose:h,size:"sm",zIndex:9998,showCloseButton:!1,bodyClassName:"p-6",panelClassName:"px-1",ariaLabel:t,children:[e.jsx(fe,{variant:"icon",onClick:h,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:e.jsx(g.HiXMark,{className:"h-4 w-4"})}),e.jsx("div",{className:"mb-4 flex h-11 w-11 items-center justify-center rounded-xl",style:{background:u.iconBg},children:e.jsx(g.HiExclamationTriangle,{className:"h-5 w-5",style:{color:u.iconColor}})}),e.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main)"},children:t}),a&&e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:a}),e.jsxs("div",{className:"mt-6 flex gap-2",children:[e.jsx(fe,{variant:"secondary",onClick:h,className:"flex-1",style:{background:"var(--bg-input)"},children:l}),e.jsx(fe,{variant:"danger",onClick:d,className:"flex-1",style:{background:u.btnBg,color:u.btnColor,borderColor:"transparent"},children:n})]})]})}function Kr(r){var n;const t=Array.from(r.querySelectorAll("*")).filter(l=>{var f;return l.scrollWidth>l.clientWidth&&!!((f=l.textContent)!=null&&f.trim())&&l.tagName.toLowerCase()!=="svg"&&!l.closest("svg")});return(r.scrollWidth>r.clientWidth||t.length>0)&&(((n=t[0])==null?void 0:n.textContent)??r.textContent??"").trim()||null}function je({children:r,content:t,onlyWhenOverflow:a=!1,className:n="",style:l,as:f="div"}){const d=s.useRef(null),h=s.useRef(null),[u,b]=s.useState(null),[N,k]=s.useState("");s.useEffect(()=>{const x=d.current;x&&(x.querySelectorAll("[title]").forEach(c=>{const M=c.getAttribute("title");M&&(c.getAttribute("aria-label")||c.setAttribute("aria-label",M),c.removeAttribute("title"))}),x.querySelectorAll("svg title").forEach(c=>c.remove()))}),s.useLayoutEffect(()=>{if(!u)return;const x=h.current;if(!x)return;const c=12,M=14,L=x.getBoundingClientRect(),Z=window.innerWidth-L.width-c,W=window.innerHeight-L.height-c;let $=u.mouseX+M,H=u.mouseY+M;$>Z&&($=u.mouseX-L.width-M),H>W&&(H=u.mouseY-L.height-M),$=Math.min(Math.max(c,$),Math.max(c,Z)),H=Math.min(Math.max(c,H),Math.max(c,W)),(Math.abs($-u.x)>.5||Math.abs(H-u.y)>.5)&&b(I=>I&&{...I,x:$,y:H})},[u]);const y=(x,c)=>{const M=d.current;if(M){if(a){const L=Kr(M);if(!L)return;k(L)}!a&&!t||b({mouseX:x,mouseY:c,x:x+14,y:c+14})}},p=a?N:t;return e.jsxs(e.Fragment,{children:[e.jsx(f,{ref:x=>{d.current=x},className:n,style:l,onMouseEnter:x=>y(x.clientX,x.clientY),onMouseMove:x=>{u&&y(x.clientX,x.clientY)},onMouseLeave:()=>b(null),children:r}),u&&p?Le.createPortal(e.jsx("div",{ref:h,role:"tooltip",style:{position:"fixed",top:u.y,left:u.x,zIndex:9999,background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:6,padding:"5px 10px",fontSize:12,color:"var(--text-main)",boxShadow:"0 4px 16px rgba(0,0,0,0.35)",pointerEvents:"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere"},children:p}),document.body):null]})}const Zr="[&_button]:h-7 [&_button]:min-h-0 [&_button]:gap-1 [&_button]:px-2 [&_button]:text-xs [&_button_svg]:h-3.5 [&_button_svg]:w-3.5 [&_button[data-icon=true]]:w-7 [&_button[data-icon=true]]:px-0";function $e(r){if(!r)return 150;const t=parseInt(r,10);return isNaN(t)||t<=0?150:t}function Ne(r,t){const a=r.minWidth??80,n=r.maxWidth??1/0;return Math.min(n,Math.max(a,t))}function Qr(r,t){if(t<=7)return Array.from({length:t},(n,l)=>l+1);const a=[1];r>3&&a.push("...");for(let n=Math.max(2,r-1);n<=Math.min(t-1,r+1);n++)a.push(n);return r<t-2&&a.push("..."),a.push(t),a}function lr({children:r,className:t="",style:a}){return e.jsx(je,{onlyWhenOverflow:!0,className:t,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",...a},children:r})}function Rr({columns:r,data:t,getRowId:a,loading:n=!1,skeletonRows:l=8,emptyIcon:f,emptyText:d="Sin resultados",onRowClick:h,selected:u,onToggleOne:b,onToggleAll:N,highlightSelected:k=!0,rowClassName:y,stickyHeader:p=!0,pageSize:x=25,pageSizeOptions:c=[25,50,100],pageSizeSelectWidth:M=62,pageSizeSelectHeight:L=30,pageSizeSelectPadding:Z="0 7px",totalRows:W,page:$,onPageChange:H,onPageSizeChange:I,storageKey:B,stickyFirstColumn:U=!1,bottomOffset:D=0,compact:C=!0,restrictHeight:F=!0,minTableWidth:V}){const P=r.map(i=>i.key).join(","),[j,Y]=s.useState(!B),Q=s.useRef(null),o=s.useRef(!B),w=(i,v)=>50+(i*17+v*13+7)%40,_=s.useRef(null),[G,X]=s.useState(void 0),[ee,ue]=s.useState(!1);s.useEffect(()=>{const v=x!==!1?32:0,E=12;function A(){if(ue(window.innerWidth<640),!_.current)return;const q=_.current.getBoundingClientRect().top;X(Math.max(120,window.innerHeight-q-v-E-D))}return A(),window.addEventListener("resize",A),()=>window.removeEventListener("resize",A)},[n,x,D]);const[re,be]=s.useState(()=>r.map(i=>i.key)),[pe,ve]=s.useState(()=>Object.fromEntries(r.map(i=>[i.key,Ne(i,$e(i.width))])));s.useEffect(()=>{const i=r.map(E=>E.key);if(!B){be(i),o.current=!1,Y(!0);return}let v=!1;return o.current=!1,Y(!1),fetch(`/api/user/preferences/datatables?key=${encodeURIComponent(B)}`,{cache:"no-store"}).then(E=>E.ok?E.json():null).then(E=>{var Sr,Cr;if(v)return;const A=(Sr=E==null?void 0:E.settings)==null?void 0:Sr.columnOrder,q=Array.isArray(A)?A.filter(he=>i.includes(he)):[],ie=i.filter(he=>!q.includes(he)),R=q.length>0?[...q,...ie]:i,Me=Object.fromEntries(r.map(he=>[he.key,Ne(he,$e(he.width))])),te=((Cr=E==null?void 0:E.settings)==null?void 0:Cr.columnWidths)??{},kr=Object.fromEntries(r.map(he=>[he.key,Ne(he,te[he.key]??Me[he.key])]));be(R),ve(kr),Q.current=JSON.stringify({columnOrder:R,columnWidths:kr}),o.current=!0}).catch(()=>{if(!v){be(i);const E=Object.fromEntries(r.map(A=>[A.key,Ne(A,$e(A.width))]));ve(E),Q.current=JSON.stringify({columnOrder:i,columnWidths:E}),o.current=!0}}).finally(()=>{v||Y(!0)}),()=>{v=!0}},[B,P,r]),s.useEffect(()=>{if(!B||!j||!o.current)return;const i={columnOrder:re,columnWidths:pe},v=JSON.stringify(i);if(v===Q.current)return;const E=window.setTimeout(()=>{fetch("/api/user/preferences/datatables",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:B,settings:i})}).then(A=>{A.ok&&(Q.current=v)}).catch(()=>{})},300);return()=>window.clearTimeout(E)},[re,pe,B,j]),s.useEffect(()=>{be(i=>{const v=r.map(q=>q.key),E=i.filter(q=>v.includes(q)),A=v.filter(q=>!E.includes(q));return[...E,...A]})},[P,r]);const ce=re.map(i=>r.find(v=>v.key===i)).filter(i=>!!i);s.useEffect(()=>{ve(i=>{const v=Object.fromEntries(r.map(E=>[E.key,Ne(E,$e(E.width))]));return Object.fromEntries(r.map(E=>[E.key,Ne(E,i[E.key]??v[E.key])]))})},[P,r]);const S=s.useRef(null);s.useEffect(()=>{function i(E){const A=S.current;if(!A)return;const q=E.clientX-A.startX,ie=r.find(R=>R.key===A.colKey);ie&&ve(R=>({...R,[A.colKey]:Ne(ie,A.startWidth+q)}))}function v(){S.current&&(S.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",i),document.addEventListener("pointerup",v),()=>{document.removeEventListener("pointermove",i),document.removeEventListener("pointerup",v)}},[r]);const z=s.useRef(null),[J,ae]=s.useState(null);function le(i,v){z.current=i,v.dataTransfer.effectAllowed="move"}function O(i,v){v.preventDefault(),v.dataTransfer.dropEffect="move",J!==i&&ae(i)}function we(i,v){v.preventDefault();const E=z.current;E!==null&&E!==i&&be(A=>{const q=[...A],[ie]=q.splice(E,1);return q.splice(i,0,ie),q}),z.current=null,ae(null)}function Ae(){z.current=null,ae(null)}const[me,De]=s.useState(null);function ze(i){i.sortKey&&De(v=>(v==null?void 0:v.key)===i.key?{key:i.key,dir:v.dir==="asc"?"desc":"asc"}:{key:i.key,dir:"asc"})}const[ne,Ce]=s.useState(1),[Be,Pe]=s.useState(x===!1?0:x);s.useEffect(()=>{Ce(1)},[t]);const ge=!!(H&&I),xe=x!==!1,de=ge?$??1:ne,m=ge||xe?Be:t.length,K=!!u&&!!b&&!!N,oe=K?40:0,ke=K&&t.length>0&&u.size===t.length,se=K&&u.size>0&&u.size<t.length,Se=s.useMemo(()=>{if(!me)return t;const i=r.find(v=>v.key===me.key&&v.sortKey);return i!=null&&i.sortKey?[...t].sort((v,E)=>{const A=v[i.sortKey],q=E[i.sortKey],ie=A===q?0:A==null?1:q==null||A<q?-1:1;return me.dir==="asc"?ie:-ie}):t},[t,me,r]),Ee=s.useMemo(()=>{if(ge||!xe)return Se;const i=(de-1)*m;return Se.slice(i,i+m)},[Se,ge,xe,de,m]),He=W??t.length,Ge=xe?Math.max(1,Math.ceil(He/m)):1,Lt=xe?(de-1)*m+1:1,It=xe?Math.min(de*m,He):He;function Xe(i){const v=Math.max(1,Math.min(i,Ge));ge?H(v):Ce(v)}function Ot(i){Pe(i),ge?(I(i),H(1)):Ce(1),I&&I(i)}const yr=i=>i==="center"?"text-center":i==="right"?"text-right":"text-left",At="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",wr=()=>e.jsxs("tr",{style:{background:"color-mix(in srgb, var(--bg-input) 72%, transparent)"},children:[K&&e.jsx("th",{className:`${C?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:U?{position:"sticky",left:0,zIndex:12,background:"color-mix(in srgb, var(--bg-input) 72%, transparent)",backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:"inset 0 -2px 0 var(--border)",borderRight:"1px solid var(--border)"}:{borderBottom:"2px solid var(--border)",borderRight:"1px solid var(--border)"},children:e.jsx("input",{type:"checkbox",checked:ke,ref:i=>{i&&(i.indeterminate=se)},onChange:N,className:"rounded cursor-pointer accent-[var(--primary)]"})}),ce.map((i,v)=>{const E=(me==null?void 0:me.key)===i.key,A=!!i.sortKey,q=U&&!ee&&v===0,ie=J===v,Me=(pe[i.key]??$e(i.width))<120;return e.jsxs("th",{className:`group select-none ${Me?"text-left":yr(i.align)}`,style:{...q?{position:"sticky",left:oe,zIndex:12,background:"color-mix(in srgb, var(--bg-input) 72%, transparent)",backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:"3px 0 6px -2px rgba(0,0,0,0.12), inset 0 -2px 0 var(--border)",borderRight:"1px solid var(--border)"}:{position:"relative",borderBottom:"2px solid var(--border)",borderRight:"1px solid var(--border)"},color:E?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:ie?"2px solid var(--primary)":"2px solid transparent",cursor:A?"pointer":"default",padding:C?"5px 24px 5px 6px":"7px 28px 7px 6px"},onDragOver:te=>O(v,te),onDrop:te=>we(v,te),onClick:A?()=>ze(i):void 0,children:[e.jsx("span",{draggable:!0,onDragStart:te=>{te.stopPropagation(),le(v,te)},onDragEnd:te=>{te.stopPropagation(),Ae()},onClick:te=>te.stopPropagation(),title:"Arrastrar para reordenar",className:"inline-flex items-center mr-1 opacity-0 group-hover:opacity-40 transition-opacity",style:{cursor:"grab",color:"var(--text-muted)",verticalAlign:"middle"},children:e.jsx(Er.MdDragIndicator,{size:15})}),e.jsx(lr,{className:"inline-block max-w-full align-middle",style:{width:"calc(100% - 22px)",textAlign:Me?"left":i.align==="center"?"center":i.align==="right"?"right":"left"},children:e.jsxs("span",{className:`inline-flex max-w-full items-center gap-1 font-semibold uppercase tracking-wider ${C?"text-[11px]":"text-xs"}`,children:[e.jsx("span",{className:"min-w-0 truncate",children:i.header}),A&&e.jsx("span",{className:"flex-shrink-0 opacity-60",children:E?me.dir==="asc"?e.jsx(g.HiChevronUp,{className:"w-3 h-3"}):e.jsx(g.HiChevronDown,{className:"w-3 h-3"}):e.jsx(g.HiChevronUpDown,{className:"w-3 h-3 opacity-40"})})]})}),e.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar",onPointerDown:te=>{te.preventDefault(),te.stopPropagation(),S.current={colKey:i.key,startX:te.clientX,startWidth:pe[i.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onClick:te=>te.stopPropagation(),className:"absolute right-0 top-0 h-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",style:{width:12,cursor:"col-resize",zIndex:3},children:e.jsx("span",{style:{width:3,height:"40%",borderRadius:2,background:"var(--primary)",display:"block"}})})]},i.key)})]}),Nr=()=>{if(!xe||n)return null;const i=Qr(de,Ge);return e.jsxs("div",{className:`flex items-center justify-between gap-2 rounded-b-xl border-t text-xs select-none ${C?"px-2 py-0.5":"px-3 py-1"}`,style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:He===0?"0 filas":`${Lt}–${It} de ${He}`}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),e.jsx(We,{value:String(m),onChange:v=>Ot(Number(v)),options:c.map(v=>({value:String(v),label:String(v)})),placeholder:"Filas",searchable:!1,height:L,padding:Z,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:M}})]})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("button",{disabled:de<=1,onClick:()=>Xe(de-1),className:"rounded p-0.5 transition-colors disabled:opacity-30",style:{color:"var(--text-muted)",background:"transparent"},children:e.jsx(g.HiChevronLeft,{className:"h-3.5 w-3.5"})}),i.map((v,E)=>v==="..."?e.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${E}`):e.jsx("button",{onClick:()=>Xe(v),className:"h-5 w-5 rounded text-[11px] font-medium transition-colors",style:{background:v===de?"var(--primary)":"transparent",color:v===de?"var(--primary-fg)":"var(--text-muted)"},children:v},v)),e.jsx("button",{disabled:de>=Ge,onClick:()=>Xe(de+1),className:"rounded p-0.5 transition-colors disabled:opacity-30",style:{color:"var(--text-muted)",background:"transparent"},children:e.jsx(g.HiChevronRight,{className:"h-3.5 w-3.5"})})]})]})};return n&&t.length===0?e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-xl overflow-visible",style:{border:"1px solid var(--border)"},children:[e.jsx("div",{ref:_,className:"min-w-0 max-w-full overflow-hidden rounded-t-xl",children:e.jsx(Ve.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:F?G:void 0,maxWidth:"100%"},defer:!0,children:e.jsxs("table",{className:"text-sm",style:{tableLayout:"fixed",width:"100%",minWidth:V??"max-content",borderCollapse:"separate",borderSpacing:0},children:[e.jsxs("colgroup",{children:[K&&e.jsx("col",{style:{width:40}}),ce.map(i=>e.jsx("col",{style:{width:pe[i.key]??150}},i.key))]}),e.jsx("thead",{style:p?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:wr()}),e.jsx("tbody",{children:Array.from({length:l}).map((i,v)=>e.jsxs("tr",{children:[K&&e.jsx("td",{className:`${C?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:"1px solid var(--border)",borderRight:"1px solid var(--border)"}}),ce.map((E,A)=>{const q=U&&!ee&&A===0;return e.jsx("td",{className:C?"px-2 py-1.5":"px-3 py-2",style:q?{position:"sticky",left:oe,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:"3px 0 6px -2px rgba(0,0,0,0.12), inset 0 -1px 0 var(--border)",borderRight:"1px solid var(--border)"}:{borderBottom:"1px solid var(--border)",borderRight:"1px solid var(--border)"},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${w(v,A)}%`,minWidth:32}})},E.key)})]},v))})]})})}),Nr()]}):!n&&t.length===0?e.jsxs("div",{className:"py-20 flex flex-col items-center gap-3",children:[f&&e.jsx("div",{style:{color:"var(--text-muted)",opacity:.5},children:f}),e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:d})]}):e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-xl overflow-visible",style:{border:"1px solid var(--border)"},children:[e.jsx("div",{ref:_,className:"min-w-0 max-w-full overflow-hidden rounded-t-xl",children:e.jsx(Ve.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:F?G:void 0,maxWidth:"100%"},defer:!0,children:e.jsxs("table",{className:"text-sm",style:{tableLayout:"fixed",width:"100%",minWidth:V??"max-content",borderCollapse:"separate",borderSpacing:0},children:[e.jsxs("colgroup",{children:[K&&e.jsx("col",{style:{width:40}}),ce.map(i=>e.jsx("col",{style:{width:pe[i.key]??150}},i.key))]}),e.jsx("thead",{style:p?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:wr()}),e.jsx("tbody",{children:Ee.map((i,v)=>{const E=a(i),A=K&&u.has(E),q=!!h,ie=A&&k?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":v%2===1?"color-mix(in srgb, var(--bg-input) 50%, var(--bg-card))":"var(--bg-card)";return e.jsxs("tr",{onClick:q?()=>h(i):void 0,className:`transition-colors ${q?"cursor-pointer":""} ${y?y(i):""}`,style:{"--dt-row-bg":ie,"--dt-sticky-bg":ie,background:"var(--dt-row-bg)"},onMouseEnter:R=>{A||(R.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),R.currentTarget.style.setProperty("--dt-sticky-bg",At))},onMouseLeave:R=>{R.currentTarget.style.setProperty("--dt-row-bg",ie),R.currentTarget.style.setProperty("--dt-sticky-bg",ie)},children:[K&&e.jsx("td",{className:`${C?"px-2 py-1.5":"px-3 py-2"} w-10`,style:U?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:"inset 0 -1px 0 var(--border)"}:{borderBottom:"1px solid var(--border)",borderRight:"1px solid var(--border)"},onClick:R=>{R.stopPropagation(),b(E)},children:e.jsx("input",{type:"checkbox",checked:A,onClick:R=>R.stopPropagation(),onChange:()=>b(E),className:"rounded cursor-pointer accent-[var(--primary)]"})}),ce.map((R,Me)=>{const te=U&&!ee&&Me===0;return e.jsx("td",{className:`${C?"px-2 py-1.5":"px-3 py-2"} ${Zr} ${yr(R.align)} ${R.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...te?{position:"sticky",left:oe,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:"3px 0 6px -2px rgba(0,0,0,0.12), inset 0 -1px 0 var(--border)",borderRight:"1px solid var(--border)"}:{borderBottom:"1px solid var(--border)",borderRight:"1px solid var(--border)"}},children:e.jsx(lr,{children:R.cell(i)})},R.key)})]},E)})})]})})}),Nr()]})}function Te(r){return r?new Date(`${r}T12:00:00`):void 0}function cr(r){return r.toISOString().slice(0,10)}function et({calendarMonth:r,displayIndex:t}){const{previousMonth:a,nextMonth:n,goToMonth:l,months:f,labels:d,formatters:h}=Ke.useDayPicker(),u=!!a&&t===0,b=!!n&&t===f.length-1;return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,width:"100%",color:"var(--text-main)",marginBottom:6},children:[e.jsx("span",{style:{fontWeight:700},children:h.formatCaption(r.date)}),e.jsx("button",{type:"button","aria-label":d.labelPrevious(a),onClick:()=>a&&l(a),disabled:!u,style:{height:28,width:28,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg-card)",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--text-main)",opacity:u?1:.45,cursor:u?"pointer":"not-allowed"},children:e.jsx(g.HiChevronLeft,{size:16})}),e.jsx("button",{type:"button","aria-label":d.labelNext(n),onClick:()=>n&&l(n),disabled:!b,style:{height:28,width:28,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg-card)",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--text-main)",opacity:b?1:.45,cursor:b?"pointer":"not-allowed"},children:e.jsx(g.HiChevronRight,{size:16})})]})}function rt(r){return r.charAt(0).toUpperCase()+r.slice(1)}function tt({startDate:r,endDate:t,onChange:a,minDate:n,viewMonth:l,numberOfMonths:f=1,showSummary:d=!0,startLabel:h="Inicio",endLabel:u="Regreso"}){const b={from:Te(r),to:Te(t)},N=Te(n),[k,y]=s.useState(Te(l||r));return s.useEffect(()=>{y(Te(l||r))},[l,r]),e.jsxs("div",{children:[e.jsx("div",{style:{borderRadius:10,overflow:"hidden",border:"1px solid var(--border)",background:"var(--bg-input)",display:"flex",justifyContent:"center",padding:"10px 8px"},children:e.jsx(Ke.DayPicker,{mode:"range",selected:b,month:k,onMonthChange:y,onSelect:p=>{const x=p!=null&&p.from?cr(p.from):r,c=p!=null&&p.to?cr(p.to):"";a({startDate:x,endDate:c})},numberOfMonths:f,hideNavigation:!0,disabled:N?{before:N}:void 0,showOutsideDays:!1,components:{MonthCaption:et},className:"text-sm",classNames:{root:"w-full",months:"flex gap-3 justify-center",month:"space-y-2",month_caption:"flex items-center justify-between px-1",caption_label:"capitalize",nav:"flex items-center gap-1",button_previous:"h-8 w-8 inline-flex items-center justify-center rounded-md transition-colors",button_next:"h-8 w-8 inline-flex items-center justify-center rounded-md transition-colors",month_grid:"w-full border-collapse",weekdays:"grid grid-cols-7 gap-1 mb-1",weekday:"text-[11px] font-semibold text-center",week:"grid grid-cols-7 gap-1",day:"h-9 w-9 p-0 flex items-center justify-center",day_button:"h-9 w-9 rounded-md text-sm font-medium transition-colors outline-none",selected:"font-semibold",range_start:"font-semibold",range_middle:"font-medium",range_end:"font-semibold",today:"font-bold",disabled:"opacity-40 cursor-not-allowed",hidden:"invisible"},styles:{month_caption:{color:"var(--text-main)",marginBottom:6,display:"flex",alignItems:"center",justifyContent:"space-between"},caption_label:{color:"var(--text-main)",fontWeight:700},nav:{position:"static",display:"flex",alignItems:"center",gap:6},weekday:{color:"var(--text-muted)",textTransform:"lowercase"},button_previous:{height:32,width:32,background:"var(--bg-card)",color:"var(--text-main)",border:"1px solid var(--border)"},button_next:{height:32,width:32,background:"var(--bg-card)",color:"var(--text-main)",border:"1px solid var(--border)"},day_button:{color:"var(--text-main)",borderRadius:8},chevron:{fill:"var(--text-main)"},today:{border:"1px solid color-mix(in srgb, var(--primary) 35%, transparent)"},disabled:{color:"var(--text-muted)"}},modifiersStyles:{selected:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_start:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_end:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_middle:{background:"color-mix(in srgb, var(--primary) 20%, transparent)",color:"var(--text-main)"}},formatters:{formatCaption:p=>rt(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(p)),formatWeekdayName:p=>new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(p)},labels:{labelMonthDropdown:()=>"Mes",labelYearDropdown:()=>"Año"}})}),d&&r&&e.jsxs("div",{style:{marginTop:8,fontSize:12,color:"var(--text-muted)",display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsxs("span",{children:[h,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:r})]}),t&&e.jsxs("span",{children:[u,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:t})]})]})]})}function at({open:r,onClose:t,title:a,subtitle:n,leadingIcon:l,confirmLabel:f="Guardar",onConfirm:d,loading:h=!1,confirmDisabled:u=!1,headerActions:b,bodyClassName:N="flex-1 overflow-y-auto px-6 py-5",width:k=440,children:y}){const[p,x]=s.useState(!1);return s.useEffect(()=>{x(!0)},[]),s.useEffect(()=>(document.body.style.overflow=r?"hidden":"",()=>{document.body.style.overflow=""}),[r]),s.useEffect(()=>{if(!r)return;const c=M=>{M.key==="Escape"&&t()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[r,t]),p?Le.createPortal(e.jsxs("div",{"aria-hidden":!r,className:`fixed inset-0 z-[1000] flex transition-opacity duration-300 ${r?"opacity-100":"opacity-0 pointer-events-none"}`,children:[e.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm",onClick:t}),e.jsxs("div",{className:`absolute inset-y-0 right-0 flex flex-col shadow-2xl transition-transform duration-300 ${r?"translate-x-0":"translate-x-full"}`,style:{width:`min(100vw, ${k}px)`,background:"var(--bg-card)",borderLeft:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 flex-shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(fe,{variant:"icon",onClick:t,title:"Cerrar",children:e.jsx(g.HiXMark,{className:"w-5 h-5"})}),l&&e.jsx("div",{className:"flex-shrink-0",children:l}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-base font-semibold truncate",style:{color:"var(--text-main)"},children:a}),n&&e.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:n})]})]}),(b||d)&&e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[b,d&&e.jsxs(e.Fragment,{children:[e.jsx(fe,{variant:"secondary",size:"sm",onClick:t,style:{background:"var(--bg-input)"},children:"Cancelar"}),e.jsx(fe,{variant:"primary",size:"sm",icon:e.jsx(Mr.FiSave,{className:"w-4 h-4"}),onClick:d,loading:h,disabled:u,title:f})]})]})]}),e.jsx("div",{"data-drawer-scroll":"true",className:N,children:y})]})]}),document.body):null}function Ue({className:r="",...t}){return e.jsx("input",{...t,className:`h-11 rounded-lg border border-[var(--border)] bg-[var(--bg-input)] px-3 py-2 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] ${r}`})}function nt({label:r,containerClassName:t="",helperText:a,error:n,labelAction:l,floatingLabel:f=!1,showPasswordToggle:d=!0,className:h="",required:u,...b}){const[N,k]=s.useState(()=>!!b.autoFocus),[y,p]=s.useState(!1),x=b.type==="password"&&d,c=x&&y?"text":b.type,M=b.value!==void 0?String(b.value).length>0:b.defaultValue!==void 0&&String(b.defaultValue).length>0,L=N||M,Z={top:L?8:15,color:N?"var(--primary)":"var(--text-muted)",fontSize:L?11:14,fontWeight:L?600:400,textTransform:L?"uppercase":"none"},W=H=>{var I;k(!0),(I=b.onFocus)==null||I.call(b,H)},$=H=>{var I;k(!1),(I=b.onBlur)==null||I.call(b,H)};return f?e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"relative block",children:[e.jsx(Ue,{...b,type:c,required:u,placeholder:" ","aria-invalid":!!n||b["aria-invalid"],"data-has-value":M?"true":void 0,className:`h-12 w-full pt-5 ${x?"pr-10":""} ${h}`,onFocus:W,onBlur:$}),e.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:Z,children:[r,u&&e.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),l&&e.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:L?8:15},children:l}),x&&e.jsx("button",{type:"button","aria-label":y?"Ocultar contraseña":"Mostrar contraseña",className:"absolute right-3 top-1/2 -translate-y-1/2 transition-colors",style:{color:"var(--text-muted)"},tabIndex:-1,onClick:()=>p(H=>!H),children:y?e.jsx(g.HiEyeSlash,{className:"h-[18px] w-[18px]"}):e.jsx(g.HiEye,{className:"h-[18px] w-[18px]"})})]}),n?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]}):e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e.jsx("span",{children:r}),u&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),l&&e.jsx("span",{className:"ml-auto normal-case",children:l})]}),e.jsx(Ue,{...b,required:u,"aria-invalid":!!n||b["aria-invalid"],className:h}),n?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]})}function ye(...r){return r.filter(Boolean).join(" ")}function ot({steps:r,activeStepId:t,initialStepId:a,completedStepIds:n,defaultCompletedStepIds:l=[],onActiveStepChange:f,onCompletedStepIdsChange:d,onBlockedStep:h,allowBackNavigation:u=!0,showFooter:b=!0,previousLabel:N="Anterior",nextLabel:k="Siguiente",blockedNextLabel:y="Completa este paso",className:p="",headerClassName:x="",contentClassName:c="",footerClassName:M=""}){var ce;const L=((ce=r[0])==null?void 0:ce.id)??"",[Z,W]=s.useState(a??L),[$,H]=s.useState(l),I=t??Z,B=n??$,U=s.useMemo(()=>new Set(B),[B]),D=Math.max(0,r.findIndex(S=>S.id===I)),C=r[D]??r[0],F=r.length<=1?100:D/(r.length-1)*100,V=S=>{n||H(S),d==null||d(S)},P=S=>{const z=r.find(J=>J.id===S);z&&(t||W(S),f==null||f(S,z))},j=S=>U.has(S),Y=S=>r.slice(0,S).find(z=>!z.optional&&!U.has(z.id)),Q=S=>{const z=r[S];return!z||z.disabled?!1:S===D||u&&S<D?!0:!Y(S)},o=S=>{const z=r.findIndex(J=>J.id===S);return z>=0&&Q(z)},w=S=>{const z=r.findIndex(J=>J.id===S);if(z<0)return!1;if(!Q(z)){const J=Y(z);return J&&(h==null||h(r[z],J)),!1}return P(S),!0},_=(S=C==null?void 0:C.id)=>{!S||U.has(S)||V([...B,S])},G=(S=C==null?void 0:C.id)=>{if(!S)return;const z=r.findIndex(ae=>ae.id===S),J=B.filter(ae=>{const le=r.findIndex(O=>O.id===ae);return le>=0&&le<z});V(J),z>=0&&D>z&&P(S)},X=()=>D<=0?!1:w(r[D-1].id),ee=()=>{const S=r[D+1];return S?w(S.id):!1},ue={activeStep:C,activeIndex:D,completedStepIds:B,isCompleted:j,isUnlocked:o,completeStep:_,uncompleteStep:G,goToStep:w,goNext:ee,goPrevious:X};if(!C)return null;const re=r[D+1],be=D>0,pe=re?o(re.id):!1,ve=typeof C.content=="function"?C.content(ue):C.content;return e.jsxs("section",{className:ye("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",p),children:[e.jsxs("div",{className:ye("border-b border-[var(--border)] bg-[var(--bg-input)]",x),children:[e.jsx("div",{className:"relative h-1 overflow-hidden bg-[var(--border)]/55",children:e.jsx("div",{className:"h-full rounded-r-full bg-[var(--primary)] transition-[width] duration-500 ease-out",style:{width:`${F}%`}})}),e.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${r.length}, minmax(0, 1fr))`},children:r.map((S,z)=>{const J=S.id===C.id,ae=j(S.id),le=Q(z),O=Y(z);return e.jsxs("button",{type:"button",disabled:!le,"aria-current":J?"step":void 0,"aria-disabled":!le,title:!le&&O?`Completa ${O.title}`:S.title,onClick:()=>w(S.id),className:ye("group relative min-h-16 min-w-0 overflow-hidden rounded-md border p-3 text-left transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/35 disabled:cursor-not-allowed",J&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",ae&&!J&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!J&&!ae&&le&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!le&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[e.jsx("span",{className:ye("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",J&&"scale-x-100")}),e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:ye("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",J&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",ae&&!J&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!ae&&!J&&le&&"border-[var(--border)] text-[var(--text-muted)]",!le&&"border-[var(--border)] text-[var(--text-muted)]"),children:ae?e.jsx(g.HiCheck,{className:"h-4 w-4"}):le?z+1:e.jsx(g.HiLockClosed,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:ye("block truncate text-xs font-semibold transition-colors duration-200",J?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[z+1,". ",S.title]}),S.description&&e.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:S.description})]}),S.badge&&e.jsx("span",{className:"shrink-0",children:S.badge})]})]},S.id)})})]}),e.jsx("div",{className:ye("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",c),children:ve},C.id),b&&e.jsxs("div",{className:ye("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",M),children:[e.jsx(fe,{variant:"secondary",height:38,padding:"0 14px",icon:e.jsx(g.HiChevronLeft,{}),disabled:!be,onClick:X,children:N}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[e.jsxs("span",{children:["Paso ",D+1," de ",r.length]}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),e.jsxs("span",{children:[B.length," completados"]})]}),e.jsx(fe,{height:38,padding:"0 14px",icon:e.jsx(g.HiChevronRight,{}),disabled:!re||!pe,onClick:ee,children:re&&!pe?y:k})]})]})}const st={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function it({checked:r,disabled:t,onCheckedChange:a,size:n="sm",className:l="",...f}){const d=st[n],h=r?d.width-d.thumb-d.padding*2:0;return e.jsx("button",{...f,type:"button",role:"switch","aria-checked":r,disabled:t,onClick:()=>!t&&a(!r),className:`relative inline-flex shrink-0 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/50 disabled:cursor-not-allowed disabled:opacity-50 ${l}`,style:{width:d.width,height:d.height,background:r?"color-mix(in srgb, var(--primary) 85%, transparent)":"var(--bg-input)",border:r?"1px solid color-mix(in srgb, var(--primary) 55%, transparent)":"1px solid var(--border)"},children:e.jsx("span",{className:"absolute inline-block rounded-full transition-transform",style:{width:d.thumb,height:d.thumb,left:d.padding,top:"50%",transform:`translate(${h}px, -50%)`,background:r?"var(--primary-fg)":"var(--text-muted)"}})})}const dr=[".sidebar-scroll","[data-overlay-scroll='true']"].join(",");function lt(r){if(!(r instanceof HTMLElement)||r.dataset.overlayScroll==="false"||r.closest("[data-overlayscrollbars]")||r.matches("textarea,input,select,[contenteditable='true']"))return!1;const t=window.getComputedStyle(r);return!(![t.overflow,t.overflowX,t.overflowY].join(" ").match(/auto|scroll/)||r.clientWidth===0&&r.clientHeight===0)}function fr(r){return r.classList.contains("sidebar-scroll")}function ur(r){fr(r)&&r.querySelectorAll(".os-scrollbar-horizontal").forEach(t=>{t.style.display="none",t.style.height="0",t.style.pointerEvents="none"})}function pr(){return s.useEffect(()=>{const r=new WeakMap;let t=0;const a=()=>{t=0,document.querySelectorAll(dr).forEach(f=>{if(!lt(f))return;if(Je.OverlayScrollbars(f)){ur(f);return}const h=Je.OverlayScrollbars(f,{overflow:fr(f)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}});ur(f),r.set(f,h)})},n=()=>{t||(t=window.requestAnimationFrame(a))};a();const l=new MutationObserver(n);return l.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","data-overlay-scroll"]}),window.addEventListener("resize",n),()=>{t&&window.cancelAnimationFrame(t),l.disconnect(),window.removeEventListener("resize",n),document.querySelectorAll(dr).forEach(f=>{var d;f instanceof HTMLElement&&((d=r.get(f))==null||d.destroy())})}},[]),null}const ct={xs:{wh:"w-5 h-5",text:"text-[8px]"},sm:{wh:"w-7 h-7",text:"text-[11px]"},md:{wh:"w-9 h-9",text:"text-sm"},lg:{wh:"w-12 h-12",text:"text-base"},xl:{wh:"w-16 h-16",text:"text-xl"}},hr=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],dt={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},ft="bonsaif.bot",ut="Bonsaif Bot",pt={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function br(r){return typeof r=="string"?r.trim():""}function ht(r){let t=0;for(const a of r)t=t*31+a.charCodeAt(0)&65535;return hr[t%hr.length]}function bt(r,t){return r===ft||t===ut}function mr({userId:r,username:t,name:a,size:n="md",showName:l=!1,showTooltip:f,tooltipContent:d,fallbackLabel:h="Usuario",wrapperClassName:u="",labelClassName:b="",labelSize:N="xs",avatarVersion:k=0,className:y="",style:p}){var P;const[x,c]=s.useState(!1),M=typeof r=="string"&&r.trim()&&r!=="undefined"&&r!=="null"?r.trim():"";s.useEffect(()=>{c(!1)},[M,k]);const{wh:L,text:Z}=ct[n],W=br(a)||br(t)||h,$=W.trim()[0]||"?",H=typeof process<"u"&&((P=process.env)==null?void 0:P.NEXT_PUBLIC_BASE_PATH)||"",I=bt(t,a),B=M?`${H}/api/user/avatar/${M}${k?`?v=${k}`:""}`:"",D={xs:20,sm:28,md:36,lg:48,xl:64}[n],C=I?e.jsx("span",{className:`${L} ${pt[n]} rounded-full flex items-center justify-center bg-[#071f1a] ring-1 ring-emerald-400/35 shadow-[0_0_0_1px_rgba(255,255,255,0.06)] flex-shrink-0 ${y}`,style:p,children:e.jsx("img",{src:`${H}/favicon.svg`,alt:W,width:D,height:D,className:"h-full w-full object-contain"})}):B&&!x?e.jsx("img",{src:B,alt:W,width:D,height:D,className:`${L} rounded-full object-cover flex-shrink-0 ${y}`,style:p,onError:()=>c(!0)},`${M}-${k}`):e.jsx("span",{className:`${L} ${ht(W)} ${Z} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${y}`,style:p,title:W,children:$});if(l)return e.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${u}`,children:[C,e.jsx("span",{className:`min-w-0 truncate ${dt[N]} font-medium text-[var(--text-main)] ${b}`,title:W,children:W})]});const F=f??!0,V=d??W;return F&&V?e.jsx(je,{as:"span",content:V,className:`inline-flex flex-shrink-0 ${u}`,children:C}):C}function mt({href:r,className:t,children:a}){return e.jsx("a",{href:r,className:t,children:a})}function vt(r){return r.reduce((t,a)=>{const n=a.section??"Principal";return t[n]=[...t[n]??[],a],t},{})}function vr({children:r,navItems:t=[],currentPath:a=typeof window>"u"?"/":window.location.pathname,user:n,appName:l="Bonsaif",appLogo:f,header:d,footer:h,onLogout:u,LinkComponent:b=mt}){const[N,k]=s.useState(!1),y=vt(t);return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[e.jsx(pr,{}),e.jsx("button",{type:"button","aria-label":"Abrir navegación",className:"fixed left-3 top-3 z-50 inline-flex h-9 w-9 items-center justify-center rounded-md border border-white/10 bg-black/70 text-white lg:hidden",onClick:()=>k(!0),children:e.jsx(g.HiBars3,{className:"h-5 w-5"})}),N&&e.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>k(!1)}),e.jsxs("aside",{className:`fixed inset-y-0 left-0 z-50 flex w-72 flex-col bg-[#071716] text-white shadow-2xl transition-transform duration-200 lg:translate-x-0 ${N?"translate-x-0":"-translate-x-full"}`,children:[e.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:f??e.jsx(g.HiHome,{className:"h-5 w-5"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:l}),e.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-white/70 hover:bg-white/10 lg:hidden",onClick:()=>k(!1),children:e.jsx(g.HiXMark,{className:"h-5 w-5"})})]}),e.jsx("nav",{className:"sidebar-scroll min-h-0 flex-1 overflow-y-auto px-3 py-4","data-overlay-scroll":"true",children:Object.entries(y).map(([p,x])=>e.jsxs("div",{className:"mb-5",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-white/35",children:[e.jsx(g.HiChevronDown,{className:"h-3.5 w-3.5"}),p]}),e.jsx("div",{className:"space-y-1",children:x.map(c=>{const M=a===c.href||a.startsWith(`${c.href}/`);return e.jsxs(b,{href:c.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${M?"bg-white/10 text-white":"text-white/55 hover:bg-white/[0.06] hover:text-white/85"}`,children:[e.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:c.icon??e.jsx(g.HiHome,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate",children:c.label})]},c.href)})})]},p))}),e.jsxs("div",{className:"border-t border-white/10 p-3",children:[n&&e.jsxs("div",{className:"mb-3 flex min-w-0 items-center gap-3 rounded-lg bg-white/[0.04] p-2",children:[e.jsx(mr,{name:n.initials??n.name??n.email??"Usuario",size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-medium text-white",children:n.name??"Usuario"}),n.email&&e.jsx("div",{className:"truncate text-xs text-white/45",children:n.email})]})]}),u&&e.jsxs(fe,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:u,children:[e.jsx(g.HiArrowRightOnRectangle,{className:"h-4 w-4"})," Salir"]}),h]})]}),e.jsxs("div",{className:"min-h-screen lg:pl-72",children:[d,e.jsx("main",{className:"min-h-screen",children:r})]})]})}const gt={dashboard:"Dashboard",tickets:"Tickets",teams:"Equipos",projects:"Proyectos",clients:"Clientes",surveys:"Encuestas",profile:"Perfil",settings:"Configuración",notifications:"Notificaciones",changelog:"Historial",admin:"Inicio",users:"Usuarios",roles:"Roles",menus:"Menús",guards:"Guardias",vacations:"Vacaciones",audit:"Auditoría",positions:"Puestos",ranks:"Rangos","email-inbox":"Buzones","security-incidents":"Incidentes","guard-schedule":"Guardias"},qe={dashboard:e.jsx(g.HiChartBar,{className:"h-5 w-5"}),tickets:e.jsx(g.HiTicket,{className:"h-5 w-5"}),teams:e.jsx(g.HiUsers,{className:"h-5 w-5"}),projects:e.jsx(g.HiRectangleGroup,{className:"h-5 w-5"}),clients:e.jsx(g.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:e.jsx(g.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:e.jsx(g.HiUser,{className:"h-5 w-5"}),settings:e.jsx(g.HiCog6Tooth,{className:"h-5 w-5"}),notifications:e.jsx(g.HiBell,{className:"h-5 w-5"}),changelog:e.jsx(g.HiDocumentText,{className:"h-5 w-5"}),admin:e.jsx(g.HiShieldCheck,{className:"h-5 w-5"}),users:e.jsx(g.HiUsers,{className:"h-5 w-5"}),roles:e.jsx(g.HiShieldCheck,{className:"h-5 w-5"}),menus:e.jsx(g.HiCog6Tooth,{className:"h-5 w-5"}),guards:e.jsx(g.HiCalendarDays,{className:"h-5 w-5"}),vacations:e.jsx(g.HiCalendarDays,{className:"h-5 w-5"}),audit:e.jsx(g.HiListBullet,{className:"h-5 w-5"}),positions:e.jsx(g.HiBriefcase,{className:"h-5 w-5"}),ranks:e.jsx(g.HiListBullet,{className:"h-5 w-5"}),"email-inbox":e.jsx(g.HiInbox,{className:"h-5 w-5"}),"security-incidents":e.jsx(g.HiShieldCheck,{className:"h-5 w-5"})};function xt({href:r,className:t,style:a,children:n}){return e.jsx("a",{href:r,className:t,style:a,children:n})}function yt(r){return r.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function wt(r){return/^\d+$/.test(r)||/^[a-f0-9]{8,}$/i.test(r)}function Nt(r){const t=r.split("/").filter(Boolean);if(t.length===0||t.length===1&&t[0]==="dashboard")return[];const a=decodeURIComponent(t[t.length-1]),n=t.length>1?decodeURIComponent(t[t.length-2]):void 0,l=wt(a)&&n?n:a,f=gt[l]??yt(l);return[{label:"Inicio",href:"/"},{label:f}]}function Ye(r){return(r==null?void 0:r.querySelector(":scope > .os-viewport"))??(r==null?void 0:r.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function kt(r){const t=r.split("/").filter(Boolean),a=t[t.length-1];if(!a)return e.jsx(g.HiHome,{className:"h-5 w-5"});if(qe[a])return qe[a];const n=t.length>1?t[t.length-2]:"";return qe[n]??e.jsx(g.HiHome,{className:"h-5 w-5"})}function St({title:r,subtitle:t,action:a,meta:n,icon:l,className:f="",contentClassName:d="",breadcrumbs:h,currentPath:u=typeof window>"u"?"/":window.location.pathname,showBreadcrumbs:b=!0,contained:N=!1,LinkComponent:k=xt}){const y=s.useRef(null),[p,x]=s.useState(!1),[c,M]=s.useState(null),L=h??Nt(u),Z=l??kt(u),W=b&&L.length>1;return s.useEffect(()=>{if(N){x(!1);return}let $=null,H=0,I=0;const B=()=>{const C=y.current,F=document.querySelector("[data-app-scroll='true']");return(C==null?void 0:C.closest(".os-viewport"))??(C==null?void 0:C.closest("[data-overlayscrollbars-viewport]"))??Ye(F)??F??window},U=()=>{const C=$&&$!==window?$.scrollTop:window.scrollY;x(F=>F?C>24:C>72)},D=()=>{$==null||$.removeEventListener("scroll",U),$=B(),$.addEventListener("scroll",U,{passive:!0}),U()};return D(),H=window.requestAnimationFrame(D),I=window.setTimeout(D,120),()=>{window.cancelAnimationFrame(H),window.clearTimeout(I),$==null||$.removeEventListener("scroll",U)}},[N]),s.useEffect(()=>{if(N){M(null);return}let $=0;const H=[],I=()=>{const P=y.current,j=P==null?void 0:P.parentElement,Y=document.querySelector("[data-app-scroll='true']"),Q=Ye(Y)??Y;if(!P||!j||!Q){M(null);return}const o=j.getBoundingClientRect(),w=window.getComputedStyle(j),_=Q.getBoundingClientRect(),G=Q instanceof HTMLElement&&Q.clientWidth>0?Q.clientWidth:_.width,X=o.left+parseFloat(w.paddingLeft||"0"),ee={marginLeft:Math.round(_.left-X),width:Math.round(G)};M(ue=>ue&&ue.marginLeft===ee.marginLeft&&ue.width===ee.width?ue:ee)},B=()=>{window.cancelAnimationFrame($),$=window.requestAnimationFrame(I)};B(),window.addEventListener("resize",B);const U=new ResizeObserver(B),D=y.current,C=D==null?void 0:D.parentElement,F=document.querySelector("[data-app-scroll='true']"),V=Ye(F)??F;return[C,F,V].forEach(P=>{P&&U.observe(P)}),H.push(window.setTimeout(B,120)),H.push(window.setTimeout(B,280)),()=>{window.cancelAnimationFrame($),window.removeEventListener("resize",B),U.disconnect(),H.forEach(P=>window.clearTimeout(P))}},[N]),e.jsx("div",{ref:y,"data-page-header":"true","data-compact":p?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${N?"mb-0 flex-shrink-0":"mb-6 sm:mb-1"} ${f}`,style:{...c?{marginLeft:c.marginLeft,width:c.width}:null,background:N?"var(--bg-card)":p?"var(--bg-main)":"color-mix(in srgb, var(--bg-main) 44%, transparent)",backdropFilter:"saturate(1.2) blur(14px)",WebkitBackdropFilter:"saturate(1.2) blur(14px)",borderBottom:N||p?"1px solid var(--border)":"1px solid transparent",boxShadow:p?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"},children:e.jsxs("div",{className:`flex flex-wrap items-center justify-between px-4 pt-0.5 transition-[gap,min-height,padding] duration-300 ease-out ${p?"min-h-10 gap-2 sm:min-h-11 sm:gap-3":"min-h-11 gap-3 sm:min-h-12 sm:gap-4"} ${d}`,children:[e.jsxs("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${p?"gap-1":"gap-1.5 sm:gap-2"}`,children:[W&&e.jsx("nav",{"aria-label":"Breadcrumb",className:"min-w-0 flex-shrink-0 transition-[opacity,transform] duration-300 ease-out",children:e.jsx("ol",{className:`flex flex-wrap items-center gap-1.5 leading-none transition-[font-size,line-height] duration-300 ease-out ${p?"text-[10px] sm:text-[11px]":"text-[11px] sm:text-xs"}`,children:L.map(($,H)=>{const I=H===L.length-1;return e.jsxs("li",{className:"flex min-w-0 items-center gap-1.5",children:[H>0&&e.jsx(g.HiChevronRight,{className:"h-3.5 w-3.5 transition-[color,transform] duration-300 ease-out",style:{color:"var(--text-muted)"}}),$.href&&!I?e.jsx(k,{href:$.href,className:"truncate transition-colors duration-300 hover:underline",style:{color:"var(--text-muted)"},children:$.label}):e.jsx("span",{"aria-current":I?"page":void 0,className:I?"truncate font-semibold":"truncate",style:{color:I?"var(--text-main)":"var(--text-muted)"},children:$.label})]},`${$.label}-${H}`)})})}),e.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${p?"gap-2":"gap-2.5 sm:gap-3"}`,children:[e.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${p?"scale-90 opacity-80":"scale-100 opacity-100"}`,style:{color:W?"var(--text-secondary)":"var(--text-muted)"},children:Z}),e.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${p?"gap-x-2 gap-y-1":"gap-x-3 gap-y-2"}`,children:[e.jsxs("div",{className:"min-w-0 flex-shrink transition-[transform] duration-300 ease-out",children:[e.jsx("h1",{className:`truncate font-bold tracking-tight transition-[font-size,line-height,color] duration-300 ease-out ${p?"text-lg sm:text-xl":"text-xl sm:text-2xl"}`,style:{color:"var(--text-main)"},children:r}),t&&e.jsx("p",{"aria-hidden":p,className:`overflow-hidden text-sm transition-[max-height,opacity,transform,margin] duration-300 ease-out ${p?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-6 translate-y-0 opacity-100 sm:mt-1"}`,style:{color:"var(--text-muted)"},children:t})]}),n&&e.jsx("div",{className:`page-header-meta flex min-w-0 flex-1 basis-full items-center overflow-visible transition-[gap,opacity,transform] duration-300 ease-out sm:basis-auto ${p?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:n})]})]})]}),a&&e.jsx("div",{className:`page-header-actions flex flex-shrink-0 items-center self-center overflow-visible transition-[gap,min-height,opacity,transform] duration-300 ease-out ${p?"min-h-10 gap-1.5 opacity-95":"min-h-11 gap-2 opacity-100"}`,children:a})]})})}function Ct({children:r,currentPath:t=typeof window>"u"?"/":window.location.pathname,publicRoutes:a=["/","/login","/reset-password"],...n}){return a.includes(t)?e.jsx(e.Fragment,{children:r}):e.jsx(vr,{currentPath:t,...n,children:r})}function gr(){if(typeof window>"u")return"system";const r=localStorage.getItem("theme");return r==="light"||r==="dark"?r:r==="system"?"system":document.documentElement.classList.contains("dark")?"dark":"light"}function Et(r,t,a){try{const n=new URL(r),l=n.searchParams.get("callbackUrl");if(l){const f=new URL(l,n.origin);return f.searchParams.set("theme",t),a&&(f.searchParams.set("primeAuthOrigin",window.location.origin),f.searchParams.set("primeAuthProjectKey",a)),n.searchParams.set("callbackUrl",`${f.pathname}${f.search}${f.hash}`),n.toString()}return n.searchParams.set("theme",t),a&&(n.searchParams.set("primeAuthOrigin",window.location.origin),n.searchParams.set("primeAuthProjectKey",a)),n.toString()}catch{return r}}function Mt({name:r,src:t,projectKey:a}){const[n,l]=s.useState(()=>gr()),f=s.useRef(null);s.useEffect(()=>{const u=new MutationObserver(()=>l(gr()));return u.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>u.disconnect()},[]);const d=s.useMemo(()=>Et(t,n,a),[a,t,n]),h=s.useMemo(()=>{try{return new URL(d).origin}catch{return""}},[d]);return s.useEffect(()=>{if(!a)return;const u=a;function b(N){var p,x,c;if(N.source!==((p=f.current)==null?void 0:p.contentWindow)||h&&N.origin!==h)return;if(((x=N.data)==null?void 0:x.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!N.data.active}}));return}if(((c=N.data)==null?void 0:c.type)!=="prime-microservice:navigation")return;const k=N.data.path;if(!k||!k.startsWith("/")||k.startsWith("//"))return;const y=`/apps/${encodeURIComponent(u)}${k}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==y&&(window.history.replaceState(window.history.state,"",y),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",b),()=>{window.removeEventListener("message",b),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[h,a]),e.jsx("div",{className:"flex h-full min-h-screen flex-col bg-[var(--bg-main)]",children:e.jsx("iframe",{ref:f,src:d,title:r,className:"min-h-0 flex-1 border-0 bg-[var(--bg-main)]",allow:"clipboard-write",sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-same-origin allow-scripts",referrerPolicy:"strict-origin-when-cross-origin"})})}function $t(){const[r,t]=s.useState(""),[a,n]=s.useState(!1),[l,f]=s.useState({width:96,height:96});return s.useEffect(()=>{let d=!1;return fetch("/api/microservices/prime-suite/chat-url",{cache:"no-store"}).then(h=>h.ok?h.json():null).then(h=>{!d&&(h!=null&&h.src)&&t(h.src)}).catch(()=>{}),()=>{d=!0}},[]),s.useEffect(()=>{const d=h=>{var b;if(((b=h.data)==null?void 0:b.type)!=="prime-suite-chat:state")return;const u=!!h.data.active;n(u),f({width:xr(h.data.width,96,720),height:xr(h.data.height,96,560)})};return window.addEventListener("message",d),()=>window.removeEventListener("message",d)},[]),r?e.jsx("iframe",{title:"Chat Bonsaif",src:r,allow:"clipboard-write",className:"fixed bottom-0 right-0 z-[70] border-0 bg-transparent transition-[width,height] duration-200",style:{width:a?`min(${l.width}px, 100vw)`:96,height:a?`min(${l.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function xr(r,t,a){const n=typeof r=="number"&&Number.isFinite(r)?r:t;return Math.max(t,Math.min(a,Math.ceil(n)))}function Tt(r){const t=document.documentElement,a=new MutationObserver(r);a.observe(t,{attributes:!0,attributeFilter:["class"]});const n=window.matchMedia("(prefers-color-scheme: dark)");return n.addEventListener("change",r),()=>{a.disconnect(),n.removeEventListener("change",r)}}function Dt(){const r=localStorage.getItem("theme")||"system",t=window.matchMedia("(prefers-color-scheme: dark)").matches;return document.documentElement.classList.contains("dark")||r==="dark"||r==="system"&&t?"dark":"light"}function Bt(){return"light"}function Ht(){const r=s.useSyncExternalStore(Tt,Dt,Bt);return e.jsx($r.Toaster,{position:"bottom-center",theme:r,richColors:!0,closeButton:!0})}T.AuthShell=vr,T.BonsaifButton=Tr,T.Button=fe,T.CalendarPicker=qr,T.CompactFilterSelect=Gr,T.CompactSearchInput=Yr,T.ConfirmDialog=Vr,T.DataTable=Rr,T.DateRangePicker=tt,T.Drawer=at,T.DynamicDetailTabs=_r,T.GlobalScrollbars=pr,T.InputField=nt,T.LoadingState=er,T.MicroserviceFrame=Mt,T.Modal=ir,T.MouseTooltip=je,T.PageHeader=St,T.PageSearchInput=Qe,T.PrimeAuthRouteShell=Ct,T.PrimeAuthToaster=Ht,T.PrimeSuiteChatFrame=$t,T.SearchableSelect=We,T.StepWizard=ot,T.TextInput=Ue,T.Toggle=it,T.UserAvatar=mr,T.cn=Ze,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(O,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react"),require("react-icons/hi2"),require("overlayscrollbars"),require("react-dom"),require("react-icons/md"),require("overlayscrollbars-react"),require("react-day-picker"),require("react-day-picker/dist/style.css"),require("react-icons/fi"),require("sonner")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-icons/hi2","overlayscrollbars","react-dom","react-icons/md","overlayscrollbars-react","react-day-picker","react-day-picker/dist/style.css","react-icons/fi","sonner"],e):(O=typeof globalThis<"u"?globalThis:O||self,e(O.BonsaifUI={},O.jsxRuntime,O.React,O.ReactIconsHi2,O.OverlayScrollbarsGlobal,O.ReactDOM,O.ReactIconsMd,O.OverlayScrollbarsReact,O.ReactDayPicker,O.ReactDayPickerStyles,O.ReactIconsFi,O.Sonner))})(this,(function(O,e,o,x,Ze,Le,Pr,Ke,Qe,oa,Ir,Ar){"use strict";"use client";function Re(...r){return r.filter(Boolean).join(" ")}function zr({variant:r="primary",className:t,type:a="button",children:n,...i}){return e.jsx("button",{className:Re("bonsaif-ui-button",`bonsaif-ui-button--${r}`,t),type:a,...i,children:n})}function er({value:r,onChange:t,placeholder:a,className:n="",autoFocus:i=!1,forceExpanded:d=!1,onEscape:f,size:h="default",inputTabIndex:c}){const b=o.useRef(null),[N,k]=o.useState(!1),v=d||N||r.trim().length>0,p=h==="sm"?"h-9 rounded-md":"h-11 rounded-lg";o.useEffect(()=>{var u;i&&(k(!0),(u=b.current)==null||u.focus())},[i]);const m=()=>{var u;k(!0),(u=b.current)==null||u.focus()};return e.jsxs("div",{className:`relative flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${v?n||"w-full":"w-28"}`,onMouseDown:u=>{v||(u.preventDefault(),m())},children:[e.jsx(x.HiMagnifyingGlass,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none transition-colors duration-200",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:b,type:"text",tabIndex:c,"aria-label":a,value:r,onChange:u=>t(u.target.value),onKeyDown:u=>{u.key==="Escape"&&(f==null||f())},placeholder:v?a:"Buscar",className:`${p} w-full py-0 text-sm placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${v?"pl-9 pr-9":"cursor-pointer pl-9 pr-3"}`,style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"},onFocus:u=>{k(!0),u.currentTarget.style.borderColor="var(--primary)",u.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:u=>{k(!1),u.currentTarget.style.borderColor="var(--border)",u.currentTarget.style.boxShadow="none"}}),r&&e.jsx("button",{type:"button",onClick:()=>t(""),className:"absolute right-2 top-1/2 flex !h-6 !w-6 -translate-y-1/2 items-center justify-center rounded-full !p-0 leading-none transition-colors hover:bg-black/5",style:{color:"var(--text-muted)"},"aria-label":"Limpiar búsqueda",children:e.jsx(x.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}function rr(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}const jr="inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap leading-none font-medium transition-all duration-150 focus:outline-none disabled:opacity-50 rounded-lg",_r={primary:"border border-[var(--border)] text-[var(--text-main)] hover:border-[var(--border)] hover:bg-[var(--bg-input)] active:scale-[0.98] transition-colors",secondary:"border border-[var(--border)] text-[var(--text-main)] hover:border-[var(--border)] hover:bg-[var(--bg-input)] active:scale-[0.98] transition-colors",danger:"border border-[var(--border)] text-[var(--danger)] hover:border-[var(--danger)] hover:bg-[var(--danger-bg)] active:scale-[0.98] transition-colors",ghost:"text-[var(--text-secondary)] hover:opacity-70",icon:"h-9 w-9 text-[var(--text-muted)] hover:text-[var(--primary)] hover:bg-primary/5"},Wr={sm:"h-9 px-3.5 text-xs",md:"h-11 px-4 text-sm",lg:"h-12 px-5 text-sm font-semibold"},Fr={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function ue({variant:r="primary",size:t="md",loading:a=!1,icon:n,height:i,padding:d,children:f,className:h="",disabled:c,style:b,...N}){const k=r==="icon";return e.jsxs("button",{...N,"data-variant":r,"data-size":t,"data-icon":k?"true":void 0,disabled:c||a,className:`${jr} ${_r[r]} ${k?"":Wr[t]} ${h}`,style:{...Fr[r],height:rr(i),padding:rr(d),...b},children:[a?e.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):n,f]})}function tr({variant:r="page",title:t="Cargando...",rows:a=6,children:n}){return r==="table"?e.jsx(ar,{rows:a}):r==="sections"?e.jsx(Ur,{rows:a}):r==="cards"?e.jsx(qr,{rows:a}):e.jsx("div",{className:"flex min-h-[240px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[e.jsx("div",{className:"h-9 w-9 animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:t}),n&&e.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:n})]})]})})}function Ur({rows:r}){return e.jsx("div",{className:"space-y-4",children:Array.from({length:Math.max(2,Math.min(r,4))}).map((t,a)=>e.jsxs("section",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-pulse rounded bg-[var(--bg-input)]"}),e.jsx("div",{className:"h-4 w-32 animate-pulse rounded bg-[var(--bg-input)]"}),e.jsx("div",{className:"h-5 w-20 animate-pulse rounded-full bg-[var(--bg-input)]"})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"h-8 w-8 animate-pulse rounded-md bg-[var(--bg-input)]"}),e.jsx("div",{className:"h-8 w-8 animate-pulse rounded-md bg-[var(--bg-input)]"})]})]}),e.jsx(ar,{rows:a===0?r:Math.max(3,r-2),compact:!0})]},a))})}function qr({rows:r}){return e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:Array.from({length:r}).map((t,a)=>e.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[e.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded bg-[var(--bg-input)]"}),e.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded bg-[var(--bg-input)]"}),e.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded bg-[var(--bg-input)]"})]},a))})}function ar({rows:r,compact:t=!1}){const a=t?5:6;return e.jsxs("div",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",children:[e.jsx("div",{className:"grid border-b border-[var(--border)]",style:{gridTemplateColumns:`repeat(${a}, minmax(0, 1fr))`},children:Array.from({length:a}).map((n,i)=>e.jsx("div",{className:"px-3 py-3",children:e.jsx("div",{className:"h-3 w-2/3 animate-pulse rounded bg-[var(--bg-input)]"})},i))}),Array.from({length:r}).map((n,i)=>e.jsx("div",{className:"grid border-b border-[var(--border)] last:border-b-0",style:{gridTemplateColumns:`repeat(${a}, minmax(0, 1fr))`},children:Array.from({length:a}).map((d,f)=>e.jsx("div",{className:"px-3 py-3",children:e.jsx("div",{className:"h-3.5 animate-pulse rounded-full bg-[var(--bg-input)]",style:{width:`${52+(i*13+f*11)%36}%`}})},f))},i))]})}function nr(r){const t=r.split("/").filter(Boolean);return(t[t.length-1]??r).replace(/^lv_/,"").split(/[-_]/).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function or(r){return r.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function Gr(r){return[r.label,nr(r.service),r.description,r.service].filter(Boolean).join(" ")}function Yr(r){return typeof r=="function"?r:r.default}function Xr(r,t){return e.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 text-center",children:e.jsxs("div",{className:"max-w-md",children:[e.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:"No se pudo cargar este modulo"}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:r.message}),e.jsx(ue,{className:"mt-4",height:36,padding:"0 14px",onClick:t,children:"Reintentar"})]})})}function Vr({parentPanel:r,parentPanelComponent:t,renderParentPanel:a,parent:n,context:i,links:d,moduleRegistry:f,loadModule:h,activeService:c,initialService:b,onActiveServiceChange:N,canAccess:k,keepAlive:v=!0,title:p,subtitle:m,emptyState:u,loadingState:w,errorState:H=Xr,renderTabLabel:F,searchableTabs:A="auto",tabsSearchThreshold:T=6,tabsSearchPlaceholder:L="Buscar modulo...",tabsSearchValue:B,onTabsSearchChange:E,emptySearchState:U,showTabCount:D=!0,className:M="",parentClassName:W="",contentClassName:Z="",tabsClassName:j=""}){var de;const q=o.useMemo(()=>d.filter(g=>!g.hidden&&((k==null?void 0:k(g,i))??!0)),[k,i,d]),Y=(de=q.find(g=>!g.disabled))==null?void 0:de.service,[Q,s]=o.useState(b??Y??""),[S,_]=o.useState({}),[X,V]=o.useState({}),[ee,fe]=o.useState(""),[re,be]=o.useState(!1),pe=o.useRef(X),ve=o.useRef(0),ce=B??ee,C=or(ce),z=A===!0||A==="auto"&&q.length>=T,J=z&&ce.trim().length>0,ae=o.useMemo(()=>C?q.filter(g=>or(Gr(g)).includes(C)):q,[C,q]),le=c??Q,P=q.find(g=>g.service===le)??q.find(g=>!g.disabled);o.useEffect(()=>{!P&&Y&&s(Y)},[Y,P]),o.useEffect(()=>{pe.current=X},[X]);const we=g=>{g.disabled||(c||s(g.service),N==null||N(g.service,g))},je=g=>{B===void 0&&fe(g),E==null||E(g)},me=(g,K)=>{const oe=ae.filter(se=>!se.disabled),ke=oe.findIndex(se=>se.service===K.service);ke<0||((g.key==="ArrowRight"||g.key==="ArrowDown")&&(g.preventDefault(),we(oe[(ke+1)%oe.length])),(g.key==="ArrowLeft"||g.key==="ArrowUp")&&(g.preventDefault(),we(oe[(ke-1+oe.length)%oe.length])),g.key==="Home"&&(g.preventDefault(),we(oe[0])),g.key==="End"&&(g.preventDefault(),we(oe[oe.length-1])))},Be=o.useCallback(()=>{if(!P)return;const g=P.service,K=pe.current[g];if(K!=null&&K.loading||K!=null&&K.component&&v)return;const oe=(f==null?void 0:f[g])??h;if(!oe){V(se=>({...se,[g]:{loading:!1,error:new Error(`No module loader found for service "${g}".`)}}));return}const ke=++ve.current;V(se=>({...se,[g]:{...se[g],loading:!0,error:void 0}})),oe(P,i).then(se=>{if(ke!==ve.current&&!v)return;const Se=Yr(se);V(Ee=>({...Ee,[g]:{component:Se,loading:!1}}))}).catch(se=>{const Se=se instanceof Error?se:new Error(String(se));V(Ee=>({...Ee,[g]:{...Ee[g],loading:!1,error:Se}}))})},[i,v,h,f,P]);o.useEffect(Be,[Be]);const _e=P?S[P.service]??null:null,ne=P?X[P.service]:void 0,Ce=ne==null?void 0:ne.component,Oe=g=>{P&&_(K=>({...K,[P.service]:g}))},We=()=>{P&&_(g=>({...g,[P.service]:null}))},ge={context:i,parent:n,links:d,visibleLinks:q,filteredLinks:ae,selectedLink:P,selectedService:P==null?void 0:P.service,activeItemId:_e,tabsSearch:ce,onSelectService:we,onOpenDetail:Oe,onBackToList:We},xe=a?a(ge):t?e.jsx(t,{...ge}):r;return e.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${M}`,children:[e.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${W}`,children:xe}),e.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${Z}`,children:[(p||m||z||D)&&e.jsx("div",{className:"relative border-b border-[var(--border)] px-4 py-3",children:e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[p&&e.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:p}),m&&e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:m})]}),(z||D)&&e.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[D&&e.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[ae.length," / ",q.length]}),z&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${re?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!re,children:e.jsx(er,{value:ce,onChange:je,placeholder:L,className:"w-full",autoFocus:re,forceExpanded:!0,onEscape:()=>be(!1),size:"sm",inputTabIndex:re?0:-1})}),e.jsx("button",{type:"button","aria-label":re?"Cerrar busqueda":"Buscar tabs","aria-expanded":re,onClick:()=>{re&&ce&&je(""),be(g=>!g)},className:`inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border transition-all duration-200 hover:scale-[1.03] active:scale-95 ${re||J?"border-[var(--primary)] bg-[var(--bg-input)] text-[var(--text-main)] shadow-sm":"border-[var(--border)] text-[var(--text-muted)] hover:bg-[var(--bg-input)] hover:text-[var(--text-main)]"}`,children:e.jsx("span",{className:"grid h-4 w-4 place-items-center transition-transform duration-200",children:re||J?e.jsx(x.HiXMark,{className:"h-4 w-4"}):e.jsx(x.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),e.jsx("div",{role:"tablist","aria-label":p??"Modulos relacionados",className:`flex gap-1 overflow-x-auto border-b border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 transition-colors duration-200 ${j}`,children:ae.length>0?ae.map(g=>{const K=g.service===(P==null?void 0:P.service);return e.jsx("button",{type:"button",role:"tab","aria-selected":K,disabled:g.disabled,onClick:()=>we(g),onKeyDown:oe=>me(oe,g),className:`inline-flex h-9 min-w-max items-center gap-2 rounded-md border px-3 text-xs font-semibold transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-50 ${K?"border-[var(--primary)] bg-[var(--bg-card)] text-[var(--text-main)] shadow-sm":"border-transparent text-[var(--text-muted)] hover:bg-[var(--bg-card)] hover:text-[var(--text-main)]"}`,children:F?F(g,K):e.jsxs(e.Fragment,{children:[g.icon,e.jsx("span",{children:g.label??nr(g.service)}),g.badge&&e.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:g.badge})]})},g.service)}):e.jsx("div",{className:"flex min-h-9 flex-1 items-center rounded-md border border-dashed border-[var(--border)] px-3 text-xs text-[var(--text-muted)]",children:U??"No hay modulos que coincidan con la busqueda."})}),(P==null?void 0:P.description)&&e.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:P.description}),e.jsxs("div",{className:"min-h-[420px] p-4",children:[!P&&(u??e.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-dashed border-[var(--border)] text-sm text-[var(--text-muted)]",children:"No hay modulos disponibles."})),P&&(ne==null?void 0:ne.loading)&&(w??e.jsx(tr,{title:"Cargando modulo..."})),P&&(ne==null?void 0:ne.error)&&H(ne.error,Be),P&&Ce&&!(ne!=null&&ne.loading)&&!(ne!=null&&ne.error)&&e.jsx(Ce,{context:i,parent:n,link:P,activeItemId:_e,onOpenDetail:Oe,onBackToList:We})]})]})]})}const sr=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],Jr=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],Zr=["Do","Lu","Ma","Mi","Ju","Vi","Sá"],Fe=6;function Ue(r,t,a){return`${r}-${String(t).padStart(2,"0")}-${String(a).padStart(2,"0")}`}function Kr(){const r=new Date;return Ue(r.getFullYear(),r.getMonth()+1,r.getDate())}function ir(r){const[t,a,n]=r.split("-").map(Number);return{year:t,month:a,day:n}}function Qr(r){if(!r)return"Seleccionar fecha";const{year:t,month:a,day:n}=ir(r);return!t||!a||!n?"Seleccionar fecha":`${String(n).padStart(2,"0")} ${sr[a-1]} ${t}`}function Rr({value:r,onChange:t,minDate:a,displayMode:n="inline"}){const i=Kr(),f=ir(r||i),h=n==="popover",[c,b]=o.useState(!1),N=o.useRef(null),[k,v]=o.useState({horizontal:"left",vertical:"bottom"}),[p,m]=o.useState(f.year),[u,w]=o.useState(f.month),[H,F]=o.useState("days"),A=16,[T,L]=o.useState(0),B=p-7+T,E=Array.from({length:A},(s,S)=>B+S);o.useEffect(()=>{if(!h||!c||!N.current)return;const s=N.current.getBoundingClientRect(),S=8,_=280,X=340,V=s.left+_>window.innerWidth-S,ee=s.right-_>=S,fe=s.bottom+8+X>window.innerHeight-S,re=s.top-8-X>=S;v({horizontal:V&&ee?"right":"left",vertical:fe&&re?"top":"bottom"})},[h,c]),o.useEffect(()=>{if(!h||!c)return;function s(_){N.current&&(N.current.contains(_.target)||b(!1))}function S(_){_.key==="Escape"&&b(!1)}return document.addEventListener("mousedown",s),document.addEventListener("keydown",S),()=>{document.removeEventListener("mousedown",s),document.removeEventListener("keydown",S)}},[h,c]);function U(){u===1?(m(s=>s-1),w(12)):w(s=>s-1)}function D(){u===12?(m(s=>s+1),w(1)):w(s=>s+1)}const M=new Date(p,u-1,1).getDay(),W=new Date(p,u,0).getDate(),Z=[...Array(M).fill(null),...Array.from({length:W},(s,S)=>S+1)];for(;Z.length<Fe*7;)Z.push(null);const j=Z.slice(0,Fe*7);function q(s){const S=Ue(p,u,s);a&&S<a||(t(S),h&&b(!1))}const Y={background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,borderRadius:6,display:"flex",alignItems:"center"},Q=e.jsxs("div",{style:{background:"var(--bg-input)",border:"1px solid var(--border)",borderRadius:10,overflow:"hidden",userSelect:"none",width:280},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 12px",borderBottom:"1px solid var(--border)"},children:H==="days"?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:U,style:Y,title:"Mes anterior",children:e.jsx(x.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>{F("years"),L(0)},style:{background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:4,fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[sr[u-1]," ",p,e.jsx(x.HiChevronDown,{size:13,style:{color:"var(--text-muted)"}})]}),e.jsx("button",{type:"button",onClick:D,style:Y,title:"Mes siguiente",children:e.jsx(x.HiChevronRight,{size:16})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>L(s=>s-A),style:Y,children:e.jsx(x.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>F("days"),style:{background:"none",border:"none",cursor:"pointer",fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[E[0]," – ",E[E.length-1]]}),e.jsx("button",{type:"button",onClick:()=>L(s=>s+A),style:Y,children:e.jsx(x.HiChevronRight,{size:16})})]})}),H==="years"&&e.jsxs("div",{style:{padding:"8px 10px 10px"},children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3,marginBottom:8},children:Jr.map((s,S)=>{const _=S+1===u;return e.jsx("button",{type:"button",onClick:()=>w(S+1),style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:11,fontWeight:_?700:400,padding:"4px 0",background:_?"var(--primary)":"transparent",color:_?"var(--primary-fg, #ffffff)":"var(--text-secondary)"},children:s},s)})}),e.jsx("div",{style:{height:1,background:"var(--border)",marginBottom:8}}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3},children:E.map(s=>{const S=s===p;return e.jsx("button",{type:"button",onClick:()=>{m(s),F("days")},style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:12,fontWeight:S?700:400,padding:"6px 0",background:S?"var(--primary)":"transparent",color:S?"var(--primary-fg, #ffffff)":"var(--text-main)",outline:s===new Date().getFullYear()&&!S?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:s},s)})})]}),H==="days"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",padding:"6px 8px 0"},children:Zr.map(s=>e.jsx("div",{style:{textAlign:"center",fontSize:10,fontWeight:700,color:"var(--text-muted)",padding:"2px 0",textTransform:"uppercase"},children:s},s))}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",gridTemplateRows:`repeat(${Fe},1fr)`,padding:"4px 8px 10px",gap:2},children:j.map((s,S)=>{if(s===null)return e.jsx("div",{style:{aspectRatio:"1"}},S);const _=Ue(p,u,s),X=_===r,V=_===i,ee=!!(a&&_<a);return e.jsx("button",{type:"button",onClick:()=>!ee&&q(s),style:{width:"100%",aspectRatio:"1",borderRadius:6,border:"none",cursor:ee?"not-allowed":"pointer",fontSize:12,fontWeight:X||V?700:400,background:X?"var(--primary)":"transparent",color:X?"var(--primary-fg, #ffffff)":ee?"var(--text-muted)":"var(--text-main)",opacity:ee?.4:1,outline:V&&!X?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:s},S)})})]})]});return h?e.jsxs("div",{ref:N,className:"relative w-full",children:[e.jsxs("button",{type:"button",onClick:()=>b(s=>!s),className:"flex h-11 w-full items-center justify-between gap-2 rounded-lg px-3 py-0 text-sm transition-all duration-150 focus:outline-none",style:{background:"var(--bg-input)",border:`1px solid ${c?"var(--primary)":"var(--border)"}`,color:"var(--text-main)",boxShadow:c?"0 0 0 3px rgba(59,130,246,0.12)":"none"},children:[e.jsxs("span",{className:"inline-flex items-center gap-2 min-w-0",children:[e.jsx(x.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),e.jsx("span",{className:"truncate",children:Qr(r)})]}),e.jsx(x.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${c?"rotate-180":""}`})]}),c&&e.jsx("div",{className:"absolute z-50",style:{...k.horizontal==="left"?{left:0}:{right:0},...k.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:Q})]}):Q}function lr(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function qe({value:r,onChange:t,options:a,placeholder:n="Seleccionar…",emptyLabel:i,disabled:d=!1,className:f="",style:h,height:c=44,padding:b="0 12px",searchable:N=!0,minOptionsForSearch:k=6}){const[v,p]=o.useState(!1),[m,u]=o.useState(""),[w,H]=o.useState(-1),[F,A]=o.useState(!1),[T,L]=o.useState({}),B=o.useRef(null),E=o.useRef(null),U=o.useRef(null),D=o.useRef(null),M=N&&a.length>=k,W=a.find(s=>s.value===r)??null,Z=M&&m.trim()?a.filter(s=>{var S;return s.label.toLowerCase().includes(m.toLowerCase())||((S=s.sublabel)==null?void 0:S.toLowerCase().includes(m.toLowerCase()))}):a,j=o.useCallback(()=>{const s=B.current;if(!s)return;const S=s.getBoundingClientRect(),_=M?272:212,X=window.innerHeight-S.bottom,V=X<_&&S.top>X;L({position:"fixed",left:S.left,top:V?void 0:S.bottom+4,bottom:V?window.innerHeight-S.top+4:void 0,width:S.width,zIndex:9999})},[M]);o.useEffect(()=>A(!0),[]),o.useEffect(()=>{if(!v)return;function s(S){var X,V;const _=S.target;!((X=B.current)!=null&&X.contains(_))&&!((V=E.current)!=null&&V.contains(_))&&(p(!1),u(""))}return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[v]),o.useEffect(()=>{v&&(H(-1),j(),M&&setTimeout(()=>{var s;return(s=U.current)==null?void 0:s.focus()},0))},[v,M,j]),o.useEffect(()=>{if(v)return window.addEventListener("resize",j),window.addEventListener("scroll",j,!0),()=>{window.removeEventListener("resize",j),window.removeEventListener("scroll",j,!0)}},[v,j]),o.useEffect(()=>{if(w<0||!D.current)return;const s=D.current.children[w];s==null||s.scrollIntoView({block:"nearest"})},[w]);const q=o.useCallback(s=>{t(s),p(!1),u("")},[t]);function Y(s){if(!v){(s.key==="Enter"||s.key===" "||s.key==="ArrowDown")&&(s.preventDefault(),p(!0));return}s.key==="Escape"?(s.preventDefault(),p(!1),u("")):s.key==="ArrowDown"?(s.preventDefault(),H(S=>Math.min(S+1,Z.length-1))):s.key==="ArrowUp"?(s.preventDefault(),H(S=>Math.max(S-1,i?-1:0))):s.key==="Enter"&&(s.preventDefault(),w===-1&&i?q(""):Z[w]&&q(Z[w].value))}const Q=e.jsxs("div",{ref:E,className:"rounded-xl shadow-xl overflow-hidden",style:{...T,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[M&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(x.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:U,value:m,onChange:s=>{u(s.target.value),H(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),m&&e.jsx("button",{type:"button",onMouseDown:s=>{s.preventDefault(),u("")},children:e.jsx(x.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),e.jsxs("ul",{ref:D,role:"listbox",className:"overflow-y-auto",style:{maxHeight:M?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[i&&e.jsx("li",{role:"option","aria-selected":r==="",onMouseDown:s=>{s.preventDefault(),q("")},onMouseEnter:()=>H(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:w===-1?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:i}),Z.map((s,S)=>{const X=S===w,V=s.value===r;return e.jsxs("li",{role:"option","aria-selected":V,onMouseDown:ee=>{ee.preventDefault(),s.disabled||q(s.value)},onMouseEnter:()=>!s.disabled&&H(S),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:X?"var(--bg-hover)":V?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:s.disabled?"var(--text-muted)":"var(--text-main)",cursor:s.disabled?"not-allowed":"pointer",boxShadow:V?"inset 2px 0 0 var(--primary)":void 0},children:[s.color&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:s.color}}),e.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:s.label}),s.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:s.sublabel})]}),s.badge&&e.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:s.badge})]},s.value)}),Z.length===0&&e.jsx("li",{className:"px-3 py-4 text-sm text-center",style:{color:"var(--text-muted)"},children:"Sin resultados"})]})]});return e.jsxs("div",{ref:B,className:`relative ${f||"w-full"}`,style:h,onKeyDown:Y,children:[e.jsxs("button",{type:"button",disabled:d,onClick:()=>!d&&p(s=>!s),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:lr(c),padding:lr(b),background:"var(--bg-input)",color:W?"var(--text-main)":"var(--text-muted)",border:v?"1px solid var(--primary)":"1px solid var(--border)",opacity:d?.5:1,cursor:d?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":v,children:[(W==null?void 0:W.color)&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:W.color}}),e.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:W?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"truncate",children:W.label}),W.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:W.sublabel})]}):e.jsx("span",{className:"truncate",children:n})}),W&&i?e.jsx("span",{role:"button",tabIndex:-1,onMouseDown:s=>{s.preventDefault(),s.stopPropagation(),q("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(x.HiXMark,{className:"w-3 h-3"})}):e.jsx(x.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:v?"rotate(180deg)":"rotate(0deg)"}})]}),v&&F&&Le.createPortal(Q,document.body)]})}function He(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function et({value:r,onChange:t,placeholder:a="Buscar...",className:n="",height:i=44,padding:d="0 12px 0 34px",iconLeft:f=12}){return e.jsxs("div",{className:`relative ${n}`,children:[e.jsx(x.HiMagnifyingGlass,{className:"absolute top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[var(--text-muted)] pointer-events-none",style:{left:He(f)}}),e.jsx("input",{type:"text",value:r,onChange:h=>t(h.target.value),placeholder:a,className:"w-full rounded-lg border border-[var(--border)] [background:var(--bg-card)] text-sm text-[var(--text-main)] placeholder:text-[var(--text-muted)] outline-none transition-[border-color,box-shadow] focus:border-primary focus:ring-2 focus:ring-primary/20",style:{height:He(i),padding:He(d)}})]})}function rt({value:r,onChange:t,options:a,placeholder:n,icon:i,className:d="",height:f=44,padding:h,iconLeft:c=12,searchable:b=!0}){const N=i?a.map((k,v)=>v===0&&!k.color?{...k,sublabel:k.sublabel??void 0}:k):a;return e.jsxs("div",{className:`relative ${d}`,children:[i&&e.jsx("span",{className:"pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--text-muted)]",style:{left:He(c)},children:i}),e.jsx(qe,{value:r,onChange:t,options:N,placeholder:n,searchable:b,minOptionsForSearch:5,height:f,padding:h??(i?"0 12px 0 34px":"0 12px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const tt={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},Pe=180;function cr({open:r,onClose:t,title:a,subtitle:n,leadingIcon:i,headerActions:d,footer:f,children:h,size:c="md",maxWidth:b,zIndex:N=1e3,closeOnBackdrop:k=!0,closeOnEscape:v=!0,showCloseButton:p=!0,placement:m="center",bodyClassName:u="px-6 py-5",panelClassName:w="",backdropClassName:H="bg-black/50 backdrop-blur-sm",contentClassName:F="p-4",ariaLabel:A,frameless:T=!1}){const[L,B]=o.useState(!1),[E,U]=o.useState(!1),D=o.useRef(null);if(o.useEffect(()=>(r?(D.current&&clearTimeout(D.current),B(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>U(!0)))):(U(!1),D.current=setTimeout(()=>B(!1),Pe+40)),()=>{D.current&&clearTimeout(D.current)}),[r]),o.useEffect(()=>{if(r)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[r]),o.useEffect(()=>{if(!r||!v)return;const Y=Q=>{Q.key==="Escape"&&t()};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[v,t,r]),!L)return null;const M=a||n||i||d||p,W=b??tt[c],Z=m==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",j=m==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",q=E?"translateY(0) scale(1)":m==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return Le.createPortal(e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":A??a,className:`fixed inset-0 flex ${Z} ${F}`,style:{zIndex:N},children:[e.jsx("div",{className:`absolute inset-0 ${H}`,onClick:k?t:void 0,style:{opacity:E?1:0,transition:`opacity ${Pe}ms ease`}}),e.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${T?"shadow-none":"shadow-2xl"} ${j} ${w}`,style:{maxWidth:W,background:T?"transparent":"var(--bg-card)",border:T?"none":"1px solid var(--border)",opacity:E?1:0,transform:q,transition:`opacity ${Pe}ms ease, transform ${Pe}ms ease`},onClick:Y=>Y.stopPropagation(),children:[M&&e.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between gap-3 px-6 py-4",style:{borderBottom:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[i&&e.jsx("div",{className:"flex-shrink-0",children:i}),(a||n)&&e.jsxs("div",{className:"min-w-0",children:[a&&e.jsx("h2",{className:"truncate text-base font-semibold",style:{color:"var(--text-main)"},children:a}),n&&e.jsx("p",{className:"truncate text-xs",style:{color:"var(--text-muted)"},children:n})]})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[d,p&&e.jsx(ue,{variant:"icon",onClick:t,title:"Cerrar",children:e.jsx(x.HiXMark,{className:"h-5 w-5"})})]})]}),e.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${u}`,children:h}),f&&e.jsx("div",{className:"flex flex-shrink-0 justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:f})]})]}),document.body)}const at={danger:{iconBg:"rgba(239,68,68,0.12)",iconColor:"var(--danger)",btnBg:"var(--danger)",btnColor:"#fff"},warning:{iconBg:"rgba(245,158,11,0.12)",iconColor:"var(--warning)",btnBg:"var(--warning)",btnColor:"#fff"},primary:{iconBg:"rgba(59,130,246,0.12)",iconColor:"var(--primary)",btnBg:"var(--primary)",btnColor:"#fff"}};function nt({open:r,title:t,description:a,confirmLabel:n="Confirmar",cancelLabel:i="Cancelar",variant:d="danger",onConfirm:f,onCancel:h}){const c=at[d];return e.jsxs(cr,{open:r,onClose:h,size:"sm",zIndex:9998,showCloseButton:!1,bodyClassName:"p-6",panelClassName:"px-1",ariaLabel:t,children:[e.jsx(ue,{variant:"icon",onClick:h,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:e.jsx(x.HiXMark,{className:"h-4 w-4"})}),e.jsx("div",{className:"mb-4 flex h-11 w-11 items-center justify-center rounded-xl",style:{background:c.iconBg},children:e.jsx(x.HiExclamationTriangle,{className:"h-5 w-5",style:{color:c.iconColor}})}),e.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main)"},children:t}),a&&e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:a}),e.jsxs("div",{className:"mt-6 flex gap-2",children:[e.jsx(ue,{variant:"secondary",onClick:h,className:"flex-1",style:{background:"var(--bg-input)"},children:i}),e.jsx(ue,{variant:"danger",onClick:f,className:"flex-1",style:{background:c.btnBg,color:c.btnColor,borderColor:"transparent"},children:n})]})]})}function dr(r){const t=document.createElement("textarea");t.value=r,t.style.position="fixed",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}async function ot(r){var t;if((t=navigator.clipboard)!=null&&t.writeText){await navigator.clipboard.writeText(r);return}dr(r)}function st(r){return typeof r=="function"?r():r}function ur({value:r,resetDelay:t=2e3,title:a,copiedTitle:n="Copiado",copiedLabel:i,icon:d=e.jsx(x.HiClipboardDocument,{className:"h-3.5 w-3.5"}),copiedIcon:f=e.jsx(x.HiCheck,{className:"h-3.5 w-3.5"}),stopPropagation:h=!0,onCopied:c,onCopyError:b,className:N="",style:k,children:v,onClick:p,type:m="button",...u}){const[w,H]=o.useState(!1),F=o.useRef(null);o.useEffect(()=>()=>{F.current&&window.clearTimeout(F.current)},[]);function A(L){H(!0),c==null||c(L),F.current&&window.clearTimeout(F.current),F.current=window.setTimeout(()=>{H(!1),F.current=null},t)}async function T(L){var E;if(h&&L.stopPropagation(),p==null||p(L),L.defaultPrevented)return;const B=st(r);if(B)try{await ot(B),A(B)}catch(U){try{dr(B),A(B)}catch(D){b==null||b(D,B);return}(E=navigator.clipboard)!=null&&E.writeText||b==null||b(U,B)}}return e.jsxs("button",{...u,type:m,onClick:T,title:w?n:a,"aria-label":u["aria-label"]??(w?n:a),"data-copied":w?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center rounded-md transition-all duration-200 ${v?"min-w-7 px-2":"w-7"} ${N}`,style:{cursor:"pointer",background:w?"rgba(22,163,74,0.15)":"transparent",border:w?"1px solid rgba(22,163,74,0.4)":"1px solid transparent",color:w?"#16a34a":"var(--text-muted)",boxShadow:w?"0 0 0 3px rgba(22,163,74,0.12)":"none",...k},children:[e.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:w?"scale(1.15)":"scale(1)"},children:w?f:d}),v&&e.jsx("span",{className:"ml-2 text-xs font-medium",children:w?i??v:v})]})}function it(r,t){const a=typeof r=="function"?r():r;return t?t(a):a}function lt({url:r,resolveUrl:t,title:a="Copiar link",copiedTitle:n="Link copiado",icon:i=e.jsx(x.HiLink,{className:"h-3.5 w-3.5"}),...d}){return e.jsx(ur,{...d,value:()=>it(r,t),title:a,copiedTitle:n,icon:i})}function ct(r){var n;const t=Array.from(r.querySelectorAll("*")).filter(i=>{var d;return i.scrollWidth>i.clientWidth&&!!((d=i.textContent)!=null&&d.trim())&&i.tagName.toLowerCase()!=="svg"&&!i.closest("svg")});return(r.scrollWidth>r.clientWidth||t.length>0)&&(((n=t[0])==null?void 0:n.textContent)??r.textContent??"").trim()||null}function Ge({children:r,content:t,onlyWhenOverflow:a=!1,className:n="",style:i,as:d="div"}){const f=o.useRef(null),h=o.useRef(null),[c,b]=o.useState(null),[N,k]=o.useState("");o.useEffect(()=>{const m=f.current;m&&(m.querySelectorAll("[title]").forEach(u=>{const w=u.getAttribute("title");w&&(u.getAttribute("aria-label")||u.setAttribute("aria-label",w),u.removeAttribute("title"))}),m.querySelectorAll("svg title").forEach(u=>u.remove()))}),o.useLayoutEffect(()=>{if(!c)return;const m=h.current;if(!m)return;const u=12,w=14,H=m.getBoundingClientRect(),F=window.innerWidth-H.width-u,A=window.innerHeight-H.height-u;let T=c.mouseX+w,L=c.mouseY+w;T>F&&(T=c.mouseX-H.width-w),L>A&&(L=c.mouseY-H.height-w),T=Math.min(Math.max(u,T),Math.max(u,F)),L=Math.min(Math.max(u,L),Math.max(u,A)),(Math.abs(T-c.x)>.5||Math.abs(L-c.y)>.5)&&b(B=>B&&{...B,x:T,y:L})},[c]);const v=(m,u)=>{const w=f.current;if(w){if(a){const H=ct(w);if(!H)return;k(H)}!a&&!t||b({mouseX:m,mouseY:u,x:m+14,y:u+14})}},p=a?N:t;return e.jsxs(e.Fragment,{children:[e.jsx(d,{ref:m=>{f.current=m},className:n,style:i,onMouseEnter:m=>v(m.clientX,m.clientY),onMouseMove:m=>{c&&v(m.clientX,m.clientY)},onMouseLeave:()=>b(null),children:r}),c&&p?Le.createPortal(e.jsx("div",{ref:h,role:"tooltip",style:{position:"fixed",top:c.y,left:c.x,zIndex:9999,background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:6,padding:"5px 10px",fontSize:12,color:"var(--text-main)",boxShadow:"0 4px 16px rgba(0,0,0,0.35)",pointerEvents:"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere"},children:p}),document.body):null]})}const dt="[&_button]:h-7 [&_button]:min-h-0 [&_button]:gap-1 [&_button]:px-2 [&_button]:text-xs [&_button_svg]:h-3.5 [&_button_svg]:w-3.5 [&_button[data-icon=true]]:w-7 [&_button[data-icon=true]]:px-0";function $e(r){if(!r)return 150;const t=parseInt(r,10);return isNaN(t)||t<=0?150:t}function Ne(r,t){const a=r.minWidth??80,n=r.maxWidth??1/0;return Math.min(n,Math.max(a,t))}function ut(r,t){if(t<=7)return Array.from({length:t},(n,i)=>i+1);const a=[1];r>3&&a.push("...");for(let n=Math.max(2,r-1);n<=Math.min(t-1,r+1);n++)a.push(n);return r<t-2&&a.push("..."),a.push(t),a}function fr({children:r,className:t="",style:a}){return e.jsx(Ge,{onlyWhenOverflow:!0,className:t,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",...a},children:r})}function ft({columns:r,data:t,getRowId:a,loading:n=!1,skeletonRows:i=8,emptyIcon:d,emptyText:f="Sin resultados",onRowClick:h,selected:c,onToggleOne:b,onToggleAll:N,highlightSelected:k=!0,rowClassName:v,stickyHeader:p=!0,pageSize:m=25,pageSizeOptions:u=[25,50,100],pageSizeSelectWidth:w=62,pageSizeSelectHeight:H=30,pageSizeSelectPadding:F="0 7px",totalRows:A,page:T,onPageChange:L,onPageSizeChange:B,storageKey:E,stickyFirstColumn:U=!1,bottomOffset:D=0,compact:M=!0,restrictHeight:W=!0,minTableWidth:Z}){const j=r.map(l=>l.key).join(","),[q,Y]=o.useState(!E),Q=o.useRef(null),s=o.useRef(!E),S=(l,y)=>50+(l*17+y*13+7)%40,_=o.useRef(null),[X,V]=o.useState(void 0),[ee,fe]=o.useState(!1);o.useEffect(()=>{const y=m!==!1?32:0,$=12;function I(){if(fe(window.innerWidth<640),!_.current)return;const G=_.current.getBoundingClientRect().top;V(Math.max(120,window.innerHeight-G-y-$-D))}return I(),window.addEventListener("resize",I),()=>window.removeEventListener("resize",I)},[n,m,D]);const[re,be]=o.useState(()=>r.map(l=>l.key)),[pe,ve]=o.useState(()=>Object.fromEntries(r.map(l=>[l.key,Ne(l,$e(l.width))])));o.useEffect(()=>{const l=r.map($=>$.key);if(!E){be(l),s.current=!1,Y(!0);return}let y=!1;return s.current=!1,Y(!1),fetch(`/api/user/preferences/datatables?key=${encodeURIComponent(E)}`,{cache:"no-store"}).then($=>$.ok?$.json():null).then($=>{var Lr,Hr;if(y)return;const I=(Lr=$==null?void 0:$.settings)==null?void 0:Lr.columnOrder,G=Array.isArray(I)?I.filter(he=>l.includes(he)):[],ie=l.filter(he=>!G.includes(he)),R=G.length>0?[...G,...ie]:l,Me=Object.fromEntries(r.map(he=>[he.key,Ne(he,$e(he.width))])),te=((Hr=$==null?void 0:$.settings)==null?void 0:Hr.columnWidths)??{},Dr=Object.fromEntries(r.map(he=>[he.key,Ne(he,te[he.key]??Me[he.key])]));be(R),ve(Dr),Q.current=JSON.stringify({columnOrder:R,columnWidths:Dr}),s.current=!0}).catch(()=>{if(!y){be(l);const $=Object.fromEntries(r.map(I=>[I.key,Ne(I,$e(I.width))]));ve($),Q.current=JSON.stringify({columnOrder:l,columnWidths:$}),s.current=!0}}).finally(()=>{y||Y(!0)}),()=>{y=!0}},[E,j,r]),o.useEffect(()=>{if(!E||!q||!s.current)return;const l={columnOrder:re,columnWidths:pe},y=JSON.stringify(l);if(y===Q.current)return;const $=window.setTimeout(()=>{fetch("/api/user/preferences/datatables",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:E,settings:l})}).then(I=>{I.ok&&(Q.current=y)}).catch(()=>{})},300);return()=>window.clearTimeout($)},[re,pe,E,q]),o.useEffect(()=>{be(l=>{const y=r.map(G=>G.key),$=l.filter(G=>y.includes(G)),I=y.filter(G=>!$.includes(G));return[...$,...I]})},[j,r]);const ce=re.map(l=>r.find(y=>y.key===l)).filter(l=>!!l);o.useEffect(()=>{ve(l=>{const y=Object.fromEntries(r.map($=>[$.key,Ne($,$e($.width))]));return Object.fromEntries(r.map($=>[$.key,Ne($,l[$.key]??y[$.key])]))})},[j,r]);const C=o.useRef(null);o.useEffect(()=>{function l($){const I=C.current;if(!I)return;const G=$.clientX-I.startX,ie=r.find(R=>R.key===I.colKey);ie&&ve(R=>({...R,[I.colKey]:Ne(ie,I.startWidth+G)}))}function y(){C.current&&(C.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",l),document.addEventListener("pointerup",y),()=>{document.removeEventListener("pointermove",l),document.removeEventListener("pointerup",y)}},[r]);const z=o.useRef(null),[J,ae]=o.useState(null);function le(l,y){z.current=l,y.dataTransfer.effectAllowed="move"}function P(l,y){y.preventDefault(),y.dataTransfer.dropEffect="move",J!==l&&ae(l)}function we(l,y){y.preventDefault();const $=z.current;$!==null&&$!==l&&be(I=>{const G=[...I],[ie]=G.splice($,1);return G.splice(l,0,ie),G}),z.current=null,ae(null)}function je(){z.current=null,ae(null)}const[me,Be]=o.useState(null);function _e(l){l.sortKey&&Be(y=>(y==null?void 0:y.key)===l.key?{key:l.key,dir:y.dir==="asc"?"desc":"asc"}:{key:l.key,dir:"asc"})}const[ne,Ce]=o.useState(1),[Oe,We]=o.useState(m===!1?0:m);o.useEffect(()=>{Ce(1)},[t]);const ge=!!(L&&B),xe=m!==!1,de=ge?T??1:ne,g=ge||xe?Oe:t.length,K=!!c&&!!b&&!!N,oe=K?40:0,ke=K&&t.length>0&&c.size===t.length,se=K&&c.size>0&&c.size<t.length,Se=o.useMemo(()=>{if(!me)return t;const l=r.find(y=>y.key===me.key&&y.sortKey);return l!=null&&l.sortKey?[...t].sort((y,$)=>{const I=y[l.sortKey],G=$[l.sortKey],ie=I===G?0:I==null?1:G==null||I<G?-1:1;return me.dir==="asc"?ie:-ie}):t},[t,me,r]),Ee=o.useMemo(()=>{if(ge||!xe)return Se;const l=(de-1)*g;return Se.slice(l,l+g)},[Se,ge,xe,de,g]),De=A??t.length,Ve=xe?Math.max(1,Math.ceil(De/g)):1,ra=xe?(de-1)*g+1:1,ta=xe?Math.min(de*g,De):De;function Je(l){const y=Math.max(1,Math.min(l,Ve));ge?L(y):Ce(y)}function aa(l){We(l),ge?(B(l),L(1)):Ce(1),B&&B(l)}const Tr=l=>l==="center"?"text-center":l==="right"?"text-right":"text-left",na="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",Br=()=>e.jsxs("tr",{style:{background:"color-mix(in srgb, var(--bg-input) 72%, transparent)"},children:[K&&e.jsx("th",{className:`${M?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:U?{position:"sticky",left:0,zIndex:12,background:"color-mix(in srgb, var(--bg-input) 72%, transparent)",backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:"inset 0 -2px 0 var(--border)",borderRight:"1px solid var(--border)"}:{borderBottom:"2px solid var(--border)",borderRight:"1px solid var(--border)"},children:e.jsx("input",{type:"checkbox",checked:ke,ref:l=>{l&&(l.indeterminate=se)},onChange:N,className:"rounded cursor-pointer accent-[var(--primary)]"})}),ce.map((l,y)=>{const $=(me==null?void 0:me.key)===l.key,I=!!l.sortKey,G=U&&!ee&&y===0,ie=J===y,Me=(pe[l.key]??$e(l.width))<120;return e.jsxs("th",{className:`group select-none ${Me?"text-left":Tr(l.align)}`,style:{...G?{position:"sticky",left:oe,zIndex:12,background:"color-mix(in srgb, var(--bg-input) 72%, transparent)",backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:"3px 0 6px -2px rgba(0,0,0,0.12), inset 0 -2px 0 var(--border)",borderRight:"1px solid var(--border)"}:{position:"relative",borderBottom:"2px solid var(--border)",borderRight:"1px solid var(--border)"},color:$?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:ie?"2px solid var(--primary)":"2px solid transparent",cursor:I?"pointer":"default",padding:M?"5px 24px 5px 6px":"7px 28px 7px 6px"},onDragOver:te=>P(y,te),onDrop:te=>we(y,te),onClick:I?()=>_e(l):void 0,children:[e.jsx("span",{draggable:!0,onDragStart:te=>{te.stopPropagation(),le(y,te)},onDragEnd:te=>{te.stopPropagation(),je()},onClick:te=>te.stopPropagation(),title:"Arrastrar para reordenar",className:"inline-flex items-center mr-1 opacity-0 group-hover:opacity-40 transition-opacity",style:{cursor:"grab",color:"var(--text-muted)",verticalAlign:"middle"},children:e.jsx(Pr.MdDragIndicator,{size:15})}),e.jsx(fr,{className:"inline-block max-w-full align-middle",style:{width:"calc(100% - 22px)",textAlign:Me?"left":l.align==="center"?"center":l.align==="right"?"right":"left"},children:e.jsxs("span",{className:`inline-flex max-w-full items-center gap-1 font-semibold uppercase tracking-wider ${M?"text-[11px]":"text-xs"}`,children:[e.jsx("span",{className:"min-w-0 truncate",children:l.header}),I&&e.jsx("span",{className:"flex-shrink-0 opacity-60",children:$?me.dir==="asc"?e.jsx(x.HiChevronUp,{className:"w-3 h-3"}):e.jsx(x.HiChevronDown,{className:"w-3 h-3"}):e.jsx(x.HiChevronUpDown,{className:"w-3 h-3 opacity-40"})})]})}),e.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar",onPointerDown:te=>{te.preventDefault(),te.stopPropagation(),C.current={colKey:l.key,startX:te.clientX,startWidth:pe[l.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onClick:te=>te.stopPropagation(),className:"absolute right-0 top-0 h-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",style:{width:12,cursor:"col-resize",zIndex:3},children:e.jsx("span",{style:{width:3,height:"40%",borderRadius:2,background:"var(--primary)",display:"block"}})})]},l.key)})]}),Or=()=>{if(!xe||n)return null;const l=ut(de,Ve);return e.jsxs("div",{className:`flex items-center justify-between gap-2 rounded-b-xl border-t text-xs select-none ${M?"px-2 py-0.5":"px-3 py-1"}`,style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:De===0?"0 filas":`${ra}–${ta} de ${De}`}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),e.jsx(qe,{value:String(g),onChange:y=>aa(Number(y)),options:u.map(y=>({value:String(y),label:String(y)})),placeholder:"Filas",searchable:!1,height:H,padding:F,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:w}})]})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("button",{disabled:de<=1,onClick:()=>Je(de-1),className:"rounded p-0.5 transition-colors disabled:opacity-30",style:{color:"var(--text-muted)",background:"transparent"},children:e.jsx(x.HiChevronLeft,{className:"h-3.5 w-3.5"})}),l.map((y,$)=>y==="..."?e.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${$}`):e.jsx("button",{onClick:()=>Je(y),className:"h-5 w-5 rounded text-[11px] font-medium transition-colors",style:{background:y===de?"var(--primary)":"transparent",color:y===de?"var(--primary-fg)":"var(--text-muted)"},children:y},y)),e.jsx("button",{disabled:de>=Ve,onClick:()=>Je(de+1),className:"rounded p-0.5 transition-colors disabled:opacity-30",style:{color:"var(--text-muted)",background:"transparent"},children:e.jsx(x.HiChevronRight,{className:"h-3.5 w-3.5"})})]})]})};return n&&t.length===0?e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-xl overflow-visible",style:{border:"1px solid var(--border)"},children:[e.jsx("div",{ref:_,className:"min-w-0 max-w-full overflow-hidden rounded-t-xl",children:e.jsx(Ke.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:W?X:void 0,maxWidth:"100%"},defer:!0,children:e.jsxs("table",{className:"text-sm",style:{tableLayout:"fixed",width:"100%",minWidth:Z??"max-content",borderCollapse:"separate",borderSpacing:0},children:[e.jsxs("colgroup",{children:[K&&e.jsx("col",{style:{width:40}}),ce.map(l=>e.jsx("col",{style:{width:pe[l.key]??150}},l.key))]}),e.jsx("thead",{style:p?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Br()}),e.jsx("tbody",{children:Array.from({length:i}).map((l,y)=>e.jsxs("tr",{children:[K&&e.jsx("td",{className:`${M?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:"1px solid var(--border)",borderRight:"1px solid var(--border)"}}),ce.map(($,I)=>{const G=U&&!ee&&I===0;return e.jsx("td",{className:M?"px-2 py-1.5":"px-3 py-2",style:G?{position:"sticky",left:oe,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:"3px 0 6px -2px rgba(0,0,0,0.12), inset 0 -1px 0 var(--border)",borderRight:"1px solid var(--border)"}:{borderBottom:"1px solid var(--border)",borderRight:"1px solid var(--border)"},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${S(y,I)}%`,minWidth:32}})},$.key)})]},y))})]})})}),Or()]}):!n&&t.length===0?e.jsxs("div",{className:"py-20 flex flex-col items-center gap-3",children:[d&&e.jsx("div",{style:{color:"var(--text-muted)",opacity:.5},children:d}),e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:f})]}):e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-xl overflow-visible",style:{border:"1px solid var(--border)"},children:[e.jsx("div",{ref:_,className:"min-w-0 max-w-full overflow-hidden rounded-t-xl",children:e.jsx(Ke.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:W?X:void 0,maxWidth:"100%"},defer:!0,children:e.jsxs("table",{className:"text-sm",style:{tableLayout:"fixed",width:"100%",minWidth:Z??"max-content",borderCollapse:"separate",borderSpacing:0},children:[e.jsxs("colgroup",{children:[K&&e.jsx("col",{style:{width:40}}),ce.map(l=>e.jsx("col",{style:{width:pe[l.key]??150}},l.key))]}),e.jsx("thead",{style:p?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Br()}),e.jsx("tbody",{children:Ee.map((l,y)=>{const $=a(l),I=K&&c.has($),G=!!h,ie=I&&k?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":y%2===1?"color-mix(in srgb, var(--bg-input) 50%, var(--bg-card))":"var(--bg-card)";return e.jsxs("tr",{onClick:G?()=>h(l):void 0,className:`transition-colors ${G?"cursor-pointer":""} ${v?v(l):""}`,style:{"--dt-row-bg":ie,"--dt-sticky-bg":ie,background:"var(--dt-row-bg)"},onMouseEnter:R=>{I||(R.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),R.currentTarget.style.setProperty("--dt-sticky-bg",na))},onMouseLeave:R=>{R.currentTarget.style.setProperty("--dt-row-bg",ie),R.currentTarget.style.setProperty("--dt-sticky-bg",ie)},children:[K&&e.jsx("td",{className:`${M?"px-2 py-1.5":"px-3 py-2"} w-10`,style:U?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:"inset 0 -1px 0 var(--border)"}:{borderBottom:"1px solid var(--border)",borderRight:"1px solid var(--border)"},onClick:R=>{R.stopPropagation(),b($)},children:e.jsx("input",{type:"checkbox",checked:I,onClick:R=>R.stopPropagation(),onChange:()=>b($),className:"rounded cursor-pointer accent-[var(--primary)]"})}),ce.map((R,Me)=>{const te=U&&!ee&&Me===0;return e.jsx("td",{className:`${M?"px-2 py-1.5":"px-3 py-2"} ${dt} ${Tr(R.align)} ${R.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...te?{position:"sticky",left:oe,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:"3px 0 6px -2px rgba(0,0,0,0.12), inset 0 -1px 0 var(--border)",borderRight:"1px solid var(--border)"}:{borderBottom:"1px solid var(--border)",borderRight:"1px solid var(--border)"}},children:e.jsx(fr,{children:R.cell(l)})},R.key)})]},$)})})]})})}),Or()]})}function Te(r){return r?new Date(`${r}T12:00:00`):void 0}function pr(r){return r.toISOString().slice(0,10)}function pt({calendarMonth:r,displayIndex:t}){const{previousMonth:a,nextMonth:n,goToMonth:i,months:d,labels:f,formatters:h}=Qe.useDayPicker(),c=!!a&&t===0,b=!!n&&t===d.length-1;return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,width:"100%",color:"var(--text-main)",marginBottom:6},children:[e.jsx("span",{style:{fontWeight:700},children:h.formatCaption(r.date)}),e.jsx("button",{type:"button","aria-label":f.labelPrevious(a),onClick:()=>a&&i(a),disabled:!c,style:{height:28,width:28,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg-card)",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--text-main)",opacity:c?1:.45,cursor:c?"pointer":"not-allowed"},children:e.jsx(x.HiChevronLeft,{size:16})}),e.jsx("button",{type:"button","aria-label":f.labelNext(n),onClick:()=>n&&i(n),disabled:!b,style:{height:28,width:28,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg-card)",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--text-main)",opacity:b?1:.45,cursor:b?"pointer":"not-allowed"},children:e.jsx(x.HiChevronRight,{size:16})})]})}function ht(r){return r.charAt(0).toUpperCase()+r.slice(1)}function bt({startDate:r,endDate:t,onChange:a,minDate:n,viewMonth:i,numberOfMonths:d=1,showSummary:f=!0,startLabel:h="Inicio",endLabel:c="Regreso"}){const b={from:Te(r),to:Te(t)},N=Te(n),[k,v]=o.useState(Te(i||r));return o.useEffect(()=>{v(Te(i||r))},[i,r]),e.jsxs("div",{children:[e.jsx("div",{style:{borderRadius:10,overflow:"hidden",border:"1px solid var(--border)",background:"var(--bg-input)",display:"flex",justifyContent:"center",padding:"10px 8px"},children:e.jsx(Qe.DayPicker,{mode:"range",selected:b,month:k,onMonthChange:v,onSelect:p=>{const m=p!=null&&p.from?pr(p.from):r,u=p!=null&&p.to?pr(p.to):"";a({startDate:m,endDate:u})},numberOfMonths:d,hideNavigation:!0,disabled:N?{before:N}:void 0,showOutsideDays:!1,components:{MonthCaption:pt},className:"text-sm",classNames:{root:"w-full",months:"flex gap-3 justify-center",month:"space-y-2",month_caption:"flex items-center justify-between px-1",caption_label:"capitalize",nav:"flex items-center gap-1",button_previous:"h-8 w-8 inline-flex items-center justify-center rounded-md transition-colors",button_next:"h-8 w-8 inline-flex items-center justify-center rounded-md transition-colors",month_grid:"w-full border-collapse",weekdays:"grid grid-cols-7 gap-1 mb-1",weekday:"text-[11px] font-semibold text-center",week:"grid grid-cols-7 gap-1",day:"h-9 w-9 p-0 flex items-center justify-center",day_button:"h-9 w-9 rounded-md text-sm font-medium transition-colors outline-none",selected:"font-semibold",range_start:"font-semibold",range_middle:"font-medium",range_end:"font-semibold",today:"font-bold",disabled:"opacity-40 cursor-not-allowed",hidden:"invisible"},styles:{month_caption:{color:"var(--text-main)",marginBottom:6,display:"flex",alignItems:"center",justifyContent:"space-between"},caption_label:{color:"var(--text-main)",fontWeight:700},nav:{position:"static",display:"flex",alignItems:"center",gap:6},weekday:{color:"var(--text-muted)",textTransform:"lowercase"},button_previous:{height:32,width:32,background:"var(--bg-card)",color:"var(--text-main)",border:"1px solid var(--border)"},button_next:{height:32,width:32,background:"var(--bg-card)",color:"var(--text-main)",border:"1px solid var(--border)"},day_button:{color:"var(--text-main)",borderRadius:8},chevron:{fill:"var(--text-main)"},today:{border:"1px solid color-mix(in srgb, var(--primary) 35%, transparent)"},disabled:{color:"var(--text-muted)"}},modifiersStyles:{selected:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_start:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_end:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_middle:{background:"color-mix(in srgb, var(--primary) 20%, transparent)",color:"var(--text-main)"}},formatters:{formatCaption:p=>ht(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(p)),formatWeekdayName:p=>new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(p)},labels:{labelMonthDropdown:()=>"Mes",labelYearDropdown:()=>"Año"}})}),f&&r&&e.jsxs("div",{style:{marginTop:8,fontSize:12,color:"var(--text-muted)",display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsxs("span",{children:[h,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:r})]}),t&&e.jsxs("span",{children:[c,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:t})]})]})]})}function mt({open:r,onClose:t,title:a,subtitle:n,leadingIcon:i,confirmLabel:d="Guardar",onConfirm:f,loading:h=!1,confirmDisabled:c=!1,headerActions:b,bodyClassName:N="flex-1 overflow-y-auto px-6 py-5",width:k=440,children:v}){const[p,m]=o.useState(!1);return o.useEffect(()=>{m(!0)},[]),o.useEffect(()=>(document.body.style.overflow=r?"hidden":"",()=>{document.body.style.overflow=""}),[r]),o.useEffect(()=>{if(!r)return;const u=w=>{w.key==="Escape"&&t()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[r,t]),p?Le.createPortal(e.jsxs("div",{"aria-hidden":!r,className:`fixed inset-0 z-[1000] flex transition-opacity duration-300 ${r?"opacity-100":"opacity-0 pointer-events-none"}`,children:[e.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm",onClick:t}),e.jsxs("div",{className:`absolute inset-y-0 right-0 flex flex-col shadow-2xl transition-transform duration-300 ${r?"translate-x-0":"translate-x-full"}`,style:{width:`min(100vw, ${k}px)`,background:"var(--bg-card)",borderLeft:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 flex-shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(ue,{variant:"icon",onClick:t,title:"Cerrar",children:e.jsx(x.HiXMark,{className:"w-5 h-5"})}),i&&e.jsx("div",{className:"flex-shrink-0",children:i}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-base font-semibold truncate",style:{color:"var(--text-main)"},children:a}),n&&e.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:n})]})]}),(b||f)&&e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[b,f&&e.jsxs(e.Fragment,{children:[e.jsx(ue,{variant:"secondary",size:"sm",onClick:t,style:{background:"var(--bg-input)"},children:"Cancelar"}),e.jsx(ue,{variant:"primary",size:"sm",icon:e.jsx(Ir.FiSave,{className:"w-4 h-4"}),onClick:f,loading:h,disabled:c,title:d})]})]})]}),e.jsx("div",{"data-drawer-scroll":"true",className:N,children:v})]})]}),document.body):null}var hr={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},br=o.createContext&&o.createContext(hr),vt=["attr","size","title"];function gt(r,t){if(r==null)return{};var a,n,i=xt(r,t);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(r);for(n=0;n<d.length;n++)a=d[n],t.indexOf(a)===-1&&{}.propertyIsEnumerable.call(r,a)&&(i[a]=r[a])}return i}function xt(r,t){if(r==null)return{};var a={};for(var n in r)if({}.hasOwnProperty.call(r,n)){if(t.indexOf(n)!==-1)continue;a[n]=r[n]}return a}function Ie(){return Ie=Object.assign?Object.assign.bind():function(r){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(r[n]=a[n])}return r},Ie.apply(null,arguments)}function mr(r,t){var a=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable})),a.push.apply(a,n)}return a}function Ae(r){for(var t=1;t<arguments.length;t++){var a=arguments[t]!=null?arguments[t]:{};t%2?mr(Object(a),!0).forEach(function(n){yt(r,n,a[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(a)):mr(Object(a)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(a,n))})}return r}function yt(r,t,a){return(t=wt(t))in r?Object.defineProperty(r,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[t]=a,r}function wt(r){var t=Nt(r,"string");return typeof t=="symbol"?t:t+""}function Nt(r,t){if(typeof r!="object"||!r)return r;var a=r[Symbol.toPrimitive];if(a!==void 0){var n=a.call(r,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function vr(r){return r&&r.map((t,a)=>o.createElement(t.tag,Ae({key:a},t.attr),vr(t.child)))}function gr(r){return t=>o.createElement(kt,Ie({attr:Ae({},r.attr)},t),vr(r.child))}function kt(r){var t=a=>{var{attr:n,size:i,title:d}=r,f=gt(r,vt),h=i||a.size||"1em",c;return a.className&&(c=a.className),r.className&&(c=(c?c+" ":"")+r.className),o.createElement("svg",Ie({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,n,f,{className:c,style:Ae(Ae({color:r.color||a.color},a.style),r.style),height:h,width:h,xmlns:"http://www.w3.org/2000/svg"}),d&&o.createElement("title",null,d),r.children)};return br!==void 0?o.createElement(br.Consumer,null,a=>t(a)):t(hr)}function St(r){return gr({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M247.31,124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57,61.26,162.88,48,128,48S61.43,61.26,36.34,86.35C17.51,105.18,9,124,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208s66.57-13.26,91.66-38.34c18.83-18.83,27.3-37.61,27.65-38.4A8,8,0,0,0,247.31,124.76ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.47,133.47,0,0,1,25,128,133.33,133.33,0,0,1,48.07,97.25C70.33,75.19,97.22,64,128,64s57.67,11.19,79.93,33.25A133.46,133.46,0,0,1,231.05,128C223.84,141.46,192.43,192,128,192Zm0-112a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Z"},child:[]}]})(r)}function Ct(r){return gr({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M228,175a8,8,0,0,1-10.92-3l-19-33.2A123.23,123.23,0,0,1,162,155.46l5.87,35.22a8,8,0,0,1-6.58,9.21A8.4,8.4,0,0,1,160,200a8,8,0,0,1-7.88-6.69l-5.77-34.58a133.06,133.06,0,0,1-36.68,0l-5.77,34.58A8,8,0,0,1,96,200a8.4,8.4,0,0,1-1.32-.11,8,8,0,0,1-6.58-9.21L94,155.46a123.23,123.23,0,0,1-36.06-16.69L39,172A8,8,0,1,1,25.06,164l20-35a153.47,153.47,0,0,1-19.3-20A8,8,0,1,1,38.22,99c16.6,20.54,45.64,45,89.78,45s73.18-24.49,89.78-45A8,8,0,1,1,230.22,109a153.47,153.47,0,0,1-19.3,20l20,35A8,8,0,0,1,228,175Z"},child:[]}]})(r)}function ze({className:r="",...t}){return e.jsx("input",{...t,className:`h-11 rounded-lg border border-[var(--border)] bg-[var(--bg-input)] px-3 py-2 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] ${r}`})}function Et({label:r,containerClassName:t="",helperText:a,error:n,labelAction:i,floatingLabel:d=!1,showPasswordToggle:f=!0,className:h="",required:c,...b}){const[N,k]=o.useState(()=>!!b.autoFocus),[v,p]=o.useState(!1),m=b.type==="password"&&f,u=m&&v?"text":b.type,w=b.value!==void 0?String(b.value).length>0:b.defaultValue!==void 0&&String(b.defaultValue).length>0,H=N||w,F={top:H?8:15,color:N?"var(--primary)":"var(--text-muted)",fontSize:H?11:14,fontWeight:H?600:400,textTransform:H?"uppercase":"none"},A=B=>{var E;k(!0),(E=b.onFocus)==null||E.call(b,B)},T=B=>{var E;k(!1),(E=b.onBlur)==null||E.call(b,B)},L=m?e.jsxs("button",{type:"button","aria-label":v?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":v,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors duration-200 hover:text-[var(--primary)] focus:outline-none",tabIndex:-1,onClick:()=>p(B=>!B),children:[e.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${v?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:e.jsx(St,{className:"h-[18px] w-[18px]"})}),e.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${v?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:e.jsx(Ct,{className:"h-[18px] w-[18px]"})})]}):null;return d?e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"relative block",children:[e.jsx(ze,{...b,type:u,required:c,placeholder:" ","aria-invalid":!!n||b["aria-invalid"],"data-has-value":w?"true":void 0,className:`h-12 w-full pt-5 ${m?"pr-10":""} ${h}`,onFocus:A,onBlur:T}),e.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:F,children:[r,c&&e.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),i&&e.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:H?8:15},children:i}),L]}),n?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]}):e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e.jsx("span",{children:r}),c&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),i&&e.jsx("span",{className:"ml-auto normal-case",children:i})]}),m?e.jsxs("span",{className:"relative block",children:[e.jsx(ze,{...b,type:u,required:c,"aria-invalid":!!n||b["aria-invalid"],className:`w-full pr-10 ${h}`,onFocus:A,onBlur:T}),L]}):e.jsx(ze,{...b,required:c,"aria-invalid":!!n||b["aria-invalid"],className:h}),n?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]})}function ye(...r){return r.filter(Boolean).join(" ")}function Mt({steps:r,activeStepId:t,initialStepId:a,completedStepIds:n,defaultCompletedStepIds:i=[],onActiveStepChange:d,onCompletedStepIdsChange:f,onBlockedStep:h,allowBackNavigation:c=!0,showFooter:b=!0,previousLabel:N="Anterior",nextLabel:k="Siguiente",blockedNextLabel:v="Completa este paso",className:p="",headerClassName:m="",contentClassName:u="",footerClassName:w=""}){var ce;const H=((ce=r[0])==null?void 0:ce.id)??"",[F,A]=o.useState(a??H),[T,L]=o.useState(i),B=t??F,E=n??T,U=o.useMemo(()=>new Set(E),[E]),D=Math.max(0,r.findIndex(C=>C.id===B)),M=r[D]??r[0],W=r.length<=1?100:D/(r.length-1)*100,Z=C=>{n||L(C),f==null||f(C)},j=C=>{const z=r.find(J=>J.id===C);z&&(t||A(C),d==null||d(C,z))},q=C=>U.has(C),Y=C=>r.slice(0,C).find(z=>!z.optional&&!U.has(z.id)),Q=C=>{const z=r[C];return!z||z.disabled?!1:C===D||c&&C<D?!0:!Y(C)},s=C=>{const z=r.findIndex(J=>J.id===C);return z>=0&&Q(z)},S=C=>{const z=r.findIndex(J=>J.id===C);if(z<0)return!1;if(!Q(z)){const J=Y(z);return J&&(h==null||h(r[z],J)),!1}return j(C),!0},_=(C=M==null?void 0:M.id)=>{!C||U.has(C)||Z([...E,C])},X=(C=M==null?void 0:M.id)=>{if(!C)return;const z=r.findIndex(ae=>ae.id===C),J=E.filter(ae=>{const le=r.findIndex(P=>P.id===ae);return le>=0&&le<z});Z(J),z>=0&&D>z&&j(C)},V=()=>D<=0?!1:S(r[D-1].id),ee=()=>{const C=r[D+1];return C?S(C.id):!1},fe={activeStep:M,activeIndex:D,completedStepIds:E,isCompleted:q,isUnlocked:s,completeStep:_,uncompleteStep:X,goToStep:S,goNext:ee,goPrevious:V};if(!M)return null;const re=r[D+1],be=D>0,pe=re?s(re.id):!1,ve=typeof M.content=="function"?M.content(fe):M.content;return e.jsxs("section",{className:ye("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",p),children:[e.jsxs("div",{className:ye("border-b border-[var(--border)] bg-[var(--bg-input)]",m),children:[e.jsx("div",{className:"relative h-1 overflow-hidden bg-[var(--border)]/55",children:e.jsx("div",{className:"h-full rounded-r-full bg-[var(--primary)] transition-[width] duration-500 ease-out",style:{width:`${W}%`}})}),e.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${r.length}, minmax(0, 1fr))`},children:r.map((C,z)=>{const J=C.id===M.id,ae=q(C.id),le=Q(z),P=Y(z);return e.jsxs("button",{type:"button",disabled:!le,"aria-current":J?"step":void 0,"aria-disabled":!le,title:!le&&P?`Completa ${P.title}`:C.title,onClick:()=>S(C.id),className:ye("group relative min-h-16 min-w-0 overflow-hidden rounded-md border p-3 text-left transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/35 disabled:cursor-not-allowed",J&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",ae&&!J&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!J&&!ae&&le&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!le&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[e.jsx("span",{className:ye("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",J&&"scale-x-100")}),e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:ye("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",J&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",ae&&!J&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!ae&&!J&&le&&"border-[var(--border)] text-[var(--text-muted)]",!le&&"border-[var(--border)] text-[var(--text-muted)]"),children:ae?e.jsx(x.HiCheck,{className:"h-4 w-4"}):le?z+1:e.jsx(x.HiLockClosed,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:ye("block truncate text-xs font-semibold transition-colors duration-200",J?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[z+1,". ",C.title]}),C.description&&e.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:C.description})]}),C.badge&&e.jsx("span",{className:"shrink-0",children:C.badge})]})]},C.id)})})]}),e.jsx("div",{className:ye("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",u),children:ve},M.id),b&&e.jsxs("div",{className:ye("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",w),children:[e.jsx(ue,{variant:"secondary",height:38,padding:"0 14px",icon:e.jsx(x.HiChevronLeft,{}),disabled:!be,onClick:V,children:N}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[e.jsxs("span",{children:["Paso ",D+1," de ",r.length]}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),e.jsxs("span",{children:[E.length," completados"]})]}),e.jsx(ue,{height:38,padding:"0 14px",icon:e.jsx(x.HiChevronRight,{}),disabled:!re||!pe,onClick:ee,children:re&&!pe?v:k})]})]})}const $t={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function Tt({checked:r,disabled:t,onCheckedChange:a,size:n="sm",className:i="",...d}){const f=$t[n],h=r?f.width-f.thumb-f.padding*2:0;return e.jsx("button",{...d,type:"button",role:"switch","aria-checked":r,disabled:t,onClick:()=>!t&&a(!r),className:`relative inline-flex shrink-0 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/50 disabled:cursor-not-allowed disabled:opacity-50 ${i}`,style:{width:f.width,height:f.height,background:r?"color-mix(in srgb, var(--primary) 85%, transparent)":"var(--bg-input)",border:r?"1px solid color-mix(in srgb, var(--primary) 55%, transparent)":"1px solid var(--border)"},children:e.jsx("span",{className:"absolute inline-block rounded-full transition-transform",style:{width:f.thumb,height:f.thumb,left:f.padding,top:"50%",transform:`translate(${h}px, -50%)`,background:r?"var(--primary-fg)":"var(--text-muted)"}})})}const xr=[".sidebar-scroll","[data-overlay-scroll='true']"].join(",");function Bt(r){if(!(r instanceof HTMLElement)||r.dataset.overlayScroll==="false"||r.closest("[data-overlayscrollbars]")||r.matches("textarea,input,select,[contenteditable='true']"))return!1;const t=window.getComputedStyle(r);return!(![t.overflow,t.overflowX,t.overflowY].join(" ").match(/auto|scroll/)||r.clientWidth===0&&r.clientHeight===0)}function yr(r){return r.classList.contains("sidebar-scroll")}function wr(r){yr(r)&&r.querySelectorAll(".os-scrollbar-horizontal").forEach(t=>{t.style.display="none",t.style.height="0",t.style.pointerEvents="none"})}function Nr(){return o.useEffect(()=>{const r=new WeakMap;let t=0;const a=()=>{t=0,document.querySelectorAll(xr).forEach(d=>{if(!Bt(d))return;if(Ze.OverlayScrollbars(d)){wr(d);return}const h=Ze.OverlayScrollbars(d,{overflow:yr(d)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}});wr(d),r.set(d,h)})},n=()=>{t||(t=window.requestAnimationFrame(a))};a();const i=new MutationObserver(n);return i.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","data-overlay-scroll"]}),window.addEventListener("resize",n),()=>{t&&window.cancelAnimationFrame(t),i.disconnect(),window.removeEventListener("resize",n),document.querySelectorAll(xr).forEach(d=>{var f;d instanceof HTMLElement&&((f=r.get(d))==null||f.destroy())})}},[]),null}const Ot={xs:{wh:"w-5 h-5",text:"text-[8px]"},sm:{wh:"w-7 h-7",text:"text-[11px]"},md:{wh:"w-9 h-9",text:"text-sm"},lg:{wh:"w-12 h-12",text:"text-base"},xl:{wh:"w-16 h-16",text:"text-xl"}},kr=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],Dt={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Lt="bonsaif.bot",Ht="Bonsaif Bot",Pt={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Sr(r){return typeof r=="string"?r.trim():""}function It(r){let t=0;for(const a of r)t=t*31+a.charCodeAt(0)&65535;return kr[t%kr.length]}function At(r,t){return r===Lt||t===Ht}function Cr({userId:r,username:t,name:a,size:n="md",showName:i=!1,showTooltip:d,tooltipContent:f,fallbackLabel:h="Usuario",wrapperClassName:c="",labelClassName:b="",labelSize:N="xs",avatarVersion:k=0,className:v="",style:p}){var j;const[m,u]=o.useState(!1),w=typeof r=="string"&&r.trim()&&r!=="undefined"&&r!=="null"?r.trim():"";o.useEffect(()=>{u(!1)},[w,k]);const{wh:H,text:F}=Ot[n],A=Sr(a)||Sr(t)||h,T=A.trim()[0]||"?",L=typeof process<"u"&&((j=process.env)==null?void 0:j.NEXT_PUBLIC_BASE_PATH)||"",B=At(t,a),E=w?`${L}/api/user/avatar/${w}${k?`?v=${k}`:""}`:"",D={xs:20,sm:28,md:36,lg:48,xl:64}[n],M=B?e.jsx("span",{className:`${H} ${Pt[n]} rounded-full flex items-center justify-center bg-[#071f1a] ring-1 ring-emerald-400/35 shadow-[0_0_0_1px_rgba(255,255,255,0.06)] flex-shrink-0 ${v}`,style:p,children:e.jsx("img",{src:`${L}/favicon.svg`,alt:A,width:D,height:D,className:"h-full w-full object-contain"})}):E&&!m?e.jsx("img",{src:E,alt:A,width:D,height:D,className:`${H} rounded-full object-cover flex-shrink-0 ${v}`,style:p,onError:()=>u(!0)},`${w}-${k}`):e.jsx("span",{className:`${H} ${It(A)} ${F} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${v}`,style:p,title:A,children:T});if(i)return e.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${c}`,children:[M,e.jsx("span",{className:`min-w-0 truncate ${Dt[N]} font-medium text-[var(--text-main)] ${b}`,title:A,children:A})]});const W=d??!0,Z=f??A;return W&&Z?e.jsx(Ge,{as:"span",content:Z,className:`inline-flex flex-shrink-0 ${c}`,children:M}):M}function zt({href:r,className:t,children:a}){return e.jsx("a",{href:r,className:t,children:a})}function jt(r){return r.reduce((t,a)=>{const n=a.section??"Principal";return t[n]=[...t[n]??[],a],t},{})}function Er({children:r,navItems:t=[],currentPath:a=typeof window>"u"?"/":window.location.pathname,user:n,appName:i="Bonsaif",appLogo:d,header:f,footer:h,onLogout:c,LinkComponent:b=zt}){const[N,k]=o.useState(!1),v=jt(t);return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[e.jsx(Nr,{}),e.jsx("button",{type:"button","aria-label":"Abrir navegación",className:"fixed left-3 top-3 z-50 inline-flex h-9 w-9 items-center justify-center rounded-md border border-white/10 bg-black/70 text-white lg:hidden",onClick:()=>k(!0),children:e.jsx(x.HiBars3,{className:"h-5 w-5"})}),N&&e.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>k(!1)}),e.jsxs("aside",{className:`fixed inset-y-0 left-0 z-50 flex w-72 flex-col bg-[#071716] text-white shadow-2xl transition-transform duration-200 lg:translate-x-0 ${N?"translate-x-0":"-translate-x-full"}`,children:[e.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:d??e.jsx(x.HiHome,{className:"h-5 w-5"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:i}),e.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-white/70 hover:bg-white/10 lg:hidden",onClick:()=>k(!1),children:e.jsx(x.HiXMark,{className:"h-5 w-5"})})]}),e.jsx("nav",{className:"sidebar-scroll min-h-0 flex-1 overflow-y-auto px-3 py-4","data-overlay-scroll":"true",children:Object.entries(v).map(([p,m])=>e.jsxs("div",{className:"mb-5",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-white/35",children:[e.jsx(x.HiChevronDown,{className:"h-3.5 w-3.5"}),p]}),e.jsx("div",{className:"space-y-1",children:m.map(u=>{const w=a===u.href||a.startsWith(`${u.href}/`);return e.jsxs(b,{href:u.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${w?"bg-white/10 text-white":"text-white/55 hover:bg-white/[0.06] hover:text-white/85"}`,children:[e.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:u.icon??e.jsx(x.HiHome,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate",children:u.label})]},u.href)})})]},p))}),e.jsxs("div",{className:"border-t border-white/10 p-3",children:[n&&e.jsxs("div",{className:"mb-3 flex min-w-0 items-center gap-3 rounded-lg bg-white/[0.04] p-2",children:[e.jsx(Cr,{name:n.initials??n.name??n.email??"Usuario",size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-medium text-white",children:n.name??"Usuario"}),n.email&&e.jsx("div",{className:"truncate text-xs text-white/45",children:n.email})]})]}),c&&e.jsxs(ue,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:c,children:[e.jsx(x.HiArrowRightOnRectangle,{className:"h-4 w-4"})," Salir"]}),h]})]}),e.jsxs("div",{className:"min-h-screen lg:pl-72",children:[f,e.jsx("main",{className:"min-h-screen",children:r})]})]})}const _t={dashboard:"Dashboard",tickets:"Tickets",teams:"Equipos",projects:"Proyectos",clients:"Clientes",surveys:"Encuestas",profile:"Perfil",settings:"Configuración",notifications:"Notificaciones",changelog:"Historial",admin:"Inicio",users:"Usuarios",roles:"Roles",menus:"Menús",guards:"Guardias",vacations:"Vacaciones",audit:"Auditoría",positions:"Puestos",ranks:"Rangos","email-inbox":"Buzones","security-incidents":"Incidentes","guard-schedule":"Guardias"},Ye={dashboard:e.jsx(x.HiChartBar,{className:"h-5 w-5"}),tickets:e.jsx(x.HiTicket,{className:"h-5 w-5"}),teams:e.jsx(x.HiUsers,{className:"h-5 w-5"}),projects:e.jsx(x.HiRectangleGroup,{className:"h-5 w-5"}),clients:e.jsx(x.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:e.jsx(x.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:e.jsx(x.HiUser,{className:"h-5 w-5"}),settings:e.jsx(x.HiCog6Tooth,{className:"h-5 w-5"}),notifications:e.jsx(x.HiBell,{className:"h-5 w-5"}),changelog:e.jsx(x.HiDocumentText,{className:"h-5 w-5"}),admin:e.jsx(x.HiShieldCheck,{className:"h-5 w-5"}),users:e.jsx(x.HiUsers,{className:"h-5 w-5"}),roles:e.jsx(x.HiShieldCheck,{className:"h-5 w-5"}),menus:e.jsx(x.HiCog6Tooth,{className:"h-5 w-5"}),guards:e.jsx(x.HiCalendarDays,{className:"h-5 w-5"}),vacations:e.jsx(x.HiCalendarDays,{className:"h-5 w-5"}),audit:e.jsx(x.HiListBullet,{className:"h-5 w-5"}),positions:e.jsx(x.HiBriefcase,{className:"h-5 w-5"}),ranks:e.jsx(x.HiListBullet,{className:"h-5 w-5"}),"email-inbox":e.jsx(x.HiInbox,{className:"h-5 w-5"}),"security-incidents":e.jsx(x.HiShieldCheck,{className:"h-5 w-5"})};function Wt({href:r,className:t,style:a,children:n}){return e.jsx("a",{href:r,className:t,style:a,children:n})}function Ft(r){return r.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Ut(r){return/^\d+$/.test(r)||/^[a-f0-9]{8,}$/i.test(r)}function qt(r){const t=r.split("/").filter(Boolean);if(t.length===0||t.length===1&&t[0]==="dashboard")return[];const a=decodeURIComponent(t[t.length-1]),n=t.length>1?decodeURIComponent(t[t.length-2]):void 0,i=Ut(a)&&n?n:a,d=_t[i]??Ft(i);return[{label:"Inicio",href:"/"},{label:d}]}function Xe(r){return(r==null?void 0:r.querySelector(":scope > .os-viewport"))??(r==null?void 0:r.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function Gt(r){const t=r.split("/").filter(Boolean),a=t[t.length-1];if(!a)return e.jsx(x.HiHome,{className:"h-5 w-5"});if(Ye[a])return Ye[a];const n=t.length>1?t[t.length-2]:"";return Ye[n]??e.jsx(x.HiHome,{className:"h-5 w-5"})}function Yt({title:r,subtitle:t,action:a,meta:n,icon:i,className:d="",contentClassName:f="",breadcrumbs:h,currentPath:c=typeof window>"u"?"/":window.location.pathname,showBreadcrumbs:b=!0,contained:N=!1,LinkComponent:k=Wt}){const v=o.useRef(null),[p,m]=o.useState(!1),[u,w]=o.useState(null),H=h??qt(c),F=i??Gt(c),A=b&&H.length>1;return o.useEffect(()=>{if(N){m(!1);return}let T=null,L=0,B=0;const E=()=>{const M=v.current,W=document.querySelector("[data-app-scroll='true']");return(M==null?void 0:M.closest(".os-viewport"))??(M==null?void 0:M.closest("[data-overlayscrollbars-viewport]"))??Xe(W)??W??window},U=()=>{const M=T&&T!==window?T.scrollTop:window.scrollY;m(W=>W?M>24:M>72)},D=()=>{T==null||T.removeEventListener("scroll",U),T=E(),T.addEventListener("scroll",U,{passive:!0}),U()};return D(),L=window.requestAnimationFrame(D),B=window.setTimeout(D,120),()=>{window.cancelAnimationFrame(L),window.clearTimeout(B),T==null||T.removeEventListener("scroll",U)}},[N]),o.useEffect(()=>{if(N){w(null);return}let T=0;const L=[],B=()=>{const j=v.current,q=j==null?void 0:j.parentElement,Y=document.querySelector("[data-app-scroll='true']"),Q=Xe(Y)??Y;if(!j||!q||!Q){w(null);return}const s=q.getBoundingClientRect(),S=window.getComputedStyle(q),_=Q.getBoundingClientRect(),X=Q instanceof HTMLElement&&Q.clientWidth>0?Q.clientWidth:_.width,V=s.left+parseFloat(S.paddingLeft||"0"),ee={marginLeft:Math.round(_.left-V),width:Math.round(X)};w(fe=>fe&&fe.marginLeft===ee.marginLeft&&fe.width===ee.width?fe:ee)},E=()=>{window.cancelAnimationFrame(T),T=window.requestAnimationFrame(B)};E(),window.addEventListener("resize",E);const U=new ResizeObserver(E),D=v.current,M=D==null?void 0:D.parentElement,W=document.querySelector("[data-app-scroll='true']"),Z=Xe(W)??W;return[M,W,Z].forEach(j=>{j&&U.observe(j)}),L.push(window.setTimeout(E,120)),L.push(window.setTimeout(E,280)),()=>{window.cancelAnimationFrame(T),window.removeEventListener("resize",E),U.disconnect(),L.forEach(j=>window.clearTimeout(j))}},[N]),e.jsx("div",{ref:v,"data-page-header":"true","data-compact":p?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${N?"mb-0 flex-shrink-0":"mb-6 sm:mb-1"} ${d}`,style:{...u?{marginLeft:u.marginLeft,width:u.width}:null,background:N?"var(--bg-card)":p?"var(--bg-main)":"color-mix(in srgb, var(--bg-main) 44%, transparent)",backdropFilter:"saturate(1.2) blur(14px)",WebkitBackdropFilter:"saturate(1.2) blur(14px)",borderBottom:N||p?"1px solid var(--border)":"1px solid transparent",boxShadow:p?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"},children:e.jsxs("div",{className:`flex flex-wrap items-center justify-between px-4 pt-0.5 transition-[gap,min-height,padding] duration-300 ease-out ${p?"min-h-10 gap-2 sm:min-h-11 sm:gap-3":"min-h-11 gap-3 sm:min-h-12 sm:gap-4"} ${f}`,children:[e.jsxs("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${p?"gap-1":"gap-1.5 sm:gap-2"}`,children:[A&&e.jsx("nav",{"aria-label":"Breadcrumb",className:"min-w-0 flex-shrink-0 transition-[opacity,transform] duration-300 ease-out",children:e.jsx("ol",{className:`flex flex-wrap items-center gap-1.5 leading-none transition-[font-size,line-height] duration-300 ease-out ${p?"text-[10px] sm:text-[11px]":"text-[11px] sm:text-xs"}`,children:H.map((T,L)=>{const B=L===H.length-1;return e.jsxs("li",{className:"flex min-w-0 items-center gap-1.5",children:[L>0&&e.jsx(x.HiChevronRight,{className:"h-3.5 w-3.5 transition-[color,transform] duration-300 ease-out",style:{color:"var(--text-muted)"}}),T.href&&!B?e.jsx(k,{href:T.href,className:"truncate transition-colors duration-300 hover:underline",style:{color:"var(--text-muted)"},children:T.label}):e.jsx("span",{"aria-current":B?"page":void 0,className:B?"truncate font-semibold":"truncate",style:{color:B?"var(--text-main)":"var(--text-muted)"},children:T.label})]},`${T.label}-${L}`)})})}),e.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${p?"gap-2":"gap-2.5 sm:gap-3"}`,children:[e.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${p?"scale-90 opacity-80":"scale-100 opacity-100"}`,style:{color:A?"var(--text-secondary)":"var(--text-muted)"},children:F}),e.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${p?"gap-x-2 gap-y-1":"gap-x-3 gap-y-2"}`,children:[e.jsxs("div",{className:"min-w-0 flex-shrink transition-[transform] duration-300 ease-out",children:[e.jsx("h1",{className:`truncate font-bold tracking-tight transition-[font-size,line-height,color] duration-300 ease-out ${p?"text-lg sm:text-xl":"text-xl sm:text-2xl"}`,style:{color:"var(--text-main)"},children:r}),t&&e.jsx("p",{"aria-hidden":p,className:`overflow-hidden text-sm transition-[max-height,opacity,transform,margin] duration-300 ease-out ${p?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-6 translate-y-0 opacity-100 sm:mt-1"}`,style:{color:"var(--text-muted)"},children:t})]}),n&&e.jsx("div",{className:`page-header-meta flex min-w-0 flex-1 basis-full items-center overflow-visible transition-[gap,opacity,transform] duration-300 ease-out sm:basis-auto ${p?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:n})]})]})]}),a&&e.jsx("div",{className:`page-header-actions flex flex-shrink-0 items-center self-center overflow-visible transition-[gap,min-height,opacity,transform] duration-300 ease-out ${p?"min-h-10 gap-1.5 opacity-95":"min-h-11 gap-2 opacity-100"}`,children:a})]})})}function Xt({children:r,currentPath:t=typeof window>"u"?"/":window.location.pathname,publicRoutes:a=["/","/login","/reset-password"],...n}){return a.includes(t)?e.jsx(e.Fragment,{children:r}):e.jsx(Er,{currentPath:t,...n,children:r})}function Mr(){if(typeof window>"u")return"system";const r=localStorage.getItem("theme");return r==="light"||r==="dark"?r:r==="system"?"system":document.documentElement.classList.contains("dark")?"dark":"light"}function Vt(r,t,a){try{const n=new URL(r),i=n.searchParams.get("callbackUrl");if(i){const d=new URL(i,n.origin);return d.searchParams.set("theme",t),a&&(d.searchParams.set("primeAuthOrigin",window.location.origin),d.searchParams.set("primeAuthProjectKey",a)),n.searchParams.set("callbackUrl",`${d.pathname}${d.search}${d.hash}`),n.toString()}return n.searchParams.set("theme",t),a&&(n.searchParams.set("primeAuthOrigin",window.location.origin),n.searchParams.set("primeAuthProjectKey",a)),n.toString()}catch{return r}}function Jt({name:r,src:t,projectKey:a}){const[n,i]=o.useState(()=>Mr()),d=o.useRef(null);o.useEffect(()=>{const c=new MutationObserver(()=>i(Mr()));return c.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>c.disconnect()},[]);const f=o.useMemo(()=>Vt(t,n,a),[a,t,n]),h=o.useMemo(()=>{try{return new URL(f).origin}catch{return""}},[f]);return o.useEffect(()=>{if(!a)return;const c=a;function b(N){var p,m,u;if(N.source!==((p=d.current)==null?void 0:p.contentWindow)||h&&N.origin!==h)return;if(((m=N.data)==null?void 0:m.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!N.data.active}}));return}if(((u=N.data)==null?void 0:u.type)!=="prime-microservice:navigation")return;const k=N.data.path;if(!k||!k.startsWith("/")||k.startsWith("//"))return;const v=`/apps/${encodeURIComponent(c)}${k}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==v&&(window.history.replaceState(window.history.state,"",v),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",b),()=>{window.removeEventListener("message",b),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[h,a]),e.jsx("div",{className:"flex h-full min-h-screen flex-col bg-[var(--bg-main)]",children:e.jsx("iframe",{ref:d,src:f,title:r,className:"min-h-0 flex-1 border-0 bg-[var(--bg-main)]",allow:"clipboard-write",sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-same-origin allow-scripts",referrerPolicy:"strict-origin-when-cross-origin"})})}function Zt(){const[r,t]=o.useState(""),[a,n]=o.useState(!1),[i,d]=o.useState({width:96,height:96});return o.useEffect(()=>{let f=!1;return fetch("/api/microservices/prime-suite/chat-url",{cache:"no-store"}).then(h=>h.ok?h.json():null).then(h=>{!f&&(h!=null&&h.src)&&t(h.src)}).catch(()=>{}),()=>{f=!0}},[]),o.useEffect(()=>{const f=h=>{var b;if(((b=h.data)==null?void 0:b.type)!=="prime-suite-chat:state")return;const c=!!h.data.active;n(c),d({width:$r(h.data.width,96,720),height:$r(h.data.height,96,560)})};return window.addEventListener("message",f),()=>window.removeEventListener("message",f)},[]),r?e.jsx("iframe",{title:"Chat Bonsaif",src:r,allow:"clipboard-write",className:"fixed bottom-0 right-0 z-[70] border-0 bg-transparent transition-[width,height] duration-200",style:{width:a?`min(${i.width}px, 100vw)`:96,height:a?`min(${i.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function $r(r,t,a){const n=typeof r=="number"&&Number.isFinite(r)?r:t;return Math.max(t,Math.min(a,Math.ceil(n)))}function Kt(r){const t=document.documentElement,a=new MutationObserver(r);a.observe(t,{attributes:!0,attributeFilter:["class"]});const n=window.matchMedia("(prefers-color-scheme: dark)");return n.addEventListener("change",r),()=>{a.disconnect(),n.removeEventListener("change",r)}}function Qt(){const r=localStorage.getItem("theme")||"system",t=window.matchMedia("(prefers-color-scheme: dark)").matches;return document.documentElement.classList.contains("dark")||r==="dark"||r==="system"&&t?"dark":"light"}function Rt(){return"light"}function ea(){const r=o.useSyncExternalStore(Kt,Qt,Rt);return e.jsx(Ar.Toaster,{position:"bottom-center",theme:r,richColors:!0,closeButton:!0})}O.AuthShell=Er,O.BonsaifButton=zr,O.Button=ue,O.CalendarPicker=Rr,O.CompactFilterSelect=rt,O.CompactSearchInput=et,O.ConfirmDialog=nt,O.CopyButton=ur,O.CopyLinkButton=lt,O.DataTable=ft,O.DateRangePicker=bt,O.Drawer=mt,O.DynamicDetailTabs=Vr,O.GlobalScrollbars=Nr,O.InputField=Et,O.LoadingState=tr,O.MicroserviceFrame=Jt,O.Modal=cr,O.MouseTooltip=Ge,O.PageHeader=Yt,O.PageSearchInput=er,O.PrimeAuthRouteShell=Xt,O.PrimeAuthToaster=ea,O.PrimeSuiteChatFrame=Zt,O.SearchableSelect=qe,O.StepWizard=Mt,O.TextInput=ze,O.Toggle=Tt,O.UserAvatar=Cr,O.cn=Re,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1,14 @@
1
+ import { ButtonHTMLAttributes, ReactNode } from 'react';
2
+ export interface CopyButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "value"> {
3
+ value: string | (() => string);
4
+ resetDelay?: number;
5
+ copiedTitle?: string;
6
+ copiedLabel?: ReactNode;
7
+ icon?: ReactNode;
8
+ copiedIcon?: ReactNode;
9
+ stopPropagation?: boolean;
10
+ onCopied?: (value: string) => void;
11
+ onCopyError?: (error: unknown, value: string) => void;
12
+ }
13
+ export default function CopyButton({ value, resetDelay, title, copiedTitle, copiedLabel, icon, copiedIcon, stopPropagation, onCopied, onCopyError, className, style, children, onClick, type, ...props }: CopyButtonProps): import("react/jsx-runtime").JSX.Element;
14
+ //# sourceMappingURL=CopyButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CopyButton.d.ts","sourceRoot":"","sources":["../../../src/components/ui/CopyButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,oBAAoB,EAEzB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAC3C,oBAAoB,CAAC,iBAAiB,CAAC,EACvC,OAAO,CACR;IACC,KAAK,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACvD;AA0BD,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,KAAK,EACL,UAAiB,EACjB,KAAK,EACL,WAAuB,EACvB,WAAW,EACX,IAAsD,EACtD,UAAgD,EAChD,eAAsB,EACtB,QAAQ,EACR,WAAW,EACX,SAAc,EACd,KAAK,EACL,QAAQ,EACR,OAAO,EACP,IAAe,EACf,GAAG,KAAK,EACT,EAAE,eAAe,2CA4EjB"}
@@ -0,0 +1,8 @@
1
+ import { CopyButtonProps } from './CopyButton';
2
+ export interface CopyLinkButtonProps extends Omit<CopyButtonProps, "value" | "icon"> {
3
+ url: string | (() => string);
4
+ resolveUrl?: (url: string) => string;
5
+ icon?: CopyButtonProps["icon"];
6
+ }
7
+ export default function CopyLinkButton({ url, resolveUrl, title, copiedTitle, icon, ...props }: CopyLinkButtonProps): import("react/jsx-runtime").JSX.Element;
8
+ //# sourceMappingURL=CopyLinkButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CopyLinkButton.d.ts","sourceRoot":"","sources":["../../../src/components/ui/CopyLinkButton.tsx"],"names":[],"mappings":"AAGA,OAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAEhE,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAC/C,eAAe,EACf,OAAO,GAAG,MAAM,CACjB;IACC,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;IAC7B,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IACrC,IAAI,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;CAChC;AAUD,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,GAAG,EACH,UAAU,EACV,KAAqB,EACrB,WAA4B,EAC5B,IAAyC,EACzC,GAAG,KAAK,EACT,EAAE,mBAAmB,2CAUrB"}
@@ -1 +1 @@
1
- {"version":3,"file":"InputField.d.ts","sourceRoot":"","sources":["../../../src/components/ui/InputField.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAIf,KAAK,eAAe,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,GAAG;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,KAAK,EACL,kBAAuB,EACvB,UAAU,EACV,KAAK,EACL,WAAW,EACX,aAAqB,EACrB,kBAAyB,EACzB,SAAc,EACd,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,eAAe,2CAqHjB"}
1
+ {"version":3,"file":"InputField.d.ts","sourceRoot":"","sources":["../../../src/components/ui/InputField.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAIf,KAAK,eAAe,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,GAAG;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,KAAK,EACL,kBAAuB,EACvB,UAAU,EACV,KAAK,EACL,WAAW,EACX,aAAqB,EACrB,kBAAyB,EACzB,SAAc,EACd,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,eAAe,2CA2IjB"}
@@ -3,6 +3,10 @@ export { default as CalendarPicker } from './CalendarPicker';
3
3
  export { CompactFilterSelect, CompactSearchInput } from './CompactFilters';
4
4
  export type { SelectOption as CompactFilterOption } from './CompactFilters';
5
5
  export { default as ConfirmDialog } from './ConfirmDialog';
6
+ export { default as CopyButton } from './CopyButton';
7
+ export type { CopyButtonProps } from './CopyButton';
8
+ export { default as CopyLinkButton } from './CopyLinkButton';
9
+ export type { CopyLinkButtonProps } from './CopyLinkButton';
6
10
  export { default as DataTable } from './DataTable';
7
11
  export type { Column, DataTableProps } from './DataTable';
8
12
  export { default as DateRangePicker } from './DateRangePicker';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ui/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,YAAY,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjE,YAAY,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ui/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,YAAY,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjE,YAAY,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bonsaif-ui",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Reusable Bonsaif UI components for Bonsaif applications.",
5
5
  "type": "module",
6
6
  "author": "Bonsaif",