bonsaif-ui 0.1.9 → 0.1.10

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($,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react-icons/hi2"),require("react"),require("react-dom"),require("overlayscrollbars"),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-icons/hi2","react","react-dom","overlayscrollbars","react-icons/md","overlayscrollbars-react","react-day-picker","react-day-picker/dist/style.css","react-icons/fi","sonner"],e):($=typeof globalThis<"u"?globalThis:$||self,e($.BonsaifUI={},$.jsxRuntime,$.ReactIconsHi2,$.React,$.ReactDOM,$.OverlayScrollbarsGlobal,$.ReactIconsMd,$.OverlayScrollbarsReact,$.ReactDayPicker,$.ReactDayPickerStyles,$.ReactIconsFi,$.Sonner))})(this,(function($,e,w,s,$e,rr,Fr,tr,ar,za,Wr,Ur){"use strict";"use client";function nr(...r){return r.filter(Boolean).join(" ")}function qr({variant:r="primary",className:t,type:a="button",children:n,...o}){return e.jsx("button",{className:nr("bonsaif-ui-button",`bonsaif-ui-button--${r}`,t),type:a,...o,children:n})}function or({value:r,onChange:t,placeholder:a,className:n="",autoFocus:o=!1,forceExpanded:l=!1,onEscape:i,size:c="default",inputTabIndex:f}){const p=s.useRef(null),[N,g]=s.useState(!1),v=l||N||r.trim().length>0,m=c==="sm"?"h-9 rounded-md":"h-11 rounded-lg";s.useEffect(()=>{var d;o&&(g(!0),(d=p.current)==null||d.focus())},[o]);const h=()=>{var d;g(!0),(d=p.current)==null||d.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:d=>{v||(d.preventDefault(),h())},children:[e.jsx(w.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:p,type:"text",tabIndex:f,"aria-label":a,value:r,onChange:d=>t(d.target.value),onKeyDown:d=>{d.key==="Escape"&&(i==null||i())},placeholder:v?a:"Buscar",className:`${m} 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:d=>{g(!0),d.currentTarget.style.borderColor="var(--primary)",d.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:d=>{g(!1),d.currentTarget.style.borderColor="var(--border)",d.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(w.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const sr=s.createContext({});function Gr(r){var n;const t=Array.from(r.querySelectorAll("*")).filter(o=>{var l;return o.scrollWidth>o.clientWidth&&!!((l=o.textContent)!=null&&l.trim())&&o.tagName.toLowerCase()!=="svg"&&!o.closest("svg")});return(r.scrollWidth>r.clientWidth||t.length>0)&&(((n=t[0])==null?void 0:n.textContent)??r.textContent??"").trim()||null}function He({children:r,content:t,onlyWhenOverflow:a=!1,className:n="",style:o,as:l="div"}){const i=s.useRef(null),c=s.useRef(null),[f,p]=s.useState(null),[N,g]=s.useState("");s.useEffect(()=>{const h=i.current;h&&(h.querySelectorAll("[title]").forEach(d=>{const y=d.getAttribute("title");y&&(d.getAttribute("aria-label")||d.setAttribute("aria-label",y),d.removeAttribute("title"))}),h.querySelectorAll("svg title").forEach(d=>d.remove()))}),s.useLayoutEffect(()=>{if(!f)return;const h=c.current;if(!h)return;const d=12,y=14,E=h.getBoundingClientRect(),z=window.innerWidth-E.width-d,P=window.innerHeight-E.height-d;let B=f.mouseX+y,x=f.mouseY+y;B>z&&(B=f.mouseX-E.width-y),x>P&&(x=f.mouseY-E.height-y),B=Math.min(Math.max(d,B),Math.max(d,z)),x=Math.min(Math.max(d,x),Math.max(d,P)),(Math.abs(B-f.x)>.5||Math.abs(x-f.y)>.5)&&p(S=>S&&{...S,x:B,y:x})},[f]);const v=(h,d)=>{const y=i.current;if(y){if(a){const E=Gr(y);if(!E)return;g(E)}!a&&!t||p({mouseX:h,mouseY:d,x:h+14,y:d+14})}},m=a?N:t;return e.jsxs(e.Fragment,{children:[e.jsx(l,{ref:h=>{i.current=h},className:n,style:o,onMouseEnter:h=>v(h.clientX,h.clientY),onMouseMove:h=>{f&&v(h.clientX,h.clientY)},onMouseLeave:()=>p(null),children:r}),f&&m?$e.createPortal(e.jsx("div",{ref:c,role:"tooltip",style:{position:"fixed",top:f.y,left:f.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:m}),document.body):null]})}function lr(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}const Yr="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",Xr={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:"text-[var(--text-muted)] hover:text-[var(--primary)] hover:bg-primary/5"},Vr="border border-[var(--border)] text-[var(--text-muted)] shadow-sm shadow-black/5 hover:border-[var(--border)] hover:bg-[var(--bg-input)] hover:text-[var(--primary)] active:scale-[0.98] transition-colors",Zr={xs:"h-8 px-2.5 text-xs",sm:"h-9 px-3.5 text-xs",md:"h-10 px-3.5 text-sm",lg:"h-11 px-4 text-sm font-semibold"},Kr={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},Jr={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function Ge(r){return typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(Ge).join(" ").trim():s.isValidElement(r)?Ge(r.props.children):""}function Qr(r){return s.Children.toArray(r).find(s.isValidElement)??null}function ie({variant:r="primary",size:t="md",loading:a=!1,icon:n,tooltip:o,iconOnly:l,height:i,padding:c,children:f,className:p="",disabled:N,style:g,...v}){const m=s.useContext(sr),h=l??m.iconOnly??r==="icon",d=m.compact??!1,y=m.headerAction??!1,E=d&&t==="md"?"xs":t,z=r==="icon"||h,P=y&&z,B=Ge(f),x=o??v.title??v["aria-label"]??(h?B:void 0),S=x?void 0:v.title,L=v["aria-label"]??(typeof x=="string"?x:B||void 0),I=a?null:n??(h?Qr(f):null),D=e.jsxs("button",{...v,title:S,"aria-label":L,"data-variant":r,"data-size":E,"data-icon":z?"true":void 0,disabled:N||a,className:`${Yr} ${P?Vr:Xr[r]} ${z?Kr[E]:Zr[E]} ${d&&!z?"px-2.5":""} ${p}`,style:{...Jr[r],height:lr(i),padding:lr(c),...g,...P?{width:"32px",height:"32px",padding:0,background:"var(--bg-card)",borderRadius:"8px"}:null},children:[a?e.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):I,!h&&f]});return x?e.jsx(He,{as:"span",content:x,className:"inline-flex shrink-0",children:D}):D}function ir({variant:r="page",title:t="Cargando...",rows:a=6,children:n}){return r==="table"?e.jsx(cr,{rows:a}):r==="sections"?e.jsx(Rr,{rows:a}):r==="cards"?e.jsx(et,{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 Rr({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(cr,{rows:a===0?r:Math.max(3,r-2),compact:!0})]},a))})}function et({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 cr({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,o)=>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)]"})},o))}),Array.from({length:r}).map((n,o)=>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((l,i)=>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+(o*13+i*11)%36}%`}})},i))},o))]})}function dr(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 ur(r){return r.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function rt(r){return[r.label,dr(r.service),r.description,r.service].filter(Boolean).join(" ")}function tt(r){return typeof r=="function"?r:r.default}function at(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(ie,{className:"mt-4",height:36,padding:"0 14px",onClick:t,children:"Reintentar"})]})})}function nt({parentPanel:r,parentPanelComponent:t,renderParentPanel:a,parent:n,context:o,links:l,moduleRegistry:i,loadModule:c,activeService:f,initialService:p,onActiveServiceChange:N,canAccess:g,keepAlive:v=!0,title:m,subtitle:h,emptyState:d,loadingState:y,errorState:E=at,renderTabLabel:z,searchableTabs:P="auto",tabsSearchThreshold:B=6,tabsSearchPlaceholder:x="Buscar modulo...",tabsSearchValue:S,onTabsSearchChange:L,emptySearchState:I,showTabCount:D=!0,className:T="",parentClassName:A="",contentClassName:F="",tabsClassName:q=""}){var ve;const U=s.useMemo(()=>l.filter(k=>!k.hidden&&((g==null?void 0:g(k,o))??!0)),[g,o,l]),K=(ve=U.find(k=>!k.disabled))==null?void 0:ve.service,[R,u]=s.useState(p??K??""),[M,G]=s.useState({}),[Y,Z]=s.useState({}),[re,ce]=s.useState(""),[te,ye]=s.useState(!1),he=s.useRef(Y),be=s.useRef(0),de=S??re,H=ur(de),W=P===!0||P==="auto"&&U.length>=B,V=W&&de.trim().length>0,ae=s.useMemo(()=>H?U.filter(k=>ur(rt(k)).includes(H)):U,[H,U]),oe=f??R,_=U.find(k=>k.service===oe)??U.find(k=>!k.disabled);s.useEffect(()=>{!_&&K&&u(K)},[K,_]),s.useEffect(()=>{he.current=Y},[Y]);const we=k=>{k.disabled||(f||u(k.service),N==null||N(k.service,k))},je=k=>{S===void 0&&ce(k),L==null||L(k)},Qe=(k,ee)=>{const J=ae.filter(le=>!le.disabled),xe=J.findIndex(le=>le.service===ee.service);xe<0||((k.key==="ArrowRight"||k.key==="ArrowDown")&&(k.preventDefault(),we(J[(xe+1)%J.length])),(k.key==="ArrowLeft"||k.key==="ArrowUp")&&(k.preventDefault(),we(J[(xe-1+J.length)%J.length])),k.key==="Home"&&(k.preventDefault(),we(J[0])),k.key==="End"&&(k.preventDefault(),we(J[J.length-1])))},fe=s.useCallback(()=>{if(!_)return;const k=_.service,ee=he.current[k];if(ee!=null&&ee.loading||ee!=null&&ee.component&&v)return;const J=(i==null?void 0:i[k])??c;if(!J){Z(le=>({...le,[k]:{loading:!1,error:new Error(`No module loader found for service "${k}".`)}}));return}const xe=++be.current;Z(le=>({...le,[k]:{...le[k],loading:!0,error:void 0}})),J(_,o).then(le=>{if(xe!==be.current&&!v)return;const Te=tt(le);Z(ke=>({...ke,[k]:{component:Te,loading:!1}}))}).catch(le=>{const Te=le instanceof Error?le:new Error(String(le));Z(ke=>({...ke,[k]:{...ke[k],loading:!1,error:Te}}))})},[o,v,c,i,_]);s.useEffect(fe,[fe]);const _e=_?M[_.service]??null:null,ne=_?Y[_.service]:void 0,Fe=ne==null?void 0:ne.component,Ee=k=>{_&&G(ee=>({...ee,[_.service]:k}))},Le=()=>{_&&G(k=>({...k,[_.service]:null}))},We={context:o,parent:n,links:l,visibleLinks:U,filteredLinks:ae,selectedLink:_,selectedService:_==null?void 0:_.service,activeItemId:_e,tabsSearch:de,onSelectService:we,onOpenDetail:Ee,onBackToList:Le},Ne=a?a(We):t?e.jsx(t,{...We}):r;return e.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${T}`,children:[e.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${A}`,children:Ne}),e.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${F}`,children:[(m||h||W||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:[m&&e.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:m}),h&&e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:h})]}),(W||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," / ",U.length]}),W&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${te?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!te,children:e.jsx(or,{value:de,onChange:je,placeholder:x,className:"w-full",autoFocus:te,forceExpanded:!0,onEscape:()=>ye(!1),size:"sm",inputTabIndex:te?0:-1})}),e.jsx("button",{type:"button","aria-label":te?"Cerrar busqueda":"Buscar tabs","aria-expanded":te,onClick:()=>{te&&de&&je(""),ye(k=>!k)},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 ${te||V?"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:te||V?e.jsx(w.HiXMark,{className:"h-4 w-4"}):e.jsx(w.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),e.jsx("div",{role:"tablist","aria-label":m??"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 ${q}`,children:ae.length>0?ae.map(k=>{const ee=k.service===(_==null?void 0:_.service);return e.jsx("button",{type:"button",role:"tab","aria-selected":ee,disabled:k.disabled,onClick:()=>we(k),onKeyDown:J=>Qe(J,k),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 ${ee?"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(k,ee):e.jsxs(e.Fragment,{children:[k.icon,e.jsx("span",{children:k.label??dr(k.service)}),k.badge&&e.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:k.badge})]})},k.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:I??"No hay modulos que coincidan con la busqueda."})}),(_==null?void 0:_.description)&&e.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:_.description}),e.jsxs("div",{className:"min-h-[420px] p-4",children:[!_&&(d??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."})),_&&(ne==null?void 0:ne.loading)&&(y??e.jsx(ir,{title:"Cargando modulo..."})),_&&(ne==null?void 0:ne.error)&&E(ne.error,fe),_&&Fe&&!(ne!=null&&ne.loading)&&!(ne!=null&&ne.error)&&e.jsx(Fe,{context:o,parent:n,link:_,activeItemId:_e,onOpenDetail:Ee,onBackToList:Le})]})]})]})}const ot={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:e.jsx(w.HiInformationCircle,{className:"h-5 w-5"})},success:{color:"#047857",background:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.24)",icon:e.jsx(w.HiCheckCircle,{className:"h-5 w-5"})},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)",icon:e.jsx(w.HiExclamationTriangle,{className:"h-5 w-5"})},danger:{color:"var(--danger)",background:"var(--danger-bg)",border:"color-mix(in srgb, var(--danger) 20%, var(--border))",icon:e.jsx(w.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:e.jsx(w.HiInformationCircle,{className:"h-5 w-5"})}};function st({variant:r="info",title:t,children:a,icon:n,action:o,onDismiss:l,className:i=""}){const c=ot[r];return e.jsxs("div",{role:r==="danger"||r==="warning"?"alert":"status",className:`flex items-start gap-3 rounded-lg border px-3 py-3 ${i}`,style:{background:c.background,borderColor:c.border},children:[e.jsx("div",{className:"mt-0.5 shrink-0",style:{color:c.color},children:n??c.icon}),e.jsxs("div",{className:"min-w-0 flex-1",children:[t&&e.jsx("div",{className:"text-sm font-semibold text-[var(--text-main)]",children:t}),a&&e.jsx("div",{className:"mt-0.5 text-sm leading-5 text-[var(--text-secondary)]",children:a}),o&&e.jsx("div",{className:"mt-3",children:o})]}),l&&e.jsx(ie,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:e.jsx(w.HiXMark,{className:"h-4 w-4"})})]})}const fr=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],lt=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],it=["Do","Lu","Ma","Mi","Ju","Vi","Sá"],Ye=6;function Xe(r,t,a){return`${r}-${String(t).padStart(2,"0")}-${String(a).padStart(2,"0")}`}function ct(){const r=new Date;return Xe(r.getFullYear(),r.getMonth()+1,r.getDate())}function pr(r){const[t,a,n]=r.split("-").map(Number);return{year:t,month:a,day:n}}function dt(r){if(!r)return"Seleccionar fecha";const{year:t,month:a,day:n}=pr(r);return!t||!a||!n?"Seleccionar fecha":`${String(n).padStart(2,"0")} ${fr[a-1]} ${t}`}function ut({value:r,onChange:t,minDate:a,displayMode:n="inline"}){const o=ct(),i=pr(r||o),c=n==="popover",[f,p]=s.useState(!1),N=s.useRef(null),[g,v]=s.useState({horizontal:"left",vertical:"bottom"}),[m,h]=s.useState(i.year),[d,y]=s.useState(i.month),[E,z]=s.useState("days"),P=16,[B,x]=s.useState(0),S=m-7+B,L=Array.from({length:P},(u,M)=>S+M);s.useEffect(()=>{if(!c||!f||!N.current)return;const u=N.current.getBoundingClientRect(),M=8,G=280,Y=340,Z=u.left+G>window.innerWidth-M,re=u.right-G>=M,ce=u.bottom+8+Y>window.innerHeight-M,te=u.top-8-Y>=M;v({horizontal:Z&&re?"right":"left",vertical:ce&&te?"top":"bottom"})},[c,f]),s.useEffect(()=>{if(!c||!f)return;function u(G){N.current&&(N.current.contains(G.target)||p(!1))}function M(G){G.key==="Escape"&&p(!1)}return document.addEventListener("mousedown",u),document.addEventListener("keydown",M),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",M)}},[c,f]);function I(){d===1?(h(u=>u-1),y(12)):y(u=>u-1)}function D(){d===12?(h(u=>u+1),y(1)):y(u=>u+1)}const T=new Date(m,d-1,1).getDay(),A=new Date(m,d,0).getDate(),F=[...Array(T).fill(null),...Array.from({length:A},(u,M)=>M+1)];for(;F.length<Ye*7;)F.push(null);const q=F.slice(0,Ye*7);function U(u){const M=Xe(m,d,u);a&&M<a||(t(M),c&&p(!1))}const K={background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,borderRadius:6,display:"flex",alignItems:"center"},R=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:E==="days"?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:I,style:K,title:"Mes anterior",children:e.jsx(w.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>{z("years"),x(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:[fr[d-1]," ",m,e.jsx(w.HiChevronDown,{size:13,style:{color:"var(--text-muted)"}})]}),e.jsx("button",{type:"button",onClick:D,style:K,title:"Mes siguiente",children:e.jsx(w.HiChevronRight,{size:16})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>x(u=>u-P),style:K,children:e.jsx(w.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:[L[0]," – ",L[L.length-1]]}),e.jsx("button",{type:"button",onClick:()=>x(u=>u+P),style:K,children:e.jsx(w.HiChevronRight,{size:16})})]})}),E==="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:lt.map((u,M)=>{const G=M+1===d;return e.jsx("button",{type:"button",onClick:()=>y(M+1),style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:11,fontWeight:G?700:400,padding:"4px 0",background:G?"var(--primary)":"transparent",color:G?"var(--primary-fg, #ffffff)":"var(--text-secondary)"},children:u},u)})}),e.jsx("div",{style:{height:1,background:"var(--border)",marginBottom:8}}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3},children:L.map(u=>{const M=u===m;return e.jsx("button",{type:"button",onClick:()=>{h(u),z("days")},style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:12,fontWeight:M?700:400,padding:"6px 0",background:M?"var(--primary)":"transparent",color:M?"var(--primary-fg, #ffffff)":"var(--text-main)",outline:u===new Date().getFullYear()&&!M?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:u},u)})})]}),E==="days"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",padding:"6px 8px 0"},children:it.map(u=>e.jsx("div",{style:{textAlign:"center",fontSize:10,fontWeight:700,color:"var(--text-muted)",padding:"2px 0",textTransform:"uppercase"},children:u},u))}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",gridTemplateRows:`repeat(${Ye},1fr)`,padding:"4px 8px 10px",gap:2},children:q.map((u,M)=>{if(u===null)return e.jsx("div",{style:{aspectRatio:"1"}},M);const G=Xe(m,d,u),Y=G===r,Z=G===o,re=!!(a&&G<a);return e.jsx("button",{type:"button",onClick:()=>!re&&U(u),style:{width:"100%",aspectRatio:"1",borderRadius:6,border:"none",cursor:re?"not-allowed":"pointer",fontSize:12,fontWeight:Y||Z?700:400,background:Y?"var(--primary)":"transparent",color:Y?"var(--primary-fg, #ffffff)":re?"var(--text-muted)":"var(--text-main)",opacity:re?.4:1,outline:Z&&!Y?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:u},M)})})]})]});return c?e.jsxs("div",{ref:N,className:"relative w-full",children:[e.jsxs("button",{type:"button",onClick:()=>p(u=>!u),className:"flex h-10 w-full items-center justify-between gap-2 rounded-lg px-2.5 py-0 text-sm transition-all duration-150 focus:outline-none",style:{background:"var(--bg-input)",border:`1px solid ${f?"var(--primary)":"var(--border)"}`,color:"var(--text-main)",boxShadow:f?"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(w.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),e.jsx("span",{className:"truncate",children:dt(r)})]}),e.jsx(w.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${f?"rotate-180":""}`})]}),f&&e.jsx("div",{className:"absolute z-50",style:{...g.horizontal==="left"?{left:0}:{right:0},...g.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:R})]}):R}const ft={sm:"h-4 w-4",md:"h-5 w-5"};function pt({label:r,description:t,error:a,size:n="md",className:o="",containerClassName:l="",disabled:i,...c}){return e.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${i?"cursor-not-allowed opacity-60":"cursor-pointer"} ${l}`,children:[e.jsxs("span",{className:"relative mt-0.5 inline-flex shrink-0",children:[e.jsx("input",{...c,type:"checkbox",disabled:i,"aria-invalid":!!a||c["aria-invalid"],className:`peer ${ft[n]} appearance-none rounded border border-[var(--border)] bg-[var(--bg-input)] transition-colors checked:border-[var(--primary)] checked:bg-[var(--primary)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/40 ${o}`}),e.jsx(w.HiCheck,{className:"pointer-events-none absolute left-1/2 top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 scale-75 text-[var(--primary-fg)] opacity-0 transition peer-checked:scale-100 peer-checked:opacity-100"})]}),(r||t||a)&&e.jsxs("span",{className:"min-w-0",children:[r&&e.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:r}),t&&!a&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:t}),a&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--danger)]",children:a})]})]})}function hr(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 ht(r){var t;if((t=navigator.clipboard)!=null&&t.writeText){await navigator.clipboard.writeText(r);return}hr(r)}function bt(r){return typeof r=="function"?r():r}function Ve({value:r,resetDelay:t=2e3,title:a,copiedTitle:n="Copiado",copiedLabel:o,icon:l=e.jsx(w.HiClipboardDocument,{size:14}),copiedIcon:i=e.jsx(w.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:f,onCopyError:p,className:N="",style:g,children:v,onClick:m,type:h="button",...d}){const[y,E]=s.useState(!1),z=s.useRef(null);s.useEffect(()=>()=>{z.current&&window.clearTimeout(z.current)},[]);function P(x){E(!0),f==null||f(x),z.current&&window.clearTimeout(z.current),z.current=window.setTimeout(()=>{E(!1),z.current=null},t)}async function B(x){var L;if(c&&x.stopPropagation(),m==null||m(x),x.defaultPrevented)return;const S=bt(r);if(S)try{await ht(S),P(S)}catch(I){try{hr(S),P(S)}catch(D){p==null||p(D,S);return}(L=navigator.clipboard)!=null&&L.writeText||p==null||p(I,S)}}return e.jsxs("button",{...d,type:h,onClick:B,title:y?n:a,"aria-label":d["aria-label"]??(y?n:a),"data-copied":y?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${v?"min-w-7 px-2":"w-7"} ${N}`,style:{cursor:"pointer",background:y?"rgba(22,163,74,0.15)":"var(--bg-card)",border:y?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:y?"#16a34a":"var(--text-secondary)",boxShadow:y?"0 0 0 3px rgba(22,163,74,0.12)":"none",...g},children:[e.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:y?"scale(1.15)":"scale(1)"},children:y?i:l}),v&&e.jsx("span",{className:"text-xs font-semibold leading-none",children:y?o??v:v})]})}function mt({code:r,children:t,title:a="Codigo",language:n,copyLabel:o="Copiar",copiedLabel:l="Copiado",className:i="",style:c,onCopied:f}){const p=(r??t??"").trim();return e.jsxs("div",{className:`overflow-hidden rounded-lg border ${i}`,style:{borderColor:"rgba(148, 163, 184, 0.22)",background:"#0f172a",color:"#e2e8f0",...c},children:[e.jsxs("div",{className:"flex min-h-9 items-center justify-between gap-3 border-b px-3 py-1.5",style:{borderColor:"rgba(148, 163, 184, 0.18)",background:"#111827",color:"#94a3b8"},children:[e.jsx("span",{className:"min-w-0 truncate text-[11px] font-black uppercase tracking-[0.08em]",children:a}),e.jsx(Ve,{value:p,title:"Copiar codigo",copiedTitle:"Codigo copiado",copiedLabel:l,onCopied:f,className:"h-7 min-w-[72px] px-2",style:{background:"#182235",border:"1px solid rgba(148, 163, 184, 0.28)",color:"#f8fafc"},children:o})]}),e.jsx("pre",{className:"m-0 overflow-x-auto p-3 text-xs leading-6",style:{background:"#0f172a",color:"#e2e8f0",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace'},children:e.jsx("code",{className:n?`language-${n}`:void 0,children:p})})]})}function br(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Ze({value:r,onChange:t,options:a,placeholder:n="Seleccionar…",emptyLabel:o,disabled:l=!1,className:i="",style:c,height:f=40,padding:p="0 10px",searchable:N=!0,minOptionsForSearch:g=6}){const[v,m]=s.useState(!1),[h,d]=s.useState(""),[y,E]=s.useState(-1),[z,P]=s.useState(!1),[B,x]=s.useState({}),S=s.useRef(null),L=s.useRef(null),I=s.useRef(null),D=s.useRef(null),T=N&&a.length>=g,A=a.find(u=>u.value===r)??null,F=T&&h.trim()?a.filter(u=>{var M;return u.label.toLowerCase().includes(h.toLowerCase())||((M=u.sublabel)==null?void 0:M.toLowerCase().includes(h.toLowerCase()))}):a,q=s.useCallback(()=>{const u=S.current;if(!u)return;const M=u.getBoundingClientRect(),G=T?272:212,Y=window.innerHeight-M.bottom,Z=Y<G&&M.top>Y;x({position:"fixed",left:M.left,top:Z?void 0:M.bottom+4,bottom:Z?window.innerHeight-M.top+4:void 0,width:M.width,zIndex:9999})},[T]);s.useEffect(()=>P(!0),[]),s.useEffect(()=>{if(!v)return;function u(M){var Y,Z;const G=M.target;!((Y=S.current)!=null&&Y.contains(G))&&!((Z=L.current)!=null&&Z.contains(G))&&(m(!1),d(""))}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[v]),s.useEffect(()=>{v&&(E(-1),q(),T&&setTimeout(()=>{var u;return(u=I.current)==null?void 0:u.focus()},0))},[v,T,q]),s.useEffect(()=>{if(v)return window.addEventListener("resize",q),window.addEventListener("scroll",q,!0),()=>{window.removeEventListener("resize",q),window.removeEventListener("scroll",q,!0)}},[v,q]),s.useEffect(()=>{if(y<0||!D.current)return;const u=D.current.children[y];u==null||u.scrollIntoView({block:"nearest"})},[y]);const U=s.useCallback(u=>{t(u),m(!1),d("")},[t]);function K(u){if(!v){(u.key==="Enter"||u.key===" "||u.key==="ArrowDown")&&(u.preventDefault(),m(!0));return}u.key==="Escape"?(u.preventDefault(),m(!1),d("")):u.key==="ArrowDown"?(u.preventDefault(),E(M=>Math.min(M+1,F.length-1))):u.key==="ArrowUp"?(u.preventDefault(),E(M=>Math.max(M-1,o?-1:0))):u.key==="Enter"&&(u.preventDefault(),y===-1&&o?U(""):F[y]&&U(F[y].value))}const R=e.jsxs("div",{ref:L,className:"rounded-xl shadow-xl overflow-hidden",style:{...B,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[T&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(w.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:I,value:h,onChange:u=>{d(u.target.value),E(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),h&&e.jsx("button",{type:"button",onMouseDown:u=>{u.preventDefault(),d("")},children:e.jsx(w.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:T?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[o&&e.jsx("li",{role:"option","aria-selected":r==="",onMouseDown:u=>{u.preventDefault(),U("")},onMouseEnter:()=>E(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:y===-1?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:o}),F.map((u,M)=>{const Y=M===y,Z=u.value===r;return e.jsxs("li",{role:"option","aria-selected":Z,onMouseDown:re=>{re.preventDefault(),u.disabled||U(u.value)},onMouseEnter:()=>!u.disabled&&E(M),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:Y?"var(--bg-hover)":Z?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:u.disabled?"var(--text-muted)":"var(--text-main)",cursor:u.disabled?"not-allowed":"pointer",boxShadow:Z?"inset 2px 0 0 var(--primary)":void 0},children:[u.color&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:u.color}}),e.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:u.label}),u.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:u.sublabel})]}),u.badge&&e.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:u.badge})]},u.value)}),F.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:S,className:`relative ${i||"w-full"}`,style:c,onKeyDown:K,children:[e.jsxs("button",{type:"button",disabled:l,onClick:()=>!l&&m(u=>!u),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:br(f),padding:br(p),background:"var(--bg-input)",color:A?"var(--text-main)":"var(--text-muted)",border:v?"1px solid var(--primary)":"1px solid var(--border)",opacity:l?.5:1,cursor:l?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":v,children:[(A==null?void 0:A.color)&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:A.color}}),e.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:A?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"truncate",children:A.label}),A.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:A.sublabel})]}):e.jsx("span",{className:"truncate",children:n})}),A&&o?e.jsx("span",{role:"button",tabIndex:-1,onMouseDown:u=>{u.preventDefault(),u.stopPropagation(),U("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(w.HiXMark,{className:"w-3 h-3"})}):e.jsx(w.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:v?"rotate(180deg)":"rotate(0deg)"}})]}),v&&z&&$e.createPortal(R,document.body)]})}function Oe(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function vt({value:r,onChange:t,placeholder:a="Buscar...",className:n="",height:o=40,padding:l="0 10px 0 30px",iconLeft:i=10}){return e.jsxs("div",{className:`relative ${n}`,children:[e.jsx(w.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:Oe(i)}}),e.jsx("input",{type:"text",value:r,onChange:c=>t(c.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:Oe(o),padding:Oe(l)}})]})}function xt({value:r,onChange:t,options:a,placeholder:n,icon:o,className:l="",height:i=40,padding:c,iconLeft:f=10,searchable:p=!0}){const N=o?a.map((g,v)=>v===0&&!g.color?{...g,sublabel:g.sublabel??void 0}:g):a;return e.jsxs("div",{className:`relative ${l}`,children:[o&&e.jsx("span",{className:"pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--text-muted)]",style:{left:Oe(f)},children:o}),e.jsx(Ze,{value:r,onChange:t,options:N,placeholder:n,searchable:p,minOptionsForSearch:5,height:i,padding:c??(o?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const gt={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},Ae=180;function mr({open:r,onClose:t,title:a,subtitle:n,leadingIcon:o,headerActions:l,footer:i,children:c,size:f="md",maxWidth:p,zIndex:N=1e3,closeOnBackdrop:g=!0,closeOnEscape:v=!0,showCloseButton:m=!0,placement:h="center",bodyClassName:d="px-6 py-5",panelClassName:y="",backdropClassName:E="bg-black/50 backdrop-blur-sm",contentClassName:z="p-4",ariaLabel:P,frameless:B=!1}){const[x,S]=s.useState(!1),[L,I]=s.useState(!1),D=s.useRef(null);if(s.useEffect(()=>(r?(D.current&&clearTimeout(D.current),S(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>I(!0)))):(I(!1),D.current=setTimeout(()=>S(!1),Ae+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||!v)return;const K=R=>{R.key==="Escape"&&t()};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[v,t,r]),!x)return null;const T=a||n||o||l||m,A=p??gt[f],F=h==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",q=h==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",U=L?"translateY(0) scale(1)":h==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return $e.createPortal(e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":P??a,className:`fixed inset-0 flex ${F} ${z}`,style:{zIndex:N},children:[e.jsx("div",{className:`absolute inset-0 ${E}`,onClick:g?t:void 0,style:{opacity:L?1:0,transition:`opacity ${Ae}ms ease`}}),e.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${B?"shadow-none":"shadow-2xl"} ${q} ${y}`,style:{maxWidth:A,background:B?"transparent":"var(--bg-card)",border:B?"none":"1px solid var(--border)",opacity:L?1:0,transform:U,transition:`opacity ${Ae}ms ease, transform ${Ae}ms ease`},onClick:K=>K.stopPropagation(),children:[T&&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:[o&&e.jsx("div",{className:"flex-shrink-0",children:o}),(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:[l,m&&e.jsx(ie,{variant:"icon",onClick:t,title:"Cerrar",children:e.jsx(w.HiXMark,{className:"h-5 w-5"})})]})]}),e.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${d}`,children:c}),i&&e.jsx("div",{className:"flex flex-shrink-0 justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:i})]})]}),document.body)}const yt={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 wt({open:r,title:t,description:a,confirmLabel:n="Confirmar",cancelLabel:o="Cancelar",variant:l="danger",onConfirm:i,onCancel:c}){const f=yt[l];return e.jsxs(mr,{open:r,onClose:c,size:"sm",zIndex:9998,showCloseButton:!1,bodyClassName:"p-6",panelClassName:"px-1",ariaLabel:t,children:[e.jsx(ie,{variant:"icon",onClick:c,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:e.jsx(w.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:f.iconBg},children:e.jsx(w.HiExclamationTriangle,{className:"h-5 w-5",style:{color:f.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(ie,{variant:"secondary",onClick:c,className:"flex-1",style:{background:"var(--bg-input)"},children:o}),e.jsx(ie,{variant:"danger",onClick:i,className:"flex-1",style:{background:f.btnBg,color:f.btnColor,borderColor:"transparent"},children:n})]})]})}function Nt(r,t){const a=typeof r=="function"?r():r;return t?t(a):a}function kt({url:r,resolveUrl:t,title:a="Copiar link",copiedTitle:n="Link copiado",icon:o=e.jsx(w.HiLink,{className:"h-3.5 w-3.5"}),...l}){return e.jsx(Ve,{...l,value:()=>Nt(r,t),title:a,copiedTitle:n,icon:o})}const St="[&_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 Me(r){if(!r)return 150;const t=parseInt(r,10);return isNaN(t)||t<=0?150:t}function Se(r,t){const a=r.minWidth??80,n=r.maxWidth??1/0;return Math.min(n,Math.max(a,t))}function Ct(r,t){if(t<=7)return Array.from({length:t},(n,o)=>o+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 vr({children:r,className:t="",style:a}){return e.jsx(He,{onlyWhenOverflow:!0,className:t,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",...a},children:r})}function Et({columns:r,data:t,getRowId:a,loading:n=!1,skeletonRows:o=8,emptyIcon:l,emptyText:i="Sin resultados",onRowClick:c,selected:f,onToggleOne:p,onToggleAll:N,highlightSelected:g=!0,rowClassName:v,getRowCategory:m,stickyHeader:h=!0,pageSize:d=25,pageSizeOptions:y=[25,50,100],pageSizeSelectWidth:E=62,pageSizeSelectHeight:z=30,pageSizeSelectPadding:P="0 7px",totalRows:B,page:x,onPageChange:S,onPageSizeChange:L,storageKey:I,stickyFirstColumn:D=!1,bottomOffset:T=0,compact:A=!0,restrictHeight:F=!0,minTableWidth:q}){const U=r.map(b=>b.key).join(","),[K,R]=s.useState(!I),u=s.useRef(null),M=s.useRef(!I),G=(b,C)=>50+(b*17+C*13+7)%40,Y=s.useRef(null),[Z,re]=s.useState(void 0),[ce,te]=s.useState(!1);s.useEffect(()=>{const C=d!==!1?32:0,O=12;function j(){if(te(window.innerWidth<640),!Y.current)return;const X=Y.current.getBoundingClientRect().top;re(Math.max(120,window.innerHeight-X-C-O-T))}return j(),window.addEventListener("resize",j),()=>window.removeEventListener("resize",j)},[n,d,T]);const[ye,he]=s.useState(()=>r.map(b=>b.key)),[be,de]=s.useState(()=>Object.fromEntries(r.map(b=>[b.key,Se(b,Me(b.width))])));s.useEffect(()=>{const b=r.map(O=>O.key);if(!I){he(b),M.current=!1,R(!0);return}let C=!1;return M.current=!1,R(!1),fetch(`/api/user/preferences/datatables?key=${encodeURIComponent(I)}`,{cache:"no-store"}).then(O=>O.ok?O.json():null).then(O=>{var Ue,qe;if(C)return;const j=(Ue=O==null?void 0:O.settings)==null?void 0:Ue.columnOrder,X=Array.isArray(j)?j.filter(pe=>b.includes(pe)):[],ue=b.filter(pe=>!X.includes(pe)),me=X.length>0?[...X,...ue]:b,Ce=Object.fromEntries(r.map(pe=>[pe.key,Se(pe,Me(pe.width))])),Q=((qe=O==null?void 0:O.settings)==null?void 0:qe.columnWidths)??{},se=Object.fromEntries(r.map(pe=>[pe.key,Se(pe,Q[pe.key]??Ce[pe.key])]));he(me),de(se),u.current=JSON.stringify({columnOrder:me,columnWidths:se}),M.current=!0}).catch(()=>{if(!C){he(b);const O=Object.fromEntries(r.map(j=>[j.key,Se(j,Me(j.width))]));de(O),u.current=JSON.stringify({columnOrder:b,columnWidths:O}),M.current=!0}}).finally(()=>{C||R(!0)}),()=>{C=!0}},[I,U,r]),s.useEffect(()=>{if(!I||!K||!M.current)return;const b={columnOrder:ye,columnWidths:be},C=JSON.stringify(b);if(C===u.current)return;const O=window.setTimeout(()=>{fetch("/api/user/preferences/datatables",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:I,settings:b})}).then(j=>{j.ok&&(u.current=C)}).catch(()=>{})},300);return()=>window.clearTimeout(O)},[ye,be,I,K]),s.useEffect(()=>{he(b=>{const C=r.map(X=>X.key),O=b.filter(X=>C.includes(X)),j=C.filter(X=>!O.includes(X));return[...O,...j]})},[U,r]);const H=ye.map(b=>r.find(C=>C.key===b)).filter(b=>!!b);s.useEffect(()=>{de(b=>{const C=Object.fromEntries(r.map(O=>[O.key,Se(O,Me(O.width))]));return Object.fromEntries(r.map(O=>[O.key,Se(O,b[O.key]??C[O.key])]))})},[U,r]);const W=s.useRef(null);s.useEffect(()=>{function b(O){const j=W.current;if(!j)return;const X=O.clientX-j.startX,ue=r.find(me=>me.key===j.colKey);ue&&de(me=>({...me,[j.colKey]:Se(ue,j.startWidth+X)}))}function C(){W.current&&(W.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",b),document.addEventListener("pointerup",C),()=>{document.removeEventListener("pointermove",b),document.removeEventListener("pointerup",C)}},[r]);const V=s.useRef(null),[ae,oe]=s.useState(null);function _(b,C){V.current=b,C.dataTransfer.effectAllowed="move"}function we(b,C){C.preventDefault(),C.dataTransfer.dropEffect="move",ae!==b&&oe(b)}function je(b,C){C.preventDefault();const O=V.current;O!==null&&O!==b&&he(j=>{const X=[...j],[ue]=X.splice(O,1);return X.splice(b,0,ue),X}),V.current=null,oe(null)}function Qe(){V.current=null,oe(null)}const[fe,_e]=s.useState(null);function ne(b){b.sortKey&&_e(C=>(C==null?void 0:C.key)===b.key?{key:b.key,dir:C.dir==="asc"?"desc":"asc"}:{key:b.key,dir:"asc"})}const[Fe,Ee]=s.useState(1),[Le,We]=s.useState(d===!1?0:d);s.useEffect(()=>{Ee(1)},[t]);const Ne=!!(S&&L),ve=d!==!1,k=Ne?x??1:Fe,ee=Ne||ve?Le:t.length,J=!!f&&!!p&&!!N,xe=J?40:0,le=J&&t.length>0&&f.size===t.length,Te=J&&f.size>0&&f.size<t.length,ke=s.useMemo(()=>{if(!fe)return t;const b=r.find(C=>C.key===fe.key&&C.sortKey);return b!=null&&b.sortKey?[...t].sort((C,O)=>{const j=C[b.sortKey],X=O[b.sortKey],ue=j===X?0:j==null?1:X==null||j<X?-1:1;return fe.dir==="asc"?ue:-ue}):t},[t,fe,r]),Ir=s.useMemo(()=>{if(Ne||!ve)return ke;const b=(k-1)*ee;return ke.slice(b,b+ee)},[ke,Ne,ve,k,ee]),De=B??t.length,Re=ve?Math.max(1,Math.ceil(De/ee)):1,Ha=ve?(k-1)*ee+1:1,Oa=ve?Math.min(k*ee,De):De;function er(b){const C=Math.max(1,Math.min(b,Re));Ne?S(C):Ee(C)}function Aa(b){We(b),Ne?(L(b),S(1)):Ee(1),L&&L(b)}const Pr=b=>b==="center"?"text-center":b==="right"?"text-right":"text-left",Ia="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",Pa=H.length+(J?1:0);function zr(b){return b?typeof b=="string"?{key:b,label:b}:b:null}const jr=()=>e.jsxs("tr",{style:{background:"color-mix(in srgb, var(--bg-input) 72%, transparent)"},children:[J&&e.jsx("th",{className:`${A?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:D?{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:le,ref:b=>{b&&(b.indeterminate=Te)},onChange:N,className:"rounded cursor-pointer accent-[var(--primary)]"})}),H.map((b,C)=>{const O=(fe==null?void 0:fe.key)===b.key,j=!!b.sortKey,X=D&&!ce&&C===0,ue=ae===C,Ce=(be[b.key]??Me(b.width))<120;return e.jsxs("th",{className:`group select-none ${Ce?"text-left":Pr(b.align)}`,style:{...X?{position:"sticky",left:xe,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:O?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:ue?"2px solid var(--primary)":"2px solid transparent",cursor:j?"pointer":"default",padding:A?"5px 24px 5px 6px":"7px 28px 7px 6px"},onDragOver:Q=>we(C,Q),onDrop:Q=>je(C,Q),onClick:j?()=>ne(b):void 0,children:[e.jsx("span",{draggable:!0,onDragStart:Q=>{Q.stopPropagation(),_(C,Q)},onDragEnd:Q=>{Q.stopPropagation(),Qe()},onClick:Q=>Q.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(Fr.MdDragIndicator,{size:15})}),e.jsx(vr,{className:"inline-block max-w-full align-middle",style:{width:"calc(100% - 22px)",textAlign:Ce?"left":b.align==="center"?"center":b.align==="right"?"right":"left"},children:e.jsxs("span",{className:`inline-flex max-w-full items-center gap-1 font-semibold uppercase tracking-wider ${A?"text-[11px]":"text-xs"}`,children:[e.jsx("span",{className:"min-w-0 truncate",children:b.header}),j&&e.jsx("span",{className:"flex-shrink-0 opacity-60",children:O?fe.dir==="asc"?e.jsx(w.HiChevronUp,{className:"w-3 h-3"}):e.jsx(w.HiChevronDown,{className:"w-3 h-3"}):e.jsx(w.HiChevronUpDown,{className:"w-3 h-3 opacity-40"})})]})}),e.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar",onPointerDown:Q=>{Q.preventDefault(),Q.stopPropagation(),W.current={colKey:b.key,startX:Q.clientX,startWidth:be[b.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onClick:Q=>Q.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"}})})]},b.key)})]}),_r=()=>{if(!ve||n)return null;const b=Ct(k,Re);return e.jsxs("div",{className:`grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 rounded-b-xl border-t text-xs select-none ${A?"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":`${Ha}–${Oa} de ${De}`}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),e.jsx(Ze,{value:String(ee),onChange:C=>Aa(Number(C)),options:y.map(C=>({value:String(C),label:String(C)})),placeholder:"Filas",searchable:!1,height:z,padding:P,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:E}})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[e.jsx("button",{disabled:k<=1,onClick:()=>er(k-1),className:"rounded p-0.5 transition-colors disabled:opacity-30",style:{color:"var(--text-muted)",background:"transparent"},children:e.jsx(w.HiChevronLeft,{className:"h-3.5 w-3.5"})}),b.map((C,O)=>C==="..."?e.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${O}`):e.jsx("button",{onClick:()=>er(C),className:"h-5 w-5 rounded text-[11px] font-medium transition-colors",style:{background:C===k?"var(--primary)":"transparent",color:C===k?"var(--primary-fg)":"var(--text-muted)"},children:C},C)),e.jsx("button",{disabled:k>=Re,onClick:()=>er(k+1),className:"rounded p-0.5 transition-colors disabled:opacity-30",style:{color:"var(--text-muted)",background:"transparent"},children:e.jsx(w.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{"aria-hidden":"true"})]})};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:Y,className:"min-w-0 max-w-full overflow-hidden rounded-t-xl",children:e.jsx(tr.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:F?Z:void 0,maxWidth:"100%"},defer:!0,children:e.jsxs("table",{className:"text-sm",style:{tableLayout:"fixed",width:"100%",minWidth:q??"max-content",borderCollapse:"separate",borderSpacing:0},children:[e.jsxs("colgroup",{children:[J&&e.jsx("col",{style:{width:40}}),H.map(b=>e.jsx("col",{style:{width:be[b.key]??150}},b.key))]}),e.jsx("thead",{style:h?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:jr()}),e.jsx("tbody",{children:Array.from({length:o}).map((b,C)=>e.jsxs("tr",{children:[J&&e.jsx("td",{className:`${A?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:"1px solid var(--border)",borderRight:"1px solid var(--border)"}}),H.map((O,j)=>{const X=D&&!ce&&j===0;return e.jsx("td",{className:A?"px-2 py-1.5":"px-3 py-2",style:X?{position:"sticky",left:xe,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:`${G(C,j)}%`,minWidth:32}})},O.key)})]},C))})]})})}),_r()]}):!n&&t.length===0?e.jsxs("div",{className:"py-20 flex flex-col items-center gap-3",children:[l&&e.jsx("div",{style:{color:"var(--text-muted)",opacity:.5},children:l}),e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:i})]}):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:Y,className:"min-w-0 max-w-full overflow-hidden rounded-t-xl",children:e.jsx(tr.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:F?Z:void 0,maxWidth:"100%"},defer:!0,children:e.jsxs("table",{className:"text-sm",style:{tableLayout:"fixed",width:"100%",minWidth:q??"max-content",borderCollapse:"separate",borderSpacing:0},children:[e.jsxs("colgroup",{children:[J&&e.jsx("col",{style:{width:40}}),H.map(b=>e.jsx("col",{style:{width:be[b.key]??150}},b.key))]}),e.jsx("thead",{style:h?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:jr()}),e.jsx("tbody",{children:Ir.map((b,C)=>{const O=a(b),j=zr(m==null?void 0:m(b)),X=C>0?zr(m==null?void 0:m(Ir[C-1])):null,ue=j&&j.key!==(X==null?void 0:X.key),me=J&&f.has(O),Ce=!!c,Q=me&&g?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":C%2===1?"color-mix(in srgb, var(--bg-input) 50%, var(--bg-card))":"var(--bg-card)";return e.jsxs(s.Fragment,{children:[ue&&e.jsx("tr",{className:j.className??"",children:e.jsx("td",{colSpan:Pa,className:A?"px-2 py-2":"px-3 py-3",style:{background:"color-mix(in srgb, var(--primary) 8%, var(--bg-input))",borderBottom:"1px solid var(--border)",borderRight:"1px solid var(--border)"},children:e.jsx("div",{className:"flex min-w-0 items-center justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-xs font-semibold uppercase tracking-wider text-[var(--text-main)]",children:j.label}),j.description&&e.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:j.description})]})})})}),e.jsxs("tr",{onClick:Ce?()=>c(b):void 0,className:`transition-colors ${Ce?"cursor-pointer":""} ${v?v(b):""}`,style:{"--dt-row-bg":Q,"--dt-sticky-bg":Q,background:"var(--dt-row-bg)"},onMouseEnter:se=>{me||(se.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),se.currentTarget.style.setProperty("--dt-sticky-bg",Ia))},onMouseLeave:se=>{se.currentTarget.style.setProperty("--dt-row-bg",Q),se.currentTarget.style.setProperty("--dt-sticky-bg",Q)},children:[J&&e.jsx("td",{className:`${A?"px-2 py-1.5":"px-3 py-2"} w-10`,style:D?{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:se=>{se.stopPropagation(),p(O)},children:e.jsx("input",{type:"checkbox",checked:me,onClick:se=>se.stopPropagation(),onChange:()=>p(O),className:"rounded cursor-pointer accent-[var(--primary)]"})}),H.map((se,Ue)=>{const qe=D&&!ce&&Ue===0;return e.jsx("td",{className:`${A?"px-2 py-1.5":"px-3 py-2"} ${St} ${Pr(se.align)} ${se.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...qe?{position:"sticky",left:xe,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(vr,{children:se.cell(b)})},se.key)})]})]},O)})})]})})}),_r()]})}function Be(r){return r?new Date(`${r}T12:00:00`):void 0}function xr(r){return r.toISOString().slice(0,10)}function $t({calendarMonth:r,displayIndex:t}){const{previousMonth:a,nextMonth:n,goToMonth:o,months:l,labels:i,formatters:c}=ar.useDayPicker(),f=!!a&&t===0,p=!!n&&t===l.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:c.formatCaption(r.date)}),e.jsx("button",{type:"button","aria-label":i.labelPrevious(a),onClick:()=>a&&o(a),disabled:!f,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:f?1:.45,cursor:f?"pointer":"not-allowed"},children:e.jsx(w.HiChevronLeft,{size:16})}),e.jsx("button",{type:"button","aria-label":i.labelNext(n),onClick:()=>n&&o(n),disabled:!p,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:p?1:.45,cursor:p?"pointer":"not-allowed"},children:e.jsx(w.HiChevronRight,{size:16})})]})}function Mt(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Bt({startDate:r,endDate:t,onChange:a,minDate:n,viewMonth:o,numberOfMonths:l=1,showSummary:i=!0,startLabel:c="Inicio",endLabel:f="Regreso"}){const p={from:Be(r),to:Be(t)},N=Be(n),[g,v]=s.useState(Be(o||r));return s.useEffect(()=>{v(Be(o||r))},[o,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(ar.DayPicker,{mode:"range",selected:p,month:g,onMonthChange:v,onSelect:m=>{const h=m!=null&&m.from?xr(m.from):r,d=m!=null&&m.to?xr(m.to):"";a({startDate:h,endDate:d})},numberOfMonths:l,hideNavigation:!0,disabled:N?{before:N}:void 0,showOutsideDays:!1,components:{MonthCaption:$t},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:m=>Mt(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(m)),formatWeekdayName:m=>new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(m)},labels:{labelMonthDropdown:()=>"Mes",labelYearDropdown:()=>"Año"}})}),i&&r&&e.jsxs("div",{style:{marginTop:8,fontSize:12,color:"var(--text-muted)",display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsxs("span",{children:[c,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:r})]}),t&&e.jsxs("span",{children:[f,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:t})]})]})]})}function Lt(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Tt({trigger:r,items:t,align:a="end",width:n=220,disabled:o=!1,className:l="",menuClassName:i="",onOpenChange:c}){const[f,p]=s.useState(!1),[N,g]=s.useState(!1),[v,m]=s.useState({}),h=s.useRef(null),d=s.useRef(null),y=s.useCallback(x=>{p(x),c==null||c(x)},[c]),E=s.useCallback(()=>{const x=h.current;if(!x)return;const S=x.getBoundingClientRect(),L=typeof n=="number"?n:S.width,I=typeof n=="number"?n:Math.max(S.width,180),D=a==="end"?Math.max(8,S.right-I):Math.min(S.left,window.innerWidth-I-8),T=window.innerHeight-S.bottom,A=T<240&&S.top>T?void 0:S.bottom+6,F=A===void 0?window.innerHeight-S.top+6:void 0;m({position:"fixed",zIndex:9999,left:D,top:A,bottom:F,width:Lt(typeof n=="number"?L:n)})},[a,n]);s.useEffect(()=>g(!0),[]),s.useEffect(()=>{if(!f)return;E();const x=L=>{var D,T;const I=L.target;!((D=h.current)!=null&&D.contains(I))&&!((T=d.current)!=null&&T.contains(I))&&y(!1)},S=L=>{L.key==="Escape"&&y(!1)};return document.addEventListener("mousedown",x),window.addEventListener("keydown",S),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0),()=>{document.removeEventListener("mousedown",x),window.removeEventListener("keydown",S),window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[f,y,E]);const z=x=>{o||(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),y(!f))},P=s.isValidElement(r)?s.cloneElement(r,{onClick:()=>!o&&y(!f)}):r,B=f?e.jsx("div",{ref:d,role:"menu",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${i}`,style:v,children:t.map(x=>e.jsxs("div",{children:[x.separatorBefore&&e.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),e.jsxs("button",{type:"button",role:"menuitem",disabled:x.disabled,onClick:()=>{var S;x.disabled||((S=x.onSelect)==null||S.call(x),y(!1))},className:"flex w-full min-w-0 items-start gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:x.danger?"var(--danger)":"var(--text-main)"},children:[x.icon&&e.jsx("span",{className:"mt-0.5 shrink-0",children:x.icon}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm font-medium",children:x.label}),x.description&&e.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:x.description})]})]})]},x.id))}):null;return e.jsxs("span",{ref:h,role:"button",tabIndex:o?-1:0,"aria-haspopup":"menu","aria-expanded":f,onKeyDown:z,className:`inline-flex ${o?"pointer-events-none opacity-60":""} ${l}`,children:[P,N&&B?$e.createPortal(B,document.body):null]})}function Dt({open:r,onClose:t,title:a,subtitle:n,leadingIcon:o,confirmLabel:l="Guardar",onConfirm:i,loading:c=!1,confirmDisabled:f=!1,headerActions:p,bodyClassName:N="flex-1 overflow-y-auto px-6 py-5",width:g=440,children:v}){const[m,h]=s.useState(!1);return s.useEffect(()=>{h(!0)},[]),s.useEffect(()=>(document.body.style.overflow=r?"hidden":"",()=>{document.body.style.overflow=""}),[r]),s.useEffect(()=>{if(!r)return;const d=y=>{y.key==="Escape"&&t()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[r,t]),m?$e.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, ${g}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(ie,{variant:"icon",onClick:t,title:"Cerrar",children:e.jsx(w.HiXMark,{className:"w-5 h-5"})}),o&&e.jsx("div",{className:"flex-shrink-0",children:o}),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})]})]}),(p||i)&&e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[p,i&&e.jsxs(e.Fragment,{children:[e.jsx(ie,{variant:"secondary",size:"sm",onClick:t,style:{background:"var(--bg-input)"},children:"Cancelar"}),e.jsx(ie,{variant:"primary",size:"sm",icon:e.jsx(Wr.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:f,title:l})]})]})]}),e.jsx("div",{"data-drawer-scroll":"true",className:N,children:v})]})]}),document.body):null}const Ht={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function Ot({title:r="Sin resultados",description:t,icon:a=e.jsx(w.HiInbox,{className:"h-5 w-5"}),action:n,secondaryAction:o,size:l="md",className:i=""}){return e.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${Ht[l]} ${i}`,children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[a&&e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:a}),e.jsxs("div",{className:"space-y-1",children:[r&&e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-main)]",children:r}),t&&e.jsx("div",{className:"text-sm leading-5 text-[var(--text-muted)]",children:t})]}),(n||o)&&e.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[o,n]})]})})}function gr({label:r,children:t,helperText:a,error:n,labelAction:o,required:l=!1,className:i="",contentClassName:c=""}){return e.jsxs("label",{className:`flex flex-col gap-2 ${i}`,children:[(r||o)&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[r&&e.jsx("span",{children:r}),l&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),o&&e.jsx("span",{className:"ml-auto normal-case",children:o})]}),e.jsx("span",{className:`block ${c}`,children:t}),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]})}var yr={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},wr=s.createContext&&s.createContext(yr),At=["attr","size","title"];function It(r,t){if(r==null)return{};var a,n,o=Pt(r,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(r);for(n=0;n<l.length;n++)a=l[n],t.indexOf(a)===-1&&{}.propertyIsEnumerable.call(r,a)&&(o[a]=r[a])}return o}function Pt(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 Nr(r,t){var a=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(r,o).enumerable})),a.push.apply(a,n)}return a}function Pe(r){for(var t=1;t<arguments.length;t++){var a=arguments[t]!=null?arguments[t]:{};t%2?Nr(Object(a),!0).forEach(function(n){zt(r,n,a[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(a)):Nr(Object(a)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(a,n))})}return r}function zt(r,t,a){return(t=jt(t))in r?Object.defineProperty(r,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[t]=a,r}function jt(r){var t=_t(r,"string");return typeof t=="symbol"?t:t+""}function _t(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 kr(r){return r&&r.map((t,a)=>s.createElement(t.tag,Pe({key:a},t.attr),kr(t.child)))}function Sr(r){return t=>s.createElement(Ft,Ie({attr:Pe({},r.attr)},t),kr(r.child))}function Ft(r){var t=a=>{var{attr:n,size:o,title:l}=r,i=It(r,At),c=o||a.size||"1em",f;return a.className&&(f=a.className),r.className&&(f=(f?f+" ":"")+r.className),s.createElement("svg",Ie({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,n,i,{className:f,style:Pe(Pe({color:r.color||a.color},a.style),r.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),l&&s.createElement("title",null,l),r.children)};return wr!==void 0?s.createElement(wr.Consumer,null,a=>t(a)):t(yr)}function Wt(r){return Sr({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 Ut(r){return Sr({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-10 rounded-lg border border-[var(--border)] bg-[var(--bg-input)] px-2.5 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] ${r}`})}function qt({label:r,containerClassName:t="",helperText:a,error:n,labelAction:o,floatingLabel:l=!1,showPasswordToggle:i=!0,className:c="",required:f,...p}){const[N,g]=s.useState(()=>!!p.autoFocus),[v,m]=s.useState(!1),h=p.type==="password"&&i,d=h&&v?"text":p.type,y=p.value!==void 0?String(p.value).length>0:p.defaultValue!==void 0&&String(p.defaultValue).length>0,E=N||y,z={top:E?7:12,color:N?"var(--primary)":"var(--text-muted)",fontSize:E?10:13,fontWeight:E?600:400,textTransform:E?"uppercase":"none"},P=S=>{var L;g(!0),(L=p.onFocus)==null||L.call(p,S)},B=S=>{var L;g(!1),(L=p.onBlur)==null||L.call(p,S)},x=h?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:()=>m(S=>!S),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(Wt,{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(Ut,{className:"h-[18px] w-[18px]"})})]}):null;return l?e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"relative block",children:[e.jsx(ze,{...p,type:d,required:f,placeholder:" ","aria-invalid":!!n||p["aria-invalid"],"data-has-value":y?"true":void 0,className:`h-11 w-full pt-5 ${h?"pr-10":""} ${c}`,onFocus:P,onBlur:B}),e.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:z,children:[r,f&&e.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),o&&e.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:E?7:12},children:o}),x]}),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}),f&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),o&&e.jsx("span",{className:"ml-auto normal-case",children:o})]}),h?e.jsxs("span",{className:"relative block",children:[e.jsx(ze,{...p,type:d,required:f,"aria-invalid":!!n||p["aria-invalid"],className:`w-full pr-10 ${c}`,onFocus:P,onBlur:B}),x]}):e.jsx(ze,{...p,required:f,"aria-invalid":!!n||p["aria-invalid"],className:c}),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 Gt(r,t,a){const n=[],o=Math.max(2,r-a),l=Math.min(t-1,r+a);n.push(1),o>2&&n.push("...");for(let i=o;i<=l;i+=1)n.push(i);return l<t-1&&n.push("..."),t>1&&n.push(t),n}function Yt({page:r,totalPages:t,onPageChange:a,disabled:n=!1,siblingCount:o=1,className:l=""}){const i=Math.max(1,t),c=Math.min(Math.max(1,r),i),f=Gt(c,i,o);return e.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[e.jsx(ie,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:n||c<=1,onClick:()=>a(c-1),children:e.jsx(w.HiChevronLeft,{className:"h-4 w-4"})}),f.map((p,N)=>p==="..."?e.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${N}`):e.jsx("button",{type:"button","aria-current":p===c?"page":void 0,disabled:n,onClick:()=>a(p),className:"flex h-8 min-w-8 items-center justify-center rounded-md border px-2 text-xs font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-50",style:{borderColor:p===c?"var(--primary)":"var(--border)",background:p===c?"var(--primary)":"var(--bg-card)",color:p===c?"var(--primary-fg)":"var(--text-secondary)"},children:p},p)),e.jsx(ie,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:n||c>=i,onClick:()=>a(c+1),children:e.jsx(w.HiChevronRight,{className:"h-4 w-4"})})]})}function Xt({value:r,onChange:t,options:a,name:n,label:o,orientation:l="vertical",disabled:i=!1,className:c="",optionClassName:f=""}){return e.jsxs("fieldset",{className:`min-w-0 ${c}`,disabled:i,children:[o&&e.jsx("legend",{className:"mb-2 text-xs font-semibold uppercase text-[var(--text-muted)]",children:o}),e.jsx("div",{className:l==="horizontal"?"flex flex-wrap gap-2":"flex flex-col gap-2",children:a.map(p=>{const N=p.value===r,g=i||p.disabled;return e.jsxs("label",{className:`inline-flex min-w-0 items-start gap-2 rounded-lg border px-2.5 py-1.5 transition-colors ${g?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${f}`,style:{borderColor:N?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:N?"color-mix(in srgb, var(--primary) 8%, transparent)":"var(--bg-card)"},children:[e.jsxs("span",{className:"relative mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-[var(--border)] bg-[var(--bg-input)]",children:[e.jsx("input",{type:"radio",name:n,value:p.value,checked:N,disabled:g,onChange:()=>t(p.value),className:"absolute inset-0 opacity-0"}),e.jsx("span",{className:`h-2 w-2 rounded-full transition ${N?"scale-100 opacity-100":"scale-50 opacity-0"}`,style:{background:"var(--primary)"}})]}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:p.label}),p.description&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:p.description})]})]},p.value)})})]})}function Vt({title:r,subtitle:t,icon:a,actions:n,children:o,footer:l,className:i="",bodyClassName:c="p-4"}){const f=r||t||a||n;return e.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${i}`,children:[f&&e.jsxs("header",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-4 py-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[a&&e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--primary)]",children:a}),e.jsxs("div",{className:"min-w-0",children:[r&&e.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:r}),t&&e.jsx("div",{className:"truncate text-xs text-[var(--text-muted)]",children:t})]})]}),n&&e.jsx("div",{className:"shrink-0",children:n})]}),e.jsx("div",{className:c,children:o}),l&&e.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:l})]})}const Zt={neutral:{text:"var(--text-secondary)",bg:"var(--bg-input)",border:"var(--border)"},primary:{text:"var(--primary)",bg:"color-mix(in srgb, var(--primary) 10%, transparent)",border:"color-mix(in srgb, var(--primary) 24%, var(--border))"},success:{text:"#047857",bg:"rgba(16, 185, 129, 0.11)",border:"rgba(16, 185, 129, 0.24)"},warning:{text:"#b45309",bg:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)"},danger:{text:"var(--danger)",bg:"var(--danger-bg)",border:"color-mix(in srgb, var(--danger) 20%, var(--border))"},info:{text:"#2563eb",bg:"rgba(59, 130, 246, 0.11)",border:"rgba(59, 130, 246, 0.24)"}},Kt={xs:"min-h-5 px-1.5 text-[10px]",sm:"min-h-6 px-2 text-xs",md:"min-h-7 px-2.5 text-sm"};function Jt({children:r,tone:t="neutral",size:a="sm",icon:n,dot:o=!1,className:l=""}){const i=Zt[t];return e.jsxs("span",{className:`inline-flex max-w-full shrink-0 items-center gap-1.5 rounded-full border font-semibold leading-none ${Kt[a]} ${l}`,style:{color:i.text,background:i.bg,borderColor:i.border},children:[o&&e.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:i.text}}),n&&e.jsx("span",{className:"shrink-0",children:n}),e.jsx("span",{className:"min-w-0 truncate",children:r})]})}function Qt({tabs:r,activeTabId:t,defaultActiveTabId:a,onTabChange:n,ariaLabel:o="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:f=""}){const p=r.find(h=>!h.disabled)??r[0],N=t??a??(p==null?void 0:p.id),g=r.find(h=>h.id===N)??p,v=h=>{h.disabled||n==null||n(h.id)},m=h=>{const d=r.filter(E=>!E.disabled);if(!d.length||!g)return;const y=d.findIndex(E=>E.id===g.id);(h.key==="ArrowRight"||h.key==="ArrowDown")&&(h.preventDefault(),v(d[(y+1)%d.length])),(h.key==="ArrowLeft"||h.key==="ArrowUp")&&(h.preventDefault(),v(d[(y-1+d.length)%d.length])),h.key==="Home"&&(h.preventDefault(),v(d[0])),h.key==="End"&&(h.preventDefault(),v(d[d.length-1]))};return e.jsxs("div",{className:i,children:[e.jsx("div",{role:"tablist","aria-label":o,onKeyDown:m,className:`flex min-w-0 gap-1 overflow-x-auto ${l==="underline"?"border-b border-[var(--border)]":"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-1"} ${c}`,children:r.map(h=>{const d=h.id===(g==null?void 0:g.id);return e.jsxs("button",{type:"button",role:"tab","aria-selected":d,"aria-controls":`${h.id}-panel`,id:`${h.id}-tab`,disabled:h.disabled,tabIndex:d?0:-1,onClick:()=>v(h),className:`inline-flex min-h-8 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap px-2.5 text-sm font-semibold transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 ${l==="underline"?"border-b-2":"rounded-md border"}`,style:{color:d?"var(--primary)":"var(--text-muted)",borderColor:d?"var(--primary)":"transparent",background:l==="pills"&&d?"var(--bg-card)":"transparent"},children:[h.icon&&e.jsx("span",{className:"shrink-0",children:h.icon}),e.jsx("span",{children:h.label}),h.badge&&e.jsx("span",{className:"shrink-0",children:h.badge})]},h.id)})}),(g==null?void 0:g.content)!==void 0&&e.jsx("div",{role:"tabpanel",id:`${g.id}-panel`,"aria-labelledby":`${g.id}-tab`,className:`pt-4 ${f}`,children:g.content})]})}function ge(...r){return r.filter(Boolean).join(" ")}function Rt({steps:r,activeStepId:t,initialStepId:a,completedStepIds:n,defaultCompletedStepIds:o=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:c,allowBackNavigation:f=!0,showFooter:p=!0,previousLabel:N="Anterior",nextLabel:g="Siguiente",blockedNextLabel:v="Completa este paso",className:m="",headerClassName:h="",contentClassName:d="",footerClassName:y=""}){var de;const E=((de=r[0])==null?void 0:de.id)??"",[z,P]=s.useState(a??E),[B,x]=s.useState(o),S=t??z,L=n??B,I=s.useMemo(()=>new Set(L),[L]),D=Math.max(0,r.findIndex(H=>H.id===S)),T=r[D]??r[0],A=r.length<=1?100:D/(r.length-1)*100,F=H=>{n||x(H),i==null||i(H)},q=H=>{const W=r.find(V=>V.id===H);W&&(t||P(H),l==null||l(H,W))},U=H=>I.has(H),K=H=>r.slice(0,H).find(W=>!W.optional&&!I.has(W.id)),R=H=>{const W=r[H];return!W||W.disabled?!1:H===D||f&&H<D?!0:!K(H)},u=H=>{const W=r.findIndex(V=>V.id===H);return W>=0&&R(W)},M=H=>{const W=r.findIndex(V=>V.id===H);if(W<0)return!1;if(!R(W)){const V=K(W);return V&&(c==null||c(r[W],V)),!1}return q(H),!0},G=(H=T==null?void 0:T.id)=>{!H||I.has(H)||F([...L,H])},Y=(H=T==null?void 0:T.id)=>{if(!H)return;const W=r.findIndex(ae=>ae.id===H),V=L.filter(ae=>{const oe=r.findIndex(_=>_.id===ae);return oe>=0&&oe<W});F(V),W>=0&&D>W&&q(H)},Z=()=>D<=0?!1:M(r[D-1].id),re=()=>{const H=r[D+1];return H?M(H.id):!1},ce={activeStep:T,activeIndex:D,completedStepIds:L,isCompleted:U,isUnlocked:u,completeStep:G,uncompleteStep:Y,goToStep:M,goNext:re,goPrevious:Z};if(!T)return null;const te=r[D+1],ye=D>0,he=te?u(te.id):!1,be=typeof T.content=="function"?T.content(ce):T.content;return e.jsxs("section",{className:ge("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",m),children:[e.jsxs("div",{className:ge("border-b border-[var(--border)] bg-[var(--bg-input)]",h),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:`${A}%`}})}),e.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${r.length}, minmax(0, 1fr))`},children:r.map((H,W)=>{const V=H.id===T.id,ae=U(H.id),oe=R(W),_=K(W);return e.jsxs("button",{type:"button",disabled:!oe,"aria-current":V?"step":void 0,"aria-disabled":!oe,title:!oe&&_?`Completa ${_.title}`:H.title,onClick:()=>M(H.id),className:ge("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",V&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",ae&&!V&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!V&&!ae&&oe&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!oe&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[e.jsx("span",{className:ge("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",V&&"scale-x-100")}),e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:ge("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",V&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",ae&&!V&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!ae&&!V&&oe&&"border-[var(--border)] text-[var(--text-muted)]",!oe&&"border-[var(--border)] text-[var(--text-muted)]"),children:ae?e.jsx(w.HiCheck,{className:"h-4 w-4"}):oe?W+1:e.jsx(w.HiLockClosed,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:ge("block truncate text-xs font-semibold transition-colors duration-200",V?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[W+1,". ",H.title]}),H.description&&e.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:H.description})]}),H.badge&&e.jsx("span",{className:"shrink-0",children:H.badge})]})]},H.id)})})]}),e.jsx("div",{className:ge("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",d),children:be},T.id),p&&e.jsxs("div",{className:ge("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",y),children:[e.jsx(ie,{variant:"secondary",height:38,padding:"0 14px",icon:e.jsx(w.HiChevronLeft,{}),disabled:!ye,onClick:Z,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:[L.length," completados"]})]}),e.jsx(ie,{height:38,padding:"0 14px",icon:e.jsx(w.HiChevronRight,{}),disabled:!te||!he,onClick:re,children:te&&!he?v:g})]})]})}const ea={sm:"min-h-20 px-2.5 py-1.5 text-xs leading-5",md:"min-h-24 px-2.5 py-2 text-sm leading-5",lg:"min-h-32 px-3 py-2.5 text-sm leading-6"},ra={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function ta(r,t){if(r){if(typeof r=="function"){r(t);return}r.current=t}}function aa(r,t){return r!==void 0?String(r).length:t!==void 0?String(t).length:0}const Cr=s.forwardRef(function({className:t="",wrapperClassName:a="",size:n="md",resize:o="vertical",autoResize:l=!1,minRows:i,maxRows:c,showCount:f=!1,maxCount:p,status:N="default",icon:g,action:v,style:m,value:h,defaultValue:d,maxLength:y,onInput:E,...z},P){const B=s.useRef(null),x=aa(h,d),S=p??y,L=!!(g||v||f),I=N==="error"?"var(--danger)":N==="success"?"#16a34a":"var(--border)",D={...m??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},T=()=>{const F=B.current;!F||!l||(F.style.height="auto",F.style.height=`${F.scrollHeight}px`)};s.useEffect(T,[l,h]);const A=e.jsx("textarea",{...z,ref:F=>{B.current=F,ta(P,F)},value:h,defaultValue:d,maxLength:y,"aria-invalid":N==="error"||z["aria-invalid"],onInput:F=>{T(),E==null||E(F)},style:{...D,borderColor:I},className:`w-full rounded-lg border bg-[var(--bg-input)] text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-60 ${ea[n]} ${ra[l?"none":o]} ${g?"pl-8":""} ${v?"pr-10":""} ${t}`});return L?e.jsxs("span",{className:`relative block ${a}`,children:[g&&e.jsx("span",{className:"pointer-events-none absolute left-2.5 top-2.5 flex h-4 w-4 items-center justify-center text-[var(--text-muted)]",children:g}),A,v&&e.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:v}),f&&e.jsxs("span",{className:"absolute bottom-1.5 right-2 rounded bg-[var(--bg-input)] px-1.5 text-[10px] font-semibold text-[var(--text-muted)]",children:[x,S?`/${S}`:""]})]}):A});function na({label:r,containerClassName:t="",helperText:a,error:n,labelAction:o,required:l,className:i="",status:c,...f}){return e.jsx(gr,{label:r,required:l,helperText:a,error:n,labelAction:o,className:t,children:e.jsx(Cr,{...f,required:l,status:n?"error":c,className:`w-full ${i}`})})}const oa={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function sa({checked:r,disabled:t,onCheckedChange:a,size:n="sm",className:o="",...l}){const i=oa[n],c=r?i.width-i.thumb-i.padding*2:0;return e.jsx("button",{...l,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 ${o}`,style:{width:i.width,height:i.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:i.thumb,height:i.thumb,left:i.padding,top:"50%",transform:`translate(${c}px, -50%)`,background:r?"var(--primary-fg)":"var(--text-muted)"}})})}const Er=[".sidebar-scroll","[data-overlay-scroll='true']"].join(",");function la(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 $r(r){return r.classList.contains("sidebar-scroll")}function Mr(r){$r(r)&&r.querySelectorAll(".os-scrollbar-horizontal").forEach(t=>{t.style.display="none",t.style.height="0",t.style.pointerEvents="none"})}function Br(){return s.useEffect(()=>{const r=new WeakMap;let t=0;const a=()=>{t=0,document.querySelectorAll(Er).forEach(l=>{if(!la(l))return;if(rr.OverlayScrollbars(l)){Mr(l);return}const c=rr.OverlayScrollbars(l,{overflow:$r(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}});Mr(l),r.set(l,c)})},n=()=>{t||(t=window.requestAnimationFrame(a))};a();const o=new MutationObserver(n);return o.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","data-overlay-scroll"]}),window.addEventListener("resize",n),()=>{t&&window.cancelAnimationFrame(t),o.disconnect(),window.removeEventListener("resize",n),document.querySelectorAll(Er).forEach(l=>{var i;l instanceof HTMLElement&&((i=r.get(l))==null||i.destroy())})}},[]),null}const ia={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"}},Lr=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],ca={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},da="bonsaif.bot",ua="Bonsaif Bot",fa={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Tr(r){return typeof r=="string"?r.trim():""}function pa(r){let t=0;for(const a of r)t=t*31+a.charCodeAt(0)&65535;return Lr[t%Lr.length]}function ha(r,t){return r===da||t===ua}function ba(r,t){return`${r.replace(/\/$/,"")}${t}`}function Dr({userId:r,username:t,name:a,size:n="md",showName:o=!1,showTooltip:l,tooltipContent:i,fallbackLabel:c="Usuario",wrapperClassName:f="",labelClassName:p="",labelSize:N="xs",avatarVersion:g=0,className:v="",style:m}){var U;const[h,d]=s.useState(!1),y=typeof r=="string"&&r.trim()&&r!=="undefined"&&r!=="null"?r.trim():"";s.useEffect(()=>{d(!1)},[y,g]);const{wh:E,text:z}=ia[n],P=Tr(a)||Tr(t)||c,B=P.trim()[0]||"?",x=typeof process<"u"&&((U=process.env)==null?void 0:U.NEXT_PUBLIC_BASE_PATH)||"",S=ha(t,a),L=ba(x,"/favicon.svg"),I=y?`${x}/api/user/avatar/${y}${g?`?v=${g}`:""}`:"",T={xs:20,sm:28,md:36,lg:48,xl:64}[n],A=S?e.jsx("span",{className:`${E} ${fa[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:m,children:e.jsx("img",{src:L,alt:P,width:T,height:T,className:"h-full w-full object-contain"})}):I&&!h?e.jsx("img",{src:I,alt:P,width:T,height:T,className:`${E} rounded-full object-cover flex-shrink-0 ${v}`,style:m,onError:()=>d(!0)},`${y}-${g}`):e.jsx("span",{className:`${E} ${pa(P)} ${z} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${v}`,style:m,title:P,children:B});if(o)return e.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${f}`,children:[A,e.jsx("span",{className:`min-w-0 truncate ${ca[N]} font-medium text-[var(--text-main)] ${p}`,title:P,children:P})]});const F=l??!0,q=i??P;return F&&q?e.jsx(He,{as:"span",content:q,className:`inline-flex flex-shrink-0 ${f}`,children:A}):A}function ma({href:r,className:t,children:a}){return e.jsx("a",{href:r,className:t,children:a})}function va(r){return r.reduce((t,a)=>{const n=a.section??"Principal";return t[n]=[...t[n]??[],a],t},{})}function Hr({children:r,navItems:t=[],currentPath:a=typeof window>"u"?"/":window.location.pathname,user:n,appName:o="Bonsaif",appLogo:l,header:i,footer:c,onLogout:f,LinkComponent:p=ma}){const[N,g]=s.useState(!1),v=va(t);return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[e.jsx(Br,{}),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:()=>g(!0),children:e.jsx(w.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:()=>g(!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:l??e.jsx(w.HiHome,{className:"h-5 w-5"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:o}),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:()=>g(!1),children:e.jsx(w.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(([m,h])=>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(w.HiChevronDown,{className:"h-3.5 w-3.5"}),m]}),e.jsx("div",{className:"space-y-1",children:h.map(d=>{const y=a===d.href||a.startsWith(`${d.href}/`);return e.jsxs(p,{href:d.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${y?"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:d.icon??e.jsx(w.HiHome,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate",children:d.label})]},d.href)})})]},m))}),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(Dr,{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})]})]}),f&&e.jsxs(ie,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:f,children:[e.jsx(w.HiArrowRightOnRectangle,{className:"h-4 w-4"})," Salir"]}),c]})]}),e.jsxs("div",{className:"min-h-screen lg:pl-72",children:[i,e.jsx("main",{className:"min-h-screen",children:r})]})]})}const xa={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"},Ke={dashboard:e.jsx(w.HiChartBar,{className:"h-5 w-5"}),tickets:e.jsx(w.HiTicket,{className:"h-5 w-5"}),teams:e.jsx(w.HiUsers,{className:"h-5 w-5"}),projects:e.jsx(w.HiRectangleGroup,{className:"h-5 w-5"}),clients:e.jsx(w.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:e.jsx(w.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:e.jsx(w.HiUser,{className:"h-5 w-5"}),settings:e.jsx(w.HiCog6Tooth,{className:"h-5 w-5"}),notifications:e.jsx(w.HiBell,{className:"h-5 w-5"}),changelog:e.jsx(w.HiDocumentText,{className:"h-5 w-5"}),admin:e.jsx(w.HiShieldCheck,{className:"h-5 w-5"}),users:e.jsx(w.HiUsers,{className:"h-5 w-5"}),roles:e.jsx(w.HiShieldCheck,{className:"h-5 w-5"}),menus:e.jsx(w.HiCog6Tooth,{className:"h-5 w-5"}),guards:e.jsx(w.HiCalendarDays,{className:"h-5 w-5"}),vacations:e.jsx(w.HiCalendarDays,{className:"h-5 w-5"}),audit:e.jsx(w.HiListBullet,{className:"h-5 w-5"}),positions:e.jsx(w.HiBriefcase,{className:"h-5 w-5"}),ranks:e.jsx(w.HiListBullet,{className:"h-5 w-5"}),"email-inbox":e.jsx(w.HiInbox,{className:"h-5 w-5"}),"security-incidents":e.jsx(w.HiShieldCheck,{className:"h-5 w-5"})};function ga({href:r,className:t,style:a,children:n}){return e.jsx("a",{href:r,className:t,style:a,children:n})}function ya(r){return r.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function wa(r){return/^\d+$/.test(r)||/^[a-f0-9]{8,}$/i.test(r)}function Na(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,o=wa(a)&&n?n:a,l=xa[o]??ya(o);return[{label:"Inicio",href:"/"},{label:l}]}function Je(r){return(r==null?void 0:r.querySelector(":scope > .os-viewport"))??(r==null?void 0:r.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function ka(r){const t=r.split("/").filter(Boolean),a=t[t.length-1];if(!a)return e.jsx(w.HiHome,{className:"h-5 w-5"});if(Ke[a])return Ke[a];const n=t.length>1?t[t.length-2]:"";return Ke[n]??e.jsx(w.HiHome,{className:"h-5 w-5"})}function Sa({title:r,subtitle:t,action:a,meta:n,icon:o,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:f=typeof window>"u"?"/":window.location.pathname,showBreadcrumbs:p=!0,contained:N=!1,LinkComponent:g=ga}){const v=s.useRef(null),[m,h]=s.useState(!1),[d,y]=s.useState(null),E=c??Na(f),z=o??ka(f),P=p&&E.length>1;return s.useEffect(()=>{if(N){h(!1);return}let B=null,x=0,S=0;const L=()=>{const T=v.current,A=document.querySelector("[data-app-scroll='true']");return(T==null?void 0:T.closest(".os-viewport"))??(T==null?void 0:T.closest("[data-overlayscrollbars-viewport]"))??Je(A)??A??window},I=()=>{const T=B&&B!==window?B.scrollTop:window.scrollY;h(A=>A?T>24:T>72)},D=()=>{B==null||B.removeEventListener("scroll",I),B=L(),B.addEventListener("scroll",I,{passive:!0}),I()};return D(),x=window.requestAnimationFrame(D),S=window.setTimeout(D,120),()=>{window.cancelAnimationFrame(x),window.clearTimeout(S),B==null||B.removeEventListener("scroll",I)}},[N]),s.useEffect(()=>{if(N){y(null);return}let B=0;const x=[],S=()=>{const q=v.current,U=q==null?void 0:q.parentElement,K=document.querySelector("[data-app-scroll='true']"),R=Je(K)??K;if(!q||!U||!R){y(null);return}const u=U.getBoundingClientRect(),M=window.getComputedStyle(U),G=R.getBoundingClientRect(),Y=R instanceof HTMLElement&&R.clientWidth>0?R.clientWidth:G.width,Z=u.left+parseFloat(M.paddingLeft||"0"),re={marginLeft:Math.round(G.left-Z),width:Math.round(Y)};y(ce=>ce&&ce.marginLeft===re.marginLeft&&ce.width===re.width?ce:re)},L=()=>{window.cancelAnimationFrame(B),B=window.requestAnimationFrame(S)};L(),window.addEventListener("resize",L);const I=new ResizeObserver(L),D=v.current,T=D==null?void 0:D.parentElement,A=document.querySelector("[data-app-scroll='true']"),F=Je(A)??A;return[T,A,F].forEach(q=>{q&&I.observe(q)}),x.push(window.setTimeout(L,120)),x.push(window.setTimeout(L,280)),()=>{window.cancelAnimationFrame(B),window.removeEventListener("resize",L),I.disconnect(),x.forEach(q=>window.clearTimeout(q))}},[N]),e.jsx("div",{ref:v,"data-page-header":"true","data-compact":m?"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-4 sm:mb-0"} ${l}`,style:{...d?{marginLeft:d.marginLeft,width:d.width}:null,background:N?"var(--bg-card)":m?"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||m?"1px solid var(--border)":"1px solid transparent",boxShadow:m?"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 ${m?"min-h-9 gap-2 sm:min-h-10 sm:gap-2.5":"min-h-10 gap-2.5 sm:min-h-11 sm:gap-3"} ${i}`,children:[e.jsxs("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${m?"gap-1":"gap-1.5 sm:gap-2"}`,children:[P&&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 ${m?"text-[10px]":"text-[10px] sm:text-[11px]"}`,children:E.map((B,x)=>{const S=x===E.length-1;return e.jsxs("li",{className:"flex min-w-0 items-center gap-1.5",children:[x>0&&e.jsx(w.HiChevronRight,{className:"h-3.5 w-3.5 transition-[color,transform] duration-300 ease-out",style:{color:"var(--text-muted)"}}),B.href&&!S?e.jsx(g,{href:B.href,className:"truncate transition-colors duration-300 hover:underline",style:{color:"var(--text-muted)"},children:B.label}):e.jsx("span",{"aria-current":S?"page":void 0,className:S?"truncate font-semibold":"truncate",style:{color:S?"var(--text-main)":"var(--text-muted)"},children:B.label})]},`${B.label}-${x}`)})})}),e.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${m?"gap-2":"gap-2.5 sm:gap-3"}`,children:[e.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${m?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:P?"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 ${m?"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 ${m?"text-base sm:text-lg":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:r}),t&&e.jsx("p",{"aria-hidden":m,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${m?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-5 translate-y-0 opacity-100"}`,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 ${m?"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 ${m?"min-h-8 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:e.jsx(sr.Provider,{value:{compact:!0,headerAction:!0},children:a})})]})})}function Ca({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(Hr,{currentPath:t,...n,children:r})}function Or(){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 Ea(r,t,a){try{const n=new URL(r),o=n.searchParams.get("callbackUrl");if(o){const l=new URL(o,n.origin);return l.searchParams.set("theme",t),a&&(l.searchParams.set("primeAuthOrigin",window.location.origin),l.searchParams.set("primeAuthProjectKey",a)),n.searchParams.set("callbackUrl",`${l.pathname}${l.search}${l.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 $a({name:r,src:t,projectKey:a}){const[n,o]=s.useState(()=>Or()),l=s.useRef(null);s.useEffect(()=>{const f=new MutationObserver(()=>o(Or()));return f.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>f.disconnect()},[]);const i=s.useMemo(()=>Ea(t,n,a),[a,t,n]),c=s.useMemo(()=>{try{return new URL(i).origin}catch{return""}},[i]);return s.useEffect(()=>{if(!a)return;const f=a;function p(N){var m,h,d;if(N.source!==((m=l.current)==null?void 0:m.contentWindow)||c&&N.origin!==c)return;if(((h=N.data)==null?void 0:h.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!N.data.active}}));return}if(((d=N.data)==null?void 0:d.type)!=="prime-microservice:navigation")return;const g=N.data.path;if(!g||!g.startsWith("/")||g.startsWith("//"))return;const v=`/apps/${encodeURIComponent(f)}${g}`;`${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",p),()=>{window.removeEventListener("message",p),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[c,a]),e.jsx("div",{className:"flex h-full min-h-screen flex-col bg-[var(--bg-main)]",children:e.jsx("iframe",{ref:l,src:i,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 Ma(){const[r,t]=s.useState(""),[a,n]=s.useState(!1),[o,l]=s.useState({width:96,height:96});return s.useEffect(()=>{let i=!1;return fetch("/api/microservices/prime-suite/chat-url",{cache:"no-store"}).then(c=>c.ok?c.json():null).then(c=>{!i&&(c!=null&&c.src)&&t(c.src)}).catch(()=>{}),()=>{i=!0}},[]),s.useEffect(()=>{const i=c=>{var p;if(((p=c.data)==null?void 0:p.type)!=="prime-suite-chat:state")return;const f=!!c.data.active;n(f),l({width:Ar(c.data.width,96,720),height:Ar(c.data.height,96,560)})};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[]),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(${o.width}px, 100vw)`:96,height:a?`min(${o.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function Ar(r,t,a){const n=typeof r=="number"&&Number.isFinite(r)?r:t;return Math.max(t,Math.min(a,Math.ceil(n)))}function Ba(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 La(){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 Ta(){return"light"}function Da(){const r=s.useSyncExternalStore(Ba,La,Ta);return e.jsx(Ur.Toaster,{position:"bottom-center",theme:r,richColors:!0,closeButton:!0})}$.Alert=st,$.AuthShell=Hr,$.BonsaifButton=qr,$.Button=ie,$.CalendarPicker=ut,$.Checkbox=pt,$.CodeBlock=mt,$.CompactFilterSelect=xt,$.CompactSearchInput=vt,$.ConfirmDialog=wt,$.CopyButton=Ve,$.CopyLinkButton=kt,$.DataTable=Et,$.DateRangePicker=Bt,$.Drawer=Dt,$.DropdownMenu=Tt,$.DynamicDetailTabs=nt,$.EmptyState=Ot,$.FormField=gr,$.GlobalScrollbars=Br,$.InputField=qt,$.LoadingState=ir,$.MicroserviceFrame=$a,$.Modal=mr,$.MouseTooltip=He,$.PageHeader=Sa,$.PageSearchInput=or,$.Pagination=Yt,$.PrimeAuthRouteShell=Ca,$.PrimeAuthToaster=Da,$.PrimeSuiteChatFrame=Ma,$.RadioGroup=Xt,$.SearchableSelect=Ze,$.SectionPanel=Vt,$.StatusBadge=Jt,$.StepWizard=Rt,$.Tabs=Qt,$.TextInput=ze,$.Textarea=Cr,$.TextareaField=na,$.Toggle=sa,$.UserAvatar=Dr,$.cn=nr,Object.defineProperty($,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(D,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react-icons/hi2"),require("react"),require("react-dom"),require("overlayscrollbars"),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-icons/hi2","react","react-dom","overlayscrollbars","react-icons/md","overlayscrollbars-react","react-day-picker","react-day-picker/dist/style.css","react-icons/fi","sonner"],e):(D=typeof globalThis<"u"?globalThis:D||self,e(D.BonsaifUI={},D.jsxRuntime,D.ReactIconsHi2,D.React,D.ReactDOM,D.OverlayScrollbarsGlobal,D.ReactIconsMd,D.OverlayScrollbarsReact,D.ReactDayPicker,D.ReactDayPickerStyles,D.ReactIconsFi,D.Sonner))})(this,(function(D,e,w,o,Ee,rr,Wr,tr,ar,Fa,Ur,qr){"use strict";"use client";function nr(...r){return r.filter(Boolean).join(" ")}function Gr({variant:r="primary",className:t,type:a="button",children:n,...s}){return e.jsx("button",{className:nr("bonsaif-ui-button",`bonsaif-ui-button--${r}`,t),type:a,...s,children:n})}function or({value:r,onChange:t,placeholder:a,className:n="",autoFocus:s=!1,forceExpanded:l=!1,onEscape:i,size:u="default",inputTabIndex:f}){const p=o.useRef(null),[k,N]=o.useState(!1),g=l||k||r.trim().length>0,x=u==="sm"?"h-9 rounded-md":"h-10 rounded-lg",d=n||"w-48 sm:w-64 lg:w-72";o.useEffect(()=>{var b;s&&((b=p.current)==null||b.focus())},[s]);const h=()=>{var b;N(!0),(b=p.current)==null||b.focus()};return e.jsxs("div",{className:`relative flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${g?d:"w-24 sm:w-28"}`,onMouseDown:b=>{g||(b.preventDefault(),h())},children:[e.jsx(w.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:p,type:"text",tabIndex:f,"aria-label":a,value:r,onChange:b=>t(b.target.value),onKeyDown:b=>{b.key==="Escape"&&(i==null||i())},placeholder:g?a:"Buscar",className:`${x} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${g?"pl-9 pr-8":"cursor-pointer pl-9 pr-3"}`,style:{background:"color-mix(in srgb, var(--bg-card) 86%, transparent)",border:"1px solid var(--border)",color:"var(--text-main)"},onFocus:b=>{N(!0),b.currentTarget.style.borderColor="var(--primary)",b.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:b=>{N(!1),b.currentTarget.style.borderColor="var(--border)",b.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(w.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const sr=o.createContext({});function Xr(r){var n;const t=Array.from(r.querySelectorAll("*")).filter(s=>{var l;return s.scrollWidth>s.clientWidth&&!!((l=s.textContent)!=null&&l.trim())&&s.tagName.toLowerCase()!=="svg"&&!s.closest("svg")});return(r.scrollWidth>r.clientWidth||t.length>0)&&(((n=t[0])==null?void 0:n.textContent)??r.textContent??"").trim()||null}function Te({children:r,content:t,onlyWhenOverflow:a=!1,className:n="",style:s,as:l="div"}){const i=o.useRef(null),u=o.useRef(null),[f,p]=o.useState(null),[k,N]=o.useState("");o.useEffect(()=>{const d=i.current;d&&(d.querySelectorAll("[title]").forEach(h=>{const b=h.getAttribute("title");b&&(h.getAttribute("aria-label")||h.setAttribute("aria-label",b),h.removeAttribute("title"))}),d.querySelectorAll("svg title").forEach(h=>h.remove()))}),o.useLayoutEffect(()=>{if(!f)return;const d=u.current;if(!d)return;const h=12,b=14,E=d.getBoundingClientRect(),j=window.innerWidth-E.width-h,z=window.innerHeight-E.height-h;let L=f.mouseX+b,y=f.mouseY+b;L>j&&(L=f.mouseX-E.width-b),y>z&&(y=f.mouseY-E.height-b),L=Math.min(Math.max(h,L),Math.max(h,j)),y=Math.min(Math.max(h,y),Math.max(h,z)),(Math.abs(L-f.x)>.5||Math.abs(y-f.y)>.5)&&p(S=>S&&{...S,x:L,y})},[f]);const g=(d,h)=>{const b=i.current;if(b){if(a){const E=Xr(b);if(!E)return;N(E)}!a&&!t||p({mouseX:d,mouseY:h,x:d+14,y:h+14})}},x=a?k:t;return e.jsxs(e.Fragment,{children:[e.jsx(l,{ref:d=>{i.current=d},className:n,style:s,onMouseEnter:d=>g(d.clientX,d.clientY),onMouseMove:d=>{f&&g(d.clientX,d.clientY)},onMouseLeave:()=>p(null),children:r}),f&&x?Ee.createPortal(e.jsx("div",{ref:u,role:"tooltip",style:{position:"fixed",top:f.y,left:f.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:x}),document.body):null]})}function lr(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}const Yr="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",Vr={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:"text-[var(--text-muted)] hover:text-[var(--primary)] hover:bg-primary/5"},Zr="border border-[var(--border)] text-[var(--text-muted)] shadow-sm shadow-black/5 hover:border-[var(--border)] hover:bg-[var(--bg-input)] hover:text-[var(--primary)] active:scale-[0.98] transition-colors",Kr={xs:"h-8 px-2.5 text-xs",sm:"h-9 px-3.5 text-xs",md:"h-10 px-3.5 text-sm",lg:"h-11 px-4 text-sm font-semibold"},Jr={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},Qr={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function Ge(r){return typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(Ge).join(" ").trim():o.isValidElement(r)?Ge(r.props.children):""}function Rr(r){return o.Children.toArray(r).find(o.isValidElement)??null}function pe({variant:r="primary",size:t="md",loading:a=!1,icon:n,tooltip:s,iconOnly:l,height:i,padding:u,children:f,className:p="",disabled:k,style:N,...g}){const x=o.useContext(sr),d=l??x.iconOnly??r==="icon",h=x.compact??!1,b=x.headerAction??!1,E=h&&!b&&t==="md"?"xs":t,j=r==="icon"||d,z=b&&j,L=Ge(f),y=s??g.title??g["aria-label"]??(d?L:void 0),S=y?void 0:g.title,H=g["aria-label"]??(typeof y=="string"?y:L||void 0),P=a?null:n??(d?Rr(f):null),T=e.jsxs("button",{...g,title:S,"aria-label":H,"data-variant":r,"data-size":E,"data-icon":j?"true":void 0,disabled:k||a,className:`${Yr} ${z?Zr:Vr[r]} ${j?Jr[E]:Kr[E]} ${h&&!j?"px-2.5":""} ${p}`,style:{...Qr[r],height:lr(i),padding:lr(u),...N,...z?{width:"40px",height:"40px",padding:0,background:"var(--bg-card)",borderRadius:"8px"}:null},children:[a?e.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):P,!d&&f]});return y?e.jsx(Te,{as:"span",content:y,className:"inline-flex shrink-0",children:T}):T}function ir({variant:r="page",title:t="Cargando...",rows:a=6,children:n}){return r==="table"?e.jsx(cr,{rows:a}):r==="sections"?e.jsx(et,{rows:a}):r==="cards"?e.jsx(rt,{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 et({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(cr,{rows:a===0?r:Math.max(3,r-2),compact:!0})]},a))})}function rt({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 cr({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,s)=>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)]"})},s))}),Array.from({length:r}).map((n,s)=>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((l,i)=>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+(s*13+i*11)%36}%`}})},i))},s))]})}function dr(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 ur(r){return r.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function tt(r){return[r.label,dr(r.service),r.description,r.service].filter(Boolean).join(" ")}function at(r){return typeof r=="function"?r:r.default}function nt(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(pe,{className:"mt-4",height:36,padding:"0 14px",onClick:t,children:"Reintentar"})]})})}function ot({parentPanel:r,parentPanelComponent:t,renderParentPanel:a,parent:n,context:s,links:l,moduleRegistry:i,loadModule:u,activeService:f,initialService:p,onActiveServiceChange:k,canAccess:N,keepAlive:g=!0,title:x,subtitle:d,emptyState:h,loadingState:b,errorState:E=nt,renderTabLabel:j,searchableTabs:z="auto",tabsSearchThreshold:L=6,tabsSearchPlaceholder:y="Buscar modulo...",tabsSearchValue:S,onTabsSearchChange:H,emptySearchState:P,showTabCount:T=!0,className:B="",parentClassName:O="",contentClassName:_="",tabsClassName:U=""}){var ve;const F=o.useMemo(()=>l.filter(C=>!C.hidden&&((N==null?void 0:N(C,s))??!0)),[N,s,l]),Z=(ve=F.find(C=>!C.disabled))==null?void 0:ve.service,[ee,c]=o.useState(p??Z??""),[$,G]=o.useState({}),[Y,K]=o.useState({}),[ne,ue]=o.useState(""),[v,V]=o.useState(!1),se=o.useRef(Y),R=o.useRef(0),oe=S??ne,A=ur(oe),X=z===!0||z==="auto"&&F.length>=L,Q=X&&oe.trim().length>0,le=o.useMemo(()=>A?F.filter(C=>ur(tt(C)).includes(A)):F,[A,F]),ce=f??ee,q=F.find(C=>C.service===ce)??F.find(C=>!C.disabled);o.useEffect(()=>{!q&&Z&&c(Z)},[Z,q]),o.useEffect(()=>{se.current=Y},[Y]);const we=C=>{C.disabled||(f||c(C.service),k==null||k(C.service,C))},je=C=>{S===void 0&&ue(C),H==null||H(C)},Qe=(C,ae)=>{const re=le.filter(fe=>!fe.disabled),ge=re.findIndex(fe=>fe.service===ae.service);ge<0||((C.key==="ArrowRight"||C.key==="ArrowDown")&&(C.preventDefault(),we(re[(ge+1)%re.length])),(C.key==="ArrowLeft"||C.key==="ArrowUp")&&(C.preventDefault(),we(re[(ge-1+re.length)%re.length])),C.key==="Home"&&(C.preventDefault(),we(re[0])),C.key==="End"&&(C.preventDefault(),we(re[re.length-1])))},be=o.useCallback(()=>{if(!q)return;const C=q.service,ae=se.current[C];if(ae!=null&&ae.loading||ae!=null&&ae.component&&g)return;const re=(i==null?void 0:i[C])??u;if(!re){K(fe=>({...fe,[C]:{loading:!1,error:new Error(`No module loader found for service "${C}".`)}}));return}const ge=++R.current;K(fe=>({...fe,[C]:{...fe[C],loading:!0,error:void 0}})),re(q,s).then(fe=>{if(ge!==R.current&&!g)return;const He=at(fe);K(ke=>({...ke,[C]:{component:He,loading:!1}}))}).catch(fe=>{const He=fe instanceof Error?fe:new Error(String(fe));K(ke=>({...ke,[C]:{...ke[C],loading:!1,error:He}}))})},[s,g,u,i,q]);o.useEffect(be,[be]);const _e=q?$[q.service]??null:null,ie=q?Y[q.service]:void 0,Fe=ie==null?void 0:ie.component,$e=C=>{q&&G(ae=>({...ae,[q.service]:C}))},Le=()=>{q&&G(C=>({...C,[q.service]:null}))},We={context:s,parent:n,links:l,visibleLinks:F,filteredLinks:le,selectedLink:q,selectedService:q==null?void 0:q.service,activeItemId:_e,tabsSearch:oe,onSelectService:we,onOpenDetail:$e,onBackToList:Le},Ne=a?a(We):t?e.jsx(t,{...We}):r;return e.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${B}`,children:[e.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${O}`,children:Ne}),e.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${_}`,children:[(x||d||X||T)&&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:[x&&e.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:x}),d&&e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:d})]}),(X||T)&&e.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[T&&e.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[le.length," / ",F.length]}),X&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${v?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!v,children:e.jsx(or,{value:oe,onChange:je,placeholder:y,className:"w-full",autoFocus:v,forceExpanded:!0,onEscape:()=>V(!1),size:"sm",inputTabIndex:v?0:-1})}),e.jsx("button",{type:"button","aria-label":v?"Cerrar busqueda":"Buscar tabs","aria-expanded":v,onClick:()=>{v&&oe&&je(""),V(C=>!C)},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 ${v||Q?"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:v||Q?e.jsx(w.HiXMark,{className:"h-4 w-4"}):e.jsx(w.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),e.jsx("div",{role:"tablist","aria-label":x??"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 ${U}`,children:le.length>0?le.map(C=>{const ae=C.service===(q==null?void 0:q.service);return e.jsx("button",{type:"button",role:"tab","aria-selected":ae,disabled:C.disabled,onClick:()=>we(C),onKeyDown:re=>Qe(re,C),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 ${ae?"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:j?j(C,ae):e.jsxs(e.Fragment,{children:[C.icon,e.jsx("span",{children:C.label??dr(C.service)}),C.badge&&e.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:C.badge})]})},C.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:P??"No hay modulos que coincidan con la busqueda."})}),(q==null?void 0:q.description)&&e.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:q.description}),e.jsxs("div",{className:"min-h-[420px] p-4",children:[!q&&(h??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."})),q&&(ie==null?void 0:ie.loading)&&(b??e.jsx(ir,{title:"Cargando modulo..."})),q&&(ie==null?void 0:ie.error)&&E(ie.error,be),q&&Fe&&!(ie!=null&&ie.loading)&&!(ie!=null&&ie.error)&&e.jsx(Fe,{context:s,parent:n,link:q,activeItemId:_e,onOpenDetail:$e,onBackToList:Le})]})]})]})}const st={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:e.jsx(w.HiInformationCircle,{className:"h-5 w-5"})},success:{color:"#047857",background:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.24)",icon:e.jsx(w.HiCheckCircle,{className:"h-5 w-5"})},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)",icon:e.jsx(w.HiExclamationTriangle,{className:"h-5 w-5"})},danger:{color:"var(--danger)",background:"var(--danger-bg)",border:"color-mix(in srgb, var(--danger) 20%, var(--border))",icon:e.jsx(w.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:e.jsx(w.HiInformationCircle,{className:"h-5 w-5"})}};function lt({variant:r="info",title:t,children:a,icon:n,action:s,onDismiss:l,className:i=""}){const u=st[r];return e.jsxs("div",{role:r==="danger"||r==="warning"?"alert":"status",className:`flex items-start gap-3 rounded-lg border px-3 py-3 ${i}`,style:{background:u.background,borderColor:u.border},children:[e.jsx("div",{className:"mt-0.5 shrink-0",style:{color:u.color},children:n??u.icon}),e.jsxs("div",{className:"min-w-0 flex-1",children:[t&&e.jsx("div",{className:"text-sm font-semibold text-[var(--text-main)]",children:t}),a&&e.jsx("div",{className:"mt-0.5 text-sm leading-5 text-[var(--text-secondary)]",children:a}),s&&e.jsx("div",{className:"mt-3",children:s})]}),l&&e.jsx(pe,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:e.jsx(w.HiXMark,{className:"h-4 w-4"})})]})}const fr=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],it=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],ct=["Do","Lu","Ma","Mi","Ju","Vi","Sá"],Xe=6;function Ye(r,t,a){return`${r}-${String(t).padStart(2,"0")}-${String(a).padStart(2,"0")}`}function dt(){const r=new Date;return Ye(r.getFullYear(),r.getMonth()+1,r.getDate())}function pr(r){const[t,a,n]=r.split("-").map(Number);return{year:t,month:a,day:n}}function ut(r){if(!r)return"Seleccionar fecha";const{year:t,month:a,day:n}=pr(r);return!t||!a||!n?"Seleccionar fecha":`${String(n).padStart(2,"0")} ${fr[a-1]} ${t}`}function ft({value:r,onChange:t,minDate:a,displayMode:n="inline"}){const s=dt(),i=pr(r||s),u=n==="popover",[f,p]=o.useState(!1),k=o.useRef(null),[N,g]=o.useState({horizontal:"left",vertical:"bottom"}),[x,d]=o.useState(i.year),[h,b]=o.useState(i.month),[E,j]=o.useState("days"),z=16,[L,y]=o.useState(0),S=x-7+L,H=Array.from({length:z},(c,$)=>S+$);o.useEffect(()=>{if(!u||!f||!k.current)return;const c=k.current.getBoundingClientRect(),$=8,G=280,Y=340,K=c.left+G>window.innerWidth-$,ne=c.right-G>=$,ue=c.bottom+8+Y>window.innerHeight-$,v=c.top-8-Y>=$;g({horizontal:K&&ne?"right":"left",vertical:ue&&v?"top":"bottom"})},[u,f]),o.useEffect(()=>{if(!u||!f)return;function c(G){k.current&&(k.current.contains(G.target)||p(!1))}function $(G){G.key==="Escape"&&p(!1)}return document.addEventListener("mousedown",c),document.addEventListener("keydown",$),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",$)}},[u,f]);function P(){h===1?(d(c=>c-1),b(12)):b(c=>c-1)}function T(){h===12?(d(c=>c+1),b(1)):b(c=>c+1)}const B=new Date(x,h-1,1).getDay(),O=new Date(x,h,0).getDate(),_=[...Array(B).fill(null),...Array.from({length:O},(c,$)=>$+1)];for(;_.length<Xe*7;)_.push(null);const U=_.slice(0,Xe*7);function F(c){const $=Ye(x,h,c);a&&$<a||(t($),u&&p(!1))}const Z={background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,borderRadius:6,display:"flex",alignItems:"center"},ee=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:E==="days"?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:P,style:Z,title:"Mes anterior",children:e.jsx(w.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>{j("years"),y(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:[fr[h-1]," ",x,e.jsx(w.HiChevronDown,{size:13,style:{color:"var(--text-muted)"}})]}),e.jsx("button",{type:"button",onClick:T,style:Z,title:"Mes siguiente",children:e.jsx(w.HiChevronRight,{size:16})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>y(c=>c-z),style:Z,children:e.jsx(w.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>j("days"),style:{background:"none",border:"none",cursor:"pointer",fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[H[0]," – ",H[H.length-1]]}),e.jsx("button",{type:"button",onClick:()=>y(c=>c+z),style:Z,children:e.jsx(w.HiChevronRight,{size:16})})]})}),E==="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:it.map((c,$)=>{const G=$+1===h;return e.jsx("button",{type:"button",onClick:()=>b($+1),style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:11,fontWeight:G?700:400,padding:"4px 0",background:G?"var(--primary)":"transparent",color:G?"var(--primary-fg, #ffffff)":"var(--text-secondary)"},children:c},c)})}),e.jsx("div",{style:{height:1,background:"var(--border)",marginBottom:8}}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3},children:H.map(c=>{const $=c===x;return e.jsx("button",{type:"button",onClick:()=>{d(c),j("days")},style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:12,fontWeight:$?700:400,padding:"6px 0",background:$?"var(--primary)":"transparent",color:$?"var(--primary-fg, #ffffff)":"var(--text-main)",outline:c===new Date().getFullYear()&&!$?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:c},c)})})]}),E==="days"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",padding:"6px 8px 0"},children:ct.map(c=>e.jsx("div",{style:{textAlign:"center",fontSize:10,fontWeight:700,color:"var(--text-muted)",padding:"2px 0",textTransform:"uppercase"},children:c},c))}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",gridTemplateRows:`repeat(${Xe},1fr)`,padding:"4px 8px 10px",gap:2},children:U.map((c,$)=>{if(c===null)return e.jsx("div",{style:{aspectRatio:"1"}},$);const G=Ye(x,h,c),Y=G===r,K=G===s,ne=!!(a&&G<a);return e.jsx("button",{type:"button",onClick:()=>!ne&&F(c),style:{width:"100%",aspectRatio:"1",borderRadius:6,border:"none",cursor:ne?"not-allowed":"pointer",fontSize:12,fontWeight:Y||K?700:400,background:Y?"var(--primary)":"transparent",color:Y?"var(--primary-fg, #ffffff)":ne?"var(--text-muted)":"var(--text-main)",opacity:ne?.4:1,outline:K&&!Y?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:c},$)})})]})]});return u?e.jsxs("div",{ref:k,className:"relative w-full",children:[e.jsxs("button",{type:"button",onClick:()=>p(c=>!c),className:"flex h-10 w-full items-center justify-between gap-2 rounded-lg px-2.5 py-0 text-sm transition-all duration-150 focus:outline-none",style:{background:"var(--bg-input)",border:`1px solid ${f?"var(--primary)":"var(--border)"}`,color:"var(--text-main)",boxShadow:f?"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(w.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),e.jsx("span",{className:"truncate",children:ut(r)})]}),e.jsx(w.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${f?"rotate-180":""}`})]}),f&&e.jsx("div",{className:"absolute z-50",style:{...N.horizontal==="left"?{left:0}:{right:0},...N.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:ee})]}):ee}const pt={sm:"h-4 w-4",md:"h-5 w-5"};function ht({label:r,description:t,error:a,size:n="md",className:s="",containerClassName:l="",disabled:i,...u}){return e.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${i?"cursor-not-allowed opacity-60":"cursor-pointer"} ${l}`,children:[e.jsxs("span",{className:"relative mt-0.5 inline-flex shrink-0",children:[e.jsx("input",{...u,type:"checkbox",disabled:i,"aria-invalid":!!a||u["aria-invalid"],className:`peer ${pt[n]} appearance-none rounded border border-[var(--border)] bg-[var(--bg-input)] transition-colors checked:border-[var(--primary)] checked:bg-[var(--primary)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/40 ${s}`}),e.jsx(w.HiCheck,{className:"pointer-events-none absolute left-1/2 top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 scale-75 text-[var(--primary-fg)] opacity-0 transition peer-checked:scale-100 peer-checked:opacity-100"})]}),(r||t||a)&&e.jsxs("span",{className:"min-w-0",children:[r&&e.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:r}),t&&!a&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:t}),a&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--danger)]",children:a})]})]})}function hr(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 bt(r){var t;if((t=navigator.clipboard)!=null&&t.writeText){await navigator.clipboard.writeText(r);return}hr(r)}function mt(r){return typeof r=="function"?r():r}function Ve({value:r,resetDelay:t=2e3,title:a,copiedTitle:n="Copiado",copiedLabel:s,icon:l=e.jsx(w.HiClipboardDocument,{size:14}),copiedIcon:i=e.jsx(w.HiCheck,{size:14}),stopPropagation:u=!0,onCopied:f,onCopyError:p,className:k="",style:N,children:g,onClick:x,type:d="button",...h}){const[b,E]=o.useState(!1),j=o.useRef(null);o.useEffect(()=>()=>{j.current&&window.clearTimeout(j.current)},[]);function z(y){E(!0),f==null||f(y),j.current&&window.clearTimeout(j.current),j.current=window.setTimeout(()=>{E(!1),j.current=null},t)}async function L(y){var H;if(u&&y.stopPropagation(),x==null||x(y),y.defaultPrevented)return;const S=mt(r);if(S)try{await bt(S),z(S)}catch(P){try{hr(S),z(S)}catch(T){p==null||p(T,S);return}(H=navigator.clipboard)!=null&&H.writeText||p==null||p(P,S)}}return e.jsxs("button",{...h,type:d,onClick:L,title:b?n:a,"aria-label":h["aria-label"]??(b?n:a),"data-copied":b?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${g?"min-w-7 px-2":"w-7"} ${k}`,style:{cursor:"pointer",background:b?"rgba(22,163,74,0.15)":"var(--bg-card)",border:b?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:b?"#16a34a":"var(--text-secondary)",boxShadow:b?"0 0 0 3px rgba(22,163,74,0.12)":"none",...N},children:[e.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:b?"scale(1.15)":"scale(1)"},children:b?i:l}),g&&e.jsx("span",{className:"text-xs font-semibold leading-none",children:b?s??g:g})]})}function xt({code:r,children:t,title:a="Codigo",language:n,copyLabel:s="Copiar",copiedLabel:l="Copiado",className:i="",style:u,onCopied:f}){const p=(r??t??"").trim();return e.jsxs("div",{className:`overflow-hidden rounded-lg border ${i}`,style:{borderColor:"rgba(148, 163, 184, 0.22)",background:"#0f172a",color:"#e2e8f0",...u},children:[e.jsxs("div",{className:"flex min-h-9 items-center justify-between gap-3 border-b px-3 py-1.5",style:{borderColor:"rgba(148, 163, 184, 0.18)",background:"#111827",color:"#94a3b8"},children:[e.jsx("span",{className:"min-w-0 truncate text-[11px] font-black uppercase tracking-[0.08em]",children:a}),e.jsx(Ve,{value:p,title:"Copiar codigo",copiedTitle:"Codigo copiado",copiedLabel:l,onCopied:f,className:"h-7 min-w-[72px] px-2",style:{background:"#182235",border:"1px solid rgba(148, 163, 184, 0.28)",color:"#f8fafc"},children:s})]}),e.jsx("pre",{className:"m-0 overflow-x-auto p-3 text-xs leading-6",style:{background:"#0f172a",color:"#e2e8f0",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace'},children:e.jsx("code",{className:n?`language-${n}`:void 0,children:p})})]})}function br(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Ze({value:r,onChange:t,options:a,placeholder:n="Seleccionar…",emptyLabel:s,disabled:l=!1,className:i="",style:u,height:f=40,padding:p="0 10px",searchable:k=!0,minOptionsForSearch:N=6}){const[g,x]=o.useState(!1),[d,h]=o.useState(""),[b,E]=o.useState(-1),[j,z]=o.useState(!1),[L,y]=o.useState({}),S=o.useRef(null),H=o.useRef(null),P=o.useRef(null),T=o.useRef(null),B=k&&a.length>=N,O=a.find(c=>c.value===r)??null,_=B&&d.trim()?a.filter(c=>{var $;return c.label.toLowerCase().includes(d.toLowerCase())||(($=c.sublabel)==null?void 0:$.toLowerCase().includes(d.toLowerCase()))}):a,U=o.useCallback(()=>{const c=S.current;if(!c)return;const $=c.getBoundingClientRect(),G=B?272:212,Y=window.innerHeight-$.bottom,K=Y<G&&$.top>Y;y({position:"fixed",left:$.left,top:K?void 0:$.bottom+4,bottom:K?window.innerHeight-$.top+4:void 0,width:$.width,zIndex:9999})},[B]);o.useEffect(()=>z(!0),[]),o.useEffect(()=>{if(!g)return;function c($){var Y,K;const G=$.target;!((Y=S.current)!=null&&Y.contains(G))&&!((K=H.current)!=null&&K.contains(G))&&(x(!1),h(""))}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[g]),o.useEffect(()=>{g&&(E(-1),U(),B&&setTimeout(()=>{var c;return(c=P.current)==null?void 0:c.focus()},0))},[g,B,U]),o.useEffect(()=>{if(g)return window.addEventListener("resize",U),window.addEventListener("scroll",U,!0),()=>{window.removeEventListener("resize",U),window.removeEventListener("scroll",U,!0)}},[g,U]),o.useEffect(()=>{if(b<0||!T.current)return;const c=T.current.children[b];c==null||c.scrollIntoView({block:"nearest"})},[b]);const F=o.useCallback(c=>{t(c),x(!1),h("")},[t]);function Z(c){if(!g){(c.key==="Enter"||c.key===" "||c.key==="ArrowDown")&&(c.preventDefault(),x(!0));return}c.key==="Escape"?(c.preventDefault(),x(!1),h("")):c.key==="ArrowDown"?(c.preventDefault(),E($=>Math.min($+1,_.length-1))):c.key==="ArrowUp"?(c.preventDefault(),E($=>Math.max($-1,s?-1:0))):c.key==="Enter"&&(c.preventDefault(),b===-1&&s?F(""):_[b]&&F(_[b].value))}const ee=e.jsxs("div",{ref:H,className:"rounded-xl shadow-xl overflow-hidden",style:{...L,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[B&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(w.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:P,value:d,onChange:c=>{h(c.target.value),E(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),d&&e.jsx("button",{type:"button",onMouseDown:c=>{c.preventDefault(),h("")},children:e.jsx(w.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),e.jsxs("ul",{ref:T,role:"listbox",className:"overflow-y-auto",style:{maxHeight:B?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[s&&e.jsx("li",{role:"option","aria-selected":r==="",onMouseDown:c=>{c.preventDefault(),F("")},onMouseEnter:()=>E(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:b===-1?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:s}),_.map((c,$)=>{const Y=$===b,K=c.value===r;return e.jsxs("li",{role:"option","aria-selected":K,onMouseDown:ne=>{ne.preventDefault(),c.disabled||F(c.value)},onMouseEnter:()=>!c.disabled&&E($),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:Y?"var(--bg-hover)":K?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:c.disabled?"var(--text-muted)":"var(--text-main)",cursor:c.disabled?"not-allowed":"pointer",boxShadow:K?"inset 2px 0 0 var(--primary)":void 0},children:[c.color&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:c.color}}),e.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:c.label}),c.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:c.sublabel})]}),c.badge&&e.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:c.badge})]},c.value)}),_.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:S,className:`relative ${i||"w-full"}`,style:u,onKeyDown:Z,children:[e.jsxs("button",{type:"button",disabled:l,onClick:()=>!l&&x(c=>!c),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:br(f),padding:br(p),background:"var(--bg-input)",color:O?"var(--text-main)":"var(--text-muted)",border:g?"1px solid var(--primary)":"1px solid var(--border)",opacity:l?.5:1,cursor:l?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":g,children:[(O==null?void 0:O.color)&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:O.color}}),e.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:O?e.jsxs(e.Fragment,{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})]}):e.jsx("span",{className:"truncate",children:n})}),O&&s?e.jsx("span",{role:"button",tabIndex:-1,onMouseDown:c=>{c.preventDefault(),c.stopPropagation(),F("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(w.HiXMark,{className:"w-3 h-3"})}):e.jsx(w.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:g?"rotate(180deg)":"rotate(0deg)"}})]}),g&&j&&Ee.createPortal(ee,document.body)]})}function Ae(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function vt({value:r,onChange:t,placeholder:a="Buscar...",className:n="",height:s=40,padding:l="0 10px 0 30px",iconLeft:i=10}){return e.jsxs("div",{className:`relative ${n}`,children:[e.jsx(w.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:Ae(i)}}),e.jsx("input",{type:"text",value:r,onChange:u=>t(u.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:Ae(s),padding:Ae(l)}})]})}function gt({value:r,onChange:t,options:a,placeholder:n,icon:s,className:l="",height:i=40,padding:u,iconLeft:f=10,searchable:p=!0}){const k=s?a.map((N,g)=>g===0&&!N.color?{...N,sublabel:N.sublabel??void 0}:N):a;return e.jsxs("div",{className:`relative ${l}`,children:[s&&e.jsx("span",{className:"pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--text-muted)]",style:{left:Ae(f)},children:s}),e.jsx(Ze,{value:r,onChange:t,options:k,placeholder:n,searchable:p,minOptionsForSearch:5,height:i,padding:u??(s?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const yt={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},Oe=180;function mr({open:r,onClose:t,title:a,subtitle:n,leadingIcon:s,headerActions:l,footer:i,children:u,size:f="md",maxWidth:p,zIndex:k=1e3,closeOnBackdrop:N=!0,closeOnEscape:g=!0,showCloseButton:x=!0,placement:d="center",bodyClassName:h="px-6 py-5",panelClassName:b="",backdropClassName:E="bg-black/50 backdrop-blur-sm",contentClassName:j="p-4",ariaLabel:z,frameless:L=!1}){const[y,S]=o.useState(!1),[H,P]=o.useState(!1),T=o.useRef(null);if(o.useEffect(()=>(r?(T.current&&clearTimeout(T.current),S(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>P(!0)))):(P(!1),T.current=setTimeout(()=>S(!1),Oe+40)),()=>{T.current&&clearTimeout(T.current)}),[r]),o.useEffect(()=>{if(r)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[r]),o.useEffect(()=>{if(!r||!g)return;const Z=ee=>{ee.key==="Escape"&&t()};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[g,t,r]),!y)return null;const B=a||n||s||l||x,O=p??yt[f],_=d==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",U=d==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",F=H?"translateY(0) scale(1)":d==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return Ee.createPortal(e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":z??a,className:`fixed inset-0 flex ${_} ${j}`,style:{zIndex:k},children:[e.jsx("div",{className:`absolute inset-0 ${E}`,onClick:N?t:void 0,style:{opacity:H?1:0,transition:`opacity ${Oe}ms ease`}}),e.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${L?"shadow-none":"shadow-2xl"} ${U} ${b}`,style:{maxWidth:O,background:L?"transparent":"var(--bg-card)",border:L?"none":"1px solid var(--border)",opacity:H?1:0,transform:F,transition:`opacity ${Oe}ms ease, transform ${Oe}ms ease`},onClick:Z=>Z.stopPropagation(),children:[B&&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:[s&&e.jsx("div",{className:"flex-shrink-0",children:s}),(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:[l,x&&e.jsx(pe,{variant:"icon",onClick:t,title:"Cerrar",children:e.jsx(w.HiXMark,{className:"h-5 w-5"})})]})]}),e.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${h}`,children:u}),i&&e.jsx("div",{className:"flex flex-shrink-0 justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:i})]})]}),document.body)}const wt={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:s="Cancelar",variant:l="danger",onConfirm:i,onCancel:u}){const f=wt[l];return e.jsxs(mr,{open:r,onClose:u,size:"sm",zIndex:9998,showCloseButton:!1,bodyClassName:"p-6",panelClassName:"px-1",ariaLabel:t,children:[e.jsx(pe,{variant:"icon",onClick:u,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:e.jsx(w.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:f.iconBg},children:e.jsx(w.HiExclamationTriangle,{className:"h-5 w-5",style:{color:f.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(pe,{variant:"secondary",onClick:u,className:"flex-1",style:{background:"var(--bg-input)"},children:s}),e.jsx(pe,{variant:"danger",onClick:i,className:"flex-1",style:{background:f.btnBg,color:f.btnColor,borderColor:"transparent"},children:n})]})]})}function kt(r,t){const a=typeof r=="function"?r():r;return t?t(a):a}function St({url:r,resolveUrl:t,title:a="Copiar link",copiedTitle:n="Link copiado",icon:s=e.jsx(w.HiLink,{className:"h-3.5 w-3.5"}),...l}){return e.jsx(Ve,{...l,value:()=>kt(r,t),title:a,copiedTitle:n,icon:s})}const Ct="[&_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 Me(r){if(!r)return 150;const t=parseInt(r,10);return isNaN(t)||t<=0?150:t}function Se(r,t){const a=r.minWidth??80,n=r.maxWidth??1/0;return Math.min(n,Math.max(a,t))}function Et(r,t){if(t<=7)return Array.from({length:t},(n,s)=>s+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 xr({children:r,className:t="",style:a}){return e.jsx(Te,{onlyWhenOverflow:!0,className:t,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",...a},children:r})}function $t({columns:r,data:t,getRowId:a,loading:n=!1,skeletonRows:s=8,emptyIcon:l,emptyText:i="Sin resultados",onRowClick:u,selected:f,onToggleOne:p,onToggleAll:k,highlightSelected:N=!0,rowClassName:g,getRowCategory:x,stickyHeader:d=!0,pageSize:h=25,pageSizeOptions:b=[25,50,100],pageSizeSelectWidth:E=62,pageSizeSelectHeight:j=30,pageSizeSelectPadding:z="0 7px",totalRows:L,page:y,onPageChange:S,onPageSizeChange:H,storageKey:P,stickyFirstColumn:T=!1,bottomOffset:B=0,compact:O=!0,restrictHeight:_=!0,minTableWidth:U}){const F=r.map(m=>m.key).join(","),[Z,ee]=o.useState(!P),c=o.useRef(null),$=o.useRef(!P),G=(m,M)=>50+(m*17+M*13+7)%40,Y=o.useRef(null),[K,ne]=o.useState(void 0),[ue,v]=o.useState(!1);o.useEffect(()=>{const M=h!==!1?32:0,I=12;function W(){if(v(window.innerWidth<640),!Y.current)return;const J=Y.current.getBoundingClientRect().top;ne(Math.max(120,window.innerHeight-J-M-I-B))}return W(),window.addEventListener("resize",W),()=>window.removeEventListener("resize",W)},[n,h,B]);const[V,se]=o.useState(()=>r.map(m=>m.key)),[R,oe]=o.useState(()=>Object.fromEntries(r.map(m=>[m.key,Se(m,Me(m.width))])));o.useEffect(()=>{const m=r.map(I=>I.key);if(!P){se(m),$.current=!1,ee(!0);return}let M=!1;return $.current=!1,ee(!1),fetch(`/api/user/preferences/datatables?key=${encodeURIComponent(P)}`,{cache:"no-store"}).then(I=>I.ok?I.json():null).then(I=>{var Ue,qe;if(M)return;const W=(Ue=I==null?void 0:I.settings)==null?void 0:Ue.columnOrder,J=Array.isArray(W)?W.filter(me=>m.includes(me)):[],he=m.filter(me=>!J.includes(me)),xe=J.length>0?[...J,...he]:m,Ce=Object.fromEntries(r.map(me=>[me.key,Se(me,Me(me.width))])),te=((qe=I==null?void 0:I.settings)==null?void 0:qe.columnWidths)??{},de=Object.fromEntries(r.map(me=>[me.key,Se(me,te[me.key]??Ce[me.key])]));se(xe),oe(de),c.current=JSON.stringify({columnOrder:xe,columnWidths:de}),$.current=!0}).catch(()=>{if(!M){se(m);const I=Object.fromEntries(r.map(W=>[W.key,Se(W,Me(W.width))]));oe(I),c.current=JSON.stringify({columnOrder:m,columnWidths:I}),$.current=!0}}).finally(()=>{M||ee(!0)}),()=>{M=!0}},[P,F,r]),o.useEffect(()=>{if(!P||!Z||!$.current)return;const m={columnOrder:V,columnWidths:R},M=JSON.stringify(m);if(M===c.current)return;const I=window.setTimeout(()=>{fetch("/api/user/preferences/datatables",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:P,settings:m})}).then(W=>{W.ok&&(c.current=M)}).catch(()=>{})},300);return()=>window.clearTimeout(I)},[V,R,P,Z]),o.useEffect(()=>{se(m=>{const M=r.map(J=>J.key),I=m.filter(J=>M.includes(J)),W=M.filter(J=>!I.includes(J));return[...I,...W]})},[F,r]);const A=V.map(m=>r.find(M=>M.key===m)).filter(m=>!!m);o.useEffect(()=>{oe(m=>{const M=Object.fromEntries(r.map(I=>[I.key,Se(I,Me(I.width))]));return Object.fromEntries(r.map(I=>[I.key,Se(I,m[I.key]??M[I.key])]))})},[F,r]);const X=o.useRef(null);o.useEffect(()=>{function m(I){const W=X.current;if(!W)return;const J=I.clientX-W.startX,he=r.find(xe=>xe.key===W.colKey);he&&oe(xe=>({...xe,[W.colKey]:Se(he,W.startWidth+J)}))}function M(){X.current&&(X.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",m),document.addEventListener("pointerup",M),()=>{document.removeEventListener("pointermove",m),document.removeEventListener("pointerup",M)}},[r]);const Q=o.useRef(null),[le,ce]=o.useState(null);function q(m,M){Q.current=m,M.dataTransfer.effectAllowed="move"}function we(m,M){M.preventDefault(),M.dataTransfer.dropEffect="move",le!==m&&ce(m)}function je(m,M){M.preventDefault();const I=Q.current;I!==null&&I!==m&&se(W=>{const J=[...W],[he]=J.splice(I,1);return J.splice(m,0,he),J}),Q.current=null,ce(null)}function Qe(){Q.current=null,ce(null)}const[be,_e]=o.useState(null);function ie(m){m.sortKey&&_e(M=>(M==null?void 0:M.key)===m.key?{key:m.key,dir:M.dir==="asc"?"desc":"asc"}:{key:m.key,dir:"asc"})}const[Fe,$e]=o.useState(1),[Le,We]=o.useState(h===!1?0:h);o.useEffect(()=>{$e(1)},[t]);const Ne=!!(S&&H),ve=h!==!1,C=Ne?y??1:Fe,ae=Ne||ve?Le:t.length,re=!!f&&!!p&&!!k,ge=re?40:0,fe=re&&t.length>0&&f.size===t.length,He=re&&f.size>0&&f.size<t.length,ke=o.useMemo(()=>{if(!be)return t;const m=r.find(M=>M.key===be.key&&M.sortKey);return m!=null&&m.sortKey?[...t].sort((M,I)=>{const W=M[m.sortKey],J=I[m.sortKey],he=W===J?0:W==null?1:J==null||W<J?-1:1;return be.dir==="asc"?he:-he}):t},[t,be,r]),Pr=o.useMemo(()=>{if(Ne||!ve)return ke;const m=(C-1)*ae;return ke.slice(m,m+ae)},[ke,Ne,ve,C,ae]),Be=L??t.length,Re=ve?Math.max(1,Math.ceil(Be/ae)):1,Ia=ve?(C-1)*ae+1:1,Pa=ve?Math.min(C*ae,Be):Be;function er(m){const M=Math.max(1,Math.min(m,Re));Ne?S(M):$e(M)}function za(m){We(m),Ne?(H(m),S(1)):$e(1),H&&H(m)}const zr=m=>m==="center"?"text-center":m==="right"?"text-right":"text-left",ja="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",_a=A.length+(re?1:0);function jr(m){return m?typeof m=="string"?{key:m,label:m}:m:null}const _r=()=>e.jsxs("tr",{style:{background:"color-mix(in srgb, var(--bg-input) 72%, transparent)"},children:[re&&e.jsx("th",{className:`${O?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:T?{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:fe,ref:m=>{m&&(m.indeterminate=He)},onChange:k,className:"rounded cursor-pointer accent-[var(--primary)]"})}),A.map((m,M)=>{const I=(be==null?void 0:be.key)===m.key,W=!!m.sortKey,J=T&&!ue&&M===0,he=le===M,Ce=(R[m.key]??Me(m.width))<120;return e.jsxs("th",{className:`group select-none ${Ce?"text-left":zr(m.align)}`,style:{...J?{position:"sticky",left:ge,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:I?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:he?"2px solid var(--primary)":"2px solid transparent",cursor:W?"pointer":"default",padding:O?"5px 24px 5px 6px":"7px 28px 7px 6px"},onDragOver:te=>we(M,te),onDrop:te=>je(M,te),onClick:W?()=>ie(m):void 0,children:[e.jsx("span",{draggable:!0,onDragStart:te=>{te.stopPropagation(),q(M,te)},onDragEnd:te=>{te.stopPropagation(),Qe()},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(Wr.MdDragIndicator,{size:15})}),e.jsx(xr,{className:"inline-block max-w-full align-middle",style:{width:"calc(100% - 22px)",textAlign:Ce?"left":m.align==="center"?"center":m.align==="right"?"right":"left"},children:e.jsxs("span",{className:`inline-flex max-w-full items-center gap-1 font-semibold uppercase tracking-wider ${O?"text-[11px]":"text-xs"}`,children:[e.jsx("span",{className:"min-w-0 truncate",children:m.header}),W&&e.jsx("span",{className:"flex-shrink-0 opacity-60",children:I?be.dir==="asc"?e.jsx(w.HiChevronUp,{className:"w-3 h-3"}):e.jsx(w.HiChevronDown,{className:"w-3 h-3"}):e.jsx(w.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(),X.current={colKey:m.key,startX:te.clientX,startWidth:R[m.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"}})})]},m.key)})]}),Fr=()=>{if(!ve||n)return null;const m=Et(C,Re);return e.jsxs("div",{className:`grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 rounded-b-xl border-t text-xs select-none ${O?"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:Be===0?"0 filas":`${Ia}–${Pa} de ${Be}`}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),e.jsx(Ze,{value:String(ae),onChange:M=>za(Number(M)),options:b.map(M=>({value:String(M),label:String(M)})),placeholder:"Filas",searchable:!1,height:j,padding:z,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:E}})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[e.jsx("button",{disabled:C<=1,onClick:()=>er(C-1),className:"rounded p-0.5 transition-colors disabled:opacity-30",style:{color:"var(--text-muted)",background:"transparent"},children:e.jsx(w.HiChevronLeft,{className:"h-3.5 w-3.5"})}),m.map((M,I)=>M==="..."?e.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${I}`):e.jsx("button",{onClick:()=>er(M),className:"h-5 w-5 rounded text-[11px] font-medium transition-colors",style:{background:M===C?"var(--primary)":"transparent",color:M===C?"var(--primary-fg)":"var(--text-muted)"},children:M},M)),e.jsx("button",{disabled:C>=Re,onClick:()=>er(C+1),className:"rounded p-0.5 transition-colors disabled:opacity-30",style:{color:"var(--text-muted)",background:"transparent"},children:e.jsx(w.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{"aria-hidden":"true"})]})};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:Y,className:"min-w-0 max-w-full overflow-hidden rounded-t-xl",children:e.jsx(tr.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:_?K:void 0,maxWidth:"100%"},defer:!0,children:e.jsxs("table",{className:"text-sm",style:{tableLayout:"fixed",width:"100%",minWidth:U??"max-content",borderCollapse:"separate",borderSpacing:0},children:[e.jsxs("colgroup",{children:[re&&e.jsx("col",{style:{width:40}}),A.map(m=>e.jsx("col",{style:{width:R[m.key]??150}},m.key))]}),e.jsx("thead",{style:d?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:_r()}),e.jsx("tbody",{children:Array.from({length:s}).map((m,M)=>e.jsxs("tr",{children:[re&&e.jsx("td",{className:`${O?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:"1px solid var(--border)",borderRight:"1px solid var(--border)"}}),A.map((I,W)=>{const J=T&&!ue&&W===0;return e.jsx("td",{className:O?"px-2 py-1.5":"px-3 py-2",style:J?{position:"sticky",left:ge,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:`${G(M,W)}%`,minWidth:32}})},I.key)})]},M))})]})})}),Fr()]}):!n&&t.length===0?e.jsxs("div",{className:"py-20 flex flex-col items-center gap-3",children:[l&&e.jsx("div",{style:{color:"var(--text-muted)",opacity:.5},children:l}),e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:i})]}):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:Y,className:"min-w-0 max-w-full overflow-hidden rounded-t-xl",children:e.jsx(tr.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:_?K:void 0,maxWidth:"100%"},defer:!0,children:e.jsxs("table",{className:"text-sm",style:{tableLayout:"fixed",width:"100%",minWidth:U??"max-content",borderCollapse:"separate",borderSpacing:0},children:[e.jsxs("colgroup",{children:[re&&e.jsx("col",{style:{width:40}}),A.map(m=>e.jsx("col",{style:{width:R[m.key]??150}},m.key))]}),e.jsx("thead",{style:d?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:_r()}),e.jsx("tbody",{children:Pr.map((m,M)=>{const I=a(m),W=jr(x==null?void 0:x(m)),J=M>0?jr(x==null?void 0:x(Pr[M-1])):null,he=W&&W.key!==(J==null?void 0:J.key),xe=re&&f.has(I),Ce=!!u,te=xe&&N?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":M%2===1?"color-mix(in srgb, var(--bg-input) 50%, var(--bg-card))":"var(--bg-card)";return e.jsxs(o.Fragment,{children:[he&&e.jsx("tr",{className:W.className??"",children:e.jsx("td",{colSpan:_a,className:O?"px-2 py-2":"px-3 py-3",style:{background:"color-mix(in srgb, var(--primary) 8%, var(--bg-input))",borderBottom:"1px solid var(--border)",borderRight:"1px solid var(--border)"},children:e.jsx("div",{className:"flex min-w-0 items-center justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-xs font-semibold uppercase tracking-wider text-[var(--text-main)]",children:W.label}),W.description&&e.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:W.description})]})})})}),e.jsxs("tr",{onClick:Ce?()=>u(m):void 0,className:`transition-colors ${Ce?"cursor-pointer":""} ${g?g(m):""}`,style:{"--dt-row-bg":te,"--dt-sticky-bg":te,background:"var(--dt-row-bg)"},onMouseEnter:de=>{xe||(de.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),de.currentTarget.style.setProperty("--dt-sticky-bg",ja))},onMouseLeave:de=>{de.currentTarget.style.setProperty("--dt-row-bg",te),de.currentTarget.style.setProperty("--dt-sticky-bg",te)},children:[re&&e.jsx("td",{className:`${O?"px-2 py-1.5":"px-3 py-2"} w-10`,style:T?{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:de=>{de.stopPropagation(),p(I)},children:e.jsx("input",{type:"checkbox",checked:xe,onClick:de=>de.stopPropagation(),onChange:()=>p(I),className:"rounded cursor-pointer accent-[var(--primary)]"})}),A.map((de,Ue)=>{const qe=T&&!ue&&Ue===0;return e.jsx("td",{className:`${O?"px-2 py-1.5":"px-3 py-2"} ${Ct} ${zr(de.align)} ${de.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...qe?{position:"sticky",left:ge,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(xr,{children:de.cell(m)})},de.key)})]})]},I)})})]})})}),Fr()]})}function De(r){return r?new Date(`${r}T12:00:00`):void 0}function vr(r){return r.toISOString().slice(0,10)}function Mt({calendarMonth:r,displayIndex:t}){const{previousMonth:a,nextMonth:n,goToMonth:s,months:l,labels:i,formatters:u}=ar.useDayPicker(),f=!!a&&t===0,p=!!n&&t===l.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:u.formatCaption(r.date)}),e.jsx("button",{type:"button","aria-label":i.labelPrevious(a),onClick:()=>a&&s(a),disabled:!f,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:f?1:.45,cursor:f?"pointer":"not-allowed"},children:e.jsx(w.HiChevronLeft,{size:16})}),e.jsx("button",{type:"button","aria-label":i.labelNext(n),onClick:()=>n&&s(n),disabled:!p,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:p?1:.45,cursor:p?"pointer":"not-allowed"},children:e.jsx(w.HiChevronRight,{size:16})})]})}function Dt(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Lt({startDate:r,endDate:t,onChange:a,minDate:n,viewMonth:s,numberOfMonths:l=1,showSummary:i=!0,startLabel:u="Inicio",endLabel:f="Regreso"}){const p={from:De(r),to:De(t)},k=De(n),[N,g]=o.useState(De(s||r));return o.useEffect(()=>{g(De(s||r))},[s,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(ar.DayPicker,{mode:"range",selected:p,month:N,onMonthChange:g,onSelect:x=>{const d=x!=null&&x.from?vr(x.from):r,h=x!=null&&x.to?vr(x.to):"";a({startDate:d,endDate:h})},numberOfMonths:l,hideNavigation:!0,disabled:k?{before:k}:void 0,showOutsideDays:!1,components:{MonthCaption:Mt},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:x=>Dt(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(x)),formatWeekdayName:x=>new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(x)},labels:{labelMonthDropdown:()=>"Mes",labelYearDropdown:()=>"Año"}})}),i&&r&&e.jsxs("div",{style:{marginTop:8,fontSize:12,color:"var(--text-muted)",display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsxs("span",{children:[u,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:r})]}),t&&e.jsxs("span",{children:[f,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:t})]})]})]})}function Ht(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Bt({trigger:r,items:t,align:a="end",width:n=220,disabled:s=!1,className:l="",menuClassName:i="",onOpenChange:u}){const[f,p]=o.useState(!1),[k,N]=o.useState(!1),[g,x]=o.useState({}),d=o.useRef(null),h=o.useRef(null),b=o.useCallback(y=>{p(y),u==null||u(y)},[u]),E=o.useCallback(()=>{const y=d.current;if(!y)return;const S=y.getBoundingClientRect(),H=typeof n=="number"?n:S.width,P=typeof n=="number"?n:Math.max(S.width,180),T=a==="end"?Math.max(8,S.right-P):Math.min(S.left,window.innerWidth-P-8),B=window.innerHeight-S.bottom,O=B<240&&S.top>B?void 0:S.bottom+6,_=O===void 0?window.innerHeight-S.top+6:void 0;x({position:"fixed",zIndex:9999,left:T,top:O,bottom:_,width:Ht(typeof n=="number"?H:n)})},[a,n]);o.useEffect(()=>N(!0),[]),o.useEffect(()=>{if(!f)return;E();const y=H=>{var T,B;const P=H.target;!((T=d.current)!=null&&T.contains(P))&&!((B=h.current)!=null&&B.contains(P))&&b(!1)},S=H=>{H.key==="Escape"&&b(!1)};return document.addEventListener("mousedown",y),window.addEventListener("keydown",S),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0),()=>{document.removeEventListener("mousedown",y),window.removeEventListener("keydown",S),window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[f,b,E]);const j=y=>{s||(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),b(!f))},z=o.isValidElement(r)?o.cloneElement(r,{onClick:()=>!s&&b(!f)}):r,L=f?e.jsx("div",{ref:h,role:"menu",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${i}`,style:g,children:t.map(y=>e.jsxs("div",{children:[y.separatorBefore&&e.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),e.jsxs("button",{type:"button",role:"menuitem",disabled:y.disabled,onClick:()=>{var S;y.disabled||((S=y.onSelect)==null||S.call(y),b(!1))},className:"flex w-full min-w-0 items-start gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:y.danger?"var(--danger)":"var(--text-main)"},children:[y.icon&&e.jsx("span",{className:"mt-0.5 shrink-0",children:y.icon}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm font-medium",children:y.label}),y.description&&e.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:y.description})]})]})]},y.id))}):null;return e.jsxs("span",{ref:d,role:"button",tabIndex:s?-1:0,"aria-haspopup":"menu","aria-expanded":f,onKeyDown:j,className:`inline-flex ${s?"pointer-events-none opacity-60":""} ${l}`,children:[z,k&&L?Ee.createPortal(L,document.body):null]})}function Tt({open:r,onClose:t,title:a,subtitle:n,leadingIcon:s,confirmLabel:l="Guardar",onConfirm:i,loading:u=!1,confirmDisabled:f=!1,headerActions:p,bodyClassName:k="flex-1 overflow-y-auto px-6 py-5",width:N=440,children:g}){const[x,d]=o.useState(!1);return o.useEffect(()=>{d(!0)},[]),o.useEffect(()=>(document.body.style.overflow=r?"hidden":"",()=>{document.body.style.overflow=""}),[r]),o.useEffect(()=>{if(!r)return;const h=b=>{b.key==="Escape"&&t()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[r,t]),x?Ee.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, ${N}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(pe,{variant:"icon",onClick:t,title:"Cerrar",children:e.jsx(w.HiXMark,{className:"w-5 h-5"})}),s&&e.jsx("div",{className:"flex-shrink-0",children:s}),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})]})]}),(p||i)&&e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[p,i&&e.jsxs(e.Fragment,{children:[e.jsx(pe,{variant:"secondary",size:"sm",onClick:t,style:{background:"var(--bg-input)"},children:"Cancelar"}),e.jsx(pe,{variant:"primary",size:"sm",icon:e.jsx(Ur.FiSave,{className:"w-4 h-4"}),onClick:i,loading:u,disabled:f,title:l})]})]})]}),e.jsx("div",{"data-drawer-scroll":"true",className:k,children:g})]})]}),document.body):null}const At={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function Ot({title:r="Sin resultados",description:t,icon:a=e.jsx(w.HiInbox,{className:"h-5 w-5"}),action:n,secondaryAction:s,size:l="md",className:i=""}){return e.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${At[l]} ${i}`,children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[a&&e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:a}),e.jsxs("div",{className:"space-y-1",children:[r&&e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-main)]",children:r}),t&&e.jsx("div",{className:"text-sm leading-5 text-[var(--text-muted)]",children:t})]}),(n||s)&&e.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[s,n]})]})})}function gr({label:r,children:t,helperText:a,error:n,labelAction:s,required:l=!1,className:i="",contentClassName:u=""}){return e.jsxs("label",{className:`flex flex-col gap-2 ${i}`,children:[(r||s)&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[r&&e.jsx("span",{children:r}),l&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),s&&e.jsx("span",{className:"ml-auto normal-case",children:s})]}),e.jsx("span",{className:`block ${u}`,children:t}),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]})}var yr={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},wr=o.createContext&&o.createContext(yr),It=["attr","size","title"];function Pt(r,t){if(r==null)return{};var a,n,s=zt(r,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(r);for(n=0;n<l.length;n++)a=l[n],t.indexOf(a)===-1&&{}.propertyIsEnumerable.call(r,a)&&(s[a]=r[a])}return s}function zt(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 Nr(r,t){var a=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);t&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),a.push.apply(a,n)}return a}function Pe(r){for(var t=1;t<arguments.length;t++){var a=arguments[t]!=null?arguments[t]:{};t%2?Nr(Object(a),!0).forEach(function(n){jt(r,n,a[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(a)):Nr(Object(a)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(a,n))})}return r}function jt(r,t,a){return(t=_t(t))in r?Object.defineProperty(r,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[t]=a,r}function _t(r){var t=Ft(r,"string");return typeof t=="symbol"?t:t+""}function Ft(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 kr(r){return r&&r.map((t,a)=>o.createElement(t.tag,Pe({key:a},t.attr),kr(t.child)))}function Sr(r){return t=>o.createElement(Wt,Ie({attr:Pe({},r.attr)},t),kr(r.child))}function Wt(r){var t=a=>{var{attr:n,size:s,title:l}=r,i=Pt(r,It),u=s||a.size||"1em",f;return a.className&&(f=a.className),r.className&&(f=(f?f+" ":"")+r.className),o.createElement("svg",Ie({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,n,i,{className:f,style:Pe(Pe({color:r.color||a.color},a.style),r.style),height:u,width:u,xmlns:"http://www.w3.org/2000/svg"}),l&&o.createElement("title",null,l),r.children)};return wr!==void 0?o.createElement(wr.Consumer,null,a=>t(a)):t(yr)}function Ut(r){return Sr({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 qt(r){return Sr({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-10 rounded-lg border border-[var(--border)] bg-[var(--bg-input)] px-2.5 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] ${r}`})}function Gt({label:r,containerClassName:t="",helperText:a,error:n,labelAction:s,floatingLabel:l=!1,showPasswordToggle:i=!0,className:u="",required:f,...p}){const[k,N]=o.useState(()=>!!p.autoFocus),[g,x]=o.useState(!1),d=p.type==="password"&&i,h=d&&g?"text":p.type,b=p.value!==void 0?String(p.value).length>0:p.defaultValue!==void 0&&String(p.defaultValue).length>0,E=k||b,j={top:E?7:12,color:k?"var(--primary)":"var(--text-muted)",fontSize:E?10:13,fontWeight:E?600:400,textTransform:E?"uppercase":"none"},z=S=>{var H;N(!0),(H=p.onFocus)==null||H.call(p,S)},L=S=>{var H;N(!1),(H=p.onBlur)==null||H.call(p,S)},y=d?e.jsxs("button",{type:"button","aria-label":g?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":g,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:()=>x(S=>!S),children:[e.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${g?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:e.jsx(Ut,{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 ${g?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:e.jsx(qt,{className:"h-[18px] w-[18px]"})})]}):null;return l?e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"relative block",children:[e.jsx(ze,{...p,type:h,required:f,placeholder:" ","aria-invalid":!!n||p["aria-invalid"],"data-has-value":b?"true":void 0,className:`h-11 w-full pt-5 ${d?"pr-10":""} ${u}`,onFocus:z,onBlur:L}),e.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:j,children:[r,f&&e.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),s&&e.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:E?7:12},children:s}),y]}),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}),f&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),s&&e.jsx("span",{className:"ml-auto normal-case",children:s})]}),d?e.jsxs("span",{className:"relative block",children:[e.jsx(ze,{...p,type:h,required:f,"aria-invalid":!!n||p["aria-invalid"],className:`w-full pr-10 ${u}`,onFocus:z,onBlur:L}),y]}):e.jsx(ze,{...p,required:f,"aria-invalid":!!n||p["aria-invalid"],className:u}),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 Cr(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Xt(r,t){return r.length!==t.length?!1:r.every((a,n)=>a===t[n])}function Yt({value:r,onChange:t,options:a,placeholder:n="Seleccionar…",disabled:s=!1,className:l="",style:i,height:u=40,padding:f="0 10px",searchable:p=!0,minOptionsForSearch:k=6,maxVisibleValues:N=2,emptyText:g="Sin resultados",clearLabel:x="Limpiar seleccion"}){const[d,h]=o.useState(!1),[b,E]=o.useState(""),[j,z]=o.useState(0),[L,y]=o.useState(!1),[S,H]=o.useState({}),P=o.useRef(null),T=o.useRef(null),B=o.useRef(null),O=o.useRef(null),_=p&&a.length>=k,U=o.useMemo(()=>new Set(r),[r]),F=o.useMemo(()=>a.filter(v=>U.has(v.value)),[a,U]),Z=F.slice(0,N),ee=Math.max(0,F.length-Z.length),c=_&&b.trim()?a.filter(v=>{var V;return v.label.toLowerCase().includes(b.toLowerCase())||((V=v.sublabel)==null?void 0:V.toLowerCase().includes(b.toLowerCase()))}):a,$=o.useCallback(()=>{const v=P.current;if(!v)return;const V=v.getBoundingClientRect(),se=_?304:244,R=window.innerHeight-V.bottom,oe=R<se&&V.top>R;H({position:"fixed",left:V.left,top:oe?void 0:V.bottom+4,bottom:oe?window.innerHeight-V.top+4:void 0,width:V.width,zIndex:9999})},[_]),G=o.useCallback(v=>{Xt(r,v)||t(v)},[t,r]),Y=o.useCallback(v=>{const V=a.find(R=>R.value===v);if(V!=null&&V.disabled)return;const se=U.has(v)?r.filter(R=>R!==v):[...r,v];G(se)},[G,a,r,U]),K=o.useCallback(()=>G([]),[G]);o.useEffect(()=>y(!0),[]),o.useEffect(()=>{if(!d)return;function v(V){var R,oe;const se=V.target;!((R=P.current)!=null&&R.contains(se))&&!((oe=T.current)!=null&&oe.contains(se))&&(h(!1),E(""))}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[d]),o.useEffect(()=>{d&&(z(0),$(),_&&setTimeout(()=>{var v;return(v=B.current)==null?void 0:v.focus()},0))},[d,_,$]),o.useEffect(()=>{if(d)return window.addEventListener("resize",$),window.addEventListener("scroll",$,!0),()=>{window.removeEventListener("resize",$),window.removeEventListener("scroll",$,!0)}},[d,$]),o.useEffect(()=>{if(j<0||!O.current)return;const v=O.current.children[j];v==null||v.scrollIntoView({block:"nearest"})},[j]);function ne(v){if(!d){(v.key==="Enter"||v.key===" "||v.key==="ArrowDown")&&(v.preventDefault(),h(!0));return}v.key==="Escape"&&(v.preventDefault(),h(!1),E("")),v.key==="ArrowDown"&&(v.preventDefault(),z(V=>Math.min(V+1,c.length-1))),v.key==="ArrowUp"&&(v.preventDefault(),z(V=>Math.max(V-1,0))),v.key==="Enter"&&c[j]&&(v.preventDefault(),Y(c[j].value)),v.key==="Backspace"&&!b&&r.length&&(v.preventDefault(),G(r.slice(0,-1)))}const ue=e.jsxs("div",{ref:T,className:"overflow-hidden rounded-xl shadow-xl",style:{...S,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[_&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(w.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:B,value:b,onChange:v=>{E(v.target.value),z(0)},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),b&&e.jsx("button",{type:"button",onMouseDown:v=>{v.preventDefault(),E("")},children:e.jsx(w.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),F.length>0&&e.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 py-2 text-xs",style:{borderBottom:"1px solid var(--border)",color:"var(--text-muted)"},children:[e.jsxs("span",{children:[F.length," seleccionados"]}),e.jsx("button",{type:"button",onMouseDown:v=>{v.preventDefault(),K()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:x})]}),e.jsxs("ul",{ref:O,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:_?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[c.map((v,V)=>{const se=V===j,R=U.has(v.value);return e.jsxs("li",{role:"option","aria-selected":R,onMouseDown:oe=>{oe.preventDefault(),Y(v.value)},onMouseEnter:()=>!v.disabled&&z(V),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:se?"var(--bg-hover)":R?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:v.disabled?"var(--text-muted)":"var(--text-main)",cursor:v.disabled?"not-allowed":"pointer",opacity:v.disabled?.58:1},children:[e.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:R?"var(--primary)":"var(--border)",background:R?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:R&&e.jsx(w.HiCheck,{className:"h-3 w-3"})}),v.color&&e.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:v.color}}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:v.label}),v.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:v.sublabel})]}),v.badge&&e.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:v.badge})]},v.value)}),c.length===0&&e.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:g})]})]});return e.jsxs("div",{ref:P,className:`relative ${l||"w-full"}`,style:i,onKeyDown:ne,children:[e.jsxs("button",{type:"button",disabled:s,onClick:()=>!s&&h(v=>!v),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:Cr(u),padding:Cr(f),background:"var(--bg-input)",color:F.length?"var(--text-main)":"var(--text-muted)",border:d?"1px solid var(--primary)":"1px solid var(--border)",opacity:s?.5:1,cursor:s?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":d,children:[e.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:Z.length?e.jsxs(e.Fragment,{children:[Z.map(v=>e.jsxs("span",{className:"inline-flex max-w-[160px] items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold",style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[v.color&&e.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:v.color}}),e.jsx("span",{className:"truncate",children:v.label})]},v.value)),ee>0&&e.jsxs("span",{className:"inline-flex items-center rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{background:"color-mix(in srgb, var(--primary) 10%, transparent)",color:"var(--primary)"},children:["+",ee]})]}):e.jsx("span",{className:"truncate",children:n})}),F.length?e.jsx("span",{role:"button",tabIndex:-1,"aria-label":x,onMouseDown:v=>{v.preventDefault(),v.stopPropagation(),K()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(w.HiXMark,{className:"h-3 w-3"})}):e.jsx(w.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:d?"rotate(180deg)":"rotate(0deg)"}})]}),d&&L&&Ee.createPortal(ue,document.body)]})}function Vt(r,t,a){const n=[],s=Math.max(2,r-a),l=Math.min(t-1,r+a);n.push(1),s>2&&n.push("...");for(let i=s;i<=l;i+=1)n.push(i);return l<t-1&&n.push("..."),t>1&&n.push(t),n}function Zt({page:r,totalPages:t,onPageChange:a,disabled:n=!1,siblingCount:s=1,className:l=""}){const i=Math.max(1,t),u=Math.min(Math.max(1,r),i),f=Vt(u,i,s);return e.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[e.jsx(pe,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:n||u<=1,onClick:()=>a(u-1),children:e.jsx(w.HiChevronLeft,{className:"h-4 w-4"})}),f.map((p,k)=>p==="..."?e.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${k}`):e.jsx("button",{type:"button","aria-current":p===u?"page":void 0,disabled:n,onClick:()=>a(p),className:"flex h-8 min-w-8 items-center justify-center rounded-md border px-2 text-xs font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-50",style:{borderColor:p===u?"var(--primary)":"var(--border)",background:p===u?"var(--primary)":"var(--bg-card)",color:p===u?"var(--primary-fg)":"var(--text-secondary)"},children:p},p)),e.jsx(pe,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:n||u>=i,onClick:()=>a(u+1),children:e.jsx(w.HiChevronRight,{className:"h-4 w-4"})})]})}function Kt({value:r,onChange:t,options:a,name:n,label:s,orientation:l="vertical",disabled:i=!1,className:u="",optionClassName:f=""}){return e.jsxs("fieldset",{className:`min-w-0 ${u}`,disabled:i,children:[s&&e.jsx("legend",{className:"mb-2 text-xs font-semibold uppercase text-[var(--text-muted)]",children:s}),e.jsx("div",{className:l==="horizontal"?"flex flex-wrap gap-2":"flex flex-col gap-2",children:a.map(p=>{const k=p.value===r,N=i||p.disabled;return e.jsxs("label",{className:`inline-flex min-w-0 items-start gap-2 rounded-lg border px-2.5 py-1.5 transition-colors ${N?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${f}`,style:{borderColor:k?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:k?"color-mix(in srgb, var(--primary) 8%, transparent)":"var(--bg-card)"},children:[e.jsxs("span",{className:"relative mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-[var(--border)] bg-[var(--bg-input)]",children:[e.jsx("input",{type:"radio",name:n,value:p.value,checked:k,disabled:N,onChange:()=>t(p.value),className:"absolute inset-0 opacity-0"}),e.jsx("span",{className:`h-2 w-2 rounded-full transition ${k?"scale-100 opacity-100":"scale-50 opacity-0"}`,style:{background:"var(--primary)"}})]}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:p.label}),p.description&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:p.description})]})]},p.value)})})]})}function Jt({title:r,subtitle:t,icon:a,actions:n,children:s,footer:l,className:i="",bodyClassName:u="p-4"}){const f=r||t||a||n;return e.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${i}`,children:[f&&e.jsxs("header",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-4 py-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[a&&e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--primary)]",children:a}),e.jsxs("div",{className:"min-w-0",children:[r&&e.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:r}),t&&e.jsx("div",{className:"truncate text-xs text-[var(--text-muted)]",children:t})]})]}),n&&e.jsx("div",{className:"shrink-0",children:n})]}),e.jsx("div",{className:u,children:s}),l&&e.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:l})]})}const Qt={neutral:{text:"var(--text-secondary)",bg:"var(--bg-input)",border:"var(--border)"},primary:{text:"var(--primary)",bg:"color-mix(in srgb, var(--primary) 10%, transparent)",border:"color-mix(in srgb, var(--primary) 24%, var(--border))"},success:{text:"#047857",bg:"rgba(16, 185, 129, 0.11)",border:"rgba(16, 185, 129, 0.24)"},warning:{text:"#b45309",bg:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)"},danger:{text:"var(--danger)",bg:"var(--danger-bg)",border:"color-mix(in srgb, var(--danger) 20%, var(--border))"},info:{text:"#2563eb",bg:"rgba(59, 130, 246, 0.11)",border:"rgba(59, 130, 246, 0.24)"}},Rt={xs:"min-h-5 px-1.5 text-[10px]",sm:"min-h-6 px-2 text-xs",md:"min-h-7 px-2.5 text-sm"};function ea({children:r,tone:t="neutral",size:a="sm",icon:n,dot:s=!1,className:l=""}){const i=Qt[t];return e.jsxs("span",{className:`inline-flex max-w-full shrink-0 items-center gap-1.5 rounded-full border font-semibold leading-none ${Rt[a]} ${l}`,style:{color:i.text,background:i.bg,borderColor:i.border},children:[s&&e.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:i.text}}),n&&e.jsx("span",{className:"shrink-0",children:n}),e.jsx("span",{className:"min-w-0 truncate",children:r})]})}function ra({tabs:r,activeTabId:t,defaultActiveTabId:a,onTabChange:n,ariaLabel:s="Pestanas",variant:l="underline",className:i="",listClassName:u="",panelClassName:f=""}){const p=r.find(d=>!d.disabled)??r[0],k=t??a??(p==null?void 0:p.id),N=r.find(d=>d.id===k)??p,g=d=>{d.disabled||n==null||n(d.id)},x=d=>{const h=r.filter(E=>!E.disabled);if(!h.length||!N)return;const b=h.findIndex(E=>E.id===N.id);(d.key==="ArrowRight"||d.key==="ArrowDown")&&(d.preventDefault(),g(h[(b+1)%h.length])),(d.key==="ArrowLeft"||d.key==="ArrowUp")&&(d.preventDefault(),g(h[(b-1+h.length)%h.length])),d.key==="Home"&&(d.preventDefault(),g(h[0])),d.key==="End"&&(d.preventDefault(),g(h[h.length-1]))};return e.jsxs("div",{className:i,children:[e.jsx("div",{role:"tablist","aria-label":s,onKeyDown:x,className:`flex min-w-0 gap-1 overflow-x-auto ${l==="underline"?"border-b border-[var(--border)]":"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-1"} ${u}`,children:r.map(d=>{const h=d.id===(N==null?void 0:N.id);return e.jsxs("button",{type:"button",role:"tab","aria-selected":h,"aria-controls":`${d.id}-panel`,id:`${d.id}-tab`,disabled:d.disabled,tabIndex:h?0:-1,onClick:()=>g(d),className:`inline-flex min-h-8 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap px-2.5 text-sm font-semibold transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 ${l==="underline"?"border-b-2":"rounded-md border"}`,style:{color:h?"var(--primary)":"var(--text-muted)",borderColor:h?"var(--primary)":"transparent",background:l==="pills"&&h?"var(--bg-card)":"transparent"},children:[d.icon&&e.jsx("span",{className:"shrink-0",children:d.icon}),e.jsx("span",{children:d.label}),d.badge&&e.jsx("span",{className:"shrink-0",children:d.badge})]},d.id)})}),(N==null?void 0:N.content)!==void 0&&e.jsx("div",{role:"tabpanel",id:`${N.id}-panel`,"aria-labelledby":`${N.id}-tab`,className:`pt-4 ${f}`,children:N.content})]})}function ye(...r){return r.filter(Boolean).join(" ")}function ta({steps:r,activeStepId:t,initialStepId:a,completedStepIds:n,defaultCompletedStepIds:s=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:u,allowBackNavigation:f=!0,showFooter:p=!0,previousLabel:k="Anterior",nextLabel:N="Siguiente",blockedNextLabel:g="Completa este paso",className:x="",headerClassName:d="",contentClassName:h="",footerClassName:b=""}){var oe;const E=((oe=r[0])==null?void 0:oe.id)??"",[j,z]=o.useState(a??E),[L,y]=o.useState(s),S=t??j,H=n??L,P=o.useMemo(()=>new Set(H),[H]),T=Math.max(0,r.findIndex(A=>A.id===S)),B=r[T]??r[0],O=r.length<=1?100:T/(r.length-1)*100,_=A=>{n||y(A),i==null||i(A)},U=A=>{const X=r.find(Q=>Q.id===A);X&&(t||z(A),l==null||l(A,X))},F=A=>P.has(A),Z=A=>r.slice(0,A).find(X=>!X.optional&&!P.has(X.id)),ee=A=>{const X=r[A];return!X||X.disabled?!1:A===T||f&&A<T?!0:!Z(A)},c=A=>{const X=r.findIndex(Q=>Q.id===A);return X>=0&&ee(X)},$=A=>{const X=r.findIndex(Q=>Q.id===A);if(X<0)return!1;if(!ee(X)){const Q=Z(X);return Q&&(u==null||u(r[X],Q)),!1}return U(A),!0},G=(A=B==null?void 0:B.id)=>{!A||P.has(A)||_([...H,A])},Y=(A=B==null?void 0:B.id)=>{if(!A)return;const X=r.findIndex(le=>le.id===A),Q=H.filter(le=>{const ce=r.findIndex(q=>q.id===le);return ce>=0&&ce<X});_(Q),X>=0&&T>X&&U(A)},K=()=>T<=0?!1:$(r[T-1].id),ne=()=>{const A=r[T+1];return A?$(A.id):!1},ue={activeStep:B,activeIndex:T,completedStepIds:H,isCompleted:F,isUnlocked:c,completeStep:G,uncompleteStep:Y,goToStep:$,goNext:ne,goPrevious:K};if(!B)return null;const v=r[T+1],V=T>0,se=v?c(v.id):!1,R=typeof B.content=="function"?B.content(ue):B.content;return e.jsxs("section",{className:ye("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",x),children:[e.jsxs("div",{className:ye("border-b border-[var(--border)] bg-[var(--bg-input)]",d),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:`${O}%`}})}),e.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${r.length}, minmax(0, 1fr))`},children:r.map((A,X)=>{const Q=A.id===B.id,le=F(A.id),ce=ee(X),q=Z(X);return e.jsxs("button",{type:"button",disabled:!ce,"aria-current":Q?"step":void 0,"aria-disabled":!ce,title:!ce&&q?`Completa ${q.title}`:A.title,onClick:()=>$(A.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",Q&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",le&&!Q&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!Q&&!le&&ce&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!ce&&"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",Q&&"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",Q&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",le&&!Q&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!le&&!Q&&ce&&"border-[var(--border)] text-[var(--text-muted)]",!ce&&"border-[var(--border)] text-[var(--text-muted)]"),children:le?e.jsx(w.HiCheck,{className:"h-4 w-4"}):ce?X+1:e.jsx(w.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",Q?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[X+1,". ",A.title]}),A.description&&e.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:A.description})]}),A.badge&&e.jsx("span",{className:"shrink-0",children:A.badge})]})]},A.id)})})]}),e.jsx("div",{className:ye("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",h),children:R},B.id),p&&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",b),children:[e.jsx(pe,{variant:"secondary",height:38,padding:"0 14px",icon:e.jsx(w.HiChevronLeft,{}),disabled:!V,onClick:K,children:k}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[e.jsxs("span",{children:["Paso ",T+1," de ",r.length]}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),e.jsxs("span",{children:[H.length," completados"]})]}),e.jsx(pe,{height:38,padding:"0 14px",icon:e.jsx(w.HiChevronRight,{}),disabled:!v||!se,onClick:ne,children:v&&!se?g:N})]})]})}const aa={sm:"min-h-20 px-2.5 py-1.5 text-xs leading-5",md:"min-h-24 px-2.5 py-2 text-sm leading-5",lg:"min-h-32 px-3 py-2.5 text-sm leading-6"},na={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function oa(r,t){if(r){if(typeof r=="function"){r(t);return}r.current=t}}function sa(r,t){return r!==void 0?String(r).length:t!==void 0?String(t).length:0}const Er=o.forwardRef(function({className:t="",wrapperClassName:a="",size:n="md",resize:s="vertical",autoResize:l=!1,minRows:i,maxRows:u,showCount:f=!1,maxCount:p,status:k="default",icon:N,action:g,style:x,value:d,defaultValue:h,maxLength:b,onInput:E,...j},z){const L=o.useRef(null),y=sa(d,h),S=p??b,H=!!(N||g||f),P=k==="error"?"var(--danger)":k==="success"?"#16a34a":"var(--border)",T={...x??{},...i?{minHeight:`${i*24+18}px`}:null,...u?{maxHeight:`${u*24+18}px`}:null},B=()=>{const _=L.current;!_||!l||(_.style.height="auto",_.style.height=`${_.scrollHeight}px`)};o.useEffect(B,[l,d]);const O=e.jsx("textarea",{...j,ref:_=>{L.current=_,oa(z,_)},value:d,defaultValue:h,maxLength:b,"aria-invalid":k==="error"||j["aria-invalid"],onInput:_=>{B(),E==null||E(_)},style:{...T,borderColor:P},className:`w-full rounded-lg border bg-[var(--bg-input)] text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-60 ${aa[n]} ${na[l?"none":s]} ${N?"pl-8":""} ${g?"pr-10":""} ${t}`});return H?e.jsxs("span",{className:`relative block ${a}`,children:[N&&e.jsx("span",{className:"pointer-events-none absolute left-2.5 top-2.5 flex h-4 w-4 items-center justify-center text-[var(--text-muted)]",children:N}),O,g&&e.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:g}),f&&e.jsxs("span",{className:"absolute bottom-1.5 right-2 rounded bg-[var(--bg-input)] px-1.5 text-[10px] font-semibold text-[var(--text-muted)]",children:[y,S?`/${S}`:""]})]}):O});function la({label:r,containerClassName:t="",helperText:a,error:n,labelAction:s,required:l,className:i="",status:u,...f}){return e.jsx(gr,{label:r,required:l,helperText:a,error:n,labelAction:s,className:t,children:e.jsx(Er,{...f,required:l,status:n?"error":u,className:`w-full ${i}`})})}const ia={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function ca({checked:r,disabled:t,onCheckedChange:a,size:n="sm",className:s="",...l}){const i=ia[n],u=r?i.width-i.thumb-i.padding*2:0;return e.jsx("button",{...l,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 ${s}`,style:{width:i.width,height:i.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:i.thumb,height:i.thumb,left:i.padding,top:"50%",transform:`translate(${u}px, -50%)`,background:r?"var(--primary-fg)":"var(--text-muted)"}})})}const $r=[".sidebar-scroll","[data-overlay-scroll='true']"].join(",");function da(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 Mr(r){return r.classList.contains("sidebar-scroll")}function Dr(r){Mr(r)&&r.querySelectorAll(".os-scrollbar-horizontal").forEach(t=>{t.style.display="none",t.style.height="0",t.style.pointerEvents="none"})}function Lr(){return o.useEffect(()=>{const r=new WeakMap;let t=0;const a=()=>{t=0,document.querySelectorAll($r).forEach(l=>{if(!da(l))return;if(rr.OverlayScrollbars(l)){Dr(l);return}const u=rr.OverlayScrollbars(l,{overflow:Mr(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}});Dr(l),r.set(l,u)})},n=()=>{t||(t=window.requestAnimationFrame(a))};a();const s=new MutationObserver(n);return s.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","data-overlay-scroll"]}),window.addEventListener("resize",n),()=>{t&&window.cancelAnimationFrame(t),s.disconnect(),window.removeEventListener("resize",n),document.querySelectorAll($r).forEach(l=>{var i;l instanceof HTMLElement&&((i=r.get(l))==null||i.destroy())})}},[]),null}const ua={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"],fa={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},pa="bonsaif.bot",ha="Bonsaif Bot",ba={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 ma(r){let t=0;for(const a of r)t=t*31+a.charCodeAt(0)&65535;return Hr[t%Hr.length]}function xa(r,t){return r===pa||t===ha}function va(r,t){return`${r.replace(/\/$/,"")}${t}`}function Tr({userId:r,username:t,name:a,size:n="md",showName:s=!1,showTooltip:l,tooltipContent:i,fallbackLabel:u="Usuario",wrapperClassName:f="",labelClassName:p="",labelSize:k="xs",avatarVersion:N=0,className:g="",style:x}){var F;const[d,h]=o.useState(!1),b=typeof r=="string"&&r.trim()&&r!=="undefined"&&r!=="null"?r.trim():"";o.useEffect(()=>{h(!1)},[b,N]);const{wh:E,text:j}=ua[n],z=Br(a)||Br(t)||u,L=z.trim()[0]||"?",y=typeof process<"u"&&((F=process.env)==null?void 0:F.NEXT_PUBLIC_BASE_PATH)||"",S=xa(t,a),H=va(y,"/favicon.svg"),P=b?`${y}/api/user/avatar/${b}${N?`?v=${N}`:""}`:"",B={xs:20,sm:28,md:36,lg:48,xl:64}[n],O=S?e.jsx("span",{className:`${E} ${ba[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 ${g}`,style:x,children:e.jsx("img",{src:H,alt:z,width:B,height:B,className:"h-full w-full object-contain"})}):P&&!d?e.jsx("img",{src:P,alt:z,width:B,height:B,className:`${E} rounded-full object-cover flex-shrink-0 ${g}`,style:x,onError:()=>h(!0)},`${b}-${N}`):e.jsx("span",{className:`${E} ${ma(z)} ${j} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${g}`,style:x,title:z,children:L});if(s)return e.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${f}`,children:[O,e.jsx("span",{className:`min-w-0 truncate ${fa[k]} font-medium text-[var(--text-main)] ${p}`,title:z,children:z})]});const _=l??!0,U=i??z;return _&&U?e.jsx(Te,{as:"span",content:U,className:`inline-flex flex-shrink-0 ${f}`,children:O}):O}function ga({href:r,className:t,children:a}){return e.jsx("a",{href:r,className:t,children:a})}function ya(r){return r.reduce((t,a)=>{const n=a.section??"Principal";return t[n]=[...t[n]??[],a],t},{})}function Ar({children:r,navItems:t=[],currentPath:a=typeof window>"u"?"/":window.location.pathname,user:n,appName:s="Bonsaif",appLogo:l,header:i,footer:u,onLogout:f,LinkComponent:p=ga}){const[k,N]=o.useState(!1),g=ya(t);return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[e.jsx(Lr,{}),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:()=>N(!0),children:e.jsx(w.HiBars3,{className:"h-5 w-5"})}),k&&e.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>N(!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 ${k?"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:l??e.jsx(w.HiHome,{className:"h-5 w-5"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:s}),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:()=>N(!1),children:e.jsx(w.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(g).map(([x,d])=>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(w.HiChevronDown,{className:"h-3.5 w-3.5"}),x]}),e.jsx("div",{className:"space-y-1",children:d.map(h=>{const b=a===h.href||a.startsWith(`${h.href}/`);return e.jsxs(p,{href:h.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${b?"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:h.icon??e.jsx(w.HiHome,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate",children:h.label})]},h.href)})})]},x))}),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(Tr,{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})]})]}),f&&e.jsxs(pe,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:f,children:[e.jsx(w.HiArrowRightOnRectangle,{className:"h-4 w-4"})," Salir"]}),u]})]}),e.jsxs("div",{className:"min-h-screen lg:pl-72",children:[i,e.jsx("main",{className:"min-h-screen",children:r})]})]})}const wa={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"},Ke={dashboard:e.jsx(w.HiChartBar,{className:"h-5 w-5"}),tickets:e.jsx(w.HiTicket,{className:"h-5 w-5"}),teams:e.jsx(w.HiUsers,{className:"h-5 w-5"}),projects:e.jsx(w.HiRectangleGroup,{className:"h-5 w-5"}),clients:e.jsx(w.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:e.jsx(w.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:e.jsx(w.HiUser,{className:"h-5 w-5"}),settings:e.jsx(w.HiCog6Tooth,{className:"h-5 w-5"}),notifications:e.jsx(w.HiBell,{className:"h-5 w-5"}),changelog:e.jsx(w.HiDocumentText,{className:"h-5 w-5"}),admin:e.jsx(w.HiShieldCheck,{className:"h-5 w-5"}),users:e.jsx(w.HiUsers,{className:"h-5 w-5"}),roles:e.jsx(w.HiShieldCheck,{className:"h-5 w-5"}),menus:e.jsx(w.HiCog6Tooth,{className:"h-5 w-5"}),guards:e.jsx(w.HiCalendarDays,{className:"h-5 w-5"}),vacations:e.jsx(w.HiCalendarDays,{className:"h-5 w-5"}),audit:e.jsx(w.HiListBullet,{className:"h-5 w-5"}),positions:e.jsx(w.HiBriefcase,{className:"h-5 w-5"}),ranks:e.jsx(w.HiListBullet,{className:"h-5 w-5"}),"email-inbox":e.jsx(w.HiInbox,{className:"h-5 w-5"}),"security-incidents":e.jsx(w.HiShieldCheck,{className:"h-5 w-5"})};function Na({href:r,className:t,style:a,children:n}){return e.jsx("a",{href:r,className:t,style:a,children:n})}function ka(r){return r.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Sa(r){return/^\d+$/.test(r)||/^[a-f0-9]{8,}$/i.test(r)}function Ca(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,s=Sa(a)&&n?n:a,l=wa[s]??ka(s);return[{label:"Inicio",href:"/"},{label:l}]}function Je(r){return(r==null?void 0:r.querySelector(":scope > .os-viewport"))??(r==null?void 0:r.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function Ea(r){const t=r.split("/").filter(Boolean),a=t[t.length-1];if(!a)return e.jsx(w.HiHome,{className:"h-5 w-5"});if(Ke[a])return Ke[a];const n=t.length>1?t[t.length-2]:"";return Ke[n]??e.jsx(w.HiHome,{className:"h-5 w-5"})}function $a({title:r,subtitle:t,action:a,meta:n,icon:s,className:l="",contentClassName:i="",breadcrumbs:u,currentPath:f=typeof window>"u"?"/":window.location.pathname,showBreadcrumbs:p=!0,contained:k=!1,LinkComponent:N=Na}){const g=o.useRef(null),[x,d]=o.useState(!1),[h,b]=o.useState(null),E=u??Ca(f),j=s??Ea(f),z=p&&E.length>1;return o.useEffect(()=>{if(k){d(!1);return}let L=null,y=0,S=0;const H=()=>{const B=g.current,O=document.querySelector("[data-app-scroll='true']");return(B==null?void 0:B.closest(".os-viewport"))??(B==null?void 0:B.closest("[data-overlayscrollbars-viewport]"))??Je(O)??O??window},P=()=>{const B=L&&L!==window?L.scrollTop:window.scrollY;d(O=>O?B>24:B>72)},T=()=>{L==null||L.removeEventListener("scroll",P),L=H(),L.addEventListener("scroll",P,{passive:!0}),P()};return T(),y=window.requestAnimationFrame(T),S=window.setTimeout(T,120),()=>{window.cancelAnimationFrame(y),window.clearTimeout(S),L==null||L.removeEventListener("scroll",P)}},[k]),o.useEffect(()=>{if(k){b(null);return}let L=0;const y=[],S=()=>{const U=g.current,F=U==null?void 0:U.parentElement,Z=document.querySelector("[data-app-scroll='true']"),ee=Je(Z)??Z;if(!U||!F||!ee){b(null);return}const c=F.getBoundingClientRect(),$=window.getComputedStyle(F),G=ee.getBoundingClientRect(),Y=ee instanceof HTMLElement&&ee.clientWidth>0?ee.clientWidth:G.width,K=c.left+parseFloat($.paddingLeft||"0"),ne={marginLeft:Math.round(G.left-K),width:Math.round(Y)};b(ue=>ue&&ue.marginLeft===ne.marginLeft&&ue.width===ne.width?ue:ne)},H=()=>{window.cancelAnimationFrame(L),L=window.requestAnimationFrame(S)};H(),window.addEventListener("resize",H);const P=new ResizeObserver(H),T=g.current,B=T==null?void 0:T.parentElement,O=document.querySelector("[data-app-scroll='true']"),_=Je(O)??O;return[B,O,_].forEach(U=>{U&&P.observe(U)}),y.push(window.setTimeout(H,120)),y.push(window.setTimeout(H,280)),()=>{window.cancelAnimationFrame(L),window.removeEventListener("resize",H),P.disconnect(),y.forEach(U=>window.clearTimeout(U))}},[k]),e.jsx("div",{ref:g,"data-page-header":"true","data-compact":x?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${k?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${l}`,style:{...h?{marginLeft:h.marginLeft,width:h.width}:null,background:k?"var(--bg-card)":x?"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:k||x?"1px solid var(--border)":"1px solid transparent",boxShadow:x?"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 ${x?"min-h-9 gap-2 sm:min-h-10 sm:gap-2.5":"min-h-10 gap-2.5 sm:min-h-11 sm:gap-3"} ${i}`,children:[e.jsxs("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${x?"gap-1":"gap-1.5 sm:gap-2"}`,children:[z&&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 ${x?"text-[10px]":"text-[10px] sm:text-[11px]"}`,children:E.map((L,y)=>{const S=y===E.length-1;return e.jsxs("li",{className:"flex min-w-0 items-center gap-1.5",children:[y>0&&e.jsx(w.HiChevronRight,{className:"h-3.5 w-3.5 transition-[color,transform] duration-300 ease-out",style:{color:"var(--text-muted)"}}),L.href&&!S?e.jsx(N,{href:L.href,className:"truncate transition-colors duration-300 hover:underline",style:{color:"var(--text-muted)"},children:L.label}):e.jsx("span",{"aria-current":S?"page":void 0,className:S?"truncate font-semibold":"truncate",style:{color:S?"var(--text-main)":"var(--text-muted)"},children:L.label})]},`${L.label}-${y}`)})})}),e.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${x?"gap-2":"gap-2.5 sm:gap-3"}`,children:[e.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${x?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:z?"var(--text-secondary)":"var(--text-muted)"},children:j}),e.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${x?"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 ${x?"text-base sm:text-lg":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:r}),t&&e.jsx("p",{"aria-hidden":x,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${x?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-5 translate-y-0 opacity-100"}`,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 ${x?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:n})]})]})]}),a&&e.jsx("div",{className:`page-header-actions ml-auto flex max-w-full flex-shrink-0 flex-wrap items-center justify-end self-center overflow-visible transition-[gap,min-height,opacity,transform] duration-300 ease-out ${x?"min-h-10 gap-1 opacity-95":"min-h-10 gap-1.5 opacity-100"}`,children:e.jsx(sr.Provider,{value:{compact:!0,headerAction:!0},children:a})})]})})}function Ma({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(Ar,{currentPath:t,...n,children:r})}function Or(){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 Da(r,t,a){try{const n=new URL(r),s=n.searchParams.get("callbackUrl");if(s){const l=new URL(s,n.origin);return l.searchParams.set("theme",t),a&&(l.searchParams.set("primeAuthOrigin",window.location.origin),l.searchParams.set("primeAuthProjectKey",a)),n.searchParams.set("callbackUrl",`${l.pathname}${l.search}${l.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 La({name:r,src:t,projectKey:a}){const[n,s]=o.useState(()=>Or()),l=o.useRef(null);o.useEffect(()=>{const f=new MutationObserver(()=>s(Or()));return f.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>f.disconnect()},[]);const i=o.useMemo(()=>Da(t,n,a),[a,t,n]),u=o.useMemo(()=>{try{return new URL(i).origin}catch{return""}},[i]);return o.useEffect(()=>{if(!a)return;const f=a;function p(k){var x,d,h;if(k.source!==((x=l.current)==null?void 0:x.contentWindow)||u&&k.origin!==u)return;if(((d=k.data)==null?void 0:d.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!k.data.active}}));return}if(((h=k.data)==null?void 0:h.type)!=="prime-microservice:navigation")return;const N=k.data.path;if(!N||!N.startsWith("/")||N.startsWith("//"))return;const g=`/apps/${encodeURIComponent(f)}${N}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==g&&(window.history.replaceState(window.history.state,"",g),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",p),()=>{window.removeEventListener("message",p),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[u,a]),e.jsx("div",{className:"flex h-full min-h-screen flex-col bg-[var(--bg-main)]",children:e.jsx("iframe",{ref:l,src:i,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 Ha(){const[r,t]=o.useState(""),[a,n]=o.useState(!1),[s,l]=o.useState({width:96,height:96});return o.useEffect(()=>{let i=!1;return fetch("/api/microservices/prime-suite/chat-url",{cache:"no-store"}).then(u=>u.ok?u.json():null).then(u=>{!i&&(u!=null&&u.src)&&t(u.src)}).catch(()=>{}),()=>{i=!0}},[]),o.useEffect(()=>{const i=u=>{var p;if(((p=u.data)==null?void 0:p.type)!=="prime-suite-chat:state")return;const f=!!u.data.active;n(f),l({width:Ir(u.data.width,96,720),height:Ir(u.data.height,96,560)})};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[]),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(${s.width}px, 100vw)`:96,height:a?`min(${s.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function Ir(r,t,a){const n=typeof r=="number"&&Number.isFinite(r)?r:t;return Math.max(t,Math.min(a,Math.ceil(n)))}function Ba(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 Ta(){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 Aa(){return"light"}function Oa(){const r=o.useSyncExternalStore(Ba,Ta,Aa);return e.jsx(qr.Toaster,{position:"bottom-center",theme:r,richColors:!0,closeButton:!0})}D.Alert=lt,D.AuthShell=Ar,D.BonsaifButton=Gr,D.Button=pe,D.CalendarPicker=ft,D.Checkbox=ht,D.CodeBlock=xt,D.CompactFilterSelect=gt,D.CompactSearchInput=vt,D.ConfirmDialog=Nt,D.CopyButton=Ve,D.CopyLinkButton=St,D.DataTable=$t,D.DateRangePicker=Lt,D.Drawer=Tt,D.DropdownMenu=Bt,D.DynamicDetailTabs=ot,D.EmptyState=Ot,D.FormField=gr,D.GlobalScrollbars=Lr,D.InputField=Gt,D.LoadingState=ir,D.MicroserviceFrame=La,D.Modal=mr,D.MouseTooltip=Te,D.MultiSelect=Yt,D.PageHeader=$a,D.PageSearchInput=or,D.Pagination=Zt,D.PrimeAuthRouteShell=Ma,D.PrimeAuthToaster=Oa,D.PrimeSuiteChatFrame=Ha,D.RadioGroup=Kt,D.SearchableSelect=Ze,D.SectionPanel=Jt,D.StatusBadge=ea,D.StepWizard=ta,D.Tabs=ra,D.TextInput=ze,D.Textarea=Er,D.TextareaField=la,D.Toggle=ca,D.UserAvatar=Tr,D.cn=nr,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})}));