bonsaif-ui 0.1.124 → 0.1.126
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.
- package/dist/bonsaif-ui.js +6957 -6186
- package/dist/bonsaif-ui.umd.cjs +23 -21
- package/dist/components/ui/AutoGrowTextarea.d.ts +16 -0
- package/dist/components/ui/AutoGrowTextarea.d.ts.map +1 -0
- package/dist/components/ui/AutoGrowTextareaField.d.ts +14 -0
- package/dist/components/ui/AutoGrowTextareaField.d.ts.map +1 -0
- package/dist/components/ui/DataTable.d.ts.map +1 -1
- package/dist/components/ui/MentionTextEditor.d.ts.map +1 -1
- package/dist/components/ui/RichTextEditorCore.d.ts.map +1 -1
- package/dist/components/ui/index.d.ts +4 -0
- package/dist/components/ui/index.d.ts.map +1 -1
- package/dist/lib/mentions.d.ts +14 -2
- package/dist/lib/mentions.d.ts.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/bonsaif-ui.umd.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
(function(Y,s){typeof exports=="object"&&typeof module<"u"?s(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"],s):(Y=typeof globalThis<"u"?globalThis:Y||self,s(Y.BonsaifUI={},Y.React,Y.jsxRuntime,Y.ReactIconsHi2,Y.ReactDOM,Y.Recharts,Y.OverlayScrollbarsGlobal,Y.Sonner,Y.OverlayScrollbarsReact,Y.ReactDayPicker,Y.ReactDayPickerStyles,Y.ReactIconsFi))})(this,(function(Y,s,t,z,nt,Ne,oa,bs,ms,la,bb,Gl){"use strict";"use client";function Tt(...e){return e.filter(Boolean).join(" ")}function Zl({variant:e="primary",className:r,type:n="button",children:a,...o}){return t.jsx("button",{className:Tt("bonsaif-ui-button",`bonsaif-ui-button--${e}`,r),type:n,...o,children:a})}function ps({value:e,onChange:r,placeholder:n,className:a="",autoFocus:o=!1,forceExpanded:l=!1,onEscape:i,size:c="default",inputTabIndex:d}){const u=s.useRef(null),[m,f]=s.useState(!1),b=l||m||e.trim().length>0,v=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",x=a||"w-48 max-w-full sm:w-64 lg:w-72";s.useEffect(()=>{var h;o&&((h=u.current)==null||h.focus())},[o]);const E=()=>{var h;f(!0),(h=u.current)==null||h.focus()};return t.jsxs("div",{className:`relative min-w-0 max-w-full flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${b?x:"w-24 sm:w-28"}`,onMouseDown:h=>{b||(h.preventDefault(),E())},children:[t.jsx(z.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)"}}),t.jsx("input",{ref:u,type:"text",tabIndex:d,"aria-label":n,value:e,onChange:h=>r(h.target.value),onKeyDown:h=>{h.key==="Escape"&&(i==null||i())},placeholder:b?n:"Buscar",className:`${v} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${b?"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:b?"calc(var(--page-header-control-padding-x, 14px) + 18px)":"var(--page-header-control-padding-x, 14px)",background:"color-mix(in srgb, var(--bg-card) 86%, transparent)",border:"1px solid var(--border)",color:"var(--text-main)"},onFocus:h=>{f(!0),h.currentTarget.style.borderColor="var(--primary)",h.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:h=>{f(!1),h.currentTarget.style.borderColor="var(--border)",h.currentTarget.style.boxShadow="none"}}),e&&t.jsx("button",{type:"button",onClick:()=>r(""),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:t.jsx(z.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const hs=s.createContext({});let gs=0;const vs="bonsaif-ui:hide-tooltips";function on(e=700){gs=Date.now()+e}function Ql(){return Date.now()>gs}function ln(e){if(typeof document>"u")return!1;const r=Array.from(document.querySelectorAll('[data-bonsaif-overlay="true"], [role="menu"], [role="dialog"][aria-modal="true"], [aria-hidden="false"] [aria-modal="true"]'));return e&&r.some(n=>n.contains(e))?!1:r.length>0}function Jl(e){var a;const r=Array.from(e.querySelectorAll("*")).filter(o=>{var l;return o.scrollWidth>o.clientWidth&&!!((l=o.textContent)!=null&&l.trim())&&o.tagName.toLowerCase()!=="svg"&&!o.closest("svg")});return(e.scrollWidth>e.clientWidth||r.length>0)&&(((a=r[0])==null?void 0:a.textContent)??e.textContent??"").trim()||null}function zt({children:e,content:r,onlyWhenOverflow:n=!1,interactive:a=!1,followCursor:o=!0,placement:l="bottom",showArrow:i=!1,className:c="",tooltipClassName:d="",style:u,tooltipStyle:m,as:f="div"}){const b=s.useRef(null),v=s.useRef(null),x=s.useRef(null),E=s.useRef(!1),[h,$]=s.useState(null),[M,y]=s.useState("");s.useEffect(()=>{const T=b.current;T&&(T.querySelectorAll("[title]").forEach(Z=>{const H=Z.getAttribute("title");H&&(Z.getAttribute("aria-label")||Z.setAttribute("aria-label",H),Z.removeAttribute("title"))}),T.querySelectorAll("svg title").forEach(Z=>Z.remove()))}),s.useLayoutEffect(()=>{if(!h)return;const T=v.current;if(!T)return;const Z=12,H=14,ae=T.getBoundingClientRect(),X=window.innerWidth-ae.width-Z,V=window.innerHeight-ae.height-Z;let q=h.mouseX+H,L=h.mouseY+H,oe,B;if(!o&&b.current){const F=b.current.getBoundingClientRect(),le=F.left+F.width/2,g=F.top+F.height/2;l==="top"?(q=le-ae.width/2,L=F.top-ae.height-H,B=ae.height-1):l==="left"?(q=F.left-ae.width-H,L=g-ae.height/2,oe=ae.width-1):l==="right"?(q=F.right+H,L=g-ae.height/2,oe=-7):(q=le-ae.width/2,L=F.bottom+H,B=-7)}if(o&&(q>X&&(q=h.mouseX-ae.width-H),L>V&&(L=h.mouseY-ae.height-H)),q=Math.min(Math.max(Z,q),Math.max(Z,X)),L=Math.min(Math.max(Z,L),Math.max(Z,V)),!o&&b.current){const F=b.current.getBoundingClientRect(),le=F.left+F.width/2,g=F.top+F.height/2;l==="top"||l==="bottom"?oe=Math.min(Math.max(14,le-q),ae.width-14):B=Math.min(Math.max(14,g-L),ae.height-14)}(Math.abs(q-h.x)>.5||Math.abs(L-h.y)>.5||oe!==h.arrowX||B!==h.arrowY)&&$(F=>F&&{...F,x:q,y:L,arrowX:oe,arrowY:B})},[o,l,h]);const w=()=>{x.current&&(window.clearTimeout(x.current),x.current=null)},k=(T,Z)=>{if(!Ql()||E.current)return;const H=b.current;if(H&&!ln(H)){if(n){const ae=Jl(H);if(!ae)return;y(ae)}!n&&!r||$({mouseX:T,mouseY:Z,x:T+14,y:Z+14})}},N=()=>{const T=b.current;if(!T)return;const Z=T.getBoundingClientRect();k(Z.left+Z.width/2,Z.bottom)},A=()=>{w(),$(null)},C=()=>{if(!a){A();return}w(),x.current=window.setTimeout(()=>$(null),120)},j=()=>{on(),E.current=!0,A()},W=()=>{E.current=!1};s.useEffect(()=>{if(!h)return;if(ln(b.current)){$(null);return}const T=()=>$(null),Z=()=>{on(),E.current=!0,$(null)};document.addEventListener("pointerdown",Z,!0),document.addEventListener("click",Z,!0),document.addEventListener("scroll",T,!0),window.addEventListener("blur",T),document.addEventListener("visibilitychange",T),document.addEventListener("keydown",T,!0);const H=new MutationObserver(()=>{ln(b.current)&&$(null)});return H.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",T,!0),window.removeEventListener("blur",T),document.removeEventListener("visibilitychange",T),document.removeEventListener("keydown",T,!0),H.disconnect()}},[h]),s.useEffect(()=>{const T=()=>on(),Z=()=>{on(),E.current=!0,$(null)};return document.addEventListener("pointerdown",T,!0),document.addEventListener("click",T,!0),document.addEventListener("keydown",T,!0),window.addEventListener(vs,Z),()=>{document.removeEventListener("pointerdown",T,!0),document.removeEventListener("click",T,!0),document.removeEventListener("keydown",T,!0),window.removeEventListener(vs,Z)}},[]);const G=n?M:r;return t.jsxs(t.Fragment,{children:[t.jsx(f,{ref:T=>{b.current=T},className:c,style:u,onMouseEnter:T=>{w(),W(),o?k(T.clientX,T.clientY):N()},onMouseMove:T=>{h&&o&&k(T.clientX,T.clientY)},onMouseDown:j,onClick:j,onMouseLeave:()=>{W(),C()},onFocus:N,onBlur:A,children:e}),h&&G&&!ln(b.current)?nt.createPortal(t.jsxs("div",{ref:v,role:"tooltip",className:d,onMouseEnter:a?w:void 0,onMouseLeave:a?C:void 0,style:{position:"fixed",top:h.y,left:h.x,zIndex:9999,background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:6,padding:"5px 10px",fontSize:12,color:"var(--text-main)",boxShadow:"0 4px 16px rgba(0,0,0,0.35)",pointerEvents:a?"auto":"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere",...m},children:[i&&t.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:h.arrowX===void 0?void 0:h.arrowX-6,top:h.arrowY===void 0?void 0:h.arrowY-6,zIndex:-1}}),G]}),document.body):null]})}function ys(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}const Rl="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",ei={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"},ti="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",ri={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"},ni={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},ai={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function ia(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(ia).join(" ").trim():s.isValidElement(e)?ia(e.props.children):""}function si(e){return s.Children.toArray(e).find(s.isValidElement)??null}function je({variant:e="primary",size:r="md",loading:n=!1,icon:a,tooltip:o,iconOnly:l,height:i,padding:c,children:d,className:u="",disabled:m,style:f,...b}){const v=s.useContext(hs),x=l??v.iconOnly??e==="icon",E=v.compact??!1,h=v.headerAction??!1,$=h&&r==="md"?"sm":E&&!h&&r==="md"?"xs":r,M=e==="icon"||x,y=h&&M,w=ia(d),k=o??b.title??b["aria-label"]??(x?w:void 0),N=k?void 0:b.title,A=b["aria-label"]??(typeof k=="string"?k:w||void 0),C=n?null:a??(x?si(d):null),j=t.jsxs("button",{...b,title:N,"aria-label":A,"data-variant":e,"data-size":$,"data-icon":M?"true":void 0,disabled:m||n,className:`${Rl} ${y?ti:ei[e]} ${M?ni[$]:ri[$]} ${E&&!M?"px-2.5":""} ${u}`,style:{...ai[e],height:ys(i),padding:ys(c),...f,...h&&!M?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...y?{width:"var(--page-header-control-height, 40px)",height:"var(--page-header-control-height, 40px)",padding:0,background:"var(--bg-card)",borderRadius:"8px"}:null},children:[n?t.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):C,!x&&d]});return k?t.jsx(zt,{as:"span",content:k,className:"inline-flex shrink-0",children:j}):j}const tt={background:"color-mix(in srgb, var(--text-muted) 26%, var(--bg-input))"};function cn({rows:e=8,columns:r=7,showToolbar:n=!0,showPagination:a=!0,compact:o=!1,className:l=""}){const i=Math.max(3,Math.min(r,12)),c=Math.max(3,Math.min(e,20)),d=o?"px-2 py-2":"px-3 py-2.5",u=o?"px-2 py-2":"px-3 py-3";return t.jsxs("div",{className:`w-full min-w-0 overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${l}`,"aria-busy":"true","aria-label":"Cargando tabla",children:[n&&t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-3 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("div",{className:"h-7 w-14 shrink-0 animate-pulse rounded-md",style:tt}),t.jsx("div",{className:"h-7 max-w-md flex-1 animate-pulse rounded-md",style:tt})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:tt}),t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:tt})]})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("div",{className:"min-w-full",style:{display:"grid",gridTemplateColumns:`repeat(${i}, minmax(96px, 1fr))`},children:[Array.from({length:i}).map((m,f)=>t.jsx("div",{className:`${u} border-b border-[var(--border)]`,style:{background:"color-mix(in srgb, var(--bg-input) 55%, transparent)"},children:t.jsx("div",{className:"h-3 animate-pulse rounded-md",style:{...tt,width:`${48+f*17%40}%`}})},`h-${f}`)),Array.from({length:c}).map((m,f)=>Array.from({length:i}).map((b,v)=>t.jsx("div",{className:`${d} ${f<c-1?"border-b border-[var(--border)]":""}`,children:t.jsx("div",{className:"h-3.5 animate-pulse rounded-md",style:{...tt,width:`${46+(f*13+v*11)%42}%`,minWidth:28}})},`c-${f}-${v}`)))]})}),a&&t.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:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"h-3 w-28 animate-pulse rounded-md",style:tt}),t.jsx("div",{className:"h-7 w-14 animate-pulse rounded-md",style:tt})]}),t.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:4}).map((m,f)=>t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:tt},f))}),t.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:tt})]})]})}function oi({size:e="md"}){const r=e==="sm"?"h-7 w-7":"h-9 w-9";return t.jsx("div",{className:`${r} animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]`,"aria-hidden":!0})}function li({logoSrc:e,logoAlt:r}){return e?t.jsxs("span",{className:"relative flex h-16 w-16 items-center justify-center","aria-hidden":!1,children:[t.jsx("span",{className:"absolute inset-0 rounded-2xl opacity-40 blur-xl",style:{background:"radial-gradient(circle, color-mix(in srgb, var(--primary) 45%, transparent) 0%, transparent 70%)"}}),t.jsx("img",{src:e,alt:r,className:"relative h-14 w-14 rounded-2xl object-contain shadow-sm shadow-black/10"})]}):null}function xs({variant:e="page",title:r="Cargando...",description:n,logoSrc:a,logoAlt:o,appearance:l="card",rows:i=6,columns:c=7,children:d,className:u=""}){if(e==="table")return t.jsx(cn,{rows:i,columns:c,className:u});if(e==="sections")return t.jsx(ii,{rows:i});if(e==="cards")return t.jsx(ci,{rows:i});const m=o||(typeof r=="string"?r:"Aplicación"),f=l==="bare",b=t.jsxs("div",{className:`flex flex-col items-center text-center ${f?"gap-5":"gap-3"}`,children:[a?t.jsx(li,{logoSrc:a,logoAlt:m}):null,t.jsx(oi,{size:f?"md":"sm"}),t.jsxs("div",{className:f?"space-y-1.5":"",children:[t.jsx("p",{className:f?"text-base font-semibold tracking-tight text-[var(--text-main)]":"text-sm font-semibold text-[var(--text-main)]",children:r}),n?t.jsx("p",{className:f?"text-sm font-medium text-[var(--text-muted)]":"mt-1 text-xs text-[var(--text-muted)]",children:n}):null,d&&t.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:d})]})]});return f?t.jsx("div",{className:`flex min-h-[240px] w-full items-center justify-center p-8 ${u}`,role:"status","aria-live":"polite","aria-busy":"true",children:b}):t.jsx("div",{className:`flex min-h-[240px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 ${u}`,role:"status","aria-live":"polite","aria-busy":"true",children:b})}function ii({rows:e}){return t.jsx(cn,{rows:e,columns:7})}function ci({rows:e}){return t.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:Array.from({length:e}).map((r,n)=>t.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[t.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded-md",style:tt}),t.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded-md",style:tt}),t.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded-md",style:tt})]},n))})}function ws(e){const r=e.split("/").filter(Boolean);return(r[r.length-1]??e).replace(/^lv_/,"").split(/[-_]/).filter(Boolean).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}function ks(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function di(e){return[e.label,ws(e.service),e.description,e.service].filter(Boolean).join(" ")}function ui(e){return typeof e=="function"?e:e.default}function fi(e,r){return t.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:t.jsxs("div",{className:"max-w-md",children:[t.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:"No se pudo cargar este modulo"}),t.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:e.message}),t.jsx(je,{className:"mt-4",height:36,padding:"0 14px",onClick:r,children:"Reintentar"})]})})}function bi({parentPanel:e,parentPanelComponent:r,renderParentPanel:n,parent:a,context:o,links:l,moduleRegistry:i,loadModule:c,activeService:d,initialService:u,onActiveServiceChange:m,canAccess:f,keepAlive:b=!0,title:v,subtitle:x,emptyState:E,loadingState:h,errorState:$=fi,renderTabLabel:M,searchableTabs:y="auto",tabsSearchThreshold:w=6,tabsSearchPlaceholder:k="Buscar modulo...",tabsSearchValue:N,onTabsSearchChange:A,emptySearchState:C,showTabCount:j=!0,className:W="",parentClassName:G="",contentClassName:T="",tabsClassName:Z=""}){var et;const H=s.useMemo(()=>l.filter(me=>!me.hidden&&((f==null?void 0:f(me,o))??!0)),[f,o,l]),ae=(et=H.find(me=>!me.disabled))==null?void 0:et.service,[X,V]=s.useState(u??ae??""),[q,L]=s.useState({}),[oe,B]=s.useState({}),[F,le]=s.useState(""),[g,P]=s.useState(!1),I=s.useRef(oe),te=s.useRef(0),U=N??F,K=ks(U),D=y===!0||y==="auto"&&H.length>=w,ee=D&&U.trim().length>0,_=s.useMemo(()=>K?H.filter(me=>ks(di(me)).includes(K)):H,[K,H]),se=d??X,Q=H.find(me=>me.service===se)??H.find(me=>!me.disabled);s.useEffect(()=>{!Q&&ae&&V(ae)},[ae,Q]),s.useEffect(()=>{I.current=oe},[oe]);const de=me=>{me.disabled||(d||V(me.service),m==null||m(me.service,me))},Se=me=>{N===void 0&&le(me),A==null||A(me)},ie=(me,J)=>{const re=_.filter(he=>!he.disabled),be=re.findIndex(he=>he.service===J.service);be<0||((me.key==="ArrowRight"||me.key==="ArrowDown")&&(me.preventDefault(),de(re[(be+1)%re.length])),(me.key==="ArrowLeft"||me.key==="ArrowUp")&&(me.preventDefault(),de(re[(be-1+re.length)%re.length])),me.key==="Home"&&(me.preventDefault(),de(re[0])),me.key==="End"&&(me.preventDefault(),de(re[re.length-1])))},pe=s.useCallback(()=>{if(!Q)return;const me=Q.service,J=I.current[me];if(J!=null&&J.loading||J!=null&&J.component&&b)return;const re=(i==null?void 0:i[me])??c;if(!re){B(he=>({...he,[me]:{loading:!1,error:new Error(`No module loader found for service "${me}".`)}}));return}const be=++te.current;B(he=>({...he,[me]:{...he[me],loading:!0,error:void 0}})),re(Q,o).then(he=>{if(be!==te.current&&!b)return;const Be=ui(he);B(Te=>({...Te,[me]:{component:Be,loading:!1}}))}).catch(he=>{const Be=he instanceof Error?he:new Error(String(he));B(Te=>({...Te,[me]:{...Te[me],loading:!1,error:Be}}))})},[o,b,c,i,Q]);s.useEffect(pe,[pe]);const Ce=Q?q[Q.service]??null:null,De=Q?oe[Q.service]:void 0,mt=De==null?void 0:De.component,xt=me=>{Q&&L(J=>({...J,[Q.service]:me}))},We=()=>{Q&&L(me=>({...me,[Q.service]:null}))},Le={context:o,parent:a,links:l,visibleLinks:H,filteredLinks:_,selectedLink:Q,selectedService:Q==null?void 0:Q.service,activeItemId:Ce,tabsSearch:U,onSelectService:de,onOpenDetail:xt,onBackToList:We},ke=n?n(Le):r?t.jsx(r,{...Le}):e;return t.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${W}`,children:[t.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${G}`,children:ke}),t.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${T}`,children:[(v||x||D||j)&&t.jsx("div",{className:"relative border-b border-[var(--border)] px-4 py-3",children:t.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[v&&t.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:v}),x&&t.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:x})]}),(D||j)&&t.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[j&&t.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[_.length," / ",H.length]}),D&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${g?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!g,children:t.jsx(ps,{value:U,onChange:Se,placeholder:k,className:"w-full",autoFocus:g,forceExpanded:!0,onEscape:()=>P(!1),size:"sm",inputTabIndex:g?0:-1})}),t.jsx("button",{type:"button","aria-label":g?"Cerrar busqueda":"Buscar tabs","aria-expanded":g,onClick:()=>{g&&U&&Se(""),P(me=>!me)},className:`inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border transition-all duration-200 hover:scale-[1.03] active:scale-95 ${g||ee?"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:t.jsx("span",{className:"grid h-4 w-4 place-items-center transition-transform duration-200",children:g||ee?t.jsx(z.HiXMark,{className:"h-4 w-4"}):t.jsx(z.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),t.jsx("div",{role:"tablist","aria-label":v??"Modulos relacionados",className:`flex gap-1 overflow-x-auto border-b border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 transition-colors duration-200 ${Z}`,children:_.length>0?_.map(me=>{const J=me.service===(Q==null?void 0:Q.service);return t.jsx("button",{type:"button",role:"tab","aria-selected":J,disabled:me.disabled,onClick:()=>de(me),onKeyDown:re=>ie(re,me),className:`inline-flex h-9 min-w-max items-center gap-2 rounded-md border px-3 text-xs font-semibold transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-50 ${J?"border-[var(--primary)] bg-[var(--bg-card)] text-[var(--text-main)] shadow-sm":"border-transparent text-[var(--text-muted)] hover:bg-[var(--bg-card)] hover:text-[var(--text-main)]"}`,children:M?M(me,J):t.jsxs(t.Fragment,{children:[me.icon,t.jsx("span",{children:me.label??ws(me.service)}),me.badge&&t.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:me.badge})]})},me.service)}):t.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:C??"No hay modulos que coincidan con la busqueda."})}),(Q==null?void 0:Q.description)&&t.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:Q.description}),t.jsxs("div",{className:"min-h-[420px] p-4",children:[!Q&&(E??t.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-dashed border-[var(--border)] text-sm text-[var(--text-muted)]",children:"No hay modulos disponibles."})),Q&&(De==null?void 0:De.loading)&&(h??t.jsx(xs,{title:"Cargando modulo..."})),Q&&(De==null?void 0:De.error)&&$(De.error,pe),Q&&mt&&!(De!=null&&De.loading)&&!(De!=null&&De.error)&&t.jsx(mt,{context:o,parent:a,link:Q,activeItemId:Ce,onOpenDetail:xt,onBackToList:We})]})]})]})}const mi={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:t.jsx(z.HiInformationCircle,{className:"h-5 w-5"})},success:{color:"#047857",background:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.24)",icon:t.jsx(z.HiCheckCircle,{className:"h-5 w-5"})},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)",icon:t.jsx(z.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:t.jsx(z.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:t.jsx(z.HiInformationCircle,{className:"h-5 w-5"})}};function pi({variant:e="info",title:r,children:n,icon:a,action:o,onDismiss:l,className:i=""}){const c=mi[e];return t.jsxs("div",{role:e==="danger"||e==="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:[t.jsx("div",{className:"mt-0.5 shrink-0",style:{color:c.color},children:a??c.icon}),t.jsxs("div",{className:"min-w-0 flex-1",children:[r&&t.jsx("div",{className:"text-sm font-semibold text-[var(--text-main)]",children:r}),n&&t.jsx("div",{className:"mt-0.5 text-sm leading-5 text-[var(--text-secondary)]",children:n}),o&&t.jsx("div",{className:"mt-3",children:o})]}),l&&t.jsx(je,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:t.jsx(z.HiXMark,{className:"h-4 w-4"})})]})}const Ns=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],hi=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],gi=["lu","ma","mi","ju","vi","sá","do"],Ss=6;function ca(e,r,n){return`${e}-${String(r).padStart(2,"0")}-${String(n).padStart(2,"0")}`}function vi(){const e=new Date;return ca(e.getFullYear(),e.getMonth()+1,e.getDate())}function Cs(e){const[r,n,a]=e.split("-").map(Number);return{year:r,month:n,day:a}}function yi(e){if(!e)return"Seleccionar fecha";const{year:r,month:n,day:a}=Cs(e);return!r||!n||!a?"Seleccionar fecha":`${String(a).padStart(2,"0")} ${Ns[n-1]} ${r}`}function xi({value:e,onChange:r,minDate:n,displayMode:a="inline",className:o=""}){const l=vi(),c=Cs(e||l),d=a==="popover",[u,m]=s.useState(!1),f=s.useRef(null),[b,v]=s.useState({horizontal:"left",vertical:"bottom"}),[x,E]=s.useState(c.year),[h,$]=s.useState(c.month),[M,y]=s.useState("days"),w=16,[k,N]=s.useState(0),A=x-7+k,C=Array.from({length:w},(V,q)=>A+q);s.useEffect(()=>{if(!d||!u||!f.current)return;const V=f.current.getBoundingClientRect(),q=8,L=280,oe=340,B=V.left+L>window.innerWidth-q,F=V.right-L>=q,le=V.bottom+8+oe>window.innerHeight-q,g=V.top-8-oe>=q;v({horizontal:B&&F?"right":"left",vertical:le&&g?"top":"bottom"})},[d,u]),s.useEffect(()=>{if(!d||!u)return;function V(L){f.current&&(f.current.contains(L.target)||m(!1))}function q(L){L.key==="Escape"&&m(!1)}return document.addEventListener("mousedown",V),document.addEventListener("keydown",q),()=>{document.removeEventListener("mousedown",V),document.removeEventListener("keydown",q)}},[d,u]);function j(){h===1?(E(V=>V-1),$(12)):$(V=>V-1)}function W(){h===12?(E(V=>V+1),$(1)):$(V=>V+1)}const G=(new Date(x,h-1,1).getDay()+6)%7,T=new Date(x,h,0).getDate(),Z=[...Array(G).fill(null),...Array.from({length:T},(V,q)=>q+1)];for(;Z.length<Ss*7;)Z.push(null);const H=Z.slice(0,Ss*7);function ae(V){const q=ca(x,h,V);n&&q<n||(r(q),d&&m(!1))}const X=t.jsx("div",{className:`bonsaif-calendar bonsaif-calendar-picker ${o}`.trim(),children:t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsx("div",{className:"bonsaif-cal-toolbar",children:M==="days"?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:j,"aria-label":"Mes anterior",children:t.jsx(z.HiChevronLeft,{size:16})}),t.jsxs("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>{y("years"),N(0)},children:[t.jsxs("span",{className:"bonsaif-cal-title",children:[Ns[h-1]," ",x]}),t.jsx(z.HiChevronDown,{size:13})]}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:W,"aria-label":"Mes siguiente",children:t.jsx(z.HiChevronRight,{size:16})})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>N(V=>V-w),"aria-label":"Años anteriores",children:t.jsx(z.HiChevronLeft,{size:16})}),t.jsx("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>y("days"),children:t.jsxs("span",{className:"bonsaif-cal-title",children:[C[0]," – ",C[C.length-1]]})}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>N(V=>V+w),"aria-label":"Años siguientes",children:t.jsx(z.HiChevronRight,{size:16})})]})}),M==="years"?t.jsxs("div",{className:"bonsaif-cal-picker-years",children:[t.jsx("div",{className:"bonsaif-cal-picker-months",children:hi.map((V,q)=>{const L=q+1===h;return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${L?" is-active":""}`,onClick:()=>$(q+1),children:V},V)})}),t.jsx("div",{className:"bonsaif-cal-picker-year-grid",children:C.map(V=>{const q=V===x,L=V===new Date().getFullYear();return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${q?" is-active":""}${L&&!q?" is-today":""}`,onClick:()=>{E(V),y("days")},children:V},V)})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bonsaif-multi-weekdays bonsaif-cal-picker-weekdays",children:gi.map(V=>t.jsx("div",{className:"bonsaif-multi-weekday",children:V},V))}),t.jsx("div",{className:"bonsaif-cal-picker-days",children:H.map((V,q)=>{if(V===null)return t.jsx("div",{className:"bonsaif-multi-day bonsaif-multi-day-hidden"},q);const L=ca(x,h,V),oe=L===e,B=L===l,F=!!(n&&L<n);return t.jsx("div",{className:`bonsaif-multi-day${oe?" bonsaif-multi-day-selected":""}${B?" bonsaif-multi-day-today":""}${F?" bonsaif-multi-day-disabled":""}`,children:t.jsx("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:F,"aria-pressed":oe,onClick:()=>!F&&ae(V),children:V})},q)})})]})]})});return d?t.jsxs("div",{ref:f,className:`relative w-full ${o}`.trim(),children:[t.jsxs("button",{type:"button",onClick:()=>m(V=>!V),className:"bonsaif-cal-trigger","data-open":u?"true":"false",children:[t.jsxs("span",{className:"inline-flex items-center gap-2 min-w-0",children:[t.jsx(z.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:yi(e)})]}),t.jsx(z.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${u?"rotate-180":""}`})]}),u&&t.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:X})]}):X}const wi={sm:"h-4 w-4",md:"h-5 w-5"};function ki(e,r){if(typeof e=="function"){e(r);return}e&&(e.current=r)}const dn=s.forwardRef(function({label:r,description:n,error:a,size:o="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:d,...u},m){const f=s.useRef(null);return s.useEffect(()=>{f.current&&(f.current.indeterminate=l)},[l]),t.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${d?"cursor-not-allowed opacity-60":"cursor-pointer"} ${c}`,children:[t.jsxs("span",{className:"relative mt-0.5 inline-flex shrink-0",children:[t.jsx("input",{...u,ref:b=>{f.current=b,ki(m,b)},type:"checkbox",disabled:d,"aria-checked":l?"mixed":u["aria-checked"],"aria-invalid":!!a||u["aria-invalid"],className:`peer ${wi[o]} 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}`}),t.jsx(z.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"})]}),(r||n||a)&&t.jsxs("span",{className:"min-w-0",children:[r&&t.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:r}),n&&!a&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:n}),a&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--danger)]",children:a})]})]})});function Es(e){const r=document.createElement("textarea");r.value=e,r.style.position="fixed",r.style.opacity="0",r.style.pointerEvents="none",document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r)}async function Ni(e){var r;if((r=navigator.clipboard)!=null&&r.writeText){await navigator.clipboard.writeText(e);return}Es(e)}function Si(e){return typeof e=="function"?e():e}function da({value:e,resetDelay:r=2e3,title:n,copiedTitle:a="Copiado",copiedLabel:o,icon:l=t.jsx(z.HiClipboardDocument,{size:14}),copiedIcon:i=t.jsx(z.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:d,onCopyError:u,className:m="",style:f,children:b,onClick:v,type:x="button",...E}){const[h,$]=s.useState(!1),M=s.useRef(null);s.useEffect(()=>()=>{M.current&&window.clearTimeout(M.current)},[]);function y(k){$(!0),d==null||d(k),M.current&&window.clearTimeout(M.current),M.current=window.setTimeout(()=>{$(!1),M.current=null},r)}async function w(k){var A;if(c&&k.stopPropagation(),v==null||v(k),k.defaultPrevented)return;const N=Si(e);if(N)try{await Ni(N),y(N)}catch(C){try{Es(N),y(N)}catch(j){u==null||u(j,N);return}(A=navigator.clipboard)!=null&&A.writeText||u==null||u(C,N)}}return t.jsxs("button",{...E,type:x,onClick:w,title:h?a:n,"aria-label":E["aria-label"]??(h?a:n),"data-copied":h?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${b?"min-w-7 px-2":"w-7"} ${m}`,style:{cursor:"pointer",background:h?"rgba(22,163,74,0.15)":"var(--bg-card)",border:h?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:h?"#16a34a":"var(--text-secondary)",boxShadow:h?"0 0 0 3px rgba(22,163,74,0.12)":"none",...f},children:[t.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:h?"scale(1.15)":"scale(1)"},children:h?i:l}),b&&t.jsx("span",{className:"text-xs font-semibold leading-none",children:h?o??b:b})]})}function Ci({code:e,children:r,title:n="Codigo",language:a,copyLabel:o="Copiar",copiedLabel:l="Copiado",className:i="",style:c,onCopied:d}){const u=(e??r??"").trim();return t.jsxs("div",{className:`overflow-hidden rounded-lg border ${i}`,style:{borderColor:"rgba(148, 163, 184, 0.22)",background:"#0f172a",color:"#e2e8f0",...c},children:[t.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:[t.jsx("span",{className:"min-w-0 truncate text-[11px] font-black uppercase tracking-[0.08em]",children:n}),t.jsx(da,{value:u,title:"Copiar codigo",copiedTitle:"Codigo copiado",copiedLabel:l,onCopied:d,className:"h-7 min-w-[72px] px-2",style:{background:"#182235",border:"1px solid rgba(148, 163, 184, 0.28)",color:"#f8fafc"},children:o})]}),t.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:t.jsx("code",{className:a?`language-${a}`:void 0,children:u})})]})}function ua(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function fa(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Ei(e,r){if(!r.trim())return!0;const n=fa(r);return fa(e.label).includes(n)||!!(e.sublabel&&fa(e.sublabel).includes(n))}function jt({value:e,onChange:r,options:n,status:a="default",ariaLabel:o,triggerVariant:l="default",showSelectedSublabel:i=!0,placeholder:c="Seleccionar…",emptyLabel:d,disabled:u=!1,className:m="",style:f,dropdownMinWidth:b,height:v=40,padding:x="0 10px",searchable:E=!0,minOptionsForSearch:h=6}){const[$,M]=s.useState(!1),[y,w]=s.useState(""),[k,N]=s.useState(-1),[A,C]=s.useState(!1),[j,W]=s.useState({}),G=s.useRef(null),T=s.useRef(null),Z=s.useRef(null),H=s.useRef(null),ae=E&&n.length>=h,X=n.find(U=>U.value===e)??null,V=l==="ghost",q=a==="error"?"var(--danger)":$?"var(--primary)":"var(--border)",L=ae&&y.trim()?n.filter(U=>Ei(U,y)):n,oe=s.useCallback(()=>{const U=G.current;if(!U)return;const K=U.getBoundingClientRect(),D=ae?272:212,ee=window.innerHeight-K.bottom,_=ee<D&&K.top>ee;W({position:"fixed",left:K.left,top:_?void 0:K.bottom+4,bottom:_?window.innerHeight-K.top+4:void 0,width:K.width,minWidth:ua(b),zIndex:9999})},[b,ae]);s.useEffect(()=>C(!0),[]),s.useEffect(()=>{if(!$)return;function U(K){var ee,_;const D=K.target;!((ee=G.current)!=null&&ee.contains(D))&&!((_=T.current)!=null&&_.contains(D))&&(M(!1),w(""))}return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[$]),s.useEffect(()=>{$&&(N(-1),oe(),ae&&setTimeout(()=>{var U;return(U=Z.current)==null?void 0:U.focus()},0))},[$,ae,oe]),s.useEffect(()=>{if($)return window.addEventListener("resize",oe),window.addEventListener("scroll",oe,!0),()=>{window.removeEventListener("resize",oe),window.removeEventListener("scroll",oe,!0)}},[$,oe]),s.useEffect(()=>{if(k<0||!H.current)return;const U=H.current.children[k];U==null||U.scrollIntoView({block:"nearest"})},[k]);const B=s.useCallback(U=>{r(U),M(!1),w("")},[r]),F=s.useRef($);F.current=$;const le=s.useRef(L);le.current=L;const g=s.useRef(k);g.current=k;const P=s.useRef(d);P.current=d;const I=s.useRef(B);I.current=B,s.useEffect(()=>{function U(K){var se,Q;const D=document.activeElement,ee=((se=G.current)==null?void 0:se.contains(D))??!1,_=((Q=T.current)==null?void 0:Q.contains(D))??!1;if(!(!ee&&!_)){if(!F.current){(K.key==="Enter"||K.key===" "||K.key==="ArrowDown")&&(K.preventDefault(),M(!0));return}switch(K.key){case"ArrowDown":K.preventDefault(),N(de=>Math.min(de+1,le.current.length-1));break;case"ArrowUp":K.preventDefault(),N(de=>Math.max(de-1,P.current?-1:0));break;case"Enter":{K.preventDefault();const de=g.current,Se=le.current;de===-1&&P.current?I.current(""):Se[de]&&!Se[de].disabled&&I.current(Se[de].value);break}case"Escape":K.preventDefault(),K.stopPropagation(),M(!1),w("");break}}}return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[]);const te=t.jsxs("div",{ref:T,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...j,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[ae&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(z.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:Z,value:y,onChange:U=>{w(U.target.value),N(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),y&&t.jsx("button",{type:"button",onMouseDown:U=>{U.preventDefault(),w("")},children:t.jsx(z.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),t.jsxs("ul",{ref:H,role:"listbox",className:"overflow-y-auto",style:{maxHeight:ae?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[d&&t.jsx("li",{role:"option","aria-selected":e==="",onMouseDown:U=>{U.preventDefault(),B("")},onMouseEnter:()=>N(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:k===-1&&!y.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:d}),L.map((U,K)=>{const ee=K===k,_=U.value===e;return t.jsxs("li",{role:"option","aria-selected":_,onMouseDown:se=>{se.preventDefault(),U.disabled||B(U.value)},onMouseEnter:()=>!U.disabled&&N(K),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:ee?"var(--bg-hover)":_?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:U.disabled?"var(--text-muted)":"var(--text-main)",cursor:U.disabled?"not-allowed":"pointer",boxShadow:_?"inset 2px 0 0 var(--primary)":void 0},children:[U.color&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:U.color}}),t.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx("span",{className:"truncate",children:U.label}),U.sublabel&&t.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:U.sublabel})]}),U.badge&&t.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:U.badge})]},U.value)}),L.length===0&&t.jsx("li",{className:"px-3 py-4 text-sm text-center",style:{color:"var(--text-muted)"},children:"Sin resultados"})]})]});return t.jsxs("div",{ref:G,className:`relative ${m||"w-full"}`,style:f,children:[t.jsxs("button",{type:"button",disabled:u,onClick:()=>!u&&M(U=>!U),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:ua(v),padding:ua(x),background:V?"transparent":"var(--bg-input)",color:X?"var(--text-main)":"var(--text-muted)",border:V?"1px solid transparent":`1px solid ${q}`,opacity:u?.5:1,cursor:u?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":$,"aria-label":o,children:[(X==null?void 0:X.color)&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:X.color}}),t.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:X?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"truncate",children:X.label}),i&&X.sublabel&&t.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:X.sublabel})]}):t.jsx("span",{className:"truncate",children:c})}),X&&d?t.jsx("span",{role:"button",tabIndex:-1,onMouseDown:U=>{U.preventDefault(),U.stopPropagation(),B("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(z.HiXMark,{className:"w-3 h-3"})}):t.jsx(z.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:$?"rotate(180deg)":"rotate(0deg)"}})]}),$&&A&&nt.createPortal(te,document.body)]})}function un(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Mi({value:e,onChange:r,placeholder:n="Buscar...",className:a="",height:o=40,padding:l="0 10px 0 30px",iconLeft:i=10}){return t.jsxs("div",{className:`relative ${a}`,children:[t.jsx(z.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:un(i)}}),t.jsx("input",{type:"text",value:e,onChange:c=>r(c.target.value),placeholder:n,className:"w-full rounded-lg border border-[var(--border)] [background:var(--bg-card)] text-sm text-[var(--text-main)] placeholder:text-[var(--text-muted)] outline-none transition-[border-color,box-shadow] focus:border-primary focus:ring-2 focus:ring-primary/20",style:{height:un(o),padding:un(l)}})]})}function $i({value:e,onChange:r,options:n,placeholder:a,icon:o,className:l="",height:i=40,padding:c,iconLeft:d=10,searchable:u=!0}){const m=o?n.map((f,b)=>b===0&&!f.color?{...f,sublabel:f.sublabel??void 0}:f):n;return t.jsxs("div",{className:`relative ${l}`,children:[o&&t.jsx("span",{className:"pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--text-muted)]",style:{left:un(d)},children:o}),t.jsx(jt,{value:e,onChange:r,options:m,placeholder:a,searchable:u,minOptionsForSearch:5,height:i,padding:c??(o?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const Ti={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},fn=180,Li="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function ba({open:e,onClose:r,title:n,subtitle:a,leadingIcon:o,headerActions:l,footer:i,children:c,size:d="md",maxWidth:u,zIndex:m=1e3,closeOnBackdrop:f=!0,closeOnEscape:b=!0,showCloseButton:v=!0,placement:x="center",bodyClassName:E="px-6 py-5",panelClassName:h="",backdropClassName:$=Li,contentClassName:M="p-4",ariaLabel:y,frameless:w=!1,disabled:k=!1}){const[N,A]=s.useState(!1),[C,j]=s.useState(!1),W=s.useRef(null);if(s.useEffect(()=>(e?(W.current&&clearTimeout(W.current),A(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>j(!0)))):(j(!1),W.current=setTimeout(()=>A(!1),fn+40)),()=>{W.current&&clearTimeout(W.current)}),[e]),s.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),s.useEffect(()=>{if(!e||!b)return;const X=V=>{V.key==="Escape"&&r()};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[b,r,e]),!N)return null;const G=n||a||o||l||v,T=u??Ti[d],Z=x==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",H=x==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",ae=C?"translateY(0) scale(1)":x==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return nt.createPortal(t.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":y??n,className:`fixed inset-0 flex ${Z} ${M}`,style:{zIndex:m},children:[t.jsx("div",{className:`absolute inset-0 ${$}`,onClick:f?r:void 0,style:{opacity:C?1:0,transition:`opacity ${fn}ms ease`}}),t.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${w?"shadow-none":"shadow-2xl"} ${H} ${h}`,style:{maxWidth:T,background:w?"transparent":"var(--bg-card)",border:w?"none":"1px solid var(--border)",opacity:C?1:0,transform:ae,transition:`opacity ${fn}ms ease, transform ${fn}ms ease`},onClick:X=>X.stopPropagation(),children:[k&&t.jsx("div",{className:"absolute inset-0 z-[1002] cursor-not-allowed rounded-2xl",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 60%, transparent)",backdropFilter:"blur(2px)"}}),G&&t.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between gap-3 px-6 py-4",style:{borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[o&&t.jsx("div",{className:"flex-shrink-0",children:o}),(n||a)&&t.jsxs("div",{className:"min-w-0",children:[n&&t.jsx("h2",{className:"truncate text-base font-semibold",style:{color:"var(--text-main)"},children:n}),a&&t.jsx("p",{className:"truncate text-xs",style:{color:"var(--text-muted)"},children:a})]})]}),t.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[l,v&&t.jsx(je,{variant:"icon",onClick:r,title:"Cerrar",children:t.jsx(z.HiXMark,{className:"h-5 w-5"})})]})]}),t.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${E}`,children:c}),i&&t.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 Ai={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 Di({open:e,title:r,description:n,confirmLabel:a="Confirmar",cancelLabel:o="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:d}){const u=Ai[l];return t.jsx(ba,{open:e,onClose:d,size:"md",zIndex:9998,showCloseButton:!1,bodyClassName:"p-0",panelClassName:"overflow-visible",ariaLabel:r,closeOnBackdrop:i,children:t.jsxs("div",{className:"relative px-6 pb-6 pt-6",children:[t.jsx(je,{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:t.jsx(z.HiXMark,{className:"h-4 w-4"})}),t.jsxs("div",{className:"flex gap-3 pr-8",children:[t.jsx("div",{className:"mt-0.5 flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl",style:{background:u.iconBg},children:t.jsx(z.HiExclamationTriangle,{className:"h-5 w-5",style:{color:u.iconColor}})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h2",{className:"text-base font-semibold leading-snug",style:{color:"var(--text-main)"},children:r}),n?t.jsx("div",{className:"mt-1.5 text-sm leading-relaxed",style:{color:"var(--text-muted)"},children:n}):null]})]}),t.jsxs("div",{className:"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[t.jsx(je,{variant:"secondary",onClick:d,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:o}),t.jsx(je,{variant:"danger",onClick:c,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:u.btnBg,color:u.btnColor,borderColor:"transparent"},children:a})]})]})})}function Ii(e){return e?typeof e=="function"?e():e:""}function Oi(e){return/^https?:\/\//i.test(e)}function Ms(e,r){try{return new URL(e,r).toString()}catch{return e}}function Hi(e,r,n,a=!1){const o=typeof e=="function"?e():e,l=r?r(o):o;if(!l||Oi(l))return l;const i=Ii(n);return i?Ms(l,i):a&&typeof window<"u"?Ms(l,window.location.origin):l}function Bi({url:e,resolveUrl:r,baseUrl:n,useWindowOriginForRelative:a=!1,title:o="Copiar link",copiedTitle:l="Link copiado",icon:i=t.jsx(z.HiLink,{className:"h-3.5 w-3.5"}),...c}){return t.jsx(da,{...c,value:()=>Hi(e,r,n,a),title:o,copiedTitle:l,icon:i})}const bn=[25,50,100,200,500];let ft={dataTable:{pageSizeOptions:[...bn]}};function Fi(){if(typeof window>"u")return;const r=window.__BONSAIF_DATA_TABLE_PREFERENCES_ENDPOINT__;return typeof r=="string"&&r.trim().length>0?r.trim().replace(/\/+$/,""):void 0}function ma(){const e=ft.dataTable.preferencesEndpoint,r=Fi();return e&&e.trim().length>0?e.trim().replace(/\/+$/,""):r}function Pi(e){if(!Array.isArray(e))return[...bn];const r=Array.from(new Set(e.map(n=>typeof n=="number"?Math.floor(n):Number.NaN).filter(n=>Number.isFinite(n)&&n>0)));return r.length>0?r:[...bn]}function $s(e){if(typeof e!="string")return;const r=e.trim();if(r)return r.replace(/\/+$/,"")}function _i(e){if(!e||typeof e!="object"||!e.dataTable)return;const r=$s(e.dataTable.preferencesEndpoint);ft={...ft,dataTable:{...ft.dataTable,pageSizeOptions:Pi(e.dataTable.pageSizeOptions),preferencesEndpoint:r??ft.dataTable.preferencesEndpoint}}}function zi(){return{dataTable:{pageSizeOptions:[...ft.dataTable.pageSizeOptions]}}}function Ir(){return[...ft.dataTable.pageSizeOptions]}function ji(){ft={dataTable:{pageSizeOptions:[...bn]}}}function Wi(e){ft={...ft,dataTable:{...ft.dataTable,preferencesEndpoint:$s(e)}}}const mn=[{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"}],qi=mn.map(e=>({value:e.value,label:e.label})),Ui=12,Vi={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},Ts={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},Yi="bonsaif-ui:datatable:",Xi="[&_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",Ki=[],Gi=52;function St(e){if(!e)return 150;const r=parseInt(e,10);return isNaN(r)||r<=0?150:r}function Ls(e){return!!(e&&(Array.isArray(e.columnOrder)&&e.columnOrder.length>0||e.columnWidths&&Object.keys(e.columnWidths).length>0||Array.isArray(e.hiddenColumnKeys)&&e.hiddenColumnKeys.length>0||e.filters&&Object.keys(e.filters).length>0||e.conditionFilters&&Object.keys(e.conditionFilters).length>0||e.sort||typeof e.bql=="string"||Array.isArray(e.bqlHistory)&&e.bqlHistory.length>0||typeof e.pageSize=="number"))}function As(e){return`${Yi}${e}`}function pn(e){try{const r=window.localStorage.getItem(As(e));if(!r)return null;const n=JSON.parse(r);return n&&typeof n=="object"?n:null}catch{return null}}function Zi(e,r){try{window.localStorage.setItem(As(e),JSON.stringify(r))}catch{}}function Qi(e,r){if(e===!0)return{...Ts};if(e===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(r&&e==null)return{...Ts};const n={...Vi,...e??{}};return r&&(typeof e!="object"||e.pagination!==!1)&&(n.pagination=!0),n}function Ds(...e){return e.reduce((r,n)=>({...r,...n??{}}),{})}function pa(e,r,n){return typeof e!="number"||e<=0?n:Pr(r).includes(e)?e:n}function Or(e){if(!e||typeof e!="object")return!1;const r=e;return typeof r.key=="string"&&(r.dir==="asc"||r.dir==="desc")}function Hr(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=Object.entries(e).flatMap(([a,o])=>{if(!r.has(a)||!Array.isArray(o))return[];const l=o.filter(i=>typeof i=="string");return l.length>0?[[a,l]]:[]});return Object.fromEntries(n)}function Br(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=new Set(mn.map(o=>o.value)),a=Object.entries(e).flatMap(([o,l])=>{if(!r.has(o)||!l||typeof l!="object")return[];const i=l;return!i.operator||!n.has(i.operator)?[]:[[o,{operator:i.operator,value:typeof i.value=="string"?i.value:"",valueTo:typeof i.valueTo=="string"?i.valueTo:""}]]});return Object.fromEntries(a)}function at(e,r){if(Wt(e))return Gi;const n=e.minWidth??80,a=e.maxWidth??1/0;return Math.min(a,Math.max(n,r))}function Ji(e){const r=window.getComputedStyle(e);return parseFloat(r.paddingLeft)+parseFloat(r.paddingRight)}function Wt(e){return e.key==="actions"||e.key==="acciones"?!0:typeof e.header=="string"&&e.header.trim().toLowerCase()==="acciones"}function ha(e){return e.sticky===!0}function Is(e){return!(e.reorderable===!1||e.sticky&&e.reorderable!==!0)}function Lt(e,r){const n=r.filter(ha).map(i=>i.key);if(n.length===0)return e;const a=new Set(n),o=n.filter(i=>e.includes(i)),l=e.filter(i=>!a.has(i));return[...o,...l]}function Ri(e,r){if(r<=7)return Array.from({length:r},(a,o)=>o+1);const n=[1];e>3&&n.push("...");for(let a=Math.max(2,e-1);a<=Math.min(r-1,e+1);a++)n.push(a);return e<r-2&&n.push("..."),n.push(r),n}function At(e,r){var i;const n=new Set(r.filter(c=>c.hideable!==!1).map(c=>c.key)),a=Array.from(new Set(e??[])).filter(c=>n.has(c));if(r.filter(c=>!a.includes(c.key)).length>0)return a;const l=(i=r.find(c=>c.hideable!==!1))==null?void 0:i.key;return l?a.filter(c=>c!==l):[]}function ec(e){return e==null||e===""?"(Vacio)":e instanceof Date?e.toLocaleDateString():String(e)}function nr(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(nr).join(" ").trim():s.isValidElement(e)?nr(e.props.children):""}function hn(e,r){const n=e.filterValue?e.filterValue(r):e.sortKey?r[e.sortKey]:e.cell(r);return typeof n=="string"||typeof n=="number"||typeof n=="boolean"||n===null||n===void 0||n instanceof Date?ec(n):nr(n).trim()}function Fr(e){const r=e.replace(/,/g,"").trim();if(!r)return null;const n=Number(r);return Number.isFinite(n)?n:null}function ar(e,r){const n=Fr(e),a=Fr(r);return n!==null&&a!==null?n-a:e.localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})}function Pr(e){const r=Array.from(new Set(e.map(n=>Math.floor(n)).filter(n=>Number.isFinite(n)&&n>0)));return r.length>0?r:Ir()}function tc(e,r,n){var i,c;const a=((i=r.value)==null?void 0:i.trim())??"",o=((c=r.valueTo)==null?void 0:c.trim())??"",l=mn.find(d=>d.value===r.operator);if((l==null?void 0:l.valueMode)==="single"&&!a||(l==null?void 0:l.valueMode)==="between"&&(!a||!o))return!0;switch(r.operator){case"equals":return e.toLowerCase()===a.toLowerCase();case"notEquals":return e.toLowerCase()!==a.toLowerCase();case"greaterThan":return ar(e,a)>0;case"greaterThanOrEqual":return ar(e,a)>=0;case"lessThan":return ar(e,a)<0;case"lessThanOrEqual":return ar(e,a)<=0;case"between":return ar(e,a)>=0&&ar(e,o)<=0;case"top10":case"bottom10":{const u=n.map(f=>({value:f,number:Fr(f)})).filter(f=>f.number!==null).sort((f,b)=>f.number-b.number).map(f=>f.value);return(r.operator==="top10"?u.slice(-10):u.slice(0,10)).includes(e)}case"aboveAverage":case"belowAverage":{const d=n.map(Fr).filter(f=>f!==null);if(d.length===0)return!1;const u=d.reduce((f,b)=>f+b,0)/d.length,m=Fr(e);return m===null?!1:r.operator==="aboveAverage"?m>u:m<u}default:return!0}}function Os({children:e,className:r="",style:n}){return t.jsx(zt,{onlyWhenOverflow:!0,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,...n},children:e})}function Hs({columns:e,data:r,getRowId:n,loading:a=!1,skeletonRows:o=8,emptyIcon:l,emptyText:i="Sin resultados",initialEmptyDelay:c=450,onRowClick:d,renderExpandedRow:u,getRowCanExpand:m,expandedRowIds:f,defaultExpandedRowIds:b=[],onExpandedRowIdsChange:v,expandOnRowClick:x=!1,selected:E,onToggleOne:h,onToggleAll:$,getRowSelectable:M,highlightSelected:y=!0,rowClassName:w,getRowCategory:k,stickyHeader:N=!0,pageSize:A=25,pageSizeOptions:C,pageSizeSelectWidth:j=62,pageSizeSelectHeight:W=30,pageSizeSelectPadding:G="0 7px",totalRows:T,page:Z,onPageChange:H,onPageSizeChange:ae,storageKey:X,stickyFirstColumn:V=!1,bottomOffset:q=0,compact:L=!0,restrictHeight:oe=!0,maxHeight:B,minTableWidth:F,enableColumnVisibility:le=!0,enableColumnFilters:g=!0,hiddenColumnKeys:P,defaultHiddenColumnKeys:I=Ki,onHiddenColumnKeysChange:te,columnVisibilityLabel:U="Columnas",enableBql:K=!1,bqlValue:D,defaultBqlValue:ee="",onBqlChange:_,bqlDescription:se="Filtra registros con Bonsaif Query Language",bqlPlaceholder:Q=`status = activo
|
|
2
|
-
rol IN (admin, employee)`,bqlQuickFilters:
|
|
3
|
-
`).map(ne=>ne.trim()).includes(
|
|
4
|
-
${S}`;rs(O,Qa.current??void 0),requestAnimationFrame(()=>{const ne=Qa.current;if(!ne)return;ne.focus();const fe=ne.value.length;ne.setSelectionRange(fe,fe),rs(ne.value,ne)})}s.useEffect(()=>{_n(Mt)},[Mt]);const Zn=s.useCallback(()=>{const p=Za.current;if(!p)return;const S=p.getBoundingClientRect(),R=12,O=8,ne=Math.min(780,Math.max(320,window.innerWidth-32)),fe=Math.max(R,window.innerWidth-ne-R),ve=Math.min(Math.max(R,S.left),fe),$e=S.bottom+O,Ke=window.innerHeight-S.top+O,Ue=window.innerHeight-$e-R,rt=S.top-R-O,Xe=Ue<280&&rt>Ue,ge=Math.max(240,Xe?rt:Ue);Lf({position:"fixed",zIndex:1e4,left:ve,top:Xe?void 0:$e,bottom:Xe?Ke:void 0,width:ne,maxWidth:"calc(100vw - 24px)",maxHeight:ge,overflowY:"auto"})},[]);s.useEffect(()=>{if(!$t)return;function p(O){var fe,ve;if(Date.now()<yl.current)return;const ne=O.target;(fe=Za.current)!=null&&fe.contains(ne)||(ve=vl.current)!=null&&ve.contains(ne)||(Yt(!1),xr(!1),wr(!1))}function S(O){O.key==="Escape"&&(Yt(!1),xr(!1),wr(!1))}function R(){Zn()}return Zn(),document.addEventListener("mousedown",p),window.addEventListener("keydown",S),window.addEventListener("resize",R),window.addEventListener("scroll",R,!0),()=>{document.removeEventListener("mousedown",p),window.removeEventListener("keydown",S),window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[$t,Zn]);function Dl(p){const S=At(p,e);Ee||Ae(S),te==null||te(S)}function Kf(p){Dl(Pe.includes(p)?Pe.filter(S=>S!==p):[...Pe,p])}function Gf(){Dl([])}const ns=s.useCallback((p=Un.current)=>{if(!p)return;const S=p.getBoundingClientRect(),R=Math.min(292,Math.max(240,window.innerWidth-16)),O=Math.max(8,window.innerWidth-R-8),ne=Math.min(Math.max(8,S.right-R),O),fe=window.innerHeight-S.bottom,ve=S.bottom+6,$e=window.innerHeight-S.top+6,Ue=fe<360&&S.top>fe?void 0:ve,rt=Ue===void 0?$e:void 0,Xe=Math.max(220,Ue===void 0?S.top-16:window.innerHeight-ve-8),ge={position:"fixed",zIndex:9999,left:ne,top:Ue,bottom:rt,width:R,maxWidth:"calc(100vw - 16px)",maxHeight:Xe,"--dt-column-menu-max-height":`${Xe}px`};Df(ge)},[]);function Il(p,S,R=null){p.preventDefault(),p.stopPropagation();const O=Un.current===p.currentTarget&&Qe===S&&Ht===R;if(Ge&&O){Ze(!1),Ut(null);return}Un.current=p.currentTarget,Et(S),Ut(R),ml(""),ns(p.currentTarget),Ze(!0)}function Zf(p){if(Wt(p))return;const S=Bt.current;if(!S)return;const O=Array.from(S.querySelectorAll("[data-dt-column-key]")).filter(ne=>ne.dataset.dtColumnKey===p.key).reduce((ne,fe)=>{const ve=fe.querySelector("[data-dt-autofit-content]"),$e=ve?ve.scrollWidth:Math.max(fe.scrollWidth,fe.offsetWidth);return Math.max(ne,Math.ceil($e+Ji(fe)))},0);O<=0||Er(ne=>({...ne,[p.key]:at(p,O+12)}))}s.useEffect(()=>{Er(p=>{const S=Object.fromEntries(e.map(R=>[R.key,at(R,St(R.width))]));return Object.fromEntries(e.map(R=>[R.key,at(R,p[R.key]??S[R.key])]))})},[me,e]),s.useEffect(()=>{Ee||Ae(p=>At(p,e))},[me,e,Ee]),s.useEffect(()=>{function p(O){var ve,$e;const ne=O.target,fe=O.target;fe!=null&&fe.closest("[data-bonsaif-select-dropdown='true']")||!((ve=xl.current)!=null&&ve.contains(ne))&&!(($e=Un.current)!=null&&$e.contains(ne))&&(Ze(!1),Ut(null))}function S(O){O.key==="Escape"&&(Ze(!1),Ut(null))}function R(){ns()}return Ge&&(document.addEventListener("mousedown",p),window.addEventListener("keydown",S),window.addEventListener("resize",R),window.addEventListener("scroll",R,!0)),()=>{document.removeEventListener("mousedown",p),window.removeEventListener("keydown",S),window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[Ge,ns]);const rn=s.useRef(null);s.useEffect(()=>{function p(R){const O=rn.current;if(!O)return;const ne=R.clientX-O.startX,fe=e.find(ve=>ve.key===O.colKey);fe&&Er(ve=>({...ve,[O.colKey]:at(fe,O.startWidth+ne)}))}function S(){rn.current&&(rn.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",p),document.addEventListener("pointerup",S),()=>{document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",S)}},[e]);const nn=s.useRef(null),[Ol,as]=s.useState(null);function Qf(p,S){const R=e.find(O=>O.key===p);if(!R||!Is(R)){S.preventDefault();return}nn.current=Sr.indexOf(p),S.dataTransfer.effectAllowed="move"}function Jf(p,S){S.preventDefault(),S.dataTransfer.dropEffect="move";const R=Sr.indexOf(p);Ol!==R&&as(R)}function Rf(p,S){S.preventDefault();const R=nn.current,O=Sr.indexOf(p);R!==null&&R!==O&&Cr(ne=>{const fe=[...ne],[ve]=fe.splice(R,1);return fe.splice(O,0,ve),Lt(fe,e)}),nn.current=null,as(null)}function eb(){nn.current=null,as(null)}function tb(p){p.sortKey&&Gt(S=>(S==null?void 0:S.key)===p.key?{key:p.key,dir:S.dir==="asc"?"desc":"asc"}:{key:p.key,dir:"asc"})}s.useEffect(()=>{Vn(1)},[r]),s.useEffect(()=>{Vn(1)},[wt,dt]);const Zt=!!(H&&ae),Qt=A!==!1,Hl=s.useMemo(()=>Pr(C??Ir()),[C]),Re=Zt?Z??1:zf,Nt=Zt||Qt?Yn:r.length,pt=!!E&&!!h&&!!$,ss=s.useMemo(()=>M?r.filter(p=>M(p)):r,[r,M]),Mr=!!u,Bl=s.useMemo(()=>new Set(Ga?Array.from(f??[]):pl),[Ga,f,pl]),rb=(Mr?40:0)+(pt?40:0),os=!Pf&&(El||V),Qn=(()=>{if(!os)return{};let p=rb;const S={};return ut.forEach((R,O)=>{(ha(R)||!El&&V&&O===0)&&(S[R.key]=p,p+=Kt[R.key]??at(R,St(R.width)))}),S})(),ls=Object.keys(Qn),is=ls.length>0?ls[ls.length-1]:null,Fl=pt&&ss.length>0&&ss.every(p=>E.has(n(p))),nb=pt&&E.size>0&&ss.some(p=>E.has(n(p)))&&!Fl,Jn=s.useMemo(()=>{const p=Object.entries(dt),S=Object.entries(wt);return p.length===0&&S.length===0?r:r.filter(R=>p.every(([O,ne])=>{const fe=e.find(ve=>ve.key===O);return fe?ne.includes(hn(fe,R)):!0})&&S.every(([O,ne])=>{const fe=e.find($e=>$e.key===O);if(!fe)return!0;const ve=r.map($e=>hn(fe,$e));return tc(hn(fe,R),ne,ve)}))},[wt,dt,e,r]),Jt=s.useMemo(()=>{if(!qe)return Jn;const p=e.find(S=>S.key===qe.key&&S.sortKey);return p!=null&&p.sortKey?[...Jn].sort((S,R)=>{const O=S[p.sortKey],ne=R[p.sortKey],fe=O===ne?0:O==null?1:ne==null||O<ne?-1:1;return qe.dir==="asc"?fe:-fe}):Jn},[Jn,qe,e]),Pl=s.useMemo(()=>{if(Zt||!Qt)return Jt;const p=(Re-1)*Nt;return Jt.slice(p,p+Nt)},[Jt,Zt,Qt,Re,Nt]),Rt=Zt?T??r.length:Jt.length,cs=Qt?Math.max(1,Math.ceil(Rt/Nt)):1,ab=Math.min(...Hl),sb=Qt&&(Rt>Nt||Rt>ab),ob=Qt?(Re-1)*Nt+1:1,lb=Qt?Math.min(Re*Nt,Rt):Rt;function ds(p){if(a)return;const S=Math.max(1,Math.min(p,cs));Zt?H(S):Vn(S)}function ib(p){a||(X&&(Xt.current=X),Xn(p),Zt?(ae(p),H(1)):(Vn(1),ae==null||ae(p)))}function _l(p){const S=new Set(Bl);S.has(p)?S.delete(p):S.add(p);const R=Array.from(S);Ga||Ef(R),v==null||v(R)}s.useEffect(()=>{De==null||De({bql:Mt,filters:dt,conditionFilters:wt,sort:qe,page:Re,pageSize:Nt,hiddenColumnKeys:Pe})},[Mt,dt,wt,qe,Re,Nt,Pe,De]);const zl=p=>p==="center"?"justify-center text-center":p==="right"?"justify-end text-right":"justify-start text-left",cb="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",us="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%)",Oe="color-mix(in srgb, var(--border) 62%, var(--bg-card))",er="color-mix(in srgb, var(--primary) 24%, var(--border))",Rn=`inset 0 0 0 1px ${Oe}`,jl=ut.reduce((p,S)=>p+(Kt[S.key]??St(S.width)),(Mr?40:0)+(pt?40:0)),Wl=typeof F=="number"?F:typeof F=="string"?Number(((Xl=F.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:Xl[1])??NaN):NaN,an=Number.isFinite(Wl)?Math.max(jl,Wl,Nl):Math.max(jl,Nl),ea=F??an,$r=`${Mr?"40px ":""}${pt?"40px ":""}${ut.map(p=>`${Kt[p.key]??St(p.width)}px`).join(" ")}`;s.useEffect(()=>{qe&&Pe.includes(qe.key)&&Gt(null)},[Pe,qe]);function ql(p){return p?typeof p=="string"?{key:p,label:p}:p:null}const ta=()=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:$r,background:us,borderBottom:`1px solid ${er}`},children:[Mr&&t.jsx("div",{role:"columnheader",className:`${L?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${er}`,borderRight:`1px solid ${Oe}`}}),pt&&t.jsx("div",{role:"columnheader",className:`${L?"px-2 py-1.5":"px-3 py-2.5"} flex w-10 items-center justify-center`,style:os?{position:"sticky",left:0,zIndex:12,background:us,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${er}`,borderRight:`1px solid ${Oe}`}:{borderBottom:`1px solid ${er}`,borderRight:`1px solid ${Oe}`},children:t.jsx(dn,{size:"sm",checked:Fl,indeterminate:nb,onChange:$,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),ut.map((p,S)=>{const R=(qe==null?void 0:qe.key)===p.key,O=!!p.sortKey,ne=Wt(p),fe=Qn[p.key],ve=fe!==void 0,$e=p.key===is,Ke=Is(p),Ue=Ol===S,Xe=(Kt[p.key]??St(p.width))<120,ge=Object.prototype.hasOwnProperty.call(dt,p.key)||Object.prototype.hasOwnProperty.call(wt,p.key);return t.jsxs("div",{role:"columnheader","data-dt-column-key":p.key,className:`group select-none ${Xe?"text-left":zl(p.align)}`,style:{...ve?{position:"sticky",left:fe,zIndex:12,background:us,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:$e?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${er}`:`inset 0 -1px 0 ${er}`,borderRight:`1px solid ${Oe}`}:{position:"relative",borderBottom:`1px solid ${er}`,borderRight:`1px solid ${Oe}`},color:R?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:Ue?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:ne?L?"7px 6px":"9px 8px":L?"8px 6px 10px":"10px 8px 12px"},onDragOver:Me=>{(Ke||nn.current!==null)&&Jf(p.key,Me)},onDrop:Me=>Rf(p.key,Me),children:[t.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${ne?"justify-center":Xe?"justify-start":p.align==="center"?"justify-center":p.align==="right"?"justify-end":"justify-start"}`,children:[Ke?t.jsx("span",{draggable:!0,onDragStart:Me=>{Me.stopPropagation(),Qf(p.key,Me)},onDragEnd:Me=>{Me.stopPropagation(),eb()},onClick:Me=>Me.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 ${Ue?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}):null,ne?t.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:t.jsx(z.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):t.jsx(Os,{className:"min-w-0 flex-1",children:t.jsx("span",{"data-dt-autofit-content":!0,className:`inline-flex max-w-full items-center font-semibold uppercase tracking-wider ${L?"text-[11px]":"text-xs"}`,children:t.jsx("span",{className:"min-w-0 truncate",children:p.header})})}),O&&t.jsx("button",{type:"button","aria-label":`Ordenar por ${String(p.header)}`,title:"Ordenar",onClick:Me=>{Me.stopPropagation(),tb(p)},"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 ${R?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:R?qe.dir==="asc"?t.jsx(z.HiChevronUp,{className:"h-3 w-3"}):t.jsx(z.HiChevronDown,{className:"h-3 w-3"}):t.jsx(z.HiChevronUpDown,{className:"h-3 w-3"})}),g&&!ne&&Uf(p)&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ge&&Ht===p.key,"aria-label":`Filtrar ${String(p.header)}`,title:"Filtrar",onClick:Me=>Il(Me,"filter",p.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 ${Ge&&Qe==="filter"&&Ht===p.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":ge?"text-[var(--primary)] opacity-100":""}`,children:ge?t.jsx(z.HiFunnel,{className:"h-3.5 w-3.5"}):t.jsx(z.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!ne&&t.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:Me=>{Me.preventDefault(),Me.stopPropagation(),rn.current={colKey:p.key,startX:Me.clientX,startWidth:Kt[p.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:Me=>{Me.preventDefault(),Me.stopPropagation(),rn.current=null,document.body.style.cursor="",document.body.style.userSelect="",Zf(p)},onClick:Me=>Me.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:t.jsxs("span",{style:{display:"flex",gap:4,alignItems:"center",height:"calc(100% - 8px)"},children:[t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}}),t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}})]})})]},p.key)})]}),ra=()=>{if(!Ge||typeof document>"u"||Qe==="visibility"&&!le||Qe==="filter"&&!g)return null;const p=e.find(ge=>ge.key===Ht),S=qf(),R=p?Object.prototype.hasOwnProperty.call(dt,p.key):!1,O=p?wt[p.key]:void 0,ne=mn.find(ge=>ge.value===(O==null?void 0:O.operator)),fe=p?dt[p.key]??[]:[],ve=bl.trim().toLowerCase(),$e=ve?S.filter(ge=>ge.label.toLowerCase().includes(ve)):S,Ke=p&&S.length>0&&(!R||fe.length===S.length),Ue=p&&R&&fe.length>0&&fe.length<S.length,rt=Pe.length,Xe=()=>{p&&(ts(p.key),Tl(p.key))};return nt.createPortal(t.jsx("div",{ref:xl,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Af,borderColor:"var(--border)",background:"var(--bg-card)"},children:Qe==="visibility"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[t.jsx("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:rt>0?`${ut.length} de ${e.length} visibles`:`${e.length} visibles`}),t.jsx("button",{type:"button",onClick:Gf,disabled:rt===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"})]}),t.jsx("div",{className:"max-h-72 overflow-auto py-1",children:Cl.map(ge=>{const Me=!Pe.includes(ge.key),ye=!(ge.hideable!==!1)||Me&&ut.length<=1;return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Me,disabled:ye,onClick:()=>Kf(ge.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:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Me?"var(--primary)":"var(--border)",background:Me?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Me&&t.jsx(z.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ge.header})]},ge.key)})})]}):p?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[t.jsxs("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:["Filtrar ",p.header]}),t.jsx("button",{type:"button",onClick:Xe,disabled:!R&&!O,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"})]}),p.sortKey&&t.jsxs("div",{className:"grid grid-cols-2 gap-1 border-b border-[var(--border)] p-1",children:[t.jsxs("button",{type:"button",onClick:()=>Gt({key:p.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:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[t.jsx(z.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Ascendente"})]}),(qe==null?void 0:qe.key)===p.key&&qe.dir==="asc"&&t.jsx(z.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),t.jsxs("button",{type:"button",onClick:()=>Gt({key:p.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:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[t.jsx(z.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Descendente"})]}),(qe==null?void 0:qe.key)===p.key&&qe.dir==="desc"&&t.jsx(z.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]})]}),t.jsxs("div",{className:"border-b border-[var(--border)] p-2",children:[t.jsxs("div",{className:"grid grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)] gap-2",children:[t.jsx(jt,{value:(O==null?void 0:O.operator)??"",onChange:ge=>{if(!ge){Tl(p.key);return}Kn(p.key,{operator:ge,value:(O==null?void 0:O.value)??"",valueTo:(O==null?void 0:O.valueTo)??""})},options:qi,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"}),(ne==null?void 0:ne.valueMode)!=="none"?t.jsx("input",{value:(O==null?void 0:O.value)??"",onChange:ge=>{O&&Kn(p.key,{...O,value:ge.target.value})},disabled:!O,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)"}}):t.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"})]}),(ne==null?void 0:ne.valueMode)==="between"&&t.jsx("input",{value:(O==null?void 0:O.valueTo)??"",onChange:ge=>{O&&Kn(p.key,{...O,valueTo:ge.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)"}})]}),t.jsx("div",{className:"border-b border-[var(--border)] p-2",children:t.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:[t.jsx(z.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("input",{value:bl,onChange:ge=>ml(ge.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)"}})]})}),t.jsxs("div",{className:"overflow-auto py-1",style:{maxHeight:"max(96px, calc(var(--dt-column-menu-max-height, 520px) - 236px))"},children:[t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ue?"mixed":!!Ke,onClick:()=>{p&&(Ke&&!R?$l(p.key,[]):ts(p.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:[t.jsxs("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ke||Ue?"var(--primary)":"var(--border)",background:Ke||Ue?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[Ue&&t.jsx(z.HiMinus,{className:"h-3 w-3"}),Ke&&!Ue&&t.jsx(z.HiCheck,{className:"h-3 w-3"})]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),$e.map(ge=>{const Me=!R||fe.includes(ge.value);return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Me,onClick:()=>Vf(p.key,ge.value,S.map(we=>we.value),R),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:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Me?"var(--primary)":"var(--border)",background:Me?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Me&&t.jsx(z.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ge.label})]},ge.value)}),$e.length===0&&t.jsx("div",{className:"px-3 py-3 text-sm text-[var(--text-muted)]",children:"Sin valores"})]})]}):null}),document.body)};s.useEffect(()=>{if(!tn)return;function p(S){Ja.current&&!Ja.current.contains(S.target)&&qn.current&&!qn.current.contains(S.target)&&Wn(!1)}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[tn]);function Ul(p,S){if(p.filterValue){const R=p.filterValue(S);return R==null||R===""?"":String(R)}return nr(p.cell(S))}function Vl(p){return`"${p.replace(/"/g,'""')}"`}function na(p){return p.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function db(){const p=ut.filter($e=>!Wt($e)),S=p.map($e=>Vl(nr($e.header))).join(","),R=Jt.map($e=>p.map(Ke=>Vl(Ul(Ke,$e))).join(",")).join(`
|
|
5
|
-
`),
|
|
6
|
-
${
|
|
7
|
-
<html lang="es"><head><meta charset="utf-8"><title>${
|
|
1
|
+
(function(Y,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):(Y=typeof globalThis<"u"?globalThis:Y||self,o(Y.BonsaifUI={},Y.React,Y.jsxRuntime,Y.ReactIconsHi2,Y.ReactDOM,Y.Recharts,Y.OverlayScrollbarsGlobal,Y.Sonner,Y.OverlayScrollbarsReact,Y.ReactDayPicker,Y.ReactDayPickerStyles,Y.ReactIconsFi))})(this,(function(Y,o,t,q,dt,Ce,ka,Ho,Bo,Sa,rm,Ci){"use strict";"use client";function jt(...e){return e.filter(Boolean).join(" ")}function Ei({variant:e="primary",className:r,type:n="button",children:a,...s}){return t.jsx("button",{className:jt("bonsaif-ui-button",`bonsaif-ui-button--${e}`,r),type:n,...s,children:a})}function Fo({value:e,onChange:r,placeholder:n,className:a="",autoFocus:s=!1,forceExpanded:l=!1,onEscape:i,size:c="default",inputTabIndex:d}){const u=o.useRef(null),[m,b]=o.useState(!1),f=l||m||e.trim().length>0,g=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",v=a||"w-48 max-w-full sm:w-64 lg:w-72";o.useEffect(()=>{var h;s&&((h=u.current)==null||h.focus())},[s]);const k=()=>{var h;b(!0),(h=u.current)==null||h.focus()};return t.jsxs("div",{className:`relative min-w-0 max-w-full flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${f?v:"w-24 sm:w-28"}`,onMouseDown:h=>{f||(h.preventDefault(),k())},children:[t.jsx(q.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)"}}),t.jsx("input",{ref:u,type:"text",tabIndex:d,"aria-label":n,value:e,onChange:h=>r(h.target.value),onKeyDown:h=>{h.key==="Escape"&&(i==null||i())},placeholder:f?n:"Buscar",className:`${g} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${f?"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:f?"calc(var(--page-header-control-padding-x, 14px) + 18px)":"var(--page-header-control-padding-x, 14px)",background:"color-mix(in srgb, var(--bg-card) 86%, transparent)",border:"1px solid var(--border)",color:"var(--text-main)"},onFocus:h=>{b(!0),h.currentTarget.style.borderColor="var(--primary)",h.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:h=>{b(!1),h.currentTarget.style.borderColor="var(--border)",h.currentTarget.style.boxShadow="none"}}),e&&t.jsx("button",{type:"button",onClick:()=>r(""),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:t.jsx(q.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const Po=o.createContext({});let _o=0;const zo="bonsaif-ui:hide-tooltips";function pn(e=700){_o=Date.now()+e}function Mi(){return Date.now()>_o}function hn(e){if(typeof document>"u")return!1;const r=Array.from(document.querySelectorAll('[data-bonsaif-overlay="true"], [role="menu"], [role="dialog"][aria-modal="true"], [aria-hidden="false"] [aria-modal="true"]'));return e&&r.some(n=>n.contains(e))?!1:r.length>0}function Ti(e){var a;const r=Array.from(e.querySelectorAll("*")).filter(s=>{var l;return s.scrollWidth>s.clientWidth&&!!((l=s.textContent)!=null&&l.trim())&&s.tagName.toLowerCase()!=="svg"&&!s.closest("svg")});return(e.scrollWidth>e.clientWidth||r.length>0)&&(((a=r[0])==null?void 0:a.textContent)??e.textContent??"").trim()||null}function nr({children:e,content:r,onlyWhenOverflow:n=!1,interactive:a=!1,followCursor:s=!0,placement:l="bottom",showArrow:i=!1,className:c="",tooltipClassName:d="",style:u,tooltipStyle:m,as:b="div"}){const f=o.useRef(null),g=o.useRef(null),v=o.useRef(null),k=o.useRef(!1),[h,C]=o.useState(null),[M,y]=o.useState("");o.useEffect(()=>{const L=f.current;L&&(L.querySelectorAll("[title]").forEach(Q=>{const z=Q.getAttribute("title");z&&(Q.getAttribute("aria-label")||Q.setAttribute("aria-label",z),Q.removeAttribute("title"))}),L.querySelectorAll("svg title").forEach(Q=>Q.remove()))}),o.useLayoutEffect(()=>{if(!h)return;const L=g.current;if(!L)return;const Q=12,z=14,se=L.getBoundingClientRect(),re=window.innerWidth-se.width-Q,R=window.innerHeight-se.height-Q;let V=h.mouseX+z,B=h.mouseY+z,le,j;if(!s&&f.current){const W=f.current.getBoundingClientRect(),ae=W.left+W.width/2,H=W.top+W.height/2;l==="top"?(V=ae-se.width/2,B=W.top-se.height-z,j=se.height-1):l==="left"?(V=W.left-se.width-z,B=H-se.height/2,le=se.width-1):l==="right"?(V=W.right+z,B=H-se.height/2,le=-7):(V=ae-se.width/2,B=W.bottom+z,j=-7)}if(s&&(V>re&&(V=h.mouseX-se.width-z),B>R&&(B=h.mouseY-se.height-z)),V=Math.min(Math.max(Q,V),Math.max(Q,re)),B=Math.min(Math.max(Q,B),Math.max(Q,R)),!s&&f.current){const W=f.current.getBoundingClientRect(),ae=W.left+W.width/2,H=W.top+W.height/2;l==="top"||l==="bottom"?le=Math.min(Math.max(14,ae-V),se.width-14):j=Math.min(Math.max(14,H-B),se.height-14)}(Math.abs(V-h.x)>.5||Math.abs(B-h.y)>.5||le!==h.arrowX||j!==h.arrowY)&&C(W=>W&&{...W,x:V,y:B,arrowX:le,arrowY:j})},[s,l,h]);const x=()=>{v.current&&(window.clearTimeout(v.current),v.current=null)},w=(L,Q)=>{if(!Mi()||k.current)return;const z=f.current;if(z&&!hn(z)){if(n){const se=Ti(z);if(!se)return;y(se)}!n&&!r||C({mouseX:L,mouseY:Q,x:L+14,y:Q+14})}},N=()=>{const L=f.current;if(!L)return;const Q=L.getBoundingClientRect();w(Q.left+Q.width/2,Q.bottom)},A=()=>{x(),C(null)},T=()=>{if(!a){A();return}x(),v.current=window.setTimeout(()=>C(null),120)},U=()=>{pn(),k.current=!0,A()},K=()=>{k.current=!1};o.useEffect(()=>{if(!h)return;if(hn(f.current)){C(null);return}const L=()=>C(null),Q=()=>{pn(),k.current=!0,C(null)};document.addEventListener("pointerdown",Q,!0),document.addEventListener("click",Q,!0),document.addEventListener("scroll",L,!0),window.addEventListener("blur",L),document.addEventListener("visibilitychange",L),document.addEventListener("keydown",L,!0);const z=new MutationObserver(()=>{hn(f.current)&&C(null)});return z.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",Q,!0),document.removeEventListener("click",Q,!0),document.removeEventListener("scroll",L,!0),window.removeEventListener("blur",L),document.removeEventListener("visibilitychange",L),document.removeEventListener("keydown",L,!0),z.disconnect()}},[h]),o.useEffect(()=>{const L=()=>pn(),Q=()=>{pn(),k.current=!0,C(null)};return document.addEventListener("pointerdown",L,!0),document.addEventListener("click",L,!0),document.addEventListener("keydown",L,!0),window.addEventListener(zo,Q),()=>{document.removeEventListener("pointerdown",L,!0),document.removeEventListener("click",L,!0),document.removeEventListener("keydown",L,!0),window.removeEventListener(zo,Q)}},[]);const Z=n?M:r;return t.jsxs(t.Fragment,{children:[t.jsx(b,{ref:L=>{f.current=L},className:c,style:u,onMouseEnter:L=>{x(),K(),s?w(L.clientX,L.clientY):N()},onMouseMove:L=>{h&&s&&w(L.clientX,L.clientY)},onMouseDown:U,onClick:U,onMouseLeave:()=>{K(),T()},onFocus:N,onBlur:A,children:e}),h&&Z&&!hn(f.current)?dt.createPortal(t.jsxs("div",{ref:g,role:"tooltip",className:d,onMouseEnter:a?x:void 0,onMouseLeave:a?T:void 0,style:{position:"fixed",top:h.y,left:h.x,zIndex:9999,background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:6,padding:"5px 10px",fontSize:12,color:"var(--text-main)",boxShadow:"0 4px 16px rgba(0,0,0,0.35)",pointerEvents:a?"auto":"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere",...m},children:[i&&t.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:h.arrowX===void 0?void 0:h.arrowX-6,top:h.arrowY===void 0?void 0:h.arrowY-6,zIndex:-1}}),Z]}),document.body):null]})}function Wo(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}const $i="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",Ai={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"},Li="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",Di={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"},Ii={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},Oi={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function Ca(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Ca).join(" ").trim():o.isValidElement(e)?Ca(e.props.children):""}function Hi(e){return o.Children.toArray(e).find(o.isValidElement)??null}function Ue({variant:e="primary",size:r="md",loading:n=!1,icon:a,tooltip:s,iconOnly:l,height:i,padding:c,children:d,className:u="",disabled:m,style:b,...f}){const g=o.useContext(Po),v=l??g.iconOnly??e==="icon",k=g.compact??!1,h=g.headerAction??!1,C=h&&r==="md"?"sm":k&&!h&&r==="md"?"xs":r,M=e==="icon"||v,y=h&&M,x=Ca(d),w=s??f.title??f["aria-label"]??(v?x:void 0),N=w?void 0:f.title,A=f["aria-label"]??(typeof w=="string"?w:x||void 0),T=n?null:a??(v?Hi(d):null),U=t.jsxs("button",{...f,title:N,"aria-label":A,"data-variant":e,"data-size":C,"data-icon":M?"true":void 0,disabled:m||n,className:`${$i} ${y?Li:Ai[e]} ${M?Ii[C]:Di[C]} ${k&&!M?"px-2.5":""} ${u}`,style:{...Oi[e],height:Wo(i),padding:Wo(c),...b,...h&&!M?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...y?{width:"var(--page-header-control-height, 40px)",height:"var(--page-header-control-height, 40px)",padding:0,background:"var(--bg-card)",borderRadius:"8px"}:null},children:[n?t.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):T,!v&&d]});return w?t.jsx(nr,{as:"span",content:w,className:"inline-flex shrink-0",children:U}):U}const ut={background:"color-mix(in srgb, var(--text-muted) 26%, var(--bg-input))"};function gn({rows:e=8,columns:r=7,showToolbar:n=!0,showPagination:a=!0,compact:s=!1,className:l=""}){const i=Math.max(3,Math.min(r,12)),c=Math.max(3,Math.min(e,20)),d=s?"px-2 py-2":"px-3 py-2.5",u=s?"px-2 py-2":"px-3 py-3";return t.jsxs("div",{className:`w-full min-w-0 overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${l}`,"aria-busy":"true","aria-label":"Cargando tabla",children:[n&&t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-3 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("div",{className:"h-7 w-14 shrink-0 animate-pulse rounded-md",style:ut}),t.jsx("div",{className:"h-7 max-w-md flex-1 animate-pulse rounded-md",style:ut})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:ut}),t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:ut})]})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("div",{className:"min-w-full",style:{display:"grid",gridTemplateColumns:`repeat(${i}, minmax(96px, 1fr))`},children:[Array.from({length:i}).map((m,b)=>t.jsx("div",{className:`${u} border-b border-[var(--border)]`,style:{background:"color-mix(in srgb, var(--bg-input) 55%, transparent)"},children:t.jsx("div",{className:"h-3 animate-pulse rounded-md",style:{...ut,width:`${48+b*17%40}%`}})},`h-${b}`)),Array.from({length:c}).map((m,b)=>Array.from({length:i}).map((f,g)=>t.jsx("div",{className:`${d} ${b<c-1?"border-b border-[var(--border)]":""}`,children:t.jsx("div",{className:"h-3.5 animate-pulse rounded-md",style:{...ut,width:`${46+(b*13+g*11)%42}%`,minWidth:28}})},`c-${b}-${g}`)))]})}),a&&t.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:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"h-3 w-28 animate-pulse rounded-md",style:ut}),t.jsx("div",{className:"h-7 w-14 animate-pulse rounded-md",style:ut})]}),t.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:4}).map((m,b)=>t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:ut},b))}),t.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:ut})]})]})}function Bi({size:e="md"}){const r=e==="sm"?"h-7 w-7":"h-9 w-9";return t.jsx("div",{className:`${r} animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]`,"aria-hidden":!0})}function Fi({logoSrc:e,logoAlt:r}){return e?t.jsxs("span",{className:"relative flex h-16 w-16 items-center justify-center","aria-hidden":!1,children:[t.jsx("span",{className:"absolute inset-0 rounded-2xl opacity-40 blur-xl",style:{background:"radial-gradient(circle, color-mix(in srgb, var(--primary) 45%, transparent) 0%, transparent 70%)"}}),t.jsx("img",{src:e,alt:r,className:"relative h-14 w-14 rounded-2xl object-contain shadow-sm shadow-black/10"})]}):null}function jo({variant:e="page",title:r="Cargando...",description:n,logoSrc:a,logoAlt:s,appearance:l="card",rows:i=6,columns:c=7,children:d,className:u=""}){if(e==="table")return t.jsx(gn,{rows:i,columns:c,className:u});if(e==="sections")return t.jsx(Pi,{rows:i});if(e==="cards")return t.jsx(_i,{rows:i});const m=s||(typeof r=="string"?r:"Aplicación"),b=l==="bare",f=t.jsxs("div",{className:`flex flex-col items-center text-center ${b?"gap-5":"gap-3"}`,children:[a?t.jsx(Fi,{logoSrc:a,logoAlt:m}):null,t.jsx(Bi,{size:b?"md":"sm"}),t.jsxs("div",{className:b?"space-y-1.5":"",children:[t.jsx("p",{className:b?"text-base font-semibold tracking-tight text-[var(--text-main)]":"text-sm font-semibold text-[var(--text-main)]",children:r}),n?t.jsx("p",{className:b?"text-sm font-medium text-[var(--text-muted)]":"mt-1 text-xs text-[var(--text-muted)]",children:n}):null,d&&t.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:d})]})]});return b?t.jsx("div",{className:`flex min-h-[240px] w-full items-center justify-center p-8 ${u}`,role:"status","aria-live":"polite","aria-busy":"true",children:f}):t.jsx("div",{className:`flex min-h-[240px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 ${u}`,role:"status","aria-live":"polite","aria-busy":"true",children:f})}function Pi({rows:e}){return t.jsx(gn,{rows:e,columns:7})}function _i({rows:e}){return t.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:Array.from({length:e}).map((r,n)=>t.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[t.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded-md",style:ut}),t.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded-md",style:ut}),t.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded-md",style:ut})]},n))})}function qo(e){const r=e.split("/").filter(Boolean);return(r[r.length-1]??e).replace(/^lv_/,"").split(/[-_]/).filter(Boolean).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}function Uo(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function zi(e){return[e.label,qo(e.service),e.description,e.service].filter(Boolean).join(" ")}function Wi(e){return typeof e=="function"?e:e.default}function ji(e,r){return t.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:t.jsxs("div",{className:"max-w-md",children:[t.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:"No se pudo cargar este modulo"}),t.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:e.message}),t.jsx(Ue,{className:"mt-4",height:36,padding:"0 14px",onClick:r,children:"Reintentar"})]})})}function qi({parentPanel:e,parentPanelComponent:r,renderParentPanel:n,parent:a,context:s,links:l,moduleRegistry:i,loadModule:c,activeService:d,initialService:u,onActiveServiceChange:m,canAccess:b,keepAlive:f=!0,title:g,subtitle:v,emptyState:k,loadingState:h,errorState:C=ji,renderTabLabel:M,searchableTabs:y="auto",tabsSearchThreshold:x=6,tabsSearchPlaceholder:w="Buscar modulo...",tabsSearchValue:N,onTabsSearchChange:A,emptySearchState:T,showTabCount:U=!0,className:K="",parentClassName:Z="",contentClassName:L="",tabsClassName:Q=""}){var lt;const z=o.useMemo(()=>l.filter(me=>!me.hidden&&((b==null?void 0:b(me,s))??!0)),[b,s,l]),se=(lt=z.find(me=>!me.disabled))==null?void 0:lt.service,[re,R]=o.useState(u??se??""),[V,B]=o.useState({}),[le,j]=o.useState({}),[W,ae]=o.useState(""),[H,D]=o.useState(!1),$=o.useRef(le),oe=o.useRef(0),G=N??W,X=Uo(G),S=y===!0||y==="auto"&&z.length>=x,O=S&&G.trim().length>0,I=o.useMemo(()=>X?z.filter(me=>Uo(zi(me)).includes(X)):z,[X,z]),te=d??re,P=z.find(me=>me.service===te)??z.find(me=>!me.disabled);o.useEffect(()=>{!P&&se&&R(se)},[se,P]),o.useEffect(()=>{$.current=le},[le]);const ce=me=>{me.disabled||(d||R(me.service),m==null||m(me.service,me))},he=me=>{N===void 0&&ae(me),A==null||A(me)},ie=(me,Ye)=>{const qe=I.filter(ze=>!ze.disabled),ct=qe.findIndex(ze=>ze.service===Ye.service);ct<0||((me.key==="ArrowRight"||me.key==="ArrowDown")&&(me.preventDefault(),ce(qe[(ct+1)%qe.length])),(me.key==="ArrowLeft"||me.key==="ArrowUp")&&(me.preventDefault(),ce(qe[(ct-1+qe.length)%qe.length])),me.key==="Home"&&(me.preventDefault(),ce(qe[0])),me.key==="End"&&(me.preventDefault(),ce(qe[qe.length-1])))},ge=o.useCallback(()=>{if(!P)return;const me=P.service,Ye=$.current[me];if(Ye!=null&&Ye.loading||Ye!=null&&Ye.component&&f)return;const qe=(i==null?void 0:i[me])??c;if(!qe){j(ze=>({...ze,[me]:{loading:!1,error:new Error(`No module loader found for service "${me}".`)}}));return}const ct=++oe.current;j(ze=>({...ze,[me]:{...ze[me],loading:!0,error:void 0}})),qe(P,s).then(ze=>{if(ct!==oe.current&&!f)return;const bt=Wi(ze);j(mt=>({...mt,[me]:{component:bt,loading:!1}}))}).catch(ze=>{const bt=ze instanceof Error?ze:new Error(String(ze));j(mt=>({...mt,[me]:{...mt[me],loading:!1,error:bt}}))})},[s,f,c,i,P]);o.useEffect(ge,[ge]);const Te=P?V[P.service]??null:null,Le=P?le[P.service]:void 0,It=Le==null?void 0:Le.component,ft=me=>{P&&B(Ye=>({...Ye,[P.service]:me}))},Qe=()=>{P&&B(me=>({...me,[P.service]:null}))},Ot={context:s,parent:a,links:l,visibleLinks:z,filteredLinks:I,selectedLink:P,selectedService:P==null?void 0:P.service,activeItemId:Te,tabsSearch:G,onSelectService:ce,onOpenDetail:ft,onBackToList:Qe},Se=n?n(Ot):r?t.jsx(r,{...Ot}):e;return t.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${K}`,children:[t.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${Z}`,children:Se}),t.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${L}`,children:[(g||v||S||U)&&t.jsx("div",{className:"relative border-b border-[var(--border)] px-4 py-3",children:t.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[g&&t.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:g}),v&&t.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:v})]}),(S||U)&&t.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[U&&t.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[I.length," / ",z.length]}),S&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${H?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!H,children:t.jsx(Fo,{value:G,onChange:he,placeholder:w,className:"w-full",autoFocus:H,forceExpanded:!0,onEscape:()=>D(!1),size:"sm",inputTabIndex:H?0:-1})}),t.jsx("button",{type:"button","aria-label":H?"Cerrar busqueda":"Buscar tabs","aria-expanded":H,onClick:()=>{H&&G&&he(""),D(me=>!me)},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 ${H||O?"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:t.jsx("span",{className:"grid h-4 w-4 place-items-center transition-transform duration-200",children:H||O?t.jsx(q.HiXMark,{className:"h-4 w-4"}):t.jsx(q.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),t.jsx("div",{role:"tablist","aria-label":g??"Modulos relacionados",className:`flex gap-1 overflow-x-auto border-b border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 transition-colors duration-200 ${Q}`,children:I.length>0?I.map(me=>{const Ye=me.service===(P==null?void 0:P.service);return t.jsx("button",{type:"button",role:"tab","aria-selected":Ye,disabled:me.disabled,onClick:()=>ce(me),onKeyDown:qe=>ie(qe,me),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 ${Ye?"border-[var(--primary)] bg-[var(--bg-card)] text-[var(--text-main)] shadow-sm":"border-transparent text-[var(--text-muted)] hover:bg-[var(--bg-card)] hover:text-[var(--text-main)]"}`,children:M?M(me,Ye):t.jsxs(t.Fragment,{children:[me.icon,t.jsx("span",{children:me.label??qo(me.service)}),me.badge&&t.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:me.badge})]})},me.service)}):t.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:T??"No hay modulos que coincidan con la busqueda."})}),(P==null?void 0:P.description)&&t.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:P.description}),t.jsxs("div",{className:"min-h-[420px] p-4",children:[!P&&(k??t.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-dashed border-[var(--border)] text-sm text-[var(--text-muted)]",children:"No hay modulos disponibles."})),P&&(Le==null?void 0:Le.loading)&&(h??t.jsx(jo,{title:"Cargando modulo..."})),P&&(Le==null?void 0:Le.error)&&C(Le.error,ge),P&&It&&!(Le!=null&&Le.loading)&&!(Le!=null&&Le.error)&&t.jsx(It,{context:s,parent:a,link:P,activeItemId:Te,onOpenDetail:ft,onBackToList:Qe})]})]})]})}const Ui={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:t.jsx(q.HiInformationCircle,{className:"h-5 w-5"})},success:{color:"#047857",background:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.24)",icon:t.jsx(q.HiCheckCircle,{className:"h-5 w-5"})},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)",icon:t.jsx(q.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:t.jsx(q.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:t.jsx(q.HiInformationCircle,{className:"h-5 w-5"})}};function Vi({variant:e="info",title:r,children:n,icon:a,action:s,onDismiss:l,className:i=""}){const c=Ui[e];return t.jsxs("div",{role:e==="danger"||e==="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:[t.jsx("div",{className:"mt-0.5 shrink-0",style:{color:c.color},children:a??c.icon}),t.jsxs("div",{className:"min-w-0 flex-1",children:[r&&t.jsx("div",{className:"text-sm font-semibold text-[var(--text-main)]",children:r}),n&&t.jsx("div",{className:"mt-0.5 text-sm leading-5 text-[var(--text-secondary)]",children:n}),s&&t.jsx("div",{className:"mt-3",children:s})]}),l&&t.jsx(Ue,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:t.jsx(q.HiXMark,{className:"h-4 w-4"})})]})}const Vo=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],Yi=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],Xi=["lu","ma","mi","ju","vi","sá","do"],Yo=6;function Ea(e,r,n){return`${e}-${String(r).padStart(2,"0")}-${String(n).padStart(2,"0")}`}function Ki(){const e=new Date;return Ea(e.getFullYear(),e.getMonth()+1,e.getDate())}function Xo(e){const[r,n,a]=e.split("-").map(Number);return{year:r,month:n,day:a}}function Gi(e){if(!e)return"Seleccionar fecha";const{year:r,month:n,day:a}=Xo(e);return!r||!n||!a?"Seleccionar fecha":`${String(a).padStart(2,"0")} ${Vo[n-1]} ${r}`}function Zi({value:e,onChange:r,minDate:n,displayMode:a="inline",className:s=""}){const l=Ki(),c=Xo(e||l),d=a==="popover",[u,m]=o.useState(!1),b=o.useRef(null),[f,g]=o.useState({horizontal:"left",vertical:"bottom"}),[v,k]=o.useState(c.year),[h,C]=o.useState(c.month),[M,y]=o.useState("days"),x=16,[w,N]=o.useState(0),A=v-7+w,T=Array.from({length:x},(R,V)=>A+V);o.useEffect(()=>{if(!d||!u||!b.current)return;const R=b.current.getBoundingClientRect(),V=8,B=280,le=340,j=R.left+B>window.innerWidth-V,W=R.right-B>=V,ae=R.bottom+8+le>window.innerHeight-V,H=R.top-8-le>=V;g({horizontal:j&&W?"right":"left",vertical:ae&&H?"top":"bottom"})},[d,u]),o.useEffect(()=>{if(!d||!u)return;function R(B){b.current&&(b.current.contains(B.target)||m(!1))}function V(B){B.key==="Escape"&&m(!1)}return document.addEventListener("mousedown",R),document.addEventListener("keydown",V),()=>{document.removeEventListener("mousedown",R),document.removeEventListener("keydown",V)}},[d,u]);function U(){h===1?(k(R=>R-1),C(12)):C(R=>R-1)}function K(){h===12?(k(R=>R+1),C(1)):C(R=>R+1)}const Z=(new Date(v,h-1,1).getDay()+6)%7,L=new Date(v,h,0).getDate(),Q=[...Array(Z).fill(null),...Array.from({length:L},(R,V)=>V+1)];for(;Q.length<Yo*7;)Q.push(null);const z=Q.slice(0,Yo*7);function se(R){const V=Ea(v,h,R);n&&V<n||(r(V),d&&m(!1))}const re=t.jsx("div",{className:`bonsaif-calendar bonsaif-calendar-picker ${s}`.trim(),children:t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsx("div",{className:"bonsaif-cal-toolbar",children:M==="days"?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:U,"aria-label":"Mes anterior",children:t.jsx(q.HiChevronLeft,{size:16})}),t.jsxs("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>{y("years"),N(0)},children:[t.jsxs("span",{className:"bonsaif-cal-title",children:[Vo[h-1]," ",v]}),t.jsx(q.HiChevronDown,{size:13})]}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:K,"aria-label":"Mes siguiente",children:t.jsx(q.HiChevronRight,{size:16})})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>N(R=>R-x),"aria-label":"Años anteriores",children:t.jsx(q.HiChevronLeft,{size:16})}),t.jsx("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>y("days"),children:t.jsxs("span",{className:"bonsaif-cal-title",children:[T[0]," – ",T[T.length-1]]})}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>N(R=>R+x),"aria-label":"Años siguientes",children:t.jsx(q.HiChevronRight,{size:16})})]})}),M==="years"?t.jsxs("div",{className:"bonsaif-cal-picker-years",children:[t.jsx("div",{className:"bonsaif-cal-picker-months",children:Yi.map((R,V)=>{const B=V+1===h;return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${B?" is-active":""}`,onClick:()=>C(V+1),children:R},R)})}),t.jsx("div",{className:"bonsaif-cal-picker-year-grid",children:T.map(R=>{const V=R===v,B=R===new Date().getFullYear();return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${V?" is-active":""}${B&&!V?" is-today":""}`,onClick:()=>{k(R),y("days")},children:R},R)})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bonsaif-multi-weekdays bonsaif-cal-picker-weekdays",children:Xi.map(R=>t.jsx("div",{className:"bonsaif-multi-weekday",children:R},R))}),t.jsx("div",{className:"bonsaif-cal-picker-days",children:z.map((R,V)=>{if(R===null)return t.jsx("div",{className:"bonsaif-multi-day bonsaif-multi-day-hidden"},V);const B=Ea(v,h,R),le=B===e,j=B===l,W=!!(n&&B<n);return t.jsx("div",{className:`bonsaif-multi-day${le?" bonsaif-multi-day-selected":""}${j?" bonsaif-multi-day-today":""}${W?" bonsaif-multi-day-disabled":""}`,children:t.jsx("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:W,"aria-pressed":le,onClick:()=>!W&&se(R),children:R})},V)})})]})]})});return d?t.jsxs("div",{ref:b,className:`relative w-full ${s}`.trim(),children:[t.jsxs("button",{type:"button",onClick:()=>m(R=>!R),className:"bonsaif-cal-trigger","data-open":u?"true":"false",children:[t.jsxs("span",{className:"inline-flex items-center gap-2 min-w-0",children:[t.jsx(q.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:Gi(e)})]}),t.jsx(q.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${u?"rotate-180":""}`})]}),u&&t.jsx("div",{className:"absolute z-50",style:{...f.horizontal==="left"?{left:0}:{right:0},...f.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:re})]}):re}const Qi={sm:"h-4 w-4",md:"h-5 w-5"};function Ji(e,r){if(typeof e=="function"){e(r);return}e&&(e.current=r)}const vn=o.forwardRef(function({label:r,description:n,error:a,size:s="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:d,...u},m){const b=o.useRef(null);return o.useEffect(()=>{b.current&&(b.current.indeterminate=l)},[l]),t.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${d?"cursor-not-allowed opacity-60":"cursor-pointer"} ${c}`,children:[t.jsxs("span",{className:"relative mt-0.5 inline-flex shrink-0",children:[t.jsx("input",{...u,ref:f=>{b.current=f,Ji(m,f)},type:"checkbox",disabled:d,"aria-checked":l?"mixed":u["aria-checked"],"aria-invalid":!!a||u["aria-invalid"],className:`peer ${Qi[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}`}),t.jsx(q.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"})]}),(r||n||a)&&t.jsxs("span",{className:"min-w-0",children:[r&&t.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:r}),n&&!a&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:n}),a&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--danger)]",children:a})]})]})});function Ko(e){const r=document.createElement("textarea");r.value=e,r.style.position="fixed",r.style.opacity="0",r.style.pointerEvents="none",document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r)}async function Ri(e){var r;if((r=navigator.clipboard)!=null&&r.writeText){await navigator.clipboard.writeText(e);return}Ko(e)}function ec(e){return typeof e=="function"?e():e}function Ma({value:e,resetDelay:r=2e3,title:n,copiedTitle:a="Copiado",copiedLabel:s,icon:l=t.jsx(q.HiClipboardDocument,{size:14}),copiedIcon:i=t.jsx(q.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:d,onCopyError:u,className:m="",style:b,children:f,onClick:g,type:v="button",...k}){const[h,C]=o.useState(!1),M=o.useRef(null);o.useEffect(()=>()=>{M.current&&window.clearTimeout(M.current)},[]);function y(w){C(!0),d==null||d(w),M.current&&window.clearTimeout(M.current),M.current=window.setTimeout(()=>{C(!1),M.current=null},r)}async function x(w){var A;if(c&&w.stopPropagation(),g==null||g(w),w.defaultPrevented)return;const N=ec(e);if(N)try{await Ri(N),y(N)}catch(T){try{Ko(N),y(N)}catch(U){u==null||u(U,N);return}(A=navigator.clipboard)!=null&&A.writeText||u==null||u(T,N)}}return t.jsxs("button",{...k,type:v,onClick:x,title:h?a:n,"aria-label":k["aria-label"]??(h?a:n),"data-copied":h?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${f?"min-w-7 px-2":"w-7"} ${m}`,style:{cursor:"pointer",background:h?"rgba(22,163,74,0.15)":"var(--bg-card)",border:h?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:h?"#16a34a":"var(--text-secondary)",boxShadow:h?"0 0 0 3px rgba(22,163,74,0.12)":"none",...b},children:[t.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:h?"scale(1.15)":"scale(1)"},children:h?i:l}),f&&t.jsx("span",{className:"text-xs font-semibold leading-none",children:h?s??f:f})]})}function tc({code:e,children:r,title:n="Codigo",language:a,copyLabel:s="Copiar",copiedLabel:l="Copiado",className:i="",style:c,onCopied:d}){const u=(e??r??"").trim();return t.jsxs("div",{className:`overflow-hidden rounded-lg border ${i}`,style:{borderColor:"rgba(148, 163, 184, 0.22)",background:"#0f172a",color:"#e2e8f0",...c},children:[t.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:[t.jsx("span",{className:"min-w-0 truncate text-[11px] font-black uppercase tracking-[0.08em]",children:n}),t.jsx(Ma,{value:u,title:"Copiar codigo",copiedTitle:"Codigo copiado",copiedLabel:l,onCopied:d,className:"h-7 min-w-[72px] px-2",style:{background:"#182235",border:"1px solid rgba(148, 163, 184, 0.28)",color:"#f8fafc"},children:s})]}),t.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:t.jsx("code",{className:a?`language-${a}`:void 0,children:u})})]})}function Ta(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function $a(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function rc(e,r){if(!r.trim())return!0;const n=$a(r);return $a(e.label).includes(n)||!!(e.sublabel&&$a(e.sublabel).includes(n))}function ar({value:e,onChange:r,options:n,status:a="default",ariaLabel:s,triggerVariant:l="default",showSelectedSublabel:i=!0,placeholder:c="Seleccionar…",emptyLabel:d,disabled:u=!1,className:m="",style:b,dropdownMinWidth:f,height:g=40,padding:v="0 10px",searchable:k=!0,minOptionsForSearch:h=6}){const[C,M]=o.useState(!1),[y,x]=o.useState(""),[w,N]=o.useState(-1),[A,T]=o.useState(!1),[U,K]=o.useState({}),Z=o.useRef(null),L=o.useRef(null),Q=o.useRef(null),z=o.useRef(null),se=k&&n.length>=h,re=n.find(G=>G.value===e)??null,R=l==="ghost",V=a==="error"?"var(--danger)":C?"var(--primary)":"var(--border)",B=se&&y.trim()?n.filter(G=>rc(G,y)):n,le=o.useCallback(()=>{const G=Z.current;if(!G)return;const X=G.getBoundingClientRect(),S=se?272:212,O=window.innerHeight-X.bottom,I=O<S&&X.top>O;K({position:"fixed",left:X.left,top:I?void 0:X.bottom+4,bottom:I?window.innerHeight-X.top+4:void 0,width:X.width,minWidth:Ta(f),zIndex:9999})},[f,se]);o.useEffect(()=>T(!0),[]),o.useEffect(()=>{if(!C)return;function G(X){var O,I;const S=X.target;!((O=Z.current)!=null&&O.contains(S))&&!((I=L.current)!=null&&I.contains(S))&&(M(!1),x(""))}return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[C]),o.useEffect(()=>{C&&(N(-1),le(),se&&setTimeout(()=>{var G;return(G=Q.current)==null?void 0:G.focus()},0))},[C,se,le]),o.useEffect(()=>{if(C)return window.addEventListener("resize",le),window.addEventListener("scroll",le,!0),()=>{window.removeEventListener("resize",le),window.removeEventListener("scroll",le,!0)}},[C,le]),o.useEffect(()=>{if(w<0||!z.current)return;const G=z.current.children[w];G==null||G.scrollIntoView({block:"nearest"})},[w]);const j=o.useCallback(G=>{r(G),M(!1),x("")},[r]),W=o.useRef(C);W.current=C;const ae=o.useRef(B);ae.current=B;const H=o.useRef(w);H.current=w;const D=o.useRef(d);D.current=d;const $=o.useRef(j);$.current=j,o.useEffect(()=>{function G(X){var te,P;const S=document.activeElement,O=((te=Z.current)==null?void 0:te.contains(S))??!1,I=((P=L.current)==null?void 0:P.contains(S))??!1;if(!(!O&&!I)){if(!W.current){(X.key==="Enter"||X.key===" "||X.key==="ArrowDown")&&(X.preventDefault(),M(!0));return}switch(X.key){case"ArrowDown":X.preventDefault(),N(ce=>Math.min(ce+1,ae.current.length-1));break;case"ArrowUp":X.preventDefault(),N(ce=>Math.max(ce-1,D.current?-1:0));break;case"Enter":{X.preventDefault();const ce=H.current,he=ae.current;ce===-1&&D.current?$.current(""):he[ce]&&!he[ce].disabled&&$.current(he[ce].value);break}case"Escape":X.preventDefault(),X.stopPropagation(),M(!1),x("");break}}}return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[]);const oe=t.jsxs("div",{ref:L,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...U,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[se&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(q.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:Q,value:y,onChange:G=>{x(G.target.value),N(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),y&&t.jsx("button",{type:"button",onMouseDown:G=>{G.preventDefault(),x("")},children:t.jsx(q.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),t.jsxs("ul",{ref:z,role:"listbox",className:"overflow-y-auto",style:{maxHeight:se?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[d&&t.jsx("li",{role:"option","aria-selected":e==="",onMouseDown:G=>{G.preventDefault(),j("")},onMouseEnter:()=>N(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:w===-1&&!y.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:d}),B.map((G,X)=>{const O=X===w,I=G.value===e;return t.jsxs("li",{role:"option","aria-selected":I,onMouseDown:te=>{te.preventDefault(),G.disabled||j(G.value)},onMouseEnter:()=>!G.disabled&&N(X),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:O?"var(--bg-hover)":I?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:G.disabled?"var(--text-muted)":"var(--text-main)",cursor:G.disabled?"not-allowed":"pointer",boxShadow:I?"inset 2px 0 0 var(--primary)":void 0},children:[G.color&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:G.color}}),t.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx("span",{className:"truncate",children:G.label}),G.sublabel&&t.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:G.sublabel})]}),G.badge&&t.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:G.badge})]},G.value)}),B.length===0&&t.jsx("li",{className:"px-3 py-4 text-sm text-center",style:{color:"var(--text-muted)"},children:"Sin resultados"})]})]});return t.jsxs("div",{ref:Z,className:`relative ${m||"w-full"}`,style:b,children:[t.jsxs("button",{type:"button",disabled:u,onClick:()=>!u&&M(G=>!G),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:Ta(g),padding:Ta(v),background:R?"transparent":"var(--bg-input)",color:re?"var(--text-main)":"var(--text-muted)",border:R?"1px solid transparent":`1px solid ${V}`,opacity:u?.5:1,cursor:u?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":C,"aria-label":s,children:[(re==null?void 0:re.color)&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:re.color}}),t.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:re?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"truncate",children:re.label}),i&&re.sublabel&&t.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:re.sublabel})]}):t.jsx("span",{className:"truncate",children:c})}),re&&d?t.jsx("span",{role:"button",tabIndex:-1,onMouseDown:G=>{G.preventDefault(),G.stopPropagation(),j("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(q.HiXMark,{className:"w-3 h-3"})}):t.jsx(q.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:C?"rotate(180deg)":"rotate(0deg)"}})]}),C&&A&&dt.createPortal(oe,document.body)]})}function yn(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function nc({value:e,onChange:r,placeholder:n="Buscar...",className:a="",height:s=40,padding:l="0 10px 0 30px",iconLeft:i=10}){return t.jsxs("div",{className:`relative ${a}`,children:[t.jsx(q.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:yn(i)}}),t.jsx("input",{type:"text",value:e,onChange:c=>r(c.target.value),placeholder:n,className:"w-full rounded-lg border border-[var(--border)] [background:var(--bg-card)] text-sm text-[var(--text-main)] placeholder:text-[var(--text-muted)] outline-none transition-[border-color,box-shadow] focus:border-primary focus:ring-2 focus:ring-primary/20",style:{height:yn(s),padding:yn(l)}})]})}function ac({value:e,onChange:r,options:n,placeholder:a,icon:s,className:l="",height:i=40,padding:c,iconLeft:d=10,searchable:u=!0}){const m=s?n.map((b,f)=>f===0&&!b.color?{...b,sublabel:b.sublabel??void 0}:b):n;return t.jsxs("div",{className:`relative ${l}`,children:[s&&t.jsx("span",{className:"pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--text-muted)]",style:{left:yn(d)},children:s}),t.jsx(ar,{value:e,onChange:r,options:m,placeholder:a,searchable:u,minOptionsForSearch:5,height:i,padding:c??(s?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const oc={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},xn=180,sc="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Aa({open:e,onClose:r,title:n,subtitle:a,leadingIcon:s,headerActions:l,footer:i,children:c,size:d="md",maxWidth:u,zIndex:m=1e3,closeOnBackdrop:b=!0,closeOnEscape:f=!0,showCloseButton:g=!0,placement:v="center",bodyClassName:k="px-6 py-5",panelClassName:h="",backdropClassName:C=sc,contentClassName:M="p-4",ariaLabel:y,frameless:x=!1,disabled:w=!1}){const[N,A]=o.useState(!1),[T,U]=o.useState(!1),K=o.useRef(null);if(o.useEffect(()=>(e?(K.current&&clearTimeout(K.current),A(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>U(!0)))):(U(!1),K.current=setTimeout(()=>A(!1),xn+40)),()=>{K.current&&clearTimeout(K.current)}),[e]),o.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),o.useEffect(()=>{if(!e||!f)return;const re=R=>{R.key==="Escape"&&r()};return window.addEventListener("keydown",re),()=>window.removeEventListener("keydown",re)},[f,r,e]),!N)return null;const Z=n||a||s||l||g,L=u??oc[d],Q=v==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",z=v==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",se=T?"translateY(0) scale(1)":v==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return dt.createPortal(t.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":y??n,className:`fixed inset-0 flex ${Q} ${M}`,style:{zIndex:m},children:[t.jsx("div",{className:`absolute inset-0 ${C}`,onClick:b?r:void 0,style:{opacity:T?1:0,transition:`opacity ${xn}ms ease`}}),t.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${x?"shadow-none":"shadow-2xl"} ${z} ${h}`,style:{maxWidth:L,background:x?"transparent":"var(--bg-card)",border:x?"none":"1px solid var(--border)",opacity:T?1:0,transform:se,transition:`opacity ${xn}ms ease, transform ${xn}ms ease`},onClick:re=>re.stopPropagation(),children:[w&&t.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&&t.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between gap-3 px-6 py-4",style:{borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[s&&t.jsx("div",{className:"flex-shrink-0",children:s}),(n||a)&&t.jsxs("div",{className:"min-w-0",children:[n&&t.jsx("h2",{className:"truncate text-base font-semibold",style:{color:"var(--text-main)"},children:n}),a&&t.jsx("p",{className:"truncate text-xs",style:{color:"var(--text-muted)"},children:a})]})]}),t.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[l,g&&t.jsx(Ue,{variant:"icon",onClick:r,title:"Cerrar",children:t.jsx(q.HiXMark,{className:"h-5 w-5"})})]})]}),t.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${k}`,children:c}),i&&t.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 lc={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 ic({open:e,title:r,description:n,confirmLabel:a="Confirmar",cancelLabel:s="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:d}){const u=lc[l];return t.jsx(Aa,{open:e,onClose:d,size:"md",zIndex:9998,showCloseButton:!1,bodyClassName:"p-0",panelClassName:"overflow-visible",ariaLabel:r,closeOnBackdrop:i,children:t.jsxs("div",{className:"relative px-6 pb-6 pt-6",children:[t.jsx(Ue,{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:t.jsx(q.HiXMark,{className:"h-4 w-4"})}),t.jsxs("div",{className:"flex gap-3 pr-8",children:[t.jsx("div",{className:"mt-0.5 flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl",style:{background:u.iconBg},children:t.jsx(q.HiExclamationTriangle,{className:"h-5 w-5",style:{color:u.iconColor}})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h2",{className:"text-base font-semibold leading-snug",style:{color:"var(--text-main)"},children:r}),n?t.jsx("div",{className:"mt-1.5 text-sm leading-relaxed",style:{color:"var(--text-muted)"},children:n}):null]})]}),t.jsxs("div",{className:"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[t.jsx(Ue,{variant:"secondary",onClick:d,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:s}),t.jsx(Ue,{variant:"danger",onClick:c,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:u.btnBg,color:u.btnColor,borderColor:"transparent"},children:a})]})]})})}function cc(e){return e?typeof e=="function"?e():e:""}function dc(e){return/^https?:\/\//i.test(e)}function Go(e,r){try{return new URL(e,r).toString()}catch{return e}}function uc(e,r,n,a=!1){const s=typeof e=="function"?e():e,l=r?r(s):s;if(!l||dc(l))return l;const i=cc(n);return i?Go(l,i):a&&typeof window<"u"?Go(l,window.location.origin):l}function fc({url:e,resolveUrl:r,baseUrl:n,useWindowOriginForRelative:a=!1,title:s="Copiar link",copiedTitle:l="Link copiado",icon:i=t.jsx(q.HiLink,{className:"h-3.5 w-3.5"}),...c}){return t.jsx(Ma,{...c,value:()=>uc(e,r,n,a),title:s,copiedTitle:l,icon:i})}const wn=[25,50,100,200,500];let Et={dataTable:{pageSizeOptions:[...wn]}};function bc(){if(typeof window>"u")return;const r=window.__BONSAIF_DATA_TABLE_PREFERENCES_ENDPOINT__;return typeof r=="string"&&r.trim().length>0?r.trim().replace(/\/+$/,""):void 0}function La(){const e=Et.dataTable.preferencesEndpoint,r=bc();return e&&e.trim().length>0?e.trim().replace(/\/+$/,""):r}function mc(e){if(!Array.isArray(e))return[...wn];const r=Array.from(new Set(e.map(n=>typeof n=="number"?Math.floor(n):Number.NaN).filter(n=>Number.isFinite(n)&&n>0)));return r.length>0?r:[...wn]}function Zo(e){if(typeof e!="string")return;const r=e.trim();if(r)return r.replace(/\/+$/,"")}function pc(e){if(!e||typeof e!="object"||!e.dataTable)return;const r=Zo(e.dataTable.preferencesEndpoint);Et={...Et,dataTable:{...Et.dataTable,pageSizeOptions:mc(e.dataTable.pageSizeOptions),preferencesEndpoint:r??Et.dataTable.preferencesEndpoint}}}function hc(){return{dataTable:{pageSizeOptions:[...Et.dataTable.pageSizeOptions]}}}function Vr(){return[...Et.dataTable.pageSizeOptions]}function gc(){Et={dataTable:{pageSizeOptions:[...wn]}}}function vc(e){Et={...Et,dataTable:{...Et.dataTable,preferencesEndpoint:Zo(e)}}}const Nn=[{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"}],yc=Nn.map(e=>({value:e.value,label:e.label})),xc=12,wc={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},Qo={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},Nc="bonsaif-ui:datatable:",kc="[&_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",Sc=[],Cc=52;function Pt(e){if(!e)return 150;const r=parseInt(e,10);return isNaN(r)||r<=0?150:r}function Jo(e){return!!(e&&(Array.isArray(e.columnOrder)&&e.columnOrder.length>0||e.columnWidths&&Object.keys(e.columnWidths).length>0||Array.isArray(e.hiddenColumnKeys)&&e.hiddenColumnKeys.length>0||e.filters&&Object.keys(e.filters).length>0||e.conditionFilters&&Object.keys(e.conditionFilters).length>0||e.sort||typeof e.bql=="string"||Array.isArray(e.bqlHistory)&&e.bqlHistory.length>0||typeof e.pageSize=="number"))}function Ro(e){return`${Nc}${e}`}function kn(e){try{const r=window.localStorage.getItem(Ro(e));if(!r)return null;const n=JSON.parse(r);return n&&typeof n=="object"?n:null}catch{return null}}function Ec(e,r){try{window.localStorage.setItem(Ro(e),JSON.stringify(r))}catch{}}function Mc(e,r){if(e===!0)return{...Qo};if(e===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(r&&e==null)return{...Qo};const n={...wc,...e??{}};return r&&(typeof e!="object"||e.pagination!==!1)&&(n.pagination=!0),n}function es(...e){return e.reduce((r,n)=>({...r,...n??{}}),{})}function Da(e,r,n){return typeof e!="number"||e<=0?n:Zr(r).includes(e)?e:n}function Yr(e){if(!e||typeof e!="object")return!1;const r=e;return typeof r.key=="string"&&(r.dir==="asc"||r.dir==="desc")}function Xr(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=Object.entries(e).flatMap(([a,s])=>{if(!r.has(a)||!Array.isArray(s))return[];const l=s.filter(i=>typeof i=="string");return l.length>0?[[a,l]]:[]});return Object.fromEntries(n)}function Kr(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=new Set(Nn.map(s=>s.value)),a=Object.entries(e).flatMap(([s,l])=>{if(!r.has(s)||!l||typeof l!="object")return[];const i=l;return!i.operator||!n.has(i.operator)?[]:[[s,{operator:i.operator,value:typeof i.value=="string"?i.value:"",valueTo:typeof i.valueTo=="string"?i.valueTo:""}]]});return Object.fromEntries(a)}function yt(e,r){if(or(e))return Cc;const n=e.minWidth??80,a=e.maxWidth??1/0;return Math.min(a,Math.max(n,r))}function Tc(e){const r=window.getComputedStyle(e);return parseFloat(r.paddingLeft)+parseFloat(r.paddingRight)}function or(e){return e.key==="actions"||e.key==="acciones"?!0:typeof e.header=="string"&&e.header.trim().toLowerCase()==="acciones"}function Ia(e){return e.sticky===!0}function ts(e){return!(e.reorderable===!1||e.sticky&&e.reorderable!==!0)}function qt(e,r){const n=r.filter(Ia).map(i=>i.key);if(n.length===0)return e;const a=new Set(n),s=n.filter(i=>e.includes(i)),l=e.filter(i=>!a.has(i));return[...s,...l]}function $c(e,r){if(r<=7)return Array.from({length:r},(a,s)=>s+1);const n=[1];e>3&&n.push("...");for(let a=Math.max(2,e-1);a<=Math.min(r-1,e+1);a++)n.push(a);return e<r-2&&n.push("..."),n.push(r),n}function Ut(e,r){var i;const n=new Set(r.filter(c=>c.hideable!==!1).map(c=>c.key)),a=Array.from(new Set(e??[])).filter(c=>n.has(c));if(r.filter(c=>!a.includes(c.key)).length>0)return a;const l=(i=r.find(c=>c.hideable!==!1))==null?void 0:i.key;return l?a.filter(c=>c!==l):[]}function Ac(e){return e==null||e===""?"(Vacio)":e instanceof Date?e.toLocaleDateString():String(e)}function gr(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(gr).join(" ").trim():o.isValidElement(e)?gr(e.props.children):""}function Sn(e,r){const n=e.filterValue?e.filterValue(r):e.sortKey?r[e.sortKey]:e.cell(r);return typeof n=="string"||typeof n=="number"||typeof n=="boolean"||n===null||n===void 0||n instanceof Date?Ac(n):gr(n).trim()}function Gr(e){const r=e.replace(/,/g,"").trim();if(!r)return null;const n=Number(r);return Number.isFinite(n)?n:null}function vr(e,r){const n=Gr(e),a=Gr(r);return n!==null&&a!==null?n-a:e.localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})}function Zr(e){const r=Array.from(new Set(e.map(n=>Math.floor(n)).filter(n=>Number.isFinite(n)&&n>0)));return r.length>0?r:Vr()}function Lc(e,r,n){var i,c;const a=((i=r.value)==null?void 0:i.trim())??"",s=((c=r.valueTo)==null?void 0:c.trim())??"",l=Nn.find(d=>d.value===r.operator);if((l==null?void 0:l.valueMode)==="single"&&!a||(l==null?void 0:l.valueMode)==="between"&&(!a||!s))return!0;switch(r.operator){case"equals":return e.toLowerCase()===a.toLowerCase();case"notEquals":return e.toLowerCase()!==a.toLowerCase();case"greaterThan":return vr(e,a)>0;case"greaterThanOrEqual":return vr(e,a)>=0;case"lessThan":return vr(e,a)<0;case"lessThanOrEqual":return vr(e,a)<=0;case"between":return vr(e,a)>=0&&vr(e,s)<=0;case"top10":case"bottom10":{const u=n.map(b=>({value:b,number:Gr(b)})).filter(b=>b.number!==null).sort((b,f)=>b.number-f.number).map(b=>b.value);return(r.operator==="top10"?u.slice(-10):u.slice(0,10)).includes(e)}case"aboveAverage":case"belowAverage":{const d=n.map(Gr).filter(b=>b!==null);if(d.length===0)return!1;const u=d.reduce((b,f)=>b+f,0)/d.length,m=Gr(e);return m===null?!1:r.operator==="aboveAverage"?m>u:m<u}default:return!0}}function rs({children:e,className:r="",style:n}){return t.jsx(nr,{onlyWhenOverflow:!0,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,...n},children:e})}function ns({columns:e,data:r,getRowId:n,loading:a=!1,skeletonRows:s=8,emptyIcon:l,emptyText:i="Sin resultados",initialEmptyDelay:c=450,onRowClick:d,renderExpandedRow:u,getRowCanExpand:m,expandedRowIds:b,defaultExpandedRowIds:f=[],onExpandedRowIdsChange:g,expandOnRowClick:v=!1,selected:k,onToggleOne:h,onToggleAll:C,getRowSelectable:M,highlightSelected:y=!0,rowClassName:x,getRowCategory:w,stickyHeader:N=!0,pageSize:A=25,pageSizeOptions:T,pageSizeSelectWidth:U=62,pageSizeSelectHeight:K=30,pageSizeSelectPadding:Z="0 7px",totalRows:L,page:Q,onPageChange:z,onPageSizeChange:se,storageKey:re,stickyFirstColumn:R=!1,bottomOffset:V=0,compact:B=!0,restrictHeight:le=!0,maxHeight:j,minTableWidth:W,enableColumnVisibility:ae=!0,enableColumnFilters:H=!0,hiddenColumnKeys:D,defaultHiddenColumnKeys:$=Sc,onHiddenColumnKeysChange:oe,columnVisibilityLabel:G="Columnas",enableBql:X=!1,bqlValue:S,defaultBqlValue:O="",onBqlChange:I,bqlDescription:te="Filtra registros con Bonsaif Query Language",bqlPlaceholder:P=`status = activo
|
|
2
|
+
rol IN (admin, employee)`,bqlQuickFilters:ce=[],bqlExamples:he=[],bqlSuggestions:ie=[],bqlActiveFilters:ge,bqlError:Te,onQueryChange:Le,persistState:It,onPreferencesReady:ft,enableExport:Qe=!1,exportFilename:Ot="datos"}){var ki;const Se=Mc(It,re),lt=Object.values(Se).some(Boolean),me=e.map(p=>p.key).join(","),Ye=$.join(","),qe=o.useRef(e),ct=o.useRef($);qe.current=e,ct.current=$;const[ze,bt]=o.useState(!re||!lt),mt=o.useRef(null),et=o.useRef(!re),Kt=o.useRef(!1),de=o.useRef(ft);de.current=ft;const pe=o.useRef(!re||!lt?re??"__none__":null),Me=D!==void 0,[Pe,Be]=o.useState(()=>Ut($,e)),Fe=Ut(Me?D:Pe,e),[tt,rt]=o.useState(!1),[Ke,nt]=o.useState("filter"),[Oe,Ht]=o.useState(null),[ta,ra]=o.useState(""),[at,Gt]=o.useState({}),[pt,Zt]=o.useState({}),_=b!==void 0,[J,ue]=o.useState(f),fe=S!==void 0,[$e,xe]=o.useState(O),De=fe?S:$e,[Ie,ot]=o.useState(De),[We,ht]=o.useState(!1),[zt,gt]=o.useState(!1),[lr,Wt]=o.useState(!1),[Qt,Or]=o.useState([]),Hr=o.useRef(null),ir=o.useRef(null),Bt=o.useRef(I);Bt.current=I;const na=o.useRef(A);na.current=A;const aa=o.useRef(T);aa.current=T;const gb=Array.isArray(T)?T.join(","):"",go=o.useRef(null),Kl=o.useRef(null),vo=o.useRef(null),Gl=o.useRef(0),[vb,yb]=o.useState({}),[xb,wb]=o.useState({}),[dn,oa]=o.useState(!1),yo=o.useRef(null),sa=o.useRef(null),[Nb,kb]=o.useState({}),Zl=o.useRef(null),la=o.useRef(null),[xo,Ql]=o.useState(r.length>0||a||c===!1),Jl=(p,E)=>50+(p*17+E*13+7)%40,Jt=o.useRef(null),[Sb,Cb]=o.useState(void 0),[Rl,Eb]=o.useState(0),[Mb,Tb]=o.useState(!1);o.useEffect(()=>{function p(){Tb(window.innerWidth<640)}if(!le||j!==void 0)return p(),window.addEventListener("resize",p),()=>window.removeEventListener("resize",p);const ee=A!==!1?48:0,F=12;function ne(){if(p(),!Jt.current)return;const be=Jt.current.getBoundingClientRect().top;Cb(Math.max(120,window.innerHeight-be-ee-F-V))}return ne(),window.addEventListener("resize",ne),()=>window.removeEventListener("resize",ne)},[a,A,V,le,j]);const ei=le?j??Sb:void 0;o.useEffect(()=>{const p=Jt.current;if(!p)return;const E=()=>Eb(p.clientWidth);if(E(),typeof ResizeObserver>"u")return window.addEventListener("resize",E),()=>window.removeEventListener("resize",E);const ee=new ResizeObserver(E);return ee.observe(p),()=>ee.disconnect()},[a,ze,r.length]),o.useEffect(()=>{if(c===!1||a||r.length>0){Ql(!0);return}if(xo)return;const p=window.setTimeout(()=>{Ql(!0)},c);return()=>window.clearTimeout(p)},[r.length,c,xo,a]);const[Br,Fr]=o.useState(()=>qt(e.map(p=>p.key),e)),[cr,Pr]=o.useState(()=>Object.fromEntries(e.map(p=>[p.key,yt(p,Pt(p.width))]))),[Ve,dr]=o.useState(null),[$b,ia]=o.useState(1),[ca,da]=o.useState(A===!1?0:A);o.useEffect(()=>{var Ee;const p=qe.current,E=ct.current,ee=p.map(ke=>ke.key),F=new Set(ee),ne=()=>{var ke;Kt.current||(Kt.current=!0,(ke=de.current)==null||ke.call(de))};if(!re||!lt){Se.layout&&Fr(qt(ee,p)),Me||Be(Ut(E,p)),et.current=!1,bt(!0),ne();return}let be=!1;const ye=pe.current===re;ye||(et.current=!1,bt(!1),Kt.current=!1);const Ae=kn(re);if(Jo(Ae)&&!ye){const ke=Ae,we=Zr(aa.current??Vr()),Ne=na.current,pr=Ne===!1?0:Ne,er=Se.layout?ke==null?void 0:ke.columnOrder:void 0,tr=Array.isArray(er)?er.filter(_e=>ee.includes(_e)):[],rr=ee.filter(_e=>!tr.includes(_e)),hr=qt(tr.length>0?[...tr,...rr]:ee,p),Wr=Object.fromEntries(p.map(_e=>[_e.key,yt(_e,Pt(_e.width))])),jr=Se.layout?(ke==null?void 0:ke.columnWidths)??{}:{},mn=Object.fromEntries(p.map(_e=>[_e.key,yt(_e,jr[_e.key]??Wr[_e.key])])),qr=Ut(Se.layout?(ke==null?void 0:ke.hiddenColumnKeys)??E:E,p);if(Se.layout&&(Fr(hr),Pr(mn)),Me||Be(qr),Se.filters&&(Gt(Xr(ke==null?void 0:ke.filters,F)),Zt(Kr(ke==null?void 0:ke.conditionFilters,F))),Se.sort){const _e=Yr(ke==null?void 0:ke.sort)?ke.sort:null;dr(_e&&F.has(_e.key)?_e:null)}if(Se.bql){if(Hr.current!==re){Hr.current=re;const _e=typeof(ke==null?void 0:ke.bql)=="string"?ke.bql:O;fe?(Ee=Bt.current)==null||Ee.call(Bt,_e):xe(_e)}Or(Array.isArray(ke==null?void 0:ke.bqlHistory)?ke.bqlHistory.filter(_e=>typeof _e=="string"):[])}Se.pagination&&ir.current!==re&&(ir.current=re,da(Da(ke==null?void 0:ke.pageSize,we,pr))),pe.current=re,bt(!0),ne()}const vt=`${La()??"/api/user/preferences/datatables"}?key=${encodeURIComponent(re)}`,Je=new AbortController,ve=window.setTimeout(()=>Je.abort(),2500);return fetch(vt,{cache:"no-store",signal:Je.signal}).then(ke=>ke.ok?ke.json():null).then(ke=>{var Si;if(be)return;const we=kn(re),Ne=es(Jo(ke==null?void 0:ke.settings)?ke==null?void 0:ke.settings:null,we),pr=Zr(aa.current??Vr()),er=na.current,tr=er===!1?0:er,rr=Se.layout?Ne==null?void 0:Ne.columnOrder:void 0,hr=Array.isArray(rr)?rr.filter(Ge=>ee.includes(Ge)):[],Wr=ee.filter(Ge=>!hr.includes(Ge)),jr=qt(hr.length>0?[...hr,...Wr]:ee,p),mn=Object.fromEntries(p.map(Ge=>[Ge.key,yt(Ge,Pt(Ge.width))])),qr=Se.layout?(Ne==null?void 0:Ne.columnWidths)??{}:{},_e=Object.fromEntries(p.map(Ge=>[Ge.key,yt(Ge,qr[Ge.key]??mn[Ge.key])])),Ur=Ut(Se.layout?(Ne==null?void 0:Ne.hiddenColumnKeys)??E:E,p);if(Se.layout&&(Fr(jr),Pr(_e)),Me||Be(Ur),Se.filters&&(Gt(Xr(Ne==null?void 0:Ne.filters,F)),Zt(Kr(Ne==null?void 0:Ne.conditionFilters,F))),Se.sort){const Ge=Yr(Ne==null?void 0:Ne.sort)?Ne.sort:null;dr(Ge&&F.has(Ge.key)?Ge:null)}if(Se.bql){if(Hr.current!==re){Hr.current=re;const Ge=typeof(Ne==null?void 0:Ne.bql)=="string"?Ne.bql:O;fe?(Si=Bt.current)==null||Si.call(Bt,Ge):xe(Ge)}Or(Array.isArray(Ne==null?void 0:Ne.bqlHistory)?Ne.bqlHistory.filter(Ge=>typeof Ge=="string"):[])}let je;Se.pagination&&(je=Da(Ne==null?void 0:Ne.pageSize,pr,tr),ir.current!==re&&(ir.current=re,da(je))),mt.current=JSON.stringify({columnOrder:jr,columnWidths:_e,hiddenColumnKeys:Ur,filters:Xr(Ne==null?void 0:Ne.filters,F),conditionFilters:Kr(Ne==null?void 0:Ne.conditionFilters,F),sort:Yr(Ne==null?void 0:Ne.sort)?Ne.sort:null,bql:typeof(Ne==null?void 0:Ne.bql)=="string"?Ne.bql:"",bqlHistory:Array.isArray(Ne==null?void 0:Ne.bqlHistory)?Ne.bqlHistory:[],pageSize:Se.pagination&&er!==!1?je:void 0}),et.current=!0}).catch(()=>{var ke;if(!be){const we=kn(re),Ne=Zr(aa.current??Vr()),pr=na.current,er=pr===!1?0:pr,tr=Se.layout?we==null?void 0:we.columnOrder:void 0,rr=Array.isArray(tr)?tr.filter(je=>ee.includes(je)):[],hr=ee.filter(je=>!rr.includes(je)),Wr=qt(rr.length>0?[...rr,...hr]:ee,p),jr=Object.fromEntries(p.map(je=>[je.key,yt(je,Pt(je.width))])),mn=Se.layout?(we==null?void 0:we.columnWidths)??{}:{},qr=Object.fromEntries(p.map(je=>[je.key,yt(je,mn[je.key]??jr[je.key])]));Se.layout&&(Fr(Wr),Pr(qr));const _e=Ut(Se.layout?(we==null?void 0:we.hiddenColumnKeys)??E:E,p);if(Me||Be(_e),Se.filters&&(Gt(Xr(we==null?void 0:we.filters,F)),Zt(Kr(we==null?void 0:we.conditionFilters,F))),Se.sort){const je=Yr(we==null?void 0:we.sort)?we.sort:null;dr(je&&F.has(je.key)?je:null)}if(Se.bql){if(Hr.current!==re){Hr.current=re;const je=typeof(we==null?void 0:we.bql)=="string"?we.bql:O;fe?(ke=Bt.current)==null||ke.call(Bt,je):xe(je)}Or(Array.isArray(we==null?void 0:we.bqlHistory)?we.bqlHistory.filter(je=>typeof je=="string"):[])}let Ur;Se.pagination&&(Ur=Da(we==null?void 0:we.pageSize,Ne,er),ir.current!==re&&(ir.current=re,da(Ur))),mt.current=JSON.stringify({columnOrder:Wr,columnWidths:qr,hiddenColumnKeys:_e,filters:Xr(we==null?void 0:we.filters,F),conditionFilters:Kr(we==null?void 0:we.conditionFilters,F),sort:Yr(we==null?void 0:we.sort)?we.sort:null,bql:typeof(we==null?void 0:we.bql)=="string"?we.bql:"",bqlHistory:Array.isArray(we==null?void 0:we.bqlHistory)?we.bqlHistory:[],pageSize:Se.pagination&&pr!==!1?Ur:void 0}),et.current=!0}}).finally(()=>{window.clearTimeout(ve),be||(pe.current=re,bt(!0),ne())}),()=>{be=!0,Je.abort(),window.clearTimeout(ve)}},[re,lt,me,Ye,Me,Se.layout,Se.filters,Se.sort,Se.bql,Se.pagination,fe,O,gb]),o.useEffect(()=>{if(!re||!ze||!lt||!et.current)return;const p={};Se.layout&&(p.columnOrder=Br,p.columnWidths=cr,p.hiddenColumnKeys=Fe),Se.filters&&(p.filters=at,p.conditionFilters=pt),Se.sort&&(p.sort=Ve),Se.bql&&(p.bql=De,p.bqlHistory=Qt),Se.pagination&&A!==!1&&(p.pageSize=ca);const E=kn(re),ee=es(E,p),F=JSON.stringify(ee);if(F===mt.current)return;Ec(re,ee),mt.current=F;const ne=window.setTimeout(()=>{const be=La()??"/api/user/preferences/datatables";fetch(be,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:re,settings:ee})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(ne)},[Br,cr,Fe,at,pt,Ve,De,Qt,ca,A,re,ze,lt,Se.layout,Se.filters,Se.sort,Se.bql,Se.pagination]),o.useEffect(()=>{Fr(p=>{const E=e.map(ne=>ne.key),ee=p.filter(ne=>E.includes(ne)),F=E.filter(ne=>!ee.includes(ne));return qt([...ee,...F],e)})},[me,e]);const ti=qt(Br,e).map(p=>e.find(E=>E.key===p)).filter(p=>!!p),Ct=ti.filter(p=>!Fe.includes(p.key)),ri=e.some(Ia),Ab=Object.keys(at).length,Lb=Object.keys(pt).length,wo=Ab+Lb;function ni(p){const E=new Set;return r.reduce((ee,F)=>{const ne=Sn(p,F);return!ne||E.has(ne)||(E.add(ne),ee.push({value:ne,label:ne})),ee},[])}function Db(){const p=e.find(E=>E.key===Oe);return p?ni(p):[]}function Ib(p){return!!(H&&!or(p)&&(p.filterValue||p.sortKey||ni(p).length>0))}function ai(p,E){Gt(ee=>{const F={...ee};return F[p]=E,F})}function Ob(p,E,ee,F){const ne=at[p]??[],be=F?ne:ee.filter(Ae=>Ae!==E),ye=F?ne.includes(E)?ne.filter(Ae=>Ae!==E):[...ne,E]:be;ye.length===ee.length?No(p):ai(p,ye)}function No(p){Gt(E=>{const ee={...E};return delete ee[p],ee})}function ua(p,E){Zt(ee=>{const F={...ee};return E?F[p]=E:delete F[p],F})}function oi(p){ua(p,null)}function Hb(){Gt({}),Zt({})}function Bb(p){fe||xe(p),I==null||I(p)}function si(p){const E=p.trim();ot(E),(I==null?void 0:I(E))!==!1&&(fe||xe(E),ht(!1),gt(!1),Wt(!1),E&&Or(F=>[E,...F.filter(ne=>ne!==E)].slice(0,xc)))}function li(){ot(""),Bb(""),ht(!1),gt(!1),Wt(!1)}function ko(p,E){ot(p),E&&(E.style.height="auto",E.style.height=`${Math.min(E.scrollHeight,180)}px`)}function fa(p){const E=p.trim();if(!E)return;Gl.current=Date.now()+500;const ee=Ie.replace(/\s+$/u,""),F=ee.length===0?E:ee.split(`
|
|
3
|
+
`).map(ne=>ne.trim()).includes(E)?ee:`${ee}
|
|
4
|
+
${E}`;ko(F,vo.current??void 0),requestAnimationFrame(()=>{const ne=vo.current;if(!ne)return;ne.focus();const be=ne.value.length;ne.setSelectionRange(be,be),ko(ne.value,ne)})}o.useEffect(()=>{ot(De)},[De]);const ba=o.useCallback(()=>{const p=go.current;if(!p)return;const E=p.getBoundingClientRect(),ee=12,F=8,ne=Math.min(780,Math.max(320,window.innerWidth-32)),be=Math.max(ee,window.innerWidth-ne-ee),ye=Math.min(Math.max(ee,E.left),be),Ae=E.bottom+F,Re=window.innerHeight-E.top+F,Xe=window.innerHeight-Ae-ee,vt=E.top-ee-F,Je=Xe<280&&vt>Xe,ve=Math.max(240,Je?vt:Xe);yb({position:"fixed",zIndex:1e4,left:ye,top:Je?void 0:Ae,bottom:Je?Re:void 0,width:ne,maxWidth:"calc(100vw - 24px)",maxHeight:ve,overflowY:"auto"})},[]);o.useEffect(()=>{if(!We)return;function p(F){var be,ye;if(Date.now()<Gl.current)return;const ne=F.target;(be=go.current)!=null&&be.contains(ne)||(ye=Kl.current)!=null&&ye.contains(ne)||(ht(!1),gt(!1),Wt(!1))}function E(F){F.key==="Escape"&&(ht(!1),gt(!1),Wt(!1))}function ee(){ba()}return ba(),document.addEventListener("mousedown",p),window.addEventListener("keydown",E),window.addEventListener("resize",ee),window.addEventListener("scroll",ee,!0),()=>{document.removeEventListener("mousedown",p),window.removeEventListener("keydown",E),window.removeEventListener("resize",ee),window.removeEventListener("scroll",ee,!0)}},[We,ba]);function ii(p){const E=Ut(p,e);Me||Be(E),oe==null||oe(E)}function Fb(p){ii(Fe.includes(p)?Fe.filter(E=>E!==p):[...Fe,p])}function Pb(){ii([])}const So=o.useCallback((p=la.current)=>{if(!p)return;const E=p.getBoundingClientRect(),ee=Math.min(292,Math.max(240,window.innerWidth-16)),F=Math.max(8,window.innerWidth-ee-8),ne=Math.min(Math.max(8,E.right-ee),F),be=window.innerHeight-E.bottom,ye=E.bottom+6,Ae=window.innerHeight-E.top+6,Xe=be<360&&E.top>be?void 0:ye,vt=Xe===void 0?Ae:void 0,Je=Math.max(220,Xe===void 0?E.top-16:window.innerHeight-ye-8),ve={position:"fixed",zIndex:9999,left:ne,top:Xe,bottom:vt,width:ee,maxWidth:"calc(100vw - 16px)",maxHeight:Je,"--dt-column-menu-max-height":`${Je}px`};wb(ve)},[]);function ci(p,E,ee=null){p.preventDefault(),p.stopPropagation();const F=la.current===p.currentTarget&&Ke===E&&Oe===ee;if(tt&&F){rt(!1),Ht(null);return}la.current=p.currentTarget,nt(E),Ht(ee),ra(""),So(p.currentTarget),rt(!0)}function _b(p){if(or(p))return;const E=Jt.current;if(!E)return;const F=Array.from(E.querySelectorAll("[data-dt-column-key]")).filter(ne=>ne.dataset.dtColumnKey===p.key).reduce((ne,be)=>{const ye=be.querySelector("[data-dt-autofit-content]"),Ae=ye?ye.scrollWidth:Math.max(be.scrollWidth,be.offsetWidth);return Math.max(ne,Math.ceil(Ae+Tc(be)))},0);F<=0||Pr(ne=>({...ne,[p.key]:yt(p,F+12)}))}o.useEffect(()=>{Pr(p=>{const E=Object.fromEntries(e.map(ee=>[ee.key,yt(ee,Pt(ee.width))]));return Object.fromEntries(e.map(ee=>[ee.key,yt(ee,p[ee.key]??E[ee.key])]))})},[me,e]),o.useEffect(()=>{Me||Be(p=>Ut(p,e))},[me,e,Me]),o.useEffect(()=>{function p(F){var ye,Ae;const ne=F.target,be=F.target;be!=null&&be.closest("[data-bonsaif-select-dropdown='true']")||!((ye=Zl.current)!=null&&ye.contains(ne))&&!((Ae=la.current)!=null&&Ae.contains(ne))&&(rt(!1),Ht(null))}function E(F){F.key==="Escape"&&(rt(!1),Ht(null))}function ee(){So()}return tt&&(document.addEventListener("mousedown",p),window.addEventListener("keydown",E),window.addEventListener("resize",ee),window.addEventListener("scroll",ee,!0)),()=>{document.removeEventListener("mousedown",p),window.removeEventListener("keydown",E),window.removeEventListener("resize",ee),window.removeEventListener("scroll",ee,!0)}},[tt,So]);const un=o.useRef(null);o.useEffect(()=>{function p(ee){const F=un.current;if(!F)return;const ne=ee.clientX-F.startX,be=e.find(ye=>ye.key===F.colKey);be&&Pr(ye=>({...ye,[F.colKey]:yt(be,F.startWidth+ne)}))}function E(){un.current&&(un.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",p),document.addEventListener("pointerup",E),()=>{document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",E)}},[e]);const fn=o.useRef(null),[di,Co]=o.useState(null);function zb(p,E){const ee=e.find(F=>F.key===p);if(!ee||!ts(ee)){E.preventDefault();return}fn.current=Br.indexOf(p),E.dataTransfer.effectAllowed="move"}function Wb(p,E){E.preventDefault(),E.dataTransfer.dropEffect="move";const ee=Br.indexOf(p);di!==ee&&Co(ee)}function jb(p,E){E.preventDefault();const ee=fn.current,F=Br.indexOf(p);ee!==null&&ee!==F&&Fr(ne=>{const be=[...ne],[ye]=be.splice(ee,1);return be.splice(F,0,ye),qt(be,e)}),fn.current=null,Co(null)}function qb(){fn.current=null,Co(null)}function Ub(p){p.sortKey&&dr(E=>(E==null?void 0:E.key)===p.key?{key:p.key,dir:E.dir==="asc"?"desc":"asc"}:{key:p.key,dir:"asc"})}o.useEffect(()=>{ia(1)},[r]),o.useEffect(()=>{ia(1)},[pt,at]);const ur=!!(z&&se),Rt=A!==!1,Eo=o.useMemo(()=>Zr(T??Vr()),[T]),it=ur?Q??1:$b,ui=Rt&&ca<1?typeof A=="number"&&A>0?A:Eo[0]??25:ca,Ft=ur||Rt?ui:r.length,Tt=!!k&&!!h&&!!C,Mo=o.useMemo(()=>M?r.filter(p=>M(p)):r,[r,M]),_r=!!u,fi=o.useMemo(()=>new Set(_?Array.from(b??[]):J),[_,b,J]),Vb=(_r?40:0)+(Tt?40:0),To=!Mb&&(ri||R),ma=(()=>{if(!To)return{};let p=Vb;const E={};return Ct.forEach((ee,F)=>{(Ia(ee)||!ri&&R&&F===0)&&(E[ee.key]=p,p+=cr[ee.key]??yt(ee,Pt(ee.width)))}),E})(),$o=Object.keys(ma),Ao=$o.length>0?$o[$o.length-1]:null,bi=Tt&&Mo.length>0&&Mo.every(p=>k.has(n(p))),Yb=Tt&&k.size>0&&Mo.some(p=>k.has(n(p)))&&!bi,pa=o.useMemo(()=>{const p=Object.entries(at),E=Object.entries(pt);return p.length===0&&E.length===0?r:r.filter(ee=>p.every(([F,ne])=>{const be=e.find(ye=>ye.key===F);return be?ne.includes(Sn(be,ee)):!0})&&E.every(([F,ne])=>{const be=e.find(Ae=>Ae.key===F);if(!be)return!0;const ye=r.map(Ae=>Sn(be,Ae));return Lc(Sn(be,ee),ne,ye)}))},[pt,at,e,r]),fr=o.useMemo(()=>{if(!Ve)return pa;const p=e.find(E=>E.key===Ve.key&&E.sortKey);return p!=null&&p.sortKey?[...pa].sort((E,ee)=>{const F=E[p.sortKey],ne=ee[p.sortKey],be=F===ne?0:F==null?1:ne==null||F<ne?-1:1;return Ve.dir==="asc"?be:-be}):pa},[pa,Ve,e]),mi=o.useMemo(()=>{if(ur||!Rt)return fr;const p=(it-1)*Ft;return fr.slice(p,p+Ft)},[fr,ur,Rt,it,Ft]),br=ur?L??r.length:fr.length,Lo=Rt?Math.max(1,Math.ceil(br/Ft)):1,Xb=Math.min(...Eo),Kb=Rt&&(br>Ft||br>Xb),Gb=Rt?(it-1)*Ft+1:1,Zb=Rt?Math.min(it*Ft,br):br;function Do(p){if(a)return;const E=Math.max(1,Math.min(p,Lo));ur?z(E):ia(E)}function Qb(p){a||(re&&(ir.current=re),da(p),ur?(se(p),z(1)):(ia(1),se==null||se(p)))}function pi(p){const E=new Set(fi);E.has(p)?E.delete(p):E.add(p);const ee=Array.from(E);_||ue(ee),g==null||g(ee)}o.useEffect(()=>{Le==null||Le({bql:De,filters:at,conditionFilters:pt,sort:Ve,page:it,pageSize:Ft,hiddenColumnKeys:Fe})},[De,at,pt,Ve,it,Ft,Fe,Le]);const hi=p=>p==="center"?"justify-center text-center":p==="right"?"justify-end text-right":"justify-start text-left",Jb="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",Io="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%)",He="color-mix(in srgb, var(--border) 62%, var(--bg-card))",mr="color-mix(in srgb, var(--primary) 24%, var(--border))",ha=`inset 0 0 0 1px ${He}`,gi=Ct.reduce((p,E)=>p+(cr[E.key]??Pt(E.width)),(_r?40:0)+(Tt?40:0)),vi=typeof W=="number"?W:typeof W=="string"?Number(((ki=W.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:ki[1])??NaN):NaN,bn=Number.isFinite(vi)?Math.max(gi,vi,Rl):Math.max(gi,Rl),ga=W??bn,zr=`${_r?"40px ":""}${Tt?"40px ":""}${Ct.map(p=>`${cr[p.key]??Pt(p.width)}px`).join(" ")}`;o.useEffect(()=>{Ve&&Fe.includes(Ve.key)&&dr(null)},[Fe,Ve]);function yi(p){return p?typeof p=="string"?{key:p,label:p}:p:null}const va=()=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:zr,background:Io,borderBottom:`1px solid ${mr}`},children:[_r&&t.jsx("div",{role:"columnheader",className:`${B?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${mr}`,borderRight:`1px solid ${He}`}}),Tt&&t.jsx("div",{role:"columnheader",className:`${B?"px-2 py-1.5":"px-3 py-2.5"} flex w-10 items-center justify-center`,style:To?{position:"sticky",left:0,zIndex:12,background:Io,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${mr}`,borderRight:`1px solid ${He}`}:{borderBottom:`1px solid ${mr}`,borderRight:`1px solid ${He}`},children:t.jsx(vn,{size:"sm",checked:bi,indeterminate:Yb,onChange:C,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),Ct.map((p,E)=>{const ee=(Ve==null?void 0:Ve.key)===p.key,F=!!p.sortKey,ne=or(p),be=ma[p.key],ye=be!==void 0,Ae=p.key===Ao,Re=ts(p),Xe=di===E,Je=(cr[p.key]??Pt(p.width))<120,ve=Object.prototype.hasOwnProperty.call(at,p.key)||Object.prototype.hasOwnProperty.call(pt,p.key);return t.jsxs("div",{role:"columnheader","data-dt-column-key":p.key,className:`group select-none ${Je?"text-left":hi(p.align)}`,style:{...ye?{position:"sticky",left:be,zIndex:12,background:Io,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:Ae?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${mr}`:`inset 0 -1px 0 ${mr}`,borderRight:`1px solid ${He}`}:{position:"relative",borderBottom:`1px solid ${mr}`,borderRight:`1px solid ${He}`},color:ee?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:Xe?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:ne?B?"7px 6px":"9px 8px":B?"8px 6px 10px":"10px 8px 12px"},onDragOver:Ee=>{(Re||fn.current!==null)&&Wb(p.key,Ee)},onDrop:Ee=>jb(p.key,Ee),children:[t.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${ne?"justify-center":Je?"justify-start":p.align==="center"?"justify-center":p.align==="right"?"justify-end":"justify-start"}`,children:[Re?t.jsx("span",{draggable:!0,onDragStart:Ee=>{Ee.stopPropagation(),zb(p.key,Ee)},onDragEnd:Ee=>{Ee.stopPropagation(),qb()},onClick:Ee=>Ee.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 ${Xe?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}):null,ne?t.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:t.jsx(q.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):t.jsx(rs,{className:"min-w-0 flex-1",children:t.jsx("span",{"data-dt-autofit-content":!0,className:`inline-flex max-w-full items-center font-semibold uppercase tracking-wider ${B?"text-[11px]":"text-xs"}`,children:t.jsx("span",{className:"min-w-0 truncate",children:p.header})})}),F&&t.jsx("button",{type:"button","aria-label":`Ordenar por ${String(p.header)}`,title:"Ordenar",onClick:Ee=>{Ee.stopPropagation(),Ub(p)},"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 ${ee?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:ee?Ve.dir==="asc"?t.jsx(q.HiChevronUp,{className:"h-3 w-3"}):t.jsx(q.HiChevronDown,{className:"h-3 w-3"}):t.jsx(q.HiChevronUpDown,{className:"h-3 w-3"})}),H&&!ne&&Ib(p)&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":tt&&Oe===p.key,"aria-label":`Filtrar ${String(p.header)}`,title:"Filtrar",onClick:Ee=>ci(Ee,"filter",p.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 ${tt&&Ke==="filter"&&Oe===p.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":ve?"text-[var(--primary)] opacity-100":""}`,children:ve?t.jsx(q.HiFunnel,{className:"h-3.5 w-3.5"}):t.jsx(q.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!ne&&t.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:Ee=>{Ee.preventDefault(),Ee.stopPropagation(),un.current={colKey:p.key,startX:Ee.clientX,startWidth:cr[p.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:Ee=>{Ee.preventDefault(),Ee.stopPropagation(),un.current=null,document.body.style.cursor="",document.body.style.userSelect="",_b(p)},onClick:Ee=>Ee.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:t.jsxs("span",{style:{display:"flex",gap:4,alignItems:"center",height:"calc(100% - 8px)"},children:[t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}}),t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}})]})})]},p.key)})]}),ya=()=>{if(!tt||typeof document>"u"||Ke==="visibility"&&!ae||Ke==="filter"&&!H)return null;const p=e.find(ve=>ve.key===Oe),E=Db(),ee=p?Object.prototype.hasOwnProperty.call(at,p.key):!1,F=p?pt[p.key]:void 0,ne=Nn.find(ve=>ve.value===(F==null?void 0:F.operator)),be=p?at[p.key]??[]:[],ye=ta.trim().toLowerCase(),Ae=ye?E.filter(ve=>ve.label.toLowerCase().includes(ye)):E,Re=p&&E.length>0&&(!ee||be.length===E.length),Xe=p&&ee&&be.length>0&&be.length<E.length,vt=Fe.length,Je=()=>{p&&(No(p.key),oi(p.key))};return dt.createPortal(t.jsx("div",{ref:Zl,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...xb,borderColor:"var(--border)",background:"var(--bg-card)"},children:Ke==="visibility"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[t.jsx("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:vt>0?`${Ct.length} de ${e.length} visibles`:`${e.length} visibles`}),t.jsx("button",{type:"button",onClick:Pb,disabled:vt===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"})]}),t.jsx("div",{className:"max-h-72 overflow-auto py-1",children:ti.map(ve=>{const Ee=!Fe.includes(ve.key),we=!(ve.hideable!==!1)||Ee&&Ct.length<=1;return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ee,disabled:we,onClick:()=>Fb(ve.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:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ee?"var(--primary)":"var(--border)",background:Ee?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ee&&t.jsx(q.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ve.header})]},ve.key)})})]}):p?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[t.jsxs("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:["Filtrar ",p.header]}),t.jsx("button",{type:"button",onClick:Je,disabled:!ee&&!F,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"})]}),p.sortKey&&t.jsxs("div",{className:"grid grid-cols-2 gap-1 border-b border-[var(--border)] p-1",children:[t.jsxs("button",{type:"button",onClick:()=>dr({key:p.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:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[t.jsx(q.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Ascendente"})]}),(Ve==null?void 0:Ve.key)===p.key&&Ve.dir==="asc"&&t.jsx(q.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),t.jsxs("button",{type:"button",onClick:()=>dr({key:p.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:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[t.jsx(q.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Descendente"})]}),(Ve==null?void 0:Ve.key)===p.key&&Ve.dir==="desc"&&t.jsx(q.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]})]}),t.jsxs("div",{className:"border-b border-[var(--border)] p-2",children:[t.jsxs("div",{className:"grid grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)] gap-2",children:[t.jsx(ar,{value:(F==null?void 0:F.operator)??"",onChange:ve=>{if(!ve){oi(p.key);return}ua(p.key,{operator:ve,value:(F==null?void 0:F.value)??"",valueTo:(F==null?void 0:F.valueTo)??""})},options:yc,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"}),(ne==null?void 0:ne.valueMode)!=="none"?t.jsx("input",{value:(F==null?void 0:F.value)??"",onChange:ve=>{F&&ua(p.key,{...F,value:ve.target.value})},disabled:!F,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)"}}):t.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"})]}),(ne==null?void 0:ne.valueMode)==="between"&&t.jsx("input",{value:(F==null?void 0:F.valueTo)??"",onChange:ve=>{F&&ua(p.key,{...F,valueTo:ve.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)"}})]}),t.jsx("div",{className:"border-b border-[var(--border)] p-2",children:t.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:[t.jsx(q.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("input",{value:ta,onChange:ve=>ra(ve.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)"}})]})}),t.jsxs("div",{className:"overflow-auto py-1",style:{maxHeight:"max(96px, calc(var(--dt-column-menu-max-height, 520px) - 236px))"},children:[t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Xe?"mixed":!!Re,onClick:()=>{p&&(Re&&!ee?ai(p.key,[]):No(p.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:[t.jsxs("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Re||Xe?"var(--primary)":"var(--border)",background:Re||Xe?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[Xe&&t.jsx(q.HiMinus,{className:"h-3 w-3"}),Re&&!Xe&&t.jsx(q.HiCheck,{className:"h-3 w-3"})]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),Ae.map(ve=>{const Ee=!ee||be.includes(ve.value);return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ee,onClick:()=>Ob(p.key,ve.value,E.map(ke=>ke.value),ee),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:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ee?"var(--primary)":"var(--border)",background:Ee?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ee&&t.jsx(q.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ve.label})]},ve.value)}),Ae.length===0&&t.jsx("div",{className:"px-3 py-3 text-sm text-[var(--text-muted)]",children:"Sin valores"})]})]}):null}),document.body)};o.useEffect(()=>{if(!dn)return;function p(E){yo.current&&!yo.current.contains(E.target)&&sa.current&&!sa.current.contains(E.target)&&oa(!1)}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[dn]);function xi(p,E){if(p.filterValue){const ee=p.filterValue(E);return ee==null||ee===""?"":String(ee)}return gr(p.cell(E))}function wi(p){return`"${p.replace(/"/g,'""')}"`}function xa(p){return p.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Rb(){const p=Ct.filter(Ae=>!or(Ae)),E=p.map(Ae=>wi(gr(Ae.header))).join(","),ee=fr.map(Ae=>p.map(Re=>wi(xi(Re,Ae))).join(",")).join(`
|
|
5
|
+
`),F=`${E}
|
|
6
|
+
${ee}`,ne=new Blob(["\uFEFF"+F],{type:"text/csv;charset=utf-8;"}),be=URL.createObjectURL(ne),ye=document.createElement("a");ye.href=be,ye.download=`${Ot}.csv`,document.body.appendChild(ye),ye.click(),document.body.removeChild(ye),URL.revokeObjectURL(be)}function em(){const p=Ct.filter(ye=>!or(ye)),E=p.map(ye=>xa(gr(ye.header))),F=fr.map(ye=>p.map(Ae=>xa(xi(Ae,ye)))).map(ye=>`<tr>${ye.map(Ae=>`<td>${Ae}</td>`).join("")}</tr>`).join(""),ne=`<!DOCTYPE html>
|
|
7
|
+
<html lang="es"><head><meta charset="utf-8"><title>${xa(Ot)}</title>
|
|
8
8
|
<style>
|
|
9
9
|
body{font-family:system-ui,sans-serif;font-size:11px;margin:20px;color:#111}
|
|
10
10
|
h3{margin:0 0 4px;font-size:14px}
|
|
@@ -15,22 +15,24 @@ ${R}`,ne=new Blob(["\uFEFF"+O],{type:"text/csv;charset=utf-8;"}),fe=URL.createOb
|
|
|
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>${
|
|
19
|
-
<p>${
|
|
20
|
-
<table><thead><tr>${
|
|
21
|
-
<tbody>${
|
|
18
|
+
<h3>${xa(Ot)}</h3>
|
|
19
|
+
<p>${fr.length} registros · ${new Date().toLocaleDateString("es")}</p>
|
|
20
|
+
<table><thead><tr>${E.map(ye=>`<th>${ye}</th>`).join("")}</tr></thead>
|
|
21
|
+
<tbody>${F}</tbody></table>
|
|
22
22
|
<script>window.onload=()=>{window.print()}<\/script>
|
|
23
|
-
</body></html>`,
|
|
24
|
-
`).map(ve=>ve.trim()).filter(Boolean)).has(ne):!1}).slice(0,8);return!le&&es===0&&!K&&!We?null:t.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:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[es>0&&t.jsxs("button",{type:"button",onClick:Yf,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:[t.jsx(z.HiXMark,{className:"h-3.5 w-3.5"}),es," filtros"]}),K&&t.jsxs("div",{ref:Za,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>{if($t){Yt(!1);return}Zn(),Yt(!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:$t?"var(--primary)":p?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:$t||p?"var(--primary)":"var(--border)",color:$t?"var(--primary-fg)":"var(--primary)"},"aria-expanded":$t,title:"Abrir filtros BQL",children:[t.jsx(z.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",p&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),$t?t.jsx(z.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(z.HiChevronDown,{className:"h-3.5 w-3.5"})]}),t.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:se}),S.length>0&&t.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[S.slice(0,3).map(O=>t.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:[t.jsxs("span",{className:"text-[var(--text-muted)]",children:[O.label,":"]}),t.jsx("span",{className:"truncate",children:O.value})]},O.key)),S.length>3&&t.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",S.length-3]})]}),p&&t.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:Al,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:t.jsx(z.HiXMark,{className:"h-4 w-4"})}),$t&&nt.createPortal(t.jsxs("div",{ref:vl,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...Tf,background:"var(--bg-card)",border:"1px solid color-mix(in srgb, var(--primary) 35%, var(--border))"},children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[de.map(O=>t.jsxs("button",{type:"button",onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),Gn(O.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:[O.icon,O.label]},O.label)),Se.length>0&&t.jsxs("button",{type:"button",onClick:()=>xr(O=>!O),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":hl,children:[t.jsx(z.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),en.length>0&&t.jsxs("button",{type:"button",onClick:()=>wr(O=>!O),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":gl,children:[t.jsx(z.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]})]}),t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-input)",border:`1.5px solid ${Ce?"var(--danger)":p?"var(--primary)":"var(--border)"}`},children:[t.jsx("textarea",{ref:Qa,value:Rr,rows:3,onChange:O=>rs(O.target.value,O.target),onKeyDown:O=>{O.key==="Enter"&&!O.shiftKey&&(O.preventDefault(),Ll(Rr)),O.key==="Escape"&&Yt(!1)},placeholder:Q,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"}}),R.length>0&&t.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:R.map(O=>t.jsx("button",{type:"button",onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),Gn(O)},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:O},O))})]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"min-w-0 text-xs",style:{color:Ce?"var(--danger)":"var(--text-muted)"},children:Ce??(p?`${S.length||1} filtro${(S.length||1)===1?"":"s"} activo${(S.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),S.map(O=>t.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:[t.jsxs("span",{className:"text-[var(--text-muted)]",children:[O.label,":"]}),t.jsx("span",{className:"truncate",children:O.value})]},O.key))]}),gl&&en.length>0&&t.jsxs("div",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-input)]",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-3 py-2",children:[t.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-semibold text-[var(--text-secondary)]",children:[t.jsx(z.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),t.jsxs("button",{type:"button",onClick:()=>{kr([]),wr(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[t.jsx(z.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),en.map(O=>t.jsxs("div",{className:"group flex items-center gap-2 border-b border-[var(--border)] px-3 py-2 last:border-b-0",children:[t.jsx("button",{type:"button",onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),Gn(O)},className:"min-w-0 flex-1 text-left",children:t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:O})}),t.jsx("button",{type:"button",onClick:()=>kr(ne=>ne.filter(fe=>fe!==O)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:t.jsx(z.HiXMark,{className:"h-3.5 w-3.5"})})]},O))]}),hl&&Se.length>0&&t.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:Se.map(O=>t.jsxs("button",{type:"button",onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),Gn(O.bql),xr(!1)},className:"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-2 text-left transition-colors hover:border-[var(--primary)]",children:[t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:O.bql}),O.description&&t.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:O.description})]},O.bql))}),t.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] pt-3",children:[p&&t.jsxs("button",{type:"button",onClick:Al,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:[t.jsx(z.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),t.jsxs("button",{type:"button",onClick:()=>Ll(Rr),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:[t.jsx(z.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),We&&t.jsx("button",{ref:qn,type:"button","aria-haspopup":"menu","aria-expanded":tn,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var ne;const O=(ne=qn.current)==null?void 0:ne.getBoundingClientRect();O&&Of({top:O.bottom+4,right:window.innerWidth-O.right}),Wn(fe=>!fe)},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)] ${tn?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(z.HiArrowDownTray,{className:"h-4 w-4"})}),le&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ge&&Qe==="visibility","aria-label":U,title:U,onClick:O=>Il(O,"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)] ${Ge&&Qe==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(z.HiCog6Tooth,{className:"h-4 w-4"})})]})},Yl=()=>{if(!sb)return null;const p=Ri(Re,cs);return t.jsxs("div",{"aria-busy":a,className:`grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 rounded-b-xl border-t text-xs select-none ${L?"px-2 py-0.5":"px-3 py-1"}`,style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:Rt===0?"0 filas":`${ob}–${lb} de ${Rt}`}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),t.jsx(jt,{value:String(Nt),onChange:S=>ib(Number(S)),options:Hl.map(S=>({value:String(S),label:String(S)})),placeholder:"Filas",searchable:!1,disabled:a,height:W,padding:G,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:j}})]})]}),t.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[t.jsx("button",{disabled:a||Re<=1,onClick:()=>ds(Re-1),onMouseEnter:S=>{S.currentTarget.disabled||(S.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",S.currentTarget.style.color="var(--primary)")},onMouseLeave:S=>{S.currentTarget.style.background="transparent",S.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:t.jsx(z.HiChevronLeft,{className:"h-3.5 w-3.5"})}),p.map((S,R)=>S==="..."?t.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${R}`):t.jsx("button",{disabled:a,onClick:()=>ds(S),onMouseEnter:O=>{O.currentTarget.disabled||S===Re||(O.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",O.currentTarget.style.color="var(--primary)")},onMouseLeave:O=>{O.currentTarget.style.background=S===Re?"var(--primary)":"transparent",O.currentTarget.style.color=S===Re?"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:S===Re?"var(--primary)":"transparent",color:S===Re?"var(--primary-fg)":"var(--text-muted)"},children:S},S)),t.jsx("button",{disabled:a||Re>=cs,onClick:()=>ds(Re+1),onMouseEnter:S=>{S.currentTarget.disabled||(S.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",S.currentTarget.style.color="var(--primary)")},onMouseLeave:S=>{S.currentTarget.style.background="transparent",S.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:t.jsx(z.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),t.jsx("div",{"aria-hidden":"true"})]})},fb=()=>t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Rn},children:[ra(),aa(),sa(),t.jsx("div",{ref:Bt,className:"min-w-0 max-w-full overflow-hidden",children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:an,minWidth:ea},children:[t.jsx("div",{role:"rowgroup",style:N?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ta()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,o)}).map((p,S)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:$r,borderBottom:`1px solid ${Oe}`},children:[pt&&t.jsx("div",{role:"cell",className:`${L?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`}},"select-cell"),ut.map((R,O)=>t.jsx("div",{role:"cell",className:L?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${kl(S,O)}%`,minWidth:32}})},R.key))]},S))})]})})]}),fs="min-w-0 max-w-full overflow-hidden";return X&&et&&!he?t.jsx(cn,{rows:o,columns:Math.max(4,ut.length||7)}):!a&&r.length===0&&!Ra?fb():a&&r.length===0?t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Rn},children:[ra(),aa(),sa(),t.jsx("div",{ref:Bt,className:fs,children:t.jsx(ms.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:Sl,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:an,minWidth:ea},children:[t.jsx("div",{role:"rowgroup",style:N?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ta()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:o}).map((p,S)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:$r,borderBottom:`1px solid ${Oe}`},children:[pt&&t.jsx("div",{role:"cell",className:`${L?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`}},"select-cell"),ut.map((R,O)=>{const ne=Qn[R.key],fe=ne!==void 0,ve=R.key===is;return t.jsx("div",{role:"cell","data-dt-column-key":R.key,className:L?"px-2 py-1.5":"px-3 py-2",style:fe?{position:"sticky",left:ne,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:ve?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Oe}`:`inset 0 -1px 0 ${Oe}`,borderRight:`1px solid ${Oe}`}:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${kl(S,O)}%`,minWidth:32}})},R.key)})]},S))})]})})}),Yl()]}):!a&&r.length===0?t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Rn},children:[ra(),aa(),sa(),t.jsx("div",{ref:Bt,className:fs,children:t.jsx("div",{role:"table",className:"text-sm",style:{width:an,minWidth:ea},children:t.jsx("div",{role:"rowgroup",style:N?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ta()})})}),t.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:Oe,background:"linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 58%, transparent), var(--bg-card))"},children:[t.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??t.jsx(z.HiMagnifyingGlass,{className:"h-5 w-5"})}),t.jsx("p",{className:"max-w-sm text-sm font-medium",style:{color:"var(--text-main)"},children:i}),t.jsx("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Ajusta la busqueda o cambia los filtros para ver mas informacion."})]})]}):t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Rn},children:[ra(),aa(),sa(),t.jsx("div",{ref:Bt,className:fs,children:t.jsx(ms.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:Sl,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:an,minWidth:ea},children:[t.jsx("div",{role:"rowgroup",style:N?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ta()}),t.jsx("div",{role:"rowgroup",children:Pl.map((p,S)=>{const R=n(p),O=ql(k==null?void 0:k(p)),ne=S>0?ql(k==null?void 0:k(Pl[S-1])):null,fe=O&&O.key!==(ne==null?void 0:ne.key),ve=pt&&E.has(R),$e=pt&&(!M||M(p)),Ke=Mr?(m==null?void 0:m(p))??!0:!1,Ue=Ke&&Bl.has(R),rt=!!d||x&&Ke,Xe=ve&&y?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":S%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return t.jsxs(s.Fragment,{children:[fe&&t.jsx("div",{role:"row",className:`grid ${O.className??""}`,style:{gridTemplateColumns:$r},children:t.jsx("div",{role:"cell",className:L?"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 ${Oe}`,borderRight:`1px solid ${Oe}`},children:t.jsx("div",{className:"flex min-w-0 items-center justify-between gap-3",children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"truncate text-xs font-semibold uppercase tracking-wider text-[var(--text-main)]",children:O.label}),O.description&&t.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:O.description})]})})})}),t.jsxs("div",{role:"row",onClick:rt?ge=>{const Me=ge.target;if(!(Me!=null&&Me.closest('[data-dt-disable-row-click="true"]'))){if(x&&Ke){_l(R);return}d==null||d(p)}}:void 0,className:`grid transition-colors ${rt?"cursor-pointer":""} ${w?w(p):""}`,style:{gridTemplateColumns:$r,"--dt-row-bg":Xe,"--dt-sticky-bg":Xe,background:"var(--dt-row-bg)",borderBottom:`1px solid ${Oe}`},onMouseEnter:ge=>{ve||(ge.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),ge.currentTarget.style.setProperty("--dt-sticky-bg",cb))},onMouseLeave:ge=>{ge.currentTarget.style.setProperty("--dt-row-bg",Xe),ge.currentTarget.style.setProperty("--dt-sticky-bg",Xe)},children:[Mr&&t.jsx("div",{role:"cell",className:`${L?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},"data-dt-disable-row-click":"true",children:Ke&&t.jsx("button",{type:"button","aria-label":Ue?"Contraer fila":"Desplegar fila","aria-expanded":Ue,onClick:ge=>{ge.stopPropagation(),_l(R)},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:Ue?t.jsx(z.HiChevronDown,{className:"h-4 w-4"}):t.jsx(z.HiChevronRight,{className:"h-4 w-4"})})}),pt&&t.jsx("div",{role:"cell",className:`${L?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:os?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${Oe}`}:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},onClick:ge=>{ge.stopPropagation(),$e&&h(R)},children:t.jsx(dn,{size:"sm",checked:ve,disabled:!$e,"aria-label":$e?"Seleccionar fila":"Fila no seleccionable",containerClassName:"items-center",className:$e?"cursor-pointer":"cursor-not-allowed opacity-50",onClick:ge=>ge.stopPropagation(),onChange:()=>{$e&&h(R)}})}),ut.map(ge=>{const Me=Qn[ge.key],we=Me!==void 0,ye=ge.key===is,xe=Wt(ge);return t.jsx("div",{role:"cell","data-dt-column-key":ge.key,"data-dt-disable-row-click":ge.disableRowClick||xe?"true":void 0,className:`${xe?"px-2 py-1.5 justify-center text-center":`${L?"px-2 py-1.5":"px-3 py-2"} ${zl(ge.align)}`} flex min-w-0 items-center ${Xi} ${ge.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...we?{position:"sticky",left:Me,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:ye?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Oe}`:`inset 0 -1px 0 ${Oe}`,borderRight:`1px solid ${Oe}`}:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`}},children:t.jsx(Os,{children:t.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:ge.cell(p)})})},ge.key)})]}),Ue&&u&&t.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:$r},children:t.jsx("div",{role:"cell",className:L?"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 ${Oe}`},children:u(p)})})]},R)})})]})})}),Yl()]})}const rc={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 nc(e,r){if(r.minLength!==void 0&&e.length<r.minLength)return r.message??`Mínimo ${r.minLength} caracteres`;if(r.maxLength!==void 0&&e.length>r.maxLength)return r.message??`Máximo ${r.maxLength} caracteres`;if(!e)return null;if(r.preset){const n=rc[r.preset];if(!n.pattern.test(e))return r.message??n.message}return r.pattern&&!r.pattern.test(e)?r.message??"Formato inválido":null}const ac=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function sc({initialValue:e,type:r,mask:n,onCommit:a,onCancel:o}){const[l,i]=s.useState(e),c=s.useRef(null),d=(n==null?void 0:n.preset)==="date",u=d?"date":r==="number"?"number":"text";return s.useEffect(()=>{var m,f;(m=c.current)==null||m.focus(),d||(f=c.current)==null||f.select()},[d]),t.jsx("input",{ref:c,type:u,value:l,maxLength:n==null?void 0:n.maxLength,onChange:m=>i(m.target.value),onBlur:()=>o(),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),a(l)),m.key==="Escape"&&(m.preventDefault(),o()),(n==null?void 0:n.preset)==="integer"&&!m.ctrlKey&&!m.metaKey&&!ac.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 oc({initialValue:e,options:r,loading:n,onCommit:a,onCancel:o}){const l=s.useRef(null);return s.useEffect(()=>{if(n)return;const i=setTimeout(()=>{var c,d;(d=(c=l.current)==null?void 0:c.querySelector("button"))==null||d.click()},0);return()=>clearTimeout(i)},[n]),t.jsx("div",{ref:l,className:"w-full",tabIndex:-1,onKeyDown:i=>{i.key==="Escape"&&(i.stopPropagation(),o())},children:t.jsx(jt,{value:e,onChange:i=>{a(i)},options:r,disabled:n,placeholder:n?"Cargando…":"Seleccionar…",triggerVariant:"ghost",height:30,padding:"0 6px",minOptionsForSearch:1,className:"w-full"})})}const lc={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},ga={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function ic({columns:e,data:r,getRowId:n,onCellUpdate:a,readOnly:o=!1,...l}){const[i,c]=s.useState(r),d=s.useRef(null);s.useEffect(()=>{d.current||c(r)},[r]);const[u,m]=s.useState(null);d.current=u;const[f,b]=s.useState(null),v=s.useRef(null);v.current=f;const[x,E]=s.useState({}),[h,$]=s.useState(null),M=s.useRef(null);M.current=h;const[y,w]=s.useState({}),[k,N]=s.useState({}),A=s.useRef(new Set),C=s.useRef(null);s.useEffect(()=>{var F;const B=document.activeElement;(!B||B===document.body)&&((F=C.current)==null||F.focus({preventScroll:!0}))},[]);const j=e.map(B=>{var F,le,g;return`${B.key}:${((g=(le=(F=B.editable)==null?void 0:F.select)==null?void 0:le.options)==null?void 0:g.length)??-1}`}).join("|");s.useEffect(()=>{e.forEach(B=>{var g,P;const F=(P=(g=B.editable)==null?void 0:g.select)==null?void 0:P.options;if(!F)return;const le=y[B.key];(!A.current.has(B.key)||(le==null?void 0:le.length)===0&&F.length>0)&&(A.current.add(B.key),w(I=>({...I,[B.key]:F})))})},[j]);const W=s.useCallback(async(B,F)=>{if(A.current.has(B))return;A.current.add(B);const{url:le,fetchOptions:g}=F.select??{};if(!(!le&&!g)){N(P=>({...P,[B]:!0}));try{let P=[];if(g)P=await g();else if(le){const I=await fetch(le);if(!I.ok)throw new Error("fetch failed");P=await I.json()}w(I=>({...I,[B]:P}))}catch{w(P=>({...P,[B]:[]}))}finally{N(P=>({...P,[B]:!1}))}}},[]),G=s.useRef(i);G.current=i;const T=s.useRef(a);T.current=a;const Z=s.useRef(n);Z.current=n;const H=s.useRef(e);H.current=e;const ae=s.useRef(o);ae.current=o,s.useEffect(()=>{if(e.length>0&&r.length>0){const B=e.find(F=>F.selectable!==!1);B&&b({rowId:n(r[0]),colKey:B.key})}},[]),s.useEffect(()=>{if(!f)return;const B=C.current;if(!B)return;const F=B.querySelector(`[data-cell-id="${f.rowId}:${f.colKey}"]`);if(!F)return;const le=B.querySelector('[role="rowgroup"]');F.style.scrollMarginTop=`${(le==null?void 0:le.offsetHeight)??0}px`;const g=B.querySelector('[role="row"]');let P=0;g&&g.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(I=>{I.style.position==="sticky"&&I.style.left!==""&&(P=Math.max(P,parseFloat(I.style.left)+I.offsetWidth))}),F.style.scrollMarginLeft=`${P}px`,F.scrollIntoView({block:"nearest",inline:"nearest"})},[f]);const X=s.useCallback(B=>{var P;const F=H.current,le=new Set,g=[];(P=C.current)==null||P.querySelectorAll("[data-cell-id]").forEach(I=>{const te=I.dataset.cellId.split(":")[0];le.has(te)||(le.add(te),g.push(te))}),b(I=>{if(!I)return I;const te=F.findIndex(ee=>ee.key===I.colKey),U=g.indexOf(I.rowId);let K=te,D=U;if(B==="up")D=Math.max(0,U-1);else if(B==="down")D=Math.min(g.length-1,U+1);else if(B==="left"){let ee=te-1;for(;ee>=0&&F[ee].selectable===!1;)ee--;ee>=0&&(K=ee)}else if(B==="right"){let ee=te+1;for(;ee<F.length&&F[ee].selectable===!1;)ee++;ee<F.length&&(K=ee)}return K===te&&D===U?I:{rowId:g[D],colKey:F[K].key}})},[]),V=s.useCallback((B=!0)=>{const F=d.current;m(null),F&&b(F),B&&setTimeout(()=>{var le;return(le=C.current)==null?void 0:le.focus({preventScroll:!0})},0)},[]),q=s.useCallback(async(B,F,le)=>{var ie;const g=H.current.find(pe=>pe.key===F);if(!(g!=null&&g.editable))return;const{field:P,type:I,mask:te,validate:U}=g.editable,K=I==="number"?le===""?null:Number(le):le;if(te){const pe=nc(le,te);if(pe){E(Ce=>({...Ce,[`${B}:${F}`]:pe}));return}}if(U){const pe=U(K);if(pe){E(Ce=>({...Ce,[`${B}:${F}`]:pe}));return}}const D=Z.current,ee=G.current.find(pe=>D(pe)===B);if(!ee)return;const _=ee[P];m(null),E(pe=>{const Ce={...pe};return delete Ce[`${B}:${F}`],Ce});const se=G.current,Q=se.findIndex(pe=>D(pe)===B),de=se[Math.min(se.length-1,Q+1)];if(b({rowId:D(de),colKey:F}),setTimeout(()=>{var Ce,De;const pe=document.activeElement;(!pe||pe===document.body||(Ce=C.current)!=null&&Ce.contains(pe))&&((De=C.current)==null||De.focus({preventScroll:!0}))},0),String(_??"")===String(K??""))return;const Se={...ee,[P]:K};c(pe=>pe.map(Ce=>D(Ce)===B?Se:Ce)),$({rowId:B,colKey:F});try{await((ie=T.current)==null?void 0:ie.call(T,{row:ee,rowId:B,field:P,oldValue:_,newValue:K}))}catch{c(pe=>pe.map(Ce=>D(Ce)===B?ee:Ce)),E(pe=>({...pe,[`${B}:${F}`]:"Error al guardar. Intenta de nuevo."}))}finally{$(null)}},[]),L=s.useCallback(B=>{if(M.current){B.preventDefault();return}if(d.current)return;const F=v.current;if(!(!F||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(B.key)))switch(B.preventDefault(),B.key){case"ArrowUp":X("up");break;case"ArrowDown":X("down");break;case"ArrowLeft":X("left");break;case"ArrowRight":X("right");break;case"Tab":X(B.shiftKey?"left":"right");break;case"Enter":{const g=H.current.find(P=>P.key===F.colKey);g!=null&&g.editable&&!ae.current?(m(F),g.editable.type==="select"&&!A.current.has(F.colKey)&&W(F.colKey,g.editable)):X("down");break}}},[X,W]),oe=s.useMemo(()=>e.map(B=>{if(!B.editable||o){const le={...B};if(delete le.editable,delete le.selectable,B.selectable===!1)return{...le,disableRowClick:!0};const g=le.cell;return{...le,className:`relative ${le.className??""}`.trim(),disableRowClick:!0,cell:P=>{const I=n(P),te=(f==null?void 0:f.rowId)===I&&(f==null?void 0:f.colKey)===B.key;return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${I}:${B.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var U;M.current||(b({rowId:I,colKey:B.key}),(U=C.current)==null||U.focus({preventScroll:!0}))}}),te&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:ga}),t.jsx("span",{className:"relative z-0 pointer-events-none",children:g(P)})]})}}}const F=B.editable;return{...B,className:`relative ${B.className??""}`.trim(),disableRowClick:!0,cell:le=>{const g=n(le),P=B.key,I=(u==null?void 0:u.rowId)===g&&(u==null?void 0:u.colKey)===P,te=(f==null?void 0:f.rowId)===g&&(f==null?void 0:f.colKey)===P,U=x[`${g}:${P}`],K=(h==null?void 0:h.rowId)===g&&(h==null?void 0:h.colKey)===P,D=le[F.field],ee=String(D??""),_=()=>{var Q;M.current||(b({rowId:g,colKey:P}),m({rowId:g,colKey:P}),(Q=C.current)==null||Q.focus({preventScroll:!0}),F.type==="select"&&!A.current.has(P)&&W(P,F))};if(I){const Q=F.type==="select"?t.jsx(oc,{initialValue:ee,options:y[P]??[],loading:k[P]??!1,onCommit:de=>q(g,P,de),onCancel:V}):t.jsx(sc,{initialValue:ee,type:F.type??"text",mask:F.mask,onCommit:de=>q(g,P,de),onCancel:V});return t.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:lc,onClick:de=>de.stopPropagation(),children:Q})}const se=B.cell(le);return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${g}:${P}`,className:`peer absolute inset-0 z-10 ${K?"cursor-wait":"cursor-pointer"}`,onClick:_}),te&&!K&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:ga}),K&&t.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:ga,children:[t.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}),t.jsx("span",{className:"truncate text-xs text-[var(--text-muted)]",children:"Guardando…"})]}),t.jsx("span",{className:"relative z-0 inline-flex items-center gap-1 pointer-events-none",children:U?t.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[t.jsx(z.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"truncate text-xs",children:U})]}):t.jsx("span",{className:"truncate",children:se})}),!K&&t.jsx(z.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"})]})}}}),[e,o,u,f,h,x,y,k,n,q,V,W]);return t.jsx("div",{ref:C,tabIndex:0,onKeyDown:L,onBlur:B=>{var F;(F=C.current)!=null&&F.contains(B.relatedTarget)||setTimeout(()=>{var g,P;const le=document.activeElement;le&&((g=le.closest)!=null&&g.call(le,"[data-bonsaif-select-dropdown]"))||(P=C.current)!=null&&P.contains(le)||V(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:t.jsx(Hs,{...l,columns:oe,data:i,getRowId:n})})}function Je(e){if(e)return new Date(`${e}T12:00:00`)}function ht(e){const r=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return`${r}-${n}-${a}`}function sr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Bs(e){return e.map(r=>Je(r)).filter(r=>!!r)}function cc(e){if(!(e!=null&&e.length))return[];const r=new Set(e.map(ht));return Array.from(r).sort()}function va(e){return new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(e)}function Fs(e){const r=Je(e);if(!r)return e;const n=va(r).replace(/\.$/u,"").replace(/^\w/u,o=>o.toUpperCase()),a=new Intl.DateTimeFormat("es-MX",{month:"short"}).format(r).replace(/\.$/u,"").toLowerCase();return`${n} - ${r.getDate()} ${a} ${r.getFullYear()}`}const ya={weekend:{dayOfWeek:[0,6]}},xa={weekend:"bonsaif-weekend"};function wa({children:e,className:r="",...n}){const a=String(e??"").toLowerCase().normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").trim(),o=a.startsWith("sab")||a.startsWith("dom")||a==="s"||a==="d";return t.jsx("th",{...n,className:`${r} ${o?"bonsaif-weekday-weekend":""}`.trim(),children:e})}const dc={background:"var(--primary)",color:"var(--primary-fg, #ffffff)",borderRadius:999},uc={background:"color-mix(in srgb, var(--primary) 22%, transparent)",color:"var(--text-main)",borderRadius:999};function fc({day:e,modifiers:r,...n}){const a=r.range_start||r.range_end||r.selected&&!r.range_middle,o=!!r.range_middle,l=!!r.weekend||e.date.getDay()===0||e.date.getDay()===6;return t.jsx("button",{...n,type:"button",className:`bonsaif-multi-day-btn${a?" is-range-edge":""}${o?" is-range-middle":""}${l?" bonsaif-day-weekend":""} ${n.className??""}`,style:{...a?dc:null,...o?uc:null,...l?{fontWeight:800}:null,...n.style}})}function bc({startDate:e,endDate:r,onChange:n,minDate:a,viewMonth:o,numberOfMonths:l=1,orientation:i="horizontal",showSummary:c=!0,startLabel:d="Inicio",endLabel:u="Regreso",className:m=""}){const f={from:Je(e),to:Je(r)},b=Je(a),[v,x]=s.useState(()=>Je(o||e)??new Date);s.useEffect(()=>{const y=Je(o||e);y&&x(y)},[o,e]);const E=s.useMemo(()=>{if(l<=1)return sr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(v));const y=new Date(v.getFullYear(),v.getMonth()+l-1,1),w=v.getFullYear()===y.getFullYear(),k=new Intl.DateTimeFormat("es-MX",{month:"short",...w?{}:{year:"numeric"}}).format(v),N=new Intl.DateTimeFormat("es-MX",{month:"short",year:"numeric"}).format(y);return`${sr(k)} – ${sr(N)}`},[v,l]);function h(){x(new Date(v.getFullYear(),v.getMonth()-1,1))}function $(){x(new Date(v.getFullYear(),v.getMonth()+1,1))}const M=l>1?`bonsaif-range-months bonsaif-range-months--multi bonsaif-range-months--${i}`:"bonsaif-range-months";return t.jsxs("div",{className:`bonsaif-calendar bonsaif-date-range-picker ${m}`.trim(),children:[t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes anterior",onClick:h,children:t.jsx(z.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:E}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes siguiente",onClick:$,children:t.jsx(z.HiChevronRight,{size:16})})]}),t.jsx(la.DayPicker,{mode:"range",selected:f,month:v,onMonthChange:x,onSelect:y=>{const w=y!=null&&y.from?ht(y.from):e,k=y!=null&&y.to?ht(y.to):"";n({startDate:w,endDate:k})},numberOfMonths:l,hideNavigation:!0,weekStartsOn:1,disabled:b?{before:b}:void 0,showOutsideDays:!1,modifiers:ya,modifiersClassNames:xa,components:{DayButton:fc,Weekday:wa},classNames:{root:"bonsaif-range-daypicker w-full",months:M,month:l>1?"bonsaif-multi-month bonsaif-range-month-card":"bonsaif-multi-month",month_caption:l>1?"bonsaif-range-month-caption":"bonsaif-multi-caption-hidden",month_grid:"bonsaif-multi-month-grid",weekdays:"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:"bonsaif-multi-week",day:"bonsaif-multi-day",day_button:"bonsaif-multi-day-btn",selected:"bonsaif-range-day-selected",range_start:"bonsaif-range-start",range_middle:"bonsaif-range-middle",range_end:"bonsaif-range-end",today:"bonsaif-multi-day-today",disabled:"bonsaif-multi-day-disabled",hidden:"bonsaif-multi-day-hidden"},formatters:{formatCaption:y=>`${sr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(y))} ${y.getFullYear()}`,formatWeekdayName:va}})]}),c?t.jsx("div",{className:"bonsaif-cal-summary",children:e?t.jsxs("div",{className:"bonsaif-cal-chips",children:[t.jsxs("span",{className:"bonsaif-cal-chip bonsaif-cal-chip--static",children:[d,": ",e]}),r?t.jsxs("span",{className:"bonsaif-cal-chip bonsaif-cal-chip--static",children:[u,": ",r]}):null]}):t.jsx("span",{children:"Sin rango seleccionado"})}):null]})}function Ps({day:e,modifiers:r,onDayPointerDown:n,onDayPointerEnter:a,onDayClickSelect:o,...l}){const i=!!(r.disabled||r.hidden),c=!!r.weekend||e.date.getDay()===0||e.date.getDay()===6;return t.jsx("button",{...l,type:"button",disabled:i||l.disabled,className:`${l.className??""}${c?" bonsaif-day-weekend":""}`,style:{...c?{fontWeight:800}:null,...l.style},onPointerDown:d=>{var u;i||(n==null||n(e.date,d),(u=l.onPointerDown)==null||u.call(l,d))},onPointerEnter:()=>{i||a==null||a(e.date)},onClick:d=>{i||(d.preventDefault(),d.stopPropagation(),o==null||o(e.date,d))}})}function _s(e,r){const n=Je(e),a=Je(r);if(!n||!a)return[];const o=n<=a?n:a,l=n<=a?a:n,i=[],c=new Date(o);for(;c<=l;)i.push(ht(c)),c.setDate(c.getDate()+1);return i}function zs(e,r=1){const n=e.getDay(),a=r===1?(n+6)%7:n,o=new Date(e);return o.setHours(12,0,0,0),o.setDate(o.getDate()-a),Array.from({length:7},(l,i)=>{const c=new Date(o);return c.setDate(o.getDate()+i),c})}function _r(e,r,n){const a=new Set(e);for(const o of r)n==="add"?a.add(o):n==="remove"||a.has(o)?a.delete(o):a.add(o);return Array.from(a).sort()}function mc(e,r){return typeof r!="number"||r<=0||e.length<=r?e:e.slice(-r)}function gn(e,r,n){return!!(r&&e<r||n&&e>n)}function js({value:e,onChange:r,disabled:n=!1,minDate:a,maxDate:o,maxDates:l,retainOutsidePrefix:i}){const c=s.useRef(null),d=s.useRef(null),u=s.useRef(!1),m=s.useRef(e);m.current=e;const f=s.useCallback(y=>{let w=y;if(i){const k=m.current.filter(A=>!A.startsWith(i)),N=y.filter(A=>A.startsWith(i));w=[...k,...N].sort()}r==null||r(mc(w,l))},[l,r,i]),b=s.useCallback(y=>y.filter(w=>!gn(w,a,o)),[a,o]),v=s.useCallback(()=>{d.current=null},[]);s.useEffect(()=>{const y=()=>v();return window.addEventListener("pointerup",y),window.addEventListener("pointercancel",y),()=>{window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",y)}},[v]);const x=s.useCallback((y,w,k,N)=>{const A=b(_s(y,w));f(k==="add"?_r(N,A,"add"):_r(N,A,"remove"))},[f,b]),E=s.useCallback((y,w)=>{if(n||w.button!==0)return;const k=ht(y);if(gn(k,a,o)||w.shiftKey)return;u.current=!0;const N=[...m.current],A=N.includes(k)?"remove":"add";d.current={active:!0,mode:A,anchor:k,latest:k,baseline:N},c.current=k,x(k,k,A,N),w.preventDefault()},[x,n,o,a]),h=s.useCallback(y=>{const w=d.current;if(!(w!=null&&w.active)||n)return;const k=ht(y);gn(k,a,o)||w.latest!==k&&(w.latest=k,x(w.anchor,k,w.mode,w.baseline))},[x,n,o,a]),$=s.useCallback((y,w)=>{if(n)return;const k=ht(y);if(!gn(k,a,o)){if(u.current&&!w.shiftKey){u.current=!1,w.preventDefault(),w.stopPropagation();return}if(u.current=!1,w.shiftKey&&c.current){w.preventDefault(),w.stopPropagation();const N=b(_s(c.current,k));f(_r(m.current,N,"add"));return}c.current=k,f(_r(m.current,[k],"toggle"))}},[f,n,b,o,a]),M=s.useCallback(y=>{if(n)return;const w=b(cc(y));if(!w.length)return;const k=w.every(N=>m.current.includes(N));f(_r(m.current,w,k?"remove":"add")),c.current=w[0]??c.current},[f,n,b]);return{onDayPointerDown:E,onDayPointerEnter:h,onDayClick:$,toggleWeek:M,endDrag:v}}function zr(e){return zs(e,1)[0]}function Ws(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function pc({value:e=[],onChange:r,minDate:n,maxDate:a,viewMonth:o,maxDates:l,showWeekNumbers:i=!1,viewMode:c,defaultViewMode:d="month",onViewModeChange:u,showSummary:m=!0,className:f="",disabled:b=!1}){const v=s.useMemo(()=>Bs(e),[e]),x=s.useMemo(()=>new Set(e),[e]),E=Je(n),h=Je(a),[$,M]=s.useState(()=>Je(o||e[0])??new Date),[y,w]=s.useState(()=>zr(Je(o||e[0])??new Date)),[k,N]=s.useState(d),A=c??k;function C(L){c===void 0&&N(L),u==null||u(L)}s.useEffect(()=>{const L=Je(o);L&&(M(L),w(zr(L)))},[o]);const{onDayPointerDown:j,onDayPointerEnter:W,onDayClick:G,toggleWeek:T}=js({value:e,onChange:r,disabled:b,minDate:n,maxDate:a,maxDates:l}),Z=s.useCallback(L=>t.jsx(Ps,{...L,className:`bonsaif-multi-day-btn ${L.className??""}`,onDayPointerDown:j,onDayPointerEnter:W,onDayClickSelect:G}),[G,j,W]),H=s.useMemo(()=>zs(y,1),[y]),ae=H[6],X=A==="week"?`${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short"}).format(H[0])} – ${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short",year:"numeric"}).format(ae)}`:sr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format($));function V(){if(A==="week"){const L=Ws(y,-7);w(zr(L)),M(L);return}M(new Date($.getFullYear(),$.getMonth()-1,1))}function q(){if(A==="week"){const L=Ws(y,7);w(zr(L)),M(L);return}M(new Date($.getFullYear(),$.getMonth()+1,1))}return t.jsxs("div",{className:`bonsaif-calendar bonsaif-multi-date-calendar ${f}`,children:[t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-view-toggle",role:"tablist","aria-label":"Vista",children:[t.jsx("button",{type:"button",role:"tab","aria-selected":A==="month",className:`bonsaif-cal-view-btn${A==="month"?" is-active":""}`,disabled:b,onClick:()=>{C("month"),M(y)},children:"Mes"}),t.jsx("button",{type:"button",role:"tab","aria-selected":A==="week",className:`bonsaif-cal-view-btn${A==="week"?" is-active":""}`,disabled:b,onClick:()=>{C("week"),w(zr($))},children:"Semana"})]}),t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":A==="week"?"Semana anterior":"Mes anterior",disabled:b,onClick:V,children:t.jsx(z.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:X}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":A==="week"?"Semana siguiente":"Mes siguiente",disabled:b,onClick:q,children:t.jsx(z.HiChevronRight,{size:16})})]}),t.jsxs("p",{className:"bonsaif-cal-hint",children:["Click · Shift+click rango · Arrastra",i&&A==="month"?" · Semana (nº)":"",A==="week"?" · Botón semana completa":""]}),A==="month"?t.jsx(la.DayPicker,{mode:"multiple",required:!1,selected:v,month:$,onMonthChange:M,onSelect:()=>{},hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,showWeekNumber:i,onWeekNumberClick:(L,oe)=>{T(oe)},disabled:b?!0:[...E?[{before:E}]:[],...h?[{after:h}]:[]],className:"bonsaif-multi-daypicker",modifiers:ya,modifiersClassNames:xa,classNames:{root:"bonsaif-multi-daypicker",months:"bonsaif-multi-months",month:"bonsaif-multi-month",month_caption:"bonsaif-multi-caption-hidden",month_grid:"bonsaif-multi-month-grid",weekdays:i?"bonsaif-multi-weekdays bonsaif-multi-weekdays--with-week":"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:i?"bonsaif-multi-week bonsaif-multi-week--with-week":"bonsaif-multi-week",week_number:"bonsaif-week-number",week_number_header:"bonsaif-week-number-header",day:"bonsaif-multi-day",day_button:"bonsaif-multi-day-btn",selected:"bonsaif-multi-day-selected",today:"bonsaif-multi-day-today",disabled:"bonsaif-multi-day-disabled",hidden:"bonsaif-multi-day-hidden"},components:{DayButton:Z,Weekday:wa},formatters:{formatWeekdayName:va}}):t.jsxs("div",{className:"bonsaif-week-view",children:[t.jsx("div",{className:"bonsaif-week-view-head",children:H.map(L=>t.jsx("div",{className:"bonsaif-multi-weekday",children:new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(L)},`h-${ht(L)}`))}),t.jsx("div",{className:"bonsaif-week-view-days",children:H.map(L=>{const oe=ht(L),B=x.has(oe),F=b||(n?oe<n:!1)||(a?oe>a:!1),le=oe===ht(new Date);return t.jsx("div",{className:`bonsaif-multi-day${B?" bonsaif-multi-day-selected":""}${le?" bonsaif-multi-day-today":""}${F?" bonsaif-multi-day-disabled":""}`,children:t.jsxs("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:F,"aria-pressed":B,onPointerDown:g=>j(L,g),onPointerEnter:()=>W(L),onClick:g=>G(L,g),children:[t.jsx("span",{className:"bonsaif-week-day-num",children:L.getDate()}),t.jsx("span",{className:"bonsaif-week-day-month",children:new Intl.DateTimeFormat("es-MX",{month:"short"}).format(L)})]})},oe)})}),t.jsx("button",{type:"button",className:"bonsaif-week-select-all",disabled:b,onClick:()=>T(H),children:"Marcar / desmarcar semana"})]})]}),m?t.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?t.jsx("span",{children:"Sin fechas seleccionadas"}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(L=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:b,onClick:()=>r==null?void 0:r(e.filter(oe=>oe!==L)),title:`Quitar ${L}`,children:[Fs(L),t.jsx("span",{"aria-hidden":!0,children:"×"})]},L))})]})}):null]})}const hc=Array.from({length:12},(e,r)=>r);function gc({value:e=[],onChange:r,year:n,onYearChange:a,minDate:o,maxDate:l,maxDates:i,showSummary:c=!0,className:d="",disabled:u=!1,readOnly:m=!1}){const f=s.useMemo(()=>Bs(e),[e]),b=Je(o),v=Je(l),x=n??(e[0]?Number(e[0].slice(0,4)):new Date().getFullYear()),[E,h]=s.useState(x);s.useEffect(()=>{typeof n=="number"&&h(n)},[n]);function $(C){h(C),a==null||a(C)}const{onDayPointerDown:M,onDayPointerEnter:y,onDayClick:w}=js({value:e,onChange:r,disabled:u||m,minDate:o,maxDate:l,maxDates:i,retainOutsidePrefix:`${E}-`}),k=s.useCallback(C=>t.jsx(Ps,{...C,className:`bonsaif-year-day-btn ${C.className??""}`,onDayPointerDown:M,onDayPointerEnter:y,onDayClickSelect:w}),[w,M,y]),N=f.filter(C=>C.getFullYear()===E),A=u?!0:[...b?[{before:b}]:[],...v?[{after:v}]:[]];return t.jsxs("div",{className:`bonsaif-calendar bonsaif-year-multi-date-calendar${m?" bonsaif-year-multi-date-calendar--readonly":""} ${d}`,children:[t.jsxs("div",{className:"bonsaif-cal-shell bonsaif-year-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año anterior",disabled:u,onClick:()=>$(E-1),children:t.jsx(z.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:E}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año siguiente",disabled:u,onClick:()=>$(E+1),children:t.jsx(z.HiChevronRight,{size:16})})]}),!m&&!u?t.jsx("p",{className:"bonsaif-cal-hint",children:"Click · Shift+click rango · Arrastra para marcar varias"}):null,t.jsx("div",{className:"bonsaif-year-cal-grid",children:hc.map(C=>{const j=new Date(E,C,1);return t.jsxs("div",{className:"bonsaif-year-cal-month",children:[t.jsx("div",{className:"bonsaif-year-cal-month-title",children:sr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(j))}),t.jsx(la.DayPicker,{mode:"multiple",required:!1,selected:N,month:j,onMonthChange:()=>{},onSelect:()=>{},numberOfMonths:1,hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,disabled:A,className:"bonsaif-year-month-picker",modifiers:ya,modifiersClassNames:xa,classNames:{root:"bonsaif-year-month-picker",months:"bonsaif-year-month-months",month:"bonsaif-year-month-inner",month_caption:"bonsaif-year-month-caption-hidden",month_grid:"bonsaif-year-month-grid",weekdays:"bonsaif-year-weekdays",weekday:"bonsaif-year-weekday",week:"bonsaif-year-week",day:"bonsaif-year-day",day_button:"bonsaif-year-day-btn",selected:"bonsaif-year-day-selected",today:"bonsaif-year-day-today",disabled:"bonsaif-year-day-disabled",hidden:"bonsaif-year-day-hidden"},components:{DayButton:k,Weekday:wa},formatters:{formatWeekdayName:W=>new Intl.DateTimeFormat("es-MX",{weekday:"narrow"}).format(W)}})]},`${E}-${C}`)})})]}),c?t.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?t.jsx("span",{children:"Sin fechas seleccionadas"}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"," ·"," ",E]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(C=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:u||m,onClick:()=>r==null?void 0:r(e.filter(j=>j!==C)),title:`Quitar ${C}`,children:[Fs(C),t.jsx("span",{"aria-hidden":!0,children:"×"})]},C))})]})}):null]})}const vc="bonsaif-ui:hide-tooltips";function qs(){window.dispatchEvent(new CustomEvent(vc))}function yc(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function xc({trigger:e,items:r,align:n="end",width:a=220,disabled:o=!1,className:l="",menuClassName:i="",onOpenChange:c}){const[d,u]=s.useState(!1),[m,f]=s.useState(!1),[b,v]=s.useState({}),x=s.useRef(null),E=s.useRef(null),h=s.useCallback(k=>{u(k),c==null||c(k)},[c]),$=s.useCallback(()=>{const k=x.current;if(!k)return;const N=k.getBoundingClientRect(),A=typeof a=="number"?a:N.width,C=typeof a=="number"?a:Math.max(N.width,180),j=n==="end"?Math.max(8,N.right-C):Math.min(N.left,window.innerWidth-C-8),W=window.innerHeight-N.bottom,G=W<240&&N.top>W?void 0:N.bottom+6,T=G===void 0?window.innerHeight-N.top+6:void 0;v({position:"fixed",zIndex:9999,left:j,top:G,bottom:T,width:yc(typeof a=="number"?A:a)})},[n,a]);s.useEffect(()=>f(!0),[]),s.useEffect(()=>{if(!d)return;$();const k=A=>{var j,W;const C=A.target;!((j=x.current)!=null&&j.contains(C))&&!((W=E.current)!=null&&W.contains(C))&&h(!1)},N=A=>{A.key==="Escape"&&h(!1)};return document.addEventListener("mousedown",k),window.addEventListener("keydown",N),window.addEventListener("resize",$),window.addEventListener("scroll",$,!0),()=>{document.removeEventListener("mousedown",k),window.removeEventListener("keydown",N),window.removeEventListener("resize",$),window.removeEventListener("scroll",$,!0)}},[d,h,$]);const M=k=>{o||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),h(!d))},y=s.isValidElement(e)?s.cloneElement(e,{onClick:()=>{o||(qs(),h(!d))}}):e,w=d?t.jsx("div",{ref:E,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${i}`,style:b,children:r.map(k=>t.jsxs("div",{children:[k.separatorBefore&&t.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),t.jsxs("button",{type:"button",role:"menuitem",disabled:k.disabled,onClick:()=>{var N;k.disabled||(qs(),(N=k.onSelect)==null||N.call(k),h(!1))},className:"flex w-full min-w-0 items-start gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:k.danger?"var(--danger)":"var(--text-main)"},children:[k.icon&&t.jsx("span",{className:"mt-0.5 shrink-0",children:k.icon}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium",children:k.label}),k.description&&t.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:k.description})]})]})]},k.id))}):null;return t.jsxs("span",{ref:x,role:"button",tabIndex:o?-1:0,"aria-haspopup":"menu","aria-expanded":d,onKeyDown:M,className:`inline-flex ${o?"pointer-events-none opacity-60":""} ${l}`,children:[y,m&&w?nt.createPortal(w,document.body):null]})}const wc=180,Us="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function kc({open:e,onClose:r,title:n,subtitle:a,leadingIcon:o,confirmLabel:l="Guardar",onConfirm:i,loading:c=!1,confirmDisabled:d=!1,headerActions:u,bodyClassName:m="flex-1 overflow-y-auto px-6 py-5",width:f=440,hasUnsavedChanges:b=!1,unsavedChangesTitle:v="Descartar cambios",unsavedChangesDescription:x="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:E="Descartar",unsavedChangesCancelLabel:h="Seguir editando",onDiscardChanges:$,disabled:M=!1,disabledMessage:y,children:w}){const[k,N]=s.useState(!1),[A,C]=s.useState(!1),[j,W]=s.useState(!1),G=s.useCallback(()=>{C(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>W(!0))})},[]),T=s.useCallback(()=>{W(!1),window.setTimeout(()=>C(!1),wc)},[]),Z=M||c,H=s.useCallback(()=>{if(!Z){if(b){G();return}r()}},[Z,b,r,G]),ae=s.useCallback(()=>{W(!1),C(!1),$==null||$(),r()},[r,$]);if(s.useEffect(()=>{N(!0)},[]),s.useEffect(()=>(document.body.style.overflow=e?"hidden":"",e||(W(!1),C(!1)),()=>{document.body.style.overflow=""}),[e]),s.useEffect(()=>{if(!e)return;const V=q=>{if(q.key==="Escape"&&!Z){if(A){T();return}H()}};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[T,Z,A,e,H]),!k)return null;const X=y!==void 0?y:c?"Guardando…":null;return nt.createPortal(t.jsxs("div",{"aria-hidden":!e,"data-bonsaif-overlay":e?"true":void 0,className:`fixed inset-0 z-[1000] flex transition-opacity duration-300 ${e?"opacity-100":"opacity-0 pointer-events-none"}`,children:[t.jsx("div",{className:`absolute inset-0 ${Us}`,onClick:H}),t.jsxs("div",{className:`absolute inset-y-0 right-0 flex flex-col shadow-2xl transition-transform duration-300 ${e?"translate-x-0":"translate-x-full"}`,style:{width:`min(100vw, ${f}px)`,background:"var(--bg-card)",borderLeft:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center justify-between px-6 py-4 flex-shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx(je,{variant:"icon",onClick:H,title:"Cerrar",disabled:Z,children:t.jsx(z.HiXMark,{className:"w-5 h-5"})}),o&&t.jsx("div",{className:"flex-shrink-0",children:o}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"text-base font-semibold truncate",style:{color:"var(--text-main)"},children:n}),a&&t.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:a})]})]}),(u||i)&&t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[u,i&&t.jsxs(t.Fragment,{children:[t.jsx(je,{variant:"secondary",size:"sm",onClick:H,disabled:Z,style:{background:"var(--bg-input)"},children:"Cancelar"}),t.jsx(je,{variant:"primary",size:"sm",icon:t.jsx(Gl.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:d||Z,title:l})]})]})]}),t.jsx("div",{"data-drawer-scroll":"true",className:m,children:w}),Z&&t.jsx("div",{className:"absolute inset-0 z-[1002] flex cursor-not-allowed items-center justify-center p-6",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 72%, transparent)",backdropFilter:"blur(3px)"},role:"status","aria-live":"polite","aria-busy":"true",children:X?t.jsxs("div",{className:"flex max-w-xs flex-col items-center gap-3 text-center",children:[t.jsx("div",{className:"h-9 w-9 animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]","aria-hidden":!0}),t.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:X})]}):null})]}),A&&t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":v,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[t.jsx("div",{className:`absolute inset-0 ${Us} transition-opacity duration-200 ease-out ${j?"opacity-100":"opacity-0"}`,onClick:T}),t.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 ${j?"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:[t.jsx(je,{variant:"icon",onClick:T,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":h,children:t.jsx(z.HiXMark,{className:"h-4 w-4"})}),t.jsx("div",{className:"mb-4 flex h-11 w-11 items-center justify-center rounded-xl",style:{background:"var(--warning-bg, #fff7ed)"},children:t.jsx(z.HiExclamationTriangle,{className:"h-5 w-5",style:{color:"var(--warning, #d97706)"}})}),t.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main, #0f2f2c)"},children:v}),t.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:x}),t.jsxs("div",{className:"mt-6 flex gap-2",children:[t.jsx(je,{variant:"secondary",onClick:T,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:h}),t.jsx(je,{variant:"secondary",onClick:ae,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:E})]})]})]})]}),document.body)}const Nc=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Sc=/^\+?[0-9\s().-]+$/,Cc=7,Ec=15;function gt(e){return e==null||String(e).trim()===""}function Vs(e){return typeof e=="number"?e:typeof e=="string"&&e.trim()!==""?Number(e):Number.NaN}function ka(e){return gt(e)?!1:Nc.test(String(e))}function Na(e){if(gt(e))return!1;const r=String(e),n=r.replace(/\D/g,"");return Sc.test(r)&&n.length>=Cc&&n.length<=Ec}function Mc(e="Este campo es requerido."){return r=>gt(r)?e:void 0}function $c(e="Ingresa un correo valido."){return r=>gt(r)||ka(r)?void 0:e}function Tc(e="Ingresa un telefono valido."){return r=>gt(r)||Na(r)?void 0:e}function Lc(e,r){return n=>gt(n)||String(n).length>=e?void 0:r??`Debe tener al menos ${e} caracteres.`}function Ac(e,r){return n=>gt(n)||String(n).length<=e?void 0:r??`Debe tener ${e} caracteres o menos.`}function Dc(e,r){return n=>{if(gt(n))return;const a=Vs(n);return Number.isFinite(a)&&a>=e?void 0:r??`Debe ser mayor o igual a ${e}.`}}function Ic(e,r){return n=>{if(gt(n))return;const a=Vs(n);return Number.isFinite(a)&&a<=e?void 0:r??`Debe ser menor o igual a ${e}.`}}function Oc(e,r="El formato no es valido."){return n=>gt(n)||e.test(String(n))?void 0:r}function Hc(e,r){const n={};for(const a of Object.keys(r)){const o=r[a];if(!o)continue;const l=Array.isArray(o)?o:[o];for(const i of l){const c=i(e[a],e);if(c){n[a]=c;break}}}return{valid:Object.keys(n).length===0,errors:n}}var Ys={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Xs=s.createContext&&s.createContext(Ys),Bc=["attr","size","title"];function Fc(e,r){if(e==null)return{};var n,a,o=Pc(e,r);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a<l.length;a++)n=l[a],r.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function Pc(e,r){if(e==null)return{};var n={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(r.indexOf(a)!==-1)continue;n[a]=e[a]}return n}function vn(){return vn=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},vn.apply(null,arguments)}function Ks(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);r&&(a=a.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,a)}return n}function yn(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Ks(Object(n),!0).forEach(function(a){_c(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ks(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function _c(e,r,n){return(r=zc(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function zc(e){var r=jc(e,"string");return typeof r=="symbol"?r:r+""}function jc(e,r){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var a=n.call(e,r);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function Gs(e){return e&&e.map((r,n)=>s.createElement(r.tag,yn({key:n},r.attr),Gs(r.child)))}function Sa(e){return r=>s.createElement(Wc,vn({attr:yn({},e.attr)},r),Gs(e.child))}function Wc(e){var r=n=>{var{attr:a,size:o,title:l}=e,i=Fc(e,Bc),c=o||n.size||"1em",d;return n.className&&(d=n.className),e.className&&(d=(d?d+" ":"")+e.className),s.createElement("svg",vn({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,i,{className:d,style:yn(yn({color:e.color||n.color},n.style),e.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),l&&s.createElement("title",null,l),e.children)};return Xs!==void 0?s.createElement(Xs.Consumer,null,n=>r(n)):r(Ys)}function Zs(e){return Sa({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:[]}]})(e)}function qc(e){return Sa({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:[]}]})(e)}function Uc(e){return Sa({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:[]}]})(e)}function or({content:e,ariaLabel:r="Más información",className:n=""}){return t.jsx(zt,{as:"span",content:e,className:`inline-flex shrink-0 align-middle text-[var(--text-muted)] outline-none transition-colors hover:text-[var(--primary)] focus-visible:text-[var(--primary)] ${n}`,children:t.jsx("span",{tabIndex:0,role:"img","aria-label":r,className:"inline-flex items-center justify-center outline-none",children:t.jsx(z.HiInformationCircle,{className:"h-3.5 w-3.5"})})})}function lr({error:e,helperText:r,helperDisplay:n="inline"}){return e?t.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:e}):r&&n!=="tooltip"?t.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:r}):null}function xn({className:e="",...r}){return t.jsx("input",{...r,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)] ${e}`})}function Ca({label:e,containerClassName:r="",helperText:n,helperDisplay:a="inline",error:o,errorDisplay:l="inline",errorTooltipLabel:i="Error de validacion",labelAction:c,floatingLabel:d=!1,showPasswordToggle:u=!0,nativeValidation:m=!1,className:f="",required:b,...v}){const[x,E]=s.useState(()=>!!v.autoFocus),[h,$]=s.useState(!1),M=v.type==="password"&&u,y=M&&h?"text":v.type,w=!!o,k=w&&l!=="tooltip",N=w&&l!=="inline",A=!!n&&a==="tooltip"&&!k,C=m?b:void 0,j=w?"border-[var(--danger)] focus:border-[var(--danger)]":"",W=N?M?"pr-20":"pr-10":M?"pr-10":"",G=v.value!==void 0?String(v.value).length>0:v.defaultValue!==void 0&&String(v.defaultValue).length>0,T=x||G,Z={top:T?7:12,color:x?"var(--primary)":"var(--text-muted)",fontSize:T?10:13,fontWeight:T?600:400,textTransform:T?"uppercase":"none"},H=L=>{var oe;E(!0),(oe=v.onFocus)==null||oe.call(v,L)},ae=L=>{var oe;E(!1),(oe=v.onBlur)==null||oe.call(v,L)},X=M?t.jsxs("button",{type:"button","aria-label":h?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":h,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors duration-200 hover:text-[var(--primary)] focus:outline-none",tabIndex:-1,onClick:()=>$(L=>!L),children:[t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${h?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:t.jsx(qc,{className:"h-[18px] w-[18px]"})}),t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${h?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:t.jsx(Uc,{className:"h-[18px] w-[18px]"})})]}):null,V=N?t.jsx(zt,{as:"span",content:o,className:`absolute top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--danger)] outline-none transition-colors hover:bg-[var(--danger-bg)] focus-visible:bg-[var(--danger-bg)] ${M?"right-10":"right-2.5"}`,children:t.jsx("span",{tabIndex:0,role:"img","aria-label":i,className:"flex h-full w-full items-center justify-center outline-none",children:t.jsx(Zs,{className:"h-[18px] w-[18px]"})})}):null,q=t.jsx(lr,{error:k?o:void 0,helperText:n,helperDisplay:a});return d?t.jsxs("label",{className:`flex flex-col gap-2 ${r}`,children:[t.jsxs("span",{className:"relative block",children:[t.jsx(xn,{...v,type:y,required:C,placeholder:" ","aria-invalid":w||v["aria-invalid"],"data-has-value":G?"true":void 0,className:`h-11 w-full pt-5 ${W} ${j} ${f}`,onFocus:H,onBlur:ae}),t.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:Z,children:[e,b&&t.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),c&&t.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:T?7:12},children:c}),V,X]}),q]}):t.jsxs("label",{className:`flex flex-col gap-2 ${r}`,children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[t.jsx("span",{children:e}),b&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),A?t.jsx(or,{content:n}):null,c&&t.jsx("span",{className:"ml-auto normal-case",children:c})]}),M?t.jsxs("span",{className:"relative block",children:[t.jsx(xn,{...v,type:y,required:C,"aria-invalid":w||v["aria-invalid"],className:`w-full ${W} ${j} ${f}`,onFocus:H,onBlur:ae}),V,X]}):t.jsxs("span",{className:"relative block",children:[t.jsx(xn,{...v,required:C,"aria-invalid":w||v["aria-invalid"],className:`w-full ${W} ${j} ${f}`}),V]}),q]})}function Qs(e){return e==null?"":String(e)}function Vc({autoComplete:e="email",inputMode:r="email",validate:n=!0,invalidMessage:a="Ingresa un correo valido.",errorDisplay:o="tooltip",error:l,value:i,defaultValue:c,onChange:d,...u}){const[m,f]=s.useState(()=>Qs(c)),b=i!==void 0?Qs(i):m,v=n&&b.length>0&&!ka(b)?a:void 0,x=E=>{i===void 0&&f(E.currentTarget.value),d==null||d(E)};return t.jsx(Ca,{...u,value:i,defaultValue:c,type:"text",inputMode:r,autoComplete:e,error:l??v,errorDisplay:o,onChange:x})}const Yc={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function Xc({title:e="Sin resultados",description:r,icon:n=t.jsx(z.HiInbox,{className:"h-5 w-5"}),action:a,secondaryAction:o,size:l="md",className:i=""}){return t.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${Yc[l]} ${i}`,children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[n&&t.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:n}),t.jsxs("div",{className:"space-y-1",children:[e&&t.jsx("h3",{className:"text-sm font-semibold text-[var(--text-main)]",children:e}),r&&t.jsx("div",{className:"text-sm leading-5 text-[var(--text-muted)]",children:r})]}),(a||o)&&t.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[o,a]})]})})}const Kc={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function Gc(e){if(e===0)return"0 B";const r=["B","KB","MB","GB"],n=Math.min(Math.floor(Math.log(e)/Math.log(1024)),r.length-1),a=e/1024**n;return`${a>=10||n===0?a.toFixed(0):a.toFixed(1)} ${r[n]}`}function Js(e,r){return r?r.split(",").map(n=>n.trim().toLowerCase()).filter(Boolean).some(n=>{const a=e.name.toLowerCase(),o=e.type.toLowerCase();return n.startsWith(".")?a.endsWith(n):n.endsWith("/*")?o.startsWith(n.slice(0,-1)):o===n}):!0}function Zc(e,r,n){return r?n===void 0?e:e.slice(0,Math.max(0,n)):e.slice(0,1)}function Qc({label:e,helperText:r,helperDisplay:n="inline",error:a,labelAction:o,value:l,defaultValue:i=[],onFilesChange:c,onRejectedFiles:d,multiple:u=!1,maxFiles:m,appendFiles:f=!1,showFileList:b=!0,clearable:v=!0,browseLabel:x="Buscar archivos",dropLabel:E="Suelta los archivos aqui",emptyLabel:h="Arrastra y suelta archivos",emptyDescription:$="o haz click para buscarlos en tu equipo",selectedLabel:M="Archivos seleccionados",size:y="md",containerClassName:w="",dropzoneClassName:k="",fileListClassName:N="",className:A="",id:C,accept:j,disabled:W,required:G,...T}){const Z=s.useId(),H=C??Z,ae=s.useRef(null),[X,V]=s.useState(!1),[q,L]=s.useState(i),oe=l??q,B=!!a,F=!!r&&n==="tooltip"&&!B,le=v&&oe.length>0&&!W,g=(Q,de)=>{l===void 0&&L(Q),c==null||c(Q,de)},P=(Q,de)=>{const Se=Q.filter(De=>Js(De,j)),ie=Q.filter(De=>!Js(De,j)),pe=f?[...oe,...Se]:Se,Ce=Zc(pe,u,m);ie.length>0&&(d==null||d(ie)),g(Ce,de)},I=()=>{var Q;W||(Q=ae.current)==null||Q.click()},te=Q=>{P(Array.from(Q.target.files??[]),Q),Q.target.value=""},U=Q=>{Q.preventDefault(),W||V(!0)},K=Q=>{Q.currentTarget.contains(Q.relatedTarget)||V(!1)},D=Q=>{Q.preventDefault(),V(!1),!W&&P(Array.from(Q.dataTransfer.files),Q)},ee=Q=>{Q.key!=="Enter"&&Q.key!==" "||(Q.preventDefault(),I())},_=Q=>{g(oe.filter((de,Se)=>Se!==Q))},se=()=>{g([])};return t.jsxs("div",{className:`flex flex-col gap-2 ${w}`,children:[(e||o||F)&&t.jsxs("div",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e&&t.jsx("span",{children:e}),G&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),F?t.jsx(or,{content:r}):null,o&&t.jsx("span",{className:"ml-auto normal-case",children:o})]}),t.jsx("input",{...T,ref:ae,id:H,type:"file",accept:j,multiple:u,disabled:W,required:G&&oe.length===0,"aria-invalid":B||T["aria-invalid"],className:"sr-only",onChange:te}),t.jsxs("div",{role:"button",tabIndex:W?-1:0,"aria-controls":H,"aria-disabled":W||void 0,"aria-invalid":B||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)] ${Kc[y]} ${X?"border-[var(--primary)] bg-[var(--bg-input)]":B?"border-[var(--danger)]":"border-[var(--border)]"} ${W?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${k} ${A}`,onClick:I,onDragOver:U,onDragLeave:K,onDrop:D,onKeyDown:ee,children:[t.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:t.jsx(z.HiArrowUpTray,{className:"h-5 w-5"})}),t.jsxs("span",{className:"space-y-1",children:[t.jsx("span",{className:"block text-sm font-semibold text-[var(--text-main)]",children:X?E:h}),$&&t.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:$})]}),x&&t.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&&oe.length>0&&t.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${N}`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-2",children:[t.jsx("span",{className:"text-xs font-semibold uppercase text-[var(--text-muted)]",children:M}),le&&t.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:se,children:t.jsx(z.HiTrash,{className:"h-4 w-4"})})]}),t.jsx("ul",{className:"divide-y divide-[var(--border)]",children:oe.map((Q,de)=>t.jsxs("li",{className:"flex items-center gap-3 px-3 py-2",children:[t.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:t.jsx(z.HiDocument,{className:"h-4 w-4"})}),t.jsxs("span",{className:"min-w-0 flex-1 text-left",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-[var(--text-main)]",children:Q.name}),t.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:Gc(Q.size)})]}),!W&&t.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:()=>_(de),children:t.jsx(z.HiXMark,{className:"h-4 w-4"})})]},`${Q.name}-${Q.lastModified}-${de}`))})]}),t.jsx(lr,{error:a,helperText:r,helperDisplay:n})]})}const Jc=[{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 Rc({fields:e,title:r="Layout",fieldTypes:n=Jc,saveLabel:a="Guardar",allowAddField:o=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:d,onChange:u}){const[m,f]=s.useState(()=>e.map(y=>({key:!1,type:"",...y}))),[b,v]=s.useState(""),[x,E]=s.useState(""),h=s.useCallback((y,w)=>{f(k=>{const N=k.map((A,C)=>C===y?{...A,...w}:A);return u==null||u(N),N})},[u]),$=s.useCallback(()=>{d==null||d(m)},[m,d]),M=s.useCallback(()=>{var N;const y=b.trim();if(!y){E("Ingresa un nombre de campo.");return}if(m.some(A=>A.name.toLowerCase()===y.toLowerCase())){E("Ese campo ya existe en el arreglo.");return}const k={name:y,key:!1,type:((N=n[0])==null?void 0:N.value)??""};f(A=>{const C=[...A,k];return u==null||u(C),C}),v(""),E("")},[n,m,b,u]);return t.jsxs("div",{className:"flex flex-col rounded-xl border shadow-sm",style:{borderColor:"var(--border)",background:"var(--bg-card)",color:"var(--text-main)"},children:[t.jsx("div",{className:"border-b px-6 py-4",style:{borderColor:"var(--border)"},children:t.jsx("span",{className:"text-base font-semibold",style:{color:"var(--text-main)"},children:r})}),t.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:[t.jsx("span",{children:"Campo"}),t.jsx("span",{className:"text-center",children:"Llave"}),t.jsx("span",{children:"Tipo de Campo"})]}),t.jsxs("div",{className:"max-h-[420px] overflow-y-auto",children:[m.map((y,w)=>t.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:[t.jsx("span",{className:"text-sm font-medium",style:{color:"var(--text-main)"},children:y.name}),t.jsx("div",{className:"flex justify-center",children:t.jsx(dn,{size:"sm",checked:y.key??!1,onChange:k=>h(w,{key:k.target.checked}),"aria-label":`${y.name} es clave`})}),t.jsx(jt,{value:y.type??"",onChange:k=>h(w,{type:k}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${y.name}`})]},y.name)),m.length===0&&t.jsx("p",{className:"px-6 py-8 text-center text-sm",style:{color:"var(--text-muted)"},children:"No hay campos disponibles."})]}),t.jsx("div",{className:"flex justify-end border-t px-6 py-4",style:{borderColor:"var(--border)"},children:t.jsxs("div",{className:"w-full space-y-2",children:[o&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:b,onChange:y=>{v(y.currentTarget.value),x&&E("")},onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),M())},placeholder:l,className:"min-w-0 flex-1 rounded-lg border px-3 py-2 text-sm outline-none transition-colors",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"},"aria-label":"Nombre del nuevo campo"}),t.jsx(je,{variant:"secondary",onClick:M,height:36,padding:"0 12px",children:i})]}),x&&t.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:x})]}),t.jsx("div",{className:"flex justify-end",children:t.jsx(je,{variant:"primary",onClick:$,disabled:c,loading:c,children:a})})]})})]})}function Ea({label:e,children:r,helperText:n,helperDisplay:a="inline",error:o,labelAction:l,required:i=!1,className:c="",contentClassName:d=""}){const u=!!n&&a==="tooltip"&&!o;return t.jsxs("label",{className:`flex flex-col gap-2 ${c}`,children:[(e||l||u)&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e&&t.jsx("span",{children:e}),i&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),u?t.jsx(or,{content:n}):null,l&&t.jsx("span",{className:"ml-auto normal-case",children:l})]}),t.jsx("span",{className:`block ${d}`,children:r}),t.jsx(lr,{error:o,helperText:n,helperDisplay:a})]})}function ed(e){return Array.from(e.querySelectorAll("img")).filter(r=>!!(r.currentSrc||r.src||"").trim())}function Rs(e,r){const n=e.target;if(!(n instanceof HTMLImageElement))return!1;const a=e.currentTarget,o=ed(a),l=o.indexOf(n);if(l<0)return!1;e.preventDefault(),e.stopPropagation();const i=n.getBoundingClientRect();return r(o.map(c=>({src:c.currentSrc||c.src,alt:c.alt||void 0})),l,{left:i.left,top:i.top,width:i.width,height:i.height}),!0}const bt=260,ir=420,Ma=380,vt="cubic-bezier(0.22, 1, 0.36, 1)",td="cubic-bezier(0.16, 1, 0.3, 1)",$a="cubic-bezier(0.22, 1, 0.36, 1)",rd="cubic-bezier(0.22, 1, 0.36, 1)",nd=8,ad=1,sd=1.25,Ta={background:"color-mix(in srgb, var(--bg-card) 90%, transparent)",border:"1px solid var(--border)",boxShadow:"0 10px 28px color-mix(in srgb, var(--bg-main) 28%, transparent), inset 0 1px 0 color-mix(in srgb, var(--bg-card) 55%, transparent)",color:"var(--text-main)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)"},od="color-mix(in srgb, var(--bg-card) 88%, var(--primary) 12%)",La=10;function jr(e,r,n){return Math.min(n,Math.max(r,e))}function ld(e){return!e||e.width<1||e.height<1?null:{left:e.left,top:e.top,width:e.width,height:e.height}}function eo(e,r){if(r.width<1||r.height<1)return{dx:0,dy:0,scale:1};const n=Math.min(e.width/r.width,e.height/r.height),a=e.left+e.width/2-(r.left+r.width/2),o=e.top+e.height/2-(r.top+r.height/2);return{dx:a,dy:o,scale:Number.isFinite(n)?n:1}}function cr({label:e,onClick:r,children:n,disabled:a,size:o="md"}){const l=o==="lg"?44:40;return t.jsx("button",{type:"button","aria-label":e,title:e,disabled:a,onClick:i=>{i.stopPropagation(),r()},className:"inline-flex items-center justify-center rounded-full disabled:cursor-not-allowed disabled:opacity-35",style:{...Ta,width:l,height:l,transition:"background 160ms ease, transform 160ms cubic-bezier(0.22, 1, 0.36, 1), opacity 160ms ease"},onMouseEnter:i=>{a||(i.currentTarget.style.background=od,i.currentTarget.style.transform="scale(1.06)")},onMouseLeave:i=>{i.currentTarget.style.background=String(Ta.background??""),i.currentTarget.style.transform="scale(1)"},onMouseDown:i=>{a||(i.currentTarget.style.transform="scale(0.94)")},onMouseUp:i=>{a||(i.currentTarget.style.transform="scale(1.06)")},children:n})}function to({open:e,onClose:r,slides:n,index:a,onIndexChange:o,originRect:l=null,maxZoom:i=nd,minZoom:c=ad,zoomStep:d=sd,closeOnBackdrop:u=!0,closeOnEscape:m=!0,showCounter:f=!0,showZoomControls:b=!0,loop:v=!0,showThumbnails:x=!0,zIndex:E=1100,ariaLabel:h="Visor de imagen"}){const[$,M]=s.useState(!1),[y,w]=s.useState(!1),[k,N]=s.useState(a??0),[A,C]=s.useState(1),[j,W]=s.useState({x:0,y:0}),[G,T]=s.useState({opacity:1,x:0,scale:1,blur:0,animate:!1}),[Z,H]=s.useState({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),[ae,X]=s.useState(!1),V=s.useRef(null),q=s.useRef(null),L=s.useRef(null),oe=s.useRef(null),B=s.useRef(null),F=s.useRef(!1),le=s.useRef(!1),g=s.useRef(null),P=s.useRef(null),I=s.useRef(null),te=s.useRef(null),U=s.useRef(null),K=s.useRef(a??0),D=a??k,ee=n.length===0?0:jr(D,0,Math.max(0,n.length-1)),_=n[ee],se=n.length>1,Q=Math.max(c,i),de=x&&se,Se=s.useCallback(ce=>{if(n.length===0)return;const ue=n.length-1,Ee=v?(ce%n.length+n.length)%n.length:jr(ce,0,ue);a===void 0&&N(Ee),o==null||o(Ee)},[a,v,o,n.length]),ie=s.useCallback(()=>{C(1),W({x:0,y:0})},[]),pe=s.useCallback((ce,ue)=>{if(ue<=c+.001)return{x:0,y:0};const Ee=te.current,Ie=U.current;if(!Ee||!Ie)return ce;const Ae=Ee.getBoundingClientRect(),Pe=Ie.offsetWidth*ue,Ge=Ie.offsetHeight*ue,Ze=Math.max(0,(Pe-Ae.width)/2+Ae.width*.15),Qe=Math.max(0,(Ge-Ae.height)/2+Ae.height*.15);return{x:jr(ce.x,-Ze,Ze),y:jr(ce.y,-Qe,Qe)}},[c]),Ce=s.useCallback(()=>{M(!1),H({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),oe.current=null,B.current=null,F.current=!1,le.current=!1,g.current&&(clearTimeout(g.current),g.current=null)},[]),De=s.useCallback(()=>{if(F.current)return;F.current=!0,w(!1),ie();const ce=oe.current,ue=ce!=null&&B.current!=null&&B.current===ee;if(ce&&ue){L.current!=null&&cancelAnimationFrame(L.current),L.current=requestAnimationFrame(()=>{L.current=requestAnimationFrame(()=>{const Ee=U.current;if(!Ee){L.current=null,V.current&&clearTimeout(V.current),V.current=setTimeout(Ce,bt+40);return}const Ie=Ee.getBoundingClientRect(),Ae=eo(ce,Ie);H({enabled:!0,dx:0,dy:0,scale:1,animate:!1}),L.current=requestAnimationFrame(()=>{H({enabled:!0,dx:Ae.dx,dy:Ae.dy,scale:Ae.scale,animate:!0}),L.current=null})})}),V.current&&clearTimeout(V.current),V.current=setTimeout(Ce,ir+80);return}H({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),V.current&&clearTimeout(V.current),V.current=setTimeout(Ce,bt+40)},[Ce,ie,ee]);s.useEffect(()=>(e?(V.current&&clearTimeout(V.current),g.current&&(clearTimeout(g.current),g.current=null),F.current=!1,le.current=!1,oe.current=ld(l),B.current=oe.current!=null?a??k:null,M(!0),w(!1),oe.current?H({dx:0,dy:0,scale:1,animate:!1,enabled:!0}):(B.current=null,requestAnimationFrame(()=>requestAnimationFrame(()=>{w(!0),H({dx:0,dy:0,scale:1,animate:!1,enabled:!1})})))):$&&De(),()=>{V.current&&clearTimeout(V.current),L.current!=null&&cancelAnimationFrame(L.current)}),[e]);const mt=s.useCallback(()=>{if(!e||F.current||le.current)return;const ce=oe.current,ue=U.current;if(!ce||!ue){ce||(w(!0),le.current=!0);return}const Ee=ue.getBoundingClientRect();if(Ee.width<2||Ee.height<2)return;le.current=!0;const Ie=eo(ce,Ee);H({enabled:!0,dx:Ie.dx,dy:Ie.dy,scale:Ie.scale,animate:!1}),L.current!=null&&cancelAnimationFrame(L.current),L.current=requestAnimationFrame(()=>{L.current=requestAnimationFrame(()=>{H({enabled:!0,dx:0,dy:0,scale:1,animate:!0}),w(!0),L.current=null,g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{H({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),g.current=null},ir+20)})})},[e]);s.useLayoutEffect(()=>{!$||!e||!oe.current||le.current||mt()},[$,e,mt]),s.useEffect(()=>{!e||F.current||B.current!=null&&B.current!==ee&&H(ce=>ce.enabled?{dx:0,dy:0,scale:1,animate:!1,enabled:!1}:ce)},[e,ee]),s.useEffect(()=>{if(!e)return;const ce=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=ce}},[e]),s.useEffect(()=>{e&&ie()},[e,ee,ie]),s.useEffect(()=>{a!==void 0&&N(a)},[a]),s.useEffect(()=>{if(!e){K.current=ee,T({opacity:1,x:0,scale:1,blur:0,animate:!1});return}const ce=K.current;if(ce===ee)return;K.current=ee;const ue=n.length;let Ee=1;if(ue>1){const Ie=(ce+1)%ue===ee,Ae=(ce-1+ue)%ue===ee;Ae&&!Ie?Ee=-1:Ie&&!Ae?Ee=1:Ee=ee>ce?1:-1}return q.current!=null&&(cancelAnimationFrame(q.current),q.current=null),T({opacity:0,x:Ee*56,scale:.94,blur:8,animate:!1}),q.current=requestAnimationFrame(()=>{q.current=requestAnimationFrame(()=>{T({opacity:1,x:0,scale:1,blur:0,animate:!0}),q.current=null})}),()=>{q.current!=null&&(cancelAnimationFrame(q.current),q.current=null)}},[e,ee,n.length]);const xt=A<=c+.001&&Math.abs(j.x)<.5&&Math.abs(j.y)<.5,We=s.useCallback((ce,ue,Ee)=>{C(Ie=>{const Ae=jr(ce,c,Q);if(Math.abs(Ae-Ie)<1e-4)return Ie;const Pe=Ae/Ie,Ge=Ae<Ie;return Ae<=c+.001?(W({x:0,y:0}),c):(W(Ze=>{let Qe=Ze;if(typeof ue=="number"&&typeof Ee=="number"&&te.current&&!Ge){const Et=te.current.getBoundingClientRect(),Ht=ue-Et.left-Et.width/2,Ut=Ee-Et.top-Et.height/2;Qe={x:Ht-(Ht-Ze.x)*Pe,y:Ut-(Ut-Ze.y)*Pe}}else if(Ge){Qe={x:Ze.x*Pe,y:Ze.y*Pe};const Et=Math.min(1,(Ie-Ae)/Math.max(.01,Ie-c));Qe={x:Qe.x*(1-Et*.65),y:Qe.y*(1-Et*.65)}}else Qe={x:Ze.x*Pe,y:Ze.y*Pe};return pe(Qe,Ae)}),Ae)})},[pe,c,Q]),Le=s.useCallback(()=>{We(A*d)},[We,A,d]),ke=s.useCallback(()=>{const ce=Math.max(c,A/d);if(ce<=c+.001){ie();return}C(ce),W({x:0,y:0})},[c,ie,A,d]);s.useEffect(()=>{if(!e)return;const ce=ue=>{if(ue.key==="Escape"&&m){ue.preventDefault(),r();return}ue.key==="ArrowLeft"&&se?(ue.preventDefault(),Se(ee-1)):ue.key==="ArrowRight"&&se?(ue.preventDefault(),Se(ee+1)):ue.key==="+"||ue.key==="="?(ue.preventDefault(),We(A*d)):ue.key==="-"||ue.key==="_"?(ue.preventDefault(),ke()):ue.key==="0"&&(ue.preventDefault(),ie())};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[We,m,se,r,e,ie,ee,A,Se,ke,d]);const et=ce=>{ce.preventDefault();const ue=ce.deltaY>0?1/d:d;We(A*ue,ce.clientX,ce.clientY)},me=ce=>{A<=c+.001||(ce.currentTarget.setPointerCapture(ce.pointerId),X(!0),P.current={pointerId:ce.pointerId,startX:ce.clientX,startY:ce.clientY,originX:j.x,originY:j.y})},J=ce=>{const ue=P.current;!ue||ue.pointerId!==ce.pointerId||W(pe({x:ue.originX+(ce.clientX-ue.startX),y:ue.originY+(ce.clientY-ue.startY)},A))},re=ce=>{var ue;((ue=P.current)==null?void 0:ue.pointerId)===ce.pointerId&&(P.current=null,X(!1))},be=ce=>{if(ce.stopPropagation(),A>c+.05){ie();return}We(Math.min(Q,3),ce.clientX,ce.clientY)},he=ce=>{if(ce.touches.length!==2)return;X(!0);const[ue,Ee]=[ce.touches[0],ce.touches[1]],Ie=Math.hypot(ue.clientX-Ee.clientX,ue.clientY-Ee.clientY);I.current={distance:Ie,scale:A}},Be=ce=>{if(ce.touches.length!==2||!I.current)return;ce.preventDefault();const[ue,Ee]=[ce.touches[0],ce.touches[1]],Ie=Math.hypot(ue.clientX-Ee.clientX,ue.clientY-Ee.clientY),Ae=(ue.clientX+Ee.clientX)/2,Pe=(ue.clientY+Ee.clientY)/2,Ge=I.current.scale*(Ie/Math.max(1,I.current.distance));We(Ge,Ae,Pe)},Te=()=>{I.current=null,X(!1)};if(!$||!_)return null;const He=Z.enabled,Fe=Z.animate?`transform ${ir}ms ${rd}`:"none";return nt.createPortal(t.jsxs("div",{className:"fixed inset-0",style:{zIndex:E},role:"dialog","aria-modal":"true","aria-label":h,children:[t.jsx("button",{type:"button","aria-label":"Cerrar",className:"absolute inset-0 border-0",style:{background:"color-mix(in srgb, var(--bg-sidebar, var(--primary)) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",opacity:y?1:0,transition:`opacity ${He?ir:bt}ms ${vt}`,cursor:"default",zIndex:0},onClick:()=>{u&&r()}}),t.jsx("div",{ref:te,className:"absolute inset-0 flex items-center justify-center",style:{zIndex:1,padding:de?"4.5rem 3.5rem 6.5rem":"4.5rem 3.5rem 2.5rem",opacity:He||y?1:0,transform:He||y?"translateY(0) scale(1)":"translateY(10px) scale(0.96)",transition:He?"none":`opacity ${bt}ms ${vt}, transform ${bt}ms ${vt}`},onClick:ce=>{ce.target===ce.currentTarget&&u&&r()},onWheel:et,children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{transform:Z.enabled?`translate3d(${Z.dx}px, ${Z.dy}px, 0) scale(${Z.scale})`:void 0,transformOrigin:"center center",transition:Z.enabled?Fe:void 0},children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{opacity:G.opacity,filter:G.blur?`blur(${G.blur}px)`:"blur(0px)",transform:`translate3d(${G.x}px, 0, 0) scale(${G.scale})`,transition:G.animate?[`opacity ${Ma}ms ${$a}`,`transform ${Ma}ms ${$a}`,`filter ${Ma}ms ${$a}`].join(", "):"none"},children:t.jsx("div",{ref:U,className:"pointer-events-auto relative max-h-full max-w-full touch-none select-none will-change-transform",style:{cursor:A>c+.001?"grab":"zoom-in",transform:`translate3d(${j.x}px, ${j.y}px, 0) scale(${A})`,transformOrigin:"center center",transition:ae?"none":`transform 220ms ${td}`},onClick:ce=>ce.stopPropagation(),onDoubleClick:be,onPointerDown:me,onPointerMove:J,onPointerUp:re,onPointerCancel:re,onTouchStart:he,onTouchMove:Be,onTouchEnd:Te,children:t.jsx("img",{src:_.src,alt:_.alt||"",draggable:!1,className:"block max-h-[min(78vh,820px)] max-w-[min(86vw,1100px)] object-contain",style:{display:"block",borderRadius:La,imageRendering:A>2.5?"pixelated":"auto"},onLoad:()=>{mt()}},_.src+String(ee))})})})}),t.jsxs("div",{className:"pointer-events-none absolute inset-0",style:{zIndex:2,opacity:y?1:0,transform:y?"translateY(0)":"translateY(-6px)",transition:`opacity ${He?ir:bt}ms ${vt}, transform ${He?ir:bt}ms ${vt}`},children:[t.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 flex items-center justify-between gap-3 px-4 pt-4",children:[t.jsx("div",{className:"pointer-events-auto flex items-center gap-2",children:f&&n.length>0?t.jsxs("span",{className:"rounded-full px-3 py-1.5 text-xs font-semibold tracking-wide",style:Ta,children:[ee+1," / ",n.length]}):null}),t.jsxs("div",{className:"pointer-events-auto flex items-center gap-2",children:[b?t.jsxs(t.Fragment,{children:[t.jsx(cr,{label:"Alejar",onClick:ke,disabled:A<=c+.001,children:t.jsx(z.HiMinus,{className:"h-5 w-5"})}),t.jsx(cr,{label:"Restablecer tamaño",onClick:ie,disabled:xt,children:t.jsx(z.HiArrowsPointingIn,{className:"h-5 w-5"})}),t.jsx(cr,{label:"Acercar",onClick:Le,disabled:A>=Q-.001,children:t.jsx(z.HiPlus,{className:"h-5 w-5"})})]}):null,t.jsx(cr,{label:"Cerrar",onClick:r,children:t.jsx(z.HiXMark,{className:"h-5 w-5"})})]})]}),se?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"pointer-events-auto absolute left-3 top-1/2",style:{opacity:y?1:0,transform:y?"translate(0, -50%)":"translate(-8px, -50%)",transition:`opacity ${bt}ms ${vt}, transform ${bt}ms ${vt}`},children:t.jsx(cr,{label:"Anterior",size:"lg",onClick:()=>Se(ee-1),disabled:!v&&ee<=0,children:t.jsx(z.HiChevronLeft,{className:"h-6 w-6"})})}),t.jsx("div",{className:"pointer-events-auto absolute right-3 top-1/2",style:{opacity:y?1:0,transform:y?"translate(0, -50%)":"translate(8px, -50%)",transition:`opacity ${bt}ms ${vt}, transform ${bt}ms ${vt}`},children:t.jsx(cr,{label:"Siguiente",size:"lg",onClick:()=>Se(ee+1),disabled:!v&&ee>=n.length-1,children:t.jsx(z.HiChevronRight,{className:"h-6 w-6"})})})]}):null,de?t.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex justify-center px-4 pb-4 pt-8",style:{background:"linear-gradient(to top, color-mix(in srgb, var(--bg-sidebar, var(--primary)) 72%, transparent), transparent)"},children:t.jsx("div",{className:"pointer-events-auto flex max-w-full items-end gap-2.5 overflow-x-auto rounded-2xl px-2 py-2",style:{background:"color-mix(in srgb, var(--bg-card) 55%, transparent)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",scrollbarWidth:"thin"},role:"tablist","aria-label":"Miniaturas",children:n.map((ce,ue)=>{const Ee=ue===ee;return t.jsx("button",{type:"button",role:"tab","aria-selected":Ee,"aria-label":ce.alt||`Imagen ${ue+1}`,onClick:Ie=>{Ie.stopPropagation(),Se(ue)},className:"relative shrink-0 overflow-hidden transition-opacity",style:{width:56,height:42,borderRadius:La,opacity:Ee?1:.42,transition:`opacity 180ms ${vt}`},children:t.jsx("img",{src:ce.src,alt:"",draggable:!1,className:"h-full w-full object-cover",style:{borderRadius:La}})},`${ce.src}-${ue}`)})})}):null]})]}),document.body)}function id({children:e,className:r,style:n,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c}){const[d,u]=s.useState(!1),[m,f]=s.useState(0),[b,v]=s.useState([]),[x,E]=s.useState(null),h=s.useCallback((M,y,w)=>{v(M),E(w??null),f(y),u(!0)},[]),$=s.useCallback(M=>{Rs(M,h)},[h]);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`[&_img]:cursor-zoom-in ${r??""}`,style:n,onClick:$,children:e}),t.jsx(to,{open:d,onClose:()=>u(!1),index:m,onIndexChange:f,slides:b,originRect:x,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c})]})}function ro(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function no(e,r){if(e.length!==r.length)return!1;const n=new Set(r);return e.every(a=>n.has(a))}function Aa(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function cd(e,r){if(!r)return!0;const n=Aa(r);return Aa(e.label).includes(n)||!!(e.sublabel&&Aa(e.sublabel).includes(n))}function dd({value:e,onChange:r,options:n,placeholder:a="Seleccionar…",disabled:o=!1,className:l="",style:i,height:c=40,padding:d="6px 10px",searchable:u=!0,minOptionsForSearch:m=6,maxVisibleValues:f=2,truncateSelectedValues:b=!0,emptyText:v="Sin resultados",clearLabel:x="Limpiar seleccion",pruneMissingValues:E=!0}){const[h,$]=s.useState(!1),[M,y]=s.useState(""),[w,k]=s.useState(0),[N,A]=s.useState(!1),[C,j]=s.useState({}),W=s.useRef(null),G=s.useRef(null),T=s.useRef(null),Z=s.useRef(null),H=u&&n.length>=m,ae=s.useMemo(()=>new Set(e),[e]),X=s.useMemo(()=>{const D=new Map;for(const ee of n)D.set(ee.value,ee);return D},[n]),V=s.useMemo(()=>{const D=[];for(const ee of e){const _=X.get(ee);_&&D.push(_)}return D},[X,e]),q=f==="all"?V.length:f,L=V.slice(0,q),oe=Math.max(0,V.length-L.length),B=s.useMemo(()=>{const D=M.trim();return!H||!D?n:n.filter(ee=>cd(ee,D))},[n,M,H]),F=s.useCallback(()=>{const D=W.current;if(!D)return;const ee=D.getBoundingClientRect(),_=H?304:244,se=window.innerHeight-ee.bottom,Q=se<_&&ee.top>se;j({position:"fixed",left:ee.left,top:Q?void 0:ee.bottom+4,bottom:Q?window.innerHeight-ee.top+4:void 0,width:Math.max(ee.width,240),zIndex:9999})},[H]),le=s.useCallback(D=>{no(e,D)||r(D)},[r,e]),g=s.useCallback(D=>{const ee=X.get(D);if(ee!=null&&ee.disabled)return;const _=ae.has(D)?e.filter(se=>se!==D):[...e,D];le(_)},[le,X,e,ae]),P=s.useCallback(()=>le([]),[le]),I=s.useCallback(()=>{$(!1),y(""),k(0)},[]);s.useEffect(()=>A(!0),[]);const te=s.useMemo(()=>n.map(D=>D.value).join("\0"),[n]);s.useEffect(()=>{if(!E||e.length===0||n.length===0)return;const D=new Set(n.map(_=>_.value)),ee=e.filter(_=>D.has(_));no(e,ee)||r(ee)},[te]),s.useEffect(()=>{if(!h)return;function D(ee){var se,Q;const _=ee.target;!((se=W.current)!=null&&se.contains(_))&&!((Q=G.current)!=null&&Q.contains(_))&&I()}return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[I,h]),s.useEffect(()=>{h&&(k(0),F(),H&&setTimeout(()=>{var D;return(D=T.current)==null?void 0:D.focus()},0))},[h,H,F]),s.useEffect(()=>{if(h)return window.addEventListener("resize",F),window.addEventListener("scroll",F,!0),()=>{window.removeEventListener("resize",F),window.removeEventListener("scroll",F,!0)}},[h,F]),s.useEffect(()=>{if(B.length===0){k(0);return}k(D=>Math.min(D,B.length-1))},[B.length]),s.useEffect(()=>{if(w<0||!Z.current)return;const D=Z.current.children[w];D==null||D.scrollIntoView({block:"nearest"})},[w]);function U(D){if(!o){if(!h){(D.key==="Enter"||D.key===" "||D.key==="ArrowDown")&&(D.preventDefault(),$(!0));return}if(D.key==="Escape"){D.preventDefault(),I();return}if(D.key==="ArrowDown"){if(D.preventDefault(),B.length===0)return;k(ee=>Math.min(ee+1,B.length-1));return}if(D.key==="ArrowUp"){D.preventDefault(),k(ee=>Math.max(ee-1,0));return}if(D.key==="Enter"&&B[w]&&!B[w].disabled){D.preventDefault(),g(B[w].value);return}D.key==="Backspace"&&!M&&e.length&&(D.preventDefault(),le(e.slice(0,-1)))}}const K=t.jsxs("div",{ref:G,className:"overflow-hidden rounded-xl shadow-xl",style:{...C,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[H&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(z.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:T,value:M,onChange:D=>{y(D.target.value),k(0)},onKeyDown:D=>{(D.key==="ArrowDown"||D.key==="ArrowUp"||D.key==="Enter"||D.key==="Escape")&&(D.stopPropagation(),U(D))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),M&&t.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:D=>{D.preventDefault(),y(""),k(0)},children:t.jsx(z.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),e.length>0&&t.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:[t.jsxs("span",{children:[V.length," seleccionados",e.length>V.length?` (${e.length-V.length} no disponibles)`:""]}),t.jsx("button",{type:"button",onMouseDown:D=>{D.preventDefault(),P()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:x})]}),t.jsxs("ul",{ref:Z,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:H?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[B.map((D,ee)=>{const _=ee===w,se=ae.has(D.value);return t.jsxs("li",{role:"option","aria-selected":se,onMouseDown:Q=>{Q.preventDefault(),!D.disabled&&g(D.value)},onMouseEnter:()=>!D.disabled&&k(ee),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:_?"var(--bg-hover)":se?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:D.disabled?"var(--text-muted)":"var(--text-main)",cursor:D.disabled?"not-allowed":"pointer",opacity:D.disabled?.58:1},children:[t.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:se?"var(--primary)":"var(--border)",background:se?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:se&&t.jsx(z.HiCheck,{className:"h-3 w-3"})}),D.color&&t.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:D.color}}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx("span",{className:"truncate",children:D.label}),D.sublabel&&t.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:D.sublabel})]}),D.badge&&t.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:D.badge})]},D.value)}),B.length===0&&t.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:v})]})]});return t.jsxs("div",{ref:W,className:`relative ${l||"w-full"}`,style:i,onKeyDown:U,children:[t.jsxs("button",{type:"button",disabled:o,onClick:()=>{o||(h?I():$(!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(d),background:"var(--bg-input)",color:V.length?"var(--text-main)":"var(--text-muted)",border:h?"1px solid var(--primary)":"1px solid var(--border)",opacity:o?.5:1,cursor:o?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":h,children:[t.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:L.length?t.jsxs(t.Fragment,{children:[L.map(D=>t.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${b?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[D.color&&t.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:D.color}}),t.jsx("span",{className:b?"truncate":"break-words",children:D.label}),t.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${D.label}`,onMouseDown:ee=>{ee.preventDefault(),ee.stopPropagation(),g(D.value)},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(z.HiXMark,{className:"h-3 w-3"})})]},D.value)),oe>0&&t.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]})]}):t.jsx("span",{className:"truncate",children:a})}),V.length?t.jsx("span",{role:"button",tabIndex:-1,"aria-label":x,onMouseDown:D=>{D.preventDefault(),D.stopPropagation(),P()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(z.HiXMark,{className:"h-3.5 w-3.5"})}):t.jsx(z.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:h?"rotate(180deg)":"rotate(0deg)"}})]}),h&&N&&nt.createPortal(K,document.body)]})}function ud({inputMode:e="decimal",...r}){return t.jsx(Ca,{...r,type:"number",inputMode:e})}function fd(e,r,n){const a=[],o=Math.max(2,e-n),l=Math.min(r-1,e+n);a.push(1),o>2&&a.push("...");for(let i=o;i<=l;i+=1)a.push(i);return l<r-1&&a.push("..."),r>1&&a.push(r),a}function bd({page:e,totalPages:r,onPageChange:n,disabled:a=!1,siblingCount:o=1,className:l=""}){const i=Math.max(1,r),c=Math.min(Math.max(1,e),i),d=fd(c,i,o);return t.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[t.jsx(je,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:a||c<=1,onClick:()=>n(c-1),children:t.jsx(z.HiChevronLeft,{className:"h-4 w-4"})}),d.map((u,m)=>u==="..."?t.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${m}`):t.jsx("button",{type:"button","aria-current":u===c?"page":void 0,disabled:a,onClick:()=>n(u),className:"flex h-8 min-w-8 items-center justify-center rounded-md border px-2 text-xs font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-50",style:{borderColor:u===c?"var(--primary)":"var(--border)",background:u===c?"var(--primary)":"var(--bg-card)",color:u===c?"var(--primary-fg)":"var(--text-secondary)"},children:u},u)),t.jsx(je,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:a||c>=i,onClick:()=>n(c+1),children:t.jsx(z.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 so(e){return e==null?"":String(e)}function wn(e){return e?e.startsWith("+")?e:`+${e}`:"+1"}function md(e){return typeof e=="number"?`${e}px`:e}function pd({autoComplete:e="tel",inputMode:r="tel",validate:n=!0,invalidMessage:a="Ingresa un telefono valido.",errorDisplay:o="tooltip",error:l,value:i,defaultValue:c,onChange:d,countryCode:u,defaultCountryCode:m="+1",onCountryCodeChange:f,allowedCountryCodes:b,countryCodeOptions:v,countryCodePlaceholder:x="Codigo",countryCodeClassName:E="",countryCodeWidth:h=84,onPhoneValueChange:$,label:M,containerClassName:y="",helperText:w,helperDisplay:k="inline",labelAction:N,className:A="",required:C,disabled:j,floatingLabel:W,showPasswordToggle:G,nativeValidation:T,errorTooltipLabel:Z="Error de validacion",...H}){var Q;const[ae,X]=s.useState(()=>so(c)),[V,q]=s.useState(()=>wn(m)),L=s.useMemo(()=>{const de=v??ao,Se=b==null?void 0:b.map(wn);return Se!=null&&Se.length?de.filter(ie=>Se.includes(ie.value)):de},[b,v]),oe=((Q=L[0])==null?void 0:Q.value)??"+1",B=L.some(de=>de.value===wn(u??V))?wn(u??V):oe,F=i!==void 0?so(i):ae,le=`${B} ${F}`.trim(),g=n&&F.length>0&&!Na(le)?a:void 0,P=l??g,I=!!P,te=I&&o!=="tooltip",U=I&&o!=="inline",K=!!w&&k==="tooltip"&&!te,D=I?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",ee=de=>{const Se=de.currentTarget.value;i===void 0&&X(Se),$==null||$(Se,{countryCode:B,nationalNumber:Se,fullNumber:`${B} ${Se}`.trim()}),d==null||d(de)},_=de=>{u===void 0&&q(de),f==null||f(de),$==null||$(F,{countryCode:de,nationalNumber:F,fullNumber:`${de} ${F}`.trim()})},se=U?t.jsx(zt,{as:"span",content:P,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:t.jsx("span",{tabIndex:0,role:"img","aria-label":Z,className:"flex h-full w-full items-center justify-center outline-none",children:t.jsx(Zs,{className:"h-[18px] w-[18px]"})})}):null;return t.jsxs("div",{className:`flex flex-col gap-2 ${y}`,children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[t.jsx("span",{children:M}),C&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),K?t.jsx(or,{content:w}):null,N&&t.jsx("span",{className:"ml-auto normal-case",children:N})]}),t.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${D}`,children:[t.jsx(jt,{value:B,onChange:_,options:L,placeholder:x,disabled:j,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${E}`,style:{width:md(h)},height:38,padding:"0 8px 0 10px"}),t.jsx("span",{className:"h-5 w-px shrink-0 bg-[var(--border)]"}),t.jsxs("span",{className:"relative min-w-0 flex-1 self-stretch",children:[t.jsx("input",{...H,value:i,defaultValue:c,type:"tel",inputMode:r,autoComplete:e,disabled:j,required:void 0,"aria-label":H["aria-label"]??(typeof M=="string"?M:void 0),"aria-invalid":I||H["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 ${U?"pr-10":""} ${A}`,onChange:ee}),se]})]}),t.jsx(lr,{error:te?P:void 0,helperText:w,helperDisplay:k})]})}function hd({value:e,onChange:r,options:n,name:a,label:o,orientation:l="vertical",disabled:i=!1,className:c="",optionClassName:d=""}){return t.jsxs("fieldset",{className:`min-w-0 ${c}`,disabled:i,children:[o&&t.jsx("legend",{className:"mb-2 text-xs font-semibold uppercase text-[var(--text-muted)]",children:o}),t.jsx("div",{className:l==="horizontal"?"flex flex-wrap gap-2":"flex flex-col gap-2",children:n.map(u=>{const m=u.value===e,f=i||u.disabled;return t.jsxs("label",{className:`inline-flex min-w-0 items-start gap-2 rounded-lg border px-2.5 py-1.5 transition-colors ${f?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${d}`,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:[t.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:[t.jsx("input",{type:"radio",name:a,value:u.value,checked:m,disabled:f,onChange:()=>r(u.value),className:"absolute inset-0 opacity-0"}),t.jsx("span",{className:`h-2 w-2 rounded-full transition ${m?"scale-100 opacity-100":"scale-50 opacity-0"}`,style:{background:"var(--primary)"}})]}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:u.label}),u.description&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:u.description})]})]},u.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>',Wr=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),lo=e=>e.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(r,n,a)=>`${n}${a.toLocaleUpperCase()}`),gd=e=>e.replace(/[<>]/g,"").toLowerCase(),vd=new Set(["p","br","div","span","b","strong","i","em","u","s","strike","ul","ol","li","h1","h2","h3","h4","blockquote","a","img","hr"]),yd=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,xd=e=>{const r=e.indexOf("<!--StartFragment-->"),n=e.indexOf("<!--EndFragment-->");if(r!==-1&&n!==-1&&n>r)return e.slice(r+20,n);const a=e.match(/<body[^>]*>([\s\S]*)<\/body>/i);return a?a[1]:e},kn=(e,r)=>r.test(e),wd=e=>kn(e,/font-weight\s*:\s*(bold|[6-9]00)/i),kd=e=>kn(e,/font-style\s*:\s*italic/i),Nd=e=>kn(e,/text-decoration(?:-line)?\s*:[^;]*underline/i),Sd=e=>kn(e,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),Nn=(e,r)=>{var a;if(!e.childNodes.length||e.childNodes.length===1&&((a=e.firstChild)==null?void 0:a.nodeType)===Node.ELEMENT_NODE&&e.firstChild.tagName.toLowerCase()===r)return;const n=e.ownerDocument.createElement(r);for(;e.firstChild;)n.appendChild(e.firstChild);e.appendChild(n)},Sn=e=>{const r=e.parentNode;if(!r){e.remove();return}for(;e.firstChild;)r.insertBefore(e.firstChild,e);r.removeChild(e)},Cd=e=>{const r=e.getAttribute("class")??"",n=e.getAttribute("style")??"";return/mso-list/i.test(n)||/MsoListParagraph/i.test(r)||/MsoList/i.test(r)},io=e=>{const r=e.getAttribute("style")??"",n=e.textContent??"";return/mso-level-number-format\s*:\s*(decimal|arabic|roman|alpha)/i.test(r)||/^\s*\d+[.)]\s/.test(n)||/^\s*[a-zA-Z][.)]\s/.test(n)?"ol":"ul"},Ed=e=>{const n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT).nextNode();if(!n||!n.textContent)return;const a=n.textContent.replace(yd,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");a!==n.textContent&&(n.textContent=a)},Md=e=>{const r=Array.from(e.querySelectorAll("span, font, p, div, li, h1, h2, h3, h4"));r.sort((n,a)=>a.querySelectorAll("*").length-n.querySelectorAll("*").length),r.forEach(n=>{const a=n.getAttribute("style")??"";a&&(wd(a)&&Nn(n,"strong"),kd(a)&&Nn(n,"em"),Nd(a)&&Nn(n,"u"),Sd(a)&&Nn(n,"s"))})},$d=e=>{const r=Array.from(e.querySelectorAll("p, div")).filter(Cd);if(!r.length)return;let n=0;for(;n<r.length;){const a=r[n],o=io(a),l=[a];let i=n+1;for(;i<r.length;){const u=r[i];if(io(u)!==o)break;let m=l[l.length-1].nextSibling;for(;m&&m.nodeType===Node.TEXT_NODE&&!(m.textContent??"").trim();)m=m.nextSibling;if(m!==u)break;l.push(u),i++}const c=a.parentNode;if(!c){n=i;continue}const d=a.ownerDocument.createElement(o);c.insertBefore(d,a),l.forEach(u=>{Ed(u);const m=u.ownerDocument.createElement("li");for(;u.firstChild;)m.appendChild(u.firstChild);d.appendChild(m),u.remove()}),n=i}},Td=e=>e==="h1"?"h2":e==="h4"||e==="h5"||e==="h6"?"h3":e==="div"?"p":e,Ld=e=>{const r=xd(e.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,"")),o=new DOMParser().parseFromString(`<!DOCTYPE html><html><body>${r}</body></html>`,"text/html").body;o.querySelectorAll("script, style, meta, link, xml, title, head, iframe, object, embed, form, input, button, textarea, select, noscript").forEach(i=>i.remove()),Md(o),$d(o);const l=i=>{const c=Array.from(i.childNodes);if(i.nodeType===Node.ELEMENT_NODE){const d=i,u=d.tagName.toLowerCase();if(u==="html"||u==="body"){c.forEach(l);return}if(u==="font"){Sn(d),c.forEach(l);return}if(!vd.has(u)){Sn(d),c.forEach(l);return}const m=Td(u);if(m!==u){const f=d.ownerDocument.createElement(m);for(;d.firstChild;)f.appendChild(d.firstChild);d.replaceWith(f),l(f);return}if(Array.from(d.attributes).forEach(f=>{const b=f.name.toLowerCase(),v=f.value;if(b.startsWith("on")||b==="style"||b==="class"){d.removeAttribute(f.name);return}if(b==="lang"||b.startsWith("data-")||b.startsWith("mso-")){d.removeAttribute(f.name);return}if((b==="href"||b==="src")&&/^\s*javascript:/i.test(v)){d.removeAttribute(f.name);return}u!=="a"&&u!=="img"&&b!=="href"&&b!=="src"&&b!=="alt"&&(["href","src","alt","target","rel"].includes(b)||d.removeAttribute(f.name))}),u==="a"){const f=d.getAttribute("href");if(!f||/^\s*#/.test(f)&&f.length<2){Sn(d),c.forEach(l);return}d.setAttribute("target","_blank"),d.setAttribute("rel","noopener noreferrer"),d.classList.add("rich-link")}if(u==="img"){const f=d.getAttribute("src")??"";if(!f||/^\s*javascript:/i.test(f)||/^file:/i.test(f)||/scheme\s*=\s*["']?file/i.test(f)){d.remove();return}d.classList.add("rich-img"),Array.from(d.attributes).forEach(b=>{["src","alt","class"].includes(b.name.toLowerCase())||d.removeAttribute(b.name)})}if(u==="span"){Sn(d),c.forEach(l);return}}c.forEach(l)};return l(o),o.querySelectorAll("p, h2, h3, li").forEach(i=>{const c=(i.textContent??"").replace(/[\u00a0\s]+/g,"").trim(),d=i.querySelector("img, hr"),u=!c&&!d&&Array.from(i.childNodes).every(m=>m.nodeType===Node.TEXT_NODE||m.nodeType===Node.ELEMENT_NODE&&m.tagName.toLowerCase()==="br");(!c&&!d||u)&&i.remove()}),o.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()}}),o.innerHTML.replace(/<!--[\s\S]*?-->/g,"").replace(/ /gi," ").replace(/(<br\s*\/?>\s*){3,}/gi,"<br><br>").replace(/<p>(?:\s|<br\s*\/?>)*<\/p>/gi,"").trim()},Da=e=>Wr(e).replace(/\r\n?/g,`
|
|
25
|
-
`).split(/\n{2,}/).map(r=>`<p>${r.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),Ad=e=>new RegExp("\\p{L}","u").test(e),Ia=(e,r)=>{const n=e.trim();return!n||!Ad(n)?!1:r==="uppercase"?n===n.toLocaleUpperCase():r==="lowercase"?n===n.toLocaleLowerCase():n===lo(n)},co=e=>{const r=a=>{var o,l;if(!a.closest(".rich-img-wrap")){const i=document.createElement("span");i.className="rich-img-wrap",i.contentEditable="false",(o=a.parentNode)==null||o.insertBefore(i,a),i.appendChild(a),i.insertAdjacentHTML("beforeend",oo())}(l=a.closest(".rich-img-wrap"))==null||l.classList.add("rich-img-broken")};e.querySelectorAll("img").forEach(a=>{if(!a.complete||a.naturalWidth===0){a.addEventListener("error",()=>r(a),{once:!0}),a.addEventListener("load",()=>{a.naturalWidth===0&&r(a)},{once:!0});const o=a.src;a.src="",a.src=o}});const n=a=>{const o=a.target;o.tagName==="IMG"&&r(o)};return e.addEventListener("error",n,!0),()=>e.removeEventListener("error",n,!0)};function uo({value:e,onChange:r,placeholder:n="Escribe algo...",minHeight:a="80px",instanceId:o}){const l=s.useId(),i=o||l,c=s.useCallback(()=>document,[]),d=s.useRef(null),u=s.useRef(null),m=s.useRef(new Map),f=s.useRef(null),b=s.useRef(!1),v=s.useRef(e??""),x=s.useRef(r),E=s.useRef(!1),[h,$]=s.useState(()=>!e||e.trim()===""),[M,y]=s.useState(new Set),[w,k]=s.useState(null),[N,A]=s.useState(""),[C,j]=s.useState(""),[W,G]=s.useState(""),[T,Z]=s.useState(""),[H,ae]=s.useState(!1),X=s.useCallback(()=>b.current?u.current:d.current,[]);s.useEffect(()=>{x.current=r},[r]);const V=s.useCallback(()=>{const J=window.getSelection(),re=X();if(!J||!re||J.rangeCount===0||J.isCollapsed)return"";const be=J.getRangeAt(0);return!re.contains(be.startContainer)||!re.contains(be.endContainer)?"":J.toString()},[X]);s.useEffect(()=>{const J=e??"";if(E.current&&J===v.current){E.current=!1,$(!J||J.trim()==="");return}E.current=!1,v.current=J;const re=[d.current,u.current].filter(he=>!!he);re.forEach(he=>{he.innerHTML!==J&&(he.innerHTML=J)}),$(!J||J.trim()==="");const be=re.map(he=>co(he));return()=>be.forEach(he=>he())},[e]),s.useEffect(()=>{var he,Be;b.current=H;let J,re=0,be;if(H){const Te=d.current;Te&&(v.current=Te.innerHTML);const He=()=>{var ce;const Fe=u.current;if(!Fe){re=requestAnimationFrame(He);return}Fe.innerHTML!==v.current&&(Fe.innerHTML=v.current),J=co(Fe),$(((ce=Fe.textContent)==null?void 0:ce.trim())===""),be=setTimeout(()=>Fe.focus(),60)};re=requestAnimationFrame(He)}else{const Te=u.current,He=d.current,Fe=(Te==null?void 0:Te.innerHTML)??v.current,ce=v.current;v.current=Fe,He&&He.innerHTML!==Fe&&(He.innerHTML=Fe),Fe!==ce&&x.current(Fe),$(((Be=(he=Te??He)==null?void 0:he.textContent)==null?void 0:Be.trim())==="")}return()=>{re&&cancelAnimationFrame(re),be&&clearTimeout(be),J==null||J()}},[H]);const q=s.useCallback(()=>{const J=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],re=new Set;J.forEach(he=>{try{c().queryCommandState(he)&&re.add(he)}catch{return}});try{const he=gd(c().queryCommandValue("formatBlock"));he&&re.add(`formatBlock:${he}`)}catch{}const be=V();Ia(be,"uppercase")&&re.add("__upper"),Ia(be,"lowercase")&&re.add("__lower"),Ia(be,"capitalize")&&re.add("__cap"),y(re)},[V,c]),L=()=>{var re;const J=X();J&&(v.current=J.innerHTML,E.current=!0,x.current(v.current),$(((re=J.textContent)==null?void 0:re.trim())===""))},oe=J=>{if(!J){const re=d.current;re&&(v.current=re.innerHTML)}ae(!J)},B=(J,re)=>{var be;(be=X())==null||be.focus(),c().execCommand(J,!1,re),L(),q()},F=J=>{B("formatBlock",J)},le=()=>{var J;(J=X())==null||J.focus(),c().execCommand("insertHTML",!1,"<hr><p><br></p>"),L(),q()},g=()=>{const J=window.getSelection();J&&J.rangeCount>0&&(f.current=J.getRangeAt(0).cloneRange())},P=()=>{const J=window.getSelection();J&&f.current&&(J.removeAllRanges(),J.addRange(f.current))},I=J=>{if(g(),J==="link"){const re=window.getSelection();j(re&&!re.isCollapsed?re.toString():""),A("")}J==="image"&&(G(""),Z("")),k(J)},te=()=>{var he;if(!N.trim())return;P(),(he=X())==null||he.focus();const J=window.getSelection(),be=(J&&!J.isCollapsed?J.toString():"")||C.trim()||N.trim();c().execCommand("insertHTML",!1,`<a href="${Wr(N.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${Wr(be)}</a>`),L(),k(null)},U=(J,re="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${Wr(J)}" alt="${Wr(re)}" class="rich-img" />${oo()}</span>`,K=()=>{var J;W.trim()&&(P(),(J=X())==null||J.focus(),c().execCommand("insertHTML",!1,U(W.trim(),T.trim())),L(),k(null))},D=(J,re=1200,be=1200,he=.72)=>new Promise((Be,Te)=>{const He=new FileReader;He.onerror=Te,He.onload=Fe=>{var Ee;const ce=(Ee=Fe.target)==null?void 0:Ee.result,ue=new Image;ue.onerror=Te,ue.onload=()=>{let{width:Ie,height:Ae}=ue;if(Ie>re||Ae>be){const Ze=Math.min(re/Ie,be/Ae);Ie=Math.round(Ie*Ze),Ae=Math.round(Ae*Ze)}const Pe=document.createElement("canvas");Pe.width=Ie,Pe.height=Ae;const Ge=Pe.getContext("2d");if(!Ge){Be(ce);return}Ge.drawImage(ue,0,0,Ie,Ae),Be(Pe.toDataURL("image/jpeg",he))},ue.src=ce},He.readAsDataURL(J)}),ee=J=>{J.focus();const re=window.getSelection();if(!re||re.rangeCount===0||!J.contains(re.anchorNode)){const be=document.createRange();be.selectNodeContents(J),be.collapse(!1),re==null||re.removeAllRanges(),re==null||re.addRange(be)}},_=s.useRef(()=>{});_.current=J=>{const re=X();re&&(ee(re),c().execCommand("insertHTML",!1,J),re.querySelectorAll("p").forEach(be=>{!(be.textContent??"").replace(/[\u00a0\s]+/g,"")&&!be.querySelector("img, hr")&&be.remove()}),L(),q())};const se=s.useRef(D);se.current=D;const Q=s.useRef(U);Q.current=U;const de=s.useCallback(J=>{if(!J||m.current.has(J))return;const re=be=>{const he=be.clipboardData;if(!he)return;const Be=he.getData("text/html"),Te=he.getData("text/plain");if(Be||Te){be.preventDefault(),be.stopPropagation();try{const ue=Be?Ld(Be):Da(Te);if(!ue){Te&&_.current(Da(Te));return}_.current(ue)}catch{Te&&_.current(Da(Te))}return}const Fe=Array.from(he.items).find(ue=>ue.type.startsWith("image/"));if(!Fe)return;be.preventDefault(),be.stopPropagation();const ce=Fe.getAsFile();ce&&se.current(ce).then(ue=>{_.current(Q.current(ue,"imagen"))})};J.addEventListener("paste",re,!0),m.current.set(J,()=>{J.removeEventListener("paste",re,!0),m.current.delete(J)})},[]),Se=s.useCallback(J=>{var be;const re=d.current;re&&re!==J&&((be=m.current.get(re))==null||be()),d.current=J,J&&de(J)},[de]),ie=s.useCallback(J=>{var be;const re=u.current;re&&re!==J&&((be=m.current.get(re))==null||be()),u.current=J,J&&de(J)},[de]);s.useEffect(()=>{const J=m.current;return()=>{J.forEach(re=>re()),J.clear()}},[]);const pe=J=>{const re=window.getSelection(),be=X();if(!re||!be||re.rangeCount===0||re.isCollapsed)return;const he=re.getRangeAt(0);if(!be.contains(he.startContainer)||!be.contains(he.endContainer))return;const Be=he.toString();if(!Be)return;let Te=Be;J==="uppercase"?Te=Be.toLocaleUpperCase():J==="lowercase"?Te=Be.toLocaleLowerCase():Te=lo(Be),he.deleteContents();const He=document.createTextNode(Te);he.insertNode(He);const Fe=document.createRange();Fe.setStart(He,0),Fe.setEnd(He,Te.length),re.removeAllRanges(),re.addRange(Fe),f.current=Fe.cloneRange(),L(),q()},Ce=()=>{g(),q()},De=()=>{L(),q()},mt=()=>{requestAnimationFrame(()=>{var J;(J=X())==null||J.focus()})},xt=J=>{var re,be;if((J.metaKey||J.ctrlKey)&&J.key==="Enter"){if(J.preventDefault(),J.stopPropagation(),J.repeat)return;(re=X())==null||re.focus(),c().execCommand("insertLineBreak",!1)||c().execCommand("insertHTML",!1,"<br>"),L(),q();return}if(J.key==="Tab"){J.preventDefault(),(be=X())==null||be.focus(),c().execCommand("insertText",!1," "),L(),q();return}if(J.key==="Escape"){if(w){k(null);return}if(b.current){ae(!1);return}}w||(J.ctrlKey||J.metaKey)&&(J.key==="b"&&(J.preventDefault(),B("bold")),J.key==="i"&&(J.preventDefault(),B("italic")),J.key==="u"&&(J.preventDefault(),B("underline")),J.key==="k"&&(J.preventDefault(),I("link")))},We=()=>t.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),Le=(J,re,be,he,Be)=>{const Te=Be??(M.has(be)||be==="__link"&&w==="link"||be==="__img"&&w==="image");return t.jsx("button",{type:"button",title:re,tabIndex:-1,onFocus:mt,onMouseDown:He=>{He.preventDefault(),he?he():B(be)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:Te?"var(--primary)":"var(--text-secondary)",background:Te?"rgba(59,130,246,0.12)":"transparent"},children:J},be)},ke=J=>{const re=J.target;if(re.closest("[data-action='delete-img']")){J.preventDefault();const be=re.closest(".rich-img-wrap");be&&(be.remove(),L())}},et=J=>t.jsxs(t.Fragment,{children:[w==="link"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:J},children:[t.jsx("input",{autoFocus:!0,type:"url",value:N,onChange:re=>A(re.target.value),onKeyDown:re=>{re.key==="Enter"&&(re.preventDefault(),te()),re.key==="Escape"&&k(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)"}}),t.jsx("input",{type:"text",value:C,onChange:re=>j(re.target.value),onKeyDown:re=>{re.key==="Enter"&&(re.preventDefault(),te()),re.key==="Escape"&&k(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)"}}),t.jsx("button",{type:"button",onClick:te,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>k(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),w==="image"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:J},children:[t.jsx("input",{autoFocus:!0,type:"url",value:W,onChange:re=>G(re.target.value),onKeyDown:re=>{re.key==="Enter"&&(re.preventDefault(),K()),re.key==="Escape"&&k(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)"}}),t.jsx("input",{type:"text",value:T,onChange:re=>Z(re.target.value),onKeyDown:re=>{re.key==="Enter"&&(re.preventDefault(),K()),re.key==="Escape"&&k(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)"}}),t.jsx("button",{type:"button",onClick:K,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>k(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),me=(J,re)=>t.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:re},children:[Le(t.jsx(z.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),Le(t.jsx(z.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),We(),Le(t.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>F("p"),M.has("formatBlock:p")||M.has("formatBlock:div")),Le(t.jsx(z.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>F("h2"),M.has("formatBlock:h2")),Le(t.jsx(z.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>F("h3"),M.has("formatBlock:h3")),Le(t.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>F("blockquote"),M.has("formatBlock:blockquote")),We(),Le(t.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),Le(t.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),Le(t.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),Le(t.jsx("s",{children:"S"}),"Tachado","strikeThrough"),We(),Le(t.jsx(z.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),Le(t.jsx(z.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),Le(t.jsx(z.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),Le(t.jsx(z.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),We(),Le(t.jsx(z.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),Le(t.jsx(z.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),Le(t.jsx(z.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),Le(t.jsx(z.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),We(),Le(t.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>pe("uppercase")),Le(t.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>pe("lowercase")),Le(t.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>pe("capitalize")),We(),Le(t.jsx(z.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>I("link")),Le(t.jsx(z.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),Le(t.jsx(z.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>I("image")),Le(t.jsx(z.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",le),We(),Le(t.jsx(z.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),Le(t.jsx(z.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>F("p")),We(),t.jsx("button",{type:"button",title:J?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:mt,onMouseDown:be=>{be.preventDefault(),oe(J)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:J?t.jsx(z.HiArrowsPointingIn,{className:"h-4 w-4"}):t.jsx(z.HiArrowsPointingOut,{className:"h-4 w-4"})})]});return t.jsxs(t.Fragment,{children:[t.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:[t.jsx("div",{ref:Se,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:De,onKeyDown:xt,onKeyUp:Ce,onSelect:Ce,onMouseUp:Ce,onMouseDown:ke,"data-placeholder":n,className:`rich-editor px-3 py-2 text-sm focus:outline-none${h?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:a,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),et("var(--bg-input)"),me(!1,"var(--bg-input)")]}),t.jsxs(ba,{open:H,onClose:()=>ae(!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:[t.jsx("div",{ref:ie,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:De,onKeyDown:xt,onKeyUp:Ce,onSelect:Ce,onMouseUp:Ce,onMouseDown:ke,"data-placeholder":n,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${h?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),et("var(--bg-input)"),me(!0,"var(--bg-input)")]})]})}const fo="[a-zA-Z0-9._@-]+",Oa=new RegExp(`@(${fo})`,"g"),Dd=/[a-zA-Z0-9._@-]/,qr=new Set([" ",`
|
|
26
|
-
`," ","\r"," ","(","[","{",".",",",";",":","!","?","¿","¡",")","]","}",'"',"'","«","»","/","\\","|","-","—","–"]);function
|
|
23
|
+
</body></html>`,be=window.open("","_blank");be&&(be.document.write(ne),be.document.close())}const wa=()=>!Qe||!dn?null:dt.createPortal(t.jsxs("div",{ref:yo,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Nb,position:"fixed",zIndex:9999,minWidth:170,borderColor:"var(--border)",background:"var(--bg-card)"},children:[t.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:()=>{Rb(),oa(!1)},children:[t.jsx(q.HiTableCells,{className:"h-4 w-4 shrink-0 text-emerald-500"}),"Descargar CSV / Excel"]}),t.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:()=>{em(),oa(!1)},children:[t.jsx(q.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),Na=()=>{const p=X&&De.trim().length>0,E=ge!=null&&ge.length?ge:p?[{key:"bql",label:"BQL",value:De}]:[],ee=ie.filter(F=>{const ne=F.trim();return ne?!new Set(Ie.split(`
|
|
24
|
+
`).map(ye=>ye.trim()).filter(Boolean)).has(ne):!1}).slice(0,8);return!ae&&wo===0&&!X&&!Qe?null:t.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:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[wo>0&&t.jsxs("button",{type:"button",onClick:Hb,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:[t.jsx(q.HiXMark,{className:"h-3.5 w-3.5"}),wo," filtros"]}),X&&t.jsxs("div",{ref:go,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>{if(We){ht(!1);return}ba(),ht(!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:We?"var(--primary)":p?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:We||p?"var(--primary)":"var(--border)",color:We?"var(--primary-fg)":"var(--primary)"},"aria-expanded":We,title:"Abrir filtros BQL",children:[t.jsx(q.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",p&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),We?t.jsx(q.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(q.HiChevronDown,{className:"h-3.5 w-3.5"})]}),t.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:te}),E.length>0&&t.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[E.slice(0,3).map(F=>t.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:[t.jsxs("span",{className:"text-[var(--text-muted)]",children:[F.label,":"]}),t.jsx("span",{className:"truncate",children:F.value})]},F.key)),E.length>3&&t.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",E.length-3]})]}),p&&t.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:li,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:t.jsx(q.HiXMark,{className:"h-4 w-4"})}),We&&dt.createPortal(t.jsxs("div",{ref:Kl,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...vb,background:"var(--bg-card)",border:"1px solid color-mix(in srgb, var(--primary) 35%, var(--border))"},children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[ce.map(F=>t.jsxs("button",{type:"button",onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),fa(F.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:[F.icon,F.label]},F.label)),he.length>0&&t.jsxs("button",{type:"button",onClick:()=>gt(F=>!F),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":zt,children:[t.jsx(q.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),Qt.length>0&&t.jsxs("button",{type:"button",onClick:()=>Wt(F=>!F),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":lr,children:[t.jsx(q.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]})]}),t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-input)",border:`1.5px solid ${Te?"var(--danger)":p?"var(--primary)":"var(--border)"}`},children:[t.jsx("textarea",{ref:vo,value:Ie,rows:3,onChange:F=>ko(F.target.value,F.target),onKeyDown:F=>{F.key==="Enter"&&!F.shiftKey&&(F.preventDefault(),si(Ie)),F.key==="Escape"&&ht(!1)},placeholder:P,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"}}),ee.length>0&&t.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:ee.map(F=>t.jsx("button",{type:"button",onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),fa(F)},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:F},F))})]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"min-w-0 text-xs",style:{color:Te?"var(--danger)":"var(--text-muted)"},children:Te??(p?`${E.length||1} filtro${(E.length||1)===1?"":"s"} activo${(E.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),E.map(F=>t.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:[t.jsxs("span",{className:"text-[var(--text-muted)]",children:[F.label,":"]}),t.jsx("span",{className:"truncate",children:F.value})]},F.key))]}),lr&&Qt.length>0&&t.jsxs("div",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-input)]",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-3 py-2",children:[t.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-semibold text-[var(--text-secondary)]",children:[t.jsx(q.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),t.jsxs("button",{type:"button",onClick:()=>{Or([]),Wt(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[t.jsx(q.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),Qt.map(F=>t.jsxs("div",{className:"group flex items-center gap-2 border-b border-[var(--border)] px-3 py-2 last:border-b-0",children:[t.jsx("button",{type:"button",onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),fa(F)},className:"min-w-0 flex-1 text-left",children:t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:F})}),t.jsx("button",{type:"button",onClick:()=>Or(ne=>ne.filter(be=>be!==F)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:t.jsx(q.HiXMark,{className:"h-3.5 w-3.5"})})]},F))]}),zt&&he.length>0&&t.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:he.map(F=>t.jsxs("button",{type:"button",onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),fa(F.bql),gt(!1)},className:"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-2 text-left transition-colors hover:border-[var(--primary)]",children:[t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:F.bql}),F.description&&t.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:F.description})]},F.bql))}),t.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] pt-3",children:[p&&t.jsxs("button",{type:"button",onClick:li,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:[t.jsx(q.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),t.jsxs("button",{type:"button",onClick:()=>si(Ie),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:[t.jsx(q.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),Qe&&t.jsx("button",{ref:sa,type:"button","aria-haspopup":"menu","aria-expanded":dn,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var ne;const F=(ne=sa.current)==null?void 0:ne.getBoundingClientRect();F&&kb({top:F.bottom+4,right:window.innerWidth-F.right}),oa(be=>!be)},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)] ${dn?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(q.HiArrowDownTray,{className:"h-4 w-4"})}),ae&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":tt&&Ke==="visibility","aria-label":G,title:G,onClick:F=>ci(F,"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)] ${tt&&Ke==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(q.HiCog6Tooth,{className:"h-4 w-4"})})]})},Ni=()=>{if(!Kb)return null;const p=$c(it,Lo);return t.jsxs("div",{"aria-busy":a,className:`grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 rounded-b-xl border-t text-xs select-none ${B?"px-2 py-0.5":"px-3 py-1"}`,style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:br===0?"0 filas":`${Gb}–${Zb} de ${br}`}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),t.jsx(ar,{value:String(Ft),onChange:E=>Qb(Number(E)),options:Eo.map(E=>({value:String(E),label:String(E)})),placeholder:"Filas",searchable:!1,disabled:a,height:K,padding:Z,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:U}})]})]}),t.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[t.jsx("button",{disabled:a||it<=1,onClick:()=>Do(it-1),onMouseEnter:E=>{E.currentTarget.disabled||(E.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",E.currentTarget.style.color="var(--primary)")},onMouseLeave:E=>{E.currentTarget.style.background="transparent",E.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:t.jsx(q.HiChevronLeft,{className:"h-3.5 w-3.5"})}),p.map((E,ee)=>E==="..."?t.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${ee}`):t.jsx("button",{disabled:a,onClick:()=>Do(E),onMouseEnter:F=>{F.currentTarget.disabled||E===it||(F.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",F.currentTarget.style.color="var(--primary)")},onMouseLeave:F=>{F.currentTarget.style.background=E===it?"var(--primary)":"transparent",F.currentTarget.style.color=E===it?"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:E===it?"var(--primary)":"transparent",color:E===it?"var(--primary-fg)":"var(--text-muted)"},children:E},E)),t.jsx("button",{disabled:a||it>=Lo,onClick:()=>Do(it+1),onMouseEnter:E=>{E.currentTarget.disabled||(E.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",E.currentTarget.style.color="var(--primary)")},onMouseLeave:E=>{E.currentTarget.style.background="transparent",E.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:t.jsx(q.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),t.jsx("div",{"aria-hidden":"true"})]})},tm=()=>t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ha},children:[ya(),wa(),Na(),t.jsx("div",{ref:Jt,className:"min-w-0 max-w-full overflow-hidden",children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:bn,minWidth:ga},children:[t.jsx("div",{role:"rowgroup",style:N?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:va()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,s)}).map((p,E)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:zr,borderBottom:`1px solid ${He}`},children:[Tt&&t.jsx("div",{role:"cell",className:`${B?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${He}`,borderRight:`1px solid ${He}`}},"select-cell"),Ct.map((ee,F)=>t.jsx("div",{role:"cell",className:B?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${He}`,borderRight:`1px solid ${He}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${Jl(E,F)}%`,minWidth:32}})},ee.key))]},E))})]})})]}),Oo="min-w-0 max-w-full overflow-hidden";return re&<&&!ze?t.jsx(gn,{rows:s,columns:Math.max(4,Ct.length||7)}):!a&&r.length===0&&!xo?tm():a&&r.length===0?t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ha},children:[ya(),wa(),Na(),t.jsx("div",{ref:Jt,className:Oo,children:t.jsx(Bo.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:ei,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:bn,minWidth:ga},children:[t.jsx("div",{role:"rowgroup",style:N?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:va()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:s}).map((p,E)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:zr,borderBottom:`1px solid ${He}`},children:[Tt&&t.jsx("div",{role:"cell",className:`${B?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${He}`,borderRight:`1px solid ${He}`}},"select-cell"),Ct.map((ee,F)=>{const ne=ma[ee.key],be=ne!==void 0,ye=ee.key===Ao;return t.jsx("div",{role:"cell","data-dt-column-key":ee.key,className:B?"px-2 py-1.5":"px-3 py-2",style:be?{position:"sticky",left:ne,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:ye?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${He}`:`inset 0 -1px 0 ${He}`,borderRight:`1px solid ${He}`}:{borderBottom:`1px solid ${He}`,borderRight:`1px solid ${He}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${Jl(E,F)}%`,minWidth:32}})},ee.key)})]},E))})]})})}),Ni()]}):!a&&r.length===0?t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ha},children:[ya(),wa(),Na(),t.jsx("div",{ref:Jt,className:Oo,children:t.jsx("div",{role:"table",className:"text-sm",style:{width:bn,minWidth:ga},children:t.jsx("div",{role:"rowgroup",style:N?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:va()})})}),t.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:He,background:"linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 58%, transparent), var(--bg-card))"},children:[t.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??t.jsx(q.HiMagnifyingGlass,{className:"h-5 w-5"})}),t.jsx("p",{className:"max-w-sm text-sm font-medium",style:{color:"var(--text-main)"},children:i}),t.jsx("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Ajusta la busqueda o cambia los filtros para ver mas informacion."})]})]}):t.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:ha},children:[ya(),wa(),Na(),t.jsx("div",{ref:Jt,className:Oo,children:t.jsx(Bo.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:ei,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:bn,minWidth:ga},children:[t.jsx("div",{role:"rowgroup",style:N?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:va()}),t.jsx("div",{role:"rowgroup",children:mi.map((p,E)=>{const ee=n(p),F=yi(w==null?void 0:w(p)),ne=E>0?yi(w==null?void 0:w(mi[E-1])):null,be=F&&F.key!==(ne==null?void 0:ne.key),ye=Tt&&k.has(ee),Ae=Tt&&(!M||M(p)),Re=_r?(m==null?void 0:m(p))??!0:!1,Xe=Re&&fi.has(ee),vt=!!d||v&&Re,Je=ye&&y?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":E%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return t.jsxs(o.Fragment,{children:[be&&t.jsx("div",{role:"row",className:`grid ${F.className??""}`,style:{gridTemplateColumns:zr},children:t.jsx("div",{role:"cell",className:B?"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 ${He}`,borderRight:`1px solid ${He}`},children:t.jsx("div",{className:"flex min-w-0 items-center justify-between gap-3",children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"truncate text-xs font-semibold uppercase tracking-wider text-[var(--text-main)]",children:F.label}),F.description&&t.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:F.description})]})})})}),t.jsxs("div",{role:"row",onClick:vt?ve=>{const Ee=ve.target;if(!(Ee!=null&&Ee.closest('[data-dt-disable-row-click="true"]'))){if(v&&Re){pi(ee);return}d==null||d(p)}}:void 0,className:`grid transition-colors ${vt?"cursor-pointer":""} ${x?x(p):""}`,style:{gridTemplateColumns:zr,"--dt-row-bg":Je,"--dt-sticky-bg":Je,background:"var(--dt-row-bg)",borderBottom:`1px solid ${He}`},onMouseEnter:ve=>{ye||(ve.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),ve.currentTarget.style.setProperty("--dt-sticky-bg",Jb))},onMouseLeave:ve=>{ve.currentTarget.style.setProperty("--dt-row-bg",Je),ve.currentTarget.style.setProperty("--dt-sticky-bg",Je)},children:[_r&&t.jsx("div",{role:"cell",className:`${B?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${He}`,borderRight:`1px solid ${He}`},"data-dt-disable-row-click":"true",children:Re&&t.jsx("button",{type:"button","aria-label":Xe?"Contraer fila":"Desplegar fila","aria-expanded":Xe,onClick:ve=>{ve.stopPropagation(),pi(ee)},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:Xe?t.jsx(q.HiChevronDown,{className:"h-4 w-4"}):t.jsx(q.HiChevronRight,{className:"h-4 w-4"})})}),Tt&&t.jsx("div",{role:"cell",className:`${B?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:To?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${He}`}:{borderBottom:`1px solid ${He}`,borderRight:`1px solid ${He}`},onClick:ve=>{ve.stopPropagation(),Ae&&h(ee)},children:t.jsx(vn,{size:"sm",checked:ye,disabled:!Ae,"aria-label":Ae?"Seleccionar fila":"Fila no seleccionable",containerClassName:"items-center",className:Ae?"cursor-pointer":"cursor-not-allowed opacity-50",onClick:ve=>ve.stopPropagation(),onChange:()=>{Ae&&h(ee)}})}),Ct.map(ve=>{const Ee=ma[ve.key],ke=Ee!==void 0,we=ve.key===Ao,Ne=or(ve);return t.jsx("div",{role:"cell","data-dt-column-key":ve.key,"data-dt-disable-row-click":ve.disableRowClick||Ne?"true":void 0,className:`${Ne?"px-2 py-1.5 justify-center text-center":`${B?"px-2 py-1.5":"px-3 py-2"} ${hi(ve.align)}`} flex min-w-0 items-center ${kc} ${ve.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...ke?{position:"sticky",left:Ee,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:we?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${He}`:`inset 0 -1px 0 ${He}`,borderRight:`1px solid ${He}`}:{borderBottom:`1px solid ${He}`,borderRight:`1px solid ${He}`}},children:t.jsx(rs,{children:t.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:ve.cell(p)})})},ve.key)})]}),Xe&&u&&t.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:zr},children:t.jsx("div",{role:"cell",className:B?"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 ${He}`},children:u(p)})})]},ee)})})]})})}),Ni()]})}const Dc={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 Ic(e,r){if(r.minLength!==void 0&&e.length<r.minLength)return r.message??`Mínimo ${r.minLength} caracteres`;if(r.maxLength!==void 0&&e.length>r.maxLength)return r.message??`Máximo ${r.maxLength} caracteres`;if(!e)return null;if(r.preset){const n=Dc[r.preset];if(!n.pattern.test(e))return r.message??n.message}return r.pattern&&!r.pattern.test(e)?r.message??"Formato inválido":null}const Oc=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function Hc({initialValue:e,type:r,mask:n,onCommit:a,onCancel:s}){const[l,i]=o.useState(e),c=o.useRef(null),d=(n==null?void 0:n.preset)==="date",u=d?"date":r==="number"?"number":"text";return o.useEffect(()=>{var m,b;(m=c.current)==null||m.focus(),d||(b=c.current)==null||b.select()},[d]),t.jsx("input",{ref:c,type:u,value:l,maxLength:n==null?void 0:n.maxLength,onChange:m=>i(m.target.value),onBlur:()=>s(),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),a(l)),m.key==="Escape"&&(m.preventDefault(),s()),(n==null?void 0:n.preset)==="integer"&&!m.ctrlKey&&!m.metaKey&&!Oc.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 Bc({initialValue:e,options:r,loading:n,onCommit:a,onCancel:s}){const l=o.useRef(null);return o.useEffect(()=>{if(n)return;const i=setTimeout(()=>{var c,d;(d=(c=l.current)==null?void 0:c.querySelector("button"))==null||d.click()},0);return()=>clearTimeout(i)},[n]),t.jsx("div",{ref:l,className:"w-full",tabIndex:-1,onKeyDown:i=>{i.key==="Escape"&&(i.stopPropagation(),s())},children:t.jsx(ar,{value:e,onChange:i=>{a(i)},options:r,disabled:n,placeholder:n?"Cargando…":"Seleccionar…",triggerVariant:"ghost",height:30,padding:"0 6px",minOptionsForSearch:1,className:"w-full"})})}const Fc={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},Oa={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function Pc({columns:e,data:r,getRowId:n,onCellUpdate:a,readOnly:s=!1,...l}){const[i,c]=o.useState(r),d=o.useRef(null);o.useEffect(()=>{d.current||c(r)},[r]);const[u,m]=o.useState(null);d.current=u;const[b,f]=o.useState(null),g=o.useRef(null);g.current=b;const[v,k]=o.useState({}),[h,C]=o.useState(null),M=o.useRef(null);M.current=h;const[y,x]=o.useState({}),[w,N]=o.useState({}),A=o.useRef(new Set),T=o.useRef(null);o.useEffect(()=>{var W;const j=document.activeElement;(!j||j===document.body)&&((W=T.current)==null||W.focus({preventScroll:!0}))},[]);const U=e.map(j=>{var W,ae,H;return`${j.key}:${((H=(ae=(W=j.editable)==null?void 0:W.select)==null?void 0:ae.options)==null?void 0:H.length)??-1}`}).join("|");o.useEffect(()=>{e.forEach(j=>{var H,D;const W=(D=(H=j.editable)==null?void 0:H.select)==null?void 0:D.options;if(!W)return;const ae=y[j.key];(!A.current.has(j.key)||(ae==null?void 0:ae.length)===0&&W.length>0)&&(A.current.add(j.key),x($=>({...$,[j.key]:W})))})},[U]);const K=o.useCallback(async(j,W)=>{if(A.current.has(j))return;A.current.add(j);const{url:ae,fetchOptions:H}=W.select??{};if(!(!ae&&!H)){N(D=>({...D,[j]:!0}));try{let D=[];if(H)D=await H();else if(ae){const $=await fetch(ae);if(!$.ok)throw new Error("fetch failed");D=await $.json()}x($=>({...$,[j]:D}))}catch{x(D=>({...D,[j]:[]}))}finally{N(D=>({...D,[j]:!1}))}}},[]),Z=o.useRef(i);Z.current=i;const L=o.useRef(a);L.current=a;const Q=o.useRef(n);Q.current=n;const z=o.useRef(e);z.current=e;const se=o.useRef(s);se.current=s,o.useEffect(()=>{if(e.length>0&&r.length>0){const j=e.find(W=>W.selectable!==!1);j&&f({rowId:n(r[0]),colKey:j.key})}},[]),o.useEffect(()=>{if(!b)return;const j=T.current;if(!j)return;const W=j.querySelector(`[data-cell-id="${b.rowId}:${b.colKey}"]`);if(!W)return;const ae=j.querySelector('[role="rowgroup"]');W.style.scrollMarginTop=`${(ae==null?void 0:ae.offsetHeight)??0}px`;const H=j.querySelector('[role="row"]');let D=0;H&&H.querySelectorAll('[role="cell"], [role="columnheader"]').forEach($=>{$.style.position==="sticky"&&$.style.left!==""&&(D=Math.max(D,parseFloat($.style.left)+$.offsetWidth))}),W.style.scrollMarginLeft=`${D}px`,W.scrollIntoView({block:"nearest",inline:"nearest"})},[b]);const re=o.useCallback(j=>{var D;const W=z.current,ae=new Set,H=[];(D=T.current)==null||D.querySelectorAll("[data-cell-id]").forEach($=>{const oe=$.dataset.cellId.split(":")[0];ae.has(oe)||(ae.add(oe),H.push(oe))}),f($=>{if(!$)return $;const oe=W.findIndex(O=>O.key===$.colKey),G=H.indexOf($.rowId);let X=oe,S=G;if(j==="up")S=Math.max(0,G-1);else if(j==="down")S=Math.min(H.length-1,G+1);else if(j==="left"){let O=oe-1;for(;O>=0&&W[O].selectable===!1;)O--;O>=0&&(X=O)}else if(j==="right"){let O=oe+1;for(;O<W.length&&W[O].selectable===!1;)O++;O<W.length&&(X=O)}return X===oe&&S===G?$:{rowId:H[S],colKey:W[X].key}})},[]),R=o.useCallback((j=!0)=>{const W=d.current;m(null),W&&f(W),j&&setTimeout(()=>{var ae;return(ae=T.current)==null?void 0:ae.focus({preventScroll:!0})},0)},[]),V=o.useCallback(async(j,W,ae)=>{var ie;const H=z.current.find(ge=>ge.key===W);if(!(H!=null&&H.editable))return;const{field:D,type:$,mask:oe,validate:G}=H.editable,X=$==="number"?ae===""?null:Number(ae):ae;if(oe){const ge=Ic(ae,oe);if(ge){k(Te=>({...Te,[`${j}:${W}`]:ge}));return}}if(G){const ge=G(X);if(ge){k(Te=>({...Te,[`${j}:${W}`]:ge}));return}}const S=Q.current,O=Z.current.find(ge=>S(ge)===j);if(!O)return;const I=O[D];m(null),k(ge=>{const Te={...ge};return delete Te[`${j}:${W}`],Te});const te=Z.current,P=te.findIndex(ge=>S(ge)===j),ce=te[Math.min(te.length-1,P+1)];if(f({rowId:S(ce),colKey:W}),setTimeout(()=>{var Te,Le;const ge=document.activeElement;(!ge||ge===document.body||(Te=T.current)!=null&&Te.contains(ge))&&((Le=T.current)==null||Le.focus({preventScroll:!0}))},0),String(I??"")===String(X??""))return;const he={...O,[D]:X};c(ge=>ge.map(Te=>S(Te)===j?he:Te)),C({rowId:j,colKey:W});try{await((ie=L.current)==null?void 0:ie.call(L,{row:O,rowId:j,field:D,oldValue:I,newValue:X}))}catch{c(ge=>ge.map(Te=>S(Te)===j?O:Te)),k(ge=>({...ge,[`${j}:${W}`]:"Error al guardar. Intenta de nuevo."}))}finally{C(null)}},[]),B=o.useCallback(j=>{if(M.current){j.preventDefault();return}if(d.current)return;const W=g.current;if(!(!W||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(j.key)))switch(j.preventDefault(),j.key){case"ArrowUp":re("up");break;case"ArrowDown":re("down");break;case"ArrowLeft":re("left");break;case"ArrowRight":re("right");break;case"Tab":re(j.shiftKey?"left":"right");break;case"Enter":{const H=z.current.find(D=>D.key===W.colKey);H!=null&&H.editable&&!se.current?(m(W),H.editable.type==="select"&&!A.current.has(W.colKey)&&K(W.colKey,H.editable)):re("down");break}}},[re,K]),le=o.useMemo(()=>e.map(j=>{if(!j.editable||s){const ae={...j};if(delete ae.editable,delete ae.selectable,j.selectable===!1)return{...ae,disableRowClick:!0};const H=ae.cell;return{...ae,className:`relative ${ae.className??""}`.trim(),disableRowClick:!0,cell:D=>{const $=n(D),oe=(b==null?void 0:b.rowId)===$&&(b==null?void 0:b.colKey)===j.key;return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${$}:${j.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var G;M.current||(f({rowId:$,colKey:j.key}),(G=T.current)==null||G.focus({preventScroll:!0}))}}),oe&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Oa}),t.jsx("span",{className:"relative z-0 pointer-events-none",children:H(D)})]})}}}const W=j.editable;return{...j,className:`relative ${j.className??""}`.trim(),disableRowClick:!0,cell:ae=>{const H=n(ae),D=j.key,$=(u==null?void 0:u.rowId)===H&&(u==null?void 0:u.colKey)===D,oe=(b==null?void 0:b.rowId)===H&&(b==null?void 0:b.colKey)===D,G=v[`${H}:${D}`],X=(h==null?void 0:h.rowId)===H&&(h==null?void 0:h.colKey)===D,S=ae[W.field],O=String(S??""),I=()=>{var P;M.current||(f({rowId:H,colKey:D}),m({rowId:H,colKey:D}),(P=T.current)==null||P.focus({preventScroll:!0}),W.type==="select"&&!A.current.has(D)&&K(D,W))};if($){const P=W.type==="select"?t.jsx(Bc,{initialValue:O,options:y[D]??[],loading:w[D]??!1,onCommit:ce=>V(H,D,ce),onCancel:R}):t.jsx(Hc,{initialValue:O,type:W.type??"text",mask:W.mask,onCommit:ce=>V(H,D,ce),onCancel:R});return t.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:Fc,onClick:ce=>ce.stopPropagation(),children:P})}const te=j.cell(ae);return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${H}:${D}`,className:`peer absolute inset-0 z-10 ${X?"cursor-wait":"cursor-pointer"}`,onClick:I}),oe&&!X&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:Oa}),X&&t.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:Oa,children:[t.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}),t.jsx("span",{className:"truncate text-xs text-[var(--text-muted)]",children:"Guardando…"})]}),t.jsx("span",{className:"relative z-0 inline-flex items-center gap-1 pointer-events-none",children:G?t.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[t.jsx(q.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"truncate text-xs",children:G})]}):t.jsx("span",{className:"truncate",children:te})}),!X&&t.jsx(q.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"})]})}}}),[e,s,u,b,h,v,y,w,n,V,R,K]);return t.jsx("div",{ref:T,tabIndex:0,onKeyDown:B,onBlur:j=>{var W;(W=T.current)!=null&&W.contains(j.relatedTarget)||setTimeout(()=>{var H,D;const ae=document.activeElement;ae&&((H=ae.closest)!=null&&H.call(ae,"[data-bonsaif-select-dropdown]"))||(D=T.current)!=null&&D.contains(ae)||R(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:t.jsx(ns,{...l,columns:le,data:i,getRowId:n})})}function st(e){if(e)return new Date(`${e}T12:00:00`)}function $t(e){const r=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return`${r}-${n}-${a}`}function yr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function as(e){return e.map(r=>st(r)).filter(r=>!!r)}function _c(e){if(!(e!=null&&e.length))return[];const r=new Set(e.map($t));return Array.from(r).sort()}function Ha(e){return new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(e)}function os(e){const r=st(e);if(!r)return e;const n=Ha(r).replace(/\.$/u,"").replace(/^\w/u,s=>s.toUpperCase()),a=new Intl.DateTimeFormat("es-MX",{month:"short"}).format(r).replace(/\.$/u,"").toLowerCase();return`${n} - ${r.getDate()} ${a} ${r.getFullYear()}`}const Ba={weekend:{dayOfWeek:[0,6]}},Fa={weekend:"bonsaif-weekend"};function Pa({children:e,className:r="",...n}){const a=String(e??"").toLowerCase().normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").trim(),s=a.startsWith("sab")||a.startsWith("dom")||a==="s"||a==="d";return t.jsx("th",{...n,className:`${r} ${s?"bonsaif-weekday-weekend":""}`.trim(),children:e})}const zc={background:"var(--primary)",color:"var(--primary-fg, #ffffff)",borderRadius:999},Wc={background:"color-mix(in srgb, var(--primary) 22%, transparent)",color:"var(--text-main)",borderRadius:999};function jc({day:e,modifiers:r,...n}){const a=r.range_start||r.range_end||r.selected&&!r.range_middle,s=!!r.range_middle,l=!!r.weekend||e.date.getDay()===0||e.date.getDay()===6;return t.jsx("button",{...n,type:"button",className:`bonsaif-multi-day-btn${a?" is-range-edge":""}${s?" is-range-middle":""}${l?" bonsaif-day-weekend":""} ${n.className??""}`,style:{...a?zc:null,...s?Wc:null,...l?{fontWeight:800}:null,...n.style}})}function qc({startDate:e,endDate:r,onChange:n,minDate:a,viewMonth:s,numberOfMonths:l=1,orientation:i="horizontal",showSummary:c=!0,startLabel:d="Inicio",endLabel:u="Regreso",className:m=""}){const b={from:st(e),to:st(r)},f=st(a),[g,v]=o.useState(()=>st(s||e)??new Date);o.useEffect(()=>{const y=st(s||e);y&&v(y)},[s,e]);const k=o.useMemo(()=>{if(l<=1)return yr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(g));const y=new Date(g.getFullYear(),g.getMonth()+l-1,1),x=g.getFullYear()===y.getFullYear(),w=new Intl.DateTimeFormat("es-MX",{month:"short",...x?{}:{year:"numeric"}}).format(g),N=new Intl.DateTimeFormat("es-MX",{month:"short",year:"numeric"}).format(y);return`${yr(w)} – ${yr(N)}`},[g,l]);function h(){v(new Date(g.getFullYear(),g.getMonth()-1,1))}function C(){v(new Date(g.getFullYear(),g.getMonth()+1,1))}const M=l>1?`bonsaif-range-months bonsaif-range-months--multi bonsaif-range-months--${i}`:"bonsaif-range-months";return t.jsxs("div",{className:`bonsaif-calendar bonsaif-date-range-picker ${m}`.trim(),children:[t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes anterior",onClick:h,children:t.jsx(q.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:k}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes siguiente",onClick:C,children:t.jsx(q.HiChevronRight,{size:16})})]}),t.jsx(Sa.DayPicker,{mode:"range",selected:b,month:g,onMonthChange:v,onSelect:y=>{const x=y!=null&&y.from?$t(y.from):e,w=y!=null&&y.to?$t(y.to):"";n({startDate:x,endDate:w})},numberOfMonths:l,hideNavigation:!0,weekStartsOn:1,disabled:f?{before:f}:void 0,showOutsideDays:!1,modifiers:Ba,modifiersClassNames:Fa,components:{DayButton:jc,Weekday:Pa},classNames:{root:"bonsaif-range-daypicker w-full",months:M,month:l>1?"bonsaif-multi-month bonsaif-range-month-card":"bonsaif-multi-month",month_caption:l>1?"bonsaif-range-month-caption":"bonsaif-multi-caption-hidden",month_grid:"bonsaif-multi-month-grid",weekdays:"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:"bonsaif-multi-week",day:"bonsaif-multi-day",day_button:"bonsaif-multi-day-btn",selected:"bonsaif-range-day-selected",range_start:"bonsaif-range-start",range_middle:"bonsaif-range-middle",range_end:"bonsaif-range-end",today:"bonsaif-multi-day-today",disabled:"bonsaif-multi-day-disabled",hidden:"bonsaif-multi-day-hidden"},formatters:{formatCaption:y=>`${yr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(y))} ${y.getFullYear()}`,formatWeekdayName:Ha}})]}),c?t.jsx("div",{className:"bonsaif-cal-summary",children:e?t.jsxs("div",{className:"bonsaif-cal-chips",children:[t.jsxs("span",{className:"bonsaif-cal-chip bonsaif-cal-chip--static",children:[d,": ",e]}),r?t.jsxs("span",{className:"bonsaif-cal-chip bonsaif-cal-chip--static",children:[u,": ",r]}):null]}):t.jsx("span",{children:"Sin rango seleccionado"})}):null]})}function ss({day:e,modifiers:r,onDayPointerDown:n,onDayPointerEnter:a,onDayClickSelect:s,...l}){const i=!!(r.disabled||r.hidden),c=!!r.weekend||e.date.getDay()===0||e.date.getDay()===6;return t.jsx("button",{...l,type:"button",disabled:i||l.disabled,className:`${l.className??""}${c?" bonsaif-day-weekend":""}`,style:{...c?{fontWeight:800}:null,...l.style},onPointerDown:d=>{var u;i||(n==null||n(e.date,d),(u=l.onPointerDown)==null||u.call(l,d))},onPointerEnter:()=>{i||a==null||a(e.date)},onClick:d=>{i||(d.preventDefault(),d.stopPropagation(),s==null||s(e.date,d))}})}function ls(e,r){const n=st(e),a=st(r);if(!n||!a)return[];const s=n<=a?n:a,l=n<=a?a:n,i=[],c=new Date(s);for(;c<=l;)i.push($t(c)),c.setDate(c.getDate()+1);return i}function is(e,r=1){const n=e.getDay(),a=r===1?(n+6)%7:n,s=new Date(e);return s.setHours(12,0,0,0),s.setDate(s.getDate()-a),Array.from({length:7},(l,i)=>{const c=new Date(s);return c.setDate(s.getDate()+i),c})}function Qr(e,r,n){const a=new Set(e);for(const s of r)n==="add"?a.add(s):n==="remove"||a.has(s)?a.delete(s):a.add(s);return Array.from(a).sort()}function Uc(e,r){return typeof r!="number"||r<=0||e.length<=r?e:e.slice(-r)}function Cn(e,r,n){return!!(r&&e<r||n&&e>n)}function cs({value:e,onChange:r,disabled:n=!1,minDate:a,maxDate:s,maxDates:l,retainOutsidePrefix:i}){const c=o.useRef(null),d=o.useRef(null),u=o.useRef(!1),m=o.useRef(e);m.current=e;const b=o.useCallback(y=>{let x=y;if(i){const w=m.current.filter(A=>!A.startsWith(i)),N=y.filter(A=>A.startsWith(i));x=[...w,...N].sort()}r==null||r(Uc(x,l))},[l,r,i]),f=o.useCallback(y=>y.filter(x=>!Cn(x,a,s)),[a,s]),g=o.useCallback(()=>{d.current=null},[]);o.useEffect(()=>{const y=()=>g();return window.addEventListener("pointerup",y),window.addEventListener("pointercancel",y),()=>{window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",y)}},[g]);const v=o.useCallback((y,x,w,N)=>{const A=f(ls(y,x));b(w==="add"?Qr(N,A,"add"):Qr(N,A,"remove"))},[b,f]),k=o.useCallback((y,x)=>{if(n||x.button!==0)return;const w=$t(y);if(Cn(w,a,s)||x.shiftKey)return;u.current=!0;const N=[...m.current],A=N.includes(w)?"remove":"add";d.current={active:!0,mode:A,anchor:w,latest:w,baseline:N},c.current=w,v(w,w,A,N),x.preventDefault()},[v,n,s,a]),h=o.useCallback(y=>{const x=d.current;if(!(x!=null&&x.active)||n)return;const w=$t(y);Cn(w,a,s)||x.latest!==w&&(x.latest=w,v(x.anchor,w,x.mode,x.baseline))},[v,n,s,a]),C=o.useCallback((y,x)=>{if(n)return;const w=$t(y);if(!Cn(w,a,s)){if(u.current&&!x.shiftKey){u.current=!1,x.preventDefault(),x.stopPropagation();return}if(u.current=!1,x.shiftKey&&c.current){x.preventDefault(),x.stopPropagation();const N=f(ls(c.current,w));b(Qr(m.current,N,"add"));return}c.current=w,b(Qr(m.current,[w],"toggle"))}},[b,n,f,s,a]),M=o.useCallback(y=>{if(n)return;const x=f(_c(y));if(!x.length)return;const w=x.every(N=>m.current.includes(N));b(Qr(m.current,x,w?"remove":"add")),c.current=x[0]??c.current},[b,n,f]);return{onDayPointerDown:k,onDayPointerEnter:h,onDayClick:C,toggleWeek:M,endDrag:g}}function Jr(e){return is(e,1)[0]}function ds(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function Vc({value:e=[],onChange:r,minDate:n,maxDate:a,viewMonth:s,maxDates:l,showWeekNumbers:i=!1,viewMode:c,defaultViewMode:d="month",onViewModeChange:u,showSummary:m=!0,className:b="",disabled:f=!1}){const g=o.useMemo(()=>as(e),[e]),v=o.useMemo(()=>new Set(e),[e]),k=st(n),h=st(a),[C,M]=o.useState(()=>st(s||e[0])??new Date),[y,x]=o.useState(()=>Jr(st(s||e[0])??new Date)),[w,N]=o.useState(d),A=c??w;function T(B){c===void 0&&N(B),u==null||u(B)}o.useEffect(()=>{const B=st(s);B&&(M(B),x(Jr(B)))},[s]);const{onDayPointerDown:U,onDayPointerEnter:K,onDayClick:Z,toggleWeek:L}=cs({value:e,onChange:r,disabled:f,minDate:n,maxDate:a,maxDates:l}),Q=o.useCallback(B=>t.jsx(ss,{...B,className:`bonsaif-multi-day-btn ${B.className??""}`,onDayPointerDown:U,onDayPointerEnter:K,onDayClickSelect:Z}),[Z,U,K]),z=o.useMemo(()=>is(y,1),[y]),se=z[6],re=A==="week"?`${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short"}).format(z[0])} – ${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short",year:"numeric"}).format(se)}`:yr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(C));function R(){if(A==="week"){const B=ds(y,-7);x(Jr(B)),M(B);return}M(new Date(C.getFullYear(),C.getMonth()-1,1))}function V(){if(A==="week"){const B=ds(y,7);x(Jr(B)),M(B);return}M(new Date(C.getFullYear(),C.getMonth()+1,1))}return t.jsxs("div",{className:`bonsaif-calendar bonsaif-multi-date-calendar ${b}`,children:[t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-view-toggle",role:"tablist","aria-label":"Vista",children:[t.jsx("button",{type:"button",role:"tab","aria-selected":A==="month",className:`bonsaif-cal-view-btn${A==="month"?" is-active":""}`,disabled:f,onClick:()=>{T("month"),M(y)},children:"Mes"}),t.jsx("button",{type:"button",role:"tab","aria-selected":A==="week",className:`bonsaif-cal-view-btn${A==="week"?" is-active":""}`,disabled:f,onClick:()=>{T("week"),x(Jr(C))},children:"Semana"})]}),t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":A==="week"?"Semana anterior":"Mes anterior",disabled:f,onClick:R,children:t.jsx(q.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:re}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":A==="week"?"Semana siguiente":"Mes siguiente",disabled:f,onClick:V,children:t.jsx(q.HiChevronRight,{size:16})})]}),t.jsxs("p",{className:"bonsaif-cal-hint",children:["Click · Shift+click rango · Arrastra",i&&A==="month"?" · Semana (nº)":"",A==="week"?" · Botón semana completa":""]}),A==="month"?t.jsx(Sa.DayPicker,{mode:"multiple",required:!1,selected:g,month:C,onMonthChange:M,onSelect:()=>{},hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,showWeekNumber:i,onWeekNumberClick:(B,le)=>{L(le)},disabled:f?!0:[...k?[{before:k}]:[],...h?[{after:h}]:[]],className:"bonsaif-multi-daypicker",modifiers:Ba,modifiersClassNames:Fa,classNames:{root:"bonsaif-multi-daypicker",months:"bonsaif-multi-months",month:"bonsaif-multi-month",month_caption:"bonsaif-multi-caption-hidden",month_grid:"bonsaif-multi-month-grid",weekdays:i?"bonsaif-multi-weekdays bonsaif-multi-weekdays--with-week":"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:i?"bonsaif-multi-week bonsaif-multi-week--with-week":"bonsaif-multi-week",week_number:"bonsaif-week-number",week_number_header:"bonsaif-week-number-header",day:"bonsaif-multi-day",day_button:"bonsaif-multi-day-btn",selected:"bonsaif-multi-day-selected",today:"bonsaif-multi-day-today",disabled:"bonsaif-multi-day-disabled",hidden:"bonsaif-multi-day-hidden"},components:{DayButton:Q,Weekday:Pa},formatters:{formatWeekdayName:Ha}}):t.jsxs("div",{className:"bonsaif-week-view",children:[t.jsx("div",{className:"bonsaif-week-view-head",children:z.map(B=>t.jsx("div",{className:"bonsaif-multi-weekday",children:new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(B)},`h-${$t(B)}`))}),t.jsx("div",{className:"bonsaif-week-view-days",children:z.map(B=>{const le=$t(B),j=v.has(le),W=f||(n?le<n:!1)||(a?le>a:!1),ae=le===$t(new Date);return t.jsx("div",{className:`bonsaif-multi-day${j?" bonsaif-multi-day-selected":""}${ae?" bonsaif-multi-day-today":""}${W?" bonsaif-multi-day-disabled":""}`,children:t.jsxs("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:W,"aria-pressed":j,onPointerDown:H=>U(B,H),onPointerEnter:()=>K(B),onClick:H=>Z(B,H),children:[t.jsx("span",{className:"bonsaif-week-day-num",children:B.getDate()}),t.jsx("span",{className:"bonsaif-week-day-month",children:new Intl.DateTimeFormat("es-MX",{month:"short"}).format(B)})]})},le)})}),t.jsx("button",{type:"button",className:"bonsaif-week-select-all",disabled:f,onClick:()=>L(z),children:"Marcar / desmarcar semana"})]})]}),m?t.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?t.jsx("span",{children:"Sin fechas seleccionadas"}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(B=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:f,onClick:()=>r==null?void 0:r(e.filter(le=>le!==B)),title:`Quitar ${B}`,children:[os(B),t.jsx("span",{"aria-hidden":!0,children:"×"})]},B))})]})}):null]})}const Yc=Array.from({length:12},(e,r)=>r);function Xc({value:e=[],onChange:r,year:n,onYearChange:a,minDate:s,maxDate:l,maxDates:i,showSummary:c=!0,className:d="",disabled:u=!1,readOnly:m=!1}){const b=o.useMemo(()=>as(e),[e]),f=st(s),g=st(l),v=n??(e[0]?Number(e[0].slice(0,4)):new Date().getFullYear()),[k,h]=o.useState(v);o.useEffect(()=>{typeof n=="number"&&h(n)},[n]);function C(T){h(T),a==null||a(T)}const{onDayPointerDown:M,onDayPointerEnter:y,onDayClick:x}=cs({value:e,onChange:r,disabled:u||m,minDate:s,maxDate:l,maxDates:i,retainOutsidePrefix:`${k}-`}),w=o.useCallback(T=>t.jsx(ss,{...T,className:`bonsaif-year-day-btn ${T.className??""}`,onDayPointerDown:M,onDayPointerEnter:y,onDayClickSelect:x}),[x,M,y]),N=b.filter(T=>T.getFullYear()===k),A=u?!0:[...f?[{before:f}]:[],...g?[{after:g}]:[]];return t.jsxs("div",{className:`bonsaif-calendar bonsaif-year-multi-date-calendar${m?" bonsaif-year-multi-date-calendar--readonly":""} ${d}`,children:[t.jsxs("div",{className:"bonsaif-cal-shell bonsaif-year-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año anterior",disabled:u,onClick:()=>C(k-1),children:t.jsx(q.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:k}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año siguiente",disabled:u,onClick:()=>C(k+1),children:t.jsx(q.HiChevronRight,{size:16})})]}),!m&&!u?t.jsx("p",{className:"bonsaif-cal-hint",children:"Click · Shift+click rango · Arrastra para marcar varias"}):null,t.jsx("div",{className:"bonsaif-year-cal-grid",children:Yc.map(T=>{const U=new Date(k,T,1);return t.jsxs("div",{className:"bonsaif-year-cal-month",children:[t.jsx("div",{className:"bonsaif-year-cal-month-title",children:yr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(U))}),t.jsx(Sa.DayPicker,{mode:"multiple",required:!1,selected:N,month:U,onMonthChange:()=>{},onSelect:()=>{},numberOfMonths:1,hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,disabled:A,className:"bonsaif-year-month-picker",modifiers:Ba,modifiersClassNames:Fa,classNames:{root:"bonsaif-year-month-picker",months:"bonsaif-year-month-months",month:"bonsaif-year-month-inner",month_caption:"bonsaif-year-month-caption-hidden",month_grid:"bonsaif-year-month-grid",weekdays:"bonsaif-year-weekdays",weekday:"bonsaif-year-weekday",week:"bonsaif-year-week",day:"bonsaif-year-day",day_button:"bonsaif-year-day-btn",selected:"bonsaif-year-day-selected",today:"bonsaif-year-day-today",disabled:"bonsaif-year-day-disabled",hidden:"bonsaif-year-day-hidden"},components:{DayButton:w,Weekday:Pa},formatters:{formatWeekdayName:K=>new Intl.DateTimeFormat("es-MX",{weekday:"narrow"}).format(K)}})]},`${k}-${T}`)})})]}),c?t.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?t.jsx("span",{children:"Sin fechas seleccionadas"}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"," ·"," ",k]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(T=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:u||m,onClick:()=>r==null?void 0:r(e.filter(U=>U!==T)),title:`Quitar ${T}`,children:[os(T),t.jsx("span",{"aria-hidden":!0,children:"×"})]},T))})]})}):null]})}const Kc="bonsaif-ui:hide-tooltips";function us(){window.dispatchEvent(new CustomEvent(Kc))}function Gc(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Zc({trigger:e,items:r,align:n="end",width:a=220,disabled:s=!1,className:l="",menuClassName:i="",onOpenChange:c}){const[d,u]=o.useState(!1),[m,b]=o.useState(!1),[f,g]=o.useState({}),v=o.useRef(null),k=o.useRef(null),h=o.useCallback(w=>{u(w),c==null||c(w)},[c]),C=o.useCallback(()=>{const w=v.current;if(!w)return;const N=w.getBoundingClientRect(),A=typeof a=="number"?a:N.width,T=typeof a=="number"?a:Math.max(N.width,180),U=n==="end"?Math.max(8,N.right-T):Math.min(N.left,window.innerWidth-T-8),K=window.innerHeight-N.bottom,Z=K<240&&N.top>K?void 0:N.bottom+6,L=Z===void 0?window.innerHeight-N.top+6:void 0;g({position:"fixed",zIndex:9999,left:U,top:Z,bottom:L,width:Gc(typeof a=="number"?A:a)})},[n,a]);o.useEffect(()=>b(!0),[]),o.useEffect(()=>{if(!d)return;C();const w=A=>{var U,K;const T=A.target;!((U=v.current)!=null&&U.contains(T))&&!((K=k.current)!=null&&K.contains(T))&&h(!1)},N=A=>{A.key==="Escape"&&h(!1)};return document.addEventListener("mousedown",w),window.addEventListener("keydown",N),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{document.removeEventListener("mousedown",w),window.removeEventListener("keydown",N),window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[d,h,C]);const M=w=>{s||(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),h(!d))},y=o.isValidElement(e)?o.cloneElement(e,{onClick:()=>{s||(us(),h(!d))}}):e,x=d?t.jsx("div",{ref:k,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${i}`,style:f,children:r.map(w=>t.jsxs("div",{children:[w.separatorBefore&&t.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),t.jsxs("button",{type:"button",role:"menuitem",disabled:w.disabled,onClick:()=>{var N;w.disabled||(us(),(N=w.onSelect)==null||N.call(w),h(!1))},className:"flex w-full min-w-0 items-start gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:w.danger?"var(--danger)":"var(--text-main)"},children:[w.icon&&t.jsx("span",{className:"mt-0.5 shrink-0",children:w.icon}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium",children:w.label}),w.description&&t.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:w.description})]})]})]},w.id))}):null;return t.jsxs("span",{ref:v,role:"button",tabIndex:s?-1:0,"aria-haspopup":"menu","aria-expanded":d,onKeyDown:M,className:`inline-flex ${s?"pointer-events-none opacity-60":""} ${l}`,children:[y,m&&x?dt.createPortal(x,document.body):null]})}const Qc=180,fs="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Jc({open:e,onClose:r,title:n,subtitle:a,leadingIcon:s,confirmLabel:l="Guardar",onConfirm:i,loading:c=!1,confirmDisabled:d=!1,headerActions:u,bodyClassName:m="flex-1 overflow-y-auto px-6 py-5",width:b=440,hasUnsavedChanges:f=!1,unsavedChangesTitle:g="Descartar cambios",unsavedChangesDescription:v="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:k="Descartar",unsavedChangesCancelLabel:h="Seguir editando",onDiscardChanges:C,disabled:M=!1,disabledMessage:y,children:x}){const[w,N]=o.useState(!1),[A,T]=o.useState(!1),[U,K]=o.useState(!1),Z=o.useCallback(()=>{T(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>K(!0))})},[]),L=o.useCallback(()=>{K(!1),window.setTimeout(()=>T(!1),Qc)},[]),Q=M||c,z=o.useCallback(()=>{if(!Q){if(f){Z();return}r()}},[Q,f,r,Z]),se=o.useCallback(()=>{K(!1),T(!1),C==null||C(),r()},[r,C]);if(o.useEffect(()=>{N(!0)},[]),o.useEffect(()=>(document.body.style.overflow=e?"hidden":"",e||(K(!1),T(!1)),()=>{document.body.style.overflow=""}),[e]),o.useEffect(()=>{if(!e)return;const R=V=>{if(V.key==="Escape"&&!Q){if(A){L();return}z()}};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[L,Q,A,e,z]),!w)return null;const re=y!==void 0?y:c?"Guardando…":null;return dt.createPortal(t.jsxs("div",{"aria-hidden":!e,"data-bonsaif-overlay":e?"true":void 0,className:`fixed inset-0 z-[1000] flex transition-opacity duration-300 ${e?"opacity-100":"opacity-0 pointer-events-none"}`,children:[t.jsx("div",{className:`absolute inset-0 ${fs}`,onClick:z}),t.jsxs("div",{className:`absolute inset-y-0 right-0 flex flex-col shadow-2xl transition-transform duration-300 ${e?"translate-x-0":"translate-x-full"}`,style:{width:`min(100vw, ${b}px)`,background:"var(--bg-card)",borderLeft:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center justify-between px-6 py-4 flex-shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx(Ue,{variant:"icon",onClick:z,title:"Cerrar",disabled:Q,children:t.jsx(q.HiXMark,{className:"w-5 h-5"})}),s&&t.jsx("div",{className:"flex-shrink-0",children:s}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"text-base font-semibold truncate",style:{color:"var(--text-main)"},children:n}),a&&t.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:a})]})]}),(u||i)&&t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[u,i&&t.jsxs(t.Fragment,{children:[t.jsx(Ue,{variant:"secondary",size:"sm",onClick:z,disabled:Q,style:{background:"var(--bg-input)"},children:"Cancelar"}),t.jsx(Ue,{variant:"primary",size:"sm",icon:t.jsx(Ci.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:d||Q,title:l})]})]})]}),t.jsx("div",{"data-drawer-scroll":"true",className:m,children:x}),Q&&t.jsx("div",{className:"absolute inset-0 z-[1002] flex cursor-not-allowed items-center justify-center p-6",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 72%, transparent)",backdropFilter:"blur(3px)"},role:"status","aria-live":"polite","aria-busy":"true",children:re?t.jsxs("div",{className:"flex max-w-xs flex-col items-center gap-3 text-center",children:[t.jsx("div",{className:"h-9 w-9 animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]","aria-hidden":!0}),t.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:re})]}):null})]}),A&&t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":g,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[t.jsx("div",{className:`absolute inset-0 ${fs} transition-opacity duration-200 ease-out ${U?"opacity-100":"opacity-0"}`,onClick:L}),t.jsxs("div",{className:`relative z-10 w-full max-w-sm rounded-2xl border p-6 shadow-2xl transition-[opacity,transform] duration-200 ease-out ${U?"translate-y-0 scale-100 opacity-100":"translate-y-2 scale-[0.96] opacity-0"}`,style:{background:"var(--bg-card, #ffffff)",borderColor:"var(--border, #d8e1dc)"},children:[t.jsx(Ue,{variant:"icon",onClick:L,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":h,children:t.jsx(q.HiXMark,{className:"h-4 w-4"})}),t.jsx("div",{className:"mb-4 flex h-11 w-11 items-center justify-center rounded-xl",style:{background:"var(--warning-bg, #fff7ed)"},children:t.jsx(q.HiExclamationTriangle,{className:"h-5 w-5",style:{color:"var(--warning, #d97706)"}})}),t.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main, #0f2f2c)"},children:g}),t.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:v}),t.jsxs("div",{className:"mt-6 flex gap-2",children:[t.jsx(Ue,{variant:"secondary",onClick:L,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:h}),t.jsx(Ue,{variant:"secondary",onClick:se,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:k})]})]})]})]}),document.body)}const Rc=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ed=/^\+?[0-9\s().-]+$/,td=7,rd=15;function At(e){return e==null||String(e).trim()===""}function bs(e){return typeof e=="number"?e:typeof e=="string"&&e.trim()!==""?Number(e):Number.NaN}function _a(e){return At(e)?!1:Rc.test(String(e))}function za(e){if(At(e))return!1;const r=String(e),n=r.replace(/\D/g,"");return ed.test(r)&&n.length>=td&&n.length<=rd}function nd(e="Este campo es requerido."){return r=>At(r)?e:void 0}function ad(e="Ingresa un correo valido."){return r=>At(r)||_a(r)?void 0:e}function od(e="Ingresa un telefono valido."){return r=>At(r)||za(r)?void 0:e}function sd(e,r){return n=>At(n)||String(n).length>=e?void 0:r??`Debe tener al menos ${e} caracteres.`}function ld(e,r){return n=>At(n)||String(n).length<=e?void 0:r??`Debe tener ${e} caracteres o menos.`}function id(e,r){return n=>{if(At(n))return;const a=bs(n);return Number.isFinite(a)&&a>=e?void 0:r??`Debe ser mayor o igual a ${e}.`}}function cd(e,r){return n=>{if(At(n))return;const a=bs(n);return Number.isFinite(a)&&a<=e?void 0:r??`Debe ser menor o igual a ${e}.`}}function dd(e,r="El formato no es valido."){return n=>At(n)||e.test(String(n))?void 0:r}function ud(e,r){const n={};for(const a of Object.keys(r)){const s=r[a];if(!s)continue;const l=Array.isArray(s)?s:[s];for(const i of l){const c=i(e[a],e);if(c){n[a]=c;break}}}return{valid:Object.keys(n).length===0,errors:n}}var ms={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},ps=o.createContext&&o.createContext(ms),fd=["attr","size","title"];function bd(e,r){if(e==null)return{};var n,a,s=md(e,r);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a<l.length;a++)n=l[a],r.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function md(e,r){if(e==null)return{};var n={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(r.indexOf(a)!==-1)continue;n[a]=e[a]}return n}function En(){return En=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},En.apply(null,arguments)}function hs(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);r&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,a)}return n}function Mn(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?hs(Object(n),!0).forEach(function(a){pd(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):hs(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function pd(e,r,n){return(r=hd(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function hd(e){var r=gd(e,"string");return typeof r=="symbol"?r:r+""}function gd(e,r){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var a=n.call(e,r);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function gs(e){return e&&e.map((r,n)=>o.createElement(r.tag,Mn({key:n},r.attr),gs(r.child)))}function Wa(e){return r=>o.createElement(vd,En({attr:Mn({},e.attr)},r),gs(e.child))}function vd(e){var r=n=>{var{attr:a,size:s,title:l}=e,i=bd(e,fd),c=s||n.size||"1em",d;return n.className&&(d=n.className),e.className&&(d=(d?d+" ":"")+e.className),o.createElement("svg",En({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,i,{className:d,style:Mn(Mn({color:e.color||n.color},n.style),e.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),l&&o.createElement("title",null,l),e.children)};return ps!==void 0?o.createElement(ps.Consumer,null,n=>r(n)):r(ms)}function vs(e){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:[]}]})(e)}function yd(e){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:[]}]})(e)}function xd(e){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:[]}]})(e)}function xr({content:e,ariaLabel:r="Más información",className:n=""}){return t.jsx(nr,{as:"span",content:e,className:`inline-flex shrink-0 align-middle text-[var(--text-muted)] outline-none transition-colors hover:text-[var(--primary)] focus-visible:text-[var(--primary)] ${n}`,children:t.jsx("span",{tabIndex:0,role:"img","aria-label":r,className:"inline-flex items-center justify-center outline-none",children:t.jsx(q.HiInformationCircle,{className:"h-3.5 w-3.5"})})})}function wr({error:e,helperText:r,helperDisplay:n="inline"}){return e?t.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:e}):r&&n!=="tooltip"?t.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:r}):null}function Tn({className:e="",...r}){return t.jsx("input",{...r,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)] ${e}`})}function ja({label:e,containerClassName:r="",helperText:n,helperDisplay:a="inline",error:s,errorDisplay:l="inline",errorTooltipLabel:i="Error de validacion",labelAction:c,floatingLabel:d=!1,showPasswordToggle:u=!0,nativeValidation:m=!1,className:b="",required:f,...g}){const[v,k]=o.useState(()=>!!g.autoFocus),[h,C]=o.useState(!1),M=g.type==="password"&&u,y=M&&h?"text":g.type,x=!!s,w=x&&l!=="tooltip",N=x&&l!=="inline",A=!!n&&a==="tooltip"&&!w,T=m?f:void 0,U=x?"border-[var(--danger)] focus:border-[var(--danger)]":"",K=N?M?"pr-20":"pr-10":M?"pr-10":"",Z=g.value!==void 0?String(g.value).length>0:g.defaultValue!==void 0&&String(g.defaultValue).length>0,L=v||Z,Q={top:L?7:12,color:v?"var(--primary)":"var(--text-muted)",fontSize:L?10:13,fontWeight:L?600:400,textTransform:L?"uppercase":"none"},z=B=>{var le;k(!0),(le=g.onFocus)==null||le.call(g,B)},se=B=>{var le;k(!1),(le=g.onBlur)==null||le.call(g,B)},re=M?t.jsxs("button",{type:"button","aria-label":h?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":h,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors duration-200 hover:text-[var(--primary)] focus:outline-none",tabIndex:-1,onClick:()=>C(B=>!B),children:[t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${h?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:t.jsx(yd,{className:"h-[18px] w-[18px]"})}),t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${h?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:t.jsx(xd,{className:"h-[18px] w-[18px]"})})]}):null,R=N?t.jsx(nr,{as:"span",content:s,className:`absolute top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--danger)] outline-none transition-colors hover:bg-[var(--danger-bg)] focus-visible:bg-[var(--danger-bg)] ${M?"right-10":"right-2.5"}`,children:t.jsx("span",{tabIndex:0,role:"img","aria-label":i,className:"flex h-full w-full items-center justify-center outline-none",children:t.jsx(vs,{className:"h-[18px] w-[18px]"})})}):null,V=t.jsx(wr,{error:w?s:void 0,helperText:n,helperDisplay:a});return d?t.jsxs("label",{className:`flex flex-col gap-2 ${r}`,children:[t.jsxs("span",{className:"relative block",children:[t.jsx(Tn,{...g,type:y,required:T,placeholder:" ","aria-invalid":x||g["aria-invalid"],"data-has-value":Z?"true":void 0,className:`h-11 w-full pt-5 ${K} ${U} ${b}`,onFocus:z,onBlur:se}),t.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:Q,children:[e,f&&t.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),c&&t.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:L?7:12},children:c}),R,re]}),V]}):t.jsxs("label",{className:`flex flex-col gap-2 ${r}`,children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[t.jsx("span",{children:e}),f&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),A?t.jsx(xr,{content:n}):null,c&&t.jsx("span",{className:"ml-auto normal-case",children:c})]}),M?t.jsxs("span",{className:"relative block",children:[t.jsx(Tn,{...g,type:y,required:T,"aria-invalid":x||g["aria-invalid"],className:`w-full ${K} ${U} ${b}`,onFocus:z,onBlur:se}),R,re]}):t.jsxs("span",{className:"relative block",children:[t.jsx(Tn,{...g,required:T,"aria-invalid":x||g["aria-invalid"],className:`w-full ${K} ${U} ${b}`}),R]}),V]})}function ys(e){return e==null?"":String(e)}function wd({autoComplete:e="email",inputMode:r="email",validate:n=!0,invalidMessage:a="Ingresa un correo valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:d,...u}){const[m,b]=o.useState(()=>ys(c)),f=i!==void 0?ys(i):m,g=n&&f.length>0&&!_a(f)?a:void 0,v=k=>{i===void 0&&b(k.currentTarget.value),d==null||d(k)};return t.jsx(ja,{...u,value:i,defaultValue:c,type:"text",inputMode:r,autoComplete:e,error:l??g,errorDisplay:s,onChange:v})}const Nd={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function kd({title:e="Sin resultados",description:r,icon:n=t.jsx(q.HiInbox,{className:"h-5 w-5"}),action:a,secondaryAction:s,size:l="md",className:i=""}){return t.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${Nd[l]} ${i}`,children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[n&&t.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:n}),t.jsxs("div",{className:"space-y-1",children:[e&&t.jsx("h3",{className:"text-sm font-semibold text-[var(--text-main)]",children:e}),r&&t.jsx("div",{className:"text-sm leading-5 text-[var(--text-muted)]",children:r})]}),(a||s)&&t.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[s,a]})]})})}const Sd={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function Cd(e){if(e===0)return"0 B";const r=["B","KB","MB","GB"],n=Math.min(Math.floor(Math.log(e)/Math.log(1024)),r.length-1),a=e/1024**n;return`${a>=10||n===0?a.toFixed(0):a.toFixed(1)} ${r[n]}`}function xs(e,r){return r?r.split(",").map(n=>n.trim().toLowerCase()).filter(Boolean).some(n=>{const a=e.name.toLowerCase(),s=e.type.toLowerCase();return n.startsWith(".")?a.endsWith(n):n.endsWith("/*")?s.startsWith(n.slice(0,-1)):s===n}):!0}function Ed(e,r,n){return r?n===void 0?e:e.slice(0,Math.max(0,n)):e.slice(0,1)}function Md({label:e,helperText:r,helperDisplay:n="inline",error:a,labelAction:s,value:l,defaultValue:i=[],onFilesChange:c,onRejectedFiles:d,multiple:u=!1,maxFiles:m,appendFiles:b=!1,showFileList:f=!0,clearable:g=!0,browseLabel:v="Buscar archivos",dropLabel:k="Suelta los archivos aqui",emptyLabel:h="Arrastra y suelta archivos",emptyDescription:C="o haz click para buscarlos en tu equipo",selectedLabel:M="Archivos seleccionados",size:y="md",containerClassName:x="",dropzoneClassName:w="",fileListClassName:N="",className:A="",id:T,accept:U,disabled:K,required:Z,...L}){const Q=o.useId(),z=T??Q,se=o.useRef(null),[re,R]=o.useState(!1),[V,B]=o.useState(i),le=l??V,j=!!a,W=!!r&&n==="tooltip"&&!j,ae=g&&le.length>0&&!K,H=(P,ce)=>{l===void 0&&B(P),c==null||c(P,ce)},D=(P,ce)=>{const he=P.filter(Le=>xs(Le,U)),ie=P.filter(Le=>!xs(Le,U)),ge=b?[...le,...he]:he,Te=Ed(ge,u,m);ie.length>0&&(d==null||d(ie)),H(Te,ce)},$=()=>{var P;K||(P=se.current)==null||P.click()},oe=P=>{D(Array.from(P.target.files??[]),P),P.target.value=""},G=P=>{P.preventDefault(),K||R(!0)},X=P=>{P.currentTarget.contains(P.relatedTarget)||R(!1)},S=P=>{P.preventDefault(),R(!1),!K&&D(Array.from(P.dataTransfer.files),P)},O=P=>{P.key!=="Enter"&&P.key!==" "||(P.preventDefault(),$())},I=P=>{H(le.filter((ce,he)=>he!==P))},te=()=>{H([])};return t.jsxs("div",{className:`flex flex-col gap-2 ${x}`,children:[(e||s||W)&&t.jsxs("div",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e&&t.jsx("span",{children:e}),Z&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),W?t.jsx(xr,{content:r}):null,s&&t.jsx("span",{className:"ml-auto normal-case",children:s})]}),t.jsx("input",{...L,ref:se,id:z,type:"file",accept:U,multiple:u,disabled:K,required:Z&&le.length===0,"aria-invalid":j||L["aria-invalid"],className:"sr-only",onChange:oe}),t.jsxs("div",{role:"button",tabIndex:K?-1:0,"aria-controls":z,"aria-disabled":K||void 0,"aria-invalid":j||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)] ${Sd[y]} ${re?"border-[var(--primary)] bg-[var(--bg-input)]":j?"border-[var(--danger)]":"border-[var(--border)]"} ${K?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${w} ${A}`,onClick:$,onDragOver:G,onDragLeave:X,onDrop:S,onKeyDown:O,children:[t.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:t.jsx(q.HiArrowUpTray,{className:"h-5 w-5"})}),t.jsxs("span",{className:"space-y-1",children:[t.jsx("span",{className:"block text-sm font-semibold text-[var(--text-main)]",children:re?k:h}),C&&t.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:C})]}),v&&t.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:v})]}),f&&le.length>0&&t.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${N}`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-2",children:[t.jsx("span",{className:"text-xs font-semibold uppercase text-[var(--text-muted)]",children:M}),ae&&t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":"Quitar todos los archivos",onClick:te,children:t.jsx(q.HiTrash,{className:"h-4 w-4"})})]}),t.jsx("ul",{className:"divide-y divide-[var(--border)]",children:le.map((P,ce)=>t.jsxs("li",{className:"flex items-center gap-3 px-3 py-2",children:[t.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:t.jsx(q.HiDocument,{className:"h-4 w-4"})}),t.jsxs("span",{className:"min-w-0 flex-1 text-left",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-[var(--text-main)]",children:P.name}),t.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:Cd(P.size)})]}),!K&&t.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 ${P.name}`,onClick:()=>I(ce),children:t.jsx(q.HiXMark,{className:"h-4 w-4"})})]},`${P.name}-${P.lastModified}-${ce}`))})]}),t.jsx(wr,{error:a,helperText:r,helperDisplay:n})]})}const Td=[{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 $d({fields:e,title:r="Layout",fieldTypes:n=Td,saveLabel:a="Guardar",allowAddField:s=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:d,onChange:u}){const[m,b]=o.useState(()=>e.map(y=>({key:!1,type:"",...y}))),[f,g]=o.useState(""),[v,k]=o.useState(""),h=o.useCallback((y,x)=>{b(w=>{const N=w.map((A,T)=>T===y?{...A,...x}:A);return u==null||u(N),N})},[u]),C=o.useCallback(()=>{d==null||d(m)},[m,d]),M=o.useCallback(()=>{var N;const y=f.trim();if(!y){k("Ingresa un nombre de campo.");return}if(m.some(A=>A.name.toLowerCase()===y.toLowerCase())){k("Ese campo ya existe en el arreglo.");return}const w={name:y,key:!1,type:((N=n[0])==null?void 0:N.value)??""};b(A=>{const T=[...A,w];return u==null||u(T),T}),g(""),k("")},[n,m,f,u]);return t.jsxs("div",{className:"flex flex-col rounded-xl border shadow-sm",style:{borderColor:"var(--border)",background:"var(--bg-card)",color:"var(--text-main)"},children:[t.jsx("div",{className:"border-b px-6 py-4",style:{borderColor:"var(--border)"},children:t.jsx("span",{className:"text-base font-semibold",style:{color:"var(--text-main)"},children:r})}),t.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:[t.jsx("span",{children:"Campo"}),t.jsx("span",{className:"text-center",children:"Llave"}),t.jsx("span",{children:"Tipo de Campo"})]}),t.jsxs("div",{className:"max-h-[420px] overflow-y-auto",children:[m.map((y,x)=>t.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:[t.jsx("span",{className:"text-sm font-medium",style:{color:"var(--text-main)"},children:y.name}),t.jsx("div",{className:"flex justify-center",children:t.jsx(vn,{size:"sm",checked:y.key??!1,onChange:w=>h(x,{key:w.target.checked}),"aria-label":`${y.name} es clave`})}),t.jsx(ar,{value:y.type??"",onChange:w=>h(x,{type:w}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${y.name}`})]},y.name)),m.length===0&&t.jsx("p",{className:"px-6 py-8 text-center text-sm",style:{color:"var(--text-muted)"},children:"No hay campos disponibles."})]}),t.jsx("div",{className:"flex justify-end border-t px-6 py-4",style:{borderColor:"var(--border)"},children:t.jsxs("div",{className:"w-full space-y-2",children:[s&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:f,onChange:y=>{g(y.currentTarget.value),v&&k("")},onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),M())},placeholder:l,className:"min-w-0 flex-1 rounded-lg border px-3 py-2 text-sm outline-none transition-colors",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"},"aria-label":"Nombre del nuevo campo"}),t.jsx(Ue,{variant:"secondary",onClick:M,height:36,padding:"0 12px",children:i})]}),v&&t.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:v})]}),t.jsx("div",{className:"flex justify-end",children:t.jsx(Ue,{variant:"primary",onClick:C,disabled:c,loading:c,children:a})})]})})]})}function $n({label:e,children:r,helperText:n,helperDisplay:a="inline",error:s,labelAction:l,required:i=!1,className:c="",contentClassName:d=""}){const u=!!n&&a==="tooltip"&&!s;return t.jsxs("label",{className:`flex flex-col gap-2 ${c}`,children:[(e||l||u)&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e&&t.jsx("span",{children:e}),i&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),u?t.jsx(xr,{content:n}):null,l&&t.jsx("span",{className:"ml-auto normal-case",children:l})]}),t.jsx("span",{className:`block ${d}`,children:r}),t.jsx(wr,{error:s,helperText:n,helperDisplay:a})]})}function Ad(e){return Array.from(e.querySelectorAll("img")).filter(r=>!!(r.currentSrc||r.src||"").trim())}function ws(e,r){const n=e.target;if(!(n instanceof HTMLImageElement))return!1;const a=e.currentTarget,s=Ad(a),l=s.indexOf(n);if(l<0)return!1;e.preventDefault(),e.stopPropagation();const i=n.getBoundingClientRect();return r(s.map(c=>({src:c.currentSrc||c.src,alt:c.alt||void 0})),l,{left:i.left,top:i.top,width:i.width,height:i.height}),!0}const Mt=260,Nr=420,qa=380,Lt="cubic-bezier(0.22, 1, 0.36, 1)",Ld="cubic-bezier(0.16, 1, 0.3, 1)",Ua="cubic-bezier(0.22, 1, 0.36, 1)",Dd="cubic-bezier(0.22, 1, 0.36, 1)",Id=8,Od=1,Hd=1.25,Va={background:"color-mix(in srgb, var(--bg-card) 90%, transparent)",border:"1px solid var(--border)",boxShadow:"0 10px 28px color-mix(in srgb, var(--bg-main) 28%, transparent), inset 0 1px 0 color-mix(in srgb, var(--bg-card) 55%, transparent)",color:"var(--text-main)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)"},Bd="color-mix(in srgb, var(--bg-card) 88%, var(--primary) 12%)",Ya=10;function Rr(e,r,n){return Math.min(n,Math.max(r,e))}function Fd(e){return!e||e.width<1||e.height<1?null:{left:e.left,top:e.top,width:e.width,height:e.height}}function Ns(e,r){if(r.width<1||r.height<1)return{dx:0,dy:0,scale:1};const n=Math.min(e.width/r.width,e.height/r.height),a=e.left+e.width/2-(r.left+r.width/2),s=e.top+e.height/2-(r.top+r.height/2);return{dx:a,dy:s,scale:Number.isFinite(n)?n:1}}function kr({label:e,onClick:r,children:n,disabled:a,size:s="md"}){const l=s==="lg"?44:40;return t.jsx("button",{type:"button","aria-label":e,title:e,disabled:a,onClick:i=>{i.stopPropagation(),r()},className:"inline-flex items-center justify-center rounded-full disabled:cursor-not-allowed disabled:opacity-35",style:{...Va,width:l,height:l,transition:"background 160ms ease, transform 160ms cubic-bezier(0.22, 1, 0.36, 1), opacity 160ms ease"},onMouseEnter:i=>{a||(i.currentTarget.style.background=Bd,i.currentTarget.style.transform="scale(1.06)")},onMouseLeave:i=>{i.currentTarget.style.background=String(Va.background??""),i.currentTarget.style.transform="scale(1)"},onMouseDown:i=>{a||(i.currentTarget.style.transform="scale(0.94)")},onMouseUp:i=>{a||(i.currentTarget.style.transform="scale(1.06)")},children:n})}function ks({open:e,onClose:r,slides:n,index:a,onIndexChange:s,originRect:l=null,maxZoom:i=Id,minZoom:c=Od,zoomStep:d=Hd,closeOnBackdrop:u=!0,closeOnEscape:m=!0,showCounter:b=!0,showZoomControls:f=!0,loop:g=!0,showThumbnails:v=!0,zIndex:k=1100,ariaLabel:h="Visor de imagen"}){const[C,M]=o.useState(!1),[y,x]=o.useState(!1),[w,N]=o.useState(a??0),[A,T]=o.useState(1),[U,K]=o.useState({x:0,y:0}),[Z,L]=o.useState({opacity:1,x:0,scale:1,blur:0,animate:!1}),[Q,z]=o.useState({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),[se,re]=o.useState(!1),R=o.useRef(null),V=o.useRef(null),B=o.useRef(null),le=o.useRef(null),j=o.useRef(null),W=o.useRef(!1),ae=o.useRef(!1),H=o.useRef(null),D=o.useRef(null),$=o.useRef(null),oe=o.useRef(null),G=o.useRef(null),X=o.useRef(a??0),S=a??w,O=n.length===0?0:Rr(S,0,Math.max(0,n.length-1)),I=n[O],te=n.length>1,P=Math.max(c,i),ce=v&&te,he=o.useCallback(de=>{if(n.length===0)return;const pe=n.length-1,Me=g?(de%n.length+n.length)%n.length:Rr(de,0,pe);a===void 0&&N(Me),s==null||s(Me)},[a,g,s,n.length]),ie=o.useCallback(()=>{T(1),K({x:0,y:0})},[]),ge=o.useCallback((de,pe)=>{if(pe<=c+.001)return{x:0,y:0};const Me=oe.current,Pe=G.current;if(!Me||!Pe)return de;const Be=Me.getBoundingClientRect(),Fe=Pe.offsetWidth*pe,tt=Pe.offsetHeight*pe,rt=Math.max(0,(Fe-Be.width)/2+Be.width*.15),Ke=Math.max(0,(tt-Be.height)/2+Be.height*.15);return{x:Rr(de.x,-rt,rt),y:Rr(de.y,-Ke,Ke)}},[c]),Te=o.useCallback(()=>{M(!1),z({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),le.current=null,j.current=null,W.current=!1,ae.current=!1,H.current&&(clearTimeout(H.current),H.current=null)},[]),Le=o.useCallback(()=>{if(W.current)return;W.current=!0,x(!1),ie();const de=le.current,pe=de!=null&&j.current!=null&&j.current===O;if(de&&pe){B.current!=null&&cancelAnimationFrame(B.current),B.current=requestAnimationFrame(()=>{B.current=requestAnimationFrame(()=>{const Me=G.current;if(!Me){B.current=null,R.current&&clearTimeout(R.current),R.current=setTimeout(Te,Mt+40);return}const Pe=Me.getBoundingClientRect(),Be=Ns(de,Pe);z({enabled:!0,dx:0,dy:0,scale:1,animate:!1}),B.current=requestAnimationFrame(()=>{z({enabled:!0,dx:Be.dx,dy:Be.dy,scale:Be.scale,animate:!0}),B.current=null})})}),R.current&&clearTimeout(R.current),R.current=setTimeout(Te,Nr+80);return}z({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),R.current&&clearTimeout(R.current),R.current=setTimeout(Te,Mt+40)},[Te,ie,O]);o.useEffect(()=>(e?(R.current&&clearTimeout(R.current),H.current&&(clearTimeout(H.current),H.current=null),W.current=!1,ae.current=!1,le.current=Fd(l),j.current=le.current!=null?a??w:null,M(!0),x(!1),le.current?z({dx:0,dy:0,scale:1,animate:!1,enabled:!0}):(j.current=null,requestAnimationFrame(()=>requestAnimationFrame(()=>{x(!0),z({dx:0,dy:0,scale:1,animate:!1,enabled:!1})})))):C&&Le(),()=>{R.current&&clearTimeout(R.current),B.current!=null&&cancelAnimationFrame(B.current)}),[e]);const It=o.useCallback(()=>{if(!e||W.current||ae.current)return;const de=le.current,pe=G.current;if(!de||!pe){de||(x(!0),ae.current=!0);return}const Me=pe.getBoundingClientRect();if(Me.width<2||Me.height<2)return;ae.current=!0;const Pe=Ns(de,Me);z({enabled:!0,dx:Pe.dx,dy:Pe.dy,scale:Pe.scale,animate:!1}),B.current!=null&&cancelAnimationFrame(B.current),B.current=requestAnimationFrame(()=>{B.current=requestAnimationFrame(()=>{z({enabled:!0,dx:0,dy:0,scale:1,animate:!0}),x(!0),B.current=null,H.current&&clearTimeout(H.current),H.current=setTimeout(()=>{z({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),H.current=null},Nr+20)})})},[e]);o.useLayoutEffect(()=>{!C||!e||!le.current||ae.current||It()},[C,e,It]),o.useEffect(()=>{!e||W.current||j.current!=null&&j.current!==O&&z(de=>de.enabled?{dx:0,dy:0,scale:1,animate:!1,enabled:!1}:de)},[e,O]),o.useEffect(()=>{if(!e)return;const de=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=de}},[e]),o.useEffect(()=>{e&&ie()},[e,O,ie]),o.useEffect(()=>{a!==void 0&&N(a)},[a]),o.useEffect(()=>{if(!e){X.current=O,L({opacity:1,x:0,scale:1,blur:0,animate:!1});return}const de=X.current;if(de===O)return;X.current=O;const pe=n.length;let Me=1;if(pe>1){const Pe=(de+1)%pe===O,Be=(de-1+pe)%pe===O;Be&&!Pe?Me=-1:Pe&&!Be?Me=1:Me=O>de?1:-1}return V.current!=null&&(cancelAnimationFrame(V.current),V.current=null),L({opacity:0,x:Me*56,scale:.94,blur:8,animate:!1}),V.current=requestAnimationFrame(()=>{V.current=requestAnimationFrame(()=>{L({opacity:1,x:0,scale:1,blur:0,animate:!0}),V.current=null})}),()=>{V.current!=null&&(cancelAnimationFrame(V.current),V.current=null)}},[e,O,n.length]);const ft=A<=c+.001&&Math.abs(U.x)<.5&&Math.abs(U.y)<.5,Qe=o.useCallback((de,pe,Me)=>{T(Pe=>{const Be=Rr(de,c,P);if(Math.abs(Be-Pe)<1e-4)return Pe;const Fe=Be/Pe,tt=Be<Pe;return Be<=c+.001?(K({x:0,y:0}),c):(K(rt=>{let Ke=rt;if(typeof pe=="number"&&typeof Me=="number"&&oe.current&&!tt){const nt=oe.current.getBoundingClientRect(),Oe=pe-nt.left-nt.width/2,Ht=Me-nt.top-nt.height/2;Ke={x:Oe-(Oe-rt.x)*Fe,y:Ht-(Ht-rt.y)*Fe}}else if(tt){Ke={x:rt.x*Fe,y:rt.y*Fe};const nt=Math.min(1,(Pe-Be)/Math.max(.01,Pe-c));Ke={x:Ke.x*(1-nt*.65),y:Ke.y*(1-nt*.65)}}else Ke={x:rt.x*Fe,y:rt.y*Fe};return ge(Ke,Be)}),Be)})},[ge,c,P]),Ot=o.useCallback(()=>{Qe(A*d)},[Qe,A,d]),Se=o.useCallback(()=>{const de=Math.max(c,A/d);if(de<=c+.001){ie();return}T(de),K({x:0,y:0})},[c,ie,A,d]);o.useEffect(()=>{if(!e)return;const de=pe=>{if(pe.key==="Escape"&&m){pe.preventDefault(),r();return}pe.key==="ArrowLeft"&&te?(pe.preventDefault(),he(O-1)):pe.key==="ArrowRight"&&te?(pe.preventDefault(),he(O+1)):pe.key==="+"||pe.key==="="?(pe.preventDefault(),Qe(A*d)):pe.key==="-"||pe.key==="_"?(pe.preventDefault(),Se()):pe.key==="0"&&(pe.preventDefault(),ie())};return window.addEventListener("keydown",de),()=>window.removeEventListener("keydown",de)},[Qe,m,te,r,e,ie,O,A,he,Se,d]);const lt=de=>{de.preventDefault();const pe=de.deltaY>0?1/d:d;Qe(A*pe,de.clientX,de.clientY)},me=de=>{A<=c+.001||(de.currentTarget.setPointerCapture(de.pointerId),re(!0),D.current={pointerId:de.pointerId,startX:de.clientX,startY:de.clientY,originX:U.x,originY:U.y})},Ye=de=>{const pe=D.current;!pe||pe.pointerId!==de.pointerId||K(ge({x:pe.originX+(de.clientX-pe.startX),y:pe.originY+(de.clientY-pe.startY)},A))},qe=de=>{var pe;((pe=D.current)==null?void 0:pe.pointerId)===de.pointerId&&(D.current=null,re(!1))},ct=de=>{if(de.stopPropagation(),A>c+.05){ie();return}Qe(Math.min(P,3),de.clientX,de.clientY)},ze=de=>{if(de.touches.length!==2)return;re(!0);const[pe,Me]=[de.touches[0],de.touches[1]],Pe=Math.hypot(pe.clientX-Me.clientX,pe.clientY-Me.clientY);$.current={distance:Pe,scale:A}},bt=de=>{if(de.touches.length!==2||!$.current)return;de.preventDefault();const[pe,Me]=[de.touches[0],de.touches[1]],Pe=Math.hypot(pe.clientX-Me.clientX,pe.clientY-Me.clientY),Be=(pe.clientX+Me.clientX)/2,Fe=(pe.clientY+Me.clientY)/2,tt=$.current.scale*(Pe/Math.max(1,$.current.distance));Qe(tt,Be,Fe)},mt=()=>{$.current=null,re(!1)};if(!C||!I)return null;const et=Q.enabled,Kt=Q.animate?`transform ${Nr}ms ${Dd}`:"none";return dt.createPortal(t.jsxs("div",{className:"fixed inset-0",style:{zIndex:k},role:"dialog","aria-modal":"true","aria-label":h,children:[t.jsx("button",{type:"button","aria-label":"Cerrar",className:"absolute inset-0 border-0",style:{background:"color-mix(in srgb, var(--bg-sidebar, var(--primary)) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",opacity:y?1:0,transition:`opacity ${et?Nr:Mt}ms ${Lt}`,cursor:"default",zIndex:0},onClick:()=>{u&&r()}}),t.jsx("div",{ref:oe,className:"absolute inset-0 flex items-center justify-center",style:{zIndex:1,padding:ce?"4.5rem 3.5rem 6.5rem":"4.5rem 3.5rem 2.5rem",opacity:et||y?1:0,transform:et||y?"translateY(0) scale(1)":"translateY(10px) scale(0.96)",transition:et?"none":`opacity ${Mt}ms ${Lt}, transform ${Mt}ms ${Lt}`},onClick:de=>{de.target===de.currentTarget&&u&&r()},onWheel:lt,children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{transform:Q.enabled?`translate3d(${Q.dx}px, ${Q.dy}px, 0) scale(${Q.scale})`:void 0,transformOrigin:"center center",transition:Q.enabled?Kt:void 0},children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{opacity:Z.opacity,filter:Z.blur?`blur(${Z.blur}px)`:"blur(0px)",transform:`translate3d(${Z.x}px, 0, 0) scale(${Z.scale})`,transition:Z.animate?[`opacity ${qa}ms ${Ua}`,`transform ${qa}ms ${Ua}`,`filter ${qa}ms ${Ua}`].join(", "):"none"},children:t.jsx("div",{ref:G,className:"pointer-events-auto relative max-h-full max-w-full touch-none select-none will-change-transform",style:{cursor:A>c+.001?"grab":"zoom-in",transform:`translate3d(${U.x}px, ${U.y}px, 0) scale(${A})`,transformOrigin:"center center",transition:se?"none":`transform 220ms ${Ld}`},onClick:de=>de.stopPropagation(),onDoubleClick:ct,onPointerDown:me,onPointerMove:Ye,onPointerUp:qe,onPointerCancel:qe,onTouchStart:ze,onTouchMove:bt,onTouchEnd:mt,children:t.jsx("img",{src:I.src,alt:I.alt||"",draggable:!1,className:"block max-h-[min(78vh,820px)] max-w-[min(86vw,1100px)] object-contain",style:{display:"block",borderRadius:Ya,imageRendering:A>2.5?"pixelated":"auto"},onLoad:()=>{It()}},I.src+String(O))})})})}),t.jsxs("div",{className:"pointer-events-none absolute inset-0",style:{zIndex:2,opacity:y?1:0,transform:y?"translateY(0)":"translateY(-6px)",transition:`opacity ${et?Nr:Mt}ms ${Lt}, transform ${et?Nr:Mt}ms ${Lt}`},children:[t.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 flex items-center justify-between gap-3 px-4 pt-4",children:[t.jsx("div",{className:"pointer-events-auto flex items-center gap-2",children:b&&n.length>0?t.jsxs("span",{className:"rounded-full px-3 py-1.5 text-xs font-semibold tracking-wide",style:Va,children:[O+1," / ",n.length]}):null}),t.jsxs("div",{className:"pointer-events-auto flex items-center gap-2",children:[f?t.jsxs(t.Fragment,{children:[t.jsx(kr,{label:"Alejar",onClick:Se,disabled:A<=c+.001,children:t.jsx(q.HiMinus,{className:"h-5 w-5"})}),t.jsx(kr,{label:"Restablecer tamaño",onClick:ie,disabled:ft,children:t.jsx(q.HiArrowsPointingIn,{className:"h-5 w-5"})}),t.jsx(kr,{label:"Acercar",onClick:Ot,disabled:A>=P-.001,children:t.jsx(q.HiPlus,{className:"h-5 w-5"})})]}):null,t.jsx(kr,{label:"Cerrar",onClick:r,children:t.jsx(q.HiXMark,{className:"h-5 w-5"})})]})]}),te?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"pointer-events-auto absolute left-3 top-1/2",style:{opacity:y?1:0,transform:y?"translate(0, -50%)":"translate(-8px, -50%)",transition:`opacity ${Mt}ms ${Lt}, transform ${Mt}ms ${Lt}`},children:t.jsx(kr,{label:"Anterior",size:"lg",onClick:()=>he(O-1),disabled:!g&&O<=0,children:t.jsx(q.HiChevronLeft,{className:"h-6 w-6"})})}),t.jsx("div",{className:"pointer-events-auto absolute right-3 top-1/2",style:{opacity:y?1:0,transform:y?"translate(0, -50%)":"translate(8px, -50%)",transition:`opacity ${Mt}ms ${Lt}, transform ${Mt}ms ${Lt}`},children:t.jsx(kr,{label:"Siguiente",size:"lg",onClick:()=>he(O+1),disabled:!g&&O>=n.length-1,children:t.jsx(q.HiChevronRight,{className:"h-6 w-6"})})})]}):null,ce?t.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex justify-center px-4 pb-4 pt-8",style:{background:"linear-gradient(to top, color-mix(in srgb, var(--bg-sidebar, var(--primary)) 72%, transparent), transparent)"},children:t.jsx("div",{className:"pointer-events-auto flex max-w-full items-end gap-2.5 overflow-x-auto rounded-2xl px-2 py-2",style:{background:"color-mix(in srgb, var(--bg-card) 55%, transparent)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",scrollbarWidth:"thin"},role:"tablist","aria-label":"Miniaturas",children:n.map((de,pe)=>{const Me=pe===O;return t.jsx("button",{type:"button",role:"tab","aria-selected":Me,"aria-label":de.alt||`Imagen ${pe+1}`,onClick:Pe=>{Pe.stopPropagation(),he(pe)},className:"relative shrink-0 overflow-hidden transition-opacity",style:{width:56,height:42,borderRadius:Ya,opacity:Me?1:.42,transition:`opacity 180ms ${Lt}`},children:t.jsx("img",{src:de.src,alt:"",draggable:!1,className:"h-full w-full object-cover",style:{borderRadius:Ya}})},`${de.src}-${pe}`)})})}):null]})]}),document.body)}function Pd({children:e,className:r,style:n,maxZoom:a,minZoom:s,zoomStep:l,loop:i,showThumbnails:c}){const[d,u]=o.useState(!1),[m,b]=o.useState(0),[f,g]=o.useState([]),[v,k]=o.useState(null),h=o.useCallback((M,y,x)=>{g(M),k(x??null),b(y),u(!0)},[]),C=o.useCallback(M=>{ws(M,h)},[h]);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`[&_img]:cursor-zoom-in ${r??""}`,style:n,onClick:C,children:e}),t.jsx(ks,{open:d,onClose:()=>u(!1),index:m,onIndexChange:b,slides:f,originRect:v,maxZoom:a,minZoom:s,zoomStep:l,loop:i,showThumbnails:c})]})}function Ss(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Cs(e,r){if(e.length!==r.length)return!1;const n=new Set(r);return e.every(a=>n.has(a))}function Xa(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function _d(e,r){if(!r)return!0;const n=Xa(r);return Xa(e.label).includes(n)||!!(e.sublabel&&Xa(e.sublabel).includes(n))}function zd({value:e,onChange:r,options:n,placeholder:a="Seleccionar…",disabled:s=!1,className:l="",style:i,height:c=40,padding:d="6px 10px",searchable:u=!0,minOptionsForSearch:m=6,maxVisibleValues:b=2,truncateSelectedValues:f=!0,emptyText:g="Sin resultados",clearLabel:v="Limpiar seleccion",pruneMissingValues:k=!0}){const[h,C]=o.useState(!1),[M,y]=o.useState(""),[x,w]=o.useState(0),[N,A]=o.useState(!1),[T,U]=o.useState({}),K=o.useRef(null),Z=o.useRef(null),L=o.useRef(null),Q=o.useRef(null),z=u&&n.length>=m,se=o.useMemo(()=>new Set(e),[e]),re=o.useMemo(()=>{const S=new Map;for(const O of n)S.set(O.value,O);return S},[n]),R=o.useMemo(()=>{const S=[];for(const O of e){const I=re.get(O);I&&S.push(I)}return S},[re,e]),V=b==="all"?R.length:b,B=R.slice(0,V),le=Math.max(0,R.length-B.length),j=o.useMemo(()=>{const S=M.trim();return!z||!S?n:n.filter(O=>_d(O,S))},[n,M,z]),W=o.useCallback(()=>{const S=K.current;if(!S)return;const O=S.getBoundingClientRect(),I=z?304:244,te=window.innerHeight-O.bottom,P=te<I&&O.top>te;U({position:"fixed",left:O.left,top:P?void 0:O.bottom+4,bottom:P?window.innerHeight-O.top+4:void 0,width:Math.max(O.width,240),zIndex:9999})},[z]),ae=o.useCallback(S=>{Cs(e,S)||r(S)},[r,e]),H=o.useCallback(S=>{const O=re.get(S);if(O!=null&&O.disabled)return;const I=se.has(S)?e.filter(te=>te!==S):[...e,S];ae(I)},[ae,re,e,se]),D=o.useCallback(()=>ae([]),[ae]),$=o.useCallback(()=>{C(!1),y(""),w(0)},[]);o.useEffect(()=>A(!0),[]);const oe=o.useMemo(()=>n.map(S=>S.value).join("\0"),[n]);o.useEffect(()=>{if(!k||e.length===0||n.length===0)return;const S=new Set(n.map(I=>I.value)),O=e.filter(I=>S.has(I));Cs(e,O)||r(O)},[oe]),o.useEffect(()=>{if(!h)return;function S(O){var te,P;const I=O.target;!((te=K.current)!=null&&te.contains(I))&&!((P=Z.current)!=null&&P.contains(I))&&$()}return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[$,h]),o.useEffect(()=>{h&&(w(0),W(),z&&setTimeout(()=>{var S;return(S=L.current)==null?void 0:S.focus()},0))},[h,z,W]),o.useEffect(()=>{if(h)return window.addEventListener("resize",W),window.addEventListener("scroll",W,!0),()=>{window.removeEventListener("resize",W),window.removeEventListener("scroll",W,!0)}},[h,W]),o.useEffect(()=>{if(j.length===0){w(0);return}w(S=>Math.min(S,j.length-1))},[j.length]),o.useEffect(()=>{if(x<0||!Q.current)return;const S=Q.current.children[x];S==null||S.scrollIntoView({block:"nearest"})},[x]);function G(S){if(!s){if(!h){(S.key==="Enter"||S.key===" "||S.key==="ArrowDown")&&(S.preventDefault(),C(!0));return}if(S.key==="Escape"){S.preventDefault(),$();return}if(S.key==="ArrowDown"){if(S.preventDefault(),j.length===0)return;w(O=>Math.min(O+1,j.length-1));return}if(S.key==="ArrowUp"){S.preventDefault(),w(O=>Math.max(O-1,0));return}if(S.key==="Enter"&&j[x]&&!j[x].disabled){S.preventDefault(),H(j[x].value);return}S.key==="Backspace"&&!M&&e.length&&(S.preventDefault(),ae(e.slice(0,-1)))}}const X=t.jsxs("div",{ref:Z,className:"overflow-hidden rounded-xl shadow-xl",style:{...T,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[z&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(q.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:L,value:M,onChange:S=>{y(S.target.value),w(0)},onKeyDown:S=>{(S.key==="ArrowDown"||S.key==="ArrowUp"||S.key==="Enter"||S.key==="Escape")&&(S.stopPropagation(),G(S))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),M&&t.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:S=>{S.preventDefault(),y(""),w(0)},children:t.jsx(q.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),e.length>0&&t.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:[t.jsxs("span",{children:[R.length," seleccionados",e.length>R.length?` (${e.length-R.length} no disponibles)`:""]}),t.jsx("button",{type:"button",onMouseDown:S=>{S.preventDefault(),D()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:v})]}),t.jsxs("ul",{ref:Q,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:z?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[j.map((S,O)=>{const I=O===x,te=se.has(S.value);return t.jsxs("li",{role:"option","aria-selected":te,onMouseDown:P=>{P.preventDefault(),!S.disabled&&H(S.value)},onMouseEnter:()=>!S.disabled&&w(O),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:I?"var(--bg-hover)":te?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:S.disabled?"var(--text-muted)":"var(--text-main)",cursor:S.disabled?"not-allowed":"pointer",opacity:S.disabled?.58:1},children:[t.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:te?"var(--primary)":"var(--border)",background:te?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:te&&t.jsx(q.HiCheck,{className:"h-3 w-3"})}),S.color&&t.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:S.color}}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx("span",{className:"truncate",children:S.label}),S.sublabel&&t.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:S.sublabel})]}),S.badge&&t.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:S.badge})]},S.value)}),j.length===0&&t.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:g})]})]});return t.jsxs("div",{ref:K,className:`relative ${l||"w-full"}`,style:i,onKeyDown:G,children:[t.jsxs("button",{type:"button",disabled:s,onClick:()=>{s||(h?$():C(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:Ss(c),padding:Ss(d),background:"var(--bg-input)",color:R.length?"var(--text-main)":"var(--text-muted)",border:h?"1px solid var(--primary)":"1px solid var(--border)",opacity:s?.5:1,cursor:s?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":h,children:[t.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:B.length?t.jsxs(t.Fragment,{children:[B.map(S=>t.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${f?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[S.color&&t.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:S.color}}),t.jsx("span",{className:f?"truncate":"break-words",children:S.label}),t.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${S.label}`,onMouseDown:O=>{O.preventDefault(),O.stopPropagation(),H(S.value)},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(q.HiXMark,{className:"h-3 w-3"})})]},S.value)),le>0&&t.jsxs("span",{className:"inline-flex items-center rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{background:"color-mix(in srgb, var(--primary) 10%, transparent)",color:"var(--primary)"},children:["+",le]})]}):t.jsx("span",{className:"truncate",children:a})}),R.length?t.jsx("span",{role:"button",tabIndex:-1,"aria-label":v,onMouseDown:S=>{S.preventDefault(),S.stopPropagation(),D()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(q.HiXMark,{className:"h-3.5 w-3.5"})}):t.jsx(q.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:h?"rotate(180deg)":"rotate(0deg)"}})]}),h&&N&&dt.createPortal(X,document.body)]})}function Wd({inputMode:e="decimal",...r}){return t.jsx(ja,{...r,type:"number",inputMode:e})}function jd(e,r,n){const a=[],s=Math.max(2,e-n),l=Math.min(r-1,e+n);a.push(1),s>2&&a.push("...");for(let i=s;i<=l;i+=1)a.push(i);return l<r-1&&a.push("..."),r>1&&a.push(r),a}function qd({page:e,totalPages:r,onPageChange:n,disabled:a=!1,siblingCount:s=1,className:l=""}){const i=Math.max(1,r),c=Math.min(Math.max(1,e),i),d=jd(c,i,s);return t.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[t.jsx(Ue,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:a||c<=1,onClick:()=>n(c-1),children:t.jsx(q.HiChevronLeft,{className:"h-4 w-4"})}),d.map((u,m)=>u==="..."?t.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${m}`):t.jsx("button",{type:"button","aria-current":u===c?"page":void 0,disabled:a,onClick:()=>n(u),className:"flex h-8 min-w-8 items-center justify-center rounded-md border px-2 text-xs font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-50",style:{borderColor:u===c?"var(--primary)":"var(--border)",background:u===c?"var(--primary)":"var(--bg-card)",color:u===c?"var(--primary-fg)":"var(--text-secondary)"},children:u},u)),t.jsx(Ue,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:a||c>=i,onClick:()=>n(c+1),children:t.jsx(q.HiChevronRight,{className:"h-4 w-4"})})]})}const Es=[{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 Ms(e){return e==null?"":String(e)}function An(e){return e?e.startsWith("+")?e:`+${e}`:"+1"}function Ud(e){return typeof e=="number"?`${e}px`:e}function Vd({autoComplete:e="tel",inputMode:r="tel",validate:n=!0,invalidMessage:a="Ingresa un telefono valido.",errorDisplay:s="tooltip",error:l,value:i,defaultValue:c,onChange:d,countryCode:u,defaultCountryCode:m="+1",onCountryCodeChange:b,allowedCountryCodes:f,countryCodeOptions:g,countryCodePlaceholder:v="Codigo",countryCodeClassName:k="",countryCodeWidth:h=84,onPhoneValueChange:C,label:M,containerClassName:y="",helperText:x,helperDisplay:w="inline",labelAction:N,className:A="",required:T,disabled:U,floatingLabel:K,showPasswordToggle:Z,nativeValidation:L,errorTooltipLabel:Q="Error de validacion",...z}){var P;const[se,re]=o.useState(()=>Ms(c)),[R,V]=o.useState(()=>An(m)),B=o.useMemo(()=>{const ce=g??Es,he=f==null?void 0:f.map(An);return he!=null&&he.length?ce.filter(ie=>he.includes(ie.value)):ce},[f,g]),le=((P=B[0])==null?void 0:P.value)??"+1",j=B.some(ce=>ce.value===An(u??R))?An(u??R):le,W=i!==void 0?Ms(i):se,ae=`${j} ${W}`.trim(),H=n&&W.length>0&&!za(ae)?a:void 0,D=l??H,$=!!D,oe=$&&s!=="tooltip",G=$&&s!=="inline",X=!!x&&w==="tooltip"&&!oe,S=$?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",O=ce=>{const he=ce.currentTarget.value;i===void 0&&re(he),C==null||C(he,{countryCode:j,nationalNumber:he,fullNumber:`${j} ${he}`.trim()}),d==null||d(ce)},I=ce=>{u===void 0&&V(ce),b==null||b(ce),C==null||C(W,{countryCode:ce,nationalNumber:W,fullNumber:`${ce} ${W}`.trim()})},te=G?t.jsx(nr,{as:"span",content:D,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:t.jsx("span",{tabIndex:0,role:"img","aria-label":Q,className:"flex h-full w-full items-center justify-center outline-none",children:t.jsx(vs,{className:"h-[18px] w-[18px]"})})}):null;return t.jsxs("div",{className:`flex flex-col gap-2 ${y}`,children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[t.jsx("span",{children:M}),T&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),X?t.jsx(xr,{content:x}):null,N&&t.jsx("span",{className:"ml-auto normal-case",children:N})]}),t.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${S}`,children:[t.jsx(ar,{value:j,onChange:I,options:B,placeholder:v,disabled:U,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${k}`,style:{width:Ud(h)},height:38,padding:"0 8px 0 10px"}),t.jsx("span",{className:"h-5 w-px shrink-0 bg-[var(--border)]"}),t.jsxs("span",{className:"relative min-w-0 flex-1 self-stretch",children:[t.jsx("input",{...z,value:i,defaultValue:c,type:"tel",inputMode:r,autoComplete:e,disabled:U,required:void 0,"aria-label":z["aria-label"]??(typeof M=="string"?M:void 0),"aria-invalid":$||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 ${G?"pr-10":""} ${A}`,onChange:O}),te]})]}),t.jsx(wr,{error:oe?D:void 0,helperText:x,helperDisplay:w})]})}function Yd({value:e,onChange:r,options:n,name:a,label:s,orientation:l="vertical",disabled:i=!1,className:c="",optionClassName:d=""}){return t.jsxs("fieldset",{className:`min-w-0 ${c}`,disabled:i,children:[s&&t.jsx("legend",{className:"mb-2 text-xs font-semibold uppercase text-[var(--text-muted)]",children:s}),t.jsx("div",{className:l==="horizontal"?"flex flex-wrap gap-2":"flex flex-col gap-2",children:n.map(u=>{const m=u.value===e,b=i||u.disabled;return t.jsxs("label",{className:`inline-flex min-w-0 items-start gap-2 rounded-lg border px-2.5 py-1.5 transition-colors ${b?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${d}`,style:{borderColor: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:[t.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:[t.jsx("input",{type:"radio",name:a,value:u.value,checked:m,disabled:b,onChange:()=>r(u.value),className:"absolute inset-0 opacity-0"}),t.jsx("span",{className:`h-2 w-2 rounded-full transition ${m?"scale-100 opacity-100":"scale-50 opacity-0"}`,style:{background:"var(--primary)"}})]}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:u.label}),u.description&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:u.description})]})]},u.value)})})]})}const Xd=new Set(["table","thead","tbody","tfoot","tr","th","td","caption"]),Ln=(e,r,n)=>Math.min(n,Math.max(r,Math.round(e)||r)),Sr=12,Dn=8,Ka=(e,r,n)=>{const a=On(n),s=e.insertRow(r);for(let l=0;l<a;l+=1){const i=s.insertCell(-1);i.innerHTML="<br>"}return s.cells[0]??null},Ts=(e,r)=>{const n=e.rows[r];if(!n)return null;const a=n.parentElement;if(!a)return null;if(a.tagName==="THEAD"){const l=e.tBodies[0]??e.createTBody();return l.rows.length>=Sr?null:Ka(l,0,e)}if(a.tagName==="TBODY"&&a.rows.length>=Sr)return null;const s=Array.from(a.rows).indexOf(n);return Ka(a,s+1,e)},Kd=(e,r)=>{var s;const n=e.rows[r];if(!n)return!1;const a=n.parentElement;return(a==null?void 0:a.tagName)==="TBODY"&&a.rows.length<=1||(a==null?void 0:a.tagName)==="THEAD"&&((s=e.tBodies[0])==null?void 0:s.rows.length)===0&&e.rows.length<=1?!1:(n.remove(),!0)},$s=(e,r)=>On(e)>=Dn?!1:(e.querySelectorAll("tr").forEach(n=>{const a=n.closest("thead")!==null,s=document.createElement(a?"th":"td");a?s.textContent=`Columna ${n.cells.length+1}`:s.innerHTML="<br>";const l=n.cells[r];l!=null&&l.nextSibling?n.insertBefore(s,l.nextSibling):n.appendChild(s)}),!0),Gd=(e,r)=>On(e)<=1?!1:(e.querySelectorAll("tr").forEach(n=>{var a;(a=n.cells[r])==null||a.remove()}),!0),As=e=>{e.querySelectorAll(".rich-table-row-active").forEach(r=>{r.classList.remove("rich-table-row-active")}),e.querySelectorAll(".rich-table-col-active").forEach(r=>{r.classList.remove("rich-table-col-active")})},Ls=(e,r,n)=>{As(e),r&&(r.classList.add("rich-table-row-active"),e.querySelectorAll("tr").forEach(a=>{var s;(s=a.cells[n])==null||s.classList.add("rich-table-col-active")}))},Zd=(e,r,n)=>{const a=e.getBoundingClientRect();return{rowIndex:Array.from(e.rows).indexOf(r),colIndex:n.cellIndex,bar:{x:a.left+a.width/2,y:a.top-6}}},In=e=>{const r=e.cloneNode(!0);return r.querySelectorAll(".rich-table-ui").forEach(n=>n.remove()),r.querySelectorAll(".rich-table-wrap").forEach(n=>{const a=n.querySelector("table");a?n.replaceWith(a):n.remove()}),r.querySelectorAll("table").forEach(n=>{n.classList.add("rich-table")}),r.querySelectorAll(".rich-table-row-active, .rich-table-col-active").forEach(n=>{n.classList.remove("rich-table-row-active","rich-table-col-active")}),r.innerHTML},Ds=e=>{e.querySelectorAll(".rich-table-wrap").forEach(r=>{const n=r.querySelector("table");n&&r.replaceWith(n)}),e.querySelectorAll(".rich-table-ui").forEach(r=>r.remove()),e.querySelectorAll("table").forEach(r=>{r.classList.add("rich-table")})},Qd=(e,r,n,a,s)=>{switch(e){case"table-delete":return r.remove(),!0;case"table-row-add":{const l=Number.isFinite(n)?Ts(r,n):Ga(r);return l&&Hn(l,s,!0),!!l}case"table-row-del":return Number.isFinite(n)?Kd(r,n):!1;case"table-col-add":return Number.isFinite(a)?$s(r,a):tu(r);case"table-col-del":return Number.isFinite(a)?Gd(r,a):!1;default:return!1}},On=e=>{let r=0;return e.querySelectorAll("tr").forEach(n=>{r=Math.max(r,n.cells.length)}),r||1},Jd=e=>{const r=e.tBodies[0]??e.createTBody();return Array.from(r.rows)},Is=e=>(e==null?void 0:e.closest("table"))??null,Os=e=>{if(!e)return null;const r=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;return(r==null?void 0:r.closest("td, th"))??null},Rd=e=>Array.from(e.querySelectorAll("th, td")),Hs=(e,r)=>{if(e.closest("thead"))return!1;const n=e.closest("tbody")??r.tBodies[0];if(!n)return!1;const a=Array.from(n.rows),s=e.closest("tr");return!s||s!==a[a.length-1]?!1:e===s.cells[s.cells.length-1]},eu=e=>{const r=window.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return!1;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return!1;const a=n.cloneRange();return a.selectNodeContents(e),a.setStart(n.endContainer,n.endOffset),a.toString().trim()===""},Hn=(e,r,n=!0)=>{r==null||r.focus();const a=document.createRange();a.selectNodeContents(e),a.collapse(n);const s=window.getSelection();s==null||s.removeAllRanges(),s==null||s.addRange(a)},Ga=e=>{const r=Jd(e);if(r.length>=Sr)return null;const n=r[r.length-1];if(!n){const a=e.tBodies[0]??e.createTBody();return Ka(a,0,e)}return Ts(e,Array.from(e.rows).indexOf(n))},tu=e=>{const r=On(e)-1;return r<0?!1:$s(e,r)},Za=e=>{Ds(e)},ru=(e,r,n)=>{const a=Ln(e,1,Sr),s=Ln(r,1,Dn),l=n?`<thead><tr>${Array.from({length:s},(c,d)=>`<th>Columna ${d+1}</th>`).join("")}</tr></thead>`:"",i=Array.from({length:a},()=>`<tr>${Array.from({length:s},()=>"<td><br></td>").join("")}</tr>`).join("");return`<table class="rich-table">${l}<tbody>${i}</tbody></table><p><br></p>`},Bs=()=>'<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>',en=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),Fs=e=>e.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(r,n,a)=>`${n}${a.toLocaleUpperCase()}`),nu=e=>e.replace(/[<>]/g,"").toLowerCase(),au=new Set(["p","br","div","span","b","strong","i","em","u","s","strike","ul","ol","li","h1","h2","h3","h4","blockquote","a","img","hr","table","thead","tbody","tfoot","tr","th","td","caption"]),ou=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,su=e=>{const r=e.indexOf("<!--StartFragment-->"),n=e.indexOf("<!--EndFragment-->");if(r!==-1&&n!==-1&&n>r)return e.slice(r+20,n);const a=e.match(/<body[^>]*>([\s\S]*)<\/body>/i);return a?a[1]:e},Bn=(e,r)=>r.test(e),lu=e=>Bn(e,/font-weight\s*:\s*(bold|[6-9]00)/i),iu=e=>Bn(e,/font-style\s*:\s*italic/i),cu=e=>Bn(e,/text-decoration(?:-line)?\s*:[^;]*underline/i),du=e=>Bn(e,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),Fn=(e,r)=>{var a;if(!e.childNodes.length||e.childNodes.length===1&&((a=e.firstChild)==null?void 0:a.nodeType)===Node.ELEMENT_NODE&&e.firstChild.tagName.toLowerCase()===r)return;const n=e.ownerDocument.createElement(r);for(;e.firstChild;)n.appendChild(e.firstChild);e.appendChild(n)},Pn=e=>{const r=e.parentNode;if(!r){e.remove();return}for(;e.firstChild;)r.insertBefore(e.firstChild,e);r.removeChild(e)},uu=e=>{const r=e.getAttribute("class")??"",n=e.getAttribute("style")??"";return/mso-list/i.test(n)||/MsoListParagraph/i.test(r)||/MsoList/i.test(r)},Ps=e=>{const r=e.getAttribute("style")??"",n=e.textContent??"";return/mso-level-number-format\s*:\s*(decimal|arabic|roman|alpha)/i.test(r)||/^\s*\d+[.)]\s/.test(n)||/^\s*[a-zA-Z][.)]\s/.test(n)?"ol":"ul"},fu=e=>{const n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT).nextNode();if(!n||!n.textContent)return;const a=n.textContent.replace(ou,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");a!==n.textContent&&(n.textContent=a)},bu=e=>{const r=Array.from(e.querySelectorAll("span, font, p, div, li, h1, h2, h3, h4"));r.sort((n,a)=>a.querySelectorAll("*").length-n.querySelectorAll("*").length),r.forEach(n=>{const a=n.getAttribute("style")??"";a&&(lu(a)&&Fn(n,"strong"),iu(a)&&Fn(n,"em"),cu(a)&&Fn(n,"u"),du(a)&&Fn(n,"s"))})},mu=e=>{const r=Array.from(e.querySelectorAll("p, div")).filter(uu);if(!r.length)return;let n=0;for(;n<r.length;){const a=r[n],s=Ps(a),l=[a];let i=n+1;for(;i<r.length;){const u=r[i];if(Ps(u)!==s)break;let m=l[l.length-1].nextSibling;for(;m&&m.nodeType===Node.TEXT_NODE&&!(m.textContent??"").trim();)m=m.nextSibling;if(m!==u)break;l.push(u),i++}const c=a.parentNode;if(!c){n=i;continue}const d=a.ownerDocument.createElement(s);c.insertBefore(d,a),l.forEach(u=>{fu(u);const m=u.ownerDocument.createElement("li");for(;u.firstChild;)m.appendChild(u.firstChild);d.appendChild(m),u.remove()}),n=i}},pu=e=>e==="h1"?"h2":e==="h4"||e==="h5"||e==="h6"?"h3":e==="div"?"p":e,hu=e=>{const r=su(e.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>${r}</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()),bu(s),mu(s);const l=i=>{const c=Array.from(i.childNodes);if(i.nodeType===Node.ELEMENT_NODE){const d=i,u=d.tagName.toLowerCase();if(u==="html"||u==="body"){c.forEach(l);return}if(u==="font"){Pn(d),c.forEach(l);return}if(!au.has(u)){Pn(d),c.forEach(l);return}if(u==="div"){const b=d.getAttribute("class")??"";if(/rich-table-wrap/.test(b)){Array.from(d.attributes).forEach(f=>{f.name.toLowerCase()!=="class"&&d.removeAttribute(f.name)}),d.className="rich-table-wrap",c.forEach(l);return}}const m=pu(u);if(m!==u){const b=d.ownerDocument.createElement(m);for(;d.firstChild;)b.appendChild(d.firstChild);d.replaceWith(b),l(b);return}if(Xd.has(u)){Array.from(d.attributes).forEach(b=>{const f=b.name.toLowerCase();if(u==="td"||u==="th"){["colspan","rowspan"].includes(f)||d.removeAttribute(b.name);return}d.removeAttribute(b.name)}),u==="table"&&d.classList.add("rich-table"),c.forEach(l);return}if(Array.from(d.attributes).forEach(b=>{const f=b.name.toLowerCase(),g=b.value;if(f.startsWith("on")||f==="style"||f==="class"){d.removeAttribute(b.name);return}if(f==="lang"||f.startsWith("data-")||f.startsWith("mso-")){d.removeAttribute(b.name);return}if((f==="href"||f==="src")&&/^\s*javascript:/i.test(g)){d.removeAttribute(b.name);return}u!=="a"&&u!=="img"&&f!=="href"&&f!=="src"&&f!=="alt"&&(["href","src","alt","target","rel"].includes(f)||d.removeAttribute(b.name))}),u==="a"){const b=d.getAttribute("href");if(!b||/^\s*#/.test(b)&&b.length<2){Pn(d),c.forEach(l);return}d.setAttribute("target","_blank"),d.setAttribute("rel","noopener noreferrer"),d.classList.add("rich-link")}if(u==="img"){const b=d.getAttribute("src")??"";if(!b||/^\s*javascript:/i.test(b)||/^file:/i.test(b)||/scheme\s*=\s*["']?file/i.test(b)){d.remove();return}d.classList.add("rich-img"),Array.from(d.attributes).forEach(f=>{["src","alt","class"].includes(f.name.toLowerCase())||d.removeAttribute(f.name)})}if(u==="span"){Pn(d),c.forEach(l);return}}c.forEach(l)};return l(s),s.querySelectorAll("p, h2, h3, li").forEach(i=>{const c=(i.textContent??"").replace(/[\u00a0\s]+/g,"").trim(),d=i.querySelector("img, hr"),u=!c&&!d&&Array.from(i.childNodes).every(m=>m.nodeType===Node.TEXT_NODE||m.nodeType===Node.ELEMENT_NODE&&m.tagName.toLowerCase()==="br");(!c&&!d||u)&&i.remove()}),s.querySelectorAll("strong, b, em, i, u, s").forEach(i=>{let c=i.nextSibling;for(;c&&c.nodeType===Node.TEXT_NODE&&!(c.textContent??"").trim();)c=c.nextSibling;if(c&&c.nodeType===Node.ELEMENT_NODE&&c.tagName===i.tagName){const d=c;for(;d.firstChild;)i.appendChild(d.firstChild);d.remove()}}),s.innerHTML.replace(/<!--[\s\S]*?-->/g,"").replace(/ /gi," ").replace(/(<br\s*\/?>\s*){3,}/gi,"<br><br>").replace(/<p>(?:\s|<br\s*\/?>)*<\/p>/gi,"").trim()},Qa=e=>en(e).replace(/\r\n?/g,`
|
|
25
|
+
`).split(/\n{2,}/).map(r=>`<p>${r.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),gu=e=>new RegExp("\\p{L}","u").test(e),Ja=(e,r)=>{const n=e.trim();return!n||!gu(n)?!1:r==="uppercase"?n===n.toLocaleUpperCase():r==="lowercase"?n===n.toLocaleLowerCase():n===Fs(n)},_s=e=>{const r=a=>{var s,l;if(!a.closest(".rich-img-wrap")){const i=document.createElement("span");i.className="rich-img-wrap",i.contentEditable="false",(s=a.parentNode)==null||s.insertBefore(i,a),i.appendChild(a),i.insertAdjacentHTML("beforeend",Bs())}(l=a.closest(".rich-img-wrap"))==null||l.classList.add("rich-img-broken")};e.querySelectorAll("img").forEach(a=>{if(!a.complete||a.naturalWidth===0){a.addEventListener("error",()=>r(a),{once:!0}),a.addEventListener("load",()=>{a.naturalWidth===0&&r(a)},{once:!0});const s=a.src;a.src="",a.src=s}});const n=a=>{const s=a.target;s.tagName==="IMG"&&r(s)};return e.addEventListener("error",n,!0),()=>e.removeEventListener("error",n,!0)};function zs({value:e,onChange:r,placeholder:n="Escribe algo...",minHeight:a="80px",instanceId:s}){const l=o.useId(),i=s||l,c=o.useCallback(()=>document,[]),d=o.useRef(null),u=o.useRef(null),m=o.useRef(new Map),b=o.useRef(null),f=o.useRef(!1),g=o.useRef(e??""),v=o.useRef(r),k=o.useRef(()=>{}),h=o.useRef(!1),[C,M]=o.useState(()=>!e||e.trim()===""),[y,x]=o.useState(new Set),[w,N]=o.useState(null),[A,T]=o.useState(""),[U,K]=o.useState(""),[Z,L]=o.useState(""),[Q,z]=o.useState(""),[se,re]=o.useState(3),[R,V]=o.useState(3),[B,le]=o.useState(!0),[j,W]=o.useState(!1),[ae,H]=o.useState(null),[D,$]=o.useState(null),oe=o.useRef(null),G=o.useRef(!1),X=o.useRef(null),S=o.useCallback(()=>f.current?u.current:d.current,[]);o.useEffect(()=>{v.current=r},[r]);const O=o.useCallback(()=>{const _=window.getSelection(),J=S();if(!_||!J||_.rangeCount===0||_.isCollapsed)return"";const ue=_.getRangeAt(0);return!J.contains(ue.startContainer)||!J.contains(ue.endContainer)?"":_.toString()},[S]);o.useEffect(()=>{const _=e??"";if(h.current&&_===g.current){h.current=!1,M(!_||_.trim()==="");return}h.current=!1,g.current=_;const J=[d.current,u.current].filter(fe=>!!fe);J.forEach(fe=>{fe.innerHTML!==_&&(fe.innerHTML=_)}),M(!_||_.trim()===""),J.forEach(fe=>Za(fe));const ue=J.map(fe=>_s(fe));return()=>ue.forEach(fe=>fe())},[e]),o.useEffect(()=>{var fe,$e;f.current=j;let _,J=0,ue;if(j){const xe=d.current;xe&&(g.current=In(xe));const De=()=>{var ot;const Ie=u.current;if(!Ie){J=requestAnimationFrame(De);return}Ie.innerHTML!==g.current&&(Ie.innerHTML=g.current),_=_s(Ie),Za(Ie),M(((ot=Ie.textContent)==null?void 0:ot.trim())===""),ue=setTimeout(()=>Ie.focus(),60)};J=requestAnimationFrame(De)}else{const xe=u.current,De=d.current,Ie=xe?In(xe):g.current,ot=g.current;g.current=Ie,De&&De.innerHTML!==Ie&&(De.innerHTML=Ie),Ie!==ot&&v.current(Ie),M((($e=(fe=xe??De)==null?void 0:fe.textContent)==null?void 0:$e.trim())==="")}return()=>{J&&cancelAnimationFrame(J),ue&&clearTimeout(ue),_==null||_()}},[j]);const I=o.useCallback(()=>{const _=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],J=new Set;_.forEach(fe=>{try{c().queryCommandState(fe)&&J.add(fe)}catch{return}});try{const fe=nu(c().queryCommandValue("formatBlock"));fe&&J.add(`formatBlock:${fe}`)}catch{}const ue=O();Ja(ue,"uppercase")&&J.add("__upper"),Ja(ue,"lowercase")&&J.add("__lower"),Ja(ue,"capitalize")&&J.add("__cap"),x(J)},[O,c]),te=()=>{var J;const _=S();_&&(g.current=In(_),h.current=!0,v.current(g.current),M(((J=_.textContent)==null?void 0:J.trim())===""))};k.current=te;const P=o.useCallback(()=>{X.current&&(clearTimeout(X.current),X.current=null),oe.current&&(As(oe.current),oe.current=null),G.current=!1,H(null),$(null)},[]),ce=o.useCallback(()=>{X.current&&(clearTimeout(X.current),X.current=null)},[]),he=o.useCallback(()=>{ce(),X.current=setTimeout(()=>{G.current||P()},280)},[ce,P]);o.useEffect(()=>()=>{X.current&&clearTimeout(X.current)},[]);const ie=o.useCallback(_=>{const J=oe.current;if(!J||!J.isConnected){P();return}const ue=(ae==null?void 0:ae.rowIndex)??(D==null?void 0:D.rowIndex)??-1,fe=(ae==null?void 0:ae.colIndex)??(D==null?void 0:D.colIndex)??-1;Qd(_,J,ue,fe,S()),P(),k.current(),I()},[S,P,I,D,ae]),ge=o.useCallback(_=>{if(D)return;const J=_.currentTarget,ue=_.target;if(ue.closest(".rich-table-action-bar, .rich-table-context-menu")){ce();return}const fe=ue.closest("td, th");if(!fe||!J.contains(fe)){he();return}const $e=fe.closest("tr"),xe=fe.closest("table");if(!$e||!xe||!J.contains(xe)){he();return}ce(),xe.classList.add("rich-table"),oe.current=xe,Ls(xe,$e,fe.cellIndex),H(Zd(xe,$e,fe))},[ce,he,D]),Te=o.useCallback(_=>{const J=_.relatedTarget;if(J instanceof Element&&(J.closest(".rich-table-action-bar")||J.closest(".rich-table-context-menu"))){ce();return}he()},[ce,he]),Le=o.useCallback(_=>{const J=_.currentTarget,fe=_.target.closest("td, th");if(!fe||!J.contains(fe))return;const $e=fe.closest("tr"),xe=fe.closest("table");if(!$e||!xe||!J.contains(xe))return;_.preventDefault(),xe.classList.add("rich-table"),oe.current=xe;const De=Array.from(xe.rows).indexOf($e),Ie=fe.cellIndex;Ls(xe,$e,Ie),H(null),$({x:_.clientX,y:_.clientY,rowIndex:De,colIndex:Ie})},[]);o.useEffect(()=>{if(!ae&&!D)return;const _=()=>he();return window.addEventListener("scroll",_,!0),window.addEventListener("resize",_),()=>{window.removeEventListener("scroll",_,!0),window.removeEventListener("resize",_)}},[he,D,ae]),o.useEffect(()=>{if(!D)return;const _=J=>{const ue=J.target;ue instanceof Element&&ue.closest(".rich-table-context-menu")||$(null)};return window.addEventListener("mousedown",_),()=>window.removeEventListener("mousedown",_)},[D]);const It=_=>{if(!_){const J=d.current;J&&(g.current=In(J))}W(!_)},ft=(_,J)=>{var ue;(ue=S())==null||ue.focus(),c().execCommand(_,!1,J),te(),I()},Qe=_=>{ft("formatBlock",_)},Ot=()=>{var _;(_=S())==null||_.focus(),c().execCommand("insertHTML",!1,"<hr><p><br></p>"),te(),I()},Se=()=>{const _=window.getSelection();_&&_.rangeCount>0&&(b.current=_.getRangeAt(0).cloneRange())},lt=()=>{const _=window.getSelection();_&&b.current&&(_.removeAllRanges(),_.addRange(b.current))},me=_=>{if(Se(),_==="link"){const J=window.getSelection();K(J&&!J.isCollapsed?J.toString():""),T("")}_==="image"&&(L(""),z("")),_==="table"&&(re(3),V(3),le(!0)),N(_)},Ye=()=>{var fe;if(!A.trim())return;lt(),(fe=S())==null||fe.focus();const _=window.getSelection(),ue=(_&&!_.isCollapsed?_.toString():"")||U.trim()||A.trim();c().execCommand("insertHTML",!1,`<a href="${en(A.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${en(ue)}</a>`),te(),N(null)},qe=(_,J="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${en(_)}" alt="${en(J)}" class="rich-img" />${Bs()}</span>`,ct=()=>{var _;Z.trim()&&(lt(),(_=S())==null||_.focus(),c().execCommand("insertHTML",!1,qe(Z.trim(),Q.trim())),te(),N(null))},ze=()=>{var _;lt(),(_=S())==null||_.focus(),c().execCommand("insertHTML",!1,ru(se,R,B)),te(),N(null)},bt=(_,J=1200,ue=1200,fe=.72)=>new Promise(($e,xe)=>{const De=new FileReader;De.onerror=xe,De.onload=Ie=>{var ht;const ot=(ht=Ie.target)==null?void 0:ht.result,We=new Image;We.onerror=xe,We.onload=()=>{let{width:zt,height:gt}=We;if(zt>J||gt>ue){const Qt=Math.min(J/zt,ue/gt);zt=Math.round(zt*Qt),gt=Math.round(gt*Qt)}const lr=document.createElement("canvas");lr.width=zt,lr.height=gt;const Wt=lr.getContext("2d");if(!Wt){$e(ot);return}Wt.drawImage(We,0,0,zt,gt),$e(lr.toDataURL("image/jpeg",fe))},We.src=ot},De.readAsDataURL(_)}),mt=_=>{_.focus();const J=window.getSelection();if(!J||J.rangeCount===0||!_.contains(J.anchorNode)){const ue=document.createRange();ue.selectNodeContents(_),ue.collapse(!1),J==null||J.removeAllRanges(),J==null||J.addRange(ue)}},et=o.useRef(()=>{});et.current=_=>{const J=S();J&&(mt(J),c().execCommand("insertHTML",!1,_),Za(J),J.querySelectorAll("p").forEach(ue=>{!(ue.textContent??"").replace(/[\u00a0\s]+/g,"")&&!ue.querySelector("img, hr, table")&&ue.remove()}),te(),I())};const Kt=o.useRef(bt);Kt.current=bt;const de=o.useRef(qe);de.current=qe;const pe=o.useCallback(_=>{if(!_||m.current.has(_))return;const J=ue=>{const fe=ue.clipboardData;if(!fe)return;const $e=fe.getData("text/html"),xe=fe.getData("text/plain");if($e||xe){ue.preventDefault(),ue.stopPropagation();try{const We=$e?hu($e):Qa(xe);if(!We){xe&&et.current(Qa(xe));return}et.current(We)}catch{xe&&et.current(Qa(xe))}return}const Ie=Array.from(fe.items).find(We=>We.type.startsWith("image/"));if(!Ie)return;ue.preventDefault(),ue.stopPropagation();const ot=Ie.getAsFile();ot&&Kt.current(ot).then(We=>{et.current(de.current(We,"imagen"))})};_.addEventListener("paste",J,!0),m.current.set(_,()=>{_.removeEventListener("paste",J,!0),m.current.delete(_)})},[]),Me=o.useCallback(_=>{var ue;const J=d.current;J&&J!==_&&((ue=m.current.get(J))==null||ue()),d.current=_,_&&pe(_)},[pe]),Pe=o.useCallback(_=>{var ue;const J=u.current;J&&J!==_&&((ue=m.current.get(J))==null||ue()),u.current=_,_&&pe(_)},[pe]);o.useEffect(()=>{const _=m.current;return()=>{_.forEach(J=>J()),_.clear()}},[]);const Be=_=>{const J=window.getSelection(),ue=S();if(!J||!ue||J.rangeCount===0||J.isCollapsed)return;const fe=J.getRangeAt(0);if(!ue.contains(fe.startContainer)||!ue.contains(fe.endContainer))return;const $e=fe.toString();if(!$e)return;let xe=$e;_==="uppercase"?xe=$e.toLocaleUpperCase():_==="lowercase"?xe=$e.toLocaleLowerCase():xe=Fs($e),fe.deleteContents();const De=document.createTextNode(xe);fe.insertNode(De);const Ie=document.createRange();Ie.setStart(De,0),Ie.setEnd(De,xe.length),J.removeAllRanges(),J.addRange(Ie),b.current=Ie.cloneRange(),te(),I()},Fe=()=>{Se(),I()},tt=()=>{const _=S();_&&Ds(_),te(),I()},rt=()=>{requestAnimationFrame(()=>{var _;(_=S())==null||_.focus()})},Ke=_=>{var J,ue;if((_.metaKey||_.ctrlKey)&&_.key==="Enter"){if(_.preventDefault(),_.stopPropagation(),_.repeat)return;(J=S())==null||J.focus(),c().execCommand("insertLineBreak",!1)||c().execCommand("insertHTML",!1,"<br>"),te(),I();return}if(_.key==="Tab"){const fe=window.getSelection(),$e=Os((fe==null?void 0:fe.anchorNode)??null),xe=S(),De=Is($e);if($e&&De&&(xe!=null&&xe.contains($e))){_.preventDefault();const Ie=Rd(De),ot=Ie.indexOf($e),We=ot>=0?Ie[ot+1]:null;if(We)Hn(We,xe,!0);else if(Hs($e,De)){const ht=Ga(De);ht&&Hn(ht,xe,!0)}te(),I();return}_.preventDefault(),(ue=S())==null||ue.focus(),c().execCommand("insertText",!1," "),te(),I();return}if(_.key==="Enter"&&!_.shiftKey&&!(_.metaKey||_.ctrlKey)){const fe=window.getSelection(),$e=Os((fe==null?void 0:fe.anchorNode)??null),xe=S(),De=Is($e);if($e&&De&&(xe!=null&&xe.contains($e))&&Hs($e,De)&&eu($e)){_.preventDefault();const Ie=Ga(De);Ie&&Hn(Ie,xe,!0),te(),I();return}}if(_.key==="Escape"){if(D){$(null);return}if(w){N(null);return}if(f.current){W(!1);return}}w||(_.ctrlKey||_.metaKey)&&(_.key==="b"&&(_.preventDefault(),ft("bold")),_.key==="i"&&(_.preventDefault(),ft("italic")),_.key==="u"&&(_.preventDefault(),ft("underline")),_.key==="k"&&(_.preventDefault(),me("link")))},nt=()=>t.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),Oe=(_,J,ue,fe,$e)=>{const xe=$e??(y.has(ue)||ue==="__link"&&w==="link"||ue==="__img"&&w==="image"||ue==="__table"&&w==="table");return t.jsx("button",{type:"button",title:J,tabIndex:-1,onFocus:rt,onMouseDown:De=>{De.preventDefault(),fe?fe():ft(ue)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:xe?"var(--primary)":"var(--text-secondary)",background:xe?"rgba(59,130,246,0.12)":"transparent"},children:_},ue)},Ht=_=>{const J=_.target;if(J.closest("[data-action='delete-img']")){_.preventDefault();const ue=J.closest(".rich-img-wrap");ue&&(ue.remove(),te())}},ta=()=>{ce(),G.current=!0},ra=()=>{G.current=!1,he()},at=(_,J,ue,fe=!1)=>t.jsx("button",{type:"button",className:`rich-table-action-btn${fe?" rich-table-action-btn--danger":""}`,title:_,"aria-label":_,onMouseDown:$e=>{$e.preventDefault(),$e.stopPropagation(),ie(ue)},children:J}),Gt=()=>typeof document>"u"||!ae&&!D?null:dt.createPortal(t.jsxs(t.Fragment,{children:[ae&&!D&&t.jsxs("div",{className:"rich-table-action-bar",style:{left:ae.bar.x,top:ae.bar.y},onMouseEnter:ta,onMouseLeave:ra,children:[t.jsxs("span",{className:"rich-table-action-hint",children:["Fila ",ae.rowIndex+1," · Col ",ae.colIndex+1]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Fila"}),at("Añadir fila abajo","+","table-row-add"),at("Eliminar fila","−","table-row-del")]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Columna"}),at("Añadir columna a la derecha","+","table-col-add"),at("Eliminar columna","−","table-col-del")]}),at("Eliminar tabla","Eliminar","table-delete",!0)]}),D&&t.jsx("div",{className:"rich-table-context-menu",style:{left:D.x,top:D.y},onMouseDown:_=>_.stopPropagation(),children:[["Añadir fila abajo","table-row-add"],["Eliminar fila","table-row-del"],["Añadir columna a la derecha","table-col-add"],["Eliminar columna","table-col-del"],["Eliminar tabla","table-delete"]].map(([_,J])=>t.jsx("button",{type:"button",onMouseDown:ue=>{ue.preventDefault(),ie(J)},children:_},J))})]}),document.body),pt=_=>t.jsxs(t.Fragment,{children:[w==="link"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:_},children:[t.jsx("input",{autoFocus:!0,type:"url",value:A,onChange:J=>T(J.target.value),onKeyDown:J=>{J.key==="Enter"&&(J.preventDefault(),Ye()),J.key==="Escape"&&N(null)},placeholder:"https://...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("input",{type:"text",value:U,onChange:J=>K(J.target.value),onKeyDown:J=>{J.key==="Enter"&&(J.preventDefault(),Ye()),J.key==="Escape"&&N(null)},placeholder:"Texto (opcional)",className:"w-32 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("button",{type:"button",onClick:Ye,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>N(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),w==="table"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:_},children:[t.jsxs("label",{className:"flex items-center gap-1 text-xs",style:{color:"var(--text-secondary)"},children:["Filas",t.jsx("input",{autoFocus:!0,type:"number",min:1,max:Sr,value:se,onChange:J=>re(Ln(Number(J.target.value),1,Sr)),onKeyDown:J=>{J.key==="Enter"&&(J.preventDefault(),ze()),J.key==="Escape"&&N(null)},className:"w-14 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}})]}),t.jsxs("label",{className:"flex items-center gap-1 text-xs",style:{color:"var(--text-secondary)"},children:["Columnas",t.jsx("input",{type:"number",min:1,max:Dn,value:R,onChange:J=>V(Ln(Number(J.target.value),1,Dn)),onKeyDown:J=>{J.key==="Enter"&&(J.preventDefault(),ze()),J.key==="Escape"&&N(null)},className:"w-14 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}})]}),t.jsxs("label",{className:"flex items-center gap-1.5 text-xs",style:{color:"var(--text-secondary)"},children:[t.jsx("input",{type:"checkbox",checked:B,onChange:J=>le(J.target.checked)}),"Encabezado"]}),t.jsx("button",{type:"button",onClick:ze,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>N(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),w==="image"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:_},children:[t.jsx("input",{autoFocus:!0,type:"url",value:Z,onChange:J=>L(J.target.value),onKeyDown:J=>{J.key==="Enter"&&(J.preventDefault(),ct()),J.key==="Escape"&&N(null)},placeholder:"URL de la imagen...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("input",{type:"text",value:Q,onChange:J=>z(J.target.value),onKeyDown:J=>{J.key==="Enter"&&(J.preventDefault(),ct()),J.key==="Escape"&&N(null)},placeholder:"Texto alt",className:"w-28 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("button",{type:"button",onClick:ct,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>N(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),Zt=(_,J)=>t.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:J},children:[Oe(t.jsx(q.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),Oe(t.jsx(q.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),nt(),Oe(t.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>Qe("p"),y.has("formatBlock:p")||y.has("formatBlock:div")),Oe(t.jsx(q.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>Qe("h2"),y.has("formatBlock:h2")),Oe(t.jsx(q.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>Qe("h3"),y.has("formatBlock:h3")),Oe(t.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>Qe("blockquote"),y.has("formatBlock:blockquote")),nt(),Oe(t.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),Oe(t.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),Oe(t.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),Oe(t.jsx("s",{children:"S"}),"Tachado","strikeThrough"),nt(),Oe(t.jsx(q.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),Oe(t.jsx(q.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),Oe(t.jsx(q.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),Oe(t.jsx(q.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),nt(),Oe(t.jsx(q.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),Oe(t.jsx(q.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),Oe(t.jsx(q.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),Oe(t.jsx(q.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),nt(),Oe(t.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>Be("uppercase")),Oe(t.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>Be("lowercase")),Oe(t.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>Be("capitalize")),nt(),Oe(t.jsx(q.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>me("link")),Oe(t.jsx(q.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),Oe(t.jsx(q.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>me("image")),Oe(t.jsx(q.HiTableCells,{className:"h-4 w-4"}),"Insertar tabla","__table",()=>me("table")),Oe(t.jsx(q.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",Ot),nt(),Oe(t.jsx(q.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),Oe(t.jsx(q.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>Qe("p")),nt(),t.jsx("button",{type:"button",title:_?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:rt,onMouseDown:ue=>{ue.preventDefault(),It(_)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:_?t.jsx(q.HiArrowsPointingIn,{className:"h-4 w-4"}):t.jsx(q.HiArrowsPointingOut,{className:"h-4 w-4"})})]});return t.jsxs(t.Fragment,{children:[Gt(),t.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:[t.jsx("div",{ref:Me,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:tt,onKeyDown:Ke,onKeyUp:Fe,onSelect:Fe,onMouseUp:Fe,onMouseMove:ge,onMouseLeave:Te,onContextMenu:Le,onMouseDown:Ht,"data-placeholder":n,className:`rich-editor px-3 py-2 text-sm focus:outline-none${C?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:a,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),pt("var(--bg-input)"),Zt(!1,"var(--bg-input)")]}),t.jsxs(Aa,{open:j,onClose:()=>W(!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:[t.jsx("div",{ref:Pe,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:tt,onKeyDown:Ke,onKeyUp:Fe,onSelect:Fe,onMouseUp:Fe,onMouseMove:ge,onMouseLeave:Te,onContextMenu:Le,onMouseDown:Ht,"data-placeholder":n,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${C?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),pt("var(--bg-input)"),Zt(!0,"var(--bg-input)")]})]})}const Ws="[a-zA-Z0-9._@-]+",Ra=new RegExp(`@(${Ws})`,"g"),vu=/[a-zA-Z0-9._@-]/,tn=new Set([" ",`
|
|
26
|
+
`," ","\r"," ","(","[","{",".",",",";",":","!","?","¿","¡",")","]","}",'"',"'","«","»","/","\\","|","-","—","–"]);function js(e,r){if(r<=0)return!0;const n=e[r-1]??"";return tn.has(n)}function qs(e,r,n){var a;if(r<0||r>e.length)return null;for(let s=r-1;s>=0;s-=1){if(e[s]!=="@"){const c=e[s]??"";if(tn.has(c)||!vu.test(c))return null;continue}if((a=n==null?void 0:n.isInsideExistingMention)!=null&&a.call(n,s)||!(n!=null&&n.isTriggerBoundary?n.isTriggerBoundary(s):js(e,s)))continue;const i=e.slice(s+1,r);return i.length>0&&!new RegExp(`^${Ws}$`).test(i)?null:{query:i,triggerIndex:s,caretIndex:r}}return null}function Us(e,r){var a;const n=Cr(e,r);return n?!!((a=n.node.parentElement)!=null&&a.closest(".mention-chip")):!1}function Vs(e,r){if(r<=0)return!0;const n=Cr(e,r);if(!n){const s=ao(e);return js(s,r)}if(n.offset>0){const s=n.node.data[n.offset-1]??"";return tn.has(s)}let a=n.node.previousSibling;for(;a;){if(a.nodeType===Node.TEXT_NODE){const s=a.textContent??"";if(s.length===0){a=a.previousSibling;continue}return tn.has(s[s.length-1]??"")}if(a.nodeType===Node.ELEMENT_NODE){const s=a;if(s.classList.contains("mention-chip")||s.tagName==="BR"||/^(P|DIV|LI|H[1-6]|BLOCKQUOTE)$/i.test(s.tagName))return!0;const l=s.textContent??"";if(l.length===0){a=a.previousSibling;continue}return tn.has(l[l.length-1]??"")}a=a.previousSibling}return!0}function eo(e,r){const n=ao(e);return qs(n,r,{isTriggerBoundary:a=>Vs(e,a),isInsideExistingMention:a=>Us(e,a)})}function to(e){return e.toLowerCase().trim()}function Ys(e){return e?e.replace(/<style[^>]*>[\s\S]*?<\/style>/gi," ").replace(/<script[^>]*>[\s\S]*?<\/script>/gi," ").replace(/<br\s*\/?>/gi,`
|
|
27
27
|
`).replace(/<\/(p|div|li)>/gi,`
|
|
28
|
-
`).replace(/<[^>]+>/g," ").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/\s+/g," ").trim():""}function Fa(e){if(!e)return[];const r=new Set,n=[],a=d=>{const u=Ba(d);!u||r.has(u)||(r.add(u),n.push(u))},o=/data-username\s*=\s*["']([^"']+)["']/gi;let l;for(;(l=o.exec(e))!==null;)a(l[1]??"");const i=go(e);Oa.lastIndex=0;let c;for(;(c=Oa.exec(i))!==null;)a(c[1]??"");return n}function vo(e){const r=String(e.name??"").trim();return r||String(e.username??"").trim()||"usuario"}function Id(e,r){const n=Fa(e);if(!n.length)return[];const a=new Map;r.forEach(i=>{i.username&&a.set(Ba(i.username),i)});const o=new Set,l=[];for(const i of n){const c=a.get(i);c&&(o.has(c.userId)||(o.add(c.userId),l.push({userId:c.userId,username:c.username,email:c.email??void 0,display:c.name??c.username})))}return l}function yo(e){const r=new Set,n=[];for(const a of e)r.has(a.userId)||(r.add(a.userId),n.push(a));return n}function Od(e,r){return r?e.filter(n=>n.userId!==r):e}function xo(e){return!e||!/@/.test(e)?e:e.replace(Oa,(r,n,a,o)=>{const l=o.slice(0,a),i=l.lastIndexOf("<"),c=l.lastIndexOf(">");return i>c?r:`<span class="mention-chip" contenteditable="false" data-username="${(n??"").toLowerCase()}">${r}</span>`})}function dr(e,r){if(r<0)return null;const n=e.ownerDocument;if(!n)return null;const a=n.createTreeWalker(e,NodeFilter.SHOW_TEXT);let o=r,l=null,i=a.nextNode();for(;i;){l=i;const c=i.data.length;if(o<=c)return{node:i,offset:o};o-=c,i=a.nextNode()}return l&&o===0?{node:l,offset:l.data.length}:null}function Pa(e,r,n){var o;const a=e.ownerDocument;if(!a||e!==r&&!e.contains(r))return-1;try{const l=a.createRange();return l.selectNodeContents(e),l.setEnd(r,n),((o=l.cloneContents().textContent)==null?void 0:o.length)??0}catch{return-1}}function wo(e,r){const{triggerIndex:n,caretIndex:a,username:o}=r;if(a<n)return null;const l=dr(e,n),i=dr(e,a);if(!l||!i)return null;const c=e.ownerDocument,d=c.createRange();d.setStart(l.node,l.offset),d.setEnd(i.node,i.offset),d.deleteContents();const u=vo({name:r.display,username:o}),m=c.createElement("span");m.className="mention-chip",m.setAttribute("data-username",o.toLowerCase()),r.userId&&m.setAttribute("data-userid",String(r.userId)),m.contentEditable="false",m.textContent=u,m.title=`@${o}`;const f=c.createTextNode(" ");d.insertNode(f),d.insertNode(m);const b=c.defaultView,v=b==null?void 0:b.getSelection();if(v){const x=c.createRange();x.setStart(f,f.data.length),x.collapse(!0),v.removeAllRanges(),v.addRange(x)}return{caretPlainOffset:n+u.length+1}}function ko(e,r){const n=e.ownerDocument,a=n.defaultView;if(!a)return;const o=a.getSelection();if(!o)return;const l=n.createRange(),i=dr(e,r);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(e),l.collapse(!1)),o.removeAllRanges(),o.addRange(l)}function Cn(e){return e instanceof HTMLElement&&e.classList.contains("mention-chip")}function No(e,r){let n=e;for(;n&&n.nodeType===Node.TEXT_NODE&&!(n.textContent??"").replace(/\u00a0/g," ").trim();)n=r==="prev"?n.previousSibling:n.nextSibling;return n}function So(e){var o;const r=e.ownerDocument,n=(o=r.defaultView)==null?void 0:o.getSelection();if(!n)return;const a=r.createRange();a.selectNode(e),n.removeAllRanges(),n.addRange(a),e.classList.add("is-selected")}function ur(e=document){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip.is-selected").forEach(n=>{n.classList.remove("is-selected")})}function En(e){var m,f;const r=e.ownerDocument,n=e.parentNode;if(!n)return;const a=(b,v)=>{let x=b;for(;x&&x.nodeType===Node.TEXT_NODE&&(x.textContent??"")==="";){const E=x;x=x[v],E.remove()}return x},o=a(e.nextSibling,"nextSibling");if(o&&o.nodeType===Node.TEXT_NODE&&/^( |\u00a0)/.test(o.textContent??"")){const b=o;(b.data.length??0)<=1?b.remove():b.data=b.data.slice(1)}const l=a(e.previousSibling,"previousSibling"),i=n,c=Array.from(n.childNodes).indexOf(e);e.remove();const d=(m=r.defaultView)==null?void 0:m.getSelection();if(!d)return;const u=r.createRange();if(l)if(l.nodeType===Node.TEXT_NODE){const b=((f=l.textContent)==null?void 0:f.length)??0;u.setStart(l,b)}else u.setStartAfter(l);else i.childNodes[c]?u.setStart(i,c):(u.selectNodeContents(i),u.collapse(!1));u.collapse(!0),d.removeAllRanges(),d.addRange(u)}function Co(e){var l;const r=(l=e.ownerDocument.defaultView)==null?void 0:l.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return null;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return null;const{startContainer:a,startOffset:o}=n;if(a.nodeType===Node.TEXT_NODE){const i=a.textContent??"",c=No(a.previousSibling,"prev");return Cn(c)&&(o===0||o===1&&(i.charAt(0)===" "||i.charAt(0)===" "))?c:null}if(a.nodeType===Node.ELEMENT_NODE){const i=a.childNodes;let c=o-1;for(;c>=0;){const d=i[c];if(Cn(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c-=1;continue}break}}return null}function Eo(e){var l;const r=(l=e.ownerDocument.defaultView)==null?void 0:l.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return null;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return null;const{startContainer:a,startOffset:o}=n;if(a.nodeType===Node.TEXT_NODE){const i=a.textContent??"";if(o>=i.length){const c=No(a.nextSibling,"next");if(Cn(c))return c}return null}if(a.nodeType===Node.ELEMENT_NODE){const i=a.childNodes;let c=o;for(;c<i.length;){const d=i[c];if(Cn(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c+=1;continue}break}}return null}function Mo(e){var o;const r=(o=e.ownerDocument.defaultView)==null?void 0:o.getSelection();if(!r||r.isCollapsed||r.rangeCount===0)return[];const n=r.getRangeAt(0);return e.contains(n.commonAncestorContainer)?Array.from(e.querySelectorAll(".mention-chip")).filter(l=>{try{return n.intersectsNode(l)}catch{return!1}}):[]}const _a=280,Mn=6,$o=260,Hd=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),Bd={position:"relative"},Fd={position:"fixed",zIndex:11050,minWidth:$o,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},To={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function Pd(e){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(e)}"]`))}function _d(e,r){const n=Math.max(8,Math.min(e.left,window.innerWidth-$o-8)),a=r==null?void 0:r.getBoundingClientRect(),o=a?Math.min(window.innerHeight-8,a.bottom):window.innerHeight-8,l=a?Math.max(8,a.top):8,i=o-e.bottom-Mn,c=e.top-l-Mn;return i<Math.min(_a,160)&&c>i?{left:n,bottom:window.innerHeight-e.top+Mn,maxHeight:Math.max(120,Math.min(_a,c))}:{left:n,top:e.bottom+Mn,maxHeight:Math.max(120,Math.min(_a,i))}}function Lo({value:e,onChange:r,onSearchUsers:n,onMentionsChange:a,minHeight:o,placeholder:l,className:i,maxSuggestions:c=8,searchDebounceMs:d=140,highlightInEditor:u=!1,searchCacheKey:m=""}){const f=s.useId().replace(/:/g,""),b=s.useRef(null),v=s.useRef(null),x=s.useRef(new Map),E=s.useRef(n);E.current=n;const h=s.useRef(null),$=s.useRef(0),M=s.useRef([]),[y,w]=s.useState(null),[k,N]=s.useState([]),[A,C]=s.useState(0),[j,W]=s.useState([]),[G,T]=s.useState(!1),[Z,H]=s.useState(!1);$.current=A,s.useEffect(()=>{H(!0)},[]);const ae=(y==null?void 0:y.query)??null;s.useEffect(()=>{if(ae===null){N([]);return}const g=ae.trim(),P=`${m}|${g.toLowerCase()||"*"}`,I=x.current.get(P);if(I){N(I),T(!1),C(0);return}const te=new AbortController;T(!0);const U=window.setTimeout(()=>{(async()=>{try{const K=await E.current(g,{signal:te.signal,limit:c});if(te.signal.aborted)return;const D=Array.isArray(K)?K:[];x.current.set(P,D),N(D),C(0)}catch{te.signal.aborted||N([])}finally{te.signal.aborted||T(!1)}})()},d);return()=>{te.abort(),window.clearTimeout(U)}},[ae,c,d,m]);const X=s.useRef(a);X.current=a,s.useEffect(()=>{var g;(g=X.current)==null||g.call(X,yo(j))},[j]);const V=s.useCallback(()=>{const g=Pd(f);if(g.length===0)return null;const P=window.getSelection();if(P!=null&&P.rangeCount){const te=P.getRangeAt(0).startContainer;for(const U of g)if(U.contains(te))return U}const I=document.activeElement;for(const te of g)if(I===te||I&&te.contains(I))return te;for(const te of g)if(te.closest('[role="dialog"]'))return te;return g[0]??null},[f]),q=s.useCallback(()=>{const g=V(),P=window.getSelection();if(!g||!P||P.rangeCount===0){w(null);return}const I=P.getRangeAt(0);if(!g.contains(I.startContainer)){w(null);return}const te=Pa(g,I.startContainer,I.startOffset);if(te<0){w(null);return}const U=Ha(g,te);if(!U){w(null);return}const K=I.getBoundingClientRect(),D=K.width===0&&K.height===0?(()=>{const _=document.createRange();return _.selectNodeContents(I.startContainer),_.collapse(!0),_.getBoundingClientRect()})():K;h.current={query:U.query,caretIndex:U.caretIndex,triggerIndex:U.triggerIndex};const ee=_d(D,g);w(_=>{const se={query:U.query,...ee};return _&&_.query===se.query&&_.top===se.top&&_.bottom===se.bottom&&_.left===se.left&&_.maxHeight===se.maxHeight?_:se})},[V]),L=s.useCallback(g=>{r(g),q()},[r,q]);s.useEffect(()=>{const g=P=>{if(Hd.has(P.key))return;const I=V(),te=P.target;!I||!te||!I.contains(te)||q()};return document.addEventListener("keyup",g,!0),()=>document.removeEventListener("keyup",g,!0)},[V,q]);const oe=s.useCallback(g=>{const P=V();if(!P)return;let I=-1;const te=window.getSelection();if(te&&te.rangeCount>0){const _=te.getRangeAt(0);P.contains(_.startContainer)&&(I=Pa(P,_.startContainer,_.startOffset))}if(I<0&&h.current&&(I=h.current.caretIndex),I<0)return;const U=Ha(P,I);if(!U)return;const K=wo(P,{triggerIndex:U.triggerIndex,caretIndex:I,username:g.username,display:g.name,userId:g.userId});if(!K)return;P.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}));const D={userId:g.userId,username:g.username,email:g.email??void 0,display:g.name??g.username};W(_=>{const se=new Map(_.map(Q=>[Q.userId,Q]));return se.set(D.userId,D),Array.from(se.values())}),w(null),h.current=null;const ee=K.caretPlainOffset;requestAnimationFrame(()=>{requestAnimationFrame(()=>{var Se,ie;const _=V();if(!_)return;_.focus(),ko(_,ee);const se=window.getSelection(),Q=se==null?void 0:se.anchorNode,de=Q instanceof Element?Q.closest(".mention-chip"):(Se=Q==null?void 0:Q.parentElement)==null?void 0:Se.closest(".mention-chip");if(de!=null&&de.parentNode){const pe=document.createRange(),Ce=de.nextSibling;Ce&&Ce.nodeType===Node.TEXT_NODE?pe.setStart(Ce,((ie=Ce.textContent)==null?void 0:ie.length)??0):pe.setStartAfter(de),pe.collapse(!0),se==null||se.removeAllRanges(),se==null||se.addRange(pe)}})})},[V]);s.useEffect(()=>{const g=new Set(Fa(e).map(P=>P.toLowerCase()));W(P=>{const I=P.filter(te=>g.has(te.username.toLowerCase()));return I.length===P.length?P:I})},[e]),s.useEffect(()=>{if(!y)return;const g=P=>{const I=P.target;if(!I||b.current&&b.current.contains(I)||v.current&&v.current.contains(I))return;const te=V();te&&te.contains(I)||w(null)};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[y,V]);const B=s.useMemo(()=>k.slice(0,c),[k,c]);M.current=B,s.useEffect(()=>{if(!y)return;const g=P=>{const I=V(),te=P.target;if(!I||!te||!I.contains(te))return;const U=M.current;if(!(U.length===0&&P.key!=="Escape"))if(P.key==="ArrowDown")P.preventDefault(),P.stopPropagation(),C(K=>(K+1)%Math.max(U.length,1));else if(P.key==="ArrowUp")P.preventDefault(),P.stopPropagation(),C(K=>(K-1+U.length)%Math.max(U.length,1));else if(P.key==="Enter"||P.key==="Tab"){const K=U[$.current];K&&(P.preventDefault(),P.stopPropagation(),oe(K))}else P.key==="Escape"&&(P.preventDefault(),P.stopPropagation(),w(null))};return document.addEventListener("keydown",g,!0),()=>document.removeEventListener("keydown",g,!0)},[V,oe,y]),s.useEffect(()=>{const g=te=>{te.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}))},P=te=>{if(te.key!=="Backspace"&&te.key!=="Delete")return;const U=V(),K=te.target;if(!U||!K||!U.contains(K))return;const D=Mo(U);if(D.length>0){te.preventDefault(),te.stopPropagation();for(const _ of D)En(_);ur(U),g(U);return}if(te.key==="Backspace"){const _=Co(U);if(!_)return;te.preventDefault(),te.stopPropagation(),En(_),ur(U),g(U);return}const ee=Eo(U);ee&&(te.preventDefault(),te.stopPropagation(),En(ee),ur(U),g(U))},I=te=>{const U=V();if(!U)return;const K=te.target;if(!(K instanceof Element)||!U.contains(K))return;const D=K.closest(".mention-chip");if(!(D instanceof HTMLElement)||!U.contains(D)){ur(U);return}te.preventDefault(),U.focus(),ur(U),So(D)};return document.addEventListener("keydown",P,!0),document.addEventListener("mousedown",I,!0),()=>{document.removeEventListener("keydown",P,!0),document.removeEventListener("mousedown",I,!0)}},[V]),s.useEffect(()=>{if(!y||!v.current)return;const g=v.current.querySelector(`[data-mention-index="${A}"]`);g==null||g.scrollIntoView({block:"nearest"})},[A,y]);const F=u?xo(e):e,le=y&&Z?nt.createPortal(t.jsxs("ul",{ref:v,style:{...Fd,left:y.left,top:y.top,bottom:y.bottom,maxHeight:y.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[G&&B.length===0&&t.jsx("li",{style:To,children:"Buscando…"}),!G&&B.length===0&&t.jsx("li",{style:To,children:y.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${y.query}”`}),B.map((g,P)=>{var I,te;return t.jsx("li",{children:t.jsxs("button",{type:"button","data-mention-index":P,onMouseDown:U=>{U.preventDefault(),oe(g)},onMouseEnter:()=>C(P),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:P===A?"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:[t.jsx("span",{style:{fontWeight:600,fontSize:13},children:((I=g.name)==null?void 0:I.trim())||`@${g.username}`}),t.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[(te=g.name)!=null&&te.trim()?`@${g.username}`:null,g.email].filter(Boolean).join(" · ")||`@${g.username}`})]})},g.userId)})]}),document.body):null;return t.jsxs("div",{ref:b,style:Bd,className:i,children:[t.jsx(uo,{value:F,onChange:L,placeholder:l,minHeight:o,instanceId:f}),le]})}function zd({value:e,onChange:r,placeholder:n,minHeight:a,onSearchUsers:o,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m}){return o?t.jsx(Lo,{value:e,onChange:r,onSearchUsers:o,onMentionsChange:l,placeholder:n,minHeight:a,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m}):t.jsx(uo,{value:e,onChange:r,placeholder:n,minHeight:a})}function jd({title:e,subtitle:r,icon:n,actions:a,children:o,footer:l,className:i="",bodyClassName:c="p-4"}){const d=e||r||n||a;return t.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${i}`,children:[d&&t.jsxs("header",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-4 py-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[n&&t.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--primary)]",children:n}),t.jsxs("div",{className:"min-w-0",children:[e&&t.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:e}),r&&t.jsx("div",{className:"truncate text-xs text-[var(--text-muted)]",children:r})]})]}),a&&t.jsx("div",{className:"shrink-0",children:a})]}),t.jsx("div",{className:c,children:o}),l&&t.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:l})]})}const Wd={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)"}},qd={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 Ud({children:e,tone:r="neutral",size:n="sm",icon:a,dot:o=!1,className:l=""}){const i=Wd[r];return t.jsxs("span",{className:`inline-flex max-w-full shrink-0 items-center gap-1.5 rounded-full border font-semibold leading-none ${qd[n]} ${l}`,style:{color:i.text,background:i.bg,borderColor:i.border},children:[o&&t.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:i.text}}),a&&t.jsx("span",{className:"shrink-0",children:a}),t.jsx("span",{className:"min-w-0 truncate",children:e})]})}const Ao={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)"}},Vd={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"},Yd={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},Xd={xs:148,sm:164,md:184},Kd={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 Gd({value:e,options:r,onChange:n,size:a="sm",disabled:o=!1,loading:l=!1,stopPropagation:i=!1,ariaLabel:c="Cambiar estado",title:d="Cambiar estado",className:u,selectClassName:m,menuClassName:f,optionClassName:b,spinnerClassName:v}){const[x,E]=s.useState(!1),[h,$]=s.useState(!1),[M,y]=s.useState(-1),[w,k]=s.useState({}),N=s.useRef(null),A=s.useRef(null),C=s.useRef(null),j=r.find(q=>q.value===e)??r[0],W={...j!=null&&j.tone?Ao[j.tone]:void 0,...j==null?void 0:j.style},G=o||l||r.length===0,T=q=>{i&&q.stopPropagation()},Z=s.useCallback(()=>{E(!1),y(-1)},[]),H=s.useCallback(()=>{const q=N.current;if(!q)return;const L=q.getBoundingClientRect(),oe=Math.max(L.width,Xd[a]),B=Math.min(Math.max(r.length,1)*38+12,260),F=window.innerHeight-L.bottom,le=F<B&&L.top>F,g=Math.min(Math.max(8,L.left+L.width/2-oe/2),window.innerWidth-oe-8);k({position:"fixed",left:g,top:le?void 0:L.bottom+6,bottom:le?window.innerHeight-L.top+6:void 0,width:oe,zIndex:9999})},[r.length,a]),ae=s.useCallback(q=>{q.disabled||(n(q.value),Z())},[Z,n]);s.useEffect(()=>$(!0),[]),s.useEffect(()=>{if(!x)return;H();const q=r.findIndex(L=>L.value===e);y(q>=0?q:0)},[x,r,H,e]),s.useEffect(()=>{if(!x)return;function q(L){var B,F;const oe=L.target;!((B=N.current)!=null&&B.contains(oe))&&!((F=A.current)!=null&&F.contains(oe))&&Z()}return document.addEventListener("mousedown",q),()=>document.removeEventListener("mousedown",q)},[Z,x]),s.useEffect(()=>{if(x)return window.addEventListener("resize",H),window.addEventListener("scroll",H,!0),()=>{window.removeEventListener("resize",H),window.removeEventListener("scroll",H,!0)}},[x,H]),s.useEffect(()=>{if(M<0||!C.current)return;const q=C.current.children[M];q==null||q.scrollIntoView({block:"nearest"})},[M]);function X(q){if(!G){if(!x){["Enter"," ","ArrowDown","ArrowUp"].includes(q.key)&&(q.preventDefault(),E(!0));return}if(q.key==="Escape"){q.preventDefault(),Z();return}if(q.key==="ArrowDown"){q.preventDefault(),y(L=>Math.min(L+1,r.length-1));return}if(q.key==="ArrowUp"){q.preventDefault(),y(L=>Math.max(L-1,0));return}if(q.key==="Enter"||q.key===" "){q.preventDefault();const L=r[M];L&&ae(L)}}}const V=t.jsx("div",{ref:A,role:"listbox","aria-label":c,className:Tt("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",f),style:{...w,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:T,onMouseDown:T,onPointerDown:T,children:t.jsx("div",{ref:C,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:r.map((q,L)=>{const oe=q.value===e,B=L===M,F={...q.tone?Ao[q.tone]:void 0,...q.style};return t.jsxs("button",{type:"button",role:"option","aria-selected":oe,disabled:q.disabled,onMouseEnter:()=>!q.disabled&&y(L),onMouseDown:le=>{le.preventDefault(),ae(q)},className:Tt("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",Kd[a],oe?q.className:void 0,b),style:{...oe?F:void 0,background:oe?F.background??"color-mix(in srgb, var(--primary) 12%, transparent)":B?"var(--bg-hover)":"transparent",color:oe?F.color??"var(--primary)":"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:oe?t.jsx(z.HiCheck,{className:"h-4 w-4"}):null}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:q.label})]},q.value)})})});return t.jsxs("span",{ref:N,className:Tt("relative inline-flex shrink-0 items-center",u),onKeyDown:X,onClick:T,onPointerDown:T,children:[t.jsx("button",{type:"button",disabled:G,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":x,title:d,onClick:()=>!G&&E(q=>!q),className:Tt("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",Vd[a],j==null?void 0:j.className,m),style:W,children:t.jsx("span",{className:"min-w-0 truncate",children:(j==null?void 0:j.label)??e})}),t.jsx(z.HiChevronDown,{"aria-hidden":"true",className:Tt("pointer-events-none absolute opacity-70 transition-transform",Yd[a],x?"rotate-180":"rotate-0")}),l&&t.jsx("span",{"aria-hidden":"true",className:Tt("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",v)}),x&&h&&nt.createPortal(V,document.body)]})}function Zd({tabs:e,activeTabId:r,defaultActiveTabId:n,onTabChange:a,ariaLabel:o="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:d=""}){const u=e.find(x=>!x.disabled)??e[0],m=r??n??(u==null?void 0:u.id),f=e.find(x=>x.id===m)??u,b=x=>{x.disabled||a==null||a(x.id)},v=x=>{const E=e.filter($=>!$.disabled);if(!E.length||!f)return;const h=E.findIndex($=>$.id===f.id);(x.key==="ArrowRight"||x.key==="ArrowDown")&&(x.preventDefault(),b(E[(h+1)%E.length])),(x.key==="ArrowLeft"||x.key==="ArrowUp")&&(x.preventDefault(),b(E[(h-1+E.length)%E.length])),x.key==="Home"&&(x.preventDefault(),b(E[0])),x.key==="End"&&(x.preventDefault(),b(E[E.length-1]))};return t.jsxs("div",{className:i,children:[t.jsx("div",{role:"tablist","aria-label":o,onKeyDown:v,className:`flex min-w-0 gap-1 overflow-x-auto ${l==="underline"?"border-b border-[var(--border)]":"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-1"} ${c}`,children:e.map(x=>{const E=x.id===(f==null?void 0:f.id);return t.jsxs("button",{type:"button",role:"tab","aria-selected":E,"aria-controls":`${x.id}-panel`,id:`${x.id}-tab`,disabled:x.disabled,tabIndex:E?0:-1,onClick:()=>b(x),className:`inline-flex min-h-8 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap px-2.5 text-sm font-semibold transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 ${l==="underline"?"border-b-2":"rounded-md border"}`,style:{color:E?"var(--primary)":"var(--text-muted)",borderColor:E?"var(--primary)":"transparent",background:l==="pills"&&E?"var(--bg-card)":"transparent"},children:[x.icon&&t.jsx("span",{className:"shrink-0",children:x.icon}),t.jsx("span",{children:x.label}),x.badge&&t.jsx("span",{className:"shrink-0",children:x.badge})]},x.id)})}),(f==null?void 0:f.content)!==void 0&&t.jsx("div",{role:"tabpanel",id:`${f.id}-panel`,"aria-labelledby":`${f.id}-tab`,className:`pt-4 ${d}`,children:f.content})]})}function Dt(...e){return e.filter(Boolean).join(" ")}function Qd({steps:e,activeStepId:r,initialStepId:n,completedStepIds:a,defaultCompletedStepIds:o=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:c,allowBackNavigation:d=!0,showFooter:u=!0,previousLabel:m="Anterior",nextLabel:f="Siguiente",blockedNextLabel:b="Completa este paso",className:v="",headerClassName:x="",contentClassName:E="",footerClassName:h=""}){var U;const $=((U=e[0])==null?void 0:U.id)??"",[M,y]=s.useState(n??$),[w,k]=s.useState(o),N=r??M,A=a??w,C=s.useMemo(()=>new Set(A),[A]),j=Math.max(0,e.findIndex(K=>K.id===N)),W=e[j]??e[0],G=e.length<=1?100:j/(e.length-1)*100,T=K=>{a||k(K),i==null||i(K)},Z=K=>{const D=e.find(ee=>ee.id===K);D&&(r||y(K),l==null||l(K,D))},H=K=>C.has(K),ae=K=>e.slice(0,K).find(D=>!D.optional&&!C.has(D.id)),X=K=>{const D=e[K];return!D||D.disabled?!1:K===j||d&&K<j?!0:!ae(K)},V=K=>{const D=e.findIndex(ee=>ee.id===K);return D>=0&&X(D)},q=K=>{const D=e.findIndex(ee=>ee.id===K);if(D<0)return!1;if(!X(D)){const ee=ae(D);return ee&&(c==null||c(e[D],ee)),!1}return Z(K),!0},L=(K=W==null?void 0:W.id)=>{!K||C.has(K)||T([...A,K])},oe=(K=W==null?void 0:W.id)=>{if(!K)return;const D=e.findIndex(_=>_.id===K),ee=A.filter(_=>{const se=e.findIndex(Q=>Q.id===_);return se>=0&&se<D});T(ee),D>=0&&j>D&&Z(K)},B=()=>j<=0?!1:q(e[j-1].id),F=()=>{const K=e[j+1];return K?q(K.id):!1},le={activeStep:W,activeIndex:j,completedStepIds:A,isCompleted:H,isUnlocked:V,completeStep:L,uncompleteStep:oe,goToStep:q,goNext:F,goPrevious:B};if(!W)return null;const g=e[j+1],P=j>0,I=g?V(g.id):!1,te=typeof W.content=="function"?W.content(le):W.content;return t.jsxs("section",{className:Dt("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",v),children:[t.jsxs("div",{className:Dt("border-b border-[var(--border)] bg-[var(--bg-input)]",x),children:[t.jsx("div",{className:"relative h-1 overflow-hidden bg-[var(--border)]/55",children:t.jsx("div",{className:"h-full rounded-r-full bg-[var(--primary)] transition-[width] duration-500 ease-out",style:{width:`${G}%`}})}),t.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map((K,D)=>{const ee=K.id===W.id,_=H(K.id),se=X(D),Q=ae(D);return t.jsxs("button",{type:"button",disabled:!se,"aria-current":ee?"step":void 0,"aria-disabled":!se,title:!se&&Q?`Completa ${Q.title}`:K.title,onClick:()=>q(K.id),className:Dt("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",ee&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",_&&!ee&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!ee&&!_&&se&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!se&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[t.jsx("span",{className:Dt("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",ee&&"scale-x-100")}),t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:Dt("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",ee&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",_&&!ee&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!_&&!ee&&se&&"border-[var(--border)] text-[var(--text-muted)]",!se&&"border-[var(--border)] text-[var(--text-muted)]"),children:_?t.jsx(z.HiCheck,{className:"h-4 w-4"}):se?D+1:t.jsx(z.HiLockClosed,{className:"h-3.5 w-3.5"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:Dt("block truncate text-xs font-semibold transition-colors duration-200",ee?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[D+1,". ",K.title]}),K.description&&t.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:K.description})]}),K.badge&&t.jsx("span",{className:"shrink-0",children:K.badge})]})]},K.id)})})]}),t.jsx("div",{className:Dt("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",E),children:te},W.id),u&&t.jsxs("div",{className:Dt("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",h),children:[t.jsx(je,{variant:"secondary",height:38,padding:"0 14px",icon:t.jsx(z.HiChevronLeft,{}),disabled:!P,onClick:B,children:m}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[t.jsxs("span",{children:["Paso ",j+1," de ",e.length]}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),t.jsxs("span",{children:[A.length," completados"]})]}),t.jsx(je,{height:38,padding:"0 14px",icon:t.jsx(z.HiChevronRight,{}),disabled:!g||!I,onClick:F,children:g&&!I?b:f})]})]})}const Jd={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"},Rd={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function eu(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function tu(e,r){return e!==void 0?String(e).length:r!==void 0?String(r).length:0}const Do=s.forwardRef(function({className:r="",wrapperClassName:n="",size:a="md",resize:o="vertical",autoResize:l=!1,minRows:i,maxRows:c,showCount:d=!1,maxCount:u,status:m="default",icon:f,action:b,style:v,value:x,defaultValue:E,maxLength:h,onInput:$,...M},y){const w=s.useRef(null),k=tu(x,E),N=u??h,A=!!(f||b||d),C=m==="error"?"var(--danger)":m==="success"?"#16a34a":"var(--border)",j={...v??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},W=()=>{const T=w.current;!T||!l||(T.style.height="auto",T.style.height=`${T.scrollHeight}px`)};s.useEffect(W,[l,x]);const G=t.jsx("textarea",{...M,ref:T=>{w.current=T,eu(y,T)},value:x,defaultValue:E,maxLength:h,"aria-invalid":m==="error"||M["aria-invalid"],onInput:T=>{W(),$==null||$(T)},style:{...j,borderColor:C},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 ${Jd[a]} ${Rd[l?"none":o]} ${f?"pl-8":""} ${b?"pr-10":""} ${r}`});return A?t.jsxs("span",{className:`relative block ${n}`,children:[f&&t.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:f}),G,b&&t.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:b}),d&&t.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:[k,N?`/${N}`:""]})]}):G});function ru({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(Ea,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:r,children:t.jsx(Do,{...u,required:i,status:o?"error":d,className:`w-full ${c}`})})}const Io=[{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 nu(e){return Io[e%Io.length]}let au=0;function za(){return++au}function Oo(e,r){return r?r instanceof RegExp?r.test(e):r(e):!0}function su(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ou(e,r){const n=r.filter(Boolean);if(n.length===0)return[e.trim()].filter(Boolean);const a=new RegExp(`${n.map(o=>su(o)).join("|")}|\\r?\\n`,"g");return e.split(a).map(o=>o.trim()).filter(Boolean)}function lu({value:e,defaultValue:r,onChange:n,placeholder:a="Escribe y presiona Enter…",disabled:o=!1,className:l="",delimiters:i=[","],maxTags:c,allowDuplicates:d=!1,validate:u,label:m,helperText:f,helperDisplay:b="inline",error:v,required:x=!1}){const E=e!==void 0,h=!!v,$=!!f&&b==="tooltip"&&!h,[M,y]=s.useState(()=>(r??[]).map((_,se)=>({id:za(),value:_.trim(),colorIndex:se})));s.useEffect(()=>{E&&y(_=>{const se=e??[],Q=new Map(_.map(de=>[de.value,de]));return se.map((de,Se)=>Q.get(de)??{id:za(),value:de,colorIndex:Se})})},[E,e]);const w=M,[k,N]=s.useState(""),[A,C]=s.useState(null),[j,W]=s.useState(""),[G,T]=s.useState(!1),[Z,H]=s.useState(!1),ae=s.useRef(null),X=s.useRef(null),V=s.useRef(null);function q(){H(!0),setTimeout(()=>H(!1),400)}function L(_){y(_),n==null||n(_.map(se=>se.value))}function oe(_){let se=w,Q=!1,de=!1;for(const Se of _){const ie=Se.trim();if(ie){if(c!==void 0&&se.length>=c){de=!0;break}if(!d&&se.some(pe=>pe.value.toLowerCase()===ie.toLowerCase())){de=!0;continue}if(!Oo(ie,u)){de=!0;continue}se=[...se,{id:za(),value:ie,colorIndex:se.length}],Q=!0}}return Q&&L(se),de&&q(),Q}function B(_){return oe([_])}function F(_){const se=w.filter(Q=>Q.id!==_);L(se.map((Q,de)=>({...Q,colorIndex:de})))}function le(_,se){const Q=se.trim();if(C(null),W(""),!Q){F(_);return}if(!(!d&&w.some(de=>de.id!==_&&de.value.toLowerCase()===Q.toLowerCase()))){if(!Oo(Q,u)){q();return}L(w.map(de=>de.id===_?{...de,value:Q}:de))}}function g(_){o||(C(_.id),W(_.value),setTimeout(()=>{var se;return(se=X.current)==null?void 0:se.select()},0))}function P(_){if(_.key==="Enter"||i.includes(_.key)){_.preventDefault(),B(k)&&N("");return}if(_.key==="Backspace"&&k===""&&w.length>0){_.preventDefault();const se=w[w.length-1];F(se.id)}}function I(_,se){if(_.key==="Enter"){_.preventDefault(),le(se,j),setTimeout(()=>{var Q;return(Q=ae.current)==null?void 0:Q.focus()},0);return}_.key==="Escape"&&(_.preventDefault(),C(null),W(""),setTimeout(()=>{var Q;return(Q=ae.current)==null?void 0:Q.focus()},0))}function te(){var _;o||(_=ae.current)==null||_.focus()}function U(_){if(o)return;const se=_.clipboardData.getData("text");if(!se||!(i.some(ie=>ie&&se.includes(ie))||se.includes(`
|
|
29
|
-
|
|
28
|
+
`).replace(/<[^>]+>/g," ").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/\s+/g," ").trim():""}function ro(e){if(!e)return[];const r=new Set,n=[],a=d=>{const u=to(d);!u||r.has(u)||(r.add(u),n.push(u))},s=/data-username\s*=\s*["']([^"']+)["']/gi;let l;for(;(l=s.exec(e))!==null;)a(l[1]??"");const i=Ys(e);Ra.lastIndex=0;let c;for(;(c=Ra.exec(i))!==null;)a(c[1]??"");return n}function Xs(e){const r=String(e.name??"").trim();return r||String(e.username??"").trim()||"usuario"}function yu(e,r){const n=ro(e);if(!n.length)return[];const a=new Map;r.forEach(i=>{i.username&&a.set(to(i.username),i)});const s=new Set,l=[];for(const i of n){const c=a.get(i);c&&(s.has(c.userId)||(s.add(c.userId),l.push({userId:c.userId,username:c.username,email:c.email??void 0,display:c.name??c.username})))}return l}function Ks(e){const r=new Set,n=[];for(const a of e)r.has(a.userId)||(r.add(a.userId),n.push(a));return n}function xu(e,r){return r?e.filter(n=>n.userId!==r):e}function Gs(e){return!e||!/@/.test(e)?e:e.replace(Ra,(r,n,a,s)=>{const l=s.slice(0,a),i=l.lastIndexOf("<"),c=l.lastIndexOf(">");return i>c?r:`<span class="mention-chip" contenteditable="false" data-username="${(n??"").toLowerCase()}">${r}</span>`})}const wu=new Set(["P","DIV","LI","H1","H2","H3","H4","H5","H6","BLOCKQUOTE"]);function Zs(e,r){return wu.has(e.tagName)&&e!==r}function no(e,r){let n="",a,s,l=!1;const i=(f,g)=>{if(l||!(r!=null&&r.domPoint))return;const{container:v,offset:k}=r.domPoint;v===f&&k===g&&(s=n.length,l=!0)},c=(f,g)=>(r==null?void 0:r.locatePlain)!==n.length?!1:(a={node:f,offset:g},!0),d=f=>(r==null?void 0:r.locatePlain)===n.length?(f==null?void 0:f.nodeType)===Node.TEXT_NODE?(a={node:f,offset:0},"matched"):"matched-at-newline":(n+=`
|
|
29
|
+
`,(r==null?void 0:r.locatePlain)===n.length?(f==null?void 0:f.nodeType)===Node.TEXT_NODE?(a={node:f,offset:0},"matched"):"matched-at-newline":!1),u=f=>{const g=f.data;for(let v=0;v<=g.length;v+=1){if(i(f,v),c(f,v))return!0;v<g.length&&(n+=g[v])}return!1},m=(f,g)=>{if(g&&n.length>0&&!n.endsWith(`
|
|
30
|
+
`)&&d(f)==="matched")return!0;if(f.nodeType===Node.TEXT_NODE)return u(f);if(f.nodeType!==Node.ELEMENT_NODE)return!1;const v=f;if(v.tagName==="BR")return i(v,0),d(v.nextSibling??void 0)==="matched";const k=Array.from(f.childNodes);for(let h=0;h<k.length;h+=1){const C=k[h],M=h>0&&C.nodeType===Node.ELEMENT_NODE&&Zs(C,e);if(m(C,M))return!0}return!1},b=Array.from(e.childNodes);for(let f=0;f<b.length;f+=1){const g=b[f],v=f>0&&g.nodeType===Node.ELEMENT_NODE&&Zs(g,e);if(m(g,v))break}if((r==null?void 0:r.locatePlain)===n.length&&!a){const f=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);let g=f.nextNode(),v=g;for(;v;)g=v,v=f.nextNode();g&&(a={node:g,offset:g.data.length})}return{plain:n,locate:a,domOffset:s}}function ao(e){return no(e).plain}function Cr(e,r){return r<0?null:no(e,{locatePlain:r}).locate??null}function _n(e,r,n){return e!==r&&!e.contains(r)?-1:no(e,{domPoint:{container:r,offset:n}}).domOffset??-1}function Qs(e,r){const{triggerIndex:n,caretIndex:a,username:s}=r;if(a<n)return null;const l=Cr(e,n),i=Cr(e,a);if(!l||!i)return null;const c=e.ownerDocument,d=c.createRange();d.setStart(l.node,l.offset),d.setEnd(i.node,i.offset),d.deleteContents();const u=Xs({name:r.display,username:s}),m=c.createElement("span");m.className="mention-chip",m.setAttribute("data-username",s.toLowerCase()),r.userId&&m.setAttribute("data-userid",String(r.userId)),m.contentEditable="false",m.textContent=u,m.title=`@${s}`;const b=c.createTextNode(" ");d.insertNode(b),d.insertNode(m);const f=c.defaultView,g=f==null?void 0:f.getSelection();if(g){const k=c.createRange();k.setStart(b,b.data.length),k.collapse(!0),g.removeAllRanges(),g.addRange(k)}const v=g!=null&&g.rangeCount?_n(e,g.getRangeAt(0).startContainer,g.getRangeAt(0).startOffset):n+u.length+1;return{caretPlainOffset:v>=0?v:n+u.length+1}}function Js(e,r){const n=e.ownerDocument,a=n.defaultView;if(!a)return;const s=a.getSelection();if(!s)return;const l=n.createRange(),i=Cr(e,r);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(e),l.collapse(!1)),s.removeAllRanges(),s.addRange(l)}function zn(e){return e instanceof HTMLElement&&e.classList.contains("mention-chip")}function Rs(e,r){let n=e;for(;n&&n.nodeType===Node.TEXT_NODE&&!(n.textContent??"").replace(/\u00a0/g," ").trim();)n=r==="prev"?n.previousSibling:n.nextSibling;return n}function el(e){var s;const r=e.ownerDocument,n=(s=r.defaultView)==null?void 0:s.getSelection();if(!n)return;const a=r.createRange();a.selectNode(e),n.removeAllRanges(),n.addRange(a),e.classList.add("is-selected")}function Er(e=document){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip.is-selected").forEach(n=>{n.classList.remove("is-selected")})}function Wn(e){var a;const r=(a=e.ownerDocument.defaultView)==null?void 0:a.getSelection();e.querySelectorAll(".mention-chip").forEach(s=>{let l=!1;if(r&&r.rangeCount>0)try{const i=r.getRangeAt(0);(!r.isCollapsed&&i.intersectsNode(s)||r.isCollapsed&&i.startContainer===s&&i.endContainer===s)&&(l=!0)}catch{l=!1}s.classList.toggle("is-selected",l)})}function tl(e){var s;const r=e.ownerDocument,n=(s=r.defaultView)==null?void 0:s.getSelection();if(!n)return;const a=r.createRange();a.selectNodeContents(e),n.removeAllRanges(),n.addRange(a),Wn(e)}function rl(e){const r=e.cloneContents();return r.querySelectorAll(".mention-chip").forEach(n=>n.remove()),(r.textContent??"").replace(/\u00a0/g," ").trim().length>0}function nl(e){var a;const r=(a=e.ownerDocument.defaultView)==null?void 0:a.getSelection();if(!r||r.isCollapsed||r.rangeCount===0)return!1;const n=r.getRangeAt(0);return e.contains(n.commonAncestorContainer)?(n.deleteContents(),Er(e),!0):!1}function jn(e){var m,b;const r=e.ownerDocument,n=e.parentNode;if(!n)return;const a=(f,g)=>{let v=f;for(;v&&v.nodeType===Node.TEXT_NODE&&(v.textContent??"")==="";){const k=v;v=v[g],k.remove()}return v},s=a(e.nextSibling,"nextSibling");if(s&&s.nodeType===Node.TEXT_NODE&&/^( |\u00a0)/.test(s.textContent??"")){const f=s;(f.data.length??0)<=1?f.remove():f.data=f.data.slice(1)}const l=a(e.previousSibling,"previousSibling"),i=n,c=Array.from(n.childNodes).indexOf(e);e.remove();const d=(m=r.defaultView)==null?void 0:m.getSelection();if(!d)return;const u=r.createRange();if(l)if(l.nodeType===Node.TEXT_NODE){const f=((b=l.textContent)==null?void 0:b.length)??0;u.setStart(l,f)}else u.setStartAfter(l);else i.childNodes[c]?u.setStart(i,c):(u.selectNodeContents(i),u.collapse(!1));u.collapse(!0),d.removeAllRanges(),d.addRange(u)}function al(e){var l;const r=(l=e.ownerDocument.defaultView)==null?void 0:l.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return null;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return null;const{startContainer:a,startOffset:s}=n;if(a.nodeType===Node.TEXT_NODE){const i=a.textContent??"",c=Rs(a.previousSibling,"prev");return zn(c)&&(s===0||s===1&&(i.charAt(0)===" "||i.charAt(0)===" "))?c:null}if(a.nodeType===Node.ELEMENT_NODE){const i=a.childNodes;let c=s-1;for(;c>=0;){const d=i[c];if(zn(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c-=1;continue}break}}return null}function ol(e){var l;const r=(l=e.ownerDocument.defaultView)==null?void 0:l.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return null;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return null;const{startContainer:a,startOffset:s}=n;if(a.nodeType===Node.TEXT_NODE){const i=a.textContent??"";if(s>=i.length){const c=Rs(a.nextSibling,"next");if(zn(c))return c}return null}if(a.nodeType===Node.ELEMENT_NODE){const i=a.childNodes;let c=s;for(;c<i.length;){const d=i[c];if(zn(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c+=1;continue}break}}return null}function oo(e){var s;const r=(s=e.ownerDocument.defaultView)==null?void 0:s.getSelection();if(!r||r.isCollapsed||r.rangeCount===0)return[];const n=r.getRangeAt(0);return e.contains(n.commonAncestorContainer)?Array.from(e.querySelectorAll(".mention-chip")).filter(l=>{try{return n.intersectsNode(l)}catch{return!1}}):[]}const so=280,qn=6,sl=260,Nu=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),ll=4,ku={position:"relative"},Su={position:"fixed",zIndex:11050,minWidth:sl,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},il={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function Cu(e){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(e)}"]`))}function Eu(e,r){const n=Math.max(8,Math.min(e.left,window.innerWidth-sl-8)),a=r==null?void 0:r.getBoundingClientRect(),s=a?Math.min(window.innerHeight-8,a.bottom):window.innerHeight-8,l=a?Math.max(8,a.top):8,i=s-e.bottom-qn,c=e.top-l-qn;return i<Math.min(so,160)&&c>i?{left:n,bottom:window.innerHeight-e.top+qn,maxHeight:Math.max(120,Math.min(so,c))}:{left:n,top:e.bottom+qn,maxHeight:Math.max(120,Math.min(so,i))}}function cl({value:e,onChange:r,onSearchUsers:n,onMentionsChange:a,minHeight:s,placeholder:l,className:i,maxSuggestions:c=8,searchDebounceMs:d=140,highlightInEditor:u=!1,searchCacheKey:m=""}){const b=o.useId().replace(/:/g,""),f=o.useRef(null),g=o.useRef(null),v=o.useRef(new Map),k=o.useRef(n);k.current=n;const h=o.useRef(null),C=o.useRef(0),M=o.useRef([]),y=o.useRef(null),[x,w]=o.useState(null),[N,A]=o.useState([]),[T,U]=o.useState(0),[K,Z]=o.useState([]),[L,Q]=o.useState(!1),[z,se]=o.useState(!1);C.current=T,o.useEffect(()=>{se(!0)},[]);const re=(x==null?void 0:x.query)??null;o.useEffect(()=>{if(re===null){A([]);return}const D=re.trim(),$=`${m}|${D.toLowerCase()||"*"}`,oe=v.current.get($);if(oe){A(oe),Q(!1),U(0);return}const G=new AbortController;Q(!0);const X=window.setTimeout(()=>{(async()=>{try{const S=await k.current(D,{signal:G.signal,limit:c});if(G.signal.aborted)return;const O=Array.isArray(S)?S:[];v.current.set($,O),A(O),U(0)}catch{G.signal.aborted||A([])}finally{G.signal.aborted||Q(!1)}})()},d);return()=>{G.abort(),window.clearTimeout(X)}},[re,c,d,m]);const R=o.useRef(a);R.current=a,o.useEffect(()=>{var D;(D=R.current)==null||D.call(R,Ks(K))},[K]);const V=o.useCallback(()=>{const D=Cu(b);if(D.length===0)return null;const $=window.getSelection();if($!=null&&$.rangeCount){const G=$.getRangeAt(0).startContainer;for(const X of D)if(X.contains(G))return X}const oe=document.activeElement;for(const G of D)if(oe===G||oe&&G.contains(oe))return G;for(const G of D)if(G.closest('[role="dialog"]'))return G;return D[0]??null},[b]),B=o.useCallback(()=>{const D=V(),$=window.getSelection();if(!D||!$||$.rangeCount===0){w(null);return}const oe=$.getRangeAt(0);if(!D.contains(oe.startContainer)){w(null);return}const G=_n(D,oe.startContainer,oe.startOffset);if(G<0){w(null);return}const X=eo(D,G);if(!X){w(null);return}const S=oe.getBoundingClientRect(),O=S.width===0&&S.height===0?(()=>{const te=document.createRange();return te.selectNodeContents(oe.startContainer),te.collapse(!0),te.getBoundingClientRect()})():S;h.current={query:X.query,caretIndex:X.caretIndex,triggerIndex:X.triggerIndex};const I=Eu(O,D);w(te=>{const P={query:X.query,...I};return te&&te.query===P.query&&te.top===P.top&&te.bottom===P.bottom&&te.left===P.left&&te.maxHeight===P.maxHeight?te:P})},[V]),le=o.useCallback(D=>{r(D),B()},[r,B]);o.useEffect(()=>{const D=$=>{if(Nu.has($.key))return;const oe=V(),G=$.target;!oe||!G||!oe.contains(G)||B()};return document.addEventListener("keyup",D,!0),()=>document.removeEventListener("keyup",D,!0)},[V,B]);const j=o.useCallback(D=>{const $=V();if(!$)return;let oe=-1;const G=window.getSelection();if(G&&G.rangeCount>0){const te=G.getRangeAt(0);$.contains(te.startContainer)&&(oe=_n($,te.startContainer,te.startOffset))}if(oe<0&&h.current&&(oe=h.current.caretIndex),oe<0)return;const X=eo($,oe);if(!X)return;const S=Qs($,{triggerIndex:X.triggerIndex,caretIndex:oe,username:D.username,display:D.name,userId:D.userId});if(!S)return;$.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}));const O={userId:D.userId,username:D.username,email:D.email??void 0,display:D.name??D.username};Z(te=>{const P=new Map(te.map(ce=>[ce.userId,ce]));return P.set(O.userId,O),Array.from(P.values())}),w(null),h.current=null;const I=S.caretPlainOffset;requestAnimationFrame(()=>{requestAnimationFrame(()=>{var ie,ge;const te=V();if(!te)return;te.focus(),Js(te,I);const P=window.getSelection(),ce=P==null?void 0:P.anchorNode,he=ce instanceof Element?ce.closest(".mention-chip"):(ie=ce==null?void 0:ce.parentElement)==null?void 0:ie.closest(".mention-chip");if(he!=null&&he.parentNode){const Te=document.createRange(),Le=he.nextSibling;Le&&Le.nodeType===Node.TEXT_NODE?Te.setStart(Le,((ge=Le.textContent)==null?void 0:ge.length)??0):Te.setStartAfter(he),Te.collapse(!0),P==null||P.removeAllRanges(),P==null||P.addRange(Te)}})})},[V]);o.useEffect(()=>{const D=new Set(ro(e).map($=>$.toLowerCase()));Z($=>{const oe=$.filter(G=>D.has(G.username.toLowerCase()));return oe.length===$.length?$:oe})},[e]),o.useEffect(()=>{if(!x)return;const D=$=>{const oe=$.target;if(!oe||f.current&&f.current.contains(oe)||g.current&&g.current.contains(oe))return;const G=V();G&&G.contains(oe)||w(null)};return document.addEventListener("mousedown",D),()=>{document.removeEventListener("mousedown",D)}},[x,V]);const W=o.useMemo(()=>N.slice(0,c),[N,c]);M.current=W,o.useEffect(()=>{if(!x)return;const D=$=>{const oe=V(),G=$.target;if(!oe||!G||!oe.contains(G))return;const X=M.current;if(!(X.length===0&&$.key!=="Escape"))if($.key==="ArrowDown")$.preventDefault(),$.stopPropagation(),U(S=>(S+1)%Math.max(X.length,1));else if($.key==="ArrowUp")$.preventDefault(),$.stopPropagation(),U(S=>(S-1+X.length)%Math.max(X.length,1));else if($.key==="Enter"||$.key==="Tab"){const S=X[C.current];S&&($.preventDefault(),$.stopPropagation(),j(S))}else $.key==="Escape"&&($.preventDefault(),$.stopPropagation(),w(null))};return document.addEventListener("keydown",D,!0),()=>document.removeEventListener("keydown",D,!0)},[V,j,x]),o.useEffect(()=>{const D=O=>{O.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}))},$=O=>{const I=V(),te=O.target;if(!I||!te||!I.contains(te))return;if((O.metaKey||O.ctrlKey)&&O.key.toLowerCase()==="a"){O.preventDefault(),O.stopPropagation(),I.focus(),tl(I);return}if(O.key!=="Backspace"&&O.key!=="Delete")return;const P=window.getSelection();if(P&&!P.isCollapsed&&P.rangeCount>0){const ie=P.getRangeAt(0);if(I.contains(ie.commonAncestorContainer)&&oo(I).length>0&&rl(ie)){O.preventDefault(),O.stopPropagation(),nl(I)&&D(I);return}}const ce=oo(I);if(ce.length>0){O.preventDefault(),O.stopPropagation();for(const ie of ce)jn(ie);Er(I),D(I);return}if(O.key==="Backspace"){const ie=al(I);if(!ie)return;O.preventDefault(),O.stopPropagation(),jn(ie),Er(I),D(I);return}const he=ol(I);he&&(O.preventDefault(),O.stopPropagation(),jn(he),Er(I),D(I))},oe=O=>{const I=V();if(!I)return;const te=O.target;if(!(te instanceof Element)||!I.contains(te))return;const P=te.closest(".mention-chip");if(!(P instanceof HTMLElement)||!I.contains(P)){y.current=null,Er(I);return}O.shiftKey||O.button!==0||(y.current={chip:P,x:O.clientX,y:O.clientY})},G=O=>{const I=y.current;if(!I)return;const te=Math.abs(O.clientX-I.x),P=Math.abs(O.clientY-I.y);(te>ll||P>ll)&&(y.current=null)},X=O=>{var he;const I=V(),te=y.current;if(y.current=null,!I||!te)return;const P=O.target;if(!(P instanceof Element)||!I.contains(P)||!((he=P.closest(".mention-chip"))!=null&&he.isSameNode(te.chip)))return;const ce=window.getSelection();if(ce){if(!ce.isCollapsed){Wn(I);return}I.focus(),el(te.chip)}},S=()=>{const O=V();if(!O)return;const I=window.getSelection();!I||I.rangeCount===0||!I.anchorNode||!O.contains(I.anchorNode)||!I.focusNode||!O.contains(I.focusNode)||Wn(O)};return document.addEventListener("keydown",$,!0),document.addEventListener("mousedown",oe,!0),document.addEventListener("mousemove",G,!0),document.addEventListener("mouseup",X,!0),document.addEventListener("selectionchange",S),()=>{document.removeEventListener("keydown",$,!0),document.removeEventListener("mousedown",oe,!0),document.removeEventListener("mousemove",G,!0),document.removeEventListener("mouseup",X,!0),document.removeEventListener("selectionchange",S)}},[V]),o.useEffect(()=>{if(!x||!g.current)return;const D=g.current.querySelector(`[data-mention-index="${T}"]`);D==null||D.scrollIntoView({block:"nearest"})},[T,x]);const ae=u?Gs(e):e,H=x&&z?dt.createPortal(t.jsxs("ul",{ref:g,style:{...Su,left:x.left,top:x.top,bottom:x.bottom,maxHeight:x.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[L&&W.length===0&&t.jsx("li",{style:il,children:"Buscando…"}),!L&&W.length===0&&t.jsx("li",{style:il,children:x.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${x.query}”`}),W.map((D,$)=>{var oe,G;return t.jsx("li",{children:t.jsxs("button",{type:"button","data-mention-index":$,onMouseDown:X=>{X.preventDefault(),j(D)},onMouseEnter:()=>U($),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:$===T?"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:[t.jsx("span",{style:{fontWeight:600,fontSize:13},children:((oe=D.name)==null?void 0:oe.trim())||`@${D.username}`}),t.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[(G=D.name)!=null&&G.trim()?`@${D.username}`:null,D.email].filter(Boolean).join(" · ")||`@${D.username}`})]})},D.userId)})]}),document.body):null;return t.jsxs("div",{ref:f,style:ku,className:i,children:[t.jsx(zs,{value:ae,onChange:le,placeholder:l,minHeight:s,instanceId:b}),H]})}function Mu({value:e,onChange:r,placeholder:n,minHeight:a,onSearchUsers:s,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m}){return s?t.jsx(cl,{value:e,onChange:r,onSearchUsers:s,onMentionsChange:l,placeholder:n,minHeight:a,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m}):t.jsx(zs,{value:e,onChange:r,placeholder:n,minHeight:a})}function Tu({title:e,subtitle:r,icon:n,actions:a,children:s,footer:l,className:i="",bodyClassName:c="p-4"}){const d=e||r||n||a;return t.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${i}`,children:[d&&t.jsxs("header",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-4 py-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[n&&t.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--primary)]",children:n}),t.jsxs("div",{className:"min-w-0",children:[e&&t.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:e}),r&&t.jsx("div",{className:"truncate text-xs text-[var(--text-muted)]",children:r})]})]}),a&&t.jsx("div",{className:"shrink-0",children:a})]}),t.jsx("div",{className:c,children:s}),l&&t.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:l})]})}const $u={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)"}},Au={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 Lu({children:e,tone:r="neutral",size:n="sm",icon:a,dot:s=!1,className:l=""}){const i=$u[r];return t.jsxs("span",{className:`inline-flex max-w-full shrink-0 items-center gap-1.5 rounded-full border font-semibold leading-none ${Au[n]} ${l}`,style:{color:i.text,background:i.bg,borderColor:i.border},children:[s&&t.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:i.text}}),a&&t.jsx("span",{className:"shrink-0",children:a}),t.jsx("span",{className:"min-w-0 truncate",children:e})]})}const dl={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)"}},Du={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"},Iu={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},Ou={xs:148,sm:164,md:184},Hu={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 Bu({value:e,options:r,onChange:n,size:a="sm",disabled:s=!1,loading:l=!1,stopPropagation:i=!1,ariaLabel:c="Cambiar estado",title:d="Cambiar estado",className:u,selectClassName:m,menuClassName:b,optionClassName:f,spinnerClassName:g}){const[v,k]=o.useState(!1),[h,C]=o.useState(!1),[M,y]=o.useState(-1),[x,w]=o.useState({}),N=o.useRef(null),A=o.useRef(null),T=o.useRef(null),U=r.find(V=>V.value===e)??r[0],K={...U!=null&&U.tone?dl[U.tone]:void 0,...U==null?void 0:U.style},Z=s||l||r.length===0,L=V=>{i&&V.stopPropagation()},Q=o.useCallback(()=>{k(!1),y(-1)},[]),z=o.useCallback(()=>{const V=N.current;if(!V)return;const B=V.getBoundingClientRect(),le=Math.max(B.width,Ou[a]),j=Math.min(Math.max(r.length,1)*38+12,260),W=window.innerHeight-B.bottom,ae=W<j&&B.top>W,H=Math.min(Math.max(8,B.left+B.width/2-le/2),window.innerWidth-le-8);w({position:"fixed",left:H,top:ae?void 0:B.bottom+6,bottom:ae?window.innerHeight-B.top+6:void 0,width:le,zIndex:9999})},[r.length,a]),se=o.useCallback(V=>{V.disabled||(n(V.value),Q())},[Q,n]);o.useEffect(()=>C(!0),[]),o.useEffect(()=>{if(!v)return;z();const V=r.findIndex(B=>B.value===e);y(V>=0?V:0)},[v,r,z,e]),o.useEffect(()=>{if(!v)return;function V(B){var j,W;const le=B.target;!((j=N.current)!=null&&j.contains(le))&&!((W=A.current)!=null&&W.contains(le))&&Q()}return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[Q,v]),o.useEffect(()=>{if(v)return window.addEventListener("resize",z),window.addEventListener("scroll",z,!0),()=>{window.removeEventListener("resize",z),window.removeEventListener("scroll",z,!0)}},[v,z]),o.useEffect(()=>{if(M<0||!T.current)return;const V=T.current.children[M];V==null||V.scrollIntoView({block:"nearest"})},[M]);function re(V){if(!Z){if(!v){["Enter"," ","ArrowDown","ArrowUp"].includes(V.key)&&(V.preventDefault(),k(!0));return}if(V.key==="Escape"){V.preventDefault(),Q();return}if(V.key==="ArrowDown"){V.preventDefault(),y(B=>Math.min(B+1,r.length-1));return}if(V.key==="ArrowUp"){V.preventDefault(),y(B=>Math.max(B-1,0));return}if(V.key==="Enter"||V.key===" "){V.preventDefault();const B=r[M];B&&se(B)}}}const R=t.jsx("div",{ref:A,role:"listbox","aria-label":c,className:jt("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",b),style:{...x,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:L,onMouseDown:L,onPointerDown:L,children:t.jsx("div",{ref:T,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:r.map((V,B)=>{const le=V.value===e,j=B===M,W={...V.tone?dl[V.tone]:void 0,...V.style};return t.jsxs("button",{type:"button",role:"option","aria-selected":le,disabled:V.disabled,onMouseEnter:()=>!V.disabled&&y(B),onMouseDown:ae=>{ae.preventDefault(),se(V)},className:jt("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",Hu[a],le?V.className:void 0,f),style:{...le?W:void 0,background:le?W.background??"color-mix(in srgb, var(--primary) 12%, transparent)":j?"var(--bg-hover)":"transparent",color:le?W.color??"var(--primary)":"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:le?t.jsx(q.HiCheck,{className:"h-4 w-4"}):null}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:V.label})]},V.value)})})});return t.jsxs("span",{ref:N,className:jt("relative inline-flex shrink-0 items-center",u),onKeyDown:re,onClick:L,onPointerDown:L,children:[t.jsx("button",{type:"button",disabled:Z,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":v,title:d,onClick:()=>!Z&&k(V=>!V),className:jt("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",Du[a],U==null?void 0:U.className,m),style:K,children:t.jsx("span",{className:"min-w-0 truncate",children:(U==null?void 0:U.label)??e})}),t.jsx(q.HiChevronDown,{"aria-hidden":"true",className:jt("pointer-events-none absolute opacity-70 transition-transform",Iu[a],v?"rotate-180":"rotate-0")}),l&&t.jsx("span",{"aria-hidden":"true",className:jt("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",g)}),v&&h&&dt.createPortal(R,document.body)]})}function Fu({tabs:e,activeTabId:r,defaultActiveTabId:n,onTabChange:a,ariaLabel:s="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:d=""}){const u=e.find(v=>!v.disabled)??e[0],m=r??n??(u==null?void 0:u.id),b=e.find(v=>v.id===m)??u,f=v=>{v.disabled||a==null||a(v.id)},g=v=>{const k=e.filter(C=>!C.disabled);if(!k.length||!b)return;const h=k.findIndex(C=>C.id===b.id);(v.key==="ArrowRight"||v.key==="ArrowDown")&&(v.preventDefault(),f(k[(h+1)%k.length])),(v.key==="ArrowLeft"||v.key==="ArrowUp")&&(v.preventDefault(),f(k[(h-1+k.length)%k.length])),v.key==="Home"&&(v.preventDefault(),f(k[0])),v.key==="End"&&(v.preventDefault(),f(k[k.length-1]))};return t.jsxs("div",{className:i,children:[t.jsx("div",{role:"tablist","aria-label":s,onKeyDown:g,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:e.map(v=>{const k=v.id===(b==null?void 0:b.id);return t.jsxs("button",{type:"button",role:"tab","aria-selected":k,"aria-controls":`${v.id}-panel`,id:`${v.id}-tab`,disabled:v.disabled,tabIndex:k?0:-1,onClick:()=>f(v),className:`inline-flex min-h-8 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap px-2.5 text-sm font-semibold transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 ${l==="underline"?"border-b-2":"rounded-md border"}`,style:{color:k?"var(--primary)":"var(--text-muted)",borderColor:k?"var(--primary)":"transparent",background:l==="pills"&&k?"var(--bg-card)":"transparent"},children:[v.icon&&t.jsx("span",{className:"shrink-0",children:v.icon}),t.jsx("span",{children:v.label}),v.badge&&t.jsx("span",{className:"shrink-0",children:v.badge})]},v.id)})}),(b==null?void 0:b.content)!==void 0&&t.jsx("div",{role:"tabpanel",id:`${b.id}-panel`,"aria-labelledby":`${b.id}-tab`,className:`pt-4 ${d}`,children:b.content})]})}function Vt(...e){return e.filter(Boolean).join(" ")}function Pu({steps:e,activeStepId:r,initialStepId:n,completedStepIds:a,defaultCompletedStepIds:s=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:c,allowBackNavigation:d=!0,showFooter:u=!0,previousLabel:m="Anterior",nextLabel:b="Siguiente",blockedNextLabel:f="Completa este paso",className:g="",headerClassName:v="",contentClassName:k="",footerClassName:h=""}){var G;const C=((G=e[0])==null?void 0:G.id)??"",[M,y]=o.useState(n??C),[x,w]=o.useState(s),N=r??M,A=a??x,T=o.useMemo(()=>new Set(A),[A]),U=Math.max(0,e.findIndex(X=>X.id===N)),K=e[U]??e[0],Z=e.length<=1?100:U/(e.length-1)*100,L=X=>{a||w(X),i==null||i(X)},Q=X=>{const S=e.find(O=>O.id===X);S&&(r||y(X),l==null||l(X,S))},z=X=>T.has(X),se=X=>e.slice(0,X).find(S=>!S.optional&&!T.has(S.id)),re=X=>{const S=e[X];return!S||S.disabled?!1:X===U||d&&X<U?!0:!se(X)},R=X=>{const S=e.findIndex(O=>O.id===X);return S>=0&&re(S)},V=X=>{const S=e.findIndex(O=>O.id===X);if(S<0)return!1;if(!re(S)){const O=se(S);return O&&(c==null||c(e[S],O)),!1}return Q(X),!0},B=(X=K==null?void 0:K.id)=>{!X||T.has(X)||L([...A,X])},le=(X=K==null?void 0:K.id)=>{if(!X)return;const S=e.findIndex(I=>I.id===X),O=A.filter(I=>{const te=e.findIndex(P=>P.id===I);return te>=0&&te<S});L(O),S>=0&&U>S&&Q(X)},j=()=>U<=0?!1:V(e[U-1].id),W=()=>{const X=e[U+1];return X?V(X.id):!1},ae={activeStep:K,activeIndex:U,completedStepIds:A,isCompleted:z,isUnlocked:R,completeStep:B,uncompleteStep:le,goToStep:V,goNext:W,goPrevious:j};if(!K)return null;const H=e[U+1],D=U>0,$=H?R(H.id):!1,oe=typeof K.content=="function"?K.content(ae):K.content;return t.jsxs("section",{className:Vt("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",g),children:[t.jsxs("div",{className:Vt("border-b border-[var(--border)] bg-[var(--bg-input)]",v),children:[t.jsx("div",{className:"relative h-1 overflow-hidden bg-[var(--border)]/55",children:t.jsx("div",{className:"h-full rounded-r-full bg-[var(--primary)] transition-[width] duration-500 ease-out",style:{width:`${Z}%`}})}),t.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map((X,S)=>{const O=X.id===K.id,I=z(X.id),te=re(S),P=se(S);return t.jsxs("button",{type:"button",disabled:!te,"aria-current":O?"step":void 0,"aria-disabled":!te,title:!te&&P?`Completa ${P.title}`:X.title,onClick:()=>V(X.id),className:Vt("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",O&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",I&&!O&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!O&&!I&&te&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!te&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[t.jsx("span",{className:Vt("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",O&&"scale-x-100")}),t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:Vt("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",O&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",I&&!O&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!I&&!O&&te&&"border-[var(--border)] text-[var(--text-muted)]",!te&&"border-[var(--border)] text-[var(--text-muted)]"),children:I?t.jsx(q.HiCheck,{className:"h-4 w-4"}):te?S+1:t.jsx(q.HiLockClosed,{className:"h-3.5 w-3.5"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:Vt("block truncate text-xs font-semibold transition-colors duration-200",O?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[S+1,". ",X.title]}),X.description&&t.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:X.description})]}),X.badge&&t.jsx("span",{className:"shrink-0",children:X.badge})]})]},X.id)})})]}),t.jsx("div",{className:Vt("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",k),children:oe},K.id),u&&t.jsxs("div",{className:Vt("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",h),children:[t.jsx(Ue,{variant:"secondary",height:38,padding:"0 14px",icon:t.jsx(q.HiChevronLeft,{}),disabled:!D,onClick:j,children:m}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[t.jsxs("span",{children:["Paso ",U+1," de ",e.length]}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),t.jsxs("span",{children:[A.length," completados"]})]}),t.jsx(Ue,{height:38,padding:"0 14px",icon:t.jsx(q.HiChevronRight,{}),disabled:!H||!$,onClick:W,children:H&&!$?f:b})]})]})}const _u={sm:"px-2.5 py-1.5 text-xs leading-5",md:"px-2.5 py-1.5 text-sm leading-5",lg:"px-3 py-2 text-sm leading-6"};function zu(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Wu(e){const r=getComputedStyle(e),n=Number.parseFloat(r.lineHeight),a=Number.parseFloat(r.paddingTop)+Number.parseFloat(r.paddingBottom),s=Number.parseFloat(r.borderTopWidth)+Number.parseFloat(r.borderBottomWidth);return{lineHeight:Number.isFinite(n)?n:20,paddingY:Number.isFinite(a)?a:12,borderY:Number.isFinite(s)?s:2}}function ul(e,r){const{lineHeight:n,paddingY:a,borderY:s}=Wu(e);return Math.ceil(r*n+a+s)}const fl=o.forwardRef(function({className:r="",size:n="md",status:a="default",maxHeight:s,maxRows:l,minRows:i=1,style:c,value:d,defaultValue:u,onInput:m,...b},f){const g=o.useRef(null),v=a==="error"?"var(--danger)":a==="success"?"#16a34a":"var(--border)",k=o.useCallback(()=>{const h=g.current;if(!h)return;h.style.height="auto";const C=h.scrollHeight,M=ul(h,i),y=s??(l!==void 0?ul(h,l):void 0),x=y!==void 0?Math.min(Math.max(C,M),y):Math.max(C,M);h.style.height=`${x}px`,h.style.overflowY=y!==void 0&&C>y?"auto":"hidden"},[s,l,i]);return o.useLayoutEffect(()=>{k()},[k,d,u]),o.useEffect(()=>{const h=g.current;if(!h||typeof ResizeObserver>"u")return;const C=new ResizeObserver(()=>k());return C.observe(h),()=>C.disconnect()},[k]),t.jsx("textarea",{...b,ref:h=>{g.current=h,zu(f,h)},rows:i,value:d,defaultValue:u,"aria-invalid":a==="error"||b["aria-invalid"],onInput:h=>{k(),m==null||m(h)},style:{...c,borderColor:v,minHeight:void 0},className:`w-full resize-none overflow-hidden 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 ${_u[n]} ${r}`})});function ju({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:s,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx($n,{label:e,required:i,helperText:n,helperDisplay:a,error:s,labelAction:l,className:r,children:t.jsx(fl,{...u,required:i,status:s?"error":d,className:`w-full ${c}`})})}const qu={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"},Uu={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Vu(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Yu(e,r){return e!==void 0?String(e).length:r!==void 0?String(r).length:0}const bl=o.forwardRef(function({className:r="",wrapperClassName:n="",size:a="md",resize:s="vertical",autoResize:l=!1,minRows:i,maxRows:c,showCount:d=!1,maxCount:u,status:m="default",icon:b,action:f,style:g,value:v,defaultValue:k,maxLength:h,onInput:C,...M},y){const x=o.useRef(null),w=Yu(v,k),N=u??h,A=!!(b||f||d),T=m==="error"?"var(--danger)":m==="success"?"#16a34a":"var(--border)",U={...g??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},K=()=>{const L=x.current;!L||!l||(L.style.height="auto",L.style.height=`${L.scrollHeight}px`)};o.useEffect(K,[l,v]);const Z=t.jsx("textarea",{...M,ref:L=>{x.current=L,Vu(y,L)},value:v,defaultValue:k,maxLength:h,"aria-invalid":m==="error"||M["aria-invalid"],onInput:L=>{K(),C==null||C(L)},style:{...U,borderColor:T},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 ${qu[a]} ${Uu[l?"none":s]} ${b?"pl-8":""} ${f?"pr-10":""} ${r}`});return A?t.jsxs("span",{className:`relative block ${n}`,children:[b&&t.jsx("span",{className:"pointer-events-none absolute left-2.5 top-2.5 flex h-4 w-4 items-center justify-center text-[var(--text-muted)]",children:b}),Z,f&&t.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:f}),d&&t.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:[w,N?`/${N}`:""]})]}):Z});function Xu({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:s,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx($n,{label:e,required:i,helperText:n,helperDisplay:a,error:s,labelAction:l,className:r,children:t.jsx(bl,{...u,required:i,status:s?"error":d,className:`w-full ${c}`})})}const ml=[{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 Ku(e){return ml[e%ml.length]}let Gu=0;function lo(){return++Gu}function pl(e,r){return r?r instanceof RegExp?r.test(e):r(e):!0}function Zu(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Qu(e,r){const n=r.filter(Boolean);if(n.length===0)return[e.trim()].filter(Boolean);const a=new RegExp(`${n.map(s=>Zu(s)).join("|")}|\\r?\\n`,"g");return e.split(a).map(s=>s.trim()).filter(Boolean)}function Ju({value:e,defaultValue:r,onChange:n,placeholder:a="Escribe y presiona Enter…",disabled:s=!1,className:l="",delimiters:i=[","],maxTags:c,allowDuplicates:d=!1,validate:u,label:m,helperText:b,helperDisplay:f="inline",error:g,required:v=!1}){const k=e!==void 0,h=!!g,C=!!b&&f==="tooltip"&&!h,[M,y]=o.useState(()=>(r??[]).map((I,te)=>({id:lo(),value:I.trim(),colorIndex:te})));o.useEffect(()=>{k&&y(I=>{const te=e??[],P=new Map(I.map(ce=>[ce.value,ce]));return te.map((ce,he)=>P.get(ce)??{id:lo(),value:ce,colorIndex:he})})},[k,e]);const x=M,[w,N]=o.useState(""),[A,T]=o.useState(null),[U,K]=o.useState(""),[Z,L]=o.useState(!1),[Q,z]=o.useState(!1),se=o.useRef(null),re=o.useRef(null),R=o.useRef(null);function V(){z(!0),setTimeout(()=>z(!1),400)}function B(I){y(I),n==null||n(I.map(te=>te.value))}function le(I){let te=x,P=!1,ce=!1;for(const he of I){const ie=he.trim();if(ie){if(c!==void 0&&te.length>=c){ce=!0;break}if(!d&&te.some(ge=>ge.value.toLowerCase()===ie.toLowerCase())){ce=!0;continue}if(!pl(ie,u)){ce=!0;continue}te=[...te,{id:lo(),value:ie,colorIndex:te.length}],P=!0}}return P&&B(te),ce&&V(),P}function j(I){return le([I])}function W(I){const te=x.filter(P=>P.id!==I);B(te.map((P,ce)=>({...P,colorIndex:ce})))}function ae(I,te){const P=te.trim();if(T(null),K(""),!P){W(I);return}if(!(!d&&x.some(ce=>ce.id!==I&&ce.value.toLowerCase()===P.toLowerCase()))){if(!pl(P,u)){V();return}B(x.map(ce=>ce.id===I?{...ce,value:P}:ce))}}function H(I){s||(T(I.id),K(I.value),setTimeout(()=>{var te;return(te=re.current)==null?void 0:te.select()},0))}function D(I){if(I.key==="Enter"||i.includes(I.key)){I.preventDefault(),j(w)&&N("");return}if(I.key==="Backspace"&&w===""&&x.length>0){I.preventDefault();const te=x[x.length-1];W(te.id)}}function $(I,te){if(I.key==="Enter"){I.preventDefault(),ae(te,U),setTimeout(()=>{var P;return(P=se.current)==null?void 0:P.focus()},0);return}I.key==="Escape"&&(I.preventDefault(),T(null),K(""),setTimeout(()=>{var P;return(P=se.current)==null?void 0:P.focus()},0))}function oe(){var I;s||(I=se.current)==null||I.focus()}function G(I){if(s)return;const te=I.clipboardData.getData("text");if(!te||!(i.some(ie=>ie&&te.includes(ie))||te.includes(`
|
|
31
|
+
`)))return;I.preventDefault();const ce=Qu(te,i);le(ce)&&N("")}function X(){const I=w.trim();I&&j(I)&&N("")}const S=h?"var(--danger)":Z?"var(--primary)":"var(--border)",O=c!==void 0&&x.length>=c;return t.jsxs("div",{className:`flex flex-col gap-2 ${l}`,children:[(m||v||C)&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[m&&t.jsx("span",{children:m}),v&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),C?t.jsx(xr,{content:b}):null]}),t.jsxs("div",{ref:R,onClick:oe,onFocus:()=>L(!0),onBlur:I=>{var te;(te=R.current)!=null&&te.contains(I.relatedTarget)||(L(!1),A!==null&&ae(A,U),A===null&&X())},style:{borderColor:S},className:`
|
|
30
32
|
flex min-h-10 flex-wrap items-center gap-1.5 rounded-lg border
|
|
31
33
|
bg-[var(--bg-input)] px-2.5 py-2 transition-colors
|
|
32
|
-
${
|
|
33
|
-
${
|
|
34
|
+
${s?"cursor-not-allowed opacity-60":"cursor-text"}
|
|
35
|
+
${Q?"animate-[tag-shake_0.4s_ease]":""}
|
|
34
36
|
`,children:[t.jsx("style",{children:`
|
|
35
37
|
@keyframes tag-shake {
|
|
36
38
|
0%,100% { transform: translateX(0); }
|
|
@@ -39,7 +41,7 @@ ${R}`,ne=new Blob(["\uFEFF"+O],{type:"text/csv;charset=utf-8;"}),fe=URL.createOb
|
|
|
39
41
|
60% { transform: translateX(-3px); }
|
|
40
42
|
80% { transform: translateX(3px); }
|
|
41
43
|
}
|
|
42
|
-
`}),w.map(_=>{const se=nu(_.colorIndex);return A===_.id?t.jsx("input",{ref:X,value:j,disabled:o,onChange:Q=>W(Q.target.value),onKeyDown:Q=>I(Q,_.id),onBlur:()=>le(_.id,j),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(j.length+2,6)}ch`}},_.id):t.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:se.bg,color:se.text,border:`1px solid ${se.border}`},children:[t.jsx("span",{className:"truncate",children:_.value}),t.jsx("button",{type:"button","aria-label":`Editar "${_.value}"`,disabled:o,tabIndex:-1,onClick:Q=>{Q.stopPropagation(),g(_)},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:t.jsx(z.HiPencil,{className:"h-3 w-3"})}),t.jsx("button",{type:"button","aria-label":`Eliminar "${_.value}"`,disabled:o,tabIndex:-1,onClick:Q=>{Q.stopPropagation(),F(_.id)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:t.jsx(z.HiXMark,{className:"h-3.5 w-3.5"})})]},_.id)}),!ee&&t.jsx("input",{ref:ae,value:k,disabled:o,placeholder:w.length===0?a:"",onChange:_=>N(_.target.value),onKeyDown:P,onPaste:U,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"})]}),t.jsx(lr,{error:v,helperText:f,helperDisplay:b})]})}const iu=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;function Ye(e){return String(e).padStart(2,"0")}function ja(e,r=fr()){const n=e.trim();if(!n)return r;const a=n.match(iu);if(!a)return r;const o=Number(a[1]),l=Number(a[2]),i=a[3]?Number(a[3]):0;return!Number.isFinite(o)||!Number.isFinite(l)||!Number.isFinite(i)||o<0||o>23||l<0||l>59||i<0||i>59?r:{hour24:o,minute:l,second:i}}function Ur(e,r=!0){const n=`${Ye(e.hour24)}:${Ye(e.minute)}`;return r?`${n}:${Ye(e.second)}`:n}function $n(e){const r=e.hour24>=12?"PM":"AM";return{hour12:e.hour24%12===0?12:e.hour24%12,minute:e.minute,second:e.second,meridiem:r}}function Vr(e){let n=Math.min(12,Math.max(1,e.hour12))%12;return e.meridiem==="PM"&&(n+=12),{hour24:n,minute:Math.min(59,Math.max(0,e.minute)),second:Math.min(59,Math.max(0,e.second))}}function cu(e,r){const n=(r==null?void 0:r.use12Hour)??!1,a=(r==null?void 0:r.showSeconds)??!0,o=ja(e);if(n){const l=$n(o),i=`${l.hour12}:${Ye(l.minute)}`;return`${a?`${i}:${Ye(l.second)}`:i} ${l.meridiem}`}return Ur(o,a)}function fr(){const e=new Date;return{hour24:e.getHours(),minute:e.getMinutes(),second:e.getSeconds()}}function du(e=!0){return Ur(fr(),e)}function Wa(e,r){const n=[];for(let a=e;a<=r;a+=1)n.push(a);return n}const st=36,qa=5,Ho=Math.floor(qa/2),uu=52,fu=48,Ct=18;function Bo(e){return e*st}function Fo(e){return Math.round(e/st)}function bu(e){return e.use12Hour??e.hour12??!1}function Tn({values:e,selected:r,onSelect:n,syncEpochRef:a,forceSyncAt:o=0,width:l=uu,label:i,maxNumeric:c=59,isMeridiem:d=!1,isFocused:u=!1,onFocus:m,onAdvance:f,onBack:b,setColumnRef:v}){const x=s.useRef(null),E=s.useRef(null),h=s.useRef(null),$=s.useRef(""),M=s.useRef(0),y=s.useRef(!1),[w,k]=s.useState(r),[N,A]=s.useState(""),C=s.useCallback(g=>{$.current=g,A(g)},[]),j=s.useMemo(()=>[...Array(Ho).fill(""),...e,...Array(Ho).fill("")],[e]),W=s.useCallback(()=>{const g=x.current;if(!g)return r;const P=Fo(g.scrollTop),I=Math.min(Math.max(P,0),e.length-1);return e[I]??r},[r,e]),G=s.useCallback((g,P=!0)=>{const I=Math.min(Math.max(g,0),e.length-1),te=e[I],U=x.current;!U||!te||(E.current&&(window.clearTimeout(E.current),E.current=null),y.current=!0,M.current=I,U.scrollTop=Bo(I),k(te),P&&te!==r&&n(te))},[n,r,e]);s.useLayoutEffect(()=>{E.current&&(window.clearTimeout(E.current),E.current=null),h.current&&(window.clearTimeout(h.current),h.current=null),C(""),k(r);const g=e.indexOf(r);if(g>=0&&(M.current=g),g<0||!x.current)return;const P=Bo(g);x.current.scrollTop!==P&&(x.current.scrollTop=P)},[o,r,C,e]);const T=s.useCallback(()=>{h.current&&(window.clearTimeout(h.current),h.current=null)},[]),Z=s.useCallback((g,P=!1)=>{T(),C("");const I=Number(g);if(!Number.isFinite(I))return;const te=Math.min(c,Math.max(0,I));let U=Ye(te),K=e.indexOf(U);if(K<0){const D=Math.min(e.length-1,Math.max(0,te-(c===12?1:0)));U=e[D]??U,K=e.indexOf(U)}K>=0&&G(K),P&&(f==null||f())},[T,c,f,G,C,e]),H=s.useCallback(g=>{const P=Math.floor(c/10),I=$.current;if(I===""){if(g>P){Z(String(g),!0);return}const U=String(g);C(U),h.current=window.setTimeout(()=>{Z($.current,!0)},1200);return}T();const te=+`${I}${g}`;te<=c?Z(String(te),!0):Z(String(g),!0)},[T,Z,c,C]),ae=s.useCallback(g=>{T(),C(""),G(M.current+g)},[T,G,C]),X=g=>{if(d){g.key==="a"||g.key==="A"?(g.preventDefault(),n("AM"),f==null||f()):g.key==="p"||g.key==="P"?(g.preventDefault(),n("PM"),f==null||f()):g.key==="ArrowUp"||g.key==="ArrowDown"?(g.preventDefault(),n(r==="AM"?"PM":"AM")):g.key==="Tab"&&(g.preventDefault(),g.shiftKey?b==null||b():f==null||f());return}if(/^\d$/.test(g.key)){g.preventDefault(),H(Number(g.key));return}g.key==="ArrowUp"?(g.preventDefault(),ae(-1)):g.key==="ArrowDown"?(g.preventDefault(),ae(1)):g.key==="Tab"&&(g.preventDefault(),T(),$.current!==""&&Z($.current,!1),g.shiftKey?b==null||b():f==null||f())},V=s.useCallback(()=>{const g=a.current,P=x.current;P&&g===a.current&&G(Fo(P.scrollTop))},[G,a]),q=()=>{if($.current!=="")return;if(y.current){y.current=!1;const P=W();k(P);const I=e.indexOf(P);I>=0&&(M.current=I);return}k(W()),E.current&&window.clearTimeout(E.current);const g=a.current;E.current=window.setTimeout(()=>{g===a.current&&V()},100)},L="absolute left-0 right-0 z-40 flex items-center justify-center border-0 bg-transparent p-0 transition-opacity duration-150 hover:opacity-80 focus:outline-none",oe=st*qa,B=oe+Ct*2,F=N!==""?N:null,le=F!==null;return t.jsxs("div",{ref:v,role:"spinbutton",tabIndex:u?0:-1,"aria-label":i,"aria-valuetext":F??r,"aria-valuenow":d?void 0:Number(r),onFocus:m,onMouseDown:()=>m==null?void 0:m(),onKeyDown:X,onBlur:()=>{T(),$.current!==""&&Z($.current,!1)},className:"relative shrink-0 rounded-lg outline-none",style:{width:l,height:B,boxShadow:u?"0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent)":"none"},children:[t.jsx("button",{type:"button","aria-label":"Valor anterior",className:L,style:{top:0,height:Ct,color:"var(--text-muted)",opacity:.35},onClick:()=>ae(-1),children:t.jsx(z.HiChevronUp,{className:"h-3.5 w-3.5"})}),t.jsx("div",{ref:x,className:"absolute inset-x-0 overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",style:{top:Ct,height:oe,scrollSnapType:"y mandatory",scrollBehavior:"auto"},onScroll:q,onMouseUp:V,onTouchEnd:V,children:j.map((g,P)=>{const I=g!==""&&g===w;return t.jsx("button",{type:"button",tabIndex:-1,disabled:!g,onClick:()=>{if(!g)return;const te=e.indexOf(g);te>=0&&G(te)},className:"flex w-full items-center justify-center tabular-nums leading-none disabled:cursor-default",style:{height:st,scrollSnapAlign:"center",color:I?"var(--text-main)":"var(--text-muted)",fontSize:I?16:14,fontWeight:I?600:400,opacity:g?le?I?0:.35:I?1:.35:0},children:g},`wheel-${P}-${g}`)})}),F!==null?t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-50 flex items-center justify-center tabular-nums font-semibold leading-none",style:{top:Ct+oe/2-st/2,height:st,color:"var(--text-main)",fontSize:16,background:"var(--bg-card)"},children:F}):null,t.jsx("button",{type:"button","aria-label":"Valor siguiente",className:L,style:{bottom:0,height:Ct,color:"var(--text-muted)",opacity:.35},onClick:()=>ae(1),children:t.jsx(z.HiChevronDown,{className:"h-3.5 w-3.5"})})]})}function Po(){return t.jsx("span",{className:"flex shrink-0 items-center justify-center self-center text-base font-medium tabular-nums leading-none",style:{color:"var(--text-muted)",height:st,width:14,opacity:.45},"aria-hidden":!0,children:":"})}function _o({value:e,onChange:r,use12Hour:n,hour12:a,showSeconds:o=!1,title:l="Seleccionar hora",variant:i="panel",onCancel:c,onConfirm:d,className:u=""}){const m=i==="popover",f=m||!d,b=bu({use12Hour:n,hour12:a}),v=s.useRef(e),x=ja(e,fr()),E=$n(x),[h,$]=s.useState(Ye(b?E.hour12:x.hour24)),[M,y]=s.useState(Ye(x.minute)),[w,k]=s.useState(Ye(x.second)),[N,A]=s.useState(E.meridiem),[C,j]=s.useState(0),W=s.useRef(0),G=s.useRef(!1),T=s.useRef({hour:null,minute:null,second:null,meridiem:null}),[Z,H]=s.useState("hour"),ae=s.useMemo(()=>{const ie=["hour","minute"];return o&&ie.push("second"),b&&ie.push("meridiem"),ie},[b,o]),X=s.useCallback(ie=>{H(pe=>{const Ce=ae.indexOf(pe);return ae[(Ce+ie+ae.length)%ae.length]})},[ae]);s.useEffect(()=>{var ie;(ie=T.current[Z])==null||ie.focus()},[Z]),s.useEffect(()=>{var ie;H("hour"),(ie=T.current.hour)==null||ie.focus()},[]),s.useEffect(()=>{if(e===v.current)return;v.current=e;const ie=ja(e,fr()),pe=$n(ie);$(Ye(b?pe.hour12:ie.hour24)),y(Ye(ie.minute)),k(Ye(ie.second)),A(pe.meridiem)},[b,e]);const V=s.useMemo(()=>(b?Wa(1,12):Wa(0,23)).map(ie=>Ye(ie)),[b]),q=s.useMemo(()=>Wa(0,59).map(ie=>Ye(ie)),[]),L=q,oe=s.useMemo(()=>["AM","PM"],[]),B=s.useCallback(()=>b?Vr({hour12:Number(h),minute:Number(M),second:Number(w),meridiem:N}):{hour24:Number(h),minute:Number(M),second:Number(w)},[h,b,N,M,w]),F=s.useCallback(ie=>{if(G.current)return;const pe=Ur(ie,o);v.current=pe,r(pe)},[r,o]),le=s.useCallback(()=>{F(B())},[B,F]),g=ie=>{$(ie),f&&F(b?Vr({hour12:Number(ie),minute:Number(M),second:Number(w),meridiem:N}):{hour24:Number(ie),minute:Number(M),second:Number(w)})},P=ie=>{y(ie),f&&F(b?Vr({hour12:Number(h),minute:Number(ie),second:Number(w),meridiem:N}):{hour24:Number(h),minute:Number(ie),second:Number(w)})},I=ie=>{k(ie),f&&F(b?Vr({hour12:Number(h),minute:Number(M),second:Number(ie),meridiem:N}):{hour24:Number(h),minute:Number(M),second:Number(ie)})},te=ie=>{A(ie),f&&F(Vr({hour12:Number(h),minute:Number(M),second:Number(w),meridiem:ie}))},U=s.useCallback(()=>(W.current+=1,j(W.current),W.current),[]),K=s.useCallback(ie=>{const pe=$n(ie),Ce=Ur(ie,o);v.current=Ce,$(Ye(b?pe.hour12:ie.hour24)),y(Ye(ie.minute)),k(Ye(ie.second)),A(pe.meridiem),r(Ce)},[b,r,o]),D=()=>{G.current=!0,U(),K(fr()),queueMicrotask(()=>{const ie=fr();Ur(ie,o)!==v.current&&(U(),K(ie)),G.current=!1})},ee=()=>{le(),d==null||d()},_=st*qa,se=_+Ct*2,Q=Ct+_/2-st/2,de=t.jsx("div",{className:"relative px-4 py-2",children:t.jsxs("div",{className:"relative mx-auto",style:{height:se,maxWidth:"100%"},children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-10 rounded-xl",style:{top:Q,height:st,background:"color-mix(in srgb, var(--primary) 10%, var(--bg-input))",border:"1px solid color-mix(in srgb, var(--primary) 22%, transparent)"}}),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-20",style:{top:Ct,height:st*1.35,background:"linear-gradient(to bottom, var(--bg-card) 40%, transparent 100%)"}}),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-20",style:{bottom:Ct,height:st*1.35,background:"linear-gradient(to top, var(--bg-card) 40%, transparent 100%)"}}),t.jsxs("div",{className:"relative z-30 flex h-full items-center justify-center gap-1",children:[t.jsx(Tn,{syncEpochRef:W,forceSyncAt:C,values:V,selected:h,onSelect:g,label:"Horas",maxNumeric:b?12:23,isFocused:Z==="hour",onFocus:()=>H("hour"),onAdvance:()=>X(1),onBack:()=>X(-1),setColumnRef:ie=>{T.current.hour=ie}}),t.jsx(Po,{}),t.jsx(Tn,{syncEpochRef:W,forceSyncAt:C,values:q,selected:M,onSelect:P,label:"Minutos",maxNumeric:59,isFocused:Z==="minute",onFocus:()=>H("minute"),onAdvance:()=>X(1),onBack:()=>X(-1),setColumnRef:ie=>{T.current.minute=ie}}),o?t.jsxs(t.Fragment,{children:[t.jsx(Po,{}),t.jsx(Tn,{syncEpochRef:W,forceSyncAt:C,values:L,selected:w,onSelect:I,label:"Segundos",maxNumeric:59,isFocused:Z==="second",onFocus:()=>H("second"),onAdvance:()=>X(1),onBack:()=>X(-1),setColumnRef:ie=>{T.current.second=ie}})]}):null,b?t.jsx("div",{className:"ml-3 shrink-0 pl-1",children:t.jsx(Tn,{syncEpochRef:W,forceSyncAt:C,values:oe,selected:N,onSelect:ie=>te(ie),width:fu,label:"AM o PM",isMeridiem:!0,isFocused:Z==="meridiem",onFocus:()=>H("meridiem"),onAdvance:()=>X(1),onBack:()=>X(-1),setColumnRef:ie=>{T.current.meridiem=ie}})}):null]})]})}),Se=t.jsxs("div",{className:`flex items-center ${m?"justify-center px-3 py-2":"justify-between gap-2 px-3 py-2.5"}`,style:{borderTop:m?"none":"1px solid color-mix(in srgb, var(--border) 80%, transparent)"},children:[t.jsx(je,{variant:"ghost",size:"sm",onClick:D,className:m?"text-xs":void 0,children:"Ahora"}),!m&&(c||d)?t.jsxs("div",{className:"flex items-center gap-2",children:[c?t.jsx(je,{variant:"ghost",size:"sm",onClick:c,children:"Cancelar"}):null,d?t.jsx(je,{variant:"primary",size:"sm",onClick:ee,children:"Listo"}):null]}):null]});return t.jsxs("div",{className:`overflow-hidden ${u}`,style:{borderRadius:m?12:14,border:m?"1px solid color-mix(in srgb, var(--border) 85%, transparent)":"1px solid var(--border)",background:"var(--bg-card)",boxShadow:m?"0 12px 40px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06)":"0 1px 3px rgba(15, 23, 42, 0.06)",minWidth:b?o?300:260:o?252:212},children:[!m&&l?t.jsx("div",{className:"border-b px-3 py-2.5",style:{borderColor:"color-mix(in srgb, var(--border) 80%, transparent)"},children:t.jsx("h3",{className:"text-sm font-semibold",style:{color:"var(--text-main)"},children:l})}):null,de,Se]})}function mu(e){return e.use12Hour??e.hour12??!1}function pu({label:e,value:r,onChange:n,use12Hour:a,hour12:o,showSeconds:l=!1,title:i="Seleccionar hora",placeholder:c="Seleccionar hora",disabled:d=!1,displayMode:u="popover",required:m,error:f,helperText:b,helperDisplay:v,className:x,contentClassName:E,className:h=""}){const $=u==="popover",[M,y]=s.useState(!1),w=s.useRef(null),[k,N]=s.useState({horizontal:"left",vertical:"bottom"}),A=mu({use12Hour:a,hour12:o}),C=s.useMemo(()=>r?cu(r,{use12Hour:A,showSeconds:l}):"",[A,l,r]);s.useEffect(()=>{if(!$||!M||!w.current)return;const G=w.current.getBoundingClientRect(),T=8,Z=A?l?300:260:l?252:212,H=276,ae=G.left+Z>window.innerWidth-T,X=G.right-Z>=T,V=G.bottom+8+H>window.innerHeight-T,q=G.top-8-H>=T;N({horizontal:ae&&X?"right":"left",vertical:V&&q?"top":"bottom"})},[A,$,M,l]),s.useEffect(()=>{if(!$||!M)return;function G(Z){w.current&&(w.current.contains(Z.target)||y(!1))}function T(Z){Z.key==="Escape"&&y(!1)}return document.addEventListener("mousedown",G),document.addEventListener("keydown",T),()=>{document.removeEventListener("mousedown",G),document.removeEventListener("keydown",T)}},[$,M]);const j=t.jsxs("button",{type:"button",disabled:d,onClick:()=>{d||y(G=>!G)},className:`flex h-10 w-full items-center justify-between gap-2 rounded-lg border px-2.5 text-sm transition-all duration-150 focus:outline-none disabled:cursor-not-allowed disabled:opacity-60 ${h}`,style:{background:"var(--bg-input)",borderColor:f?"var(--danger)":M?"var(--primary)":"var(--border)",color:C?"var(--text-main)":"var(--text-muted)",boxShadow:M?"0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent)":"none"},children:[t.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2",children:[t.jsx(z.HiClock,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:C||c})]}),$?t.jsx(z.HiChevronDown,{className:`h-4 w-4 shrink-0 text-[var(--text-muted)] transition-transform duration-150 ${M?"rotate-180":""}`}):null]}),W=t.jsx(_o,{variant:$?"popover":"panel",value:r||du(l),onChange:n,use12Hour:A,showSeconds:l,title:i,onClose:()=>y(!1)});return t.jsx(Ea,{label:e,required:m,error:f,helperText:b,helperDisplay:v,className:x,contentClassName:E,children:$?t.jsxs("div",{ref:w,className:"relative w-full",children:[j,M?t.jsx("div",{className:"absolute z-50",style:{...k.horizontal==="left"?{left:0}:{right:0},...k.vertical==="bottom"?{top:"calc(100% + 6px)"}:{bottom:"calc(100% + 6px)"}},children:W}):null]}):t.jsxs("div",{className:"space-y-2",children:[j,M?W:null]})})}const hu={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function gu({checked:e,disabled:r,onCheckedChange:n,size:a="sm",className:o="",...l}){const i=hu[a],c=e?i.width-i.thumb-i.padding*2:0;return t.jsx("button",{...l,type:"button",role:"switch","aria-checked":e,disabled:r,onClick:()=>!r&&n(!e),className:`relative inline-flex shrink-0 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/50 disabled:cursor-not-allowed disabled:opacity-50 ${o}`,style:{width:i.width,height:i.height,background:e?"color-mix(in srgb, var(--primary) 85%, transparent)":"var(--bg-input)",border:e?"1px solid color-mix(in srgb, var(--primary) 55%, transparent)":"1px solid var(--border)"},children:t.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:e?"var(--primary-fg)":"var(--text-muted)"}})})}const zo=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),vu=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function yu(e){if(!(e instanceof HTMLElement)||e.dataset.overlayScroll==="false"||e.matches("[data-overlayscrollbars]")||e.closest("[data-overlayscrollbars]")||e.matches("textarea,input,select,[contenteditable='true']"))return!1;const r=window.getComputedStyle(e);return!(![r.overflow,r.overflowX,r.overflowY].join(" ").match(/auto|scroll/)||e.clientWidth===0&&e.clientHeight===0)}function jo(e){return e.classList.contains("sidebar-scroll")||e.classList.contains("showcase-nav-scroll")}function Wo(e){jo(e)&&e.querySelectorAll(".os-scrollbar-horizontal").forEach(r=>{r.style.display="none",r.style.height="0",r.style.pointerEvents="none"})}function xu(e){const r=e.querySelector(vu);return r instanceof HTMLElement?r:null}function qo(){return s.useEffect(()=>{const e=new WeakMap;let r=0;const n=()=>{r=0,document.querySelectorAll(zo).forEach(l=>{if(!(l instanceof HTMLElement))return;if(oa.OverlayScrollbars(l)){Wo(l);return}if(!yu(l))return;const c={overflow:jo(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},d=xu(l),u=d?oa.OverlayScrollbars({target:l,elements:{viewport:d}},c):oa.OverlayScrollbars(l,c);Wo(l),e.set(l,u)})},a=()=>{r||(r=window.requestAnimationFrame(n))};n();const o=new MutationObserver(a);return o.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","data-overlay-scroll"]}),window.addEventListener("resize",a),()=>{r&&window.cancelAnimationFrame(r),o.disconnect(),window.removeEventListener("resize",a),document.querySelectorAll(zo).forEach(l=>{var i;l instanceof HTMLElement&&((i=e.get(l))==null||i.destroy())})}},[]),null}function It(e){const r=e.trim();return!r||r==="/"||r==="/."?"":(r.startsWith("/")?r:`/${r}`).replace(/\/+$/,"")}function Uo(e){try{const r=new URL(e);return It(r.pathname)}catch{return""}}function wu(e){const r=It(e);if(!r)return"";const n=r.match(/^\/apps\/[^/]+/i);if(n)return It(n[0]);const a=r.split("/").filter(Boolean);return a.length===0?"":a.length>=2&&a[0].toLowerCase()==="apps"?It(`/${a[0]}/${a[1]}`):new Set(["admin","apps","apps-list","tickets","my-tickets","projects","projects-calendars","dashboard","teams","clients","services","settings","profile","messages","notifications","my-access","my-registers","my-pings","security-incidents","email-inbox","webhook-config","webphone-config","vobo","auth","api","login","forbidden","unauthorized","change-password","reset-password","chat-widget"]).has(a[0].toLowerCase())?"":It(`/${a[0]}`)}const Ua="primeSuiteAppUrl",ku={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"}},Vo={xs:20,sm:28,md:36,lg:48,xl:64},Yo=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],Nu={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Su="bonsaif.bot",Cu="Bonsaif Bot",Eu={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Xo(e){return typeof e=="string"?e.trim():""}function Mu(e){var o;if(e!==void 0)return It(e);const r=It(typeof process<"u"&&((o=process.env)==null?void 0:o.NEXT_PUBLIC_BASE_PATH)||"");if(r)return r;if(typeof window>"u")return"";try{const i=new URLSearchParams(window.location.search).get(Ua)||"";i&&window.sessionStorage.setItem(Ua,i);const c=window.sessionStorage.getItem(Ua)||"",d=i||c;if(d){const u=Uo(d);if(u&&!/^\/admin(\/|$)/i.test(u))return u}}catch{}const n=window.__NEXT_DATA__,a=(n==null?void 0:n.assetPrefix)||"";if(a){const l=a.startsWith("http")?Uo(a):It(a);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return wu(window.location.pathname)}function $u(e){const r=e.split(/\s+/).map(n=>n.trim()).filter(Boolean);return r.length===0?"?":r.length===1?r[0].slice(0,1).toUpperCase():`${r[0].slice(0,1)}${r[1].slice(0,1)}`.toUpperCase()}function Tu(e){let r=0;for(const n of e)r=r*31+n.charCodeAt(0)&65535;return Yo[r%Yo.length]}function Lu(e,r){return e===Su||r===Cu}function Au(e,r){return`${e.replace(/\/$/,"")}${r}`}function Ko({userId:e,username:r,name:n,size:a="md",showName:o=!1,showTooltip:l,tooltipContent:i,fallbackLabel:c="Usuario",basePath:d,wrapperClassName:u="",labelClassName:m="",labelSize:f="xs",avatarVersion:b=0,className:v="",style:x}){const[E,h]=s.useState(!1),$=typeof e=="string"&&e.trim()&&e!=="undefined"&&e!=="null"?e.trim():"";s.useEffect(()=>{h(!1)},[$,b]);const{wh:M,text:y}=ku[a],w=Xo(n)||Xo(r)||c,k=$u(w),N=Mu(d),A=Lu(r,n),C=Au(N,"/favicon.svg"),j=s.useMemo(()=>{if(!$)return"";const H=new URLSearchParams;H.set("size",String(Vo[a])),b&&H.set("v",String(b));const ae=H.toString();return`${N}/api/user/avatar/${encodeURIComponent($)}${ae?`?${ae}`:""}`},[b,N,$,a]),W=Vo[a],G=A?t.jsx("span",{className:`${M} ${Eu[a]} rounded-full flex items-center justify-center bg-[#071f1a] ring-1 ring-emerald-400/35 shadow-[0_0_0_1px_rgba(255,255,255,0.06)] flex-shrink-0 ${v}`,style:x,children:t.jsx("img",{src:C,alt:w,width:W,height:W,className:"h-full w-full object-contain"})}):j&&!E?t.jsx("img",{src:j,alt:w,width:W,height:W,className:`${M} rounded-full object-cover flex-shrink-0 ${v}`,style:x,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>h(!0)},`${$}-${b}`):t.jsx("span",{className:`${M} ${Tu(w)} ${y} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${v}`,style:x,title:w,children:k});if(o)return t.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${u}`,children:[G,t.jsx("span",{className:`min-w-0 truncate ${Nu[f]} font-medium text-[var(--text-main)] ${m}`,title:w,children:w})]});const T=l??!0,Z=i??w;return T&&Z?t.jsx(zt,{as:"span",content:Z,className:`inline-flex flex-shrink-0 ${u}`,children:G}):G}function Du({href:e,className:r,children:n}){return t.jsx("a",{href:e,className:r,children:n})}function Iu(e){return e.reduce((r,n)=>{const a=n.section??"Principal";return r[a]=[...r[a]??[],n],r},{})}function Go({children:e,navItems:r=[],currentPath:n=typeof window>"u"?"/":window.location.pathname,user:a,appName:o="Bonsaif",appLogo:l,header:i,footer:c,onLogout:d,LinkComponent:u=Du}){const[m,f]=s.useState(!1),b=Iu(r);return t.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[t.jsx(qo,{}),t.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:()=>f(!0),children:t.jsx(z.HiBars3,{className:"h-5 w-5"})}),m&&t.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>f(!1)}),t.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:[t.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[t.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:l??t.jsx(z.HiHome,{className:"h-5 w-5"})}),t.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:o}),t.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:()=>f(!1),children:t.jsx(z.HiXMark,{className:"h-5 w-5"})})]}),t.jsx("nav",{className:"sidebar-scroll min-h-0 flex-1 overflow-y-auto px-3 py-4","data-overlay-scroll":"true",children:t.jsx("div",{className:"sidebar-scroll-body",children:Object.entries(b).map(([v,x])=>t.jsxs("div",{className:"mb-5",children:[t.jsxs("div",{className:"mb-2 flex items-center gap-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-white/35",children:[t.jsx(z.HiChevronDown,{className:"h-3.5 w-3.5"}),v]}),t.jsx("div",{className:"space-y-1",children:x.map(E=>{const h=n===E.href||n.startsWith(`${E.href}/`);return t.jsxs(u,{href:E.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${h?"bg-white/10 text-white":"text-white/55 hover:bg-white/[0.06] hover:text-white/85"}`,children:[t.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:E.icon??t.jsx(z.HiHome,{className:"h-4 w-4"})}),t.jsx("span",{className:"truncate",children:E.label})]},E.href)})})]},v))})}),t.jsxs("div",{className:"border-t border-white/10 p-3",children:[a&&t.jsxs("div",{className:"mb-3 flex min-w-0 items-center gap-3 rounded-lg bg-white/[0.04] p-2",children:[t.jsx(Ko,{name:a.initials??a.name??a.email??"Usuario",size:"md"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-sm font-medium text-white",children:a.name??"Usuario"}),a.email&&t.jsx("div",{className:"truncate text-xs text-white/45",children:a.email})]})]}),d&&t.jsxs(je,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:d,children:[t.jsx(z.HiArrowRightOnRectangle,{className:"h-4 w-4"})," Salir"]}),c]})]}),t.jsxs("div",{className:"min-h-screen lg:pl-72",children:[i,t.jsx("main",{className:"min-h-screen",children:e})]})]})}const Zo="bonsaif-ui:prime-auth-sso",Ou={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"},Va={dashboard:t.jsx(z.HiChartBar,{className:"h-5 w-5"}),tickets:t.jsx(z.HiTicket,{className:"h-5 w-5"}),teams:t.jsx(z.HiUsers,{className:"h-5 w-5"}),projects:t.jsx(z.HiRectangleGroup,{className:"h-5 w-5"}),clients:t.jsx(z.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:t.jsx(z.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:t.jsx(z.HiUser,{className:"h-5 w-5"}),settings:t.jsx(z.HiCog6Tooth,{className:"h-5 w-5"}),notifications:t.jsx(z.HiBell,{className:"h-5 w-5"}),changelog:t.jsx(z.HiDocumentText,{className:"h-5 w-5"}),admin:t.jsx(z.HiShieldCheck,{className:"h-5 w-5"}),users:t.jsx(z.HiUsers,{className:"h-5 w-5"}),roles:t.jsx(z.HiShieldCheck,{className:"h-5 w-5"}),menus:t.jsx(z.HiCog6Tooth,{className:"h-5 w-5"}),guards:t.jsx(z.HiCalendarDays,{className:"h-5 w-5"}),vacations:t.jsx(z.HiCalendarDays,{className:"h-5 w-5"}),audit:t.jsx(z.HiListBullet,{className:"h-5 w-5"}),positions:t.jsx(z.HiBriefcase,{className:"h-5 w-5"}),ranks:t.jsx(z.HiListBullet,{className:"h-5 w-5"}),"email-inbox":t.jsx(z.HiInbox,{className:"h-5 w-5"}),"security-incidents":t.jsx(z.HiShieldCheck,{className:"h-5 w-5"})};function Hu(e){return e.split("-").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function Bu(e){return/^\d+$/.test(e)||/^[a-f0-9]{8,}$/i.test(e)}function Fu(e){const r=e.split("/").filter(Boolean);if(r.length===0||r.length===1&&r[0]==="dashboard")return[];const n=decodeURIComponent(r[r.length-1]),a=r.length>1?decodeURIComponent(r[r.length-2]):void 0,o=Bu(n)&&a?a:n,l=Ou[o]??Hu(o);return[{label:"Inicio",href:"/"},{label:l}]}function Ya(e){return(e==null?void 0:e.querySelector(":scope > .os-viewport"))??(e==null?void 0:e.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function Pu(e){const r=e.split("/").filter(Boolean),n=r[r.length-1];if(!n)return t.jsx(z.HiHome,{className:"h-5 w-5"});if(Va[n])return Va[n];const a=r.length>1?r[r.length-2]:"";return Va[a]??t.jsx(z.HiHome,{className:"h-5 w-5"})}function _u(e){return e.includes("primeAuthOrigin")||e.includes("primeAuthProjectKey")}function Qo(){if(typeof window>"u")return!1;if(_u(window.location.href)){try{window.sessionStorage.setItem(Zo,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Zo)==="true"}catch{return!1}}function zu({title:e,subtitle:r,action:n,meta:a,icon:o,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:d,showBreadcrumbs:u=!0,contained:m=!1}){const f=s.useRef(null),[b,v]=s.useState(!1),[x,E]=s.useState(d??"/"),[h,$]=s.useState(()=>Qo()),[M,y]=s.useState(null),w=d??x,k=c??Fu(w),N=o??Pu(w),A=u&&!h&&k.length>1,C=!A;s.useEffect(()=>{d||E(window.location.pathname)},[d]),s.useEffect(()=>{$(Qo())},[]),s.useEffect(()=>{if(m){v(!1);return}let W=null,G=0,T=0;const Z=()=>{const X=f.current,V=document.querySelector("[data-app-scroll='true']");return(X==null?void 0:X.closest(".os-viewport"))??(X==null?void 0:X.closest("[data-overlayscrollbars-viewport]"))??Ya(V)??V??window},H=()=>{const X=W&&W!==window?W.scrollTop:window.scrollY;v(V=>V?X>24:X>72)},ae=()=>{W==null||W.removeEventListener("scroll",H),W=Z(),W.addEventListener("scroll",H,{passive:!0}),H()};return ae(),G=window.requestAnimationFrame(ae),T=window.setTimeout(ae,120),()=>{window.cancelAnimationFrame(G),window.clearTimeout(T),W==null||W.removeEventListener("scroll",H)}},[m]),s.useEffect(()=>{if(m){y(null);return}let W=0;const G=[],T=()=>{const L=f.current,oe=L==null?void 0:L.parentElement,B=document.querySelector("[data-app-scroll='true']"),F=Ya(B)??B;if(!L||!oe||!F){y(null);return}const le=oe.getBoundingClientRect(),g=window.getComputedStyle(oe),P=F.getBoundingClientRect(),I=F instanceof HTMLElement&&F.clientWidth>0?F.clientWidth:P.width,te=le.left+parseFloat(g.paddingLeft||"0"),U={marginLeft:Math.round(P.left-te),width:Math.round(I)};y(K=>K&&K.marginLeft===U.marginLeft&&K.width===U.width?K:U)},Z=()=>{window.cancelAnimationFrame(W),W=window.requestAnimationFrame(T)};Z(),window.addEventListener("resize",Z);const H=new ResizeObserver(Z),ae=f.current,X=ae==null?void 0:ae.parentElement,V=document.querySelector("[data-app-scroll='true']"),q=Ya(V)??V;return[X,V,q].forEach(L=>{L&&H.observe(L)}),G.push(window.setTimeout(Z,120)),G.push(window.setTimeout(Z,280)),()=>{window.cancelAnimationFrame(W),window.removeEventListener("resize",Z),H.disconnect(),G.forEach(L=>window.clearTimeout(L))}},[m]);const j={...M?{marginLeft:M.marginLeft,width:M.width}:null,"--page-header-control-height":b?"34px":"40px","--page-header-control-padding-x":b?"10px":"14px","--page-header-control-icon-left":b?"10px":"12px",background:m?"var(--bg-card)":b?"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||b?"1px solid var(--border)":"1px solid transparent",boxShadow:b?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return t.jsx("div",{ref:f,"data-page-header":"true","data-compact":b?"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:t.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${b?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":C?"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:[t.jsx("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${b||C?"gap-1":"gap-1.5 sm:gap-2"}`,children:t.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${b||C?"gap-2":"gap-2.5 sm:gap-3"}`,children:[t.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${b?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:A?"var(--text-secondary)":"var(--text-muted)"},children:N}),t.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${b?"gap-x-2 gap-y-1":"gap-x-3 gap-y-2"}`,children:[t.jsxs("div",{className:"min-w-0 flex-shrink transition-[transform] duration-300 ease-out",children:[t.jsx("h1",{className:`truncate font-bold tracking-tight transition-[font-size,line-height,color] duration-300 ease-out ${b?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:e}),r&&t.jsx("div",{"aria-hidden":b,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${b?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-8 translate-y-0 opacity-100"}`,style:{color:"var(--text-muted)"},children:r})]}),a&&t.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 ${b?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:a})]})]})}),n&&t.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 ${b?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:t.jsx(hs.Provider,{value:{compact:!0,headerAction:!0},children:n})})]})})}function ju({children:e,currentPath:r=typeof window>"u"?"/":window.location.pathname,publicRoutes:n=["/","/login","/reset-password"],...a}){return n.includes(r)?t.jsx(t.Fragment,{children:e}):t.jsx(Go,{currentPath:r,...a,children:e})}function Jo(){if(typeof window>"u")return"system";const e=localStorage.getItem("theme");return e==="light"||e==="dark"?e:e==="system"?"system":document.documentElement.classList.contains("dark")?"dark":"light"}function Wu(e,r,n){try{const a=new URL(e),o=a.searchParams.get("callbackUrl");if(o){const l=new URL(o,a.origin);return l.searchParams.set("theme",r),n&&(l.searchParams.set("primeAuthOrigin",window.location.origin),l.searchParams.set("primeAuthProjectKey",n)),a.searchParams.set("callbackUrl",`${l.pathname}${l.search}${l.hash}`),a.toString()}return a.searchParams.set("theme",r),n&&(a.searchParams.set("primeAuthOrigin",window.location.origin),a.searchParams.set("primeAuthProjectKey",n)),a.toString()}catch{return e}}function qu({name:e,src:r,projectKey:n}){const[a,o]=s.useState("system"),l=s.useRef(null);s.useEffect(()=>{o(Jo());const d=new MutationObserver(()=>o(Jo()));return d.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>d.disconnect()},[]);const i=s.useMemo(()=>Wu(r,a,n),[n,r,a]),c=s.useMemo(()=>{try{return new URL(i).origin}catch{return""}},[i]);return s.useEffect(()=>{if(!n)return;const d=n;function u(m){var v,x,E;if(m.source!==((v=l.current)==null?void 0:v.contentWindow)||c&&m.origin!==c)return;if(((x=m.data)==null?void 0:x.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!m.data.active}}));return}if(((E=m.data)==null?void 0:E.type)!=="prime-microservice:navigation")return;const f=m.data.path;if(!f||!f.startsWith("/")||f.startsWith("//"))return;const b=`/apps/${encodeURIComponent(d)}${f}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==b&&(window.history.replaceState(window.history.state,"",b),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",u),()=>{window.removeEventListener("message",u),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[c,n]),t.jsx("div",{className:"flex h-full min-h-screen flex-col bg-[var(--bg-main)]",children:t.jsx("iframe",{ref:l,src:i,title:e,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 Uu(){const[e,r]=s.useState(""),[n,a]=s.useState(!1),[o,l]=s.useState({width:96,height:96});return s.useEffect(()=>{let i=!1;return fetch("/api/microservices/prime-suite/chat-url",{cache:"no-store"}).then(c=>c.ok?c.json():null).then(c=>{!i&&(c!=null&&c.src)&&r(c.src)}).catch(()=>{}),()=>{i=!0}},[]),s.useEffect(()=>{const i=c=>{var u;if(((u=c.data)==null?void 0:u.type)!=="prime-suite-chat:state")return;const d=!!c.data.active;a(d),l({width:Ro(c.data.width,96,720),height:Ro(c.data.height,96,560)})};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[]),e?t.jsx("iframe",{title:"Chat Bonsaif",src:e,allow:"clipboard-write",className:"fixed bottom-0 right-0 z-[70] border-0 bg-transparent transition-[width,height] duration-200",style:{width:n?`min(${o.width}px, 100vw)`:96,height:n?`min(${o.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function Ro(e,r,n){const a=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(r,Math.min(n,Math.ceil(a)))}function Vu(e){const r=document.documentElement,n=new MutationObserver(e);n.observe(r,{attributes:!0,attributeFilter:["class"]});const a=window.matchMedia("(prefers-color-scheme: dark)");return a.addEventListener("change",e),()=>{n.disconnect(),a.removeEventListener("change",e)}}function Yu(){const e=localStorage.getItem("theme")||"system",r=window.matchMedia("(prefers-color-scheme: dark)").matches;return document.documentElement.classList.contains("dark")||e==="dark"||e==="system"&&r?"dark":"light"}function Xu(){return"light"}function Ku({position:e="bottom-center"}){const r=s.useSyncExternalStore(Vu,Yu,Xu);return t.jsx(bs.Toaster,{position:e,theme:r,richColors:!0,closeButton:!0})}function Gu({title:e,subtitle:r,actions:n,loading:a=!1,empty:o=!1,emptyText:l="Sin datos para mostrar",className:i="",children:c}){return t.jsxs("div",{className:`bonsaif-chart-card w-full overflow-visible ${i}`,children:[(e||r||n)&&t.jsxs("div",{className:"bonsaif-chart-card-head",children:[t.jsx("div",{className:"bonsaif-chart-card-accent","aria-hidden":!0}),t.jsxs("div",{className:"bonsaif-chart-card-copy min-w-0",children:[e?t.jsx("div",{className:"bonsaif-chart-card-title",children:e}):null,r?t.jsx("div",{className:"bonsaif-chart-card-subtitle",children:r}):null]}),n?t.jsx("div",{className:"bonsaif-chart-card-actions shrink-0",children:n}):null]}),t.jsx("div",{className:"bonsaif-chart-card-body",children:a?t.jsx("div",{className:"flex h-48 items-center justify-center",children:t.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"})}):o?t.jsx("div",{className:"flex h-48 items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:l}):c})]})}const Yr=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function el(e,r){return e.color??Yr[r%Yr.length]}function yt(e="primary"){switch(e){case"success":return"#34d399";case"warning":return"#fbbf24";case"danger":return"#f87171";case"neutral":return"var(--text-muted)";default:return"var(--primary)"}}const ot=e=>{if(!Number.isFinite(e))return"—";const r=Math.abs(e);return r>=1e9?`${(e/1e9).toFixed(1).replace(/\.0$/,"")}B`:r>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,"")}M`:r>=1e4?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}k`:e.toLocaleString(void 0,{maximumFractionDigits:2})};function br(e){if(e==null||e==="")return null;const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?r:null}const Xa={warning:70,danger:90};function Ln(e,r=Xa){const n=r.warning??Xa.warning,a=r.danger??Xa.danger;return e>=a?"danger":e>=n?"warning":e<=0?"primary":"success"}function Xr(e,r){return yt(Ln(e,r))}function mr(e,r=0){return Number.isFinite(e)?`${e.toFixed(r)}%`:"—"}function pr(e,r=1){if(!Number.isFinite(e))return"—";const n=e<0?"-":"",a=Math.abs(e);if(a<1024)return`${n}${Math.round(a)} B`;const o=["KB","MB","GB","TB","PB"];let l=a/1024,i=0;for(;l>=1024&&i<o.length-1;)l/=1024,i+=1;const c=l>=100?l.toFixed(0):l.toFixed(r);return`${n}${c.replace(/\.0$/,"")} ${o[i]}`}function tl(e,r="bytes",n=1){if(!Number.isFinite(e))return"—";const a=e<0?"-":"",o=Math.abs(e),l=r==="bits"?["b/s","Kb/s","Mb/s","Gb/s","Tb/s"]:["B/s","KB/s","MB/s","GB/s","TB/s"];if(o<1024)return`${a}${Math.round(o)} ${l[0]}`;let i=o/1024,c=1;for(;i>=1024&&c<l.length-1;)i/=1024,c+=1;const d=i>=100?i.toFixed(0):i.toFixed(n);return`${a}${d.replace(/\.0$/,"")} ${l[c]}`}function hr(e,r){var n;for(let a=e.length-1;a>=0;a-=1){const o=br((n=e[a])==null?void 0:n[r]);if(o!==null)return o}return null}function lt({height:e}){return t.jsx("div",{className:"flex items-center justify-center",style:{height:e},"aria-busy":!0,children:t.jsx("div",{className:"h-7 w-7 animate-spin rounded-full border-2",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"}})})}function it({height:e,text:r}){return t.jsx("div",{className:"flex items-center justify-center text-sm",style:{height:e,color:"var(--text-muted)"},children:r})}const Ot=680,qt="ease-out",Zu={top:18,right:8,bottom:12,left:0};function Kr(e){return{...Zu,...e}}function Gr(e){return e.map((r,n)=>({...r,color:el(r,n),label:r.label??r.key}))}function An(e,r){return!e.length||!r.length||e.every(n=>r.every(a=>br(n[a.key])===null))}function ct(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function Zr(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function rl(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function Dn(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function Qu(e,r=ot){if(e==null||e==="")return"—";const n=typeof e=="number"?e:Number(e);return Number.isFinite(n)?r(n):String(e)}function nl(e){return`bonsaif-grad-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function Ju({active:e,label:r,payload:n,valueFormat:a=ot}){var c,d,u,m,f,b;if(!e||!(n!=null&&n.length))return null;const o=n.filter(v=>v.dataKey!=="base"&&v.name!=="base"&&v.value!==null&&v.value!==void 0);if(!o.length)return null;const l=((d=(c=o[0])==null?void 0:c.payload)==null?void 0:d.fullName)??((m=(u=o[0])==null?void 0:u.payload)==null?void 0:m.tooltipLabel)??((b=(f=o[0])==null?void 0:f.payload)==null?void 0:b.display),i=typeof l=="string"&&l.length>0?l:r;return t.jsxs("div",{className:"bonsaif-chart-tooltip-panel",children:[i!=null&&i!==""?t.jsx("div",{className:"bonsaif-chart-tooltip-label",children:String(i)}):null,t.jsx("div",{className:"bonsaif-chart-tooltip-items",children:o.map((v,x)=>{const E=v.payload,h=E&&typeof E.display=="number"?E.display:v.value;return t.jsxs("div",{className:"bonsaif-chart-tooltip-row",children:[t.jsxs("span",{className:"bonsaif-chart-tooltip-name",children:[t.jsx("span",{className:"bonsaif-chart-tooltip-swatch",style:{background:v.color??"var(--primary)"}}),v.name??v.dataKey]}),t.jsx("span",{className:"bonsaif-chart-tooltip-value",children:Qu(h,a)})]},String(v.dataKey??v.name??x))})})]})}function gr({valueFormat:e,content:r,cursor:n,offset:a=12,wrapperStyle:o,allowEscapeViewBox:l,reverseDirection:i,...c}){return t.jsx(Ne.Tooltip,{...c,cursor:n,offset:a,allowEscapeViewBox:l??{x:!1,y:!1},reverseDirection:i??{x:!1,y:!1},wrapperStyle:{outline:"none",zIndex:60,pointerEvents:"none",overflow:"visible",...o},content:r??t.jsx(Ju,{valueFormat:e})})}function al(e,r,n){return n==null?-1:e.findIndex(a=>String(a[r])===String(n))}function sl(e,r,n){if(n<=1)return null;const a=Math.max(0,Math.min(e,r)),o=Math.min(n-1,Math.max(e,r));return o-a<1||a===0&&o>=n-1?null:{startIndex:a,endIndex:o}}function In(e,r,n={}){const{zoomable:a=!1,zoomMode:o="both",brushHeight:l=28,onZoomChange:i}=n,[c,d]=s.useState(null),[u,m]=s.useState(null),f=!!a&&e.length>1,b=f&&(o==="brush"||o==="both"),v=f&&(o==="drag"||o==="both"),x=s.useCallback(G=>{d(G),i==null||i(G)},[i]),E=s.useCallback(()=>{m(null),x(null)},[x]),h=!!c,$=s.useMemo(()=>!c||b?e:e.slice(c.startIndex,c.endIndex+1),[e,b,c]),M=s.useCallback((G,T)=>{const Z=al(e,r,G),H=al(e,r,T);Z<0||H<0||x(sl(Z,H,e.length))},[x,e,r]),y=s.useCallback(G=>{v&&((G==null?void 0:G.activeLabel)===void 0||(G==null?void 0:G.activeLabel)===null||m({leftLabel:G.activeLabel,rightLabel:G.activeLabel}))},[v]),w=s.useCallback(G=>{!v||!u||(G==null?void 0:G.activeLabel)===void 0||(G==null?void 0:G.activeLabel)===null||m(T=>T&&{...T,rightLabel:G.activeLabel})},[u,v]),k=s.useCallback(()=>{if(v){if(!u||u.rightLabel===null||u.rightLabel===void 0){m(null);return}M(u.leftLabel,u.rightLabel),m(null)}},[M,u,v]),N=s.useCallback(G=>{if(b){if(!G){x(null);return}x(sl(G.startIndex??0,G.endIndex??e.length-1,e.length))}},[x,e.length,b]),A=v?{onMouseDown:y,onMouseMove:w,onMouseUp:k,onMouseLeave:()=>{u&&k()}}:{},C=c??{startIndex:0,endIndex:Math.max(0,e.length-1)},j=t.jsxs(t.Fragment,{children:[v&&u&&u.rightLabel!==null&&u.rightLabel!==void 0?t.jsx(Ne.ReferenceArea,{x1:u.leftLabel,x2:u.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,b?t.jsx(Ne.Brush,{dataKey:r,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:C.startIndex,endIndex:C.endIndex,onChange:N,tickFormatter:G=>String(G)}):null]}),W=b?{bottom:Math.max(l+10,36)}:void 0;return{enabled:f,showBrush:b,showDrag:v,viewData:$,isZoomed:h,resetZoom:E,chartHandlers:A,zoomNodes:j,marginExtra:W}}function On({visible:e,onReset:r}){return e?t.jsx("button",{type:"button",className:"bonsaif-chart-zoom-reset",onClick:r,"aria-label":"Restablecer zoom",children:"Restablecer zoom"}):null}function Ru({data:e,xKey:r,series:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:f=ot,yDomain:b,ariaLabel:v="Gráfico de líneas",curve:x=!0,strokeWidth:E=2.25,zoomable:h=!1,zoomMode:$="both",brushHeight:M,onZoomChange:y}){const w=An(e,n),k=Gr(n),N=In(e,r,{zoomable:h,zoomMode:$,brushHeight:M,onZoomChange:y}),A=Kr({...m,...N.marginExtra});return l?t.jsx(lt,{height:a}):w?t.jsx(it,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${o}`,role:"img","aria-label":v,style:{height:a},children:[t.jsx(On,{visible:N.isZoomed,onReset:N.resetZoom}),t.jsx(Ne.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ne.LineChart,{data:N.viewData,margin:A,...N.chartHandlers,children:[c?t.jsx(Ne.CartesianGrid,{strokeDasharray:"2 8",stroke:Zr(),vertical:!1}):null,t.jsx(Ne.XAxis,{dataKey:r,tick:ct(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Ne.YAxis,{tick:ct(),tickLine:!1,axisLine:!1,width:44,domain:b??["auto","auto"],tickFormatter:C=>f(Number(C)),dx:-2}),u?t.jsx(gr,{valueFormat:f,cursor:{stroke:rl(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Ne.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Dn()}):null,k.map((C,j)=>t.jsx(Ne.Line,{type:x?"monotone":"linear",dataKey:C.key,name:C.label,stroke:C.color,strokeWidth:j===0?E+.35:E,strokeOpacity:j===0?1:.88,isAnimationActive:!0,animationDuration:Ot,animationEasing:qt,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:C.color}},C.key)),N.zoomNodes]})})]})}function Hn({data:e,xKey:r,series:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:f=ot,yDomain:b,ariaLabel:v="Gráfico de área",stacked:x=!1,opacity:E=.22,zoomable:h=!1,zoomMode:$="both",brushHeight:M,onZoomChange:y}){const w=An(e,n),k=Gr(n),N=In(e,r,{zoomable:h,zoomMode:$,brushHeight:M,onZoomChange:y}),A=Kr({...m,...N.marginExtra});return l?t.jsx(lt,{height:a}):w?t.jsx(it,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${o}`,role:"img","aria-label":v,style:{height:a},children:[t.jsx(On,{visible:N.isZoomed,onReset:N.resetZoom}),t.jsx(Ne.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ne.AreaChart,{data:N.viewData,margin:A,...N.chartHandlers,children:[t.jsx("defs",{children:k.map(C=>t.jsxs("linearGradient",{id:nl(C.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:C.color,stopOpacity:Math.min(.55,E+.28)}),t.jsx("stop",{offset:"48%",stopColor:C.color,stopOpacity:E*.5}),t.jsx("stop",{offset:"100%",stopColor:C.color,stopOpacity:0})]},C.key))}),c?t.jsx(Ne.CartesianGrid,{strokeDasharray:"2 8",stroke:Zr(),vertical:!1}):null,t.jsx(Ne.XAxis,{dataKey:r,tick:ct(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Ne.YAxis,{tick:ct(),tickLine:!1,axisLine:!1,width:44,domain:b??["auto","auto"],tickFormatter:C=>f(Number(C)),dx:-2}),u?t.jsx(gr,{valueFormat:f,cursor:{stroke:rl(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Ne.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Dn()}):null,k.map(C=>t.jsx(Ne.Area,{type:"monotone",dataKey:C.key,name:C.label,stroke:C.color,fill:`url(#${nl(C.key)})`,strokeWidth:2.25,stackId:x?"stack":void 0,isAnimationActive:!0,animationDuration:Ot,animationEasing:qt,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:C.color}},C.key)),N.zoomNodes]})})]})}function ef({data:e,xKey:r,series:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:f=ot,yDomain:b,ariaLabel:v="Gráfico de barras",layout:x="vertical",mode:E="grouped",barRadius:h=6,categoryAxisWidth:$=64,zoomable:M=!1,zoomMode:y="both",brushHeight:w,onZoomChange:k}){const N=An(e,n),A=Gr(n),C=x==="horizontal",j=In(e,r,{zoomable:M&&!C,zoomMode:y,brushHeight:w,onZoomChange:k}),W=Kr({...m,...j.marginExtra});return l?t.jsx(lt,{height:a}):N?t.jsx(it,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${o}`,role:"img","aria-label":v,style:{height:a},children:[t.jsx(On,{visible:j.isZoomed,onReset:j.resetZoom}),t.jsx(Ne.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ne.BarChart,{data:j.viewData,margin:W,layout:C?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,...j.chartHandlers,children:[c?t.jsx(Ne.CartesianGrid,{strokeDasharray:"2 8",stroke:Zr(),horizontal:!C,vertical:C}):null,C?t.jsxs(t.Fragment,{children:[t.jsx(Ne.XAxis,{type:"number",tick:ct(),tickLine:!1,axisLine:!1,tickFormatter:G=>f(Number(G)),domain:b??["auto","auto"]}),t.jsx(Ne.YAxis,{type:"category",dataKey:r,tick:ct(),tickLine:!1,axisLine:!1,width:$})]}):t.jsxs(t.Fragment,{children:[t.jsx(Ne.XAxis,{dataKey:r,tick:ct(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Ne.YAxis,{tick:ct(),tickLine:!1,axisLine:!1,width:44,domain:b??["auto","auto"],tickFormatter:G=>f(Number(G)),dx:-2})]}),u?t.jsx(gr,{valueFormat:f,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,d?t.jsx(Ne.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Dn()}):null,A.map((G,T)=>t.jsx(Ne.Bar,{dataKey:G.key,name:G.label,fill:G.color,fillOpacity:T===0?1:.82,radius:C?[0,h,h,0]:[h,h,2,2],maxBarSize:20,stackId:E==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:Ot,animationEasing:qt},G.key)),j.zoomNodes]})})]})}function tf(e){return t.jsx(ll,{...e,variant:"pie"})}function rf(e){return t.jsx(ll,{...e,variant:"donut",innerRadius:e.innerRadius??.62,cornerRadius:e.cornerRadius??10,padAngle:e.padAngle??2})}function ol(e,r){return e==null||!Number.isFinite(e)?r:e>0&&e<=1?e*100:e}function ll({data:e,nameKey:r,valueKey:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showLegend:c=!0,showTooltip:d=!0,valueFormat:u=ot,ariaLabel:m,innerRadius:f,outerRadius:b,colors:v=[...Yr],padAngle:x,cornerRadius:E,variant:h}){const $=e.map((T,Z)=>({name:String(T[r]??""),value:br(T[n])??0,fill:v[Z%v.length],row:T})).filter(T=>T.value>0),M=!$.length,y=h==="donut",w=$.length,k=ol(f,y?62:12),N=ol(b,78),A=Math.min(x??(y?2:3),Math.max(.5,10/Math.max(1,w))),C=Math.min(E??(y?10:8),Math.max(2,36/Math.max(1,w)));if(l)return t.jsx(lt,{height:a});if(M)return t.jsx(it,{height:a,text:i});const j=$.reduce((T,Z)=>T+Z.value,0),W=c?Math.min(96,28+Math.ceil(w/3)*22):0,G=Math.max(140,a-W);return t.jsx("div",{className:`bonsaif-chart bonsaif-${h}-chart w-full ${o}`,role:"img","aria-label":m??(h==="donut"?"Donut chart":"Pie chart"),style:{height:a},children:t.jsxs("div",{className:"bonsaif-pie-layout",children:[t.jsx("div",{className:"bonsaif-pie-plot",style:{height:G},children:t.jsx(Ne.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ne.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[d?t.jsx(gr,{valueFormat:u,isAnimationActive:!1}):null,t.jsx(Ne.Pie,{data:$,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${k}%`,outerRadius:`${N}%`,startAngle:90,endAngle:-270,paddingAngle:A,cornerRadius:C,minAngle:w>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:Ot,animationEasing:qt,label:!1,activeShape:nf,children:$.map(T=>t.jsx(Ne.Cell,{fill:T.fill},T.name))}),y?t.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:u(j)}):null]})})}),c?t.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:$.map(T=>t.jsxs("li",{className:"bonsaif-pie-legend-item",children:[t.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:T.fill},"aria-hidden":!0}),t.jsx("span",{className:"bonsaif-pie-legend-label",title:T.name,children:T.name}),t.jsx("span",{className:"bonsaif-pie-legend-value",children:u(T.value)})]},T.name))}):null]})})}function nf(e){const{outerRadius:r=0,...n}=e;return t.jsx(Ne.Sector,{...n,outerRadius:Number(r)+4,stroke:"var(--bg-card)",strokeWidth:2})}function af({data:e,dataKey:r,width:n="100%",height:a=36,tone:o="primary",color:l,fill:i=!0,className:c="",ariaLabel:d="Sparkline"}){const u=l??yt(o),m=e.map(N=>br(N[r])).filter(N=>N!==null);if(m.length<2)return t.jsx("div",{className:c,style:{width:n,height:a,color:"var(--text-muted)"},"aria-label":d});const f=120,b=36,v=3,x=1,E=Math.min(...m),$=Math.max(...m)-E||1,M=m.map((N,A)=>{const C=x+A/(m.length-1)*(f-x*2),j=b-v-(N-E)/$*(b-v*2);return{x:C,y:j}}),y=M.map((N,A)=>`${A===0?"M":"L"}${N.x.toFixed(2)} ${N.y.toFixed(2)}`).join(" "),w=`${y} L${M[M.length-1].x.toFixed(2)} ${b} L${M[0].x.toFixed(2)} ${b} Z`,k=`bonsaif-spark-${r.replace(/[^a-zA-Z0-9_-]/g,"")}-${o}`;return t.jsx("div",{className:`bonsaif-sparkline ${c}`,style:{width:n,height:a},role:"img","aria-label":d,children:t.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${f} ${b}`,preserveAspectRatio:"none",focusable:"false",children:[i?t.jsx("defs",{children:t.jsxs("linearGradient",{id:k,x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:u,stopOpacity:.38}),t.jsx("stop",{offset:"100%",stopColor:u,stopOpacity:0})]})}):null,i?t.jsx("path",{d:w,fill:`url(#${k})`}):null,t.jsx("path",{d:y,fill:"none",stroke:u,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function sf({data:e,xKey:r,series:n,barSeries:a,lineSeries:o,height:l=280,className:i="",loading:c=!1,emptyText:d="Sin datos para mostrar",showGrid:u=!0,showLegend:m=!0,showTooltip:f=!0,margin:b,valueFormat:v=ot,yDomain:x,ariaLabel:E="Gráfico combinado",barRadius:h=6,zoomable:$=!1,zoomMode:M="both",brushHeight:y,onZoomChange:w}){const k=a??n.slice(0,Math.max(1,n.length-1)),N=o??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),A=[...k,...N.filter(H=>!k.some(ae=>ae.key===H.key))],C=An(e,A),j=Gr(k),W=Gr(A),G=N.map(H=>{var X;const ae=W.find(V=>V.key===H.key);return{...H,label:H.label??H.key,color:H.color??(ae==null?void 0:ae.color)??((X=W[0])==null?void 0:X.color)}}),T=In(e,r,{zoomable:$,zoomMode:M,brushHeight:y,onZoomChange:w}),Z=Kr({...b,...T.marginExtra});return c?t.jsx(lt,{height:l}):C?t.jsx(it,{height:l,text:d}):t.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":E,style:{height:l},children:[t.jsx(On,{visible:T.isZoomed,onReset:T.resetZoom}),t.jsx(Ne.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ne.ComposedChart,{data:T.viewData,margin:Z,barCategoryGap:"34%",...T.chartHandlers,children:[u?t.jsx(Ne.CartesianGrid,{strokeDasharray:"2 8",stroke:Zr(),vertical:!1}):null,t.jsx(Ne.XAxis,{dataKey:r,tick:ct(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Ne.YAxis,{tick:ct(),tickLine:!1,axisLine:!1,width:44,domain:x??["auto","auto"],tickFormatter:H=>v(Number(H)),dx:-2}),f?t.jsx(gr,{valueFormat:v,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,m?t.jsx(Ne.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Dn()}):null,j.map(H=>t.jsx(Ne.Bar,{dataKey:H.key,name:H.label,fill:H.color,fillOpacity:.88,radius:[h,h,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:Ot,animationEasing:qt},H.key)),G.map(H=>t.jsx(Ne.Line,{type:"monotone",dataKey:H.key,name:H.label,stroke:H.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:Ot,animationEasing:qt,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:H.color}},H.key)),T.zoomNodes]})})]})}function of({data:e,xKey:r,valueKey:n,typeKey:a,height:o=280,className:l="",loading:i=!1,emptyText:c="Sin datos para mostrar",showGrid:d=!0,showTooltip:u=!0,margin:m,valueFormat:f=ot,ariaLabel:b="Gráfico waterfall",increaseColor:v="#34d399",decreaseColor:x="#f87171",totalColor:E="var(--primary)"}){const h=s.useMemo(()=>lf(e,{xKey:r,valueKey:n,typeKey:a,increaseColor:v,decreaseColor:x,totalColor:E}),[e,r,n,a,v,x,E]),$=!h.length,M=Kr(m);return i?t.jsx(lt,{height:o}):$?t.jsx(it,{height:o,text:c}):t.jsx("div",{className:`bonsaif-chart bonsaif-waterfall-chart w-full ${l}`,role:"img","aria-label":b,style:{height:o},children:t.jsx(Ne.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ne.BarChart,{data:h,margin:M,barCategoryGap:"42%",children:[d?t.jsx(Ne.CartesianGrid,{strokeDasharray:"2 8",stroke:Zr(),vertical:!1}):null,t.jsx(Ne.XAxis,{dataKey:"label",tick:ct(),tickLine:!1,axisLine:!1,interval:0,dy:6}),t.jsx(Ne.YAxis,{tick:ct(),tickLine:!1,axisLine:!1,width:44,tickFormatter:y=>f(Number(y)),dx:-2}),u?t.jsx(gr,{valueFormat:f,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,t.jsx(Ne.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),t.jsx(Ne.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:Ot,animationEasing:qt,children:h.map(y=>t.jsx(Ne.Cell,{fill:y.color},y.label))})]})})})}function lf(e,r){let n=0;return e.map((a,o)=>{const l=br(a[r.valueKey])??0,i=r.typeKey?String(a[r.typeKey]??""):"",c=i==="total"||o===e.length-1&&i!=="increase"&&i!=="decrease";let d="increase",u=0,m=0,f=l;return c&&i==="total"?(d="total",u=0,m=Math.abs(l),f=l,n=l):c&&o===e.length-1&&!i?(d="total",u=0,m=Math.abs(n),f=n):(d=i==="decrease"||l<0?"decrease":"increase",d==="decrease"?(u=n+l,m=Math.abs(l),n=n+l):(u=n,m=Math.abs(l),n=n+l),f=l),{label:String(a[r.xKey]??""),base:u,delta:m,display:f,kind:d,color:d==="total"?r.totalColor:d==="decrease"?r.decreaseColor:r.increaseColor}})}const il="bonsaif-funnel-chart-keyframes",cf=`
|
|
44
|
+
`}),x.map(I=>{const te=Ku(I.colorIndex);return A===I.id?t.jsx("input",{ref:re,value:U,disabled:s,onChange:P=>K(P.target.value),onKeyDown:P=>$(P,I.id),onBlur:()=>ae(I.id,U),className:"min-w-[4rem] rounded border border-[var(--primary)] bg-transparent px-1 py-0.5 text-sm text-[var(--text-main)] outline-none",style:{width:`${Math.max(U.length+2,6)}ch`}},I.id):t.jsxs("span",{className:"inline-flex max-w-[240px] items-center gap-1 rounded-md px-2 py-0.5 text-xs font-medium",style:{backgroundColor:te.bg,color:te.text,border:`1px solid ${te.border}`},children:[t.jsx("span",{className:"truncate",children:I.value}),t.jsx("button",{type:"button","aria-label":`Editar "${I.value}"`,disabled:s,tabIndex:-1,onClick:P=>{P.stopPropagation(),H(I)},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:t.jsx(q.HiPencil,{className:"h-3 w-3"})}),t.jsx("button",{type:"button","aria-label":`Eliminar "${I.value}"`,disabled:s,tabIndex:-1,onClick:P=>{P.stopPropagation(),W(I.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:t.jsx(q.HiXMark,{className:"h-3.5 w-3.5"})})]},I.id)}),!O&&t.jsx("input",{ref:se,value:w,disabled:s,placeholder:x.length===0?a:"",onChange:I=>N(I.target.value),onKeyDown:D,onPaste:G,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"})]}),t.jsx(wr,{error:g,helperText:b,helperDisplay:f})]})}const Ru=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;function Ze(e){return String(e).padStart(2,"0")}function io(e,r=Mr()){const n=e.trim();if(!n)return r;const a=n.match(Ru);if(!a)return r;const s=Number(a[1]),l=Number(a[2]),i=a[3]?Number(a[3]):0;return!Number.isFinite(s)||!Number.isFinite(l)||!Number.isFinite(i)||s<0||s>23||l<0||l>59||i<0||i>59?r:{hour24:s,minute:l,second:i}}function rn(e,r=!0){const n=`${Ze(e.hour24)}:${Ze(e.minute)}`;return r?`${n}:${Ze(e.second)}`:n}function Un(e){const r=e.hour24>=12?"PM":"AM";return{hour12:e.hour24%12===0?12:e.hour24%12,minute:e.minute,second:e.second,meridiem:r}}function nn(e){let n=Math.min(12,Math.max(1,e.hour12))%12;return e.meridiem==="PM"&&(n+=12),{hour24:n,minute:Math.min(59,Math.max(0,e.minute)),second:Math.min(59,Math.max(0,e.second))}}function ef(e,r){const n=(r==null?void 0:r.use12Hour)??!1,a=(r==null?void 0:r.showSeconds)??!0,s=io(e);if(n){const l=Un(s),i=`${l.hour12}:${Ze(l.minute)}`;return`${a?`${i}:${Ze(l.second)}`:i} ${l.meridiem}`}return rn(s,a)}function Mr(){const e=new Date;return{hour24:e.getHours(),minute:e.getMinutes(),second:e.getSeconds()}}function tf(e=!0){return rn(Mr(),e)}function co(e,r){const n=[];for(let a=e;a<=r;a+=1)n.push(a);return n}const xt=36,uo=5,hl=Math.floor(uo/2),rf=52,nf=48,_t=18;function gl(e){return e*xt}function vl(e){return Math.round(e/xt)}function af(e){return e.use12Hour??e.hour12??!1}function Vn({values:e,selected:r,onSelect:n,syncEpochRef:a,forceSyncAt:s=0,width:l=rf,label:i,maxNumeric:c=59,isMeridiem:d=!1,isFocused:u=!1,onFocus:m,onAdvance:b,onBack:f,setColumnRef:g}){const v=o.useRef(null),k=o.useRef(null),h=o.useRef(null),C=o.useRef(""),M=o.useRef(0),y=o.useRef(!1),[x,w]=o.useState(r),[N,A]=o.useState(""),T=o.useCallback(H=>{C.current=H,A(H)},[]),U=o.useMemo(()=>[...Array(hl).fill(""),...e,...Array(hl).fill("")],[e]),K=o.useCallback(()=>{const H=v.current;if(!H)return r;const D=vl(H.scrollTop),$=Math.min(Math.max(D,0),e.length-1);return e[$]??r},[r,e]),Z=o.useCallback((H,D=!0)=>{const $=Math.min(Math.max(H,0),e.length-1),oe=e[$],G=v.current;!G||!oe||(k.current&&(window.clearTimeout(k.current),k.current=null),y.current=!0,M.current=$,G.scrollTop=gl($),w(oe),D&&oe!==r&&n(oe))},[n,r,e]);o.useLayoutEffect(()=>{k.current&&(window.clearTimeout(k.current),k.current=null),h.current&&(window.clearTimeout(h.current),h.current=null),T(""),w(r);const H=e.indexOf(r);if(H>=0&&(M.current=H),H<0||!v.current)return;const D=gl(H);v.current.scrollTop!==D&&(v.current.scrollTop=D)},[s,r,T,e]);const L=o.useCallback(()=>{h.current&&(window.clearTimeout(h.current),h.current=null)},[]),Q=o.useCallback((H,D=!1)=>{L(),T("");const $=Number(H);if(!Number.isFinite($))return;const oe=Math.min(c,Math.max(0,$));let G=Ze(oe),X=e.indexOf(G);if(X<0){const S=Math.min(e.length-1,Math.max(0,oe-(c===12?1:0)));G=e[S]??G,X=e.indexOf(G)}X>=0&&Z(X),D&&(b==null||b())},[L,c,b,Z,T,e]),z=o.useCallback(H=>{const D=Math.floor(c/10),$=C.current;if($===""){if(H>D){Q(String(H),!0);return}const G=String(H);T(G),h.current=window.setTimeout(()=>{Q(C.current,!0)},1200);return}L();const oe=+`${$}${H}`;oe<=c?Q(String(oe),!0):Q(String(H),!0)},[L,Q,c,T]),se=o.useCallback(H=>{L(),T(""),Z(M.current+H)},[L,Z,T]),re=H=>{if(d){H.key==="a"||H.key==="A"?(H.preventDefault(),n("AM"),b==null||b()):H.key==="p"||H.key==="P"?(H.preventDefault(),n("PM"),b==null||b()):H.key==="ArrowUp"||H.key==="ArrowDown"?(H.preventDefault(),n(r==="AM"?"PM":"AM")):H.key==="Tab"&&(H.preventDefault(),H.shiftKey?f==null||f():b==null||b());return}if(/^\d$/.test(H.key)){H.preventDefault(),z(Number(H.key));return}H.key==="ArrowUp"?(H.preventDefault(),se(-1)):H.key==="ArrowDown"?(H.preventDefault(),se(1)):H.key==="Tab"&&(H.preventDefault(),L(),C.current!==""&&Q(C.current,!1),H.shiftKey?f==null||f():b==null||b())},R=o.useCallback(()=>{const H=a.current,D=v.current;D&&H===a.current&&Z(vl(D.scrollTop))},[Z,a]),V=()=>{if(C.current!=="")return;if(y.current){y.current=!1;const D=K();w(D);const $=e.indexOf(D);$>=0&&(M.current=$);return}w(K()),k.current&&window.clearTimeout(k.current);const H=a.current;k.current=window.setTimeout(()=>{H===a.current&&R()},100)},B="absolute left-0 right-0 z-40 flex items-center justify-center border-0 bg-transparent p-0 transition-opacity duration-150 hover:opacity-80 focus:outline-none",le=xt*uo,j=le+_t*2,W=N!==""?N:null,ae=W!==null;return t.jsxs("div",{ref:g,role:"spinbutton",tabIndex:u?0:-1,"aria-label":i,"aria-valuetext":W??r,"aria-valuenow":d?void 0:Number(r),onFocus:m,onMouseDown:()=>m==null?void 0:m(),onKeyDown:re,onBlur:()=>{L(),C.current!==""&&Q(C.current,!1)},className:"relative shrink-0 rounded-lg outline-none",style:{width:l,height:j,boxShadow:u?"0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent)":"none"},children:[t.jsx("button",{type:"button","aria-label":"Valor anterior",className:B,style:{top:0,height:_t,color:"var(--text-muted)",opacity:.35},onClick:()=>se(-1),children:t.jsx(q.HiChevronUp,{className:"h-3.5 w-3.5"})}),t.jsx("div",{ref:v,className:"absolute inset-x-0 overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",style:{top:_t,height:le,scrollSnapType:"y mandatory",scrollBehavior:"auto"},onScroll:V,onMouseUp:R,onTouchEnd:R,children:U.map((H,D)=>{const $=H!==""&&H===x;return t.jsx("button",{type:"button",tabIndex:-1,disabled:!H,onClick:()=>{if(!H)return;const oe=e.indexOf(H);oe>=0&&Z(oe)},className:"flex w-full items-center justify-center tabular-nums leading-none disabled:cursor-default",style:{height:xt,scrollSnapAlign:"center",color:$?"var(--text-main)":"var(--text-muted)",fontSize:$?16:14,fontWeight:$?600:400,opacity:H?ae?$?0:.35:$?1:.35:0},children:H},`wheel-${D}-${H}`)})}),W!==null?t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-50 flex items-center justify-center tabular-nums font-semibold leading-none",style:{top:_t+le/2-xt/2,height:xt,color:"var(--text-main)",fontSize:16,background:"var(--bg-card)"},children:W}):null,t.jsx("button",{type:"button","aria-label":"Valor siguiente",className:B,style:{bottom:0,height:_t,color:"var(--text-muted)",opacity:.35},onClick:()=>se(1),children:t.jsx(q.HiChevronDown,{className:"h-3.5 w-3.5"})})]})}function yl(){return t.jsx("span",{className:"flex shrink-0 items-center justify-center self-center text-base font-medium tabular-nums leading-none",style:{color:"var(--text-muted)",height:xt,width:14,opacity:.45},"aria-hidden":!0,children:":"})}function xl({value:e,onChange:r,use12Hour:n,hour12:a,showSeconds:s=!1,title:l="Seleccionar hora",variant:i="panel",onCancel:c,onConfirm:d,className:u=""}){const m=i==="popover",b=m||!d,f=af({use12Hour:n,hour12:a}),g=o.useRef(e),v=io(e,Mr()),k=Un(v),[h,C]=o.useState(Ze(f?k.hour12:v.hour24)),[M,y]=o.useState(Ze(v.minute)),[x,w]=o.useState(Ze(v.second)),[N,A]=o.useState(k.meridiem),[T,U]=o.useState(0),K=o.useRef(0),Z=o.useRef(!1),L=o.useRef({hour:null,minute:null,second:null,meridiem:null}),[Q,z]=o.useState("hour"),se=o.useMemo(()=>{const ie=["hour","minute"];return s&&ie.push("second"),f&&ie.push("meridiem"),ie},[f,s]),re=o.useCallback(ie=>{z(ge=>{const Te=se.indexOf(ge);return se[(Te+ie+se.length)%se.length]})},[se]);o.useEffect(()=>{var ie;(ie=L.current[Q])==null||ie.focus()},[Q]),o.useEffect(()=>{var ie;z("hour"),(ie=L.current.hour)==null||ie.focus()},[]),o.useEffect(()=>{if(e===g.current)return;g.current=e;const ie=io(e,Mr()),ge=Un(ie);C(Ze(f?ge.hour12:ie.hour24)),y(Ze(ie.minute)),w(Ze(ie.second)),A(ge.meridiem)},[f,e]);const R=o.useMemo(()=>(f?co(1,12):co(0,23)).map(ie=>Ze(ie)),[f]),V=o.useMemo(()=>co(0,59).map(ie=>Ze(ie)),[]),B=V,le=o.useMemo(()=>["AM","PM"],[]),j=o.useCallback(()=>f?nn({hour12:Number(h),minute:Number(M),second:Number(x),meridiem:N}):{hour24:Number(h),minute:Number(M),second:Number(x)},[h,f,N,M,x]),W=o.useCallback(ie=>{if(Z.current)return;const ge=rn(ie,s);g.current=ge,r(ge)},[r,s]),ae=o.useCallback(()=>{W(j())},[j,W]),H=ie=>{C(ie),b&&W(f?nn({hour12:Number(ie),minute:Number(M),second:Number(x),meridiem:N}):{hour24:Number(ie),minute:Number(M),second:Number(x)})},D=ie=>{y(ie),b&&W(f?nn({hour12:Number(h),minute:Number(ie),second:Number(x),meridiem:N}):{hour24:Number(h),minute:Number(ie),second:Number(x)})},$=ie=>{w(ie),b&&W(f?nn({hour12:Number(h),minute:Number(M),second:Number(ie),meridiem:N}):{hour24:Number(h),minute:Number(M),second:Number(ie)})},oe=ie=>{A(ie),b&&W(nn({hour12:Number(h),minute:Number(M),second:Number(x),meridiem:ie}))},G=o.useCallback(()=>(K.current+=1,U(K.current),K.current),[]),X=o.useCallback(ie=>{const ge=Un(ie),Te=rn(ie,s);g.current=Te,C(Ze(f?ge.hour12:ie.hour24)),y(Ze(ie.minute)),w(Ze(ie.second)),A(ge.meridiem),r(Te)},[f,r,s]),S=()=>{Z.current=!0,G(),X(Mr()),queueMicrotask(()=>{const ie=Mr();rn(ie,s)!==g.current&&(G(),X(ie)),Z.current=!1})},O=()=>{ae(),d==null||d()},I=xt*uo,te=I+_t*2,P=_t+I/2-xt/2,ce=t.jsx("div",{className:"relative px-4 py-2",children:t.jsxs("div",{className:"relative mx-auto",style:{height:te,maxWidth:"100%"},children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-10 rounded-xl",style:{top:P,height:xt,background:"color-mix(in srgb, var(--primary) 10%, var(--bg-input))",border:"1px solid color-mix(in srgb, var(--primary) 22%, transparent)"}}),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-20",style:{top:_t,height:xt*1.35,background:"linear-gradient(to bottom, var(--bg-card) 40%, transparent 100%)"}}),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-20",style:{bottom:_t,height:xt*1.35,background:"linear-gradient(to top, var(--bg-card) 40%, transparent 100%)"}}),t.jsxs("div",{className:"relative z-30 flex h-full items-center justify-center gap-1",children:[t.jsx(Vn,{syncEpochRef:K,forceSyncAt:T,values:R,selected:h,onSelect:H,label:"Horas",maxNumeric:f?12:23,isFocused:Q==="hour",onFocus:()=>z("hour"),onAdvance:()=>re(1),onBack:()=>re(-1),setColumnRef:ie=>{L.current.hour=ie}}),t.jsx(yl,{}),t.jsx(Vn,{syncEpochRef:K,forceSyncAt:T,values:V,selected:M,onSelect:D,label:"Minutos",maxNumeric:59,isFocused:Q==="minute",onFocus:()=>z("minute"),onAdvance:()=>re(1),onBack:()=>re(-1),setColumnRef:ie=>{L.current.minute=ie}}),s?t.jsxs(t.Fragment,{children:[t.jsx(yl,{}),t.jsx(Vn,{syncEpochRef:K,forceSyncAt:T,values:B,selected:x,onSelect:$,label:"Segundos",maxNumeric:59,isFocused:Q==="second",onFocus:()=>z("second"),onAdvance:()=>re(1),onBack:()=>re(-1),setColumnRef:ie=>{L.current.second=ie}})]}):null,f?t.jsx("div",{className:"ml-3 shrink-0 pl-1",children:t.jsx(Vn,{syncEpochRef:K,forceSyncAt:T,values:le,selected:N,onSelect:ie=>oe(ie),width:nf,label:"AM o PM",isMeridiem:!0,isFocused:Q==="meridiem",onFocus:()=>z("meridiem"),onAdvance:()=>re(1),onBack:()=>re(-1),setColumnRef:ie=>{L.current.meridiem=ie}})}):null]})]})}),he=t.jsxs("div",{className:`flex items-center ${m?"justify-center px-3 py-2":"justify-between gap-2 px-3 py-2.5"}`,style:{borderTop:m?"none":"1px solid color-mix(in srgb, var(--border) 80%, transparent)"},children:[t.jsx(Ue,{variant:"ghost",size:"sm",onClick:S,className:m?"text-xs":void 0,children:"Ahora"}),!m&&(c||d)?t.jsxs("div",{className:"flex items-center gap-2",children:[c?t.jsx(Ue,{variant:"ghost",size:"sm",onClick:c,children:"Cancelar"}):null,d?t.jsx(Ue,{variant:"primary",size:"sm",onClick:O,children:"Listo"}):null]}):null]});return t.jsxs("div",{className:`overflow-hidden ${u}`,style:{borderRadius:m?12:14,border:m?"1px solid color-mix(in srgb, var(--border) 85%, transparent)":"1px solid var(--border)",background:"var(--bg-card)",boxShadow:m?"0 12px 40px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06)":"0 1px 3px rgba(15, 23, 42, 0.06)",minWidth:f?s?300:260:s?252:212},children:[!m&&l?t.jsx("div",{className:"border-b px-3 py-2.5",style:{borderColor:"color-mix(in srgb, var(--border) 80%, transparent)"},children:t.jsx("h3",{className:"text-sm font-semibold",style:{color:"var(--text-main)"},children:l})}):null,ce,he]})}function of(e){return e.use12Hour??e.hour12??!1}function sf({label:e,value:r,onChange:n,use12Hour:a,hour12:s,showSeconds:l=!1,title:i="Seleccionar hora",placeholder:c="Seleccionar hora",disabled:d=!1,displayMode:u="popover",required:m,error:b,helperText:f,helperDisplay:g,className:v,contentClassName:k,className:h=""}){const C=u==="popover",[M,y]=o.useState(!1),x=o.useRef(null),[w,N]=o.useState({horizontal:"left",vertical:"bottom"}),A=of({use12Hour:a,hour12:s}),T=o.useMemo(()=>r?ef(r,{use12Hour:A,showSeconds:l}):"",[A,l,r]);o.useEffect(()=>{if(!C||!M||!x.current)return;const Z=x.current.getBoundingClientRect(),L=8,Q=A?l?300:260:l?252:212,z=276,se=Z.left+Q>window.innerWidth-L,re=Z.right-Q>=L,R=Z.bottom+8+z>window.innerHeight-L,V=Z.top-8-z>=L;N({horizontal:se&&re?"right":"left",vertical:R&&V?"top":"bottom"})},[A,C,M,l]),o.useEffect(()=>{if(!C||!M)return;function Z(Q){x.current&&(x.current.contains(Q.target)||y(!1))}function L(Q){Q.key==="Escape"&&y(!1)}return document.addEventListener("mousedown",Z),document.addEventListener("keydown",L),()=>{document.removeEventListener("mousedown",Z),document.removeEventListener("keydown",L)}},[C,M]);const U=t.jsxs("button",{type:"button",disabled:d,onClick:()=>{d||y(Z=>!Z)},className:`flex h-10 w-full items-center justify-between gap-2 rounded-lg border px-2.5 text-sm transition-all duration-150 focus:outline-none disabled:cursor-not-allowed disabled:opacity-60 ${h}`,style:{background:"var(--bg-input)",borderColor:b?"var(--danger)":M?"var(--primary)":"var(--border)",color:T?"var(--text-main)":"var(--text-muted)",boxShadow:M?"0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent)":"none"},children:[t.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2",children:[t.jsx(q.HiClock,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:T||c})]}),C?t.jsx(q.HiChevronDown,{className:`h-4 w-4 shrink-0 text-[var(--text-muted)] transition-transform duration-150 ${M?"rotate-180":""}`}):null]}),K=t.jsx(xl,{variant:C?"popover":"panel",value:r||tf(l),onChange:n,use12Hour:A,showSeconds:l,title:i,onClose:()=>y(!1)});return t.jsx($n,{label:e,required:m,error:b,helperText:f,helperDisplay:g,className:v,contentClassName:k,children:C?t.jsxs("div",{ref:x,className:"relative w-full",children:[U,M?t.jsx("div",{className:"absolute z-50",style:{...w.horizontal==="left"?{left:0}:{right:0},...w.vertical==="bottom"?{top:"calc(100% + 6px)"}:{bottom:"calc(100% + 6px)"}},children:K}):null]}):t.jsxs("div",{className:"space-y-2",children:[U,M?K:null]})})}const lf={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function cf({checked:e,disabled:r,onCheckedChange:n,size:a="sm",className:s="",...l}){const i=lf[a],c=e?i.width-i.thumb-i.padding*2:0;return t.jsx("button",{...l,type:"button",role:"switch","aria-checked":e,disabled:r,onClick:()=>!r&&n(!e),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:e?"color-mix(in srgb, var(--primary) 85%, transparent)":"var(--bg-input)",border:e?"1px solid color-mix(in srgb, var(--primary) 55%, transparent)":"1px solid var(--border)"},children:t.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:e?"var(--primary-fg)":"var(--text-muted)"}})})}const wl=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),df=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function uf(e){if(!(e instanceof HTMLElement)||e.dataset.overlayScroll==="false"||e.matches("[data-overlayscrollbars]")||e.closest("[data-overlayscrollbars]")||e.matches("textarea,input,select,[contenteditable='true']"))return!1;const r=window.getComputedStyle(e);return!(![r.overflow,r.overflowX,r.overflowY].join(" ").match(/auto|scroll/)||e.clientWidth===0&&e.clientHeight===0)}function Nl(e){return e.classList.contains("sidebar-scroll")||e.classList.contains("showcase-nav-scroll")}function kl(e){Nl(e)&&e.querySelectorAll(".os-scrollbar-horizontal").forEach(r=>{r.style.display="none",r.style.height="0",r.style.pointerEvents="none"})}function ff(e){const r=e.querySelector(df);return r instanceof HTMLElement?r:null}function Sl(){return o.useEffect(()=>{const e=new WeakMap;let r=0;const n=()=>{r=0,document.querySelectorAll(wl).forEach(l=>{if(!(l instanceof HTMLElement))return;if(ka.OverlayScrollbars(l)){kl(l);return}if(!uf(l))return;const c={overflow:Nl(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},d=ff(l),u=d?ka.OverlayScrollbars({target:l,elements:{viewport:d}},c):ka.OverlayScrollbars(l,c);kl(l),e.set(l,u)})},a=()=>{r||(r=window.requestAnimationFrame(n))};n();const s=new MutationObserver(a);return s.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","data-overlay-scroll"]}),window.addEventListener("resize",a),()=>{r&&window.cancelAnimationFrame(r),s.disconnect(),window.removeEventListener("resize",a),document.querySelectorAll(wl).forEach(l=>{var i;l instanceof HTMLElement&&((i=e.get(l))==null||i.destroy())})}},[]),null}function Yt(e){const r=e.trim();return!r||r==="/"||r==="/."?"":(r.startsWith("/")?r:`/${r}`).replace(/\/+$/,"")}function Cl(e){try{const r=new URL(e);return Yt(r.pathname)}catch{return""}}function bf(e){const r=Yt(e);if(!r)return"";const n=r.match(/^\/apps\/[^/]+/i);if(n)return Yt(n[0]);const a=r.split("/").filter(Boolean);return a.length===0?"":a.length>=2&&a[0].toLowerCase()==="apps"?Yt(`/${a[0]}/${a[1]}`):new Set(["admin","apps","apps-list","tickets","my-tickets","projects","projects-calendars","dashboard","teams","clients","services","settings","profile","messages","notifications","my-access","my-registers","my-pings","security-incidents","email-inbox","webhook-config","webphone-config","vobo","auth","api","login","forbidden","unauthorized","change-password","reset-password","chat-widget"]).has(a[0].toLowerCase())?"":Yt(`/${a[0]}`)}const fo="primeSuiteAppUrl",mf={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"}},El={xs:20,sm:28,md:36,lg:48,xl:64},Ml=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],pf={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},hf="bonsaif.bot",gf="Bonsaif Bot",vf={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Tl(e){return typeof e=="string"?e.trim():""}function yf(e){var s;if(e!==void 0)return Yt(e);const r=Yt(typeof process<"u"&&((s=process.env)==null?void 0:s.NEXT_PUBLIC_BASE_PATH)||"");if(r)return r;if(typeof window>"u")return"";try{const i=new URLSearchParams(window.location.search).get(fo)||"";i&&window.sessionStorage.setItem(fo,i);const c=window.sessionStorage.getItem(fo)||"",d=i||c;if(d){const u=Cl(d);if(u&&!/^\/admin(\/|$)/i.test(u))return u}}catch{}const n=window.__NEXT_DATA__,a=(n==null?void 0:n.assetPrefix)||"";if(a){const l=a.startsWith("http")?Cl(a):Yt(a);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return bf(window.location.pathname)}function xf(e){const r=e.split(/\s+/).map(n=>n.trim()).filter(Boolean);return r.length===0?"?":r.length===1?r[0].slice(0,1).toUpperCase():`${r[0].slice(0,1)}${r[1].slice(0,1)}`.toUpperCase()}function wf(e){let r=0;for(const n of e)r=r*31+n.charCodeAt(0)&65535;return Ml[r%Ml.length]}function Nf(e,r){return e===hf||r===gf}function kf(e,r){return`${e.replace(/\/$/,"")}${r}`}function $l({userId:e,username:r,name:n,size:a="md",showName:s=!1,showTooltip:l,tooltipContent:i,fallbackLabel:c="Usuario",basePath:d,wrapperClassName:u="",labelClassName:m="",labelSize:b="xs",avatarVersion:f=0,className:g="",style:v}){const[k,h]=o.useState(!1),C=typeof e=="string"&&e.trim()&&e!=="undefined"&&e!=="null"?e.trim():"";o.useEffect(()=>{h(!1)},[C,f]);const{wh:M,text:y}=mf[a],x=Tl(n)||Tl(r)||c,w=xf(x),N=yf(d),A=Nf(r,n),T=kf(N,"/favicon.svg"),U=o.useMemo(()=>{if(!C)return"";const z=new URLSearchParams;z.set("size",String(El[a])),f&&z.set("v",String(f));const se=z.toString();return`${N}/api/user/avatar/${encodeURIComponent(C)}${se?`?${se}`:""}`},[f,N,C,a]),K=El[a],Z=A?t.jsx("span",{className:`${M} ${vf[a]} rounded-full flex items-center justify-center bg-[#071f1a] ring-1 ring-emerald-400/35 shadow-[0_0_0_1px_rgba(255,255,255,0.06)] flex-shrink-0 ${g}`,style:v,children:t.jsx("img",{src:T,alt:x,width:K,height:K,className:"h-full w-full object-contain"})}):U&&!k?t.jsx("img",{src:U,alt:x,width:K,height:K,className:`${M} rounded-full object-cover flex-shrink-0 ${g}`,style:v,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>h(!0)},`${C}-${f}`):t.jsx("span",{className:`${M} ${wf(x)} ${y} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${g}`,style:v,title:x,children:w});if(s)return t.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${u}`,children:[Z,t.jsx("span",{className:`min-w-0 truncate ${pf[b]} font-medium text-[var(--text-main)] ${m}`,title:x,children:x})]});const L=l??!0,Q=i??x;return L&&Q?t.jsx(nr,{as:"span",content:Q,className:`inline-flex flex-shrink-0 ${u}`,children:Z}):Z}function Sf({href:e,className:r,children:n}){return t.jsx("a",{href:e,className:r,children:n})}function Cf(e){return e.reduce((r,n)=>{const a=n.section??"Principal";return r[a]=[...r[a]??[],n],r},{})}function Al({children:e,navItems:r=[],currentPath:n=typeof window>"u"?"/":window.location.pathname,user:a,appName:s="Bonsaif",appLogo:l,header:i,footer:c,onLogout:d,LinkComponent:u=Sf}){const[m,b]=o.useState(!1),f=Cf(r);return t.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[t.jsx(Sl,{}),t.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:t.jsx(q.HiBars3,{className:"h-5 w-5"})}),m&&t.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>b(!1)}),t.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:[t.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[t.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:l??t.jsx(q.HiHome,{className:"h-5 w-5"})}),t.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:s}),t.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:t.jsx(q.HiXMark,{className:"h-5 w-5"})})]}),t.jsx("nav",{className:"sidebar-scroll min-h-0 flex-1 overflow-y-auto px-3 py-4","data-overlay-scroll":"true",children:t.jsx("div",{className:"sidebar-scroll-body",children:Object.entries(f).map(([g,v])=>t.jsxs("div",{className:"mb-5",children:[t.jsxs("div",{className:"mb-2 flex items-center gap-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-white/35",children:[t.jsx(q.HiChevronDown,{className:"h-3.5 w-3.5"}),g]}),t.jsx("div",{className:"space-y-1",children:v.map(k=>{const h=n===k.href||n.startsWith(`${k.href}/`);return t.jsxs(u,{href:k.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${h?"bg-white/10 text-white":"text-white/55 hover:bg-white/[0.06] hover:text-white/85"}`,children:[t.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:k.icon??t.jsx(q.HiHome,{className:"h-4 w-4"})}),t.jsx("span",{className:"truncate",children:k.label})]},k.href)})})]},g))})}),t.jsxs("div",{className:"border-t border-white/10 p-3",children:[a&&t.jsxs("div",{className:"mb-3 flex min-w-0 items-center gap-3 rounded-lg bg-white/[0.04] p-2",children:[t.jsx($l,{name:a.initials??a.name??a.email??"Usuario",size:"md"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-sm font-medium text-white",children:a.name??"Usuario"}),a.email&&t.jsx("div",{className:"truncate text-xs text-white/45",children:a.email})]})]}),d&&t.jsxs(Ue,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:d,children:[t.jsx(q.HiArrowRightOnRectangle,{className:"h-4 w-4"})," Salir"]}),c]})]}),t.jsxs("div",{className:"min-h-screen lg:pl-72",children:[i,t.jsx("main",{className:"min-h-screen",children:e})]})]})}const Ll="bonsaif-ui:prime-auth-sso",Ef={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"},bo={dashboard:t.jsx(q.HiChartBar,{className:"h-5 w-5"}),tickets:t.jsx(q.HiTicket,{className:"h-5 w-5"}),teams:t.jsx(q.HiUsers,{className:"h-5 w-5"}),projects:t.jsx(q.HiRectangleGroup,{className:"h-5 w-5"}),clients:t.jsx(q.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:t.jsx(q.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:t.jsx(q.HiUser,{className:"h-5 w-5"}),settings:t.jsx(q.HiCog6Tooth,{className:"h-5 w-5"}),notifications:t.jsx(q.HiBell,{className:"h-5 w-5"}),changelog:t.jsx(q.HiDocumentText,{className:"h-5 w-5"}),admin:t.jsx(q.HiShieldCheck,{className:"h-5 w-5"}),users:t.jsx(q.HiUsers,{className:"h-5 w-5"}),roles:t.jsx(q.HiShieldCheck,{className:"h-5 w-5"}),menus:t.jsx(q.HiCog6Tooth,{className:"h-5 w-5"}),guards:t.jsx(q.HiCalendarDays,{className:"h-5 w-5"}),vacations:t.jsx(q.HiCalendarDays,{className:"h-5 w-5"}),audit:t.jsx(q.HiListBullet,{className:"h-5 w-5"}),positions:t.jsx(q.HiBriefcase,{className:"h-5 w-5"}),ranks:t.jsx(q.HiListBullet,{className:"h-5 w-5"}),"email-inbox":t.jsx(q.HiInbox,{className:"h-5 w-5"}),"security-incidents":t.jsx(q.HiShieldCheck,{className:"h-5 w-5"})};function Mf(e){return e.split("-").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function Tf(e){return/^\d+$/.test(e)||/^[a-f0-9]{8,}$/i.test(e)}function $f(e){const r=e.split("/").filter(Boolean);if(r.length===0||r.length===1&&r[0]==="dashboard")return[];const n=decodeURIComponent(r[r.length-1]),a=r.length>1?decodeURIComponent(r[r.length-2]):void 0,s=Tf(n)&&a?a:n,l=Ef[s]??Mf(s);return[{label:"Inicio",href:"/"},{label:l}]}function mo(e){return(e==null?void 0:e.querySelector(":scope > .os-viewport"))??(e==null?void 0:e.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function Af(e){const r=e.split("/").filter(Boolean),n=r[r.length-1];if(!n)return t.jsx(q.HiHome,{className:"h-5 w-5"});if(bo[n])return bo[n];const a=r.length>1?r[r.length-2]:"";return bo[a]??t.jsx(q.HiHome,{className:"h-5 w-5"})}function Lf(e){return e.includes("primeAuthOrigin")||e.includes("primeAuthProjectKey")}function Dl(){if(typeof window>"u")return!1;if(Lf(window.location.href)){try{window.sessionStorage.setItem(Ll,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Ll)==="true"}catch{return!1}}function Df({title:e,subtitle:r,action:n,meta:a,icon:s,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:d,showBreadcrumbs:u=!0,contained:m=!1}){const b=o.useRef(null),[f,g]=o.useState(!1),[v,k]=o.useState(d??"/"),[h,C]=o.useState(()=>Dl()),[M,y]=o.useState(null),x=d??v,w=c??$f(x),N=s??Af(x),A=u&&!h&&w.length>1,T=!A;o.useEffect(()=>{d||k(window.location.pathname)},[d]),o.useEffect(()=>{C(Dl())},[]),o.useEffect(()=>{if(m){g(!1);return}let K=null,Z=0,L=0;const Q=()=>{const re=b.current,R=document.querySelector("[data-app-scroll='true']");return(re==null?void 0:re.closest(".os-viewport"))??(re==null?void 0:re.closest("[data-overlayscrollbars-viewport]"))??mo(R)??R??window},z=()=>{const re=K&&K!==window?K.scrollTop:window.scrollY;g(R=>R?re>24:re>72)},se=()=>{K==null||K.removeEventListener("scroll",z),K=Q(),K.addEventListener("scroll",z,{passive:!0}),z()};return se(),Z=window.requestAnimationFrame(se),L=window.setTimeout(se,120),()=>{window.cancelAnimationFrame(Z),window.clearTimeout(L),K==null||K.removeEventListener("scroll",z)}},[m]),o.useEffect(()=>{if(m){y(null);return}let K=0;const Z=[],L=()=>{const B=b.current,le=B==null?void 0:B.parentElement,j=document.querySelector("[data-app-scroll='true']"),W=mo(j)??j;if(!B||!le||!W){y(null);return}const ae=le.getBoundingClientRect(),H=window.getComputedStyle(le),D=W.getBoundingClientRect(),$=W instanceof HTMLElement&&W.clientWidth>0?W.clientWidth:D.width,oe=ae.left+parseFloat(H.paddingLeft||"0"),G={marginLeft:Math.round(D.left-oe),width:Math.round($)};y(X=>X&&X.marginLeft===G.marginLeft&&X.width===G.width?X:G)},Q=()=>{window.cancelAnimationFrame(K),K=window.requestAnimationFrame(L)};Q(),window.addEventListener("resize",Q);const z=new ResizeObserver(Q),se=b.current,re=se==null?void 0:se.parentElement,R=document.querySelector("[data-app-scroll='true']"),V=mo(R)??R;return[re,R,V].forEach(B=>{B&&z.observe(B)}),Z.push(window.setTimeout(Q,120)),Z.push(window.setTimeout(Q,280)),()=>{window.cancelAnimationFrame(K),window.removeEventListener("resize",Q),z.disconnect(),Z.forEach(B=>window.clearTimeout(B))}},[m]);const U={...M?{marginLeft:M.marginLeft,width:M.width}:null,"--page-header-control-height":f?"34px":"40px","--page-header-control-padding-x":f?"10px":"14px","--page-header-control-icon-left":f?"10px":"12px",background:m?"var(--bg-card)":f?"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||f?"1px solid var(--border)":"1px solid transparent",boxShadow:f?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return t.jsx("div",{ref:b,"data-page-header":"true","data-compact":f?"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:U,children:t.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${f?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":T?"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:[t.jsx("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${f||T?"gap-1":"gap-1.5 sm:gap-2"}`,children:t.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${f||T?"gap-2":"gap-2.5 sm:gap-3"}`,children:[t.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${f?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:A?"var(--text-secondary)":"var(--text-muted)"},children:N}),t.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${f?"gap-x-2 gap-y-1":"gap-x-3 gap-y-2"}`,children:[t.jsxs("div",{className:"min-w-0 flex-shrink transition-[transform] duration-300 ease-out",children:[t.jsx("h1",{className:`truncate font-bold tracking-tight transition-[font-size,line-height,color] duration-300 ease-out ${f?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:e}),r&&t.jsx("div",{"aria-hidden":f,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${f?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-8 translate-y-0 opacity-100"}`,style:{color:"var(--text-muted)"},children:r})]}),a&&t.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 ${f?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:a})]})]})}),n&&t.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 ${f?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:t.jsx(Po.Provider,{value:{compact:!0,headerAction:!0},children:n})})]})})}function If({children:e,currentPath:r=typeof window>"u"?"/":window.location.pathname,publicRoutes:n=["/","/login","/reset-password"],...a}){return n.includes(r)?t.jsx(t.Fragment,{children:e}):t.jsx(Al,{currentPath:r,...a,children:e})}function Il(){if(typeof window>"u")return"system";const e=localStorage.getItem("theme");return e==="light"||e==="dark"?e:e==="system"?"system":document.documentElement.classList.contains("dark")?"dark":"light"}function Of(e,r,n){try{const a=new URL(e),s=a.searchParams.get("callbackUrl");if(s){const l=new URL(s,a.origin);return l.searchParams.set("theme",r),n&&(l.searchParams.set("primeAuthOrigin",window.location.origin),l.searchParams.set("primeAuthProjectKey",n)),a.searchParams.set("callbackUrl",`${l.pathname}${l.search}${l.hash}`),a.toString()}return a.searchParams.set("theme",r),n&&(a.searchParams.set("primeAuthOrigin",window.location.origin),a.searchParams.set("primeAuthProjectKey",n)),a.toString()}catch{return e}}function Hf({name:e,src:r,projectKey:n}){const[a,s]=o.useState("system"),l=o.useRef(null);o.useEffect(()=>{s(Il());const d=new MutationObserver(()=>s(Il()));return d.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>d.disconnect()},[]);const i=o.useMemo(()=>Of(r,a,n),[n,r,a]),c=o.useMemo(()=>{try{return new URL(i).origin}catch{return""}},[i]);return o.useEffect(()=>{if(!n)return;const d=n;function u(m){var g,v,k;if(m.source!==((g=l.current)==null?void 0:g.contentWindow)||c&&m.origin!==c)return;if(((v=m.data)==null?void 0:v.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!m.data.active}}));return}if(((k=m.data)==null?void 0:k.type)!=="prime-microservice:navigation")return;const b=m.data.path;if(!b||!b.startsWith("/")||b.startsWith("//"))return;const f=`/apps/${encodeURIComponent(d)}${b}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==f&&(window.history.replaceState(window.history.state,"",f),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",u),()=>{window.removeEventListener("message",u),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[c,n]),t.jsx("div",{className:"flex h-full min-h-screen flex-col bg-[var(--bg-main)]",children:t.jsx("iframe",{ref:l,src:i,title:e,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 Bf(){const[e,r]=o.useState(""),[n,a]=o.useState(!1),[s,l]=o.useState({width:96,height:96});return o.useEffect(()=>{let i=!1;return fetch("/api/microservices/prime-suite/chat-url",{cache:"no-store"}).then(c=>c.ok?c.json():null).then(c=>{!i&&(c!=null&&c.src)&&r(c.src)}).catch(()=>{}),()=>{i=!0}},[]),o.useEffect(()=>{const i=c=>{var u;if(((u=c.data)==null?void 0:u.type)!=="prime-suite-chat:state")return;const d=!!c.data.active;a(d),l({width:Ol(c.data.width,96,720),height:Ol(c.data.height,96,560)})};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[]),e?t.jsx("iframe",{title:"Chat Bonsaif",src:e,allow:"clipboard-write",className:"fixed bottom-0 right-0 z-[70] border-0 bg-transparent transition-[width,height] duration-200",style:{width:n?`min(${s.width}px, 100vw)`:96,height:n?`min(${s.height}px, 100vh)`:96,background:"transparent",backgroundColor:"transparent",colorScheme:"normal"}}):null}function Ol(e,r,n){const a=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(r,Math.min(n,Math.ceil(a)))}function Ff(e){const r=document.documentElement,n=new MutationObserver(e);n.observe(r,{attributes:!0,attributeFilter:["class"]});const a=window.matchMedia("(prefers-color-scheme: dark)");return a.addEventListener("change",e),()=>{n.disconnect(),a.removeEventListener("change",e)}}function Pf(){const e=localStorage.getItem("theme")||"system",r=window.matchMedia("(prefers-color-scheme: dark)").matches;return document.documentElement.classList.contains("dark")||e==="dark"||e==="system"&&r?"dark":"light"}function _f(){return"light"}function zf({position:e="bottom-center"}){const r=o.useSyncExternalStore(Ff,Pf,_f);return t.jsx(Ho.Toaster,{position:e,theme:r,richColors:!0,closeButton:!0})}function Wf({title:e,subtitle:r,actions:n,loading:a=!1,empty:s=!1,emptyText:l="Sin datos para mostrar",className:i="",children:c}){return t.jsxs("div",{className:`bonsaif-chart-card w-full overflow-visible ${i}`,children:[(e||r||n)&&t.jsxs("div",{className:"bonsaif-chart-card-head",children:[t.jsx("div",{className:"bonsaif-chart-card-accent","aria-hidden":!0}),t.jsxs("div",{className:"bonsaif-chart-card-copy min-w-0",children:[e?t.jsx("div",{className:"bonsaif-chart-card-title",children:e}):null,r?t.jsx("div",{className:"bonsaif-chart-card-subtitle",children:r}):null]}),n?t.jsx("div",{className:"bonsaif-chart-card-actions shrink-0",children:n}):null]}),t.jsx("div",{className:"bonsaif-chart-card-body",children:a?t.jsx("div",{className:"flex h-48 items-center justify-center",children:t.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?t.jsx("div",{className:"flex h-48 items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:l}):c})]})}const an=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function Hl(e,r){return e.color??an[r%an.length]}function Dt(e="primary"){switch(e){case"success":return"#34d399";case"warning":return"#fbbf24";case"danger":return"#f87171";case"neutral":return"var(--text-muted)";default:return"var(--primary)"}}const wt=e=>{if(!Number.isFinite(e))return"—";const r=Math.abs(e);return r>=1e9?`${(e/1e9).toFixed(1).replace(/\.0$/,"")}B`:r>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,"")}M`:r>=1e4?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}k`:e.toLocaleString(void 0,{maximumFractionDigits:2})};function Tr(e){if(e==null||e==="")return null;const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?r:null}const po={warning:70,danger:90};function Yn(e,r=po){const n=r.warning??po.warning,a=r.danger??po.danger;return e>=a?"danger":e>=n?"warning":e<=0?"primary":"success"}function on(e,r){return Dt(Yn(e,r))}function $r(e,r=0){return Number.isFinite(e)?`${e.toFixed(r)}%`:"—"}function Ar(e,r=1){if(!Number.isFinite(e))return"—";const n=e<0?"-":"",a=Math.abs(e);if(a<1024)return`${n}${Math.round(a)} B`;const s=["KB","MB","GB","TB","PB"];let l=a/1024,i=0;for(;l>=1024&&i<s.length-1;)l/=1024,i+=1;const c=l>=100?l.toFixed(0):l.toFixed(r);return`${n}${c.replace(/\.0$/,"")} ${s[i]}`}function Bl(e,r="bytes",n=1){if(!Number.isFinite(e))return"—";const a=e<0?"-":"",s=Math.abs(e),l=r==="bits"?["b/s","Kb/s","Mb/s","Gb/s","Tb/s"]:["B/s","KB/s","MB/s","GB/s","TB/s"];if(s<1024)return`${a}${Math.round(s)} ${l[0]}`;let i=s/1024,c=1;for(;i>=1024&&c<l.length-1;)i/=1024,c+=1;const d=i>=100?i.toFixed(0):i.toFixed(n);return`${a}${d.replace(/\.0$/,"")} ${l[c]}`}function Lr(e,r){var n;for(let a=e.length-1;a>=0;a-=1){const s=Tr((n=e[a])==null?void 0:n[r]);if(s!==null)return s}return null}function Nt({height:e}){return t.jsx("div",{className:"flex items-center justify-center",style:{height:e},"aria-busy":!0,children:t.jsx("div",{className:"h-7 w-7 animate-spin rounded-full border-2",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"}})})}function kt({height:e,text:r}){return t.jsx("div",{className:"flex items-center justify-center text-sm",style:{height:e,color:"var(--text-muted)"},children:r})}const Xt=680,sr="ease-out",jf={top:18,right:8,bottom:12,left:0};function sn(e){return{...jf,...e}}function ln(e){return e.map((r,n)=>({...r,color:Hl(r,n),label:r.label??r.key}))}function Xn(e,r){return!e.length||!r.length||e.every(n=>r.every(a=>Tr(n[a.key])===null))}function St(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function cn(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function Fl(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function Kn(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function qf(e,r=wt){if(e==null||e==="")return"—";const n=typeof e=="number"?e:Number(e);return Number.isFinite(n)?r(n):String(e)}function Pl(e){return`bonsaif-grad-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function Uf({active:e,label:r,payload:n,valueFormat:a=wt}){var c,d,u,m,b,f;if(!e||!(n!=null&&n.length))return null;const s=n.filter(g=>g.dataKey!=="base"&&g.name!=="base"&&g.value!==null&&g.value!==void 0);if(!s.length)return null;const l=((d=(c=s[0])==null?void 0:c.payload)==null?void 0:d.fullName)??((m=(u=s[0])==null?void 0:u.payload)==null?void 0:m.tooltipLabel)??((f=(b=s[0])==null?void 0:b.payload)==null?void 0:f.display),i=typeof l=="string"&&l.length>0?l:r;return t.jsxs("div",{className:"bonsaif-chart-tooltip-panel",children:[i!=null&&i!==""?t.jsx("div",{className:"bonsaif-chart-tooltip-label",children:String(i)}):null,t.jsx("div",{className:"bonsaif-chart-tooltip-items",children:s.map((g,v)=>{const k=g.payload,h=k&&typeof k.display=="number"?k.display:g.value;return t.jsxs("div",{className:"bonsaif-chart-tooltip-row",children:[t.jsxs("span",{className:"bonsaif-chart-tooltip-name",children:[t.jsx("span",{className:"bonsaif-chart-tooltip-swatch",style:{background:g.color??"var(--primary)"}}),g.name??g.dataKey]}),t.jsx("span",{className:"bonsaif-chart-tooltip-value",children:qf(h,a)})]},String(g.dataKey??g.name??v))})})]})}function Dr({valueFormat:e,content:r,cursor:n,offset:a=12,wrapperStyle:s,allowEscapeViewBox:l,reverseDirection:i,...c}){return t.jsx(Ce.Tooltip,{...c,cursor:n,offset:a,allowEscapeViewBox:l??{x:!1,y:!1},reverseDirection:i??{x:!1,y:!1},wrapperStyle:{outline:"none",zIndex:60,pointerEvents:"none",overflow:"visible",...s},content:r??t.jsx(Uf,{valueFormat:e})})}function _l(e,r,n){return n==null?-1:e.findIndex(a=>String(a[r])===String(n))}function zl(e,r,n){if(n<=1)return null;const a=Math.max(0,Math.min(e,r)),s=Math.min(n-1,Math.max(e,r));return s-a<1||a===0&&s>=n-1?null:{startIndex:a,endIndex:s}}function Gn(e,r,n={}){const{zoomable:a=!1,zoomMode:s="both",brushHeight:l=28,onZoomChange:i}=n,[c,d]=o.useState(null),[u,m]=o.useState(null),b=!!a&&e.length>1,f=b&&(s==="brush"||s==="both"),g=b&&(s==="drag"||s==="both"),v=o.useCallback(Z=>{d(Z),i==null||i(Z)},[i]),k=o.useCallback(()=>{m(null),v(null)},[v]),h=!!c,C=o.useMemo(()=>!c||f?e:e.slice(c.startIndex,c.endIndex+1),[e,f,c]),M=o.useCallback((Z,L)=>{const Q=_l(e,r,Z),z=_l(e,r,L);Q<0||z<0||v(zl(Q,z,e.length))},[v,e,r]),y=o.useCallback(Z=>{g&&((Z==null?void 0:Z.activeLabel)===void 0||(Z==null?void 0:Z.activeLabel)===null||m({leftLabel:Z.activeLabel,rightLabel:Z.activeLabel}))},[g]),x=o.useCallback(Z=>{!g||!u||(Z==null?void 0:Z.activeLabel)===void 0||(Z==null?void 0:Z.activeLabel)===null||m(L=>L&&{...L,rightLabel:Z.activeLabel})},[u,g]),w=o.useCallback(()=>{if(g){if(!u||u.rightLabel===null||u.rightLabel===void 0){m(null);return}M(u.leftLabel,u.rightLabel),m(null)}},[M,u,g]),N=o.useCallback(Z=>{if(f){if(!Z){v(null);return}v(zl(Z.startIndex??0,Z.endIndex??e.length-1,e.length))}},[v,e.length,f]),A=g?{onMouseDown:y,onMouseMove:x,onMouseUp:w,onMouseLeave:()=>{u&&w()}}:{},T=c??{startIndex:0,endIndex:Math.max(0,e.length-1)},U=t.jsxs(t.Fragment,{children:[g&&u&&u.rightLabel!==null&&u.rightLabel!==void 0?t.jsx(Ce.ReferenceArea,{x1:u.leftLabel,x2:u.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,f?t.jsx(Ce.Brush,{dataKey:r,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:T.startIndex,endIndex:T.endIndex,onChange:N,tickFormatter:Z=>String(Z)}):null]}),K=f?{bottom:Math.max(l+10,36)}:void 0;return{enabled:b,showBrush:f,showDrag:g,viewData:C,isZoomed:h,resetZoom:k,chartHandlers:A,zoomNodes:U,marginExtra:K}}function Zn({visible:e,onReset:r}){return e?t.jsx("button",{type:"button",className:"bonsaif-chart-zoom-reset",onClick:r,"aria-label":"Restablecer zoom",children:"Restablecer zoom"}):null}function Vf({data:e,xKey:r,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=wt,yDomain:f,ariaLabel:g="Gráfico de líneas",curve:v=!0,strokeWidth:k=2.25,zoomable:h=!1,zoomMode:C="both",brushHeight:M,onZoomChange:y}){const x=Xn(e,n),w=ln(n),N=Gn(e,r,{zoomable:h,zoomMode:C,brushHeight:M,onZoomChange:y}),A=sn({...m,...N.marginExtra});return l?t.jsx(Nt,{height:a}):x?t.jsx(kt,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${s}`,role:"img","aria-label":g,style:{height:a},children:[t.jsx(Zn,{visible:N.isZoomed,onReset:N.resetZoom}),t.jsx(Ce.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ce.LineChart,{data:N.viewData,margin:A,...N.chartHandlers,children:[c?t.jsx(Ce.CartesianGrid,{strokeDasharray:"2 8",stroke:cn(),vertical:!1}):null,t.jsx(Ce.XAxis,{dataKey:r,tick:St(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Ce.YAxis,{tick:St(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:T=>b(Number(T)),dx:-2}),u?t.jsx(Dr,{valueFormat:b,cursor:{stroke:Fl(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Ce.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Kn()}):null,w.map((T,U)=>t.jsx(Ce.Line,{type:v?"monotone":"linear",dataKey:T.key,name:T.label,stroke:T.color,strokeWidth:U===0?k+.35:k,strokeOpacity:U===0?1:.88,isAnimationActive:!0,animationDuration:Xt,animationEasing:sr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:T.color}},T.key)),N.zoomNodes]})})]})}function Qn({data:e,xKey:r,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=wt,yDomain:f,ariaLabel:g="Gráfico de área",stacked:v=!1,opacity:k=.22,zoomable:h=!1,zoomMode:C="both",brushHeight:M,onZoomChange:y}){const x=Xn(e,n),w=ln(n),N=Gn(e,r,{zoomable:h,zoomMode:C,brushHeight:M,onZoomChange:y}),A=sn({...m,...N.marginExtra});return l?t.jsx(Nt,{height:a}):x?t.jsx(kt,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${s}`,role:"img","aria-label":g,style:{height:a},children:[t.jsx(Zn,{visible:N.isZoomed,onReset:N.resetZoom}),t.jsx(Ce.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ce.AreaChart,{data:N.viewData,margin:A,...N.chartHandlers,children:[t.jsx("defs",{children:w.map(T=>t.jsxs("linearGradient",{id:Pl(T.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:T.color,stopOpacity:Math.min(.55,k+.28)}),t.jsx("stop",{offset:"48%",stopColor:T.color,stopOpacity:k*.5}),t.jsx("stop",{offset:"100%",stopColor:T.color,stopOpacity:0})]},T.key))}),c?t.jsx(Ce.CartesianGrid,{strokeDasharray:"2 8",stroke:cn(),vertical:!1}):null,t.jsx(Ce.XAxis,{dataKey:r,tick:St(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Ce.YAxis,{tick:St(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:T=>b(Number(T)),dx:-2}),u?t.jsx(Dr,{valueFormat:b,cursor:{stroke:Fl(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Ce.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Kn()}):null,w.map(T=>t.jsx(Ce.Area,{type:"monotone",dataKey:T.key,name:T.label,stroke:T.color,fill:`url(#${Pl(T.key)})`,strokeWidth:2.25,stackId:v?"stack":void 0,isAnimationActive:!0,animationDuration:Xt,animationEasing:sr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:T.color}},T.key)),N.zoomNodes]})})]})}function Yf({data:e,xKey:r,series:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=wt,yDomain:f,ariaLabel:g="Gráfico de barras",layout:v="vertical",mode:k="grouped",barRadius:h=6,categoryAxisWidth:C=64,zoomable:M=!1,zoomMode:y="both",brushHeight:x,onZoomChange:w}){const N=Xn(e,n),A=ln(n),T=v==="horizontal",U=Gn(e,r,{zoomable:M&&!T,zoomMode:y,brushHeight:x,onZoomChange:w}),K=sn({...m,...U.marginExtra});return l?t.jsx(Nt,{height:a}):N?t.jsx(kt,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${s}`,role:"img","aria-label":g,style:{height:a},children:[t.jsx(Zn,{visible:U.isZoomed,onReset:U.resetZoom}),t.jsx(Ce.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ce.BarChart,{data:U.viewData,margin:K,layout:T?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,...U.chartHandlers,children:[c?t.jsx(Ce.CartesianGrid,{strokeDasharray:"2 8",stroke:cn(),horizontal:!T,vertical:T}):null,T?t.jsxs(t.Fragment,{children:[t.jsx(Ce.XAxis,{type:"number",tick:St(),tickLine:!1,axisLine:!1,tickFormatter:Z=>b(Number(Z)),domain:f??["auto","auto"]}),t.jsx(Ce.YAxis,{type:"category",dataKey:r,tick:St(),tickLine:!1,axisLine:!1,width:C})]}):t.jsxs(t.Fragment,{children:[t.jsx(Ce.XAxis,{dataKey:r,tick:St(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Ce.YAxis,{tick:St(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:Z=>b(Number(Z)),dx:-2})]}),u?t.jsx(Dr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,d?t.jsx(Ce.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Kn()}):null,A.map((Z,L)=>t.jsx(Ce.Bar,{dataKey:Z.key,name:Z.label,fill:Z.color,fillOpacity:L===0?1:.82,radius:T?[0,h,h,0]:[h,h,2,2],maxBarSize:20,stackId:k==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:Xt,animationEasing:sr},Z.key)),U.zoomNodes]})})]})}function Xf(e){return t.jsx(jl,{...e,variant:"pie"})}function Kf(e){return t.jsx(jl,{...e,variant:"donut",innerRadius:e.innerRadius??.62,cornerRadius:e.cornerRadius??10,padAngle:e.padAngle??2})}function Wl(e,r){return e==null||!Number.isFinite(e)?r:e>0&&e<=1?e*100:e}function jl({data:e,nameKey:r,valueKey:n,height:a=280,className:s="",loading:l=!1,emptyText:i="Sin datos para mostrar",showLegend:c=!0,showTooltip:d=!0,valueFormat:u=wt,ariaLabel:m,innerRadius:b,outerRadius:f,colors:g=[...an],padAngle:v,cornerRadius:k,variant:h}){const C=e.map((L,Q)=>({name:String(L[r]??""),value:Tr(L[n])??0,fill:g[Q%g.length],row:L})).filter(L=>L.value>0),M=!C.length,y=h==="donut",x=C.length,w=Wl(b,y?62:12),N=Wl(f,78),A=Math.min(v??(y?2:3),Math.max(.5,10/Math.max(1,x))),T=Math.min(k??(y?10:8),Math.max(2,36/Math.max(1,x)));if(l)return t.jsx(Nt,{height:a});if(M)return t.jsx(kt,{height:a,text:i});const U=C.reduce((L,Q)=>L+Q.value,0),K=c?Math.min(96,28+Math.ceil(x/3)*22):0,Z=Math.max(140,a-K);return t.jsx("div",{className:`bonsaif-chart bonsaif-${h}-chart w-full ${s}`,role:"img","aria-label":m??(h==="donut"?"Donut chart":"Pie chart"),style:{height:a},children:t.jsxs("div",{className:"bonsaif-pie-layout",children:[t.jsx("div",{className:"bonsaif-pie-plot",style:{height:Z},children:t.jsx(Ce.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ce.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[d?t.jsx(Dr,{valueFormat:u,isAnimationActive:!1}):null,t.jsx(Ce.Pie,{data:C,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${w}%`,outerRadius:`${N}%`,startAngle:90,endAngle:-270,paddingAngle:A,cornerRadius:T,minAngle:x>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:Xt,animationEasing:sr,label:!1,activeShape:Gf,children:C.map(L=>t.jsx(Ce.Cell,{fill:L.fill},L.name))}),y?t.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:u(U)}):null]})})}),c?t.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:C.map(L=>t.jsxs("li",{className:"bonsaif-pie-legend-item",children:[t.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:L.fill},"aria-hidden":!0}),t.jsx("span",{className:"bonsaif-pie-legend-label",title:L.name,children:L.name}),t.jsx("span",{className:"bonsaif-pie-legend-value",children:u(L.value)})]},L.name))}):null]})})}function Gf(e){const{outerRadius:r=0,...n}=e;return t.jsx(Ce.Sector,{...n,outerRadius:Number(r)+4,stroke:"var(--bg-card)",strokeWidth:2})}function Zf({data:e,dataKey:r,width:n="100%",height:a=36,tone:s="primary",color:l,fill:i=!0,className:c="",ariaLabel:d="Sparkline"}){const u=l??Dt(s),m=e.map(N=>Tr(N[r])).filter(N=>N!==null);if(m.length<2)return t.jsx("div",{className:c,style:{width:n,height:a,color:"var(--text-muted)"},"aria-label":d});const b=120,f=36,g=3,v=1,k=Math.min(...m),C=Math.max(...m)-k||1,M=m.map((N,A)=>{const T=v+A/(m.length-1)*(b-v*2),U=f-g-(N-k)/C*(f-g*2);return{x:T,y:U}}),y=M.map((N,A)=>`${A===0?"M":"L"}${N.x.toFixed(2)} ${N.y.toFixed(2)}`).join(" "),x=`${y} L${M[M.length-1].x.toFixed(2)} ${f} L${M[0].x.toFixed(2)} ${f} Z`,w=`bonsaif-spark-${r.replace(/[^a-zA-Z0-9_-]/g,"")}-${s}`;return t.jsx("div",{className:`bonsaif-sparkline ${c}`,style:{width:n,height:a},role:"img","aria-label":d,children:t.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${b} ${f}`,preserveAspectRatio:"none",focusable:"false",children:[i?t.jsx("defs",{children:t.jsxs("linearGradient",{id:w,x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:u,stopOpacity:.38}),t.jsx("stop",{offset:"100%",stopColor:u,stopOpacity:0})]})}):null,i?t.jsx("path",{d:x,fill:`url(#${w})`}):null,t.jsx("path",{d:y,fill:"none",stroke:u,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function Qf({data:e,xKey:r,series:n,barSeries:a,lineSeries:s,height:l=280,className:i="",loading:c=!1,emptyText:d="Sin datos para mostrar",showGrid:u=!0,showLegend:m=!0,showTooltip:b=!0,margin:f,valueFormat:g=wt,yDomain:v,ariaLabel:k="Gráfico combinado",barRadius:h=6,zoomable:C=!1,zoomMode:M="both",brushHeight:y,onZoomChange:x}){const w=a??n.slice(0,Math.max(1,n.length-1)),N=s??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),A=[...w,...N.filter(z=>!w.some(se=>se.key===z.key))],T=Xn(e,A),U=ln(w),K=ln(A),Z=N.map(z=>{var re;const se=K.find(R=>R.key===z.key);return{...z,label:z.label??z.key,color:z.color??(se==null?void 0:se.color)??((re=K[0])==null?void 0:re.color)}}),L=Gn(e,r,{zoomable:C,zoomMode:M,brushHeight:y,onZoomChange:x}),Q=sn({...f,...L.marginExtra});return c?t.jsx(Nt,{height:l}):T?t.jsx(kt,{height:l,text:d}):t.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":k,style:{height:l},children:[t.jsx(Zn,{visible:L.isZoomed,onReset:L.resetZoom}),t.jsx(Ce.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ce.ComposedChart,{data:L.viewData,margin:Q,barCategoryGap:"34%",...L.chartHandlers,children:[u?t.jsx(Ce.CartesianGrid,{strokeDasharray:"2 8",stroke:cn(),vertical:!1}):null,t.jsx(Ce.XAxis,{dataKey:r,tick:St(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Ce.YAxis,{tick:St(),tickLine:!1,axisLine:!1,width:44,domain:v??["auto","auto"],tickFormatter:z=>g(Number(z)),dx:-2}),b?t.jsx(Dr,{valueFormat:g,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,m?t.jsx(Ce.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Kn()}):null,U.map(z=>t.jsx(Ce.Bar,{dataKey:z.key,name:z.label,fill:z.color,fillOpacity:.88,radius:[h,h,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:Xt,animationEasing:sr},z.key)),Z.map(z=>t.jsx(Ce.Line,{type:"monotone",dataKey:z.key,name:z.label,stroke:z.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:Xt,animationEasing:sr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:z.color}},z.key)),L.zoomNodes]})})]})}function Jf({data:e,xKey:r,valueKey:n,typeKey:a,height:s=280,className:l="",loading:i=!1,emptyText:c="Sin datos para mostrar",showGrid:d=!0,showTooltip:u=!0,margin:m,valueFormat:b=wt,ariaLabel:f="Gráfico waterfall",increaseColor:g="#34d399",decreaseColor:v="#f87171",totalColor:k="var(--primary)"}){const h=o.useMemo(()=>Rf(e,{xKey:r,valueKey:n,typeKey:a,increaseColor:g,decreaseColor:v,totalColor:k}),[e,r,n,a,g,v,k]),C=!h.length,M=sn(m);return i?t.jsx(Nt,{height:s}):C?t.jsx(kt,{height:s,text:c}):t.jsx("div",{className:`bonsaif-chart bonsaif-waterfall-chart w-full ${l}`,role:"img","aria-label":f,style:{height:s},children:t.jsx(Ce.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ce.BarChart,{data:h,margin:M,barCategoryGap:"42%",children:[d?t.jsx(Ce.CartesianGrid,{strokeDasharray:"2 8",stroke:cn(),vertical:!1}):null,t.jsx(Ce.XAxis,{dataKey:"label",tick:St(),tickLine:!1,axisLine:!1,interval:0,dy:6}),t.jsx(Ce.YAxis,{tick:St(),tickLine:!1,axisLine:!1,width:44,tickFormatter:y=>b(Number(y)),dx:-2}),u?t.jsx(Dr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,t.jsx(Ce.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),t.jsx(Ce.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:Xt,animationEasing:sr,children:h.map(y=>t.jsx(Ce.Cell,{fill:y.color},y.label))})]})})})}function Rf(e,r){let n=0;return e.map((a,s)=>{const l=Tr(a[r.valueKey])??0,i=r.typeKey?String(a[r.typeKey]??""):"",c=i==="total"||s===e.length-1&&i!=="increase"&&i!=="decrease";let d="increase",u=0,m=0,b=l;return c&&i==="total"?(d="total",u=0,m=Math.abs(l),b=l,n=l):c&&s===e.length-1&&!i?(d="total",u=0,m=Math.abs(n),b=n):(d=i==="decrease"||l<0?"decrease":"increase",d==="decrease"?(u=n+l,m=Math.abs(l),n=n+l):(u=n,m=Math.abs(l),n=n+l),b=l),{label:String(a[r.xKey]??""),base:u,delta:m,display:b,kind:d,color:d==="total"?r.totalColor:d==="decrease"?r.decreaseColor:r.increaseColor}})}const ql="bonsaif-funnel-chart-keyframes",eb=`
|
|
43
45
|
@keyframes bonsaif-funnel-stage-in {
|
|
44
46
|
from {
|
|
45
47
|
opacity: 0;
|
|
@@ -79,4 +81,4 @@ ${R}`,ne=new Blob(["\uFEFF"+O],{type:"text/csv;charset=utf-8;"}),fe=URL.createOb
|
|
|
79
81
|
animation: none !important;
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
|
-
`;function df(){if(typeof document>"u"||document.getElementById(il))return;const e=document.createElement("style");e.id=il,e.textContent=cf,document.head.appendChild(e)}function cl(e,r,n){return Math.min(n,Math.max(r,e))}function Bn(e,r,n){const a=cl(n,0,1);return`color-mix(in srgb, ${e} ${Math.round((1-a)*100)}%, ${r} ${Math.round(a*100)}%)`}function uf(e,r,n,a,o,l){const i=e.map((d,u)=>{const m=br(d[n])??0,f=String(d[r]??""),b=a?String(d[a]??"").trim():"",v=o?String(d[o]??"").trim():"";return{name:f,value:m,color:l[u%l.length],...b?{title:b}:{},...v?{description:v}:{}}}).filter(d=>d.value>0&&d.name),c=Math.max(...i.map(d=>d.value),1);return i.map(d=>({...d,pct:d.value/c}))}function ff(e,r){const n=e.length;if(n===0)return[];const a=r.gap*Math.max(0,n-1),o=(r.plotH-a)/n,l=r.maxTopW,i=r.maxTopW*r.taper;return e.map((c,d)=>{const u=n===1?0:d/n,m=n===1?1:(d+1)/n,f=l+(i-l)*u,b=l+(i-l)*m;return{...c,index:d,y:r.topY+d*(o+r.gap),h:o,topW:f,bottomW:b,cx:r.cx}})}function bf({stage:e,hovered:r,onHover:n}){const{cx:a,y:o,h:l,topW:i,bottomW:c,color:d}=e,u=a-i/2,m=a+i/2,f=a-c/2,b=a+c/2,v=o+l,x=Math.max(4,Math.min(14,l*.18)),E=Bn(d,"#000",r?.12:.22),h=Bn(d,"#fff",r?.08:0),$=Bn(d,"#fff",.22),M=[`M ${u} ${o}`,`L ${m} ${o}`,`L ${b} ${v}`,`L ${f} ${v}`,"Z"].join(" ");return t.jsxs("g",{onMouseEnter:()=>n(e.index),onMouseLeave:()=>n(null),style:{cursor:"default"},children:[t.jsx("path",{d:M,fill:E}),t.jsx("path",{d:[`M ${u} ${o}`,`L ${m} ${o}`,`L ${m} ${o+1}`,`L ${b} ${v}`,`L ${a} ${v}`,`L ${u} ${o}`,"Z"].join(" "),fill:h,opacity:.55}),t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:x,fill:$,stroke:Bn(d,"#000",.15),strokeWidth:1}),r?t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:x,fill:"none",stroke:"var(--text-main)",strokeOpacity:.25,strokeWidth:1.5}):null]})}function mf({data:e,nameKey:r,valueKey:n,titleKey:a,descriptionKey:o,height:l=360,className:i="",loading:c=!1,emptyText:d="Sin datos para mostrar",showTooltip:u=!0,showLabels:m=!0,showValues:f=!0,showBottomArrow:b=!0,taper:v=.42,colors:x=[...Yr],animationDuration:E=Ot,valueFormat:h=ot,ariaLabel:$="Gráfico embudo"}){const[M,y]=s.useState(null),[w,k]=s.useState(!1),N=s.useMemo(()=>uf(e,r,n,a,o,x),[e,r,n,a,o,x]),A=s.useMemo(()=>N.map(I=>`${I.name}:${I.value}`).join("|"),[N]);if(s.useEffect(()=>{if(df(),typeof window>"u")return;const I=window.matchMedia("(prefers-reduced-motion: reduce)");k(I.matches);const te=()=>k(I.matches);return I.addEventListener("change",te),()=>I.removeEventListener("change",te)},[]),c)return t.jsx(lt,{height:l});if(!N.length)return t.jsx(it,{height:l,text:d});const C=E>0&&!w,j=E,W=Math.min(90,Math.max(40,Math.round(E/8))),G=Math.round(j*.15),T=N.length*W+Math.round(j*.35),Z=N.some(I=>I.title||I.description),H=m?160:24,ae=Z?168:24,X=b?36:8,V=H+220+ae,q=l,L=18,oe=Math.max(120,q-L-X-8),B=H+110,le=ff(N,{cx:B,topY:L,plotH:oe,maxTopW:200,taper:cl(v,.2,.95),gap:10}),g=M!=null?le[M]:null,P="cubic-bezier(0.22, 1, 0.36, 1)";return t.jsxs("div",{className:`bonsaif-chart bonsaif-funnel-chart relative w-full ${i}`,role:"img","aria-label":$,style:{height:l},children:[t.jsxs("svg",{viewBox:`0 0 ${V} ${q}`,width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",children:[m?t.jsx("line",{className:C?"bonsaif-funnel-label":void 0,style:C?{animation:`bonsaif-funnel-fade-in ${j}ms ${P} both`}:void 0,x1:H-12,y1:L,x2:H-12,y2:L+oe,stroke:"var(--border)",strokeDasharray:"3 5",strokeWidth:1}):null,le.map(I=>{const te=I.y+I.h/2,U=I.cx-I.topW/2,K=I.index*W,D=C?{animation:`bonsaif-funnel-stage-in ${j}ms ${P} ${K}ms both`}:void 0,ee=C?{animation:`bonsaif-funnel-fade-in ${Math.round(j*.85)}ms ${P} ${K+G}ms both`}:void 0;return t.jsxs("g",{children:[t.jsx("g",{className:"bonsaif-funnel-stage",style:D,children:t.jsx(bf,{stage:I,hovered:M===I.index,onHover:y})}),m?t.jsxs("g",{className:"bonsaif-funnel-label",style:ee,children:[t.jsx("line",{x1:24,y1:te,x2:H-12,y2:te,stroke:I.color,strokeOpacity:.55,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("line",{x1:H-12,y1:te,x2:U-6,y2:te,stroke:I.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("text",{x:20,y:te-(f?6:0),textAnchor:"end",fill:I.color,fontSize:12,fontWeight:600,children:I.name.length>18?`${I.name.slice(0,16)}…`:I.name}),f?t.jsx("text",{x:20,y:te+10,textAnchor:"end",fill:"var(--text-muted)",fontSize:11,children:h(I.value)}):null]}):null,(I.title||I.description)&&Z?t.jsxs("g",{className:"bonsaif-funnel-anno",style:ee,children:[t.jsx("line",{x1:I.cx+I.bottomW/2+6,y1:te,x2:H+220+8,y2:te,stroke:I.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),I.title?t.jsx("text",{x:H+220+14,y:te-(I.description?6:0),fill:"var(--text-main)",fontSize:12,fontWeight:700,children:I.title.length>22?`${I.title.slice(0,20)}…`:I.title}):null,I.description?t.jsx("text",{x:H+220+14,y:te+(I.title?10:0),fill:"var(--text-muted)",fontSize:11,children:I.description.length>28?`${I.description.slice(0,26)}…`:I.description}):null]}):null]},`${I.name}-${I.index}`)}),b?t.jsx("g",{className:"bonsaif-funnel-arrow",transform:`translate(${B}, ${L+oe+8})`,fill:"var(--primary)",style:C?{animation:`bonsaif-funnel-arrow-in ${Math.round(j*.7)}ms ${P} ${T}ms both`}:void 0,children:t.jsx("path",{d:"M0,22 L10,8 L4,8 L4,0 L-4,0 L-4,8 L-10,8 Z"})}):null]},A),u&&g?t.jsxs("div",{className:"pointer-events-none absolute z-10 rounded-md border px-2.5 py-1.5 text-xs shadow-sm",style:{left:"50%",top:8,transform:"translateX(-50%)",background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[t.jsx("span",{className:"font-semibold",style:{color:g.color},children:g.name}),t.jsx("span",{style:{color:"var(--text-muted)"},children:" · "}),h(g.value),t.jsxs("span",{style:{color:"var(--text-muted)"},children:[" ","(",Math.round(g.pct*100),"% del top)"]})]}):null]})}const vr=135*Math.PI/180,Ka=270*Math.PI/180;function pf({value:e,min:r=0,max:n=100,height:a=180,className:o="",loading:l=!1,empty:i=!1,emptyText:c="Sin datos para mostrar",label:d,valueFormat:u=ot,tone:m="primary",color:f,thresholds:b,ariaLabel:v="Gauge",animationDuration:x=700,thickness:E=9,showScale:h=!1}){const $=s.useId().replace(/:/g,""),M=n-r||1,y=Math.min(1,Math.max(0,(e-r)/M)),[w,k]=s.useState(x>0?0:y);if(s.useEffect(()=>{if(l||i)return;if(x<=0){k(y);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){k(y);return}let V=0,q=0;k(B=>(q=B,B));const L=performance.now(),oe=B=>{const F=Math.min(1,(B-L)/x),le=1-(1-F)**3;k(q+(y-q)*le),F<1&&(V=requestAnimationFrame(oe))};return V=requestAnimationFrame(oe),()=>cancelAnimationFrame(V)},[y,x,l,i]),l)return t.jsx(lt,{height:a});if(i)return t.jsx(it,{height:a,text:c});const N=100,A=108,C=72,j=f??hf(e,n,m,b),W=r+w*M,G=dl(N,A,C,vr,vr+Ka),T=vr+Math.max(.001,w)*Ka,Z=dl(N,A,C,vr,T),H=Fn(N,A,C,vr),ae=Fn(N,A,C,vr+Ka);return t.jsx("div",{className:`bonsaif-chart bonsaif-gauge-chart flex flex-col items-center justify-center ${o}`,style:{height:a},children:t.jsxs("svg",{viewBox:"0 0 200 168",width:"100%",height:"100%",role:"img","aria-label":v,className:"overflow-visible",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:`bonsaif-gauge-${$}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[t.jsx("stop",{offset:"0%",stopColor:j,stopOpacity:.82}),t.jsx("stop",{offset:"100%",stopColor:j,stopOpacity:1})]})}),t.jsx("path",{d:G,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:E,strokeLinecap:"butt"}),t.jsx("path",{d:Z,fill:"none",stroke:`url(#bonsaif-gauge-${$})`,strokeWidth:E,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),t.jsx("text",{x:N,y:A-(d?4:0),textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:28,fontWeight:700,letterSpacing:"-0.04em",className:"bonsaif-chart-gauge-label",children:u(W)}),d?t.jsx("text",{x:N,y:A+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:d}):null,h?t.jsxs(t.Fragment,{children:[t.jsx("text",{x:H.x-2,y:H.y+E+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(r)}),t.jsx("text",{x:ae.x+2,y:ae.y+E+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(n)})]}):null]})})}function hf(e,r,n,a){if(a!=null&&a.length){const l=[...a].sort((c,d)=>c.value-d.value);let i=l[0].color;for(const c of l)e>=c.value&&(i=c.color);return i}if(n)return yt(n);const o=e/(r||1);return o>=.8?yt("success"):o>=.5?yt("warning"):yt("danger")}function Fn(e,r,n,a){return{x:e+n*Math.cos(a),y:r+n*Math.sin(a)}}function dl(e,r,n,a,o){const l=Fn(e,r,n,a),i=Fn(e,r,n,o),c=o-a,d=Math.abs(c)>Math.PI?1:0;return`M ${l.x} ${l.y} A ${n} ${n} 0 ${d} 1 ${i.x} ${i.y}`}function gf({value:e,target:r,max:n,ranges:a,height:o=72,className:l="",loading:i=!1,empty:c=!1,emptyText:d="Sin datos para mostrar",label:u,subtitle:m,valueFormat:f=ot,tone:b="primary",showScale:v=!0,showStatus:x=!0,ariaLabel:E="Bullet chart"}){if(i)return t.jsx(lt,{height:o});if(c)return t.jsx(it,{height:o,text:d});const h=n??Math.max(e,r,...(a==null?void 0:a.map(j=>j.value))??[],1)*1.05,M=[...a??[{value:h*.5,color:"color-mix(in srgb, var(--border) 72%, transparent)"},{value:h*.75,color:"color-mix(in srgb, var(--border) 48%, transparent)"},{value:h,color:"color-mix(in srgb, var(--border) 28%, transparent)"}]].sort((j,W)=>j.value-W.value),y=yt(b),w=Math.min(100,Math.max(0,e/h*100)),k=Math.min(100,Math.max(0,r/h*100)),N=e>=r,A=[0,.25,.5,.75,1].map(j=>j*h),C=t.jsxs("div",{className:"bonsaif-bullet-plot min-w-0 flex-1",children:[t.jsxs("div",{className:"bonsaif-bullet-track relative w-full",style:{height:Math.max(22,u?28:o*.42)},role:"img","aria-label":E,children:[t.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:M.map((j,W)=>{const G=W===0?0:M[W-1].value,T=Math.max(0,(j.value-G)/h*100);return t.jsx("div",{style:{width:`${T}%`,background:j.color??`color-mix(in srgb, var(--border) ${70-W*18}%, transparent)`}},W)})}),t.jsx("div",{className:"absolute left-0 top-1/2 w-full",style:{height:"34%",transform:"translateY(-50%)"},children:t.jsx("div",{className:"bonsaif-bullet-value h-full",style:{width:`${w}%`,background:y,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${y} 35%, transparent)`}})}),t.jsx("div",{className:"bonsaif-bullet-target absolute top-1/2 z-[1]",style:{left:`${k}%`,height:"72%",width:3,transform:"translate(-50%, -50%)",background:y,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${f(r)}`})]}),v?t.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:A.map((j,W)=>{const G=j/h*100,T=W===0,Z=W===A.length-1;return t.jsxs("div",{className:"absolute top-0",style:{left:`${G}%`,transform:T?"none":Z?"translateX(-100%)":"translateX(-50%)"},children:[t.jsx("div",{className:"mx-auto h-1.5 w-px",style:{background:"color-mix(in srgb, var(--text-muted) 55%, transparent)",marginLeft:T?0:Z?"auto":void 0,marginRight:Z?0:void 0}}),t.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:T?"left":Z?"right":"center"},children:f(j)})]},j)})}):null]});return t.jsx("div",{className:`bonsaif-chart bonsaif-bullet-chart w-full ${l}`,children:u?t.jsxs("div",{className:"bonsaif-bullet-row flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-4",children:[t.jsxs("div",{className:"bonsaif-bullet-label shrink-0 sm:w-[7.5rem] sm:pt-1 sm:text-right",children:[t.jsx("div",{className:"text-sm font-semibold tracking-tight",style:{color:"var(--text-main)"},children:u}),m?t.jsx("div",{className:"mt-0.5 text-[11px] leading-snug",style:{color:"var(--text-muted)"},children:m}):t.jsxs("div",{className:"mt-0.5 text-[11px] tabular-nums leading-snug",style:{color:"var(--text-muted)"},children:[t.jsx("span",{style:{color:y,fontWeight:600},children:f(e)}),t.jsxs("span",{children:[" / meta ",f(r)]})]}),x?t.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:yt(N?"success":"warning")},children:N?"En meta":"Bajo meta"}):null]}),C]}):C})}function vf({data:e,value:r,timeKey:n="t",usageKey:a="usage",series:o,cores:l,height:i=220,className:c="",loading:d=!1,emptyText:u="Sin datos de CPU",showLegend:m=!1,showTooltip:f=!0,thresholds:b,label:v="CPU",ariaLabel:x="Uso de CPU"}){var k;const E=o??[{key:a,label:"Uso",color:Xr(r??hr(e,a)??0,b)}],h=r??hr(e,a)??hr(e,((k=E[0])==null?void 0:k.key)??a),$=!d&&(!e.length||h===null);if(d)return t.jsx(lt,{height:i});if($)return t.jsx(it,{height:i,text:u});const M=Math.min(100,Math.max(0,h??0)),y=Ln(M,b),w=Xr(M,b);return t.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":x,children:[t.jsxs("div",{className:"bonsaif-metric-head",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"bonsaif-metric-kicker",children:[v,l!=null?t.jsxs("span",{className:"ml-1.5 normal-case tracking-normal opacity-80",children:["· ",l," ",l===1?"core":"cores"]}):null]}),t.jsx("div",{className:"bonsaif-metric-value",style:{color:w},children:mr(M,M<10?1:0)})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:w,background:`color-mix(in srgb, ${w} 14%, transparent)`},children:y==="danger"?"Crítico":y==="warning"?"Alto":"Normal"})]}),t.jsx(Hn,{data:e,xKey:n,series:E.map(N=>({...N,color:N.color??w})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:m,showTooltip:f,valueFormat:N=>mr(N,0),ariaLabel:x,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function yf({used:e,total:r,cached:n,data:a=[],timeKey:o="t",usageKey:l="usage",height:i=220,className:c="",loading:d=!1,emptyText:u="Sin datos de memoria",showHistory:m=!0,showTooltip:f=!0,thresholds:b,label:v="RAM",ariaLabel:x="Uso de memoria"}){const E=r>0?r:1,h=Math.min(100,Math.max(0,e/E*100)),$=!d&&!(Number.isFinite(e)&&Number.isFinite(r)&&r>0);if(d)return t.jsx(lt,{height:i});if($)return t.jsx(it,{height:i,text:u});const M=Ln(h,b),y=Xr(h,b),w=Math.max(0,r-e),k=a.length>0?hr(a,l)??h:h,N=Xr(k,b),A=m&&a.length>1?Math.max(100,i-110):0;return t.jsxs("div",{className:`bonsaif-chart bonsaif-ram-chart w-full ${c}`,role:"group","aria-label":x,children:[t.jsxs("div",{className:"bonsaif-metric-head",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"bonsaif-metric-kicker",children:v}),t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("span",{className:"bonsaif-metric-value",style:{color:y},children:mr(h,h<10?1:0)}),t.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[pr(e)," / ",pr(r)]})]})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:y,background:`color-mix(in srgb, ${y} 14%, transparent)`},children:M==="danger"?"Crítico":M==="warning"?"Alto":"Normal"})]}),t.jsxs("div",{className:"mb-2",children:[t.jsx("div",{className:"h-2 w-full overflow-hidden rounded-sm",style:{background:"color-mix(in srgb, var(--border) 55%, transparent)"},role:"progressbar","aria-valuenow":Math.round(h),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${v} ${mr(h,0)}`,children:t.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${h}%`,background:`linear-gradient(90deg, ${y}, color-mix(in srgb, ${y} 55%, #38bdf8))`}})}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[11px] tabular-nums",style:{color:"var(--text-muted)"},children:[t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Usada"})," ",pr(e)]}),n!=null&&Number.isFinite(n)?t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",pr(n)]}):null,t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",pr(w)]})]})]}),m&&a.length>1?t.jsx(Hn,{data:a,xKey:o,series:[{key:l,label:"Uso",color:N}],height:A,yDomain:[0,100],showLegend:!1,showTooltip:f,valueFormat:C=>mr(C,0),ariaLabel:`${x} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const xf="color-mix(in srgb, var(--primary) 25%, #38bdf8)",wf="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function kf({data:e,timeKey:r="t",inboundKey:n="in",outboundKey:a="out",inbound:o,outbound:l,unit:i="bytes",inboundLabel:c="Entrada",outboundLabel:d="Salida",inboundColor:u=xf,outboundColor:m=wf,height:f=240,className:b="",loading:v=!1,emptyText:x="Sin datos de red",showLegend:E=!1,showTooltip:h=!0,label:$="Network",ariaLabel:M="Tráfico de red"}){const y=o??hr(e,n)??0,w=l??hr(e,a)??0,k=!v&&e.length===0;if(v)return t.jsx(lt,{height:f});if(k)return t.jsx(it,{height:f,text:x});const N=j=>tl(j,i),C=Math.max(140,f-76);return t.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${b}`,role:"group","aria-label":M,children:[t.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:t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"bonsaif-metric-kicker",children:$}),t.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-5 sm:max-w-lg",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[t.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:u},"aria-hidden":!0}),c]}),t.jsx("div",{className:"mt-1 truncate text-xl font-bold tabular-nums leading-tight tracking-tight",style:{color:u},title:N(y),children:N(y)})]}),t.jsxs("div",{className:"min-w-0 pl-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[t.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:m},"aria-hidden":!0}),d]}),t.jsx("div",{className:"mt-1 truncate text-lg font-semibold tabular-nums leading-tight tracking-tight opacity-95",style:{color:m},title:N(w),children:N(w)})]})]})]})}),t.jsx("div",{className:"bonsaif-network-plot relative z-0",children:t.jsx(Hn,{data:e,xKey:r,series:[{key:n,label:c,color:u},{key:a,label:d,color:m}],height:C,showLegend:E,showTooltip:h,valueFormat:N,ariaLabel:M,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const ul=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],fl=["primeSuiteOrigin","primeSuiteProjectKey"];function Nf(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const e=new URLSearchParams(window.location.search);for(const r of ul){const n=e.get(r);if(n){const a=Pn(n);if(a)return a}}if(typeof sessionStorage<"u")for(const r of fl){const n=sessionStorage.getItem(r);if(n)try{const a=new URL(n);if(a.origin&&a.origin!==window.location.origin)return a.origin}catch{const a=Pn(n);if(a)return a}}if(document.referrer){const r=Pn(document.referrer);if(r&&r!==window.location.origin)return r}return"*"}catch{return"*"}}function Sf(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const e=new URLSearchParams(window.location.search);for(const r of ul)if(e.get(r))return"query";if(typeof sessionStorage<"u"){for(const r of fl)if(sessionStorage.getItem(r))return"sessionStorage"}if(document.referrer){const r=Pn(document.referrer);if(r&&r!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function Pn(e){if(!e)return null;const r=e.trim().replace(/\/+$/,"");if(!r)return null;if(/^https?:\/\/[^/]+$/.test(r))return r;try{return new URL(r).origin}catch{return null}}function Cf(e){const[r,n]=s.useState({}),[a,o]=s.useState(!1),l=s.useCallback(u=>a||r[u]?e[u]:void 0,[e,a,r]),i=s.useCallback(u=>{n(m=>({...m,[u]:!0}))},[]),c=s.useCallback(()=>{o(!0)},[]),d=s.useCallback(()=>{n({}),o(!1)},[]);return{submitted:a,touchedFields:r,getFieldError:l,touchField:i,submit:c,reset:d}}Object.defineProperty(Y,"toast",{enumerable:!0,get:()=>bs.toast}),Y.Alert=pi,Y.AreaChart=Hn,Y.AuthShell=Go,Y.BarChart=ef,Y.BonsaifButton=Zl,Y.BonsaifUIToaster=Ku,Y.BulletChart=gf,Y.Button=je,Y.CHART_PALETTE=Yr,Y.CalendarPicker=xi,Y.ChartCard=Gu,Y.Checkbox=dn,Y.CodeBlock=Ci,Y.ComboChart=sf,Y.CompactFilterSelect=$i,Y.CompactSearchInput=Mi,Y.ConfirmDialog=Di,Y.CopyButton=da,Y.CopyLinkButton=Bi,Y.CpuChart=vf,Y.DataSheets=ic,Y.DataTable=Hs,Y.DateRangePicker=bc,Y.DonutChart=rf,Y.Drawer=kc,Y.DropdownMenu=xc,Y.DynamicDetailTabs=bi,Y.EmailField=Vc,Y.EmptyState=Xc,Y.FieldHelperFooter=lr,Y.FieldLabelInfo=or,Y.FieldLayoutEditor=Rc,Y.FileUpload=Qc,Y.FormField=Ea,Y.FunnelChart=mf,Y.GaugeChart=pf,Y.GlobalScrollbars=qo,Y.ImageLightbox=to,Y.ImageLightboxHost=id,Y.InputField=Ca,Y.LineChart=Ru,Y.LoadingState=xs,Y.MentionTextEditor=Lo,Y.MicroserviceFrame=qu,Y.Modal=ba,Y.MouseTooltip=zt,Y.MultiDateCalendar=pc,Y.MultiSelect=dd,Y.NetworkChart=kf,Y.NumberField=ud,Y.PageHeader=zu,Y.PageSearchInput=ps,Y.Pagination=bd,Y.PhoneField=pd,Y.PieChart=tf,Y.PrimeAuthRouteShell=ju,Y.PrimeSuiteChatFrame=Uu,Y.RadioGroup=hd,Y.RamChart=yf,Y.RichTextEditor=zd,Y.SearchableSelect=jt,Y.SectionPanel=jd,Y.Sparkline=af,Y.StatusBadge=Ud,Y.StatusSelect=Gd,Y.StepWizard=Qd,Y.TableSkeleton=cn,Y.Tabs=Zd,Y.TagInput=lu,Y.TextInput=xn,Y.Textarea=Do,Y.TextareaField=ru,Y.TimeField=pu,Y.TimePicker=_o,Y.Toggle=gu,Y.UserAvatar=Ko,Y.WaterfallChart=of,Y.YearMultiDateCalendar=gc,Y.buildMentionQueryRegex=mo,Y.clearMentionChipSelection=ur,Y.cn=Tt,Y.configureBonsaifUI=_i,Y.dedupeMentions=yo,Y.defaultValueFormat=ot,Y.describeParentTargetOrigin=Sf,Y.emailFormat=$c,Y.extractMentionUsernames=Fa,Y.filterSelfMentions=Od,Y.findMentionChipAfterCaret=Eo,Y.findMentionChipBeforeCaret=Co,Y.findMentionChipsInSelection=Mo,Y.findMentionTriggerInEditor=Ha,Y.formatBytes=pr,Y.formatPercent=mr,Y.formatRate=tl,Y.getBonsaifUIConfig=zi,Y.getDataTablePreferencesEndpoint=ma,Y.getPlainTextOffset=Pa,Y.highlightMentions=xo,Y.htmlToText=go,Y.insertMentionInEditor=wo,Y.isMentionTriggerBoundary=ho,Y.isPlainOffsetInsideMentionChip=po,Y.isValidEmail=ka,Y.isValidPhone=Na,Y.locateTextOffset=dr,Y.matches=Oc,Y.maxLength=Ac,Y.maxValue=Ic,Y.mentionDisplayLabel=vo,Y.minLength=Lc,Y.minValue=Dc,Y.normalizeUsername=Ba,Y.openImageLightboxFromEvent=Rs,Y.phoneCountryCodeOptions=ao,Y.phoneFormat=Tc,Y.placeCaretAtTextOffset=ko,Y.removeMentionChip=En,Y.required=Mc,Y.resetBonsaifUIConfig=ji,Y.resolveMentions=Id,Y.resolveParentTargetOrigin=Nf,Y.selectMentionChip=So,Y.seriesColor=el,Y.setBonsaifDataTablePreferencesEndpoint=Wi,Y.toneColor=yt,Y.usageColor=Xr,Y.usageTone=Ln,Y.useValidationVisibility=Cf,Y.validateForm=Hc,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})}));
|
|
84
|
+
`;function tb(){if(typeof document>"u"||document.getElementById(ql))return;const e=document.createElement("style");e.id=ql,e.textContent=eb,document.head.appendChild(e)}function Ul(e,r,n){return Math.min(n,Math.max(r,e))}function Jn(e,r,n){const a=Ul(n,0,1);return`color-mix(in srgb, ${e} ${Math.round((1-a)*100)}%, ${r} ${Math.round(a*100)}%)`}function rb(e,r,n,a,s,l){const i=e.map((d,u)=>{const m=Tr(d[n])??0,b=String(d[r]??""),f=a?String(d[a]??"").trim():"",g=s?String(d[s]??"").trim():"";return{name:b,value:m,color:l[u%l.length],...f?{title:f}:{},...g?{description:g}:{}}}).filter(d=>d.value>0&&d.name),c=Math.max(...i.map(d=>d.value),1);return i.map(d=>({...d,pct:d.value/c}))}function nb(e,r){const n=e.length;if(n===0)return[];const a=r.gap*Math.max(0,n-1),s=(r.plotH-a)/n,l=r.maxTopW,i=r.maxTopW*r.taper;return e.map((c,d)=>{const u=n===1?0:d/n,m=n===1?1:(d+1)/n,b=l+(i-l)*u,f=l+(i-l)*m;return{...c,index:d,y:r.topY+d*(s+r.gap),h:s,topW:b,bottomW:f,cx:r.cx}})}function ab({stage:e,hovered:r,onHover:n}){const{cx:a,y:s,h:l,topW:i,bottomW:c,color:d}=e,u=a-i/2,m=a+i/2,b=a-c/2,f=a+c/2,g=s+l,v=Math.max(4,Math.min(14,l*.18)),k=Jn(d,"#000",r?.12:.22),h=Jn(d,"#fff",r?.08:0),C=Jn(d,"#fff",.22),M=[`M ${u} ${s}`,`L ${m} ${s}`,`L ${f} ${g}`,`L ${b} ${g}`,"Z"].join(" ");return t.jsxs("g",{onMouseEnter:()=>n(e.index),onMouseLeave:()=>n(null),style:{cursor:"default"},children:[t.jsx("path",{d:M,fill:k}),t.jsx("path",{d:[`M ${u} ${s}`,`L ${m} ${s}`,`L ${m} ${s+1}`,`L ${f} ${g}`,`L ${a} ${g}`,`L ${u} ${s}`,"Z"].join(" "),fill:h,opacity:.55}),t.jsx("ellipse",{cx:a,cy:s,rx:i/2,ry:v,fill:C,stroke:Jn(d,"#000",.15),strokeWidth:1}),r?t.jsx("ellipse",{cx:a,cy:s,rx:i/2,ry:v,fill:"none",stroke:"var(--text-main)",strokeOpacity:.25,strokeWidth:1.5}):null]})}function ob({data:e,nameKey:r,valueKey:n,titleKey:a,descriptionKey:s,height:l=360,className:i="",loading:c=!1,emptyText:d="Sin datos para mostrar",showTooltip:u=!0,showLabels:m=!0,showValues:b=!0,showBottomArrow:f=!0,taper:g=.42,colors:v=[...an],animationDuration:k=Xt,valueFormat:h=wt,ariaLabel:C="Gráfico embudo"}){const[M,y]=o.useState(null),[x,w]=o.useState(!1),N=o.useMemo(()=>rb(e,r,n,a,s,v),[e,r,n,a,s,v]),A=o.useMemo(()=>N.map($=>`${$.name}:${$.value}`).join("|"),[N]);if(o.useEffect(()=>{if(tb(),typeof window>"u")return;const $=window.matchMedia("(prefers-reduced-motion: reduce)");w($.matches);const oe=()=>w($.matches);return $.addEventListener("change",oe),()=>$.removeEventListener("change",oe)},[]),c)return t.jsx(Nt,{height:l});if(!N.length)return t.jsx(kt,{height:l,text:d});const T=k>0&&!x,U=k,K=Math.min(90,Math.max(40,Math.round(k/8))),Z=Math.round(U*.15),L=N.length*K+Math.round(U*.35),Q=N.some($=>$.title||$.description),z=m?160:24,se=Q?168:24,re=f?36:8,R=z+220+se,V=l,B=18,le=Math.max(120,V-B-re-8),j=z+110,ae=nb(N,{cx:j,topY:B,plotH:le,maxTopW:200,taper:Ul(g,.2,.95),gap:10}),H=M!=null?ae[M]:null,D="cubic-bezier(0.22, 1, 0.36, 1)";return t.jsxs("div",{className:`bonsaif-chart bonsaif-funnel-chart relative w-full ${i}`,role:"img","aria-label":C,style:{height:l},children:[t.jsxs("svg",{viewBox:`0 0 ${R} ${V}`,width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",children:[m?t.jsx("line",{className:T?"bonsaif-funnel-label":void 0,style:T?{animation:`bonsaif-funnel-fade-in ${U}ms ${D} both`}:void 0,x1:z-12,y1:B,x2:z-12,y2:B+le,stroke:"var(--border)",strokeDasharray:"3 5",strokeWidth:1}):null,ae.map($=>{const oe=$.y+$.h/2,G=$.cx-$.topW/2,X=$.index*K,S=T?{animation:`bonsaif-funnel-stage-in ${U}ms ${D} ${X}ms both`}:void 0,O=T?{animation:`bonsaif-funnel-fade-in ${Math.round(U*.85)}ms ${D} ${X+Z}ms both`}:void 0;return t.jsxs("g",{children:[t.jsx("g",{className:"bonsaif-funnel-stage",style:S,children:t.jsx(ab,{stage:$,hovered:M===$.index,onHover:y})}),m?t.jsxs("g",{className:"bonsaif-funnel-label",style:O,children:[t.jsx("line",{x1:24,y1:oe,x2:z-12,y2:oe,stroke:$.color,strokeOpacity:.55,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("line",{x1:z-12,y1:oe,x2:G-6,y2:oe,stroke:$.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("text",{x:20,y:oe-(b?6:0),textAnchor:"end",fill:$.color,fontSize:12,fontWeight:600,children:$.name.length>18?`${$.name.slice(0,16)}…`:$.name}),b?t.jsx("text",{x:20,y:oe+10,textAnchor:"end",fill:"var(--text-muted)",fontSize:11,children:h($.value)}):null]}):null,($.title||$.description)&&Q?t.jsxs("g",{className:"bonsaif-funnel-anno",style:O,children:[t.jsx("line",{x1:$.cx+$.bottomW/2+6,y1:oe,x2:z+220+8,y2:oe,stroke:$.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),$.title?t.jsx("text",{x:z+220+14,y:oe-($.description?6:0),fill:"var(--text-main)",fontSize:12,fontWeight:700,children:$.title.length>22?`${$.title.slice(0,20)}…`:$.title}):null,$.description?t.jsx("text",{x:z+220+14,y:oe+($.title?10:0),fill:"var(--text-muted)",fontSize:11,children:$.description.length>28?`${$.description.slice(0,26)}…`:$.description}):null]}):null]},`${$.name}-${$.index}`)}),f?t.jsx("g",{className:"bonsaif-funnel-arrow",transform:`translate(${j}, ${B+le+8})`,fill:"var(--primary)",style:T?{animation:`bonsaif-funnel-arrow-in ${Math.round(U*.7)}ms ${D} ${L}ms both`}:void 0,children:t.jsx("path",{d:"M0,22 L10,8 L4,8 L4,0 L-4,0 L-4,8 L-10,8 Z"})}):null]},A),u&&H?t.jsxs("div",{className:"pointer-events-none absolute z-10 rounded-md border px-2.5 py-1.5 text-xs shadow-sm",style:{left:"50%",top:8,transform:"translateX(-50%)",background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[t.jsx("span",{className:"font-semibold",style:{color:H.color},children:H.name}),t.jsx("span",{style:{color:"var(--text-muted)"},children:" · "}),h(H.value),t.jsxs("span",{style:{color:"var(--text-muted)"},children:[" ","(",Math.round(H.pct*100),"% del top)"]})]}):null]})}const Ir=135*Math.PI/180,ho=270*Math.PI/180;function sb({value:e,min:r=0,max:n=100,height:a=180,className:s="",loading:l=!1,empty:i=!1,emptyText:c="Sin datos para mostrar",label:d,valueFormat:u=wt,tone:m="primary",color:b,thresholds:f,ariaLabel:g="Gauge",animationDuration:v=700,thickness:k=9,showScale:h=!1}){const C=o.useId().replace(/:/g,""),M=n-r||1,y=Math.min(1,Math.max(0,(e-r)/M)),[x,w]=o.useState(v>0?0:y);if(o.useEffect(()=>{if(l||i)return;if(v<=0){w(y);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){w(y);return}let R=0,V=0;w(j=>(V=j,j));const B=performance.now(),le=j=>{const W=Math.min(1,(j-B)/v),ae=1-(1-W)**3;w(V+(y-V)*ae),W<1&&(R=requestAnimationFrame(le))};return R=requestAnimationFrame(le),()=>cancelAnimationFrame(R)},[y,v,l,i]),l)return t.jsx(Nt,{height:a});if(i)return t.jsx(kt,{height:a,text:c});const N=100,A=108,T=72,U=b??lb(e,n,m,f),K=r+x*M,Z=Vl(N,A,T,Ir,Ir+ho),L=Ir+Math.max(.001,x)*ho,Q=Vl(N,A,T,Ir,L),z=Rn(N,A,T,Ir),se=Rn(N,A,T,Ir+ho);return t.jsx("div",{className:`bonsaif-chart bonsaif-gauge-chart flex flex-col items-center justify-center ${s}`,style:{height:a},children:t.jsxs("svg",{viewBox:"0 0 200 168",width:"100%",height:"100%",role:"img","aria-label":g,className:"overflow-visible",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:`bonsaif-gauge-${C}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[t.jsx("stop",{offset:"0%",stopColor:U,stopOpacity:.82}),t.jsx("stop",{offset:"100%",stopColor:U,stopOpacity:1})]})}),t.jsx("path",{d:Z,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:k,strokeLinecap:"butt"}),t.jsx("path",{d:Q,fill:"none",stroke:`url(#bonsaif-gauge-${C})`,strokeWidth:k,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),t.jsx("text",{x:N,y:A-(d?4:0),textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:28,fontWeight:700,letterSpacing:"-0.04em",className:"bonsaif-chart-gauge-label",children:u(K)}),d?t.jsx("text",{x:N,y:A+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:d}):null,h?t.jsxs(t.Fragment,{children:[t.jsx("text",{x:z.x-2,y:z.y+k+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(r)}),t.jsx("text",{x:se.x+2,y:se.y+k+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(n)})]}):null]})})}function lb(e,r,n,a){if(a!=null&&a.length){const l=[...a].sort((c,d)=>c.value-d.value);let i=l[0].color;for(const c of l)e>=c.value&&(i=c.color);return i}if(n)return Dt(n);const s=e/(r||1);return s>=.8?Dt("success"):s>=.5?Dt("warning"):Dt("danger")}function Rn(e,r,n,a){return{x:e+n*Math.cos(a),y:r+n*Math.sin(a)}}function Vl(e,r,n,a,s){const l=Rn(e,r,n,a),i=Rn(e,r,n,s),c=s-a,d=Math.abs(c)>Math.PI?1:0;return`M ${l.x} ${l.y} A ${n} ${n} 0 ${d} 1 ${i.x} ${i.y}`}function ib({value:e,target:r,max:n,ranges:a,height:s=72,className:l="",loading:i=!1,empty:c=!1,emptyText:d="Sin datos para mostrar",label:u,subtitle:m,valueFormat:b=wt,tone:f="primary",showScale:g=!0,showStatus:v=!0,ariaLabel:k="Bullet chart"}){if(i)return t.jsx(Nt,{height:s});if(c)return t.jsx(kt,{height:s,text:d});const h=n??Math.max(e,r,...(a==null?void 0:a.map(U=>U.value))??[],1)*1.05,M=[...a??[{value:h*.5,color:"color-mix(in srgb, var(--border) 72%, transparent)"},{value:h*.75,color:"color-mix(in srgb, var(--border) 48%, transparent)"},{value:h,color:"color-mix(in srgb, var(--border) 28%, transparent)"}]].sort((U,K)=>U.value-K.value),y=Dt(f),x=Math.min(100,Math.max(0,e/h*100)),w=Math.min(100,Math.max(0,r/h*100)),N=e>=r,A=[0,.25,.5,.75,1].map(U=>U*h),T=t.jsxs("div",{className:"bonsaif-bullet-plot min-w-0 flex-1",children:[t.jsxs("div",{className:"bonsaif-bullet-track relative w-full",style:{height:Math.max(22,u?28:s*.42)},role:"img","aria-label":k,children:[t.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:M.map((U,K)=>{const Z=K===0?0:M[K-1].value,L=Math.max(0,(U.value-Z)/h*100);return t.jsx("div",{style:{width:`${L}%`,background:U.color??`color-mix(in srgb, var(--border) ${70-K*18}%, transparent)`}},K)})}),t.jsx("div",{className:"absolute left-0 top-1/2 w-full",style:{height:"34%",transform:"translateY(-50%)"},children:t.jsx("div",{className:"bonsaif-bullet-value h-full",style:{width:`${x}%`,background:y,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${y} 35%, transparent)`}})}),t.jsx("div",{className:"bonsaif-bullet-target absolute top-1/2 z-[1]",style:{left:`${w}%`,height:"72%",width:3,transform:"translate(-50%, -50%)",background:y,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${b(r)}`})]}),g?t.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:A.map((U,K)=>{const Z=U/h*100,L=K===0,Q=K===A.length-1;return t.jsxs("div",{className:"absolute top-0",style:{left:`${Z}%`,transform:L?"none":Q?"translateX(-100%)":"translateX(-50%)"},children:[t.jsx("div",{className:"mx-auto h-1.5 w-px",style:{background:"color-mix(in srgb, var(--text-muted) 55%, transparent)",marginLeft:L?0:Q?"auto":void 0,marginRight:Q?0:void 0}}),t.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:L?"left":Q?"right":"center"},children:b(U)})]},U)})}):null]});return t.jsx("div",{className:`bonsaif-chart bonsaif-bullet-chart w-full ${l}`,children:u?t.jsxs("div",{className:"bonsaif-bullet-row flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-4",children:[t.jsxs("div",{className:"bonsaif-bullet-label shrink-0 sm:w-[7.5rem] sm:pt-1 sm:text-right",children:[t.jsx("div",{className:"text-sm font-semibold tracking-tight",style:{color:"var(--text-main)"},children:u}),m?t.jsx("div",{className:"mt-0.5 text-[11px] leading-snug",style:{color:"var(--text-muted)"},children:m}):t.jsxs("div",{className:"mt-0.5 text-[11px] tabular-nums leading-snug",style:{color:"var(--text-muted)"},children:[t.jsx("span",{style:{color:y,fontWeight:600},children:b(e)}),t.jsxs("span",{children:[" / meta ",b(r)]})]}),v?t.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:Dt(N?"success":"warning")},children:N?"En meta":"Bajo meta"}):null]}),T]}):T})}function cb({data:e,value:r,timeKey:n="t",usageKey:a="usage",series:s,cores:l,height:i=220,className:c="",loading:d=!1,emptyText:u="Sin datos de CPU",showLegend:m=!1,showTooltip:b=!0,thresholds:f,label:g="CPU",ariaLabel:v="Uso de CPU"}){var w;const k=s??[{key:a,label:"Uso",color:on(r??Lr(e,a)??0,f)}],h=r??Lr(e,a)??Lr(e,((w=k[0])==null?void 0:w.key)??a),C=!d&&(!e.length||h===null);if(d)return t.jsx(Nt,{height:i});if(C)return t.jsx(kt,{height:i,text:u});const M=Math.min(100,Math.max(0,h??0)),y=Yn(M,f),x=on(M,f);return t.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":v,children:[t.jsxs("div",{className:"bonsaif-metric-head",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"bonsaif-metric-kicker",children:[g,l!=null?t.jsxs("span",{className:"ml-1.5 normal-case tracking-normal opacity-80",children:["· ",l," ",l===1?"core":"cores"]}):null]}),t.jsx("div",{className:"bonsaif-metric-value",style:{color:x},children:$r(M,M<10?1:0)})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:x,background:`color-mix(in srgb, ${x} 14%, transparent)`},children:y==="danger"?"Crítico":y==="warning"?"Alto":"Normal"})]}),t.jsx(Qn,{data:e,xKey:n,series:k.map(N=>({...N,color:N.color??x})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:m,showTooltip:b,valueFormat:N=>$r(N,0),ariaLabel:v,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function db({used:e,total:r,cached:n,data:a=[],timeKey:s="t",usageKey:l="usage",height:i=220,className:c="",loading:d=!1,emptyText:u="Sin datos de memoria",showHistory:m=!0,showTooltip:b=!0,thresholds:f,label:g="RAM",ariaLabel:v="Uso de memoria"}){const k=r>0?r:1,h=Math.min(100,Math.max(0,e/k*100)),C=!d&&!(Number.isFinite(e)&&Number.isFinite(r)&&r>0);if(d)return t.jsx(Nt,{height:i});if(C)return t.jsx(kt,{height:i,text:u});const M=Yn(h,f),y=on(h,f),x=Math.max(0,r-e),w=a.length>0?Lr(a,l)??h:h,N=on(w,f),A=m&&a.length>1?Math.max(100,i-110):0;return t.jsxs("div",{className:`bonsaif-chart bonsaif-ram-chart w-full ${c}`,role:"group","aria-label":v,children:[t.jsxs("div",{className:"bonsaif-metric-head",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"bonsaif-metric-kicker",children:g}),t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("span",{className:"bonsaif-metric-value",style:{color:y},children:$r(h,h<10?1:0)}),t.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[Ar(e)," / ",Ar(r)]})]})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:y,background:`color-mix(in srgb, ${y} 14%, transparent)`},children:M==="danger"?"Crítico":M==="warning"?"Alto":"Normal"})]}),t.jsxs("div",{className:"mb-2",children:[t.jsx("div",{className:"h-2 w-full overflow-hidden rounded-sm",style:{background:"color-mix(in srgb, var(--border) 55%, transparent)"},role:"progressbar","aria-valuenow":Math.round(h),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${g} ${$r(h,0)}`,children:t.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${h}%`,background:`linear-gradient(90deg, ${y}, color-mix(in srgb, ${y} 55%, #38bdf8))`}})}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[11px] tabular-nums",style:{color:"var(--text-muted)"},children:[t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Usada"})," ",Ar(e)]}),n!=null&&Number.isFinite(n)?t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",Ar(n)]}):null,t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",Ar(x)]})]})]}),m&&a.length>1?t.jsx(Qn,{data:a,xKey:s,series:[{key:l,label:"Uso",color:N}],height:A,yDomain:[0,100],showLegend:!1,showTooltip:b,valueFormat:T=>$r(T,0),ariaLabel:`${v} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const ub="color-mix(in srgb, var(--primary) 25%, #38bdf8)",fb="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function bb({data:e,timeKey:r="t",inboundKey:n="in",outboundKey:a="out",inbound:s,outbound:l,unit:i="bytes",inboundLabel:c="Entrada",outboundLabel:d="Salida",inboundColor:u=ub,outboundColor:m=fb,height:b=240,className:f="",loading:g=!1,emptyText:v="Sin datos de red",showLegend:k=!1,showTooltip:h=!0,label:C="Network",ariaLabel:M="Tráfico de red"}){const y=s??Lr(e,n)??0,x=l??Lr(e,a)??0,w=!g&&e.length===0;if(g)return t.jsx(Nt,{height:b});if(w)return t.jsx(kt,{height:b,text:v});const N=U=>Bl(U,i),T=Math.max(140,b-76);return t.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${f}`,role:"group","aria-label":M,children:[t.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:t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"bonsaif-metric-kicker",children:C}),t.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-5 sm:max-w-lg",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[t.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:u},"aria-hidden":!0}),c]}),t.jsx("div",{className:"mt-1 truncate text-xl font-bold tabular-nums leading-tight tracking-tight",style:{color:u},title:N(y),children:N(y)})]}),t.jsxs("div",{className:"min-w-0 pl-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[t.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:m},"aria-hidden":!0}),d]}),t.jsx("div",{className:"mt-1 truncate text-lg font-semibold tabular-nums leading-tight tracking-tight opacity-95",style:{color:m},title:N(x),children:N(x)})]})]})]})}),t.jsx("div",{className:"bonsaif-network-plot relative z-0",children:t.jsx(Qn,{data:e,xKey:r,series:[{key:n,label:c,color:u},{key:a,label:d,color:m}],height:T,showLegend:k,showTooltip:h,valueFormat:N,ariaLabel:M,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const Yl=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],Xl=["primeSuiteOrigin","primeSuiteProjectKey"];function mb(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const e=new URLSearchParams(window.location.search);for(const r of Yl){const n=e.get(r);if(n){const a=ea(n);if(a)return a}}if(typeof sessionStorage<"u")for(const r of Xl){const n=sessionStorage.getItem(r);if(n)try{const a=new URL(n);if(a.origin&&a.origin!==window.location.origin)return a.origin}catch{const a=ea(n);if(a)return a}}if(document.referrer){const r=ea(document.referrer);if(r&&r!==window.location.origin)return r}return"*"}catch{return"*"}}function pb(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const e=new URLSearchParams(window.location.search);for(const r of Yl)if(e.get(r))return"query";if(typeof sessionStorage<"u"){for(const r of Xl)if(sessionStorage.getItem(r))return"sessionStorage"}if(document.referrer){const r=ea(document.referrer);if(r&&r!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function ea(e){if(!e)return null;const r=e.trim().replace(/\/+$/,"");if(!r)return null;if(/^https?:\/\/[^/]+$/.test(r))return r;try{return new URL(r).origin}catch{return null}}function hb(e){const[r,n]=o.useState({}),[a,s]=o.useState(!1),l=o.useCallback(u=>a||r[u]?e[u]:void 0,[e,a,r]),i=o.useCallback(u=>{n(m=>({...m,[u]:!0}))},[]),c=o.useCallback(()=>{s(!0)},[]),d=o.useCallback(()=>{n({}),s(!1)},[]);return{submitted:a,touchedFields:r,getFieldError:l,touchField:i,submit:c,reset:d}}Object.defineProperty(Y,"toast",{enumerable:!0,get:()=>Ho.toast}),Y.Alert=Vi,Y.AreaChart=Qn,Y.AuthShell=Al,Y.AutoGrowTextarea=fl,Y.AutoGrowTextareaField=ju,Y.BarChart=Yf,Y.BonsaifButton=Ei,Y.BonsaifUIToaster=zf,Y.BulletChart=ib,Y.Button=Ue,Y.CHART_PALETTE=an,Y.CalendarPicker=Zi,Y.ChartCard=Wf,Y.Checkbox=vn,Y.CodeBlock=tc,Y.ComboChart=Qf,Y.CompactFilterSelect=ac,Y.CompactSearchInput=nc,Y.ConfirmDialog=ic,Y.CopyButton=Ma,Y.CopyLinkButton=fc,Y.CpuChart=cb,Y.DataSheets=Pc,Y.DataTable=ns,Y.DateRangePicker=qc,Y.DonutChart=Kf,Y.Drawer=Jc,Y.DropdownMenu=Zc,Y.DynamicDetailTabs=qi,Y.EmailField=wd,Y.EmptyState=kd,Y.FieldHelperFooter=wr,Y.FieldLabelInfo=xr,Y.FieldLayoutEditor=$d,Y.FileUpload=Md,Y.FormField=$n,Y.FunnelChart=ob,Y.GaugeChart=sb,Y.GlobalScrollbars=Sl,Y.ImageLightbox=ks,Y.ImageLightboxHost=Pd,Y.InputField=ja,Y.LineChart=Vf,Y.LoadingState=jo,Y.MentionTextEditor=cl,Y.MicroserviceFrame=Hf,Y.Modal=Aa,Y.MouseTooltip=nr,Y.MultiDateCalendar=Vc,Y.MultiSelect=zd,Y.NetworkChart=bb,Y.NumberField=Wd,Y.PageHeader=Df,Y.PageSearchInput=Fo,Y.Pagination=qd,Y.PhoneField=Vd,Y.PieChart=Xf,Y.PrimeAuthRouteShell=If,Y.PrimeSuiteChatFrame=Bf,Y.RadioGroup=Yd,Y.RamChart=db,Y.RichTextEditor=Mu,Y.SearchableSelect=ar,Y.SectionPanel=Tu,Y.Sparkline=Zf,Y.StatusBadge=Lu,Y.StatusSelect=Bu,Y.StepWizard=Pu,Y.TableSkeleton=gn,Y.Tabs=Fu,Y.TagInput=Ju,Y.TextInput=Tn,Y.Textarea=bl,Y.TextareaField=Xu,Y.TimeField=sf,Y.TimePicker=xl,Y.Toggle=cf,Y.UserAvatar=$l,Y.WaterfallChart=Jf,Y.YearMultiDateCalendar=Xc,Y.buildMentionQueryRegex=qs,Y.clearMentionChipSelection=Er,Y.cn=jt,Y.configureBonsaifUI=pc,Y.dedupeMentions=Ks,Y.defaultValueFormat=wt,Y.deleteEditorSelection=nl,Y.describeParentTargetOrigin=pb,Y.emailFormat=ad,Y.extractMentionUsernames=ro,Y.filterSelfMentions=xu,Y.findMentionChipAfterCaret=ol,Y.findMentionChipBeforeCaret=al,Y.findMentionChipsInSelection=oo,Y.findMentionTriggerInEditor=eo,Y.formatBytes=Ar,Y.formatPercent=$r,Y.formatRate=Bl,Y.getBonsaifUIConfig=hc,Y.getDataTablePreferencesEndpoint=La,Y.getEditorPlainText=ao,Y.getPlainTextOffset=_n,Y.highlightMentions=Gs,Y.htmlToText=Ys,Y.insertMentionInEditor=Qs,Y.isMentionTriggerBoundary=Vs,Y.isPlainOffsetInsideMentionChip=Us,Y.isValidEmail=_a,Y.isValidPhone=za,Y.locateTextOffset=Cr,Y.matches=dd,Y.maxLength=ld,Y.maxValue=cd,Y.mentionDisplayLabel=Xs,Y.minLength=sd,Y.minValue=id,Y.normalizeUsername=to,Y.openImageLightboxFromEvent=ws,Y.phoneCountryCodeOptions=Es,Y.phoneFormat=od,Y.placeCaretAtTextOffset=Js,Y.removeMentionChip=jn,Y.required=nd,Y.resetBonsaifUIConfig=gc,Y.resolveMentions=yu,Y.resolveParentTargetOrigin=mb,Y.selectAllEditorContents=tl,Y.selectMentionChip=el,Y.selectionIncludesNonChipText=rl,Y.seriesColor=Hl,Y.setBonsaifDataTablePreferencesEndpoint=vc,Y.syncMentionChipSelectionHighlight=Wn,Y.toneColor=Dt,Y.usageColor=on,Y.usageTone=Yn,Y.useValidationVisibility=hb,Y.validateForm=ud,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})}));
|