bonsaif-ui 0.1.92 → 0.1.97

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,10 +1,10 @@
1
- (function(_,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react"),require("react/jsx-runtime"),require("react-icons/hi2"),require("react-dom"),require("recharts"),require("overlayscrollbars"),require("sonner"),require("overlayscrollbars-react"),require("react-day-picker"),require("react-day-picker/dist/style.css"),require("react-icons/fi")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","react-icons/hi2","react-dom","recharts","overlayscrollbars","sonner","overlayscrollbars-react","react-day-picker","react-day-picker/dist/style.css","react-icons/fi"],o):(_=typeof globalThis<"u"?globalThis:_||self,o(_.BonsaifUI={},_.React,_.jsxRuntime,_.ReactIconsHi2,_.ReactDOM,_.Recharts,_.OverlayScrollbarsGlobal,_.Sonner,_.OverlayScrollbarsReact,_.ReactDayPicker,_.ReactDayPickerStyles,_.ReactIconsFi))})(this,(function(_,o,e,A,rr,me,$a,wn,Nn,kn,du,Ms){"use strict";"use client";function pr(...r){return r.filter(Boolean).join(" ")}function Ls({variant:r="primary",className:t,type:a="button",children:n,...s}){return e.jsx("button",{className:pr("bonsaif-ui-button",`bonsaif-ui-button--${r}`,t),type:a,...s,children:n})}function Sn({value:r,onChange:t,placeholder:a,className:n="",autoFocus:s=!1,forceExpanded:l=!1,onEscape:i,size:c="default",inputTabIndex:u}){const f=o.useRef(null),[b,p]=o.useState(!1),m=l||b||r.trim().length>0,w=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",y=n||"w-48 max-w-full sm:w-64 lg:w-72";o.useEffect(()=>{var v;s&&((v=f.current)==null||v.focus())},[s]);const k=()=>{var v;p(!0),(v=f.current)==null||v.focus()};return e.jsxs("div",{className:`relative min-w-0 max-w-full flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${m?y:"w-24 sm:w-28"}`,onMouseDown:v=>{m||(v.preventDefault(),k())},children:[e.jsx(A.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)",left:"var(--page-header-control-icon-left, 12px)"}}),e.jsx("input",{ref:f,type:"text",tabIndex:u,"aria-label":a,value:r,onChange:v=>t(v.target.value),onKeyDown:v=>{v.key==="Escape"&&(i==null||i())},placeholder:m?a:"Buscar",className:`${w} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${m?"pl-9 pr-8":"cursor-pointer pl-9 pr-3"}`,style:{height:`var(--page-header-control-height, ${c==="sm"?"36px":"40px"})`,paddingLeft:"calc(var(--page-header-control-icon-left, 12px) + 24px)",paddingRight:m?"calc(var(--page-header-control-padding-x, 14px) + 18px)":"var(--page-header-control-padding-x, 14px)",background:"color-mix(in srgb, var(--bg-card) 86%, transparent)",border:"1px solid var(--border)",color:"var(--text-main)"},onFocus:v=>{p(!0),v.currentTarget.style.borderColor="var(--primary)",v.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:v=>{p(!1),v.currentTarget.style.borderColor="var(--border)",v.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)",right:"var(--page-header-control-padding-x, 8px)"},"aria-label":"Limpiar búsqueda",children:e.jsx(A.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const Cn=o.createContext({});let En=0;const Mn="bonsaif-ui:hide-tooltips";function It(r=700){En=Date.now()+r}function $s(){return Date.now()>En}function Bt(r){if(typeof document>"u")return!1;const t=Array.from(document.querySelectorAll('[data-bonsaif-overlay="true"], [role="menu"], [role="dialog"][aria-modal="true"], [aria-hidden="false"] [aria-modal="true"]'));return r&&t.some(a=>a.contains(r))?!1:t.length>0}function Ts(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 _r({children:r,content:t,onlyWhenOverflow:a=!1,interactive:n=!1,followCursor:s=!0,placement:l="bottom",showArrow:i=!1,className:c="",tooltipClassName:u="",style:f,tooltipStyle:b,as:p="div"}){const m=o.useRef(null),w=o.useRef(null),y=o.useRef(null),k=o.useRef(!1),[v,C]=o.useState(null),[B,T]=o.useState("");o.useEffect(()=>{const M=m.current;M&&(M.querySelectorAll("[title]").forEach(U=>{const j=U.getAttribute("title");j&&(U.getAttribute("aria-label")||U.setAttribute("aria-label",j),U.removeAttribute("title"))}),M.querySelectorAll("svg title").forEach(U=>U.remove()))}),o.useLayoutEffect(()=>{if(!v)return;const M=w.current;if(!M)return;const U=12,j=14,N=M.getBoundingClientRect(),K=window.innerWidth-N.width-U,I=window.innerHeight-N.height-U;let E=v.mouseX+j,R=v.mouseY+j,ne,$;if(!s&&m.current){const O=m.current.getBoundingClientRect(),re=O.left+O.width/2,ee=O.top+O.height/2;l==="top"?(E=re-N.width/2,R=O.top-N.height-j,$=N.height-1):l==="left"?(E=O.left-N.width-j,R=ee-N.height/2,ne=N.width-1):l==="right"?(E=O.right+j,R=ee-N.height/2,ne=-7):(E=re-N.width/2,R=O.bottom+j,$=-7)}if(s&&(E>K&&(E=v.mouseX-N.width-j),R>I&&(R=v.mouseY-N.height-j)),E=Math.min(Math.max(U,E),Math.max(U,K)),R=Math.min(Math.max(U,R),Math.max(U,I)),!s&&m.current){const O=m.current.getBoundingClientRect(),re=O.left+O.width/2,ee=O.top+O.height/2;l==="top"||l==="bottom"?ne=Math.min(Math.max(14,re-E),N.width-14):$=Math.min(Math.max(14,ee-R),N.height-14)}(Math.abs(E-v.x)>.5||Math.abs(R-v.y)>.5||ne!==v.arrowX||$!==v.arrowY)&&C(O=>O&&{...O,x:E,y:R,arrowX:ne,arrowY:$})},[s,l,v]);const W=()=>{y.current&&(window.clearTimeout(y.current),y.current=null)},L=(M,U)=>{if(!$s()||k.current)return;const j=m.current;if(j&&!Bt(j)){if(a){const N=Ts(j);if(!N)return;T(N)}!a&&!t||C({mouseX:M,mouseY:U,x:M+14,y:U+14})}},S=()=>{const M=m.current;if(!M)return;const U=M.getBoundingClientRect();L(U.left+U.width/2,U.bottom)},q=()=>{W(),C(null)},H=()=>{if(!n){q();return}W(),y.current=window.setTimeout(()=>C(null),120)},z=()=>{It(),k.current=!0,q()},X=()=>{k.current=!1};o.useEffect(()=>{if(!v)return;if(Bt(m.current)){C(null);return}const M=()=>C(null),U=()=>{It(),k.current=!0,C(null)};document.addEventListener("pointerdown",U,!0),document.addEventListener("click",U,!0),document.addEventListener("scroll",M,!0),window.addEventListener("blur",M),document.addEventListener("visibilitychange",M),document.addEventListener("keydown",M,!0);const j=new MutationObserver(()=>{Bt(m.current)&&C(null)});return j.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",U,!0),document.removeEventListener("click",U,!0),document.removeEventListener("scroll",M,!0),window.removeEventListener("blur",M),document.removeEventListener("visibilitychange",M),document.removeEventListener("keydown",M,!0),j.disconnect()}},[v]),o.useEffect(()=>{const M=()=>It(),U=()=>{It(),k.current=!0,C(null)};return document.addEventListener("pointerdown",M,!0),document.addEventListener("click",M,!0),document.addEventListener("keydown",M,!0),window.addEventListener(Mn,U),()=>{document.removeEventListener("pointerdown",M,!0),document.removeEventListener("click",M,!0),document.removeEventListener("keydown",M,!0),window.removeEventListener(Mn,U)}},[]);const Z=a?B:t;return e.jsxs(e.Fragment,{children:[e.jsx(p,{ref:M=>{m.current=M},className:c,style:f,onMouseEnter:M=>{W(),X(),s?L(M.clientX,M.clientY):S()},onMouseMove:M=>{v&&s&&L(M.clientX,M.clientY)},onMouseDown:z,onClick:z,onMouseLeave:()=>{X(),H()},onFocus:S,onBlur:q,children:r}),v&&Z&&!Bt(m.current)?rr.createPortal(e.jsxs("div",{ref:w,role:"tooltip",className:u,onMouseEnter:n?W:void 0,onMouseLeave:n?H:void 0,style:{position:"fixed",top:v.y,left:v.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:n?"auto":"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere",...b},children:[i&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",width:12,height:12,background:(b==null?void 0:b.background)??"var(--bg-card)",borderLeft:l==="right"?(b==null?void 0:b.border)??"1px solid var(--border)":void 0,borderTop:l==="bottom"||l==="right"?(b==null?void 0:b.border)??"1px solid var(--border)":void 0,borderRight:l==="left"?(b==null?void 0:b.border)??"1px solid var(--border)":void 0,borderBottom:l==="top"||l==="left"?(b==null?void 0:b.border)??"1px solid var(--border)":void 0,transform:"rotate(45deg)",left:v.arrowX===void 0?void 0:v.arrowX-6,top:v.arrowY===void 0?void 0:v.arrowY-6,zIndex:-1}}),Z]}),document.body):null]})}function Ln(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}const As="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",Ds={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"},Is="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",Bs={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"},Os={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},Hs={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function Ta(r){return typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(Ta).join(" ").trim():o.isValidElement(r)?Ta(r.props.children):""}function Ps(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:c,children:u,className:f="",disabled:b,style:p,...m}){const w=o.useContext(Cn),y=l??w.iconOnly??r==="icon",k=w.compact??!1,v=w.headerAction??!1,C=v&&t==="md"?"sm":k&&!v&&t==="md"?"xs":t,B=r==="icon"||y,T=v&&B,W=Ta(u),L=s??m.title??m["aria-label"]??(y?W:void 0),S=L?void 0:m.title,q=m["aria-label"]??(typeof L=="string"?L:W||void 0),H=a?null:n??(y?Ps(u):null),z=e.jsxs("button",{...m,title:S,"aria-label":q,"data-variant":r,"data-size":C,"data-icon":B?"true":void 0,disabled:b||a,className:`${As} ${T?Is:Ds[r]} ${B?Os[C]:Bs[C]} ${k&&!B?"px-2.5":""} ${f}`,style:{...Hs[r],height:Ln(i),padding:Ln(c),...p,...v&&!B?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...T?{width:"var(--page-header-control-height, 40px)",height:"var(--page-header-control-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"}):H,!y&&u]});return L?e.jsx(_r,{as:"span",content:L,className:"inline-flex shrink-0",children:z}):z}const Ge={background:"color-mix(in srgb, var(--text-muted) 26%, var(--bg-input))"};function Ot({rows:r=8,columns:t=7,showToolbar:a=!0,showPagination:n=!0,compact:s=!1,className:l=""}){const i=Math.max(3,Math.min(t,12)),c=Math.max(3,Math.min(r,20)),u=s?"px-2 py-2":"px-3 py-2.5",f=s?"px-2 py-2":"px-3 py-3";return e.jsxs("div",{className:`w-full min-w-0 overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${l}`,"aria-busy":"true","aria-label":"Cargando tabla",children:[a&&e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-3 py-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx("div",{className:"h-7 w-14 shrink-0 animate-pulse rounded-md",style:Ge}),e.jsx("div",{className:"h-7 max-w-md flex-1 animate-pulse rounded-md",style:Ge})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:Ge}),e.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:Ge})]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("div",{className:"min-w-full",style:{display:"grid",gridTemplateColumns:`repeat(${i}, minmax(96px, 1fr))`},children:[Array.from({length:i}).map((b,p)=>e.jsx("div",{className:`${f} border-b border-[var(--border)]`,style:{background:"color-mix(in srgb, var(--bg-input) 55%, transparent)"},children:e.jsx("div",{className:"h-3 animate-pulse rounded-md",style:{...Ge,width:`${48+p*17%40}%`}})},`h-${p}`)),Array.from({length:c}).map((b,p)=>Array.from({length:i}).map((m,w)=>e.jsx("div",{className:`${u} ${p<c-1?"border-b border-[var(--border)]":""}`,children:e.jsx("div",{className:"h-3.5 animate-pulse rounded-md",style:{...Ge,width:`${46+(p*13+w*11)%42}%`,minWidth:28}})},`c-${p}-${w}`)))]})}),n&&e.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-[var(--border)] px-3 py-2",style:{background:"color-mix(in srgb, var(--bg-input) 40%, transparent)"},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-28 animate-pulse rounded-md",style:Ge}),e.jsx("div",{className:"h-7 w-14 animate-pulse rounded-md",style:Ge})]}),e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:4}).map((b,p)=>e.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:Ge},p))}),e.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:Ge})]})]})}function $n({variant:r="page",title:t="Cargando...",rows:a=6,columns:n=7,children:s}){return r==="table"?e.jsx(Ot,{rows:a,columns:n}):r==="sections"?e.jsx(Fs,{rows:a}):r==="cards"?e.jsx(zs,{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}),s&&e.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:s})]})]})})}function Fs({rows:r}){return e.jsx(Ot,{rows:r,columns:7})}function zs({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-md",style:Ge}),e.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded-md",style:Ge}),e.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded-md",style:Ge})]},a))})}function Tn(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 An(r){return r.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function _s(r){return[r.label,Tn(r.service),r.description,r.service].filter(Boolean).join(" ")}function js(r){return typeof r=="function"?r:r.default}function Ws(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 qs({parentPanel:r,parentPanelComponent:t,renderParentPanel:a,parent:n,context:s,links:l,moduleRegistry:i,loadModule:c,activeService:u,initialService:f,onActiveServiceChange:b,canAccess:p,keepAlive:m=!0,title:w,subtitle:y,emptyState:k,loadingState:v,errorState:C=Ws,renderTabLabel:B,searchableTabs:T="auto",tabsSearchThreshold:W=6,tabsSearchPlaceholder:L="Buscar modulo...",tabsSearchValue:S,onTabsSearchChange:q,emptySearchState:H,showTabCount:z=!0,className:X="",parentClassName:Z="",contentClassName:M="",tabsClassName:U=""}){var Q;const j=o.useMemo(()=>l.filter(Y=>!Y.hidden&&((p==null?void 0:p(Y,s))??!0)),[p,s,l]),N=(Q=j.find(Y=>!Y.disabled))==null?void 0:Q.service,[K,I]=o.useState(f??N??""),[E,R]=o.useState({}),[ne,$]=o.useState({}),[O,re]=o.useState(""),[ee,oe]=o.useState(!1),ie=o.useRef(ne),ve=o.useRef(0),te=S??O,J=An(te),h=T===!0||T==="auto"&&j.length>=W,D=h&&te.trim().length>0,V=o.useMemo(()=>J?j.filter(Y=>An(_s(Y)).includes(J)):j,[J,j]),ae=u??K,se=j.find(Y=>Y.service===ae)??j.find(Y=>!Y.disabled);o.useEffect(()=>{!se&&N&&I(N)},[N,se]),o.useEffect(()=>{ie.current=ne},[ne]);const he=Y=>{Y.disabled||(u||I(Y.service),b==null||b(Y.service,Y))},Be=Y=>{S===void 0&&re(Y),q==null||q(Y)},Ve=(Y,de)=>{const Se=V.filter(ye=>!ye.disabled),ke=Se.findIndex(ye=>ye.service===de.service);ke<0||((Y.key==="ArrowRight"||Y.key==="ArrowDown")&&(Y.preventDefault(),he(Se[(ke+1)%Se.length])),(Y.key==="ArrowLeft"||Y.key==="ArrowUp")&&(Y.preventDefault(),he(Se[(ke-1+Se.length)%Se.length])),Y.key==="Home"&&(Y.preventDefault(),he(Se[0])),Y.key==="End"&&(Y.preventDefault(),he(Se[Se.length-1])))},xe=o.useCallback(()=>{if(!se)return;const Y=se.service,de=ie.current[Y];if(de!=null&&de.loading||de!=null&&de.component&&m)return;const Se=(i==null?void 0:i[Y])??c;if(!Se){$(ye=>({...ye,[Y]:{loading:!1,error:new Error(`No module loader found for service "${Y}".`)}}));return}const ke=++ve.current;$(ye=>({...ye,[Y]:{...ye[Y],loading:!0,error:void 0}})),Se(se,s).then(ye=>{if(ke!==ve.current&&!m)return;const Le=js(ye);$(Oe=>({...Oe,[Y]:{component:Le,loading:!1}}))}).catch(ye=>{const Le=ye instanceof Error?ye:new Error(String(ye));$(Oe=>({...Oe,[Y]:{...Oe[Y],loading:!1,error:Le}}))})},[s,m,c,i,se]);o.useEffect(xe,[xe]);const Ae=se?E[se.service]??null:null,$e=se?ne[se.service]:void 0,Ee=$e==null?void 0:$e.component,cr=Y=>{se&&R(de=>({...de,[se.service]:Y}))},dr=()=>{se&&R(Y=>({...Y,[se.service]:null}))},pe={context:s,parent:n,links:l,visibleLinks:j,filteredLinks:V,selectedLink:se,selectedService:se==null?void 0:se.service,activeItemId:Ae,tabsSearch:te,onSelectService:he,onOpenDetail:cr,onBackToList:dr},P=a?a(pe):t?e.jsx(t,{...pe}):r;return e.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${X}`,children:[e.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${Z}`,children:P}),e.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${M}`,children:[(w||y||h||z)&&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:[w&&e.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:w}),y&&e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:y})]}),(h||z)&&e.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[z&&e.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[V.length," / ",j.length]}),h&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${ee?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!ee,children:e.jsx(Sn,{value:te,onChange:Be,placeholder:L,className:"w-full",autoFocus:ee,forceExpanded:!0,onEscape:()=>oe(!1),size:"sm",inputTabIndex:ee?0:-1})}),e.jsx("button",{type:"button","aria-label":ee?"Cerrar busqueda":"Buscar tabs","aria-expanded":ee,onClick:()=>{ee&&te&&Be(""),oe(Y=>!Y)},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 ${ee||D?"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:ee||D?e.jsx(A.HiXMark,{className:"h-4 w-4"}):e.jsx(A.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),e.jsx("div",{role:"tablist","aria-label":w??"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:V.length>0?V.map(Y=>{const de=Y.service===(se==null?void 0:se.service);return e.jsx("button",{type:"button",role:"tab","aria-selected":de,disabled:Y.disabled,onClick:()=>he(Y),onKeyDown:Se=>Ve(Se,Y),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 ${de?"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:B?B(Y,de):e.jsxs(e.Fragment,{children:[Y.icon,e.jsx("span",{children:Y.label??Tn(Y.service)}),Y.badge&&e.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:Y.badge})]})},Y.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:H??"No hay modulos que coincidan con la busqueda."})}),(se==null?void 0:se.description)&&e.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:se.description}),e.jsxs("div",{className:"min-h-[420px] p-4",children:[!se&&(k??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."})),se&&($e==null?void 0:$e.loading)&&(v??e.jsx($n,{title:"Cargando modulo..."})),se&&($e==null?void 0:$e.error)&&C($e.error,xe),se&&Ee&&!($e!=null&&$e.loading)&&!($e!=null&&$e.error)&&e.jsx(Ee,{context:s,parent:n,link:se,activeItemId:Ae,onOpenDetail:cr,onBackToList:dr})]})]})]})}const Us={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:e.jsx(A.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(A.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(A.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(A.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:e.jsx(A.HiInformationCircle,{className:"h-5 w-5"})}};function Vs({variant:r="info",title:t,children:a,icon:n,action:s,onDismiss:l,className:i=""}){const c=Us[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}),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(A.HiXMark,{className:"h-4 w-4"})})]})}const Dn=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],Gs=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],Ks=["Do","Lu","Ma","Mi","Ju","Vi","Sá"],Aa=6;function Da(r,t,a){return`${r}-${String(t).padStart(2,"0")}-${String(a).padStart(2,"0")}`}function Xs(){const r=new Date;return Da(r.getFullYear(),r.getMonth()+1,r.getDate())}function In(r){const[t,a,n]=r.split("-").map(Number);return{year:t,month:a,day:n}}function Ys(r){if(!r)return"Seleccionar fecha";const{year:t,month:a,day:n}=In(r);return!t||!a||!n?"Seleccionar fecha":`${String(n).padStart(2,"0")} ${Dn[a-1]} ${t}`}function Zs({value:r,onChange:t,minDate:a,displayMode:n="inline"}){const s=Xs(),i=In(r||s),c=n==="popover",[u,f]=o.useState(!1),b=o.useRef(null),[p,m]=o.useState({horizontal:"left",vertical:"bottom"}),[w,y]=o.useState(i.year),[k,v]=o.useState(i.month),[C,B]=o.useState("days"),T=16,[W,L]=o.useState(0),S=w-7+W,q=Array.from({length:T},(I,E)=>S+E);o.useEffect(()=>{if(!c||!u||!b.current)return;const I=b.current.getBoundingClientRect(),E=8,R=280,ne=340,$=I.left+R>window.innerWidth-E,O=I.right-R>=E,re=I.bottom+8+ne>window.innerHeight-E,ee=I.top-8-ne>=E;m({horizontal:$&&O?"right":"left",vertical:re&&ee?"top":"bottom"})},[c,u]),o.useEffect(()=>{if(!c||!u)return;function I(R){b.current&&(b.current.contains(R.target)||f(!1))}function E(R){R.key==="Escape"&&f(!1)}return document.addEventListener("mousedown",I),document.addEventListener("keydown",E),()=>{document.removeEventListener("mousedown",I),document.removeEventListener("keydown",E)}},[c,u]);function H(){k===1?(y(I=>I-1),v(12)):v(I=>I-1)}function z(){k===12?(y(I=>I+1),v(1)):v(I=>I+1)}const X=new Date(w,k-1,1).getDay(),Z=new Date(w,k,0).getDate(),M=[...Array(X).fill(null),...Array.from({length:Z},(I,E)=>E+1)];for(;M.length<Aa*7;)M.push(null);const U=M.slice(0,Aa*7);function j(I){const E=Da(w,k,I);a&&E<a||(t(E),c&&f(!1))}const N={background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,borderRadius:6,display:"flex",alignItems:"center"},K=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:C==="days"?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:H,style:N,title:"Mes anterior",children:e.jsx(A.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>{B("years"),L(0)},style:{background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:4,fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[Dn[k-1]," ",w,e.jsx(A.HiChevronDown,{size:13,style:{color:"var(--text-muted)"}})]}),e.jsx("button",{type:"button",onClick:z,style:N,title:"Mes siguiente",children:e.jsx(A.HiChevronRight,{size:16})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>L(I=>I-T),style:N,children:e.jsx(A.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>B("days"),style:{background:"none",border:"none",cursor:"pointer",fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[q[0]," – ",q[q.length-1]]}),e.jsx("button",{type:"button",onClick:()=>L(I=>I+T),style:N,children:e.jsx(A.HiChevronRight,{size:16})})]})}),C==="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:Gs.map((I,E)=>{const R=E+1===k;return e.jsx("button",{type:"button",onClick:()=>v(E+1),style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:11,fontWeight:R?700:400,padding:"4px 0",background:R?"var(--primary)":"transparent",color:R?"var(--primary-fg, #ffffff)":"var(--text-secondary)"},children:I},I)})}),e.jsx("div",{style:{height:1,background:"var(--border)",marginBottom:8}}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3},children:q.map(I=>{const E=I===w;return e.jsx("button",{type:"button",onClick:()=>{y(I),B("days")},style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:12,fontWeight:E?700:400,padding:"6px 0",background:E?"var(--primary)":"transparent",color:E?"var(--primary-fg, #ffffff)":"var(--text-main)",outline:I===new Date().getFullYear()&&!E?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:I},I)})})]}),C==="days"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",padding:"6px 8px 0"},children:Ks.map(I=>e.jsx("div",{style:{textAlign:"center",fontSize:10,fontWeight:700,color:"var(--text-muted)",padding:"2px 0",textTransform:"uppercase"},children:I},I))}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",gridTemplateRows:`repeat(${Aa},1fr)`,padding:"4px 8px 10px",gap:2},children:U.map((I,E)=>{if(I===null)return e.jsx("div",{style:{aspectRatio:"1"}},E);const R=Da(w,k,I),ne=R===r,$=R===s,O=!!(a&&R<a);return e.jsx("button",{type:"button",onClick:()=>!O&&j(I),style:{width:"100%",aspectRatio:"1",borderRadius:6,border:"none",cursor:O?"not-allowed":"pointer",fontSize:12,fontWeight:ne||$?700:400,background:ne?"var(--primary)":"transparent",color:ne?"var(--primary-fg, #ffffff)":O?"var(--text-muted)":"var(--text-main)",opacity:O?.4:1,outline:$&&!ne?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:I},E)})})]})]});return c?e.jsxs("div",{ref:b,className:"relative w-full",children:[e.jsxs("button",{type:"button",onClick:()=>f(I=>!I),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 ${u?"var(--primary)":"var(--border)"}`,color:"var(--text-main)",boxShadow:u?"0 0 0 3px rgba(59,130,246,0.12)":"none"},children:[e.jsxs("span",{className:"inline-flex items-center gap-2 min-w-0",children:[e.jsx(A.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),e.jsx("span",{className:"truncate",children:Ys(r)})]}),e.jsx(A.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${u?"rotate-180":""}`})]}),u&&e.jsx("div",{className:"absolute z-50",style:{...p.horizontal==="left"?{left:0}:{right:0},...p.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:K})]}):K}const Qs={sm:"h-4 w-4",md:"h-5 w-5"};function Js(r,t){if(typeof r=="function"){r(t);return}r&&(r.current=t)}const Ht=o.forwardRef(function({label:t,description:a,error:n,size:s="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:u,...f},b){const p=o.useRef(null);return o.useEffect(()=>{p.current&&(p.current.indeterminate=l)},[l]),e.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${u?"cursor-not-allowed opacity-60":"cursor-pointer"} ${c}`,children:[e.jsxs("span",{className:"relative mt-0.5 inline-flex shrink-0",children:[e.jsx("input",{...f,ref:m=>{p.current=m,Js(b,m)},type:"checkbox",disabled:u,"aria-checked":l?"mixed":f["aria-checked"],"aria-invalid":!!n||f["aria-invalid"],className:`peer ${Qs[s]} 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 ${i}`}),e.jsx(A.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 peer-aria-checked:mixed:scale-100 peer-aria-checked:mixed:opacity-100"})]}),(t||a||n)&&e.jsxs("span",{className:"min-w-0",children:[t&&e.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:t}),a&&!n&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:a}),n&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--danger)]",children:n})]})]})});function Bn(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 Rs(r){var t;if((t=navigator.clipboard)!=null&&t.writeText){await navigator.clipboard.writeText(r);return}Bn(r)}function el(r){return typeof r=="function"?r():r}function Ia({value:r,resetDelay:t=2e3,title:a,copiedTitle:n="Copiado",copiedLabel:s,icon:l=e.jsx(A.HiClipboardDocument,{size:14}),copiedIcon:i=e.jsx(A.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:u,onCopyError:f,className:b="",style:p,children:m,onClick:w,type:y="button",...k}){const[v,C]=o.useState(!1),B=o.useRef(null);o.useEffect(()=>()=>{B.current&&window.clearTimeout(B.current)},[]);function T(L){C(!0),u==null||u(L),B.current&&window.clearTimeout(B.current),B.current=window.setTimeout(()=>{C(!1),B.current=null},t)}async function W(L){var q;if(c&&L.stopPropagation(),w==null||w(L),L.defaultPrevented)return;const S=el(r);if(S)try{await Rs(S),T(S)}catch(H){try{Bn(S),T(S)}catch(z){f==null||f(z,S);return}(q=navigator.clipboard)!=null&&q.writeText||f==null||f(H,S)}}return e.jsxs("button",{...k,type:y,onClick:W,title:v?n:a,"aria-label":k["aria-label"]??(v?n:a),"data-copied":v?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${m?"min-w-7 px-2":"w-7"} ${b}`,style:{cursor:"pointer",background:v?"rgba(22,163,74,0.15)":"var(--bg-card)",border:v?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:v?"#16a34a":"var(--text-secondary)",boxShadow:v?"0 0 0 3px rgba(22,163,74,0.12)":"none",...p},children:[e.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:v?"scale(1.15)":"scale(1)"},children:v?i:l}),m&&e.jsx("span",{className:"text-xs font-semibold leading-none",children:v?s??m:m})]})}function rl({code:r,children:t,title:a="Codigo",language:n,copyLabel:s="Copiar",copiedLabel:l="Copiado",className:i="",style:c,onCopied:u}){const f=(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(Ia,{value:f,title:"Copiar codigo",copiedTitle:"Codigo copiado",copiedLabel:l,onCopied:u,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:f})})]})}function Ba(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Oa(r){return r.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function tl(r,t){if(!t.trim())return!0;const a=Oa(t);return Oa(r.label).includes(a)||!!(r.sublabel&&Oa(r.sublabel).includes(a))}function Sr({value:r,onChange:t,options:a,status:n="default",ariaLabel:s,triggerVariant:l="default",showSelectedSublabel:i=!0,placeholder:c="Seleccionar…",emptyLabel:u,disabled:f=!1,className:b="",style:p,dropdownMinWidth:m,height:w=40,padding:y="0 10px",searchable:k=!0,minOptionsForSearch:v=6}){const[C,B]=o.useState(!1),[T,W]=o.useState(""),[L,S]=o.useState(-1),[q,H]=o.useState(!1),[z,X]=o.useState({}),Z=o.useRef(null),M=o.useRef(null),U=o.useRef(null),j=o.useRef(null),N=k&&a.length>=v,K=a.find(te=>te.value===r)??null,I=l==="ghost",E=n==="error"?"var(--danger)":C?"var(--primary)":"var(--border)",R=N&&T.trim()?a.filter(te=>tl(te,T)):a,ne=o.useCallback(()=>{const te=Z.current;if(!te)return;const J=te.getBoundingClientRect(),h=N?272:212,D=window.innerHeight-J.bottom,V=D<h&&J.top>D;X({position:"fixed",left:J.left,top:V?void 0:J.bottom+4,bottom:V?window.innerHeight-J.top+4:void 0,width:J.width,minWidth:Ba(m),zIndex:9999})},[m,N]);o.useEffect(()=>H(!0),[]),o.useEffect(()=>{if(!C)return;function te(J){var D,V;const h=J.target;!((D=Z.current)!=null&&D.contains(h))&&!((V=M.current)!=null&&V.contains(h))&&(B(!1),W(""))}return document.addEventListener("mousedown",te),()=>document.removeEventListener("mousedown",te)},[C]),o.useEffect(()=>{C&&(S(-1),ne(),N&&setTimeout(()=>{var te;return(te=U.current)==null?void 0:te.focus()},0))},[C,N,ne]),o.useEffect(()=>{if(C)return window.addEventListener("resize",ne),window.addEventListener("scroll",ne,!0),()=>{window.removeEventListener("resize",ne),window.removeEventListener("scroll",ne,!0)}},[C,ne]),o.useEffect(()=>{if(L<0||!j.current)return;const te=j.current.children[L];te==null||te.scrollIntoView({block:"nearest"})},[L]);const $=o.useCallback(te=>{t(te),B(!1),W("")},[t]),O=o.useRef(C);O.current=C;const re=o.useRef(R);re.current=R;const ee=o.useRef(L);ee.current=L;const oe=o.useRef(u);oe.current=u;const ie=o.useRef($);ie.current=$,o.useEffect(()=>{function te(J){var ae,se;const h=document.activeElement,D=((ae=Z.current)==null?void 0:ae.contains(h))??!1,V=((se=M.current)==null?void 0:se.contains(h))??!1;if(!(!D&&!V)){if(!O.current){(J.key==="Enter"||J.key===" "||J.key==="ArrowDown")&&(J.preventDefault(),B(!0));return}switch(J.key){case"ArrowDown":J.preventDefault(),S(he=>Math.min(he+1,re.current.length-1));break;case"ArrowUp":J.preventDefault(),S(he=>Math.max(he-1,oe.current?-1:0));break;case"Enter":{J.preventDefault();const he=ee.current,Be=re.current;he===-1&&oe.current?ie.current(""):Be[he]&&!Be[he].disabled&&ie.current(Be[he].value);break}case"Escape":J.preventDefault(),J.stopPropagation(),B(!1),W("");break}}}return document.addEventListener("keydown",te),()=>document.removeEventListener("keydown",te)},[]);const ve=e.jsxs("div",{ref:M,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...z,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[N&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(A.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:U,value:T,onChange:te=>{W(te.target.value),S(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),T&&e.jsx("button",{type:"button",onMouseDown:te=>{te.preventDefault(),W("")},children:e.jsx(A.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),e.jsxs("ul",{ref:j,role:"listbox",className:"overflow-y-auto",style:{maxHeight:N?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[u&&e.jsx("li",{role:"option","aria-selected":r==="",onMouseDown:te=>{te.preventDefault(),$("")},onMouseEnter:()=>S(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:L===-1&&!T.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:u}),R.map((te,J)=>{const D=J===L,V=te.value===r;return e.jsxs("li",{role:"option","aria-selected":V,onMouseDown:ae=>{ae.preventDefault(),te.disabled||$(te.value)},onMouseEnter:()=>!te.disabled&&S(J),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:D?"var(--bg-hover)":V?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:te.disabled?"var(--text-muted)":"var(--text-main)",cursor:te.disabled?"not-allowed":"pointer",boxShadow:V?"inset 2px 0 0 var(--primary)":void 0},children:[te.color&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:te.color}}),e.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:te.label}),te.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:te.sublabel})]}),te.badge&&e.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:te.badge})]},te.value)}),R.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:Z,className:`relative ${b||"w-full"}`,style:p,children:[e.jsxs("button",{type:"button",disabled:f,onClick:()=>!f&&B(te=>!te),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:Ba(w),padding:Ba(y),background:I?"transparent":"var(--bg-input)",color:K?"var(--text-main)":"var(--text-muted)",border:I?"1px solid transparent":`1px solid ${E}`,opacity:f?.5:1,cursor:f?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":C,"aria-label":s,children:[(K==null?void 0:K.color)&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:K.color}}),e.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:K?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"truncate",children:K.label}),i&&K.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:K.sublabel})]}):e.jsx("span",{className:"truncate",children:c})}),K&&u?e.jsx("span",{role:"button",tabIndex:-1,onMouseDown:te=>{te.preventDefault(),te.stopPropagation(),$("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(A.HiXMark,{className:"w-3 h-3"})}):e.jsx(A.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:C?"rotate(180deg)":"rotate(0deg)"}})]}),C&&q&&rr.createPortal(ve,document.body)]})}function Pt(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function al({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(A.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:Pt(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:Pt(s),padding:Pt(l)}})]})}function nl({value:r,onChange:t,options:a,placeholder:n,icon:s,className:l="",height:i=40,padding:c,iconLeft:u=10,searchable:f=!0}){const b=s?a.map((p,m)=>m===0&&!p.color?{...p,sublabel:p.sublabel??void 0}:p):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:Pt(u)},children:s}),e.jsx(Sr,{value:r,onChange:t,options:b,placeholder:n,searchable:f,minOptionsForSearch:5,height:i,padding:c??(s?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const ol={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},Ft=180,sl="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Ha({open:r,onClose:t,title:a,subtitle:n,leadingIcon:s,headerActions:l,footer:i,children:c,size:u="md",maxWidth:f,zIndex:b=1e3,closeOnBackdrop:p=!0,closeOnEscape:m=!0,showCloseButton:w=!0,placement:y="center",bodyClassName:k="px-6 py-5",panelClassName:v="",backdropClassName:C=sl,contentClassName:B="p-4",ariaLabel:T,frameless:W=!1,disabled:L=!1}){const[S,q]=o.useState(!1),[H,z]=o.useState(!1),X=o.useRef(null);if(o.useEffect(()=>(r?(X.current&&clearTimeout(X.current),q(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>z(!0)))):(z(!1),X.current=setTimeout(()=>q(!1),Ft+40)),()=>{X.current&&clearTimeout(X.current)}),[r]),o.useEffect(()=>{if(r)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[r]),o.useEffect(()=>{if(!r||!m)return;const K=I=>{I.key==="Escape"&&t()};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[m,t,r]),!S)return null;const Z=a||n||s||l||w,M=f??ol[u],U=y==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",j=y==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",N=H?"translateY(0) scale(1)":y==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return rr.createPortal(e.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":T??a,className:`fixed inset-0 flex ${U} ${B}`,style:{zIndex:b},children:[e.jsx("div",{className:`absolute inset-0 ${C}`,onClick:p?t:void 0,style:{opacity:H?1:0,transition:`opacity ${Ft}ms ease`}}),e.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${W?"shadow-none":"shadow-2xl"} ${j} ${v}`,style:{maxWidth:M,background:W?"transparent":"var(--bg-card)",border:W?"none":"1px solid var(--border)",opacity:H?1:0,transform:N,transition:`opacity ${Ft}ms ease, transform ${Ft}ms ease`},onClick:K=>K.stopPropagation(),children:[L&&e.jsx("div",{className:"absolute inset-0 z-[1002] cursor-not-allowed rounded-2xl",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 60%, transparent)",backdropFilter:"blur(2px)"}}),Z&&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,w&&e.jsx(Pe,{variant:"icon",onClick:t,title:"Cerrar",children:e.jsx(A.HiXMark,{className:"h-5 w-5"})})]})]}),e.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${k}`,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 ll={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 il({open:r,title:t,description:a,confirmLabel:n="Confirmar",cancelLabel:s="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:u}){const f=ll[l];return e.jsx(Ha,{open:r,onClose:u,size:"md",zIndex:9998,showCloseButton:!1,bodyClassName:"p-0",panelClassName:"overflow-visible",ariaLabel:t,closeOnBackdrop:i,children:e.jsxs("div",{className:"relative px-6 pb-6 pt-6",children:[e.jsx(Pe,{variant:"icon",onClick:u,className:"absolute right-3 top-3 h-8 w-8 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:e.jsx(A.HiXMark,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex gap-3 pr-8",children:[e.jsx("div",{className:"mt-0.5 flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl",style:{background:f.iconBg},children:e.jsx(A.HiExclamationTriangle,{className:"h-5 w-5",style:{color:f.iconColor}})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-base font-semibold leading-snug",style:{color:"var(--text-main)"},children:t}),a?e.jsx("div",{className:"mt-1.5 text-sm leading-relaxed",style:{color:"var(--text-muted)"},children:a}):null]})]}),e.jsxs("div",{className:"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e.jsx(Pe,{variant:"secondary",onClick:u,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:s}),e.jsx(Pe,{variant:"danger",onClick:c,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:f.btnBg,color:f.btnColor,borderColor:"transparent"},children:n})]})]})})}function cl(r){return r?typeof r=="function"?r():r:""}function dl(r){return/^https?:\/\//i.test(r)}function On(r,t){try{return new URL(r,t).toString()}catch{return r}}function ul(r,t,a,n=!1){const s=typeof r=="function"?r():r,l=t?t(s):s;if(!l||dl(l))return l;const i=cl(a);return i?On(l,i):n&&typeof window<"u"?On(l,window.location.origin):l}function fl({url:r,resolveUrl:t,baseUrl:a,useWindowOriginForRelative:n=!1,title:s="Copiar link",copiedTitle:l="Link copiado",icon:i=e.jsx(A.HiLink,{className:"h-3.5 w-3.5"}),...c}){return e.jsx(Ia,{...c,value:()=>ul(r,t,a,n),title:s,copiedTitle:l,icon:i})}const zt=[25,50,100,200,500];let Ye={dataTable:{pageSizeOptions:[...zt]}};function bl(){if(typeof window>"u")return;const t=window.__BONSAIF_DATA_TABLE_PREFERENCES_ENDPOINT__;return typeof t=="string"&&t.trim().length>0?t.trim().replace(/\/+$/,""):void 0}function Pa(){const r=Ye.dataTable.preferencesEndpoint,t=bl();return r&&r.trim().length>0?r.trim().replace(/\/+$/,""):t}function pl(r){if(!Array.isArray(r))return[...zt];const t=Array.from(new Set(r.map(a=>typeof a=="number"?Math.floor(a):Number.NaN).filter(a=>Number.isFinite(a)&&a>0)));return t.length>0?t:[...zt]}function Hn(r){if(typeof r!="string")return;const t=r.trim();if(t)return t.replace(/\/+$/,"")}function ml(r){if(!r||typeof r!="object"||!r.dataTable)return;const t=Hn(r.dataTable.preferencesEndpoint);Ye={...Ye,dataTable:{...Ye.dataTable,pageSizeOptions:pl(r.dataTable.pageSizeOptions),preferencesEndpoint:t??Ye.dataTable.preferencesEndpoint}}}function hl(){return{dataTable:{pageSizeOptions:[...Ye.dataTable.pageSizeOptions]}}}function ut(){return[...Ye.dataTable.pageSizeOptions]}function vl(){Ye={dataTable:{pageSizeOptions:[...zt]}}}function gl(r){Ye={...Ye,dataTable:{...Ye.dataTable,preferencesEndpoint:Hn(r)}}}const _t=[{value:"equals",label:"Igual a",valueMode:"single"},{value:"notEquals",label:"No es igual a",valueMode:"single"},{value:"greaterThan",label:"Mayor que",valueMode:"single"},{value:"greaterThanOrEqual",label:"Mayor o igual que",valueMode:"single"},{value:"lessThan",label:"Menor que",valueMode:"single"},{value:"lessThanOrEqual",label:"Menor o igual que",valueMode:"single"},{value:"between",label:"Entre",valueMode:"between"},{value:"top10",label:"10 superiores",valueMode:"none"},{value:"bottom10",label:"10 inferiores",valueMode:"none"},{value:"aboveAverage",label:"Sobre promedio",valueMode:"none"},{value:"belowAverage",label:"Bajo promedio",valueMode:"none"}],xl=_t.map(r=>({value:r.value,label:r.label})),yl=12,wl={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},Pn={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},Nl="bonsaif-ui:datatable:",kl="[&_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",Sl=[],Cl=52;function mr(r){if(!r)return 150;const t=parseInt(r,10);return isNaN(t)||t<=0?150:t}function Fn(r){return!!(r&&(Array.isArray(r.columnOrder)&&r.columnOrder.length>0||r.columnWidths&&Object.keys(r.columnWidths).length>0||Array.isArray(r.hiddenColumnKeys)&&r.hiddenColumnKeys.length>0||r.filters&&Object.keys(r.filters).length>0||r.conditionFilters&&Object.keys(r.conditionFilters).length>0||r.sort||typeof r.bql=="string"||Array.isArray(r.bqlHistory)&&r.bqlHistory.length>0||typeof r.pageSize=="number"))}function zn(r){return`${Nl}${r}`}function jt(r){try{const t=window.localStorage.getItem(zn(r));if(!t)return null;const a=JSON.parse(t);return a&&typeof a=="object"?a:null}catch{return null}}function El(r,t){try{window.localStorage.setItem(zn(r),JSON.stringify(t))}catch{}}function Ml(r,t){if(r===!0)return{...Pn};if(r===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(t&&r==null)return{...Pn};const a={...wl,...r??{}};return t&&(typeof r!="object"||r.pagination!==!1)&&(a.pagination=!0),a}function _n(...r){return r.reduce((t,a)=>({...t,...a??{}}),{})}function Fa(r,t,a){return typeof r!="number"||r<=0?a:ht(t).includes(r)?r:a}function ft(r){if(!r||typeof r!="object")return!1;const t=r;return typeof t.key=="string"&&(t.dir==="asc"||t.dir==="desc")}function bt(r,t){if(!r||typeof r!="object"||Array.isArray(r))return{};const a=Object.entries(r).flatMap(([n,s])=>{if(!t.has(n)||!Array.isArray(s))return[];const l=s.filter(i=>typeof i=="string");return l.length>0?[[n,l]]:[]});return Object.fromEntries(a)}function pt(r,t){if(!r||typeof r!="object"||Array.isArray(r))return{};const a=new Set(_t.map(s=>s.value)),n=Object.entries(r).flatMap(([s,l])=>{if(!t.has(s)||!l||typeof l!="object")return[];const i=l;return!i.operator||!a.has(i.operator)?[]:[[s,{operator:i.operator,value:typeof i.value=="string"?i.value:"",valueTo:typeof i.valueTo=="string"?i.valueTo:""}]]});return Object.fromEntries(n)}function Ze(r,t){if(Cr(r))return Cl;const a=r.minWidth??80,n=r.maxWidth??1/0;return Math.min(n,Math.max(a,t))}function Ll(r){const t=window.getComputedStyle(r);return parseFloat(t.paddingLeft)+parseFloat(t.paddingRight)}function Cr(r){return r.key==="actions"||r.key==="acciones"?!0:typeof r.header=="string"&&r.header.trim().toLowerCase()==="acciones"}function $l(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 hr(r,t){var i;const a=new Set(t.filter(c=>c.hideable!==!1).map(c=>c.key)),n=Array.from(new Set(r??[])).filter(c=>a.has(c));if(t.filter(c=>!n.includes(c.key)).length>0)return n;const l=(i=t.find(c=>c.hideable!==!1))==null?void 0:i.key;return l?n.filter(c=>c!==l):[]}function Tl(r){return r==null||r===""?"(Vacio)":r instanceof Date?r.toLocaleDateString():String(r)}function jr(r){return r==null||typeof r=="boolean"?"":typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(jr).join(" ").trim():o.isValidElement(r)?jr(r.props.children):""}function Wt(r,t){const a=r.filterValue?r.filterValue(t):r.sortKey?t[r.sortKey]:r.cell(t);return typeof a=="string"||typeof a=="number"||typeof a=="boolean"||a===null||a===void 0||a instanceof Date?Tl(a):jr(a).trim()}function mt(r){const t=r.replace(/,/g,"").trim();if(!t)return null;const a=Number(t);return Number.isFinite(a)?a:null}function Wr(r,t){const a=mt(r),n=mt(t);return a!==null&&n!==null?a-n:r.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function ht(r){const t=Array.from(new Set(r.map(a=>Math.floor(a)).filter(a=>Number.isFinite(a)&&a>0)));return t.length>0?t:ut()}function Al(r,t,a){var i,c;const n=((i=t.value)==null?void 0:i.trim())??"",s=((c=t.valueTo)==null?void 0:c.trim())??"",l=_t.find(u=>u.value===t.operator);if((l==null?void 0:l.valueMode)==="single"&&!n||(l==null?void 0:l.valueMode)==="between"&&(!n||!s))return!0;switch(t.operator){case"equals":return r.toLowerCase()===n.toLowerCase();case"notEquals":return r.toLowerCase()!==n.toLowerCase();case"greaterThan":return Wr(r,n)>0;case"greaterThanOrEqual":return Wr(r,n)>=0;case"lessThan":return Wr(r,n)<0;case"lessThanOrEqual":return Wr(r,n)<=0;case"between":return Wr(r,n)>=0&&Wr(r,s)<=0;case"top10":case"bottom10":{const f=a.map(p=>({value:p,number:mt(p)})).filter(p=>p.number!==null).sort((p,m)=>p.number-m.number).map(p=>p.value);return(t.operator==="top10"?f.slice(-10):f.slice(0,10)).includes(r)}case"aboveAverage":case"belowAverage":{const u=a.map(mt).filter(p=>p!==null);if(u.length===0)return!1;const f=u.reduce((p,m)=>p+m,0)/u.length,b=mt(r);return b===null?!1:t.operator==="aboveAverage"?b>f:b<f}default:return!0}}function jn({children:r,className:t="",style:a}){return e.jsx(_r,{onlyWhenOverflow:!0,className:t,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",...a},children:r})}function Wn({columns:r,data:t,getRowId:a,loading:n=!1,skeletonRows:s=8,emptyIcon:l,emptyText:i="Sin resultados",initialEmptyDelay:c=450,onRowClick:u,renderExpandedRow:f,getRowCanExpand:b,expandedRowIds:p,defaultExpandedRowIds:m=[],onExpandedRowIdsChange:w,expandOnRowClick:y=!1,selected:k,onToggleOne:v,onToggleAll:C,highlightSelected:B=!0,rowClassName:T,getRowCategory:W,stickyHeader:L=!0,pageSize:S=25,pageSizeOptions:q,pageSizeSelectWidth:H=62,pageSizeSelectHeight:z=30,pageSizeSelectPadding:X="0 7px",totalRows:Z,page:M,onPageChange:U,onPageSizeChange:j,storageKey:N,stickyFirstColumn:K=!1,bottomOffset:I=0,compact:E=!0,restrictHeight:R=!0,maxHeight:ne,minTableWidth:$,enableColumnVisibility:O=!0,enableColumnFilters:re=!0,hiddenColumnKeys:ee,defaultHiddenColumnKeys:oe=Sl,onHiddenColumnKeysChange:ie,columnVisibilityLabel:ve="Columnas",enableBql:te=!1,bqlValue:J,defaultBqlValue:h="",onBqlChange:D,bqlDescription:V="Filtra registros con Bonsaif Query Language",bqlPlaceholder:ae=`status = activo
2
- rol IN (admin, employee)`,bqlQuickFilters:se=[],bqlExamples:he=[],bqlSuggestions:Be=[],bqlActiveFilters:Ve,bqlError:xe,onQueryChange:Ae,persistState:$e,onPreferencesReady:Ee,enableExport:cr=!1,exportFilename:dr="datos"}){var Cs;const pe=Ml($e,N),P=Object.values(pe).some(Boolean),Q=r.map(d=>d.key).join(","),Y=oe.join(","),de=o.useRef(r),Se=o.useRef(oe);de.current=r,Se.current=oe;const[ke,ye]=o.useState(!N||!P),Le=o.useRef(null),Oe=o.useRef(!N),_e=o.useRef(!1),Lr=o.useRef(Ee);Lr.current=Ee;const nr=o.useRef(!N||!P?N??"__none__":null),je=ee!==void 0,[Xr,ur]=o.useState(()=>hr(oe,r)),qe=hr(je?ee:Xr,r),[xr,sa]=o.useState(!1),[$r,kd]=o.useState("filter"),[St,la]=o.useState(null),[Ko,Xo]=o.useState(""),[Xe,Yr]=o.useState({}),[or,Ct]=o.useState({}),nn=p!==void 0,[Yo,Sd]=o.useState(m),Tr=J!==void 0,[Cd,Et]=o.useState(h),fr=Tr?J:Cd,[Mt,ia]=o.useState(fr),[br,Ar]=o.useState(!1),[Zo,Zr]=o.useState(!1),[Qo,Qr]=o.useState(!1),[Lt,Jr]=o.useState([]),Rr=o.useRef(null),Dr=o.useRef(null),sr=o.useRef(D);sr.current=D;const ca=o.useRef(S);ca.current=S;const da=o.useRef(q);da.current=q;const Ed=Array.isArray(q)?q.join(","):"",on=o.useRef(null),Jo=o.useRef(null),sn=o.useRef(null),Ro=o.useRef(0),[Md,Ld]=o.useState({}),[$d,Td]=o.useState({}),[$t,ua]=o.useState(!1),ln=o.useRef(null),fa=o.useRef(null),[Ad,Dd]=o.useState({}),es=o.useRef(null),ba=o.useRef(null),[cn,rs]=o.useState(t.length>0||n||c===!1),ts=(d,g)=>50+(d*17+g*13+7)%40,yr=o.useRef(null),[Id,Bd]=o.useState(void 0),[as,Od]=o.useState(0),[dn,Hd]=o.useState(!1);o.useEffect(()=>{function d(){Hd(window.innerWidth<640)}if(!R||ne!==void 0)return d(),window.addEventListener("resize",d),()=>window.removeEventListener("resize",d);const F=S!==!1?48:0,x=12;function G(){if(d(),!yr.current)return;const le=yr.current.getBoundingClientRect().top;Bd(Math.max(120,window.innerHeight-le-F-x-I))}return G(),window.addEventListener("resize",G),()=>window.removeEventListener("resize",G)},[n,S,I,R,ne]);const ns=R?ne??Id:void 0;o.useEffect(()=>{const d=yr.current;if(!d)return;const g=()=>Od(d.clientWidth);if(g(),typeof ResizeObserver>"u")return window.addEventListener("resize",g),()=>window.removeEventListener("resize",g);const F=new ResizeObserver(g);return F.observe(d),()=>F.disconnect()},[n,ke,t.length]),o.useEffect(()=>{if(c===!1||n||t.length>0){rs(!0);return}if(cn)return;const d=window.setTimeout(()=>{rs(!0)},c);return()=>window.clearTimeout(d)},[t.length,c,cn,n]);const[et,rt]=o.useState(()=>r.map(d=>d.key)),[tt,at]=o.useState(()=>Object.fromEntries(r.map(d=>[d.key,Ze(d,mr(d.width))]))),[Ie,Ir]=o.useState(null),[Pd,pa]=o.useState(1),[ma,ha]=o.useState(S===!1?0:S);o.useEffect(()=>{var Ue;const d=de.current,g=Se.current,F=d.map(ue=>ue.key),x=new Set(F),G=()=>{var ue;_e.current||(_e.current=!0,(ue=Lr.current)==null||ue.call(Lr))};if(!N||!P){pe.layout&&rt(F),je||ur(hr(g,d)),Oe.current=!1,ye(!0),G();return}let le=!1;const ce=nr.current===N;ce||(Oe.current=!1,ye(!1),_e.current=!1);const ge=jt(N);if(Fn(ge)&&!ce){const ue=ge,fe=ht(da.current??ut()),be=ca.current,Fr=be===!1?0:be,wr=pe.layout?ue==null?void 0:ue.columnOrder:void 0,Nr=Array.isArray(wr)?wr.filter(Te=>F.includes(Te)):[],kr=F.filter(Te=>!Nr.includes(Te)),zr=Nr.length>0?[...Nr,...kr]:F,lt=Object.fromEntries(d.map(Te=>[Te.key,Ze(Te,mr(Te.width))])),it=pe.layout?(ue==null?void 0:ue.columnWidths)??{}:{},Dt=Object.fromEntries(d.map(Te=>[Te.key,Ze(Te,it[Te.key]??lt[Te.key])])),ct=hr(pe.layout?(ue==null?void 0:ue.hiddenColumnKeys)??g:g,d);if(pe.layout&&(rt(zr),at(Dt)),je||ur(ct),pe.filters&&(Yr(bt(ue==null?void 0:ue.filters,x)),Ct(pt(ue==null?void 0:ue.conditionFilters,x))),pe.sort){const Te=ft(ue==null?void 0:ue.sort)?ue.sort:null;Ir(Te&&x.has(Te.key)?Te:null)}if(pe.bql){if(Rr.current!==N){Rr.current=N;const Te=typeof(ue==null?void 0:ue.bql)=="string"?ue.bql:h;Tr?(Ue=sr.current)==null||Ue.call(sr,Te):Et(Te)}Jr(Array.isArray(ue==null?void 0:ue.bqlHistory)?ue.bqlHistory.filter(Te=>typeof Te=="string"):[])}pe.pagination&&Dr.current!==N&&(Dr.current=N,ha(Fa(ue==null?void 0:ue.pageSize,fe,Fr))),nr.current=N,ye(!0),G()}const we=`${Pa()??"/api/user/preferences/datatables"}?key=${encodeURIComponent(N)}`,Ce=new AbortController,Ne=window.setTimeout(()=>Ce.abort(),2500);return fetch(we,{cache:"no-store",signal:Ce.signal}).then(ue=>ue.ok?ue.json():null).then(ue=>{var Es;if(le)return;const fe=jt(N),be=_n(Fn(ue==null?void 0:ue.settings)?ue==null?void 0:ue.settings:null,fe),Fr=ht(da.current??ut()),wr=ca.current,Nr=wr===!1?0:wr,kr=pe.layout?be==null?void 0:be.columnOrder:void 0,zr=Array.isArray(kr)?kr.filter(He=>F.includes(He)):[],lt=F.filter(He=>!zr.includes(He)),it=zr.length>0?[...zr,...lt]:F,Dt=Object.fromEntries(d.map(He=>[He.key,Ze(He,mr(He.width))])),ct=pe.layout?(be==null?void 0:be.columnWidths)??{}:{},Te=Object.fromEntries(d.map(He=>[He.key,Ze(He,ct[He.key]??Dt[He.key])])),dt=hr(pe.layout?(be==null?void 0:be.hiddenColumnKeys)??g:g,d);if(pe.layout&&(rt(it),at(Te)),je||ur(dt),pe.filters&&(Yr(bt(be==null?void 0:be.filters,x)),Ct(pt(be==null?void 0:be.conditionFilters,x))),pe.sort){const He=ft(be==null?void 0:be.sort)?be.sort:null;Ir(He&&x.has(He.key)?He:null)}if(pe.bql){if(Rr.current!==N){Rr.current=N;const He=typeof(be==null?void 0:be.bql)=="string"?be.bql:h;Tr?(Es=sr.current)==null||Es.call(sr,He):Et(He)}Jr(Array.isArray(be==null?void 0:be.bqlHistory)?be.bqlHistory.filter(He=>typeof He=="string"):[])}let De;pe.pagination&&(De=Fa(be==null?void 0:be.pageSize,Fr,Nr),Dr.current!==N&&(Dr.current=N,ha(De))),Le.current=JSON.stringify({columnOrder:it,columnWidths:Te,hiddenColumnKeys:dt,filters:bt(be==null?void 0:be.filters,x),conditionFilters:pt(be==null?void 0:be.conditionFilters,x),sort:ft(be==null?void 0:be.sort)?be.sort:null,bql:typeof(be==null?void 0:be.bql)=="string"?be.bql:"",bqlHistory:Array.isArray(be==null?void 0:be.bqlHistory)?be.bqlHistory:[],pageSize:pe.pagination&&wr!==!1?De:void 0}),Oe.current=!0}).catch(()=>{var ue;if(!le){const fe=jt(N),be=ht(da.current??ut()),Fr=ca.current,wr=Fr===!1?0:Fr,Nr=pe.layout?fe==null?void 0:fe.columnOrder:void 0,kr=Array.isArray(Nr)?Nr.filter(De=>F.includes(De)):[],zr=F.filter(De=>!kr.includes(De)),lt=kr.length>0?[...kr,...zr]:F,it=Object.fromEntries(d.map(De=>[De.key,Ze(De,mr(De.width))])),Dt=pe.layout?(fe==null?void 0:fe.columnWidths)??{}:{},ct=Object.fromEntries(d.map(De=>[De.key,Ze(De,Dt[De.key]??it[De.key])]));pe.layout&&(rt(lt),at(ct));const Te=hr(pe.layout?(fe==null?void 0:fe.hiddenColumnKeys)??g:g,d);if(je||ur(Te),pe.filters&&(Yr(bt(fe==null?void 0:fe.filters,x)),Ct(pt(fe==null?void 0:fe.conditionFilters,x))),pe.sort){const De=ft(fe==null?void 0:fe.sort)?fe.sort:null;Ir(De&&x.has(De.key)?De:null)}if(pe.bql){if(Rr.current!==N){Rr.current=N;const De=typeof(fe==null?void 0:fe.bql)=="string"?fe.bql:h;Tr?(ue=sr.current)==null||ue.call(sr,De):Et(De)}Jr(Array.isArray(fe==null?void 0:fe.bqlHistory)?fe.bqlHistory.filter(De=>typeof De=="string"):[])}let dt;pe.pagination&&(dt=Fa(fe==null?void 0:fe.pageSize,be,wr),Dr.current!==N&&(Dr.current=N,ha(dt))),Le.current=JSON.stringify({columnOrder:lt,columnWidths:ct,hiddenColumnKeys:Te,filters:bt(fe==null?void 0:fe.filters,x),conditionFilters:pt(fe==null?void 0:fe.conditionFilters,x),sort:ft(fe==null?void 0:fe.sort)?fe.sort:null,bql:typeof(fe==null?void 0:fe.bql)=="string"?fe.bql:"",bqlHistory:Array.isArray(fe==null?void 0:fe.bqlHistory)?fe.bqlHistory:[],pageSize:pe.pagination&&Fr!==!1?dt:void 0}),Oe.current=!0}}).finally(()=>{window.clearTimeout(Ne),le||(nr.current=N,ye(!0),G())}),()=>{le=!0,Ce.abort(),window.clearTimeout(Ne)}},[N,P,Q,Y,je,pe.layout,pe.filters,pe.sort,pe.bql,pe.pagination,Tr,h,Ed]),o.useEffect(()=>{if(!N||!ke||!P||!Oe.current)return;const d={};pe.layout&&(d.columnOrder=et,d.columnWidths=tt,d.hiddenColumnKeys=qe),pe.filters&&(d.filters=Xe,d.conditionFilters=or),pe.sort&&(d.sort=Ie),pe.bql&&(d.bql=fr,d.bqlHistory=Lt),pe.pagination&&S!==!1&&(d.pageSize=ma);const g=jt(N),F=_n(g,d),x=JSON.stringify(F);if(x===Le.current)return;El(N,F),Le.current=x;const G=window.setTimeout(()=>{const le=Pa()??"/api/user/preferences/datatables";fetch(le,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:N,settings:F})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(G)},[et,tt,qe,Xe,or,Ie,fr,Lt,ma,S,N,ke,P,pe.layout,pe.filters,pe.sort,pe.bql,pe.pagination]),o.useEffect(()=>{rt(d=>{const g=r.map(G=>G.key),F=d.filter(G=>g.includes(G)),x=g.filter(G=>!F.includes(G));return[...F,...x]})},[Q,r]);const os=et.map(d=>r.find(g=>g.key===d)).filter(d=>!!d),er=os.filter(d=>!qe.includes(d.key)),Fd=Object.keys(Xe).length,zd=Object.keys(or).length,un=Fd+zd;function ss(d){const g=new Set;return t.reduce((F,x)=>{const G=Wt(d,x);return!G||g.has(G)||(g.add(G),F.push({value:G,label:G})),F},[])}function _d(){const d=r.find(g=>g.key===St);return d?ss(d):[]}function jd(d){return!!(re&&!Cr(d)&&(d.filterValue||d.sortKey||ss(d).length>0))}function ls(d,g){Yr(F=>{const x={...F};return x[d]=g,x})}function Wd(d,g,F,x){const G=Xe[d]??[],le=x?G:F.filter(ge=>ge!==g),ce=x?G.includes(g)?G.filter(ge=>ge!==g):[...G,g]:le;ce.length===F.length?fn(d):ls(d,ce)}function fn(d){Yr(g=>{const F={...g};return delete F[d],F})}function va(d,g){Ct(F=>{const x={...F};return g?x[d]=g:delete x[d],x})}function is(d){va(d,null)}function qd(){Yr({}),Ct({})}function Ud(d){Tr||Et(d),D==null||D(d)}function cs(d){const g=d.trim();ia(g),(D==null?void 0:D(g))!==!1&&(Tr||Et(g),Ar(!1),Zr(!1),Qr(!1),g&&Jr(x=>[g,...x.filter(G=>G!==g)].slice(0,yl)))}function ds(){ia(""),Ud(""),Ar(!1),Zr(!1),Qr(!1)}function bn(d,g){ia(d),g&&(g.style.height="auto",g.style.height=`${Math.min(g.scrollHeight,180)}px`)}function ga(d){const g=d.trim();if(!g)return;Ro.current=Date.now()+500;const F=Mt.replace(/\s+$/u,""),x=F.length===0?g:F.split(`
3
- `).map(G=>G.trim()).includes(g)?F:`${F}
4
- ${g}`;bn(x,sn.current??void 0),requestAnimationFrame(()=>{const G=sn.current;if(!G)return;G.focus();const le=G.value.length;G.setSelectionRange(le,le),bn(G.value,G)})}o.useEffect(()=>{ia(fr)},[fr]);const xa=o.useCallback(()=>{const d=on.current;if(!d)return;const g=d.getBoundingClientRect(),F=12,x=8,G=Math.min(780,Math.max(320,window.innerWidth-32)),le=Math.max(F,window.innerWidth-G-F),ce=Math.min(Math.max(F,g.left),le),ge=g.bottom+x,ze=window.innerHeight-g.top+x,Fe=window.innerHeight-ge-F,we=g.top-F-x,Ce=Fe<280&&we>Fe,Ne=Math.max(240,Ce?we:Fe);Ld({position:"fixed",zIndex:1e4,left:ce,top:Ce?void 0:ge,bottom:Ce?ze:void 0,width:G,maxWidth:"calc(100vw - 24px)",maxHeight:Ne,overflowY:"auto"})},[]);o.useEffect(()=>{if(!br)return;function d(x){var le,ce;if(Date.now()<Ro.current)return;const G=x.target;(le=on.current)!=null&&le.contains(G)||(ce=Jo.current)!=null&&ce.contains(G)||(Ar(!1),Zr(!1),Qr(!1))}function g(x){x.key==="Escape"&&(Ar(!1),Zr(!1),Qr(!1))}function F(){xa()}return xa(),document.addEventListener("mousedown",d),window.addEventListener("keydown",g),window.addEventListener("resize",F),window.addEventListener("scroll",F,!0),()=>{document.removeEventListener("mousedown",d),window.removeEventListener("keydown",g),window.removeEventListener("resize",F),window.removeEventListener("scroll",F,!0)}},[br,xa]);function us(d){const g=hr(d,r);je||ur(g),ie==null||ie(g)}function Vd(d){us(qe.includes(d)?qe.filter(g=>g!==d):[...qe,d])}function Gd(){us([])}const pn=o.useCallback((d=ba.current)=>{if(!d)return;const g=d.getBoundingClientRect(),F=Math.min(292,Math.max(240,window.innerWidth-16)),x=Math.max(8,window.innerWidth-F-8),G=Math.min(Math.max(8,g.right-F),x),le=window.innerHeight-g.bottom,ce=g.bottom+6,ge=window.innerHeight-g.top+6,Fe=le<360&&g.top>le?void 0:ce,we=Fe===void 0?ge:void 0,Ce=Math.max(220,Fe===void 0?g.top-16:window.innerHeight-ce-8),Ne={position:"fixed",zIndex:9999,left:G,top:Fe,bottom:we,width:F,maxWidth:"calc(100vw - 16px)",maxHeight:Ce,"--dt-column-menu-max-height":`${Ce}px`};Td(Ne)},[]);function fs(d,g,F=null){d.preventDefault(),d.stopPropagation();const x=ba.current===d.currentTarget&&$r===g&&St===F;if(xr&&x){sa(!1),la(null);return}ba.current=d.currentTarget,kd(g),la(F),Xo(""),pn(d.currentTarget),sa(!0)}function Kd(d){if(Cr(d))return;const g=yr.current;if(!g)return;const x=Array.from(g.querySelectorAll("[data-dt-column-key]")).filter(G=>G.dataset.dtColumnKey===d.key).reduce((G,le)=>{const ce=le.querySelector("[data-dt-autofit-content]"),ge=ce?ce.scrollWidth:Math.max(le.scrollWidth,le.offsetWidth);return Math.max(G,Math.ceil(ge+Ll(le)))},0);x<=0||at(G=>({...G,[d.key]:Ze(d,x+12)}))}o.useEffect(()=>{at(d=>{const g=Object.fromEntries(r.map(F=>[F.key,Ze(F,mr(F.width))]));return Object.fromEntries(r.map(F=>[F.key,Ze(F,d[F.key]??g[F.key])]))})},[Q,r]),o.useEffect(()=>{je||ur(d=>hr(d,r))},[Q,r,je]),o.useEffect(()=>{function d(x){var ce,ge;const G=x.target,le=x.target;le!=null&&le.closest("[data-bonsaif-select-dropdown='true']")||!((ce=es.current)!=null&&ce.contains(G))&&!((ge=ba.current)!=null&&ge.contains(G))&&(sa(!1),la(null))}function g(x){x.key==="Escape"&&(sa(!1),la(null))}function F(){pn()}return xr&&(document.addEventListener("mousedown",d),window.addEventListener("keydown",g),window.addEventListener("resize",F),window.addEventListener("scroll",F,!0)),()=>{document.removeEventListener("mousedown",d),window.removeEventListener("keydown",g),window.removeEventListener("resize",F),window.removeEventListener("scroll",F,!0)}},[xr,pn]);const Tt=o.useRef(null);o.useEffect(()=>{function d(F){const x=Tt.current;if(!x)return;const G=F.clientX-x.startX,le=r.find(ce=>ce.key===x.colKey);le&&at(ce=>({...ce,[x.colKey]:Ze(le,x.startWidth+G)}))}function g(){Tt.current&&(Tt.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",d),document.addEventListener("pointerup",g),()=>{document.removeEventListener("pointermove",d),document.removeEventListener("pointerup",g)}},[r]);const ya=o.useRef(null),[bs,mn]=o.useState(null);function Xd(d,g){ya.current=et.indexOf(d),g.dataTransfer.effectAllowed="move"}function Yd(d,g){g.preventDefault(),g.dataTransfer.dropEffect="move";const F=et.indexOf(d);bs!==F&&mn(F)}function Zd(d,g){g.preventDefault();const F=ya.current,x=et.indexOf(d);F!==null&&F!==x&&rt(G=>{const le=[...G],[ce]=le.splice(F,1);return le.splice(x,0,ce),le}),ya.current=null,mn(null)}function Qd(){ya.current=null,mn(null)}function Jd(d){d.sortKey&&Ir(g=>(g==null?void 0:g.key)===d.key?{key:d.key,dir:g.dir==="asc"?"desc":"asc"}:{key:d.key,dir:"asc"})}o.useEffect(()=>{pa(1)},[t]),o.useEffect(()=>{pa(1)},[or,Xe]);const Br=!!(U&&j),Or=S!==!1,ps=o.useMemo(()=>ht(q??ut()),[q]),We=Br?M??1:Pd,lr=Br||Or?ma:t.length,ir=!!k&&!!v&&!!C,nt=!!f,ms=o.useMemo(()=>new Set(nn?Array.from(p??[]):Yo),[nn,p,Yo]),hn=(nt?40:0)+(ir?40:0),Rd=ir&&t.length>0&&k.size===t.length,eu=ir&&k.size>0&&k.size<t.length,wa=o.useMemo(()=>{const d=Object.entries(Xe),g=Object.entries(or);return d.length===0&&g.length===0?t:t.filter(F=>d.every(([x,G])=>{const le=r.find(ce=>ce.key===x);return le?G.includes(Wt(le,F)):!0})&&g.every(([x,G])=>{const le=r.find(ge=>ge.key===x);if(!le)return!0;const ce=t.map(ge=>Wt(le,ge));return Al(Wt(le,F),G,ce)}))},[or,Xe,r,t]),Hr=o.useMemo(()=>{if(!Ie)return wa;const d=r.find(g=>g.key===Ie.key&&g.sortKey);return d!=null&&d.sortKey?[...wa].sort((g,F)=>{const x=g[d.sortKey],G=F[d.sortKey],le=x===G?0:x==null?1:G==null||x<G?-1:1;return Ie.dir==="asc"?le:-le}):wa},[wa,Ie,r]),hs=o.useMemo(()=>{if(Br||!Or)return Hr;const d=(We-1)*lr;return Hr.slice(d,d+lr)},[Hr,Br,Or,We,lr]),Pr=Br?Z??t.length:Hr.length,vn=Or?Math.max(1,Math.ceil(Pr/lr)):1,ru=Math.min(...ps),tu=Or&&(Pr>lr||Pr>ru),au=Or?(We-1)*lr+1:1,nu=Or?Math.min(We*lr,Pr):Pr;function gn(d){if(n)return;const g=Math.max(1,Math.min(d,vn));Br?U(g):pa(g)}function ou(d){n||(N&&(Dr.current=N),ha(d),Br?(j(d),U(1)):(pa(1),j==null||j(d)))}function vs(d){const g=new Set(ms);g.has(d)?g.delete(d):g.add(d);const F=Array.from(g);nn||Sd(F),w==null||w(F)}o.useEffect(()=>{Ae==null||Ae({bql:fr,filters:Xe,conditionFilters:or,sort:Ie,page:We,pageSize:lr,hiddenColumnKeys:qe})},[fr,Xe,or,Ie,We,lr,qe,Ae]);const gs=d=>d==="center"?"text-center":d==="right"?"text-right":"text-left",su="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",xn="linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 90%, var(--bg-card)) 0%, color-mix(in srgb, var(--bg-input) 70%, var(--bg-card)) 100%)",Me="color-mix(in srgb, var(--border) 62%, var(--bg-card))",ot="color-mix(in srgb, var(--primary) 24%, var(--border))",Na=`inset 0 0 0 1px ${Me}`,xs=er.reduce((d,g)=>d+(tt[g.key]??mr(g.width)),(nt?40:0)+(ir?40:0)),ys=typeof $=="number"?$:typeof $=="string"?Number(((Cs=$.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:Cs[1])??NaN):NaN,At=Number.isFinite(ys)?Math.max(xs,ys,as):Math.max(xs,as),ka=$??At,st=`${nt?"40px ":""}${ir?"40px ":""}${er.map(d=>`${tt[d.key]??mr(d.width)}px`).join(" ")}`;o.useEffect(()=>{Ie&&qe.includes(Ie.key)&&Ir(null)},[qe,Ie]);function ws(d){return d?typeof d=="string"?{key:d,label:d}:d:null}const Sa=()=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:st,background:xn,borderBottom:`1px solid ${ot}`},children:[nt&&e.jsx("div",{role:"columnheader",className:`${E?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${ot}`,borderRight:`1px solid ${Me}`}}),ir&&e.jsx("div",{role:"columnheader",className:`${E?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:K?{position:"sticky",left:0,zIndex:12,background:xn,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${ot}`,borderRight:`1px solid ${Me}`}:{borderBottom:`1px solid ${ot}`,borderRight:`1px solid ${Me}`},children:e.jsx(Ht,{size:"sm",checked:Rd,indeterminate:eu,onChange:C,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),er.map((d,g)=>{const F=(Ie==null?void 0:Ie.key)===d.key,x=!!d.sortKey,G=Cr(d),le=K&&!dn&&g===0,ce=bs===g,ze=(tt[d.key]??mr(d.width))<120,Fe=Object.prototype.hasOwnProperty.call(Xe,d.key)||Object.prototype.hasOwnProperty.call(or,d.key);return e.jsxs("div",{role:"columnheader","data-dt-column-key":d.key,className:`group select-none ${ze?"text-left":gs(d.align)}`,style:{...le?{position:"sticky",left:hn,zIndex:12,background:xn,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${ot}`,borderRight:`1px solid ${Me}`}:{position:"relative",borderBottom:`1px solid ${ot}`,borderRight:`1px solid ${Me}`},color:F?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:ce?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:G?E?"7px 6px":"9px 8px":E?"8px 6px 10px":"10px 8px 12px"},onDragOver:we=>Yd(d.key,we),onDrop:we=>Zd(d.key,we),children:[e.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${G?"justify-center":ze?"justify-start":d.align==="center"?"justify-center":d.align==="right"?"justify-end":"justify-start"}`,children:[e.jsx("span",{draggable:!0,onDragStart:we=>{we.stopPropagation(),Xd(d.key,we)},onDragEnd:we=>{we.stopPropagation(),Qd()},onClick:we=>we.stopPropagation(),title:"Arrastrar para mover columna","aria-label":"Arrastrar para mover columna",className:`absolute left-0 top-0 z-10 inline-flex h-full w-3 shrink-0 rounded-sm transition-colors duration-150 hover:bg-[var(--primary)]/15 ${ce?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}),G?e.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-md text-[var(--text-muted)]",title:"Acciones","aria-label":"Acciones",children:e.jsx(A.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):e.jsx(jn,{className:"min-w-0 flex-1",children:e.jsx("span",{"data-dt-autofit-content":!0,className:`inline-flex max-w-full items-center font-semibold uppercase tracking-wider ${E?"text-[11px]":"text-xs"}`,children:e.jsx("span",{className:"min-w-0 truncate",children:d.header})})}),x&&e.jsx("button",{type:"button","aria-label":`Ordenar por ${String(d.header)}`,title:"Ordenar",onClick:we=>{we.stopPropagation(),Jd(d)},"data-dt-sort-button":!0,className:`absolute -bottom-2 left-1/2 z-20 inline-flex h-4 w-4 -translate-x-1/2 items-center justify-center rounded-full bg-[var(--primary)] text-[var(--primary-fg)] shadow-[0_1px_3px_rgba(15,23,42,0.22)] transition-[opacity,transform] duration-150 hover:scale-105 focus:scale-105 focus:opacity-100 focus:outline-none ${F?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:F?Ie.dir==="asc"?e.jsx(A.HiChevronUp,{className:"h-3 w-3"}):e.jsx(A.HiChevronDown,{className:"h-3 w-3"}):e.jsx(A.HiChevronUpDown,{className:"h-3 w-3"})}),re&&!G&&jd(d)&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":xr&&St===d.key,"aria-label":`Filtrar ${String(d.header)}`,title:"Filtrar",onClick:we=>fs(we,"filter",d.key),className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-sm bg-transparent text-[var(--text-muted)] opacity-0 transition-[opacity,color,background-color] duration-150 hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] focus:opacity-100 group-hover:opacity-100 ${xr&&$r==="filter"&&St===d.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":Fe?"text-[var(--primary)] opacity-100":""}`,children:Fe?e.jsx(A.HiFunnel,{className:"h-3.5 w-3.5"}):e.jsx(A.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!G&&e.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:we=>{we.preventDefault(),we.stopPropagation(),Tt.current={colKey:d.key,startX:we.clientX,startWidth:tt[d.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:we=>{we.preventDefault(),we.stopPropagation(),Tt.current=null,document.body.style.cursor="",document.body.style.userSelect="",Kd(d)},onClick:we=>we.stopPropagation(),className:"absolute top-0 flex h-full items-center justify-center opacity-0 transition-opacity duration-200 hover:opacity-100",style:{right:0,width:12,cursor:"col-resize",zIndex:6,transform:"translateX(50%)"},children:e.jsxs("span",{style:{display:"flex",gap:4,alignItems:"center",height:"calc(100% - 8px)"},children:[e.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}}),e.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}})]})})]},d.key)})]}),Ca=()=>{if(!xr||typeof document>"u"||$r==="visibility"&&!O||$r==="filter"&&!re)return null;const d=r.find(Ne=>Ne.key===St),g=_d(),F=d?Object.prototype.hasOwnProperty.call(Xe,d.key):!1,x=d?or[d.key]:void 0,G=_t.find(Ne=>Ne.value===(x==null?void 0:x.operator)),le=d?Xe[d.key]??[]:[],ce=Ko.trim().toLowerCase(),ge=ce?g.filter(Ne=>Ne.label.toLowerCase().includes(ce)):g,ze=d&&g.length>0&&(!F||le.length===g.length),Fe=d&&F&&le.length>0&&le.length<g.length,we=qe.length,Ce=()=>{d&&(fn(d.key),is(d.key))};return rr.createPortal(e.jsx("div",{ref:es,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...$d,borderColor:"var(--border)",background:"var(--bg-card)"},children:$r==="visibility"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[e.jsx("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:we>0?`${er.length} de ${r.length} visibles`:`${r.length} visibles`}),e.jsx("button",{type:"button",onClick:Gd,disabled:we===0,className:"rounded px-1.5 py-0.5 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-input)] disabled:opacity-40",children:"Mostrar todas"})]}),e.jsx("div",{className:"max-h-72 overflow-auto py-1",children:os.map(Ne=>{const Ue=!qe.includes(Ne.key),fe=!(Ne.hideable!==!1)||Ue&&er.length<=1;return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ue,disabled:fe,onClick:()=>Vd(Ne.key),className:"flex w-full min-w-0 items-center 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:"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ue?"var(--primary)":"var(--border)",background:Ue?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ue&&e.jsx(A.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:Ne.header})]},Ne.key)})})]}):d?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[e.jsxs("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:["Filtrar ",d.header]}),e.jsx("button",{type:"button",onClick:Ce,disabled:!F&&!x,className:"rounded px-1.5 py-0.5 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-input)] disabled:opacity-40",children:"Limpiar"})]}),d.sortKey&&e.jsxs("div",{className:"grid grid-cols-2 gap-1 border-b border-[var(--border)] p-1",children:[e.jsxs("button",{type:"button",onClick:()=>Ir({key:d.key,dir:"asc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[e.jsx(A.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate",children:"Ascendente"})]}),(Ie==null?void 0:Ie.key)===d.key&&Ie.dir==="asc"&&e.jsx(A.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),e.jsxs("button",{type:"button",onClick:()=>Ir({key:d.key,dir:"desc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[e.jsx(A.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate",children:"Descendente"})]}),(Ie==null?void 0:Ie.key)===d.key&&Ie.dir==="desc"&&e.jsx(A.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]})]}),e.jsxs("div",{className:"border-b border-[var(--border)] p-2",children:[e.jsxs("div",{className:"grid grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)] gap-2",children:[e.jsx(Sr,{value:(x==null?void 0:x.operator)??"",onChange:Ne=>{if(!Ne){is(d.key);return}va(d.key,{operator:Ne,value:(x==null?void 0:x.value)??"",valueTo:(x==null?void 0:x.valueTo)??""})},options:xl,placeholder:"Opcion",emptyLabel:"Sin condicion",ariaLabel:"Operador de filtro",searchable:!1,height:34,padding:"0 9px",dropdownMinWidth:260,className:"min-w-0 [&>button]:rounded-md [&>button]:text-sm [&>button]:font-medium"}),(G==null?void 0:G.valueMode)!=="none"?e.jsx("input",{value:(x==null?void 0:x.value)??"",onChange:Ne=>{x&&va(d.key,{...x,value:Ne.target.value})},disabled:!x,placeholder:"Valor",className:"min-w-0 rounded-md border px-2 py-1.5 text-sm outline-none transition-colors placeholder:text-[var(--text-muted)] focus:border-[var(--primary)] disabled:opacity-50",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"}}):e.jsx("div",{className:"min-h-8 rounded-md border px-2 py-1.5 text-sm text-[var(--text-muted)]",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:"Automatico"})]}),(G==null?void 0:G.valueMode)==="between"&&e.jsx("input",{value:(x==null?void 0:x.valueTo)??"",onChange:Ne=>{x&&va(d.key,{...x,valueTo:Ne.target.value})},placeholder:"Valor final",className:"mt-2 w-full rounded-md border px-2 py-1.5 text-xs outline-none transition-colors placeholder:text-[var(--text-muted)] focus:border-[var(--primary)]",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"}})]}),e.jsx("div",{className:"border-b border-[var(--border)] p-2",children:e.jsxs("div",{className:"flex items-center gap-1 rounded-md border px-2 py-1.5 text-sm",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[e.jsx(A.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),e.jsx("input",{value:Ko,onChange:Ne=>Xo(Ne.target.value),placeholder:"Buscar",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-[var(--text-muted)]",style:{color:"var(--text-main)"}})]})}),e.jsxs("div",{className:"overflow-auto py-1",style:{maxHeight:"max(96px, calc(var(--dt-column-menu-max-height, 520px) - 236px))"},children:[e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Fe?"mixed":!!ze,onClick:()=>{d&&(ze&&!F?ls(d.key,[]):fn(d.key))},className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[e.jsxs("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:ze||Fe?"var(--primary)":"var(--border)",background:ze||Fe?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[Fe&&e.jsx(A.HiMinus,{className:"h-3 w-3"}),ze&&!Fe&&e.jsx(A.HiCheck,{className:"h-3 w-3"})]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),ge.map(Ne=>{const Ue=!F||le.includes(Ne.value);return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ue,onClick:()=>Wd(d.key,Ne.value,g.map(ue=>ue.value),F),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ue?"var(--primary)":"var(--border)",background:Ue?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ue&&e.jsx(A.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:Ne.label})]},Ne.value)}),ge.length===0&&e.jsx("div",{className:"px-3 py-3 text-sm text-[var(--text-muted)]",children:"Sin valores"})]})]}):null}),document.body)};o.useEffect(()=>{if(!$t)return;function d(g){ln.current&&!ln.current.contains(g.target)&&fa.current&&!fa.current.contains(g.target)&&ua(!1)}return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[$t]);function Ns(d,g){if(d.filterValue){const F=d.filterValue(g);return F==null||F===""?"":String(F)}return jr(d.cell(g))}function ks(d){return`"${d.replace(/"/g,'""')}"`}function Ea(d){return d.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function lu(){const d=er.filter(ge=>!Cr(ge)),g=d.map(ge=>ks(jr(ge.header))).join(","),F=Hr.map(ge=>d.map(ze=>ks(Ns(ze,ge))).join(",")).join(`
5
- `),x=`${g}
6
- ${F}`,G=new Blob(["\uFEFF"+x],{type:"text/csv;charset=utf-8;"}),le=URL.createObjectURL(G),ce=document.createElement("a");ce.href=le,ce.download=`${dr}.csv`,document.body.appendChild(ce),ce.click(),document.body.removeChild(ce),URL.revokeObjectURL(le)}function iu(){const d=er.filter(ce=>!Cr(ce)),g=d.map(ce=>Ea(jr(ce.header))),x=Hr.map(ce=>d.map(ge=>Ea(Ns(ge,ce)))).map(ce=>`<tr>${ce.map(ge=>`<td>${ge}</td>`).join("")}</tr>`).join(""),G=`<!DOCTYPE html>
7
- <html lang="es"><head><meta charset="utf-8"><title>${Ea(dr)}</title>
1
+ (function(P,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react"),require("react/jsx-runtime"),require("react-icons/hi2"),require("react-dom"),require("recharts"),require("overlayscrollbars"),require("sonner"),require("overlayscrollbars-react"),require("react-day-picker"),require("react-day-picker/dist/style.css"),require("react-icons/fi")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","react-icons/hi2","react-dom","recharts","overlayscrollbars","sonner","overlayscrollbars-react","react-day-picker","react-day-picker/dist/style.css","react-icons/fi"],o):(P=typeof globalThis<"u"?globalThis:P||self,o(P.BonsaifUI={},P.React,P.jsxRuntime,P.ReactIconsHi2,P.ReactDOM,P.Recharts,P.OverlayScrollbarsGlobal,P.Sonner,P.OverlayScrollbarsReact,P.ReactDayPicker,P.ReactDayPickerStyles,P.ReactIconsFi))})(this,(function(P,o,e,$,Je,ge,$a,Nn,kn,Sn,gu,Is){"use strict";"use client";function hr(...r){return r.filter(Boolean).join(" ")}function Bs({variant:r="primary",className:t,type:a="button",children:n,...s}){return e.jsx("button",{className:hr("bonsaif-ui-button",`bonsaif-ui-button--${r}`,t),type:a,...s,children:n})}function Cn({value:r,onChange:t,placeholder:a,className:n="",autoFocus:s=!1,forceExpanded:l=!1,onEscape:i,size:c="default",inputTabIndex:u}){const f=o.useRef(null),[m,b]=o.useState(!1),p=l||m||r.trim().length>0,y=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",N=n||"w-48 max-w-full sm:w-64 lg:w-72";o.useEffect(()=>{var g;s&&((g=f.current)==null||g.focus())},[s]);const M=()=>{var g;b(!0),(g=f.current)==null||g.focus()};return e.jsxs("div",{className:`relative min-w-0 max-w-full flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${p?N:"w-24 sm:w-28"}`,onMouseDown:g=>{p||(g.preventDefault(),M())},children:[e.jsx($.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)",left:"var(--page-header-control-icon-left, 12px)"}}),e.jsx("input",{ref:f,type:"text",tabIndex:u,"aria-label":a,value:r,onChange:g=>t(g.target.value),onKeyDown:g=>{g.key==="Escape"&&(i==null||i())},placeholder:p?a:"Buscar",className:`${y} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${p?"pl-9 pr-8":"cursor-pointer pl-9 pr-3"}`,style:{height:`var(--page-header-control-height, ${c==="sm"?"36px":"40px"})`,paddingLeft:"calc(var(--page-header-control-icon-left, 12px) + 24px)",paddingRight:p?"calc(var(--page-header-control-padding-x, 14px) + 18px)":"var(--page-header-control-padding-x, 14px)",background:"color-mix(in srgb, var(--bg-card) 86%, transparent)",border:"1px solid var(--border)",color:"var(--text-main)"},onFocus:g=>{b(!0),g.currentTarget.style.borderColor="var(--primary)",g.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:g=>{b(!1),g.currentTarget.style.borderColor="var(--border)",g.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)",right:"var(--page-header-control-padding-x, 8px)"},"aria-label":"Limpiar búsqueda",children:e.jsx($.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const En=o.createContext({});let Mn=0;const Tn="bonsaif-ui:hide-tooltips";function Ot(r=700){Mn=Date.now()+r}function Os(){return Date.now()>Mn}function Ht(r){if(typeof document>"u")return!1;const t=Array.from(document.querySelectorAll('[data-bonsaif-overlay="true"], [role="menu"], [role="dialog"][aria-modal="true"], [aria-hidden="false"] [aria-modal="true"]'));return r&&t.some(a=>a.contains(r))?!1:t.length>0}function Hs(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 jr({children:r,content:t,onlyWhenOverflow:a=!1,interactive:n=!1,followCursor:s=!0,placement:l="bottom",showArrow:i=!1,className:c="",tooltipClassName:u="",style:f,tooltipStyle:m,as:b="div"}){const p=o.useRef(null),y=o.useRef(null),N=o.useRef(null),M=o.useRef(!1),[g,C]=o.useState(null),[B,A]=o.useState("");o.useEffect(()=>{const T=p.current;T&&(T.querySelectorAll("[title]").forEach(J=>{const O=J.getAttribute("title");O&&(J.getAttribute("aria-label")||J.setAttribute("aria-label",O),J.removeAttribute("title"))}),T.querySelectorAll("svg title").forEach(J=>J.remove()))}),o.useLayoutEffect(()=>{if(!g)return;const T=y.current;if(!T)return;const J=12,O=14,j=T.getBoundingClientRect(),te=window.innerWidth-j.width-J,X=window.innerHeight-j.height-J;let I=g.mouseX+O,ee=g.mouseY+O,R,x;if(!s&&p.current){const S=p.current.getBoundingClientRect(),K=S.left+S.width/2,Q=S.top+S.height/2;l==="top"?(I=K-j.width/2,ee=S.top-j.height-O,x=j.height-1):l==="left"?(I=S.left-j.width-O,ee=Q-j.height/2,R=j.width-1):l==="right"?(I=S.right+O,ee=Q-j.height/2,R=-7):(I=K-j.width/2,ee=S.bottom+O,x=-7)}if(s&&(I>te&&(I=g.mouseX-j.width-O),ee>X&&(ee=g.mouseY-j.height-O)),I=Math.min(Math.max(J,I),Math.max(J,te)),ee=Math.min(Math.max(J,ee),Math.max(J,X)),!s&&p.current){const S=p.current.getBoundingClientRect(),K=S.left+S.width/2,Q=S.top+S.height/2;l==="top"||l==="bottom"?R=Math.min(Math.max(14,K-I),j.width-14):x=Math.min(Math.max(14,Q-ee),j.height-14)}(Math.abs(I-g.x)>.5||Math.abs(ee-g.y)>.5||R!==g.arrowX||x!==g.arrowY)&&C(S=>S&&{...S,x:I,y:ee,arrowX:R,arrowY:x})},[s,l,g]);const z=()=>{N.current&&(window.clearTimeout(N.current),N.current=null)},E=(T,J)=>{if(!Os()||M.current)return;const O=p.current;if(O&&!Ht(O)){if(a){const j=Hs(O);if(!j)return;A(j)}!a&&!t||C({mouseX:T,mouseY:J,x:T+14,y:J+14})}},k=()=>{const T=p.current;if(!T)return;const J=T.getBoundingClientRect();E(J.left+J.width/2,J.bottom)},q=()=>{z(),C(null)},H=()=>{if(!n){q();return}z(),N.current=window.setTimeout(()=>C(null),120)},_=()=>{Ot(),M.current=!0,q()},Y=()=>{M.current=!1};o.useEffect(()=>{if(!g)return;if(Ht(p.current)){C(null);return}const T=()=>C(null),J=()=>{Ot(),M.current=!0,C(null)};document.addEventListener("pointerdown",J,!0),document.addEventListener("click",J,!0),document.addEventListener("scroll",T,!0),window.addEventListener("blur",T),document.addEventListener("visibilitychange",T),document.addEventListener("keydown",T,!0);const O=new MutationObserver(()=>{Ht(p.current)&&C(null)});return O.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",J,!0),document.removeEventListener("click",J,!0),document.removeEventListener("scroll",T,!0),window.removeEventListener("blur",T),document.removeEventListener("visibilitychange",T),document.removeEventListener("keydown",T,!0),O.disconnect()}},[g]),o.useEffect(()=>{const T=()=>Ot(),J=()=>{Ot(),M.current=!0,C(null)};return document.addEventListener("pointerdown",T,!0),document.addEventListener("click",T,!0),document.addEventListener("keydown",T,!0),window.addEventListener(Tn,J),()=>{document.removeEventListener("pointerdown",T,!0),document.removeEventListener("click",T,!0),document.removeEventListener("keydown",T,!0),window.removeEventListener(Tn,J)}},[]);const Z=a?B:t;return e.jsxs(e.Fragment,{children:[e.jsx(b,{ref:T=>{p.current=T},className:c,style:f,onMouseEnter:T=>{z(),Y(),s?E(T.clientX,T.clientY):k()},onMouseMove:T=>{g&&s&&E(T.clientX,T.clientY)},onMouseDown:_,onClick:_,onMouseLeave:()=>{Y(),H()},onFocus:k,onBlur:q,children:r}),g&&Z&&!Ht(p.current)?Je.createPortal(e.jsxs("div",{ref:y,role:"tooltip",className:u,onMouseEnter:n?z:void 0,onMouseLeave:n?H:void 0,style:{position:"fixed",top:g.y,left:g.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:n?"auto":"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere",...m},children:[i&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",width:12,height:12,background:(m==null?void 0:m.background)??"var(--bg-card)",borderLeft:l==="right"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderTop:l==="bottom"||l==="right"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderRight:l==="left"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderBottom:l==="top"||l==="left"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,transform:"rotate(45deg)",left:g.arrowX===void 0?void 0:g.arrowX-6,top:g.arrowY===void 0?void 0:g.arrowY-6,zIndex:-1}}),Z]}),document.body):null]})}function Ln(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}const Ps="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",Fs={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"},zs="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",_s={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"},js={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},Ws={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function Aa(r){return typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(Aa).join(" ").trim():o.isValidElement(r)?Aa(r.props.children):""}function qs(r){return o.Children.toArray(r).find(o.isValidElement)??null}function He({variant:r="primary",size:t="md",loading:a=!1,icon:n,tooltip:s,iconOnly:l,height:i,padding:c,children:u,className:f="",disabled:m,style:b,...p}){const y=o.useContext(En),N=l??y.iconOnly??r==="icon",M=y.compact??!1,g=y.headerAction??!1,C=g&&t==="md"?"sm":M&&!g&&t==="md"?"xs":t,B=r==="icon"||N,A=g&&B,z=Aa(u),E=s??p.title??p["aria-label"]??(N?z:void 0),k=E?void 0:p.title,q=p["aria-label"]??(typeof E=="string"?E:z||void 0),H=a?null:n??(N?qs(u):null),_=e.jsxs("button",{...p,title:k,"aria-label":q,"data-variant":r,"data-size":C,"data-icon":B?"true":void 0,disabled:m||a,className:`${Ps} ${A?zs:Fs[r]} ${B?js[C]:_s[C]} ${M&&!B?"px-2.5":""} ${f}`,style:{...Ws[r],height:Ln(i),padding:Ln(c),...b,...g&&!B?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...A?{width:"var(--page-header-control-height, 40px)",height:"var(--page-header-control-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"}):H,!N&&u]});return E?e.jsx(jr,{as:"span",content:E,className:"inline-flex shrink-0",children:_}):_}const Ve={background:"color-mix(in srgb, var(--text-muted) 26%, var(--bg-input))"};function Pt({rows:r=8,columns:t=7,showToolbar:a=!0,showPagination:n=!0,compact:s=!1,className:l=""}){const i=Math.max(3,Math.min(t,12)),c=Math.max(3,Math.min(r,20)),u=s?"px-2 py-2":"px-3 py-2.5",f=s?"px-2 py-2":"px-3 py-3";return e.jsxs("div",{className:`w-full min-w-0 overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${l}`,"aria-busy":"true","aria-label":"Cargando tabla",children:[a&&e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-3 py-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx("div",{className:"h-7 w-14 shrink-0 animate-pulse rounded-md",style:Ve}),e.jsx("div",{className:"h-7 max-w-md flex-1 animate-pulse rounded-md",style:Ve})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:Ve}),e.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:Ve})]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("div",{className:"min-w-full",style:{display:"grid",gridTemplateColumns:`repeat(${i}, minmax(96px, 1fr))`},children:[Array.from({length:i}).map((m,b)=>e.jsx("div",{className:`${f} border-b border-[var(--border)]`,style:{background:"color-mix(in srgb, var(--bg-input) 55%, transparent)"},children:e.jsx("div",{className:"h-3 animate-pulse rounded-md",style:{...Ve,width:`${48+b*17%40}%`}})},`h-${b}`)),Array.from({length:c}).map((m,b)=>Array.from({length:i}).map((p,y)=>e.jsx("div",{className:`${u} ${b<c-1?"border-b border-[var(--border)]":""}`,children:e.jsx("div",{className:"h-3.5 animate-pulse rounded-md",style:{...Ve,width:`${46+(b*13+y*11)%42}%`,minWidth:28}})},`c-${b}-${y}`)))]})}),n&&e.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-[var(--border)] px-3 py-2",style:{background:"color-mix(in srgb, var(--bg-input) 40%, transparent)"},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-28 animate-pulse rounded-md",style:Ve}),e.jsx("div",{className:"h-7 w-14 animate-pulse rounded-md",style:Ve})]}),e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:4}).map((m,b)=>e.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:Ve},b))}),e.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:Ve})]})]})}function $n({variant:r="page",title:t="Cargando...",rows:a=6,columns:n=7,children:s}){return r==="table"?e.jsx(Pt,{rows:a,columns:n}):r==="sections"?e.jsx(Us,{rows:a}):r==="cards"?e.jsx(Vs,{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}),s&&e.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:s})]})]})})}function Us({rows:r}){return e.jsx(Pt,{rows:r,columns:7})}function Vs({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-md",style:Ve}),e.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded-md",style:Ve}),e.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded-md",style:Ve})]},a))})}function An(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 Dn(r){return r.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function Gs(r){return[r.label,An(r.service),r.description,r.service].filter(Boolean).join(" ")}function Ks(r){return typeof r=="function"?r:r.default}function Xs(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(He,{className:"mt-4",height:36,padding:"0 14px",onClick:t,children:"Reintentar"})]})})}function Ys({parentPanel:r,parentPanelComponent:t,renderParentPanel:a,parent:n,context:s,links:l,moduleRegistry:i,loadModule:c,activeService:u,initialService:f,onActiveServiceChange:m,canAccess:b,keepAlive:p=!0,title:y,subtitle:N,emptyState:M,loadingState:g,errorState:C=Xs,renderTabLabel:B,searchableTabs:A="auto",tabsSearchThreshold:z=6,tabsSearchPlaceholder:E="Buscar modulo...",tabsSearchValue:k,onTabsSearchChange:q,emptySearchState:H,showTabCount:_=!0,className:Y="",parentClassName:Z="",contentClassName:T="",tabsClassName:J=""}){var lr;const O=o.useMemo(()=>l.filter(de=>!de.hidden&&((b==null?void 0:b(de,s))??!0)),[b,s,l]),j=(lr=O.find(de=>!de.disabled))==null?void 0:lr.service,[te,X]=o.useState(f??j??""),[I,ee]=o.useState({}),[R,x]=o.useState({}),[S,K]=o.useState(""),[Q,ae]=o.useState(!1),ce=o.useRef(R),ve=o.useRef(0),re=k??S,G=Dn(re),h=A===!0||A==="auto"&&O.length>=z,L=h&&re.trim().length>0,W=o.useMemo(()=>G?O.filter(de=>Dn(Gs(de)).includes(G)):O,[G,O]),ne=u??te,oe=O.find(de=>de.service===ne)??O.find(de=>!de.disabled);o.useEffect(()=>{!oe&&j&&X(j)},[j,oe]),o.useEffect(()=>{ce.current=R},[R]);const he=de=>{de.disabled||(u||X(de.service),m==null||m(de.service,de))},_e=de=>{k===void 0&&K(de),q==null||q(de)},Ge=(de,D)=>{const U=W.filter(ue=>!ue.disabled),le=U.findIndex(ue=>ue.service===D.service);le<0||((de.key==="ArrowRight"||de.key==="ArrowDown")&&(de.preventDefault(),he(U[(le+1)%U.length])),(de.key==="ArrowLeft"||de.key==="ArrowUp")&&(de.preventDefault(),he(U[(le-1+U.length)%U.length])),de.key==="Home"&&(de.preventDefault(),he(U[0])),de.key==="End"&&(de.preventDefault(),he(U[U.length-1])))},xe=o.useCallback(()=>{if(!oe)return;const de=oe.service,D=ce.current[de];if(D!=null&&D.loading||D!=null&&D.component&&p)return;const U=(i==null?void 0:i[de])??c;if(!U){x(ue=>({...ue,[de]:{loading:!1,error:new Error(`No module loader found for service "${de}".`)}}));return}const le=++ve.current;x(ue=>({...ue,[de]:{...ue[de],loading:!0,error:void 0}})),U(oe,s).then(ue=>{if(le!==ve.current&&!p)return;const Le=Ks(ue);x(ke=>({...ke,[de]:{component:Le,loading:!1}}))}).catch(ue=>{const Le=ue instanceof Error?ue:new Error(String(ue));x(ke=>({...ke,[de]:{...ke[de],loading:!1,error:Le}}))})},[s,p,c,i,oe]);o.useEffect(xe,[xe]);const Ee=oe?I[oe.service]??null:null,Ae=oe?R[oe.service]:void 0,wr=Ae==null?void 0:Ae.component,br=de=>{oe&&ee(D=>({...D,[oe.service]:de}))},We=()=>{oe&&ee(de=>({...de,[oe.service]:null}))},se={context:s,parent:n,links:l,visibleLinks:O,filteredLinks:W,selectedLink:oe,selectedService:oe==null?void 0:oe.service,activeItemId:Ee,tabsSearch:re,onSelectService:he,onOpenDetail:br,onBackToList:We},Ze=a?a(se):t?e.jsx(t,{...se}):r;return e.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${Y}`,children:[e.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${Z}`,children:Ze}),e.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${T}`,children:[(y||N||h||_)&&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:[y&&e.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:y}),N&&e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:N})]}),(h||_)&&e.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[_&&e.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[W.length," / ",O.length]}),h&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${Q?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!Q,children:e.jsx(Cn,{value:re,onChange:_e,placeholder:E,className:"w-full",autoFocus:Q,forceExpanded:!0,onEscape:()=>ae(!1),size:"sm",inputTabIndex:Q?0:-1})}),e.jsx("button",{type:"button","aria-label":Q?"Cerrar busqueda":"Buscar tabs","aria-expanded":Q,onClick:()=>{Q&&re&&_e(""),ae(de=>!de)},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 ${Q||L?"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:Q||L?e.jsx($.HiXMark,{className:"h-4 w-4"}):e.jsx($.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),e.jsx("div",{role:"tablist","aria-label":y??"Modulos relacionados",className:`flex gap-1 overflow-x-auto border-b border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 transition-colors duration-200 ${J}`,children:W.length>0?W.map(de=>{const D=de.service===(oe==null?void 0:oe.service);return e.jsx("button",{type:"button",role:"tab","aria-selected":D,disabled:de.disabled,onClick:()=>he(de),onKeyDown:U=>Ge(U,de),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 ${D?"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:B?B(de,D):e.jsxs(e.Fragment,{children:[de.icon,e.jsx("span",{children:de.label??An(de.service)}),de.badge&&e.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:de.badge})]})},de.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:H??"No hay modulos que coincidan con la busqueda."})}),(oe==null?void 0:oe.description)&&e.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:oe.description}),e.jsxs("div",{className:"min-h-[420px] p-4",children:[!oe&&(M??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."})),oe&&(Ae==null?void 0:Ae.loading)&&(g??e.jsx($n,{title:"Cargando modulo..."})),oe&&(Ae==null?void 0:Ae.error)&&C(Ae.error,xe),oe&&wr&&!(Ae!=null&&Ae.loading)&&!(Ae!=null&&Ae.error)&&e.jsx(wr,{context:s,parent:n,link:oe,activeItemId:Ee,onOpenDetail:br,onBackToList:We})]})]})]})}const Zs={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:e.jsx($.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($.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($.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($.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:e.jsx($.HiInformationCircle,{className:"h-5 w-5"})}};function Qs({variant:r="info",title:t,children:a,icon:n,action:s,onDismiss:l,className:i=""}){const c=Zs[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}),s&&e.jsx("div",{className:"mt-3",children:s})]}),l&&e.jsx(He,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:e.jsx($.HiXMark,{className:"h-4 w-4"})})]})}const In=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],Js=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],Rs=["Do","Lu","Ma","Mi","Ju","Vi","Sá"],Da=6;function Ia(r,t,a){return`${r}-${String(t).padStart(2,"0")}-${String(a).padStart(2,"0")}`}function el(){const r=new Date;return Ia(r.getFullYear(),r.getMonth()+1,r.getDate())}function Bn(r){const[t,a,n]=r.split("-").map(Number);return{year:t,month:a,day:n}}function rl(r){if(!r)return"Seleccionar fecha";const{year:t,month:a,day:n}=Bn(r);return!t||!a||!n?"Seleccionar fecha":`${String(n).padStart(2,"0")} ${In[a-1]} ${t}`}function tl({value:r,onChange:t,minDate:a,displayMode:n="inline"}){const s=el(),i=Bn(r||s),c=n==="popover",[u,f]=o.useState(!1),m=o.useRef(null),[b,p]=o.useState({horizontal:"left",vertical:"bottom"}),[y,N]=o.useState(i.year),[M,g]=o.useState(i.month),[C,B]=o.useState("days"),A=16,[z,E]=o.useState(0),k=y-7+z,q=Array.from({length:A},(X,I)=>k+I);o.useEffect(()=>{if(!c||!u||!m.current)return;const X=m.current.getBoundingClientRect(),I=8,ee=280,R=340,x=X.left+ee>window.innerWidth-I,S=X.right-ee>=I,K=X.bottom+8+R>window.innerHeight-I,Q=X.top-8-R>=I;p({horizontal:x&&S?"right":"left",vertical:K&&Q?"top":"bottom"})},[c,u]),o.useEffect(()=>{if(!c||!u)return;function X(ee){m.current&&(m.current.contains(ee.target)||f(!1))}function I(ee){ee.key==="Escape"&&f(!1)}return document.addEventListener("mousedown",X),document.addEventListener("keydown",I),()=>{document.removeEventListener("mousedown",X),document.removeEventListener("keydown",I)}},[c,u]);function H(){M===1?(N(X=>X-1),g(12)):g(X=>X-1)}function _(){M===12?(N(X=>X+1),g(1)):g(X=>X+1)}const Y=new Date(y,M-1,1).getDay(),Z=new Date(y,M,0).getDate(),T=[...Array(Y).fill(null),...Array.from({length:Z},(X,I)=>I+1)];for(;T.length<Da*7;)T.push(null);const J=T.slice(0,Da*7);function O(X){const I=Ia(y,M,X);a&&I<a||(t(I),c&&f(!1))}const j={background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,borderRadius:6,display:"flex",alignItems:"center"},te=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:C==="days"?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:H,style:j,title:"Mes anterior",children:e.jsx($.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>{B("years"),E(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:[In[M-1]," ",y,e.jsx($.HiChevronDown,{size:13,style:{color:"var(--text-muted)"}})]}),e.jsx("button",{type:"button",onClick:_,style:j,title:"Mes siguiente",children:e.jsx($.HiChevronRight,{size:16})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>E(X=>X-A),style:j,children:e.jsx($.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>B("days"),style:{background:"none",border:"none",cursor:"pointer",fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[q[0]," – ",q[q.length-1]]}),e.jsx("button",{type:"button",onClick:()=>E(X=>X+A),style:j,children:e.jsx($.HiChevronRight,{size:16})})]})}),C==="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:Js.map((X,I)=>{const ee=I+1===M;return e.jsx("button",{type:"button",onClick:()=>g(I+1),style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:11,fontWeight:ee?700:400,padding:"4px 0",background:ee?"var(--primary)":"transparent",color:ee?"var(--primary-fg, #ffffff)":"var(--text-secondary)"},children:X},X)})}),e.jsx("div",{style:{height:1,background:"var(--border)",marginBottom:8}}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3},children:q.map(X=>{const I=X===y;return e.jsx("button",{type:"button",onClick:()=>{N(X),B("days")},style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:12,fontWeight:I?700:400,padding:"6px 0",background:I?"var(--primary)":"transparent",color:I?"var(--primary-fg, #ffffff)":"var(--text-main)",outline:X===new Date().getFullYear()&&!I?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:X},X)})})]}),C==="days"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",padding:"6px 8px 0"},children:Rs.map(X=>e.jsx("div",{style:{textAlign:"center",fontSize:10,fontWeight:700,color:"var(--text-muted)",padding:"2px 0",textTransform:"uppercase"},children:X},X))}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",gridTemplateRows:`repeat(${Da},1fr)`,padding:"4px 8px 10px",gap:2},children:J.map((X,I)=>{if(X===null)return e.jsx("div",{style:{aspectRatio:"1"}},I);const ee=Ia(y,M,X),R=ee===r,x=ee===s,S=!!(a&&ee<a);return e.jsx("button",{type:"button",onClick:()=>!S&&O(X),style:{width:"100%",aspectRatio:"1",borderRadius:6,border:"none",cursor:S?"not-allowed":"pointer",fontSize:12,fontWeight:R||x?700:400,background:R?"var(--primary)":"transparent",color:R?"var(--primary-fg, #ffffff)":S?"var(--text-muted)":"var(--text-main)",opacity:S?.4:1,outline:x&&!R?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:X},I)})})]})]});return c?e.jsxs("div",{ref:m,className:"relative w-full",children:[e.jsxs("button",{type:"button",onClick:()=>f(X=>!X),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 ${u?"var(--primary)":"var(--border)"}`,color:"var(--text-main)",boxShadow:u?"0 0 0 3px rgba(59,130,246,0.12)":"none"},children:[e.jsxs("span",{className:"inline-flex items-center gap-2 min-w-0",children:[e.jsx($.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),e.jsx("span",{className:"truncate",children:rl(r)})]}),e.jsx($.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${u?"rotate-180":""}`})]}),u&&e.jsx("div",{className:"absolute z-50",style:{...b.horizontal==="left"?{left:0}:{right:0},...b.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:te})]}):te}const al={sm:"h-4 w-4",md:"h-5 w-5"};function nl(r,t){if(typeof r=="function"){r(t);return}r&&(r.current=t)}const Ft=o.forwardRef(function({label:t,description:a,error:n,size:s="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:u,...f},m){const b=o.useRef(null);return o.useEffect(()=>{b.current&&(b.current.indeterminate=l)},[l]),e.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${u?"cursor-not-allowed opacity-60":"cursor-pointer"} ${c}`,children:[e.jsxs("span",{className:"relative mt-0.5 inline-flex shrink-0",children:[e.jsx("input",{...f,ref:p=>{b.current=p,nl(m,p)},type:"checkbox",disabled:u,"aria-checked":l?"mixed":f["aria-checked"],"aria-invalid":!!n||f["aria-invalid"],className:`peer ${al[s]} 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 ${i}`}),e.jsx($.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 peer-aria-checked:mixed:scale-100 peer-aria-checked:mixed:opacity-100"})]}),(t||a||n)&&e.jsxs("span",{className:"min-w-0",children:[t&&e.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:t}),a&&!n&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:a}),n&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--danger)]",children:n})]})]})});function On(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 ol(r){var t;if((t=navigator.clipboard)!=null&&t.writeText){await navigator.clipboard.writeText(r);return}On(r)}function sl(r){return typeof r=="function"?r():r}function Ba({value:r,resetDelay:t=2e3,title:a,copiedTitle:n="Copiado",copiedLabel:s,icon:l=e.jsx($.HiClipboardDocument,{size:14}),copiedIcon:i=e.jsx($.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:u,onCopyError:f,className:m="",style:b,children:p,onClick:y,type:N="button",...M}){const[g,C]=o.useState(!1),B=o.useRef(null);o.useEffect(()=>()=>{B.current&&window.clearTimeout(B.current)},[]);function A(E){C(!0),u==null||u(E),B.current&&window.clearTimeout(B.current),B.current=window.setTimeout(()=>{C(!1),B.current=null},t)}async function z(E){var q;if(c&&E.stopPropagation(),y==null||y(E),E.defaultPrevented)return;const k=sl(r);if(k)try{await ol(k),A(k)}catch(H){try{On(k),A(k)}catch(_){f==null||f(_,k);return}(q=navigator.clipboard)!=null&&q.writeText||f==null||f(H,k)}}return e.jsxs("button",{...M,type:N,onClick:z,title:g?n:a,"aria-label":M["aria-label"]??(g?n:a),"data-copied":g?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${p?"min-w-7 px-2":"w-7"} ${m}`,style:{cursor:"pointer",background:g?"rgba(22,163,74,0.15)":"var(--bg-card)",border:g?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:g?"#16a34a":"var(--text-secondary)",boxShadow:g?"0 0 0 3px rgba(22,163,74,0.12)":"none",...b},children:[e.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:g?"scale(1.15)":"scale(1)"},children:g?i:l}),p&&e.jsx("span",{className:"text-xs font-semibold leading-none",children:g?s??p:p})]})}function ll({code:r,children:t,title:a="Codigo",language:n,copyLabel:s="Copiar",copiedLabel:l="Copiado",className:i="",style:c,onCopied:u}){const f=(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(Ba,{value:f,title:"Copiar codigo",copiedTitle:"Codigo copiado",copiedLabel:l,onCopied:u,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:f})})]})}function Oa(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Ha(r){return r.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function il(r,t){if(!t.trim())return!0;const a=Ha(t);return Ha(r.label).includes(a)||!!(r.sublabel&&Ha(r.sublabel).includes(a))}function Er({value:r,onChange:t,options:a,status:n="default",ariaLabel:s,triggerVariant:l="default",showSelectedSublabel:i=!0,placeholder:c="Seleccionar…",emptyLabel:u,disabled:f=!1,className:m="",style:b,dropdownMinWidth:p,height:y=40,padding:N="0 10px",searchable:M=!0,minOptionsForSearch:g=6}){const[C,B]=o.useState(!1),[A,z]=o.useState(""),[E,k]=o.useState(-1),[q,H]=o.useState(!1),[_,Y]=o.useState({}),Z=o.useRef(null),T=o.useRef(null),J=o.useRef(null),O=o.useRef(null),j=M&&a.length>=g,te=a.find(re=>re.value===r)??null,X=l==="ghost",I=n==="error"?"var(--danger)":C?"var(--primary)":"var(--border)",ee=j&&A.trim()?a.filter(re=>il(re,A)):a,R=o.useCallback(()=>{const re=Z.current;if(!re)return;const G=re.getBoundingClientRect(),h=j?272:212,L=window.innerHeight-G.bottom,W=L<h&&G.top>L;Y({position:"fixed",left:G.left,top:W?void 0:G.bottom+4,bottom:W?window.innerHeight-G.top+4:void 0,width:G.width,minWidth:Oa(p),zIndex:9999})},[p,j]);o.useEffect(()=>H(!0),[]),o.useEffect(()=>{if(!C)return;function re(G){var L,W;const h=G.target;!((L=Z.current)!=null&&L.contains(h))&&!((W=T.current)!=null&&W.contains(h))&&(B(!1),z(""))}return document.addEventListener("mousedown",re),()=>document.removeEventListener("mousedown",re)},[C]),o.useEffect(()=>{C&&(k(-1),R(),j&&setTimeout(()=>{var re;return(re=J.current)==null?void 0:re.focus()},0))},[C,j,R]),o.useEffect(()=>{if(C)return window.addEventListener("resize",R),window.addEventListener("scroll",R,!0),()=>{window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[C,R]),o.useEffect(()=>{if(E<0||!O.current)return;const re=O.current.children[E];re==null||re.scrollIntoView({block:"nearest"})},[E]);const x=o.useCallback(re=>{t(re),B(!1),z("")},[t]),S=o.useRef(C);S.current=C;const K=o.useRef(ee);K.current=ee;const Q=o.useRef(E);Q.current=E;const ae=o.useRef(u);ae.current=u;const ce=o.useRef(x);ce.current=x,o.useEffect(()=>{function re(G){var ne,oe;const h=document.activeElement,L=((ne=Z.current)==null?void 0:ne.contains(h))??!1,W=((oe=T.current)==null?void 0:oe.contains(h))??!1;if(!(!L&&!W)){if(!S.current){(G.key==="Enter"||G.key===" "||G.key==="ArrowDown")&&(G.preventDefault(),B(!0));return}switch(G.key){case"ArrowDown":G.preventDefault(),k(he=>Math.min(he+1,K.current.length-1));break;case"ArrowUp":G.preventDefault(),k(he=>Math.max(he-1,ae.current?-1:0));break;case"Enter":{G.preventDefault();const he=Q.current,_e=K.current;he===-1&&ae.current?ce.current(""):_e[he]&&!_e[he].disabled&&ce.current(_e[he].value);break}case"Escape":G.preventDefault(),G.stopPropagation(),B(!1),z("");break}}}return document.addEventListener("keydown",re),()=>document.removeEventListener("keydown",re)},[]);const ve=e.jsxs("div",{ref:T,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{..._,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[j&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx($.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:J,value:A,onChange:re=>{z(re.target.value),k(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),A&&e.jsx("button",{type:"button",onMouseDown:re=>{re.preventDefault(),z("")},children:e.jsx($.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),e.jsxs("ul",{ref:O,role:"listbox",className:"overflow-y-auto",style:{maxHeight:j?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[u&&e.jsx("li",{role:"option","aria-selected":r==="",onMouseDown:re=>{re.preventDefault(),x("")},onMouseEnter:()=>k(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:E===-1&&!A.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:u}),ee.map((re,G)=>{const L=G===E,W=re.value===r;return e.jsxs("li",{role:"option","aria-selected":W,onMouseDown:ne=>{ne.preventDefault(),re.disabled||x(re.value)},onMouseEnter:()=>!re.disabled&&k(G),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:L?"var(--bg-hover)":W?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:re.disabled?"var(--text-muted)":"var(--text-main)",cursor:re.disabled?"not-allowed":"pointer",boxShadow:W?"inset 2px 0 0 var(--primary)":void 0},children:[re.color&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:re.color}}),e.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:re.label}),re.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:re.sublabel})]}),re.badge&&e.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:re.badge})]},re.value)}),ee.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:Z,className:`relative ${m||"w-full"}`,style:b,children:[e.jsxs("button",{type:"button",disabled:f,onClick:()=>!f&&B(re=>!re),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:Oa(y),padding:Oa(N),background:X?"transparent":"var(--bg-input)",color:te?"var(--text-main)":"var(--text-muted)",border:X?"1px solid transparent":`1px solid ${I}`,opacity:f?.5:1,cursor:f?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":C,"aria-label":s,children:[(te==null?void 0:te.color)&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:te.color}}),e.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:te?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"truncate",children:te.label}),i&&te.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:te.sublabel})]}):e.jsx("span",{className:"truncate",children:c})}),te&&u?e.jsx("span",{role:"button",tabIndex:-1,onMouseDown:re=>{re.preventDefault(),re.stopPropagation(),x("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx($.HiXMark,{className:"w-3 h-3"})}):e.jsx($.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:C?"rotate(180deg)":"rotate(0deg)"}})]}),C&&q&&Je.createPortal(ve,document.body)]})}function zt(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function cl({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($.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:zt(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:zt(s),padding:zt(l)}})]})}function dl({value:r,onChange:t,options:a,placeholder:n,icon:s,className:l="",height:i=40,padding:c,iconLeft:u=10,searchable:f=!0}){const m=s?a.map((b,p)=>p===0&&!b.color?{...b,sublabel:b.sublabel??void 0}:b):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:zt(u)},children:s}),e.jsx(Er,{value:r,onChange:t,options:m,placeholder:n,searchable:f,minOptionsForSearch:5,height:i,padding:c??(s?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const ul={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},_t=180,fl="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Pa({open:r,onClose:t,title:a,subtitle:n,leadingIcon:s,headerActions:l,footer:i,children:c,size:u="md",maxWidth:f,zIndex:m=1e3,closeOnBackdrop:b=!0,closeOnEscape:p=!0,showCloseButton:y=!0,placement:N="center",bodyClassName:M="px-6 py-5",panelClassName:g="",backdropClassName:C=fl,contentClassName:B="p-4",ariaLabel:A,frameless:z=!1,disabled:E=!1}){const[k,q]=o.useState(!1),[H,_]=o.useState(!1),Y=o.useRef(null);if(o.useEffect(()=>(r?(Y.current&&clearTimeout(Y.current),q(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>_(!0)))):(_(!1),Y.current=setTimeout(()=>q(!1),_t+40)),()=>{Y.current&&clearTimeout(Y.current)}),[r]),o.useEffect(()=>{if(r)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[r]),o.useEffect(()=>{if(!r||!p)return;const te=X=>{X.key==="Escape"&&t()};return window.addEventListener("keydown",te),()=>window.removeEventListener("keydown",te)},[p,t,r]),!k)return null;const Z=a||n||s||l||y,T=f??ul[u],J=N==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",O=N==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",j=H?"translateY(0) scale(1)":N==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return Je.createPortal(e.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":A??a,className:`fixed inset-0 flex ${J} ${B}`,style:{zIndex:m},children:[e.jsx("div",{className:`absolute inset-0 ${C}`,onClick:b?t:void 0,style:{opacity:H?1:0,transition:`opacity ${_t}ms ease`}}),e.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${z?"shadow-none":"shadow-2xl"} ${O} ${g}`,style:{maxWidth:T,background:z?"transparent":"var(--bg-card)",border:z?"none":"1px solid var(--border)",opacity:H?1:0,transform:j,transition:`opacity ${_t}ms ease, transform ${_t}ms ease`},onClick:te=>te.stopPropagation(),children:[E&&e.jsx("div",{className:"absolute inset-0 z-[1002] cursor-not-allowed rounded-2xl",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 60%, transparent)",backdropFilter:"blur(2px)"}}),Z&&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,y&&e.jsx(He,{variant:"icon",onClick:t,title:"Cerrar",children:e.jsx($.HiXMark,{className:"h-5 w-5"})})]})]}),e.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${M}`,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 bl={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 pl({open:r,title:t,description:a,confirmLabel:n="Confirmar",cancelLabel:s="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:u}){const f=bl[l];return e.jsx(Pa,{open:r,onClose:u,size:"md",zIndex:9998,showCloseButton:!1,bodyClassName:"p-0",panelClassName:"overflow-visible",ariaLabel:t,closeOnBackdrop:i,children:e.jsxs("div",{className:"relative px-6 pb-6 pt-6",children:[e.jsx(He,{variant:"icon",onClick:u,className:"absolute right-3 top-3 h-8 w-8 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:e.jsx($.HiXMark,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex gap-3 pr-8",children:[e.jsx("div",{className:"mt-0.5 flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl",style:{background:f.iconBg},children:e.jsx($.HiExclamationTriangle,{className:"h-5 w-5",style:{color:f.iconColor}})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-base font-semibold leading-snug",style:{color:"var(--text-main)"},children:t}),a?e.jsx("div",{className:"mt-1.5 text-sm leading-relaxed",style:{color:"var(--text-muted)"},children:a}):null]})]}),e.jsxs("div",{className:"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e.jsx(He,{variant:"secondary",onClick:u,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:s}),e.jsx(He,{variant:"danger",onClick:c,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:f.btnBg,color:f.btnColor,borderColor:"transparent"},children:n})]})]})})}function ml(r){return r?typeof r=="function"?r():r:""}function hl(r){return/^https?:\/\//i.test(r)}function Hn(r,t){try{return new URL(r,t).toString()}catch{return r}}function gl(r,t,a,n=!1){const s=typeof r=="function"?r():r,l=t?t(s):s;if(!l||hl(l))return l;const i=ml(a);return i?Hn(l,i):n&&typeof window<"u"?Hn(l,window.location.origin):l}function vl({url:r,resolveUrl:t,baseUrl:a,useWindowOriginForRelative:n=!1,title:s="Copiar link",copiedTitle:l="Link copiado",icon:i=e.jsx($.HiLink,{className:"h-3.5 w-3.5"}),...c}){return e.jsx(Ba,{...c,value:()=>gl(r,t,a,n),title:s,copiedTitle:l,icon:i})}const jt=[25,50,100,200,500];let Re={dataTable:{pageSizeOptions:[...jt]}};function xl(){if(typeof window>"u")return;const t=window.__BONSAIF_DATA_TABLE_PREFERENCES_ENDPOINT__;return typeof t=="string"&&t.trim().length>0?t.trim().replace(/\/+$/,""):void 0}function Fa(){const r=Re.dataTable.preferencesEndpoint,t=xl();return r&&r.trim().length>0?r.trim().replace(/\/+$/,""):t}function yl(r){if(!Array.isArray(r))return[...jt];const t=Array.from(new Set(r.map(a=>typeof a=="number"?Math.floor(a):Number.NaN).filter(a=>Number.isFinite(a)&&a>0)));return t.length>0?t:[...jt]}function Pn(r){if(typeof r!="string")return;const t=r.trim();if(t)return t.replace(/\/+$/,"")}function wl(r){if(!r||typeof r!="object"||!r.dataTable)return;const t=Pn(r.dataTable.preferencesEndpoint);Re={...Re,dataTable:{...Re.dataTable,pageSizeOptions:yl(r.dataTable.pageSizeOptions),preferencesEndpoint:t??Re.dataTable.preferencesEndpoint}}}function Nl(){return{dataTable:{pageSizeOptions:[...Re.dataTable.pageSizeOptions]}}}function ft(){return[...Re.dataTable.pageSizeOptions]}function kl(){Re={dataTable:{pageSizeOptions:[...jt]}}}function Sl(r){Re={...Re,dataTable:{...Re.dataTable,preferencesEndpoint:Pn(r)}}}const Wt=[{value:"equals",label:"Igual a",valueMode:"single"},{value:"notEquals",label:"No es igual a",valueMode:"single"},{value:"greaterThan",label:"Mayor que",valueMode:"single"},{value:"greaterThanOrEqual",label:"Mayor o igual que",valueMode:"single"},{value:"lessThan",label:"Menor que",valueMode:"single"},{value:"lessThanOrEqual",label:"Menor o igual que",valueMode:"single"},{value:"between",label:"Entre",valueMode:"between"},{value:"top10",label:"10 superiores",valueMode:"none"},{value:"bottom10",label:"10 inferiores",valueMode:"none"},{value:"aboveAverage",label:"Sobre promedio",valueMode:"none"},{value:"belowAverage",label:"Bajo promedio",valueMode:"none"}],Cl=Wt.map(r=>({value:r.value,label:r.label})),El=12,Ml={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},Fn={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},Tl="bonsaif-ui:datatable:",Ll="[&_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",$l=[],Al=52;function gr(r){if(!r)return 150;const t=parseInt(r,10);return isNaN(t)||t<=0?150:t}function zn(r){return!!(r&&(Array.isArray(r.columnOrder)&&r.columnOrder.length>0||r.columnWidths&&Object.keys(r.columnWidths).length>0||Array.isArray(r.hiddenColumnKeys)&&r.hiddenColumnKeys.length>0||r.filters&&Object.keys(r.filters).length>0||r.conditionFilters&&Object.keys(r.conditionFilters).length>0||r.sort||typeof r.bql=="string"||Array.isArray(r.bqlHistory)&&r.bqlHistory.length>0||typeof r.pageSize=="number"))}function _n(r){return`${Tl}${r}`}function qt(r){try{const t=window.localStorage.getItem(_n(r));if(!t)return null;const a=JSON.parse(t);return a&&typeof a=="object"?a:null}catch{return null}}function Dl(r,t){try{window.localStorage.setItem(_n(r),JSON.stringify(t))}catch{}}function Il(r,t){if(r===!0)return{...Fn};if(r===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(t&&r==null)return{...Fn};const a={...Ml,...r??{}};return t&&(typeof r!="object"||r.pagination!==!1)&&(a.pagination=!0),a}function jn(...r){return r.reduce((t,a)=>({...t,...a??{}}),{})}function za(r,t,a){return typeof r!="number"||r<=0?a:gt(t).includes(r)?r:a}function bt(r){if(!r||typeof r!="object")return!1;const t=r;return typeof t.key=="string"&&(t.dir==="asc"||t.dir==="desc")}function pt(r,t){if(!r||typeof r!="object"||Array.isArray(r))return{};const a=Object.entries(r).flatMap(([n,s])=>{if(!t.has(n)||!Array.isArray(s))return[];const l=s.filter(i=>typeof i=="string");return l.length>0?[[n,l]]:[]});return Object.fromEntries(a)}function mt(r,t){if(!r||typeof r!="object"||Array.isArray(r))return{};const a=new Set(Wt.map(s=>s.value)),n=Object.entries(r).flatMap(([s,l])=>{if(!t.has(s)||!l||typeof l!="object")return[];const i=l;return!i.operator||!a.has(i.operator)?[]:[[s,{operator:i.operator,value:typeof i.value=="string"?i.value:"",valueTo:typeof i.valueTo=="string"?i.valueTo:""}]]});return Object.fromEntries(n)}function er(r,t){if(Mr(r))return Al;const a=r.minWidth??80,n=r.maxWidth??1/0;return Math.min(n,Math.max(a,t))}function Bl(r){const t=window.getComputedStyle(r);return parseFloat(t.paddingLeft)+parseFloat(t.paddingRight)}function Mr(r){return r.key==="actions"||r.key==="acciones"?!0:typeof r.header=="string"&&r.header.trim().toLowerCase()==="acciones"}function Ol(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 vr(r,t){var i;const a=new Set(t.filter(c=>c.hideable!==!1).map(c=>c.key)),n=Array.from(new Set(r??[])).filter(c=>a.has(c));if(t.filter(c=>!n.includes(c.key)).length>0)return n;const l=(i=t.find(c=>c.hideable!==!1))==null?void 0:i.key;return l?n.filter(c=>c!==l):[]}function Hl(r){return r==null||r===""?"(Vacio)":r instanceof Date?r.toLocaleDateString():String(r)}function Wr(r){return r==null||typeof r=="boolean"?"":typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(Wr).join(" ").trim():o.isValidElement(r)?Wr(r.props.children):""}function Ut(r,t){const a=r.filterValue?r.filterValue(t):r.sortKey?t[r.sortKey]:r.cell(t);return typeof a=="string"||typeof a=="number"||typeof a=="boolean"||a===null||a===void 0||a instanceof Date?Hl(a):Wr(a).trim()}function ht(r){const t=r.replace(/,/g,"").trim();if(!t)return null;const a=Number(t);return Number.isFinite(a)?a:null}function qr(r,t){const a=ht(r),n=ht(t);return a!==null&&n!==null?a-n:r.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function gt(r){const t=Array.from(new Set(r.map(a=>Math.floor(a)).filter(a=>Number.isFinite(a)&&a>0)));return t.length>0?t:ft()}function Pl(r,t,a){var i,c;const n=((i=t.value)==null?void 0:i.trim())??"",s=((c=t.valueTo)==null?void 0:c.trim())??"",l=Wt.find(u=>u.value===t.operator);if((l==null?void 0:l.valueMode)==="single"&&!n||(l==null?void 0:l.valueMode)==="between"&&(!n||!s))return!0;switch(t.operator){case"equals":return r.toLowerCase()===n.toLowerCase();case"notEquals":return r.toLowerCase()!==n.toLowerCase();case"greaterThan":return qr(r,n)>0;case"greaterThanOrEqual":return qr(r,n)>=0;case"lessThan":return qr(r,n)<0;case"lessThanOrEqual":return qr(r,n)<=0;case"between":return qr(r,n)>=0&&qr(r,s)<=0;case"top10":case"bottom10":{const f=a.map(b=>({value:b,number:ht(b)})).filter(b=>b.number!==null).sort((b,p)=>b.number-p.number).map(b=>b.value);return(t.operator==="top10"?f.slice(-10):f.slice(0,10)).includes(r)}case"aboveAverage":case"belowAverage":{const u=a.map(ht).filter(b=>b!==null);if(u.length===0)return!1;const f=u.reduce((b,p)=>b+p,0)/u.length,m=ht(r);return m===null?!1:t.operator==="aboveAverage"?m>f:m<f}default:return!0}}function Wn({children:r,className:t="",style:a}){return e.jsx(jr,{onlyWhenOverflow:!0,className:t,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",...a},children:r})}function qn({columns:r,data:t,getRowId:a,loading:n=!1,skeletonRows:s=8,emptyIcon:l,emptyText:i="Sin resultados",initialEmptyDelay:c=450,onRowClick:u,renderExpandedRow:f,getRowCanExpand:m,expandedRowIds:b,defaultExpandedRowIds:p=[],onExpandedRowIdsChange:y,expandOnRowClick:N=!1,selected:M,onToggleOne:g,onToggleAll:C,highlightSelected:B=!0,rowClassName:A,getRowCategory:z,stickyHeader:E=!0,pageSize:k=25,pageSizeOptions:q,pageSizeSelectWidth:H=62,pageSizeSelectHeight:_=30,pageSizeSelectPadding:Y="0 7px",totalRows:Z,page:T,onPageChange:J,onPageSizeChange:O,storageKey:j,stickyFirstColumn:te=!1,bottomOffset:X=0,compact:I=!0,restrictHeight:ee=!0,maxHeight:R,minTableWidth:x,enableColumnVisibility:S=!0,enableColumnFilters:K=!0,hiddenColumnKeys:Q,defaultHiddenColumnKeys:ae=$l,onHiddenColumnKeysChange:ce,columnVisibilityLabel:ve="Columnas",enableBql:re=!1,bqlValue:G,defaultBqlValue:h="",onBqlChange:L,bqlDescription:W="Filtra registros con Bonsaif Query Language",bqlPlaceholder:ne=`status = activo
2
+ rol IN (admin, employee)`,bqlQuickFilters:oe=[],bqlExamples:he=[],bqlSuggestions:_e=[],bqlActiveFilters:Ge,bqlError:xe,onQueryChange:Ee,persistState:Ae,onPreferencesReady:wr,enableExport:br=!1,exportFilename:We="datos"}){var As;const se=Il(Ae,j),Ze=Object.values(se).some(Boolean),lr=r.map(d=>d.key).join(","),de=ae.join(","),D=o.useRef(r),U=o.useRef(ae);D.current=r,U.current=ae;const[le,ue]=o.useState(!j||!Ze),Le=o.useRef(null),ke=o.useRef(!j),Ie=o.useRef(!1),Me=o.useRef(wr);Me.current=wr;const Ue=o.useRef(!j||!Ze?j??"__none__":null),Be=Q!==void 0,[la,Ke]=o.useState(()=>vr(ae,r)),Fe=vr(Be?Q:la,r),[Xe,$r]=o.useState(!1),[ir,$d]=o.useState("filter"),[Et,ia]=o.useState(null),[Ro,es]=o.useState(""),[Qe,Zr]=o.useState({}),[cr,Mt]=o.useState({}),on=b!==void 0,[rs,Ad]=o.useState(p),Ar=G!==void 0,[Dd,Tt]=o.useState(h),pr=Ar?G:Dd,[Lt,ca]=o.useState(pr),[mr,Dr]=o.useState(!1),[ts,Qr]=o.useState(!1),[as,Jr]=o.useState(!1),[$t,Rr]=o.useState([]),et=o.useRef(null),Ir=o.useRef(null),dr=o.useRef(L);dr.current=L;const da=o.useRef(k);da.current=k;const ua=o.useRef(q);ua.current=q;const Id=Array.isArray(q)?q.join(","):"",sn=o.useRef(null),ns=o.useRef(null),ln=o.useRef(null),os=o.useRef(0),[Bd,Od]=o.useState({}),[Hd,Pd]=o.useState({}),[At,fa]=o.useState(!1),cn=o.useRef(null),ba=o.useRef(null),[Fd,zd]=o.useState({}),ss=o.useRef(null),pa=o.useRef(null),[dn,ls]=o.useState(t.length>0||n||c===!1),is=(d,v)=>50+(d*17+v*13+7)%40,Nr=o.useRef(null),[_d,jd]=o.useState(void 0),[cs,Wd]=o.useState(0),[un,qd]=o.useState(!1);o.useEffect(()=>{function d(){qd(window.innerWidth<640)}if(!ee||R!==void 0)return d(),window.addEventListener("resize",d),()=>window.removeEventListener("resize",d);const F=k!==!1?48:0,w=12;function V(){if(d(),!Nr.current)return;const ie=Nr.current.getBoundingClientRect().top;jd(Math.max(120,window.innerHeight-ie-F-w-X))}return V(),window.addEventListener("resize",V),()=>window.removeEventListener("resize",V)},[n,k,X,ee,R]);const ds=ee?R??_d:void 0;o.useEffect(()=>{const d=Nr.current;if(!d)return;const v=()=>Wd(d.clientWidth);if(v(),typeof ResizeObserver>"u")return window.addEventListener("resize",v),()=>window.removeEventListener("resize",v);const F=new ResizeObserver(v);return F.observe(d),()=>F.disconnect()},[n,le,t.length]),o.useEffect(()=>{if(c===!1||n||t.length>0){ls(!0);return}if(dn)return;const d=window.setTimeout(()=>{ls(!0)},c);return()=>window.clearTimeout(d)},[t.length,c,dn,n]);const[rt,tt]=o.useState(()=>r.map(d=>d.key)),[at,nt]=o.useState(()=>Object.fromEntries(r.map(d=>[d.key,er(d,gr(d.width))]))),[De,Br]=o.useState(null),[Ud,ma]=o.useState(1),[ha,ga]=o.useState(k===!1?0:k);o.useEffect(()=>{var qe;const d=D.current,v=U.current,F=d.map(be=>be.key),w=new Set(F),V=()=>{var be;Ie.current||(Ie.current=!0,(be=Me.current)==null||be.call(Me))};if(!j||!Ze){se.layout&&tt(F),Be||Ke(vr(v,d)),ke.current=!1,ue(!0),V();return}let ie=!1;const fe=Ue.current===j;fe||(ke.current=!1,ue(!1),Ie.current=!1);const ye=qt(j);if(zn(ye)&&!fe){const be=ye,pe=gt(ua.current??ft()),me=da.current,zr=me===!1?0:me,kr=se.layout?be==null?void 0:be.columnOrder:void 0,Sr=Array.isArray(kr)?kr.filter(Te=>F.includes(Te)):[],Cr=F.filter(Te=>!Sr.includes(Te)),_r=Sr.length>0?[...Sr,...Cr]:F,it=Object.fromEntries(d.map(Te=>[Te.key,er(Te,gr(Te.width))])),ct=se.layout?(be==null?void 0:be.columnWidths)??{}:{},Bt=Object.fromEntries(d.map(Te=>[Te.key,er(Te,ct[Te.key]??it[Te.key])])),dt=vr(se.layout?(be==null?void 0:be.hiddenColumnKeys)??v:v,d);if(se.layout&&(tt(_r),nt(Bt)),Be||Ke(dt),se.filters&&(Zr(pt(be==null?void 0:be.filters,w)),Mt(mt(be==null?void 0:be.conditionFilters,w))),se.sort){const Te=bt(be==null?void 0:be.sort)?be.sort:null;Br(Te&&w.has(Te.key)?Te:null)}if(se.bql){if(et.current!==j){et.current=j;const Te=typeof(be==null?void 0:be.bql)=="string"?be.bql:h;Ar?(qe=dr.current)==null||qe.call(dr,Te):Tt(Te)}Rr(Array.isArray(be==null?void 0:be.bqlHistory)?be.bqlHistory.filter(Te=>typeof Te=="string"):[])}se.pagination&&Ir.current!==j&&(Ir.current=j,ga(za(be==null?void 0:be.pageSize,pe,zr))),Ue.current=j,ue(!0),V()}const we=`${Fa()??"/api/user/preferences/datatables"}?key=${encodeURIComponent(j)}`,Se=new AbortController,Ne=window.setTimeout(()=>Se.abort(),2500);return fetch(we,{cache:"no-store",signal:Se.signal}).then(be=>be.ok?be.json():null).then(be=>{var Ds;if(ie)return;const pe=qt(j),me=jn(zn(be==null?void 0:be.settings)?be==null?void 0:be.settings:null,pe),zr=gt(ua.current??ft()),kr=da.current,Sr=kr===!1?0:kr,Cr=se.layout?me==null?void 0:me.columnOrder:void 0,_r=Array.isArray(Cr)?Cr.filter(Oe=>F.includes(Oe)):[],it=F.filter(Oe=>!_r.includes(Oe)),ct=_r.length>0?[..._r,...it]:F,Bt=Object.fromEntries(d.map(Oe=>[Oe.key,er(Oe,gr(Oe.width))])),dt=se.layout?(me==null?void 0:me.columnWidths)??{}:{},Te=Object.fromEntries(d.map(Oe=>[Oe.key,er(Oe,dt[Oe.key]??Bt[Oe.key])])),ut=vr(se.layout?(me==null?void 0:me.hiddenColumnKeys)??v:v,d);if(se.layout&&(tt(ct),nt(Te)),Be||Ke(ut),se.filters&&(Zr(pt(me==null?void 0:me.filters,w)),Mt(mt(me==null?void 0:me.conditionFilters,w))),se.sort){const Oe=bt(me==null?void 0:me.sort)?me.sort:null;Br(Oe&&w.has(Oe.key)?Oe:null)}if(se.bql){if(et.current!==j){et.current=j;const Oe=typeof(me==null?void 0:me.bql)=="string"?me.bql:h;Ar?(Ds=dr.current)==null||Ds.call(dr,Oe):Tt(Oe)}Rr(Array.isArray(me==null?void 0:me.bqlHistory)?me.bqlHistory.filter(Oe=>typeof Oe=="string"):[])}let $e;se.pagination&&($e=za(me==null?void 0:me.pageSize,zr,Sr),Ir.current!==j&&(Ir.current=j,ga($e))),Le.current=JSON.stringify({columnOrder:ct,columnWidths:Te,hiddenColumnKeys:ut,filters:pt(me==null?void 0:me.filters,w),conditionFilters:mt(me==null?void 0:me.conditionFilters,w),sort:bt(me==null?void 0:me.sort)?me.sort:null,bql:typeof(me==null?void 0:me.bql)=="string"?me.bql:"",bqlHistory:Array.isArray(me==null?void 0:me.bqlHistory)?me.bqlHistory:[],pageSize:se.pagination&&kr!==!1?$e:void 0}),ke.current=!0}).catch(()=>{var be;if(!ie){const pe=qt(j),me=gt(ua.current??ft()),zr=da.current,kr=zr===!1?0:zr,Sr=se.layout?pe==null?void 0:pe.columnOrder:void 0,Cr=Array.isArray(Sr)?Sr.filter($e=>F.includes($e)):[],_r=F.filter($e=>!Cr.includes($e)),it=Cr.length>0?[...Cr,..._r]:F,ct=Object.fromEntries(d.map($e=>[$e.key,er($e,gr($e.width))])),Bt=se.layout?(pe==null?void 0:pe.columnWidths)??{}:{},dt=Object.fromEntries(d.map($e=>[$e.key,er($e,Bt[$e.key]??ct[$e.key])]));se.layout&&(tt(it),nt(dt));const Te=vr(se.layout?(pe==null?void 0:pe.hiddenColumnKeys)??v:v,d);if(Be||Ke(Te),se.filters&&(Zr(pt(pe==null?void 0:pe.filters,w)),Mt(mt(pe==null?void 0:pe.conditionFilters,w))),se.sort){const $e=bt(pe==null?void 0:pe.sort)?pe.sort:null;Br($e&&w.has($e.key)?$e:null)}if(se.bql){if(et.current!==j){et.current=j;const $e=typeof(pe==null?void 0:pe.bql)=="string"?pe.bql:h;Ar?(be=dr.current)==null||be.call(dr,$e):Tt($e)}Rr(Array.isArray(pe==null?void 0:pe.bqlHistory)?pe.bqlHistory.filter($e=>typeof $e=="string"):[])}let ut;se.pagination&&(ut=za(pe==null?void 0:pe.pageSize,me,kr),Ir.current!==j&&(Ir.current=j,ga(ut))),Le.current=JSON.stringify({columnOrder:it,columnWidths:dt,hiddenColumnKeys:Te,filters:pt(pe==null?void 0:pe.filters,w),conditionFilters:mt(pe==null?void 0:pe.conditionFilters,w),sort:bt(pe==null?void 0:pe.sort)?pe.sort:null,bql:typeof(pe==null?void 0:pe.bql)=="string"?pe.bql:"",bqlHistory:Array.isArray(pe==null?void 0:pe.bqlHistory)?pe.bqlHistory:[],pageSize:se.pagination&&zr!==!1?ut:void 0}),ke.current=!0}}).finally(()=>{window.clearTimeout(Ne),ie||(Ue.current=j,ue(!0),V())}),()=>{ie=!0,Se.abort(),window.clearTimeout(Ne)}},[j,Ze,lr,de,Be,se.layout,se.filters,se.sort,se.bql,se.pagination,Ar,h,Id]),o.useEffect(()=>{if(!j||!le||!Ze||!ke.current)return;const d={};se.layout&&(d.columnOrder=rt,d.columnWidths=at,d.hiddenColumnKeys=Fe),se.filters&&(d.filters=Qe,d.conditionFilters=cr),se.sort&&(d.sort=De),se.bql&&(d.bql=pr,d.bqlHistory=$t),se.pagination&&k!==!1&&(d.pageSize=ha);const v=qt(j),F=jn(v,d),w=JSON.stringify(F);if(w===Le.current)return;Dl(j,F),Le.current=w;const V=window.setTimeout(()=>{const ie=Fa()??"/api/user/preferences/datatables";fetch(ie,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:j,settings:F})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(V)},[rt,at,Fe,Qe,cr,De,pr,$t,ha,k,j,le,Ze,se.layout,se.filters,se.sort,se.bql,se.pagination]),o.useEffect(()=>{tt(d=>{const v=r.map(V=>V.key),F=d.filter(V=>v.includes(V)),w=v.filter(V=>!F.includes(V));return[...F,...w]})},[lr,r]);const us=rt.map(d=>r.find(v=>v.key===d)).filter(d=>!!d),nr=us.filter(d=>!Fe.includes(d.key)),Vd=Object.keys(Qe).length,Gd=Object.keys(cr).length,fn=Vd+Gd;function fs(d){const v=new Set;return t.reduce((F,w)=>{const V=Ut(d,w);return!V||v.has(V)||(v.add(V),F.push({value:V,label:V})),F},[])}function Kd(){const d=r.find(v=>v.key===Et);return d?fs(d):[]}function Xd(d){return!!(K&&!Mr(d)&&(d.filterValue||d.sortKey||fs(d).length>0))}function bs(d,v){Zr(F=>{const w={...F};return w[d]=v,w})}function Yd(d,v,F,w){const V=Qe[d]??[],ie=w?V:F.filter(ye=>ye!==v),fe=w?V.includes(v)?V.filter(ye=>ye!==v):[...V,v]:ie;fe.length===F.length?bn(d):bs(d,fe)}function bn(d){Zr(v=>{const F={...v};return delete F[d],F})}function va(d,v){Mt(F=>{const w={...F};return v?w[d]=v:delete w[d],w})}function ps(d){va(d,null)}function Zd(){Zr({}),Mt({})}function Qd(d){Ar||Tt(d),L==null||L(d)}function ms(d){const v=d.trim();ca(v),(L==null?void 0:L(v))!==!1&&(Ar||Tt(v),Dr(!1),Qr(!1),Jr(!1),v&&Rr(w=>[v,...w.filter(V=>V!==v)].slice(0,El)))}function hs(){ca(""),Qd(""),Dr(!1),Qr(!1),Jr(!1)}function pn(d,v){ca(d),v&&(v.style.height="auto",v.style.height=`${Math.min(v.scrollHeight,180)}px`)}function xa(d){const v=d.trim();if(!v)return;os.current=Date.now()+500;const F=Lt.replace(/\s+$/u,""),w=F.length===0?v:F.split(`
3
+ `).map(V=>V.trim()).includes(v)?F:`${F}
4
+ ${v}`;pn(w,ln.current??void 0),requestAnimationFrame(()=>{const V=ln.current;if(!V)return;V.focus();const ie=V.value.length;V.setSelectionRange(ie,ie),pn(V.value,V)})}o.useEffect(()=>{ca(pr)},[pr]);const ya=o.useCallback(()=>{const d=sn.current;if(!d)return;const v=d.getBoundingClientRect(),F=12,w=8,V=Math.min(780,Math.max(320,window.innerWidth-32)),ie=Math.max(F,window.innerWidth-V-F),fe=Math.min(Math.max(F,v.left),ie),ye=v.bottom+w,ze=window.innerHeight-v.top+w,Pe=window.innerHeight-ye-F,we=v.top-F-w,Se=Pe<280&&we>Pe,Ne=Math.max(240,Se?we:Pe);Od({position:"fixed",zIndex:1e4,left:fe,top:Se?void 0:ye,bottom:Se?ze:void 0,width:V,maxWidth:"calc(100vw - 24px)",maxHeight:Ne,overflowY:"auto"})},[]);o.useEffect(()=>{if(!mr)return;function d(w){var ie,fe;if(Date.now()<os.current)return;const V=w.target;(ie=sn.current)!=null&&ie.contains(V)||(fe=ns.current)!=null&&fe.contains(V)||(Dr(!1),Qr(!1),Jr(!1))}function v(w){w.key==="Escape"&&(Dr(!1),Qr(!1),Jr(!1))}function F(){ya()}return ya(),document.addEventListener("mousedown",d),window.addEventListener("keydown",v),window.addEventListener("resize",F),window.addEventListener("scroll",F,!0),()=>{document.removeEventListener("mousedown",d),window.removeEventListener("keydown",v),window.removeEventListener("resize",F),window.removeEventListener("scroll",F,!0)}},[mr,ya]);function gs(d){const v=vr(d,r);Be||Ke(v),ce==null||ce(v)}function Jd(d){gs(Fe.includes(d)?Fe.filter(v=>v!==d):[...Fe,d])}function Rd(){gs([])}const mn=o.useCallback((d=pa.current)=>{if(!d)return;const v=d.getBoundingClientRect(),F=Math.min(292,Math.max(240,window.innerWidth-16)),w=Math.max(8,window.innerWidth-F-8),V=Math.min(Math.max(8,v.right-F),w),ie=window.innerHeight-v.bottom,fe=v.bottom+6,ye=window.innerHeight-v.top+6,Pe=ie<360&&v.top>ie?void 0:fe,we=Pe===void 0?ye:void 0,Se=Math.max(220,Pe===void 0?v.top-16:window.innerHeight-fe-8),Ne={position:"fixed",zIndex:9999,left:V,top:Pe,bottom:we,width:F,maxWidth:"calc(100vw - 16px)",maxHeight:Se,"--dt-column-menu-max-height":`${Se}px`};Pd(Ne)},[]);function vs(d,v,F=null){d.preventDefault(),d.stopPropagation();const w=pa.current===d.currentTarget&&ir===v&&Et===F;if(Xe&&w){$r(!1),ia(null);return}pa.current=d.currentTarget,$d(v),ia(F),es(""),mn(d.currentTarget),$r(!0)}function eu(d){if(Mr(d))return;const v=Nr.current;if(!v)return;const w=Array.from(v.querySelectorAll("[data-dt-column-key]")).filter(V=>V.dataset.dtColumnKey===d.key).reduce((V,ie)=>{const fe=ie.querySelector("[data-dt-autofit-content]"),ye=fe?fe.scrollWidth:Math.max(ie.scrollWidth,ie.offsetWidth);return Math.max(V,Math.ceil(ye+Bl(ie)))},0);w<=0||nt(V=>({...V,[d.key]:er(d,w+12)}))}o.useEffect(()=>{nt(d=>{const v=Object.fromEntries(r.map(F=>[F.key,er(F,gr(F.width))]));return Object.fromEntries(r.map(F=>[F.key,er(F,d[F.key]??v[F.key])]))})},[lr,r]),o.useEffect(()=>{Be||Ke(d=>vr(d,r))},[lr,r,Be]),o.useEffect(()=>{function d(w){var fe,ye;const V=w.target,ie=w.target;ie!=null&&ie.closest("[data-bonsaif-select-dropdown='true']")||!((fe=ss.current)!=null&&fe.contains(V))&&!((ye=pa.current)!=null&&ye.contains(V))&&($r(!1),ia(null))}function v(w){w.key==="Escape"&&($r(!1),ia(null))}function F(){mn()}return Xe&&(document.addEventListener("mousedown",d),window.addEventListener("keydown",v),window.addEventListener("resize",F),window.addEventListener("scroll",F,!0)),()=>{document.removeEventListener("mousedown",d),window.removeEventListener("keydown",v),window.removeEventListener("resize",F),window.removeEventListener("scroll",F,!0)}},[Xe,mn]);const Dt=o.useRef(null);o.useEffect(()=>{function d(F){const w=Dt.current;if(!w)return;const V=F.clientX-w.startX,ie=r.find(fe=>fe.key===w.colKey);ie&&nt(fe=>({...fe,[w.colKey]:er(ie,w.startWidth+V)}))}function v(){Dt.current&&(Dt.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",d),document.addEventListener("pointerup",v),()=>{document.removeEventListener("pointermove",d),document.removeEventListener("pointerup",v)}},[r]);const wa=o.useRef(null),[xs,hn]=o.useState(null);function ru(d,v){wa.current=rt.indexOf(d),v.dataTransfer.effectAllowed="move"}function tu(d,v){v.preventDefault(),v.dataTransfer.dropEffect="move";const F=rt.indexOf(d);xs!==F&&hn(F)}function au(d,v){v.preventDefault();const F=wa.current,w=rt.indexOf(d);F!==null&&F!==w&&tt(V=>{const ie=[...V],[fe]=ie.splice(F,1);return ie.splice(w,0,fe),ie}),wa.current=null,hn(null)}function nu(){wa.current=null,hn(null)}function ou(d){d.sortKey&&Br(v=>(v==null?void 0:v.key)===d.key?{key:d.key,dir:v.dir==="asc"?"desc":"asc"}:{key:d.key,dir:"asc"})}o.useEffect(()=>{ma(1)},[t]),o.useEffect(()=>{ma(1)},[cr,Qe]);const Or=!!(J&&O),Hr=k!==!1,ys=o.useMemo(()=>gt(q??ft()),[q]),je=Or?T??1:Ud,ur=Or||Hr?ha:t.length,fr=!!M&&!!g&&!!C,ot=!!f,ws=o.useMemo(()=>new Set(on?Array.from(b??[]):rs),[on,b,rs]),gn=(ot?40:0)+(fr?40:0),su=fr&&t.length>0&&M.size===t.length,lu=fr&&M.size>0&&M.size<t.length,Na=o.useMemo(()=>{const d=Object.entries(Qe),v=Object.entries(cr);return d.length===0&&v.length===0?t:t.filter(F=>d.every(([w,V])=>{const ie=r.find(fe=>fe.key===w);return ie?V.includes(Ut(ie,F)):!0})&&v.every(([w,V])=>{const ie=r.find(ye=>ye.key===w);if(!ie)return!0;const fe=t.map(ye=>Ut(ie,ye));return Pl(Ut(ie,F),V,fe)}))},[cr,Qe,r,t]),Pr=o.useMemo(()=>{if(!De)return Na;const d=r.find(v=>v.key===De.key&&v.sortKey);return d!=null&&d.sortKey?[...Na].sort((v,F)=>{const w=v[d.sortKey],V=F[d.sortKey],ie=w===V?0:w==null?1:V==null||w<V?-1:1;return De.dir==="asc"?ie:-ie}):Na},[Na,De,r]),Ns=o.useMemo(()=>{if(Or||!Hr)return Pr;const d=(je-1)*ur;return Pr.slice(d,d+ur)},[Pr,Or,Hr,je,ur]),Fr=Or?Z??t.length:Pr.length,vn=Hr?Math.max(1,Math.ceil(Fr/ur)):1,iu=Math.min(...ys),cu=Hr&&(Fr>ur||Fr>iu),du=Hr?(je-1)*ur+1:1,uu=Hr?Math.min(je*ur,Fr):Fr;function xn(d){if(n)return;const v=Math.max(1,Math.min(d,vn));Or?J(v):ma(v)}function fu(d){n||(j&&(Ir.current=j),ga(d),Or?(O(d),J(1)):(ma(1),O==null||O(d)))}function ks(d){const v=new Set(ws);v.has(d)?v.delete(d):v.add(d);const F=Array.from(v);on||Ad(F),y==null||y(F)}o.useEffect(()=>{Ee==null||Ee({bql:pr,filters:Qe,conditionFilters:cr,sort:De,page:je,pageSize:ur,hiddenColumnKeys:Fe})},[pr,Qe,cr,De,je,ur,Fe,Ee]);const Ss=d=>d==="center"?"text-center":d==="right"?"text-right":"text-left",bu="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",yn="linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 90%, var(--bg-card)) 0%, color-mix(in srgb, var(--bg-input) 70%, var(--bg-card)) 100%)",Ce="color-mix(in srgb, var(--border) 62%, var(--bg-card))",st="color-mix(in srgb, var(--primary) 24%, var(--border))",ka=`inset 0 0 0 1px ${Ce}`,Cs=nr.reduce((d,v)=>d+(at[v.key]??gr(v.width)),(ot?40:0)+(fr?40:0)),Es=typeof x=="number"?x:typeof x=="string"?Number(((As=x.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:As[1])??NaN):NaN,It=Number.isFinite(Es)?Math.max(Cs,Es,cs):Math.max(Cs,cs),Sa=x??It,lt=`${ot?"40px ":""}${fr?"40px ":""}${nr.map(d=>`${at[d.key]??gr(d.width)}px`).join(" ")}`;o.useEffect(()=>{De&&Fe.includes(De.key)&&Br(null)},[Fe,De]);function Ms(d){return d?typeof d=="string"?{key:d,label:d}:d:null}const Ca=()=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:lt,background:yn,borderBottom:`1px solid ${st}`},children:[ot&&e.jsx("div",{role:"columnheader",className:`${I?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${st}`,borderRight:`1px solid ${Ce}`}}),fr&&e.jsx("div",{role:"columnheader",className:`${I?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:te?{position:"sticky",left:0,zIndex:12,background:yn,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${st}`,borderRight:`1px solid ${Ce}`}:{borderBottom:`1px solid ${st}`,borderRight:`1px solid ${Ce}`},children:e.jsx(Ft,{size:"sm",checked:su,indeterminate:lu,onChange:C,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),nr.map((d,v)=>{const F=(De==null?void 0:De.key)===d.key,w=!!d.sortKey,V=Mr(d),ie=te&&!un&&v===0,fe=xs===v,ze=(at[d.key]??gr(d.width))<120,Pe=Object.prototype.hasOwnProperty.call(Qe,d.key)||Object.prototype.hasOwnProperty.call(cr,d.key);return e.jsxs("div",{role:"columnheader","data-dt-column-key":d.key,className:`group select-none ${ze?"text-left":Ss(d.align)}`,style:{...ie?{position:"sticky",left:gn,zIndex:12,background:yn,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${st}`,borderRight:`1px solid ${Ce}`}:{position:"relative",borderBottom:`1px solid ${st}`,borderRight:`1px solid ${Ce}`},color:F?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:fe?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:V?I?"7px 6px":"9px 8px":I?"8px 6px 10px":"10px 8px 12px"},onDragOver:we=>tu(d.key,we),onDrop:we=>au(d.key,we),children:[e.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${V?"justify-center":ze?"justify-start":d.align==="center"?"justify-center":d.align==="right"?"justify-end":"justify-start"}`,children:[e.jsx("span",{draggable:!0,onDragStart:we=>{we.stopPropagation(),ru(d.key,we)},onDragEnd:we=>{we.stopPropagation(),nu()},onClick:we=>we.stopPropagation(),title:"Arrastrar para mover columna","aria-label":"Arrastrar para mover columna",className:`absolute left-0 top-0 z-10 inline-flex h-full w-3 shrink-0 rounded-sm transition-colors duration-150 hover:bg-[var(--primary)]/15 ${fe?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}),V?e.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-md text-[var(--text-muted)]",title:"Acciones","aria-label":"Acciones",children:e.jsx($.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):e.jsx(Wn,{className:"min-w-0 flex-1",children:e.jsx("span",{"data-dt-autofit-content":!0,className:`inline-flex max-w-full items-center font-semibold uppercase tracking-wider ${I?"text-[11px]":"text-xs"}`,children:e.jsx("span",{className:"min-w-0 truncate",children:d.header})})}),w&&e.jsx("button",{type:"button","aria-label":`Ordenar por ${String(d.header)}`,title:"Ordenar",onClick:we=>{we.stopPropagation(),ou(d)},"data-dt-sort-button":!0,className:`absolute -bottom-2 left-1/2 z-20 inline-flex h-4 w-4 -translate-x-1/2 items-center justify-center rounded-full bg-[var(--primary)] text-[var(--primary-fg)] shadow-[0_1px_3px_rgba(15,23,42,0.22)] transition-[opacity,transform] duration-150 hover:scale-105 focus:scale-105 focus:opacity-100 focus:outline-none ${F?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:F?De.dir==="asc"?e.jsx($.HiChevronUp,{className:"h-3 w-3"}):e.jsx($.HiChevronDown,{className:"h-3 w-3"}):e.jsx($.HiChevronUpDown,{className:"h-3 w-3"})}),K&&!V&&Xd(d)&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Xe&&Et===d.key,"aria-label":`Filtrar ${String(d.header)}`,title:"Filtrar",onClick:we=>vs(we,"filter",d.key),className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-sm bg-transparent text-[var(--text-muted)] opacity-0 transition-[opacity,color,background-color] duration-150 hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] focus:opacity-100 group-hover:opacity-100 ${Xe&&ir==="filter"&&Et===d.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":Pe?"text-[var(--primary)] opacity-100":""}`,children:Pe?e.jsx($.HiFunnel,{className:"h-3.5 w-3.5"}):e.jsx($.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!V&&e.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:we=>{we.preventDefault(),we.stopPropagation(),Dt.current={colKey:d.key,startX:we.clientX,startWidth:at[d.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:we=>{we.preventDefault(),we.stopPropagation(),Dt.current=null,document.body.style.cursor="",document.body.style.userSelect="",eu(d)},onClick:we=>we.stopPropagation(),className:"absolute top-0 flex h-full items-center justify-center opacity-0 transition-opacity duration-200 hover:opacity-100",style:{right:0,width:12,cursor:"col-resize",zIndex:6,transform:"translateX(50%)"},children:e.jsxs("span",{style:{display:"flex",gap:4,alignItems:"center",height:"calc(100% - 8px)"},children:[e.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}}),e.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}})]})})]},d.key)})]}),Ea=()=>{if(!Xe||typeof document>"u"||ir==="visibility"&&!S||ir==="filter"&&!K)return null;const d=r.find(Ne=>Ne.key===Et),v=Kd(),F=d?Object.prototype.hasOwnProperty.call(Qe,d.key):!1,w=d?cr[d.key]:void 0,V=Wt.find(Ne=>Ne.value===(w==null?void 0:w.operator)),ie=d?Qe[d.key]??[]:[],fe=Ro.trim().toLowerCase(),ye=fe?v.filter(Ne=>Ne.label.toLowerCase().includes(fe)):v,ze=d&&v.length>0&&(!F||ie.length===v.length),Pe=d&&F&&ie.length>0&&ie.length<v.length,we=Fe.length,Se=()=>{d&&(bn(d.key),ps(d.key))};return Je.createPortal(e.jsx("div",{ref:ss,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Hd,borderColor:"var(--border)",background:"var(--bg-card)"},children:ir==="visibility"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[e.jsx("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:we>0?`${nr.length} de ${r.length} visibles`:`${r.length} visibles`}),e.jsx("button",{type:"button",onClick:Rd,disabled:we===0,className:"rounded px-1.5 py-0.5 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-input)] disabled:opacity-40",children:"Mostrar todas"})]}),e.jsx("div",{className:"max-h-72 overflow-auto py-1",children:us.map(Ne=>{const qe=!Fe.includes(Ne.key),pe=!(Ne.hideable!==!1)||qe&&nr.length<=1;return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":qe,disabled:pe,onClick:()=>Jd(Ne.key),className:"flex w-full min-w-0 items-center 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:"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:qe?"var(--primary)":"var(--border)",background:qe?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:qe&&e.jsx($.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:Ne.header})]},Ne.key)})})]}):d?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[e.jsxs("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:["Filtrar ",d.header]}),e.jsx("button",{type:"button",onClick:Se,disabled:!F&&!w,className:"rounded px-1.5 py-0.5 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-input)] disabled:opacity-40",children:"Limpiar"})]}),d.sortKey&&e.jsxs("div",{className:"grid grid-cols-2 gap-1 border-b border-[var(--border)] p-1",children:[e.jsxs("button",{type:"button",onClick:()=>Br({key:d.key,dir:"asc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[e.jsx($.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate",children:"Ascendente"})]}),(De==null?void 0:De.key)===d.key&&De.dir==="asc"&&e.jsx($.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),e.jsxs("button",{type:"button",onClick:()=>Br({key:d.key,dir:"desc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[e.jsx($.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate",children:"Descendente"})]}),(De==null?void 0:De.key)===d.key&&De.dir==="desc"&&e.jsx($.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]})]}),e.jsxs("div",{className:"border-b border-[var(--border)] p-2",children:[e.jsxs("div",{className:"grid grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)] gap-2",children:[e.jsx(Er,{value:(w==null?void 0:w.operator)??"",onChange:Ne=>{if(!Ne){ps(d.key);return}va(d.key,{operator:Ne,value:(w==null?void 0:w.value)??"",valueTo:(w==null?void 0:w.valueTo)??""})},options:Cl,placeholder:"Opcion",emptyLabel:"Sin condicion",ariaLabel:"Operador de filtro",searchable:!1,height:34,padding:"0 9px",dropdownMinWidth:260,className:"min-w-0 [&>button]:rounded-md [&>button]:text-sm [&>button]:font-medium"}),(V==null?void 0:V.valueMode)!=="none"?e.jsx("input",{value:(w==null?void 0:w.value)??"",onChange:Ne=>{w&&va(d.key,{...w,value:Ne.target.value})},disabled:!w,placeholder:"Valor",className:"min-w-0 rounded-md border px-2 py-1.5 text-sm outline-none transition-colors placeholder:text-[var(--text-muted)] focus:border-[var(--primary)] disabled:opacity-50",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"}}):e.jsx("div",{className:"min-h-8 rounded-md border px-2 py-1.5 text-sm text-[var(--text-muted)]",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:"Automatico"})]}),(V==null?void 0:V.valueMode)==="between"&&e.jsx("input",{value:(w==null?void 0:w.valueTo)??"",onChange:Ne=>{w&&va(d.key,{...w,valueTo:Ne.target.value})},placeholder:"Valor final",className:"mt-2 w-full rounded-md border px-2 py-1.5 text-xs outline-none transition-colors placeholder:text-[var(--text-muted)] focus:border-[var(--primary)]",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"}})]}),e.jsx("div",{className:"border-b border-[var(--border)] p-2",children:e.jsxs("div",{className:"flex items-center gap-1 rounded-md border px-2 py-1.5 text-sm",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[e.jsx($.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),e.jsx("input",{value:Ro,onChange:Ne=>es(Ne.target.value),placeholder:"Buscar",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-[var(--text-muted)]",style:{color:"var(--text-main)"}})]})}),e.jsxs("div",{className:"overflow-auto py-1",style:{maxHeight:"max(96px, calc(var(--dt-column-menu-max-height, 520px) - 236px))"},children:[e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Pe?"mixed":!!ze,onClick:()=>{d&&(ze&&!F?bs(d.key,[]):bn(d.key))},className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[e.jsxs("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:ze||Pe?"var(--primary)":"var(--border)",background:ze||Pe?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[Pe&&e.jsx($.HiMinus,{className:"h-3 w-3"}),ze&&!Pe&&e.jsx($.HiCheck,{className:"h-3 w-3"})]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),ye.map(Ne=>{const qe=!F||ie.includes(Ne.value);return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":qe,onClick:()=>Yd(d.key,Ne.value,v.map(be=>be.value),F),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:qe?"var(--primary)":"var(--border)",background:qe?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:qe&&e.jsx($.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:Ne.label})]},Ne.value)}),ye.length===0&&e.jsx("div",{className:"px-3 py-3 text-sm text-[var(--text-muted)]",children:"Sin valores"})]})]}):null}),document.body)};o.useEffect(()=>{if(!At)return;function d(v){cn.current&&!cn.current.contains(v.target)&&ba.current&&!ba.current.contains(v.target)&&fa(!1)}return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[At]);function Ts(d,v){if(d.filterValue){const F=d.filterValue(v);return F==null||F===""?"":String(F)}return Wr(d.cell(v))}function Ls(d){return`"${d.replace(/"/g,'""')}"`}function Ma(d){return d.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function pu(){const d=nr.filter(ye=>!Mr(ye)),v=d.map(ye=>Ls(Wr(ye.header))).join(","),F=Pr.map(ye=>d.map(ze=>Ls(Ts(ze,ye))).join(",")).join(`
5
+ `),w=`${v}
6
+ ${F}`,V=new Blob(["\uFEFF"+w],{type:"text/csv;charset=utf-8;"}),ie=URL.createObjectURL(V),fe=document.createElement("a");fe.href=ie,fe.download=`${We}.csv`,document.body.appendChild(fe),fe.click(),document.body.removeChild(fe),URL.revokeObjectURL(ie)}function mu(){const d=nr.filter(fe=>!Mr(fe)),v=d.map(fe=>Ma(Wr(fe.header))),w=Pr.map(fe=>d.map(ye=>Ma(Ts(ye,fe)))).map(fe=>`<tr>${fe.map(ye=>`<td>${ye}</td>`).join("")}</tr>`).join(""),V=`<!DOCTYPE html>
7
+ <html lang="es"><head><meta charset="utf-8"><title>${Ma(We)}</title>
8
8
  <style>
9
9
  body{font-family:system-ui,sans-serif;font-size:11px;margin:20px;color:#111}
10
10
  h3{margin:0 0 4px;font-size:14px}
@@ -15,23 +15,22 @@ ${F}`,G=new Blob(["\uFEFF"+x],{type:"text/csv;charset=utf-8;"}),le=URL.createObj
15
15
  tr:nth-child(even) td{background:#f9f9f9}
16
16
  @media print{body{margin:0}@page{margin:1cm}}
17
17
  </style></head><body>
18
- <h3>${Ea(dr)}</h3>
19
- <p>${Hr.length} registros · ${new Date().toLocaleDateString("es")}</p>
20
- <table><thead><tr>${g.map(ce=>`<th>${ce}</th>`).join("")}</tr></thead>
21
- <tbody>${x}</tbody></table>
18
+ <h3>${Ma(We)}</h3>
19
+ <p>${Pr.length} registros · ${new Date().toLocaleDateString("es")}</p>
20
+ <table><thead><tr>${v.map(fe=>`<th>${fe}</th>`).join("")}</tr></thead>
21
+ <tbody>${w}</tbody></table>
22
22
  <script>window.onload=()=>{window.print()}<\/script>
23
- </body></html>`,le=window.open("","_blank");le&&(le.document.write(G),le.document.close())}const Ma=()=>!cr||!$t?null:rr.createPortal(e.jsxs("div",{ref:ln,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Ad,position:"fixed",zIndex:9999,minWidth:170,borderColor:"var(--border)",background:"var(--bg-card)"},children:[e.jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},onClick:()=>{lu(),ua(!1)},children:[e.jsx(A.HiTableCells,{className:"h-4 w-4 shrink-0 text-emerald-500"}),"Descargar CSV / Excel"]}),e.jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},onClick:()=>{iu(),ua(!1)},children:[e.jsx(A.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),La=()=>{const d=te&&fr.trim().length>0,g=Ve!=null&&Ve.length?Ve:d?[{key:"bql",label:"BQL",value:fr}]:[],F=Be.filter(x=>{const G=x.trim();return G?!new Set(Mt.split(`
24
- `).map(ce=>ce.trim()).filter(Boolean)).has(G):!1}).slice(0,8);return!O&&un===0&&!te&&!cr?null:e.jsxs("div",{className:"relative flex min-h-9 flex-wrap items-center justify-between gap-2 border-b rounded-t-lg px-2 py-1",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[un>0&&e.jsxs("button",{type:"button",onClick:qd,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-card)]",children:[e.jsx(A.HiXMark,{className:"h-3.5 w-3.5"}),un," filtros"]}),te&&e.jsxs("div",{ref:on,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>{if(br){Ar(!1);return}xa(),Ar(!0)},className:"inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border px-2 text-xs font-bold transition-colors",style:{background:br?"var(--primary)":d?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:br||d?"var(--primary)":"var(--border)",color:br?"var(--primary-fg)":"var(--primary)"},"aria-expanded":br,title:"Abrir filtros BQL",children:[e.jsx(A.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",d&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),br?e.jsx(A.HiChevronUp,{className:"h-3.5 w-3.5"}):e.jsx(A.HiChevronDown,{className:"h-3.5 w-3.5"})]}),e.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:V}),g.length>0&&e.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[g.slice(0,3).map(x=>e.jsxs("span",{className:"inline-flex max-w-44 items-center gap-1 truncate rounded-full px-2 py-1 text-xs font-medium",style:{background:"var(--bg-hover)",border:"1px solid var(--primary)",color:"var(--primary)"},children:[e.jsxs("span",{className:"text-[var(--text-muted)]",children:[x.label,":"]}),e.jsx("span",{className:"truncate",children:x.value})]},x.key)),g.length>3&&e.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",g.length-3]})]}),d&&e.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:ds,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)]",children:e.jsx(A.HiXMark,{className:"h-4 w-4"})}),br&&rr.createPortal(e.jsxs("div",{ref:Jo,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...Md,background:"var(--bg-card)",border:"1px solid color-mix(in srgb, var(--primary) 35%, var(--border))"},children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[se.map(x=>e.jsxs("button",{type:"button",onMouseDown:G=>{G.preventDefault(),G.stopPropagation()},onClick:G=>{G.preventDefault(),G.stopPropagation(),ga(x.bql)},className:"inline-flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs font-semibold transition-colors hover:border-[var(--primary)] hover:text-[var(--primary)]",style:{background:"var(--bg-input)",borderColor:"var(--border)",color:"var(--text-secondary)"},children:[x.icon,x.label]},x.label)),he.length>0&&e.jsxs("button",{type:"button",onClick:()=>Zr(x=>!x),className:"inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]","aria-expanded":Zo,children:[e.jsx(A.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),Lt.length>0&&e.jsxs("button",{type:"button",onClick:()=>Qr(x=>!x),className:"inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]","aria-expanded":Qo,children:[e.jsx(A.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]})]}),e.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-input)",border:`1.5px solid ${xe?"var(--danger)":d?"var(--primary)":"var(--border)"}`},children:[e.jsx("textarea",{ref:sn,value:Mt,rows:3,onChange:x=>bn(x.target.value,x.target),onKeyDown:x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),cs(Mt)),x.key==="Escape"&&Ar(!1)},placeholder:ae,autoComplete:"off",spellCheck:!1,className:"block w-full px-4 py-3 text-sm outline-none",style:{background:"var(--bg-input)",color:"var(--text-main)",border:"none",fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace",lineHeight:1.6,maxHeight:180,minHeight:88,overflowY:"auto",resize:"vertical"}}),F.length>0&&e.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:F.map(x=>e.jsx("button",{type:"button",onMouseDown:G=>{G.preventDefault(),G.stopPropagation()},onClick:G=>{G.preventDefault(),G.stopPropagation(),ga(x)},className:"block w-full px-4 py-2 text-left text-xs transition-colors hover:bg-[var(--bg-hover)] hover:text-[var(--primary)]",style:{fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace"},children:x},x))})]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 text-xs",style:{color:xe?"var(--danger)":"var(--text-muted)"},children:xe??(d?`${g.length||1} filtro${(g.length||1)===1?"":"s"} activo${(g.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),g.map(x=>e.jsxs("span",{className:"inline-flex max-w-56 items-center gap-1 truncate rounded-full px-2 py-1 text-xs font-medium",style:{background:"var(--bg-hover)",border:"1px solid var(--primary)",color:"var(--primary)"},children:[e.jsxs("span",{className:"text-[var(--text-muted)]",children:[x.label,":"]}),e.jsx("span",{className:"truncate",children:x.value})]},x.key))]}),Qo&&Lt.length>0&&e.jsxs("div",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-input)]",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-3 py-2",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-semibold text-[var(--text-secondary)]",children:[e.jsx(A.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),e.jsxs("button",{type:"button",onClick:()=>{Jr([]),Qr(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[e.jsx(A.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),Lt.map(x=>e.jsxs("div",{className:"group flex items-center gap-2 border-b border-[var(--border)] px-3 py-2 last:border-b-0",children:[e.jsx("button",{type:"button",onMouseDown:G=>{G.preventDefault(),G.stopPropagation()},onClick:G=>{G.preventDefault(),G.stopPropagation(),ga(x)},className:"min-w-0 flex-1 text-left",children:e.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:x})}),e.jsx("button",{type:"button",onClick:()=>Jr(G=>G.filter(le=>le!==x)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx(A.HiXMark,{className:"h-3.5 w-3.5"})})]},x))]}),Zo&&he.length>0&&e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:he.map(x=>e.jsxs("button",{type:"button",onMouseDown:G=>{G.preventDefault(),G.stopPropagation()},onClick:G=>{G.preventDefault(),G.stopPropagation(),ga(x.bql),Zr(!1)},className:"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-2 text-left transition-colors hover:border-[var(--primary)]",children:[e.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:x.bql}),x.description&&e.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:x.description})]},x.bql))}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] pt-3",children:[d&&e.jsxs("button",{type:"button",onClick:ds,className:"inline-flex h-8 items-center gap-1 rounded-md px-2.5 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]",children:[e.jsx(A.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),e.jsxs("button",{type:"button",onClick:()=>cs(Mt),className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-[var(--primary)] px-4 text-xs font-semibold text-[var(--primary-fg)] transition-opacity hover:opacity-90",children:[e.jsx(A.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),cr&&e.jsx("button",{ref:fa,type:"button","aria-haspopup":"menu","aria-expanded":$t,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var G;const x=(G=fa.current)==null?void 0:G.getBoundingClientRect();x&&Dd({top:x.bottom+4,right:window.innerWidth-x.right}),ua(le=>!le)},className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] ${$t?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:e.jsx(A.HiArrowDownTray,{className:"h-4 w-4"})}),O&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":xr&&$r==="visibility","aria-label":ve,title:ve,onClick:x=>fs(x,"visibility"),className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] ${xr&&$r==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:e.jsx(A.HiCog6Tooth,{className:"h-4 w-4"})})]})},Ss=()=>{if(!tu)return null;const d=$l(We,vn);return e.jsxs("div",{"aria-busy":n,className:`grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 rounded-b-xl border-t text-xs select-none ${E?"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:Pr===0?"0 filas":`${au}–${nu} de ${Pr}`}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),e.jsx(Sr,{value:String(lr),onChange:g=>ou(Number(g)),options:ps.map(g=>({value:String(g),label:String(g)})),placeholder:"Filas",searchable:!1,disabled:n,height:z,padding:X,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:H}})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[e.jsx("button",{disabled:n||We<=1,onClick:()=>gn(We-1),onMouseEnter:g=>{g.currentTarget.disabled||(g.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",g.currentTarget.style.color="var(--primary)")},onMouseLeave:g=>{g.currentTarget.style.background="transparent",g.currentTarget.style.color="var(--text-muted)"},className:"cursor-pointer rounded p-0.5 transition-colors disabled:cursor-not-allowed disabled:opacity-30",style:{background:"transparent",color:"var(--text-muted)"},children:e.jsx(A.HiChevronLeft,{className:"h-3.5 w-3.5"})}),d.map((g,F)=>g==="..."?e.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${F}`):e.jsx("button",{disabled:n,onClick:()=>gn(g),onMouseEnter:x=>{x.currentTarget.disabled||g===We||(x.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",x.currentTarget.style.color="var(--primary)")},onMouseLeave:x=>{x.currentTarget.style.background=g===We?"var(--primary)":"transparent",x.currentTarget.style.color=g===We?"var(--primary-fg)":"var(--text-muted)"},className:"h-5 w-5 cursor-pointer rounded text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-60",style:{background:g===We?"var(--primary)":"transparent",color:g===We?"var(--primary-fg)":"var(--text-muted)"},children:g},g)),e.jsx("button",{disabled:n||We>=vn,onClick:()=>gn(We+1),onMouseEnter:g=>{g.currentTarget.disabled||(g.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",g.currentTarget.style.color="var(--primary)")},onMouseLeave:g=>{g.currentTarget.style.background="transparent",g.currentTarget.style.color="var(--text-muted)"},className:"cursor-pointer rounded p-0.5 transition-colors disabled:cursor-not-allowed disabled:opacity-30",style:{background:"transparent",color:"var(--text-muted)"},children:e.jsx(A.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{"aria-hidden":"true"})]})},cu=()=>e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Na},children:[Ca(),Ma(),La(),e.jsx("div",{ref:yr,className:"min-w-0 max-w-full overflow-hidden",children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:At,minWidth:ka},children:[e.jsx("div",{role:"rowgroup",style:L?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Sa()}),e.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,s)}).map((d,g)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:st,borderBottom:`1px solid ${Me}`},children:[ir&&e.jsx("div",{role:"cell",className:`${E?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Me}`,borderRight:`1px solid ${Me}`}},"select-cell"),er.map((F,x)=>e.jsx("div",{role:"cell",className:E?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${Me}`,borderRight:`1px solid ${Me}`},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${ts(g,x)}%`,minWidth:32}})},F.key))]},g))})]})})]}),yn="min-w-0 max-w-full overflow-hidden";return N&&P&&!ke?e.jsx(Ot,{rows:s,columns:Math.max(4,er.length||7)}):!n&&t.length===0&&!cn?cu():n&&t.length===0?e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Na},children:[Ca(),Ma(),La(),e.jsx("div",{ref:yr,className:yn,children:e.jsx(Nn.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:ns,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:At,minWidth:ka},children:[e.jsx("div",{role:"rowgroup",style:L?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Sa()}),e.jsx("div",{role:"rowgroup",children:Array.from({length:s}).map((d,g)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:st,borderBottom:`1px solid ${Me}`},children:[ir&&e.jsx("div",{role:"cell",className:`${E?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Me}`,borderRight:`1px solid ${Me}`}},"select-cell"),er.map((F,x)=>{const G=K&&!dn&&x===0;return e.jsx("div",{role:"cell","data-dt-column-key":F.key,className:E?"px-2 py-1.5":"px-3 py-2",style:G?{position:"sticky",left:hn,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.10), inset 0 -1px 0 ${Me}`,borderRight:`1px solid ${Me}`}:{borderBottom:`1px solid ${Me}`,borderRight:`1px solid ${Me}`},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${ts(g,x)}%`,minWidth:32}})},F.key)})]},g))})]})})}),Ss()]}):!n&&t.length===0?e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Na},children:[Ca(),Ma(),La(),e.jsx("div",{ref:yr,className:yn,children:e.jsx("div",{role:"table",className:"text-sm",style:{width:At,minWidth:ka},children:e.jsx("div",{role:"rowgroup",style:L?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Sa()})})}),e.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-3 border-t px-6 py-12 text-center",style:{borderColor:Me,background:"linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 58%, transparent), var(--bg-card))"},children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full border",style:{borderColor:"color-mix(in srgb, var(--primary) 24%, var(--border))",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-card))",color:"var(--primary)"},children:l??e.jsx(A.HiMagnifyingGlass,{className:"h-5 w-5"})}),e.jsx("p",{className:"max-w-sm text-sm font-medium",style:{color:"var(--text-main)"},children:i}),e.jsx("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Ajusta la busqueda o cambia los filtros para ver mas informacion."})]})]}):e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Na},children:[Ca(),Ma(),La(),e.jsx("div",{ref:yr,className:yn,children:e.jsx(Nn.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:ns,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:At,minWidth:ka},children:[e.jsx("div",{role:"rowgroup",style:L?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Sa()}),e.jsx("div",{role:"rowgroup",children:hs.map((d,g)=>{const F=a(d),x=ws(W==null?void 0:W(d)),G=g>0?ws(W==null?void 0:W(hs[g-1])):null,le=x&&x.key!==(G==null?void 0:G.key),ce=ir&&k.has(F),ge=nt?(b==null?void 0:b(d))??!0:!1,ze=ge&&ms.has(F),Fe=!!u||y&&ge,we=ce&&B?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":g%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return e.jsxs(o.Fragment,{children:[le&&e.jsx("div",{role:"row",className:`grid ${x.className??""}`,style:{gridTemplateColumns:st},children:e.jsx("div",{role:"cell",className:E?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-input))",borderBottom:`1px solid ${Me}`,borderRight:`1px solid ${Me}`},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:x.label}),x.description&&e.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:x.description})]})})})}),e.jsxs("div",{role:"row",onClick:Fe?Ce=>{const Ne=Ce.target;if(!(Ne!=null&&Ne.closest('[data-dt-disable-row-click="true"]'))){if(y&&ge){vs(F);return}u==null||u(d)}}:void 0,className:`grid transition-colors ${Fe?"cursor-pointer":""} ${T?T(d):""}`,style:{gridTemplateColumns:st,"--dt-row-bg":we,"--dt-sticky-bg":we,background:"var(--dt-row-bg)",borderBottom:`1px solid ${Me}`},onMouseEnter:Ce=>{ce||(Ce.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),Ce.currentTarget.style.setProperty("--dt-sticky-bg",su))},onMouseLeave:Ce=>{Ce.currentTarget.style.setProperty("--dt-row-bg",we),Ce.currentTarget.style.setProperty("--dt-sticky-bg",we)},children:[nt&&e.jsx("div",{role:"cell",className:`${E?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${Me}`,borderRight:`1px solid ${Me}`},"data-dt-disable-row-click":"true",children:ge&&e.jsx("button",{type:"button","aria-label":ze?"Contraer fila":"Desplegar fila","aria-expanded":ze,onClick:Ce=>{Ce.stopPropagation(),vs(F)},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]",children:ze?e.jsx(A.HiChevronDown,{className:"h-4 w-4"}):e.jsx(A.HiChevronRight,{className:"h-4 w-4"})})}),ir&&e.jsx("div",{role:"cell",className:`${E?"px-2 py-1.5":"px-3 py-2"} w-10`,style:K?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${Me}`}:{borderBottom:`1px solid ${Me}`,borderRight:`1px solid ${Me}`},onClick:Ce=>{Ce.stopPropagation(),v(F)},children:e.jsx(Ht,{size:"sm",checked:ce,"aria-label":"Seleccionar fila",containerClassName:"items-center",className:"cursor-pointer",onClick:Ce=>Ce.stopPropagation(),onChange:()=>v(F)})}),er.map((Ce,Ne)=>{const Ue=K&&!dn&&Ne===0,ue=Cr(Ce);return e.jsx("div",{role:"cell","data-dt-column-key":Ce.key,"data-dt-disable-row-click":Ce.disableRowClick||ue?"true":void 0,className:`${ue?"px-2 py-1.5 text-center":`${E?"px-2 py-1.5":"px-3 py-2"} ${gs(Ce.align)}`} ${kl} ${Ce.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...Ue?{position:"sticky",left:hn,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Me}`,borderRight:`1px solid ${Me}`}:{borderBottom:`1px solid ${Me}`,borderRight:`1px solid ${Me}`}},children:e.jsx(jn,{children:e.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:Ce.cell(d)})})},Ce.key)})]}),ze&&f&&e.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:st},children:e.jsx("div",{role:"cell",className:E?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--bg-input) 60%, var(--bg-card))",borderBottom:`1px solid ${Me}`},children:f(d)})})]},F)})})]})})}),Ss()]})}const Dl={email:{pattern:/^[^\s@]+@[^\s@]+\.[^\s@]+$/,message:"Correo inválido"},integer:{pattern:/^-?\d+$/,message:"Debe ser un número entero"},date:{pattern:/^\d{4}-\d{2}-\d{2}$/,message:"Fecha inválida"}};function Il(r,t){if(t.minLength!==void 0&&r.length<t.minLength)return t.message??`Mínimo ${t.minLength} caracteres`;if(t.maxLength!==void 0&&r.length>t.maxLength)return t.message??`Máximo ${t.maxLength} caracteres`;if(!r)return null;if(t.preset){const a=Dl[t.preset];if(!a.pattern.test(r))return t.message??a.message}return t.pattern&&!t.pattern.test(r)?t.message??"Formato inválido":null}const Bl=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function Ol({initialValue:r,type:t,mask:a,onCommit:n,onCancel:s}){const[l,i]=o.useState(r),c=o.useRef(null),u=(a==null?void 0:a.preset)==="date",f=u?"date":t==="number"?"number":"text";return o.useEffect(()=>{var b,p;(b=c.current)==null||b.focus(),u||(p=c.current)==null||p.select()},[u]),e.jsx("input",{ref:c,type:f,value:l,maxLength:a==null?void 0:a.maxLength,onChange:b=>i(b.target.value),onBlur:()=>s(),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),n(l)),b.key==="Escape"&&(b.preventDefault(),s()),(a==null?void 0:a.preset)==="integer"&&!b.ctrlKey&&!b.metaKey&&!Bl.has(b.key)&&!/^[\d-]$/.test(b.key)&&b.preventDefault()},onClick:b=>b.stopPropagation(),className:"w-full min-w-0 border-0 bg-transparent p-0 text-sm text-[var(--text-main)] outline-none"})}function Hl({initialValue:r,options:t,loading:a,onCommit:n,onCancel:s}){const l=o.useRef(null);return o.useEffect(()=>{if(a)return;const i=setTimeout(()=>{var c,u;(u=(c=l.current)==null?void 0:c.querySelector("button"))==null||u.click()},0);return()=>clearTimeout(i)},[a]),e.jsx("div",{ref:l,className:"w-full",tabIndex:-1,onKeyDown:i=>{i.key==="Escape"&&(i.stopPropagation(),s())},children:e.jsx(Sr,{value:r,onChange:i=>{n(i)},options:t,disabled:a,placeholder:a?"Cargando…":"Seleccionar…",triggerVariant:"ghost",height:30,padding:"0 6px",minOptionsForSearch:1,className:"w-full"})})}const Pl={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},za={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function Fl({columns:r,data:t,getRowId:a,onCellUpdate:n,readOnly:s=!1,...l}){const[i,c]=o.useState(t),u=o.useRef(null);o.useEffect(()=>{u.current||c(t)},[t]);const[f,b]=o.useState(null);u.current=f;const[p,m]=o.useState(null),w=o.useRef(null);w.current=p;const[y,k]=o.useState({}),[v,C]=o.useState(null),B=o.useRef(null);B.current=v;const[T,W]=o.useState({}),[L,S]=o.useState({}),q=o.useRef(new Set),H=o.useRef(null);o.useEffect(()=>{var O;const $=document.activeElement;(!$||$===document.body)&&((O=H.current)==null||O.focus({preventScroll:!0}))},[]);const z=r.map($=>{var O,re,ee;return`${$.key}:${((ee=(re=(O=$.editable)==null?void 0:O.select)==null?void 0:re.options)==null?void 0:ee.length)??-1}`}).join("|");o.useEffect(()=>{r.forEach($=>{var ee,oe;const O=(oe=(ee=$.editable)==null?void 0:ee.select)==null?void 0:oe.options;if(!O)return;const re=T[$.key];(!q.current.has($.key)||(re==null?void 0:re.length)===0&&O.length>0)&&(q.current.add($.key),W(ie=>({...ie,[$.key]:O})))})},[z]);const X=o.useCallback(async($,O)=>{if(q.current.has($))return;q.current.add($);const{url:re,fetchOptions:ee}=O.select??{};if(!(!re&&!ee)){S(oe=>({...oe,[$]:!0}));try{let oe=[];if(ee)oe=await ee();else if(re){const ie=await fetch(re);if(!ie.ok)throw new Error("fetch failed");oe=await ie.json()}W(ie=>({...ie,[$]:oe}))}catch{W(oe=>({...oe,[$]:[]}))}finally{S(oe=>({...oe,[$]:!1}))}}},[]),Z=o.useRef(i);Z.current=i;const M=o.useRef(n);M.current=n;const U=o.useRef(a);U.current=a;const j=o.useRef(r);j.current=r;const N=o.useRef(s);N.current=s,o.useEffect(()=>{if(r.length>0&&t.length>0){const $=r.find(O=>O.selectable!==!1);$&&m({rowId:a(t[0]),colKey:$.key})}},[]),o.useEffect(()=>{if(!p)return;const $=H.current;if(!$)return;const O=$.querySelector(`[data-cell-id="${p.rowId}:${p.colKey}"]`);if(!O)return;const re=$.querySelector('[role="rowgroup"]');O.style.scrollMarginTop=`${(re==null?void 0:re.offsetHeight)??0}px`;const ee=$.querySelector('[role="row"]');let oe=0;ee&&ee.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(ie=>{ie.style.position==="sticky"&&ie.style.left!==""&&(oe=Math.max(oe,parseFloat(ie.style.left)+ie.offsetWidth))}),O.style.scrollMarginLeft=`${oe}px`,O.scrollIntoView({block:"nearest",inline:"nearest"})},[p]);const K=o.useCallback($=>{var oe;const O=j.current,re=new Set,ee=[];(oe=H.current)==null||oe.querySelectorAll("[data-cell-id]").forEach(ie=>{const ve=ie.dataset.cellId.split(":")[0];re.has(ve)||(re.add(ve),ee.push(ve))}),m(ie=>{if(!ie)return ie;const ve=O.findIndex(D=>D.key===ie.colKey),te=ee.indexOf(ie.rowId);let J=ve,h=te;if($==="up")h=Math.max(0,te-1);else if($==="down")h=Math.min(ee.length-1,te+1);else if($==="left"){let D=ve-1;for(;D>=0&&O[D].selectable===!1;)D--;D>=0&&(J=D)}else if($==="right"){let D=ve+1;for(;D<O.length&&O[D].selectable===!1;)D++;D<O.length&&(J=D)}return J===ve&&h===te?ie:{rowId:ee[h],colKey:O[J].key}})},[]),I=o.useCallback(($=!0)=>{const O=u.current;b(null),O&&m(O),$&&setTimeout(()=>{var re;return(re=H.current)==null?void 0:re.focus({preventScroll:!0})},0)},[]),E=o.useCallback(async($,O,re)=>{var Ve;const ee=j.current.find(xe=>xe.key===O);if(!(ee!=null&&ee.editable))return;const{field:oe,type:ie,mask:ve,validate:te}=ee.editable,J=ie==="number"?re===""?null:Number(re):re;if(ve){const xe=Il(re,ve);if(xe){k(Ae=>({...Ae,[`${$}:${O}`]:xe}));return}}if(te){const xe=te(J);if(xe){k(Ae=>({...Ae,[`${$}:${O}`]:xe}));return}}const h=U.current,D=Z.current.find(xe=>h(xe)===$);if(!D)return;const V=D[oe];b(null),k(xe=>{const Ae={...xe};return delete Ae[`${$}:${O}`],Ae});const ae=Z.current,se=ae.findIndex(xe=>h(xe)===$),he=ae[Math.min(ae.length-1,se+1)];if(m({rowId:h(he),colKey:O}),setTimeout(()=>{var Ae,$e;const xe=document.activeElement;(!xe||xe===document.body||(Ae=H.current)!=null&&Ae.contains(xe))&&(($e=H.current)==null||$e.focus({preventScroll:!0}))},0),String(V??"")===String(J??""))return;const Be={...D,[oe]:J};c(xe=>xe.map(Ae=>h(Ae)===$?Be:Ae)),C({rowId:$,colKey:O});try{await((Ve=M.current)==null?void 0:Ve.call(M,{row:D,rowId:$,field:oe,oldValue:V,newValue:J}))}catch{c(xe=>xe.map(Ae=>h(Ae)===$?D:Ae)),k(xe=>({...xe,[`${$}:${O}`]:"Error al guardar. Intenta de nuevo."}))}finally{C(null)}},[]),R=o.useCallback($=>{if(B.current){$.preventDefault();return}if(u.current)return;const O=w.current;if(!(!O||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes($.key)))switch($.preventDefault(),$.key){case"ArrowUp":K("up");break;case"ArrowDown":K("down");break;case"ArrowLeft":K("left");break;case"ArrowRight":K("right");break;case"Tab":K($.shiftKey?"left":"right");break;case"Enter":{const ee=j.current.find(oe=>oe.key===O.colKey);ee!=null&&ee.editable&&!N.current?(b(O),ee.editable.type==="select"&&!q.current.has(O.colKey)&&X(O.colKey,ee.editable)):K("down");break}}},[K,X]),ne=o.useMemo(()=>r.map($=>{if(!$.editable||s){const re={...$};if(delete re.editable,delete re.selectable,$.selectable===!1)return{...re,disableRowClick:!0};const ee=re.cell;return{...re,className:`relative ${re.className??""}`.trim(),disableRowClick:!0,cell:oe=>{const ie=a(oe),ve=(p==null?void 0:p.rowId)===ie&&(p==null?void 0:p.colKey)===$.key;return e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-cell-id":`${ie}:${$.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var te;B.current||(m({rowId:ie,colKey:$.key}),(te=H.current)==null||te.focus({preventScroll:!0}))}}),ve&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:za}),e.jsx("span",{className:"relative z-0 pointer-events-none",children:ee(oe)})]})}}}const O=$.editable;return{...$,className:`relative ${$.className??""}`.trim(),disableRowClick:!0,cell:re=>{const ee=a(re),oe=$.key,ie=(f==null?void 0:f.rowId)===ee&&(f==null?void 0:f.colKey)===oe,ve=(p==null?void 0:p.rowId)===ee&&(p==null?void 0:p.colKey)===oe,te=y[`${ee}:${oe}`],J=(v==null?void 0:v.rowId)===ee&&(v==null?void 0:v.colKey)===oe,h=re[O.field],D=String(h??""),V=()=>{var se;B.current||(m({rowId:ee,colKey:oe}),b({rowId:ee,colKey:oe}),(se=H.current)==null||se.focus({preventScroll:!0}),O.type==="select"&&!q.current.has(oe)&&X(oe,O))};if(ie){const se=O.type==="select"?e.jsx(Hl,{initialValue:D,options:T[oe]??[],loading:L[oe]??!1,onCommit:he=>E(ee,oe,he),onCancel:I}):e.jsx(Ol,{initialValue:D,type:O.type??"text",mask:O.mask,onCommit:he=>E(ee,oe,he),onCancel:I});return e.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:Pl,onClick:he=>he.stopPropagation(),children:se})}const ae=$.cell(re);return e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-cell-id":`${ee}:${oe}`,className:`peer absolute inset-0 z-10 ${J?"cursor-wait":"cursor-pointer"}`,onClick:V}),ve&&!J&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:za}),J&&e.jsxs("div",{className:"pointer-events-none absolute inset-0 z-20 flex items-center gap-1.5 bg-[var(--bg-card)]/80 px-2",style:za,children:[e.jsx("span",{className:"h-3 w-3 shrink-0 animate-spin rounded-full border-2 border-[var(--text-muted)] border-t-transparent","aria-hidden":!0}),e.jsx("span",{className:"truncate text-xs text-[var(--text-muted)]",children:"Guardando…"})]}),e.jsx("span",{className:"relative z-0 inline-flex items-center gap-1 pointer-events-none",children:te?e.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[e.jsx(A.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate text-xs",children:te})]}):e.jsx("span",{className:"truncate",children:ae})}),!J&&e.jsx(A.HiPencil,{className:"pointer-events-none absolute right-1 top-1/2 z-0 h-3 w-3 -translate-y-1/2 shrink-0 text-[var(--text-muted)] opacity-0 transition-opacity peer-hover:opacity-40"})]})}}}),[r,s,f,p,v,y,T,L,a,E,I,X]);return e.jsx("div",{ref:H,tabIndex:0,onKeyDown:R,onBlur:$=>{var O;(O=H.current)!=null&&O.contains($.relatedTarget)||setTimeout(()=>{var ee,oe;const re=document.activeElement;re&&((ee=re.closest)!=null&&ee.call(re,"[data-bonsaif-select-dropdown]"))||(oe=H.current)!=null&&oe.contains(re)||I(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:e.jsx(Wn,{...l,columns:ne,data:i,getRowId:a})})}function vt(r){return r?new Date(`${r}T12:00:00`):void 0}function qn(r){return r.toISOString().slice(0,10)}function zl({calendarMonth:r,displayIndex:t}){const{previousMonth:a,nextMonth:n,goToMonth:s,months:l,labels:i,formatters:c}=kn.useDayPicker(),u=!!a&&t===0,f=!!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&&s(a),disabled:!u,style:{height:28,width:28,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg-card)",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--text-main)",opacity:u?1:.45,cursor:u?"pointer":"not-allowed"},children:e.jsx(A.HiChevronLeft,{size:16})}),e.jsx("button",{type:"button","aria-label":i.labelNext(n),onClick:()=>n&&s(n),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(A.HiChevronRight,{size:16})})]})}function _l(r){return r.charAt(0).toUpperCase()+r.slice(1)}function jl({startDate:r,endDate:t,onChange:a,minDate:n,viewMonth:s,numberOfMonths:l=1,showSummary:i=!0,startLabel:c="Inicio",endLabel:u="Regreso"}){const f={from:vt(r),to:vt(t)},b=vt(n),[p,m]=o.useState(vt(s||r));return o.useEffect(()=>{m(vt(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(kn.DayPicker,{mode:"range",selected:f,month:p,onMonthChange:m,onSelect:w=>{const y=w!=null&&w.from?qn(w.from):r,k=w!=null&&w.to?qn(w.to):"";a({startDate:y,endDate:k})},numberOfMonths:l,hideNavigation:!0,disabled:b?{before:b}:void 0,showOutsideDays:!1,components:{MonthCaption:zl},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:w=>_l(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(w)),formatWeekdayName:w=>new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(w)},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:[u,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:t})]})]})]})}const Wl="bonsaif-ui:hide-tooltips";function Un(){window.dispatchEvent(new CustomEvent(Wl))}function ql(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Ul({trigger:r,items:t,align:a="end",width:n=220,disabled:s=!1,className:l="",menuClassName:i="",onOpenChange:c}){const[u,f]=o.useState(!1),[b,p]=o.useState(!1),[m,w]=o.useState({}),y=o.useRef(null),k=o.useRef(null),v=o.useCallback(L=>{f(L),c==null||c(L)},[c]),C=o.useCallback(()=>{const L=y.current;if(!L)return;const S=L.getBoundingClientRect(),q=typeof n=="number"?n:S.width,H=typeof n=="number"?n:Math.max(S.width,180),z=a==="end"?Math.max(8,S.right-H):Math.min(S.left,window.innerWidth-H-8),X=window.innerHeight-S.bottom,Z=X<240&&S.top>X?void 0:S.bottom+6,M=Z===void 0?window.innerHeight-S.top+6:void 0;w({position:"fixed",zIndex:9999,left:z,top:Z,bottom:M,width:ql(typeof n=="number"?q:n)})},[a,n]);o.useEffect(()=>p(!0),[]),o.useEffect(()=>{if(!u)return;C();const L=q=>{var z,X;const H=q.target;!((z=y.current)!=null&&z.contains(H))&&!((X=k.current)!=null&&X.contains(H))&&v(!1)},S=q=>{q.key==="Escape"&&v(!1)};return document.addEventListener("mousedown",L),window.addEventListener("keydown",S),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{document.removeEventListener("mousedown",L),window.removeEventListener("keydown",S),window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[u,v,C]);const B=L=>{s||(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),v(!u))},T=o.isValidElement(r)?o.cloneElement(r,{onClick:()=>{s||(Un(),v(!u))}}):r,W=u?e.jsx("div",{ref:k,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${i}`,style:m,children:t.map(L=>e.jsxs("div",{children:[L.separatorBefore&&e.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),e.jsxs("button",{type:"button",role:"menuitem",disabled:L.disabled,onClick:()=>{var S;L.disabled||(Un(),(S=L.onSelect)==null||S.call(L),v(!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:L.danger?"var(--danger)":"var(--text-main)"},children:[L.icon&&e.jsx("span",{className:"mt-0.5 shrink-0",children:L.icon}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm font-medium",children:L.label}),L.description&&e.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:L.description})]})]})]},L.id))}):null;return e.jsxs("span",{ref:y,role:"button",tabIndex:s?-1:0,"aria-haspopup":"menu","aria-expanded":u,onKeyDown:B,className:`inline-flex ${s?"pointer-events-none opacity-60":""} ${l}`,children:[T,b&&W?rr.createPortal(W,document.body):null]})}const Vl=180,Vn="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Gl({open:r,onClose:t,title:a,subtitle:n,leadingIcon:s,confirmLabel:l="Guardar",onConfirm:i,loading:c=!1,confirmDisabled:u=!1,headerActions:f,bodyClassName:b="flex-1 overflow-y-auto px-6 py-5",width:p=440,hasUnsavedChanges:m=!1,unsavedChangesTitle:w="Descartar cambios",unsavedChangesDescription:y="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:k="Descartar",unsavedChangesCancelLabel:v="Seguir editando",onDiscardChanges:C,disabled:B=!1,children:T}){const[W,L]=o.useState(!1),[S,q]=o.useState(!1),[H,z]=o.useState(!1),X=o.useCallback(()=>{q(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>z(!0))})},[]),Z=o.useCallback(()=>{z(!1),window.setTimeout(()=>q(!1),Vl)},[]),M=o.useCallback(()=>{if(m){X();return}t()},[m,t,X]),U=o.useCallback(()=>{z(!1),q(!1),C==null||C(),t()},[t,C]);return o.useEffect(()=>{L(!0)},[]),o.useEffect(()=>(document.body.style.overflow=r?"hidden":"",r||(z(!1),q(!1)),()=>{document.body.style.overflow=""}),[r]),o.useEffect(()=>{if(!r)return;const j=N=>{if(N.key==="Escape"){if(S){Z();return}M()}};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[Z,S,r,M]),W?rr.createPortal(e.jsxs("div",{"aria-hidden":!r,"data-bonsaif-overlay":r?"true":void 0,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 ${Vn}`,onClick:M}),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, ${p}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:M,title:"Cerrar",children:e.jsx(A.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})]})]}),(f||i)&&e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[f,i&&e.jsxs(e.Fragment,{children:[e.jsx(Pe,{variant:"secondary",size:"sm",onClick:M,style:{background:"var(--bg-input)"},children:"Cancelar"}),e.jsx(Pe,{variant:"primary",size:"sm",icon:e.jsx(Ms.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:u,title:l})]})]})]}),e.jsx("div",{"data-drawer-scroll":"true",className:b,children:T})]}),B&&e.jsx("div",{className:"absolute inset-0 z-[1002] cursor-not-allowed",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 60%, transparent)",backdropFilter:"blur(2px)"}}),S&&e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":w,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[e.jsx("div",{className:`absolute inset-0 ${Vn} transition-opacity duration-200 ease-out ${H?"opacity-100":"opacity-0"}`,onClick:Z}),e.jsxs("div",{className:`relative z-10 w-full max-w-sm rounded-2xl border p-6 shadow-2xl transition-[opacity,transform] duration-200 ease-out ${H?"translate-y-0 scale-100 opacity-100":"translate-y-2 scale-[0.96] opacity-0"}`,style:{background:"var(--bg-card, #ffffff)",borderColor:"var(--border, #d8e1dc)"},children:[e.jsx(Pe,{variant:"icon",onClick:Z,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":v,children:e.jsx(A.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:"var(--warning-bg, #fff7ed)"},children:e.jsx(A.HiExclamationTriangle,{className:"h-5 w-5",style:{color:"var(--warning, #d97706)"}})}),e.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main, #0f2f2c)"},children:w}),e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:y}),e.jsxs("div",{className:"mt-6 flex gap-2",children:[e.jsx(Pe,{variant:"secondary",onClick:Z,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:v}),e.jsx(Pe,{variant:"secondary",onClick:U,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:k})]})]})]})]}),document.body):null}const Kl=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Xl=/^\+?[0-9\s().-]+$/,Yl=7,Zl=15;function tr(r){return r==null||String(r).trim()===""}function Gn(r){return typeof r=="number"?r:typeof r=="string"&&r.trim()!==""?Number(r):Number.NaN}function _a(r){return tr(r)?!1:Kl.test(String(r))}function ja(r){if(tr(r))return!1;const t=String(r),a=t.replace(/\D/g,"");return Xl.test(t)&&a.length>=Yl&&a.length<=Zl}function Ql(r="Este campo es requerido."){return t=>tr(t)?r:void 0}function Jl(r="Ingresa un correo valido."){return t=>tr(t)||_a(t)?void 0:r}function Rl(r="Ingresa un telefono valido."){return t=>tr(t)||ja(t)?void 0:r}function ei(r,t){return a=>tr(a)||String(a).length>=r?void 0:t??`Debe tener al menos ${r} caracteres.`}function ri(r,t){return a=>tr(a)||String(a).length<=r?void 0:t??`Debe tener ${r} caracteres o menos.`}function ti(r,t){return a=>{if(tr(a))return;const n=Gn(a);return Number.isFinite(n)&&n>=r?void 0:t??`Debe ser mayor o igual a ${r}.`}}function ai(r,t){return a=>{if(tr(a))return;const n=Gn(a);return Number.isFinite(n)&&n<=r?void 0:t??`Debe ser menor o igual a ${r}.`}}function ni(r,t="El formato no es valido."){return a=>tr(a)||r.test(String(a))?void 0:t}function oi(r,t){const a={};for(const n of Object.keys(t)){const s=t[n];if(!s)continue;const l=Array.isArray(s)?s:[s];for(const i of l){const c=i(r[n],r);if(c){a[n]=c;break}}}return{valid:Object.keys(a).length===0,errors:a}}var Kn={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Xn=o.createContext&&o.createContext(Kn),si=["attr","size","title"];function li(r,t){if(r==null)return{};var a,n,s=ii(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 ii(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 qt(){return qt=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},qt.apply(null,arguments)}function Yn(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 Ut(r){for(var t=1;t<arguments.length;t++){var a=arguments[t]!=null?arguments[t]:{};t%2?Yn(Object(a),!0).forEach(function(n){ci(r,n,a[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(a)):Yn(Object(a)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(a,n))})}return r}function ci(r,t,a){return(t=di(t))in r?Object.defineProperty(r,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[t]=a,r}function di(r){var t=ui(r,"string");return typeof t=="symbol"?t:t+""}function ui(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 Zn(r){return r&&r.map((t,a)=>o.createElement(t.tag,Ut({key:a},t.attr),Zn(t.child)))}function Wa(r){return t=>o.createElement(fi,qt({attr:Ut({},r.attr)},t),Zn(r.child))}function fi(r){var t=a=>{var{attr:n,size:s,title:l}=r,i=li(r,si),c=s||a.size||"1em",u;return a.className&&(u=a.className),r.className&&(u=(u?u+" ":"")+r.className),o.createElement("svg",qt({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,n,i,{className:u,style:Ut(Ut({color:r.color||a.color},a.style),r.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),l&&o.createElement("title",null,l),r.children)};return Xn!==void 0?o.createElement(Xn.Consumer,null,a=>t(a)):t(Kn)}function Qn(r){return Wa({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z"},child:[]}]})(r)}function bi(r){return Wa({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 pi(r){return Wa({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 Vt({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 qa({label:r,containerClassName:t="",helperText:a,error:n,errorDisplay:s="inline",errorTooltipLabel:l="Error de validacion",labelAction:i,floatingLabel:c=!1,showPasswordToggle:u=!0,nativeValidation:f=!1,className:b="",required:p,...m}){const[w,y]=o.useState(()=>!!m.autoFocus),[k,v]=o.useState(!1),C=m.type==="password"&&u,B=C&&k?"text":m.type,T=!!n,W=T&&s!=="tooltip",L=T&&s!=="inline",S=f?p:void 0,q=T?"border-[var(--danger)] focus:border-[var(--danger)]":"",H=L?C?"pr-20":"pr-10":C?"pr-10":"",z=m.value!==void 0?String(m.value).length>0:m.defaultValue!==void 0&&String(m.defaultValue).length>0,X=w||z,Z={top:X?7:12,color:w?"var(--primary)":"var(--text-muted)",fontSize:X?10:13,fontWeight:X?600:400,textTransform:X?"uppercase":"none"},M=K=>{var I;y(!0),(I=m.onFocus)==null||I.call(m,K)},U=K=>{var I;y(!1),(I=m.onBlur)==null||I.call(m,K)},j=C?e.jsxs("button",{type:"button","aria-label":k?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":k,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:()=>v(K=>!K),children:[e.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${k?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:e.jsx(bi,{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 ${k?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:e.jsx(pi,{className:"h-[18px] w-[18px]"})})]}):null,N=L?e.jsx(_r,{as:"span",content:n,className:`absolute top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--danger)] outline-none transition-colors hover:bg-[var(--danger-bg)] focus-visible:bg-[var(--danger-bg)] ${C?"right-10":"right-2.5"}`,children:e.jsx("span",{tabIndex:0,role:"img","aria-label":l,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(Qn,{className:"h-[18px] w-[18px]"})})}):null;return c?e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"relative block",children:[e.jsx(Vt,{...m,type:B,required:S,placeholder:" ","aria-invalid":T||m["aria-invalid"],"data-has-value":z?"true":void 0,className:`h-11 w-full pt-5 ${H} ${q} ${b}`,onFocus:M,onBlur:U}),e.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:Z,children:[r,p&&e.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),i&&e.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:X?7:12},children:i}),N,j]}),W?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}),p&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),i&&e.jsx("span",{className:"ml-auto normal-case",children:i})]}),C?e.jsxs("span",{className:"relative block",children:[e.jsx(Vt,{...m,type:B,required:S,"aria-invalid":T||m["aria-invalid"],className:`w-full ${H} ${q} ${b}`,onFocus:M,onBlur:U}),N,j]}):e.jsxs("span",{className:"relative block",children:[e.jsx(Vt,{...m,required:S,"aria-invalid":T||m["aria-invalid"],className:`w-full ${H} ${q} ${b}`}),N]}),W?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 Jn(r){return r==null?"":String(r)}function mi({autoComplete:r="email",inputMode:t="email",validate:a=!0,invalidMessage:n="Ingresa un correo valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:u,...f}){const[b,p]=o.useState(()=>Jn(c)),m=i!==void 0?Jn(i):b,w=a&&m.length>0&&!_a(m)?n:void 0,y=k=>{i===void 0&&p(k.currentTarget.value),u==null||u(k)};return e.jsx(qa,{...f,value:i,defaultValue:c,type:"text",inputMode:t,autoComplete:r,error:l??w,errorDisplay:s,onChange:y})}const hi={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function vi({title:r="Sin resultados",description:t,icon:a=e.jsx(A.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 ${hi[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]})]})})}const gi={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function xi(r){if(r===0)return"0 B";const t=["B","KB","MB","GB"],a=Math.min(Math.floor(Math.log(r)/Math.log(1024)),t.length-1),n=r/1024**a;return`${n>=10||a===0?n.toFixed(0):n.toFixed(1)} ${t[a]}`}function Rn(r,t){return t?t.split(",").map(a=>a.trim().toLowerCase()).filter(Boolean).some(a=>{const n=r.name.toLowerCase(),s=r.type.toLowerCase();return a.startsWith(".")?n.endsWith(a):a.endsWith("/*")?s.startsWith(a.slice(0,-1)):s===a}):!0}function yi(r,t,a){return t?a===void 0?r:r.slice(0,Math.max(0,a)):r.slice(0,1)}function wi({label:r,helperText:t,error:a,labelAction:n,value:s,defaultValue:l=[],onFilesChange:i,onRejectedFiles:c,multiple:u=!1,maxFiles:f,appendFiles:b=!1,showFileList:p=!0,clearable:m=!0,browseLabel:w="Buscar archivos",dropLabel:y="Suelta los archivos aqui",emptyLabel:k="Arrastra y suelta archivos",emptyDescription:v="o haz click para buscarlos en tu equipo",selectedLabel:C="Archivos seleccionados",size:B="md",containerClassName:T="",dropzoneClassName:W="",fileListClassName:L="",className:S="",id:q,accept:H,disabled:z,required:X,...Z}){const M=o.useId(),U=q??M,j=o.useRef(null),[N,K]=o.useState(!1),[I,E]=o.useState(l),R=s??I,ne=!!a,$=m&&R.length>0&&!z,O=(V,ae)=>{s===void 0&&E(V),i==null||i(V,ae)},re=(V,ae)=>{const se=V.filter(xe=>Rn(xe,H)),he=V.filter(xe=>!Rn(xe,H)),Be=b?[...R,...se]:se,Ve=yi(Be,u,f);he.length>0&&(c==null||c(he)),O(Ve,ae)},ee=()=>{var V;z||(V=j.current)==null||V.click()},oe=V=>{re(Array.from(V.target.files??[]),V),V.target.value=""},ie=V=>{V.preventDefault(),z||K(!0)},ve=V=>{V.currentTarget.contains(V.relatedTarget)||K(!1)},te=V=>{V.preventDefault(),K(!1),!z&&re(Array.from(V.dataTransfer.files),V)},J=V=>{V.key!=="Enter"&&V.key!==" "||(V.preventDefault(),ee())},h=V=>{O(R.filter((ae,se)=>se!==V))},D=()=>{O([])};return e.jsxs("div",{className:`flex flex-col gap-2 ${T}`,children:[(r||n)&&e.jsxs("div",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[r&&e.jsx("span",{children:r}),X&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),n&&e.jsx("span",{className:"ml-auto normal-case",children:n})]}),e.jsx("input",{...Z,ref:j,id:U,type:"file",accept:H,multiple:u,disabled:z,required:X&&R.length===0,"aria-invalid":ne||Z["aria-invalid"],className:"sr-only",onChange:oe}),e.jsxs("div",{role:"button",tabIndex:z?-1:0,"aria-controls":U,"aria-disabled":z||void 0,"aria-invalid":ne||void 0,className:`flex cursor-pointer flex-col items-center justify-center gap-3 rounded-lg border border-dashed bg-[var(--bg-card)] text-center outline-none transition-colors focus:border-[var(--primary)] focus:bg-[var(--bg-input)] ${gi[B]} ${N?"border-[var(--primary)] bg-[var(--bg-input)]":ne?"border-[var(--danger)]":"border-[var(--border)]"} ${z?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${W} ${S}`,onClick:ee,onDragOver:ie,onDragLeave:ve,onDrop:te,onKeyDown:J,children:[e.jsx("span",{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:e.jsx(A.HiArrowUpTray,{className:"h-5 w-5"})}),e.jsxs("span",{className:"space-y-1",children:[e.jsx("span",{className:"block text-sm font-semibold text-[var(--text-main)]",children:N?y:k}),v&&e.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:v})]}),w&&e.jsx("span",{className:"inline-flex h-9 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] px-3 text-xs font-semibold text-[var(--text-main)] shadow-sm shadow-black/5 transition-colors",children:w})]}),p&&R.length>0&&e.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${L}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase text-[var(--text-muted)]",children:C}),$&&e.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":"Quitar todos los archivos",onClick:D,children:e.jsx(A.HiTrash,{className:"h-4 w-4"})})]}),e.jsx("ul",{className:"divide-y divide-[var(--border)]",children:R.map((V,ae)=>e.jsxs("li",{className:"flex items-center gap-3 px-3 py-2",children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-[var(--bg-input)] text-[var(--text-muted)]",children:e.jsx(A.HiDocument,{className:"h-4 w-4"})}),e.jsxs("span",{className:"min-w-0 flex-1 text-left",children:[e.jsx("span",{className:"block truncate text-sm font-medium text-[var(--text-main)]",children:V.name}),e.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:xi(V.size)})]}),!z&&e.jsx("button",{type:"button",className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":`Quitar ${V.name}`,onClick:()=>h(ae),children:e.jsx(A.HiXMark,{className:"h-4 w-4"})})]},`${V.name}-${V.lastModified}-${ae}`))})]}),a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:a}):t?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:t}):null]})}const Ni=[{value:"texto",label:"texto"},{value:"numero",label:"número"},{value:"fecha",label:"fecha"},{value:"booleano",label:"booleano"},{value:"email",label:"email"},{value:"telefono",label:"teléfono"},{value:"select",label:"select"},{value:"textarea",label:"textarea"},{value:"archivo",label:"archivo"},{value:"imagen",label:"imagen"}];function ki({fields:r,title:t="Layout",fieldTypes:a=Ni,saveLabel:n="Guardar",allowAddField:s=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:u,onChange:f}){const[b,p]=o.useState(()=>r.map(T=>({key:!1,type:"",...T}))),[m,w]=o.useState(""),[y,k]=o.useState(""),v=o.useCallback((T,W)=>{p(L=>{const S=L.map((q,H)=>H===T?{...q,...W}:q);return f==null||f(S),S})},[f]),C=o.useCallback(()=>{u==null||u(b)},[b,u]),B=o.useCallback(()=>{var S;const T=m.trim();if(!T){k("Ingresa un nombre de campo.");return}if(b.some(q=>q.name.toLowerCase()===T.toLowerCase())){k("Ese campo ya existe en el arreglo.");return}const L={name:T,key:!1,type:((S=a[0])==null?void 0:S.value)??""};p(q=>{const H=[...q,L];return f==null||f(H),H}),w(""),k("")},[a,b,m,f]);return e.jsxs("div",{className:"flex flex-col rounded-xl border shadow-sm",style:{borderColor:"var(--border)",background:"var(--bg-card)",color:"var(--text-main)"},children:[e.jsx("div",{className:"border-b px-6 py-4",style:{borderColor:"var(--border)"},children:e.jsx("span",{className:"text-base font-semibold",style:{color:"var(--text-main)"},children:t})}),e.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] gap-4 border-b px-6 py-2 text-xs font-medium uppercase tracking-wide",style:{borderColor:"var(--border)",color:"var(--text-muted)"},children:[e.jsx("span",{children:"Campo"}),e.jsx("span",{className:"text-center",children:"Llave"}),e.jsx("span",{children:"Tipo de Campo"})]}),e.jsxs("div",{className:"max-h-[420px] overflow-y-auto",children:[b.map((T,W)=>e.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] items-center gap-4 border-b px-6 py-3 last:border-0 hover:bg-[var(--bg-input)] transition-colors",style:{borderColor:"var(--border)"},children:[e.jsx("span",{className:"text-sm font-medium",style:{color:"var(--text-main)"},children:T.name}),e.jsx("div",{className:"flex justify-center",children:e.jsx(Ht,{size:"sm",checked:T.key??!1,onChange:L=>v(W,{key:L.target.checked}),"aria-label":`${T.name} es clave`})}),e.jsx(Sr,{value:T.type??"",onChange:L=>v(W,{type:L}),options:a,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${T.name}`})]},T.name)),b.length===0&&e.jsx("p",{className:"px-6 py-8 text-center text-sm",style:{color:"var(--text-muted)"},children:"No hay campos disponibles."})]}),e.jsx("div",{className:"flex justify-end border-t px-6 py-4",style:{borderColor:"var(--border)"},children:e.jsxs("div",{className:"w-full space-y-2",children:[s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:m,onChange:T=>{w(T.currentTarget.value),y&&k("")},onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),B())},placeholder:l,className:"min-w-0 flex-1 rounded-lg border px-3 py-2 text-sm outline-none transition-colors",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"},"aria-label":"Nombre del nuevo campo"}),e.jsx(Pe,{variant:"secondary",onClick:B,height:36,padding:"0 12px",children:i})]}),y&&e.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:y})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(Pe,{variant:"primary",onClick:C,disabled:c,loading:c,children:n})})]})})]})}function eo({label:r,children:t,helperText:a,error:n,labelAction:s,required:l=!1,className:i="",contentClassName:c=""}){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 ${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]})}function ro(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function to(r,t){if(r.length!==t.length)return!1;const a=new Set(t);return r.every(n=>a.has(n))}function Ua(r){return r.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Si(r,t){if(!t)return!0;const a=Ua(t);return Ua(r.label).includes(a)||!!(r.sublabel&&Ua(r.sublabel).includes(a))}function Ci({value:r,onChange:t,options:a,placeholder:n="Seleccionar…",disabled:s=!1,className:l="",style:i,height:c=40,padding:u="6px 10px",searchable:f=!0,minOptionsForSearch:b=6,maxVisibleValues:p=2,truncateSelectedValues:m=!0,emptyText:w="Sin resultados",clearLabel:y="Limpiar seleccion",pruneMissingValues:k=!0}){const[v,C]=o.useState(!1),[B,T]=o.useState(""),[W,L]=o.useState(0),[S,q]=o.useState(!1),[H,z]=o.useState({}),X=o.useRef(null),Z=o.useRef(null),M=o.useRef(null),U=o.useRef(null),j=f&&a.length>=b,N=o.useMemo(()=>new Set(r),[r]),K=o.useMemo(()=>{const h=new Map;for(const D of a)h.set(D.value,D);return h},[a]),I=o.useMemo(()=>{const h=[];for(const D of r){const V=K.get(D);V&&h.push(V)}return h},[K,r]),E=p==="all"?I.length:p,R=I.slice(0,E),ne=Math.max(0,I.length-R.length),$=o.useMemo(()=>{const h=B.trim();return!j||!h?a:a.filter(D=>Si(D,h))},[a,B,j]),O=o.useCallback(()=>{const h=X.current;if(!h)return;const D=h.getBoundingClientRect(),V=j?304:244,ae=window.innerHeight-D.bottom,se=ae<V&&D.top>ae;z({position:"fixed",left:D.left,top:se?void 0:D.bottom+4,bottom:se?window.innerHeight-D.top+4:void 0,width:Math.max(D.width,240),zIndex:9999})},[j]),re=o.useCallback(h=>{to(r,h)||t(h)},[t,r]),ee=o.useCallback(h=>{const D=K.get(h);if(D!=null&&D.disabled)return;const V=N.has(h)?r.filter(ae=>ae!==h):[...r,h];re(V)},[re,K,r,N]),oe=o.useCallback(()=>re([]),[re]),ie=o.useCallback(()=>{C(!1),T(""),L(0)},[]);o.useEffect(()=>q(!0),[]);const ve=o.useMemo(()=>a.map(h=>h.value).join("\0"),[a]);o.useEffect(()=>{if(!k||r.length===0||a.length===0)return;const h=new Set(a.map(V=>V.value)),D=r.filter(V=>h.has(V));to(r,D)||t(D)},[ve]),o.useEffect(()=>{if(!v)return;function h(D){var ae,se;const V=D.target;!((ae=X.current)!=null&&ae.contains(V))&&!((se=Z.current)!=null&&se.contains(V))&&ie()}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[ie,v]),o.useEffect(()=>{v&&(L(0),O(),j&&setTimeout(()=>{var h;return(h=M.current)==null?void 0:h.focus()},0))},[v,j,O]),o.useEffect(()=>{if(v)return window.addEventListener("resize",O),window.addEventListener("scroll",O,!0),()=>{window.removeEventListener("resize",O),window.removeEventListener("scroll",O,!0)}},[v,O]),o.useEffect(()=>{if($.length===0){L(0);return}L(h=>Math.min(h,$.length-1))},[$.length]),o.useEffect(()=>{if(W<0||!U.current)return;const h=U.current.children[W];h==null||h.scrollIntoView({block:"nearest"})},[W]);function te(h){if(!s){if(!v){(h.key==="Enter"||h.key===" "||h.key==="ArrowDown")&&(h.preventDefault(),C(!0));return}if(h.key==="Escape"){h.preventDefault(),ie();return}if(h.key==="ArrowDown"){if(h.preventDefault(),$.length===0)return;L(D=>Math.min(D+1,$.length-1));return}if(h.key==="ArrowUp"){h.preventDefault(),L(D=>Math.max(D-1,0));return}if(h.key==="Enter"&&$[W]&&!$[W].disabled){h.preventDefault(),ee($[W].value);return}h.key==="Backspace"&&!B&&r.length&&(h.preventDefault(),re(r.slice(0,-1)))}}const J=e.jsxs("div",{ref:Z,className:"overflow-hidden rounded-xl shadow-xl",style:{...H,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[j&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(A.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:M,value:B,onChange:h=>{T(h.target.value),L(0)},onKeyDown:h=>{(h.key==="ArrowDown"||h.key==="ArrowUp"||h.key==="Enter"||h.key==="Escape")&&(h.stopPropagation(),te(h))},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","aria-label":"Limpiar búsqueda",onMouseDown:h=>{h.preventDefault(),T(""),L(0)},children:e.jsx(A.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),r.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:[I.length," seleccionados",r.length>I.length?` (${r.length-I.length} no disponibles)`:""]}),e.jsx("button",{type:"button",onMouseDown:h=>{h.preventDefault(),oe()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:y})]}),e.jsxs("ul",{ref:U,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:j?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[$.map((h,D)=>{const V=D===W,ae=N.has(h.value);return e.jsxs("li",{role:"option","aria-selected":ae,onMouseDown:se=>{se.preventDefault(),!h.disabled&&ee(h.value)},onMouseEnter:()=>!h.disabled&&L(D),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:V?"var(--bg-hover)":ae?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:h.disabled?"var(--text-muted)":"var(--text-main)",cursor:h.disabled?"not-allowed":"pointer",opacity:h.disabled?.58:1},children:[e.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:ae?"var(--primary)":"var(--border)",background:ae?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:ae&&e.jsx(A.HiCheck,{className:"h-3 w-3"})}),h.color&&e.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:h.color}}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:h.label}),h.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:h.sublabel})]}),h.badge&&e.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:h.badge})]},h.value)}),$.length===0&&e.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:w})]})]});return e.jsxs("div",{ref:X,className:`relative ${l||"w-full"}`,style:i,onKeyDown:te,children:[e.jsxs("button",{type:"button",disabled:s,onClick:()=>{s||(v?ie():C(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:ro(c),padding:ro(u),background:"var(--bg-input)",color:I.length?"var(--text-main)":"var(--text-muted)",border:v?"1px solid var(--primary)":"1px solid var(--border)",opacity:s?.5:1,cursor:s?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":v,children:[e.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:R.length?e.jsxs(e.Fragment,{children:[R.map(h=>e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${m?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[h.color&&e.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:h.color}}),e.jsx("span",{className:m?"truncate":"break-words",children:h.label}),e.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${h.label}`,onMouseDown:D=>{D.preventDefault(),D.stopPropagation(),ee(h.value)},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(A.HiXMark,{className:"h-3 w-3"})})]},h.value)),ne>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:["+",ne]})]}):e.jsx("span",{className:"truncate",children:n})}),I.length?e.jsx("span",{role:"button",tabIndex:-1,"aria-label":y,onMouseDown:h=>{h.preventDefault(),h.stopPropagation(),oe()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(A.HiXMark,{className:"h-3.5 w-3.5"})}):e.jsx(A.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:v?"rotate(180deg)":"rotate(0deg)"}})]}),v&&S&&rr.createPortal(J,document.body)]})}function Ei({inputMode:r="decimal",...t}){return e.jsx(qa,{...t,type:"number",inputMode:r})}function Mi(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 Li({page:r,totalPages:t,onPageChange:a,disabled:n=!1,siblingCount:s=1,className:l=""}){const i=Math.max(1,t),c=Math.min(Math.max(1,r),i),u=Mi(c,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||c<=1,onClick:()=>a(c-1),children:e.jsx(A.HiChevronLeft,{className:"h-4 w-4"})}),u.map((f,b)=>f==="..."?e.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${b}`):e.jsx("button",{type:"button","aria-current":f===c?"page":void 0,disabled:n,onClick:()=>a(f),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:f===c?"var(--primary)":"var(--border)",background:f===c?"var(--primary)":"var(--bg-card)",color:f===c?"var(--primary-fg)":"var(--text-secondary)"},children:f},f)),e.jsx(Pe,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:n||c>=i,onClick:()=>a(c+1),children:e.jsx(A.HiChevronRight,{className:"h-4 w-4"})})]})}const ao=[{value:"+1",label:"+1",sublabel:"Estados Unidos, Canada, Caribe"},{value:"+7",label:"+7",sublabel:"Rusia, Kazajistan"},{value:"+20",label:"+20",sublabel:"Egipto"},{value:"+27",label:"+27",sublabel:"Sudafrica"},{value:"+30",label:"+30",sublabel:"Grecia"},{value:"+31",label:"+31",sublabel:"Paises Bajos"},{value:"+32",label:"+32",sublabel:"Belgica"},{value:"+33",label:"+33",sublabel:"Francia"},{value:"+34",label:"+34",sublabel:"Espana"},{value:"+36",label:"+36",sublabel:"Hungria"},{value:"+39",label:"+39",sublabel:"Italia, Vaticano"},{value:"+40",label:"+40",sublabel:"Rumania"},{value:"+41",label:"+41",sublabel:"Suiza"},{value:"+43",label:"+43",sublabel:"Austria"},{value:"+44",label:"+44",sublabel:"Reino Unido"},{value:"+45",label:"+45",sublabel:"Dinamarca"},{value:"+46",label:"+46",sublabel:"Suecia"},{value:"+47",label:"+47",sublabel:"Noruega"},{value:"+48",label:"+48",sublabel:"Polonia"},{value:"+49",label:"+49",sublabel:"Alemania"},{value:"+51",label:"+51",sublabel:"Peru"},{value:"+52",label:"+52",sublabel:"Mexico"},{value:"+53",label:"+53",sublabel:"Cuba"},{value:"+54",label:"+54",sublabel:"Argentina"},{value:"+55",label:"+55",sublabel:"Brasil"},{value:"+56",label:"+56",sublabel:"Chile"},{value:"+57",label:"+57",sublabel:"Colombia"},{value:"+58",label:"+58",sublabel:"Venezuela"},{value:"+60",label:"+60",sublabel:"Malasia"},{value:"+61",label:"+61",sublabel:"Australia"},{value:"+62",label:"+62",sublabel:"Indonesia"},{value:"+63",label:"+63",sublabel:"Filipinas"},{value:"+64",label:"+64",sublabel:"Nueva Zelanda"},{value:"+65",label:"+65",sublabel:"Singapur"},{value:"+66",label:"+66",sublabel:"Tailandia"},{value:"+81",label:"+81",sublabel:"Japon"},{value:"+82",label:"+82",sublabel:"Corea del Sur"},{value:"+84",label:"+84",sublabel:"Vietnam"},{value:"+86",label:"+86",sublabel:"China"},{value:"+90",label:"+90",sublabel:"Turquia"},{value:"+91",label:"+91",sublabel:"India"},{value:"+92",label:"+92",sublabel:"Pakistan"},{value:"+93",label:"+93",sublabel:"Afganistan"},{value:"+94",label:"+94",sublabel:"Sri Lanka"},{value:"+95",label:"+95",sublabel:"Myanmar"},{value:"+98",label:"+98",sublabel:"Iran"},{value:"+211",label:"+211",sublabel:"Sudan del Sur"},{value:"+212",label:"+212",sublabel:"Marruecos, Sahara Occidental"},{value:"+213",label:"+213",sublabel:"Argelia"},{value:"+216",label:"+216",sublabel:"Tunez"},{value:"+218",label:"+218",sublabel:"Libia"},{value:"+220",label:"+220",sublabel:"Gambia"},{value:"+221",label:"+221",sublabel:"Senegal"},{value:"+222",label:"+222",sublabel:"Mauritania"},{value:"+223",label:"+223",sublabel:"Mali"},{value:"+224",label:"+224",sublabel:"Guinea"},{value:"+225",label:"+225",sublabel:"Costa de Marfil"},{value:"+226",label:"+226",sublabel:"Burkina Faso"},{value:"+227",label:"+227",sublabel:"Niger"},{value:"+228",label:"+228",sublabel:"Togo"},{value:"+229",label:"+229",sublabel:"Benin"},{value:"+230",label:"+230",sublabel:"Mauricio"},{value:"+231",label:"+231",sublabel:"Liberia"},{value:"+232",label:"+232",sublabel:"Sierra Leona"},{value:"+233",label:"+233",sublabel:"Ghana"},{value:"+234",label:"+234",sublabel:"Nigeria"},{value:"+235",label:"+235",sublabel:"Chad"},{value:"+236",label:"+236",sublabel:"Republica Centroafricana"},{value:"+237",label:"+237",sublabel:"Camerun"},{value:"+238",label:"+238",sublabel:"Cabo Verde"},{value:"+239",label:"+239",sublabel:"Santo Tome y Principe"},{value:"+240",label:"+240",sublabel:"Guinea Ecuatorial"},{value:"+241",label:"+241",sublabel:"Gabon"},{value:"+242",label:"+242",sublabel:"Republica del Congo"},{value:"+243",label:"+243",sublabel:"Republica Democratica del Congo"},{value:"+244",label:"+244",sublabel:"Angola"},{value:"+245",label:"+245",sublabel:"Guinea-Bisau"},{value:"+246",label:"+246",sublabel:"Territorio Britanico del Oceano Indico"},{value:"+248",label:"+248",sublabel:"Seychelles"},{value:"+249",label:"+249",sublabel:"Sudan"},{value:"+250",label:"+250",sublabel:"Ruanda"},{value:"+251",label:"+251",sublabel:"Etiopia"},{value:"+252",label:"+252",sublabel:"Somalia"},{value:"+253",label:"+253",sublabel:"Yibuti"},{value:"+254",label:"+254",sublabel:"Kenia"},{value:"+255",label:"+255",sublabel:"Tanzania"},{value:"+256",label:"+256",sublabel:"Uganda"},{value:"+257",label:"+257",sublabel:"Burundi"},{value:"+258",label:"+258",sublabel:"Mozambique"},{value:"+260",label:"+260",sublabel:"Zambia"},{value:"+261",label:"+261",sublabel:"Madagascar"},{value:"+262",label:"+262",sublabel:"Reunion, Mayotte"},{value:"+263",label:"+263",sublabel:"Zimbabue"},{value:"+264",label:"+264",sublabel:"Namibia"},{value:"+265",label:"+265",sublabel:"Malaui"},{value:"+266",label:"+266",sublabel:"Lesoto"},{value:"+267",label:"+267",sublabel:"Botsuana"},{value:"+268",label:"+268",sublabel:"Esuatini"},{value:"+269",label:"+269",sublabel:"Comoras"},{value:"+290",label:"+290",sublabel:"Santa Elena"},{value:"+291",label:"+291",sublabel:"Eritrea"},{value:"+297",label:"+297",sublabel:"Aruba"},{value:"+298",label:"+298",sublabel:"Islas Feroe"},{value:"+299",label:"+299",sublabel:"Groenlandia"},{value:"+350",label:"+350",sublabel:"Gibraltar"},{value:"+351",label:"+351",sublabel:"Portugal"},{value:"+352",label:"+352",sublabel:"Luxemburgo"},{value:"+353",label:"+353",sublabel:"Irlanda"},{value:"+354",label:"+354",sublabel:"Islandia"},{value:"+355",label:"+355",sublabel:"Albania"},{value:"+356",label:"+356",sublabel:"Malta"},{value:"+357",label:"+357",sublabel:"Chipre"},{value:"+358",label:"+358",sublabel:"Finlandia, Aland"},{value:"+359",label:"+359",sublabel:"Bulgaria"},{value:"+370",label:"+370",sublabel:"Lituania"},{value:"+371",label:"+371",sublabel:"Letonia"},{value:"+372",label:"+372",sublabel:"Estonia"},{value:"+373",label:"+373",sublabel:"Moldavia"},{value:"+374",label:"+374",sublabel:"Armenia"},{value:"+375",label:"+375",sublabel:"Bielorrusia"},{value:"+376",label:"+376",sublabel:"Andorra"},{value:"+377",label:"+377",sublabel:"Monaco"},{value:"+378",label:"+378",sublabel:"San Marino"},{value:"+380",label:"+380",sublabel:"Ucrania"},{value:"+381",label:"+381",sublabel:"Serbia"},{value:"+382",label:"+382",sublabel:"Montenegro"},{value:"+383",label:"+383",sublabel:"Kosovo"},{value:"+385",label:"+385",sublabel:"Croacia"},{value:"+386",label:"+386",sublabel:"Eslovenia"},{value:"+387",label:"+387",sublabel:"Bosnia y Herzegovina"},{value:"+389",label:"+389",sublabel:"Macedonia del Norte"},{value:"+420",label:"+420",sublabel:"Chequia"},{value:"+421",label:"+421",sublabel:"Eslovaquia"},{value:"+423",label:"+423",sublabel:"Liechtenstein"},{value:"+500",label:"+500",sublabel:"Islas Malvinas"},{value:"+501",label:"+501",sublabel:"Belice"},{value:"+502",label:"+502",sublabel:"Guatemala"},{value:"+503",label:"+503",sublabel:"El Salvador"},{value:"+504",label:"+504",sublabel:"Honduras"},{value:"+505",label:"+505",sublabel:"Nicaragua"},{value:"+506",label:"+506",sublabel:"Costa Rica"},{value:"+507",label:"+507",sublabel:"Panama"},{value:"+508",label:"+508",sublabel:"San Pedro y Miquelon"},{value:"+509",label:"+509",sublabel:"Haiti"},{value:"+590",label:"+590",sublabel:"Guadalupe, San Bartolome"},{value:"+591",label:"+591",sublabel:"Bolivia"},{value:"+592",label:"+592",sublabel:"Guyana"},{value:"+593",label:"+593",sublabel:"Ecuador"},{value:"+594",label:"+594",sublabel:"Guayana Francesa"},{value:"+595",label:"+595",sublabel:"Paraguay"},{value:"+596",label:"+596",sublabel:"Martinica"},{value:"+597",label:"+597",sublabel:"Surinam"},{value:"+598",label:"+598",sublabel:"Uruguay"},{value:"+599",label:"+599",sublabel:"Caribe Neerlandes, Curazao"},{value:"+670",label:"+670",sublabel:"Timor Oriental"},{value:"+672",label:"+672",sublabel:"Antartida, Isla Norfolk"},{value:"+673",label:"+673",sublabel:"Brunei"},{value:"+674",label:"+674",sublabel:"Nauru"},{value:"+675",label:"+675",sublabel:"Papua Nueva Guinea"},{value:"+676",label:"+676",sublabel:"Tonga"},{value:"+677",label:"+677",sublabel:"Islas Salomon"},{value:"+678",label:"+678",sublabel:"Vanuatu"},{value:"+679",label:"+679",sublabel:"Fiyi"},{value:"+680",label:"+680",sublabel:"Palaos"},{value:"+681",label:"+681",sublabel:"Wallis y Futuna"},{value:"+682",label:"+682",sublabel:"Islas Cook"},{value:"+683",label:"+683",sublabel:"Niue"},{value:"+685",label:"+685",sublabel:"Samoa"},{value:"+686",label:"+686",sublabel:"Kiribati"},{value:"+687",label:"+687",sublabel:"Nueva Caledonia"},{value:"+688",label:"+688",sublabel:"Tuvalu"},{value:"+689",label:"+689",sublabel:"Polinesia Francesa"},{value:"+690",label:"+690",sublabel:"Tokelau"},{value:"+691",label:"+691",sublabel:"Micronesia"},{value:"+692",label:"+692",sublabel:"Islas Marshall"},{value:"+850",label:"+850",sublabel:"Corea del Norte"},{value:"+852",label:"+852",sublabel:"Hong Kong"},{value:"+853",label:"+853",sublabel:"Macao"},{value:"+855",label:"+855",sublabel:"Camboya"},{value:"+856",label:"+856",sublabel:"Laos"},{value:"+880",label:"+880",sublabel:"Banglades"},{value:"+886",label:"+886",sublabel:"Taiwan"},{value:"+960",label:"+960",sublabel:"Maldivas"},{value:"+961",label:"+961",sublabel:"Libano"},{value:"+962",label:"+962",sublabel:"Jordania"},{value:"+963",label:"+963",sublabel:"Siria"},{value:"+964",label:"+964",sublabel:"Irak"},{value:"+965",label:"+965",sublabel:"Kuwait"},{value:"+966",label:"+966",sublabel:"Arabia Saudita"},{value:"+967",label:"+967",sublabel:"Yemen"},{value:"+968",label:"+968",sublabel:"Oman"},{value:"+970",label:"+970",sublabel:"Palestina"},{value:"+971",label:"+971",sublabel:"Emiratos Arabes Unidos"},{value:"+972",label:"+972",sublabel:"Israel"},{value:"+973",label:"+973",sublabel:"Barein"},{value:"+974",label:"+974",sublabel:"Catar"},{value:"+975",label:"+975",sublabel:"Butan"},{value:"+976",label:"+976",sublabel:"Mongolia"},{value:"+977",label:"+977",sublabel:"Nepal"},{value:"+992",label:"+992",sublabel:"Tayikistan"},{value:"+993",label:"+993",sublabel:"Turkmenistan"},{value:"+994",label:"+994",sublabel:"Azerbaiyan"},{value:"+995",label:"+995",sublabel:"Georgia"},{value:"+996",label:"+996",sublabel:"Kirguistan"},{value:"+998",label:"+998",sublabel:"Uzbekistan"}];function no(r){return r==null?"":String(r)}function Gt(r){return r?r.startsWith("+")?r:`+${r}`:"+1"}function $i(r){return typeof r=="number"?`${r}px`:r}function Ti({autoComplete:r="tel",inputMode:t="tel",validate:a=!0,invalidMessage:n="Ingresa un telefono valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:u,countryCode:f,defaultCountryCode:b="+1",onCountryCodeChange:p,allowedCountryCodes:m,countryCodeOptions:w,countryCodePlaceholder:y="Codigo",countryCodeClassName:k="",countryCodeWidth:v=84,onPhoneValueChange:C,label:B,containerClassName:T="",helperText:W,labelAction:L,className:S="",required:q,disabled:H,floatingLabel:z,showPasswordToggle:X,nativeValidation:Z,errorTooltipLabel:M="Error de validacion",...U}){var V;const[j,N]=o.useState(()=>no(c)),[K,I]=o.useState(()=>Gt(b)),E=o.useMemo(()=>{const ae=w??ao,se=m==null?void 0:m.map(Gt);return se!=null&&se.length?ae.filter(he=>se.includes(he.value)):ae},[m,w]),R=((V=E[0])==null?void 0:V.value)??"+1",ne=E.some(ae=>ae.value===Gt(f??K))?Gt(f??K):R,$=i!==void 0?no(i):j,O=`${ne} ${$}`.trim(),re=a&&$.length>0&&!ja(O)?n:void 0,ee=l??re,oe=!!ee,ie=oe&&s!=="tooltip",ve=oe&&s!=="inline",te=oe?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",J=ae=>{const se=ae.currentTarget.value;i===void 0&&N(se),C==null||C(se,{countryCode:ne,nationalNumber:se,fullNumber:`${ne} ${se}`.trim()}),u==null||u(ae)},h=ae=>{f===void 0&&I(ae),p==null||p(ae),C==null||C($,{countryCode:ae,nationalNumber:$,fullNumber:`${ae} ${$}`.trim()})},D=ve?e.jsx(_r,{as:"span",content:ee,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(--danger)] outline-none transition-colors hover:bg-[var(--danger-bg)] focus-visible:bg-[var(--danger-bg)]",children:e.jsx("span",{tabIndex:0,role:"img","aria-label":M,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(Qn,{className:"h-[18px] w-[18px]"})})}):null;return e.jsxs("div",{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:B}),q&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),L&&e.jsx("span",{className:"ml-auto normal-case",children:L})]}),e.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${te}`,children:[e.jsx(Sr,{value:ne,onChange:h,options:E,placeholder:y,disabled:H,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${k}`,style:{width:$i(v)},height:38,padding:"0 8px 0 10px"}),e.jsx("span",{className:"h-5 w-px shrink-0 bg-[var(--border)]"}),e.jsxs("span",{className:"relative min-w-0 flex-1 self-stretch",children:[e.jsx("input",{...U,value:i,defaultValue:c,type:"tel",inputMode:t,autoComplete:r,disabled:H,required:void 0,"aria-label":U["aria-label"]??(typeof B=="string"?B:void 0),"aria-invalid":oe||U["aria-invalid"],className:`h-full w-full min-w-0 bg-transparent px-2 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed disabled:opacity-60 ${ve?"pr-10":""} ${S}`,onChange:J}),D]})]}),ie?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:ee}):W?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:W}):null]})}function Ai({value:r,onChange:t,options:a,name:n,label:s,orientation:l="vertical",disabled:i=!1,className:c="",optionClassName:u=""}){return e.jsxs("fieldset",{className:`min-w-0 ${c}`,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(f=>{const b=f.value===r,p=i||f.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 ${p?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${u}`,style:{borderColor:b?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:b?"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:f.value,checked:b,disabled:p,onChange:()=>t(f.value),className:"absolute inset-0 opacity-0"}),e.jsx("span",{className:`h-2 w-2 rounded-full transition ${b?"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:f.label}),f.description&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:f.description})]})]},f.value)})})]})}const oo=()=>'<button type="button" class="rich-img-del" data-action="delete-img" title="Eliminar imagen"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M9 2a1 1 0 0 0-.894.553L7.382 4H4a1 1 0 0 0 0 2v10a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V6a1 1 0 0 0 0-2h-3.382l-.724-1.447A1 1 0 0 0 11 2H9zm-1 6a1 1 0 1 1 2 0v4a1 1 0 1 1-2 0V8zm4 0a1 1 0 1 1 2 0v4a1 1 0 1 1-2 0V8z" clip-rule="evenodd"/></svg></button>',gt=r=>r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),so=r=>r.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(t,a,n)=>`${a}${n.toLocaleUpperCase()}`),Di=r=>r.replace(/[<>]/g,"").toLowerCase(),Ii=new Set(["p","br","div","span","b","strong","i","em","u","s","strike","ul","ol","li","h1","h2","h3","h4","blockquote","a","img","hr"]),Bi=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,Oi=r=>{const t=r.indexOf("<!--StartFragment-->"),a=r.indexOf("<!--EndFragment-->");if(t!==-1&&a!==-1&&a>t)return r.slice(t+20,a);const n=r.match(/<body[^>]*>([\s\S]*)<\/body>/i);return n?n[1]:r},Kt=(r,t)=>t.test(r),Hi=r=>Kt(r,/font-weight\s*:\s*(bold|[6-9]00)/i),Pi=r=>Kt(r,/font-style\s*:\s*italic/i),Fi=r=>Kt(r,/text-decoration(?:-line)?\s*:[^;]*underline/i),zi=r=>Kt(r,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),Xt=(r,t)=>{var n;if(!r.childNodes.length||r.childNodes.length===1&&((n=r.firstChild)==null?void 0:n.nodeType)===Node.ELEMENT_NODE&&r.firstChild.tagName.toLowerCase()===t)return;const a=r.ownerDocument.createElement(t);for(;r.firstChild;)a.appendChild(r.firstChild);r.appendChild(a)},Yt=r=>{const t=r.parentNode;if(!t){r.remove();return}for(;r.firstChild;)t.insertBefore(r.firstChild,r);t.removeChild(r)},_i=r=>{const t=r.getAttribute("class")??"",a=r.getAttribute("style")??"";return/mso-list/i.test(a)||/MsoListParagraph/i.test(t)||/MsoList/i.test(t)},lo=r=>{const t=r.getAttribute("style")??"",a=r.textContent??"";return/mso-level-number-format\s*:\s*(decimal|arabic|roman|alpha)/i.test(t)||/^\s*\d+[.)]\s/.test(a)||/^\s*[a-zA-Z][.)]\s/.test(a)?"ol":"ul"},ji=r=>{const a=r.ownerDocument.createTreeWalker(r,NodeFilter.SHOW_TEXT).nextNode();if(!a||!a.textContent)return;const n=a.textContent.replace(Bi,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");n!==a.textContent&&(a.textContent=n)},Wi=r=>{const t=Array.from(r.querySelectorAll("span, font, p, div, li, h1, h2, h3, h4"));t.sort((a,n)=>n.querySelectorAll("*").length-a.querySelectorAll("*").length),t.forEach(a=>{const n=a.getAttribute("style")??"";n&&(Hi(n)&&Xt(a,"strong"),Pi(n)&&Xt(a,"em"),Fi(n)&&Xt(a,"u"),zi(n)&&Xt(a,"s"))})},qi=r=>{const t=Array.from(r.querySelectorAll("p, div")).filter(_i);if(!t.length)return;let a=0;for(;a<t.length;){const n=t[a],s=lo(n),l=[n];let i=a+1;for(;i<t.length;){const f=t[i];if(lo(f)!==s)break;let b=l[l.length-1].nextSibling;for(;b&&b.nodeType===Node.TEXT_NODE&&!(b.textContent??"").trim();)b=b.nextSibling;if(b!==f)break;l.push(f),i++}const c=n.parentNode;if(!c){a=i;continue}const u=n.ownerDocument.createElement(s);c.insertBefore(u,n),l.forEach(f=>{ji(f);const b=f.ownerDocument.createElement("li");for(;f.firstChild;)b.appendChild(f.firstChild);u.appendChild(b),f.remove()}),a=i}},Ui=r=>r==="h1"?"h2":r==="h4"||r==="h5"||r==="h6"?"h3":r==="div"?"p":r,Vi=r=>{const t=Oi(r.replace(/<!--\[if[\s\S]*?<!\[endif\]-->/gi,"").replace(/<xml[\s\S]*?<\/xml>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<\/?o:[^>]*>/gi,"").replace(/<\/?w:[^>]*>/gi,"").replace(/<\/?m:[^>]*>/gi,"")),s=new DOMParser().parseFromString(`<!DOCTYPE html><html><body>${t}</body></html>`,"text/html").body;s.querySelectorAll("script, style, meta, link, xml, title, head, iframe, object, embed, form, input, button, textarea, select, noscript").forEach(i=>i.remove()),Wi(s),qi(s);const l=i=>{const c=Array.from(i.childNodes);if(i.nodeType===Node.ELEMENT_NODE){const u=i,f=u.tagName.toLowerCase();if(f==="html"||f==="body"){c.forEach(l);return}if(f==="font"){Yt(u),c.forEach(l);return}if(!Ii.has(f)){Yt(u),c.forEach(l);return}const b=Ui(f);if(b!==f){const p=u.ownerDocument.createElement(b);for(;u.firstChild;)p.appendChild(u.firstChild);u.replaceWith(p),l(p);return}if(Array.from(u.attributes).forEach(p=>{const m=p.name.toLowerCase(),w=p.value;if(m.startsWith("on")||m==="style"||m==="class"){u.removeAttribute(p.name);return}if(m==="lang"||m.startsWith("data-")||m.startsWith("mso-")){u.removeAttribute(p.name);return}if((m==="href"||m==="src")&&/^\s*javascript:/i.test(w)){u.removeAttribute(p.name);return}f!=="a"&&f!=="img"&&m!=="href"&&m!=="src"&&m!=="alt"&&(["href","src","alt","target","rel"].includes(m)||u.removeAttribute(p.name))}),f==="a"){const p=u.getAttribute("href");if(!p||/^\s*#/.test(p)&&p.length<2){Yt(u),c.forEach(l);return}u.setAttribute("target","_blank"),u.setAttribute("rel","noopener noreferrer"),u.classList.add("rich-link")}if(f==="img"){const p=u.getAttribute("src")??"";if(!p||/^\s*javascript:/i.test(p)||/^file:/i.test(p)||/scheme\s*=\s*["']?file/i.test(p)){u.remove();return}u.classList.add("rich-img"),Array.from(u.attributes).forEach(m=>{["src","alt","class"].includes(m.name.toLowerCase())||u.removeAttribute(m.name)})}if(f==="span"){Yt(u),c.forEach(l);return}}c.forEach(l)};return l(s),s.querySelectorAll("p, h2, h3, li").forEach(i=>{const c=(i.textContent??"").replace(/[\u00a0\s]+/g,"").trim(),u=i.querySelector("img, hr"),f=!c&&!u&&Array.from(i.childNodes).every(b=>b.nodeType===Node.TEXT_NODE||b.nodeType===Node.ELEMENT_NODE&&b.tagName.toLowerCase()==="br");(!c&&!u||f)&&i.remove()}),s.querySelectorAll("strong, b, em, i, u, s").forEach(i=>{let c=i.nextSibling;for(;c&&c.nodeType===Node.TEXT_NODE&&!(c.textContent??"").trim();)c=c.nextSibling;if(c&&c.nodeType===Node.ELEMENT_NODE&&c.tagName===i.tagName){const u=c;for(;u.firstChild;)i.appendChild(u.firstChild);u.remove()}}),s.innerHTML.replace(/<!--[\s\S]*?-->/g,"").replace(/&nbsp;/gi," ").replace(/(<br\s*\/?>\s*){3,}/gi,"<br><br>").replace(/<p>(?:\s|<br\s*\/?>)*<\/p>/gi,"").trim()},Va=r=>gt(r).replace(/\r\n?/g,`
25
- `).split(/\n{2,}/).map(t=>`<p>${t.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),Gi=r=>new RegExp("\\p{L}","u").test(r),Ga=(r,t)=>{const a=r.trim();return!a||!Gi(a)?!1:t==="uppercase"?a===a.toLocaleUpperCase():t==="lowercase"?a===a.toLocaleLowerCase():a===so(a)},io=r=>{const t=n=>{var s,l;if(!n.closest(".rich-img-wrap")){const i=document.createElement("span");i.className="rich-img-wrap",i.contentEditable="false",(s=n.parentNode)==null||s.insertBefore(i,n),i.appendChild(n),i.insertAdjacentHTML("beforeend",oo())}(l=n.closest(".rich-img-wrap"))==null||l.classList.add("rich-img-broken")};r.querySelectorAll("img").forEach(n=>{if(!n.complete||n.naturalWidth===0){n.addEventListener("error",()=>t(n),{once:!0}),n.addEventListener("load",()=>{n.naturalWidth===0&&t(n)},{once:!0});const s=n.src;n.src="",n.src=s}});const a=n=>{const s=n.target;s.tagName==="IMG"&&t(s)};return r.addEventListener("error",a,!0),()=>r.removeEventListener("error",a,!0)};function co({value:r,onChange:t,placeholder:a="Escribe algo...",minHeight:n="80px"}){const s=o.useCallback(()=>document,[]),l=o.useRef(null),i=o.useRef(null),c=o.useRef(new Map),u=o.useRef(null),f=o.useRef(!1),b=o.useRef(r??""),p=o.useRef(t),m=o.useRef(!1),[w,y]=o.useState(()=>!r||r.trim()===""),[k,v]=o.useState(new Set),[C,B]=o.useState(null),[T,W]=o.useState(""),[L,S]=o.useState(""),[q,H]=o.useState(""),[z,X]=o.useState(""),[Z,M]=o.useState(!1),U=o.useCallback(()=>f.current?i.current:l.current,[]);o.useEffect(()=>{p.current=t},[t]);const j=o.useCallback(()=>{const P=window.getSelection(),Q=U();if(!P||!Q||P.rangeCount===0||P.isCollapsed)return"";const Y=P.getRangeAt(0);return!Q.contains(Y.startContainer)||!Q.contains(Y.endContainer)?"":P.toString()},[U]);o.useEffect(()=>{const P=r??"";if(m.current&&P===b.current){m.current=!1,y(!P||P.trim()==="");return}m.current=!1,b.current=P;const Q=[l.current,i.current].filter(de=>!!de);Q.forEach(de=>{de.innerHTML!==P&&(de.innerHTML=P)}),y(!P||P.trim()==="");const Y=Q.map(de=>io(de));return()=>Y.forEach(de=>de())},[r]),o.useEffect(()=>{var de,Se;f.current=Z;let P,Q=0,Y;if(Z){const ke=l.current;ke&&(b.current=ke.innerHTML);const ye=()=>{var Oe;const Le=i.current;if(!Le){Q=requestAnimationFrame(ye);return}Le.innerHTML!==b.current&&(Le.innerHTML=b.current),P=io(Le),y(((Oe=Le.textContent)==null?void 0:Oe.trim())===""),Y=setTimeout(()=>Le.focus(),60)};Q=requestAnimationFrame(ye)}else{const ke=i.current,ye=l.current,Le=(ke==null?void 0:ke.innerHTML)??b.current,Oe=b.current;b.current=Le,ye&&ye.innerHTML!==Le&&(ye.innerHTML=Le),Le!==Oe&&p.current(Le),y(((Se=(de=ke??ye)==null?void 0:de.textContent)==null?void 0:Se.trim())==="")}return()=>{Q&&cancelAnimationFrame(Q),Y&&clearTimeout(Y),P==null||P()}},[Z]);const N=o.useCallback(()=>{const P=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],Q=new Set;P.forEach(de=>{try{s().queryCommandState(de)&&Q.add(de)}catch{return}});try{const de=Di(s().queryCommandValue("formatBlock"));de&&Q.add(`formatBlock:${de}`)}catch{}const Y=j();Ga(Y,"uppercase")&&Q.add("__upper"),Ga(Y,"lowercase")&&Q.add("__lower"),Ga(Y,"capitalize")&&Q.add("__cap"),v(Q)},[j,s]),K=()=>{var Q;const P=U();P&&(b.current=P.innerHTML,m.current=!0,p.current(b.current),y(((Q=P.textContent)==null?void 0:Q.trim())===""))},I=P=>{if(!P){const Q=l.current;Q&&(b.current=Q.innerHTML)}M(!P)},E=(P,Q)=>{var Y;(Y=U())==null||Y.focus(),s().execCommand(P,!1,Q),K(),N()},R=P=>{E("formatBlock",P)},ne=()=>{var P;(P=U())==null||P.focus(),s().execCommand("insertHTML",!1,"<hr><p><br></p>"),K(),N()},$=()=>{const P=window.getSelection();P&&P.rangeCount>0&&(u.current=P.getRangeAt(0).cloneRange())},O=()=>{const P=window.getSelection();P&&u.current&&(P.removeAllRanges(),P.addRange(u.current))},re=P=>{if($(),P==="link"){const Q=window.getSelection();S(Q&&!Q.isCollapsed?Q.toString():""),W("")}P==="image"&&(H(""),X("")),B(P)},ee=()=>{var de;if(!T.trim())return;O(),(de=U())==null||de.focus();const P=window.getSelection(),Y=(P&&!P.isCollapsed?P.toString():"")||L.trim()||T.trim();s().execCommand("insertHTML",!1,`<a href="${gt(T.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${gt(Y)}</a>`),K(),B(null)},oe=(P,Q="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${gt(P)}" alt="${gt(Q)}" class="rich-img" />${oo()}</span>`,ie=()=>{var P;q.trim()&&(O(),(P=U())==null||P.focus(),s().execCommand("insertHTML",!1,oe(q.trim(),z.trim())),K(),B(null))},ve=(P,Q=1200,Y=1200,de=.72)=>new Promise((Se,ke)=>{const ye=new FileReader;ye.onerror=ke,ye.onload=Le=>{var Lr;const Oe=(Lr=Le.target)==null?void 0:Lr.result,_e=new Image;_e.onerror=ke,_e.onload=()=>{let{width:nr,height:je}=_e;if(nr>Q||je>Y){const qe=Math.min(Q/nr,Y/je);nr=Math.round(nr*qe),je=Math.round(je*qe)}const Xr=document.createElement("canvas");Xr.width=nr,Xr.height=je;const ur=Xr.getContext("2d");if(!ur){Se(Oe);return}ur.drawImage(_e,0,0,nr,je),Se(Xr.toDataURL("image/jpeg",de))},_e.src=Oe},ye.readAsDataURL(P)}),te=P=>{P.focus();const Q=window.getSelection();if(!Q||Q.rangeCount===0||!P.contains(Q.anchorNode)){const Y=document.createRange();Y.selectNodeContents(P),Y.collapse(!1),Q==null||Q.removeAllRanges(),Q==null||Q.addRange(Y)}},J=o.useRef(()=>{});J.current=P=>{const Q=U();Q&&(te(Q),s().execCommand("insertHTML",!1,P),Q.querySelectorAll("p").forEach(Y=>{!(Y.textContent??"").replace(/[\u00a0\s]+/g,"")&&!Y.querySelector("img, hr")&&Y.remove()}),K(),N())};const h=o.useRef(ve);h.current=ve;const D=o.useRef(oe);D.current=oe;const V=o.useCallback(P=>{if(!P||c.current.has(P))return;const Q=Y=>{const de=Y.clipboardData;if(!de)return;const Se=de.getData("text/html"),ke=de.getData("text/plain");if(Se||ke){Y.preventDefault(),Y.stopPropagation();try{const _e=Se?Vi(Se):Va(ke);if(!_e){ke&&J.current(Va(ke));return}J.current(_e)}catch{ke&&J.current(Va(ke))}return}const Le=Array.from(de.items).find(_e=>_e.type.startsWith("image/"));if(!Le)return;Y.preventDefault(),Y.stopPropagation();const Oe=Le.getAsFile();Oe&&h.current(Oe).then(_e=>{J.current(D.current(_e,"imagen"))})};P.addEventListener("paste",Q,!0),c.current.set(P,()=>{P.removeEventListener("paste",Q,!0),c.current.delete(P)})},[]),ae=o.useCallback(P=>{var Y;const Q=l.current;Q&&Q!==P&&((Y=c.current.get(Q))==null||Y()),l.current=P,P&&V(P)},[V]),se=o.useCallback(P=>{var Y;const Q=i.current;Q&&Q!==P&&((Y=c.current.get(Q))==null||Y()),i.current=P,P&&V(P)},[V]);o.useEffect(()=>{const P=c.current;return()=>{P.forEach(Q=>Q()),P.clear()}},[]);const he=P=>{const Q=window.getSelection(),Y=U();if(!Q||!Y||Q.rangeCount===0||Q.isCollapsed)return;const de=Q.getRangeAt(0);if(!Y.contains(de.startContainer)||!Y.contains(de.endContainer))return;const Se=de.toString();if(!Se)return;let ke=Se;P==="uppercase"?ke=Se.toLocaleUpperCase():P==="lowercase"?ke=Se.toLocaleLowerCase():ke=so(Se),de.deleteContents();const ye=document.createTextNode(ke);de.insertNode(ye);const Le=document.createRange();Le.setStart(ye,0),Le.setEnd(ye,ke.length),Q.removeAllRanges(),Q.addRange(Le),u.current=Le.cloneRange(),K(),N()},Be=()=>{$(),N()},Ve=()=>{K(),N()},xe=()=>{requestAnimationFrame(()=>{var P;(P=U())==null||P.focus()})},Ae=P=>{var Q,Y;if((P.metaKey||P.ctrlKey)&&P.key==="Enter"){if(P.preventDefault(),P.stopPropagation(),P.repeat)return;(Q=U())==null||Q.focus(),s().execCommand("insertLineBreak",!1)||s().execCommand("insertHTML",!1,"<br>"),K(),N();return}if(P.key==="Tab"){P.preventDefault(),(Y=U())==null||Y.focus(),s().execCommand("insertText",!1,"    "),K(),N();return}if(P.key==="Escape"){if(C){B(null);return}if(f.current){M(!1);return}}C||(P.ctrlKey||P.metaKey)&&(P.key==="b"&&(P.preventDefault(),E("bold")),P.key==="i"&&(P.preventDefault(),E("italic")),P.key==="u"&&(P.preventDefault(),E("underline")),P.key==="k"&&(P.preventDefault(),re("link")))},$e=()=>e.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),Ee=(P,Q,Y,de,Se)=>{const ke=Se??(k.has(Y)||Y==="__link"&&C==="link"||Y==="__img"&&C==="image");return e.jsx("button",{type:"button",title:Q,tabIndex:-1,onFocus:xe,onMouseDown:ye=>{ye.preventDefault(),de?de():E(Y)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:ke?"var(--primary)":"var(--text-secondary)",background:ke?"rgba(59,130,246,0.12)":"transparent"},children:P},Y)},cr=P=>{const Q=P.target;if(Q.closest("[data-action='delete-img']")){P.preventDefault();const Y=Q.closest(".rich-img-wrap");Y&&(Y.remove(),K())}},dr=P=>e.jsxs(e.Fragment,{children:[C==="link"&&e.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:P},children:[e.jsx("input",{autoFocus:!0,type:"url",value:T,onChange:Q=>W(Q.target.value),onKeyDown:Q=>{Q.key==="Enter"&&(Q.preventDefault(),ee()),Q.key==="Escape"&&B(null)},placeholder:"https://...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),e.jsx("input",{type:"text",value:L,onChange:Q=>S(Q.target.value),onKeyDown:Q=>{Q.key==="Enter"&&(Q.preventDefault(),ee()),Q.key==="Escape"&&B(null)},placeholder:"Texto (opcional)",className:"w-32 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),e.jsx("button",{type:"button",onClick:ee,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),e.jsx("button",{type:"button",onClick:()=>B(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),C==="image"&&e.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:P},children:[e.jsx("input",{autoFocus:!0,type:"url",value:q,onChange:Q=>H(Q.target.value),onKeyDown:Q=>{Q.key==="Enter"&&(Q.preventDefault(),ie()),Q.key==="Escape"&&B(null)},placeholder:"URL de la imagen...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),e.jsx("input",{type:"text",value:z,onChange:Q=>X(Q.target.value),onKeyDown:Q=>{Q.key==="Enter"&&(Q.preventDefault(),ie()),Q.key==="Escape"&&B(null)},placeholder:"Texto alt",className:"w-28 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),e.jsx("button",{type:"button",onClick:ie,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),e.jsx("button",{type:"button",onClick:()=>B(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),pe=(P,Q)=>e.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-0.5 border-t px-2 py-1",style:{borderColor:"var(--border)",background:Q},children:[Ee(e.jsx(A.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),Ee(e.jsx(A.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),$e(),Ee(e.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>R("p"),k.has("formatBlock:p")||k.has("formatBlock:div")),Ee(e.jsx(A.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>R("h2"),k.has("formatBlock:h2")),Ee(e.jsx(A.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>R("h3"),k.has("formatBlock:h3")),Ee(e.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>R("blockquote"),k.has("formatBlock:blockquote")),$e(),Ee(e.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),Ee(e.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),Ee(e.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),Ee(e.jsx("s",{children:"S"}),"Tachado","strikeThrough"),$e(),Ee(e.jsx(A.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),Ee(e.jsx(A.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),Ee(e.jsx(A.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),Ee(e.jsx(A.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),$e(),Ee(e.jsx(A.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),Ee(e.jsx(A.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),Ee(e.jsx(A.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),Ee(e.jsx(A.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),$e(),Ee(e.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>he("uppercase")),Ee(e.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>he("lowercase")),Ee(e.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>he("capitalize")),$e(),Ee(e.jsx(A.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>re("link")),Ee(e.jsx(A.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),Ee(e.jsx(A.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>re("image")),Ee(e.jsx(A.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",ne),$e(),Ee(e.jsx(A.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),Ee(e.jsx(A.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>R("p")),$e(),e.jsx("button",{type:"button",title:P?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:xe,onMouseDown:Y=>{Y.preventDefault(),I(P)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:P?e.jsx(A.HiArrowsPointingIn,{className:"h-4 w-4"}):e.jsx(A.HiArrowsPointingOut,{className:"h-4 w-4"})})]});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"overflow-hidden rounded-lg transition-all duration-150 ring-1 ring-transparent focus-within:ring-primary/30",style:{border:"1px solid var(--border)"},children:[e.jsx("div",{ref:ae,contentEditable:!0,suppressContentEditableWarning:!0,onInput:Ve,onKeyDown:Ae,onKeyUp:Be,onSelect:Be,onMouseUp:Be,onMouseDown:cr,"data-placeholder":a,className:`rich-editor px-3 py-2 text-sm focus:outline-none${w?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:n,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),dr("var(--bg-input)"),pe(!1,"var(--bg-input)")]}),e.jsxs(Ha,{open:Z,onClose:()=>M(!1),title:"Modo de enfoque",subtitle:"Esc para salir",maxWidth:"920px",bodyClassName:"flex min-h-0 flex-col p-0",panelClassName:"h-[88vh]",backdropClassName:"bg-black/50 backdrop-blur-[2px]",children:[e.jsx("div",{ref:se,contentEditable:!0,suppressContentEditableWarning:!0,onInput:Ve,onKeyDown:Ae,onKeyUp:Be,onSelect:Be,onMouseUp:Be,onMouseDown:cr,"data-placeholder":a,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${w?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),dr("var(--bg-input)"),pe(!0,"var(--bg-input)")]})]})}const uo="[a-zA-Z0-9._@-]+",Ka=new RegExp(`@(${uo})`,"g"),Ki=/[a-zA-Z0-9._@-]/;function Xa(r,t){if(t<0||t>r.length)return null;for(let a=t-1;a>=0;a-=1){if(r[a]!=="@"){const s=r[a]??"";if(s===" "||s===`
26
- `||s===" "||s==="("||!Ki.test(s))return null;continue}if(a>0){const s=r[a-1]??"";if(s!==" "&&s!==`
27
- `&&s!==" "&&s!=="(")continue}const n=r.slice(a+1,t);return n.length>0&&!new RegExp(`^${uo}$`).test(n)?null:{query:n,triggerIndex:a,caretIndex:t}}return null}function Ya(r){return r.toLowerCase().trim()}function fo(r){return r?r.replace(/<style[^>]*>[\s\S]*?<\/style>/gi," ").replace(/<script[^>]*>[\s\S]*?<\/script>/gi," ").replace(/<br\s*\/?>/gi,`
23
+ </body></html>`,ie=window.open("","_blank");ie&&(ie.document.write(V),ie.document.close())}const Ta=()=>!br||!At?null:Je.createPortal(e.jsxs("div",{ref:cn,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Fd,position:"fixed",zIndex:9999,minWidth:170,borderColor:"var(--border)",background:"var(--bg-card)"},children:[e.jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},onClick:()=>{pu(),fa(!1)},children:[e.jsx($.HiTableCells,{className:"h-4 w-4 shrink-0 text-emerald-500"}),"Descargar CSV / Excel"]}),e.jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},onClick:()=>{mu(),fa(!1)},children:[e.jsx($.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),La=()=>{const d=re&&pr.trim().length>0,v=Ge!=null&&Ge.length?Ge:d?[{key:"bql",label:"BQL",value:pr}]:[],F=_e.filter(w=>{const V=w.trim();return V?!new Set(Lt.split(`
24
+ `).map(fe=>fe.trim()).filter(Boolean)).has(V):!1}).slice(0,8);return!S&&fn===0&&!re&&!br?null:e.jsxs("div",{className:"relative flex min-h-9 flex-wrap items-center justify-between gap-2 border-b rounded-t-lg px-2 py-1",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[fn>0&&e.jsxs("button",{type:"button",onClick:Zd,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-card)]",children:[e.jsx($.HiXMark,{className:"h-3.5 w-3.5"}),fn," filtros"]}),re&&e.jsxs("div",{ref:sn,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>{if(mr){Dr(!1);return}ya(),Dr(!0)},className:"inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border px-2 text-xs font-bold transition-colors",style:{background:mr?"var(--primary)":d?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:mr||d?"var(--primary)":"var(--border)",color:mr?"var(--primary-fg)":"var(--primary)"},"aria-expanded":mr,title:"Abrir filtros BQL",children:[e.jsx($.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",d&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),mr?e.jsx($.HiChevronUp,{className:"h-3.5 w-3.5"}):e.jsx($.HiChevronDown,{className:"h-3.5 w-3.5"})]}),e.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:W}),v.length>0&&e.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[v.slice(0,3).map(w=>e.jsxs("span",{className:"inline-flex max-w-44 items-center gap-1 truncate rounded-full px-2 py-1 text-xs font-medium",style:{background:"var(--bg-hover)",border:"1px solid var(--primary)",color:"var(--primary)"},children:[e.jsxs("span",{className:"text-[var(--text-muted)]",children:[w.label,":"]}),e.jsx("span",{className:"truncate",children:w.value})]},w.key)),v.length>3&&e.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",v.length-3]})]}),d&&e.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:hs,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)]",children:e.jsx($.HiXMark,{className:"h-4 w-4"})}),mr&&Je.createPortal(e.jsxs("div",{ref:ns,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...Bd,background:"var(--bg-card)",border:"1px solid color-mix(in srgb, var(--primary) 35%, var(--border))"},children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[oe.map(w=>e.jsxs("button",{type:"button",onMouseDown:V=>{V.preventDefault(),V.stopPropagation()},onClick:V=>{V.preventDefault(),V.stopPropagation(),xa(w.bql)},className:"inline-flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs font-semibold transition-colors hover:border-[var(--primary)] hover:text-[var(--primary)]",style:{background:"var(--bg-input)",borderColor:"var(--border)",color:"var(--text-secondary)"},children:[w.icon,w.label]},w.label)),he.length>0&&e.jsxs("button",{type:"button",onClick:()=>Qr(w=>!w),className:"inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]","aria-expanded":ts,children:[e.jsx($.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),$t.length>0&&e.jsxs("button",{type:"button",onClick:()=>Jr(w=>!w),className:"inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]","aria-expanded":as,children:[e.jsx($.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]})]}),e.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-input)",border:`1.5px solid ${xe?"var(--danger)":d?"var(--primary)":"var(--border)"}`},children:[e.jsx("textarea",{ref:ln,value:Lt,rows:3,onChange:w=>pn(w.target.value,w.target),onKeyDown:w=>{w.key==="Enter"&&!w.shiftKey&&(w.preventDefault(),ms(Lt)),w.key==="Escape"&&Dr(!1)},placeholder:ne,autoComplete:"off",spellCheck:!1,className:"block w-full px-4 py-3 text-sm outline-none",style:{background:"var(--bg-input)",color:"var(--text-main)",border:"none",fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace",lineHeight:1.6,maxHeight:180,minHeight:88,overflowY:"auto",resize:"vertical"}}),F.length>0&&e.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:F.map(w=>e.jsx("button",{type:"button",onMouseDown:V=>{V.preventDefault(),V.stopPropagation()},onClick:V=>{V.preventDefault(),V.stopPropagation(),xa(w)},className:"block w-full px-4 py-2 text-left text-xs transition-colors hover:bg-[var(--bg-hover)] hover:text-[var(--primary)]",style:{fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace"},children:w},w))})]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 text-xs",style:{color:xe?"var(--danger)":"var(--text-muted)"},children:xe??(d?`${v.length||1} filtro${(v.length||1)===1?"":"s"} activo${(v.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),v.map(w=>e.jsxs("span",{className:"inline-flex max-w-56 items-center gap-1 truncate rounded-full px-2 py-1 text-xs font-medium",style:{background:"var(--bg-hover)",border:"1px solid var(--primary)",color:"var(--primary)"},children:[e.jsxs("span",{className:"text-[var(--text-muted)]",children:[w.label,":"]}),e.jsx("span",{className:"truncate",children:w.value})]},w.key))]}),as&&$t.length>0&&e.jsxs("div",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-input)]",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-3 py-2",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-semibold text-[var(--text-secondary)]",children:[e.jsx($.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),e.jsxs("button",{type:"button",onClick:()=>{Rr([]),Jr(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[e.jsx($.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),$t.map(w=>e.jsxs("div",{className:"group flex items-center gap-2 border-b border-[var(--border)] px-3 py-2 last:border-b-0",children:[e.jsx("button",{type:"button",onMouseDown:V=>{V.preventDefault(),V.stopPropagation()},onClick:V=>{V.preventDefault(),V.stopPropagation(),xa(w)},className:"min-w-0 flex-1 text-left",children:e.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:w})}),e.jsx("button",{type:"button",onClick:()=>Rr(V=>V.filter(ie=>ie!==w)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx($.HiXMark,{className:"h-3.5 w-3.5"})})]},w))]}),ts&&he.length>0&&e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:he.map(w=>e.jsxs("button",{type:"button",onMouseDown:V=>{V.preventDefault(),V.stopPropagation()},onClick:V=>{V.preventDefault(),V.stopPropagation(),xa(w.bql),Qr(!1)},className:"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-2 text-left transition-colors hover:border-[var(--primary)]",children:[e.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:w.bql}),w.description&&e.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:w.description})]},w.bql))}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] pt-3",children:[d&&e.jsxs("button",{type:"button",onClick:hs,className:"inline-flex h-8 items-center gap-1 rounded-md px-2.5 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]",children:[e.jsx($.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),e.jsxs("button",{type:"button",onClick:()=>ms(Lt),className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-[var(--primary)] px-4 text-xs font-semibold text-[var(--primary-fg)] transition-opacity hover:opacity-90",children:[e.jsx($.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),br&&e.jsx("button",{ref:ba,type:"button","aria-haspopup":"menu","aria-expanded":At,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var V;const w=(V=ba.current)==null?void 0:V.getBoundingClientRect();w&&zd({top:w.bottom+4,right:window.innerWidth-w.right}),fa(ie=>!ie)},className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] ${At?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:e.jsx($.HiArrowDownTray,{className:"h-4 w-4"})}),S&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Xe&&ir==="visibility","aria-label":ve,title:ve,onClick:w=>vs(w,"visibility"),className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] ${Xe&&ir==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:e.jsx($.HiCog6Tooth,{className:"h-4 w-4"})})]})},$s=()=>{if(!cu)return null;const d=Ol(je,vn);return e.jsxs("div",{"aria-busy":n,className:`grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 rounded-b-xl border-t text-xs select-none ${I?"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:Fr===0?"0 filas":`${du}–${uu} de ${Fr}`}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),e.jsx(Er,{value:String(ur),onChange:v=>fu(Number(v)),options:ys.map(v=>({value:String(v),label:String(v)})),placeholder:"Filas",searchable:!1,disabled:n,height:_,padding:Y,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:H}})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[e.jsx("button",{disabled:n||je<=1,onClick:()=>xn(je-1),onMouseEnter:v=>{v.currentTarget.disabled||(v.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",v.currentTarget.style.color="var(--primary)")},onMouseLeave:v=>{v.currentTarget.style.background="transparent",v.currentTarget.style.color="var(--text-muted)"},className:"cursor-pointer rounded p-0.5 transition-colors disabled:cursor-not-allowed disabled:opacity-30",style:{background:"transparent",color:"var(--text-muted)"},children:e.jsx($.HiChevronLeft,{className:"h-3.5 w-3.5"})}),d.map((v,F)=>v==="..."?e.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${F}`):e.jsx("button",{disabled:n,onClick:()=>xn(v),onMouseEnter:w=>{w.currentTarget.disabled||v===je||(w.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",w.currentTarget.style.color="var(--primary)")},onMouseLeave:w=>{w.currentTarget.style.background=v===je?"var(--primary)":"transparent",w.currentTarget.style.color=v===je?"var(--primary-fg)":"var(--text-muted)"},className:"h-5 w-5 cursor-pointer rounded text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-60",style:{background:v===je?"var(--primary)":"transparent",color:v===je?"var(--primary-fg)":"var(--text-muted)"},children:v},v)),e.jsx("button",{disabled:n||je>=vn,onClick:()=>xn(je+1),onMouseEnter:v=>{v.currentTarget.disabled||(v.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",v.currentTarget.style.color="var(--primary)")},onMouseLeave:v=>{v.currentTarget.style.background="transparent",v.currentTarget.style.color="var(--text-muted)"},className:"cursor-pointer rounded p-0.5 transition-colors disabled:cursor-not-allowed disabled:opacity-30",style:{background:"transparent",color:"var(--text-muted)"},children:e.jsx($.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{"aria-hidden":"true"})]})},hu=()=>e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ka},children:[Ea(),Ta(),La(),e.jsx("div",{ref:Nr,className:"min-w-0 max-w-full overflow-hidden",children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:It,minWidth:Sa},children:[e.jsx("div",{role:"rowgroup",style:E?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Ca()}),e.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,s)}).map((d,v)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:lt,borderBottom:`1px solid ${Ce}`},children:[fr&&e.jsx("div",{role:"cell",className:`${I?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Ce}`,borderRight:`1px solid ${Ce}`}},"select-cell"),nr.map((F,w)=>e.jsx("div",{role:"cell",className:I?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${Ce}`,borderRight:`1px solid ${Ce}`},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${is(v,w)}%`,minWidth:32}})},F.key))]},v))})]})})]}),wn="min-w-0 max-w-full overflow-hidden";return j&&Ze&&!le?e.jsx(Pt,{rows:s,columns:Math.max(4,nr.length||7)}):!n&&t.length===0&&!dn?hu():n&&t.length===0?e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ka},children:[Ea(),Ta(),La(),e.jsx("div",{ref:Nr,className:wn,children:e.jsx(kn.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:ds,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:It,minWidth:Sa},children:[e.jsx("div",{role:"rowgroup",style:E?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Ca()}),e.jsx("div",{role:"rowgroup",children:Array.from({length:s}).map((d,v)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:lt,borderBottom:`1px solid ${Ce}`},children:[fr&&e.jsx("div",{role:"cell",className:`${I?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Ce}`,borderRight:`1px solid ${Ce}`}},"select-cell"),nr.map((F,w)=>{const V=te&&!un&&w===0;return e.jsx("div",{role:"cell","data-dt-column-key":F.key,className:I?"px-2 py-1.5":"px-3 py-2",style:V?{position:"sticky",left:gn,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.10), inset 0 -1px 0 ${Ce}`,borderRight:`1px solid ${Ce}`}:{borderBottom:`1px solid ${Ce}`,borderRight:`1px solid ${Ce}`},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${is(v,w)}%`,minWidth:32}})},F.key)})]},v))})]})})}),$s()]}):!n&&t.length===0?e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ka},children:[Ea(),Ta(),La(),e.jsx("div",{ref:Nr,className:wn,children:e.jsx("div",{role:"table",className:"text-sm",style:{width:It,minWidth:Sa},children:e.jsx("div",{role:"rowgroup",style:E?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Ca()})})}),e.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-3 border-t px-6 py-12 text-center",style:{borderColor:Ce,background:"linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 58%, transparent), var(--bg-card))"},children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full border",style:{borderColor:"color-mix(in srgb, var(--primary) 24%, var(--border))",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-card))",color:"var(--primary)"},children:l??e.jsx($.HiMagnifyingGlass,{className:"h-5 w-5"})}),e.jsx("p",{className:"max-w-sm text-sm font-medium",style:{color:"var(--text-main)"},children:i}),e.jsx("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Ajusta la busqueda o cambia los filtros para ver mas informacion."})]})]}):e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ka},children:[Ea(),Ta(),La(),e.jsx("div",{ref:Nr,className:wn,children:e.jsx(kn.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:ds,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:It,minWidth:Sa},children:[e.jsx("div",{role:"rowgroup",style:E?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Ca()}),e.jsx("div",{role:"rowgroup",children:Ns.map((d,v)=>{const F=a(d),w=Ms(z==null?void 0:z(d)),V=v>0?Ms(z==null?void 0:z(Ns[v-1])):null,ie=w&&w.key!==(V==null?void 0:V.key),fe=fr&&M.has(F),ye=ot?(m==null?void 0:m(d))??!0:!1,ze=ye&&ws.has(F),Pe=!!u||N&&ye,we=fe&&B?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":v%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return e.jsxs(o.Fragment,{children:[ie&&e.jsx("div",{role:"row",className:`grid ${w.className??""}`,style:{gridTemplateColumns:lt},children:e.jsx("div",{role:"cell",className:I?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-input))",borderBottom:`1px solid ${Ce}`,borderRight:`1px solid ${Ce}`},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("div",{role:"row",onClick:Pe?Se=>{const Ne=Se.target;if(!(Ne!=null&&Ne.closest('[data-dt-disable-row-click="true"]'))){if(N&&ye){ks(F);return}u==null||u(d)}}:void 0,className:`grid transition-colors ${Pe?"cursor-pointer":""} ${A?A(d):""}`,style:{gridTemplateColumns:lt,"--dt-row-bg":we,"--dt-sticky-bg":we,background:"var(--dt-row-bg)",borderBottom:`1px solid ${Ce}`},onMouseEnter:Se=>{fe||(Se.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),Se.currentTarget.style.setProperty("--dt-sticky-bg",bu))},onMouseLeave:Se=>{Se.currentTarget.style.setProperty("--dt-row-bg",we),Se.currentTarget.style.setProperty("--dt-sticky-bg",we)},children:[ot&&e.jsx("div",{role:"cell",className:`${I?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${Ce}`,borderRight:`1px solid ${Ce}`},"data-dt-disable-row-click":"true",children:ye&&e.jsx("button",{type:"button","aria-label":ze?"Contraer fila":"Desplegar fila","aria-expanded":ze,onClick:Se=>{Se.stopPropagation(),ks(F)},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]",children:ze?e.jsx($.HiChevronDown,{className:"h-4 w-4"}):e.jsx($.HiChevronRight,{className:"h-4 w-4"})})}),fr&&e.jsx("div",{role:"cell",className:`${I?"px-2 py-1.5":"px-3 py-2"} w-10`,style:te?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${Ce}`}:{borderBottom:`1px solid ${Ce}`,borderRight:`1px solid ${Ce}`},onClick:Se=>{Se.stopPropagation(),g(F)},children:e.jsx(Ft,{size:"sm",checked:fe,"aria-label":"Seleccionar fila",containerClassName:"items-center",className:"cursor-pointer",onClick:Se=>Se.stopPropagation(),onChange:()=>g(F)})}),nr.map((Se,Ne)=>{const qe=te&&!un&&Ne===0,be=Mr(Se);return e.jsx("div",{role:"cell","data-dt-column-key":Se.key,"data-dt-disable-row-click":Se.disableRowClick||be?"true":void 0,className:`${be?"px-2 py-1.5 text-center":`${I?"px-2 py-1.5":"px-3 py-2"} ${Ss(Se.align)}`} ${Ll} ${Se.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...qe?{position:"sticky",left:gn,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Ce}`,borderRight:`1px solid ${Ce}`}:{borderBottom:`1px solid ${Ce}`,borderRight:`1px solid ${Ce}`}},children:e.jsx(Wn,{children:e.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:Se.cell(d)})})},Se.key)})]}),ze&&f&&e.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:lt},children:e.jsx("div",{role:"cell",className:I?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--bg-input) 60%, var(--bg-card))",borderBottom:`1px solid ${Ce}`},children:f(d)})})]},F)})})]})})}),$s()]})}const Fl={email:{pattern:/^[^\s@]+@[^\s@]+\.[^\s@]+$/,message:"Correo inválido"},integer:{pattern:/^-?\d+$/,message:"Debe ser un número entero"},date:{pattern:/^\d{4}-\d{2}-\d{2}$/,message:"Fecha inválida"}};function zl(r,t){if(t.minLength!==void 0&&r.length<t.minLength)return t.message??`Mínimo ${t.minLength} caracteres`;if(t.maxLength!==void 0&&r.length>t.maxLength)return t.message??`Máximo ${t.maxLength} caracteres`;if(!r)return null;if(t.preset){const a=Fl[t.preset];if(!a.pattern.test(r))return t.message??a.message}return t.pattern&&!t.pattern.test(r)?t.message??"Formato inválido":null}const _l=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function jl({initialValue:r,type:t,mask:a,onCommit:n,onCancel:s}){const[l,i]=o.useState(r),c=o.useRef(null),u=(a==null?void 0:a.preset)==="date",f=u?"date":t==="number"?"number":"text";return o.useEffect(()=>{var m,b;(m=c.current)==null||m.focus(),u||(b=c.current)==null||b.select()},[u]),e.jsx("input",{ref:c,type:f,value:l,maxLength:a==null?void 0:a.maxLength,onChange:m=>i(m.target.value),onBlur:()=>s(),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),n(l)),m.key==="Escape"&&(m.preventDefault(),s()),(a==null?void 0:a.preset)==="integer"&&!m.ctrlKey&&!m.metaKey&&!_l.has(m.key)&&!/^[\d-]$/.test(m.key)&&m.preventDefault()},onClick:m=>m.stopPropagation(),className:"w-full min-w-0 border-0 bg-transparent p-0 text-sm text-[var(--text-main)] outline-none"})}function Wl({initialValue:r,options:t,loading:a,onCommit:n,onCancel:s}){const l=o.useRef(null);return o.useEffect(()=>{if(a)return;const i=setTimeout(()=>{var c,u;(u=(c=l.current)==null?void 0:c.querySelector("button"))==null||u.click()},0);return()=>clearTimeout(i)},[a]),e.jsx("div",{ref:l,className:"w-full",tabIndex:-1,onKeyDown:i=>{i.key==="Escape"&&(i.stopPropagation(),s())},children:e.jsx(Er,{value:r,onChange:i=>{n(i)},options:t,disabled:a,placeholder:a?"Cargando…":"Seleccionar…",triggerVariant:"ghost",height:30,padding:"0 6px",minOptionsForSearch:1,className:"w-full"})})}const ql={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},_a={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function Ul({columns:r,data:t,getRowId:a,onCellUpdate:n,readOnly:s=!1,...l}){const[i,c]=o.useState(t),u=o.useRef(null);o.useEffect(()=>{u.current||c(t)},[t]);const[f,m]=o.useState(null);u.current=f;const[b,p]=o.useState(null),y=o.useRef(null);y.current=b;const[N,M]=o.useState({}),[g,C]=o.useState(null),B=o.useRef(null);B.current=g;const[A,z]=o.useState({}),[E,k]=o.useState({}),q=o.useRef(new Set),H=o.useRef(null);o.useEffect(()=>{var S;const x=document.activeElement;(!x||x===document.body)&&((S=H.current)==null||S.focus({preventScroll:!0}))},[]);const _=r.map(x=>{var S,K,Q;return`${x.key}:${((Q=(K=(S=x.editable)==null?void 0:S.select)==null?void 0:K.options)==null?void 0:Q.length)??-1}`}).join("|");o.useEffect(()=>{r.forEach(x=>{var Q,ae;const S=(ae=(Q=x.editable)==null?void 0:Q.select)==null?void 0:ae.options;if(!S)return;const K=A[x.key];(!q.current.has(x.key)||(K==null?void 0:K.length)===0&&S.length>0)&&(q.current.add(x.key),z(ce=>({...ce,[x.key]:S})))})},[_]);const Y=o.useCallback(async(x,S)=>{if(q.current.has(x))return;q.current.add(x);const{url:K,fetchOptions:Q}=S.select??{};if(!(!K&&!Q)){k(ae=>({...ae,[x]:!0}));try{let ae=[];if(Q)ae=await Q();else if(K){const ce=await fetch(K);if(!ce.ok)throw new Error("fetch failed");ae=await ce.json()}z(ce=>({...ce,[x]:ae}))}catch{z(ae=>({...ae,[x]:[]}))}finally{k(ae=>({...ae,[x]:!1}))}}},[]),Z=o.useRef(i);Z.current=i;const T=o.useRef(n);T.current=n;const J=o.useRef(a);J.current=a;const O=o.useRef(r);O.current=r;const j=o.useRef(s);j.current=s,o.useEffect(()=>{if(r.length>0&&t.length>0){const x=r.find(S=>S.selectable!==!1);x&&p({rowId:a(t[0]),colKey:x.key})}},[]),o.useEffect(()=>{if(!b)return;const x=H.current;if(!x)return;const S=x.querySelector(`[data-cell-id="${b.rowId}:${b.colKey}"]`);if(!S)return;const K=x.querySelector('[role="rowgroup"]');S.style.scrollMarginTop=`${(K==null?void 0:K.offsetHeight)??0}px`;const Q=x.querySelector('[role="row"]');let ae=0;Q&&Q.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(ce=>{ce.style.position==="sticky"&&ce.style.left!==""&&(ae=Math.max(ae,parseFloat(ce.style.left)+ce.offsetWidth))}),S.style.scrollMarginLeft=`${ae}px`,S.scrollIntoView({block:"nearest",inline:"nearest"})},[b]);const te=o.useCallback(x=>{var ae;const S=O.current,K=new Set,Q=[];(ae=H.current)==null||ae.querySelectorAll("[data-cell-id]").forEach(ce=>{const ve=ce.dataset.cellId.split(":")[0];K.has(ve)||(K.add(ve),Q.push(ve))}),p(ce=>{if(!ce)return ce;const ve=S.findIndex(L=>L.key===ce.colKey),re=Q.indexOf(ce.rowId);let G=ve,h=re;if(x==="up")h=Math.max(0,re-1);else if(x==="down")h=Math.min(Q.length-1,re+1);else if(x==="left"){let L=ve-1;for(;L>=0&&S[L].selectable===!1;)L--;L>=0&&(G=L)}else if(x==="right"){let L=ve+1;for(;L<S.length&&S[L].selectable===!1;)L++;L<S.length&&(G=L)}return G===ve&&h===re?ce:{rowId:Q[h],colKey:S[G].key}})},[]),X=o.useCallback((x=!0)=>{const S=u.current;m(null),S&&p(S),x&&setTimeout(()=>{var K;return(K=H.current)==null?void 0:K.focus({preventScroll:!0})},0)},[]),I=o.useCallback(async(x,S,K)=>{var Ge;const Q=O.current.find(xe=>xe.key===S);if(!(Q!=null&&Q.editable))return;const{field:ae,type:ce,mask:ve,validate:re}=Q.editable,G=ce==="number"?K===""?null:Number(K):K;if(ve){const xe=zl(K,ve);if(xe){M(Ee=>({...Ee,[`${x}:${S}`]:xe}));return}}if(re){const xe=re(G);if(xe){M(Ee=>({...Ee,[`${x}:${S}`]:xe}));return}}const h=J.current,L=Z.current.find(xe=>h(xe)===x);if(!L)return;const W=L[ae];m(null),M(xe=>{const Ee={...xe};return delete Ee[`${x}:${S}`],Ee});const ne=Z.current,oe=ne.findIndex(xe=>h(xe)===x),he=ne[Math.min(ne.length-1,oe+1)];if(p({rowId:h(he),colKey:S}),setTimeout(()=>{var Ee,Ae;const xe=document.activeElement;(!xe||xe===document.body||(Ee=H.current)!=null&&Ee.contains(xe))&&((Ae=H.current)==null||Ae.focus({preventScroll:!0}))},0),String(W??"")===String(G??""))return;const _e={...L,[ae]:G};c(xe=>xe.map(Ee=>h(Ee)===x?_e:Ee)),C({rowId:x,colKey:S});try{await((Ge=T.current)==null?void 0:Ge.call(T,{row:L,rowId:x,field:ae,oldValue:W,newValue:G}))}catch{c(xe=>xe.map(Ee=>h(Ee)===x?L:Ee)),M(xe=>({...xe,[`${x}:${S}`]:"Error al guardar. Intenta de nuevo."}))}finally{C(null)}},[]),ee=o.useCallback(x=>{if(B.current){x.preventDefault();return}if(u.current)return;const S=y.current;if(!(!S||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(x.key)))switch(x.preventDefault(),x.key){case"ArrowUp":te("up");break;case"ArrowDown":te("down");break;case"ArrowLeft":te("left");break;case"ArrowRight":te("right");break;case"Tab":te(x.shiftKey?"left":"right");break;case"Enter":{const Q=O.current.find(ae=>ae.key===S.colKey);Q!=null&&Q.editable&&!j.current?(m(S),Q.editable.type==="select"&&!q.current.has(S.colKey)&&Y(S.colKey,Q.editable)):te("down");break}}},[te,Y]),R=o.useMemo(()=>r.map(x=>{if(!x.editable||s){const K={...x};if(delete K.editable,delete K.selectable,x.selectable===!1)return{...K,disableRowClick:!0};const Q=K.cell;return{...K,className:`relative ${K.className??""}`.trim(),disableRowClick:!0,cell:ae=>{const ce=a(ae),ve=(b==null?void 0:b.rowId)===ce&&(b==null?void 0:b.colKey)===x.key;return e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-cell-id":`${ce}:${x.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var re;B.current||(p({rowId:ce,colKey:x.key}),(re=H.current)==null||re.focus({preventScroll:!0}))}}),ve&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:_a}),e.jsx("span",{className:"relative z-0 pointer-events-none",children:Q(ae)})]})}}}const S=x.editable;return{...x,className:`relative ${x.className??""}`.trim(),disableRowClick:!0,cell:K=>{const Q=a(K),ae=x.key,ce=(f==null?void 0:f.rowId)===Q&&(f==null?void 0:f.colKey)===ae,ve=(b==null?void 0:b.rowId)===Q&&(b==null?void 0:b.colKey)===ae,re=N[`${Q}:${ae}`],G=(g==null?void 0:g.rowId)===Q&&(g==null?void 0:g.colKey)===ae,h=K[S.field],L=String(h??""),W=()=>{var oe;B.current||(p({rowId:Q,colKey:ae}),m({rowId:Q,colKey:ae}),(oe=H.current)==null||oe.focus({preventScroll:!0}),S.type==="select"&&!q.current.has(ae)&&Y(ae,S))};if(ce){const oe=S.type==="select"?e.jsx(Wl,{initialValue:L,options:A[ae]??[],loading:E[ae]??!1,onCommit:he=>I(Q,ae,he),onCancel:X}):e.jsx(jl,{initialValue:L,type:S.type??"text",mask:S.mask,onCommit:he=>I(Q,ae,he),onCancel:X});return e.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:ql,onClick:he=>he.stopPropagation(),children:oe})}const ne=x.cell(K);return e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-cell-id":`${Q}:${ae}`,className:`peer absolute inset-0 z-10 ${G?"cursor-wait":"cursor-pointer"}`,onClick:W}),ve&&!G&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:_a}),G&&e.jsxs("div",{className:"pointer-events-none absolute inset-0 z-20 flex items-center gap-1.5 bg-[var(--bg-card)]/80 px-2",style:_a,children:[e.jsx("span",{className:"h-3 w-3 shrink-0 animate-spin rounded-full border-2 border-[var(--text-muted)] border-t-transparent","aria-hidden":!0}),e.jsx("span",{className:"truncate text-xs text-[var(--text-muted)]",children:"Guardando…"})]}),e.jsx("span",{className:"relative z-0 inline-flex items-center gap-1 pointer-events-none",children:re?e.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[e.jsx($.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate text-xs",children:re})]}):e.jsx("span",{className:"truncate",children:ne})}),!G&&e.jsx($.HiPencil,{className:"pointer-events-none absolute right-1 top-1/2 z-0 h-3 w-3 -translate-y-1/2 shrink-0 text-[var(--text-muted)] opacity-0 transition-opacity peer-hover:opacity-40"})]})}}}),[r,s,f,b,g,N,A,E,a,I,X,Y]);return e.jsx("div",{ref:H,tabIndex:0,onKeyDown:ee,onBlur:x=>{var S;(S=H.current)!=null&&S.contains(x.relatedTarget)||setTimeout(()=>{var Q,ae;const K=document.activeElement;K&&((Q=K.closest)!=null&&Q.call(K,"[data-bonsaif-select-dropdown]"))||(ae=H.current)!=null&&ae.contains(K)||X(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:e.jsx(qn,{...l,columns:R,data:i,getRowId:a})})}function vt(r){return r?new Date(`${r}T12:00:00`):void 0}function Un(r){return r.toISOString().slice(0,10)}function Vl({calendarMonth:r,displayIndex:t}){const{previousMonth:a,nextMonth:n,goToMonth:s,months:l,labels:i,formatters:c}=Sn.useDayPicker(),u=!!a&&t===0,f=!!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&&s(a),disabled:!u,style:{height:28,width:28,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg-card)",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--text-main)",opacity:u?1:.45,cursor:u?"pointer":"not-allowed"},children:e.jsx($.HiChevronLeft,{size:16})}),e.jsx("button",{type:"button","aria-label":i.labelNext(n),onClick:()=>n&&s(n),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($.HiChevronRight,{size:16})})]})}function Gl(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Kl({startDate:r,endDate:t,onChange:a,minDate:n,viewMonth:s,numberOfMonths:l=1,showSummary:i=!0,startLabel:c="Inicio",endLabel:u="Regreso"}){const f={from:vt(r),to:vt(t)},m=vt(n),[b,p]=o.useState(vt(s||r));return o.useEffect(()=>{p(vt(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(Sn.DayPicker,{mode:"range",selected:f,month:b,onMonthChange:p,onSelect:y=>{const N=y!=null&&y.from?Un(y.from):r,M=y!=null&&y.to?Un(y.to):"";a({startDate:N,endDate:M})},numberOfMonths:l,hideNavigation:!0,disabled:m?{before:m}:void 0,showOutsideDays:!1,components:{MonthCaption:Vl},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:y=>Gl(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(y)),formatWeekdayName:y=>new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(y)},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:[u,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:t})]})]})]})}const Xl="bonsaif-ui:hide-tooltips";function Vn(){window.dispatchEvent(new CustomEvent(Xl))}function Yl(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Zl({trigger:r,items:t,align:a="end",width:n=220,disabled:s=!1,className:l="",menuClassName:i="",onOpenChange:c}){const[u,f]=o.useState(!1),[m,b]=o.useState(!1),[p,y]=o.useState({}),N=o.useRef(null),M=o.useRef(null),g=o.useCallback(E=>{f(E),c==null||c(E)},[c]),C=o.useCallback(()=>{const E=N.current;if(!E)return;const k=E.getBoundingClientRect(),q=typeof n=="number"?n:k.width,H=typeof n=="number"?n:Math.max(k.width,180),_=a==="end"?Math.max(8,k.right-H):Math.min(k.left,window.innerWidth-H-8),Y=window.innerHeight-k.bottom,Z=Y<240&&k.top>Y?void 0:k.bottom+6,T=Z===void 0?window.innerHeight-k.top+6:void 0;y({position:"fixed",zIndex:9999,left:_,top:Z,bottom:T,width:Yl(typeof n=="number"?q:n)})},[a,n]);o.useEffect(()=>b(!0),[]),o.useEffect(()=>{if(!u)return;C();const E=q=>{var _,Y;const H=q.target;!((_=N.current)!=null&&_.contains(H))&&!((Y=M.current)!=null&&Y.contains(H))&&g(!1)},k=q=>{q.key==="Escape"&&g(!1)};return document.addEventListener("mousedown",E),window.addEventListener("keydown",k),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{document.removeEventListener("mousedown",E),window.removeEventListener("keydown",k),window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[u,g,C]);const B=E=>{s||(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),g(!u))},A=o.isValidElement(r)?o.cloneElement(r,{onClick:()=>{s||(Vn(),g(!u))}}):r,z=u?e.jsx("div",{ref:M,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${i}`,style:p,children:t.map(E=>e.jsxs("div",{children:[E.separatorBefore&&e.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),e.jsxs("button",{type:"button",role:"menuitem",disabled:E.disabled,onClick:()=>{var k;E.disabled||(Vn(),(k=E.onSelect)==null||k.call(E),g(!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:E.danger?"var(--danger)":"var(--text-main)"},children:[E.icon&&e.jsx("span",{className:"mt-0.5 shrink-0",children:E.icon}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm font-medium",children:E.label}),E.description&&e.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:E.description})]})]})]},E.id))}):null;return e.jsxs("span",{ref:N,role:"button",tabIndex:s?-1:0,"aria-haspopup":"menu","aria-expanded":u,onKeyDown:B,className:`inline-flex ${s?"pointer-events-none opacity-60":""} ${l}`,children:[A,m&&z?Je.createPortal(z,document.body):null]})}const Ql=180,Gn="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Jl({open:r,onClose:t,title:a,subtitle:n,leadingIcon:s,confirmLabel:l="Guardar",onConfirm:i,loading:c=!1,confirmDisabled:u=!1,headerActions:f,bodyClassName:m="flex-1 overflow-y-auto px-6 py-5",width:b=440,hasUnsavedChanges:p=!1,unsavedChangesTitle:y="Descartar cambios",unsavedChangesDescription:N="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:M="Descartar",unsavedChangesCancelLabel:g="Seguir editando",onDiscardChanges:C,disabled:B=!1,children:A}){const[z,E]=o.useState(!1),[k,q]=o.useState(!1),[H,_]=o.useState(!1),Y=o.useCallback(()=>{q(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>_(!0))})},[]),Z=o.useCallback(()=>{_(!1),window.setTimeout(()=>q(!1),Ql)},[]),T=o.useCallback(()=>{if(p){Y();return}t()},[p,t,Y]),J=o.useCallback(()=>{_(!1),q(!1),C==null||C(),t()},[t,C]);return o.useEffect(()=>{E(!0)},[]),o.useEffect(()=>(document.body.style.overflow=r?"hidden":"",r||(_(!1),q(!1)),()=>{document.body.style.overflow=""}),[r]),o.useEffect(()=>{if(!r)return;const O=j=>{if(j.key==="Escape"){if(k){Z();return}T()}};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[Z,k,r,T]),z?Je.createPortal(e.jsxs("div",{"aria-hidden":!r,"data-bonsaif-overlay":r?"true":void 0,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 ${Gn}`,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, ${b}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(He,{variant:"icon",onClick:T,title:"Cerrar",children:e.jsx($.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})]})]}),(f||i)&&e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[f,i&&e.jsxs(e.Fragment,{children:[e.jsx(He,{variant:"secondary",size:"sm",onClick:T,style:{background:"var(--bg-input)"},children:"Cancelar"}),e.jsx(He,{variant:"primary",size:"sm",icon:e.jsx(Is.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:u,title:l})]})]})]}),e.jsx("div",{"data-drawer-scroll":"true",className:m,children:A})]}),B&&e.jsx("div",{className:"absolute inset-0 z-[1002] cursor-not-allowed",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 60%, transparent)",backdropFilter:"blur(2px)"}}),k&&e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":y,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[e.jsx("div",{className:`absolute inset-0 ${Gn} transition-opacity duration-200 ease-out ${H?"opacity-100":"opacity-0"}`,onClick:Z}),e.jsxs("div",{className:`relative z-10 w-full max-w-sm rounded-2xl border p-6 shadow-2xl transition-[opacity,transform] duration-200 ease-out ${H?"translate-y-0 scale-100 opacity-100":"translate-y-2 scale-[0.96] opacity-0"}`,style:{background:"var(--bg-card, #ffffff)",borderColor:"var(--border, #d8e1dc)"},children:[e.jsx(He,{variant:"icon",onClick:Z,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":g,children:e.jsx($.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:"var(--warning-bg, #fff7ed)"},children:e.jsx($.HiExclamationTriangle,{className:"h-5 w-5",style:{color:"var(--warning, #d97706)"}})}),e.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main, #0f2f2c)"},children:y}),e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:N}),e.jsxs("div",{className:"mt-6 flex gap-2",children:[e.jsx(He,{variant:"secondary",onClick:Z,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:g}),e.jsx(He,{variant:"secondary",onClick:J,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:M})]})]})]})]}),document.body):null}const Rl=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ei=/^\+?[0-9\s().-]+$/,ri=7,ti=15;function or(r){return r==null||String(r).trim()===""}function Kn(r){return typeof r=="number"?r:typeof r=="string"&&r.trim()!==""?Number(r):Number.NaN}function ja(r){return or(r)?!1:Rl.test(String(r))}function Wa(r){if(or(r))return!1;const t=String(r),a=t.replace(/\D/g,"");return ei.test(t)&&a.length>=ri&&a.length<=ti}function ai(r="Este campo es requerido."){return t=>or(t)?r:void 0}function ni(r="Ingresa un correo valido."){return t=>or(t)||ja(t)?void 0:r}function oi(r="Ingresa un telefono valido."){return t=>or(t)||Wa(t)?void 0:r}function si(r,t){return a=>or(a)||String(a).length>=r?void 0:t??`Debe tener al menos ${r} caracteres.`}function li(r,t){return a=>or(a)||String(a).length<=r?void 0:t??`Debe tener ${r} caracteres o menos.`}function ii(r,t){return a=>{if(or(a))return;const n=Kn(a);return Number.isFinite(n)&&n>=r?void 0:t??`Debe ser mayor o igual a ${r}.`}}function ci(r,t){return a=>{if(or(a))return;const n=Kn(a);return Number.isFinite(n)&&n<=r?void 0:t??`Debe ser menor o igual a ${r}.`}}function di(r,t="El formato no es valido."){return a=>or(a)||r.test(String(a))?void 0:t}function ui(r,t){const a={};for(const n of Object.keys(t)){const s=t[n];if(!s)continue;const l=Array.isArray(s)?s:[s];for(const i of l){const c=i(r[n],r);if(c){a[n]=c;break}}}return{valid:Object.keys(a).length===0,errors:a}}var Xn={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Yn=o.createContext&&o.createContext(Xn),fi=["attr","size","title"];function bi(r,t){if(r==null)return{};var a,n,s=pi(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 pi(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 Vt(){return Vt=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},Vt.apply(null,arguments)}function Zn(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 Gt(r){for(var t=1;t<arguments.length;t++){var a=arguments[t]!=null?arguments[t]:{};t%2?Zn(Object(a),!0).forEach(function(n){mi(r,n,a[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(a)):Zn(Object(a)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(a,n))})}return r}function mi(r,t,a){return(t=hi(t))in r?Object.defineProperty(r,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[t]=a,r}function hi(r){var t=gi(r,"string");return typeof t=="symbol"?t:t+""}function gi(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 Qn(r){return r&&r.map((t,a)=>o.createElement(t.tag,Gt({key:a},t.attr),Qn(t.child)))}function qa(r){return t=>o.createElement(vi,Vt({attr:Gt({},r.attr)},t),Qn(r.child))}function vi(r){var t=a=>{var{attr:n,size:s,title:l}=r,i=bi(r,fi),c=s||a.size||"1em",u;return a.className&&(u=a.className),r.className&&(u=(u?u+" ":"")+r.className),o.createElement("svg",Vt({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,n,i,{className:u,style:Gt(Gt({color:r.color||a.color},a.style),r.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),l&&o.createElement("title",null,l),r.children)};return Yn!==void 0?o.createElement(Yn.Consumer,null,a=>t(a)):t(Xn)}function Jn(r){return qa({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z"},child:[]}]})(r)}function xi(r){return qa({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 yi(r){return qa({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 Kt({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 Ua({label:r,containerClassName:t="",helperText:a,error:n,errorDisplay:s="inline",errorTooltipLabel:l="Error de validacion",labelAction:i,floatingLabel:c=!1,showPasswordToggle:u=!0,nativeValidation:f=!1,className:m="",required:b,...p}){const[y,N]=o.useState(()=>!!p.autoFocus),[M,g]=o.useState(!1),C=p.type==="password"&&u,B=C&&M?"text":p.type,A=!!n,z=A&&s!=="tooltip",E=A&&s!=="inline",k=f?b:void 0,q=A?"border-[var(--danger)] focus:border-[var(--danger)]":"",H=E?C?"pr-20":"pr-10":C?"pr-10":"",_=p.value!==void 0?String(p.value).length>0:p.defaultValue!==void 0&&String(p.defaultValue).length>0,Y=y||_,Z={top:Y?7:12,color:y?"var(--primary)":"var(--text-muted)",fontSize:Y?10:13,fontWeight:Y?600:400,textTransform:Y?"uppercase":"none"},T=te=>{var X;N(!0),(X=p.onFocus)==null||X.call(p,te)},J=te=>{var X;N(!1),(X=p.onBlur)==null||X.call(p,te)},O=C?e.jsxs("button",{type:"button","aria-label":M?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":M,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:()=>g(te=>!te),children:[e.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${M?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:e.jsx(xi,{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 ${M?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:e.jsx(yi,{className:"h-[18px] w-[18px]"})})]}):null,j=E?e.jsx(jr,{as:"span",content:n,className:`absolute top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--danger)] outline-none transition-colors hover:bg-[var(--danger-bg)] focus-visible:bg-[var(--danger-bg)] ${C?"right-10":"right-2.5"}`,children:e.jsx("span",{tabIndex:0,role:"img","aria-label":l,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(Jn,{className:"h-[18px] w-[18px]"})})}):null;return c?e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"relative block",children:[e.jsx(Kt,{...p,type:B,required:k,placeholder:" ","aria-invalid":A||p["aria-invalid"],"data-has-value":_?"true":void 0,className:`h-11 w-full pt-5 ${H} ${q} ${m}`,onFocus:T,onBlur:J}),e.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:Z,children:[r,b&&e.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),i&&e.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:Y?7:12},children:i}),j,O]}),z?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}),b&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),i&&e.jsx("span",{className:"ml-auto normal-case",children:i})]}),C?e.jsxs("span",{className:"relative block",children:[e.jsx(Kt,{...p,type:B,required:k,"aria-invalid":A||p["aria-invalid"],className:`w-full ${H} ${q} ${m}`,onFocus:T,onBlur:J}),j,O]}):e.jsxs("span",{className:"relative block",children:[e.jsx(Kt,{...p,required:k,"aria-invalid":A||p["aria-invalid"],className:`w-full ${H} ${q} ${m}`}),j]}),z?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 Rn(r){return r==null?"":String(r)}function wi({autoComplete:r="email",inputMode:t="email",validate:a=!0,invalidMessage:n="Ingresa un correo valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:u,...f}){const[m,b]=o.useState(()=>Rn(c)),p=i!==void 0?Rn(i):m,y=a&&p.length>0&&!ja(p)?n:void 0,N=M=>{i===void 0&&b(M.currentTarget.value),u==null||u(M)};return e.jsx(Ua,{...f,value:i,defaultValue:c,type:"text",inputMode:t,autoComplete:r,error:l??y,errorDisplay:s,onChange:N})}const Ni={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function ki({title:r="Sin resultados",description:t,icon:a=e.jsx($.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 ${Ni[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]})]})})}const Si={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function Ci(r){if(r===0)return"0 B";const t=["B","KB","MB","GB"],a=Math.min(Math.floor(Math.log(r)/Math.log(1024)),t.length-1),n=r/1024**a;return`${n>=10||a===0?n.toFixed(0):n.toFixed(1)} ${t[a]}`}function eo(r,t){return t?t.split(",").map(a=>a.trim().toLowerCase()).filter(Boolean).some(a=>{const n=r.name.toLowerCase(),s=r.type.toLowerCase();return a.startsWith(".")?n.endsWith(a):a.endsWith("/*")?s.startsWith(a.slice(0,-1)):s===a}):!0}function Ei(r,t,a){return t?a===void 0?r:r.slice(0,Math.max(0,a)):r.slice(0,1)}function Mi({label:r,helperText:t,error:a,labelAction:n,value:s,defaultValue:l=[],onFilesChange:i,onRejectedFiles:c,multiple:u=!1,maxFiles:f,appendFiles:m=!1,showFileList:b=!0,clearable:p=!0,browseLabel:y="Buscar archivos",dropLabel:N="Suelta los archivos aqui",emptyLabel:M="Arrastra y suelta archivos",emptyDescription:g="o haz click para buscarlos en tu equipo",selectedLabel:C="Archivos seleccionados",size:B="md",containerClassName:A="",dropzoneClassName:z="",fileListClassName:E="",className:k="",id:q,accept:H,disabled:_,required:Y,...Z}){const T=o.useId(),J=q??T,O=o.useRef(null),[j,te]=o.useState(!1),[X,I]=o.useState(l),ee=s??X,R=!!a,x=p&&ee.length>0&&!_,S=(W,ne)=>{s===void 0&&I(W),i==null||i(W,ne)},K=(W,ne)=>{const oe=W.filter(xe=>eo(xe,H)),he=W.filter(xe=>!eo(xe,H)),_e=m?[...ee,...oe]:oe,Ge=Ei(_e,u,f);he.length>0&&(c==null||c(he)),S(Ge,ne)},Q=()=>{var W;_||(W=O.current)==null||W.click()},ae=W=>{K(Array.from(W.target.files??[]),W),W.target.value=""},ce=W=>{W.preventDefault(),_||te(!0)},ve=W=>{W.currentTarget.contains(W.relatedTarget)||te(!1)},re=W=>{W.preventDefault(),te(!1),!_&&K(Array.from(W.dataTransfer.files),W)},G=W=>{W.key!=="Enter"&&W.key!==" "||(W.preventDefault(),Q())},h=W=>{S(ee.filter((ne,oe)=>oe!==W))},L=()=>{S([])};return e.jsxs("div",{className:`flex flex-col gap-2 ${A}`,children:[(r||n)&&e.jsxs("div",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[r&&e.jsx("span",{children:r}),Y&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),n&&e.jsx("span",{className:"ml-auto normal-case",children:n})]}),e.jsx("input",{...Z,ref:O,id:J,type:"file",accept:H,multiple:u,disabled:_,required:Y&&ee.length===0,"aria-invalid":R||Z["aria-invalid"],className:"sr-only",onChange:ae}),e.jsxs("div",{role:"button",tabIndex:_?-1:0,"aria-controls":J,"aria-disabled":_||void 0,"aria-invalid":R||void 0,className:`flex cursor-pointer flex-col items-center justify-center gap-3 rounded-lg border border-dashed bg-[var(--bg-card)] text-center outline-none transition-colors focus:border-[var(--primary)] focus:bg-[var(--bg-input)] ${Si[B]} ${j?"border-[var(--primary)] bg-[var(--bg-input)]":R?"border-[var(--danger)]":"border-[var(--border)]"} ${_?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${z} ${k}`,onClick:Q,onDragOver:ce,onDragLeave:ve,onDrop:re,onKeyDown:G,children:[e.jsx("span",{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:e.jsx($.HiArrowUpTray,{className:"h-5 w-5"})}),e.jsxs("span",{className:"space-y-1",children:[e.jsx("span",{className:"block text-sm font-semibold text-[var(--text-main)]",children:j?N:M}),g&&e.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:g})]}),y&&e.jsx("span",{className:"inline-flex h-9 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] px-3 text-xs font-semibold text-[var(--text-main)] shadow-sm shadow-black/5 transition-colors",children:y})]}),b&&ee.length>0&&e.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${E}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase text-[var(--text-muted)]",children:C}),x&&e.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":"Quitar todos los archivos",onClick:L,children:e.jsx($.HiTrash,{className:"h-4 w-4"})})]}),e.jsx("ul",{className:"divide-y divide-[var(--border)]",children:ee.map((W,ne)=>e.jsxs("li",{className:"flex items-center gap-3 px-3 py-2",children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-[var(--bg-input)] text-[var(--text-muted)]",children:e.jsx($.HiDocument,{className:"h-4 w-4"})}),e.jsxs("span",{className:"min-w-0 flex-1 text-left",children:[e.jsx("span",{className:"block truncate text-sm font-medium text-[var(--text-main)]",children:W.name}),e.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:Ci(W.size)})]}),!_&&e.jsx("button",{type:"button",className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":`Quitar ${W.name}`,onClick:()=>h(ne),children:e.jsx($.HiXMark,{className:"h-4 w-4"})})]},`${W.name}-${W.lastModified}-${ne}`))})]}),a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:a}):t?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:t}):null]})}const Ti=[{value:"texto",label:"texto"},{value:"numero",label:"número"},{value:"fecha",label:"fecha"},{value:"booleano",label:"booleano"},{value:"email",label:"email"},{value:"telefono",label:"teléfono"},{value:"select",label:"select"},{value:"textarea",label:"textarea"},{value:"archivo",label:"archivo"},{value:"imagen",label:"imagen"}];function Li({fields:r,title:t="Layout",fieldTypes:a=Ti,saveLabel:n="Guardar",allowAddField:s=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:u,onChange:f}){const[m,b]=o.useState(()=>r.map(A=>({key:!1,type:"",...A}))),[p,y]=o.useState(""),[N,M]=o.useState(""),g=o.useCallback((A,z)=>{b(E=>{const k=E.map((q,H)=>H===A?{...q,...z}:q);return f==null||f(k),k})},[f]),C=o.useCallback(()=>{u==null||u(m)},[m,u]),B=o.useCallback(()=>{var k;const A=p.trim();if(!A){M("Ingresa un nombre de campo.");return}if(m.some(q=>q.name.toLowerCase()===A.toLowerCase())){M("Ese campo ya existe en el arreglo.");return}const E={name:A,key:!1,type:((k=a[0])==null?void 0:k.value)??""};b(q=>{const H=[...q,E];return f==null||f(H),H}),y(""),M("")},[a,m,p,f]);return e.jsxs("div",{className:"flex flex-col rounded-xl border shadow-sm",style:{borderColor:"var(--border)",background:"var(--bg-card)",color:"var(--text-main)"},children:[e.jsx("div",{className:"border-b px-6 py-4",style:{borderColor:"var(--border)"},children:e.jsx("span",{className:"text-base font-semibold",style:{color:"var(--text-main)"},children:t})}),e.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] gap-4 border-b px-6 py-2 text-xs font-medium uppercase tracking-wide",style:{borderColor:"var(--border)",color:"var(--text-muted)"},children:[e.jsx("span",{children:"Campo"}),e.jsx("span",{className:"text-center",children:"Llave"}),e.jsx("span",{children:"Tipo de Campo"})]}),e.jsxs("div",{className:"max-h-[420px] overflow-y-auto",children:[m.map((A,z)=>e.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] items-center gap-4 border-b px-6 py-3 last:border-0 hover:bg-[var(--bg-input)] transition-colors",style:{borderColor:"var(--border)"},children:[e.jsx("span",{className:"text-sm font-medium",style:{color:"var(--text-main)"},children:A.name}),e.jsx("div",{className:"flex justify-center",children:e.jsx(Ft,{size:"sm",checked:A.key??!1,onChange:E=>g(z,{key:E.target.checked}),"aria-label":`${A.name} es clave`})}),e.jsx(Er,{value:A.type??"",onChange:E=>g(z,{type:E}),options:a,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${A.name}`})]},A.name)),m.length===0&&e.jsx("p",{className:"px-6 py-8 text-center text-sm",style:{color:"var(--text-muted)"},children:"No hay campos disponibles."})]}),e.jsx("div",{className:"flex justify-end border-t px-6 py-4",style:{borderColor:"var(--border)"},children:e.jsxs("div",{className:"w-full space-y-2",children:[s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:p,onChange:A=>{y(A.currentTarget.value),N&&M("")},onKeyDown:A=>{A.key==="Enter"&&(A.preventDefault(),B())},placeholder:l,className:"min-w-0 flex-1 rounded-lg border px-3 py-2 text-sm outline-none transition-colors",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"},"aria-label":"Nombre del nuevo campo"}),e.jsx(He,{variant:"secondary",onClick:B,height:36,padding:"0 12px",children:i})]}),N&&e.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:N})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(He,{variant:"primary",onClick:C,disabled:c,loading:c,children:n})})]})})]})}function ro({label:r,children:t,helperText:a,error:n,labelAction:s,required:l=!1,className:i="",contentClassName:c=""}){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 ${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]})}function to(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function ao(r,t){if(r.length!==t.length)return!1;const a=new Set(t);return r.every(n=>a.has(n))}function Va(r){return r.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function $i(r,t){if(!t)return!0;const a=Va(t);return Va(r.label).includes(a)||!!(r.sublabel&&Va(r.sublabel).includes(a))}function Ai({value:r,onChange:t,options:a,placeholder:n="Seleccionar…",disabled:s=!1,className:l="",style:i,height:c=40,padding:u="6px 10px",searchable:f=!0,minOptionsForSearch:m=6,maxVisibleValues:b=2,truncateSelectedValues:p=!0,emptyText:y="Sin resultados",clearLabel:N="Limpiar seleccion",pruneMissingValues:M=!0}){const[g,C]=o.useState(!1),[B,A]=o.useState(""),[z,E]=o.useState(0),[k,q]=o.useState(!1),[H,_]=o.useState({}),Y=o.useRef(null),Z=o.useRef(null),T=o.useRef(null),J=o.useRef(null),O=f&&a.length>=m,j=o.useMemo(()=>new Set(r),[r]),te=o.useMemo(()=>{const h=new Map;for(const L of a)h.set(L.value,L);return h},[a]),X=o.useMemo(()=>{const h=[];for(const L of r){const W=te.get(L);W&&h.push(W)}return h},[te,r]),I=b==="all"?X.length:b,ee=X.slice(0,I),R=Math.max(0,X.length-ee.length),x=o.useMemo(()=>{const h=B.trim();return!O||!h?a:a.filter(L=>$i(L,h))},[a,B,O]),S=o.useCallback(()=>{const h=Y.current;if(!h)return;const L=h.getBoundingClientRect(),W=O?304:244,ne=window.innerHeight-L.bottom,oe=ne<W&&L.top>ne;_({position:"fixed",left:L.left,top:oe?void 0:L.bottom+4,bottom:oe?window.innerHeight-L.top+4:void 0,width:Math.max(L.width,240),zIndex:9999})},[O]),K=o.useCallback(h=>{ao(r,h)||t(h)},[t,r]),Q=o.useCallback(h=>{const L=te.get(h);if(L!=null&&L.disabled)return;const W=j.has(h)?r.filter(ne=>ne!==h):[...r,h];K(W)},[K,te,r,j]),ae=o.useCallback(()=>K([]),[K]),ce=o.useCallback(()=>{C(!1),A(""),E(0)},[]);o.useEffect(()=>q(!0),[]);const ve=o.useMemo(()=>a.map(h=>h.value).join("\0"),[a]);o.useEffect(()=>{if(!M||r.length===0||a.length===0)return;const h=new Set(a.map(W=>W.value)),L=r.filter(W=>h.has(W));ao(r,L)||t(L)},[ve]),o.useEffect(()=>{if(!g)return;function h(L){var ne,oe;const W=L.target;!((ne=Y.current)!=null&&ne.contains(W))&&!((oe=Z.current)!=null&&oe.contains(W))&&ce()}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[ce,g]),o.useEffect(()=>{g&&(E(0),S(),O&&setTimeout(()=>{var h;return(h=T.current)==null?void 0:h.focus()},0))},[g,O,S]),o.useEffect(()=>{if(g)return window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}},[g,S]),o.useEffect(()=>{if(x.length===0){E(0);return}E(h=>Math.min(h,x.length-1))},[x.length]),o.useEffect(()=>{if(z<0||!J.current)return;const h=J.current.children[z];h==null||h.scrollIntoView({block:"nearest"})},[z]);function re(h){if(!s){if(!g){(h.key==="Enter"||h.key===" "||h.key==="ArrowDown")&&(h.preventDefault(),C(!0));return}if(h.key==="Escape"){h.preventDefault(),ce();return}if(h.key==="ArrowDown"){if(h.preventDefault(),x.length===0)return;E(L=>Math.min(L+1,x.length-1));return}if(h.key==="ArrowUp"){h.preventDefault(),E(L=>Math.max(L-1,0));return}if(h.key==="Enter"&&x[z]&&!x[z].disabled){h.preventDefault(),Q(x[z].value);return}h.key==="Backspace"&&!B&&r.length&&(h.preventDefault(),K(r.slice(0,-1)))}}const G=e.jsxs("div",{ref:Z,className:"overflow-hidden rounded-xl shadow-xl",style:{...H,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[O&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx($.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:T,value:B,onChange:h=>{A(h.target.value),E(0)},onKeyDown:h=>{(h.key==="ArrowDown"||h.key==="ArrowUp"||h.key==="Enter"||h.key==="Escape")&&(h.stopPropagation(),re(h))},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","aria-label":"Limpiar búsqueda",onMouseDown:h=>{h.preventDefault(),A(""),E(0)},children:e.jsx($.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),r.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:[X.length," seleccionados",r.length>X.length?` (${r.length-X.length} no disponibles)`:""]}),e.jsx("button",{type:"button",onMouseDown:h=>{h.preventDefault(),ae()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:N})]}),e.jsxs("ul",{ref:J,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:O?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[x.map((h,L)=>{const W=L===z,ne=j.has(h.value);return e.jsxs("li",{role:"option","aria-selected":ne,onMouseDown:oe=>{oe.preventDefault(),!h.disabled&&Q(h.value)},onMouseEnter:()=>!h.disabled&&E(L),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:W?"var(--bg-hover)":ne?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:h.disabled?"var(--text-muted)":"var(--text-main)",cursor:h.disabled?"not-allowed":"pointer",opacity:h.disabled?.58:1},children:[e.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:ne?"var(--primary)":"var(--border)",background:ne?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:ne&&e.jsx($.HiCheck,{className:"h-3 w-3"})}),h.color&&e.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:h.color}}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:h.label}),h.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:h.sublabel})]}),h.badge&&e.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:h.badge})]},h.value)}),x.length===0&&e.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:y})]})]});return e.jsxs("div",{ref:Y,className:`relative ${l||"w-full"}`,style:i,onKeyDown:re,children:[e.jsxs("button",{type:"button",disabled:s,onClick:()=>{s||(g?ce():C(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:to(c),padding:to(u),background:"var(--bg-input)",color:X.length?"var(--text-main)":"var(--text-muted)",border:g?"1px solid var(--primary)":"1px solid var(--border)",opacity:s?.5:1,cursor:s?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":g,children:[e.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:ee.length?e.jsxs(e.Fragment,{children:[ee.map(h=>e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${p?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[h.color&&e.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:h.color}}),e.jsx("span",{className:p?"truncate":"break-words",children:h.label}),e.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${h.label}`,onMouseDown:L=>{L.preventDefault(),L.stopPropagation(),Q(h.value)},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx($.HiXMark,{className:"h-3 w-3"})})]},h.value)),R>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:["+",R]})]}):e.jsx("span",{className:"truncate",children:n})}),X.length?e.jsx("span",{role:"button",tabIndex:-1,"aria-label":N,onMouseDown:h=>{h.preventDefault(),h.stopPropagation(),ae()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx($.HiXMark,{className:"h-3.5 w-3.5"})}):e.jsx($.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:g?"rotate(180deg)":"rotate(0deg)"}})]}),g&&k&&Je.createPortal(G,document.body)]})}function Di({inputMode:r="decimal",...t}){return e.jsx(Ua,{...t,type:"number",inputMode:r})}function Ii(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 Bi({page:r,totalPages:t,onPageChange:a,disabled:n=!1,siblingCount:s=1,className:l=""}){const i=Math.max(1,t),c=Math.min(Math.max(1,r),i),u=Ii(c,i,s);return e.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[e.jsx(He,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:n||c<=1,onClick:()=>a(c-1),children:e.jsx($.HiChevronLeft,{className:"h-4 w-4"})}),u.map((f,m)=>f==="..."?e.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${m}`):e.jsx("button",{type:"button","aria-current":f===c?"page":void 0,disabled:n,onClick:()=>a(f),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:f===c?"var(--primary)":"var(--border)",background:f===c?"var(--primary)":"var(--bg-card)",color:f===c?"var(--primary-fg)":"var(--text-secondary)"},children:f},f)),e.jsx(He,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:n||c>=i,onClick:()=>a(c+1),children:e.jsx($.HiChevronRight,{className:"h-4 w-4"})})]})}const no=[{value:"+1",label:"+1",sublabel:"Estados Unidos, Canada, Caribe"},{value:"+7",label:"+7",sublabel:"Rusia, Kazajistan"},{value:"+20",label:"+20",sublabel:"Egipto"},{value:"+27",label:"+27",sublabel:"Sudafrica"},{value:"+30",label:"+30",sublabel:"Grecia"},{value:"+31",label:"+31",sublabel:"Paises Bajos"},{value:"+32",label:"+32",sublabel:"Belgica"},{value:"+33",label:"+33",sublabel:"Francia"},{value:"+34",label:"+34",sublabel:"Espana"},{value:"+36",label:"+36",sublabel:"Hungria"},{value:"+39",label:"+39",sublabel:"Italia, Vaticano"},{value:"+40",label:"+40",sublabel:"Rumania"},{value:"+41",label:"+41",sublabel:"Suiza"},{value:"+43",label:"+43",sublabel:"Austria"},{value:"+44",label:"+44",sublabel:"Reino Unido"},{value:"+45",label:"+45",sublabel:"Dinamarca"},{value:"+46",label:"+46",sublabel:"Suecia"},{value:"+47",label:"+47",sublabel:"Noruega"},{value:"+48",label:"+48",sublabel:"Polonia"},{value:"+49",label:"+49",sublabel:"Alemania"},{value:"+51",label:"+51",sublabel:"Peru"},{value:"+52",label:"+52",sublabel:"Mexico"},{value:"+53",label:"+53",sublabel:"Cuba"},{value:"+54",label:"+54",sublabel:"Argentina"},{value:"+55",label:"+55",sublabel:"Brasil"},{value:"+56",label:"+56",sublabel:"Chile"},{value:"+57",label:"+57",sublabel:"Colombia"},{value:"+58",label:"+58",sublabel:"Venezuela"},{value:"+60",label:"+60",sublabel:"Malasia"},{value:"+61",label:"+61",sublabel:"Australia"},{value:"+62",label:"+62",sublabel:"Indonesia"},{value:"+63",label:"+63",sublabel:"Filipinas"},{value:"+64",label:"+64",sublabel:"Nueva Zelanda"},{value:"+65",label:"+65",sublabel:"Singapur"},{value:"+66",label:"+66",sublabel:"Tailandia"},{value:"+81",label:"+81",sublabel:"Japon"},{value:"+82",label:"+82",sublabel:"Corea del Sur"},{value:"+84",label:"+84",sublabel:"Vietnam"},{value:"+86",label:"+86",sublabel:"China"},{value:"+90",label:"+90",sublabel:"Turquia"},{value:"+91",label:"+91",sublabel:"India"},{value:"+92",label:"+92",sublabel:"Pakistan"},{value:"+93",label:"+93",sublabel:"Afganistan"},{value:"+94",label:"+94",sublabel:"Sri Lanka"},{value:"+95",label:"+95",sublabel:"Myanmar"},{value:"+98",label:"+98",sublabel:"Iran"},{value:"+211",label:"+211",sublabel:"Sudan del Sur"},{value:"+212",label:"+212",sublabel:"Marruecos, Sahara Occidental"},{value:"+213",label:"+213",sublabel:"Argelia"},{value:"+216",label:"+216",sublabel:"Tunez"},{value:"+218",label:"+218",sublabel:"Libia"},{value:"+220",label:"+220",sublabel:"Gambia"},{value:"+221",label:"+221",sublabel:"Senegal"},{value:"+222",label:"+222",sublabel:"Mauritania"},{value:"+223",label:"+223",sublabel:"Mali"},{value:"+224",label:"+224",sublabel:"Guinea"},{value:"+225",label:"+225",sublabel:"Costa de Marfil"},{value:"+226",label:"+226",sublabel:"Burkina Faso"},{value:"+227",label:"+227",sublabel:"Niger"},{value:"+228",label:"+228",sublabel:"Togo"},{value:"+229",label:"+229",sublabel:"Benin"},{value:"+230",label:"+230",sublabel:"Mauricio"},{value:"+231",label:"+231",sublabel:"Liberia"},{value:"+232",label:"+232",sublabel:"Sierra Leona"},{value:"+233",label:"+233",sublabel:"Ghana"},{value:"+234",label:"+234",sublabel:"Nigeria"},{value:"+235",label:"+235",sublabel:"Chad"},{value:"+236",label:"+236",sublabel:"Republica Centroafricana"},{value:"+237",label:"+237",sublabel:"Camerun"},{value:"+238",label:"+238",sublabel:"Cabo Verde"},{value:"+239",label:"+239",sublabel:"Santo Tome y Principe"},{value:"+240",label:"+240",sublabel:"Guinea Ecuatorial"},{value:"+241",label:"+241",sublabel:"Gabon"},{value:"+242",label:"+242",sublabel:"Republica del Congo"},{value:"+243",label:"+243",sublabel:"Republica Democratica del Congo"},{value:"+244",label:"+244",sublabel:"Angola"},{value:"+245",label:"+245",sublabel:"Guinea-Bisau"},{value:"+246",label:"+246",sublabel:"Territorio Britanico del Oceano Indico"},{value:"+248",label:"+248",sublabel:"Seychelles"},{value:"+249",label:"+249",sublabel:"Sudan"},{value:"+250",label:"+250",sublabel:"Ruanda"},{value:"+251",label:"+251",sublabel:"Etiopia"},{value:"+252",label:"+252",sublabel:"Somalia"},{value:"+253",label:"+253",sublabel:"Yibuti"},{value:"+254",label:"+254",sublabel:"Kenia"},{value:"+255",label:"+255",sublabel:"Tanzania"},{value:"+256",label:"+256",sublabel:"Uganda"},{value:"+257",label:"+257",sublabel:"Burundi"},{value:"+258",label:"+258",sublabel:"Mozambique"},{value:"+260",label:"+260",sublabel:"Zambia"},{value:"+261",label:"+261",sublabel:"Madagascar"},{value:"+262",label:"+262",sublabel:"Reunion, Mayotte"},{value:"+263",label:"+263",sublabel:"Zimbabue"},{value:"+264",label:"+264",sublabel:"Namibia"},{value:"+265",label:"+265",sublabel:"Malaui"},{value:"+266",label:"+266",sublabel:"Lesoto"},{value:"+267",label:"+267",sublabel:"Botsuana"},{value:"+268",label:"+268",sublabel:"Esuatini"},{value:"+269",label:"+269",sublabel:"Comoras"},{value:"+290",label:"+290",sublabel:"Santa Elena"},{value:"+291",label:"+291",sublabel:"Eritrea"},{value:"+297",label:"+297",sublabel:"Aruba"},{value:"+298",label:"+298",sublabel:"Islas Feroe"},{value:"+299",label:"+299",sublabel:"Groenlandia"},{value:"+350",label:"+350",sublabel:"Gibraltar"},{value:"+351",label:"+351",sublabel:"Portugal"},{value:"+352",label:"+352",sublabel:"Luxemburgo"},{value:"+353",label:"+353",sublabel:"Irlanda"},{value:"+354",label:"+354",sublabel:"Islandia"},{value:"+355",label:"+355",sublabel:"Albania"},{value:"+356",label:"+356",sublabel:"Malta"},{value:"+357",label:"+357",sublabel:"Chipre"},{value:"+358",label:"+358",sublabel:"Finlandia, Aland"},{value:"+359",label:"+359",sublabel:"Bulgaria"},{value:"+370",label:"+370",sublabel:"Lituania"},{value:"+371",label:"+371",sublabel:"Letonia"},{value:"+372",label:"+372",sublabel:"Estonia"},{value:"+373",label:"+373",sublabel:"Moldavia"},{value:"+374",label:"+374",sublabel:"Armenia"},{value:"+375",label:"+375",sublabel:"Bielorrusia"},{value:"+376",label:"+376",sublabel:"Andorra"},{value:"+377",label:"+377",sublabel:"Monaco"},{value:"+378",label:"+378",sublabel:"San Marino"},{value:"+380",label:"+380",sublabel:"Ucrania"},{value:"+381",label:"+381",sublabel:"Serbia"},{value:"+382",label:"+382",sublabel:"Montenegro"},{value:"+383",label:"+383",sublabel:"Kosovo"},{value:"+385",label:"+385",sublabel:"Croacia"},{value:"+386",label:"+386",sublabel:"Eslovenia"},{value:"+387",label:"+387",sublabel:"Bosnia y Herzegovina"},{value:"+389",label:"+389",sublabel:"Macedonia del Norte"},{value:"+420",label:"+420",sublabel:"Chequia"},{value:"+421",label:"+421",sublabel:"Eslovaquia"},{value:"+423",label:"+423",sublabel:"Liechtenstein"},{value:"+500",label:"+500",sublabel:"Islas Malvinas"},{value:"+501",label:"+501",sublabel:"Belice"},{value:"+502",label:"+502",sublabel:"Guatemala"},{value:"+503",label:"+503",sublabel:"El Salvador"},{value:"+504",label:"+504",sublabel:"Honduras"},{value:"+505",label:"+505",sublabel:"Nicaragua"},{value:"+506",label:"+506",sublabel:"Costa Rica"},{value:"+507",label:"+507",sublabel:"Panama"},{value:"+508",label:"+508",sublabel:"San Pedro y Miquelon"},{value:"+509",label:"+509",sublabel:"Haiti"},{value:"+590",label:"+590",sublabel:"Guadalupe, San Bartolome"},{value:"+591",label:"+591",sublabel:"Bolivia"},{value:"+592",label:"+592",sublabel:"Guyana"},{value:"+593",label:"+593",sublabel:"Ecuador"},{value:"+594",label:"+594",sublabel:"Guayana Francesa"},{value:"+595",label:"+595",sublabel:"Paraguay"},{value:"+596",label:"+596",sublabel:"Martinica"},{value:"+597",label:"+597",sublabel:"Surinam"},{value:"+598",label:"+598",sublabel:"Uruguay"},{value:"+599",label:"+599",sublabel:"Caribe Neerlandes, Curazao"},{value:"+670",label:"+670",sublabel:"Timor Oriental"},{value:"+672",label:"+672",sublabel:"Antartida, Isla Norfolk"},{value:"+673",label:"+673",sublabel:"Brunei"},{value:"+674",label:"+674",sublabel:"Nauru"},{value:"+675",label:"+675",sublabel:"Papua Nueva Guinea"},{value:"+676",label:"+676",sublabel:"Tonga"},{value:"+677",label:"+677",sublabel:"Islas Salomon"},{value:"+678",label:"+678",sublabel:"Vanuatu"},{value:"+679",label:"+679",sublabel:"Fiyi"},{value:"+680",label:"+680",sublabel:"Palaos"},{value:"+681",label:"+681",sublabel:"Wallis y Futuna"},{value:"+682",label:"+682",sublabel:"Islas Cook"},{value:"+683",label:"+683",sublabel:"Niue"},{value:"+685",label:"+685",sublabel:"Samoa"},{value:"+686",label:"+686",sublabel:"Kiribati"},{value:"+687",label:"+687",sublabel:"Nueva Caledonia"},{value:"+688",label:"+688",sublabel:"Tuvalu"},{value:"+689",label:"+689",sublabel:"Polinesia Francesa"},{value:"+690",label:"+690",sublabel:"Tokelau"},{value:"+691",label:"+691",sublabel:"Micronesia"},{value:"+692",label:"+692",sublabel:"Islas Marshall"},{value:"+850",label:"+850",sublabel:"Corea del Norte"},{value:"+852",label:"+852",sublabel:"Hong Kong"},{value:"+853",label:"+853",sublabel:"Macao"},{value:"+855",label:"+855",sublabel:"Camboya"},{value:"+856",label:"+856",sublabel:"Laos"},{value:"+880",label:"+880",sublabel:"Banglades"},{value:"+886",label:"+886",sublabel:"Taiwan"},{value:"+960",label:"+960",sublabel:"Maldivas"},{value:"+961",label:"+961",sublabel:"Libano"},{value:"+962",label:"+962",sublabel:"Jordania"},{value:"+963",label:"+963",sublabel:"Siria"},{value:"+964",label:"+964",sublabel:"Irak"},{value:"+965",label:"+965",sublabel:"Kuwait"},{value:"+966",label:"+966",sublabel:"Arabia Saudita"},{value:"+967",label:"+967",sublabel:"Yemen"},{value:"+968",label:"+968",sublabel:"Oman"},{value:"+970",label:"+970",sublabel:"Palestina"},{value:"+971",label:"+971",sublabel:"Emiratos Arabes Unidos"},{value:"+972",label:"+972",sublabel:"Israel"},{value:"+973",label:"+973",sublabel:"Barein"},{value:"+974",label:"+974",sublabel:"Catar"},{value:"+975",label:"+975",sublabel:"Butan"},{value:"+976",label:"+976",sublabel:"Mongolia"},{value:"+977",label:"+977",sublabel:"Nepal"},{value:"+992",label:"+992",sublabel:"Tayikistan"},{value:"+993",label:"+993",sublabel:"Turkmenistan"},{value:"+994",label:"+994",sublabel:"Azerbaiyan"},{value:"+995",label:"+995",sublabel:"Georgia"},{value:"+996",label:"+996",sublabel:"Kirguistan"},{value:"+998",label:"+998",sublabel:"Uzbekistan"}];function oo(r){return r==null?"":String(r)}function Xt(r){return r?r.startsWith("+")?r:`+${r}`:"+1"}function Oi(r){return typeof r=="number"?`${r}px`:r}function Hi({autoComplete:r="tel",inputMode:t="tel",validate:a=!0,invalidMessage:n="Ingresa un telefono valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:u,countryCode:f,defaultCountryCode:m="+1",onCountryCodeChange:b,allowedCountryCodes:p,countryCodeOptions:y,countryCodePlaceholder:N="Codigo",countryCodeClassName:M="",countryCodeWidth:g=84,onPhoneValueChange:C,label:B,containerClassName:A="",helperText:z,labelAction:E,className:k="",required:q,disabled:H,floatingLabel:_,showPasswordToggle:Y,nativeValidation:Z,errorTooltipLabel:T="Error de validacion",...J}){var W;const[O,j]=o.useState(()=>oo(c)),[te,X]=o.useState(()=>Xt(m)),I=o.useMemo(()=>{const ne=y??no,oe=p==null?void 0:p.map(Xt);return oe!=null&&oe.length?ne.filter(he=>oe.includes(he.value)):ne},[p,y]),ee=((W=I[0])==null?void 0:W.value)??"+1",R=I.some(ne=>ne.value===Xt(f??te))?Xt(f??te):ee,x=i!==void 0?oo(i):O,S=`${R} ${x}`.trim(),K=a&&x.length>0&&!Wa(S)?n:void 0,Q=l??K,ae=!!Q,ce=ae&&s!=="tooltip",ve=ae&&s!=="inline",re=ae?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",G=ne=>{const oe=ne.currentTarget.value;i===void 0&&j(oe),C==null||C(oe,{countryCode:R,nationalNumber:oe,fullNumber:`${R} ${oe}`.trim()}),u==null||u(ne)},h=ne=>{f===void 0&&X(ne),b==null||b(ne),C==null||C(x,{countryCode:ne,nationalNumber:x,fullNumber:`${ne} ${x}`.trim()})},L=ve?e.jsx(jr,{as:"span",content:Q,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(--danger)] outline-none transition-colors hover:bg-[var(--danger-bg)] focus-visible:bg-[var(--danger-bg)]",children:e.jsx("span",{tabIndex:0,role:"img","aria-label":T,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(Jn,{className:"h-[18px] w-[18px]"})})}):null;return e.jsxs("div",{className:`flex flex-col gap-2 ${A}`,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:B}),q&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),E&&e.jsx("span",{className:"ml-auto normal-case",children:E})]}),e.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${re}`,children:[e.jsx(Er,{value:R,onChange:h,options:I,placeholder:N,disabled:H,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${M}`,style:{width:Oi(g)},height:38,padding:"0 8px 0 10px"}),e.jsx("span",{className:"h-5 w-px shrink-0 bg-[var(--border)]"}),e.jsxs("span",{className:"relative min-w-0 flex-1 self-stretch",children:[e.jsx("input",{...J,value:i,defaultValue:c,type:"tel",inputMode:t,autoComplete:r,disabled:H,required:void 0,"aria-label":J["aria-label"]??(typeof B=="string"?B:void 0),"aria-invalid":ae||J["aria-invalid"],className:`h-full w-full min-w-0 bg-transparent px-2 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed disabled:opacity-60 ${ve?"pr-10":""} ${k}`,onChange:G}),L]})]}),ce?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:Q}):z?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:z}):null]})}function Pi({value:r,onChange:t,options:a,name:n,label:s,orientation:l="vertical",disabled:i=!1,className:c="",optionClassName:u=""}){return e.jsxs("fieldset",{className:`min-w-0 ${c}`,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(f=>{const m=f.value===r,b=i||f.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 ${b?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${u}`,style:{borderColor:m?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:m?"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:f.value,checked:m,disabled:b,onChange:()=>t(f.value),className:"absolute inset-0 opacity-0"}),e.jsx("span",{className:`h-2 w-2 rounded-full transition ${m?"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:f.label}),f.description&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:f.description})]})]},f.value)})})]})}const so=()=>'<button type="button" class="rich-img-del" data-action="delete-img" title="Eliminar imagen"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M9 2a1 1 0 0 0-.894.553L7.382 4H4a1 1 0 0 0 0 2v10a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V6a1 1 0 0 0 0-2h-3.382l-.724-1.447A1 1 0 0 0 11 2H9zm-1 6a1 1 0 1 1 2 0v4a1 1 0 1 1-2 0V8zm4 0a1 1 0 1 1 2 0v4a1 1 0 1 1-2 0V8z" clip-rule="evenodd"/></svg></button>',xt=r=>r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),lo=r=>r.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(t,a,n)=>`${a}${n.toLocaleUpperCase()}`),Fi=r=>r.replace(/[<>]/g,"").toLowerCase(),zi=new Set(["p","br","div","span","b","strong","i","em","u","s","strike","ul","ol","li","h1","h2","h3","h4","blockquote","a","img","hr"]),_i=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,ji=r=>{const t=r.indexOf("<!--StartFragment-->"),a=r.indexOf("<!--EndFragment-->");if(t!==-1&&a!==-1&&a>t)return r.slice(t+20,a);const n=r.match(/<body[^>]*>([\s\S]*)<\/body>/i);return n?n[1]:r},Yt=(r,t)=>t.test(r),Wi=r=>Yt(r,/font-weight\s*:\s*(bold|[6-9]00)/i),qi=r=>Yt(r,/font-style\s*:\s*italic/i),Ui=r=>Yt(r,/text-decoration(?:-line)?\s*:[^;]*underline/i),Vi=r=>Yt(r,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),Zt=(r,t)=>{var n;if(!r.childNodes.length||r.childNodes.length===1&&((n=r.firstChild)==null?void 0:n.nodeType)===Node.ELEMENT_NODE&&r.firstChild.tagName.toLowerCase()===t)return;const a=r.ownerDocument.createElement(t);for(;r.firstChild;)a.appendChild(r.firstChild);r.appendChild(a)},Qt=r=>{const t=r.parentNode;if(!t){r.remove();return}for(;r.firstChild;)t.insertBefore(r.firstChild,r);t.removeChild(r)},Gi=r=>{const t=r.getAttribute("class")??"",a=r.getAttribute("style")??"";return/mso-list/i.test(a)||/MsoListParagraph/i.test(t)||/MsoList/i.test(t)},io=r=>{const t=r.getAttribute("style")??"",a=r.textContent??"";return/mso-level-number-format\s*:\s*(decimal|arabic|roman|alpha)/i.test(t)||/^\s*\d+[.)]\s/.test(a)||/^\s*[a-zA-Z][.)]\s/.test(a)?"ol":"ul"},Ki=r=>{const a=r.ownerDocument.createTreeWalker(r,NodeFilter.SHOW_TEXT).nextNode();if(!a||!a.textContent)return;const n=a.textContent.replace(_i,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");n!==a.textContent&&(a.textContent=n)},Xi=r=>{const t=Array.from(r.querySelectorAll("span, font, p, div, li, h1, h2, h3, h4"));t.sort((a,n)=>n.querySelectorAll("*").length-a.querySelectorAll("*").length),t.forEach(a=>{const n=a.getAttribute("style")??"";n&&(Wi(n)&&Zt(a,"strong"),qi(n)&&Zt(a,"em"),Ui(n)&&Zt(a,"u"),Vi(n)&&Zt(a,"s"))})},Yi=r=>{const t=Array.from(r.querySelectorAll("p, div")).filter(Gi);if(!t.length)return;let a=0;for(;a<t.length;){const n=t[a],s=io(n),l=[n];let i=a+1;for(;i<t.length;){const f=t[i];if(io(f)!==s)break;let m=l[l.length-1].nextSibling;for(;m&&m.nodeType===Node.TEXT_NODE&&!(m.textContent??"").trim();)m=m.nextSibling;if(m!==f)break;l.push(f),i++}const c=n.parentNode;if(!c){a=i;continue}const u=n.ownerDocument.createElement(s);c.insertBefore(u,n),l.forEach(f=>{Ki(f);const m=f.ownerDocument.createElement("li");for(;f.firstChild;)m.appendChild(f.firstChild);u.appendChild(m),f.remove()}),a=i}},Zi=r=>r==="h1"?"h2":r==="h4"||r==="h5"||r==="h6"?"h3":r==="div"?"p":r,Qi=r=>{const t=ji(r.replace(/<!--\[if[\s\S]*?<!\[endif\]-->/gi,"").replace(/<xml[\s\S]*?<\/xml>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<\/?o:[^>]*>/gi,"").replace(/<\/?w:[^>]*>/gi,"").replace(/<\/?m:[^>]*>/gi,"")),s=new DOMParser().parseFromString(`<!DOCTYPE html><html><body>${t}</body></html>`,"text/html").body;s.querySelectorAll("script, style, meta, link, xml, title, head, iframe, object, embed, form, input, button, textarea, select, noscript").forEach(i=>i.remove()),Xi(s),Yi(s);const l=i=>{const c=Array.from(i.childNodes);if(i.nodeType===Node.ELEMENT_NODE){const u=i,f=u.tagName.toLowerCase();if(f==="html"||f==="body"){c.forEach(l);return}if(f==="font"){Qt(u),c.forEach(l);return}if(!zi.has(f)){Qt(u),c.forEach(l);return}const m=Zi(f);if(m!==f){const b=u.ownerDocument.createElement(m);for(;u.firstChild;)b.appendChild(u.firstChild);u.replaceWith(b),l(b);return}if(Array.from(u.attributes).forEach(b=>{const p=b.name.toLowerCase(),y=b.value;if(p.startsWith("on")||p==="style"||p==="class"){u.removeAttribute(b.name);return}if(p==="lang"||p.startsWith("data-")||p.startsWith("mso-")){u.removeAttribute(b.name);return}if((p==="href"||p==="src")&&/^\s*javascript:/i.test(y)){u.removeAttribute(b.name);return}f!=="a"&&f!=="img"&&p!=="href"&&p!=="src"&&p!=="alt"&&(["href","src","alt","target","rel"].includes(p)||u.removeAttribute(b.name))}),f==="a"){const b=u.getAttribute("href");if(!b||/^\s*#/.test(b)&&b.length<2){Qt(u),c.forEach(l);return}u.setAttribute("target","_blank"),u.setAttribute("rel","noopener noreferrer"),u.classList.add("rich-link")}if(f==="img"){const b=u.getAttribute("src")??"";if(!b||/^\s*javascript:/i.test(b)||/^file:/i.test(b)||/scheme\s*=\s*["']?file/i.test(b)){u.remove();return}u.classList.add("rich-img"),Array.from(u.attributes).forEach(p=>{["src","alt","class"].includes(p.name.toLowerCase())||u.removeAttribute(p.name)})}if(f==="span"){Qt(u),c.forEach(l);return}}c.forEach(l)};return l(s),s.querySelectorAll("p, h2, h3, li").forEach(i=>{const c=(i.textContent??"").replace(/[\u00a0\s]+/g,"").trim(),u=i.querySelector("img, hr"),f=!c&&!u&&Array.from(i.childNodes).every(m=>m.nodeType===Node.TEXT_NODE||m.nodeType===Node.ELEMENT_NODE&&m.tagName.toLowerCase()==="br");(!c&&!u||f)&&i.remove()}),s.querySelectorAll("strong, b, em, i, u, s").forEach(i=>{let c=i.nextSibling;for(;c&&c.nodeType===Node.TEXT_NODE&&!(c.textContent??"").trim();)c=c.nextSibling;if(c&&c.nodeType===Node.ELEMENT_NODE&&c.tagName===i.tagName){const u=c;for(;u.firstChild;)i.appendChild(u.firstChild);u.remove()}}),s.innerHTML.replace(/<!--[\s\S]*?-->/g,"").replace(/&nbsp;/gi," ").replace(/(<br\s*\/?>\s*){3,}/gi,"<br><br>").replace(/<p>(?:\s|<br\s*\/?>)*<\/p>/gi,"").trim()},Ga=r=>xt(r).replace(/\r\n?/g,`
25
+ `).split(/\n{2,}/).map(t=>`<p>${t.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),Ji=r=>new RegExp("\\p{L}","u").test(r),Ka=(r,t)=>{const a=r.trim();return!a||!Ji(a)?!1:t==="uppercase"?a===a.toLocaleUpperCase():t==="lowercase"?a===a.toLocaleLowerCase():a===lo(a)},co=r=>{const t=n=>{var s,l;if(!n.closest(".rich-img-wrap")){const i=document.createElement("span");i.className="rich-img-wrap",i.contentEditable="false",(s=n.parentNode)==null||s.insertBefore(i,n),i.appendChild(n),i.insertAdjacentHTML("beforeend",so())}(l=n.closest(".rich-img-wrap"))==null||l.classList.add("rich-img-broken")};r.querySelectorAll("img").forEach(n=>{if(!n.complete||n.naturalWidth===0){n.addEventListener("error",()=>t(n),{once:!0}),n.addEventListener("load",()=>{n.naturalWidth===0&&t(n)},{once:!0});const s=n.src;n.src="",n.src=s}});const a=n=>{const s=n.target;s.tagName==="IMG"&&t(s)};return r.addEventListener("error",a,!0),()=>r.removeEventListener("error",a,!0)};function uo({value:r,onChange:t,placeholder:a="Escribe algo...",minHeight:n="80px",instanceId:s}){const l=o.useId(),i=s||l,c=o.useCallback(()=>document,[]),u=o.useRef(null),f=o.useRef(null),m=o.useRef(new Map),b=o.useRef(null),p=o.useRef(!1),y=o.useRef(r??""),N=o.useRef(t),M=o.useRef(!1),[g,C]=o.useState(()=>!r||r.trim()===""),[B,A]=o.useState(new Set),[z,E]=o.useState(null),[k,q]=o.useState(""),[H,_]=o.useState(""),[Y,Z]=o.useState(""),[T,J]=o.useState(""),[O,j]=o.useState(!1),te=o.useCallback(()=>p.current?f.current:u.current,[]);o.useEffect(()=>{N.current=t},[t]);const X=o.useCallback(()=>{const D=window.getSelection(),U=te();if(!D||!U||D.rangeCount===0||D.isCollapsed)return"";const le=D.getRangeAt(0);return!U.contains(le.startContainer)||!U.contains(le.endContainer)?"":D.toString()},[te]);o.useEffect(()=>{const D=r??"";if(M.current&&D===y.current){M.current=!1,C(!D||D.trim()==="");return}M.current=!1,y.current=D;const U=[u.current,f.current].filter(ue=>!!ue);U.forEach(ue=>{ue.innerHTML!==D&&(ue.innerHTML=D)}),C(!D||D.trim()==="");const le=U.map(ue=>co(ue));return()=>le.forEach(ue=>ue())},[r]),o.useEffect(()=>{var ue,Le;p.current=O;let D,U=0,le;if(O){const ke=u.current;ke&&(y.current=ke.innerHTML);const Ie=()=>{var Ue;const Me=f.current;if(!Me){U=requestAnimationFrame(Ie);return}Me.innerHTML!==y.current&&(Me.innerHTML=y.current),D=co(Me),C(((Ue=Me.textContent)==null?void 0:Ue.trim())===""),le=setTimeout(()=>Me.focus(),60)};U=requestAnimationFrame(Ie)}else{const ke=f.current,Ie=u.current,Me=(ke==null?void 0:ke.innerHTML)??y.current,Ue=y.current;y.current=Me,Ie&&Ie.innerHTML!==Me&&(Ie.innerHTML=Me),Me!==Ue&&N.current(Me),C(((Le=(ue=ke??Ie)==null?void 0:ue.textContent)==null?void 0:Le.trim())==="")}return()=>{U&&cancelAnimationFrame(U),le&&clearTimeout(le),D==null||D()}},[O]);const I=o.useCallback(()=>{const D=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],U=new Set;D.forEach(ue=>{try{c().queryCommandState(ue)&&U.add(ue)}catch{return}});try{const ue=Fi(c().queryCommandValue("formatBlock"));ue&&U.add(`formatBlock:${ue}`)}catch{}const le=X();Ka(le,"uppercase")&&U.add("__upper"),Ka(le,"lowercase")&&U.add("__lower"),Ka(le,"capitalize")&&U.add("__cap"),A(U)},[X,c]),ee=()=>{var U;const D=te();D&&(y.current=D.innerHTML,M.current=!0,N.current(y.current),C(((U=D.textContent)==null?void 0:U.trim())===""))},R=D=>{if(!D){const U=u.current;U&&(y.current=U.innerHTML)}j(!D)},x=(D,U)=>{var le;(le=te())==null||le.focus(),c().execCommand(D,!1,U),ee(),I()},S=D=>{x("formatBlock",D)},K=()=>{var D;(D=te())==null||D.focus(),c().execCommand("insertHTML",!1,"<hr><p><br></p>"),ee(),I()},Q=()=>{const D=window.getSelection();D&&D.rangeCount>0&&(b.current=D.getRangeAt(0).cloneRange())},ae=()=>{const D=window.getSelection();D&&b.current&&(D.removeAllRanges(),D.addRange(b.current))},ce=D=>{if(Q(),D==="link"){const U=window.getSelection();_(U&&!U.isCollapsed?U.toString():""),q("")}D==="image"&&(Z(""),J("")),E(D)},ve=()=>{var ue;if(!k.trim())return;ae(),(ue=te())==null||ue.focus();const D=window.getSelection(),le=(D&&!D.isCollapsed?D.toString():"")||H.trim()||k.trim();c().execCommand("insertHTML",!1,`<a href="${xt(k.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${xt(le)}</a>`),ee(),E(null)},re=(D,U="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${xt(D)}" alt="${xt(U)}" class="rich-img" />${so()}</span>`,G=()=>{var D;Y.trim()&&(ae(),(D=te())==null||D.focus(),c().execCommand("insertHTML",!1,re(Y.trim(),T.trim())),ee(),E(null))},h=(D,U=1200,le=1200,ue=.72)=>new Promise((Le,ke)=>{const Ie=new FileReader;Ie.onerror=ke,Ie.onload=Me=>{var la;const Ue=(la=Me.target)==null?void 0:la.result,Be=new Image;Be.onerror=ke,Be.onload=()=>{let{width:Ke,height:Fe}=Be;if(Ke>U||Fe>le){const ir=Math.min(U/Ke,le/Fe);Ke=Math.round(Ke*ir),Fe=Math.round(Fe*ir)}const Xe=document.createElement("canvas");Xe.width=Ke,Xe.height=Fe;const $r=Xe.getContext("2d");if(!$r){Le(Ue);return}$r.drawImage(Be,0,0,Ke,Fe),Le(Xe.toDataURL("image/jpeg",ue))},Be.src=Ue},Ie.readAsDataURL(D)}),L=D=>{D.focus();const U=window.getSelection();if(!U||U.rangeCount===0||!D.contains(U.anchorNode)){const le=document.createRange();le.selectNodeContents(D),le.collapse(!1),U==null||U.removeAllRanges(),U==null||U.addRange(le)}},W=o.useRef(()=>{});W.current=D=>{const U=te();U&&(L(U),c().execCommand("insertHTML",!1,D),U.querySelectorAll("p").forEach(le=>{!(le.textContent??"").replace(/[\u00a0\s]+/g,"")&&!le.querySelector("img, hr")&&le.remove()}),ee(),I())};const ne=o.useRef(h);ne.current=h;const oe=o.useRef(re);oe.current=re;const he=o.useCallback(D=>{if(!D||m.current.has(D))return;const U=le=>{const ue=le.clipboardData;if(!ue)return;const Le=ue.getData("text/html"),ke=ue.getData("text/plain");if(Le||ke){le.preventDefault(),le.stopPropagation();try{const Be=Le?Qi(Le):Ga(ke);if(!Be){ke&&W.current(Ga(ke));return}W.current(Be)}catch{ke&&W.current(Ga(ke))}return}const Me=Array.from(ue.items).find(Be=>Be.type.startsWith("image/"));if(!Me)return;le.preventDefault(),le.stopPropagation();const Ue=Me.getAsFile();Ue&&ne.current(Ue).then(Be=>{W.current(oe.current(Be,"imagen"))})};D.addEventListener("paste",U,!0),m.current.set(D,()=>{D.removeEventListener("paste",U,!0),m.current.delete(D)})},[]),_e=o.useCallback(D=>{var le;const U=u.current;U&&U!==D&&((le=m.current.get(U))==null||le()),u.current=D,D&&he(D)},[he]),Ge=o.useCallback(D=>{var le;const U=f.current;U&&U!==D&&((le=m.current.get(U))==null||le()),f.current=D,D&&he(D)},[he]);o.useEffect(()=>{const D=m.current;return()=>{D.forEach(U=>U()),D.clear()}},[]);const xe=D=>{const U=window.getSelection(),le=te();if(!U||!le||U.rangeCount===0||U.isCollapsed)return;const ue=U.getRangeAt(0);if(!le.contains(ue.startContainer)||!le.contains(ue.endContainer))return;const Le=ue.toString();if(!Le)return;let ke=Le;D==="uppercase"?ke=Le.toLocaleUpperCase():D==="lowercase"?ke=Le.toLocaleLowerCase():ke=lo(Le),ue.deleteContents();const Ie=document.createTextNode(ke);ue.insertNode(Ie);const Me=document.createRange();Me.setStart(Ie,0),Me.setEnd(Ie,ke.length),U.removeAllRanges(),U.addRange(Me),b.current=Me.cloneRange(),ee(),I()},Ee=()=>{Q(),I()},Ae=()=>{ee(),I()},wr=()=>{requestAnimationFrame(()=>{var D;(D=te())==null||D.focus()})},br=D=>{var U,le;if((D.metaKey||D.ctrlKey)&&D.key==="Enter"){if(D.preventDefault(),D.stopPropagation(),D.repeat)return;(U=te())==null||U.focus(),c().execCommand("insertLineBreak",!1)||c().execCommand("insertHTML",!1,"<br>"),ee(),I();return}if(D.key==="Tab"){D.preventDefault(),(le=te())==null||le.focus(),c().execCommand("insertText",!1,"    "),ee(),I();return}if(D.key==="Escape"){if(z){E(null);return}if(p.current){j(!1);return}}z||(D.ctrlKey||D.metaKey)&&(D.key==="b"&&(D.preventDefault(),x("bold")),D.key==="i"&&(D.preventDefault(),x("italic")),D.key==="u"&&(D.preventDefault(),x("underline")),D.key==="k"&&(D.preventDefault(),ce("link")))},We=()=>e.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),se=(D,U,le,ue,Le)=>{const ke=Le??(B.has(le)||le==="__link"&&z==="link"||le==="__img"&&z==="image");return e.jsx("button",{type:"button",title:U,tabIndex:-1,onFocus:wr,onMouseDown:Ie=>{Ie.preventDefault(),ue?ue():x(le)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:ke?"var(--primary)":"var(--text-secondary)",background:ke?"rgba(59,130,246,0.12)":"transparent"},children:D},le)},Ze=D=>{const U=D.target;if(U.closest("[data-action='delete-img']")){D.preventDefault();const le=U.closest(".rich-img-wrap");le&&(le.remove(),ee())}},lr=D=>e.jsxs(e.Fragment,{children:[z==="link"&&e.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:D},children:[e.jsx("input",{autoFocus:!0,type:"url",value:k,onChange:U=>q(U.target.value),onKeyDown:U=>{U.key==="Enter"&&(U.preventDefault(),ve()),U.key==="Escape"&&E(null)},placeholder:"https://...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),e.jsx("input",{type:"text",value:H,onChange:U=>_(U.target.value),onKeyDown:U=>{U.key==="Enter"&&(U.preventDefault(),ve()),U.key==="Escape"&&E(null)},placeholder:"Texto (opcional)",className:"w-32 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),e.jsx("button",{type:"button",onClick:ve,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),e.jsx("button",{type:"button",onClick:()=>E(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),z==="image"&&e.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:D},children:[e.jsx("input",{autoFocus:!0,type:"url",value:Y,onChange:U=>Z(U.target.value),onKeyDown:U=>{U.key==="Enter"&&(U.preventDefault(),G()),U.key==="Escape"&&E(null)},placeholder:"URL de la imagen...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),e.jsx("input",{type:"text",value:T,onChange:U=>J(U.target.value),onKeyDown:U=>{U.key==="Enter"&&(U.preventDefault(),G()),U.key==="Escape"&&E(null)},placeholder:"Texto alt",className:"w-28 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),e.jsx("button",{type:"button",onClick:G,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),e.jsx("button",{type:"button",onClick:()=>E(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),de=(D,U)=>e.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-0.5 border-t px-2 py-1",style:{borderColor:"var(--border)",background:U},children:[se(e.jsx($.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),se(e.jsx($.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),We(),se(e.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>S("p"),B.has("formatBlock:p")||B.has("formatBlock:div")),se(e.jsx($.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>S("h2"),B.has("formatBlock:h2")),se(e.jsx($.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>S("h3"),B.has("formatBlock:h3")),se(e.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>S("blockquote"),B.has("formatBlock:blockquote")),We(),se(e.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),se(e.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),se(e.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),se(e.jsx("s",{children:"S"}),"Tachado","strikeThrough"),We(),se(e.jsx($.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),se(e.jsx($.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),se(e.jsx($.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),se(e.jsx($.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),We(),se(e.jsx($.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),se(e.jsx($.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),se(e.jsx($.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),se(e.jsx($.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),We(),se(e.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>xe("uppercase")),se(e.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>xe("lowercase")),se(e.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>xe("capitalize")),We(),se(e.jsx($.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>ce("link")),se(e.jsx($.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),se(e.jsx($.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>ce("image")),se(e.jsx($.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",K),We(),se(e.jsx($.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),se(e.jsx($.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>S("p")),We(),e.jsx("button",{type:"button",title:D?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:wr,onMouseDown:le=>{le.preventDefault(),R(D)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:D?e.jsx($.HiArrowsPointingIn,{className:"h-4 w-4"}):e.jsx($.HiArrowsPointingOut,{className:"h-4 w-4"})})]});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"overflow-hidden rounded-lg transition-all duration-150 ring-1 ring-transparent focus-within:ring-primary/30",style:{border:"1px solid var(--border)"},children:[e.jsx("div",{ref:_e,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:Ae,onKeyDown:br,onKeyUp:Ee,onSelect:Ee,onMouseUp:Ee,onMouseDown:Ze,"data-placeholder":a,className:`rich-editor px-3 py-2 text-sm focus:outline-none${g?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:n,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),lr("var(--bg-input)"),de(!1,"var(--bg-input)")]}),e.jsxs(Pa,{open:O,onClose:()=>j(!1),title:"Modo de enfoque",subtitle:"Esc para salir",maxWidth:"920px",bodyClassName:"flex min-h-0 flex-col p-0",panelClassName:"h-[88vh]",backdropClassName:"bg-black/50 backdrop-blur-[2px]",children:[e.jsx("div",{ref:Ge,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:Ae,onKeyDown:br,onKeyUp:Ee,onSelect:Ee,onMouseUp:Ee,onMouseDown:Ze,"data-placeholder":a,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${g?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),lr("var(--bg-input)"),de(!0,"var(--bg-input)")]})]})}const fo="[a-zA-Z0-9._@-]+",Xa=new RegExp(`@(${fo})`,"g"),Ri=/[a-zA-Z0-9._@-]/,yt=new Set([" ",`
26
+ `," ","("]);function bo(r,t){if(t<=0)return!0;const a=r[t-1]??"";return yt.has(a)}function po(r,t,a){var n;if(t<0||t>r.length)return null;for(let s=t-1;s>=0;s-=1){if(r[s]!=="@"){const c=r[s]??"";if(yt.has(c)||!Ri.test(c))return null;continue}if((n=a==null?void 0:a.isInsideExistingMention)!=null&&n.call(a,s)||!(a!=null&&a.isTriggerBoundary?a.isTriggerBoundary(s):bo(r,s)))continue;const i=r.slice(s+1,t);return i.length>0&&!new RegExp(`^${fo}$`).test(i)?null:{query:i,triggerIndex:s,caretIndex:t}}return null}function mo(r,t){var n;const a=Ur(r,t);return a?!!((n=a.node.parentElement)!=null&&n.closest(".mention-chip")):!1}function ho(r,t){if(t<=0)return!0;const a=Ur(r,t);if(!a){const s=r.textContent??"";return bo(s,t)}if(a.offset>0){const s=a.node.data[a.offset-1]??"";return yt.has(s)}let n=a.node.previousSibling;for(;n;){if(n.nodeType===Node.TEXT_NODE){const s=n.textContent??"";if(s.length===0){n=n.previousSibling;continue}return yt.has(s[s.length-1]??"")}if(n.nodeType===Node.ELEMENT_NODE){const s=n;if(s.classList.contains("mention-chip")||s.tagName==="BR"||/^(P|DIV|LI|H[1-6]|BLOCKQUOTE)$/i.test(s.tagName))return!0;const l=s.textContent??"";if(l.length===0){n=n.previousSibling;continue}return yt.has(l[l.length-1]??"")}n=n.previousSibling}return!0}function Ya(r,t){const a=r.textContent??"";return po(a,t,{isTriggerBoundary:n=>ho(r,n),isInsideExistingMention:n=>mo(r,n)})}function Za(r){return r.toLowerCase().trim()}function go(r){return r?r.replace(/<style[^>]*>[\s\S]*?<\/style>/gi," ").replace(/<script[^>]*>[\s\S]*?<\/script>/gi," ").replace(/<br\s*\/?>/gi,`
28
27
  `).replace(/<\/(p|div|li)>/gi,`
29
- `).replace(/<[^>]+>/g," ").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/\s+/g," ").trim():""}function Za(r){if(!r)return[];const t=fo(r),a=new Set,n=[];Ka.lastIndex=0;let s;for(;(s=Ka.exec(t))!==null;){const l=Ya(s[1]??"");!l||a.has(l)||(a.add(l),n.push(l))}return n}function Xi(r,t){const a=Za(r);if(!a.length)return[];const n=new Map;t.forEach(i=>{i.username&&n.set(Ya(i.username),i)});const s=new Set,l=[];for(const i of a){const c=n.get(i);c&&(s.has(c.userId)||(s.add(c.userId),l.push({userId:c.userId,username:c.username,email:c.email??void 0,display:c.name??c.username})))}return l}function bo(r){const t=new Set,a=[];for(const n of r)t.has(n.userId)||(t.add(n.userId),a.push(n));return a}function Yi(r,t){return t?r.filter(a=>a.userId!==t):r}function po(r){return!r||!/@/.test(r)?r:r.replace(Ka,(t,a,n,s)=>{const l=s.slice(0,n),i=l.lastIndexOf("<"),c=l.lastIndexOf(">");return i>c?t:`<span class="mention-chip" data-username="${(a??"").toLowerCase()}">${t}</span>`})}function Zt(r,t){if(t<0)return null;const a=r.ownerDocument;if(!a)return null;const n=a.createTreeWalker(r,NodeFilter.SHOW_TEXT);let s=t,l=null,i=n.nextNode();for(;i;){l=i;const c=i.data.length;if(s<=c)return{node:i,offset:s};s-=c,i=n.nextNode()}return l&&s===0?{node:l,offset:l.data.length}:null}function Qa(r,t,a){var s;const n=r.ownerDocument;if(!n||r!==t&&!r.contains(t))return-1;try{const l=n.createRange();return l.selectNodeContents(r),l.setEnd(t,a),((s=l.cloneContents().textContent)==null?void 0:s.length)??0}catch{return-1}}function mo(r,t){const{triggerIndex:a,caretIndex:n,username:s}=t;if(n<a)return null;const l=Zt(r,a),i=Zt(r,n);if(!l||!i)return null;const c=r.ownerDocument,u=c.createRange();u.setStart(l.node,l.offset),u.setEnd(i.node,i.offset),u.deleteContents();const f=c.createElement("span");f.className="mention-chip",f.setAttribute("data-username",s.toLowerCase()),f.textContent=`@${s}`;const b=c.createTextNode(" ");return u.insertNode(b),u.insertNode(f),{caretPlainOffset:a+s.length+2}}function ho(r,t){const a=r.ownerDocument,n=a.defaultView;if(!n)return;const s=n.getSelection();if(!s)return;const l=a.createRange(),i=Zt(r,t);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(r),l.collapse(!1)),s.removeAllRanges(),s.addRange(l)}const Zi={position:"relative"},Qi={position:"absolute",zIndex:60,minWidth:260,maxHeight:280,overflowY:"auto",background:"var(--bg-card, var(--bonsaif-ui-surface, #fff))",border:"1px solid var(--border, var(--bonsaif-ui-border, #d0d7de))",borderRadius:10,boxShadow:"0 12px 32px rgba(0,0,0,0.18)",padding:4},vo={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function Ji({value:r,onChange:t,onSearchUsers:a,onMentionsChange:n,minHeight:s,placeholder:l,className:i,maxSuggestions:c=8,searchDebounceMs:u=140,highlightInEditor:f=!1,searchCacheKey:b=""}){const p=o.useRef(null),m=o.useRef(null),w=o.useRef(new Map),y=o.useRef(a);y.current=a;const k=o.useRef(null),[v,C]=o.useState(null),[B,T]=o.useState([]),[W,L]=o.useState(0),[S,q]=o.useState([]),[H,z]=o.useState(!1);o.useEffect(()=>{if(!v){T([]);return}const N=v.query.trim(),K=`${b}|${N.toLowerCase()||"*"}`,I=w.current.get(K);if(I){T(I),L(0),z(!1);return}const E=new AbortController;z(!0);const R=setTimeout(async()=>{try{const ne=await y.current(N,{signal:E.signal,limit:Math.max(c,20)});if(E.signal.aborted)return;const $=Array.isArray(ne)?ne:[];w.current.set(K,$),T($),L(0)}catch{}finally{E.signal.aborted||z(!1)}},u);return()=>{E.abort(),clearTimeout(R)}},[v==null?void 0:v.query,c,b,u]),o.useEffect(()=>{n&&n(bo(S))},[S,n]);const X=o.useCallback(()=>{var N;return(N=p.current)==null?void 0:N.querySelector("[contenteditable='true']")},[]),Z=o.useCallback(N=>{var ee;t(N);const K=X(),I=window.getSelection();if(!K||!I||I.rangeCount===0){C(null);return}const E=I.getRangeAt(0);if(!K.contains(E.startContainer)){C(null);return}const R=Qa(K,E.startContainer,E.startOffset);if(R<0){C(null);return}const ne=K.textContent??"",$=Xa(ne,R);if(!$){C(null);return}const O=E.getBoundingClientRect(),re=(ee=p.current)==null?void 0:ee.getBoundingClientRect();re&&(k.current={query:$.query,caretIndex:$.caretIndex,triggerIndex:$.triggerIndex},C({query:$.query,top:O.bottom-re.top+6,left:O.left-re.left}))},[X,t]),M=o.useCallback(N=>{const K=X();if(!K)return;let I=-1;const E=K.textContent??"",R=window.getSelection();if(R&&R.rangeCount>0){const ee=R.getRangeAt(0);K.contains(ee.startContainer)&&(I=Qa(K,ee.startContainer,ee.startOffset))}if(I<0&&k.current&&(I=k.current.caretIndex),I<0)return;const ne=Xa(E,I);if(!ne)return;const $=mo(K,{triggerIndex:ne.triggerIndex,caretIndex:I,username:N.username});if(!$)return;t(K.innerHTML);const O={userId:N.userId,username:N.username,email:N.email??void 0,display:N.name??N.username};q(ee=>{const oe=new Map(ee.map(ie=>[ie.userId,ie]));return oe.set(O.userId,O),Array.from(oe.values())}),C(null),k.current=null;const re=$.caretPlainOffset;requestAnimationFrame(()=>{const ee=X();ee&&(ee.focus(),ho(ee,re))})},[X,t]);o.useEffect(()=>{const N=new Set(Za(r).map(K=>K.toLowerCase()));q(K=>{const I=K.filter(E=>N.has(E.username.toLowerCase()));return I.length===K.length?K:I})},[r]),o.useEffect(()=>{if(!v)return;const N=K=>{const I=K.target;I&&(p.current&&p.current.contains(I)||m.current&&m.current.contains(I)||C(null))};return document.addEventListener("mousedown",N),()=>{document.removeEventListener("mousedown",N)}},[v]);const U=o.useMemo(()=>B.slice(0,c),[B,c]);o.useEffect(()=>{const N=X();if(!N)return;const K=I=>{if(v&&!(U.length===0&&I.key!=="Escape"))if(I.key==="ArrowDown")I.preventDefault(),L(E=>(E+1)%Math.max(U.length,1));else if(I.key==="ArrowUp")I.preventDefault(),L(E=>(E-1+U.length)%Math.max(U.length,1));else if(I.key==="Enter"||I.key==="Tab"){const E=U[W];E&&(I.preventDefault(),M(E))}else I.key==="Escape"&&(I.preventDefault(),C(null))};return N.addEventListener("keydown",K),()=>N.removeEventListener("keydown",K)},[W,X,M,v,U]);const j=f?po(r):r;return e.jsxs("div",{ref:p,style:Zi,className:i,children:[e.jsx(co,{value:j,onChange:Z,placeholder:l,minHeight:s}),v&&e.jsxs("ul",{ref:m,style:{...Qi,top:v.top,left:v.left},role:"listbox","aria-label":"Menciones sugeridas",children:[H&&U.length===0&&e.jsx("li",{style:vo,children:"Buscando…"}),!H&&U.length===0&&e.jsx("li",{style:vo,children:v.query.trim().length===0?"Escribe para buscar un usuario":`Sin coincidencias para “${v.query}”`}),U.map((N,K)=>e.jsx("li",{children:e.jsxs("button",{type:"button",onMouseDown:I=>{I.preventDefault(),M(N)},onMouseEnter:()=>L(K),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:K===W?"color-mix(in srgb, var(--primary, var(--bonsaif-ui-primary, #1f6feb)) 14%, transparent)":"transparent",color:"var(--text-main, var(--bonsaif-ui-text, #24292f))",borderRadius:6,cursor:"pointer",display:"flex",flexDirection:"column",gap:2},children:[e.jsxs("span",{style:{fontWeight:600,fontSize:13},children:["@",N.username]}),e.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[N.name,N.email].filter(Boolean).join(" · ")||" "})]})},N.userId))]})]})}function Ri({title:r,subtitle:t,icon:a,actions:n,children:s,footer:l,className:i="",bodyClassName:c="p-4"}){const u=r||t||a||n;return e.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${i}`,children:[u&&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:s}),l&&e.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:l})]})}const ec={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)"}},rc={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 tc({children:r,tone:t="neutral",size:a="sm",icon:n,dot:s=!1,className:l=""}){const i=ec[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 ${rc[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})]})}const go={neutral:{color:"var(--text-secondary)",background:"var(--bg-input)"},primary:{color:"var(--primary)",background:"color-mix(in srgb, var(--primary) 10%, transparent)"},success:{color:"#047857",background:"rgba(16, 185, 129, 0.11)"},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)"},danger:{color:"var(--danger)",background:"var(--danger-bg)"},info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.11)"}},ac={xs:"min-h-5 px-1.5 pr-6 text-[10px]",sm:"min-h-6 px-2 pr-7 text-xs",md:"min-h-7 px-2.5 pr-8 text-sm"},nc={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},oc={xs:148,sm:164,md:184},sc={xs:"px-2.5 py-1.5 text-xs",sm:"px-3 py-2 text-sm",md:"px-3.5 py-2.5 text-sm"};function lc({value:r,options:t,onChange:a,size:n="sm",disabled:s=!1,loading:l=!1,stopPropagation:i=!1,ariaLabel:c="Cambiar estado",title:u="Cambiar estado",className:f,selectClassName:b,menuClassName:p,optionClassName:m,spinnerClassName:w}){const[y,k]=o.useState(!1),[v,C]=o.useState(!1),[B,T]=o.useState(-1),[W,L]=o.useState({}),S=o.useRef(null),q=o.useRef(null),H=o.useRef(null),z=t.find(E=>E.value===r)??t[0],X={...z!=null&&z.tone?go[z.tone]:void 0,...z==null?void 0:z.style},Z=s||l||t.length===0,M=E=>{i&&E.stopPropagation()},U=o.useCallback(()=>{k(!1),T(-1)},[]),j=o.useCallback(()=>{const E=S.current;if(!E)return;const R=E.getBoundingClientRect(),ne=Math.max(R.width,oc[n]),$=Math.min(Math.max(t.length,1)*38+12,260),O=window.innerHeight-R.bottom,re=O<$&&R.top>O,ee=Math.min(Math.max(8,R.left+R.width/2-ne/2),window.innerWidth-ne-8);L({position:"fixed",left:ee,top:re?void 0:R.bottom+6,bottom:re?window.innerHeight-R.top+6:void 0,width:ne,zIndex:9999})},[t.length,n]),N=o.useCallback(E=>{E.disabled||(a(E.value),U())},[U,a]);o.useEffect(()=>C(!0),[]),o.useEffect(()=>{if(!y)return;j();const E=t.findIndex(R=>R.value===r);T(E>=0?E:0)},[y,t,j,r]),o.useEffect(()=>{if(!y)return;function E(R){var $,O;const ne=R.target;!(($=S.current)!=null&&$.contains(ne))&&!((O=q.current)!=null&&O.contains(ne))&&U()}return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[U,y]),o.useEffect(()=>{if(y)return window.addEventListener("resize",j),window.addEventListener("scroll",j,!0),()=>{window.removeEventListener("resize",j),window.removeEventListener("scroll",j,!0)}},[y,j]),o.useEffect(()=>{if(B<0||!H.current)return;const E=H.current.children[B];E==null||E.scrollIntoView({block:"nearest"})},[B]);function K(E){if(!Z){if(!y){["Enter"," ","ArrowDown","ArrowUp"].includes(E.key)&&(E.preventDefault(),k(!0));return}if(E.key==="Escape"){E.preventDefault(),U();return}if(E.key==="ArrowDown"){E.preventDefault(),T(R=>Math.min(R+1,t.length-1));return}if(E.key==="ArrowUp"){E.preventDefault(),T(R=>Math.max(R-1,0));return}if(E.key==="Enter"||E.key===" "){E.preventDefault();const R=t[B];R&&N(R)}}}const I=e.jsx("div",{ref:q,role:"listbox","aria-label":c,className:pr("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",p),style:{...W,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:M,onMouseDown:M,onPointerDown:M,children:e.jsx("div",{ref:H,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:t.map((E,R)=>{const ne=E.value===r,$=R===B,O={...E.tone?go[E.tone]:void 0,...E.style};return e.jsxs("button",{type:"button",role:"option","aria-selected":ne,disabled:E.disabled,onMouseEnter:()=>!E.disabled&&T(R),onMouseDown:re=>{re.preventDefault(),N(E)},className:pr("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",sc[n],ne?E.className:void 0,m),style:{...ne?O:void 0,background:ne?O.background??"color-mix(in srgb, var(--primary) 12%, transparent)":$?"var(--bg-hover)":"transparent",color:ne?O.color??"var(--primary)":"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:ne?e.jsx(A.HiCheck,{className:"h-4 w-4"}):null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:E.label})]},E.value)})})});return e.jsxs("span",{ref:S,className:pr("relative inline-flex shrink-0 items-center",f),onKeyDown:K,onClick:M,onPointerDown:M,children:[e.jsx("button",{type:"button",disabled:Z,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":y,title:u,onClick:()=>!Z&&k(E=>!E),className:pr("inline-flex items-center rounded-full border border-transparent font-medium leading-none outline-none transition-colors hover:border-current focus:border-current disabled:cursor-wait disabled:opacity-70",ac[n],z==null?void 0:z.className,b),style:X,children:e.jsx("span",{className:"min-w-0 truncate",children:(z==null?void 0:z.label)??r})}),e.jsx(A.HiChevronDown,{"aria-hidden":"true",className:pr("pointer-events-none absolute opacity-70 transition-transform",nc[n],y?"rotate-180":"rotate-0")}),l&&e.jsx("span",{"aria-hidden":"true",className:pr("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",w)}),y&&v&&rr.createPortal(I,document.body)]})}function ic({tabs:r,activeTabId:t,defaultActiveTabId:a,onTabChange:n,ariaLabel:s="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:u=""}){const f=r.find(y=>!y.disabled)??r[0],b=t??a??(f==null?void 0:f.id),p=r.find(y=>y.id===b)??f,m=y=>{y.disabled||n==null||n(y.id)},w=y=>{const k=r.filter(C=>!C.disabled);if(!k.length||!p)return;const v=k.findIndex(C=>C.id===p.id);(y.key==="ArrowRight"||y.key==="ArrowDown")&&(y.preventDefault(),m(k[(v+1)%k.length])),(y.key==="ArrowLeft"||y.key==="ArrowUp")&&(y.preventDefault(),m(k[(v-1+k.length)%k.length])),y.key==="Home"&&(y.preventDefault(),m(k[0])),y.key==="End"&&(y.preventDefault(),m(k[k.length-1]))};return e.jsxs("div",{className:i,children:[e.jsx("div",{role:"tablist","aria-label":s,onKeyDown:w,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(y=>{const k=y.id===(p==null?void 0:p.id);return e.jsxs("button",{type:"button",role:"tab","aria-selected":k,"aria-controls":`${y.id}-panel`,id:`${y.id}-tab`,disabled:y.disabled,tabIndex:k?0:-1,onClick:()=>m(y),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:k?"var(--primary)":"var(--text-muted)",borderColor:k?"var(--primary)":"transparent",background:l==="pills"&&k?"var(--bg-card)":"transparent"},children:[y.icon&&e.jsx("span",{className:"shrink-0",children:y.icon}),e.jsx("span",{children:y.label}),y.badge&&e.jsx("span",{className:"shrink-0",children:y.badge})]},y.id)})}),(p==null?void 0:p.content)!==void 0&&e.jsx("div",{role:"tabpanel",id:`${p.id}-panel`,"aria-labelledby":`${p.id}-tab`,className:`pt-4 ${u}`,children:p.content})]})}function vr(...r){return r.filter(Boolean).join(" ")}function cc({steps:r,activeStepId:t,initialStepId:a,completedStepIds:n,defaultCompletedStepIds:s=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:c,allowBackNavigation:u=!0,showFooter:f=!0,previousLabel:b="Anterior",nextLabel:p="Siguiente",blockedNextLabel:m="Completa este paso",className:w="",headerClassName:y="",contentClassName:k="",footerClassName:v=""}){var te;const C=((te=r[0])==null?void 0:te.id)??"",[B,T]=o.useState(a??C),[W,L]=o.useState(s),S=t??B,q=n??W,H=o.useMemo(()=>new Set(q),[q]),z=Math.max(0,r.findIndex(J=>J.id===S)),X=r[z]??r[0],Z=r.length<=1?100:z/(r.length-1)*100,M=J=>{n||L(J),i==null||i(J)},U=J=>{const h=r.find(D=>D.id===J);h&&(t||T(J),l==null||l(J,h))},j=J=>H.has(J),N=J=>r.slice(0,J).find(h=>!h.optional&&!H.has(h.id)),K=J=>{const h=r[J];return!h||h.disabled?!1:J===z||u&&J<z?!0:!N(J)},I=J=>{const h=r.findIndex(D=>D.id===J);return h>=0&&K(h)},E=J=>{const h=r.findIndex(D=>D.id===J);if(h<0)return!1;if(!K(h)){const D=N(h);return D&&(c==null||c(r[h],D)),!1}return U(J),!0},R=(J=X==null?void 0:X.id)=>{!J||H.has(J)||M([...q,J])},ne=(J=X==null?void 0:X.id)=>{if(!J)return;const h=r.findIndex(V=>V.id===J),D=q.filter(V=>{const ae=r.findIndex(se=>se.id===V);return ae>=0&&ae<h});M(D),h>=0&&z>h&&U(J)},$=()=>z<=0?!1:E(r[z-1].id),O=()=>{const J=r[z+1];return J?E(J.id):!1},re={activeStep:X,activeIndex:z,completedStepIds:q,isCompleted:j,isUnlocked:I,completeStep:R,uncompleteStep:ne,goToStep:E,goNext:O,goPrevious:$};if(!X)return null;const ee=r[z+1],oe=z>0,ie=ee?I(ee.id):!1,ve=typeof X.content=="function"?X.content(re):X.content;return e.jsxs("section",{className:vr("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",w),children:[e.jsxs("div",{className:vr("border-b border-[var(--border)] bg-[var(--bg-input)]",y),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:`${Z}%`}})}),e.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${r.length}, minmax(0, 1fr))`},children:r.map((J,h)=>{const D=J.id===X.id,V=j(J.id),ae=K(h),se=N(h);return e.jsxs("button",{type:"button",disabled:!ae,"aria-current":D?"step":void 0,"aria-disabled":!ae,title:!ae&&se?`Completa ${se.title}`:J.title,onClick:()=>E(J.id),className:vr("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",D&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",V&&!D&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!D&&!V&&ae&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!ae&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[e.jsx("span",{className:vr("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",D&&"scale-x-100")}),e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:vr("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",D&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",V&&!D&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!V&&!D&&ae&&"border-[var(--border)] text-[var(--text-muted)]",!ae&&"border-[var(--border)] text-[var(--text-muted)]"),children:V?e.jsx(A.HiCheck,{className:"h-4 w-4"}):ae?h+1:e.jsx(A.HiLockClosed,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:vr("block truncate text-xs font-semibold transition-colors duration-200",D?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[h+1,". ",J.title]}),J.description&&e.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:J.description})]}),J.badge&&e.jsx("span",{className:"shrink-0",children:J.badge})]})]},J.id)})})]}),e.jsx("div",{className:vr("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",k),children:ve},X.id),f&&e.jsxs("div",{className:vr("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",v),children:[e.jsx(Pe,{variant:"secondary",height:38,padding:"0 14px",icon:e.jsx(A.HiChevronLeft,{}),disabled:!oe,onClick:$,children:b}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[e.jsxs("span",{children:["Paso ",z+1," de ",r.length]}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),e.jsxs("span",{children:[q.length," completados"]})]}),e.jsx(Pe,{height:38,padding:"0 14px",icon:e.jsx(A.HiChevronRight,{}),disabled:!ee||!ie,onClick:O,children:ee&&!ie?m:p})]})]})}const dc={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"},uc={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function fc(r,t){if(r){if(typeof r=="function"){r(t);return}r.current=t}}function bc(r,t){return r!==void 0?String(r).length:t!==void 0?String(t).length:0}const xo=o.forwardRef(function({className:t="",wrapperClassName:a="",size:n="md",resize:s="vertical",autoResize:l=!1,minRows:i,maxRows:c,showCount:u=!1,maxCount:f,status:b="default",icon:p,action:m,style:w,value:y,defaultValue:k,maxLength:v,onInput:C,...B},T){const W=o.useRef(null),L=bc(y,k),S=f??v,q=!!(p||m||u),H=b==="error"?"var(--danger)":b==="success"?"#16a34a":"var(--border)",z={...w??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},X=()=>{const M=W.current;!M||!l||(M.style.height="auto",M.style.height=`${M.scrollHeight}px`)};o.useEffect(X,[l,y]);const Z=e.jsx("textarea",{...B,ref:M=>{W.current=M,fc(T,M)},value:y,defaultValue:k,maxLength:v,"aria-invalid":b==="error"||B["aria-invalid"],onInput:M=>{X(),C==null||C(M)},style:{...z,borderColor:H},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 ${dc[n]} ${uc[l?"none":s]} ${p?"pl-8":""} ${m?"pr-10":""} ${t}`});return q?e.jsxs("span",{className:`relative block ${a}`,children:[p&&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:p}),Z,m&&e.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:m}),u&&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:[L,S?`/${S}`:""]})]}):Z});function pc({label:r,containerClassName:t="",helperText:a,error:n,labelAction:s,required:l,className:i="",status:c,...u}){return e.jsx(eo,{label:r,required:l,helperText:a,error:n,labelAction:s,className:t,children:e.jsx(xo,{...u,required:l,status:n?"error":c,className:`w-full ${i}`})})}const yo=[{bg:"#dbeafe",text:"#1e40af",border:"#bfdbfe"},{bg:"#dcfce7",text:"#166534",border:"#bbf7d0"},{bg:"#fce7f3",text:"#9d174d",border:"#fbcfe8"},{bg:"#fef9c3",text:"#854d0e",border:"#fef08a"},{bg:"#ede9fe",text:"#5b21b6",border:"#ddd6fe"},{bg:"#ffedd5",text:"#9a3412",border:"#fed7aa"},{bg:"#cffafe",text:"#155e75",border:"#a5f3fc"},{bg:"#f0fdf4",text:"#14532d",border:"#bbf7d0"}];function mc(r){return yo[r%yo.length]}let hc=0;function Ja(){return++hc}function wo(r,t){return t?t instanceof RegExp?t.test(r):t(r):!0}function vc(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function gc(r,t){const a=t.filter(Boolean);if(a.length===0)return[r.trim()].filter(Boolean);const n=new RegExp(`${a.map(s=>vc(s)).join("|")}|\\r?\\n`,"g");return r.split(n).map(s=>s.trim()).filter(Boolean)}function xc({value:r,defaultValue:t,onChange:a,placeholder:n="Escribe y presiona Enter…",disabled:s=!1,className:l="",delimiters:i=[","],maxTags:c,allowDuplicates:u=!1,validate:f,label:b,helperText:p,error:m,required:w=!1}){const y=r!==void 0,[k,v]=o.useState(()=>(t??[]).map((h,D)=>({id:Ja(),value:h.trim(),colorIndex:D})));o.useEffect(()=>{y&&v(h=>{const D=r??[],V=new Map(h.map(ae=>[ae.value,ae]));return D.map((ae,se)=>V.get(ae)??{id:Ja(),value:ae,colorIndex:se})})},[y,r]);const C=k,[B,T]=o.useState(""),[W,L]=o.useState(null),[S,q]=o.useState(""),[H,z]=o.useState(!1),[X,Z]=o.useState(!1),M=o.useRef(null),U=o.useRef(null),j=o.useRef(null),N=!!m;function K(){Z(!0),setTimeout(()=>Z(!1),400)}function I(h){v(h),a==null||a(h.map(D=>D.value))}function E(h){let D=C,V=!1,ae=!1;for(const se of h){const he=se.trim();if(he){if(c!==void 0&&D.length>=c){ae=!0;break}if(!u&&D.some(Be=>Be.value.toLowerCase()===he.toLowerCase())){ae=!0;continue}if(!wo(he,f)){ae=!0;continue}D=[...D,{id:Ja(),value:he,colorIndex:D.length}],V=!0}}return V&&I(D),ae&&K(),V}function R(h){return E([h])}function ne(h){const D=C.filter(V=>V.id!==h);I(D.map((V,ae)=>({...V,colorIndex:ae})))}function $(h,D){const V=D.trim();if(L(null),q(""),!V){ne(h);return}if(!(!u&&C.some(ae=>ae.id!==h&&ae.value.toLowerCase()===V.toLowerCase()))){if(!wo(V,f)){K();return}I(C.map(ae=>ae.id===h?{...ae,value:V}:ae))}}function O(h){s||(L(h.id),q(h.value),setTimeout(()=>{var D;return(D=U.current)==null?void 0:D.select()},0))}function re(h){if(h.key==="Enter"||i.includes(h.key)){h.preventDefault(),R(B)&&T("");return}if(h.key==="Backspace"&&B===""&&C.length>0){h.preventDefault();const D=C[C.length-1];ne(D.id)}}function ee(h,D){if(h.key==="Enter"){h.preventDefault(),$(D,S),setTimeout(()=>{var V;return(V=M.current)==null?void 0:V.focus()},0);return}h.key==="Escape"&&(h.preventDefault(),L(null),q(""),setTimeout(()=>{var V;return(V=M.current)==null?void 0:V.focus()},0))}function oe(){var h;s||(h=M.current)==null||h.focus()}function ie(h){if(s)return;const D=h.clipboardData.getData("text");if(!D||!(i.some(he=>he&&D.includes(he))||D.includes(`
30
- `)))return;h.preventDefault();const ae=gc(D,i);E(ae)&&T("")}function ve(){const h=B.trim();h&&R(h)&&T("")}const te=N?"var(--danger)":H?"var(--primary)":"var(--border)",J=c!==void 0&&C.length>=c;return e.jsxs("div",{className:`flex flex-col gap-2 ${l}`,children:[(b||w)&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[b&&e.jsx("span",{children:b}),w&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"})]}),e.jsxs("div",{ref:j,onClick:oe,onFocus:()=>z(!0),onBlur:h=>{var D;(D=j.current)!=null&&D.contains(h.relatedTarget)||(z(!1),W!==null&&$(W,S),W===null&&ve())},style:{borderColor:te},className:`
28
+ `).replace(/<[^>]+>/g," ").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/\s+/g," ").trim():""}function Qa(r){if(!r)return[];const t=go(r),a=new Set,n=[];Xa.lastIndex=0;let s;for(;(s=Xa.exec(t))!==null;){const l=Za(s[1]??"");!l||a.has(l)||(a.add(l),n.push(l))}return n}function ec(r,t){const a=Qa(r);if(!a.length)return[];const n=new Map;t.forEach(i=>{i.username&&n.set(Za(i.username),i)});const s=new Set,l=[];for(const i of a){const c=n.get(i);c&&(s.has(c.userId)||(s.add(c.userId),l.push({userId:c.userId,username:c.username,email:c.email??void 0,display:c.name??c.username})))}return l}function vo(r){const t=new Set,a=[];for(const n of r)t.has(n.userId)||(t.add(n.userId),a.push(n));return a}function rc(r,t){return t?r.filter(a=>a.userId!==t):r}function xo(r){return!r||!/@/.test(r)?r:r.replace(Xa,(t,a,n,s)=>{const l=s.slice(0,n),i=l.lastIndexOf("<"),c=l.lastIndexOf(">");return i>c?t:`<span class="mention-chip" contenteditable="false" data-username="${(a??"").toLowerCase()}">${t}</span>`})}function Ur(r,t){if(t<0)return null;const a=r.ownerDocument;if(!a)return null;const n=a.createTreeWalker(r,NodeFilter.SHOW_TEXT);let s=t,l=null,i=n.nextNode();for(;i;){l=i;const c=i.data.length;if(s<=c)return{node:i,offset:s};s-=c,i=n.nextNode()}return l&&s===0?{node:l,offset:l.data.length}:null}function Ja(r,t,a){var s;const n=r.ownerDocument;if(!n||r!==t&&!r.contains(t))return-1;try{const l=n.createRange();return l.selectNodeContents(r),l.setEnd(t,a),((s=l.cloneContents().textContent)==null?void 0:s.length)??0}catch{return-1}}function yo(r,t){const{triggerIndex:a,caretIndex:n,username:s}=t;if(n<a)return null;const l=Ur(r,a),i=Ur(r,n);if(!l||!i)return null;const c=r.ownerDocument,u=c.createRange();u.setStart(l.node,l.offset),u.setEnd(i.node,i.offset),u.deleteContents();const f=c.createElement("span");f.className="mention-chip",f.setAttribute("data-username",s.toLowerCase()),f.contentEditable="false",f.textContent=`@${s}`;const m=c.createTextNode(" ");u.insertNode(m),u.insertNode(f);const b=c.defaultView,p=b==null?void 0:b.getSelection();if(p){const y=c.createRange();y.setStart(m,m.data.length),y.collapse(!0),p.removeAllRanges(),p.addRange(y)}return{caretPlainOffset:a+s.length+2}}function wo(r,t){const a=r.ownerDocument,n=a.defaultView;if(!n)return;const s=n.getSelection();if(!s)return;const l=a.createRange(),i=Ur(r,t);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(r),l.collapse(!1)),s.removeAllRanges(),s.addRange(l)}const tc={position:"relative"},ac={position:"fixed",zIndex:1100,minWidth:260,maxHeight:280,overflowY:"auto",background:"var(--bg-card, var(--bonsaif-ui-surface, #fff))",border:"1px solid var(--border, var(--bonsaif-ui-border, #d0d7de))",borderRadius:10,boxShadow:"0 12px 32px rgba(0,0,0,0.18)",padding:4},No={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function nc(r){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(r)}"]`))}function ko({value:r,onChange:t,onSearchUsers:a,onMentionsChange:n,minHeight:s,placeholder:l,className:i,maxSuggestions:c=8,searchDebounceMs:u=140,highlightInEditor:f=!1,searchCacheKey:m=""}){const b=o.useId().replace(/:/g,""),p=o.useRef(null),y=o.useRef(null),N=o.useRef(new Map),M=o.useRef(a);M.current=a;const g=o.useRef(null),[C,B]=o.useState(null),[A,z]=o.useState([]),[E,k]=o.useState(0),[q,H]=o.useState([]),[_,Y]=o.useState(!1),[Z,T]=o.useState(!1);o.useEffect(()=>{T(!0)},[]),o.useEffect(()=>{if(!C){z([]);return}const R=C.query.trim(),x=`${m}|${R.toLowerCase()||"*"}`,S=N.current.get(x);if(S){z(S),Y(!1),k(0);return}const K=new AbortController;Y(!0);const Q=window.setTimeout(()=>{(async()=>{try{const ae=await M.current(R,{signal:K.signal,limit:c});if(K.signal.aborted)return;const ce=Array.isArray(ae)?ae:[];N.current.set(x,ce),z(ce),k(0)}catch{K.signal.aborted||z([])}finally{K.signal.aborted||Y(!1)}})()},u);return()=>{K.abort(),window.clearTimeout(Q)}},[C,c,u,m]);const J=o.useRef(n);J.current=n,o.useEffect(()=>{var R;(R=J.current)==null||R.call(J,vo(q))},[q]);const O=o.useCallback(()=>{const R=nc(b);if(R.length===0)return null;const x=window.getSelection();if(x!=null&&x.rangeCount){const K=x.getRangeAt(0).startContainer;for(const Q of R)if(Q.contains(K))return Q}const S=document.activeElement;for(const K of R)if(S===K||S&&K.contains(S))return K;for(const K of R)if(K.closest('[role="dialog"]'))return K;return R[0]??null},[b]),j=o.useCallback(R=>{t(R);const x=O(),S=window.getSelection();if(!x||!S||S.rangeCount===0){B(null);return}const K=S.getRangeAt(0);if(!x.contains(K.startContainer)){B(null);return}const Q=Ja(x,K.startContainer,K.startOffset);if(Q<0){B(null);return}const ae=Ya(x,Q);if(!ae){B(null);return}const ce=K.getBoundingClientRect();g.current={query:ae.query,caretIndex:ae.caretIndex,triggerIndex:ae.triggerIndex},B({query:ae.query,top:ce.bottom+6,left:Math.max(8,Math.min(ce.left,window.innerWidth-280))})},[O,t]),te=o.useCallback(R=>{const x=O();if(!x)return;let S=-1;const K=window.getSelection();if(K&&K.rangeCount>0){const re=K.getRangeAt(0);x.contains(re.startContainer)&&(S=Ja(x,re.startContainer,re.startOffset))}if(S<0&&g.current&&(S=g.current.caretIndex),S<0)return;const Q=Ya(x,S);if(!Q)return;const ae=yo(x,{triggerIndex:Q.triggerIndex,caretIndex:S,username:R.username});if(!ae)return;t(x.innerHTML);const ce={userId:R.userId,username:R.username,email:R.email??void 0,display:R.name??R.username};H(re=>{const G=new Map(re.map(h=>[h.userId,h]));return G.set(ce.userId,ce),Array.from(G.values())}),B(null),g.current=null;const ve=ae.caretPlainOffset;requestAnimationFrame(()=>{requestAnimationFrame(()=>{var W,ne;const re=O();if(!re)return;re.focus(),wo(re,ve);const G=window.getSelection(),h=G==null?void 0:G.anchorNode,L=h instanceof Element?h.closest(".mention-chip"):(W=h==null?void 0:h.parentElement)==null?void 0:W.closest(".mention-chip");if(L!=null&&L.parentNode){const oe=document.createRange(),he=L.nextSibling;he&&he.nodeType===Node.TEXT_NODE?oe.setStart(he,((ne=he.textContent)==null?void 0:ne.length)??0):oe.setStartAfter(L),oe.collapse(!0),G==null||G.removeAllRanges(),G==null||G.addRange(oe)}})})},[O,t]);o.useEffect(()=>{const R=new Set(Qa(r).map(x=>x.toLowerCase()));H(x=>{const S=x.filter(K=>R.has(K.username.toLowerCase()));return S.length===x.length?x:S})},[r]),o.useEffect(()=>{if(!C)return;const R=x=>{const S=x.target;if(!S||p.current&&p.current.contains(S)||y.current&&y.current.contains(S))return;const K=O();K&&K.contains(S)||B(null)};return document.addEventListener("mousedown",R),()=>{document.removeEventListener("mousedown",R)}},[C,O]);const X=o.useMemo(()=>A.slice(0,c),[A,c]);o.useEffect(()=>{if(!C)return;const R=x=>{const S=O(),K=x.target;if(!(!S||!K||!S.contains(K))&&!(X.length===0&&x.key!=="Escape"))if(x.key==="ArrowDown")x.preventDefault(),x.stopPropagation(),k(Q=>(Q+1)%Math.max(X.length,1));else if(x.key==="ArrowUp")x.preventDefault(),x.stopPropagation(),k(Q=>(Q-1+X.length)%Math.max(X.length,1));else if(x.key==="Enter"||x.key==="Tab"){const Q=X[E];Q&&(x.preventDefault(),x.stopPropagation(),te(Q))}else x.key==="Escape"&&(x.preventDefault(),x.stopPropagation(),B(null))};return document.addEventListener("keydown",R,!0),()=>document.removeEventListener("keydown",R,!0)},[E,O,te,C,X]);const I=f?xo(r):r,ee=C&&Z?Je.createPortal(e.jsxs("ul",{ref:y,style:{...ac,top:C.top,left:C.left},role:"listbox","aria-label":"Menciones sugeridas",children:[_&&X.length===0&&e.jsx("li",{style:No,children:"Buscando…"}),!_&&X.length===0&&e.jsx("li",{style:No,children:C.query.trim().length===0?"Escribe para buscar un usuario":`Sin coincidencias para “${C.query}”`}),X.map((R,x)=>e.jsx("li",{children:e.jsxs("button",{type:"button",onMouseDown:S=>{S.preventDefault(),te(R)},onMouseEnter:()=>k(x),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:x===E?"color-mix(in srgb, var(--primary, var(--bonsaif-ui-primary, #1f6feb)) 14%, transparent)":"transparent",color:"var(--text-main, var(--bonsaif-ui-text, #24292f))",borderRadius:6,cursor:"pointer",display:"flex",flexDirection:"column",gap:2},children:[e.jsxs("span",{style:{fontWeight:600,fontSize:13},children:["@",R.username]}),e.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[R.name,R.email].filter(Boolean).join(" · ")||" "})]})},R.userId))]}),document.body):null;return e.jsxs("div",{ref:p,style:tc,className:i,children:[e.jsx(uo,{value:I,onChange:j,placeholder:l,minHeight:s,instanceId:b}),ee]})}function oc({value:r,onChange:t,placeholder:a,minHeight:n,onSearchUsers:s,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:u,highlightInEditor:f,searchCacheKey:m}){return s?e.jsx(ko,{value:r,onChange:t,onSearchUsers:s,onMentionsChange:l,placeholder:a,minHeight:n,className:i,maxSuggestions:c,searchDebounceMs:u,highlightInEditor:f,searchCacheKey:m}):e.jsx(uo,{value:r,onChange:t,placeholder:a,minHeight:n})}function sc({title:r,subtitle:t,icon:a,actions:n,children:s,footer:l,className:i="",bodyClassName:c="p-4"}){const u=r||t||a||n;return e.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${i}`,children:[u&&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:s}),l&&e.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:l})]})}const lc={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)"}},ic={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 cc({children:r,tone:t="neutral",size:a="sm",icon:n,dot:s=!1,className:l=""}){const i=lc[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 ${ic[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})]})}const So={neutral:{color:"var(--text-secondary)",background:"var(--bg-input)"},primary:{color:"var(--primary)",background:"color-mix(in srgb, var(--primary) 10%, transparent)"},success:{color:"#047857",background:"rgba(16, 185, 129, 0.11)"},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)"},danger:{color:"var(--danger)",background:"var(--danger-bg)"},info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.11)"}},dc={xs:"min-h-5 px-1.5 pr-6 text-[10px]",sm:"min-h-6 px-2 pr-7 text-xs",md:"min-h-7 px-2.5 pr-8 text-sm"},uc={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},fc={xs:148,sm:164,md:184},bc={xs:"px-2.5 py-1.5 text-xs",sm:"px-3 py-2 text-sm",md:"px-3.5 py-2.5 text-sm"};function pc({value:r,options:t,onChange:a,size:n="sm",disabled:s=!1,loading:l=!1,stopPropagation:i=!1,ariaLabel:c="Cambiar estado",title:u="Cambiar estado",className:f,selectClassName:m,menuClassName:b,optionClassName:p,spinnerClassName:y}){const[N,M]=o.useState(!1),[g,C]=o.useState(!1),[B,A]=o.useState(-1),[z,E]=o.useState({}),k=o.useRef(null),q=o.useRef(null),H=o.useRef(null),_=t.find(I=>I.value===r)??t[0],Y={..._!=null&&_.tone?So[_.tone]:void 0,..._==null?void 0:_.style},Z=s||l||t.length===0,T=I=>{i&&I.stopPropagation()},J=o.useCallback(()=>{M(!1),A(-1)},[]),O=o.useCallback(()=>{const I=k.current;if(!I)return;const ee=I.getBoundingClientRect(),R=Math.max(ee.width,fc[n]),x=Math.min(Math.max(t.length,1)*38+12,260),S=window.innerHeight-ee.bottom,K=S<x&&ee.top>S,Q=Math.min(Math.max(8,ee.left+ee.width/2-R/2),window.innerWidth-R-8);E({position:"fixed",left:Q,top:K?void 0:ee.bottom+6,bottom:K?window.innerHeight-ee.top+6:void 0,width:R,zIndex:9999})},[t.length,n]),j=o.useCallback(I=>{I.disabled||(a(I.value),J())},[J,a]);o.useEffect(()=>C(!0),[]),o.useEffect(()=>{if(!N)return;O();const I=t.findIndex(ee=>ee.value===r);A(I>=0?I:0)},[N,t,O,r]),o.useEffect(()=>{if(!N)return;function I(ee){var x,S;const R=ee.target;!((x=k.current)!=null&&x.contains(R))&&!((S=q.current)!=null&&S.contains(R))&&J()}return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[J,N]),o.useEffect(()=>{if(N)return window.addEventListener("resize",O),window.addEventListener("scroll",O,!0),()=>{window.removeEventListener("resize",O),window.removeEventListener("scroll",O,!0)}},[N,O]),o.useEffect(()=>{if(B<0||!H.current)return;const I=H.current.children[B];I==null||I.scrollIntoView({block:"nearest"})},[B]);function te(I){if(!Z){if(!N){["Enter"," ","ArrowDown","ArrowUp"].includes(I.key)&&(I.preventDefault(),M(!0));return}if(I.key==="Escape"){I.preventDefault(),J();return}if(I.key==="ArrowDown"){I.preventDefault(),A(ee=>Math.min(ee+1,t.length-1));return}if(I.key==="ArrowUp"){I.preventDefault(),A(ee=>Math.max(ee-1,0));return}if(I.key==="Enter"||I.key===" "){I.preventDefault();const ee=t[B];ee&&j(ee)}}}const X=e.jsx("div",{ref:q,role:"listbox","aria-label":c,className:hr("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",b),style:{...z,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:T,onMouseDown:T,onPointerDown:T,children:e.jsx("div",{ref:H,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:t.map((I,ee)=>{const R=I.value===r,x=ee===B,S={...I.tone?So[I.tone]:void 0,...I.style};return e.jsxs("button",{type:"button",role:"option","aria-selected":R,disabled:I.disabled,onMouseEnter:()=>!I.disabled&&A(ee),onMouseDown:K=>{K.preventDefault(),j(I)},className:hr("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",bc[n],R?I.className:void 0,p),style:{...R?S:void 0,background:R?S.background??"color-mix(in srgb, var(--primary) 12%, transparent)":x?"var(--bg-hover)":"transparent",color:R?S.color??"var(--primary)":"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:R?e.jsx($.HiCheck,{className:"h-4 w-4"}):null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:I.label})]},I.value)})})});return e.jsxs("span",{ref:k,className:hr("relative inline-flex shrink-0 items-center",f),onKeyDown:te,onClick:T,onPointerDown:T,children:[e.jsx("button",{type:"button",disabled:Z,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":N,title:u,onClick:()=>!Z&&M(I=>!I),className:hr("inline-flex items-center rounded-full border border-transparent font-medium leading-none outline-none transition-colors hover:border-current focus:border-current disabled:cursor-wait disabled:opacity-70",dc[n],_==null?void 0:_.className,m),style:Y,children:e.jsx("span",{className:"min-w-0 truncate",children:(_==null?void 0:_.label)??r})}),e.jsx($.HiChevronDown,{"aria-hidden":"true",className:hr("pointer-events-none absolute opacity-70 transition-transform",uc[n],N?"rotate-180":"rotate-0")}),l&&e.jsx("span",{"aria-hidden":"true",className:hr("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",y)}),N&&g&&Je.createPortal(X,document.body)]})}function mc({tabs:r,activeTabId:t,defaultActiveTabId:a,onTabChange:n,ariaLabel:s="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:u=""}){const f=r.find(N=>!N.disabled)??r[0],m=t??a??(f==null?void 0:f.id),b=r.find(N=>N.id===m)??f,p=N=>{N.disabled||n==null||n(N.id)},y=N=>{const M=r.filter(C=>!C.disabled);if(!M.length||!b)return;const g=M.findIndex(C=>C.id===b.id);(N.key==="ArrowRight"||N.key==="ArrowDown")&&(N.preventDefault(),p(M[(g+1)%M.length])),(N.key==="ArrowLeft"||N.key==="ArrowUp")&&(N.preventDefault(),p(M[(g-1+M.length)%M.length])),N.key==="Home"&&(N.preventDefault(),p(M[0])),N.key==="End"&&(N.preventDefault(),p(M[M.length-1]))};return e.jsxs("div",{className:i,children:[e.jsx("div",{role:"tablist","aria-label":s,onKeyDown:y,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(N=>{const M=N.id===(b==null?void 0:b.id);return e.jsxs("button",{type:"button",role:"tab","aria-selected":M,"aria-controls":`${N.id}-panel`,id:`${N.id}-tab`,disabled:N.disabled,tabIndex:M?0:-1,onClick:()=>p(N),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:M?"var(--primary)":"var(--text-muted)",borderColor:M?"var(--primary)":"transparent",background:l==="pills"&&M?"var(--bg-card)":"transparent"},children:[N.icon&&e.jsx("span",{className:"shrink-0",children:N.icon}),e.jsx("span",{children:N.label}),N.badge&&e.jsx("span",{className:"shrink-0",children:N.badge})]},N.id)})}),(b==null?void 0:b.content)!==void 0&&e.jsx("div",{role:"tabpanel",id:`${b.id}-panel`,"aria-labelledby":`${b.id}-tab`,className:`pt-4 ${u}`,children:b.content})]})}function xr(...r){return r.filter(Boolean).join(" ")}function hc({steps:r,activeStepId:t,initialStepId:a,completedStepIds:n,defaultCompletedStepIds:s=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:c,allowBackNavigation:u=!0,showFooter:f=!0,previousLabel:m="Anterior",nextLabel:b="Siguiente",blockedNextLabel:p="Completa este paso",className:y="",headerClassName:N="",contentClassName:M="",footerClassName:g=""}){var re;const C=((re=r[0])==null?void 0:re.id)??"",[B,A]=o.useState(a??C),[z,E]=o.useState(s),k=t??B,q=n??z,H=o.useMemo(()=>new Set(q),[q]),_=Math.max(0,r.findIndex(G=>G.id===k)),Y=r[_]??r[0],Z=r.length<=1?100:_/(r.length-1)*100,T=G=>{n||E(G),i==null||i(G)},J=G=>{const h=r.find(L=>L.id===G);h&&(t||A(G),l==null||l(G,h))},O=G=>H.has(G),j=G=>r.slice(0,G).find(h=>!h.optional&&!H.has(h.id)),te=G=>{const h=r[G];return!h||h.disabled?!1:G===_||u&&G<_?!0:!j(G)},X=G=>{const h=r.findIndex(L=>L.id===G);return h>=0&&te(h)},I=G=>{const h=r.findIndex(L=>L.id===G);if(h<0)return!1;if(!te(h)){const L=j(h);return L&&(c==null||c(r[h],L)),!1}return J(G),!0},ee=(G=Y==null?void 0:Y.id)=>{!G||H.has(G)||T([...q,G])},R=(G=Y==null?void 0:Y.id)=>{if(!G)return;const h=r.findIndex(W=>W.id===G),L=q.filter(W=>{const ne=r.findIndex(oe=>oe.id===W);return ne>=0&&ne<h});T(L),h>=0&&_>h&&J(G)},x=()=>_<=0?!1:I(r[_-1].id),S=()=>{const G=r[_+1];return G?I(G.id):!1},K={activeStep:Y,activeIndex:_,completedStepIds:q,isCompleted:O,isUnlocked:X,completeStep:ee,uncompleteStep:R,goToStep:I,goNext:S,goPrevious:x};if(!Y)return null;const Q=r[_+1],ae=_>0,ce=Q?X(Q.id):!1,ve=typeof Y.content=="function"?Y.content(K):Y.content;return e.jsxs("section",{className:xr("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",y),children:[e.jsxs("div",{className:xr("border-b border-[var(--border)] bg-[var(--bg-input)]",N),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:`${Z}%`}})}),e.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${r.length}, minmax(0, 1fr))`},children:r.map((G,h)=>{const L=G.id===Y.id,W=O(G.id),ne=te(h),oe=j(h);return e.jsxs("button",{type:"button",disabled:!ne,"aria-current":L?"step":void 0,"aria-disabled":!ne,title:!ne&&oe?`Completa ${oe.title}`:G.title,onClick:()=>I(G.id),className:xr("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",L&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",W&&!L&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!L&&!W&&ne&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!ne&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[e.jsx("span",{className:xr("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",L&&"scale-x-100")}),e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:xr("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",L&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",W&&!L&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!W&&!L&&ne&&"border-[var(--border)] text-[var(--text-muted)]",!ne&&"border-[var(--border)] text-[var(--text-muted)]"),children:W?e.jsx($.HiCheck,{className:"h-4 w-4"}):ne?h+1:e.jsx($.HiLockClosed,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:xr("block truncate text-xs font-semibold transition-colors duration-200",L?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[h+1,". ",G.title]}),G.description&&e.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:G.description})]}),G.badge&&e.jsx("span",{className:"shrink-0",children:G.badge})]})]},G.id)})})]}),e.jsx("div",{className:xr("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",M),children:ve},Y.id),f&&e.jsxs("div",{className:xr("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",g),children:[e.jsx(He,{variant:"secondary",height:38,padding:"0 14px",icon:e.jsx($.HiChevronLeft,{}),disabled:!ae,onClick:x,children:m}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[e.jsxs("span",{children:["Paso ",_+1," de ",r.length]}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),e.jsxs("span",{children:[q.length," completados"]})]}),e.jsx(He,{height:38,padding:"0 14px",icon:e.jsx($.HiChevronRight,{}),disabled:!Q||!ce,onClick:S,children:Q&&!ce?p:b})]})]})}const gc={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"},vc={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function xc(r,t){if(r){if(typeof r=="function"){r(t);return}r.current=t}}function yc(r,t){return r!==void 0?String(r).length:t!==void 0?String(t).length:0}const Co=o.forwardRef(function({className:t="",wrapperClassName:a="",size:n="md",resize:s="vertical",autoResize:l=!1,minRows:i,maxRows:c,showCount:u=!1,maxCount:f,status:m="default",icon:b,action:p,style:y,value:N,defaultValue:M,maxLength:g,onInput:C,...B},A){const z=o.useRef(null),E=yc(N,M),k=f??g,q=!!(b||p||u),H=m==="error"?"var(--danger)":m==="success"?"#16a34a":"var(--border)",_={...y??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},Y=()=>{const T=z.current;!T||!l||(T.style.height="auto",T.style.height=`${T.scrollHeight}px`)};o.useEffect(Y,[l,N]);const Z=e.jsx("textarea",{...B,ref:T=>{z.current=T,xc(A,T)},value:N,defaultValue:M,maxLength:g,"aria-invalid":m==="error"||B["aria-invalid"],onInput:T=>{Y(),C==null||C(T)},style:{..._,borderColor:H},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 ${gc[n]} ${vc[l?"none":s]} ${b?"pl-8":""} ${p?"pr-10":""} ${t}`});return q?e.jsxs("span",{className:`relative block ${a}`,children:[b&&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:b}),Z,p&&e.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:p}),u&&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:[E,k?`/${k}`:""]})]}):Z});function wc({label:r,containerClassName:t="",helperText:a,error:n,labelAction:s,required:l,className:i="",status:c,...u}){return e.jsx(ro,{label:r,required:l,helperText:a,error:n,labelAction:s,className:t,children:e.jsx(Co,{...u,required:l,status:n?"error":c,className:`w-full ${i}`})})}const Eo=[{bg:"#dbeafe",text:"#1e40af",border:"#bfdbfe"},{bg:"#dcfce7",text:"#166534",border:"#bbf7d0"},{bg:"#fce7f3",text:"#9d174d",border:"#fbcfe8"},{bg:"#fef9c3",text:"#854d0e",border:"#fef08a"},{bg:"#ede9fe",text:"#5b21b6",border:"#ddd6fe"},{bg:"#ffedd5",text:"#9a3412",border:"#fed7aa"},{bg:"#cffafe",text:"#155e75",border:"#a5f3fc"},{bg:"#f0fdf4",text:"#14532d",border:"#bbf7d0"}];function Nc(r){return Eo[r%Eo.length]}let kc=0;function Ra(){return++kc}function Mo(r,t){return t?t instanceof RegExp?t.test(r):t(r):!0}function Sc(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Cc(r,t){const a=t.filter(Boolean);if(a.length===0)return[r.trim()].filter(Boolean);const n=new RegExp(`${a.map(s=>Sc(s)).join("|")}|\\r?\\n`,"g");return r.split(n).map(s=>s.trim()).filter(Boolean)}function Ec({value:r,defaultValue:t,onChange:a,placeholder:n="Escribe y presiona Enter…",disabled:s=!1,className:l="",delimiters:i=[","],maxTags:c,allowDuplicates:u=!1,validate:f,label:m,helperText:b,error:p,required:y=!1}){const N=r!==void 0,[M,g]=o.useState(()=>(t??[]).map((h,L)=>({id:Ra(),value:h.trim(),colorIndex:L})));o.useEffect(()=>{N&&g(h=>{const L=r??[],W=new Map(h.map(ne=>[ne.value,ne]));return L.map((ne,oe)=>W.get(ne)??{id:Ra(),value:ne,colorIndex:oe})})},[N,r]);const C=M,[B,A]=o.useState(""),[z,E]=o.useState(null),[k,q]=o.useState(""),[H,_]=o.useState(!1),[Y,Z]=o.useState(!1),T=o.useRef(null),J=o.useRef(null),O=o.useRef(null),j=!!p;function te(){Z(!0),setTimeout(()=>Z(!1),400)}function X(h){g(h),a==null||a(h.map(L=>L.value))}function I(h){let L=C,W=!1,ne=!1;for(const oe of h){const he=oe.trim();if(he){if(c!==void 0&&L.length>=c){ne=!0;break}if(!u&&L.some(_e=>_e.value.toLowerCase()===he.toLowerCase())){ne=!0;continue}if(!Mo(he,f)){ne=!0;continue}L=[...L,{id:Ra(),value:he,colorIndex:L.length}],W=!0}}return W&&X(L),ne&&te(),W}function ee(h){return I([h])}function R(h){const L=C.filter(W=>W.id!==h);X(L.map((W,ne)=>({...W,colorIndex:ne})))}function x(h,L){const W=L.trim();if(E(null),q(""),!W){R(h);return}if(!(!u&&C.some(ne=>ne.id!==h&&ne.value.toLowerCase()===W.toLowerCase()))){if(!Mo(W,f)){te();return}X(C.map(ne=>ne.id===h?{...ne,value:W}:ne))}}function S(h){s||(E(h.id),q(h.value),setTimeout(()=>{var L;return(L=J.current)==null?void 0:L.select()},0))}function K(h){if(h.key==="Enter"||i.includes(h.key)){h.preventDefault(),ee(B)&&A("");return}if(h.key==="Backspace"&&B===""&&C.length>0){h.preventDefault();const L=C[C.length-1];R(L.id)}}function Q(h,L){if(h.key==="Enter"){h.preventDefault(),x(L,k),setTimeout(()=>{var W;return(W=T.current)==null?void 0:W.focus()},0);return}h.key==="Escape"&&(h.preventDefault(),E(null),q(""),setTimeout(()=>{var W;return(W=T.current)==null?void 0:W.focus()},0))}function ae(){var h;s||(h=T.current)==null||h.focus()}function ce(h){if(s)return;const L=h.clipboardData.getData("text");if(!L||!(i.some(he=>he&&L.includes(he))||L.includes(`
29
+ `)))return;h.preventDefault();const ne=Cc(L,i);I(ne)&&A("")}function ve(){const h=B.trim();h&&ee(h)&&A("")}const re=j?"var(--danger)":H?"var(--primary)":"var(--border)",G=c!==void 0&&C.length>=c;return e.jsxs("div",{className:`flex flex-col gap-2 ${l}`,children:[(m||y)&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[m&&e.jsx("span",{children:m}),y&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"})]}),e.jsxs("div",{ref:O,onClick:ae,onFocus:()=>_(!0),onBlur:h=>{var L;(L=O.current)!=null&&L.contains(h.relatedTarget)||(_(!1),z!==null&&x(z,k),z===null&&ve())},style:{borderColor:re},className:`
31
30
  flex min-h-10 flex-wrap items-center gap-1.5 rounded-lg border
32
31
  bg-[var(--bg-input)] px-2.5 py-2 transition-colors
33
32
  ${s?"cursor-not-allowed opacity-60":"cursor-text"}
34
- ${X?"animate-[tag-shake_0.4s_ease]":""}
33
+ ${Y?"animate-[tag-shake_0.4s_ease]":""}
35
34
  `,children:[e.jsx("style",{children:`
36
35
  @keyframes tag-shake {
37
36
  0%,100% { transform: translateX(0); }
@@ -40,4 +39,4 @@ ${F}`,G=new Blob(["\uFEFF"+x],{type:"text/csv;charset=utf-8;"}),le=URL.createObj
40
39
  60% { transform: translateX(-3px); }
41
40
  80% { transform: translateX(3px); }
42
41
  }
43
- `}),C.map(h=>{const D=mc(h.colorIndex);return W===h.id?e.jsx("input",{ref:U,value:S,disabled:s,onChange:V=>q(V.target.value),onKeyDown:V=>ee(V,h.id),onBlur:()=>$(h.id,S),className:"min-w-[4rem] rounded border border-[var(--primary)] bg-transparent px-1 py-0.5 text-sm text-[var(--text-main)] outline-none",style:{width:`${Math.max(S.length+2,6)}ch`}},h.id):e.jsxs("span",{className:"inline-flex max-w-[240px] items-center gap-1 rounded-md px-2 py-0.5 text-xs font-medium",style:{backgroundColor:D.bg,color:D.text,border:`1px solid ${D.border}`},children:[e.jsx("span",{className:"truncate",children:h.value}),e.jsx("button",{type:"button","aria-label":`Editar "${h.value}"`,disabled:s,tabIndex:-1,onClick:V=>{V.stopPropagation(),O(h)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:e.jsx(A.HiPencil,{className:"h-3 w-3"})}),e.jsx("button",{type:"button","aria-label":`Eliminar "${h.value}"`,disabled:s,tabIndex:-1,onClick:V=>{V.stopPropagation(),ne(h.id)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:e.jsx(A.HiXMark,{className:"h-3.5 w-3.5"})})]},h.id)}),!J&&e.jsx("input",{ref:M,value:B,disabled:s,placeholder:C.length===0?n:"",onChange:h=>T(h.target.value),onKeyDown:re,onPaste:ie,className:"min-w-[8rem] flex-1 bg-transparent text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed"})]}),N?e.jsx("span",{className:"text-xs font-medium text-[var(--danger)]",children:m}):p?e.jsx("span",{className:"text-xs font-medium text-[var(--text-muted)]",children:p}):null]})}const yc={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function wc({checked:r,disabled:t,onCheckedChange:a,size:n="sm",className:s="",...l}){const i=yc[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 ${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(${c}px, -50%)`,background:r?"var(--primary-fg)":"var(--text-muted)"}})})}const No=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),Nc=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function kc(r){if(!(r instanceof HTMLElement)||r.dataset.overlayScroll==="false"||r.matches("[data-overlayscrollbars]")||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 ko(r){return r.classList.contains("sidebar-scroll")||r.classList.contains("showcase-nav-scroll")}function So(r){ko(r)&&r.querySelectorAll(".os-scrollbar-horizontal").forEach(t=>{t.style.display="none",t.style.height="0",t.style.pointerEvents="none"})}function Sc(r){const t=r.querySelector(Nc);return t instanceof HTMLElement?t:null}function Co(){return o.useEffect(()=>{const r=new WeakMap;let t=0;const a=()=>{t=0,document.querySelectorAll(No).forEach(l=>{if(!(l instanceof HTMLElement))return;if($a.OverlayScrollbars(l)){So(l);return}if(!kc(l))return;const c={overflow:ko(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},u=Sc(l),f=u?$a.OverlayScrollbars({target:l,elements:{viewport:u}},c):$a.OverlayScrollbars(l,c);So(l),r.set(l,f)})},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(No).forEach(l=>{var i;l instanceof HTMLElement&&((i=r.get(l))==null||i.destroy())})}},[]),null}function gr(r){const t=r.trim();return!t||t==="/"||t==="/."?"":(t.startsWith("/")?t:`/${t}`).replace(/\/+$/,"")}function Eo(r){try{const t=new URL(r);return gr(t.pathname)}catch{return""}}function Cc(r){const t=gr(r);if(!t)return"";const a=t.match(/^\/apps\/[^/]+/i);if(a)return gr(a[0]);const n=t.split("/").filter(Boolean);return n.length===0?"":n.length>=2&&n[0].toLowerCase()==="apps"?gr(`/${n[0]}/${n[1]}`):new Set(["admin","apps","apps-list","tickets","my-tickets","projects","projects-calendars","dashboard","teams","clients","services","settings","profile","messages","notifications","my-access","my-registers","my-pings","security-incidents","email-inbox","webhook-config","webphone-config","vobo","auth","api","login","forbidden","unauthorized","change-password","reset-password","chat-widget"]).has(n[0].toLowerCase())?"":gr(`/${n[0]}`)}const Ra="primeSuiteAppUrl",Ec={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"}},Mo={xs:20,sm:28,md:36,lg:48,xl:64},Lo=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],Mc={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Lc="bonsaif.bot",$c="Bonsaif Bot",Tc={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function $o(r){return typeof r=="string"?r.trim():""}function Ac(r){var s;if(r!==void 0)return gr(r);const t=gr(typeof process<"u"&&((s=process.env)==null?void 0:s.NEXT_PUBLIC_BASE_PATH)||"");if(t)return t;if(typeof window>"u")return"";try{const i=new URLSearchParams(window.location.search).get(Ra)||"";i&&window.sessionStorage.setItem(Ra,i);const c=window.sessionStorage.getItem(Ra)||"",u=i||c;if(u){const f=Eo(u);if(f&&!/^\/admin(\/|$)/i.test(f))return f}}catch{}const a=window.__NEXT_DATA__,n=(a==null?void 0:a.assetPrefix)||"";if(n){const l=n.startsWith("http")?Eo(n):gr(n);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return Cc(window.location.pathname)}function Dc(r){const t=r.split(/\s+/).map(a=>a.trim()).filter(Boolean);return t.length===0?"?":t.length===1?t[0].slice(0,1).toUpperCase():`${t[0].slice(0,1)}${t[1].slice(0,1)}`.toUpperCase()}function Ic(r){let t=0;for(const a of r)t=t*31+a.charCodeAt(0)&65535;return Lo[t%Lo.length]}function Bc(r,t){return r===Lc||t===$c}function Oc(r,t){return`${r.replace(/\/$/,"")}${t}`}function To({userId:r,username:t,name:a,size:n="md",showName:s=!1,showTooltip:l,tooltipContent:i,fallbackLabel:c="Usuario",basePath:u,wrapperClassName:f="",labelClassName:b="",labelSize:p="xs",avatarVersion:m=0,className:w="",style:y}){const[k,v]=o.useState(!1),C=typeof r=="string"&&r.trim()&&r!=="undefined"&&r!=="null"?r.trim():"";o.useEffect(()=>{v(!1)},[C,m]);const{wh:B,text:T}=Ec[n],W=$o(a)||$o(t)||c,L=Dc(W),S=Ac(u),q=Bc(t,a),H=Oc(S,"/favicon.svg"),z=o.useMemo(()=>{if(!C)return"";const j=new URLSearchParams;j.set("size",String(Mo[n])),m&&j.set("v",String(m));const N=j.toString();return`${S}/api/user/avatar/${encodeURIComponent(C)}${N?`?${N}`:""}`},[m,S,C,n]),X=Mo[n],Z=q?e.jsx("span",{className:`${B} ${Tc[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 ${w}`,style:y,children:e.jsx("img",{src:H,alt:W,width:X,height:X,className:"h-full w-full object-contain"})}):z&&!k?e.jsx("img",{src:z,alt:W,width:X,height:X,className:`${B} rounded-full object-cover flex-shrink-0 ${w}`,style:y,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>v(!0)},`${C}-${m}`):e.jsx("span",{className:`${B} ${Ic(W)} ${T} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${w}`,style:y,title:W,children:L});if(s)return e.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${f}`,children:[Z,e.jsx("span",{className:`min-w-0 truncate ${Mc[p]} font-medium text-[var(--text-main)] ${b}`,title:W,children:W})]});const M=l??!0,U=i??W;return M&&U?e.jsx(_r,{as:"span",content:U,className:`inline-flex flex-shrink-0 ${f}`,children:Z}):Z}function Hc({href:r,className:t,children:a}){return e.jsx("a",{href:r,className:t,children:a})}function Pc(r){return r.reduce((t,a)=>{const n=a.section??"Principal";return t[n]=[...t[n]??[],a],t},{})}function Ao({children:r,navItems:t=[],currentPath:a=typeof window>"u"?"/":window.location.pathname,user:n,appName:s="Bonsaif",appLogo:l,header:i,footer:c,onLogout:u,LinkComponent:f=Hc}){const[b,p]=o.useState(!1),m=Pc(t);return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[e.jsx(Co,{}),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:()=>p(!0),children:e.jsx(A.HiBars3,{className:"h-5 w-5"})}),b&&e.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>p(!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 ${b?"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(A.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:()=>p(!1),children:e.jsx(A.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:e.jsx("div",{className:"sidebar-scroll-body",children:Object.entries(m).map(([w,y])=>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(A.HiChevronDown,{className:"h-3.5 w-3.5"}),w]}),e.jsx("div",{className:"space-y-1",children:y.map(k=>{const v=a===k.href||a.startsWith(`${k.href}/`);return e.jsxs(f,{href:k.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${v?"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:k.icon??e.jsx(A.HiHome,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate",children:k.label})]},k.href)})})]},w))})}),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(To,{name:n.initials??n.name??n.email??"Usuario",size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-medium text-white",children:n.name??"Usuario"}),n.email&&e.jsx("div",{className:"truncate text-xs text-white/45",children:n.email})]})]}),u&&e.jsxs(Pe,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:u,children:[e.jsx(A.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 Do="bonsaif-ui:prime-auth-sso",Fc={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"},en={dashboard:e.jsx(A.HiChartBar,{className:"h-5 w-5"}),tickets:e.jsx(A.HiTicket,{className:"h-5 w-5"}),teams:e.jsx(A.HiUsers,{className:"h-5 w-5"}),projects:e.jsx(A.HiRectangleGroup,{className:"h-5 w-5"}),clients:e.jsx(A.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:e.jsx(A.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:e.jsx(A.HiUser,{className:"h-5 w-5"}),settings:e.jsx(A.HiCog6Tooth,{className:"h-5 w-5"}),notifications:e.jsx(A.HiBell,{className:"h-5 w-5"}),changelog:e.jsx(A.HiDocumentText,{className:"h-5 w-5"}),admin:e.jsx(A.HiShieldCheck,{className:"h-5 w-5"}),users:e.jsx(A.HiUsers,{className:"h-5 w-5"}),roles:e.jsx(A.HiShieldCheck,{className:"h-5 w-5"}),menus:e.jsx(A.HiCog6Tooth,{className:"h-5 w-5"}),guards:e.jsx(A.HiCalendarDays,{className:"h-5 w-5"}),vacations:e.jsx(A.HiCalendarDays,{className:"h-5 w-5"}),audit:e.jsx(A.HiListBullet,{className:"h-5 w-5"}),positions:e.jsx(A.HiBriefcase,{className:"h-5 w-5"}),ranks:e.jsx(A.HiListBullet,{className:"h-5 w-5"}),"email-inbox":e.jsx(A.HiInbox,{className:"h-5 w-5"}),"security-incidents":e.jsx(A.HiShieldCheck,{className:"h-5 w-5"})};function zc(r){return r.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function _c(r){return/^\d+$/.test(r)||/^[a-f0-9]{8,}$/i.test(r)}function jc(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=_c(a)&&n?n:a,l=Fc[s]??zc(s);return[{label:"Inicio",href:"/"},{label:l}]}function rn(r){return(r==null?void 0:r.querySelector(":scope > .os-viewport"))??(r==null?void 0:r.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function Wc(r){const t=r.split("/").filter(Boolean),a=t[t.length-1];if(!a)return e.jsx(A.HiHome,{className:"h-5 w-5"});if(en[a])return en[a];const n=t.length>1?t[t.length-2]:"";return en[n]??e.jsx(A.HiHome,{className:"h-5 w-5"})}function qc(r){return r.includes("primeAuthOrigin")||r.includes("primeAuthProjectKey")}function Io(){if(typeof window>"u")return!1;if(qc(window.location.href)){try{window.sessionStorage.setItem(Do,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Do)==="true"}catch{return!1}}function Uc({title:r,subtitle:t,action:a,meta:n,icon:s,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:u,showBreadcrumbs:f=!0,contained:b=!1}){const p=o.useRef(null),[m,w]=o.useState(!1),[y,k]=o.useState(u??"/"),[v,C]=o.useState(()=>Io()),[B,T]=o.useState(null),W=u??y,L=c??jc(W),S=s??Wc(W),q=f&&!v&&L.length>1,H=!q;o.useEffect(()=>{u||k(window.location.pathname)},[u]),o.useEffect(()=>{C(Io())},[]),o.useEffect(()=>{if(b){w(!1);return}let X=null,Z=0,M=0;const U=()=>{const K=p.current,I=document.querySelector("[data-app-scroll='true']");return(K==null?void 0:K.closest(".os-viewport"))??(K==null?void 0:K.closest("[data-overlayscrollbars-viewport]"))??rn(I)??I??window},j=()=>{const K=X&&X!==window?X.scrollTop:window.scrollY;w(I=>I?K>24:K>72)},N=()=>{X==null||X.removeEventListener("scroll",j),X=U(),X.addEventListener("scroll",j,{passive:!0}),j()};return N(),Z=window.requestAnimationFrame(N),M=window.setTimeout(N,120),()=>{window.cancelAnimationFrame(Z),window.clearTimeout(M),X==null||X.removeEventListener("scroll",j)}},[b]),o.useEffect(()=>{if(b){T(null);return}let X=0;const Z=[],M=()=>{const R=p.current,ne=R==null?void 0:R.parentElement,$=document.querySelector("[data-app-scroll='true']"),O=rn($)??$;if(!R||!ne||!O){T(null);return}const re=ne.getBoundingClientRect(),ee=window.getComputedStyle(ne),oe=O.getBoundingClientRect(),ie=O instanceof HTMLElement&&O.clientWidth>0?O.clientWidth:oe.width,ve=re.left+parseFloat(ee.paddingLeft||"0"),te={marginLeft:Math.round(oe.left-ve),width:Math.round(ie)};T(J=>J&&J.marginLeft===te.marginLeft&&J.width===te.width?J:te)},U=()=>{window.cancelAnimationFrame(X),X=window.requestAnimationFrame(M)};U(),window.addEventListener("resize",U);const j=new ResizeObserver(U),N=p.current,K=N==null?void 0:N.parentElement,I=document.querySelector("[data-app-scroll='true']"),E=rn(I)??I;return[K,I,E].forEach(R=>{R&&j.observe(R)}),Z.push(window.setTimeout(U,120)),Z.push(window.setTimeout(U,280)),()=>{window.cancelAnimationFrame(X),window.removeEventListener("resize",U),j.disconnect(),Z.forEach(R=>window.clearTimeout(R))}},[b]);const z={...B?{marginLeft:B.marginLeft,width:B.width}:null,"--page-header-control-height":m?"34px":"40px","--page-header-control-padding-x":m?"10px":"14px","--page-header-control-icon-left":m?"10px":"12px",background:b?"var(--bg-card)":m?"color-mix(in srgb, var(--bg-main) 82%, transparent)":"color-mix(in srgb, var(--bg-main) 58%, transparent)",backdropFilter:"saturate(1.25) blur(18px)",WebkitBackdropFilter:"saturate(1.25) blur(18px)",borderBottom:b||m?"1px solid var(--border)":"1px solid transparent",boxShadow:m?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return e.jsx("div",{ref:p,"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 ${b?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${l}`,style:z,children:e.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${m?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":H?"min-h-9 gap-2 px-4 py-0 sm:min-h-10 sm:gap-2.5":"min-h-10 gap-2.5 px-4 pt-0.5 sm:min-h-11 sm:gap-3"} ${i}`,children:[e.jsx("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${m||H?"gap-1":"gap-1.5 sm:gap-2"}`,children:e.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${m||H?"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:q?"var(--text-secondary)":"var(--text-muted)"},children:S}),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-sm sm:text-base":"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 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 ${m?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:e.jsx(Cn.Provider,{value:{compact:!0,headerAction:!0},children:a})})]})})}function Vc({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(Ao,{currentPath:t,...n,children:r})}function Bo(){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 Gc(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 Kc({name:r,src:t,projectKey:a}){const[n,s]=o.useState("system"),l=o.useRef(null);o.useEffect(()=>{s(Bo());const u=new MutationObserver(()=>s(Bo()));return u.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>u.disconnect()},[]);const i=o.useMemo(()=>Gc(t,n,a),[a,t,n]),c=o.useMemo(()=>{try{return new URL(i).origin}catch{return""}},[i]);return o.useEffect(()=>{if(!a)return;const u=a;function f(b){var w,y,k;if(b.source!==((w=l.current)==null?void 0:w.contentWindow)||c&&b.origin!==c)return;if(((y=b.data)==null?void 0:y.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!b.data.active}}));return}if(((k=b.data)==null?void 0:k.type)!=="prime-microservice:navigation")return;const p=b.data.path;if(!p||!p.startsWith("/")||p.startsWith("//"))return;const m=`/apps/${encodeURIComponent(u)}${p}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==m&&(window.history.replaceState(window.history.state,"",m),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",f),()=>{window.removeEventListener("message",f),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 Xc(){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(c=>c.ok?c.json():null).then(c=>{!i&&(c!=null&&c.src)&&t(c.src)}).catch(()=>{}),()=>{i=!0}},[]),o.useEffect(()=>{const i=c=>{var f;if(((f=c.data)==null?void 0:f.type)!=="prime-suite-chat:state")return;const u=!!c.data.active;n(u),l({width:Oo(c.data.width,96,720),height:Oo(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(${s.width}px, 100vw)`:96,height:a?`min(${s.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function Oo(r,t,a){const n=typeof r=="number"&&Number.isFinite(r)?r:t;return Math.max(t,Math.min(a,Math.ceil(n)))}function Yc(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 Zc(){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 Qc(){return"light"}function Jc({position:r="bottom-center"}){const t=o.useSyncExternalStore(Yc,Zc,Qc);return e.jsx(wn.Toaster,{position:r,theme:t,richColors:!0,closeButton:!0})}function Rc({title:r,subtitle:t,actions:a,loading:n=!1,empty:s=!1,emptyText:l="Sin datos para mostrar",className:i="",children:c}){return e.jsxs("div",{className:`bonsaif-chart-card w-full overflow-visible ${i}`,children:[(r||t||a)&&e.jsxs("div",{className:"bonsaif-chart-card-head",children:[e.jsx("div",{className:"bonsaif-chart-card-accent","aria-hidden":!0}),e.jsxs("div",{className:"bonsaif-chart-card-copy min-w-0",children:[r?e.jsx("div",{className:"bonsaif-chart-card-title",children:r}):null,t?e.jsx("div",{className:"bonsaif-chart-card-subtitle",children:t}):null]}),a?e.jsx("div",{className:"bonsaif-chart-card-actions shrink-0",children:a}):null]}),e.jsx("div",{className:"bonsaif-chart-card-body",children:n?e.jsx("div",{className:"flex h-48 items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-t-transparent",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"},"aria-label":"Cargando"})}):s?e.jsx("div",{className:"flex h-48 items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:l}):c})]})}const Qt=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function Ho(r,t){return r.color??Qt[t%Qt.length]}function ar(r="primary"){switch(r){case"success":return"#34d399";case"warning":return"#fbbf24";case"danger":return"#f87171";case"neutral":return"var(--text-muted)";default:return"var(--primary)"}}const Qe=r=>{if(!Number.isFinite(r))return"—";const t=Math.abs(r);return t>=1e9?`${(r/1e9).toFixed(1).replace(/\.0$/,"")}B`:t>=1e6?`${(r/1e6).toFixed(1).replace(/\.0$/,"")}M`:t>=1e4?`${(r/1e3).toFixed(1).replace(/\.0$/,"")}k`:r.toLocaleString(void 0,{maximumFractionDigits:2})};function xt(r){if(r==null||r==="")return null;const t=typeof r=="number"?r:Number(r);return Number.isFinite(t)?t:null}const tn={warning:70,danger:90};function Jt(r,t=tn){const a=t.warning??tn.warning,n=t.danger??tn.danger;return r>=n?"danger":r>=a?"warning":r<=0?"primary":"success"}function yt(r,t){return ar(Jt(r,t))}function qr(r,t=0){return Number.isFinite(r)?`${r.toFixed(t)}%`:"—"}function Ur(r,t=1){if(!Number.isFinite(r))return"—";const a=r<0?"-":"",n=Math.abs(r);if(n<1024)return`${a}${Math.round(n)} B`;const s=["KB","MB","GB","TB","PB"];let l=n/1024,i=0;for(;l>=1024&&i<s.length-1;)l/=1024,i+=1;const c=l>=100?l.toFixed(0):l.toFixed(t);return`${a}${c.replace(/\.0$/,"")} ${s[i]}`}function Po(r,t="bytes",a=1){if(!Number.isFinite(r))return"—";const n=r<0?"-":"",s=Math.abs(r),l=t==="bits"?["b/s","Kb/s","Mb/s","Gb/s","Tb/s"]:["B/s","KB/s","MB/s","GB/s","TB/s"];if(s<1024)return`${n}${Math.round(s)} ${l[0]}`;let i=s/1024,c=1;for(;i>=1024&&c<l.length-1;)i/=1024,c+=1;const u=i>=100?i.toFixed(0):i.toFixed(a);return`${n}${u.replace(/\.0$/,"")} ${l[c]}`}function Vr(r,t){var a;for(let n=r.length-1;n>=0;n-=1){const s=xt((a=r[n])==null?void 0:a[t]);if(s!==null)return s}return null}function Je({height:r}){return e.jsx("div",{className:"flex items-center justify-center",style:{height:r},"aria-busy":!0,children:e.jsx("div",{className:"h-7 w-7 animate-spin rounded-full border-2",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"}})})}function Re({height:r,text:t}){return e.jsx("div",{className:"flex items-center justify-center text-sm",style:{height:r,color:"var(--text-muted)"},children:t})}const Er=680,Mr="ease-out",ed={top:18,right:8,bottom:12,left:0};function wt(r){return{...ed,...r}}function Nt(r){return r.map((t,a)=>({...t,color:Ho(t,a),label:t.label??t.key}))}function Rt(r,t){return!r.length||!t.length||r.every(a=>t.every(n=>xt(a[n.key])===null))}function Ke(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function kt(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function Fo(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function ea(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function rd(r,t=Qe){if(r==null||r==="")return"—";const a=typeof r=="number"?r:Number(r);return Number.isFinite(a)?t(a):String(r)}function zo(r){return`bonsaif-grad-${r.replace(/[^a-zA-Z0-9_-]/g,"")}`}function td({active:r,label:t,payload:a,valueFormat:n=Qe}){var c,u,f,b,p,m;if(!r||!(a!=null&&a.length))return null;const s=a.filter(w=>w.dataKey!=="base"&&w.name!=="base"&&w.value!==null&&w.value!==void 0);if(!s.length)return null;const l=((u=(c=s[0])==null?void 0:c.payload)==null?void 0:u.fullName)??((b=(f=s[0])==null?void 0:f.payload)==null?void 0:b.tooltipLabel)??((m=(p=s[0])==null?void 0:p.payload)==null?void 0:m.display),i=typeof l=="string"&&l.length>0?l:t;return e.jsxs("div",{className:"bonsaif-chart-tooltip-panel",children:[i!=null&&i!==""?e.jsx("div",{className:"bonsaif-chart-tooltip-label",children:String(i)}):null,e.jsx("div",{className:"bonsaif-chart-tooltip-items",children:s.map((w,y)=>{const k=w.payload,v=k&&typeof k.display=="number"?k.display:w.value;return e.jsxs("div",{className:"bonsaif-chart-tooltip-row",children:[e.jsxs("span",{className:"bonsaif-chart-tooltip-name",children:[e.jsx("span",{className:"bonsaif-chart-tooltip-swatch",style:{background:w.color??"var(--primary)"}}),w.name??w.dataKey]}),e.jsx("span",{className:"bonsaif-chart-tooltip-value",children:rd(v,n)})]},String(w.dataKey??w.name??y))})})]})}function Gr({valueFormat:r,content:t,cursor:a,offset:n=12,wrapperStyle:s,allowEscapeViewBox:l,reverseDirection:i,...c}){return e.jsx(me.Tooltip,{...c,cursor:a,offset:n,allowEscapeViewBox:l??{x:!1,y:!1},reverseDirection:i??{x:!1,y:!1},wrapperStyle:{outline:"none",zIndex:60,pointerEvents:"none",overflow:"visible",...s},content:t??e.jsx(td,{valueFormat:r})})}function _o(r,t,a){return a==null?-1:r.findIndex(n=>String(n[t])===String(a))}function jo(r,t,a){if(a<=1)return null;const n=Math.max(0,Math.min(r,t)),s=Math.min(a-1,Math.max(r,t));return s-n<1||n===0&&s>=a-1?null:{startIndex:n,endIndex:s}}function ra(r,t,a={}){const{zoomable:n=!1,zoomMode:s="both",brushHeight:l=28,onZoomChange:i}=a,[c,u]=o.useState(null),[f,b]=o.useState(null),p=!!n&&r.length>1,m=p&&(s==="brush"||s==="both"),w=p&&(s==="drag"||s==="both"),y=o.useCallback(Z=>{u(Z),i==null||i(Z)},[i]),k=o.useCallback(()=>{b(null),y(null)},[y]),v=!!c,C=o.useMemo(()=>!c||m?r:r.slice(c.startIndex,c.endIndex+1),[r,m,c]),B=o.useCallback((Z,M)=>{const U=_o(r,t,Z),j=_o(r,t,M);U<0||j<0||y(jo(U,j,r.length))},[y,r,t]),T=o.useCallback(Z=>{w&&((Z==null?void 0:Z.activeLabel)===void 0||(Z==null?void 0:Z.activeLabel)===null||b({leftLabel:Z.activeLabel,rightLabel:Z.activeLabel}))},[w]),W=o.useCallback(Z=>{!w||!f||(Z==null?void 0:Z.activeLabel)===void 0||(Z==null?void 0:Z.activeLabel)===null||b(M=>M&&{...M,rightLabel:Z.activeLabel})},[f,w]),L=o.useCallback(()=>{if(w){if(!f||f.rightLabel===null||f.rightLabel===void 0){b(null);return}B(f.leftLabel,f.rightLabel),b(null)}},[B,f,w]),S=o.useCallback(Z=>{if(m){if(!Z){y(null);return}y(jo(Z.startIndex??0,Z.endIndex??r.length-1,r.length))}},[y,r.length,m]),q=w?{onMouseDown:T,onMouseMove:W,onMouseUp:L,onMouseLeave:()=>{f&&L()}}:{},H=c??{startIndex:0,endIndex:Math.max(0,r.length-1)},z=e.jsxs(e.Fragment,{children:[w&&f&&f.rightLabel!==null&&f.rightLabel!==void 0?e.jsx(me.ReferenceArea,{x1:f.leftLabel,x2:f.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,m?e.jsx(me.Brush,{dataKey:t,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:H.startIndex,endIndex:H.endIndex,onChange:S,tickFormatter:Z=>String(Z)}):null]}),X=m?{bottom:Math.max(l+10,36)}:void 0;return{enabled:p,showBrush:m,showDrag:w,viewData:C,isZoomed:v,resetZoom:k,chartHandlers:q,zoomNodes:z,marginExtra:X}}function ta({visible:r,onReset:t}){return r?e.jsx("button",{type:"button",className:"bonsaif-chart-zoom-reset",onClick:t,"aria-label":"Restablecer zoom",children:"Restablecer zoom"}):null}function ad({data:r,xKey:t,series:a,height:n=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:u=!0,showTooltip:f=!0,margin:b,valueFormat:p=Qe,yDomain:m,ariaLabel:w="Gráfico de líneas",curve:y=!0,strokeWidth:k=2.25,zoomable:v=!1,zoomMode:C="both",brushHeight:B,onZoomChange:T}){const W=Rt(r,a),L=Nt(a),S=ra(r,t,{zoomable:v,zoomMode:C,brushHeight:B,onZoomChange:T}),q=wt({...b,...S.marginExtra});return l?e.jsx(Je,{height:n}):W?e.jsx(Re,{height:n,text:i}):e.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${s}`,role:"img","aria-label":w,style:{height:n},children:[e.jsx(ta,{visible:S.isZoomed,onReset:S.resetZoom}),e.jsx(me.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(me.LineChart,{data:S.viewData,margin:q,...S.chartHandlers,children:[c?e.jsx(me.CartesianGrid,{strokeDasharray:"2 8",stroke:kt(),vertical:!1}):null,e.jsx(me.XAxis,{dataKey:t,tick:Ke(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),e.jsx(me.YAxis,{tick:Ke(),tickLine:!1,axisLine:!1,width:44,domain:m??["auto","auto"],tickFormatter:H=>p(Number(H)),dx:-2}),f?e.jsx(Gr,{valueFormat:p,cursor:{stroke:Fo(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,u?e.jsx(me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ea()}):null,L.map((H,z)=>e.jsx(me.Line,{type:y?"monotone":"linear",dataKey:H.key,name:H.label,stroke:H.color,strokeWidth:z===0?k+.35:k,strokeOpacity:z===0?1:.88,isAnimationActive:!0,animationDuration:Er,animationEasing:Mr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:H.color}},H.key)),S.zoomNodes]})})]})}function aa({data:r,xKey:t,series:a,height:n=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:u=!0,showTooltip:f=!0,margin:b,valueFormat:p=Qe,yDomain:m,ariaLabel:w="Gráfico de área",stacked:y=!1,opacity:k=.22,zoomable:v=!1,zoomMode:C="both",brushHeight:B,onZoomChange:T}){const W=Rt(r,a),L=Nt(a),S=ra(r,t,{zoomable:v,zoomMode:C,brushHeight:B,onZoomChange:T}),q=wt({...b,...S.marginExtra});return l?e.jsx(Je,{height:n}):W?e.jsx(Re,{height:n,text:i}):e.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${s}`,role:"img","aria-label":w,style:{height:n},children:[e.jsx(ta,{visible:S.isZoomed,onReset:S.resetZoom}),e.jsx(me.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(me.AreaChart,{data:S.viewData,margin:q,...S.chartHandlers,children:[e.jsx("defs",{children:L.map(H=>e.jsxs("linearGradient",{id:zo(H.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:H.color,stopOpacity:Math.min(.55,k+.28)}),e.jsx("stop",{offset:"48%",stopColor:H.color,stopOpacity:k*.5}),e.jsx("stop",{offset:"100%",stopColor:H.color,stopOpacity:0})]},H.key))}),c?e.jsx(me.CartesianGrid,{strokeDasharray:"2 8",stroke:kt(),vertical:!1}):null,e.jsx(me.XAxis,{dataKey:t,tick:Ke(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),e.jsx(me.YAxis,{tick:Ke(),tickLine:!1,axisLine:!1,width:44,domain:m??["auto","auto"],tickFormatter:H=>p(Number(H)),dx:-2}),f?e.jsx(Gr,{valueFormat:p,cursor:{stroke:Fo(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,u?e.jsx(me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ea()}):null,L.map(H=>e.jsx(me.Area,{type:"monotone",dataKey:H.key,name:H.label,stroke:H.color,fill:`url(#${zo(H.key)})`,strokeWidth:2.25,stackId:y?"stack":void 0,isAnimationActive:!0,animationDuration:Er,animationEasing:Mr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:H.color}},H.key)),S.zoomNodes]})})]})}function nd({data:r,xKey:t,series:a,height:n=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:u=!0,showTooltip:f=!0,margin:b,valueFormat:p=Qe,yDomain:m,ariaLabel:w="Gráfico de barras",layout:y="vertical",mode:k="grouped",barRadius:v=6,categoryAxisWidth:C=64,zoomable:B=!1,zoomMode:T="both",brushHeight:W,onZoomChange:L}){const S=Rt(r,a),q=Nt(a),H=y==="horizontal",z=ra(r,t,{zoomable:B&&!H,zoomMode:T,brushHeight:W,onZoomChange:L}),X=wt({...b,...z.marginExtra});return l?e.jsx(Je,{height:n}):S?e.jsx(Re,{height:n,text:i}):e.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${s}`,role:"img","aria-label":w,style:{height:n},children:[e.jsx(ta,{visible:z.isZoomed,onReset:z.resetZoom}),e.jsx(me.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(me.BarChart,{data:z.viewData,margin:X,layout:H?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,...z.chartHandlers,children:[c?e.jsx(me.CartesianGrid,{strokeDasharray:"2 8",stroke:kt(),horizontal:!H,vertical:H}):null,H?e.jsxs(e.Fragment,{children:[e.jsx(me.XAxis,{type:"number",tick:Ke(),tickLine:!1,axisLine:!1,tickFormatter:Z=>p(Number(Z)),domain:m??["auto","auto"]}),e.jsx(me.YAxis,{type:"category",dataKey:t,tick:Ke(),tickLine:!1,axisLine:!1,width:C})]}):e.jsxs(e.Fragment,{children:[e.jsx(me.XAxis,{dataKey:t,tick:Ke(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),e.jsx(me.YAxis,{tick:Ke(),tickLine:!1,axisLine:!1,width:44,domain:m??["auto","auto"],tickFormatter:Z=>p(Number(Z)),dx:-2})]}),f?e.jsx(Gr,{valueFormat:p,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,u?e.jsx(me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ea()}):null,q.map((Z,M)=>e.jsx(me.Bar,{dataKey:Z.key,name:Z.label,fill:Z.color,fillOpacity:M===0?1:.82,radius:H?[0,v,v,0]:[v,v,2,2],maxBarSize:20,stackId:k==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:Er,animationEasing:Mr},Z.key)),z.zoomNodes]})})]})}function od(r){return e.jsx(qo,{...r,variant:"pie"})}function sd(r){return e.jsx(qo,{...r,variant:"donut",innerRadius:r.innerRadius??.62,cornerRadius:r.cornerRadius??10,padAngle:r.padAngle??2})}function Wo(r,t){return r==null||!Number.isFinite(r)?t:r>0&&r<=1?r*100:r}function qo({data:r,nameKey:t,valueKey:a,height:n=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showLegend:c=!0,showTooltip:u=!0,valueFormat:f=Qe,ariaLabel:b,innerRadius:p,outerRadius:m,colors:w=[...Qt],padAngle:y,cornerRadius:k,variant:v}){const C=r.map((M,U)=>({name:String(M[t]??""),value:xt(M[a])??0,fill:w[U%w.length],row:M})).filter(M=>M.value>0),B=!C.length,T=v==="donut",W=C.length,L=Wo(p,T?62:12),S=Wo(m,78),q=Math.min(y??(T?2:3),Math.max(.5,10/Math.max(1,W))),H=Math.min(k??(T?10:8),Math.max(2,36/Math.max(1,W)));if(l)return e.jsx(Je,{height:n});if(B)return e.jsx(Re,{height:n,text:i});const z=C.reduce((M,U)=>M+U.value,0),X=c?Math.min(96,28+Math.ceil(W/3)*22):0,Z=Math.max(140,n-X);return e.jsx("div",{className:`bonsaif-chart bonsaif-${v}-chart w-full ${s}`,role:"img","aria-label":b??(v==="donut"?"Donut chart":"Pie chart"),style:{height:n},children:e.jsxs("div",{className:"bonsaif-pie-layout",children:[e.jsx("div",{className:"bonsaif-pie-plot",style:{height:Z},children:e.jsx(me.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(me.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[u?e.jsx(Gr,{valueFormat:f,isAnimationActive:!1}):null,e.jsx(me.Pie,{data:C,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${L}%`,outerRadius:`${S}%`,startAngle:90,endAngle:-270,paddingAngle:q,cornerRadius:H,minAngle:W>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:Er,animationEasing:Mr,label:!1,activeShape:ld,children:C.map(M=>e.jsx(me.Cell,{fill:M.fill},M.name))}),T?e.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:f(z)}):null]})})}),c?e.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:C.map(M=>e.jsxs("li",{className:"bonsaif-pie-legend-item",children:[e.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:M.fill},"aria-hidden":!0}),e.jsx("span",{className:"bonsaif-pie-legend-label",title:M.name,children:M.name}),e.jsx("span",{className:"bonsaif-pie-legend-value",children:f(M.value)})]},M.name))}):null]})})}function ld(r){const{outerRadius:t=0,...a}=r;return e.jsx(me.Sector,{...a,outerRadius:Number(t)+4,stroke:"var(--bg-card)",strokeWidth:2})}function id({data:r,dataKey:t,width:a="100%",height:n=36,tone:s="primary",color:l,fill:i=!0,className:c="",ariaLabel:u="Sparkline"}){const f=l??ar(s),b=r.map(S=>xt(S[t])).filter(S=>S!==null);if(b.length<2)return e.jsx("div",{className:c,style:{width:a,height:n,color:"var(--text-muted)"},"aria-label":u});const p=120,m=36,w=3,y=1,k=Math.min(...b),C=Math.max(...b)-k||1,B=b.map((S,q)=>{const H=y+q/(b.length-1)*(p-y*2),z=m-w-(S-k)/C*(m-w*2);return{x:H,y:z}}),T=B.map((S,q)=>`${q===0?"M":"L"}${S.x.toFixed(2)} ${S.y.toFixed(2)}`).join(" "),W=`${T} L${B[B.length-1].x.toFixed(2)} ${m} L${B[0].x.toFixed(2)} ${m} Z`,L=`bonsaif-spark-${t.replace(/[^a-zA-Z0-9_-]/g,"")}-${s}`;return e.jsx("div",{className:`bonsaif-sparkline ${c}`,style:{width:a,height:n},role:"img","aria-label":u,children:e.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${p} ${m}`,preserveAspectRatio:"none",focusable:"false",children:[i?e.jsx("defs",{children:e.jsxs("linearGradient",{id:L,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:f,stopOpacity:.38}),e.jsx("stop",{offset:"100%",stopColor:f,stopOpacity:0})]})}):null,i?e.jsx("path",{d:W,fill:`url(#${L})`}):null,e.jsx("path",{d:T,fill:"none",stroke:f,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function cd({data:r,xKey:t,series:a,barSeries:n,lineSeries:s,height:l=280,className:i="",loading:c=!1,emptyText:u="Sin datos para mostrar",showGrid:f=!0,showLegend:b=!0,showTooltip:p=!0,margin:m,valueFormat:w=Qe,yDomain:y,ariaLabel:k="Gráfico combinado",barRadius:v=6,zoomable:C=!1,zoomMode:B="both",brushHeight:T,onZoomChange:W}){const L=n??a.slice(0,Math.max(1,a.length-1)),S=s??(a.length>1?a.slice(-1):a.length?[a[0]]:[]),q=[...L,...S.filter(j=>!L.some(N=>N.key===j.key))],H=Rt(r,q),z=Nt(L),X=Nt(q),Z=S.map(j=>{var K;const N=X.find(I=>I.key===j.key);return{...j,label:j.label??j.key,color:j.color??(N==null?void 0:N.color)??((K=X[0])==null?void 0:K.color)}}),M=ra(r,t,{zoomable:C,zoomMode:B,brushHeight:T,onZoomChange:W}),U=wt({...m,...M.marginExtra});return c?e.jsx(Je,{height:l}):H?e.jsx(Re,{height:l,text:u}):e.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":k,style:{height:l},children:[e.jsx(ta,{visible:M.isZoomed,onReset:M.resetZoom}),e.jsx(me.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(me.ComposedChart,{data:M.viewData,margin:U,barCategoryGap:"34%",...M.chartHandlers,children:[f?e.jsx(me.CartesianGrid,{strokeDasharray:"2 8",stroke:kt(),vertical:!1}):null,e.jsx(me.XAxis,{dataKey:t,tick:Ke(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),e.jsx(me.YAxis,{tick:Ke(),tickLine:!1,axisLine:!1,width:44,domain:y??["auto","auto"],tickFormatter:j=>w(Number(j)),dx:-2}),p?e.jsx(Gr,{valueFormat:w,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,b?e.jsx(me.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ea()}):null,z.map(j=>e.jsx(me.Bar,{dataKey:j.key,name:j.label,fill:j.color,fillOpacity:.88,radius:[v,v,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:Er,animationEasing:Mr},j.key)),Z.map(j=>e.jsx(me.Line,{type:"monotone",dataKey:j.key,name:j.label,stroke:j.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:Er,animationEasing:Mr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:j.color}},j.key)),M.zoomNodes]})})]})}function dd({data:r,xKey:t,valueKey:a,typeKey:n,height:s=280,className:l="",loading:i=!1,emptyText:c="Sin datos para mostrar",showGrid:u=!0,showTooltip:f=!0,margin:b,valueFormat:p=Qe,ariaLabel:m="Gráfico waterfall",increaseColor:w="#34d399",decreaseColor:y="#f87171",totalColor:k="var(--primary)"}){const v=o.useMemo(()=>ud(r,{xKey:t,valueKey:a,typeKey:n,increaseColor:w,decreaseColor:y,totalColor:k}),[r,t,a,n,w,y,k]),C=!v.length,B=wt(b);return i?e.jsx(Je,{height:s}):C?e.jsx(Re,{height:s,text:c}):e.jsx("div",{className:`bonsaif-chart bonsaif-waterfall-chart w-full ${l}`,role:"img","aria-label":m,style:{height:s},children:e.jsx(me.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(me.BarChart,{data:v,margin:B,barCategoryGap:"42%",children:[u?e.jsx(me.CartesianGrid,{strokeDasharray:"2 8",stroke:kt(),vertical:!1}):null,e.jsx(me.XAxis,{dataKey:"label",tick:Ke(),tickLine:!1,axisLine:!1,interval:0,dy:6}),e.jsx(me.YAxis,{tick:Ke(),tickLine:!1,axisLine:!1,width:44,tickFormatter:T=>p(Number(T)),dx:-2}),f?e.jsx(Gr,{valueFormat:p,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,e.jsx(me.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),e.jsx(me.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:Er,animationEasing:Mr,children:v.map(T=>e.jsx(me.Cell,{fill:T.color},T.label))})]})})})}function ud(r,t){let a=0;return r.map((n,s)=>{const l=xt(n[t.valueKey])??0,i=t.typeKey?String(n[t.typeKey]??""):"",c=i==="total"||s===r.length-1&&i!=="increase"&&i!=="decrease";let u="increase",f=0,b=0,p=l;return c&&i==="total"?(u="total",f=0,b=Math.abs(l),p=l,a=l):c&&s===r.length-1&&!i?(u="total",f=0,b=Math.abs(a),p=a):(u=i==="decrease"||l<0?"decrease":"increase",u==="decrease"?(f=a+l,b=Math.abs(l),a=a+l):(f=a,b=Math.abs(l),a=a+l),p=l),{label:String(n[t.xKey]??""),base:f,delta:b,display:p,kind:u,color:u==="total"?t.totalColor:u==="decrease"?t.decreaseColor:t.increaseColor}})}const Kr=135*Math.PI/180,an=270*Math.PI/180;function fd({value:r,min:t=0,max:a=100,height:n=180,className:s="",loading:l=!1,empty:i=!1,emptyText:c="Sin datos para mostrar",label:u,valueFormat:f=Qe,tone:b="primary",color:p,thresholds:m,ariaLabel:w="Gauge",animationDuration:y=700,thickness:k=9,showScale:v=!1}){const C=o.useId().replace(/:/g,""),B=a-t||1,T=Math.min(1,Math.max(0,(r-t)/B)),[W,L]=o.useState(y>0?0:T);if(o.useEffect(()=>{if(l||i)return;if(y<=0){L(T);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){L(T);return}let I=0,E=0;L($=>(E=$,$));const R=performance.now(),ne=$=>{const O=Math.min(1,($-R)/y),re=1-(1-O)**3;L(E+(T-E)*re),O<1&&(I=requestAnimationFrame(ne))};return I=requestAnimationFrame(ne),()=>cancelAnimationFrame(I)},[T,y,l,i]),l)return e.jsx(Je,{height:n});if(i)return e.jsx(Re,{height:n,text:c});const S=100,q=108,H=72,z=p??bd(r,a,b,m),X=t+W*B,Z=Uo(S,q,H,Kr,Kr+an),M=Kr+Math.max(.001,W)*an,U=Uo(S,q,H,Kr,M),j=na(S,q,H,Kr),N=na(S,q,H,Kr+an);return e.jsx("div",{className:`bonsaif-chart bonsaif-gauge-chart flex flex-col items-center justify-center ${s}`,style:{height:n},children:e.jsxs("svg",{viewBox:"0 0 200 168",width:"100%",height:"100%",role:"img","aria-label":w,className:"overflow-visible",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:`bonsaif-gauge-${C}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[e.jsx("stop",{offset:"0%",stopColor:z,stopOpacity:.82}),e.jsx("stop",{offset:"100%",stopColor:z,stopOpacity:1})]})}),e.jsx("path",{d:Z,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:k,strokeLinecap:"butt"}),e.jsx("path",{d:U,fill:"none",stroke:`url(#bonsaif-gauge-${C})`,strokeWidth:k,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),e.jsx("text",{x:S,y:q-(u?4:0),textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:28,fontWeight:700,letterSpacing:"-0.04em",className:"bonsaif-chart-gauge-label",children:f(X)}),u?e.jsx("text",{x:S,y:q+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:u}):null,v?e.jsxs(e.Fragment,{children:[e.jsx("text",{x:j.x-2,y:j.y+k+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:f(t)}),e.jsx("text",{x:N.x+2,y:N.y+k+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:f(a)})]}):null]})})}function bd(r,t,a,n){if(n!=null&&n.length){const l=[...n].sort((c,u)=>c.value-u.value);let i=l[0].color;for(const c of l)r>=c.value&&(i=c.color);return i}if(a)return ar(a);const s=r/(t||1);return s>=.8?ar("success"):s>=.5?ar("warning"):ar("danger")}function na(r,t,a,n){return{x:r+a*Math.cos(n),y:t+a*Math.sin(n)}}function Uo(r,t,a,n,s){const l=na(r,t,a,n),i=na(r,t,a,s),c=s-n,u=Math.abs(c)>Math.PI?1:0;return`M ${l.x} ${l.y} A ${a} ${a} 0 ${u} 1 ${i.x} ${i.y}`}function pd({value:r,target:t,max:a,ranges:n,height:s=72,className:l="",loading:i=!1,empty:c=!1,emptyText:u="Sin datos para mostrar",label:f,subtitle:b,valueFormat:p=Qe,tone:m="primary",showScale:w=!0,showStatus:y=!0,ariaLabel:k="Bullet chart"}){if(i)return e.jsx(Je,{height:s});if(c)return e.jsx(Re,{height:s,text:u});const v=a??Math.max(r,t,...(n==null?void 0:n.map(z=>z.value))??[],1)*1.05,B=[...n??[{value:v*.5,color:"color-mix(in srgb, var(--border) 72%, transparent)"},{value:v*.75,color:"color-mix(in srgb, var(--border) 48%, transparent)"},{value:v,color:"color-mix(in srgb, var(--border) 28%, transparent)"}]].sort((z,X)=>z.value-X.value),T=ar(m),W=Math.min(100,Math.max(0,r/v*100)),L=Math.min(100,Math.max(0,t/v*100)),S=r>=t,q=[0,.25,.5,.75,1].map(z=>z*v),H=e.jsxs("div",{className:"bonsaif-bullet-plot min-w-0 flex-1",children:[e.jsxs("div",{className:"bonsaif-bullet-track relative w-full",style:{height:Math.max(22,f?28:s*.42)},role:"img","aria-label":k,children:[e.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:B.map((z,X)=>{const Z=X===0?0:B[X-1].value,M=Math.max(0,(z.value-Z)/v*100);return e.jsx("div",{style:{width:`${M}%`,background:z.color??`color-mix(in srgb, var(--border) ${70-X*18}%, transparent)`}},X)})}),e.jsx("div",{className:"absolute left-0 top-1/2 w-full",style:{height:"34%",transform:"translateY(-50%)"},children:e.jsx("div",{className:"bonsaif-bullet-value h-full",style:{width:`${W}%`,background:T,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${T} 35%, transparent)`}})}),e.jsx("div",{className:"bonsaif-bullet-target absolute top-1/2 z-[1]",style:{left:`${L}%`,height:"72%",width:3,transform:"translate(-50%, -50%)",background:T,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${p(t)}`})]}),w?e.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:q.map((z,X)=>{const Z=z/v*100,M=X===0,U=X===q.length-1;return e.jsxs("div",{className:"absolute top-0",style:{left:`${Z}%`,transform:M?"none":U?"translateX(-100%)":"translateX(-50%)"},children:[e.jsx("div",{className:"mx-auto h-1.5 w-px",style:{background:"color-mix(in srgb, var(--text-muted) 55%, transparent)",marginLeft:M?0:U?"auto":void 0,marginRight:U?0:void 0}}),e.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:M?"left":U?"right":"center"},children:p(z)})]},z)})}):null]});return e.jsx("div",{className:`bonsaif-chart bonsaif-bullet-chart w-full ${l}`,children:f?e.jsxs("div",{className:"bonsaif-bullet-row flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-4",children:[e.jsxs("div",{className:"bonsaif-bullet-label shrink-0 sm:w-[7.5rem] sm:pt-1 sm:text-right",children:[e.jsx("div",{className:"text-sm font-semibold tracking-tight",style:{color:"var(--text-main)"},children:f}),b?e.jsx("div",{className:"mt-0.5 text-[11px] leading-snug",style:{color:"var(--text-muted)"},children:b}):e.jsxs("div",{className:"mt-0.5 text-[11px] tabular-nums leading-snug",style:{color:"var(--text-muted)"},children:[e.jsx("span",{style:{color:T,fontWeight:600},children:p(r)}),e.jsxs("span",{children:[" / meta ",p(t)]})]}),y?e.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:ar(S?"success":"warning")},children:S?"En meta":"Bajo meta"}):null]}),H]}):H})}function md({data:r,value:t,timeKey:a="t",usageKey:n="usage",series:s,cores:l,height:i=220,className:c="",loading:u=!1,emptyText:f="Sin datos de CPU",showLegend:b=!1,showTooltip:p=!0,thresholds:m,label:w="CPU",ariaLabel:y="Uso de CPU"}){var L;const k=s??[{key:n,label:"Uso",color:yt(t??Vr(r,n)??0,m)}],v=t??Vr(r,n)??Vr(r,((L=k[0])==null?void 0:L.key)??n),C=!u&&(!r.length||v===null);if(u)return e.jsx(Je,{height:i});if(C)return e.jsx(Re,{height:i,text:f});const B=Math.min(100,Math.max(0,v??0)),T=Jt(B,m),W=yt(B,m);return e.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":y,children:[e.jsxs("div",{className:"bonsaif-metric-head",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"bonsaif-metric-kicker",children:[w,l!=null?e.jsxs("span",{className:"ml-1.5 normal-case tracking-normal opacity-80",children:["· ",l," ",l===1?"core":"cores"]}):null]}),e.jsx("div",{className:"bonsaif-metric-value",style:{color:W},children:qr(B,B<10?1:0)})]}),e.jsx("div",{className:"bonsaif-metric-badge",style:{color:W,background:`color-mix(in srgb, ${W} 14%, transparent)`},children:T==="danger"?"Crítico":T==="warning"?"Alto":"Normal"})]}),e.jsx(aa,{data:r,xKey:a,series:k.map(S=>({...S,color:S.color??W})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:b,showTooltip:p,valueFormat:S=>qr(S,0),ariaLabel:y,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function hd({used:r,total:t,cached:a,data:n=[],timeKey:s="t",usageKey:l="usage",height:i=220,className:c="",loading:u=!1,emptyText:f="Sin datos de memoria",showHistory:b=!0,showTooltip:p=!0,thresholds:m,label:w="RAM",ariaLabel:y="Uso de memoria"}){const k=t>0?t:1,v=Math.min(100,Math.max(0,r/k*100)),C=!u&&!(Number.isFinite(r)&&Number.isFinite(t)&&t>0);if(u)return e.jsx(Je,{height:i});if(C)return e.jsx(Re,{height:i,text:f});const B=Jt(v,m),T=yt(v,m),W=Math.max(0,t-r),L=n.length>0?Vr(n,l)??v:v,S=yt(L,m),q=b&&n.length>1?Math.max(100,i-110):0;return e.jsxs("div",{className:`bonsaif-chart bonsaif-ram-chart w-full ${c}`,role:"group","aria-label":y,children:[e.jsxs("div",{className:"bonsaif-metric-head",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"bonsaif-metric-kicker",children:w}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"bonsaif-metric-value",style:{color:T},children:qr(v,v<10?1:0)}),e.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[Ur(r)," / ",Ur(t)]})]})]}),e.jsx("div",{className:"bonsaif-metric-badge",style:{color:T,background:`color-mix(in srgb, ${T} 14%, transparent)`},children:B==="danger"?"Crítico":B==="warning"?"Alto":"Normal"})]}),e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-sm",style:{background:"color-mix(in srgb, var(--border) 55%, transparent)"},role:"progressbar","aria-valuenow":Math.round(v),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${w} ${qr(v,0)}`,children:e.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${v}%`,background:`linear-gradient(90deg, ${T}, color-mix(in srgb, ${T} 55%, #38bdf8))`}})}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[11px] tabular-nums",style:{color:"var(--text-muted)"},children:[e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Usada"})," ",Ur(r)]}),a!=null&&Number.isFinite(a)?e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",Ur(a)]}):null,e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",Ur(W)]})]})]}),b&&n.length>1?e.jsx(aa,{data:n,xKey:s,series:[{key:l,label:"Uso",color:S}],height:q,yDomain:[0,100],showLegend:!1,showTooltip:p,valueFormat:H=>qr(H,0),ariaLabel:`${y} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const vd="color-mix(in srgb, var(--primary) 25%, #38bdf8)",gd="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function xd({data:r,timeKey:t="t",inboundKey:a="in",outboundKey:n="out",inbound:s,outbound:l,unit:i="bytes",inboundLabel:c="Entrada",outboundLabel:u="Salida",inboundColor:f=vd,outboundColor:b=gd,height:p=240,className:m="",loading:w=!1,emptyText:y="Sin datos de red",showLegend:k=!1,showTooltip:v=!0,label:C="Network",ariaLabel:B="Tráfico de red"}){const T=s??Vr(r,a)??0,W=l??Vr(r,n)??0,L=!w&&r.length===0;if(w)return e.jsx(Je,{height:p});if(L)return e.jsx(Re,{height:p,text:y});const S=z=>Po(z,i),H=Math.max(140,p-76);return e.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${m}`,role:"group","aria-label":B,children:[e.jsx("div",{className:"bonsaif-network-header relative z-10 mb-4 grid gap-3 border-b pb-3 sm:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]",style:{borderColor:"var(--border)"},children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"bonsaif-metric-kicker",children:C}),e.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-5 sm:max-w-lg",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[e.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:f},"aria-hidden":!0}),c]}),e.jsx("div",{className:"mt-1 truncate text-xl font-bold tabular-nums leading-tight tracking-tight",style:{color:f},title:S(T),children:S(T)})]}),e.jsxs("div",{className:"min-w-0 pl-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[e.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:b},"aria-hidden":!0}),u]}),e.jsx("div",{className:"mt-1 truncate text-lg font-semibold tabular-nums leading-tight tracking-tight opacity-95",style:{color:b},title:S(W),children:S(W)})]})]})]})}),e.jsx("div",{className:"bonsaif-network-plot relative z-0",children:e.jsx(aa,{data:r,xKey:t,series:[{key:a,label:c,color:f},{key:n,label:u,color:b}],height:H,showLegend:k,showTooltip:v,valueFormat:S,ariaLabel:B,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const Vo=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],Go=["primeSuiteOrigin","primeSuiteProjectKey"];function yd(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const r=new URLSearchParams(window.location.search);for(const t of Vo){const a=r.get(t);if(a){const n=oa(a);if(n)return n}}if(typeof sessionStorage<"u")for(const t of Go){const a=sessionStorage.getItem(t);if(a)try{const n=new URL(a);if(n.origin&&n.origin!==window.location.origin)return n.origin}catch{const n=oa(a);if(n)return n}}if(document.referrer){const t=oa(document.referrer);if(t&&t!==window.location.origin)return t}return"*"}catch{return"*"}}function wd(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const r=new URLSearchParams(window.location.search);for(const t of Vo)if(r.get(t))return"query";if(typeof sessionStorage<"u"){for(const t of Go)if(sessionStorage.getItem(t))return"sessionStorage"}if(document.referrer){const t=oa(document.referrer);if(t&&t!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function oa(r){if(!r)return null;const t=r.trim().replace(/\/+$/,"");if(!t)return null;if(/^https?:\/\/[^/]+$/.test(t))return t;try{return new URL(t).origin}catch{return null}}function Nd(r){const[t,a]=o.useState({}),[n,s]=o.useState(!1),l=o.useCallback(f=>n||t[f]?r[f]:void 0,[r,n,t]),i=o.useCallback(f=>{a(b=>({...b,[f]:!0}))},[]),c=o.useCallback(()=>{s(!0)},[]),u=o.useCallback(()=>{a({}),s(!1)},[]);return{submitted:n,touchedFields:t,getFieldError:l,touchField:i,submit:c,reset:u}}Object.defineProperty(_,"toast",{enumerable:!0,get:()=>wn.toast}),_.Alert=Vs,_.AreaChart=aa,_.AuthShell=Ao,_.BarChart=nd,_.BonsaifButton=Ls,_.BonsaifUIToaster=Jc,_.BulletChart=pd,_.Button=Pe,_.CHART_PALETTE=Qt,_.CalendarPicker=Zs,_.ChartCard=Rc,_.Checkbox=Ht,_.CodeBlock=rl,_.ComboChart=cd,_.CompactFilterSelect=nl,_.CompactSearchInput=al,_.ConfirmDialog=il,_.CopyButton=Ia,_.CopyLinkButton=fl,_.CpuChart=md,_.DataSheets=Fl,_.DataTable=Wn,_.DateRangePicker=jl,_.DonutChart=sd,_.Drawer=Gl,_.DropdownMenu=Ul,_.DynamicDetailTabs=qs,_.EmailField=mi,_.EmptyState=vi,_.FieldLayoutEditor=ki,_.FileUpload=wi,_.FormField=eo,_.GaugeChart=fd,_.GlobalScrollbars=Co,_.InputField=qa,_.LineChart=ad,_.LoadingState=$n,_.MentionTextEditor=Ji,_.MicroserviceFrame=Kc,_.Modal=Ha,_.MouseTooltip=_r,_.MultiSelect=Ci,_.NetworkChart=xd,_.NumberField=Ei,_.PageHeader=Uc,_.PageSearchInput=Sn,_.Pagination=Li,_.PhoneField=Ti,_.PieChart=od,_.PrimeAuthRouteShell=Vc,_.PrimeSuiteChatFrame=Xc,_.RadioGroup=Ai,_.RamChart=hd,_.RichTextEditor=co,_.SearchableSelect=Sr,_.SectionPanel=Ri,_.Sparkline=id,_.StatusBadge=tc,_.StatusSelect=lc,_.StepWizard=cc,_.TableSkeleton=Ot,_.Tabs=ic,_.TagInput=xc,_.TextInput=Vt,_.Textarea=xo,_.TextareaField=pc,_.Toggle=wc,_.UserAvatar=To,_.WaterfallChart=dd,_.buildMentionQueryRegex=Xa,_.cn=pr,_.configureBonsaifUI=ml,_.dedupeMentions=bo,_.defaultValueFormat=Qe,_.describeParentTargetOrigin=wd,_.emailFormat=Jl,_.extractMentionUsernames=Za,_.filterSelfMentions=Yi,_.formatBytes=Ur,_.formatPercent=qr,_.formatRate=Po,_.getBonsaifUIConfig=hl,_.getDataTablePreferencesEndpoint=Pa,_.getPlainTextOffset=Qa,_.highlightMentions=po,_.htmlToText=fo,_.insertMentionInEditor=mo,_.isValidEmail=_a,_.isValidPhone=ja,_.locateTextOffset=Zt,_.matches=ni,_.maxLength=ri,_.maxValue=ai,_.minLength=ei,_.minValue=ti,_.normalizeUsername=Ya,_.phoneCountryCodeOptions=ao,_.phoneFormat=Rl,_.placeCaretAtTextOffset=ho,_.required=Ql,_.resetBonsaifUIConfig=vl,_.resolveMentions=Xi,_.resolveParentTargetOrigin=yd,_.seriesColor=Ho,_.setBonsaifDataTablePreferencesEndpoint=gl,_.toneColor=ar,_.usageColor=yt,_.usageTone=Jt,_.useValidationVisibility=Nd,_.validateForm=oi,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})}));
42
+ `}),C.map(h=>{const L=Nc(h.colorIndex);return z===h.id?e.jsx("input",{ref:J,value:k,disabled:s,onChange:W=>q(W.target.value),onKeyDown:W=>Q(W,h.id),onBlur:()=>x(h.id,k),className:"min-w-[4rem] rounded border border-[var(--primary)] bg-transparent px-1 py-0.5 text-sm text-[var(--text-main)] outline-none",style:{width:`${Math.max(k.length+2,6)}ch`}},h.id):e.jsxs("span",{className:"inline-flex max-w-[240px] items-center gap-1 rounded-md px-2 py-0.5 text-xs font-medium",style:{backgroundColor:L.bg,color:L.text,border:`1px solid ${L.border}`},children:[e.jsx("span",{className:"truncate",children:h.value}),e.jsx("button",{type:"button","aria-label":`Editar "${h.value}"`,disabled:s,tabIndex:-1,onClick:W=>{W.stopPropagation(),S(h)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:e.jsx($.HiPencil,{className:"h-3 w-3"})}),e.jsx("button",{type:"button","aria-label":`Eliminar "${h.value}"`,disabled:s,tabIndex:-1,onClick:W=>{W.stopPropagation(),R(h.id)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:e.jsx($.HiXMark,{className:"h-3.5 w-3.5"})})]},h.id)}),!G&&e.jsx("input",{ref:T,value:B,disabled:s,placeholder:C.length===0?n:"",onChange:h=>A(h.target.value),onKeyDown:K,onPaste:ce,className:"min-w-[8rem] flex-1 bg-transparent text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed"})]}),j?e.jsx("span",{className:"text-xs font-medium text-[var(--danger)]",children:p}):b?e.jsx("span",{className:"text-xs font-medium text-[var(--text-muted)]",children:b}):null]})}const Mc={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function Tc({checked:r,disabled:t,onCheckedChange:a,size:n="sm",className:s="",...l}){const i=Mc[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 ${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(${c}px, -50%)`,background:r?"var(--primary-fg)":"var(--text-muted)"}})})}const To=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),Lc=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function $c(r){if(!(r instanceof HTMLElement)||r.dataset.overlayScroll==="false"||r.matches("[data-overlayscrollbars]")||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 Lo(r){return r.classList.contains("sidebar-scroll")||r.classList.contains("showcase-nav-scroll")}function $o(r){Lo(r)&&r.querySelectorAll(".os-scrollbar-horizontal").forEach(t=>{t.style.display="none",t.style.height="0",t.style.pointerEvents="none"})}function Ac(r){const t=r.querySelector(Lc);return t instanceof HTMLElement?t:null}function Ao(){return o.useEffect(()=>{const r=new WeakMap;let t=0;const a=()=>{t=0,document.querySelectorAll(To).forEach(l=>{if(!(l instanceof HTMLElement))return;if($a.OverlayScrollbars(l)){$o(l);return}if(!$c(l))return;const c={overflow:Lo(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},u=Ac(l),f=u?$a.OverlayScrollbars({target:l,elements:{viewport:u}},c):$a.OverlayScrollbars(l,c);$o(l),r.set(l,f)})},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(To).forEach(l=>{var i;l instanceof HTMLElement&&((i=r.get(l))==null||i.destroy())})}},[]),null}function yr(r){const t=r.trim();return!t||t==="/"||t==="/."?"":(t.startsWith("/")?t:`/${t}`).replace(/\/+$/,"")}function Do(r){try{const t=new URL(r);return yr(t.pathname)}catch{return""}}function Dc(r){const t=yr(r);if(!t)return"";const a=t.match(/^\/apps\/[^/]+/i);if(a)return yr(a[0]);const n=t.split("/").filter(Boolean);return n.length===0?"":n.length>=2&&n[0].toLowerCase()==="apps"?yr(`/${n[0]}/${n[1]}`):new Set(["admin","apps","apps-list","tickets","my-tickets","projects","projects-calendars","dashboard","teams","clients","services","settings","profile","messages","notifications","my-access","my-registers","my-pings","security-incidents","email-inbox","webhook-config","webphone-config","vobo","auth","api","login","forbidden","unauthorized","change-password","reset-password","chat-widget"]).has(n[0].toLowerCase())?"":yr(`/${n[0]}`)}const en="primeSuiteAppUrl",Ic={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"}},Io={xs:20,sm:28,md:36,lg:48,xl:64},Bo=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],Bc={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Oc="bonsaif.bot",Hc="Bonsaif Bot",Pc={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Oo(r){return typeof r=="string"?r.trim():""}function Fc(r){var s;if(r!==void 0)return yr(r);const t=yr(typeof process<"u"&&((s=process.env)==null?void 0:s.NEXT_PUBLIC_BASE_PATH)||"");if(t)return t;if(typeof window>"u")return"";try{const i=new URLSearchParams(window.location.search).get(en)||"";i&&window.sessionStorage.setItem(en,i);const c=window.sessionStorage.getItem(en)||"",u=i||c;if(u){const f=Do(u);if(f&&!/^\/admin(\/|$)/i.test(f))return f}}catch{}const a=window.__NEXT_DATA__,n=(a==null?void 0:a.assetPrefix)||"";if(n){const l=n.startsWith("http")?Do(n):yr(n);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return Dc(window.location.pathname)}function zc(r){const t=r.split(/\s+/).map(a=>a.trim()).filter(Boolean);return t.length===0?"?":t.length===1?t[0].slice(0,1).toUpperCase():`${t[0].slice(0,1)}${t[1].slice(0,1)}`.toUpperCase()}function _c(r){let t=0;for(const a of r)t=t*31+a.charCodeAt(0)&65535;return Bo[t%Bo.length]}function jc(r,t){return r===Oc||t===Hc}function Wc(r,t){return`${r.replace(/\/$/,"")}${t}`}function Ho({userId:r,username:t,name:a,size:n="md",showName:s=!1,showTooltip:l,tooltipContent:i,fallbackLabel:c="Usuario",basePath:u,wrapperClassName:f="",labelClassName:m="",labelSize:b="xs",avatarVersion:p=0,className:y="",style:N}){const[M,g]=o.useState(!1),C=typeof r=="string"&&r.trim()&&r!=="undefined"&&r!=="null"?r.trim():"";o.useEffect(()=>{g(!1)},[C,p]);const{wh:B,text:A}=Ic[n],z=Oo(a)||Oo(t)||c,E=zc(z),k=Fc(u),q=jc(t,a),H=Wc(k,"/favicon.svg"),_=o.useMemo(()=>{if(!C)return"";const O=new URLSearchParams;O.set("size",String(Io[n])),p&&O.set("v",String(p));const j=O.toString();return`${k}/api/user/avatar/${encodeURIComponent(C)}${j?`?${j}`:""}`},[p,k,C,n]),Y=Io[n],Z=q?e.jsx("span",{className:`${B} ${Pc[n]} rounded-full flex items-center justify-center bg-[#071f1a] ring-1 ring-emerald-400/35 shadow-[0_0_0_1px_rgba(255,255,255,0.06)] flex-shrink-0 ${y}`,style:N,children:e.jsx("img",{src:H,alt:z,width:Y,height:Y,className:"h-full w-full object-contain"})}):_&&!M?e.jsx("img",{src:_,alt:z,width:Y,height:Y,className:`${B} rounded-full object-cover flex-shrink-0 ${y}`,style:N,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>g(!0)},`${C}-${p}`):e.jsx("span",{className:`${B} ${_c(z)} ${A} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${y}`,style:N,title:z,children:E});if(s)return e.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${f}`,children:[Z,e.jsx("span",{className:`min-w-0 truncate ${Bc[b]} font-medium text-[var(--text-main)] ${m}`,title:z,children:z})]});const T=l??!0,J=i??z;return T&&J?e.jsx(jr,{as:"span",content:J,className:`inline-flex flex-shrink-0 ${f}`,children:Z}):Z}function qc({href:r,className:t,children:a}){return e.jsx("a",{href:r,className:t,children:a})}function Uc(r){return r.reduce((t,a)=>{const n=a.section??"Principal";return t[n]=[...t[n]??[],a],t},{})}function Po({children:r,navItems:t=[],currentPath:a=typeof window>"u"?"/":window.location.pathname,user:n,appName:s="Bonsaif",appLogo:l,header:i,footer:c,onLogout:u,LinkComponent:f=qc}){const[m,b]=o.useState(!1),p=Uc(t);return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[e.jsx(Ao,{}),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:()=>b(!0),children:e.jsx($.HiBars3,{className:"h-5 w-5"})}),m&&e.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>b(!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 ${m?"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($.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:()=>b(!1),children:e.jsx($.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:e.jsx("div",{className:"sidebar-scroll-body",children:Object.entries(p).map(([y,N])=>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($.HiChevronDown,{className:"h-3.5 w-3.5"}),y]}),e.jsx("div",{className:"space-y-1",children:N.map(M=>{const g=a===M.href||a.startsWith(`${M.href}/`);return e.jsxs(f,{href:M.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${g?"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:M.icon??e.jsx($.HiHome,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate",children:M.label})]},M.href)})})]},y))})}),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(Ho,{name:n.initials??n.name??n.email??"Usuario",size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-medium text-white",children:n.name??"Usuario"}),n.email&&e.jsx("div",{className:"truncate text-xs text-white/45",children:n.email})]})]}),u&&e.jsxs(He,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:u,children:[e.jsx($.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 Fo="bonsaif-ui:prime-auth-sso",Vc={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"},rn={dashboard:e.jsx($.HiChartBar,{className:"h-5 w-5"}),tickets:e.jsx($.HiTicket,{className:"h-5 w-5"}),teams:e.jsx($.HiUsers,{className:"h-5 w-5"}),projects:e.jsx($.HiRectangleGroup,{className:"h-5 w-5"}),clients:e.jsx($.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:e.jsx($.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:e.jsx($.HiUser,{className:"h-5 w-5"}),settings:e.jsx($.HiCog6Tooth,{className:"h-5 w-5"}),notifications:e.jsx($.HiBell,{className:"h-5 w-5"}),changelog:e.jsx($.HiDocumentText,{className:"h-5 w-5"}),admin:e.jsx($.HiShieldCheck,{className:"h-5 w-5"}),users:e.jsx($.HiUsers,{className:"h-5 w-5"}),roles:e.jsx($.HiShieldCheck,{className:"h-5 w-5"}),menus:e.jsx($.HiCog6Tooth,{className:"h-5 w-5"}),guards:e.jsx($.HiCalendarDays,{className:"h-5 w-5"}),vacations:e.jsx($.HiCalendarDays,{className:"h-5 w-5"}),audit:e.jsx($.HiListBullet,{className:"h-5 w-5"}),positions:e.jsx($.HiBriefcase,{className:"h-5 w-5"}),ranks:e.jsx($.HiListBullet,{className:"h-5 w-5"}),"email-inbox":e.jsx($.HiInbox,{className:"h-5 w-5"}),"security-incidents":e.jsx($.HiShieldCheck,{className:"h-5 w-5"})};function Gc(r){return r.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Kc(r){return/^\d+$/.test(r)||/^[a-f0-9]{8,}$/i.test(r)}function Xc(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=Kc(a)&&n?n:a,l=Vc[s]??Gc(s);return[{label:"Inicio",href:"/"},{label:l}]}function tn(r){return(r==null?void 0:r.querySelector(":scope > .os-viewport"))??(r==null?void 0:r.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function Yc(r){const t=r.split("/").filter(Boolean),a=t[t.length-1];if(!a)return e.jsx($.HiHome,{className:"h-5 w-5"});if(rn[a])return rn[a];const n=t.length>1?t[t.length-2]:"";return rn[n]??e.jsx($.HiHome,{className:"h-5 w-5"})}function Zc(r){return r.includes("primeAuthOrigin")||r.includes("primeAuthProjectKey")}function zo(){if(typeof window>"u")return!1;if(Zc(window.location.href)){try{window.sessionStorage.setItem(Fo,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Fo)==="true"}catch{return!1}}function Qc({title:r,subtitle:t,action:a,meta:n,icon:s,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:u,showBreadcrumbs:f=!0,contained:m=!1}){const b=o.useRef(null),[p,y]=o.useState(!1),[N,M]=o.useState(u??"/"),[g,C]=o.useState(()=>zo()),[B,A]=o.useState(null),z=u??N,E=c??Xc(z),k=s??Yc(z),q=f&&!g&&E.length>1,H=!q;o.useEffect(()=>{u||M(window.location.pathname)},[u]),o.useEffect(()=>{C(zo())},[]),o.useEffect(()=>{if(m){y(!1);return}let Y=null,Z=0,T=0;const J=()=>{const te=b.current,X=document.querySelector("[data-app-scroll='true']");return(te==null?void 0:te.closest(".os-viewport"))??(te==null?void 0:te.closest("[data-overlayscrollbars-viewport]"))??tn(X)??X??window},O=()=>{const te=Y&&Y!==window?Y.scrollTop:window.scrollY;y(X=>X?te>24:te>72)},j=()=>{Y==null||Y.removeEventListener("scroll",O),Y=J(),Y.addEventListener("scroll",O,{passive:!0}),O()};return j(),Z=window.requestAnimationFrame(j),T=window.setTimeout(j,120),()=>{window.cancelAnimationFrame(Z),window.clearTimeout(T),Y==null||Y.removeEventListener("scroll",O)}},[m]),o.useEffect(()=>{if(m){A(null);return}let Y=0;const Z=[],T=()=>{const ee=b.current,R=ee==null?void 0:ee.parentElement,x=document.querySelector("[data-app-scroll='true']"),S=tn(x)??x;if(!ee||!R||!S){A(null);return}const K=R.getBoundingClientRect(),Q=window.getComputedStyle(R),ae=S.getBoundingClientRect(),ce=S instanceof HTMLElement&&S.clientWidth>0?S.clientWidth:ae.width,ve=K.left+parseFloat(Q.paddingLeft||"0"),re={marginLeft:Math.round(ae.left-ve),width:Math.round(ce)};A(G=>G&&G.marginLeft===re.marginLeft&&G.width===re.width?G:re)},J=()=>{window.cancelAnimationFrame(Y),Y=window.requestAnimationFrame(T)};J(),window.addEventListener("resize",J);const O=new ResizeObserver(J),j=b.current,te=j==null?void 0:j.parentElement,X=document.querySelector("[data-app-scroll='true']"),I=tn(X)??X;return[te,X,I].forEach(ee=>{ee&&O.observe(ee)}),Z.push(window.setTimeout(J,120)),Z.push(window.setTimeout(J,280)),()=>{window.cancelAnimationFrame(Y),window.removeEventListener("resize",J),O.disconnect(),Z.forEach(ee=>window.clearTimeout(ee))}},[m]);const _={...B?{marginLeft:B.marginLeft,width:B.width}:null,"--page-header-control-height":p?"34px":"40px","--page-header-control-padding-x":p?"10px":"14px","--page-header-control-icon-left":p?"10px":"12px",background:m?"var(--bg-card)":p?"color-mix(in srgb, var(--bg-main) 82%, transparent)":"color-mix(in srgb, var(--bg-main) 58%, transparent)",backdropFilter:"saturate(1.25) blur(18px)",WebkitBackdropFilter:"saturate(1.25) blur(18px)",borderBottom:m||p?"1px solid var(--border)":"1px solid transparent",boxShadow:p?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return e.jsx("div",{ref:b,"data-page-header":"true","data-compact":p?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${m?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${l}`,style:_,children:e.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${p?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":H?"min-h-9 gap-2 px-4 py-0 sm:min-h-10 sm:gap-2.5":"min-h-10 gap-2.5 px-4 pt-0.5 sm:min-h-11 sm:gap-3"} ${i}`,children:[e.jsx("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${p||H?"gap-1":"gap-1.5 sm:gap-2"}`,children:e.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${p||H?"gap-2":"gap-2.5 sm:gap-3"}`,children:[e.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${p?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:q?"var(--text-secondary)":"var(--text-muted)"},children:k}),e.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${p?"gap-x-2 gap-y-1":"gap-x-3 gap-y-2"}`,children:[e.jsxs("div",{className:"min-w-0 flex-shrink transition-[transform] duration-300 ease-out",children:[e.jsx("h1",{className:`truncate font-bold tracking-tight transition-[font-size,line-height,color] duration-300 ease-out ${p?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:r}),t&&e.jsx("p",{"aria-hidden":p,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${p?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-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 ${p?"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 ${p?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:e.jsx(En.Provider,{value:{compact:!0,headerAction:!0},children:a})})]})})}function Jc({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(Po,{currentPath:t,...n,children:r})}function _o(){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 Rc(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 ed({name:r,src:t,projectKey:a}){const[n,s]=o.useState("system"),l=o.useRef(null);o.useEffect(()=>{s(_o());const u=new MutationObserver(()=>s(_o()));return u.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>u.disconnect()},[]);const i=o.useMemo(()=>Rc(t,n,a),[a,t,n]),c=o.useMemo(()=>{try{return new URL(i).origin}catch{return""}},[i]);return o.useEffect(()=>{if(!a)return;const u=a;function f(m){var y,N,M;if(m.source!==((y=l.current)==null?void 0:y.contentWindow)||c&&m.origin!==c)return;if(((N=m.data)==null?void 0:N.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!m.data.active}}));return}if(((M=m.data)==null?void 0:M.type)!=="prime-microservice:navigation")return;const b=m.data.path;if(!b||!b.startsWith("/")||b.startsWith("//"))return;const p=`/apps/${encodeURIComponent(u)}${b}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==p&&(window.history.replaceState(window.history.state,"",p),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",f),()=>{window.removeEventListener("message",f),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 rd(){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(c=>c.ok?c.json():null).then(c=>{!i&&(c!=null&&c.src)&&t(c.src)}).catch(()=>{}),()=>{i=!0}},[]),o.useEffect(()=>{const i=c=>{var f;if(((f=c.data)==null?void 0:f.type)!=="prime-suite-chat:state")return;const u=!!c.data.active;n(u),l({width:jo(c.data.width,96,720),height:jo(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(${s.width}px, 100vw)`:96,height:a?`min(${s.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function jo(r,t,a){const n=typeof r=="number"&&Number.isFinite(r)?r:t;return Math.max(t,Math.min(a,Math.ceil(n)))}function td(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 ad(){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 nd(){return"light"}function od({position:r="bottom-center"}){const t=o.useSyncExternalStore(td,ad,nd);return e.jsx(Nn.Toaster,{position:r,theme:t,richColors:!0,closeButton:!0})}function sd({title:r,subtitle:t,actions:a,loading:n=!1,empty:s=!1,emptyText:l="Sin datos para mostrar",className:i="",children:c}){return e.jsxs("div",{className:`bonsaif-chart-card w-full overflow-visible ${i}`,children:[(r||t||a)&&e.jsxs("div",{className:"bonsaif-chart-card-head",children:[e.jsx("div",{className:"bonsaif-chart-card-accent","aria-hidden":!0}),e.jsxs("div",{className:"bonsaif-chart-card-copy min-w-0",children:[r?e.jsx("div",{className:"bonsaif-chart-card-title",children:r}):null,t?e.jsx("div",{className:"bonsaif-chart-card-subtitle",children:t}):null]}),a?e.jsx("div",{className:"bonsaif-chart-card-actions shrink-0",children:a}):null]}),e.jsx("div",{className:"bonsaif-chart-card-body",children:n?e.jsx("div",{className:"flex h-48 items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-t-transparent",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"},"aria-label":"Cargando"})}):s?e.jsx("div",{className:"flex h-48 items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:l}):c})]})}const Jt=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function Wo(r,t){return r.color??Jt[t%Jt.length]}function sr(r="primary"){switch(r){case"success":return"#34d399";case"warning":return"#fbbf24";case"danger":return"#f87171";case"neutral":return"var(--text-muted)";default:return"var(--primary)"}}const rr=r=>{if(!Number.isFinite(r))return"—";const t=Math.abs(r);return t>=1e9?`${(r/1e9).toFixed(1).replace(/\.0$/,"")}B`:t>=1e6?`${(r/1e6).toFixed(1).replace(/\.0$/,"")}M`:t>=1e4?`${(r/1e3).toFixed(1).replace(/\.0$/,"")}k`:r.toLocaleString(void 0,{maximumFractionDigits:2})};function wt(r){if(r==null||r==="")return null;const t=typeof r=="number"?r:Number(r);return Number.isFinite(t)?t:null}const an={warning:70,danger:90};function Rt(r,t=an){const a=t.warning??an.warning,n=t.danger??an.danger;return r>=n?"danger":r>=a?"warning":r<=0?"primary":"success"}function Nt(r,t){return sr(Rt(r,t))}function Vr(r,t=0){return Number.isFinite(r)?`${r.toFixed(t)}%`:"—"}function Gr(r,t=1){if(!Number.isFinite(r))return"—";const a=r<0?"-":"",n=Math.abs(r);if(n<1024)return`${a}${Math.round(n)} B`;const s=["KB","MB","GB","TB","PB"];let l=n/1024,i=0;for(;l>=1024&&i<s.length-1;)l/=1024,i+=1;const c=l>=100?l.toFixed(0):l.toFixed(t);return`${a}${c.replace(/\.0$/,"")} ${s[i]}`}function qo(r,t="bytes",a=1){if(!Number.isFinite(r))return"—";const n=r<0?"-":"",s=Math.abs(r),l=t==="bits"?["b/s","Kb/s","Mb/s","Gb/s","Tb/s"]:["B/s","KB/s","MB/s","GB/s","TB/s"];if(s<1024)return`${n}${Math.round(s)} ${l[0]}`;let i=s/1024,c=1;for(;i>=1024&&c<l.length-1;)i/=1024,c+=1;const u=i>=100?i.toFixed(0):i.toFixed(a);return`${n}${u.replace(/\.0$/,"")} ${l[c]}`}function Kr(r,t){var a;for(let n=r.length-1;n>=0;n-=1){const s=wt((a=r[n])==null?void 0:a[t]);if(s!==null)return s}return null}function tr({height:r}){return e.jsx("div",{className:"flex items-center justify-center",style:{height:r},"aria-busy":!0,children:e.jsx("div",{className:"h-7 w-7 animate-spin rounded-full border-2",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"}})})}function ar({height:r,text:t}){return e.jsx("div",{className:"flex items-center justify-center text-sm",style:{height:r,color:"var(--text-muted)"},children:t})}const Tr=680,Lr="ease-out",ld={top:18,right:8,bottom:12,left:0};function kt(r){return{...ld,...r}}function St(r){return r.map((t,a)=>({...t,color:Wo(t,a),label:t.label??t.key}))}function ea(r,t){return!r.length||!t.length||r.every(a=>t.every(n=>wt(a[n.key])===null))}function Ye(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function Ct(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function Uo(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function ra(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function id(r,t=rr){if(r==null||r==="")return"—";const a=typeof r=="number"?r:Number(r);return Number.isFinite(a)?t(a):String(r)}function Vo(r){return`bonsaif-grad-${r.replace(/[^a-zA-Z0-9_-]/g,"")}`}function cd({active:r,label:t,payload:a,valueFormat:n=rr}){var c,u,f,m,b,p;if(!r||!(a!=null&&a.length))return null;const s=a.filter(y=>y.dataKey!=="base"&&y.name!=="base"&&y.value!==null&&y.value!==void 0);if(!s.length)return null;const l=((u=(c=s[0])==null?void 0:c.payload)==null?void 0:u.fullName)??((m=(f=s[0])==null?void 0:f.payload)==null?void 0:m.tooltipLabel)??((p=(b=s[0])==null?void 0:b.payload)==null?void 0:p.display),i=typeof l=="string"&&l.length>0?l:t;return e.jsxs("div",{className:"bonsaif-chart-tooltip-panel",children:[i!=null&&i!==""?e.jsx("div",{className:"bonsaif-chart-tooltip-label",children:String(i)}):null,e.jsx("div",{className:"bonsaif-chart-tooltip-items",children:s.map((y,N)=>{const M=y.payload,g=M&&typeof M.display=="number"?M.display:y.value;return e.jsxs("div",{className:"bonsaif-chart-tooltip-row",children:[e.jsxs("span",{className:"bonsaif-chart-tooltip-name",children:[e.jsx("span",{className:"bonsaif-chart-tooltip-swatch",style:{background:y.color??"var(--primary)"}}),y.name??y.dataKey]}),e.jsx("span",{className:"bonsaif-chart-tooltip-value",children:id(g,n)})]},String(y.dataKey??y.name??N))})})]})}function Xr({valueFormat:r,content:t,cursor:a,offset:n=12,wrapperStyle:s,allowEscapeViewBox:l,reverseDirection:i,...c}){return e.jsx(ge.Tooltip,{...c,cursor:a,offset:n,allowEscapeViewBox:l??{x:!1,y:!1},reverseDirection:i??{x:!1,y:!1},wrapperStyle:{outline:"none",zIndex:60,pointerEvents:"none",overflow:"visible",...s},content:t??e.jsx(cd,{valueFormat:r})})}function Go(r,t,a){return a==null?-1:r.findIndex(n=>String(n[t])===String(a))}function Ko(r,t,a){if(a<=1)return null;const n=Math.max(0,Math.min(r,t)),s=Math.min(a-1,Math.max(r,t));return s-n<1||n===0&&s>=a-1?null:{startIndex:n,endIndex:s}}function ta(r,t,a={}){const{zoomable:n=!1,zoomMode:s="both",brushHeight:l=28,onZoomChange:i}=a,[c,u]=o.useState(null),[f,m]=o.useState(null),b=!!n&&r.length>1,p=b&&(s==="brush"||s==="both"),y=b&&(s==="drag"||s==="both"),N=o.useCallback(Z=>{u(Z),i==null||i(Z)},[i]),M=o.useCallback(()=>{m(null),N(null)},[N]),g=!!c,C=o.useMemo(()=>!c||p?r:r.slice(c.startIndex,c.endIndex+1),[r,p,c]),B=o.useCallback((Z,T)=>{const J=Go(r,t,Z),O=Go(r,t,T);J<0||O<0||N(Ko(J,O,r.length))},[N,r,t]),A=o.useCallback(Z=>{y&&((Z==null?void 0:Z.activeLabel)===void 0||(Z==null?void 0:Z.activeLabel)===null||m({leftLabel:Z.activeLabel,rightLabel:Z.activeLabel}))},[y]),z=o.useCallback(Z=>{!y||!f||(Z==null?void 0:Z.activeLabel)===void 0||(Z==null?void 0:Z.activeLabel)===null||m(T=>T&&{...T,rightLabel:Z.activeLabel})},[f,y]),E=o.useCallback(()=>{if(y){if(!f||f.rightLabel===null||f.rightLabel===void 0){m(null);return}B(f.leftLabel,f.rightLabel),m(null)}},[B,f,y]),k=o.useCallback(Z=>{if(p){if(!Z){N(null);return}N(Ko(Z.startIndex??0,Z.endIndex??r.length-1,r.length))}},[N,r.length,p]),q=y?{onMouseDown:A,onMouseMove:z,onMouseUp:E,onMouseLeave:()=>{f&&E()}}:{},H=c??{startIndex:0,endIndex:Math.max(0,r.length-1)},_=e.jsxs(e.Fragment,{children:[y&&f&&f.rightLabel!==null&&f.rightLabel!==void 0?e.jsx(ge.ReferenceArea,{x1:f.leftLabel,x2:f.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,p?e.jsx(ge.Brush,{dataKey:t,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:H.startIndex,endIndex:H.endIndex,onChange:k,tickFormatter:Z=>String(Z)}):null]}),Y=p?{bottom:Math.max(l+10,36)}:void 0;return{enabled:b,showBrush:p,showDrag:y,viewData:C,isZoomed:g,resetZoom:M,chartHandlers:q,zoomNodes:_,marginExtra:Y}}function aa({visible:r,onReset:t}){return r?e.jsx("button",{type:"button",className:"bonsaif-chart-zoom-reset",onClick:t,"aria-label":"Restablecer zoom",children:"Restablecer zoom"}):null}function dd({data:r,xKey:t,series:a,height:n=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:u=!0,showTooltip:f=!0,margin:m,valueFormat:b=rr,yDomain:p,ariaLabel:y="Gráfico de líneas",curve:N=!0,strokeWidth:M=2.25,zoomable:g=!1,zoomMode:C="both",brushHeight:B,onZoomChange:A}){const z=ea(r,a),E=St(a),k=ta(r,t,{zoomable:g,zoomMode:C,brushHeight:B,onZoomChange:A}),q=kt({...m,...k.marginExtra});return l?e.jsx(tr,{height:n}):z?e.jsx(ar,{height:n,text:i}):e.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${s}`,role:"img","aria-label":y,style:{height:n},children:[e.jsx(aa,{visible:k.isZoomed,onReset:k.resetZoom}),e.jsx(ge.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ge.LineChart,{data:k.viewData,margin:q,...k.chartHandlers,children:[c?e.jsx(ge.CartesianGrid,{strokeDasharray:"2 8",stroke:Ct(),vertical:!1}):null,e.jsx(ge.XAxis,{dataKey:t,tick:Ye(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),e.jsx(ge.YAxis,{tick:Ye(),tickLine:!1,axisLine:!1,width:44,domain:p??["auto","auto"],tickFormatter:H=>b(Number(H)),dx:-2}),f?e.jsx(Xr,{valueFormat:b,cursor:{stroke:Uo(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,u?e.jsx(ge.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ra()}):null,E.map((H,_)=>e.jsx(ge.Line,{type:N?"monotone":"linear",dataKey:H.key,name:H.label,stroke:H.color,strokeWidth:_===0?M+.35:M,strokeOpacity:_===0?1:.88,isAnimationActive:!0,animationDuration:Tr,animationEasing:Lr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:H.color}},H.key)),k.zoomNodes]})})]})}function na({data:r,xKey:t,series:a,height:n=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:u=!0,showTooltip:f=!0,margin:m,valueFormat:b=rr,yDomain:p,ariaLabel:y="Gráfico de área",stacked:N=!1,opacity:M=.22,zoomable:g=!1,zoomMode:C="both",brushHeight:B,onZoomChange:A}){const z=ea(r,a),E=St(a),k=ta(r,t,{zoomable:g,zoomMode:C,brushHeight:B,onZoomChange:A}),q=kt({...m,...k.marginExtra});return l?e.jsx(tr,{height:n}):z?e.jsx(ar,{height:n,text:i}):e.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${s}`,role:"img","aria-label":y,style:{height:n},children:[e.jsx(aa,{visible:k.isZoomed,onReset:k.resetZoom}),e.jsx(ge.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ge.AreaChart,{data:k.viewData,margin:q,...k.chartHandlers,children:[e.jsx("defs",{children:E.map(H=>e.jsxs("linearGradient",{id:Vo(H.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:H.color,stopOpacity:Math.min(.55,M+.28)}),e.jsx("stop",{offset:"48%",stopColor:H.color,stopOpacity:M*.5}),e.jsx("stop",{offset:"100%",stopColor:H.color,stopOpacity:0})]},H.key))}),c?e.jsx(ge.CartesianGrid,{strokeDasharray:"2 8",stroke:Ct(),vertical:!1}):null,e.jsx(ge.XAxis,{dataKey:t,tick:Ye(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),e.jsx(ge.YAxis,{tick:Ye(),tickLine:!1,axisLine:!1,width:44,domain:p??["auto","auto"],tickFormatter:H=>b(Number(H)),dx:-2}),f?e.jsx(Xr,{valueFormat:b,cursor:{stroke:Uo(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,u?e.jsx(ge.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ra()}):null,E.map(H=>e.jsx(ge.Area,{type:"monotone",dataKey:H.key,name:H.label,stroke:H.color,fill:`url(#${Vo(H.key)})`,strokeWidth:2.25,stackId:N?"stack":void 0,isAnimationActive:!0,animationDuration:Tr,animationEasing:Lr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:H.color}},H.key)),k.zoomNodes]})})]})}function ud({data:r,xKey:t,series:a,height:n=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:u=!0,showTooltip:f=!0,margin:m,valueFormat:b=rr,yDomain:p,ariaLabel:y="Gráfico de barras",layout:N="vertical",mode:M="grouped",barRadius:g=6,categoryAxisWidth:C=64,zoomable:B=!1,zoomMode:A="both",brushHeight:z,onZoomChange:E}){const k=ea(r,a),q=St(a),H=N==="horizontal",_=ta(r,t,{zoomable:B&&!H,zoomMode:A,brushHeight:z,onZoomChange:E}),Y=kt({...m,..._.marginExtra});return l?e.jsx(tr,{height:n}):k?e.jsx(ar,{height:n,text:i}):e.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${s}`,role:"img","aria-label":y,style:{height:n},children:[e.jsx(aa,{visible:_.isZoomed,onReset:_.resetZoom}),e.jsx(ge.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ge.BarChart,{data:_.viewData,margin:Y,layout:H?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,..._.chartHandlers,children:[c?e.jsx(ge.CartesianGrid,{strokeDasharray:"2 8",stroke:Ct(),horizontal:!H,vertical:H}):null,H?e.jsxs(e.Fragment,{children:[e.jsx(ge.XAxis,{type:"number",tick:Ye(),tickLine:!1,axisLine:!1,tickFormatter:Z=>b(Number(Z)),domain:p??["auto","auto"]}),e.jsx(ge.YAxis,{type:"category",dataKey:t,tick:Ye(),tickLine:!1,axisLine:!1,width:C})]}):e.jsxs(e.Fragment,{children:[e.jsx(ge.XAxis,{dataKey:t,tick:Ye(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),e.jsx(ge.YAxis,{tick:Ye(),tickLine:!1,axisLine:!1,width:44,domain:p??["auto","auto"],tickFormatter:Z=>b(Number(Z)),dx:-2})]}),f?e.jsx(Xr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,u?e.jsx(ge.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ra()}):null,q.map((Z,T)=>e.jsx(ge.Bar,{dataKey:Z.key,name:Z.label,fill:Z.color,fillOpacity:T===0?1:.82,radius:H?[0,g,g,0]:[g,g,2,2],maxBarSize:20,stackId:M==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:Tr,animationEasing:Lr},Z.key)),_.zoomNodes]})})]})}function fd(r){return e.jsx(Yo,{...r,variant:"pie"})}function bd(r){return e.jsx(Yo,{...r,variant:"donut",innerRadius:r.innerRadius??.62,cornerRadius:r.cornerRadius??10,padAngle:r.padAngle??2})}function Xo(r,t){return r==null||!Number.isFinite(r)?t:r>0&&r<=1?r*100:r}function Yo({data:r,nameKey:t,valueKey:a,height:n=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showLegend:c=!0,showTooltip:u=!0,valueFormat:f=rr,ariaLabel:m,innerRadius:b,outerRadius:p,colors:y=[...Jt],padAngle:N,cornerRadius:M,variant:g}){const C=r.map((T,J)=>({name:String(T[t]??""),value:wt(T[a])??0,fill:y[J%y.length],row:T})).filter(T=>T.value>0),B=!C.length,A=g==="donut",z=C.length,E=Xo(b,A?62:12),k=Xo(p,78),q=Math.min(N??(A?2:3),Math.max(.5,10/Math.max(1,z))),H=Math.min(M??(A?10:8),Math.max(2,36/Math.max(1,z)));if(l)return e.jsx(tr,{height:n});if(B)return e.jsx(ar,{height:n,text:i});const _=C.reduce((T,J)=>T+J.value,0),Y=c?Math.min(96,28+Math.ceil(z/3)*22):0,Z=Math.max(140,n-Y);return e.jsx("div",{className:`bonsaif-chart bonsaif-${g}-chart w-full ${s}`,role:"img","aria-label":m??(g==="donut"?"Donut chart":"Pie chart"),style:{height:n},children:e.jsxs("div",{className:"bonsaif-pie-layout",children:[e.jsx("div",{className:"bonsaif-pie-plot",style:{height:Z},children:e.jsx(ge.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ge.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[u?e.jsx(Xr,{valueFormat:f,isAnimationActive:!1}):null,e.jsx(ge.Pie,{data:C,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${E}%`,outerRadius:`${k}%`,startAngle:90,endAngle:-270,paddingAngle:q,cornerRadius:H,minAngle:z>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:Tr,animationEasing:Lr,label:!1,activeShape:pd,children:C.map(T=>e.jsx(ge.Cell,{fill:T.fill},T.name))}),A?e.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:f(_)}):null]})})}),c?e.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:C.map(T=>e.jsxs("li",{className:"bonsaif-pie-legend-item",children:[e.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:T.fill},"aria-hidden":!0}),e.jsx("span",{className:"bonsaif-pie-legend-label",title:T.name,children:T.name}),e.jsx("span",{className:"bonsaif-pie-legend-value",children:f(T.value)})]},T.name))}):null]})})}function pd(r){const{outerRadius:t=0,...a}=r;return e.jsx(ge.Sector,{...a,outerRadius:Number(t)+4,stroke:"var(--bg-card)",strokeWidth:2})}function md({data:r,dataKey:t,width:a="100%",height:n=36,tone:s="primary",color:l,fill:i=!0,className:c="",ariaLabel:u="Sparkline"}){const f=l??sr(s),m=r.map(k=>wt(k[t])).filter(k=>k!==null);if(m.length<2)return e.jsx("div",{className:c,style:{width:a,height:n,color:"var(--text-muted)"},"aria-label":u});const b=120,p=36,y=3,N=1,M=Math.min(...m),C=Math.max(...m)-M||1,B=m.map((k,q)=>{const H=N+q/(m.length-1)*(b-N*2),_=p-y-(k-M)/C*(p-y*2);return{x:H,y:_}}),A=B.map((k,q)=>`${q===0?"M":"L"}${k.x.toFixed(2)} ${k.y.toFixed(2)}`).join(" "),z=`${A} L${B[B.length-1].x.toFixed(2)} ${p} L${B[0].x.toFixed(2)} ${p} Z`,E=`bonsaif-spark-${t.replace(/[^a-zA-Z0-9_-]/g,"")}-${s}`;return e.jsx("div",{className:`bonsaif-sparkline ${c}`,style:{width:a,height:n},role:"img","aria-label":u,children:e.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${b} ${p}`,preserveAspectRatio:"none",focusable:"false",children:[i?e.jsx("defs",{children:e.jsxs("linearGradient",{id:E,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:f,stopOpacity:.38}),e.jsx("stop",{offset:"100%",stopColor:f,stopOpacity:0})]})}):null,i?e.jsx("path",{d:z,fill:`url(#${E})`}):null,e.jsx("path",{d:A,fill:"none",stroke:f,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function hd({data:r,xKey:t,series:a,barSeries:n,lineSeries:s,height:l=280,className:i="",loading:c=!1,emptyText:u="Sin datos para mostrar",showGrid:f=!0,showLegend:m=!0,showTooltip:b=!0,margin:p,valueFormat:y=rr,yDomain:N,ariaLabel:M="Gráfico combinado",barRadius:g=6,zoomable:C=!1,zoomMode:B="both",brushHeight:A,onZoomChange:z}){const E=n??a.slice(0,Math.max(1,a.length-1)),k=s??(a.length>1?a.slice(-1):a.length?[a[0]]:[]),q=[...E,...k.filter(O=>!E.some(j=>j.key===O.key))],H=ea(r,q),_=St(E),Y=St(q),Z=k.map(O=>{var te;const j=Y.find(X=>X.key===O.key);return{...O,label:O.label??O.key,color:O.color??(j==null?void 0:j.color)??((te=Y[0])==null?void 0:te.color)}}),T=ta(r,t,{zoomable:C,zoomMode:B,brushHeight:A,onZoomChange:z}),J=kt({...p,...T.marginExtra});return c?e.jsx(tr,{height:l}):H?e.jsx(ar,{height:l,text:u}):e.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":M,style:{height:l},children:[e.jsx(aa,{visible:T.isZoomed,onReset:T.resetZoom}),e.jsx(ge.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ge.ComposedChart,{data:T.viewData,margin:J,barCategoryGap:"34%",...T.chartHandlers,children:[f?e.jsx(ge.CartesianGrid,{strokeDasharray:"2 8",stroke:Ct(),vertical:!1}):null,e.jsx(ge.XAxis,{dataKey:t,tick:Ye(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),e.jsx(ge.YAxis,{tick:Ye(),tickLine:!1,axisLine:!1,width:44,domain:N??["auto","auto"],tickFormatter:O=>y(Number(O)),dx:-2}),b?e.jsx(Xr,{valueFormat:y,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,m?e.jsx(ge.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ra()}):null,_.map(O=>e.jsx(ge.Bar,{dataKey:O.key,name:O.label,fill:O.color,fillOpacity:.88,radius:[g,g,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:Tr,animationEasing:Lr},O.key)),Z.map(O=>e.jsx(ge.Line,{type:"monotone",dataKey:O.key,name:O.label,stroke:O.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:Tr,animationEasing:Lr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:O.color}},O.key)),T.zoomNodes]})})]})}function gd({data:r,xKey:t,valueKey:a,typeKey:n,height:s=280,className:l="",loading:i=!1,emptyText:c="Sin datos para mostrar",showGrid:u=!0,showTooltip:f=!0,margin:m,valueFormat:b=rr,ariaLabel:p="Gráfico waterfall",increaseColor:y="#34d399",decreaseColor:N="#f87171",totalColor:M="var(--primary)"}){const g=o.useMemo(()=>vd(r,{xKey:t,valueKey:a,typeKey:n,increaseColor:y,decreaseColor:N,totalColor:M}),[r,t,a,n,y,N,M]),C=!g.length,B=kt(m);return i?e.jsx(tr,{height:s}):C?e.jsx(ar,{height:s,text:c}):e.jsx("div",{className:`bonsaif-chart bonsaif-waterfall-chart w-full ${l}`,role:"img","aria-label":p,style:{height:s},children:e.jsx(ge.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ge.BarChart,{data:g,margin:B,barCategoryGap:"42%",children:[u?e.jsx(ge.CartesianGrid,{strokeDasharray:"2 8",stroke:Ct(),vertical:!1}):null,e.jsx(ge.XAxis,{dataKey:"label",tick:Ye(),tickLine:!1,axisLine:!1,interval:0,dy:6}),e.jsx(ge.YAxis,{tick:Ye(),tickLine:!1,axisLine:!1,width:44,tickFormatter:A=>b(Number(A)),dx:-2}),f?e.jsx(Xr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,e.jsx(ge.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),e.jsx(ge.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:Tr,animationEasing:Lr,children:g.map(A=>e.jsx(ge.Cell,{fill:A.color},A.label))})]})})})}function vd(r,t){let a=0;return r.map((n,s)=>{const l=wt(n[t.valueKey])??0,i=t.typeKey?String(n[t.typeKey]??""):"",c=i==="total"||s===r.length-1&&i!=="increase"&&i!=="decrease";let u="increase",f=0,m=0,b=l;return c&&i==="total"?(u="total",f=0,m=Math.abs(l),b=l,a=l):c&&s===r.length-1&&!i?(u="total",f=0,m=Math.abs(a),b=a):(u=i==="decrease"||l<0?"decrease":"increase",u==="decrease"?(f=a+l,m=Math.abs(l),a=a+l):(f=a,m=Math.abs(l),a=a+l),b=l),{label:String(n[t.xKey]??""),base:f,delta:m,display:b,kind:u,color:u==="total"?t.totalColor:u==="decrease"?t.decreaseColor:t.increaseColor}})}const Yr=135*Math.PI/180,nn=270*Math.PI/180;function xd({value:r,min:t=0,max:a=100,height:n=180,className:s="",loading:l=!1,empty:i=!1,emptyText:c="Sin datos para mostrar",label:u,valueFormat:f=rr,tone:m="primary",color:b,thresholds:p,ariaLabel:y="Gauge",animationDuration:N=700,thickness:M=9,showScale:g=!1}){const C=o.useId().replace(/:/g,""),B=a-t||1,A=Math.min(1,Math.max(0,(r-t)/B)),[z,E]=o.useState(N>0?0:A);if(o.useEffect(()=>{if(l||i)return;if(N<=0){E(A);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){E(A);return}let X=0,I=0;E(x=>(I=x,x));const ee=performance.now(),R=x=>{const S=Math.min(1,(x-ee)/N),K=1-(1-S)**3;E(I+(A-I)*K),S<1&&(X=requestAnimationFrame(R))};return X=requestAnimationFrame(R),()=>cancelAnimationFrame(X)},[A,N,l,i]),l)return e.jsx(tr,{height:n});if(i)return e.jsx(ar,{height:n,text:c});const k=100,q=108,H=72,_=b??yd(r,a,m,p),Y=t+z*B,Z=Zo(k,q,H,Yr,Yr+nn),T=Yr+Math.max(.001,z)*nn,J=Zo(k,q,H,Yr,T),O=oa(k,q,H,Yr),j=oa(k,q,H,Yr+nn);return e.jsx("div",{className:`bonsaif-chart bonsaif-gauge-chart flex flex-col items-center justify-center ${s}`,style:{height:n},children:e.jsxs("svg",{viewBox:"0 0 200 168",width:"100%",height:"100%",role:"img","aria-label":y,className:"overflow-visible",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:`bonsaif-gauge-${C}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[e.jsx("stop",{offset:"0%",stopColor:_,stopOpacity:.82}),e.jsx("stop",{offset:"100%",stopColor:_,stopOpacity:1})]})}),e.jsx("path",{d:Z,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:M,strokeLinecap:"butt"}),e.jsx("path",{d:J,fill:"none",stroke:`url(#bonsaif-gauge-${C})`,strokeWidth:M,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),e.jsx("text",{x:k,y:q-(u?4:0),textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:28,fontWeight:700,letterSpacing:"-0.04em",className:"bonsaif-chart-gauge-label",children:f(Y)}),u?e.jsx("text",{x:k,y:q+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:u}):null,g?e.jsxs(e.Fragment,{children:[e.jsx("text",{x:O.x-2,y:O.y+M+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:f(t)}),e.jsx("text",{x:j.x+2,y:j.y+M+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:f(a)})]}):null]})})}function yd(r,t,a,n){if(n!=null&&n.length){const l=[...n].sort((c,u)=>c.value-u.value);let i=l[0].color;for(const c of l)r>=c.value&&(i=c.color);return i}if(a)return sr(a);const s=r/(t||1);return s>=.8?sr("success"):s>=.5?sr("warning"):sr("danger")}function oa(r,t,a,n){return{x:r+a*Math.cos(n),y:t+a*Math.sin(n)}}function Zo(r,t,a,n,s){const l=oa(r,t,a,n),i=oa(r,t,a,s),c=s-n,u=Math.abs(c)>Math.PI?1:0;return`M ${l.x} ${l.y} A ${a} ${a} 0 ${u} 1 ${i.x} ${i.y}`}function wd({value:r,target:t,max:a,ranges:n,height:s=72,className:l="",loading:i=!1,empty:c=!1,emptyText:u="Sin datos para mostrar",label:f,subtitle:m,valueFormat:b=rr,tone:p="primary",showScale:y=!0,showStatus:N=!0,ariaLabel:M="Bullet chart"}){if(i)return e.jsx(tr,{height:s});if(c)return e.jsx(ar,{height:s,text:u});const g=a??Math.max(r,t,...(n==null?void 0:n.map(_=>_.value))??[],1)*1.05,B=[...n??[{value:g*.5,color:"color-mix(in srgb, var(--border) 72%, transparent)"},{value:g*.75,color:"color-mix(in srgb, var(--border) 48%, transparent)"},{value:g,color:"color-mix(in srgb, var(--border) 28%, transparent)"}]].sort((_,Y)=>_.value-Y.value),A=sr(p),z=Math.min(100,Math.max(0,r/g*100)),E=Math.min(100,Math.max(0,t/g*100)),k=r>=t,q=[0,.25,.5,.75,1].map(_=>_*g),H=e.jsxs("div",{className:"bonsaif-bullet-plot min-w-0 flex-1",children:[e.jsxs("div",{className:"bonsaif-bullet-track relative w-full",style:{height:Math.max(22,f?28:s*.42)},role:"img","aria-label":M,children:[e.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:B.map((_,Y)=>{const Z=Y===0?0:B[Y-1].value,T=Math.max(0,(_.value-Z)/g*100);return e.jsx("div",{style:{width:`${T}%`,background:_.color??`color-mix(in srgb, var(--border) ${70-Y*18}%, transparent)`}},Y)})}),e.jsx("div",{className:"absolute left-0 top-1/2 w-full",style:{height:"34%",transform:"translateY(-50%)"},children:e.jsx("div",{className:"bonsaif-bullet-value h-full",style:{width:`${z}%`,background:A,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${A} 35%, transparent)`}})}),e.jsx("div",{className:"bonsaif-bullet-target absolute top-1/2 z-[1]",style:{left:`${E}%`,height:"72%",width:3,transform:"translate(-50%, -50%)",background:A,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${b(t)}`})]}),y?e.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:q.map((_,Y)=>{const Z=_/g*100,T=Y===0,J=Y===q.length-1;return e.jsxs("div",{className:"absolute top-0",style:{left:`${Z}%`,transform:T?"none":J?"translateX(-100%)":"translateX(-50%)"},children:[e.jsx("div",{className:"mx-auto h-1.5 w-px",style:{background:"color-mix(in srgb, var(--text-muted) 55%, transparent)",marginLeft:T?0:J?"auto":void 0,marginRight:J?0:void 0}}),e.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:T?"left":J?"right":"center"},children:b(_)})]},_)})}):null]});return e.jsx("div",{className:`bonsaif-chart bonsaif-bullet-chart w-full ${l}`,children:f?e.jsxs("div",{className:"bonsaif-bullet-row flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-4",children:[e.jsxs("div",{className:"bonsaif-bullet-label shrink-0 sm:w-[7.5rem] sm:pt-1 sm:text-right",children:[e.jsx("div",{className:"text-sm font-semibold tracking-tight",style:{color:"var(--text-main)"},children:f}),m?e.jsx("div",{className:"mt-0.5 text-[11px] leading-snug",style:{color:"var(--text-muted)"},children:m}):e.jsxs("div",{className:"mt-0.5 text-[11px] tabular-nums leading-snug",style:{color:"var(--text-muted)"},children:[e.jsx("span",{style:{color:A,fontWeight:600},children:b(r)}),e.jsxs("span",{children:[" / meta ",b(t)]})]}),N?e.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:sr(k?"success":"warning")},children:k?"En meta":"Bajo meta"}):null]}),H]}):H})}function Nd({data:r,value:t,timeKey:a="t",usageKey:n="usage",series:s,cores:l,height:i=220,className:c="",loading:u=!1,emptyText:f="Sin datos de CPU",showLegend:m=!1,showTooltip:b=!0,thresholds:p,label:y="CPU",ariaLabel:N="Uso de CPU"}){var E;const M=s??[{key:n,label:"Uso",color:Nt(t??Kr(r,n)??0,p)}],g=t??Kr(r,n)??Kr(r,((E=M[0])==null?void 0:E.key)??n),C=!u&&(!r.length||g===null);if(u)return e.jsx(tr,{height:i});if(C)return e.jsx(ar,{height:i,text:f});const B=Math.min(100,Math.max(0,g??0)),A=Rt(B,p),z=Nt(B,p);return e.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":N,children:[e.jsxs("div",{className:"bonsaif-metric-head",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"bonsaif-metric-kicker",children:[y,l!=null?e.jsxs("span",{className:"ml-1.5 normal-case tracking-normal opacity-80",children:["· ",l," ",l===1?"core":"cores"]}):null]}),e.jsx("div",{className:"bonsaif-metric-value",style:{color:z},children:Vr(B,B<10?1:0)})]}),e.jsx("div",{className:"bonsaif-metric-badge",style:{color:z,background:`color-mix(in srgb, ${z} 14%, transparent)`},children:A==="danger"?"Crítico":A==="warning"?"Alto":"Normal"})]}),e.jsx(na,{data:r,xKey:a,series:M.map(k=>({...k,color:k.color??z})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:m,showTooltip:b,valueFormat:k=>Vr(k,0),ariaLabel:N,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function kd({used:r,total:t,cached:a,data:n=[],timeKey:s="t",usageKey:l="usage",height:i=220,className:c="",loading:u=!1,emptyText:f="Sin datos de memoria",showHistory:m=!0,showTooltip:b=!0,thresholds:p,label:y="RAM",ariaLabel:N="Uso de memoria"}){const M=t>0?t:1,g=Math.min(100,Math.max(0,r/M*100)),C=!u&&!(Number.isFinite(r)&&Number.isFinite(t)&&t>0);if(u)return e.jsx(tr,{height:i});if(C)return e.jsx(ar,{height:i,text:f});const B=Rt(g,p),A=Nt(g,p),z=Math.max(0,t-r),E=n.length>0?Kr(n,l)??g:g,k=Nt(E,p),q=m&&n.length>1?Math.max(100,i-110):0;return e.jsxs("div",{className:`bonsaif-chart bonsaif-ram-chart w-full ${c}`,role:"group","aria-label":N,children:[e.jsxs("div",{className:"bonsaif-metric-head",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"bonsaif-metric-kicker",children:y}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"bonsaif-metric-value",style:{color:A},children:Vr(g,g<10?1:0)}),e.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[Gr(r)," / ",Gr(t)]})]})]}),e.jsx("div",{className:"bonsaif-metric-badge",style:{color:A,background:`color-mix(in srgb, ${A} 14%, transparent)`},children:B==="danger"?"Crítico":B==="warning"?"Alto":"Normal"})]}),e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-sm",style:{background:"color-mix(in srgb, var(--border) 55%, transparent)"},role:"progressbar","aria-valuenow":Math.round(g),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${y} ${Vr(g,0)}`,children:e.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${g}%`,background:`linear-gradient(90deg, ${A}, color-mix(in srgb, ${A} 55%, #38bdf8))`}})}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[11px] tabular-nums",style:{color:"var(--text-muted)"},children:[e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Usada"})," ",Gr(r)]}),a!=null&&Number.isFinite(a)?e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",Gr(a)]}):null,e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",Gr(z)]})]})]}),m&&n.length>1?e.jsx(na,{data:n,xKey:s,series:[{key:l,label:"Uso",color:k}],height:q,yDomain:[0,100],showLegend:!1,showTooltip:b,valueFormat:H=>Vr(H,0),ariaLabel:`${N} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const Sd="color-mix(in srgb, var(--primary) 25%, #38bdf8)",Cd="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function Ed({data:r,timeKey:t="t",inboundKey:a="in",outboundKey:n="out",inbound:s,outbound:l,unit:i="bytes",inboundLabel:c="Entrada",outboundLabel:u="Salida",inboundColor:f=Sd,outboundColor:m=Cd,height:b=240,className:p="",loading:y=!1,emptyText:N="Sin datos de red",showLegend:M=!1,showTooltip:g=!0,label:C="Network",ariaLabel:B="Tráfico de red"}){const A=s??Kr(r,a)??0,z=l??Kr(r,n)??0,E=!y&&r.length===0;if(y)return e.jsx(tr,{height:b});if(E)return e.jsx(ar,{height:b,text:N});const k=_=>qo(_,i),H=Math.max(140,b-76);return e.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${p}`,role:"group","aria-label":B,children:[e.jsx("div",{className:"bonsaif-network-header relative z-10 mb-4 grid gap-3 border-b pb-3 sm:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]",style:{borderColor:"var(--border)"},children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"bonsaif-metric-kicker",children:C}),e.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-5 sm:max-w-lg",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[e.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:f},"aria-hidden":!0}),c]}),e.jsx("div",{className:"mt-1 truncate text-xl font-bold tabular-nums leading-tight tracking-tight",style:{color:f},title:k(A),children:k(A)})]}),e.jsxs("div",{className:"min-w-0 pl-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[e.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:m},"aria-hidden":!0}),u]}),e.jsx("div",{className:"mt-1 truncate text-lg font-semibold tabular-nums leading-tight tracking-tight opacity-95",style:{color:m},title:k(z),children:k(z)})]})]})]})}),e.jsx("div",{className:"bonsaif-network-plot relative z-0",children:e.jsx(na,{data:r,xKey:t,series:[{key:a,label:c,color:f},{key:n,label:u,color:m}],height:H,showLegend:M,showTooltip:g,valueFormat:k,ariaLabel:B,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const Qo=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],Jo=["primeSuiteOrigin","primeSuiteProjectKey"];function Md(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const r=new URLSearchParams(window.location.search);for(const t of Qo){const a=r.get(t);if(a){const n=sa(a);if(n)return n}}if(typeof sessionStorage<"u")for(const t of Jo){const a=sessionStorage.getItem(t);if(a)try{const n=new URL(a);if(n.origin&&n.origin!==window.location.origin)return n.origin}catch{const n=sa(a);if(n)return n}}if(document.referrer){const t=sa(document.referrer);if(t&&t!==window.location.origin)return t}return"*"}catch{return"*"}}function Td(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const r=new URLSearchParams(window.location.search);for(const t of Qo)if(r.get(t))return"query";if(typeof sessionStorage<"u"){for(const t of Jo)if(sessionStorage.getItem(t))return"sessionStorage"}if(document.referrer){const t=sa(document.referrer);if(t&&t!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function sa(r){if(!r)return null;const t=r.trim().replace(/\/+$/,"");if(!t)return null;if(/^https?:\/\/[^/]+$/.test(t))return t;try{return new URL(t).origin}catch{return null}}function Ld(r){const[t,a]=o.useState({}),[n,s]=o.useState(!1),l=o.useCallback(f=>n||t[f]?r[f]:void 0,[r,n,t]),i=o.useCallback(f=>{a(m=>({...m,[f]:!0}))},[]),c=o.useCallback(()=>{s(!0)},[]),u=o.useCallback(()=>{a({}),s(!1)},[]);return{submitted:n,touchedFields:t,getFieldError:l,touchField:i,submit:c,reset:u}}Object.defineProperty(P,"toast",{enumerable:!0,get:()=>Nn.toast}),P.Alert=Qs,P.AreaChart=na,P.AuthShell=Po,P.BarChart=ud,P.BonsaifButton=Bs,P.BonsaifUIToaster=od,P.BulletChart=wd,P.Button=He,P.CHART_PALETTE=Jt,P.CalendarPicker=tl,P.ChartCard=sd,P.Checkbox=Ft,P.CodeBlock=ll,P.ComboChart=hd,P.CompactFilterSelect=dl,P.CompactSearchInput=cl,P.ConfirmDialog=pl,P.CopyButton=Ba,P.CopyLinkButton=vl,P.CpuChart=Nd,P.DataSheets=Ul,P.DataTable=qn,P.DateRangePicker=Kl,P.DonutChart=bd,P.Drawer=Jl,P.DropdownMenu=Zl,P.DynamicDetailTabs=Ys,P.EmailField=wi,P.EmptyState=ki,P.FieldLayoutEditor=Li,P.FileUpload=Mi,P.FormField=ro,P.GaugeChart=xd,P.GlobalScrollbars=Ao,P.InputField=Ua,P.LineChart=dd,P.LoadingState=$n,P.MentionTextEditor=ko,P.MicroserviceFrame=ed,P.Modal=Pa,P.MouseTooltip=jr,P.MultiSelect=Ai,P.NetworkChart=Ed,P.NumberField=Di,P.PageHeader=Qc,P.PageSearchInput=Cn,P.Pagination=Bi,P.PhoneField=Hi,P.PieChart=fd,P.PrimeAuthRouteShell=Jc,P.PrimeSuiteChatFrame=rd,P.RadioGroup=Pi,P.RamChart=kd,P.RichTextEditor=oc,P.SearchableSelect=Er,P.SectionPanel=sc,P.Sparkline=md,P.StatusBadge=cc,P.StatusSelect=pc,P.StepWizard=hc,P.TableSkeleton=Pt,P.Tabs=mc,P.TagInput=Ec,P.TextInput=Kt,P.Textarea=Co,P.TextareaField=wc,P.Toggle=Tc,P.UserAvatar=Ho,P.WaterfallChart=gd,P.buildMentionQueryRegex=po,P.cn=hr,P.configureBonsaifUI=wl,P.dedupeMentions=vo,P.defaultValueFormat=rr,P.describeParentTargetOrigin=Td,P.emailFormat=ni,P.extractMentionUsernames=Qa,P.filterSelfMentions=rc,P.findMentionTriggerInEditor=Ya,P.formatBytes=Gr,P.formatPercent=Vr,P.formatRate=qo,P.getBonsaifUIConfig=Nl,P.getDataTablePreferencesEndpoint=Fa,P.getPlainTextOffset=Ja,P.highlightMentions=xo,P.htmlToText=go,P.insertMentionInEditor=yo,P.isMentionTriggerBoundary=ho,P.isPlainOffsetInsideMentionChip=mo,P.isValidEmail=ja,P.isValidPhone=Wa,P.locateTextOffset=Ur,P.matches=di,P.maxLength=li,P.maxValue=ci,P.minLength=si,P.minValue=ii,P.normalizeUsername=Za,P.phoneCountryCodeOptions=no,P.phoneFormat=oi,P.placeCaretAtTextOffset=wo,P.required=ai,P.resetBonsaifUIConfig=kl,P.resolveMentions=ec,P.resolveParentTargetOrigin=Md,P.seriesColor=Wo,P.setBonsaifDataTablePreferencesEndpoint=Sl,P.toneColor=sr,P.usageColor=Nt,P.usageTone=Rt,P.useValidationVisibility=Ld,P.validateForm=ui,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})}));