bonsaif-ui 0.1.95 → 0.1.99

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,Je,ge,$a,wn,Nn,kn,fu,Ls){"use strict";"use client";function hr(...r){return r.filter(Boolean).join(" ")}function $s({variant:r="primary",className:t,type:a="button",children:n,...s}){return e.jsx("button",{className:hr("bonsaif-ui-button",`bonsaif-ui-button--${r}`,t),type:a,...s,children:n})}function Sn({value:r,onChange:t,placeholder:a,className:n="",autoFocus:s=!1,forceExpanded:l=!1,onEscape:i,size:c="default",inputTabIndex:u}){const f=o.useRef(null),[m,b]=o.useState(!1),p=l||m||r.trim().length>0,x=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",N=n||"w-48 max-w-full sm:w-64 lg:w-72";o.useEffect(()=>{var g;s&&((g=f.current)==null||g.focus())},[s]);const M=()=>{var g;b(!0),(g=f.current)==null||g.focus()};return e.jsxs("div",{className:`relative min-w-0 max-w-full flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${p?N:"w-24 sm:w-28"}`,onMouseDown:g=>{p||(g.preventDefault(),M())},children:[e.jsx(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":a,value:r,onChange:g=>t(g.target.value),onKeyDown:g=>{g.key==="Escape"&&(i==null||i())},placeholder:p?a:"Buscar",className:`${x} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${p?"pl-9 pr-8":"cursor-pointer pl-9 pr-3"}`,style:{height:`var(--page-header-control-height, ${c==="sm"?"36px":"40px"})`,paddingLeft:"calc(var(--page-header-control-icon-left, 12px) + 24px)",paddingRight:p?"calc(var(--page-header-control-padding-x, 14px) + 18px)":"var(--page-header-control-padding-x, 14px)",background:"color-mix(in srgb, var(--bg-card) 86%, transparent)",border:"1px solid var(--border)",color:"var(--text-main)"},onFocus:g=>{b(!0),g.currentTarget.style.borderColor="var(--primary)",g.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:g=>{b(!1),g.currentTarget.style.borderColor="var(--border)",g.currentTarget.style.boxShadow="none"}}),r&&e.jsx("button",{type:"button",onClick:()=>t(""),className:"absolute right-2 top-1/2 flex !h-6 !w-6 -translate-y-1/2 items-center justify-center rounded-full !p-0 leading-none transition-colors hover:bg-black/5",style:{color:"var(--text-muted)",right:"var(--page-header-control-padding-x, 8px)"},"aria-label":"Limpiar búsqueda",children:e.jsx(T.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const Cn=o.createContext({});let En=0;const Mn="bonsaif-ui:hide-tooltips";function It(r=700){En=Date.now()+r}function Ts(){return Date.now()>En}function Bt(r){if(typeof document>"u")return!1;const t=Array.from(document.querySelectorAll('[data-bonsaif-overlay="true"], [role="menu"], [role="dialog"][aria-modal="true"], [aria-hidden="false"] [aria-modal="true"]'));return r&&t.some(a=>a.contains(r))?!1:t.length>0}function As(r){var n;const t=Array.from(r.querySelectorAll("*")).filter(s=>{var l;return s.scrollWidth>s.clientWidth&&!!((l=s.textContent)!=null&&l.trim())&&s.tagName.toLowerCase()!=="svg"&&!s.closest("svg")});return(r.scrollWidth>r.clientWidth||t.length>0)&&(((n=t[0])==null?void 0:n.textContent)??r.textContent??"").trim()||null}function jr({children:r,content:t,onlyWhenOverflow:a=!1,interactive:n=!1,followCursor:s=!0,placement:l="bottom",showArrow:i=!1,className:c="",tooltipClassName:u="",style:f,tooltipStyle:m,as:b="div"}){const p=o.useRef(null),x=o.useRef(null),N=o.useRef(null),M=o.useRef(!1),[g,C]=o.useState(null),[B,A]=o.useState("");o.useEffect(()=>{const L=p.current;L&&(L.querySelectorAll("[title]").forEach(Z=>{const W=Z.getAttribute("title");W&&(Z.getAttribute("aria-label")||Z.setAttribute("aria-label",W),Z.removeAttribute("title"))}),L.querySelectorAll("svg title").forEach(Z=>Z.remove()))}),o.useLayoutEffect(()=>{if(!g)return;const L=x.current;if(!L)return;const Z=12,W=14,z=L.getBoundingClientRect(),ee=window.innerWidth-z.width-Z,J=window.innerHeight-z.height-Z;let I=g.mouseX+W,O=g.mouseY+W,K,w;if(!s&&p.current){const S=p.current.getBoundingClientRect(),R=S.left+S.width/2,te=S.top+S.height/2;l==="top"?(I=R-z.width/2,O=S.top-z.height-W,w=z.height-1):l==="left"?(I=S.left-z.width-W,O=te-z.height/2,K=z.width-1):l==="right"?(I=S.right+W,O=te-z.height/2,K=-7):(I=R-z.width/2,O=S.bottom+W,w=-7)}if(s&&(I>ee&&(I=g.mouseX-z.width-W),O>J&&(O=g.mouseY-z.height-W)),I=Math.min(Math.max(Z,I),Math.max(Z,ee)),O=Math.min(Math.max(Z,O),Math.max(Z,J)),!s&&p.current){const S=p.current.getBoundingClientRect(),R=S.left+S.width/2,te=S.top+S.height/2;l==="top"||l==="bottom"?K=Math.min(Math.max(14,R-I),z.width-14):w=Math.min(Math.max(14,te-O),z.height-14)}(Math.abs(I-g.x)>.5||Math.abs(O-g.y)>.5||K!==g.arrowX||w!==g.arrowY)&&C(S=>S&&{...S,x:I,y:O,arrowX:K,arrowY:w})},[s,l,g]);const F=()=>{N.current&&(window.clearTimeout(N.current),N.current=null)},E=(L,Z)=>{if(!Ts()||M.current)return;const W=p.current;if(W&&!Bt(W)){if(a){const z=As(W);if(!z)return;A(z)}!a&&!t||C({mouseX:L,mouseY:Z,x:L+14,y:Z+14})}},k=()=>{const L=p.current;if(!L)return;const Z=L.getBoundingClientRect();E(Z.left+Z.width/2,Z.bottom)},U=()=>{F(),C(null)},H=()=>{if(!n){U();return}F(),N.current=window.setTimeout(()=>C(null),120)},j=()=>{It(),M.current=!0,U()},Y=()=>{M.current=!1};o.useEffect(()=>{if(!g)return;if(Bt(p.current)){C(null);return}const L=()=>C(null),Z=()=>{It(),M.current=!0,C(null)};document.addEventListener("pointerdown",Z,!0),document.addEventListener("click",Z,!0),document.addEventListener("scroll",L,!0),window.addEventListener("blur",L),document.addEventListener("visibilitychange",L),document.addEventListener("keydown",L,!0);const W=new MutationObserver(()=>{Bt(p.current)&&C(null)});return W.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",Z,!0),document.removeEventListener("click",Z,!0),document.removeEventListener("scroll",L,!0),window.removeEventListener("blur",L),document.removeEventListener("visibilitychange",L),document.removeEventListener("keydown",L,!0),W.disconnect()}},[g]),o.useEffect(()=>{const L=()=>It(),Z=()=>{It(),M.current=!0,C(null)};return document.addEventListener("pointerdown",L,!0),document.addEventListener("click",L,!0),document.addEventListener("keydown",L,!0),window.addEventListener(Mn,Z),()=>{document.removeEventListener("pointerdown",L,!0),document.removeEventListener("click",L,!0),document.removeEventListener("keydown",L,!0),window.removeEventListener(Mn,Z)}},[]);const Q=a?B:t;return e.jsxs(e.Fragment,{children:[e.jsx(b,{ref:L=>{p.current=L},className:c,style:f,onMouseEnter:L=>{F(),Y(),s?E(L.clientX,L.clientY):k()},onMouseMove:L=>{g&&s&&E(L.clientX,L.clientY)},onMouseDown:j,onClick:j,onMouseLeave:()=>{Y(),H()},onFocus:k,onBlur:U,children:r}),g&&Q&&!Bt(p.current)?Je.createPortal(e.jsxs("div",{ref:x,role:"tooltip",className:u,onMouseEnter:n?F:void 0,onMouseLeave:n?H:void 0,style:{position:"fixed",top:g.y,left:g.x,zIndex:9999,background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:6,padding:"5px 10px",fontSize:12,color:"var(--text-main)",boxShadow:"0 4px 16px rgba(0,0,0,0.35)",pointerEvents:n?"auto":"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere",...m},children:[i&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",width:12,height:12,background:(m==null?void 0:m.background)??"var(--bg-card)",borderLeft:l==="right"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderTop:l==="bottom"||l==="right"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderRight:l==="left"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderBottom:l==="top"||l==="left"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,transform:"rotate(45deg)",left:g.arrowX===void 0?void 0:g.arrowX-6,top:g.arrowY===void 0?void 0:g.arrowY-6,zIndex:-1}}),Q]}),document.body):null]})}function Ln(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}const Ds="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",Is={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"},Bs="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",Os={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"},Hs={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},Ps={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function Ta(r){return typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(Ta).join(" ").trim():o.isValidElement(r)?Ta(r.props.children):""}function Fs(r){return o.Children.toArray(r).find(o.isValidElement)??null}function He({variant:r="primary",size:t="md",loading:a=!1,icon:n,tooltip:s,iconOnly:l,height:i,padding:c,children:u,className:f="",disabled:m,style:b,...p}){const x=o.useContext(Cn),N=l??x.iconOnly??r==="icon",M=x.compact??!1,g=x.headerAction??!1,C=g&&t==="md"?"sm":M&&!g&&t==="md"?"xs":t,B=r==="icon"||N,A=g&&B,F=Ta(u),E=s??p.title??p["aria-label"]??(N?F:void 0),k=E?void 0:p.title,U=p["aria-label"]??(typeof E=="string"?E:F||void 0),H=a?null:n??(N?Fs(u):null),j=e.jsxs("button",{...p,title:k,"aria-label":U,"data-variant":r,"data-size":C,"data-icon":B?"true":void 0,disabled:m||a,className:`${Ds} ${A?Bs:Is[r]} ${B?Hs[C]:Os[C]} ${M&&!B?"px-2.5":""} ${f}`,style:{...Ps[r],height:Ln(i),padding:Ln(c),...b,...g&&!B?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...A?{width:"var(--page-header-control-height, 40px)",height:"var(--page-header-control-height, 40px)",padding:0,background:"var(--bg-card)",borderRadius:"8px"}:null},children:[a?e.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):H,!N&&u]});return E?e.jsx(jr,{as:"span",content:E,className:"inline-flex shrink-0",children:j}):j}const Ve={background:"color-mix(in srgb, var(--text-muted) 26%, var(--bg-input))"};function Ot({rows:r=8,columns:t=7,showToolbar:a=!0,showPagination:n=!0,compact:s=!1,className:l=""}){const i=Math.max(3,Math.min(t,12)),c=Math.max(3,Math.min(r,20)),u=s?"px-2 py-2":"px-3 py-2.5",f=s?"px-2 py-2":"px-3 py-3";return e.jsxs("div",{className:`w-full min-w-0 overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${l}`,"aria-busy":"true","aria-label":"Cargando tabla",children:[a&&e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-3 py-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx("div",{className:"h-7 w-14 shrink-0 animate-pulse rounded-md",style:Ve}),e.jsx("div",{className:"h-7 max-w-md flex-1 animate-pulse rounded-md",style:Ve})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:Ve}),e.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:Ve})]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("div",{className:"min-w-full",style:{display:"grid",gridTemplateColumns:`repeat(${i}, minmax(96px, 1fr))`},children:[Array.from({length:i}).map((m,b)=>e.jsx("div",{className:`${f} border-b border-[var(--border)]`,style:{background:"color-mix(in srgb, var(--bg-input) 55%, transparent)"},children:e.jsx("div",{className:"h-3 animate-pulse rounded-md",style:{...Ve,width:`${48+b*17%40}%`}})},`h-${b}`)),Array.from({length:c}).map((m,b)=>Array.from({length:i}).map((p,x)=>e.jsx("div",{className:`${u} ${b<c-1?"border-b border-[var(--border)]":""}`,children:e.jsx("div",{className:"h-3.5 animate-pulse rounded-md",style:{...Ve,width:`${46+(b*13+x*11)%42}%`,minWidth:28}})},`c-${b}-${x}`)))]})}),n&&e.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-[var(--border)] px-3 py-2",style:{background:"color-mix(in srgb, var(--bg-input) 40%, transparent)"},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-28 animate-pulse rounded-md",style:Ve}),e.jsx("div",{className:"h-7 w-14 animate-pulse rounded-md",style:Ve})]}),e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:4}).map((m,b)=>e.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:Ve},b))}),e.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:Ve})]})]})}function $n({variant:r="page",title:t="Cargando...",rows:a=6,columns:n=7,children:s}){return r==="table"?e.jsx(Ot,{rows:a,columns:n}):r==="sections"?e.jsx(zs,{rows:a}):r==="cards"?e.jsx(_s,{rows:a}):e.jsx("div",{className:"flex min-h-[240px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[e.jsx("div",{className:"h-9 w-9 animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:t}),s&&e.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:s})]})]})})}function zs({rows:r}){return e.jsx(Ot,{rows:r,columns:7})}function _s({rows:r}){return e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:Array.from({length:r}).map((t,a)=>e.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[e.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded-md",style:Ve}),e.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded-md",style:Ve}),e.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded-md",style:Ve})]},a))})}function Tn(r){const t=r.split("/").filter(Boolean);return(t[t.length-1]??r).replace(/^lv_/,"").split(/[-_]/).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function An(r){return r.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function js(r){return[r.label,Tn(r.service),r.description,r.service].filter(Boolean).join(" ")}function Ws(r){return typeof r=="function"?r:r.default}function qs(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 Us({parentPanel:r,parentPanelComponent:t,renderParentPanel:a,parent:n,context:s,links:l,moduleRegistry:i,loadModule:c,activeService:u,initialService:f,onActiveServiceChange:m,canAccess:b,keepAlive:p=!0,title:x,subtitle:N,emptyState:M,loadingState:g,errorState:C=qs,renderTabLabel:B,searchableTabs:A="auto",tabsSearchThreshold:F=6,tabsSearchPlaceholder:E="Buscar modulo...",tabsSearchValue:k,onTabsSearchChange:U,emptySearchState:H,showTabCount:j=!0,className:Y="",parentClassName:Q="",contentClassName:L="",tabsClassName:Z=""}){var lr;const W=o.useMemo(()=>l.filter(de=>!de.hidden&&((b==null?void 0:b(de,s))??!0)),[b,s,l]),z=(lr=W.find(de=>!de.disabled))==null?void 0:lr.service,[ee,J]=o.useState(f??z??""),[I,O]=o.useState({}),[K,w]=o.useState({}),[S,R]=o.useState(""),[te,ae]=o.useState(!1),ce=o.useRef(K),ve=o.useRef(0),re=k??S,X=An(re),h=A===!0||A==="auto"&&W.length>=F,$=h&&re.trim().length>0,q=o.useMemo(()=>X?W.filter(de=>An(js(de)).includes(X)):W,[X,W]),ne=u??ee,oe=W.find(de=>de.service===ne)??W.find(de=>!de.disabled);o.useEffect(()=>{!oe&&z&&J(z)},[z,oe]),o.useEffect(()=>{ce.current=K},[K]);const he=de=>{de.disabled||(u||J(de.service),m==null||m(de.service,de))},_e=de=>{k===void 0&&R(de),U==null||U(de)},Ge=(de,D)=>{const V=q.filter(ue=>!ue.disabled),le=V.findIndex(ue=>ue.service===D.service);le<0||((de.key==="ArrowRight"||de.key==="ArrowDown")&&(de.preventDefault(),he(V[(le+1)%V.length])),(de.key==="ArrowLeft"||de.key==="ArrowUp")&&(de.preventDefault(),he(V[(le-1+V.length)%V.length])),de.key==="Home"&&(de.preventDefault(),he(V[0])),de.key==="End"&&(de.preventDefault(),he(V[V.length-1])))},xe=o.useCallback(()=>{if(!oe)return;const de=oe.service,D=ce.current[de];if(D!=null&&D.loading||D!=null&&D.component&&p)return;const V=(i==null?void 0:i[de])??c;if(!V){w(ue=>({...ue,[de]:{loading:!1,error:new Error(`No module loader found for service "${de}".`)}}));return}const le=++ve.current;w(ue=>({...ue,[de]:{...ue[de],loading:!0,error:void 0}})),V(oe,s).then(ue=>{if(le!==ve.current&&!p)return;const $e=Ws(ue);w(ke=>({...ke,[de]:{component:$e,loading:!1}}))}).catch(ue=>{const $e=ue instanceof Error?ue:new Error(String(ue));w(ke=>({...ke,[de]:{...ke[de],loading:!1,error:$e}}))})},[s,p,c,i,oe]);o.useEffect(xe,[xe]);const Ee=oe?I[oe.service]??null:null,Ae=oe?K[oe.service]:void 0,wr=Ae==null?void 0:Ae.component,br=de=>{oe&&O(D=>({...D,[oe.service]:de}))},We=()=>{oe&&O(de=>({...de,[oe.service]:null}))},se={context:s,parent:n,links:l,visibleLinks:W,filteredLinks:q,selectedLink:oe,selectedService:oe==null?void 0:oe.service,activeItemId:Ee,tabsSearch:re,onSelectService:he,onOpenDetail:br,onBackToList:We},Ze=a?a(se):t?e.jsx(t,{...se}):r;return e.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${Y}`,children:[e.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${Q}`,children:Ze}),e.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${L}`,children:[(x||N||h||j)&&e.jsx("div",{className:"relative border-b border-[var(--border)] px-4 py-3",children:e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[x&&e.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:x}),N&&e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:N})]}),(h||j)&&e.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[j&&e.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[q.length," / ",W.length]}),h&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${te?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!te,children:e.jsx(Sn,{value:re,onChange:_e,placeholder:E,className:"w-full",autoFocus:te,forceExpanded:!0,onEscape:()=>ae(!1),size:"sm",inputTabIndex:te?0:-1})}),e.jsx("button",{type:"button","aria-label":te?"Cerrar busqueda":"Buscar tabs","aria-expanded":te,onClick:()=>{te&&re&&_e(""),ae(de=>!de)},className:`inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border transition-all duration-200 hover:scale-[1.03] active:scale-95 ${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:te||$?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":x??"Modulos relacionados",className:`flex gap-1 overflow-x-auto border-b border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 transition-colors duration-200 ${Z}`,children:q.length>0?q.map(de=>{const D=de.service===(oe==null?void 0:oe.service);return e.jsx("button",{type:"button",role:"tab","aria-selected":D,disabled:de.disabled,onClick:()=>he(de),onKeyDown:V=>Ge(V,de),className:`inline-flex h-9 min-w-max items-center gap-2 rounded-md border px-3 text-xs font-semibold transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-50 ${D?"border-[var(--primary)] bg-[var(--bg-card)] text-[var(--text-main)] shadow-sm":"border-transparent text-[var(--text-muted)] hover:bg-[var(--bg-card)] hover:text-[var(--text-main)]"}`,children:B?B(de,D):e.jsxs(e.Fragment,{children:[de.icon,e.jsx("span",{children:de.label??Tn(de.service)}),de.badge&&e.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:de.badge})]})},de.service)}):e.jsx("div",{className:"flex min-h-9 flex-1 items-center rounded-md border border-dashed border-[var(--border)] px-3 text-xs text-[var(--text-muted)]",children:H??"No hay modulos que coincidan con la busqueda."})}),(oe==null?void 0:oe.description)&&e.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:oe.description}),e.jsxs("div",{className:"min-h-[420px] p-4",children:[!oe&&(M??e.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-dashed border-[var(--border)] text-sm text-[var(--text-muted)]",children:"No hay modulos disponibles."})),oe&&(Ae==null?void 0:Ae.loading)&&(g??e.jsx($n,{title:"Cargando modulo..."})),oe&&(Ae==null?void 0:Ae.error)&&C(Ae.error,xe),oe&&wr&&!(Ae!=null&&Ae.loading)&&!(Ae!=null&&Ae.error)&&e.jsx(wr,{context:s,parent:n,link:oe,activeItemId:Ee,onOpenDetail:br,onBackToList:We})]})]})]})}const Vs={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 Gs({variant:r="info",title:t,children:a,icon:n,action:s,onDismiss:l,className:i=""}){const c=Vs[r];return e.jsxs("div",{role:r==="danger"||r==="warning"?"alert":"status",className:`flex items-start gap-3 rounded-lg border px-3 py-3 ${i}`,style:{background:c.background,borderColor:c.border},children:[e.jsx("div",{className:"mt-0.5 shrink-0",style:{color:c.color},children:n??c.icon}),e.jsxs("div",{className:"min-w-0 flex-1",children:[t&&e.jsx("div",{className:"text-sm font-semibold text-[var(--text-main)]",children:t}),a&&e.jsx("div",{className:"mt-0.5 text-sm leading-5 text-[var(--text-secondary)]",children:a}),s&&e.jsx("div",{className:"mt-3",children:s})]}),l&&e.jsx(He,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:e.jsx(T.HiXMark,{className:"h-4 w-4"})})]})}const Dn=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],Ks=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],Xs=["Do","Lu","Ma","Mi","Ju","Vi","Sá"],Aa=6;function Da(r,t,a){return`${r}-${String(t).padStart(2,"0")}-${String(a).padStart(2,"0")}`}function Ys(){const r=new Date;return Da(r.getFullYear(),r.getMonth()+1,r.getDate())}function In(r){const[t,a,n]=r.split("-").map(Number);return{year:t,month:a,day:n}}function Zs(r){if(!r)return"Seleccionar fecha";const{year:t,month:a,day:n}=In(r);return!t||!a||!n?"Seleccionar fecha":`${String(n).padStart(2,"0")} ${Dn[a-1]} ${t}`}function Qs({value:r,onChange:t,minDate:a,displayMode:n="inline"}){const s=Ys(),i=In(r||s),c=n==="popover",[u,f]=o.useState(!1),m=o.useRef(null),[b,p]=o.useState({horizontal:"left",vertical:"bottom"}),[x,N]=o.useState(i.year),[M,g]=o.useState(i.month),[C,B]=o.useState("days"),A=16,[F,E]=o.useState(0),k=x-7+F,U=Array.from({length:A},(J,I)=>k+I);o.useEffect(()=>{if(!c||!u||!m.current)return;const J=m.current.getBoundingClientRect(),I=8,O=280,K=340,w=J.left+O>window.innerWidth-I,S=J.right-O>=I,R=J.bottom+8+K>window.innerHeight-I,te=J.top-8-K>=I;p({horizontal:w&&S?"right":"left",vertical:R&&te?"top":"bottom"})},[c,u]),o.useEffect(()=>{if(!c||!u)return;function J(O){m.current&&(m.current.contains(O.target)||f(!1))}function I(O){O.key==="Escape"&&f(!1)}return document.addEventListener("mousedown",J),document.addEventListener("keydown",I),()=>{document.removeEventListener("mousedown",J),document.removeEventListener("keydown",I)}},[c,u]);function H(){M===1?(N(J=>J-1),g(12)):g(J=>J-1)}function j(){M===12?(N(J=>J+1),g(1)):g(J=>J+1)}const Y=new Date(x,M-1,1).getDay(),Q=new Date(x,M,0).getDate(),L=[...Array(Y).fill(null),...Array.from({length:Q},(J,I)=>I+1)];for(;L.length<Aa*7;)L.push(null);const Z=L.slice(0,Aa*7);function W(J){const I=Da(x,M,J);a&&I<a||(t(I),c&&f(!1))}const z={background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,borderRadius:6,display:"flex",alignItems:"center"},ee=e.jsxs("div",{style:{background:"var(--bg-input)",border:"1px solid var(--border)",borderRadius:10,overflow:"hidden",userSelect:"none",width:280},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 12px",borderBottom:"1px solid var(--border)"},children:C==="days"?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:H,style:z,title:"Mes anterior",children:e.jsx(T.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>{B("years"),E(0)},style:{background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:4,fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[Dn[M-1]," ",x,e.jsx(T.HiChevronDown,{size:13,style:{color:"var(--text-muted)"}})]}),e.jsx("button",{type:"button",onClick:j,style:z,title:"Mes siguiente",children:e.jsx(T.HiChevronRight,{size:16})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>E(J=>J-A),style:z,children:e.jsx(T.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>B("days"),style:{background:"none",border:"none",cursor:"pointer",fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[U[0]," – ",U[U.length-1]]}),e.jsx("button",{type:"button",onClick:()=>E(J=>J+A),style:z,children:e.jsx(T.HiChevronRight,{size:16})})]})}),C==="years"&&e.jsxs("div",{style:{padding:"8px 10px 10px"},children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3,marginBottom:8},children:Ks.map((J,I)=>{const O=I+1===M;return e.jsx("button",{type:"button",onClick:()=>g(I+1),style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:11,fontWeight:O?700:400,padding:"4px 0",background:O?"var(--primary)":"transparent",color:O?"var(--primary-fg, #ffffff)":"var(--text-secondary)"},children:J},J)})}),e.jsx("div",{style:{height:1,background:"var(--border)",marginBottom:8}}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3},children:U.map(J=>{const I=J===x;return e.jsx("button",{type:"button",onClick:()=>{N(J),B("days")},style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:12,fontWeight:I?700:400,padding:"6px 0",background:I?"var(--primary)":"transparent",color:I?"var(--primary-fg, #ffffff)":"var(--text-main)",outline:J===new Date().getFullYear()&&!I?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:J},J)})})]}),C==="days"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",padding:"6px 8px 0"},children:Xs.map(J=>e.jsx("div",{style:{textAlign:"center",fontSize:10,fontWeight:700,color:"var(--text-muted)",padding:"2px 0",textTransform:"uppercase"},children:J},J))}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",gridTemplateRows:`repeat(${Aa},1fr)`,padding:"4px 8px 10px",gap:2},children:Z.map((J,I)=>{if(J===null)return e.jsx("div",{style:{aspectRatio:"1"}},I);const O=Da(x,M,J),K=O===r,w=O===s,S=!!(a&&O<a);return e.jsx("button",{type:"button",onClick:()=>!S&&W(J),style:{width:"100%",aspectRatio:"1",borderRadius:6,border:"none",cursor:S?"not-allowed":"pointer",fontSize:12,fontWeight:K||w?700:400,background:K?"var(--primary)":"transparent",color:K?"var(--primary-fg, #ffffff)":S?"var(--text-muted)":"var(--text-main)",opacity:S?.4:1,outline:w&&!K?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:J},I)})})]})]});return c?e.jsxs("div",{ref:m,className:"relative w-full",children:[e.jsxs("button",{type:"button",onClick:()=>f(J=>!J),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:Zs(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:ee})]}):ee}const Js={sm:"h-4 w-4",md:"h-5 w-5"};function Rs(r,t){if(typeof r=="function"){r(t);return}r&&(r.current=t)}const Ht=o.forwardRef(function({label:t,description:a,error:n,size:s="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:u,...f},m){const b=o.useRef(null);return o.useEffect(()=>{b.current&&(b.current.indeterminate=l)},[l]),e.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${u?"cursor-not-allowed opacity-60":"cursor-pointer"} ${c}`,children:[e.jsxs("span",{className:"relative mt-0.5 inline-flex shrink-0",children:[e.jsx("input",{...f,ref:p=>{b.current=p,Rs(m,p)},type:"checkbox",disabled:u,"aria-checked":l?"mixed":f["aria-checked"],"aria-invalid":!!n||f["aria-invalid"],className:`peer ${Js[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||a||n)&&e.jsxs("span",{className:"min-w-0",children:[t&&e.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:t}),a&&!n&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:a}),n&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--danger)]",children:n})]})]})});function Bn(r){const t=document.createElement("textarea");t.value=r,t.style.position="fixed",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}async function el(r){var t;if((t=navigator.clipboard)!=null&&t.writeText){await navigator.clipboard.writeText(r);return}Bn(r)}function rl(r){return typeof r=="function"?r():r}function Ia({value:r,resetDelay:t=2e3,title:a,copiedTitle:n="Copiado",copiedLabel:s,icon:l=e.jsx(T.HiClipboardDocument,{size:14}),copiedIcon:i=e.jsx(T.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:u,onCopyError:f,className:m="",style:b,children:p,onClick:x,type:N="button",...M}){const[g,C]=o.useState(!1),B=o.useRef(null);o.useEffect(()=>()=>{B.current&&window.clearTimeout(B.current)},[]);function A(E){C(!0),u==null||u(E),B.current&&window.clearTimeout(B.current),B.current=window.setTimeout(()=>{C(!1),B.current=null},t)}async function F(E){var U;if(c&&E.stopPropagation(),x==null||x(E),E.defaultPrevented)return;const k=rl(r);if(k)try{await el(k),A(k)}catch(H){try{Bn(k),A(k)}catch(j){f==null||f(j,k);return}(U=navigator.clipboard)!=null&&U.writeText||f==null||f(H,k)}}return e.jsxs("button",{...M,type:N,onClick:F,title:g?n:a,"aria-label":M["aria-label"]??(g?n:a),"data-copied":g?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${p?"min-w-7 px-2":"w-7"} ${m}`,style:{cursor:"pointer",background:g?"rgba(22,163,74,0.15)":"var(--bg-card)",border:g?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:g?"#16a34a":"var(--text-secondary)",boxShadow:g?"0 0 0 3px rgba(22,163,74,0.12)":"none",...b},children:[e.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:g?"scale(1.15)":"scale(1)"},children:g?i:l}),p&&e.jsx("span",{className:"text-xs font-semibold leading-none",children:g?s??p:p})]})}function tl({code:r,children:t,title:a="Codigo",language:n,copyLabel:s="Copiar",copiedLabel:l="Copiado",className:i="",style:c,onCopied:u}){const f=(r??t??"").trim();return e.jsxs("div",{className:`overflow-hidden rounded-lg border ${i}`,style:{borderColor:"rgba(148, 163, 184, 0.22)",background:"#0f172a",color:"#e2e8f0",...c},children:[e.jsxs("div",{className:"flex min-h-9 items-center justify-between gap-3 border-b px-3 py-1.5",style:{borderColor:"rgba(148, 163, 184, 0.18)",background:"#111827",color:"#94a3b8"},children:[e.jsx("span",{className:"min-w-0 truncate text-[11px] font-black uppercase tracking-[0.08em]",children:a}),e.jsx(Ia,{value:f,title:"Copiar codigo",copiedTitle:"Codigo copiado",copiedLabel:l,onCopied:u,className:"h-7 min-w-[72px] px-2",style:{background:"#182235",border:"1px solid rgba(148, 163, 184, 0.28)",color:"#f8fafc"},children:s})]}),e.jsx("pre",{className:"m-0 overflow-x-auto p-3 text-xs leading-6",style:{background:"#0f172a",color:"#e2e8f0",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace'},children:e.jsx("code",{className:n?`language-${n}`:void 0,children:f})})]})}function Ba(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Oa(r){return r.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function al(r,t){if(!t.trim())return!0;const a=Oa(t);return Oa(r.label).includes(a)||!!(r.sublabel&&Oa(r.sublabel).includes(a))}function Er({value:r,onChange:t,options:a,status:n="default",ariaLabel:s,triggerVariant:l="default",showSelectedSublabel:i=!0,placeholder:c="Seleccionar…",emptyLabel:u,disabled:f=!1,className:m="",style:b,dropdownMinWidth:p,height:x=40,padding:N="0 10px",searchable:M=!0,minOptionsForSearch:g=6}){const[C,B]=o.useState(!1),[A,F]=o.useState(""),[E,k]=o.useState(-1),[U,H]=o.useState(!1),[j,Y]=o.useState({}),Q=o.useRef(null),L=o.useRef(null),Z=o.useRef(null),W=o.useRef(null),z=M&&a.length>=g,ee=a.find(re=>re.value===r)??null,J=l==="ghost",I=n==="error"?"var(--danger)":C?"var(--primary)":"var(--border)",O=z&&A.trim()?a.filter(re=>al(re,A)):a,K=o.useCallback(()=>{const re=Q.current;if(!re)return;const X=re.getBoundingClientRect(),h=z?272:212,$=window.innerHeight-X.bottom,q=$<h&&X.top>$;Y({position:"fixed",left:X.left,top:q?void 0:X.bottom+4,bottom:q?window.innerHeight-X.top+4:void 0,width:X.width,minWidth:Ba(p),zIndex:9999})},[p,z]);o.useEffect(()=>H(!0),[]),o.useEffect(()=>{if(!C)return;function re(X){var $,q;const h=X.target;!(($=Q.current)!=null&&$.contains(h))&&!((q=L.current)!=null&&q.contains(h))&&(B(!1),F(""))}return document.addEventListener("mousedown",re),()=>document.removeEventListener("mousedown",re)},[C]),o.useEffect(()=>{C&&(k(-1),K(),z&&setTimeout(()=>{var re;return(re=Z.current)==null?void 0:re.focus()},0))},[C,z,K]),o.useEffect(()=>{if(C)return window.addEventListener("resize",K),window.addEventListener("scroll",K,!0),()=>{window.removeEventListener("resize",K),window.removeEventListener("scroll",K,!0)}},[C,K]),o.useEffect(()=>{if(E<0||!W.current)return;const re=W.current.children[E];re==null||re.scrollIntoView({block:"nearest"})},[E]);const w=o.useCallback(re=>{t(re),B(!1),F("")},[t]),S=o.useRef(C);S.current=C;const R=o.useRef(O);R.current=O;const te=o.useRef(E);te.current=E;const ae=o.useRef(u);ae.current=u;const ce=o.useRef(w);ce.current=w,o.useEffect(()=>{function re(X){var ne,oe;const h=document.activeElement,$=((ne=Q.current)==null?void 0:ne.contains(h))??!1,q=((oe=L.current)==null?void 0:oe.contains(h))??!1;if(!(!$&&!q)){if(!S.current){(X.key==="Enter"||X.key===" "||X.key==="ArrowDown")&&(X.preventDefault(),B(!0));return}switch(X.key){case"ArrowDown":X.preventDefault(),k(he=>Math.min(he+1,R.current.length-1));break;case"ArrowUp":X.preventDefault(),k(he=>Math.max(he-1,ae.current?-1:0));break;case"Enter":{X.preventDefault();const he=te.current,_e=R.current;he===-1&&ae.current?ce.current(""):_e[he]&&!_e[he].disabled&&ce.current(_e[he].value);break}case"Escape":X.preventDefault(),X.stopPropagation(),B(!1),F("");break}}}return document.addEventListener("keydown",re),()=>document.removeEventListener("keydown",re)},[]);const ve=e.jsxs("div",{ref:L,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...j,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[z&&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:Z,value:A,onChange:re=>{F(re.target.value),k(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),A&&e.jsx("button",{type:"button",onMouseDown:re=>{re.preventDefault(),F("")},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:z?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[u&&e.jsx("li",{role:"option","aria-selected":r==="",onMouseDown:re=>{re.preventDefault(),w("")},onMouseEnter:()=>k(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:E===-1&&!A.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:u}),O.map((re,X)=>{const $=X===E,q=re.value===r;return e.jsxs("li",{role:"option","aria-selected":q,onMouseDown:ne=>{ne.preventDefault(),re.disabled||w(re.value)},onMouseEnter:()=>!re.disabled&&k(X),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:$?"var(--bg-hover)":q?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:re.disabled?"var(--text-muted)":"var(--text-main)",cursor:re.disabled?"not-allowed":"pointer",boxShadow:q?"inset 2px 0 0 var(--primary)":void 0},children:[re.color&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:re.color}}),e.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:re.label}),re.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:re.sublabel})]}),re.badge&&e.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:re.badge})]},re.value)}),O.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:Q,className:`relative ${m||"w-full"}`,style:b,children:[e.jsxs("button",{type:"button",disabled:f,onClick:()=>!f&&B(re=>!re),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:Ba(x),padding:Ba(N),background:J?"transparent":"var(--bg-input)",color:ee?"var(--text-main)":"var(--text-muted)",border:J?"1px solid transparent":`1px solid ${I}`,opacity:f?.5:1,cursor:f?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":C,"aria-label":s,children:[(ee==null?void 0:ee.color)&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:ee.color}}),e.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:ee?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"truncate",children:ee.label}),i&&ee.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:ee.sublabel})]}):e.jsx("span",{className:"truncate",children:c})}),ee&&u?e.jsx("span",{role:"button",tabIndex:-1,onMouseDown:re=>{re.preventDefault(),re.stopPropagation(),w("")},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:C?"rotate(180deg)":"rotate(0deg)"}})]}),C&&U&&Je.createPortal(ve,document.body)]})}function Pt(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function nl({value:r,onChange:t,placeholder:a="Buscar...",className:n="",height:s=40,padding:l="0 10px 0 30px",iconLeft:i=10}){return e.jsxs("div",{className:`relative ${n}`,children:[e.jsx(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:Pt(i)}}),e.jsx("input",{type:"text",value:r,onChange:c=>t(c.target.value),placeholder:a,className:"w-full rounded-lg border border-[var(--border)] [background:var(--bg-card)] text-sm text-[var(--text-main)] placeholder:text-[var(--text-muted)] outline-none transition-[border-color,box-shadow] focus:border-primary focus:ring-2 focus:ring-primary/20",style:{height:Pt(s),padding:Pt(l)}})]})}function ol({value:r,onChange:t,options:a,placeholder:n,icon:s,className:l="",height:i=40,padding:c,iconLeft:u=10,searchable:f=!0}){const m=s?a.map((b,p)=>p===0&&!b.color?{...b,sublabel:b.sublabel??void 0}:b):a;return e.jsxs("div",{className:`relative ${l}`,children:[s&&e.jsx("span",{className:"pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--text-muted)]",style:{left:Pt(u)},children:s}),e.jsx(Er,{value:r,onChange:t,options:m,placeholder:n,searchable:f,minOptionsForSearch:5,height:i,padding:c??(s?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const sl={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},Ft=180,ll="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Ha({open:r,onClose:t,title:a,subtitle:n,leadingIcon:s,headerActions:l,footer:i,children:c,size:u="md",maxWidth:f,zIndex:m=1e3,closeOnBackdrop:b=!0,closeOnEscape:p=!0,showCloseButton:x=!0,placement:N="center",bodyClassName:M="px-6 py-5",panelClassName:g="",backdropClassName:C=ll,contentClassName:B="p-4",ariaLabel:A,frameless:F=!1,disabled:E=!1}){const[k,U]=o.useState(!1),[H,j]=o.useState(!1),Y=o.useRef(null);if(o.useEffect(()=>(r?(Y.current&&clearTimeout(Y.current),U(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>j(!0)))):(j(!1),Y.current=setTimeout(()=>U(!1),Ft+40)),()=>{Y.current&&clearTimeout(Y.current)}),[r]),o.useEffect(()=>{if(r)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[r]),o.useEffect(()=>{if(!r||!p)return;const ee=J=>{J.key==="Escape"&&t()};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[p,t,r]),!k)return null;const Q=a||n||s||l||x,L=f??sl[u],Z=N==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",W=N==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",z=H?"translateY(0) scale(1)":N==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return Je.createPortal(e.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":A??a,className:`fixed inset-0 flex ${Z} ${B}`,style:{zIndex:m},children:[e.jsx("div",{className:`absolute inset-0 ${C}`,onClick:b?t:void 0,style:{opacity:H?1:0,transition:`opacity ${Ft}ms ease`}}),e.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${F?"shadow-none":"shadow-2xl"} ${W} ${g}`,style:{maxWidth:L,background:F?"transparent":"var(--bg-card)",border:F?"none":"1px solid var(--border)",opacity:H?1:0,transform:z,transition:`opacity ${Ft}ms ease, transform ${Ft}ms ease`},onClick:ee=>ee.stopPropagation(),children:[E&&e.jsx("div",{className:"absolute inset-0 z-[1002] cursor-not-allowed rounded-2xl",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 60%, transparent)",backdropFilter:"blur(2px)"}}),Q&&e.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between gap-3 px-6 py-4",style:{borderBottom:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[s&&e.jsx("div",{className:"flex-shrink-0",children:s}),(a||n)&&e.jsxs("div",{className:"min-w-0",children:[a&&e.jsx("h2",{className:"truncate text-base font-semibold",style:{color:"var(--text-main)"},children:a}),n&&e.jsx("p",{className:"truncate text-xs",style:{color:"var(--text-muted)"},children:n})]})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[l,x&&e.jsx(He,{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 ${M}`,children:c}),i&&e.jsx("div",{className:"flex flex-shrink-0 justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:i})]})]}),document.body)}const il={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 cl({open:r,title:t,description:a,confirmLabel:n="Confirmar",cancelLabel:s="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:u}){const f=il[l];return e.jsx(Ha,{open:r,onClose:u,size:"md",zIndex:9998,showCloseButton:!1,bodyClassName:"p-0",panelClassName:"overflow-visible",ariaLabel:t,closeOnBackdrop:i,children:e.jsxs("div",{className:"relative px-6 pb-6 pt-6",children:[e.jsx(He,{variant:"icon",onClick:u,className:"absolute right-3 top-3 h-8 w-8 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:e.jsx(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}),a?e.jsx("div",{className:"mt-1.5 text-sm leading-relaxed",style:{color:"var(--text-muted)"},children:a}):null]})]}),e.jsxs("div",{className:"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e.jsx(He,{variant:"secondary",onClick:u,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:s}),e.jsx(He,{variant:"danger",onClick:c,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:f.btnBg,color:f.btnColor,borderColor:"transparent"},children:n})]})]})})}function dl(r){return r?typeof r=="function"?r():r:""}function ul(r){return/^https?:\/\//i.test(r)}function On(r,t){try{return new URL(r,t).toString()}catch{return r}}function fl(r,t,a,n=!1){const s=typeof r=="function"?r():r,l=t?t(s):s;if(!l||ul(l))return l;const i=dl(a);return i?On(l,i):n&&typeof window<"u"?On(l,window.location.origin):l}function bl({url:r,resolveUrl:t,baseUrl:a,useWindowOriginForRelative:n=!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(Ia,{...c,value:()=>fl(r,t,a,n),title:s,copiedTitle:l,icon:i})}const zt=[25,50,100,200,500];let Re={dataTable:{pageSizeOptions:[...zt]}};function pl(){if(typeof window>"u")return;const t=window.__BONSAIF_DATA_TABLE_PREFERENCES_ENDPOINT__;return typeof t=="string"&&t.trim().length>0?t.trim().replace(/\/+$/,""):void 0}function Pa(){const r=Re.dataTable.preferencesEndpoint,t=pl();return r&&r.trim().length>0?r.trim().replace(/\/+$/,""):t}function ml(r){if(!Array.isArray(r))return[...zt];const t=Array.from(new Set(r.map(a=>typeof a=="number"?Math.floor(a):Number.NaN).filter(a=>Number.isFinite(a)&&a>0)));return t.length>0?t:[...zt]}function Hn(r){if(typeof r!="string")return;const t=r.trim();if(t)return t.replace(/\/+$/,"")}function hl(r){if(!r||typeof r!="object"||!r.dataTable)return;const t=Hn(r.dataTable.preferencesEndpoint);Re={...Re,dataTable:{...Re.dataTable,pageSizeOptions:ml(r.dataTable.pageSizeOptions),preferencesEndpoint:t??Re.dataTable.preferencesEndpoint}}}function gl(){return{dataTable:{pageSizeOptions:[...Re.dataTable.pageSizeOptions]}}}function ut(){return[...Re.dataTable.pageSizeOptions]}function vl(){Re={dataTable:{pageSizeOptions:[...zt]}}}function xl(r){Re={...Re,dataTable:{...Re.dataTable,preferencesEndpoint:Hn(r)}}}const _t=[{value:"equals",label:"Igual a",valueMode:"single"},{value:"notEquals",label:"No es igual a",valueMode:"single"},{value:"greaterThan",label:"Mayor que",valueMode:"single"},{value:"greaterThanOrEqual",label:"Mayor o igual que",valueMode:"single"},{value:"lessThan",label:"Menor que",valueMode:"single"},{value:"lessThanOrEqual",label:"Menor o igual que",valueMode:"single"},{value:"between",label:"Entre",valueMode:"between"},{value:"top10",label:"10 superiores",valueMode:"none"},{value:"bottom10",label:"10 inferiores",valueMode:"none"},{value:"aboveAverage",label:"Sobre promedio",valueMode:"none"},{value:"belowAverage",label:"Bajo promedio",valueMode:"none"}],yl=_t.map(r=>({value:r.value,label:r.label})),wl=12,Nl={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},Pn={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},kl="bonsaif-ui:datatable:",Sl="[&_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",Cl=[],El=52;function gr(r){if(!r)return 150;const t=parseInt(r,10);return isNaN(t)||t<=0?150:t}function Fn(r){return!!(r&&(Array.isArray(r.columnOrder)&&r.columnOrder.length>0||r.columnWidths&&Object.keys(r.columnWidths).length>0||Array.isArray(r.hiddenColumnKeys)&&r.hiddenColumnKeys.length>0||r.filters&&Object.keys(r.filters).length>0||r.conditionFilters&&Object.keys(r.conditionFilters).length>0||r.sort||typeof r.bql=="string"||Array.isArray(r.bqlHistory)&&r.bqlHistory.length>0||typeof r.pageSize=="number"))}function zn(r){return`${kl}${r}`}function jt(r){try{const t=window.localStorage.getItem(zn(r));if(!t)return null;const a=JSON.parse(t);return a&&typeof a=="object"?a:null}catch{return null}}function Ml(r,t){try{window.localStorage.setItem(zn(r),JSON.stringify(t))}catch{}}function Ll(r,t){if(r===!0)return{...Pn};if(r===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(t&&r==null)return{...Pn};const a={...Nl,...r??{}};return t&&(typeof r!="object"||r.pagination!==!1)&&(a.pagination=!0),a}function _n(...r){return r.reduce((t,a)=>({...t,...a??{}}),{})}function Fa(r,t,a){return typeof r!="number"||r<=0?a:ht(t).includes(r)?r:a}function ft(r){if(!r||typeof r!="object")return!1;const t=r;return typeof t.key=="string"&&(t.dir==="asc"||t.dir==="desc")}function bt(r,t){if(!r||typeof r!="object"||Array.isArray(r))return{};const a=Object.entries(r).flatMap(([n,s])=>{if(!t.has(n)||!Array.isArray(s))return[];const l=s.filter(i=>typeof i=="string");return l.length>0?[[n,l]]:[]});return Object.fromEntries(a)}function pt(r,t){if(!r||typeof r!="object"||Array.isArray(r))return{};const a=new Set(_t.map(s=>s.value)),n=Object.entries(r).flatMap(([s,l])=>{if(!t.has(s)||!l||typeof l!="object")return[];const i=l;return!i.operator||!a.has(i.operator)?[]:[[s,{operator:i.operator,value:typeof i.value=="string"?i.value:"",valueTo:typeof i.valueTo=="string"?i.valueTo:""}]]});return Object.fromEntries(n)}function er(r,t){if(Mr(r))return El;const a=r.minWidth??80,n=r.maxWidth??1/0;return Math.min(n,Math.max(a,t))}function $l(r){const t=window.getComputedStyle(r);return parseFloat(t.paddingLeft)+parseFloat(t.paddingRight)}function Mr(r){return r.key==="actions"||r.key==="acciones"?!0:typeof r.header=="string"&&r.header.trim().toLowerCase()==="acciones"}function Tl(r,t){if(t<=7)return Array.from({length:t},(n,s)=>s+1);const a=[1];r>3&&a.push("...");for(let n=Math.max(2,r-1);n<=Math.min(t-1,r+1);n++)a.push(n);return r<t-2&&a.push("..."),a.push(t),a}function vr(r,t){var i;const a=new Set(t.filter(c=>c.hideable!==!1).map(c=>c.key)),n=Array.from(new Set(r??[])).filter(c=>a.has(c));if(t.filter(c=>!n.includes(c.key)).length>0)return n;const l=(i=t.find(c=>c.hideable!==!1))==null?void 0:i.key;return l?n.filter(c=>c!==l):[]}function Al(r){return r==null||r===""?"(Vacio)":r instanceof Date?r.toLocaleDateString():String(r)}function Wr(r){return r==null||typeof r=="boolean"?"":typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(Wr).join(" ").trim():o.isValidElement(r)?Wr(r.props.children):""}function Wt(r,t){const a=r.filterValue?r.filterValue(t):r.sortKey?t[r.sortKey]:r.cell(t);return typeof a=="string"||typeof a=="number"||typeof a=="boolean"||a===null||a===void 0||a instanceof Date?Al(a):Wr(a).trim()}function mt(r){const t=r.replace(/,/g,"").trim();if(!t)return null;const a=Number(t);return Number.isFinite(a)?a:null}function qr(r,t){const a=mt(r),n=mt(t);return a!==null&&n!==null?a-n:r.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function ht(r){const t=Array.from(new Set(r.map(a=>Math.floor(a)).filter(a=>Number.isFinite(a)&&a>0)));return t.length>0?t:ut()}function Dl(r,t,a){var i,c;const n=((i=t.value)==null?void 0:i.trim())??"",s=((c=t.valueTo)==null?void 0:c.trim())??"",l=_t.find(u=>u.value===t.operator);if((l==null?void 0:l.valueMode)==="single"&&!n||(l==null?void 0:l.valueMode)==="between"&&(!n||!s))return!0;switch(t.operator){case"equals":return r.toLowerCase()===n.toLowerCase();case"notEquals":return r.toLowerCase()!==n.toLowerCase();case"greaterThan":return qr(r,n)>0;case"greaterThanOrEqual":return qr(r,n)>=0;case"lessThan":return qr(r,n)<0;case"lessThanOrEqual":return qr(r,n)<=0;case"between":return qr(r,n)>=0&&qr(r,s)<=0;case"top10":case"bottom10":{const f=a.map(b=>({value:b,number:mt(b)})).filter(b=>b.number!==null).sort((b,p)=>b.number-p.number).map(b=>b.value);return(t.operator==="top10"?f.slice(-10):f.slice(0,10)).includes(r)}case"aboveAverage":case"belowAverage":{const u=a.map(mt).filter(b=>b!==null);if(u.length===0)return!1;const f=u.reduce((b,p)=>b+p,0)/u.length,m=mt(r);return m===null?!1:t.operator==="aboveAverage"?m>f:m<f}default:return!0}}function jn({children:r,className:t="",style:a}){return e.jsx(jr,{onlyWhenOverflow:!0,className:t,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",...a},children:r})}function Wn({columns:r,data:t,getRowId:a,loading:n=!1,skeletonRows:s=8,emptyIcon:l,emptyText:i="Sin resultados",initialEmptyDelay:c=450,onRowClick:u,renderExpandedRow:f,getRowCanExpand:m,expandedRowIds:b,defaultExpandedRowIds:p=[],onExpandedRowIdsChange:x,expandOnRowClick:N=!1,selected:M,onToggleOne:g,onToggleAll:C,highlightSelected:B=!0,rowClassName:A,getRowCategory:F,stickyHeader:E=!0,pageSize:k=25,pageSizeOptions:U,pageSizeSelectWidth:H=62,pageSizeSelectHeight:j=30,pageSizeSelectPadding:Y="0 7px",totalRows:Q,page:L,onPageChange:Z,onPageSizeChange:W,storageKey:z,stickyFirstColumn:ee=!1,bottomOffset:J=0,compact:I=!0,restrictHeight:O=!0,maxHeight:K,minTableWidth:w,enableColumnVisibility:S=!0,enableColumnFilters:R=!0,hiddenColumnKeys:te,defaultHiddenColumnKeys:ae=Cl,onHiddenColumnKeysChange:ce,columnVisibilityLabel:ve="Columnas",enableBql:re=!1,bqlValue:X,defaultBqlValue:h="",onBqlChange:$,bqlDescription:q="Filtra registros con Bonsaif Query Language",bqlPlaceholder:ne=`status = activo
2
- rol IN (admin, employee)`,bqlQuickFilters:oe=[],bqlExamples:he=[],bqlSuggestions:_e=[],bqlActiveFilters:Ge,bqlError:xe,onQueryChange:Ee,persistState:Ae,onPreferencesReady:wr,enableExport:br=!1,exportFilename:We="datos"}){var Es;const se=Ll(Ae,z),Ze=Object.values(se).some(Boolean),lr=r.map(d=>d.key).join(","),de=ae.join(","),D=o.useRef(r),V=o.useRef(ae);D.current=r,V.current=ae;const[le,ue]=o.useState(!z||!Ze),$e=o.useRef(null),ke=o.useRef(!z),Ie=o.useRef(!1),Me=o.useRef(wr);Me.current=wr;const Ue=o.useRef(!z||!Ze?z??"__none__":null),Be=te!==void 0,[sa,Ke]=o.useState(()=>vr(ae,r)),Fe=vr(Be?te:sa,r),[Xe,Tr]=o.useState(!1),[ir,Cd]=o.useState("filter"),[St,la]=o.useState(null),[Xo,Yo]=o.useState(""),[Qe,Yr]=o.useState({}),[cr,Ct]=o.useState({}),nn=b!==void 0,[Zo,Ed]=o.useState(p),Ar=X!==void 0,[Md,Et]=o.useState(h),pr=Ar?X:Md,[Mt,ia]=o.useState(pr),[mr,Dr]=o.useState(!1),[Qo,Zr]=o.useState(!1),[Jo,Qr]=o.useState(!1),[Lt,Jr]=o.useState([]),Rr=o.useRef(null),Ir=o.useRef(null),dr=o.useRef($);dr.current=$;const ca=o.useRef(k);ca.current=k;const da=o.useRef(U);da.current=U;const Ld=Array.isArray(U)?U.join(","):"",on=o.useRef(null),Ro=o.useRef(null),sn=o.useRef(null),es=o.useRef(0),[$d,Td]=o.useState({}),[Ad,Dd]=o.useState({}),[$t,ua]=o.useState(!1),ln=o.useRef(null),fa=o.useRef(null),[Id,Bd]=o.useState({}),rs=o.useRef(null),ba=o.useRef(null),[cn,ts]=o.useState(t.length>0||n||c===!1),as=(d,v)=>50+(d*17+v*13+7)%40,Nr=o.useRef(null),[Od,Hd]=o.useState(void 0),[ns,Pd]=o.useState(0),[dn,Fd]=o.useState(!1);o.useEffect(()=>{function d(){Fd(window.innerWidth<640)}if(!O||K!==void 0)return d(),window.addEventListener("resize",d),()=>window.removeEventListener("resize",d);const P=k!==!1?48:0,y=12;function G(){if(d(),!Nr.current)return;const ie=Nr.current.getBoundingClientRect().top;Hd(Math.max(120,window.innerHeight-ie-P-y-J))}return G(),window.addEventListener("resize",G),()=>window.removeEventListener("resize",G)},[n,k,J,O,K]);const os=O?K??Od:void 0;o.useEffect(()=>{const d=Nr.current;if(!d)return;const v=()=>Pd(d.clientWidth);if(v(),typeof ResizeObserver>"u")return window.addEventListener("resize",v),()=>window.removeEventListener("resize",v);const P=new ResizeObserver(v);return P.observe(d),()=>P.disconnect()},[n,le,t.length]),o.useEffect(()=>{if(c===!1||n||t.length>0){ts(!0);return}if(cn)return;const d=window.setTimeout(()=>{ts(!0)},c);return()=>window.clearTimeout(d)},[t.length,c,cn,n]);const[et,rt]=o.useState(()=>r.map(d=>d.key)),[tt,at]=o.useState(()=>Object.fromEntries(r.map(d=>[d.key,er(d,gr(d.width))]))),[De,Br]=o.useState(null),[zd,pa]=o.useState(1),[ma,ha]=o.useState(k===!1?0:k);o.useEffect(()=>{var qe;const d=D.current,v=V.current,P=d.map(be=>be.key),y=new Set(P),G=()=>{var be;Ie.current||(Ie.current=!0,(be=Me.current)==null||be.call(Me))};if(!z||!Ze){se.layout&&rt(P),Be||Ke(vr(v,d)),ke.current=!1,ue(!0),G();return}let ie=!1;const fe=Ue.current===z;fe||(ke.current=!1,ue(!1),Ie.current=!1);const ye=jt(z);if(Fn(ye)&&!fe){const be=ye,pe=ht(da.current??ut()),me=ca.current,zr=me===!1?0:me,kr=se.layout?be==null?void 0:be.columnOrder:void 0,Sr=Array.isArray(kr)?kr.filter(Le=>P.includes(Le)):[],Cr=P.filter(Le=>!Sr.includes(Le)),_r=Sr.length>0?[...Sr,...Cr]:P,lt=Object.fromEntries(d.map(Le=>[Le.key,er(Le,gr(Le.width))])),it=se.layout?(be==null?void 0:be.columnWidths)??{}:{},Dt=Object.fromEntries(d.map(Le=>[Le.key,er(Le,it[Le.key]??lt[Le.key])])),ct=vr(se.layout?(be==null?void 0:be.hiddenColumnKeys)??v:v,d);if(se.layout&&(rt(_r),at(Dt)),Be||Ke(ct),se.filters&&(Yr(bt(be==null?void 0:be.filters,y)),Ct(pt(be==null?void 0:be.conditionFilters,y))),se.sort){const Le=ft(be==null?void 0:be.sort)?be.sort:null;Br(Le&&y.has(Le.key)?Le:null)}if(se.bql){if(Rr.current!==z){Rr.current=z;const Le=typeof(be==null?void 0:be.bql)=="string"?be.bql:h;Ar?(qe=dr.current)==null||qe.call(dr,Le):Et(Le)}Jr(Array.isArray(be==null?void 0:be.bqlHistory)?be.bqlHistory.filter(Le=>typeof Le=="string"):[])}se.pagination&&Ir.current!==z&&(Ir.current=z,ha(Fa(be==null?void 0:be.pageSize,pe,zr))),Ue.current=z,ue(!0),G()}const we=`${Pa()??"/api/user/preferences/datatables"}?key=${encodeURIComponent(z)}`,Se=new AbortController,Ne=window.setTimeout(()=>Se.abort(),2500);return fetch(we,{cache:"no-store",signal:Se.signal}).then(be=>be.ok?be.json():null).then(be=>{var Ms;if(ie)return;const pe=jt(z),me=_n(Fn(be==null?void 0:be.settings)?be==null?void 0:be.settings:null,pe),zr=ht(da.current??ut()),kr=ca.current,Sr=kr===!1?0:kr,Cr=se.layout?me==null?void 0:me.columnOrder:void 0,_r=Array.isArray(Cr)?Cr.filter(Oe=>P.includes(Oe)):[],lt=P.filter(Oe=>!_r.includes(Oe)),it=_r.length>0?[..._r,...lt]:P,Dt=Object.fromEntries(d.map(Oe=>[Oe.key,er(Oe,gr(Oe.width))])),ct=se.layout?(me==null?void 0:me.columnWidths)??{}:{},Le=Object.fromEntries(d.map(Oe=>[Oe.key,er(Oe,ct[Oe.key]??Dt[Oe.key])])),dt=vr(se.layout?(me==null?void 0:me.hiddenColumnKeys)??v:v,d);if(se.layout&&(rt(it),at(Le)),Be||Ke(dt),se.filters&&(Yr(bt(me==null?void 0:me.filters,y)),Ct(pt(me==null?void 0:me.conditionFilters,y))),se.sort){const Oe=ft(me==null?void 0:me.sort)?me.sort:null;Br(Oe&&y.has(Oe.key)?Oe:null)}if(se.bql){if(Rr.current!==z){Rr.current=z;const Oe=typeof(me==null?void 0:me.bql)=="string"?me.bql:h;Ar?(Ms=dr.current)==null||Ms.call(dr,Oe):Et(Oe)}Jr(Array.isArray(me==null?void 0:me.bqlHistory)?me.bqlHistory.filter(Oe=>typeof Oe=="string"):[])}let Te;se.pagination&&(Te=Fa(me==null?void 0:me.pageSize,zr,Sr),Ir.current!==z&&(Ir.current=z,ha(Te))),$e.current=JSON.stringify({columnOrder:it,columnWidths:Le,hiddenColumnKeys:dt,filters:bt(me==null?void 0:me.filters,y),conditionFilters:pt(me==null?void 0:me.conditionFilters,y),sort:ft(me==null?void 0:me.sort)?me.sort:null,bql:typeof(me==null?void 0:me.bql)=="string"?me.bql:"",bqlHistory:Array.isArray(me==null?void 0:me.bqlHistory)?me.bqlHistory:[],pageSize:se.pagination&&kr!==!1?Te:void 0}),ke.current=!0}).catch(()=>{var be;if(!ie){const pe=jt(z),me=ht(da.current??ut()),zr=ca.current,kr=zr===!1?0:zr,Sr=se.layout?pe==null?void 0:pe.columnOrder:void 0,Cr=Array.isArray(Sr)?Sr.filter(Te=>P.includes(Te)):[],_r=P.filter(Te=>!Cr.includes(Te)),lt=Cr.length>0?[...Cr,..._r]:P,it=Object.fromEntries(d.map(Te=>[Te.key,er(Te,gr(Te.width))])),Dt=se.layout?(pe==null?void 0:pe.columnWidths)??{}:{},ct=Object.fromEntries(d.map(Te=>[Te.key,er(Te,Dt[Te.key]??it[Te.key])]));se.layout&&(rt(lt),at(ct));const Le=vr(se.layout?(pe==null?void 0:pe.hiddenColumnKeys)??v:v,d);if(Be||Ke(Le),se.filters&&(Yr(bt(pe==null?void 0:pe.filters,y)),Ct(pt(pe==null?void 0:pe.conditionFilters,y))),se.sort){const Te=ft(pe==null?void 0:pe.sort)?pe.sort:null;Br(Te&&y.has(Te.key)?Te:null)}if(se.bql){if(Rr.current!==z){Rr.current=z;const Te=typeof(pe==null?void 0:pe.bql)=="string"?pe.bql:h;Ar?(be=dr.current)==null||be.call(dr,Te):Et(Te)}Jr(Array.isArray(pe==null?void 0:pe.bqlHistory)?pe.bqlHistory.filter(Te=>typeof Te=="string"):[])}let dt;se.pagination&&(dt=Fa(pe==null?void 0:pe.pageSize,me,kr),Ir.current!==z&&(Ir.current=z,ha(dt))),$e.current=JSON.stringify({columnOrder:lt,columnWidths:ct,hiddenColumnKeys:Le,filters:bt(pe==null?void 0:pe.filters,y),conditionFilters:pt(pe==null?void 0:pe.conditionFilters,y),sort:ft(pe==null?void 0:pe.sort)?pe.sort:null,bql:typeof(pe==null?void 0:pe.bql)=="string"?pe.bql:"",bqlHistory:Array.isArray(pe==null?void 0:pe.bqlHistory)?pe.bqlHistory:[],pageSize:se.pagination&&zr!==!1?dt:void 0}),ke.current=!0}}).finally(()=>{window.clearTimeout(Ne),ie||(Ue.current=z,ue(!0),G())}),()=>{ie=!0,Se.abort(),window.clearTimeout(Ne)}},[z,Ze,lr,de,Be,se.layout,se.filters,se.sort,se.bql,se.pagination,Ar,h,Ld]),o.useEffect(()=>{if(!z||!le||!Ze||!ke.current)return;const d={};se.layout&&(d.columnOrder=et,d.columnWidths=tt,d.hiddenColumnKeys=Fe),se.filters&&(d.filters=Qe,d.conditionFilters=cr),se.sort&&(d.sort=De),se.bql&&(d.bql=pr,d.bqlHistory=Lt),se.pagination&&k!==!1&&(d.pageSize=ma);const v=jt(z),P=_n(v,d),y=JSON.stringify(P);if(y===$e.current)return;Ml(z,P),$e.current=y;const G=window.setTimeout(()=>{const ie=Pa()??"/api/user/preferences/datatables";fetch(ie,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:z,settings:P})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(G)},[et,tt,Fe,Qe,cr,De,pr,Lt,ma,k,z,le,Ze,se.layout,se.filters,se.sort,se.bql,se.pagination]),o.useEffect(()=>{rt(d=>{const v=r.map(G=>G.key),P=d.filter(G=>v.includes(G)),y=v.filter(G=>!P.includes(G));return[...P,...y]})},[lr,r]);const ss=et.map(d=>r.find(v=>v.key===d)).filter(d=>!!d),nr=ss.filter(d=>!Fe.includes(d.key)),_d=Object.keys(Qe).length,jd=Object.keys(cr).length,un=_d+jd;function ls(d){const v=new Set;return t.reduce((P,y)=>{const G=Wt(d,y);return!G||v.has(G)||(v.add(G),P.push({value:G,label:G})),P},[])}function Wd(){const d=r.find(v=>v.key===St);return d?ls(d):[]}function qd(d){return!!(R&&!Mr(d)&&(d.filterValue||d.sortKey||ls(d).length>0))}function is(d,v){Yr(P=>{const y={...P};return y[d]=v,y})}function Ud(d,v,P,y){const G=Qe[d]??[],ie=y?G:P.filter(ye=>ye!==v),fe=y?G.includes(v)?G.filter(ye=>ye!==v):[...G,v]:ie;fe.length===P.length?fn(d):is(d,fe)}function fn(d){Yr(v=>{const P={...v};return delete P[d],P})}function ga(d,v){Ct(P=>{const y={...P};return v?y[d]=v:delete y[d],y})}function cs(d){ga(d,null)}function Vd(){Yr({}),Ct({})}function Gd(d){Ar||Et(d),$==null||$(d)}function ds(d){const v=d.trim();ia(v),($==null?void 0:$(v))!==!1&&(Ar||Et(v),Dr(!1),Zr(!1),Qr(!1),v&&Jr(y=>[v,...y.filter(G=>G!==v)].slice(0,wl)))}function us(){ia(""),Gd(""),Dr(!1),Zr(!1),Qr(!1)}function bn(d,v){ia(d),v&&(v.style.height="auto",v.style.height=`${Math.min(v.scrollHeight,180)}px`)}function va(d){const v=d.trim();if(!v)return;es.current=Date.now()+500;const P=Mt.replace(/\s+$/u,""),y=P.length===0?v:P.split(`
3
- `).map(G=>G.trim()).includes(v)?P:`${P}
4
- ${v}`;bn(y,sn.current??void 0),requestAnimationFrame(()=>{const G=sn.current;if(!G)return;G.focus();const ie=G.value.length;G.setSelectionRange(ie,ie),bn(G.value,G)})}o.useEffect(()=>{ia(pr)},[pr]);const xa=o.useCallback(()=>{const d=on.current;if(!d)return;const v=d.getBoundingClientRect(),P=12,y=8,G=Math.min(780,Math.max(320,window.innerWidth-32)),ie=Math.max(P,window.innerWidth-G-P),fe=Math.min(Math.max(P,v.left),ie),ye=v.bottom+y,ze=window.innerHeight-v.top+y,Pe=window.innerHeight-ye-P,we=v.top-P-y,Se=Pe<280&&we>Pe,Ne=Math.max(240,Se?we:Pe);Td({position:"fixed",zIndex:1e4,left:fe,top:Se?void 0:ye,bottom:Se?ze:void 0,width:G,maxWidth:"calc(100vw - 24px)",maxHeight:Ne,overflowY:"auto"})},[]);o.useEffect(()=>{if(!mr)return;function d(y){var ie,fe;if(Date.now()<es.current)return;const G=y.target;(ie=on.current)!=null&&ie.contains(G)||(fe=Ro.current)!=null&&fe.contains(G)||(Dr(!1),Zr(!1),Qr(!1))}function v(y){y.key==="Escape"&&(Dr(!1),Zr(!1),Qr(!1))}function P(){xa()}return xa(),document.addEventListener("mousedown",d),window.addEventListener("keydown",v),window.addEventListener("resize",P),window.addEventListener("scroll",P,!0),()=>{document.removeEventListener("mousedown",d),window.removeEventListener("keydown",v),window.removeEventListener("resize",P),window.removeEventListener("scroll",P,!0)}},[mr,xa]);function fs(d){const v=vr(d,r);Be||Ke(v),ce==null||ce(v)}function Kd(d){fs(Fe.includes(d)?Fe.filter(v=>v!==d):[...Fe,d])}function Xd(){fs([])}const pn=o.useCallback((d=ba.current)=>{if(!d)return;const v=d.getBoundingClientRect(),P=Math.min(292,Math.max(240,window.innerWidth-16)),y=Math.max(8,window.innerWidth-P-8),G=Math.min(Math.max(8,v.right-P),y),ie=window.innerHeight-v.bottom,fe=v.bottom+6,ye=window.innerHeight-v.top+6,Pe=ie<360&&v.top>ie?void 0:fe,we=Pe===void 0?ye:void 0,Se=Math.max(220,Pe===void 0?v.top-16:window.innerHeight-fe-8),Ne={position:"fixed",zIndex:9999,left:G,top:Pe,bottom:we,width:P,maxWidth:"calc(100vw - 16px)",maxHeight:Se,"--dt-column-menu-max-height":`${Se}px`};Dd(Ne)},[]);function bs(d,v,P=null){d.preventDefault(),d.stopPropagation();const y=ba.current===d.currentTarget&&ir===v&&St===P;if(Xe&&y){Tr(!1),la(null);return}ba.current=d.currentTarget,Cd(v),la(P),Yo(""),pn(d.currentTarget),Tr(!0)}function Yd(d){if(Mr(d))return;const v=Nr.current;if(!v)return;const y=Array.from(v.querySelectorAll("[data-dt-column-key]")).filter(G=>G.dataset.dtColumnKey===d.key).reduce((G,ie)=>{const fe=ie.querySelector("[data-dt-autofit-content]"),ye=fe?fe.scrollWidth:Math.max(ie.scrollWidth,ie.offsetWidth);return Math.max(G,Math.ceil(ye+$l(ie)))},0);y<=0||at(G=>({...G,[d.key]:er(d,y+12)}))}o.useEffect(()=>{at(d=>{const v=Object.fromEntries(r.map(P=>[P.key,er(P,gr(P.width))]));return Object.fromEntries(r.map(P=>[P.key,er(P,d[P.key]??v[P.key])]))})},[lr,r]),o.useEffect(()=>{Be||Ke(d=>vr(d,r))},[lr,r,Be]),o.useEffect(()=>{function d(y){var fe,ye;const G=y.target,ie=y.target;ie!=null&&ie.closest("[data-bonsaif-select-dropdown='true']")||!((fe=rs.current)!=null&&fe.contains(G))&&!((ye=ba.current)!=null&&ye.contains(G))&&(Tr(!1),la(null))}function v(y){y.key==="Escape"&&(Tr(!1),la(null))}function P(){pn()}return Xe&&(document.addEventListener("mousedown",d),window.addEventListener("keydown",v),window.addEventListener("resize",P),window.addEventListener("scroll",P,!0)),()=>{document.removeEventListener("mousedown",d),window.removeEventListener("keydown",v),window.removeEventListener("resize",P),window.removeEventListener("scroll",P,!0)}},[Xe,pn]);const Tt=o.useRef(null);o.useEffect(()=>{function d(P){const y=Tt.current;if(!y)return;const G=P.clientX-y.startX,ie=r.find(fe=>fe.key===y.colKey);ie&&at(fe=>({...fe,[y.colKey]:er(ie,y.startWidth+G)}))}function v(){Tt.current&&(Tt.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",d),document.addEventListener("pointerup",v),()=>{document.removeEventListener("pointermove",d),document.removeEventListener("pointerup",v)}},[r]);const ya=o.useRef(null),[ps,mn]=o.useState(null);function Zd(d,v){ya.current=et.indexOf(d),v.dataTransfer.effectAllowed="move"}function Qd(d,v){v.preventDefault(),v.dataTransfer.dropEffect="move";const P=et.indexOf(d);ps!==P&&mn(P)}function Jd(d,v){v.preventDefault();const P=ya.current,y=et.indexOf(d);P!==null&&P!==y&&rt(G=>{const ie=[...G],[fe]=ie.splice(P,1);return ie.splice(y,0,fe),ie}),ya.current=null,mn(null)}function Rd(){ya.current=null,mn(null)}function eu(d){d.sortKey&&Br(v=>(v==null?void 0:v.key)===d.key?{key:d.key,dir:v.dir==="asc"?"desc":"asc"}:{key:d.key,dir:"asc"})}o.useEffect(()=>{pa(1)},[t]),o.useEffect(()=>{pa(1)},[cr,Qe]);const Or=!!(Z&&W),Hr=k!==!1,ms=o.useMemo(()=>ht(U??ut()),[U]),je=Or?L??1:zd,ur=Or||Hr?ma:t.length,fr=!!M&&!!g&&!!C,nt=!!f,hs=o.useMemo(()=>new Set(nn?Array.from(b??[]):Zo),[nn,b,Zo]),hn=(nt?40:0)+(fr?40:0),ru=fr&&t.length>0&&M.size===t.length,tu=fr&&M.size>0&&M.size<t.length,wa=o.useMemo(()=>{const d=Object.entries(Qe),v=Object.entries(cr);return d.length===0&&v.length===0?t:t.filter(P=>d.every(([y,G])=>{const ie=r.find(fe=>fe.key===y);return ie?G.includes(Wt(ie,P)):!0})&&v.every(([y,G])=>{const ie=r.find(ye=>ye.key===y);if(!ie)return!0;const fe=t.map(ye=>Wt(ie,ye));return Dl(Wt(ie,P),G,fe)}))},[cr,Qe,r,t]),Pr=o.useMemo(()=>{if(!De)return wa;const d=r.find(v=>v.key===De.key&&v.sortKey);return d!=null&&d.sortKey?[...wa].sort((v,P)=>{const y=v[d.sortKey],G=P[d.sortKey],ie=y===G?0:y==null?1:G==null||y<G?-1:1;return De.dir==="asc"?ie:-ie}):wa},[wa,De,r]),gs=o.useMemo(()=>{if(Or||!Hr)return Pr;const d=(je-1)*ur;return Pr.slice(d,d+ur)},[Pr,Or,Hr,je,ur]),Fr=Or?Q??t.length:Pr.length,gn=Hr?Math.max(1,Math.ceil(Fr/ur)):1,au=Math.min(...ms),nu=Hr&&(Fr>ur||Fr>au),ou=Hr?(je-1)*ur+1:1,su=Hr?Math.min(je*ur,Fr):Fr;function vn(d){if(n)return;const v=Math.max(1,Math.min(d,gn));Or?Z(v):pa(v)}function lu(d){n||(z&&(Ir.current=z),ha(d),Or?(W(d),Z(1)):(pa(1),W==null||W(d)))}function vs(d){const v=new Set(hs);v.has(d)?v.delete(d):v.add(d);const P=Array.from(v);nn||Ed(P),x==null||x(P)}o.useEffect(()=>{Ee==null||Ee({bql:pr,filters:Qe,conditionFilters:cr,sort:De,page:je,pageSize:ur,hiddenColumnKeys:Fe})},[pr,Qe,cr,De,je,ur,Fe,Ee]);const xs=d=>d==="center"?"text-center":d==="right"?"text-right":"text-left",iu="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",xn="linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 90%, var(--bg-card)) 0%, color-mix(in srgb, var(--bg-input) 70%, var(--bg-card)) 100%)",Ce="color-mix(in srgb, var(--border) 62%, var(--bg-card))",ot="color-mix(in srgb, var(--primary) 24%, var(--border))",Na=`inset 0 0 0 1px ${Ce}`,ys=nr.reduce((d,v)=>d+(tt[v.key]??gr(v.width)),(nt?40:0)+(fr?40:0)),ws=typeof w=="number"?w:typeof w=="string"?Number(((Es=w.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:Es[1])??NaN):NaN,At=Number.isFinite(ws)?Math.max(ys,ws,ns):Math.max(ys,ns),ka=w??At,st=`${nt?"40px ":""}${fr?"40px ":""}${nr.map(d=>`${tt[d.key]??gr(d.width)}px`).join(" ")}`;o.useEffect(()=>{De&&Fe.includes(De.key)&&Br(null)},[Fe,De]);function Ns(d){return d?typeof d=="string"?{key:d,label:d}:d:null}const Sa=()=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:st,background:xn,borderBottom:`1px solid ${ot}`},children:[nt&&e.jsx("div",{role:"columnheader",className:`${I?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${ot}`,borderRight:`1px solid ${Ce}`}}),fr&&e.jsx("div",{role:"columnheader",className:`${I?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:ee?{position:"sticky",left:0,zIndex:12,background:xn,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${ot}`,borderRight:`1px solid ${Ce}`}:{borderBottom:`1px solid ${ot}`,borderRight:`1px solid ${Ce}`},children:e.jsx(Ht,{size:"sm",checked:ru,indeterminate:tu,onChange:C,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),nr.map((d,v)=>{const P=(De==null?void 0:De.key)===d.key,y=!!d.sortKey,G=Mr(d),ie=ee&&!dn&&v===0,fe=ps===v,ze=(tt[d.key]??gr(d.width))<120,Pe=Object.prototype.hasOwnProperty.call(Qe,d.key)||Object.prototype.hasOwnProperty.call(cr,d.key);return e.jsxs("div",{role:"columnheader","data-dt-column-key":d.key,className:`group select-none ${ze?"text-left":xs(d.align)}`,style:{...ie?{position:"sticky",left:hn,zIndex:12,background:xn,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${ot}`,borderRight:`1px solid ${Ce}`}:{position:"relative",borderBottom:`1px solid ${ot}`,borderRight:`1px solid ${Ce}`},color:P?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:fe?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:G?I?"7px 6px":"9px 8px":I?"8px 6px 10px":"10px 8px 12px"},onDragOver:we=>Qd(d.key,we),onDrop:we=>Jd(d.key,we),children:[e.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${G?"justify-center":ze?"justify-start":d.align==="center"?"justify-center":d.align==="right"?"justify-end":"justify-start"}`,children:[e.jsx("span",{draggable:!0,onDragStart:we=>{we.stopPropagation(),Zd(d.key,we)},onDragEnd:we=>{we.stopPropagation(),Rd()},onClick:we=>we.stopPropagation(),title:"Arrastrar para mover columna","aria-label":"Arrastrar para mover columna",className:`absolute left-0 top-0 z-10 inline-flex h-full w-3 shrink-0 rounded-sm transition-colors duration-150 hover:bg-[var(--primary)]/15 ${fe?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}),G?e.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-md text-[var(--text-muted)]",title:"Acciones","aria-label":"Acciones",children:e.jsx(T.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):e.jsx(jn,{className:"min-w-0 flex-1",children:e.jsx("span",{"data-dt-autofit-content":!0,className:`inline-flex max-w-full items-center font-semibold uppercase tracking-wider ${I?"text-[11px]":"text-xs"}`,children:e.jsx("span",{className:"min-w-0 truncate",children:d.header})})}),y&&e.jsx("button",{type:"button","aria-label":`Ordenar por ${String(d.header)}`,title:"Ordenar",onClick:we=>{we.stopPropagation(),eu(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 ${P?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:P?De.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"})}),R&&!G&&qd(d)&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Xe&&St===d.key,"aria-label":`Filtrar ${String(d.header)}`,title:"Filtrar",onClick:we=>bs(we,"filter",d.key),className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-sm bg-transparent text-[var(--text-muted)] opacity-0 transition-[opacity,color,background-color] duration-150 hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] focus:opacity-100 group-hover:opacity-100 ${Xe&&ir==="filter"&&St===d.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":Pe?"text-[var(--primary)] opacity-100":""}`,children:Pe?e.jsx(T.HiFunnel,{className:"h-3.5 w-3.5"}):e.jsx(T.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!G&&e.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:we=>{we.preventDefault(),we.stopPropagation(),Tt.current={colKey:d.key,startX:we.clientX,startWidth:tt[d.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:we=>{we.preventDefault(),we.stopPropagation(),Tt.current=null,document.body.style.cursor="",document.body.style.userSelect="",Yd(d)},onClick:we=>we.stopPropagation(),className:"absolute top-0 flex h-full items-center justify-center opacity-0 transition-opacity duration-200 hover:opacity-100",style:{right:0,width:12,cursor:"col-resize",zIndex:6,transform:"translateX(50%)"},children:e.jsxs("span",{style:{display:"flex",gap:4,alignItems:"center",height:"calc(100% - 8px)"},children:[e.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}}),e.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}})]})})]},d.key)})]}),Ca=()=>{if(!Xe||typeof document>"u"||ir==="visibility"&&!S||ir==="filter"&&!R)return null;const d=r.find(Ne=>Ne.key===St),v=Wd(),P=d?Object.prototype.hasOwnProperty.call(Qe,d.key):!1,y=d?cr[d.key]:void 0,G=_t.find(Ne=>Ne.value===(y==null?void 0:y.operator)),ie=d?Qe[d.key]??[]:[],fe=Xo.trim().toLowerCase(),ye=fe?v.filter(Ne=>Ne.label.toLowerCase().includes(fe)):v,ze=d&&v.length>0&&(!P||ie.length===v.length),Pe=d&&P&&ie.length>0&&ie.length<v.length,we=Fe.length,Se=()=>{d&&(fn(d.key),cs(d.key))};return Je.createPortal(e.jsx("div",{ref:rs,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Ad,borderColor:"var(--border)",background:"var(--bg-card)"},children:ir==="visibility"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[e.jsx("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:we>0?`${nr.length} de ${r.length} visibles`:`${r.length} visibles`}),e.jsx("button",{type:"button",onClick:Xd,disabled:we===0,className:"rounded px-1.5 py-0.5 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-input)] disabled:opacity-40",children:"Mostrar todas"})]}),e.jsx("div",{className:"max-h-72 overflow-auto py-1",children:ss.map(Ne=>{const qe=!Fe.includes(Ne.key),pe=!(Ne.hideable!==!1)||qe&&nr.length<=1;return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":qe,disabled:pe,onClick:()=>Kd(Ne.key),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:qe?"var(--primary)":"var(--border)",background:qe?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:qe&&e.jsx(T.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:Ne.header})]},Ne.key)})})]}):d?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[e.jsxs("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:["Filtrar ",d.header]}),e.jsx("button",{type:"button",onClick:Se,disabled:!P&&!y,className:"rounded px-1.5 py-0.5 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-input)] disabled:opacity-40",children:"Limpiar"})]}),d.sortKey&&e.jsxs("div",{className:"grid grid-cols-2 gap-1 border-b border-[var(--border)] p-1",children:[e.jsxs("button",{type:"button",onClick:()=>Br({key:d.key,dir:"asc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[e.jsx(T.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate",children:"Ascendente"})]}),(De==null?void 0:De.key)===d.key&&De.dir==="asc"&&e.jsx(T.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),e.jsxs("button",{type:"button",onClick:()=>Br({key:d.key,dir:"desc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[e.jsx(T.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate",children:"Descendente"})]}),(De==null?void 0:De.key)===d.key&&De.dir==="desc"&&e.jsx(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(Er,{value:(y==null?void 0:y.operator)??"",onChange:Ne=>{if(!Ne){cs(d.key);return}ga(d.key,{operator:Ne,value:(y==null?void 0:y.value)??"",valueTo:(y==null?void 0:y.valueTo)??""})},options:yl,placeholder:"Opcion",emptyLabel:"Sin condicion",ariaLabel:"Operador de filtro",searchable:!1,height:34,padding:"0 9px",dropdownMinWidth:260,className:"min-w-0 [&>button]:rounded-md [&>button]:text-sm [&>button]:font-medium"}),(G==null?void 0:G.valueMode)!=="none"?e.jsx("input",{value:(y==null?void 0:y.value)??"",onChange:Ne=>{y&&ga(d.key,{...y,value:Ne.target.value})},disabled:!y,placeholder:"Valor",className:"min-w-0 rounded-md border px-2 py-1.5 text-sm outline-none transition-colors placeholder:text-[var(--text-muted)] focus:border-[var(--primary)] disabled:opacity-50",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"}}):e.jsx("div",{className:"min-h-8 rounded-md border px-2 py-1.5 text-sm text-[var(--text-muted)]",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:"Automatico"})]}),(G==null?void 0:G.valueMode)==="between"&&e.jsx("input",{value:(y==null?void 0:y.valueTo)??"",onChange:Ne=>{y&&ga(d.key,{...y,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(T.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),e.jsx("input",{value:Xo,onChange:Ne=>Yo(Ne.target.value),placeholder:"Buscar",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-[var(--text-muted)]",style:{color:"var(--text-main)"}})]})}),e.jsxs("div",{className:"overflow-auto py-1",style:{maxHeight:"max(96px, calc(var(--dt-column-menu-max-height, 520px) - 236px))"},children:[e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Pe?"mixed":!!ze,onClick:()=>{d&&(ze&&!P?is(d.key,[]):fn(d.key))},className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[e.jsxs("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:ze||Pe?"var(--primary)":"var(--border)",background:ze||Pe?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[Pe&&e.jsx(T.HiMinus,{className:"h-3 w-3"}),ze&&!Pe&&e.jsx(T.HiCheck,{className:"h-3 w-3"})]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),ye.map(Ne=>{const qe=!P||ie.includes(Ne.value);return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":qe,onClick:()=>Ud(d.key,Ne.value,v.map(be=>be.value),P),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:qe?"var(--primary)":"var(--border)",background:qe?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:qe&&e.jsx(T.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:Ne.label})]},Ne.value)}),ye.length===0&&e.jsx("div",{className:"px-3 py-3 text-sm text-[var(--text-muted)]",children:"Sin valores"})]})]}):null}),document.body)};o.useEffect(()=>{if(!$t)return;function d(v){ln.current&&!ln.current.contains(v.target)&&fa.current&&!fa.current.contains(v.target)&&ua(!1)}return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[$t]);function ks(d,v){if(d.filterValue){const P=d.filterValue(v);return P==null||P===""?"":String(P)}return Wr(d.cell(v))}function Ss(d){return`"${d.replace(/"/g,'""')}"`}function Ea(d){return d.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function cu(){const d=nr.filter(ye=>!Mr(ye)),v=d.map(ye=>Ss(Wr(ye.header))).join(","),P=Pr.map(ye=>d.map(ze=>Ss(ks(ze,ye))).join(",")).join(`
5
- `),y=`${v}
6
- ${P}`,G=new Blob(["\uFEFF"+y],{type:"text/csv;charset=utf-8;"}),ie=URL.createObjectURL(G),fe=document.createElement("a");fe.href=ie,fe.download=`${We}.csv`,document.body.appendChild(fe),fe.click(),document.body.removeChild(fe),URL.revokeObjectURL(ie)}function du(){const d=nr.filter(fe=>!Mr(fe)),v=d.map(fe=>Ea(Wr(fe.header))),y=Pr.map(fe=>d.map(ye=>Ea(ks(ye,fe)))).map(fe=>`<tr>${fe.map(ye=>`<td>${ye}</td>`).join("")}</tr>`).join(""),G=`<!DOCTYPE html>
7
- <html lang="es"><head><meta charset="utf-8"><title>${Ea(We)}</title>
1
+ (function(P,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react"),require("react/jsx-runtime"),require("react-icons/hi2"),require("react-dom"),require("recharts"),require("overlayscrollbars"),require("sonner"),require("overlayscrollbars-react"),require("react-day-picker"),require("react-day-picker/dist/style.css"),require("react-icons/fi")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","react-icons/hi2","react-dom","recharts","overlayscrollbars","sonner","overlayscrollbars-react","react-day-picker","react-day-picker/dist/style.css","react-icons/fi"],o):(P=typeof globalThis<"u"?globalThis:P||self,o(P.BonsaifUI={},P.React,P.jsxRuntime,P.ReactIconsHi2,P.ReactDOM,P.Recharts,P.OverlayScrollbarsGlobal,P.Sonner,P.OverlayScrollbarsReact,P.ReactDayPicker,P.ReactDayPickerStyles,P.ReactIconsFi))})(this,(function(P,o,e,A,Je,ge,$a,Nn,kn,Sn,vu,Bs){"use strict";"use client";function hr(...r){return r.filter(Boolean).join(" ")}function Os({variant:r="primary",className:t,type:a="button",children:n,...s}){return e.jsx("button",{className:hr("bonsaif-ui-button",`bonsaif-ui-button--${r}`,t),type:a,...s,children:n})}function Cn({value:r,onChange:t,placeholder:a,className:n="",autoFocus:s=!1,forceExpanded:l=!1,onEscape:i,size:c="default",inputTabIndex:d}){const f=o.useRef(null),[b,p]=o.useState(!1),m=l||b||r.trim().length>0,w=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",k=n||"w-48 max-w-full sm:w-64 lg:w-72";o.useEffect(()=>{var g;s&&((g=f.current)==null||g.focus())},[s]);const M=()=>{var g;p(!0),(g=f.current)==null||g.focus()};return e.jsxs("div",{className:`relative min-w-0 max-w-full flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${m?k:"w-24 sm:w-28"}`,onMouseDown:g=>{m||(g.preventDefault(),M())},children:[e.jsx(A.HiMagnifyingGlass,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none transition-colors duration-200",style:{color:"var(--text-muted)",left:"var(--page-header-control-icon-left, 12px)"}}),e.jsx("input",{ref:f,type:"text",tabIndex:d,"aria-label":a,value:r,onChange:g=>t(g.target.value),onKeyDown:g=>{g.key==="Escape"&&(i==null||i())},placeholder:m?a:"Buscar",className:`${w} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${m?"pl-9 pr-8":"cursor-pointer pl-9 pr-3"}`,style:{height:`var(--page-header-control-height, ${c==="sm"?"36px":"40px"})`,paddingLeft:"calc(var(--page-header-control-icon-left, 12px) + 24px)",paddingRight:m?"calc(var(--page-header-control-padding-x, 14px) + 18px)":"var(--page-header-control-padding-x, 14px)",background:"color-mix(in srgb, var(--bg-card) 86%, transparent)",border:"1px solid var(--border)",color:"var(--text-main)"},onFocus:g=>{p(!0),g.currentTarget.style.borderColor="var(--primary)",g.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:g=>{p(!1),g.currentTarget.style.borderColor="var(--border)",g.currentTarget.style.boxShadow="none"}}),r&&e.jsx("button",{type:"button",onClick:()=>t(""),className:"absolute right-2 top-1/2 flex !h-6 !w-6 -translate-y-1/2 items-center justify-center rounded-full !p-0 leading-none transition-colors hover:bg-black/5",style:{color:"var(--text-muted)",right:"var(--page-header-control-padding-x, 8px)"},"aria-label":"Limpiar búsqueda",children:e.jsx(A.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const En=o.createContext({});let Mn=0;const Tn="bonsaif-ui:hide-tooltips";function Ot(r=700){Mn=Date.now()+r}function Hs(){return Date.now()>Mn}function Ht(r){if(typeof document>"u")return!1;const t=Array.from(document.querySelectorAll('[data-bonsaif-overlay="true"], [role="menu"], [role="dialog"][aria-modal="true"], [aria-hidden="false"] [aria-modal="true"]'));return r&&t.some(a=>a.contains(r))?!1:t.length>0}function Ps(r){var n;const t=Array.from(r.querySelectorAll("*")).filter(s=>{var l;return s.scrollWidth>s.clientWidth&&!!((l=s.textContent)!=null&&l.trim())&&s.tagName.toLowerCase()!=="svg"&&!s.closest("svg")});return(r.scrollWidth>r.clientWidth||t.length>0)&&(((n=t[0])==null?void 0:n.textContent)??r.textContent??"").trim()||null}function jr({children:r,content:t,onlyWhenOverflow:a=!1,interactive:n=!1,followCursor:s=!0,placement:l="bottom",showArrow:i=!1,className:c="",tooltipClassName:d="",style:f,tooltipStyle:b,as:p="div"}){const m=o.useRef(null),w=o.useRef(null),k=o.useRef(null),M=o.useRef(!1),[g,C]=o.useState(null),[O,D]=o.useState("");o.useEffect(()=>{const T=m.current;T&&(T.querySelectorAll("[title]").forEach(J=>{const B=J.getAttribute("title");B&&(J.getAttribute("aria-label")||J.setAttribute("aria-label",B),J.removeAttribute("title"))}),T.querySelectorAll("svg title").forEach(J=>J.remove()))}),o.useLayoutEffect(()=>{if(!g)return;const T=w.current;if(!T)return;const J=12,B=14,_=T.getBoundingClientRect(),re=window.innerWidth-_.width-J,Q=window.innerHeight-_.height-J;let $=g.mouseX+B,R=g.mouseY+B,oe,x;if(!s&&m.current){const y=m.current.getBoundingClientRect(),V=y.left+y.width/2,q=y.top+y.height/2;l==="top"?($=V-_.width/2,R=y.top-_.height-B,x=_.height-1):l==="left"?($=y.left-_.width-B,R=q-_.height/2,oe=_.width-1):l==="right"?($=y.right+B,R=q-_.height/2,oe=-7):($=V-_.width/2,R=y.bottom+B,x=-7)}if(s&&($>re&&($=g.mouseX-_.width-B),R>Q&&(R=g.mouseY-_.height-B)),$=Math.min(Math.max(J,$),Math.max(J,re)),R=Math.min(Math.max(J,R),Math.max(J,Q)),!s&&m.current){const y=m.current.getBoundingClientRect(),V=y.left+y.width/2,q=y.top+y.height/2;l==="top"||l==="bottom"?oe=Math.min(Math.max(14,V-$),_.width-14):x=Math.min(Math.max(14,q-R),_.height-14)}(Math.abs($-g.x)>.5||Math.abs(R-g.y)>.5||oe!==g.arrowX||x!==g.arrowY)&&C(y=>y&&{...y,x:$,y:R,arrowX:oe,arrowY:x})},[s,l,g]);const z=()=>{k.current&&(window.clearTimeout(k.current),k.current=null)},E=(T,J)=>{if(!Hs()||M.current)return;const B=m.current;if(B&&!Ht(B)){if(a){const _=Ps(B);if(!_)return;D(_)}!a&&!t||C({mouseX:T,mouseY:J,x:T+14,y:J+14})}},S=()=>{const T=m.current;if(!T)return;const J=T.getBoundingClientRect();E(J.left+J.width/2,J.bottom)},U=()=>{z(),C(null)},H=()=>{if(!n){U();return}z(),k.current=window.setTimeout(()=>C(null),120)},W=()=>{Ot(),M.current=!0,U()},Y=()=>{M.current=!1};o.useEffect(()=>{if(!g)return;if(Ht(m.current)){C(null);return}const T=()=>C(null),J=()=>{Ot(),M.current=!0,C(null)};document.addEventListener("pointerdown",J,!0),document.addEventListener("click",J,!0),document.addEventListener("scroll",T,!0),window.addEventListener("blur",T),document.addEventListener("visibilitychange",T),document.addEventListener("keydown",T,!0);const B=new MutationObserver(()=>{Ht(m.current)&&C(null)});return B.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",J,!0),document.removeEventListener("click",J,!0),document.removeEventListener("scroll",T,!0),window.removeEventListener("blur",T),document.removeEventListener("visibilitychange",T),document.removeEventListener("keydown",T,!0),B.disconnect()}},[g]),o.useEffect(()=>{const T=()=>Ot(),J=()=>{Ot(),M.current=!0,C(null)};return document.addEventListener("pointerdown",T,!0),document.addEventListener("click",T,!0),document.addEventListener("keydown",T,!0),window.addEventListener(Tn,J),()=>{document.removeEventListener("pointerdown",T,!0),document.removeEventListener("click",T,!0),document.removeEventListener("keydown",T,!0),window.removeEventListener(Tn,J)}},[]);const Z=a?O:t;return e.jsxs(e.Fragment,{children:[e.jsx(p,{ref:T=>{m.current=T},className:c,style:f,onMouseEnter:T=>{z(),Y(),s?E(T.clientX,T.clientY):S()},onMouseMove:T=>{g&&s&&E(T.clientX,T.clientY)},onMouseDown:W,onClick:W,onMouseLeave:()=>{Y(),H()},onFocus:S,onBlur:U,children:r}),g&&Z&&!Ht(m.current)?Je.createPortal(e.jsxs("div",{ref:w,role:"tooltip",className:d,onMouseEnter:n?z:void 0,onMouseLeave:n?H:void 0,style:{position:"fixed",top:g.y,left:g.x,zIndex:9999,background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:6,padding:"5px 10px",fontSize:12,color:"var(--text-main)",boxShadow:"0 4px 16px rgba(0,0,0,0.35)",pointerEvents:n?"auto":"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere",...b},children:[i&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",width:12,height:12,background:(b==null?void 0:b.background)??"var(--bg-card)",borderLeft:l==="right"?(b==null?void 0:b.border)??"1px solid var(--border)":void 0,borderTop:l==="bottom"||l==="right"?(b==null?void 0:b.border)??"1px solid var(--border)":void 0,borderRight:l==="left"?(b==null?void 0:b.border)??"1px solid var(--border)":void 0,borderBottom:l==="top"||l==="left"?(b==null?void 0:b.border)??"1px solid var(--border)":void 0,transform:"rotate(45deg)",left:g.arrowX===void 0?void 0:g.arrowX-6,top:g.arrowY===void 0?void 0:g.arrowY-6,zIndex:-1}}),Z]}),document.body):null]})}function Ln(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}const Fs="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"},_s="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"},Ws={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},qs={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function Aa(r){return typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(Aa).join(" ").trim():o.isValidElement(r)?Aa(r.props.children):""}function Us(r){return o.Children.toArray(r).find(o.isValidElement)??null}function Pe({variant:r="primary",size:t="md",loading:a=!1,icon:n,tooltip:s,iconOnly:l,height:i,padding:c,children:d,className:f="",disabled:b,style:p,...m}){const w=o.useContext(En),k=l??w.iconOnly??r==="icon",M=w.compact??!1,g=w.headerAction??!1,C=g&&t==="md"?"sm":M&&!g&&t==="md"?"xs":t,O=r==="icon"||k,D=g&&O,z=Aa(d),E=s??m.title??m["aria-label"]??(k?z:void 0),S=E?void 0:m.title,U=m["aria-label"]??(typeof E=="string"?E:z||void 0),H=a?null:n??(k?Us(d):null),W=e.jsxs("button",{...m,title:S,"aria-label":U,"data-variant":r,"data-size":C,"data-icon":O?"true":void 0,disabled:b||a,className:`${Fs} ${D?_s:zs[r]} ${O?Ws[C]:js[C]} ${M&&!O?"px-2.5":""} ${f}`,style:{...qs[r],height:Ln(i),padding:Ln(c),...p,...g&&!O?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...D?{width:"var(--page-header-control-height, 40px)",height:"var(--page-header-control-height, 40px)",padding:0,background:"var(--bg-card)",borderRadius:"8px"}:null},children:[a?e.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):H,!k&&d]});return E?e.jsx(jr,{as:"span",content:E,className:"inline-flex shrink-0",children:W}):W}const Ve={background:"color-mix(in srgb, var(--text-muted) 26%, var(--bg-input))"};function Pt({rows:r=8,columns:t=7,showToolbar:a=!0,showPagination:n=!0,compact:s=!1,className:l=""}){const i=Math.max(3,Math.min(t,12)),c=Math.max(3,Math.min(r,20)),d=s?"px-2 py-2":"px-3 py-2.5",f=s?"px-2 py-2":"px-3 py-3";return e.jsxs("div",{className:`w-full min-w-0 overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${l}`,"aria-busy":"true","aria-label":"Cargando tabla",children:[a&&e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-3 py-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx("div",{className:"h-7 w-14 shrink-0 animate-pulse rounded-md",style:Ve}),e.jsx("div",{className:"h-7 max-w-md flex-1 animate-pulse rounded-md",style:Ve})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:Ve}),e.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:Ve})]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("div",{className:"min-w-full",style:{display:"grid",gridTemplateColumns:`repeat(${i}, minmax(96px, 1fr))`},children:[Array.from({length:i}).map((b,p)=>e.jsx("div",{className:`${f} border-b border-[var(--border)]`,style:{background:"color-mix(in srgb, var(--bg-input) 55%, transparent)"},children:e.jsx("div",{className:"h-3 animate-pulse rounded-md",style:{...Ve,width:`${48+p*17%40}%`}})},`h-${p}`)),Array.from({length:c}).map((b,p)=>Array.from({length:i}).map((m,w)=>e.jsx("div",{className:`${d} ${p<c-1?"border-b border-[var(--border)]":""}`,children:e.jsx("div",{className:"h-3.5 animate-pulse rounded-md",style:{...Ve,width:`${46+(p*13+w*11)%42}%`,minWidth:28}})},`c-${p}-${w}`)))]})}),n&&e.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-[var(--border)] px-3 py-2",style:{background:"color-mix(in srgb, var(--bg-input) 40%, transparent)"},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-28 animate-pulse rounded-md",style:Ve}),e.jsx("div",{className:"h-7 w-14 animate-pulse rounded-md",style:Ve})]}),e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:4}).map((b,p)=>e.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:Ve},p))}),e.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:Ve})]})]})}function $n({variant:r="page",title:t="Cargando...",rows:a=6,columns:n=7,children:s}){return r==="table"?e.jsx(Pt,{rows:a,columns:n}):r==="sections"?e.jsx(Vs,{rows:a}):r==="cards"?e.jsx(Gs,{rows:a}):e.jsx("div",{className:"flex min-h-[240px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[e.jsx("div",{className:"h-9 w-9 animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:t}),s&&e.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:s})]})]})})}function Vs({rows:r}){return e.jsx(Pt,{rows:r,columns:7})}function Gs({rows:r}){return e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:Array.from({length:r}).map((t,a)=>e.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[e.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded-md",style:Ve}),e.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded-md",style:Ve}),e.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded-md",style:Ve})]},a))})}function An(r){const t=r.split("/").filter(Boolean);return(t[t.length-1]??r).replace(/^lv_/,"").split(/[-_]/).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function Dn(r){return r.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function Ks(r){return[r.label,An(r.service),r.description,r.service].filter(Boolean).join(" ")}function Xs(r){return typeof r=="function"?r:r.default}function Ys(r,t){return e.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 text-center",children:e.jsxs("div",{className:"max-w-md",children:[e.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:"No se pudo cargar este modulo"}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:r.message}),e.jsx(Pe,{className:"mt-4",height:36,padding:"0 14px",onClick:t,children:"Reintentar"})]})})}function Zs({parentPanel:r,parentPanelComponent:t,renderParentPanel:a,parent:n,context:s,links:l,moduleRegistry:i,loadModule:c,activeService:d,initialService:f,onActiveServiceChange:b,canAccess:p,keepAlive:m=!0,title:w,subtitle:k,emptyState:M,loadingState:g,errorState:C=Ys,renderTabLabel:O,searchableTabs:D="auto",tabsSearchThreshold:z=6,tabsSearchPlaceholder:E="Buscar modulo...",tabsSearchValue:S,onTabsSearchChange:U,emptySearchState:H,showTabCount:W=!0,className:Y="",parentClassName:Z="",contentClassName:T="",tabsClassName:J=""}){var lr;const B=o.useMemo(()=>l.filter(de=>!de.hidden&&((p==null?void 0:p(de,s))??!0)),[p,s,l]),_=(lr=B.find(de=>!de.disabled))==null?void 0:lr.service,[re,Q]=o.useState(f??_??""),[$,R]=o.useState({}),[oe,x]=o.useState({}),[y,V]=o.useState(""),[q,ee]=o.useState(!1),ce=o.useRef(oe),ve=o.useRef(0),te=S??y,X=Dn(te),h=D===!0||D==="auto"&&B.length>=z,L=h&&te.trim().length>0,j=o.useMemo(()=>X?B.filter(de=>Dn(Ks(de)).includes(X)):B,[X,B]),ae=d??re,ne=B.find(de=>de.service===ae)??B.find(de=>!de.disabled);o.useEffect(()=>{!ne&&_&&Q(_)},[_,ne]),o.useEffect(()=>{ce.current=oe},[oe]);const he=de=>{de.disabled||(d||Q(de.service),b==null||b(de.service,de))},Oe=de=>{S===void 0&&V(de),U==null||U(de)},Ge=(de,I)=>{const G=j.filter(ue=>!ue.disabled),le=G.findIndex(ue=>ue.service===I.service);le<0||((de.key==="ArrowRight"||de.key==="ArrowDown")&&(de.preventDefault(),he(G[(le+1)%G.length])),(de.key==="ArrowLeft"||de.key==="ArrowUp")&&(de.preventDefault(),he(G[(le-1+G.length)%G.length])),de.key==="Home"&&(de.preventDefault(),he(G[0])),de.key==="End"&&(de.preventDefault(),he(G[G.length-1])))},xe=o.useCallback(()=>{if(!ne)return;const de=ne.service,I=ce.current[de];if(I!=null&&I.loading||I!=null&&I.component&&m)return;const G=(i==null?void 0:i[de])??c;if(!G){x(ue=>({...ue,[de]:{loading:!1,error:new Error(`No module loader found for service "${de}".`)}}));return}const le=++ve.current;x(ue=>({...ue,[de]:{...ue[de],loading:!0,error:void 0}})),G(ne,s).then(ue=>{if(le!==ve.current&&!m)return;const Le=Xs(ue);x(ke=>({...ke,[de]:{component:Le,loading:!1}}))}).catch(ue=>{const Le=ue instanceof Error?ue:new Error(String(ue));x(ke=>({...ke,[de]:{...ke[de],loading:!1,error:Le}}))})},[s,m,c,i,ne]);o.useEffect(xe,[xe]);const Ee=ne?$[ne.service]??null:null,Ae=ne?oe[ne.service]:void 0,wr=Ae==null?void 0:Ae.component,br=de=>{ne&&R(I=>({...I,[ne.service]:de}))},We=()=>{ne&&R(de=>({...de,[ne.service]:null}))},se={context:s,parent:n,links:l,visibleLinks:B,filteredLinks:j,selectedLink:ne,selectedService:ne==null?void 0:ne.service,activeItemId:Ee,tabsSearch:te,onSelectService:he,onOpenDetail:br,onBackToList:We},Ze=a?a(se):t?e.jsx(t,{...se}):r;return e.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${Y}`,children:[e.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${Z}`,children:Ze}),e.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${T}`,children:[(w||k||h||W)&&e.jsx("div",{className:"relative border-b border-[var(--border)] px-4 py-3",children:e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[w&&e.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:w}),k&&e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:k})]}),(h||W)&&e.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[W&&e.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[j.length," / ",B.length]}),h&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${q?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!q,children:e.jsx(Cn,{value:te,onChange:Oe,placeholder:E,className:"w-full",autoFocus:q,forceExpanded:!0,onEscape:()=>ee(!1),size:"sm",inputTabIndex:q?0:-1})}),e.jsx("button",{type:"button","aria-label":q?"Cerrar busqueda":"Buscar tabs","aria-expanded":q,onClick:()=>{q&&te&&Oe(""),ee(de=>!de)},className:`inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border transition-all duration-200 hover:scale-[1.03] active:scale-95 ${q||L?"border-[var(--primary)] bg-[var(--bg-input)] text-[var(--text-main)] shadow-sm":"border-[var(--border)] text-[var(--text-muted)] hover:bg-[var(--bg-input)] hover:text-[var(--text-main)]"}`,children:e.jsx("span",{className:"grid h-4 w-4 place-items-center transition-transform duration-200",children:q||L?e.jsx(A.HiXMark,{className:"h-4 w-4"}):e.jsx(A.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),e.jsx("div",{role:"tablist","aria-label":w??"Modulos relacionados",className:`flex gap-1 overflow-x-auto border-b border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 transition-colors duration-200 ${J}`,children:j.length>0?j.map(de=>{const I=de.service===(ne==null?void 0:ne.service);return e.jsx("button",{type:"button",role:"tab","aria-selected":I,disabled:de.disabled,onClick:()=>he(de),onKeyDown:G=>Ge(G,de),className:`inline-flex h-9 min-w-max items-center gap-2 rounded-md border px-3 text-xs font-semibold transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-50 ${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(de,I):e.jsxs(e.Fragment,{children:[de.icon,e.jsx("span",{children:de.label??An(de.service)}),de.badge&&e.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:de.badge})]})},de.service)}):e.jsx("div",{className:"flex min-h-9 flex-1 items-center rounded-md border border-dashed border-[var(--border)] px-3 text-xs text-[var(--text-muted)]",children:H??"No hay modulos que coincidan con la busqueda."})}),(ne==null?void 0:ne.description)&&e.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:ne.description}),e.jsxs("div",{className:"min-h-[420px] p-4",children:[!ne&&(M??e.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-dashed border-[var(--border)] text-sm text-[var(--text-muted)]",children:"No hay modulos disponibles."})),ne&&(Ae==null?void 0:Ae.loading)&&(g??e.jsx($n,{title:"Cargando modulo..."})),ne&&(Ae==null?void 0:Ae.error)&&C(Ae.error,xe),ne&&wr&&!(Ae!=null&&Ae.loading)&&!(Ae!=null&&Ae.error)&&e.jsx(wr,{context:s,parent:n,link:ne,activeItemId:Ee,onOpenDetail:br,onBackToList:We})]})]})]})}const Qs={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:e.jsx(A.HiInformationCircle,{className:"h-5 w-5"})},success:{color:"#047857",background:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.24)",icon:e.jsx(A.HiCheckCircle,{className:"h-5 w-5"})},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)",icon:e.jsx(A.HiExclamationTriangle,{className:"h-5 w-5"})},danger:{color:"var(--danger)",background:"var(--danger-bg)",border:"color-mix(in srgb, var(--danger) 20%, var(--border))",icon:e.jsx(A.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:e.jsx(A.HiInformationCircle,{className:"h-5 w-5"})}};function Js({variant:r="info",title:t,children:a,icon:n,action:s,onDismiss:l,className:i=""}){const c=Qs[r];return e.jsxs("div",{role:r==="danger"||r==="warning"?"alert":"status",className:`flex items-start gap-3 rounded-lg border px-3 py-3 ${i}`,style:{background:c.background,borderColor:c.border},children:[e.jsx("div",{className:"mt-0.5 shrink-0",style:{color:c.color},children:n??c.icon}),e.jsxs("div",{className:"min-w-0 flex-1",children:[t&&e.jsx("div",{className:"text-sm font-semibold text-[var(--text-main)]",children:t}),a&&e.jsx("div",{className:"mt-0.5 text-sm leading-5 text-[var(--text-secondary)]",children:a}),s&&e.jsx("div",{className:"mt-3",children:s})]}),l&&e.jsx(Pe,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:e.jsx(A.HiXMark,{className:"h-4 w-4"})})]})}const In=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],Rs=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],el=["Do","Lu","Ma","Mi","Ju","Vi","Sá"],Da=6;function Ia(r,t,a){return`${r}-${String(t).padStart(2,"0")}-${String(a).padStart(2,"0")}`}function rl(){const r=new Date;return Ia(r.getFullYear(),r.getMonth()+1,r.getDate())}function Bn(r){const[t,a,n]=r.split("-").map(Number);return{year:t,month:a,day:n}}function tl(r){if(!r)return"Seleccionar fecha";const{year:t,month:a,day:n}=Bn(r);return!t||!a||!n?"Seleccionar fecha":`${String(n).padStart(2,"0")} ${In[a-1]} ${t}`}function al({value:r,onChange:t,minDate:a,displayMode:n="inline"}){const s=rl(),i=Bn(r||s),c=n==="popover",[d,f]=o.useState(!1),b=o.useRef(null),[p,m]=o.useState({horizontal:"left",vertical:"bottom"}),[w,k]=o.useState(i.year),[M,g]=o.useState(i.month),[C,O]=o.useState("days"),D=16,[z,E]=o.useState(0),S=w-7+z,U=Array.from({length:D},(Q,$)=>S+$);o.useEffect(()=>{if(!c||!d||!b.current)return;const Q=b.current.getBoundingClientRect(),$=8,R=280,oe=340,x=Q.left+R>window.innerWidth-$,y=Q.right-R>=$,V=Q.bottom+8+oe>window.innerHeight-$,q=Q.top-8-oe>=$;m({horizontal:x&&y?"right":"left",vertical:V&&q?"top":"bottom"})},[c,d]),o.useEffect(()=>{if(!c||!d)return;function Q(R){b.current&&(b.current.contains(R.target)||f(!1))}function $(R){R.key==="Escape"&&f(!1)}return document.addEventListener("mousedown",Q),document.addEventListener("keydown",$),()=>{document.removeEventListener("mousedown",Q),document.removeEventListener("keydown",$)}},[c,d]);function H(){M===1?(k(Q=>Q-1),g(12)):g(Q=>Q-1)}function W(){M===12?(k(Q=>Q+1),g(1)):g(Q=>Q+1)}const Y=new Date(w,M-1,1).getDay(),Z=new Date(w,M,0).getDate(),T=[...Array(Y).fill(null),...Array.from({length:Z},(Q,$)=>$+1)];for(;T.length<Da*7;)T.push(null);const J=T.slice(0,Da*7);function B(Q){const $=Ia(w,M,Q);a&&$<a||(t($),c&&f(!1))}const _={background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:4,borderRadius:6,display:"flex",alignItems:"center"},re=e.jsxs("div",{style:{background:"var(--bg-input)",border:"1px solid var(--border)",borderRadius:10,overflow:"hidden",userSelect:"none",width:280},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 12px",borderBottom:"1px solid var(--border)"},children:C==="days"?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:H,style:_,title:"Mes anterior",children:e.jsx(A.HiChevronLeft,{size:16})}),e.jsxs("button",{type:"button",onClick:()=>{O("years"),E(0)},style:{background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:4,fontSize:13,fontWeight:700,color:"var(--text-main)",borderRadius:6,padding:"2px 6px"},children:[In[M-1]," ",w,e.jsx(A.HiChevronDown,{size:13,style:{color:"var(--text-muted)"}})]}),e.jsx("button",{type:"button",onClick:W,style:_,title:"Mes siguiente",children:e.jsx(A.HiChevronRight,{size:16})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>E(Q=>Q-D),style:_,children:e.jsx(A.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:[U[0]," – ",U[U.length-1]]}),e.jsx("button",{type:"button",onClick:()=>E(Q=>Q+D),style:_,children:e.jsx(A.HiChevronRight,{size:16})})]})}),C==="years"&&e.jsxs("div",{style:{padding:"8px 10px 10px"},children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3,marginBottom:8},children:Rs.map((Q,$)=>{const R=$+1===M;return e.jsx("button",{type:"button",onClick:()=>g($+1),style:{border:"none",cursor:"pointer",borderRadius:6,fontSize:11,fontWeight:R?700:400,padding:"4px 0",background:R?"var(--primary)":"transparent",color:R?"var(--primary-fg, #ffffff)":"var(--text-secondary)"},children:Q},Q)})}),e.jsx("div",{style:{height:1,background:"var(--border)",marginBottom:8}}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:3},children:U.map(Q=>{const $=Q===w;return e.jsx("button",{type:"button",onClick:()=>{k(Q),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:Q===new Date().getFullYear()&&!$?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:Q},Q)})})]}),C==="days"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",padding:"6px 8px 0"},children:el.map(Q=>e.jsx("div",{style:{textAlign:"center",fontSize:10,fontWeight:700,color:"var(--text-muted)",padding:"2px 0",textTransform:"uppercase"},children:Q},Q))}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7,1fr)",gridTemplateRows:`repeat(${Da},1fr)`,padding:"4px 8px 10px",gap:2},children:J.map((Q,$)=>{if(Q===null)return e.jsx("div",{style:{aspectRatio:"1"}},$);const R=Ia(w,M,Q),oe=R===r,x=R===s,y=!!(a&&R<a);return e.jsx("button",{type:"button",onClick:()=>!y&&B(Q),style:{width:"100%",aspectRatio:"1",borderRadius:6,border:"none",cursor:y?"not-allowed":"pointer",fontSize:12,fontWeight:oe||x?700:400,background:oe?"var(--primary)":"transparent",color:oe?"var(--primary-fg, #ffffff)":y?"var(--text-muted)":"var(--text-main)",opacity:y?.4:1,outline:x&&!oe?"2px solid var(--primary)":"none",outlineOffset:"-2px"},children:Q},$)})})]})]});return c?e.jsxs("div",{ref:b,className:"relative w-full",children:[e.jsxs("button",{type:"button",onClick:()=>f(Q=>!Q),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(A.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),e.jsx("span",{className:"truncate",children:tl(r)})]}),e.jsx(A.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${d?"rotate-180":""}`})]}),d&&e.jsx("div",{className:"absolute z-50",style:{...p.horizontal==="left"?{left:0}:{right:0},...p.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:re})]}):re}const nl={sm:"h-4 w-4",md:"h-5 w-5"};function ol(r,t){if(typeof r=="function"){r(t);return}r&&(r.current=t)}const Ft=o.forwardRef(function({label:t,description:a,error:n,size:s="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:d,...f},b){const p=o.useRef(null);return o.useEffect(()=>{p.current&&(p.current.indeterminate=l)},[l]),e.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${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",{...f,ref:m=>{p.current=m,ol(b,m)},type:"checkbox",disabled:d,"aria-checked":l?"mixed":f["aria-checked"],"aria-invalid":!!n||f["aria-invalid"],className:`peer ${nl[s]} appearance-none rounded border border-[var(--border)] bg-[var(--bg-input)] transition-colors checked:border-[var(--primary)] checked:bg-[var(--primary)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/40 ${i}`}),e.jsx(A.HiCheck,{className:"pointer-events-none absolute left-1/2 top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 scale-75 text-[var(--primary-fg)] opacity-0 transition peer-checked:scale-100 peer-checked:opacity-100 peer-aria-checked:mixed:scale-100 peer-aria-checked:mixed:opacity-100"})]}),(t||a||n)&&e.jsxs("span",{className:"min-w-0",children:[t&&e.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:t}),a&&!n&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:a}),n&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--danger)]",children:n})]})]})});function On(r){const t=document.createElement("textarea");t.value=r,t.style.position="fixed",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}async function sl(r){var t;if((t=navigator.clipboard)!=null&&t.writeText){await navigator.clipboard.writeText(r);return}On(r)}function ll(r){return typeof r=="function"?r():r}function Ba({value:r,resetDelay:t=2e3,title:a,copiedTitle:n="Copiado",copiedLabel:s,icon:l=e.jsx(A.HiClipboardDocument,{size:14}),copiedIcon:i=e.jsx(A.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:d,onCopyError:f,className:b="",style:p,children:m,onClick:w,type:k="button",...M}){const[g,C]=o.useState(!1),O=o.useRef(null);o.useEffect(()=>()=>{O.current&&window.clearTimeout(O.current)},[]);function D(E){C(!0),d==null||d(E),O.current&&window.clearTimeout(O.current),O.current=window.setTimeout(()=>{C(!1),O.current=null},t)}async function z(E){var U;if(c&&E.stopPropagation(),w==null||w(E),E.defaultPrevented)return;const S=ll(r);if(S)try{await sl(S),D(S)}catch(H){try{On(S),D(S)}catch(W){f==null||f(W,S);return}(U=navigator.clipboard)!=null&&U.writeText||f==null||f(H,S)}}return e.jsxs("button",{...M,type:k,onClick:z,title:g?n:a,"aria-label":M["aria-label"]??(g?n:a),"data-copied":g?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${m?"min-w-7 px-2":"w-7"} ${b}`,style:{cursor:"pointer",background:g?"rgba(22,163,74,0.15)":"var(--bg-card)",border:g?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:g?"#16a34a":"var(--text-secondary)",boxShadow:g?"0 0 0 3px rgba(22,163,74,0.12)":"none",...p},children:[e.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:g?"scale(1.15)":"scale(1)"},children:g?i:l}),m&&e.jsx("span",{className:"text-xs font-semibold leading-none",children:g?s??m:m})]})}function il({code:r,children:t,title:a="Codigo",language:n,copyLabel:s="Copiar",copiedLabel:l="Copiado",className:i="",style:c,onCopied:d}){const f=(r??t??"").trim();return e.jsxs("div",{className:`overflow-hidden rounded-lg border ${i}`,style:{borderColor:"rgba(148, 163, 184, 0.22)",background:"#0f172a",color:"#e2e8f0",...c},children:[e.jsxs("div",{className:"flex min-h-9 items-center justify-between gap-3 border-b px-3 py-1.5",style:{borderColor:"rgba(148, 163, 184, 0.18)",background:"#111827",color:"#94a3b8"},children:[e.jsx("span",{className:"min-w-0 truncate text-[11px] font-black uppercase tracking-[0.08em]",children:a}),e.jsx(Ba,{value:f,title:"Copiar codigo",copiedTitle:"Codigo copiado",copiedLabel:l,onCopied: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:n?`language-${n}`:void 0,children:f})})]})}function Oa(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Ha(r){return r.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function cl(r,t){if(!t.trim())return!0;const a=Ha(t);return Ha(r.label).includes(a)||!!(r.sublabel&&Ha(r.sublabel).includes(a))}function Er({value:r,onChange:t,options:a,status:n="default",ariaLabel:s,triggerVariant:l="default",showSelectedSublabel:i=!0,placeholder:c="Seleccionar…",emptyLabel:d,disabled:f=!1,className:b="",style:p,dropdownMinWidth:m,height:w=40,padding:k="0 10px",searchable:M=!0,minOptionsForSearch:g=6}){const[C,O]=o.useState(!1),[D,z]=o.useState(""),[E,S]=o.useState(-1),[U,H]=o.useState(!1),[W,Y]=o.useState({}),Z=o.useRef(null),T=o.useRef(null),J=o.useRef(null),B=o.useRef(null),_=M&&a.length>=g,re=a.find(te=>te.value===r)??null,Q=l==="ghost",$=n==="error"?"var(--danger)":C?"var(--primary)":"var(--border)",R=_&&D.trim()?a.filter(te=>cl(te,D)):a,oe=o.useCallback(()=>{const te=Z.current;if(!te)return;const X=te.getBoundingClientRect(),h=_?272:212,L=window.innerHeight-X.bottom,j=L<h&&X.top>L;Y({position:"fixed",left:X.left,top:j?void 0:X.bottom+4,bottom:j?window.innerHeight-X.top+4:void 0,width:X.width,minWidth:Oa(m),zIndex:9999})},[m,_]);o.useEffect(()=>H(!0),[]),o.useEffect(()=>{if(!C)return;function te(X){var L,j;const h=X.target;!((L=Z.current)!=null&&L.contains(h))&&!((j=T.current)!=null&&j.contains(h))&&(O(!1),z(""))}return document.addEventListener("mousedown",te),()=>document.removeEventListener("mousedown",te)},[C]),o.useEffect(()=>{C&&(S(-1),oe(),_&&setTimeout(()=>{var te;return(te=J.current)==null?void 0:te.focus()},0))},[C,_,oe]),o.useEffect(()=>{if(C)return window.addEventListener("resize",oe),window.addEventListener("scroll",oe,!0),()=>{window.removeEventListener("resize",oe),window.removeEventListener("scroll",oe,!0)}},[C,oe]),o.useEffect(()=>{if(E<0||!B.current)return;const te=B.current.children[E];te==null||te.scrollIntoView({block:"nearest"})},[E]);const x=o.useCallback(te=>{t(te),O(!1),z("")},[t]),y=o.useRef(C);y.current=C;const V=o.useRef(R);V.current=R;const q=o.useRef(E);q.current=E;const ee=o.useRef(d);ee.current=d;const ce=o.useRef(x);ce.current=x,o.useEffect(()=>{function te(X){var ae,ne;const h=document.activeElement,L=((ae=Z.current)==null?void 0:ae.contains(h))??!1,j=((ne=T.current)==null?void 0:ne.contains(h))??!1;if(!(!L&&!j)){if(!y.current){(X.key==="Enter"||X.key===" "||X.key==="ArrowDown")&&(X.preventDefault(),O(!0));return}switch(X.key){case"ArrowDown":X.preventDefault(),S(he=>Math.min(he+1,V.current.length-1));break;case"ArrowUp":X.preventDefault(),S(he=>Math.max(he-1,ee.current?-1:0));break;case"Enter":{X.preventDefault();const he=q.current,Oe=V.current;he===-1&&ee.current?ce.current(""):Oe[he]&&!Oe[he].disabled&&ce.current(Oe[he].value);break}case"Escape":X.preventDefault(),X.stopPropagation(),O(!1),z("");break}}}return document.addEventListener("keydown",te),()=>document.removeEventListener("keydown",te)},[]);const ve=e.jsxs("div",{ref:T,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...W,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(A.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:J,value:D,onChange:te=>{z(te.target.value),S(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),D&&e.jsx("button",{type:"button",onMouseDown:te=>{te.preventDefault(),z("")},children:e.jsx(A.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),e.jsxs("ul",{ref:B,role:"listbox",className:"overflow-y-auto",style:{maxHeight:_?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[d&&e.jsx("li",{role:"option","aria-selected":r==="",onMouseDown:te=>{te.preventDefault(),x("")},onMouseEnter:()=>S(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:E===-1&&!D.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:d}),R.map((te,X)=>{const L=X===E,j=te.value===r;return e.jsxs("li",{role:"option","aria-selected":j,onMouseDown:ae=>{ae.preventDefault(),te.disabled||x(te.value)},onMouseEnter:()=>!te.disabled&&S(X),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:L?"var(--bg-hover)":j?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:te.disabled?"var(--text-muted)":"var(--text-main)",cursor:te.disabled?"not-allowed":"pointer",boxShadow:j?"inset 2px 0 0 var(--primary)":void 0},children:[te.color&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:te.color}}),e.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:te.label}),te.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:te.sublabel})]}),te.badge&&e.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:te.badge})]},te.value)}),R.length===0&&e.jsx("li",{className:"px-3 py-4 text-sm text-center",style:{color:"var(--text-muted)"},children:"Sin resultados"})]})]});return e.jsxs("div",{ref:Z,className:`relative ${b||"w-full"}`,style:p,children:[e.jsxs("button",{type:"button",disabled:f,onClick:()=>!f&&O(te=>!te),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:Oa(w),padding:Oa(k),background:Q?"transparent":"var(--bg-input)",color:re?"var(--text-main)":"var(--text-muted)",border:Q?"1px solid transparent":`1px solid ${$}`,opacity:f?.5:1,cursor:f?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":C,"aria-label":s,children:[(re==null?void 0:re.color)&&e.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:re.color}}),e.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:re?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"truncate",children:re.label}),i&&re.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:re.sublabel})]}):e.jsx("span",{className:"truncate",children:c})}),re&&d?e.jsx("span",{role:"button",tabIndex:-1,onMouseDown:te=>{te.preventDefault(),te.stopPropagation(),x("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(A.HiXMark,{className:"w-3 h-3"})}):e.jsx(A.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:C?"rotate(180deg)":"rotate(0deg)"}})]}),C&&U&&Je.createPortal(ve,document.body)]})}function zt(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function dl({value:r,onChange:t,placeholder:a="Buscar...",className:n="",height:s=40,padding:l="0 10px 0 30px",iconLeft:i=10}){return e.jsxs("div",{className:`relative ${n}`,children:[e.jsx(A.HiMagnifyingGlass,{className:"absolute top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[var(--text-muted)] pointer-events-none",style:{left:zt(i)}}),e.jsx("input",{type:"text",value:r,onChange:c=>t(c.target.value),placeholder:a,className:"w-full rounded-lg border border-[var(--border)] [background:var(--bg-card)] text-sm text-[var(--text-main)] placeholder:text-[var(--text-muted)] outline-none transition-[border-color,box-shadow] focus:border-primary focus:ring-2 focus:ring-primary/20",style:{height:zt(s),padding:zt(l)}})]})}function ul({value:r,onChange:t,options:a,placeholder:n,icon:s,className:l="",height:i=40,padding:c,iconLeft:d=10,searchable:f=!0}){const b=s?a.map((p,m)=>m===0&&!p.color?{...p,sublabel:p.sublabel??void 0}:p):a;return e.jsxs("div",{className:`relative ${l}`,children:[s&&e.jsx("span",{className:"pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--text-muted)]",style:{left:zt(d)},children:s}),e.jsx(Er,{value:r,onChange:t,options:b,placeholder:n,searchable:f,minOptionsForSearch:5,height:i,padding:c??(s?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const fl={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},_t=180,bl="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Pa({open:r,onClose:t,title:a,subtitle:n,leadingIcon:s,headerActions:l,footer:i,children:c,size:d="md",maxWidth:f,zIndex:b=1e3,closeOnBackdrop:p=!0,closeOnEscape:m=!0,showCloseButton:w=!0,placement:k="center",bodyClassName:M="px-6 py-5",panelClassName:g="",backdropClassName:C=bl,contentClassName:O="p-4",ariaLabel:D,frameless:z=!1,disabled:E=!1}){const[S,U]=o.useState(!1),[H,W]=o.useState(!1),Y=o.useRef(null);if(o.useEffect(()=>(r?(Y.current&&clearTimeout(Y.current),U(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>W(!0)))):(W(!1),Y.current=setTimeout(()=>U(!1),_t+40)),()=>{Y.current&&clearTimeout(Y.current)}),[r]),o.useEffect(()=>{if(r)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[r]),o.useEffect(()=>{if(!r||!m)return;const re=Q=>{Q.key==="Escape"&&t()};return window.addEventListener("keydown",re),()=>window.removeEventListener("keydown",re)},[m,t,r]),!S)return null;const Z=a||n||s||l||w,T=f??fl[d],J=k==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",B=k==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",_=H?"translateY(0) scale(1)":k==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return Je.createPortal(e.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":D??a,className:`fixed inset-0 flex ${J} ${O}`,style:{zIndex:b},children:[e.jsx("div",{className:`absolute inset-0 ${C}`,onClick:p?t:void 0,style:{opacity:H?1:0,transition:`opacity ${_t}ms ease`}}),e.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${z?"shadow-none":"shadow-2xl"} ${B} ${g}`,style:{maxWidth:T,background:z?"transparent":"var(--bg-card)",border:z?"none":"1px solid var(--border)",opacity:H?1:0,transform:_,transition:`opacity ${_t}ms ease, transform ${_t}ms ease`},onClick:re=>re.stopPropagation(),children:[E&&e.jsx("div",{className:"absolute inset-0 z-[1002] cursor-not-allowed rounded-2xl",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 60%, transparent)",backdropFilter:"blur(2px)"}}),Z&&e.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between gap-3 px-6 py-4",style:{borderBottom:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[s&&e.jsx("div",{className:"flex-shrink-0",children:s}),(a||n)&&e.jsxs("div",{className:"min-w-0",children:[a&&e.jsx("h2",{className:"truncate text-base font-semibold",style:{color:"var(--text-main)"},children:a}),n&&e.jsx("p",{className:"truncate text-xs",style:{color:"var(--text-muted)"},children:n})]})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[l,w&&e.jsx(Pe,{variant:"icon",onClick:t,title:"Cerrar",children:e.jsx(A.HiXMark,{className:"h-5 w-5"})})]})]}),e.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${M}`,children:c}),i&&e.jsx("div",{className:"flex flex-shrink-0 justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:i})]})]}),document.body)}const pl={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 ml({open:r,title:t,description:a,confirmLabel:n="Confirmar",cancelLabel:s="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:d}){const f=pl[l];return e.jsx(Pa,{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(Pe,{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(A.HiXMark,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex gap-3 pr-8",children:[e.jsx("div",{className:"mt-0.5 flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl",style:{background:f.iconBg},children:e.jsx(A.HiExclamationTriangle,{className:"h-5 w-5",style:{color:f.iconColor}})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-base font-semibold leading-snug",style:{color:"var(--text-main)"},children:t}),a?e.jsx("div",{className:"mt-1.5 text-sm leading-relaxed",style:{color:"var(--text-muted)"},children:a}):null]})]}),e.jsxs("div",{className:"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e.jsx(Pe,{variant:"secondary",onClick:d,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:s}),e.jsx(Pe,{variant:"danger",onClick:c,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:f.btnBg,color:f.btnColor,borderColor:"transparent"},children:n})]})]})})}function hl(r){return r?typeof r=="function"?r():r:""}function gl(r){return/^https?:\/\//i.test(r)}function Hn(r,t){try{return new URL(r,t).toString()}catch{return r}}function vl(r,t,a,n=!1){const s=typeof r=="function"?r():r,l=t?t(s):s;if(!l||gl(l))return l;const i=hl(a);return i?Hn(l,i):n&&typeof window<"u"?Hn(l,window.location.origin):l}function xl({url:r,resolveUrl:t,baseUrl:a,useWindowOriginForRelative:n=!1,title:s="Copiar link",copiedTitle:l="Link copiado",icon:i=e.jsx(A.HiLink,{className:"h-3.5 w-3.5"}),...c}){return e.jsx(Ba,{...c,value:()=>vl(r,t,a,n),title:s,copiedTitle:l,icon:i})}const jt=[25,50,100,200,500];let Re={dataTable:{pageSizeOptions:[...jt]}};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 Fa(){const r=Re.dataTable.preferencesEndpoint,t=yl();return r&&r.trim().length>0?r.trim().replace(/\/+$/,""):t}function wl(r){if(!Array.isArray(r))return[...jt];const t=Array.from(new Set(r.map(a=>typeof a=="number"?Math.floor(a):Number.NaN).filter(a=>Number.isFinite(a)&&a>0)));return t.length>0?t:[...jt]}function Pn(r){if(typeof r!="string")return;const t=r.trim();if(t)return t.replace(/\/+$/,"")}function Nl(r){if(!r||typeof r!="object"||!r.dataTable)return;const t=Pn(r.dataTable.preferencesEndpoint);Re={...Re,dataTable:{...Re.dataTable,pageSizeOptions:wl(r.dataTable.pageSizeOptions),preferencesEndpoint:t??Re.dataTable.preferencesEndpoint}}}function kl(){return{dataTable:{pageSizeOptions:[...Re.dataTable.pageSizeOptions]}}}function ft(){return[...Re.dataTable.pageSizeOptions]}function Sl(){Re={dataTable:{pageSizeOptions:[...jt]}}}function Cl(r){Re={...Re,dataTable:{...Re.dataTable,preferencesEndpoint:Pn(r)}}}const Wt=[{value:"equals",label:"Igual a",valueMode:"single"},{value:"notEquals",label:"No es igual a",valueMode:"single"},{value:"greaterThan",label:"Mayor que",valueMode:"single"},{value:"greaterThanOrEqual",label:"Mayor o igual que",valueMode:"single"},{value:"lessThan",label:"Menor que",valueMode:"single"},{value:"lessThanOrEqual",label:"Menor o igual que",valueMode:"single"},{value:"between",label:"Entre",valueMode:"between"},{value:"top10",label:"10 superiores",valueMode:"none"},{value:"bottom10",label:"10 inferiores",valueMode:"none"},{value:"aboveAverage",label:"Sobre promedio",valueMode:"none"},{value:"belowAverage",label:"Bajo promedio",valueMode:"none"}],El=Wt.map(r=>({value:r.value,label:r.label})),Ml=12,Tl={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},Fn={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},Ll="bonsaif-ui:datatable:",$l="[&_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",Al=[],Dl=52;function gr(r){if(!r)return 150;const t=parseInt(r,10);return isNaN(t)||t<=0?150:t}function zn(r){return!!(r&&(Array.isArray(r.columnOrder)&&r.columnOrder.length>0||r.columnWidths&&Object.keys(r.columnWidths).length>0||Array.isArray(r.hiddenColumnKeys)&&r.hiddenColumnKeys.length>0||r.filters&&Object.keys(r.filters).length>0||r.conditionFilters&&Object.keys(r.conditionFilters).length>0||r.sort||typeof r.bql=="string"||Array.isArray(r.bqlHistory)&&r.bqlHistory.length>0||typeof r.pageSize=="number"))}function _n(r){return`${Ll}${r}`}function qt(r){try{const t=window.localStorage.getItem(_n(r));if(!t)return null;const a=JSON.parse(t);return a&&typeof a=="object"?a:null}catch{return null}}function Il(r,t){try{window.localStorage.setItem(_n(r),JSON.stringify(t))}catch{}}function Bl(r,t){if(r===!0)return{...Fn};if(r===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(t&&r==null)return{...Fn};const a={...Tl,...r??{}};return t&&(typeof r!="object"||r.pagination!==!1)&&(a.pagination=!0),a}function jn(...r){return r.reduce((t,a)=>({...t,...a??{}}),{})}function za(r,t,a){return typeof r!="number"||r<=0?a:gt(t).includes(r)?r:a}function bt(r){if(!r||typeof r!="object")return!1;const t=r;return typeof t.key=="string"&&(t.dir==="asc"||t.dir==="desc")}function pt(r,t){if(!r||typeof r!="object"||Array.isArray(r))return{};const a=Object.entries(r).flatMap(([n,s])=>{if(!t.has(n)||!Array.isArray(s))return[];const l=s.filter(i=>typeof i=="string");return l.length>0?[[n,l]]:[]});return Object.fromEntries(a)}function mt(r,t){if(!r||typeof r!="object"||Array.isArray(r))return{};const a=new Set(Wt.map(s=>s.value)),n=Object.entries(r).flatMap(([s,l])=>{if(!t.has(s)||!l||typeof l!="object")return[];const i=l;return!i.operator||!a.has(i.operator)?[]:[[s,{operator:i.operator,value:typeof i.value=="string"?i.value:"",valueTo:typeof i.valueTo=="string"?i.valueTo:""}]]});return Object.fromEntries(n)}function er(r,t){if(Mr(r))return Dl;const a=r.minWidth??80,n=r.maxWidth??1/0;return Math.min(n,Math.max(a,t))}function Ol(r){const t=window.getComputedStyle(r);return parseFloat(t.paddingLeft)+parseFloat(t.paddingRight)}function Mr(r){return r.key==="actions"||r.key==="acciones"?!0:typeof r.header=="string"&&r.header.trim().toLowerCase()==="acciones"}function Hl(r,t){if(t<=7)return Array.from({length:t},(n,s)=>s+1);const a=[1];r>3&&a.push("...");for(let n=Math.max(2,r-1);n<=Math.min(t-1,r+1);n++)a.push(n);return r<t-2&&a.push("..."),a.push(t),a}function vr(r,t){var i;const a=new Set(t.filter(c=>c.hideable!==!1).map(c=>c.key)),n=Array.from(new Set(r??[])).filter(c=>a.has(c));if(t.filter(c=>!n.includes(c.key)).length>0)return n;const l=(i=t.find(c=>c.hideable!==!1))==null?void 0:i.key;return l?n.filter(c=>c!==l):[]}function Pl(r){return r==null||r===""?"(Vacio)":r instanceof Date?r.toLocaleDateString():String(r)}function Wr(r){return r==null||typeof r=="boolean"?"":typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(Wr).join(" ").trim():o.isValidElement(r)?Wr(r.props.children):""}function Ut(r,t){const a=r.filterValue?r.filterValue(t):r.sortKey?t[r.sortKey]:r.cell(t);return typeof a=="string"||typeof a=="number"||typeof a=="boolean"||a===null||a===void 0||a instanceof Date?Pl(a):Wr(a).trim()}function ht(r){const t=r.replace(/,/g,"").trim();if(!t)return null;const a=Number(t);return Number.isFinite(a)?a:null}function qr(r,t){const a=ht(r),n=ht(t);return a!==null&&n!==null?a-n:r.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function gt(r){const t=Array.from(new Set(r.map(a=>Math.floor(a)).filter(a=>Number.isFinite(a)&&a>0)));return t.length>0?t:ft()}function Fl(r,t,a){var i,c;const n=((i=t.value)==null?void 0:i.trim())??"",s=((c=t.valueTo)==null?void 0:c.trim())??"",l=Wt.find(d=>d.value===t.operator);if((l==null?void 0:l.valueMode)==="single"&&!n||(l==null?void 0:l.valueMode)==="between"&&(!n||!s))return!0;switch(t.operator){case"equals":return r.toLowerCase()===n.toLowerCase();case"notEquals":return r.toLowerCase()!==n.toLowerCase();case"greaterThan":return qr(r,n)>0;case"greaterThanOrEqual":return qr(r,n)>=0;case"lessThan":return qr(r,n)<0;case"lessThanOrEqual":return qr(r,n)<=0;case"between":return qr(r,n)>=0&&qr(r,s)<=0;case"top10":case"bottom10":{const f=a.map(p=>({value:p,number:ht(p)})).filter(p=>p.number!==null).sort((p,m)=>p.number-m.number).map(p=>p.value);return(t.operator==="top10"?f.slice(-10):f.slice(0,10)).includes(r)}case"aboveAverage":case"belowAverage":{const d=a.map(ht).filter(p=>p!==null);if(d.length===0)return!1;const f=d.reduce((p,m)=>p+m,0)/d.length,b=ht(r);return b===null?!1:t.operator==="aboveAverage"?b>f:b<f}default:return!0}}function Wn({children:r,className:t="",style:a}){return e.jsx(jr,{onlyWhenOverflow:!0,className:t,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",...a},children:r})}function qn({columns:r,data:t,getRowId:a,loading:n=!1,skeletonRows:s=8,emptyIcon:l,emptyText:i="Sin resultados",initialEmptyDelay:c=450,onRowClick:d,renderExpandedRow:f,getRowCanExpand:b,expandedRowIds:p,defaultExpandedRowIds:m=[],onExpandedRowIdsChange:w,expandOnRowClick:k=!1,selected:M,onToggleOne:g,onToggleAll:C,highlightSelected:O=!0,rowClassName:D,getRowCategory:z,stickyHeader:E=!0,pageSize:S=25,pageSizeOptions:U,pageSizeSelectWidth:H=62,pageSizeSelectHeight:W=30,pageSizeSelectPadding:Y="0 7px",totalRows:Z,page:T,onPageChange:J,onPageSizeChange:B,storageKey:_,stickyFirstColumn:re=!1,bottomOffset:Q=0,compact:$=!0,restrictHeight:R=!0,maxHeight:oe,minTableWidth:x,enableColumnVisibility:y=!0,enableColumnFilters:V=!0,hiddenColumnKeys:q,defaultHiddenColumnKeys:ee=Al,onHiddenColumnKeysChange:ce,columnVisibilityLabel:ve="Columnas",enableBql:te=!1,bqlValue:X,defaultBqlValue:h="",onBqlChange:L,bqlDescription:j="Filtra registros con Bonsaif Query Language",bqlPlaceholder:ae=`status = activo
2
+ rol IN (admin, employee)`,bqlQuickFilters:ne=[],bqlExamples:he=[],bqlSuggestions:Oe=[],bqlActiveFilters:Ge,bqlError:xe,onQueryChange:Ee,persistState:Ae,onPreferencesReady:wr,enableExport:br=!1,exportFilename:We="datos"}){var Ds;const se=Bl(Ae,_),Ze=Object.values(se).some(Boolean),lr=r.map(u=>u.key).join(","),de=ee.join(","),I=o.useRef(r),G=o.useRef(ee);I.current=r,G.current=ee;const[le,ue]=o.useState(!_||!Ze),Le=o.useRef(null),ke=o.useRef(!_),Ie=o.useRef(!1),Me=o.useRef(wr);Me.current=wr;const Ue=o.useRef(!_||!Ze?_??"__none__":null),Be=q!==void 0,[la,Ke]=o.useState(()=>vr(ee,r)),ze=vr(Be?q:la,r),[Xe,$r]=o.useState(!1),[ir,Ad]=o.useState("filter"),[Et,ia]=o.useState(null),[es,rs]=o.useState(""),[Qe,Zr]=o.useState({}),[cr,Mt]=o.useState({}),on=p!==void 0,[ts,Dd]=o.useState(m),Ar=X!==void 0,[Id,Tt]=o.useState(h),pr=Ar?X:Id,[Lt,ca]=o.useState(pr),[mr,Dr]=o.useState(!1),[as,Qr]=o.useState(!1),[ns,Jr]=o.useState(!1),[$t,Rr]=o.useState([]),et=o.useRef(null),Ir=o.useRef(null),dr=o.useRef(L);dr.current=L;const da=o.useRef(S);da.current=S;const ua=o.useRef(U);ua.current=U;const Bd=Array.isArray(U)?U.join(","):"",sn=o.useRef(null),os=o.useRef(null),ln=o.useRef(null),ss=o.useRef(0),[Od,Hd]=o.useState({}),[Pd,Fd]=o.useState({}),[At,fa]=o.useState(!1),cn=o.useRef(null),ba=o.useRef(null),[zd,_d]=o.useState({}),ls=o.useRef(null),pa=o.useRef(null),[dn,is]=o.useState(t.length>0||n||c===!1),cs=(u,v)=>50+(u*17+v*13+7)%40,Nr=o.useRef(null),[jd,Wd]=o.useState(void 0),[ds,qd]=o.useState(0),[un,Ud]=o.useState(!1);o.useEffect(()=>{function u(){Ud(window.innerWidth<640)}if(!R||oe!==void 0)return u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u);const F=S!==!1?48:0,N=12;function K(){if(u(),!Nr.current)return;const ie=Nr.current.getBoundingClientRect().top;Wd(Math.max(120,window.innerHeight-ie-F-N-Q))}return K(),window.addEventListener("resize",K),()=>window.removeEventListener("resize",K)},[n,S,Q,R,oe]);const us=R?oe??jd:void 0;o.useEffect(()=>{const u=Nr.current;if(!u)return;const v=()=>qd(u.clientWidth);if(v(),typeof ResizeObserver>"u")return window.addEventListener("resize",v),()=>window.removeEventListener("resize",v);const F=new ResizeObserver(v);return F.observe(u),()=>F.disconnect()},[n,le,t.length]),o.useEffect(()=>{if(c===!1||n||t.length>0){is(!0);return}if(dn)return;const u=window.setTimeout(()=>{is(!0)},c);return()=>window.clearTimeout(u)},[t.length,c,dn,n]);const[rt,tt]=o.useState(()=>r.map(u=>u.key)),[at,nt]=o.useState(()=>Object.fromEntries(r.map(u=>[u.key,er(u,gr(u.width))]))),[De,Br]=o.useState(null),[Vd,ma]=o.useState(1),[ha,ga]=o.useState(S===!1?0:S);o.useEffect(()=>{var qe;const u=I.current,v=G.current,F=u.map(be=>be.key),N=new Set(F),K=()=>{var be;Ie.current||(Ie.current=!0,(be=Me.current)==null||be.call(Me))};if(!_||!Ze){se.layout&&tt(F),Be||Ke(vr(v,u)),ke.current=!1,ue(!0),K();return}let ie=!1;const fe=Ue.current===_;fe||(ke.current=!1,ue(!1),Ie.current=!1);const ye=qt(_);if(zn(ye)&&!fe){const be=ye,pe=gt(ua.current??ft()),me=da.current,zr=me===!1?0:me,kr=se.layout?be==null?void 0:be.columnOrder:void 0,Sr=Array.isArray(kr)?kr.filter(Te=>F.includes(Te)):[],Cr=F.filter(Te=>!Sr.includes(Te)),_r=Sr.length>0?[...Sr,...Cr]:F,it=Object.fromEntries(u.map(Te=>[Te.key,er(Te,gr(Te.width))])),ct=se.layout?(be==null?void 0:be.columnWidths)??{}:{},Bt=Object.fromEntries(u.map(Te=>[Te.key,er(Te,ct[Te.key]??it[Te.key])])),dt=vr(se.layout?(be==null?void 0:be.hiddenColumnKeys)??v:v,u);if(se.layout&&(tt(_r),nt(Bt)),Be||Ke(dt),se.filters&&(Zr(pt(be==null?void 0:be.filters,N)),Mt(mt(be==null?void 0:be.conditionFilters,N))),se.sort){const Te=bt(be==null?void 0:be.sort)?be.sort:null;Br(Te&&N.has(Te.key)?Te:null)}if(se.bql){if(et.current!==_){et.current=_;const Te=typeof(be==null?void 0:be.bql)=="string"?be.bql:h;Ar?(qe=dr.current)==null||qe.call(dr,Te):Tt(Te)}Rr(Array.isArray(be==null?void 0:be.bqlHistory)?be.bqlHistory.filter(Te=>typeof Te=="string"):[])}se.pagination&&Ir.current!==_&&(Ir.current=_,ga(za(be==null?void 0:be.pageSize,pe,zr))),Ue.current=_,ue(!0),K()}const we=`${Fa()??"/api/user/preferences/datatables"}?key=${encodeURIComponent(_)}`,Se=new AbortController,Ne=window.setTimeout(()=>Se.abort(),2500);return fetch(we,{cache:"no-store",signal:Se.signal}).then(be=>be.ok?be.json():null).then(be=>{var Is;if(ie)return;const pe=qt(_),me=jn(zn(be==null?void 0:be.settings)?be==null?void 0:be.settings:null,pe),zr=gt(ua.current??ft()),kr=da.current,Sr=kr===!1?0:kr,Cr=se.layout?me==null?void 0:me.columnOrder:void 0,_r=Array.isArray(Cr)?Cr.filter(He=>F.includes(He)):[],it=F.filter(He=>!_r.includes(He)),ct=_r.length>0?[..._r,...it]:F,Bt=Object.fromEntries(u.map(He=>[He.key,er(He,gr(He.width))])),dt=se.layout?(me==null?void 0:me.columnWidths)??{}:{},Te=Object.fromEntries(u.map(He=>[He.key,er(He,dt[He.key]??Bt[He.key])])),ut=vr(se.layout?(me==null?void 0:me.hiddenColumnKeys)??v:v,u);if(se.layout&&(tt(ct),nt(Te)),Be||Ke(ut),se.filters&&(Zr(pt(me==null?void 0:me.filters,N)),Mt(mt(me==null?void 0:me.conditionFilters,N))),se.sort){const He=bt(me==null?void 0:me.sort)?me.sort:null;Br(He&&N.has(He.key)?He:null)}if(se.bql){if(et.current!==_){et.current=_;const He=typeof(me==null?void 0:me.bql)=="string"?me.bql:h;Ar?(Is=dr.current)==null||Is.call(dr,He):Tt(He)}Rr(Array.isArray(me==null?void 0:me.bqlHistory)?me.bqlHistory.filter(He=>typeof He=="string"):[])}let $e;se.pagination&&($e=za(me==null?void 0:me.pageSize,zr,Sr),Ir.current!==_&&(Ir.current=_,ga($e))),Le.current=JSON.stringify({columnOrder:ct,columnWidths:Te,hiddenColumnKeys:ut,filters:pt(me==null?void 0:me.filters,N),conditionFilters:mt(me==null?void 0:me.conditionFilters,N),sort:bt(me==null?void 0:me.sort)?me.sort:null,bql:typeof(me==null?void 0:me.bql)=="string"?me.bql:"",bqlHistory:Array.isArray(me==null?void 0:me.bqlHistory)?me.bqlHistory:[],pageSize:se.pagination&&kr!==!1?$e:void 0}),ke.current=!0}).catch(()=>{var be;if(!ie){const pe=qt(_),me=gt(ua.current??ft()),zr=da.current,kr=zr===!1?0:zr,Sr=se.layout?pe==null?void 0:pe.columnOrder:void 0,Cr=Array.isArray(Sr)?Sr.filter($e=>F.includes($e)):[],_r=F.filter($e=>!Cr.includes($e)),it=Cr.length>0?[...Cr,..._r]:F,ct=Object.fromEntries(u.map($e=>[$e.key,er($e,gr($e.width))])),Bt=se.layout?(pe==null?void 0:pe.columnWidths)??{}:{},dt=Object.fromEntries(u.map($e=>[$e.key,er($e,Bt[$e.key]??ct[$e.key])]));se.layout&&(tt(it),nt(dt));const Te=vr(se.layout?(pe==null?void 0:pe.hiddenColumnKeys)??v:v,u);if(Be||Ke(Te),se.filters&&(Zr(pt(pe==null?void 0:pe.filters,N)),Mt(mt(pe==null?void 0:pe.conditionFilters,N))),se.sort){const $e=bt(pe==null?void 0:pe.sort)?pe.sort:null;Br($e&&N.has($e.key)?$e:null)}if(se.bql){if(et.current!==_){et.current=_;const $e=typeof(pe==null?void 0:pe.bql)=="string"?pe.bql:h;Ar?(be=dr.current)==null||be.call(dr,$e):Tt($e)}Rr(Array.isArray(pe==null?void 0:pe.bqlHistory)?pe.bqlHistory.filter($e=>typeof $e=="string"):[])}let ut;se.pagination&&(ut=za(pe==null?void 0:pe.pageSize,me,kr),Ir.current!==_&&(Ir.current=_,ga(ut))),Le.current=JSON.stringify({columnOrder:it,columnWidths:dt,hiddenColumnKeys:Te,filters:pt(pe==null?void 0:pe.filters,N),conditionFilters:mt(pe==null?void 0:pe.conditionFilters,N),sort:bt(pe==null?void 0:pe.sort)?pe.sort:null,bql:typeof(pe==null?void 0:pe.bql)=="string"?pe.bql:"",bqlHistory:Array.isArray(pe==null?void 0:pe.bqlHistory)?pe.bqlHistory:[],pageSize:se.pagination&&zr!==!1?ut:void 0}),ke.current=!0}}).finally(()=>{window.clearTimeout(Ne),ie||(Ue.current=_,ue(!0),K())}),()=>{ie=!0,Se.abort(),window.clearTimeout(Ne)}},[_,Ze,lr,de,Be,se.layout,se.filters,se.sort,se.bql,se.pagination,Ar,h,Bd]),o.useEffect(()=>{if(!_||!le||!Ze||!ke.current)return;const u={};se.layout&&(u.columnOrder=rt,u.columnWidths=at,u.hiddenColumnKeys=ze),se.filters&&(u.filters=Qe,u.conditionFilters=cr),se.sort&&(u.sort=De),se.bql&&(u.bql=pr,u.bqlHistory=$t),se.pagination&&S!==!1&&(u.pageSize=ha);const v=qt(_),F=jn(v,u),N=JSON.stringify(F);if(N===Le.current)return;Il(_,F),Le.current=N;const K=window.setTimeout(()=>{const ie=Fa()??"/api/user/preferences/datatables";fetch(ie,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:_,settings:F})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(K)},[rt,at,ze,Qe,cr,De,pr,$t,ha,S,_,le,Ze,se.layout,se.filters,se.sort,se.bql,se.pagination]),o.useEffect(()=>{tt(u=>{const v=r.map(K=>K.key),F=u.filter(K=>v.includes(K)),N=v.filter(K=>!F.includes(K));return[...F,...N]})},[lr,r]);const fs=rt.map(u=>r.find(v=>v.key===u)).filter(u=>!!u),nr=fs.filter(u=>!ze.includes(u.key)),Gd=Object.keys(Qe).length,Kd=Object.keys(cr).length,fn=Gd+Kd;function bs(u){const v=new Set;return t.reduce((F,N)=>{const K=Ut(u,N);return!K||v.has(K)||(v.add(K),F.push({value:K,label:K})),F},[])}function Xd(){const u=r.find(v=>v.key===Et);return u?bs(u):[]}function Yd(u){return!!(V&&!Mr(u)&&(u.filterValue||u.sortKey||bs(u).length>0))}function ps(u,v){Zr(F=>{const N={...F};return N[u]=v,N})}function Zd(u,v,F,N){const K=Qe[u]??[],ie=N?K:F.filter(ye=>ye!==v),fe=N?K.includes(v)?K.filter(ye=>ye!==v):[...K,v]:ie;fe.length===F.length?bn(u):ps(u,fe)}function bn(u){Zr(v=>{const F={...v};return delete F[u],F})}function va(u,v){Mt(F=>{const N={...F};return v?N[u]=v:delete N[u],N})}function ms(u){va(u,null)}function Qd(){Zr({}),Mt({})}function Jd(u){Ar||Tt(u),L==null||L(u)}function hs(u){const v=u.trim();ca(v),(L==null?void 0:L(v))!==!1&&(Ar||Tt(v),Dr(!1),Qr(!1),Jr(!1),v&&Rr(N=>[v,...N.filter(K=>K!==v)].slice(0,Ml)))}function gs(){ca(""),Jd(""),Dr(!1),Qr(!1),Jr(!1)}function pn(u,v){ca(u),v&&(v.style.height="auto",v.style.height=`${Math.min(v.scrollHeight,180)}px`)}function xa(u){const v=u.trim();if(!v)return;ss.current=Date.now()+500;const F=Lt.replace(/\s+$/u,""),N=F.length===0?v:F.split(`
3
+ `).map(K=>K.trim()).includes(v)?F:`${F}
4
+ ${v}`;pn(N,ln.current??void 0),requestAnimationFrame(()=>{const K=ln.current;if(!K)return;K.focus();const ie=K.value.length;K.setSelectionRange(ie,ie),pn(K.value,K)})}o.useEffect(()=>{ca(pr)},[pr]);const ya=o.useCallback(()=>{const u=sn.current;if(!u)return;const v=u.getBoundingClientRect(),F=12,N=8,K=Math.min(780,Math.max(320,window.innerWidth-32)),ie=Math.max(F,window.innerWidth-K-F),fe=Math.min(Math.max(F,v.left),ie),ye=v.bottom+N,_e=window.innerHeight-v.top+N,Fe=window.innerHeight-ye-F,we=v.top-F-N,Se=Fe<280&&we>Fe,Ne=Math.max(240,Se?we:Fe);Hd({position:"fixed",zIndex:1e4,left:fe,top:Se?void 0:ye,bottom:Se?_e:void 0,width:K,maxWidth:"calc(100vw - 24px)",maxHeight:Ne,overflowY:"auto"})},[]);o.useEffect(()=>{if(!mr)return;function u(N){var ie,fe;if(Date.now()<ss.current)return;const K=N.target;(ie=sn.current)!=null&&ie.contains(K)||(fe=os.current)!=null&&fe.contains(K)||(Dr(!1),Qr(!1),Jr(!1))}function v(N){N.key==="Escape"&&(Dr(!1),Qr(!1),Jr(!1))}function F(){ya()}return ya(),document.addEventListener("mousedown",u),window.addEventListener("keydown",v),window.addEventListener("resize",F),window.addEventListener("scroll",F,!0),()=>{document.removeEventListener("mousedown",u),window.removeEventListener("keydown",v),window.removeEventListener("resize",F),window.removeEventListener("scroll",F,!0)}},[mr,ya]);function vs(u){const v=vr(u,r);Be||Ke(v),ce==null||ce(v)}function Rd(u){vs(ze.includes(u)?ze.filter(v=>v!==u):[...ze,u])}function eu(){vs([])}const mn=o.useCallback((u=pa.current)=>{if(!u)return;const v=u.getBoundingClientRect(),F=Math.min(292,Math.max(240,window.innerWidth-16)),N=Math.max(8,window.innerWidth-F-8),K=Math.min(Math.max(8,v.right-F),N),ie=window.innerHeight-v.bottom,fe=v.bottom+6,ye=window.innerHeight-v.top+6,Fe=ie<360&&v.top>ie?void 0:fe,we=Fe===void 0?ye:void 0,Se=Math.max(220,Fe===void 0?v.top-16:window.innerHeight-fe-8),Ne={position:"fixed",zIndex:9999,left:K,top:Fe,bottom:we,width:F,maxWidth:"calc(100vw - 16px)",maxHeight:Se,"--dt-column-menu-max-height":`${Se}px`};Fd(Ne)},[]);function xs(u,v,F=null){u.preventDefault(),u.stopPropagation();const N=pa.current===u.currentTarget&&ir===v&&Et===F;if(Xe&&N){$r(!1),ia(null);return}pa.current=u.currentTarget,Ad(v),ia(F),rs(""),mn(u.currentTarget),$r(!0)}function ru(u){if(Mr(u))return;const v=Nr.current;if(!v)return;const N=Array.from(v.querySelectorAll("[data-dt-column-key]")).filter(K=>K.dataset.dtColumnKey===u.key).reduce((K,ie)=>{const fe=ie.querySelector("[data-dt-autofit-content]"),ye=fe?fe.scrollWidth:Math.max(ie.scrollWidth,ie.offsetWidth);return Math.max(K,Math.ceil(ye+Ol(ie)))},0);N<=0||nt(K=>({...K,[u.key]:er(u,N+12)}))}o.useEffect(()=>{nt(u=>{const v=Object.fromEntries(r.map(F=>[F.key,er(F,gr(F.width))]));return Object.fromEntries(r.map(F=>[F.key,er(F,u[F.key]??v[F.key])]))})},[lr,r]),o.useEffect(()=>{Be||Ke(u=>vr(u,r))},[lr,r,Be]),o.useEffect(()=>{function u(N){var fe,ye;const K=N.target,ie=N.target;ie!=null&&ie.closest("[data-bonsaif-select-dropdown='true']")||!((fe=ls.current)!=null&&fe.contains(K))&&!((ye=pa.current)!=null&&ye.contains(K))&&($r(!1),ia(null))}function v(N){N.key==="Escape"&&($r(!1),ia(null))}function F(){mn()}return Xe&&(document.addEventListener("mousedown",u),window.addEventListener("keydown",v),window.addEventListener("resize",F),window.addEventListener("scroll",F,!0)),()=>{document.removeEventListener("mousedown",u),window.removeEventListener("keydown",v),window.removeEventListener("resize",F),window.removeEventListener("scroll",F,!0)}},[Xe,mn]);const Dt=o.useRef(null);o.useEffect(()=>{function u(F){const N=Dt.current;if(!N)return;const K=F.clientX-N.startX,ie=r.find(fe=>fe.key===N.colKey);ie&&nt(fe=>({...fe,[N.colKey]:er(ie,N.startWidth+K)}))}function v(){Dt.current&&(Dt.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",u),document.addEventListener("pointerup",v),()=>{document.removeEventListener("pointermove",u),document.removeEventListener("pointerup",v)}},[r]);const wa=o.useRef(null),[ys,hn]=o.useState(null);function tu(u,v){wa.current=rt.indexOf(u),v.dataTransfer.effectAllowed="move"}function au(u,v){v.preventDefault(),v.dataTransfer.dropEffect="move";const F=rt.indexOf(u);ys!==F&&hn(F)}function nu(u,v){v.preventDefault();const F=wa.current,N=rt.indexOf(u);F!==null&&F!==N&&tt(K=>{const ie=[...K],[fe]=ie.splice(F,1);return ie.splice(N,0,fe),ie}),wa.current=null,hn(null)}function ou(){wa.current=null,hn(null)}function su(u){u.sortKey&&Br(v=>(v==null?void 0:v.key)===u.key?{key:u.key,dir:v.dir==="asc"?"desc":"asc"}:{key:u.key,dir:"asc"})}o.useEffect(()=>{ma(1)},[t]),o.useEffect(()=>{ma(1)},[cr,Qe]);const Or=!!(J&&B),Hr=S!==!1,ws=o.useMemo(()=>gt(U??ft()),[U]),je=Or?T??1:Vd,ur=Or||Hr?ha:t.length,fr=!!M&&!!g&&!!C,ot=!!f,Ns=o.useMemo(()=>new Set(on?Array.from(p??[]):ts),[on,p,ts]),gn=(ot?40:0)+(fr?40:0),lu=fr&&t.length>0&&M.size===t.length,iu=fr&&M.size>0&&M.size<t.length,Na=o.useMemo(()=>{const u=Object.entries(Qe),v=Object.entries(cr);return u.length===0&&v.length===0?t:t.filter(F=>u.every(([N,K])=>{const ie=r.find(fe=>fe.key===N);return ie?K.includes(Ut(ie,F)):!0})&&v.every(([N,K])=>{const ie=r.find(ye=>ye.key===N);if(!ie)return!0;const fe=t.map(ye=>Ut(ie,ye));return Fl(Ut(ie,F),K,fe)}))},[cr,Qe,r,t]),Pr=o.useMemo(()=>{if(!De)return Na;const u=r.find(v=>v.key===De.key&&v.sortKey);return u!=null&&u.sortKey?[...Na].sort((v,F)=>{const N=v[u.sortKey],K=F[u.sortKey],ie=N===K?0:N==null?1:K==null||N<K?-1:1;return De.dir==="asc"?ie:-ie}):Na},[Na,De,r]),ks=o.useMemo(()=>{if(Or||!Hr)return Pr;const u=(je-1)*ur;return Pr.slice(u,u+ur)},[Pr,Or,Hr,je,ur]),Fr=Or?Z??t.length:Pr.length,vn=Hr?Math.max(1,Math.ceil(Fr/ur)):1,cu=Math.min(...ws),du=Hr&&(Fr>ur||Fr>cu),uu=Hr?(je-1)*ur+1:1,fu=Hr?Math.min(je*ur,Fr):Fr;function xn(u){if(n)return;const v=Math.max(1,Math.min(u,vn));Or?J(v):ma(v)}function bu(u){n||(_&&(Ir.current=_),ga(u),Or?(B(u),J(1)):(ma(1),B==null||B(u)))}function Ss(u){const v=new Set(Ns);v.has(u)?v.delete(u):v.add(u);const F=Array.from(v);on||Dd(F),w==null||w(F)}o.useEffect(()=>{Ee==null||Ee({bql:pr,filters:Qe,conditionFilters:cr,sort:De,page:je,pageSize:ur,hiddenColumnKeys:ze})},[pr,Qe,cr,De,je,ur,ze,Ee]);const Cs=u=>u==="center"?"text-center":u==="right"?"text-right":"text-left",pu="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",yn="linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 90%, var(--bg-card)) 0%, color-mix(in srgb, var(--bg-input) 70%, var(--bg-card)) 100%)",Ce="color-mix(in srgb, var(--border) 62%, var(--bg-card))",st="color-mix(in srgb, var(--primary) 24%, var(--border))",ka=`inset 0 0 0 1px ${Ce}`,Es=nr.reduce((u,v)=>u+(at[v.key]??gr(v.width)),(ot?40:0)+(fr?40:0)),Ms=typeof x=="number"?x:typeof x=="string"?Number(((Ds=x.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:Ds[1])??NaN):NaN,It=Number.isFinite(Ms)?Math.max(Es,Ms,ds):Math.max(Es,ds),Sa=x??It,lt=`${ot?"40px ":""}${fr?"40px ":""}${nr.map(u=>`${at[u.key]??gr(u.width)}px`).join(" ")}`;o.useEffect(()=>{De&&ze.includes(De.key)&&Br(null)},[ze,De]);function Ts(u){return u?typeof u=="string"?{key:u,label:u}:u:null}const Ca=()=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:lt,background:yn,borderBottom:`1px solid ${st}`},children:[ot&&e.jsx("div",{role:"columnheader",className:`${$?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${st}`,borderRight:`1px solid ${Ce}`}}),fr&&e.jsx("div",{role:"columnheader",className:`${$?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:re?{position:"sticky",left:0,zIndex:12,background:yn,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${st}`,borderRight:`1px solid ${Ce}`}:{borderBottom:`1px solid ${st}`,borderRight:`1px solid ${Ce}`},children:e.jsx(Ft,{size:"sm",checked:lu,indeterminate:iu,onChange:C,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),nr.map((u,v)=>{const F=(De==null?void 0:De.key)===u.key,N=!!u.sortKey,K=Mr(u),ie=re&&!un&&v===0,fe=ys===v,_e=(at[u.key]??gr(u.width))<120,Fe=Object.prototype.hasOwnProperty.call(Qe,u.key)||Object.prototype.hasOwnProperty.call(cr,u.key);return e.jsxs("div",{role:"columnheader","data-dt-column-key":u.key,className:`group select-none ${_e?"text-left":Cs(u.align)}`,style:{...ie?{position:"sticky",left:gn,zIndex:12,background:yn,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${st}`,borderRight:`1px solid ${Ce}`}:{position:"relative",borderBottom:`1px solid ${st}`,borderRight:`1px solid ${Ce}`},color:F?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:fe?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:K?$?"7px 6px":"9px 8px":$?"8px 6px 10px":"10px 8px 12px"},onDragOver:we=>au(u.key,we),onDrop:we=>nu(u.key,we),children:[e.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${K?"justify-center":_e?"justify-start":u.align==="center"?"justify-center":u.align==="right"?"justify-end":"justify-start"}`,children:[e.jsx("span",{draggable:!0,onDragStart:we=>{we.stopPropagation(),tu(u.key,we)},onDragEnd:we=>{we.stopPropagation(),ou()},onClick:we=>we.stopPropagation(),title:"Arrastrar para mover columna","aria-label":"Arrastrar para mover columna",className:`absolute left-0 top-0 z-10 inline-flex h-full w-3 shrink-0 rounded-sm transition-colors duration-150 hover:bg-[var(--primary)]/15 ${fe?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}),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(A.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):e.jsx(Wn,{className:"min-w-0 flex-1",children:e.jsx("span",{"data-dt-autofit-content":!0,className:`inline-flex max-w-full items-center font-semibold uppercase tracking-wider ${$?"text-[11px]":"text-xs"}`,children:e.jsx("span",{className:"min-w-0 truncate",children:u.header})})}),N&&e.jsx("button",{type:"button","aria-label":`Ordenar por ${String(u.header)}`,title:"Ordenar",onClick:we=>{we.stopPropagation(),su(u)},"data-dt-sort-button":!0,className:`absolute -bottom-2 left-1/2 z-20 inline-flex h-4 w-4 -translate-x-1/2 items-center justify-center rounded-full bg-[var(--primary)] text-[var(--primary-fg)] shadow-[0_1px_3px_rgba(15,23,42,0.22)] transition-[opacity,transform] duration-150 hover:scale-105 focus:scale-105 focus:opacity-100 focus:outline-none ${F?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:F?De.dir==="asc"?e.jsx(A.HiChevronUp,{className:"h-3 w-3"}):e.jsx(A.HiChevronDown,{className:"h-3 w-3"}):e.jsx(A.HiChevronUpDown,{className:"h-3 w-3"})}),V&&!K&&Yd(u)&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Xe&&Et===u.key,"aria-label":`Filtrar ${String(u.header)}`,title:"Filtrar",onClick:we=>xs(we,"filter",u.key),className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-sm bg-transparent text-[var(--text-muted)] opacity-0 transition-[opacity,color,background-color] duration-150 hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] focus:opacity-100 group-hover:opacity-100 ${Xe&&ir==="filter"&&Et===u.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":Fe?"text-[var(--primary)] opacity-100":""}`,children:Fe?e.jsx(A.HiFunnel,{className:"h-3.5 w-3.5"}):e.jsx(A.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!K&&e.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:we=>{we.preventDefault(),we.stopPropagation(),Dt.current={colKey:u.key,startX:we.clientX,startWidth:at[u.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:we=>{we.preventDefault(),we.stopPropagation(),Dt.current=null,document.body.style.cursor="",document.body.style.userSelect="",ru(u)},onClick:we=>we.stopPropagation(),className:"absolute top-0 flex h-full items-center justify-center opacity-0 transition-opacity duration-200 hover:opacity-100",style:{right:0,width:12,cursor:"col-resize",zIndex:6,transform:"translateX(50%)"},children:e.jsxs("span",{style:{display:"flex",gap:4,alignItems:"center",height:"calc(100% - 8px)"},children:[e.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}}),e.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}})]})})]},u.key)})]}),Ea=()=>{if(!Xe||typeof document>"u"||ir==="visibility"&&!y||ir==="filter"&&!V)return null;const u=r.find(Ne=>Ne.key===Et),v=Xd(),F=u?Object.prototype.hasOwnProperty.call(Qe,u.key):!1,N=u?cr[u.key]:void 0,K=Wt.find(Ne=>Ne.value===(N==null?void 0:N.operator)),ie=u?Qe[u.key]??[]:[],fe=es.trim().toLowerCase(),ye=fe?v.filter(Ne=>Ne.label.toLowerCase().includes(fe)):v,_e=u&&v.length>0&&(!F||ie.length===v.length),Fe=u&&F&&ie.length>0&&ie.length<v.length,we=ze.length,Se=()=>{u&&(bn(u.key),ms(u.key))};return Je.createPortal(e.jsx("div",{ref:ls,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Pd,borderColor:"var(--border)",background:"var(--bg-card)"},children:ir==="visibility"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[e.jsx("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:we>0?`${nr.length} de ${r.length} visibles`:`${r.length} visibles`}),e.jsx("button",{type:"button",onClick:eu,disabled:we===0,className:"rounded px-1.5 py-0.5 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-input)] disabled:opacity-40",children:"Mostrar todas"})]}),e.jsx("div",{className:"max-h-72 overflow-auto py-1",children:fs.map(Ne=>{const qe=!ze.includes(Ne.key),pe=!(Ne.hideable!==!1)||qe&&nr.length<=1;return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":qe,disabled:pe,onClick:()=>Rd(Ne.key),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:qe?"var(--primary)":"var(--border)",background:qe?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:qe&&e.jsx(A.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:Ne.header})]},Ne.key)})})]}):u?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 ",u.header]}),e.jsx("button",{type:"button",onClick:Se,disabled:!F&&!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"})]}),u.sortKey&&e.jsxs("div",{className:"grid grid-cols-2 gap-1 border-b border-[var(--border)] p-1",children:[e.jsxs("button",{type:"button",onClick:()=>Br({key:u.key,dir:"asc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[e.jsx(A.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate",children:"Ascendente"})]}),(De==null?void 0:De.key)===u.key&&De.dir==="asc"&&e.jsx(A.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),e.jsxs("button",{type:"button",onClick:()=>Br({key:u.key,dir:"desc"}),className:"flex min-w-0 items-center justify-between rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[e.jsx(A.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate",children:"Descendente"})]}),(De==null?void 0:De.key)===u.key&&De.dir==="desc"&&e.jsx(A.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]})]}),e.jsxs("div",{className:"border-b border-[var(--border)] p-2",children:[e.jsxs("div",{className:"grid grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)] gap-2",children:[e.jsx(Er,{value:(N==null?void 0:N.operator)??"",onChange:Ne=>{if(!Ne){ms(u.key);return}va(u.key,{operator:Ne,value:(N==null?void 0:N.value)??"",valueTo:(N==null?void 0:N.valueTo)??""})},options:El,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:(N==null?void 0:N.value)??"",onChange:Ne=>{N&&va(u.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"})]}),(K==null?void 0:K.valueMode)==="between"&&e.jsx("input",{value:(N==null?void 0:N.valueTo)??"",onChange:Ne=>{N&&va(u.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(A.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),e.jsx("input",{value:es,onChange:Ne=>rs(Ne.target.value),placeholder:"Buscar",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-[var(--text-muted)]",style:{color:"var(--text-main)"}})]})}),e.jsxs("div",{className:"overflow-auto py-1",style:{maxHeight:"max(96px, calc(var(--dt-column-menu-max-height, 520px) - 236px))"},children:[e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Fe?"mixed":!!_e,onClick:()=>{u&&(_e&&!F?ps(u.key,[]):bn(u.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:_e||Fe?"var(--primary)":"var(--border)",background:_e||Fe?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[Fe&&e.jsx(A.HiMinus,{className:"h-3 w-3"}),_e&&!Fe&&e.jsx(A.HiCheck,{className:"h-3 w-3"})]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),ye.map(Ne=>{const qe=!F||ie.includes(Ne.value);return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":qe,onClick:()=>Zd(u.key,Ne.value,v.map(be=>be.value),F),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:qe?"var(--primary)":"var(--border)",background:qe?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:qe&&e.jsx(A.HiCheck,{className:"h-3 w-3"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:Ne.label})]},Ne.value)}),ye.length===0&&e.jsx("div",{className:"px-3 py-3 text-sm text-[var(--text-muted)]",children:"Sin valores"})]})]}):null}),document.body)};o.useEffect(()=>{if(!At)return;function u(v){cn.current&&!cn.current.contains(v.target)&&ba.current&&!ba.current.contains(v.target)&&fa(!1)}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[At]);function Ls(u,v){if(u.filterValue){const F=u.filterValue(v);return F==null||F===""?"":String(F)}return Wr(u.cell(v))}function $s(u){return`"${u.replace(/"/g,'""')}"`}function Ma(u){return u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function mu(){const u=nr.filter(ye=>!Mr(ye)),v=u.map(ye=>$s(Wr(ye.header))).join(","),F=Pr.map(ye=>u.map(_e=>$s(Ls(_e,ye))).join(",")).join(`
5
+ `),N=`${v}
6
+ ${F}`,K=new Blob(["\uFEFF"+N],{type:"text/csv;charset=utf-8;"}),ie=URL.createObjectURL(K),fe=document.createElement("a");fe.href=ie,fe.download=`${We}.csv`,document.body.appendChild(fe),fe.click(),document.body.removeChild(fe),URL.revokeObjectURL(ie)}function hu(){const u=nr.filter(fe=>!Mr(fe)),v=u.map(fe=>Ma(Wr(fe.header))),N=Pr.map(fe=>u.map(ye=>Ma(Ls(ye,fe)))).map(fe=>`<tr>${fe.map(ye=>`<td>${ye}</td>`).join("")}</tr>`).join(""),K=`<!DOCTYPE html>
7
+ <html lang="es"><head><meta charset="utf-8"><title>${Ma(We)}</title>
8
8
  <style>
9
9
  body{font-family:system-ui,sans-serif;font-size:11px;margin:20px;color:#111}
10
10
  h3{margin:0 0 4px;font-size:14px}
@@ -15,19 +15,18 @@ ${P}`,G=new Blob(["\uFEFF"+y],{type:"text/csv;charset=utf-8;"}),ie=URL.createObj
15
15
  tr:nth-child(even) td{background:#f9f9f9}
16
16
  @media print{body{margin:0}@page{margin:1cm}}
17
17
  </style></head><body>
18
- <h3>${Ea(We)}</h3>
18
+ <h3>${Ma(We)}</h3>
19
19
  <p>${Pr.length} registros · ${new Date().toLocaleDateString("es")}</p>
20
20
  <table><thead><tr>${v.map(fe=>`<th>${fe}</th>`).join("")}</tr></thead>
21
- <tbody>${y}</tbody></table>
21
+ <tbody>${N}</tbody></table>
22
22
  <script>window.onload=()=>{window.print()}<\/script>
23
- </body></html>`,ie=window.open("","_blank");ie&&(ie.document.write(G),ie.document.close())}const Ma=()=>!br||!$t?null:Je.createPortal(e.jsxs("div",{ref:ln,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Id,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:()=>{cu(),ua(!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:()=>{du(),ua(!1)},children:[e.jsx(T.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),La=()=>{const d=re&&pr.trim().length>0,v=Ge!=null&&Ge.length?Ge:d?[{key:"bql",label:"BQL",value:pr}]:[],P=_e.filter(y=>{const G=y.trim();return G?!new Set(Mt.split(`
24
- `).map(fe=>fe.trim()).filter(Boolean)).has(G):!1}).slice(0,8);return!S&&un===0&&!re&&!br?null:e.jsxs("div",{className:"relative flex min-h-9 flex-wrap items-center justify-between gap-2 border-b rounded-t-lg px-2 py-1",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[un>0&&e.jsxs("button",{type:"button",onClick:Vd,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"}),un," filtros"]}),re&&e.jsxs("div",{ref:on,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>{if(mr){Dr(!1);return}xa(),Dr(!0)},className:"inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border px-2 text-xs font-bold transition-colors",style:{background:mr?"var(--primary)":d?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:mr||d?"var(--primary)":"var(--border)",color:mr?"var(--primary-fg)":"var(--primary)"},"aria-expanded":mr,title:"Abrir filtros BQL",children:[e.jsx(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"}),mr?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:q}),v.length>0&&e.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[v.slice(0,3).map(y=>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:[y.label,":"]}),e.jsx("span",{className:"truncate",children:y.value})]},y.key)),v.length>3&&e.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",v.length-3]})]}),d&&e.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick: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(T.HiXMark,{className:"h-4 w-4"})}),mr&&Je.createPortal(e.jsxs("div",{ref:Ro,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...$d,background:"var(--bg-card)",border:"1px solid color-mix(in srgb, var(--primary) 35%, var(--border))"},children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[oe.map(y=>e.jsxs("button",{type:"button",onMouseDown:G=>{G.preventDefault(),G.stopPropagation()},onClick:G=>{G.preventDefault(),G.stopPropagation(),va(y.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:[y.icon,y.label]},y.label)),he.length>0&&e.jsxs("button",{type:"button",onClick:()=>Zr(y=>!y),className:"inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]","aria-expanded":Qo,children:[e.jsx(T.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),Lt.length>0&&e.jsxs("button",{type:"button",onClick:()=>Qr(y=>!y),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":Jo,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:sn,value:Mt,rows:3,onChange:y=>bn(y.target.value,y.target),onKeyDown:y=>{y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),ds(Mt)),y.key==="Escape"&&Dr(!1)},placeholder:ne,autoComplete:"off",spellCheck:!1,className:"block w-full px-4 py-3 text-sm outline-none",style:{background:"var(--bg-input)",color:"var(--text-main)",border:"none",fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace",lineHeight:1.6,maxHeight:180,minHeight:88,overflowY:"auto",resize:"vertical"}}),P.length>0&&e.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:P.map(y=>e.jsx("button",{type:"button",onMouseDown:G=>{G.preventDefault(),G.stopPropagation()},onClick:G=>{G.preventDefault(),G.stopPropagation(),va(y)},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:y},y))})]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 text-xs",style:{color:xe?"var(--danger)":"var(--text-muted)"},children:xe??(d?`${v.length||1} filtro${(v.length||1)===1?"":"s"} activo${(v.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),v.map(y=>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:[y.label,":"]}),e.jsx("span",{className:"truncate",children:y.value})]},y.key))]}),Jo&&Lt.length>0&&e.jsxs("div",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-input)]",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-3 py-2",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-semibold text-[var(--text-secondary)]",children:[e.jsx(T.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),e.jsxs("button",{type:"button",onClick:()=>{Jr([]),Qr(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[e.jsx(T.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),Lt.map(y=>e.jsxs("div",{className:"group flex items-center gap-2 border-b border-[var(--border)] px-3 py-2 last:border-b-0",children:[e.jsx("button",{type:"button",onMouseDown:G=>{G.preventDefault(),G.stopPropagation()},onClick:G=>{G.preventDefault(),G.stopPropagation(),va(y)},className:"min-w-0 flex-1 text-left",children:e.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:y})}),e.jsx("button",{type:"button",onClick:()=>Jr(G=>G.filter(ie=>ie!==y)),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"})})]},y))]}),Qo&&he.length>0&&e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:he.map(y=>e.jsxs("button",{type:"button",onMouseDown:G=>{G.preventDefault(),G.stopPropagation()},onClick:G=>{G.preventDefault(),G.stopPropagation(),va(y.bql),Zr(!1)},className:"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-2 text-left transition-colors hover:border-[var(--primary)]",children:[e.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:y.bql}),y.description&&e.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:y.description})]},y.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: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(T.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),e.jsxs("button",{type:"button",onClick:()=>ds(Mt),className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-[var(--primary)] px-4 text-xs font-semibold text-[var(--primary-fg)] transition-opacity hover:opacity-90",children:[e.jsx(T.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),br&&e.jsx("button",{ref:fa,type:"button","aria-haspopup":"menu","aria-expanded":$t,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var G;const y=(G=fa.current)==null?void 0:G.getBoundingClientRect();y&&Bd({top:y.bottom+4,right:window.innerWidth-y.right}),ua(ie=>!ie)},className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] ${$t?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:e.jsx(T.HiArrowDownTray,{className:"h-4 w-4"})}),S&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Xe&&ir==="visibility","aria-label":ve,title:ve,onClick:y=>bs(y,"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"})})]})},Cs=()=>{if(!nu)return null;const d=Tl(je,gn);return e.jsxs("div",{"aria-busy":n,className:`grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 rounded-b-xl border-t text-xs select-none ${I?"px-2 py-0.5":"px-3 py-1"}`,style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:Fr===0?"0 filas":`${ou}–${su} de ${Fr}`}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),e.jsx(Er,{value:String(ur),onChange:v=>lu(Number(v)),options:ms.map(v=>({value:String(v),label:String(v)})),placeholder:"Filas",searchable:!1,disabled:n,height:j,padding:Y,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:H}})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[e.jsx("button",{disabled:n||je<=1,onClick:()=>vn(je-1),onMouseEnter:v=>{v.currentTarget.disabled||(v.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",v.currentTarget.style.color="var(--primary)")},onMouseLeave:v=>{v.currentTarget.style.background="transparent",v.currentTarget.style.color="var(--text-muted)"},className:"cursor-pointer rounded p-0.5 transition-colors disabled:cursor-not-allowed disabled:opacity-30",style:{background:"transparent",color:"var(--text-muted)"},children:e.jsx(T.HiChevronLeft,{className:"h-3.5 w-3.5"})}),d.map((v,P)=>v==="..."?e.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${P}`):e.jsx("button",{disabled:n,onClick:()=>vn(v),onMouseEnter:y=>{y.currentTarget.disabled||v===je||(y.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",y.currentTarget.style.color="var(--primary)")},onMouseLeave:y=>{y.currentTarget.style.background=v===je?"var(--primary)":"transparent",y.currentTarget.style.color=v===je?"var(--primary-fg)":"var(--text-muted)"},className:"h-5 w-5 cursor-pointer rounded text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-60",style:{background:v===je?"var(--primary)":"transparent",color:v===je?"var(--primary-fg)":"var(--text-muted)"},children:v},v)),e.jsx("button",{disabled:n||je>=gn,onClick:()=>vn(je+1),onMouseEnter:v=>{v.currentTarget.disabled||(v.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",v.currentTarget.style.color="var(--primary)")},onMouseLeave:v=>{v.currentTarget.style.background="transparent",v.currentTarget.style.color="var(--text-muted)"},className:"cursor-pointer rounded p-0.5 transition-colors disabled:cursor-not-allowed disabled:opacity-30",style:{background:"transparent",color:"var(--text-muted)"},children:e.jsx(T.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{"aria-hidden":"true"})]})},uu=()=>e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Na},children:[Ca(),Ma(),La(),e.jsx("div",{ref:Nr,className:"min-w-0 max-w-full overflow-hidden",children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:At,minWidth:ka},children:[e.jsx("div",{role:"rowgroup",style:E?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Sa()}),e.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,s)}).map((d,v)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:st,borderBottom:`1px solid ${Ce}`},children:[fr&&e.jsx("div",{role:"cell",className:`${I?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Ce}`,borderRight:`1px solid ${Ce}`}},"select-cell"),nr.map((P,y)=>e.jsx("div",{role:"cell",className:I?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${Ce}`,borderRight:`1px solid ${Ce}`},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${as(v,y)}%`,minWidth:32}})},P.key))]},v))})]})})]}),yn="min-w-0 max-w-full overflow-hidden";return z&&Ze&&!le?e.jsx(Ot,{rows:s,columns:Math.max(4,nr.length||7)}):!n&&t.length===0&&!cn?uu():n&&t.length===0?e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Na},children:[Ca(),Ma(),La(),e.jsx("div",{ref:Nr,className:yn,children:e.jsx(Nn.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:os,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:At,minWidth:ka},children:[e.jsx("div",{role:"rowgroup",style:E?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Sa()}),e.jsx("div",{role:"rowgroup",children:Array.from({length:s}).map((d,v)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:st,borderBottom:`1px solid ${Ce}`},children:[fr&&e.jsx("div",{role:"cell",className:`${I?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Ce}`,borderRight:`1px solid ${Ce}`}},"select-cell"),nr.map((P,y)=>{const G=ee&&!dn&&y===0;return e.jsx("div",{role:"cell","data-dt-column-key":P.key,className:I?"px-2 py-1.5":"px-3 py-2",style:G?{position:"sticky",left:hn,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Ce}`,borderRight:`1px solid ${Ce}`}:{borderBottom:`1px solid ${Ce}`,borderRight:`1px solid ${Ce}`},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${as(v,y)}%`,minWidth:32}})},P.key)})]},v))})]})})}),Cs()]}):!n&&t.length===0?e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Na},children:[Ca(),Ma(),La(),e.jsx("div",{ref:Nr,className:yn,children:e.jsx("div",{role:"table",className:"text-sm",style:{width:At,minWidth:ka},children:e.jsx("div",{role:"rowgroup",style:E?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Sa()})})}),e.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-3 border-t px-6 py-12 text-center",style:{borderColor:Ce,background:"linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 58%, transparent), var(--bg-card))"},children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full border",style:{borderColor:"color-mix(in srgb, var(--primary) 24%, var(--border))",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-card))",color:"var(--primary)"},children:l??e.jsx(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:Na},children:[Ca(),Ma(),La(),e.jsx("div",{ref:Nr,className:yn,children:e.jsx(Nn.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:os,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:At,minWidth:ka},children:[e.jsx("div",{role:"rowgroup",style:E?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Sa()}),e.jsx("div",{role:"rowgroup",children:gs.map((d,v)=>{const P=a(d),y=Ns(F==null?void 0:F(d)),G=v>0?Ns(F==null?void 0:F(gs[v-1])):null,ie=y&&y.key!==(G==null?void 0:G.key),fe=fr&&M.has(P),ye=nt?(m==null?void 0:m(d))??!0:!1,ze=ye&&hs.has(P),Pe=!!u||N&&ye,we=fe&&B?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":v%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return e.jsxs(o.Fragment,{children:[ie&&e.jsx("div",{role:"row",className:`grid ${y.className??""}`,style:{gridTemplateColumns:st},children:e.jsx("div",{role:"cell",className:I?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-input))",borderBottom:`1px solid ${Ce}`,borderRight:`1px solid ${Ce}`},children:e.jsx("div",{className:"flex min-w-0 items-center justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-xs font-semibold uppercase tracking-wider text-[var(--text-main)]",children:y.label}),y.description&&e.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:y.description})]})})})}),e.jsxs("div",{role:"row",onClick:Pe?Se=>{const Ne=Se.target;if(!(Ne!=null&&Ne.closest('[data-dt-disable-row-click="true"]'))){if(N&&ye){vs(P);return}u==null||u(d)}}:void 0,className:`grid transition-colors ${Pe?"cursor-pointer":""} ${A?A(d):""}`,style:{gridTemplateColumns:st,"--dt-row-bg":we,"--dt-sticky-bg":we,background:"var(--dt-row-bg)",borderBottom:`1px solid ${Ce}`},onMouseEnter:Se=>{fe||(Se.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),Se.currentTarget.style.setProperty("--dt-sticky-bg",iu))},onMouseLeave:Se=>{Se.currentTarget.style.setProperty("--dt-row-bg",we),Se.currentTarget.style.setProperty("--dt-sticky-bg",we)},children:[nt&&e.jsx("div",{role:"cell",className:`${I?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${Ce}`,borderRight:`1px solid ${Ce}`},"data-dt-disable-row-click":"true",children:ye&&e.jsx("button",{type:"button","aria-label":ze?"Contraer fila":"Desplegar fila","aria-expanded":ze,onClick:Se=>{Se.stopPropagation(),vs(P)},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]",children:ze?e.jsx(T.HiChevronDown,{className:"h-4 w-4"}):e.jsx(T.HiChevronRight,{className:"h-4 w-4"})})}),fr&&e.jsx("div",{role:"cell",className:`${I?"px-2 py-1.5":"px-3 py-2"} w-10`,style:ee?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${Ce}`}:{borderBottom:`1px solid ${Ce}`,borderRight:`1px solid ${Ce}`},onClick:Se=>{Se.stopPropagation(),g(P)},children:e.jsx(Ht,{size:"sm",checked:fe,"aria-label":"Seleccionar fila",containerClassName:"items-center",className:"cursor-pointer",onClick:Se=>Se.stopPropagation(),onChange:()=>g(P)})}),nr.map((Se,Ne)=>{const qe=ee&&!dn&&Ne===0,be=Mr(Se);return e.jsx("div",{role:"cell","data-dt-column-key":Se.key,"data-dt-disable-row-click":Se.disableRowClick||be?"true":void 0,className:`${be?"px-2 py-1.5 text-center":`${I?"px-2 py-1.5":"px-3 py-2"} ${xs(Se.align)}`} ${Sl} ${Se.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...qe?{position:"sticky",left:hn,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Ce}`,borderRight:`1px solid ${Ce}`}:{borderBottom:`1px solid ${Ce}`,borderRight:`1px solid ${Ce}`}},children:e.jsx(jn,{children:e.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:Se.cell(d)})})},Se.key)})]}),ze&&f&&e.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:st},children:e.jsx("div",{role:"cell",className:I?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--bg-input) 60%, var(--bg-card))",borderBottom:`1px solid ${Ce}`},children:f(d)})})]},P)})})]})})}),Cs()]})}const Il={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 Bl(r,t){if(t.minLength!==void 0&&r.length<t.minLength)return t.message??`Mínimo ${t.minLength} caracteres`;if(t.maxLength!==void 0&&r.length>t.maxLength)return t.message??`Máximo ${t.maxLength} caracteres`;if(!r)return null;if(t.preset){const a=Il[t.preset];if(!a.pattern.test(r))return t.message??a.message}return t.pattern&&!t.pattern.test(r)?t.message??"Formato inválido":null}const Ol=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function Hl({initialValue:r,type:t,mask:a,onCommit:n,onCancel:s}){const[l,i]=o.useState(r),c=o.useRef(null),u=(a==null?void 0:a.preset)==="date",f=u?"date":t==="number"?"number":"text";return o.useEffect(()=>{var m,b;(m=c.current)==null||m.focus(),u||(b=c.current)==null||b.select()},[u]),e.jsx("input",{ref:c,type:f,value:l,maxLength:a==null?void 0:a.maxLength,onChange:m=>i(m.target.value),onBlur:()=>s(),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),n(l)),m.key==="Escape"&&(m.preventDefault(),s()),(a==null?void 0:a.preset)==="integer"&&!m.ctrlKey&&!m.metaKey&&!Ol.has(m.key)&&!/^[\d-]$/.test(m.key)&&m.preventDefault()},onClick:m=>m.stopPropagation(),className:"w-full min-w-0 border-0 bg-transparent p-0 text-sm text-[var(--text-main)] outline-none"})}function Pl({initialValue:r,options:t,loading:a,onCommit:n,onCancel:s}){const l=o.useRef(null);return o.useEffect(()=>{if(a)return;const i=setTimeout(()=>{var c,u;(u=(c=l.current)==null?void 0:c.querySelector("button"))==null||u.click()},0);return()=>clearTimeout(i)},[a]),e.jsx("div",{ref:l,className:"w-full",tabIndex:-1,onKeyDown:i=>{i.key==="Escape"&&(i.stopPropagation(),s())},children:e.jsx(Er,{value:r,onChange:i=>{n(i)},options:t,disabled:a,placeholder:a?"Cargando…":"Seleccionar…",triggerVariant:"ghost",height:30,padding:"0 6px",minOptionsForSearch:1,className:"w-full"})})}const Fl={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},za={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function zl({columns:r,data:t,getRowId:a,onCellUpdate:n,readOnly:s=!1,...l}){const[i,c]=o.useState(t),u=o.useRef(null);o.useEffect(()=>{u.current||c(t)},[t]);const[f,m]=o.useState(null);u.current=f;const[b,p]=o.useState(null),x=o.useRef(null);x.current=b;const[N,M]=o.useState({}),[g,C]=o.useState(null),B=o.useRef(null);B.current=g;const[A,F]=o.useState({}),[E,k]=o.useState({}),U=o.useRef(new Set),H=o.useRef(null);o.useEffect(()=>{var S;const w=document.activeElement;(!w||w===document.body)&&((S=H.current)==null||S.focus({preventScroll:!0}))},[]);const j=r.map(w=>{var S,R,te;return`${w.key}:${((te=(R=(S=w.editable)==null?void 0:S.select)==null?void 0:R.options)==null?void 0:te.length)??-1}`}).join("|");o.useEffect(()=>{r.forEach(w=>{var te,ae;const S=(ae=(te=w.editable)==null?void 0:te.select)==null?void 0:ae.options;if(!S)return;const R=A[w.key];(!U.current.has(w.key)||(R==null?void 0:R.length)===0&&S.length>0)&&(U.current.add(w.key),F(ce=>({...ce,[w.key]:S})))})},[j]);const Y=o.useCallback(async(w,S)=>{if(U.current.has(w))return;U.current.add(w);const{url:R,fetchOptions:te}=S.select??{};if(!(!R&&!te)){k(ae=>({...ae,[w]:!0}));try{let ae=[];if(te)ae=await te();else if(R){const ce=await fetch(R);if(!ce.ok)throw new Error("fetch failed");ae=await ce.json()}F(ce=>({...ce,[w]:ae}))}catch{F(ae=>({...ae,[w]:[]}))}finally{k(ae=>({...ae,[w]:!1}))}}},[]),Q=o.useRef(i);Q.current=i;const L=o.useRef(n);L.current=n;const Z=o.useRef(a);Z.current=a;const W=o.useRef(r);W.current=r;const z=o.useRef(s);z.current=s,o.useEffect(()=>{if(r.length>0&&t.length>0){const w=r.find(S=>S.selectable!==!1);w&&p({rowId:a(t[0]),colKey:w.key})}},[]),o.useEffect(()=>{if(!b)return;const w=H.current;if(!w)return;const S=w.querySelector(`[data-cell-id="${b.rowId}:${b.colKey}"]`);if(!S)return;const R=w.querySelector('[role="rowgroup"]');S.style.scrollMarginTop=`${(R==null?void 0:R.offsetHeight)??0}px`;const te=w.querySelector('[role="row"]');let ae=0;te&&te.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(ce=>{ce.style.position==="sticky"&&ce.style.left!==""&&(ae=Math.max(ae,parseFloat(ce.style.left)+ce.offsetWidth))}),S.style.scrollMarginLeft=`${ae}px`,S.scrollIntoView({block:"nearest",inline:"nearest"})},[b]);const ee=o.useCallback(w=>{var ae;const S=W.current,R=new Set,te=[];(ae=H.current)==null||ae.querySelectorAll("[data-cell-id]").forEach(ce=>{const ve=ce.dataset.cellId.split(":")[0];R.has(ve)||(R.add(ve),te.push(ve))}),p(ce=>{if(!ce)return ce;const ve=S.findIndex($=>$.key===ce.colKey),re=te.indexOf(ce.rowId);let X=ve,h=re;if(w==="up")h=Math.max(0,re-1);else if(w==="down")h=Math.min(te.length-1,re+1);else if(w==="left"){let $=ve-1;for(;$>=0&&S[$].selectable===!1;)$--;$>=0&&(X=$)}else if(w==="right"){let $=ve+1;for(;$<S.length&&S[$].selectable===!1;)$++;$<S.length&&(X=$)}return X===ve&&h===re?ce:{rowId:te[h],colKey:S[X].key}})},[]),J=o.useCallback((w=!0)=>{const S=u.current;m(null),S&&p(S),w&&setTimeout(()=>{var R;return(R=H.current)==null?void 0:R.focus({preventScroll:!0})},0)},[]),I=o.useCallback(async(w,S,R)=>{var Ge;const te=W.current.find(xe=>xe.key===S);if(!(te!=null&&te.editable))return;const{field:ae,type:ce,mask:ve,validate:re}=te.editable,X=ce==="number"?R===""?null:Number(R):R;if(ve){const xe=Bl(R,ve);if(xe){M(Ee=>({...Ee,[`${w}:${S}`]:xe}));return}}if(re){const xe=re(X);if(xe){M(Ee=>({...Ee,[`${w}:${S}`]:xe}));return}}const h=Z.current,$=Q.current.find(xe=>h(xe)===w);if(!$)return;const q=$[ae];m(null),M(xe=>{const Ee={...xe};return delete Ee[`${w}:${S}`],Ee});const ne=Q.current,oe=ne.findIndex(xe=>h(xe)===w),he=ne[Math.min(ne.length-1,oe+1)];if(p({rowId:h(he),colKey:S}),setTimeout(()=>{var Ee,Ae;const xe=document.activeElement;(!xe||xe===document.body||(Ee=H.current)!=null&&Ee.contains(xe))&&((Ae=H.current)==null||Ae.focus({preventScroll:!0}))},0),String(q??"")===String(X??""))return;const _e={...$,[ae]:X};c(xe=>xe.map(Ee=>h(Ee)===w?_e:Ee)),C({rowId:w,colKey:S});try{await((Ge=L.current)==null?void 0:Ge.call(L,{row:$,rowId:w,field:ae,oldValue:q,newValue:X}))}catch{c(xe=>xe.map(Ee=>h(Ee)===w?$:Ee)),M(xe=>({...xe,[`${w}:${S}`]:"Error al guardar. Intenta de nuevo."}))}finally{C(null)}},[]),O=o.useCallback(w=>{if(B.current){w.preventDefault();return}if(u.current)return;const S=x.current;if(!(!S||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(w.key)))switch(w.preventDefault(),w.key){case"ArrowUp":ee("up");break;case"ArrowDown":ee("down");break;case"ArrowLeft":ee("left");break;case"ArrowRight":ee("right");break;case"Tab":ee(w.shiftKey?"left":"right");break;case"Enter":{const te=W.current.find(ae=>ae.key===S.colKey);te!=null&&te.editable&&!z.current?(m(S),te.editable.type==="select"&&!U.current.has(S.colKey)&&Y(S.colKey,te.editable)):ee("down");break}}},[ee,Y]),K=o.useMemo(()=>r.map(w=>{if(!w.editable||s){const R={...w};if(delete R.editable,delete R.selectable,w.selectable===!1)return{...R,disableRowClick:!0};const te=R.cell;return{...R,className:`relative ${R.className??""}`.trim(),disableRowClick:!0,cell:ae=>{const ce=a(ae),ve=(b==null?void 0:b.rowId)===ce&&(b==null?void 0:b.colKey)===w.key;return e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-cell-id":`${ce}:${w.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var re;B.current||(p({rowId:ce,colKey:w.key}),(re=H.current)==null||re.focus({preventScroll:!0}))}}),ve&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:za}),e.jsx("span",{className:"relative z-0 pointer-events-none",children:te(ae)})]})}}}const S=w.editable;return{...w,className:`relative ${w.className??""}`.trim(),disableRowClick:!0,cell:R=>{const te=a(R),ae=w.key,ce=(f==null?void 0:f.rowId)===te&&(f==null?void 0:f.colKey)===ae,ve=(b==null?void 0:b.rowId)===te&&(b==null?void 0:b.colKey)===ae,re=N[`${te}:${ae}`],X=(g==null?void 0:g.rowId)===te&&(g==null?void 0:g.colKey)===ae,h=R[S.field],$=String(h??""),q=()=>{var oe;B.current||(p({rowId:te,colKey:ae}),m({rowId:te,colKey:ae}),(oe=H.current)==null||oe.focus({preventScroll:!0}),S.type==="select"&&!U.current.has(ae)&&Y(ae,S))};if(ce){const oe=S.type==="select"?e.jsx(Pl,{initialValue:$,options:A[ae]??[],loading:E[ae]??!1,onCommit:he=>I(te,ae,he),onCancel:J}):e.jsx(Hl,{initialValue:$,type:S.type??"text",mask:S.mask,onCommit:he=>I(te,ae,he),onCancel:J});return e.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:Fl,onClick:he=>he.stopPropagation(),children:oe})}const ne=w.cell(R);return e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-cell-id":`${te}:${ae}`,className:`peer absolute inset-0 z-10 ${X?"cursor-wait":"cursor-pointer"}`,onClick:q}),ve&&!X&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:za}),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:za,children:[e.jsx("span",{className:"h-3 w-3 shrink-0 animate-spin rounded-full border-2 border-[var(--text-muted)] border-t-transparent","aria-hidden":!0}),e.jsx("span",{className:"truncate text-xs text-[var(--text-muted)]",children:"Guardando…"})]}),e.jsx("span",{className:"relative z-0 inline-flex items-center gap-1 pointer-events-none",children:re?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:re})]}):e.jsx("span",{className:"truncate",children:ne})}),!X&&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,g,N,A,E,a,I,J,Y]);return e.jsx("div",{ref:H,tabIndex:0,onKeyDown:O,onBlur:w=>{var S;(S=H.current)!=null&&S.contains(w.relatedTarget)||setTimeout(()=>{var te,ae;const R=document.activeElement;R&&((te=R.closest)!=null&&te.call(R,"[data-bonsaif-select-dropdown]"))||(ae=H.current)!=null&&ae.contains(R)||J(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:e.jsx(Wn,{...l,columns:K,data:i,getRowId:a})})}function gt(r){return r?new Date(`${r}T12:00:00`):void 0}function qn(r){return r.toISOString().slice(0,10)}function _l({calendarMonth:r,displayIndex:t}){const{previousMonth:a,nextMonth:n,goToMonth:s,months:l,labels:i,formatters:c}=kn.useDayPicker(),u=!!a&&t===0,f=!!n&&t===l.length-1;return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,width:"100%",color:"var(--text-main)",marginBottom:6},children:[e.jsx("span",{style:{fontWeight:700},children:c.formatCaption(r.date)}),e.jsx("button",{type:"button","aria-label":i.labelPrevious(a),onClick:()=>a&&s(a),disabled:!u,style:{height:28,width:28,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg-card)",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--text-main)",opacity:u?1:.45,cursor:u?"pointer":"not-allowed"},children:e.jsx(T.HiChevronLeft,{size:16})}),e.jsx("button",{type:"button","aria-label":i.labelNext(n),onClick:()=>n&&s(n),disabled:!f,style:{height:28,width:28,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg-card)",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--text-main)",opacity:f?1:.45,cursor:f?"pointer":"not-allowed"},children:e.jsx(T.HiChevronRight,{size:16})})]})}function jl(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Wl({startDate:r,endDate:t,onChange:a,minDate:n,viewMonth:s,numberOfMonths:l=1,showSummary:i=!0,startLabel:c="Inicio",endLabel:u="Regreso"}){const f={from:gt(r),to:gt(t)},m=gt(n),[b,p]=o.useState(gt(s||r));return o.useEffect(()=>{p(gt(s||r))},[s,r]),e.jsxs("div",{children:[e.jsx("div",{style:{borderRadius:10,overflow:"hidden",border:"1px solid var(--border)",background:"var(--bg-input)",display:"flex",justifyContent:"center",padding:"10px 8px"},children:e.jsx(kn.DayPicker,{mode:"range",selected:f,month:b,onMonthChange:p,onSelect:x=>{const N=x!=null&&x.from?qn(x.from):r,M=x!=null&&x.to?qn(x.to):"";a({startDate:N,endDate:M})},numberOfMonths:l,hideNavigation:!0,disabled:m?{before:m}:void 0,showOutsideDays:!1,components:{MonthCaption:_l},className:"text-sm",classNames:{root:"w-full",months:"flex gap-3 justify-center",month:"space-y-2",month_caption:"flex items-center justify-between px-1",caption_label:"capitalize",nav:"flex items-center gap-1",button_previous:"h-8 w-8 inline-flex items-center justify-center rounded-md transition-colors",button_next:"h-8 w-8 inline-flex items-center justify-center rounded-md transition-colors",month_grid:"w-full border-collapse",weekdays:"grid grid-cols-7 gap-1 mb-1",weekday:"text-[11px] font-semibold text-center",week:"grid grid-cols-7 gap-1",day:"h-9 w-9 p-0 flex items-center justify-center",day_button:"h-9 w-9 rounded-md text-sm font-medium transition-colors outline-none",selected:"font-semibold",range_start:"font-semibold",range_middle:"font-medium",range_end:"font-semibold",today:"font-bold",disabled:"opacity-40 cursor-not-allowed",hidden:"invisible"},styles:{month_caption:{color:"var(--text-main)",marginBottom:6,display:"flex",alignItems:"center",justifyContent:"space-between"},caption_label:{color:"var(--text-main)",fontWeight:700},nav:{position:"static",display:"flex",alignItems:"center",gap:6},weekday:{color:"var(--text-muted)",textTransform:"lowercase"},button_previous:{height:32,width:32,background:"var(--bg-card)",color:"var(--text-main)",border:"1px solid var(--border)"},button_next:{height:32,width:32,background:"var(--bg-card)",color:"var(--text-main)",border:"1px solid var(--border)"},day_button:{color:"var(--text-main)",borderRadius:8},chevron:{fill:"var(--text-main)"},today:{border:"1px solid color-mix(in srgb, var(--primary) 35%, transparent)"},disabled:{color:"var(--text-muted)"}},modifiersStyles:{selected:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_start:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_end:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_middle:{background:"color-mix(in srgb, var(--primary) 20%, transparent)",color:"var(--text-main)"}},formatters:{formatCaption:x=>jl(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(x)),formatWeekdayName:x=>new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(x)},labels:{labelMonthDropdown:()=>"Mes",labelYearDropdown:()=>"Año"}})}),i&&r&&e.jsxs("div",{style:{marginTop:8,fontSize:12,color:"var(--text-muted)",display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsxs("span",{children:[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 ql="bonsaif-ui:hide-tooltips";function Un(){window.dispatchEvent(new CustomEvent(ql))}function Ul(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Vl({trigger:r,items:t,align:a="end",width:n=220,disabled:s=!1,className:l="",menuClassName:i="",onOpenChange:c}){const[u,f]=o.useState(!1),[m,b]=o.useState(!1),[p,x]=o.useState({}),N=o.useRef(null),M=o.useRef(null),g=o.useCallback(E=>{f(E),c==null||c(E)},[c]),C=o.useCallback(()=>{const E=N.current;if(!E)return;const k=E.getBoundingClientRect(),U=typeof n=="number"?n:k.width,H=typeof n=="number"?n:Math.max(k.width,180),j=a==="end"?Math.max(8,k.right-H):Math.min(k.left,window.innerWidth-H-8),Y=window.innerHeight-k.bottom,Q=Y<240&&k.top>Y?void 0:k.bottom+6,L=Q===void 0?window.innerHeight-k.top+6:void 0;x({position:"fixed",zIndex:9999,left:j,top:Q,bottom:L,width:Ul(typeof n=="number"?U:n)})},[a,n]);o.useEffect(()=>b(!0),[]),o.useEffect(()=>{if(!u)return;C();const E=U=>{var j,Y;const H=U.target;!((j=N.current)!=null&&j.contains(H))&&!((Y=M.current)!=null&&Y.contains(H))&&g(!1)},k=U=>{U.key==="Escape"&&g(!1)};return document.addEventListener("mousedown",E),window.addEventListener("keydown",k),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{document.removeEventListener("mousedown",E),window.removeEventListener("keydown",k),window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[u,g,C]);const B=E=>{s||(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),g(!u))},A=o.isValidElement(r)?o.cloneElement(r,{onClick:()=>{s||(Un(),g(!u))}}):r,F=u?e.jsx("div",{ref:M,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${i}`,style:p,children:t.map(E=>e.jsxs("div",{children:[E.separatorBefore&&e.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),e.jsxs("button",{type:"button",role:"menuitem",disabled:E.disabled,onClick:()=>{var k;E.disabled||(Un(),(k=E.onSelect)==null||k.call(E),g(!1))},className:"flex w-full min-w-0 items-start gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:E.danger?"var(--danger)":"var(--text-main)"},children:[E.icon&&e.jsx("span",{className:"mt-0.5 shrink-0",children:E.icon}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm font-medium",children:E.label}),E.description&&e.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:E.description})]})]})]},E.id))}):null;return e.jsxs("span",{ref:N,role:"button",tabIndex:s?-1:0,"aria-haspopup":"menu","aria-expanded":u,onKeyDown:B,className:`inline-flex ${s?"pointer-events-none opacity-60":""} ${l}`,children:[A,m&&F?Je.createPortal(F,document.body):null]})}const Gl=180,Vn="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Kl({open:r,onClose:t,title:a,subtitle:n,leadingIcon:s,confirmLabel:l="Guardar",onConfirm:i,loading:c=!1,confirmDisabled:u=!1,headerActions:f,bodyClassName:m="flex-1 overflow-y-auto px-6 py-5",width:b=440,hasUnsavedChanges:p=!1,unsavedChangesTitle:x="Descartar cambios",unsavedChangesDescription:N="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:M="Descartar",unsavedChangesCancelLabel:g="Seguir editando",onDiscardChanges:C,disabled:B=!1,children:A}){const[F,E]=o.useState(!1),[k,U]=o.useState(!1),[H,j]=o.useState(!1),Y=o.useCallback(()=>{U(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>j(!0))})},[]),Q=o.useCallback(()=>{j(!1),window.setTimeout(()=>U(!1),Gl)},[]),L=o.useCallback(()=>{if(p){Y();return}t()},[p,t,Y]),Z=o.useCallback(()=>{j(!1),U(!1),C==null||C(),t()},[t,C]);return o.useEffect(()=>{E(!0)},[]),o.useEffect(()=>(document.body.style.overflow=r?"hidden":"",r||(j(!1),U(!1)),()=>{document.body.style.overflow=""}),[r]),o.useEffect(()=>{if(!r)return;const W=z=>{if(z.key==="Escape"){if(k){Q();return}L()}};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[Q,k,r,L]),F?Je.createPortal(e.jsxs("div",{"aria-hidden":!r,"data-bonsaif-overlay":r?"true":void 0,className:`fixed inset-0 z-[1000] flex transition-opacity duration-300 ${r?"opacity-100":"opacity-0 pointer-events-none"}`,children:[e.jsx("div",{className:`absolute inset-0 ${Vn}`,onClick:L}),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:L,title:"Cerrar",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:a}),n&&e.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:n})]})]}),(f||i)&&e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[f,i&&e.jsxs(e.Fragment,{children:[e.jsx(He,{variant:"secondary",size:"sm",onClick:L,style:{background:"var(--bg-input)"},children:"Cancelar"}),e.jsx(He,{variant:"primary",size:"sm",icon:e.jsx(Ls.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:u,title:l})]})]})]}),e.jsx("div",{"data-drawer-scroll":"true",className:m,children:A})]}),B&&e.jsx("div",{className:"absolute inset-0 z-[1002] cursor-not-allowed",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 60%, transparent)",backdropFilter:"blur(2px)"}}),k&&e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":x,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[e.jsx("div",{className:`absolute inset-0 ${Vn} transition-opacity duration-200 ease-out ${H?"opacity-100":"opacity-0"}`,onClick:Q}),e.jsxs("div",{className:`relative z-10 w-full max-w-sm rounded-2xl border p-6 shadow-2xl transition-[opacity,transform] duration-200 ease-out ${H?"translate-y-0 scale-100 opacity-100":"translate-y-2 scale-[0.96] opacity-0"}`,style:{background:"var(--bg-card, #ffffff)",borderColor:"var(--border, #d8e1dc)"},children:[e.jsx(He,{variant:"icon",onClick:Q,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":g,children:e.jsx(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:x}),e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:N}),e.jsxs("div",{className:"mt-6 flex gap-2",children:[e.jsx(He,{variant:"secondary",onClick:Q,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:g}),e.jsx(He,{variant:"secondary",onClick:Z,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:M})]})]})]})]}),document.body):null}const Xl=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Yl=/^\+?[0-9\s().-]+$/,Zl=7,Ql=15;function or(r){return r==null||String(r).trim()===""}function Gn(r){return typeof r=="number"?r:typeof r=="string"&&r.trim()!==""?Number(r):Number.NaN}function _a(r){return or(r)?!1:Xl.test(String(r))}function ja(r){if(or(r))return!1;const t=String(r),a=t.replace(/\D/g,"");return Yl.test(t)&&a.length>=Zl&&a.length<=Ql}function Jl(r="Este campo es requerido."){return t=>or(t)?r:void 0}function Rl(r="Ingresa un correo valido."){return t=>or(t)||_a(t)?void 0:r}function ei(r="Ingresa un telefono valido."){return t=>or(t)||ja(t)?void 0:r}function ri(r,t){return a=>or(a)||String(a).length>=r?void 0:t??`Debe tener al menos ${r} caracteres.`}function ti(r,t){return a=>or(a)||String(a).length<=r?void 0:t??`Debe tener ${r} caracteres o menos.`}function ai(r,t){return a=>{if(or(a))return;const n=Gn(a);return Number.isFinite(n)&&n>=r?void 0:t??`Debe ser mayor o igual a ${r}.`}}function ni(r,t){return a=>{if(or(a))return;const n=Gn(a);return Number.isFinite(n)&&n<=r?void 0:t??`Debe ser menor o igual a ${r}.`}}function oi(r,t="El formato no es valido."){return a=>or(a)||r.test(String(a))?void 0:t}function si(r,t){const a={};for(const n of Object.keys(t)){const s=t[n];if(!s)continue;const l=Array.isArray(s)?s:[s];for(const i of l){const c=i(r[n],r);if(c){a[n]=c;break}}}return{valid:Object.keys(a).length===0,errors:a}}var Kn={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Xn=o.createContext&&o.createContext(Kn),li=["attr","size","title"];function ii(r,t){if(r==null)return{};var a,n,s=ci(r,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(r);for(n=0;n<l.length;n++)a=l[n],t.indexOf(a)===-1&&{}.propertyIsEnumerable.call(r,a)&&(s[a]=r[a])}return s}function ci(r,t){if(r==null)return{};var a={};for(var n in r)if({}.hasOwnProperty.call(r,n)){if(t.indexOf(n)!==-1)continue;a[n]=r[n]}return a}function qt(){return qt=Object.assign?Object.assign.bind():function(r){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(r[n]=a[n])}return r},qt.apply(null,arguments)}function Yn(r,t){var a=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);t&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),a.push.apply(a,n)}return a}function Ut(r){for(var t=1;t<arguments.length;t++){var a=arguments[t]!=null?arguments[t]:{};t%2?Yn(Object(a),!0).forEach(function(n){di(r,n,a[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(a)):Yn(Object(a)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(a,n))})}return r}function di(r,t,a){return(t=ui(t))in r?Object.defineProperty(r,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[t]=a,r}function ui(r){var t=fi(r,"string");return typeof t=="symbol"?t:t+""}function fi(r,t){if(typeof r!="object"||!r)return r;var a=r[Symbol.toPrimitive];if(a!==void 0){var n=a.call(r,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function Zn(r){return r&&r.map((t,a)=>o.createElement(t.tag,Ut({key:a},t.attr),Zn(t.child)))}function Wa(r){return t=>o.createElement(bi,qt({attr:Ut({},r.attr)},t),Zn(r.child))}function bi(r){var t=a=>{var{attr:n,size:s,title:l}=r,i=ii(r,li),c=s||a.size||"1em",u;return a.className&&(u=a.className),r.className&&(u=(u?u+" ":"")+r.className),o.createElement("svg",qt({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,n,i,{className:u,style:Ut(Ut({color:r.color||a.color},a.style),r.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),l&&o.createElement("title",null,l),r.children)};return Xn!==void 0?o.createElement(Xn.Consumer,null,a=>t(a)):t(Kn)}function Qn(r){return Wa({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z"},child:[]}]})(r)}function pi(r){return Wa({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M247.31,124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57,61.26,162.88,48,128,48S61.43,61.26,36.34,86.35C17.51,105.18,9,124,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208s66.57-13.26,91.66-38.34c18.83-18.83,27.3-37.61,27.65-38.4A8,8,0,0,0,247.31,124.76ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.47,133.47,0,0,1,25,128,133.33,133.33,0,0,1,48.07,97.25C70.33,75.19,97.22,64,128,64s57.67,11.19,79.93,33.25A133.46,133.46,0,0,1,231.05,128C223.84,141.46,192.43,192,128,192Zm0-112a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Z"},child:[]}]})(r)}function mi(r){return Wa({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M228,175a8,8,0,0,1-10.92-3l-19-33.2A123.23,123.23,0,0,1,162,155.46l5.87,35.22a8,8,0,0,1-6.58,9.21A8.4,8.4,0,0,1,160,200a8,8,0,0,1-7.88-6.69l-5.77-34.58a133.06,133.06,0,0,1-36.68,0l-5.77,34.58A8,8,0,0,1,96,200a8.4,8.4,0,0,1-1.32-.11,8,8,0,0,1-6.58-9.21L94,155.46a123.23,123.23,0,0,1-36.06-16.69L39,172A8,8,0,1,1,25.06,164l20-35a153.47,153.47,0,0,1-19.3-20A8,8,0,1,1,38.22,99c16.6,20.54,45.64,45,89.78,45s73.18-24.49,89.78-45A8,8,0,1,1,230.22,109a153.47,153.47,0,0,1-19.3,20l20,35A8,8,0,0,1,228,175Z"},child:[]}]})(r)}function Vt({className:r="",...t}){return e.jsx("input",{...t,className:`h-10 rounded-lg border border-[var(--border)] bg-[var(--bg-input)] px-2.5 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] ${r}`})}function qa({label:r,containerClassName:t="",helperText:a,error:n,errorDisplay:s="inline",errorTooltipLabel:l="Error de validacion",labelAction:i,floatingLabel:c=!1,showPasswordToggle:u=!0,nativeValidation:f=!1,className:m="",required:b,...p}){const[x,N]=o.useState(()=>!!p.autoFocus),[M,g]=o.useState(!1),C=p.type==="password"&&u,B=C&&M?"text":p.type,A=!!n,F=A&&s!=="tooltip",E=A&&s!=="inline",k=f?b:void 0,U=A?"border-[var(--danger)] focus:border-[var(--danger)]":"",H=E?C?"pr-20":"pr-10":C?"pr-10":"",j=p.value!==void 0?String(p.value).length>0:p.defaultValue!==void 0&&String(p.defaultValue).length>0,Y=x||j,Q={top:Y?7:12,color:x?"var(--primary)":"var(--text-muted)",fontSize:Y?10:13,fontWeight:Y?600:400,textTransform:Y?"uppercase":"none"},L=ee=>{var J;N(!0),(J=p.onFocus)==null||J.call(p,ee)},Z=ee=>{var J;N(!1),(J=p.onBlur)==null||J.call(p,ee)},W=C?e.jsxs("button",{type:"button","aria-label":M?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":M,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors duration-200 hover:text-[var(--primary)] focus:outline-none",tabIndex:-1,onClick:()=>g(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 ${M?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:e.jsx(pi,{className:"h-[18px] w-[18px]"})}),e.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${M?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:e.jsx(mi,{className:"h-[18px] w-[18px]"})})]}):null,z=E?e.jsx(jr,{as:"span",content:n,className:`absolute top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--danger)] outline-none transition-colors hover:bg-[var(--danger-bg)] focus-visible:bg-[var(--danger-bg)] ${C?"right-10":"right-2.5"}`,children:e.jsx("span",{tabIndex:0,role:"img","aria-label":l,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(Qn,{className:"h-[18px] w-[18px]"})})}):null;return c?e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"relative block",children:[e.jsx(Vt,{...p,type:B,required:k,placeholder:" ","aria-invalid":A||p["aria-invalid"],"data-has-value":j?"true":void 0,className:`h-11 w-full pt-5 ${H} ${U} ${m}`,onFocus:L,onBlur:Z}),e.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:Q,children:[r,b&&e.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),i&&e.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:Y?7:12},children:i}),z,W]}),F?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]}):e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e.jsx("span",{children:r}),b&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),i&&e.jsx("span",{className:"ml-auto normal-case",children:i})]}),C?e.jsxs("span",{className:"relative block",children:[e.jsx(Vt,{...p,type:B,required:k,"aria-invalid":A||p["aria-invalid"],className:`w-full ${H} ${U} ${m}`,onFocus:L,onBlur:Z}),z,W]}):e.jsxs("span",{className:"relative block",children:[e.jsx(Vt,{...p,required:k,"aria-invalid":A||p["aria-invalid"],className:`w-full ${H} ${U} ${m}`}),z]}),F?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]})}function Jn(r){return r==null?"":String(r)}function hi({autoComplete:r="email",inputMode:t="email",validate:a=!0,invalidMessage:n="Ingresa un correo valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:u,...f}){const[m,b]=o.useState(()=>Jn(c)),p=i!==void 0?Jn(i):m,x=a&&p.length>0&&!_a(p)?n:void 0,N=M=>{i===void 0&&b(M.currentTarget.value),u==null||u(M)};return e.jsx(qa,{...f,value:i,defaultValue:c,type:"text",inputMode:t,autoComplete:r,error:l??x,errorDisplay:s,onChange:N})}const gi={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function vi({title:r="Sin resultados",description:t,icon:a=e.jsx(T.HiInbox,{className:"h-5 w-5"}),action:n,secondaryAction:s,size:l="md",className:i=""}){return e.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${gi[l]} ${i}`,children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[a&&e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:a}),e.jsxs("div",{className:"space-y-1",children:[r&&e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-main)]",children:r}),t&&e.jsx("div",{className:"text-sm leading-5 text-[var(--text-muted)]",children:t})]}),(n||s)&&e.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[s,n]})]})})}const xi={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function yi(r){if(r===0)return"0 B";const t=["B","KB","MB","GB"],a=Math.min(Math.floor(Math.log(r)/Math.log(1024)),t.length-1),n=r/1024**a;return`${n>=10||a===0?n.toFixed(0):n.toFixed(1)} ${t[a]}`}function Rn(r,t){return t?t.split(",").map(a=>a.trim().toLowerCase()).filter(Boolean).some(a=>{const n=r.name.toLowerCase(),s=r.type.toLowerCase();return a.startsWith(".")?n.endsWith(a):a.endsWith("/*")?s.startsWith(a.slice(0,-1)):s===a}):!0}function wi(r,t,a){return t?a===void 0?r:r.slice(0,Math.max(0,a)):r.slice(0,1)}function Ni({label:r,helperText:t,error:a,labelAction:n,value:s,defaultValue:l=[],onFilesChange:i,onRejectedFiles:c,multiple:u=!1,maxFiles:f,appendFiles:m=!1,showFileList:b=!0,clearable:p=!0,browseLabel:x="Buscar archivos",dropLabel:N="Suelta los archivos aqui",emptyLabel:M="Arrastra y suelta archivos",emptyDescription:g="o haz click para buscarlos en tu equipo",selectedLabel:C="Archivos seleccionados",size:B="md",containerClassName:A="",dropzoneClassName:F="",fileListClassName:E="",className:k="",id:U,accept:H,disabled:j,required:Y,...Q}){const L=o.useId(),Z=U??L,W=o.useRef(null),[z,ee]=o.useState(!1),[J,I]=o.useState(l),O=s??J,K=!!a,w=p&&O.length>0&&!j,S=(q,ne)=>{s===void 0&&I(q),i==null||i(q,ne)},R=(q,ne)=>{const oe=q.filter(xe=>Rn(xe,H)),he=q.filter(xe=>!Rn(xe,H)),_e=m?[...O,...oe]:oe,Ge=wi(_e,u,f);he.length>0&&(c==null||c(he)),S(Ge,ne)},te=()=>{var q;j||(q=W.current)==null||q.click()},ae=q=>{R(Array.from(q.target.files??[]),q),q.target.value=""},ce=q=>{q.preventDefault(),j||ee(!0)},ve=q=>{q.currentTarget.contains(q.relatedTarget)||ee(!1)},re=q=>{q.preventDefault(),ee(!1),!j&&R(Array.from(q.dataTransfer.files),q)},X=q=>{q.key!=="Enter"&&q.key!==" "||(q.preventDefault(),te())},h=q=>{S(O.filter((ne,oe)=>oe!==q))},$=()=>{S([])};return e.jsxs("div",{className:`flex flex-col gap-2 ${A}`,children:[(r||n)&&e.jsxs("div",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[r&&e.jsx("span",{children:r}),Y&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),n&&e.jsx("span",{className:"ml-auto normal-case",children:n})]}),e.jsx("input",{...Q,ref:W,id:Z,type:"file",accept:H,multiple:u,disabled:j,required:Y&&O.length===0,"aria-invalid":K||Q["aria-invalid"],className:"sr-only",onChange:ae}),e.jsxs("div",{role:"button",tabIndex:j?-1:0,"aria-controls":Z,"aria-disabled":j||void 0,"aria-invalid":K||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)] ${xi[B]} ${z?"border-[var(--primary)] bg-[var(--bg-input)]":K?"border-[var(--danger)]":"border-[var(--border)]"} ${j?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${F} ${k}`,onClick:te,onDragOver:ce,onDragLeave:ve,onDrop:re,onKeyDown:X,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:z?N:M}),g&&e.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:g})]}),x&&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:x})]}),b&&O.length>0&&e.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${E}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase text-[var(--text-muted)]",children:C}),w&&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:$,children:e.jsx(T.HiTrash,{className:"h-4 w-4"})})]}),e.jsx("ul",{className:"divide-y divide-[var(--border)]",children:O.map((q,ne)=>e.jsxs("li",{className:"flex items-center gap-3 px-3 py-2",children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-[var(--bg-input)] text-[var(--text-muted)]",children:e.jsx(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:q.name}),e.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:yi(q.size)})]}),!j&&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:()=>h(ne),children:e.jsx(T.HiXMark,{className:"h-4 w-4"})})]},`${q.name}-${q.lastModified}-${ne}`))})]}),a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:a}):t?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:t}):null]})}const ki=[{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 Si({fields:r,title:t="Layout",fieldTypes:a=ki,saveLabel:n="Guardar",allowAddField:s=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:u,onChange:f}){const[m,b]=o.useState(()=>r.map(A=>({key:!1,type:"",...A}))),[p,x]=o.useState(""),[N,M]=o.useState(""),g=o.useCallback((A,F)=>{b(E=>{const k=E.map((U,H)=>H===A?{...U,...F}:U);return f==null||f(k),k})},[f]),C=o.useCallback(()=>{u==null||u(m)},[m,u]),B=o.useCallback(()=>{var k;const A=p.trim();if(!A){M("Ingresa un nombre de campo.");return}if(m.some(U=>U.name.toLowerCase()===A.toLowerCase())){M("Ese campo ya existe en el arreglo.");return}const E={name:A,key:!1,type:((k=a[0])==null?void 0:k.value)??""};b(U=>{const H=[...U,E];return f==null||f(H),H}),x(""),M("")},[a,m,p,f]);return e.jsxs("div",{className:"flex flex-col rounded-xl border shadow-sm",style:{borderColor:"var(--border)",background:"var(--bg-card)",color:"var(--text-main)"},children:[e.jsx("div",{className:"border-b px-6 py-4",style:{borderColor:"var(--border)"},children:e.jsx("span",{className:"text-base font-semibold",style:{color:"var(--text-main)"},children:t})}),e.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] gap-4 border-b px-6 py-2 text-xs font-medium uppercase tracking-wide",style:{borderColor:"var(--border)",color:"var(--text-muted)"},children:[e.jsx("span",{children:"Campo"}),e.jsx("span",{className:"text-center",children:"Llave"}),e.jsx("span",{children:"Tipo de Campo"})]}),e.jsxs("div",{className:"max-h-[420px] overflow-y-auto",children:[m.map((A,F)=>e.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] items-center gap-4 border-b px-6 py-3 last:border-0 hover:bg-[var(--bg-input)] transition-colors",style:{borderColor:"var(--border)"},children:[e.jsx("span",{className:"text-sm font-medium",style:{color:"var(--text-main)"},children:A.name}),e.jsx("div",{className:"flex justify-center",children:e.jsx(Ht,{size:"sm",checked:A.key??!1,onChange:E=>g(F,{key:E.target.checked}),"aria-label":`${A.name} es clave`})}),e.jsx(Er,{value:A.type??"",onChange:E=>g(F,{type:E}),options:a,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${A.name}`})]},A.name)),m.length===0&&e.jsx("p",{className:"px-6 py-8 text-center text-sm",style:{color:"var(--text-muted)"},children:"No hay campos disponibles."})]}),e.jsx("div",{className:"flex justify-end border-t px-6 py-4",style:{borderColor:"var(--border)"},children:e.jsxs("div",{className:"w-full space-y-2",children:[s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:p,onChange:A=>{x(A.currentTarget.value),N&&M("")},onKeyDown:A=>{A.key==="Enter"&&(A.preventDefault(),B())},placeholder:l,className:"min-w-0 flex-1 rounded-lg border px-3 py-2 text-sm outline-none transition-colors",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"},"aria-label":"Nombre del nuevo campo"}),e.jsx(He,{variant:"secondary",onClick:B,height:36,padding:"0 12px",children:i})]}),N&&e.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:N})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(He,{variant:"primary",onClick:C,disabled:c,loading:c,children:n})})]})})]})}function eo({label:r,children:t,helperText:a,error:n,labelAction:s,required:l=!1,className:i="",contentClassName:c=""}){return e.jsxs("label",{className:`flex flex-col gap-2 ${i}`,children:[(r||s)&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[r&&e.jsx("span",{children:r}),l&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),s&&e.jsx("span",{className:"ml-auto normal-case",children:s})]}),e.jsx("span",{className:`block ${c}`,children:t}),n?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]})}function ro(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function to(r,t){if(r.length!==t.length)return!1;const a=new Set(t);return r.every(n=>a.has(n))}function Ua(r){return r.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Ci(r,t){if(!t)return!0;const a=Ua(t);return Ua(r.label).includes(a)||!!(r.sublabel&&Ua(r.sublabel).includes(a))}function Ei({value:r,onChange:t,options:a,placeholder:n="Seleccionar…",disabled:s=!1,className:l="",style:i,height:c=40,padding:u="6px 10px",searchable:f=!0,minOptionsForSearch:m=6,maxVisibleValues:b=2,truncateSelectedValues:p=!0,emptyText:x="Sin resultados",clearLabel:N="Limpiar seleccion",pruneMissingValues:M=!0}){const[g,C]=o.useState(!1),[B,A]=o.useState(""),[F,E]=o.useState(0),[k,U]=o.useState(!1),[H,j]=o.useState({}),Y=o.useRef(null),Q=o.useRef(null),L=o.useRef(null),Z=o.useRef(null),W=f&&a.length>=m,z=o.useMemo(()=>new Set(r),[r]),ee=o.useMemo(()=>{const h=new Map;for(const $ of a)h.set($.value,$);return h},[a]),J=o.useMemo(()=>{const h=[];for(const $ of r){const q=ee.get($);q&&h.push(q)}return h},[ee,r]),I=b==="all"?J.length:b,O=J.slice(0,I),K=Math.max(0,J.length-O.length),w=o.useMemo(()=>{const h=B.trim();return!W||!h?a:a.filter($=>Ci($,h))},[a,B,W]),S=o.useCallback(()=>{const h=Y.current;if(!h)return;const $=h.getBoundingClientRect(),q=W?304:244,ne=window.innerHeight-$.bottom,oe=ne<q&&$.top>ne;j({position:"fixed",left:$.left,top:oe?void 0:$.bottom+4,bottom:oe?window.innerHeight-$.top+4:void 0,width:Math.max($.width,240),zIndex:9999})},[W]),R=o.useCallback(h=>{to(r,h)||t(h)},[t,r]),te=o.useCallback(h=>{const $=ee.get(h);if($!=null&&$.disabled)return;const q=z.has(h)?r.filter(ne=>ne!==h):[...r,h];R(q)},[R,ee,r,z]),ae=o.useCallback(()=>R([]),[R]),ce=o.useCallback(()=>{C(!1),A(""),E(0)},[]);o.useEffect(()=>U(!0),[]);const ve=o.useMemo(()=>a.map(h=>h.value).join("\0"),[a]);o.useEffect(()=>{if(!M||r.length===0||a.length===0)return;const h=new Set(a.map(q=>q.value)),$=r.filter(q=>h.has(q));to(r,$)||t($)},[ve]),o.useEffect(()=>{if(!g)return;function h($){var ne,oe;const q=$.target;!((ne=Y.current)!=null&&ne.contains(q))&&!((oe=Q.current)!=null&&oe.contains(q))&&ce()}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[ce,g]),o.useEffect(()=>{g&&(E(0),S(),W&&setTimeout(()=>{var h;return(h=L.current)==null?void 0:h.focus()},0))},[g,W,S]),o.useEffect(()=>{if(g)return window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}},[g,S]),o.useEffect(()=>{if(w.length===0){E(0);return}E(h=>Math.min(h,w.length-1))},[w.length]),o.useEffect(()=>{if(F<0||!Z.current)return;const h=Z.current.children[F];h==null||h.scrollIntoView({block:"nearest"})},[F]);function re(h){if(!s){if(!g){(h.key==="Enter"||h.key===" "||h.key==="ArrowDown")&&(h.preventDefault(),C(!0));return}if(h.key==="Escape"){h.preventDefault(),ce();return}if(h.key==="ArrowDown"){if(h.preventDefault(),w.length===0)return;E($=>Math.min($+1,w.length-1));return}if(h.key==="ArrowUp"){h.preventDefault(),E($=>Math.max($-1,0));return}if(h.key==="Enter"&&w[F]&&!w[F].disabled){h.preventDefault(),te(w[F].value);return}h.key==="Backspace"&&!B&&r.length&&(h.preventDefault(),R(r.slice(0,-1)))}}const X=e.jsxs("div",{ref:Q,className:"overflow-hidden rounded-xl shadow-xl",style:{...H,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:L,value:B,onChange:h=>{A(h.target.value),E(0)},onKeyDown:h=>{(h.key==="ArrowDown"||h.key==="ArrowUp"||h.key==="Enter"||h.key==="Escape")&&(h.stopPropagation(),re(h))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),B&&e.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:h=>{h.preventDefault(),A(""),E(0)},children:e.jsx(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:[J.length," seleccionados",r.length>J.length?` (${r.length-J.length} no disponibles)`:""]}),e.jsx("button",{type:"button",onMouseDown:h=>{h.preventDefault(),ae()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:N})]}),e.jsxs("ul",{ref:Z,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:W?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[w.map((h,$)=>{const q=$===F,ne=z.has(h.value);return e.jsxs("li",{role:"option","aria-selected":ne,onMouseDown:oe=>{oe.preventDefault(),!h.disabled&&te(h.value)},onMouseEnter:()=>!h.disabled&&E($),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:q?"var(--bg-hover)":ne?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:h.disabled?"var(--text-muted)":"var(--text-main)",cursor:h.disabled?"not-allowed":"pointer",opacity:h.disabled?.58:1},children:[e.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:ne?"var(--primary)":"var(--border)",background:ne?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:ne&&e.jsx(T.HiCheck,{className:"h-3 w-3"})}),h.color&&e.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:h.color}}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:h.label}),h.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:h.sublabel})]}),h.badge&&e.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:h.badge})]},h.value)}),w.length===0&&e.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:x})]})]});return e.jsxs("div",{ref:Y,className:`relative ${l||"w-full"}`,style:i,onKeyDown:re,children:[e.jsxs("button",{type:"button",disabled:s,onClick:()=>{s||(g?ce():C(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:ro(c),padding:ro(u),background:"var(--bg-input)",color:J.length?"var(--text-main)":"var(--text-muted)",border:g?"1px solid var(--primary)":"1px solid var(--border)",opacity:s?.5:1,cursor:s?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":g,children:[e.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:O.length?e.jsxs(e.Fragment,{children:[O.map(h=>e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${p?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[h.color&&e.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:h.color}}),e.jsx("span",{className:p?"truncate":"break-words",children:h.label}),e.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${h.label}`,onMouseDown:$=>{$.preventDefault(),$.stopPropagation(),te(h.value)},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(T.HiXMark,{className:"h-3 w-3"})})]},h.value)),K>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:["+",K]})]}):e.jsx("span",{className:"truncate",children:n})}),J.length?e.jsx("span",{role:"button",tabIndex:-1,"aria-label":N,onMouseDown:h=>{h.preventDefault(),h.stopPropagation(),ae()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(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:g?"rotate(180deg)":"rotate(0deg)"}})]}),g&&k&&Je.createPortal(X,document.body)]})}function Mi({inputMode:r="decimal",...t}){return e.jsx(qa,{...t,type:"number",inputMode:r})}function Li(r,t,a){const n=[],s=Math.max(2,r-a),l=Math.min(t-1,r+a);n.push(1),s>2&&n.push("...");for(let i=s;i<=l;i+=1)n.push(i);return l<t-1&&n.push("..."),t>1&&n.push(t),n}function $i({page:r,totalPages:t,onPageChange:a,disabled:n=!1,siblingCount:s=1,className:l=""}){const i=Math.max(1,t),c=Math.min(Math.max(1,r),i),u=Li(c,i,s);return e.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[e.jsx(He,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:n||c<=1,onClick:()=>a(c-1),children:e.jsx(T.HiChevronLeft,{className:"h-4 w-4"})}),u.map((f,m)=>f==="..."?e.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${m}`):e.jsx("button",{type:"button","aria-current":f===c?"page":void 0,disabled:n,onClick:()=>a(f),className:"flex h-8 min-w-8 items-center justify-center rounded-md border px-2 text-xs font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-50",style:{borderColor:f===c?"var(--primary)":"var(--border)",background:f===c?"var(--primary)":"var(--bg-card)",color:f===c?"var(--primary-fg)":"var(--text-secondary)"},children:f},f)),e.jsx(He,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:n||c>=i,onClick:()=>a(c+1),children:e.jsx(T.HiChevronRight,{className:"h-4 w-4"})})]})}const ao=[{value:"+1",label:"+1",sublabel:"Estados Unidos, Canada, Caribe"},{value:"+7",label:"+7",sublabel:"Rusia, Kazajistan"},{value:"+20",label:"+20",sublabel:"Egipto"},{value:"+27",label:"+27",sublabel:"Sudafrica"},{value:"+30",label:"+30",sublabel:"Grecia"},{value:"+31",label:"+31",sublabel:"Paises Bajos"},{value:"+32",label:"+32",sublabel:"Belgica"},{value:"+33",label:"+33",sublabel:"Francia"},{value:"+34",label:"+34",sublabel:"Espana"},{value:"+36",label:"+36",sublabel:"Hungria"},{value:"+39",label:"+39",sublabel:"Italia, Vaticano"},{value:"+40",label:"+40",sublabel:"Rumania"},{value:"+41",label:"+41",sublabel:"Suiza"},{value:"+43",label:"+43",sublabel:"Austria"},{value:"+44",label:"+44",sublabel:"Reino Unido"},{value:"+45",label:"+45",sublabel:"Dinamarca"},{value:"+46",label:"+46",sublabel:"Suecia"},{value:"+47",label:"+47",sublabel:"Noruega"},{value:"+48",label:"+48",sublabel:"Polonia"},{value:"+49",label:"+49",sublabel:"Alemania"},{value:"+51",label:"+51",sublabel:"Peru"},{value:"+52",label:"+52",sublabel:"Mexico"},{value:"+53",label:"+53",sublabel:"Cuba"},{value:"+54",label:"+54",sublabel:"Argentina"},{value:"+55",label:"+55",sublabel:"Brasil"},{value:"+56",label:"+56",sublabel:"Chile"},{value:"+57",label:"+57",sublabel:"Colombia"},{value:"+58",label:"+58",sublabel:"Venezuela"},{value:"+60",label:"+60",sublabel:"Malasia"},{value:"+61",label:"+61",sublabel:"Australia"},{value:"+62",label:"+62",sublabel:"Indonesia"},{value:"+63",label:"+63",sublabel:"Filipinas"},{value:"+64",label:"+64",sublabel:"Nueva Zelanda"},{value:"+65",label:"+65",sublabel:"Singapur"},{value:"+66",label:"+66",sublabel:"Tailandia"},{value:"+81",label:"+81",sublabel:"Japon"},{value:"+82",label:"+82",sublabel:"Corea del Sur"},{value:"+84",label:"+84",sublabel:"Vietnam"},{value:"+86",label:"+86",sublabel:"China"},{value:"+90",label:"+90",sublabel:"Turquia"},{value:"+91",label:"+91",sublabel:"India"},{value:"+92",label:"+92",sublabel:"Pakistan"},{value:"+93",label:"+93",sublabel:"Afganistan"},{value:"+94",label:"+94",sublabel:"Sri Lanka"},{value:"+95",label:"+95",sublabel:"Myanmar"},{value:"+98",label:"+98",sublabel:"Iran"},{value:"+211",label:"+211",sublabel:"Sudan del Sur"},{value:"+212",label:"+212",sublabel:"Marruecos, Sahara Occidental"},{value:"+213",label:"+213",sublabel:"Argelia"},{value:"+216",label:"+216",sublabel:"Tunez"},{value:"+218",label:"+218",sublabel:"Libia"},{value:"+220",label:"+220",sublabel:"Gambia"},{value:"+221",label:"+221",sublabel:"Senegal"},{value:"+222",label:"+222",sublabel:"Mauritania"},{value:"+223",label:"+223",sublabel:"Mali"},{value:"+224",label:"+224",sublabel:"Guinea"},{value:"+225",label:"+225",sublabel:"Costa de Marfil"},{value:"+226",label:"+226",sublabel:"Burkina Faso"},{value:"+227",label:"+227",sublabel:"Niger"},{value:"+228",label:"+228",sublabel:"Togo"},{value:"+229",label:"+229",sublabel:"Benin"},{value:"+230",label:"+230",sublabel:"Mauricio"},{value:"+231",label:"+231",sublabel:"Liberia"},{value:"+232",label:"+232",sublabel:"Sierra Leona"},{value:"+233",label:"+233",sublabel:"Ghana"},{value:"+234",label:"+234",sublabel:"Nigeria"},{value:"+235",label:"+235",sublabel:"Chad"},{value:"+236",label:"+236",sublabel:"Republica Centroafricana"},{value:"+237",label:"+237",sublabel:"Camerun"},{value:"+238",label:"+238",sublabel:"Cabo Verde"},{value:"+239",label:"+239",sublabel:"Santo Tome y Principe"},{value:"+240",label:"+240",sublabel:"Guinea Ecuatorial"},{value:"+241",label:"+241",sublabel:"Gabon"},{value:"+242",label:"+242",sublabel:"Republica del Congo"},{value:"+243",label:"+243",sublabel:"Republica Democratica del Congo"},{value:"+244",label:"+244",sublabel:"Angola"},{value:"+245",label:"+245",sublabel:"Guinea-Bisau"},{value:"+246",label:"+246",sublabel:"Territorio Britanico del Oceano Indico"},{value:"+248",label:"+248",sublabel:"Seychelles"},{value:"+249",label:"+249",sublabel:"Sudan"},{value:"+250",label:"+250",sublabel:"Ruanda"},{value:"+251",label:"+251",sublabel:"Etiopia"},{value:"+252",label:"+252",sublabel:"Somalia"},{value:"+253",label:"+253",sublabel:"Yibuti"},{value:"+254",label:"+254",sublabel:"Kenia"},{value:"+255",label:"+255",sublabel:"Tanzania"},{value:"+256",label:"+256",sublabel:"Uganda"},{value:"+257",label:"+257",sublabel:"Burundi"},{value:"+258",label:"+258",sublabel:"Mozambique"},{value:"+260",label:"+260",sublabel:"Zambia"},{value:"+261",label:"+261",sublabel:"Madagascar"},{value:"+262",label:"+262",sublabel:"Reunion, Mayotte"},{value:"+263",label:"+263",sublabel:"Zimbabue"},{value:"+264",label:"+264",sublabel:"Namibia"},{value:"+265",label:"+265",sublabel:"Malaui"},{value:"+266",label:"+266",sublabel:"Lesoto"},{value:"+267",label:"+267",sublabel:"Botsuana"},{value:"+268",label:"+268",sublabel:"Esuatini"},{value:"+269",label:"+269",sublabel:"Comoras"},{value:"+290",label:"+290",sublabel:"Santa Elena"},{value:"+291",label:"+291",sublabel:"Eritrea"},{value:"+297",label:"+297",sublabel:"Aruba"},{value:"+298",label:"+298",sublabel:"Islas Feroe"},{value:"+299",label:"+299",sublabel:"Groenlandia"},{value:"+350",label:"+350",sublabel:"Gibraltar"},{value:"+351",label:"+351",sublabel:"Portugal"},{value:"+352",label:"+352",sublabel:"Luxemburgo"},{value:"+353",label:"+353",sublabel:"Irlanda"},{value:"+354",label:"+354",sublabel:"Islandia"},{value:"+355",label:"+355",sublabel:"Albania"},{value:"+356",label:"+356",sublabel:"Malta"},{value:"+357",label:"+357",sublabel:"Chipre"},{value:"+358",label:"+358",sublabel:"Finlandia, Aland"},{value:"+359",label:"+359",sublabel:"Bulgaria"},{value:"+370",label:"+370",sublabel:"Lituania"},{value:"+371",label:"+371",sublabel:"Letonia"},{value:"+372",label:"+372",sublabel:"Estonia"},{value:"+373",label:"+373",sublabel:"Moldavia"},{value:"+374",label:"+374",sublabel:"Armenia"},{value:"+375",label:"+375",sublabel:"Bielorrusia"},{value:"+376",label:"+376",sublabel:"Andorra"},{value:"+377",label:"+377",sublabel:"Monaco"},{value:"+378",label:"+378",sublabel:"San Marino"},{value:"+380",label:"+380",sublabel:"Ucrania"},{value:"+381",label:"+381",sublabel:"Serbia"},{value:"+382",label:"+382",sublabel:"Montenegro"},{value:"+383",label:"+383",sublabel:"Kosovo"},{value:"+385",label:"+385",sublabel:"Croacia"},{value:"+386",label:"+386",sublabel:"Eslovenia"},{value:"+387",label:"+387",sublabel:"Bosnia y Herzegovina"},{value:"+389",label:"+389",sublabel:"Macedonia del Norte"},{value:"+420",label:"+420",sublabel:"Chequia"},{value:"+421",label:"+421",sublabel:"Eslovaquia"},{value:"+423",label:"+423",sublabel:"Liechtenstein"},{value:"+500",label:"+500",sublabel:"Islas Malvinas"},{value:"+501",label:"+501",sublabel:"Belice"},{value:"+502",label:"+502",sublabel:"Guatemala"},{value:"+503",label:"+503",sublabel:"El Salvador"},{value:"+504",label:"+504",sublabel:"Honduras"},{value:"+505",label:"+505",sublabel:"Nicaragua"},{value:"+506",label:"+506",sublabel:"Costa Rica"},{value:"+507",label:"+507",sublabel:"Panama"},{value:"+508",label:"+508",sublabel:"San Pedro y Miquelon"},{value:"+509",label:"+509",sublabel:"Haiti"},{value:"+590",label:"+590",sublabel:"Guadalupe, San Bartolome"},{value:"+591",label:"+591",sublabel:"Bolivia"},{value:"+592",label:"+592",sublabel:"Guyana"},{value:"+593",label:"+593",sublabel:"Ecuador"},{value:"+594",label:"+594",sublabel:"Guayana Francesa"},{value:"+595",label:"+595",sublabel:"Paraguay"},{value:"+596",label:"+596",sublabel:"Martinica"},{value:"+597",label:"+597",sublabel:"Surinam"},{value:"+598",label:"+598",sublabel:"Uruguay"},{value:"+599",label:"+599",sublabel:"Caribe Neerlandes, Curazao"},{value:"+670",label:"+670",sublabel:"Timor Oriental"},{value:"+672",label:"+672",sublabel:"Antartida, Isla Norfolk"},{value:"+673",label:"+673",sublabel:"Brunei"},{value:"+674",label:"+674",sublabel:"Nauru"},{value:"+675",label:"+675",sublabel:"Papua Nueva Guinea"},{value:"+676",label:"+676",sublabel:"Tonga"},{value:"+677",label:"+677",sublabel:"Islas Salomon"},{value:"+678",label:"+678",sublabel:"Vanuatu"},{value:"+679",label:"+679",sublabel:"Fiyi"},{value:"+680",label:"+680",sublabel:"Palaos"},{value:"+681",label:"+681",sublabel:"Wallis y Futuna"},{value:"+682",label:"+682",sublabel:"Islas Cook"},{value:"+683",label:"+683",sublabel:"Niue"},{value:"+685",label:"+685",sublabel:"Samoa"},{value:"+686",label:"+686",sublabel:"Kiribati"},{value:"+687",label:"+687",sublabel:"Nueva Caledonia"},{value:"+688",label:"+688",sublabel:"Tuvalu"},{value:"+689",label:"+689",sublabel:"Polinesia Francesa"},{value:"+690",label:"+690",sublabel:"Tokelau"},{value:"+691",label:"+691",sublabel:"Micronesia"},{value:"+692",label:"+692",sublabel:"Islas Marshall"},{value:"+850",label:"+850",sublabel:"Corea del Norte"},{value:"+852",label:"+852",sublabel:"Hong Kong"},{value:"+853",label:"+853",sublabel:"Macao"},{value:"+855",label:"+855",sublabel:"Camboya"},{value:"+856",label:"+856",sublabel:"Laos"},{value:"+880",label:"+880",sublabel:"Banglades"},{value:"+886",label:"+886",sublabel:"Taiwan"},{value:"+960",label:"+960",sublabel:"Maldivas"},{value:"+961",label:"+961",sublabel:"Libano"},{value:"+962",label:"+962",sublabel:"Jordania"},{value:"+963",label:"+963",sublabel:"Siria"},{value:"+964",label:"+964",sublabel:"Irak"},{value:"+965",label:"+965",sublabel:"Kuwait"},{value:"+966",label:"+966",sublabel:"Arabia Saudita"},{value:"+967",label:"+967",sublabel:"Yemen"},{value:"+968",label:"+968",sublabel:"Oman"},{value:"+970",label:"+970",sublabel:"Palestina"},{value:"+971",label:"+971",sublabel:"Emiratos Arabes Unidos"},{value:"+972",label:"+972",sublabel:"Israel"},{value:"+973",label:"+973",sublabel:"Barein"},{value:"+974",label:"+974",sublabel:"Catar"},{value:"+975",label:"+975",sublabel:"Butan"},{value:"+976",label:"+976",sublabel:"Mongolia"},{value:"+977",label:"+977",sublabel:"Nepal"},{value:"+992",label:"+992",sublabel:"Tayikistan"},{value:"+993",label:"+993",sublabel:"Turkmenistan"},{value:"+994",label:"+994",sublabel:"Azerbaiyan"},{value:"+995",label:"+995",sublabel:"Georgia"},{value:"+996",label:"+996",sublabel:"Kirguistan"},{value:"+998",label:"+998",sublabel:"Uzbekistan"}];function no(r){return r==null?"":String(r)}function Gt(r){return r?r.startsWith("+")?r:`+${r}`:"+1"}function Ti(r){return typeof r=="number"?`${r}px`:r}function Ai({autoComplete:r="tel",inputMode:t="tel",validate:a=!0,invalidMessage:n="Ingresa un telefono valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:u,countryCode:f,defaultCountryCode:m="+1",onCountryCodeChange:b,allowedCountryCodes:p,countryCodeOptions:x,countryCodePlaceholder:N="Codigo",countryCodeClassName:M="",countryCodeWidth:g=84,onPhoneValueChange:C,label:B,containerClassName:A="",helperText:F,labelAction:E,className:k="",required:U,disabled:H,floatingLabel:j,showPasswordToggle:Y,nativeValidation:Q,errorTooltipLabel:L="Error de validacion",...Z}){var q;const[W,z]=o.useState(()=>no(c)),[ee,J]=o.useState(()=>Gt(m)),I=o.useMemo(()=>{const ne=x??ao,oe=p==null?void 0:p.map(Gt);return oe!=null&&oe.length?ne.filter(he=>oe.includes(he.value)):ne},[p,x]),O=((q=I[0])==null?void 0:q.value)??"+1",K=I.some(ne=>ne.value===Gt(f??ee))?Gt(f??ee):O,w=i!==void 0?no(i):W,S=`${K} ${w}`.trim(),R=a&&w.length>0&&!ja(S)?n:void 0,te=l??R,ae=!!te,ce=ae&&s!=="tooltip",ve=ae&&s!=="inline",re=ae?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",X=ne=>{const oe=ne.currentTarget.value;i===void 0&&z(oe),C==null||C(oe,{countryCode:K,nationalNumber:oe,fullNumber:`${K} ${oe}`.trim()}),u==null||u(ne)},h=ne=>{f===void 0&&J(ne),b==null||b(ne),C==null||C(w,{countryCode:ne,nationalNumber:w,fullNumber:`${ne} ${w}`.trim()})},$=ve?e.jsx(jr,{as:"span",content:te,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":L,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(Qn,{className:"h-[18px] w-[18px]"})})}):null;return e.jsxs("div",{className:`flex flex-col gap-2 ${A}`,children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e.jsx("span",{children:B}),U&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),E&&e.jsx("span",{className:"ml-auto normal-case",children:E})]}),e.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${re}`,children:[e.jsx(Er,{value:K,onChange:h,options:I,placeholder:N,disabled:H,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${M}`,style:{width:Ti(g)},height:38,padding:"0 8px 0 10px"}),e.jsx("span",{className:"h-5 w-px shrink-0 bg-[var(--border)]"}),e.jsxs("span",{className:"relative min-w-0 flex-1 self-stretch",children:[e.jsx("input",{...Z,value:i,defaultValue:c,type:"tel",inputMode:t,autoComplete:r,disabled:H,required:void 0,"aria-label":Z["aria-label"]??(typeof B=="string"?B:void 0),"aria-invalid":ae||Z["aria-invalid"],className:`h-full w-full min-w-0 bg-transparent px-2 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed disabled:opacity-60 ${ve?"pr-10":""} ${k}`,onChange:X}),$]})]}),ce?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:te}):F?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:F}):null]})}function Di({value:r,onChange:t,options:a,name:n,label:s,orientation:l="vertical",disabled:i=!1,className:c="",optionClassName:u=""}){return e.jsxs("fieldset",{className:`min-w-0 ${c}`,disabled:i,children:[s&&e.jsx("legend",{className:"mb-2 text-xs font-semibold uppercase text-[var(--text-muted)]",children:s}),e.jsx("div",{className:l==="horizontal"?"flex flex-wrap gap-2":"flex flex-col gap-2",children:a.map(f=>{const m=f.value===r,b=i||f.disabled;return e.jsxs("label",{className:`inline-flex min-w-0 items-start gap-2 rounded-lg border px-2.5 py-1.5 transition-colors ${b?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${u}`,style:{borderColor:m?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:m?"color-mix(in srgb, var(--primary) 8%, transparent)":"var(--bg-card)"},children:[e.jsxs("span",{className:"relative mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-[var(--border)] bg-[var(--bg-input)]",children:[e.jsx("input",{type:"radio",name:n,value:f.value,checked:m,disabled:b,onChange:()=>t(f.value),className:"absolute inset-0 opacity-0"}),e.jsx("span",{className:`h-2 w-2 rounded-full transition ${m?"scale-100 opacity-100":"scale-50 opacity-0"}`,style:{background:"var(--primary)"}})]}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:f.label}),f.description&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:f.description})]})]},f.value)})})]})}const oo=()=>'<button type="button" class="rich-img-del" data-action="delete-img" title="Eliminar imagen"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M9 2a1 1 0 0 0-.894.553L7.382 4H4a1 1 0 0 0 0 2v10a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V6a1 1 0 0 0 0-2h-3.382l-.724-1.447A1 1 0 0 0 11 2H9zm-1 6a1 1 0 1 1 2 0v4a1 1 0 1 1-2 0V8zm4 0a1 1 0 1 1 2 0v4a1 1 0 1 1-2 0V8z" clip-rule="evenodd"/></svg></button>',vt=r=>r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),so=r=>r.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(t,a,n)=>`${a}${n.toLocaleUpperCase()}`),Ii=r=>r.replace(/[<>]/g,"").toLowerCase(),Bi=new Set(["p","br","div","span","b","strong","i","em","u","s","strike","ul","ol","li","h1","h2","h3","h4","blockquote","a","img","hr"]),Oi=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,Hi=r=>{const t=r.indexOf("<!--StartFragment-->"),a=r.indexOf("<!--EndFragment-->");if(t!==-1&&a!==-1&&a>t)return r.slice(t+20,a);const n=r.match(/<body[^>]*>([\s\S]*)<\/body>/i);return n?n[1]:r},Kt=(r,t)=>t.test(r),Pi=r=>Kt(r,/font-weight\s*:\s*(bold|[6-9]00)/i),Fi=r=>Kt(r,/font-style\s*:\s*italic/i),zi=r=>Kt(r,/text-decoration(?:-line)?\s*:[^;]*underline/i),_i=r=>Kt(r,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),Xt=(r,t)=>{var n;if(!r.childNodes.length||r.childNodes.length===1&&((n=r.firstChild)==null?void 0:n.nodeType)===Node.ELEMENT_NODE&&r.firstChild.tagName.toLowerCase()===t)return;const a=r.ownerDocument.createElement(t);for(;r.firstChild;)a.appendChild(r.firstChild);r.appendChild(a)},Yt=r=>{const t=r.parentNode;if(!t){r.remove();return}for(;r.firstChild;)t.insertBefore(r.firstChild,r);t.removeChild(r)},ji=r=>{const t=r.getAttribute("class")??"",a=r.getAttribute("style")??"";return/mso-list/i.test(a)||/MsoListParagraph/i.test(t)||/MsoList/i.test(t)},lo=r=>{const t=r.getAttribute("style")??"",a=r.textContent??"";return/mso-level-number-format\s*:\s*(decimal|arabic|roman|alpha)/i.test(t)||/^\s*\d+[.)]\s/.test(a)||/^\s*[a-zA-Z][.)]\s/.test(a)?"ol":"ul"},Wi=r=>{const a=r.ownerDocument.createTreeWalker(r,NodeFilter.SHOW_TEXT).nextNode();if(!a||!a.textContent)return;const n=a.textContent.replace(Oi,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");n!==a.textContent&&(a.textContent=n)},qi=r=>{const t=Array.from(r.querySelectorAll("span, font, p, div, li, h1, h2, h3, h4"));t.sort((a,n)=>n.querySelectorAll("*").length-a.querySelectorAll("*").length),t.forEach(a=>{const n=a.getAttribute("style")??"";n&&(Pi(n)&&Xt(a,"strong"),Fi(n)&&Xt(a,"em"),zi(n)&&Xt(a,"u"),_i(n)&&Xt(a,"s"))})},Ui=r=>{const t=Array.from(r.querySelectorAll("p, div")).filter(ji);if(!t.length)return;let a=0;for(;a<t.length;){const n=t[a],s=lo(n),l=[n];let i=a+1;for(;i<t.length;){const f=t[i];if(lo(f)!==s)break;let m=l[l.length-1].nextSibling;for(;m&&m.nodeType===Node.TEXT_NODE&&!(m.textContent??"").trim();)m=m.nextSibling;if(m!==f)break;l.push(f),i++}const c=n.parentNode;if(!c){a=i;continue}const u=n.ownerDocument.createElement(s);c.insertBefore(u,n),l.forEach(f=>{Wi(f);const m=f.ownerDocument.createElement("li");for(;f.firstChild;)m.appendChild(f.firstChild);u.appendChild(m),f.remove()}),a=i}},Vi=r=>r==="h1"?"h2":r==="h4"||r==="h5"||r==="h6"?"h3":r==="div"?"p":r,Gi=r=>{const t=Hi(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()),qi(s),Ui(s);const l=i=>{const c=Array.from(i.childNodes);if(i.nodeType===Node.ELEMENT_NODE){const u=i,f=u.tagName.toLowerCase();if(f==="html"||f==="body"){c.forEach(l);return}if(f==="font"){Yt(u),c.forEach(l);return}if(!Bi.has(f)){Yt(u),c.forEach(l);return}const m=Vi(f);if(m!==f){const b=u.ownerDocument.createElement(m);for(;u.firstChild;)b.appendChild(u.firstChild);u.replaceWith(b),l(b);return}if(Array.from(u.attributes).forEach(b=>{const p=b.name.toLowerCase(),x=b.value;if(p.startsWith("on")||p==="style"||p==="class"){u.removeAttribute(b.name);return}if(p==="lang"||p.startsWith("data-")||p.startsWith("mso-")){u.removeAttribute(b.name);return}if((p==="href"||p==="src")&&/^\s*javascript:/i.test(x)){u.removeAttribute(b.name);return}f!=="a"&&f!=="img"&&p!=="href"&&p!=="src"&&p!=="alt"&&(["href","src","alt","target","rel"].includes(p)||u.removeAttribute(b.name))}),f==="a"){const b=u.getAttribute("href");if(!b||/^\s*#/.test(b)&&b.length<2){Yt(u),c.forEach(l);return}u.setAttribute("target","_blank"),u.setAttribute("rel","noopener noreferrer"),u.classList.add("rich-link")}if(f==="img"){const b=u.getAttribute("src")??"";if(!b||/^\s*javascript:/i.test(b)||/^file:/i.test(b)||/scheme\s*=\s*["']?file/i.test(b)){u.remove();return}u.classList.add("rich-img"),Array.from(u.attributes).forEach(p=>{["src","alt","class"].includes(p.name.toLowerCase())||u.removeAttribute(p.name)})}if(f==="span"){Yt(u),c.forEach(l);return}}c.forEach(l)};return l(s),s.querySelectorAll("p, h2, h3, li").forEach(i=>{const c=(i.textContent??"").replace(/[\u00a0\s]+/g,"").trim(),u=i.querySelector("img, hr"),f=!c&&!u&&Array.from(i.childNodes).every(m=>m.nodeType===Node.TEXT_NODE||m.nodeType===Node.ELEMENT_NODE&&m.tagName.toLowerCase()==="br");(!c&&!u||f)&&i.remove()}),s.querySelectorAll("strong, b, em, i, u, s").forEach(i=>{let c=i.nextSibling;for(;c&&c.nodeType===Node.TEXT_NODE&&!(c.textContent??"").trim();)c=c.nextSibling;if(c&&c.nodeType===Node.ELEMENT_NODE&&c.tagName===i.tagName){const u=c;for(;u.firstChild;)i.appendChild(u.firstChild);u.remove()}}),s.innerHTML.replace(/<!--[\s\S]*?-->/g,"").replace(/&nbsp;/gi," ").replace(/(<br\s*\/?>\s*){3,}/gi,"<br><br>").replace(/<p>(?:\s|<br\s*\/?>)*<\/p>/gi,"").trim()},Va=r=>vt(r).replace(/\r\n?/g,`
25
- `).split(/\n{2,}/).map(t=>`<p>${t.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),Ki=r=>new RegExp("\\p{L}","u").test(r),Ga=(r,t)=>{const a=r.trim();return!a||!Ki(a)?!1:t==="uppercase"?a===a.toLocaleUpperCase():t==="lowercase"?a===a.toLocaleLowerCase():a===so(a)},io=r=>{const t=n=>{var s,l;if(!n.closest(".rich-img-wrap")){const i=document.createElement("span");i.className="rich-img-wrap",i.contentEditable="false",(s=n.parentNode)==null||s.insertBefore(i,n),i.appendChild(n),i.insertAdjacentHTML("beforeend",oo())}(l=n.closest(".rich-img-wrap"))==null||l.classList.add("rich-img-broken")};r.querySelectorAll("img").forEach(n=>{if(!n.complete||n.naturalWidth===0){n.addEventListener("error",()=>t(n),{once:!0}),n.addEventListener("load",()=>{n.naturalWidth===0&&t(n)},{once:!0});const s=n.src;n.src="",n.src=s}});const a=n=>{const s=n.target;s.tagName==="IMG"&&t(s)};return r.addEventListener("error",a,!0),()=>r.removeEventListener("error",a,!0)};function co({value:r,onChange:t,placeholder:a="Escribe algo...",minHeight:n="80px",instanceId:s}){const l=o.useId(),i=s||l,c=o.useCallback(()=>document,[]),u=o.useRef(null),f=o.useRef(null),m=o.useRef(new Map),b=o.useRef(null),p=o.useRef(!1),x=o.useRef(r??""),N=o.useRef(t),M=o.useRef(!1),[g,C]=o.useState(()=>!r||r.trim()===""),[B,A]=o.useState(new Set),[F,E]=o.useState(null),[k,U]=o.useState(""),[H,j]=o.useState(""),[Y,Q]=o.useState(""),[L,Z]=o.useState(""),[W,z]=o.useState(!1),ee=o.useCallback(()=>p.current?f.current:u.current,[]);o.useEffect(()=>{N.current=t},[t]);const J=o.useCallback(()=>{const D=window.getSelection(),V=ee();if(!D||!V||D.rangeCount===0||D.isCollapsed)return"";const le=D.getRangeAt(0);return!V.contains(le.startContainer)||!V.contains(le.endContainer)?"":D.toString()},[ee]);o.useEffect(()=>{const D=r??"";if(M.current&&D===x.current){M.current=!1,C(!D||D.trim()==="");return}M.current=!1,x.current=D;const V=[u.current,f.current].filter(ue=>!!ue);V.forEach(ue=>{ue.innerHTML!==D&&(ue.innerHTML=D)}),C(!D||D.trim()==="");const le=V.map(ue=>io(ue));return()=>le.forEach(ue=>ue())},[r]),o.useEffect(()=>{var ue,$e;p.current=W;let D,V=0,le;if(W){const ke=u.current;ke&&(x.current=ke.innerHTML);const Ie=()=>{var Ue;const Me=f.current;if(!Me){V=requestAnimationFrame(Ie);return}Me.innerHTML!==x.current&&(Me.innerHTML=x.current),D=io(Me),C(((Ue=Me.textContent)==null?void 0:Ue.trim())===""),le=setTimeout(()=>Me.focus(),60)};V=requestAnimationFrame(Ie)}else{const ke=f.current,Ie=u.current,Me=(ke==null?void 0:ke.innerHTML)??x.current,Ue=x.current;x.current=Me,Ie&&Ie.innerHTML!==Me&&(Ie.innerHTML=Me),Me!==Ue&&N.current(Me),C((($e=(ue=ke??Ie)==null?void 0:ue.textContent)==null?void 0:$e.trim())==="")}return()=>{V&&cancelAnimationFrame(V),le&&clearTimeout(le),D==null||D()}},[W]);const I=o.useCallback(()=>{const D=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],V=new Set;D.forEach(ue=>{try{c().queryCommandState(ue)&&V.add(ue)}catch{return}});try{const ue=Ii(c().queryCommandValue("formatBlock"));ue&&V.add(`formatBlock:${ue}`)}catch{}const le=J();Ga(le,"uppercase")&&V.add("__upper"),Ga(le,"lowercase")&&V.add("__lower"),Ga(le,"capitalize")&&V.add("__cap"),A(V)},[J,c]),O=()=>{var V;const D=ee();D&&(x.current=D.innerHTML,M.current=!0,N.current(x.current),C(((V=D.textContent)==null?void 0:V.trim())===""))},K=D=>{if(!D){const V=u.current;V&&(x.current=V.innerHTML)}z(!D)},w=(D,V)=>{var le;(le=ee())==null||le.focus(),c().execCommand(D,!1,V),O(),I()},S=D=>{w("formatBlock",D)},R=()=>{var D;(D=ee())==null||D.focus(),c().execCommand("insertHTML",!1,"<hr><p><br></p>"),O(),I()},te=()=>{const D=window.getSelection();D&&D.rangeCount>0&&(b.current=D.getRangeAt(0).cloneRange())},ae=()=>{const D=window.getSelection();D&&b.current&&(D.removeAllRanges(),D.addRange(b.current))},ce=D=>{if(te(),D==="link"){const V=window.getSelection();j(V&&!V.isCollapsed?V.toString():""),U("")}D==="image"&&(Q(""),Z("")),E(D)},ve=()=>{var ue;if(!k.trim())return;ae(),(ue=ee())==null||ue.focus();const D=window.getSelection(),le=(D&&!D.isCollapsed?D.toString():"")||H.trim()||k.trim();c().execCommand("insertHTML",!1,`<a href="${vt(k.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${vt(le)}</a>`),O(),E(null)},re=(D,V="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${vt(D)}" alt="${vt(V)}" class="rich-img" />${oo()}</span>`,X=()=>{var D;Y.trim()&&(ae(),(D=ee())==null||D.focus(),c().execCommand("insertHTML",!1,re(Y.trim(),L.trim())),O(),E(null))},h=(D,V=1200,le=1200,ue=.72)=>new Promise(($e,ke)=>{const Ie=new FileReader;Ie.onerror=ke,Ie.onload=Me=>{var sa;const Ue=(sa=Me.target)==null?void 0:sa.result,Be=new Image;Be.onerror=ke,Be.onload=()=>{let{width:Ke,height:Fe}=Be;if(Ke>V||Fe>le){const ir=Math.min(V/Ke,le/Fe);Ke=Math.round(Ke*ir),Fe=Math.round(Fe*ir)}const Xe=document.createElement("canvas");Xe.width=Ke,Xe.height=Fe;const Tr=Xe.getContext("2d");if(!Tr){$e(Ue);return}Tr.drawImage(Be,0,0,Ke,Fe),$e(Xe.toDataURL("image/jpeg",ue))},Be.src=Ue},Ie.readAsDataURL(D)}),$=D=>{D.focus();const V=window.getSelection();if(!V||V.rangeCount===0||!D.contains(V.anchorNode)){const le=document.createRange();le.selectNodeContents(D),le.collapse(!1),V==null||V.removeAllRanges(),V==null||V.addRange(le)}},q=o.useRef(()=>{});q.current=D=>{const V=ee();V&&($(V),c().execCommand("insertHTML",!1,D),V.querySelectorAll("p").forEach(le=>{!(le.textContent??"").replace(/[\u00a0\s]+/g,"")&&!le.querySelector("img, hr")&&le.remove()}),O(),I())};const ne=o.useRef(h);ne.current=h;const oe=o.useRef(re);oe.current=re;const he=o.useCallback(D=>{if(!D||m.current.has(D))return;const V=le=>{const ue=le.clipboardData;if(!ue)return;const $e=ue.getData("text/html"),ke=ue.getData("text/plain");if($e||ke){le.preventDefault(),le.stopPropagation();try{const Be=$e?Gi($e):Va(ke);if(!Be){ke&&q.current(Va(ke));return}q.current(Be)}catch{ke&&q.current(Va(ke))}return}const Me=Array.from(ue.items).find(Be=>Be.type.startsWith("image/"));if(!Me)return;le.preventDefault(),le.stopPropagation();const Ue=Me.getAsFile();Ue&&ne.current(Ue).then(Be=>{q.current(oe.current(Be,"imagen"))})};D.addEventListener("paste",V,!0),m.current.set(D,()=>{D.removeEventListener("paste",V,!0),m.current.delete(D)})},[]),_e=o.useCallback(D=>{var le;const V=u.current;V&&V!==D&&((le=m.current.get(V))==null||le()),u.current=D,D&&he(D)},[he]),Ge=o.useCallback(D=>{var le;const V=f.current;V&&V!==D&&((le=m.current.get(V))==null||le()),f.current=D,D&&he(D)},[he]);o.useEffect(()=>{const D=m.current;return()=>{D.forEach(V=>V()),D.clear()}},[]);const xe=D=>{const V=window.getSelection(),le=ee();if(!V||!le||V.rangeCount===0||V.isCollapsed)return;const ue=V.getRangeAt(0);if(!le.contains(ue.startContainer)||!le.contains(ue.endContainer))return;const $e=ue.toString();if(!$e)return;let ke=$e;D==="uppercase"?ke=$e.toLocaleUpperCase():D==="lowercase"?ke=$e.toLocaleLowerCase():ke=so($e),ue.deleteContents();const Ie=document.createTextNode(ke);ue.insertNode(Ie);const Me=document.createRange();Me.setStart(Ie,0),Me.setEnd(Ie,ke.length),V.removeAllRanges(),V.addRange(Me),b.current=Me.cloneRange(),O(),I()},Ee=()=>{te(),I()},Ae=()=>{O(),I()},wr=()=>{requestAnimationFrame(()=>{var D;(D=ee())==null||D.focus()})},br=D=>{var V,le;if((D.metaKey||D.ctrlKey)&&D.key==="Enter"){if(D.preventDefault(),D.stopPropagation(),D.repeat)return;(V=ee())==null||V.focus(),c().execCommand("insertLineBreak",!1)||c().execCommand("insertHTML",!1,"<br>"),O(),I();return}if(D.key==="Tab"){D.preventDefault(),(le=ee())==null||le.focus(),c().execCommand("insertText",!1,"    "),O(),I();return}if(D.key==="Escape"){if(F){E(null);return}if(p.current){z(!1);return}}F||(D.ctrlKey||D.metaKey)&&(D.key==="b"&&(D.preventDefault(),w("bold")),D.key==="i"&&(D.preventDefault(),w("italic")),D.key==="u"&&(D.preventDefault(),w("underline")),D.key==="k"&&(D.preventDefault(),ce("link")))},We=()=>e.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),se=(D,V,le,ue,$e)=>{const ke=$e??(B.has(le)||le==="__link"&&F==="link"||le==="__img"&&F==="image");return e.jsx("button",{type:"button",title:V,tabIndex:-1,onFocus:wr,onMouseDown:Ie=>{Ie.preventDefault(),ue?ue():w(le)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:ke?"var(--primary)":"var(--text-secondary)",background:ke?"rgba(59,130,246,0.12)":"transparent"},children:D},le)},Ze=D=>{const V=D.target;if(V.closest("[data-action='delete-img']")){D.preventDefault();const le=V.closest(".rich-img-wrap");le&&(le.remove(),O())}},lr=D=>e.jsxs(e.Fragment,{children:[F==="link"&&e.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:D},children:[e.jsx("input",{autoFocus:!0,type:"url",value:k,onChange:V=>U(V.target.value),onKeyDown:V=>{V.key==="Enter"&&(V.preventDefault(),ve()),V.key==="Escape"&&E(null)},placeholder:"https://...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),e.jsx("input",{type:"text",value:H,onChange:V=>j(V.target.value),onKeyDown:V=>{V.key==="Enter"&&(V.preventDefault(),ve()),V.key==="Escape"&&E(null)},placeholder:"Texto (opcional)",className:"w-32 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),e.jsx("button",{type:"button",onClick:ve,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),e.jsx("button",{type:"button",onClick:()=>E(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),F==="image"&&e.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:D},children:[e.jsx("input",{autoFocus:!0,type:"url",value:Y,onChange:V=>Q(V.target.value),onKeyDown:V=>{V.key==="Enter"&&(V.preventDefault(),X()),V.key==="Escape"&&E(null)},placeholder:"URL de la imagen...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),e.jsx("input",{type:"text",value:L,onChange:V=>Z(V.target.value),onKeyDown:V=>{V.key==="Enter"&&(V.preventDefault(),X()),V.key==="Escape"&&E(null)},placeholder:"Texto alt",className:"w-28 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),e.jsx("button",{type:"button",onClick: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:()=>E(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),de=(D,V)=>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:V},children:[se(e.jsx(T.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),se(e.jsx(T.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),We(),se(e.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>S("p"),B.has("formatBlock:p")||B.has("formatBlock:div")),se(e.jsx(T.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>S("h2"),B.has("formatBlock:h2")),se(e.jsx(T.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>S("h3"),B.has("formatBlock:h3")),se(e.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>S("blockquote"),B.has("formatBlock:blockquote")),We(),se(e.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),se(e.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),se(e.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),se(e.jsx("s",{children:"S"}),"Tachado","strikeThrough"),We(),se(e.jsx(T.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),se(e.jsx(T.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),se(e.jsx(T.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),se(e.jsx(T.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),We(),se(e.jsx(T.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),se(e.jsx(T.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),se(e.jsx(T.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),se(e.jsx(T.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),We(),se(e.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>xe("uppercase")),se(e.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>xe("lowercase")),se(e.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>xe("capitalize")),We(),se(e.jsx(T.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>ce("link")),se(e.jsx(T.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),se(e.jsx(T.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>ce("image")),se(e.jsx(T.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",R),We(),se(e.jsx(T.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),se(e.jsx(T.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>S("p")),We(),e.jsx("button",{type:"button",title:D?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:wr,onMouseDown:le=>{le.preventDefault(),K(D)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:D?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:_e,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:Ae,onKeyDown:br,onKeyUp:Ee,onSelect:Ee,onMouseUp:Ee,onMouseDown:Ze,"data-placeholder":a,className:`rich-editor px-3 py-2 text-sm focus:outline-none${g?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:n,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),lr("var(--bg-input)"),de(!1,"var(--bg-input)")]}),e.jsxs(Ha,{open:W,onClose:()=>z(!1),title:"Modo de enfoque",subtitle:"Esc para salir",maxWidth:"920px",bodyClassName:"flex min-h-0 flex-col p-0",panelClassName:"h-[88vh]",backdropClassName:"bg-black/50 backdrop-blur-[2px]",children:[e.jsx("div",{ref:Ge,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:Ae,onKeyDown:br,onKeyUp:Ee,onSelect:Ee,onMouseUp:Ee,onMouseDown:Ze,"data-placeholder":a,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${g?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),lr("var(--bg-input)"),de(!0,"var(--bg-input)")]})]})}const uo="[a-zA-Z0-9._@-]+",Ka=new RegExp(`@(${uo})`,"g"),Xi=/[a-zA-Z0-9._@-]/;function Xa(r,t){if(t<0||t>r.length)return null;for(let a=t-1;a>=0;a-=1){if(r[a]!=="@"){const s=r[a]??"";if(s===" "||s===`
26
- `||s===" "||s==="("||!Xi.test(s))return null;continue}if(a>0){const s=r[a-1]??"";if(s!==" "&&s!==`
27
- `&&s!==" "&&s!=="(")continue}const n=r.slice(a+1,t);return n.length>0&&!new RegExp(`^${uo}$`).test(n)?null:{query:n,triggerIndex:a,caretIndex:t}}return null}function Ya(r){return r.toLowerCase().trim()}function fo(r){return r?r.replace(/<style[^>]*>[\s\S]*?<\/style>/gi," ").replace(/<script[^>]*>[\s\S]*?<\/script>/gi," ").replace(/<br\s*\/?>/gi,`
23
+ </body></html>`,ie=window.open("","_blank");ie&&(ie.document.write(K),ie.document.close())}const Ta=()=>!br||!At?null:Je.createPortal(e.jsxs("div",{ref:cn,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...zd,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:()=>{mu(),fa(!1)},children:[e.jsx(A.HiTableCells,{className:"h-4 w-4 shrink-0 text-emerald-500"}),"Descargar CSV / Excel"]}),e.jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},onClick:()=>{hu(),fa(!1)},children:[e.jsx(A.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),La=()=>{const u=te&&pr.trim().length>0,v=Ge!=null&&Ge.length?Ge:u?[{key:"bql",label:"BQL",value:pr}]:[],F=Oe.filter(N=>{const K=N.trim();return K?!new Set(Lt.split(`
24
+ `).map(fe=>fe.trim()).filter(Boolean)).has(K):!1}).slice(0,8);return!y&&fn===0&&!te&&!br?null:e.jsxs("div",{className:"relative flex min-h-9 flex-wrap items-center justify-between gap-2 border-b rounded-t-lg px-2 py-1",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[fn>0&&e.jsxs("button",{type:"button",onClick:Qd,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-card)]",children:[e.jsx(A.HiXMark,{className:"h-3.5 w-3.5"}),fn," filtros"]}),te&&e.jsxs("div",{ref:sn,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>{if(mr){Dr(!1);return}ya(),Dr(!0)},className:"inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border px-2 text-xs font-bold transition-colors",style:{background:mr?"var(--primary)":u?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:mr||u?"var(--primary)":"var(--border)",color:mr?"var(--primary-fg)":"var(--primary)"},"aria-expanded":mr,title:"Abrir filtros BQL",children:[e.jsx(A.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",u&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),mr?e.jsx(A.HiChevronUp,{className:"h-3.5 w-3.5"}):e.jsx(A.HiChevronDown,{className:"h-3.5 w-3.5"})]}),e.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:j}),v.length>0&&e.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[v.slice(0,3).map(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)),v.length>3&&e.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",v.length-3]})]}),u&&e.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:gs,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)]",children:e.jsx(A.HiXMark,{className:"h-4 w-4"})}),mr&&Je.createPortal(e.jsxs("div",{ref:os,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...Od,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:[ne.map(N=>e.jsxs("button",{type:"button",onMouseDown:K=>{K.preventDefault(),K.stopPropagation()},onClick:K=>{K.preventDefault(),K.stopPropagation(),xa(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)),he.length>0&&e.jsxs("button",{type:"button",onClick:()=>Qr(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":as,children:[e.jsx(A.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),$t.length>0&&e.jsxs("button",{type:"button",onClick:()=>Jr(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":ns,children:[e.jsx(A.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]})]}),e.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-input)",border:`1.5px solid ${xe?"var(--danger)":u?"var(--primary)":"var(--border)"}`},children:[e.jsx("textarea",{ref:ln,value:Lt,rows:3,onChange:N=>pn(N.target.value,N.target),onKeyDown:N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),hs(Lt)),N.key==="Escape"&&Dr(!1)},placeholder:ae,autoComplete:"off",spellCheck:!1,className:"block w-full px-4 py-3 text-sm outline-none",style:{background:"var(--bg-input)",color:"var(--text-main)",border:"none",fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace",lineHeight:1.6,maxHeight:180,minHeight:88,overflowY:"auto",resize:"vertical"}}),F.length>0&&e.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:F.map(N=>e.jsx("button",{type:"button",onMouseDown:K=>{K.preventDefault(),K.stopPropagation()},onClick:K=>{K.preventDefault(),K.stopPropagation(),xa(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:xe?"var(--danger)":"var(--text-muted)"},children:xe??(u?`${v.length||1} filtro${(v.length||1)===1?"":"s"} activo${(v.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),v.map(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))]}),ns&&$t.length>0&&e.jsxs("div",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-input)]",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-3 py-2",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-semibold text-[var(--text-secondary)]",children:[e.jsx(A.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),e.jsxs("button",{type:"button",onClick:()=>{Rr([]),Jr(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[e.jsx(A.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),$t.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:K=>{K.preventDefault(),K.stopPropagation()},onClick:K=>{K.preventDefault(),K.stopPropagation(),xa(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:()=>Rr(K=>K.filter(ie=>ie!==N)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx(A.HiXMark,{className:"h-3.5 w-3.5"})})]},N))]}),as&&he.length>0&&e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:he.map(N=>e.jsxs("button",{type:"button",onMouseDown:K=>{K.preventDefault(),K.stopPropagation()},onClick:K=>{K.preventDefault(),K.stopPropagation(),xa(N.bql),Qr(!1)},className:"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-2 text-left transition-colors hover:border-[var(--primary)]",children:[e.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children: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:[u&&e.jsxs("button",{type:"button",onClick:gs,className:"inline-flex h-8 items-center gap-1 rounded-md px-2.5 text-xs font-medium text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]",children:[e.jsx(A.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),e.jsxs("button",{type:"button",onClick:()=>hs(Lt),className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-[var(--primary)] px-4 text-xs font-semibold text-[var(--primary-fg)] transition-opacity hover:opacity-90",children:[e.jsx(A.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),br&&e.jsx("button",{ref:ba,type:"button","aria-haspopup":"menu","aria-expanded":At,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var K;const N=(K=ba.current)==null?void 0:K.getBoundingClientRect();N&&_d({top:N.bottom+4,right:window.innerWidth-N.right}),fa(ie=>!ie)},className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] ${At?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:e.jsx(A.HiArrowDownTray,{className:"h-4 w-4"})}),y&&e.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Xe&&ir==="visibility","aria-label":ve,title:ve,onClick:N=>xs(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)] ${Xe&&ir==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:e.jsx(A.HiCog6Tooth,{className:"h-4 w-4"})})]})},As=()=>{if(!du)return null;const u=Hl(je,vn);return e.jsxs("div",{"aria-busy":n,className:`grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 rounded-b-xl border-t text-xs select-none ${$?"px-2 py-0.5":"px-3 py-1"}`,style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:Fr===0?"0 filas":`${uu}–${fu} de ${Fr}`}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),e.jsx(Er,{value:String(ur),onChange:v=>bu(Number(v)),options:ws.map(v=>({value:String(v),label:String(v)})),placeholder:"Filas",searchable:!1,disabled:n,height:W,padding:Y,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:H}})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[e.jsx("button",{disabled:n||je<=1,onClick:()=>xn(je-1),onMouseEnter:v=>{v.currentTarget.disabled||(v.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",v.currentTarget.style.color="var(--primary)")},onMouseLeave:v=>{v.currentTarget.style.background="transparent",v.currentTarget.style.color="var(--text-muted)"},className:"cursor-pointer rounded p-0.5 transition-colors disabled:cursor-not-allowed disabled:opacity-30",style:{background:"transparent",color:"var(--text-muted)"},children:e.jsx(A.HiChevronLeft,{className:"h-3.5 w-3.5"})}),u.map((v,F)=>v==="..."?e.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${F}`):e.jsx("button",{disabled:n,onClick:()=>xn(v),onMouseEnter:N=>{N.currentTarget.disabled||v===je||(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=v===je?"var(--primary)":"transparent",N.currentTarget.style.color=v===je?"var(--primary-fg)":"var(--text-muted)"},className:"h-5 w-5 cursor-pointer rounded text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-60",style:{background:v===je?"var(--primary)":"transparent",color:v===je?"var(--primary-fg)":"var(--text-muted)"},children:v},v)),e.jsx("button",{disabled:n||je>=vn,onClick:()=>xn(je+1),onMouseEnter:v=>{v.currentTarget.disabled||(v.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",v.currentTarget.style.color="var(--primary)")},onMouseLeave:v=>{v.currentTarget.style.background="transparent",v.currentTarget.style.color="var(--text-muted)"},className:"cursor-pointer rounded p-0.5 transition-colors disabled:cursor-not-allowed disabled:opacity-30",style:{background:"transparent",color:"var(--text-muted)"},children:e.jsx(A.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{"aria-hidden":"true"})]})},gu=()=>e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ka},children:[Ea(),Ta(),La(),e.jsx("div",{ref:Nr,className:"min-w-0 max-w-full overflow-hidden",children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:It,minWidth:Sa},children:[e.jsx("div",{role:"rowgroup",style:E?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Ca()}),e.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,s)}).map((u,v)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:lt,borderBottom:`1px solid ${Ce}`},children:[fr&&e.jsx("div",{role:"cell",className:`${$?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Ce}`,borderRight:`1px solid ${Ce}`}},"select-cell"),nr.map((F,N)=>e.jsx("div",{role:"cell",className:$?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${Ce}`,borderRight:`1px solid ${Ce}`},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${cs(v,N)}%`,minWidth:32}})},F.key))]},v))})]})})]}),wn="min-w-0 max-w-full overflow-hidden";return _&&Ze&&!le?e.jsx(Pt,{rows:s,columns:Math.max(4,nr.length||7)}):!n&&t.length===0&&!dn?gu():n&&t.length===0?e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ka},children:[Ea(),Ta(),La(),e.jsx("div",{ref:Nr,className:wn,children:e.jsx(kn.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:us,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:It,minWidth:Sa},children:[e.jsx("div",{role:"rowgroup",style:E?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Ca()}),e.jsx("div",{role:"rowgroup",children:Array.from({length:s}).map((u,v)=>e.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:lt,borderBottom:`1px solid ${Ce}`},children:[fr&&e.jsx("div",{role:"cell",className:`${$?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Ce}`,borderRight:`1px solid ${Ce}`}},"select-cell"),nr.map((F,N)=>{const K=re&&!un&&N===0;return e.jsx("div",{role:"cell","data-dt-column-key":F.key,className:$?"px-2 py-1.5":"px-3 py-2",style:K?{position:"sticky",left:gn,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Ce}`,borderRight:`1px solid ${Ce}`}:{borderBottom:`1px solid ${Ce}`,borderRight:`1px solid ${Ce}`},children:e.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${cs(v,N)}%`,minWidth:32}})},F.key)})]},v))})]})})}),As()]}):!n&&t.length===0?e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ka},children:[Ea(),Ta(),La(),e.jsx("div",{ref:Nr,className:wn,children:e.jsx("div",{role:"table",className:"text-sm",style:{width:It,minWidth:Sa},children:e.jsx("div",{role:"rowgroup",style:E?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Ca()})})}),e.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-3 border-t px-6 py-12 text-center",style:{borderColor:Ce,background:"linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 58%, transparent), var(--bg-card))"},children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full border",style:{borderColor:"color-mix(in srgb, var(--primary) 24%, var(--border))",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-card))",color:"var(--primary)"},children:l??e.jsx(A.HiMagnifyingGlass,{className:"h-5 w-5"})}),e.jsx("p",{className:"max-w-sm text-sm font-medium",style:{color:"var(--text-main)"},children:i}),e.jsx("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Ajusta la busqueda o cambia los filtros para ver mas informacion."})]})]}):e.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ka},children:[Ea(),Ta(),La(),e.jsx("div",{ref:Nr,className:wn,children:e.jsx(kn.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:us,maxWidth:"100%"},defer:!0,children:e.jsxs("div",{role:"table",className:"text-sm",style:{width:It,minWidth:Sa},children:[e.jsx("div",{role:"rowgroup",style:E?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Ca()}),e.jsx("div",{role:"rowgroup",children:ks.map((u,v)=>{const F=a(u),N=Ts(z==null?void 0:z(u)),K=v>0?Ts(z==null?void 0:z(ks[v-1])):null,ie=N&&N.key!==(K==null?void 0:K.key),fe=fr&&M.has(F),ye=ot?(b==null?void 0:b(u))??!0:!1,_e=ye&&Ns.has(F),Fe=!!d||k&&ye,we=fe&&O?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":v%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return e.jsxs(o.Fragment,{children:[ie&&e.jsx("div",{role:"row",className:`grid ${N.className??""}`,style:{gridTemplateColumns:lt},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 ${Ce}`,borderRight:`1px solid ${Ce}`},children:e.jsx("div",{className:"flex min-w-0 items-center justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-xs font-semibold uppercase tracking-wider text-[var(--text-main)]",children: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:Fe?Se=>{const Ne=Se.target;if(!(Ne!=null&&Ne.closest('[data-dt-disable-row-click="true"]'))){if(k&&ye){Ss(F);return}d==null||d(u)}}:void 0,className:`grid transition-colors ${Fe?"cursor-pointer":""} ${D?D(u):""}`,style:{gridTemplateColumns:lt,"--dt-row-bg":we,"--dt-sticky-bg":we,background:"var(--dt-row-bg)",borderBottom:`1px solid ${Ce}`},onMouseEnter:Se=>{fe||(Se.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),Se.currentTarget.style.setProperty("--dt-sticky-bg",pu))},onMouseLeave:Se=>{Se.currentTarget.style.setProperty("--dt-row-bg",we),Se.currentTarget.style.setProperty("--dt-sticky-bg",we)},children:[ot&&e.jsx("div",{role:"cell",className:`${$?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${Ce}`,borderRight:`1px solid ${Ce}`},"data-dt-disable-row-click":"true",children:ye&&e.jsx("button",{type:"button","aria-label":_e?"Contraer fila":"Desplegar fila","aria-expanded":_e,onClick:Se=>{Se.stopPropagation(),Ss(F)},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]",children:_e?e.jsx(A.HiChevronDown,{className:"h-4 w-4"}):e.jsx(A.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:re?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${Ce}`}:{borderBottom:`1px solid ${Ce}`,borderRight:`1px solid ${Ce}`},onClick:Se=>{Se.stopPropagation(),g(F)},children:e.jsx(Ft,{size:"sm",checked:fe,"aria-label":"Seleccionar fila",containerClassName:"items-center",className:"cursor-pointer",onClick:Se=>Se.stopPropagation(),onChange:()=>g(F)})}),nr.map((Se,Ne)=>{const qe=re&&!un&&Ne===0,be=Mr(Se);return e.jsx("div",{role:"cell","data-dt-column-key":Se.key,"data-dt-disable-row-click":Se.disableRowClick||be?"true":void 0,className:`${be?"px-2 py-1.5 text-center":`${$?"px-2 py-1.5":"px-3 py-2"} ${Cs(Se.align)}`} ${$l} ${Se.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...qe?{position:"sticky",left:gn,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Ce}`,borderRight:`1px solid ${Ce}`}:{borderBottom:`1px solid ${Ce}`,borderRight:`1px solid ${Ce}`}},children:e.jsx(Wn,{children:e.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:Se.cell(u)})})},Se.key)})]}),_e&&f&&e.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:lt},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 ${Ce}`},children:f(u)})})]},F)})})]})})}),As()]})}const zl={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 _l(r,t){if(t.minLength!==void 0&&r.length<t.minLength)return t.message??`Mínimo ${t.minLength} caracteres`;if(t.maxLength!==void 0&&r.length>t.maxLength)return t.message??`Máximo ${t.maxLength} caracteres`;if(!r)return null;if(t.preset){const a=zl[t.preset];if(!a.pattern.test(r))return t.message??a.message}return t.pattern&&!t.pattern.test(r)?t.message??"Formato inválido":null}const jl=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function Wl({initialValue:r,type:t,mask:a,onCommit:n,onCancel:s}){const[l,i]=o.useState(r),c=o.useRef(null),d=(a==null?void 0:a.preset)==="date",f=d?"date":t==="number"?"number":"text";return o.useEffect(()=>{var b,p;(b=c.current)==null||b.focus(),d||(p=c.current)==null||p.select()},[d]),e.jsx("input",{ref:c,type:f,value:l,maxLength:a==null?void 0:a.maxLength,onChange:b=>i(b.target.value),onBlur:()=>s(),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),n(l)),b.key==="Escape"&&(b.preventDefault(),s()),(a==null?void 0:a.preset)==="integer"&&!b.ctrlKey&&!b.metaKey&&!jl.has(b.key)&&!/^[\d-]$/.test(b.key)&&b.preventDefault()},onClick:b=>b.stopPropagation(),className:"w-full min-w-0 border-0 bg-transparent p-0 text-sm text-[var(--text-main)] outline-none"})}function ql({initialValue:r,options:t,loading:a,onCommit:n,onCancel:s}){const l=o.useRef(null);return o.useEffect(()=>{if(a)return;const i=setTimeout(()=>{var c,d;(d=(c=l.current)==null?void 0:c.querySelector("button"))==null||d.click()},0);return()=>clearTimeout(i)},[a]),e.jsx("div",{ref:l,className:"w-full",tabIndex:-1,onKeyDown:i=>{i.key==="Escape"&&(i.stopPropagation(),s())},children:e.jsx(Er,{value:r,onChange:i=>{n(i)},options:t,disabled:a,placeholder:a?"Cargando…":"Seleccionar…",triggerVariant:"ghost",height:30,padding:"0 6px",minOptionsForSearch:1,className:"w-full"})})}const Ul={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},_a={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function Vl({columns:r,data:t,getRowId:a,onCellUpdate:n,readOnly:s=!1,...l}){const[i,c]=o.useState(t),d=o.useRef(null);o.useEffect(()=>{d.current||c(t)},[t]);const[f,b]=o.useState(null);d.current=f;const[p,m]=o.useState(null),w=o.useRef(null);w.current=p;const[k,M]=o.useState({}),[g,C]=o.useState(null),O=o.useRef(null);O.current=g;const[D,z]=o.useState({}),[E,S]=o.useState({}),U=o.useRef(new Set),H=o.useRef(null);o.useEffect(()=>{var y;const x=document.activeElement;(!x||x===document.body)&&((y=H.current)==null||y.focus({preventScroll:!0}))},[]);const W=r.map(x=>{var y,V,q;return`${x.key}:${((q=(V=(y=x.editable)==null?void 0:y.select)==null?void 0:V.options)==null?void 0:q.length)??-1}`}).join("|");o.useEffect(()=>{r.forEach(x=>{var q,ee;const y=(ee=(q=x.editable)==null?void 0:q.select)==null?void 0:ee.options;if(!y)return;const V=D[x.key];(!U.current.has(x.key)||(V==null?void 0:V.length)===0&&y.length>0)&&(U.current.add(x.key),z(ce=>({...ce,[x.key]:y})))})},[W]);const Y=o.useCallback(async(x,y)=>{if(U.current.has(x))return;U.current.add(x);const{url:V,fetchOptions:q}=y.select??{};if(!(!V&&!q)){S(ee=>({...ee,[x]:!0}));try{let ee=[];if(q)ee=await q();else if(V){const ce=await fetch(V);if(!ce.ok)throw new Error("fetch failed");ee=await ce.json()}z(ce=>({...ce,[x]:ee}))}catch{z(ee=>({...ee,[x]:[]}))}finally{S(ee=>({...ee,[x]:!1}))}}},[]),Z=o.useRef(i);Z.current=i;const T=o.useRef(n);T.current=n;const J=o.useRef(a);J.current=a;const B=o.useRef(r);B.current=r;const _=o.useRef(s);_.current=s,o.useEffect(()=>{if(r.length>0&&t.length>0){const x=r.find(y=>y.selectable!==!1);x&&m({rowId:a(t[0]),colKey:x.key})}},[]),o.useEffect(()=>{if(!p)return;const x=H.current;if(!x)return;const y=x.querySelector(`[data-cell-id="${p.rowId}:${p.colKey}"]`);if(!y)return;const V=x.querySelector('[role="rowgroup"]');y.style.scrollMarginTop=`${(V==null?void 0:V.offsetHeight)??0}px`;const q=x.querySelector('[role="row"]');let ee=0;q&&q.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(ce=>{ce.style.position==="sticky"&&ce.style.left!==""&&(ee=Math.max(ee,parseFloat(ce.style.left)+ce.offsetWidth))}),y.style.scrollMarginLeft=`${ee}px`,y.scrollIntoView({block:"nearest",inline:"nearest"})},[p]);const re=o.useCallback(x=>{var ee;const y=B.current,V=new Set,q=[];(ee=H.current)==null||ee.querySelectorAll("[data-cell-id]").forEach(ce=>{const ve=ce.dataset.cellId.split(":")[0];V.has(ve)||(V.add(ve),q.push(ve))}),m(ce=>{if(!ce)return ce;const ve=y.findIndex(L=>L.key===ce.colKey),te=q.indexOf(ce.rowId);let X=ve,h=te;if(x==="up")h=Math.max(0,te-1);else if(x==="down")h=Math.min(q.length-1,te+1);else if(x==="left"){let L=ve-1;for(;L>=0&&y[L].selectable===!1;)L--;L>=0&&(X=L)}else if(x==="right"){let L=ve+1;for(;L<y.length&&y[L].selectable===!1;)L++;L<y.length&&(X=L)}return X===ve&&h===te?ce:{rowId:q[h],colKey:y[X].key}})},[]),Q=o.useCallback((x=!0)=>{const y=d.current;b(null),y&&m(y),x&&setTimeout(()=>{var V;return(V=H.current)==null?void 0:V.focus({preventScroll:!0})},0)},[]),$=o.useCallback(async(x,y,V)=>{var Ge;const q=B.current.find(xe=>xe.key===y);if(!(q!=null&&q.editable))return;const{field:ee,type:ce,mask:ve,validate:te}=q.editable,X=ce==="number"?V===""?null:Number(V):V;if(ve){const xe=_l(V,ve);if(xe){M(Ee=>({...Ee,[`${x}:${y}`]:xe}));return}}if(te){const xe=te(X);if(xe){M(Ee=>({...Ee,[`${x}:${y}`]:xe}));return}}const h=J.current,L=Z.current.find(xe=>h(xe)===x);if(!L)return;const j=L[ee];b(null),M(xe=>{const Ee={...xe};return delete Ee[`${x}:${y}`],Ee});const ae=Z.current,ne=ae.findIndex(xe=>h(xe)===x),he=ae[Math.min(ae.length-1,ne+1)];if(m({rowId:h(he),colKey:y}),setTimeout(()=>{var Ee,Ae;const xe=document.activeElement;(!xe||xe===document.body||(Ee=H.current)!=null&&Ee.contains(xe))&&((Ae=H.current)==null||Ae.focus({preventScroll:!0}))},0),String(j??"")===String(X??""))return;const Oe={...L,[ee]:X};c(xe=>xe.map(Ee=>h(Ee)===x?Oe:Ee)),C({rowId:x,colKey:y});try{await((Ge=T.current)==null?void 0:Ge.call(T,{row:L,rowId:x,field:ee,oldValue:j,newValue:X}))}catch{c(xe=>xe.map(Ee=>h(Ee)===x?L:Ee)),M(xe=>({...xe,[`${x}:${y}`]:"Error al guardar. Intenta de nuevo."}))}finally{C(null)}},[]),R=o.useCallback(x=>{if(O.current){x.preventDefault();return}if(d.current)return;const y=w.current;if(!(!y||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(x.key)))switch(x.preventDefault(),x.key){case"ArrowUp":re("up");break;case"ArrowDown":re("down");break;case"ArrowLeft":re("left");break;case"ArrowRight":re("right");break;case"Tab":re(x.shiftKey?"left":"right");break;case"Enter":{const q=B.current.find(ee=>ee.key===y.colKey);q!=null&&q.editable&&!_.current?(b(y),q.editable.type==="select"&&!U.current.has(y.colKey)&&Y(y.colKey,q.editable)):re("down");break}}},[re,Y]),oe=o.useMemo(()=>r.map(x=>{if(!x.editable||s){const V={...x};if(delete V.editable,delete V.selectable,x.selectable===!1)return{...V,disableRowClick:!0};const q=V.cell;return{...V,className:`relative ${V.className??""}`.trim(),disableRowClick:!0,cell:ee=>{const ce=a(ee),ve=(p==null?void 0:p.rowId)===ce&&(p==null?void 0:p.colKey)===x.key;return e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-cell-id":`${ce}:${x.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var te;O.current||(m({rowId:ce,colKey:x.key}),(te=H.current)==null||te.focus({preventScroll:!0}))}}),ve&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:_a}),e.jsx("span",{className:"relative z-0 pointer-events-none",children:q(ee)})]})}}}const y=x.editable;return{...x,className:`relative ${x.className??""}`.trim(),disableRowClick:!0,cell:V=>{const q=a(V),ee=x.key,ce=(f==null?void 0:f.rowId)===q&&(f==null?void 0:f.colKey)===ee,ve=(p==null?void 0:p.rowId)===q&&(p==null?void 0:p.colKey)===ee,te=k[`${q}:${ee}`],X=(g==null?void 0:g.rowId)===q&&(g==null?void 0:g.colKey)===ee,h=V[y.field],L=String(h??""),j=()=>{var ne;O.current||(m({rowId:q,colKey:ee}),b({rowId:q,colKey:ee}),(ne=H.current)==null||ne.focus({preventScroll:!0}),y.type==="select"&&!U.current.has(ee)&&Y(ee,y))};if(ce){const ne=y.type==="select"?e.jsx(ql,{initialValue:L,options:D[ee]??[],loading:E[ee]??!1,onCommit:he=>$(q,ee,he),onCancel:Q}):e.jsx(Wl,{initialValue:L,type:y.type??"text",mask:y.mask,onCommit:he=>$(q,ee,he),onCancel:Q});return e.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:Ul,onClick:he=>he.stopPropagation(),children:ne})}const ae=x.cell(V);return e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-cell-id":`${q}:${ee}`,className:`peer absolute inset-0 z-10 ${X?"cursor-wait":"cursor-pointer"}`,onClick:j}),ve&&!X&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:_a}),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:_a,children:[e.jsx("span",{className:"h-3 w-3 shrink-0 animate-spin rounded-full border-2 border-[var(--text-muted)] border-t-transparent","aria-hidden":!0}),e.jsx("span",{className:"truncate text-xs text-[var(--text-muted)]",children:"Guardando…"})]}),e.jsx("span",{className:"relative z-0 inline-flex items-center gap-1 pointer-events-none",children:te?e.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[e.jsx(A.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate text-xs",children:te})]}):e.jsx("span",{className:"truncate",children:ae})}),!X&&e.jsx(A.HiPencil,{className:"pointer-events-none absolute right-1 top-1/2 z-0 h-3 w-3 -translate-y-1/2 shrink-0 text-[var(--text-muted)] opacity-0 transition-opacity peer-hover:opacity-40"})]})}}}),[r,s,f,p,g,k,D,E,a,$,Q,Y]);return e.jsx("div",{ref:H,tabIndex:0,onKeyDown:R,onBlur:x=>{var y;(y=H.current)!=null&&y.contains(x.relatedTarget)||setTimeout(()=>{var q,ee;const V=document.activeElement;V&&((q=V.closest)!=null&&q.call(V,"[data-bonsaif-select-dropdown]"))||(ee=H.current)!=null&&ee.contains(V)||Q(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:e.jsx(qn,{...l,columns:oe,data:i,getRowId:a})})}function vt(r){return r?new Date(`${r}T12:00:00`):void 0}function Un(r){return r.toISOString().slice(0,10)}function Gl({calendarMonth:r,displayIndex:t}){const{previousMonth:a,nextMonth:n,goToMonth:s,months:l,labels:i,formatters:c}=Sn.useDayPicker(),d=!!a&&t===0,f=!!n&&t===l.length-1;return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,width:"100%",color:"var(--text-main)",marginBottom:6},children:[e.jsx("span",{style:{fontWeight:700},children:c.formatCaption(r.date)}),e.jsx("button",{type:"button","aria-label":i.labelPrevious(a),onClick:()=>a&&s(a),disabled:!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(A.HiChevronLeft,{size:16})}),e.jsx("button",{type:"button","aria-label":i.labelNext(n),onClick:()=>n&&s(n),disabled:!f,style:{height:28,width:28,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg-card)",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--text-main)",opacity:f?1:.45,cursor:f?"pointer":"not-allowed"},children:e.jsx(A.HiChevronRight,{size:16})})]})}function Kl(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Xl({startDate:r,endDate:t,onChange:a,minDate:n,viewMonth:s,numberOfMonths:l=1,showSummary:i=!0,startLabel:c="Inicio",endLabel:d="Regreso"}){const f={from:vt(r),to:vt(t)},b=vt(n),[p,m]=o.useState(vt(s||r));return o.useEffect(()=>{m(vt(s||r))},[s,r]),e.jsxs("div",{children:[e.jsx("div",{style:{borderRadius:10,overflow:"hidden",border:"1px solid var(--border)",background:"var(--bg-input)",display:"flex",justifyContent:"center",padding:"10px 8px"},children:e.jsx(Sn.DayPicker,{mode:"range",selected:f,month:p,onMonthChange:m,onSelect:w=>{const k=w!=null&&w.from?Un(w.from):r,M=w!=null&&w.to?Un(w.to):"";a({startDate:k,endDate:M})},numberOfMonths:l,hideNavigation:!0,disabled:b?{before:b}:void 0,showOutsideDays:!1,components:{MonthCaption:Gl},className:"text-sm",classNames:{root:"w-full",months:"flex gap-3 justify-center",month:"space-y-2",month_caption:"flex items-center justify-between px-1",caption_label:"capitalize",nav:"flex items-center gap-1",button_previous:"h-8 w-8 inline-flex items-center justify-center rounded-md transition-colors",button_next:"h-8 w-8 inline-flex items-center justify-center rounded-md transition-colors",month_grid:"w-full border-collapse",weekdays:"grid grid-cols-7 gap-1 mb-1",weekday:"text-[11px] font-semibold text-center",week:"grid grid-cols-7 gap-1",day:"h-9 w-9 p-0 flex items-center justify-center",day_button:"h-9 w-9 rounded-md text-sm font-medium transition-colors outline-none",selected:"font-semibold",range_start:"font-semibold",range_middle:"font-medium",range_end:"font-semibold",today:"font-bold",disabled:"opacity-40 cursor-not-allowed",hidden:"invisible"},styles:{month_caption:{color:"var(--text-main)",marginBottom:6,display:"flex",alignItems:"center",justifyContent:"space-between"},caption_label:{color:"var(--text-main)",fontWeight:700},nav:{position:"static",display:"flex",alignItems:"center",gap:6},weekday:{color:"var(--text-muted)",textTransform:"lowercase"},button_previous:{height:32,width:32,background:"var(--bg-card)",color:"var(--text-main)",border:"1px solid var(--border)"},button_next:{height:32,width:32,background:"var(--bg-card)",color:"var(--text-main)",border:"1px solid var(--border)"},day_button:{color:"var(--text-main)",borderRadius:8},chevron:{fill:"var(--text-main)"},today:{border:"1px solid color-mix(in srgb, var(--primary) 35%, transparent)"},disabled:{color:"var(--text-muted)"}},modifiersStyles:{selected:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_start:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_end:{background:"var(--primary)",color:"var(--primary-fg, #ffffff)"},range_middle:{background:"color-mix(in srgb, var(--primary) 20%, transparent)",color:"var(--text-main)"}},formatters:{formatCaption:w=>Kl(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(w)),formatWeekdayName:w=>new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(w)},labels:{labelMonthDropdown:()=>"Mes",labelYearDropdown:()=>"Año"}})}),i&&r&&e.jsxs("div",{style:{marginTop:8,fontSize:12,color:"var(--text-muted)",display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsxs("span",{children:[c,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:r})]}),t&&e.jsxs("span",{children:[d,":"," ",e.jsx("strong",{style:{color:"var(--text-main)"},children:t})]})]})]})}const Yl="bonsaif-ui:hide-tooltips";function Vn(){window.dispatchEvent(new CustomEvent(Yl))}function Zl(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function Ql({trigger:r,items:t,align:a="end",width:n=220,disabled:s=!1,className:l="",menuClassName:i="",onOpenChange:c}){const[d,f]=o.useState(!1),[b,p]=o.useState(!1),[m,w]=o.useState({}),k=o.useRef(null),M=o.useRef(null),g=o.useCallback(E=>{f(E),c==null||c(E)},[c]),C=o.useCallback(()=>{const E=k.current;if(!E)return;const S=E.getBoundingClientRect(),U=typeof n=="number"?n:S.width,H=typeof n=="number"?n:Math.max(S.width,180),W=a==="end"?Math.max(8,S.right-H):Math.min(S.left,window.innerWidth-H-8),Y=window.innerHeight-S.bottom,Z=Y<240&&S.top>Y?void 0:S.bottom+6,T=Z===void 0?window.innerHeight-S.top+6:void 0;w({position:"fixed",zIndex:9999,left:W,top:Z,bottom:T,width:Zl(typeof n=="number"?U:n)})},[a,n]);o.useEffect(()=>p(!0),[]),o.useEffect(()=>{if(!d)return;C();const E=U=>{var W,Y;const H=U.target;!((W=k.current)!=null&&W.contains(H))&&!((Y=M.current)!=null&&Y.contains(H))&&g(!1)},S=U=>{U.key==="Escape"&&g(!1)};return document.addEventListener("mousedown",E),window.addEventListener("keydown",S),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{document.removeEventListener("mousedown",E),window.removeEventListener("keydown",S),window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[d,g,C]);const O=E=>{s||(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),g(!d))},D=o.isValidElement(r)?o.cloneElement(r,{onClick:()=>{s||(Vn(),g(!d))}}):r,z=d?e.jsx("div",{ref:M,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${i}`,style:m,children:t.map(E=>e.jsxs("div",{children:[E.separatorBefore&&e.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),e.jsxs("button",{type:"button",role:"menuitem",disabled:E.disabled,onClick:()=>{var S;E.disabled||(Vn(),(S=E.onSelect)==null||S.call(E),g(!1))},className:"flex w-full min-w-0 items-start gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:E.danger?"var(--danger)":"var(--text-main)"},children:[E.icon&&e.jsx("span",{className:"mt-0.5 shrink-0",children:E.icon}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm font-medium",children:E.label}),E.description&&e.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:E.description})]})]})]},E.id))}):null;return e.jsxs("span",{ref:k,role:"button",tabIndex:s?-1:0,"aria-haspopup":"menu","aria-expanded":d,onKeyDown:O,className:`inline-flex ${s?"pointer-events-none opacity-60":""} ${l}`,children:[D,b&&z?Je.createPortal(z,document.body):null]})}const Jl=180,Gn="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Rl({open:r,onClose:t,title:a,subtitle:n,leadingIcon:s,confirmLabel:l="Guardar",onConfirm:i,loading:c=!1,confirmDisabled:d=!1,headerActions:f,bodyClassName:b="flex-1 overflow-y-auto px-6 py-5",width:p=440,hasUnsavedChanges:m=!1,unsavedChangesTitle:w="Descartar cambios",unsavedChangesDescription:k="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:M="Descartar",unsavedChangesCancelLabel:g="Seguir editando",onDiscardChanges:C,disabled:O=!1,children:D}){const[z,E]=o.useState(!1),[S,U]=o.useState(!1),[H,W]=o.useState(!1),Y=o.useCallback(()=>{U(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>W(!0))})},[]),Z=o.useCallback(()=>{W(!1),window.setTimeout(()=>U(!1),Jl)},[]),T=o.useCallback(()=>{if(m){Y();return}t()},[m,t,Y]),J=o.useCallback(()=>{W(!1),U(!1),C==null||C(),t()},[t,C]);return o.useEffect(()=>{E(!0)},[]),o.useEffect(()=>(document.body.style.overflow=r?"hidden":"",r||(W(!1),U(!1)),()=>{document.body.style.overflow=""}),[r]),o.useEffect(()=>{if(!r)return;const B=_=>{if(_.key==="Escape"){if(S){Z();return}T()}};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[Z,S,r,T]),z?Je.createPortal(e.jsxs("div",{"aria-hidden":!r,"data-bonsaif-overlay":r?"true":void 0,className:`fixed inset-0 z-[1000] flex transition-opacity duration-300 ${r?"opacity-100":"opacity-0 pointer-events-none"}`,children:[e.jsx("div",{className:`absolute inset-0 ${Gn}`,onClick:T}),e.jsxs("div",{className:`absolute inset-y-0 right-0 flex flex-col shadow-2xl transition-transform duration-300 ${r?"translate-x-0":"translate-x-full"}`,style:{width:`min(100vw, ${p}px)`,background:"var(--bg-card)",borderLeft:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 flex-shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(Pe,{variant:"icon",onClick:T,title:"Cerrar",children:e.jsx(A.HiXMark,{className:"w-5 h-5"})}),s&&e.jsx("div",{className:"flex-shrink-0",children:s}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-base font-semibold truncate",style:{color:"var(--text-main)"},children:a}),n&&e.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:n})]})]}),(f||i)&&e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[f,i&&e.jsxs(e.Fragment,{children:[e.jsx(Pe,{variant:"secondary",size:"sm",onClick:T,style:{background:"var(--bg-input)"},children:"Cancelar"}),e.jsx(Pe,{variant:"primary",size:"sm",icon:e.jsx(Bs.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:d,title:l})]})]})]}),e.jsx("div",{"data-drawer-scroll":"true",className:b,children:D})]}),O&&e.jsx("div",{className:"absolute inset-0 z-[1002] cursor-not-allowed",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 60%, transparent)",backdropFilter:"blur(2px)"}}),S&&e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":w,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[e.jsx("div",{className:`absolute inset-0 ${Gn} transition-opacity duration-200 ease-out ${H?"opacity-100":"opacity-0"}`,onClick:Z}),e.jsxs("div",{className:`relative z-10 w-full max-w-sm rounded-2xl border p-6 shadow-2xl transition-[opacity,transform] duration-200 ease-out ${H?"translate-y-0 scale-100 opacity-100":"translate-y-2 scale-[0.96] opacity-0"}`,style:{background:"var(--bg-card, #ffffff)",borderColor:"var(--border, #d8e1dc)"},children:[e.jsx(Pe,{variant:"icon",onClick:Z,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":g,children:e.jsx(A.HiXMark,{className:"h-4 w-4"})}),e.jsx("div",{className:"mb-4 flex h-11 w-11 items-center justify-center rounded-xl",style:{background:"var(--warning-bg, #fff7ed)"},children:e.jsx(A.HiExclamationTriangle,{className:"h-5 w-5",style:{color:"var(--warning, #d97706)"}})}),e.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main, #0f2f2c)"},children:w}),e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:k}),e.jsxs("div",{className:"mt-6 flex gap-2",children:[e.jsx(Pe,{variant:"secondary",onClick:Z,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:g}),e.jsx(Pe,{variant:"secondary",onClick:J,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:M})]})]})]})]}),document.body):null}const ei=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ri=/^\+?[0-9\s().-]+$/,ti=7,ai=15;function or(r){return r==null||String(r).trim()===""}function Kn(r){return typeof r=="number"?r:typeof r=="string"&&r.trim()!==""?Number(r):Number.NaN}function ja(r){return or(r)?!1:ei.test(String(r))}function Wa(r){if(or(r))return!1;const t=String(r),a=t.replace(/\D/g,"");return ri.test(t)&&a.length>=ti&&a.length<=ai}function ni(r="Este campo es requerido."){return t=>or(t)?r:void 0}function oi(r="Ingresa un correo valido."){return t=>or(t)||ja(t)?void 0:r}function si(r="Ingresa un telefono valido."){return t=>or(t)||Wa(t)?void 0:r}function li(r,t){return a=>or(a)||String(a).length>=r?void 0:t??`Debe tener al menos ${r} caracteres.`}function ii(r,t){return a=>or(a)||String(a).length<=r?void 0:t??`Debe tener ${r} caracteres o menos.`}function ci(r,t){return a=>{if(or(a))return;const n=Kn(a);return Number.isFinite(n)&&n>=r?void 0:t??`Debe ser mayor o igual a ${r}.`}}function di(r,t){return a=>{if(or(a))return;const n=Kn(a);return Number.isFinite(n)&&n<=r?void 0:t??`Debe ser menor o igual a ${r}.`}}function ui(r,t="El formato no es valido."){return a=>or(a)||r.test(String(a))?void 0:t}function fi(r,t){const a={};for(const n of Object.keys(t)){const s=t[n];if(!s)continue;const l=Array.isArray(s)?s:[s];for(const i of l){const c=i(r[n],r);if(c){a[n]=c;break}}}return{valid:Object.keys(a).length===0,errors:a}}var Xn={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Yn=o.createContext&&o.createContext(Xn),bi=["attr","size","title"];function pi(r,t){if(r==null)return{};var a,n,s=mi(r,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(r);for(n=0;n<l.length;n++)a=l[n],t.indexOf(a)===-1&&{}.propertyIsEnumerable.call(r,a)&&(s[a]=r[a])}return s}function mi(r,t){if(r==null)return{};var a={};for(var n in r)if({}.hasOwnProperty.call(r,n)){if(t.indexOf(n)!==-1)continue;a[n]=r[n]}return a}function Vt(){return Vt=Object.assign?Object.assign.bind():function(r){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(r[n]=a[n])}return r},Vt.apply(null,arguments)}function Zn(r,t){var a=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);t&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),a.push.apply(a,n)}return a}function Gt(r){for(var t=1;t<arguments.length;t++){var a=arguments[t]!=null?arguments[t]:{};t%2?Zn(Object(a),!0).forEach(function(n){hi(r,n,a[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(a)):Zn(Object(a)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(a,n))})}return r}function hi(r,t,a){return(t=gi(t))in r?Object.defineProperty(r,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[t]=a,r}function gi(r){var t=vi(r,"string");return typeof t=="symbol"?t:t+""}function vi(r,t){if(typeof r!="object"||!r)return r;var a=r[Symbol.toPrimitive];if(a!==void 0){var n=a.call(r,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function Qn(r){return r&&r.map((t,a)=>o.createElement(t.tag,Gt({key:a},t.attr),Qn(t.child)))}function qa(r){return t=>o.createElement(xi,Vt({attr:Gt({},r.attr)},t),Qn(r.child))}function xi(r){var t=a=>{var{attr:n,size:s,title:l}=r,i=pi(r,bi),c=s||a.size||"1em",d;return a.className&&(d=a.className),r.className&&(d=(d?d+" ":"")+r.className),o.createElement("svg",Vt({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,n,i,{className:d,style:Gt(Gt({color:r.color||a.color},a.style),r.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),l&&o.createElement("title",null,l),r.children)};return Yn!==void 0?o.createElement(Yn.Consumer,null,a=>t(a)):t(Xn)}function Jn(r){return qa({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z"},child:[]}]})(r)}function yi(r){return qa({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M247.31,124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57,61.26,162.88,48,128,48S61.43,61.26,36.34,86.35C17.51,105.18,9,124,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208s66.57-13.26,91.66-38.34c18.83-18.83,27.3-37.61,27.65-38.4A8,8,0,0,0,247.31,124.76ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.47,133.47,0,0,1,25,128,133.33,133.33,0,0,1,48.07,97.25C70.33,75.19,97.22,64,128,64s57.67,11.19,79.93,33.25A133.46,133.46,0,0,1,231.05,128C223.84,141.46,192.43,192,128,192Zm0-112a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Z"},child:[]}]})(r)}function wi(r){return qa({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M228,175a8,8,0,0,1-10.92-3l-19-33.2A123.23,123.23,0,0,1,162,155.46l5.87,35.22a8,8,0,0,1-6.58,9.21A8.4,8.4,0,0,1,160,200a8,8,0,0,1-7.88-6.69l-5.77-34.58a133.06,133.06,0,0,1-36.68,0l-5.77,34.58A8,8,0,0,1,96,200a8.4,8.4,0,0,1-1.32-.11,8,8,0,0,1-6.58-9.21L94,155.46a123.23,123.23,0,0,1-36.06-16.69L39,172A8,8,0,1,1,25.06,164l20-35a153.47,153.47,0,0,1-19.3-20A8,8,0,1,1,38.22,99c16.6,20.54,45.64,45,89.78,45s73.18-24.49,89.78-45A8,8,0,1,1,230.22,109a153.47,153.47,0,0,1-19.3,20l20,35A8,8,0,0,1,228,175Z"},child:[]}]})(r)}function Kt({className:r="",...t}){return e.jsx("input",{...t,className:`h-10 rounded-lg border border-[var(--border)] bg-[var(--bg-input)] px-2.5 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] ${r}`})}function Ua({label:r,containerClassName:t="",helperText:a,error:n,errorDisplay:s="inline",errorTooltipLabel:l="Error de validacion",labelAction:i,floatingLabel:c=!1,showPasswordToggle:d=!0,nativeValidation:f=!1,className:b="",required:p,...m}){const[w,k]=o.useState(()=>!!m.autoFocus),[M,g]=o.useState(!1),C=m.type==="password"&&d,O=C&&M?"text":m.type,D=!!n,z=D&&s!=="tooltip",E=D&&s!=="inline",S=f?p:void 0,U=D?"border-[var(--danger)] focus:border-[var(--danger)]":"",H=E?C?"pr-20":"pr-10":C?"pr-10":"",W=m.value!==void 0?String(m.value).length>0:m.defaultValue!==void 0&&String(m.defaultValue).length>0,Y=w||W,Z={top:Y?7:12,color:w?"var(--primary)":"var(--text-muted)",fontSize:Y?10:13,fontWeight:Y?600:400,textTransform:Y?"uppercase":"none"},T=re=>{var Q;k(!0),(Q=m.onFocus)==null||Q.call(m,re)},J=re=>{var Q;k(!1),(Q=m.onBlur)==null||Q.call(m,re)},B=C?e.jsxs("button",{type:"button","aria-label":M?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":M,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors duration-200 hover:text-[var(--primary)] focus:outline-none",tabIndex:-1,onClick:()=>g(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 ${M?"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 ${M?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:e.jsx(wi,{className:"h-[18px] w-[18px]"})})]}):null,_=E?e.jsx(jr,{as:"span",content:n,className:`absolute top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--danger)] outline-none transition-colors hover:bg-[var(--danger-bg)] focus-visible:bg-[var(--danger-bg)] ${C?"right-10":"right-2.5"}`,children:e.jsx("span",{tabIndex:0,role:"img","aria-label":l,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(Jn,{className:"h-[18px] w-[18px]"})})}):null;return c?e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"relative block",children:[e.jsx(Kt,{...m,type:O,required:S,placeholder:" ","aria-invalid":D||m["aria-invalid"],"data-has-value":W?"true":void 0,className:`h-11 w-full pt-5 ${H} ${U} ${b}`,onFocus:T,onBlur:J}),e.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:Z,children:[r,p&&e.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),i&&e.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:Y?7:12},children:i}),_,B]}),z?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]}):e.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e.jsx("span",{children:r}),p&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),i&&e.jsx("span",{className:"ml-auto normal-case",children:i})]}),C?e.jsxs("span",{className:"relative block",children:[e.jsx(Kt,{...m,type:O,required:S,"aria-invalid":D||m["aria-invalid"],className:`w-full ${H} ${U} ${b}`,onFocus:T,onBlur:J}),_,B]}):e.jsxs("span",{className:"relative block",children:[e.jsx(Kt,{...m,required:S,"aria-invalid":D||m["aria-invalid"],className:`w-full ${H} ${U} ${b}`}),_]}),z?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]})}function Rn(r){return r==null?"":String(r)}function Ni({autoComplete:r="email",inputMode:t="email",validate:a=!0,invalidMessage:n="Ingresa un correo valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:d,...f}){const[b,p]=o.useState(()=>Rn(c)),m=i!==void 0?Rn(i):b,w=a&&m.length>0&&!ja(m)?n:void 0,k=M=>{i===void 0&&p(M.currentTarget.value),d==null||d(M)};return e.jsx(Ua,{...f,value:i,defaultValue:c,type:"text",inputMode:t,autoComplete:r,error:l??w,errorDisplay:s,onChange:k})}const ki={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function Si({title:r="Sin resultados",description:t,icon:a=e.jsx(A.HiInbox,{className:"h-5 w-5"}),action:n,secondaryAction:s,size:l="md",className:i=""}){return e.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${ki[l]} ${i}`,children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[a&&e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:a}),e.jsxs("div",{className:"space-y-1",children:[r&&e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-main)]",children:r}),t&&e.jsx("div",{className:"text-sm leading-5 text-[var(--text-muted)]",children:t})]}),(n||s)&&e.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[s,n]})]})})}const Ci={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function Ei(r){if(r===0)return"0 B";const t=["B","KB","MB","GB"],a=Math.min(Math.floor(Math.log(r)/Math.log(1024)),t.length-1),n=r/1024**a;return`${n>=10||a===0?n.toFixed(0):n.toFixed(1)} ${t[a]}`}function eo(r,t){return t?t.split(",").map(a=>a.trim().toLowerCase()).filter(Boolean).some(a=>{const n=r.name.toLowerCase(),s=r.type.toLowerCase();return a.startsWith(".")?n.endsWith(a):a.endsWith("/*")?s.startsWith(a.slice(0,-1)):s===a}):!0}function Mi(r,t,a){return t?a===void 0?r:r.slice(0,Math.max(0,a)):r.slice(0,1)}function Ti({label:r,helperText:t,error:a,labelAction:n,value:s,defaultValue:l=[],onFilesChange:i,onRejectedFiles:c,multiple:d=!1,maxFiles:f,appendFiles:b=!1,showFileList:p=!0,clearable:m=!0,browseLabel:w="Buscar archivos",dropLabel:k="Suelta los archivos aqui",emptyLabel:M="Arrastra y suelta archivos",emptyDescription:g="o haz click para buscarlos en tu equipo",selectedLabel:C="Archivos seleccionados",size:O="md",containerClassName:D="",dropzoneClassName:z="",fileListClassName:E="",className:S="",id:U,accept:H,disabled:W,required:Y,...Z}){const T=o.useId(),J=U??T,B=o.useRef(null),[_,re]=o.useState(!1),[Q,$]=o.useState(l),R=s??Q,oe=!!a,x=m&&R.length>0&&!W,y=(j,ae)=>{s===void 0&&$(j),i==null||i(j,ae)},V=(j,ae)=>{const ne=j.filter(xe=>eo(xe,H)),he=j.filter(xe=>!eo(xe,H)),Oe=b?[...R,...ne]:ne,Ge=Mi(Oe,d,f);he.length>0&&(c==null||c(he)),y(Ge,ae)},q=()=>{var j;W||(j=B.current)==null||j.click()},ee=j=>{V(Array.from(j.target.files??[]),j),j.target.value=""},ce=j=>{j.preventDefault(),W||re(!0)},ve=j=>{j.currentTarget.contains(j.relatedTarget)||re(!1)},te=j=>{j.preventDefault(),re(!1),!W&&V(Array.from(j.dataTransfer.files),j)},X=j=>{j.key!=="Enter"&&j.key!==" "||(j.preventDefault(),q())},h=j=>{y(R.filter((ae,ne)=>ne!==j))},L=()=>{y([])};return e.jsxs("div",{className:`flex flex-col gap-2 ${D}`,children:[(r||n)&&e.jsxs("div",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[r&&e.jsx("span",{children:r}),Y&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),n&&e.jsx("span",{className:"ml-auto normal-case",children:n})]}),e.jsx("input",{...Z,ref:B,id:J,type:"file",accept:H,multiple:d,disabled:W,required:Y&&R.length===0,"aria-invalid":oe||Z["aria-invalid"],className:"sr-only",onChange:ee}),e.jsxs("div",{role:"button",tabIndex:W?-1:0,"aria-controls":J,"aria-disabled":W||void 0,"aria-invalid":oe||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)] ${Ci[O]} ${_?"border-[var(--primary)] bg-[var(--bg-input)]":oe?"border-[var(--danger)]":"border-[var(--border)]"} ${W?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${z} ${S}`,onClick:q,onDragOver:ce,onDragLeave:ve,onDrop:te,onKeyDown:X,children:[e.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:e.jsx(A.HiArrowUpTray,{className:"h-5 w-5"})}),e.jsxs("span",{className:"space-y-1",children:[e.jsx("span",{className:"block text-sm font-semibold text-[var(--text-main)]",children:_?k:M}),g&&e.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:g})]}),w&&e.jsx("span",{className:"inline-flex h-9 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] px-3 text-xs font-semibold text-[var(--text-main)] shadow-sm shadow-black/5 transition-colors",children:w})]}),p&&R.length>0&&e.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${E}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase text-[var(--text-muted)]",children:C}),x&&e.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":"Quitar todos los archivos",onClick:L,children:e.jsx(A.HiTrash,{className:"h-4 w-4"})})]}),e.jsx("ul",{className:"divide-y divide-[var(--border)]",children:R.map((j,ae)=>e.jsxs("li",{className:"flex items-center gap-3 px-3 py-2",children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-[var(--bg-input)] text-[var(--text-muted)]",children:e.jsx(A.HiDocument,{className:"h-4 w-4"})}),e.jsxs("span",{className:"min-w-0 flex-1 text-left",children:[e.jsx("span",{className:"block truncate text-sm font-medium text-[var(--text-main)]",children:j.name}),e.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:Ei(j.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 ${j.name}`,onClick:()=>h(ae),children:e.jsx(A.HiXMark,{className:"h-4 w-4"})})]},`${j.name}-${j.lastModified}-${ae}`))})]}),a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:a}):t?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:t}):null]})}const Li=[{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 $i({fields:r,title:t="Layout",fieldTypes:a=Li,saveLabel:n="Guardar",allowAddField:s=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:d,onChange:f}){const[b,p]=o.useState(()=>r.map(D=>({key:!1,type:"",...D}))),[m,w]=o.useState(""),[k,M]=o.useState(""),g=o.useCallback((D,z)=>{p(E=>{const S=E.map((U,H)=>H===D?{...U,...z}:U);return f==null||f(S),S})},[f]),C=o.useCallback(()=>{d==null||d(b)},[b,d]),O=o.useCallback(()=>{var S;const D=m.trim();if(!D){M("Ingresa un nombre de campo.");return}if(b.some(U=>U.name.toLowerCase()===D.toLowerCase())){M("Ese campo ya existe en el arreglo.");return}const E={name:D,key:!1,type:((S=a[0])==null?void 0:S.value)??""};p(U=>{const H=[...U,E];return f==null||f(H),H}),w(""),M("")},[a,b,m,f]);return e.jsxs("div",{className:"flex flex-col rounded-xl border shadow-sm",style:{borderColor:"var(--border)",background:"var(--bg-card)",color:"var(--text-main)"},children:[e.jsx("div",{className:"border-b px-6 py-4",style:{borderColor:"var(--border)"},children:e.jsx("span",{className:"text-base font-semibold",style:{color:"var(--text-main)"},children:t})}),e.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] gap-4 border-b px-6 py-2 text-xs font-medium uppercase tracking-wide",style:{borderColor:"var(--border)",color:"var(--text-muted)"},children:[e.jsx("span",{children:"Campo"}),e.jsx("span",{className:"text-center",children:"Llave"}),e.jsx("span",{children:"Tipo de Campo"})]}),e.jsxs("div",{className:"max-h-[420px] overflow-y-auto",children:[b.map((D,z)=>e.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] items-center gap-4 border-b px-6 py-3 last:border-0 hover:bg-[var(--bg-input)] transition-colors",style:{borderColor:"var(--border)"},children:[e.jsx("span",{className:"text-sm font-medium",style:{color:"var(--text-main)"},children:D.name}),e.jsx("div",{className:"flex justify-center",children:e.jsx(Ft,{size:"sm",checked:D.key??!1,onChange:E=>g(z,{key:E.target.checked}),"aria-label":`${D.name} es clave`})}),e.jsx(Er,{value:D.type??"",onChange:E=>g(z,{type:E}),options:a,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${D.name}`})]},D.name)),b.length===0&&e.jsx("p",{className:"px-6 py-8 text-center text-sm",style:{color:"var(--text-muted)"},children:"No hay campos disponibles."})]}),e.jsx("div",{className:"flex justify-end border-t px-6 py-4",style:{borderColor:"var(--border)"},children:e.jsxs("div",{className:"w-full space-y-2",children:[s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:m,onChange:D=>{w(D.currentTarget.value),k&&M("")},onKeyDown:D=>{D.key==="Enter"&&(D.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(Pe,{variant:"secondary",onClick:O,height:36,padding:"0 12px",children:i})]}),k&&e.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:k})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(Pe,{variant:"primary",onClick:C,disabled:c,loading:c,children:n})})]})})]})}function ro({label:r,children:t,helperText:a,error:n,labelAction:s,required:l=!1,className:i="",contentClassName:c=""}){return e.jsxs("label",{className:`flex flex-col gap-2 ${i}`,children:[(r||s)&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[r&&e.jsx("span",{children:r}),l&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),s&&e.jsx("span",{className:"ml-auto normal-case",children:s})]}),e.jsx("span",{className:`block ${c}`,children:t}),n?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:n}):a?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:a}):null]})}function to(r){if(r!==void 0)return typeof r=="number"?`${r}px`:r}function ao(r,t){if(r.length!==t.length)return!1;const a=new Set(t);return r.every(n=>a.has(n))}function Va(r){return r.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Ai(r,t){if(!t)return!0;const a=Va(t);return Va(r.label).includes(a)||!!(r.sublabel&&Va(r.sublabel).includes(a))}function Di({value:r,onChange:t,options:a,placeholder:n="Seleccionar…",disabled:s=!1,className:l="",style:i,height:c=40,padding:d="6px 10px",searchable:f=!0,minOptionsForSearch:b=6,maxVisibleValues:p=2,truncateSelectedValues:m=!0,emptyText:w="Sin resultados",clearLabel:k="Limpiar seleccion",pruneMissingValues:M=!0}){const[g,C]=o.useState(!1),[O,D]=o.useState(""),[z,E]=o.useState(0),[S,U]=o.useState(!1),[H,W]=o.useState({}),Y=o.useRef(null),Z=o.useRef(null),T=o.useRef(null),J=o.useRef(null),B=f&&a.length>=b,_=o.useMemo(()=>new Set(r),[r]),re=o.useMemo(()=>{const h=new Map;for(const L of a)h.set(L.value,L);return h},[a]),Q=o.useMemo(()=>{const h=[];for(const L of r){const j=re.get(L);j&&h.push(j)}return h},[re,r]),$=p==="all"?Q.length:p,R=Q.slice(0,$),oe=Math.max(0,Q.length-R.length),x=o.useMemo(()=>{const h=O.trim();return!B||!h?a:a.filter(L=>Ai(L,h))},[a,O,B]),y=o.useCallback(()=>{const h=Y.current;if(!h)return;const L=h.getBoundingClientRect(),j=B?304:244,ae=window.innerHeight-L.bottom,ne=ae<j&&L.top>ae;W({position:"fixed",left:L.left,top:ne?void 0:L.bottom+4,bottom:ne?window.innerHeight-L.top+4:void 0,width:Math.max(L.width,240),zIndex:9999})},[B]),V=o.useCallback(h=>{ao(r,h)||t(h)},[t,r]),q=o.useCallback(h=>{const L=re.get(h);if(L!=null&&L.disabled)return;const j=_.has(h)?r.filter(ae=>ae!==h):[...r,h];V(j)},[V,re,r,_]),ee=o.useCallback(()=>V([]),[V]),ce=o.useCallback(()=>{C(!1),D(""),E(0)},[]);o.useEffect(()=>U(!0),[]);const ve=o.useMemo(()=>a.map(h=>h.value).join("\0"),[a]);o.useEffect(()=>{if(!M||r.length===0||a.length===0)return;const h=new Set(a.map(j=>j.value)),L=r.filter(j=>h.has(j));ao(r,L)||t(L)},[ve]),o.useEffect(()=>{if(!g)return;function h(L){var ae,ne;const j=L.target;!((ae=Y.current)!=null&&ae.contains(j))&&!((ne=Z.current)!=null&&ne.contains(j))&&ce()}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[ce,g]),o.useEffect(()=>{g&&(E(0),y(),B&&setTimeout(()=>{var h;return(h=T.current)==null?void 0:h.focus()},0))},[g,B,y]),o.useEffect(()=>{if(g)return window.addEventListener("resize",y),window.addEventListener("scroll",y,!0),()=>{window.removeEventListener("resize",y),window.removeEventListener("scroll",y,!0)}},[g,y]),o.useEffect(()=>{if(x.length===0){E(0);return}E(h=>Math.min(h,x.length-1))},[x.length]),o.useEffect(()=>{if(z<0||!J.current)return;const h=J.current.children[z];h==null||h.scrollIntoView({block:"nearest"})},[z]);function te(h){if(!s){if(!g){(h.key==="Enter"||h.key===" "||h.key==="ArrowDown")&&(h.preventDefault(),C(!0));return}if(h.key==="Escape"){h.preventDefault(),ce();return}if(h.key==="ArrowDown"){if(h.preventDefault(),x.length===0)return;E(L=>Math.min(L+1,x.length-1));return}if(h.key==="ArrowUp"){h.preventDefault(),E(L=>Math.max(L-1,0));return}if(h.key==="Enter"&&x[z]&&!x[z].disabled){h.preventDefault(),q(x[z].value);return}h.key==="Backspace"&&!O&&r.length&&(h.preventDefault(),V(r.slice(0,-1)))}}const X=e.jsxs("div",{ref:Z,className:"overflow-hidden rounded-xl shadow-xl",style:{...H,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[B&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[e.jsx(A.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),e.jsx("input",{ref:T,value:O,onChange:h=>{D(h.target.value),E(0)},onKeyDown:h=>{(h.key==="ArrowDown"||h.key==="ArrowUp"||h.key==="Enter"||h.key==="Escape")&&(h.stopPropagation(),te(h))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),O&&e.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:h=>{h.preventDefault(),D(""),E(0)},children:e.jsx(A.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),r.length>0&&e.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 py-2 text-xs",style:{borderBottom:"1px solid var(--border)",color:"var(--text-muted)"},children:[e.jsxs("span",{children:[Q.length," seleccionados",r.length>Q.length?` (${r.length-Q.length} no disponibles)`:""]}),e.jsx("button",{type:"button",onMouseDown:h=>{h.preventDefault(),ee()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:k})]}),e.jsxs("ul",{ref:J,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:B?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[x.map((h,L)=>{const j=L===z,ae=_.has(h.value);return e.jsxs("li",{role:"option","aria-selected":ae,onMouseDown:ne=>{ne.preventDefault(),!h.disabled&&q(h.value)},onMouseEnter:()=>!h.disabled&&E(L),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:j?"var(--bg-hover)":ae?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:h.disabled?"var(--text-muted)":"var(--text-main)",cursor:h.disabled?"not-allowed":"pointer",opacity:h.disabled?.58:1},children:[e.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:ae?"var(--primary)":"var(--border)",background:ae?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:ae&&e.jsx(A.HiCheck,{className:"h-3 w-3"})}),h.color&&e.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:h.color}}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[e.jsx("span",{className:"truncate",children:h.label}),h.sublabel&&e.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:h.sublabel})]}),h.badge&&e.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:h.badge})]},h.value)}),x.length===0&&e.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:w})]})]});return e.jsxs("div",{ref:Y,className:`relative ${l||"w-full"}`,style:i,onKeyDown:te,children:[e.jsxs("button",{type:"button",disabled:s,onClick:()=>{s||(g?ce():C(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:to(c),padding:to(d),background:"var(--bg-input)",color:Q.length?"var(--text-main)":"var(--text-muted)",border:g?"1px solid var(--primary)":"1px solid var(--border)",opacity:s?.5:1,cursor:s?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":g,children:[e.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:R.length?e.jsxs(e.Fragment,{children:[R.map(h=>e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${m?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[h.color&&e.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:h.color}}),e.jsx("span",{className:m?"truncate":"break-words",children:h.label}),e.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${h.label}`,onMouseDown:L=>{L.preventDefault(),L.stopPropagation(),q(h.value)},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(A.HiXMark,{className:"h-3 w-3"})})]},h.value)),oe>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:["+",oe]})]}):e.jsx("span",{className:"truncate",children:n})}),Q.length?e.jsx("span",{role:"button",tabIndex:-1,"aria-label":k,onMouseDown:h=>{h.preventDefault(),h.stopPropagation(),ee()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:e.jsx(A.HiXMark,{className:"h-3.5 w-3.5"})}):e.jsx(A.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:g?"rotate(180deg)":"rotate(0deg)"}})]}),g&&S&&Je.createPortal(X,document.body)]})}function Ii({inputMode:r="decimal",...t}){return e.jsx(Ua,{...t,type:"number",inputMode:r})}function Bi(r,t,a){const n=[],s=Math.max(2,r-a),l=Math.min(t-1,r+a);n.push(1),s>2&&n.push("...");for(let i=s;i<=l;i+=1)n.push(i);return l<t-1&&n.push("..."),t>1&&n.push(t),n}function Oi({page:r,totalPages:t,onPageChange:a,disabled:n=!1,siblingCount:s=1,className:l=""}){const i=Math.max(1,t),c=Math.min(Math.max(1,r),i),d=Bi(c,i,s);return e.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[e.jsx(Pe,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:n||c<=1,onClick:()=>a(c-1),children:e.jsx(A.HiChevronLeft,{className:"h-4 w-4"})}),d.map((f,b)=>f==="..."?e.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${b}`):e.jsx("button",{type:"button","aria-current":f===c?"page":void 0,disabled:n,onClick:()=>a(f),className:"flex h-8 min-w-8 items-center justify-center rounded-md border px-2 text-xs font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-50",style:{borderColor:f===c?"var(--primary)":"var(--border)",background:f===c?"var(--primary)":"var(--bg-card)",color:f===c?"var(--primary-fg)":"var(--text-secondary)"},children:f},f)),e.jsx(Pe,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:n||c>=i,onClick:()=>a(c+1),children:e.jsx(A.HiChevronRight,{className:"h-4 w-4"})})]})}const no=[{value:"+1",label:"+1",sublabel:"Estados Unidos, Canada, Caribe"},{value:"+7",label:"+7",sublabel:"Rusia, Kazajistan"},{value:"+20",label:"+20",sublabel:"Egipto"},{value:"+27",label:"+27",sublabel:"Sudafrica"},{value:"+30",label:"+30",sublabel:"Grecia"},{value:"+31",label:"+31",sublabel:"Paises Bajos"},{value:"+32",label:"+32",sublabel:"Belgica"},{value:"+33",label:"+33",sublabel:"Francia"},{value:"+34",label:"+34",sublabel:"Espana"},{value:"+36",label:"+36",sublabel:"Hungria"},{value:"+39",label:"+39",sublabel:"Italia, Vaticano"},{value:"+40",label:"+40",sublabel:"Rumania"},{value:"+41",label:"+41",sublabel:"Suiza"},{value:"+43",label:"+43",sublabel:"Austria"},{value:"+44",label:"+44",sublabel:"Reino Unido"},{value:"+45",label:"+45",sublabel:"Dinamarca"},{value:"+46",label:"+46",sublabel:"Suecia"},{value:"+47",label:"+47",sublabel:"Noruega"},{value:"+48",label:"+48",sublabel:"Polonia"},{value:"+49",label:"+49",sublabel:"Alemania"},{value:"+51",label:"+51",sublabel:"Peru"},{value:"+52",label:"+52",sublabel:"Mexico"},{value:"+53",label:"+53",sublabel:"Cuba"},{value:"+54",label:"+54",sublabel:"Argentina"},{value:"+55",label:"+55",sublabel:"Brasil"},{value:"+56",label:"+56",sublabel:"Chile"},{value:"+57",label:"+57",sublabel:"Colombia"},{value:"+58",label:"+58",sublabel:"Venezuela"},{value:"+60",label:"+60",sublabel:"Malasia"},{value:"+61",label:"+61",sublabel:"Australia"},{value:"+62",label:"+62",sublabel:"Indonesia"},{value:"+63",label:"+63",sublabel:"Filipinas"},{value:"+64",label:"+64",sublabel:"Nueva Zelanda"},{value:"+65",label:"+65",sublabel:"Singapur"},{value:"+66",label:"+66",sublabel:"Tailandia"},{value:"+81",label:"+81",sublabel:"Japon"},{value:"+82",label:"+82",sublabel:"Corea del Sur"},{value:"+84",label:"+84",sublabel:"Vietnam"},{value:"+86",label:"+86",sublabel:"China"},{value:"+90",label:"+90",sublabel:"Turquia"},{value:"+91",label:"+91",sublabel:"India"},{value:"+92",label:"+92",sublabel:"Pakistan"},{value:"+93",label:"+93",sublabel:"Afganistan"},{value:"+94",label:"+94",sublabel:"Sri Lanka"},{value:"+95",label:"+95",sublabel:"Myanmar"},{value:"+98",label:"+98",sublabel:"Iran"},{value:"+211",label:"+211",sublabel:"Sudan del Sur"},{value:"+212",label:"+212",sublabel:"Marruecos, Sahara Occidental"},{value:"+213",label:"+213",sublabel:"Argelia"},{value:"+216",label:"+216",sublabel:"Tunez"},{value:"+218",label:"+218",sublabel:"Libia"},{value:"+220",label:"+220",sublabel:"Gambia"},{value:"+221",label:"+221",sublabel:"Senegal"},{value:"+222",label:"+222",sublabel:"Mauritania"},{value:"+223",label:"+223",sublabel:"Mali"},{value:"+224",label:"+224",sublabel:"Guinea"},{value:"+225",label:"+225",sublabel:"Costa de Marfil"},{value:"+226",label:"+226",sublabel:"Burkina Faso"},{value:"+227",label:"+227",sublabel:"Niger"},{value:"+228",label:"+228",sublabel:"Togo"},{value:"+229",label:"+229",sublabel:"Benin"},{value:"+230",label:"+230",sublabel:"Mauricio"},{value:"+231",label:"+231",sublabel:"Liberia"},{value:"+232",label:"+232",sublabel:"Sierra Leona"},{value:"+233",label:"+233",sublabel:"Ghana"},{value:"+234",label:"+234",sublabel:"Nigeria"},{value:"+235",label:"+235",sublabel:"Chad"},{value:"+236",label:"+236",sublabel:"Republica Centroafricana"},{value:"+237",label:"+237",sublabel:"Camerun"},{value:"+238",label:"+238",sublabel:"Cabo Verde"},{value:"+239",label:"+239",sublabel:"Santo Tome y Principe"},{value:"+240",label:"+240",sublabel:"Guinea Ecuatorial"},{value:"+241",label:"+241",sublabel:"Gabon"},{value:"+242",label:"+242",sublabel:"Republica del Congo"},{value:"+243",label:"+243",sublabel:"Republica Democratica del Congo"},{value:"+244",label:"+244",sublabel:"Angola"},{value:"+245",label:"+245",sublabel:"Guinea-Bisau"},{value:"+246",label:"+246",sublabel:"Territorio Britanico del Oceano Indico"},{value:"+248",label:"+248",sublabel:"Seychelles"},{value:"+249",label:"+249",sublabel:"Sudan"},{value:"+250",label:"+250",sublabel:"Ruanda"},{value:"+251",label:"+251",sublabel:"Etiopia"},{value:"+252",label:"+252",sublabel:"Somalia"},{value:"+253",label:"+253",sublabel:"Yibuti"},{value:"+254",label:"+254",sublabel:"Kenia"},{value:"+255",label:"+255",sublabel:"Tanzania"},{value:"+256",label:"+256",sublabel:"Uganda"},{value:"+257",label:"+257",sublabel:"Burundi"},{value:"+258",label:"+258",sublabel:"Mozambique"},{value:"+260",label:"+260",sublabel:"Zambia"},{value:"+261",label:"+261",sublabel:"Madagascar"},{value:"+262",label:"+262",sublabel:"Reunion, Mayotte"},{value:"+263",label:"+263",sublabel:"Zimbabue"},{value:"+264",label:"+264",sublabel:"Namibia"},{value:"+265",label:"+265",sublabel:"Malaui"},{value:"+266",label:"+266",sublabel:"Lesoto"},{value:"+267",label:"+267",sublabel:"Botsuana"},{value:"+268",label:"+268",sublabel:"Esuatini"},{value:"+269",label:"+269",sublabel:"Comoras"},{value:"+290",label:"+290",sublabel:"Santa Elena"},{value:"+291",label:"+291",sublabel:"Eritrea"},{value:"+297",label:"+297",sublabel:"Aruba"},{value:"+298",label:"+298",sublabel:"Islas Feroe"},{value:"+299",label:"+299",sublabel:"Groenlandia"},{value:"+350",label:"+350",sublabel:"Gibraltar"},{value:"+351",label:"+351",sublabel:"Portugal"},{value:"+352",label:"+352",sublabel:"Luxemburgo"},{value:"+353",label:"+353",sublabel:"Irlanda"},{value:"+354",label:"+354",sublabel:"Islandia"},{value:"+355",label:"+355",sublabel:"Albania"},{value:"+356",label:"+356",sublabel:"Malta"},{value:"+357",label:"+357",sublabel:"Chipre"},{value:"+358",label:"+358",sublabel:"Finlandia, Aland"},{value:"+359",label:"+359",sublabel:"Bulgaria"},{value:"+370",label:"+370",sublabel:"Lituania"},{value:"+371",label:"+371",sublabel:"Letonia"},{value:"+372",label:"+372",sublabel:"Estonia"},{value:"+373",label:"+373",sublabel:"Moldavia"},{value:"+374",label:"+374",sublabel:"Armenia"},{value:"+375",label:"+375",sublabel:"Bielorrusia"},{value:"+376",label:"+376",sublabel:"Andorra"},{value:"+377",label:"+377",sublabel:"Monaco"},{value:"+378",label:"+378",sublabel:"San Marino"},{value:"+380",label:"+380",sublabel:"Ucrania"},{value:"+381",label:"+381",sublabel:"Serbia"},{value:"+382",label:"+382",sublabel:"Montenegro"},{value:"+383",label:"+383",sublabel:"Kosovo"},{value:"+385",label:"+385",sublabel:"Croacia"},{value:"+386",label:"+386",sublabel:"Eslovenia"},{value:"+387",label:"+387",sublabel:"Bosnia y Herzegovina"},{value:"+389",label:"+389",sublabel:"Macedonia del Norte"},{value:"+420",label:"+420",sublabel:"Chequia"},{value:"+421",label:"+421",sublabel:"Eslovaquia"},{value:"+423",label:"+423",sublabel:"Liechtenstein"},{value:"+500",label:"+500",sublabel:"Islas Malvinas"},{value:"+501",label:"+501",sublabel:"Belice"},{value:"+502",label:"+502",sublabel:"Guatemala"},{value:"+503",label:"+503",sublabel:"El Salvador"},{value:"+504",label:"+504",sublabel:"Honduras"},{value:"+505",label:"+505",sublabel:"Nicaragua"},{value:"+506",label:"+506",sublabel:"Costa Rica"},{value:"+507",label:"+507",sublabel:"Panama"},{value:"+508",label:"+508",sublabel:"San Pedro y Miquelon"},{value:"+509",label:"+509",sublabel:"Haiti"},{value:"+590",label:"+590",sublabel:"Guadalupe, San Bartolome"},{value:"+591",label:"+591",sublabel:"Bolivia"},{value:"+592",label:"+592",sublabel:"Guyana"},{value:"+593",label:"+593",sublabel:"Ecuador"},{value:"+594",label:"+594",sublabel:"Guayana Francesa"},{value:"+595",label:"+595",sublabel:"Paraguay"},{value:"+596",label:"+596",sublabel:"Martinica"},{value:"+597",label:"+597",sublabel:"Surinam"},{value:"+598",label:"+598",sublabel:"Uruguay"},{value:"+599",label:"+599",sublabel:"Caribe Neerlandes, Curazao"},{value:"+670",label:"+670",sublabel:"Timor Oriental"},{value:"+672",label:"+672",sublabel:"Antartida, Isla Norfolk"},{value:"+673",label:"+673",sublabel:"Brunei"},{value:"+674",label:"+674",sublabel:"Nauru"},{value:"+675",label:"+675",sublabel:"Papua Nueva Guinea"},{value:"+676",label:"+676",sublabel:"Tonga"},{value:"+677",label:"+677",sublabel:"Islas Salomon"},{value:"+678",label:"+678",sublabel:"Vanuatu"},{value:"+679",label:"+679",sublabel:"Fiyi"},{value:"+680",label:"+680",sublabel:"Palaos"},{value:"+681",label:"+681",sublabel:"Wallis y Futuna"},{value:"+682",label:"+682",sublabel:"Islas Cook"},{value:"+683",label:"+683",sublabel:"Niue"},{value:"+685",label:"+685",sublabel:"Samoa"},{value:"+686",label:"+686",sublabel:"Kiribati"},{value:"+687",label:"+687",sublabel:"Nueva Caledonia"},{value:"+688",label:"+688",sublabel:"Tuvalu"},{value:"+689",label:"+689",sublabel:"Polinesia Francesa"},{value:"+690",label:"+690",sublabel:"Tokelau"},{value:"+691",label:"+691",sublabel:"Micronesia"},{value:"+692",label:"+692",sublabel:"Islas Marshall"},{value:"+850",label:"+850",sublabel:"Corea del Norte"},{value:"+852",label:"+852",sublabel:"Hong Kong"},{value:"+853",label:"+853",sublabel:"Macao"},{value:"+855",label:"+855",sublabel:"Camboya"},{value:"+856",label:"+856",sublabel:"Laos"},{value:"+880",label:"+880",sublabel:"Banglades"},{value:"+886",label:"+886",sublabel:"Taiwan"},{value:"+960",label:"+960",sublabel:"Maldivas"},{value:"+961",label:"+961",sublabel:"Libano"},{value:"+962",label:"+962",sublabel:"Jordania"},{value:"+963",label:"+963",sublabel:"Siria"},{value:"+964",label:"+964",sublabel:"Irak"},{value:"+965",label:"+965",sublabel:"Kuwait"},{value:"+966",label:"+966",sublabel:"Arabia Saudita"},{value:"+967",label:"+967",sublabel:"Yemen"},{value:"+968",label:"+968",sublabel:"Oman"},{value:"+970",label:"+970",sublabel:"Palestina"},{value:"+971",label:"+971",sublabel:"Emiratos Arabes Unidos"},{value:"+972",label:"+972",sublabel:"Israel"},{value:"+973",label:"+973",sublabel:"Barein"},{value:"+974",label:"+974",sublabel:"Catar"},{value:"+975",label:"+975",sublabel:"Butan"},{value:"+976",label:"+976",sublabel:"Mongolia"},{value:"+977",label:"+977",sublabel:"Nepal"},{value:"+992",label:"+992",sublabel:"Tayikistan"},{value:"+993",label:"+993",sublabel:"Turkmenistan"},{value:"+994",label:"+994",sublabel:"Azerbaiyan"},{value:"+995",label:"+995",sublabel:"Georgia"},{value:"+996",label:"+996",sublabel:"Kirguistan"},{value:"+998",label:"+998",sublabel:"Uzbekistan"}];function oo(r){return r==null?"":String(r)}function Xt(r){return r?r.startsWith("+")?r:`+${r}`:"+1"}function Hi(r){return typeof r=="number"?`${r}px`:r}function Pi({autoComplete:r="tel",inputMode:t="tel",validate:a=!0,invalidMessage:n="Ingresa un telefono valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:d,countryCode:f,defaultCountryCode:b="+1",onCountryCodeChange:p,allowedCountryCodes:m,countryCodeOptions:w,countryCodePlaceholder:k="Codigo",countryCodeClassName:M="",countryCodeWidth:g=84,onPhoneValueChange:C,label:O,containerClassName:D="",helperText:z,labelAction:E,className:S="",required:U,disabled:H,floatingLabel:W,showPasswordToggle:Y,nativeValidation:Z,errorTooltipLabel:T="Error de validacion",...J}){var j;const[B,_]=o.useState(()=>oo(c)),[re,Q]=o.useState(()=>Xt(b)),$=o.useMemo(()=>{const ae=w??no,ne=m==null?void 0:m.map(Xt);return ne!=null&&ne.length?ae.filter(he=>ne.includes(he.value)):ae},[m,w]),R=((j=$[0])==null?void 0:j.value)??"+1",oe=$.some(ae=>ae.value===Xt(f??re))?Xt(f??re):R,x=i!==void 0?oo(i):B,y=`${oe} ${x}`.trim(),V=a&&x.length>0&&!Wa(y)?n:void 0,q=l??V,ee=!!q,ce=ee&&s!=="tooltip",ve=ee&&s!=="inline",te=ee?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",X=ae=>{const ne=ae.currentTarget.value;i===void 0&&_(ne),C==null||C(ne,{countryCode:oe,nationalNumber:ne,fullNumber:`${oe} ${ne}`.trim()}),d==null||d(ae)},h=ae=>{f===void 0&&Q(ae),p==null||p(ae),C==null||C(x,{countryCode:ae,nationalNumber:x,fullNumber:`${ae} ${x}`.trim()})},L=ve?e.jsx(jr,{as:"span",content:q,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--danger)] outline-none transition-colors hover:bg-[var(--danger-bg)] focus-visible:bg-[var(--danger-bg)]",children:e.jsx("span",{tabIndex:0,role:"img","aria-label":T,className:"flex h-full w-full items-center justify-center outline-none",children:e.jsx(Jn,{className:"h-[18px] w-[18px]"})})}):null;return e.jsxs("div",{className:`flex flex-col gap-2 ${D}`,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}),U&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"}),E&&e.jsx("span",{className:"ml-auto normal-case",children:E})]}),e.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${te}`,children:[e.jsx(Er,{value:oe,onChange:h,options:$,placeholder:k,disabled:H,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${M}`,style:{width:Hi(g)},height:38,padding:"0 8px 0 10px"}),e.jsx("span",{className:"h-5 w-px shrink-0 bg-[var(--border)]"}),e.jsxs("span",{className:"relative min-w-0 flex-1 self-stretch",children:[e.jsx("input",{...J,value:i,defaultValue:c,type:"tel",inputMode:t,autoComplete:r,disabled:H,required:void 0,"aria-label":J["aria-label"]??(typeof O=="string"?O:void 0),"aria-invalid":ee||J["aria-invalid"],className:`h-full w-full min-w-0 bg-transparent px-2 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed disabled:opacity-60 ${ve?"pr-10":""} ${S}`,onChange:X}),L]})]}),ce?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:q}):z?e.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:z}):null]})}function Fi({value:r,onChange:t,options:a,name:n,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:a.map(f=>{const b=f.value===r,p=i||f.disabled;return e.jsxs("label",{className:`inline-flex min-w-0 items-start gap-2 rounded-lg border px-2.5 py-1.5 transition-colors ${p?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${d}`,style:{borderColor:b?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:b?"color-mix(in srgb, var(--primary) 8%, transparent)":"var(--bg-card)"},children:[e.jsxs("span",{className:"relative mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-[var(--border)] bg-[var(--bg-input)]",children:[e.jsx("input",{type:"radio",name:n,value:f.value,checked:b,disabled:p,onChange:()=>t(f.value),className:"absolute inset-0 opacity-0"}),e.jsx("span",{className:`h-2 w-2 rounded-full transition ${b?"scale-100 opacity-100":"scale-50 opacity-0"}`,style:{background:"var(--primary)"}})]}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:f.label}),f.description&&e.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:f.description})]})]},f.value)})})]})}const so=()=>'<button type="button" class="rich-img-del" data-action="delete-img" title="Eliminar imagen"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M9 2a1 1 0 0 0-.894.553L7.382 4H4a1 1 0 0 0 0 2v10a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V6a1 1 0 0 0 0-2h-3.382l-.724-1.447A1 1 0 0 0 11 2H9zm-1 6a1 1 0 1 1 2 0v4a1 1 0 1 1-2 0V8zm4 0a1 1 0 1 1 2 0v4a1 1 0 1 1-2 0V8z" clip-rule="evenodd"/></svg></button>',xt=r=>r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),lo=r=>r.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(t,a,n)=>`${a}${n.toLocaleUpperCase()}`),zi=r=>r.replace(/[<>]/g,"").toLowerCase(),_i=new Set(["p","br","div","span","b","strong","i","em","u","s","strike","ul","ol","li","h1","h2","h3","h4","blockquote","a","img","hr"]),ji=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,Wi=r=>{const t=r.indexOf("<!--StartFragment-->"),a=r.indexOf("<!--EndFragment-->");if(t!==-1&&a!==-1&&a>t)return r.slice(t+20,a);const n=r.match(/<body[^>]*>([\s\S]*)<\/body>/i);return n?n[1]:r},Yt=(r,t)=>t.test(r),qi=r=>Yt(r,/font-weight\s*:\s*(bold|[6-9]00)/i),Ui=r=>Yt(r,/font-style\s*:\s*italic/i),Vi=r=>Yt(r,/text-decoration(?:-line)?\s*:[^;]*underline/i),Gi=r=>Yt(r,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),Zt=(r,t)=>{var n;if(!r.childNodes.length||r.childNodes.length===1&&((n=r.firstChild)==null?void 0:n.nodeType)===Node.ELEMENT_NODE&&r.firstChild.tagName.toLowerCase()===t)return;const a=r.ownerDocument.createElement(t);for(;r.firstChild;)a.appendChild(r.firstChild);r.appendChild(a)},Qt=r=>{const t=r.parentNode;if(!t){r.remove();return}for(;r.firstChild;)t.insertBefore(r.firstChild,r);t.removeChild(r)},Ki=r=>{const t=r.getAttribute("class")??"",a=r.getAttribute("style")??"";return/mso-list/i.test(a)||/MsoListParagraph/i.test(t)||/MsoList/i.test(t)},io=r=>{const t=r.getAttribute("style")??"",a=r.textContent??"";return/mso-level-number-format\s*:\s*(decimal|arabic|roman|alpha)/i.test(t)||/^\s*\d+[.)]\s/.test(a)||/^\s*[a-zA-Z][.)]\s/.test(a)?"ol":"ul"},Xi=r=>{const a=r.ownerDocument.createTreeWalker(r,NodeFilter.SHOW_TEXT).nextNode();if(!a||!a.textContent)return;const n=a.textContent.replace(ji,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");n!==a.textContent&&(a.textContent=n)},Yi=r=>{const t=Array.from(r.querySelectorAll("span, font, p, div, li, h1, h2, h3, h4"));t.sort((a,n)=>n.querySelectorAll("*").length-a.querySelectorAll("*").length),t.forEach(a=>{const n=a.getAttribute("style")??"";n&&(qi(n)&&Zt(a,"strong"),Ui(n)&&Zt(a,"em"),Vi(n)&&Zt(a,"u"),Gi(n)&&Zt(a,"s"))})},Zi=r=>{const t=Array.from(r.querySelectorAll("p, div")).filter(Ki);if(!t.length)return;let a=0;for(;a<t.length;){const n=t[a],s=io(n),l=[n];let i=a+1;for(;i<t.length;){const f=t[i];if(io(f)!==s)break;let b=l[l.length-1].nextSibling;for(;b&&b.nodeType===Node.TEXT_NODE&&!(b.textContent??"").trim();)b=b.nextSibling;if(b!==f)break;l.push(f),i++}const c=n.parentNode;if(!c){a=i;continue}const d=n.ownerDocument.createElement(s);c.insertBefore(d,n),l.forEach(f=>{Xi(f);const b=f.ownerDocument.createElement("li");for(;f.firstChild;)b.appendChild(f.firstChild);d.appendChild(b),f.remove()}),a=i}},Qi=r=>r==="h1"?"h2":r==="h4"||r==="h5"||r==="h6"?"h3":r==="div"?"p":r,Ji=r=>{const t=Wi(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()),Yi(s),Zi(s);const l=i=>{const c=Array.from(i.childNodes);if(i.nodeType===Node.ELEMENT_NODE){const d=i,f=d.tagName.toLowerCase();if(f==="html"||f==="body"){c.forEach(l);return}if(f==="font"){Qt(d),c.forEach(l);return}if(!_i.has(f)){Qt(d),c.forEach(l);return}const b=Qi(f);if(b!==f){const p=d.ownerDocument.createElement(b);for(;d.firstChild;)p.appendChild(d.firstChild);d.replaceWith(p),l(p);return}if(Array.from(d.attributes).forEach(p=>{const m=p.name.toLowerCase(),w=p.value;if(m.startsWith("on")||m==="style"||m==="class"){d.removeAttribute(p.name);return}if(m==="lang"||m.startsWith("data-")||m.startsWith("mso-")){d.removeAttribute(p.name);return}if((m==="href"||m==="src")&&/^\s*javascript:/i.test(w)){d.removeAttribute(p.name);return}f!=="a"&&f!=="img"&&m!=="href"&&m!=="src"&&m!=="alt"&&(["href","src","alt","target","rel"].includes(m)||d.removeAttribute(p.name))}),f==="a"){const p=d.getAttribute("href");if(!p||/^\s*#/.test(p)&&p.length<2){Qt(d),c.forEach(l);return}d.setAttribute("target","_blank"),d.setAttribute("rel","noopener noreferrer"),d.classList.add("rich-link")}if(f==="img"){const p=d.getAttribute("src")??"";if(!p||/^\s*javascript:/i.test(p)||/^file:/i.test(p)||/scheme\s*=\s*["']?file/i.test(p)){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(f==="span"){Qt(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"),f=!c&&!d&&Array.from(i.childNodes).every(b=>b.nodeType===Node.TEXT_NODE||b.nodeType===Node.ELEMENT_NODE&&b.tagName.toLowerCase()==="br");(!c&&!d||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 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()},Ga=r=>xt(r).replace(/\r\n?/g,`
25
+ `).split(/\n{2,}/).map(t=>`<p>${t.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),Ri=r=>new RegExp("\\p{L}","u").test(r),Ka=(r,t)=>{const a=r.trim();return!a||!Ri(a)?!1:t==="uppercase"?a===a.toLocaleUpperCase():t==="lowercase"?a===a.toLocaleLowerCase():a===lo(a)},co=r=>{const t=n=>{var s,l;if(!n.closest(".rich-img-wrap")){const i=document.createElement("span");i.className="rich-img-wrap",i.contentEditable="false",(s=n.parentNode)==null||s.insertBefore(i,n),i.appendChild(n),i.insertAdjacentHTML("beforeend",so())}(l=n.closest(".rich-img-wrap"))==null||l.classList.add("rich-img-broken")};r.querySelectorAll("img").forEach(n=>{if(!n.complete||n.naturalWidth===0){n.addEventListener("error",()=>t(n),{once:!0}),n.addEventListener("load",()=>{n.naturalWidth===0&&t(n)},{once:!0});const s=n.src;n.src="",n.src=s}});const a=n=>{const s=n.target;s.tagName==="IMG"&&t(s)};return r.addEventListener("error",a,!0),()=>r.removeEventListener("error",a,!0)};function uo({value:r,onChange:t,placeholder:a="Escribe algo...",minHeight:n="80px",instanceId:s}){const l=o.useId(),i=s||l,c=o.useCallback(()=>document,[]),d=o.useRef(null),f=o.useRef(null),b=o.useRef(new Map),p=o.useRef(null),m=o.useRef(!1),w=o.useRef(r??""),k=o.useRef(t),M=o.useRef(!1),[g,C]=o.useState(()=>!r||r.trim()===""),[O,D]=o.useState(new Set),[z,E]=o.useState(null),[S,U]=o.useState(""),[H,W]=o.useState(""),[Y,Z]=o.useState(""),[T,J]=o.useState(""),[B,_]=o.useState(!1),re=o.useCallback(()=>m.current?f.current:d.current,[]);o.useEffect(()=>{k.current=t},[t]);const Q=o.useCallback(()=>{const I=window.getSelection(),G=re();if(!I||!G||I.rangeCount===0||I.isCollapsed)return"";const le=I.getRangeAt(0);return!G.contains(le.startContainer)||!G.contains(le.endContainer)?"":I.toString()},[re]);o.useEffect(()=>{const I=r??"";if(M.current&&I===w.current){M.current=!1,C(!I||I.trim()==="");return}M.current=!1,w.current=I;const G=[d.current,f.current].filter(ue=>!!ue);G.forEach(ue=>{ue.innerHTML!==I&&(ue.innerHTML=I)}),C(!I||I.trim()==="");const le=G.map(ue=>co(ue));return()=>le.forEach(ue=>ue())},[r]),o.useEffect(()=>{var ue,Le;m.current=B;let I,G=0,le;if(B){const ke=d.current;ke&&(w.current=ke.innerHTML);const Ie=()=>{var Ue;const Me=f.current;if(!Me){G=requestAnimationFrame(Ie);return}Me.innerHTML!==w.current&&(Me.innerHTML=w.current),I=co(Me),C(((Ue=Me.textContent)==null?void 0:Ue.trim())===""),le=setTimeout(()=>Me.focus(),60)};G=requestAnimationFrame(Ie)}else{const ke=f.current,Ie=d.current,Me=(ke==null?void 0:ke.innerHTML)??w.current,Ue=w.current;w.current=Me,Ie&&Ie.innerHTML!==Me&&(Ie.innerHTML=Me),Me!==Ue&&k.current(Me),C(((Le=(ue=ke??Ie)==null?void 0:ue.textContent)==null?void 0:Le.trim())==="")}return()=>{G&&cancelAnimationFrame(G),le&&clearTimeout(le),I==null||I()}},[B]);const $=o.useCallback(()=>{const I=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],G=new Set;I.forEach(ue=>{try{c().queryCommandState(ue)&&G.add(ue)}catch{return}});try{const ue=zi(c().queryCommandValue("formatBlock"));ue&&G.add(`formatBlock:${ue}`)}catch{}const le=Q();Ka(le,"uppercase")&&G.add("__upper"),Ka(le,"lowercase")&&G.add("__lower"),Ka(le,"capitalize")&&G.add("__cap"),D(G)},[Q,c]),R=()=>{var G;const I=re();I&&(w.current=I.innerHTML,M.current=!0,k.current(w.current),C(((G=I.textContent)==null?void 0:G.trim())===""))},oe=I=>{if(!I){const G=d.current;G&&(w.current=G.innerHTML)}_(!I)},x=(I,G)=>{var le;(le=re())==null||le.focus(),c().execCommand(I,!1,G),R(),$()},y=I=>{x("formatBlock",I)},V=()=>{var I;(I=re())==null||I.focus(),c().execCommand("insertHTML",!1,"<hr><p><br></p>"),R(),$()},q=()=>{const I=window.getSelection();I&&I.rangeCount>0&&(p.current=I.getRangeAt(0).cloneRange())},ee=()=>{const I=window.getSelection();I&&p.current&&(I.removeAllRanges(),I.addRange(p.current))},ce=I=>{if(q(),I==="link"){const G=window.getSelection();W(G&&!G.isCollapsed?G.toString():""),U("")}I==="image"&&(Z(""),J("")),E(I)},ve=()=>{var ue;if(!S.trim())return;ee(),(ue=re())==null||ue.focus();const I=window.getSelection(),le=(I&&!I.isCollapsed?I.toString():"")||H.trim()||S.trim();c().execCommand("insertHTML",!1,`<a href="${xt(S.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${xt(le)}</a>`),R(),E(null)},te=(I,G="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${xt(I)}" alt="${xt(G)}" class="rich-img" />${so()}</span>`,X=()=>{var I;Y.trim()&&(ee(),(I=re())==null||I.focus(),c().execCommand("insertHTML",!1,te(Y.trim(),T.trim())),R(),E(null))},h=(I,G=1200,le=1200,ue=.72)=>new Promise((Le,ke)=>{const Ie=new FileReader;Ie.onerror=ke,Ie.onload=Me=>{var la;const Ue=(la=Me.target)==null?void 0:la.result,Be=new Image;Be.onerror=ke,Be.onload=()=>{let{width:Ke,height:ze}=Be;if(Ke>G||ze>le){const ir=Math.min(G/Ke,le/ze);Ke=Math.round(Ke*ir),ze=Math.round(ze*ir)}const Xe=document.createElement("canvas");Xe.width=Ke,Xe.height=ze;const $r=Xe.getContext("2d");if(!$r){Le(Ue);return}$r.drawImage(Be,0,0,Ke,ze),Le(Xe.toDataURL("image/jpeg",ue))},Be.src=Ue},Ie.readAsDataURL(I)}),L=I=>{I.focus();const G=window.getSelection();if(!G||G.rangeCount===0||!I.contains(G.anchorNode)){const le=document.createRange();le.selectNodeContents(I),le.collapse(!1),G==null||G.removeAllRanges(),G==null||G.addRange(le)}},j=o.useRef(()=>{});j.current=I=>{const G=re();G&&(L(G),c().execCommand("insertHTML",!1,I),G.querySelectorAll("p").forEach(le=>{!(le.textContent??"").replace(/[\u00a0\s]+/g,"")&&!le.querySelector("img, hr")&&le.remove()}),R(),$())};const ae=o.useRef(h);ae.current=h;const ne=o.useRef(te);ne.current=te;const he=o.useCallback(I=>{if(!I||b.current.has(I))return;const G=le=>{const ue=le.clipboardData;if(!ue)return;const Le=ue.getData("text/html"),ke=ue.getData("text/plain");if(Le||ke){le.preventDefault(),le.stopPropagation();try{const Be=Le?Ji(Le):Ga(ke);if(!Be){ke&&j.current(Ga(ke));return}j.current(Be)}catch{ke&&j.current(Ga(ke))}return}const Me=Array.from(ue.items).find(Be=>Be.type.startsWith("image/"));if(!Me)return;le.preventDefault(),le.stopPropagation();const Ue=Me.getAsFile();Ue&&ae.current(Ue).then(Be=>{j.current(ne.current(Be,"imagen"))})};I.addEventListener("paste",G,!0),b.current.set(I,()=>{I.removeEventListener("paste",G,!0),b.current.delete(I)})},[]),Oe=o.useCallback(I=>{var le;const G=d.current;G&&G!==I&&((le=b.current.get(G))==null||le()),d.current=I,I&&he(I)},[he]),Ge=o.useCallback(I=>{var le;const G=f.current;G&&G!==I&&((le=b.current.get(G))==null||le()),f.current=I,I&&he(I)},[he]);o.useEffect(()=>{const I=b.current;return()=>{I.forEach(G=>G()),I.clear()}},[]);const xe=I=>{const G=window.getSelection(),le=re();if(!G||!le||G.rangeCount===0||G.isCollapsed)return;const ue=G.getRangeAt(0);if(!le.contains(ue.startContainer)||!le.contains(ue.endContainer))return;const Le=ue.toString();if(!Le)return;let ke=Le;I==="uppercase"?ke=Le.toLocaleUpperCase():I==="lowercase"?ke=Le.toLocaleLowerCase():ke=lo(Le),ue.deleteContents();const Ie=document.createTextNode(ke);ue.insertNode(Ie);const Me=document.createRange();Me.setStart(Ie,0),Me.setEnd(Ie,ke.length),G.removeAllRanges(),G.addRange(Me),p.current=Me.cloneRange(),R(),$()},Ee=()=>{q(),$()},Ae=()=>{R(),$()},wr=()=>{requestAnimationFrame(()=>{var I;(I=re())==null||I.focus()})},br=I=>{var G,le;if((I.metaKey||I.ctrlKey)&&I.key==="Enter"){if(I.preventDefault(),I.stopPropagation(),I.repeat)return;(G=re())==null||G.focus(),c().execCommand("insertLineBreak",!1)||c().execCommand("insertHTML",!1,"<br>"),R(),$();return}if(I.key==="Tab"){I.preventDefault(),(le=re())==null||le.focus(),c().execCommand("insertText",!1,"    "),R(),$();return}if(I.key==="Escape"){if(z){E(null);return}if(m.current){_(!1);return}}z||(I.ctrlKey||I.metaKey)&&(I.key==="b"&&(I.preventDefault(),x("bold")),I.key==="i"&&(I.preventDefault(),x("italic")),I.key==="u"&&(I.preventDefault(),x("underline")),I.key==="k"&&(I.preventDefault(),ce("link")))},We=()=>e.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),se=(I,G,le,ue,Le)=>{const ke=Le??(O.has(le)||le==="__link"&&z==="link"||le==="__img"&&z==="image");return e.jsx("button",{type:"button",title:G,tabIndex:-1,onFocus:wr,onMouseDown:Ie=>{Ie.preventDefault(),ue?ue():x(le)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:ke?"var(--primary)":"var(--text-secondary)",background:ke?"rgba(59,130,246,0.12)":"transparent"},children:I},le)},Ze=I=>{const G=I.target;if(G.closest("[data-action='delete-img']")){I.preventDefault();const le=G.closest(".rich-img-wrap");le&&(le.remove(),R())}},lr=I=>e.jsxs(e.Fragment,{children:[z==="link"&&e.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:I},children:[e.jsx("input",{autoFocus:!0,type:"url",value:S,onChange:G=>U(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),ve()),G.key==="Escape"&&E(null)},placeholder:"https://...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),e.jsx("input",{type:"text",value:H,onChange:G=>W(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),ve()),G.key==="Escape"&&E(null)},placeholder:"Texto (opcional)",className:"w-32 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),e.jsx("button",{type:"button",onClick:ve,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),e.jsx("button",{type:"button",onClick:()=>E(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),z==="image"&&e.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:I},children:[e.jsx("input",{autoFocus:!0,type:"url",value:Y,onChange:G=>Z(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),X()),G.key==="Escape"&&E(null)},placeholder:"URL de la imagen...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),e.jsx("input",{type:"text",value:T,onChange:G=>J(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),X()),G.key==="Escape"&&E(null)},placeholder:"Texto alt",className:"w-28 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),e.jsx("button",{type:"button",onClick: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:()=>E(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),de=(I,G)=>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:G},children:[se(e.jsx(A.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),se(e.jsx(A.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),We(),se(e.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>y("p"),O.has("formatBlock:p")||O.has("formatBlock:div")),se(e.jsx(A.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>y("h2"),O.has("formatBlock:h2")),se(e.jsx(A.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>y("h3"),O.has("formatBlock:h3")),se(e.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>y("blockquote"),O.has("formatBlock:blockquote")),We(),se(e.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),se(e.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),se(e.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),se(e.jsx("s",{children:"S"}),"Tachado","strikeThrough"),We(),se(e.jsx(A.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),se(e.jsx(A.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),se(e.jsx(A.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),se(e.jsx(A.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),We(),se(e.jsx(A.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),se(e.jsx(A.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),se(e.jsx(A.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),se(e.jsx(A.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),We(),se(e.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>xe("uppercase")),se(e.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>xe("lowercase")),se(e.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>xe("capitalize")),We(),se(e.jsx(A.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>ce("link")),se(e.jsx(A.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),se(e.jsx(A.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>ce("image")),se(e.jsx(A.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",V),We(),se(e.jsx(A.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),se(e.jsx(A.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>y("p")),We(),e.jsx("button",{type:"button",title:I?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:wr,onMouseDown:le=>{le.preventDefault(),oe(I)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:I?e.jsx(A.HiArrowsPointingIn,{className:"h-4 w-4"}):e.jsx(A.HiArrowsPointingOut,{className:"h-4 w-4"})})]});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"overflow-hidden rounded-lg transition-all duration-150 ring-1 ring-transparent focus-within:ring-primary/30",style:{border:"1px solid var(--border)"},children:[e.jsx("div",{ref:Oe,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:Ae,onKeyDown:br,onKeyUp:Ee,onSelect:Ee,onMouseUp:Ee,onMouseDown:Ze,"data-placeholder":a,className:`rich-editor px-3 py-2 text-sm focus:outline-none${g?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:n,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),lr("var(--bg-input)"),de(!1,"var(--bg-input)")]}),e.jsxs(Pa,{open:B,onClose:()=>_(!1),title:"Modo de enfoque",subtitle:"Esc para salir",maxWidth:"920px",bodyClassName:"flex min-h-0 flex-col p-0",panelClassName:"h-[88vh]",backdropClassName:"bg-black/50 backdrop-blur-[2px]",children:[e.jsx("div",{ref:Ge,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:Ae,onKeyDown:br,onKeyUp:Ee,onSelect:Ee,onMouseUp:Ee,onMouseDown:Ze,"data-placeholder":a,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${g?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),lr("var(--bg-input)"),de(!0,"var(--bg-input)")]})]})}const fo="[a-zA-Z0-9._@-]+",Xa=new RegExp(`@(${fo})`,"g"),ec=/[a-zA-Z0-9._@-]/,yt=new Set([" ",`
26
+ `," ","\r"," ","(","[","{",".",",",";",":","!","?","¿","¡",")","]","}",'"',"'","«","»","/","\\","|","-","—","–"]);function bo(r,t){if(t<=0)return!0;const a=r[t-1]??"";return yt.has(a)}function po(r,t,a){var n;if(t<0||t>r.length)return null;for(let s=t-1;s>=0;s-=1){if(r[s]!=="@"){const c=r[s]??"";if(yt.has(c)||!ec.test(c))return null;continue}if((n=a==null?void 0:a.isInsideExistingMention)!=null&&n.call(a,s)||!(a!=null&&a.isTriggerBoundary?a.isTriggerBoundary(s):bo(r,s)))continue;const i=r.slice(s+1,t);return i.length>0&&!new RegExp(`^${fo}$`).test(i)?null:{query:i,triggerIndex:s,caretIndex:t}}return null}function mo(r,t){var n;const a=Ur(r,t);return a?!!((n=a.node.parentElement)!=null&&n.closest(".mention-chip")):!1}function ho(r,t){if(t<=0)return!0;const a=Ur(r,t);if(!a){const s=r.textContent??"";return bo(s,t)}if(a.offset>0){const s=a.node.data[a.offset-1]??"";return yt.has(s)}let n=a.node.previousSibling;for(;n;){if(n.nodeType===Node.TEXT_NODE){const s=n.textContent??"";if(s.length===0){n=n.previousSibling;continue}return yt.has(s[s.length-1]??"")}if(n.nodeType===Node.ELEMENT_NODE){const s=n;if(s.classList.contains("mention-chip")||s.tagName==="BR"||/^(P|DIV|LI|H[1-6]|BLOCKQUOTE)$/i.test(s.tagName))return!0;const l=s.textContent??"";if(l.length===0){n=n.previousSibling;continue}return yt.has(l[l.length-1]??"")}n=n.previousSibling}return!0}function Ya(r,t){const a=r.textContent??"";return po(a,t,{isTriggerBoundary:n=>ho(r,n),isInsideExistingMention:n=>mo(r,n)})}function Za(r){return r.toLowerCase().trim()}function go(r){return r?r.replace(/<style[^>]*>[\s\S]*?<\/style>/gi," ").replace(/<script[^>]*>[\s\S]*?<\/script>/gi," ").replace(/<br\s*\/?>/gi,`
28
27
  `).replace(/<\/(p|div|li)>/gi,`
29
- `).replace(/<[^>]+>/g," ").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/\s+/g," ").trim():""}function Za(r){if(!r)return[];const t=fo(r),a=new Set,n=[];Ka.lastIndex=0;let s;for(;(s=Ka.exec(t))!==null;){const l=Ya(s[1]??"");!l||a.has(l)||(a.add(l),n.push(l))}return n}function Yi(r,t){const a=Za(r);if(!a.length)return[];const n=new Map;t.forEach(i=>{i.username&&n.set(Ya(i.username),i)});const s=new Set,l=[];for(const i of a){const c=n.get(i);c&&(s.has(c.userId)||(s.add(c.userId),l.push({userId:c.userId,username:c.username,email:c.email??void 0,display:c.name??c.username})))}return l}function bo(r){const t=new Set,a=[];for(const n of r)t.has(n.userId)||(t.add(n.userId),a.push(n));return a}function Zi(r,t){return t?r.filter(a=>a.userId!==t):r}function po(r){return!r||!/@/.test(r)?r:r.replace(Ka,(t,a,n,s)=>{const l=s.slice(0,n),i=l.lastIndexOf("<"),c=l.lastIndexOf(">");return i>c?t:`<span class="mention-chip" contenteditable="false" data-username="${(a??"").toLowerCase()}">${t}</span>`})}function Zt(r,t){if(t<0)return null;const a=r.ownerDocument;if(!a)return null;const n=a.createTreeWalker(r,NodeFilter.SHOW_TEXT);let s=t,l=null,i=n.nextNode();for(;i;){l=i;const c=i.data.length;if(s<=c)return{node:i,offset:s};s-=c,i=n.nextNode()}return l&&s===0?{node:l,offset:l.data.length}:null}function Qa(r,t,a){var s;const n=r.ownerDocument;if(!n||r!==t&&!r.contains(t))return-1;try{const l=n.createRange();return l.selectNodeContents(r),l.setEnd(t,a),((s=l.cloneContents().textContent)==null?void 0:s.length)??0}catch{return-1}}function mo(r,t){const{triggerIndex:a,caretIndex:n,username:s}=t;if(n<a)return null;const l=Zt(r,a),i=Zt(r,n);if(!l||!i)return null;const c=r.ownerDocument,u=c.createRange();u.setStart(l.node,l.offset),u.setEnd(i.node,i.offset),u.deleteContents();const f=c.createElement("span");f.className="mention-chip",f.setAttribute("data-username",s.toLowerCase()),f.contentEditable="false",f.textContent=`@${s}`;const m=c.createTextNode(" ");u.insertNode(m),u.insertNode(f);const b=c.defaultView,p=b==null?void 0:b.getSelection();if(p){const x=c.createRange();x.setStart(m,m.data.length),x.collapse(!0),p.removeAllRanges(),p.addRange(x)}return{caretPlainOffset:a+s.length+2}}function ho(r,t){const a=r.ownerDocument,n=a.defaultView;if(!n)return;const s=n.getSelection();if(!s)return;const l=a.createRange(),i=Zt(r,t);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(r),l.collapse(!1)),s.removeAllRanges(),s.addRange(l)}const Qi={position:"relative"},Ji={position:"fixed",zIndex:1100,minWidth:260,maxHeight:280,overflowY:"auto",background:"var(--bg-card, var(--bonsaif-ui-surface, #fff))",border:"1px solid var(--border, var(--bonsaif-ui-border, #d0d7de))",borderRadius:10,boxShadow:"0 12px 32px rgba(0,0,0,0.18)",padding:4},go={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function Ri(r){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(r)}"]`))}function vo({value:r,onChange:t,onSearchUsers:a,onMentionsChange:n,minHeight:s,placeholder:l,className:i,maxSuggestions:c=8,searchDebounceMs:u=140,highlightInEditor:f=!1,searchCacheKey:m=""}){const b=o.useId().replace(/:/g,""),p=o.useRef(null),x=o.useRef(null),N=o.useRef(new Map),M=o.useRef(a);M.current=a;const g=o.useRef(null),[C,B]=o.useState(null),[A,F]=o.useState([]),[E,k]=o.useState(0),[U,H]=o.useState([]),[j,Y]=o.useState(!1),[Q,L]=o.useState(!1);o.useEffect(()=>{L(!0)},[]),o.useEffect(()=>{if(!C){F([]);return}const O=C.query.trim(),K=`${m}|${O.toLowerCase()||"*"}`,w=N.current.get(K);if(w){F(w),Y(!1),k(0);return}const S=new AbortController;Y(!0);const R=window.setTimeout(()=>{(async()=>{try{const te=await M.current(O,{signal:S.signal,limit:c});if(S.signal.aborted)return;const ae=Array.isArray(te)?te:[];N.current.set(K,ae),F(ae),k(0)}catch{S.signal.aborted||F([])}finally{S.signal.aborted||Y(!1)}})()},u);return()=>{S.abort(),window.clearTimeout(R)}},[C,c,u,m]),o.useEffect(()=>{n&&n(bo(U))},[U,n]);const Z=o.useCallback(()=>{const O=Ri(b);if(O.length===0)return null;const K=window.getSelection();if(K!=null&&K.rangeCount){const S=K.getRangeAt(0).startContainer;for(const R of O)if(R.contains(S))return R}const w=document.activeElement;for(const S of O)if(w===S||w&&S.contains(w))return S;for(const S of O)if(S.closest('[role="dialog"]'))return S;return O[0]??null},[b]),W=o.useCallback(O=>{t(O);const K=Z(),w=window.getSelection();if(!K||!w||w.rangeCount===0){B(null);return}const S=w.getRangeAt(0);if(!K.contains(S.startContainer)){B(null);return}const R=Qa(K,S.startContainer,S.startOffset);if(R<0){B(null);return}const te=K.textContent??"",ae=Xa(te,R);if(!ae){B(null);return}const ce=S.getBoundingClientRect();g.current={query:ae.query,caretIndex:ae.caretIndex,triggerIndex:ae.triggerIndex},B({query:ae.query,top:ce.bottom+6,left:Math.max(8,Math.min(ce.left,window.innerWidth-280))})},[Z,t]),z=o.useCallback(O=>{const K=Z();if(!K)return;let w=-1;const S=K.textContent??"",R=window.getSelection();if(R&&R.rangeCount>0){const re=R.getRangeAt(0);K.contains(re.startContainer)&&(w=Qa(K,re.startContainer,re.startOffset))}if(w<0&&g.current&&(w=g.current.caretIndex),w<0)return;const te=Xa(S,w);if(!te)return;const ae=mo(K,{triggerIndex:te.triggerIndex,caretIndex:w,username:O.username});if(!ae)return;t(K.innerHTML);const ce={userId:O.userId,username:O.username,email:O.email??void 0,display:O.name??O.username};H(re=>{const X=new Map(re.map(h=>[h.userId,h]));return X.set(ce.userId,ce),Array.from(X.values())}),B(null),g.current=null;const ve=ae.caretPlainOffset;requestAnimationFrame(()=>{requestAnimationFrame(()=>{var q,ne;const re=Z();if(!re)return;re.focus(),ho(re,ve);const X=window.getSelection(),h=X==null?void 0:X.anchorNode,$=h instanceof Element?h.closest(".mention-chip"):(q=h==null?void 0:h.parentElement)==null?void 0:q.closest(".mention-chip");if($!=null&&$.parentNode){const oe=document.createRange(),he=$.nextSibling;he&&he.nodeType===Node.TEXT_NODE?oe.setStart(he,((ne=he.textContent)==null?void 0:ne.length)??0):oe.setStartAfter($),oe.collapse(!0),X==null||X.removeAllRanges(),X==null||X.addRange(oe)}})})},[Z,t]);o.useEffect(()=>{const O=new Set(Za(r).map(K=>K.toLowerCase()));H(K=>{const w=K.filter(S=>O.has(S.username.toLowerCase()));return w.length===K.length?K:w})},[r]),o.useEffect(()=>{if(!C)return;const O=K=>{const w=K.target;if(!w||p.current&&p.current.contains(w)||x.current&&x.current.contains(w))return;const S=Z();S&&S.contains(w)||B(null)};return document.addEventListener("mousedown",O),()=>{document.removeEventListener("mousedown",O)}},[C,Z]);const ee=o.useMemo(()=>A.slice(0,c),[A,c]);o.useEffect(()=>{if(!C)return;const O=K=>{const w=Z(),S=K.target;if(!(!w||!S||!w.contains(S))&&!(ee.length===0&&K.key!=="Escape"))if(K.key==="ArrowDown")K.preventDefault(),K.stopPropagation(),k(R=>(R+1)%Math.max(ee.length,1));else if(K.key==="ArrowUp")K.preventDefault(),K.stopPropagation(),k(R=>(R-1+ee.length)%Math.max(ee.length,1));else if(K.key==="Enter"||K.key==="Tab"){const R=ee[E];R&&(K.preventDefault(),K.stopPropagation(),z(R))}else K.key==="Escape"&&(K.preventDefault(),K.stopPropagation(),B(null))};return document.addEventListener("keydown",O,!0),()=>document.removeEventListener("keydown",O,!0)},[E,Z,z,C,ee]);const J=f?po(r):r,I=C&&Q?Je.createPortal(e.jsxs("ul",{ref:x,style:{...Ji,top:C.top,left:C.left},role:"listbox","aria-label":"Menciones sugeridas",children:[j&&ee.length===0&&e.jsx("li",{style:go,children:"Buscando…"}),!j&&ee.length===0&&e.jsx("li",{style:go,children:C.query.trim().length===0?"Escribe para buscar un usuario":`Sin coincidencias para “${C.query}”`}),ee.map((O,K)=>e.jsx("li",{children:e.jsxs("button",{type:"button",onMouseDown:w=>{w.preventDefault(),z(O)},onMouseEnter:()=>k(K),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:K===E?"color-mix(in srgb, var(--primary, var(--bonsaif-ui-primary, #1f6feb)) 14%, transparent)":"transparent",color:"var(--text-main, var(--bonsaif-ui-text, #24292f))",borderRadius:6,cursor:"pointer",display:"flex",flexDirection:"column",gap:2},children:[e.jsxs("span",{style:{fontWeight:600,fontSize:13},children:["@",O.username]}),e.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[O.name,O.email].filter(Boolean).join(" · ")||" "})]})},O.userId))]}),document.body):null;return e.jsxs("div",{ref:p,style:Qi,className:i,children:[e.jsx(co,{value:J,onChange:W,placeholder:l,minHeight:s,instanceId:b}),I]})}function ec({value:r,onChange:t,placeholder:a,minHeight:n,onSearchUsers:s,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:u,highlightInEditor:f,searchCacheKey:m}){return s?e.jsx(vo,{value:r,onChange:t,onSearchUsers:s,onMentionsChange:l,placeholder:a,minHeight:n,className:i,maxSuggestions:c,searchDebounceMs:u,highlightInEditor:f,searchCacheKey:m}):e.jsx(co,{value:r,onChange:t,placeholder:a,minHeight:n})}function rc({title:r,subtitle:t,icon:a,actions:n,children:s,footer:l,className:i="",bodyClassName:c="p-4"}){const u=r||t||a||n;return e.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${i}`,children:[u&&e.jsxs("header",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-4 py-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[a&&e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--primary)]",children:a}),e.jsxs("div",{className:"min-w-0",children:[r&&e.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:r}),t&&e.jsx("div",{className:"truncate text-xs text-[var(--text-muted)]",children:t})]})]}),n&&e.jsx("div",{className:"shrink-0",children:n})]}),e.jsx("div",{className:c,children:s}),l&&e.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:l})]})}const tc={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)"}},ac={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 nc({children:r,tone:t="neutral",size:a="sm",icon:n,dot:s=!1,className:l=""}){const i=tc[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 ${ac[a]} ${l}`,style:{color:i.text,background:i.bg,borderColor:i.border},children:[s&&e.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:i.text}}),n&&e.jsx("span",{className:"shrink-0",children:n}),e.jsx("span",{className:"min-w-0 truncate",children:r})]})}const xo={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)"}},oc={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"},sc={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},ic={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 cc({value:r,options:t,onChange:a,size:n="sm",disabled:s=!1,loading:l=!1,stopPropagation:i=!1,ariaLabel:c="Cambiar estado",title:u="Cambiar estado",className:f,selectClassName:m,menuClassName:b,optionClassName:p,spinnerClassName:x}){const[N,M]=o.useState(!1),[g,C]=o.useState(!1),[B,A]=o.useState(-1),[F,E]=o.useState({}),k=o.useRef(null),U=o.useRef(null),H=o.useRef(null),j=t.find(I=>I.value===r)??t[0],Y={...j!=null&&j.tone?xo[j.tone]:void 0,...j==null?void 0:j.style},Q=s||l||t.length===0,L=I=>{i&&I.stopPropagation()},Z=o.useCallback(()=>{M(!1),A(-1)},[]),W=o.useCallback(()=>{const I=k.current;if(!I)return;const O=I.getBoundingClientRect(),K=Math.max(O.width,lc[n]),w=Math.min(Math.max(t.length,1)*38+12,260),S=window.innerHeight-O.bottom,R=S<w&&O.top>S,te=Math.min(Math.max(8,O.left+O.width/2-K/2),window.innerWidth-K-8);E({position:"fixed",left:te,top:R?void 0:O.bottom+6,bottom:R?window.innerHeight-O.top+6:void 0,width:K,zIndex:9999})},[t.length,n]),z=o.useCallback(I=>{I.disabled||(a(I.value),Z())},[Z,a]);o.useEffect(()=>C(!0),[]),o.useEffect(()=>{if(!N)return;W();const I=t.findIndex(O=>O.value===r);A(I>=0?I:0)},[N,t,W,r]),o.useEffect(()=>{if(!N)return;function I(O){var w,S;const K=O.target;!((w=k.current)!=null&&w.contains(K))&&!((S=U.current)!=null&&S.contains(K))&&Z()}return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[Z,N]),o.useEffect(()=>{if(N)return window.addEventListener("resize",W),window.addEventListener("scroll",W,!0),()=>{window.removeEventListener("resize",W),window.removeEventListener("scroll",W,!0)}},[N,W]),o.useEffect(()=>{if(B<0||!H.current)return;const I=H.current.children[B];I==null||I.scrollIntoView({block:"nearest"})},[B]);function ee(I){if(!Q){if(!N){["Enter"," ","ArrowDown","ArrowUp"].includes(I.key)&&(I.preventDefault(),M(!0));return}if(I.key==="Escape"){I.preventDefault(),Z();return}if(I.key==="ArrowDown"){I.preventDefault(),A(O=>Math.min(O+1,t.length-1));return}if(I.key==="ArrowUp"){I.preventDefault(),A(O=>Math.max(O-1,0));return}if(I.key==="Enter"||I.key===" "){I.preventDefault();const O=t[B];O&&z(O)}}}const J=e.jsx("div",{ref:U,role:"listbox","aria-label":c,className:hr("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",b),style:{...F,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:L,onMouseDown:L,onPointerDown:L,children:e.jsx("div",{ref:H,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:t.map((I,O)=>{const K=I.value===r,w=O===B,S={...I.tone?xo[I.tone]:void 0,...I.style};return e.jsxs("button",{type:"button",role:"option","aria-selected":K,disabled:I.disabled,onMouseEnter:()=>!I.disabled&&A(O),onMouseDown:R=>{R.preventDefault(),z(I)},className:hr("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",ic[n],K?I.className:void 0,p),style:{...K?S:void 0,background:K?S.background??"color-mix(in srgb, var(--primary) 12%, transparent)":w?"var(--bg-hover)":"transparent",color:K?S.color??"var(--primary)":"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:K?e.jsx(T.HiCheck,{className:"h-4 w-4"}):null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:I.label})]},I.value)})})});return e.jsxs("span",{ref:k,className:hr("relative inline-flex shrink-0 items-center",f),onKeyDown:ee,onClick:L,onPointerDown:L,children:[e.jsx("button",{type:"button",disabled:Q,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":N,title:u,onClick:()=>!Q&&M(I=>!I),className:hr("inline-flex items-center rounded-full border border-transparent font-medium leading-none outline-none transition-colors hover:border-current focus:border-current disabled:cursor-wait disabled:opacity-70",oc[n],j==null?void 0:j.className,m),style:Y,children:e.jsx("span",{className:"min-w-0 truncate",children:(j==null?void 0:j.label)??r})}),e.jsx(T.HiChevronDown,{"aria-hidden":"true",className:hr("pointer-events-none absolute opacity-70 transition-transform",sc[n],N?"rotate-180":"rotate-0")}),l&&e.jsx("span",{"aria-hidden":"true",className:hr("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",x)}),N&&g&&Je.createPortal(J,document.body)]})}function dc({tabs:r,activeTabId:t,defaultActiveTabId:a,onTabChange:n,ariaLabel:s="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:u=""}){const f=r.find(N=>!N.disabled)??r[0],m=t??a??(f==null?void 0:f.id),b=r.find(N=>N.id===m)??f,p=N=>{N.disabled||n==null||n(N.id)},x=N=>{const M=r.filter(C=>!C.disabled);if(!M.length||!b)return;const g=M.findIndex(C=>C.id===b.id);(N.key==="ArrowRight"||N.key==="ArrowDown")&&(N.preventDefault(),p(M[(g+1)%M.length])),(N.key==="ArrowLeft"||N.key==="ArrowUp")&&(N.preventDefault(),p(M[(g-1+M.length)%M.length])),N.key==="Home"&&(N.preventDefault(),p(M[0])),N.key==="End"&&(N.preventDefault(),p(M[M.length-1]))};return e.jsxs("div",{className:i,children:[e.jsx("div",{role:"tablist","aria-label":s,onKeyDown:x,className:`flex min-w-0 gap-1 overflow-x-auto ${l==="underline"?"border-b border-[var(--border)]":"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-1"} ${c}`,children:r.map(N=>{const M=N.id===(b==null?void 0:b.id);return e.jsxs("button",{type:"button",role:"tab","aria-selected":M,"aria-controls":`${N.id}-panel`,id:`${N.id}-tab`,disabled:N.disabled,tabIndex:M?0:-1,onClick:()=>p(N),className:`inline-flex min-h-8 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap px-2.5 text-sm font-semibold transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 ${l==="underline"?"border-b-2":"rounded-md border"}`,style:{color:M?"var(--primary)":"var(--text-muted)",borderColor:M?"var(--primary)":"transparent",background:l==="pills"&&M?"var(--bg-card)":"transparent"},children:[N.icon&&e.jsx("span",{className:"shrink-0",children:N.icon}),e.jsx("span",{children:N.label}),N.badge&&e.jsx("span",{className:"shrink-0",children:N.badge})]},N.id)})}),(b==null?void 0:b.content)!==void 0&&e.jsx("div",{role:"tabpanel",id:`${b.id}-panel`,"aria-labelledby":`${b.id}-tab`,className:`pt-4 ${u}`,children:b.content})]})}function xr(...r){return r.filter(Boolean).join(" ")}function uc({steps:r,activeStepId:t,initialStepId:a,completedStepIds:n,defaultCompletedStepIds:s=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:c,allowBackNavigation:u=!0,showFooter:f=!0,previousLabel:m="Anterior",nextLabel:b="Siguiente",blockedNextLabel:p="Completa este paso",className:x="",headerClassName:N="",contentClassName:M="",footerClassName:g=""}){var re;const C=((re=r[0])==null?void 0:re.id)??"",[B,A]=o.useState(a??C),[F,E]=o.useState(s),k=t??B,U=n??F,H=o.useMemo(()=>new Set(U),[U]),j=Math.max(0,r.findIndex(X=>X.id===k)),Y=r[j]??r[0],Q=r.length<=1?100:j/(r.length-1)*100,L=X=>{n||E(X),i==null||i(X)},Z=X=>{const h=r.find($=>$.id===X);h&&(t||A(X),l==null||l(X,h))},W=X=>H.has(X),z=X=>r.slice(0,X).find(h=>!h.optional&&!H.has(h.id)),ee=X=>{const h=r[X];return!h||h.disabled?!1:X===j||u&&X<j?!0:!z(X)},J=X=>{const h=r.findIndex($=>$.id===X);return h>=0&&ee(h)},I=X=>{const h=r.findIndex($=>$.id===X);if(h<0)return!1;if(!ee(h)){const $=z(h);return $&&(c==null||c(r[h],$)),!1}return Z(X),!0},O=(X=Y==null?void 0:Y.id)=>{!X||H.has(X)||L([...U,X])},K=(X=Y==null?void 0:Y.id)=>{if(!X)return;const h=r.findIndex(q=>q.id===X),$=U.filter(q=>{const ne=r.findIndex(oe=>oe.id===q);return ne>=0&&ne<h});L($),h>=0&&j>h&&Z(X)},w=()=>j<=0?!1:I(r[j-1].id),S=()=>{const X=r[j+1];return X?I(X.id):!1},R={activeStep:Y,activeIndex:j,completedStepIds:U,isCompleted:W,isUnlocked:J,completeStep:O,uncompleteStep:K,goToStep:I,goNext:S,goPrevious:w};if(!Y)return null;const te=r[j+1],ae=j>0,ce=te?J(te.id):!1,ve=typeof Y.content=="function"?Y.content(R):Y.content;return e.jsxs("section",{className:xr("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",x),children:[e.jsxs("div",{className:xr("border-b border-[var(--border)] bg-[var(--bg-input)]",N),children:[e.jsx("div",{className:"relative h-1 overflow-hidden bg-[var(--border)]/55",children:e.jsx("div",{className:"h-full rounded-r-full bg-[var(--primary)] transition-[width] duration-500 ease-out",style:{width:`${Q}%`}})}),e.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${r.length}, minmax(0, 1fr))`},children:r.map((X,h)=>{const $=X.id===Y.id,q=W(X.id),ne=ee(h),oe=z(h);return e.jsxs("button",{type:"button",disabled:!ne,"aria-current":$?"step":void 0,"aria-disabled":!ne,title:!ne&&oe?`Completa ${oe.title}`:X.title,onClick:()=>I(X.id),className:xr("group relative min-h-16 min-w-0 overflow-hidden rounded-md border p-3 text-left transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/35 disabled:cursor-not-allowed",$&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",q&&!$&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!$&&!q&&ne&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!ne&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[e.jsx("span",{className:xr("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",$&&"scale-x-100")}),e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:xr("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",$&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",q&&!$&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!q&&!$&&ne&&"border-[var(--border)] text-[var(--text-muted)]",!ne&&"border-[var(--border)] text-[var(--text-muted)]"),children:q?e.jsx(T.HiCheck,{className:"h-4 w-4"}):ne?h+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:xr("block truncate text-xs font-semibold transition-colors duration-200",$?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[h+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:xr("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",M),children:ve},Y.id),f&&e.jsxs("div",{className:xr("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",g),children:[e.jsx(He,{variant:"secondary",height:38,padding:"0 14px",icon:e.jsx(T.HiChevronLeft,{}),disabled:!ae,onClick:w,children:m}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[e.jsxs("span",{children:["Paso ",j+1," de ",r.length]}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),e.jsxs("span",{children:[U.length," completados"]})]}),e.jsx(He,{height:38,padding:"0 14px",icon:e.jsx(T.HiChevronRight,{}),disabled:!te||!ce,onClick:S,children:te&&!ce?p:b})]})]})}const fc={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 pc(r,t){if(r){if(typeof r=="function"){r(t);return}r.current=t}}function mc(r,t){return r!==void 0?String(r).length:t!==void 0?String(t).length:0}const yo=o.forwardRef(function({className:t="",wrapperClassName:a="",size:n="md",resize:s="vertical",autoResize:l=!1,minRows:i,maxRows:c,showCount:u=!1,maxCount:f,status:m="default",icon:b,action:p,style:x,value:N,defaultValue:M,maxLength:g,onInput:C,...B},A){const F=o.useRef(null),E=mc(N,M),k=f??g,U=!!(b||p||u),H=m==="error"?"var(--danger)":m==="success"?"#16a34a":"var(--border)",j={...x??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},Y=()=>{const L=F.current;!L||!l||(L.style.height="auto",L.style.height=`${L.scrollHeight}px`)};o.useEffect(Y,[l,N]);const Q=e.jsx("textarea",{...B,ref:L=>{F.current=L,pc(A,L)},value:N,defaultValue:M,maxLength:g,"aria-invalid":m==="error"||B["aria-invalid"],onInput:L=>{Y(),C==null||C(L)},style:{...j,borderColor:H},className:`w-full rounded-lg border bg-[var(--bg-input)] text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-60 ${fc[n]} ${bc[l?"none":s]} ${b?"pl-8":""} ${p?"pr-10":""} ${t}`});return U?e.jsxs("span",{className:`relative block ${a}`,children:[b&&e.jsx("span",{className:"pointer-events-none absolute left-2.5 top-2.5 flex h-4 w-4 items-center justify-center text-[var(--text-muted)]",children:b}),Q,p&&e.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:p}),u&&e.jsxs("span",{className:"absolute bottom-1.5 right-2 rounded bg-[var(--bg-input)] px-1.5 text-[10px] font-semibold text-[var(--text-muted)]",children:[E,k?`/${k}`:""]})]}):Q});function hc({label:r,containerClassName:t="",helperText:a,error:n,labelAction:s,required:l,className:i="",status:c,...u}){return e.jsx(eo,{label:r,required:l,helperText:a,error:n,labelAction:s,className:t,children:e.jsx(yo,{...u,required:l,status:n?"error":c,className:`w-full ${i}`})})}const wo=[{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 gc(r){return wo[r%wo.length]}let vc=0;function Ja(){return++vc}function No(r,t){return t?t instanceof RegExp?t.test(r):t(r):!0}function xc(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function yc(r,t){const a=t.filter(Boolean);if(a.length===0)return[r.trim()].filter(Boolean);const n=new RegExp(`${a.map(s=>xc(s)).join("|")}|\\r?\\n`,"g");return r.split(n).map(s=>s.trim()).filter(Boolean)}function wc({value:r,defaultValue:t,onChange:a,placeholder:n="Escribe y presiona Enter…",disabled:s=!1,className:l="",delimiters:i=[","],maxTags:c,allowDuplicates:u=!1,validate:f,label:m,helperText:b,error:p,required:x=!1}){const N=r!==void 0,[M,g]=o.useState(()=>(t??[]).map((h,$)=>({id:Ja(),value:h.trim(),colorIndex:$})));o.useEffect(()=>{N&&g(h=>{const $=r??[],q=new Map(h.map(ne=>[ne.value,ne]));return $.map((ne,oe)=>q.get(ne)??{id:Ja(),value:ne,colorIndex:oe})})},[N,r]);const C=M,[B,A]=o.useState(""),[F,E]=o.useState(null),[k,U]=o.useState(""),[H,j]=o.useState(!1),[Y,Q]=o.useState(!1),L=o.useRef(null),Z=o.useRef(null),W=o.useRef(null),z=!!p;function ee(){Q(!0),setTimeout(()=>Q(!1),400)}function J(h){g(h),a==null||a(h.map($=>$.value))}function I(h){let $=C,q=!1,ne=!1;for(const oe of h){const he=oe.trim();if(he){if(c!==void 0&&$.length>=c){ne=!0;break}if(!u&&$.some(_e=>_e.value.toLowerCase()===he.toLowerCase())){ne=!0;continue}if(!No(he,f)){ne=!0;continue}$=[...$,{id:Ja(),value:he,colorIndex:$.length}],q=!0}}return q&&J($),ne&&ee(),q}function O(h){return I([h])}function K(h){const $=C.filter(q=>q.id!==h);J($.map((q,ne)=>({...q,colorIndex:ne})))}function w(h,$){const q=$.trim();if(E(null),U(""),!q){K(h);return}if(!(!u&&C.some(ne=>ne.id!==h&&ne.value.toLowerCase()===q.toLowerCase()))){if(!No(q,f)){ee();return}J(C.map(ne=>ne.id===h?{...ne,value:q}:ne))}}function S(h){s||(E(h.id),U(h.value),setTimeout(()=>{var $;return($=Z.current)==null?void 0:$.select()},0))}function R(h){if(h.key==="Enter"||i.includes(h.key)){h.preventDefault(),O(B)&&A("");return}if(h.key==="Backspace"&&B===""&&C.length>0){h.preventDefault();const $=C[C.length-1];K($.id)}}function te(h,$){if(h.key==="Enter"){h.preventDefault(),w($,k),setTimeout(()=>{var q;return(q=L.current)==null?void 0:q.focus()},0);return}h.key==="Escape"&&(h.preventDefault(),E(null),U(""),setTimeout(()=>{var q;return(q=L.current)==null?void 0:q.focus()},0))}function ae(){var h;s||(h=L.current)==null||h.focus()}function ce(h){if(s)return;const $=h.clipboardData.getData("text");if(!$||!(i.some(he=>he&&$.includes(he))||$.includes(`
30
- `)))return;h.preventDefault();const ne=yc($,i);I(ne)&&A("")}function ve(){const h=B.trim();h&&O(h)&&A("")}const re=z?"var(--danger)":H?"var(--primary)":"var(--border)",X=c!==void 0&&C.length>=c;return e.jsxs("div",{className:`flex flex-col gap-2 ${l}`,children:[(m||x)&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[m&&e.jsx("span",{children:m}),x&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"})]}),e.jsxs("div",{ref:W,onClick:ae,onFocus:()=>j(!0),onBlur:h=>{var $;($=W.current)!=null&&$.contains(h.relatedTarget)||(j(!1),F!==null&&w(F,k),F===null&&ve())},style:{borderColor:re},className:`
28
+ `).replace(/<[^>]+>/g," ").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/\s+/g," ").trim():""}function Qa(r){if(!r)return[];const t=new Set,a=[],n=d=>{const f=Za(d);!f||t.has(f)||(t.add(f),a.push(f))},s=/data-username\s*=\s*["']([^"']+)["']/gi;let l;for(;(l=s.exec(r))!==null;)n(l[1]??"");const i=go(r);Xa.lastIndex=0;let c;for(;(c=Xa.exec(i))!==null;)n(c[1]??"");return a}function vo(r){const t=String(r.name??"").trim();return t||String(r.username??"").trim()||"usuario"}function rc(r,t){const a=Qa(r);if(!a.length)return[];const n=new Map;t.forEach(i=>{i.username&&n.set(Za(i.username),i)});const s=new Set,l=[];for(const i of a){const c=n.get(i);c&&(s.has(c.userId)||(s.add(c.userId),l.push({userId:c.userId,username:c.username,email:c.email??void 0,display:c.name??c.username})))}return l}function xo(r){const t=new Set,a=[];for(const n of r)t.has(n.userId)||(t.add(n.userId),a.push(n));return a}function tc(r,t){return t?r.filter(a=>a.userId!==t):r}function yo(r){return!r||!/@/.test(r)?r:r.replace(Xa,(t,a,n,s)=>{const l=s.slice(0,n),i=l.lastIndexOf("<"),c=l.lastIndexOf(">");return i>c?t:`<span class="mention-chip" contenteditable="false" data-username="${(a??"").toLowerCase()}">${t}</span>`})}function Ur(r,t){if(t<0)return null;const a=r.ownerDocument;if(!a)return null;const n=a.createTreeWalker(r,NodeFilter.SHOW_TEXT);let s=t,l=null,i=n.nextNode();for(;i;){l=i;const c=i.data.length;if(s<=c)return{node:i,offset:s};s-=c,i=n.nextNode()}return l&&s===0?{node:l,offset:l.data.length}:null}function Ja(r,t,a){var s;const n=r.ownerDocument;if(!n||r!==t&&!r.contains(t))return-1;try{const l=n.createRange();return l.selectNodeContents(r),l.setEnd(t,a),((s=l.cloneContents().textContent)==null?void 0:s.length)??0}catch{return-1}}function wo(r,t){const{triggerIndex:a,caretIndex:n,username:s}=t;if(n<a)return null;const l=Ur(r,a),i=Ur(r,n);if(!l||!i)return null;const c=r.ownerDocument,d=c.createRange();d.setStart(l.node,l.offset),d.setEnd(i.node,i.offset),d.deleteContents();const f=vo({name:t.display,username:s}),b=c.createElement("span");b.className="mention-chip",b.setAttribute("data-username",s.toLowerCase()),t.userId&&b.setAttribute("data-userid",String(t.userId)),b.contentEditable="false",b.textContent=f,b.title=`@${s}`;const p=c.createTextNode(" ");d.insertNode(p),d.insertNode(b);const m=c.defaultView,w=m==null?void 0:m.getSelection();if(w){const k=c.createRange();k.setStart(p,p.data.length),k.collapse(!0),w.removeAllRanges(),w.addRange(k)}return{caretPlainOffset:a+f.length+1}}function No(r,t){const a=r.ownerDocument,n=a.defaultView;if(!n)return;const s=n.getSelection();if(!s)return;const l=a.createRange(),i=Ur(r,t);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(r),l.collapse(!1)),s.removeAllRanges(),s.addRange(l)}const ac={position:"relative"},nc={position:"fixed",zIndex:11050,minWidth:260,maxHeight:280,overflowY:"auto",background:"var(--bg-card, var(--bonsaif-ui-surface, #fff))",border:"1px solid var(--border, var(--bonsaif-ui-border, #d0d7de))",borderRadius:10,boxShadow:"0 12px 32px rgba(0,0,0,0.18)",padding:4},ko={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 So({value:r,onChange:t,onSearchUsers:a,onMentionsChange:n,minHeight:s,placeholder:l,className:i,maxSuggestions:c=8,searchDebounceMs:d=140,highlightInEditor:f=!1,searchCacheKey:b=""}){const p=o.useId().replace(/:/g,""),m=o.useRef(null),w=o.useRef(null),k=o.useRef(new Map),M=o.useRef(a);M.current=a;const g=o.useRef(null),[C,O]=o.useState(null),[D,z]=o.useState([]),[E,S]=o.useState(0),[U,H]=o.useState([]),[W,Y]=o.useState(!1),[Z,T]=o.useState(!1);o.useEffect(()=>{T(!0)},[]),o.useEffect(()=>{if(!C){z([]);return}const x=C.query.trim(),y=`${b}|${x.toLowerCase()||"*"}`,V=k.current.get(y);if(V){z(V),Y(!1),S(0);return}const q=new AbortController;Y(!0);const ee=window.setTimeout(()=>{(async()=>{try{const ce=await M.current(x,{signal:q.signal,limit:c});if(q.signal.aborted)return;const ve=Array.isArray(ce)?ce:[];k.current.set(y,ve),z(ve),S(0)}catch{q.signal.aborted||z([])}finally{q.signal.aborted||Y(!1)}})()},d);return()=>{q.abort(),window.clearTimeout(ee)}},[C,c,d,b]);const J=o.useRef(n);J.current=n,o.useEffect(()=>{var x;(x=J.current)==null||x.call(J,xo(U))},[U]);const B=o.useCallback(()=>{const x=oc(p);if(x.length===0)return null;const y=window.getSelection();if(y!=null&&y.rangeCount){const q=y.getRangeAt(0).startContainer;for(const ee of x)if(ee.contains(q))return ee}const V=document.activeElement;for(const q of x)if(V===q||V&&q.contains(V))return q;for(const q of x)if(q.closest('[role="dialog"]'))return q;return x[0]??null},[p]),_=o.useCallback(()=>{const x=B(),y=window.getSelection();if(!x||!y||y.rangeCount===0){O(null);return}const V=y.getRangeAt(0);if(!x.contains(V.startContainer)){O(null);return}const q=Ja(x,V.startContainer,V.startOffset);if(q<0){O(null);return}const ee=Ya(x,q);if(!ee){O(null);return}const ce=V.getBoundingClientRect();g.current={query:ee.query,caretIndex:ee.caretIndex,triggerIndex:ee.triggerIndex},O({query:ee.query,top:ce.bottom+6,left:Math.max(8,Math.min(ce.left,window.innerWidth-280))})},[B]),re=o.useCallback(x=>{t(x),_()},[t,_]);o.useEffect(()=>{const x=y=>{const V=B(),q=y.target;!V||!q||!V.contains(q)||_()};return document.addEventListener("keyup",x,!0),()=>document.removeEventListener("keyup",x,!0)},[B,_]);const Q=o.useCallback(x=>{const y=B();if(!y)return;let V=-1;const q=window.getSelection();if(q&&q.rangeCount>0){const X=q.getRangeAt(0);y.contains(X.startContainer)&&(V=Ja(y,X.startContainer,X.startOffset))}if(V<0&&g.current&&(V=g.current.caretIndex),V<0)return;const ee=Ya(y,V);if(!ee)return;const ce=wo(y,{triggerIndex:ee.triggerIndex,caretIndex:V,username:x.username,display:x.name,userId:x.userId});if(!ce)return;t(y.innerHTML);const ve={userId:x.userId,username:x.username,email:x.email??void 0,display:x.name??x.username};H(X=>{const h=new Map(X.map(L=>[L.userId,L]));return h.set(ve.userId,ve),Array.from(h.values())}),O(null),g.current=null;const te=ce.caretPlainOffset;requestAnimationFrame(()=>{requestAnimationFrame(()=>{var ae,ne;const X=B();if(!X)return;X.focus(),No(X,te);const h=window.getSelection(),L=h==null?void 0:h.anchorNode,j=L instanceof Element?L.closest(".mention-chip"):(ae=L==null?void 0:L.parentElement)==null?void 0:ae.closest(".mention-chip");if(j!=null&&j.parentNode){const he=document.createRange(),Oe=j.nextSibling;Oe&&Oe.nodeType===Node.TEXT_NODE?he.setStart(Oe,((ne=Oe.textContent)==null?void 0:ne.length)??0):he.setStartAfter(j),he.collapse(!0),h==null||h.removeAllRanges(),h==null||h.addRange(he)}})})},[B,t]);o.useEffect(()=>{const x=new Set(Qa(r).map(y=>y.toLowerCase()));H(y=>{const V=y.filter(q=>x.has(q.username.toLowerCase()));return V.length===y.length?y:V})},[r]),o.useEffect(()=>{if(!C)return;const x=y=>{const V=y.target;if(!V||m.current&&m.current.contains(V)||w.current&&w.current.contains(V))return;const q=B();q&&q.contains(V)||O(null)};return document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[C,B]);const $=o.useMemo(()=>D.slice(0,c),[D,c]);o.useEffect(()=>{if(!C)return;const x=y=>{const V=B(),q=y.target;if(!(!V||!q||!V.contains(q))&&!($.length===0&&y.key!=="Escape"))if(y.key==="ArrowDown")y.preventDefault(),y.stopPropagation(),S(ee=>(ee+1)%Math.max($.length,1));else if(y.key==="ArrowUp")y.preventDefault(),y.stopPropagation(),S(ee=>(ee-1+$.length)%Math.max($.length,1));else if(y.key==="Enter"||y.key==="Tab"){const ee=$[E];ee&&(y.preventDefault(),y.stopPropagation(),Q(ee))}else y.key==="Escape"&&(y.preventDefault(),y.stopPropagation(),O(null))};return document.addEventListener("keydown",x,!0),()=>document.removeEventListener("keydown",x,!0)},[E,B,Q,C,$]);const R=f?yo(r):r,oe=C&&Z?Je.createPortal(e.jsxs("ul",{ref:w,style:{...nc,top:C.top,left:C.left},role:"listbox","aria-label":"Menciones sugeridas",children:[W&&$.length===0&&e.jsx("li",{style:ko,children:"Buscando…"}),!W&&$.length===0&&e.jsx("li",{style:ko,children:C.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${C.query}”`}),$.map((x,y)=>{var V,q;return e.jsx("li",{children:e.jsxs("button",{type:"button",onMouseDown:ee=>{ee.preventDefault(),Q(x)},onMouseEnter:()=>S(y),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:y===E?"color-mix(in srgb, var(--primary, var(--bonsaif-ui-primary, #1f6feb)) 14%, transparent)":"transparent",color:"var(--text-main, var(--bonsaif-ui-text, #24292f))",borderRadius:6,cursor:"pointer",display:"flex",flexDirection:"column",gap:2},children:[e.jsx("span",{style:{fontWeight:600,fontSize:13},children:((V=x.name)==null?void 0:V.trim())||`@${x.username}`}),e.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[(q=x.name)!=null&&q.trim()?`@${x.username}`:null,x.email].filter(Boolean).join(" · ")||`@${x.username}`})]})},x.userId)})]}),document.body):null;return e.jsxs("div",{ref:m,style:ac,className:i,children:[e.jsx(uo,{value:R,onChange:re,placeholder:l,minHeight:s,instanceId:p}),oe]})}function sc({value:r,onChange:t,placeholder:a,minHeight:n,onSearchUsers:s,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:f,searchCacheKey:b}){return s?e.jsx(So,{value:r,onChange:t,onSearchUsers:s,onMentionsChange:l,placeholder:a,minHeight:n,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:f,searchCacheKey:b}):e.jsx(uo,{value:r,onChange:t,placeholder:a,minHeight:n})}function lc({title:r,subtitle:t,icon:a,actions:n,children:s,footer:l,className:i="",bodyClassName:c="p-4"}){const d=r||t||a||n;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:[a&&e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--primary)]",children:a}),e.jsxs("div",{className:"min-w-0",children:[r&&e.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:r}),t&&e.jsx("div",{className:"truncate text-xs text-[var(--text-muted)]",children:t})]})]}),n&&e.jsx("div",{className:"shrink-0",children:n})]}),e.jsx("div",{className:c,children:s}),l&&e.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:l})]})}const ic={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)"}},cc={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 dc({children:r,tone:t="neutral",size:a="sm",icon:n,dot:s=!1,className:l=""}){const i=ic[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 ${cc[a]} ${l}`,style:{color:i.text,background:i.bg,borderColor:i.border},children:[s&&e.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:i.text}}),n&&e.jsx("span",{className:"shrink-0",children:n}),e.jsx("span",{className:"min-w-0 truncate",children:r})]})}const Co={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)"}},uc={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"},fc={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},bc={xs:148,sm:164,md:184},pc={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 mc({value:r,options:t,onChange:a,size:n="sm",disabled:s=!1,loading:l=!1,stopPropagation:i=!1,ariaLabel:c="Cambiar estado",title:d="Cambiar estado",className:f,selectClassName:b,menuClassName:p,optionClassName:m,spinnerClassName:w}){const[k,M]=o.useState(!1),[g,C]=o.useState(!1),[O,D]=o.useState(-1),[z,E]=o.useState({}),S=o.useRef(null),U=o.useRef(null),H=o.useRef(null),W=t.find($=>$.value===r)??t[0],Y={...W!=null&&W.tone?Co[W.tone]:void 0,...W==null?void 0:W.style},Z=s||l||t.length===0,T=$=>{i&&$.stopPropagation()},J=o.useCallback(()=>{M(!1),D(-1)},[]),B=o.useCallback(()=>{const $=S.current;if(!$)return;const R=$.getBoundingClientRect(),oe=Math.max(R.width,bc[n]),x=Math.min(Math.max(t.length,1)*38+12,260),y=window.innerHeight-R.bottom,V=y<x&&R.top>y,q=Math.min(Math.max(8,R.left+R.width/2-oe/2),window.innerWidth-oe-8);E({position:"fixed",left:q,top:V?void 0:R.bottom+6,bottom:V?window.innerHeight-R.top+6:void 0,width:oe,zIndex:9999})},[t.length,n]),_=o.useCallback($=>{$.disabled||(a($.value),J())},[J,a]);o.useEffect(()=>C(!0),[]),o.useEffect(()=>{if(!k)return;B();const $=t.findIndex(R=>R.value===r);D($>=0?$:0)},[k,t,B,r]),o.useEffect(()=>{if(!k)return;function $(R){var x,y;const oe=R.target;!((x=S.current)!=null&&x.contains(oe))&&!((y=U.current)!=null&&y.contains(oe))&&J()}return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[J,k]),o.useEffect(()=>{if(k)return window.addEventListener("resize",B),window.addEventListener("scroll",B,!0),()=>{window.removeEventListener("resize",B),window.removeEventListener("scroll",B,!0)}},[k,B]),o.useEffect(()=>{if(O<0||!H.current)return;const $=H.current.children[O];$==null||$.scrollIntoView({block:"nearest"})},[O]);function re($){if(!Z){if(!k){["Enter"," ","ArrowDown","ArrowUp"].includes($.key)&&($.preventDefault(),M(!0));return}if($.key==="Escape"){$.preventDefault(),J();return}if($.key==="ArrowDown"){$.preventDefault(),D(R=>Math.min(R+1,t.length-1));return}if($.key==="ArrowUp"){$.preventDefault(),D(R=>Math.max(R-1,0));return}if($.key==="Enter"||$.key===" "){$.preventDefault();const R=t[O];R&&_(R)}}}const Q=e.jsx("div",{ref:U,role:"listbox","aria-label":c,className:hr("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",p),style:{...z,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:T,onMouseDown:T,onPointerDown:T,children:e.jsx("div",{ref:H,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:t.map(($,R)=>{const oe=$.value===r,x=R===O,y={...$.tone?Co[$.tone]:void 0,...$.style};return e.jsxs("button",{type:"button",role:"option","aria-selected":oe,disabled:$.disabled,onMouseEnter:()=>!$.disabled&&D(R),onMouseDown:V=>{V.preventDefault(),_($)},className:hr("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",pc[n],oe?$.className:void 0,m),style:{...oe?y:void 0,background:oe?y.background??"color-mix(in srgb, var(--primary) 12%, transparent)":x?"var(--bg-hover)":"transparent",color:oe?y.color??"var(--primary)":"var(--text-main)"},children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:oe?e.jsx(A.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:S,className:hr("relative inline-flex shrink-0 items-center",f),onKeyDown:re,onClick:T,onPointerDown:T,children:[e.jsx("button",{type:"button",disabled:Z,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":k,title:d,onClick:()=>!Z&&M($=>!$),className:hr("inline-flex items-center rounded-full border border-transparent font-medium leading-none outline-none transition-colors hover:border-current focus:border-current disabled:cursor-wait disabled:opacity-70",uc[n],W==null?void 0:W.className,b),style:Y,children:e.jsx("span",{className:"min-w-0 truncate",children:(W==null?void 0:W.label)??r})}),e.jsx(A.HiChevronDown,{"aria-hidden":"true",className:hr("pointer-events-none absolute opacity-70 transition-transform",fc[n],k?"rotate-180":"rotate-0")}),l&&e.jsx("span",{"aria-hidden":"true",className:hr("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",w)}),k&&g&&Je.createPortal(Q,document.body)]})}function hc({tabs:r,activeTabId:t,defaultActiveTabId:a,onTabChange:n,ariaLabel:s="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:d=""}){const f=r.find(k=>!k.disabled)??r[0],b=t??a??(f==null?void 0:f.id),p=r.find(k=>k.id===b)??f,m=k=>{k.disabled||n==null||n(k.id)},w=k=>{const M=r.filter(C=>!C.disabled);if(!M.length||!p)return;const g=M.findIndex(C=>C.id===p.id);(k.key==="ArrowRight"||k.key==="ArrowDown")&&(k.preventDefault(),m(M[(g+1)%M.length])),(k.key==="ArrowLeft"||k.key==="ArrowUp")&&(k.preventDefault(),m(M[(g-1+M.length)%M.length])),k.key==="Home"&&(k.preventDefault(),m(M[0])),k.key==="End"&&(k.preventDefault(),m(M[M.length-1]))};return e.jsxs("div",{className:i,children:[e.jsx("div",{role:"tablist","aria-label":s,onKeyDown:w,className:`flex min-w-0 gap-1 overflow-x-auto ${l==="underline"?"border-b border-[var(--border)]":"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-1"} ${c}`,children:r.map(k=>{const M=k.id===(p==null?void 0:p.id);return e.jsxs("button",{type:"button",role:"tab","aria-selected":M,"aria-controls":`${k.id}-panel`,id:`${k.id}-tab`,disabled:k.disabled,tabIndex:M?0:-1,onClick:()=>m(k),className:`inline-flex min-h-8 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap px-2.5 text-sm font-semibold transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 ${l==="underline"?"border-b-2":"rounded-md border"}`,style:{color:M?"var(--primary)":"var(--text-muted)",borderColor:M?"var(--primary)":"transparent",background:l==="pills"&&M?"var(--bg-card)":"transparent"},children:[k.icon&&e.jsx("span",{className:"shrink-0",children:k.icon}),e.jsx("span",{children:k.label}),k.badge&&e.jsx("span",{className:"shrink-0",children:k.badge})]},k.id)})}),(p==null?void 0:p.content)!==void 0&&e.jsx("div",{role:"tabpanel",id:`${p.id}-panel`,"aria-labelledby":`${p.id}-tab`,className:`pt-4 ${d}`,children:p.content})]})}function xr(...r){return r.filter(Boolean).join(" ")}function gc({steps:r,activeStepId:t,initialStepId:a,completedStepIds:n,defaultCompletedStepIds:s=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:c,allowBackNavigation:d=!0,showFooter:f=!0,previousLabel:b="Anterior",nextLabel:p="Siguiente",blockedNextLabel:m="Completa este paso",className:w="",headerClassName:k="",contentClassName:M="",footerClassName:g=""}){var te;const C=((te=r[0])==null?void 0:te.id)??"",[O,D]=o.useState(a??C),[z,E]=o.useState(s),S=t??O,U=n??z,H=o.useMemo(()=>new Set(U),[U]),W=Math.max(0,r.findIndex(X=>X.id===S)),Y=r[W]??r[0],Z=r.length<=1?100:W/(r.length-1)*100,T=X=>{n||E(X),i==null||i(X)},J=X=>{const h=r.find(L=>L.id===X);h&&(t||D(X),l==null||l(X,h))},B=X=>H.has(X),_=X=>r.slice(0,X).find(h=>!h.optional&&!H.has(h.id)),re=X=>{const h=r[X];return!h||h.disabled?!1:X===W||d&&X<W?!0:!_(X)},Q=X=>{const h=r.findIndex(L=>L.id===X);return h>=0&&re(h)},$=X=>{const h=r.findIndex(L=>L.id===X);if(h<0)return!1;if(!re(h)){const L=_(h);return L&&(c==null||c(r[h],L)),!1}return J(X),!0},R=(X=Y==null?void 0:Y.id)=>{!X||H.has(X)||T([...U,X])},oe=(X=Y==null?void 0:Y.id)=>{if(!X)return;const h=r.findIndex(j=>j.id===X),L=U.filter(j=>{const ae=r.findIndex(ne=>ne.id===j);return ae>=0&&ae<h});T(L),h>=0&&W>h&&J(X)},x=()=>W<=0?!1:$(r[W-1].id),y=()=>{const X=r[W+1];return X?$(X.id):!1},V={activeStep:Y,activeIndex:W,completedStepIds:U,isCompleted:B,isUnlocked:Q,completeStep:R,uncompleteStep:oe,goToStep:$,goNext:y,goPrevious:x};if(!Y)return null;const q=r[W+1],ee=W>0,ce=q?Q(q.id):!1,ve=typeof Y.content=="function"?Y.content(V):Y.content;return e.jsxs("section",{className:xr("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",w),children:[e.jsxs("div",{className:xr("border-b border-[var(--border)] bg-[var(--bg-input)]",k),children:[e.jsx("div",{className:"relative h-1 overflow-hidden bg-[var(--border)]/55",children:e.jsx("div",{className:"h-full rounded-r-full bg-[var(--primary)] transition-[width] duration-500 ease-out",style:{width:`${Z}%`}})}),e.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${r.length}, minmax(0, 1fr))`},children:r.map((X,h)=>{const L=X.id===Y.id,j=B(X.id),ae=re(h),ne=_(h);return e.jsxs("button",{type:"button",disabled:!ae,"aria-current":L?"step":void 0,"aria-disabled":!ae,title:!ae&&ne?`Completa ${ne.title}`:X.title,onClick:()=>$(X.id),className:xr("group relative min-h-16 min-w-0 overflow-hidden rounded-md border p-3 text-left transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/35 disabled:cursor-not-allowed",L&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",j&&!L&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!L&&!j&&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:xr("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",L&&"scale-x-100")}),e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:xr("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",L&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",j&&!L&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!j&&!L&&ae&&"border-[var(--border)] text-[var(--text-muted)]",!ae&&"border-[var(--border)] text-[var(--text-muted)]"),children:j?e.jsx(A.HiCheck,{className:"h-4 w-4"}):ae?h+1:e.jsx(A.HiLockClosed,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:xr("block truncate text-xs font-semibold transition-colors duration-200",L?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[h+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:xr("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",M),children:ve},Y.id),f&&e.jsxs("div",{className:xr("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",g),children:[e.jsx(Pe,{variant:"secondary",height:38,padding:"0 14px",icon:e.jsx(A.HiChevronLeft,{}),disabled:!ee,onClick:x,children:b}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[e.jsxs("span",{children:["Paso ",W+1," de ",r.length]}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),e.jsxs("span",{children:[U.length," completados"]})]}),e.jsx(Pe,{height:38,padding:"0 14px",icon:e.jsx(A.HiChevronRight,{}),disabled:!q||!ce,onClick:y,children:q&&!ce?m:p})]})]})}const vc={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"},xc={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function yc(r,t){if(r){if(typeof r=="function"){r(t);return}r.current=t}}function wc(r,t){return r!==void 0?String(r).length:t!==void 0?String(t).length:0}const Eo=o.forwardRef(function({className:t="",wrapperClassName:a="",size:n="md",resize:s="vertical",autoResize:l=!1,minRows:i,maxRows:c,showCount:d=!1,maxCount:f,status:b="default",icon:p,action:m,style:w,value:k,defaultValue:M,maxLength:g,onInput:C,...O},D){const z=o.useRef(null),E=wc(k,M),S=f??g,U=!!(p||m||d),H=b==="error"?"var(--danger)":b==="success"?"#16a34a":"var(--border)",W={...w??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},Y=()=>{const T=z.current;!T||!l||(T.style.height="auto",T.style.height=`${T.scrollHeight}px`)};o.useEffect(Y,[l,k]);const Z=e.jsx("textarea",{...O,ref:T=>{z.current=T,yc(D,T)},value:k,defaultValue:M,maxLength:g,"aria-invalid":b==="error"||O["aria-invalid"],onInput:T=>{Y(),C==null||C(T)},style:{...W,borderColor:H},className:`w-full rounded-lg border bg-[var(--bg-input)] text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-60 ${vc[n]} ${xc[l?"none":s]} ${p?"pl-8":""} ${m?"pr-10":""} ${t}`});return U?e.jsxs("span",{className:`relative block ${a}`,children:[p&&e.jsx("span",{className:"pointer-events-none absolute left-2.5 top-2.5 flex h-4 w-4 items-center justify-center text-[var(--text-muted)]",children:p}),Z,m&&e.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:m}),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:[E,S?`/${S}`:""]})]}):Z});function Nc({label:r,containerClassName:t="",helperText:a,error:n,labelAction:s,required:l,className:i="",status:c,...d}){return e.jsx(ro,{label:r,required:l,helperText:a,error:n,labelAction:s,className:t,children:e.jsx(Eo,{...d,required:l,status:n?"error":c,className:`w-full ${i}`})})}const Mo=[{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 kc(r){return Mo[r%Mo.length]}let Sc=0;function Ra(){return++Sc}function To(r,t){return t?t instanceof RegExp?t.test(r):t(r):!0}function Cc(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ec(r,t){const a=t.filter(Boolean);if(a.length===0)return[r.trim()].filter(Boolean);const n=new RegExp(`${a.map(s=>Cc(s)).join("|")}|\\r?\\n`,"g");return r.split(n).map(s=>s.trim()).filter(Boolean)}function Mc({value:r,defaultValue:t,onChange:a,placeholder:n="Escribe y presiona Enter…",disabled:s=!1,className:l="",delimiters:i=[","],maxTags:c,allowDuplicates:d=!1,validate:f,label:b,helperText:p,error:m,required:w=!1}){const k=r!==void 0,[M,g]=o.useState(()=>(t??[]).map((h,L)=>({id:Ra(),value:h.trim(),colorIndex:L})));o.useEffect(()=>{k&&g(h=>{const L=r??[],j=new Map(h.map(ae=>[ae.value,ae]));return L.map((ae,ne)=>j.get(ae)??{id:Ra(),value:ae,colorIndex:ne})})},[k,r]);const C=M,[O,D]=o.useState(""),[z,E]=o.useState(null),[S,U]=o.useState(""),[H,W]=o.useState(!1),[Y,Z]=o.useState(!1),T=o.useRef(null),J=o.useRef(null),B=o.useRef(null),_=!!m;function re(){Z(!0),setTimeout(()=>Z(!1),400)}function Q(h){g(h),a==null||a(h.map(L=>L.value))}function $(h){let L=C,j=!1,ae=!1;for(const ne of h){const he=ne.trim();if(he){if(c!==void 0&&L.length>=c){ae=!0;break}if(!d&&L.some(Oe=>Oe.value.toLowerCase()===he.toLowerCase())){ae=!0;continue}if(!To(he,f)){ae=!0;continue}L=[...L,{id:Ra(),value:he,colorIndex:L.length}],j=!0}}return j&&Q(L),ae&&re(),j}function R(h){return $([h])}function oe(h){const L=C.filter(j=>j.id!==h);Q(L.map((j,ae)=>({...j,colorIndex:ae})))}function x(h,L){const j=L.trim();if(E(null),U(""),!j){oe(h);return}if(!(!d&&C.some(ae=>ae.id!==h&&ae.value.toLowerCase()===j.toLowerCase()))){if(!To(j,f)){re();return}Q(C.map(ae=>ae.id===h?{...ae,value:j}:ae))}}function y(h){s||(E(h.id),U(h.value),setTimeout(()=>{var L;return(L=J.current)==null?void 0:L.select()},0))}function V(h){if(h.key==="Enter"||i.includes(h.key)){h.preventDefault(),R(O)&&D("");return}if(h.key==="Backspace"&&O===""&&C.length>0){h.preventDefault();const L=C[C.length-1];oe(L.id)}}function q(h,L){if(h.key==="Enter"){h.preventDefault(),x(L,S),setTimeout(()=>{var j;return(j=T.current)==null?void 0:j.focus()},0);return}h.key==="Escape"&&(h.preventDefault(),E(null),U(""),setTimeout(()=>{var j;return(j=T.current)==null?void 0:j.focus()},0))}function ee(){var h;s||(h=T.current)==null||h.focus()}function ce(h){if(s)return;const L=h.clipboardData.getData("text");if(!L||!(i.some(he=>he&&L.includes(he))||L.includes(`
29
+ `)))return;h.preventDefault();const ae=Ec(L,i);$(ae)&&D("")}function ve(){const h=O.trim();h&&R(h)&&D("")}const te=_?"var(--danger)":H?"var(--primary)":"var(--border)",X=c!==void 0&&C.length>=c;return e.jsxs("div",{className:`flex flex-col gap-2 ${l}`,children:[(b||w)&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[b&&e.jsx("span",{children:b}),w&&e.jsx("span",{className:"text-[var(--danger)]",children:"*"})]}),e.jsxs("div",{ref:B,onClick:ee,onFocus:()=>W(!0),onBlur:h=>{var L;(L=B.current)!=null&&L.contains(h.relatedTarget)||(W(!1),z!==null&&x(z,S),z===null&&ve())},style:{borderColor:te},className:`
31
30
  flex min-h-10 flex-wrap items-center gap-1.5 rounded-lg border
32
31
  bg-[var(--bg-input)] px-2.5 py-2 transition-colors
33
32
  ${s?"cursor-not-allowed opacity-60":"cursor-text"}
@@ -40,4 +39,4 @@ ${P}`,G=new Blob(["\uFEFF"+y],{type:"text/csv;charset=utf-8;"}),ie=URL.createObj
40
39
  60% { transform: translateX(-3px); }
41
40
  80% { transform: translateX(3px); }
42
41
  }
43
- `}),C.map(h=>{const $=gc(h.colorIndex);return F===h.id?e.jsx("input",{ref:Z,value:k,disabled:s,onChange:q=>U(q.target.value),onKeyDown:q=>te(q,h.id),onBlur:()=>w(h.id,k),className:"min-w-[4rem] rounded border border-[var(--primary)] bg-transparent px-1 py-0.5 text-sm text-[var(--text-main)] outline-none",style:{width:`${Math.max(k.length+2,6)}ch`}},h.id):e.jsxs("span",{className:"inline-flex max-w-[240px] items-center gap-1 rounded-md px-2 py-0.5 text-xs font-medium",style:{backgroundColor:$.bg,color:$.text,border:`1px solid ${$.border}`},children:[e.jsx("span",{className:"truncate",children:h.value}),e.jsx("button",{type:"button","aria-label":`Editar "${h.value}"`,disabled:s,tabIndex:-1,onClick:q=>{q.stopPropagation(),S(h)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:e.jsx(T.HiPencil,{className:"h-3 w-3"})}),e.jsx("button",{type:"button","aria-label":`Eliminar "${h.value}"`,disabled:s,tabIndex:-1,onClick:q=>{q.stopPropagation(),K(h.id)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:e.jsx(T.HiXMark,{className:"h-3.5 w-3.5"})})]},h.id)}),!X&&e.jsx("input",{ref:L,value:B,disabled:s,placeholder:C.length===0?n:"",onChange:h=>A(h.target.value),onKeyDown:R,onPaste:ce,className:"min-w-[8rem] flex-1 bg-transparent text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed"})]}),z?e.jsx("span",{className:"text-xs font-medium text-[var(--danger)]",children:p}):b?e.jsx("span",{className:"text-xs font-medium text-[var(--text-muted)]",children:b}):null]})}const Nc={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function kc({checked:r,disabled:t,onCheckedChange:a,size:n="sm",className:s="",...l}){const i=Nc[n],c=r?i.width-i.thumb-i.padding*2:0;return e.jsx("button",{...l,type:"button",role:"switch","aria-checked":r,disabled:t,onClick:()=>!t&&a(!r),className:`relative inline-flex shrink-0 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/50 disabled:cursor-not-allowed disabled:opacity-50 ${s}`,style:{width:i.width,height:i.height,background:r?"color-mix(in srgb, var(--primary) 85%, transparent)":"var(--bg-input)",border:r?"1px solid color-mix(in srgb, var(--primary) 55%, transparent)":"1px solid var(--border)"},children:e.jsx("span",{className:"absolute inline-block rounded-full transition-transform",style:{width:i.thumb,height:i.thumb,left:i.padding,top:"50%",transform:`translate(${c}px, -50%)`,background:r?"var(--primary-fg)":"var(--text-muted)"}})})}const ko=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),Sc=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function Cc(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 So(r){return r.classList.contains("sidebar-scroll")||r.classList.contains("showcase-nav-scroll")}function Co(r){So(r)&&r.querySelectorAll(".os-scrollbar-horizontal").forEach(t=>{t.style.display="none",t.style.height="0",t.style.pointerEvents="none"})}function Ec(r){const t=r.querySelector(Sc);return t instanceof HTMLElement?t:null}function Eo(){return o.useEffect(()=>{const r=new WeakMap;let t=0;const a=()=>{t=0,document.querySelectorAll(ko).forEach(l=>{if(!(l instanceof HTMLElement))return;if($a.OverlayScrollbars(l)){Co(l);return}if(!Cc(l))return;const c={overflow:So(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},u=Ec(l),f=u?$a.OverlayScrollbars({target:l,elements:{viewport:u}},c):$a.OverlayScrollbars(l,c);Co(l),r.set(l,f)})},n=()=>{t||(t=window.requestAnimationFrame(a))};a();const s=new MutationObserver(n);return s.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","data-overlay-scroll"]}),window.addEventListener("resize",n),()=>{t&&window.cancelAnimationFrame(t),s.disconnect(),window.removeEventListener("resize",n),document.querySelectorAll(ko).forEach(l=>{var i;l instanceof HTMLElement&&((i=r.get(l))==null||i.destroy())})}},[]),null}function yr(r){const t=r.trim();return!t||t==="/"||t==="/."?"":(t.startsWith("/")?t:`/${t}`).replace(/\/+$/,"")}function Mo(r){try{const t=new URL(r);return yr(t.pathname)}catch{return""}}function Mc(r){const t=yr(r);if(!t)return"";const a=t.match(/^\/apps\/[^/]+/i);if(a)return yr(a[0]);const n=t.split("/").filter(Boolean);return n.length===0?"":n.length>=2&&n[0].toLowerCase()==="apps"?yr(`/${n[0]}/${n[1]}`):new Set(["admin","apps","apps-list","tickets","my-tickets","projects","projects-calendars","dashboard","teams","clients","services","settings","profile","messages","notifications","my-access","my-registers","my-pings","security-incidents","email-inbox","webhook-config","webphone-config","vobo","auth","api","login","forbidden","unauthorized","change-password","reset-password","chat-widget"]).has(n[0].toLowerCase())?"":yr(`/${n[0]}`)}const Ra="primeSuiteAppUrl",Lc={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"}},Lo={xs:20,sm:28,md:36,lg:48,xl:64},$o=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],$c={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Tc="bonsaif.bot",Ac="Bonsaif Bot",Dc={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function To(r){return typeof r=="string"?r.trim():""}function Ic(r){var s;if(r!==void 0)return yr(r);const t=yr(typeof process<"u"&&((s=process.env)==null?void 0:s.NEXT_PUBLIC_BASE_PATH)||"");if(t)return t;if(typeof window>"u")return"";try{const i=new URLSearchParams(window.location.search).get(Ra)||"";i&&window.sessionStorage.setItem(Ra,i);const c=window.sessionStorage.getItem(Ra)||"",u=i||c;if(u){const f=Mo(u);if(f&&!/^\/admin(\/|$)/i.test(f))return f}}catch{}const a=window.__NEXT_DATA__,n=(a==null?void 0:a.assetPrefix)||"";if(n){const l=n.startsWith("http")?Mo(n):yr(n);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return Mc(window.location.pathname)}function Bc(r){const t=r.split(/\s+/).map(a=>a.trim()).filter(Boolean);return t.length===0?"?":t.length===1?t[0].slice(0,1).toUpperCase():`${t[0].slice(0,1)}${t[1].slice(0,1)}`.toUpperCase()}function Oc(r){let t=0;for(const a of r)t=t*31+a.charCodeAt(0)&65535;return $o[t%$o.length]}function Hc(r,t){return r===Tc||t===Ac}function Pc(r,t){return`${r.replace(/\/$/,"")}${t}`}function Ao({userId:r,username:t,name:a,size:n="md",showName:s=!1,showTooltip:l,tooltipContent:i,fallbackLabel:c="Usuario",basePath:u,wrapperClassName:f="",labelClassName:m="",labelSize:b="xs",avatarVersion:p=0,className:x="",style:N}){const[M,g]=o.useState(!1),C=typeof r=="string"&&r.trim()&&r!=="undefined"&&r!=="null"?r.trim():"";o.useEffect(()=>{g(!1)},[C,p]);const{wh:B,text:A}=Lc[n],F=To(a)||To(t)||c,E=Bc(F),k=Ic(u),U=Hc(t,a),H=Pc(k,"/favicon.svg"),j=o.useMemo(()=>{if(!C)return"";const W=new URLSearchParams;W.set("size",String(Lo[n])),p&&W.set("v",String(p));const z=W.toString();return`${k}/api/user/avatar/${encodeURIComponent(C)}${z?`?${z}`:""}`},[p,k,C,n]),Y=Lo[n],Q=U?e.jsx("span",{className:`${B} ${Dc[n]} rounded-full flex items-center justify-center bg-[#071f1a] ring-1 ring-emerald-400/35 shadow-[0_0_0_1px_rgba(255,255,255,0.06)] flex-shrink-0 ${x}`,style:N,children:e.jsx("img",{src:H,alt:F,width:Y,height:Y,className:"h-full w-full object-contain"})}):j&&!M?e.jsx("img",{src:j,alt:F,width:Y,height:Y,className:`${B} rounded-full object-cover flex-shrink-0 ${x}`,style:N,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>g(!0)},`${C}-${p}`):e.jsx("span",{className:`${B} ${Oc(F)} ${A} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${x}`,style:N,title:F,children:E});if(s)return e.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${f}`,children:[Q,e.jsx("span",{className:`min-w-0 truncate ${$c[b]} font-medium text-[var(--text-main)] ${m}`,title:F,children:F})]});const L=l??!0,Z=i??F;return L&&Z?e.jsx(jr,{as:"span",content:Z,className:`inline-flex flex-shrink-0 ${f}`,children:Q}):Q}function Fc({href:r,className:t,children:a}){return e.jsx("a",{href:r,className:t,children:a})}function zc(r){return r.reduce((t,a)=>{const n=a.section??"Principal";return t[n]=[...t[n]??[],a],t},{})}function Do({children:r,navItems:t=[],currentPath:a=typeof window>"u"?"/":window.location.pathname,user:n,appName:s="Bonsaif",appLogo:l,header:i,footer:c,onLogout:u,LinkComponent:f=Fc}){const[m,b]=o.useState(!1),p=zc(t);return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[e.jsx(Eo,{}),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"})}),m&&e.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>b(!1)}),e.jsxs("aside",{className:`fixed inset-y-0 left-0 z-50 flex w-72 flex-col bg-[#071716] text-white shadow-2xl transition-transform duration-200 lg:translate-x-0 ${m?"translate-x-0":"-translate-x-full"}`,children:[e.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:l??e.jsx(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(p).map(([x,N])=>e.jsxs("div",{className:"mb-5",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-white/35",children:[e.jsx(T.HiChevronDown,{className:"h-3.5 w-3.5"}),x]}),e.jsx("div",{className:"space-y-1",children:N.map(M=>{const g=a===M.href||a.startsWith(`${M.href}/`);return e.jsxs(f,{href:M.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${g?"bg-white/10 text-white":"text-white/55 hover:bg-white/[0.06] hover:text-white/85"}`,children:[e.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:M.icon??e.jsx(T.HiHome,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate",children:M.label})]},M.href)})})]},x))})}),e.jsxs("div",{className:"border-t border-white/10 p-3",children:[n&&e.jsxs("div",{className:"mb-3 flex min-w-0 items-center gap-3 rounded-lg bg-white/[0.04] p-2",children:[e.jsx(Ao,{name:n.initials??n.name??n.email??"Usuario",size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-medium text-white",children:n.name??"Usuario"}),n.email&&e.jsx("div",{className:"truncate text-xs text-white/45",children:n.email})]})]}),u&&e.jsxs(He,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:u,children:[e.jsx(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 Io="bonsaif-ui:prime-auth-sso",_c={dashboard:"Dashboard",tickets:"Tickets",teams:"Equipos",projects:"Proyectos",clients:"Clientes",surveys:"Encuestas",profile:"Perfil",settings:"Configuración",notifications:"Notificaciones",changelog:"Historial",admin:"Inicio",users:"Usuarios",roles:"Roles",menus:"Menús",guards:"Guardias",vacations:"Vacaciones",audit:"Auditoría",positions:"Puestos",ranks:"Rangos","email-inbox":"Buzones","security-incidents":"Incidentes","guard-schedule":"Guardias"},en={dashboard:e.jsx(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 jc(r){return r.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Wc(r){return/^\d+$/.test(r)||/^[a-f0-9]{8,}$/i.test(r)}function qc(r){const t=r.split("/").filter(Boolean);if(t.length===0||t.length===1&&t[0]==="dashboard")return[];const a=decodeURIComponent(t[t.length-1]),n=t.length>1?decodeURIComponent(t[t.length-2]):void 0,s=Wc(a)&&n?n:a,l=_c[s]??jc(s);return[{label:"Inicio",href:"/"},{label:l}]}function rn(r){return(r==null?void 0:r.querySelector(":scope > .os-viewport"))??(r==null?void 0:r.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function Uc(r){const t=r.split("/").filter(Boolean),a=t[t.length-1];if(!a)return e.jsx(T.HiHome,{className:"h-5 w-5"});if(en[a])return en[a];const n=t.length>1?t[t.length-2]:"";return en[n]??e.jsx(T.HiHome,{className:"h-5 w-5"})}function Vc(r){return r.includes("primeAuthOrigin")||r.includes("primeAuthProjectKey")}function Bo(){if(typeof window>"u")return!1;if(Vc(window.location.href)){try{window.sessionStorage.setItem(Io,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Io)==="true"}catch{return!1}}function Gc({title:r,subtitle:t,action:a,meta:n,icon:s,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:u,showBreadcrumbs:f=!0,contained:m=!1}){const b=o.useRef(null),[p,x]=o.useState(!1),[N,M]=o.useState(u??"/"),[g,C]=o.useState(()=>Bo()),[B,A]=o.useState(null),F=u??N,E=c??qc(F),k=s??Uc(F),U=f&&!g&&E.length>1,H=!U;o.useEffect(()=>{u||M(window.location.pathname)},[u]),o.useEffect(()=>{C(Bo())},[]),o.useEffect(()=>{if(m){x(!1);return}let Y=null,Q=0,L=0;const Z=()=>{const ee=b.current,J=document.querySelector("[data-app-scroll='true']");return(ee==null?void 0:ee.closest(".os-viewport"))??(ee==null?void 0:ee.closest("[data-overlayscrollbars-viewport]"))??rn(J)??J??window},W=()=>{const ee=Y&&Y!==window?Y.scrollTop:window.scrollY;x(J=>J?ee>24:ee>72)},z=()=>{Y==null||Y.removeEventListener("scroll",W),Y=Z(),Y.addEventListener("scroll",W,{passive:!0}),W()};return z(),Q=window.requestAnimationFrame(z),L=window.setTimeout(z,120),()=>{window.cancelAnimationFrame(Q),window.clearTimeout(L),Y==null||Y.removeEventListener("scroll",W)}},[m]),o.useEffect(()=>{if(m){A(null);return}let Y=0;const Q=[],L=()=>{const O=b.current,K=O==null?void 0:O.parentElement,w=document.querySelector("[data-app-scroll='true']"),S=rn(w)??w;if(!O||!K||!S){A(null);return}const R=K.getBoundingClientRect(),te=window.getComputedStyle(K),ae=S.getBoundingClientRect(),ce=S instanceof HTMLElement&&S.clientWidth>0?S.clientWidth:ae.width,ve=R.left+parseFloat(te.paddingLeft||"0"),re={marginLeft:Math.round(ae.left-ve),width:Math.round(ce)};A(X=>X&&X.marginLeft===re.marginLeft&&X.width===re.width?X:re)},Z=()=>{window.cancelAnimationFrame(Y),Y=window.requestAnimationFrame(L)};Z(),window.addEventListener("resize",Z);const W=new ResizeObserver(Z),z=b.current,ee=z==null?void 0:z.parentElement,J=document.querySelector("[data-app-scroll='true']"),I=rn(J)??J;return[ee,J,I].forEach(O=>{O&&W.observe(O)}),Q.push(window.setTimeout(Z,120)),Q.push(window.setTimeout(Z,280)),()=>{window.cancelAnimationFrame(Y),window.removeEventListener("resize",Z),W.disconnect(),Q.forEach(O=>window.clearTimeout(O))}},[m]);const j={...B?{marginLeft:B.marginLeft,width:B.width}:null,"--page-header-control-height":p?"34px":"40px","--page-header-control-padding-x":p?"10px":"14px","--page-header-control-icon-left":p?"10px":"12px",background:m?"var(--bg-card)":p?"color-mix(in srgb, var(--bg-main) 82%, transparent)":"color-mix(in srgb, var(--bg-main) 58%, transparent)",backdropFilter:"saturate(1.25) blur(18px)",WebkitBackdropFilter:"saturate(1.25) blur(18px)",borderBottom:m||p?"1px solid var(--border)":"1px solid transparent",boxShadow:p?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return e.jsx("div",{ref:b,"data-page-header":"true","data-compact":p?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${m?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${l}`,style:j,children:e.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${p?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":H?"min-h-9 gap-2 px-4 py-0 sm:min-h-10 sm:gap-2.5":"min-h-10 gap-2.5 px-4 pt-0.5 sm:min-h-11 sm:gap-3"} ${i}`,children:[e.jsx("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${p||H?"gap-1":"gap-1.5 sm:gap-2"}`,children:e.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${p||H?"gap-2":"gap-2.5 sm:gap-3"}`,children:[e.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${p?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:U?"var(--text-secondary)":"var(--text-muted)"},children:k}),e.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${p?"gap-x-2 gap-y-1":"gap-x-3 gap-y-2"}`,children:[e.jsxs("div",{className:"min-w-0 flex-shrink transition-[transform] duration-300 ease-out",children:[e.jsx("h1",{className:`truncate font-bold tracking-tight transition-[font-size,line-height,color] duration-300 ease-out ${p?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:r}),t&&e.jsx("p",{"aria-hidden":p,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${p?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-5 translate-y-0 opacity-100"}`,style:{color:"var(--text-muted)"},children:t})]}),n&&e.jsx("div",{className:`page-header-meta flex min-w-0 flex-1 basis-full items-center overflow-visible transition-[gap,opacity,transform] duration-300 ease-out sm:basis-auto ${p?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:n})]})]})}),a&&e.jsx("div",{className:`page-header-actions ml-auto flex max-w-full flex-shrink-0 flex-wrap items-center justify-end self-center overflow-visible transition-[gap,min-height,opacity,transform] duration-300 ease-out ${p?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:e.jsx(Cn.Provider,{value:{compact:!0,headerAction:!0},children:a})})]})})}function Kc({children:r,currentPath:t=typeof window>"u"?"/":window.location.pathname,publicRoutes:a=["/","/login","/reset-password"],...n}){return a.includes(t)?e.jsx(e.Fragment,{children:r}):e.jsx(Do,{currentPath:t,...n,children:r})}function Oo(){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 Xc(r,t,a){try{const n=new URL(r),s=n.searchParams.get("callbackUrl");if(s){const l=new URL(s,n.origin);return l.searchParams.set("theme",t),a&&(l.searchParams.set("primeAuthOrigin",window.location.origin),l.searchParams.set("primeAuthProjectKey",a)),n.searchParams.set("callbackUrl",`${l.pathname}${l.search}${l.hash}`),n.toString()}return n.searchParams.set("theme",t),a&&(n.searchParams.set("primeAuthOrigin",window.location.origin),n.searchParams.set("primeAuthProjectKey",a)),n.toString()}catch{return r}}function Yc({name:r,src:t,projectKey:a}){const[n,s]=o.useState("system"),l=o.useRef(null);o.useEffect(()=>{s(Oo());const u=new MutationObserver(()=>s(Oo()));return u.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>u.disconnect()},[]);const i=o.useMemo(()=>Xc(t,n,a),[a,t,n]),c=o.useMemo(()=>{try{return new URL(i).origin}catch{return""}},[i]);return o.useEffect(()=>{if(!a)return;const u=a;function f(m){var x,N,M;if(m.source!==((x=l.current)==null?void 0:x.contentWindow)||c&&m.origin!==c)return;if(((N=m.data)==null?void 0:N.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!m.data.active}}));return}if(((M=m.data)==null?void 0:M.type)!=="prime-microservice:navigation")return;const b=m.data.path;if(!b||!b.startsWith("/")||b.startsWith("//"))return;const p=`/apps/${encodeURIComponent(u)}${b}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==p&&(window.history.replaceState(window.history.state,"",p),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",f),()=>{window.removeEventListener("message",f),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[c,a]),e.jsx("div",{className:"flex h-full min-h-screen flex-col bg-[var(--bg-main)]",children:e.jsx("iframe",{ref:l,src:i,title:r,className:"min-h-0 flex-1 border-0 bg-[var(--bg-main)]",allow:"clipboard-write",sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-same-origin allow-scripts",referrerPolicy:"strict-origin-when-cross-origin"})})}function Zc(){const[r,t]=o.useState(""),[a,n]=o.useState(!1),[s,l]=o.useState({width:96,height:96});return o.useEffect(()=>{let i=!1;return fetch("/api/microservices/prime-suite/chat-url",{cache:"no-store"}).then(c=>c.ok?c.json():null).then(c=>{!i&&(c!=null&&c.src)&&t(c.src)}).catch(()=>{}),()=>{i=!0}},[]),o.useEffect(()=>{const i=c=>{var f;if(((f=c.data)==null?void 0:f.type)!=="prime-suite-chat:state")return;const u=!!c.data.active;n(u),l({width:Ho(c.data.width,96,720),height:Ho(c.data.height,96,560)})};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[]),r?e.jsx("iframe",{title:"Chat Bonsaif",src:r,allow:"clipboard-write",className:"fixed bottom-0 right-0 z-[70] border-0 bg-transparent transition-[width,height] duration-200",style:{width:a?`min(${s.width}px, 100vw)`:96,height:a?`min(${s.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function Ho(r,t,a){const n=typeof r=="number"&&Number.isFinite(r)?r:t;return Math.max(t,Math.min(a,Math.ceil(n)))}function Qc(r){const t=document.documentElement,a=new MutationObserver(r);a.observe(t,{attributes:!0,attributeFilter:["class"]});const n=window.matchMedia("(prefers-color-scheme: dark)");return n.addEventListener("change",r),()=>{a.disconnect(),n.removeEventListener("change",r)}}function Jc(){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 Rc(){return"light"}function ed({position:r="bottom-center"}){const t=o.useSyncExternalStore(Qc,Jc,Rc);return e.jsx(wn.Toaster,{position:r,theme:t,richColors:!0,closeButton:!0})}function rd({title:r,subtitle:t,actions:a,loading:n=!1,empty:s=!1,emptyText:l="Sin datos para mostrar",className:i="",children:c}){return e.jsxs("div",{className:`bonsaif-chart-card w-full overflow-visible ${i}`,children:[(r||t||a)&&e.jsxs("div",{className:"bonsaif-chart-card-head",children:[e.jsx("div",{className:"bonsaif-chart-card-accent","aria-hidden":!0}),e.jsxs("div",{className:"bonsaif-chart-card-copy min-w-0",children:[r?e.jsx("div",{className:"bonsaif-chart-card-title",children:r}):null,t?e.jsx("div",{className:"bonsaif-chart-card-subtitle",children:t}):null]}),a?e.jsx("div",{className:"bonsaif-chart-card-actions shrink-0",children:a}):null]}),e.jsx("div",{className:"bonsaif-chart-card-body",children:n?e.jsx("div",{className:"flex h-48 items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-t-transparent",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"},"aria-label":"Cargando"})}):s?e.jsx("div",{className:"flex h-48 items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:l}):c})]})}const Qt=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function Po(r,t){return r.color??Qt[t%Qt.length]}function sr(r="primary"){switch(r){case"success":return"#34d399";case"warning":return"#fbbf24";case"danger":return"#f87171";case"neutral":return"var(--text-muted)";default:return"var(--primary)"}}const rr=r=>{if(!Number.isFinite(r))return"—";const t=Math.abs(r);return t>=1e9?`${(r/1e9).toFixed(1).replace(/\.0$/,"")}B`:t>=1e6?`${(r/1e6).toFixed(1).replace(/\.0$/,"")}M`:t>=1e4?`${(r/1e3).toFixed(1).replace(/\.0$/,"")}k`:r.toLocaleString(void 0,{maximumFractionDigits:2})};function xt(r){if(r==null||r==="")return null;const t=typeof r=="number"?r:Number(r);return Number.isFinite(t)?t:null}const tn={warning:70,danger:90};function Jt(r,t=tn){const a=t.warning??tn.warning,n=t.danger??tn.danger;return r>=n?"danger":r>=a?"warning":r<=0?"primary":"success"}function yt(r,t){return sr(Jt(r,t))}function Ur(r,t=0){return Number.isFinite(r)?`${r.toFixed(t)}%`:"—"}function Vr(r,t=1){if(!Number.isFinite(r))return"—";const a=r<0?"-":"",n=Math.abs(r);if(n<1024)return`${a}${Math.round(n)} B`;const s=["KB","MB","GB","TB","PB"];let l=n/1024,i=0;for(;l>=1024&&i<s.length-1;)l/=1024,i+=1;const c=l>=100?l.toFixed(0):l.toFixed(t);return`${a}${c.replace(/\.0$/,"")} ${s[i]}`}function Fo(r,t="bytes",a=1){if(!Number.isFinite(r))return"—";const n=r<0?"-":"",s=Math.abs(r),l=t==="bits"?["b/s","Kb/s","Mb/s","Gb/s","Tb/s"]:["B/s","KB/s","MB/s","GB/s","TB/s"];if(s<1024)return`${n}${Math.round(s)} ${l[0]}`;let i=s/1024,c=1;for(;i>=1024&&c<l.length-1;)i/=1024,c+=1;const u=i>=100?i.toFixed(0):i.toFixed(a);return`${n}${u.replace(/\.0$/,"")} ${l[c]}`}function Gr(r,t){var a;for(let n=r.length-1;n>=0;n-=1){const s=xt((a=r[n])==null?void 0:a[t]);if(s!==null)return s}return null}function tr({height:r}){return e.jsx("div",{className:"flex items-center justify-center",style:{height:r},"aria-busy":!0,children:e.jsx("div",{className:"h-7 w-7 animate-spin rounded-full border-2",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"}})})}function ar({height:r,text:t}){return e.jsx("div",{className:"flex items-center justify-center text-sm",style:{height:r,color:"var(--text-muted)"},children:t})}const Lr=680,$r="ease-out",td={top:18,right:8,bottom:12,left:0};function wt(r){return{...td,...r}}function Nt(r){return r.map((t,a)=>({...t,color:Po(t,a),label:t.label??t.key}))}function Rt(r,t){return!r.length||!t.length||r.every(a=>t.every(n=>xt(a[n.key])===null))}function Ye(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function kt(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function zo(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function ea(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function ad(r,t=rr){if(r==null||r==="")return"—";const a=typeof r=="number"?r:Number(r);return Number.isFinite(a)?t(a):String(r)}function _o(r){return`bonsaif-grad-${r.replace(/[^a-zA-Z0-9_-]/g,"")}`}function nd({active:r,label:t,payload:a,valueFormat:n=rr}){var c,u,f,m,b,p;if(!r||!(a!=null&&a.length))return null;const s=a.filter(x=>x.dataKey!=="base"&&x.name!=="base"&&x.value!==null&&x.value!==void 0);if(!s.length)return null;const l=((u=(c=s[0])==null?void 0:c.payload)==null?void 0:u.fullName)??((m=(f=s[0])==null?void 0:f.payload)==null?void 0:m.tooltipLabel)??((p=(b=s[0])==null?void 0:b.payload)==null?void 0:p.display),i=typeof l=="string"&&l.length>0?l:t;return e.jsxs("div",{className:"bonsaif-chart-tooltip-panel",children:[i!=null&&i!==""?e.jsx("div",{className:"bonsaif-chart-tooltip-label",children:String(i)}):null,e.jsx("div",{className:"bonsaif-chart-tooltip-items",children:s.map((x,N)=>{const M=x.payload,g=M&&typeof M.display=="number"?M.display:x.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:x.color??"var(--primary)"}}),x.name??x.dataKey]}),e.jsx("span",{className:"bonsaif-chart-tooltip-value",children:ad(g,n)})]},String(x.dataKey??x.name??N))})})]})}function Kr({valueFormat:r,content:t,cursor:a,offset:n=12,wrapperStyle:s,allowEscapeViewBox:l,reverseDirection:i,...c}){return e.jsx(ge.Tooltip,{...c,cursor:a,offset:n,allowEscapeViewBox:l??{x:!1,y:!1},reverseDirection:i??{x:!1,y:!1},wrapperStyle:{outline:"none",zIndex:60,pointerEvents:"none",overflow:"visible",...s},content:t??e.jsx(nd,{valueFormat:r})})}function jo(r,t,a){return a==null?-1:r.findIndex(n=>String(n[t])===String(a))}function Wo(r,t,a){if(a<=1)return null;const n=Math.max(0,Math.min(r,t)),s=Math.min(a-1,Math.max(r,t));return s-n<1||n===0&&s>=a-1?null:{startIndex:n,endIndex:s}}function ra(r,t,a={}){const{zoomable:n=!1,zoomMode:s="both",brushHeight:l=28,onZoomChange:i}=a,[c,u]=o.useState(null),[f,m]=o.useState(null),b=!!n&&r.length>1,p=b&&(s==="brush"||s==="both"),x=b&&(s==="drag"||s==="both"),N=o.useCallback(Q=>{u(Q),i==null||i(Q)},[i]),M=o.useCallback(()=>{m(null),N(null)},[N]),g=!!c,C=o.useMemo(()=>!c||p?r:r.slice(c.startIndex,c.endIndex+1),[r,p,c]),B=o.useCallback((Q,L)=>{const Z=jo(r,t,Q),W=jo(r,t,L);Z<0||W<0||N(Wo(Z,W,r.length))},[N,r,t]),A=o.useCallback(Q=>{x&&((Q==null?void 0:Q.activeLabel)===void 0||(Q==null?void 0:Q.activeLabel)===null||m({leftLabel:Q.activeLabel,rightLabel:Q.activeLabel}))},[x]),F=o.useCallback(Q=>{!x||!f||(Q==null?void 0:Q.activeLabel)===void 0||(Q==null?void 0:Q.activeLabel)===null||m(L=>L&&{...L,rightLabel:Q.activeLabel})},[f,x]),E=o.useCallback(()=>{if(x){if(!f||f.rightLabel===null||f.rightLabel===void 0){m(null);return}B(f.leftLabel,f.rightLabel),m(null)}},[B,f,x]),k=o.useCallback(Q=>{if(p){if(!Q){N(null);return}N(Wo(Q.startIndex??0,Q.endIndex??r.length-1,r.length))}},[N,r.length,p]),U=x?{onMouseDown:A,onMouseMove:F,onMouseUp:E,onMouseLeave:()=>{f&&E()}}:{},H=c??{startIndex:0,endIndex:Math.max(0,r.length-1)},j=e.jsxs(e.Fragment,{children:[x&&f&&f.rightLabel!==null&&f.rightLabel!==void 0?e.jsx(ge.ReferenceArea,{x1:f.leftLabel,x2:f.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,p?e.jsx(ge.Brush,{dataKey:t,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:H.startIndex,endIndex:H.endIndex,onChange:k,tickFormatter:Q=>String(Q)}):null]}),Y=p?{bottom:Math.max(l+10,36)}:void 0;return{enabled:b,showBrush:p,showDrag:x,viewData:C,isZoomed:g,resetZoom:M,chartHandlers:U,zoomNodes:j,marginExtra:Y}}function ta({visible:r,onReset:t}){return r?e.jsx("button",{type:"button",className:"bonsaif-chart-zoom-reset",onClick:t,"aria-label":"Restablecer zoom",children:"Restablecer zoom"}):null}function od({data:r,xKey:t,series:a,height:n=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:u=!0,showTooltip:f=!0,margin:m,valueFormat:b=rr,yDomain:p,ariaLabel:x="Gráfico de líneas",curve:N=!0,strokeWidth:M=2.25,zoomable:g=!1,zoomMode:C="both",brushHeight:B,onZoomChange:A}){const F=Rt(r,a),E=Nt(a),k=ra(r,t,{zoomable:g,zoomMode:C,brushHeight:B,onZoomChange:A}),U=wt({...m,...k.marginExtra});return l?e.jsx(tr,{height:n}):F?e.jsx(ar,{height:n,text:i}):e.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${s}`,role:"img","aria-label":x,style:{height:n},children:[e.jsx(ta,{visible:k.isZoomed,onReset:k.resetZoom}),e.jsx(ge.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ge.LineChart,{data:k.viewData,margin:U,...k.chartHandlers,children:[c?e.jsx(ge.CartesianGrid,{strokeDasharray:"2 8",stroke:kt(),vertical:!1}):null,e.jsx(ge.XAxis,{dataKey:t,tick:Ye(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),e.jsx(ge.YAxis,{tick:Ye(),tickLine:!1,axisLine:!1,width:44,domain:p??["auto","auto"],tickFormatter:H=>b(Number(H)),dx:-2}),f?e.jsx(Kr,{valueFormat:b,cursor:{stroke:zo(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,u?e.jsx(ge.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ea()}):null,E.map((H,j)=>e.jsx(ge.Line,{type:N?"monotone":"linear",dataKey:H.key,name:H.label,stroke:H.color,strokeWidth:j===0?M+.35:M,strokeOpacity:j===0?1:.88,isAnimationActive:!0,animationDuration:Lr,animationEasing:$r,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:H.color}},H.key)),k.zoomNodes]})})]})}function aa({data:r,xKey:t,series:a,height:n=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:u=!0,showTooltip:f=!0,margin:m,valueFormat:b=rr,yDomain:p,ariaLabel:x="Gráfico de área",stacked:N=!1,opacity:M=.22,zoomable:g=!1,zoomMode:C="both",brushHeight:B,onZoomChange:A}){const F=Rt(r,a),E=Nt(a),k=ra(r,t,{zoomable:g,zoomMode:C,brushHeight:B,onZoomChange:A}),U=wt({...m,...k.marginExtra});return l?e.jsx(tr,{height:n}):F?e.jsx(ar,{height:n,text:i}):e.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${s}`,role:"img","aria-label":x,style:{height:n},children:[e.jsx(ta,{visible:k.isZoomed,onReset:k.resetZoom}),e.jsx(ge.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ge.AreaChart,{data:k.viewData,margin:U,...k.chartHandlers,children:[e.jsx("defs",{children:E.map(H=>e.jsxs("linearGradient",{id:_o(H.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:H.color,stopOpacity:Math.min(.55,M+.28)}),e.jsx("stop",{offset:"48%",stopColor:H.color,stopOpacity:M*.5}),e.jsx("stop",{offset:"100%",stopColor:H.color,stopOpacity:0})]},H.key))}),c?e.jsx(ge.CartesianGrid,{strokeDasharray:"2 8",stroke:kt(),vertical:!1}):null,e.jsx(ge.XAxis,{dataKey:t,tick:Ye(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),e.jsx(ge.YAxis,{tick:Ye(),tickLine:!1,axisLine:!1,width:44,domain:p??["auto","auto"],tickFormatter:H=>b(Number(H)),dx:-2}),f?e.jsx(Kr,{valueFormat:b,cursor:{stroke:zo(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,u?e.jsx(ge.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ea()}):null,E.map(H=>e.jsx(ge.Area,{type:"monotone",dataKey:H.key,name:H.label,stroke:H.color,fill:`url(#${_o(H.key)})`,strokeWidth:2.25,stackId:N?"stack":void 0,isAnimationActive:!0,animationDuration:Lr,animationEasing:$r,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:H.color}},H.key)),k.zoomNodes]})})]})}function sd({data:r,xKey:t,series:a,height:n=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:u=!0,showTooltip:f=!0,margin:m,valueFormat:b=rr,yDomain:p,ariaLabel:x="Gráfico de barras",layout:N="vertical",mode:M="grouped",barRadius:g=6,categoryAxisWidth:C=64,zoomable:B=!1,zoomMode:A="both",brushHeight:F,onZoomChange:E}){const k=Rt(r,a),U=Nt(a),H=N==="horizontal",j=ra(r,t,{zoomable:B&&!H,zoomMode:A,brushHeight:F,onZoomChange:E}),Y=wt({...m,...j.marginExtra});return l?e.jsx(tr,{height:n}):k?e.jsx(ar,{height:n,text:i}):e.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${s}`,role:"img","aria-label":x,style:{height:n},children:[e.jsx(ta,{visible:j.isZoomed,onReset:j.resetZoom}),e.jsx(ge.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ge.BarChart,{data:j.viewData,margin:Y,layout:H?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,...j.chartHandlers,children:[c?e.jsx(ge.CartesianGrid,{strokeDasharray:"2 8",stroke:kt(),horizontal:!H,vertical:H}):null,H?e.jsxs(e.Fragment,{children:[e.jsx(ge.XAxis,{type:"number",tick:Ye(),tickLine:!1,axisLine:!1,tickFormatter:Q=>b(Number(Q)),domain:p??["auto","auto"]}),e.jsx(ge.YAxis,{type:"category",dataKey:t,tick:Ye(),tickLine:!1,axisLine:!1,width:C})]}):e.jsxs(e.Fragment,{children:[e.jsx(ge.XAxis,{dataKey:t,tick:Ye(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),e.jsx(ge.YAxis,{tick:Ye(),tickLine:!1,axisLine:!1,width:44,domain:p??["auto","auto"],tickFormatter:Q=>b(Number(Q)),dx:-2})]}),f?e.jsx(Kr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,u?e.jsx(ge.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ea()}):null,U.map((Q,L)=>e.jsx(ge.Bar,{dataKey:Q.key,name:Q.label,fill:Q.color,fillOpacity:L===0?1:.82,radius:H?[0,g,g,0]:[g,g,2,2],maxBarSize:20,stackId:M==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:Lr,animationEasing:$r},Q.key)),j.zoomNodes]})})]})}function ld(r){return e.jsx(Uo,{...r,variant:"pie"})}function id(r){return e.jsx(Uo,{...r,variant:"donut",innerRadius:r.innerRadius??.62,cornerRadius:r.cornerRadius??10,padAngle:r.padAngle??2})}function qo(r,t){return r==null||!Number.isFinite(r)?t:r>0&&r<=1?r*100:r}function Uo({data:r,nameKey:t,valueKey:a,height:n=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showLegend:c=!0,showTooltip:u=!0,valueFormat:f=rr,ariaLabel:m,innerRadius:b,outerRadius:p,colors:x=[...Qt],padAngle:N,cornerRadius:M,variant:g}){const C=r.map((L,Z)=>({name:String(L[t]??""),value:xt(L[a])??0,fill:x[Z%x.length],row:L})).filter(L=>L.value>0),B=!C.length,A=g==="donut",F=C.length,E=qo(b,A?62:12),k=qo(p,78),U=Math.min(N??(A?2:3),Math.max(.5,10/Math.max(1,F))),H=Math.min(M??(A?10:8),Math.max(2,36/Math.max(1,F)));if(l)return e.jsx(tr,{height:n});if(B)return e.jsx(ar,{height:n,text:i});const j=C.reduce((L,Z)=>L+Z.value,0),Y=c?Math.min(96,28+Math.ceil(F/3)*22):0,Q=Math.max(140,n-Y);return e.jsx("div",{className:`bonsaif-chart bonsaif-${g}-chart w-full ${s}`,role:"img","aria-label":m??(g==="donut"?"Donut chart":"Pie chart"),style:{height:n},children:e.jsxs("div",{className:"bonsaif-pie-layout",children:[e.jsx("div",{className:"bonsaif-pie-plot",style:{height:Q},children:e.jsx(ge.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ge.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[u?e.jsx(Kr,{valueFormat:f,isAnimationActive:!1}):null,e.jsx(ge.Pie,{data:C,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${E}%`,outerRadius:`${k}%`,startAngle:90,endAngle:-270,paddingAngle:U,cornerRadius:H,minAngle:F>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:Lr,animationEasing:$r,label:!1,activeShape:cd,children:C.map(L=>e.jsx(ge.Cell,{fill:L.fill},L.name))}),A?e.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:f(j)}):null]})})}),c?e.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:C.map(L=>e.jsxs("li",{className:"bonsaif-pie-legend-item",children:[e.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:L.fill},"aria-hidden":!0}),e.jsx("span",{className:"bonsaif-pie-legend-label",title:L.name,children:L.name}),e.jsx("span",{className:"bonsaif-pie-legend-value",children:f(L.value)})]},L.name))}):null]})})}function cd(r){const{outerRadius:t=0,...a}=r;return e.jsx(ge.Sector,{...a,outerRadius:Number(t)+4,stroke:"var(--bg-card)",strokeWidth:2})}function dd({data:r,dataKey:t,width:a="100%",height:n=36,tone:s="primary",color:l,fill:i=!0,className:c="",ariaLabel:u="Sparkline"}){const f=l??sr(s),m=r.map(k=>xt(k[t])).filter(k=>k!==null);if(m.length<2)return e.jsx("div",{className:c,style:{width:a,height:n,color:"var(--text-muted)"},"aria-label":u});const b=120,p=36,x=3,N=1,M=Math.min(...m),C=Math.max(...m)-M||1,B=m.map((k,U)=>{const H=N+U/(m.length-1)*(b-N*2),j=p-x-(k-M)/C*(p-x*2);return{x:H,y:j}}),A=B.map((k,U)=>`${U===0?"M":"L"}${k.x.toFixed(2)} ${k.y.toFixed(2)}`).join(" "),F=`${A} L${B[B.length-1].x.toFixed(2)} ${p} L${B[0].x.toFixed(2)} ${p} Z`,E=`bonsaif-spark-${t.replace(/[^a-zA-Z0-9_-]/g,"")}-${s}`;return e.jsx("div",{className:`bonsaif-sparkline ${c}`,style:{width:a,height:n},role:"img","aria-label":u,children:e.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${b} ${p}`,preserveAspectRatio:"none",focusable:"false",children:[i?e.jsx("defs",{children:e.jsxs("linearGradient",{id:E,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:f,stopOpacity:.38}),e.jsx("stop",{offset:"100%",stopColor:f,stopOpacity:0})]})}):null,i?e.jsx("path",{d:F,fill:`url(#${E})`}):null,e.jsx("path",{d:A,fill:"none",stroke:f,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function ud({data:r,xKey:t,series:a,barSeries:n,lineSeries:s,height:l=280,className:i="",loading:c=!1,emptyText:u="Sin datos para mostrar",showGrid:f=!0,showLegend:m=!0,showTooltip:b=!0,margin:p,valueFormat:x=rr,yDomain:N,ariaLabel:M="Gráfico combinado",barRadius:g=6,zoomable:C=!1,zoomMode:B="both",brushHeight:A,onZoomChange:F}){const E=n??a.slice(0,Math.max(1,a.length-1)),k=s??(a.length>1?a.slice(-1):a.length?[a[0]]:[]),U=[...E,...k.filter(W=>!E.some(z=>z.key===W.key))],H=Rt(r,U),j=Nt(E),Y=Nt(U),Q=k.map(W=>{var ee;const z=Y.find(J=>J.key===W.key);return{...W,label:W.label??W.key,color:W.color??(z==null?void 0:z.color)??((ee=Y[0])==null?void 0:ee.color)}}),L=ra(r,t,{zoomable:C,zoomMode:B,brushHeight:A,onZoomChange:F}),Z=wt({...p,...L.marginExtra});return c?e.jsx(tr,{height:l}):H?e.jsx(ar,{height:l,text:u}):e.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":M,style:{height:l},children:[e.jsx(ta,{visible:L.isZoomed,onReset:L.resetZoom}),e.jsx(ge.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ge.ComposedChart,{data:L.viewData,margin:Z,barCategoryGap:"34%",...L.chartHandlers,children:[f?e.jsx(ge.CartesianGrid,{strokeDasharray:"2 8",stroke:kt(),vertical:!1}):null,e.jsx(ge.XAxis,{dataKey:t,tick:Ye(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),e.jsx(ge.YAxis,{tick:Ye(),tickLine:!1,axisLine:!1,width:44,domain:N??["auto","auto"],tickFormatter:W=>x(Number(W)),dx:-2}),b?e.jsx(Kr,{valueFormat:x,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,m?e.jsx(ge.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ea()}):null,j.map(W=>e.jsx(ge.Bar,{dataKey:W.key,name:W.label,fill:W.color,fillOpacity:.88,radius:[g,g,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:Lr,animationEasing:$r},W.key)),Q.map(W=>e.jsx(ge.Line,{type:"monotone",dataKey:W.key,name:W.label,stroke:W.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:Lr,animationEasing:$r,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:W.color}},W.key)),L.zoomNodes]})})]})}function fd({data:r,xKey:t,valueKey:a,typeKey:n,height:s=280,className:l="",loading:i=!1,emptyText:c="Sin datos para mostrar",showGrid:u=!0,showTooltip:f=!0,margin:m,valueFormat:b=rr,ariaLabel:p="Gráfico waterfall",increaseColor:x="#34d399",decreaseColor:N="#f87171",totalColor:M="var(--primary)"}){const g=o.useMemo(()=>bd(r,{xKey:t,valueKey:a,typeKey:n,increaseColor:x,decreaseColor:N,totalColor:M}),[r,t,a,n,x,N,M]),C=!g.length,B=wt(m);return i?e.jsx(tr,{height:s}):C?e.jsx(ar,{height:s,text:c}):e.jsx("div",{className:`bonsaif-chart bonsaif-waterfall-chart w-full ${l}`,role:"img","aria-label":p,style:{height:s},children:e.jsx(ge.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ge.BarChart,{data:g,margin:B,barCategoryGap:"42%",children:[u?e.jsx(ge.CartesianGrid,{strokeDasharray:"2 8",stroke:kt(),vertical:!1}):null,e.jsx(ge.XAxis,{dataKey:"label",tick:Ye(),tickLine:!1,axisLine:!1,interval:0,dy:6}),e.jsx(ge.YAxis,{tick:Ye(),tickLine:!1,axisLine:!1,width:44,tickFormatter:A=>b(Number(A)),dx:-2}),f?e.jsx(Kr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,e.jsx(ge.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),e.jsx(ge.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:Lr,animationEasing:$r,children:g.map(A=>e.jsx(ge.Cell,{fill:A.color},A.label))})]})})})}function bd(r,t){let a=0;return r.map((n,s)=>{const l=xt(n[t.valueKey])??0,i=t.typeKey?String(n[t.typeKey]??""):"",c=i==="total"||s===r.length-1&&i!=="increase"&&i!=="decrease";let u="increase",f=0,m=0,b=l;return c&&i==="total"?(u="total",f=0,m=Math.abs(l),b=l,a=l):c&&s===r.length-1&&!i?(u="total",f=0,m=Math.abs(a),b=a):(u=i==="decrease"||l<0?"decrease":"increase",u==="decrease"?(f=a+l,m=Math.abs(l),a=a+l):(f=a,m=Math.abs(l),a=a+l),b=l),{label:String(n[t.xKey]??""),base:f,delta:m,display:b,kind:u,color:u==="total"?t.totalColor:u==="decrease"?t.decreaseColor:t.increaseColor}})}const Xr=135*Math.PI/180,an=270*Math.PI/180;function pd({value:r,min:t=0,max:a=100,height:n=180,className:s="",loading:l=!1,empty:i=!1,emptyText:c="Sin datos para mostrar",label:u,valueFormat:f=rr,tone:m="primary",color:b,thresholds:p,ariaLabel:x="Gauge",animationDuration:N=700,thickness:M=9,showScale:g=!1}){const C=o.useId().replace(/:/g,""),B=a-t||1,A=Math.min(1,Math.max(0,(r-t)/B)),[F,E]=o.useState(N>0?0:A);if(o.useEffect(()=>{if(l||i)return;if(N<=0){E(A);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){E(A);return}let J=0,I=0;E(w=>(I=w,w));const O=performance.now(),K=w=>{const S=Math.min(1,(w-O)/N),R=1-(1-S)**3;E(I+(A-I)*R),S<1&&(J=requestAnimationFrame(K))};return J=requestAnimationFrame(K),()=>cancelAnimationFrame(J)},[A,N,l,i]),l)return e.jsx(tr,{height:n});if(i)return e.jsx(ar,{height:n,text:c});const k=100,U=108,H=72,j=b??md(r,a,m,p),Y=t+F*B,Q=Vo(k,U,H,Xr,Xr+an),L=Xr+Math.max(.001,F)*an,Z=Vo(k,U,H,Xr,L),W=na(k,U,H,Xr),z=na(k,U,H,Xr+an);return e.jsx("div",{className:`bonsaif-chart bonsaif-gauge-chart flex flex-col items-center justify-center ${s}`,style:{height:n},children:e.jsxs("svg",{viewBox:"0 0 200 168",width:"100%",height:"100%",role:"img","aria-label":x,className:"overflow-visible",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:`bonsaif-gauge-${C}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[e.jsx("stop",{offset:"0%",stopColor:j,stopOpacity:.82}),e.jsx("stop",{offset:"100%",stopColor:j,stopOpacity:1})]})}),e.jsx("path",{d:Q,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:M,strokeLinecap:"butt"}),e.jsx("path",{d:Z,fill:"none",stroke:`url(#bonsaif-gauge-${C})`,strokeWidth:M,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),e.jsx("text",{x:k,y:U-(u?4:0),textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:28,fontWeight:700,letterSpacing:"-0.04em",className:"bonsaif-chart-gauge-label",children:f(Y)}),u?e.jsx("text",{x:k,y:U+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:u}):null,g?e.jsxs(e.Fragment,{children:[e.jsx("text",{x:W.x-2,y:W.y+M+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:f(t)}),e.jsx("text",{x:z.x+2,y:z.y+M+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:f(a)})]}):null]})})}function md(r,t,a,n){if(n!=null&&n.length){const l=[...n].sort((c,u)=>c.value-u.value);let i=l[0].color;for(const c of l)r>=c.value&&(i=c.color);return i}if(a)return sr(a);const s=r/(t||1);return s>=.8?sr("success"):s>=.5?sr("warning"):sr("danger")}function na(r,t,a,n){return{x:r+a*Math.cos(n),y:t+a*Math.sin(n)}}function Vo(r,t,a,n,s){const l=na(r,t,a,n),i=na(r,t,a,s),c=s-n,u=Math.abs(c)>Math.PI?1:0;return`M ${l.x} ${l.y} A ${a} ${a} 0 ${u} 1 ${i.x} ${i.y}`}function hd({value:r,target:t,max:a,ranges:n,height:s=72,className:l="",loading:i=!1,empty:c=!1,emptyText:u="Sin datos para mostrar",label:f,subtitle:m,valueFormat:b=rr,tone:p="primary",showScale:x=!0,showStatus:N=!0,ariaLabel:M="Bullet chart"}){if(i)return e.jsx(tr,{height:s});if(c)return e.jsx(ar,{height:s,text:u});const g=a??Math.max(r,t,...(n==null?void 0:n.map(j=>j.value))??[],1)*1.05,B=[...n??[{value:g*.5,color:"color-mix(in srgb, var(--border) 72%, transparent)"},{value:g*.75,color:"color-mix(in srgb, var(--border) 48%, transparent)"},{value:g,color:"color-mix(in srgb, var(--border) 28%, transparent)"}]].sort((j,Y)=>j.value-Y.value),A=sr(p),F=Math.min(100,Math.max(0,r/g*100)),E=Math.min(100,Math.max(0,t/g*100)),k=r>=t,U=[0,.25,.5,.75,1].map(j=>j*g),H=e.jsxs("div",{className:"bonsaif-bullet-plot min-w-0 flex-1",children:[e.jsxs("div",{className:"bonsaif-bullet-track relative w-full",style:{height:Math.max(22,f?28:s*.42)},role:"img","aria-label":M,children:[e.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:B.map((j,Y)=>{const Q=Y===0?0:B[Y-1].value,L=Math.max(0,(j.value-Q)/g*100);return e.jsx("div",{style:{width:`${L}%`,background:j.color??`color-mix(in srgb, var(--border) ${70-Y*18}%, transparent)`}},Y)})}),e.jsx("div",{className:"absolute left-0 top-1/2 w-full",style:{height:"34%",transform:"translateY(-50%)"},children:e.jsx("div",{className:"bonsaif-bullet-value h-full",style:{width:`${F}%`,background:A,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${A} 35%, transparent)`}})}),e.jsx("div",{className:"bonsaif-bullet-target absolute top-1/2 z-[1]",style:{left:`${E}%`,height:"72%",width:3,transform:"translate(-50%, -50%)",background:A,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${b(t)}`})]}),x?e.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:U.map((j,Y)=>{const Q=j/g*100,L=Y===0,Z=Y===U.length-1;return e.jsxs("div",{className:"absolute top-0",style:{left:`${Q}%`,transform:L?"none":Z?"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:L?0:Z?"auto":void 0,marginRight:Z?0:void 0}}),e.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:L?"left":Z?"right":"center"},children:b(j)})]},j)})}):null]});return e.jsx("div",{className:`bonsaif-chart bonsaif-bullet-chart w-full ${l}`,children:f?e.jsxs("div",{className:"bonsaif-bullet-row flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-4",children:[e.jsxs("div",{className:"bonsaif-bullet-label shrink-0 sm:w-[7.5rem] sm:pt-1 sm:text-right",children:[e.jsx("div",{className:"text-sm font-semibold tracking-tight",style:{color:"var(--text-main)"},children:f}),m?e.jsx("div",{className:"mt-0.5 text-[11px] leading-snug",style:{color:"var(--text-muted)"},children:m}):e.jsxs("div",{className:"mt-0.5 text-[11px] tabular-nums leading-snug",style:{color:"var(--text-muted)"},children:[e.jsx("span",{style:{color:A,fontWeight:600},children:b(r)}),e.jsxs("span",{children:[" / meta ",b(t)]})]}),N?e.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:sr(k?"success":"warning")},children:k?"En meta":"Bajo meta"}):null]}),H]}):H})}function gd({data:r,value:t,timeKey:a="t",usageKey:n="usage",series:s,cores:l,height:i=220,className:c="",loading:u=!1,emptyText:f="Sin datos de CPU",showLegend:m=!1,showTooltip:b=!0,thresholds:p,label:x="CPU",ariaLabel:N="Uso de CPU"}){var E;const M=s??[{key:n,label:"Uso",color:yt(t??Gr(r,n)??0,p)}],g=t??Gr(r,n)??Gr(r,((E=M[0])==null?void 0:E.key)??n),C=!u&&(!r.length||g===null);if(u)return e.jsx(tr,{height:i});if(C)return e.jsx(ar,{height:i,text:f});const B=Math.min(100,Math.max(0,g??0)),A=Jt(B,p),F=yt(B,p);return e.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":N,children:[e.jsxs("div",{className:"bonsaif-metric-head",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"bonsaif-metric-kicker",children:[x,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:F},children:Ur(B,B<10?1:0)})]}),e.jsx("div",{className:"bonsaif-metric-badge",style:{color:F,background:`color-mix(in srgb, ${F} 14%, transparent)`},children:A==="danger"?"Crítico":A==="warning"?"Alto":"Normal"})]}),e.jsx(aa,{data:r,xKey:a,series:M.map(k=>({...k,color:k.color??F})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:m,showTooltip:b,valueFormat:k=>Ur(k,0),ariaLabel:N,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function vd({used:r,total:t,cached:a,data:n=[],timeKey:s="t",usageKey:l="usage",height:i=220,className:c="",loading:u=!1,emptyText:f="Sin datos de memoria",showHistory:m=!0,showTooltip:b=!0,thresholds:p,label:x="RAM",ariaLabel:N="Uso de memoria"}){const M=t>0?t:1,g=Math.min(100,Math.max(0,r/M*100)),C=!u&&!(Number.isFinite(r)&&Number.isFinite(t)&&t>0);if(u)return e.jsx(tr,{height:i});if(C)return e.jsx(ar,{height:i,text:f});const B=Jt(g,p),A=yt(g,p),F=Math.max(0,t-r),E=n.length>0?Gr(n,l)??g:g,k=yt(E,p),U=m&&n.length>1?Math.max(100,i-110):0;return e.jsxs("div",{className:`bonsaif-chart bonsaif-ram-chart w-full ${c}`,role:"group","aria-label":N,children:[e.jsxs("div",{className:"bonsaif-metric-head",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"bonsaif-metric-kicker",children:x}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"bonsaif-metric-value",style:{color:A},children:Ur(g,g<10?1:0)}),e.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[Vr(r)," / ",Vr(t)]})]})]}),e.jsx("div",{className:"bonsaif-metric-badge",style:{color:A,background:`color-mix(in srgb, ${A} 14%, transparent)`},children:B==="danger"?"Crítico":B==="warning"?"Alto":"Normal"})]}),e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-sm",style:{background:"color-mix(in srgb, var(--border) 55%, transparent)"},role:"progressbar","aria-valuenow":Math.round(g),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${x} ${Ur(g,0)}`,children:e.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${g}%`,background:`linear-gradient(90deg, ${A}, color-mix(in srgb, ${A} 55%, #38bdf8))`}})}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[11px] tabular-nums",style:{color:"var(--text-muted)"},children:[e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Usada"})," ",Vr(r)]}),a!=null&&Number.isFinite(a)?e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",Vr(a)]}):null,e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",Vr(F)]})]})]}),m&&n.length>1?e.jsx(aa,{data:n,xKey:s,series:[{key:l,label:"Uso",color:k}],height:U,yDomain:[0,100],showLegend:!1,showTooltip:b,valueFormat:H=>Ur(H,0),ariaLabel:`${N} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const xd="color-mix(in srgb, var(--primary) 25%, #38bdf8)",yd="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function wd({data:r,timeKey:t="t",inboundKey:a="in",outboundKey:n="out",inbound:s,outbound:l,unit:i="bytes",inboundLabel:c="Entrada",outboundLabel:u="Salida",inboundColor:f=xd,outboundColor:m=yd,height:b=240,className:p="",loading:x=!1,emptyText:N="Sin datos de red",showLegend:M=!1,showTooltip:g=!0,label:C="Network",ariaLabel:B="Tráfico de red"}){const A=s??Gr(r,a)??0,F=l??Gr(r,n)??0,E=!x&&r.length===0;if(x)return e.jsx(tr,{height:b});if(E)return e.jsx(ar,{height:b,text:N});const k=j=>Fo(j,i),H=Math.max(140,b-76);return e.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${p}`,role:"group","aria-label":B,children:[e.jsx("div",{className:"bonsaif-network-header relative z-10 mb-4 grid gap-3 border-b pb-3 sm:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]",style:{borderColor:"var(--border)"},children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"bonsaif-metric-kicker",children:C}),e.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-5 sm:max-w-lg",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[e.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:f},"aria-hidden":!0}),c]}),e.jsx("div",{className:"mt-1 truncate text-xl font-bold tabular-nums leading-tight tracking-tight",style:{color:f},title:k(A),children:k(A)})]}),e.jsxs("div",{className:"min-w-0 pl-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[e.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:m},"aria-hidden":!0}),u]}),e.jsx("div",{className:"mt-1 truncate text-lg font-semibold tabular-nums leading-tight tracking-tight opacity-95",style:{color:m},title:k(F),children:k(F)})]})]})]})}),e.jsx("div",{className:"bonsaif-network-plot relative z-0",children:e.jsx(aa,{data:r,xKey:t,series:[{key:a,label:c,color:f},{key:n,label:u,color:m}],height:H,showLegend:M,showTooltip:g,valueFormat:k,ariaLabel:B,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const Go=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],Ko=["primeSuiteOrigin","primeSuiteProjectKey"];function Nd(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const r=new URLSearchParams(window.location.search);for(const t of Go){const a=r.get(t);if(a){const n=oa(a);if(n)return n}}if(typeof sessionStorage<"u")for(const t of Ko){const a=sessionStorage.getItem(t);if(a)try{const n=new URL(a);if(n.origin&&n.origin!==window.location.origin)return n.origin}catch{const n=oa(a);if(n)return n}}if(document.referrer){const t=oa(document.referrer);if(t&&t!==window.location.origin)return t}return"*"}catch{return"*"}}function kd(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const r=new URLSearchParams(window.location.search);for(const t of Go)if(r.get(t))return"query";if(typeof sessionStorage<"u"){for(const t of Ko)if(sessionStorage.getItem(t))return"sessionStorage"}if(document.referrer){const t=oa(document.referrer);if(t&&t!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function oa(r){if(!r)return null;const t=r.trim().replace(/\/+$/,"");if(!t)return null;if(/^https?:\/\/[^/]+$/.test(t))return t;try{return new URL(t).origin}catch{return null}}function Sd(r){const[t,a]=o.useState({}),[n,s]=o.useState(!1),l=o.useCallback(f=>n||t[f]?r[f]:void 0,[r,n,t]),i=o.useCallback(f=>{a(m=>({...m,[f]:!0}))},[]),c=o.useCallback(()=>{s(!0)},[]),u=o.useCallback(()=>{a({}),s(!1)},[]);return{submitted:n,touchedFields:t,getFieldError:l,touchField:i,submit:c,reset:u}}Object.defineProperty(_,"toast",{enumerable:!0,get:()=>wn.toast}),_.Alert=Gs,_.AreaChart=aa,_.AuthShell=Do,_.BarChart=sd,_.BonsaifButton=$s,_.BonsaifUIToaster=ed,_.BulletChart=hd,_.Button=He,_.CHART_PALETTE=Qt,_.CalendarPicker=Qs,_.ChartCard=rd,_.Checkbox=Ht,_.CodeBlock=tl,_.ComboChart=ud,_.CompactFilterSelect=ol,_.CompactSearchInput=nl,_.ConfirmDialog=cl,_.CopyButton=Ia,_.CopyLinkButton=bl,_.CpuChart=gd,_.DataSheets=zl,_.DataTable=Wn,_.DateRangePicker=Wl,_.DonutChart=id,_.Drawer=Kl,_.DropdownMenu=Vl,_.DynamicDetailTabs=Us,_.EmailField=hi,_.EmptyState=vi,_.FieldLayoutEditor=Si,_.FileUpload=Ni,_.FormField=eo,_.GaugeChart=pd,_.GlobalScrollbars=Eo,_.InputField=qa,_.LineChart=od,_.LoadingState=$n,_.MentionTextEditor=vo,_.MicroserviceFrame=Yc,_.Modal=Ha,_.MouseTooltip=jr,_.MultiSelect=Ei,_.NetworkChart=wd,_.NumberField=Mi,_.PageHeader=Gc,_.PageSearchInput=Sn,_.Pagination=$i,_.PhoneField=Ai,_.PieChart=ld,_.PrimeAuthRouteShell=Kc,_.PrimeSuiteChatFrame=Zc,_.RadioGroup=Di,_.RamChart=vd,_.RichTextEditor=ec,_.SearchableSelect=Er,_.SectionPanel=rc,_.Sparkline=dd,_.StatusBadge=nc,_.StatusSelect=cc,_.StepWizard=uc,_.TableSkeleton=Ot,_.Tabs=dc,_.TagInput=wc,_.TextInput=Vt,_.Textarea=yo,_.TextareaField=hc,_.Toggle=kc,_.UserAvatar=Ao,_.WaterfallChart=fd,_.buildMentionQueryRegex=Xa,_.cn=hr,_.configureBonsaifUI=hl,_.dedupeMentions=bo,_.defaultValueFormat=rr,_.describeParentTargetOrigin=kd,_.emailFormat=Rl,_.extractMentionUsernames=Za,_.filterSelfMentions=Zi,_.formatBytes=Vr,_.formatPercent=Ur,_.formatRate=Fo,_.getBonsaifUIConfig=gl,_.getDataTablePreferencesEndpoint=Pa,_.getPlainTextOffset=Qa,_.highlightMentions=po,_.htmlToText=fo,_.insertMentionInEditor=mo,_.isValidEmail=_a,_.isValidPhone=ja,_.locateTextOffset=Zt,_.matches=oi,_.maxLength=ti,_.maxValue=ni,_.minLength=ri,_.minValue=ai,_.normalizeUsername=Ya,_.phoneCountryCodeOptions=ao,_.phoneFormat=ei,_.placeCaretAtTextOffset=ho,_.required=Jl,_.resetBonsaifUIConfig=vl,_.resolveMentions=Yi,_.resolveParentTargetOrigin=Nd,_.seriesColor=Po,_.setBonsaifDataTablePreferencesEndpoint=xl,_.toneColor=sr,_.usageColor=yt,_.usageTone=Jt,_.useValidationVisibility=Sd,_.validateForm=si,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})}));
42
+ `}),C.map(h=>{const L=kc(h.colorIndex);return z===h.id?e.jsx("input",{ref:J,value:S,disabled:s,onChange:j=>U(j.target.value),onKeyDown:j=>q(j,h.id),onBlur:()=>x(h.id,S),className:"min-w-[4rem] rounded border border-[var(--primary)] bg-transparent px-1 py-0.5 text-sm text-[var(--text-main)] outline-none",style:{width:`${Math.max(S.length+2,6)}ch`}},h.id):e.jsxs("span",{className:"inline-flex max-w-[240px] items-center gap-1 rounded-md px-2 py-0.5 text-xs font-medium",style:{backgroundColor:L.bg,color:L.text,border:`1px solid ${L.border}`},children:[e.jsx("span",{className:"truncate",children:h.value}),e.jsx("button",{type:"button","aria-label":`Editar "${h.value}"`,disabled:s,tabIndex:-1,onClick:j=>{j.stopPropagation(),y(h)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:e.jsx(A.HiPencil,{className:"h-3 w-3"})}),e.jsx("button",{type:"button","aria-label":`Eliminar "${h.value}"`,disabled:s,tabIndex:-1,onClick:j=>{j.stopPropagation(),oe(h.id)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:e.jsx(A.HiXMark,{className:"h-3.5 w-3.5"})})]},h.id)}),!X&&e.jsx("input",{ref:T,value:O,disabled:s,placeholder:C.length===0?n:"",onChange:h=>D(h.target.value),onKeyDown:V,onPaste:ce,className:"min-w-[8rem] flex-1 bg-transparent text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed"})]}),_?e.jsx("span",{className:"text-xs font-medium text-[var(--danger)]",children:m}):p?e.jsx("span",{className:"text-xs font-medium text-[var(--text-muted)]",children:p}):null]})}const Tc={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function Lc({checked:r,disabled:t,onCheckedChange:a,size:n="sm",className:s="",...l}){const i=Tc[n],c=r?i.width-i.thumb-i.padding*2:0;return e.jsx("button",{...l,type:"button",role:"switch","aria-checked":r,disabled:t,onClick:()=>!t&&a(!r),className:`relative inline-flex shrink-0 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/50 disabled:cursor-not-allowed disabled:opacity-50 ${s}`,style:{width:i.width,height:i.height,background:r?"color-mix(in srgb, var(--primary) 85%, transparent)":"var(--bg-input)",border:r?"1px solid color-mix(in srgb, var(--primary) 55%, transparent)":"1px solid var(--border)"},children:e.jsx("span",{className:"absolute inline-block rounded-full transition-transform",style:{width:i.thumb,height:i.thumb,left:i.padding,top:"50%",transform:`translate(${c}px, -50%)`,background:r?"var(--primary-fg)":"var(--text-muted)"}})})}const Lo=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),$c=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function Ac(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 Ao(r){$o(r)&&r.querySelectorAll(".os-scrollbar-horizontal").forEach(t=>{t.style.display="none",t.style.height="0",t.style.pointerEvents="none"})}function Dc(r){const t=r.querySelector($c);return t instanceof HTMLElement?t:null}function Do(){return o.useEffect(()=>{const r=new WeakMap;let t=0;const a=()=>{t=0,document.querySelectorAll(Lo).forEach(l=>{if(!(l instanceof HTMLElement))return;if($a.OverlayScrollbars(l)){Ao(l);return}if(!Ac(l))return;const c={overflow:$o(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},d=Dc(l),f=d?$a.OverlayScrollbars({target:l,elements:{viewport:d}},c):$a.OverlayScrollbars(l,c);Ao(l),r.set(l,f)})},n=()=>{t||(t=window.requestAnimationFrame(a))};a();const s=new MutationObserver(n);return s.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","data-overlay-scroll"]}),window.addEventListener("resize",n),()=>{t&&window.cancelAnimationFrame(t),s.disconnect(),window.removeEventListener("resize",n),document.querySelectorAll(Lo).forEach(l=>{var i;l instanceof HTMLElement&&((i=r.get(l))==null||i.destroy())})}},[]),null}function yr(r){const t=r.trim();return!t||t==="/"||t==="/."?"":(t.startsWith("/")?t:`/${t}`).replace(/\/+$/,"")}function Io(r){try{const t=new URL(r);return yr(t.pathname)}catch{return""}}function Ic(r){const t=yr(r);if(!t)return"";const a=t.match(/^\/apps\/[^/]+/i);if(a)return yr(a[0]);const n=t.split("/").filter(Boolean);return n.length===0?"":n.length>=2&&n[0].toLowerCase()==="apps"?yr(`/${n[0]}/${n[1]}`):new Set(["admin","apps","apps-list","tickets","my-tickets","projects","projects-calendars","dashboard","teams","clients","services","settings","profile","messages","notifications","my-access","my-registers","my-pings","security-incidents","email-inbox","webhook-config","webphone-config","vobo","auth","api","login","forbidden","unauthorized","change-password","reset-password","chat-widget"]).has(n[0].toLowerCase())?"":yr(`/${n[0]}`)}const en="primeSuiteAppUrl",Bc={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"}},Bo={xs:20,sm:28,md:36,lg:48,xl:64},Oo=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],Oc={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Hc="bonsaif.bot",Pc="Bonsaif Bot",Fc={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Ho(r){return typeof r=="string"?r.trim():""}function zc(r){var s;if(r!==void 0)return yr(r);const t=yr(typeof process<"u"&&((s=process.env)==null?void 0:s.NEXT_PUBLIC_BASE_PATH)||"");if(t)return t;if(typeof window>"u")return"";try{const i=new URLSearchParams(window.location.search).get(en)||"";i&&window.sessionStorage.setItem(en,i);const c=window.sessionStorage.getItem(en)||"",d=i||c;if(d){const f=Io(d);if(f&&!/^\/admin(\/|$)/i.test(f))return f}}catch{}const a=window.__NEXT_DATA__,n=(a==null?void 0:a.assetPrefix)||"";if(n){const l=n.startsWith("http")?Io(n):yr(n);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return Ic(window.location.pathname)}function _c(r){const t=r.split(/\s+/).map(a=>a.trim()).filter(Boolean);return t.length===0?"?":t.length===1?t[0].slice(0,1).toUpperCase():`${t[0].slice(0,1)}${t[1].slice(0,1)}`.toUpperCase()}function jc(r){let t=0;for(const a of r)t=t*31+a.charCodeAt(0)&65535;return Oo[t%Oo.length]}function Wc(r,t){return r===Hc||t===Pc}function qc(r,t){return`${r.replace(/\/$/,"")}${t}`}function Po({userId:r,username:t,name:a,size:n="md",showName:s=!1,showTooltip:l,tooltipContent:i,fallbackLabel:c="Usuario",basePath:d,wrapperClassName:f="",labelClassName:b="",labelSize:p="xs",avatarVersion:m=0,className:w="",style:k}){const[M,g]=o.useState(!1),C=typeof r=="string"&&r.trim()&&r!=="undefined"&&r!=="null"?r.trim():"";o.useEffect(()=>{g(!1)},[C,m]);const{wh:O,text:D}=Bc[n],z=Ho(a)||Ho(t)||c,E=_c(z),S=zc(d),U=Wc(t,a),H=qc(S,"/favicon.svg"),W=o.useMemo(()=>{if(!C)return"";const B=new URLSearchParams;B.set("size",String(Bo[n])),m&&B.set("v",String(m));const _=B.toString();return`${S}/api/user/avatar/${encodeURIComponent(C)}${_?`?${_}`:""}`},[m,S,C,n]),Y=Bo[n],Z=U?e.jsx("span",{className:`${O} ${Fc[n]} rounded-full flex items-center justify-center bg-[#071f1a] ring-1 ring-emerald-400/35 shadow-[0_0_0_1px_rgba(255,255,255,0.06)] flex-shrink-0 ${w}`,style:k,children:e.jsx("img",{src:H,alt:z,width:Y,height:Y,className:"h-full w-full object-contain"})}):W&&!M?e.jsx("img",{src:W,alt:z,width:Y,height:Y,className:`${O} rounded-full object-cover flex-shrink-0 ${w}`,style:k,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>g(!0)},`${C}-${m}`):e.jsx("span",{className:`${O} ${jc(z)} ${D} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${w}`,style:k,title:z,children:E});if(s)return e.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${f}`,children:[Z,e.jsx("span",{className:`min-w-0 truncate ${Oc[p]} font-medium text-[var(--text-main)] ${b}`,title:z,children:z})]});const T=l??!0,J=i??z;return T&&J?e.jsx(jr,{as:"span",content:J,className:`inline-flex flex-shrink-0 ${f}`,children:Z}):Z}function Uc({href:r,className:t,children:a}){return e.jsx("a",{href:r,className:t,children:a})}function Vc(r){return r.reduce((t,a)=>{const n=a.section??"Principal";return t[n]=[...t[n]??[],a],t},{})}function Fo({children:r,navItems:t=[],currentPath:a=typeof window>"u"?"/":window.location.pathname,user:n,appName:s="Bonsaif",appLogo:l,header:i,footer:c,onLogout:d,LinkComponent:f=Uc}){const[b,p]=o.useState(!1),m=Vc(t);return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[e.jsx(Do,{}),e.jsx("button",{type:"button","aria-label":"Abrir navegación",className:"fixed left-3 top-3 z-50 inline-flex h-9 w-9 items-center justify-center rounded-md border border-white/10 bg-black/70 text-white lg:hidden",onClick:()=>p(!0),children:e.jsx(A.HiBars3,{className:"h-5 w-5"})}),b&&e.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>p(!1)}),e.jsxs("aside",{className:`fixed inset-y-0 left-0 z-50 flex w-72 flex-col bg-[#071716] text-white shadow-2xl transition-transform duration-200 lg:translate-x-0 ${b?"translate-x-0":"-translate-x-full"}`,children:[e.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:l??e.jsx(A.HiHome,{className:"h-5 w-5"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:s}),e.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-white/70 hover:bg-white/10 lg:hidden",onClick:()=>p(!1),children:e.jsx(A.HiXMark,{className:"h-5 w-5"})})]}),e.jsx("nav",{className:"sidebar-scroll min-h-0 flex-1 overflow-y-auto px-3 py-4","data-overlay-scroll":"true",children:e.jsx("div",{className:"sidebar-scroll-body",children:Object.entries(m).map(([w,k])=>e.jsxs("div",{className:"mb-5",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-white/35",children:[e.jsx(A.HiChevronDown,{className:"h-3.5 w-3.5"}),w]}),e.jsx("div",{className:"space-y-1",children:k.map(M=>{const g=a===M.href||a.startsWith(`${M.href}/`);return e.jsxs(f,{href:M.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${g?"bg-white/10 text-white":"text-white/55 hover:bg-white/[0.06] hover:text-white/85"}`,children:[e.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:M.icon??e.jsx(A.HiHome,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate",children:M.label})]},M.href)})})]},w))})}),e.jsxs("div",{className:"border-t border-white/10 p-3",children:[n&&e.jsxs("div",{className:"mb-3 flex min-w-0 items-center gap-3 rounded-lg bg-white/[0.04] p-2",children:[e.jsx(Po,{name:n.initials??n.name??n.email??"Usuario",size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-medium text-white",children:n.name??"Usuario"}),n.email&&e.jsx("div",{className:"truncate text-xs text-white/45",children:n.email})]})]}),d&&e.jsxs(Pe,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:d,children:[e.jsx(A.HiArrowRightOnRectangle,{className:"h-4 w-4"})," Salir"]}),c]})]}),e.jsxs("div",{className:"min-h-screen lg:pl-72",children:[i,e.jsx("main",{className:"min-h-screen",children:r})]})]})}const zo="bonsaif-ui:prime-auth-sso",Gc={dashboard:"Dashboard",tickets:"Tickets",teams:"Equipos",projects:"Proyectos",clients:"Clientes",surveys:"Encuestas",profile:"Perfil",settings:"Configuración",notifications:"Notificaciones",changelog:"Historial",admin:"Inicio",users:"Usuarios",roles:"Roles",menus:"Menús",guards:"Guardias",vacations:"Vacaciones",audit:"Auditoría",positions:"Puestos",ranks:"Rangos","email-inbox":"Buzones","security-incidents":"Incidentes","guard-schedule":"Guardias"},rn={dashboard:e.jsx(A.HiChartBar,{className:"h-5 w-5"}),tickets:e.jsx(A.HiTicket,{className:"h-5 w-5"}),teams:e.jsx(A.HiUsers,{className:"h-5 w-5"}),projects:e.jsx(A.HiRectangleGroup,{className:"h-5 w-5"}),clients:e.jsx(A.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:e.jsx(A.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:e.jsx(A.HiUser,{className:"h-5 w-5"}),settings:e.jsx(A.HiCog6Tooth,{className:"h-5 w-5"}),notifications:e.jsx(A.HiBell,{className:"h-5 w-5"}),changelog:e.jsx(A.HiDocumentText,{className:"h-5 w-5"}),admin:e.jsx(A.HiShieldCheck,{className:"h-5 w-5"}),users:e.jsx(A.HiUsers,{className:"h-5 w-5"}),roles:e.jsx(A.HiShieldCheck,{className:"h-5 w-5"}),menus:e.jsx(A.HiCog6Tooth,{className:"h-5 w-5"}),guards:e.jsx(A.HiCalendarDays,{className:"h-5 w-5"}),vacations:e.jsx(A.HiCalendarDays,{className:"h-5 w-5"}),audit:e.jsx(A.HiListBullet,{className:"h-5 w-5"}),positions:e.jsx(A.HiBriefcase,{className:"h-5 w-5"}),ranks:e.jsx(A.HiListBullet,{className:"h-5 w-5"}),"email-inbox":e.jsx(A.HiInbox,{className:"h-5 w-5"}),"security-incidents":e.jsx(A.HiShieldCheck,{className:"h-5 w-5"})};function Kc(r){return r.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Xc(r){return/^\d+$/.test(r)||/^[a-f0-9]{8,}$/i.test(r)}function Yc(r){const t=r.split("/").filter(Boolean);if(t.length===0||t.length===1&&t[0]==="dashboard")return[];const a=decodeURIComponent(t[t.length-1]),n=t.length>1?decodeURIComponent(t[t.length-2]):void 0,s=Xc(a)&&n?n:a,l=Gc[s]??Kc(s);return[{label:"Inicio",href:"/"},{label:l}]}function tn(r){return(r==null?void 0:r.querySelector(":scope > .os-viewport"))??(r==null?void 0:r.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function Zc(r){const t=r.split("/").filter(Boolean),a=t[t.length-1];if(!a)return e.jsx(A.HiHome,{className:"h-5 w-5"});if(rn[a])return rn[a];const n=t.length>1?t[t.length-2]:"";return rn[n]??e.jsx(A.HiHome,{className:"h-5 w-5"})}function Qc(r){return r.includes("primeAuthOrigin")||r.includes("primeAuthProjectKey")}function _o(){if(typeof window>"u")return!1;if(Qc(window.location.href)){try{window.sessionStorage.setItem(zo,"true")}catch{}return!0}try{return window.sessionStorage.getItem(zo)==="true"}catch{return!1}}function Jc({title:r,subtitle:t,action:a,meta:n,icon:s,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:d,showBreadcrumbs:f=!0,contained:b=!1}){const p=o.useRef(null),[m,w]=o.useState(!1),[k,M]=o.useState(d??"/"),[g,C]=o.useState(()=>_o()),[O,D]=o.useState(null),z=d??k,E=c??Yc(z),S=s??Zc(z),U=f&&!g&&E.length>1,H=!U;o.useEffect(()=>{d||M(window.location.pathname)},[d]),o.useEffect(()=>{C(_o())},[]),o.useEffect(()=>{if(b){w(!1);return}let Y=null,Z=0,T=0;const J=()=>{const re=p.current,Q=document.querySelector("[data-app-scroll='true']");return(re==null?void 0:re.closest(".os-viewport"))??(re==null?void 0:re.closest("[data-overlayscrollbars-viewport]"))??tn(Q)??Q??window},B=()=>{const re=Y&&Y!==window?Y.scrollTop:window.scrollY;w(Q=>Q?re>24:re>72)},_=()=>{Y==null||Y.removeEventListener("scroll",B),Y=J(),Y.addEventListener("scroll",B,{passive:!0}),B()};return _(),Z=window.requestAnimationFrame(_),T=window.setTimeout(_,120),()=>{window.cancelAnimationFrame(Z),window.clearTimeout(T),Y==null||Y.removeEventListener("scroll",B)}},[b]),o.useEffect(()=>{if(b){D(null);return}let Y=0;const Z=[],T=()=>{const R=p.current,oe=R==null?void 0:R.parentElement,x=document.querySelector("[data-app-scroll='true']"),y=tn(x)??x;if(!R||!oe||!y){D(null);return}const V=oe.getBoundingClientRect(),q=window.getComputedStyle(oe),ee=y.getBoundingClientRect(),ce=y instanceof HTMLElement&&y.clientWidth>0?y.clientWidth:ee.width,ve=V.left+parseFloat(q.paddingLeft||"0"),te={marginLeft:Math.round(ee.left-ve),width:Math.round(ce)};D(X=>X&&X.marginLeft===te.marginLeft&&X.width===te.width?X:te)},J=()=>{window.cancelAnimationFrame(Y),Y=window.requestAnimationFrame(T)};J(),window.addEventListener("resize",J);const B=new ResizeObserver(J),_=p.current,re=_==null?void 0:_.parentElement,Q=document.querySelector("[data-app-scroll='true']"),$=tn(Q)??Q;return[re,Q,$].forEach(R=>{R&&B.observe(R)}),Z.push(window.setTimeout(J,120)),Z.push(window.setTimeout(J,280)),()=>{window.cancelAnimationFrame(Y),window.removeEventListener("resize",J),B.disconnect(),Z.forEach(R=>window.clearTimeout(R))}},[b]);const W={...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:b?"var(--bg-card)":m?"color-mix(in srgb, var(--bg-main) 82%, transparent)":"color-mix(in srgb, var(--bg-main) 58%, transparent)",backdropFilter:"saturate(1.25) blur(18px)",WebkitBackdropFilter:"saturate(1.25) blur(18px)",borderBottom:b||m?"1px solid var(--border)":"1px solid transparent",boxShadow:m?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return e.jsx("div",{ref:p,"data-page-header":"true","data-compact":m?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${b?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${l}`,style:W,children:e.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${m?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":H?"min-h-9 gap-2 px-4 py-0 sm:min-h-10 sm:gap-2.5":"min-h-10 gap-2.5 px-4 pt-0.5 sm:min-h-11 sm:gap-3"} ${i}`,children:[e.jsx("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${m||H?"gap-1":"gap-1.5 sm:gap-2"}`,children:e.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${m||H?"gap-2":"gap-2.5 sm:gap-3"}`,children:[e.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${m?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:U?"var(--text-secondary)":"var(--text-muted)"},children:S}),e.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${m?"gap-x-2 gap-y-1":"gap-x-3 gap-y-2"}`,children:[e.jsxs("div",{className:"min-w-0 flex-shrink transition-[transform] duration-300 ease-out",children:[e.jsx("h1",{className:`truncate font-bold tracking-tight transition-[font-size,line-height,color] duration-300 ease-out ${m?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:r}),t&&e.jsx("p",{"aria-hidden":m,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${m?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-5 translate-y-0 opacity-100"}`,style:{color:"var(--text-muted)"},children:t})]}),n&&e.jsx("div",{className:`page-header-meta flex min-w-0 flex-1 basis-full items-center overflow-visible transition-[gap,opacity,transform] duration-300 ease-out sm:basis-auto ${m?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:n})]})]})}),a&&e.jsx("div",{className:`page-header-actions ml-auto flex max-w-full flex-shrink-0 flex-wrap items-center justify-end self-center overflow-visible transition-[gap,min-height,opacity,transform] duration-300 ease-out ${m?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:e.jsx(En.Provider,{value:{compact:!0,headerAction:!0},children:a})})]})})}function Rc({children:r,currentPath:t=typeof window>"u"?"/":window.location.pathname,publicRoutes:a=["/","/login","/reset-password"],...n}){return a.includes(t)?e.jsx(e.Fragment,{children:r}):e.jsx(Fo,{currentPath:t,...n,children:r})}function jo(){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 ed(r,t,a){try{const n=new URL(r),s=n.searchParams.get("callbackUrl");if(s){const l=new URL(s,n.origin);return l.searchParams.set("theme",t),a&&(l.searchParams.set("primeAuthOrigin",window.location.origin),l.searchParams.set("primeAuthProjectKey",a)),n.searchParams.set("callbackUrl",`${l.pathname}${l.search}${l.hash}`),n.toString()}return n.searchParams.set("theme",t),a&&(n.searchParams.set("primeAuthOrigin",window.location.origin),n.searchParams.set("primeAuthProjectKey",a)),n.toString()}catch{return r}}function rd({name:r,src:t,projectKey:a}){const[n,s]=o.useState("system"),l=o.useRef(null);o.useEffect(()=>{s(jo());const d=new MutationObserver(()=>s(jo()));return d.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>d.disconnect()},[]);const i=o.useMemo(()=>ed(t,n,a),[a,t,n]),c=o.useMemo(()=>{try{return new URL(i).origin}catch{return""}},[i]);return o.useEffect(()=>{if(!a)return;const d=a;function f(b){var w,k,M;if(b.source!==((w=l.current)==null?void 0:w.contentWindow)||c&&b.origin!==c)return;if(((k=b.data)==null?void 0:k.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!b.data.active}}));return}if(((M=b.data)==null?void 0:M.type)!=="prime-microservice:navigation")return;const p=b.data.path;if(!p||!p.startsWith("/")||p.startsWith("//"))return;const m=`/apps/${encodeURIComponent(d)}${p}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==m&&(window.history.replaceState(window.history.state,"",m),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",f),()=>{window.removeEventListener("message",f),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[c,a]),e.jsx("div",{className:"flex h-full min-h-screen flex-col bg-[var(--bg-main)]",children:e.jsx("iframe",{ref:l,src:i,title:r,className:"min-h-0 flex-1 border-0 bg-[var(--bg-main)]",allow:"clipboard-write",sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-same-origin allow-scripts",referrerPolicy:"strict-origin-when-cross-origin"})})}function td(){const[r,t]=o.useState(""),[a,n]=o.useState(!1),[s,l]=o.useState({width:96,height:96});return o.useEffect(()=>{let i=!1;return fetch("/api/microservices/prime-suite/chat-url",{cache:"no-store"}).then(c=>c.ok?c.json():null).then(c=>{!i&&(c!=null&&c.src)&&t(c.src)}).catch(()=>{}),()=>{i=!0}},[]),o.useEffect(()=>{const i=c=>{var f;if(((f=c.data)==null?void 0:f.type)!=="prime-suite-chat:state")return;const d=!!c.data.active;n(d),l({width:Wo(c.data.width,96,720),height:Wo(c.data.height,96,560)})};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[]),r?e.jsx("iframe",{title:"Chat Bonsaif",src:r,allow:"clipboard-write",className:"fixed bottom-0 right-0 z-[70] border-0 bg-transparent transition-[width,height] duration-200",style:{width:a?`min(${s.width}px, 100vw)`:96,height:a?`min(${s.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function Wo(r,t,a){const n=typeof r=="number"&&Number.isFinite(r)?r:t;return Math.max(t,Math.min(a,Math.ceil(n)))}function ad(r){const t=document.documentElement,a=new MutationObserver(r);a.observe(t,{attributes:!0,attributeFilter:["class"]});const n=window.matchMedia("(prefers-color-scheme: dark)");return n.addEventListener("change",r),()=>{a.disconnect(),n.removeEventListener("change",r)}}function nd(){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 od(){return"light"}function sd({position:r="bottom-center"}){const t=o.useSyncExternalStore(ad,nd,od);return e.jsx(Nn.Toaster,{position:r,theme:t,richColors:!0,closeButton:!0})}function ld({title:r,subtitle:t,actions:a,loading:n=!1,empty:s=!1,emptyText:l="Sin datos para mostrar",className:i="",children:c}){return e.jsxs("div",{className:`bonsaif-chart-card w-full overflow-visible ${i}`,children:[(r||t||a)&&e.jsxs("div",{className:"bonsaif-chart-card-head",children:[e.jsx("div",{className:"bonsaif-chart-card-accent","aria-hidden":!0}),e.jsxs("div",{className:"bonsaif-chart-card-copy min-w-0",children:[r?e.jsx("div",{className:"bonsaif-chart-card-title",children:r}):null,t?e.jsx("div",{className:"bonsaif-chart-card-subtitle",children:t}):null]}),a?e.jsx("div",{className:"bonsaif-chart-card-actions shrink-0",children:a}):null]}),e.jsx("div",{className:"bonsaif-chart-card-body",children:n?e.jsx("div",{className:"flex h-48 items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-t-transparent",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"},"aria-label":"Cargando"})}):s?e.jsx("div",{className:"flex h-48 items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:l}):c})]})}const Jt=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function qo(r,t){return r.color??Jt[t%Jt.length]}function sr(r="primary"){switch(r){case"success":return"#34d399";case"warning":return"#fbbf24";case"danger":return"#f87171";case"neutral":return"var(--text-muted)";default:return"var(--primary)"}}const rr=r=>{if(!Number.isFinite(r))return"—";const t=Math.abs(r);return t>=1e9?`${(r/1e9).toFixed(1).replace(/\.0$/,"")}B`:t>=1e6?`${(r/1e6).toFixed(1).replace(/\.0$/,"")}M`:t>=1e4?`${(r/1e3).toFixed(1).replace(/\.0$/,"")}k`:r.toLocaleString(void 0,{maximumFractionDigits:2})};function wt(r){if(r==null||r==="")return null;const t=typeof r=="number"?r:Number(r);return Number.isFinite(t)?t:null}const an={warning:70,danger:90};function Rt(r,t=an){const a=t.warning??an.warning,n=t.danger??an.danger;return r>=n?"danger":r>=a?"warning":r<=0?"primary":"success"}function Nt(r,t){return sr(Rt(r,t))}function Vr(r,t=0){return Number.isFinite(r)?`${r.toFixed(t)}%`:"—"}function Gr(r,t=1){if(!Number.isFinite(r))return"—";const a=r<0?"-":"",n=Math.abs(r);if(n<1024)return`${a}${Math.round(n)} B`;const s=["KB","MB","GB","TB","PB"];let l=n/1024,i=0;for(;l>=1024&&i<s.length-1;)l/=1024,i+=1;const c=l>=100?l.toFixed(0):l.toFixed(t);return`${a}${c.replace(/\.0$/,"")} ${s[i]}`}function Uo(r,t="bytes",a=1){if(!Number.isFinite(r))return"—";const n=r<0?"-":"",s=Math.abs(r),l=t==="bits"?["b/s","Kb/s","Mb/s","Gb/s","Tb/s"]:["B/s","KB/s","MB/s","GB/s","TB/s"];if(s<1024)return`${n}${Math.round(s)} ${l[0]}`;let i=s/1024,c=1;for(;i>=1024&&c<l.length-1;)i/=1024,c+=1;const d=i>=100?i.toFixed(0):i.toFixed(a);return`${n}${d.replace(/\.0$/,"")} ${l[c]}`}function Kr(r,t){var a;for(let n=r.length-1;n>=0;n-=1){const s=wt((a=r[n])==null?void 0:a[t]);if(s!==null)return s}return null}function tr({height:r}){return e.jsx("div",{className:"flex items-center justify-center",style:{height:r},"aria-busy":!0,children:e.jsx("div",{className:"h-7 w-7 animate-spin rounded-full border-2",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"}})})}function ar({height:r,text:t}){return e.jsx("div",{className:"flex items-center justify-center text-sm",style:{height:r,color:"var(--text-muted)"},children:t})}const Tr=680,Lr="ease-out",id={top:18,right:8,bottom:12,left:0};function kt(r){return{...id,...r}}function St(r){return r.map((t,a)=>({...t,color:qo(t,a),label:t.label??t.key}))}function ea(r,t){return!r.length||!t.length||r.every(a=>t.every(n=>wt(a[n.key])===null))}function Ye(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function Ct(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function Vo(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function ra(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function cd(r,t=rr){if(r==null||r==="")return"—";const a=typeof r=="number"?r:Number(r);return Number.isFinite(a)?t(a):String(r)}function Go(r){return`bonsaif-grad-${r.replace(/[^a-zA-Z0-9_-]/g,"")}`}function dd({active:r,label:t,payload:a,valueFormat:n=rr}){var c,d,f,b,p,m;if(!r||!(a!=null&&a.length))return null;const s=a.filter(w=>w.dataKey!=="base"&&w.name!=="base"&&w.value!==null&&w.value!==void 0);if(!s.length)return null;const l=((d=(c=s[0])==null?void 0:c.payload)==null?void 0:d.fullName)??((b=(f=s[0])==null?void 0:f.payload)==null?void 0:b.tooltipLabel)??((m=(p=s[0])==null?void 0:p.payload)==null?void 0:m.display),i=typeof l=="string"&&l.length>0?l:t;return e.jsxs("div",{className:"bonsaif-chart-tooltip-panel",children:[i!=null&&i!==""?e.jsx("div",{className:"bonsaif-chart-tooltip-label",children:String(i)}):null,e.jsx("div",{className:"bonsaif-chart-tooltip-items",children:s.map((w,k)=>{const M=w.payload,g=M&&typeof M.display=="number"?M.display:w.value;return e.jsxs("div",{className:"bonsaif-chart-tooltip-row",children:[e.jsxs("span",{className:"bonsaif-chart-tooltip-name",children:[e.jsx("span",{className:"bonsaif-chart-tooltip-swatch",style:{background:w.color??"var(--primary)"}}),w.name??w.dataKey]}),e.jsx("span",{className:"bonsaif-chart-tooltip-value",children:cd(g,n)})]},String(w.dataKey??w.name??k))})})]})}function Xr({valueFormat:r,content:t,cursor:a,offset:n=12,wrapperStyle:s,allowEscapeViewBox:l,reverseDirection:i,...c}){return e.jsx(ge.Tooltip,{...c,cursor:a,offset:n,allowEscapeViewBox:l??{x:!1,y:!1},reverseDirection:i??{x:!1,y:!1},wrapperStyle:{outline:"none",zIndex:60,pointerEvents:"none",overflow:"visible",...s},content:t??e.jsx(dd,{valueFormat:r})})}function Ko(r,t,a){return a==null?-1:r.findIndex(n=>String(n[t])===String(a))}function Xo(r,t,a){if(a<=1)return null;const n=Math.max(0,Math.min(r,t)),s=Math.min(a-1,Math.max(r,t));return s-n<1||n===0&&s>=a-1?null:{startIndex:n,endIndex:s}}function ta(r,t,a={}){const{zoomable:n=!1,zoomMode:s="both",brushHeight:l=28,onZoomChange:i}=a,[c,d]=o.useState(null),[f,b]=o.useState(null),p=!!n&&r.length>1,m=p&&(s==="brush"||s==="both"),w=p&&(s==="drag"||s==="both"),k=o.useCallback(Z=>{d(Z),i==null||i(Z)},[i]),M=o.useCallback(()=>{b(null),k(null)},[k]),g=!!c,C=o.useMemo(()=>!c||m?r:r.slice(c.startIndex,c.endIndex+1),[r,m,c]),O=o.useCallback((Z,T)=>{const J=Ko(r,t,Z),B=Ko(r,t,T);J<0||B<0||k(Xo(J,B,r.length))},[k,r,t]),D=o.useCallback(Z=>{w&&((Z==null?void 0:Z.activeLabel)===void 0||(Z==null?void 0:Z.activeLabel)===null||b({leftLabel:Z.activeLabel,rightLabel:Z.activeLabel}))},[w]),z=o.useCallback(Z=>{!w||!f||(Z==null?void 0:Z.activeLabel)===void 0||(Z==null?void 0:Z.activeLabel)===null||b(T=>T&&{...T,rightLabel:Z.activeLabel})},[f,w]),E=o.useCallback(()=>{if(w){if(!f||f.rightLabel===null||f.rightLabel===void 0){b(null);return}O(f.leftLabel,f.rightLabel),b(null)}},[O,f,w]),S=o.useCallback(Z=>{if(m){if(!Z){k(null);return}k(Xo(Z.startIndex??0,Z.endIndex??r.length-1,r.length))}},[k,r.length,m]),U=w?{onMouseDown:D,onMouseMove:z,onMouseUp:E,onMouseLeave:()=>{f&&E()}}:{},H=c??{startIndex:0,endIndex:Math.max(0,r.length-1)},W=e.jsxs(e.Fragment,{children:[w&&f&&f.rightLabel!==null&&f.rightLabel!==void 0?e.jsx(ge.ReferenceArea,{x1:f.leftLabel,x2:f.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,m?e.jsx(ge.Brush,{dataKey:t,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:H.startIndex,endIndex:H.endIndex,onChange:S,tickFormatter:Z=>String(Z)}):null]}),Y=m?{bottom:Math.max(l+10,36)}:void 0;return{enabled:p,showBrush:m,showDrag:w,viewData:C,isZoomed:g,resetZoom:M,chartHandlers:U,zoomNodes:W,marginExtra:Y}}function aa({visible:r,onReset:t}){return r?e.jsx("button",{type:"button",className:"bonsaif-chart-zoom-reset",onClick:t,"aria-label":"Restablecer zoom",children:"Restablecer zoom"}):null}function ud({data:r,xKey:t,series:a,height:n=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:f=!0,margin:b,valueFormat:p=rr,yDomain:m,ariaLabel:w="Gráfico de líneas",curve:k=!0,strokeWidth:M=2.25,zoomable:g=!1,zoomMode:C="both",brushHeight:O,onZoomChange:D}){const z=ea(r,a),E=St(a),S=ta(r,t,{zoomable:g,zoomMode:C,brushHeight:O,onZoomChange:D}),U=kt({...b,...S.marginExtra});return l?e.jsx(tr,{height:n}):z?e.jsx(ar,{height:n,text:i}):e.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${s}`,role:"img","aria-label":w,style:{height:n},children:[e.jsx(aa,{visible:S.isZoomed,onReset:S.resetZoom}),e.jsx(ge.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ge.LineChart,{data:S.viewData,margin:U,...S.chartHandlers,children:[c?e.jsx(ge.CartesianGrid,{strokeDasharray:"2 8",stroke:Ct(),vertical:!1}):null,e.jsx(ge.XAxis,{dataKey:t,tick:Ye(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),e.jsx(ge.YAxis,{tick:Ye(),tickLine:!1,axisLine:!1,width:44,domain:m??["auto","auto"],tickFormatter:H=>p(Number(H)),dx:-2}),f?e.jsx(Xr,{valueFormat:p,cursor:{stroke:Vo(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?e.jsx(ge.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ra()}):null,E.map((H,W)=>e.jsx(ge.Line,{type:k?"monotone":"linear",dataKey:H.key,name:H.label,stroke:H.color,strokeWidth:W===0?M+.35:M,strokeOpacity:W===0?1:.88,isAnimationActive:!0,animationDuration:Tr,animationEasing:Lr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:H.color}},H.key)),S.zoomNodes]})})]})}function na({data:r,xKey:t,series:a,height:n=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:f=!0,margin:b,valueFormat:p=rr,yDomain:m,ariaLabel:w="Gráfico de área",stacked:k=!1,opacity:M=.22,zoomable:g=!1,zoomMode:C="both",brushHeight:O,onZoomChange:D}){const z=ea(r,a),E=St(a),S=ta(r,t,{zoomable:g,zoomMode:C,brushHeight:O,onZoomChange:D}),U=kt({...b,...S.marginExtra});return l?e.jsx(tr,{height:n}):z?e.jsx(ar,{height:n,text:i}):e.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${s}`,role:"img","aria-label":w,style:{height:n},children:[e.jsx(aa,{visible:S.isZoomed,onReset:S.resetZoom}),e.jsx(ge.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ge.AreaChart,{data:S.viewData,margin:U,...S.chartHandlers,children:[e.jsx("defs",{children:E.map(H=>e.jsxs("linearGradient",{id:Go(H.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:H.color,stopOpacity:Math.min(.55,M+.28)}),e.jsx("stop",{offset:"48%",stopColor:H.color,stopOpacity:M*.5}),e.jsx("stop",{offset:"100%",stopColor:H.color,stopOpacity:0})]},H.key))}),c?e.jsx(ge.CartesianGrid,{strokeDasharray:"2 8",stroke:Ct(),vertical:!1}):null,e.jsx(ge.XAxis,{dataKey:t,tick:Ye(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),e.jsx(ge.YAxis,{tick:Ye(),tickLine:!1,axisLine:!1,width:44,domain:m??["auto","auto"],tickFormatter:H=>p(Number(H)),dx:-2}),f?e.jsx(Xr,{valueFormat:p,cursor:{stroke:Vo(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?e.jsx(ge.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ra()}):null,E.map(H=>e.jsx(ge.Area,{type:"monotone",dataKey:H.key,name:H.label,stroke:H.color,fill:`url(#${Go(H.key)})`,strokeWidth:2.25,stackId:k?"stack":void 0,isAnimationActive:!0,animationDuration:Tr,animationEasing:Lr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:H.color}},H.key)),S.zoomNodes]})})]})}function fd({data:r,xKey:t,series:a,height:n=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:f=!0,margin:b,valueFormat:p=rr,yDomain:m,ariaLabel:w="Gráfico de barras",layout:k="vertical",mode:M="grouped",barRadius:g=6,categoryAxisWidth:C=64,zoomable:O=!1,zoomMode:D="both",brushHeight:z,onZoomChange:E}){const S=ea(r,a),U=St(a),H=k==="horizontal",W=ta(r,t,{zoomable:O&&!H,zoomMode:D,brushHeight:z,onZoomChange:E}),Y=kt({...b,...W.marginExtra});return l?e.jsx(tr,{height:n}):S?e.jsx(ar,{height:n,text:i}):e.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${s}`,role:"img","aria-label":w,style:{height:n},children:[e.jsx(aa,{visible:W.isZoomed,onReset:W.resetZoom}),e.jsx(ge.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ge.BarChart,{data:W.viewData,margin:Y,layout:H?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,...W.chartHandlers,children:[c?e.jsx(ge.CartesianGrid,{strokeDasharray:"2 8",stroke:Ct(),horizontal:!H,vertical:H}):null,H?e.jsxs(e.Fragment,{children:[e.jsx(ge.XAxis,{type:"number",tick:Ye(),tickLine:!1,axisLine:!1,tickFormatter:Z=>p(Number(Z)),domain:m??["auto","auto"]}),e.jsx(ge.YAxis,{type:"category",dataKey:t,tick:Ye(),tickLine:!1,axisLine:!1,width:C})]}):e.jsxs(e.Fragment,{children:[e.jsx(ge.XAxis,{dataKey:t,tick:Ye(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),e.jsx(ge.YAxis,{tick:Ye(),tickLine:!1,axisLine:!1,width:44,domain:m??["auto","auto"],tickFormatter:Z=>p(Number(Z)),dx:-2})]}),f?e.jsx(Xr,{valueFormat:p,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,d?e.jsx(ge.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ra()}):null,U.map((Z,T)=>e.jsx(ge.Bar,{dataKey:Z.key,name:Z.label,fill:Z.color,fillOpacity:T===0?1:.82,radius:H?[0,g,g,0]:[g,g,2,2],maxBarSize:20,stackId:M==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:Tr,animationEasing:Lr},Z.key)),W.zoomNodes]})})]})}function bd(r){return e.jsx(Zo,{...r,variant:"pie"})}function pd(r){return e.jsx(Zo,{...r,variant:"donut",innerRadius:r.innerRadius??.62,cornerRadius:r.cornerRadius??10,padAngle:r.padAngle??2})}function Yo(r,t){return r==null||!Number.isFinite(r)?t:r>0&&r<=1?r*100:r}function Zo({data:r,nameKey:t,valueKey:a,height:n=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showLegend:c=!0,showTooltip:d=!0,valueFormat:f=rr,ariaLabel:b,innerRadius:p,outerRadius:m,colors:w=[...Jt],padAngle:k,cornerRadius:M,variant:g}){const C=r.map((T,J)=>({name:String(T[t]??""),value:wt(T[a])??0,fill:w[J%w.length],row:T})).filter(T=>T.value>0),O=!C.length,D=g==="donut",z=C.length,E=Yo(p,D?62:12),S=Yo(m,78),U=Math.min(k??(D?2:3),Math.max(.5,10/Math.max(1,z))),H=Math.min(M??(D?10:8),Math.max(2,36/Math.max(1,z)));if(l)return e.jsx(tr,{height:n});if(O)return e.jsx(ar,{height:n,text:i});const W=C.reduce((T,J)=>T+J.value,0),Y=c?Math.min(96,28+Math.ceil(z/3)*22):0,Z=Math.max(140,n-Y);return e.jsx("div",{className:`bonsaif-chart bonsaif-${g}-chart w-full ${s}`,role:"img","aria-label":b??(g==="donut"?"Donut chart":"Pie chart"),style:{height:n},children:e.jsxs("div",{className:"bonsaif-pie-layout",children:[e.jsx("div",{className:"bonsaif-pie-plot",style:{height:Z},children:e.jsx(ge.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ge.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[d?e.jsx(Xr,{valueFormat:f,isAnimationActive:!1}):null,e.jsx(ge.Pie,{data:C,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${E}%`,outerRadius:`${S}%`,startAngle:90,endAngle:-270,paddingAngle:U,cornerRadius:H,minAngle:z>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:Tr,animationEasing:Lr,label:!1,activeShape:md,children:C.map(T=>e.jsx(ge.Cell,{fill:T.fill},T.name))}),D?e.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:f(W)}):null]})})}),c?e.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:C.map(T=>e.jsxs("li",{className:"bonsaif-pie-legend-item",children:[e.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:T.fill},"aria-hidden":!0}),e.jsx("span",{className:"bonsaif-pie-legend-label",title:T.name,children:T.name}),e.jsx("span",{className:"bonsaif-pie-legend-value",children:f(T.value)})]},T.name))}):null]})})}function md(r){const{outerRadius:t=0,...a}=r;return e.jsx(ge.Sector,{...a,outerRadius:Number(t)+4,stroke:"var(--bg-card)",strokeWidth:2})}function hd({data:r,dataKey:t,width:a="100%",height:n=36,tone:s="primary",color:l,fill:i=!0,className:c="",ariaLabel:d="Sparkline"}){const f=l??sr(s),b=r.map(S=>wt(S[t])).filter(S=>S!==null);if(b.length<2)return e.jsx("div",{className:c,style:{width:a,height:n,color:"var(--text-muted)"},"aria-label":d});const p=120,m=36,w=3,k=1,M=Math.min(...b),C=Math.max(...b)-M||1,O=b.map((S,U)=>{const H=k+U/(b.length-1)*(p-k*2),W=m-w-(S-M)/C*(m-w*2);return{x:H,y:W}}),D=O.map((S,U)=>`${U===0?"M":"L"}${S.x.toFixed(2)} ${S.y.toFixed(2)}`).join(" "),z=`${D} L${O[O.length-1].x.toFixed(2)} ${m} L${O[0].x.toFixed(2)} ${m} Z`,E=`bonsaif-spark-${t.replace(/[^a-zA-Z0-9_-]/g,"")}-${s}`;return e.jsx("div",{className:`bonsaif-sparkline ${c}`,style:{width:a,height:n},role:"img","aria-label":d,children:e.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${p} ${m}`,preserveAspectRatio:"none",focusable:"false",children:[i?e.jsx("defs",{children:e.jsxs("linearGradient",{id:E,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:f,stopOpacity:.38}),e.jsx("stop",{offset:"100%",stopColor:f,stopOpacity:0})]})}):null,i?e.jsx("path",{d:z,fill:`url(#${E})`}):null,e.jsx("path",{d:D,fill:"none",stroke:f,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function gd({data:r,xKey:t,series:a,barSeries:n,lineSeries:s,height:l=280,className:i="",loading:c=!1,emptyText:d="Sin datos para mostrar",showGrid:f=!0,showLegend:b=!0,showTooltip:p=!0,margin:m,valueFormat:w=rr,yDomain:k,ariaLabel:M="Gráfico combinado",barRadius:g=6,zoomable:C=!1,zoomMode:O="both",brushHeight:D,onZoomChange:z}){const E=n??a.slice(0,Math.max(1,a.length-1)),S=s??(a.length>1?a.slice(-1):a.length?[a[0]]:[]),U=[...E,...S.filter(B=>!E.some(_=>_.key===B.key))],H=ea(r,U),W=St(E),Y=St(U),Z=S.map(B=>{var re;const _=Y.find(Q=>Q.key===B.key);return{...B,label:B.label??B.key,color:B.color??(_==null?void 0:_.color)??((re=Y[0])==null?void 0:re.color)}}),T=ta(r,t,{zoomable:C,zoomMode:O,brushHeight:D,onZoomChange:z}),J=kt({...m,...T.marginExtra});return c?e.jsx(tr,{height:l}):H?e.jsx(ar,{height:l,text:d}):e.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":M,style:{height:l},children:[e.jsx(aa,{visible:T.isZoomed,onReset:T.resetZoom}),e.jsx(ge.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ge.ComposedChart,{data:T.viewData,margin:J,barCategoryGap:"34%",...T.chartHandlers,children:[f?e.jsx(ge.CartesianGrid,{strokeDasharray:"2 8",stroke:Ct(),vertical:!1}):null,e.jsx(ge.XAxis,{dataKey:t,tick:Ye(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),e.jsx(ge.YAxis,{tick:Ye(),tickLine:!1,axisLine:!1,width:44,domain:k??["auto","auto"],tickFormatter:B=>w(Number(B)),dx:-2}),p?e.jsx(Xr,{valueFormat:w,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,b?e.jsx(ge.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ra()}):null,W.map(B=>e.jsx(ge.Bar,{dataKey:B.key,name:B.label,fill:B.color,fillOpacity:.88,radius:[g,g,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:Tr,animationEasing:Lr},B.key)),Z.map(B=>e.jsx(ge.Line,{type:"monotone",dataKey:B.key,name:B.label,stroke:B.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:Tr,animationEasing:Lr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:B.color}},B.key)),T.zoomNodes]})})]})}function vd({data:r,xKey:t,valueKey:a,typeKey:n,height:s=280,className:l="",loading:i=!1,emptyText:c="Sin datos para mostrar",showGrid:d=!0,showTooltip:f=!0,margin:b,valueFormat:p=rr,ariaLabel:m="Gráfico waterfall",increaseColor:w="#34d399",decreaseColor:k="#f87171",totalColor:M="var(--primary)"}){const g=o.useMemo(()=>xd(r,{xKey:t,valueKey:a,typeKey:n,increaseColor:w,decreaseColor:k,totalColor:M}),[r,t,a,n,w,k,M]),C=!g.length,O=kt(b);return i?e.jsx(tr,{height:s}):C?e.jsx(ar,{height:s,text:c}):e.jsx("div",{className:`bonsaif-chart bonsaif-waterfall-chart w-full ${l}`,role:"img","aria-label":m,style:{height:s},children:e.jsx(ge.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ge.BarChart,{data:g,margin:O,barCategoryGap:"42%",children:[d?e.jsx(ge.CartesianGrid,{strokeDasharray:"2 8",stroke:Ct(),vertical:!1}):null,e.jsx(ge.XAxis,{dataKey:"label",tick:Ye(),tickLine:!1,axisLine:!1,interval:0,dy:6}),e.jsx(ge.YAxis,{tick:Ye(),tickLine:!1,axisLine:!1,width:44,tickFormatter:D=>p(Number(D)),dx:-2}),f?e.jsx(Xr,{valueFormat:p,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,e.jsx(ge.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),e.jsx(ge.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:Tr,animationEasing:Lr,children:g.map(D=>e.jsx(ge.Cell,{fill:D.color},D.label))})]})})})}function xd(r,t){let a=0;return r.map((n,s)=>{const l=wt(n[t.valueKey])??0,i=t.typeKey?String(n[t.typeKey]??""):"",c=i==="total"||s===r.length-1&&i!=="increase"&&i!=="decrease";let d="increase",f=0,b=0,p=l;return c&&i==="total"?(d="total",f=0,b=Math.abs(l),p=l,a=l):c&&s===r.length-1&&!i?(d="total",f=0,b=Math.abs(a),p=a):(d=i==="decrease"||l<0?"decrease":"increase",d==="decrease"?(f=a+l,b=Math.abs(l),a=a+l):(f=a,b=Math.abs(l),a=a+l),p=l),{label:String(n[t.xKey]??""),base:f,delta:b,display:p,kind:d,color:d==="total"?t.totalColor:d==="decrease"?t.decreaseColor:t.increaseColor}})}const Yr=135*Math.PI/180,nn=270*Math.PI/180;function yd({value:r,min:t=0,max:a=100,height:n=180,className:s="",loading:l=!1,empty:i=!1,emptyText:c="Sin datos para mostrar",label:d,valueFormat:f=rr,tone:b="primary",color:p,thresholds:m,ariaLabel:w="Gauge",animationDuration:k=700,thickness:M=9,showScale:g=!1}){const C=o.useId().replace(/:/g,""),O=a-t||1,D=Math.min(1,Math.max(0,(r-t)/O)),[z,E]=o.useState(k>0?0:D);if(o.useEffect(()=>{if(l||i)return;if(k<=0){E(D);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){E(D);return}let Q=0,$=0;E(x=>($=x,x));const R=performance.now(),oe=x=>{const y=Math.min(1,(x-R)/k),V=1-(1-y)**3;E($+(D-$)*V),y<1&&(Q=requestAnimationFrame(oe))};return Q=requestAnimationFrame(oe),()=>cancelAnimationFrame(Q)},[D,k,l,i]),l)return e.jsx(tr,{height:n});if(i)return e.jsx(ar,{height:n,text:c});const S=100,U=108,H=72,W=p??wd(r,a,b,m),Y=t+z*O,Z=Qo(S,U,H,Yr,Yr+nn),T=Yr+Math.max(.001,z)*nn,J=Qo(S,U,H,Yr,T),B=oa(S,U,H,Yr),_=oa(S,U,H,Yr+nn);return e.jsx("div",{className:`bonsaif-chart bonsaif-gauge-chart flex flex-col items-center justify-center ${s}`,style:{height:n},children:e.jsxs("svg",{viewBox:"0 0 200 168",width:"100%",height:"100%",role:"img","aria-label":w,className:"overflow-visible",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:`bonsaif-gauge-${C}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[e.jsx("stop",{offset:"0%",stopColor:W,stopOpacity:.82}),e.jsx("stop",{offset:"100%",stopColor:W,stopOpacity:1})]})}),e.jsx("path",{d:Z,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:M,strokeLinecap:"butt"}),e.jsx("path",{d:J,fill:"none",stroke:`url(#bonsaif-gauge-${C})`,strokeWidth:M,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),e.jsx("text",{x:S,y:U-(d?4:0),textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:28,fontWeight:700,letterSpacing:"-0.04em",className:"bonsaif-chart-gauge-label",children:f(Y)}),d?e.jsx("text",{x:S,y:U+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:d}):null,g?e.jsxs(e.Fragment,{children:[e.jsx("text",{x:B.x-2,y:B.y+M+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:f(t)}),e.jsx("text",{x:_.x+2,y:_.y+M+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:f(a)})]}):null]})})}function wd(r,t,a,n){if(n!=null&&n.length){const l=[...n].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(a)return sr(a);const s=r/(t||1);return s>=.8?sr("success"):s>=.5?sr("warning"):sr("danger")}function oa(r,t,a,n){return{x:r+a*Math.cos(n),y:t+a*Math.sin(n)}}function Qo(r,t,a,n,s){const l=oa(r,t,a,n),i=oa(r,t,a,s),c=s-n,d=Math.abs(c)>Math.PI?1:0;return`M ${l.x} ${l.y} A ${a} ${a} 0 ${d} 1 ${i.x} ${i.y}`}function Nd({value:r,target:t,max:a,ranges:n,height:s=72,className:l="",loading:i=!1,empty:c=!1,emptyText:d="Sin datos para mostrar",label:f,subtitle:b,valueFormat:p=rr,tone:m="primary",showScale:w=!0,showStatus:k=!0,ariaLabel:M="Bullet chart"}){if(i)return e.jsx(tr,{height:s});if(c)return e.jsx(ar,{height:s,text:d});const g=a??Math.max(r,t,...(n==null?void 0:n.map(W=>W.value))??[],1)*1.05,O=[...n??[{value:g*.5,color:"color-mix(in srgb, var(--border) 72%, transparent)"},{value:g*.75,color:"color-mix(in srgb, var(--border) 48%, transparent)"},{value:g,color:"color-mix(in srgb, var(--border) 28%, transparent)"}]].sort((W,Y)=>W.value-Y.value),D=sr(m),z=Math.min(100,Math.max(0,r/g*100)),E=Math.min(100,Math.max(0,t/g*100)),S=r>=t,U=[0,.25,.5,.75,1].map(W=>W*g),H=e.jsxs("div",{className:"bonsaif-bullet-plot min-w-0 flex-1",children:[e.jsxs("div",{className:"bonsaif-bullet-track relative w-full",style:{height:Math.max(22,f?28:s*.42)},role:"img","aria-label":M,children:[e.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:O.map((W,Y)=>{const Z=Y===0?0:O[Y-1].value,T=Math.max(0,(W.value-Z)/g*100);return e.jsx("div",{style:{width:`${T}%`,background:W.color??`color-mix(in srgb, var(--border) ${70-Y*18}%, transparent)`}},Y)})}),e.jsx("div",{className:"absolute left-0 top-1/2 w-full",style:{height:"34%",transform:"translateY(-50%)"},children:e.jsx("div",{className:"bonsaif-bullet-value h-full",style:{width:`${z}%`,background:D,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${D} 35%, transparent)`}})}),e.jsx("div",{className:"bonsaif-bullet-target absolute top-1/2 z-[1]",style:{left:`${E}%`,height:"72%",width:3,transform:"translate(-50%, -50%)",background:D,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${p(t)}`})]}),w?e.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:U.map((W,Y)=>{const Z=W/g*100,T=Y===0,J=Y===U.length-1;return e.jsxs("div",{className:"absolute top-0",style:{left:`${Z}%`,transform:T?"none":J?"translateX(-100%)":"translateX(-50%)"},children:[e.jsx("div",{className:"mx-auto h-1.5 w-px",style:{background:"color-mix(in srgb, var(--text-muted) 55%, transparent)",marginLeft:T?0:J?"auto":void 0,marginRight:J?0:void 0}}),e.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:T?"left":J?"right":"center"},children:p(W)})]},W)})}):null]});return e.jsx("div",{className:`bonsaif-chart bonsaif-bullet-chart w-full ${l}`,children:f?e.jsxs("div",{className:"bonsaif-bullet-row flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-4",children:[e.jsxs("div",{className:"bonsaif-bullet-label shrink-0 sm:w-[7.5rem] sm:pt-1 sm:text-right",children:[e.jsx("div",{className:"text-sm font-semibold tracking-tight",style:{color:"var(--text-main)"},children:f}),b?e.jsx("div",{className:"mt-0.5 text-[11px] leading-snug",style:{color:"var(--text-muted)"},children:b}):e.jsxs("div",{className:"mt-0.5 text-[11px] tabular-nums leading-snug",style:{color:"var(--text-muted)"},children:[e.jsx("span",{style:{color:D,fontWeight:600},children:p(r)}),e.jsxs("span",{children:[" / meta ",p(t)]})]}),k?e.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:sr(S?"success":"warning")},children:S?"En meta":"Bajo meta"}):null]}),H]}):H})}function kd({data:r,value:t,timeKey:a="t",usageKey:n="usage",series:s,cores:l,height:i=220,className:c="",loading:d=!1,emptyText:f="Sin datos de CPU",showLegend:b=!1,showTooltip:p=!0,thresholds:m,label:w="CPU",ariaLabel:k="Uso de CPU"}){var E;const M=s??[{key:n,label:"Uso",color:Nt(t??Kr(r,n)??0,m)}],g=t??Kr(r,n)??Kr(r,((E=M[0])==null?void 0:E.key)??n),C=!d&&(!r.length||g===null);if(d)return e.jsx(tr,{height:i});if(C)return e.jsx(ar,{height:i,text:f});const O=Math.min(100,Math.max(0,g??0)),D=Rt(O,m),z=Nt(O,m);return e.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":k,children:[e.jsxs("div",{className:"bonsaif-metric-head",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"bonsaif-metric-kicker",children:[w,l!=null?e.jsxs("span",{className:"ml-1.5 normal-case tracking-normal opacity-80",children:["· ",l," ",l===1?"core":"cores"]}):null]}),e.jsx("div",{className:"bonsaif-metric-value",style:{color:z},children:Vr(O,O<10?1:0)})]}),e.jsx("div",{className:"bonsaif-metric-badge",style:{color:z,background:`color-mix(in srgb, ${z} 14%, transparent)`},children:D==="danger"?"Crítico":D==="warning"?"Alto":"Normal"})]}),e.jsx(na,{data:r,xKey:a,series:M.map(S=>({...S,color:S.color??z})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:b,showTooltip:p,valueFormat:S=>Vr(S,0),ariaLabel:k,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function Sd({used:r,total:t,cached:a,data:n=[],timeKey:s="t",usageKey:l="usage",height:i=220,className:c="",loading:d=!1,emptyText:f="Sin datos de memoria",showHistory:b=!0,showTooltip:p=!0,thresholds:m,label:w="RAM",ariaLabel:k="Uso de memoria"}){const M=t>0?t:1,g=Math.min(100,Math.max(0,r/M*100)),C=!d&&!(Number.isFinite(r)&&Number.isFinite(t)&&t>0);if(d)return e.jsx(tr,{height:i});if(C)return e.jsx(ar,{height:i,text:f});const O=Rt(g,m),D=Nt(g,m),z=Math.max(0,t-r),E=n.length>0?Kr(n,l)??g:g,S=Nt(E,m),U=b&&n.length>1?Math.max(100,i-110):0;return e.jsxs("div",{className:`bonsaif-chart bonsaif-ram-chart w-full ${c}`,role:"group","aria-label":k,children:[e.jsxs("div",{className:"bonsaif-metric-head",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"bonsaif-metric-kicker",children:w}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"bonsaif-metric-value",style:{color:D},children:Vr(g,g<10?1:0)}),e.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[Gr(r)," / ",Gr(t)]})]})]}),e.jsx("div",{className:"bonsaif-metric-badge",style:{color:D,background:`color-mix(in srgb, ${D} 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(g),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${w} ${Vr(g,0)}`,children:e.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${g}%`,background:`linear-gradient(90deg, ${D}, color-mix(in srgb, ${D} 55%, #38bdf8))`}})}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[11px] tabular-nums",style:{color:"var(--text-muted)"},children:[e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Usada"})," ",Gr(r)]}),a!=null&&Number.isFinite(a)?e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",Gr(a)]}):null,e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",Gr(z)]})]})]}),b&&n.length>1?e.jsx(na,{data:n,xKey:s,series:[{key:l,label:"Uso",color:S}],height:U,yDomain:[0,100],showLegend:!1,showTooltip:p,valueFormat:H=>Vr(H,0),ariaLabel:`${k} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const Cd="color-mix(in srgb, var(--primary) 25%, #38bdf8)",Ed="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function Md({data:r,timeKey:t="t",inboundKey:a="in",outboundKey:n="out",inbound:s,outbound:l,unit:i="bytes",inboundLabel:c="Entrada",outboundLabel:d="Salida",inboundColor:f=Cd,outboundColor:b=Ed,height:p=240,className:m="",loading:w=!1,emptyText:k="Sin datos de red",showLegend:M=!1,showTooltip:g=!0,label:C="Network",ariaLabel:O="Tráfico de red"}){const D=s??Kr(r,a)??0,z=l??Kr(r,n)??0,E=!w&&r.length===0;if(w)return e.jsx(tr,{height:p});if(E)return e.jsx(ar,{height:p,text:k});const S=W=>Uo(W,i),H=Math.max(140,p-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:C}),e.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-5 sm:max-w-lg",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[e.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:f},"aria-hidden":!0}),c]}),e.jsx("div",{className:"mt-1 truncate text-xl font-bold tabular-nums leading-tight tracking-tight",style:{color:f},title:S(D),children:S(D)})]}),e.jsxs("div",{className:"min-w-0 pl-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[e.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:b},"aria-hidden":!0}),d]}),e.jsx("div",{className:"mt-1 truncate text-lg font-semibold tabular-nums leading-tight tracking-tight opacity-95",style:{color:b},title:S(z),children:S(z)})]})]})]})}),e.jsx("div",{className:"bonsaif-network-plot relative z-0",children:e.jsx(na,{data:r,xKey:t,series:[{key:a,label:c,color:f},{key:n,label:d,color:b}],height:H,showLegend:M,showTooltip:g,valueFormat:S,ariaLabel:O,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const Jo=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],Ro=["primeSuiteOrigin","primeSuiteProjectKey"];function Td(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const r=new URLSearchParams(window.location.search);for(const t of Jo){const a=r.get(t);if(a){const n=sa(a);if(n)return n}}if(typeof sessionStorage<"u")for(const t of Ro){const a=sessionStorage.getItem(t);if(a)try{const n=new URL(a);if(n.origin&&n.origin!==window.location.origin)return n.origin}catch{const n=sa(a);if(n)return n}}if(document.referrer){const t=sa(document.referrer);if(t&&t!==window.location.origin)return t}return"*"}catch{return"*"}}function Ld(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const r=new URLSearchParams(window.location.search);for(const t of Jo)if(r.get(t))return"query";if(typeof sessionStorage<"u"){for(const t of Ro)if(sessionStorage.getItem(t))return"sessionStorage"}if(document.referrer){const t=sa(document.referrer);if(t&&t!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function sa(r){if(!r)return null;const t=r.trim().replace(/\/+$/,"");if(!t)return null;if(/^https?:\/\/[^/]+$/.test(t))return t;try{return new URL(t).origin}catch{return null}}function $d(r){const[t,a]=o.useState({}),[n,s]=o.useState(!1),l=o.useCallback(f=>n||t[f]?r[f]:void 0,[r,n,t]),i=o.useCallback(f=>{a(b=>({...b,[f]:!0}))},[]),c=o.useCallback(()=>{s(!0)},[]),d=o.useCallback(()=>{a({}),s(!1)},[]);return{submitted:n,touchedFields:t,getFieldError:l,touchField:i,submit:c,reset:d}}Object.defineProperty(P,"toast",{enumerable:!0,get:()=>Nn.toast}),P.Alert=Js,P.AreaChart=na,P.AuthShell=Fo,P.BarChart=fd,P.BonsaifButton=Os,P.BonsaifUIToaster=sd,P.BulletChart=Nd,P.Button=Pe,P.CHART_PALETTE=Jt,P.CalendarPicker=al,P.ChartCard=ld,P.Checkbox=Ft,P.CodeBlock=il,P.ComboChart=gd,P.CompactFilterSelect=ul,P.CompactSearchInput=dl,P.ConfirmDialog=ml,P.CopyButton=Ba,P.CopyLinkButton=xl,P.CpuChart=kd,P.DataSheets=Vl,P.DataTable=qn,P.DateRangePicker=Xl,P.DonutChart=pd,P.Drawer=Rl,P.DropdownMenu=Ql,P.DynamicDetailTabs=Zs,P.EmailField=Ni,P.EmptyState=Si,P.FieldLayoutEditor=$i,P.FileUpload=Ti,P.FormField=ro,P.GaugeChart=yd,P.GlobalScrollbars=Do,P.InputField=Ua,P.LineChart=ud,P.LoadingState=$n,P.MentionTextEditor=So,P.MicroserviceFrame=rd,P.Modal=Pa,P.MouseTooltip=jr,P.MultiSelect=Di,P.NetworkChart=Md,P.NumberField=Ii,P.PageHeader=Jc,P.PageSearchInput=Cn,P.Pagination=Oi,P.PhoneField=Pi,P.PieChart=bd,P.PrimeAuthRouteShell=Rc,P.PrimeSuiteChatFrame=td,P.RadioGroup=Fi,P.RamChart=Sd,P.RichTextEditor=sc,P.SearchableSelect=Er,P.SectionPanel=lc,P.Sparkline=hd,P.StatusBadge=dc,P.StatusSelect=mc,P.StepWizard=gc,P.TableSkeleton=Pt,P.Tabs=hc,P.TagInput=Mc,P.TextInput=Kt,P.Textarea=Eo,P.TextareaField=Nc,P.Toggle=Lc,P.UserAvatar=Po,P.WaterfallChart=vd,P.buildMentionQueryRegex=po,P.cn=hr,P.configureBonsaifUI=Nl,P.dedupeMentions=xo,P.defaultValueFormat=rr,P.describeParentTargetOrigin=Ld,P.emailFormat=oi,P.extractMentionUsernames=Qa,P.filterSelfMentions=tc,P.findMentionTriggerInEditor=Ya,P.formatBytes=Gr,P.formatPercent=Vr,P.formatRate=Uo,P.getBonsaifUIConfig=kl,P.getDataTablePreferencesEndpoint=Fa,P.getPlainTextOffset=Ja,P.highlightMentions=yo,P.htmlToText=go,P.insertMentionInEditor=wo,P.isMentionTriggerBoundary=ho,P.isPlainOffsetInsideMentionChip=mo,P.isValidEmail=ja,P.isValidPhone=Wa,P.locateTextOffset=Ur,P.matches=ui,P.maxLength=ii,P.maxValue=di,P.mentionDisplayLabel=vo,P.minLength=li,P.minValue=ci,P.normalizeUsername=Za,P.phoneCountryCodeOptions=no,P.phoneFormat=si,P.placeCaretAtTextOffset=No,P.required=ni,P.resetBonsaifUIConfig=Sl,P.resolveMentions=rc,P.resolveParentTargetOrigin=Td,P.seriesColor=qo,P.setBonsaifDataTablePreferencesEndpoint=Cl,P.toneColor=sr,P.usageColor=Nt,P.usageTone=Rt,P.useValidationVisibility=$d,P.validateForm=fi,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})}));