bonsaif-ui 0.1.104 → 0.1.105

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,T,er,ve,Hn,$a,Aa,Da,Ou,Vs){"use strict";"use client";function gr(...r){return r.filter(Boolean).join(" ")}function Gs({variant:r="primary",className:t,type:n="button",children:a,...s}){return e.jsx("button",{className:gr("bonsaif-ui-button",`bonsaif-ui-button--${r}`,t),type:n,...s,children:a})}function Ia({value:r,onChange:t,placeholder:n,className:a="",autoFocus:s=!1,forceExpanded:l=!1,onEscape:i,size:c="default",inputTabIndex:u}){const f=o.useRef(null),[p,b]=o.useState(!1),m=l||p||r.trim().length>0,v=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",y=a||"w-48 max-w-full sm:w-64 lg:w-72";o.useEffect(()=>{var h;s&&((h=f.current)==null||h.focus())},[s]);const S=()=>{var h;b(!0),(h=f.current)==null||h.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:h=>{m||(h.preventDefault(),S())},children:[e.jsx(T.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":n,value:r,onChange:h=>t(h.target.value),onKeyDown:h=>{h.key==="Escape"&&(i==null||i())},placeholder:m?n:"Buscar",className:`${v} 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:h=>{b(!0),h.currentTarget.style.borderColor="var(--primary)",h.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:h=>{b(!1),h.currentTarget.style.borderColor="var(--border)",h.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(T.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const Ba=o.createContext({});let Oa=0;const Ha="bonsaif-ui:hide-tooltips";function zt(r=700){Oa=Date.now()+r}function Ks(){return Date.now()>Oa}function _t(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(n=>n.contains(r))?!1:t.length>0}function Xs(r){var a;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)&&(((a=t[0])==null?void 0:a.textContent)??r.textContent??"").trim()||null}function Mr({children:r,content:t,onlyWhenOverflow:n=!1,interactive:a=!1,followCursor:s=!0,placement:l="bottom",showArrow:i=!1,className:c="",tooltipClassName:u="",style:f,tooltipStyle:p,as:b="div"}){const m=o.useRef(null),v=o.useRef(null),y=o.useRef(null),S=o.useRef(!1),[h,P]=o.useState(null),[O,E]=o.useState("");o.useEffect(()=>{const C=m.current;C&&(C.querySelectorAll("[title]").forEach(re=>{const W=re.getAttribute("title");W&&(re.getAttribute("aria-label")||re.setAttribute("aria-label",W),re.removeAttribute("title"))}),C.querySelectorAll("svg title").forEach(re=>re.remove()))}),o.useLayoutEffect(()=>{if(!h)return;const C=v.current;if(!C)return;const re=12,W=14,j=C.getBoundingClientRect(),ae=window.innerWidth-j.width-re,Z=window.innerHeight-j.height-re;let $=h.mouseX+W,ee=h.mouseY+W,se,M;if(!s&&m.current){const H=m.current.getBoundingClientRect(),oe=H.left+H.width/2,A=H.top+H.height/2;l==="top"?($=oe-j.width/2,ee=H.top-j.height-W,M=j.height-1):l==="left"?($=H.left-j.width-W,ee=A-j.height/2,se=j.width-1):l==="right"?($=H.right+W,ee=A-j.height/2,se=-7):($=oe-j.width/2,ee=H.bottom+W,M=-7)}if(s&&($>ae&&($=h.mouseX-j.width-W),ee>Z&&(ee=h.mouseY-j.height-W)),$=Math.min(Math.max(re,$),Math.max(re,ae)),ee=Math.min(Math.max(re,ee),Math.max(re,Z)),!s&&m.current){const H=m.current.getBoundingClientRect(),oe=H.left+H.width/2,A=H.top+H.height/2;l==="top"||l==="bottom"?se=Math.min(Math.max(14,oe-$),j.width-14):M=Math.min(Math.max(14,A-ee),j.height-14)}(Math.abs($-h.x)>.5||Math.abs(ee-h.y)>.5||se!==h.arrowX||M!==h.arrowY)&&P(H=>H&&{...H,x:$,y:ee,arrowX:se,arrowY:M})},[s,l,h]);const L=()=>{y.current&&(window.clearTimeout(y.current),y.current=null)},N=(C,re)=>{if(!Ks()||S.current)return;const W=m.current;if(W&&!_t(W)){if(n){const j=Xs(W);if(!j)return;E(j)}!n&&!t||P({mouseX:C,mouseY:re,x:C+14,y:re+14})}},k=()=>{const C=m.current;if(!C)return;const re=C.getBoundingClientRect();N(re.left+re.width/2,re.bottom)},Y=()=>{L(),P(null)},F=()=>{if(!a){Y();return}L(),y.current=window.setTimeout(()=>P(null),120)},U=()=>{zt(),S.current=!0,Y()},V=()=>{S.current=!1};o.useEffect(()=>{if(!h)return;if(_t(m.current)){P(null);return}const C=()=>P(null),re=()=>{zt(),S.current=!0,P(null)};document.addEventListener("pointerdown",re,!0),document.addEventListener("click",re,!0),document.addEventListener("scroll",C,!0),window.addEventListener("blur",C),document.addEventListener("visibilitychange",C),document.addEventListener("keydown",C,!0);const W=new MutationObserver(()=>{_t(m.current)&&P(null)});return W.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",re,!0),document.removeEventListener("click",re,!0),document.removeEventListener("scroll",C,!0),window.removeEventListener("blur",C),document.removeEventListener("visibilitychange",C),document.removeEventListener("keydown",C,!0),W.disconnect()}},[h]),o.useEffect(()=>{const C=()=>zt(),re=()=>{zt(),S.current=!0,P(null)};return document.addEventListener("pointerdown",C,!0),document.addEventListener("click",C,!0),document.addEventListener("keydown",C,!0),window.addEventListener(Ha,re),()=>{document.removeEventListener("pointerdown",C,!0),document.removeEventListener("click",C,!0),document.removeEventListener("keydown",C,!0),window.removeEventListener(Ha,re)}},[]);const J=n?O:t;return e.jsxs(e.Fragment,{children:[e.jsx(b,{ref:C=>{m.current=C},className:c,style:f,onMouseEnter:C=>{L(),V(),s?N(C.clientX,C.clientY):k()},onMouseMove:C=>{h&&s&&N(C.clientX,C.clientY)},onMouseDown:U,onClick:U,onMouseLeave:()=>{V(),F()},onFocus:k,onBlur:Y,children:r}),h&&J&&!_t(m.current)?er.createPortal(e.jsxs("div",{ref:v,role:"tooltip",className:u,onMouseEnter:a?L:void 0,onMouseLeave:a?F:void 0,style:{position:"fixed",top:h.y,left:h.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:a?"auto":"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere",...p},children:[i&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",width:12,height:12,background:(p==null?void 0:p.background)??"var(--bg-card)",borderLeft:l==="right"?(p==null?void 0:p.border)??"1px solid var(--border)":void 0,borderTop:l==="bottom"||l==="right"?(p==null?void 0:p.border)??"1px solid var(--border)":void 0,borderRight:l==="left"?(p==null?void 0:p.border)??"1px solid var(--border)":void 0,borderBottom:l==="top"||l==="left"?(p==null?void 0:p.border)??"1px solid var(--border)":void 0,transform:"rotate(45deg)",left:h.arrowX===void 0?void 0:h.arrowX-6,top:h.arrowY===void 0?void 0:h.arrowY-6,zIndex:-1}}),J]}),document.body):null]})}function Pa(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}const Ys="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",Zs={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"},Qs="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",Js={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"},Rs={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},el={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function Pn(r){return typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(Pn).join(" ").trim():o.isValidElement(r)?Pn(r.props.children):""}function rl(r){return o.Children.toArray(r).find(o.isValidElement)??null}function Fe({variant:r="primary",size:t="md",loading:n=!1,icon:a,tooltip:s,iconOnly:l,height:i,padding:c,children:u,className:f="",disabled:p,style:b,...m}){const v=o.useContext(Ba),y=l??v.iconOnly??r==="icon",S=v.compact??!1,h=v.headerAction??!1,P=h&&t==="md"?"sm":S&&!h&&t==="md"?"xs":t,O=r==="icon"||y,E=h&&O,L=Pn(u),N=s??m.title??m["aria-label"]??(y?L:void 0),k=N?void 0:m.title,Y=m["aria-label"]??(typeof N=="string"?N:L||void 0),F=n?null:a??(y?rl(u):null),U=e.jsxs("button",{...m,title:k,"aria-label":Y,"data-variant":r,"data-size":P,"data-icon":O?"true":void 0,disabled:p||n,className:`${Ys} ${E?Qs:Zs[r]} ${O?Rs[P]:Js[P]} ${S&&!O?"px-2.5":""} ${f}`,style:{...el[r],height:Pa(i),padding:Pa(c),...b,...h&&!O?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...E?{width:"var(--page-header-control-height, 40px)",height:"var(--page-header-control-height, 40px)",padding:0,background:"var(--bg-card)",borderRadius:"8px"}:null},children:[n?e.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):F,!y&&u]});return N?e.jsx(Mr,{as:"span",content:N,className:"inline-flex shrink-0",children:U}):U}const Ge={background:"color-mix(in srgb, var(--text-muted) 26%, var(--bg-input))"};function jt({rows:r=8,columns:t=7,showToolbar:n=!0,showPagination:a=!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:[n&&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((p,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:{...Ge,width:`${48+b*17%40}%`}})},`h-${b}`)),Array.from({length:c}).map((p,b)=>Array.from({length:i}).map((m,v)=>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:{...Ge,width:`${46+(b*13+v*11)%42}%`,minWidth:28}})},`c-${b}-${v}`)))]})}),a&&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((p,b)=>e.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:Ge},b))}),e.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:Ge})]})]})}function tl({size:r="md"}){const t=r==="sm"?"h-7 w-7":"h-9 w-9";return e.jsx("div",{className:`${t} animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]`,"aria-hidden":!0})}function nl({logoSrc:r,logoAlt:t}){return r?e.jsxs("span",{className:"relative flex h-16 w-16 items-center justify-center","aria-hidden":!1,children:[e.jsx("span",{className:"absolute inset-0 rounded-2xl opacity-40 blur-xl",style:{background:"radial-gradient(circle, color-mix(in srgb, var(--primary) 45%, transparent) 0%, transparent 70%)"}}),e.jsx("img",{src:r,alt:t,className:"relative h-14 w-14 rounded-2xl object-contain shadow-sm shadow-black/10"})]}):null}function Fa({variant:r="page",title:t="Cargando...",description:n,logoSrc:a,logoAlt:s,appearance:l="card",rows:i=6,columns:c=7,children:u,className:f=""}){if(r==="table")return e.jsx(jt,{rows:i,columns:c,className:f});if(r==="sections")return e.jsx(al,{rows:i});if(r==="cards")return e.jsx(ol,{rows:i});const p=s||(typeof t=="string"?t:"Aplicación"),b=l==="bare",m=e.jsxs("div",{className:`flex flex-col items-center text-center ${b?"gap-5":"gap-3"}`,children:[a?e.jsx(nl,{logoSrc:a,logoAlt:p}):null,e.jsx(tl,{size:b?"md":"sm"}),e.jsxs("div",{className:b?"space-y-1.5":"",children:[e.jsx("p",{className:b?"text-base font-semibold tracking-tight text-[var(--text-main)]":"text-sm font-semibold text-[var(--text-main)]",children:t}),n?e.jsx("p",{className:b?"text-sm font-medium text-[var(--text-muted)]":"mt-1 text-xs text-[var(--text-muted)]",children:n}):null,u&&e.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:u})]})]});return b?e.jsx("div",{className:`flex min-h-[240px] w-full items-center justify-center p-8 ${f}`,role:"status","aria-live":"polite","aria-busy":"true",children:m}):e.jsx("div",{className:`flex min-h-[240px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 ${f}`,role:"status","aria-live":"polite","aria-busy":"true",children:m})}function al({rows:r}){return e.jsx(jt,{rows:r,columns:7})}function ol({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,n)=>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})]},n))})}function za(r){const t=r.split("/").filter(Boolean);return(t[t.length-1]??r).replace(/^lv_/,"").split(/[-_]/).filter(Boolean).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}function _a(r){return r.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function sl(r){return[r.label,za(r.service),r.description,r.service].filter(Boolean).join(" ")}function ll(r){return typeof r=="function"?r:r.default}function il(r,t){return e.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 text-center",children:e.jsxs("div",{className:"max-w-md",children:[e.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:"No se pudo cargar este modulo"}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:r.message}),e.jsx(Fe,{className:"mt-4",height:36,padding:"0 14px",onClick:t,children:"Reintentar"})]})})}function cl({parentPanel:r,parentPanelComponent:t,renderParentPanel:n,parent:a,context:s,links:l,moduleRegistry:i,loadModule:c,activeService:u,initialService:f,onActiveServiceChange:p,canAccess:b,keepAlive:m=!0,title:v,subtitle:y,emptyState:S,loadingState:h,errorState:P=il,renderTabLabel:O,searchableTabs:E="auto",tabsSearchThreshold:L=6,tabsSearchPlaceholder:N="Buscar modulo...",tabsSearchValue:k,onTabsSearchChange:Y,emptySearchState:F,showTabCount:U=!0,className:V="",parentClassName:J="",contentClassName:C="",tabsClassName:re=""}){var lr;const W=o.useMemo(()=>l.filter(fe=>!fe.hidden&&((b==null?void 0:b(fe,s))??!0)),[b,s,l]),j=(lr=W.find(fe=>!fe.disabled))==null?void 0:lr.service,[ae,Z]=o.useState(f??j??""),[$,ee]=o.useState({}),[se,M]=o.useState({}),[H,oe]=o.useState(""),[A,q]=o.useState(!1),ne=o.useRef(se),ie=o.useRef(0),Q=k??H,G=_a(Q),w=E===!0||E==="auto"&&W.length>=L,R=w&&Q.trim().length>0,B=o.useMemo(()=>G?W.filter(fe=>_a(sl(fe)).includes(G)):W,[G,W]),te=u??ae,z=W.find(fe=>fe.service===te)??W.find(fe=>!fe.disabled);o.useEffect(()=>{!z&&j&&Z(j)},[j,z]),o.useEffect(()=>{ne.current=se},[se]);const le=fe=>{fe.disabled||(u||Z(fe.service),p==null||p(fe.service,fe))},Ee=fe=>{k===void 0&&oe(fe),Y==null||Y(fe)},Le=(fe,I)=>{const X=B.filter(be=>!be.disabled),ue=X.findIndex(be=>be.service===I.service);ue<0||((fe.key==="ArrowRight"||fe.key==="ArrowDown")&&(fe.preventDefault(),le(X[(ue+1)%X.length])),(fe.key==="ArrowLeft"||fe.key==="ArrowUp")&&(fe.preventDefault(),le(X[(ue-1+X.length)%X.length])),fe.key==="Home"&&(fe.preventDefault(),le(X[0])),fe.key==="End"&&(fe.preventDefault(),le(X[X.length-1])))},xe=o.useCallback(()=>{if(!z)return;const fe=z.service,I=ne.current[fe];if(I!=null&&I.loading||I!=null&&I.component&&m)return;const X=(i==null?void 0:i[fe])??c;if(!X){M(be=>({...be,[fe]:{loading:!1,error:new Error(`No module loader found for service "${fe}".`)}}));return}const ue=++ie.current;M(be=>({...be,[fe]:{...be[fe],loading:!0,error:void 0}})),X(z,s).then(be=>{if(ue!==ie.current&&!m)return;const De=ll(be);M(Ce=>({...Ce,[fe]:{component:De,loading:!1}}))}).catch(be=>{const De=be instanceof Error?be:new Error(String(be));M(Ce=>({...Ce,[fe]:{...Ce[fe],loading:!1,error:De}}))})},[s,m,c,i,z]);o.useEffect(xe,[xe]);const Se=z?$[z.service]??null:null,Te=z?se[z.service]:void 0,kr=Te==null?void 0:Te.component,pr=fe=>{z&&ee(I=>({...I,[z.service]:fe}))},qe=()=>{z&&ee(fe=>({...fe,[z.service]:null}))},ce={context:s,parent:a,links:l,visibleLinks:W,filteredLinks:B,selectedLink:z,selectedService:z==null?void 0:z.service,activeItemId:Se,tabsSearch:Q,onSelectService:le,onOpenDetail:pr,onBackToList:qe},Qe=n?n(ce):t?e.jsx(t,{...ce}):r;return e.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${V}`,children:[e.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${J}`,children:Qe}),e.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${C}`,children:[(v||y||w||U)&&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:[v&&e.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:v}),y&&e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:y})]}),(w||U)&&e.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[U&&e.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[B.length," / ",W.length]}),w&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${A?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!A,children:e.jsx(Ia,{value:Q,onChange:Ee,placeholder:N,className:"w-full",autoFocus:A,forceExpanded:!0,onEscape:()=>q(!1),size:"sm",inputTabIndex:A?0:-1})}),e.jsx("button",{type:"button","aria-label":A?"Cerrar busqueda":"Buscar tabs","aria-expanded":A,onClick:()=>{A&&Q&&Ee(""),q(fe=>!fe)},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 ${A||R?"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:A||R?e.jsx(T.HiXMark,{className:"h-4 w-4"}):e.jsx(T.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),e.jsx("div",{role:"tablist","aria-label":v??"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 ${re}`,children:B.length>0?B.map(fe=>{const I=fe.service===(z==null?void 0:z.service);return e.jsx("button",{type:"button",role:"tab","aria-selected":I,disabled:fe.disabled,onClick:()=>le(fe),onKeyDown:X=>Le(X,fe),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 ${I?"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:O?O(fe,I):e.jsxs(e.Fragment,{children:[fe.icon,e.jsx("span",{children:fe.label??za(fe.service)}),fe.badge&&e.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:fe.badge})]})},fe.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:F??"No hay modulos que coincidan con la busqueda."})}),(z==null?void 0:z.description)&&e.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:z.description}),e.jsxs("div",{className:"min-h-[420px] p-4",children:[!z&&(S??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."})),z&&(Te==null?void 0:Te.loading)&&(h??e.jsx(Fa,{title:"Cargando modulo..."})),z&&(Te==null?void 0:Te.error)&&P(Te.error,xe),z&&kr&&!(Te!=null&&Te.loading)&&!(Te!=null&&Te.error)&&e.jsx(kr,{context:s,parent:a,link:z,activeItemId:Se,onOpenDetail:pr,onBackToList:qe})]})]})]})}const dl={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:e.jsx(T.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(T.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(T.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(T.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:e.jsx(T.HiInformationCircle,{className:"h-5 w-5"})}};function ul({variant:r="info",title:t,children:n,icon:a,action:s,onDismiss:l,className:i=""}){const c=dl[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:a??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}),n&&e.jsx("div",{className:"mt-0.5 text-sm leading-5 text-[var(--text-secondary)]",children:n}),s&&e.jsx("div",{className:"mt-3",children:s})]}),l&&e.jsx(Fe,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:e.jsx(T.HiXMark,{className:"h-4 w-4"})})]})}const ja=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],fl=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],bl=["Do","Lu","Ma","Mi","Ju","Vi","Sá"],Fn=6;function zn(r,t,n){return`${r}-${String(t).padStart(2,"0")}-${String(n).padStart(2,"0")}`}function pl(){const r=new Date;return zn(r.getFullYear(),r.getMonth()+1,r.getDate())}function Wa(r){const[t,n,a]=r.split("-").map(Number);return{year:t,month:n,day:a}}function ml(r){if(!r)return"Seleccionar fecha";const{year:t,month:n,day:a}=Wa(r);return!t||!n||!a?"Seleccionar fecha":`${String(a).padStart(2,"0")} ${ja[n-1]} ${t}`}function hl({value:r,onChange:t,minDate:n,displayMode:a="inline"}){const s=pl(),i=Wa(r||s),c=a==="popover",[u,f]=o.useState(!1),p=o.useRef(null),[b,m]=o.useState({horizontal:"left",vertical:"bottom"}),[v,y]=o.useState(i.year),[S,h]=o.useState(i.month),[P,O]=o.useState("days"),E=16,[L,N]=o.useState(0),k=v-7+L,Y=Array.from({length:E},(Z,$)=>k+$);o.useEffect(()=>{if(!c||!u||!p.current)return;const Z=p.current.getBoundingClientRect(),$=8,ee=280,se=340,M=Z.left+ee>window.innerWidth-$,H=Z.right-ee>=$,oe=Z.bottom+8+se>window.innerHeight-$,A=Z.top-8-se>=$;m({horizontal:M&&H?"right":"left",vertical:oe&&A?"top":"bottom"})},[c,u]),o.useEffect(()=>{if(!c||!u)return;function Z(ee){p.current&&(p.current.contains(ee.target)||f(!1))}function $(ee){ee.key==="Escape"&&f(!1)}return document.addEventListener("mousedown",Z),document.addEventListener("keydown",$),()=>{document.removeEventListener("mousedown",Z),document.removeEventListener("keydown",$)}},[c,u]);function F(){S===1?(y(Z=>Z-1),h(12)):h(Z=>Z-1)}function U(){S===12?(y(Z=>Z+1),h(1)):h(Z=>Z+1)}const V=new Date(v,S-1,1).getDay(),J=new Date(v,S,0).getDate(),C=[...Array(V).fill(null),...Array.from({length:J},(Z,$)=>$+1)];for(;C.length<Fn*7;)C.push(null);const re=C.slice(0,Fn*7);function W(Z){const $=zn(v,S,Z);n&&$<n||(t($),c&&f(!1))}const j={background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,borderRadius:6,display:"flex",alignItems:"center"},ae=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:P==="days"?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:F,style:j,title:"Mes anterior",children:e.jsx(T.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>{O("years"),N(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:[ja[S-1]," ",v,e.jsx(T.HiChevronDown,{size:13,style:{color:"var(--text-muted)"}})]}),e.jsx("button",{type:"button",onClick:U,style:j,title:"Mes siguiente",children:e.jsx(T.HiChevronRight,{size:16})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>N(Z=>Z-E),style:j,children:e.jsx(T.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>O("days"),style:{background:"none",border:"none",cursor:"pointer",fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[Y[0]," – ",Y[Y.length-1]]}),e.jsx("button",{type:"button",onClick:()=>N(Z=>Z+E),style:j,children:e.jsx(T.HiChevronRight,{size:16})})]})}),P==="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:fl.map((Z,$)=>{const ee=$+1===S;return e.jsx("button",{type:"button",onClick:()=>h($+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:Z},Z)})}),e.jsx("div",{style:{height:1,background:"var(--border)",marginBottom:8}}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3},children:Y.map(Z=>{const $=Z===v;return e.jsx("button",{type:"button",onClick:()=>{y(Z),O("days")},style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:12,fontWeight:$?700:400,padding:"6px 0",background:$?"var(--primary)":"transparent",color:$?"var(--primary-fg, #ffffff)":"var(--text-main)",outline:Z===new Date().getFullYear()&&!$?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:Z},Z)})})]}),P==="days"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",padding:"6px 8px 0"},children:bl.map(Z=>e.jsx("div",{style:{textAlign:"center",fontSize:10,fontWeight:700,color:"var(--text-muted)",padding:"2px 0",textTransform:"uppercase"},children:Z},Z))}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",gridTemplateRows:`repeat(${Fn},1fr)`,padding:"4px 8px 10px",gap:2},children:re.map((Z,$)=>{if(Z===null)return e.jsx("div",{style:{aspectRatio:"1"}},$);const ee=zn(v,S,Z),se=ee===r,M=ee===s,H=!!(n&&ee<n);return e.jsx("button",{type:"button",onClick:()=>!H&&W(Z),style:{width:"100%",aspectRatio:"1",borderRadius:6,border:"none",cursor:H?"not-allowed":"pointer",fontSize:12,fontWeight:se||M?700:400,background:se?"var(--primary)":"transparent",color:se?"var(--primary-fg, #ffffff)":H?"var(--text-muted)":"var(--text-main)",opacity:H?.4:1,outline:M&&!se?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:Z},$)})})]})]});return c?e.jsxs("div",{ref:p,className:"relative w-full",children:[e.jsxs("button",{type:"button",onClick:()=>f(Z=>!Z),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(T.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),e.jsx("span",{className:"truncate",children:ml(r)})]}),e.jsx(T.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:ae})]}):ae}const gl={sm:"h-4 w-4",md:"h-5 w-5"};function vl(r,t){if(typeof r=="function"){r(t);return}r&&(r.current=t)}const Wt=o.forwardRef(function({label:t,description:n,error:a,size:s="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:u,...f},p){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:m=>{b.current=m,vl(p,m)},type:"checkbox",disabled:u,"aria-checked":l?"mixed":f["aria-checked"],"aria-invalid":!!a||f["aria-invalid"],className:`peer ${gl[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(T.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||n||a)&&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}),n&&!a&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:n}),a&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--danger)]",children:a})]})]})});function qa(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 xl(r){var t;if((t=navigator.clipboard)!=null&&t.writeText){await navigator.clipboard.writeText(r);return}qa(r)}function yl(r){return typeof r=="function"?r():r}function _n({value:r,resetDelay:t=2e3,title:n,copiedTitle:a="Copiado",copiedLabel:s,icon:l=e.jsx(T.HiClipboardDocument,{size:14}),copiedIcon:i=e.jsx(T.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:u,onCopyError:f,className:p="",style:b,children:m,onClick:v,type:y="button",...S}){const[h,P]=o.useState(!1),O=o.useRef(null);o.useEffect(()=>()=>{O.current&&window.clearTimeout(O.current)},[]);function E(N){P(!0),u==null||u(N),O.current&&window.clearTimeout(O.current),O.current=window.setTimeout(()=>{P(!1),O.current=null},t)}async function L(N){var Y;if(c&&N.stopPropagation(),v==null||v(N),N.defaultPrevented)return;const k=yl(r);if(k)try{await xl(k),E(k)}catch(F){try{qa(k),E(k)}catch(U){f==null||f(U,k);return}(Y=navigator.clipboard)!=null&&Y.writeText||f==null||f(F,k)}}return e.jsxs("button",{...S,type:y,onClick:L,title:h?a:n,"aria-label":S["aria-label"]??(h?a:n),"data-copied":h?"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"} ${p}`,style:{cursor:"pointer",background:h?"rgba(22,163,74,0.15)":"var(--bg-card)",border:h?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:h?"#16a34a":"var(--text-secondary)",boxShadow:h?"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:h?"scale(1.15)":"scale(1)"},children:h?i:l}),m&&e.jsx("span",{className:"text-xs font-semibold leading-none",children:h?s??m:m})]})}function wl({code:r,children:t,title:n="Codigo",language:a,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:n}),e.jsx(_n,{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:a?`language-${a}`:void 0,children:f})})]})}function jn(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Wn(r){return r.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function kl(r,t){if(!t.trim())return!0;const n=Wn(t);return Wn(r.label).includes(n)||!!(r.sublabel&&Wn(r.sublabel).includes(n))}function Lr({value:r,onChange:t,options:n,status:a="default",ariaLabel:s,triggerVariant:l="default",showSelectedSublabel:i=!0,placeholder:c="Seleccionar…",emptyLabel:u,disabled:f=!1,className:p="",style:b,dropdownMinWidth:m,height:v=40,padding:y="0 10px",searchable:S=!0,minOptionsForSearch:h=6}){const[P,O]=o.useState(!1),[E,L]=o.useState(""),[N,k]=o.useState(-1),[Y,F]=o.useState(!1),[U,V]=o.useState({}),J=o.useRef(null),C=o.useRef(null),re=o.useRef(null),W=o.useRef(null),j=S&&n.length>=h,ae=n.find(Q=>Q.value===r)??null,Z=l==="ghost",$=a==="error"?"var(--danger)":P?"var(--primary)":"var(--border)",ee=j&&E.trim()?n.filter(Q=>kl(Q,E)):n,se=o.useCallback(()=>{const Q=J.current;if(!Q)return;const G=Q.getBoundingClientRect(),w=j?272:212,R=window.innerHeight-G.bottom,B=R<w&&G.top>R;V({position:"fixed",left:G.left,top:B?void 0:G.bottom+4,bottom:B?window.innerHeight-G.top+4:void 0,width:G.width,minWidth:jn(m),zIndex:9999})},[m,j]);o.useEffect(()=>F(!0),[]),o.useEffect(()=>{if(!P)return;function Q(G){var R,B;const w=G.target;!((R=J.current)!=null&&R.contains(w))&&!((B=C.current)!=null&&B.contains(w))&&(O(!1),L(""))}return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[P]),o.useEffect(()=>{P&&(k(-1),se(),j&&setTimeout(()=>{var Q;return(Q=re.current)==null?void 0:Q.focus()},0))},[P,j,se]),o.useEffect(()=>{if(P)return window.addEventListener("resize",se),window.addEventListener("scroll",se,!0),()=>{window.removeEventListener("resize",se),window.removeEventListener("scroll",se,!0)}},[P,se]),o.useEffect(()=>{if(N<0||!W.current)return;const Q=W.current.children[N];Q==null||Q.scrollIntoView({block:"nearest"})},[N]);const M=o.useCallback(Q=>{t(Q),O(!1),L("")},[t]),H=o.useRef(P);H.current=P;const oe=o.useRef(ee);oe.current=ee;const A=o.useRef(N);A.current=N;const q=o.useRef(u);q.current=u;const ne=o.useRef(M);ne.current=M,o.useEffect(()=>{function Q(G){var te,z;const w=document.activeElement,R=((te=J.current)==null?void 0:te.contains(w))??!1,B=((z=C.current)==null?void 0:z.contains(w))??!1;if(!(!R&&!B)){if(!H.current){(G.key==="Enter"||G.key===" "||G.key==="ArrowDown")&&(G.preventDefault(),O(!0));return}switch(G.key){case"ArrowDown":G.preventDefault(),k(le=>Math.min(le+1,oe.current.length-1));break;case"ArrowUp":G.preventDefault(),k(le=>Math.max(le-1,q.current?-1:0));break;case"Enter":{G.preventDefault();const le=A.current,Ee=oe.current;le===-1&&q.current?ne.current(""):Ee[le]&&!Ee[le].disabled&&ne.current(Ee[le].value);break}case"Escape":G.preventDefault(),G.stopPropagation(),O(!1),L("");break}}}return document.addEventListener("keydown",Q),()=>document.removeEventListener("keydown",Q)},[]);const ie=e.jsxs("div",{ref:C,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...U,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(T.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:re,value:E,onChange:Q=>{L(Q.target.value),k(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),E&&e.jsx("button",{type:"button",onMouseDown:Q=>{Q.preventDefault(),L("")},children:e.jsx(T.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),e.jsxs("ul",{ref:W,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:Q=>{Q.preventDefault(),M("")},onMouseEnter:()=>k(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:N===-1&&!E.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:u}),ee.map((Q,G)=>{const R=G===N,B=Q.value===r;return e.jsxs("li",{role:"option","aria-selected":B,onMouseDown:te=>{te.preventDefault(),Q.disabled||M(Q.value)},onMouseEnter:()=>!Q.disabled&&k(G),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:R?"var(--bg-hover)":B?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:Q.disabled?"var(--text-muted)":"var(--text-main)",cursor:Q.disabled?"not-allowed":"pointer",boxShadow:B?"inset 2px 0 0 var(--primary)":void 0},children:[Q.color&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:Q.color}}),e.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:Q.label}),Q.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:Q.sublabel})]}),Q.badge&&e.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:Q.badge})]},Q.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:J,className:`relative ${p||"w-full"}`,style:b,children:[e.jsxs("button",{type:"button",disabled:f,onClick:()=>!f&&O(Q=>!Q),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:jn(v),padding:jn(y),background:Z?"transparent":"var(--bg-input)",color:ae?"var(--text-main)":"var(--text-muted)",border:Z?"1px solid transparent":`1px solid ${$}`,opacity:f?.5:1,cursor:f?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":P,"aria-label":s,children:[(ae==null?void 0:ae.color)&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:ae.color}}),e.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:ae?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"truncate",children:ae.label}),i&&ae.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:ae.sublabel})]}):e.jsx("span",{className:"truncate",children:c})}),ae&&u?e.jsx("span",{role:"button",tabIndex:-1,onMouseDown:Q=>{Q.preventDefault(),Q.stopPropagation(),M("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(T.HiXMark,{className:"w-3 h-3"})}):e.jsx(T.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:P?"rotate(180deg)":"rotate(0deg)"}})]}),P&&Y&&er.createPortal(ie,document.body)]})}function qt(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Nl({value:r,onChange:t,placeholder:n="Buscar...",className:a="",height:s=40,padding:l="0 10px 0 30px",iconLeft:i=10}){return e.jsxs("div",{className:`relative ${a}`,children:[e.jsx(T.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:qt(i)}}),e.jsx("input",{type:"text",value:r,onChange:c=>t(c.target.value),placeholder:n,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:qt(s),padding:qt(l)}})]})}function Sl({value:r,onChange:t,options:n,placeholder:a,icon:s,className:l="",height:i=40,padding:c,iconLeft:u=10,searchable:f=!0}){const p=s?n.map((b,m)=>m===0&&!b.color?{...b,sublabel:b.sublabel??void 0}:b):n;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:qt(u)},children:s}),e.jsx(Lr,{value:r,onChange:t,options:p,placeholder:a,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 Cl={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},Ut=180,El="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function qn({open:r,onClose:t,title:n,subtitle:a,leadingIcon:s,headerActions:l,footer:i,children:c,size:u="md",maxWidth:f,zIndex:p=1e3,closeOnBackdrop:b=!0,closeOnEscape:m=!0,showCloseButton:v=!0,placement:y="center",bodyClassName:S="px-6 py-5",panelClassName:h="",backdropClassName:P=El,contentClassName:O="p-4",ariaLabel:E,frameless:L=!1,disabled:N=!1}){const[k,Y]=o.useState(!1),[F,U]=o.useState(!1),V=o.useRef(null);if(o.useEffect(()=>(r?(V.current&&clearTimeout(V.current),Y(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>U(!0)))):(U(!1),V.current=setTimeout(()=>Y(!1),Ut+40)),()=>{V.current&&clearTimeout(V.current)}),[r]),o.useEffect(()=>{if(r)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[r]),o.useEffect(()=>{if(!r||!m)return;const ae=Z=>{Z.key==="Escape"&&t()};return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[m,t,r]),!k)return null;const J=n||a||s||l||v,C=f??Cl[u],re=y==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",W=y==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",j=F?"translateY(0) scale(1)":y==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return er.createPortal(e.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":E??n,className:`fixed inset-0 flex ${re} ${O}`,style:{zIndex:p},children:[e.jsx("div",{className:`absolute inset-0 ${P}`,onClick:b?t:void 0,style:{opacity:F?1:0,transition:`opacity ${Ut}ms ease`}}),e.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${L?"shadow-none":"shadow-2xl"} ${W} ${h}`,style:{maxWidth:C,background:L?"transparent":"var(--bg-card)",border:L?"none":"1px solid var(--border)",opacity:F?1:0,transform:j,transition:`opacity ${Ut}ms ease, transform ${Ut}ms ease`},onClick:ae=>ae.stopPropagation(),children:[N&&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)"}}),J&&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}),(n||a)&&e.jsxs("div",{className:"min-w-0",children:[n&&e.jsx("h2",{className:"truncate text-base font-semibold",style:{color:"var(--text-main)"},children:n}),a&&e.jsx("p",{className:"truncate text-xs",style:{color:"var(--text-muted)"},children:a})]})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[l,v&&e.jsx(Fe,{variant:"icon",onClick:t,title:"Cerrar",children:e.jsx(T.HiXMark,{className:"h-5 w-5"})})]})]}),e.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${S}`,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 Ml={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 Ll({open:r,title:t,description:n,confirmLabel:a="Confirmar",cancelLabel:s="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:u}){const f=Ml[l];return e.jsx(qn,{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(Fe,{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(T.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(T.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}),n?e.jsx("div",{className:"mt-1.5 text-sm leading-relaxed",style:{color:"var(--text-muted)"},children:n}):null]})]}),e.jsxs("div",{className:"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e.jsx(Fe,{variant:"secondary",onClick:u,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:s}),e.jsx(Fe,{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:a})]})]})})}function Tl(r){return r?typeof r=="function"?r():r:""}function $l(r){return/^https?:\/\//i.test(r)}function Ua(r,t){try{return new URL(r,t).toString()}catch{return r}}function Al(r,t,n,a=!1){const s=typeof r=="function"?r():r,l=t?t(s):s;if(!l||$l(l))return l;const i=Tl(n);return i?Ua(l,i):a&&typeof window<"u"?Ua(l,window.location.origin):l}function Dl({url:r,resolveUrl:t,baseUrl:n,useWindowOriginForRelative:a=!1,title:s="Copiar link",copiedTitle:l="Link copiado",icon:i=e.jsx(T.HiLink,{className:"h-3.5 w-3.5"}),...c}){return e.jsx(_n,{...c,value:()=>Al(r,t,n,a),title:s,copiedTitle:l,icon:i})}const Vt=[25,50,100,200,500];let rr={dataTable:{pageSizeOptions:[...Vt]}};function Il(){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 Un(){const r=rr.dataTable.preferencesEndpoint,t=Il();return r&&r.trim().length>0?r.trim().replace(/\/+$/,""):t}function Bl(r){if(!Array.isArray(r))return[...Vt];const t=Array.from(new Set(r.map(n=>typeof n=="number"?Math.floor(n):Number.NaN).filter(n=>Number.isFinite(n)&&n>0)));return t.length>0?t:[...Vt]}function Va(r){if(typeof r!="string")return;const t=r.trim();if(t)return t.replace(/\/+$/,"")}function Ol(r){if(!r||typeof r!="object"||!r.dataTable)return;const t=Va(r.dataTable.preferencesEndpoint);rr={...rr,dataTable:{...rr.dataTable,pageSizeOptions:Bl(r.dataTable.pageSizeOptions),preferencesEndpoint:t??rr.dataTable.preferencesEndpoint}}}function Hl(){return{dataTable:{pageSizeOptions:[...rr.dataTable.pageSizeOptions]}}}function mt(){return[...rr.dataTable.pageSizeOptions]}function Pl(){rr={dataTable:{pageSizeOptions:[...Vt]}}}function Fl(r){rr={...rr,dataTable:{...rr.dataTable,preferencesEndpoint:Va(r)}}}const Gt=[{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"}],zl=Gt.map(r=>({value:r.value,label:r.label})),_l=12,jl={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},Ga={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},Wl="bonsaif-ui:datatable:",ql="[&_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",Ul=[],Vl=52;function br(r){if(!r)return 150;const t=parseInt(r,10);return isNaN(t)||t<=0?150:t}function Ka(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 Xa(r){return`${Wl}${r}`}function Kt(r){try{const t=window.localStorage.getItem(Xa(r));if(!t)return null;const n=JSON.parse(t);return n&&typeof n=="object"?n:null}catch{return null}}function Gl(r,t){try{window.localStorage.setItem(Xa(r),JSON.stringify(t))}catch{}}function Kl(r,t){if(r===!0)return{...Ga};if(r===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(t&&r==null)return{...Ga};const n={...jl,...r??{}};return t&&(typeof r!="object"||r.pagination!==!1)&&(n.pagination=!0),n}function Ya(...r){return r.reduce((t,n)=>({...t,...n??{}}),{})}function Vn(r,t,n){return typeof r!="number"||r<=0?n:yt(t).includes(r)?r:n}function ht(r){if(!r||typeof r!="object")return!1;const t=r;return typeof t.key=="string"&&(t.dir==="asc"||t.dir==="desc")}function gt(r,t){if(!r||typeof r!="object"||Array.isArray(r))return{};const n=Object.entries(r).flatMap(([a,s])=>{if(!t.has(a)||!Array.isArray(s))return[];const l=s.filter(i=>typeof i=="string");return l.length>0?[[a,l]]:[]});return Object.fromEntries(n)}function vt(r,t){if(!r||typeof r!="object"||Array.isArray(r))return{};const n=new Set(Gt.map(s=>s.value)),a=Object.entries(r).flatMap(([s,l])=>{if(!t.has(s)||!l||typeof l!="object")return[];const i=l;return!i.operator||!n.has(i.operator)?[]:[[s,{operator:i.operator,value:typeof i.value=="string"?i.value:"",valueTo:typeof i.valueTo=="string"?i.valueTo:""}]]});return Object.fromEntries(a)}function Ye(r,t){if(Tr(r))return Vl;const n=r.minWidth??80,a=r.maxWidth??1/0;return Math.min(a,Math.max(n,t))}function Xl(r){const t=window.getComputedStyle(r);return parseFloat(t.paddingLeft)+parseFloat(t.paddingRight)}function Tr(r){return r.key==="actions"||r.key==="acciones"?!0:typeof r.header=="string"&&r.header.trim().toLowerCase()==="acciones"}function Gn(r){return r.sticky===!0}function Za(r){return!(r.reorderable===!1||r.sticky&&r.reorderable!==!0)}function vr(r,t){const n=t.filter(Gn).map(i=>i.key);if(n.length===0)return r;const a=new Set(n),s=n.filter(i=>r.includes(i)),l=r.filter(i=>!a.has(i));return[...s,...l]}function Yl(r,t){if(t<=7)return Array.from({length:t},(a,s)=>s+1);const n=[1];r>3&&n.push("...");for(let a=Math.max(2,r-1);a<=Math.min(t-1,r+1);a++)n.push(a);return r<t-2&&n.push("..."),n.push(t),n}function xr(r,t){var i;const n=new Set(t.filter(c=>c.hideable!==!1).map(c=>c.key)),a=Array.from(new Set(r??[])).filter(c=>n.has(c));if(t.filter(c=>!a.includes(c.key)).length>0)return a;const l=(i=t.find(c=>c.hideable!==!1))==null?void 0:i.key;return l?a.filter(c=>c!==l):[]}function Zl(r){return r==null||r===""?"(Vacio)":r instanceof Date?r.toLocaleDateString():String(r)}function Vr(r){return r==null||typeof r=="boolean"?"":typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(Vr).join(" ").trim():o.isValidElement(r)?Vr(r.props.children):""}function Xt(r,t){const n=r.filterValue?r.filterValue(t):r.sortKey?t[r.sortKey]:r.cell(t);return typeof n=="string"||typeof n=="number"||typeof n=="boolean"||n===null||n===void 0||n instanceof Date?Zl(n):Vr(n).trim()}function xt(r){const t=r.replace(/,/g,"").trim();if(!t)return null;const n=Number(t);return Number.isFinite(n)?n:null}function Gr(r,t){const n=xt(r),a=xt(t);return n!==null&&a!==null?n-a:r.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function yt(r){const t=Array.from(new Set(r.map(n=>Math.floor(n)).filter(n=>Number.isFinite(n)&&n>0)));return t.length>0?t:mt()}function Ql(r,t,n){var i,c;const a=((i=t.value)==null?void 0:i.trim())??"",s=((c=t.valueTo)==null?void 0:c.trim())??"",l=Gt.find(u=>u.value===t.operator);if((l==null?void 0:l.valueMode)==="single"&&!a||(l==null?void 0:l.valueMode)==="between"&&(!a||!s))return!0;switch(t.operator){case"equals":return r.toLowerCase()===a.toLowerCase();case"notEquals":return r.toLowerCase()!==a.toLowerCase();case"greaterThan":return Gr(r,a)>0;case"greaterThanOrEqual":return Gr(r,a)>=0;case"lessThan":return Gr(r,a)<0;case"lessThanOrEqual":return Gr(r,a)<=0;case"between":return Gr(r,a)>=0&&Gr(r,s)<=0;case"top10":case"bottom10":{const f=n.map(b=>({value:b,number:xt(b)})).filter(b=>b.number!==null).sort((b,m)=>b.number-m.number).map(b=>b.value);return(t.operator==="top10"?f.slice(-10):f.slice(0,10)).includes(r)}case"aboveAverage":case"belowAverage":{const u=n.map(xt).filter(b=>b!==null);if(u.length===0)return!1;const f=u.reduce((b,m)=>b+m,0)/u.length,p=xt(r);return p===null?!1:t.operator==="aboveAverage"?p>f:p<f}default:return!0}}function Qa({children:r,className:t="",style:n}){return e.jsx(Mr,{onlyWhenOverflow:!0,className:t,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",...n},children:r})}function Ja({columns:r,data:t,getRowId:n,loading:a=!1,skeletonRows:s=8,emptyIcon:l,emptyText:i="Sin resultados",initialEmptyDelay:c=450,onRowClick:u,renderExpandedRow:f,getRowCanExpand:p,expandedRowIds:b,defaultExpandedRowIds:m=[],onExpandedRowIdsChange:v,expandOnRowClick:y=!1,selected:S,onToggleOne:h,onToggleAll:P,highlightSelected:O=!0,rowClassName:E,getRowCategory:L,stickyHeader:N=!0,pageSize:k=25,pageSizeOptions:Y,pageSizeSelectWidth:F=62,pageSizeSelectHeight:U=30,pageSizeSelectPadding:V="0 7px",totalRows:J,page:C,onPageChange:re,onPageSizeChange:W,storageKey:j,stickyFirstColumn:ae=!1,bottomOffset:Z=0,compact:$=!0,restrictHeight:ee=!0,maxHeight:se,minTableWidth:M,enableColumnVisibility:H=!0,enableColumnFilters:oe=!0,hiddenColumnKeys:A,defaultHiddenColumnKeys:q=Ul,onHiddenColumnKeysChange:ne,columnVisibilityLabel:ie="Columnas",enableBql:Q=!1,bqlValue:G,defaultBqlValue:w="",onBqlChange:R,bqlDescription:B="Filtra registros con Bonsaif Query Language",bqlPlaceholder:te=`status = activo
2
- rol IN (admin, employee)`,bqlQuickFilters:z=[],bqlExamples:le=[],bqlSuggestions:Ee=[],bqlActiveFilters:Le,bqlError:xe,onQueryChange:Se,persistState:Te,onPreferencesReady:kr,enableExport:pr=!1,exportFilename:qe="datos"}){var qs;const ce=Kl(Te,j),Qe=Object.values(ce).some(Boolean),lr=r.map(d=>d.key).join(","),fe=q.join(","),I=o.useRef(r),X=o.useRef(q);I.current=r,X.current=q;const[ue,be]=o.useState(!j||!Qe),De=o.useRef(null),Ce=o.useRef(!j),Oe=o.useRef(!1),$e=o.useRef(kr);$e.current=kr;const Ve=o.useRef(!j||!Qe?j??"__none__":null),He=A!==void 0,[bn,Ke]=o.useState(()=>xr(q,r)),_e=xr(He?A:bn,r),[Xe,Dr]=o.useState(!1),[ir,Gd]=o.useState("filter"),[Tt,pn]=o.useState(null),[ds,us]=o.useState(""),[Je,rt]=o.useState({}),[cr,$t]=o.useState({}),ba=b!==void 0,[fs,Kd]=o.useState(m),Ir=G!==void 0,[Xd,At]=o.useState(w),mr=Ir?G:Xd,[Dt,mn]=o.useState(mr),[hr,Br]=o.useState(!1),[bs,tt]=o.useState(!1),[ps,nt]=o.useState(!1),[It,at]=o.useState([]),ot=o.useRef(null),Or=o.useRef(null),dr=o.useRef(R);dr.current=R;const hn=o.useRef(k);hn.current=k;const gn=o.useRef(Y);gn.current=Y;const Yd=Array.isArray(Y)?Y.join(","):"",pa=o.useRef(null),ms=o.useRef(null),ma=o.useRef(null),hs=o.useRef(0),[Zd,Qd]=o.useState({}),[Jd,Rd]=o.useState({}),[Bt,vn]=o.useState(!1),ha=o.useRef(null),xn=o.useRef(null),[eu,ru]=o.useState({}),gs=o.useRef(null),yn=o.useRef(null),[ga,vs]=o.useState(t.length>0||a||c===!1),xs=(d,g)=>50+(d*17+g*13+7)%40,Nr=o.useRef(null),[tu,nu]=o.useState(void 0),[ys,au]=o.useState(0),[ou,su]=o.useState(!1);o.useEffect(()=>{function d(){su(window.innerWidth<640)}if(!ee||se!==void 0)return d(),window.addEventListener("resize",d),()=>window.removeEventListener("resize",d);const D=k!==!1?48:0,x=12;function K(){if(d(),!Nr.current)return;const de=Nr.current.getBoundingClientRect().top;nu(Math.max(120,window.innerHeight-de-D-x-Z))}return K(),window.addEventListener("resize",K),()=>window.removeEventListener("resize",K)},[a,k,Z,ee,se]);const ws=ee?se??tu:void 0;o.useEffect(()=>{const d=Nr.current;if(!d)return;const g=()=>au(d.clientWidth);if(g(),typeof ResizeObserver>"u")return window.addEventListener("resize",g),()=>window.removeEventListener("resize",g);const D=new ResizeObserver(g);return D.observe(d),()=>D.disconnect()},[a,ue,t.length]),o.useEffect(()=>{if(c===!1||a||t.length>0){vs(!0);return}if(ga)return;const d=window.setTimeout(()=>{vs(!0)},c);return()=>window.clearTimeout(d)},[t.length,c,ga,a]);const[st,lt]=o.useState(()=>vr(r.map(d=>d.key),r)),[Hr,it]=o.useState(()=>Object.fromEntries(r.map(d=>[d.key,Ye(d,br(d.width))]))),[Be,Pr]=o.useState(null),[lu,wn]=o.useState(1),[kn,Nn]=o.useState(k===!1?0:k);o.useEffect(()=>{var Ne;const d=I.current,g=X.current,D=d.map(he=>he.key),x=new Set(D),K=()=>{var he;Oe.current||(Oe.current=!0,(he=$e.current)==null||he.call($e))};if(!j||!Qe){ce.layout&&lt(vr(D,d)),He||Ke(xr(g,d)),Ce.current=!1,be(!0),K();return}let de=!1;const pe=Ve.current===j;pe||(Ce.current=!1,be(!1),Oe.current=!1);const we=Kt(j);if(Ka(we)&&!pe){const he=we,me=yt(gn.current??mt()),ge=hn.current,qr=ge===!1?0:ge,Sr=ce.layout?he==null?void 0:he.columnOrder:void 0,Cr=Array.isArray(Sr)?Sr.filter(Ae=>D.includes(Ae)):[],Er=D.filter(Ae=>!Cr.includes(Ae)),Ur=vr(Cr.length>0?[...Cr,...Er]:D,d),ut=Object.fromEntries(d.map(Ae=>[Ae.key,Ye(Ae,br(Ae.width))])),ft=ce.layout?(he==null?void 0:he.columnWidths)??{}:{},Ft=Object.fromEntries(d.map(Ae=>[Ae.key,Ye(Ae,ft[Ae.key]??ut[Ae.key])])),bt=xr(ce.layout?(he==null?void 0:he.hiddenColumnKeys)??g:g,d);if(ce.layout&&(lt(Ur),it(Ft)),He||Ke(bt),ce.filters&&(rt(gt(he==null?void 0:he.filters,x)),$t(vt(he==null?void 0:he.conditionFilters,x))),ce.sort){const Ae=ht(he==null?void 0:he.sort)?he.sort:null;Pr(Ae&&x.has(Ae.key)?Ae:null)}if(ce.bql){if(ot.current!==j){ot.current=j;const Ae=typeof(he==null?void 0:he.bql)=="string"?he.bql:w;Ir?(Ne=dr.current)==null||Ne.call(dr,Ae):At(Ae)}at(Array.isArray(he==null?void 0:he.bqlHistory)?he.bqlHistory.filter(Ae=>typeof Ae=="string"):[])}ce.pagination&&Or.current!==j&&(Or.current=j,Nn(Vn(he==null?void 0:he.pageSize,me,qr))),Ve.current=j,be(!0),K()}const Ue=`${Un()??"/api/user/preferences/datatables"}?key=${encodeURIComponent(j)}`,ke=new AbortController,ye=window.setTimeout(()=>ke.abort(),2500);return fetch(Ue,{cache:"no-store",signal:ke.signal}).then(he=>he.ok?he.json():null).then(he=>{var Us;if(de)return;const me=Kt(j),ge=Ya(Ka(he==null?void 0:he.settings)?he==null?void 0:he.settings:null,me),qr=yt(gn.current??mt()),Sr=hn.current,Cr=Sr===!1?0:Sr,Er=ce.layout?ge==null?void 0:ge.columnOrder:void 0,Ur=Array.isArray(Er)?Er.filter(Pe=>D.includes(Pe)):[],ut=D.filter(Pe=>!Ur.includes(Pe)),ft=vr(Ur.length>0?[...Ur,...ut]:D,d),Ft=Object.fromEntries(d.map(Pe=>[Pe.key,Ye(Pe,br(Pe.width))])),bt=ce.layout?(ge==null?void 0:ge.columnWidths)??{}:{},Ae=Object.fromEntries(d.map(Pe=>[Pe.key,Ye(Pe,bt[Pe.key]??Ft[Pe.key])])),pt=xr(ce.layout?(ge==null?void 0:ge.hiddenColumnKeys)??g:g,d);if(ce.layout&&(lt(ft),it(Ae)),He||Ke(pt),ce.filters&&(rt(gt(ge==null?void 0:ge.filters,x)),$t(vt(ge==null?void 0:ge.conditionFilters,x))),ce.sort){const Pe=ht(ge==null?void 0:ge.sort)?ge.sort:null;Pr(Pe&&x.has(Pe.key)?Pe:null)}if(ce.bql){if(ot.current!==j){ot.current=j;const Pe=typeof(ge==null?void 0:ge.bql)=="string"?ge.bql:w;Ir?(Us=dr.current)==null||Us.call(dr,Pe):At(Pe)}at(Array.isArray(ge==null?void 0:ge.bqlHistory)?ge.bqlHistory.filter(Pe=>typeof Pe=="string"):[])}let Ie;ce.pagination&&(Ie=Vn(ge==null?void 0:ge.pageSize,qr,Cr),Or.current!==j&&(Or.current=j,Nn(Ie))),De.current=JSON.stringify({columnOrder:ft,columnWidths:Ae,hiddenColumnKeys:pt,filters:gt(ge==null?void 0:ge.filters,x),conditionFilters:vt(ge==null?void 0:ge.conditionFilters,x),sort:ht(ge==null?void 0:ge.sort)?ge.sort:null,bql:typeof(ge==null?void 0:ge.bql)=="string"?ge.bql:"",bqlHistory:Array.isArray(ge==null?void 0:ge.bqlHistory)?ge.bqlHistory:[],pageSize:ce.pagination&&Sr!==!1?Ie:void 0}),Ce.current=!0}).catch(()=>{var he;if(!de){const me=Kt(j),ge=yt(gn.current??mt()),qr=hn.current,Sr=qr===!1?0:qr,Cr=ce.layout?me==null?void 0:me.columnOrder:void 0,Er=Array.isArray(Cr)?Cr.filter(Ie=>D.includes(Ie)):[],Ur=D.filter(Ie=>!Er.includes(Ie)),ut=vr(Er.length>0?[...Er,...Ur]:D,d),ft=Object.fromEntries(d.map(Ie=>[Ie.key,Ye(Ie,br(Ie.width))])),Ft=ce.layout?(me==null?void 0:me.columnWidths)??{}:{},bt=Object.fromEntries(d.map(Ie=>[Ie.key,Ye(Ie,Ft[Ie.key]??ft[Ie.key])]));ce.layout&&(lt(ut),it(bt));const Ae=xr(ce.layout?(me==null?void 0:me.hiddenColumnKeys)??g:g,d);if(He||Ke(Ae),ce.filters&&(rt(gt(me==null?void 0:me.filters,x)),$t(vt(me==null?void 0:me.conditionFilters,x))),ce.sort){const Ie=ht(me==null?void 0:me.sort)?me.sort:null;Pr(Ie&&x.has(Ie.key)?Ie:null)}if(ce.bql){if(ot.current!==j){ot.current=j;const Ie=typeof(me==null?void 0:me.bql)=="string"?me.bql:w;Ir?(he=dr.current)==null||he.call(dr,Ie):At(Ie)}at(Array.isArray(me==null?void 0:me.bqlHistory)?me.bqlHistory.filter(Ie=>typeof Ie=="string"):[])}let pt;ce.pagination&&(pt=Vn(me==null?void 0:me.pageSize,ge,Sr),Or.current!==j&&(Or.current=j,Nn(pt))),De.current=JSON.stringify({columnOrder:ut,columnWidths:bt,hiddenColumnKeys:Ae,filters:gt(me==null?void 0:me.filters,x),conditionFilters:vt(me==null?void 0:me.conditionFilters,x),sort:ht(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:ce.pagination&&qr!==!1?pt:void 0}),Ce.current=!0}}).finally(()=>{window.clearTimeout(ye),de||(Ve.current=j,be(!0),K())}),()=>{de=!0,ke.abort(),window.clearTimeout(ye)}},[j,Qe,lr,fe,He,ce.layout,ce.filters,ce.sort,ce.bql,ce.pagination,Ir,w,Yd]),o.useEffect(()=>{if(!j||!ue||!Qe||!Ce.current)return;const d={};ce.layout&&(d.columnOrder=st,d.columnWidths=Hr,d.hiddenColumnKeys=_e),ce.filters&&(d.filters=Je,d.conditionFilters=cr),ce.sort&&(d.sort=Be),ce.bql&&(d.bql=mr,d.bqlHistory=It),ce.pagination&&k!==!1&&(d.pageSize=kn);const g=Kt(j),D=Ya(g,d),x=JSON.stringify(D);if(x===De.current)return;Gl(j,D),De.current=x;const K=window.setTimeout(()=>{const de=Un()??"/api/user/preferences/datatables";fetch(de,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:j,settings:D})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(K)},[st,Hr,_e,Je,cr,Be,mr,It,kn,k,j,ue,Qe,ce.layout,ce.filters,ce.sort,ce.bql,ce.pagination]),o.useEffect(()=>{lt(d=>{const g=r.map(K=>K.key),D=d.filter(K=>g.includes(K)),x=g.filter(K=>!D.includes(K));return vr([...D,...x],r)})},[lr,r]);const ks=vr(st,r).map(d=>r.find(g=>g.key===d)).filter(d=>!!d),Re=ks.filter(d=>!_e.includes(d.key)),Ns=r.some(Gn),iu=Object.keys(Je).length,cu=Object.keys(cr).length,va=iu+cu;function Ss(d){const g=new Set;return t.reduce((D,x)=>{const K=Xt(d,x);return!K||g.has(K)||(g.add(K),D.push({value:K,label:K})),D},[])}function du(){const d=r.find(g=>g.key===Tt);return d?Ss(d):[]}function uu(d){return!!(oe&&!Tr(d)&&(d.filterValue||d.sortKey||Ss(d).length>0))}function Cs(d,g){rt(D=>{const x={...D};return x[d]=g,x})}function fu(d,g,D,x){const K=Je[d]??[],de=x?K:D.filter(we=>we!==g),pe=x?K.includes(g)?K.filter(we=>we!==g):[...K,g]:de;pe.length===D.length?xa(d):Cs(d,pe)}function xa(d){rt(g=>{const D={...g};return delete D[d],D})}function Sn(d,g){$t(D=>{const x={...D};return g?x[d]=g:delete x[d],x})}function Es(d){Sn(d,null)}function bu(){rt({}),$t({})}function pu(d){Ir||At(d),R==null||R(d)}function Ms(d){const g=d.trim();mn(g),(R==null?void 0:R(g))!==!1&&(Ir||At(g),Br(!1),tt(!1),nt(!1),g&&at(x=>[g,...x.filter(K=>K!==g)].slice(0,_l)))}function Ls(){mn(""),pu(""),Br(!1),tt(!1),nt(!1)}function ya(d,g){mn(d),g&&(g.style.height="auto",g.style.height=`${Math.min(g.scrollHeight,180)}px`)}function Cn(d){const g=d.trim();if(!g)return;hs.current=Date.now()+500;const D=Dt.replace(/\s+$/u,""),x=D.length===0?g:D.split(`
3
- `).map(K=>K.trim()).includes(g)?D:`${D}
4
- ${g}`;ya(x,ma.current??void 0),requestAnimationFrame(()=>{const K=ma.current;if(!K)return;K.focus();const de=K.value.length;K.setSelectionRange(de,de),ya(K.value,K)})}o.useEffect(()=>{mn(mr)},[mr]);const En=o.useCallback(()=>{const d=pa.current;if(!d)return;const g=d.getBoundingClientRect(),D=12,x=8,K=Math.min(780,Math.max(320,window.innerWidth-32)),de=Math.max(D,window.innerWidth-K-D),pe=Math.min(Math.max(D,g.left),de),we=g.bottom+x,je=window.innerHeight-g.top+x,ze=window.innerHeight-we-D,Ue=g.top-D-x,ke=ze<280&&Ue>ze,ye=Math.max(240,ke?Ue:ze);Qd({position:"fixed",zIndex:1e4,left:pe,top:ke?void 0:we,bottom:ke?je:void 0,width:K,maxWidth:"calc(100vw - 24px)",maxHeight:ye,overflowY:"auto"})},[]);o.useEffect(()=>{if(!hr)return;function d(x){var de,pe;if(Date.now()<hs.current)return;const K=x.target;(de=pa.current)!=null&&de.contains(K)||(pe=ms.current)!=null&&pe.contains(K)||(Br(!1),tt(!1),nt(!1))}function g(x){x.key==="Escape"&&(Br(!1),tt(!1),nt(!1))}function D(){En()}return En(),document.addEventListener("mousedown",d),window.addEventListener("keydown",g),window.addEventListener("resize",D),window.addEventListener("scroll",D,!0),()=>{document.removeEventListener("mousedown",d),window.removeEventListener("keydown",g),window.removeEventListener("resize",D),window.removeEventListener("scroll",D,!0)}},[hr,En]);function Ts(d){const g=xr(d,r);He||Ke(g),ne==null||ne(g)}function mu(d){Ts(_e.includes(d)?_e.filter(g=>g!==d):[..._e,d])}function hu(){Ts([])}const wa=o.useCallback((d=yn.current)=>{if(!d)return;const g=d.getBoundingClientRect(),D=Math.min(292,Math.max(240,window.innerWidth-16)),x=Math.max(8,window.innerWidth-D-8),K=Math.min(Math.max(8,g.right-D),x),de=window.innerHeight-g.bottom,pe=g.bottom+6,we=window.innerHeight-g.top+6,ze=de<360&&g.top>de?void 0:pe,Ue=ze===void 0?we:void 0,ke=Math.max(220,ze===void 0?g.top-16:window.innerHeight-pe-8),ye={position:"fixed",zIndex:9999,left:K,top:ze,bottom:Ue,width:D,maxWidth:"calc(100vw - 16px)",maxHeight:ke,"--dt-column-menu-max-height":`${ke}px`};Rd(ye)},[]);function $s(d,g,D=null){d.preventDefault(),d.stopPropagation();const x=yn.current===d.currentTarget&&ir===g&&Tt===D;if(Xe&&x){Dr(!1),pn(null);return}yn.current=d.currentTarget,Gd(g),pn(D),us(""),wa(d.currentTarget),Dr(!0)}function gu(d){if(Tr(d))return;const g=Nr.current;if(!g)return;const x=Array.from(g.querySelectorAll("[data-dt-column-key]")).filter(K=>K.dataset.dtColumnKey===d.key).reduce((K,de)=>{const pe=de.querySelector("[data-dt-autofit-content]"),we=pe?pe.scrollWidth:Math.max(de.scrollWidth,de.offsetWidth);return Math.max(K,Math.ceil(we+Xl(de)))},0);x<=0||it(K=>({...K,[d.key]:Ye(d,x+12)}))}o.useEffect(()=>{it(d=>{const g=Object.fromEntries(r.map(D=>[D.key,Ye(D,br(D.width))]));return Object.fromEntries(r.map(D=>[D.key,Ye(D,d[D.key]??g[D.key])]))})},[lr,r]),o.useEffect(()=>{He||Ke(d=>xr(d,r))},[lr,r,He]),o.useEffect(()=>{function d(x){var pe,we;const K=x.target,de=x.target;de!=null&&de.closest("[data-bonsaif-select-dropdown='true']")||!((pe=gs.current)!=null&&pe.contains(K))&&!((we=yn.current)!=null&&we.contains(K))&&(Dr(!1),pn(null))}function g(x){x.key==="Escape"&&(Dr(!1),pn(null))}function D(){wa()}return Xe&&(document.addEventListener("mousedown",d),window.addEventListener("keydown",g),window.addEventListener("resize",D),window.addEventListener("scroll",D,!0)),()=>{document.removeEventListener("mousedown",d),window.removeEventListener("keydown",g),window.removeEventListener("resize",D),window.removeEventListener("scroll",D,!0)}},[Xe,wa]);const Ot=o.useRef(null);o.useEffect(()=>{function d(D){const x=Ot.current;if(!x)return;const K=D.clientX-x.startX,de=r.find(pe=>pe.key===x.colKey);de&&it(pe=>({...pe,[x.colKey]:Ye(de,x.startWidth+K)}))}function g(){Ot.current&&(Ot.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 Ht=o.useRef(null),[As,ka]=o.useState(null);function vu(d,g){const D=r.find(x=>x.key===d);if(!D||!Za(D)){g.preventDefault();return}Ht.current=st.indexOf(d),g.dataTransfer.effectAllowed="move"}function xu(d,g){g.preventDefault(),g.dataTransfer.dropEffect="move";const D=st.indexOf(d);As!==D&&ka(D)}function yu(d,g){g.preventDefault();const D=Ht.current,x=st.indexOf(d);D!==null&&D!==x&&lt(K=>{const de=[...K],[pe]=de.splice(D,1);return de.splice(x,0,pe),vr(de,r)}),Ht.current=null,ka(null)}function wu(){Ht.current=null,ka(null)}function ku(d){d.sortKey&&Pr(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(()=>{wn(1)},[t]),o.useEffect(()=>{wn(1)},[cr,Je]);const Fr=!!(re&&W),zr=k!==!1,Ds=o.useMemo(()=>yt(Y??mt()),[Y]),We=Fr?C??1:lu,ur=Fr||zr?kn:t.length,fr=!!S&&!!h&&!!P,ct=!!f,Is=o.useMemo(()=>new Set(ba?Array.from(b??[]):fs),[ba,b,fs]),Nu=(ct?40:0)+(fr?40:0),Na=!ou&&(Ns||ae),Mn=(()=>{if(!Na)return{};let d=Nu;const g={};return Re.forEach((D,x)=>{(Gn(D)||!Ns&&ae&&x===0)&&(g[D.key]=d,d+=Hr[D.key]??Ye(D,br(D.width)))}),g})(),Sa=Object.keys(Mn),Ca=Sa.length>0?Sa[Sa.length-1]:null,Su=fr&&t.length>0&&S.size===t.length,Cu=fr&&S.size>0&&S.size<t.length,Ln=o.useMemo(()=>{const d=Object.entries(Je),g=Object.entries(cr);return d.length===0&&g.length===0?t:t.filter(D=>d.every(([x,K])=>{const de=r.find(pe=>pe.key===x);return de?K.includes(Xt(de,D)):!0})&&g.every(([x,K])=>{const de=r.find(we=>we.key===x);if(!de)return!0;const pe=t.map(we=>Xt(de,we));return Ql(Xt(de,D),K,pe)}))},[cr,Je,r,t]),_r=o.useMemo(()=>{if(!Be)return Ln;const d=r.find(g=>g.key===Be.key&&g.sortKey);return d!=null&&d.sortKey?[...Ln].sort((g,D)=>{const x=g[d.sortKey],K=D[d.sortKey],de=x===K?0:x==null?1:K==null||x<K?-1:1;return Be.dir==="asc"?de:-de}):Ln},[Ln,Be,r]),Bs=o.useMemo(()=>{if(Fr||!zr)return _r;const d=(We-1)*ur;return _r.slice(d,d+ur)},[_r,Fr,zr,We,ur]),jr=Fr?J??t.length:_r.length,Ea=zr?Math.max(1,Math.ceil(jr/ur)):1,Eu=Math.min(...Ds),Mu=zr&&(jr>ur||jr>Eu),Lu=zr?(We-1)*ur+1:1,Tu=zr?Math.min(We*ur,jr):jr;function Ma(d){if(a)return;const g=Math.max(1,Math.min(d,Ea));Fr?re(g):wn(g)}function $u(d){a||(j&&(Or.current=j),Nn(d),Fr?(W(d),re(1)):(wn(1),W==null||W(d)))}function Os(d){const g=new Set(Is);g.has(d)?g.delete(d):g.add(d);const D=Array.from(g);ba||Kd(D),v==null||v(D)}o.useEffect(()=>{Se==null||Se({bql:mr,filters:Je,conditionFilters:cr,sort:Be,page:We,pageSize:ur,hiddenColumnKeys:_e})},[mr,Je,cr,Be,We,ur,_e,Se]);const Hs=d=>d==="center"?"text-center":d==="right"?"text-right":"text-left",Au="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",La="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))",Wr="color-mix(in srgb, var(--primary) 24%, var(--border))",Tn=`inset 0 0 0 1px ${Me}`,Ps=Re.reduce((d,g)=>d+(Hr[g.key]??br(g.width)),(ct?40:0)+(fr?40:0)),Fs=typeof M=="number"?M:typeof M=="string"?Number(((qs=M.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:qs[1])??NaN):NaN,Pt=Number.isFinite(Fs)?Math.max(Ps,Fs,ys):Math.max(Ps,ys),$n=M??Pt,dt=`${ct?"40px ":""}${fr?"40px ":""}${Re.map(d=>`${Hr[d.key]??br(d.width)}px`).join(" ")}`;o.useEffect(()=>{Be&&_e.includes(Be.key)&&Pr(null)},[_e,Be]);function zs(d){return d?typeof d=="string"?{key:d,label:d}:d:null}const An=()=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:dt,background:La,borderBottom:`1px solid ${Wr}`},children:[ct&&e.jsx("div",{role:"columnheader",className:`${$?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${Wr}`,borderRight:`1px solid ${Me}`}}),fr&&e.jsx("div",{role:"columnheader",className:`${$?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:Na?{position:"sticky",left:0,zIndex:12,background:La,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${Wr}`,borderRight:`1px solid ${Me}`}:{borderBottom:`1px solid ${Wr}`,borderRight:`1px solid ${Me}`},children:e.jsx(Wt,{size:"sm",checked:Su,indeterminate:Cu,onChange:P,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),Re.map((d,g)=>{const D=(Be==null?void 0:Be.key)===d.key,x=!!d.sortKey,K=Tr(d),de=Mn[d.key],pe=de!==void 0,we=d.key===Ca,je=Za(d),ze=As===g,ke=(Hr[d.key]??br(d.width))<120,ye=Object.prototype.hasOwnProperty.call(Je,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 ${ke?"text-left":Hs(d.align)}`,style:{...pe?{position:"sticky",left:de,zIndex:12,background:La,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:we?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Wr}`:`inset 0 -1px 0 ${Wr}`,borderRight:`1px solid ${Me}`}:{position:"relative",borderBottom:`1px solid ${Wr}`,borderRight:`1px solid ${Me}`},color:D?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:ze?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:K?$?"7px 6px":"9px 8px":$?"8px 6px 10px":"10px 8px 12px"},onDragOver:Ne=>{(je||Ht.current!==null)&&xu(d.key,Ne)},onDrop:Ne=>yu(d.key,Ne),children:[e.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${K?"justify-center":ke?"justify-start":d.align==="center"?"justify-center":d.align==="right"?"justify-end":"justify-start"}`,children:[je?e.jsx("span",{draggable:!0,onDragStart:Ne=>{Ne.stopPropagation(),vu(d.key,Ne)},onDragEnd:Ne=>{Ne.stopPropagation(),wu()},onClick:Ne=>Ne.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 ${ze?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}):null,K?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(T.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):e.jsx(Qa,{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 ${$?"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:Ne=>{Ne.stopPropagation(),ku(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 ${D?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:D?Be.dir==="asc"?e.jsx(T.HiChevronUp,{className:"h-3 w-3"}):e.jsx(T.HiChevronDown,{className:"h-3 w-3"}):e.jsx(T.HiChevronUpDown,{className:"h-3 w-3"})}),oe&&!K&&uu(d)&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Xe&&Tt===d.key,"aria-label":`Filtrar ${String(d.header)}`,title:"Filtrar",onClick:Ne=>$s(Ne,"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"&&Tt===d.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":ye?"text-[var(--primary)] opacity-100":""}`,children:ye?e.jsx(T.HiFunnel,{className:"h-3.5 w-3.5"}):e.jsx(T.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!K&&e.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:Ne=>{Ne.preventDefault(),Ne.stopPropagation(),Ot.current={colKey:d.key,startX:Ne.clientX,startWidth:Hr[d.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:Ne=>{Ne.preventDefault(),Ne.stopPropagation(),Ot.current=null,document.body.style.cursor="",document.body.style.userSelect="",gu(d)},onClick:Ne=>Ne.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)})]}),Dn=()=>{if(!Xe||typeof document>"u"||ir==="visibility"&&!H||ir==="filter"&&!oe)return null;const d=r.find(ye=>ye.key===Tt),g=du(),D=d?Object.prototype.hasOwnProperty.call(Je,d.key):!1,x=d?cr[d.key]:void 0,K=Gt.find(ye=>ye.value===(x==null?void 0:x.operator)),de=d?Je[d.key]??[]:[],pe=ds.trim().toLowerCase(),we=pe?g.filter(ye=>ye.label.toLowerCase().includes(pe)):g,je=d&&g.length>0&&(!D||de.length===g.length),ze=d&&D&&de.length>0&&de.length<g.length,Ue=_e.length,ke=()=>{d&&(xa(d.key),Es(d.key))};return er.createPortal(e.jsx("div",{ref:gs,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Jd,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:Ue>0?`${Re.length} de ${r.length} visibles`:`${r.length} visibles`}),e.jsx("button",{type:"button",onClick:hu,disabled:Ue===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:ks.map(ye=>{const Ne=!_e.includes(ye.key),me=!(ye.hideable!==!1)||Ne&&Re.length<=1;return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ne,disabled:me,onClick:()=>mu(ye.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:Ne?"var(--primary)":"var(--border)",background:Ne?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ne&&e.jsx(T.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ye.header})]},ye.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:ke,disabled:!D&&!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:()=>Pr({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(T.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate",children:"Ascendente"})]}),(Be==null?void 0:Be.key)===d.key&&Be.dir==="asc"&&e.jsx(T.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),e.jsxs("button",{type:"button",onClick:()=>Pr({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(T.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate",children:"Descendente"})]}),(Be==null?void 0:Be.key)===d.key&&Be.dir==="desc"&&e.jsx(T.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(Lr,{value:(x==null?void 0:x.operator)??"",onChange:ye=>{if(!ye){Es(d.key);return}Sn(d.key,{operator:ye,value:(x==null?void 0:x.value)??"",valueTo:(x==null?void 0:x.valueTo)??""})},options:zl,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"}),(K==null?void 0:K.valueMode)!=="none"?e.jsx("input",{value:(x==null?void 0:x.value)??"",onChange:ye=>{x&&Sn(d.key,{...x,value:ye.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"})]}),(K==null?void 0:K.valueMode)==="between"&&e.jsx("input",{value:(x==null?void 0:x.valueTo)??"",onChange:ye=>{x&&Sn(d.key,{...x,valueTo:ye.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(T.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),e.jsx("input",{value:ds,onChange:ye=>us(ye.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":ze?"mixed":!!je,onClick:()=>{d&&(je&&!D?Cs(d.key,[]):xa(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:je||ze?"var(--primary)":"var(--border)",background:je||ze?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[ze&&e.jsx(T.HiMinus,{className:"h-3 w-3"}),je&&!ze&&e.jsx(T.HiCheck,{className:"h-3 w-3"})]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),we.map(ye=>{const Ne=!D||de.includes(ye.value);return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ne,onClick:()=>fu(d.key,ye.value,g.map(he=>he.value),D),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:Ne?"var(--primary)":"var(--border)",background:Ne?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ne&&e.jsx(T.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ye.label})]},ye.value)}),we.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(!Bt)return;function d(g){ha.current&&!ha.current.contains(g.target)&&xn.current&&!xn.current.contains(g.target)&&vn(!1)}return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[Bt]);function _s(d,g){if(d.filterValue){const D=d.filterValue(g);return D==null||D===""?"":String(D)}return Vr(d.cell(g))}function js(d){return`"${d.replace(/"/g,'""')}"`}function In(d){return d.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Du(){const d=Re.filter(we=>!Tr(we)),g=d.map(we=>js(Vr(we.header))).join(","),D=_r.map(we=>d.map(je=>js(_s(je,we))).join(",")).join(`
5
- `),x=`${g}
6
- ${D}`,K=new Blob(["\uFEFF"+x],{type:"text/csv;charset=utf-8;"}),de=URL.createObjectURL(K),pe=document.createElement("a");pe.href=de,pe.download=`${qe}.csv`,document.body.appendChild(pe),pe.click(),document.body.removeChild(pe),URL.revokeObjectURL(de)}function Iu(){const d=Re.filter(pe=>!Tr(pe)),g=d.map(pe=>In(Vr(pe.header))),x=_r.map(pe=>d.map(we=>In(_s(we,pe)))).map(pe=>`<tr>${pe.map(we=>`<td>${we}</td>`).join("")}</tr>`).join(""),K=`<!DOCTYPE html>
7
- <html lang="es"><head><meta charset="utf-8"><title>${In(qe)}</title>
1
+ (function(U,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):(U=typeof globalThis<"u"?globalThis:U||self,o(U.BonsaifUI={},U.React,U.jsxRuntime,U.ReactIconsHi2,U.ReactDOM,U.Recharts,U.OverlayScrollbarsGlobal,U.Sonner,U.OverlayScrollbarsReact,U.ReactDayPicker,U.ReactDayPickerStyles,U.ReactIconsFi))})(this,(function(U,o,e,B,tr,ye,Un,Wa,qa,Ua,of,ll){"use strict";"use client";function yr(...r){return r.filter(Boolean).join(" ")}function il({variant:r="primary",className:t,type:n="button",children:a,...s}){return e.jsx("button",{className:yr("bonsaif-ui-button",`bonsaif-ui-button--${r}`,t),type:n,...s,children:a})}function Va({value:r,onChange:t,placeholder:n,className:a="",autoFocus:s=!1,forceExpanded:l=!1,onEscape:i,size:c="default",inputTabIndex:d}){const u=o.useRef(null),[p,b]=o.useState(!1),m=l||p||r.trim().length>0,v=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",y=a||"w-48 max-w-full sm:w-64 lg:w-72";o.useEffect(()=>{var h;s&&((h=u.current)==null||h.focus())},[s]);const E=()=>{var h;b(!0),(h=u.current)==null||h.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:h=>{m||(h.preventDefault(),E())},children:[e.jsx(B.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:u,type:"text",tabIndex:d,"aria-label":n,value:r,onChange:h=>t(h.target.value),onKeyDown:h=>{h.key==="Escape"&&(i==null||i())},placeholder:m?n:"Buscar",className:`${v} 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:h=>{b(!0),h.currentTarget.style.borderColor="var(--primary)",h.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:h=>{b(!1),h.currentTarget.style.borderColor="var(--border)",h.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(B.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const Ka=o.createContext({});let Ga=0;const Xa="bonsaif-ui:hide-tooltips";function Vt(r=700){Ga=Date.now()+r}function cl(){return Date.now()>Ga}function Kt(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(n=>n.contains(r))?!1:t.length>0}function dl(r){var a;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)&&(((a=t[0])==null?void 0:a.textContent)??r.textContent??"").trim()||null}function $r({children:r,content:t,onlyWhenOverflow:n=!1,interactive:a=!1,followCursor:s=!0,placement:l="bottom",showArrow:i=!1,className:c="",tooltipClassName:d="",style:u,tooltipStyle:p,as:b="div"}){const m=o.useRef(null),v=o.useRef(null),y=o.useRef(null),E=o.useRef(!1),[h,$]=o.useState(null),[M,T]=o.useState("");o.useEffect(()=>{const w=m.current;w&&(w.querySelectorAll("[title]").forEach(Q=>{const _=Q.getAttribute("title");_&&(Q.getAttribute("aria-label")||Q.setAttribute("aria-label",_),Q.removeAttribute("title"))}),w.querySelectorAll("svg title").forEach(Q=>Q.remove()))}),o.useLayoutEffect(()=>{if(!h)return;const w=v.current;if(!w)return;const Q=12,_=14,P=w.getBoundingClientRect(),ne=window.innerWidth-P.width-Q,Y=window.innerHeight-P.height-Q;let D=h.mouseX+_,re=h.mouseY+_,le,I;if(!s&&m.current){const H=m.current.getBoundingClientRect(),oe=H.left+H.width/2,g=H.top+H.height/2;l==="top"?(D=oe-P.width/2,re=H.top-P.height-_,I=P.height-1):l==="left"?(D=H.left-P.width-_,re=g-P.height/2,le=P.width-1):l==="right"?(D=H.right+_,re=g-P.height/2,le=-7):(D=oe-P.width/2,re=H.bottom+_,I=-7)}if(s&&(D>ne&&(D=h.mouseX-P.width-_),re>Y&&(re=h.mouseY-P.height-_)),D=Math.min(Math.max(Q,D),Math.max(Q,ne)),re=Math.min(Math.max(Q,re),Math.max(Q,Y)),!s&&m.current){const H=m.current.getBoundingClientRect(),oe=H.left+H.width/2,g=H.top+H.height/2;l==="top"||l==="bottom"?le=Math.min(Math.max(14,oe-D),P.width-14):I=Math.min(Math.max(14,g-re),P.height-14)}(Math.abs(D-h.x)>.5||Math.abs(re-h.y)>.5||le!==h.arrowX||I!==h.arrowY)&&$(H=>H&&{...H,x:D,y:re,arrowX:le,arrowY:I})},[s,l,h]);const L=()=>{y.current&&(window.clearTimeout(y.current),y.current=null)},C=(w,Q)=>{if(!cl()||E.current)return;const _=m.current;if(_&&!Kt(_)){if(n){const P=dl(_);if(!P)return;T(P)}!n&&!t||$({mouseX:w,mouseY:Q,x:w+14,y:Q+14})}},k=()=>{const w=m.current;if(!w)return;const Q=w.getBoundingClientRect();C(Q.left+Q.width/2,Q.bottom)},V=()=>{L(),$(null)},A=()=>{if(!a){V();return}L(),y.current=window.setTimeout(()=>$(null),120)},K=()=>{Vt(),E.current=!0,V()},W=()=>{E.current=!1};o.useEffect(()=>{if(!h)return;if(Kt(m.current)){$(null);return}const w=()=>$(null),Q=()=>{Vt(),E.current=!0,$(null)};document.addEventListener("pointerdown",Q,!0),document.addEventListener("click",Q,!0),document.addEventListener("scroll",w,!0),window.addEventListener("blur",w),document.addEventListener("visibilitychange",w),document.addEventListener("keydown",w,!0);const _=new MutationObserver(()=>{Kt(m.current)&&$(null)});return _.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",Q,!0),document.removeEventListener("click",Q,!0),document.removeEventListener("scroll",w,!0),window.removeEventListener("blur",w),document.removeEventListener("visibilitychange",w),document.removeEventListener("keydown",w,!0),_.disconnect()}},[h]),o.useEffect(()=>{const w=()=>Vt(),Q=()=>{Vt(),E.current=!0,$(null)};return document.addEventListener("pointerdown",w,!0),document.addEventListener("click",w,!0),document.addEventListener("keydown",w,!0),window.addEventListener(Xa,Q),()=>{document.removeEventListener("pointerdown",w,!0),document.removeEventListener("click",w,!0),document.removeEventListener("keydown",w,!0),window.removeEventListener(Xa,Q)}},[]);const G=n?M:t;return e.jsxs(e.Fragment,{children:[e.jsx(b,{ref:w=>{m.current=w},className:c,style:u,onMouseEnter:w=>{L(),W(),s?C(w.clientX,w.clientY):k()},onMouseMove:w=>{h&&s&&C(w.clientX,w.clientY)},onMouseDown:K,onClick:K,onMouseLeave:()=>{W(),A()},onFocus:k,onBlur:V,children:r}),h&&G&&!Kt(m.current)?tr.createPortal(e.jsxs("div",{ref:v,role:"tooltip",className:d,onMouseEnter:a?L:void 0,onMouseLeave:a?A:void 0,style:{position:"fixed",top:h.y,left:h.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:a?"auto":"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere",...p},children:[i&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",width:12,height:12,background:(p==null?void 0:p.background)??"var(--bg-card)",borderLeft:l==="right"?(p==null?void 0:p.border)??"1px solid var(--border)":void 0,borderTop:l==="bottom"||l==="right"?(p==null?void 0:p.border)??"1px solid var(--border)":void 0,borderRight:l==="left"?(p==null?void 0:p.border)??"1px solid var(--border)":void 0,borderBottom:l==="top"||l==="left"?(p==null?void 0:p.border)??"1px solid var(--border)":void 0,transform:"rotate(45deg)",left:h.arrowX===void 0?void 0:h.arrowX-6,top:h.arrowY===void 0?void 0:h.arrowY-6,zIndex:-1}}),G]}),document.body):null]})}function Ya(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}const ul="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",fl={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"},bl="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",pl={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"},ml={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},hl={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function Vn(r){return typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(Vn).join(" ").trim():o.isValidElement(r)?Vn(r.props.children):""}function gl(r){return o.Children.toArray(r).find(o.isValidElement)??null}function He({variant:r="primary",size:t="md",loading:n=!1,icon:a,tooltip:s,iconOnly:l,height:i,padding:c,children:d,className:u="",disabled:p,style:b,...m}){const v=o.useContext(Ka),y=l??v.iconOnly??r==="icon",E=v.compact??!1,h=v.headerAction??!1,$=h&&t==="md"?"sm":E&&!h&&t==="md"?"xs":t,M=r==="icon"||y,T=h&&M,L=Vn(d),C=s??m.title??m["aria-label"]??(y?L:void 0),k=C?void 0:m.title,V=m["aria-label"]??(typeof C=="string"?C:L||void 0),A=n?null:a??(y?gl(d):null),K=e.jsxs("button",{...m,title:k,"aria-label":V,"data-variant":r,"data-size":$,"data-icon":M?"true":void 0,disabled:p||n,className:`${ul} ${T?bl:fl[r]} ${M?ml[$]:pl[$]} ${E&&!M?"px-2.5":""} ${u}`,style:{...hl[r],height:Ya(i),padding:Ya(c),...b,...h&&!M?{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:[n?e.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):A,!y&&d]});return C?e.jsx($r,{as:"span",content:C,className:"inline-flex shrink-0",children:K}):K}const Ge={background:"color-mix(in srgb, var(--text-muted) 26%, var(--bg-input))"};function Gt({rows:r=8,columns:t=7,showToolbar:n=!0,showPagination:a=!0,compact:s=!1,className:l=""}){const i=Math.max(3,Math.min(t,12)),c=Math.max(3,Math.min(r,20)),d=s?"px-2 py-2":"px-3 py-2.5",u=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:[n&&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((p,b)=>e.jsx("div",{className:`${u} 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+b*17%40}%`}})},`h-${b}`)),Array.from({length:c}).map((p,b)=>Array.from({length:i}).map((m,v)=>e.jsx("div",{className:`${d} ${b<c-1?"border-b border-[var(--border)]":""}`,children:e.jsx("div",{className:"h-3.5 animate-pulse rounded-md",style:{...Ge,width:`${46+(b*13+v*11)%42}%`,minWidth:28}})},`c-${b}-${v}`)))]})}),a&&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((p,b)=>e.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:Ge},b))}),e.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:Ge})]})]})}function vl({size:r="md"}){const t=r==="sm"?"h-7 w-7":"h-9 w-9";return e.jsx("div",{className:`${t} animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]`,"aria-hidden":!0})}function xl({logoSrc:r,logoAlt:t}){return r?e.jsxs("span",{className:"relative flex h-16 w-16 items-center justify-center","aria-hidden":!1,children:[e.jsx("span",{className:"absolute inset-0 rounded-2xl opacity-40 blur-xl",style:{background:"radial-gradient(circle, color-mix(in srgb, var(--primary) 45%, transparent) 0%, transparent 70%)"}}),e.jsx("img",{src:r,alt:t,className:"relative h-14 w-14 rounded-2xl object-contain shadow-sm shadow-black/10"})]}):null}function Za({variant:r="page",title:t="Cargando...",description:n,logoSrc:a,logoAlt:s,appearance:l="card",rows:i=6,columns:c=7,children:d,className:u=""}){if(r==="table")return e.jsx(Gt,{rows:i,columns:c,className:u});if(r==="sections")return e.jsx(yl,{rows:i});if(r==="cards")return e.jsx(wl,{rows:i});const p=s||(typeof t=="string"?t:"Aplicación"),b=l==="bare",m=e.jsxs("div",{className:`flex flex-col items-center text-center ${b?"gap-5":"gap-3"}`,children:[a?e.jsx(xl,{logoSrc:a,logoAlt:p}):null,e.jsx(vl,{size:b?"md":"sm"}),e.jsxs("div",{className:b?"space-y-1.5":"",children:[e.jsx("p",{className:b?"text-base font-semibold tracking-tight text-[var(--text-main)]":"text-sm font-semibold text-[var(--text-main)]",children:t}),n?e.jsx("p",{className:b?"text-sm font-medium text-[var(--text-muted)]":"mt-1 text-xs text-[var(--text-muted)]",children:n}):null,d&&e.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:d})]})]});return b?e.jsx("div",{className:`flex min-h-[240px] w-full items-center justify-center p-8 ${u}`,role:"status","aria-live":"polite","aria-busy":"true",children:m}):e.jsx("div",{className:`flex min-h-[240px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 ${u}`,role:"status","aria-live":"polite","aria-busy":"true",children:m})}function yl({rows:r}){return e.jsx(Gt,{rows:r,columns:7})}function wl({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,n)=>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})]},n))})}function Qa(r){const t=r.split("/").filter(Boolean);return(t[t.length-1]??r).replace(/^lv_/,"").split(/[-_]/).filter(Boolean).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}function Ja(r){return r.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function Nl(r){return[r.label,Qa(r.service),r.description,r.service].filter(Boolean).join(" ")}function kl(r){return typeof r=="function"?r:r.default}function Sl(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 Cl({parentPanel:r,parentPanelComponent:t,renderParentPanel:n,parent:a,context:s,links:l,moduleRegistry:i,loadModule:c,activeService:d,initialService:u,onActiveServiceChange:p,canAccess:b,keepAlive:m=!0,title:v,subtitle:y,emptyState:E,loadingState:h,errorState:$=Sl,renderTabLabel:M,searchableTabs:T="auto",tabsSearchThreshold:L=6,tabsSearchPlaceholder:C="Buscar modulo...",tabsSearchValue:k,onTabsSearchChange:V,emptySearchState:A,showTabCount:K=!0,className:W="",parentClassName:G="",contentClassName:w="",tabsClassName:Q=""}){var cr;const _=o.useMemo(()=>l.filter(be=>!be.hidden&&((b==null?void 0:b(be,s))??!0)),[b,s,l]),P=(cr=_.find(be=>!be.disabled))==null?void 0:cr.service,[ne,Y]=o.useState(u??P??""),[D,re]=o.useState({}),[le,I]=o.useState({}),[H,oe]=o.useState(""),[g,O]=o.useState(!1),R=o.useRef(le),se=o.useRef(0),Z=k??H,X=Ja(Z),S=T===!0||T==="auto"&&_.length>=L,te=S&&Z.trim().length>0,F=o.useMemo(()=>X?_.filter(be=>Ja(Nl(be)).includes(X)):_,[X,_]),ae=d??ne,q=_.find(be=>be.service===ae)??_.find(be=>!be.disabled);o.useEffect(()=>{!q&&P&&Y(P)},[P,q]),o.useEffect(()=>{R.current=le},[le]);const ce=be=>{be.disabled||(d||Y(be.service),p==null||p(be.service,be))},Ee=be=>{k===void 0&&oe(be),V==null||V(be)},ie=(be,j)=>{const ee=F.filter(pe=>!pe.disabled),fe=ee.findIndex(pe=>pe.service===j.service);fe<0||((be.key==="ArrowRight"||be.key==="ArrowDown")&&(be.preventDefault(),ce(ee[(fe+1)%ee.length])),(be.key==="ArrowLeft"||be.key==="ArrowUp")&&(be.preventDefault(),ce(ee[(fe-1+ee.length)%ee.length])),be.key==="Home"&&(be.preventDefault(),ce(ee[0])),be.key==="End"&&(be.preventDefault(),ce(ee[ee.length-1])))},ge=o.useCallback(()=>{if(!q)return;const be=q.service,j=R.current[be];if(j!=null&&j.loading||j!=null&&j.component&&m)return;const ee=(i==null?void 0:i[be])??c;if(!ee){I(pe=>({...pe,[be]:{loading:!1,error:new Error(`No module loader found for service "${be}".`)}}));return}const fe=++se.current;I(pe=>({...pe,[be]:{...pe[be],loading:!0,error:void 0}})),ee(q,s).then(pe=>{if(fe!==se.current&&!m)return;const De=kl(pe);I(Me=>({...Me,[be]:{component:De,loading:!1}}))}).catch(pe=>{const De=pe instanceof Error?pe:new Error(String(pe));I(Me=>({...Me,[be]:{...Me[be],loading:!1,error:De}}))})},[s,m,c,i,q]);o.useEffect(ge,[ge]);const we=q?D[q.service]??null:null,Le=q?le[q.service]:void 0,Cr=Le==null?void 0:Le.component,gr=be=>{q&&re(j=>({...j,[q.service]:be}))},Ue=()=>{q&&re(be=>({...be,[q.service]:null}))},de={context:s,parent:a,links:l,visibleLinks:_,filteredLinks:F,selectedLink:q,selectedService:q==null?void 0:q.service,activeItemId:we,tabsSearch:Z,onSelectService:ce,onOpenDetail:gr,onBackToList:Ue},Re=n?n(de):t?e.jsx(t,{...de}):r;return e.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${W}`,children:[e.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${G}`,children:Re}),e.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${w}`,children:[(v||y||S||K)&&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:[v&&e.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:v}),y&&e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:y})]}),(S||K)&&e.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[K&&e.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[F.length," / ",_.length]}),S&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${g?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!g,children:e.jsx(Va,{value:Z,onChange:Ee,placeholder:C,className:"w-full",autoFocus:g,forceExpanded:!0,onEscape:()=>O(!1),size:"sm",inputTabIndex:g?0:-1})}),e.jsx("button",{type:"button","aria-label":g?"Cerrar busqueda":"Buscar tabs","aria-expanded":g,onClick:()=>{g&&Z&&Ee(""),O(be=>!be)},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 ${g||te?"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:g||te?e.jsx(B.HiXMark,{className:"h-4 w-4"}):e.jsx(B.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),e.jsx("div",{role:"tablist","aria-label":v??"Modulos relacionados",className:`flex gap-1 overflow-x-auto border-b border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 transition-colors duration-200 ${Q}`,children:F.length>0?F.map(be=>{const j=be.service===(q==null?void 0:q.service);return e.jsx("button",{type:"button",role:"tab","aria-selected":j,disabled:be.disabled,onClick:()=>ce(be),onKeyDown:ee=>ie(ee,be),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 ${j?"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:M?M(be,j):e.jsxs(e.Fragment,{children:[be.icon,e.jsx("span",{children:be.label??Qa(be.service)}),be.badge&&e.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:be.badge})]})},be.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:A??"No hay modulos que coincidan con la busqueda."})}),(q==null?void 0:q.description)&&e.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:q.description}),e.jsxs("div",{className:"min-h-[420px] p-4",children:[!q&&(E??e.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-dashed border-[var(--border)] text-sm text-[var(--text-muted)]",children:"No hay modulos disponibles."})),q&&(Le==null?void 0:Le.loading)&&(h??e.jsx(Za,{title:"Cargando modulo..."})),q&&(Le==null?void 0:Le.error)&&$(Le.error,ge),q&&Cr&&!(Le!=null&&Le.loading)&&!(Le!=null&&Le.error)&&e.jsx(Cr,{context:s,parent:a,link:q,activeItemId:we,onOpenDetail:gr,onBackToList:Ue})]})]})]})}const El={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:e.jsx(B.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(B.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(B.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(B.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:e.jsx(B.HiInformationCircle,{className:"h-5 w-5"})}};function Ml({variant:r="info",title:t,children:n,icon:a,action:s,onDismiss:l,className:i=""}){const c=El[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:a??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}),n&&e.jsx("div",{className:"mt-0.5 text-sm leading-5 text-[var(--text-secondary)]",children:n}),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(B.HiXMark,{className:"h-4 w-4"})})]})}const Ra=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],Tl=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],Ll=["Do","Lu","Ma","Mi","Ju","Vi","Sá"],Kn=6;function Gn(r,t,n){return`${r}-${String(t).padStart(2,"0")}-${String(n).padStart(2,"0")}`}function $l(){const r=new Date;return Gn(r.getFullYear(),r.getMonth()+1,r.getDate())}function eo(r){const[t,n,a]=r.split("-").map(Number);return{year:t,month:n,day:a}}function Al(r){if(!r)return"Seleccionar fecha";const{year:t,month:n,day:a}=eo(r);return!t||!n||!a?"Seleccionar fecha":`${String(a).padStart(2,"0")} ${Ra[n-1]} ${t}`}function Dl({value:r,onChange:t,minDate:n,displayMode:a="inline"}){const s=$l(),i=eo(r||s),c=a==="popover",[d,u]=o.useState(!1),p=o.useRef(null),[b,m]=o.useState({horizontal:"left",vertical:"bottom"}),[v,y]=o.useState(i.year),[E,h]=o.useState(i.month),[$,M]=o.useState("days"),T=16,[L,C]=o.useState(0),k=v-7+L,V=Array.from({length:T},(Y,D)=>k+D);o.useEffect(()=>{if(!c||!d||!p.current)return;const Y=p.current.getBoundingClientRect(),D=8,re=280,le=340,I=Y.left+re>window.innerWidth-D,H=Y.right-re>=D,oe=Y.bottom+8+le>window.innerHeight-D,g=Y.top-8-le>=D;m({horizontal:I&&H?"right":"left",vertical:oe&&g?"top":"bottom"})},[c,d]),o.useEffect(()=>{if(!c||!d)return;function Y(re){p.current&&(p.current.contains(re.target)||u(!1))}function D(re){re.key==="Escape"&&u(!1)}return document.addEventListener("mousedown",Y),document.addEventListener("keydown",D),()=>{document.removeEventListener("mousedown",Y),document.removeEventListener("keydown",D)}},[c,d]);function A(){E===1?(y(Y=>Y-1),h(12)):h(Y=>Y-1)}function K(){E===12?(y(Y=>Y+1),h(1)):h(Y=>Y+1)}const W=new Date(v,E-1,1).getDay(),G=new Date(v,E,0).getDate(),w=[...Array(W).fill(null),...Array.from({length:G},(Y,D)=>D+1)];for(;w.length<Kn*7;)w.push(null);const Q=w.slice(0,Kn*7);function _(Y){const D=Gn(v,E,Y);n&&D<n||(t(D),c&&u(!1))}const P={background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,borderRadius:6,display:"flex",alignItems:"center"},ne=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:$==="days"?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:A,style:P,title:"Mes anterior",children:e.jsx(B.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>{M("years"),C(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:[Ra[E-1]," ",v,e.jsx(B.HiChevronDown,{size:13,style:{color:"var(--text-muted)"}})]}),e.jsx("button",{type:"button",onClick:K,style:P,title:"Mes siguiente",children:e.jsx(B.HiChevronRight,{size:16})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>C(Y=>Y-T),style:P,children:e.jsx(B.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>M("days"),style:{background:"none",border:"none",cursor:"pointer",fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[V[0]," – ",V[V.length-1]]}),e.jsx("button",{type:"button",onClick:()=>C(Y=>Y+T),style:P,children:e.jsx(B.HiChevronRight,{size:16})})]})}),$==="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:Tl.map((Y,D)=>{const re=D+1===E;return e.jsx("button",{type:"button",onClick:()=>h(D+1),style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:11,fontWeight:re?700:400,padding:"4px 0",background:re?"var(--primary)":"transparent",color:re?"var(--primary-fg, #ffffff)":"var(--text-secondary)"},children:Y},Y)})}),e.jsx("div",{style:{height:1,background:"var(--border)",marginBottom:8}}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3},children:V.map(Y=>{const D=Y===v;return e.jsx("button",{type:"button",onClick:()=>{y(Y),M("days")},style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:12,fontWeight:D?700:400,padding:"6px 0",background:D?"var(--primary)":"transparent",color:D?"var(--primary-fg, #ffffff)":"var(--text-main)",outline:Y===new Date().getFullYear()&&!D?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:Y},Y)})})]}),$==="days"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",padding:"6px 8px 0"},children:Ll.map(Y=>e.jsx("div",{style:{textAlign:"center",fontSize:10,fontWeight:700,color:"var(--text-muted)",padding:"2px 0",textTransform:"uppercase"},children:Y},Y))}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",gridTemplateRows:`repeat(${Kn},1fr)`,padding:"4px 8px 10px",gap:2},children:Q.map((Y,D)=>{if(Y===null)return e.jsx("div",{style:{aspectRatio:"1"}},D);const re=Gn(v,E,Y),le=re===r,I=re===s,H=!!(n&&re<n);return e.jsx("button",{type:"button",onClick:()=>!H&&_(Y),style:{width:"100%",aspectRatio:"1",borderRadius:6,border:"none",cursor:H?"not-allowed":"pointer",fontSize:12,fontWeight:le||I?700:400,background:le?"var(--primary)":"transparent",color:le?"var(--primary-fg, #ffffff)":H?"var(--text-muted)":"var(--text-main)",opacity:H?.4:1,outline:I&&!le?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:Y},D)})})]})]});return c?e.jsxs("div",{ref:p,className:"relative w-full",children:[e.jsxs("button",{type:"button",onClick:()=>u(Y=>!Y),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 ${d?"var(--primary)":"var(--border)"}`,color:"var(--text-main)",boxShadow:d?"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(B.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),e.jsx("span",{className:"truncate",children:Al(r)})]}),e.jsx(B.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${d?"rotate-180":""}`})]}),d&&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:ne})]}):ne}const Il={sm:"h-4 w-4",md:"h-5 w-5"};function Hl(r,t){if(typeof r=="function"){r(t);return}r&&(r.current=t)}const Xt=o.forwardRef(function({label:t,description:n,error:a,size:s="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:d,...u},p){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 ${d?"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",{...u,ref:m=>{b.current=m,Hl(p,m)},type:"checkbox",disabled:d,"aria-checked":l?"mixed":u["aria-checked"],"aria-invalid":!!a||u["aria-invalid"],className:`peer ${Il[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(B.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||n||a)&&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}),n&&!a&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:n}),a&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--danger)]",children:a})]})]})});function ro(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}ro(r)}function Bl(r){return typeof r=="function"?r():r}function Xn({value:r,resetDelay:t=2e3,title:n,copiedTitle:a="Copiado",copiedLabel:s,icon:l=e.jsx(B.HiClipboardDocument,{size:14}),copiedIcon:i=e.jsx(B.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:d,onCopyError:u,className:p="",style:b,children:m,onClick:v,type:y="button",...E}){const[h,$]=o.useState(!1),M=o.useRef(null);o.useEffect(()=>()=>{M.current&&window.clearTimeout(M.current)},[]);function T(C){$(!0),d==null||d(C),M.current&&window.clearTimeout(M.current),M.current=window.setTimeout(()=>{$(!1),M.current=null},t)}async function L(C){var V;if(c&&C.stopPropagation(),v==null||v(C),C.defaultPrevented)return;const k=Bl(r);if(k)try{await Ol(k),T(k)}catch(A){try{ro(k),T(k)}catch(K){u==null||u(K,k);return}(V=navigator.clipboard)!=null&&V.writeText||u==null||u(A,k)}}return e.jsxs("button",{...E,type:y,onClick:L,title:h?a:n,"aria-label":E["aria-label"]??(h?a:n),"data-copied":h?"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"} ${p}`,style:{cursor:"pointer",background:h?"rgba(22,163,74,0.15)":"var(--bg-card)",border:h?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:h?"#16a34a":"var(--text-secondary)",boxShadow:h?"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:h?"scale(1.15)":"scale(1)"},children:h?i:l}),m&&e.jsx("span",{className:"text-xs font-semibold leading-none",children:h?s??m:m})]})}function Pl({code:r,children:t,title:n="Codigo",language:a,copyLabel:s="Copiar",copiedLabel:l="Copiado",className:i="",style:c,onCopied:d}){const u=(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:n}),e.jsx(Xn,{value:u,title:"Copiar codigo",copiedTitle:"Codigo copiado",copiedLabel:l,onCopied:d,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:a?`language-${a}`:void 0,children:u})})]})}function Yn(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Zn(r){return r.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Fl(r,t){if(!t.trim())return!0;const n=Zn(t);return Zn(r.label).includes(n)||!!(r.sublabel&&Zn(r.sublabel).includes(n))}function Ar({value:r,onChange:t,options:n,status:a="default",ariaLabel:s,triggerVariant:l="default",showSelectedSublabel:i=!0,placeholder:c="Seleccionar…",emptyLabel:d,disabled:u=!1,className:p="",style:b,dropdownMinWidth:m,height:v=40,padding:y="0 10px",searchable:E=!0,minOptionsForSearch:h=6}){const[$,M]=o.useState(!1),[T,L]=o.useState(""),[C,k]=o.useState(-1),[V,A]=o.useState(!1),[K,W]=o.useState({}),G=o.useRef(null),w=o.useRef(null),Q=o.useRef(null),_=o.useRef(null),P=E&&n.length>=h,ne=n.find(Z=>Z.value===r)??null,Y=l==="ghost",D=a==="error"?"var(--danger)":$?"var(--primary)":"var(--border)",re=P&&T.trim()?n.filter(Z=>Fl(Z,T)):n,le=o.useCallback(()=>{const Z=G.current;if(!Z)return;const X=Z.getBoundingClientRect(),S=P?272:212,te=window.innerHeight-X.bottom,F=te<S&&X.top>te;W({position:"fixed",left:X.left,top:F?void 0:X.bottom+4,bottom:F?window.innerHeight-X.top+4:void 0,width:X.width,minWidth:Yn(m),zIndex:9999})},[m,P]);o.useEffect(()=>A(!0),[]),o.useEffect(()=>{if(!$)return;function Z(X){var te,F;const S=X.target;!((te=G.current)!=null&&te.contains(S))&&!((F=w.current)!=null&&F.contains(S))&&(M(!1),L(""))}return document.addEventListener("mousedown",Z),()=>document.removeEventListener("mousedown",Z)},[$]),o.useEffect(()=>{$&&(k(-1),le(),P&&setTimeout(()=>{var Z;return(Z=Q.current)==null?void 0:Z.focus()},0))},[$,P,le]),o.useEffect(()=>{if($)return window.addEventListener("resize",le),window.addEventListener("scroll",le,!0),()=>{window.removeEventListener("resize",le),window.removeEventListener("scroll",le,!0)}},[$,le]),o.useEffect(()=>{if(C<0||!_.current)return;const Z=_.current.children[C];Z==null||Z.scrollIntoView({block:"nearest"})},[C]);const I=o.useCallback(Z=>{t(Z),M(!1),L("")},[t]),H=o.useRef($);H.current=$;const oe=o.useRef(re);oe.current=re;const g=o.useRef(C);g.current=C;const O=o.useRef(d);O.current=d;const R=o.useRef(I);R.current=I,o.useEffect(()=>{function Z(X){var ae,q;const S=document.activeElement,te=((ae=G.current)==null?void 0:ae.contains(S))??!1,F=((q=w.current)==null?void 0:q.contains(S))??!1;if(!(!te&&!F)){if(!H.current){(X.key==="Enter"||X.key===" "||X.key==="ArrowDown")&&(X.preventDefault(),M(!0));return}switch(X.key){case"ArrowDown":X.preventDefault(),k(ce=>Math.min(ce+1,oe.current.length-1));break;case"ArrowUp":X.preventDefault(),k(ce=>Math.max(ce-1,O.current?-1:0));break;case"Enter":{X.preventDefault();const ce=g.current,Ee=oe.current;ce===-1&&O.current?R.current(""):Ee[ce]&&!Ee[ce].disabled&&R.current(Ee[ce].value);break}case"Escape":X.preventDefault(),X.stopPropagation(),M(!1),L("");break}}}return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[]);const se=e.jsxs("div",{ref:w,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...K,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[P&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(B.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:Q,value:T,onChange:Z=>{L(Z.target.value),k(-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:Z=>{Z.preventDefault(),L("")},children:e.jsx(B.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),e.jsxs("ul",{ref:_,role:"listbox",className:"overflow-y-auto",style:{maxHeight:P?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[d&&e.jsx("li",{role:"option","aria-selected":r==="",onMouseDown:Z=>{Z.preventDefault(),I("")},onMouseEnter:()=>k(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:C===-1&&!T.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:d}),re.map((Z,X)=>{const te=X===C,F=Z.value===r;return e.jsxs("li",{role:"option","aria-selected":F,onMouseDown:ae=>{ae.preventDefault(),Z.disabled||I(Z.value)},onMouseEnter:()=>!Z.disabled&&k(X),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:te?"var(--bg-hover)":F?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:Z.disabled?"var(--text-muted)":"var(--text-main)",cursor:Z.disabled?"not-allowed":"pointer",boxShadow:F?"inset 2px 0 0 var(--primary)":void 0},children:[Z.color&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:Z.color}}),e.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:Z.label}),Z.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:Z.sublabel})]}),Z.badge&&e.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:Z.badge})]},Z.value)}),re.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:G,className:`relative ${p||"w-full"}`,style:b,children:[e.jsxs("button",{type:"button",disabled:u,onClick:()=>!u&&M(Z=>!Z),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:Yn(v),padding:Yn(y),background:Y?"transparent":"var(--bg-input)",color:ne?"var(--text-main)":"var(--text-muted)",border:Y?"1px solid transparent":`1px solid ${D}`,opacity:u?.5:1,cursor:u?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":$,"aria-label":s,children:[(ne==null?void 0:ne.color)&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:ne.color}}),e.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:ne?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"truncate",children:ne.label}),i&&ne.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:ne.sublabel})]}):e.jsx("span",{className:"truncate",children:c})}),ne&&d?e.jsx("span",{role:"button",tabIndex:-1,onMouseDown:Z=>{Z.preventDefault(),Z.stopPropagation(),I("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(B.HiXMark,{className:"w-3 h-3"})}):e.jsx(B.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:$?"rotate(180deg)":"rotate(0deg)"}})]}),$&&V&&tr.createPortal(se,document.body)]})}function Yt(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function zl({value:r,onChange:t,placeholder:n="Buscar...",className:a="",height:s=40,padding:l="0 10px 0 30px",iconLeft:i=10}){return e.jsxs("div",{className:`relative ${a}`,children:[e.jsx(B.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:Yt(i)}}),e.jsx("input",{type:"text",value:r,onChange:c=>t(c.target.value),placeholder:n,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:Yt(s),padding:Yt(l)}})]})}function _l({value:r,onChange:t,options:n,placeholder:a,icon:s,className:l="",height:i=40,padding:c,iconLeft:d=10,searchable:u=!0}){const p=s?n.map((b,m)=>m===0&&!b.color?{...b,sublabel:b.sublabel??void 0}:b):n;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:Yt(d)},children:s}),e.jsx(Ar,{value:r,onChange:t,options:p,placeholder:a,searchable:u,minOptionsForSearch:5,height:i,padding:c??(s?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const jl={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},Zt=180,Wl="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Qn({open:r,onClose:t,title:n,subtitle:a,leadingIcon:s,headerActions:l,footer:i,children:c,size:d="md",maxWidth:u,zIndex:p=1e3,closeOnBackdrop:b=!0,closeOnEscape:m=!0,showCloseButton:v=!0,placement:y="center",bodyClassName:E="px-6 py-5",panelClassName:h="",backdropClassName:$=Wl,contentClassName:M="p-4",ariaLabel:T,frameless:L=!1,disabled:C=!1}){const[k,V]=o.useState(!1),[A,K]=o.useState(!1),W=o.useRef(null);if(o.useEffect(()=>(r?(W.current&&clearTimeout(W.current),V(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>K(!0)))):(K(!1),W.current=setTimeout(()=>V(!1),Zt+40)),()=>{W.current&&clearTimeout(W.current)}),[r]),o.useEffect(()=>{if(r)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[r]),o.useEffect(()=>{if(!r||!m)return;const ne=Y=>{Y.key==="Escape"&&t()};return window.addEventListener("keydown",ne),()=>window.removeEventListener("keydown",ne)},[m,t,r]),!k)return null;const G=n||a||s||l||v,w=u??jl[d],Q=y==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",_=y==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",P=A?"translateY(0) scale(1)":y==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return tr.createPortal(e.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":T??n,className:`fixed inset-0 flex ${Q} ${M}`,style:{zIndex:p},children:[e.jsx("div",{className:`absolute inset-0 ${$}`,onClick:b?t:void 0,style:{opacity:A?1:0,transition:`opacity ${Zt}ms ease`}}),e.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${L?"shadow-none":"shadow-2xl"} ${_} ${h}`,style:{maxWidth:w,background:L?"transparent":"var(--bg-card)",border:L?"none":"1px solid var(--border)",opacity:A?1:0,transform:P,transition:`opacity ${Zt}ms ease, transform ${Zt}ms ease`},onClick:ne=>ne.stopPropagation(),children:[C&&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)"}}),G&&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}),(n||a)&&e.jsxs("div",{className:"min-w-0",children:[n&&e.jsx("h2",{className:"truncate text-base font-semibold",style:{color:"var(--text-main)"},children:n}),a&&e.jsx("p",{className:"truncate text-xs",style:{color:"var(--text-muted)"},children:a})]})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[l,v&&e.jsx(He,{variant:"icon",onClick:t,title:"Cerrar",children:e.jsx(B.HiXMark,{className:"h-5 w-5"})})]})]}),e.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${E}`,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 ql={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 Ul({open:r,title:t,description:n,confirmLabel:a="Confirmar",cancelLabel:s="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:d}){const u=ql[l];return e.jsx(Qn,{open:r,onClose:d,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:d,className:"absolute right-3 top-3 h-8 w-8 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:e.jsx(B.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:u.iconBg},children:e.jsx(B.HiExclamationTriangle,{className:"h-5 w-5",style:{color:u.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}),n?e.jsx("div",{className:"mt-1.5 text-sm leading-relaxed",style:{color:"var(--text-muted)"},children:n}):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:d,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:u.btnBg,color:u.btnColor,borderColor:"transparent"},children:a})]})]})})}function Vl(r){return r?typeof r=="function"?r():r:""}function Kl(r){return/^https?:\/\//i.test(r)}function to(r,t){try{return new URL(r,t).toString()}catch{return r}}function Gl(r,t,n,a=!1){const s=typeof r=="function"?r():r,l=t?t(s):s;if(!l||Kl(l))return l;const i=Vl(n);return i?to(l,i):a&&typeof window<"u"?to(l,window.location.origin):l}function Xl({url:r,resolveUrl:t,baseUrl:n,useWindowOriginForRelative:a=!1,title:s="Copiar link",copiedTitle:l="Link copiado",icon:i=e.jsx(B.HiLink,{className:"h-3.5 w-3.5"}),...c}){return e.jsx(Xn,{...c,value:()=>Gl(r,t,n,a),title:s,copiedTitle:l,icon:i})}const Qt=[25,50,100,200,500];let nr={dataTable:{pageSizeOptions:[...Qt]}};function Yl(){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 Jn(){const r=nr.dataTable.preferencesEndpoint,t=Yl();return r&&r.trim().length>0?r.trim().replace(/\/+$/,""):t}function Zl(r){if(!Array.isArray(r))return[...Qt];const t=Array.from(new Set(r.map(n=>typeof n=="number"?Math.floor(n):Number.NaN).filter(n=>Number.isFinite(n)&&n>0)));return t.length>0?t:[...Qt]}function no(r){if(typeof r!="string")return;const t=r.trim();if(t)return t.replace(/\/+$/,"")}function Ql(r){if(!r||typeof r!="object"||!r.dataTable)return;const t=no(r.dataTable.preferencesEndpoint);nr={...nr,dataTable:{...nr.dataTable,pageSizeOptions:Zl(r.dataTable.pageSizeOptions),preferencesEndpoint:t??nr.dataTable.preferencesEndpoint}}}function Jl(){return{dataTable:{pageSizeOptions:[...nr.dataTable.pageSizeOptions]}}}function xt(){return[...nr.dataTable.pageSizeOptions]}function Rl(){nr={dataTable:{pageSizeOptions:[...Qt]}}}function ei(r){nr={...nr,dataTable:{...nr.dataTable,preferencesEndpoint:no(r)}}}const Jt=[{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"}],ri=Jt.map(r=>({value:r.value,label:r.label})),ti=12,ni={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},ao={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},ai="bonsaif-ui:datatable:",oi="[&_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",si=[],li=52;function mr(r){if(!r)return 150;const t=parseInt(r,10);return isNaN(t)||t<=0?150:t}function oo(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 so(r){return`${ai}${r}`}function Rt(r){try{const t=window.localStorage.getItem(so(r));if(!t)return null;const n=JSON.parse(t);return n&&typeof n=="object"?n:null}catch{return null}}function ii(r,t){try{window.localStorage.setItem(so(r),JSON.stringify(t))}catch{}}function ci(r,t){if(r===!0)return{...ao};if(r===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(t&&r==null)return{...ao};const n={...ni,...r??{}};return t&&(typeof r!="object"||r.pagination!==!1)&&(n.pagination=!0),n}function lo(...r){return r.reduce((t,n)=>({...t,...n??{}}),{})}function Rn(r,t,n){return typeof r!="number"||r<=0?n:St(t).includes(r)?r:n}function yt(r){if(!r||typeof r!="object")return!1;const t=r;return typeof t.key=="string"&&(t.dir==="asc"||t.dir==="desc")}function wt(r,t){if(!r||typeof r!="object"||Array.isArray(r))return{};const n=Object.entries(r).flatMap(([a,s])=>{if(!t.has(a)||!Array.isArray(s))return[];const l=s.filter(i=>typeof i=="string");return l.length>0?[[a,l]]:[]});return Object.fromEntries(n)}function Nt(r,t){if(!r||typeof r!="object"||Array.isArray(r))return{};const n=new Set(Jt.map(s=>s.value)),a=Object.entries(r).flatMap(([s,l])=>{if(!t.has(s)||!l||typeof l!="object")return[];const i=l;return!i.operator||!n.has(i.operator)?[]:[[s,{operator:i.operator,value:typeof i.value=="string"?i.value:"",valueTo:typeof i.valueTo=="string"?i.valueTo:""}]]});return Object.fromEntries(a)}function Ze(r,t){if(Dr(r))return li;const n=r.minWidth??80,a=r.maxWidth??1/0;return Math.min(a,Math.max(n,t))}function di(r){const t=window.getComputedStyle(r);return parseFloat(t.paddingLeft)+parseFloat(t.paddingRight)}function Dr(r){return r.key==="actions"||r.key==="acciones"?!0:typeof r.header=="string"&&r.header.trim().toLowerCase()==="acciones"}function ea(r){return r.sticky===!0}function io(r){return!(r.reorderable===!1||r.sticky&&r.reorderable!==!0)}function wr(r,t){const n=t.filter(ea).map(i=>i.key);if(n.length===0)return r;const a=new Set(n),s=n.filter(i=>r.includes(i)),l=r.filter(i=>!a.has(i));return[...s,...l]}function ui(r,t){if(t<=7)return Array.from({length:t},(a,s)=>s+1);const n=[1];r>3&&n.push("...");for(let a=Math.max(2,r-1);a<=Math.min(t-1,r+1);a++)n.push(a);return r<t-2&&n.push("..."),n.push(t),n}function Nr(r,t){var i;const n=new Set(t.filter(c=>c.hideable!==!1).map(c=>c.key)),a=Array.from(new Set(r??[])).filter(c=>n.has(c));if(t.filter(c=>!a.includes(c.key)).length>0)return a;const l=(i=t.find(c=>c.hideable!==!1))==null?void 0:i.key;return l?a.filter(c=>c!==l):[]}function fi(r){return r==null||r===""?"(Vacio)":r instanceof Date?r.toLocaleDateString():String(r)}function Xr(r){return r==null||typeof r=="boolean"?"":typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(Xr).join(" ").trim():o.isValidElement(r)?Xr(r.props.children):""}function en(r,t){const n=r.filterValue?r.filterValue(t):r.sortKey?t[r.sortKey]:r.cell(t);return typeof n=="string"||typeof n=="number"||typeof n=="boolean"||n===null||n===void 0||n instanceof Date?fi(n):Xr(n).trim()}function kt(r){const t=r.replace(/,/g,"").trim();if(!t)return null;const n=Number(t);return Number.isFinite(n)?n:null}function Yr(r,t){const n=kt(r),a=kt(t);return n!==null&&a!==null?n-a:r.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function St(r){const t=Array.from(new Set(r.map(n=>Math.floor(n)).filter(n=>Number.isFinite(n)&&n>0)));return t.length>0?t:xt()}function bi(r,t,n){var i,c;const a=((i=t.value)==null?void 0:i.trim())??"",s=((c=t.valueTo)==null?void 0:c.trim())??"",l=Jt.find(d=>d.value===t.operator);if((l==null?void 0:l.valueMode)==="single"&&!a||(l==null?void 0:l.valueMode)==="between"&&(!a||!s))return!0;switch(t.operator){case"equals":return r.toLowerCase()===a.toLowerCase();case"notEquals":return r.toLowerCase()!==a.toLowerCase();case"greaterThan":return Yr(r,a)>0;case"greaterThanOrEqual":return Yr(r,a)>=0;case"lessThan":return Yr(r,a)<0;case"lessThanOrEqual":return Yr(r,a)<=0;case"between":return Yr(r,a)>=0&&Yr(r,s)<=0;case"top10":case"bottom10":{const u=n.map(b=>({value:b,number:kt(b)})).filter(b=>b.number!==null).sort((b,m)=>b.number-m.number).map(b=>b.value);return(t.operator==="top10"?u.slice(-10):u.slice(0,10)).includes(r)}case"aboveAverage":case"belowAverage":{const d=n.map(kt).filter(b=>b!==null);if(d.length===0)return!1;const u=d.reduce((b,m)=>b+m,0)/d.length,p=kt(r);return p===null?!1:t.operator==="aboveAverage"?p>u:p<u}default:return!0}}function co({children:r,className:t="",style:n}){return e.jsx($r,{onlyWhenOverflow:!0,className:t,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",...n},children:r})}function uo({columns:r,data:t,getRowId:n,loading:a=!1,skeletonRows:s=8,emptyIcon:l,emptyText:i="Sin resultados",initialEmptyDelay:c=450,onRowClick:d,renderExpandedRow:u,getRowCanExpand:p,expandedRowIds:b,defaultExpandedRowIds:m=[],onExpandedRowIdsChange:v,expandOnRowClick:y=!1,selected:E,onToggleOne:h,onToggleAll:$,highlightSelected:M=!0,rowClassName:T,getRowCategory:L,stickyHeader:C=!0,pageSize:k=25,pageSizeOptions:V,pageSizeSelectWidth:A=62,pageSizeSelectHeight:K=30,pageSizeSelectPadding:W="0 7px",totalRows:G,page:w,onPageChange:Q,onPageSizeChange:_,storageKey:P,stickyFirstColumn:ne=!1,bottomOffset:Y=0,compact:D=!0,restrictHeight:re=!0,maxHeight:le,minTableWidth:I,enableColumnVisibility:H=!0,enableColumnFilters:oe=!0,hiddenColumnKeys:g,defaultHiddenColumnKeys:O=si,onHiddenColumnKeysChange:R,columnVisibilityLabel:se="Columnas",enableBql:Z=!1,bqlValue:X,defaultBqlValue:S="",onBqlChange:te,bqlDescription:F="Filtra registros con Bonsaif Query Language",bqlPlaceholder:ae=`status = activo
2
+ rol IN (admin, employee)`,bqlQuickFilters:q=[],bqlExamples:ce=[],bqlSuggestions:Ee=[],bqlActiveFilters:ie,bqlError:ge,onQueryChange:we,persistState:Le,onPreferencesReady:Cr,enableExport:gr=!1,exportFilename:Ue="datos"}){var ol;const de=ci(Le,P),Re=Object.values(de).some(Boolean),cr=r.map(f=>f.key).join(","),be=O.join(","),j=o.useRef(r),ee=o.useRef(O);j.current=r,ee.current=O;const[fe,pe]=o.useState(!P||!Re),De=o.useRef(null),Me=o.useRef(!P),Be=o.useRef(!1),$e=o.useRef(Cr);$e.current=Cr;const Ke=o.useRef(!P||!Re?P??"__none__":null),Pe=g!==void 0,[wn,Xe]=o.useState(()=>Nr(O,r)),je=Nr(Pe?g:wn,r),[Ye,Or]=o.useState(!1),[dr,hu]=o.useState("filter"),[Ot,Nn]=o.useState(null),[Es,Ms]=o.useState(""),[er,ot]=o.useState({}),[ur,Bt]=o.useState({}),Ca=b!==void 0,[Ts,gu]=o.useState(m),Br=X!==void 0,[vu,Pt]=o.useState(S),vr=Br?X:vu,[Ft,kn]=o.useState(vr),[xr,Pr]=o.useState(!1),[Ls,st]=o.useState(!1),[$s,lt]=o.useState(!1),[zt,it]=o.useState([]),ct=o.useRef(null),Fr=o.useRef(null),fr=o.useRef(te);fr.current=te;const Sn=o.useRef(k);Sn.current=k;const Cn=o.useRef(V);Cn.current=V;const xu=Array.isArray(V)?V.join(","):"",Ea=o.useRef(null),As=o.useRef(null),Ma=o.useRef(null),Ds=o.useRef(0),[yu,wu]=o.useState({}),[Nu,ku]=o.useState({}),[_t,En]=o.useState(!1),Ta=o.useRef(null),Mn=o.useRef(null),[Su,Cu]=o.useState({}),Is=o.useRef(null),Tn=o.useRef(null),[La,Hs]=o.useState(t.length>0||a||c===!1),Os=(f,x)=>50+(f*17+x*13+7)%40,Er=o.useRef(null),[Eu,Mu]=o.useState(void 0),[Bs,Tu]=o.useState(0),[Lu,$u]=o.useState(!1);o.useEffect(()=>{function f(){$u(window.innerWidth<640)}if(!re||le!==void 0)return f(),window.addEventListener("resize",f),()=>window.removeEventListener("resize",f);const z=k!==!1?48:0,N=12;function J(){if(f(),!Er.current)return;const ue=Er.current.getBoundingClientRect().top;Mu(Math.max(120,window.innerHeight-ue-z-N-Y))}return J(),window.addEventListener("resize",J),()=>window.removeEventListener("resize",J)},[a,k,Y,re,le]);const Ps=re?le??Eu:void 0;o.useEffect(()=>{const f=Er.current;if(!f)return;const x=()=>Tu(f.clientWidth);if(x(),typeof ResizeObserver>"u")return window.addEventListener("resize",x),()=>window.removeEventListener("resize",x);const z=new ResizeObserver(x);return z.observe(f),()=>z.disconnect()},[a,fe,t.length]),o.useEffect(()=>{if(c===!1||a||t.length>0){Hs(!0);return}if(La)return;const f=window.setTimeout(()=>{Hs(!0)},c);return()=>window.clearTimeout(f)},[t.length,c,La,a]);const[dt,ut]=o.useState(()=>wr(r.map(f=>f.key),r)),[zr,ft]=o.useState(()=>Object.fromEntries(r.map(f=>[f.key,Ze(f,mr(f.width))]))),[Oe,_r]=o.useState(null),[Au,Ln]=o.useState(1),[$n,An]=o.useState(k===!1?0:k);o.useEffect(()=>{var Ce;const f=j.current,x=ee.current,z=f.map(ve=>ve.key),N=new Set(z),J=()=>{var ve;Be.current||(Be.current=!0,(ve=$e.current)==null||ve.call($e))};if(!P||!Re){de.layout&&ut(wr(z,f)),Pe||Xe(Nr(x,f)),Me.current=!1,pe(!0),J();return}let ue=!1;const me=Ke.current===P;me||(Me.current=!1,pe(!1),Be.current=!1);const ke=Rt(P);if(oo(ke)&&!me){const ve=ke,he=St(Cn.current??xt()),xe=Sn.current,Kr=xe===!1?0:xe,Mr=de.layout?ve==null?void 0:ve.columnOrder:void 0,Tr=Array.isArray(Mr)?Mr.filter(Ae=>z.includes(Ae)):[],Lr=z.filter(Ae=>!Tr.includes(Ae)),Gr=wr(Tr.length>0?[...Tr,...Lr]:z,f),mt=Object.fromEntries(f.map(Ae=>[Ae.key,Ze(Ae,mr(Ae.width))])),ht=de.layout?(ve==null?void 0:ve.columnWidths)??{}:{},Ut=Object.fromEntries(f.map(Ae=>[Ae.key,Ze(Ae,ht[Ae.key]??mt[Ae.key])])),gt=Nr(de.layout?(ve==null?void 0:ve.hiddenColumnKeys)??x:x,f);if(de.layout&&(ut(Gr),ft(Ut)),Pe||Xe(gt),de.filters&&(ot(wt(ve==null?void 0:ve.filters,N)),Bt(Nt(ve==null?void 0:ve.conditionFilters,N))),de.sort){const Ae=yt(ve==null?void 0:ve.sort)?ve.sort:null;_r(Ae&&N.has(Ae.key)?Ae:null)}if(de.bql){if(ct.current!==P){ct.current=P;const Ae=typeof(ve==null?void 0:ve.bql)=="string"?ve.bql:S;Br?(Ce=fr.current)==null||Ce.call(fr,Ae):Pt(Ae)}it(Array.isArray(ve==null?void 0:ve.bqlHistory)?ve.bqlHistory.filter(Ae=>typeof Ae=="string"):[])}de.pagination&&Fr.current!==P&&(Fr.current=P,An(Rn(ve==null?void 0:ve.pageSize,he,Kr))),Ke.current=P,pe(!0),J()}const Ve=`${Jn()??"/api/user/preferences/datatables"}?key=${encodeURIComponent(P)}`,Se=new AbortController,Ne=window.setTimeout(()=>Se.abort(),2500);return fetch(Ve,{cache:"no-store",signal:Se.signal}).then(ve=>ve.ok?ve.json():null).then(ve=>{var sl;if(ue)return;const he=Rt(P),xe=lo(oo(ve==null?void 0:ve.settings)?ve==null?void 0:ve.settings:null,he),Kr=St(Cn.current??xt()),Mr=Sn.current,Tr=Mr===!1?0:Mr,Lr=de.layout?xe==null?void 0:xe.columnOrder:void 0,Gr=Array.isArray(Lr)?Lr.filter(Fe=>z.includes(Fe)):[],mt=z.filter(Fe=>!Gr.includes(Fe)),ht=wr(Gr.length>0?[...Gr,...mt]:z,f),Ut=Object.fromEntries(f.map(Fe=>[Fe.key,Ze(Fe,mr(Fe.width))])),gt=de.layout?(xe==null?void 0:xe.columnWidths)??{}:{},Ae=Object.fromEntries(f.map(Fe=>[Fe.key,Ze(Fe,gt[Fe.key]??Ut[Fe.key])])),vt=Nr(de.layout?(xe==null?void 0:xe.hiddenColumnKeys)??x:x,f);if(de.layout&&(ut(ht),ft(Ae)),Pe||Xe(vt),de.filters&&(ot(wt(xe==null?void 0:xe.filters,N)),Bt(Nt(xe==null?void 0:xe.conditionFilters,N))),de.sort){const Fe=yt(xe==null?void 0:xe.sort)?xe.sort:null;_r(Fe&&N.has(Fe.key)?Fe:null)}if(de.bql){if(ct.current!==P){ct.current=P;const Fe=typeof(xe==null?void 0:xe.bql)=="string"?xe.bql:S;Br?(sl=fr.current)==null||sl.call(fr,Fe):Pt(Fe)}it(Array.isArray(xe==null?void 0:xe.bqlHistory)?xe.bqlHistory.filter(Fe=>typeof Fe=="string"):[])}let Ie;de.pagination&&(Ie=Rn(xe==null?void 0:xe.pageSize,Kr,Tr),Fr.current!==P&&(Fr.current=P,An(Ie))),De.current=JSON.stringify({columnOrder:ht,columnWidths:Ae,hiddenColumnKeys:vt,filters:wt(xe==null?void 0:xe.filters,N),conditionFilters:Nt(xe==null?void 0:xe.conditionFilters,N),sort:yt(xe==null?void 0:xe.sort)?xe.sort:null,bql:typeof(xe==null?void 0:xe.bql)=="string"?xe.bql:"",bqlHistory:Array.isArray(xe==null?void 0:xe.bqlHistory)?xe.bqlHistory:[],pageSize:de.pagination&&Mr!==!1?Ie:void 0}),Me.current=!0}).catch(()=>{var ve;if(!ue){const he=Rt(P),xe=St(Cn.current??xt()),Kr=Sn.current,Mr=Kr===!1?0:Kr,Tr=de.layout?he==null?void 0:he.columnOrder:void 0,Lr=Array.isArray(Tr)?Tr.filter(Ie=>z.includes(Ie)):[],Gr=z.filter(Ie=>!Lr.includes(Ie)),mt=wr(Lr.length>0?[...Lr,...Gr]:z,f),ht=Object.fromEntries(f.map(Ie=>[Ie.key,Ze(Ie,mr(Ie.width))])),Ut=de.layout?(he==null?void 0:he.columnWidths)??{}:{},gt=Object.fromEntries(f.map(Ie=>[Ie.key,Ze(Ie,Ut[Ie.key]??ht[Ie.key])]));de.layout&&(ut(mt),ft(gt));const Ae=Nr(de.layout?(he==null?void 0:he.hiddenColumnKeys)??x:x,f);if(Pe||Xe(Ae),de.filters&&(ot(wt(he==null?void 0:he.filters,N)),Bt(Nt(he==null?void 0:he.conditionFilters,N))),de.sort){const Ie=yt(he==null?void 0:he.sort)?he.sort:null;_r(Ie&&N.has(Ie.key)?Ie:null)}if(de.bql){if(ct.current!==P){ct.current=P;const Ie=typeof(he==null?void 0:he.bql)=="string"?he.bql:S;Br?(ve=fr.current)==null||ve.call(fr,Ie):Pt(Ie)}it(Array.isArray(he==null?void 0:he.bqlHistory)?he.bqlHistory.filter(Ie=>typeof Ie=="string"):[])}let vt;de.pagination&&(vt=Rn(he==null?void 0:he.pageSize,xe,Mr),Fr.current!==P&&(Fr.current=P,An(vt))),De.current=JSON.stringify({columnOrder:mt,columnWidths:gt,hiddenColumnKeys:Ae,filters:wt(he==null?void 0:he.filters,N),conditionFilters:Nt(he==null?void 0:he.conditionFilters,N),sort:yt(he==null?void 0:he.sort)?he.sort:null,bql:typeof(he==null?void 0:he.bql)=="string"?he.bql:"",bqlHistory:Array.isArray(he==null?void 0:he.bqlHistory)?he.bqlHistory:[],pageSize:de.pagination&&Kr!==!1?vt:void 0}),Me.current=!0}}).finally(()=>{window.clearTimeout(Ne),ue||(Ke.current=P,pe(!0),J())}),()=>{ue=!0,Se.abort(),window.clearTimeout(Ne)}},[P,Re,cr,be,Pe,de.layout,de.filters,de.sort,de.bql,de.pagination,Br,S,xu]),o.useEffect(()=>{if(!P||!fe||!Re||!Me.current)return;const f={};de.layout&&(f.columnOrder=dt,f.columnWidths=zr,f.hiddenColumnKeys=je),de.filters&&(f.filters=er,f.conditionFilters=ur),de.sort&&(f.sort=Oe),de.bql&&(f.bql=vr,f.bqlHistory=zt),de.pagination&&k!==!1&&(f.pageSize=$n);const x=Rt(P),z=lo(x,f),N=JSON.stringify(z);if(N===De.current)return;ii(P,z),De.current=N;const J=window.setTimeout(()=>{const ue=Jn()??"/api/user/preferences/datatables";fetch(ue,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:P,settings:z})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(J)},[dt,zr,je,er,ur,Oe,vr,zt,$n,k,P,fe,Re,de.layout,de.filters,de.sort,de.bql,de.pagination]),o.useEffect(()=>{ut(f=>{const x=r.map(J=>J.key),z=f.filter(J=>x.includes(J)),N=x.filter(J=>!z.includes(J));return wr([...z,...N],r)})},[cr,r]);const Fs=wr(dt,r).map(f=>r.find(x=>x.key===f)).filter(f=>!!f),rr=Fs.filter(f=>!je.includes(f.key)),zs=r.some(ea),Du=Object.keys(er).length,Iu=Object.keys(ur).length,$a=Du+Iu;function _s(f){const x=new Set;return t.reduce((z,N)=>{const J=en(f,N);return!J||x.has(J)||(x.add(J),z.push({value:J,label:J})),z},[])}function Hu(){const f=r.find(x=>x.key===Ot);return f?_s(f):[]}function Ou(f){return!!(oe&&!Dr(f)&&(f.filterValue||f.sortKey||_s(f).length>0))}function js(f,x){ot(z=>{const N={...z};return N[f]=x,N})}function Bu(f,x,z,N){const J=er[f]??[],ue=N?J:z.filter(ke=>ke!==x),me=N?J.includes(x)?J.filter(ke=>ke!==x):[...J,x]:ue;me.length===z.length?Aa(f):js(f,me)}function Aa(f){ot(x=>{const z={...x};return delete z[f],z})}function Dn(f,x){Bt(z=>{const N={...z};return x?N[f]=x:delete N[f],N})}function Ws(f){Dn(f,null)}function Pu(){ot({}),Bt({})}function Fu(f){Br||Pt(f),te==null||te(f)}function qs(f){const x=f.trim();kn(x),(te==null?void 0:te(x))!==!1&&(Br||Pt(x),Pr(!1),st(!1),lt(!1),x&&it(N=>[x,...N.filter(J=>J!==x)].slice(0,ti)))}function Us(){kn(""),Fu(""),Pr(!1),st(!1),lt(!1)}function Da(f,x){kn(f),x&&(x.style.height="auto",x.style.height=`${Math.min(x.scrollHeight,180)}px`)}function In(f){const x=f.trim();if(!x)return;Ds.current=Date.now()+500;const z=Ft.replace(/\s+$/u,""),N=z.length===0?x:z.split(`
3
+ `).map(J=>J.trim()).includes(x)?z:`${z}
4
+ ${x}`;Da(N,Ma.current??void 0),requestAnimationFrame(()=>{const J=Ma.current;if(!J)return;J.focus();const ue=J.value.length;J.setSelectionRange(ue,ue),Da(J.value,J)})}o.useEffect(()=>{kn(vr)},[vr]);const Hn=o.useCallback(()=>{const f=Ea.current;if(!f)return;const x=f.getBoundingClientRect(),z=12,N=8,J=Math.min(780,Math.max(320,window.innerWidth-32)),ue=Math.max(z,window.innerWidth-J-z),me=Math.min(Math.max(z,x.left),ue),ke=x.bottom+N,We=window.innerHeight-x.top+N,_e=window.innerHeight-ke-z,Ve=x.top-z-N,Se=_e<280&&Ve>_e,Ne=Math.max(240,Se?Ve:_e);wu({position:"fixed",zIndex:1e4,left:me,top:Se?void 0:ke,bottom:Se?We:void 0,width:J,maxWidth:"calc(100vw - 24px)",maxHeight:Ne,overflowY:"auto"})},[]);o.useEffect(()=>{if(!xr)return;function f(N){var ue,me;if(Date.now()<Ds.current)return;const J=N.target;(ue=Ea.current)!=null&&ue.contains(J)||(me=As.current)!=null&&me.contains(J)||(Pr(!1),st(!1),lt(!1))}function x(N){N.key==="Escape"&&(Pr(!1),st(!1),lt(!1))}function z(){Hn()}return Hn(),document.addEventListener("mousedown",f),window.addEventListener("keydown",x),window.addEventListener("resize",z),window.addEventListener("scroll",z,!0),()=>{document.removeEventListener("mousedown",f),window.removeEventListener("keydown",x),window.removeEventListener("resize",z),window.removeEventListener("scroll",z,!0)}},[xr,Hn]);function Vs(f){const x=Nr(f,r);Pe||Xe(x),R==null||R(x)}function zu(f){Vs(je.includes(f)?je.filter(x=>x!==f):[...je,f])}function _u(){Vs([])}const Ia=o.useCallback((f=Tn.current)=>{if(!f)return;const x=f.getBoundingClientRect(),z=Math.min(292,Math.max(240,window.innerWidth-16)),N=Math.max(8,window.innerWidth-z-8),J=Math.min(Math.max(8,x.right-z),N),ue=window.innerHeight-x.bottom,me=x.bottom+6,ke=window.innerHeight-x.top+6,_e=ue<360&&x.top>ue?void 0:me,Ve=_e===void 0?ke:void 0,Se=Math.max(220,_e===void 0?x.top-16:window.innerHeight-me-8),Ne={position:"fixed",zIndex:9999,left:J,top:_e,bottom:Ve,width:z,maxWidth:"calc(100vw - 16px)",maxHeight:Se,"--dt-column-menu-max-height":`${Se}px`};ku(Ne)},[]);function Ks(f,x,z=null){f.preventDefault(),f.stopPropagation();const N=Tn.current===f.currentTarget&&dr===x&&Ot===z;if(Ye&&N){Or(!1),Nn(null);return}Tn.current=f.currentTarget,hu(x),Nn(z),Ms(""),Ia(f.currentTarget),Or(!0)}function ju(f){if(Dr(f))return;const x=Er.current;if(!x)return;const N=Array.from(x.querySelectorAll("[data-dt-column-key]")).filter(J=>J.dataset.dtColumnKey===f.key).reduce((J,ue)=>{const me=ue.querySelector("[data-dt-autofit-content]"),ke=me?me.scrollWidth:Math.max(ue.scrollWidth,ue.offsetWidth);return Math.max(J,Math.ceil(ke+di(ue)))},0);N<=0||ft(J=>({...J,[f.key]:Ze(f,N+12)}))}o.useEffect(()=>{ft(f=>{const x=Object.fromEntries(r.map(z=>[z.key,Ze(z,mr(z.width))]));return Object.fromEntries(r.map(z=>[z.key,Ze(z,f[z.key]??x[z.key])]))})},[cr,r]),o.useEffect(()=>{Pe||Xe(f=>Nr(f,r))},[cr,r,Pe]),o.useEffect(()=>{function f(N){var me,ke;const J=N.target,ue=N.target;ue!=null&&ue.closest("[data-bonsaif-select-dropdown='true']")||!((me=Is.current)!=null&&me.contains(J))&&!((ke=Tn.current)!=null&&ke.contains(J))&&(Or(!1),Nn(null))}function x(N){N.key==="Escape"&&(Or(!1),Nn(null))}function z(){Ia()}return Ye&&(document.addEventListener("mousedown",f),window.addEventListener("keydown",x),window.addEventListener("resize",z),window.addEventListener("scroll",z,!0)),()=>{document.removeEventListener("mousedown",f),window.removeEventListener("keydown",x),window.removeEventListener("resize",z),window.removeEventListener("scroll",z,!0)}},[Ye,Ia]);const jt=o.useRef(null);o.useEffect(()=>{function f(z){const N=jt.current;if(!N)return;const J=z.clientX-N.startX,ue=r.find(me=>me.key===N.colKey);ue&&ft(me=>({...me,[N.colKey]:Ze(ue,N.startWidth+J)}))}function x(){jt.current&&(jt.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",f),document.addEventListener("pointerup",x),()=>{document.removeEventListener("pointermove",f),document.removeEventListener("pointerup",x)}},[r]);const Wt=o.useRef(null),[Gs,Ha]=o.useState(null);function Wu(f,x){const z=r.find(N=>N.key===f);if(!z||!io(z)){x.preventDefault();return}Wt.current=dt.indexOf(f),x.dataTransfer.effectAllowed="move"}function qu(f,x){x.preventDefault(),x.dataTransfer.dropEffect="move";const z=dt.indexOf(f);Gs!==z&&Ha(z)}function Uu(f,x){x.preventDefault();const z=Wt.current,N=dt.indexOf(f);z!==null&&z!==N&&ut(J=>{const ue=[...J],[me]=ue.splice(z,1);return ue.splice(N,0,me),wr(ue,r)}),Wt.current=null,Ha(null)}function Vu(){Wt.current=null,Ha(null)}function Ku(f){f.sortKey&&_r(x=>(x==null?void 0:x.key)===f.key?{key:f.key,dir:x.dir==="asc"?"desc":"asc"}:{key:f.key,dir:"asc"})}o.useEffect(()=>{Ln(1)},[t]),o.useEffect(()=>{Ln(1)},[ur,er]);const jr=!!(Q&&_),Wr=k!==!1,Xs=o.useMemo(()=>St(V??xt()),[V]),qe=jr?w??1:Au,br=jr||Wr?$n:t.length,pr=!!E&&!!h&&!!$,bt=!!u,Ys=o.useMemo(()=>new Set(Ca?Array.from(b??[]):Ts),[Ca,b,Ts]),Gu=(bt?40:0)+(pr?40:0),Oa=!Lu&&(zs||ne),On=(()=>{if(!Oa)return{};let f=Gu;const x={};return rr.forEach((z,N)=>{(ea(z)||!zs&&ne&&N===0)&&(x[z.key]=f,f+=zr[z.key]??Ze(z,mr(z.width)))}),x})(),Ba=Object.keys(On),Pa=Ba.length>0?Ba[Ba.length-1]:null,Xu=pr&&t.length>0&&E.size===t.length,Yu=pr&&E.size>0&&E.size<t.length,Bn=o.useMemo(()=>{const f=Object.entries(er),x=Object.entries(ur);return f.length===0&&x.length===0?t:t.filter(z=>f.every(([N,J])=>{const ue=r.find(me=>me.key===N);return ue?J.includes(en(ue,z)):!0})&&x.every(([N,J])=>{const ue=r.find(ke=>ke.key===N);if(!ue)return!0;const me=t.map(ke=>en(ue,ke));return bi(en(ue,z),J,me)}))},[ur,er,r,t]),qr=o.useMemo(()=>{if(!Oe)return Bn;const f=r.find(x=>x.key===Oe.key&&x.sortKey);return f!=null&&f.sortKey?[...Bn].sort((x,z)=>{const N=x[f.sortKey],J=z[f.sortKey],ue=N===J?0:N==null?1:J==null||N<J?-1:1;return Oe.dir==="asc"?ue:-ue}):Bn},[Bn,Oe,r]),Zs=o.useMemo(()=>{if(jr||!Wr)return qr;const f=(qe-1)*br;return qr.slice(f,f+br)},[qr,jr,Wr,qe,br]),Ur=jr?G??t.length:qr.length,Fa=Wr?Math.max(1,Math.ceil(Ur/br)):1,Zu=Math.min(...Xs),Qu=Wr&&(Ur>br||Ur>Zu),Ju=Wr?(qe-1)*br+1:1,Ru=Wr?Math.min(qe*br,Ur):Ur;function za(f){if(a)return;const x=Math.max(1,Math.min(f,Fa));jr?Q(x):Ln(x)}function ef(f){a||(P&&(Fr.current=P),An(f),jr?(_(f),Q(1)):(Ln(1),_==null||_(f)))}function Qs(f){const x=new Set(Ys);x.has(f)?x.delete(f):x.add(f);const z=Array.from(x);Ca||gu(z),v==null||v(z)}o.useEffect(()=>{we==null||we({bql:vr,filters:er,conditionFilters:ur,sort:Oe,page:qe,pageSize:br,hiddenColumnKeys:je})},[vr,er,ur,Oe,qe,br,je,we]);const Js=f=>f==="center"?"text-center":f==="right"?"text-right":"text-left",rf="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",_a="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%)",Te="color-mix(in srgb, var(--border) 62%, var(--bg-card))",Vr="color-mix(in srgb, var(--primary) 24%, var(--border))",Pn=`inset 0 0 0 1px ${Te}`,Rs=rr.reduce((f,x)=>f+(zr[x.key]??mr(x.width)),(bt?40:0)+(pr?40:0)),el=typeof I=="number"?I:typeof I=="string"?Number(((ol=I.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:ol[1])??NaN):NaN,qt=Number.isFinite(el)?Math.max(Rs,el,Bs):Math.max(Rs,Bs),Fn=I??qt,pt=`${bt?"40px ":""}${pr?"40px ":""}${rr.map(f=>`${zr[f.key]??mr(f.width)}px`).join(" ")}`;o.useEffect(()=>{Oe&&je.includes(Oe.key)&&_r(null)},[je,Oe]);function rl(f){return f?typeof f=="string"?{key:f,label:f}:f:null}const zn=()=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:pt,background:_a,borderBottom:`1px solid ${Vr}`},children:[bt&&e.jsx("div",{role:"columnheader",className:`${D?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${Vr}`,borderRight:`1px solid ${Te}`}}),pr&&e.jsx("div",{role:"columnheader",className:`${D?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:Oa?{position:"sticky",left:0,zIndex:12,background:_a,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${Vr}`,borderRight:`1px solid ${Te}`}:{borderBottom:`1px solid ${Vr}`,borderRight:`1px solid ${Te}`},children:e.jsx(Xt,{size:"sm",checked:Xu,indeterminate:Yu,onChange:$,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),rr.map((f,x)=>{const z=(Oe==null?void 0:Oe.key)===f.key,N=!!f.sortKey,J=Dr(f),ue=On[f.key],me=ue!==void 0,ke=f.key===Pa,We=io(f),_e=Gs===x,Se=(zr[f.key]??mr(f.width))<120,Ne=Object.prototype.hasOwnProperty.call(er,f.key)||Object.prototype.hasOwnProperty.call(ur,f.key);return e.jsxs("div",{role:"columnheader","data-dt-column-key":f.key,className:`group select-none ${Se?"text-left":Js(f.align)}`,style:{...me?{position:"sticky",left:ue,zIndex:12,background:_a,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:ke?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Vr}`:`inset 0 -1px 0 ${Vr}`,borderRight:`1px solid ${Te}`}:{position:"relative",borderBottom:`1px solid ${Vr}`,borderRight:`1px solid ${Te}`},color:z?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:_e?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:J?D?"7px 6px":"9px 8px":D?"8px 6px 10px":"10px 8px 12px"},onDragOver:Ce=>{(We||Wt.current!==null)&&qu(f.key,Ce)},onDrop:Ce=>Uu(f.key,Ce),children:[e.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${J?"justify-center":Se?"justify-start":f.align==="center"?"justify-center":f.align==="right"?"justify-end":"justify-start"}`,children:[We?e.jsx("span",{draggable:!0,onDragStart:Ce=>{Ce.stopPropagation(),Wu(f.key,Ce)},onDragEnd:Ce=>{Ce.stopPropagation(),Vu()},onClick:Ce=>Ce.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 ${_e?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}):null,J?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(B.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):e.jsx(co,{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 ${D?"text-[11px]":"text-xs"}`,children:e.jsx("span",{className:"min-w-0 truncate",children:f.header})})}),N&&e.jsx("button",{type:"button","aria-label":`Ordenar por ${String(f.header)}`,title:"Ordenar",onClick:Ce=>{Ce.stopPropagation(),Ku(f)},"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 ${z?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:z?Oe.dir==="asc"?e.jsx(B.HiChevronUp,{className:"h-3 w-3"}):e.jsx(B.HiChevronDown,{className:"h-3 w-3"}):e.jsx(B.HiChevronUpDown,{className:"h-3 w-3"})}),oe&&!J&&Ou(f)&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ye&&Ot===f.key,"aria-label":`Filtrar ${String(f.header)}`,title:"Filtrar",onClick:Ce=>Ks(Ce,"filter",f.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 ${Ye&&dr==="filter"&&Ot===f.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":Ne?"text-[var(--primary)] opacity-100":""}`,children:Ne?e.jsx(B.HiFunnel,{className:"h-3.5 w-3.5"}):e.jsx(B.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!J&&e.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:Ce=>{Ce.preventDefault(),Ce.stopPropagation(),jt.current={colKey:f.key,startX:Ce.clientX,startWidth:zr[f.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:Ce=>{Ce.preventDefault(),Ce.stopPropagation(),jt.current=null,document.body.style.cursor="",document.body.style.userSelect="",ju(f)},onClick:Ce=>Ce.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"}})]})})]},f.key)})]}),_n=()=>{if(!Ye||typeof document>"u"||dr==="visibility"&&!H||dr==="filter"&&!oe)return null;const f=r.find(Ne=>Ne.key===Ot),x=Hu(),z=f?Object.prototype.hasOwnProperty.call(er,f.key):!1,N=f?ur[f.key]:void 0,J=Jt.find(Ne=>Ne.value===(N==null?void 0:N.operator)),ue=f?er[f.key]??[]:[],me=Es.trim().toLowerCase(),ke=me?x.filter(Ne=>Ne.label.toLowerCase().includes(me)):x,We=f&&x.length>0&&(!z||ue.length===x.length),_e=f&&z&&ue.length>0&&ue.length<x.length,Ve=je.length,Se=()=>{f&&(Aa(f.key),Ws(f.key))};return tr.createPortal(e.jsx("div",{ref:Is,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Nu,borderColor:"var(--border)",background:"var(--bg-card)"},children:dr==="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:Ve>0?`${rr.length} de ${r.length} visibles`:`${r.length} visibles`}),e.jsx("button",{type:"button",onClick:_u,disabled:Ve===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:Fs.map(Ne=>{const Ce=!je.includes(Ne.key),he=!(Ne.hideable!==!1)||Ce&&rr.length<=1;return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ce,disabled:he,onClick:()=>zu(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:Ce?"var(--primary)":"var(--border)",background:Ce?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ce&&e.jsx(B.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:Ne.header})]},Ne.key)})})]}):f?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 ",f.header]}),e.jsx("button",{type:"button",onClick:Se,disabled:!z&&!N,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"})]}),f.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:()=>_r({key:f.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(B.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate",children:"Ascendente"})]}),(Oe==null?void 0:Oe.key)===f.key&&Oe.dir==="asc"&&e.jsx(B.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),e.jsxs("button",{type:"button",onClick:()=>_r({key:f.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(B.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate",children:"Descendente"})]}),(Oe==null?void 0:Oe.key)===f.key&&Oe.dir==="desc"&&e.jsx(B.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(Ar,{value:(N==null?void 0:N.operator)??"",onChange:Ne=>{if(!Ne){Ws(f.key);return}Dn(f.key,{operator:Ne,value:(N==null?void 0:N.value)??"",valueTo:(N==null?void 0:N.valueTo)??""})},options:ri,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"}),(J==null?void 0:J.valueMode)!=="none"?e.jsx("input",{value:(N==null?void 0:N.value)??"",onChange:Ne=>{N&&Dn(f.key,{...N,value:Ne.target.value})},disabled:!N,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"})]}),(J==null?void 0:J.valueMode)==="between"&&e.jsx("input",{value:(N==null?void 0:N.valueTo)??"",onChange:Ne=>{N&&Dn(f.key,{...N,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(B.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),e.jsx("input",{value:Es,onChange:Ne=>Ms(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":_e?"mixed":!!We,onClick:()=>{f&&(We&&!z?js(f.key,[]):Aa(f.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:We||_e?"var(--primary)":"var(--border)",background:We||_e?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[_e&&e.jsx(B.HiMinus,{className:"h-3 w-3"}),We&&!_e&&e.jsx(B.HiCheck,{className:"h-3 w-3"})]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),ke.map(Ne=>{const Ce=!z||ue.includes(Ne.value);return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ce,onClick:()=>Bu(f.key,Ne.value,x.map(ve=>ve.value),z),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:Ce?"var(--primary)":"var(--border)",background:Ce?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ce&&e.jsx(B.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:Ne.label})]},Ne.value)}),ke.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 f(x){Ta.current&&!Ta.current.contains(x.target)&&Mn.current&&!Mn.current.contains(x.target)&&En(!1)}return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[_t]);function tl(f,x){if(f.filterValue){const z=f.filterValue(x);return z==null||z===""?"":String(z)}return Xr(f.cell(x))}function nl(f){return`"${f.replace(/"/g,'""')}"`}function jn(f){return f.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function tf(){const f=rr.filter(ke=>!Dr(ke)),x=f.map(ke=>nl(Xr(ke.header))).join(","),z=qr.map(ke=>f.map(We=>nl(tl(We,ke))).join(",")).join(`
5
+ `),N=`${x}
6
+ ${z}`,J=new Blob(["\uFEFF"+N],{type:"text/csv;charset=utf-8;"}),ue=URL.createObjectURL(J),me=document.createElement("a");me.href=ue,me.download=`${Ue}.csv`,document.body.appendChild(me),me.click(),document.body.removeChild(me),URL.revokeObjectURL(ue)}function nf(){const f=rr.filter(me=>!Dr(me)),x=f.map(me=>jn(Xr(me.header))),N=qr.map(me=>f.map(ke=>jn(tl(ke,me)))).map(me=>`<tr>${me.map(ke=>`<td>${ke}</td>`).join("")}</tr>`).join(""),J=`<!DOCTYPE html>
7
+ <html lang="es"><head><meta charset="utf-8"><title>${jn(Ue)}</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,22 +15,22 @@ ${D}`,K=new Blob(["\uFEFF"+x],{type:"text/csv;charset=utf-8;"}),de=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>${In(qe)}</h3>
19
- <p>${_r.length} registros · ${new Date().toLocaleDateString("es")}</p>
20
- <table><thead><tr>${g.map(pe=>`<th>${pe}</th>`).join("")}</tr></thead>
21
- <tbody>${x}</tbody></table>
18
+ <h3>${jn(Ue)}</h3>
19
+ <p>${qr.length} registros · ${new Date().toLocaleDateString("es")}</p>
20
+ <table><thead><tr>${x.map(me=>`<th>${me}</th>`).join("")}</tr></thead>
21
+ <tbody>${N}</tbody></table>
22
22
  <script>window.onload=()=>{window.print()}<\/script>
23
- </body></html>`,de=window.open("","_blank");de&&(de.document.write(K),de.document.close())}const Bn=()=>!pr||!Bt?null:er.createPortal(e.jsxs("div",{ref:ha,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...eu,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:()=>{Du(),vn(!1)},children:[e.jsx(T.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(),vn(!1)},children:[e.jsx(T.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),On=()=>{const d=Q&&mr.trim().length>0,g=Le!=null&&Le.length?Le:d?[{key:"bql",label:"BQL",value:mr}]:[],D=Ee.filter(x=>{const K=x.trim();return K?!new Set(Dt.split(`
24
- `).map(pe=>pe.trim()).filter(Boolean)).has(K):!1}).slice(0,8);return!H&&va===0&&!Q&&!pr?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:[va>0&&e.jsxs("button",{type:"button",onClick:bu,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(T.HiXMark,{className:"h-3.5 w-3.5"}),va," filtros"]}),Q&&e.jsxs("div",{ref:pa,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>{if(hr){Br(!1);return}En(),Br(!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:hr?"var(--primary)":d?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:hr||d?"var(--primary)":"var(--border)",color:hr?"var(--primary-fg)":"var(--primary)"},"aria-expanded":hr,title:"Abrir filtros BQL",children:[e.jsx(T.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",d&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),hr?e.jsx(T.HiChevronUp,{className:"h-3.5 w-3.5"}):e.jsx(T.HiChevronDown,{className:"h-3.5 w-3.5"})]}),e.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:B}),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:Ls,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(T.HiXMark,{className:"h-4 w-4"})}),hr&&er.createPortal(e.jsxs("div",{ref:ms,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...Zd,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:[z.map(x=>e.jsxs("button",{type:"button",onMouseDown:K=>{K.preventDefault(),K.stopPropagation()},onClick:K=>{K.preventDefault(),K.stopPropagation(),Cn(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)),le.length>0&&e.jsxs("button",{type:"button",onClick:()=>tt(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":bs,children:[e.jsx(T.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),It.length>0&&e.jsxs("button",{type:"button",onClick:()=>nt(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":ps,children:[e.jsx(T.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:ma,value:Dt,rows:3,onChange:x=>ya(x.target.value,x.target),onKeyDown:x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),Ms(Dt)),x.key==="Escape"&&Br(!1)},placeholder:te,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"}}),D.length>0&&e.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:D.map(x=>e.jsx("button",{type:"button",onMouseDown:K=>{K.preventDefault(),K.stopPropagation()},onClick:K=>{K.preventDefault(),K.stopPropagation(),Cn(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))]}),ps&&It.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(T.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),e.jsxs("button",{type:"button",onClick:()=>{at([]),nt(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[e.jsx(T.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),It.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:K=>{K.preventDefault(),K.stopPropagation()},onClick:K=>{K.preventDefault(),K.stopPropagation(),Cn(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:()=>at(K=>K.filter(de=>de!==x)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx(T.HiXMark,{className:"h-3.5 w-3.5"})})]},x))]}),bs&&le.length>0&&e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:le.map(x=>e.jsxs("button",{type:"button",onMouseDown:K=>{K.preventDefault(),K.stopPropagation()},onClick:K=>{K.preventDefault(),K.stopPropagation(),Cn(x.bql),tt(!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:Ls,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(T.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),e.jsxs("button",{type:"button",onClick:()=>Ms(Dt),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(T.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),pr&&e.jsx("button",{ref:xn,type:"button","aria-haspopup":"menu","aria-expanded":Bt,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var K;const x=(K=xn.current)==null?void 0:K.getBoundingClientRect();x&&ru({top:x.bottom+4,right:window.innerWidth-x.right}),vn(de=>!de)},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)] ${Bt?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:e.jsx(T.HiArrowDownTray,{className:"h-4 w-4"})}),H&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Xe&&ir==="visibility","aria-label":ie,title:ie,onClick:x=>$s(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)] ${Xe&&ir==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:e.jsx(T.HiCog6Tooth,{className:"h-4 w-4"})})]})},Ws=()=>{if(!Mu)return null;const d=Yl(We,Ea);return e.jsxs("div",{"aria-busy":a,className:`grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 rounded-b-xl border-t text-xs select-none ${$?"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:jr===0?"0 filas":`${Lu}–${Tu} de ${jr}`}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),e.jsx(Lr,{value:String(ur),onChange:g=>$u(Number(g)),options:Ds.map(g=>({value:String(g),label:String(g)})),placeholder:"Filas",searchable:!1,disabled:a,height:U,padding:V,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:F}})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[e.jsx("button",{disabled:a||We<=1,onClick:()=>Ma(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(T.HiChevronLeft,{className:"h-3.5 w-3.5"})}),d.map((g,D)=>g==="..."?e.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${D}`):e.jsx("button",{disabled:a,onClick:()=>Ma(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:a||We>=Ea,onClick:()=>Ma(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(T.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{"aria-hidden":"true"})]})},Bu=()=>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:Tn},children:[Dn(),Bn(),On(),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:Pt,minWidth:$n},children:[e.jsx("div",{role:"rowgroup",style:N?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:An()}),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:dt,borderBottom:`1px solid ${Me}`},children:[fr&&e.jsx("div",{role:"cell",className:`${$?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Me}`,borderRight:`1px solid ${Me}`}},"select-cell"),Re.map((D,x)=>e.jsx("div",{role:"cell",className:$?"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:`${xs(g,x)}%`,minWidth:32}})},D.key))]},g))})]})})]}),Ta="min-w-0 max-w-full overflow-hidden";return j&&Qe&&!ue?e.jsx(jt,{rows:s,columns:Math.max(4,Re.length||7)}):!a&&t.length===0&&!ga?Bu():a&&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:Tn},children:[Dn(),Bn(),On(),e.jsx("div",{ref:Nr,className:Ta,children:e.jsx(Aa.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:ws,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:Pt,minWidth:$n},children:[e.jsx("div",{role:"rowgroup",style:N?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:An()}),e.jsx("div",{role:"rowgroup",children:Array.from({length:s}).map((d,g)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:dt,borderBottom:`1px solid ${Me}`},children:[fr&&e.jsx("div",{role:"cell",className:`${$?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Me}`,borderRight:`1px solid ${Me}`}},"select-cell"),Re.map((D,x)=>{const K=Mn[D.key],de=K!==void 0,pe=D.key===Ca;return e.jsx("div",{role:"cell","data-dt-column-key":D.key,className:$?"px-2 py-1.5":"px-3 py-2",style:de?{position:"sticky",left:K,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:pe?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Me}`:`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:`${xs(g,x)}%`,minWidth:32}})},D.key)})]},g))})]})})}),Ws()]}):!a&&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:Tn},children:[Dn(),Bn(),On(),e.jsx("div",{ref:Nr,className:Ta,children:e.jsx("div",{role:"table",className:"text-sm",style:{width:Pt,minWidth:$n},children:e.jsx("div",{role:"rowgroup",style:N?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:An()})})}),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(T.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:Tn},children:[Dn(),Bn(),On(),e.jsx("div",{ref:Nr,className:Ta,children:e.jsx(Aa.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:ws,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:Pt,minWidth:$n},children:[e.jsx("div",{role:"rowgroup",style:N?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:An()}),e.jsx("div",{role:"rowgroup",children:Bs.map((d,g)=>{const D=n(d),x=zs(L==null?void 0:L(d)),K=g>0?zs(L==null?void 0:L(Bs[g-1])):null,de=x&&x.key!==(K==null?void 0:K.key),pe=fr&&S.has(D),we=ct?(p==null?void 0:p(d))??!0:!1,je=we&&Is.has(D),ze=!!u||y&&we,Ue=pe&&O?"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:[de&&e.jsx("div",{role:"row",className:`grid ${x.className??""}`,style:{gridTemplateColumns:dt},children:e.jsx("div",{role:"cell",className:$?"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:ze?ke=>{const ye=ke.target;if(!(ye!=null&&ye.closest('[data-dt-disable-row-click="true"]'))){if(y&&we){Os(D);return}u==null||u(d)}}:void 0,className:`grid transition-colors ${ze?"cursor-pointer":""} ${E?E(d):""}`,style:{gridTemplateColumns:dt,"--dt-row-bg":Ue,"--dt-sticky-bg":Ue,background:"var(--dt-row-bg)",borderBottom:`1px solid ${Me}`},onMouseEnter:ke=>{pe||(ke.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),ke.currentTarget.style.setProperty("--dt-sticky-bg",Au))},onMouseLeave:ke=>{ke.currentTarget.style.setProperty("--dt-row-bg",Ue),ke.currentTarget.style.setProperty("--dt-sticky-bg",Ue)},children:[ct&&e.jsx("div",{role:"cell",className:`${$?"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:we&&e.jsx("button",{type:"button","aria-label":je?"Contraer fila":"Desplegar fila","aria-expanded":je,onClick:ke=>{ke.stopPropagation(),Os(D)},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:je?e.jsx(T.HiChevronDown,{className:"h-4 w-4"}):e.jsx(T.HiChevronRight,{className:"h-4 w-4"})})}),fr&&e.jsx("div",{role:"cell",className:`${$?"px-2 py-1.5":"px-3 py-2"} w-10`,style:Na?{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:ke=>{ke.stopPropagation(),h(D)},children:e.jsx(Wt,{size:"sm",checked:pe,"aria-label":"Seleccionar fila",containerClassName:"items-center",className:"cursor-pointer",onClick:ke=>ke.stopPropagation(),onChange:()=>h(D)})}),Re.map(ke=>{const ye=Mn[ke.key],Ne=ye!==void 0,he=ke.key===Ca,me=Tr(ke);return e.jsx("div",{role:"cell","data-dt-column-key":ke.key,"data-dt-disable-row-click":ke.disableRowClick||me?"true":void 0,className:`${me?"px-2 py-1.5 text-center":`${$?"px-2 py-1.5":"px-3 py-2"} ${Hs(ke.align)}`} ${ql} ${ke.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...Ne?{position:"sticky",left:ye,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:he?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Me}`:`inset 0 -1px 0 ${Me}`,borderRight:`1px solid ${Me}`}:{borderBottom:`1px solid ${Me}`,borderRight:`1px solid ${Me}`}},children:e.jsx(Qa,{children:e.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:ke.cell(d)})})},ke.key)})]}),je&&f&&e.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:dt},children:e.jsx("div",{role:"cell",className:$?"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)})})]},D)})})]})})}),Ws()]})}const Jl={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 Rl(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 n=Jl[t.preset];if(!n.pattern.test(r))return t.message??n.message}return t.pattern&&!t.pattern.test(r)?t.message??"Formato inválido":null}const ei=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function ri({initialValue:r,type:t,mask:n,onCommit:a,onCancel:s}){const[l,i]=o.useState(r),c=o.useRef(null),u=(n==null?void 0:n.preset)==="date",f=u?"date":t==="number"?"number":"text";return o.useEffect(()=>{var p,b;(p=c.current)==null||p.focus(),u||(b=c.current)==null||b.select()},[u]),e.jsx("input",{ref:c,type:f,value:l,maxLength:n==null?void 0:n.maxLength,onChange:p=>i(p.target.value),onBlur:()=>s(),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),a(l)),p.key==="Escape"&&(p.preventDefault(),s()),(n==null?void 0:n.preset)==="integer"&&!p.ctrlKey&&!p.metaKey&&!ei.has(p.key)&&!/^[\d-]$/.test(p.key)&&p.preventDefault()},onClick:p=>p.stopPropagation(),className:"w-full min-w-0 border-0 bg-transparent p-0 text-sm text-[var(--text-main)] outline-none"})}function ti({initialValue:r,options:t,loading:n,onCommit:a,onCancel:s}){const l=o.useRef(null);return o.useEffect(()=>{if(n)return;const i=setTimeout(()=>{var c,u;(u=(c=l.current)==null?void 0:c.querySelector("button"))==null||u.click()},0);return()=>clearTimeout(i)},[n]),e.jsx("div",{ref:l,className:"w-full",tabIndex:-1,onKeyDown:i=>{i.key==="Escape"&&(i.stopPropagation(),s())},children:e.jsx(Lr,{value:r,onChange:i=>{a(i)},options:t,disabled:n,placeholder:n?"Cargando…":"Seleccionar…",triggerVariant:"ghost",height:30,padding:"0 6px",minOptionsForSearch:1,className:"w-full"})})}const ni={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},Kn={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function ai({columns:r,data:t,getRowId:n,onCellUpdate:a,readOnly:s=!1,...l}){const[i,c]=o.useState(t),u=o.useRef(null);o.useEffect(()=>{u.current||c(t)},[t]);const[f,p]=o.useState(null);u.current=f;const[b,m]=o.useState(null),v=o.useRef(null);v.current=b;const[y,S]=o.useState({}),[h,P]=o.useState(null),O=o.useRef(null);O.current=h;const[E,L]=o.useState({}),[N,k]=o.useState({}),Y=o.useRef(new Set),F=o.useRef(null);o.useEffect(()=>{var H;const M=document.activeElement;(!M||M===document.body)&&((H=F.current)==null||H.focus({preventScroll:!0}))},[]);const U=r.map(M=>{var H,oe,A;return`${M.key}:${((A=(oe=(H=M.editable)==null?void 0:H.select)==null?void 0:oe.options)==null?void 0:A.length)??-1}`}).join("|");o.useEffect(()=>{r.forEach(M=>{var A,q;const H=(q=(A=M.editable)==null?void 0:A.select)==null?void 0:q.options;if(!H)return;const oe=E[M.key];(!Y.current.has(M.key)||(oe==null?void 0:oe.length)===0&&H.length>0)&&(Y.current.add(M.key),L(ne=>({...ne,[M.key]:H})))})},[U]);const V=o.useCallback(async(M,H)=>{if(Y.current.has(M))return;Y.current.add(M);const{url:oe,fetchOptions:A}=H.select??{};if(!(!oe&&!A)){k(q=>({...q,[M]:!0}));try{let q=[];if(A)q=await A();else if(oe){const ne=await fetch(oe);if(!ne.ok)throw new Error("fetch failed");q=await ne.json()}L(ne=>({...ne,[M]:q}))}catch{L(q=>({...q,[M]:[]}))}finally{k(q=>({...q,[M]:!1}))}}},[]),J=o.useRef(i);J.current=i;const C=o.useRef(a);C.current=a;const re=o.useRef(n);re.current=n;const W=o.useRef(r);W.current=r;const j=o.useRef(s);j.current=s,o.useEffect(()=>{if(r.length>0&&t.length>0){const M=r.find(H=>H.selectable!==!1);M&&m({rowId:n(t[0]),colKey:M.key})}},[]),o.useEffect(()=>{if(!b)return;const M=F.current;if(!M)return;const H=M.querySelector(`[data-cell-id="${b.rowId}:${b.colKey}"]`);if(!H)return;const oe=M.querySelector('[role="rowgroup"]');H.style.scrollMarginTop=`${(oe==null?void 0:oe.offsetHeight)??0}px`;const A=M.querySelector('[role="row"]');let q=0;A&&A.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(ne=>{ne.style.position==="sticky"&&ne.style.left!==""&&(q=Math.max(q,parseFloat(ne.style.left)+ne.offsetWidth))}),H.style.scrollMarginLeft=`${q}px`,H.scrollIntoView({block:"nearest",inline:"nearest"})},[b]);const ae=o.useCallback(M=>{var q;const H=W.current,oe=new Set,A=[];(q=F.current)==null||q.querySelectorAll("[data-cell-id]").forEach(ne=>{const ie=ne.dataset.cellId.split(":")[0];oe.has(ie)||(oe.add(ie),A.push(ie))}),m(ne=>{if(!ne)return ne;const ie=H.findIndex(R=>R.key===ne.colKey),Q=A.indexOf(ne.rowId);let G=ie,w=Q;if(M==="up")w=Math.max(0,Q-1);else if(M==="down")w=Math.min(A.length-1,Q+1);else if(M==="left"){let R=ie-1;for(;R>=0&&H[R].selectable===!1;)R--;R>=0&&(G=R)}else if(M==="right"){let R=ie+1;for(;R<H.length&&H[R].selectable===!1;)R++;R<H.length&&(G=R)}return G===ie&&w===Q?ne:{rowId:A[w],colKey:H[G].key}})},[]),Z=o.useCallback((M=!0)=>{const H=u.current;p(null),H&&m(H),M&&setTimeout(()=>{var oe;return(oe=F.current)==null?void 0:oe.focus({preventScroll:!0})},0)},[]),$=o.useCallback(async(M,H,oe)=>{var Le;const A=W.current.find(xe=>xe.key===H);if(!(A!=null&&A.editable))return;const{field:q,type:ne,mask:ie,validate:Q}=A.editable,G=ne==="number"?oe===""?null:Number(oe):oe;if(ie){const xe=Rl(oe,ie);if(xe){S(Se=>({...Se,[`${M}:${H}`]:xe}));return}}if(Q){const xe=Q(G);if(xe){S(Se=>({...Se,[`${M}:${H}`]:xe}));return}}const w=re.current,R=J.current.find(xe=>w(xe)===M);if(!R)return;const B=R[q];p(null),S(xe=>{const Se={...xe};return delete Se[`${M}:${H}`],Se});const te=J.current,z=te.findIndex(xe=>w(xe)===M),le=te[Math.min(te.length-1,z+1)];if(m({rowId:w(le),colKey:H}),setTimeout(()=>{var Se,Te;const xe=document.activeElement;(!xe||xe===document.body||(Se=F.current)!=null&&Se.contains(xe))&&((Te=F.current)==null||Te.focus({preventScroll:!0}))},0),String(B??"")===String(G??""))return;const Ee={...R,[q]:G};c(xe=>xe.map(Se=>w(Se)===M?Ee:Se)),P({rowId:M,colKey:H});try{await((Le=C.current)==null?void 0:Le.call(C,{row:R,rowId:M,field:q,oldValue:B,newValue:G}))}catch{c(xe=>xe.map(Se=>w(Se)===M?R:Se)),S(xe=>({...xe,[`${M}:${H}`]:"Error al guardar. Intenta de nuevo."}))}finally{P(null)}},[]),ee=o.useCallback(M=>{if(O.current){M.preventDefault();return}if(u.current)return;const H=v.current;if(!(!H||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(M.key)))switch(M.preventDefault(),M.key){case"ArrowUp":ae("up");break;case"ArrowDown":ae("down");break;case"ArrowLeft":ae("left");break;case"ArrowRight":ae("right");break;case"Tab":ae(M.shiftKey?"left":"right");break;case"Enter":{const A=W.current.find(q=>q.key===H.colKey);A!=null&&A.editable&&!j.current?(p(H),A.editable.type==="select"&&!Y.current.has(H.colKey)&&V(H.colKey,A.editable)):ae("down");break}}},[ae,V]),se=o.useMemo(()=>r.map(M=>{if(!M.editable||s){const oe={...M};if(delete oe.editable,delete oe.selectable,M.selectable===!1)return{...oe,disableRowClick:!0};const A=oe.cell;return{...oe,className:`relative ${oe.className??""}`.trim(),disableRowClick:!0,cell:q=>{const ne=n(q),ie=(b==null?void 0:b.rowId)===ne&&(b==null?void 0:b.colKey)===M.key;return e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-cell-id":`${ne}:${M.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var Q;O.current||(m({rowId:ne,colKey:M.key}),(Q=F.current)==null||Q.focus({preventScroll:!0}))}}),ie&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Kn}),e.jsx("span",{className:"relative z-0 pointer-events-none",children:A(q)})]})}}}const H=M.editable;return{...M,className:`relative ${M.className??""}`.trim(),disableRowClick:!0,cell:oe=>{const A=n(oe),q=M.key,ne=(f==null?void 0:f.rowId)===A&&(f==null?void 0:f.colKey)===q,ie=(b==null?void 0:b.rowId)===A&&(b==null?void 0:b.colKey)===q,Q=y[`${A}:${q}`],G=(h==null?void 0:h.rowId)===A&&(h==null?void 0:h.colKey)===q,w=oe[H.field],R=String(w??""),B=()=>{var z;O.current||(m({rowId:A,colKey:q}),p({rowId:A,colKey:q}),(z=F.current)==null||z.focus({preventScroll:!0}),H.type==="select"&&!Y.current.has(q)&&V(q,H))};if(ne){const z=H.type==="select"?e.jsx(ti,{initialValue:R,options:E[q]??[],loading:N[q]??!1,onCommit:le=>$(A,q,le),onCancel:Z}):e.jsx(ri,{initialValue:R,type:H.type??"text",mask:H.mask,onCommit:le=>$(A,q,le),onCancel:Z});return e.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:ni,onClick:le=>le.stopPropagation(),children:z})}const te=M.cell(oe);return e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-cell-id":`${A}:${q}`,className:`peer absolute inset-0 z-10 ${G?"cursor-wait":"cursor-pointer"}`,onClick:B}),ie&&!G&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Kn}),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:Kn,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:Q?e.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[e.jsx(T.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate text-xs",children:Q})]}):e.jsx("span",{className:"truncate",children:te})}),!G&&e.jsx(T.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,h,y,E,N,n,$,Z,V]);return e.jsx("div",{ref:F,tabIndex:0,onKeyDown:ee,onBlur:M=>{var H;(H=F.current)!=null&&H.contains(M.relatedTarget)||setTimeout(()=>{var A,q;const oe=document.activeElement;oe&&((A=oe.closest)!=null&&A.call(oe,"[data-bonsaif-select-dropdown]"))||(q=F.current)!=null&&q.contains(oe)||Z(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:e.jsx(Ja,{...l,columns:se,data:i,getRowId:n})})}function wt(r){return r?new Date(`${r}T12:00:00`):void 0}function Ra(r){return r.toISOString().slice(0,10)}function oi({calendarMonth:r,displayIndex:t}){const{previousMonth:n,nextMonth:a,goToMonth:s,months:l,labels:i,formatters:c}=Da.useDayPicker(),u=!!n&&t===0,f=!!a&&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(n),onClick:()=>n&&s(n),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(T.HiChevronLeft,{size:16})}),e.jsx("button",{type:"button","aria-label":i.labelNext(a),onClick:()=>a&&s(a),disabled:!f,style:{height:28,width:28,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg-card)",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--text-main)",opacity:f?1:.45,cursor:f?"pointer":"not-allowed"},children:e.jsx(T.HiChevronRight,{size:16})})]})}function si(r){return r.charAt(0).toUpperCase()+r.slice(1)}function li({startDate:r,endDate:t,onChange:n,minDate:a,viewMonth:s,numberOfMonths:l=1,showSummary:i=!0,startLabel:c="Inicio",endLabel:u="Regreso"}){const f={from:wt(r),to:wt(t)},p=wt(a),[b,m]=o.useState(wt(s||r));return o.useEffect(()=>{m(wt(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(Da.DayPicker,{mode:"range",selected:f,month:b,onMonthChange:m,onSelect:v=>{const y=v!=null&&v.from?Ra(v.from):r,S=v!=null&&v.to?Ra(v.to):"";n({startDate:y,endDate:S})},numberOfMonths:l,hideNavigation:!0,disabled:p?{before:p}:void 0,showOutsideDays:!1,components:{MonthCaption:oi},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:v=>si(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(v)),formatWeekdayName:v=>new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(v)},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 ii="bonsaif-ui:hide-tooltips";function eo(){window.dispatchEvent(new CustomEvent(ii))}function ci(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function di({trigger:r,items:t,align:n="end",width:a=220,disabled:s=!1,className:l="",menuClassName:i="",onOpenChange:c}){const[u,f]=o.useState(!1),[p,b]=o.useState(!1),[m,v]=o.useState({}),y=o.useRef(null),S=o.useRef(null),h=o.useCallback(N=>{f(N),c==null||c(N)},[c]),P=o.useCallback(()=>{const N=y.current;if(!N)return;const k=N.getBoundingClientRect(),Y=typeof a=="number"?a:k.width,F=typeof a=="number"?a:Math.max(k.width,180),U=n==="end"?Math.max(8,k.right-F):Math.min(k.left,window.innerWidth-F-8),V=window.innerHeight-k.bottom,J=V<240&&k.top>V?void 0:k.bottom+6,C=J===void 0?window.innerHeight-k.top+6:void 0;v({position:"fixed",zIndex:9999,left:U,top:J,bottom:C,width:ci(typeof a=="number"?Y:a)})},[n,a]);o.useEffect(()=>b(!0),[]),o.useEffect(()=>{if(!u)return;P();const N=Y=>{var U,V;const F=Y.target;!((U=y.current)!=null&&U.contains(F))&&!((V=S.current)!=null&&V.contains(F))&&h(!1)},k=Y=>{Y.key==="Escape"&&h(!1)};return document.addEventListener("mousedown",N),window.addEventListener("keydown",k),window.addEventListener("resize",P),window.addEventListener("scroll",P,!0),()=>{document.removeEventListener("mousedown",N),window.removeEventListener("keydown",k),window.removeEventListener("resize",P),window.removeEventListener("scroll",P,!0)}},[u,h,P]);const O=N=>{s||(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),h(!u))},E=o.isValidElement(r)?o.cloneElement(r,{onClick:()=>{s||(eo(),h(!u))}}):r,L=u?e.jsx("div",{ref:S,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(N=>e.jsxs("div",{children:[N.separatorBefore&&e.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),e.jsxs("button",{type:"button",role:"menuitem",disabled:N.disabled,onClick:()=>{var k;N.disabled||(eo(),(k=N.onSelect)==null||k.call(N),h(!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:N.danger?"var(--danger)":"var(--text-main)"},children:[N.icon&&e.jsx("span",{className:"mt-0.5 shrink-0",children:N.icon}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm font-medium",children:N.label}),N.description&&e.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:N.description})]})]})]},N.id))}):null;return e.jsxs("span",{ref:y,role:"button",tabIndex:s?-1:0,"aria-haspopup":"menu","aria-expanded":u,onKeyDown:O,className:`inline-flex ${s?"pointer-events-none opacity-60":""} ${l}`,children:[E,p&&L?er.createPortal(L,document.body):null]})}const ui=180,ro="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function fi({open:r,onClose:t,title:n,subtitle:a,leadingIcon:s,confirmLabel:l="Guardar",onConfirm:i,loading:c=!1,confirmDisabled:u=!1,headerActions:f,bodyClassName:p="flex-1 overflow-y-auto px-6 py-5",width:b=440,hasUnsavedChanges:m=!1,unsavedChangesTitle:v="Descartar cambios",unsavedChangesDescription:y="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:S="Descartar",unsavedChangesCancelLabel:h="Seguir editando",onDiscardChanges:P,disabled:O=!1,disabledMessage:E,children:L}){const[N,k]=o.useState(!1),[Y,F]=o.useState(!1),[U,V]=o.useState(!1),J=o.useCallback(()=>{F(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>V(!0))})},[]),C=o.useCallback(()=>{V(!1),window.setTimeout(()=>F(!1),ui)},[]),re=o.useCallback(()=>{if(!O){if(m){J();return}t()}},[O,m,t,J]),W=o.useCallback(()=>{V(!1),F(!1),P==null||P(),t()},[t,P]);if(o.useEffect(()=>{k(!0)},[]),o.useEffect(()=>(document.body.style.overflow=r?"hidden":"",r||(V(!1),F(!1)),()=>{document.body.style.overflow=""}),[r]),o.useEffect(()=>{if(!r)return;const ae=Z=>{if(Z.key==="Escape"&&!O){if(Y){C();return}re()}};return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[C,O,Y,r,re]),!N)return null;const j=E!==void 0?E:c?"Guardando…":null;return er.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 ${ro}`,onClick:re}),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(Fe,{variant:"icon",onClick:re,title:"Cerrar",disabled:O,children:e.jsx(T.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:n}),a&&e.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:a})]})]}),(f||i)&&e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[f,i&&e.jsxs(e.Fragment,{children:[e.jsx(Fe,{variant:"secondary",size:"sm",onClick:re,disabled:O,style:{background:"var(--bg-input)"},children:"Cancelar"}),e.jsx(Fe,{variant:"primary",size:"sm",icon:e.jsx(Vs.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:u||O,title:l})]})]})]}),e.jsx("div",{"data-drawer-scroll":"true",className:p,children:L}),O&&e.jsx("div",{className:"absolute inset-0 z-[1002] flex cursor-not-allowed items-center justify-center p-6",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 72%, transparent)",backdropFilter:"blur(3px)"},role:"status","aria-live":"polite","aria-busy":"true",children:j?e.jsxs("div",{className:"flex max-w-xs 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)]","aria-hidden":!0}),e.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:j})]}):null})]}),Y&&e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":v,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[e.jsx("div",{className:`absolute inset-0 ${ro} transition-opacity duration-200 ease-out ${U?"opacity-100":"opacity-0"}`,onClick:C}),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 ${U?"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(Fe,{variant:"icon",onClick:C,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":h,children:e.jsx(T.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(T.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:v}),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(Fe,{variant:"secondary",onClick:C,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:h}),e.jsx(Fe,{variant:"secondary",onClick:W,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:S})]})]})]})]}),document.body)}const bi=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,pi=/^\+?[0-9\s().-]+$/,mi=7,hi=15;function or(r){return r==null||String(r).trim()===""}function to(r){return typeof r=="number"?r:typeof r=="string"&&r.trim()!==""?Number(r):Number.NaN}function Xn(r){return or(r)?!1:bi.test(String(r))}function Yn(r){if(or(r))return!1;const t=String(r),n=t.replace(/\D/g,"");return pi.test(t)&&n.length>=mi&&n.length<=hi}function gi(r="Este campo es requerido."){return t=>or(t)?r:void 0}function vi(r="Ingresa un correo valido."){return t=>or(t)||Xn(t)?void 0:r}function xi(r="Ingresa un telefono valido."){return t=>or(t)||Yn(t)?void 0:r}function yi(r,t){return n=>or(n)||String(n).length>=r?void 0:t??`Debe tener al menos ${r} caracteres.`}function wi(r,t){return n=>or(n)||String(n).length<=r?void 0:t??`Debe tener ${r} caracteres o menos.`}function ki(r,t){return n=>{if(or(n))return;const a=to(n);return Number.isFinite(a)&&a>=r?void 0:t??`Debe ser mayor o igual a ${r}.`}}function Ni(r,t){return n=>{if(or(n))return;const a=to(n);return Number.isFinite(a)&&a<=r?void 0:t??`Debe ser menor o igual a ${r}.`}}function Si(r,t="El formato no es valido."){return n=>or(n)||r.test(String(n))?void 0:t}function Ci(r,t){const n={};for(const a of Object.keys(t)){const s=t[a];if(!s)continue;const l=Array.isArray(s)?s:[s];for(const i of l){const c=i(r[a],r);if(c){n[a]=c;break}}}return{valid:Object.keys(n).length===0,errors:n}}var no={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},ao=o.createContext&&o.createContext(no),Ei=["attr","size","title"];function Mi(r,t){if(r==null)return{};var n,a,s=Li(r,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(r);for(a=0;a<l.length;a++)n=l[a],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(r,n)&&(s[n]=r[n])}return s}function Li(r,t){if(r==null)return{};var n={};for(var a in r)if({}.hasOwnProperty.call(r,a)){if(t.indexOf(a)!==-1)continue;n[a]=r[a]}return n}function Yt(){return Yt=Object.assign?Object.assign.bind():function(r){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)({}).hasOwnProperty.call(n,a)&&(r[a]=n[a])}return r},Yt.apply(null,arguments)}function oo(r,t){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);t&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),n.push.apply(n,a)}return n}function Zt(r){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?oo(Object(n),!0).forEach(function(a){Ti(r,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):oo(Object(n)).forEach(function(a){Object.defineProperty(r,a,Object.getOwnPropertyDescriptor(n,a))})}return r}function Ti(r,t,n){return(t=$i(t))in r?Object.defineProperty(r,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[t]=n,r}function $i(r){var t=Ai(r,"string");return typeof t=="symbol"?t:t+""}function Ai(r,t){if(typeof r!="object"||!r)return r;var n=r[Symbol.toPrimitive];if(n!==void 0){var a=n.call(r,t);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function so(r){return r&&r.map((t,n)=>o.createElement(t.tag,Zt({key:n},t.attr),so(t.child)))}function Zn(r){return t=>o.createElement(Di,Yt({attr:Zt({},r.attr)},t),so(r.child))}function Di(r){var t=n=>{var{attr:a,size:s,title:l}=r,i=Mi(r,Ei),c=s||n.size||"1em",u;return n.className&&(u=n.className),r.className&&(u=(u?u+" ":"")+r.className),o.createElement("svg",Yt({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,i,{className:u,style:Zt(Zt({color:r.color||n.color},n.style),r.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),l&&o.createElement("title",null,l),r.children)};return ao!==void 0?o.createElement(ao.Consumer,null,n=>t(n)):t(no)}function lo(r){return Zn({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 Ii(r){return Zn({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 Bi(r){return Zn({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 Kr({content:r,ariaLabel:t="Más información",className:n=""}){return e.jsx(Mr,{as:"span",content:r,className:`inline-flex shrink-0 align-middle text-[var(--text-muted)] outline-none transition-colors hover:text-[var(--primary)] focus-visible:text-[var(--primary)] ${n}`,children:e.jsx("span",{tabIndex:0,role:"img","aria-label":t,className:"inline-flex items-center justify-center outline-none",children:e.jsx(T.HiInformationCircle,{className:"h-3.5 w-3.5"})})})}function Xr({error:r,helperText:t,helperDisplay:n="inline"}){return r?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:r}):t&&n!=="tooltip"?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:t}):null}function Qt({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 Qn({label:r,containerClassName:t="",helperText:n,helperDisplay:a="inline",error:s,errorDisplay:l="inline",errorTooltipLabel:i="Error de validacion",labelAction:c,floatingLabel:u=!1,showPasswordToggle:f=!0,nativeValidation:p=!1,className:b="",required:m,...v}){const[y,S]=o.useState(()=>!!v.autoFocus),[h,P]=o.useState(!1),O=v.type==="password"&&f,E=O&&h?"text":v.type,L=!!s,N=L&&l!=="tooltip",k=L&&l!=="inline",Y=!!n&&a==="tooltip"&&!N,F=p?m:void 0,U=L?"border-[var(--danger)] focus:border-[var(--danger)]":"",V=k?O?"pr-20":"pr-10":O?"pr-10":"",J=v.value!==void 0?String(v.value).length>0:v.defaultValue!==void 0&&String(v.defaultValue).length>0,C=y||J,re={top:C?7:12,color:y?"var(--primary)":"var(--text-muted)",fontSize:C?10:13,fontWeight:C?600:400,textTransform:C?"uppercase":"none"},W=ee=>{var se;S(!0),(se=v.onFocus)==null||se.call(v,ee)},j=ee=>{var se;S(!1),(se=v.onBlur)==null||se.call(v,ee)},ae=O?e.jsxs("button",{type:"button","aria-label":h?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":h,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors duration-200 hover:text-[var(--primary)] focus:outline-none",tabIndex:-1,onClick:()=>P(ee=>!ee),children:[e.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${h?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:e.jsx(Ii,{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 ${h?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:e.jsx(Bi,{className:"h-[18px] w-[18px]"})})]}):null,Z=k?e.jsx(Mr,{as:"span",content:s,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)] ${O?"right-10":"right-2.5"}`,children:e.jsx("span",{tabIndex:0,role:"img","aria-label":i,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(lo,{className:"h-[18px] w-[18px]"})})}):null,$=e.jsx(Xr,{error:N?s:void 0,helperText:n,helperDisplay:a});return u?e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"relative block",children:[e.jsx(Qt,{...v,type:E,required:F,placeholder:" ","aria-invalid":L||v["aria-invalid"],"data-has-value":J?"true":void 0,className:`h-11 w-full pt-5 ${V} ${U} ${b}`,onFocus:W,onBlur:j}),e.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:re,children:[r,m&&e.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),c&&e.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:C?7:12},children:c}),Z,ae]}),$]}):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}),m&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),Y?e.jsx(Kr,{content:n}):null,c&&e.jsx("span",{className:"ml-auto normal-case",children:c})]}),O?e.jsxs("span",{className:"relative block",children:[e.jsx(Qt,{...v,type:E,required:F,"aria-invalid":L||v["aria-invalid"],className:`w-full ${V} ${U} ${b}`,onFocus:W,onBlur:j}),Z,ae]}):e.jsxs("span",{className:"relative block",children:[e.jsx(Qt,{...v,required:F,"aria-invalid":L||v["aria-invalid"],className:`w-full ${V} ${U} ${b}`}),Z]}),$]})}function io(r){return r==null?"":String(r)}function Oi({autoComplete:r="email",inputMode:t="email",validate:n=!0,invalidMessage:a="Ingresa un correo valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:u,...f}){const[p,b]=o.useState(()=>io(c)),m=i!==void 0?io(i):p,v=n&&m.length>0&&!Xn(m)?a:void 0,y=S=>{i===void 0&&b(S.currentTarget.value),u==null||u(S)};return e.jsx(Qn,{...f,value:i,defaultValue:c,type:"text",inputMode:t,autoComplete:r,error:l??v,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 Pi({title:r="Sin resultados",description:t,icon:n=e.jsx(T.HiInbox,{className:"h-5 w-5"}),action:a,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:[n&&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:n}),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})]}),(a||s)&&e.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[s,a]})]})})}const Fi={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function zi(r){if(r===0)return"0 B";const t=["B","KB","MB","GB"],n=Math.min(Math.floor(Math.log(r)/Math.log(1024)),t.length-1),a=r/1024**n;return`${a>=10||n===0?a.toFixed(0):a.toFixed(1)} ${t[n]}`}function co(r,t){return t?t.split(",").map(n=>n.trim().toLowerCase()).filter(Boolean).some(n=>{const a=r.name.toLowerCase(),s=r.type.toLowerCase();return n.startsWith(".")?a.endsWith(n):n.endsWith("/*")?s.startsWith(n.slice(0,-1)):s===n}):!0}function _i(r,t,n){return t?n===void 0?r:r.slice(0,Math.max(0,n)):r.slice(0,1)}function ji({label:r,helperText:t,helperDisplay:n="inline",error:a,labelAction:s,value:l,defaultValue:i=[],onFilesChange:c,onRejectedFiles:u,multiple:f=!1,maxFiles:p,appendFiles:b=!1,showFileList:m=!0,clearable:v=!0,browseLabel:y="Buscar archivos",dropLabel:S="Suelta los archivos aqui",emptyLabel:h="Arrastra y suelta archivos",emptyDescription:P="o haz click para buscarlos en tu equipo",selectedLabel:O="Archivos seleccionados",size:E="md",containerClassName:L="",dropzoneClassName:N="",fileListClassName:k="",className:Y="",id:F,accept:U,disabled:V,required:J,...C}){const re=o.useId(),W=F??re,j=o.useRef(null),[ae,Z]=o.useState(!1),[$,ee]=o.useState(i),se=l??$,M=!!a,H=!!t&&n==="tooltip"&&!M,oe=v&&se.length>0&&!V,A=(z,le)=>{l===void 0&&ee(z),c==null||c(z,le)},q=(z,le)=>{const Ee=z.filter(Te=>co(Te,U)),Le=z.filter(Te=>!co(Te,U)),xe=b?[...se,...Ee]:Ee,Se=_i(xe,f,p);Le.length>0&&(u==null||u(Le)),A(Se,le)},ne=()=>{var z;V||(z=j.current)==null||z.click()},ie=z=>{q(Array.from(z.target.files??[]),z),z.target.value=""},Q=z=>{z.preventDefault(),V||Z(!0)},G=z=>{z.currentTarget.contains(z.relatedTarget)||Z(!1)},w=z=>{z.preventDefault(),Z(!1),!V&&q(Array.from(z.dataTransfer.files),z)},R=z=>{z.key!=="Enter"&&z.key!==" "||(z.preventDefault(),ne())},B=z=>{A(se.filter((le,Ee)=>Ee!==z))},te=()=>{A([])};return e.jsxs("div",{className:`flex flex-col gap-2 ${L}`,children:[(r||s||H)&&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}),J&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),H?e.jsx(Kr,{content:t}):null,s&&e.jsx("span",{className:"ml-auto normal-case",children:s})]}),e.jsx("input",{...C,ref:j,id:W,type:"file",accept:U,multiple:f,disabled:V,required:J&&se.length===0,"aria-invalid":M||C["aria-invalid"],className:"sr-only",onChange:ie}),e.jsxs("div",{role:"button",tabIndex:V?-1:0,"aria-controls":W,"aria-disabled":V||void 0,"aria-invalid":M||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)] ${Fi[E]} ${ae?"border-[var(--primary)] bg-[var(--bg-input)]":M?"border-[var(--danger)]":"border-[var(--border)]"} ${V?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${N} ${Y}`,onClick:ne,onDragOver:Q,onDragLeave:G,onDrop:w,onKeyDown:R,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(T.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:ae?S:h}),P&&e.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:P})]}),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})]}),m&&se.length>0&&e.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${k}`,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:O}),oe&&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:te,children:e.jsx(T.HiTrash,{className:"h-4 w-4"})})]}),e.jsx("ul",{className:"divide-y divide-[var(--border)]",children:se.map((z,le)=>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(T.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:z.name}),e.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:zi(z.size)})]}),!V&&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 ${z.name}`,onClick:()=>B(le),children:e.jsx(T.HiXMark,{className:"h-4 w-4"})})]},`${z.name}-${z.lastModified}-${le}`))})]}),e.jsx(Xr,{error:a,helperText:t,helperDisplay:n})]})}const Wi=[{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 qi({fields:r,title:t="Layout",fieldTypes:n=Wi,saveLabel:a="Guardar",allowAddField:s=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:u,onChange:f}){const[p,b]=o.useState(()=>r.map(E=>({key:!1,type:"",...E}))),[m,v]=o.useState(""),[y,S]=o.useState(""),h=o.useCallback((E,L)=>{b(N=>{const k=N.map((Y,F)=>F===E?{...Y,...L}:Y);return f==null||f(k),k})},[f]),P=o.useCallback(()=>{u==null||u(p)},[p,u]),O=o.useCallback(()=>{var k;const E=m.trim();if(!E){S("Ingresa un nombre de campo.");return}if(p.some(Y=>Y.name.toLowerCase()===E.toLowerCase())){S("Ese campo ya existe en el arreglo.");return}const N={name:E,key:!1,type:((k=n[0])==null?void 0:k.value)??""};b(Y=>{const F=[...Y,N];return f==null||f(F),F}),v(""),S("")},[n,p,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:[p.map((E,L)=>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:E.name}),e.jsx("div",{className:"flex justify-center",children:e.jsx(Wt,{size:"sm",checked:E.key??!1,onChange:N=>h(L,{key:N.target.checked}),"aria-label":`${E.name} es clave`})}),e.jsx(Lr,{value:E.type??"",onChange:N=>h(L,{type:N}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${E.name}`})]},E.name)),p.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:E=>{v(E.currentTarget.value),y&&S("")},onKeyDown:E=>{E.key==="Enter"&&(E.preventDefault(),O())},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(Fe,{variant:"secondary",onClick:O,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(Fe,{variant:"primary",onClick:P,disabled:c,loading:c,children:a})})]})})]})}function uo({label:r,children:t,helperText:n,helperDisplay:a="inline",error:s,labelAction:l,required:i=!1,className:c="",contentClassName:u=""}){const f=!!n&&a==="tooltip"&&!s;return e.jsxs("label",{className:`flex flex-col gap-2 ${c}`,children:[(r||l||f)&&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}),i&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),f?e.jsx(Kr,{content:n}):null,l&&e.jsx("span",{className:"ml-auto normal-case",children:l})]}),e.jsx("span",{className:`block ${u}`,children:t}),e.jsx(Xr,{error:s,helperText:n,helperDisplay:a})]})}function fo(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function bo(r,t){if(r.length!==t.length)return!1;const n=new Set(t);return r.every(a=>n.has(a))}function Jn(r){return r.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Ui(r,t){if(!t)return!0;const n=Jn(t);return Jn(r.label).includes(n)||!!(r.sublabel&&Jn(r.sublabel).includes(n))}function Vi({value:r,onChange:t,options:n,placeholder:a="Seleccionar…",disabled:s=!1,className:l="",style:i,height:c=40,padding:u="6px 10px",searchable:f=!0,minOptionsForSearch:p=6,maxVisibleValues:b=2,truncateSelectedValues:m=!0,emptyText:v="Sin resultados",clearLabel:y="Limpiar seleccion",pruneMissingValues:S=!0}){const[h,P]=o.useState(!1),[O,E]=o.useState(""),[L,N]=o.useState(0),[k,Y]=o.useState(!1),[F,U]=o.useState({}),V=o.useRef(null),J=o.useRef(null),C=o.useRef(null),re=o.useRef(null),W=f&&n.length>=p,j=o.useMemo(()=>new Set(r),[r]),ae=o.useMemo(()=>{const w=new Map;for(const R of n)w.set(R.value,R);return w},[n]),Z=o.useMemo(()=>{const w=[];for(const R of r){const B=ae.get(R);B&&w.push(B)}return w},[ae,r]),$=b==="all"?Z.length:b,ee=Z.slice(0,$),se=Math.max(0,Z.length-ee.length),M=o.useMemo(()=>{const w=O.trim();return!W||!w?n:n.filter(R=>Ui(R,w))},[n,O,W]),H=o.useCallback(()=>{const w=V.current;if(!w)return;const R=w.getBoundingClientRect(),B=W?304:244,te=window.innerHeight-R.bottom,z=te<B&&R.top>te;U({position:"fixed",left:R.left,top:z?void 0:R.bottom+4,bottom:z?window.innerHeight-R.top+4:void 0,width:Math.max(R.width,240),zIndex:9999})},[W]),oe=o.useCallback(w=>{bo(r,w)||t(w)},[t,r]),A=o.useCallback(w=>{const R=ae.get(w);if(R!=null&&R.disabled)return;const B=j.has(w)?r.filter(te=>te!==w):[...r,w];oe(B)},[oe,ae,r,j]),q=o.useCallback(()=>oe([]),[oe]),ne=o.useCallback(()=>{P(!1),E(""),N(0)},[]);o.useEffect(()=>Y(!0),[]);const ie=o.useMemo(()=>n.map(w=>w.value).join("\0"),[n]);o.useEffect(()=>{if(!S||r.length===0||n.length===0)return;const w=new Set(n.map(B=>B.value)),R=r.filter(B=>w.has(B));bo(r,R)||t(R)},[ie]),o.useEffect(()=>{if(!h)return;function w(R){var te,z;const B=R.target;!((te=V.current)!=null&&te.contains(B))&&!((z=J.current)!=null&&z.contains(B))&&ne()}return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[ne,h]),o.useEffect(()=>{h&&(N(0),H(),W&&setTimeout(()=>{var w;return(w=C.current)==null?void 0:w.focus()},0))},[h,W,H]),o.useEffect(()=>{if(h)return window.addEventListener("resize",H),window.addEventListener("scroll",H,!0),()=>{window.removeEventListener("resize",H),window.removeEventListener("scroll",H,!0)}},[h,H]),o.useEffect(()=>{if(M.length===0){N(0);return}N(w=>Math.min(w,M.length-1))},[M.length]),o.useEffect(()=>{if(L<0||!re.current)return;const w=re.current.children[L];w==null||w.scrollIntoView({block:"nearest"})},[L]);function Q(w){if(!s){if(!h){(w.key==="Enter"||w.key===" "||w.key==="ArrowDown")&&(w.preventDefault(),P(!0));return}if(w.key==="Escape"){w.preventDefault(),ne();return}if(w.key==="ArrowDown"){if(w.preventDefault(),M.length===0)return;N(R=>Math.min(R+1,M.length-1));return}if(w.key==="ArrowUp"){w.preventDefault(),N(R=>Math.max(R-1,0));return}if(w.key==="Enter"&&M[L]&&!M[L].disabled){w.preventDefault(),A(M[L].value);return}w.key==="Backspace"&&!O&&r.length&&(w.preventDefault(),oe(r.slice(0,-1)))}}const G=e.jsxs("div",{ref:J,className:"overflow-hidden rounded-xl shadow-xl",style:{...F,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[W&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(T.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:C,value:O,onChange:w=>{E(w.target.value),N(0)},onKeyDown:w=>{(w.key==="ArrowDown"||w.key==="ArrowUp"||w.key==="Enter"||w.key==="Escape")&&(w.stopPropagation(),Q(w))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),O&&e.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:w=>{w.preventDefault(),E(""),N(0)},children:e.jsx(T.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:[Z.length," seleccionados",r.length>Z.length?` (${r.length-Z.length} no disponibles)`:""]}),e.jsx("button",{type:"button",onMouseDown:w=>{w.preventDefault(),q()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:y})]}),e.jsxs("ul",{ref:re,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:W?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[M.map((w,R)=>{const B=R===L,te=j.has(w.value);return e.jsxs("li",{role:"option","aria-selected":te,onMouseDown:z=>{z.preventDefault(),!w.disabled&&A(w.value)},onMouseEnter:()=>!w.disabled&&N(R),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:B?"var(--bg-hover)":te?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:w.disabled?"var(--text-muted)":"var(--text-main)",cursor:w.disabled?"not-allowed":"pointer",opacity:w.disabled?.58:1},children:[e.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:te?"var(--primary)":"var(--border)",background:te?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:te&&e.jsx(T.HiCheck,{className:"h-3 w-3"})}),w.color&&e.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:w.color}}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:w.label}),w.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:w.sublabel})]}),w.badge&&e.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:w.badge})]},w.value)}),M.length===0&&e.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:v})]})]});return e.jsxs("div",{ref:V,className:`relative ${l||"w-full"}`,style:i,onKeyDown:Q,children:[e.jsxs("button",{type:"button",disabled:s,onClick:()=>{s||(h?ne():P(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:fo(c),padding:fo(u),background:"var(--bg-input)",color:Z.length?"var(--text-main)":"var(--text-muted)",border:h?"1px solid var(--primary)":"1px solid var(--border)",opacity:s?.5:1,cursor:s?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":h,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(w=>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:[w.color&&e.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:w.color}}),e.jsx("span",{className:m?"truncate":"break-words",children:w.label}),e.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${w.label}`,onMouseDown:R=>{R.preventDefault(),R.stopPropagation(),A(w.value)},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(T.HiXMark,{className:"h-3 w-3"})})]},w.value)),se>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:["+",se]})]}):e.jsx("span",{className:"truncate",children:a})}),Z.length?e.jsx("span",{role:"button",tabIndex:-1,"aria-label":y,onMouseDown:w=>{w.preventDefault(),w.stopPropagation(),q()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(T.HiXMark,{className:"h-3.5 w-3.5"})}):e.jsx(T.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:h?"rotate(180deg)":"rotate(0deg)"}})]}),h&&k&&er.createPortal(G,document.body)]})}function Gi({inputMode:r="decimal",...t}){return e.jsx(Qn,{...t,type:"number",inputMode:r})}function Ki(r,t,n){const a=[],s=Math.max(2,r-n),l=Math.min(t-1,r+n);a.push(1),s>2&&a.push("...");for(let i=s;i<=l;i+=1)a.push(i);return l<t-1&&a.push("..."),t>1&&a.push(t),a}function Xi({page:r,totalPages:t,onPageChange:n,disabled:a=!1,siblingCount:s=1,className:l=""}){const i=Math.max(1,t),c=Math.min(Math.max(1,r),i),u=Ki(c,i,s);return e.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[e.jsx(Fe,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:a||c<=1,onClick:()=>n(c-1),children:e.jsx(T.HiChevronLeft,{className:"h-4 w-4"})}),u.map((f,p)=>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-${p}`):e.jsx("button",{type:"button","aria-current":f===c?"page":void 0,disabled:a,onClick:()=>n(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(Fe,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:a||c>=i,onClick:()=>n(c+1),children:e.jsx(T.HiChevronRight,{className:"h-4 w-4"})})]})}const po=[{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 mo(r){return r==null?"":String(r)}function Jt(r){return r?r.startsWith("+")?r:`+${r}`:"+1"}function Yi(r){return typeof r=="number"?`${r}px`:r}function Zi({autoComplete:r="tel",inputMode:t="tel",validate:n=!0,invalidMessage:a="Ingresa un telefono valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:u,countryCode:f,defaultCountryCode:p="+1",onCountryCodeChange:b,allowedCountryCodes:m,countryCodeOptions:v,countryCodePlaceholder:y="Codigo",countryCodeClassName:S="",countryCodeWidth:h=84,onPhoneValueChange:P,label:O,containerClassName:E="",helperText:L,helperDisplay:N="inline",labelAction:k,className:Y="",required:F,disabled:U,floatingLabel:V,showPasswordToggle:J,nativeValidation:C,errorTooltipLabel:re="Error de validacion",...W}){var z;const[j,ae]=o.useState(()=>mo(c)),[Z,$]=o.useState(()=>Jt(p)),ee=o.useMemo(()=>{const le=v??po,Ee=m==null?void 0:m.map(Jt);return Ee!=null&&Ee.length?le.filter(Le=>Ee.includes(Le.value)):le},[m,v]),se=((z=ee[0])==null?void 0:z.value)??"+1",M=ee.some(le=>le.value===Jt(f??Z))?Jt(f??Z):se,H=i!==void 0?mo(i):j,oe=`${M} ${H}`.trim(),A=n&&H.length>0&&!Yn(oe)?a:void 0,q=l??A,ne=!!q,ie=ne&&s!=="tooltip",Q=ne&&s!=="inline",G=!!L&&N==="tooltip"&&!ie,w=ne?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",R=le=>{const Ee=le.currentTarget.value;i===void 0&&ae(Ee),P==null||P(Ee,{countryCode:M,nationalNumber:Ee,fullNumber:`${M} ${Ee}`.trim()}),u==null||u(le)},B=le=>{f===void 0&&$(le),b==null||b(le),P==null||P(H,{countryCode:le,nationalNumber:H,fullNumber:`${le} ${H}`.trim()})},te=Q?e.jsx(Mr,{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":re,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(lo,{className:"h-[18px] w-[18px]"})})}):null;return e.jsxs("div",{className:`flex flex-col gap-2 ${E}`,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:O}),F&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),G?e.jsx(Kr,{content:L}):null,k&&e.jsx("span",{className:"ml-auto normal-case",children:k})]}),e.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${w}`,children:[e.jsx(Lr,{value:M,onChange:B,options:ee,placeholder:y,disabled:U,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${S}`,style:{width:Yi(h)},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",{...W,value:i,defaultValue:c,type:"tel",inputMode:t,autoComplete:r,disabled:U,required:void 0,"aria-label":W["aria-label"]??(typeof O=="string"?O:void 0),"aria-invalid":ne||W["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 ${Q?"pr-10":""} ${Y}`,onChange:R}),te]})]}),e.jsx(Xr,{error:ie?q:void 0,helperText:L,helperDisplay:N})]})}function Qi({value:r,onChange:t,options:n,name:a,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:n.map(f=>{const p=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:p?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:p?"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:a,value:f.value,checked:p,disabled:b,onChange:()=>t(f.value),className:"absolute inset-0 opacity-0"}),e.jsx("span",{className:`h-2 w-2 rounded-full transition ${p?"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 ho=()=>'<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>',kt=r=>r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),go=r=>r.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(t,n,a)=>`${n}${a.toLocaleUpperCase()}`),Ji=r=>r.replace(/[<>]/g,"").toLowerCase(),Ri=new Set(["p","br","div","span","b","strong","i","em","u","s","strike","ul","ol","li","h1","h2","h3","h4","blockquote","a","img","hr"]),ec=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,rc=r=>{const t=r.indexOf("<!--StartFragment-->"),n=r.indexOf("<!--EndFragment-->");if(t!==-1&&n!==-1&&n>t)return r.slice(t+20,n);const a=r.match(/<body[^>]*>([\s\S]*)<\/body>/i);return a?a[1]:r},Rt=(r,t)=>t.test(r),tc=r=>Rt(r,/font-weight\s*:\s*(bold|[6-9]00)/i),nc=r=>Rt(r,/font-style\s*:\s*italic/i),ac=r=>Rt(r,/text-decoration(?:-line)?\s*:[^;]*underline/i),oc=r=>Rt(r,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),en=(r,t)=>{var a;if(!r.childNodes.length||r.childNodes.length===1&&((a=r.firstChild)==null?void 0:a.nodeType)===Node.ELEMENT_NODE&&r.firstChild.tagName.toLowerCase()===t)return;const n=r.ownerDocument.createElement(t);for(;r.firstChild;)n.appendChild(r.firstChild);r.appendChild(n)},rn=r=>{const t=r.parentNode;if(!t){r.remove();return}for(;r.firstChild;)t.insertBefore(r.firstChild,r);t.removeChild(r)},sc=r=>{const t=r.getAttribute("class")??"",n=r.getAttribute("style")??"";return/mso-list/i.test(n)||/MsoListParagraph/i.test(t)||/MsoList/i.test(t)},vo=r=>{const t=r.getAttribute("style")??"",n=r.textContent??"";return/mso-level-number-format\s*:\s*(decimal|arabic|roman|alpha)/i.test(t)||/^\s*\d+[.)]\s/.test(n)||/^\s*[a-zA-Z][.)]\s/.test(n)?"ol":"ul"},lc=r=>{const n=r.ownerDocument.createTreeWalker(r,NodeFilter.SHOW_TEXT).nextNode();if(!n||!n.textContent)return;const a=n.textContent.replace(ec,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");a!==n.textContent&&(n.textContent=a)},ic=r=>{const t=Array.from(r.querySelectorAll("span, font, p, div, li, h1, h2, h3, h4"));t.sort((n,a)=>a.querySelectorAll("*").length-n.querySelectorAll("*").length),t.forEach(n=>{const a=n.getAttribute("style")??"";a&&(tc(a)&&en(n,"strong"),nc(a)&&en(n,"em"),ac(a)&&en(n,"u"),oc(a)&&en(n,"s"))})},cc=r=>{const t=Array.from(r.querySelectorAll("p, div")).filter(sc);if(!t.length)return;let n=0;for(;n<t.length;){const a=t[n],s=vo(a),l=[a];let i=n+1;for(;i<t.length;){const f=t[i];if(vo(f)!==s)break;let p=l[l.length-1].nextSibling;for(;p&&p.nodeType===Node.TEXT_NODE&&!(p.textContent??"").trim();)p=p.nextSibling;if(p!==f)break;l.push(f),i++}const c=a.parentNode;if(!c){n=i;continue}const u=a.ownerDocument.createElement(s);c.insertBefore(u,a),l.forEach(f=>{lc(f);const p=f.ownerDocument.createElement("li");for(;f.firstChild;)p.appendChild(f.firstChild);u.appendChild(p),f.remove()}),n=i}},dc=r=>r==="h1"?"h2":r==="h4"||r==="h5"||r==="h6"?"h3":r==="div"?"p":r,uc=r=>{const t=rc(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()),ic(s),cc(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"){rn(u),c.forEach(l);return}if(!Ri.has(f)){rn(u),c.forEach(l);return}const p=dc(f);if(p!==f){const b=u.ownerDocument.createElement(p);for(;u.firstChild;)b.appendChild(u.firstChild);u.replaceWith(b),l(b);return}if(Array.from(u.attributes).forEach(b=>{const m=b.name.toLowerCase(),v=b.value;if(m.startsWith("on")||m==="style"||m==="class"){u.removeAttribute(b.name);return}if(m==="lang"||m.startsWith("data-")||m.startsWith("mso-")){u.removeAttribute(b.name);return}if((m==="href"||m==="src")&&/^\s*javascript:/i.test(v)){u.removeAttribute(b.name);return}f!=="a"&&f!=="img"&&m!=="href"&&m!=="src"&&m!=="alt"&&(["href","src","alt","target","rel"].includes(m)||u.removeAttribute(b.name))}),f==="a"){const b=u.getAttribute("href");if(!b||/^\s*#/.test(b)&&b.length<2){rn(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(m=>{["src","alt","class"].includes(m.name.toLowerCase())||u.removeAttribute(m.name)})}if(f==="span"){rn(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(p=>p.nodeType===Node.TEXT_NODE||p.nodeType===Node.ELEMENT_NODE&&p.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()},Rn=r=>kt(r).replace(/\r\n?/g,`
25
- `).split(/\n{2,}/).map(t=>`<p>${t.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),fc=r=>new RegExp("\\p{L}","u").test(r),ea=(r,t)=>{const n=r.trim();return!n||!fc(n)?!1:t==="uppercase"?n===n.toLocaleUpperCase():t==="lowercase"?n===n.toLocaleLowerCase():n===go(n)},xo=r=>{const t=a=>{var s,l;if(!a.closest(".rich-img-wrap")){const i=document.createElement("span");i.className="rich-img-wrap",i.contentEditable="false",(s=a.parentNode)==null||s.insertBefore(i,a),i.appendChild(a),i.insertAdjacentHTML("beforeend",ho())}(l=a.closest(".rich-img-wrap"))==null||l.classList.add("rich-img-broken")};r.querySelectorAll("img").forEach(a=>{if(!a.complete||a.naturalWidth===0){a.addEventListener("error",()=>t(a),{once:!0}),a.addEventListener("load",()=>{a.naturalWidth===0&&t(a)},{once:!0});const s=a.src;a.src="",a.src=s}});const n=a=>{const s=a.target;s.tagName==="IMG"&&t(s)};return r.addEventListener("error",n,!0),()=>r.removeEventListener("error",n,!0)};function yo({value:r,onChange:t,placeholder:n="Escribe algo...",minHeight:a="80px",instanceId:s}){const l=o.useId(),i=s||l,c=o.useCallback(()=>document,[]),u=o.useRef(null),f=o.useRef(null),p=o.useRef(new Map),b=o.useRef(null),m=o.useRef(!1),v=o.useRef(r??""),y=o.useRef(t),S=o.useRef(!1),[h,P]=o.useState(()=>!r||r.trim()===""),[O,E]=o.useState(new Set),[L,N]=o.useState(null),[k,Y]=o.useState(""),[F,U]=o.useState(""),[V,J]=o.useState(""),[C,re]=o.useState(""),[W,j]=o.useState(!1),ae=o.useCallback(()=>m.current?f.current:u.current,[]);o.useEffect(()=>{y.current=t},[t]);const Z=o.useCallback(()=>{const I=window.getSelection(),X=ae();if(!I||!X||I.rangeCount===0||I.isCollapsed)return"";const ue=I.getRangeAt(0);return!X.contains(ue.startContainer)||!X.contains(ue.endContainer)?"":I.toString()},[ae]);o.useEffect(()=>{const I=r??"";if(S.current&&I===v.current){S.current=!1,P(!I||I.trim()==="");return}S.current=!1,v.current=I;const X=[u.current,f.current].filter(be=>!!be);X.forEach(be=>{be.innerHTML!==I&&(be.innerHTML=I)}),P(!I||I.trim()==="");const ue=X.map(be=>xo(be));return()=>ue.forEach(be=>be())},[r]),o.useEffect(()=>{var be,De;m.current=W;let I,X=0,ue;if(W){const Ce=u.current;Ce&&(v.current=Ce.innerHTML);const Oe=()=>{var Ve;const $e=f.current;if(!$e){X=requestAnimationFrame(Oe);return}$e.innerHTML!==v.current&&($e.innerHTML=v.current),I=xo($e),P(((Ve=$e.textContent)==null?void 0:Ve.trim())===""),ue=setTimeout(()=>$e.focus(),60)};X=requestAnimationFrame(Oe)}else{const Ce=f.current,Oe=u.current,$e=(Ce==null?void 0:Ce.innerHTML)??v.current,Ve=v.current;v.current=$e,Oe&&Oe.innerHTML!==$e&&(Oe.innerHTML=$e),$e!==Ve&&y.current($e),P(((De=(be=Ce??Oe)==null?void 0:be.textContent)==null?void 0:De.trim())==="")}return()=>{X&&cancelAnimationFrame(X),ue&&clearTimeout(ue),I==null||I()}},[W]);const $=o.useCallback(()=>{const I=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],X=new Set;I.forEach(be=>{try{c().queryCommandState(be)&&X.add(be)}catch{return}});try{const be=Ji(c().queryCommandValue("formatBlock"));be&&X.add(`formatBlock:${be}`)}catch{}const ue=Z();ea(ue,"uppercase")&&X.add("__upper"),ea(ue,"lowercase")&&X.add("__lower"),ea(ue,"capitalize")&&X.add("__cap"),E(X)},[Z,c]),ee=()=>{var X;const I=ae();I&&(v.current=I.innerHTML,S.current=!0,y.current(v.current),P(((X=I.textContent)==null?void 0:X.trim())===""))},se=I=>{if(!I){const X=u.current;X&&(v.current=X.innerHTML)}j(!I)},M=(I,X)=>{var ue;(ue=ae())==null||ue.focus(),c().execCommand(I,!1,X),ee(),$()},H=I=>{M("formatBlock",I)},oe=()=>{var I;(I=ae())==null||I.focus(),c().execCommand("insertHTML",!1,"<hr><p><br></p>"),ee(),$()},A=()=>{const I=window.getSelection();I&&I.rangeCount>0&&(b.current=I.getRangeAt(0).cloneRange())},q=()=>{const I=window.getSelection();I&&b.current&&(I.removeAllRanges(),I.addRange(b.current))},ne=I=>{if(A(),I==="link"){const X=window.getSelection();U(X&&!X.isCollapsed?X.toString():""),Y("")}I==="image"&&(J(""),re("")),N(I)},ie=()=>{var be;if(!k.trim())return;q(),(be=ae())==null||be.focus();const I=window.getSelection(),ue=(I&&!I.isCollapsed?I.toString():"")||F.trim()||k.trim();c().execCommand("insertHTML",!1,`<a href="${kt(k.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${kt(ue)}</a>`),ee(),N(null)},Q=(I,X="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${kt(I)}" alt="${kt(X)}" class="rich-img" />${ho()}</span>`,G=()=>{var I;V.trim()&&(q(),(I=ae())==null||I.focus(),c().execCommand("insertHTML",!1,Q(V.trim(),C.trim())),ee(),N(null))},w=(I,X=1200,ue=1200,be=.72)=>new Promise((De,Ce)=>{const Oe=new FileReader;Oe.onerror=Ce,Oe.onload=$e=>{var bn;const Ve=(bn=$e.target)==null?void 0:bn.result,He=new Image;He.onerror=Ce,He.onload=()=>{let{width:Ke,height:_e}=He;if(Ke>X||_e>ue){const ir=Math.min(X/Ke,ue/_e);Ke=Math.round(Ke*ir),_e=Math.round(_e*ir)}const Xe=document.createElement("canvas");Xe.width=Ke,Xe.height=_e;const Dr=Xe.getContext("2d");if(!Dr){De(Ve);return}Dr.drawImage(He,0,0,Ke,_e),De(Xe.toDataURL("image/jpeg",be))},He.src=Ve},Oe.readAsDataURL(I)}),R=I=>{I.focus();const X=window.getSelection();if(!X||X.rangeCount===0||!I.contains(X.anchorNode)){const ue=document.createRange();ue.selectNodeContents(I),ue.collapse(!1),X==null||X.removeAllRanges(),X==null||X.addRange(ue)}},B=o.useRef(()=>{});B.current=I=>{const X=ae();X&&(R(X),c().execCommand("insertHTML",!1,I),X.querySelectorAll("p").forEach(ue=>{!(ue.textContent??"").replace(/[\u00a0\s]+/g,"")&&!ue.querySelector("img, hr")&&ue.remove()}),ee(),$())};const te=o.useRef(w);te.current=w;const z=o.useRef(Q);z.current=Q;const le=o.useCallback(I=>{if(!I||p.current.has(I))return;const X=ue=>{const be=ue.clipboardData;if(!be)return;const De=be.getData("text/html"),Ce=be.getData("text/plain");if(De||Ce){ue.preventDefault(),ue.stopPropagation();try{const He=De?uc(De):Rn(Ce);if(!He){Ce&&B.current(Rn(Ce));return}B.current(He)}catch{Ce&&B.current(Rn(Ce))}return}const $e=Array.from(be.items).find(He=>He.type.startsWith("image/"));if(!$e)return;ue.preventDefault(),ue.stopPropagation();const Ve=$e.getAsFile();Ve&&te.current(Ve).then(He=>{B.current(z.current(He,"imagen"))})};I.addEventListener("paste",X,!0),p.current.set(I,()=>{I.removeEventListener("paste",X,!0),p.current.delete(I)})},[]),Ee=o.useCallback(I=>{var ue;const X=u.current;X&&X!==I&&((ue=p.current.get(X))==null||ue()),u.current=I,I&&le(I)},[le]),Le=o.useCallback(I=>{var ue;const X=f.current;X&&X!==I&&((ue=p.current.get(X))==null||ue()),f.current=I,I&&le(I)},[le]);o.useEffect(()=>{const I=p.current;return()=>{I.forEach(X=>X()),I.clear()}},[]);const xe=I=>{const X=window.getSelection(),ue=ae();if(!X||!ue||X.rangeCount===0||X.isCollapsed)return;const be=X.getRangeAt(0);if(!ue.contains(be.startContainer)||!ue.contains(be.endContainer))return;const De=be.toString();if(!De)return;let Ce=De;I==="uppercase"?Ce=De.toLocaleUpperCase():I==="lowercase"?Ce=De.toLocaleLowerCase():Ce=go(De),be.deleteContents();const Oe=document.createTextNode(Ce);be.insertNode(Oe);const $e=document.createRange();$e.setStart(Oe,0),$e.setEnd(Oe,Ce.length),X.removeAllRanges(),X.addRange($e),b.current=$e.cloneRange(),ee(),$()},Se=()=>{A(),$()},Te=()=>{ee(),$()},kr=()=>{requestAnimationFrame(()=>{var I;(I=ae())==null||I.focus()})},pr=I=>{var X,ue;if((I.metaKey||I.ctrlKey)&&I.key==="Enter"){if(I.preventDefault(),I.stopPropagation(),I.repeat)return;(X=ae())==null||X.focus(),c().execCommand("insertLineBreak",!1)||c().execCommand("insertHTML",!1,"<br>"),ee(),$();return}if(I.key==="Tab"){I.preventDefault(),(ue=ae())==null||ue.focus(),c().execCommand("insertText",!1,"    "),ee(),$();return}if(I.key==="Escape"){if(L){N(null);return}if(m.current){j(!1);return}}L||(I.ctrlKey||I.metaKey)&&(I.key==="b"&&(I.preventDefault(),M("bold")),I.key==="i"&&(I.preventDefault(),M("italic")),I.key==="u"&&(I.preventDefault(),M("underline")),I.key==="k"&&(I.preventDefault(),ne("link")))},qe=()=>e.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),ce=(I,X,ue,be,De)=>{const Ce=De??(O.has(ue)||ue==="__link"&&L==="link"||ue==="__img"&&L==="image");return e.jsx("button",{type:"button",title:X,tabIndex:-1,onFocus:kr,onMouseDown:Oe=>{Oe.preventDefault(),be?be():M(ue)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:Ce?"var(--primary)":"var(--text-secondary)",background:Ce?"rgba(59,130,246,0.12)":"transparent"},children:I},ue)},Qe=I=>{const X=I.target;if(X.closest("[data-action='delete-img']")){I.preventDefault();const ue=X.closest(".rich-img-wrap");ue&&(ue.remove(),ee())}},lr=I=>e.jsxs(e.Fragment,{children:[L==="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:I},children:[e.jsx("input",{autoFocus:!0,type:"url",value:k,onChange:X=>Y(X.target.value),onKeyDown:X=>{X.key==="Enter"&&(X.preventDefault(),ie()),X.key==="Escape"&&N(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:F,onChange:X=>U(X.target.value),onKeyDown:X=>{X.key==="Enter"&&(X.preventDefault(),ie()),X.key==="Escape"&&N(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: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:()=>N(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),L==="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:I},children:[e.jsx("input",{autoFocus:!0,type:"url",value:V,onChange:X=>J(X.target.value),onKeyDown:X=>{X.key==="Enter"&&(X.preventDefault(),G()),X.key==="Escape"&&N(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:C,onChange:X=>re(X.target.value),onKeyDown:X=>{X.key==="Enter"&&(X.preventDefault(),G()),X.key==="Escape"&&N(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:()=>N(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),fe=(I,X)=>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:X},children:[ce(e.jsx(T.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),ce(e.jsx(T.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),qe(),ce(e.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>H("p"),O.has("formatBlock:p")||O.has("formatBlock:div")),ce(e.jsx(T.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>H("h2"),O.has("formatBlock:h2")),ce(e.jsx(T.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>H("h3"),O.has("formatBlock:h3")),ce(e.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>H("blockquote"),O.has("formatBlock:blockquote")),qe(),ce(e.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),ce(e.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),ce(e.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),ce(e.jsx("s",{children:"S"}),"Tachado","strikeThrough"),qe(),ce(e.jsx(T.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),ce(e.jsx(T.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),ce(e.jsx(T.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),ce(e.jsx(T.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),qe(),ce(e.jsx(T.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),ce(e.jsx(T.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),ce(e.jsx(T.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),ce(e.jsx(T.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),qe(),ce(e.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>xe("uppercase")),ce(e.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>xe("lowercase")),ce(e.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>xe("capitalize")),qe(),ce(e.jsx(T.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>ne("link")),ce(e.jsx(T.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),ce(e.jsx(T.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>ne("image")),ce(e.jsx(T.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",oe),qe(),ce(e.jsx(T.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),ce(e.jsx(T.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>H("p")),qe(),e.jsx("button",{type:"button",title:I?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:kr,onMouseDown:ue=>{ue.preventDefault(),se(I)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:I?e.jsx(T.HiArrowsPointingIn,{className:"h-4 w-4"}):e.jsx(T.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:Ee,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:Te,onKeyDown:pr,onKeyUp:Se,onSelect:Se,onMouseUp:Se,onMouseDown:Qe,"data-placeholder":n,className:`rich-editor px-3 py-2 text-sm focus:outline-none${h?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:a,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),lr("var(--bg-input)"),fe(!1,"var(--bg-input)")]}),e.jsxs(qn,{open:W,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:Le,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:Te,onKeyDown:pr,onKeyUp:Se,onSelect:Se,onMouseUp:Se,onMouseDown:Qe,"data-placeholder":n,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${h?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),lr("var(--bg-input)"),fe(!0,"var(--bg-input)")]})]})}const wo="[a-zA-Z0-9._@-]+",ra=new RegExp(`@(${wo})`,"g"),bc=/[a-zA-Z0-9._@-]/,Nt=new Set([" ",`
26
- `," ","\r"," ","(","[","{",".",",",";",":","!","?","¿","¡",")","]","}",'"',"'","«","»","/","\\","|","-","—","–"]);function ko(r,t){if(t<=0)return!0;const n=r[t-1]??"";return Nt.has(n)}function No(r,t,n){var a;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(Nt.has(c)||!bc.test(c))return null;continue}if((a=n==null?void 0:n.isInsideExistingMention)!=null&&a.call(n,s)||!(n!=null&&n.isTriggerBoundary?n.isTriggerBoundary(s):ko(r,s)))continue;const i=r.slice(s+1,t);return i.length>0&&!new RegExp(`^${wo}$`).test(i)?null:{query:i,triggerIndex:s,caretIndex:t}}return null}function So(r,t){var a;const n=Yr(r,t);return n?!!((a=n.node.parentElement)!=null&&a.closest(".mention-chip")):!1}function Co(r,t){if(t<=0)return!0;const n=Yr(r,t);if(!n){const s=r.textContent??"";return ko(s,t)}if(n.offset>0){const s=n.node.data[n.offset-1]??"";return Nt.has(s)}let a=n.node.previousSibling;for(;a;){if(a.nodeType===Node.TEXT_NODE){const s=a.textContent??"";if(s.length===0){a=a.previousSibling;continue}return Nt.has(s[s.length-1]??"")}if(a.nodeType===Node.ELEMENT_NODE){const s=a;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){a=a.previousSibling;continue}return Nt.has(l[l.length-1]??"")}a=a.previousSibling}return!0}function ta(r,t){const n=r.textContent??"";return No(n,t,{isTriggerBoundary:a=>Co(r,a),isInsideExistingMention:a=>So(r,a)})}function na(r){return r.toLowerCase().trim()}function Eo(r){return r?r.replace(/<style[^>]*>[\s\S]*?<\/style>/gi," ").replace(/<script[^>]*>[\s\S]*?<\/script>/gi," ").replace(/<br\s*\/?>/gi,`
23
+ </body></html>`,ue=window.open("","_blank");ue&&(ue.document.write(J),ue.document.close())}const Wn=()=>!gr||!_t?null:tr.createPortal(e.jsxs("div",{ref:Ta,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Su,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:()=>{tf(),En(!1)},children:[e.jsx(B.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:()=>{nf(),En(!1)},children:[e.jsx(B.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),qn=()=>{const f=Z&&vr.trim().length>0,x=ie!=null&&ie.length?ie:f?[{key:"bql",label:"BQL",value:vr}]:[],z=Ee.filter(N=>{const J=N.trim();return J?!new Set(Ft.split(`
24
+ `).map(me=>me.trim()).filter(Boolean)).has(J):!1}).slice(0,8);return!H&&$a===0&&!Z&&!gr?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:[$a>0&&e.jsxs("button",{type:"button",onClick:Pu,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(B.HiXMark,{className:"h-3.5 w-3.5"}),$a," filtros"]}),Z&&e.jsxs("div",{ref:Ea,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>{if(xr){Pr(!1);return}Hn(),Pr(!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:xr?"var(--primary)":f?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:xr||f?"var(--primary)":"var(--border)",color:xr?"var(--primary-fg)":"var(--primary)"},"aria-expanded":xr,title:"Abrir filtros BQL",children:[e.jsx(B.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",f&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),xr?e.jsx(B.HiChevronUp,{className:"h-3.5 w-3.5"}):e.jsx(B.HiChevronDown,{className:"h-3.5 w-3.5"})]}),e.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:F}),x.length>0&&e.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[x.slice(0,3).map(N=>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:[N.label,":"]}),e.jsx("span",{className:"truncate",children:N.value})]},N.key)),x.length>3&&e.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",x.length-3]})]}),f&&e.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:Us,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(B.HiXMark,{className:"h-4 w-4"})}),xr&&tr.createPortal(e.jsxs("div",{ref:As,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...yu,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:[q.map(N=>e.jsxs("button",{type:"button",onMouseDown:J=>{J.preventDefault(),J.stopPropagation()},onClick:J=>{J.preventDefault(),J.stopPropagation(),In(N.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:[N.icon,N.label]},N.label)),ce.length>0&&e.jsxs("button",{type:"button",onClick:()=>st(N=>!N),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":Ls,children:[e.jsx(B.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),zt.length>0&&e.jsxs("button",{type:"button",onClick:()=>lt(N=>!N),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":$s,children:[e.jsx(B.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 ${ge?"var(--danger)":f?"var(--primary)":"var(--border)"}`},children:[e.jsx("textarea",{ref:Ma,value:Ft,rows:3,onChange:N=>Da(N.target.value,N.target),onKeyDown:N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),qs(Ft)),N.key==="Escape"&&Pr(!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"}}),z.length>0&&e.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:z.map(N=>e.jsx("button",{type:"button",onMouseDown:J=>{J.preventDefault(),J.stopPropagation()},onClick:J=>{J.preventDefault(),J.stopPropagation(),In(N)},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:N},N))})]}),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:ge?"var(--danger)":"var(--text-muted)"},children:ge??(f?`${x.length||1} filtro${(x.length||1)===1?"":"s"} activo${(x.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),x.map(N=>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:[N.label,":"]}),e.jsx("span",{className:"truncate",children:N.value})]},N.key))]}),$s&&zt.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(B.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),e.jsxs("button",{type:"button",onClick:()=>{it([]),lt(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[e.jsx(B.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),zt.map(N=>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:J=>{J.preventDefault(),J.stopPropagation()},onClick:J=>{J.preventDefault(),J.stopPropagation(),In(N)},className:"min-w-0 flex-1 text-left",children:e.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:N})}),e.jsx("button",{type:"button",onClick:()=>it(J=>J.filter(ue=>ue!==N)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx(B.HiXMark,{className:"h-3.5 w-3.5"})})]},N))]}),Ls&&ce.length>0&&e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:ce.map(N=>e.jsxs("button",{type:"button",onMouseDown:J=>{J.preventDefault(),J.stopPropagation()},onClick:J=>{J.preventDefault(),J.stopPropagation(),In(N.bql),st(!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:N.bql}),N.description&&e.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:N.description})]},N.bql))}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] pt-3",children:[f&&e.jsxs("button",{type:"button",onClick:Us,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(B.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),e.jsxs("button",{type:"button",onClick:()=>qs(Ft),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(B.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),gr&&e.jsx("button",{ref:Mn,type:"button","aria-haspopup":"menu","aria-expanded":_t,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var J;const N=(J=Mn.current)==null?void 0:J.getBoundingClientRect();N&&Cu({top:N.bottom+4,right:window.innerWidth-N.right}),En(ue=>!ue)},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(B.HiArrowDownTray,{className:"h-4 w-4"})}),H&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ye&&dr==="visibility","aria-label":se,title:se,onClick:N=>Ks(N,"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)] ${Ye&&dr==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:e.jsx(B.HiCog6Tooth,{className:"h-4 w-4"})})]})},al=()=>{if(!Qu)return null;const f=ui(qe,Fa);return e.jsxs("div",{"aria-busy":a,className:`grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 rounded-b-xl border-t text-xs select-none ${D?"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:Ur===0?"0 filas":`${Ju}–${Ru} de ${Ur}`}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),e.jsx(Ar,{value:String(br),onChange:x=>ef(Number(x)),options:Xs.map(x=>({value:String(x),label:String(x)})),placeholder:"Filas",searchable:!1,disabled:a,height:K,padding:W,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:A}})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[e.jsx("button",{disabled:a||qe<=1,onClick:()=>za(qe-1),onMouseEnter:x=>{x.currentTarget.disabled||(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="transparent",x.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(B.HiChevronLeft,{className:"h-3.5 w-3.5"})}),f.map((x,z)=>x==="..."?e.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${z}`):e.jsx("button",{disabled:a,onClick:()=>za(x),onMouseEnter:N=>{N.currentTarget.disabled||x===qe||(N.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",N.currentTarget.style.color="var(--primary)")},onMouseLeave:N=>{N.currentTarget.style.background=x===qe?"var(--primary)":"transparent",N.currentTarget.style.color=x===qe?"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:x===qe?"var(--primary)":"transparent",color:x===qe?"var(--primary-fg)":"var(--text-muted)"},children:x},x)),e.jsx("button",{disabled:a||qe>=Fa,onClick:()=>za(qe+1),onMouseEnter:x=>{x.currentTarget.disabled||(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="transparent",x.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(B.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{"aria-hidden":"true"})]})},af=()=>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:Pn},children:[_n(),Wn(),qn(),e.jsx("div",{ref:Er,className:"min-w-0 max-w-full overflow-hidden",children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:qt,minWidth:Fn},children:[e.jsx("div",{role:"rowgroup",style:C?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:zn()}),e.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,s)}).map((f,x)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:pt,borderBottom:`1px solid ${Te}`},children:[pr&&e.jsx("div",{role:"cell",className:`${D?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Te}`,borderRight:`1px solid ${Te}`}},"select-cell"),rr.map((z,N)=>e.jsx("div",{role:"cell",className:D?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${Te}`,borderRight:`1px solid ${Te}`},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${Os(x,N)}%`,minWidth:32}})},z.key))]},x))})]})})]}),ja="min-w-0 max-w-full overflow-hidden";return P&&Re&&!fe?e.jsx(Gt,{rows:s,columns:Math.max(4,rr.length||7)}):!a&&t.length===0&&!La?af():a&&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:Pn},children:[_n(),Wn(),qn(),e.jsx("div",{ref:Er,className:ja,children:e.jsx(qa.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:Ps,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:qt,minWidth:Fn},children:[e.jsx("div",{role:"rowgroup",style:C?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:zn()}),e.jsx("div",{role:"rowgroup",children:Array.from({length:s}).map((f,x)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:pt,borderBottom:`1px solid ${Te}`},children:[pr&&e.jsx("div",{role:"cell",className:`${D?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Te}`,borderRight:`1px solid ${Te}`}},"select-cell"),rr.map((z,N)=>{const J=On[z.key],ue=J!==void 0,me=z.key===Pa;return e.jsx("div",{role:"cell","data-dt-column-key":z.key,className:D?"px-2 py-1.5":"px-3 py-2",style:ue?{position:"sticky",left:J,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:me?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Te}`:`inset 0 -1px 0 ${Te}`,borderRight:`1px solid ${Te}`}:{borderBottom:`1px solid ${Te}`,borderRight:`1px solid ${Te}`},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${Os(x,N)}%`,minWidth:32}})},z.key)})]},x))})]})})}),al()]}):!a&&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:Pn},children:[_n(),Wn(),qn(),e.jsx("div",{ref:Er,className:ja,children:e.jsx("div",{role:"table",className:"text-sm",style:{width:qt,minWidth:Fn},children:e.jsx("div",{role:"rowgroup",style:C?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:zn()})})}),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:Te,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(B.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:Pn},children:[_n(),Wn(),qn(),e.jsx("div",{ref:Er,className:ja,children:e.jsx(qa.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:Ps,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:qt,minWidth:Fn},children:[e.jsx("div",{role:"rowgroup",style:C?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:zn()}),e.jsx("div",{role:"rowgroup",children:Zs.map((f,x)=>{const z=n(f),N=rl(L==null?void 0:L(f)),J=x>0?rl(L==null?void 0:L(Zs[x-1])):null,ue=N&&N.key!==(J==null?void 0:J.key),me=pr&&E.has(z),ke=bt?(p==null?void 0:p(f))??!0:!1,We=ke&&Ys.has(z),_e=!!d||y&&ke,Ve=me&&M?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":x%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return e.jsxs(o.Fragment,{children:[ue&&e.jsx("div",{role:"row",className:`grid ${N.className??""}`,style:{gridTemplateColumns:pt},children:e.jsx("div",{role:"cell",className:D?"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 ${Te}`,borderRight:`1px solid ${Te}`},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:N.label}),N.description&&e.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:N.description})]})})})}),e.jsxs("div",{role:"row",onClick:_e?Se=>{const Ne=Se.target;if(!(Ne!=null&&Ne.closest('[data-dt-disable-row-click="true"]'))){if(y&&ke){Qs(z);return}d==null||d(f)}}:void 0,className:`grid transition-colors ${_e?"cursor-pointer":""} ${T?T(f):""}`,style:{gridTemplateColumns:pt,"--dt-row-bg":Ve,"--dt-sticky-bg":Ve,background:"var(--dt-row-bg)",borderBottom:`1px solid ${Te}`},onMouseEnter:Se=>{me||(Se.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),Se.currentTarget.style.setProperty("--dt-sticky-bg",rf))},onMouseLeave:Se=>{Se.currentTarget.style.setProperty("--dt-row-bg",Ve),Se.currentTarget.style.setProperty("--dt-sticky-bg",Ve)},children:[bt&&e.jsx("div",{role:"cell",className:`${D?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${Te}`,borderRight:`1px solid ${Te}`},"data-dt-disable-row-click":"true",children:ke&&e.jsx("button",{type:"button","aria-label":We?"Contraer fila":"Desplegar fila","aria-expanded":We,onClick:Se=>{Se.stopPropagation(),Qs(z)},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:We?e.jsx(B.HiChevronDown,{className:"h-4 w-4"}):e.jsx(B.HiChevronRight,{className:"h-4 w-4"})})}),pr&&e.jsx("div",{role:"cell",className:`${D?"px-2 py-1.5":"px-3 py-2"} w-10`,style:Oa?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${Te}`}:{borderBottom:`1px solid ${Te}`,borderRight:`1px solid ${Te}`},onClick:Se=>{Se.stopPropagation(),h(z)},children:e.jsx(Xt,{size:"sm",checked:me,"aria-label":"Seleccionar fila",containerClassName:"items-center",className:"cursor-pointer",onClick:Se=>Se.stopPropagation(),onChange:()=>h(z)})}),rr.map(Se=>{const Ne=On[Se.key],Ce=Ne!==void 0,ve=Se.key===Pa,he=Dr(Se);return e.jsx("div",{role:"cell","data-dt-column-key":Se.key,"data-dt-disable-row-click":Se.disableRowClick||he?"true":void 0,className:`${he?"px-2 py-1.5 text-center":`${D?"px-2 py-1.5":"px-3 py-2"} ${Js(Se.align)}`} ${oi} ${Se.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...Ce?{position:"sticky",left:Ne,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:ve?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Te}`:`inset 0 -1px 0 ${Te}`,borderRight:`1px solid ${Te}`}:{borderBottom:`1px solid ${Te}`,borderRight:`1px solid ${Te}`}},children:e.jsx(co,{children:e.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:Se.cell(f)})})},Se.key)})]}),We&&u&&e.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:pt},children:e.jsx("div",{role:"cell",className:D?"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 ${Te}`},children:u(f)})})]},z)})})]})})}),al()]})}const pi={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 mi(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 n=pi[t.preset];if(!n.pattern.test(r))return t.message??n.message}return t.pattern&&!t.pattern.test(r)?t.message??"Formato inválido":null}const hi=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function gi({initialValue:r,type:t,mask:n,onCommit:a,onCancel:s}){const[l,i]=o.useState(r),c=o.useRef(null),d=(n==null?void 0:n.preset)==="date",u=d?"date":t==="number"?"number":"text";return o.useEffect(()=>{var p,b;(p=c.current)==null||p.focus(),d||(b=c.current)==null||b.select()},[d]),e.jsx("input",{ref:c,type:u,value:l,maxLength:n==null?void 0:n.maxLength,onChange:p=>i(p.target.value),onBlur:()=>s(),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),a(l)),p.key==="Escape"&&(p.preventDefault(),s()),(n==null?void 0:n.preset)==="integer"&&!p.ctrlKey&&!p.metaKey&&!hi.has(p.key)&&!/^[\d-]$/.test(p.key)&&p.preventDefault()},onClick:p=>p.stopPropagation(),className:"w-full min-w-0 border-0 bg-transparent p-0 text-sm text-[var(--text-main)] outline-none"})}function vi({initialValue:r,options:t,loading:n,onCommit:a,onCancel:s}){const l=o.useRef(null);return o.useEffect(()=>{if(n)return;const i=setTimeout(()=>{var c,d;(d=(c=l.current)==null?void 0:c.querySelector("button"))==null||d.click()},0);return()=>clearTimeout(i)},[n]),e.jsx("div",{ref:l,className:"w-full",tabIndex:-1,onKeyDown:i=>{i.key==="Escape"&&(i.stopPropagation(),s())},children:e.jsx(Ar,{value:r,onChange:i=>{a(i)},options:t,disabled:n,placeholder:n?"Cargando…":"Seleccionar…",triggerVariant:"ghost",height:30,padding:"0 6px",minOptionsForSearch:1,className:"w-full"})})}const xi={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},ra={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function yi({columns:r,data:t,getRowId:n,onCellUpdate:a,readOnly:s=!1,...l}){const[i,c]=o.useState(t),d=o.useRef(null);o.useEffect(()=>{d.current||c(t)},[t]);const[u,p]=o.useState(null);d.current=u;const[b,m]=o.useState(null),v=o.useRef(null);v.current=b;const[y,E]=o.useState({}),[h,$]=o.useState(null),M=o.useRef(null);M.current=h;const[T,L]=o.useState({}),[C,k]=o.useState({}),V=o.useRef(new Set),A=o.useRef(null);o.useEffect(()=>{var H;const I=document.activeElement;(!I||I===document.body)&&((H=A.current)==null||H.focus({preventScroll:!0}))},[]);const K=r.map(I=>{var H,oe,g;return`${I.key}:${((g=(oe=(H=I.editable)==null?void 0:H.select)==null?void 0:oe.options)==null?void 0:g.length)??-1}`}).join("|");o.useEffect(()=>{r.forEach(I=>{var g,O;const H=(O=(g=I.editable)==null?void 0:g.select)==null?void 0:O.options;if(!H)return;const oe=T[I.key];(!V.current.has(I.key)||(oe==null?void 0:oe.length)===0&&H.length>0)&&(V.current.add(I.key),L(R=>({...R,[I.key]:H})))})},[K]);const W=o.useCallback(async(I,H)=>{if(V.current.has(I))return;V.current.add(I);const{url:oe,fetchOptions:g}=H.select??{};if(!(!oe&&!g)){k(O=>({...O,[I]:!0}));try{let O=[];if(g)O=await g();else if(oe){const R=await fetch(oe);if(!R.ok)throw new Error("fetch failed");O=await R.json()}L(R=>({...R,[I]:O}))}catch{L(O=>({...O,[I]:[]}))}finally{k(O=>({...O,[I]:!1}))}}},[]),G=o.useRef(i);G.current=i;const w=o.useRef(a);w.current=a;const Q=o.useRef(n);Q.current=n;const _=o.useRef(r);_.current=r;const P=o.useRef(s);P.current=s,o.useEffect(()=>{if(r.length>0&&t.length>0){const I=r.find(H=>H.selectable!==!1);I&&m({rowId:n(t[0]),colKey:I.key})}},[]),o.useEffect(()=>{if(!b)return;const I=A.current;if(!I)return;const H=I.querySelector(`[data-cell-id="${b.rowId}:${b.colKey}"]`);if(!H)return;const oe=I.querySelector('[role="rowgroup"]');H.style.scrollMarginTop=`${(oe==null?void 0:oe.offsetHeight)??0}px`;const g=I.querySelector('[role="row"]');let O=0;g&&g.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(R=>{R.style.position==="sticky"&&R.style.left!==""&&(O=Math.max(O,parseFloat(R.style.left)+R.offsetWidth))}),H.style.scrollMarginLeft=`${O}px`,H.scrollIntoView({block:"nearest",inline:"nearest"})},[b]);const ne=o.useCallback(I=>{var O;const H=_.current,oe=new Set,g=[];(O=A.current)==null||O.querySelectorAll("[data-cell-id]").forEach(R=>{const se=R.dataset.cellId.split(":")[0];oe.has(se)||(oe.add(se),g.push(se))}),m(R=>{if(!R)return R;const se=H.findIndex(te=>te.key===R.colKey),Z=g.indexOf(R.rowId);let X=se,S=Z;if(I==="up")S=Math.max(0,Z-1);else if(I==="down")S=Math.min(g.length-1,Z+1);else if(I==="left"){let te=se-1;for(;te>=0&&H[te].selectable===!1;)te--;te>=0&&(X=te)}else if(I==="right"){let te=se+1;for(;te<H.length&&H[te].selectable===!1;)te++;te<H.length&&(X=te)}return X===se&&S===Z?R:{rowId:g[S],colKey:H[X].key}})},[]),Y=o.useCallback((I=!0)=>{const H=d.current;p(null),H&&m(H),I&&setTimeout(()=>{var oe;return(oe=A.current)==null?void 0:oe.focus({preventScroll:!0})},0)},[]),D=o.useCallback(async(I,H,oe)=>{var ie;const g=_.current.find(ge=>ge.key===H);if(!(g!=null&&g.editable))return;const{field:O,type:R,mask:se,validate:Z}=g.editable,X=R==="number"?oe===""?null:Number(oe):oe;if(se){const ge=mi(oe,se);if(ge){E(we=>({...we,[`${I}:${H}`]:ge}));return}}if(Z){const ge=Z(X);if(ge){E(we=>({...we,[`${I}:${H}`]:ge}));return}}const S=Q.current,te=G.current.find(ge=>S(ge)===I);if(!te)return;const F=te[O];p(null),E(ge=>{const we={...ge};return delete we[`${I}:${H}`],we});const ae=G.current,q=ae.findIndex(ge=>S(ge)===I),ce=ae[Math.min(ae.length-1,q+1)];if(m({rowId:S(ce),colKey:H}),setTimeout(()=>{var we,Le;const ge=document.activeElement;(!ge||ge===document.body||(we=A.current)!=null&&we.contains(ge))&&((Le=A.current)==null||Le.focus({preventScroll:!0}))},0),String(F??"")===String(X??""))return;const Ee={...te,[O]:X};c(ge=>ge.map(we=>S(we)===I?Ee:we)),$({rowId:I,colKey:H});try{await((ie=w.current)==null?void 0:ie.call(w,{row:te,rowId:I,field:O,oldValue:F,newValue:X}))}catch{c(ge=>ge.map(we=>S(we)===I?te:we)),E(ge=>({...ge,[`${I}:${H}`]:"Error al guardar. Intenta de nuevo."}))}finally{$(null)}},[]),re=o.useCallback(I=>{if(M.current){I.preventDefault();return}if(d.current)return;const H=v.current;if(!(!H||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(I.key)))switch(I.preventDefault(),I.key){case"ArrowUp":ne("up");break;case"ArrowDown":ne("down");break;case"ArrowLeft":ne("left");break;case"ArrowRight":ne("right");break;case"Tab":ne(I.shiftKey?"left":"right");break;case"Enter":{const g=_.current.find(O=>O.key===H.colKey);g!=null&&g.editable&&!P.current?(p(H),g.editable.type==="select"&&!V.current.has(H.colKey)&&W(H.colKey,g.editable)):ne("down");break}}},[ne,W]),le=o.useMemo(()=>r.map(I=>{if(!I.editable||s){const oe={...I};if(delete oe.editable,delete oe.selectable,I.selectable===!1)return{...oe,disableRowClick:!0};const g=oe.cell;return{...oe,className:`relative ${oe.className??""}`.trim(),disableRowClick:!0,cell:O=>{const R=n(O),se=(b==null?void 0:b.rowId)===R&&(b==null?void 0:b.colKey)===I.key;return e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-cell-id":`${R}:${I.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var Z;M.current||(m({rowId:R,colKey:I.key}),(Z=A.current)==null||Z.focus({preventScroll:!0}))}}),se&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:ra}),e.jsx("span",{className:"relative z-0 pointer-events-none",children:g(O)})]})}}}const H=I.editable;return{...I,className:`relative ${I.className??""}`.trim(),disableRowClick:!0,cell:oe=>{const g=n(oe),O=I.key,R=(u==null?void 0:u.rowId)===g&&(u==null?void 0:u.colKey)===O,se=(b==null?void 0:b.rowId)===g&&(b==null?void 0:b.colKey)===O,Z=y[`${g}:${O}`],X=(h==null?void 0:h.rowId)===g&&(h==null?void 0:h.colKey)===O,S=oe[H.field],te=String(S??""),F=()=>{var q;M.current||(m({rowId:g,colKey:O}),p({rowId:g,colKey:O}),(q=A.current)==null||q.focus({preventScroll:!0}),H.type==="select"&&!V.current.has(O)&&W(O,H))};if(R){const q=H.type==="select"?e.jsx(vi,{initialValue:te,options:T[O]??[],loading:C[O]??!1,onCommit:ce=>D(g,O,ce),onCancel:Y}):e.jsx(gi,{initialValue:te,type:H.type??"text",mask:H.mask,onCommit:ce=>D(g,O,ce),onCancel:Y});return e.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:xi,onClick:ce=>ce.stopPropagation(),children:q})}const ae=I.cell(oe);return e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-cell-id":`${g}:${O}`,className:`peer absolute inset-0 z-10 ${X?"cursor-wait":"cursor-pointer"}`,onClick:F}),se&&!X&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:ra}),X&&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:ra,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:Z?e.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[e.jsx(B.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate text-xs",children:Z})]}):e.jsx("span",{className:"truncate",children:ae})}),!X&&e.jsx(B.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,u,b,h,y,T,C,n,D,Y,W]);return e.jsx("div",{ref:A,tabIndex:0,onKeyDown:re,onBlur:I=>{var H;(H=A.current)!=null&&H.contains(I.relatedTarget)||setTimeout(()=>{var g,O;const oe=document.activeElement;oe&&((g=oe.closest)!=null&&g.call(oe,"[data-bonsaif-select-dropdown]"))||(O=A.current)!=null&&O.contains(oe)||Y(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:e.jsx(uo,{...l,columns:le,data:i,getRowId:n})})}function Ct(r){return r?new Date(`${r}T12:00:00`):void 0}function fo(r){return r.toISOString().slice(0,10)}function wi({calendarMonth:r,displayIndex:t}){const{previousMonth:n,nextMonth:a,goToMonth:s,months:l,labels:i,formatters:c}=Ua.useDayPicker(),d=!!n&&t===0,u=!!a&&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(n),onClick:()=>n&&s(n),disabled:!d,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:d?1:.45,cursor:d?"pointer":"not-allowed"},children:e.jsx(B.HiChevronLeft,{size:16})}),e.jsx("button",{type:"button","aria-label":i.labelNext(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(B.HiChevronRight,{size:16})})]})}function Ni(r){return r.charAt(0).toUpperCase()+r.slice(1)}function ki({startDate:r,endDate:t,onChange:n,minDate:a,viewMonth:s,numberOfMonths:l=1,showSummary:i=!0,startLabel:c="Inicio",endLabel:d="Regreso"}){const u={from:Ct(r),to:Ct(t)},p=Ct(a),[b,m]=o.useState(Ct(s||r));return o.useEffect(()=>{m(Ct(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(Ua.DayPicker,{mode:"range",selected:u,month:b,onMonthChange:m,onSelect:v=>{const y=v!=null&&v.from?fo(v.from):r,E=v!=null&&v.to?fo(v.to):"";n({startDate:y,endDate:E})},numberOfMonths:l,hideNavigation:!0,disabled:p?{before:p}:void 0,showOutsideDays:!1,components:{MonthCaption:wi},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:v=>Ni(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(v)),formatWeekdayName:v=>new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(v)},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:[d,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:t})]})]})]})}const Si="bonsaif-ui:hide-tooltips";function bo(){window.dispatchEvent(new CustomEvent(Si))}function Ci(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Ei({trigger:r,items:t,align:n="end",width:a=220,disabled:s=!1,className:l="",menuClassName:i="",onOpenChange:c}){const[d,u]=o.useState(!1),[p,b]=o.useState(!1),[m,v]=o.useState({}),y=o.useRef(null),E=o.useRef(null),h=o.useCallback(C=>{u(C),c==null||c(C)},[c]),$=o.useCallback(()=>{const C=y.current;if(!C)return;const k=C.getBoundingClientRect(),V=typeof a=="number"?a:k.width,A=typeof a=="number"?a:Math.max(k.width,180),K=n==="end"?Math.max(8,k.right-A):Math.min(k.left,window.innerWidth-A-8),W=window.innerHeight-k.bottom,G=W<240&&k.top>W?void 0:k.bottom+6,w=G===void 0?window.innerHeight-k.top+6:void 0;v({position:"fixed",zIndex:9999,left:K,top:G,bottom:w,width:Ci(typeof a=="number"?V:a)})},[n,a]);o.useEffect(()=>b(!0),[]),o.useEffect(()=>{if(!d)return;$();const C=V=>{var K,W;const A=V.target;!((K=y.current)!=null&&K.contains(A))&&!((W=E.current)!=null&&W.contains(A))&&h(!1)},k=V=>{V.key==="Escape"&&h(!1)};return document.addEventListener("mousedown",C),window.addEventListener("keydown",k),window.addEventListener("resize",$),window.addEventListener("scroll",$,!0),()=>{document.removeEventListener("mousedown",C),window.removeEventListener("keydown",k),window.removeEventListener("resize",$),window.removeEventListener("scroll",$,!0)}},[d,h,$]);const M=C=>{s||(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),h(!d))},T=o.isValidElement(r)?o.cloneElement(r,{onClick:()=>{s||(bo(),h(!d))}}):r,L=d?e.jsx("div",{ref:E,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(C=>e.jsxs("div",{children:[C.separatorBefore&&e.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),e.jsxs("button",{type:"button",role:"menuitem",disabled:C.disabled,onClick:()=>{var k;C.disabled||(bo(),(k=C.onSelect)==null||k.call(C),h(!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:C.danger?"var(--danger)":"var(--text-main)"},children:[C.icon&&e.jsx("span",{className:"mt-0.5 shrink-0",children:C.icon}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm font-medium",children:C.label}),C.description&&e.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:C.description})]})]})]},C.id))}):null;return e.jsxs("span",{ref:y,role:"button",tabIndex:s?-1:0,"aria-haspopup":"menu","aria-expanded":d,onKeyDown:M,className:`inline-flex ${s?"pointer-events-none opacity-60":""} ${l}`,children:[T,p&&L?tr.createPortal(L,document.body):null]})}const Mi=180,po="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Ti({open:r,onClose:t,title:n,subtitle:a,leadingIcon:s,confirmLabel:l="Guardar",onConfirm:i,loading:c=!1,confirmDisabled:d=!1,headerActions:u,bodyClassName:p="flex-1 overflow-y-auto px-6 py-5",width:b=440,hasUnsavedChanges:m=!1,unsavedChangesTitle:v="Descartar cambios",unsavedChangesDescription:y="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:E="Descartar",unsavedChangesCancelLabel:h="Seguir editando",onDiscardChanges:$,disabled:M=!1,disabledMessage:T,children:L}){const[C,k]=o.useState(!1),[V,A]=o.useState(!1),[K,W]=o.useState(!1),G=o.useCallback(()=>{A(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>W(!0))})},[]),w=o.useCallback(()=>{W(!1),window.setTimeout(()=>A(!1),Mi)},[]),Q=o.useCallback(()=>{if(!M){if(m){G();return}t()}},[M,m,t,G]),_=o.useCallback(()=>{W(!1),A(!1),$==null||$(),t()},[t,$]);if(o.useEffect(()=>{k(!0)},[]),o.useEffect(()=>(document.body.style.overflow=r?"hidden":"",r||(W(!1),A(!1)),()=>{document.body.style.overflow=""}),[r]),o.useEffect(()=>{if(!r)return;const ne=Y=>{if(Y.key==="Escape"&&!M){if(V){w();return}Q()}};return window.addEventListener("keydown",ne),()=>window.removeEventListener("keydown",ne)},[w,M,V,r,Q]),!C)return null;const P=T!==void 0?T:c?"Guardando…":null;return tr.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 ${po}`,onClick:Q}),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:Q,title:"Cerrar",disabled:M,children:e.jsx(B.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:n}),a&&e.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:a})]})]}),(u||i)&&e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[u,i&&e.jsxs(e.Fragment,{children:[e.jsx(He,{variant:"secondary",size:"sm",onClick:Q,disabled:M,style:{background:"var(--bg-input)"},children:"Cancelar"}),e.jsx(He,{variant:"primary",size:"sm",icon:e.jsx(ll.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:d||M,title:l})]})]})]}),e.jsx("div",{"data-drawer-scroll":"true",className:p,children:L}),M&&e.jsx("div",{className:"absolute inset-0 z-[1002] flex cursor-not-allowed items-center justify-center p-6",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 72%, transparent)",backdropFilter:"blur(3px)"},role:"status","aria-live":"polite","aria-busy":"true",children:P?e.jsxs("div",{className:"flex max-w-xs 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)]","aria-hidden":!0}),e.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:P})]}):null})]}),V&&e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":v,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[e.jsx("div",{className:`absolute inset-0 ${po} transition-opacity duration-200 ease-out ${K?"opacity-100":"opacity-0"}`,onClick:w}),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 ${K?"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:w,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":h,children:e.jsx(B.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(B.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:v}),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(He,{variant:"secondary",onClick:w,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:h}),e.jsx(He,{variant:"secondary",onClick:_,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:E})]})]})]})]}),document.body)}const Li=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,$i=/^\+?[0-9\s().-]+$/,Ai=7,Di=15;function lr(r){return r==null||String(r).trim()===""}function mo(r){return typeof r=="number"?r:typeof r=="string"&&r.trim()!==""?Number(r):Number.NaN}function ta(r){return lr(r)?!1:Li.test(String(r))}function na(r){if(lr(r))return!1;const t=String(r),n=t.replace(/\D/g,"");return $i.test(t)&&n.length>=Ai&&n.length<=Di}function Ii(r="Este campo es requerido."){return t=>lr(t)?r:void 0}function Hi(r="Ingresa un correo valido."){return t=>lr(t)||ta(t)?void 0:r}function Oi(r="Ingresa un telefono valido."){return t=>lr(t)||na(t)?void 0:r}function Bi(r,t){return n=>lr(n)||String(n).length>=r?void 0:t??`Debe tener al menos ${r} caracteres.`}function Pi(r,t){return n=>lr(n)||String(n).length<=r?void 0:t??`Debe tener ${r} caracteres o menos.`}function Fi(r,t){return n=>{if(lr(n))return;const a=mo(n);return Number.isFinite(a)&&a>=r?void 0:t??`Debe ser mayor o igual a ${r}.`}}function zi(r,t){return n=>{if(lr(n))return;const a=mo(n);return Number.isFinite(a)&&a<=r?void 0:t??`Debe ser menor o igual a ${r}.`}}function _i(r,t="El formato no es valido."){return n=>lr(n)||r.test(String(n))?void 0:t}function ji(r,t){const n={};for(const a of Object.keys(t)){const s=t[a];if(!s)continue;const l=Array.isArray(s)?s:[s];for(const i of l){const c=i(r[a],r);if(c){n[a]=c;break}}}return{valid:Object.keys(n).length===0,errors:n}}var ho={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},go=o.createContext&&o.createContext(ho),Wi=["attr","size","title"];function qi(r,t){if(r==null)return{};var n,a,s=Ui(r,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(r);for(a=0;a<l.length;a++)n=l[a],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(r,n)&&(s[n]=r[n])}return s}function Ui(r,t){if(r==null)return{};var n={};for(var a in r)if({}.hasOwnProperty.call(r,a)){if(t.indexOf(a)!==-1)continue;n[a]=r[a]}return n}function rn(){return rn=Object.assign?Object.assign.bind():function(r){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)({}).hasOwnProperty.call(n,a)&&(r[a]=n[a])}return r},rn.apply(null,arguments)}function vo(r,t){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);t&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),n.push.apply(n,a)}return n}function tn(r){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?vo(Object(n),!0).forEach(function(a){Vi(r,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):vo(Object(n)).forEach(function(a){Object.defineProperty(r,a,Object.getOwnPropertyDescriptor(n,a))})}return r}function Vi(r,t,n){return(t=Ki(t))in r?Object.defineProperty(r,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[t]=n,r}function Ki(r){var t=Gi(r,"string");return typeof t=="symbol"?t:t+""}function Gi(r,t){if(typeof r!="object"||!r)return r;var n=r[Symbol.toPrimitive];if(n!==void 0){var a=n.call(r,t);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function xo(r){return r&&r.map((t,n)=>o.createElement(t.tag,tn({key:n},t.attr),xo(t.child)))}function aa(r){return t=>o.createElement(Xi,rn({attr:tn({},r.attr)},t),xo(r.child))}function Xi(r){var t=n=>{var{attr:a,size:s,title:l}=r,i=qi(r,Wi),c=s||n.size||"1em",d;return n.className&&(d=n.className),r.className&&(d=(d?d+" ":"")+r.className),o.createElement("svg",rn({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,i,{className:d,style:tn(tn({color:r.color||n.color},n.style),r.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),l&&o.createElement("title",null,l),r.children)};return go!==void 0?o.createElement(go.Consumer,null,n=>t(n)):t(ho)}function yo(r){return aa({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 Yi(r){return aa({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 Zi(r){return aa({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 Zr({content:r,ariaLabel:t="Más información",className:n=""}){return e.jsx($r,{as:"span",content:r,className:`inline-flex shrink-0 align-middle text-[var(--text-muted)] outline-none transition-colors hover:text-[var(--primary)] focus-visible:text-[var(--primary)] ${n}`,children:e.jsx("span",{tabIndex:0,role:"img","aria-label":t,className:"inline-flex items-center justify-center outline-none",children:e.jsx(B.HiInformationCircle,{className:"h-3.5 w-3.5"})})})}function Qr({error:r,helperText:t,helperDisplay:n="inline"}){return r?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:r}):t&&n!=="tooltip"?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:t}):null}function nn({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 oa({label:r,containerClassName:t="",helperText:n,helperDisplay:a="inline",error:s,errorDisplay:l="inline",errorTooltipLabel:i="Error de validacion",labelAction:c,floatingLabel:d=!1,showPasswordToggle:u=!0,nativeValidation:p=!1,className:b="",required:m,...v}){const[y,E]=o.useState(()=>!!v.autoFocus),[h,$]=o.useState(!1),M=v.type==="password"&&u,T=M&&h?"text":v.type,L=!!s,C=L&&l!=="tooltip",k=L&&l!=="inline",V=!!n&&a==="tooltip"&&!C,A=p?m:void 0,K=L?"border-[var(--danger)] focus:border-[var(--danger)]":"",W=k?M?"pr-20":"pr-10":M?"pr-10":"",G=v.value!==void 0?String(v.value).length>0:v.defaultValue!==void 0&&String(v.defaultValue).length>0,w=y||G,Q={top:w?7:12,color:y?"var(--primary)":"var(--text-muted)",fontSize:w?10:13,fontWeight:w?600:400,textTransform:w?"uppercase":"none"},_=re=>{var le;E(!0),(le=v.onFocus)==null||le.call(v,re)},P=re=>{var le;E(!1),(le=v.onBlur)==null||le.call(v,re)},ne=M?e.jsxs("button",{type:"button","aria-label":h?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":h,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:()=>$(re=>!re),children:[e.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${h?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:e.jsx(Yi,{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 ${h?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:e.jsx(Zi,{className:"h-[18px] w-[18px]"})})]}):null,Y=k?e.jsx($r,{as:"span",content:s,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)] ${M?"right-10":"right-2.5"}`,children:e.jsx("span",{tabIndex:0,role:"img","aria-label":i,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(yo,{className:"h-[18px] w-[18px]"})})}):null,D=e.jsx(Qr,{error:C?s:void 0,helperText:n,helperDisplay:a});return d?e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"relative block",children:[e.jsx(nn,{...v,type:T,required:A,placeholder:" ","aria-invalid":L||v["aria-invalid"],"data-has-value":G?"true":void 0,className:`h-11 w-full pt-5 ${W} ${K} ${b}`,onFocus:_,onBlur:P}),e.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:Q,children:[r,m&&e.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),c&&e.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:w?7:12},children:c}),Y,ne]}),D]}):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}),m&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),V?e.jsx(Zr,{content:n}):null,c&&e.jsx("span",{className:"ml-auto normal-case",children:c})]}),M?e.jsxs("span",{className:"relative block",children:[e.jsx(nn,{...v,type:T,required:A,"aria-invalid":L||v["aria-invalid"],className:`w-full ${W} ${K} ${b}`,onFocus:_,onBlur:P}),Y,ne]}):e.jsxs("span",{className:"relative block",children:[e.jsx(nn,{...v,required:A,"aria-invalid":L||v["aria-invalid"],className:`w-full ${W} ${K} ${b}`}),Y]}),D]})}function wo(r){return r==null?"":String(r)}function Qi({autoComplete:r="email",inputMode:t="email",validate:n=!0,invalidMessage:a="Ingresa un correo valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:d,...u}){const[p,b]=o.useState(()=>wo(c)),m=i!==void 0?wo(i):p,v=n&&m.length>0&&!ta(m)?a:void 0,y=E=>{i===void 0&&b(E.currentTarget.value),d==null||d(E)};return e.jsx(oa,{...u,value:i,defaultValue:c,type:"text",inputMode:t,autoComplete:r,error:l??v,errorDisplay:s,onChange:y})}const Ji={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function Ri({title:r="Sin resultados",description:t,icon:n=e.jsx(B.HiInbox,{className:"h-5 w-5"}),action:a,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 ${Ji[l]} ${i}`,children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[n&&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:n}),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})]}),(a||s)&&e.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[s,a]})]})})}const ec={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function rc(r){if(r===0)return"0 B";const t=["B","KB","MB","GB"],n=Math.min(Math.floor(Math.log(r)/Math.log(1024)),t.length-1),a=r/1024**n;return`${a>=10||n===0?a.toFixed(0):a.toFixed(1)} ${t[n]}`}function No(r,t){return t?t.split(",").map(n=>n.trim().toLowerCase()).filter(Boolean).some(n=>{const a=r.name.toLowerCase(),s=r.type.toLowerCase();return n.startsWith(".")?a.endsWith(n):n.endsWith("/*")?s.startsWith(n.slice(0,-1)):s===n}):!0}function tc(r,t,n){return t?n===void 0?r:r.slice(0,Math.max(0,n)):r.slice(0,1)}function nc({label:r,helperText:t,helperDisplay:n="inline",error:a,labelAction:s,value:l,defaultValue:i=[],onFilesChange:c,onRejectedFiles:d,multiple:u=!1,maxFiles:p,appendFiles:b=!1,showFileList:m=!0,clearable:v=!0,browseLabel:y="Buscar archivos",dropLabel:E="Suelta los archivos aqui",emptyLabel:h="Arrastra y suelta archivos",emptyDescription:$="o haz click para buscarlos en tu equipo",selectedLabel:M="Archivos seleccionados",size:T="md",containerClassName:L="",dropzoneClassName:C="",fileListClassName:k="",className:V="",id:A,accept:K,disabled:W,required:G,...w}){const Q=o.useId(),_=A??Q,P=o.useRef(null),[ne,Y]=o.useState(!1),[D,re]=o.useState(i),le=l??D,I=!!a,H=!!t&&n==="tooltip"&&!I,oe=v&&le.length>0&&!W,g=(q,ce)=>{l===void 0&&re(q),c==null||c(q,ce)},O=(q,ce)=>{const Ee=q.filter(Le=>No(Le,K)),ie=q.filter(Le=>!No(Le,K)),ge=b?[...le,...Ee]:Ee,we=tc(ge,u,p);ie.length>0&&(d==null||d(ie)),g(we,ce)},R=()=>{var q;W||(q=P.current)==null||q.click()},se=q=>{O(Array.from(q.target.files??[]),q),q.target.value=""},Z=q=>{q.preventDefault(),W||Y(!0)},X=q=>{q.currentTarget.contains(q.relatedTarget)||Y(!1)},S=q=>{q.preventDefault(),Y(!1),!W&&O(Array.from(q.dataTransfer.files),q)},te=q=>{q.key!=="Enter"&&q.key!==" "||(q.preventDefault(),R())},F=q=>{g(le.filter((ce,Ee)=>Ee!==q))},ae=()=>{g([])};return e.jsxs("div",{className:`flex flex-col gap-2 ${L}`,children:[(r||s||H)&&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}),G&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),H?e.jsx(Zr,{content:t}):null,s&&e.jsx("span",{className:"ml-auto normal-case",children:s})]}),e.jsx("input",{...w,ref:P,id:_,type:"file",accept:K,multiple:u,disabled:W,required:G&&le.length===0,"aria-invalid":I||w["aria-invalid"],className:"sr-only",onChange:se}),e.jsxs("div",{role:"button",tabIndex:W?-1:0,"aria-controls":_,"aria-disabled":W||void 0,"aria-invalid":I||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)] ${ec[T]} ${ne?"border-[var(--primary)] bg-[var(--bg-input)]":I?"border-[var(--danger)]":"border-[var(--border)]"} ${W?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${C} ${V}`,onClick:R,onDragOver:Z,onDragLeave:X,onDrop:S,onKeyDown:te,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(B.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:ne?E:h}),$&&e.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:$})]}),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})]}),m&&le.length>0&&e.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${k}`,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:M}),oe&&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:ae,children:e.jsx(B.HiTrash,{className:"h-4 w-4"})})]}),e.jsx("ul",{className:"divide-y divide-[var(--border)]",children:le.map((q,ce)=>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(B.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:q.name}),e.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:rc(q.size)})]}),!W&&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 ${q.name}`,onClick:()=>F(ce),children:e.jsx(B.HiXMark,{className:"h-4 w-4"})})]},`${q.name}-${q.lastModified}-${ce}`))})]}),e.jsx(Qr,{error:a,helperText:t,helperDisplay:n})]})}const ac=[{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 oc({fields:r,title:t="Layout",fieldTypes:n=ac,saveLabel:a="Guardar",allowAddField:s=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:d,onChange:u}){const[p,b]=o.useState(()=>r.map(T=>({key:!1,type:"",...T}))),[m,v]=o.useState(""),[y,E]=o.useState(""),h=o.useCallback((T,L)=>{b(C=>{const k=C.map((V,A)=>A===T?{...V,...L}:V);return u==null||u(k),k})},[u]),$=o.useCallback(()=>{d==null||d(p)},[p,d]),M=o.useCallback(()=>{var k;const T=m.trim();if(!T){E("Ingresa un nombre de campo.");return}if(p.some(V=>V.name.toLowerCase()===T.toLowerCase())){E("Ese campo ya existe en el arreglo.");return}const C={name:T,key:!1,type:((k=n[0])==null?void 0:k.value)??""};b(V=>{const A=[...V,C];return u==null||u(A),A}),v(""),E("")},[n,p,m,u]);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:[p.map((T,L)=>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(Xt,{size:"sm",checked:T.key??!1,onChange:C=>h(L,{key:C.target.checked}),"aria-label":`${T.name} es clave`})}),e.jsx(Ar,{value:T.type??"",onChange:C=>h(L,{type:C}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${T.name}`})]},T.name)),p.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=>{v(T.currentTarget.value),y&&E("")},onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),M())},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:M,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(He,{variant:"primary",onClick:$,disabled:c,loading:c,children:a})})]})})]})}function sa({label:r,children:t,helperText:n,helperDisplay:a="inline",error:s,labelAction:l,required:i=!1,className:c="",contentClassName:d=""}){const u=!!n&&a==="tooltip"&&!s;return e.jsxs("label",{className:`flex flex-col gap-2 ${c}`,children:[(r||l||u)&&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}),i&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),u?e.jsx(Zr,{content:n}):null,l&&e.jsx("span",{className:"ml-auto normal-case",children:l})]}),e.jsx("span",{className:`block ${d}`,children:t}),e.jsx(Qr,{error:s,helperText:n,helperDisplay:a})]})}function ko(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function So(r,t){if(r.length!==t.length)return!1;const n=new Set(t);return r.every(a=>n.has(a))}function la(r){return r.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function sc(r,t){if(!t)return!0;const n=la(t);return la(r.label).includes(n)||!!(r.sublabel&&la(r.sublabel).includes(n))}function lc({value:r,onChange:t,options:n,placeholder:a="Seleccionar…",disabled:s=!1,className:l="",style:i,height:c=40,padding:d="6px 10px",searchable:u=!0,minOptionsForSearch:p=6,maxVisibleValues:b=2,truncateSelectedValues:m=!0,emptyText:v="Sin resultados",clearLabel:y="Limpiar seleccion",pruneMissingValues:E=!0}){const[h,$]=o.useState(!1),[M,T]=o.useState(""),[L,C]=o.useState(0),[k,V]=o.useState(!1),[A,K]=o.useState({}),W=o.useRef(null),G=o.useRef(null),w=o.useRef(null),Q=o.useRef(null),_=u&&n.length>=p,P=o.useMemo(()=>new Set(r),[r]),ne=o.useMemo(()=>{const S=new Map;for(const te of n)S.set(te.value,te);return S},[n]),Y=o.useMemo(()=>{const S=[];for(const te of r){const F=ne.get(te);F&&S.push(F)}return S},[ne,r]),D=b==="all"?Y.length:b,re=Y.slice(0,D),le=Math.max(0,Y.length-re.length),I=o.useMemo(()=>{const S=M.trim();return!_||!S?n:n.filter(te=>sc(te,S))},[n,M,_]),H=o.useCallback(()=>{const S=W.current;if(!S)return;const te=S.getBoundingClientRect(),F=_?304:244,ae=window.innerHeight-te.bottom,q=ae<F&&te.top>ae;K({position:"fixed",left:te.left,top:q?void 0:te.bottom+4,bottom:q?window.innerHeight-te.top+4:void 0,width:Math.max(te.width,240),zIndex:9999})},[_]),oe=o.useCallback(S=>{So(r,S)||t(S)},[t,r]),g=o.useCallback(S=>{const te=ne.get(S);if(te!=null&&te.disabled)return;const F=P.has(S)?r.filter(ae=>ae!==S):[...r,S];oe(F)},[oe,ne,r,P]),O=o.useCallback(()=>oe([]),[oe]),R=o.useCallback(()=>{$(!1),T(""),C(0)},[]);o.useEffect(()=>V(!0),[]);const se=o.useMemo(()=>n.map(S=>S.value).join("\0"),[n]);o.useEffect(()=>{if(!E||r.length===0||n.length===0)return;const S=new Set(n.map(F=>F.value)),te=r.filter(F=>S.has(F));So(r,te)||t(te)},[se]),o.useEffect(()=>{if(!h)return;function S(te){var ae,q;const F=te.target;!((ae=W.current)!=null&&ae.contains(F))&&!((q=G.current)!=null&&q.contains(F))&&R()}return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[R,h]),o.useEffect(()=>{h&&(C(0),H(),_&&setTimeout(()=>{var S;return(S=w.current)==null?void 0:S.focus()},0))},[h,_,H]),o.useEffect(()=>{if(h)return window.addEventListener("resize",H),window.addEventListener("scroll",H,!0),()=>{window.removeEventListener("resize",H),window.removeEventListener("scroll",H,!0)}},[h,H]),o.useEffect(()=>{if(I.length===0){C(0);return}C(S=>Math.min(S,I.length-1))},[I.length]),o.useEffect(()=>{if(L<0||!Q.current)return;const S=Q.current.children[L];S==null||S.scrollIntoView({block:"nearest"})},[L]);function Z(S){if(!s){if(!h){(S.key==="Enter"||S.key===" "||S.key==="ArrowDown")&&(S.preventDefault(),$(!0));return}if(S.key==="Escape"){S.preventDefault(),R();return}if(S.key==="ArrowDown"){if(S.preventDefault(),I.length===0)return;C(te=>Math.min(te+1,I.length-1));return}if(S.key==="ArrowUp"){S.preventDefault(),C(te=>Math.max(te-1,0));return}if(S.key==="Enter"&&I[L]&&!I[L].disabled){S.preventDefault(),g(I[L].value);return}S.key==="Backspace"&&!M&&r.length&&(S.preventDefault(),oe(r.slice(0,-1)))}}const X=e.jsxs("div",{ref:G,className:"overflow-hidden rounded-xl shadow-xl",style:{...A,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[_&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(B.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:w,value:M,onChange:S=>{T(S.target.value),C(0)},onKeyDown:S=>{(S.key==="ArrowDown"||S.key==="ArrowUp"||S.key==="Enter"||S.key==="Escape")&&(S.stopPropagation(),Z(S))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),M&&e.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:S=>{S.preventDefault(),T(""),C(0)},children:e.jsx(B.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:[Y.length," seleccionados",r.length>Y.length?` (${r.length-Y.length} no disponibles)`:""]}),e.jsx("button",{type:"button",onMouseDown:S=>{S.preventDefault(),O()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:y})]}),e.jsxs("ul",{ref:Q,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:_?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[I.map((S,te)=>{const F=te===L,ae=P.has(S.value);return e.jsxs("li",{role:"option","aria-selected":ae,onMouseDown:q=>{q.preventDefault(),!S.disabled&&g(S.value)},onMouseEnter:()=>!S.disabled&&C(te),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:F?"var(--bg-hover)":ae?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:S.disabled?"var(--text-muted)":"var(--text-main)",cursor:S.disabled?"not-allowed":"pointer",opacity:S.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(B.HiCheck,{className:"h-3 w-3"})}),S.color&&e.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:S.color}}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:S.label}),S.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:S.sublabel})]}),S.badge&&e.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:S.badge})]},S.value)}),I.length===0&&e.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:v})]})]});return e.jsxs("div",{ref:W,className:`relative ${l||"w-full"}`,style:i,onKeyDown:Z,children:[e.jsxs("button",{type:"button",disabled:s,onClick:()=>{s||(h?R():$(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:ko(c),padding:ko(d),background:"var(--bg-input)",color:Y.length?"var(--text-main)":"var(--text-muted)",border:h?"1px solid var(--primary)":"1px solid var(--border)",opacity:s?.5:1,cursor:s?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":h,children:[e.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:re.length?e.jsxs(e.Fragment,{children:[re.map(S=>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:[S.color&&e.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:S.color}}),e.jsx("span",{className:m?"truncate":"break-words",children:S.label}),e.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${S.label}`,onMouseDown:te=>{te.preventDefault(),te.stopPropagation(),g(S.value)},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(B.HiXMark,{className:"h-3 w-3"})})]},S.value)),le>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:["+",le]})]}):e.jsx("span",{className:"truncate",children:a})}),Y.length?e.jsx("span",{role:"button",tabIndex:-1,"aria-label":y,onMouseDown:S=>{S.preventDefault(),S.stopPropagation(),O()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(B.HiXMark,{className:"h-3.5 w-3.5"})}):e.jsx(B.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:h?"rotate(180deg)":"rotate(0deg)"}})]}),h&&k&&tr.createPortal(X,document.body)]})}function ic({inputMode:r="decimal",...t}){return e.jsx(oa,{...t,type:"number",inputMode:r})}function cc(r,t,n){const a=[],s=Math.max(2,r-n),l=Math.min(t-1,r+n);a.push(1),s>2&&a.push("...");for(let i=s;i<=l;i+=1)a.push(i);return l<t-1&&a.push("..."),t>1&&a.push(t),a}function dc({page:r,totalPages:t,onPageChange:n,disabled:a=!1,siblingCount:s=1,className:l=""}){const i=Math.max(1,t),c=Math.min(Math.max(1,r),i),d=cc(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:a||c<=1,onClick:()=>n(c-1),children:e.jsx(B.HiChevronLeft,{className:"h-4 w-4"})}),d.map((u,p)=>u==="..."?e.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${p}`):e.jsx("button",{type:"button","aria-current":u===c?"page":void 0,disabled:a,onClick:()=>n(u),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:u===c?"var(--primary)":"var(--border)",background:u===c?"var(--primary)":"var(--bg-card)",color:u===c?"var(--primary-fg)":"var(--text-secondary)"},children:u},u)),e.jsx(He,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:a||c>=i,onClick:()=>n(c+1),children:e.jsx(B.HiChevronRight,{className:"h-4 w-4"})})]})}const Co=[{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 Eo(r){return r==null?"":String(r)}function an(r){return r?r.startsWith("+")?r:`+${r}`:"+1"}function uc(r){return typeof r=="number"?`${r}px`:r}function fc({autoComplete:r="tel",inputMode:t="tel",validate:n=!0,invalidMessage:a="Ingresa un telefono valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:d,countryCode:u,defaultCountryCode:p="+1",onCountryCodeChange:b,allowedCountryCodes:m,countryCodeOptions:v,countryCodePlaceholder:y="Codigo",countryCodeClassName:E="",countryCodeWidth:h=84,onPhoneValueChange:$,label:M,containerClassName:T="",helperText:L,helperDisplay:C="inline",labelAction:k,className:V="",required:A,disabled:K,floatingLabel:W,showPasswordToggle:G,nativeValidation:w,errorTooltipLabel:Q="Error de validacion",..._}){var q;const[P,ne]=o.useState(()=>Eo(c)),[Y,D]=o.useState(()=>an(p)),re=o.useMemo(()=>{const ce=v??Co,Ee=m==null?void 0:m.map(an);return Ee!=null&&Ee.length?ce.filter(ie=>Ee.includes(ie.value)):ce},[m,v]),le=((q=re[0])==null?void 0:q.value)??"+1",I=re.some(ce=>ce.value===an(u??Y))?an(u??Y):le,H=i!==void 0?Eo(i):P,oe=`${I} ${H}`.trim(),g=n&&H.length>0&&!na(oe)?a:void 0,O=l??g,R=!!O,se=R&&s!=="tooltip",Z=R&&s!=="inline",X=!!L&&C==="tooltip"&&!se,S=R?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",te=ce=>{const Ee=ce.currentTarget.value;i===void 0&&ne(Ee),$==null||$(Ee,{countryCode:I,nationalNumber:Ee,fullNumber:`${I} ${Ee}`.trim()}),d==null||d(ce)},F=ce=>{u===void 0&&D(ce),b==null||b(ce),$==null||$(H,{countryCode:ce,nationalNumber:H,fullNumber:`${ce} ${H}`.trim()})},ae=Z?e.jsx($r,{as:"span",content:O,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":Q,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(yo,{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:M}),A&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),X?e.jsx(Zr,{content:L}):null,k&&e.jsx("span",{className:"ml-auto normal-case",children:k})]}),e.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${S}`,children:[e.jsx(Ar,{value:I,onChange:F,options:re,placeholder:y,disabled:K,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${E}`,style:{width:uc(h)},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",{..._,value:i,defaultValue:c,type:"tel",inputMode:t,autoComplete:r,disabled:K,required:void 0,"aria-label":_["aria-label"]??(typeof M=="string"?M:void 0),"aria-invalid":R||_["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 ${Z?"pr-10":""} ${V}`,onChange:te}),ae]})]}),e.jsx(Qr,{error:se?O:void 0,helperText:L,helperDisplay:C})]})}function bc({value:r,onChange:t,options:n,name:a,label:s,orientation:l="vertical",disabled:i=!1,className:c="",optionClassName:d=""}){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:n.map(u=>{const p=u.value===r,b=i||u.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)]"} ${d}`,style:{borderColor:p?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:p?"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:a,value:u.value,checked:p,disabled:b,onChange:()=>t(u.value),className:"absolute inset-0 opacity-0"}),e.jsx("span",{className:`h-2 w-2 rounded-full transition ${p?"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:u.label}),u.description&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:u.description})]})]},u.value)})})]})}const Mo=()=>'<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>',Et=r=>r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),To=r=>r.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(t,n,a)=>`${n}${a.toLocaleUpperCase()}`),pc=r=>r.replace(/[<>]/g,"").toLowerCase(),mc=new Set(["p","br","div","span","b","strong","i","em","u","s","strike","ul","ol","li","h1","h2","h3","h4","blockquote","a","img","hr"]),hc=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,gc=r=>{const t=r.indexOf("<!--StartFragment-->"),n=r.indexOf("<!--EndFragment-->");if(t!==-1&&n!==-1&&n>t)return r.slice(t+20,n);const a=r.match(/<body[^>]*>([\s\S]*)<\/body>/i);return a?a[1]:r},on=(r,t)=>t.test(r),vc=r=>on(r,/font-weight\s*:\s*(bold|[6-9]00)/i),xc=r=>on(r,/font-style\s*:\s*italic/i),yc=r=>on(r,/text-decoration(?:-line)?\s*:[^;]*underline/i),wc=r=>on(r,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),sn=(r,t)=>{var a;if(!r.childNodes.length||r.childNodes.length===1&&((a=r.firstChild)==null?void 0:a.nodeType)===Node.ELEMENT_NODE&&r.firstChild.tagName.toLowerCase()===t)return;const n=r.ownerDocument.createElement(t);for(;r.firstChild;)n.appendChild(r.firstChild);r.appendChild(n)},ln=r=>{const t=r.parentNode;if(!t){r.remove();return}for(;r.firstChild;)t.insertBefore(r.firstChild,r);t.removeChild(r)},Nc=r=>{const t=r.getAttribute("class")??"",n=r.getAttribute("style")??"";return/mso-list/i.test(n)||/MsoListParagraph/i.test(t)||/MsoList/i.test(t)},Lo=r=>{const t=r.getAttribute("style")??"",n=r.textContent??"";return/mso-level-number-format\s*:\s*(decimal|arabic|roman|alpha)/i.test(t)||/^\s*\d+[.)]\s/.test(n)||/^\s*[a-zA-Z][.)]\s/.test(n)?"ol":"ul"},kc=r=>{const n=r.ownerDocument.createTreeWalker(r,NodeFilter.SHOW_TEXT).nextNode();if(!n||!n.textContent)return;const a=n.textContent.replace(hc,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");a!==n.textContent&&(n.textContent=a)},Sc=r=>{const t=Array.from(r.querySelectorAll("span, font, p, div, li, h1, h2, h3, h4"));t.sort((n,a)=>a.querySelectorAll("*").length-n.querySelectorAll("*").length),t.forEach(n=>{const a=n.getAttribute("style")??"";a&&(vc(a)&&sn(n,"strong"),xc(a)&&sn(n,"em"),yc(a)&&sn(n,"u"),wc(a)&&sn(n,"s"))})},Cc=r=>{const t=Array.from(r.querySelectorAll("p, div")).filter(Nc);if(!t.length)return;let n=0;for(;n<t.length;){const a=t[n],s=Lo(a),l=[a];let i=n+1;for(;i<t.length;){const u=t[i];if(Lo(u)!==s)break;let p=l[l.length-1].nextSibling;for(;p&&p.nodeType===Node.TEXT_NODE&&!(p.textContent??"").trim();)p=p.nextSibling;if(p!==u)break;l.push(u),i++}const c=a.parentNode;if(!c){n=i;continue}const d=a.ownerDocument.createElement(s);c.insertBefore(d,a),l.forEach(u=>{kc(u);const p=u.ownerDocument.createElement("li");for(;u.firstChild;)p.appendChild(u.firstChild);d.appendChild(p),u.remove()}),n=i}},Ec=r=>r==="h1"?"h2":r==="h4"||r==="h5"||r==="h6"?"h3":r==="div"?"p":r,Mc=r=>{const t=gc(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()),Sc(s),Cc(s);const l=i=>{const c=Array.from(i.childNodes);if(i.nodeType===Node.ELEMENT_NODE){const d=i,u=d.tagName.toLowerCase();if(u==="html"||u==="body"){c.forEach(l);return}if(u==="font"){ln(d),c.forEach(l);return}if(!mc.has(u)){ln(d),c.forEach(l);return}const p=Ec(u);if(p!==u){const b=d.ownerDocument.createElement(p);for(;d.firstChild;)b.appendChild(d.firstChild);d.replaceWith(b),l(b);return}if(Array.from(d.attributes).forEach(b=>{const m=b.name.toLowerCase(),v=b.value;if(m.startsWith("on")||m==="style"||m==="class"){d.removeAttribute(b.name);return}if(m==="lang"||m.startsWith("data-")||m.startsWith("mso-")){d.removeAttribute(b.name);return}if((m==="href"||m==="src")&&/^\s*javascript:/i.test(v)){d.removeAttribute(b.name);return}u!=="a"&&u!=="img"&&m!=="href"&&m!=="src"&&m!=="alt"&&(["href","src","alt","target","rel"].includes(m)||d.removeAttribute(b.name))}),u==="a"){const b=d.getAttribute("href");if(!b||/^\s*#/.test(b)&&b.length<2){ln(d),c.forEach(l);return}d.setAttribute("target","_blank"),d.setAttribute("rel","noopener noreferrer"),d.classList.add("rich-link")}if(u==="img"){const b=d.getAttribute("src")??"";if(!b||/^\s*javascript:/i.test(b)||/^file:/i.test(b)||/scheme\s*=\s*["']?file/i.test(b)){d.remove();return}d.classList.add("rich-img"),Array.from(d.attributes).forEach(m=>{["src","alt","class"].includes(m.name.toLowerCase())||d.removeAttribute(m.name)})}if(u==="span"){ln(d),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(),d=i.querySelector("img, hr"),u=!c&&!d&&Array.from(i.childNodes).every(p=>p.nodeType===Node.TEXT_NODE||p.nodeType===Node.ELEMENT_NODE&&p.tagName.toLowerCase()==="br");(!c&&!d||u)&&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 d=c;for(;d.firstChild;)i.appendChild(d.firstChild);d.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()},ia=r=>Et(r).replace(/\r\n?/g,`
25
+ `).split(/\n{2,}/).map(t=>`<p>${t.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),Tc=r=>new RegExp("\\p{L}","u").test(r),ca=(r,t)=>{const n=r.trim();return!n||!Tc(n)?!1:t==="uppercase"?n===n.toLocaleUpperCase():t==="lowercase"?n===n.toLocaleLowerCase():n===To(n)},$o=r=>{const t=a=>{var s,l;if(!a.closest(".rich-img-wrap")){const i=document.createElement("span");i.className="rich-img-wrap",i.contentEditable="false",(s=a.parentNode)==null||s.insertBefore(i,a),i.appendChild(a),i.insertAdjacentHTML("beforeend",Mo())}(l=a.closest(".rich-img-wrap"))==null||l.classList.add("rich-img-broken")};r.querySelectorAll("img").forEach(a=>{if(!a.complete||a.naturalWidth===0){a.addEventListener("error",()=>t(a),{once:!0}),a.addEventListener("load",()=>{a.naturalWidth===0&&t(a)},{once:!0});const s=a.src;a.src="",a.src=s}});const n=a=>{const s=a.target;s.tagName==="IMG"&&t(s)};return r.addEventListener("error",n,!0),()=>r.removeEventListener("error",n,!0)};function Ao({value:r,onChange:t,placeholder:n="Escribe algo...",minHeight:a="80px",instanceId:s}){const l=o.useId(),i=s||l,c=o.useCallback(()=>document,[]),d=o.useRef(null),u=o.useRef(null),p=o.useRef(new Map),b=o.useRef(null),m=o.useRef(!1),v=o.useRef(r??""),y=o.useRef(t),E=o.useRef(!1),[h,$]=o.useState(()=>!r||r.trim()===""),[M,T]=o.useState(new Set),[L,C]=o.useState(null),[k,V]=o.useState(""),[A,K]=o.useState(""),[W,G]=o.useState(""),[w,Q]=o.useState(""),[_,P]=o.useState(!1),ne=o.useCallback(()=>m.current?u.current:d.current,[]);o.useEffect(()=>{y.current=t},[t]);const Y=o.useCallback(()=>{const j=window.getSelection(),ee=ne();if(!j||!ee||j.rangeCount===0||j.isCollapsed)return"";const fe=j.getRangeAt(0);return!ee.contains(fe.startContainer)||!ee.contains(fe.endContainer)?"":j.toString()},[ne]);o.useEffect(()=>{const j=r??"";if(E.current&&j===v.current){E.current=!1,$(!j||j.trim()==="");return}E.current=!1,v.current=j;const ee=[d.current,u.current].filter(pe=>!!pe);ee.forEach(pe=>{pe.innerHTML!==j&&(pe.innerHTML=j)}),$(!j||j.trim()==="");const fe=ee.map(pe=>$o(pe));return()=>fe.forEach(pe=>pe())},[r]),o.useEffect(()=>{var pe,De;m.current=_;let j,ee=0,fe;if(_){const Me=d.current;Me&&(v.current=Me.innerHTML);const Be=()=>{var Ke;const $e=u.current;if(!$e){ee=requestAnimationFrame(Be);return}$e.innerHTML!==v.current&&($e.innerHTML=v.current),j=$o($e),$(((Ke=$e.textContent)==null?void 0:Ke.trim())===""),fe=setTimeout(()=>$e.focus(),60)};ee=requestAnimationFrame(Be)}else{const Me=u.current,Be=d.current,$e=(Me==null?void 0:Me.innerHTML)??v.current,Ke=v.current;v.current=$e,Be&&Be.innerHTML!==$e&&(Be.innerHTML=$e),$e!==Ke&&y.current($e),$(((De=(pe=Me??Be)==null?void 0:pe.textContent)==null?void 0:De.trim())==="")}return()=>{ee&&cancelAnimationFrame(ee),fe&&clearTimeout(fe),j==null||j()}},[_]);const D=o.useCallback(()=>{const j=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],ee=new Set;j.forEach(pe=>{try{c().queryCommandState(pe)&&ee.add(pe)}catch{return}});try{const pe=pc(c().queryCommandValue("formatBlock"));pe&&ee.add(`formatBlock:${pe}`)}catch{}const fe=Y();ca(fe,"uppercase")&&ee.add("__upper"),ca(fe,"lowercase")&&ee.add("__lower"),ca(fe,"capitalize")&&ee.add("__cap"),T(ee)},[Y,c]),re=()=>{var ee;const j=ne();j&&(v.current=j.innerHTML,E.current=!0,y.current(v.current),$(((ee=j.textContent)==null?void 0:ee.trim())===""))},le=j=>{if(!j){const ee=d.current;ee&&(v.current=ee.innerHTML)}P(!j)},I=(j,ee)=>{var fe;(fe=ne())==null||fe.focus(),c().execCommand(j,!1,ee),re(),D()},H=j=>{I("formatBlock",j)},oe=()=>{var j;(j=ne())==null||j.focus(),c().execCommand("insertHTML",!1,"<hr><p><br></p>"),re(),D()},g=()=>{const j=window.getSelection();j&&j.rangeCount>0&&(b.current=j.getRangeAt(0).cloneRange())},O=()=>{const j=window.getSelection();j&&b.current&&(j.removeAllRanges(),j.addRange(b.current))},R=j=>{if(g(),j==="link"){const ee=window.getSelection();K(ee&&!ee.isCollapsed?ee.toString():""),V("")}j==="image"&&(G(""),Q("")),C(j)},se=()=>{var pe;if(!k.trim())return;O(),(pe=ne())==null||pe.focus();const j=window.getSelection(),fe=(j&&!j.isCollapsed?j.toString():"")||A.trim()||k.trim();c().execCommand("insertHTML",!1,`<a href="${Et(k.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${Et(fe)}</a>`),re(),C(null)},Z=(j,ee="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${Et(j)}" alt="${Et(ee)}" class="rich-img" />${Mo()}</span>`,X=()=>{var j;W.trim()&&(O(),(j=ne())==null||j.focus(),c().execCommand("insertHTML",!1,Z(W.trim(),w.trim())),re(),C(null))},S=(j,ee=1200,fe=1200,pe=.72)=>new Promise((De,Me)=>{const Be=new FileReader;Be.onerror=Me,Be.onload=$e=>{var wn;const Ke=(wn=$e.target)==null?void 0:wn.result,Pe=new Image;Pe.onerror=Me,Pe.onload=()=>{let{width:Xe,height:je}=Pe;if(Xe>ee||je>fe){const dr=Math.min(ee/Xe,fe/je);Xe=Math.round(Xe*dr),je=Math.round(je*dr)}const Ye=document.createElement("canvas");Ye.width=Xe,Ye.height=je;const Or=Ye.getContext("2d");if(!Or){De(Ke);return}Or.drawImage(Pe,0,0,Xe,je),De(Ye.toDataURL("image/jpeg",pe))},Pe.src=Ke},Be.readAsDataURL(j)}),te=j=>{j.focus();const ee=window.getSelection();if(!ee||ee.rangeCount===0||!j.contains(ee.anchorNode)){const fe=document.createRange();fe.selectNodeContents(j),fe.collapse(!1),ee==null||ee.removeAllRanges(),ee==null||ee.addRange(fe)}},F=o.useRef(()=>{});F.current=j=>{const ee=ne();ee&&(te(ee),c().execCommand("insertHTML",!1,j),ee.querySelectorAll("p").forEach(fe=>{!(fe.textContent??"").replace(/[\u00a0\s]+/g,"")&&!fe.querySelector("img, hr")&&fe.remove()}),re(),D())};const ae=o.useRef(S);ae.current=S;const q=o.useRef(Z);q.current=Z;const ce=o.useCallback(j=>{if(!j||p.current.has(j))return;const ee=fe=>{const pe=fe.clipboardData;if(!pe)return;const De=pe.getData("text/html"),Me=pe.getData("text/plain");if(De||Me){fe.preventDefault(),fe.stopPropagation();try{const Pe=De?Mc(De):ia(Me);if(!Pe){Me&&F.current(ia(Me));return}F.current(Pe)}catch{Me&&F.current(ia(Me))}return}const $e=Array.from(pe.items).find(Pe=>Pe.type.startsWith("image/"));if(!$e)return;fe.preventDefault(),fe.stopPropagation();const Ke=$e.getAsFile();Ke&&ae.current(Ke).then(Pe=>{F.current(q.current(Pe,"imagen"))})};j.addEventListener("paste",ee,!0),p.current.set(j,()=>{j.removeEventListener("paste",ee,!0),p.current.delete(j)})},[]),Ee=o.useCallback(j=>{var fe;const ee=d.current;ee&&ee!==j&&((fe=p.current.get(ee))==null||fe()),d.current=j,j&&ce(j)},[ce]),ie=o.useCallback(j=>{var fe;const ee=u.current;ee&&ee!==j&&((fe=p.current.get(ee))==null||fe()),u.current=j,j&&ce(j)},[ce]);o.useEffect(()=>{const j=p.current;return()=>{j.forEach(ee=>ee()),j.clear()}},[]);const ge=j=>{const ee=window.getSelection(),fe=ne();if(!ee||!fe||ee.rangeCount===0||ee.isCollapsed)return;const pe=ee.getRangeAt(0);if(!fe.contains(pe.startContainer)||!fe.contains(pe.endContainer))return;const De=pe.toString();if(!De)return;let Me=De;j==="uppercase"?Me=De.toLocaleUpperCase():j==="lowercase"?Me=De.toLocaleLowerCase():Me=To(De),pe.deleteContents();const Be=document.createTextNode(Me);pe.insertNode(Be);const $e=document.createRange();$e.setStart(Be,0),$e.setEnd(Be,Me.length),ee.removeAllRanges(),ee.addRange($e),b.current=$e.cloneRange(),re(),D()},we=()=>{g(),D()},Le=()=>{re(),D()},Cr=()=>{requestAnimationFrame(()=>{var j;(j=ne())==null||j.focus()})},gr=j=>{var ee,fe;if((j.metaKey||j.ctrlKey)&&j.key==="Enter"){if(j.preventDefault(),j.stopPropagation(),j.repeat)return;(ee=ne())==null||ee.focus(),c().execCommand("insertLineBreak",!1)||c().execCommand("insertHTML",!1,"<br>"),re(),D();return}if(j.key==="Tab"){j.preventDefault(),(fe=ne())==null||fe.focus(),c().execCommand("insertText",!1,"    "),re(),D();return}if(j.key==="Escape"){if(L){C(null);return}if(m.current){P(!1);return}}L||(j.ctrlKey||j.metaKey)&&(j.key==="b"&&(j.preventDefault(),I("bold")),j.key==="i"&&(j.preventDefault(),I("italic")),j.key==="u"&&(j.preventDefault(),I("underline")),j.key==="k"&&(j.preventDefault(),R("link")))},Ue=()=>e.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),de=(j,ee,fe,pe,De)=>{const Me=De??(M.has(fe)||fe==="__link"&&L==="link"||fe==="__img"&&L==="image");return e.jsx("button",{type:"button",title:ee,tabIndex:-1,onFocus:Cr,onMouseDown:Be=>{Be.preventDefault(),pe?pe():I(fe)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:Me?"var(--primary)":"var(--text-secondary)",background:Me?"rgba(59,130,246,0.12)":"transparent"},children:j},fe)},Re=j=>{const ee=j.target;if(ee.closest("[data-action='delete-img']")){j.preventDefault();const fe=ee.closest(".rich-img-wrap");fe&&(fe.remove(),re())}},cr=j=>e.jsxs(e.Fragment,{children:[L==="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:j},children:[e.jsx("input",{autoFocus:!0,type:"url",value:k,onChange:ee=>V(ee.target.value),onKeyDown:ee=>{ee.key==="Enter"&&(ee.preventDefault(),se()),ee.key==="Escape"&&C(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:A,onChange:ee=>K(ee.target.value),onKeyDown:ee=>{ee.key==="Enter"&&(ee.preventDefault(),se()),ee.key==="Escape"&&C(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:se,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:()=>C(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),L==="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:j},children:[e.jsx("input",{autoFocus:!0,type:"url",value:W,onChange:ee=>G(ee.target.value),onKeyDown:ee=>{ee.key==="Enter"&&(ee.preventDefault(),X()),ee.key==="Escape"&&C(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:w,onChange:ee=>Q(ee.target.value),onKeyDown:ee=>{ee.key==="Enter"&&(ee.preventDefault(),X()),ee.key==="Escape"&&C(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:X,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:()=>C(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),be=(j,ee)=>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:ee},children:[de(e.jsx(B.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),de(e.jsx(B.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),Ue(),de(e.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>H("p"),M.has("formatBlock:p")||M.has("formatBlock:div")),de(e.jsx(B.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>H("h2"),M.has("formatBlock:h2")),de(e.jsx(B.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>H("h3"),M.has("formatBlock:h3")),de(e.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>H("blockquote"),M.has("formatBlock:blockquote")),Ue(),de(e.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),de(e.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),de(e.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),de(e.jsx("s",{children:"S"}),"Tachado","strikeThrough"),Ue(),de(e.jsx(B.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),de(e.jsx(B.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),de(e.jsx(B.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),de(e.jsx(B.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),Ue(),de(e.jsx(B.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),de(e.jsx(B.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),de(e.jsx(B.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),de(e.jsx(B.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),Ue(),de(e.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>ge("uppercase")),de(e.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>ge("lowercase")),de(e.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>ge("capitalize")),Ue(),de(e.jsx(B.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>R("link")),de(e.jsx(B.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),de(e.jsx(B.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>R("image")),de(e.jsx(B.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",oe),Ue(),de(e.jsx(B.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),de(e.jsx(B.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>H("p")),Ue(),e.jsx("button",{type:"button",title:j?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:Cr,onMouseDown:fe=>{fe.preventDefault(),le(j)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:j?e.jsx(B.HiArrowsPointingIn,{className:"h-4 w-4"}):e.jsx(B.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:Ee,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:Le,onKeyDown:gr,onKeyUp:we,onSelect:we,onMouseUp:we,onMouseDown:Re,"data-placeholder":n,className:`rich-editor px-3 py-2 text-sm focus:outline-none${h?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:a,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),cr("var(--bg-input)"),be(!1,"var(--bg-input)")]}),e.jsxs(Qn,{open:_,onClose:()=>P(!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:ie,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:Le,onKeyDown:gr,onKeyUp:we,onSelect:we,onMouseUp:we,onMouseDown:Re,"data-placeholder":n,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${h?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),cr("var(--bg-input)"),be(!0,"var(--bg-input)")]})]})}const Do="[a-zA-Z0-9._@-]+",da=new RegExp(`@(${Do})`,"g"),Lc=/[a-zA-Z0-9._@-]/,Mt=new Set([" ",`
26
+ `," ","\r"," ","(","[","{",".",",",";",":","!","?","¿","¡",")","]","}",'"',"'","«","»","/","\\","|","-","—","–"]);function Io(r,t){if(t<=0)return!0;const n=r[t-1]??"";return Mt.has(n)}function Ho(r,t,n){var a;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(Mt.has(c)||!Lc.test(c))return null;continue}if((a=n==null?void 0:n.isInsideExistingMention)!=null&&a.call(n,s)||!(n!=null&&n.isTriggerBoundary?n.isTriggerBoundary(s):Io(r,s)))continue;const i=r.slice(s+1,t);return i.length>0&&!new RegExp(`^${Do}$`).test(i)?null:{query:i,triggerIndex:s,caretIndex:t}}return null}function Oo(r,t){var a;const n=Jr(r,t);return n?!!((a=n.node.parentElement)!=null&&a.closest(".mention-chip")):!1}function Bo(r,t){if(t<=0)return!0;const n=Jr(r,t);if(!n){const s=r.textContent??"";return Io(s,t)}if(n.offset>0){const s=n.node.data[n.offset-1]??"";return Mt.has(s)}let a=n.node.previousSibling;for(;a;){if(a.nodeType===Node.TEXT_NODE){const s=a.textContent??"";if(s.length===0){a=a.previousSibling;continue}return Mt.has(s[s.length-1]??"")}if(a.nodeType===Node.ELEMENT_NODE){const s=a;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){a=a.previousSibling;continue}return Mt.has(l[l.length-1]??"")}a=a.previousSibling}return!0}function ua(r,t){const n=r.textContent??"";return Ho(n,t,{isTriggerBoundary:a=>Bo(r,a),isInsideExistingMention:a=>Oo(r,a)})}function fa(r){return r.toLowerCase().trim()}function Po(r){return r?r.replace(/<style[^>]*>[\s\S]*?<\/style>/gi," ").replace(/<script[^>]*>[\s\S]*?<\/script>/gi," ").replace(/<br\s*\/?>/gi,`
27
27
  `).replace(/<\/(p|div|li)>/gi,`
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 aa(r){if(!r)return[];const t=new Set,n=[],a=u=>{const f=na(u);!f||t.has(f)||(t.add(f),n.push(f))},s=/data-username\s*=\s*["']([^"']+)["']/gi;let l;for(;(l=s.exec(r))!==null;)a(l[1]??"");const i=Eo(r);ra.lastIndex=0;let c;for(;(c=ra.exec(i))!==null;)a(c[1]??"");return n}function Mo(r){const t=String(r.name??"").trim();return t||String(r.username??"").trim()||"usuario"}function pc(r,t){const n=aa(r);if(!n.length)return[];const a=new Map;t.forEach(i=>{i.username&&a.set(na(i.username),i)});const s=new Set,l=[];for(const i of n){const c=a.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 Lo(r){const t=new Set,n=[];for(const a of r)t.has(a.userId)||(t.add(a.userId),n.push(a));return n}function mc(r,t){return t?r.filter(n=>n.userId!==t):r}function To(r){return!r||!/@/.test(r)?r:r.replace(ra,(t,n,a,s)=>{const l=s.slice(0,a),i=l.lastIndexOf("<"),c=l.lastIndexOf(">");return i>c?t:`<span class="mention-chip" contenteditable="false" data-username="${(n??"").toLowerCase()}">${t}</span>`})}function Yr(r,t){if(t<0)return null;const n=r.ownerDocument;if(!n)return null;const a=n.createTreeWalker(r,NodeFilter.SHOW_TEXT);let s=t,l=null,i=a.nextNode();for(;i;){l=i;const c=i.data.length;if(s<=c)return{node:i,offset:s};s-=c,i=a.nextNode()}return l&&s===0?{node:l,offset:l.data.length}:null}function oa(r,t,n){var s;const a=r.ownerDocument;if(!a||r!==t&&!r.contains(t))return-1;try{const l=a.createRange();return l.selectNodeContents(r),l.setEnd(t,n),((s=l.cloneContents().textContent)==null?void 0:s.length)??0}catch{return-1}}function $o(r,t){const{triggerIndex:n,caretIndex:a,username:s}=t;if(a<n)return null;const l=Yr(r,n),i=Yr(r,a);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=Mo({name:t.display,username:s}),p=c.createElement("span");p.className="mention-chip",p.setAttribute("data-username",s.toLowerCase()),t.userId&&p.setAttribute("data-userid",String(t.userId)),p.contentEditable="false",p.textContent=f,p.title=`@${s}`;const b=c.createTextNode(" ");u.insertNode(b),u.insertNode(p);const m=c.defaultView,v=m==null?void 0:m.getSelection();if(v){const y=c.createRange();y.setStart(b,b.data.length),y.collapse(!0),v.removeAllRanges(),v.addRange(y)}return{caretPlainOffset:n+f.length+1}}function Ao(r,t){const n=r.ownerDocument,a=n.defaultView;if(!a)return;const s=a.getSelection();if(!s)return;const l=n.createRange(),i=Yr(r,t);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(r),l.collapse(!1)),s.removeAllRanges(),s.addRange(l)}const sa=280,tn=6,Do=260,hc=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),gc={position:"relative"},vc={position:"fixed",zIndex:11050,minWidth:Do,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},Io={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function xc(r){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(r)}"]`))}function yc(r,t){const n=Math.max(8,Math.min(r.left,window.innerWidth-Do-8)),a=t==null?void 0:t.getBoundingClientRect(),s=a?Math.min(window.innerHeight-8,a.bottom):window.innerHeight-8,l=a?Math.max(8,a.top):8,i=s-r.bottom-tn,c=r.top-l-tn;return i<Math.min(sa,160)&&c>i?{left:n,bottom:window.innerHeight-r.top+tn,maxHeight:Math.max(120,Math.min(sa,c))}:{left:n,top:r.bottom+tn,maxHeight:Math.max(120,Math.min(sa,i))}}function Bo({value:r,onChange:t,onSearchUsers:n,onMentionsChange:a,minHeight:s,placeholder:l,className:i,maxSuggestions:c=8,searchDebounceMs:u=140,highlightInEditor:f=!1,searchCacheKey:p=""}){const b=o.useId().replace(/:/g,""),m=o.useRef(null),v=o.useRef(null),y=o.useRef(new Map),S=o.useRef(n);S.current=n;const h=o.useRef(null),P=o.useRef(0),O=o.useRef([]),[E,L]=o.useState(null),[N,k]=o.useState([]),[Y,F]=o.useState(0),[U,V]=o.useState([]),[J,C]=o.useState(!1),[re,W]=o.useState(!1);P.current=Y,o.useEffect(()=>{W(!0)},[]);const j=(E==null?void 0:E.query)??null;o.useEffect(()=>{if(j===null){k([]);return}const A=j.trim(),q=`${p}|${A.toLowerCase()||"*"}`,ne=y.current.get(q);if(ne){k(ne),C(!1),F(0);return}const ie=new AbortController;C(!0);const Q=window.setTimeout(()=>{(async()=>{try{const G=await S.current(A,{signal:ie.signal,limit:c});if(ie.signal.aborted)return;const w=Array.isArray(G)?G:[];y.current.set(q,w),k(w),F(0)}catch{ie.signal.aborted||k([])}finally{ie.signal.aborted||C(!1)}})()},u);return()=>{ie.abort(),window.clearTimeout(Q)}},[j,c,u,p]);const ae=o.useRef(a);ae.current=a,o.useEffect(()=>{var A;(A=ae.current)==null||A.call(ae,Lo(U))},[U]);const Z=o.useCallback(()=>{const A=xc(b);if(A.length===0)return null;const q=window.getSelection();if(q!=null&&q.rangeCount){const ie=q.getRangeAt(0).startContainer;for(const Q of A)if(Q.contains(ie))return Q}const ne=document.activeElement;for(const ie of A)if(ne===ie||ne&&ie.contains(ne))return ie;for(const ie of A)if(ie.closest('[role="dialog"]'))return ie;return A[0]??null},[b]),$=o.useCallback(()=>{const A=Z(),q=window.getSelection();if(!A||!q||q.rangeCount===0){L(null);return}const ne=q.getRangeAt(0);if(!A.contains(ne.startContainer)){L(null);return}const ie=oa(A,ne.startContainer,ne.startOffset);if(ie<0){L(null);return}const Q=ta(A,ie);if(!Q){L(null);return}const G=ne.getBoundingClientRect(),w=G.width===0&&G.height===0?(()=>{const B=document.createRange();return B.selectNodeContents(ne.startContainer),B.collapse(!0),B.getBoundingClientRect()})():G;h.current={query:Q.query,caretIndex:Q.caretIndex,triggerIndex:Q.triggerIndex};const R=yc(w,A);L(B=>{const te={query:Q.query,...R};return B&&B.query===te.query&&B.top===te.top&&B.bottom===te.bottom&&B.left===te.left&&B.maxHeight===te.maxHeight?B:te})},[Z]),ee=o.useCallback(A=>{t(A),$()},[t,$]);o.useEffect(()=>{const A=q=>{if(hc.has(q.key))return;const ne=Z(),ie=q.target;!ne||!ie||!ne.contains(ie)||$()};return document.addEventListener("keyup",A,!0),()=>document.removeEventListener("keyup",A,!0)},[Z,$]);const se=o.useCallback(A=>{const q=Z();if(!q)return;let ne=-1;const ie=window.getSelection();if(ie&&ie.rangeCount>0){const B=ie.getRangeAt(0);q.contains(B.startContainer)&&(ne=oa(q,B.startContainer,B.startOffset))}if(ne<0&&h.current&&(ne=h.current.caretIndex),ne<0)return;const Q=ta(q,ne);if(!Q)return;const G=$o(q,{triggerIndex:Q.triggerIndex,caretIndex:ne,username:A.username,display:A.name,userId:A.userId});if(!G)return;t(q.innerHTML);const w={userId:A.userId,username:A.username,email:A.email??void 0,display:A.name??A.username};V(B=>{const te=new Map(B.map(z=>[z.userId,z]));return te.set(w.userId,w),Array.from(te.values())}),L(null),h.current=null;const R=G.caretPlainOffset;requestAnimationFrame(()=>{requestAnimationFrame(()=>{var Ee,Le;const B=Z();if(!B)return;B.focus(),Ao(B,R);const te=window.getSelection(),z=te==null?void 0:te.anchorNode,le=z instanceof Element?z.closest(".mention-chip"):(Ee=z==null?void 0:z.parentElement)==null?void 0:Ee.closest(".mention-chip");if(le!=null&&le.parentNode){const xe=document.createRange(),Se=le.nextSibling;Se&&Se.nodeType===Node.TEXT_NODE?xe.setStart(Se,((Le=Se.textContent)==null?void 0:Le.length)??0):xe.setStartAfter(le),xe.collapse(!0),te==null||te.removeAllRanges(),te==null||te.addRange(xe)}})})},[Z,t]);o.useEffect(()=>{const A=new Set(aa(r).map(q=>q.toLowerCase()));V(q=>{const ne=q.filter(ie=>A.has(ie.username.toLowerCase()));return ne.length===q.length?q:ne})},[r]),o.useEffect(()=>{if(!E)return;const A=q=>{const ne=q.target;if(!ne||m.current&&m.current.contains(ne)||v.current&&v.current.contains(ne))return;const ie=Z();ie&&ie.contains(ne)||L(null)};return document.addEventListener("mousedown",A),()=>{document.removeEventListener("mousedown",A)}},[E,Z]);const M=o.useMemo(()=>N.slice(0,c),[N,c]);O.current=M,o.useEffect(()=>{if(!E)return;const A=q=>{const ne=Z(),ie=q.target;if(!ne||!ie||!ne.contains(ie))return;const Q=O.current;if(!(Q.length===0&&q.key!=="Escape"))if(q.key==="ArrowDown")q.preventDefault(),q.stopPropagation(),F(G=>(G+1)%Math.max(Q.length,1));else if(q.key==="ArrowUp")q.preventDefault(),q.stopPropagation(),F(G=>(G-1+Q.length)%Math.max(Q.length,1));else if(q.key==="Enter"||q.key==="Tab"){const G=Q[P.current];G&&(q.preventDefault(),q.stopPropagation(),se(G))}else q.key==="Escape"&&(q.preventDefault(),q.stopPropagation(),L(null))};return document.addEventListener("keydown",A,!0),()=>document.removeEventListener("keydown",A,!0)},[Z,se,E]),o.useEffect(()=>{if(!E||!v.current)return;const A=v.current.querySelector(`[data-mention-index="${Y}"]`);A==null||A.scrollIntoView({block:"nearest"})},[Y,E]);const H=f?To(r):r,oe=E&&re?er.createPortal(e.jsxs("ul",{ref:v,style:{...vc,left:E.left,top:E.top,bottom:E.bottom,maxHeight:E.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[J&&M.length===0&&e.jsx("li",{style:Io,children:"Buscando…"}),!J&&M.length===0&&e.jsx("li",{style:Io,children:E.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${E.query}”`}),M.map((A,q)=>{var ne,ie;return e.jsx("li",{children:e.jsxs("button",{type:"button","data-mention-index":q,onMouseDown:Q=>{Q.preventDefault(),se(A)},onMouseEnter:()=>F(q),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:q===Y?"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.jsx("span",{style:{fontWeight:600,fontSize:13},children:((ne=A.name)==null?void 0:ne.trim())||`@${A.username}`}),e.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[(ie=A.name)!=null&&ie.trim()?`@${A.username}`:null,A.email].filter(Boolean).join(" · ")||`@${A.username}`})]})},A.userId)})]}),document.body):null;return e.jsxs("div",{ref:m,style:gc,className:i,children:[e.jsx(yo,{value:H,onChange:ee,placeholder:l,minHeight:s,instanceId:b}),oe]})}function wc({value:r,onChange:t,placeholder:n,minHeight:a,onSearchUsers:s,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:u,highlightInEditor:f,searchCacheKey:p}){return s?e.jsx(Bo,{value:r,onChange:t,onSearchUsers:s,onMentionsChange:l,placeholder:n,minHeight:a,className:i,maxSuggestions:c,searchDebounceMs:u,highlightInEditor:f,searchCacheKey:p}):e.jsx(yo,{value:r,onChange:t,placeholder:n,minHeight:a})}function kc({title:r,subtitle:t,icon:n,actions:a,children:s,footer:l,className:i="",bodyClassName:c="p-4"}){const u=r||t||n||a;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:[n&&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:n}),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})]})]}),a&&e.jsx("div",{className:"shrink-0",children:a})]}),e.jsx("div",{className:c,children:s}),l&&e.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:l})]})}const Nc={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)"}},Sc={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:n="sm",icon:a,dot:s=!1,className:l=""}){const i=Nc[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 ${Sc[n]} ${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}}),a&&e.jsx("span",{className:"shrink-0",children:a}),e.jsx("span",{className:"min-w-0 truncate",children:r})]})}const Oo={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)"}},Ec={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"},Mc={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},Lc={xs:148,sm:164,md:184},Tc={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 $c({value:r,options:t,onChange:n,size:a="sm",disabled:s=!1,loading:l=!1,stopPropagation:i=!1,ariaLabel:c="Cambiar estado",title:u="Cambiar estado",className:f,selectClassName:p,menuClassName:b,optionClassName:m,spinnerClassName:v}){const[y,S]=o.useState(!1),[h,P]=o.useState(!1),[O,E]=o.useState(-1),[L,N]=o.useState({}),k=o.useRef(null),Y=o.useRef(null),F=o.useRef(null),U=t.find($=>$.value===r)??t[0],V={...U!=null&&U.tone?Oo[U.tone]:void 0,...U==null?void 0:U.style},J=s||l||t.length===0,C=$=>{i&&$.stopPropagation()},re=o.useCallback(()=>{S(!1),E(-1)},[]),W=o.useCallback(()=>{const $=k.current;if(!$)return;const ee=$.getBoundingClientRect(),se=Math.max(ee.width,Lc[a]),M=Math.min(Math.max(t.length,1)*38+12,260),H=window.innerHeight-ee.bottom,oe=H<M&&ee.top>H,A=Math.min(Math.max(8,ee.left+ee.width/2-se/2),window.innerWidth-se-8);N({position:"fixed",left:A,top:oe?void 0:ee.bottom+6,bottom:oe?window.innerHeight-ee.top+6:void 0,width:se,zIndex:9999})},[t.length,a]),j=o.useCallback($=>{$.disabled||(n($.value),re())},[re,n]);o.useEffect(()=>P(!0),[]),o.useEffect(()=>{if(!y)return;W();const $=t.findIndex(ee=>ee.value===r);E($>=0?$:0)},[y,t,W,r]),o.useEffect(()=>{if(!y)return;function $(ee){var M,H;const se=ee.target;!((M=k.current)!=null&&M.contains(se))&&!((H=Y.current)!=null&&H.contains(se))&&re()}return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[re,y]),o.useEffect(()=>{if(y)return window.addEventListener("resize",W),window.addEventListener("scroll",W,!0),()=>{window.removeEventListener("resize",W),window.removeEventListener("scroll",W,!0)}},[y,W]),o.useEffect(()=>{if(O<0||!F.current)return;const $=F.current.children[O];$==null||$.scrollIntoView({block:"nearest"})},[O]);function ae($){if(!J){if(!y){["Enter"," ","ArrowDown","ArrowUp"].includes($.key)&&($.preventDefault(),S(!0));return}if($.key==="Escape"){$.preventDefault(),re();return}if($.key==="ArrowDown"){$.preventDefault(),E(ee=>Math.min(ee+1,t.length-1));return}if($.key==="ArrowUp"){$.preventDefault(),E(ee=>Math.max(ee-1,0));return}if($.key==="Enter"||$.key===" "){$.preventDefault();const ee=t[O];ee&&j(ee)}}}const Z=e.jsx("div",{ref:Y,role:"listbox","aria-label":c,className:gr("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",b),style:{...L,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:C,onMouseDown:C,onPointerDown:C,children:e.jsx("div",{ref:F,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:t.map(($,ee)=>{const se=$.value===r,M=ee===O,H={...$.tone?Oo[$.tone]:void 0,...$.style};return e.jsxs("button",{type:"button",role:"option","aria-selected":se,disabled:$.disabled,onMouseEnter:()=>!$.disabled&&E(ee),onMouseDown:oe=>{oe.preventDefault(),j($)},className:gr("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",Tc[a],se?$.className:void 0,m),style:{...se?H:void 0,background:se?H.background??"color-mix(in srgb, var(--primary) 12%, transparent)":M?"var(--bg-hover)":"transparent",color:se?H.color??"var(--primary)":"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:se?e.jsx(T.HiCheck,{className:"h-4 w-4"}):null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:$.label})]},$.value)})})});return e.jsxs("span",{ref:k,className:gr("relative inline-flex shrink-0 items-center",f),onKeyDown:ae,onClick:C,onPointerDown:C,children:[e.jsx("button",{type:"button",disabled:J,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":y,title:u,onClick:()=>!J&&S($=>!$),className:gr("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",Ec[a],U==null?void 0:U.className,p),style:V,children:e.jsx("span",{className:"min-w-0 truncate",children:(U==null?void 0:U.label)??r})}),e.jsx(T.HiChevronDown,{"aria-hidden":"true",className:gr("pointer-events-none absolute opacity-70 transition-transform",Mc[a],y?"rotate-180":"rotate-0")}),l&&e.jsx("span",{"aria-hidden":"true",className:gr("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",v)}),y&&h&&er.createPortal(Z,document.body)]})}function Ac({tabs:r,activeTabId:t,defaultActiveTabId:n,onTabChange:a,ariaLabel:s="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:u=""}){const f=r.find(y=>!y.disabled)??r[0],p=t??n??(f==null?void 0:f.id),b=r.find(y=>y.id===p)??f,m=y=>{y.disabled||a==null||a(y.id)},v=y=>{const S=r.filter(P=>!P.disabled);if(!S.length||!b)return;const h=S.findIndex(P=>P.id===b.id);(y.key==="ArrowRight"||y.key==="ArrowDown")&&(y.preventDefault(),m(S[(h+1)%S.length])),(y.key==="ArrowLeft"||y.key==="ArrowUp")&&(y.preventDefault(),m(S[(h-1+S.length)%S.length])),y.key==="Home"&&(y.preventDefault(),m(S[0])),y.key==="End"&&(y.preventDefault(),m(S[S.length-1]))};return e.jsxs("div",{className:i,children:[e.jsx("div",{role:"tablist","aria-label":s,onKeyDown:v,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 S=y.id===(b==null?void 0:b.id);return e.jsxs("button",{type:"button",role:"tab","aria-selected":S,"aria-controls":`${y.id}-panel`,id:`${y.id}-tab`,disabled:y.disabled,tabIndex:S?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:S?"var(--primary)":"var(--text-muted)",borderColor:S?"var(--primary)":"transparent",background:l==="pills"&&S?"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)})}),(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 yr(...r){return r.filter(Boolean).join(" ")}function Dc({steps:r,activeStepId:t,initialStepId:n,completedStepIds:a,defaultCompletedStepIds:s=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:c,allowBackNavigation:u=!0,showFooter:f=!0,previousLabel:p="Anterior",nextLabel:b="Siguiente",blockedNextLabel:m="Completa este paso",className:v="",headerClassName:y="",contentClassName:S="",footerClassName:h=""}){var Q;const P=((Q=r[0])==null?void 0:Q.id)??"",[O,E]=o.useState(n??P),[L,N]=o.useState(s),k=t??O,Y=a??L,F=o.useMemo(()=>new Set(Y),[Y]),U=Math.max(0,r.findIndex(G=>G.id===k)),V=r[U]??r[0],J=r.length<=1?100:U/(r.length-1)*100,C=G=>{a||N(G),i==null||i(G)},re=G=>{const w=r.find(R=>R.id===G);w&&(t||E(G),l==null||l(G,w))},W=G=>F.has(G),j=G=>r.slice(0,G).find(w=>!w.optional&&!F.has(w.id)),ae=G=>{const w=r[G];return!w||w.disabled?!1:G===U||u&&G<U?!0:!j(G)},Z=G=>{const w=r.findIndex(R=>R.id===G);return w>=0&&ae(w)},$=G=>{const w=r.findIndex(R=>R.id===G);if(w<0)return!1;if(!ae(w)){const R=j(w);return R&&(c==null||c(r[w],R)),!1}return re(G),!0},ee=(G=V==null?void 0:V.id)=>{!G||F.has(G)||C([...Y,G])},se=(G=V==null?void 0:V.id)=>{if(!G)return;const w=r.findIndex(B=>B.id===G),R=Y.filter(B=>{const te=r.findIndex(z=>z.id===B);return te>=0&&te<w});C(R),w>=0&&U>w&&re(G)},M=()=>U<=0?!1:$(r[U-1].id),H=()=>{const G=r[U+1];return G?$(G.id):!1},oe={activeStep:V,activeIndex:U,completedStepIds:Y,isCompleted:W,isUnlocked:Z,completeStep:ee,uncompleteStep:se,goToStep:$,goNext:H,goPrevious:M};if(!V)return null;const A=r[U+1],q=U>0,ne=A?Z(A.id):!1,ie=typeof V.content=="function"?V.content(oe):V.content;return e.jsxs("section",{className:yr("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",v),children:[e.jsxs("div",{className:yr("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:`${J}%`}})}),e.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${r.length}, minmax(0, 1fr))`},children:r.map((G,w)=>{const R=G.id===V.id,B=W(G.id),te=ae(w),z=j(w);return e.jsxs("button",{type:"button",disabled:!te,"aria-current":R?"step":void 0,"aria-disabled":!te,title:!te&&z?`Completa ${z.title}`:G.title,onClick:()=>$(G.id),className:yr("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",R&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",B&&!R&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!R&&!B&&te&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!te&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[e.jsx("span",{className:yr("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",R&&"scale-x-100")}),e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:yr("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",R&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",B&&!R&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!B&&!R&&te&&"border-[var(--border)] text-[var(--text-muted)]",!te&&"border-[var(--border)] text-[var(--text-muted)]"),children:B?e.jsx(T.HiCheck,{className:"h-4 w-4"}):te?w+1:e.jsx(T.HiLockClosed,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:yr("block truncate text-xs font-semibold transition-colors duration-200",R?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[w+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:yr("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",S),children:ie},V.id),f&&e.jsxs("div",{className:yr("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",h),children:[e.jsx(Fe,{variant:"secondary",height:38,padding:"0 14px",icon:e.jsx(T.HiChevronLeft,{}),disabled:!q,onClick:M,children:p}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[e.jsxs("span",{children:["Paso ",U+1," de ",r.length]}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),e.jsxs("span",{children:[Y.length," completados"]})]}),e.jsx(Fe,{height:38,padding:"0 14px",icon:e.jsx(T.HiChevronRight,{}),disabled:!A||!ne,onClick:H,children:A&&!ne?m:b})]})]})}const Ic={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"},Bc={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Oc(r,t){if(r){if(typeof r=="function"){r(t);return}r.current=t}}function Hc(r,t){return r!==void 0?String(r).length:t!==void 0?String(t).length:0}const Ho=o.forwardRef(function({className:t="",wrapperClassName:n="",size:a="md",resize:s="vertical",autoResize:l=!1,minRows:i,maxRows:c,showCount:u=!1,maxCount:f,status:p="default",icon:b,action:m,style:v,value:y,defaultValue:S,maxLength:h,onInput:P,...O},E){const L=o.useRef(null),N=Hc(y,S),k=f??h,Y=!!(b||m||u),F=p==="error"?"var(--danger)":p==="success"?"#16a34a":"var(--border)",U={...v??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},V=()=>{const C=L.current;!C||!l||(C.style.height="auto",C.style.height=`${C.scrollHeight}px`)};o.useEffect(V,[l,y]);const J=e.jsx("textarea",{...O,ref:C=>{L.current=C,Oc(E,C)},value:y,defaultValue:S,maxLength:h,"aria-invalid":p==="error"||O["aria-invalid"],onInput:C=>{V(),P==null||P(C)},style:{...U,borderColor:F},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 ${Ic[a]} ${Bc[l?"none":s]} ${b?"pl-8":""} ${m?"pr-10":""} ${t}`});return Y?e.jsxs("span",{className:`relative block ${n}`,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}),J,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:[N,k?`/${k}`:""]})]}):J});function Pc({label:r,containerClassName:t="",helperText:n,helperDisplay:a,error:s,labelAction:l,required:i,className:c="",status:u,...f}){return e.jsx(uo,{label:r,required:i,helperText:n,helperDisplay:a,error:s,labelAction:l,className:t,children:e.jsx(Ho,{...f,required:i,status:s?"error":u,className:`w-full ${c}`})})}const Po=[{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 Fc(r){return Po[r%Po.length]}let zc=0;function la(){return++zc}function Fo(r,t){return t?t instanceof RegExp?t.test(r):t(r):!0}function _c(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function jc(r,t){const n=t.filter(Boolean);if(n.length===0)return[r.trim()].filter(Boolean);const a=new RegExp(`${n.map(s=>_c(s)).join("|")}|\\r?\\n`,"g");return r.split(a).map(s=>s.trim()).filter(Boolean)}function Wc({value:r,defaultValue:t,onChange:n,placeholder:a="Escribe y presiona Enter…",disabled:s=!1,className:l="",delimiters:i=[","],maxTags:c,allowDuplicates:u=!1,validate:f,label:p,helperText:b,helperDisplay:m="inline",error:v,required:y=!1}){const S=r!==void 0,h=!!v,P=!!b&&m==="tooltip"&&!h,[O,E]=o.useState(()=>(t??[]).map((B,te)=>({id:la(),value:B.trim(),colorIndex:te})));o.useEffect(()=>{S&&E(B=>{const te=r??[],z=new Map(B.map(le=>[le.value,le]));return te.map((le,Ee)=>z.get(le)??{id:la(),value:le,colorIndex:Ee})})},[S,r]);const L=O,[N,k]=o.useState(""),[Y,F]=o.useState(null),[U,V]=o.useState(""),[J,C]=o.useState(!1),[re,W]=o.useState(!1),j=o.useRef(null),ae=o.useRef(null),Z=o.useRef(null);function $(){W(!0),setTimeout(()=>W(!1),400)}function ee(B){E(B),n==null||n(B.map(te=>te.value))}function se(B){let te=L,z=!1,le=!1;for(const Ee of B){const Le=Ee.trim();if(Le){if(c!==void 0&&te.length>=c){le=!0;break}if(!u&&te.some(xe=>xe.value.toLowerCase()===Le.toLowerCase())){le=!0;continue}if(!Fo(Le,f)){le=!0;continue}te=[...te,{id:la(),value:Le,colorIndex:te.length}],z=!0}}return z&&ee(te),le&&$(),z}function M(B){return se([B])}function H(B){const te=L.filter(z=>z.id!==B);ee(te.map((z,le)=>({...z,colorIndex:le})))}function oe(B,te){const z=te.trim();if(F(null),V(""),!z){H(B);return}if(!(!u&&L.some(le=>le.id!==B&&le.value.toLowerCase()===z.toLowerCase()))){if(!Fo(z,f)){$();return}ee(L.map(le=>le.id===B?{...le,value:z}:le))}}function A(B){s||(F(B.id),V(B.value),setTimeout(()=>{var te;return(te=ae.current)==null?void 0:te.select()},0))}function q(B){if(B.key==="Enter"||i.includes(B.key)){B.preventDefault(),M(N)&&k("");return}if(B.key==="Backspace"&&N===""&&L.length>0){B.preventDefault();const te=L[L.length-1];H(te.id)}}function ne(B,te){if(B.key==="Enter"){B.preventDefault(),oe(te,U),setTimeout(()=>{var z;return(z=j.current)==null?void 0:z.focus()},0);return}B.key==="Escape"&&(B.preventDefault(),F(null),V(""),setTimeout(()=>{var z;return(z=j.current)==null?void 0:z.focus()},0))}function ie(){var B;s||(B=j.current)==null||B.focus()}function Q(B){if(s)return;const te=B.clipboardData.getData("text");if(!te||!(i.some(Le=>Le&&te.includes(Le))||te.includes(`
29
- `)))return;B.preventDefault();const le=jc(te,i);se(le)&&k("")}function G(){const B=N.trim();B&&M(B)&&k("")}const w=h?"var(--danger)":J?"var(--primary)":"var(--border)",R=c!==void 0&&L.length>=c;return e.jsxs("div",{className:`flex flex-col gap-2 ${l}`,children:[(p||y||P)&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[p&&e.jsx("span",{children:p}),y&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),P?e.jsx(Kr,{content:b}):null]}),e.jsxs("div",{ref:Z,onClick:ie,onFocus:()=>C(!0),onBlur:B=>{var te;(te=Z.current)!=null&&te.contains(B.relatedTarget)||(C(!1),Y!==null&&oe(Y,U),Y===null&&G())},style:{borderColor:w},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 ba(r){if(!r)return[];const t=new Set,n=[],a=d=>{const u=fa(d);!u||t.has(u)||(t.add(u),n.push(u))},s=/data-username\s*=\s*["']([^"']+)["']/gi;let l;for(;(l=s.exec(r))!==null;)a(l[1]??"");const i=Po(r);da.lastIndex=0;let c;for(;(c=da.exec(i))!==null;)a(c[1]??"");return n}function Fo(r){const t=String(r.name??"").trim();return t||String(r.username??"").trim()||"usuario"}function $c(r,t){const n=ba(r);if(!n.length)return[];const a=new Map;t.forEach(i=>{i.username&&a.set(fa(i.username),i)});const s=new Set,l=[];for(const i of n){const c=a.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 zo(r){const t=new Set,n=[];for(const a of r)t.has(a.userId)||(t.add(a.userId),n.push(a));return n}function Ac(r,t){return t?r.filter(n=>n.userId!==t):r}function _o(r){return!r||!/@/.test(r)?r:r.replace(da,(t,n,a,s)=>{const l=s.slice(0,a),i=l.lastIndexOf("<"),c=l.lastIndexOf(">");return i>c?t:`<span class="mention-chip" contenteditable="false" data-username="${(n??"").toLowerCase()}">${t}</span>`})}function Jr(r,t){if(t<0)return null;const n=r.ownerDocument;if(!n)return null;const a=n.createTreeWalker(r,NodeFilter.SHOW_TEXT);let s=t,l=null,i=a.nextNode();for(;i;){l=i;const c=i.data.length;if(s<=c)return{node:i,offset:s};s-=c,i=a.nextNode()}return l&&s===0?{node:l,offset:l.data.length}:null}function pa(r,t,n){var s;const a=r.ownerDocument;if(!a||r!==t&&!r.contains(t))return-1;try{const l=a.createRange();return l.selectNodeContents(r),l.setEnd(t,n),((s=l.cloneContents().textContent)==null?void 0:s.length)??0}catch{return-1}}function jo(r,t){const{triggerIndex:n,caretIndex:a,username:s}=t;if(a<n)return null;const l=Jr(r,n),i=Jr(r,a);if(!l||!i)return null;const c=r.ownerDocument,d=c.createRange();d.setStart(l.node,l.offset),d.setEnd(i.node,i.offset),d.deleteContents();const u=Fo({name:t.display,username:s}),p=c.createElement("span");p.className="mention-chip",p.setAttribute("data-username",s.toLowerCase()),t.userId&&p.setAttribute("data-userid",String(t.userId)),p.contentEditable="false",p.textContent=u,p.title=`@${s}`;const b=c.createTextNode(" ");d.insertNode(b),d.insertNode(p);const m=c.defaultView,v=m==null?void 0:m.getSelection();if(v){const y=c.createRange();y.setStart(b,b.data.length),y.collapse(!0),v.removeAllRanges(),v.addRange(y)}return{caretPlainOffset:n+u.length+1}}function Wo(r,t){const n=r.ownerDocument,a=n.defaultView;if(!a)return;const s=a.getSelection();if(!s)return;const l=n.createRange(),i=Jr(r,t);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(r),l.collapse(!1)),s.removeAllRanges(),s.addRange(l)}const ma=280,cn=6,qo=260,Dc=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),Ic={position:"relative"},Hc={position:"fixed",zIndex:11050,minWidth:qo,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},Uo={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function Oc(r){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(r)}"]`))}function Bc(r,t){const n=Math.max(8,Math.min(r.left,window.innerWidth-qo-8)),a=t==null?void 0:t.getBoundingClientRect(),s=a?Math.min(window.innerHeight-8,a.bottom):window.innerHeight-8,l=a?Math.max(8,a.top):8,i=s-r.bottom-cn,c=r.top-l-cn;return i<Math.min(ma,160)&&c>i?{left:n,bottom:window.innerHeight-r.top+cn,maxHeight:Math.max(120,Math.min(ma,c))}:{left:n,top:r.bottom+cn,maxHeight:Math.max(120,Math.min(ma,i))}}function Vo({value:r,onChange:t,onSearchUsers:n,onMentionsChange:a,minHeight:s,placeholder:l,className:i,maxSuggestions:c=8,searchDebounceMs:d=140,highlightInEditor:u=!1,searchCacheKey:p=""}){const b=o.useId().replace(/:/g,""),m=o.useRef(null),v=o.useRef(null),y=o.useRef(new Map),E=o.useRef(n);E.current=n;const h=o.useRef(null),$=o.useRef(0),M=o.useRef([]),[T,L]=o.useState(null),[C,k]=o.useState([]),[V,A]=o.useState(0),[K,W]=o.useState([]),[G,w]=o.useState(!1),[Q,_]=o.useState(!1);$.current=V,o.useEffect(()=>{_(!0)},[]);const P=(T==null?void 0:T.query)??null;o.useEffect(()=>{if(P===null){k([]);return}const g=P.trim(),O=`${p}|${g.toLowerCase()||"*"}`,R=y.current.get(O);if(R){k(R),w(!1),A(0);return}const se=new AbortController;w(!0);const Z=window.setTimeout(()=>{(async()=>{try{const X=await E.current(g,{signal:se.signal,limit:c});if(se.signal.aborted)return;const S=Array.isArray(X)?X:[];y.current.set(O,S),k(S),A(0)}catch{se.signal.aborted||k([])}finally{se.signal.aborted||w(!1)}})()},d);return()=>{se.abort(),window.clearTimeout(Z)}},[P,c,d,p]);const ne=o.useRef(a);ne.current=a,o.useEffect(()=>{var g;(g=ne.current)==null||g.call(ne,zo(K))},[K]);const Y=o.useCallback(()=>{const g=Oc(b);if(g.length===0)return null;const O=window.getSelection();if(O!=null&&O.rangeCount){const se=O.getRangeAt(0).startContainer;for(const Z of g)if(Z.contains(se))return Z}const R=document.activeElement;for(const se of g)if(R===se||R&&se.contains(R))return se;for(const se of g)if(se.closest('[role="dialog"]'))return se;return g[0]??null},[b]),D=o.useCallback(()=>{const g=Y(),O=window.getSelection();if(!g||!O||O.rangeCount===0){L(null);return}const R=O.getRangeAt(0);if(!g.contains(R.startContainer)){L(null);return}const se=pa(g,R.startContainer,R.startOffset);if(se<0){L(null);return}const Z=ua(g,se);if(!Z){L(null);return}const X=R.getBoundingClientRect(),S=X.width===0&&X.height===0?(()=>{const F=document.createRange();return F.selectNodeContents(R.startContainer),F.collapse(!0),F.getBoundingClientRect()})():X;h.current={query:Z.query,caretIndex:Z.caretIndex,triggerIndex:Z.triggerIndex};const te=Bc(S,g);L(F=>{const ae={query:Z.query,...te};return F&&F.query===ae.query&&F.top===ae.top&&F.bottom===ae.bottom&&F.left===ae.left&&F.maxHeight===ae.maxHeight?F:ae})},[Y]),re=o.useCallback(g=>{t(g),D()},[t,D]);o.useEffect(()=>{const g=O=>{if(Dc.has(O.key))return;const R=Y(),se=O.target;!R||!se||!R.contains(se)||D()};return document.addEventListener("keyup",g,!0),()=>document.removeEventListener("keyup",g,!0)},[Y,D]);const le=o.useCallback(g=>{const O=Y();if(!O)return;let R=-1;const se=window.getSelection();if(se&&se.rangeCount>0){const F=se.getRangeAt(0);O.contains(F.startContainer)&&(R=pa(O,F.startContainer,F.startOffset))}if(R<0&&h.current&&(R=h.current.caretIndex),R<0)return;const Z=ua(O,R);if(!Z)return;const X=jo(O,{triggerIndex:Z.triggerIndex,caretIndex:R,username:g.username,display:g.name,userId:g.userId});if(!X)return;t(O.innerHTML);const S={userId:g.userId,username:g.username,email:g.email??void 0,display:g.name??g.username};W(F=>{const ae=new Map(F.map(q=>[q.userId,q]));return ae.set(S.userId,S),Array.from(ae.values())}),L(null),h.current=null;const te=X.caretPlainOffset;requestAnimationFrame(()=>{requestAnimationFrame(()=>{var Ee,ie;const F=Y();if(!F)return;F.focus(),Wo(F,te);const ae=window.getSelection(),q=ae==null?void 0:ae.anchorNode,ce=q instanceof Element?q.closest(".mention-chip"):(Ee=q==null?void 0:q.parentElement)==null?void 0:Ee.closest(".mention-chip");if(ce!=null&&ce.parentNode){const ge=document.createRange(),we=ce.nextSibling;we&&we.nodeType===Node.TEXT_NODE?ge.setStart(we,((ie=we.textContent)==null?void 0:ie.length)??0):ge.setStartAfter(ce),ge.collapse(!0),ae==null||ae.removeAllRanges(),ae==null||ae.addRange(ge)}})})},[Y,t]);o.useEffect(()=>{const g=new Set(ba(r).map(O=>O.toLowerCase()));W(O=>{const R=O.filter(se=>g.has(se.username.toLowerCase()));return R.length===O.length?O:R})},[r]),o.useEffect(()=>{if(!T)return;const g=O=>{const R=O.target;if(!R||m.current&&m.current.contains(R)||v.current&&v.current.contains(R))return;const se=Y();se&&se.contains(R)||L(null)};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[T,Y]);const I=o.useMemo(()=>C.slice(0,c),[C,c]);M.current=I,o.useEffect(()=>{if(!T)return;const g=O=>{const R=Y(),se=O.target;if(!R||!se||!R.contains(se))return;const Z=M.current;if(!(Z.length===0&&O.key!=="Escape"))if(O.key==="ArrowDown")O.preventDefault(),O.stopPropagation(),A(X=>(X+1)%Math.max(Z.length,1));else if(O.key==="ArrowUp")O.preventDefault(),O.stopPropagation(),A(X=>(X-1+Z.length)%Math.max(Z.length,1));else if(O.key==="Enter"||O.key==="Tab"){const X=Z[$.current];X&&(O.preventDefault(),O.stopPropagation(),le(X))}else O.key==="Escape"&&(O.preventDefault(),O.stopPropagation(),L(null))};return document.addEventListener("keydown",g,!0),()=>document.removeEventListener("keydown",g,!0)},[Y,le,T]),o.useEffect(()=>{if(!T||!v.current)return;const g=v.current.querySelector(`[data-mention-index="${V}"]`);g==null||g.scrollIntoView({block:"nearest"})},[V,T]);const H=u?_o(r):r,oe=T&&Q?tr.createPortal(e.jsxs("ul",{ref:v,style:{...Hc,left:T.left,top:T.top,bottom:T.bottom,maxHeight:T.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[G&&I.length===0&&e.jsx("li",{style:Uo,children:"Buscando…"}),!G&&I.length===0&&e.jsx("li",{style:Uo,children:T.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${T.query}”`}),I.map((g,O)=>{var R,se;return e.jsx("li",{children:e.jsxs("button",{type:"button","data-mention-index":O,onMouseDown:Z=>{Z.preventDefault(),le(g)},onMouseEnter:()=>A(O),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:O===V?"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.jsx("span",{style:{fontWeight:600,fontSize:13},children:((R=g.name)==null?void 0:R.trim())||`@${g.username}`}),e.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[(se=g.name)!=null&&se.trim()?`@${g.username}`:null,g.email].filter(Boolean).join(" · ")||`@${g.username}`})]})},g.userId)})]}),document.body):null;return e.jsxs("div",{ref:m,style:Ic,className:i,children:[e.jsx(Ao,{value:H,onChange:re,placeholder:l,minHeight:s,instanceId:b}),oe]})}function Pc({value:r,onChange:t,placeholder:n,minHeight:a,onSearchUsers:s,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:p}){return s?e.jsx(Vo,{value:r,onChange:t,onSearchUsers:s,onMentionsChange:l,placeholder:n,minHeight:a,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:p}):e.jsx(Ao,{value:r,onChange:t,placeholder:n,minHeight:a})}function Fc({title:r,subtitle:t,icon:n,actions:a,children:s,footer:l,className:i="",bodyClassName:c="p-4"}){const d=r||t||n||a;return e.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${i}`,children:[d&&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:[n&&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:n}),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})]})]}),a&&e.jsx("div",{className:"shrink-0",children:a})]}),e.jsx("div",{className:c,children:s}),l&&e.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:l})]})}const zc={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)"}},_c={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 jc({children:r,tone:t="neutral",size:n="sm",icon:a,dot:s=!1,className:l=""}){const i=zc[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 ${_c[n]} ${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}}),a&&e.jsx("span",{className:"shrink-0",children:a}),e.jsx("span",{className:"min-w-0 truncate",children:r})]})}const Ko={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)"}},Wc={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"},qc={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},Uc={xs:148,sm:164,md:184},Vc={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 Kc({value:r,options:t,onChange:n,size:a="sm",disabled:s=!1,loading:l=!1,stopPropagation:i=!1,ariaLabel:c="Cambiar estado",title:d="Cambiar estado",className:u,selectClassName:p,menuClassName:b,optionClassName:m,spinnerClassName:v}){const[y,E]=o.useState(!1),[h,$]=o.useState(!1),[M,T]=o.useState(-1),[L,C]=o.useState({}),k=o.useRef(null),V=o.useRef(null),A=o.useRef(null),K=t.find(D=>D.value===r)??t[0],W={...K!=null&&K.tone?Ko[K.tone]:void 0,...K==null?void 0:K.style},G=s||l||t.length===0,w=D=>{i&&D.stopPropagation()},Q=o.useCallback(()=>{E(!1),T(-1)},[]),_=o.useCallback(()=>{const D=k.current;if(!D)return;const re=D.getBoundingClientRect(),le=Math.max(re.width,Uc[a]),I=Math.min(Math.max(t.length,1)*38+12,260),H=window.innerHeight-re.bottom,oe=H<I&&re.top>H,g=Math.min(Math.max(8,re.left+re.width/2-le/2),window.innerWidth-le-8);C({position:"fixed",left:g,top:oe?void 0:re.bottom+6,bottom:oe?window.innerHeight-re.top+6:void 0,width:le,zIndex:9999})},[t.length,a]),P=o.useCallback(D=>{D.disabled||(n(D.value),Q())},[Q,n]);o.useEffect(()=>$(!0),[]),o.useEffect(()=>{if(!y)return;_();const D=t.findIndex(re=>re.value===r);T(D>=0?D:0)},[y,t,_,r]),o.useEffect(()=>{if(!y)return;function D(re){var I,H;const le=re.target;!((I=k.current)!=null&&I.contains(le))&&!((H=V.current)!=null&&H.contains(le))&&Q()}return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[Q,y]),o.useEffect(()=>{if(y)return window.addEventListener("resize",_),window.addEventListener("scroll",_,!0),()=>{window.removeEventListener("resize",_),window.removeEventListener("scroll",_,!0)}},[y,_]),o.useEffect(()=>{if(M<0||!A.current)return;const D=A.current.children[M];D==null||D.scrollIntoView({block:"nearest"})},[M]);function ne(D){if(!G){if(!y){["Enter"," ","ArrowDown","ArrowUp"].includes(D.key)&&(D.preventDefault(),E(!0));return}if(D.key==="Escape"){D.preventDefault(),Q();return}if(D.key==="ArrowDown"){D.preventDefault(),T(re=>Math.min(re+1,t.length-1));return}if(D.key==="ArrowUp"){D.preventDefault(),T(re=>Math.max(re-1,0));return}if(D.key==="Enter"||D.key===" "){D.preventDefault();const re=t[M];re&&P(re)}}}const Y=e.jsx("div",{ref:V,role:"listbox","aria-label":c,className:yr("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",b),style:{...L,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:w,onMouseDown:w,onPointerDown:w,children:e.jsx("div",{ref:A,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:t.map((D,re)=>{const le=D.value===r,I=re===M,H={...D.tone?Ko[D.tone]:void 0,...D.style};return e.jsxs("button",{type:"button",role:"option","aria-selected":le,disabled:D.disabled,onMouseEnter:()=>!D.disabled&&T(re),onMouseDown:oe=>{oe.preventDefault(),P(D)},className:yr("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",Vc[a],le?D.className:void 0,m),style:{...le?H:void 0,background:le?H.background??"color-mix(in srgb, var(--primary) 12%, transparent)":I?"var(--bg-hover)":"transparent",color:le?H.color??"var(--primary)":"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:le?e.jsx(B.HiCheck,{className:"h-4 w-4"}):null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:D.label})]},D.value)})})});return e.jsxs("span",{ref:k,className:yr("relative inline-flex shrink-0 items-center",u),onKeyDown:ne,onClick:w,onPointerDown:w,children:[e.jsx("button",{type:"button",disabled:G,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":y,title:d,onClick:()=>!G&&E(D=>!D),className:yr("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",Wc[a],K==null?void 0:K.className,p),style:W,children:e.jsx("span",{className:"min-w-0 truncate",children:(K==null?void 0:K.label)??r})}),e.jsx(B.HiChevronDown,{"aria-hidden":"true",className:yr("pointer-events-none absolute opacity-70 transition-transform",qc[a],y?"rotate-180":"rotate-0")}),l&&e.jsx("span",{"aria-hidden":"true",className:yr("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",v)}),y&&h&&tr.createPortal(Y,document.body)]})}function Gc({tabs:r,activeTabId:t,defaultActiveTabId:n,onTabChange:a,ariaLabel:s="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:d=""}){const u=r.find(y=>!y.disabled)??r[0],p=t??n??(u==null?void 0:u.id),b=r.find(y=>y.id===p)??u,m=y=>{y.disabled||a==null||a(y.id)},v=y=>{const E=r.filter($=>!$.disabled);if(!E.length||!b)return;const h=E.findIndex($=>$.id===b.id);(y.key==="ArrowRight"||y.key==="ArrowDown")&&(y.preventDefault(),m(E[(h+1)%E.length])),(y.key==="ArrowLeft"||y.key==="ArrowUp")&&(y.preventDefault(),m(E[(h-1+E.length)%E.length])),y.key==="Home"&&(y.preventDefault(),m(E[0])),y.key==="End"&&(y.preventDefault(),m(E[E.length-1]))};return e.jsxs("div",{className:i,children:[e.jsx("div",{role:"tablist","aria-label":s,onKeyDown:v,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 E=y.id===(b==null?void 0:b.id);return e.jsxs("button",{type:"button",role:"tab","aria-selected":E,"aria-controls":`${y.id}-panel`,id:`${y.id}-tab`,disabled:y.disabled,tabIndex:E?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:E?"var(--primary)":"var(--text-muted)",borderColor:E?"var(--primary)":"transparent",background:l==="pills"&&E?"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)})}),(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 ${d}`,children:b.content})]})}function kr(...r){return r.filter(Boolean).join(" ")}function Xc({steps:r,activeStepId:t,initialStepId:n,completedStepIds:a,defaultCompletedStepIds:s=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:c,allowBackNavigation:d=!0,showFooter:u=!0,previousLabel:p="Anterior",nextLabel:b="Siguiente",blockedNextLabel:m="Completa este paso",className:v="",headerClassName:y="",contentClassName:E="",footerClassName:h=""}){var Z;const $=((Z=r[0])==null?void 0:Z.id)??"",[M,T]=o.useState(n??$),[L,C]=o.useState(s),k=t??M,V=a??L,A=o.useMemo(()=>new Set(V),[V]),K=Math.max(0,r.findIndex(X=>X.id===k)),W=r[K]??r[0],G=r.length<=1?100:K/(r.length-1)*100,w=X=>{a||C(X),i==null||i(X)},Q=X=>{const S=r.find(te=>te.id===X);S&&(t||T(X),l==null||l(X,S))},_=X=>A.has(X),P=X=>r.slice(0,X).find(S=>!S.optional&&!A.has(S.id)),ne=X=>{const S=r[X];return!S||S.disabled?!1:X===K||d&&X<K?!0:!P(X)},Y=X=>{const S=r.findIndex(te=>te.id===X);return S>=0&&ne(S)},D=X=>{const S=r.findIndex(te=>te.id===X);if(S<0)return!1;if(!ne(S)){const te=P(S);return te&&(c==null||c(r[S],te)),!1}return Q(X),!0},re=(X=W==null?void 0:W.id)=>{!X||A.has(X)||w([...V,X])},le=(X=W==null?void 0:W.id)=>{if(!X)return;const S=r.findIndex(F=>F.id===X),te=V.filter(F=>{const ae=r.findIndex(q=>q.id===F);return ae>=0&&ae<S});w(te),S>=0&&K>S&&Q(X)},I=()=>K<=0?!1:D(r[K-1].id),H=()=>{const X=r[K+1];return X?D(X.id):!1},oe={activeStep:W,activeIndex:K,completedStepIds:V,isCompleted:_,isUnlocked:Y,completeStep:re,uncompleteStep:le,goToStep:D,goNext:H,goPrevious:I};if(!W)return null;const g=r[K+1],O=K>0,R=g?Y(g.id):!1,se=typeof W.content=="function"?W.content(oe):W.content;return e.jsxs("section",{className:kr("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",v),children:[e.jsxs("div",{className:kr("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:`${G}%`}})}),e.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${r.length}, minmax(0, 1fr))`},children:r.map((X,S)=>{const te=X.id===W.id,F=_(X.id),ae=ne(S),q=P(S);return e.jsxs("button",{type:"button",disabled:!ae,"aria-current":te?"step":void 0,"aria-disabled":!ae,title:!ae&&q?`Completa ${q.title}`:X.title,onClick:()=>D(X.id),className:kr("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",te&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",F&&!te&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!te&&!F&&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:kr("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",te&&"scale-x-100")}),e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:kr("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",te&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",F&&!te&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!F&&!te&&ae&&"border-[var(--border)] text-[var(--text-muted)]",!ae&&"border-[var(--border)] text-[var(--text-muted)]"),children:F?e.jsx(B.HiCheck,{className:"h-4 w-4"}):ae?S+1:e.jsx(B.HiLockClosed,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:kr("block truncate text-xs font-semibold transition-colors duration-200",te?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[S+1,". ",X.title]}),X.description&&e.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:X.description})]}),X.badge&&e.jsx("span",{className:"shrink-0",children:X.badge})]})]},X.id)})})]}),e.jsx("div",{className:kr("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",E),children:se},W.id),u&&e.jsxs("div",{className:kr("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",h),children:[e.jsx(He,{variant:"secondary",height:38,padding:"0 14px",icon:e.jsx(B.HiChevronLeft,{}),disabled:!O,onClick:I,children:p}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[e.jsxs("span",{children:["Paso ",K+1," de ",r.length]}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),e.jsxs("span",{children:[V.length," completados"]})]}),e.jsx(He,{height:38,padding:"0 14px",icon:e.jsx(B.HiChevronRight,{}),disabled:!g||!R,onClick:H,children:g&&!R?m:b})]})]})}const Yc={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"},Zc={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Qc(r,t){if(r){if(typeof r=="function"){r(t);return}r.current=t}}function Jc(r,t){return r!==void 0?String(r).length:t!==void 0?String(t).length:0}const Go=o.forwardRef(function({className:t="",wrapperClassName:n="",size:a="md",resize:s="vertical",autoResize:l=!1,minRows:i,maxRows:c,showCount:d=!1,maxCount:u,status:p="default",icon:b,action:m,style:v,value:y,defaultValue:E,maxLength:h,onInput:$,...M},T){const L=o.useRef(null),C=Jc(y,E),k=u??h,V=!!(b||m||d),A=p==="error"?"var(--danger)":p==="success"?"#16a34a":"var(--border)",K={...v??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},W=()=>{const w=L.current;!w||!l||(w.style.height="auto",w.style.height=`${w.scrollHeight}px`)};o.useEffect(W,[l,y]);const G=e.jsx("textarea",{...M,ref:w=>{L.current=w,Qc(T,w)},value:y,defaultValue:E,maxLength:h,"aria-invalid":p==="error"||M["aria-invalid"],onInput:w=>{W(),$==null||$(w)},style:{...K,borderColor:A},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 ${Yc[a]} ${Zc[l?"none":s]} ${b?"pl-8":""} ${m?"pr-10":""} ${t}`});return V?e.jsxs("span",{className:`relative block ${n}`,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}),G,m&&e.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:m}),d&&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:[C,k?`/${k}`:""]})]}):G});function Rc({label:r,containerClassName:t="",helperText:n,helperDisplay:a,error:s,labelAction:l,required:i,className:c="",status:d,...u}){return e.jsx(sa,{label:r,required:i,helperText:n,helperDisplay:a,error:s,labelAction:l,className:t,children:e.jsx(Go,{...u,required:i,status:s?"error":d,className:`w-full ${c}`})})}const Xo=[{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 ed(r){return Xo[r%Xo.length]}let rd=0;function ha(){return++rd}function Yo(r,t){return t?t instanceof RegExp?t.test(r):t(r):!0}function td(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function nd(r,t){const n=t.filter(Boolean);if(n.length===0)return[r.trim()].filter(Boolean);const a=new RegExp(`${n.map(s=>td(s)).join("|")}|\\r?\\n`,"g");return r.split(a).map(s=>s.trim()).filter(Boolean)}function ad({value:r,defaultValue:t,onChange:n,placeholder:a="Escribe y presiona Enter…",disabled:s=!1,className:l="",delimiters:i=[","],maxTags:c,allowDuplicates:d=!1,validate:u,label:p,helperText:b,helperDisplay:m="inline",error:v,required:y=!1}){const E=r!==void 0,h=!!v,$=!!b&&m==="tooltip"&&!h,[M,T]=o.useState(()=>(t??[]).map((F,ae)=>({id:ha(),value:F.trim(),colorIndex:ae})));o.useEffect(()=>{E&&T(F=>{const ae=r??[],q=new Map(F.map(ce=>[ce.value,ce]));return ae.map((ce,Ee)=>q.get(ce)??{id:ha(),value:ce,colorIndex:Ee})})},[E,r]);const L=M,[C,k]=o.useState(""),[V,A]=o.useState(null),[K,W]=o.useState(""),[G,w]=o.useState(!1),[Q,_]=o.useState(!1),P=o.useRef(null),ne=o.useRef(null),Y=o.useRef(null);function D(){_(!0),setTimeout(()=>_(!1),400)}function re(F){T(F),n==null||n(F.map(ae=>ae.value))}function le(F){let ae=L,q=!1,ce=!1;for(const Ee of F){const ie=Ee.trim();if(ie){if(c!==void 0&&ae.length>=c){ce=!0;break}if(!d&&ae.some(ge=>ge.value.toLowerCase()===ie.toLowerCase())){ce=!0;continue}if(!Yo(ie,u)){ce=!0;continue}ae=[...ae,{id:ha(),value:ie,colorIndex:ae.length}],q=!0}}return q&&re(ae),ce&&D(),q}function I(F){return le([F])}function H(F){const ae=L.filter(q=>q.id!==F);re(ae.map((q,ce)=>({...q,colorIndex:ce})))}function oe(F,ae){const q=ae.trim();if(A(null),W(""),!q){H(F);return}if(!(!d&&L.some(ce=>ce.id!==F&&ce.value.toLowerCase()===q.toLowerCase()))){if(!Yo(q,u)){D();return}re(L.map(ce=>ce.id===F?{...ce,value:q}:ce))}}function g(F){s||(A(F.id),W(F.value),setTimeout(()=>{var ae;return(ae=ne.current)==null?void 0:ae.select()},0))}function O(F){if(F.key==="Enter"||i.includes(F.key)){F.preventDefault(),I(C)&&k("");return}if(F.key==="Backspace"&&C===""&&L.length>0){F.preventDefault();const ae=L[L.length-1];H(ae.id)}}function R(F,ae){if(F.key==="Enter"){F.preventDefault(),oe(ae,K),setTimeout(()=>{var q;return(q=P.current)==null?void 0:q.focus()},0);return}F.key==="Escape"&&(F.preventDefault(),A(null),W(""),setTimeout(()=>{var q;return(q=P.current)==null?void 0:q.focus()},0))}function se(){var F;s||(F=P.current)==null||F.focus()}function Z(F){if(s)return;const ae=F.clipboardData.getData("text");if(!ae||!(i.some(ie=>ie&&ae.includes(ie))||ae.includes(`
29
+ `)))return;F.preventDefault();const ce=nd(ae,i);le(ce)&&k("")}function X(){const F=C.trim();F&&I(F)&&k("")}const S=h?"var(--danger)":G?"var(--primary)":"var(--border)",te=c!==void 0&&L.length>=c;return e.jsxs("div",{className:`flex flex-col gap-2 ${l}`,children:[(p||y||$)&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[p&&e.jsx("span",{children:p}),y&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),$?e.jsx(Zr,{content:b}):null]}),e.jsxs("div",{ref:Y,onClick:se,onFocus:()=>w(!0),onBlur:F=>{var ae;(ae=Y.current)!=null&&ae.contains(F.relatedTarget)||(w(!1),V!==null&&oe(V,K),V===null&&X())},style:{borderColor:S},className:`
30
30
  flex min-h-10 flex-wrap items-center gap-1.5 rounded-lg border
31
31
  bg-[var(--bg-input)] px-2.5 py-2 transition-colors
32
32
  ${s?"cursor-not-allowed opacity-60":"cursor-text"}
33
- ${re?"animate-[tag-shake_0.4s_ease]":""}
33
+ ${Q?"animate-[tag-shake_0.4s_ease]":""}
34
34
  `,children:[e.jsx("style",{children:`
35
35
  @keyframes tag-shake {
36
36
  0%,100% { transform: translateX(0); }
@@ -39,4 +39,4 @@ ${D}`,K=new Blob(["\uFEFF"+x],{type:"text/csv;charset=utf-8;"}),de=URL.createObj
39
39
  60% { transform: translateX(-3px); }
40
40
  80% { transform: translateX(3px); }
41
41
  }
42
- `}),L.map(B=>{const te=Fc(B.colorIndex);return Y===B.id?e.jsx("input",{ref:ae,value:U,disabled:s,onChange:z=>V(z.target.value),onKeyDown:z=>ne(z,B.id),onBlur:()=>oe(B.id,U),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(U.length+2,6)}ch`}},B.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:te.bg,color:te.text,border:`1px solid ${te.border}`},children:[e.jsx("span",{className:"truncate",children:B.value}),e.jsx("button",{type:"button","aria-label":`Editar "${B.value}"`,disabled:s,tabIndex:-1,onClick:z=>{z.stopPropagation(),A(B)},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(T.HiPencil,{className:"h-3 w-3"})}),e.jsx("button",{type:"button","aria-label":`Eliminar "${B.value}"`,disabled:s,tabIndex:-1,onClick:z=>{z.stopPropagation(),H(B.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(T.HiXMark,{className:"h-3.5 w-3.5"})})]},B.id)}),!R&&e.jsx("input",{ref:j,value:N,disabled:s,placeholder:L.length===0?a:"",onChange:B=>k(B.target.value),onKeyDown:q,onPaste:Q,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"})]}),e.jsx(Xr,{error:v,helperText:b,helperDisplay:m})]})}const qc={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function Uc({checked:r,disabled:t,onCheckedChange:n,size:a="sm",className:s="",...l}){const i=qc[a],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&&n(!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 zo=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),Vc=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function Gc(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 _o(r){return r.classList.contains("sidebar-scroll")||r.classList.contains("showcase-nav-scroll")}function jo(r){_o(r)&&r.querySelectorAll(".os-scrollbar-horizontal").forEach(t=>{t.style.display="none",t.style.height="0",t.style.pointerEvents="none"})}function Kc(r){const t=r.querySelector(Vc);return t instanceof HTMLElement?t:null}function Wo(){return o.useEffect(()=>{const r=new WeakMap;let t=0;const n=()=>{t=0,document.querySelectorAll(zo).forEach(l=>{if(!(l instanceof HTMLElement))return;if(Hn.OverlayScrollbars(l)){jo(l);return}if(!Gc(l))return;const c={overflow:_o(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},u=Kc(l),f=u?Hn.OverlayScrollbars({target:l,elements:{viewport:u}},c):Hn.OverlayScrollbars(l,c);jo(l),r.set(l,f)})},a=()=>{t||(t=window.requestAnimationFrame(n))};n();const s=new MutationObserver(a);return s.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","data-overlay-scroll"]}),window.addEventListener("resize",a),()=>{t&&window.cancelAnimationFrame(t),s.disconnect(),window.removeEventListener("resize",a),document.querySelectorAll(zo).forEach(l=>{var i;l instanceof HTMLElement&&((i=r.get(l))==null||i.destroy())})}},[]),null}function wr(r){const t=r.trim();return!t||t==="/"||t==="/."?"":(t.startsWith("/")?t:`/${t}`).replace(/\/+$/,"")}function qo(r){try{const t=new URL(r);return wr(t.pathname)}catch{return""}}function Xc(r){const t=wr(r);if(!t)return"";const n=t.match(/^\/apps\/[^/]+/i);if(n)return wr(n[0]);const a=t.split("/").filter(Boolean);return a.length===0?"":a.length>=2&&a[0].toLowerCase()==="apps"?wr(`/${a[0]}/${a[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(a[0].toLowerCase())?"":wr(`/${a[0]}`)}const ia="primeSuiteAppUrl",Yc={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"}},Uo={xs:20,sm:28,md:36,lg:48,xl:64},Vo=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],Zc={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Qc="bonsaif.bot",Jc="Bonsaif Bot",Rc={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Go(r){return typeof r=="string"?r.trim():""}function ed(r){var s;if(r!==void 0)return wr(r);const t=wr(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(ia)||"";i&&window.sessionStorage.setItem(ia,i);const c=window.sessionStorage.getItem(ia)||"",u=i||c;if(u){const f=qo(u);if(f&&!/^\/admin(\/|$)/i.test(f))return f}}catch{}const n=window.__NEXT_DATA__,a=(n==null?void 0:n.assetPrefix)||"";if(a){const l=a.startsWith("http")?qo(a):wr(a);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return Xc(window.location.pathname)}function rd(r){const t=r.split(/\s+/).map(n=>n.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 td(r){let t=0;for(const n of r)t=t*31+n.charCodeAt(0)&65535;return Vo[t%Vo.length]}function nd(r,t){return r===Qc||t===Jc}function ad(r,t){return`${r.replace(/\/$/,"")}${t}`}function Ko({userId:r,username:t,name:n,size:a="md",showName:s=!1,showTooltip:l,tooltipContent:i,fallbackLabel:c="Usuario",basePath:u,wrapperClassName:f="",labelClassName:p="",labelSize:b="xs",avatarVersion:m=0,className:v="",style:y}){const[S,h]=o.useState(!1),P=typeof r=="string"&&r.trim()&&r!=="undefined"&&r!=="null"?r.trim():"";o.useEffect(()=>{h(!1)},[P,m]);const{wh:O,text:E}=Yc[a],L=Go(n)||Go(t)||c,N=rd(L),k=ed(u),Y=nd(t,n),F=ad(k,"/favicon.svg"),U=o.useMemo(()=>{if(!P)return"";const W=new URLSearchParams;W.set("size",String(Uo[a])),m&&W.set("v",String(m));const j=W.toString();return`${k}/api/user/avatar/${encodeURIComponent(P)}${j?`?${j}`:""}`},[m,k,P,a]),V=Uo[a],J=Y?e.jsx("span",{className:`${O} ${Rc[a]} rounded-full flex items-center justify-center bg-[#071f1a] ring-1 ring-emerald-400/35 shadow-[0_0_0_1px_rgba(255,255,255,0.06)] flex-shrink-0 ${v}`,style:y,children:e.jsx("img",{src:F,alt:L,width:V,height:V,className:"h-full w-full object-contain"})}):U&&!S?e.jsx("img",{src:U,alt:L,width:V,height:V,className:`${O} rounded-full object-cover flex-shrink-0 ${v}`,style:y,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>h(!0)},`${P}-${m}`):e.jsx("span",{className:`${O} ${td(L)} ${E} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${v}`,style:y,title:L,children:N});if(s)return e.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${f}`,children:[J,e.jsx("span",{className:`min-w-0 truncate ${Zc[b]} font-medium text-[var(--text-main)] ${p}`,title:L,children:L})]});const C=l??!0,re=i??L;return C&&re?e.jsx(Mr,{as:"span",content:re,className:`inline-flex flex-shrink-0 ${f}`,children:J}):J}function od({href:r,className:t,children:n}){return e.jsx("a",{href:r,className:t,children:n})}function sd(r){return r.reduce((t,n)=>{const a=n.section??"Principal";return t[a]=[...t[a]??[],n],t},{})}function Xo({children:r,navItems:t=[],currentPath:n=typeof window>"u"?"/":window.location.pathname,user:a,appName:s="Bonsaif",appLogo:l,header:i,footer:c,onLogout:u,LinkComponent:f=od}){const[p,b]=o.useState(!1),m=sd(t);return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[e.jsx(Wo,{}),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(T.HiBars3,{className:"h-5 w-5"})}),p&&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 ${p?"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(T.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(T.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(([v,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(T.HiChevronDown,{className:"h-3.5 w-3.5"}),v]}),e.jsx("div",{className:"space-y-1",children:y.map(S=>{const h=n===S.href||n.startsWith(`${S.href}/`);return e.jsxs(f,{href:S.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${h?"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:S.icon??e.jsx(T.HiHome,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate",children:S.label})]},S.href)})})]},v))})}),e.jsxs("div",{className:"border-t border-white/10 p-3",children:[a&&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(Ko,{name:a.initials??a.name??a.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:a.name??"Usuario"}),a.email&&e.jsx("div",{className:"truncate text-xs text-white/45",children:a.email})]})]}),u&&e.jsxs(Fe,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:u,children:[e.jsx(T.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 Yo="bonsaif-ui:prime-auth-sso",ld={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"},ca={dashboard:e.jsx(T.HiChartBar,{className:"h-5 w-5"}),tickets:e.jsx(T.HiTicket,{className:"h-5 w-5"}),teams:e.jsx(T.HiUsers,{className:"h-5 w-5"}),projects:e.jsx(T.HiRectangleGroup,{className:"h-5 w-5"}),clients:e.jsx(T.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:e.jsx(T.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:e.jsx(T.HiUser,{className:"h-5 w-5"}),settings:e.jsx(T.HiCog6Tooth,{className:"h-5 w-5"}),notifications:e.jsx(T.HiBell,{className:"h-5 w-5"}),changelog:e.jsx(T.HiDocumentText,{className:"h-5 w-5"}),admin:e.jsx(T.HiShieldCheck,{className:"h-5 w-5"}),users:e.jsx(T.HiUsers,{className:"h-5 w-5"}),roles:e.jsx(T.HiShieldCheck,{className:"h-5 w-5"}),menus:e.jsx(T.HiCog6Tooth,{className:"h-5 w-5"}),guards:e.jsx(T.HiCalendarDays,{className:"h-5 w-5"}),vacations:e.jsx(T.HiCalendarDays,{className:"h-5 w-5"}),audit:e.jsx(T.HiListBullet,{className:"h-5 w-5"}),positions:e.jsx(T.HiBriefcase,{className:"h-5 w-5"}),ranks:e.jsx(T.HiListBullet,{className:"h-5 w-5"}),"email-inbox":e.jsx(T.HiInbox,{className:"h-5 w-5"}),"security-incidents":e.jsx(T.HiShieldCheck,{className:"h-5 w-5"})};function id(r){return r.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function cd(r){return/^\d+$/.test(r)||/^[a-f0-9]{8,}$/i.test(r)}function dd(r){const t=r.split("/").filter(Boolean);if(t.length===0||t.length===1&&t[0]==="dashboard")return[];const n=decodeURIComponent(t[t.length-1]),a=t.length>1?decodeURIComponent(t[t.length-2]):void 0,s=cd(n)&&a?a:n,l=ld[s]??id(s);return[{label:"Inicio",href:"/"},{label:l}]}function da(r){return(r==null?void 0:r.querySelector(":scope > .os-viewport"))??(r==null?void 0:r.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function ud(r){const t=r.split("/").filter(Boolean),n=t[t.length-1];if(!n)return e.jsx(T.HiHome,{className:"h-5 w-5"});if(ca[n])return ca[n];const a=t.length>1?t[t.length-2]:"";return ca[a]??e.jsx(T.HiHome,{className:"h-5 w-5"})}function fd(r){return r.includes("primeAuthOrigin")||r.includes("primeAuthProjectKey")}function Zo(){if(typeof window>"u")return!1;if(fd(window.location.href)){try{window.sessionStorage.setItem(Yo,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Yo)==="true"}catch{return!1}}function bd({title:r,subtitle:t,action:n,meta:a,icon:s,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:u,showBreadcrumbs:f=!0,contained:p=!1}){const b=o.useRef(null),[m,v]=o.useState(!1),[y,S]=o.useState(u??"/"),[h,P]=o.useState(()=>Zo()),[O,E]=o.useState(null),L=u??y,N=c??dd(L),k=s??ud(L),Y=f&&!h&&N.length>1,F=!Y;o.useEffect(()=>{u||S(window.location.pathname)},[u]),o.useEffect(()=>{P(Zo())},[]),o.useEffect(()=>{if(p){v(!1);return}let V=null,J=0,C=0;const re=()=>{const ae=b.current,Z=document.querySelector("[data-app-scroll='true']");return(ae==null?void 0:ae.closest(".os-viewport"))??(ae==null?void 0:ae.closest("[data-overlayscrollbars-viewport]"))??da(Z)??Z??window},W=()=>{const ae=V&&V!==window?V.scrollTop:window.scrollY;v(Z=>Z?ae>24:ae>72)},j=()=>{V==null||V.removeEventListener("scroll",W),V=re(),V.addEventListener("scroll",W,{passive:!0}),W()};return j(),J=window.requestAnimationFrame(j),C=window.setTimeout(j,120),()=>{window.cancelAnimationFrame(J),window.clearTimeout(C),V==null||V.removeEventListener("scroll",W)}},[p]),o.useEffect(()=>{if(p){E(null);return}let V=0;const J=[],C=()=>{const ee=b.current,se=ee==null?void 0:ee.parentElement,M=document.querySelector("[data-app-scroll='true']"),H=da(M)??M;if(!ee||!se||!H){E(null);return}const oe=se.getBoundingClientRect(),A=window.getComputedStyle(se),q=H.getBoundingClientRect(),ne=H instanceof HTMLElement&&H.clientWidth>0?H.clientWidth:q.width,ie=oe.left+parseFloat(A.paddingLeft||"0"),Q={marginLeft:Math.round(q.left-ie),width:Math.round(ne)};E(G=>G&&G.marginLeft===Q.marginLeft&&G.width===Q.width?G:Q)},re=()=>{window.cancelAnimationFrame(V),V=window.requestAnimationFrame(C)};re(),window.addEventListener("resize",re);const W=new ResizeObserver(re),j=b.current,ae=j==null?void 0:j.parentElement,Z=document.querySelector("[data-app-scroll='true']"),$=da(Z)??Z;return[ae,Z,$].forEach(ee=>{ee&&W.observe(ee)}),J.push(window.setTimeout(re,120)),J.push(window.setTimeout(re,280)),()=>{window.cancelAnimationFrame(V),window.removeEventListener("resize",re),W.disconnect(),J.forEach(ee=>window.clearTimeout(ee))}},[p]);const U={...O?{marginLeft:O.marginLeft,width:O.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:p?"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:p||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:b,"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 ${p?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${l}`,style:U,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":F?"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||F?"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||F?"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:Y?"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 ${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})]}),a&&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:a})]})]})}),n&&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(Ba.Provider,{value:{compact:!0,headerAction:!0},children:n})})]})})}function pd({children:r,currentPath:t=typeof window>"u"?"/":window.location.pathname,publicRoutes:n=["/","/login","/reset-password"],...a}){return n.includes(t)?e.jsx(e.Fragment,{children:r}):e.jsx(Xo,{currentPath:t,...a,children:r})}function Qo(){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 md(r,t,n){try{const a=new URL(r),s=a.searchParams.get("callbackUrl");if(s){const l=new URL(s,a.origin);return l.searchParams.set("theme",t),n&&(l.searchParams.set("primeAuthOrigin",window.location.origin),l.searchParams.set("primeAuthProjectKey",n)),a.searchParams.set("callbackUrl",`${l.pathname}${l.search}${l.hash}`),a.toString()}return a.searchParams.set("theme",t),n&&(a.searchParams.set("primeAuthOrigin",window.location.origin),a.searchParams.set("primeAuthProjectKey",n)),a.toString()}catch{return r}}function hd({name:r,src:t,projectKey:n}){const[a,s]=o.useState("system"),l=o.useRef(null);o.useEffect(()=>{s(Qo());const u=new MutationObserver(()=>s(Qo()));return u.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>u.disconnect()},[]);const i=o.useMemo(()=>md(t,a,n),[n,t,a]),c=o.useMemo(()=>{try{return new URL(i).origin}catch{return""}},[i]);return o.useEffect(()=>{if(!n)return;const u=n;function f(p){var v,y,S;if(p.source!==((v=l.current)==null?void 0:v.contentWindow)||c&&p.origin!==c)return;if(((y=p.data)==null?void 0:y.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!p.data.active}}));return}if(((S=p.data)==null?void 0:S.type)!=="prime-microservice:navigation")return;const b=p.data.path;if(!b||!b.startsWith("/")||b.startsWith("//"))return;const m=`/apps/${encodeURIComponent(u)}${b}`;`${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,n]),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 gd(){const[r,t]=o.useState(""),[n,a]=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;a(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:n?`min(${s.width}px, 100vw)`:96,height:n?`min(${s.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function Jo(r,t,n){const a=typeof r=="number"&&Number.isFinite(r)?r:t;return Math.max(t,Math.min(n,Math.ceil(a)))}function vd(r){const t=document.documentElement,n=new MutationObserver(r);n.observe(t,{attributes:!0,attributeFilter:["class"]});const a=window.matchMedia("(prefers-color-scheme: dark)");return a.addEventListener("change",r),()=>{n.disconnect(),a.removeEventListener("change",r)}}function xd(){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 yd(){return"light"}function wd({position:r="bottom-center"}){const t=o.useSyncExternalStore(vd,xd,yd);return e.jsx($a.Toaster,{position:r,theme:t,richColors:!0,closeButton:!0})}function kd({title:r,subtitle:t,actions:n,loading:a=!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||n)&&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]}),n?e.jsx("div",{className:"bonsaif-chart-card-actions shrink-0",children:n}):null]}),e.jsx("div",{className:"bonsaif-chart-card-body",children:a?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 nn=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function Ro(r,t){return r.color??nn[t%nn.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 tr=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 St(r){if(r==null||r==="")return null;const t=typeof r=="number"?r:Number(r);return Number.isFinite(t)?t:null}const ua={warning:70,danger:90};function an(r,t=ua){const n=t.warning??ua.warning,a=t.danger??ua.danger;return r>=a?"danger":r>=n?"warning":r<=0?"primary":"success"}function Ct(r,t){return sr(an(r,t))}function Zr(r,t=0){return Number.isFinite(r)?`${r.toFixed(t)}%`:"—"}function Qr(r,t=1){if(!Number.isFinite(r))return"—";const n=r<0?"-":"",a=Math.abs(r);if(a<1024)return`${n}${Math.round(a)} B`;const s=["KB","MB","GB","TB","PB"];let l=a/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`${n}${c.replace(/\.0$/,"")} ${s[i]}`}function es(r,t="bytes",n=1){if(!Number.isFinite(r))return"—";const a=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`${a}${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(n);return`${a}${u.replace(/\.0$/,"")} ${l[c]}`}function Jr(r,t){var n;for(let a=r.length-1;a>=0;a-=1){const s=St((n=r[a])==null?void 0:n[t]);if(s!==null)return s}return null}function nr({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 $r=680,Ar="ease-out",Nd={top:18,right:8,bottom:12,left:0};function Et(r){return{...Nd,...r}}function Mt(r){return r.map((t,n)=>({...t,color:Ro(t,n),label:t.label??t.key}))}function on(r,t){return!r.length||!t.length||r.every(n=>t.every(a=>St(n[a.key])===null))}function Ze(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function Lt(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function rs(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function sn(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function Sd(r,t=tr){if(r==null||r==="")return"—";const n=typeof r=="number"?r:Number(r);return Number.isFinite(n)?t(n):String(r)}function ts(r){return`bonsaif-grad-${r.replace(/[^a-zA-Z0-9_-]/g,"")}`}function Cd({active:r,label:t,payload:n,valueFormat:a=tr}){var c,u,f,p,b,m;if(!r||!(n!=null&&n.length))return null;const s=n.filter(v=>v.dataKey!=="base"&&v.name!=="base"&&v.value!==null&&v.value!==void 0);if(!s.length)return null;const l=((u=(c=s[0])==null?void 0:c.payload)==null?void 0:u.fullName)??((p=(f=s[0])==null?void 0:f.payload)==null?void 0:p.tooltipLabel)??((m=(b=s[0])==null?void 0:b.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((v,y)=>{const S=v.payload,h=S&&typeof S.display=="number"?S.display:v.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:v.color??"var(--primary)"}}),v.name??v.dataKey]}),e.jsx("span",{className:"bonsaif-chart-tooltip-value",children:Sd(h,a)})]},String(v.dataKey??v.name??y))})})]})}function Rr({valueFormat:r,content:t,cursor:n,offset:a=12,wrapperStyle:s,allowEscapeViewBox:l,reverseDirection:i,...c}){return e.jsx(ve.Tooltip,{...c,cursor:n,offset:a,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 ns(r,t,n){return n==null?-1:r.findIndex(a=>String(a[t])===String(n))}function as(r,t,n){if(n<=1)return null;const a=Math.max(0,Math.min(r,t)),s=Math.min(n-1,Math.max(r,t));return s-a<1||a===0&&s>=n-1?null:{startIndex:a,endIndex:s}}function ln(r,t,n={}){const{zoomable:a=!1,zoomMode:s="both",brushHeight:l=28,onZoomChange:i}=n,[c,u]=o.useState(null),[f,p]=o.useState(null),b=!!a&&r.length>1,m=b&&(s==="brush"||s==="both"),v=b&&(s==="drag"||s==="both"),y=o.useCallback(J=>{u(J),i==null||i(J)},[i]),S=o.useCallback(()=>{p(null),y(null)},[y]),h=!!c,P=o.useMemo(()=>!c||m?r:r.slice(c.startIndex,c.endIndex+1),[r,m,c]),O=o.useCallback((J,C)=>{const re=ns(r,t,J),W=ns(r,t,C);re<0||W<0||y(as(re,W,r.length))},[y,r,t]),E=o.useCallback(J=>{v&&((J==null?void 0:J.activeLabel)===void 0||(J==null?void 0:J.activeLabel)===null||p({leftLabel:J.activeLabel,rightLabel:J.activeLabel}))},[v]),L=o.useCallback(J=>{!v||!f||(J==null?void 0:J.activeLabel)===void 0||(J==null?void 0:J.activeLabel)===null||p(C=>C&&{...C,rightLabel:J.activeLabel})},[f,v]),N=o.useCallback(()=>{if(v){if(!f||f.rightLabel===null||f.rightLabel===void 0){p(null);return}O(f.leftLabel,f.rightLabel),p(null)}},[O,f,v]),k=o.useCallback(J=>{if(m){if(!J){y(null);return}y(as(J.startIndex??0,J.endIndex??r.length-1,r.length))}},[y,r.length,m]),Y=v?{onMouseDown:E,onMouseMove:L,onMouseUp:N,onMouseLeave:()=>{f&&N()}}:{},F=c??{startIndex:0,endIndex:Math.max(0,r.length-1)},U=e.jsxs(e.Fragment,{children:[v&&f&&f.rightLabel!==null&&f.rightLabel!==void 0?e.jsx(ve.ReferenceArea,{x1:f.leftLabel,x2:f.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,m?e.jsx(ve.Brush,{dataKey:t,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:F.startIndex,endIndex:F.endIndex,onChange:k,tickFormatter:J=>String(J)}):null]}),V=m?{bottom:Math.max(l+10,36)}:void 0;return{enabled:b,showBrush:m,showDrag:v,viewData:P,isZoomed:h,resetZoom:S,chartHandlers:Y,zoomNodes:U,marginExtra:V}}function cn({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 Ed({data:r,xKey:t,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:u=!0,showTooltip:f=!0,margin:p,valueFormat:b=tr,yDomain:m,ariaLabel:v="Gráfico de líneas",curve:y=!0,strokeWidth:S=2.25,zoomable:h=!1,zoomMode:P="both",brushHeight:O,onZoomChange:E}){const L=on(r,n),N=Mt(n),k=ln(r,t,{zoomable:h,zoomMode:P,brushHeight:O,onZoomChange:E}),Y=Et({...p,...k.marginExtra});return l?e.jsx(nr,{height:a}):L?e.jsx(ar,{height:a,text:i}):e.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${s}`,role:"img","aria-label":v,style:{height:a},children:[e.jsx(cn,{visible:k.isZoomed,onReset:k.resetZoom}),e.jsx(ve.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ve.LineChart,{data:k.viewData,margin:Y,...k.chartHandlers,children:[c?e.jsx(ve.CartesianGrid,{strokeDasharray:"2 8",stroke:Lt(),vertical:!1}):null,e.jsx(ve.XAxis,{dataKey:t,tick:Ze(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),e.jsx(ve.YAxis,{tick:Ze(),tickLine:!1,axisLine:!1,width:44,domain:m??["auto","auto"],tickFormatter:F=>b(Number(F)),dx:-2}),f?e.jsx(Rr,{valueFormat:b,cursor:{stroke:rs(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,u?e.jsx(ve.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:sn()}):null,N.map((F,U)=>e.jsx(ve.Line,{type:y?"monotone":"linear",dataKey:F.key,name:F.label,stroke:F.color,strokeWidth:U===0?S+.35:S,strokeOpacity:U===0?1:.88,isAnimationActive:!0,animationDuration:$r,animationEasing:Ar,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:F.color}},F.key)),k.zoomNodes]})})]})}function dn({data:r,xKey:t,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:u=!0,showTooltip:f=!0,margin:p,valueFormat:b=tr,yDomain:m,ariaLabel:v="Gráfico de área",stacked:y=!1,opacity:S=.22,zoomable:h=!1,zoomMode:P="both",brushHeight:O,onZoomChange:E}){const L=on(r,n),N=Mt(n),k=ln(r,t,{zoomable:h,zoomMode:P,brushHeight:O,onZoomChange:E}),Y=Et({...p,...k.marginExtra});return l?e.jsx(nr,{height:a}):L?e.jsx(ar,{height:a,text:i}):e.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${s}`,role:"img","aria-label":v,style:{height:a},children:[e.jsx(cn,{visible:k.isZoomed,onReset:k.resetZoom}),e.jsx(ve.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ve.AreaChart,{data:k.viewData,margin:Y,...k.chartHandlers,children:[e.jsx("defs",{children:N.map(F=>e.jsxs("linearGradient",{id:ts(F.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:F.color,stopOpacity:Math.min(.55,S+.28)}),e.jsx("stop",{offset:"48%",stopColor:F.color,stopOpacity:S*.5}),e.jsx("stop",{offset:"100%",stopColor:F.color,stopOpacity:0})]},F.key))}),c?e.jsx(ve.CartesianGrid,{strokeDasharray:"2 8",stroke:Lt(),vertical:!1}):null,e.jsx(ve.XAxis,{dataKey:t,tick:Ze(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),e.jsx(ve.YAxis,{tick:Ze(),tickLine:!1,axisLine:!1,width:44,domain:m??["auto","auto"],tickFormatter:F=>b(Number(F)),dx:-2}),f?e.jsx(Rr,{valueFormat:b,cursor:{stroke:rs(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,u?e.jsx(ve.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:sn()}):null,N.map(F=>e.jsx(ve.Area,{type:"monotone",dataKey:F.key,name:F.label,stroke:F.color,fill:`url(#${ts(F.key)})`,strokeWidth:2.25,stackId:y?"stack":void 0,isAnimationActive:!0,animationDuration:$r,animationEasing:Ar,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:F.color}},F.key)),k.zoomNodes]})})]})}function Md({data:r,xKey:t,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:u=!0,showTooltip:f=!0,margin:p,valueFormat:b=tr,yDomain:m,ariaLabel:v="Gráfico de barras",layout:y="vertical",mode:S="grouped",barRadius:h=6,categoryAxisWidth:P=64,zoomable:O=!1,zoomMode:E="both",brushHeight:L,onZoomChange:N}){const k=on(r,n),Y=Mt(n),F=y==="horizontal",U=ln(r,t,{zoomable:O&&!F,zoomMode:E,brushHeight:L,onZoomChange:N}),V=Et({...p,...U.marginExtra});return l?e.jsx(nr,{height:a}):k?e.jsx(ar,{height:a,text:i}):e.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${s}`,role:"img","aria-label":v,style:{height:a},children:[e.jsx(cn,{visible:U.isZoomed,onReset:U.resetZoom}),e.jsx(ve.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ve.BarChart,{data:U.viewData,margin:V,layout:F?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,...U.chartHandlers,children:[c?e.jsx(ve.CartesianGrid,{strokeDasharray:"2 8",stroke:Lt(),horizontal:!F,vertical:F}):null,F?e.jsxs(e.Fragment,{children:[e.jsx(ve.XAxis,{type:"number",tick:Ze(),tickLine:!1,axisLine:!1,tickFormatter:J=>b(Number(J)),domain:m??["auto","auto"]}),e.jsx(ve.YAxis,{type:"category",dataKey:t,tick:Ze(),tickLine:!1,axisLine:!1,width:P})]}):e.jsxs(e.Fragment,{children:[e.jsx(ve.XAxis,{dataKey:t,tick:Ze(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),e.jsx(ve.YAxis,{tick:Ze(),tickLine:!1,axisLine:!1,width:44,domain:m??["auto","auto"],tickFormatter:J=>b(Number(J)),dx:-2})]}),f?e.jsx(Rr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,u?e.jsx(ve.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:sn()}):null,Y.map((J,C)=>e.jsx(ve.Bar,{dataKey:J.key,name:J.label,fill:J.color,fillOpacity:C===0?1:.82,radius:F?[0,h,h,0]:[h,h,2,2],maxBarSize:20,stackId:S==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:$r,animationEasing:Ar},J.key)),U.zoomNodes]})})]})}function Ld(r){return e.jsx(ss,{...r,variant:"pie"})}function Td(r){return e.jsx(ss,{...r,variant:"donut",innerRadius:r.innerRadius??.62,cornerRadius:r.cornerRadius??10,padAngle:r.padAngle??2})}function os(r,t){return r==null||!Number.isFinite(r)?t:r>0&&r<=1?r*100:r}function ss({data:r,nameKey:t,valueKey:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showLegend:c=!0,showTooltip:u=!0,valueFormat:f=tr,ariaLabel:p,innerRadius:b,outerRadius:m,colors:v=[...nn],padAngle:y,cornerRadius:S,variant:h}){const P=r.map((C,re)=>({name:String(C[t]??""),value:St(C[n])??0,fill:v[re%v.length],row:C})).filter(C=>C.value>0),O=!P.length,E=h==="donut",L=P.length,N=os(b,E?62:12),k=os(m,78),Y=Math.min(y??(E?2:3),Math.max(.5,10/Math.max(1,L))),F=Math.min(S??(E?10:8),Math.max(2,36/Math.max(1,L)));if(l)return e.jsx(nr,{height:a});if(O)return e.jsx(ar,{height:a,text:i});const U=P.reduce((C,re)=>C+re.value,0),V=c?Math.min(96,28+Math.ceil(L/3)*22):0,J=Math.max(140,a-V);return e.jsx("div",{className:`bonsaif-chart bonsaif-${h}-chart w-full ${s}`,role:"img","aria-label":p??(h==="donut"?"Donut chart":"Pie chart"),style:{height:a},children:e.jsxs("div",{className:"bonsaif-pie-layout",children:[e.jsx("div",{className:"bonsaif-pie-plot",style:{height:J},children:e.jsx(ve.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ve.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[u?e.jsx(Rr,{valueFormat:f,isAnimationActive:!1}):null,e.jsx(ve.Pie,{data:P,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${N}%`,outerRadius:`${k}%`,startAngle:90,endAngle:-270,paddingAngle:Y,cornerRadius:F,minAngle:L>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:$r,animationEasing:Ar,label:!1,activeShape:$d,children:P.map(C=>e.jsx(ve.Cell,{fill:C.fill},C.name))}),E?e.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:f(U)}):null]})})}),c?e.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:P.map(C=>e.jsxs("li",{className:"bonsaif-pie-legend-item",children:[e.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:C.fill},"aria-hidden":!0}),e.jsx("span",{className:"bonsaif-pie-legend-label",title:C.name,children:C.name}),e.jsx("span",{className:"bonsaif-pie-legend-value",children:f(C.value)})]},C.name))}):null]})})}function $d(r){const{outerRadius:t=0,...n}=r;return e.jsx(ve.Sector,{...n,outerRadius:Number(t)+4,stroke:"var(--bg-card)",strokeWidth:2})}function Ad({data:r,dataKey:t,width:n="100%",height:a=36,tone:s="primary",color:l,fill:i=!0,className:c="",ariaLabel:u="Sparkline"}){const f=l??sr(s),p=r.map(k=>St(k[t])).filter(k=>k!==null);if(p.length<2)return e.jsx("div",{className:c,style:{width:n,height:a,color:"var(--text-muted)"},"aria-label":u});const b=120,m=36,v=3,y=1,S=Math.min(...p),P=Math.max(...p)-S||1,O=p.map((k,Y)=>{const F=y+Y/(p.length-1)*(b-y*2),U=m-v-(k-S)/P*(m-v*2);return{x:F,y:U}}),E=O.map((k,Y)=>`${Y===0?"M":"L"}${k.x.toFixed(2)} ${k.y.toFixed(2)}`).join(" "),L=`${E} L${O[O.length-1].x.toFixed(2)} ${m} L${O[0].x.toFixed(2)} ${m} Z`,N=`bonsaif-spark-${t.replace(/[^a-zA-Z0-9_-]/g,"")}-${s}`;return e.jsx("div",{className:`bonsaif-sparkline ${c}`,style:{width:n,height:a},role:"img","aria-label":u,children:e.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${b} ${m}`,preserveAspectRatio:"none",focusable:"false",children:[i?e.jsx("defs",{children:e.jsxs("linearGradient",{id:N,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:L,fill:`url(#${N})`}):null,e.jsx("path",{d:E,fill:"none",stroke:f,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function Dd({data:r,xKey:t,series:n,barSeries:a,lineSeries:s,height:l=280,className:i="",loading:c=!1,emptyText:u="Sin datos para mostrar",showGrid:f=!0,showLegend:p=!0,showTooltip:b=!0,margin:m,valueFormat:v=tr,yDomain:y,ariaLabel:S="Gráfico combinado",barRadius:h=6,zoomable:P=!1,zoomMode:O="both",brushHeight:E,onZoomChange:L}){const N=a??n.slice(0,Math.max(1,n.length-1)),k=s??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),Y=[...N,...k.filter(W=>!N.some(j=>j.key===W.key))],F=on(r,Y),U=Mt(N),V=Mt(Y),J=k.map(W=>{var ae;const j=V.find(Z=>Z.key===W.key);return{...W,label:W.label??W.key,color:W.color??(j==null?void 0:j.color)??((ae=V[0])==null?void 0:ae.color)}}),C=ln(r,t,{zoomable:P,zoomMode:O,brushHeight:E,onZoomChange:L}),re=Et({...m,...C.marginExtra});return c?e.jsx(nr,{height:l}):F?e.jsx(ar,{height:l,text:u}):e.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":S,style:{height:l},children:[e.jsx(cn,{visible:C.isZoomed,onReset:C.resetZoom}),e.jsx(ve.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ve.ComposedChart,{data:C.viewData,margin:re,barCategoryGap:"34%",...C.chartHandlers,children:[f?e.jsx(ve.CartesianGrid,{strokeDasharray:"2 8",stroke:Lt(),vertical:!1}):null,e.jsx(ve.XAxis,{dataKey:t,tick:Ze(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),e.jsx(ve.YAxis,{tick:Ze(),tickLine:!1,axisLine:!1,width:44,domain:y??["auto","auto"],tickFormatter:W=>v(Number(W)),dx:-2}),b?e.jsx(Rr,{valueFormat:v,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,p?e.jsx(ve.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:sn()}):null,U.map(W=>e.jsx(ve.Bar,{dataKey:W.key,name:W.label,fill:W.color,fillOpacity:.88,radius:[h,h,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:$r,animationEasing:Ar},W.key)),J.map(W=>e.jsx(ve.Line,{type:"monotone",dataKey:W.key,name:W.label,stroke:W.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:$r,animationEasing:Ar,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:W.color}},W.key)),C.zoomNodes]})})]})}function Id({data:r,xKey:t,valueKey:n,typeKey:a,height:s=280,className:l="",loading:i=!1,emptyText:c="Sin datos para mostrar",showGrid:u=!0,showTooltip:f=!0,margin:p,valueFormat:b=tr,ariaLabel:m="Gráfico waterfall",increaseColor:v="#34d399",decreaseColor:y="#f87171",totalColor:S="var(--primary)"}){const h=o.useMemo(()=>Bd(r,{xKey:t,valueKey:n,typeKey:a,increaseColor:v,decreaseColor:y,totalColor:S}),[r,t,n,a,v,y,S]),P=!h.length,O=Et(p);return i?e.jsx(nr,{height:s}):P?e.jsx(ar,{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(ve.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ve.BarChart,{data:h,margin:O,barCategoryGap:"42%",children:[u?e.jsx(ve.CartesianGrid,{strokeDasharray:"2 8",stroke:Lt(),vertical:!1}):null,e.jsx(ve.XAxis,{dataKey:"label",tick:Ze(),tickLine:!1,axisLine:!1,interval:0,dy:6}),e.jsx(ve.YAxis,{tick:Ze(),tickLine:!1,axisLine:!1,width:44,tickFormatter:E=>b(Number(E)),dx:-2}),f?e.jsx(Rr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,e.jsx(ve.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),e.jsx(ve.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:$r,animationEasing:Ar,children:h.map(E=>e.jsx(ve.Cell,{fill:E.color},E.label))})]})})})}function Bd(r,t){let n=0;return r.map((a,s)=>{const l=St(a[t.valueKey])??0,i=t.typeKey?String(a[t.typeKey]??""):"",c=i==="total"||s===r.length-1&&i!=="increase"&&i!=="decrease";let u="increase",f=0,p=0,b=l;return c&&i==="total"?(u="total",f=0,p=Math.abs(l),b=l,n=l):c&&s===r.length-1&&!i?(u="total",f=0,p=Math.abs(n),b=n):(u=i==="decrease"||l<0?"decrease":"increase",u==="decrease"?(f=n+l,p=Math.abs(l),n=n+l):(f=n,p=Math.abs(l),n=n+l),b=l),{label:String(a[t.xKey]??""),base:f,delta:p,display:b,kind:u,color:u==="total"?t.totalColor:u==="decrease"?t.decreaseColor:t.increaseColor}})}const et=135*Math.PI/180,fa=270*Math.PI/180;function Od({value:r,min:t=0,max:n=100,height:a=180,className:s="",loading:l=!1,empty:i=!1,emptyText:c="Sin datos para mostrar",label:u,valueFormat:f=tr,tone:p="primary",color:b,thresholds:m,ariaLabel:v="Gauge",animationDuration:y=700,thickness:S=9,showScale:h=!1}){const P=o.useId().replace(/:/g,""),O=n-t||1,E=Math.min(1,Math.max(0,(r-t)/O)),[L,N]=o.useState(y>0?0:E);if(o.useEffect(()=>{if(l||i)return;if(y<=0){N(E);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){N(E);return}let Z=0,$=0;N(M=>($=M,M));const ee=performance.now(),se=M=>{const H=Math.min(1,(M-ee)/y),oe=1-(1-H)**3;N($+(E-$)*oe),H<1&&(Z=requestAnimationFrame(se))};return Z=requestAnimationFrame(se),()=>cancelAnimationFrame(Z)},[E,y,l,i]),l)return e.jsx(nr,{height:a});if(i)return e.jsx(ar,{height:a,text:c});const k=100,Y=108,F=72,U=b??Hd(r,n,p,m),V=t+L*O,J=ls(k,Y,F,et,et+fa),C=et+Math.max(.001,L)*fa,re=ls(k,Y,F,et,C),W=un(k,Y,F,et),j=un(k,Y,F,et+fa);return e.jsx("div",{className:`bonsaif-chart bonsaif-gauge-chart flex flex-col items-center justify-center ${s}`,style:{height:a},children:e.jsxs("svg",{viewBox:"0 0 200 168",width:"100%",height:"100%",role:"img","aria-label":v,className:"overflow-visible",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:`bonsaif-gauge-${P}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[e.jsx("stop",{offset:"0%",stopColor:U,stopOpacity:.82}),e.jsx("stop",{offset:"100%",stopColor:U,stopOpacity:1})]})}),e.jsx("path",{d:J,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:S,strokeLinecap:"butt"}),e.jsx("path",{d:re,fill:"none",stroke:`url(#bonsaif-gauge-${P})`,strokeWidth:S,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),e.jsx("text",{x:k,y:Y-(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(V)}),u?e.jsx("text",{x:k,y:Y+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:u}):null,h?e.jsxs(e.Fragment,{children:[e.jsx("text",{x:W.x-2,y:W.y+S+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:f(t)}),e.jsx("text",{x:j.x+2,y:j.y+S+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:f(n)})]}):null]})})}function Hd(r,t,n,a){if(a!=null&&a.length){const l=[...a].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(n)return sr(n);const s=r/(t||1);return s>=.8?sr("success"):s>=.5?sr("warning"):sr("danger")}function un(r,t,n,a){return{x:r+n*Math.cos(a),y:t+n*Math.sin(a)}}function ls(r,t,n,a,s){const l=un(r,t,n,a),i=un(r,t,n,s),c=s-a,u=Math.abs(c)>Math.PI?1:0;return`M ${l.x} ${l.y} A ${n} ${n} 0 ${u} 1 ${i.x} ${i.y}`}function Pd({value:r,target:t,max:n,ranges:a,height:s=72,className:l="",loading:i=!1,empty:c=!1,emptyText:u="Sin datos para mostrar",label:f,subtitle:p,valueFormat:b=tr,tone:m="primary",showScale:v=!0,showStatus:y=!0,ariaLabel:S="Bullet chart"}){if(i)return e.jsx(nr,{height:s});if(c)return e.jsx(ar,{height:s,text:u});const h=n??Math.max(r,t,...(a==null?void 0:a.map(U=>U.value))??[],1)*1.05,O=[...a??[{value:h*.5,color:"color-mix(in srgb, var(--border) 72%, transparent)"},{value:h*.75,color:"color-mix(in srgb, var(--border) 48%, transparent)"},{value:h,color:"color-mix(in srgb, var(--border) 28%, transparent)"}]].sort((U,V)=>U.value-V.value),E=sr(m),L=Math.min(100,Math.max(0,r/h*100)),N=Math.min(100,Math.max(0,t/h*100)),k=r>=t,Y=[0,.25,.5,.75,1].map(U=>U*h),F=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":S,children:[e.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:O.map((U,V)=>{const J=V===0?0:O[V-1].value,C=Math.max(0,(U.value-J)/h*100);return e.jsx("div",{style:{width:`${C}%`,background:U.color??`color-mix(in srgb, var(--border) ${70-V*18}%, transparent)`}},V)})}),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:`${L}%`,background:E,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${E} 35%, transparent)`}})}),e.jsx("div",{className:"bonsaif-bullet-target absolute top-1/2 z-[1]",style:{left:`${N}%`,height:"72%",width:3,transform:"translate(-50%, -50%)",background:E,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${b(t)}`})]}),v?e.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:Y.map((U,V)=>{const J=U/h*100,C=V===0,re=V===Y.length-1;return e.jsxs("div",{className:"absolute top-0",style:{left:`${J}%`,transform:C?"none":re?"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:C?0:re?"auto":void 0,marginRight:re?0:void 0}}),e.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:C?"left":re?"right":"center"},children:b(U)})]},U)})}):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}),p?e.jsx("div",{className:"mt-0.5 text-[11px] leading-snug",style:{color:"var(--text-muted)"},children:p}):e.jsxs("div",{className:"mt-0.5 text-[11px] tabular-nums leading-snug",style:{color:"var(--text-muted)"},children:[e.jsx("span",{style:{color:E,fontWeight:600},children:b(r)}),e.jsxs("span",{children:[" / meta ",b(t)]})]}),y?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]}),F]}):F})}function Fd({data:r,value:t,timeKey:n="t",usageKey:a="usage",series:s,cores:l,height:i=220,className:c="",loading:u=!1,emptyText:f="Sin datos de CPU",showLegend:p=!1,showTooltip:b=!0,thresholds:m,label:v="CPU",ariaLabel:y="Uso de CPU"}){var N;const S=s??[{key:a,label:"Uso",color:Ct(t??Jr(r,a)??0,m)}],h=t??Jr(r,a)??Jr(r,((N=S[0])==null?void 0:N.key)??a),P=!u&&(!r.length||h===null);if(u)return e.jsx(nr,{height:i});if(P)return e.jsx(ar,{height:i,text:f});const O=Math.min(100,Math.max(0,h??0)),E=an(O,m),L=Ct(O,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:[v,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:L},children:Zr(O,O<10?1:0)})]}),e.jsx("div",{className:"bonsaif-metric-badge",style:{color:L,background:`color-mix(in srgb, ${L} 14%, transparent)`},children:E==="danger"?"Crítico":E==="warning"?"Alto":"Normal"})]}),e.jsx(dn,{data:r,xKey:n,series:S.map(k=>({...k,color:k.color??L})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:p,showTooltip:b,valueFormat:k=>Zr(k,0),ariaLabel:y,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function zd({used:r,total:t,cached:n,data:a=[],timeKey:s="t",usageKey:l="usage",height:i=220,className:c="",loading:u=!1,emptyText:f="Sin datos de memoria",showHistory:p=!0,showTooltip:b=!0,thresholds:m,label:v="RAM",ariaLabel:y="Uso de memoria"}){const S=t>0?t:1,h=Math.min(100,Math.max(0,r/S*100)),P=!u&&!(Number.isFinite(r)&&Number.isFinite(t)&&t>0);if(u)return e.jsx(nr,{height:i});if(P)return e.jsx(ar,{height:i,text:f});const O=an(h,m),E=Ct(h,m),L=Math.max(0,t-r),N=a.length>0?Jr(a,l)??h:h,k=Ct(N,m),Y=p&&a.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:v}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"bonsaif-metric-value",style:{color:E},children:Zr(h,h<10?1:0)}),e.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[Qr(r)," / ",Qr(t)]})]})]}),e.jsx("div",{className:"bonsaif-metric-badge",style:{color:E,background:`color-mix(in srgb, ${E} 14%, transparent)`},children:O==="danger"?"Crítico":O==="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(h),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${v} ${Zr(h,0)}`,children:e.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${h}%`,background:`linear-gradient(90deg, ${E}, color-mix(in srgb, ${E} 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"})," ",Qr(r)]}),n!=null&&Number.isFinite(n)?e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",Qr(n)]}):null,e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",Qr(L)]})]})]}),p&&a.length>1?e.jsx(dn,{data:a,xKey:s,series:[{key:l,label:"Uso",color:k}],height:Y,yDomain:[0,100],showLegend:!1,showTooltip:b,valueFormat:F=>Zr(F,0),ariaLabel:`${y} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const _d="color-mix(in srgb, var(--primary) 25%, #38bdf8)",jd="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function Wd({data:r,timeKey:t="t",inboundKey:n="in",outboundKey:a="out",inbound:s,outbound:l,unit:i="bytes",inboundLabel:c="Entrada",outboundLabel:u="Salida",inboundColor:f=_d,outboundColor:p=jd,height:b=240,className:m="",loading:v=!1,emptyText:y="Sin datos de red",showLegend:S=!1,showTooltip:h=!0,label:P="Network",ariaLabel:O="Tráfico de red"}){const E=s??Jr(r,n)??0,L=l??Jr(r,a)??0,N=!v&&r.length===0;if(v)return e.jsx(nr,{height:b});if(N)return e.jsx(ar,{height:b,text:y});const k=U=>es(U,i),F=Math.max(140,b-76);return e.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${m}`,role:"group","aria-label":O,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:P}),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(E),children:k(E)})]}),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:p},"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:p},title:k(L),children:k(L)})]})]})]})}),e.jsx("div",{className:"bonsaif-network-plot relative z-0",children:e.jsx(dn,{data:r,xKey:t,series:[{key:n,label:c,color:f},{key:a,label:u,color:p}],height:F,showLegend:S,showTooltip:h,valueFormat:k,ariaLabel:O,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const is=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],cs=["primeSuiteOrigin","primeSuiteProjectKey"];function qd(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const r=new URLSearchParams(window.location.search);for(const t of is){const n=r.get(t);if(n){const a=fn(n);if(a)return a}}if(typeof sessionStorage<"u")for(const t of cs){const n=sessionStorage.getItem(t);if(n)try{const a=new URL(n);if(a.origin&&a.origin!==window.location.origin)return a.origin}catch{const a=fn(n);if(a)return a}}if(document.referrer){const t=fn(document.referrer);if(t&&t!==window.location.origin)return t}return"*"}catch{return"*"}}function Ud(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const r=new URLSearchParams(window.location.search);for(const t of is)if(r.get(t))return"query";if(typeof sessionStorage<"u"){for(const t of cs)if(sessionStorage.getItem(t))return"sessionStorage"}if(document.referrer){const t=fn(document.referrer);if(t&&t!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function fn(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 Vd(r){const[t,n]=o.useState({}),[a,s]=o.useState(!1),l=o.useCallback(f=>a||t[f]?r[f]:void 0,[r,a,t]),i=o.useCallback(f=>{n(p=>({...p,[f]:!0}))},[]),c=o.useCallback(()=>{s(!0)},[]),u=o.useCallback(()=>{n({}),s(!1)},[]);return{submitted:a,touchedFields:t,getFieldError:l,touchField:i,submit:c,reset:u}}Object.defineProperty(_,"toast",{enumerable:!0,get:()=>$a.toast}),_.Alert=ul,_.AreaChart=dn,_.AuthShell=Xo,_.BarChart=Md,_.BonsaifButton=Gs,_.BonsaifUIToaster=wd,_.BulletChart=Pd,_.Button=Fe,_.CHART_PALETTE=nn,_.CalendarPicker=hl,_.ChartCard=kd,_.Checkbox=Wt,_.CodeBlock=wl,_.ComboChart=Dd,_.CompactFilterSelect=Sl,_.CompactSearchInput=Nl,_.ConfirmDialog=Ll,_.CopyButton=_n,_.CopyLinkButton=Dl,_.CpuChart=Fd,_.DataSheets=ai,_.DataTable=Ja,_.DateRangePicker=li,_.DonutChart=Td,_.Drawer=fi,_.DropdownMenu=di,_.DynamicDetailTabs=cl,_.EmailField=Oi,_.EmptyState=Pi,_.FieldHelperFooter=Xr,_.FieldLabelInfo=Kr,_.FieldLayoutEditor=qi,_.FileUpload=ji,_.FormField=uo,_.GaugeChart=Od,_.GlobalScrollbars=Wo,_.InputField=Qn,_.LineChart=Ed,_.LoadingState=Fa,_.MentionTextEditor=Bo,_.MicroserviceFrame=hd,_.Modal=qn,_.MouseTooltip=Mr,_.MultiSelect=Vi,_.NetworkChart=Wd,_.NumberField=Gi,_.PageHeader=bd,_.PageSearchInput=Ia,_.Pagination=Xi,_.PhoneField=Zi,_.PieChart=Ld,_.PrimeAuthRouteShell=pd,_.PrimeSuiteChatFrame=gd,_.RadioGroup=Qi,_.RamChart=zd,_.RichTextEditor=wc,_.SearchableSelect=Lr,_.SectionPanel=kc,_.Sparkline=Ad,_.StatusBadge=Cc,_.StatusSelect=$c,_.StepWizard=Dc,_.TableSkeleton=jt,_.Tabs=Ac,_.TagInput=Wc,_.TextInput=Qt,_.Textarea=Ho,_.TextareaField=Pc,_.Toggle=Uc,_.UserAvatar=Ko,_.WaterfallChart=Id,_.buildMentionQueryRegex=No,_.cn=gr,_.configureBonsaifUI=Ol,_.dedupeMentions=Lo,_.defaultValueFormat=tr,_.describeParentTargetOrigin=Ud,_.emailFormat=vi,_.extractMentionUsernames=aa,_.filterSelfMentions=mc,_.findMentionTriggerInEditor=ta,_.formatBytes=Qr,_.formatPercent=Zr,_.formatRate=es,_.getBonsaifUIConfig=Hl,_.getDataTablePreferencesEndpoint=Un,_.getPlainTextOffset=oa,_.highlightMentions=To,_.htmlToText=Eo,_.insertMentionInEditor=$o,_.isMentionTriggerBoundary=Co,_.isPlainOffsetInsideMentionChip=So,_.isValidEmail=Xn,_.isValidPhone=Yn,_.locateTextOffset=Yr,_.matches=Si,_.maxLength=wi,_.maxValue=Ni,_.mentionDisplayLabel=Mo,_.minLength=yi,_.minValue=ki,_.normalizeUsername=na,_.phoneCountryCodeOptions=po,_.phoneFormat=xi,_.placeCaretAtTextOffset=Ao,_.required=gi,_.resetBonsaifUIConfig=Pl,_.resolveMentions=pc,_.resolveParentTargetOrigin=qd,_.seriesColor=Ro,_.setBonsaifDataTablePreferencesEndpoint=Fl,_.toneColor=sr,_.usageColor=Ct,_.usageTone=an,_.useValidationVisibility=Vd,_.validateForm=Ci,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})}));
42
+ `}),L.map(F=>{const ae=ed(F.colorIndex);return V===F.id?e.jsx("input",{ref:ne,value:K,disabled:s,onChange:q=>W(q.target.value),onKeyDown:q=>R(q,F.id),onBlur:()=>oe(F.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`}},F.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:ae.bg,color:ae.text,border:`1px solid ${ae.border}`},children:[e.jsx("span",{className:"truncate",children:F.value}),e.jsx("button",{type:"button","aria-label":`Editar "${F.value}"`,disabled:s,tabIndex:-1,onClick:q=>{q.stopPropagation(),g(F)},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(B.HiPencil,{className:"h-3 w-3"})}),e.jsx("button",{type:"button","aria-label":`Eliminar "${F.value}"`,disabled:s,tabIndex:-1,onClick:q=>{q.stopPropagation(),H(F.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(B.HiXMark,{className:"h-3.5 w-3.5"})})]},F.id)}),!te&&e.jsx("input",{ref:P,value:C,disabled:s,placeholder:L.length===0?a:"",onChange:F=>k(F.target.value),onKeyDown:O,onPaste:Z,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"})]}),e.jsx(Qr,{error:v,helperText:b,helperDisplay:m})]})}const od=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;function ze(r){return String(r).padStart(2,"0")}function ga(r,t=Rr()){const n=r.trim();if(!n)return t;const a=n.match(od);if(!a)return t;const s=Number(a[1]),l=Number(a[2]),i=a[3]?Number(a[3]):0;return!Number.isFinite(s)||!Number.isFinite(l)||!Number.isFinite(i)||s<0||s>23||l<0||l>59||i<0||i>59?t:{hour24:s,minute:l,second:i}}function Tt(r,t=!0){const n=`${ze(r.hour24)}:${ze(r.minute)}`;return t?`${n}:${ze(r.second)}`:n}function dn(r){const t=r.hour24>=12?"PM":"AM";return{hour12:r.hour24%12===0?12:r.hour24%12,minute:r.minute,second:r.second,meridiem:t}}function Lt(r){let n=Math.min(12,Math.max(1,r.hour12))%12;return r.meridiem==="PM"&&(n+=12),{hour24:n,minute:Math.min(59,Math.max(0,r.minute)),second:Math.min(59,Math.max(0,r.second))}}function sd(r,t){const n=(t==null?void 0:t.use12Hour)??!1,a=(t==null?void 0:t.showSeconds)??!0,s=ga(r);if(n){const l=dn(s),i=`${l.hour12}:${ze(l.minute)}`;return`${a?`${i}:${ze(l.second)}`:i} ${l.meridiem}`}return Tt(s,a)}function Rr(){const r=new Date;return{hour24:r.getHours(),minute:r.getMinutes(),second:r.getSeconds()}}function ld(r=!0){return Tt(Rr(),r)}function va(r,t){const n=[];for(let a=r;a<=t;a+=1)n.push(a);return n}const Qe=36,xa=5,Zo=Math.floor(xa/2),id=52,cd=48,hr=18;function Qo(r){return r*Qe}function Jo(r){return Math.round(r/Qe)}function dd(r){return r.use12Hour??r.hour12??!1}function un({values:r,selected:t,onSelect:n,syncEpochRef:a,forceSyncAt:s=0,width:l=id,label:i,maxNumeric:c=59,isMeridiem:d=!1,isFocused:u=!1,onFocus:p,onAdvance:b,onBack:m,setColumnRef:v}){const y=o.useRef(null),E=o.useRef(null),h=o.useRef(null),$=o.useRef(""),M=o.useRef(0),T=o.useRef(!1),[L,C]=o.useState(t),[k,V]=o.useState(""),A=o.useCallback(g=>{$.current=g,V(g)},[]),K=o.useMemo(()=>[...Array(Zo).fill(""),...r,...Array(Zo).fill("")],[r]),W=o.useCallback(()=>{const g=y.current;if(!g)return t;const O=Jo(g.scrollTop),R=Math.min(Math.max(O,0),r.length-1);return r[R]??t},[t,r]),G=o.useCallback((g,O=!0)=>{const R=Math.min(Math.max(g,0),r.length-1),se=r[R],Z=y.current;!Z||!se||(E.current&&(window.clearTimeout(E.current),E.current=null),T.current=!0,M.current=R,Z.scrollTop=Qo(R),C(se),O&&se!==t&&n(se))},[n,t,r]);o.useLayoutEffect(()=>{E.current&&(window.clearTimeout(E.current),E.current=null),h.current&&(window.clearTimeout(h.current),h.current=null),A(""),C(t);const g=r.indexOf(t);if(g>=0&&(M.current=g),g<0||!y.current)return;const O=Qo(g);y.current.scrollTop!==O&&(y.current.scrollTop=O)},[s,t,A,r]);const w=o.useCallback(()=>{h.current&&(window.clearTimeout(h.current),h.current=null)},[]),Q=o.useCallback((g,O=!1)=>{w(),A("");const R=Number(g);if(!Number.isFinite(R))return;const se=Math.min(c,Math.max(0,R));let Z=ze(se),X=r.indexOf(Z);if(X<0){const S=Math.min(r.length-1,Math.max(0,se-(c===12?1:0)));Z=r[S]??Z,X=r.indexOf(Z)}X>=0&&G(X),O&&(b==null||b())},[w,c,b,G,A,r]),_=o.useCallback(g=>{const O=Math.floor(c/10),R=$.current;if(R===""){if(g>O){Q(String(g),!0);return}const Z=String(g);A(Z),h.current=window.setTimeout(()=>{Q($.current,!0)},1200);return}w();const se=+`${R}${g}`;se<=c?Q(String(se),!0):Q(String(g),!0)},[w,Q,c,A]),P=o.useCallback(g=>{w(),A(""),G(M.current+g)},[w,G,A]),ne=g=>{if(d){g.key==="a"||g.key==="A"?(g.preventDefault(),n("AM"),b==null||b()):g.key==="p"||g.key==="P"?(g.preventDefault(),n("PM"),b==null||b()):g.key==="ArrowUp"||g.key==="ArrowDown"?(g.preventDefault(),n(t==="AM"?"PM":"AM")):g.key==="Tab"&&(g.preventDefault(),g.shiftKey?m==null||m():b==null||b());return}if(/^\d$/.test(g.key)){g.preventDefault(),_(Number(g.key));return}g.key==="ArrowUp"?(g.preventDefault(),P(-1)):g.key==="ArrowDown"?(g.preventDefault(),P(1)):g.key==="Tab"&&(g.preventDefault(),w(),$.current!==""&&Q($.current,!1),g.shiftKey?m==null||m():b==null||b())},Y=o.useCallback(()=>{const g=a.current,O=y.current;O&&g===a.current&&G(Jo(O.scrollTop))},[G,a]),D=()=>{if($.current!=="")return;if(T.current){T.current=!1;const O=W();C(O);const R=r.indexOf(O);R>=0&&(M.current=R);return}C(W()),E.current&&window.clearTimeout(E.current);const g=a.current;E.current=window.setTimeout(()=>{g===a.current&&Y()},100)},re="absolute left-0 right-0 z-40 flex items-center justify-center border-0 bg-transparent p-0 transition-opacity duration-150 hover:opacity-80 focus:outline-none",le=Qe*xa,I=le+hr*2,H=k!==""?k:null,oe=H!==null;return e.jsxs("div",{ref:v,role:"spinbutton",tabIndex:u?0:-1,"aria-label":i,"aria-valuetext":H??t,"aria-valuenow":d?void 0:Number(t),onFocus:p,onMouseDown:()=>p==null?void 0:p(),onKeyDown:ne,onBlur:()=>{w(),$.current!==""&&Q($.current,!1)},className:"relative shrink-0 rounded-lg outline-none",style:{width:l,height:I,boxShadow:u?"0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent)":"none"},children:[e.jsx("button",{type:"button","aria-label":"Valor anterior",className:re,style:{top:0,height:hr,color:"var(--text-muted)",opacity:.35},onClick:()=>P(-1),children:e.jsx(B.HiChevronUp,{className:"h-3.5 w-3.5"})}),e.jsx("div",{ref:y,className:"absolute inset-x-0 overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",style:{top:hr,height:le,scrollSnapType:"y mandatory",scrollBehavior:"auto"},onScroll:D,onMouseUp:Y,onTouchEnd:Y,children:K.map((g,O)=>{const R=g!==""&&g===L;return e.jsx("button",{type:"button",tabIndex:-1,disabled:!g,onClick:()=>{if(!g)return;const se=r.indexOf(g);se>=0&&G(se)},className:"flex w-full items-center justify-center tabular-nums leading-none disabled:cursor-default",style:{height:Qe,scrollSnapAlign:"center",color:R?"var(--text-main)":"var(--text-muted)",fontSize:R?16:14,fontWeight:R?600:400,opacity:g?oe?R?0:.35:R?1:.35:0},children:g},`wheel-${O}-${g}`)})}),H!==null?e.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-50 flex items-center justify-center tabular-nums font-semibold leading-none",style:{top:hr+le/2-Qe/2,height:Qe,color:"var(--text-main)",fontSize:16,background:"var(--bg-card)"},children:H}):null,e.jsx("button",{type:"button","aria-label":"Valor siguiente",className:re,style:{bottom:0,height:hr,color:"var(--text-muted)",opacity:.35},onClick:()=>P(1),children:e.jsx(B.HiChevronDown,{className:"h-3.5 w-3.5"})})]})}function Ro(){return e.jsx("span",{className:"flex shrink-0 items-center justify-center self-center text-base font-medium tabular-nums leading-none",style:{color:"var(--text-muted)",height:Qe,width:14,opacity:.45},"aria-hidden":!0,children:":"})}function es({value:r,onChange:t,use12Hour:n,hour12:a,showSeconds:s=!1,title:l="Seleccionar hora",variant:i="panel",onCancel:c,onConfirm:d,className:u=""}){const p=i==="popover",b=p||!d,m=dd({use12Hour:n,hour12:a}),v=o.useRef(r),y=ga(r,Rr()),E=dn(y),[h,$]=o.useState(ze(m?E.hour12:y.hour24)),[M,T]=o.useState(ze(y.minute)),[L,C]=o.useState(ze(y.second)),[k,V]=o.useState(E.meridiem),[A,K]=o.useState(0),W=o.useRef(0),G=o.useRef(!1),w=o.useRef({hour:null,minute:null,second:null,meridiem:null}),[Q,_]=o.useState("hour"),P=o.useMemo(()=>{const ie=["hour","minute"];return s&&ie.push("second"),m&&ie.push("meridiem"),ie},[m,s]),ne=o.useCallback(ie=>{_(ge=>{const we=P.indexOf(ge);return P[(we+ie+P.length)%P.length]})},[P]);o.useEffect(()=>{var ie;(ie=w.current[Q])==null||ie.focus()},[Q]),o.useEffect(()=>{var ie;_("hour"),(ie=w.current.hour)==null||ie.focus()},[]),o.useEffect(()=>{if(r===v.current)return;v.current=r;const ie=ga(r,Rr()),ge=dn(ie);$(ze(m?ge.hour12:ie.hour24)),T(ze(ie.minute)),C(ze(ie.second)),V(ge.meridiem)},[m,r]);const Y=o.useMemo(()=>(m?va(1,12):va(0,23)).map(ie=>ze(ie)),[m]),D=o.useMemo(()=>va(0,59).map(ie=>ze(ie)),[]),re=D,le=o.useMemo(()=>["AM","PM"],[]),I=o.useCallback(()=>m?Lt({hour12:Number(h),minute:Number(M),second:Number(L),meridiem:k}):{hour24:Number(h),minute:Number(M),second:Number(L)},[h,m,k,M,L]),H=o.useCallback(ie=>{if(G.current)return;const ge=Tt(ie,s);v.current=ge,t(ge)},[t,s]),oe=o.useCallback(()=>{H(I())},[I,H]),g=ie=>{$(ie),b&&H(m?Lt({hour12:Number(ie),minute:Number(M),second:Number(L),meridiem:k}):{hour24:Number(ie),minute:Number(M),second:Number(L)})},O=ie=>{T(ie),b&&H(m?Lt({hour12:Number(h),minute:Number(ie),second:Number(L),meridiem:k}):{hour24:Number(h),minute:Number(ie),second:Number(L)})},R=ie=>{C(ie),b&&H(m?Lt({hour12:Number(h),minute:Number(M),second:Number(ie),meridiem:k}):{hour24:Number(h),minute:Number(M),second:Number(ie)})},se=ie=>{V(ie),b&&H(Lt({hour12:Number(h),minute:Number(M),second:Number(L),meridiem:ie}))},Z=o.useCallback(()=>(W.current+=1,K(W.current),W.current),[]),X=o.useCallback(ie=>{const ge=dn(ie),we=Tt(ie,s);v.current=we,$(ze(m?ge.hour12:ie.hour24)),T(ze(ie.minute)),C(ze(ie.second)),V(ge.meridiem),t(we)},[m,t,s]),S=()=>{G.current=!0,Z(),X(Rr()),queueMicrotask(()=>{const ie=Rr();Tt(ie,s)!==v.current&&(Z(),X(ie)),G.current=!1})},te=()=>{oe(),d==null||d()},F=Qe*xa,ae=F+hr*2,q=hr+F/2-Qe/2,ce=e.jsx("div",{className:"relative px-4 py-2",children:e.jsxs("div",{className:"relative mx-auto",style:{height:ae,maxWidth:"100%"},children:[e.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-10 rounded-xl",style:{top:q,height:Qe,background:"color-mix(in srgb, var(--primary) 10%, var(--bg-input))",border:"1px solid color-mix(in srgb, var(--primary) 22%, transparent)"}}),e.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-20",style:{top:hr,height:Qe*1.35,background:"linear-gradient(to bottom, var(--bg-card) 40%, transparent 100%)"}}),e.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-20",style:{bottom:hr,height:Qe*1.35,background:"linear-gradient(to top, var(--bg-card) 40%, transparent 100%)"}}),e.jsxs("div",{className:"relative z-30 flex h-full items-center justify-center gap-1",children:[e.jsx(un,{syncEpochRef:W,forceSyncAt:A,values:Y,selected:h,onSelect:g,label:"Horas",maxNumeric:m?12:23,isFocused:Q==="hour",onFocus:()=>_("hour"),onAdvance:()=>ne(1),onBack:()=>ne(-1),setColumnRef:ie=>{w.current.hour=ie}}),e.jsx(Ro,{}),e.jsx(un,{syncEpochRef:W,forceSyncAt:A,values:D,selected:M,onSelect:O,label:"Minutos",maxNumeric:59,isFocused:Q==="minute",onFocus:()=>_("minute"),onAdvance:()=>ne(1),onBack:()=>ne(-1),setColumnRef:ie=>{w.current.minute=ie}}),s?e.jsxs(e.Fragment,{children:[e.jsx(Ro,{}),e.jsx(un,{syncEpochRef:W,forceSyncAt:A,values:re,selected:L,onSelect:R,label:"Segundos",maxNumeric:59,isFocused:Q==="second",onFocus:()=>_("second"),onAdvance:()=>ne(1),onBack:()=>ne(-1),setColumnRef:ie=>{w.current.second=ie}})]}):null,m?e.jsx("div",{className:"ml-3 shrink-0 pl-1",children:e.jsx(un,{syncEpochRef:W,forceSyncAt:A,values:le,selected:k,onSelect:ie=>se(ie),width:cd,label:"AM o PM",isMeridiem:!0,isFocused:Q==="meridiem",onFocus:()=>_("meridiem"),onAdvance:()=>ne(1),onBack:()=>ne(-1),setColumnRef:ie=>{w.current.meridiem=ie}})}):null]})]})}),Ee=e.jsxs("div",{className:`flex items-center ${p?"justify-center px-3 py-2":"justify-between gap-2 px-3 py-2.5"}`,style:{borderTop:p?"none":"1px solid color-mix(in srgb, var(--border) 80%, transparent)"},children:[e.jsx(He,{variant:"ghost",size:"sm",onClick:S,className:p?"text-xs":void 0,children:"Ahora"}),!p&&(c||d)?e.jsxs("div",{className:"flex items-center gap-2",children:[c?e.jsx(He,{variant:"ghost",size:"sm",onClick:c,children:"Cancelar"}):null,d?e.jsx(He,{variant:"primary",size:"sm",onClick:te,children:"Listo"}):null]}):null]});return e.jsxs("div",{className:`overflow-hidden ${u}`,style:{borderRadius:p?12:14,border:p?"1px solid color-mix(in srgb, var(--border) 85%, transparent)":"1px solid var(--border)",background:"var(--bg-card)",boxShadow:p?"0 12px 40px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06)":"0 1px 3px rgba(15, 23, 42, 0.06)",minWidth:m?s?300:260:s?252:212},children:[!p&&l?e.jsx("div",{className:"border-b px-3 py-2.5",style:{borderColor:"color-mix(in srgb, var(--border) 80%, transparent)"},children:e.jsx("h3",{className:"text-sm font-semibold",style:{color:"var(--text-main)"},children:l})}):null,ce,Ee]})}function ud(r){return r.use12Hour??r.hour12??!1}function fd({label:r,value:t,onChange:n,use12Hour:a,hour12:s,showSeconds:l=!1,title:i="Seleccionar hora",placeholder:c="Seleccionar hora",disabled:d=!1,displayMode:u="popover",required:p,error:b,helperText:m,helperDisplay:v,className:y,contentClassName:E,className:h=""}){const $=u==="popover",[M,T]=o.useState(!1),L=o.useRef(null),[C,k]=o.useState({horizontal:"left",vertical:"bottom"}),V=ud({use12Hour:a,hour12:s}),A=o.useMemo(()=>t?sd(t,{use12Hour:V,showSeconds:l}):"",[V,l,t]);o.useEffect(()=>{if(!$||!M||!L.current)return;const G=L.current.getBoundingClientRect(),w=8,Q=V?l?300:260:l?252:212,_=276,P=G.left+Q>window.innerWidth-w,ne=G.right-Q>=w,Y=G.bottom+8+_>window.innerHeight-w,D=G.top-8-_>=w;k({horizontal:P&&ne?"right":"left",vertical:Y&&D?"top":"bottom"})},[V,$,M,l]),o.useEffect(()=>{if(!$||!M)return;function G(Q){L.current&&(L.current.contains(Q.target)||T(!1))}function w(Q){Q.key==="Escape"&&T(!1)}return document.addEventListener("mousedown",G),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",G),document.removeEventListener("keydown",w)}},[$,M]);const K=e.jsxs("button",{type:"button",disabled:d,onClick:()=>{d||T(G=>!G)},className:`flex h-10 w-full items-center justify-between gap-2 rounded-lg border px-2.5 text-sm transition-all duration-150 focus:outline-none disabled:cursor-not-allowed disabled:opacity-60 ${h}`,style:{background:"var(--bg-input)",borderColor:b?"var(--danger)":M?"var(--primary)":"var(--border)",color:A?"var(--text-main)":"var(--text-muted)",boxShadow:M?"0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent)":"none"},children:[e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2",children:[e.jsx(B.HiClock,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),e.jsx("span",{className:"truncate",children:A||c})]}),$?e.jsx(B.HiChevronDown,{className:`h-4 w-4 shrink-0 text-[var(--text-muted)] transition-transform duration-150 ${M?"rotate-180":""}`}):null]}),W=e.jsx(es,{variant:$?"popover":"panel",value:t||ld(l),onChange:n,use12Hour:V,showSeconds:l,title:i,onClose:()=>T(!1)});return e.jsx(sa,{label:r,required:p,error:b,helperText:m,helperDisplay:v,className:y,contentClassName:E,children:$?e.jsxs("div",{ref:L,className:"relative w-full",children:[K,M?e.jsx("div",{className:"absolute z-50",style:{...C.horizontal==="left"?{left:0}:{right:0},...C.vertical==="bottom"?{top:"calc(100% + 6px)"}:{bottom:"calc(100% + 6px)"}},children:W}):null]}):e.jsxs("div",{className:"space-y-2",children:[K,M?W:null]})})}const bd={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function pd({checked:r,disabled:t,onCheckedChange:n,size:a="sm",className:s="",...l}){const i=bd[a],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&&n(!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 rs=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),md=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function hd(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 ts(r){return r.classList.contains("sidebar-scroll")||r.classList.contains("showcase-nav-scroll")}function ns(r){ts(r)&&r.querySelectorAll(".os-scrollbar-horizontal").forEach(t=>{t.style.display="none",t.style.height="0",t.style.pointerEvents="none"})}function gd(r){const t=r.querySelector(md);return t instanceof HTMLElement?t:null}function as(){return o.useEffect(()=>{const r=new WeakMap;let t=0;const n=()=>{t=0,document.querySelectorAll(rs).forEach(l=>{if(!(l instanceof HTMLElement))return;if(Un.OverlayScrollbars(l)){ns(l);return}if(!hd(l))return;const c={overflow:ts(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},d=gd(l),u=d?Un.OverlayScrollbars({target:l,elements:{viewport:d}},c):Un.OverlayScrollbars(l,c);ns(l),r.set(l,u)})},a=()=>{t||(t=window.requestAnimationFrame(n))};n();const s=new MutationObserver(a);return s.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","data-overlay-scroll"]}),window.addEventListener("resize",a),()=>{t&&window.cancelAnimationFrame(t),s.disconnect(),window.removeEventListener("resize",a),document.querySelectorAll(rs).forEach(l=>{var i;l instanceof HTMLElement&&((i=r.get(l))==null||i.destroy())})}},[]),null}function Sr(r){const t=r.trim();return!t||t==="/"||t==="/."?"":(t.startsWith("/")?t:`/${t}`).replace(/\/+$/,"")}function os(r){try{const t=new URL(r);return Sr(t.pathname)}catch{return""}}function vd(r){const t=Sr(r);if(!t)return"";const n=t.match(/^\/apps\/[^/]+/i);if(n)return Sr(n[0]);const a=t.split("/").filter(Boolean);return a.length===0?"":a.length>=2&&a[0].toLowerCase()==="apps"?Sr(`/${a[0]}/${a[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(a[0].toLowerCase())?"":Sr(`/${a[0]}`)}const ya="primeSuiteAppUrl",xd={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"}},ss={xs:20,sm:28,md:36,lg:48,xl:64},ls=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],yd={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},wd="bonsaif.bot",Nd="Bonsaif Bot",kd={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function is(r){return typeof r=="string"?r.trim():""}function Sd(r){var s;if(r!==void 0)return Sr(r);const t=Sr(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(ya)||"";i&&window.sessionStorage.setItem(ya,i);const c=window.sessionStorage.getItem(ya)||"",d=i||c;if(d){const u=os(d);if(u&&!/^\/admin(\/|$)/i.test(u))return u}}catch{}const n=window.__NEXT_DATA__,a=(n==null?void 0:n.assetPrefix)||"";if(a){const l=a.startsWith("http")?os(a):Sr(a);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return vd(window.location.pathname)}function Cd(r){const t=r.split(/\s+/).map(n=>n.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 Ed(r){let t=0;for(const n of r)t=t*31+n.charCodeAt(0)&65535;return ls[t%ls.length]}function Md(r,t){return r===wd||t===Nd}function Td(r,t){return`${r.replace(/\/$/,"")}${t}`}function cs({userId:r,username:t,name:n,size:a="md",showName:s=!1,showTooltip:l,tooltipContent:i,fallbackLabel:c="Usuario",basePath:d,wrapperClassName:u="",labelClassName:p="",labelSize:b="xs",avatarVersion:m=0,className:v="",style:y}){const[E,h]=o.useState(!1),$=typeof r=="string"&&r.trim()&&r!=="undefined"&&r!=="null"?r.trim():"";o.useEffect(()=>{h(!1)},[$,m]);const{wh:M,text:T}=xd[a],L=is(n)||is(t)||c,C=Cd(L),k=Sd(d),V=Md(t,n),A=Td(k,"/favicon.svg"),K=o.useMemo(()=>{if(!$)return"";const _=new URLSearchParams;_.set("size",String(ss[a])),m&&_.set("v",String(m));const P=_.toString();return`${k}/api/user/avatar/${encodeURIComponent($)}${P?`?${P}`:""}`},[m,k,$,a]),W=ss[a],G=V?e.jsx("span",{className:`${M} ${kd[a]} rounded-full flex items-center justify-center bg-[#071f1a] ring-1 ring-emerald-400/35 shadow-[0_0_0_1px_rgba(255,255,255,0.06)] flex-shrink-0 ${v}`,style:y,children:e.jsx("img",{src:A,alt:L,width:W,height:W,className:"h-full w-full object-contain"})}):K&&!E?e.jsx("img",{src:K,alt:L,width:W,height:W,className:`${M} rounded-full object-cover flex-shrink-0 ${v}`,style:y,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>h(!0)},`${$}-${m}`):e.jsx("span",{className:`${M} ${Ed(L)} ${T} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${v}`,style:y,title:L,children:C});if(s)return e.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${u}`,children:[G,e.jsx("span",{className:`min-w-0 truncate ${yd[b]} font-medium text-[var(--text-main)] ${p}`,title:L,children:L})]});const w=l??!0,Q=i??L;return w&&Q?e.jsx($r,{as:"span",content:Q,className:`inline-flex flex-shrink-0 ${u}`,children:G}):G}function Ld({href:r,className:t,children:n}){return e.jsx("a",{href:r,className:t,children:n})}function $d(r){return r.reduce((t,n)=>{const a=n.section??"Principal";return t[a]=[...t[a]??[],n],t},{})}function ds({children:r,navItems:t=[],currentPath:n=typeof window>"u"?"/":window.location.pathname,user:a,appName:s="Bonsaif",appLogo:l,header:i,footer:c,onLogout:d,LinkComponent:u=Ld}){const[p,b]=o.useState(!1),m=$d(t);return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[e.jsx(as,{}),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(B.HiBars3,{className:"h-5 w-5"})}),p&&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 ${p?"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(B.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(B.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(([v,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(B.HiChevronDown,{className:"h-3.5 w-3.5"}),v]}),e.jsx("div",{className:"space-y-1",children:y.map(E=>{const h=n===E.href||n.startsWith(`${E.href}/`);return e.jsxs(u,{href:E.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${h?"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:E.icon??e.jsx(B.HiHome,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate",children:E.label})]},E.href)})})]},v))})}),e.jsxs("div",{className:"border-t border-white/10 p-3",children:[a&&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(cs,{name:a.initials??a.name??a.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:a.name??"Usuario"}),a.email&&e.jsx("div",{className:"truncate text-xs text-white/45",children:a.email})]})]}),d&&e.jsxs(He,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:d,children:[e.jsx(B.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 us="bonsaif-ui:prime-auth-sso",Ad={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"},wa={dashboard:e.jsx(B.HiChartBar,{className:"h-5 w-5"}),tickets:e.jsx(B.HiTicket,{className:"h-5 w-5"}),teams:e.jsx(B.HiUsers,{className:"h-5 w-5"}),projects:e.jsx(B.HiRectangleGroup,{className:"h-5 w-5"}),clients:e.jsx(B.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:e.jsx(B.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:e.jsx(B.HiUser,{className:"h-5 w-5"}),settings:e.jsx(B.HiCog6Tooth,{className:"h-5 w-5"}),notifications:e.jsx(B.HiBell,{className:"h-5 w-5"}),changelog:e.jsx(B.HiDocumentText,{className:"h-5 w-5"}),admin:e.jsx(B.HiShieldCheck,{className:"h-5 w-5"}),users:e.jsx(B.HiUsers,{className:"h-5 w-5"}),roles:e.jsx(B.HiShieldCheck,{className:"h-5 w-5"}),menus:e.jsx(B.HiCog6Tooth,{className:"h-5 w-5"}),guards:e.jsx(B.HiCalendarDays,{className:"h-5 w-5"}),vacations:e.jsx(B.HiCalendarDays,{className:"h-5 w-5"}),audit:e.jsx(B.HiListBullet,{className:"h-5 w-5"}),positions:e.jsx(B.HiBriefcase,{className:"h-5 w-5"}),ranks:e.jsx(B.HiListBullet,{className:"h-5 w-5"}),"email-inbox":e.jsx(B.HiInbox,{className:"h-5 w-5"}),"security-incidents":e.jsx(B.HiShieldCheck,{className:"h-5 w-5"})};function Dd(r){return r.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Id(r){return/^\d+$/.test(r)||/^[a-f0-9]{8,}$/i.test(r)}function Hd(r){const t=r.split("/").filter(Boolean);if(t.length===0||t.length===1&&t[0]==="dashboard")return[];const n=decodeURIComponent(t[t.length-1]),a=t.length>1?decodeURIComponent(t[t.length-2]):void 0,s=Id(n)&&a?a:n,l=Ad[s]??Dd(s);return[{label:"Inicio",href:"/"},{label:l}]}function Na(r){return(r==null?void 0:r.querySelector(":scope > .os-viewport"))??(r==null?void 0:r.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function Od(r){const t=r.split("/").filter(Boolean),n=t[t.length-1];if(!n)return e.jsx(B.HiHome,{className:"h-5 w-5"});if(wa[n])return wa[n];const a=t.length>1?t[t.length-2]:"";return wa[a]??e.jsx(B.HiHome,{className:"h-5 w-5"})}function Bd(r){return r.includes("primeAuthOrigin")||r.includes("primeAuthProjectKey")}function fs(){if(typeof window>"u")return!1;if(Bd(window.location.href)){try{window.sessionStorage.setItem(us,"true")}catch{}return!0}try{return window.sessionStorage.getItem(us)==="true"}catch{return!1}}function Pd({title:r,subtitle:t,action:n,meta:a,icon:s,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:d,showBreadcrumbs:u=!0,contained:p=!1}){const b=o.useRef(null),[m,v]=o.useState(!1),[y,E]=o.useState(d??"/"),[h,$]=o.useState(()=>fs()),[M,T]=o.useState(null),L=d??y,C=c??Hd(L),k=s??Od(L),V=u&&!h&&C.length>1,A=!V;o.useEffect(()=>{d||E(window.location.pathname)},[d]),o.useEffect(()=>{$(fs())},[]),o.useEffect(()=>{if(p){v(!1);return}let W=null,G=0,w=0;const Q=()=>{const ne=b.current,Y=document.querySelector("[data-app-scroll='true']");return(ne==null?void 0:ne.closest(".os-viewport"))??(ne==null?void 0:ne.closest("[data-overlayscrollbars-viewport]"))??Na(Y)??Y??window},_=()=>{const ne=W&&W!==window?W.scrollTop:window.scrollY;v(Y=>Y?ne>24:ne>72)},P=()=>{W==null||W.removeEventListener("scroll",_),W=Q(),W.addEventListener("scroll",_,{passive:!0}),_()};return P(),G=window.requestAnimationFrame(P),w=window.setTimeout(P,120),()=>{window.cancelAnimationFrame(G),window.clearTimeout(w),W==null||W.removeEventListener("scroll",_)}},[p]),o.useEffect(()=>{if(p){T(null);return}let W=0;const G=[],w=()=>{const re=b.current,le=re==null?void 0:re.parentElement,I=document.querySelector("[data-app-scroll='true']"),H=Na(I)??I;if(!re||!le||!H){T(null);return}const oe=le.getBoundingClientRect(),g=window.getComputedStyle(le),O=H.getBoundingClientRect(),R=H instanceof HTMLElement&&H.clientWidth>0?H.clientWidth:O.width,se=oe.left+parseFloat(g.paddingLeft||"0"),Z={marginLeft:Math.round(O.left-se),width:Math.round(R)};T(X=>X&&X.marginLeft===Z.marginLeft&&X.width===Z.width?X:Z)},Q=()=>{window.cancelAnimationFrame(W),W=window.requestAnimationFrame(w)};Q(),window.addEventListener("resize",Q);const _=new ResizeObserver(Q),P=b.current,ne=P==null?void 0:P.parentElement,Y=document.querySelector("[data-app-scroll='true']"),D=Na(Y)??Y;return[ne,Y,D].forEach(re=>{re&&_.observe(re)}),G.push(window.setTimeout(Q,120)),G.push(window.setTimeout(Q,280)),()=>{window.cancelAnimationFrame(W),window.removeEventListener("resize",Q),_.disconnect(),G.forEach(re=>window.clearTimeout(re))}},[p]);const K={...M?{marginLeft:M.marginLeft,width:M.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:p?"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:p||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:b,"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 ${p?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${l}`,style:K,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":A?"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||A?"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||A?"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:V?"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 ${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})]}),a&&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:a})]})]})}),n&&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(Ka.Provider,{value:{compact:!0,headerAction:!0},children:n})})]})})}function Fd({children:r,currentPath:t=typeof window>"u"?"/":window.location.pathname,publicRoutes:n=["/","/login","/reset-password"],...a}){return n.includes(t)?e.jsx(e.Fragment,{children:r}):e.jsx(ds,{currentPath:t,...a,children:r})}function bs(){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 zd(r,t,n){try{const a=new URL(r),s=a.searchParams.get("callbackUrl");if(s){const l=new URL(s,a.origin);return l.searchParams.set("theme",t),n&&(l.searchParams.set("primeAuthOrigin",window.location.origin),l.searchParams.set("primeAuthProjectKey",n)),a.searchParams.set("callbackUrl",`${l.pathname}${l.search}${l.hash}`),a.toString()}return a.searchParams.set("theme",t),n&&(a.searchParams.set("primeAuthOrigin",window.location.origin),a.searchParams.set("primeAuthProjectKey",n)),a.toString()}catch{return r}}function _d({name:r,src:t,projectKey:n}){const[a,s]=o.useState("system"),l=o.useRef(null);o.useEffect(()=>{s(bs());const d=new MutationObserver(()=>s(bs()));return d.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>d.disconnect()},[]);const i=o.useMemo(()=>zd(t,a,n),[n,t,a]),c=o.useMemo(()=>{try{return new URL(i).origin}catch{return""}},[i]);return o.useEffect(()=>{if(!n)return;const d=n;function u(p){var v,y,E;if(p.source!==((v=l.current)==null?void 0:v.contentWindow)||c&&p.origin!==c)return;if(((y=p.data)==null?void 0:y.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!p.data.active}}));return}if(((E=p.data)==null?void 0:E.type)!=="prime-microservice:navigation")return;const b=p.data.path;if(!b||!b.startsWith("/")||b.startsWith("//"))return;const m=`/apps/${encodeURIComponent(d)}${b}`;`${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",u),()=>{window.removeEventListener("message",u),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[c,n]),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 jd(){const[r,t]=o.useState(""),[n,a]=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 u;if(((u=c.data)==null?void 0:u.type)!=="prime-suite-chat:state")return;const d=!!c.data.active;a(d),l({width:ps(c.data.width,96,720),height:ps(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:n?`min(${s.width}px, 100vw)`:96,height:n?`min(${s.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function ps(r,t,n){const a=typeof r=="number"&&Number.isFinite(r)?r:t;return Math.max(t,Math.min(n,Math.ceil(a)))}function Wd(r){const t=document.documentElement,n=new MutationObserver(r);n.observe(t,{attributes:!0,attributeFilter:["class"]});const a=window.matchMedia("(prefers-color-scheme: dark)");return a.addEventListener("change",r),()=>{n.disconnect(),a.removeEventListener("change",r)}}function qd(){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 Ud(){return"light"}function Vd({position:r="bottom-center"}){const t=o.useSyncExternalStore(Wd,qd,Ud);return e.jsx(Wa.Toaster,{position:r,theme:t,richColors:!0,closeButton:!0})}function Kd({title:r,subtitle:t,actions:n,loading:a=!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||n)&&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]}),n?e.jsx("div",{className:"bonsaif-chart-card-actions shrink-0",children:n}):null]}),e.jsx("div",{className:"bonsaif-chart-card-body",children:a?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 fn=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function ms(r,t){return r.color??fn[t%fn.length]}function ir(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 ar=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 $t(r){if(r==null||r==="")return null;const t=typeof r=="number"?r:Number(r);return Number.isFinite(t)?t:null}const ka={warning:70,danger:90};function bn(r,t=ka){const n=t.warning??ka.warning,a=t.danger??ka.danger;return r>=a?"danger":r>=n?"warning":r<=0?"primary":"success"}function At(r,t){return ir(bn(r,t))}function et(r,t=0){return Number.isFinite(r)?`${r.toFixed(t)}%`:"—"}function rt(r,t=1){if(!Number.isFinite(r))return"—";const n=r<0?"-":"",a=Math.abs(r);if(a<1024)return`${n}${Math.round(a)} B`;const s=["KB","MB","GB","TB","PB"];let l=a/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`${n}${c.replace(/\.0$/,"")} ${s[i]}`}function hs(r,t="bytes",n=1){if(!Number.isFinite(r))return"—";const a=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`${a}${Math.round(s)} ${l[0]}`;let i=s/1024,c=1;for(;i>=1024&&c<l.length-1;)i/=1024,c+=1;const d=i>=100?i.toFixed(0):i.toFixed(n);return`${a}${d.replace(/\.0$/,"")} ${l[c]}`}function tt(r,t){var n;for(let a=r.length-1;a>=0;a-=1){const s=$t((n=r[a])==null?void 0:n[t]);if(s!==null)return s}return null}function or({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 sr({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 Ir=680,Hr="ease-out",Gd={top:18,right:8,bottom:12,left:0};function Dt(r){return{...Gd,...r}}function It(r){return r.map((t,n)=>({...t,color:ms(t,n),label:t.label??t.key}))}function pn(r,t){return!r.length||!t.length||r.every(n=>t.every(a=>$t(n[a.key])===null))}function Je(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function Ht(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function gs(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function mn(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function Xd(r,t=ar){if(r==null||r==="")return"—";const n=typeof r=="number"?r:Number(r);return Number.isFinite(n)?t(n):String(r)}function vs(r){return`bonsaif-grad-${r.replace(/[^a-zA-Z0-9_-]/g,"")}`}function Yd({active:r,label:t,payload:n,valueFormat:a=ar}){var c,d,u,p,b,m;if(!r||!(n!=null&&n.length))return null;const s=n.filter(v=>v.dataKey!=="base"&&v.name!=="base"&&v.value!==null&&v.value!==void 0);if(!s.length)return null;const l=((d=(c=s[0])==null?void 0:c.payload)==null?void 0:d.fullName)??((p=(u=s[0])==null?void 0:u.payload)==null?void 0:p.tooltipLabel)??((m=(b=s[0])==null?void 0:b.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((v,y)=>{const E=v.payload,h=E&&typeof E.display=="number"?E.display:v.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:v.color??"var(--primary)"}}),v.name??v.dataKey]}),e.jsx("span",{className:"bonsaif-chart-tooltip-value",children:Xd(h,a)})]},String(v.dataKey??v.name??y))})})]})}function nt({valueFormat:r,content:t,cursor:n,offset:a=12,wrapperStyle:s,allowEscapeViewBox:l,reverseDirection:i,...c}){return e.jsx(ye.Tooltip,{...c,cursor:n,offset:a,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(Yd,{valueFormat:r})})}function xs(r,t,n){return n==null?-1:r.findIndex(a=>String(a[t])===String(n))}function ys(r,t,n){if(n<=1)return null;const a=Math.max(0,Math.min(r,t)),s=Math.min(n-1,Math.max(r,t));return s-a<1||a===0&&s>=n-1?null:{startIndex:a,endIndex:s}}function hn(r,t,n={}){const{zoomable:a=!1,zoomMode:s="both",brushHeight:l=28,onZoomChange:i}=n,[c,d]=o.useState(null),[u,p]=o.useState(null),b=!!a&&r.length>1,m=b&&(s==="brush"||s==="both"),v=b&&(s==="drag"||s==="both"),y=o.useCallback(G=>{d(G),i==null||i(G)},[i]),E=o.useCallback(()=>{p(null),y(null)},[y]),h=!!c,$=o.useMemo(()=>!c||m?r:r.slice(c.startIndex,c.endIndex+1),[r,m,c]),M=o.useCallback((G,w)=>{const Q=xs(r,t,G),_=xs(r,t,w);Q<0||_<0||y(ys(Q,_,r.length))},[y,r,t]),T=o.useCallback(G=>{v&&((G==null?void 0:G.activeLabel)===void 0||(G==null?void 0:G.activeLabel)===null||p({leftLabel:G.activeLabel,rightLabel:G.activeLabel}))},[v]),L=o.useCallback(G=>{!v||!u||(G==null?void 0:G.activeLabel)===void 0||(G==null?void 0:G.activeLabel)===null||p(w=>w&&{...w,rightLabel:G.activeLabel})},[u,v]),C=o.useCallback(()=>{if(v){if(!u||u.rightLabel===null||u.rightLabel===void 0){p(null);return}M(u.leftLabel,u.rightLabel),p(null)}},[M,u,v]),k=o.useCallback(G=>{if(m){if(!G){y(null);return}y(ys(G.startIndex??0,G.endIndex??r.length-1,r.length))}},[y,r.length,m]),V=v?{onMouseDown:T,onMouseMove:L,onMouseUp:C,onMouseLeave:()=>{u&&C()}}:{},A=c??{startIndex:0,endIndex:Math.max(0,r.length-1)},K=e.jsxs(e.Fragment,{children:[v&&u&&u.rightLabel!==null&&u.rightLabel!==void 0?e.jsx(ye.ReferenceArea,{x1:u.leftLabel,x2:u.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,m?e.jsx(ye.Brush,{dataKey:t,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:A.startIndex,endIndex:A.endIndex,onChange:k,tickFormatter:G=>String(G)}):null]}),W=m?{bottom:Math.max(l+10,36)}:void 0;return{enabled:b,showBrush:m,showDrag:v,viewData:$,isZoomed:h,resetZoom:E,chartHandlers:V,zoomNodes:K,marginExtra:W}}function gn({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 Zd({data:r,xKey:t,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:p,valueFormat:b=ar,yDomain:m,ariaLabel:v="Gráfico de líneas",curve:y=!0,strokeWidth:E=2.25,zoomable:h=!1,zoomMode:$="both",brushHeight:M,onZoomChange:T}){const L=pn(r,n),C=It(n),k=hn(r,t,{zoomable:h,zoomMode:$,brushHeight:M,onZoomChange:T}),V=Dt({...p,...k.marginExtra});return l?e.jsx(or,{height:a}):L?e.jsx(sr,{height:a,text:i}):e.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${s}`,role:"img","aria-label":v,style:{height:a},children:[e.jsx(gn,{visible:k.isZoomed,onReset:k.resetZoom}),e.jsx(ye.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ye.LineChart,{data:k.viewData,margin:V,...k.chartHandlers,children:[c?e.jsx(ye.CartesianGrid,{strokeDasharray:"2 8",stroke:Ht(),vertical:!1}):null,e.jsx(ye.XAxis,{dataKey:t,tick:Je(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),e.jsx(ye.YAxis,{tick:Je(),tickLine:!1,axisLine:!1,width:44,domain:m??["auto","auto"],tickFormatter:A=>b(Number(A)),dx:-2}),u?e.jsx(nt,{valueFormat:b,cursor:{stroke:gs(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?e.jsx(ye.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:mn()}):null,C.map((A,K)=>e.jsx(ye.Line,{type:y?"monotone":"linear",dataKey:A.key,name:A.label,stroke:A.color,strokeWidth:K===0?E+.35:E,strokeOpacity:K===0?1:.88,isAnimationActive:!0,animationDuration:Ir,animationEasing:Hr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:A.color}},A.key)),k.zoomNodes]})})]})}function vn({data:r,xKey:t,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:p,valueFormat:b=ar,yDomain:m,ariaLabel:v="Gráfico de área",stacked:y=!1,opacity:E=.22,zoomable:h=!1,zoomMode:$="both",brushHeight:M,onZoomChange:T}){const L=pn(r,n),C=It(n),k=hn(r,t,{zoomable:h,zoomMode:$,brushHeight:M,onZoomChange:T}),V=Dt({...p,...k.marginExtra});return l?e.jsx(or,{height:a}):L?e.jsx(sr,{height:a,text:i}):e.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${s}`,role:"img","aria-label":v,style:{height:a},children:[e.jsx(gn,{visible:k.isZoomed,onReset:k.resetZoom}),e.jsx(ye.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ye.AreaChart,{data:k.viewData,margin:V,...k.chartHandlers,children:[e.jsx("defs",{children:C.map(A=>e.jsxs("linearGradient",{id:vs(A.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:A.color,stopOpacity:Math.min(.55,E+.28)}),e.jsx("stop",{offset:"48%",stopColor:A.color,stopOpacity:E*.5}),e.jsx("stop",{offset:"100%",stopColor:A.color,stopOpacity:0})]},A.key))}),c?e.jsx(ye.CartesianGrid,{strokeDasharray:"2 8",stroke:Ht(),vertical:!1}):null,e.jsx(ye.XAxis,{dataKey:t,tick:Je(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),e.jsx(ye.YAxis,{tick:Je(),tickLine:!1,axisLine:!1,width:44,domain:m??["auto","auto"],tickFormatter:A=>b(Number(A)),dx:-2}),u?e.jsx(nt,{valueFormat:b,cursor:{stroke:gs(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?e.jsx(ye.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:mn()}):null,C.map(A=>e.jsx(ye.Area,{type:"monotone",dataKey:A.key,name:A.label,stroke:A.color,fill:`url(#${vs(A.key)})`,strokeWidth:2.25,stackId:y?"stack":void 0,isAnimationActive:!0,animationDuration:Ir,animationEasing:Hr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:A.color}},A.key)),k.zoomNodes]})})]})}function Qd({data:r,xKey:t,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:p,valueFormat:b=ar,yDomain:m,ariaLabel:v="Gráfico de barras",layout:y="vertical",mode:E="grouped",barRadius:h=6,categoryAxisWidth:$=64,zoomable:M=!1,zoomMode:T="both",brushHeight:L,onZoomChange:C}){const k=pn(r,n),V=It(n),A=y==="horizontal",K=hn(r,t,{zoomable:M&&!A,zoomMode:T,brushHeight:L,onZoomChange:C}),W=Dt({...p,...K.marginExtra});return l?e.jsx(or,{height:a}):k?e.jsx(sr,{height:a,text:i}):e.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${s}`,role:"img","aria-label":v,style:{height:a},children:[e.jsx(gn,{visible:K.isZoomed,onReset:K.resetZoom}),e.jsx(ye.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ye.BarChart,{data:K.viewData,margin:W,layout:A?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,...K.chartHandlers,children:[c?e.jsx(ye.CartesianGrid,{strokeDasharray:"2 8",stroke:Ht(),horizontal:!A,vertical:A}):null,A?e.jsxs(e.Fragment,{children:[e.jsx(ye.XAxis,{type:"number",tick:Je(),tickLine:!1,axisLine:!1,tickFormatter:G=>b(Number(G)),domain:m??["auto","auto"]}),e.jsx(ye.YAxis,{type:"category",dataKey:t,tick:Je(),tickLine:!1,axisLine:!1,width:$})]}):e.jsxs(e.Fragment,{children:[e.jsx(ye.XAxis,{dataKey:t,tick:Je(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),e.jsx(ye.YAxis,{tick:Je(),tickLine:!1,axisLine:!1,width:44,domain:m??["auto","auto"],tickFormatter:G=>b(Number(G)),dx:-2})]}),u?e.jsx(nt,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,d?e.jsx(ye.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:mn()}):null,V.map((G,w)=>e.jsx(ye.Bar,{dataKey:G.key,name:G.label,fill:G.color,fillOpacity:w===0?1:.82,radius:A?[0,h,h,0]:[h,h,2,2],maxBarSize:20,stackId:E==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:Ir,animationEasing:Hr},G.key)),K.zoomNodes]})})]})}function Jd(r){return e.jsx(Ns,{...r,variant:"pie"})}function Rd(r){return e.jsx(Ns,{...r,variant:"donut",innerRadius:r.innerRadius??.62,cornerRadius:r.cornerRadius??10,padAngle:r.padAngle??2})}function ws(r,t){return r==null||!Number.isFinite(r)?t:r>0&&r<=1?r*100:r}function Ns({data:r,nameKey:t,valueKey:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showLegend:c=!0,showTooltip:d=!0,valueFormat:u=ar,ariaLabel:p,innerRadius:b,outerRadius:m,colors:v=[...fn],padAngle:y,cornerRadius:E,variant:h}){const $=r.map((w,Q)=>({name:String(w[t]??""),value:$t(w[n])??0,fill:v[Q%v.length],row:w})).filter(w=>w.value>0),M=!$.length,T=h==="donut",L=$.length,C=ws(b,T?62:12),k=ws(m,78),V=Math.min(y??(T?2:3),Math.max(.5,10/Math.max(1,L))),A=Math.min(E??(T?10:8),Math.max(2,36/Math.max(1,L)));if(l)return e.jsx(or,{height:a});if(M)return e.jsx(sr,{height:a,text:i});const K=$.reduce((w,Q)=>w+Q.value,0),W=c?Math.min(96,28+Math.ceil(L/3)*22):0,G=Math.max(140,a-W);return e.jsx("div",{className:`bonsaif-chart bonsaif-${h}-chart w-full ${s}`,role:"img","aria-label":p??(h==="donut"?"Donut chart":"Pie chart"),style:{height:a},children:e.jsxs("div",{className:"bonsaif-pie-layout",children:[e.jsx("div",{className:"bonsaif-pie-plot",style:{height:G},children:e.jsx(ye.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ye.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[d?e.jsx(nt,{valueFormat:u,isAnimationActive:!1}):null,e.jsx(ye.Pie,{data:$,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${C}%`,outerRadius:`${k}%`,startAngle:90,endAngle:-270,paddingAngle:V,cornerRadius:A,minAngle:L>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:Ir,animationEasing:Hr,label:!1,activeShape:eu,children:$.map(w=>e.jsx(ye.Cell,{fill:w.fill},w.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:u(K)}):null]})})}),c?e.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:$.map(w=>e.jsxs("li",{className:"bonsaif-pie-legend-item",children:[e.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:w.fill},"aria-hidden":!0}),e.jsx("span",{className:"bonsaif-pie-legend-label",title:w.name,children:w.name}),e.jsx("span",{className:"bonsaif-pie-legend-value",children:u(w.value)})]},w.name))}):null]})})}function eu(r){const{outerRadius:t=0,...n}=r;return e.jsx(ye.Sector,{...n,outerRadius:Number(t)+4,stroke:"var(--bg-card)",strokeWidth:2})}function ru({data:r,dataKey:t,width:n="100%",height:a=36,tone:s="primary",color:l,fill:i=!0,className:c="",ariaLabel:d="Sparkline"}){const u=l??ir(s),p=r.map(k=>$t(k[t])).filter(k=>k!==null);if(p.length<2)return e.jsx("div",{className:c,style:{width:n,height:a,color:"var(--text-muted)"},"aria-label":d});const b=120,m=36,v=3,y=1,E=Math.min(...p),$=Math.max(...p)-E||1,M=p.map((k,V)=>{const A=y+V/(p.length-1)*(b-y*2),K=m-v-(k-E)/$*(m-v*2);return{x:A,y:K}}),T=M.map((k,V)=>`${V===0?"M":"L"}${k.x.toFixed(2)} ${k.y.toFixed(2)}`).join(" "),L=`${T} L${M[M.length-1].x.toFixed(2)} ${m} L${M[0].x.toFixed(2)} ${m} Z`,C=`bonsaif-spark-${t.replace(/[^a-zA-Z0-9_-]/g,"")}-${s}`;return e.jsx("div",{className:`bonsaif-sparkline ${c}`,style:{width:n,height:a},role:"img","aria-label":d,children:e.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${b} ${m}`,preserveAspectRatio:"none",focusable:"false",children:[i?e.jsx("defs",{children:e.jsxs("linearGradient",{id:C,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:u,stopOpacity:.38}),e.jsx("stop",{offset:"100%",stopColor:u,stopOpacity:0})]})}):null,i?e.jsx("path",{d:L,fill:`url(#${C})`}):null,e.jsx("path",{d:T,fill:"none",stroke:u,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function tu({data:r,xKey:t,series:n,barSeries:a,lineSeries:s,height:l=280,className:i="",loading:c=!1,emptyText:d="Sin datos para mostrar",showGrid:u=!0,showLegend:p=!0,showTooltip:b=!0,margin:m,valueFormat:v=ar,yDomain:y,ariaLabel:E="Gráfico combinado",barRadius:h=6,zoomable:$=!1,zoomMode:M="both",brushHeight:T,onZoomChange:L}){const C=a??n.slice(0,Math.max(1,n.length-1)),k=s??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),V=[...C,...k.filter(_=>!C.some(P=>P.key===_.key))],A=pn(r,V),K=It(C),W=It(V),G=k.map(_=>{var ne;const P=W.find(Y=>Y.key===_.key);return{..._,label:_.label??_.key,color:_.color??(P==null?void 0:P.color)??((ne=W[0])==null?void 0:ne.color)}}),w=hn(r,t,{zoomable:$,zoomMode:M,brushHeight:T,onZoomChange:L}),Q=Dt({...m,...w.marginExtra});return c?e.jsx(or,{height:l}):A?e.jsx(sr,{height:l,text:d}):e.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":E,style:{height:l},children:[e.jsx(gn,{visible:w.isZoomed,onReset:w.resetZoom}),e.jsx(ye.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ye.ComposedChart,{data:w.viewData,margin:Q,barCategoryGap:"34%",...w.chartHandlers,children:[u?e.jsx(ye.CartesianGrid,{strokeDasharray:"2 8",stroke:Ht(),vertical:!1}):null,e.jsx(ye.XAxis,{dataKey:t,tick:Je(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),e.jsx(ye.YAxis,{tick:Je(),tickLine:!1,axisLine:!1,width:44,domain:y??["auto","auto"],tickFormatter:_=>v(Number(_)),dx:-2}),b?e.jsx(nt,{valueFormat:v,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,p?e.jsx(ye.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:mn()}):null,K.map(_=>e.jsx(ye.Bar,{dataKey:_.key,name:_.label,fill:_.color,fillOpacity:.88,radius:[h,h,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:Ir,animationEasing:Hr},_.key)),G.map(_=>e.jsx(ye.Line,{type:"monotone",dataKey:_.key,name:_.label,stroke:_.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:Ir,animationEasing:Hr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:_.color}},_.key)),w.zoomNodes]})})]})}function nu({data:r,xKey:t,valueKey:n,typeKey:a,height:s=280,className:l="",loading:i=!1,emptyText:c="Sin datos para mostrar",showGrid:d=!0,showTooltip:u=!0,margin:p,valueFormat:b=ar,ariaLabel:m="Gráfico waterfall",increaseColor:v="#34d399",decreaseColor:y="#f87171",totalColor:E="var(--primary)"}){const h=o.useMemo(()=>au(r,{xKey:t,valueKey:n,typeKey:a,increaseColor:v,decreaseColor:y,totalColor:E}),[r,t,n,a,v,y,E]),$=!h.length,M=Dt(p);return i?e.jsx(or,{height:s}):$?e.jsx(sr,{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(ye.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ye.BarChart,{data:h,margin:M,barCategoryGap:"42%",children:[d?e.jsx(ye.CartesianGrid,{strokeDasharray:"2 8",stroke:Ht(),vertical:!1}):null,e.jsx(ye.XAxis,{dataKey:"label",tick:Je(),tickLine:!1,axisLine:!1,interval:0,dy:6}),e.jsx(ye.YAxis,{tick:Je(),tickLine:!1,axisLine:!1,width:44,tickFormatter:T=>b(Number(T)),dx:-2}),u?e.jsx(nt,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,e.jsx(ye.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),e.jsx(ye.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:Ir,animationEasing:Hr,children:h.map(T=>e.jsx(ye.Cell,{fill:T.color},T.label))})]})})})}function au(r,t){let n=0;return r.map((a,s)=>{const l=$t(a[t.valueKey])??0,i=t.typeKey?String(a[t.typeKey]??""):"",c=i==="total"||s===r.length-1&&i!=="increase"&&i!=="decrease";let d="increase",u=0,p=0,b=l;return c&&i==="total"?(d="total",u=0,p=Math.abs(l),b=l,n=l):c&&s===r.length-1&&!i?(d="total",u=0,p=Math.abs(n),b=n):(d=i==="decrease"||l<0?"decrease":"increase",d==="decrease"?(u=n+l,p=Math.abs(l),n=n+l):(u=n,p=Math.abs(l),n=n+l),b=l),{label:String(a[t.xKey]??""),base:u,delta:p,display:b,kind:d,color:d==="total"?t.totalColor:d==="decrease"?t.decreaseColor:t.increaseColor}})}const at=135*Math.PI/180,Sa=270*Math.PI/180;function ou({value:r,min:t=0,max:n=100,height:a=180,className:s="",loading:l=!1,empty:i=!1,emptyText:c="Sin datos para mostrar",label:d,valueFormat:u=ar,tone:p="primary",color:b,thresholds:m,ariaLabel:v="Gauge",animationDuration:y=700,thickness:E=9,showScale:h=!1}){const $=o.useId().replace(/:/g,""),M=n-t||1,T=Math.min(1,Math.max(0,(r-t)/M)),[L,C]=o.useState(y>0?0:T);if(o.useEffect(()=>{if(l||i)return;if(y<=0){C(T);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){C(T);return}let Y=0,D=0;C(I=>(D=I,I));const re=performance.now(),le=I=>{const H=Math.min(1,(I-re)/y),oe=1-(1-H)**3;C(D+(T-D)*oe),H<1&&(Y=requestAnimationFrame(le))};return Y=requestAnimationFrame(le),()=>cancelAnimationFrame(Y)},[T,y,l,i]),l)return e.jsx(or,{height:a});if(i)return e.jsx(sr,{height:a,text:c});const k=100,V=108,A=72,K=b??su(r,n,p,m),W=t+L*M,G=ks(k,V,A,at,at+Sa),w=at+Math.max(.001,L)*Sa,Q=ks(k,V,A,at,w),_=xn(k,V,A,at),P=xn(k,V,A,at+Sa);return e.jsx("div",{className:`bonsaif-chart bonsaif-gauge-chart flex flex-col items-center justify-center ${s}`,style:{height:a},children:e.jsxs("svg",{viewBox:"0 0 200 168",width:"100%",height:"100%",role:"img","aria-label":v,className:"overflow-visible",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:`bonsaif-gauge-${$}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[e.jsx("stop",{offset:"0%",stopColor:K,stopOpacity:.82}),e.jsx("stop",{offset:"100%",stopColor:K,stopOpacity:1})]})}),e.jsx("path",{d:G,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:E,strokeLinecap:"butt"}),e.jsx("path",{d:Q,fill:"none",stroke:`url(#bonsaif-gauge-${$})`,strokeWidth:E,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),e.jsx("text",{x:k,y:V-(d?4:0),textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:28,fontWeight:700,letterSpacing:"-0.04em",className:"bonsaif-chart-gauge-label",children:u(W)}),d?e.jsx("text",{x:k,y:V+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:d}):null,h?e.jsxs(e.Fragment,{children:[e.jsx("text",{x:_.x-2,y:_.y+E+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(t)}),e.jsx("text",{x:P.x+2,y:P.y+E+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(n)})]}):null]})})}function su(r,t,n,a){if(a!=null&&a.length){const l=[...a].sort((c,d)=>c.value-d.value);let i=l[0].color;for(const c of l)r>=c.value&&(i=c.color);return i}if(n)return ir(n);const s=r/(t||1);return s>=.8?ir("success"):s>=.5?ir("warning"):ir("danger")}function xn(r,t,n,a){return{x:r+n*Math.cos(a),y:t+n*Math.sin(a)}}function ks(r,t,n,a,s){const l=xn(r,t,n,a),i=xn(r,t,n,s),c=s-a,d=Math.abs(c)>Math.PI?1:0;return`M ${l.x} ${l.y} A ${n} ${n} 0 ${d} 1 ${i.x} ${i.y}`}function lu({value:r,target:t,max:n,ranges:a,height:s=72,className:l="",loading:i=!1,empty:c=!1,emptyText:d="Sin datos para mostrar",label:u,subtitle:p,valueFormat:b=ar,tone:m="primary",showScale:v=!0,showStatus:y=!0,ariaLabel:E="Bullet chart"}){if(i)return e.jsx(or,{height:s});if(c)return e.jsx(sr,{height:s,text:d});const h=n??Math.max(r,t,...(a==null?void 0:a.map(K=>K.value))??[],1)*1.05,M=[...a??[{value:h*.5,color:"color-mix(in srgb, var(--border) 72%, transparent)"},{value:h*.75,color:"color-mix(in srgb, var(--border) 48%, transparent)"},{value:h,color:"color-mix(in srgb, var(--border) 28%, transparent)"}]].sort((K,W)=>K.value-W.value),T=ir(m),L=Math.min(100,Math.max(0,r/h*100)),C=Math.min(100,Math.max(0,t/h*100)),k=r>=t,V=[0,.25,.5,.75,1].map(K=>K*h),A=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,u?28:s*.42)},role:"img","aria-label":E,children:[e.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:M.map((K,W)=>{const G=W===0?0:M[W-1].value,w=Math.max(0,(K.value-G)/h*100);return e.jsx("div",{style:{width:`${w}%`,background:K.color??`color-mix(in srgb, var(--border) ${70-W*18}%, transparent)`}},W)})}),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:`${L}%`,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:`${C}%`,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 ${b(t)}`})]}),v?e.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:V.map((K,W)=>{const G=K/h*100,w=W===0,Q=W===V.length-1;return e.jsxs("div",{className:"absolute top-0",style:{left:`${G}%`,transform:w?"none":Q?"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:w?0:Q?"auto":void 0,marginRight:Q?0:void 0}}),e.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:w?"left":Q?"right":"center"},children:b(K)})]},K)})}):null]});return e.jsx("div",{className:`bonsaif-chart bonsaif-bullet-chart w-full ${l}`,children:u?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:u}),p?e.jsx("div",{className:"mt-0.5 text-[11px] leading-snug",style:{color:"var(--text-muted)"},children:p}):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:b(r)}),e.jsxs("span",{children:[" / meta ",b(t)]})]}),y?e.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:ir(k?"success":"warning")},children:k?"En meta":"Bajo meta"}):null]}),A]}):A})}function iu({data:r,value:t,timeKey:n="t",usageKey:a="usage",series:s,cores:l,height:i=220,className:c="",loading:d=!1,emptyText:u="Sin datos de CPU",showLegend:p=!1,showTooltip:b=!0,thresholds:m,label:v="CPU",ariaLabel:y="Uso de CPU"}){var C;const E=s??[{key:a,label:"Uso",color:At(t??tt(r,a)??0,m)}],h=t??tt(r,a)??tt(r,((C=E[0])==null?void 0:C.key)??a),$=!d&&(!r.length||h===null);if(d)return e.jsx(or,{height:i});if($)return e.jsx(sr,{height:i,text:u});const M=Math.min(100,Math.max(0,h??0)),T=bn(M,m),L=At(M,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:[v,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:L},children:et(M,M<10?1:0)})]}),e.jsx("div",{className:"bonsaif-metric-badge",style:{color:L,background:`color-mix(in srgb, ${L} 14%, transparent)`},children:T==="danger"?"Crítico":T==="warning"?"Alto":"Normal"})]}),e.jsx(vn,{data:r,xKey:n,series:E.map(k=>({...k,color:k.color??L})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:p,showTooltip:b,valueFormat:k=>et(k,0),ariaLabel:y,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function cu({used:r,total:t,cached:n,data:a=[],timeKey:s="t",usageKey:l="usage",height:i=220,className:c="",loading:d=!1,emptyText:u="Sin datos de memoria",showHistory:p=!0,showTooltip:b=!0,thresholds:m,label:v="RAM",ariaLabel:y="Uso de memoria"}){const E=t>0?t:1,h=Math.min(100,Math.max(0,r/E*100)),$=!d&&!(Number.isFinite(r)&&Number.isFinite(t)&&t>0);if(d)return e.jsx(or,{height:i});if($)return e.jsx(sr,{height:i,text:u});const M=bn(h,m),T=At(h,m),L=Math.max(0,t-r),C=a.length>0?tt(a,l)??h:h,k=At(C,m),V=p&&a.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:v}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"bonsaif-metric-value",style:{color:T},children:et(h,h<10?1:0)}),e.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[rt(r)," / ",rt(t)]})]})]}),e.jsx("div",{className:"bonsaif-metric-badge",style:{color:T,background:`color-mix(in srgb, ${T} 14%, transparent)`},children:M==="danger"?"Crítico":M==="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(h),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${v} ${et(h,0)}`,children:e.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${h}%`,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"})," ",rt(r)]}),n!=null&&Number.isFinite(n)?e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",rt(n)]}):null,e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",rt(L)]})]})]}),p&&a.length>1?e.jsx(vn,{data:a,xKey:s,series:[{key:l,label:"Uso",color:k}],height:V,yDomain:[0,100],showLegend:!1,showTooltip:b,valueFormat:A=>et(A,0),ariaLabel:`${y} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const du="color-mix(in srgb, var(--primary) 25%, #38bdf8)",uu="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function fu({data:r,timeKey:t="t",inboundKey:n="in",outboundKey:a="out",inbound:s,outbound:l,unit:i="bytes",inboundLabel:c="Entrada",outboundLabel:d="Salida",inboundColor:u=du,outboundColor:p=uu,height:b=240,className:m="",loading:v=!1,emptyText:y="Sin datos de red",showLegend:E=!1,showTooltip:h=!0,label:$="Network",ariaLabel:M="Tráfico de red"}){const T=s??tt(r,n)??0,L=l??tt(r,a)??0,C=!v&&r.length===0;if(v)return e.jsx(or,{height:b});if(C)return e.jsx(sr,{height:b,text:y});const k=K=>hs(K,i),A=Math.max(140,b-76);return e.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${m}`,role:"group","aria-label":M,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:$}),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:u},"aria-hidden":!0}),c]}),e.jsx("div",{className:"mt-1 truncate text-xl font-bold tabular-nums leading-tight tracking-tight",style:{color:u},title:k(T),children:k(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:p},"aria-hidden":!0}),d]}),e.jsx("div",{className:"mt-1 truncate text-lg font-semibold tabular-nums leading-tight tracking-tight opacity-95",style:{color:p},title:k(L),children:k(L)})]})]})]})}),e.jsx("div",{className:"bonsaif-network-plot relative z-0",children:e.jsx(vn,{data:r,xKey:t,series:[{key:n,label:c,color:u},{key:a,label:d,color:p}],height:A,showLegend:E,showTooltip:h,valueFormat:k,ariaLabel:M,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const Ss=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],Cs=["primeSuiteOrigin","primeSuiteProjectKey"];function bu(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const r=new URLSearchParams(window.location.search);for(const t of Ss){const n=r.get(t);if(n){const a=yn(n);if(a)return a}}if(typeof sessionStorage<"u")for(const t of Cs){const n=sessionStorage.getItem(t);if(n)try{const a=new URL(n);if(a.origin&&a.origin!==window.location.origin)return a.origin}catch{const a=yn(n);if(a)return a}}if(document.referrer){const t=yn(document.referrer);if(t&&t!==window.location.origin)return t}return"*"}catch{return"*"}}function pu(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const r=new URLSearchParams(window.location.search);for(const t of Ss)if(r.get(t))return"query";if(typeof sessionStorage<"u"){for(const t of Cs)if(sessionStorage.getItem(t))return"sessionStorage"}if(document.referrer){const t=yn(document.referrer);if(t&&t!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function yn(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 mu(r){const[t,n]=o.useState({}),[a,s]=o.useState(!1),l=o.useCallback(u=>a||t[u]?r[u]:void 0,[r,a,t]),i=o.useCallback(u=>{n(p=>({...p,[u]:!0}))},[]),c=o.useCallback(()=>{s(!0)},[]),d=o.useCallback(()=>{n({}),s(!1)},[]);return{submitted:a,touchedFields:t,getFieldError:l,touchField:i,submit:c,reset:d}}Object.defineProperty(U,"toast",{enumerable:!0,get:()=>Wa.toast}),U.Alert=Ml,U.AreaChart=vn,U.AuthShell=ds,U.BarChart=Qd,U.BonsaifButton=il,U.BonsaifUIToaster=Vd,U.BulletChart=lu,U.Button=He,U.CHART_PALETTE=fn,U.CalendarPicker=Dl,U.ChartCard=Kd,U.Checkbox=Xt,U.CodeBlock=Pl,U.ComboChart=tu,U.CompactFilterSelect=_l,U.CompactSearchInput=zl,U.ConfirmDialog=Ul,U.CopyButton=Xn,U.CopyLinkButton=Xl,U.CpuChart=iu,U.DataSheets=yi,U.DataTable=uo,U.DateRangePicker=ki,U.DonutChart=Rd,U.Drawer=Ti,U.DropdownMenu=Ei,U.DynamicDetailTabs=Cl,U.EmailField=Qi,U.EmptyState=Ri,U.FieldHelperFooter=Qr,U.FieldLabelInfo=Zr,U.FieldLayoutEditor=oc,U.FileUpload=nc,U.FormField=sa,U.GaugeChart=ou,U.GlobalScrollbars=as,U.InputField=oa,U.LineChart=Zd,U.LoadingState=Za,U.MentionTextEditor=Vo,U.MicroserviceFrame=_d,U.Modal=Qn,U.MouseTooltip=$r,U.MultiSelect=lc,U.NetworkChart=fu,U.NumberField=ic,U.PageHeader=Pd,U.PageSearchInput=Va,U.Pagination=dc,U.PhoneField=fc,U.PieChart=Jd,U.PrimeAuthRouteShell=Fd,U.PrimeSuiteChatFrame=jd,U.RadioGroup=bc,U.RamChart=cu,U.RichTextEditor=Pc,U.SearchableSelect=Ar,U.SectionPanel=Fc,U.Sparkline=ru,U.StatusBadge=jc,U.StatusSelect=Kc,U.StepWizard=Xc,U.TableSkeleton=Gt,U.Tabs=Gc,U.TagInput=ad,U.TextInput=nn,U.Textarea=Go,U.TextareaField=Rc,U.TimeField=fd,U.TimePicker=es,U.Toggle=pd,U.UserAvatar=cs,U.WaterfallChart=nu,U.buildMentionQueryRegex=Ho,U.cn=yr,U.configureBonsaifUI=Ql,U.dedupeMentions=zo,U.defaultValueFormat=ar,U.describeParentTargetOrigin=pu,U.emailFormat=Hi,U.extractMentionUsernames=ba,U.filterSelfMentions=Ac,U.findMentionTriggerInEditor=ua,U.formatBytes=rt,U.formatPercent=et,U.formatRate=hs,U.getBonsaifUIConfig=Jl,U.getDataTablePreferencesEndpoint=Jn,U.getPlainTextOffset=pa,U.highlightMentions=_o,U.htmlToText=Po,U.insertMentionInEditor=jo,U.isMentionTriggerBoundary=Bo,U.isPlainOffsetInsideMentionChip=Oo,U.isValidEmail=ta,U.isValidPhone=na,U.locateTextOffset=Jr,U.matches=_i,U.maxLength=Pi,U.maxValue=zi,U.mentionDisplayLabel=Fo,U.minLength=Bi,U.minValue=Fi,U.normalizeUsername=fa,U.phoneCountryCodeOptions=Co,U.phoneFormat=Oi,U.placeCaretAtTextOffset=Wo,U.required=Ii,U.resetBonsaifUIConfig=Rl,U.resolveMentions=$c,U.resolveParentTargetOrigin=bu,U.seriesColor=ms,U.setBonsaifDataTablePreferencesEndpoint=ei,U.toneColor=ir,U.usageColor=At,U.usageTone=bn,U.useValidationVisibility=mu,U.validateForm=ji,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})}));