bonsaif-ui 0.1.150 → 0.1.158

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
- (function(I,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):(I=typeof globalThis<"u"?globalThis:I||self,s(I.BonsaifUI={},I.React,I.jsxRuntime,I.ReactIconsHi2,I.ReactDOM,I.Recharts,I.OverlayScrollbarsGlobal,I.Sonner,I.OverlayScrollbarsReact,I.ReactDayPicker,I.ReactDayPickerStyles,I.ReactIconsFi))})(this,(function(I,s,t,W,mt,Te,Ba,Ia,os,Fa,em,dc){"use strict";"use client";function Rt(...e){return e.filter(Boolean).join(" ")}function uc({variant:e="primary",className:r,type:n="button",children:a,...o}){return t.jsx("button",{className:Rt("bonsaif-ui-button",`bonsaif-ui-button--${e}`,r),type:n,...o,children:a})}function ss({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),[h,b]=s.useState(!1),f=l||h||e.trim().length>0,p=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",v=a||"w-48 max-w-full sm:w-64 lg:w-72";s.useEffect(()=>{var g;o&&((g=u.current)==null||g.focus())},[o]);const w=()=>{var g;b(!0),(g=u.current)==null||g.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:g=>{f||(g.preventDefault(),w())},children:[t.jsx(W.HiMagnifyingGlass,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none transition-colors duration-200",style:{color:"var(--text-muted)",left:"var(--page-header-control-icon-left, 12px)"}}),t.jsx("input",{ref:u,type:"text",tabIndex:d,"aria-label":n,value:e,onChange:g=>r(g.target.value),onKeyDown:g=>{g.key==="Escape"&&(i==null||i())},placeholder:f?n:"Buscar",className:`${p} 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:g=>{b(!0),g.currentTarget.style.borderColor="var(--primary)",g.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:g=>{b(!1),g.currentTarget.style.borderColor="var(--border)",g.currentTarget.style.boxShadow="none"}}),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(W.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const ls=s.createContext({});let is=0;const cs="bonsaif-ui:hide-tooltips";function Cn(e=700){is=Date.now()+e}function fc(){return Date.now()>is}function En(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 bc(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 _t({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:h,as:b="div"}){const f=s.useRef(null),p=s.useRef(null),v=s.useRef(null),w=s.useRef(!1),[g,A]=s.useState(null),[C,T]=s.useState("");s.useEffect(()=>{const D=f.current;D&&(D.querySelectorAll("[title]").forEach(K=>{const j=K.getAttribute("title");j&&(K.getAttribute("aria-label")||K.setAttribute("aria-label",j),K.removeAttribute("title"))}),D.querySelectorAll("svg title").forEach(K=>K.remove()))}),s.useLayoutEffect(()=>{if(!g)return;const D=p.current;if(!D)return;const K=12,j=14,le=D.getBoundingClientRect(),Q=window.innerWidth-le.width-K,fe=window.innerHeight-le.height-K;let F=g.mouseX+j,V=g.mouseY+j,ae,$;if(!o&&f.current){const P=f.current.getBoundingClientRect(),ce=P.left+P.width/2,O=P.top+P.height/2;l==="top"?(F=ce-le.width/2,V=P.top-le.height-j,$=le.height-1):l==="left"?(F=P.left-le.width-j,V=O-le.height/2,ae=le.width-1):l==="right"?(F=P.right+j,V=O-le.height/2,ae=-7):(F=ce-le.width/2,V=P.bottom+j,$=-7)}if(o&&(F>Q&&(F=g.mouseX-le.width-j),V>fe&&(V=g.mouseY-le.height-j)),F=Math.min(Math.max(K,F),Math.max(K,Q)),V=Math.min(Math.max(K,V),Math.max(K,fe)),!o&&f.current){const P=f.current.getBoundingClientRect(),ce=P.left+P.width/2,O=P.top+P.height/2;l==="top"||l==="bottom"?ae=Math.min(Math.max(14,ce-F),le.width-14):$=Math.min(Math.max(14,O-V),le.height-14)}(Math.abs(F-g.x)>.5||Math.abs(V-g.y)>.5||ae!==g.arrowX||$!==g.arrowY)&&A(P=>P&&{...P,x:F,y:V,arrowX:ae,arrowY:$})},[o,l,g]);const H=()=>{v.current&&(window.clearTimeout(v.current),v.current=null)},E=(D,K)=>{if(!fc()||w.current)return;const j=f.current;if(j&&!En(j)){if(n){const le=bc(j);if(!le)return;T(le)}!n&&!r||A({mouseX:D,mouseY:K,x:D+14,y:K+14})}},x=()=>{const D=f.current;if(!D)return;const K=D.getBoundingClientRect();E(K.left+K.width/2,K.bottom)},M=()=>{H(),A(null)},k=()=>{if(!a){M();return}H(),v.current=window.setTimeout(()=>A(null),120)},_=()=>{Cn(),w.current=!0,M()},q=()=>{w.current=!1};s.useEffect(()=>{if(!g)return;if(En(f.current)){A(null);return}const D=()=>A(null),K=()=>{Cn(),w.current=!0,A(null)};document.addEventListener("pointerdown",K,!0),document.addEventListener("click",K,!0),document.addEventListener("scroll",D,!0),window.addEventListener("blur",D),document.addEventListener("visibilitychange",D),document.addEventListener("keydown",D,!0);const j=new MutationObserver(()=>{En(f.current)&&A(null)});return j.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",K,!0),document.removeEventListener("click",K,!0),document.removeEventListener("scroll",D,!0),window.removeEventListener("blur",D),document.removeEventListener("visibilitychange",D),document.removeEventListener("keydown",D,!0),j.disconnect()}},[g]),s.useEffect(()=>{const D=()=>Cn(),K=()=>{Cn(),w.current=!0,A(null)};return document.addEventListener("pointerdown",D,!0),document.addEventListener("click",D,!0),document.addEventListener("keydown",D,!0),window.addEventListener(cs,K),()=>{document.removeEventListener("pointerdown",D,!0),document.removeEventListener("click",D,!0),document.removeEventListener("keydown",D,!0),window.removeEventListener(cs,K)}},[]);const X=n?C:r;return t.jsxs(t.Fragment,{children:[t.jsx(b,{ref:D=>{f.current=D},className:c,style:u,onMouseEnter:D=>{H(),q(),o?E(D.clientX,D.clientY):x()},onMouseMove:D=>{g&&o&&E(D.clientX,D.clientY)},onMouseDown:_,onClick:_,onMouseLeave:()=>{q(),k()},onFocus:x,onBlur:M,children:e}),g&&X&&!En(f.current)?mt.createPortal(t.jsxs("div",{ref:p,role:"tooltip",className:d,onMouseEnter:a?H:void 0,onMouseLeave:a?k:void 0,style:{position:"fixed",top:g.y,left:g.x,zIndex:9999,background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:6,padding:"5px 10px",fontSize:12,color:"var(--text-main)",boxShadow:"0 4px 16px rgba(0,0,0,0.35)",pointerEvents:a?"auto":"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere",...h},children:[i&&t.jsx("span",{"aria-hidden":"true",style:{position:"absolute",width:12,height:12,background:(h==null?void 0:h.background)??"var(--bg-card)",borderLeft:l==="right"?(h==null?void 0:h.border)??"1px solid var(--border)":void 0,borderTop:l==="bottom"||l==="right"?(h==null?void 0:h.border)??"1px solid var(--border)":void 0,borderRight:l==="left"?(h==null?void 0:h.border)??"1px solid var(--border)":void 0,borderBottom:l==="top"||l==="left"?(h==null?void 0:h.border)??"1px solid var(--border)":void 0,transform:"rotate(45deg)",left:g.arrowX===void 0?void 0:g.arrowX-6,top:g.arrowY===void 0?void 0:g.arrowY-6,zIndex:-1}}),X]}),document.body):null]})}function ds(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}const hc="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",mc={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"},pc="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",gc={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"},vc={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},yc={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function _a(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(_a).join(" ").trim():s.isValidElement(e)?_a(e.props.children):""}function xc(e){return s.Children.toArray(e).find(s.isValidElement)??null}function Ke({variant:e="primary",size:r="md",loading:n=!1,icon:a,tooltip:o,iconOnly:l,height:i,padding:c,children:d,className:u="",disabled:h,style:b,...f}){const p=s.useContext(ls),v=l??p.iconOnly??e==="icon",w=p.compact??!1,g=p.headerAction??!1,A=g&&r==="md"?"sm":w&&!g&&r==="md"?"xs":r,C=e==="icon"||v,T=g&&C,H=_a(d),E=o??f.title??f["aria-label"]??(v?H:void 0),x=E?void 0:f.title,M=f["aria-label"]??(typeof E=="string"?E:H||void 0),k=n?null:a??(v?xc(d):null),_=t.jsxs("button",{...f,title:x,"aria-label":M,"data-variant":e,"data-size":A,"data-icon":C?"true":void 0,disabled:h||n,className:`${hc} ${T?pc:mc[e]} ${C?vc[A]:gc[A]} ${w&&!C?"px-2.5":""} ${u}`,style:{...yc[e],height:ds(i),padding:ds(c),...b,...g&&!C?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...T?{width:"var(--page-header-control-height, 40px)",height:"var(--page-header-control-height, 40px)",padding:0,background:"var(--bg-card)",borderRadius:"8px"}:null},children:[n?t.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):k,!v&&d]});return E?t.jsx(_t,{as:"span",content:E,className:"inline-flex shrink-0",children:_}):_}const pt={background:"color-mix(in srgb, var(--text-muted) 26%, var(--bg-input))"};function Mn({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:pt}),t.jsx("div",{className:"h-7 max-w-md flex-1 animate-pulse rounded-md",style:pt})]}),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:pt}),t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:pt})]})]}),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((h,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:{...pt,width:`${48+b*17%40}%`}})},`h-${b}`)),Array.from({length:c}).map((h,b)=>Array.from({length:i}).map((f,p)=>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:{...pt,width:`${46+(b*13+p*11)%42}%`,minWidth:28}})},`c-${b}-${p}`)))]})}),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:pt}),t.jsx("div",{className:"h-7 w-14 animate-pulse rounded-md",style:pt})]}),t.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:4}).map((h,b)=>t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:pt},b))}),t.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:pt})]})]})}function wc({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 Nc({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 us({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(Mn,{rows:i,columns:c,className:u});if(e==="sections")return t.jsx(kc,{rows:i});if(e==="cards")return t.jsx(Sc,{rows:i});const h=o||(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(Nc,{logoSrc:a,logoAlt:h}):null,t.jsx(wc,{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 kc({rows:e}){return t.jsx(Mn,{rows:e,columns:7})}function Sc({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:pt}),t.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded-md",style:pt}),t.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded-md",style:pt})]},n))})}function fs(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 bs(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function Cc(e){return[e.label,fs(e.service),e.description,e.service].filter(Boolean).join(" ")}function Ec(e){return typeof e=="function"?e:e.default}function Mc(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(Ke,{className:"mt-4",height:36,padding:"0 14px",onClick:r,children:"Reintentar"})]})})}function Tc({parentPanel:e,parentPanelComponent:r,renderParentPanel:n,parent:a,context:o,links:l,moduleRegistry:i,loadModule:c,activeService:d,initialService:u,onActiveServiceChange:h,canAccess:b,keepAlive:f=!0,title:p,subtitle:v,emptyState:w,loadingState:g,errorState:A=Mc,renderTabLabel:C,searchableTabs:T="auto",tabsSearchThreshold:H=6,tabsSearchPlaceholder:E="Buscar modulo...",tabsSearchValue:x,onTabsSearchChange:M,emptySearchState:k,showTabCount:_=!0,className:q="",parentClassName:X="",contentClassName:D="",tabsClassName:K=""}){var Ee;const j=s.useMemo(()=>l.filter(ne=>!ne.hidden&&((b==null?void 0:b(ne,o))??!0)),[b,o,l]),le=(Ee=j.find(ne=>!ne.disabled))==null?void 0:Ee.service,[Q,fe]=s.useState(u??le??""),[F,V]=s.useState({}),[ae,$]=s.useState({}),[P,ce]=s.useState(""),[O,oe]=s.useState(!1),G=s.useRef(ae),U=s.useRef(0),se=x??P,S=bs(se),R=T===!0||T==="auto"&&j.length>=H,ee=R&&se.trim().length>0,J=s.useMemo(()=>S?j.filter(ne=>bs(Cc(ne)).includes(S)):j,[S,j]),y=d??Q,N=j.find(ne=>ne.service===y)??j.find(ne=>!ne.disabled);s.useEffect(()=>{!N&&le&&fe(le)},[le,N]),s.useEffect(()=>{G.current=ae},[ae]);const te=ne=>{ne.disabled||(d||fe(ne.service),h==null||h(ne.service,ne))},ue=ne=>{x===void 0&&ce(ne),M==null||M(ne)},re=(ne,De)=>{const Be=J.filter(je=>!je.disabled),Ue=Be.findIndex(je=>je.service===De.service);Ue<0||((ne.key==="ArrowRight"||ne.key==="ArrowDown")&&(ne.preventDefault(),te(Be[(Ue+1)%Be.length])),(ne.key==="ArrowLeft"||ne.key==="ArrowUp")&&(ne.preventDefault(),te(Be[(Ue-1+Be.length)%Be.length])),ne.key==="Home"&&(ne.preventDefault(),te(Be[0])),ne.key==="End"&&(ne.preventDefault(),te(Be[Be.length-1])))},ge=s.useCallback(()=>{if(!N)return;const ne=N.service,De=G.current[ne];if(De!=null&&De.loading||De!=null&&De.component&&f)return;const Be=(i==null?void 0:i[ne])??c;if(!Be){$(je=>({...je,[ne]:{loading:!1,error:new Error(`No module loader found for service "${ne}".`)}}));return}const Ue=++U.current;$(je=>({...je,[ne]:{...je[ne],loading:!0,error:void 0}})),Be(N,o).then(je=>{if(Ue!==U.current&&!f)return;const Fe=Ec(je);$(Qe=>({...Qe,[ne]:{component:Fe,loading:!1}}))}).catch(je=>{const Fe=je instanceof Error?je:new Error(String(je));$(Qe=>({...Qe,[ne]:{...Qe[ne],loading:!1,error:Fe}}))})},[o,f,c,i,N]);s.useEffect(ge,[ge]);const Se=N?F[N.service]??null:null,$e=N?ae[N.service]:void 0,ht=$e==null?void 0:$e.component,Ct=ne=>{N&&V(De=>({...De,[N.service]:ne}))},rt=()=>{N&&V(ne=>({...ne,[N.service]:null}))},at={context:o,parent:a,links:l,visibleLinks:j,filteredLinks:J,selectedLink:N,selectedService:N==null?void 0:N.service,activeItemId:Se,tabsSearch:se,onSelectService:te,onOpenDetail:Ct,onBackToList:rt},de=n?n(at):r?t.jsx(r,{...at}):e;return t.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${q}`,children:[t.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${X}`,children:de}),t.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${D}`,children:[(p||v||R||_)&&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:[p&&t.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:p}),v&&t.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:v})]}),(R||_)&&t.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[_&&t.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[J.length," / ",j.length]}),R&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${O?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!O,children:t.jsx(ss,{value:se,onChange:ue,placeholder:E,className:"w-full",autoFocus:O,forceExpanded:!0,onEscape:()=>oe(!1),size:"sm",inputTabIndex:O?0:-1})}),t.jsx("button",{type:"button","aria-label":O?"Cerrar busqueda":"Buscar tabs","aria-expanded":O,onClick:()=>{O&&se&&ue(""),oe(ne=>!ne)},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 ${O||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:O||ee?t.jsx(W.HiXMark,{className:"h-4 w-4"}):t.jsx(W.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),t.jsx("div",{role:"tablist","aria-label":p??"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 ${K}`,children:J.length>0?J.map(ne=>{const De=ne.service===(N==null?void 0:N.service);return t.jsx("button",{type:"button",role:"tab","aria-selected":De,disabled:ne.disabled,onClick:()=>te(ne),onKeyDown:Be=>re(Be,ne),className:`inline-flex h-9 min-w-max items-center gap-2 rounded-md border px-3 text-xs font-semibold transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-50 ${De?"border-[var(--primary)] bg-[var(--bg-card)] text-[var(--text-main)] shadow-sm":"border-transparent text-[var(--text-muted)] hover:bg-[var(--bg-card)] hover:text-[var(--text-main)]"}`,children:C?C(ne,De):t.jsxs(t.Fragment,{children:[ne.icon,t.jsx("span",{children:ne.label??fs(ne.service)}),ne.badge&&t.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:ne.badge})]})},ne.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:k??"No hay modulos que coincidan con la busqueda."})}),(N==null?void 0:N.description)&&t.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:N.description}),t.jsxs("div",{className:"min-h-[420px] p-4",children:[!N&&(w??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."})),N&&($e==null?void 0:$e.loading)&&(g??t.jsx(us,{title:"Cargando modulo..."})),N&&($e==null?void 0:$e.error)&&A($e.error,ge),N&&ht&&!($e!=null&&$e.loading)&&!($e!=null&&$e.error)&&t.jsx(ht,{context:o,parent:a,link:N,activeItemId:Se,onOpenDetail:Ct,onBackToList:rt})]})]})]})}const $c={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:t.jsx(W.HiInformationCircle,{className:"h-5 w-5"})},success:{color:"#047857",background:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.24)",icon:t.jsx(W.HiCheckCircle,{className:"h-5 w-5"})},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)",icon:t.jsx(W.HiExclamationTriangle,{className:"h-5 w-5"})},danger:{color:"var(--danger)",background:"var(--danger-bg)",border:"color-mix(in srgb, var(--danger) 20%, var(--border))",icon:t.jsx(W.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:t.jsx(W.HiInformationCircle,{className:"h-5 w-5"})}};function Ac({variant:e="info",title:r,children:n,icon:a,action:o,onDismiss:l,className:i=""}){const c=$c[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(Ke,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:t.jsx(W.HiXMark,{className:"h-4 w-4"})})]})}const hs=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],Lc=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],Dc=["lu","ma","mi","ju","vi","sá","do"],ms=6;function Pa(e,r,n){return`${e}-${String(r).padStart(2,"0")}-${String(n).padStart(2,"0")}`}function Oc(){const e=new Date;return Pa(e.getFullYear(),e.getMonth()+1,e.getDate())}function za(e){const[r,n,a]=e.split("-").map(Number);return{year:r,month:n,day:a}}function Hc(e){if(!e)return"Seleccionar fecha";const{year:r,month:n,day:a}=za(e);return!r||!n||!a?"Seleccionar fecha":`${String(a).padStart(2,"0")} ${hs[n-1]} ${r}`}function ps(e){const{year:r,month:n,day:a}=za(e);if(!r||!n||!a)return!1;const o=new Date(r,n-1,a).getDay();return o===0||o===6}function Bc({value:e,onChange:r,minDate:n,disableWeekends:a=!1,displayMode:o="inline",className:l=""}){const i=Oc(),d=za(e||i),u=o==="popover",[h,b]=s.useState(!1),f=s.useRef(null),[p,v]=s.useState({horizontal:"left",vertical:"bottom"}),[w,g]=s.useState(d.year),[A,C]=s.useState(d.month),[T,H]=s.useState("days"),E=16,[x,M]=s.useState(0),k=w-7+x,_=Array.from({length:E},(F,V)=>k+V);s.useEffect(()=>{if(!u||!h||!f.current)return;const F=f.current.getBoundingClientRect(),V=8,ae=280,$=340,P=F.left+ae>window.innerWidth-V,ce=F.right-ae>=V,O=F.bottom+8+$>window.innerHeight-V,oe=F.top-8-$>=V;v({horizontal:P&&ce?"right":"left",vertical:O&&oe?"top":"bottom"})},[u,h]),s.useEffect(()=>{if(!u||!h)return;function F(ae){f.current&&(f.current.contains(ae.target)||b(!1))}function V(ae){ae.key==="Escape"&&b(!1)}return document.addEventListener("mousedown",F),document.addEventListener("keydown",V),()=>{document.removeEventListener("mousedown",F),document.removeEventListener("keydown",V)}},[u,h]);function q(){A===1?(g(F=>F-1),C(12)):C(F=>F-1)}function X(){A===12?(g(F=>F+1),C(1)):C(F=>F+1)}const D=(new Date(w,A-1,1).getDay()+6)%7,K=new Date(w,A,0).getDate(),j=[...Array(D).fill(null),...Array.from({length:K},(F,V)=>V+1)];for(;j.length<ms*7;)j.push(null);const le=j.slice(0,ms*7);function Q(F){const V=Pa(w,A,F);n&&V<n||a&&ps(V)||(r(V),u&&b(!1))}const fe=t.jsx("div",{className:`bonsaif-calendar bonsaif-calendar-picker ${l}`.trim(),children:t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsx("div",{className:"bonsaif-cal-toolbar",children:T==="days"?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:q,"aria-label":"Mes anterior",children:t.jsx(W.HiChevronLeft,{size:16})}),t.jsxs("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>{H("years"),M(0)},children:[t.jsxs("span",{className:"bonsaif-cal-title",children:[hs[A-1]," ",w]}),t.jsx(W.HiChevronDown,{size:13})]}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:X,"aria-label":"Mes siguiente",children:t.jsx(W.HiChevronRight,{size:16})})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>M(F=>F-E),"aria-label":"Años anteriores",children:t.jsx(W.HiChevronLeft,{size:16})}),t.jsx("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>H("days"),children:t.jsxs("span",{className:"bonsaif-cal-title",children:[_[0]," – ",_[_.length-1]]})}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>M(F=>F+E),"aria-label":"Años siguientes",children:t.jsx(W.HiChevronRight,{size:16})})]})}),T==="years"?t.jsxs("div",{className:"bonsaif-cal-picker-years",children:[t.jsx("div",{className:"bonsaif-cal-picker-months",children:Lc.map((F,V)=>{const ae=V+1===A;return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${ae?" is-active":""}`,onClick:()=>C(V+1),children:F},F)})}),t.jsx("div",{className:"bonsaif-cal-picker-year-grid",children:_.map(F=>{const V=F===w,ae=F===new Date().getFullYear();return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${V?" is-active":""}${ae&&!V?" is-today":""}`,onClick:()=>{g(F),H("days")},children:F},F)})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bonsaif-multi-weekdays bonsaif-cal-picker-weekdays",children:Dc.map(F=>t.jsx("div",{className:"bonsaif-multi-weekday",children:F},F))}),t.jsx("div",{className:"bonsaif-cal-picker-days",children:le.map((F,V)=>{if(F===null)return t.jsx("div",{className:"bonsaif-multi-day bonsaif-multi-day-hidden"},V);const ae=Pa(w,A,F),$=ae===e,P=ae===i,ce=!!(n&&ae<n)||a&&ps(ae);return t.jsx("div",{className:`bonsaif-multi-day${$?" bonsaif-multi-day-selected":""}${P?" bonsaif-multi-day-today":""}${ce?" bonsaif-multi-day-disabled":""}`,children:t.jsx("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:ce,"aria-pressed":$,onClick:()=>!ce&&Q(F),children:F})},V)})})]})]})});return u?t.jsxs("div",{ref:f,className:`relative w-full ${l}`.trim(),children:[t.jsxs("button",{type:"button",onClick:()=>b(F=>!F),className:"bonsaif-cal-trigger","data-open":h?"true":"false",children:[t.jsxs("span",{className:"inline-flex items-center gap-2 min-w-0",children:[t.jsx(W.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:Hc(e)})]}),t.jsx(W.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${h?"rotate-180":""}`})]}),h&&t.jsx("div",{className:"absolute z-50",style:{...p.horizontal==="left"?{left:0}:{right:0},...p.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:fe})]}):fe}function Yt({children:e,className:r="",style:n,as:a="span",followCursor:o=!1,placement:l="top"}){return t.jsx(_t,{onlyWhenOverflow:!0,as:a,followCursor:o,placement:l,showArrow:!o,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,...n},children:e})}function Wa(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function ja(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Ic(e,r){if(!r.trim())return!0;const n=ja(r);return ja(e.label).includes(n)||!!(e.sublabel&&ja(e.sublabel).includes(n))}function fr({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:h="",style:b,dropdownMinWidth:f,dropdownZIndex:p=9999,height:v=40,padding:w="0 10px",searchable:g=!0,minOptionsForSearch:A=6}){const[C,T]=s.useState(!1),[H,E]=s.useState(""),[x,M]=s.useState(-1),[k,_]=s.useState(!1),[q,X]=s.useState({}),D=s.useRef(null),K=s.useRef(null),j=s.useRef(null),le=s.useRef(null),Q=g&&n.length>=A,fe=n.find(S=>S.value===e)??null,F=l==="ghost",V=a==="error"?"var(--danger)":C?"var(--primary)":"var(--border)",ae=Q&&H.trim()?n.filter(S=>Ic(S,H)):n,$=s.useCallback(()=>{const S=D.current;if(!S)return;const R=S.getBoundingClientRect(),ee=Q?272:212,J=window.innerHeight-R.bottom,y=J<ee&&R.top>J;X({position:"fixed",left:R.left,top:y?void 0:R.bottom+4,bottom:y?window.innerHeight-R.top+4:void 0,width:R.width,minWidth:Wa(f),zIndex:p})},[f,p,Q]);s.useEffect(()=>_(!0),[]),s.useEffect(()=>{if(!C)return;function S(R){var J,y;const ee=R.target;!((J=D.current)!=null&&J.contains(ee))&&!((y=K.current)!=null&&y.contains(ee))&&(T(!1),E(""))}return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[C]),s.useEffect(()=>{C&&(M(-1),$(),Q&&setTimeout(()=>{var S;return(S=j.current)==null?void 0:S.focus()},0))},[C,Q,$]),s.useEffect(()=>{if(C)return window.addEventListener("resize",$),window.addEventListener("scroll",$,!0),()=>{window.removeEventListener("resize",$),window.removeEventListener("scroll",$,!0)}},[C,$]),s.useEffect(()=>{if(x<0||!le.current)return;const S=le.current.children[x];S==null||S.scrollIntoView({block:"nearest"})},[x]);const P=s.useCallback(S=>{r(S),T(!1),E("")},[r]),ce=s.useRef(C);ce.current=C;const O=s.useRef(ae);O.current=ae;const oe=s.useRef(x);oe.current=x;const G=s.useRef(d);G.current=d;const U=s.useRef(P);U.current=P,s.useEffect(()=>{function S(R){var N,te;const ee=document.activeElement,J=((N=D.current)==null?void 0:N.contains(ee))??!1,y=((te=K.current)==null?void 0:te.contains(ee))??!1;if(!(!J&&!y)){if(!ce.current){(R.key==="Enter"||R.key===" "||R.key==="ArrowDown")&&(R.preventDefault(),T(!0));return}switch(R.key){case"ArrowDown":R.preventDefault(),M(ue=>Math.min(ue+1,O.current.length-1));break;case"ArrowUp":R.preventDefault(),M(ue=>Math.max(ue-1,G.current?-1:0));break;case"Enter":{R.preventDefault();const ue=oe.current,re=O.current;ue===-1&&G.current?U.current(""):re[ue]&&!re[ue].disabled&&U.current(re[ue].value);break}case"Escape":R.preventDefault(),R.stopPropagation(),T(!1),E("");break}}}return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[]);const se=t.jsxs("div",{ref:K,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...q,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[Q&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(W.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:j,value:H,onChange:S=>{E(S.target.value),M(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),H&&t.jsx("button",{type:"button",onMouseDown:S=>{S.preventDefault(),E("")},children:t.jsx(W.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),t.jsxs("ul",{ref:le,role:"listbox",className:"overflow-y-auto",style:{maxHeight:Q?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[d&&t.jsx("li",{role:"option","aria-selected":e==="",onMouseDown:S=>{S.preventDefault(),P("")},onMouseEnter:()=>M(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:x===-1&&!H.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:d}),ae.map((S,R)=>{const J=R===x,y=S.value===e;return t.jsxs("li",{role:"option","aria-selected":y,onMouseDown:N=>{N.preventDefault(),S.disabled||P(S.value)},onMouseEnter:()=>!S.disabled&&M(R),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:J?"var(--bg-hover)":y?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:S.disabled?"var(--text-muted)":"var(--text-main)",cursor:S.disabled?"not-allowed":"pointer",boxShadow:y?"inset 2px 0 0 var(--primary)":void 0},children:[S.color&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:S.color}}),t.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(Yt,{className:"min-w-0 flex-1",children:S.label}),S.sublabel&&t.jsx(Yt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:S.sublabel})]}),S.badge&&t.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:S.badge})]},S.value)}),ae.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:D,className:`relative ${h||"w-full"}`,style:b,children:[t.jsxs("button",{type:"button",disabled:u,onClick:()=>!u&&T(S=>!S),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:Wa(v),padding:Wa(w),background:F?"transparent":"var(--bg-input)",color:fe?"var(--text-main)":"var(--text-muted)",border:F?"1px solid transparent":`1px solid ${V}`,opacity:u?.5:1,cursor:u?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":C,"aria-label":o,children:[(fe==null?void 0:fe.color)&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:fe.color}}),t.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:fe?t.jsxs(t.Fragment,{children:[t.jsx(Yt,{className:"min-w-0 flex-1",children:fe.label}),i&&fe.sublabel&&t.jsx(Yt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:fe.sublabel})]}):t.jsx(Yt,{className:"min-w-0 flex-1",children:c})}),fe&&d?t.jsx("span",{role:"button",tabIndex:-1,onMouseDown:S=>{S.preventDefault(),S.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(W.HiXMark,{className:"w-3 h-3"})}):t.jsx(W.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:C?"rotate(180deg)":"rotate(0deg)"}})]}),C&&k&&mt.createPortal(se,document.body)]})}const Fc={sm:"h-4 w-4",md:"h-5 w-5"};function _c(e,r){if(typeof e=="function"){e(r);return}e&&(e.current=r)}const Tn=s.forwardRef(function({label:r,description:n,error:a,size:o="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:d,...u},h){const b=s.useRef(null);return s.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,_c(h,f)},type:"checkbox",disabled:d,"aria-checked":l?"mixed":u["aria-checked"],"aria-invalid":!!a||u["aria-invalid"],className:`peer ${Fc[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(W.HiCheck,{className:"pointer-events-none absolute left-1/2 top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 scale-75 text-[var(--primary-fg)] opacity-0 transition peer-checked:scale-100 peer-checked:opacity-100 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})]})]})}),gs=32767;function $n(e){let r=String(e??"");return r=r.split("\0").join(""),r.length<=gs?r:`${r.slice(0,gs-1)}…`}const An=[25,50,100,200,500];let Lt={dataTable:{pageSizeOptions:[...An]}};function Pc(){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 qa(){const e=Lt.dataTable.preferencesEndpoint,r=Pc();return e&&e.trim().length>0?e.trim().replace(/\/+$/,""):r}function zc(e){if(!Array.isArray(e))return[...An];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:[...An]}function vs(e){if(typeof e!="string")return;const r=e.trim();if(r)return r.replace(/\/+$/,"")}function Wc(e){if(!e||typeof e!="object"||!e.dataTable)return;const r=vs(e.dataTable.preferencesEndpoint);Lt={...Lt,dataTable:{...Lt.dataTable,pageSizeOptions:zc(e.dataTable.pageSizeOptions),preferencesEndpoint:r??Lt.dataTable.preferencesEndpoint}}}function jc(){return{dataTable:{pageSizeOptions:[...Lt.dataTable.pageSizeOptions]}}}function Jr(){return[...Lt.dataTable.pageSizeOptions]}function qc(){Lt={dataTable:{pageSizeOptions:[...An]}}}function Uc(e){Lt={...Lt,dataTable:{...Lt.dataTable,preferencesEndpoint:vs(e)}}}const Ln=[{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"}],Vc=Ln.map(e=>({value:e.value,label:e.label})),Xc=12,Yc={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},ys={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},Kc="bonsaif-ui:datatable:",Gc="[&_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",Zc=[],Qc=52;function Kt(e){if(!e)return 150;const r=parseInt(e,10);return isNaN(r)||r<=0?150:r}function xs(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 ws(e){return`${Kc}${e}`}function Dn(e){try{const r=window.localStorage.getItem(ws(e));if(!r)return null;const n=JSON.parse(r);return n&&typeof n=="object"?n:null}catch{return null}}function Jc(e,r){try{window.localStorage.setItem(ws(e),JSON.stringify(r))}catch{}}function Rc(e,r){if(e===!0)return{...ys};if(e===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(r&&e==null)return{...ys};const n={...Yc,...e??{}};return r&&(typeof e!="object"||e.pagination!==!1)&&(n.pagination=!0),n}function Ns(...e){return e.reduce((r,n)=>({...r,...n??{}}),{})}function Ua(e,r,n){return typeof e!="number"||e<=0?n:nn(r).includes(e)?e:n}function Rr(e){if(!e||typeof e!="object")return!1;const r=e;return typeof r.key=="string"&&(r.dir==="asc"||r.dir==="desc")}function en(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 tn(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=new Set(Ln.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 yt(e,r){if(br(e))return Qc;const n=e.minWidth??80,a=e.maxWidth??1/0;return Math.min(a,Math.max(n,r))}function ed(e){const r=window.getComputedStyle(e);return parseFloat(r.paddingLeft)+parseFloat(r.paddingRight)}function br(e){return e.key==="actions"||e.key==="acciones"?!0:typeof e.header=="string"&&e.header.trim().toLowerCase()==="acciones"}function Va(e){return e.sticky===!0}function ks(e){return!(e.reorderable===!1||e.sticky&&e.reorderable!==!0)}function On(e,r){const a=[...e.filter(o=>r.includes(o))];for(let o=0;o<r.length;o+=1){const l=r[o];if(a.includes(l))continue;let i=a.length;for(let c=o-1;c>=0;c-=1){const d=r[c],u=a.indexOf(d);if(u!==-1){i=u+1;break}}if(i===a.length)for(let c=o+1;c<r.length;c+=1){const d=r[c],u=a.indexOf(d);if(u!==-1){i=u;break}}a.splice(i,0,l)}return a}function er(e,r){const n=r.filter(Va).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 td(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 tr(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 rd(e){return e==null||e===""?"(Vacio)":e instanceof Date?e.toLocaleDateString():String(e)}function Cr(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Cr).join(" ").trim():s.isValidElement(e)?Cr(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?rd(n):Cr(n).trim()}function rn(e){const r=e.replace(/,/g,"").trim();if(!r)return null;const n=Number(r);return Number.isFinite(n)?n:null}function Er(e,r){const n=rn(e),a=rn(r);return n!==null&&a!==null?n-a:e.localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})}function nn(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:Jr()}function nd(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=Ln.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 Er(e,a)>0;case"greaterThanOrEqual":return Er(e,a)>=0;case"lessThan":return Er(e,a)<0;case"lessThanOrEqual":return Er(e,a)<=0;case"between":return Er(e,a)>=0&&Er(e,o)<=0;case"top10":case"bottom10":{const u=n.map(b=>({value:b,number:rn(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(rn).filter(b=>b!==null);if(d.length===0)return!1;const u=d.reduce((b,f)=>b+f,0)/d.length,h=rn(e);return h===null?!1:r.operator==="aboveAverage"?h>u:h<u}default:return!0}}function Ss({children:e,className:r="",style:n}){return t.jsx(_t,{onlyWhenOverflow:!0,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,...n},children:e})}function Xa({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:h,expandedRowIds:b,defaultExpandedRowIds:f=[],onExpandedRowIdsChange:p,expandOnRowClick:v=!1,selected:w,onToggleOne:g,onToggleAll:A,getRowSelectable:C,highlightSelected:T=!0,rowClassName:H,getRowCategory:E,stickyHeader:x=!0,pageSize:M=25,pageSizeOptions:k,pageSizeSelectWidth:_=62,pageSizeSelectHeight:q=30,pageSizeSelectPadding:X="0 7px",totalRows:D,page:K,onPageChange:j,onPageSizeChange:le,storageKey:Q,stickyFirstColumn:fe=!1,bottomOffset:F=0,compact:V=!0,restrictHeight:ae=!0,maxHeight:$,minTableWidth:P,enableColumnVisibility:ce=!0,enableColumnFilters:O=!0,hiddenColumnKeys:oe,defaultHiddenColumnKeys:G=Zc,onHiddenColumnKeysChange:U,columnVisibilityLabel:se="Columnas",enableBql:S=!1,bqlValue:R,defaultBqlValue:ee="",onBqlChange:J,bqlDescription:y="Filtra registros con Bonsaif Query Language",bqlPlaceholder:N=`status = activo
2
- rol IN (admin, employee)`,bqlQuickFilters:te=[],bqlExamples:ue=[],bqlSuggestions:re=[],bqlActiveFilters:ge,bqlError:Se,onQueryChange:$e,persistState:ht,onPreferencesReady:Ct,enableExport:rt=!1,exportFilename:at="datos",onExportCsv:de,onExportPdf:Ee}){var ic;const ne=Rc(ht,Q),De=Object.values(ne).some(Boolean),Be=e.map(m=>m.key).join(","),Ue=G.join(","),je=s.useRef(e),Fe=s.useRef(G);je.current=e,Fe.current=G;const[Qe,ot]=s.useState(!Q||!De),Et=s.useRef(null),he=s.useRef(!Q),ve=s.useRef(!1),Ie=s.useRef(Ct);Ie.current=Ct;const _e=s.useRef(!Q||!De?Q??"__none__":null),Pe=oe!==void 0,[ft,st]=s.useState(()=>tr(G,e)),Ve=tr(Pe?oe:ft,e),[Re,ct]=s.useState(!1),[lt,mr]=s.useState("filter"),[Zt,pr]=s.useState(null),[Mt,We]=s.useState(""),[bt,lr]=s.useState({}),[Tt,Bt]=s.useState({}),vn=b!==void 0,[yn,ha]=s.useState(f),B=R!==void 0,[Y,me]=s.useState(ee),be=B?R:Y,[xe,we]=s.useState(be),[He,Oe]=s.useState(!1),[dt,Je]=s.useState(!1),[ir,gt]=s.useState(!1),[$t,It]=s.useState([]),Qt=s.useRef(null),qt=s.useRef(null),Ut=s.useRef(J);Ut.current=J;const ma=s.useRef(M);ma.current=M;const pa=s.useRef(k);pa.current=k;const mh=Array.isArray(k)?k.join(","):"",zo=s.useRef(null),Oi=s.useRef(null),Wo=s.useRef(null),Hi=s.useRef(0),[ph,gh]=s.useState({}),[vh,yh]=s.useState({}),[xn,ga]=s.useState(!1),jo=s.useRef(null),va=s.useRef(null),[xh,wh]=s.useState({}),Bi=s.useRef(null),ya=s.useRef(null),[qo,Ii]=s.useState(r.length>0||a||c===!1),Fi=(m,L)=>50+(m*17+L*13+7)%40,cr=s.useRef(null),[Nh,kh]=s.useState(void 0),[_i,Sh]=s.useState(0),[Ch,Eh]=s.useState(!1);s.useEffect(()=>{function m(){Eh(window.innerWidth<640)}if(!ae||$!==void 0)return m(),window.addEventListener("resize",m),()=>window.removeEventListener("resize",m);const Z=M!==!1?48:0,z=12;function ie(){if(m(),!cr.current)return;const pe=cr.current.getBoundingClientRect().top;kh(Math.max(120,window.innerHeight-pe-Z-z-F))}return ie(),window.addEventListener("resize",ie),()=>window.removeEventListener("resize",ie)},[a,M,F,ae,$]);const Pi=ae?$??Nh:void 0;s.useEffect(()=>{const m=cr.current;if(!m)return;const L=()=>Sh(m.clientWidth);if(L(),typeof ResizeObserver>"u")return window.addEventListener("resize",L),()=>window.removeEventListener("resize",L);const Z=new ResizeObserver(L);return Z.observe(m),()=>Z.disconnect()},[a,Qe,r.length]),s.useEffect(()=>{if(c===!1||a||r.length>0){Ii(!0);return}if(qo)return;const m=window.setTimeout(()=>{Ii(!0)},c);return()=>window.clearTimeout(m)},[r.length,c,qo,a]);const[Ur,Vr]=s.useState(()=>er(e.map(m=>m.key),e)),[gr,Xr]=s.useState(()=>Object.fromEntries(e.map(m=>[m.key,yt(m,Kt(m.width))]))),[Ge,vr]=s.useState(null),[Mh,xa]=s.useState(1),[wa,Na]=s.useState(M===!1?0:M);s.useEffect(()=>{var Ae;const m=je.current,L=Fe.current,Z=m.map(Ce=>Ce.key),z=new Set(Z),ie=()=>{var Ce;ve.current||(ve.current=!0,(Ce=Ie.current)==null||Ce.call(Ie))};if(!Q||!De){ne.layout&&Vr(er(Z,m)),Pe||st(tr(L,m)),he.current=!1,ot(!0),ie();return}let pe=!1;const Me=_e.current===Q;Me||(he.current=!1,ot(!1),ve.current=!1);const Le=Dn(Q);if(xs(Le)&&!Me){const Ce=Le,Ne=nn(pa.current??Jr()),ke=ma.current,wr=ke===!1?0:ke,ur=ne.layout?Ce==null?void 0:Ce.columnOrder:void 0,Nr=Array.isArray(ur)?ur.filter(Xe=>Z.includes(Xe)):[],kr=er(Nr.length>0?On(Nr,Z):Z,m),Sr=Object.fromEntries(m.map(Xe=>[Xe.key,yt(Xe,Kt(Xe.width))])),Gr=ne.layout?(Ce==null?void 0:Ce.columnWidths)??{}:{},Sn=Object.fromEntries(m.map(Xe=>[Xe.key,yt(Xe,Gr[Xe.key]??Sr[Xe.key])])),Zr=tr(ne.layout?(Ce==null?void 0:Ce.hiddenColumnKeys)??L:L,m);if(ne.layout&&(Vr(kr),Xr(Sn)),Pe||st(Zr),ne.filters&&(lr(en(Ce==null?void 0:Ce.filters,z)),Bt(tn(Ce==null?void 0:Ce.conditionFilters,z))),ne.sort){const Xe=Rr(Ce==null?void 0:Ce.sort)?Ce.sort:null;vr(Xe&&z.has(Xe.key)?Xe:null)}if(ne.bql){if(Qt.current!==Q){Qt.current=Q;const Xe=typeof(Ce==null?void 0:Ce.bql)=="string"?Ce.bql:ee;B?(Ae=Ut.current)==null||Ae.call(Ut,Xe):me(Xe)}It(Array.isArray(Ce==null?void 0:Ce.bqlHistory)?Ce.bqlHistory.filter(Xe=>typeof Xe=="string"):[])}ne.pagination&&qt.current!==Q&&(qt.current=Q,Na(Ua(Ce==null?void 0:Ce.pageSize,Ne,wr))),_e.current=Q,ot(!0),ie()}const vt=`${qa()??"/api/user/preferences/datatables"}?key=${encodeURIComponent(Q)}`,tt=new AbortController,ye=window.setTimeout(()=>tt.abort(),2500);return fetch(vt,{cache:"no-store",signal:tt.signal}).then(Ce=>Ce.ok?Ce.json():null).then(Ce=>{var cc;if(pe)return;const Ne=Dn(Q),ke=Ns(xs(Ce==null?void 0:Ce.settings)?Ce==null?void 0:Ce.settings:null,Ne),wr=nn(pa.current??Jr()),ur=ma.current,Nr=ur===!1?0:ur,kr=ne.layout?ke==null?void 0:ke.columnOrder:void 0,Sr=Array.isArray(kr)?kr.filter(nt=>Z.includes(nt)):[],Gr=er(Sr.length>0?On(Sr,Z):Z,m),Sn=Object.fromEntries(m.map(nt=>[nt.key,yt(nt,Kt(nt.width))])),Zr=ne.layout?(ke==null?void 0:ke.columnWidths)??{}:{},Xe=Object.fromEntries(m.map(nt=>[nt.key,yt(nt,Zr[nt.key]??Sn[nt.key])])),Qr=tr(ne.layout?(ke==null?void 0:ke.hiddenColumnKeys)??L:L,m);if(ne.layout&&(Vr(Gr),Xr(Xe)),Pe||st(Qr),ne.filters&&(lr(en(ke==null?void 0:ke.filters,z)),Bt(tn(ke==null?void 0:ke.conditionFilters,z))),ne.sort){const nt=Rr(ke==null?void 0:ke.sort)?ke.sort:null;vr(nt&&z.has(nt.key)?nt:null)}if(ne.bql){if(Qt.current!==Q){Qt.current=Q;const nt=typeof(ke==null?void 0:ke.bql)=="string"?ke.bql:ee;B?(cc=Ut.current)==null||cc.call(Ut,nt):me(nt)}It(Array.isArray(ke==null?void 0:ke.bqlHistory)?ke.bqlHistory.filter(nt=>typeof nt=="string"):[])}let Ze;ne.pagination&&(Ze=Ua(ke==null?void 0:ke.pageSize,wr,Nr),qt.current!==Q&&(qt.current=Q,Na(Ze))),Et.current=JSON.stringify({columnOrder:Gr,columnWidths:Xe,hiddenColumnKeys:Qr,filters:en(ke==null?void 0:ke.filters,z),conditionFilters:tn(ke==null?void 0:ke.conditionFilters,z),sort:Rr(ke==null?void 0:ke.sort)?ke.sort:null,bql:typeof(ke==null?void 0:ke.bql)=="string"?ke.bql:"",bqlHistory:Array.isArray(ke==null?void 0:ke.bqlHistory)?ke.bqlHistory:[],pageSize:ne.pagination&&ur!==!1?Ze:void 0}),he.current=!0}).catch(()=>{var Ce;if(!pe){const Ne=Dn(Q),ke=nn(pa.current??Jr()),wr=ma.current,ur=wr===!1?0:wr,Nr=ne.layout?Ne==null?void 0:Ne.columnOrder:void 0,kr=Array.isArray(Nr)?Nr.filter(Ze=>Z.includes(Ze)):[],Sr=er(kr.length>0?On(kr,Z):Z,m),Gr=Object.fromEntries(m.map(Ze=>[Ze.key,yt(Ze,Kt(Ze.width))])),Sn=ne.layout?(Ne==null?void 0:Ne.columnWidths)??{}:{},Zr=Object.fromEntries(m.map(Ze=>[Ze.key,yt(Ze,Sn[Ze.key]??Gr[Ze.key])]));ne.layout&&(Vr(Sr),Xr(Zr));const Xe=tr(ne.layout?(Ne==null?void 0:Ne.hiddenColumnKeys)??L:L,m);if(Pe||st(Xe),ne.filters&&(lr(en(Ne==null?void 0:Ne.filters,z)),Bt(tn(Ne==null?void 0:Ne.conditionFilters,z))),ne.sort){const Ze=Rr(Ne==null?void 0:Ne.sort)?Ne.sort:null;vr(Ze&&z.has(Ze.key)?Ze:null)}if(ne.bql){if(Qt.current!==Q){Qt.current=Q;const Ze=typeof(Ne==null?void 0:Ne.bql)=="string"?Ne.bql:ee;B?(Ce=Ut.current)==null||Ce.call(Ut,Ze):me(Ze)}It(Array.isArray(Ne==null?void 0:Ne.bqlHistory)?Ne.bqlHistory.filter(Ze=>typeof Ze=="string"):[])}let Qr;ne.pagination&&(Qr=Ua(Ne==null?void 0:Ne.pageSize,ke,ur),qt.current!==Q&&(qt.current=Q,Na(Qr))),Et.current=JSON.stringify({columnOrder:Sr,columnWidths:Zr,hiddenColumnKeys:Xe,filters:en(Ne==null?void 0:Ne.filters,z),conditionFilters:tn(Ne==null?void 0:Ne.conditionFilters,z),sort:Rr(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:ne.pagination&&wr!==!1?Qr:void 0}),he.current=!0}}).finally(()=>{window.clearTimeout(ye),pe||(_e.current=Q,ot(!0),ie())}),()=>{pe=!0,tt.abort(),window.clearTimeout(ye)}},[Q,De,Be,Ue,Pe,ne.layout,ne.filters,ne.sort,ne.bql,ne.pagination,B,ee,mh]),s.useEffect(()=>{if(!Q||!Qe||!De||!he.current)return;const m={};ne.layout&&(m.columnOrder=Ur,m.columnWidths=gr,m.hiddenColumnKeys=Ve),ne.filters&&(m.filters=bt,m.conditionFilters=Tt),ne.sort&&(m.sort=Ge),ne.bql&&(m.bql=be,m.bqlHistory=$t),ne.pagination&&M!==!1&&(m.pageSize=wa);const L=Dn(Q),Z=Ns(L,m),z=JSON.stringify(Z);if(z===Et.current)return;Jc(Q,Z),Et.current=z;const ie=window.setTimeout(()=>{const pe=qa()??"/api/user/preferences/datatables";fetch(pe,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:Q,settings:Z})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(ie)},[Ur,gr,Ve,bt,Tt,Ge,be,$t,wa,M,Q,Qe,De,ne.layout,ne.filters,ne.sort,ne.bql,ne.pagination]),s.useEffect(()=>{Vr(m=>{const L=e.map(Z=>Z.key);return er(On(m,L),e)})},[Be,e]);const zi=er(Ur,e).map(m=>e.find(L=>L.key===m)).filter(m=>!!m),At=zi.filter(m=>!Ve.includes(m.key)),Wi=e.some(Va),Th=Object.keys(bt).length,$h=Object.keys(Tt).length,Uo=Th+$h;function ji(m){const L=new Set;return r.reduce((Z,z)=>{const ie=Hn(m,z);return!ie||L.has(ie)||(L.add(ie),Z.push({value:ie,label:ie})),Z},[])}function Ah(){const m=e.find(L=>L.key===Zt);return m?ji(m):[]}function Lh(m){return!!(O&&!br(m)&&(m.filterValue||m.sortKey||ji(m).length>0))}function Vo(m,L){lr(Z=>{const z={...Z};return z[m]=L,z})}function Dh(m,L,Z,z){const ie=bt[m]??[];if(!z){Vo(m,[L]);return}const pe=ie.includes(L)?ie.filter(Me=>Me!==L):[...ie,L];pe.length===0||pe.length===Z.length?Xo(m):Vo(m,pe)}function Xo(m){lr(L=>{const Z={...L};return delete Z[m],Z})}function ka(m,L){Bt(Z=>{const z={...Z};return L?z[m]=L:delete z[m],z})}function qi(m){ka(m,null)}function Oh(){lr({}),Bt({})}function Hh(m){B||me(m),J==null||J(m)}function Ui(m){const L=m.trim();we(L),(J==null?void 0:J(L))!==!1&&(B||me(L),Oe(!1),Je(!1),gt(!1),L&&It(z=>[L,...z.filter(ie=>ie!==L)].slice(0,Xc)))}function Vi(){we(""),Hh(""),Oe(!1),Je(!1),gt(!1)}function Yo(m,L){we(m),L&&(L.style.height="auto",L.style.height=`${Math.min(L.scrollHeight,180)}px`)}function Sa(m){const L=m.trim();if(!L)return;Hi.current=Date.now()+500;const Z=xe.replace(/\s+$/u,""),z=Z.length===0?L:Z.split(`
3
- `).map(ie=>ie.trim()).includes(L)?Z:`${Z}
4
- ${L}`;Yo(z,Wo.current??void 0),requestAnimationFrame(()=>{const ie=Wo.current;if(!ie)return;ie.focus();const pe=ie.value.length;ie.setSelectionRange(pe,pe),Yo(ie.value,ie)})}s.useEffect(()=>{we(be)},[be]);const Ca=s.useCallback(()=>{const m=zo.current;if(!m)return;const L=m.getBoundingClientRect(),Z=12,z=8,ie=Math.min(780,Math.max(320,window.innerWidth-32)),pe=Math.max(Z,window.innerWidth-ie-Z),Me=Math.min(Math.max(Z,L.left),pe),Le=L.bottom+z,qe=window.innerHeight-L.top+z,Ye=window.innerHeight-Le-Z,vt=L.top-Z-z,tt=Ye<280&&vt>Ye,ye=Math.max(240,tt?vt:Ye);gh({position:"fixed",zIndex:1e4,left:Me,top:tt?void 0:Le,bottom:tt?qe:void 0,width:ie,maxWidth:"calc(100vw - 24px)",maxHeight:ye,overflowY:"auto"})},[]);s.useEffect(()=>{if(!He)return;function m(z){var pe,Me;if(Date.now()<Hi.current)return;const ie=z.target;(pe=zo.current)!=null&&pe.contains(ie)||(Me=Oi.current)!=null&&Me.contains(ie)||(Oe(!1),Je(!1),gt(!1))}function L(z){z.key==="Escape"&&(Oe(!1),Je(!1),gt(!1))}function Z(){Ca()}return Ca(),document.addEventListener("mousedown",m),window.addEventListener("keydown",L),window.addEventListener("resize",Z),window.addEventListener("scroll",Z,!0),()=>{document.removeEventListener("mousedown",m),window.removeEventListener("keydown",L),window.removeEventListener("resize",Z),window.removeEventListener("scroll",Z,!0)}},[He,Ca]);function Xi(m){const L=tr(m,e);Pe||st(L),U==null||U(L)}function Bh(m){Xi(Ve.includes(m)?Ve.filter(L=>L!==m):[...Ve,m])}function Ih(){Xi([])}const Ko=s.useCallback((m=ya.current)=>{if(!m)return;const L=m.getBoundingClientRect(),Z=Math.min(292,Math.max(240,window.innerWidth-16)),z=Math.max(8,window.innerWidth-Z-8),ie=Math.min(Math.max(8,L.right-Z),z),pe=window.innerHeight-L.bottom,Me=L.bottom+6,Le=window.innerHeight-L.top+6,Ye=pe<360&&L.top>pe?void 0:Me,vt=Ye===void 0?Le:void 0,tt=Math.max(220,Ye===void 0?L.top-16:window.innerHeight-Me-8),ye={position:"fixed",zIndex:9999,left:ie,top:Ye,bottom:vt,width:Z,maxWidth:"calc(100vw - 16px)",maxHeight:tt,"--dt-column-menu-max-height":`${tt}px`};yh(ye)},[]);function Yi(m,L,Z=null){m.preventDefault(),m.stopPropagation();const z=ya.current===m.currentTarget&&lt===L&&Zt===Z;if(Re&&z){ct(!1),pr(null);return}ya.current=m.currentTarget,mr(L),pr(Z),We(""),Ko(m.currentTarget),ct(!0)}function Fh(m){if(br(m))return;const L=cr.current;if(!L)return;const z=Array.from(L.querySelectorAll("[data-dt-column-key]")).filter(ie=>ie.dataset.dtColumnKey===m.key).reduce((ie,pe)=>{const Me=pe.querySelector("[data-dt-autofit-content]"),Le=Me?Me.scrollWidth:Math.max(pe.scrollWidth,pe.offsetWidth);return Math.max(ie,Math.ceil(Le+ed(pe)))},0);z<=0||Xr(ie=>({...ie,[m.key]:yt(m,z+12)}))}s.useEffect(()=>{Xr(m=>{const L=Object.fromEntries(e.map(Z=>[Z.key,yt(Z,Kt(Z.width))]));return Object.fromEntries(e.map(Z=>[Z.key,yt(Z,m[Z.key]??L[Z.key])]))})},[Be,e]),s.useEffect(()=>{Pe||st(m=>tr(m,e))},[Be,e,Pe]),s.useEffect(()=>{function m(z){var Me,Le;const ie=z.target,pe=z.target;pe!=null&&pe.closest("[data-bonsaif-select-dropdown='true']")||!((Me=Bi.current)!=null&&Me.contains(ie))&&!((Le=ya.current)!=null&&Le.contains(ie))&&(ct(!1),pr(null))}function L(z){z.key==="Escape"&&(ct(!1),pr(null))}function Z(){Ko()}return Re&&(document.addEventListener("mousedown",m),window.addEventListener("keydown",L),window.addEventListener("resize",Z),window.addEventListener("scroll",Z,!0)),()=>{document.removeEventListener("mousedown",m),window.removeEventListener("keydown",L),window.removeEventListener("resize",Z),window.removeEventListener("scroll",Z,!0)}},[Re,Ko]);const wn=s.useRef(null);s.useEffect(()=>{function m(Z){const z=wn.current;if(!z)return;const ie=Z.clientX-z.startX,pe=e.find(Me=>Me.key===z.colKey);pe&&Xr(Me=>({...Me,[z.colKey]:yt(pe,z.startWidth+ie)}))}function L(){wn.current&&(wn.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",m),document.addEventListener("pointerup",L),()=>{document.removeEventListener("pointermove",m),document.removeEventListener("pointerup",L)}},[e]);const Nn=s.useRef(null),[Ki,Go]=s.useState(null);function _h(m,L){const Z=e.find(z=>z.key===m);if(!Z||!ks(Z)){L.preventDefault();return}Nn.current=Ur.indexOf(m),L.dataTransfer.effectAllowed="move"}function Ph(m,L){L.preventDefault(),L.dataTransfer.dropEffect="move";const Z=Ur.indexOf(m);Ki!==Z&&Go(Z)}function zh(m,L){L.preventDefault();const Z=Nn.current,z=Ur.indexOf(m);Z!==null&&Z!==z&&Vr(ie=>{const pe=[...ie],[Me]=pe.splice(Z,1);return pe.splice(z,0,Me),er(pe,e)}),Nn.current=null,Go(null)}function Wh(){Nn.current=null,Go(null)}function jh(m){m.sortKey&&vr(L=>(L==null?void 0:L.key)===m.key?{key:m.key,dir:L.dir==="asc"?"desc":"asc"}:{key:m.key,dir:"asc"})}s.useEffect(()=>{xa(1)},[r]),s.useEffect(()=>{xa(1)},[Tt,bt]);const Vt=!!(j&&le),dr=M!==!1,Zo=s.useMemo(()=>nn(k??Jr()),[k]),ut=Vt?K??1:Mh,Gi=dr&&wa<1?typeof M=="number"&&M>0?M:Zo[0]??25:wa,Xt=Vt||dr?Gi:r.length,Ft=!!w&&!!g&&!!A,Qo=s.useMemo(()=>C?r.filter(m=>C(m)):r,[r,C]),Yr=!!u,Zi=s.useMemo(()=>new Set(vn?Array.from(b??[]):yn),[vn,b,yn]),qh=(Yr?40:0)+(Ft?40:0),Jo=!Ch&&(Wi||fe),Ea=(()=>{if(!Jo)return{};let m=qh;const L={};return At.forEach((Z,z)=>{(Va(Z)||!Wi&&fe&&z===0)&&(L[Z.key]=m,m+=gr[Z.key]??yt(Z,Kt(Z.width)))}),L})(),Ro=Object.keys(Ea),es=Ro.length>0?Ro[Ro.length-1]:null,Qi=Ft&&Qo.length>0&&Qo.every(m=>w.has(n(m))),Uh=Ft&&w.size>0&&Qo.some(m=>w.has(n(m)))&&!Qi,Ma=s.useMemo(()=>{if(Vt)return r;const m=Object.entries(bt),L=Object.entries(Tt);return m.length===0&&L.length===0?r:r.filter(Z=>m.every(([z,ie])=>{const pe=e.find(Me=>Me.key===z);return pe?ie.includes(Hn(pe,Z)):!0})&&L.every(([z,ie])=>{const pe=e.find(Le=>Le.key===z);if(!pe)return!0;const Me=r.map(Le=>Hn(pe,Le));return nd(Hn(pe,Z),ie,Me)}))},[Tt,bt,e,r,Vt]),yr=s.useMemo(()=>{if(!Ge)return Ma;const m=e.find(L=>L.key===Ge.key&&L.sortKey);return m!=null&&m.sortKey?[...Ma].sort((L,Z)=>{const z=L[m.sortKey],ie=Z[m.sortKey],pe=z===ie?0:z==null?1:ie==null||z<ie?-1:1;return Ge.dir==="asc"?pe:-pe}):Ma},[Ma,Ge,e]),Ji=s.useMemo(()=>{if(Vt||!dr)return yr;const m=(ut-1)*Xt;return yr.slice(m,m+Xt)},[yr,Vt,dr,ut,Xt]),Jt=Vt?D??r.length:yr.length,ts=dr?Math.max(1,Math.ceil(Jt/Xt)):1,Vh=Math.min(...Zo),Xh=dr&&(Jt>Xt||Jt>Vh),Yh=dr?(ut-1)*Xt+1:1,Kh=dr?Math.min(ut*Xt,Jt):Jt;function rs(m){if(a)return;const L=Math.max(1,Math.min(m,ts));Vt?j(L):xa(L)}function Gh(m){a||(Q&&(qt.current=Q),Na(m),Vt?(le(m),j(1)):(xa(1),le==null||le(m)))}function Ri(m){const L=new Set(Zi);L.has(m)?L.delete(m):L.add(m);const Z=Array.from(L);vn||ha(Z),p==null||p(Z)}s.useEffect(()=>{$e==null||$e({bql:be,filters:bt,conditionFilters:Tt,sort:Ge,page:ut,pageSize:Xt,hiddenColumnKeys:Ve})},[be,bt,Tt,Ge,ut,Xt,Ve,$e]);const ec=m=>m==="center"?"justify-center text-center":m==="right"?"justify-end text-right":"justify-start text-left",Zh="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",ns="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%)",ze="color-mix(in srgb, var(--border) 62%, var(--bg-card))",xr="color-mix(in srgb, var(--primary) 24%, var(--border))",Ta=`inset 0 0 0 1px ${ze}`,tc=At.reduce((m,L)=>m+(gr[L.key]??Kt(L.width)),(Yr?40:0)+(Ft?40:0)),rc=typeof P=="number"?P:typeof P=="string"?Number(((ic=P.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:ic[1])??NaN):NaN,kn=Number.isFinite(rc)?Math.max(tc,rc,_i):Math.max(tc,_i),$a=P??kn,Kr=`${Yr?"40px ":""}${Ft?"40px ":""}${At.map(m=>`${gr[m.key]??Kt(m.width)}px`).join(" ")}`;s.useEffect(()=>{Ge&&Ve.includes(Ge.key)&&vr(null)},[Ve,Ge]);function nc(m){return m?typeof m=="string"?{key:m,label:m}:m:null}const Aa=()=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Kr,background:ns,borderBottom:`1px solid ${xr}`},children:[Yr&&t.jsx("div",{role:"columnheader",className:`${V?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${xr}`,borderRight:`1px solid ${ze}`}}),Ft&&t.jsx("div",{role:"columnheader",className:`${V?"px-2 py-1.5":"px-3 py-2.5"} flex w-10 items-center justify-center`,style:Jo?{position:"sticky",left:0,zIndex:12,background:ns,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${xr}`,borderRight:`1px solid ${ze}`}:{borderBottom:`1px solid ${xr}`,borderRight:`1px solid ${ze}`},children:t.jsx(Tn,{size:"sm",checked:Qi,indeterminate:Uh,onChange:A,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),At.map((m,L)=>{const Z=(Ge==null?void 0:Ge.key)===m.key,z=!!m.sortKey,ie=br(m),pe=Ea[m.key],Me=pe!==void 0,Le=m.key===es,qe=ks(m),Ye=Ki===L,tt=(gr[m.key]??Kt(m.width))<120,ye=Object.prototype.hasOwnProperty.call(bt,m.key)||Object.prototype.hasOwnProperty.call(Tt,m.key);return t.jsxs("div",{role:"columnheader","data-dt-column-key":m.key,className:`group select-none ${tt?"text-left":ec(m.align)}`,style:{...Me?{position:"sticky",left:pe,zIndex:12,background:ns,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:Le?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${xr}`:`inset 0 -1px 0 ${xr}`,borderRight:`1px solid ${ze}`}:{position:"relative",borderBottom:`1px solid ${xr}`,borderRight:`1px solid ${ze}`},color:Z?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:Ye?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:ie?V?"7px 6px":"9px 8px":V?"8px 6px 10px":"10px 8px 12px"},onDragOver:Ae=>{(qe||Nn.current!==null)&&Ph(m.key,Ae)},onDrop:Ae=>zh(m.key,Ae),children:[t.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${ie?"justify-center":tt?"justify-start":m.align==="center"?"justify-center":m.align==="right"?"justify-end":"justify-start"}`,children:[qe?t.jsx("span",{draggable:!0,onDragStart:Ae=>{Ae.stopPropagation(),_h(m.key,Ae)},onDragEnd:Ae=>{Ae.stopPropagation(),Wh()},onClick:Ae=>Ae.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 ${Ye?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}):null,ie?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(W.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):t.jsx(Ss,{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 ${V?"text-[11px]":"text-xs"}`,children:t.jsx("span",{className:"min-w-0 truncate",children:m.header})})}),z&&t.jsx("button",{type:"button","aria-label":`Ordenar por ${String(m.header)}`,title:"Ordenar",onClick:Ae=>{Ae.stopPropagation(),jh(m)},"data-dt-sort-button":!0,className:`absolute -bottom-2 left-1/2 z-20 inline-flex h-4 w-4 -translate-x-1/2 items-center justify-center rounded-full bg-[var(--primary)] text-[var(--primary-fg)] shadow-[0_1px_3px_rgba(15,23,42,0.22)] transition-[opacity,transform] duration-150 hover:scale-105 focus:scale-105 focus:opacity-100 focus:outline-none ${Z?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:Z?Ge.dir==="asc"?t.jsx(W.HiChevronUp,{className:"h-3 w-3"}):t.jsx(W.HiChevronDown,{className:"h-3 w-3"}):t.jsx(W.HiChevronUpDown,{className:"h-3 w-3"})}),O&&!ie&&Lh(m)&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Re&&Zt===m.key,"aria-label":`Filtrar ${String(m.header)}`,title:"Filtrar",onClick:Ae=>Yi(Ae,"filter",m.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 ${Re&&lt==="filter"&&Zt===m.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":ye?"text-[var(--primary)] opacity-100":""}`,children:ye?t.jsx(W.HiFunnel,{className:"h-3.5 w-3.5"}):t.jsx(W.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!ie&&t.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:Ae=>{Ae.preventDefault(),Ae.stopPropagation(),wn.current={colKey:m.key,startX:Ae.clientX,startWidth:gr[m.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:Ae=>{Ae.preventDefault(),Ae.stopPropagation(),wn.current=null,document.body.style.cursor="",document.body.style.userSelect="",Fh(m)},onClick:Ae=>Ae.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"}})]})})]},m.key)})]}),La=()=>{if(!Re||typeof document>"u"||lt==="visibility"&&!ce||lt==="filter"&&!O)return null;const m=e.find(ye=>ye.key===Zt),L=Ah(),Z=m?Object.prototype.hasOwnProperty.call(bt,m.key):!1,z=m?Tt[m.key]:void 0,ie=Ln.find(ye=>ye.value===(z==null?void 0:z.operator)),pe=m?bt[m.key]??[]:[],Me=Mt.trim().toLowerCase(),Le=Me?L.filter(ye=>ye.label.toLowerCase().includes(Me)):L,qe=m&&L.length>0&&(!Z||pe.length===L.length),Ye=m&&Z&&pe.length>0&&pe.length<L.length,vt=Ve.length,tt=()=>{m&&(Xo(m.key),qi(m.key))};return mt.createPortal(t.jsx("div",{ref:Bi,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...vh,borderColor:"var(--border)",background:"var(--bg-card)"},children:lt==="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?`${At.length} de ${e.length} visibles`:`${e.length} visibles`}),t.jsx("button",{type:"button",onClick:Ih,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:zi.map(ye=>{const Ae=!Ve.includes(ye.key),Ne=!(ye.hideable!==!1)||Ae&&At.length<=1;return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ae,disabled:Ne,onClick:()=>Bh(ye.key),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ae?"var(--primary)":"var(--border)",background:Ae?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ae&&t.jsx(W.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ye.header})]},ye.key)})})]}):m?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 ",m.header]}),t.jsx("button",{type:"button",onClick:tt,disabled:!Z&&!z,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"})]}),m.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:()=>vr({key:m.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(W.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Ascendente"})]}),(Ge==null?void 0:Ge.key)===m.key&&Ge.dir==="asc"&&t.jsx(W.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),t.jsxs("button",{type:"button",onClick:()=>vr({key:m.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(W.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Descendente"})]}),(Ge==null?void 0:Ge.key)===m.key&&Ge.dir==="desc"&&t.jsx(W.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(fr,{value:(z==null?void 0:z.operator)??"",onChange:ye=>{if(!ye){qi(m.key);return}ka(m.key,{operator:ye,value:(z==null?void 0:z.value)??"",valueTo:(z==null?void 0:z.valueTo)??""})},options:Vc,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"}),(ie==null?void 0:ie.valueMode)!=="none"?t.jsx("input",{value:(z==null?void 0:z.value)??"",onChange:ye=>{z&&ka(m.key,{...z,value:ye.target.value})},disabled:!z,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"})]}),(ie==null?void 0:ie.valueMode)==="between"&&t.jsx("input",{value:(z==null?void 0:z.valueTo)??"",onChange:ye=>{z&&ka(m.key,{...z,valueTo:ye.target.value})},placeholder:"Valor final",className:"mt-2 w-full rounded-md border px-2 py-1.5 text-xs outline-none transition-colors placeholder:text-[var(--text-muted)] focus:border-[var(--primary)]",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"}})]}),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(W.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("input",{value:Mt,onChange:ye=>We(ye.target.value),placeholder:"Buscar",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-[var(--text-muted)]",style:{color:"var(--text-main)"}})]})}),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":Ye?"mixed":!!qe,onClick:()=>{m&&(qe&&!Z?Vo(m.key,[]):Xo(m.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:qe||Ye?"var(--primary)":"var(--border)",background:qe||Ye?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[Ye&&t.jsx(W.HiMinus,{className:"h-3 w-3"}),qe&&!Ye&&t.jsx(W.HiCheck,{className:"h-3 w-3"})]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),Le.map(ye=>{const Ae=!Z||pe.includes(ye.value);return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ae,onClick:()=>Dh(m.key,ye.value,L.map(Ce=>Ce.value),Z),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ae?"var(--primary)":"var(--border)",background:Ae?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Ae&&t.jsx(W.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ye.label})]},ye.value)}),Le.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(!xn)return;function m(L){jo.current&&!jo.current.contains(L.target)&&va.current&&!va.current.contains(L.target)&&ga(!1)}return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[xn]);function ac(m,L){if(m.filterValue){const Z=m.filterValue(L);return Z==null||Z===""?"":$n(Z)}return $n(Cr(m.cell(L)))}function oc(m){return`"${$n(m).replace(/"/g,'""')}"`}function Da(m){return $n(m).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function sc(){return Vt&&Jt>yr.length&&Ia.toast.warning(`Exportando ${yr.length.toLocaleString("es-MX")} de ${Jt.toLocaleString("es-MX")} (página actual). Usa exportación completa si está disponible.`),yr}function Qh(){const m=At.filter(qe=>!br(qe)),L=sc(),Z=m.map(qe=>oc(Cr(qe.header))).join(","),z=L.map(qe=>m.map(Ye=>oc(ac(Ye,qe))).join(",")).join(`
5
- `),ie=`${Z}
6
- ${z}`,pe=new Blob(["\uFEFF"+ie],{type:"text/csv;charset=utf-8;"}),Me=URL.createObjectURL(pe),Le=document.createElement("a");Le.href=Me,Le.download=`${at}.csv`,document.body.appendChild(Le),Le.click(),document.body.removeChild(Le),URL.revokeObjectURL(Me)}function Jh(){const m=At.filter(Le=>!br(Le)),L=sc(),Z=m.map(Le=>Da(Cr(Le.header))),ie=L.map(Le=>m.map(qe=>Da(ac(qe,Le)))).map(Le=>`<tr>${Le.map(qe=>`<td>${qe}</td>`).join("")}</tr>`).join(""),pe=`<!DOCTYPE html>
7
- <html lang="es"><head><meta charset="utf-8"><title>${Da(at)}</title>
1
+ (function(I,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):(I=typeof globalThis<"u"?globalThis:I||self,s(I.BonsaifUI={},I.React,I.jsxRuntime,I.ReactIconsHi2,I.ReactDOM,I.Recharts,I.OverlayScrollbarsGlobal,I.Sonner,I.OverlayScrollbarsReact,I.ReactDayPicker,I.ReactDayPickerStyles,I.ReactIconsFi))})(this,(function(I,s,t,z,pt,Ae,Va,Xa,ms,Ya,vm,yc){"use strict";"use client";function Rt(...e){return e.filter(Boolean).join(" ")}function xc({variant:e="primary",className:r,type:n="button",children:a,...o}){return t.jsx("button",{className:Rt("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),[h,b]=s.useState(!1),f=l||h||e.trim().length>0,p=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",g=a||"w-48 max-w-full sm:w-64 lg:w-72";s.useEffect(()=>{var v;o&&((v=u.current)==null||v.focus())},[o]);const w=()=>{var v;b(!0),(v=u.current)==null||v.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?g:"w-24 sm:w-28"}`,onMouseDown:v=>{f||(v.preventDefault(),w())},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:v=>r(v.target.value),onKeyDown:v=>{v.key==="Escape"&&(i==null||i())},placeholder:f?n:"Buscar",className:`${p} 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:v=>{b(!0),v.currentTarget.style.borderColor="var(--primary)",v.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:v=>{b(!1),v.currentTarget.style.borderColor="var(--border)",v.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 gs=s.createContext({});let vs=0;const ys="bonsaif-ui:hide-tooltips";function Hn(e=700){vs=Date.now()+e}function wc(){return Date.now()>vs}function Bn(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 Nc(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 Pt({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:h,as:b="div"}){const f=s.useRef(null),p=s.useRef(null),g=s.useRef(null),w=s.useRef(!1),[v,L]=s.useState(null),[M,S]=s.useState("");s.useEffect(()=>{const D=f.current;D&&(D.querySelectorAll("[title]").forEach(K=>{const j=K.getAttribute("title");j&&(K.getAttribute("aria-label")||K.setAttribute("aria-label",j),K.removeAttribute("title"))}),D.querySelectorAll("svg title").forEach(K=>K.remove()))}),s.useLayoutEffect(()=>{if(!v)return;const D=p.current;if(!D)return;const K=12,j=14,ie=D.getBoundingClientRect(),Q=window.innerWidth-ie.width-K,fe=window.innerHeight-ie.height-K;let F=v.mouseX+j,Y=v.mouseY+j,ae,$;if(!o&&f.current){const W=f.current.getBoundingClientRect(),ce=W.left+W.width/2,B=W.top+W.height/2;l==="top"?(F=ce-ie.width/2,Y=W.top-ie.height-j,$=ie.height-1):l==="left"?(F=W.left-ie.width-j,Y=B-ie.height/2,ae=ie.width-1):l==="right"?(F=W.right+j,Y=B-ie.height/2,ae=-7):(F=ce-ie.width/2,Y=W.bottom+j,$=-7)}if(o&&(F>Q&&(F=v.mouseX-ie.width-j),Y>fe&&(Y=v.mouseY-ie.height-j)),F=Math.min(Math.max(K,F),Math.max(K,Q)),Y=Math.min(Math.max(K,Y),Math.max(K,fe)),!o&&f.current){const W=f.current.getBoundingClientRect(),ce=W.left+W.width/2,B=W.top+W.height/2;l==="top"||l==="bottom"?ae=Math.min(Math.max(14,ce-F),ie.width-14):$=Math.min(Math.max(14,B-Y),ie.height-14)}(Math.abs(F-v.x)>.5||Math.abs(Y-v.y)>.5||ae!==v.arrowX||$!==v.arrowY)&&L(W=>W&&{...W,x:F,y:Y,arrowX:ae,arrowY:$})},[o,l,v]);const H=()=>{g.current&&(window.clearTimeout(g.current),g.current=null)},C=(D,K)=>{if(!wc()||w.current)return;const j=f.current;if(j&&!Bn(j)){if(n){const ie=Nc(j);if(!ie)return;S(ie)}!n&&!r||L({mouseX:D,mouseY:K,x:D+14,y:K+14})}},y=()=>{const D=f.current;if(!D)return;const K=D.getBoundingClientRect();C(K.left+K.width/2,K.bottom)},T=()=>{H(),L(null)},N=()=>{if(!a){T();return}H(),g.current=window.setTimeout(()=>L(null),120)},_=()=>{Hn(),w.current=!0,T()},q=()=>{w.current=!1};s.useEffect(()=>{if(!v)return;if(Bn(f.current)){L(null);return}const D=()=>L(null),K=()=>{Hn(),w.current=!0,L(null)};document.addEventListener("pointerdown",K,!0),document.addEventListener("click",K,!0),document.addEventListener("scroll",D,!0),window.addEventListener("blur",D),document.addEventListener("visibilitychange",D),document.addEventListener("keydown",D,!0);const j=new MutationObserver(()=>{Bn(f.current)&&L(null)});return j.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",K,!0),document.removeEventListener("click",K,!0),document.removeEventListener("scroll",D,!0),window.removeEventListener("blur",D),document.removeEventListener("visibilitychange",D),document.removeEventListener("keydown",D,!0),j.disconnect()}},[v]),s.useEffect(()=>{const D=()=>Hn(),K=()=>{Hn(),w.current=!0,L(null)};return document.addEventListener("pointerdown",D,!0),document.addEventListener("click",D,!0),document.addEventListener("keydown",D,!0),window.addEventListener(ys,K),()=>{document.removeEventListener("pointerdown",D,!0),document.removeEventListener("click",D,!0),document.removeEventListener("keydown",D,!0),window.removeEventListener(ys,K)}},[]);const U=n?M:r;return t.jsxs(t.Fragment,{children:[t.jsx(b,{ref:D=>{f.current=D},className:c,style:u,onMouseEnter:D=>{H(),q(),o?C(D.clientX,D.clientY):y()},onMouseMove:D=>{v&&o&&C(D.clientX,D.clientY)},onMouseDown:_,onClick:_,onMouseLeave:()=>{q(),N()},onFocus:y,onBlur:T,children:e}),v&&U&&!Bn(f.current)?pt.createPortal(t.jsxs("div",{ref:p,role:"tooltip",className:d,onMouseEnter:a?H:void 0,onMouseLeave:a?N:void 0,style:{position:"fixed",top:v.y,left:v.x,zIndex:9999,background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:6,padding:"5px 10px",fontSize:12,color:"var(--text-main)",boxShadow:"0 4px 16px rgba(0,0,0,0.35)",pointerEvents:a?"auto":"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere",...h},children:[i&&t.jsx("span",{"aria-hidden":"true",style:{position:"absolute",width:12,height:12,background:(h==null?void 0:h.background)??"var(--bg-card)",borderLeft:l==="right"?(h==null?void 0:h.border)??"1px solid var(--border)":void 0,borderTop:l==="bottom"||l==="right"?(h==null?void 0:h.border)??"1px solid var(--border)":void 0,borderRight:l==="left"?(h==null?void 0:h.border)??"1px solid var(--border)":void 0,borderBottom:l==="top"||l==="left"?(h==null?void 0:h.border)??"1px solid var(--border)":void 0,transform:"rotate(45deg)",left:v.arrowX===void 0?void 0:v.arrowX-6,top:v.arrowY===void 0?void 0:v.arrowY-6,zIndex:-1}}),U]}),document.body):null]})}function xs(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}const kc="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",Cc={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"},Sc="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",Ec={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"},Mc={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},Tc={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function Ga(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Ga).join(" ").trim():s.isValidElement(e)?Ga(e.props.children):""}function $c(e){return s.Children.toArray(e).find(s.isValidElement)??null}function Xe({variant:e="primary",size:r="md",loading:n=!1,icon:a,tooltip:o,iconOnly:l,height:i,padding:c,children:d,className:u="",disabled:h,style:b,...f}){const p=s.useContext(gs),g=l??p.iconOnly??e==="icon",w=p.compact??!1,v=p.headerAction??!1,L=v&&r==="md"?"sm":w&&!v&&r==="md"?"xs":r,M=e==="icon"||g,S=v&&M,H=Ga(d),C=o??f.title??f["aria-label"]??(g?H:void 0),y=C?void 0:f.title,T=f["aria-label"]??(typeof C=="string"?C:H||void 0),N=n?null:a??(g?$c(d):null),_=t.jsxs("button",{...f,title:y,"aria-label":T,"data-variant":e,"data-size":L,"data-icon":M?"true":void 0,disabled:h||n,className:`${kc} ${S?Sc:Cc[e]} ${M?Mc[L]:Ec[L]} ${w&&!M?"px-2.5":""} ${u}`,style:{...Tc[e],height:xs(i),padding:xs(c),...b,...v&&!M?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...S?{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"}):N,!g&&d]});return C?t.jsx(Pt,{as:"span",content:C,className:"inline-flex shrink-0",children:_}):_}const vt={background:"color-mix(in srgb, var(--text-muted) 26%, var(--bg-input))"};function In({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:vt}),t.jsx("div",{className:"h-7 max-w-md flex-1 animate-pulse rounded-md",style:vt})]}),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:vt}),t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:vt})]})]}),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((h,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:{...vt,width:`${48+b*17%40}%`}})},`h-${b}`)),Array.from({length:c}).map((h,b)=>Array.from({length:i}).map((f,p)=>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:{...vt,width:`${46+(b*13+p*11)%42}%`,minWidth:28}})},`c-${b}-${p}`)))]})}),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:vt}),t.jsx("div",{className:"h-7 w-14 animate-pulse rounded-md",style:vt})]}),t.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:4}).map((h,b)=>t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:vt},b))}),t.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:vt})]})]})}function Ac({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 Lc({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 ws({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(In,{rows:i,columns:c,className:u});if(e==="sections")return t.jsx(Dc,{rows:i});if(e==="cards")return t.jsx(Oc,{rows:i});const h=o||(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(Lc,{logoSrc:a,logoAlt:h}):null,t.jsx(Ac,{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 Dc({rows:e}){return t.jsx(In,{rows:e,columns:7})}function Oc({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:vt}),t.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded-md",style:vt}),t.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded-md",style:vt})]},n))})}function Ns(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 Hc(e){return[e.label,Ns(e.service),e.description,e.service].filter(Boolean).join(" ")}function Bc(e){return typeof e=="function"?e:e.default}function Ic(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(Xe,{className:"mt-4",height:36,padding:"0 14px",onClick:r,children:"Reintentar"})]})})}function Fc({parentPanel:e,parentPanelComponent:r,renderParentPanel:n,parent:a,context:o,links:l,moduleRegistry:i,loadModule:c,activeService:d,initialService:u,onActiveServiceChange:h,canAccess:b,keepAlive:f=!0,title:p,subtitle:g,emptyState:w,loadingState:v,errorState:L=Ic,renderTabLabel:M,searchableTabs:S="auto",tabsSearchThreshold:H=6,tabsSearchPlaceholder:C="Buscar modulo...",tabsSearchValue:y,onTabsSearchChange:T,emptySearchState:N,showTabCount:_=!0,className:q="",parentClassName:U="",contentClassName:D="",tabsClassName:K=""}){var $e;const j=s.useMemo(()=>l.filter(ne=>!ne.hidden&&((b==null?void 0:b(ne,o))??!0)),[b,o,l]),ie=($e=j.find(ne=>!ne.disabled))==null?void 0:$e.service,[Q,fe]=s.useState(u??ie??""),[F,Y]=s.useState({}),[ae,$]=s.useState({}),[W,ce]=s.useState(""),[B,oe]=s.useState(!1),Z=s.useRef(ae),X=s.useRef(0),se=y??W,E=ks(se),J=S===!0||S==="auto"&&j.length>=H,ee=J&&se.trim().length>0,R=s.useMemo(()=>E?j.filter(ne=>ks(Hc(ne)).includes(E)):j,[E,j]),x=d??Q,k=j.find(ne=>ne.service===x)??j.find(ne=>!ne.disabled);s.useEffect(()=>{!k&&ie&&fe(ie)},[ie,k]),s.useEffect(()=>{Z.current=ae},[ae]);const te=ne=>{ne.disabled||(d||fe(ne.service),h==null||h(ne.service,ne))},de=ne=>{y===void 0&&ce(ne),T==null||T(ne)},re=(ne,He)=>{const Fe=R.filter(Ye=>!Ye.disabled),Ge=Fe.findIndex(Ye=>Ye.service===He.service);Ge<0||((ne.key==="ArrowRight"||ne.key==="ArrowDown")&&(ne.preventDefault(),te(Fe[(Ge+1)%Fe.length])),(ne.key==="ArrowLeft"||ne.key==="ArrowUp")&&(ne.preventDefault(),te(Fe[(Ge-1+Fe.length)%Fe.length])),ne.key==="Home"&&(ne.preventDefault(),te(Fe[0])),ne.key==="End"&&(ne.preventDefault(),te(Fe[Fe.length-1])))},ge=s.useCallback(()=>{if(!k)return;const ne=k.service,He=Z.current[ne];if(He!=null&&He.loading||He!=null&&He.component&&f)return;const Fe=(i==null?void 0:i[ne])??c;if(!Fe){$(Ye=>({...Ye,[ne]:{loading:!1,error:new Error(`No module loader found for service "${ne}".`)}}));return}const Ge=++X.current;$(Ye=>({...Ye,[ne]:{...Ye[ne],loading:!0,error:void 0}})),Fe(k,o).then(Ye=>{if(Ge!==X.current&&!f)return;const ze=Bc(Ye);$(Je=>({...Je,[ne]:{component:ze,loading:!1}}))}).catch(Ye=>{const ze=Ye instanceof Error?Ye:new Error(String(Ye));$(Je=>({...Je,[ne]:{...Je[ne],loading:!1,error:ze}}))})},[o,f,c,i,k]);s.useEffect(ge,[ge]);const Ee=k?F[k.service]??null:null,Le=k?ae[k.service]:void 0,gt=Le==null?void 0:Le.component,Tt=ne=>{k&&Y(He=>({...He,[k.service]:ne}))},nt=()=>{k&&Y(ne=>({...ne,[k.service]:null}))},ot={context:o,parent:a,links:l,visibleLinks:j,filteredLinks:R,selectedLink:k,selectedService:k==null?void 0:k.service,activeItemId:Ee,tabsSearch:se,onSelectService:te,onOpenDetail:Tt,onBackToList:nt},ue=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)] ${q}`,children:[t.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${U}`,children:ue}),t.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${D}`,children:[(p||g||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:[p&&t.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:p}),g&&t.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:g})]}),(J||_)&&t.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[_&&t.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[R.length," / ",j.length]}),J&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${B?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!B,children:t.jsx(ps,{value:se,onChange:de,placeholder:C,className:"w-full",autoFocus:B,forceExpanded:!0,onEscape:()=>oe(!1),size:"sm",inputTabIndex:B?0:-1})}),t.jsx("button",{type:"button","aria-label":B?"Cerrar busqueda":"Buscar tabs","aria-expanded":B,onClick:()=>{B&&se&&de(""),oe(ne=>!ne)},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 ${B||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:B||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":p??"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 ${K}`,children:R.length>0?R.map(ne=>{const He=ne.service===(k==null?void 0:k.service);return t.jsx("button",{type:"button",role:"tab","aria-selected":He,disabled:ne.disabled,onClick:()=>te(ne),onKeyDown:Fe=>re(Fe,ne),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 ${He?"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(ne,He):t.jsxs(t.Fragment,{children:[ne.icon,t.jsx("span",{children:ne.label??Ns(ne.service)}),ne.badge&&t.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:ne.badge})]})},ne.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:N??"No hay modulos que coincidan con la busqueda."})}),(k==null?void 0:k.description)&&t.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:k.description}),t.jsxs("div",{className:"min-h-[420px] p-4",children:[!k&&(w??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."})),k&&(Le==null?void 0:Le.loading)&&(v??t.jsx(ws,{title:"Cargando modulo..."})),k&&(Le==null?void 0:Le.error)&&L(Le.error,ge),k&&gt&&!(Le!=null&&Le.loading)&&!(Le!=null&&Le.error)&&t.jsx(gt,{context:o,parent:a,link:k,activeItemId:Ee,onOpenDetail:Tt,onBackToList:nt})]})]})]})}const _c={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 Pc({variant:e="info",title:r,children:n,icon:a,action:o,onDismiss:l,className:i=""}){const c=_c[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(Xe,{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 Cs=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],zc=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],Wc=["lu","ma","mi","ju","vi","sá","do"],Ss=6;function Ka(e,r,n){return`${e}-${String(r).padStart(2,"0")}-${String(n).padStart(2,"0")}`}function jc(){const e=new Date;return Ka(e.getFullYear(),e.getMonth()+1,e.getDate())}function Za(e){const[r,n,a]=e.split("-").map(Number);return{year:r,month:n,day:a}}function qc(e){if(!e)return"Seleccionar fecha";const{year:r,month:n,day:a}=Za(e);return!r||!n||!a?"Seleccionar fecha":`${String(a).padStart(2,"0")} ${Cs[n-1]} ${r}`}function Es(e){const{year:r,month:n,day:a}=Za(e);if(!r||!n||!a)return!1;const o=new Date(r,n-1,a).getDay();return o===0||o===6}function Uc({value:e,onChange:r,minDate:n,disableWeekends:a=!1,displayMode:o="inline",className:l=""}){const i=jc(),d=Za(e||i),u=o==="popover",[h,b]=s.useState(!1),f=s.useRef(null),[p,g]=s.useState({horizontal:"left",vertical:"bottom"}),[w,v]=s.useState(d.year),[L,M]=s.useState(d.month),[S,H]=s.useState("days"),C=16,[y,T]=s.useState(0),N=w-7+y,_=Array.from({length:C},(F,Y)=>N+Y);s.useEffect(()=>{if(!u||!h||!f.current)return;const F=f.current.getBoundingClientRect(),Y=8,ae=280,$=340,W=F.left+ae>window.innerWidth-Y,ce=F.right-ae>=Y,B=F.bottom+8+$>window.innerHeight-Y,oe=F.top-8-$>=Y;g({horizontal:W&&ce?"right":"left",vertical:B&&oe?"top":"bottom"})},[u,h]),s.useEffect(()=>{if(!u||!h)return;function F(ae){f.current&&(f.current.contains(ae.target)||b(!1))}function Y(ae){ae.key==="Escape"&&b(!1)}return document.addEventListener("mousedown",F),document.addEventListener("keydown",Y),()=>{document.removeEventListener("mousedown",F),document.removeEventListener("keydown",Y)}},[u,h]);function q(){L===1?(v(F=>F-1),M(12)):M(F=>F-1)}function U(){L===12?(v(F=>F+1),M(1)):M(F=>F+1)}const D=(new Date(w,L-1,1).getDay()+6)%7,K=new Date(w,L,0).getDate(),j=[...Array(D).fill(null),...Array.from({length:K},(F,Y)=>Y+1)];for(;j.length<Ss*7;)j.push(null);const ie=j.slice(0,Ss*7);function Q(F){const Y=Ka(w,L,F);n&&Y<n||a&&Es(Y)||(r(Y),u&&b(!1))}const fe=t.jsx("div",{className:`bonsaif-calendar bonsaif-calendar-picker ${l}`.trim(),children:t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsx("div",{className:"bonsaif-cal-toolbar",children:S==="days"?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:q,"aria-label":"Mes anterior",children:t.jsx(z.HiChevronLeft,{size:16})}),t.jsxs("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>{H("years"),T(0)},children:[t.jsxs("span",{className:"bonsaif-cal-title",children:[Cs[L-1]," ",w]}),t.jsx(z.HiChevronDown,{size:13})]}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:U,"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:()=>T(F=>F-C),"aria-label":"Años anteriores",children:t.jsx(z.HiChevronLeft,{size:16})}),t.jsx("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>H("days"),children:t.jsxs("span",{className:"bonsaif-cal-title",children:[_[0]," – ",_[_.length-1]]})}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>T(F=>F+C),"aria-label":"Años siguientes",children:t.jsx(z.HiChevronRight,{size:16})})]})}),S==="years"?t.jsxs("div",{className:"bonsaif-cal-picker-years",children:[t.jsx("div",{className:"bonsaif-cal-picker-months",children:zc.map((F,Y)=>{const ae=Y+1===L;return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${ae?" is-active":""}`,onClick:()=>M(Y+1),children:F},F)})}),t.jsx("div",{className:"bonsaif-cal-picker-year-grid",children:_.map(F=>{const Y=F===w,ae=F===new Date().getFullYear();return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${Y?" is-active":""}${ae&&!Y?" is-today":""}`,onClick:()=>{v(F),H("days")},children:F},F)})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bonsaif-multi-weekdays bonsaif-cal-picker-weekdays",children:Wc.map(F=>t.jsx("div",{className:"bonsaif-multi-weekday",children:F},F))}),t.jsx("div",{className:"bonsaif-cal-picker-days",children:ie.map((F,Y)=>{if(F===null)return t.jsx("div",{className:"bonsaif-multi-day bonsaif-multi-day-hidden"},Y);const ae=Ka(w,L,F),$=ae===e,W=ae===i,ce=!!(n&&ae<n)||a&&Es(ae);return t.jsx("div",{className:`bonsaif-multi-day${$?" bonsaif-multi-day-selected":""}${W?" bonsaif-multi-day-today":""}${ce?" bonsaif-multi-day-disabled":""}`,children:t.jsx("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:ce,"aria-pressed":$,onClick:()=>!ce&&Q(F),children:F})},Y)})})]})]})});return u?t.jsxs("div",{ref:f,className:`relative w-full ${l}`.trim(),children:[t.jsxs("button",{type:"button",onClick:()=>b(F=>!F),className:"bonsaif-cal-trigger","data-open":h?"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:qc(e)})]}),t.jsx(z.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${h?"rotate-180":""}`})]}),h&&t.jsx("div",{className:"absolute z-50",style:{...p.horizontal==="left"?{left:0}:{right:0},...p.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:fe})]}):fe}function Yt({children:e,className:r="",style:n,as:a="span",followCursor:o=!1,placement:l="top"}){return t.jsx(Pt,{onlyWhenOverflow:!0,as:a,followCursor:o,placement:l,showArrow:!o,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,...n},children:e})}function Qa(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Ja(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Vc(e,r){if(!r.trim())return!0;const n=Ja(r);return Ja(e.label).includes(n)||!!(e.sublabel&&Ja(e.sublabel).includes(n))}function br({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:h="",style:b,dropdownMinWidth:f,dropdownZIndex:p=9999,height:g=40,padding:w="0 10px",searchable:v=!0,minOptionsForSearch:L=6}){const[M,S]=s.useState(!1),[H,C]=s.useState(""),[y,T]=s.useState(-1),[N,_]=s.useState(!1),[q,U]=s.useState({}),D=s.useRef(null),K=s.useRef(null),j=s.useRef(null),ie=s.useRef(null),Q=v&&n.length>=L,fe=n.find(E=>E.value===e)??null,F=l==="ghost",Y=a==="error"?"var(--danger)":M?"var(--primary)":"var(--border)",ae=Q&&H.trim()?n.filter(E=>Vc(E,H)):n,$=s.useCallback(()=>{const E=D.current;if(!(E!=null&&E.isConnected))return;const J=E.getBoundingClientRect();if(J.width<1&&J.height<1||J.bottom<0||J.top>window.innerHeight)return;const ee=Q?272:212,R=window.innerHeight-J.bottom,x=R<ee&&J.top>R,k=8,te=Math.max(J.width,0),de=Math.max(k,window.innerWidth-te-k),re=Math.min(Math.max(k,J.left),de);U({position:"fixed",left:re,top:x?void 0:J.bottom+4,bottom:x?window.innerHeight-J.top+4:void 0,width:J.width,minWidth:Qa(f),zIndex:p})},[f,p,Q]);s.useEffect(()=>_(!0),[]),s.useEffect(()=>{if(!M)return;function E(J){var R,x;const ee=J.target;!((R=D.current)!=null&&R.contains(ee))&&!((x=K.current)!=null&&x.contains(ee))&&(S(!1),C(""))}return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[M]),s.useEffect(()=>{M&&(T(-1),$(),Q&&setTimeout(()=>{var E;return(E=j.current)==null?void 0:E.focus()},0))},[M,Q,$]),s.useEffect(()=>{if(M)return window.addEventListener("resize",$),window.addEventListener("scroll",$,!0),()=>{window.removeEventListener("resize",$),window.removeEventListener("scroll",$,!0)}},[M,$]),s.useEffect(()=>{if(y<0||!ie.current)return;const E=ie.current.children[y];E==null||E.scrollIntoView({block:"nearest"})},[y]);const W=s.useCallback(E=>{r(E),S(!1),C("")},[r]),ce=s.useRef(M);ce.current=M;const B=s.useRef(ae);B.current=ae;const oe=s.useRef(y);oe.current=y;const Z=s.useRef(d);Z.current=d;const X=s.useRef(W);X.current=W,s.useEffect(()=>{function E(J){var k,te;const ee=document.activeElement,R=((k=D.current)==null?void 0:k.contains(ee))??!1,x=((te=K.current)==null?void 0:te.contains(ee))??!1;if(!(!R&&!x)){if(!ce.current){(J.key==="Enter"||J.key===" "||J.key==="ArrowDown")&&(J.preventDefault(),S(!0));return}switch(J.key){case"ArrowDown":J.preventDefault(),T(de=>Math.min(de+1,B.current.length-1));break;case"ArrowUp":J.preventDefault(),T(de=>Math.max(de-1,Z.current?-1:0));break;case"Enter":{J.preventDefault();const de=oe.current,re=B.current;de===-1&&Z.current?X.current(""):re[de]&&!re[de].disabled&&X.current(re[de].value);break}case"Escape":J.preventDefault(),J.stopPropagation(),S(!1),C("");break}}}return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[]);const se=t.jsxs("div",{ref:K,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...q,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[Q&&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:j,value:H,onChange:E=>{C(E.target.value),T(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),H&&t.jsx("button",{type:"button",onMouseDown:E=>{E.preventDefault(),C("")},children:t.jsx(z.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),t.jsxs("ul",{ref:ie,role:"listbox",className:"overflow-y-auto",style:{maxHeight:Q?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[d&&t.jsx("li",{role:"option","aria-selected":e==="",onMouseDown:E=>{E.preventDefault(),W("")},onMouseEnter:()=>T(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:y===-1&&!H.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:d}),ae.map((E,J)=>{const R=J===y,x=E.value===e;return t.jsxs("li",{role:"option","aria-selected":x,onMouseDown:k=>{k.preventDefault(),E.disabled||W(E.value)},onMouseEnter:()=>!E.disabled&&T(J),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:R?"var(--bg-hover)":x?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:E.disabled?"var(--text-muted)":"var(--text-main)",cursor:E.disabled?"not-allowed":"pointer",boxShadow:x?"inset 2px 0 0 var(--primary)":void 0},children:[E.color&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:E.color}}),t.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(Yt,{className:"min-w-0 flex-1",children:E.label}),E.sublabel&&t.jsx(Yt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:E.sublabel})]}),E.badge&&t.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:E.badge})]},E.value)}),ae.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:D,className:`relative ${h||"w-full"}`,style:b,children:[t.jsxs("button",{type:"button",disabled:u,onClick:()=>!u&&S(E=>!E),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:Qa(g),padding:Qa(w),background:F?"transparent":"var(--bg-input)",color:fe?"var(--text-main)":"var(--text-muted)",border:F?"1px solid transparent":`1px solid ${Y}`,opacity:u?.5:1,cursor:u?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":M,"aria-label":o,children:[(fe==null?void 0:fe.color)&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:fe.color}}),t.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:fe?t.jsxs(t.Fragment,{children:[t.jsx(Yt,{className:"min-w-0 flex-1",children:fe.label}),i&&fe.sublabel&&t.jsx(Yt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:fe.sublabel})]}):t.jsx(Yt,{className:"min-w-0 flex-1",children:c})}),fe&&d?t.jsx("span",{role:"button",tabIndex:-1,onMouseDown:E=>{E.preventDefault(),E.stopPropagation(),W("")},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:M?"rotate(180deg)":"rotate(0deg)"}})]}),M&&N&&pt.createPortal(se,document.body)]})}const Xc={sm:"h-4 w-4",md:"h-5 w-5"};function Yc(e,r){if(typeof e=="function"){e(r);return}e&&(e.current=r)}const Fn=s.forwardRef(function({label:r,description:n,error:a,size:o="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:d,...u},h){const b=s.useRef(null);return s.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,Yc(h,f)},type:"checkbox",disabled:d,"aria-checked":l?"mixed":u["aria-checked"],"aria-invalid":!!a||u["aria-invalid"],className:`peer ${Xc[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})]})]})}),Ms=32767;function _n(e){let r=String(e??"");return r=r.split("\0").join(""),r.length<=Ms?r:`${r.slice(0,Ms-1)}…`}const Pn=[25,50,100,200,500];let Ot={dataTable:{pageSizeOptions:[...Pn]}};function Gc(){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 Ra(){const e=Ot.dataTable.preferencesEndpoint,r=Gc();return e&&e.trim().length>0?e.trim().replace(/\/+$/,""):r}function Kc(e){if(!Array.isArray(e))return[...Pn];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:[...Pn]}function Ts(e){if(typeof e!="string")return;const r=e.trim();if(r)return r.replace(/\/+$/,"")}function Zc(e){if(!e||typeof e!="object"||!e.dataTable)return;const r=Ts(e.dataTable.preferencesEndpoint);Ot={...Ot,dataTable:{...Ot.dataTable,pageSizeOptions:Kc(e.dataTable.pageSizeOptions),preferencesEndpoint:r??Ot.dataTable.preferencesEndpoint}}}function Qc(){return{dataTable:{pageSizeOptions:[...Ot.dataTable.pageSizeOptions]}}}function ln(){return[...Ot.dataTable.pageSizeOptions]}function Jc(){Ot={dataTable:{pageSizeOptions:[...Pn]}}}function Rc(e){Ot={...Ot,dataTable:{...Ot.dataTable,preferencesEndpoint:Ts(e)}}}const zn=[{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"}],ed=zn.map(e=>({value:e.value,label:e.label})),td=12,rd={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},$s={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},nd="bonsaif-ui:datatable:",ad="[&_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",od=[],sd=52;function Gt(e){if(!e)return 150;const r=parseInt(e,10);return isNaN(r)||r<=0?150:r}function As(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.filterOptionValues&&Object.keys(e.filterOptionValues).length>0||e.sort||typeof e.bql=="string"||Array.isArray(e.bqlHistory)&&e.bqlHistory.length>0||typeof e.pageSize=="number"))}function Ls(e){return`${nd}${e}`}function Wn(e){try{const r=window.localStorage.getItem(Ls(e));if(!r)return null;const n=JSON.parse(r);return n&&typeof n=="object"?n:null}catch{return null}}function ld(e,r){try{window.localStorage.setItem(Ls(e),JSON.stringify(r))}catch{}}function id(e,r){if(e===!0)return{...$s};if(e===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(r&&e==null)return{...$s};const n={...rd,...e??{}};return r&&(typeof e!="object"||e.pagination!==!1)&&(n.pagination=!0),n}function Ds(...e){return e.reduce((r,n)=>({...r,...n??{}}),{})}function eo(e,r,n){return typeof e!="number"||e<=0?n:bn(r).includes(e)?e:n}function cn(e){if(!e||typeof e!="object")return!1;const r=e;return typeof r.key=="string"&&(r.dir==="asc"||r.dir==="desc")}function dn(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 cd(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=[...new Set(o.filter(i=>typeof i=="string"&&i.trim().length>0))];return l.length>0?[[a,l]]:[]});return Object.fromEntries(n)}function dd(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=Object.entries(e).flatMap(([a,o])=>{if(!r.has(a)||!o||typeof o!="object")return[];const l=Object.fromEntries(Object.entries(o).flatMap(([i,c])=>typeof i=="string"&&i.trim()&&typeof c=="string"&&c.trim()?[[i,c]]:[]));return Object.keys(l).length>0?[[a,l]]:[]});return Object.fromEntries(n)}function un(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=new Set(zn.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 Nt(e,r){if(hr(e))return sd;const n=e.minWidth??80,a=e.maxWidth??1/0;return Math.min(a,Math.max(n,r))}function ud(e){const r=window.getComputedStyle(e);return parseFloat(r.paddingLeft)+parseFloat(r.paddingRight)}function hr(e){return e.key==="actions"||e.key==="acciones"?!0:typeof e.header=="string"&&e.header.trim().toLowerCase()==="acciones"}function to(e){return e.sticky===!0}function Os(e){return!(e.reorderable===!1||e.sticky&&e.reorderable!==!0)}function jn(e,r){const a=[...e.filter(o=>r.includes(o))];for(let o=0;o<r.length;o+=1){const l=r[o];if(a.includes(l))continue;let i=a.length;for(let c=o-1;c>=0;c-=1){const d=r[c],u=a.indexOf(d);if(u!==-1){i=u+1;break}}if(i===a.length)for(let c=o+1;c<r.length;c+=1){const d=r[c],u=a.indexOf(d);if(u!==-1){i=u;break}}a.splice(i,0,l)}return a}function er(e,r){const n=r.filter(to).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 fd(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 tr(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 bd(e){return e==null||e===""?"(Vacio)":e instanceof Date?e.toLocaleDateString():String(e)}function $r(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map($r).join(" ").trim():s.isValidElement(e)?$r(e.props.children):""}function qn(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?bd(n):$r(n).trim()}function fn(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=fn(e),a=fn(r);return n!==null&&a!==null?n-a:e.localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})}function bn(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:ln()}function hd(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=zn.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(b=>({value:b,number:fn(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(fn).filter(b=>b!==null);if(d.length===0)return!1;const u=d.reduce((b,f)=>b+f,0)/d.length,h=fn(e);return h===null?!1:r.operator==="aboveAverage"?h>u:h<u}default:return!0}}function Hs({children:e,className:r="",style:n}){return t.jsx(Pt,{onlyWhenOverflow:!0,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,...n},children:e})}function ro({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:h,expandedRowIds:b,defaultExpandedRowIds:f=[],onExpandedRowIdsChange:p,expandOnRowClick:g=!1,selected:w,onToggleOne:v,onToggleAll:L,getRowSelectable:M,highlightSelected:S=!0,rowClassName:H,getRowCategory:C,stickyHeader:y=!0,pageSize:T=25,pageSizeOptions:N,pageSizeSelectWidth:_=62,pageSizeSelectHeight:q=30,pageSizeSelectPadding:U="0 7px",totalRows:D,page:K,onPageChange:j,onPageSizeChange:ie,storageKey:Q,stickyFirstColumn:fe=!1,bottomOffset:F=0,compact:Y=!0,restrictHeight:ae=!0,maxHeight:$,minTableWidth:W,enableColumnVisibility:ce=!0,enableColumnFilters:B=!0,hiddenColumnKeys:oe,defaultHiddenColumnKeys:Z=od,onHiddenColumnKeysChange:X,columnVisibilityLabel:se="Columnas",enableBql:E=!1,bqlValue:J,defaultBqlValue:ee="",onBqlChange:R,bqlDescription:x="Filtra registros con Bonsaif Query Language",bqlPlaceholder:k=`status = activo
2
+ rol IN (admin, employee)`,bqlQuickFilters:te=[],bqlExamples:de=[],bqlSuggestions:re=[],bqlActiveFilters:ge,bqlError:Ee,onQueryChange:Le,persistState:gt,onPreferencesReady:Tt,enableExport:nt=!1,exportFilename:ot="datos",onExportCsv:ue,onExportPdf:$e}){var gc;const ne=id(gt,Q),He=Object.values(ne).some(Boolean),Fe=e.map(m=>m.key).join(","),Ge=Z.join(","),Ye=s.useRef(e),ze=s.useRef(Z);Ye.current=e,ze.current=Z;const[Je,st]=s.useState(!Q||!He),$t=s.useRef(null),he=s.useRef(!Q),ye=s.useRef(!1),_e=s.useRef(Tt);_e.current=Tt;const We=s.useRef(!Q||!He?Q??"__none__":null),je=oe!==void 0,[ht,lt]=s.useState(()=>tr(Z,e)),Ke=tr(je?oe:ht,e),[Re,ft]=s.useState(!1),[dt,pr]=s.useState("filter"),[mt,gr]=s.useState(null),[At,Ue]=s.useState(""),[it,ir]=s.useState({}),[yt,Ft]=s.useState({}),vr=s.useRef({}),cr=s.useRef({});function Kr(m,A){if(!m)return;const V=cd(m.filterOptionValues,A),O=dd(m.filterOptionLabels,A);Object.keys(V).length>0&&(vr.current={...vr.current,...V}),Object.keys(O).length>0&&(cr.current={...cr.current,...O})}const P=b!==void 0,[G,pe]=s.useState(f),me=J!==void 0,[Me,ke]=s.useState(ee),Ie=me?J:Me,[Pe,ct]=s.useState(Ie),[Ze,xt]=s.useState(!1),[Zt,wt]=s.useState(!1),[yr,Qt]=s.useState(!1),[dr,Zr]=s.useState([]),Qr=s.useRef(null),Jr=s.useRef(null),xr=s.useRef(null),Ut=s.useRef(R);Ut.current=R;const Ca=s.useRef(T);Ca.current=T;const Sa=s.useRef(N);Sa.current=N;const Oh=Array.isArray(N)?N.join(","):"",Qo=s.useRef(null),qi=s.useRef(null),Jo=s.useRef(null),Ui=s.useRef(0),[Hh,Bh]=s.useState({}),[Ih,Fh]=s.useState({}),[Mn,Ea]=s.useState(!1),Ro=s.useRef(null),Ma=s.useRef(null),[_h,Ph]=s.useState({}),Vi=s.useRef(null),Tn=s.useRef(null),[es,Xi]=s.useState(r.length>0||a||c===!1),Yi=(m,A)=>50+(m*17+A*13+7)%40,Lt=s.useRef(null),[zh,Wh]=s.useState(void 0),[Gi,jh]=s.useState(0),[qh,Uh]=s.useState(!1);s.useEffect(()=>{function m(){Uh(window.innerWidth<640)}if(!ae||$!==void 0)return m(),window.addEventListener("resize",m),()=>window.removeEventListener("resize",m);const V=T!==!1?48:0,O=12;function le(){if(m(),!Lt.current)return;const we=Lt.current.getBoundingClientRect().top;Wh(Math.max(120,window.innerHeight-we-V-O-F))}le(),window.addEventListener("resize",le);const be=typeof ResizeObserver<"u"&&Lt.current?new ResizeObserver(()=>le()):null;return Lt.current&&be&&be.observe(Lt.current),()=>{window.removeEventListener("resize",le),be==null||be.disconnect()}},[a,T,F,ae,$,Je,r.length]);const Ki=ae?$??zh:void 0;s.useEffect(()=>{const m=Lt.current;if(!m)return;const A=()=>jh(m.clientWidth);if(A(),typeof ResizeObserver>"u")return window.addEventListener("resize",A),()=>window.removeEventListener("resize",A);const V=new ResizeObserver(A);return V.observe(m),()=>V.disconnect()},[a,Je,r.length]),s.useEffect(()=>{if(c===!1||a||r.length>0){Xi(!0);return}if(es)return;const m=window.setTimeout(()=>{Xi(!0)},c);return()=>window.clearTimeout(m)},[r.length,c,es,a]);const[Rr,en]=s.useState(()=>er(e.map(m=>m.key),e)),[wr,tn]=s.useState(()=>Object.fromEntries(e.map(m=>[m.key,Nt(m,Gt(m.width))]))),[et,Nr]=s.useState(null),[Vh,Ta]=s.useState(1),[$a,Aa]=s.useState(T===!1?0:T);s.useEffect(()=>{var Oe;const m=Ye.current,A=ze.current,V=m.map(Ce=>Ce.key),O=new Set(V),le=()=>{var Ce;ye.current||(ye.current=!0,(Ce=_e.current)==null||Ce.call(_e))};if(!Q||!He){ne.layout&&en(er(V,m)),je||lt(tr(A,m)),he.current=!1,st(!0),le();return}let be=!1;const we=We.current===Q;we||(he.current=!1,st(!1),ye.current=!1);const Te=Wn(Q);if(As(Te)&&!we){const Ce=Te,Ne=bn(Sa.current??ln()),Se=Ca.current,Sr=Se===!1?0:Se,fr=ne.layout?Ce==null?void 0:Ce.columnOrder:void 0,Er=Array.isArray(fr)?fr.filter(Qe=>V.includes(Qe)):[],Mr=er(Er.length>0?jn(Er,V):V,m),Tr=Object.fromEntries(m.map(Qe=>[Qe.key,Nt(Qe,Gt(Qe.width))])),an=ne.layout?(Ce==null?void 0:Ce.columnWidths)??{}:{},On=Object.fromEntries(m.map(Qe=>[Qe.key,Nt(Qe,an[Qe.key]??Tr[Qe.key])])),on=tr(ne.layout?(Ce==null?void 0:Ce.hiddenColumnKeys)??A:A,m);if(ne.layout&&(en(Mr),tn(On)),je||lt(on),ne.filters&&Jr.current!==Q&&(Jr.current=Q,Kr(Ce,O),ir(dn(Ce==null?void 0:Ce.filters,O)),Ft(un(Ce==null?void 0:Ce.conditionFilters,O))),ne.sort){const Qe=cn(Ce==null?void 0:Ce.sort)?Ce.sort:null;Nr(Qe&&O.has(Qe.key)?Qe:null)}if(ne.bql){if(Qr.current!==Q){Qr.current=Q;const Qe=typeof(Ce==null?void 0:Ce.bql)=="string"?Ce.bql:ee;me?(Oe=Ut.current)==null||Oe.call(Ut,Qe):ke(Qe)}Zr(Array.isArray(Ce==null?void 0:Ce.bqlHistory)?Ce.bqlHistory.filter(Qe=>typeof Qe=="string"):[])}ne.pagination&&xr.current!==Q&&(xr.current=Q,Aa(eo(Ce==null?void 0:Ce.pageSize,Ne,Sr))),We.current=Q,st(!0),le()}const De=`${Ra()??"/api/user/preferences/datatables"}?key=${encodeURIComponent(Q)}`,Ve=new AbortController,xe=window.setTimeout(()=>Ve.abort(),2500);return fetch(De,{cache:"no-store",signal:Ve.signal}).then(Ce=>Ce.ok?Ce.json():null).then(Ce=>{var vc;if(be)return;const Ne=Wn(Q),Se=Ds(As(Ce==null?void 0:Ce.settings)?Ce==null?void 0:Ce.settings:null,Ne),Sr=bn(Sa.current??ln()),fr=Ca.current,Er=fr===!1?0:fr,Mr=ne.layout?Se==null?void 0:Se.columnOrder:void 0,Tr=Array.isArray(Mr)?Mr.filter(at=>V.includes(at)):[],an=er(Tr.length>0?jn(Tr,V):V,m),On=Object.fromEntries(m.map(at=>[at.key,Nt(at,Gt(at.width))])),on=ne.layout?(Se==null?void 0:Se.columnWidths)??{}:{},Qe=Object.fromEntries(m.map(at=>[at.key,Nt(at,on[at.key]??On[at.key])])),sn=tr(ne.layout?(Se==null?void 0:Se.hiddenColumnKeys)??A:A,m);if(ne.layout&&(en(an),tn(Qe)),je||lt(sn),ne.filters&&Jr.current!==Q&&(Jr.current=Q,Kr(Se,O),ir(dn(Se==null?void 0:Se.filters,O)),Ft(un(Se==null?void 0:Se.conditionFilters,O))),ne.sort){const at=cn(Se==null?void 0:Se.sort)?Se.sort:null;Nr(at&&O.has(at.key)?at:null)}if(ne.bql){if(Qr.current!==Q){Qr.current=Q;const at=typeof(Se==null?void 0:Se.bql)=="string"?Se.bql:ee;me?(vc=Ut.current)==null||vc.call(Ut,at):ke(at)}Zr(Array.isArray(Se==null?void 0:Se.bqlHistory)?Se.bqlHistory.filter(at=>typeof at=="string"):[])}let tt;ne.pagination&&(tt=eo(Se==null?void 0:Se.pageSize,Sr,Er),xr.current!==Q&&(xr.current=Q,Aa(tt))),$t.current=JSON.stringify({columnOrder:an,columnWidths:Qe,hiddenColumnKeys:sn,filters:dn(Se==null?void 0:Se.filters,O),conditionFilters:un(Se==null?void 0:Se.conditionFilters,O),sort:cn(Se==null?void 0:Se.sort)?Se.sort:null,bql:typeof(Se==null?void 0:Se.bql)=="string"?Se.bql:"",bqlHistory:Array.isArray(Se==null?void 0:Se.bqlHistory)?Se.bqlHistory:[],pageSize:ne.pagination&&fr!==!1?tt:void 0}),he.current=!0}).catch(()=>{var Ce;if(!be){const Ne=Wn(Q),Se=bn(Sa.current??ln()),Sr=Ca.current,fr=Sr===!1?0:Sr,Er=ne.layout?Ne==null?void 0:Ne.columnOrder:void 0,Mr=Array.isArray(Er)?Er.filter(tt=>V.includes(tt)):[],Tr=er(Mr.length>0?jn(Mr,V):V,m),an=Object.fromEntries(m.map(tt=>[tt.key,Nt(tt,Gt(tt.width))])),On=ne.layout?(Ne==null?void 0:Ne.columnWidths)??{}:{},on=Object.fromEntries(m.map(tt=>[tt.key,Nt(tt,On[tt.key]??an[tt.key])]));ne.layout&&(en(Tr),tn(on));const Qe=tr(ne.layout?(Ne==null?void 0:Ne.hiddenColumnKeys)??A:A,m);if(je||lt(Qe),ne.filters&&Jr.current!==Q&&(Jr.current=Q,Kr(Ne,O),ir(dn(Ne==null?void 0:Ne.filters,O)),Ft(un(Ne==null?void 0:Ne.conditionFilters,O))),ne.sort){const tt=cn(Ne==null?void 0:Ne.sort)?Ne.sort:null;Nr(tt&&O.has(tt.key)?tt:null)}if(ne.bql){if(Qr.current!==Q){Qr.current=Q;const tt=typeof(Ne==null?void 0:Ne.bql)=="string"?Ne.bql:ee;me?(Ce=Ut.current)==null||Ce.call(Ut,tt):ke(tt)}Zr(Array.isArray(Ne==null?void 0:Ne.bqlHistory)?Ne.bqlHistory.filter(tt=>typeof tt=="string"):[])}let sn;ne.pagination&&(sn=eo(Ne==null?void 0:Ne.pageSize,Se,fr),xr.current!==Q&&(xr.current=Q,Aa(sn))),$t.current=JSON.stringify({columnOrder:Tr,columnWidths:on,hiddenColumnKeys:Qe,filters:dn(Ne==null?void 0:Ne.filters,O),conditionFilters:un(Ne==null?void 0:Ne.conditionFilters,O),sort:cn(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:ne.pagination&&Sr!==!1?sn:void 0}),he.current=!0}}).finally(()=>{window.clearTimeout(xe),be||(We.current=Q,st(!0),le())}),()=>{be=!0,Ve.abort(),window.clearTimeout(xe)}},[Q,He,Fe,Ge,je,ne.layout,ne.filters,ne.sort,ne.bql,ne.pagination,me,ee,Oh]),s.useEffect(()=>{if(!Q||!Je||!He||!he.current)return;const m={};ne.layout&&(m.columnOrder=Rr,m.columnWidths=wr,m.hiddenColumnKeys=Ke),ne.filters&&(m.filters=it,m.conditionFilters=yt,m.filterOptionValues=vr.current,m.filterOptionLabels=cr.current),ne.sort&&(m.sort=et),ne.bql&&(m.bql=Ie,m.bqlHistory=dr),ne.pagination&&T!==!1&&(m.pageSize=$a);const A=Wn(Q),V=Ds(A,m),O=JSON.stringify(V);if(O===$t.current)return;ld(Q,V),$t.current=O;const le=window.setTimeout(()=>{const be=Ra()??"/api/user/preferences/datatables";fetch(be,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:Q,settings:V})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(le)},[Rr,wr,Ke,it,yt,et,Ie,dr,$a,T,Q,Je,He,ne.layout,ne.filters,ne.sort,ne.bql,ne.pagination,r]),s.useEffect(()=>{en(m=>{const A=e.map(V=>V.key);return er(jn(m,A),e)})},[Fe,e]);const Zi=er(Rr,e).map(m=>e.find(A=>A.key===m)).filter(m=>!!m),Dt=Zi.filter(m=>!Ke.includes(m.key)),Qi=e.some(to),Xh=Object.keys(it).length,Yh=Object.keys(yt).length,ts=Xh+Yh;function rs(m){var Te;const A=!!(j&&ie),V=new Map,O=(ve,Be)=>{const De=ve.trim();if(!De)return;const Ve=(Be??De).trim()||De;V.has(De)?Be!=null&&Be.trim()&&V.get(De)===De&&V.set(De,Ve):V.set(De,Ve)};for(const ve of m.filterOptions??[])typeof ve=="string"?O(ve):ve!=null&&ve.value&&O(ve.value,ve.label);if(A){const ve=cr.current[m.key]??{};for(const Be of vr.current[m.key]??[])O(Be,ve[Be])}for(const ve of r){const Be=qn(m,ve),De=((Te=m.filterOptionLabel)==null?void 0:Te.call(m,ve))??void 0;O(Be,De??void 0)}for(const ve of it[m.key]??[])O(ve);const le=ve=>/^[a-f\d]{24}$/i.test(ve.trim()),be=new Map;for(const[ve,Be]of V){const De=Be.trim().toLowerCase(),Ve=be.get(De)??[];Ve.push(ve),be.set(De,Ve)}for(const ve of be.values()){if(ve.length<2)continue;const Be=ve.find(le)??ve.slice().sort((De,Ve)=>De.localeCompare(Ve))[0];for(const De of ve)De!==Be&&V.delete(De)}const we=Array.from(V.keys()).sort((ve,Be)=>{const De=V.get(ve)??ve,Ve=V.get(Be)??Be;return De.localeCompare(Ve,void 0,{numeric:!0,sensitivity:"base"})});return A&&(vr.current[m.key]=we,cr.current[m.key]=Object.fromEntries(V.entries())),we.map(ve=>({value:ve,label:V.get(ve)??ve}))}function Gh(){const m=e.find(A=>A.key===mt);return m?rs(m):[]}function Kh(m){return!!(B&&!hr(m)&&(m.filterValue||m.sortKey||rs(m).length>0))}function ns(m,A){ir(V=>{const O={...V};return O[m]=A,O})}function Zh(m,A,V,O){const le=it[m]??[],be=O?le.includes(A)?le.filter(Te=>Te!==A):[...le,A]:[A];V.length>0&&be.length===V.length&&V.every(Te=>be.includes(Te))?La(m):ns(m,be)}function La(m){ir(A=>{const V={...A};return delete V[m],V})}function Da(m,A){Ft(V=>{const O={...V};return A?O[m]=A:delete O[m],O})}function Ji(m){Da(m,null)}function Qh(){ir({}),Ft({})}function Jh(m){me||ke(m),R==null||R(m)}function Ri(m){const A=m.trim();ct(A),(R==null?void 0:R(A))!==!1&&(me||ke(A),xt(!1),wt(!1),Qt(!1),A&&Zr(O=>[A,...O.filter(le=>le!==A)].slice(0,td)))}function ec(){ct(""),Jh(""),xt(!1),wt(!1),Qt(!1)}function as(m,A){ct(m),A&&(A.style.height="auto",A.style.height=`${Math.min(A.scrollHeight,180)}px`)}function Oa(m){const A=m.trim();if(!A)return;Ui.current=Date.now()+500;const V=Pe.replace(/\s+$/u,""),O=V.length===0?A:V.split(`
3
+ `).map(le=>le.trim()).includes(A)?V:`${V}
4
+ ${A}`;as(O,Jo.current??void 0),requestAnimationFrame(()=>{const le=Jo.current;if(!le)return;le.focus();const be=le.value.length;le.setSelectionRange(be,be),as(le.value,le)})}s.useEffect(()=>{ct(Ie)},[Ie]);const Ha=s.useCallback(()=>{const m=Qo.current;if(!m)return;const A=m.getBoundingClientRect(),V=12,O=8,le=Math.min(780,Math.max(320,window.innerWidth-32)),be=Math.max(V,window.innerWidth-le-V),we=Math.min(Math.max(V,A.left),be),Te=A.bottom+O,ve=window.innerHeight-A.top+O,Be=window.innerHeight-Te-V,De=A.top-V-O,Ve=Be<280&&De>Be,xe=Math.max(240,Ve?De:Be);Bh({position:"fixed",zIndex:1e4,left:we,top:Ve?void 0:Te,bottom:Ve?ve:void 0,width:le,maxWidth:"calc(100vw - 24px)",maxHeight:xe,overflowY:"auto"})},[]);s.useEffect(()=>{if(!Ze)return;function m(O){var be,we;if(Date.now()<Ui.current)return;const le=O.target;(be=Qo.current)!=null&&be.contains(le)||(we=qi.current)!=null&&we.contains(le)||(xt(!1),wt(!1),Qt(!1))}function A(O){O.key==="Escape"&&(xt(!1),wt(!1),Qt(!1))}function V(){Ha()}return Ha(),document.addEventListener("mousedown",m),window.addEventListener("keydown",A),window.addEventListener("resize",V),window.addEventListener("scroll",V,!0),()=>{document.removeEventListener("mousedown",m),window.removeEventListener("keydown",A),window.removeEventListener("resize",V),window.removeEventListener("scroll",V,!0)}},[Ze,Ha]);function tc(m){const A=tr(m,e);je||lt(A),X==null||X(A)}function Rh(m){tc(Ke.includes(m)?Ke.filter(A=>A!==m):[...Ke,m])}function em(){tc([])}const Ba=s.useCallback(m=>{var le;if(m!=null&&m.isConnected)return m;if(!mt)return null;const V=`[role="columnheader"][data-dt-column-key="${typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(mt):mt.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"] button[aria-haspopup="menu"]`,O=((le=Lt.current)==null?void 0:le.querySelector(V))??document.querySelector(V);return O&&(Tn.current=O),O},[mt]),$n=s.useCallback((m=Tn.current)=>{const A=Ba(m);if(!A)return;const O=(A.closest("th")??A.closest("[role='columnheader']")??A.closest("[data-dt-column-key]")??A).getBoundingClientRect();if(O.width<1&&O.height<1||O.bottom<0||O.top>window.innerHeight)return;const le=Math.min(292,Math.max(240,window.innerWidth-16)),be=8,we=Math.max(be,window.innerWidth-le-be),Te=Math.min(Math.max(be,O.left),we),ve=window.innerHeight-O.bottom,Be=O.bottom+6,De=window.innerHeight-O.top+6,xe=ve<360&&O.top>ve?void 0:Be,Oe=xe===void 0?De:void 0,Ce=Math.max(220,xe===void 0?O.top-16:window.innerHeight-Be-8),Ne={position:"fixed",zIndex:9999,left:Te,top:xe,bottom:Oe,width:le,maxWidth:"calc(100vw - 16px)",maxHeight:Ce,"--dt-column-menu-max-height":`${Ce}px`};Fh(Ne)},[Ba]);function rc(m,A,V=null){m.preventDefault(),m.stopPropagation();const O=Tn.current===m.currentTarget&&dt===A&&mt===V;if(Re&&O){ft(!1),gr(null);return}if(Tn.current=m.currentTarget,pr(A),gr(V),Ue(""),A==="filter"&&V){const le=e.find(we=>we.key===V),be=it[V];if(le&&(be!=null&&be.length)){const we=rs(le),Te=new Map(we.map(De=>[De.label.trim().toLowerCase(),De.value])),ve=[...new Set(be.map(De=>we.some(Ve=>Ve.value===De)?De:Te.get(De.trim().toLowerCase())??De))];(ve.length!==be.length||ve.some((De,Ve)=>De!==be[Ve]))&&(we.length>0&&ve.length===we.length&&we.every(De=>ve.includes(De.value))?La(V):ns(V,ve))}}$n(m.currentTarget),ft(!0)}function tm(m){if(hr(m))return;const A=Lt.current;if(!A)return;const O=Array.from(A.querySelectorAll("[data-dt-column-key]")).filter(le=>le.dataset.dtColumnKey===m.key).reduce((le,be)=>{const we=be.querySelector("[data-dt-autofit-content]"),Te=we?we.scrollWidth:Math.max(be.scrollWidth,be.offsetWidth);return Math.max(le,Math.ceil(Te+ud(be)))},0);O<=0||tn(le=>({...le,[m.key]:Nt(m,O+12)}))}s.useEffect(()=>{tn(m=>{const A=Object.fromEntries(e.map(V=>[V.key,Nt(V,Gt(V.width))]));return Object.fromEntries(e.map(V=>[V.key,Nt(V,m[V.key]??A[V.key])]))})},[Fe,e]),s.useEffect(()=>{je||lt(m=>tr(m,e))},[Fe,e,je]),s.useEffect(()=>{function m(O){var Te;const le=O.target,be=O.target;if(be!=null&&be.closest("[data-bonsaif-select-dropdown='true']"))return;const we=Ba(Tn.current);!((Te=Vi.current)!=null&&Te.contains(le))&&!(we!=null&&we.contains(le))&&(ft(!1),gr(null))}function A(O){O.key==="Escape"&&(ft(!1),gr(null))}function V(){$n()}return Re&&(document.addEventListener("mousedown",m),window.addEventListener("keydown",A),window.addEventListener("resize",V),window.addEventListener("scroll",V,!0)),()=>{document.removeEventListener("mousedown",m),window.removeEventListener("keydown",A),window.removeEventListener("resize",V),window.removeEventListener("scroll",V,!0)}},[Re,Ba,$n]),s.useLayoutEffect(()=>{!Re||!mt||$n()},[Re,mt,it,yt,r,$n]);const An=s.useRef(null);s.useEffect(()=>{function m(V){const O=An.current;if(!O)return;const le=V.clientX-O.startX,be=e.find(we=>we.key===O.colKey);be&&tn(we=>({...we,[O.colKey]:Nt(be,O.startWidth+le)}))}function A(){An.current&&(An.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",m),document.addEventListener("pointerup",A),()=>{document.removeEventListener("pointermove",m),document.removeEventListener("pointerup",A)}},[e]);const Ln=s.useRef(null),[nc,os]=s.useState(null);function rm(m,A){const V=e.find(O=>O.key===m);if(!V||!Os(V)){A.preventDefault();return}Ln.current=Rr.indexOf(m),A.dataTransfer.effectAllowed="move"}function nm(m,A){A.preventDefault(),A.dataTransfer.dropEffect="move";const V=Rr.indexOf(m);nc!==V&&os(V)}function am(m,A){A.preventDefault();const V=Ln.current,O=Rr.indexOf(m);V!==null&&V!==O&&en(le=>{const be=[...le],[we]=be.splice(V,1);return be.splice(O,0,we),er(be,e)}),Ln.current=null,os(null)}function om(){Ln.current=null,os(null)}function sm(m){m.sortKey&&Nr(A=>(A==null?void 0:A.key)===m.key?{key:m.key,dir:A.dir==="asc"?"desc":"asc"}:{key:m.key,dir:"asc"})}s.useEffect(()=>{Ta(1)},[r]),s.useEffect(()=>{Ta(1)},[yt,it]);const Vt=!!(j&&ie),ur=T!==!1,ss=s.useMemo(()=>bn(N??ln()),[N]),bt=Vt?K??1:Vh,ac=ur&&$a<1?typeof T=="number"&&T>0?T:ss[0]??25:$a,Xt=Vt||ur?ac:r.length,_t=!!w&&!!v&&!!L,ls=s.useMemo(()=>M?r.filter(m=>M(m)):r,[r,M]),rn=!!u,oc=s.useMemo(()=>new Set(P?Array.from(b??[]):G),[P,b,G]),lm=(rn?40:0)+(_t?40:0),is=!qh&&(Qi||fe),Ia=(()=>{if(!is)return{};let m=lm;const A={};return Dt.forEach((V,O)=>{(to(V)||!Qi&&fe&&O===0)&&(A[V.key]=m,m+=wr[V.key]??Nt(V,Gt(V.width)))}),A})(),cs=Object.keys(Ia),ds=cs.length>0?cs[cs.length-1]:null,sc=_t&&ls.length>0&&ls.every(m=>w.has(n(m))),im=_t&&w.size>0&&ls.some(m=>w.has(n(m)))&&!sc,Fa=s.useMemo(()=>{if(Vt)return r;const m=Object.entries(it),A=Object.entries(yt);return m.length===0&&A.length===0?r:r.filter(V=>m.every(([O,le])=>{const be=e.find(we=>we.key===O);return be?le.includes(qn(be,V)):!0})&&A.every(([O,le])=>{const be=e.find(Te=>Te.key===O);if(!be)return!0;const we=r.map(Te=>qn(be,Te));return hd(qn(be,V),le,we)}))},[yt,it,e,r,Vt]),kr=s.useMemo(()=>{if(!et)return Fa;const m=e.find(A=>A.key===et.key&&A.sortKey);return m!=null&&m.sortKey?[...Fa].sort((A,V)=>{const O=A[m.sortKey],le=V[m.sortKey],be=O===le?0:O==null?1:le==null||O<le?-1:1;return et.dir==="asc"?be:-be}):Fa},[Fa,et,e]),lc=s.useMemo(()=>{if(Vt||!ur)return kr;const m=(bt-1)*Xt;return kr.slice(m,m+Xt)},[kr,Vt,ur,bt,Xt]),Jt=Vt?D??r.length:kr.length,us=ur?Math.max(1,Math.ceil(Jt/Xt)):1,cm=Math.min(...ss),dm=ur&&(Jt>Xt||Jt>cm),um=ur?(bt-1)*Xt+1:1,fm=ur?Math.min(bt*Xt,Jt):Jt;function fs(m){if(a)return;const A=Math.max(1,Math.min(m,us));Vt?j(A):Ta(A)}function bm(m){a||(Q&&(xr.current=Q),Aa(m),Vt?(ie(m),j(1)):(Ta(1),ie==null||ie(m)))}function ic(m){const A=new Set(oc);A.has(m)?A.delete(m):A.add(m);const V=Array.from(A);P||pe(V),p==null||p(V)}s.useEffect(()=>{Le==null||Le({bql:Ie,filters:it,conditionFilters:yt,sort:et,page:bt,pageSize:Xt,hiddenColumnKeys:Ke})},[Ie,it,yt,et,bt,Xt,Ke,Le]);const cc=m=>m==="center"?"justify-center text-center":m==="right"?"justify-end text-right":"justify-start text-left",hm="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",bs="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%)",qe="color-mix(in srgb, var(--border) 62%, var(--bg-card))",Cr="color-mix(in srgb, var(--primary) 24%, var(--border))",_a=`inset 0 0 0 1px ${qe}`,dc=Dt.reduce((m,A)=>m+(wr[A.key]??Gt(A.width)),(rn?40:0)+(_t?40:0)),uc=typeof W=="number"?W:typeof W=="string"?Number(((gc=W.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:gc[1])??NaN):NaN,Dn=Number.isFinite(uc)?Math.max(dc,uc,Gi):Math.max(dc,Gi),Pa=W??Dn,nn=`${rn?"40px ":""}${_t?"40px ":""}${Dt.map(m=>`${wr[m.key]??Gt(m.width)}px`).join(" ")}`;s.useEffect(()=>{et&&Ke.includes(et.key)&&Nr(null)},[Ke,et]);function fc(m){return m?typeof m=="string"?{key:m,label:m}:m:null}const za=()=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:nn,background:bs,borderBottom:`1px solid ${Cr}`},children:[rn&&t.jsx("div",{role:"columnheader",className:`${Y?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${Cr}`,borderRight:`1px solid ${qe}`}}),_t&&t.jsx("div",{role:"columnheader",className:`${Y?"px-2 py-1.5":"px-3 py-2.5"} flex w-10 items-center justify-center`,style:is?{position:"sticky",left:0,zIndex:12,background:bs,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${Cr}`,borderRight:`1px solid ${qe}`}:{borderBottom:`1px solid ${Cr}`,borderRight:`1px solid ${qe}`},children:t.jsx(Fn,{size:"sm",checked:sc,indeterminate:im,onChange:L,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),Dt.map((m,A)=>{const V=(et==null?void 0:et.key)===m.key,O=!!m.sortKey,le=hr(m),be=Ia[m.key],we=be!==void 0,Te=m.key===ds,ve=Os(m),Be=nc===A,Ve=(wr[m.key]??Gt(m.width))<120,xe=Object.prototype.hasOwnProperty.call(it,m.key)||Object.prototype.hasOwnProperty.call(yt,m.key);return t.jsxs("div",{role:"columnheader","data-dt-column-key":m.key,className:`group select-none ${Ve?"text-left":cc(m.align)}`,style:{...we?{position:"sticky",left:be,zIndex:12,background:bs,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:Te?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Cr}`:`inset 0 -1px 0 ${Cr}`,borderRight:`1px solid ${qe}`}:{position:"relative",borderBottom:`1px solid ${Cr}`,borderRight:`1px solid ${qe}`},color:V?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:Be?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:le?Y?"7px 6px":"9px 8px":Y?"8px 6px 10px":"10px 8px 12px"},onDragOver:Oe=>{(ve||Ln.current!==null)&&nm(m.key,Oe)},onDrop:Oe=>am(m.key,Oe),children:[t.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${le?"justify-center":Ve?"justify-start":m.align==="center"?"justify-center":m.align==="right"?"justify-end":"justify-start"}`,children:[ve?t.jsx("span",{draggable:!0,onDragStart:Oe=>{Oe.stopPropagation(),rm(m.key,Oe)},onDragEnd:Oe=>{Oe.stopPropagation(),om()},onClick:Oe=>Oe.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 ${Be?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}):null,le?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(Hs,{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 ${Y?"text-[11px]":"text-xs"}`,children:t.jsx("span",{className:"min-w-0 truncate",children:m.header})})}),O&&t.jsx("button",{type:"button","aria-label":`Ordenar por ${String(m.header)}`,title:"Ordenar",onClick:Oe=>{Oe.stopPropagation(),sm(m)},"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 ${V?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:V?et.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"})}),B&&!le&&Kh(m)&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Re&&mt===m.key,"aria-label":`Filtrar ${String(m.header)}`,title:"Filtrar",onClick:Oe=>rc(Oe,"filter",m.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 ${Re&&dt==="filter"&&mt===m.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":xe?"text-[var(--primary)] opacity-100":""}`,children:xe?t.jsx(z.HiFunnel,{className:"h-3.5 w-3.5"}):t.jsx(z.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!le&&t.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:Oe=>{Oe.preventDefault(),Oe.stopPropagation(),An.current={colKey:m.key,startX:Oe.clientX,startWidth:wr[m.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:Oe=>{Oe.preventDefault(),Oe.stopPropagation(),An.current=null,document.body.style.cursor="",document.body.style.userSelect="",tm(m)},onClick:Oe=>Oe.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"}})]})})]},m.key)})]}),Wa=()=>{if(!Re||typeof document>"u"||dt==="visibility"&&!ce||dt==="filter"&&!B)return null;const m=e.find(xe=>xe.key===mt),A=Gh(),V=m?Object.prototype.hasOwnProperty.call(it,m.key):!1,O=m?yt[m.key]:void 0,le=zn.find(xe=>xe.value===(O==null?void 0:O.operator)),be=m?it[m.key]??[]:[],we=At.trim().toLowerCase(),Te=we?A.filter(xe=>xe.label.toLowerCase().includes(we)):A,ve=m&&A.length>0&&(!V||be.length===A.length),Be=m&&V&&be.length>0&&be.length<A.length,De=Ke.length,Ve=()=>{m&&(La(m.key),Ji(m.key))};return pt.createPortal(t.jsx("div",{ref:Vi,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Ih,borderColor:"var(--border)",background:"var(--bg-card)"},children:dt==="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:De>0?`${Dt.length} de ${e.length} visibles`:`${e.length} visibles`}),t.jsx("button",{type:"button",onClick:em,disabled:De===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:Zi.map(xe=>{const Oe=!Ke.includes(xe.key),Ne=!(xe.hideable!==!1)||Oe&&Dt.length<=1;return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Oe,disabled:Ne,onClick:()=>Rh(xe.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:Oe?"var(--primary)":"var(--border)",background:Oe?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Oe&&t.jsx(z.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:xe.header})]},xe.key)})})]}):m?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 ",m.header]}),t.jsx("button",{type:"button",onClick:Ve,disabled:!V&&!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"})]}),m.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:()=>Nr({key:m.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"})]}),(et==null?void 0:et.key)===m.key&&et.dir==="asc"&&t.jsx(z.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),t.jsxs("button",{type:"button",onClick:()=>Nr({key:m.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"})]}),(et==null?void 0:et.key)===m.key&&et.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(br,{value:(O==null?void 0:O.operator)??"",onChange:xe=>{if(!xe){Ji(m.key);return}Da(m.key,{operator:xe,value:(O==null?void 0:O.value)??"",valueTo:(O==null?void 0:O.valueTo)??""})},options:ed,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"}),(le==null?void 0:le.valueMode)!=="none"?t.jsx("input",{value:(O==null?void 0:O.value)??"",onChange:xe=>{O&&Da(m.key,{...O,value:xe.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"})]}),(le==null?void 0:le.valueMode)==="between"&&t.jsx("input",{value:(O==null?void 0:O.valueTo)??"",onChange:xe=>{O&&Da(m.key,{...O,valueTo:xe.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:At,onChange:xe=>Ue(xe.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":Be?"mixed":!!ve,onClick:()=>{m&&(ve?ns(m.key,[]):La(m.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:ve||Be?"var(--primary)":"var(--border)",background:ve||Be?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[Be&&t.jsx(z.HiMinus,{className:"h-3 w-3"}),ve&&!Be&&t.jsx(z.HiCheck,{className:"h-3 w-3"})]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),Te.map(xe=>{const Oe=!V||be.includes(xe.value);return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Oe,onClick:()=>Zh(m.key,xe.value,A.map(Ce=>Ce.value),V),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:Oe?"var(--primary)":"var(--border)",background:Oe?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Oe&&t.jsx(z.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:xe.label})]},xe.value)}),Te.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(!Mn)return;function m(A){Ro.current&&!Ro.current.contains(A.target)&&Ma.current&&!Ma.current.contains(A.target)&&Ea(!1)}return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[Mn]);function bc(m,A){if(m.filterValue){const V=m.filterValue(A);return V==null||V===""?"":_n(V)}return _n($r(m.cell(A)))}function hc(m){return`"${_n(m).replace(/"/g,'""')}"`}function ja(m){return _n(m).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function mc(){return Vt&&Jt>kr.length&&Xa.toast.warning(`Exportando ${kr.length.toLocaleString("es-MX")} de ${Jt.toLocaleString("es-MX")} (página actual). Usa exportación completa si está disponible.`),kr}function mm(){const m=Dt.filter(ve=>!hr(ve)),A=mc(),V=m.map(ve=>hc($r(ve.header))).join(","),O=A.map(ve=>m.map(Be=>hc(bc(Be,ve))).join(",")).join(`
5
+ `),le=`${V}
6
+ ${O}`,be=new Blob(["\uFEFF"+le],{type:"text/csv;charset=utf-8;"}),we=URL.createObjectURL(be),Te=document.createElement("a");Te.href=we,Te.download=`${ot}.csv`,document.body.appendChild(Te),Te.click(),document.body.removeChild(Te),URL.revokeObjectURL(we)}function pm(){const m=Dt.filter(Te=>!hr(Te)),A=mc(),V=m.map(Te=>ja($r(Te.header))),le=A.map(Te=>m.map(ve=>ja(bc(ve,Te)))).map(Te=>`<tr>${Te.map(ve=>`<td>${ve}</td>`).join("")}</tr>`).join(""),be=`<!DOCTYPE html>
7
+ <html lang="es"><head><meta charset="utf-8"><title>${ja(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,28 +15,28 @@ ${z}`,pe=new Blob(["\uFEFF"+ie],{type:"text/csv;charset=utf-8;"}),Me=URL.createO
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>${Da(at)}</h3>
19
- <p>${L.length} registros · ${new Date().toLocaleDateString("es")}</p>
20
- <table><thead><tr>${Z.map(Le=>`<th>${Le}</th>`).join("")}</tr></thead>
21
- <tbody>${ie}</tbody></table>
18
+ <h3>${ja(ot)}</h3>
19
+ <p>${A.length} registros · ${new Date().toLocaleDateString("es")}</p>
20
+ <table><thead><tr>${V.map(Te=>`<th>${Te}</th>`).join("")}</tr></thead>
21
+ <tbody>${le}</tbody></table>
22
22
  <script>window.onload=()=>{window.print()}<\/script>
23
- </body></html>`,Me=window.open("","_blank");Me&&(Me.document.write(pe),Me.document.close())}const Oa=()=>!rt||!xn?null:mt.createPortal(t.jsxs("div",{ref:jo,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...xh,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:()=>{(async()=>(de?await de():Qh(),ga(!1)))()},children:[t.jsx(W.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:()=>{(async()=>(Ee?await Ee():Jh(),ga(!1)))()},children:[t.jsx(W.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),Ha=()=>{const m=S&&be.trim().length>0,L=ge!=null&&ge.length?ge:m?[{key:"bql",label:"BQL",value:be}]:[],Z=re.filter(z=>{const ie=z.trim();return ie?!new Set(xe.split(`
24
- `).map(Me=>Me.trim()).filter(Boolean)).has(ie):!1}).slice(0,8);return!ce&&Uo===0&&!S&&!rt?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:[Uo>0&&t.jsxs("button",{type:"button",onClick:Oh,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(W.HiXMark,{className:"h-3.5 w-3.5"}),Uo," filtros"]}),S&&t.jsxs("div",{ref:zo,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>{if(He){Oe(!1);return}Ca(),Oe(!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:He?"var(--primary)":m?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:He||m?"var(--primary)":"var(--border)",color:He?"var(--primary-fg)":"var(--primary)"},"aria-expanded":He,title:"Abrir filtros BQL",children:[t.jsx(W.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",m&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),He?t.jsx(W.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(W.HiChevronDown,{className:"h-3.5 w-3.5"})]}),t.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:y}),L.length>0&&t.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[L.slice(0,3).map(z=>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:[z.label,":"]}),t.jsx("span",{className:"truncate",children:z.value})]},z.key)),L.length>3&&t.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",L.length-3]})]}),m&&t.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:Vi,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(W.HiXMark,{className:"h-4 w-4"})}),He&&mt.createPortal(t.jsxs("div",{ref:Oi,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...ph,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:[te.map(z=>t.jsxs("button",{type:"button",onMouseDown:ie=>{ie.preventDefault(),ie.stopPropagation()},onClick:ie=>{ie.preventDefault(),ie.stopPropagation(),Sa(z.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:[z.icon,z.label]},z.label)),ue.length>0&&t.jsxs("button",{type:"button",onClick:()=>Je(z=>!z),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":dt,children:[t.jsx(W.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),$t.length>0&&t.jsxs("button",{type:"button",onClick:()=>gt(z=>!z),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":ir,children:[t.jsx(W.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 ${Se?"var(--danger)":m?"var(--primary)":"var(--border)"}`},children:[t.jsx("textarea",{ref:Wo,value:xe,rows:3,onChange:z=>Yo(z.target.value,z.target),onKeyDown:z=>{z.key==="Enter"&&!z.shiftKey&&(z.preventDefault(),Ui(xe)),z.key==="Escape"&&Oe(!1)},placeholder:N,autoComplete:"off",spellCheck:!1,className:"block w-full px-4 py-3 text-sm outline-none",style:{background:"var(--bg-input)",color:"var(--text-main)",border:"none",fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace",lineHeight:1.6,maxHeight:180,minHeight:88,overflowY:"auto",resize:"vertical"}}),Z.length>0&&t.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:Z.map(z=>t.jsx("button",{type:"button",onMouseDown:ie=>{ie.preventDefault(),ie.stopPropagation()},onClick:ie=>{ie.preventDefault(),ie.stopPropagation(),Sa(z)},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:z},z))})]}),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:Se?"var(--danger)":"var(--text-muted)"},children:Se??(m?`${L.length||1} filtro${(L.length||1)===1?"":"s"} activo${(L.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),L.map(z=>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:[z.label,":"]}),t.jsx("span",{className:"truncate",children:z.value})]},z.key))]}),ir&&$t.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(W.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),t.jsxs("button",{type:"button",onClick:()=>{It([]),gt(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[t.jsx(W.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),$t.map(z=>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:ie=>{ie.preventDefault(),ie.stopPropagation()},onClick:ie=>{ie.preventDefault(),ie.stopPropagation(),Sa(z)},className:"min-w-0 flex-1 text-left",children:t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:z})}),t.jsx("button",{type:"button",onClick:()=>It(ie=>ie.filter(pe=>pe!==z)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:t.jsx(W.HiXMark,{className:"h-3.5 w-3.5"})})]},z))]}),dt&&ue.length>0&&t.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:ue.map(z=>t.jsxs("button",{type:"button",onMouseDown:ie=>{ie.preventDefault(),ie.stopPropagation()},onClick:ie=>{ie.preventDefault(),ie.stopPropagation(),Sa(z.bql),Je(!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:z.bql}),z.description&&t.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:z.description})]},z.bql))}),t.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] pt-3",children:[m&&t.jsxs("button",{type:"button",onClick:Vi,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(W.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),t.jsxs("button",{type:"button",onClick:()=>Ui(xe),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(W.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),rt&&t.jsx("button",{ref:va,type:"button","aria-haspopup":"menu","aria-expanded":xn,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var ie;const z=(ie=va.current)==null?void 0:ie.getBoundingClientRect();z&&wh({top:z.bottom+4,right:window.innerWidth-z.right}),ga(pe=>!pe)},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)] ${xn?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(W.HiArrowDownTray,{className:"h-4 w-4"})}),ce&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Re&&lt==="visibility","aria-label":se,title:se,onClick:z=>Yi(z,"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)] ${Re&&lt==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(W.HiCog6Tooth,{className:"h-4 w-4"})})]})},lc=()=>{if(!Xh)return null;const m=td(ut,ts);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 ${V?"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:Jt===0?"0 filas":`${Yh}–${Kh} de ${Jt}`}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),t.jsx(fr,{value:String(Xt),onChange:L=>Gh(Number(L)),options:Zo.map(L=>({value:String(L),label:String(L)})),placeholder:"Filas",searchable:!1,disabled:a,height:q,padding:X,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:_}})]})]}),t.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[t.jsx("button",{disabled:a||ut<=1,onClick:()=>rs(ut-1),onMouseEnter:L=>{L.currentTarget.disabled||(L.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",L.currentTarget.style.color="var(--primary)")},onMouseLeave:L=>{L.currentTarget.style.background="transparent",L.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(W.HiChevronLeft,{className:"h-3.5 w-3.5"})}),m.map((L,Z)=>L==="..."?t.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${Z}`):t.jsx("button",{disabled:a,onClick:()=>rs(L),onMouseEnter:z=>{z.currentTarget.disabled||L===ut||(z.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",z.currentTarget.style.color="var(--primary)")},onMouseLeave:z=>{z.currentTarget.style.background=L===ut?"var(--primary)":"transparent",z.currentTarget.style.color=L===ut?"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:L===ut?"var(--primary)":"transparent",color:L===ut?"var(--primary-fg)":"var(--text-muted)"},children:L},L)),t.jsx("button",{disabled:a||ut>=ts,onClick:()=>rs(ut+1),onMouseEnter:L=>{L.currentTarget.disabled||(L.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",L.currentTarget.style.color="var(--primary)")},onMouseLeave:L=>{L.currentTarget.style.background="transparent",L.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(W.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),t.jsx("div",{"aria-hidden":"true"})]})},Rh=()=>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:Ta},children:[La(),Oa(),Ha(),t.jsx("div",{ref:cr,className:"min-w-0 max-w-full overflow-hidden",children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:kn,minWidth:$a},children:[t.jsx("div",{role:"rowgroup",style:x?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Aa()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,o)}).map((m,L)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Kr,borderBottom:`1px solid ${ze}`},children:[Ft&&t.jsx("div",{role:"cell",className:`${V?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${ze}`,borderRight:`1px solid ${ze}`}},"select-cell"),At.map((Z,z)=>t.jsx("div",{role:"cell",className:V?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${ze}`,borderRight:`1px solid ${ze}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${Fi(L,z)}%`,minWidth:32}})},Z.key))]},L))})]})})]}),as="min-w-0 max-w-full overflow-hidden";return Q&&De&&!Qe?t.jsx(Mn,{rows:o,columns:Math.max(4,At.length||7)}):!a&&r.length===0&&!qo?Rh():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:Ta},children:[La(),Oa(),Ha(),t.jsx("div",{ref:cr,className:as,children:t.jsx(os.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:Pi,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:kn,minWidth:$a},children:[t.jsx("div",{role:"rowgroup",style:x?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Aa()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:o}).map((m,L)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Kr,borderBottom:`1px solid ${ze}`},children:[Ft&&t.jsx("div",{role:"cell",className:`${V?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${ze}`,borderRight:`1px solid ${ze}`}},"select-cell"),At.map((Z,z)=>{const ie=Ea[Z.key],pe=ie!==void 0,Me=Z.key===es;return t.jsx("div",{role:"cell","data-dt-column-key":Z.key,className:V?"px-2 py-1.5":"px-3 py-2",style:pe?{position:"sticky",left:ie,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:Me?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${ze}`:`inset 0 -1px 0 ${ze}`,borderRight:`1px solid ${ze}`}:{borderBottom:`1px solid ${ze}`,borderRight:`1px solid ${ze}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${Fi(L,z)}%`,minWidth:32}})},Z.key)})]},L))})]})})}),lc()]}):!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:Ta},children:[La(),Oa(),Ha(),t.jsx("div",{ref:cr,className:as,children:t.jsx("div",{role:"table",className:"text-sm",style:{width:kn,minWidth:$a},children:t.jsx("div",{role:"rowgroup",style:x?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Aa()})})}),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:ze,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(W.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:Ta},children:[La(),Oa(),Ha(),t.jsx("div",{ref:cr,className:as,children:t.jsx(os.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:Pi,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:kn,minWidth:$a},children:[t.jsx("div",{role:"rowgroup",style:x?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Aa()}),t.jsx("div",{role:"rowgroup",children:Ji.map((m,L)=>{const Z=n(m),z=nc(E==null?void 0:E(m)),ie=L>0?nc(E==null?void 0:E(Ji[L-1])):null,pe=z&&z.key!==(ie==null?void 0:ie.key),Me=Ft&&w.has(Z),Le=Ft&&(!C||C(m)),qe=Yr?(h==null?void 0:h(m))??!0:!1,Ye=qe&&Zi.has(Z),vt=!!d||v&&qe,tt=Me&&T?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":L%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return t.jsxs(s.Fragment,{children:[pe&&t.jsx("div",{role:"row",className:`grid ${z.className??""}`,style:{gridTemplateColumns:Kr},children:t.jsx("div",{role:"cell",className:V?"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 ${ze}`,borderRight:`1px solid ${ze}`},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:z.label}),z.description&&t.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:z.description})]})})})}),t.jsxs("div",{role:"row",onClick:vt?ye=>{const Ae=ye.target;if(!(Ae!=null&&Ae.closest('[data-dt-disable-row-click="true"]'))){if(v&&qe){Ri(Z);return}d==null||d(m)}}:void 0,className:`grid transition-colors ${vt?"cursor-pointer":""} ${H?H(m):""}`,style:{gridTemplateColumns:Kr,"--dt-row-bg":tt,"--dt-sticky-bg":tt,background:"var(--dt-row-bg)",borderBottom:`1px solid ${ze}`},onMouseEnter:ye=>{Me||(ye.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),ye.currentTarget.style.setProperty("--dt-sticky-bg",Zh))},onMouseLeave:ye=>{ye.currentTarget.style.setProperty("--dt-row-bg",tt),ye.currentTarget.style.setProperty("--dt-sticky-bg",tt)},children:[Yr&&t.jsx("div",{role:"cell",className:`${V?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${ze}`,borderRight:`1px solid ${ze}`},"data-dt-disable-row-click":"true",children:qe&&t.jsx("button",{type:"button","aria-label":Ye?"Contraer fila":"Desplegar fila","aria-expanded":Ye,onClick:ye=>{ye.stopPropagation(),Ri(Z)},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]",children:Ye?t.jsx(W.HiChevronDown,{className:"h-4 w-4"}):t.jsx(W.HiChevronRight,{className:"h-4 w-4"})})}),Ft&&t.jsx("div",{role:"cell",className:`${V?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:Jo?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${ze}`}:{borderBottom:`1px solid ${ze}`,borderRight:`1px solid ${ze}`},onClick:ye=>{ye.stopPropagation(),Le&&g(Z)},children:t.jsx(Tn,{size:"sm",checked:Me,disabled:!Le,"aria-label":Le?"Seleccionar fila":"Fila no seleccionable",containerClassName:"items-center",className:Le?"cursor-pointer":"cursor-not-allowed opacity-50",onClick:ye=>ye.stopPropagation(),onChange:()=>{Le&&g(Z)}})}),At.map(ye=>{const Ae=Ea[ye.key],Ce=Ae!==void 0,Ne=ye.key===es,ke=br(ye);return t.jsx("div",{role:"cell","data-dt-column-key":ye.key,"data-dt-disable-row-click":ye.disableRowClick||ke?"true":void 0,className:`${ke?"px-2 py-1.5 justify-center text-center":`${V?"px-2 py-1.5":"px-3 py-2"} ${ec(ye.align)}`} flex min-w-0 items-center ${Gc} ${ye.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...Ce?{position:"sticky",left:Ae,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:Ne?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${ze}`:`inset 0 -1px 0 ${ze}`,borderRight:`1px solid ${ze}`}:{borderBottom:`1px solid ${ze}`,borderRight:`1px solid ${ze}`}},children:t.jsx(Ss,{children:t.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:ye.cell(m)})})},ye.key)})]}),Ye&&u&&t.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:Kr},children:t.jsx("div",{role:"cell",className:V?"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 ${ze}`},children:u(m)})})]},Z)})})]})})}),lc()]})}const ad={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function Bn({title:e="Sin resultados",description:r,icon:n=t.jsx(W.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 ${ad[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]})]})})}function Pt(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 Cs(e){if(!e)return null;const r=String(e).slice(0,10),[n,a,o]=r.split("-").map(Number);return!n||!a||!o?null:new Date(n,a-1,o)}function Mr(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function rr(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function Es(e){const r=Mr(e),n=(r.getDay()+6)%7;return rr(r,-n)}function Ya(e){const r=Es(e);return Array.from({length:7},(n,a)=>rr(r,a))}function Ms(e){const r=e.getDay();return r===0||r===6}function In(e){return e.filter(r=>!Ms(r))}function Ts(e){return In(Ya(e))}function od(e){const r=Mr(e),n=r.getDay();return n===6?rr(r,-1):n===0?rr(r,-2):r}function Ka(e){const r=new Date(e.getFullYear(),e.getMonth(),1),n=Es(r);return Array.from({length:42},(a,o)=>rr(n,o))}function Ga(e){const r=[];for(let n=0;n<e.length;n+=7)r.push(e.slice(n,n+7));return r}function $s(e){return Ga(e).map(In)}function sd(e,r,n,a){return e.getTime()<=a.getTime()&&r.getTime()>=n.getTime()}function nr(e,r){const n=r?r(e):{start:e.startDate,end:e.endDate},a=Cs(n.start);if(!a)return null;const o=Cs(n.end??n.start)??a;return o.getTime()<a.getTime()?{start:o,end:a}:{start:a,end:o}}function As(e,r){const n={};for(const a of e){const o=nr(a,r);if(!o)continue;let l=Mr(o.start);const i=Mr(o.end);for(;l.getTime()<=i.getTime();){const c=Pt(l);n[c]||(n[c]=[]),n[c].push(a),l=rr(l,1)}}return n}function Za(e,r,n){if(r.length===0)return[];const a=Mr(r[0]),o=Mr(r[r.length-1]),l=[],i=[],c=[...e].sort((d,u)=>{const h=nr(d,n),b=nr(u,n),f=(h==null?void 0:h.start.getTime())??0,p=(b==null?void 0:b.start.getTime())??0;return f-p||d.title.localeCompare(u.title)});for(const d of c){const u=nr(d,n);if(!u||!sd(u.start,u.end,a,o))continue;const h=u.start.getTime()<a.getTime()?a:u.start,b=u.end.getTime()>o.getTime()?o:u.end,f=Math.max(0,Math.round((h.getTime()-a.getTime())/864e5)),p=Math.min(r.length-1,Math.round((b.getTime()-a.getTime())/864e5)),v=Math.max(1,p-f+1);let w=l.findIndex(g=>g<f);w<0?(w=l.length,l.push(f+v-1)):l[w]=f+v-1,i.push({item:d,lane:w,colStart:f,colSpan:v})}return i}function Dt(e){return new Intl.DateTimeFormat("es-MX",{day:"2-digit",month:"short",year:"numeric"}).format(e)}function ld(e){const r=new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(e);return r.charAt(0).toUpperCase()+r.slice(1)}function id(e){const r=new Intl.DateTimeFormat("es-MX",{weekday:"short",day:"2-digit",month:"short",year:"numeric"}).format(e);return r.charAt(0).toUpperCase()+r.slice(1)}function Ls(e){const r=new Intl.DateTimeFormat("es-MX",{weekday:"short",day:"2-digit",month:"short"}).format(e);return r.charAt(0).toUpperCase()+r.slice(1)}function Ds(e,r,n){return r==="month"?new Date(e.getFullYear(),e.getMonth()+n,1):r==="week"?rr(e,n*7):rr(e,n)}const cd=["Lun","Mar","Mié","Jue","Vie","Sáb","Dom"],Os=["Lun","Mar","Mié","Jue","Vie"];function dd({item:e,style:r,onClick:n}){const a=e.color??"var(--text-muted)",o=e.bg??"rgba(100, 116, 139, 0.14)",l=nr(e),i=l?`${Dt(l.start)} → ${Dt(l.end)}`:"",c=[e.title,e.subtitle,i,e.status].filter(Boolean).join(" · ");return t.jsx(_t,{content:c||e.title,children:t.jsxs("button",{type:"button",className:"absolute overflow-hidden rounded-md px-1.5 py-0.5 text-left text-[11px] leading-tight transition-opacity hover:opacity-90",style:{...r,background:o,borderLeft:`3px solid ${a}`,boxShadow:"inset 0 0 0 1px var(--border)",color:"var(--text-main)"},onClick:d=>{d.stopPropagation(),n==null||n()},children:[t.jsx("span",{className:"block truncate font-semibold",children:e.title}),e.status?t.jsx("span",{className:"block truncate",style:{color:a},children:e.status}):null]})})}function ud({item:e,onClick:r}){const n=e.color??"var(--text-muted)",a=e.bg??"rgba(100, 116, 139, 0.10)",o=nr(e),l=o?`${Dt(o.start)} → ${Dt(o.end)}`:"";return t.jsxs("button",{type:"button",className:"flex w-full flex-col gap-2 rounded-lg p-4 text-left transition-opacity hover:opacity-95 sm:flex-row sm:items-start sm:justify-between",style:{background:a,border:"1px solid var(--border)",boxShadow:`inset 3px 0 0 ${n}`,color:"var(--text-main)"},onClick:()=>r==null?void 0:r(),children:[t.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[t.jsx("div",{className:"text-base font-semibold",children:e.title}),e.subtitle?t.jsx("div",{className:"text-sm leading-5",style:{color:"var(--text-muted)"},children:e.subtitle}):null]}),t.jsxs("div",{className:"flex shrink-0 flex-col gap-2 sm:items-end",children:[e.status?t.jsx("span",{className:"inline-flex rounded-full px-2.5 py-0.5 text-xs font-semibold",style:{color:n,background:"color-mix(in srgb, var(--bg-card) 70%, transparent)",border:`1px solid color-mix(in srgb, ${n} 45%, transparent)`},children:e.status}):null,l?t.jsxs("div",{className:"text-xs",style:{color:"var(--text-secondary)"},children:[t.jsx("span",{className:"font-semibold uppercase tracking-wide opacity-70",children:"Rango"}),t.jsx("div",{children:l})]}):null]})]})}function fd({item:e,style:r,onClick:n}){const a=e.color??"var(--text-muted)",o=e.bg??"rgba(100, 116, 139, 0.14)",l=nr(e),i=l?`${Dt(l.start)} → ${Dt(l.end)}`:"";return t.jsxs("button",{type:"button",className:"absolute mx-1 overflow-hidden rounded-md px-2 py-1.5 text-left text-xs transition-opacity hover:opacity-90",style:{...r,background:o,borderLeft:`3px solid ${a}`,boxShadow:"inset 0 0 0 1px var(--border)",color:"var(--text-main)"},title:[e.title,i,e.status].filter(Boolean).join(" · "),onClick:()=>n==null?void 0:n(),children:[t.jsx("span",{className:"block truncate font-semibold",children:e.title}),t.jsx("span",{className:"block truncate",style:{color:a},children:[e.status,i].filter(Boolean).join(" · ")})]})}function Hs({item:e,day:r,renderPill:n,onClick:a}){if(n)return t.jsx("div",{className:"min-w-0",children:n(e,{day:r})});const o=e.color??"var(--text-muted)",l=e.bg??"rgba(100, 116, 139, 0.14)";return t.jsxs("button",{type:"button",className:"block w-full overflow-hidden rounded-md px-1.5 py-0.5 text-left text-[11px] leading-tight",style:{background:l,borderLeft:`3px solid ${o}`,color:"var(--text-main)"},onClick:i=>{i.stopPropagation(),a==null||a()},children:[t.jsx("span",{className:"block truncate font-semibold",children:e.title}),e.status?t.jsx("span",{className:"block truncate",style:{color:o},children:e.status}):null]})}function Bs({value:e,options:r,onChange:n}){return t.jsx("div",{className:"inline-flex overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:r.map((a,o)=>{const l=e===a.value;return t.jsxs("button",{type:"button",onClick:()=>n(a.value),className:"inline-flex items-center gap-1.5 px-3 py-2 text-xs font-semibold transition-colors",style:{background:l?"var(--primary)":"var(--bg-card)",color:l?"var(--primary-fg, #fff)":"var(--text-secondary)",borderRight:o<r.length-1?"1px solid var(--border)":void 0},children:[a.icon,a.label]},a.value)})})}function bd({items:e,cursorDate:r,onCursorDateChange:n,displayMode:a,onDisplayModeChange:o,viewMode:l,onViewModeChange:i,getItemDates:c,maxPillsPerDay:d=3,overloadThreshold:u=5,weekdayLabels:h,hideWeekends:b=!1,renderToolbarExtra:f,renderPill:p,renderDayCard:v,renderWeekBar:w,tableColumns:g,tableProps:A,onItemClick:C,onDayClick:T,loading:H=!1,emptyTitle:E="Sin eventos",emptyDescription:x="No hay eventos para los filtros seleccionados.",legend:M,legendInteractive:k=!0,activeLegendKeys:_,defaultActiveLegendKeys:q,onActiveLegendKeysChange:X,getItemLegendKey:D,overloadLabel:K="Sobrecarga de eventos",notice:j,showOverload:le=!0,layout:Q="span",className:fe="",showToolbar:F=!0}){const V=h??(b?[...Os]:[...cd]),ae=b?5:7,$=b?"grid grid-cols-5":"grid grid-cols-7",P=s.useMemo(()=>(M??[]).map(de=>de.label),[M]),[ce,O]=s.useState(()=>q??P),oe=s.useMemo(()=>_??(P.length>0?ce:[]),[_,P.length,ce]),G=s.useMemo(()=>new Set(oe),[oe]),U=de=>{_===void 0&&O(de),X==null||X(de)},se=de=>{k&&(G.has(de)?U(oe.filter(Ee=>Ee!==de)):U([...oe,de]))},S=s.useMemo(()=>{if(!k||P.length===0)return e;const de=new Set(P);return e.filter(Ee=>{const ne=(D==null?void 0:D(Ee))??Ee.status;return!ne||!de.has(ne)?!0:G.has(ne)})},[e,k,P,G,D]),R=s.useMemo(()=>As(S,c),[S,c]),ee=s.useMemo(()=>{const de=Ka(r);return b?In(de):de},[r,b]),J=s.useMemo(()=>{const de=Ka(r);return b?$s(de):Ga(de)},[r,b]),y=s.useMemo(()=>b?Ts(r):Ya(r),[r,b]),N=Pt(r),te=R[N]??[],ue=s.useMemo(()=>Za(S,y,c),[S,y,c]),re=s.useMemo(()=>ue.length===0?1:Math.max(...ue.map(de=>de.lane))+1,[ue]),ge=s.useMemo(()=>J.map(de=>{const Ee=Za(S,de,c),ne=Ee.length===0?0:Math.max(...Ee.map(De=>De.lane))+1;return{days:de,bars:Ee,laneCount:ne}}),[J,S,c]),Se=36,$e=38,ht=s.useMemo(()=>{const de=l==="month"?ee:l==="week"?y:[r],Ee=[];for(const ne of de){const De=Pt(ne),Be=R[De]??[];Be.length>=u&&Ee.push([ne,Be])}return Ee},[l,ee,y,r,R,u]),Ct=l==="month"?ld(r):l==="week"?`${Dt(y[0])} – ${Dt(y[6])}`:id(r),rt=s.useMemo(()=>[{key:"title",header:"Título",cell:de=>de.title},{key:"status",header:"Estado",cell:de=>de.status??"—"},{key:"range",header:"Rango",cell:de=>{const Ee=nr(de,c);return Ee?`${Dt(Ee.start)} → ${Dt(Ee.end)}`:"—"}},{key:"subtitle",header:"Detalle",cell:de=>de.subtitle??"—"}],[c]),at=de=>{if(n(de),T){T(de);return}i("day")};return t.jsxs("div",{className:`bonsaif-event-calendar space-y-4 ${fe}`.trim(),children:[F?t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("button",{type:"button","aria-label":"Anterior",className:"inline-flex h-9 w-9 items-center justify-center rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"},onClick:()=>n(Ds(r,l,-1)),children:t.jsx(W.HiChevronLeft,{className:"h-4 w-4"})}),t.jsx("div",{className:"min-w-[160px] text-center text-sm font-semibold capitalize",style:{color:"var(--text-main)"},children:Ct}),t.jsx("button",{type:"button","aria-label":"Siguiente",className:"inline-flex h-9 w-9 items-center justify-center rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"},onClick:()=>n(Ds(r,l,1)),children:t.jsx(W.HiChevronRight,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",className:"rounded-lg px-3 py-2 text-xs font-semibold",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-secondary)"},onClick:()=>n(new Date),children:"Hoy"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f,t.jsx(Bs,{value:a,onChange:o,options:[{value:"calendar",label:"Calendario",icon:t.jsx(W.HiCalendarDays,{className:"h-4 w-4"})},{value:"table",label:"Tabla",icon:t.jsx(W.HiTableCells,{className:"h-4 w-4"})}]}),a==="calendar"?t.jsx(Bs,{value:l,onChange:i,options:[{value:"month",label:"Mes"},{value:"week",label:"Semana"},{value:"day",label:"Día"}]}):null]})]}):null,M&&M.length>0?t.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",role:k?"group":void 0,"aria-label":k?"Filtrar por estado":void 0,children:M.map(de=>{const Ee=G.has(de.label);return k?t.jsxs("button",{type:"button","aria-pressed":Ee,onClick:()=>se(de.label),className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 transition-opacity",style:{color:Ee?"var(--text-main)":"var(--text-muted)",background:Ee?"color-mix(in srgb, var(--bg-card) 80%, transparent)":"transparent",border:Ee?`1px solid color-mix(in srgb, ${de.color} 55%, var(--border))`:"1px solid var(--border)",opacity:Ee?1:.45},title:Ee?`Ocultar “${de.label}”`:`Mostrar “${de.label}”`,children:[t.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:de.color,boxShadow:Ee?`0 0 0 2px color-mix(in srgb, ${de.color} 25%, transparent)`:void 0},"aria-hidden":!0}),de.label]},de.label):t.jsxs("span",{className:"inline-flex items-center gap-1.5",style:{color:"var(--text-secondary)"},children:[t.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:de.color},"aria-hidden":!0}),de.label]},de.label)})}):null,a==="calendar"&&j&&j.items.length>0?t.jsxs("div",{className:"rounded-lg px-4 py-3 text-sm",style:j.tone==="danger"?{background:"rgba(220, 38, 38, 0.12)",border:"1px solid rgba(220, 38, 38, 0.35)",color:"#dc2626"}:{background:"rgba(217, 119, 6, 0.14)",border:"1px solid rgba(217, 119, 6, 0.35)",color:"#b45309"},children:[t.jsxs("strong",{children:[j.label,":"]})," ",j.items.join(", ")]}):a==="calendar"&&le&&ht.length>0?t.jsxs("div",{className:"rounded-lg px-4 py-3 text-sm",style:{background:"rgba(217, 119, 6, 0.14)",border:"1px solid rgba(217, 119, 6, 0.35)",color:"#b45309"},children:[t.jsxs("strong",{children:[K,":"]})," ",ht.map(([de,Ee])=>`${Dt(de)} (${Ee.length})`).join(", ")]}):null,a==="table"?H||S.length>0?t.jsx(Xa,{columns:g??rt,data:S,getRowId:de=>de.id,loading:H,skeletonRows:8,emptyIcon:t.jsx(W.HiCalendarDays,{className:"h-10 w-10"}),emptyText:x,onRowClick:C,pageSize:25,compact:!0,...A}):t.jsx(Bn,{icon:t.jsx(W.HiCalendarDays,{className:"h-5 w-5"}),title:E,description:x}):null,a==="calendar"&&l==="month"&&Q==="daily"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{className:$,style:{borderBottom:"1px solid var(--border)"},children:V.map(de=>t.jsx("div",{className:"px-3 py-2 text-xs font-bold uppercase",style:{background:"var(--bg-card)",color:"var(--text-muted)"},children:de},de))}),t.jsx("div",{className:$,children:ee.map(de=>{const Ee=Pt(de),ne=R[Ee]??[],De=de.getMonth()!==r.getMonth(),Be=Math.max(0,ne.length-d);return t.jsxs("div",{role:"button",tabIndex:0,"aria-label":`${de.getDate()}`,onClick:()=>at(de),onKeyDown:Ue=>{(Ue.key==="Enter"||Ue.key===" ")&&(Ue.preventDefault(),at(de))},className:"flex min-h-[108px] cursor-pointer flex-col gap-1 p-2 text-left transition-colors hover:bg-black/[0.03] dark:hover:bg-white/[0.04]",style:{background:"var(--bg-main)",borderRight:"1px solid var(--border)",borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-sm font-semibold",style:{color:De?"var(--text-muted)":"var(--text-main)"},children:de.getDate()}),ne.length>0?t.jsx("span",{className:"rounded-full px-2 py-0.5 text-[11px] font-bold",style:{background:"var(--primary)",color:"var(--primary-fg, #fff)"},children:ne.length}):null]}),t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[ne.slice(0,d).map(Ue=>t.jsx(Hs,{item:Ue,day:de,renderPill:p,onClick:()=>C==null?void 0:C(Ue)},Ue.id)),Be>0?t.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-muted)"},children:["+",Be," más"]}):null]})]},Ee)})})]}):null,a==="calendar"&&l==="month"&&Q==="span"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{className:$,style:{borderBottom:"1px solid var(--border)"},children:V.map(de=>t.jsx("div",{className:"px-3 py-2 text-xs font-bold uppercase",style:{background:"var(--bg-card)",color:"var(--text-muted)"},children:de},de))}),ge.map(({days:de,bars:Ee,laneCount:ne},De)=>{const Be=Math.min(ne,d),Ue=Math.max(0,ne-d),je=Se+Math.max(1,Be)*$e+(Ue>0?20:8)+8;return t.jsxs("div",{className:"relative",style:{minHeight:je,borderBottom:De<ge.length-1?"1px solid var(--border)":void 0},children:[t.jsx("div",{className:$,style:{minHeight:je},children:de.map(Fe=>{const Qe=Pt(Fe),ot=R[Qe]??[],Et=Fe.getMonth()!==r.getMonth();return t.jsx("div",{role:"button",tabIndex:0,"aria-label":`${Fe.getDate()}`,onClick:()=>at(Fe),onKeyDown:he=>{(he.key==="Enter"||he.key===" ")&&(he.preventDefault(),at(Fe))},className:"cursor-pointer p-2 text-left transition-colors hover:bg-black/[0.03] dark:hover:bg-white/[0.04]",style:{background:"var(--bg-main)",borderRight:"1px solid var(--border)",minHeight:je},children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-sm font-semibold",style:{color:Et?"var(--text-muted)":"var(--text-main)"},children:Fe.getDate()}),ot.length>0?t.jsx("span",{className:"rounded-full px-2 py-0.5 text-[11px] font-bold",style:{background:"var(--primary)",color:"var(--primary-fg, #fff)"},children:ot.length}):null]})},Qe)})}),t.jsxs("div",{className:"pointer-events-none absolute inset-x-0",style:{top:Se,bottom:4},children:[Ee.filter(Fe=>Fe.lane<d).map(Fe=>{const Qe={left:`calc(${Fe.colStart/ae*100}% + 4px)`,width:`calc(${Fe.colSpan/ae*100}% - 8px)`,top:2+Fe.lane*$e,height:$e-6,pointerEvents:"auto"};return p?t.jsx("div",{className:"absolute overflow-hidden",style:Qe,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:p(Fe.item,{day:de[Fe.colStart]})})},`${Fe.item.id}-${Fe.colStart}-${De}`):w?t.jsx("div",{className:"absolute overflow-hidden",style:Qe,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:w(Fe.item)})},`${Fe.item.id}-${Fe.colStart}-${De}`):t.jsx(dd,{item:Fe.item,style:Qe,onClick:()=>C==null?void 0:C(Fe.item)},`${Fe.item.id}-${Fe.colStart}-${De}`)}),Ue>0?t.jsxs("span",{className:"absolute text-[11px] font-semibold",style:{left:8,top:2+Be*$e,color:"var(--text-muted)"},children:["+",Ue," más"]}):null]})]},`week-${De}-${Pt(de[0])}`)})]}):null,a==="calendar"&&l==="week"&&Q==="daily"?t.jsx("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)"},children:t.jsx("div",{className:$,children:y.map(de=>{const Ee=Pt(de),ne=R[Ee]??[],De=Math.max(0,ne.length-d);return t.jsxs("div",{className:"min-h-[180px] p-2",style:{borderRight:"1px solid var(--border)"},children:[t.jsxs("button",{type:"button",className:"mb-2 w-full text-center text-xs font-semibold capitalize",style:{color:"var(--text-main)"},onClick:()=>at(de),children:[Ls(de),t.jsx("span",{className:"mt-1 block text-sm",children:de.getDate()})]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[ne.slice(0,d).map(Be=>t.jsx(Hs,{item:Be,day:de,renderPill:p,onClick:()=>C==null?void 0:C(Be)},Be.id)),De>0?t.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-muted)"},children:["+",De," más"]}):null]})]},Ee)})})}):null,a==="calendar"&&l==="week"&&Q==="span"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)"},children:[t.jsx("div",{className:`${$} border-b`,style:{borderColor:"var(--border)"},children:y.map(de=>t.jsx("button",{type:"button",className:"px-3 py-2 text-center text-xs font-semibold capitalize",style:{color:"var(--text-main)",borderRight:"1px solid var(--border)"},onClick:()=>at(de),children:Ls(de)},Pt(de)))}),t.jsxs("div",{className:`relative ${$}`,style:{minHeight:Math.max(220,re*56+24)},children:[y.map(de=>t.jsx("div",{className:"min-h-full",style:{borderRight:"1px solid var(--border)"}},`lane-${Pt(de)}`)),ue.map(de=>{const Ee={left:`calc(${de.colStart/ae*100}% + 4px)`,width:`calc(${de.colSpan/ae*100}% - 8px)`,top:12+de.lane*56,height:48};return w?t.jsx("div",{className:"absolute overflow-hidden",style:Ee,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:w(de.item)})},`${de.item.id}-${de.colStart}`):t.jsx(fd,{item:de.item,style:Ee,onClick:()=>C==null?void 0:C(de.item)},`${de.item.id}-${de.colStart}`)}),ue.length===0&&!H?t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:x}):null]})]}):null,a==="calendar"&&l==="day"?te.length>0||H?t.jsxs("div",{className:"space-y-3",children:[H&&te.length===0?t.jsx(Bn,{icon:t.jsx(W.HiCalendarDays,{className:"h-5 w-5"}),title:"Cargando…",description:"Obteniendo eventos del día."}):null,te.map(de=>v?t.jsx("div",{children:v(de)},de.id):t.jsx(ud,{item:de,onClick:()=>C==null?void 0:C(de)},de.id))]}):t.jsx(Bn,{icon:t.jsx(W.HiCalendarDays,{className:"h-5 w-5"}),title:E,description:x}):null]})}function hd(e){const r=document.createElement("textarea");r.value=e,r.setAttribute("readonly",""),r.style.position="fixed",r.style.opacity="0",r.style.left="-9999px",r.style.top="0",document.body.appendChild(r),r.focus(),r.select(),r.setSelectionRange(0,e.length);const n=document.execCommand("copy");if(document.body.removeChild(r),!n)throw new Error("execCommand_copy_failed")}async function Qa(e){var n;const r=String(e??"");if(!r.trim())throw new Error("empty_clipboard_text");try{if(typeof window<"u"&&window.focus(),(n=navigator.clipboard)!=null&&n.writeText){await navigator.clipboard.writeText(r);return}}catch{}hd(r)}function md(e){return typeof e=="function"?e():e}function Ja({value:e,resetDelay:r=2e3,title:n,copiedTitle:a="Copiado",copiedLabel:o,icon:l=t.jsx(W.HiClipboardDocument,{size:14}),copiedIcon:i=t.jsx(W.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:d,onCopyError:u,className:h="",style:b,children:f,onClick:p,type:v="button",...w}){const[g,A]=s.useState(!1),C=s.useRef(null);s.useEffect(()=>()=>{C.current&&window.clearTimeout(C.current)},[]);function T(E){A(!0),d==null||d(E),C.current&&window.clearTimeout(C.current),C.current=window.setTimeout(()=>{A(!1),C.current=null},r)}async function H(E){if(c&&E.stopPropagation(),p==null||p(E),E.defaultPrevented)return;const x=md(e);if(x)try{await Qa(x),T(x)}catch(M){u==null||u(M,x)}}return t.jsxs("button",{...w,type:v,onClick:H,title:g?a:n,"aria-label":w["aria-label"]??(g?a:n),"data-copied":g?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${f?"min-w-7 px-2":"w-7"} ${h}`,style:{cursor:"pointer",background:g?"rgba(22,163,74,0.15)":"var(--bg-card)",border:g?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:g?"#16a34a":"var(--text-secondary)",boxShadow:g?"0 0 0 3px rgba(22,163,74,0.12)":"none",...b},children:[t.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:g?"scale(1.15)":"scale(1)"},children:g?i:l}),f&&t.jsx("span",{className:"text-xs font-semibold leading-none",children:g?o??f:f})]})}function pd({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(Ja,{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 Fn(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function gd({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(W.HiMagnifyingGlass,{className:"absolute top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[var(--text-muted)] pointer-events-none",style:{left:Fn(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:Fn(o),padding:Fn(l)}})]})}function vd({value:e,onChange:r,options:n,placeholder:a,icon:o,className:l="",height:i=40,padding:c,iconLeft:d=10,searchable:u=!0}){const h=o?n.map((b,f)=>f===0&&!b.color?{...b,sublabel:b.sublabel??void 0}:b):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:Fn(d)},children:o}),t.jsx(fr,{value:e,onChange:r,options:h,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 yd={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},_n=180,xd="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Ra({open:e,onClose:r,title:n,subtitle:a,leadingIcon:o,headerActions:l,footer:i,children:c,size:d="md",maxWidth:u,zIndex:h=1e3,closeOnBackdrop:b=!0,closeOnEscape:f=!0,showCloseButton:p=!0,placement:v="center",bodyClassName:w="px-6 py-5",panelClassName:g="",backdropClassName:A=xd,contentClassName:C="p-4",ariaLabel:T,frameless:H=!1,disabled:E=!1}){const[x,M]=s.useState(!1),[k,_]=s.useState(!1),q=s.useRef(null);if(s.useEffect(()=>(e?(q.current&&clearTimeout(q.current),M(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>_(!0)))):(_(!1),q.current=setTimeout(()=>M(!1),_n+40)),()=>{q.current&&clearTimeout(q.current)}),[e]),s.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),s.useEffect(()=>{if(!e||!f)return;const Q=fe=>{fe.key==="Escape"&&r()};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[f,r,e]),!x)return null;const X=n||a||o||l||p,D=u??yd[d],K=v==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",j=v==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",le=k?"translateY(0) scale(1)":v==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return mt.createPortal(t.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":T??n,className:`fixed inset-0 flex ${K} ${C}`,style:{zIndex:h},children:[t.jsx("div",{className:`absolute inset-0 ${A}`,onClick:b?r:void 0,style:{opacity:k?1:0,transition:`opacity ${_n}ms ease`}}),t.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${H?"shadow-none":"shadow-2xl"} ${j} ${g}`,style:{maxWidth:D,background:H?"transparent":"var(--bg-card)",border:H?"none":"1px solid var(--border)",opacity:k?1:0,transform:le,transition:`opacity ${_n}ms ease, transform ${_n}ms ease`},onClick:Q=>Q.stopPropagation(),children:[E&&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)"}}),X&&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,p&&t.jsx(Ke,{variant:"icon",onClick:r,title:"Cerrar",children:t.jsx(W.HiXMark,{className:"h-5 w-5"})})]})]}),t.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${w}`,children:c}),i&&t.jsx("div",{className:"flex min-w-0 flex-shrink-0 flex-wrap justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:i})]})]}),document.body)}const wd={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 Nd({open:e,title:r,description:n,confirmLabel:a="Confirmar",cancelLabel:o="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:d}){const u=wd[l];return t.jsx(Ra,{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(Ke,{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(W.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(W.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(Ke,{variant:"secondary",onClick:d,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:o}),t.jsx(Ke,{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 kd(e){return e?typeof e=="function"?e():e:""}function Sd(e){return/^https?:\/\//i.test(e)}function Is(e,r){try{return new URL(e,r).toString()}catch{return e}}function Cd(e,r,n,a=!1){const o=typeof e=="function"?e():e,l=r?r(o):o;if(!l||Sd(l))return l;const i=kd(n);return i?Is(l,i):a&&typeof window<"u"?Is(l,window.location.origin):l}function Ed({url:e,resolveUrl:r,baseUrl:n,useWindowOriginForRelative:a=!1,title:o="Copiar link",copiedTitle:l="Link copiado",icon:i=t.jsx(W.HiLink,{className:"h-3.5 w-3.5"}),...c}){return t.jsx(Ja,{...c,value:()=>Cd(e,r,n,a),title:o,copiedTitle:l,icon:i})}const Md={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 Td(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=Md[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 $d=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function Ad({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 h,b;(h=c.current)==null||h.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:h=>i(h.target.value),onBlur:()=>o(),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),a(l)),h.key==="Escape"&&(h.preventDefault(),o()),(n==null?void 0:n.preset)==="integer"&&!h.ctrlKey&&!h.metaKey&&!$d.has(h.key)&&!/^[\d-]$/.test(h.key)&&h.preventDefault()},onClick:h=>h.stopPropagation(),className:"w-full min-w-0 border-0 bg-transparent p-0 text-sm text-[var(--text-main)] outline-none"})}function Ld({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(fr,{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 Dd={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},eo={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function Od({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,h]=s.useState(null);d.current=u;const[b,f]=s.useState(null),p=s.useRef(null);p.current=b;const[v,w]=s.useState({}),[g,A]=s.useState(null),C=s.useRef(null);C.current=g;const[T,H]=s.useState({}),[E,x]=s.useState({}),M=s.useRef(new Set),k=s.useRef(null);s.useEffect(()=>{var P;const $=document.activeElement;(!$||$===document.body)&&((P=k.current)==null||P.focus({preventScroll:!0}))},[]);const _=e.map($=>{var P,ce,O;return`${$.key}:${((O=(ce=(P=$.editable)==null?void 0:P.select)==null?void 0:ce.options)==null?void 0:O.length)??-1}`}).join("|");s.useEffect(()=>{e.forEach($=>{var O,oe;const P=(oe=(O=$.editable)==null?void 0:O.select)==null?void 0:oe.options;if(!P)return;const ce=T[$.key];(!M.current.has($.key)||(ce==null?void 0:ce.length)===0&&P.length>0)&&(M.current.add($.key),H(G=>({...G,[$.key]:P})))})},[_]);const q=s.useCallback(async($,P)=>{if(M.current.has($))return;M.current.add($);const{url:ce,fetchOptions:O}=P.select??{};if(!(!ce&&!O)){x(oe=>({...oe,[$]:!0}));try{let oe=[];if(O)oe=await O();else if(ce){const G=await fetch(ce);if(!G.ok)throw new Error("fetch failed");oe=await G.json()}H(G=>({...G,[$]:oe}))}catch{H(oe=>({...oe,[$]:[]}))}finally{x(oe=>({...oe,[$]:!1}))}}},[]),X=s.useRef(i);X.current=i;const D=s.useRef(a);D.current=a;const K=s.useRef(n);K.current=n;const j=s.useRef(e);j.current=e;const le=s.useRef(o);le.current=o,s.useEffect(()=>{if(e.length>0&&r.length>0){const $=e.find(P=>P.selectable!==!1);$&&f({rowId:n(r[0]),colKey:$.key})}},[]),s.useEffect(()=>{if(!b)return;const $=k.current;if(!$)return;const P=$.querySelector(`[data-cell-id="${b.rowId}:${b.colKey}"]`);if(!P)return;const ce=$.querySelector('[role="rowgroup"]');P.style.scrollMarginTop=`${(ce==null?void 0:ce.offsetHeight)??0}px`;const O=$.querySelector('[role="row"]');let oe=0;O&&O.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(G=>{G.style.position==="sticky"&&G.style.left!==""&&(oe=Math.max(oe,parseFloat(G.style.left)+G.offsetWidth))}),P.style.scrollMarginLeft=`${oe}px`,P.scrollIntoView({block:"nearest",inline:"nearest"})},[b]);const Q=s.useCallback($=>{var oe;const P=j.current,ce=new Set,O=[];(oe=k.current)==null||oe.querySelectorAll("[data-cell-id]").forEach(G=>{const U=G.dataset.cellId.split(":")[0];ce.has(U)||(ce.add(U),O.push(U))}),f(G=>{if(!G)return G;const U=P.findIndex(ee=>ee.key===G.colKey),se=O.indexOf(G.rowId);let S=U,R=se;if($==="up")R=Math.max(0,se-1);else if($==="down")R=Math.min(O.length-1,se+1);else if($==="left"){let ee=U-1;for(;ee>=0&&P[ee].selectable===!1;)ee--;ee>=0&&(S=ee)}else if($==="right"){let ee=U+1;for(;ee<P.length&&P[ee].selectable===!1;)ee++;ee<P.length&&(S=ee)}return S===U&&R===se?G:{rowId:O[R],colKey:P[S].key}})},[]),fe=s.useCallback(($=!0)=>{const P=d.current;h(null),P&&f(P),$&&setTimeout(()=>{var ce;return(ce=k.current)==null?void 0:ce.focus({preventScroll:!0})},0)},[]),F=s.useCallback(async($,P,ce)=>{var re;const O=j.current.find(ge=>ge.key===P);if(!(O!=null&&O.editable))return;const{field:oe,type:G,mask:U,validate:se}=O.editable,S=G==="number"?ce===""?null:Number(ce):ce;if(U){const ge=Td(ce,U);if(ge){w(Se=>({...Se,[`${$}:${P}`]:ge}));return}}if(se){const ge=se(S);if(ge){w(Se=>({...Se,[`${$}:${P}`]:ge}));return}}const R=K.current,ee=X.current.find(ge=>R(ge)===$);if(!ee)return;const J=ee[oe];h(null),w(ge=>{const Se={...ge};return delete Se[`${$}:${P}`],Se});const y=X.current,N=y.findIndex(ge=>R(ge)===$),te=y[Math.min(y.length-1,N+1)];if(f({rowId:R(te),colKey:P}),setTimeout(()=>{var Se,$e;const ge=document.activeElement;(!ge||ge===document.body||(Se=k.current)!=null&&Se.contains(ge))&&(($e=k.current)==null||$e.focus({preventScroll:!0}))},0),String(J??"")===String(S??""))return;const ue={...ee,[oe]:S};c(ge=>ge.map(Se=>R(Se)===$?ue:Se)),A({rowId:$,colKey:P});try{await((re=D.current)==null?void 0:re.call(D,{row:ee,rowId:$,field:oe,oldValue:J,newValue:S}))}catch{c(ge=>ge.map(Se=>R(Se)===$?ee:Se)),w(ge=>({...ge,[`${$}:${P}`]:"Error al guardar. Intenta de nuevo."}))}finally{A(null)}},[]),V=s.useCallback($=>{if(C.current){$.preventDefault();return}if(d.current)return;const P=p.current;if(!(!P||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes($.key)))switch($.preventDefault(),$.key){case"ArrowUp":Q("up");break;case"ArrowDown":Q("down");break;case"ArrowLeft":Q("left");break;case"ArrowRight":Q("right");break;case"Tab":Q($.shiftKey?"left":"right");break;case"Enter":{const O=j.current.find(oe=>oe.key===P.colKey);O!=null&&O.editable&&!le.current?(h(P),O.editable.type==="select"&&!M.current.has(P.colKey)&&q(P.colKey,O.editable)):Q("down");break}}},[Q,q]),ae=s.useMemo(()=>e.map($=>{if(!$.editable||o){const ce={...$};if(delete ce.editable,delete ce.selectable,$.selectable===!1)return{...ce,disableRowClick:!0};const O=ce.cell;return{...ce,className:`relative ${ce.className??""}`.trim(),disableRowClick:!0,cell:oe=>{const G=n(oe),U=(b==null?void 0:b.rowId)===G&&(b==null?void 0:b.colKey)===$.key;return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${G}:${$.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var se;C.current||(f({rowId:G,colKey:$.key}),(se=k.current)==null||se.focus({preventScroll:!0}))}}),U&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:eo}),t.jsx("span",{className:"relative z-0 pointer-events-none",children:O(oe)})]})}}}const P=$.editable;return{...$,className:`relative ${$.className??""}`.trim(),disableRowClick:!0,cell:ce=>{const O=n(ce),oe=$.key,G=(u==null?void 0:u.rowId)===O&&(u==null?void 0:u.colKey)===oe,U=(b==null?void 0:b.rowId)===O&&(b==null?void 0:b.colKey)===oe,se=v[`${O}:${oe}`],S=(g==null?void 0:g.rowId)===O&&(g==null?void 0:g.colKey)===oe,R=ce[P.field],ee=String(R??""),J=()=>{var N;C.current||(f({rowId:O,colKey:oe}),h({rowId:O,colKey:oe}),(N=k.current)==null||N.focus({preventScroll:!0}),P.type==="select"&&!M.current.has(oe)&&q(oe,P))};if(G){const N=P.type==="select"?t.jsx(Ld,{initialValue:ee,options:T[oe]??[],loading:E[oe]??!1,onCommit:te=>F(O,oe,te),onCancel:fe}):t.jsx(Ad,{initialValue:ee,type:P.type??"text",mask:P.mask,onCommit:te=>F(O,oe,te),onCancel:fe});return t.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:Dd,onClick:te=>te.stopPropagation(),children:N})}const y=$.cell(ce);return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${O}:${oe}`,className:`peer absolute inset-0 z-10 ${S?"cursor-wait":"cursor-pointer"}`,onClick:J}),U&&!S&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:eo}),S&&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:eo,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:se?t.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[t.jsx(W.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"truncate text-xs",children:se})]}):t.jsx("span",{className:"truncate",children:y})}),!S&&t.jsx(W.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,b,g,v,T,E,n,F,fe,q]);return t.jsx("div",{ref:k,tabIndex:0,onKeyDown:V,onBlur:$=>{var P;(P=k.current)!=null&&P.contains($.relatedTarget)||setTimeout(()=>{var O,oe;const ce=document.activeElement;ce&&((O=ce.closest)!=null&&O.call(ce,"[data-bonsaif-select-dropdown]"))||(oe=k.current)!=null&&oe.contains(ce)||fe(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:t.jsx(Xa,{...l,columns:ae,data:i,getRowId:n})})}function it(e){if(e)return new Date(`${e}T12:00:00`)}function Ot(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 Tr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Fs(e){return e.map(r=>it(r)).filter(r=>!!r)}function Hd(e){if(!(e!=null&&e.length))return[];const r=new Set(e.map(Ot));return Array.from(r).sort()}function to(e){return new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(e)}function _s(e){const r=it(e);if(!r)return e;const n=to(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 ro={weekend:{dayOfWeek:[0,6]}},no={weekend:"bonsaif-weekend"};function ao({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 Bd={background:"var(--primary)",color:"var(--primary-fg, #ffffff)",borderRadius:999},Id={background:"color-mix(in srgb, var(--primary) 22%, transparent)",color:"var(--text-main)",borderRadius:999};function Fd({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?Bd:null,...o?Id:null,...l?{fontWeight:800}:null,...n.style}})}function _d({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:h=""}){const b={from:it(e),to:it(r)},f=it(a),[p,v]=s.useState(()=>it(o||e)??new Date);s.useEffect(()=>{const T=it(o||e);T&&v(T)},[o,e]);const w=s.useMemo(()=>{if(l<=1)return Tr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(p));const T=new Date(p.getFullYear(),p.getMonth()+l-1,1),H=p.getFullYear()===T.getFullYear(),E=new Intl.DateTimeFormat("es-MX",{month:"short",...H?{}:{year:"numeric"}}).format(p),x=new Intl.DateTimeFormat("es-MX",{month:"short",year:"numeric"}).format(T);return`${Tr(E)} – ${Tr(x)}`},[p,l]);function g(){v(new Date(p.getFullYear(),p.getMonth()-1,1))}function A(){v(new Date(p.getFullYear(),p.getMonth()+1,1))}const C=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 ${h}`.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:g,children:t.jsx(W.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:w}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes siguiente",onClick:A,children:t.jsx(W.HiChevronRight,{size:16})})]}),t.jsx(Fa.DayPicker,{mode:"range",selected:b,month:p,onMonthChange:v,onSelect:T=>{const H=T!=null&&T.from?Ot(T.from):e,E=T!=null&&T.to?Ot(T.to):"";n({startDate:H,endDate:E})},numberOfMonths:l,hideNavigation:!0,weekStartsOn:1,disabled:f?{before:f}:void 0,showOutsideDays:!1,modifiers:ro,modifiersClassNames:no,components:{DayButton:Fd,Weekday:ao},classNames:{root:"bonsaif-range-daypicker w-full",months:C,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:T=>`${Tr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(T))} ${T.getFullYear()}`,formatWeekdayName:to}})]}),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 zs(e,r){const n=it(e),a=it(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(Ot(c)),c.setDate(c.getDate()+1);return i}function Ws(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 an(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 Pd(e,r){return typeof r!="number"||r<=0||e.length<=r?e:e.slice(-r)}function zd(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,isDateDisabled:i,retainOutsidePrefix:c}){const d=s.useRef(null),u=s.useRef(null),h=s.useRef(!1),b=s.useRef(e);b.current=e;const f=s.useCallback(E=>{let x=E;if(c){const M=b.current.filter(_=>!_.startsWith(c)),k=E.filter(_=>_.startsWith(c));x=[...M,...k].sort()}r==null||r(Pd(x,l))},[l,r,c]),p=s.useCallback((E,x=!1)=>zd(E,a,o)?!0:!(!(i!=null&&i(E))||x&&b.current.includes(E)),[i,o,a]),v=s.useCallback(E=>E.filter(x=>!p(x)),[p]),w=s.useCallback(()=>{u.current=null},[]);s.useEffect(()=>{const E=()=>w();return window.addEventListener("pointerup",E),window.addEventListener("pointercancel",E),()=>{window.removeEventListener("pointerup",E),window.removeEventListener("pointercancel",E)}},[w]);const g=s.useCallback((E,x,M,k)=>{const _=v(zs(E,x));f(M==="add"?an(k,_,"add"):an(k,_,"remove"))},[f,v]),A=s.useCallback((E,x)=>{if(n||x.button!==0)return;const M=Ot(E);if(p(M,!0)||x.shiftKey)return;h.current=!0;const k=[...b.current],_=k.includes(M)?"remove":"add";_==="add"&&p(M)||(u.current={active:!0,mode:_,anchor:M,latest:M,baseline:k},d.current=M,g(M,M,_,k),x.preventDefault())},[g,n,p]),C=s.useCallback(E=>{const x=u.current;if(!(x!=null&&x.active)||n)return;const M=Ot(E);x.mode==="add"&&p(M)||x.latest!==M&&(x.latest=M,g(x.anchor,M,x.mode,x.baseline))},[g,n,p]),T=s.useCallback((E,x)=>{if(n)return;const M=Ot(E);if(!p(M,!0)){if(h.current&&!x.shiftKey){h.current=!1,x.preventDefault(),x.stopPropagation();return}if(h.current=!1,x.shiftKey&&d.current){x.preventDefault(),x.stopPropagation();const k=v(zs(d.current,M));f(an(b.current,k,"add"));return}!b.current.includes(M)&&p(M)||(d.current=M,f(an(b.current,[M],"toggle")))}},[f,n,v,p]),H=s.useCallback(E=>{if(n)return;const x=v(Hd(E));if(!x.length)return;const M=x.every(k=>b.current.includes(k));f(an(b.current,x,M?"remove":"add")),d.current=x[0]??d.current},[f,n,v]);return{onDayPointerDown:A,onDayPointerEnter:C,onDayClick:T,toggleWeek:H,endDrag:w}}function on(e){return Ws(e,1)[0]}function qs(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function Wd({value:e=[],onChange:r,minDate:n,maxDate:a,isDateDisabled:o,viewMonth:l,maxDates:i,showWeekNumbers:c=!1,viewMode:d,defaultViewMode:u="month",onViewModeChange:h,showSummary:b=!0,className:f="",disabled:p=!1}){const v=s.useMemo(()=>Fs(e),[e]),w=s.useMemo(()=>new Set(e),[e]),g=it(n),A=it(a),[C,T]=s.useState(()=>it(l||e[0])??new Date),[H,E]=s.useState(()=>on(it(l||e[0])??new Date)),[x,M]=s.useState(u),k=d??x;function _($){d===void 0&&M($),h==null||h($)}s.useEffect(()=>{const $=it(l);$&&(T($),E(on($)))},[l]);const{onDayPointerDown:q,onDayPointerEnter:X,onDayClick:D,toggleWeek:K}=js({value:e,onChange:r,disabled:p,minDate:n,maxDate:a,maxDates:i,isDateDisabled:o}),j=s.useMemo(()=>{if(p)return!0;const $=[];return g&&$.push({before:g}),A&&$.push({after:A}),o&&$.push(P=>o(Ot(P))),$.length>0?$:void 0},[p,o,A,g]),le=s.useCallback($=>t.jsx(Ps,{...$,className:`bonsaif-multi-day-btn ${$.className??""}`,onDayPointerDown:q,onDayPointerEnter:X,onDayClickSelect:D}),[D,q,X]),Q=s.useMemo(()=>Ws(H,1),[H]),fe=Q[6],F=k==="week"?`${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short"}).format(Q[0])} – ${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short",year:"numeric"}).format(fe)}`:Tr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(C));function V(){if(k==="week"){const $=qs(H,-7);E(on($)),T($);return}T(new Date(C.getFullYear(),C.getMonth()-1,1))}function ae(){if(k==="week"){const $=qs(H,7);E(on($)),T($);return}T(new Date(C.getFullYear(),C.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":k==="month",className:`bonsaif-cal-view-btn${k==="month"?" is-active":""}`,disabled:p,onClick:()=>{_("month"),T(H)},children:"Mes"}),t.jsx("button",{type:"button",role:"tab","aria-selected":k==="week",className:`bonsaif-cal-view-btn${k==="week"?" is-active":""}`,disabled:p,onClick:()=>{_("week"),E(on(C))},children:"Semana"})]}),t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":k==="week"?"Semana anterior":"Mes anterior",disabled:p,onClick:V,children:t.jsx(W.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:F}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":k==="week"?"Semana siguiente":"Mes siguiente",disabled:p,onClick:ae,children:t.jsx(W.HiChevronRight,{size:16})})]}),t.jsxs("p",{className:"bonsaif-cal-hint",children:["Click · Shift+click rango · Arrastra",c&&k==="month"?" · Semana (nº)":"",k==="week"?" · Botón semana completa":""]}),k==="month"?t.jsx(Fa.DayPicker,{mode:"multiple",required:!1,selected:v,month:C,onMonthChange:T,onSelect:()=>{},hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,showWeekNumber:c,onWeekNumberClick:($,P)=>{K(P)},disabled:j,className:"bonsaif-multi-daypicker",modifiers:ro,modifiersClassNames:no,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:c?"bonsaif-multi-weekdays bonsaif-multi-weekdays--with-week":"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:c?"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:le,Weekday:ao},formatters:{formatWeekdayName:to}}):t.jsxs("div",{className:"bonsaif-week-view",children:[t.jsx("div",{className:"bonsaif-week-view-head",children:Q.map($=>t.jsx("div",{className:"bonsaif-multi-weekday",children:new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format($)},`h-${Ot($)}`))}),t.jsx("div",{className:"bonsaif-week-view-days",children:Q.map($=>{const P=Ot($),ce=w.has(P),O=p||(n?P<n:!1)||(a?P>a:!1)||!!(o!=null&&o(P)),oe=P===Ot(new Date);return t.jsx("div",{className:`bonsaif-multi-day${ce?" bonsaif-multi-day-selected":""}${oe?" bonsaif-multi-day-today":""}${O?" bonsaif-multi-day-disabled":""}`,children:t.jsxs("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:O,"aria-pressed":ce,onPointerDown:G=>q($,G),onPointerEnter:()=>X($),onClick:G=>D($,G),children:[t.jsx("span",{className:"bonsaif-week-day-num",children:$.getDate()}),t.jsx("span",{className:"bonsaif-week-day-month",children:new Intl.DateTimeFormat("es-MX",{month:"short"}).format($)})]})},P)})}),t.jsx("button",{type:"button",className:"bonsaif-week-select-all",disabled:p,onClick:()=>K(Q),children:"Marcar / desmarcar semana"})]})]}),b?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($=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:p,onClick:()=>r==null?void 0:r(e.filter(P=>P!==$)),title:`Quitar ${$}`,children:[_s($),t.jsx("span",{"aria-hidden":!0,children:"×"})]},$))})]})}):null]})}const jd=Array.from({length:12},(e,r)=>r);function qd({value:e=[],onChange:r,year:n,onYearChange:a,minDate:o,maxDate:l,maxDates:i,showSummary:c=!0,className:d="",disabled:u=!1,readOnly:h=!1}){const b=s.useMemo(()=>Fs(e),[e]),f=it(o),p=it(l),v=n??(e[0]?Number(e[0].slice(0,4)):new Date().getFullYear()),[w,g]=s.useState(v);s.useEffect(()=>{typeof n=="number"&&g(n)},[n]);function A(k){g(k),a==null||a(k)}const{onDayPointerDown:C,onDayPointerEnter:T,onDayClick:H}=js({value:e,onChange:r,disabled:u||h,minDate:o,maxDate:l,maxDates:i,retainOutsidePrefix:`${w}-`}),E=s.useCallback(k=>t.jsx(Ps,{...k,className:`bonsaif-year-day-btn ${k.className??""}`,onDayPointerDown:C,onDayPointerEnter:T,onDayClickSelect:H}),[H,C,T]),x=b.filter(k=>k.getFullYear()===w),M=u?!0:[...f?[{before:f}]:[],...p?[{after:p}]:[]];return t.jsxs("div",{className:`bonsaif-calendar bonsaif-year-multi-date-calendar${h?" 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:()=>A(w-1),children:t.jsx(W.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:w}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año siguiente",disabled:u,onClick:()=>A(w+1),children:t.jsx(W.HiChevronRight,{size:16})})]}),!h&&!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:jd.map(k=>{const _=new Date(w,k,1);return t.jsxs("div",{className:"bonsaif-year-cal-month",children:[t.jsx("div",{className:"bonsaif-year-cal-month-title",children:Tr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(_))}),t.jsx(Fa.DayPicker,{mode:"multiple",required:!1,selected:x,month:_,onMonthChange:()=>{},onSelect:()=>{},numberOfMonths:1,hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,disabled:M,className:"bonsaif-year-month-picker",modifiers:ro,modifiersClassNames:no,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:E,Weekday:ao},formatters:{formatWeekdayName:q=>new Intl.DateTimeFormat("es-MX",{weekday:"narrow"}).format(q)}})]},`${w}-${k}`)})})]}),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"," ·"," ",w]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(k=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:u||h,onClick:()=>r==null?void 0:r(e.filter(_=>_!==k)),title:`Quitar ${k}`,children:[_s(k),t.jsx("span",{"aria-hidden":!0,children:"×"})]},k))})]})}):null]})}const Ud="bonsaif-ui:hide-tooltips";function Us(){window.dispatchEvent(new CustomEvent(Ud))}function Vd(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Xd({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),[h,b]=s.useState(!1),[f,p]=s.useState({}),v=s.useRef(null),w=s.useRef(null),g=s.useCallback(E=>{u(E),c==null||c(E)},[c]),A=s.useCallback(()=>{const E=v.current;if(!E)return;const x=E.getBoundingClientRect(),M=typeof a=="number"?a:x.width,k=typeof a=="number"?a:Math.max(x.width,180),_=n==="end"?Math.max(8,x.right-k):Math.min(x.left,window.innerWidth-k-8),q=window.innerHeight-x.bottom,X=q<240&&x.top>q?void 0:x.bottom+6,D=X===void 0?window.innerHeight-x.top+6:void 0;p({position:"fixed",zIndex:9999,left:_,top:X,bottom:D,width:Vd(typeof a=="number"?M:a)})},[n,a]);s.useEffect(()=>b(!0),[]),s.useEffect(()=>{if(!d)return;A();const E=M=>{var _,q;const k=M.target;!((_=v.current)!=null&&_.contains(k))&&!((q=w.current)!=null&&q.contains(k))&&g(!1)},x=M=>{M.key==="Escape"&&g(!1)};return document.addEventListener("mousedown",E),window.addEventListener("keydown",x),window.addEventListener("resize",A),window.addEventListener("scroll",A,!0),()=>{document.removeEventListener("mousedown",E),window.removeEventListener("keydown",x),window.removeEventListener("resize",A),window.removeEventListener("scroll",A,!0)}},[d,g,A]);const C=E=>{o||(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),g(!d))},T=s.isValidElement(e)?s.cloneElement(e,{onClick:()=>{o||(Us(),g(!d))}}):e,H=d?t.jsx("div",{ref:w,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(E=>t.jsxs("div",{children:[E.separatorBefore&&t.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),t.jsxs("button",{type:"button",role:"menuitem",disabled:E.disabled,onClick:()=>{var x;E.disabled||(Us(),(x=E.onSelect)==null||x.call(E),g(!1))},className:"flex w-full min-w-0 items-start gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:E.danger?"var(--danger)":"var(--text-main)"},children:[E.icon&&t.jsx("span",{className:"mt-0.5 shrink-0",children:E.icon}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium",children:E.label}),E.description&&t.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:E.description})]})]})]},E.id))}):null;return t.jsxs("span",{ref:v,role:"button",tabIndex:o?-1:0,"aria-haspopup":"menu","aria-expanded":d,onKeyDown:C,className:`inline-flex ${o?"pointer-events-none opacity-60":""} ${l}`,children:[T,h&&H?mt.createPortal(H,document.body):null]})}const Yd=180,Vs="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function Kd({open:e,onClose:r,title:n,subtitle:a,leadingIcon:o,confirmLabel:l="Guardar",onConfirm:i,loading:c=!1,confirmDisabled:d=!1,headerActions:u,bodyClassName:h="flex-1 overflow-y-auto px-6 py-5",width:b=440,hasUnsavedChanges:f=!1,unsavedChangesTitle:p="Descartar cambios",unsavedChangesDescription:v="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:w="Descartar",unsavedChangesCancelLabel:g="Seguir editando",onDiscardChanges:A,disabled:C=!1,disabledMessage:T,children:H}){const[E,x]=s.useState(!1),[M,k]=s.useState(!1),[_,q]=s.useState(!1),X=s.useCallback(()=>{k(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>q(!0))})},[]),D=s.useCallback(()=>{q(!1),window.setTimeout(()=>k(!1),Yd)},[]),K=C||c,j=s.useCallback(()=>{if(!K){if(f){X();return}r()}},[K,f,r,X]),le=s.useCallback(()=>{q(!1),k(!1),A==null||A(),r()},[r,A]);if(s.useEffect(()=>{x(!0)},[]),s.useEffect(()=>(document.body.style.overflow=e?"hidden":"",e||(q(!1),k(!1)),()=>{document.body.style.overflow=""}),[e]),s.useEffect(()=>{if(!e)return;const fe=F=>{if(F.key==="Escape"&&!K){if(M){D();return}j()}};return window.addEventListener("keydown",fe),()=>window.removeEventListener("keydown",fe)},[D,K,M,e,j]),!E)return null;const Q=T!==void 0?T:c?"Guardando…":null;return mt.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 ${Vs}`,onClick:j}),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(Ke,{variant:"icon",onClick:j,title:"Cerrar",disabled:K,children:t.jsx(W.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(Ke,{variant:"secondary",size:"sm",onClick:j,disabled:K,style:{background:"var(--bg-input)"},children:"Cancelar"}),t.jsx(Ke,{variant:"primary",size:"sm",icon:t.jsx(dc.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:d||K,title:l})]})]})]}),t.jsx("div",{"data-drawer-scroll":"true",className:h,children:H}),K&&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:Q?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:Q})]}):null})]}),M&&t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":p,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[t.jsx("div",{className:`absolute inset-0 ${Vs} transition-opacity duration-200 ease-out ${_?"opacity-100":"opacity-0"}`,onClick:D}),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 ${_?"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(Ke,{variant:"icon",onClick:D,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":g,children:t.jsx(W.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(W.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:p}),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(Ke,{variant:"secondary",onClick:D,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:g}),t.jsx(Ke,{variant:"secondary",onClick:le,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:w})]})]})]})]}),document.body)}const Gd=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Zd=/^\+?[0-9\s().-]+$/,Qd=7,Jd=15;function zt(e){return e==null||String(e).trim()===""}function Xs(e){return typeof e=="number"?e:typeof e=="string"&&e.trim()!==""?Number(e):Number.NaN}function oo(e){return zt(e)?!1:Gd.test(String(e))}function so(e){if(zt(e))return!1;const r=String(e),n=r.replace(/\D/g,"");return Zd.test(r)&&n.length>=Qd&&n.length<=Jd}function Rd(e="Este campo es requerido."){return r=>zt(r)?e:void 0}function eu(e="Ingresa un correo valido."){return r=>zt(r)||oo(r)?void 0:e}function tu(e="Ingresa un telefono valido."){return r=>zt(r)||so(r)?void 0:e}function ru(e,r){return n=>zt(n)||String(n).length>=e?void 0:r??`Debe tener al menos ${e} caracteres.`}function nu(e,r){return n=>zt(n)||String(n).length<=e?void 0:r??`Debe tener ${e} caracteres o menos.`}function au(e,r){return n=>{if(zt(n))return;const a=Xs(n);return Number.isFinite(a)&&a>=e?void 0:r??`Debe ser mayor o igual a ${e}.`}}function ou(e,r){return n=>{if(zt(n))return;const a=Xs(n);return Number.isFinite(a)&&a<=e?void 0:r??`Debe ser menor o igual a ${e}.`}}function su(e,r="El formato no es valido."){return n=>zt(n)||e.test(String(n))?void 0:r}function lu(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},Ks=s.createContext&&s.createContext(Ys),iu=["attr","size","title"];function cu(e,r){if(e==null)return{};var n,a,o=du(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 du(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 Pn(){return Pn=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},Pn.apply(null,arguments)}function Gs(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 zn(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Gs(Object(n),!0).forEach(function(a){uu(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Gs(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function uu(e,r,n){return(r=fu(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function fu(e){var r=bu(e,"string");return typeof r=="symbol"?r:r+""}function bu(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 Zs(e){return e&&e.map((r,n)=>s.createElement(r.tag,zn({key:n},r.attr),Zs(r.child)))}function lo(e){return r=>s.createElement(hu,Pn({attr:zn({},e.attr)},r),Zs(e.child))}function hu(e){var r=n=>{var{attr:a,size:o,title:l}=e,i=cu(e,iu),c=o||n.size||"1em",d;return n.className&&(d=n.className),e.className&&(d=(d?d+" ":"")+e.className),s.createElement("svg",Pn({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,i,{className:d,style:zn(zn({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 Ks!==void 0?s.createElement(Ks.Consumer,null,n=>r(n)):r(Ys)}function Qs(e){return lo({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 mu(e){return lo({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 pu(e){return lo({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 $r({content:e,ariaLabel:r="Más información",className:n=""}){return t.jsx(_t,{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(W.HiInformationCircle,{className:"h-3.5 w-3.5"})})})}function Ar({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 Wn({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 io({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:h=!1,className:b="",required:f,...p}){const[v,w]=s.useState(()=>!!p.autoFocus),[g,A]=s.useState(!1),C=p.type==="password"&&u,T=C&&g?"text":p.type,H=!!o,E=H&&l!=="tooltip",x=H&&l!=="inline",M=!!n&&a==="tooltip"&&!E,k=h?f:void 0,_=H?"border-[var(--danger)] focus:border-[var(--danger)]":"",q=x?C?"pr-20":"pr-10":C?"pr-10":"",X=p.value!==void 0?String(p.value).length>0:p.defaultValue!==void 0&&String(p.defaultValue).length>0,D=v||X,K={top:D?7:12,color:v?"var(--primary)":"var(--text-muted)",fontSize:D?10:13,fontWeight:D?600:400,textTransform:D?"uppercase":"none"},j=V=>{var ae;w(!0),(ae=p.onFocus)==null||ae.call(p,V)},le=V=>{var ae;w(!1),(ae=p.onBlur)==null||ae.call(p,V)},Q=C?t.jsxs("button",{type:"button","aria-label":g?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":g,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors duration-200 hover:text-[var(--primary)] focus:outline-none",tabIndex:-1,onClick:()=>A(V=>!V),children:[t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${g?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:t.jsx(mu,{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 ${g?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:t.jsx(pu,{className:"h-[18px] w-[18px]"})})]}):null,fe=x?t.jsx(_t,{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)] ${C?"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(Qs,{className:"h-[18px] w-[18px]"})})}):null,F=t.jsx(Ar,{error:E?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(Wn,{...p,type:T,required:k,placeholder:" ","aria-invalid":H||p["aria-invalid"],"data-has-value":X?"true":void 0,className:`h-11 w-full pt-5 ${q} ${_} ${b}`,onFocus:j,onBlur:le}),t.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:K,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:D?7:12},children:c}),fe,Q]}),F]}):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:"*"}),M?t.jsx($r,{content:n}):null,c&&t.jsx("span",{className:"ml-auto normal-case",children:c})]}),C?t.jsxs("span",{className:"relative block",children:[t.jsx(Wn,{...p,type:T,required:k,"aria-invalid":H||p["aria-invalid"],className:`w-full ${q} ${_} ${b}`,onFocus:j,onBlur:le}),fe,Q]}):t.jsxs("span",{className:"relative block",children:[t.jsx(Wn,{...p,required:k,"aria-invalid":H||p["aria-invalid"],className:`w-full ${q} ${_} ${b}`}),fe]}),F]})}function Js(e){return e==null?"":String(e)}function gu({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[h,b]=s.useState(()=>Js(c)),f=i!==void 0?Js(i):h,p=n&&f.length>0&&!oo(f)?a:void 0,v=w=>{i===void 0&&b(w.currentTarget.value),d==null||d(w)};return t.jsx(io,{...u,value:i,defaultValue:c,type:"text",inputMode:r,autoComplete:e,error:l??p,errorDisplay:o,onChange:v})}const vu={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function yu(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 Rs(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 xu(e,r,n){return r?n===void 0?e:e.slice(0,Math.max(0,n)):e.slice(0,1)}function wu({label:e,helperText:r,helperDisplay:n="inline",error:a,labelAction:o,value:l,defaultValue:i=[],onFilesChange:c,onRejectedFiles:d,multiple:u=!1,maxFiles:h,appendFiles:b=!1,showFileList:f=!0,clearable:p=!0,browseLabel:v="Buscar archivos",dropLabel:w="Suelta los archivos aqui",emptyLabel:g="Arrastra y suelta archivos",emptyDescription:A="o haz click para buscarlos en tu equipo",selectedLabel:C="Archivos seleccionados",size:T="md",containerClassName:H="",dropzoneClassName:E="",fileListClassName:x="",className:M="",id:k,accept:_,disabled:q,required:X,...D}){const K=s.useId(),j=k??K,le=s.useRef(null),[Q,fe]=s.useState(!1),[F,V]=s.useState(i),ae=l??F,$=!!a,P=!!r&&n==="tooltip"&&!$,ce=p&&ae.length>0&&!q,O=(N,te)=>{l===void 0&&V(N),c==null||c(N,te)},oe=(N,te)=>{const ue=N.filter($e=>Rs($e,_)),re=N.filter($e=>!Rs($e,_)),ge=b?[...ae,...ue]:ue,Se=xu(ge,u,h);re.length>0&&(d==null||d(re)),O(Se,te)},G=()=>{var N;q||(N=le.current)==null||N.click()},U=N=>{oe(Array.from(N.target.files??[]),N),N.target.value=""},se=N=>{N.preventDefault(),q||fe(!0)},S=N=>{N.currentTarget.contains(N.relatedTarget)||fe(!1)},R=N=>{N.preventDefault(),fe(!1),!q&&oe(Array.from(N.dataTransfer.files),N)},ee=N=>{N.key!=="Enter"&&N.key!==" "||(N.preventDefault(),G())},J=N=>{O(ae.filter((te,ue)=>ue!==N))},y=()=>{O([])};return t.jsxs("div",{className:`flex flex-col gap-2 ${H}`,children:[(e||o||P)&&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}),X&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),P?t.jsx($r,{content:r}):null,o&&t.jsx("span",{className:"ml-auto normal-case",children:o})]}),t.jsx("input",{...D,ref:le,id:j,type:"file",accept:_,multiple:u,disabled:q,required:X&&ae.length===0,"aria-invalid":$||D["aria-invalid"],className:"sr-only",onChange:U}),t.jsxs("div",{role:"button",tabIndex:q?-1:0,"aria-controls":j,"aria-disabled":q||void 0,"aria-invalid":$||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)] ${vu[T]} ${Q?"border-[var(--primary)] bg-[var(--bg-input)]":$?"border-[var(--danger)]":"border-[var(--border)]"} ${q?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${E} ${M}`,onClick:G,onDragOver:se,onDragLeave:S,onDrop:R,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(W.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:Q?w:g}),A&&t.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:A})]}),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&&ae.length>0&&t.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${x}`,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:C}),ce&&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:y,children:t.jsx(W.HiTrash,{className:"h-4 w-4"})})]}),t.jsx("ul",{className:"divide-y divide-[var(--border)]",children:ae.map((N,te)=>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(W.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:N.name}),t.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:yu(N.size)})]}),!q&&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 ${N.name}`,onClick:()=>J(te),children:t.jsx(W.HiXMark,{className:"h-4 w-4"})})]},`${N.name}-${N.lastModified}-${te}`))})]}),t.jsx(Ar,{error:a,helperText:r,helperDisplay:n})]})}const Nu=[{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 ku({fields:e,title:r="Layout",fieldTypes:n=Nu,saveLabel:a="Guardar",allowAddField:o=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:d,onChange:u}){const[h,b]=s.useState(()=>e.map(T=>({key:!1,type:"",...T}))),[f,p]=s.useState(""),[v,w]=s.useState(""),g=s.useCallback((T,H)=>{b(E=>{const x=E.map((M,k)=>k===T?{...M,...H}:M);return u==null||u(x),x})},[u]),A=s.useCallback(()=>{d==null||d(h)},[h,d]),C=s.useCallback(()=>{var x;const T=f.trim();if(!T){w("Ingresa un nombre de campo.");return}if(h.some(M=>M.name.toLowerCase()===T.toLowerCase())){w("Ese campo ya existe en el arreglo.");return}const E={name:T,key:!1,type:((x=n[0])==null?void 0:x.value)??""};b(M=>{const k=[...M,E];return u==null||u(k),k}),p(""),w("")},[n,h,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:[h.map((T,H)=>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:T.name}),t.jsx("div",{className:"flex justify-center",children:t.jsx(Tn,{size:"sm",checked:T.key??!1,onChange:E=>g(H,{key:E.target.checked}),"aria-label":`${T.name} es clave`})}),t.jsx(fr,{value:T.type??"",onChange:E=>g(H,{type:E}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${T.name}`})]},T.name)),h.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:f,onChange:T=>{p(T.currentTarget.value),v&&w("")},onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),C())},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(Ke,{variant:"secondary",onClick:C,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(Ke,{variant:"primary",onClick:A,disabled:c,loading:c,children:a})})]})})]})}function jn({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($r,{content:n}):null,l&&t.jsx("span",{className:"ml-auto normal-case",children:l})]}),t.jsx("span",{className:`block ${d}`,children:r}),t.jsx(Ar,{error:o,helperText:n,helperDisplay:a})]})}function Su(e){return Array.from(e.querySelectorAll("img")).filter(r=>!!(r.currentSrc||r.src||"").trim())}function el(e,r){const n=e.target;if(!(n instanceof HTMLImageElement))return!1;const a=e.currentTarget,o=Su(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 Ht=260,Lr=420,co=380,Wt="cubic-bezier(0.22, 1, 0.36, 1)",Cu="cubic-bezier(0.16, 1, 0.3, 1)",uo="cubic-bezier(0.22, 1, 0.36, 1)",Eu="cubic-bezier(0.22, 1, 0.36, 1)",Mu=8,Tu=1,$u=1.25,fo={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)"},Au="color-mix(in srgb, var(--bg-card) 88%, var(--primary) 12%)",bo=10;function sn(e,r,n){return Math.min(n,Math.max(r,e))}function Lu(e){return!e||e.width<1||e.height<1?null:{left:e.left,top:e.top,width:e.width,height:e.height}}function tl(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 Dr({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:{...fo,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=Au,i.currentTarget.style.transform="scale(1.06)")},onMouseLeave:i=>{i.currentTarget.style.background=String(fo.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 rl({open:e,onClose:r,slides:n,index:a,onIndexChange:o,originRect:l=null,maxZoom:i=Mu,minZoom:c=Tu,zoomStep:d=$u,closeOnBackdrop:u=!0,closeOnEscape:h=!0,showCounter:b=!0,showZoomControls:f=!0,loop:p=!0,showThumbnails:v=!0,zIndex:w=1100,ariaLabel:g="Visor de imagen"}){const[A,C]=s.useState(!1),[T,H]=s.useState(!1),[E,x]=s.useState(a??0),[M,k]=s.useState(1),[_,q]=s.useState({x:0,y:0}),[X,D]=s.useState({opacity:1,x:0,scale:1,blur:0,animate:!1}),[K,j]=s.useState({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),[le,Q]=s.useState(!1),fe=s.useRef(null),F=s.useRef(null),V=s.useRef(null),ae=s.useRef(null),$=s.useRef(null),P=s.useRef(!1),ce=s.useRef(!1),O=s.useRef(null),oe=s.useRef(null),G=s.useRef(null),U=s.useRef(null),se=s.useRef(null),S=s.useRef(a??0),R=a??E,ee=n.length===0?0:sn(R,0,Math.max(0,n.length-1)),J=n[ee],y=n.length>1,N=Math.max(c,i),te=v&&y,ue=s.useCallback(he=>{if(n.length===0)return;const ve=n.length-1,Ie=p?(he%n.length+n.length)%n.length:sn(he,0,ve);a===void 0&&x(Ie),o==null||o(Ie)},[a,p,o,n.length]),re=s.useCallback(()=>{k(1),q({x:0,y:0})},[]),ge=s.useCallback((he,ve)=>{if(ve<=c+.001)return{x:0,y:0};const Ie=U.current,_e=se.current;if(!Ie||!_e)return he;const Pe=Ie.getBoundingClientRect(),ft=_e.offsetWidth*ve,st=_e.offsetHeight*ve,Ve=Math.max(0,(ft-Pe.width)/2+Pe.width*.15),Re=Math.max(0,(st-Pe.height)/2+Pe.height*.15);return{x:sn(he.x,-Ve,Ve),y:sn(he.y,-Re,Re)}},[c]),Se=s.useCallback(()=>{C(!1),j({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),ae.current=null,$.current=null,P.current=!1,ce.current=!1,O.current&&(clearTimeout(O.current),O.current=null)},[]),$e=s.useCallback(()=>{if(P.current)return;P.current=!0,H(!1),re();const he=ae.current,ve=he!=null&&$.current!=null&&$.current===ee;if(he&&ve){V.current!=null&&cancelAnimationFrame(V.current),V.current=requestAnimationFrame(()=>{V.current=requestAnimationFrame(()=>{const Ie=se.current;if(!Ie){V.current=null,fe.current&&clearTimeout(fe.current),fe.current=setTimeout(Se,Ht+40);return}const _e=Ie.getBoundingClientRect(),Pe=tl(he,_e);j({enabled:!0,dx:0,dy:0,scale:1,animate:!1}),V.current=requestAnimationFrame(()=>{j({enabled:!0,dx:Pe.dx,dy:Pe.dy,scale:Pe.scale,animate:!0}),V.current=null})})}),fe.current&&clearTimeout(fe.current),fe.current=setTimeout(Se,Lr+80);return}j({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),fe.current&&clearTimeout(fe.current),fe.current=setTimeout(Se,Ht+40)},[Se,re,ee]);s.useEffect(()=>(e?(fe.current&&clearTimeout(fe.current),O.current&&(clearTimeout(O.current),O.current=null),P.current=!1,ce.current=!1,ae.current=Lu(l),$.current=ae.current!=null?a??E:null,C(!0),H(!1),ae.current?j({dx:0,dy:0,scale:1,animate:!1,enabled:!0}):($.current=null,requestAnimationFrame(()=>requestAnimationFrame(()=>{H(!0),j({dx:0,dy:0,scale:1,animate:!1,enabled:!1})})))):A&&$e(),()=>{fe.current&&clearTimeout(fe.current),V.current!=null&&cancelAnimationFrame(V.current)}),[e]);const ht=s.useCallback(()=>{if(!e||P.current||ce.current)return;const he=ae.current,ve=se.current;if(!he||!ve){he||(H(!0),ce.current=!0);return}const Ie=ve.getBoundingClientRect();if(Ie.width<2||Ie.height<2)return;ce.current=!0;const _e=tl(he,Ie);j({enabled:!0,dx:_e.dx,dy:_e.dy,scale:_e.scale,animate:!1}),V.current!=null&&cancelAnimationFrame(V.current),V.current=requestAnimationFrame(()=>{V.current=requestAnimationFrame(()=>{j({enabled:!0,dx:0,dy:0,scale:1,animate:!0}),H(!0),V.current=null,O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{j({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),O.current=null},Lr+20)})})},[e]);s.useLayoutEffect(()=>{!A||!e||!ae.current||ce.current||ht()},[A,e,ht]),s.useEffect(()=>{!e||P.current||$.current!=null&&$.current!==ee&&j(he=>he.enabled?{dx:0,dy:0,scale:1,animate:!1,enabled:!1}:he)},[e,ee]),s.useEffect(()=>{if(!e)return;const he=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=he}},[e]),s.useEffect(()=>{e&&re()},[e,ee,re]),s.useEffect(()=>{a!==void 0&&x(a)},[a]),s.useEffect(()=>{if(!e){S.current=ee,D({opacity:1,x:0,scale:1,blur:0,animate:!1});return}const he=S.current;if(he===ee)return;S.current=ee;const ve=n.length;let Ie=1;if(ve>1){const _e=(he+1)%ve===ee,Pe=(he-1+ve)%ve===ee;Pe&&!_e?Ie=-1:_e&&!Pe?Ie=1:Ie=ee>he?1:-1}return F.current!=null&&(cancelAnimationFrame(F.current),F.current=null),D({opacity:0,x:Ie*56,scale:.94,blur:8,animate:!1}),F.current=requestAnimationFrame(()=>{F.current=requestAnimationFrame(()=>{D({opacity:1,x:0,scale:1,blur:0,animate:!0}),F.current=null})}),()=>{F.current!=null&&(cancelAnimationFrame(F.current),F.current=null)}},[e,ee,n.length]);const Ct=M<=c+.001&&Math.abs(_.x)<.5&&Math.abs(_.y)<.5,rt=s.useCallback((he,ve,Ie)=>{k(_e=>{const Pe=sn(he,c,N);if(Math.abs(Pe-_e)<1e-4)return _e;const ft=Pe/_e,st=Pe<_e;return Pe<=c+.001?(q({x:0,y:0}),c):(q(Ve=>{let Re=Ve;if(typeof ve=="number"&&typeof Ie=="number"&&U.current&&!st){const ct=U.current.getBoundingClientRect(),lt=ve-ct.left-ct.width/2,mr=Ie-ct.top-ct.height/2;Re={x:lt-(lt-Ve.x)*ft,y:mr-(mr-Ve.y)*ft}}else if(st){Re={x:Ve.x*ft,y:Ve.y*ft};const ct=Math.min(1,(_e-Pe)/Math.max(.01,_e-c));Re={x:Re.x*(1-ct*.65),y:Re.y*(1-ct*.65)}}else Re={x:Ve.x*ft,y:Ve.y*ft};return ge(Re,Pe)}),Pe)})},[ge,c,N]),at=s.useCallback(()=>{rt(M*d)},[rt,M,d]),de=s.useCallback(()=>{const he=Math.max(c,M/d);if(he<=c+.001){re();return}k(he),q({x:0,y:0})},[c,re,M,d]);s.useEffect(()=>{if(!e)return;const he=ve=>{if(ve.key==="Escape"&&h){ve.preventDefault(),r();return}ve.key==="ArrowLeft"&&y?(ve.preventDefault(),ue(ee-1)):ve.key==="ArrowRight"&&y?(ve.preventDefault(),ue(ee+1)):ve.key==="+"||ve.key==="="?(ve.preventDefault(),rt(M*d)):ve.key==="-"||ve.key==="_"?(ve.preventDefault(),de()):ve.key==="0"&&(ve.preventDefault(),re())};return window.addEventListener("keydown",he),()=>window.removeEventListener("keydown",he)},[rt,h,y,r,e,re,ee,M,ue,de,d]);const Ee=he=>{he.preventDefault();const ve=he.deltaY>0?1/d:d;rt(M*ve,he.clientX,he.clientY)},ne=he=>{M<=c+.001||(he.currentTarget.setPointerCapture(he.pointerId),Q(!0),oe.current={pointerId:he.pointerId,startX:he.clientX,startY:he.clientY,originX:_.x,originY:_.y})},De=he=>{const ve=oe.current;!ve||ve.pointerId!==he.pointerId||q(ge({x:ve.originX+(he.clientX-ve.startX),y:ve.originY+(he.clientY-ve.startY)},M))},Be=he=>{var ve;((ve=oe.current)==null?void 0:ve.pointerId)===he.pointerId&&(oe.current=null,Q(!1))},Ue=he=>{if(he.stopPropagation(),M>c+.05){re();return}rt(Math.min(N,3),he.clientX,he.clientY)},je=he=>{if(he.touches.length!==2)return;Q(!0);const[ve,Ie]=[he.touches[0],he.touches[1]],_e=Math.hypot(ve.clientX-Ie.clientX,ve.clientY-Ie.clientY);G.current={distance:_e,scale:M}},Fe=he=>{if(he.touches.length!==2||!G.current)return;he.preventDefault();const[ve,Ie]=[he.touches[0],he.touches[1]],_e=Math.hypot(ve.clientX-Ie.clientX,ve.clientY-Ie.clientY),Pe=(ve.clientX+Ie.clientX)/2,ft=(ve.clientY+Ie.clientY)/2,st=G.current.scale*(_e/Math.max(1,G.current.distance));rt(st,Pe,ft)},Qe=()=>{G.current=null,Q(!1)};if(!A||!J)return null;const ot=K.enabled,Et=K.animate?`transform ${Lr}ms ${Eu}`:"none";return mt.createPortal(t.jsxs("div",{className:"fixed inset-0",style:{zIndex:w},role:"dialog","aria-modal":"true","aria-label":g,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:T?1:0,transition:`opacity ${ot?Lr:Ht}ms ${Wt}`,cursor:"default",zIndex:0},onClick:()=>{u&&r()}}),t.jsx("div",{ref:U,className:"absolute inset-0 flex items-center justify-center",style:{zIndex:1,padding:te?"4.5rem 3.5rem 6.5rem":"4.5rem 3.5rem 2.5rem",opacity:ot||T?1:0,transform:ot||T?"translateY(0) scale(1)":"translateY(10px) scale(0.96)",transition:ot?"none":`opacity ${Ht}ms ${Wt}, transform ${Ht}ms ${Wt}`},onClick:he=>{he.target===he.currentTarget&&u&&r()},onWheel:Ee,children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{transform:K.enabled?`translate3d(${K.dx}px, ${K.dy}px, 0) scale(${K.scale})`:void 0,transformOrigin:"center center",transition:K.enabled?Et:void 0},children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{opacity:X.opacity,filter:X.blur?`blur(${X.blur}px)`:"blur(0px)",transform:`translate3d(${X.x}px, 0, 0) scale(${X.scale})`,transition:X.animate?[`opacity ${co}ms ${uo}`,`transform ${co}ms ${uo}`,`filter ${co}ms ${uo}`].join(", "):"none"},children:t.jsx("div",{ref:se,className:"pointer-events-auto relative max-h-full max-w-full touch-none select-none will-change-transform",style:{cursor:M>c+.001?"grab":"zoom-in",transform:`translate3d(${_.x}px, ${_.y}px, 0) scale(${M})`,transformOrigin:"center center",transition:le?"none":`transform 220ms ${Cu}`},onClick:he=>he.stopPropagation(),onDoubleClick:Ue,onPointerDown:ne,onPointerMove:De,onPointerUp:Be,onPointerCancel:Be,onTouchStart:je,onTouchMove:Fe,onTouchEnd:Qe,children:t.jsx("img",{src:J.src,alt:J.alt||"",draggable:!1,className:"block max-h-[min(78vh,820px)] max-w-[min(86vw,1100px)] object-contain",style:{display:"block",borderRadius:bo,imageRendering:M>2.5?"pixelated":"auto"},onLoad:()=>{ht()}},J.src+String(ee))})})})}),t.jsxs("div",{className:"pointer-events-none absolute inset-0",style:{zIndex:2,opacity:T?1:0,transform:T?"translateY(0)":"translateY(-6px)",transition:`opacity ${ot?Lr:Ht}ms ${Wt}, transform ${ot?Lr:Ht}ms ${Wt}`},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:fo,children:[ee+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(Dr,{label:"Alejar",onClick:de,disabled:M<=c+.001,children:t.jsx(W.HiMinus,{className:"h-5 w-5"})}),t.jsx(Dr,{label:"Restablecer tamaño",onClick:re,disabled:Ct,children:t.jsx(W.HiArrowsPointingIn,{className:"h-5 w-5"})}),t.jsx(Dr,{label:"Acercar",onClick:at,disabled:M>=N-.001,children:t.jsx(W.HiPlus,{className:"h-5 w-5"})})]}):null,t.jsx(Dr,{label:"Cerrar",onClick:r,children:t.jsx(W.HiXMark,{className:"h-5 w-5"})})]})]}),y?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"pointer-events-auto absolute left-3 top-1/2",style:{opacity:T?1:0,transform:T?"translate(0, -50%)":"translate(-8px, -50%)",transition:`opacity ${Ht}ms ${Wt}, transform ${Ht}ms ${Wt}`},children:t.jsx(Dr,{label:"Anterior",size:"lg",onClick:()=>ue(ee-1),disabled:!p&&ee<=0,children:t.jsx(W.HiChevronLeft,{className:"h-6 w-6"})})}),t.jsx("div",{className:"pointer-events-auto absolute right-3 top-1/2",style:{opacity:T?1:0,transform:T?"translate(0, -50%)":"translate(8px, -50%)",transition:`opacity ${Ht}ms ${Wt}, transform ${Ht}ms ${Wt}`},children:t.jsx(Dr,{label:"Siguiente",size:"lg",onClick:()=>ue(ee+1),disabled:!p&&ee>=n.length-1,children:t.jsx(W.HiChevronRight,{className:"h-6 w-6"})})})]}):null,te?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((he,ve)=>{const Ie=ve===ee;return t.jsx("button",{type:"button",role:"tab","aria-selected":Ie,"aria-label":he.alt||`Imagen ${ve+1}`,onClick:_e=>{_e.stopPropagation(),ue(ve)},className:"relative shrink-0 overflow-hidden transition-opacity",style:{width:56,height:42,borderRadius:bo,opacity:Ie?1:.42,transition:`opacity 180ms ${Wt}`},children:t.jsx("img",{src:he.src,alt:"",draggable:!1,className:"h-full w-full object-cover",style:{borderRadius:bo}})},`${he.src}-${ve}`)})})}):null]})]}),document.body)}function Du({children:e,className:r,style:n,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c,zIndex:d}){const[u,h]=s.useState(!1),[b,f]=s.useState(0),[p,v]=s.useState([]),[w,g]=s.useState(null),A=s.useCallback((T,H,E)=>{v(T),g(E??null),f(H),h(!0)},[]),C=s.useCallback(T=>{el(T,A)},[A]);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`[&_img]:cursor-zoom-in ${r??""}`,style:n,onClick:C,children:e}),t.jsx(rl,{open:u,onClose:()=>h(!1),index:b,onIndexChange:f,slides:p,originRect:w,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c,zIndex:d})]})}function nl(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function al(e,r){if(e.length!==r.length)return!1;const n=new Set(r);return e.every(a=>n.has(a))}function ho(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Ou(e,r){if(!r)return!0;const n=ho(r);return ho(e.label).includes(n)||!!(e.sublabel&&ho(e.sublabel).includes(n))}function Hu({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:h=6,maxVisibleValues:b=2,truncateSelectedValues:f=!0,selectedOverflowPopover:p=!0,emptyText:v="Sin resultados",clearLabel:w="Limpiar seleccion",pruneMissingValues:g=!0}){const[A,C]=s.useState(!1),[T,H]=s.useState(""),[E,x]=s.useState(0),[M,k]=s.useState(!1),[_,q]=s.useState({}),X=s.useRef(null),D=s.useRef(null),K=s.useRef(null),j=s.useRef(null),le=u&&n.length>=h,Q=s.useMemo(()=>new Set(e),[e]),fe=s.useMemo(()=>{const y=new Map;for(const N of n)y.set(N.value,N);return y},[n]),F=s.useMemo(()=>{const y=[];for(const N of e){const te=fe.get(N);te&&y.push(te)}return y},[fe,e]),V=b==="all"?F.length:b,ae=F.slice(0,V),$=Math.max(0,F.length-ae.length),P=p&&F.length>1,ce=t.jsxs("div",{className:"flex max-w-[280px] flex-col gap-1.5 py-0.5",children:[t.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wide",style:{color:"var(--text-muted)"},children:[F.length," seleccionados"]}),t.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:F.map(y=>t.jsxs("li",{className:"flex min-w-0 items-baseline gap-1.5 text-xs",style:{color:"var(--text-main)"},children:[y.color&&t.jsx("span",{className:"mt-1 h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:y.color}}),t.jsx("span",{className:"min-w-0 break-words font-medium",children:y.label}),y.sublabel?t.jsx("span",{className:"min-w-0 break-words",style:{color:"var(--text-muted)"},children:y.sublabel}):null]},y.value))})]}),O=s.useMemo(()=>{const y=T.trim();return!le||!y?n:n.filter(N=>Ou(N,y))},[n,T,le]),oe=s.useCallback(()=>{const y=X.current;if(!y)return;const N=y.getBoundingClientRect(),te=le?304:244,ue=window.innerHeight-N.bottom,re=ue<te&&N.top>ue;q({position:"fixed",left:N.left,top:re?void 0:N.bottom+4,bottom:re?window.innerHeight-N.top+4:void 0,width:Math.max(N.width,240),zIndex:9999})},[le]),G=s.useCallback(y=>{al(e,y)||r(y)},[r,e]),U=s.useCallback(y=>{const N=fe.get(y);if(N!=null&&N.disabled)return;const te=Q.has(y)?e.filter(ue=>ue!==y):[...e,y];G(te)},[G,fe,e,Q]),se=s.useCallback(()=>G([]),[G]),S=s.useCallback(()=>{C(!1),H(""),x(0)},[]);s.useEffect(()=>k(!0),[]);const R=s.useMemo(()=>n.map(y=>y.value).join("\0"),[n]);s.useEffect(()=>{if(!g||e.length===0||n.length===0)return;const y=new Set(n.map(te=>te.value)),N=e.filter(te=>y.has(te));al(e,N)||r(N)},[R]),s.useEffect(()=>{if(!A)return;function y(N){var ue,re;const te=N.target;!((ue=X.current)!=null&&ue.contains(te))&&!((re=D.current)!=null&&re.contains(te))&&S()}return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[S,A]),s.useEffect(()=>{A&&(x(0),oe(),le&&setTimeout(()=>{var y;return(y=K.current)==null?void 0:y.focus()},0))},[A,le,oe]),s.useEffect(()=>{if(A)return window.addEventListener("resize",oe),window.addEventListener("scroll",oe,!0),()=>{window.removeEventListener("resize",oe),window.removeEventListener("scroll",oe,!0)}},[A,oe]),s.useEffect(()=>{if(O.length===0){x(0);return}x(y=>Math.min(y,O.length-1))},[O.length]),s.useEffect(()=>{if(E<0||!j.current)return;const y=j.current.children[E];y==null||y.scrollIntoView({block:"nearest"})},[E]);function ee(y){if(!o){if(!A){(y.key==="Enter"||y.key===" "||y.key==="ArrowDown")&&(y.preventDefault(),C(!0));return}if(y.key==="Escape"){y.preventDefault(),S();return}if(y.key==="ArrowDown"){if(y.preventDefault(),O.length===0)return;x(N=>Math.min(N+1,O.length-1));return}if(y.key==="ArrowUp"){y.preventDefault(),x(N=>Math.max(N-1,0));return}if(y.key==="Enter"&&O[E]&&!O[E].disabled){y.preventDefault(),U(O[E].value);return}y.key==="Backspace"&&!T&&e.length&&(y.preventDefault(),G(e.slice(0,-1)))}}const J=t.jsxs("div",{ref:D,className:"overflow-hidden rounded-xl shadow-xl",style:{..._,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[le&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(W.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:K,value:T,onChange:y=>{H(y.target.value),x(0)},onKeyDown:y=>{(y.key==="ArrowDown"||y.key==="ArrowUp"||y.key==="Enter"||y.key==="Escape")&&(y.stopPropagation(),ee(y))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),T&&t.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:y=>{y.preventDefault(),H(""),x(0)},children:t.jsx(W.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:[F.length," seleccionados",e.length>F.length?` (${e.length-F.length} no disponibles)`:""]}),t.jsx("button",{type:"button",onMouseDown:y=>{y.preventDefault(),se()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:w})]}),t.jsxs("ul",{ref:j,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:le?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[O.map((y,N)=>{const te=N===E,ue=Q.has(y.value);return t.jsxs("li",{role:"option","aria-selected":ue,onMouseDown:re=>{re.preventDefault(),!y.disabled&&U(y.value)},onMouseEnter:()=>!y.disabled&&x(N),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:te?"var(--bg-hover)":ue?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:y.disabled?"var(--text-muted)":"var(--text-main)",cursor:y.disabled?"not-allowed":"pointer",opacity:y.disabled?.58:1},children:[t.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:ue?"var(--primary)":"var(--border)",background:ue?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:ue&&t.jsx(W.HiCheck,{className:"h-3 w-3"})}),y.color&&t.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:y.color}}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(Yt,{className:"min-w-0 flex-1",children:y.label}),y.sublabel&&t.jsx(Yt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:y.sublabel})]}),y.badge&&t.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:y.badge})]},y.value)}),O.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:X,className:`relative ${l||"w-full"}`,style:i,onKeyDown:ee,children:[t.jsxs("button",{type:"button",disabled:o,onClick:()=>{o||(A?S():C(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:nl(c),padding:nl(d),background:"var(--bg-input)",color:F.length?"var(--text-main)":"var(--text-muted)",border:A?"1px solid var(--primary)":"1px solid var(--border)",opacity:o?.5:1,cursor:o?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":A,children:[t.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:ae.length?(()=>{const y=t.jsxs(t.Fragment,{children:[ae.map(N=>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:[N.color&&t.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:N.color}}),f?t.jsx(Yt,{className:"min-w-0 flex-1",children:N.label}):t.jsx("span",{className:"break-words",children:N.label}),t.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${N.label}`,onMouseDown:te=>{te.preventDefault(),te.stopPropagation(),U(N.value)},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(W.HiXMark,{className:"h-3 w-3"})})]},N.value)),$>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)"},"aria-label":`${$} seleccionados más`,children:["+",$]})]});return P?t.jsx(_t,{as:"span",content:ce,placement:"bottom",followCursor:!1,className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:y}):y})():t.jsx("span",{className:"truncate",children:a})}),F.length?t.jsx("span",{role:"button",tabIndex:-1,"aria-label":w,onMouseDown:y=>{y.preventDefault(),y.stopPropagation(),se()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(W.HiXMark,{className:"h-3.5 w-3.5"})}):t.jsx(W.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:A?"rotate(180deg)":"rotate(0deg)"}})]}),A&&M&&mt.createPortal(J,document.body)]})}function Bu({inputMode:e="decimal",...r}){return t.jsx(io,{...r,type:"number",inputMode:e})}function Iu(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 Fu({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=Iu(c,i,o);return t.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[t.jsx(Ke,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:a||c<=1,onClick:()=>n(c-1),children:t.jsx(W.HiChevronLeft,{className:"h-4 w-4"})}),d.map((u,h)=>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-${h}`):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(Ke,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:a||c>=i,onClick:()=>n(c+1),children:t.jsx(W.HiChevronRight,{className:"h-4 w-4"})})]})}const ol=[{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 sl(e){return e==null?"":String(e)}function qn(e){return e?e.startsWith("+")?e:`+${e}`:"+1"}function _u(e){return typeof e=="number"?`${e}px`:e}function Pu({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:h="+1",onCountryCodeChange:b,allowedCountryCodes:f,countryCodeOptions:p,countryCodePlaceholder:v="Codigo",countryCodeClassName:w="",countryCodeWidth:g=84,onPhoneValueChange:A,label:C,containerClassName:T="",helperText:H,helperDisplay:E="inline",labelAction:x,className:M="",required:k,disabled:_,floatingLabel:q,showPasswordToggle:X,nativeValidation:D,errorTooltipLabel:K="Error de validacion",...j}){var N;const[le,Q]=s.useState(()=>sl(c)),[fe,F]=s.useState(()=>qn(h)),V=s.useMemo(()=>{const te=p??ol,ue=f==null?void 0:f.map(qn);return ue!=null&&ue.length?te.filter(re=>ue.includes(re.value)):te},[f,p]),ae=((N=V[0])==null?void 0:N.value)??"+1",$=V.some(te=>te.value===qn(u??fe))?qn(u??fe):ae,P=i!==void 0?sl(i):le,ce=`${$} ${P}`.trim(),O=n&&P.length>0&&!so(ce)?a:void 0,oe=l??O,G=!!oe,U=G&&o!=="tooltip",se=G&&o!=="inline",S=!!H&&E==="tooltip"&&!U,R=G?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",ee=te=>{const ue=te.currentTarget.value;i===void 0&&Q(ue),A==null||A(ue,{countryCode:$,nationalNumber:ue,fullNumber:`${$} ${ue}`.trim()}),d==null||d(te)},J=te=>{u===void 0&&F(te),b==null||b(te),A==null||A(P,{countryCode:te,nationalNumber:P,fullNumber:`${te} ${P}`.trim()})},y=se?t.jsx(_t,{as:"span",content:oe,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":K,className:"flex h-full w-full items-center justify-center outline-none",children:t.jsx(Qs,{className:"h-[18px] w-[18px]"})})}):null;return t.jsxs("div",{className:`flex flex-col gap-2 ${T}`,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:C}),k&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),S?t.jsx($r,{content:H}):null,x&&t.jsx("span",{className:"ml-auto normal-case",children:x})]}),t.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${R}`,children:[t.jsx(fr,{value:$,onChange:J,options:V,placeholder:v,disabled:_,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${w}`,style:{width:_u(g)},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",{...j,value:i,defaultValue:c,type:"tel",inputMode:r,autoComplete:e,disabled:_,required:void 0,"aria-label":j["aria-label"]??(typeof C=="string"?C:void 0),"aria-invalid":G||j["aria-invalid"],className:`h-full w-full min-w-0 bg-transparent px-2 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed disabled:opacity-60 ${se?"pr-10":""} ${M}`,onChange:ee}),y]})]}),t.jsx(Ar,{error:U?oe:void 0,helperText:H,helperDisplay:E})]})}function zu({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 h=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:h?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:h?"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:h,disabled:b,onChange:()=>r(u.value),className:"absolute inset-0 opacity-0"}),t.jsx("span",{className:`h-2 w-2 rounded-full transition ${h?"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 Wu='<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" aria-hidden="true" height="14" width="14" class="rich-code-copy-clipboard" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M17.663 3.118c.225.015.45.032.673.05C19.876 3.298 21 4.604 21 6.109v9.642a3 3 0 0 1-3 3V16.5c0-5.922-4.576-10.775-10.384-11.217.324-1.132 1.3-2.01 2.548-2.114.224-.019.448-.036.673-.051A3 3 0 0 1 13.5 1.5H15a3 3 0 0 1 2.663 1.618ZM12 4.5A1.5 1.5 0 0 1 13.5 3H15a1.5 1.5 0 0 1 1.5 1.5H12Z" clip-rule="evenodd"></path><path d="M3 8.625c0-1.036.84-1.875 1.875-1.875h.375A3.75 3.75 0 0 1 9 10.5v1.875c0 1.036.84 1.875 1.875 1.875h1.875A3.75 3.75 0 0 1 16.5 18v2.625c0 1.035-.84 1.875-1.875 1.875h-9.75A1.875 1.875 0 0 1 3 20.625v-12Z"></path><path d="M10.5 10.5a5.23 5.23 0 0 0-1.279-3.434 9.768 9.768 0 0 1 6.963 6.963 5.23 5.23 0 0 0-3.434-1.279h-1.875a.375.375 0 0 1-.375-.375V10.5Z"></path></svg>',ju='<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" aria-hidden="true" height="14" width="14" class="rich-code-copy-check" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M19.916 4.626a.75.75 0 0 1 .208 1.04l-9 13.5a.75.75 0 0 1-1.154.114l-6-6a.75.75 0 0 1 1.06-1.06l5.353 5.353 8.493-12.74a.75.75 0 0 1 1.04-.207Z" clip-rule="evenodd"></path></svg>';function ll(){return`<button type="button" class="rich-code-copy" data-action="copy-code" title="Copiar" aria-label="Copiar">${Wu}${ju}</button>`}const qu=new Set(["div","p","li","tr","pre","h1","h2","h3","h4","h5","h6"]);function il(e){const r=n=>{if(n.nodeType===Node.TEXT_NODE)return(n.textContent??"").replace(/\u00a0/g," ");if(n.nodeType!==Node.ELEMENT_NODE)return"";const a=n,o=a.tagName.toLowerCase();if(o==="br")return`
25
- `;if(o==="script"||o==="style")return"";let l="";for(const i of Array.from(a.childNodes))l+=r(i);return qu.has(o)&&l.length>0&&!l.endsWith(`
23
+ </body></html>`,we=window.open("","_blank");we&&(we.document.write(be),we.document.close())}const qa=()=>!nt||!Mn?null:pt.createPortal(t.jsxs("div",{ref:Ro,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{..._h,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:()=>{(async()=>(ue?await ue():mm(),Ea(!1)))()},children:[t.jsx(z.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:()=>{(async()=>($e?await $e():pm(),Ea(!1)))()},children:[t.jsx(z.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),Ua=()=>{const m=E&&Ie.trim().length>0,A=ge!=null&&ge.length?ge:m?[{key:"bql",label:"BQL",value:Ie}]:[],V=re.filter(O=>{const le=O.trim();return le?!new Set(Pe.split(`
24
+ `).map(we=>we.trim()).filter(Boolean)).has(le):!1}).slice(0,8);return!ce&&ts===0&&!E&&!nt?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:[ts>0&&t.jsxs("button",{type:"button",onClick:Qh,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"}),ts," filtros"]}),E&&t.jsxs("div",{ref:Qo,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>{if(Ze){xt(!1);return}Ha(),xt(!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:Ze?"var(--primary)":m?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:Ze||m?"var(--primary)":"var(--border)",color:Ze?"var(--primary-fg)":"var(--primary)"},"aria-expanded":Ze,title:"Abrir filtros BQL",children:[t.jsx(z.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",m&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),Ze?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:x}),A.length>0&&t.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[A.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)),A.length>3&&t.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",A.length-3]})]}),m&&t.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:ec,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"})}),Ze&&pt.createPortal(t.jsxs("div",{ref:qi,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...Hh,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:[te.map(O=>t.jsxs("button",{type:"button",onMouseDown:le=>{le.preventDefault(),le.stopPropagation()},onClick:le=>{le.preventDefault(),le.stopPropagation(),Oa(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)),de.length>0&&t.jsxs("button",{type:"button",onClick:()=>wt(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":Zt,children:[t.jsx(z.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),dr.length>0&&t.jsxs("button",{type:"button",onClick:()=>Qt(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":yr,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 ${Ee?"var(--danger)":m?"var(--primary)":"var(--border)"}`},children:[t.jsx("textarea",{ref:Jo,value:Pe,rows:3,onChange:O=>as(O.target.value,O.target),onKeyDown:O=>{O.key==="Enter"&&!O.shiftKey&&(O.preventDefault(),Ri(Pe)),O.key==="Escape"&&xt(!1)},placeholder:k,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"}}),V.length>0&&t.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:V.map(O=>t.jsx("button",{type:"button",onMouseDown:le=>{le.preventDefault(),le.stopPropagation()},onClick:le=>{le.preventDefault(),le.stopPropagation(),Oa(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:Ee?"var(--danger)":"var(--text-muted)"},children:Ee??(m?`${A.length||1} filtro${(A.length||1)===1?"":"s"} activo${(A.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),A.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))]}),yr&&dr.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:()=>{Zr([]),Qt(!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"]})]}),dr.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:le=>{le.preventDefault(),le.stopPropagation()},onClick:le=>{le.preventDefault(),le.stopPropagation(),Oa(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:()=>Zr(le=>le.filter(be=>be!==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))]}),Zt&&de.length>0&&t.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:de.map(O=>t.jsxs("button",{type:"button",onMouseDown:le=>{le.preventDefault(),le.stopPropagation()},onClick:le=>{le.preventDefault(),le.stopPropagation(),Oa(O.bql),wt(!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:[m&&t.jsxs("button",{type:"button",onClick:ec,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:()=>Ri(Pe),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)]})]}),nt&&t.jsx("button",{ref:Ma,type:"button","aria-haspopup":"menu","aria-expanded":Mn,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var le;const O=(le=Ma.current)==null?void 0:le.getBoundingClientRect();O&&Ph({top:O.bottom+4,right:window.innerWidth-O.right}),Ea(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)] ${Mn?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(z.HiArrowDownTray,{className:"h-4 w-4"})}),ce&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Re&&dt==="visibility","aria-label":se,title:se,onClick:O=>rc(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)] ${Re&&dt==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(z.HiCog6Tooth,{className:"h-4 w-4"})})]})},pc=()=>{if(!dm)return null;const m=fd(bt,us);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 ${Y?"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:Jt===0?"0 filas":`${um}–${fm} de ${Jt}`}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),t.jsx(br,{value:String(Xt),onChange:A=>bm(Number(A)),options:ss.map(A=>({value:String(A),label:String(A)})),placeholder:"Filas",searchable:!1,disabled:a,height:q,padding:U,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:_}})]})]}),t.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[t.jsx("button",{disabled:a||bt<=1,onClick:()=>fs(bt-1),onMouseEnter:A=>{A.currentTarget.disabled||(A.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",A.currentTarget.style.color="var(--primary)")},onMouseLeave:A=>{A.currentTarget.style.background="transparent",A.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"})}),m.map((A,V)=>A==="..."?t.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${V}`):t.jsx("button",{disabled:a,onClick:()=>fs(A),onMouseEnter:O=>{O.currentTarget.disabled||A===bt||(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=A===bt?"var(--primary)":"transparent",O.currentTarget.style.color=A===bt?"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:A===bt?"var(--primary)":"transparent",color:A===bt?"var(--primary-fg)":"var(--text-muted)"},children:A},A)),t.jsx("button",{disabled:a||bt>=us,onClick:()=>fs(bt+1),onMouseEnter:A=>{A.currentTarget.disabled||(A.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",A.currentTarget.style.color="var(--primary)")},onMouseLeave:A=>{A.currentTarget.style.background="transparent",A.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"})]})},gm=()=>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:_a},children:[Wa(),qa(),Ua(),t.jsx("div",{ref:Lt,className:"min-w-0 max-w-full overflow-hidden",children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Dn,minWidth:Pa},children:[t.jsx("div",{role:"rowgroup",style:y?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:za()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,o)}).map((m,A)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:nn,borderBottom:`1px solid ${qe}`},children:[_t&&t.jsx("div",{role:"cell",className:`${Y?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${qe}`,borderRight:`1px solid ${qe}`}},"select-cell"),Dt.map((V,O)=>t.jsx("div",{role:"cell",className:Y?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${qe}`,borderRight:`1px solid ${qe}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${Yi(A,O)}%`,minWidth:32}})},V.key))]},A))})]})})]}),hs="min-w-0 max-w-full overflow-hidden";return Q&&He&&!Je?t.jsx(In,{rows:o,columns:Math.max(4,Dt.length||7)}):!a&&r.length===0&&!es?gm():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:_a},children:[Wa(),qa(),Ua(),t.jsx("div",{ref:Lt,className:hs,children:t.jsx(ms.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:Ki,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Dn,minWidth:Pa},children:[t.jsx("div",{role:"rowgroup",style:y?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:za()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:o}).map((m,A)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:nn,borderBottom:`1px solid ${qe}`},children:[_t&&t.jsx("div",{role:"cell",className:`${Y?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${qe}`,borderRight:`1px solid ${qe}`}},"select-cell"),Dt.map((V,O)=>{const le=Ia[V.key],be=le!==void 0,we=V.key===ds;return t.jsx("div",{role:"cell","data-dt-column-key":V.key,className:Y?"px-2 py-1.5":"px-3 py-2",style:be?{position:"sticky",left:le,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:we?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${qe}`:`inset 0 -1px 0 ${qe}`,borderRight:`1px solid ${qe}`}:{borderBottom:`1px solid ${qe}`,borderRight:`1px solid ${qe}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${Yi(A,O)}%`,minWidth:32}})},V.key)})]},A))})]})})}),pc()]}):!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:_a},children:[Wa(),qa(),Ua(),t.jsx("div",{ref:Lt,className:hs,children:t.jsx("div",{role:"table",className:"text-sm",style:{width:Dn,minWidth:Pa},children:t.jsx("div",{role:"rowgroup",style:y?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:za()})})}),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:qe,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:_a},children:[Wa(),qa(),Ua(),t.jsx("div",{ref:Lt,className:hs,children:t.jsx(ms.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:Ki,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:Dn,minWidth:Pa},children:[t.jsx("div",{role:"rowgroup",style:y?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:za()}),t.jsx("div",{role:"rowgroup",children:lc.map((m,A)=>{const V=n(m),O=fc(C==null?void 0:C(m)),le=A>0?fc(C==null?void 0:C(lc[A-1])):null,be=O&&O.key!==(le==null?void 0:le.key),we=_t&&w.has(V),Te=_t&&(!M||M(m)),ve=rn?(h==null?void 0:h(m))??!0:!1,Be=ve&&oc.has(V),De=!!d||g&&ve,Ve=we&&S?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":A%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return t.jsxs(s.Fragment,{children:[be&&t.jsx("div",{role:"row",className:`grid ${O.className??""}`,style:{gridTemplateColumns:nn},children:t.jsx("div",{role:"cell",className:Y?"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 ${qe}`,borderRight:`1px solid ${qe}`},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:De?xe=>{const Oe=xe.target;if(!(Oe!=null&&Oe.closest('[data-dt-disable-row-click="true"]'))){if(g&&ve){ic(V);return}d==null||d(m)}}:void 0,className:`grid transition-colors ${De?"cursor-pointer":""} ${H?H(m):""}`,style:{gridTemplateColumns:nn,"--dt-row-bg":Ve,"--dt-sticky-bg":Ve,background:"var(--dt-row-bg)",borderBottom:`1px solid ${qe}`},onMouseEnter:xe=>{we||(xe.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),xe.currentTarget.style.setProperty("--dt-sticky-bg",hm))},onMouseLeave:xe=>{xe.currentTarget.style.setProperty("--dt-row-bg",Ve),xe.currentTarget.style.setProperty("--dt-sticky-bg",Ve)},children:[rn&&t.jsx("div",{role:"cell",className:`${Y?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${qe}`,borderRight:`1px solid ${qe}`},"data-dt-disable-row-click":"true",children:ve&&t.jsx("button",{type:"button","aria-label":Be?"Contraer fila":"Desplegar fila","aria-expanded":Be,onClick:xe=>{xe.stopPropagation(),ic(V)},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:Be?t.jsx(z.HiChevronDown,{className:"h-4 w-4"}):t.jsx(z.HiChevronRight,{className:"h-4 w-4"})})}),_t&&t.jsx("div",{role:"cell",className:`${Y?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:is?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${qe}`}:{borderBottom:`1px solid ${qe}`,borderRight:`1px solid ${qe}`},onClick:xe=>{xe.stopPropagation(),Te&&v(V)},children:t.jsx(Fn,{size:"sm",checked:we,disabled:!Te,"aria-label":Te?"Seleccionar fila":"Fila no seleccionable",containerClassName:"items-center",className:Te?"cursor-pointer":"cursor-not-allowed opacity-50",onClick:xe=>xe.stopPropagation(),onChange:()=>{Te&&v(V)}})}),Dt.map(xe=>{const Oe=Ia[xe.key],Ce=Oe!==void 0,Ne=xe.key===ds,Se=hr(xe);return t.jsx("div",{role:"cell","data-dt-column-key":xe.key,"data-dt-disable-row-click":xe.disableRowClick||Se?"true":void 0,className:`${Se?"px-2 py-1.5 justify-center text-center":`${Y?"px-2 py-1.5":"px-3 py-2"} ${cc(xe.align)}`} flex min-w-0 items-center ${ad} ${xe.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...Ce?{position:"sticky",left:Oe,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:Ne?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${qe}`:`inset 0 -1px 0 ${qe}`,borderRight:`1px solid ${qe}`}:{borderBottom:`1px solid ${qe}`,borderRight:`1px solid ${qe}`}},children:t.jsx(Hs,{children:t.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:xe.cell(m)})})},xe.key)})]}),Be&&u&&t.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:nn},children:t.jsx("div",{role:"cell",className:Y?"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 ${qe}`},children:u(m)})})]},V)})})]})})}),pc()]})}const md={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function Un({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 ${md[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]})]})})}function zt(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 Bs(e){if(!e)return null;const r=String(e).slice(0,10),[n,a,o]=r.split("-").map(Number);return!n||!a||!o?null:new Date(n,a-1,o)}function Lr(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function rr(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function Is(e){const r=Lr(e),n=(r.getDay()+6)%7;return rr(r,-n)}function no(e){const r=Is(e);return Array.from({length:7},(n,a)=>rr(r,a))}function Fs(e){const r=e.getDay();return r===0||r===6}function Vn(e){return e.filter(r=>!Fs(r))}function _s(e){return Vn(no(e))}function pd(e){const r=Lr(e),n=r.getDay();return n===6?rr(r,-1):n===0?rr(r,-2):r}function ao(e){const r=new Date(e.getFullYear(),e.getMonth(),1),n=Is(r);return Array.from({length:42},(a,o)=>rr(n,o))}function oo(e){const r=[];for(let n=0;n<e.length;n+=7)r.push(e.slice(n,n+7));return r}function Ps(e){return oo(e).map(Vn)}function gd(e,r,n,a){return e.getTime()<=a.getTime()&&r.getTime()>=n.getTime()}function nr(e,r){const n=r?r(e):{start:e.startDate,end:e.endDate},a=Bs(n.start);if(!a)return null;const o=Bs(n.end??n.start)??a;return o.getTime()<a.getTime()?{start:o,end:a}:{start:a,end:o}}function zs(e,r){const n={};for(const a of e){const o=nr(a,r);if(!o)continue;let l=Lr(o.start);const i=Lr(o.end);for(;l.getTime()<=i.getTime();){const c=zt(l);n[c]||(n[c]=[]),n[c].push(a),l=rr(l,1)}}return n}function so(e,r,n){if(r.length===0)return[];const a=Lr(r[0]),o=Lr(r[r.length-1]),l=[],i=[],c=[...e].sort((d,u)=>{const h=nr(d,n),b=nr(u,n),f=(h==null?void 0:h.start.getTime())??0,p=(b==null?void 0:b.start.getTime())??0;return f-p||d.title.localeCompare(u.title)});for(const d of c){const u=nr(d,n);if(!u||!gd(u.start,u.end,a,o))continue;const h=u.start.getTime()<a.getTime()?a:u.start,b=u.end.getTime()>o.getTime()?o:u.end,f=Math.max(0,Math.round((h.getTime()-a.getTime())/864e5)),p=Math.min(r.length-1,Math.round((b.getTime()-a.getTime())/864e5)),g=Math.max(1,p-f+1);let w=l.findIndex(v=>v<f);w<0?(w=l.length,l.push(f+g-1)):l[w]=f+g-1,i.push({item:d,lane:w,colStart:f,colSpan:g})}return i}function Ht(e){return new Intl.DateTimeFormat("es-MX",{day:"2-digit",month:"short",year:"numeric"}).format(e)}function vd(e){const r=new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(e);return r.charAt(0).toUpperCase()+r.slice(1)}function yd(e){const r=new Intl.DateTimeFormat("es-MX",{weekday:"short",day:"2-digit",month:"short",year:"numeric"}).format(e);return r.charAt(0).toUpperCase()+r.slice(1)}function Ws(e){const r=new Intl.DateTimeFormat("es-MX",{weekday:"short",day:"2-digit",month:"short"}).format(e);return r.charAt(0).toUpperCase()+r.slice(1)}function js(e,r,n){return r==="month"?new Date(e.getFullYear(),e.getMonth()+n,1):r==="week"?rr(e,n*7):rr(e,n)}const xd=["Lun","Mar","Mié","Jue","Vie","Sáb","Dom"],qs=["Lun","Mar","Mié","Jue","Vie"];function wd({item:e,style:r,onClick:n}){const a=e.color??"var(--text-muted)",o=e.bg??"rgba(100, 116, 139, 0.14)",l=nr(e),i=l?`${Ht(l.start)} → ${Ht(l.end)}`:"",c=[e.title,e.subtitle,i,e.status].filter(Boolean).join(" · ");return t.jsx(Pt,{content:c||e.title,children:t.jsxs("button",{type:"button",className:"absolute overflow-hidden rounded-md px-1.5 py-0.5 text-left text-[11px] leading-tight transition-opacity hover:opacity-90",style:{...r,background:o,borderLeft:`3px solid ${a}`,boxShadow:"inset 0 0 0 1px var(--border)",color:"var(--text-main)"},onClick:d=>{d.stopPropagation(),n==null||n()},children:[t.jsx("span",{className:"block truncate font-semibold",children:e.title}),e.status?t.jsx("span",{className:"block truncate",style:{color:a},children:e.status}):null]})})}function Nd({item:e,onClick:r}){const n=e.color??"var(--text-muted)",a=e.bg??"rgba(100, 116, 139, 0.10)",o=nr(e),l=o?`${Ht(o.start)} → ${Ht(o.end)}`:"";return t.jsxs("button",{type:"button",className:"flex w-full flex-col gap-2 rounded-lg p-4 text-left transition-opacity hover:opacity-95 sm:flex-row sm:items-start sm:justify-between",style:{background:a,border:"1px solid var(--border)",boxShadow:`inset 3px 0 0 ${n}`,color:"var(--text-main)"},onClick:()=>r==null?void 0:r(),children:[t.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[t.jsx("div",{className:"text-base font-semibold",children:e.title}),e.subtitle?t.jsx("div",{className:"text-sm leading-5",style:{color:"var(--text-muted)"},children:e.subtitle}):null]}),t.jsxs("div",{className:"flex shrink-0 flex-col gap-2 sm:items-end",children:[e.status?t.jsx("span",{className:"inline-flex rounded-full px-2.5 py-0.5 text-xs font-semibold",style:{color:n,background:"color-mix(in srgb, var(--bg-card) 70%, transparent)",border:`1px solid color-mix(in srgb, ${n} 45%, transparent)`},children:e.status}):null,l?t.jsxs("div",{className:"text-xs",style:{color:"var(--text-secondary)"},children:[t.jsx("span",{className:"font-semibold uppercase tracking-wide opacity-70",children:"Rango"}),t.jsx("div",{children:l})]}):null]})]})}function kd({item:e,style:r,onClick:n}){const a=e.color??"var(--text-muted)",o=e.bg??"rgba(100, 116, 139, 0.14)",l=nr(e),i=l?`${Ht(l.start)} → ${Ht(l.end)}`:"";return t.jsxs("button",{type:"button",className:"absolute mx-1 overflow-hidden rounded-md px-2 py-1.5 text-left text-xs transition-opacity hover:opacity-90",style:{...r,background:o,borderLeft:`3px solid ${a}`,boxShadow:"inset 0 0 0 1px var(--border)",color:"var(--text-main)"},title:[e.title,i,e.status].filter(Boolean).join(" · "),onClick:()=>n==null?void 0:n(),children:[t.jsx("span",{className:"block truncate font-semibold",children:e.title}),t.jsx("span",{className:"block truncate",style:{color:a},children:[e.status,i].filter(Boolean).join(" · ")})]})}function Us({item:e,day:r,renderPill:n,onClick:a}){if(n)return t.jsx("div",{className:"min-w-0",children:n(e,{day:r})});const o=e.color??"var(--text-muted)",l=e.bg??"rgba(100, 116, 139, 0.14)";return t.jsxs("button",{type:"button",className:"block w-full overflow-hidden rounded-md px-1.5 py-0.5 text-left text-[11px] leading-tight",style:{background:l,borderLeft:`3px solid ${o}`,color:"var(--text-main)"},onClick:i=>{i.stopPropagation(),a==null||a()},children:[t.jsx("span",{className:"block truncate font-semibold",children:e.title}),e.status?t.jsx("span",{className:"block truncate",style:{color:o},children:e.status}):null]})}function Vs({value:e,options:r,onChange:n}){return t.jsx("div",{className:"inline-flex overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:r.map((a,o)=>{const l=e===a.value;return t.jsxs("button",{type:"button",onClick:()=>n(a.value),className:"inline-flex items-center gap-1.5 px-3 py-2 text-xs font-semibold transition-colors",style:{background:l?"var(--primary)":"var(--bg-card)",color:l?"var(--primary-fg, #fff)":"var(--text-secondary)",borderRight:o<r.length-1?"1px solid var(--border)":void 0},children:[a.icon,a.label]},a.value)})})}function Cd({items:e,cursorDate:r,onCursorDateChange:n,displayMode:a,onDisplayModeChange:o,viewMode:l,onViewModeChange:i,getItemDates:c,maxPillsPerDay:d=3,overloadThreshold:u=5,weekdayLabels:h,hideWeekends:b=!1,renderToolbarExtra:f,renderPill:p,renderDayCard:g,renderWeekBar:w,tableColumns:v,tableProps:L,onItemClick:M,onDayClick:S,loading:H=!1,emptyTitle:C="Sin eventos",emptyDescription:y="No hay eventos para los filtros seleccionados.",legend:T,legendInteractive:N=!0,activeLegendKeys:_,defaultActiveLegendKeys:q,onActiveLegendKeysChange:U,getItemLegendKey:D,overloadLabel:K="Sobrecarga de eventos",notice:j,showOverload:ie=!0,layout:Q="span",className:fe="",showToolbar:F=!0}){const Y=h??(b?[...qs]:[...xd]),ae=b?5:7,$=b?"grid grid-cols-5":"grid grid-cols-7",W=s.useMemo(()=>(T??[]).map(ue=>ue.label),[T]),[ce,B]=s.useState(()=>q??W),oe=s.useMemo(()=>_??(W.length>0?ce:[]),[_,W.length,ce]),Z=s.useMemo(()=>new Set(oe),[oe]),X=ue=>{_===void 0&&B(ue),U==null||U(ue)},se=ue=>{N&&(Z.has(ue)?X(oe.filter($e=>$e!==ue)):X([...oe,ue]))},E=s.useMemo(()=>{if(!N||W.length===0)return e;const ue=new Set(W);return e.filter($e=>{const ne=(D==null?void 0:D($e))??$e.status;return!ne||!ue.has(ne)?!0:Z.has(ne)})},[e,N,W,Z,D]),J=s.useMemo(()=>zs(E,c),[E,c]),ee=s.useMemo(()=>{const ue=ao(r);return b?Vn(ue):ue},[r,b]),R=s.useMemo(()=>{const ue=ao(r);return b?Ps(ue):oo(ue)},[r,b]),x=s.useMemo(()=>b?_s(r):no(r),[r,b]),k=zt(r),te=J[k]??[],de=s.useMemo(()=>so(E,x,c),[E,x,c]),re=s.useMemo(()=>de.length===0?1:Math.max(...de.map(ue=>ue.lane))+1,[de]),ge=s.useMemo(()=>R.map(ue=>{const $e=so(E,ue,c),ne=$e.length===0?0:Math.max(...$e.map(He=>He.lane))+1;return{days:ue,bars:$e,laneCount:ne}}),[R,E,c]),Ee=36,Le=38,gt=s.useMemo(()=>{const ue=l==="month"?ee:l==="week"?x:[r],$e=[];for(const ne of ue){const He=zt(ne),Fe=J[He]??[];Fe.length>=u&&$e.push([ne,Fe])}return $e},[l,ee,x,r,J,u]),Tt=l==="month"?vd(r):l==="week"?`${Ht(x[0])} – ${Ht(x[6])}`:yd(r),nt=s.useMemo(()=>[{key:"title",header:"Título",cell:ue=>ue.title},{key:"status",header:"Estado",cell:ue=>ue.status??"—"},{key:"range",header:"Rango",cell:ue=>{const $e=nr(ue,c);return $e?`${Ht($e.start)} → ${Ht($e.end)}`:"—"}},{key:"subtitle",header:"Detalle",cell:ue=>ue.subtitle??"—"}],[c]),ot=ue=>{if(n(ue),S){S(ue);return}i("day")};return t.jsxs("div",{className:`bonsaif-event-calendar space-y-4 ${fe}`.trim(),children:[F?t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("button",{type:"button","aria-label":"Anterior",className:"inline-flex h-9 w-9 items-center justify-center rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"},onClick:()=>n(js(r,l,-1)),children:t.jsx(z.HiChevronLeft,{className:"h-4 w-4"})}),t.jsx("div",{className:"min-w-[160px] text-center text-sm font-semibold capitalize",style:{color:"var(--text-main)"},children:Tt}),t.jsx("button",{type:"button","aria-label":"Siguiente",className:"inline-flex h-9 w-9 items-center justify-center rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"},onClick:()=>n(js(r,l,1)),children:t.jsx(z.HiChevronRight,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",className:"rounded-lg px-3 py-2 text-xs font-semibold",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-secondary)"},onClick:()=>n(new Date),children:"Hoy"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f,t.jsx(Vs,{value:a,onChange:o,options:[{value:"calendar",label:"Calendario",icon:t.jsx(z.HiCalendarDays,{className:"h-4 w-4"})},{value:"table",label:"Tabla",icon:t.jsx(z.HiTableCells,{className:"h-4 w-4"})}]}),a==="calendar"?t.jsx(Vs,{value:l,onChange:i,options:[{value:"month",label:"Mes"},{value:"week",label:"Semana"},{value:"day",label:"Día"}]}):null]})]}):null,T&&T.length>0?t.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",role:N?"group":void 0,"aria-label":N?"Filtrar por estado":void 0,children:T.map(ue=>{const $e=Z.has(ue.label);return N?t.jsxs("button",{type:"button","aria-pressed":$e,onClick:()=>se(ue.label),className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 transition-opacity",style:{color:$e?"var(--text-main)":"var(--text-muted)",background:$e?"color-mix(in srgb, var(--bg-card) 80%, transparent)":"transparent",border:$e?`1px solid color-mix(in srgb, ${ue.color} 55%, var(--border))`:"1px solid var(--border)",opacity:$e?1:.45},title:$e?`Ocultar “${ue.label}”`:`Mostrar “${ue.label}”`,children:[t.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:ue.color,boxShadow:$e?`0 0 0 2px color-mix(in srgb, ${ue.color} 25%, transparent)`:void 0},"aria-hidden":!0}),ue.label]},ue.label):t.jsxs("span",{className:"inline-flex items-center gap-1.5",style:{color:"var(--text-secondary)"},children:[t.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:ue.color},"aria-hidden":!0}),ue.label]},ue.label)})}):null,a==="calendar"&&j&&j.items.length>0?t.jsxs("div",{className:"rounded-lg px-4 py-3 text-sm",style:j.tone==="danger"?{background:"rgba(220, 38, 38, 0.12)",border:"1px solid rgba(220, 38, 38, 0.35)",color:"#dc2626"}:{background:"rgba(217, 119, 6, 0.14)",border:"1px solid rgba(217, 119, 6, 0.35)",color:"#b45309"},children:[t.jsxs("strong",{children:[j.label,":"]})," ",j.items.join(", ")]}):a==="calendar"&&ie&&gt.length>0?t.jsxs("div",{className:"rounded-lg px-4 py-3 text-sm",style:{background:"rgba(217, 119, 6, 0.14)",border:"1px solid rgba(217, 119, 6, 0.35)",color:"#b45309"},children:[t.jsxs("strong",{children:[K,":"]})," ",gt.map(([ue,$e])=>`${Ht(ue)} (${$e.length})`).join(", ")]}):null,a==="table"?H||E.length>0?t.jsx(ro,{columns:v??nt,data:E,getRowId:ue=>ue.id,loading:H,skeletonRows:8,emptyIcon:t.jsx(z.HiCalendarDays,{className:"h-10 w-10"}),emptyText:y,onRowClick:M,pageSize:25,compact:!0,...L}):t.jsx(Un,{icon:t.jsx(z.HiCalendarDays,{className:"h-5 w-5"}),title:C,description:y}):null,a==="calendar"&&l==="month"&&Q==="daily"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{className:$,style:{borderBottom:"1px solid var(--border)"},children:Y.map(ue=>t.jsx("div",{className:"px-3 py-2 text-xs font-bold uppercase",style:{background:"var(--bg-card)",color:"var(--text-muted)"},children:ue},ue))}),t.jsx("div",{className:$,children:ee.map(ue=>{const $e=zt(ue),ne=J[$e]??[],He=ue.getMonth()!==r.getMonth(),Fe=Math.max(0,ne.length-d);return t.jsxs("div",{role:"button",tabIndex:0,"aria-label":`${ue.getDate()}`,onClick:()=>ot(ue),onKeyDown:Ge=>{(Ge.key==="Enter"||Ge.key===" ")&&(Ge.preventDefault(),ot(ue))},className:"flex min-h-[108px] cursor-pointer flex-col gap-1 p-2 text-left transition-colors hover:bg-black/[0.03] dark:hover:bg-white/[0.04]",style:{background:"var(--bg-main)",borderRight:"1px solid var(--border)",borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-sm font-semibold",style:{color:He?"var(--text-muted)":"var(--text-main)"},children:ue.getDate()}),ne.length>0?t.jsx("span",{className:"rounded-full px-2 py-0.5 text-[11px] font-bold",style:{background:"var(--primary)",color:"var(--primary-fg, #fff)"},children:ne.length}):null]}),t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[ne.slice(0,d).map(Ge=>t.jsx(Us,{item:Ge,day:ue,renderPill:p,onClick:()=>M==null?void 0:M(Ge)},Ge.id)),Fe>0?t.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-muted)"},children:["+",Fe," más"]}):null]})]},$e)})})]}):null,a==="calendar"&&l==="month"&&Q==="span"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{className:$,style:{borderBottom:"1px solid var(--border)"},children:Y.map(ue=>t.jsx("div",{className:"px-3 py-2 text-xs font-bold uppercase",style:{background:"var(--bg-card)",color:"var(--text-muted)"},children:ue},ue))}),ge.map(({days:ue,bars:$e,laneCount:ne},He)=>{const Fe=Math.min(ne,d),Ge=Math.max(0,ne-d),Ye=Ee+Math.max(1,Fe)*Le+(Ge>0?20:8)+8;return t.jsxs("div",{className:"relative",style:{minHeight:Ye,borderBottom:He<ge.length-1?"1px solid var(--border)":void 0},children:[t.jsx("div",{className:$,style:{minHeight:Ye},children:ue.map(ze=>{const Je=zt(ze),st=J[Je]??[],$t=ze.getMonth()!==r.getMonth();return t.jsx("div",{role:"button",tabIndex:0,"aria-label":`${ze.getDate()}`,onClick:()=>ot(ze),onKeyDown:he=>{(he.key==="Enter"||he.key===" ")&&(he.preventDefault(),ot(ze))},className:"cursor-pointer p-2 text-left transition-colors hover:bg-black/[0.03] dark:hover:bg-white/[0.04]",style:{background:"var(--bg-main)",borderRight:"1px solid var(--border)",minHeight:Ye},children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-sm font-semibold",style:{color:$t?"var(--text-muted)":"var(--text-main)"},children:ze.getDate()}),st.length>0?t.jsx("span",{className:"rounded-full px-2 py-0.5 text-[11px] font-bold",style:{background:"var(--primary)",color:"var(--primary-fg, #fff)"},children:st.length}):null]})},Je)})}),t.jsxs("div",{className:"pointer-events-none absolute inset-x-0",style:{top:Ee,bottom:4},children:[$e.filter(ze=>ze.lane<d).map(ze=>{const Je={left:`calc(${ze.colStart/ae*100}% + 4px)`,width:`calc(${ze.colSpan/ae*100}% - 8px)`,top:2+ze.lane*Le,height:Le-6,pointerEvents:"auto"};return p?t.jsx("div",{className:"absolute overflow-hidden",style:Je,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:p(ze.item,{day:ue[ze.colStart]})})},`${ze.item.id}-${ze.colStart}-${He}`):w?t.jsx("div",{className:"absolute overflow-hidden",style:Je,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:w(ze.item)})},`${ze.item.id}-${ze.colStart}-${He}`):t.jsx(wd,{item:ze.item,style:Je,onClick:()=>M==null?void 0:M(ze.item)},`${ze.item.id}-${ze.colStart}-${He}`)}),Ge>0?t.jsxs("span",{className:"absolute text-[11px] font-semibold",style:{left:8,top:2+Fe*Le,color:"var(--text-muted)"},children:["+",Ge," más"]}):null]})]},`week-${He}-${zt(ue[0])}`)})]}):null,a==="calendar"&&l==="week"&&Q==="daily"?t.jsx("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)"},children:t.jsx("div",{className:$,children:x.map(ue=>{const $e=zt(ue),ne=J[$e]??[],He=Math.max(0,ne.length-d);return t.jsxs("div",{className:"min-h-[180px] p-2",style:{borderRight:"1px solid var(--border)"},children:[t.jsxs("button",{type:"button",className:"mb-2 w-full text-center text-xs font-semibold capitalize",style:{color:"var(--text-main)"},onClick:()=>ot(ue),children:[Ws(ue),t.jsx("span",{className:"mt-1 block text-sm",children:ue.getDate()})]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[ne.slice(0,d).map(Fe=>t.jsx(Us,{item:Fe,day:ue,renderPill:p,onClick:()=>M==null?void 0:M(Fe)},Fe.id)),He>0?t.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-muted)"},children:["+",He," más"]}):null]})]},$e)})})}):null,a==="calendar"&&l==="week"&&Q==="span"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)"},children:[t.jsx("div",{className:`${$} border-b`,style:{borderColor:"var(--border)"},children:x.map(ue=>t.jsx("button",{type:"button",className:"px-3 py-2 text-center text-xs font-semibold capitalize",style:{color:"var(--text-main)",borderRight:"1px solid var(--border)"},onClick:()=>ot(ue),children:Ws(ue)},zt(ue)))}),t.jsxs("div",{className:`relative ${$}`,style:{minHeight:Math.max(220,re*56+24)},children:[x.map(ue=>t.jsx("div",{className:"min-h-full",style:{borderRight:"1px solid var(--border)"}},`lane-${zt(ue)}`)),de.map(ue=>{const $e={left:`calc(${ue.colStart/ae*100}% + 4px)`,width:`calc(${ue.colSpan/ae*100}% - 8px)`,top:12+ue.lane*56,height:48};return w?t.jsx("div",{className:"absolute overflow-hidden",style:$e,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:w(ue.item)})},`${ue.item.id}-${ue.colStart}`):t.jsx(kd,{item:ue.item,style:$e,onClick:()=>M==null?void 0:M(ue.item)},`${ue.item.id}-${ue.colStart}`)}),de.length===0&&!H?t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:y}):null]})]}):null,a==="calendar"&&l==="day"?te.length>0||H?t.jsxs("div",{className:"space-y-3",children:[H&&te.length===0?t.jsx(Un,{icon:t.jsx(z.HiCalendarDays,{className:"h-5 w-5"}),title:"Cargando…",description:"Obteniendo eventos del día."}):null,te.map(ue=>g?t.jsx("div",{children:g(ue)},ue.id):t.jsx(Nd,{item:ue,onClick:()=>M==null?void 0:M(ue)},ue.id))]}):t.jsx(Un,{icon:t.jsx(z.HiCalendarDays,{className:"h-5 w-5"}),title:C,description:y}):null]})}function Sd(e){const r=document.createElement("textarea");r.value=e,r.setAttribute("readonly",""),r.style.position="fixed",r.style.opacity="0",r.style.left="-9999px",r.style.top="0",document.body.appendChild(r),r.focus(),r.select(),r.setSelectionRange(0,e.length);const n=document.execCommand("copy");if(document.body.removeChild(r),!n)throw new Error("execCommand_copy_failed")}async function lo(e){var n;const r=String(e??"");if(!r.trim())throw new Error("empty_clipboard_text");try{if(typeof window<"u"&&window.focus(),(n=navigator.clipboard)!=null&&n.writeText){await navigator.clipboard.writeText(r);return}}catch{}Sd(r)}function Ed(e){return typeof e=="function"?e():e}function io({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:h="",style:b,children:f,onClick:p,type:g="button",...w}){const[v,L]=s.useState(!1),M=s.useRef(null);s.useEffect(()=>()=>{M.current&&window.clearTimeout(M.current)},[]);function S(C){L(!0),d==null||d(C),M.current&&window.clearTimeout(M.current),M.current=window.setTimeout(()=>{L(!1),M.current=null},r)}async function H(C){if(c&&C.stopPropagation(),p==null||p(C),C.defaultPrevented)return;const y=Ed(e);if(y)try{await lo(y),S(y)}catch(T){u==null||u(T,y)}}return t.jsxs("button",{...w,type:g,onClick:H,title:v?a:n,"aria-label":w["aria-label"]??(v?a:n),"data-copied":v?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${f?"min-w-7 px-2":"w-7"} ${h}`,style:{cursor:"pointer",background:v?"rgba(22,163,74,0.15)":"var(--bg-card)",border:v?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:v?"#16a34a":"var(--text-secondary)",boxShadow:v?"0 0 0 3px rgba(22,163,74,0.12)":"none",...b},children:[t.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:v?"scale(1.15)":"scale(1)"},children:v?i:l}),f&&t.jsx("span",{className:"text-xs font-semibold leading-none",children:v?o??f:f})]})}function Md({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(io,{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 Xn(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Td({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:Xn(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:Xn(o),padding:Xn(l)}})]})}function $d({value:e,onChange:r,options:n,placeholder:a,icon:o,className:l="",height:i=40,padding:c,iconLeft:d=10,searchable:u=!0}){const h=o?n.map((b,f)=>f===0&&!b.color?{...b,sublabel:b.sublabel??void 0}:b):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:Xn(d)},children:o}),t.jsx(br,{value:e,onChange:r,options:h,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 Ad={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},Yn=180,Ld="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function co({open:e,onClose:r,title:n,subtitle:a,leadingIcon:o,headerActions:l,footer:i,children:c,size:d="md",maxWidth:u,zIndex:h=1e3,closeOnBackdrop:b=!0,closeOnEscape:f=!0,showCloseButton:p=!0,placement:g="center",bodyClassName:w="px-6 py-5",panelClassName:v="",backdropClassName:L=Ld,contentClassName:M="p-4",ariaLabel:S,frameless:H=!1,disabled:C=!1}){const[y,T]=s.useState(!1),[N,_]=s.useState(!1),q=s.useRef(null);if(s.useEffect(()=>(e?(q.current&&clearTimeout(q.current),T(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>_(!0)))):(_(!1),q.current=setTimeout(()=>T(!1),Yn+40)),()=>{q.current&&clearTimeout(q.current)}),[e]),s.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),s.useEffect(()=>{if(!e||!f)return;const Q=fe=>{fe.key==="Escape"&&r()};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[f,r,e]),!y)return null;const U=n||a||o||l||p,D=u??Ad[d],K=g==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",j=g==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",ie=N?"translateY(0) scale(1)":g==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return pt.createPortal(t.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":S??n,className:`fixed inset-0 flex ${K} ${M}`,style:{zIndex:h},children:[t.jsx("div",{className:`absolute inset-0 ${L}`,onClick:b?r:void 0,style:{opacity:N?1:0,transition:`opacity ${Yn}ms ease`}}),t.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${H?"shadow-none":"shadow-2xl"} ${j} ${v}`,style:{maxWidth:D,background:H?"transparent":"var(--bg-card)",border:H?"none":"1px solid var(--border)",opacity:N?1:0,transform:ie,transition:`opacity ${Yn}ms ease, transform ${Yn}ms ease`},onClick:Q=>Q.stopPropagation(),children:[C&&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)"}}),U&&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,p&&t.jsx(Xe,{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 ${w}`,children:c}),i&&t.jsx("div",{className:"flex min-w-0 flex-shrink-0 flex-wrap justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:i})]})]}),document.body)}const Dd={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 Od({open:e,title:r,description:n,confirmLabel:a="Confirmar",cancelLabel:o="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:d}){const u=Dd[l];return t.jsx(co,{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(Xe,{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(Xe,{variant:"secondary",onClick:d,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:o}),t.jsx(Xe,{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 Hd(e){return e?typeof e=="function"?e():e:""}function Bd(e){return/^https?:\/\//i.test(e)}function Xs(e,r){try{return new URL(e,r).toString()}catch{return e}}function Id(e,r,n,a=!1){const o=typeof e=="function"?e():e,l=r?r(o):o;if(!l||Bd(l))return l;const i=Hd(n);return i?Xs(l,i):a&&typeof window<"u"?Xs(l,window.location.origin):l}function Fd({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(io,{...c,value:()=>Id(e,r,n,a),title:o,copiedTitle:l,icon:i})}const _d={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 Pd(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=_d[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 zd=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function Wd({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 h,b;(h=c.current)==null||h.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:h=>i(h.target.value),onBlur:()=>o(),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),a(l)),h.key==="Escape"&&(h.preventDefault(),o()),(n==null?void 0:n.preset)==="integer"&&!h.ctrlKey&&!h.metaKey&&!zd.has(h.key)&&!/^[\d-]$/.test(h.key)&&h.preventDefault()},onClick:h=>h.stopPropagation(),className:"w-full min-w-0 border-0 bg-transparent p-0 text-sm text-[var(--text-main)] outline-none"})}function jd({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(br,{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 qd={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},uo={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function Ud({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,h]=s.useState(null);d.current=u;const[b,f]=s.useState(null),p=s.useRef(null);p.current=b;const[g,w]=s.useState({}),[v,L]=s.useState(null),M=s.useRef(null);M.current=v;const[S,H]=s.useState({}),[C,y]=s.useState({}),T=s.useRef(new Set),N=s.useRef(null);s.useEffect(()=>{var W;const $=document.activeElement;(!$||$===document.body)&&((W=N.current)==null||W.focus({preventScroll:!0}))},[]);const _=e.map($=>{var W,ce,B;return`${$.key}:${((B=(ce=(W=$.editable)==null?void 0:W.select)==null?void 0:ce.options)==null?void 0:B.length)??-1}`}).join("|");s.useEffect(()=>{e.forEach($=>{var B,oe;const W=(oe=(B=$.editable)==null?void 0:B.select)==null?void 0:oe.options;if(!W)return;const ce=S[$.key];(!T.current.has($.key)||(ce==null?void 0:ce.length)===0&&W.length>0)&&(T.current.add($.key),H(Z=>({...Z,[$.key]:W})))})},[_]);const q=s.useCallback(async($,W)=>{if(T.current.has($))return;T.current.add($);const{url:ce,fetchOptions:B}=W.select??{};if(!(!ce&&!B)){y(oe=>({...oe,[$]:!0}));try{let oe=[];if(B)oe=await B();else if(ce){const Z=await fetch(ce);if(!Z.ok)throw new Error("fetch failed");oe=await Z.json()}H(Z=>({...Z,[$]:oe}))}catch{H(oe=>({...oe,[$]:[]}))}finally{y(oe=>({...oe,[$]:!1}))}}},[]),U=s.useRef(i);U.current=i;const D=s.useRef(a);D.current=a;const K=s.useRef(n);K.current=n;const j=s.useRef(e);j.current=e;const ie=s.useRef(o);ie.current=o,s.useEffect(()=>{if(e.length>0&&r.length>0){const $=e.find(W=>W.selectable!==!1);$&&f({rowId:n(r[0]),colKey:$.key})}},[]),s.useEffect(()=>{if(!b)return;const $=N.current;if(!$)return;const W=$.querySelector(`[data-cell-id="${b.rowId}:${b.colKey}"]`);if(!W)return;const ce=$.querySelector('[role="rowgroup"]');W.style.scrollMarginTop=`${(ce==null?void 0:ce.offsetHeight)??0}px`;const B=$.querySelector('[role="row"]');let oe=0;B&&B.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(Z=>{Z.style.position==="sticky"&&Z.style.left!==""&&(oe=Math.max(oe,parseFloat(Z.style.left)+Z.offsetWidth))}),W.style.scrollMarginLeft=`${oe}px`,W.scrollIntoView({block:"nearest",inline:"nearest"})},[b]);const Q=s.useCallback($=>{var oe;const W=j.current,ce=new Set,B=[];(oe=N.current)==null||oe.querySelectorAll("[data-cell-id]").forEach(Z=>{const X=Z.dataset.cellId.split(":")[0];ce.has(X)||(ce.add(X),B.push(X))}),f(Z=>{if(!Z)return Z;const X=W.findIndex(ee=>ee.key===Z.colKey),se=B.indexOf(Z.rowId);let E=X,J=se;if($==="up")J=Math.max(0,se-1);else if($==="down")J=Math.min(B.length-1,se+1);else if($==="left"){let ee=X-1;for(;ee>=0&&W[ee].selectable===!1;)ee--;ee>=0&&(E=ee)}else if($==="right"){let ee=X+1;for(;ee<W.length&&W[ee].selectable===!1;)ee++;ee<W.length&&(E=ee)}return E===X&&J===se?Z:{rowId:B[J],colKey:W[E].key}})},[]),fe=s.useCallback(($=!0)=>{const W=d.current;h(null),W&&f(W),$&&setTimeout(()=>{var ce;return(ce=N.current)==null?void 0:ce.focus({preventScroll:!0})},0)},[]),F=s.useCallback(async($,W,ce)=>{var re;const B=j.current.find(ge=>ge.key===W);if(!(B!=null&&B.editable))return;const{field:oe,type:Z,mask:X,validate:se}=B.editable,E=Z==="number"?ce===""?null:Number(ce):ce;if(X){const ge=Pd(ce,X);if(ge){w(Ee=>({...Ee,[`${$}:${W}`]:ge}));return}}if(se){const ge=se(E);if(ge){w(Ee=>({...Ee,[`${$}:${W}`]:ge}));return}}const J=K.current,ee=U.current.find(ge=>J(ge)===$);if(!ee)return;const R=ee[oe];h(null),w(ge=>{const Ee={...ge};return delete Ee[`${$}:${W}`],Ee});const x=U.current,k=x.findIndex(ge=>J(ge)===$),te=x[Math.min(x.length-1,k+1)];if(f({rowId:J(te),colKey:W}),setTimeout(()=>{var Ee,Le;const ge=document.activeElement;(!ge||ge===document.body||(Ee=N.current)!=null&&Ee.contains(ge))&&((Le=N.current)==null||Le.focus({preventScroll:!0}))},0),String(R??"")===String(E??""))return;const de={...ee,[oe]:E};c(ge=>ge.map(Ee=>J(Ee)===$?de:Ee)),L({rowId:$,colKey:W});try{await((re=D.current)==null?void 0:re.call(D,{row:ee,rowId:$,field:oe,oldValue:R,newValue:E}))}catch{c(ge=>ge.map(Ee=>J(Ee)===$?ee:Ee)),w(ge=>({...ge,[`${$}:${W}`]:"Error al guardar. Intenta de nuevo."}))}finally{L(null)}},[]),Y=s.useCallback($=>{if(M.current){$.preventDefault();return}if(d.current)return;const W=p.current;if(!(!W||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes($.key)))switch($.preventDefault(),$.key){case"ArrowUp":Q("up");break;case"ArrowDown":Q("down");break;case"ArrowLeft":Q("left");break;case"ArrowRight":Q("right");break;case"Tab":Q($.shiftKey?"left":"right");break;case"Enter":{const B=j.current.find(oe=>oe.key===W.colKey);B!=null&&B.editable&&!ie.current?(h(W),B.editable.type==="select"&&!T.current.has(W.colKey)&&q(W.colKey,B.editable)):Q("down");break}}},[Q,q]),ae=s.useMemo(()=>e.map($=>{if(!$.editable||o){const ce={...$};if(delete ce.editable,delete ce.selectable,$.selectable===!1)return{...ce,disableRowClick:!0};const B=ce.cell;return{...ce,className:`relative ${ce.className??""}`.trim(),disableRowClick:!0,cell:oe=>{const Z=n(oe),X=(b==null?void 0:b.rowId)===Z&&(b==null?void 0:b.colKey)===$.key;return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${Z}:${$.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var se;M.current||(f({rowId:Z,colKey:$.key}),(se=N.current)==null||se.focus({preventScroll:!0}))}}),X&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:uo}),t.jsx("span",{className:"relative z-0 pointer-events-none",children:B(oe)})]})}}}const W=$.editable;return{...$,className:`relative ${$.className??""}`.trim(),disableRowClick:!0,cell:ce=>{const B=n(ce),oe=$.key,Z=(u==null?void 0:u.rowId)===B&&(u==null?void 0:u.colKey)===oe,X=(b==null?void 0:b.rowId)===B&&(b==null?void 0:b.colKey)===oe,se=g[`${B}:${oe}`],E=(v==null?void 0:v.rowId)===B&&(v==null?void 0:v.colKey)===oe,J=ce[W.field],ee=String(J??""),R=()=>{var k;M.current||(f({rowId:B,colKey:oe}),h({rowId:B,colKey:oe}),(k=N.current)==null||k.focus({preventScroll:!0}),W.type==="select"&&!T.current.has(oe)&&q(oe,W))};if(Z){const k=W.type==="select"?t.jsx(jd,{initialValue:ee,options:S[oe]??[],loading:C[oe]??!1,onCommit:te=>F(B,oe,te),onCancel:fe}):t.jsx(Wd,{initialValue:ee,type:W.type??"text",mask:W.mask,onCommit:te=>F(B,oe,te),onCancel:fe});return t.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:qd,onClick:te=>te.stopPropagation(),children:k})}const x=$.cell(ce);return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${B}:${oe}`,className:`peer absolute inset-0 z-10 ${E?"cursor-wait":"cursor-pointer"}`,onClick:R}),X&&!E&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:uo}),E&&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:uo,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:se?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:se})]}):t.jsx("span",{className:"truncate",children:x})}),!E&&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,b,v,g,S,C,n,F,fe,q]);return t.jsx("div",{ref:N,tabIndex:0,onKeyDown:Y,onBlur:$=>{var W;(W=N.current)!=null&&W.contains($.relatedTarget)||setTimeout(()=>{var B,oe;const ce=document.activeElement;ce&&((B=ce.closest)!=null&&B.call(ce,"[data-bonsaif-select-dropdown]"))||(oe=N.current)!=null&&oe.contains(ce)||fe(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:t.jsx(ro,{...l,columns:ae,data:i,getRowId:n})})}function ut(e){if(e)return new Date(`${e}T12:00:00`)}function Bt(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 Dr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ys(e){return e.map(r=>ut(r)).filter(r=>!!r)}function Vd(e){if(!(e!=null&&e.length))return[];const r=new Set(e.map(Bt));return Array.from(r).sort()}function fo(e){return new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(e)}function Gs(e){const r=ut(e);if(!r)return e;const n=fo(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 bo={weekend:{dayOfWeek:[0,6]}},ho={weekend:"bonsaif-weekend"};function mo({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 Xd={background:"var(--primary)",color:"var(--primary-fg, #ffffff)",borderRadius:999},Yd={background:"color-mix(in srgb, var(--primary) 22%, transparent)",color:"var(--text-main)",borderRadius:999};function Gd({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?Xd:null,...o?Yd:null,...l?{fontWeight:800}:null,...n.style}})}function Kd({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:h=""}){const b={from:ut(e),to:ut(r)},f=ut(a),[p,g]=s.useState(()=>ut(o||e)??new Date);s.useEffect(()=>{const S=ut(o||e);S&&g(S)},[o,e]);const w=s.useMemo(()=>{if(l<=1)return Dr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(p));const S=new Date(p.getFullYear(),p.getMonth()+l-1,1),H=p.getFullYear()===S.getFullYear(),C=new Intl.DateTimeFormat("es-MX",{month:"short",...H?{}:{year:"numeric"}}).format(p),y=new Intl.DateTimeFormat("es-MX",{month:"short",year:"numeric"}).format(S);return`${Dr(C)} – ${Dr(y)}`},[p,l]);function v(){g(new Date(p.getFullYear(),p.getMonth()-1,1))}function L(){g(new Date(p.getFullYear(),p.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 ${h}`.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:v,children:t.jsx(z.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:w}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes siguiente",onClick:L,children:t.jsx(z.HiChevronRight,{size:16})})]}),t.jsx(Ya.DayPicker,{mode:"range",selected:b,month:p,onMonthChange:g,onSelect:S=>{const H=S!=null&&S.from?Bt(S.from):e,C=S!=null&&S.to?Bt(S.to):"";n({startDate:H,endDate:C})},numberOfMonths:l,hideNavigation:!0,weekStartsOn:1,disabled:f?{before:f}:void 0,showOutsideDays:!1,modifiers:bo,modifiersClassNames:ho,components:{DayButton:Gd,Weekday:mo},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:S=>`${Dr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(S))} ${S.getFullYear()}`,formatWeekdayName:fo}})]}),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 Ks({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 Zs(e,r){const n=ut(e),a=ut(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(Bt(c)),c.setDate(c.getDate()+1);return i}function Qs(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 hn(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 Zd(e,r){return typeof r!="number"||r<=0||e.length<=r?e:e.slice(-r)}function Qd(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,isDateDisabled:i,retainOutsidePrefix:c}){const d=s.useRef(null),u=s.useRef(null),h=s.useRef(!1),b=s.useRef(e);b.current=e;const f=s.useCallback(C=>{let y=C;if(c){const T=b.current.filter(_=>!_.startsWith(c)),N=C.filter(_=>_.startsWith(c));y=[...T,...N].sort()}r==null||r(Zd(y,l))},[l,r,c]),p=s.useCallback((C,y=!1)=>Qd(C,a,o)?!0:!(!(i!=null&&i(C))||y&&b.current.includes(C)),[i,o,a]),g=s.useCallback(C=>C.filter(y=>!p(y)),[p]),w=s.useCallback(()=>{u.current=null},[]);s.useEffect(()=>{const C=()=>w();return window.addEventListener("pointerup",C),window.addEventListener("pointercancel",C),()=>{window.removeEventListener("pointerup",C),window.removeEventListener("pointercancel",C)}},[w]);const v=s.useCallback((C,y,T,N)=>{const _=g(Zs(C,y));f(T==="add"?hn(N,_,"add"):hn(N,_,"remove"))},[f,g]),L=s.useCallback((C,y)=>{if(n||y.button!==0)return;const T=Bt(C);if(p(T,!0)||y.shiftKey)return;h.current=!0;const N=[...b.current],_=N.includes(T)?"remove":"add";_==="add"&&p(T)||(u.current={active:!0,mode:_,anchor:T,latest:T,baseline:N},d.current=T,v(T,T,_,N),y.preventDefault())},[v,n,p]),M=s.useCallback(C=>{const y=u.current;if(!(y!=null&&y.active)||n)return;const T=Bt(C);y.mode==="add"&&p(T)||y.latest!==T&&(y.latest=T,v(y.anchor,T,y.mode,y.baseline))},[v,n,p]),S=s.useCallback((C,y)=>{if(n)return;const T=Bt(C);if(!p(T,!0)){if(h.current&&!y.shiftKey){h.current=!1,y.preventDefault(),y.stopPropagation();return}if(h.current=!1,y.shiftKey&&d.current){y.preventDefault(),y.stopPropagation();const N=g(Zs(d.current,T));f(hn(b.current,N,"add"));return}!b.current.includes(T)&&p(T)||(d.current=T,f(hn(b.current,[T],"toggle")))}},[f,n,g,p]),H=s.useCallback(C=>{if(n)return;const y=g(Vd(C));if(!y.length)return;const T=y.every(N=>b.current.includes(N));f(hn(b.current,y,T?"remove":"add")),d.current=y[0]??d.current},[f,n,g]);return{onDayPointerDown:L,onDayPointerEnter:M,onDayClick:S,toggleWeek:H,endDrag:w}}function mn(e){return Qs(e,1)[0]}function Rs(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function Jd({value:e=[],onChange:r,minDate:n,maxDate:a,isDateDisabled:o,viewMonth:l,maxDates:i,showWeekNumbers:c=!1,viewMode:d,defaultViewMode:u="month",onViewModeChange:h,showSummary:b=!0,className:f="",disabled:p=!1}){const g=s.useMemo(()=>Ys(e),[e]),w=s.useMemo(()=>new Set(e),[e]),v=ut(n),L=ut(a),[M,S]=s.useState(()=>ut(l||e[0])??new Date),[H,C]=s.useState(()=>mn(ut(l||e[0])??new Date)),[y,T]=s.useState(u),N=d??y;function _($){d===void 0&&T($),h==null||h($)}s.useEffect(()=>{const $=ut(l);$&&(S($),C(mn($)))},[l]);const{onDayPointerDown:q,onDayPointerEnter:U,onDayClick:D,toggleWeek:K}=Js({value:e,onChange:r,disabled:p,minDate:n,maxDate:a,maxDates:i,isDateDisabled:o}),j=s.useMemo(()=>{if(p)return!0;const $=[];return v&&$.push({before:v}),L&&$.push({after:L}),o&&$.push(W=>o(Bt(W))),$.length>0?$:void 0},[p,o,L,v]),ie=s.useCallback($=>t.jsx(Ks,{...$,className:`bonsaif-multi-day-btn ${$.className??""}`,onDayPointerDown:q,onDayPointerEnter:U,onDayClickSelect:D}),[D,q,U]),Q=s.useMemo(()=>Qs(H,1),[H]),fe=Q[6],F=N==="week"?`${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short"}).format(Q[0])} – ${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short",year:"numeric"}).format(fe)}`:Dr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(M));function Y(){if(N==="week"){const $=Rs(H,-7);C(mn($)),S($);return}S(new Date(M.getFullYear(),M.getMonth()-1,1))}function ae(){if(N==="week"){const $=Rs(H,7);C(mn($)),S($);return}S(new Date(M.getFullYear(),M.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":N==="month",className:`bonsaif-cal-view-btn${N==="month"?" is-active":""}`,disabled:p,onClick:()=>{_("month"),S(H)},children:"Mes"}),t.jsx("button",{type:"button",role:"tab","aria-selected":N==="week",className:`bonsaif-cal-view-btn${N==="week"?" is-active":""}`,disabled:p,onClick:()=>{_("week"),C(mn(M))},children:"Semana"})]}),t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":N==="week"?"Semana anterior":"Mes anterior",disabled:p,onClick:Y,children:t.jsx(z.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:F}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":N==="week"?"Semana siguiente":"Mes siguiente",disabled:p,onClick:ae,children:t.jsx(z.HiChevronRight,{size:16})})]}),t.jsxs("p",{className:"bonsaif-cal-hint",children:["Click · Shift+click rango · Arrastra",c&&N==="month"?" · Semana (nº)":"",N==="week"?" · Botón semana completa":""]}),N==="month"?t.jsx(Ya.DayPicker,{mode:"multiple",required:!1,selected:g,month:M,onMonthChange:S,onSelect:()=>{},hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,showWeekNumber:c,onWeekNumberClick:($,W)=>{K(W)},disabled:j,className:"bonsaif-multi-daypicker",modifiers:bo,modifiersClassNames:ho,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:c?"bonsaif-multi-weekdays bonsaif-multi-weekdays--with-week":"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:c?"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:ie,Weekday:mo},formatters:{formatWeekdayName:fo}}):t.jsxs("div",{className:"bonsaif-week-view",children:[t.jsx("div",{className:"bonsaif-week-view-head",children:Q.map($=>t.jsx("div",{className:"bonsaif-multi-weekday",children:new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format($)},`h-${Bt($)}`))}),t.jsx("div",{className:"bonsaif-week-view-days",children:Q.map($=>{const W=Bt($),ce=w.has(W),B=p||(n?W<n:!1)||(a?W>a:!1)||!!(o!=null&&o(W)),oe=W===Bt(new Date);return t.jsx("div",{className:`bonsaif-multi-day${ce?" bonsaif-multi-day-selected":""}${oe?" bonsaif-multi-day-today":""}${B?" bonsaif-multi-day-disabled":""}`,children:t.jsxs("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:B,"aria-pressed":ce,onPointerDown:Z=>q($,Z),onPointerEnter:()=>U($),onClick:Z=>D($,Z),children:[t.jsx("span",{className:"bonsaif-week-day-num",children:$.getDate()}),t.jsx("span",{className:"bonsaif-week-day-month",children:new Intl.DateTimeFormat("es-MX",{month:"short"}).format($)})]})},W)})}),t.jsx("button",{type:"button",className:"bonsaif-week-select-all",disabled:p,onClick:()=>K(Q),children:"Marcar / desmarcar semana"})]})]}),b?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($=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:p,onClick:()=>r==null?void 0:r(e.filter(W=>W!==$)),title:`Quitar ${$}`,children:[Gs($),t.jsx("span",{"aria-hidden":!0,children:"×"})]},$))})]})}):null]})}const Rd=Array.from({length:12},(e,r)=>r);function eu({value:e=[],onChange:r,year:n,onYearChange:a,minDate:o,maxDate:l,maxDates:i,showSummary:c=!0,className:d="",disabled:u=!1,readOnly:h=!1}){const b=s.useMemo(()=>Ys(e),[e]),f=ut(o),p=ut(l),g=n??(e[0]?Number(e[0].slice(0,4)):new Date().getFullYear()),[w,v]=s.useState(g);s.useEffect(()=>{typeof n=="number"&&v(n)},[n]);function L(N){v(N),a==null||a(N)}const{onDayPointerDown:M,onDayPointerEnter:S,onDayClick:H}=Js({value:e,onChange:r,disabled:u||h,minDate:o,maxDate:l,maxDates:i,retainOutsidePrefix:`${w}-`}),C=s.useCallback(N=>t.jsx(Ks,{...N,className:`bonsaif-year-day-btn ${N.className??""}`,onDayPointerDown:M,onDayPointerEnter:S,onDayClickSelect:H}),[H,M,S]),y=b.filter(N=>N.getFullYear()===w),T=u?!0:[...f?[{before:f}]:[],...p?[{after:p}]:[]];return t.jsxs("div",{className:`bonsaif-calendar bonsaif-year-multi-date-calendar${h?" 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:()=>L(w-1),children:t.jsx(z.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:w}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año siguiente",disabled:u,onClick:()=>L(w+1),children:t.jsx(z.HiChevronRight,{size:16})})]}),!h&&!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:Rd.map(N=>{const _=new Date(w,N,1);return t.jsxs("div",{className:"bonsaif-year-cal-month",children:[t.jsx("div",{className:"bonsaif-year-cal-month-title",children:Dr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(_))}),t.jsx(Ya.DayPicker,{mode:"multiple",required:!1,selected:y,month:_,onMonthChange:()=>{},onSelect:()=>{},numberOfMonths:1,hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,disabled:T,className:"bonsaif-year-month-picker",modifiers:bo,modifiersClassNames:ho,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:C,Weekday:mo},formatters:{formatWeekdayName:q=>new Intl.DateTimeFormat("es-MX",{weekday:"narrow"}).format(q)}})]},`${w}-${N}`)})})]}),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"," ·"," ",w]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(N=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:u||h,onClick:()=>r==null?void 0:r(e.filter(_=>_!==N)),title:`Quitar ${N}`,children:[Gs(N),t.jsx("span",{"aria-hidden":!0,children:"×"})]},N))})]})}):null]})}const tu="bonsaif-ui:hide-tooltips";function el(){window.dispatchEvent(new CustomEvent(tu))}function ru(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function nu({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),[h,b]=s.useState(!1),[f,p]=s.useState({}),g=s.useRef(null),w=s.useRef(null),v=s.useCallback(C=>{u(C),c==null||c(C)},[c]),L=s.useCallback(()=>{const C=g.current;if(!C)return;const y=C.getBoundingClientRect(),T=typeof a=="number"?a:y.width,N=typeof a=="number"?a:Math.max(y.width,180),_=n==="end"?Math.max(8,y.right-N):Math.min(y.left,window.innerWidth-N-8),q=window.innerHeight-y.bottom,U=q<240&&y.top>q?void 0:y.bottom+6,D=U===void 0?window.innerHeight-y.top+6:void 0;p({position:"fixed",zIndex:9999,left:_,top:U,bottom:D,width:ru(typeof a=="number"?T:a)})},[n,a]);s.useEffect(()=>b(!0),[]),s.useEffect(()=>{if(!d)return;L();const C=T=>{var _,q;const N=T.target;!((_=g.current)!=null&&_.contains(N))&&!((q=w.current)!=null&&q.contains(N))&&v(!1)},y=T=>{T.key==="Escape"&&v(!1)};return document.addEventListener("mousedown",C),window.addEventListener("keydown",y),window.addEventListener("resize",L),window.addEventListener("scroll",L,!0),()=>{document.removeEventListener("mousedown",C),window.removeEventListener("keydown",y),window.removeEventListener("resize",L),window.removeEventListener("scroll",L,!0)}},[d,v,L]);const M=C=>{o||(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),v(!d))},S=s.isValidElement(e)?s.cloneElement(e,{onClick:()=>{o||(el(),v(!d))}}):e,H=d?t.jsx("div",{ref:w,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(C=>t.jsxs("div",{children:[C.separatorBefore&&t.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),t.jsxs("button",{type:"button",role:"menuitem",disabled:C.disabled,onClick:()=>{var y;C.disabled||(el(),(y=C.onSelect)==null||y.call(C),v(!1))},className:"flex w-full min-w-0 items-start gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:C.danger?"var(--danger)":"var(--text-main)"},children:[C.icon&&t.jsx("span",{className:"mt-0.5 shrink-0",children:C.icon}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium",children:C.label}),C.description&&t.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:C.description})]})]})]},C.id))}):null;return t.jsxs("span",{ref:g,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:[S,h&&H?pt.createPortal(H,document.body):null]})}const au=180,tl="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function ou({open:e,onClose:r,title:n,subtitle:a,leadingIcon:o,confirmLabel:l="Guardar",onConfirm:i,loading:c=!1,confirmDisabled:d=!1,headerActions:u,bodyClassName:h="flex-1 overflow-y-auto px-6 py-5",width:b=440,hasUnsavedChanges:f=!1,unsavedChangesTitle:p="Descartar cambios",unsavedChangesDescription:g="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:w="Descartar",unsavedChangesCancelLabel:v="Seguir editando",onDiscardChanges:L,disabled:M=!1,disabledMessage:S,children:H}){const[C,y]=s.useState(!1),[T,N]=s.useState(!1),[_,q]=s.useState(!1),U=s.useCallback(()=>{N(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>q(!0))})},[]),D=s.useCallback(()=>{q(!1),window.setTimeout(()=>N(!1),au)},[]),K=M||c,j=s.useCallback(()=>{if(!K){if(f){U();return}r()}},[K,f,r,U]),ie=s.useCallback(()=>{q(!1),N(!1),L==null||L(),r()},[r,L]);if(s.useEffect(()=>{y(!0)},[]),s.useEffect(()=>(document.body.style.overflow=e?"hidden":"",e||(q(!1),N(!1)),()=>{document.body.style.overflow=""}),[e]),s.useEffect(()=>{if(!e)return;const fe=F=>{if(F.key==="Escape"&&!K){if(T){D();return}j()}};return window.addEventListener("keydown",fe),()=>window.removeEventListener("keydown",fe)},[D,K,T,e,j]),!C)return null;const Q=S!==void 0?S:c?"Guardando…":null;return pt.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 ${tl}`,onClick:j}),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(Xe,{variant:"icon",onClick:j,title:"Cerrar",disabled:K,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(Xe,{variant:"secondary",size:"sm",onClick:j,disabled:K,style:{background:"var(--bg-input)"},children:"Cancelar"}),t.jsx(Xe,{variant:"primary",size:"sm",icon:t.jsx(yc.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:d||K,title:l})]})]})]}),t.jsx("div",{"data-drawer-scroll":"true",className:h,children:H}),K&&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:Q?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:Q})]}):null})]}),T&&t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":p,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[t.jsx("div",{className:`absolute inset-0 ${tl} transition-opacity duration-200 ease-out ${_?"opacity-100":"opacity-0"}`,onClick:D}),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 ${_?"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(Xe,{variant:"icon",onClick:D,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":v,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:p}),t.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:g}),t.jsxs("div",{className:"mt-6 flex gap-2",children:[t.jsx(Xe,{variant:"secondary",onClick:D,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:v}),t.jsx(Xe,{variant:"secondary",onClick:ie,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:w})]})]})]})]}),document.body)}const su=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,lu=/^\+?[0-9\s().-]+$/,iu=7,cu=15;function Wt(e){return e==null||String(e).trim()===""}function rl(e){return typeof e=="number"?e:typeof e=="string"&&e.trim()!==""?Number(e):Number.NaN}function po(e){return Wt(e)?!1:su.test(String(e))}function go(e){if(Wt(e))return!1;const r=String(e),n=r.replace(/\D/g,"");return lu.test(r)&&n.length>=iu&&n.length<=cu}function du(e="Este campo es requerido."){return r=>Wt(r)?e:void 0}function uu(e="Ingresa un correo valido."){return r=>Wt(r)||po(r)?void 0:e}function fu(e="Ingresa un telefono valido."){return r=>Wt(r)||go(r)?void 0:e}function bu(e,r){return n=>Wt(n)||String(n).length>=e?void 0:r??`Debe tener al menos ${e} caracteres.`}function hu(e,r){return n=>Wt(n)||String(n).length<=e?void 0:r??`Debe tener ${e} caracteres o menos.`}function mu(e,r){return n=>{if(Wt(n))return;const a=rl(n);return Number.isFinite(a)&&a>=e?void 0:r??`Debe ser mayor o igual a ${e}.`}}function pu(e,r){return n=>{if(Wt(n))return;const a=rl(n);return Number.isFinite(a)&&a<=e?void 0:r??`Debe ser menor o igual a ${e}.`}}function gu(e,r="El formato no es valido."){return n=>Wt(n)||e.test(String(n))?void 0:r}function vu(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 nl={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},al=s.createContext&&s.createContext(nl),yu=["attr","size","title"];function xu(e,r){if(e==null)return{};var n,a,o=wu(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 wu(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 Gn(){return Gn=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},Gn.apply(null,arguments)}function ol(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 Kn(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?ol(Object(n),!0).forEach(function(a){Nu(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ol(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function Nu(e,r,n){return(r=ku(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function ku(e){var r=Cu(e,"string");return typeof r=="symbol"?r:r+""}function Cu(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 sl(e){return e&&e.map((r,n)=>s.createElement(r.tag,Kn({key:n},r.attr),sl(r.child)))}function vo(e){return r=>s.createElement(Su,Gn({attr:Kn({},e.attr)},r),sl(e.child))}function Su(e){var r=n=>{var{attr:a,size:o,title:l}=e,i=xu(e,yu),c=o||n.size||"1em",d;return n.className&&(d=n.className),e.className&&(d=(d?d+" ":"")+e.className),s.createElement("svg",Gn({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,i,{className:d,style:Kn(Kn({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 al!==void 0?s.createElement(al.Consumer,null,n=>r(n)):r(nl)}function ll(e){return vo({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 Eu(e){return vo({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 Mu(e){return vo({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(Pt,{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 Hr({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 Zn({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 yo({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:h=!1,className:b="",required:f,...p}){const[g,w]=s.useState(()=>!!p.autoFocus),[v,L]=s.useState(!1),M=p.type==="password"&&u,S=M&&v?"text":p.type,H=!!o,C=H&&l!=="tooltip",y=H&&l!=="inline",T=!!n&&a==="tooltip"&&!C,N=h?f:void 0,_=H?"border-[var(--danger)] focus:border-[var(--danger)]":"",q=y?M?"pr-20":"pr-10":M?"pr-10":"",U=p.value!==void 0?String(p.value).length>0:p.defaultValue!==void 0&&String(p.defaultValue).length>0,D=g||U,K={top:D?7:12,color:g?"var(--primary)":"var(--text-muted)",fontSize:D?10:13,fontWeight:D?600:400,textTransform:D?"uppercase":"none"},j=Y=>{var ae;w(!0),(ae=p.onFocus)==null||ae.call(p,Y)},ie=Y=>{var ae;w(!1),(ae=p.onBlur)==null||ae.call(p,Y)},Q=M?t.jsxs("button",{type:"button","aria-label":v?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":v,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors duration-200 hover:text-[var(--primary)] focus:outline-none",tabIndex:-1,onClick:()=>L(Y=>!Y),children:[t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${v?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:t.jsx(Eu,{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 ${v?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:t.jsx(Mu,{className:"h-[18px] w-[18px]"})})]}):null,fe=y?t.jsx(Pt,{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(ll,{className:"h-[18px] w-[18px]"})})}):null,F=t.jsx(Hr,{error:C?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(Zn,{...p,type:S,required:N,placeholder:" ","aria-invalid":H||p["aria-invalid"],"data-has-value":U?"true":void 0,className:`h-11 w-full pt-5 ${q} ${_} ${b}`,onFocus:j,onBlur:ie}),t.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:K,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:D?7:12},children:c}),fe,Q]}),F]}):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:"*"}),T?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(Zn,{...p,type:S,required:N,"aria-invalid":H||p["aria-invalid"],className:`w-full ${q} ${_} ${b}`,onFocus:j,onBlur:ie}),fe,Q]}):t.jsxs("span",{className:"relative block",children:[t.jsx(Zn,{...p,required:N,"aria-invalid":H||p["aria-invalid"],className:`w-full ${q} ${_} ${b}`}),fe]}),F]})}function il(e){return e==null?"":String(e)}function Tu({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[h,b]=s.useState(()=>il(c)),f=i!==void 0?il(i):h,p=n&&f.length>0&&!po(f)?a:void 0,g=w=>{i===void 0&&b(w.currentTarget.value),d==null||d(w)};return t.jsx(yo,{...u,value:i,defaultValue:c,type:"text",inputMode:r,autoComplete:e,error:l??p,errorDisplay:o,onChange:g})}const $u={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function Au(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 cl(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 Lu(e,r,n){return r?n===void 0?e:e.slice(0,Math.max(0,n)):e.slice(0,1)}function Du({label:e,helperText:r,helperDisplay:n="inline",error:a,labelAction:o,value:l,defaultValue:i=[],onFilesChange:c,onRejectedFiles:d,multiple:u=!1,maxFiles:h,appendFiles:b=!1,showFileList:f=!0,clearable:p=!0,browseLabel:g="Buscar archivos",dropLabel:w="Suelta los archivos aqui",emptyLabel:v="Arrastra y suelta archivos",emptyDescription:L="o haz click para buscarlos en tu equipo",selectedLabel:M="Archivos seleccionados",size:S="md",containerClassName:H="",dropzoneClassName:C="",fileListClassName:y="",className:T="",id:N,accept:_,disabled:q,required:U,...D}){const K=s.useId(),j=N??K,ie=s.useRef(null),[Q,fe]=s.useState(!1),[F,Y]=s.useState(i),ae=l??F,$=!!a,W=!!r&&n==="tooltip"&&!$,ce=p&&ae.length>0&&!q,B=(k,te)=>{l===void 0&&Y(k),c==null||c(k,te)},oe=(k,te)=>{const de=k.filter(Le=>cl(Le,_)),re=k.filter(Le=>!cl(Le,_)),ge=b?[...ae,...de]:de,Ee=Lu(ge,u,h);re.length>0&&(d==null||d(re)),B(Ee,te)},Z=()=>{var k;q||(k=ie.current)==null||k.click()},X=k=>{oe(Array.from(k.target.files??[]),k),k.target.value=""},se=k=>{k.preventDefault(),q||fe(!0)},E=k=>{k.currentTarget.contains(k.relatedTarget)||fe(!1)},J=k=>{k.preventDefault(),fe(!1),!q&&oe(Array.from(k.dataTransfer.files),k)},ee=k=>{k.key!=="Enter"&&k.key!==" "||(k.preventDefault(),Z())},R=k=>{B(ae.filter((te,de)=>de!==k))},x=()=>{B([])};return t.jsxs("div",{className:`flex flex-col gap-2 ${H}`,children:[(e||o||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}),U&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),W?t.jsx(Or,{content:r}):null,o&&t.jsx("span",{className:"ml-auto normal-case",children:o})]}),t.jsx("input",{...D,ref:ie,id:j,type:"file",accept:_,multiple:u,disabled:q,required:U&&ae.length===0,"aria-invalid":$||D["aria-invalid"],className:"sr-only",onChange:X}),t.jsxs("div",{role:"button",tabIndex:q?-1:0,"aria-controls":j,"aria-disabled":q||void 0,"aria-invalid":$||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)] ${$u[S]} ${Q?"border-[var(--primary)] bg-[var(--bg-input)]":$?"border-[var(--danger)]":"border-[var(--border)]"} ${q?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${C} ${T}`,onClick:Z,onDragOver:se,onDragLeave:E,onDrop:J,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:Q?w:v}),L&&t.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:L})]}),g&&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:g})]}),f&&ae.length>0&&t.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${y}`,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}),ce&&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:x,children:t.jsx(z.HiTrash,{className:"h-4 w-4"})})]}),t.jsx("ul",{className:"divide-y divide-[var(--border)]",children:ae.map((k,te)=>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:k.name}),t.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:Au(k.size)})]}),!q&&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 ${k.name}`,onClick:()=>R(te),children:t.jsx(z.HiXMark,{className:"h-4 w-4"})})]},`${k.name}-${k.lastModified}-${te}`))})]}),t.jsx(Hr,{error:a,helperText:r,helperDisplay:n})]})}const Ou=[{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 Hu({fields:e,title:r="Layout",fieldTypes:n=Ou,saveLabel:a="Guardar",allowAddField:o=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:d,onChange:u}){const[h,b]=s.useState(()=>e.map(S=>({key:!1,type:"",...S}))),[f,p]=s.useState(""),[g,w]=s.useState(""),v=s.useCallback((S,H)=>{b(C=>{const y=C.map((T,N)=>N===S?{...T,...H}:T);return u==null||u(y),y})},[u]),L=s.useCallback(()=>{d==null||d(h)},[h,d]),M=s.useCallback(()=>{var y;const S=f.trim();if(!S){w("Ingresa un nombre de campo.");return}if(h.some(T=>T.name.toLowerCase()===S.toLowerCase())){w("Ese campo ya existe en el arreglo.");return}const C={name:S,key:!1,type:((y=n[0])==null?void 0:y.value)??""};b(T=>{const N=[...T,C];return u==null||u(N),N}),p(""),w("")},[n,h,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:[h.map((S,H)=>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:S.name}),t.jsx("div",{className:"flex justify-center",children:t.jsx(Fn,{size:"sm",checked:S.key??!1,onChange:C=>v(H,{key:C.target.checked}),"aria-label":`${S.name} es clave`})}),t.jsx(br,{value:S.type??"",onChange:C=>v(H,{type:C}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${S.name}`})]},S.name)),h.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:f,onChange:S=>{p(S.currentTarget.value),g&&w("")},onKeyDown:S=>{S.key==="Enter"&&(S.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(Xe,{variant:"secondary",onClick:M,height:36,padding:"0 12px",children:i})]}),g&&t.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:g})]}),t.jsx("div",{className:"flex justify-end",children:t.jsx(Xe,{variant:"primary",onClick:L,disabled:c,loading:c,children:a})})]})})]})}function Qn({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(Hr,{error:o,helperText:n,helperDisplay:a})]})}function Bu(e){return Array.from(e.querySelectorAll("img")).filter(r=>!!(r.currentSrc||r.src||"").trim())}function dl(e,r){const n=e.target;if(!(n instanceof HTMLImageElement))return!1;const a=e.currentTarget,o=Bu(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 It=260,Br=420,xo=380,jt="cubic-bezier(0.22, 1, 0.36, 1)",Iu="cubic-bezier(0.16, 1, 0.3, 1)",wo="cubic-bezier(0.22, 1, 0.36, 1)",Fu="cubic-bezier(0.22, 1, 0.36, 1)",_u=8,Pu=1,zu=1.25,No={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)"},Wu="color-mix(in srgb, var(--bg-card) 88%, var(--primary) 12%)",ko=10;function pn(e,r,n){return Math.min(n,Math.max(r,e))}function ju(e){return!e||e.width<1||e.height<1?null:{left:e.left,top:e.top,width:e.width,height:e.height}}function ul(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 Ir({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:{...No,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=Wu,i.currentTarget.style.transform="scale(1.06)")},onMouseLeave:i=>{i.currentTarget.style.background=String(No.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 fl({open:e,onClose:r,slides:n,index:a,onIndexChange:o,originRect:l=null,maxZoom:i=_u,minZoom:c=Pu,zoomStep:d=zu,closeOnBackdrop:u=!0,closeOnEscape:h=!0,showCounter:b=!0,showZoomControls:f=!0,loop:p=!0,showThumbnails:g=!0,zIndex:w=1100,ariaLabel:v="Visor de imagen"}){const[L,M]=s.useState(!1),[S,H]=s.useState(!1),[C,y]=s.useState(a??0),[T,N]=s.useState(1),[_,q]=s.useState({x:0,y:0}),[U,D]=s.useState({opacity:1,x:0,scale:1,blur:0,animate:!1}),[K,j]=s.useState({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),[ie,Q]=s.useState(!1),fe=s.useRef(null),F=s.useRef(null),Y=s.useRef(null),ae=s.useRef(null),$=s.useRef(null),W=s.useRef(!1),ce=s.useRef(!1),B=s.useRef(null),oe=s.useRef(null),Z=s.useRef(null),X=s.useRef(null),se=s.useRef(null),E=s.useRef(a??0),J=a??C,ee=n.length===0?0:pn(J,0,Math.max(0,n.length-1)),R=n[ee],x=n.length>1,k=Math.max(c,i),te=g&&x,de=s.useCallback(he=>{if(n.length===0)return;const ye=n.length-1,_e=p?(he%n.length+n.length)%n.length:pn(he,0,ye);a===void 0&&y(_e),o==null||o(_e)},[a,p,o,n.length]),re=s.useCallback(()=>{N(1),q({x:0,y:0})},[]),ge=s.useCallback((he,ye)=>{if(ye<=c+.001)return{x:0,y:0};const _e=X.current,We=se.current;if(!_e||!We)return he;const je=_e.getBoundingClientRect(),ht=We.offsetWidth*ye,lt=We.offsetHeight*ye,Ke=Math.max(0,(ht-je.width)/2+je.width*.15),Re=Math.max(0,(lt-je.height)/2+je.height*.15);return{x:pn(he.x,-Ke,Ke),y:pn(he.y,-Re,Re)}},[c]),Ee=s.useCallback(()=>{M(!1),j({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),ae.current=null,$.current=null,W.current=!1,ce.current=!1,B.current&&(clearTimeout(B.current),B.current=null)},[]),Le=s.useCallback(()=>{if(W.current)return;W.current=!0,H(!1),re();const he=ae.current,ye=he!=null&&$.current!=null&&$.current===ee;if(he&&ye){Y.current!=null&&cancelAnimationFrame(Y.current),Y.current=requestAnimationFrame(()=>{Y.current=requestAnimationFrame(()=>{const _e=se.current;if(!_e){Y.current=null,fe.current&&clearTimeout(fe.current),fe.current=setTimeout(Ee,It+40);return}const We=_e.getBoundingClientRect(),je=ul(he,We);j({enabled:!0,dx:0,dy:0,scale:1,animate:!1}),Y.current=requestAnimationFrame(()=>{j({enabled:!0,dx:je.dx,dy:je.dy,scale:je.scale,animate:!0}),Y.current=null})})}),fe.current&&clearTimeout(fe.current),fe.current=setTimeout(Ee,Br+80);return}j({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),fe.current&&clearTimeout(fe.current),fe.current=setTimeout(Ee,It+40)},[Ee,re,ee]);s.useEffect(()=>(e?(fe.current&&clearTimeout(fe.current),B.current&&(clearTimeout(B.current),B.current=null),W.current=!1,ce.current=!1,ae.current=ju(l),$.current=ae.current!=null?a??C:null,M(!0),H(!1),ae.current?j({dx:0,dy:0,scale:1,animate:!1,enabled:!0}):($.current=null,requestAnimationFrame(()=>requestAnimationFrame(()=>{H(!0),j({dx:0,dy:0,scale:1,animate:!1,enabled:!1})})))):L&&Le(),()=>{fe.current&&clearTimeout(fe.current),Y.current!=null&&cancelAnimationFrame(Y.current)}),[e]);const gt=s.useCallback(()=>{if(!e||W.current||ce.current)return;const he=ae.current,ye=se.current;if(!he||!ye){he||(H(!0),ce.current=!0);return}const _e=ye.getBoundingClientRect();if(_e.width<2||_e.height<2)return;ce.current=!0;const We=ul(he,_e);j({enabled:!0,dx:We.dx,dy:We.dy,scale:We.scale,animate:!1}),Y.current!=null&&cancelAnimationFrame(Y.current),Y.current=requestAnimationFrame(()=>{Y.current=requestAnimationFrame(()=>{j({enabled:!0,dx:0,dy:0,scale:1,animate:!0}),H(!0),Y.current=null,B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{j({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),B.current=null},Br+20)})})},[e]);s.useLayoutEffect(()=>{!L||!e||!ae.current||ce.current||gt()},[L,e,gt]),s.useEffect(()=>{!e||W.current||$.current!=null&&$.current!==ee&&j(he=>he.enabled?{dx:0,dy:0,scale:1,animate:!1,enabled:!1}:he)},[e,ee]),s.useEffect(()=>{if(!e)return;const he=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=he}},[e]),s.useEffect(()=>{e&&re()},[e,ee,re]),s.useEffect(()=>{a!==void 0&&y(a)},[a]),s.useEffect(()=>{if(!e){E.current=ee,D({opacity:1,x:0,scale:1,blur:0,animate:!1});return}const he=E.current;if(he===ee)return;E.current=ee;const ye=n.length;let _e=1;if(ye>1){const We=(he+1)%ye===ee,je=(he-1+ye)%ye===ee;je&&!We?_e=-1:We&&!je?_e=1:_e=ee>he?1:-1}return F.current!=null&&(cancelAnimationFrame(F.current),F.current=null),D({opacity:0,x:_e*56,scale:.94,blur:8,animate:!1}),F.current=requestAnimationFrame(()=>{F.current=requestAnimationFrame(()=>{D({opacity:1,x:0,scale:1,blur:0,animate:!0}),F.current=null})}),()=>{F.current!=null&&(cancelAnimationFrame(F.current),F.current=null)}},[e,ee,n.length]);const Tt=T<=c+.001&&Math.abs(_.x)<.5&&Math.abs(_.y)<.5,nt=s.useCallback((he,ye,_e)=>{N(We=>{const je=pn(he,c,k);if(Math.abs(je-We)<1e-4)return We;const ht=je/We,lt=je<We;return je<=c+.001?(q({x:0,y:0}),c):(q(Ke=>{let Re=Ke;if(typeof ye=="number"&&typeof _e=="number"&&X.current&&!lt){const ft=X.current.getBoundingClientRect(),dt=ye-ft.left-ft.width/2,pr=_e-ft.top-ft.height/2;Re={x:dt-(dt-Ke.x)*ht,y:pr-(pr-Ke.y)*ht}}else if(lt){Re={x:Ke.x*ht,y:Ke.y*ht};const ft=Math.min(1,(We-je)/Math.max(.01,We-c));Re={x:Re.x*(1-ft*.65),y:Re.y*(1-ft*.65)}}else Re={x:Ke.x*ht,y:Ke.y*ht};return ge(Re,je)}),je)})},[ge,c,k]),ot=s.useCallback(()=>{nt(T*d)},[nt,T,d]),ue=s.useCallback(()=>{const he=Math.max(c,T/d);if(he<=c+.001){re();return}N(he),q({x:0,y:0})},[c,re,T,d]);s.useEffect(()=>{if(!e)return;const he=ye=>{if(ye.key==="Escape"&&h){ye.preventDefault(),r();return}ye.key==="ArrowLeft"&&x?(ye.preventDefault(),de(ee-1)):ye.key==="ArrowRight"&&x?(ye.preventDefault(),de(ee+1)):ye.key==="+"||ye.key==="="?(ye.preventDefault(),nt(T*d)):ye.key==="-"||ye.key==="_"?(ye.preventDefault(),ue()):ye.key==="0"&&(ye.preventDefault(),re())};return window.addEventListener("keydown",he),()=>window.removeEventListener("keydown",he)},[nt,h,x,r,e,re,ee,T,de,ue,d]);const $e=he=>{he.preventDefault();const ye=he.deltaY>0?1/d:d;nt(T*ye,he.clientX,he.clientY)},ne=he=>{T<=c+.001||(he.currentTarget.setPointerCapture(he.pointerId),Q(!0),oe.current={pointerId:he.pointerId,startX:he.clientX,startY:he.clientY,originX:_.x,originY:_.y})},He=he=>{const ye=oe.current;!ye||ye.pointerId!==he.pointerId||q(ge({x:ye.originX+(he.clientX-ye.startX),y:ye.originY+(he.clientY-ye.startY)},T))},Fe=he=>{var ye;((ye=oe.current)==null?void 0:ye.pointerId)===he.pointerId&&(oe.current=null,Q(!1))},Ge=he=>{if(he.stopPropagation(),T>c+.05){re();return}nt(Math.min(k,3),he.clientX,he.clientY)},Ye=he=>{if(he.touches.length!==2)return;Q(!0);const[ye,_e]=[he.touches[0],he.touches[1]],We=Math.hypot(ye.clientX-_e.clientX,ye.clientY-_e.clientY);Z.current={distance:We,scale:T}},ze=he=>{if(he.touches.length!==2||!Z.current)return;he.preventDefault();const[ye,_e]=[he.touches[0],he.touches[1]],We=Math.hypot(ye.clientX-_e.clientX,ye.clientY-_e.clientY),je=(ye.clientX+_e.clientX)/2,ht=(ye.clientY+_e.clientY)/2,lt=Z.current.scale*(We/Math.max(1,Z.current.distance));nt(lt,je,ht)},Je=()=>{Z.current=null,Q(!1)};if(!L||!R)return null;const st=K.enabled,$t=K.animate?`transform ${Br}ms ${Fu}`:"none";return pt.createPortal(t.jsxs("div",{className:"fixed inset-0",style:{zIndex:w},role:"dialog","aria-modal":"true","aria-label":v,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:S?1:0,transition:`opacity ${st?Br:It}ms ${jt}`,cursor:"default",zIndex:0},onClick:()=>{u&&r()}}),t.jsx("div",{ref:X,className:"absolute inset-0 flex items-center justify-center",style:{zIndex:1,padding:te?"4.5rem 3.5rem 6.5rem":"4.5rem 3.5rem 2.5rem",opacity:st||S?1:0,transform:st||S?"translateY(0) scale(1)":"translateY(10px) scale(0.96)",transition:st?"none":`opacity ${It}ms ${jt}, transform ${It}ms ${jt}`},onClick:he=>{he.target===he.currentTarget&&u&&r()},onWheel:$e,children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{transform:K.enabled?`translate3d(${K.dx}px, ${K.dy}px, 0) scale(${K.scale})`:void 0,transformOrigin:"center center",transition:K.enabled?$t:void 0},children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{opacity:U.opacity,filter:U.blur?`blur(${U.blur}px)`:"blur(0px)",transform:`translate3d(${U.x}px, 0, 0) scale(${U.scale})`,transition:U.animate?[`opacity ${xo}ms ${wo}`,`transform ${xo}ms ${wo}`,`filter ${xo}ms ${wo}`].join(", "):"none"},children:t.jsx("div",{ref:se,className:"pointer-events-auto relative max-h-full max-w-full touch-none select-none will-change-transform",style:{cursor:T>c+.001?"grab":"zoom-in",transform:`translate3d(${_.x}px, ${_.y}px, 0) scale(${T})`,transformOrigin:"center center",transition:ie?"none":`transform 220ms ${Iu}`},onClick:he=>he.stopPropagation(),onDoubleClick:Ge,onPointerDown:ne,onPointerMove:He,onPointerUp:Fe,onPointerCancel:Fe,onTouchStart:Ye,onTouchMove:ze,onTouchEnd:Je,children:t.jsx("img",{src:R.src,alt:R.alt||"",draggable:!1,className:"block max-h-[min(78vh,820px)] max-w-[min(86vw,1100px)] object-contain",style:{display:"block",borderRadius:ko,imageRendering:T>2.5?"pixelated":"auto"},onLoad:()=>{gt()}},R.src+String(ee))})})})}),t.jsxs("div",{className:"pointer-events-none absolute inset-0",style:{zIndex:2,opacity:S?1:0,transform:S?"translateY(0)":"translateY(-6px)",transition:`opacity ${st?Br:It}ms ${jt}, transform ${st?Br:It}ms ${jt}`},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:No,children:[ee+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(Ir,{label:"Alejar",onClick:ue,disabled:T<=c+.001,children:t.jsx(z.HiMinus,{className:"h-5 w-5"})}),t.jsx(Ir,{label:"Restablecer tamaño",onClick:re,disabled:Tt,children:t.jsx(z.HiArrowsPointingIn,{className:"h-5 w-5"})}),t.jsx(Ir,{label:"Acercar",onClick:ot,disabled:T>=k-.001,children:t.jsx(z.HiPlus,{className:"h-5 w-5"})})]}):null,t.jsx(Ir,{label:"Cerrar",onClick:r,children:t.jsx(z.HiXMark,{className:"h-5 w-5"})})]})]}),x?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"pointer-events-auto absolute left-3 top-1/2",style:{opacity:S?1:0,transform:S?"translate(0, -50%)":"translate(-8px, -50%)",transition:`opacity ${It}ms ${jt}, transform ${It}ms ${jt}`},children:t.jsx(Ir,{label:"Anterior",size:"lg",onClick:()=>de(ee-1),disabled:!p&&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:S?1:0,transform:S?"translate(0, -50%)":"translate(8px, -50%)",transition:`opacity ${It}ms ${jt}, transform ${It}ms ${jt}`},children:t.jsx(Ir,{label:"Siguiente",size:"lg",onClick:()=>de(ee+1),disabled:!p&&ee>=n.length-1,children:t.jsx(z.HiChevronRight,{className:"h-6 w-6"})})})]}):null,te?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((he,ye)=>{const _e=ye===ee;return t.jsx("button",{type:"button",role:"tab","aria-selected":_e,"aria-label":he.alt||`Imagen ${ye+1}`,onClick:We=>{We.stopPropagation(),de(ye)},className:"relative shrink-0 overflow-hidden transition-opacity",style:{width:56,height:42,borderRadius:ko,opacity:_e?1:.42,transition:`opacity 180ms ${jt}`},children:t.jsx("img",{src:he.src,alt:"",draggable:!1,className:"h-full w-full object-cover",style:{borderRadius:ko}})},`${he.src}-${ye}`)})})}):null]})]}),document.body)}function qu({children:e,className:r,style:n,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c,zIndex:d}){const[u,h]=s.useState(!1),[b,f]=s.useState(0),[p,g]=s.useState([]),[w,v]=s.useState(null),L=s.useCallback((S,H,C)=>{g(S),v(C??null),f(H),h(!0)},[]),M=s.useCallback(S=>{dl(S,L)},[L]);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`[&_img]:cursor-zoom-in ${r??""}`,style:n,onClick:M,children:e}),t.jsx(fl,{open:u,onClose:()=>h(!1),index:b,onIndexChange:f,slides:p,originRect:w,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c,zIndex:d})]})}function bl(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function hl(e,r){if(e.length!==r.length)return!1;const n=new Set(r);return e.every(a=>n.has(a))}function Co(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Uu(e,r){if(!r)return!0;const n=Co(r);return Co(e.label).includes(n)||!!(e.sublabel&&Co(e.sublabel).includes(n))}function Vu({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:h=6,maxVisibleValues:b=2,truncateSelectedValues:f=!0,selectedOverflowPopover:p=!0,emptyText:g="Sin resultados",clearLabel:w="Limpiar seleccion",pruneMissingValues:v=!0}){const[L,M]=s.useState(!1),[S,H]=s.useState(""),[C,y]=s.useState(0),[T,N]=s.useState(!1),[_,q]=s.useState({}),U=s.useRef(null),D=s.useRef(null),K=s.useRef(null),j=s.useRef(null),ie=u&&n.length>=h,Q=s.useMemo(()=>new Set(e),[e]),fe=s.useMemo(()=>{const x=new Map;for(const k of n)x.set(k.value,k);return x},[n]),F=s.useMemo(()=>{const x=[];for(const k of e){const te=fe.get(k);te&&x.push(te)}return x},[fe,e]),Y=b==="all"?F.length:b,ae=F.slice(0,Y),$=Math.max(0,F.length-ae.length),W=p&&F.length>1,ce=t.jsxs("div",{className:"flex max-w-[280px] flex-col gap-1.5 py-0.5",children:[t.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wide",style:{color:"var(--text-muted)"},children:[F.length," seleccionados"]}),t.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:F.map(x=>t.jsxs("li",{className:"flex min-w-0 items-baseline gap-1.5 text-xs",style:{color:"var(--text-main)"},children:[x.color&&t.jsx("span",{className:"mt-1 h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:x.color}}),t.jsx("span",{className:"min-w-0 break-words font-medium",children:x.label}),x.sublabel?t.jsx("span",{className:"min-w-0 break-words",style:{color:"var(--text-muted)"},children:x.sublabel}):null]},x.value))})]}),B=s.useMemo(()=>{const x=S.trim();return!ie||!x?n:n.filter(k=>Uu(k,x))},[n,S,ie]),oe=s.useCallback(()=>{const x=U.current;if(!x)return;const k=x.getBoundingClientRect(),te=ie?304:244,de=window.innerHeight-k.bottom,re=de<te&&k.top>de;q({position:"fixed",left:k.left,top:re?void 0:k.bottom+4,bottom:re?window.innerHeight-k.top+4:void 0,width:Math.max(k.width,240),zIndex:9999})},[ie]),Z=s.useCallback(x=>{hl(e,x)||r(x)},[r,e]),X=s.useCallback(x=>{const k=fe.get(x);if(k!=null&&k.disabled)return;const te=Q.has(x)?e.filter(de=>de!==x):[...e,x];Z(te)},[Z,fe,e,Q]),se=s.useCallback(()=>Z([]),[Z]),E=s.useCallback(()=>{M(!1),H(""),y(0)},[]);s.useEffect(()=>N(!0),[]);const J=s.useMemo(()=>n.map(x=>x.value).join("\0"),[n]);s.useEffect(()=>{if(!v||e.length===0||n.length===0)return;const x=new Set(n.map(te=>te.value)),k=e.filter(te=>x.has(te));hl(e,k)||r(k)},[J]),s.useEffect(()=>{if(!L)return;function x(k){var de,re;const te=k.target;!((de=U.current)!=null&&de.contains(te))&&!((re=D.current)!=null&&re.contains(te))&&E()}return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[E,L]),s.useEffect(()=>{L&&(y(0),oe(),ie&&setTimeout(()=>{var x;return(x=K.current)==null?void 0:x.focus()},0))},[L,ie,oe]),s.useEffect(()=>{if(L)return window.addEventListener("resize",oe),window.addEventListener("scroll",oe,!0),()=>{window.removeEventListener("resize",oe),window.removeEventListener("scroll",oe,!0)}},[L,oe]),s.useEffect(()=>{if(B.length===0){y(0);return}y(x=>Math.min(x,B.length-1))},[B.length]),s.useEffect(()=>{if(C<0||!j.current)return;const x=j.current.children[C];x==null||x.scrollIntoView({block:"nearest"})},[C]);function ee(x){if(!o){if(!L){(x.key==="Enter"||x.key===" "||x.key==="ArrowDown")&&(x.preventDefault(),M(!0));return}if(x.key==="Escape"){x.preventDefault(),E();return}if(x.key==="ArrowDown"){if(x.preventDefault(),B.length===0)return;y(k=>Math.min(k+1,B.length-1));return}if(x.key==="ArrowUp"){x.preventDefault(),y(k=>Math.max(k-1,0));return}if(x.key==="Enter"&&B[C]&&!B[C].disabled){x.preventDefault(),X(B[C].value);return}x.key==="Backspace"&&!S&&e.length&&(x.preventDefault(),Z(e.slice(0,-1)))}}const R=t.jsxs("div",{ref:D,className:"overflow-hidden rounded-xl shadow-xl",style:{..._,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[ie&&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:K,value:S,onChange:x=>{H(x.target.value),y(0)},onKeyDown:x=>{(x.key==="ArrowDown"||x.key==="ArrowUp"||x.key==="Enter"||x.key==="Escape")&&(x.stopPropagation(),ee(x))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),S&&t.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:x=>{x.preventDefault(),H(""),y(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:[F.length," seleccionados",e.length>F.length?` (${e.length-F.length} no disponibles)`:""]}),t.jsx("button",{type:"button",onMouseDown:x=>{x.preventDefault(),se()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:w})]}),t.jsxs("ul",{ref:j,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:ie?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[B.map((x,k)=>{const te=k===C,de=Q.has(x.value);return t.jsxs("li",{role:"option","aria-selected":de,onMouseDown:re=>{re.preventDefault(),!x.disabled&&X(x.value)},onMouseEnter:()=>!x.disabled&&y(k),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:te?"var(--bg-hover)":de?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:x.disabled?"var(--text-muted)":"var(--text-main)",cursor:x.disabled?"not-allowed":"pointer",opacity:x.disabled?.58:1},children:[t.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:de?"var(--primary)":"var(--border)",background:de?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:de&&t.jsx(z.HiCheck,{className:"h-3 w-3"})}),x.color&&t.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:x.color}}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx(Yt,{className:"min-w-0 flex-1",children:x.label}),x.sublabel&&t.jsx(Yt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:x.sublabel})]}),x.badge&&t.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:x.badge})]},x.value)}),B.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:U,className:`relative ${l||"w-full"}`,style:i,onKeyDown:ee,children:[t.jsxs("button",{type:"button",disabled:o,onClick:()=>{o||(L?E():M(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:bl(c),padding:bl(d),background:"var(--bg-input)",color:F.length?"var(--text-main)":"var(--text-muted)",border:L?"1px solid var(--primary)":"1px solid var(--border)",opacity:o?.5:1,cursor:o?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":L,children:[t.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:ae.length?(()=>{const x=t.jsxs(t.Fragment,{children:[ae.map(k=>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:[k.color&&t.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:k.color}}),f?t.jsx(Yt,{className:"min-w-0 flex-1",children:k.label}):t.jsx("span",{className:"break-words",children:k.label}),t.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${k.label}`,onMouseDown:te=>{te.preventDefault(),te.stopPropagation(),X(k.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"})})]},k.value)),$>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)"},"aria-label":`${$} seleccionados más`,children:["+",$]})]});return W?t.jsx(Pt,{as:"span",content:ce,placement:"bottom",followCursor:!1,className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:x}):x})():t.jsx("span",{className:"truncate",children:a})}),F.length?t.jsx("span",{role:"button",tabIndex:-1,"aria-label":w,onMouseDown:x=>{x.preventDefault(),x.stopPropagation(),se()},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:L?"rotate(180deg)":"rotate(0deg)"}})]}),L&&T&&pt.createPortal(R,document.body)]})}function Xu({inputMode:e="decimal",...r}){return t.jsx(yo,{...r,type:"number",inputMode:e})}function Yu(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 Gu({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=Yu(c,i,o);return t.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[t.jsx(Xe,{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,h)=>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-${h}`):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(Xe,{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 ml=[{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 pl(e){return e==null?"":String(e)}function Jn(e){return e?e.startsWith("+")?e:`+${e}`:"+1"}function Ku(e){return typeof e=="number"?`${e}px`:e}function Zu({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:h="+1",onCountryCodeChange:b,allowedCountryCodes:f,countryCodeOptions:p,countryCodePlaceholder:g="Codigo",countryCodeClassName:w="",countryCodeWidth:v=84,onPhoneValueChange:L,label:M,containerClassName:S="",helperText:H,helperDisplay:C="inline",labelAction:y,className:T="",required:N,disabled:_,floatingLabel:q,showPasswordToggle:U,nativeValidation:D,errorTooltipLabel:K="Error de validacion",...j}){var k;const[ie,Q]=s.useState(()=>pl(c)),[fe,F]=s.useState(()=>Jn(h)),Y=s.useMemo(()=>{const te=p??ml,de=f==null?void 0:f.map(Jn);return de!=null&&de.length?te.filter(re=>de.includes(re.value)):te},[f,p]),ae=((k=Y[0])==null?void 0:k.value)??"+1",$=Y.some(te=>te.value===Jn(u??fe))?Jn(u??fe):ae,W=i!==void 0?pl(i):ie,ce=`${$} ${W}`.trim(),B=n&&W.length>0&&!go(ce)?a:void 0,oe=l??B,Z=!!oe,X=Z&&o!=="tooltip",se=Z&&o!=="inline",E=!!H&&C==="tooltip"&&!X,J=Z?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",ee=te=>{const de=te.currentTarget.value;i===void 0&&Q(de),L==null||L(de,{countryCode:$,nationalNumber:de,fullNumber:`${$} ${de}`.trim()}),d==null||d(te)},R=te=>{u===void 0&&F(te),b==null||b(te),L==null||L(W,{countryCode:te,nationalNumber:W,fullNumber:`${te} ${W}`.trim()})},x=se?t.jsx(Pt,{as:"span",content:oe,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":K,className:"flex h-full w-full items-center justify-center outline-none",children:t.jsx(ll,{className:"h-[18px] w-[18px]"})})}):null;return t.jsxs("div",{className:`flex flex-col gap-2 ${S}`,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}),N&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),E?t.jsx(Or,{content:H}):null,y&&t.jsx("span",{className:"ml-auto normal-case",children:y})]}),t.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${J}`,children:[t.jsx(br,{value:$,onChange:R,options:Y,placeholder:g,disabled:_,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${w}`,style:{width:Ku(v)},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",{...j,value:i,defaultValue:c,type:"tel",inputMode:r,autoComplete:e,disabled:_,required:void 0,"aria-label":j["aria-label"]??(typeof M=="string"?M:void 0),"aria-invalid":Z||j["aria-invalid"],className:`h-full w-full min-w-0 bg-transparent px-2 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed disabled:opacity-60 ${se?"pr-10":""} ${T}`,onChange:ee}),x]})]}),t.jsx(Hr,{error:X?oe:void 0,helperText:H,helperDisplay:C})]})}function Qu({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 h=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:h?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:h?"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:h,disabled:b,onChange:()=>r(u.value),className:"absolute inset-0 opacity-0"}),t.jsx("span",{className:`h-2 w-2 rounded-full transition ${h?"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 Ju='<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" aria-hidden="true" height="14" width="14" class="rich-code-copy-clipboard" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M17.663 3.118c.225.015.45.032.673.05C19.876 3.298 21 4.604 21 6.109v9.642a3 3 0 0 1-3 3V16.5c0-5.922-4.576-10.775-10.384-11.217.324-1.132 1.3-2.01 2.548-2.114.224-.019.448-.036.673-.051A3 3 0 0 1 13.5 1.5H15a3 3 0 0 1 2.663 1.618ZM12 4.5A1.5 1.5 0 0 1 13.5 3H15a1.5 1.5 0 0 1 1.5 1.5H12Z" clip-rule="evenodd"></path><path d="M3 8.625c0-1.036.84-1.875 1.875-1.875h.375A3.75 3.75 0 0 1 9 10.5v1.875c0 1.036.84 1.875 1.875 1.875h1.875A3.75 3.75 0 0 1 16.5 18v2.625c0 1.035-.84 1.875-1.875 1.875h-9.75A1.875 1.875 0 0 1 3 20.625v-12Z"></path><path d="M10.5 10.5a5.23 5.23 0 0 0-1.279-3.434 9.768 9.768 0 0 1 6.963 6.963 5.23 5.23 0 0 0-3.434-1.279h-1.875a.375.375 0 0 1-.375-.375V10.5Z"></path></svg>',Ru='<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" aria-hidden="true" height="14" width="14" class="rich-code-copy-check" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M19.916 4.626a.75.75 0 0 1 .208 1.04l-9 13.5a.75.75 0 0 1-1.154.114l-6-6a.75.75 0 0 1 1.06-1.06l5.353 5.353 8.493-12.74a.75.75 0 0 1 1.04-.207Z" clip-rule="evenodd"></path></svg>';function gl(){return`<button type="button" class="rich-code-copy" data-action="copy-code" title="Copiar" aria-label="Copiar">${Ju}${Ru}</button>`}const ef=new Set(["div","p","li","tr","pre","h1","h2","h3","h4","h5","h6"]);function vl(e){const r=n=>{if(n.nodeType===Node.TEXT_NODE)return(n.textContent??"").replace(/\u00a0/g," ");if(n.nodeType!==Node.ELEMENT_NODE)return"";const a=n,o=a.tagName.toLowerCase();if(o==="br")return`
25
+ `;if(o==="script"||o==="style")return"";let l="";for(const i of Array.from(a.childNodes))l+=r(i);return ef.has(o)&&l.length>0&&!l.endsWith(`
26
26
  `)&&(l+=`
27
27
  `),l};return r(e).replace(/\r\n?/g,`
28
28
  `).replace(/\n{3,}/g,`
29
29
 
30
- `).replace(/^\n+/,"").replace(/\n+$/,"")}async function cl(e){const r=e.closest(".rich-code-wrap"),n=r==null?void 0:r.querySelector("pre"),a=(n==null?void 0:n.querySelector("code"))??n,o=a?il(a):"";if(!o.trim())throw new Error("empty_code_block");await Qa(o),dl(e)}function dl(e,r=2e3){e.setAttribute("data-copied","true"),e.title="Copiado",e.setAttribute("aria-label","Copiado"),window.setTimeout(()=>{e.removeAttribute("data-copied"),e.title="Copiar",e.setAttribute("aria-label","Copiar")},r)}function ul(e,r,n=!0){const a=e.replace(/\r\n?/g,`
31
- `),o=r(a).replace(/\n/g,"<br>")||"<br>",l=`<div class="rich-code-wrap"><div class="rich-code-header" contenteditable="false"><span class="rich-code-label">Código</span>${ll()}</div><pre class="rich-code-block"><code>${o}</code></pre></div>`;return n?`${l}<p><br></p>`:l}const Uu=new Set(["table","thead","tbody","tfoot","tr","th","td","caption"]),Un=(e,r,n)=>Math.min(n,Math.max(r,Math.round(e)||r)),Or=12,Vn=8,mo=(e,r,n)=>{const a=Yn(n),o=e.insertRow(r);for(let l=0;l<a;l+=1){const i=o.insertCell(-1);i.innerHTML="<br>"}return o.cells[0]??null},fl=(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>=Or?null:mo(l,0,e)}if(a.tagName==="TBODY"&&a.rows.length>=Or)return null;const o=Array.from(a.rows).indexOf(n);return mo(a,o+1,e)},Vu=(e,r)=>{var o;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"&&((o=e.tBodies[0])==null?void 0:o.rows.length)===0&&e.rows.length<=1?!1:(n.remove(),!0)},bl=(e,r)=>Yn(e)>=Vn?!1:(e.querySelectorAll("tr").forEach(n=>{const a=n.closest("thead")!==null,o=document.createElement(a?"th":"td");a?o.textContent=`Columna ${n.cells.length+1}`:o.innerHTML="<br>";const l=n.cells[r];l!=null&&l.nextSibling?n.insertBefore(o,l.nextSibling):n.appendChild(o)}),!0),Xu=(e,r)=>Yn(e)<=1?!1:(e.querySelectorAll("tr").forEach(n=>{var a;(a=n.cells[r])==null||a.remove()}),!0),hl=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")})},ml=(e,r,n)=>{hl(e),r&&(r.classList.add("rich-table-row-active"),e.querySelectorAll("tr").forEach(a=>{var o;(o=a.cells[n])==null||o.classList.add("rich-table-col-active")}))},Yu=(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}}},Xn=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},pl=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")})},Ku=(e,r,n,a,o)=>{switch(e){case"table-delete":return r.remove(),!0;case"table-row-add":{const l=Number.isFinite(n)?fl(r,n):po(r);return l&&Kn(l,o,!0),!!l}case"table-row-del":return Number.isFinite(n)?Vu(r,n):!1;case"table-col-add":return Number.isFinite(a)?bl(r,a):Ju(r);case"table-col-del":return Number.isFinite(a)?Xu(r,a):!1;default:return!1}},Yn=e=>{let r=0;return e.querySelectorAll("tr").forEach(n=>{r=Math.max(r,n.cells.length)}),r||1},Gu=e=>{const r=e.tBodies[0]??e.createTBody();return Array.from(r.rows)},gl=e=>(e==null?void 0:e.closest("table"))??null,vl=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},Zu=e=>Array.from(e.querySelectorAll("th, td")),yl=(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),o=e.closest("tr");return!o||o!==a[a.length-1]?!1:e===o.cells[o.cells.length-1]},Qu=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()===""},Kn=(e,r,n=!0)=>{r==null||r.focus();const a=document.createRange();a.selectNodeContents(e),a.collapse(n);const o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(a)},po=e=>{const r=Gu(e);if(r.length>=Or)return null;const n=r[r.length-1];if(!n){const a=e.tBodies[0]??e.createTBody();return mo(a,0,e)}return fl(e,Array.from(e.rows).indexOf(n))},Ju=e=>{const r=Yn(e)-1;return r<0?!1:bl(e,r)},go=e=>{pl(e)},Ru=(e,r,n)=>{const a=Un(e,1,Or),o=Un(r,1,Vn),l=n?`<thead><tr>${Array.from({length:o},(c,d)=>`<th>Columna ${d+1}</th>`).join("")}</tr></thead>`:"",i=Array.from({length:a},()=>`<tr>${Array.from({length:o},()=>"<td><br></td>").join("")}</tr>`).join("");return`<table class="rich-table">${l}<tbody>${i}</tbody></table><p><br></p>`},xl=()=>'<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>',Hr=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),wl=e=>e.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(r,n,a)=>`${n}${a.toLocaleUpperCase()}`),ef=e=>e.replace(/[<>]/g,"").toLowerCase(),tf=new Set(["p","br","div","span","b","strong","i","em","u","s","strike","ul","ol","li","h1","h2","h3","h4","blockquote","pre","code","button","a","img","hr","table","thead","tbody","tfoot","tr","th","td","caption"]),rf=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,nf=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},Gn=(e,r)=>r.test(e),af=e=>Gn(e,/font-weight\s*:\s*(bold|[6-9]00)/i),of=e=>Gn(e,/font-style\s*:\s*italic/i),sf=e=>Gn(e,/text-decoration(?:-line)?\s*:[^;]*underline/i),lf=e=>Gn(e,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),Zn=(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)},Qn=e=>{const r=e.parentNode;if(!r){e.remove();return}for(;e.firstChild;)r.insertBefore(e.firstChild,e);r.removeChild(e)},cf=e=>{const r=e.getAttribute("class")??"",n=e.getAttribute("style")??"";return/mso-list/i.test(n)||/MsoListParagraph/i.test(r)||/MsoList/i.test(r)},Nl=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"},df=e=>{const n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT).nextNode();if(!n||!n.textContent)return;const a=n.textContent.replace(rf,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");a!==n.textContent&&(n.textContent=a)},uf=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&&(af(a)&&Zn(n,"strong"),of(a)&&Zn(n,"em"),sf(a)&&Zn(n,"u"),lf(a)&&Zn(n,"s"))})},ff=e=>{const r=Array.from(e.querySelectorAll("p, div")).filter(cf);if(!r.length)return;let n=0;for(;n<r.length;){const a=r[n],o=Nl(a),l=[a];let i=n+1;for(;i<r.length;){const u=r[i];if(Nl(u)!==o)break;let h=l[l.length-1].nextSibling;for(;h&&h.nodeType===Node.TEXT_NODE&&!(h.textContent??"").trim();)h=h.nextSibling;if(h!==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=>{df(u);const h=u.ownerDocument.createElement("li");for(;u.firstChild;)h.appendChild(u.firstChild);d.appendChild(h),u.remove()}),n=i}},bf=e=>e==="h1"?"h2":e==="h4"||e==="h5"||e==="h6"?"h3":e==="div"?"p":e,hf=e=>{const r=nf(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,"")),a=new DOMParser().parseFromString(`<!DOCTYPE html><html><body>${r}</body></html>`,"text/html"),o=a.body;o.querySelectorAll("script, style, meta, link, xml, title, head, iframe, object, embed, form, input, textarea, select, noscript").forEach(i=>i.remove()),uf(o),ff(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"){Qn(d),c.forEach(l);return}if(!tf.has(u)){Qn(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}if(/rich-code-wrap/.test(b)){Array.from(d.attributes).forEach(f=>{f.name.toLowerCase()!=="class"&&d.removeAttribute(f.name)}),d.className="rich-code-wrap",c.forEach(l);return}if(/rich-code-header/.test(b)){Array.from(d.attributes).forEach(f=>{const p=f.name.toLowerCase();p!=="class"&&p!=="contenteditable"&&d.removeAttribute(f.name)}),d.className="rich-code-header",d.setAttribute("contenteditable","false"),c.forEach(l);return}}if(u==="button"){if(d.closest(".rich-code-wrap")&&d.getAttribute("data-action")==="copy-code"){Array.from(d.attributes).forEach(f=>{const p=f.name.toLowerCase();["type","class","data-action","title","aria-label"].includes(p)||d.removeAttribute(f.name)}),d.setAttribute("type","button"),d.className="rich-code-copy",d.setAttribute("data-action","copy-code");return}d.remove();return}if(u==="pre"){Array.from(d.attributes).forEach(b=>{b.name.toLowerCase()!=="class"&&d.removeAttribute(b.name)}),d.classList.contains("rich-code-block")||d.classList.add("rich-code-block"),c.forEach(l);return}if(u==="code"){Array.from(d.attributes).forEach(b=>{d.removeAttribute(b.name)}),c.forEach(l);return}const h=bf(u);if(h!==u){const b=d.ownerDocument.createElement(h);for(;d.firstChild;)b.appendChild(d.firstChild);d.replaceWith(b),l(b);return}if(Uu.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(),p=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(p)){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){Qn(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"){Qn(d),c.forEach(l);return}}c.forEach(l)};return l(o),o.querySelectorAll("pre").forEach(i=>{if(i.closest(".rich-code-wrap"))return;const c=i.textContent??"",d=a.createElement("div");d.innerHTML=yo(c,!1);const u=d.querySelector(".rich-code-wrap");u&&i.replaceWith(u)}),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(h=>h.nodeType===Node.TEXT_NODE||h.nodeType===Node.ELEMENT_NODE&&h.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(/&nbsp;/gi," ").replace(/(<br\s*\/?>\s*){3,}/gi,"<br><br>").replace(/<p>(?:\s|<br\s*\/?>)*<\/p>/gi,"").trim()},vo=e=>Hr(e).replace(/\r\n?/g,`
32
- `).split(/\n{2,}/).map(r=>`<p>${r.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),yo=(e,r=!0)=>ul(e,Hr,r),ln=e=>{const r=e.replace(/\r\n?/g,`
33
- `);if(!/```/.test(r))return vo(e);const n=[],a=/```(?:[\w-]*\n)?([\s\S]*?)```/g;let o=0,l;for(;(l=a.exec(r))!==null;)l.index>o&&n.push(vo(r.slice(o,l.index))),n.push(yo(l[1]??"")),o=a.lastIndex;return o<r.length&&n.push(vo(r.slice(o))),n.join("")},kl=/```[\s\S]+?```/,mf=e=>{const r=(e.textContent??"").replace(/\u00a0/g," ");if(!e.querySelector(".rich-code-wrap")&&r.includes("```")&&kl.test(r)){const o=ln(r);if(o.includes("rich-code-wrap"))return e.innerHTML=o,!0}let n=!1;const a=Array.from(e.children).filter(o=>o instanceof HTMLElement&&!o.classList.contains("rich-code-wrap"));for(const o of a){if(o.closest(".rich-code-wrap"))continue;const l=(o.textContent??"").replace(/\u00a0/g," ");if(!l.includes("```")||!kl.test(l))continue;const i=ln(l);if(!i.includes("rich-code-wrap"))continue;const c=document.createElement("div");c.innerHTML=i;const d=o.parentNode;if(d){for(;c.firstChild;)d.insertBefore(c.firstChild,o);o.remove(),n=!0}}return n},pf=e=>new RegExp("\\p{L}","u").test(e),xo=(e,r)=>{const n=e.trim();return!n||!pf(n)?!1:r==="uppercase"?n===n.toLocaleUpperCase():r==="lowercase"?n===n.toLocaleLowerCase():n===wl(n)},Sl=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",xl())}(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 Cl({value:e,onChange:r,placeholder:n="Escribe algo...",minHeight:a="80px",instanceId:o,toolbarVariant:l="full",focusModalZIndex:i=1e3}){const c=s.useId(),d=o||c,u=s.useCallback(()=>document,[]),h=s.useRef(null),b=s.useRef(null),f=s.useRef(new Map),p=s.useRef(null),v=s.useRef(!1),w=s.useRef(e??""),g=s.useRef(r),A=s.useRef(()=>{}),C=s.useRef(!1),[T,H]=s.useState(()=>!e||e.trim()===""),[E,x]=s.useState(new Set),[M,k]=s.useState(null),[_,q]=s.useState(""),[X,D]=s.useState(""),[K,j]=s.useState(""),[le,Q]=s.useState(""),[fe,F]=s.useState(3),[V,ae]=s.useState(3),[$,P]=s.useState(!0),[ce,O]=s.useState(!1),[oe,G]=s.useState(l==="full"),[U,se]=s.useState(null),[S,R]=s.useState(null),ee=s.useRef(null),J=s.useRef(!1),y=s.useRef(null),N=s.useCallback(()=>v.current?b.current:h.current,[]);s.useEffect(()=>{g.current=r},[r]);const te=s.useCallback(()=>{const B=window.getSelection(),Y=N();if(!B||!Y||B.rangeCount===0||B.isCollapsed)return"";const me=B.getRangeAt(0);return!Y.contains(me.startContainer)||!Y.contains(me.endContainer)?"":B.toString()},[N]);s.useEffect(()=>{const B=e??"";if(C.current&&B===w.current){C.current=!1,H(!B||B.trim()==="");return}C.current=!1,w.current=B;const Y=[h.current,b.current].filter(be=>!!be);Y.forEach(be=>{be.innerHTML!==B&&(be.innerHTML=B)}),H(!B||B.trim()===""),Y.forEach(be=>go(be));const me=Y.map(be=>Sl(be));return()=>me.forEach(be=>be())},[e]),s.useEffect(()=>{var be,xe;v.current=ce;let B,Y=0,me;if(ce){const we=h.current;we&&(w.current=Xn(we));const He=()=>{var dt;const Oe=b.current;if(!Oe){Y=requestAnimationFrame(He);return}Oe.innerHTML!==w.current&&(Oe.innerHTML=w.current),B=Sl(Oe),go(Oe),H(((dt=Oe.textContent)==null?void 0:dt.trim())===""),me=setTimeout(()=>Oe.focus(),60)};Y=requestAnimationFrame(He)}else{const we=b.current,He=h.current,Oe=we?Xn(we):w.current,dt=w.current;w.current=Oe,He&&He.innerHTML!==Oe&&(He.innerHTML=Oe),Oe!==dt&&g.current(Oe),H(((xe=(be=we??He)==null?void 0:be.textContent)==null?void 0:xe.trim())==="")}return()=>{Y&&cancelAnimationFrame(Y),me&&clearTimeout(me),B==null||B()}},[ce]);const ue=s.useCallback(()=>{const B=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],Y=new Set;B.forEach(be=>{try{u().queryCommandState(be)&&Y.add(be)}catch{return}});try{const be=ef(u().queryCommandValue("formatBlock"));be&&Y.add(`formatBlock:${be}`)}catch{}const me=te();xo(me,"uppercase")&&Y.add("__upper"),xo(me,"lowercase")&&Y.add("__lower"),xo(me,"capitalize")&&Y.add("__cap");try{const be=window.getSelection();let xe=(be==null?void 0:be.anchorNode)??null;(xe==null?void 0:xe.nodeType)===Node.TEXT_NODE&&(xe=xe.parentElement),xe instanceof Element&&xe.closest(".rich-code-wrap")&&Y.add("__code")}catch{}x(Y)},[te,u]),re=()=>{var Y;const B=N();B&&(mf(B),w.current=Xn(B),C.current=!0,g.current(w.current),H(((Y=B.textContent)==null?void 0:Y.trim())===""))};A.current=re;const ge=s.useCallback(()=>{y.current&&(clearTimeout(y.current),y.current=null),ee.current&&(hl(ee.current),ee.current=null),J.current=!1,se(null),R(null)},[]),Se=s.useCallback(()=>{y.current&&(clearTimeout(y.current),y.current=null)},[]),$e=s.useCallback(()=>{Se(),y.current=setTimeout(()=>{J.current||ge()},280)},[Se,ge]);s.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]);const ht=s.useCallback(B=>{const Y=ee.current;if(!Y||!Y.isConnected){ge();return}const me=(U==null?void 0:U.rowIndex)??(S==null?void 0:S.rowIndex)??-1,be=(U==null?void 0:U.colIndex)??(S==null?void 0:S.colIndex)??-1;Ku(B,Y,me,be,N()),ge(),A.current(),ue()},[N,ge,ue,S,U]),Ct=s.useCallback(B=>{if(S)return;const Y=B.currentTarget,me=B.target;if(me.closest(".rich-table-action-bar, .rich-table-context-menu")){Se();return}const be=me.closest("td, th");if(!be||!Y.contains(be)){$e();return}const xe=be.closest("tr"),we=be.closest("table");if(!xe||!we||!Y.contains(we)){$e();return}Se(),we.classList.add("rich-table"),ee.current=we,ml(we,xe,be.cellIndex),se(Yu(we,xe,be))},[Se,$e,S]),rt=s.useCallback(B=>{const Y=B.relatedTarget;if(Y instanceof Element&&(Y.closest(".rich-table-action-bar")||Y.closest(".rich-table-context-menu"))){Se();return}$e()},[Se,$e]),at=s.useCallback(B=>{const Y=B.currentTarget,be=B.target.closest("td, th");if(!be||!Y.contains(be))return;const xe=be.closest("tr"),we=be.closest("table");if(!xe||!we||!Y.contains(we))return;B.preventDefault(),we.classList.add("rich-table"),ee.current=we;const He=Array.from(we.rows).indexOf(xe),Oe=be.cellIndex;ml(we,xe,Oe),se(null),R({x:B.clientX,y:B.clientY,rowIndex:He,colIndex:Oe})},[]);s.useEffect(()=>{if(!U&&!S)return;const B=()=>$e();return window.addEventListener("scroll",B,!0),window.addEventListener("resize",B),()=>{window.removeEventListener("scroll",B,!0),window.removeEventListener("resize",B)}},[$e,S,U]),s.useEffect(()=>{if(!S)return;const B=Y=>{const me=Y.target;me instanceof Element&&me.closest(".rich-table-context-menu")||R(null)};return window.addEventListener("mousedown",B),()=>window.removeEventListener("mousedown",B)},[S]);const de=B=>{if(!B){const Y=h.current;Y&&(w.current=Xn(Y))}O(!B)},Ee=(B,Y)=>{var me;(me=N())==null||me.focus(),u().execCommand(B,!1,Y),re(),ue()},ne=B=>{Ee("formatBlock",B)},De=()=>{var B;(B=N())==null||B.focus(),u().execCommand("insertHTML",!1,"<hr><p><br></p>"),re(),ue()},Be=()=>{const B=window.getSelection();B&&B.rangeCount>0&&(p.current=B.getRangeAt(0).cloneRange())},Ue=()=>{const B=window.getSelection();B&&p.current&&(B.removeAllRanges(),B.addRange(p.current))},je=B=>{if(Be(),B==="link"){const Y=window.getSelection();D(Y&&!Y.isCollapsed?Y.toString():""),q("")}B==="image"&&(j(""),Q("")),B==="table"&&(F(3),ae(3),P(!0)),k(B)},Fe=()=>{var be;if(!_.trim())return;Ue(),(be=N())==null||be.focus();const B=window.getSelection(),me=(B&&!B.isCollapsed?B.toString():"")||X.trim()||_.trim();u().execCommand("insertHTML",!1,`<a href="${Hr(_.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${Hr(me)}</a>`),re(),k(null)},Qe=(B,Y="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${Hr(B)}" alt="${Hr(Y)}" class="rich-img" />${xl()}</span>`,ot=()=>{var B;K.trim()&&(Ue(),(B=N())==null||B.focus(),u().execCommand("insertHTML",!1,Qe(K.trim(),le.trim())),re(),k(null))},Et=()=>{var B;Ue(),(B=N())==null||B.focus(),u().execCommand("insertHTML",!1,Ru(fe,V,$)),re(),k(null)},he=()=>{var me;Ue(),(me=N())==null||me.focus();const B=window.getSelection(),Y=B&&!B.isCollapsed?B.toString():"";u().execCommand("insertHTML",!1,yo(Y)),re()},ve=(B,Y=1200,me=1200,be=.72)=>new Promise((xe,we)=>{const He=new FileReader;He.onerror=we,He.onload=Oe=>{var ir;const dt=(ir=Oe.target)==null?void 0:ir.result,Je=new Image;Je.onerror=we,Je.onload=()=>{let{width:gt,height:$t}=Je;if(gt>Y||$t>me){const qt=Math.min(Y/gt,me/$t);gt=Math.round(gt*qt),$t=Math.round($t*qt)}const It=document.createElement("canvas");It.width=gt,It.height=$t;const Qt=It.getContext("2d");if(!Qt){xe(dt);return}Qt.drawImage(Je,0,0,gt,$t),xe(It.toDataURL("image/jpeg",be))},Je.src=dt},He.readAsDataURL(B)}),Ie=B=>{B.focus();const Y=window.getSelection();if(!Y||Y.rangeCount===0||!B.contains(Y.anchorNode)){const me=document.createRange();me.selectNodeContents(B),me.collapse(!1),Y==null||Y.removeAllRanges(),Y==null||Y.addRange(me)}},_e=s.useRef(()=>{});_e.current=B=>{const Y=N();Y&&(Ie(Y),u().execCommand("insertHTML",!1,B),go(Y),Y.querySelectorAll("p").forEach(me=>{!(me.textContent??"").replace(/[\u00a0\s]+/g,"")&&!me.querySelector("img, hr, table")&&me.remove()}),re(),ue())};const Pe=s.useRef(ve);Pe.current=ve;const ft=s.useRef(Qe);ft.current=Qe;const st=s.useCallback(B=>{if(!B||f.current.has(B))return;const Y=me=>{const be=me.clipboardData;if(!be)return;const xe=be.getData("text/html"),we=be.getData("text/plain");if(xe||we){me.preventDefault(),me.stopPropagation();try{const Je=xe?hf(xe):ln(we);if(!Je){we&&_e.current(ln(we));return}_e.current(Je)}catch{we&&_e.current(ln(we))}return}const Oe=Array.from(be.items).find(Je=>Je.type.startsWith("image/"));if(!Oe)return;me.preventDefault(),me.stopPropagation();const dt=Oe.getAsFile();dt&&Pe.current(dt).then(Je=>{_e.current(ft.current(Je,"imagen"))})};B.addEventListener("paste",Y,!0),f.current.set(B,()=>{B.removeEventListener("paste",Y,!0),f.current.delete(B)})},[]),Ve=s.useCallback(B=>{var me;const Y=h.current;Y&&Y!==B&&((me=f.current.get(Y))==null||me()),h.current=B,B&&st(B)},[st]),Re=s.useCallback(B=>{var me;const Y=b.current;Y&&Y!==B&&((me=f.current.get(Y))==null||me()),b.current=B,B&&st(B)},[st]);s.useEffect(()=>{const B=f.current;return()=>{B.forEach(Y=>Y()),B.clear()}},[]);const ct=B=>{const Y=window.getSelection(),me=N();if(!Y||!me||Y.rangeCount===0||Y.isCollapsed)return;const be=Y.getRangeAt(0);if(!me.contains(be.startContainer)||!me.contains(be.endContainer))return;const xe=be.toString();if(!xe)return;let we=xe;B==="uppercase"?we=xe.toLocaleUpperCase():B==="lowercase"?we=xe.toLocaleLowerCase():we=wl(xe),be.deleteContents();const He=document.createTextNode(we);be.insertNode(He);const Oe=document.createRange();Oe.setStart(He,0),Oe.setEnd(He,we.length),Y.removeAllRanges(),Y.addRange(Oe),p.current=Oe.cloneRange(),re(),ue()},lt=()=>{Be(),ue()},mr=()=>{const B=N();B&&pl(B),re(),ue()},Zt=()=>{requestAnimationFrame(()=>{var B;(B=N())==null||B.focus()})},pr=B=>{var Y,me;if((B.metaKey||B.ctrlKey)&&B.key==="Enter"){if(B.preventDefault(),B.stopPropagation(),B.repeat)return;(Y=N())==null||Y.focus(),u().execCommand("insertLineBreak",!1)||u().execCommand("insertHTML",!1,"<br>"),re(),ue();return}if(B.key==="Tab"){const be=window.getSelection(),xe=vl((be==null?void 0:be.anchorNode)??null),we=N(),He=gl(xe);if(xe&&He&&(we!=null&&we.contains(xe))){B.preventDefault();const Oe=Zu(He),dt=Oe.indexOf(xe),Je=dt>=0?Oe[dt+1]:null;if(Je)Kn(Je,we,!0);else if(yl(xe,He)){const ir=po(He);ir&&Kn(ir,we,!0)}re(),ue();return}B.preventDefault(),(me=N())==null||me.focus(),u().execCommand("insertText",!1,"    "),re(),ue();return}if(B.key==="Enter"&&!B.shiftKey&&!(B.metaKey||B.ctrlKey)){const be=window.getSelection(),xe=vl((be==null?void 0:be.anchorNode)??null),we=N(),He=gl(xe);if(xe&&He&&(we!=null&&we.contains(xe))&&yl(xe,He)&&Qu(xe)){B.preventDefault();const Oe=po(He);Oe&&Kn(Oe,we,!0),re(),ue();return}}if(B.key==="Escape"){if(S){R(null);return}if(M){k(null);return}if(v.current){O(!1);return}}M||(B.ctrlKey||B.metaKey)&&(B.key==="b"&&(B.preventDefault(),Ee("bold")),B.key==="i"&&(B.preventDefault(),Ee("italic")),B.key==="u"&&(B.preventDefault(),Ee("underline")),B.key==="k"&&(B.preventDefault(),je("link")))},Mt=()=>t.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),We=(B,Y,me,be,xe)=>{const we=xe??(E.has(me)||me==="__link"&&M==="link"||me==="__img"&&M==="image"||me==="__table"&&M==="table");return t.jsx("button",{type:"button",title:Y,tabIndex:-1,onFocus:Zt,onMouseDown:He=>{He.preventDefault(),be?be():Ee(me)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:we?"var(--primary)":"var(--text-secondary)",background:we?"rgba(59,130,246,0.12)":"transparent"},children:B},me)},bt=B=>{const Y=B.target;if(Y.closest("[data-action='delete-img']")){B.preventDefault();const be=Y.closest(".rich-img-wrap");be&&(be.remove(),re());return}const me=Y.closest("[data-action='copy-code']");me instanceof HTMLButtonElement&&(B.preventDefault(),cl(me).catch(()=>{}))},lr=()=>{Se(),J.current=!0},Tt=()=>{J.current=!1,$e()},Bt=(B,Y,me,be=!1)=>t.jsx("button",{type:"button",className:`rich-table-action-btn${be?" rich-table-action-btn--danger":""}`,title:B,"aria-label":B,onMouseDown:xe=>{xe.preventDefault(),xe.stopPropagation(),ht(me)},children:Y}),vn=()=>typeof document>"u"||!U&&!S?null:mt.createPortal(t.jsxs(t.Fragment,{children:[U&&!S&&t.jsxs("div",{className:"rich-table-action-bar",style:{left:U.bar.x,top:U.bar.y},onMouseEnter:lr,onMouseLeave:Tt,children:[t.jsxs("span",{className:"rich-table-action-hint",children:["Fila ",U.rowIndex+1," · Col ",U.colIndex+1]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Fila"}),Bt("Añadir fila abajo","+","table-row-add"),Bt("Eliminar fila","−","table-row-del")]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Columna"}),Bt("Añadir columna a la derecha","+","table-col-add"),Bt("Eliminar columna","−","table-col-del")]}),Bt("Eliminar tabla","Eliminar","table-delete",!0)]}),S&&t.jsx("div",{className:"rich-table-context-menu",style:{left:S.x,top:S.y},onMouseDown:B=>B.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(([B,Y])=>t.jsx("button",{type:"button",onMouseDown:me=>{me.preventDefault(),ht(Y)},children:B},Y))})]}),document.body),yn=B=>t.jsxs(t.Fragment,{children:[M==="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:B},children:[t.jsx("input",{autoFocus:!0,type:"url",value:_,onChange:Y=>q(Y.target.value),onKeyDown:Y=>{Y.key==="Enter"&&(Y.preventDefault(),Fe()),Y.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:X,onChange:Y=>D(Y.target.value),onKeyDown:Y=>{Y.key==="Enter"&&(Y.preventDefault(),Fe()),Y.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:Fe,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"})]}),M==="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:B},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:Or,value:fe,onChange:Y=>F(Un(Number(Y.target.value),1,Or)),onKeyDown:Y=>{Y.key==="Enter"&&(Y.preventDefault(),Et()),Y.key==="Escape"&&k(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:Vn,value:V,onChange:Y=>ae(Un(Number(Y.target.value),1,Vn)),onKeyDown:Y=>{Y.key==="Enter"&&(Y.preventDefault(),Et()),Y.key==="Escape"&&k(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:$,onChange:Y=>P(Y.target.checked)}),"Encabezado"]}),t.jsx("button",{type:"button",onClick:Et,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"})]}),M==="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:B},children:[t.jsx("input",{autoFocus:!0,type:"url",value:K,onChange:Y=>j(Y.target.value),onKeyDown:Y=>{Y.key==="Enter"&&(Y.preventDefault(),ot()),Y.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:le,onChange:Y=>Q(Y.target.value),onKeyDown:Y=>{Y.key==="Enter"&&(Y.preventDefault(),ot()),Y.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:ot,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"})]})]}),ha=(B,Y)=>{const me=l==="compact",be=!me||oe||B;return 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:Y},"data-toolbar-variant":l,children:[me&&!B&&t.jsxs("button",{type:"button",title:oe?"Ocultar herramientas":"Mostrar herramientas de formato",tabIndex:-1,onFocus:Zt,onMouseDown:xe=>{xe.preventDefault(),G(we=>!we)},className:"flex h-7 items-center gap-1 rounded px-1.5 text-[10px] font-semibold transition-colors",style:{color:"var(--text-secondary)",background:oe?"color-mix(in srgb, var(--primary) 12%, transparent)":"transparent"},children:[oe?t.jsx(W.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(W.HiChevronDown,{className:"h-3.5 w-3.5"}),oe?"Ocultar herramientas":"Herramientas"]}),be&&t.jsxs(t.Fragment,{children:[We(t.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),We(t.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),We(t.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),We(t.jsx(W.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),We(t.jsx(W.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),We(t.jsx(W.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>je("link")),Mt(),We(t.jsx(W.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),We(t.jsx(W.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),Mt(),We(t.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>ne("p"),E.has("formatBlock:p")||E.has("formatBlock:div")),We(t.jsx(W.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>ne("h2"),E.has("formatBlock:h2")),We(t.jsx(W.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>ne("h3"),E.has("formatBlock:h3")),We(t.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>ne("blockquote"),E.has("formatBlock:blockquote")),We(t.jsx("span",{style:{fontFamily:"ui-monospace, monospace",fontSize:"10px"},children:"</>"}),"Bloque de código","__code",()=>he(),E.has("__code")),Mt(),We(t.jsx("s",{children:"S"}),"Tachado","strikeThrough"),Mt(),We(t.jsx(W.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),We(t.jsx(W.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),Mt(),We(t.jsx(W.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),We(t.jsx(W.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),We(t.jsx(W.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),We(t.jsx(W.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),Mt(),We(t.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>ct("uppercase")),We(t.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>ct("lowercase")),We(t.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>ct("capitalize")),Mt(),We(t.jsx(W.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),We(t.jsx(W.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>je("image")),We(t.jsx(W.HiTableCells,{className:"h-4 w-4"}),"Insertar tabla","__table",()=>je("table")),We(t.jsx(W.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",De),Mt(),We(t.jsx(W.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),We(t.jsx(W.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>ne("p"))]}),Mt(),t.jsx("button",{type:"button",title:B?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:Zt,onMouseDown:xe=>{xe.preventDefault(),de(B)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:B?t.jsx(W.HiArrowsPointingIn,{className:"h-4 w-4"}):t.jsx(W.HiArrowsPointingOut,{className:"h-4 w-4"})})]})};return t.jsxs(t.Fragment,{children:[vn(),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:Ve,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":d,onInput:mr,onKeyDown:pr,onKeyUp:lt,onSelect:lt,onMouseUp:lt,onMouseMove:Ct,onMouseLeave:rt,onContextMenu:at,onMouseDown:bt,"data-placeholder":n,className:`rich-editor px-3 py-2 text-sm focus:outline-none${T?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:a,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),yn("var(--bg-input)"),ha(!1,"var(--bg-input)")]}),t.jsxs(Ra,{open:ce,onClose:()=>O(!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]",zIndex:i,children:[t.jsx("div",{ref:Re,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":d,onInput:mr,onKeyDown:pr,onKeyUp:lt,onSelect:lt,onMouseUp:lt,onMouseMove:Ct,onMouseLeave:rt,onContextMenu:at,onMouseDown:bt,"data-placeholder":n,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${T?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),yn("var(--bg-input)"),ha(!0,"var(--bg-input)")]})]})}const El="[a-zA-Z0-9._@-]+",wo=new RegExp(`@(${El})`,"g"),gf=/[a-zA-Z0-9._@-]/,cn=new Set([" ",`
34
- `," ","\r"," ","(","[","{",".",",",";",":","!","?","¿","¡",")","]","}",'"',"'","«","»","/","\\","|","-","—","–"]);function Ml(e,r){if(r<=0)return!0;const n=e[r-1]??"";return cn.has(n)}function Tl(e,r,n){var a;if(r<0||r>e.length)return null;for(let o=r-1;o>=0;o-=1){if(e[o]!=="@"){const c=e[o]??"";if(cn.has(c)||!gf.test(c))return null;continue}if((a=n==null?void 0:n.isInsideExistingMention)!=null&&a.call(n,o)||!(n!=null&&n.isTriggerBoundary?n.isTriggerBoundary(o):Ml(e,o)))continue;const i=e.slice(o+1,r);return i.length>0&&!new RegExp(`^${El}$`).test(i)?null:{query:i,triggerIndex:o,caretIndex:r}}return null}function $l(e,r){var a;const n=Br(e,r);return n?!!((a=n.node.parentElement)!=null&&a.closest(".mention-chip")):!1}function Al(e,r){if(r<=0)return!0;const n=Br(e,r);if(!n){const o=To(e);return Ml(o,r)}if(n.offset>0){const o=n.node.data[n.offset-1]??"";return cn.has(o)}let a=n.node.previousSibling;for(;a;){if(a.nodeType===Node.TEXT_NODE){const o=a.textContent??"";if(o.length===0){a=a.previousSibling;continue}return cn.has(o[o.length-1]??"")}if(a.nodeType===Node.ELEMENT_NODE){const o=a;if(o.classList.contains("mention-chip")||o.tagName==="BR"||/^(P|DIV|LI|H[1-6]|BLOCKQUOTE)$/i.test(o.tagName))return!0;const l=o.textContent??"";if(l.length===0){a=a.previousSibling;continue}return cn.has(l[l.length-1]??"")}a=a.previousSibling}return!0}function No(e,r){const n=To(e);return Tl(n,r,{isTriggerBoundary:a=>Al(e,a),isInsideExistingMention:a=>$l(e,a)})}function ko(e){return e.toLowerCase().trim()}function Ll(e){return e?e.replace(/<style[^>]*>[\s\S]*?<\/style>/gi," ").replace(/<script[^>]*>[\s\S]*?<\/script>/gi," ").replace(/<br\s*\/?>/gi,`
30
+ `).replace(/^\n+/,"").replace(/\n+$/,"")}async function yl(e){const r=e.closest(".rich-code-wrap"),n=r==null?void 0:r.querySelector("pre"),a=(n==null?void 0:n.querySelector("code"))??n,o=a?vl(a):"";if(!o.trim())throw new Error("empty_code_block");await lo(o),xl(e)}function xl(e,r=2e3){e.setAttribute("data-copied","true"),e.title="Copiado",e.setAttribute("aria-label","Copiado"),window.setTimeout(()=>{e.removeAttribute("data-copied"),e.title="Copiar",e.setAttribute("aria-label","Copiar")},r)}function wl(e,r,n=!0){const a=e.replace(/\r\n?/g,`
31
+ `),o=r(a).replace(/\n/g,"<br>")||"<br>",l=`<div class="rich-code-wrap"><div class="rich-code-header" contenteditable="false"><span class="rich-code-label">Código</span>${gl()}</div><pre class="rich-code-block"><code>${o}</code></pre></div>`;return n?`${l}<p><br></p>`:l}const tf=new Set(["table","thead","tbody","tfoot","tr","th","td","caption"]),Rn=(e,r,n)=>Math.min(n,Math.max(r,Math.round(e)||r)),Fr=12,ea=8,So=(e,r,n)=>{const a=ra(n),o=e.insertRow(r);for(let l=0;l<a;l+=1){const i=o.insertCell(-1);i.innerHTML="<br>"}return o.cells[0]??null},Nl=(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>=Fr?null:So(l,0,e)}if(a.tagName==="TBODY"&&a.rows.length>=Fr)return null;const o=Array.from(a.rows).indexOf(n);return So(a,o+1,e)},rf=(e,r)=>{var o;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"&&((o=e.tBodies[0])==null?void 0:o.rows.length)===0&&e.rows.length<=1?!1:(n.remove(),!0)},kl=(e,r)=>ra(e)>=ea?!1:(e.querySelectorAll("tr").forEach(n=>{const a=n.closest("thead")!==null,o=document.createElement(a?"th":"td");a?o.textContent=`Columna ${n.cells.length+1}`:o.innerHTML="<br>";const l=n.cells[r];l!=null&&l.nextSibling?n.insertBefore(o,l.nextSibling):n.appendChild(o)}),!0),nf=(e,r)=>ra(e)<=1?!1:(e.querySelectorAll("tr").forEach(n=>{var a;(a=n.cells[r])==null||a.remove()}),!0),Cl=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")})},Sl=(e,r,n)=>{Cl(e),r&&(r.classList.add("rich-table-row-active"),e.querySelectorAll("tr").forEach(a=>{var o;(o=a.cells[n])==null||o.classList.add("rich-table-col-active")}))},af=(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}}},ta=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},El=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")})},of=(e,r,n,a,o)=>{switch(e){case"table-delete":return r.remove(),!0;case"table-row-add":{const l=Number.isFinite(n)?Nl(r,n):Eo(r);return l&&na(l,o,!0),!!l}case"table-row-del":return Number.isFinite(n)?rf(r,n):!1;case"table-col-add":return Number.isFinite(a)?kl(r,a):df(r);case"table-col-del":return Number.isFinite(a)?nf(r,a):!1;default:return!1}},ra=e=>{let r=0;return e.querySelectorAll("tr").forEach(n=>{r=Math.max(r,n.cells.length)}),r||1},sf=e=>{const r=e.tBodies[0]??e.createTBody();return Array.from(r.rows)},Ml=e=>(e==null?void 0:e.closest("table"))??null,Tl=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},lf=e=>Array.from(e.querySelectorAll("th, td")),$l=(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),o=e.closest("tr");return!o||o!==a[a.length-1]?!1:e===o.cells[o.cells.length-1]},cf=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()===""},na=(e,r,n=!0)=>{r==null||r.focus();const a=document.createRange();a.selectNodeContents(e),a.collapse(n);const o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(a)},Eo=e=>{const r=sf(e);if(r.length>=Fr)return null;const n=r[r.length-1];if(!n){const a=e.tBodies[0]??e.createTBody();return So(a,0,e)}return Nl(e,Array.from(e.rows).indexOf(n))},df=e=>{const r=ra(e)-1;return r<0?!1:kl(e,r)},Mo=e=>{El(e)},uf=(e,r,n)=>{const a=Rn(e,1,Fr),o=Rn(r,1,ea),l=n?`<thead><tr>${Array.from({length:o},(c,d)=>`<th>Columna ${d+1}</th>`).join("")}</tr></thead>`:"",i=Array.from({length:a},()=>`<tr>${Array.from({length:o},()=>"<td><br></td>").join("")}</tr>`).join("");return`<table class="rich-table">${l}<tbody>${i}</tbody></table><p><br></p>`},Al=()=>'<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>',_r=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),Ll=e=>e.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(r,n,a)=>`${n}${a.toLocaleUpperCase()}`),ff=e=>e.replace(/[<>]/g,"").toLowerCase(),bf=new Set(["p","br","div","span","b","strong","i","em","u","s","strike","ul","ol","li","h1","h2","h3","h4","blockquote","pre","code","button","a","img","hr","table","thead","tbody","tfoot","tr","th","td","caption"]),hf=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,mf=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},aa=(e,r)=>r.test(e),pf=e=>aa(e,/font-weight\s*:\s*(bold|[6-9]00)/i),gf=e=>aa(e,/font-style\s*:\s*italic/i),vf=e=>aa(e,/text-decoration(?:-line)?\s*:[^;]*underline/i),yf=e=>aa(e,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),oa=(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)},sa=e=>{const r=e.parentNode;if(!r){e.remove();return}for(;e.firstChild;)r.insertBefore(e.firstChild,e);r.removeChild(e)},xf=e=>{const r=e.getAttribute("class")??"",n=e.getAttribute("style")??"";return/mso-list/i.test(n)||/MsoListParagraph/i.test(r)||/MsoList/i.test(r)},Dl=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"},wf=e=>{const n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT).nextNode();if(!n||!n.textContent)return;const a=n.textContent.replace(hf,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");a!==n.textContent&&(n.textContent=a)},Nf=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&&(pf(a)&&oa(n,"strong"),gf(a)&&oa(n,"em"),vf(a)&&oa(n,"u"),yf(a)&&oa(n,"s"))})},kf=e=>{const r=Array.from(e.querySelectorAll("p, div")).filter(xf);if(!r.length)return;let n=0;for(;n<r.length;){const a=r[n],o=Dl(a),l=[a];let i=n+1;for(;i<r.length;){const u=r[i];if(Dl(u)!==o)break;let h=l[l.length-1].nextSibling;for(;h&&h.nodeType===Node.TEXT_NODE&&!(h.textContent??"").trim();)h=h.nextSibling;if(h!==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=>{wf(u);const h=u.ownerDocument.createElement("li");for(;u.firstChild;)h.appendChild(u.firstChild);d.appendChild(h),u.remove()}),n=i}},Cf=e=>e==="h1"?"h2":e==="h4"||e==="h5"||e==="h6"?"h3":e==="div"?"p":e,Sf=e=>{const r=mf(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,"")),a=new DOMParser().parseFromString(`<!DOCTYPE html><html><body>${r}</body></html>`,"text/html"),o=a.body;o.querySelectorAll("script, style, meta, link, xml, title, head, iframe, object, embed, form, input, textarea, select, noscript").forEach(i=>i.remove()),Nf(o),kf(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"){sa(d),c.forEach(l);return}if(!bf.has(u)){sa(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}if(/rich-code-wrap/.test(b)){Array.from(d.attributes).forEach(f=>{f.name.toLowerCase()!=="class"&&d.removeAttribute(f.name)}),d.className="rich-code-wrap",c.forEach(l);return}if(/rich-code-header/.test(b)){Array.from(d.attributes).forEach(f=>{const p=f.name.toLowerCase();p!=="class"&&p!=="contenteditable"&&d.removeAttribute(f.name)}),d.className="rich-code-header",d.setAttribute("contenteditable","false"),c.forEach(l);return}}if(u==="button"){if(d.closest(".rich-code-wrap")&&d.getAttribute("data-action")==="copy-code"){Array.from(d.attributes).forEach(f=>{const p=f.name.toLowerCase();["type","class","data-action","title","aria-label"].includes(p)||d.removeAttribute(f.name)}),d.setAttribute("type","button"),d.className="rich-code-copy",d.setAttribute("data-action","copy-code");return}d.remove();return}if(u==="pre"){Array.from(d.attributes).forEach(b=>{b.name.toLowerCase()!=="class"&&d.removeAttribute(b.name)}),d.classList.contains("rich-code-block")||d.classList.add("rich-code-block"),c.forEach(l);return}if(u==="code"){Array.from(d.attributes).forEach(b=>{d.removeAttribute(b.name)}),c.forEach(l);return}const h=Cf(u);if(h!==u){const b=d.ownerDocument.createElement(h);for(;d.firstChild;)b.appendChild(d.firstChild);d.replaceWith(b),l(b);return}if(tf.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(),p=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(p)){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){sa(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"){sa(d),c.forEach(l);return}}c.forEach(l)};return l(o),o.querySelectorAll("pre").forEach(i=>{if(i.closest(".rich-code-wrap"))return;const c=i.textContent??"",d=a.createElement("div");d.innerHTML=$o(c,!1);const u=d.querySelector(".rich-code-wrap");u&&i.replaceWith(u)}),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(h=>h.nodeType===Node.TEXT_NODE||h.nodeType===Node.ELEMENT_NODE&&h.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(/&nbsp;/gi," ").replace(/(<br\s*\/?>\s*){3,}/gi,"<br><br>").replace(/<p>(?:\s|<br\s*\/?>)*<\/p>/gi,"").trim()},To=e=>_r(e).replace(/\r\n?/g,`
32
+ `).split(/\n{2,}/).map(r=>`<p>${r.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),$o=(e,r=!0)=>wl(e,_r,r),gn=e=>{const r=e.replace(/\r\n?/g,`
33
+ `);if(!/```/.test(r))return To(e);const n=[],a=/```(?:[\w-]*\n)?([\s\S]*?)```/g;let o=0,l;for(;(l=a.exec(r))!==null;)l.index>o&&n.push(To(r.slice(o,l.index))),n.push($o(l[1]??"")),o=a.lastIndex;return o<r.length&&n.push(To(r.slice(o))),n.join("")},Ol=/```[\s\S]+?```/,Ef=e=>{const r=(e.textContent??"").replace(/\u00a0/g," ");if(!e.querySelector(".rich-code-wrap")&&r.includes("```")&&Ol.test(r)){const o=gn(r);if(o.includes("rich-code-wrap"))return e.innerHTML=o,!0}let n=!1;const a=Array.from(e.children).filter(o=>o instanceof HTMLElement&&!o.classList.contains("rich-code-wrap"));for(const o of a){if(o.closest(".rich-code-wrap"))continue;const l=(o.textContent??"").replace(/\u00a0/g," ");if(!l.includes("```")||!Ol.test(l))continue;const i=gn(l);if(!i.includes("rich-code-wrap"))continue;const c=document.createElement("div");c.innerHTML=i;const d=o.parentNode;if(d){for(;c.firstChild;)d.insertBefore(c.firstChild,o);o.remove(),n=!0}}return n},Mf=e=>new RegExp("\\p{L}","u").test(e),Ao=(e,r)=>{const n=e.trim();return!n||!Mf(n)?!1:r==="uppercase"?n===n.toLocaleUpperCase():r==="lowercase"?n===n.toLocaleLowerCase():n===Ll(n)},Hl=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",Al())}(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 Bl({value:e,onChange:r,placeholder:n="Escribe algo...",minHeight:a="80px",instanceId:o,toolbarVariant:l="full",focusModalZIndex:i=1e3}){const c=s.useId(),d=o||c,u=s.useCallback(()=>document,[]),h=s.useRef(null),b=s.useRef(null),f=s.useRef(new Map),p=s.useRef(null),g=s.useRef(!1),w=s.useRef(e??""),v=s.useRef(r),L=s.useRef(()=>{}),M=s.useRef(!1),[S,H]=s.useState(()=>!e||e.trim()===""),[C,y]=s.useState(new Set),[T,N]=s.useState(null),[_,q]=s.useState(""),[U,D]=s.useState(""),[K,j]=s.useState(""),[ie,Q]=s.useState(""),[fe,F]=s.useState(3),[Y,ae]=s.useState(3),[$,W]=s.useState(!0),[ce,B]=s.useState(!1),[oe,Z]=s.useState(l==="full"),[X,se]=s.useState(null),[E,J]=s.useState(null),ee=s.useRef(null),R=s.useRef(!1),x=s.useRef(null),k=s.useCallback(()=>g.current?b.current:h.current,[]);s.useEffect(()=>{v.current=r},[r]);const te=s.useCallback(()=>{const P=window.getSelection(),G=k();if(!P||!G||P.rangeCount===0||P.isCollapsed)return"";const pe=P.getRangeAt(0);return!G.contains(pe.startContainer)||!G.contains(pe.endContainer)?"":P.toString()},[k]);s.useEffect(()=>{const P=e??"";if(M.current&&P===w.current){M.current=!1,H(!P||P.trim()==="");return}M.current=!1,w.current=P;const G=[h.current,b.current].filter(me=>!!me);G.forEach(me=>{me.innerHTML!==P&&(me.innerHTML=P)}),H(!P||P.trim()===""),G.forEach(me=>Mo(me));const pe=G.map(me=>Hl(me));return()=>pe.forEach(me=>me())},[e]),s.useEffect(()=>{var me,Me;g.current=ce;let P,G=0,pe;if(ce){const ke=h.current;ke&&(w.current=ta(ke));const Ie=()=>{var ct;const Pe=b.current;if(!Pe){G=requestAnimationFrame(Ie);return}Pe.innerHTML!==w.current&&(Pe.innerHTML=w.current),P=Hl(Pe),Mo(Pe),H(((ct=Pe.textContent)==null?void 0:ct.trim())===""),pe=setTimeout(()=>Pe.focus(),60)};G=requestAnimationFrame(Ie)}else{const ke=b.current,Ie=h.current,Pe=ke?ta(ke):w.current,ct=w.current;w.current=Pe,Ie&&Ie.innerHTML!==Pe&&(Ie.innerHTML=Pe),Pe!==ct&&v.current(Pe),H(((Me=(me=ke??Ie)==null?void 0:me.textContent)==null?void 0:Me.trim())==="")}return()=>{G&&cancelAnimationFrame(G),pe&&clearTimeout(pe),P==null||P()}},[ce]);const de=s.useCallback(()=>{const P=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],G=new Set;P.forEach(me=>{try{u().queryCommandState(me)&&G.add(me)}catch{return}});try{const me=ff(u().queryCommandValue("formatBlock"));me&&G.add(`formatBlock:${me}`)}catch{}const pe=te();Ao(pe,"uppercase")&&G.add("__upper"),Ao(pe,"lowercase")&&G.add("__lower"),Ao(pe,"capitalize")&&G.add("__cap");try{const me=window.getSelection();let Me=(me==null?void 0:me.anchorNode)??null;(Me==null?void 0:Me.nodeType)===Node.TEXT_NODE&&(Me=Me.parentElement),Me instanceof Element&&Me.closest(".rich-code-wrap")&&G.add("__code")}catch{}y(G)},[te,u]),re=()=>{var G;const P=k();P&&(Ef(P),w.current=ta(P),M.current=!0,v.current(w.current),H(((G=P.textContent)==null?void 0:G.trim())===""))};L.current=re;const ge=s.useCallback(()=>{x.current&&(clearTimeout(x.current),x.current=null),ee.current&&(Cl(ee.current),ee.current=null),R.current=!1,se(null),J(null)},[]),Ee=s.useCallback(()=>{x.current&&(clearTimeout(x.current),x.current=null)},[]),Le=s.useCallback(()=>{Ee(),x.current=setTimeout(()=>{R.current||ge()},280)},[Ee,ge]);s.useEffect(()=>()=>{x.current&&clearTimeout(x.current)},[]);const gt=s.useCallback(P=>{const G=ee.current;if(!G||!G.isConnected){ge();return}const pe=(X==null?void 0:X.rowIndex)??(E==null?void 0:E.rowIndex)??-1,me=(X==null?void 0:X.colIndex)??(E==null?void 0:E.colIndex)??-1;of(P,G,pe,me,k()),ge(),L.current(),de()},[k,ge,de,E,X]),Tt=s.useCallback(P=>{if(E)return;const G=P.currentTarget,pe=P.target;if(pe.closest(".rich-table-action-bar, .rich-table-context-menu")){Ee();return}const me=pe.closest("td, th");if(!me||!G.contains(me)){Le();return}const Me=me.closest("tr"),ke=me.closest("table");if(!Me||!ke||!G.contains(ke)){Le();return}Ee(),ke.classList.add("rich-table"),ee.current=ke,Sl(ke,Me,me.cellIndex),se(af(ke,Me,me))},[Ee,Le,E]),nt=s.useCallback(P=>{const G=P.relatedTarget;if(G instanceof Element&&(G.closest(".rich-table-action-bar")||G.closest(".rich-table-context-menu"))){Ee();return}Le()},[Ee,Le]),ot=s.useCallback(P=>{const G=P.currentTarget,me=P.target.closest("td, th");if(!me||!G.contains(me))return;const Me=me.closest("tr"),ke=me.closest("table");if(!Me||!ke||!G.contains(ke))return;P.preventDefault(),ke.classList.add("rich-table"),ee.current=ke;const Ie=Array.from(ke.rows).indexOf(Me),Pe=me.cellIndex;Sl(ke,Me,Pe),se(null),J({x:P.clientX,y:P.clientY,rowIndex:Ie,colIndex:Pe})},[]);s.useEffect(()=>{if(!X&&!E)return;const P=()=>Le();return window.addEventListener("scroll",P,!0),window.addEventListener("resize",P),()=>{window.removeEventListener("scroll",P,!0),window.removeEventListener("resize",P)}},[Le,E,X]),s.useEffect(()=>{if(!E)return;const P=G=>{const pe=G.target;pe instanceof Element&&pe.closest(".rich-table-context-menu")||J(null)};return window.addEventListener("mousedown",P),()=>window.removeEventListener("mousedown",P)},[E]);const ue=P=>{if(!P){const G=h.current;G&&(w.current=ta(G))}B(!P)},$e=(P,G)=>{var pe;(pe=k())==null||pe.focus(),u().execCommand(P,!1,G),re(),de()},ne=P=>{$e("formatBlock",P)},He=()=>{var P;(P=k())==null||P.focus(),u().execCommand("insertHTML",!1,"<hr><p><br></p>"),re(),de()},Fe=()=>{const P=window.getSelection();P&&P.rangeCount>0&&(p.current=P.getRangeAt(0).cloneRange())},Ge=()=>{const P=window.getSelection();P&&p.current&&(P.removeAllRanges(),P.addRange(p.current))},Ye=P=>{if(Fe(),P==="link"){const G=window.getSelection();D(G&&!G.isCollapsed?G.toString():""),q("")}P==="image"&&(j(""),Q("")),P==="table"&&(F(3),ae(3),W(!0)),N(P)},ze=()=>{var me;if(!_.trim())return;Ge(),(me=k())==null||me.focus();const P=window.getSelection(),pe=(P&&!P.isCollapsed?P.toString():"")||U.trim()||_.trim();u().execCommand("insertHTML",!1,`<a href="${_r(_.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${_r(pe)}</a>`),re(),N(null)},Je=(P,G="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${_r(P)}" alt="${_r(G)}" class="rich-img" />${Al()}</span>`,st=()=>{var P;K.trim()&&(Ge(),(P=k())==null||P.focus(),u().execCommand("insertHTML",!1,Je(K.trim(),ie.trim())),re(),N(null))},$t=()=>{var P;Ge(),(P=k())==null||P.focus(),u().execCommand("insertHTML",!1,uf(fe,Y,$)),re(),N(null)},he=()=>{var pe;Ge(),(pe=k())==null||pe.focus();const P=window.getSelection(),G=P&&!P.isCollapsed?P.toString():"";u().execCommand("insertHTML",!1,$o(G)),re()},ye=(P,G=1200,pe=1200,me=.72)=>new Promise((Me,ke)=>{const Ie=new FileReader;Ie.onerror=ke,Ie.onload=Pe=>{var xt;const ct=(xt=Pe.target)==null?void 0:xt.result,Ze=new Image;Ze.onerror=ke,Ze.onload=()=>{let{width:Zt,height:wt}=Ze;if(Zt>G||wt>pe){const dr=Math.min(G/Zt,pe/wt);Zt=Math.round(Zt*dr),wt=Math.round(wt*dr)}const yr=document.createElement("canvas");yr.width=Zt,yr.height=wt;const Qt=yr.getContext("2d");if(!Qt){Me(ct);return}Qt.drawImage(Ze,0,0,Zt,wt),Me(yr.toDataURL("image/jpeg",me))},Ze.src=ct},Ie.readAsDataURL(P)}),_e=P=>{P.focus();const G=window.getSelection();if(!G||G.rangeCount===0||!P.contains(G.anchorNode)){const pe=document.createRange();pe.selectNodeContents(P),pe.collapse(!1),G==null||G.removeAllRanges(),G==null||G.addRange(pe)}},We=s.useRef(()=>{});We.current=P=>{const G=k();G&&(_e(G),u().execCommand("insertHTML",!1,P),Mo(G),G.querySelectorAll("p").forEach(pe=>{!(pe.textContent??"").replace(/[\u00a0\s]+/g,"")&&!pe.querySelector("img, hr, table")&&pe.remove()}),re(),de())};const je=s.useRef(ye);je.current=ye;const ht=s.useRef(Je);ht.current=Je;const lt=s.useCallback(P=>{if(!P||f.current.has(P))return;const G=pe=>{const me=pe.clipboardData;if(!me)return;const Me=me.getData("text/html"),ke=me.getData("text/plain");if(Me||ke){pe.preventDefault(),pe.stopPropagation();try{const Ze=Me?Sf(Me):gn(ke);if(!Ze){ke&&We.current(gn(ke));return}We.current(Ze)}catch{ke&&We.current(gn(ke))}return}const Pe=Array.from(me.items).find(Ze=>Ze.type.startsWith("image/"));if(!Pe)return;pe.preventDefault(),pe.stopPropagation();const ct=Pe.getAsFile();ct&&je.current(ct).then(Ze=>{We.current(ht.current(Ze,"imagen"))})};P.addEventListener("paste",G,!0),f.current.set(P,()=>{P.removeEventListener("paste",G,!0),f.current.delete(P)})},[]),Ke=s.useCallback(P=>{var pe;const G=h.current;G&&G!==P&&((pe=f.current.get(G))==null||pe()),h.current=P,P&&lt(P)},[lt]),Re=s.useCallback(P=>{var pe;const G=b.current;G&&G!==P&&((pe=f.current.get(G))==null||pe()),b.current=P,P&&lt(P)},[lt]);s.useEffect(()=>{const P=f.current;return()=>{P.forEach(G=>G()),P.clear()}},[]);const ft=P=>{const G=window.getSelection(),pe=k();if(!G||!pe||G.rangeCount===0||G.isCollapsed)return;const me=G.getRangeAt(0);if(!pe.contains(me.startContainer)||!pe.contains(me.endContainer))return;const Me=me.toString();if(!Me)return;let ke=Me;P==="uppercase"?ke=Me.toLocaleUpperCase():P==="lowercase"?ke=Me.toLocaleLowerCase():ke=Ll(Me),me.deleteContents();const Ie=document.createTextNode(ke);me.insertNode(Ie);const Pe=document.createRange();Pe.setStart(Ie,0),Pe.setEnd(Ie,ke.length),G.removeAllRanges(),G.addRange(Pe),p.current=Pe.cloneRange(),re(),de()},dt=()=>{Fe(),de()},pr=()=>{const P=k();P&&El(P),re(),de()},mt=()=>{requestAnimationFrame(()=>{var P;(P=k())==null||P.focus()})},gr=P=>{var G,pe;if((P.metaKey||P.ctrlKey)&&P.key==="Enter"){if(P.preventDefault(),P.stopPropagation(),P.repeat)return;(G=k())==null||G.focus(),u().execCommand("insertLineBreak",!1)||u().execCommand("insertHTML",!1,"<br>"),re(),de();return}if(P.key==="Tab"){const me=window.getSelection(),Me=Tl((me==null?void 0:me.anchorNode)??null),ke=k(),Ie=Ml(Me);if(Me&&Ie&&(ke!=null&&ke.contains(Me))){P.preventDefault();const Pe=lf(Ie),ct=Pe.indexOf(Me),Ze=ct>=0?Pe[ct+1]:null;if(Ze)na(Ze,ke,!0);else if($l(Me,Ie)){const xt=Eo(Ie);xt&&na(xt,ke,!0)}re(),de();return}P.preventDefault(),(pe=k())==null||pe.focus(),u().execCommand("insertText",!1,"    "),re(),de();return}if(P.key==="Enter"&&!P.shiftKey&&!(P.metaKey||P.ctrlKey)){const me=window.getSelection(),Me=Tl((me==null?void 0:me.anchorNode)??null),ke=k(),Ie=Ml(Me);if(Me&&Ie&&(ke!=null&&ke.contains(Me))&&$l(Me,Ie)&&cf(Me)){P.preventDefault();const Pe=Eo(Ie);Pe&&na(Pe,ke,!0),re(),de();return}}if(P.key==="Escape"){if(E){J(null);return}if(T){N(null);return}if(g.current){B(!1);return}}T||(P.ctrlKey||P.metaKey)&&(P.key==="b"&&(P.preventDefault(),$e("bold")),P.key==="i"&&(P.preventDefault(),$e("italic")),P.key==="u"&&(P.preventDefault(),$e("underline")),P.key==="k"&&(P.preventDefault(),Ye("link")))},At=()=>t.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),Ue=(P,G,pe,me,Me)=>{const ke=Me??(C.has(pe)||pe==="__link"&&T==="link"||pe==="__img"&&T==="image"||pe==="__table"&&T==="table");return t.jsx("button",{type:"button",title:G,tabIndex:-1,onFocus:mt,onMouseDown:Ie=>{Ie.preventDefault(),me?me():$e(pe)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:ke?"var(--primary)":"var(--text-secondary)",background:ke?"rgba(59,130,246,0.12)":"transparent"},children:P},pe)},it=P=>{const G=P.target;if(G.closest("[data-action='delete-img']")){P.preventDefault();const me=G.closest(".rich-img-wrap");me&&(me.remove(),re());return}const pe=G.closest("[data-action='copy-code']");pe instanceof HTMLButtonElement&&(P.preventDefault(),yl(pe).catch(()=>{}))},ir=()=>{Ee(),R.current=!0},yt=()=>{R.current=!1,Le()},Ft=(P,G,pe,me=!1)=>t.jsx("button",{type:"button",className:`rich-table-action-btn${me?" rich-table-action-btn--danger":""}`,title:P,"aria-label":P,onMouseDown:Me=>{Me.preventDefault(),Me.stopPropagation(),gt(pe)},children:G}),vr=()=>typeof document>"u"||!X&&!E?null:pt.createPortal(t.jsxs(t.Fragment,{children:[X&&!E&&t.jsxs("div",{className:"rich-table-action-bar",style:{left:X.bar.x,top:X.bar.y},onMouseEnter:ir,onMouseLeave:yt,children:[t.jsxs("span",{className:"rich-table-action-hint",children:["Fila ",X.rowIndex+1," · Col ",X.colIndex+1]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Fila"}),Ft("Añadir fila abajo","+","table-row-add"),Ft("Eliminar fila","−","table-row-del")]}),t.jsxs("div",{className:"rich-table-action-group",children:[t.jsx("span",{className:"rich-table-action-label",children:"Columna"}),Ft("Añadir columna a la derecha","+","table-col-add"),Ft("Eliminar columna","−","table-col-del")]}),Ft("Eliminar tabla","Eliminar","table-delete",!0)]}),E&&t.jsx("div",{className:"rich-table-context-menu",style:{left:E.x,top:E.y},onMouseDown:P=>P.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(([P,G])=>t.jsx("button",{type:"button",onMouseDown:pe=>{pe.preventDefault(),gt(G)},children:P},G))})]}),document.body),cr=P=>t.jsxs(t.Fragment,{children:[T==="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:P},children:[t.jsx("input",{autoFocus:!0,type:"url",value:_,onChange:G=>q(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),ze()),G.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:G=>D(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),ze()),G.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: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"})]}),T==="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:P},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:Fr,value:fe,onChange:G=>F(Rn(Number(G.target.value),1,Fr)),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),$t()),G.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:ea,value:Y,onChange:G=>ae(Rn(Number(G.target.value),1,ea)),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),$t()),G.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:$,onChange:G=>W(G.target.checked)}),"Encabezado"]}),t.jsx("button",{type:"button",onClick:$t,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"})]}),T==="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:P},children:[t.jsx("input",{autoFocus:!0,type:"url",value:K,onChange:G=>j(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),st()),G.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:ie,onChange:G=>Q(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),st()),G.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:st,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"})]})]}),Kr=(P,G)=>{const pe=l==="compact",me=!pe||oe||P;return 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:G},"data-toolbar-variant":l,children:[pe&&!P&&t.jsxs("button",{type:"button",title:oe?"Ocultar herramientas":"Mostrar herramientas de formato",tabIndex:-1,onFocus:mt,onMouseDown:Me=>{Me.preventDefault(),Z(ke=>!ke)},className:"flex h-7 items-center gap-1 rounded px-1.5 text-[10px] font-semibold transition-colors",style:{color:"var(--text-secondary)",background:oe?"color-mix(in srgb, var(--primary) 12%, transparent)":"transparent"},children:[oe?t.jsx(z.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(z.HiChevronDown,{className:"h-3.5 w-3.5"}),oe?"Ocultar herramientas":"Herramientas"]}),me&&t.jsxs(t.Fragment,{children:[Ue(t.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),Ue(t.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),Ue(t.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),Ue(t.jsx(z.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),Ue(t.jsx(z.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),Ue(t.jsx(z.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>Ye("link")),At(),Ue(t.jsx(z.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),Ue(t.jsx(z.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),At(),Ue(t.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>ne("p"),C.has("formatBlock:p")||C.has("formatBlock:div")),Ue(t.jsx(z.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>ne("h2"),C.has("formatBlock:h2")),Ue(t.jsx(z.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>ne("h3"),C.has("formatBlock:h3")),Ue(t.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>ne("blockquote"),C.has("formatBlock:blockquote")),Ue(t.jsx("span",{style:{fontFamily:"ui-monospace, monospace",fontSize:"10px"},children:"</>"}),"Bloque de código","__code",()=>he(),C.has("__code")),At(),Ue(t.jsx("s",{children:"S"}),"Tachado","strikeThrough"),At(),Ue(t.jsx(z.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),Ue(t.jsx(z.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),At(),Ue(t.jsx(z.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),Ue(t.jsx(z.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),Ue(t.jsx(z.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),Ue(t.jsx(z.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),At(),Ue(t.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>ft("uppercase")),Ue(t.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>ft("lowercase")),Ue(t.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>ft("capitalize")),At(),Ue(t.jsx(z.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),Ue(t.jsx(z.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>Ye("image")),Ue(t.jsx(z.HiTableCells,{className:"h-4 w-4"}),"Insertar tabla","__table",()=>Ye("table")),Ue(t.jsx(z.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",He),At(),Ue(t.jsx(z.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),Ue(t.jsx(z.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>ne("p"))]}),At(),t.jsx("button",{type:"button",title:P?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:mt,onMouseDown:Me=>{Me.preventDefault(),ue(P)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:P?t.jsx(z.HiArrowsPointingIn,{className:"h-4 w-4"}):t.jsx(z.HiArrowsPointingOut,{className:"h-4 w-4"})})]})};return t.jsxs(t.Fragment,{children:[vr(),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:Ke,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":d,onInput:pr,onKeyDown:gr,onKeyUp:dt,onSelect:dt,onMouseUp:dt,onMouseMove:Tt,onMouseLeave:nt,onContextMenu:ot,onMouseDown:it,"data-placeholder":n,className:`rich-editor px-3 py-2 text-sm focus:outline-none${S?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:a,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),cr("var(--bg-input)"),Kr(!1,"var(--bg-input)")]}),t.jsxs(co,{open:ce,onClose:()=>B(!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]",zIndex:i,children:[t.jsx("div",{ref:Re,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":d,onInput:pr,onKeyDown:gr,onKeyUp:dt,onSelect:dt,onMouseUp:dt,onMouseMove:Tt,onMouseLeave:nt,onContextMenu:ot,onMouseDown:it,"data-placeholder":n,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${S?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),cr("var(--bg-input)"),Kr(!0,"var(--bg-input)")]})]})}const Il="[a-zA-Z0-9._@-]+",Lo=new RegExp(`@(${Il})`,"g"),Tf=/[a-zA-Z0-9._@-]/,vn=new Set([" ",`
34
+ `," ","\r"," ","(","[","{",".",",",";",":","!","?","¿","¡",")","]","}",'"',"'","«","»","/","\\","|","-","—","–"]);function Fl(e,r){if(r<=0)return!0;const n=e[r-1]??"";return vn.has(n)}function _l(e,r,n){var a;if(r<0||r>e.length)return null;for(let o=r-1;o>=0;o-=1){if(e[o]!=="@"){const c=e[o]??"";if(vn.has(c)||!Tf.test(c))return null;continue}if((a=n==null?void 0:n.isInsideExistingMention)!=null&&a.call(n,o)||!(n!=null&&n.isTriggerBoundary?n.isTriggerBoundary(o):Fl(e,o)))continue;const i=e.slice(o+1,r);return i.length>0&&!new RegExp(`^${Il}$`).test(i)?null:{query:i,triggerIndex:o,caretIndex:r}}return null}function Pl(e,r){var a;const n=Pr(e,r);return n?!!((a=n.node.parentElement)!=null&&a.closest(".mention-chip")):!1}function zl(e,r){if(r<=0)return!0;const n=Pr(e,r);if(!n){const o=_o(e);return Fl(o,r)}if(n.offset>0){const o=n.node.data[n.offset-1]??"";return vn.has(o)}let a=n.node.previousSibling;for(;a;){if(a.nodeType===Node.TEXT_NODE){const o=a.textContent??"";if(o.length===0){a=a.previousSibling;continue}return vn.has(o[o.length-1]??"")}if(a.nodeType===Node.ELEMENT_NODE){const o=a;if(o.classList.contains("mention-chip")||o.tagName==="BR"||/^(P|DIV|LI|H[1-6]|BLOCKQUOTE)$/i.test(o.tagName))return!0;const l=o.textContent??"";if(l.length===0){a=a.previousSibling;continue}return vn.has(l[l.length-1]??"")}a=a.previousSibling}return!0}function Do(e,r){const n=_o(e);return _l(n,r,{isTriggerBoundary:a=>zl(e,a),isInsideExistingMention:a=>Pl(e,a)})}function Oo(e){return e.toLowerCase().trim()}function Wl(e){return e?e.replace(/<style[^>]*>[\s\S]*?<\/style>/gi," ").replace(/<script[^>]*>[\s\S]*?<\/script>/gi," ").replace(/<br\s*\/?>/gi,`
35
35
  `).replace(/<\/(p|div|li)>/gi,`
36
- `).replace(/<[^>]+>/g," ").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/\s+/g," ").trim():""}function So(e){if(!e)return[];const r=new Set,n=[],a=d=>{const u=ko(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=Ll(e);wo.lastIndex=0;let c;for(;(c=wo.exec(i))!==null;)a(c[1]??"");return n}function Dl(e){const r=String(e.name??"").trim();return r||String(e.username??"").trim()||"usuario"}function vf(e,r){const n=So(e);if(!n.length)return[];const a=new Map;r.forEach(i=>{i.username&&a.set(ko(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 Ol(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 yf(e,r){return r?e.filter(n=>n.userId!==r):e}function Co(e){var n;let r=e.nextSibling;for((r==null?void 0:r.nodeType)===Node.TEXT_NODE&&/^[ \u00a0]/.test(r.textContent??"")&&(r=r.nextSibling);r&&r.nodeType===Node.TEXT_NODE&&!(r.textContent??"").replace(/\u00a0/g," ").trim();)r=r.nextSibling;return r&&r.nodeType===Node.ELEMENT_NODE&&((n=r.classList)!=null&&n.contains("mention-chip"))?" ":!r||r.nodeType===Node.ELEMENT_NODE&&r.tagName==="BR"?" ":" "}function Hl(e){return!e||!/@/.test(e)?e:e.replace(wo,(r,n,a,o)=>{const l=o.slice(0,a),i=l.lastIndexOf("<"),c=l.lastIndexOf(">");if(i>c)return r;const d=(n??"").toLowerCase(),u=o[a+r.length]??"";return u===" "||u===" "?`<span class="mention-chip" contenteditable="false" data-username="${d}">${r}</span>`:`<span class="mention-chip" contenteditable="false" data-username="${d}">${r}</span>${u?" ":" "}`})}function dn(e){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip").forEach(n=>{if(!(n instanceof HTMLElement))return;const a=n.ownerDocument,o=Co(n),l=n.nextSibling;if((l==null?void 0:l.nodeType)===Node.TEXT_NODE){const i=l.textContent??"";if(i.startsWith(o))return;if(i.startsWith(" ")||i.startsWith(" ")){l.textContent=`${o}${i.slice(1)}`;return}if(i.length>0){l.textContent=`${o}${i}`;return}}n.after(a.createTextNode(o))})}function Eo(e){var d;const r=e.ownerDocument,n=r.defaultView,a=e.parentNode;a&&dn(a);const o=Co(e);let l=e.nextSibling;!l||l.nodeType!==Node.TEXT_NODE||!/^[ \u00a0]/.test(l.textContent??"")?(l=r.createTextNode(o),e.after(l)):(l.textContent??"").startsWith(o)||(l.textContent=`${o}${(l.textContent??"").slice(1)}`);const i=n==null?void 0:n.getSelection();if(!i)return;const c=r.createRange();c.setStart(l,((d=l.textContent)==null?void 0:d.length)??1),c.collapse(!0),i.removeAllRanges(),i.addRange(c)}const xf=new Set(["P","DIV","LI","H1","H2","H3","H4","H5","H6","BLOCKQUOTE"]);function Bl(e,r){return xf.has(e.tagName)&&e!==r}function Mo(e,r){let n="",a,o,l=!1;const i=(f,p)=>{if(l||!(r!=null&&r.domPoint))return;const{container:v,offset:w}=r.domPoint;v===f&&w===p&&(o=n.length,l=!0)},c=(f,p)=>(r==null?void 0:r.locatePlain)!==n.length?!1:(a={node:f,offset:p},!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+=`
37
- `,(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 p=f.data;for(let v=0;v<=p.length;v+=1){if(i(f,v),c(f,v))return!0;v<p.length&&(n+=p[v])}return!1},h=(f,p)=>{if(p&&n.length>0&&!n.endsWith(`
38
- `)&&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 w=Array.from(f.childNodes);for(let g=0;g<w.length;g+=1){const A=w[g],C=g>0&&A.nodeType===Node.ELEMENT_NODE&&Bl(A,e);if(h(A,C))return!0}return!1},b=Array.from(e.childNodes);for(let f=0;f<b.length;f+=1){const p=b[f],v=f>0&&p.nodeType===Node.ELEMENT_NODE&&Bl(p,e);if(h(p,v))break}if((r==null?void 0:r.locatePlain)===n.length&&!a){const f=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);let p=f.nextNode(),v=p;for(;v;)p=v,v=f.nextNode();p&&(a={node:p,offset:p.data.length})}return{plain:n,locate:a,domOffset:o}}function To(e){return Mo(e).plain}function Br(e,r){return r<0?null:Mo(e,{locatePlain:r}).locate??null}function Jn(e,r,n){return e!==r&&!e.contains(r)?-1:Mo(e,{domPoint:{container:r,offset:n}}).domOffset??-1}function Il(e,r){const{triggerIndex:n,caretIndex:a,username:o}=r;if(a<n)return null;const l=Br(e,n),i=Br(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=Dl({name:r.display,username:o}),h=c.createElement("span");h.className="mention-chip",h.setAttribute("data-username",o.toLowerCase()),r.userId&&h.setAttribute("data-userid",String(r.userId)),h.contentEditable="false",h.textContent=u,h.title=`@${o}`;const b=c.createTextNode(" "),f=c.createDocumentFragment();f.append(h,b),d.insertNode(f),dn(e),Eo(h);const p=c.defaultView,v=p==null?void 0:p.getSelection(),w=v!=null&&v.rangeCount?Jn(e,v.getRangeAt(0).startContainer,v.getRangeAt(0).startOffset):n+u.length+1;return{caretPlainOffset:w>=0?w:n+u.length+1}}function Fl(e,r){const n=e.ownerDocument,a=n.defaultView;if(!a)return;const o=a.getSelection();if(!o)return;const l=n.createRange(),i=Br(e,r);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(e),l.collapse(!1)),o.removeAllRanges(),o.addRange(l)}function Rn(e){return e instanceof HTMLElement&&e.classList.contains("mention-chip")}function _l(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 Pl(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 Ir(e=document){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip.is-selected").forEach(n=>{n.classList.remove("is-selected")})}function ea(e){var a;const r=(a=e.ownerDocument.defaultView)==null?void 0:a.getSelection();e.querySelectorAll(".mention-chip").forEach(o=>{let l=!1;if(r&&r.rangeCount>0)try{const i=r.getRangeAt(0);(!r.isCollapsed&&i.intersectsNode(o)||r.isCollapsed&&i.startContainer===o&&i.endContainer===o)&&(l=!0)}catch{l=!1}o.classList.toggle("is-selected",l)})}function zl(e){var o;const r=e.ownerDocument,n=(o=r.defaultView)==null?void 0:o.getSelection();if(!n)return;const a=r.createRange();a.selectNodeContents(e),n.removeAllRanges(),n.addRange(a),ea(e)}function Wl(e){const r=e.cloneContents();return r.querySelectorAll(".mention-chip").forEach(n=>n.remove()),(r.textContent??"").replace(/\u00a0/g," ").trim().length>0}function jl(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(),Ir(e),!0):!1}function ta(e){var h,b;const r=e.ownerDocument,n=e.parentNode;if(!n)return;const a=(f,p)=>{let v=f;for(;v&&v.nodeType===Node.TEXT_NODE&&(v.textContent??"")==="";){const w=v;v=v[p],w.remove()}return v},o=a(e.nextSibling,"nextSibling");if(o&&o.nodeType===Node.TEXT_NODE&&/^( |\u00a0)/.test(o.textContent??"")){const f=o;(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=(h=r.defaultView)==null?void 0:h.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 ql(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=_l(a.previousSibling,"prev");return Rn(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(Rn(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c-=1;continue}break}}return null}function Ul(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=_l(a.nextSibling,"next");if(Rn(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(Rn(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c+=1;continue}break}}return null}function $o(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 Ao=420,ra=6,Vl=260,wf=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),Xl=4,Nf={position:"relative"},kf={position:"fixed",zIndex:11050,minWidth:Vl,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},Yl={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function Sf(e){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(e)}"]`))}function Cf(e){const r=Math.max(8,Math.min(e.left,window.innerWidth-Vl-8)),n=window.innerHeight-e.bottom-ra-8,a=e.top-ra-8;return n<Math.min(Ao,180)&&a>n?{left:r,bottom:window.innerHeight-e.top+ra,maxHeight:Math.min(Ao,Math.max(120,a))}:{left:r,top:e.bottom+ra,maxHeight:Math.min(Ao,Math.max(120,n))}}function Kl({value:e,onChange:r,onSearchUsers:n,onMentionsChange:a,minHeight:o,placeholder:l,className:i,maxSuggestions:c=8,searchDebounceMs:d=140,highlightInEditor:u=!1,searchCacheKey:h="",toolbarVariant:b="full",focusModalZIndex:f}){const p=s.useId().replace(/:/g,""),v=s.useRef(null),w=s.useRef(null),g=s.useRef(new Map),A=s.useRef(n);A.current=n;const C=s.useRef(null),T=s.useRef(0),H=s.useRef([]),E=s.useRef(null),[x,M]=s.useState(null),[k,_]=s.useState([]),[q,X]=s.useState(0),[D,K]=s.useState([]),[j,le]=s.useState(!1),[Q,fe]=s.useState(!1);T.current=q,s.useEffect(()=>{fe(!0)},[]);const F=(x==null?void 0:x.query)??null;s.useEffect(()=>{if(F===null){_([]);return}const U=F.trim(),se=`${h}|${U.toLowerCase()||"*"}`,S=g.current.get(se);if(S){_(S),le(!1),X(0);return}const R=new AbortController;le(!0);const ee=window.setTimeout(()=>{(async()=>{try{const J=await A.current(U,{signal:R.signal,limit:c});if(R.signal.aborted)return;const y=Array.isArray(J)?J:[];g.current.set(se,y),_(y),X(0)}catch{R.signal.aborted||_([])}finally{R.signal.aborted||le(!1)}})()},d);return()=>{R.abort(),window.clearTimeout(ee)}},[F,c,d,h]);const V=s.useRef(a);V.current=a,s.useEffect(()=>{var U;(U=V.current)==null||U.call(V,Ol(D))},[D]);const ae=s.useCallback(()=>{const U=Sf(p);if(U.length===0)return null;const se=window.getSelection();if(se!=null&&se.rangeCount){const R=se.getRangeAt(0).startContainer;for(const ee of U)if(ee.contains(R))return ee}const S=document.activeElement;for(const R of U)if(S===R||S&&R.contains(S))return R;for(const R of U)if(R.closest('[role="dialog"]'))return R;return U[0]??null},[p]),$=s.useCallback(()=>{const U=ae(),se=window.getSelection();if(!U||!se||se.rangeCount===0){M(null);return}const S=se.getRangeAt(0);if(!U.contains(S.startContainer)){M(null);return}const R=Jn(U,S.startContainer,S.startOffset);if(R<0){M(null);return}const ee=No(U,R);if(!ee){M(null);return}const J=S.getBoundingClientRect(),y=J.width===0&&J.height===0?(()=>{const te=document.createRange();return te.selectNodeContents(S.startContainer),te.collapse(!0),te.getBoundingClientRect()})():J;C.current={query:ee.query,caretIndex:ee.caretIndex,triggerIndex:ee.triggerIndex};const N=Cf(y);M(te=>{const ue={query:ee.query,...N};return te&&te.query===ue.query&&te.top===ue.top&&te.bottom===ue.bottom&&te.left===ue.left&&te.maxHeight===ue.maxHeight?te:ue})},[ae]),P=s.useCallback(U=>{r(U),$()},[r,$]);s.useEffect(()=>{const U=se=>{if(wf.has(se.key))return;const S=ae(),R=se.target;!S||!R||!S.contains(R)||$()};return document.addEventListener("keyup",U,!0),()=>document.removeEventListener("keyup",U,!0)},[ae,$]);const ce=s.useCallback(U=>{const se=ae();if(!se)return;let S=-1;const R=window.getSelection();if(R&&R.rangeCount>0){const te=R.getRangeAt(0);se.contains(te.startContainer)&&(S=Jn(se,te.startContainer,te.startOffset))}if(S<0&&C.current&&(S=C.current.caretIndex),S<0)return;const ee=No(se,S);if(!ee)return;const J=Il(se,{triggerIndex:ee.triggerIndex,caretIndex:S,username:U.username,display:U.name,userId:U.userId});if(!J)return;dn(se),se.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}));const y={userId:U.userId,username:U.username,email:U.email??void 0,display:U.name??U.username};K(te=>{const ue=new Map(te.map(re=>[re.userId,re]));return ue.set(y.userId,y),Array.from(ue.values())}),M(null),C.current=null;const N=U.username.toLowerCase();requestAnimationFrame(()=>{requestAnimationFrame(()=>{const te=ae();if(!te)return;te.focus(),dn(te);const ue=Array.from(te.querySelectorAll(".mention-chip")),re=[...ue].reverse().find(ge=>ge.getAttribute("data-username")===N)??ue[ue.length-1];if(re){Eo(re);return}Fl(te,J.caretPlainOffset)})})},[ae]);s.useEffect(()=>{const U=new Set(So(e).map(se=>se.toLowerCase()));K(se=>{const S=se.filter(R=>U.has(R.username.toLowerCase()));return S.length===se.length?se:S})},[e]),s.useEffect(()=>{if(!x)return;const U=se=>{const S=se.target;if(!S||v.current&&v.current.contains(S)||w.current&&w.current.contains(S))return;const R=ae();R&&R.contains(S)||M(null)};return document.addEventListener("mousedown",U),()=>{document.removeEventListener("mousedown",U)}},[x,ae]);const O=s.useMemo(()=>k.slice(0,c),[k,c]);H.current=O,s.useEffect(()=>{if(!x)return;const U=se=>{const S=ae(),R=se.target;if(!S||!R||!S.contains(R))return;const ee=H.current;if(!(ee.length===0&&se.key!=="Escape"))if(se.key==="ArrowDown")se.preventDefault(),se.stopPropagation(),X(J=>(J+1)%Math.max(ee.length,1));else if(se.key==="ArrowUp")se.preventDefault(),se.stopPropagation(),X(J=>(J-1+ee.length)%Math.max(ee.length,1));else if(se.key==="Enter"||se.key==="Tab"){const J=ee[T.current];J&&(se.preventDefault(),se.stopPropagation(),ce(J))}else se.key==="Escape"&&(se.preventDefault(),se.stopPropagation(),M(null))};return document.addEventListener("keydown",U,!0),()=>document.removeEventListener("keydown",U,!0)},[ae,ce,x]),s.useEffect(()=>{const U=y=>{y.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}))},se=y=>{const N=ae(),te=y.target;if(!N||!te||!N.contains(te))return;if((y.metaKey||y.ctrlKey)&&y.key.toLowerCase()==="a"){y.preventDefault(),y.stopPropagation(),N.focus(),zl(N);return}if(y.key!=="Backspace"&&y.key!=="Delete")return;const ue=window.getSelection();if(ue&&!ue.isCollapsed&&ue.rangeCount>0){const Se=ue.getRangeAt(0);if(N.contains(Se.commonAncestorContainer)&&$o(N).length>0&&Wl(Se)){y.preventDefault(),y.stopPropagation(),jl(N)&&U(N);return}}const re=$o(N);if(re.length>0){y.preventDefault(),y.stopPropagation();for(const Se of re)ta(Se);Ir(N),U(N);return}if(y.key==="Backspace"){const Se=ql(N);if(!Se)return;y.preventDefault(),y.stopPropagation(),ta(Se),Ir(N),U(N);return}const ge=Ul(N);ge&&(y.preventDefault(),y.stopPropagation(),ta(ge),Ir(N),U(N))},S=y=>{const N=ae();if(!N)return;const te=y.target;if(!(te instanceof Element)||!N.contains(te))return;const ue=te.closest(".mention-chip");if(!(ue instanceof HTMLElement)||!N.contains(ue)){E.current=null,Ir(N);return}y.shiftKey||y.button!==0||(E.current={chip:ue,x:y.clientX,y:y.clientY})},R=y=>{const N=E.current;if(!N)return;const te=Math.abs(y.clientX-N.x),ue=Math.abs(y.clientY-N.y);(te>Xl||ue>Xl)&&(E.current=null)},ee=y=>{var ge;const N=ae(),te=E.current;if(E.current=null,!N||!te)return;const ue=y.target;if(!(ue instanceof Element)||!N.contains(ue)||!((ge=ue.closest(".mention-chip"))!=null&&ge.isSameNode(te.chip)))return;const re=window.getSelection();if(re){if(!re.isCollapsed){ea(N);return}N.focus(),Pl(te.chip)}},J=()=>{const y=ae();if(!y)return;const N=window.getSelection();!N||N.rangeCount===0||!N.anchorNode||!y.contains(N.anchorNode)||!N.focusNode||!y.contains(N.focusNode)||ea(y)};return document.addEventListener("keydown",se,!0),document.addEventListener("mousedown",S,!0),document.addEventListener("mousemove",R,!0),document.addEventListener("mouseup",ee,!0),document.addEventListener("selectionchange",J),()=>{document.removeEventListener("keydown",se,!0),document.removeEventListener("mousedown",S,!0),document.removeEventListener("mousemove",R,!0),document.removeEventListener("mouseup",ee,!0),document.removeEventListener("selectionchange",J)}},[ae]),s.useEffect(()=>{if(!x||!w.current)return;const U=w.current.querySelector(`[data-mention-index="${q}"]`);U==null||U.scrollIntoView({block:"nearest"})},[q,x]);const oe=u?Hl(e):e,G=x&&Q?mt.createPortal(t.jsxs("ul",{ref:w,style:{...kf,left:x.left,top:x.top,bottom:x.bottom,maxHeight:x.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[j&&O.length===0&&t.jsx("li",{style:Yl,children:"Buscando…"}),!j&&O.length===0&&t.jsx("li",{style:Yl,children:x.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${x.query}”`}),O.map((U,se)=>{var S,R;return t.jsx("li",{children:t.jsxs("button",{type:"button","data-mention-index":se,onMouseDown:ee=>{ee.preventDefault(),ce(U)},onMouseEnter:()=>X(se),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:se===q?"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:((S=U.name)==null?void 0:S.trim())||`@${U.username}`}),t.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[(R=U.name)!=null&&R.trim()?`@${U.username}`:null,U.email].filter(Boolean).join(" · ")||`@${U.username}`})]})},U.userId)})]}),document.body):null;return t.jsxs("div",{ref:v,style:Nf,className:i,children:[t.jsx(Cl,{value:oe,onChange:P,placeholder:l,minHeight:o,instanceId:p,toolbarVariant:b,focusModalZIndex:f}),G]})}function Ef({value:e,onChange:r,placeholder:n,minHeight:a,onSearchUsers:o,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:h,toolbarVariant:b,focusModalZIndex:f}){return o?t.jsx(Kl,{value:e,onChange:r,onSearchUsers:o,onMentionsChange:l,placeholder:n,minHeight:a,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:h,toolbarVariant:b,focusModalZIndex:f}):t.jsx(Cl,{value:e,onChange:r,placeholder:n,minHeight:a,toolbarVariant:b,focusModalZIndex:f})}function Mf({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 Tf={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)"}},$f={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 Af({children:e,tone:r="neutral",size:n="sm",icon:a,dot:o=!1,className:l=""}){const i=Tf[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 ${$f[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 Gl={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)"}},Lf={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"},Df={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},Of={xs:148,sm:164,md:184},Hf={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 Bf({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:h,menuClassName:b,optionClassName:f,spinnerClassName:p}){const[v,w]=s.useState(!1),[g,A]=s.useState(!1),[C,T]=s.useState(-1),[H,E]=s.useState({}),x=s.useRef(null),M=s.useRef(null),k=s.useRef(null),_=r.find(F=>F.value===e)??r[0],q={..._!=null&&_.tone?Gl[_.tone]:void 0,..._==null?void 0:_.style},X=o||l||r.length===0,D=F=>{i&&F.stopPropagation()},K=s.useCallback(()=>{w(!1),T(-1)},[]),j=s.useCallback(()=>{const F=x.current;if(!F)return;const V=F.getBoundingClientRect(),ae=Math.max(V.width,Of[a]),$=Math.min(Math.max(r.length,1)*38+12,260),P=window.innerHeight-V.bottom,ce=P<$&&V.top>P,O=Math.min(Math.max(8,V.left+V.width/2-ae/2),window.innerWidth-ae-8);E({position:"fixed",left:O,top:ce?void 0:V.bottom+6,bottom:ce?window.innerHeight-V.top+6:void 0,width:ae,zIndex:9999})},[r.length,a]),le=s.useCallback(F=>{F.disabled||(n(F.value),K())},[K,n]);s.useEffect(()=>A(!0),[]),s.useEffect(()=>{if(!v)return;j();const F=r.findIndex(V=>V.value===e);T(F>=0?F:0)},[v,r,j,e]),s.useEffect(()=>{if(!v)return;function F(V){var $,P;const ae=V.target;!(($=x.current)!=null&&$.contains(ae))&&!((P=M.current)!=null&&P.contains(ae))&&K()}return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[K,v]),s.useEffect(()=>{if(v)return window.addEventListener("resize",j),window.addEventListener("scroll",j,!0),()=>{window.removeEventListener("resize",j),window.removeEventListener("scroll",j,!0)}},[v,j]),s.useEffect(()=>{if(C<0||!k.current)return;const F=k.current.children[C];F==null||F.scrollIntoView({block:"nearest"})},[C]);function Q(F){if(!X){if(!v){["Enter"," ","ArrowDown","ArrowUp"].includes(F.key)&&(F.preventDefault(),w(!0));return}if(F.key==="Escape"){F.preventDefault(),K();return}if(F.key==="ArrowDown"){F.preventDefault(),T(V=>Math.min(V+1,r.length-1));return}if(F.key==="ArrowUp"){F.preventDefault(),T(V=>Math.max(V-1,0));return}if(F.key==="Enter"||F.key===" "){F.preventDefault();const V=r[C];V&&le(V)}}}const fe=t.jsx("div",{ref:M,role:"listbox","aria-label":c,className:Rt("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",b),style:{...H,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:D,onMouseDown:D,onPointerDown:D,children:t.jsx("div",{ref:k,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:r.map((F,V)=>{const ae=F.value===e,$=V===C,P={...F.tone?Gl[F.tone]:void 0,...F.style};return t.jsxs("button",{type:"button",role:"option","aria-selected":ae,disabled:F.disabled,onMouseEnter:()=>!F.disabled&&T(V),onMouseDown:ce=>{ce.preventDefault(),le(F)},className:Rt("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",Hf[a],ae?F.className:void 0,f),style:{...ae?P:void 0,background:ae?P.background??"color-mix(in srgb, var(--primary) 12%, transparent)":$?"var(--bg-hover)":"transparent",color:ae?P.color??"var(--primary)":"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:ae?t.jsx(W.HiCheck,{className:"h-4 w-4"}):null}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:F.label})]},F.value)})})});return t.jsxs("span",{ref:x,className:Rt("relative inline-flex shrink-0 items-center",u),onKeyDown:Q,onClick:D,onPointerDown:D,children:[t.jsx("button",{type:"button",disabled:X,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":v,title:d,onClick:()=>!X&&w(F=>!F),className:Rt("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",Lf[a],_==null?void 0:_.className,h),style:q,children:t.jsx("span",{className:"min-w-0 truncate",children:(_==null?void 0:_.label)??e})}),t.jsx(W.HiChevronDown,{"aria-hidden":"true",className:Rt("pointer-events-none absolute opacity-70 transition-transform",Df[a],v?"rotate-180":"rotate-0")}),l&&t.jsx("span",{"aria-hidden":"true",className:Rt("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",p)}),v&&g&&mt.createPortal(fe,document.body)]})}function If({tabs:e,activeTabId:r,defaultActiveTabId:n,onTabChange:a,ariaLabel:o="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:d=""}){const u=e.find(v=>!v.disabled)??e[0],h=r??n??(u==null?void 0:u.id),b=e.find(v=>v.id===h)??u,f=v=>{v.disabled||a==null||a(v.id)},p=v=>{const w=e.filter(A=>!A.disabled);if(!w.length||!b)return;const g=w.findIndex(A=>A.id===b.id);(v.key==="ArrowRight"||v.key==="ArrowDown")&&(v.preventDefault(),f(w[(g+1)%w.length])),(v.key==="ArrowLeft"||v.key==="ArrowUp")&&(v.preventDefault(),f(w[(g-1+w.length)%w.length])),v.key==="Home"&&(v.preventDefault(),f(w[0])),v.key==="End"&&(v.preventDefault(),f(w[w.length-1]))};return t.jsxs("div",{className:i,children:[t.jsx("div",{role:"tablist","aria-label":o,onKeyDown:p,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 w=v.id===(b==null?void 0:b.id);return t.jsxs("button",{type:"button",role:"tab","aria-selected":w,"aria-controls":`${v.id}-panel`,id:`${v.id}-tab`,disabled:v.disabled,tabIndex:w?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:w?"var(--primary)":"var(--text-muted)",borderColor:w?"var(--primary)":"transparent",background:l==="pills"&&w?"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 ar(...e){return e.filter(Boolean).join(" ")}function Ff({steps:e,activeStepId:r,initialStepId:n,completedStepIds:a,defaultCompletedStepIds:o=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:c,allowBackNavigation:d=!0,showFooter:u=!0,previousLabel:h="Anterior",nextLabel:b="Siguiente",blockedNextLabel:f="Completa este paso",className:p="",headerClassName:v="",contentClassName:w="",footerClassName:g=""}){var se;const A=((se=e[0])==null?void 0:se.id)??"",[C,T]=s.useState(n??A),[H,E]=s.useState(o),x=r??C,M=a??H,k=s.useMemo(()=>new Set(M),[M]),_=Math.max(0,e.findIndex(S=>S.id===x)),q=e[_]??e[0],X=e.length<=1?100:_/(e.length-1)*100,D=S=>{a||E(S),i==null||i(S)},K=S=>{const R=e.find(ee=>ee.id===S);R&&(r||T(S),l==null||l(S,R))},j=S=>k.has(S),le=S=>e.slice(0,S).find(R=>!R.optional&&!k.has(R.id)),Q=S=>{const R=e[S];return!R||R.disabled?!1:S===_||d&&S<_?!0:!le(S)},fe=S=>{const R=e.findIndex(ee=>ee.id===S);return R>=0&&Q(R)},F=S=>{const R=e.findIndex(ee=>ee.id===S);if(R<0)return!1;if(!Q(R)){const ee=le(R);return ee&&(c==null||c(e[R],ee)),!1}return K(S),!0},V=(S=q==null?void 0:q.id)=>{!S||k.has(S)||D([...M,S])},ae=(S=q==null?void 0:q.id)=>{if(!S)return;const R=e.findIndex(J=>J.id===S),ee=M.filter(J=>{const y=e.findIndex(N=>N.id===J);return y>=0&&y<R});D(ee),R>=0&&_>R&&K(S)},$=()=>_<=0?!1:F(e[_-1].id),P=()=>{const S=e[_+1];return S?F(S.id):!1},ce={activeStep:q,activeIndex:_,completedStepIds:M,isCompleted:j,isUnlocked:fe,completeStep:V,uncompleteStep:ae,goToStep:F,goNext:P,goPrevious:$};if(!q)return null;const O=e[_+1],oe=_>0,G=O?fe(O.id):!1,U=typeof q.content=="function"?q.content(ce):q.content;return t.jsxs("section",{className:ar("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",p),children:[t.jsxs("div",{className:ar("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:`${X}%`}})}),t.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map((S,R)=>{const ee=S.id===q.id,J=j(S.id),y=Q(R),N=le(R);return t.jsxs("button",{type:"button",disabled:!y,"aria-current":ee?"step":void 0,"aria-disabled":!y,title:!y&&N?`Completa ${N.title}`:S.title,onClick:()=>F(S.id),className:ar("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",J&&!ee&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!ee&&!J&&y&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!y&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[t.jsx("span",{className:ar("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:ar("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)]",J&&!ee&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!J&&!ee&&y&&"border-[var(--border)] text-[var(--text-muted)]",!y&&"border-[var(--border)] text-[var(--text-muted)]"),children:J?t.jsx(W.HiCheck,{className:"h-4 w-4"}):y?R+1:t.jsx(W.HiLockClosed,{className:"h-3.5 w-3.5"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:ar("block truncate text-xs font-semibold transition-colors duration-200",ee?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[R+1,". ",S.title]}),S.description&&t.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:S.description})]}),S.badge&&t.jsx("span",{className:"shrink-0",children:S.badge})]})]},S.id)})})]}),t.jsx("div",{className:ar("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",w),children:U},q.id),u&&t.jsxs("div",{className:ar("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",g),children:[t.jsx(Ke,{variant:"secondary",height:38,padding:"0 14px",icon:t.jsx(W.HiChevronLeft,{}),disabled:!oe,onClick:$,children:h}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[t.jsxs("span",{children:["Paso ",_+1," de ",e.length]}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),t.jsxs("span",{children:[M.length," completados"]})]}),t.jsx(Ke,{height:38,padding:"0 14px",icon:t.jsx(W.HiChevronRight,{}),disabled:!O||!G,onClick:P,children:O&&!G?f:b})]})]})}const _f={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 Pf(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function zf(e){const r=getComputedStyle(e),n=Number.parseFloat(r.lineHeight),a=Number.parseFloat(r.paddingTop)+Number.parseFloat(r.paddingBottom),o=Number.parseFloat(r.borderTopWidth)+Number.parseFloat(r.borderBottomWidth);return{lineHeight:Number.isFinite(n)?n:20,paddingY:Number.isFinite(a)?a:12,borderY:Number.isFinite(o)?o:2}}function Zl(e,r){const{lineHeight:n,paddingY:a,borderY:o}=zf(e);return Math.ceil(r*n+a+o)}const Ql=s.forwardRef(function({className:r="",size:n="md",status:a="default",maxHeight:o,maxRows:l,minRows:i=1,style:c,value:d,defaultValue:u,onInput:h,...b},f){const p=s.useRef(null),v=a==="error"?"var(--danger)":a==="success"?"#16a34a":"var(--border)",w=s.useCallback(()=>{const g=p.current;if(!g)return;g.style.height="auto";const A=g.scrollHeight,C=Zl(g,i),T=o??(l!==void 0?Zl(g,l):void 0),H=T!==void 0?Math.min(Math.max(A,C),T):Math.max(A,C);g.style.height=`${H}px`,g.style.overflowY=T!==void 0&&A>T?"auto":"hidden"},[o,l,i]);return s.useLayoutEffect(()=>{w()},[w,d,u]),s.useEffect(()=>{const g=p.current;if(!g||typeof ResizeObserver>"u")return;const A=new ResizeObserver(()=>w());return A.observe(g),()=>A.disconnect()},[w]),t.jsx("textarea",{...b,ref:g=>{p.current=g,Pf(f,g)},rows:i,value:d,defaultValue:u,"aria-invalid":a==="error"||b["aria-invalid"],onInput:g=>{w(),h==null||h(g)},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 ${_f[n]} ${r}`})});function Wf({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(jn,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:r,children:t.jsx(Ql,{...u,required:i,status:o?"error":d,className:`w-full ${c}`})})}const jf={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"},qf={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Uf(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Vf(e,r){return e!==void 0?String(e).length:r!==void 0?String(r).length:0}const Jl=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:h="default",icon:b,action:f,style:p,value:v,defaultValue:w,maxLength:g,onInput:A,...C},T){const H=s.useRef(null),E=Vf(v,w),x=u??g,M=!!(b||f||d),k=h==="error"?"var(--danger)":h==="success"?"#16a34a":"var(--border)",_={...p??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},q=()=>{const D=H.current;!D||!l||(D.style.height="auto",D.style.height=`${D.scrollHeight}px`)};s.useEffect(q,[l,v]);const X=t.jsx("textarea",{...C,ref:D=>{H.current=D,Uf(T,D)},value:v,defaultValue:w,maxLength:g,"aria-invalid":h==="error"||C["aria-invalid"],onInput:D=>{q(),A==null||A(D)},style:{..._,borderColor:k},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 ${jf[a]} ${qf[l?"none":o]} ${b?"pl-8":""} ${f?"pr-10":""} ${r}`});return M?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}),X,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:[E,x?`/${x}`:""]})]}):X});function Xf({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(jn,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:r,children:t.jsx(Jl,{...u,required:i,status:o?"error":d,className:`w-full ${c}`})})}const Rl=[{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 Yf(e){return Rl[e%Rl.length]}let Kf=0;function Lo(){return++Kf}function ei(e,r){return r?r instanceof RegExp?r.test(e):r(e):!0}function Gf(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Zf(e,r){const n=r.filter(Boolean);if(n.length===0)return[e.trim()].filter(Boolean);const a=new RegExp(`${n.map(o=>Gf(o)).join("|")}|\\r?\\n`,"g");return e.split(a).map(o=>o.trim()).filter(Boolean)}function Qf({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:h,helperText:b,helperDisplay:f="inline",error:p,required:v=!1}){const w=e!==void 0,g=!!p,A=!!b&&f==="tooltip"&&!g,[C,T]=s.useState(()=>(r??[]).map((J,y)=>({id:Lo(),value:J.trim(),colorIndex:y})));s.useEffect(()=>{w&&T(J=>{const y=e??[],N=new Map(J.map(te=>[te.value,te]));return y.map((te,ue)=>N.get(te)??{id:Lo(),value:te,colorIndex:ue})})},[w,e]);const H=C,[E,x]=s.useState(""),[M,k]=s.useState(null),[_,q]=s.useState(""),[X,D]=s.useState(!1),[K,j]=s.useState(!1),le=s.useRef(null),Q=s.useRef(null),fe=s.useRef(null);function F(){j(!0),setTimeout(()=>j(!1),400)}function V(J){T(J),n==null||n(J.map(y=>y.value))}function ae(J){let y=H,N=!1,te=!1;for(const ue of J){const re=ue.trim();if(re){if(c!==void 0&&y.length>=c){te=!0;break}if(!d&&y.some(ge=>ge.value.toLowerCase()===re.toLowerCase())){te=!0;continue}if(!ei(re,u)){te=!0;continue}y=[...y,{id:Lo(),value:re,colorIndex:y.length}],N=!0}}return N&&V(y),te&&F(),N}function $(J){return ae([J])}function P(J){const y=H.filter(N=>N.id!==J);V(y.map((N,te)=>({...N,colorIndex:te})))}function ce(J,y){const N=y.trim();if(k(null),q(""),!N){P(J);return}if(!(!d&&H.some(te=>te.id!==J&&te.value.toLowerCase()===N.toLowerCase()))){if(!ei(N,u)){F();return}V(H.map(te=>te.id===J?{...te,value:N}:te))}}function O(J){o||(k(J.id),q(J.value),setTimeout(()=>{var y;return(y=Q.current)==null?void 0:y.select()},0))}function oe(J){if(J.key==="Enter"||i.includes(J.key)){J.preventDefault(),$(E)&&x("");return}if(J.key==="Backspace"&&E===""&&H.length>0){J.preventDefault();const y=H[H.length-1];P(y.id)}}function G(J,y){if(J.key==="Enter"){J.preventDefault(),ce(y,_),setTimeout(()=>{var N;return(N=le.current)==null?void 0:N.focus()},0);return}J.key==="Escape"&&(J.preventDefault(),k(null),q(""),setTimeout(()=>{var N;return(N=le.current)==null?void 0:N.focus()},0))}function U(){var J;o||(J=le.current)==null||J.focus()}function se(J){if(o)return;const y=J.clipboardData.getData("text");if(!y||!(i.some(re=>re&&y.includes(re))||y.includes(`
39
- `)))return;J.preventDefault();const te=Zf(y,i);ae(te)&&x("")}function S(){const J=E.trim();J&&$(J)&&x("")}const R=g?"var(--danger)":X?"var(--primary)":"var(--border)",ee=c!==void 0&&H.length>=c;return t.jsxs("div",{className:`flex flex-col gap-2 ${l}`,children:[(h||v||A)&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[h&&t.jsx("span",{children:h}),v&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),A?t.jsx($r,{content:b}):null]}),t.jsxs("div",{ref:fe,onClick:U,onFocus:()=>D(!0),onBlur:J=>{var y;(y=fe.current)!=null&&y.contains(J.relatedTarget)||(D(!1),M!==null&&ce(M,_),M===null&&S())},style:{borderColor:R},className:`
36
+ `).replace(/<[^>]+>/g," ").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/\s+/g," ").trim():""}function Ho(e){if(!e)return[];const r=new Set,n=[],a=d=>{const u=Oo(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=Wl(e);Lo.lastIndex=0;let c;for(;(c=Lo.exec(i))!==null;)a(c[1]??"");return n}function jl(e){const r=String(e.name??"").trim();return r||String(e.username??"").trim()||"usuario"}function $f(e,r){const n=Ho(e);if(!n.length)return[];const a=new Map;r.forEach(i=>{i.username&&a.set(Oo(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 ql(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 Af(e,r){return r?e.filter(n=>n.userId!==r):e}function Bo(e){var n;let r=e.nextSibling;for((r==null?void 0:r.nodeType)===Node.TEXT_NODE&&/^[ \u00a0]/.test(r.textContent??"")&&(r=r.nextSibling);r&&r.nodeType===Node.TEXT_NODE&&!(r.textContent??"").replace(/\u00a0/g," ").trim();)r=r.nextSibling;return r&&r.nodeType===Node.ELEMENT_NODE&&((n=r.classList)!=null&&n.contains("mention-chip"))?" ":!r||r.nodeType===Node.ELEMENT_NODE&&r.tagName==="BR"?" ":" "}function Ul(e){return!e||!/@/.test(e)?e:e.replace(Lo,(r,n,a,o)=>{const l=o.slice(0,a),i=l.lastIndexOf("<"),c=l.lastIndexOf(">");if(i>c)return r;const d=(n??"").toLowerCase(),u=o[a+r.length]??"";return u===" "||u===" "?`<span class="mention-chip" contenteditable="false" data-username="${d}">${r}</span>`:`<span class="mention-chip" contenteditable="false" data-username="${d}">${r}</span>${u?" ":" "}`})}function yn(e){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip").forEach(n=>{if(!(n instanceof HTMLElement))return;const a=n.ownerDocument,o=Bo(n),l=n.nextSibling;if((l==null?void 0:l.nodeType)===Node.TEXT_NODE){const i=l.textContent??"";if(i.startsWith(o))return;if(i.startsWith(" ")||i.startsWith(" ")){l.textContent=`${o}${i.slice(1)}`;return}if(i.length>0){l.textContent=`${o}${i}`;return}}n.after(a.createTextNode(o))})}function Io(e){var d;const r=e.ownerDocument,n=r.defaultView,a=e.parentNode;a&&yn(a);const o=Bo(e);let l=e.nextSibling;!l||l.nodeType!==Node.TEXT_NODE||!/^[ \u00a0]/.test(l.textContent??"")?(l=r.createTextNode(o),e.after(l)):(l.textContent??"").startsWith(o)||(l.textContent=`${o}${(l.textContent??"").slice(1)}`);const i=n==null?void 0:n.getSelection();if(!i)return;const c=r.createRange();c.setStart(l,((d=l.textContent)==null?void 0:d.length)??1),c.collapse(!0),i.removeAllRanges(),i.addRange(c)}const Lf=new Set(["P","DIV","LI","H1","H2","H3","H4","H5","H6","BLOCKQUOTE"]);function Vl(e,r){return Lf.has(e.tagName)&&e!==r}function Fo(e,r){let n="",a,o,l=!1;const i=(f,p)=>{if(l||!(r!=null&&r.domPoint))return;const{container:g,offset:w}=r.domPoint;g===f&&w===p&&(o=n.length,l=!0)},c=(f,p)=>(r==null?void 0:r.locatePlain)!==n.length?!1:(a={node:f,offset:p},!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+=`
37
+ `,(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 p=f.data;for(let g=0;g<=p.length;g+=1){if(i(f,g),c(f,g))return!0;g<p.length&&(n+=p[g])}return!1},h=(f,p)=>{if(p&&n.length>0&&!n.endsWith(`
38
+ `)&&d(f)==="matched")return!0;if(f.nodeType===Node.TEXT_NODE)return u(f);if(f.nodeType!==Node.ELEMENT_NODE)return!1;const g=f;if(g.tagName==="BR")return i(g,0),d(g.nextSibling??void 0)==="matched";const w=Array.from(f.childNodes);for(let v=0;v<w.length;v+=1){const L=w[v],M=v>0&&L.nodeType===Node.ELEMENT_NODE&&Vl(L,e);if(h(L,M))return!0}return!1},b=Array.from(e.childNodes);for(let f=0;f<b.length;f+=1){const p=b[f],g=f>0&&p.nodeType===Node.ELEMENT_NODE&&Vl(p,e);if(h(p,g))break}if((r==null?void 0:r.locatePlain)===n.length&&!a){const f=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);let p=f.nextNode(),g=p;for(;g;)p=g,g=f.nextNode();p&&(a={node:p,offset:p.data.length})}return{plain:n,locate:a,domOffset:o}}function _o(e){return Fo(e).plain}function Pr(e,r){return r<0?null:Fo(e,{locatePlain:r}).locate??null}function la(e,r,n){return e!==r&&!e.contains(r)?-1:Fo(e,{domPoint:{container:r,offset:n}}).domOffset??-1}function Xl(e,r){const{triggerIndex:n,caretIndex:a,username:o}=r;if(a<n)return null;const l=Pr(e,n),i=Pr(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=jl({name:r.display,username:o}),h=c.createElement("span");h.className="mention-chip",h.setAttribute("data-username",o.toLowerCase()),r.userId&&h.setAttribute("data-userid",String(r.userId)),h.contentEditable="false",h.textContent=u,h.title=`@${o}`;const b=c.createTextNode(" "),f=c.createDocumentFragment();f.append(h,b),d.insertNode(f),yn(e),Io(h);const p=c.defaultView,g=p==null?void 0:p.getSelection(),w=g!=null&&g.rangeCount?la(e,g.getRangeAt(0).startContainer,g.getRangeAt(0).startOffset):n+u.length+1;return{caretPlainOffset:w>=0?w:n+u.length+1}}function Yl(e,r){const n=e.ownerDocument,a=n.defaultView;if(!a)return;const o=a.getSelection();if(!o)return;const l=n.createRange(),i=Pr(e,r);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(e),l.collapse(!1)),o.removeAllRanges(),o.addRange(l)}function ia(e){return e instanceof HTMLElement&&e.classList.contains("mention-chip")}function Gl(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 Kl(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 zr(e=document){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip.is-selected").forEach(n=>{n.classList.remove("is-selected")})}function ca(e){var a;const r=(a=e.ownerDocument.defaultView)==null?void 0:a.getSelection();e.querySelectorAll(".mention-chip").forEach(o=>{let l=!1;if(r&&r.rangeCount>0)try{const i=r.getRangeAt(0);(!r.isCollapsed&&i.intersectsNode(o)||r.isCollapsed&&i.startContainer===o&&i.endContainer===o)&&(l=!0)}catch{l=!1}o.classList.toggle("is-selected",l)})}function Zl(e){var o;const r=e.ownerDocument,n=(o=r.defaultView)==null?void 0:o.getSelection();if(!n)return;const a=r.createRange();a.selectNodeContents(e),n.removeAllRanges(),n.addRange(a),ca(e)}function Ql(e){const r=e.cloneContents();return r.querySelectorAll(".mention-chip").forEach(n=>n.remove()),(r.textContent??"").replace(/\u00a0/g," ").trim().length>0}function Jl(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(),zr(e),!0):!1}function da(e){var h,b;const r=e.ownerDocument,n=e.parentNode;if(!n)return;const a=(f,p)=>{let g=f;for(;g&&g.nodeType===Node.TEXT_NODE&&(g.textContent??"")==="";){const w=g;g=g[p],w.remove()}return g},o=a(e.nextSibling,"nextSibling");if(o&&o.nodeType===Node.TEXT_NODE&&/^( |\u00a0)/.test(o.textContent??"")){const f=o;(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=(h=r.defaultView)==null?void 0:h.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 Rl(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=Gl(a.previousSibling,"prev");return ia(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(ia(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c-=1;continue}break}}return null}function ei(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=Gl(a.nextSibling,"next");if(ia(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(ia(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c+=1;continue}break}}return null}function Po(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 zo=420,ua=6,ti=260,Df=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),ri=4,Of={position:"relative"},Hf={position:"fixed",zIndex:11050,minWidth:ti,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},ni={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function Bf(e){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(e)}"]`))}function If(e){const r=Math.max(8,Math.min(e.left,window.innerWidth-ti-8)),n=window.innerHeight-e.bottom-ua-8,a=e.top-ua-8;return n<Math.min(zo,180)&&a>n?{left:r,bottom:window.innerHeight-e.top+ua,maxHeight:Math.min(zo,Math.max(120,a))}:{left:r,top:e.bottom+ua,maxHeight:Math.min(zo,Math.max(120,n))}}function ai({value:e,onChange:r,onSearchUsers:n,onMentionsChange:a,minHeight:o,placeholder:l,className:i,maxSuggestions:c=8,searchDebounceMs:d=140,highlightInEditor:u=!1,searchCacheKey:h="",toolbarVariant:b="full",focusModalZIndex:f}){const p=s.useId().replace(/:/g,""),g=s.useRef(null),w=s.useRef(null),v=s.useRef(new Map),L=s.useRef(n);L.current=n;const M=s.useRef(null),S=s.useRef(0),H=s.useRef([]),C=s.useRef(null),[y,T]=s.useState(null),[N,_]=s.useState([]),[q,U]=s.useState(0),[D,K]=s.useState([]),[j,ie]=s.useState(!1),[Q,fe]=s.useState(!1);S.current=q,s.useEffect(()=>{fe(!0)},[]);const F=(y==null?void 0:y.query)??null;s.useEffect(()=>{if(F===null){_([]);return}const X=F.trim(),se=`${h}|${X.toLowerCase()||"*"}`,E=v.current.get(se);if(E){_(E),ie(!1),U(0);return}const J=new AbortController;ie(!0);const ee=window.setTimeout(()=>{(async()=>{try{const R=await L.current(X,{signal:J.signal,limit:c});if(J.signal.aborted)return;const x=Array.isArray(R)?R:[];v.current.set(se,x),_(x),U(0)}catch{J.signal.aborted||_([])}finally{J.signal.aborted||ie(!1)}})()},d);return()=>{J.abort(),window.clearTimeout(ee)}},[F,c,d,h]);const Y=s.useRef(a);Y.current=a,s.useEffect(()=>{var X;(X=Y.current)==null||X.call(Y,ql(D))},[D]);const ae=s.useCallback(()=>{const X=Bf(p);if(X.length===0)return null;const se=window.getSelection();if(se!=null&&se.rangeCount){const J=se.getRangeAt(0).startContainer;for(const ee of X)if(ee.contains(J))return ee}const E=document.activeElement;for(const J of X)if(E===J||E&&J.contains(E))return J;for(const J of X)if(J.closest('[role="dialog"]'))return J;return X[0]??null},[p]),$=s.useCallback(()=>{const X=ae(),se=window.getSelection();if(!X||!se||se.rangeCount===0){T(null);return}const E=se.getRangeAt(0);if(!X.contains(E.startContainer)){T(null);return}const J=la(X,E.startContainer,E.startOffset);if(J<0){T(null);return}const ee=Do(X,J);if(!ee){T(null);return}const R=E.getBoundingClientRect(),x=R.width===0&&R.height===0?(()=>{const te=document.createRange();return te.selectNodeContents(E.startContainer),te.collapse(!0),te.getBoundingClientRect()})():R;M.current={query:ee.query,caretIndex:ee.caretIndex,triggerIndex:ee.triggerIndex};const k=If(x);T(te=>{const de={query:ee.query,...k};return te&&te.query===de.query&&te.top===de.top&&te.bottom===de.bottom&&te.left===de.left&&te.maxHeight===de.maxHeight?te:de})},[ae]),W=s.useCallback(X=>{r(X),$()},[r,$]);s.useEffect(()=>{const X=se=>{if(Df.has(se.key))return;const E=ae(),J=se.target;!E||!J||!E.contains(J)||$()};return document.addEventListener("keyup",X,!0),()=>document.removeEventListener("keyup",X,!0)},[ae,$]);const ce=s.useCallback(X=>{const se=ae();if(!se)return;let E=-1;const J=window.getSelection();if(J&&J.rangeCount>0){const te=J.getRangeAt(0);se.contains(te.startContainer)&&(E=la(se,te.startContainer,te.startOffset))}if(E<0&&M.current&&(E=M.current.caretIndex),E<0)return;const ee=Do(se,E);if(!ee)return;const R=Xl(se,{triggerIndex:ee.triggerIndex,caretIndex:E,username:X.username,display:X.name,userId:X.userId});if(!R)return;yn(se),se.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}));const x={userId:X.userId,username:X.username,email:X.email??void 0,display:X.name??X.username};K(te=>{const de=new Map(te.map(re=>[re.userId,re]));return de.set(x.userId,x),Array.from(de.values())}),T(null),M.current=null;const k=X.username.toLowerCase();requestAnimationFrame(()=>{requestAnimationFrame(()=>{const te=ae();if(!te)return;te.focus(),yn(te);const de=Array.from(te.querySelectorAll(".mention-chip")),re=[...de].reverse().find(ge=>ge.getAttribute("data-username")===k)??de[de.length-1];if(re){Io(re);return}Yl(te,R.caretPlainOffset)})})},[ae]);s.useEffect(()=>{const X=new Set(Ho(e).map(se=>se.toLowerCase()));K(se=>{const E=se.filter(J=>X.has(J.username.toLowerCase()));return E.length===se.length?se:E})},[e]),s.useEffect(()=>{if(!y)return;const X=se=>{const E=se.target;if(!E||g.current&&g.current.contains(E)||w.current&&w.current.contains(E))return;const J=ae();J&&J.contains(E)||T(null)};return document.addEventListener("mousedown",X),()=>{document.removeEventListener("mousedown",X)}},[y,ae]);const B=s.useMemo(()=>N.slice(0,c),[N,c]);H.current=B,s.useEffect(()=>{if(!y)return;const X=se=>{const E=ae(),J=se.target;if(!E||!J||!E.contains(J))return;const ee=H.current;if(!(ee.length===0&&se.key!=="Escape"))if(se.key==="ArrowDown")se.preventDefault(),se.stopPropagation(),U(R=>(R+1)%Math.max(ee.length,1));else if(se.key==="ArrowUp")se.preventDefault(),se.stopPropagation(),U(R=>(R-1+ee.length)%Math.max(ee.length,1));else if(se.key==="Enter"||se.key==="Tab"){const R=ee[S.current];R&&(se.preventDefault(),se.stopPropagation(),ce(R))}else se.key==="Escape"&&(se.preventDefault(),se.stopPropagation(),T(null))};return document.addEventListener("keydown",X,!0),()=>document.removeEventListener("keydown",X,!0)},[ae,ce,y]),s.useEffect(()=>{const X=x=>{x.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}))},se=x=>{const k=ae(),te=x.target;if(!k||!te||!k.contains(te))return;if((x.metaKey||x.ctrlKey)&&x.key.toLowerCase()==="a"){x.preventDefault(),x.stopPropagation(),k.focus(),Zl(k);return}if(x.key!=="Backspace"&&x.key!=="Delete")return;const de=window.getSelection();if(de&&!de.isCollapsed&&de.rangeCount>0){const Ee=de.getRangeAt(0);if(k.contains(Ee.commonAncestorContainer)&&Po(k).length>0&&Ql(Ee)){x.preventDefault(),x.stopPropagation(),Jl(k)&&X(k);return}}const re=Po(k);if(re.length>0){x.preventDefault(),x.stopPropagation();for(const Ee of re)da(Ee);zr(k),X(k);return}if(x.key==="Backspace"){const Ee=Rl(k);if(!Ee)return;x.preventDefault(),x.stopPropagation(),da(Ee),zr(k),X(k);return}const ge=ei(k);ge&&(x.preventDefault(),x.stopPropagation(),da(ge),zr(k),X(k))},E=x=>{const k=ae();if(!k)return;const te=x.target;if(!(te instanceof Element)||!k.contains(te))return;const de=te.closest(".mention-chip");if(!(de instanceof HTMLElement)||!k.contains(de)){C.current=null,zr(k);return}x.shiftKey||x.button!==0||(C.current={chip:de,x:x.clientX,y:x.clientY})},J=x=>{const k=C.current;if(!k)return;const te=Math.abs(x.clientX-k.x),de=Math.abs(x.clientY-k.y);(te>ri||de>ri)&&(C.current=null)},ee=x=>{var ge;const k=ae(),te=C.current;if(C.current=null,!k||!te)return;const de=x.target;if(!(de instanceof Element)||!k.contains(de)||!((ge=de.closest(".mention-chip"))!=null&&ge.isSameNode(te.chip)))return;const re=window.getSelection();if(re){if(!re.isCollapsed){ca(k);return}k.focus(),Kl(te.chip)}},R=()=>{const x=ae();if(!x)return;const k=window.getSelection();!k||k.rangeCount===0||!k.anchorNode||!x.contains(k.anchorNode)||!k.focusNode||!x.contains(k.focusNode)||ca(x)};return document.addEventListener("keydown",se,!0),document.addEventListener("mousedown",E,!0),document.addEventListener("mousemove",J,!0),document.addEventListener("mouseup",ee,!0),document.addEventListener("selectionchange",R),()=>{document.removeEventListener("keydown",se,!0),document.removeEventListener("mousedown",E,!0),document.removeEventListener("mousemove",J,!0),document.removeEventListener("mouseup",ee,!0),document.removeEventListener("selectionchange",R)}},[ae]),s.useEffect(()=>{if(!y||!w.current)return;const X=w.current.querySelector(`[data-mention-index="${q}"]`);X==null||X.scrollIntoView({block:"nearest"})},[q,y]);const oe=u?Ul(e):e,Z=y&&Q?pt.createPortal(t.jsxs("ul",{ref:w,style:{...Hf,left:y.left,top:y.top,bottom:y.bottom,maxHeight:y.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[j&&B.length===0&&t.jsx("li",{style:ni,children:"Buscando…"}),!j&&B.length===0&&t.jsx("li",{style:ni,children:y.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${y.query}”`}),B.map((X,se)=>{var E,J;return t.jsx("li",{children:t.jsxs("button",{type:"button","data-mention-index":se,onMouseDown:ee=>{ee.preventDefault(),ce(X)},onMouseEnter:()=>U(se),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:se===q?"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:((E=X.name)==null?void 0:E.trim())||`@${X.username}`}),t.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[(J=X.name)!=null&&J.trim()?`@${X.username}`:null,X.email].filter(Boolean).join(" · ")||`@${X.username}`})]})},X.userId)})]}),document.body):null;return t.jsxs("div",{ref:g,style:Of,className:i,children:[t.jsx(Bl,{value:oe,onChange:W,placeholder:l,minHeight:o,instanceId:p,toolbarVariant:b,focusModalZIndex:f}),Z]})}function Ff({value:e,onChange:r,placeholder:n,minHeight:a,onSearchUsers:o,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:h,toolbarVariant:b,focusModalZIndex:f}){return o?t.jsx(ai,{value:e,onChange:r,onSearchUsers:o,onMentionsChange:l,placeholder:n,minHeight:a,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:h,toolbarVariant:b,focusModalZIndex:f}):t.jsx(Bl,{value:e,onChange:r,placeholder:n,minHeight:a,toolbarVariant:b,focusModalZIndex:f})}function _f({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 Pf={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)"}},zf={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 Wf({children:e,tone:r="neutral",size:n="sm",icon:a,dot:o=!1,className:l=""}){const i=Pf[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 ${zf[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 oi={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)"}},jf={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"},qf={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},Uf={xs:148,sm:164,md:184},Vf={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 Xf({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:h,menuClassName:b,optionClassName:f,spinnerClassName:p}){const[g,w]=s.useState(!1),[v,L]=s.useState(!1),[M,S]=s.useState(-1),[H,C]=s.useState({}),y=s.useRef(null),T=s.useRef(null),N=s.useRef(null),_=r.find(F=>F.value===e)??r[0],q={..._!=null&&_.tone?oi[_.tone]:void 0,..._==null?void 0:_.style},U=o||l||r.length===0,D=F=>{i&&F.stopPropagation()},K=s.useCallback(()=>{w(!1),S(-1)},[]),j=s.useCallback(()=>{const F=y.current;if(!F)return;const Y=F.getBoundingClientRect(),ae=Math.max(Y.width,Uf[a]),$=Math.min(Math.max(r.length,1)*38+12,260),W=window.innerHeight-Y.bottom,ce=W<$&&Y.top>W,B=Math.min(Math.max(8,Y.left+Y.width/2-ae/2),window.innerWidth-ae-8);C({position:"fixed",left:B,top:ce?void 0:Y.bottom+6,bottom:ce?window.innerHeight-Y.top+6:void 0,width:ae,zIndex:9999})},[r.length,a]),ie=s.useCallback(F=>{F.disabled||(n(F.value),K())},[K,n]);s.useEffect(()=>L(!0),[]),s.useEffect(()=>{if(!g)return;j();const F=r.findIndex(Y=>Y.value===e);S(F>=0?F:0)},[g,r,j,e]),s.useEffect(()=>{if(!g)return;function F(Y){var $,W;const ae=Y.target;!(($=y.current)!=null&&$.contains(ae))&&!((W=T.current)!=null&&W.contains(ae))&&K()}return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[K,g]),s.useEffect(()=>{if(g)return window.addEventListener("resize",j),window.addEventListener("scroll",j,!0),()=>{window.removeEventListener("resize",j),window.removeEventListener("scroll",j,!0)}},[g,j]),s.useEffect(()=>{if(M<0||!N.current)return;const F=N.current.children[M];F==null||F.scrollIntoView({block:"nearest"})},[M]);function Q(F){if(!U){if(!g){["Enter"," ","ArrowDown","ArrowUp"].includes(F.key)&&(F.preventDefault(),w(!0));return}if(F.key==="Escape"){F.preventDefault(),K();return}if(F.key==="ArrowDown"){F.preventDefault(),S(Y=>Math.min(Y+1,r.length-1));return}if(F.key==="ArrowUp"){F.preventDefault(),S(Y=>Math.max(Y-1,0));return}if(F.key==="Enter"||F.key===" "){F.preventDefault();const Y=r[M];Y&&ie(Y)}}}const fe=t.jsx("div",{ref:T,role:"listbox","aria-label":c,className:Rt("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",b),style:{...H,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:D,onMouseDown:D,onPointerDown:D,children:t.jsx("div",{ref:N,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:r.map((F,Y)=>{const ae=F.value===e,$=Y===M,W={...F.tone?oi[F.tone]:void 0,...F.style};return t.jsxs("button",{type:"button",role:"option","aria-selected":ae,disabled:F.disabled,onMouseEnter:()=>!F.disabled&&S(Y),onMouseDown:ce=>{ce.preventDefault(),ie(F)},className:Rt("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",Vf[a],ae?F.className:void 0,f),style:{...ae?W:void 0,background:ae?W.background??"color-mix(in srgb, var(--primary) 12%, transparent)":$?"var(--bg-hover)":"transparent",color:ae?W.color??"var(--primary)":"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:ae?t.jsx(z.HiCheck,{className:"h-4 w-4"}):null}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:F.label})]},F.value)})})});return t.jsxs("span",{ref:y,className:Rt("relative inline-flex shrink-0 items-center",u),onKeyDown:Q,onClick:D,onPointerDown:D,children:[t.jsx("button",{type:"button",disabled:U,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":g,title:d,onClick:()=>!U&&w(F=>!F),className:Rt("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",jf[a],_==null?void 0:_.className,h),style:q,children:t.jsx("span",{className:"min-w-0 truncate",children:(_==null?void 0:_.label)??e})}),t.jsx(z.HiChevronDown,{"aria-hidden":"true",className:Rt("pointer-events-none absolute opacity-70 transition-transform",qf[a],g?"rotate-180":"rotate-0")}),l&&t.jsx("span",{"aria-hidden":"true",className:Rt("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",p)}),g&&v&&pt.createPortal(fe,document.body)]})}function Yf({tabs:e,activeTabId:r,defaultActiveTabId:n,onTabChange:a,ariaLabel:o="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:d=""}){const u=e.find(g=>!g.disabled)??e[0],h=r??n??(u==null?void 0:u.id),b=e.find(g=>g.id===h)??u,f=g=>{g.disabled||a==null||a(g.id)},p=g=>{const w=e.filter(L=>!L.disabled);if(!w.length||!b)return;const v=w.findIndex(L=>L.id===b.id);(g.key==="ArrowRight"||g.key==="ArrowDown")&&(g.preventDefault(),f(w[(v+1)%w.length])),(g.key==="ArrowLeft"||g.key==="ArrowUp")&&(g.preventDefault(),f(w[(v-1+w.length)%w.length])),g.key==="Home"&&(g.preventDefault(),f(w[0])),g.key==="End"&&(g.preventDefault(),f(w[w.length-1]))};return t.jsxs("div",{className:i,children:[t.jsx("div",{role:"tablist","aria-label":o,onKeyDown:p,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(g=>{const w=g.id===(b==null?void 0:b.id);return t.jsxs("button",{type:"button",role:"tab","aria-selected":w,"aria-controls":`${g.id}-panel`,id:`${g.id}-tab`,disabled:g.disabled,tabIndex:w?0:-1,onClick:()=>f(g),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:w?"var(--primary)":"var(--text-muted)",borderColor:w?"var(--primary)":"transparent",background:l==="pills"&&w?"var(--bg-card)":"transparent"},children:[g.icon&&t.jsx("span",{className:"shrink-0",children:g.icon}),t.jsx("span",{children:g.label}),g.badge&&t.jsx("span",{className:"shrink-0",children:g.badge})]},g.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 ar(...e){return e.filter(Boolean).join(" ")}function Gf({steps:e,activeStepId:r,initialStepId:n,completedStepIds:a,defaultCompletedStepIds:o=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:c,allowBackNavigation:d=!0,showFooter:u=!0,previousLabel:h="Anterior",nextLabel:b="Siguiente",blockedNextLabel:f="Completa este paso",className:p="",headerClassName:g="",contentClassName:w="",footerClassName:v=""}){var se;const L=((se=e[0])==null?void 0:se.id)??"",[M,S]=s.useState(n??L),[H,C]=s.useState(o),y=r??M,T=a??H,N=s.useMemo(()=>new Set(T),[T]),_=Math.max(0,e.findIndex(E=>E.id===y)),q=e[_]??e[0],U=e.length<=1?100:_/(e.length-1)*100,D=E=>{a||C(E),i==null||i(E)},K=E=>{const J=e.find(ee=>ee.id===E);J&&(r||S(E),l==null||l(E,J))},j=E=>N.has(E),ie=E=>e.slice(0,E).find(J=>!J.optional&&!N.has(J.id)),Q=E=>{const J=e[E];return!J||J.disabled?!1:E===_||d&&E<_?!0:!ie(E)},fe=E=>{const J=e.findIndex(ee=>ee.id===E);return J>=0&&Q(J)},F=E=>{const J=e.findIndex(ee=>ee.id===E);if(J<0)return!1;if(!Q(J)){const ee=ie(J);return ee&&(c==null||c(e[J],ee)),!1}return K(E),!0},Y=(E=q==null?void 0:q.id)=>{!E||N.has(E)||D([...T,E])},ae=(E=q==null?void 0:q.id)=>{if(!E)return;const J=e.findIndex(R=>R.id===E),ee=T.filter(R=>{const x=e.findIndex(k=>k.id===R);return x>=0&&x<J});D(ee),J>=0&&_>J&&K(E)},$=()=>_<=0?!1:F(e[_-1].id),W=()=>{const E=e[_+1];return E?F(E.id):!1},ce={activeStep:q,activeIndex:_,completedStepIds:T,isCompleted:j,isUnlocked:fe,completeStep:Y,uncompleteStep:ae,goToStep:F,goNext:W,goPrevious:$};if(!q)return null;const B=e[_+1],oe=_>0,Z=B?fe(B.id):!1,X=typeof q.content=="function"?q.content(ce):q.content;return t.jsxs("section",{className:ar("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",p),children:[t.jsxs("div",{className:ar("border-b border-[var(--border)] bg-[var(--bg-input)]",g),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:`${U}%`}})}),t.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map((E,J)=>{const ee=E.id===q.id,R=j(E.id),x=Q(J),k=ie(J);return t.jsxs("button",{type:"button",disabled:!x,"aria-current":ee?"step":void 0,"aria-disabled":!x,title:!x&&k?`Completa ${k.title}`:E.title,onClick:()=>F(E.id),className:ar("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",R&&!ee&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!ee&&!R&&x&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!x&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[t.jsx("span",{className:ar("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:ar("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)]",R&&!ee&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!R&&!ee&&x&&"border-[var(--border)] text-[var(--text-muted)]",!x&&"border-[var(--border)] text-[var(--text-muted)]"),children:R?t.jsx(z.HiCheck,{className:"h-4 w-4"}):x?J+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:ar("block truncate text-xs font-semibold transition-colors duration-200",ee?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[J+1,". ",E.title]}),E.description&&t.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:E.description})]}),E.badge&&t.jsx("span",{className:"shrink-0",children:E.badge})]})]},E.id)})})]}),t.jsx("div",{className:ar("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",w),children:X},q.id),u&&t.jsxs("div",{className:ar("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",v),children:[t.jsx(Xe,{variant:"secondary",height:38,padding:"0 14px",icon:t.jsx(z.HiChevronLeft,{}),disabled:!oe,onClick:$,children:h}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[t.jsxs("span",{children:["Paso ",_+1," de ",e.length]}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),t.jsxs("span",{children:[T.length," completados"]})]}),t.jsx(Xe,{height:38,padding:"0 14px",icon:t.jsx(z.HiChevronRight,{}),disabled:!B||!Z,onClick:W,children:B&&!Z?f:b})]})]})}const Kf={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 Zf(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Qf(e){const r=getComputedStyle(e),n=Number.parseFloat(r.lineHeight),a=Number.parseFloat(r.paddingTop)+Number.parseFloat(r.paddingBottom),o=Number.parseFloat(r.borderTopWidth)+Number.parseFloat(r.borderBottomWidth);return{lineHeight:Number.isFinite(n)?n:20,paddingY:Number.isFinite(a)?a:12,borderY:Number.isFinite(o)?o:2}}function si(e,r){const{lineHeight:n,paddingY:a,borderY:o}=Qf(e);return Math.ceil(r*n+a+o)}const li=s.forwardRef(function({className:r="",size:n="md",status:a="default",maxHeight:o,maxRows:l,minRows:i=1,style:c,value:d,defaultValue:u,onInput:h,...b},f){const p=s.useRef(null),g=a==="error"?"var(--danger)":a==="success"?"#16a34a":"var(--border)",w=s.useCallback(()=>{const v=p.current;if(!v)return;v.style.height="auto";const L=v.scrollHeight,M=si(v,i),S=o??(l!==void 0?si(v,l):void 0),H=S!==void 0?Math.min(Math.max(L,M),S):Math.max(L,M);v.style.height=`${H}px`,v.style.overflowY=S!==void 0&&L>S?"auto":"hidden"},[o,l,i]);return s.useLayoutEffect(()=>{w()},[w,d,u]),s.useEffect(()=>{const v=p.current;if(!v||typeof ResizeObserver>"u")return;const L=new ResizeObserver(()=>w());return L.observe(v),()=>L.disconnect()},[w]),t.jsx("textarea",{...b,ref:v=>{p.current=v,Zf(f,v)},rows:i,value:d,defaultValue:u,"aria-invalid":a==="error"||b["aria-invalid"],onInput:v=>{w(),h==null||h(v)},style:{...c,borderColor:g,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 ${Kf[n]} ${r}`})});function Jf({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(Qn,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:r,children:t.jsx(li,{...u,required:i,status:o?"error":d,className:`w-full ${c}`})})}const Rf={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"},eb={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function tb(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function rb(e,r){return e!==void 0?String(e).length:r!==void 0?String(r).length:0}const ii=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:h="default",icon:b,action:f,style:p,value:g,defaultValue:w,maxLength:v,onInput:L,...M},S){const H=s.useRef(null),C=rb(g,w),y=u??v,T=!!(b||f||d),N=h==="error"?"var(--danger)":h==="success"?"#16a34a":"var(--border)",_={...p??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},q=()=>{const D=H.current;!D||!l||(D.style.height="auto",D.style.height=`${D.scrollHeight}px`)};s.useEffect(q,[l,g]);const U=t.jsx("textarea",{...M,ref:D=>{H.current=D,tb(S,D)},value:g,defaultValue:w,maxLength:v,"aria-invalid":h==="error"||M["aria-invalid"],onInput:D=>{q(),L==null||L(D)},style:{..._,borderColor:N},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 ${Rf[a]} ${eb[l?"none":o]} ${b?"pl-8":""} ${f?"pr-10":""} ${r}`});return T?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}),U,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:[C,y?`/${y}`:""]})]}):U});function nb({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(Qn,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:r,children:t.jsx(ii,{...u,required:i,status:o?"error":d,className:`w-full ${c}`})})}const ci=[{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 ab(e){return ci[e%ci.length]}let ob=0;function Wo(){return++ob}function di(e,r){return r?r instanceof RegExp?r.test(e):r(e):!0}function sb(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function lb(e,r){const n=r.filter(Boolean);if(n.length===0)return[e.trim()].filter(Boolean);const a=new RegExp(`${n.map(o=>sb(o)).join("|")}|\\r?\\n`,"g");return e.split(a).map(o=>o.trim()).filter(Boolean)}function ib({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:h,helperText:b,helperDisplay:f="inline",error:p,required:g=!1}){const w=e!==void 0,v=!!p,L=!!b&&f==="tooltip"&&!v,[M,S]=s.useState(()=>(r??[]).map((R,x)=>({id:Wo(),value:R.trim(),colorIndex:x})));s.useEffect(()=>{w&&S(R=>{const x=e??[],k=new Map(R.map(te=>[te.value,te]));return x.map((te,de)=>k.get(te)??{id:Wo(),value:te,colorIndex:de})})},[w,e]);const H=M,[C,y]=s.useState(""),[T,N]=s.useState(null),[_,q]=s.useState(""),[U,D]=s.useState(!1),[K,j]=s.useState(!1),ie=s.useRef(null),Q=s.useRef(null),fe=s.useRef(null);function F(){j(!0),setTimeout(()=>j(!1),400)}function Y(R){S(R),n==null||n(R.map(x=>x.value))}function ae(R){let x=H,k=!1,te=!1;for(const de of R){const re=de.trim();if(re){if(c!==void 0&&x.length>=c){te=!0;break}if(!d&&x.some(ge=>ge.value.toLowerCase()===re.toLowerCase())){te=!0;continue}if(!di(re,u)){te=!0;continue}x=[...x,{id:Wo(),value:re,colorIndex:x.length}],k=!0}}return k&&Y(x),te&&F(),k}function $(R){return ae([R])}function W(R){const x=H.filter(k=>k.id!==R);Y(x.map((k,te)=>({...k,colorIndex:te})))}function ce(R,x){const k=x.trim();if(N(null),q(""),!k){W(R);return}if(!(!d&&H.some(te=>te.id!==R&&te.value.toLowerCase()===k.toLowerCase()))){if(!di(k,u)){F();return}Y(H.map(te=>te.id===R?{...te,value:k}:te))}}function B(R){o||(N(R.id),q(R.value),setTimeout(()=>{var x;return(x=Q.current)==null?void 0:x.select()},0))}function oe(R){if(R.key==="Enter"||i.includes(R.key)){R.preventDefault(),$(C)&&y("");return}if(R.key==="Backspace"&&C===""&&H.length>0){R.preventDefault();const x=H[H.length-1];W(x.id)}}function Z(R,x){if(R.key==="Enter"){R.preventDefault(),ce(x,_),setTimeout(()=>{var k;return(k=ie.current)==null?void 0:k.focus()},0);return}R.key==="Escape"&&(R.preventDefault(),N(null),q(""),setTimeout(()=>{var k;return(k=ie.current)==null?void 0:k.focus()},0))}function X(){var R;o||(R=ie.current)==null||R.focus()}function se(R){if(o)return;const x=R.clipboardData.getData("text");if(!x||!(i.some(re=>re&&x.includes(re))||x.includes(`
39
+ `)))return;R.preventDefault();const te=lb(x,i);ae(te)&&y("")}function E(){const R=C.trim();R&&$(R)&&y("")}const J=v?"var(--danger)":U?"var(--primary)":"var(--border)",ee=c!==void 0&&H.length>=c;return t.jsxs("div",{className:`flex flex-col gap-2 ${l}`,children:[(h||g||L)&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[h&&t.jsx("span",{children:h}),g&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),L?t.jsx(Or,{content:b}):null]}),t.jsxs("div",{ref:fe,onClick:X,onFocus:()=>D(!0),onBlur:R=>{var x;(x=fe.current)!=null&&x.contains(R.relatedTarget)||(D(!1),T!==null&&ce(T,_),T===null&&E())},style:{borderColor:J},className:`
40
40
  flex min-h-10 flex-wrap items-center gap-1.5 rounded-lg border
41
41
  bg-[var(--bg-input)] px-2.5 py-2 transition-colors
42
42
  ${o?"cursor-not-allowed opacity-60":"cursor-text"}
@@ -49,7 +49,7 @@ ${z}`,pe=new Blob(["\uFEFF"+ie],{type:"text/csv;charset=utf-8;"}),Me=URL.createO
49
49
  60% { transform: translateX(-3px); }
50
50
  80% { transform: translateX(3px); }
51
51
  }
52
- `}),H.map(J=>{const y=Yf(J.colorIndex);return M===J.id?t.jsx("input",{ref:Q,value:_,disabled:o,onChange:N=>q(N.target.value),onKeyDown:N=>G(N,J.id),onBlur:()=>ce(J.id,_),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(_.length+2,6)}ch`}},J.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:y.bg,color:y.text,border:`1px solid ${y.border}`},children:[t.jsx("span",{className:"truncate",children:J.value}),t.jsx("button",{type:"button","aria-label":`Editar "${J.value}"`,disabled:o,tabIndex:-1,onClick:N=>{N.stopPropagation(),O(J)},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(W.HiPencil,{className:"h-3 w-3"})}),t.jsx("button",{type:"button","aria-label":`Eliminar "${J.value}"`,disabled:o,tabIndex:-1,onClick:N=>{N.stopPropagation(),P(J.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(W.HiXMark,{className:"h-3.5 w-3.5"})})]},J.id)}),!ee&&t.jsx("input",{ref:le,value:E,disabled:o,placeholder:H.length===0?a:"",onChange:J=>x(J.target.value),onKeyDown:oe,onPaste:se,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(Ar,{error:p,helperText:b,helperDisplay:f})]})}const Jf=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;function et(e){return String(e).padStart(2,"0")}function Do(e,r=Fr()){const n=e.trim();if(!n)return r;const a=n.match(Jf);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 un(e,r=!0){const n=`${et(e.hour24)}:${et(e.minute)}`;return r?`${n}:${et(e.second)}`:n}function na(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 fn(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 Rf(e,r){const n=(r==null?void 0:r.use12Hour)??!1,a=(r==null?void 0:r.showSeconds)??!0,o=Do(e);if(n){const l=na(o),i=`${l.hour12}:${et(l.minute)}`;return`${a?`${i}:${et(l.second)}`:i} ${l.meridiem}`}return un(o,a)}function Fr(){const e=new Date;return{hour24:e.getHours(),minute:e.getMinutes(),second:e.getSeconds()}}function eb(e=!0){return un(Fr(),e)}function Oo(e,r){const n=[];for(let a=e;a<=r;a+=1)n.push(a);return n}const xt=36,Ho=5,ti=Math.floor(Ho/2),tb=52,rb=48,Gt=18;function ri(e){return e*xt}function ni(e){return Math.round(e/xt)}function nb(e){return e.use12Hour??e.hour12??!1}function aa({values:e,selected:r,onSelect:n,syncEpochRef:a,forceSyncAt:o=0,width:l=tb,label:i,maxNumeric:c=59,isMeridiem:d=!1,isFocused:u=!1,onFocus:h,onAdvance:b,onBack:f,setColumnRef:p}){const v=s.useRef(null),w=s.useRef(null),g=s.useRef(null),A=s.useRef(""),C=s.useRef(0),T=s.useRef(!1),[H,E]=s.useState(r),[x,M]=s.useState(""),k=s.useCallback(O=>{A.current=O,M(O)},[]),_=s.useMemo(()=>[...Array(ti).fill(""),...e,...Array(ti).fill("")],[e]),q=s.useCallback(()=>{const O=v.current;if(!O)return r;const oe=ni(O.scrollTop),G=Math.min(Math.max(oe,0),e.length-1);return e[G]??r},[r,e]),X=s.useCallback((O,oe=!0)=>{const G=Math.min(Math.max(O,0),e.length-1),U=e[G],se=v.current;!se||!U||(w.current&&(window.clearTimeout(w.current),w.current=null),T.current=!0,C.current=G,se.scrollTop=ri(G),E(U),oe&&U!==r&&n(U))},[n,r,e]);s.useLayoutEffect(()=>{w.current&&(window.clearTimeout(w.current),w.current=null),g.current&&(window.clearTimeout(g.current),g.current=null),k(""),E(r);const O=e.indexOf(r);if(O>=0&&(C.current=O),O<0||!v.current)return;const oe=ri(O);v.current.scrollTop!==oe&&(v.current.scrollTop=oe)},[o,r,k,e]);const D=s.useCallback(()=>{g.current&&(window.clearTimeout(g.current),g.current=null)},[]),K=s.useCallback((O,oe=!1)=>{D(),k("");const G=Number(O);if(!Number.isFinite(G))return;const U=Math.min(c,Math.max(0,G));let se=et(U),S=e.indexOf(se);if(S<0){const R=Math.min(e.length-1,Math.max(0,U-(c===12?1:0)));se=e[R]??se,S=e.indexOf(se)}S>=0&&X(S),oe&&(b==null||b())},[D,c,b,X,k,e]),j=s.useCallback(O=>{const oe=Math.floor(c/10),G=A.current;if(G===""){if(O>oe){K(String(O),!0);return}const se=String(O);k(se),g.current=window.setTimeout(()=>{K(A.current,!0)},1200);return}D();const U=+`${G}${O}`;U<=c?K(String(U),!0):K(String(O),!0)},[D,K,c,k]),le=s.useCallback(O=>{D(),k(""),X(C.current+O)},[D,X,k]),Q=O=>{if(d){O.key==="a"||O.key==="A"?(O.preventDefault(),n("AM"),b==null||b()):O.key==="p"||O.key==="P"?(O.preventDefault(),n("PM"),b==null||b()):O.key==="ArrowUp"||O.key==="ArrowDown"?(O.preventDefault(),n(r==="AM"?"PM":"AM")):O.key==="Tab"&&(O.preventDefault(),O.shiftKey?f==null||f():b==null||b());return}if(/^\d$/.test(O.key)){O.preventDefault(),j(Number(O.key));return}O.key==="ArrowUp"?(O.preventDefault(),le(-1)):O.key==="ArrowDown"?(O.preventDefault(),le(1)):O.key==="Tab"&&(O.preventDefault(),D(),A.current!==""&&K(A.current,!1),O.shiftKey?f==null||f():b==null||b())},fe=s.useCallback(()=>{const O=a.current,oe=v.current;oe&&O===a.current&&X(ni(oe.scrollTop))},[X,a]),F=()=>{if(A.current!=="")return;if(T.current){T.current=!1;const oe=q();E(oe);const G=e.indexOf(oe);G>=0&&(C.current=G);return}E(q()),w.current&&window.clearTimeout(w.current);const O=a.current;w.current=window.setTimeout(()=>{O===a.current&&fe()},100)},V="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",ae=xt*Ho,$=ae+Gt*2,P=x!==""?x:null,ce=P!==null;return t.jsxs("div",{ref:p,role:"spinbutton",tabIndex:u?0:-1,"aria-label":i,"aria-valuetext":P??r,"aria-valuenow":d?void 0:Number(r),onFocus:h,onMouseDown:()=>h==null?void 0:h(),onKeyDown:Q,onBlur:()=>{D(),A.current!==""&&K(A.current,!1)},className:"relative shrink-0 rounded-lg outline-none",style:{width:l,height:$,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:V,style:{top:0,height:Gt,color:"var(--text-muted)",opacity:.35},onClick:()=>le(-1),children:t.jsx(W.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:Gt,height:ae,scrollSnapType:"y mandatory",scrollBehavior:"auto"},onScroll:F,onMouseUp:fe,onTouchEnd:fe,children:_.map((O,oe)=>{const G=O!==""&&O===H;return t.jsx("button",{type:"button",tabIndex:-1,disabled:!O,onClick:()=>{if(!O)return;const U=e.indexOf(O);U>=0&&X(U)},className:"flex w-full items-center justify-center tabular-nums leading-none disabled:cursor-default",style:{height:xt,scrollSnapAlign:"center",color:G?"var(--text-main)":"var(--text-muted)",fontSize:G?16:14,fontWeight:G?600:400,opacity:O?ce?G?0:.35:G?1:.35:0},children:O},`wheel-${oe}-${O}`)})}),P!==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:Gt+ae/2-xt/2,height:xt,color:"var(--text-main)",fontSize:16,background:"var(--bg-card)"},children:P}):null,t.jsx("button",{type:"button","aria-label":"Valor siguiente",className:V,style:{bottom:0,height:Gt,color:"var(--text-muted)",opacity:.35},onClick:()=>le(1),children:t.jsx(W.HiChevronDown,{className:"h-3.5 w-3.5"})})]})}function ai(){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 oi({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 h=i==="popover",b=h||!d,f=nb({use12Hour:n,hour12:a}),p=s.useRef(e),v=Do(e,Fr()),w=na(v),[g,A]=s.useState(et(f?w.hour12:v.hour24)),[C,T]=s.useState(et(v.minute)),[H,E]=s.useState(et(v.second)),[x,M]=s.useState(w.meridiem),[k,_]=s.useState(0),q=s.useRef(0),X=s.useRef(!1),D=s.useRef({hour:null,minute:null,second:null,meridiem:null}),[K,j]=s.useState("hour"),le=s.useMemo(()=>{const re=["hour","minute"];return o&&re.push("second"),f&&re.push("meridiem"),re},[f,o]),Q=s.useCallback(re=>{j(ge=>{const Se=le.indexOf(ge);return le[(Se+re+le.length)%le.length]})},[le]);s.useEffect(()=>{var re;(re=D.current[K])==null||re.focus()},[K]),s.useEffect(()=>{var re;j("hour"),(re=D.current.hour)==null||re.focus()},[]),s.useEffect(()=>{if(e===p.current)return;p.current=e;const re=Do(e,Fr()),ge=na(re);A(et(f?ge.hour12:re.hour24)),T(et(re.minute)),E(et(re.second)),M(ge.meridiem)},[f,e]);const fe=s.useMemo(()=>(f?Oo(1,12):Oo(0,23)).map(re=>et(re)),[f]),F=s.useMemo(()=>Oo(0,59).map(re=>et(re)),[]),V=F,ae=s.useMemo(()=>["AM","PM"],[]),$=s.useCallback(()=>f?fn({hour12:Number(g),minute:Number(C),second:Number(H),meridiem:x}):{hour24:Number(g),minute:Number(C),second:Number(H)},[g,f,x,C,H]),P=s.useCallback(re=>{if(X.current)return;const ge=un(re,o);p.current=ge,r(ge)},[r,o]),ce=s.useCallback(()=>{P($())},[$,P]),O=re=>{A(re),b&&P(f?fn({hour12:Number(re),minute:Number(C),second:Number(H),meridiem:x}):{hour24:Number(re),minute:Number(C),second:Number(H)})},oe=re=>{T(re),b&&P(f?fn({hour12:Number(g),minute:Number(re),second:Number(H),meridiem:x}):{hour24:Number(g),minute:Number(re),second:Number(H)})},G=re=>{E(re),b&&P(f?fn({hour12:Number(g),minute:Number(C),second:Number(re),meridiem:x}):{hour24:Number(g),minute:Number(C),second:Number(re)})},U=re=>{M(re),b&&P(fn({hour12:Number(g),minute:Number(C),second:Number(H),meridiem:re}))},se=s.useCallback(()=>(q.current+=1,_(q.current),q.current),[]),S=s.useCallback(re=>{const ge=na(re),Se=un(re,o);p.current=Se,A(et(f?ge.hour12:re.hour24)),T(et(re.minute)),E(et(re.second)),M(ge.meridiem),r(Se)},[f,r,o]),R=()=>{X.current=!0,se(),S(Fr()),queueMicrotask(()=>{const re=Fr();un(re,o)!==p.current&&(se(),S(re)),X.current=!1})},ee=()=>{ce(),d==null||d()},J=xt*Ho,y=J+Gt*2,N=Gt+J/2-xt/2,te=t.jsx("div",{className:"relative px-4 py-2",children:t.jsxs("div",{className:"relative mx-auto",style:{height:y,maxWidth:"100%"},children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-10 rounded-xl",style:{top:N,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:Gt,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:Gt,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(aa,{syncEpochRef:q,forceSyncAt:k,values:fe,selected:g,onSelect:O,label:"Horas",maxNumeric:f?12:23,isFocused:K==="hour",onFocus:()=>j("hour"),onAdvance:()=>Q(1),onBack:()=>Q(-1),setColumnRef:re=>{D.current.hour=re}}),t.jsx(ai,{}),t.jsx(aa,{syncEpochRef:q,forceSyncAt:k,values:F,selected:C,onSelect:oe,label:"Minutos",maxNumeric:59,isFocused:K==="minute",onFocus:()=>j("minute"),onAdvance:()=>Q(1),onBack:()=>Q(-1),setColumnRef:re=>{D.current.minute=re}}),o?t.jsxs(t.Fragment,{children:[t.jsx(ai,{}),t.jsx(aa,{syncEpochRef:q,forceSyncAt:k,values:V,selected:H,onSelect:G,label:"Segundos",maxNumeric:59,isFocused:K==="second",onFocus:()=>j("second"),onAdvance:()=>Q(1),onBack:()=>Q(-1),setColumnRef:re=>{D.current.second=re}})]}):null,f?t.jsx("div",{className:"ml-3 shrink-0 pl-1",children:t.jsx(aa,{syncEpochRef:q,forceSyncAt:k,values:ae,selected:x,onSelect:re=>U(re),width:rb,label:"AM o PM",isMeridiem:!0,isFocused:K==="meridiem",onFocus:()=>j("meridiem"),onAdvance:()=>Q(1),onBack:()=>Q(-1),setColumnRef:re=>{D.current.meridiem=re}})}):null]})]})}),ue=t.jsxs("div",{className:`flex items-center ${h?"justify-center px-3 py-2":"justify-between gap-2 px-3 py-2.5"}`,style:{borderTop:h?"none":"1px solid color-mix(in srgb, var(--border) 80%, transparent)"},children:[t.jsx(Ke,{variant:"ghost",size:"sm",onClick:R,className:h?"text-xs":void 0,children:"Ahora"}),!h&&(c||d)?t.jsxs("div",{className:"flex items-center gap-2",children:[c?t.jsx(Ke,{variant:"ghost",size:"sm",onClick:c,children:"Cancelar"}):null,d?t.jsx(Ke,{variant:"primary",size:"sm",onClick:ee,children:"Listo"}):null]}):null]});return t.jsxs("div",{className:`overflow-hidden ${u}`,style:{borderRadius:h?12:14,border:h?"1px solid color-mix(in srgb, var(--border) 85%, transparent)":"1px solid var(--border)",background:"var(--bg-card)",boxShadow:h?"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?o?300:260:o?252:212},children:[!h&&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,te,ue]})}function ab(e){return e.use12Hour??e.hour12??!1}function ob({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:h,error:b,helperText:f,helperDisplay:p,className:v,contentClassName:w,className:g=""}){const A=u==="popover",[C,T]=s.useState(!1),H=s.useRef(null),[E,x]=s.useState({horizontal:"left",vertical:"bottom"}),M=ab({use12Hour:a,hour12:o}),k=s.useMemo(()=>r?Rf(r,{use12Hour:M,showSeconds:l}):"",[M,l,r]);s.useEffect(()=>{if(!A||!C||!H.current)return;const X=H.current.getBoundingClientRect(),D=8,K=M?l?300:260:l?252:212,j=276,le=X.left+K>window.innerWidth-D,Q=X.right-K>=D,fe=X.bottom+8+j>window.innerHeight-D,F=X.top-8-j>=D;x({horizontal:le&&Q?"right":"left",vertical:fe&&F?"top":"bottom"})},[M,A,C,l]),s.useEffect(()=>{if(!A||!C)return;function X(K){H.current&&(H.current.contains(K.target)||T(!1))}function D(K){K.key==="Escape"&&T(!1)}return document.addEventListener("mousedown",X),document.addEventListener("keydown",D),()=>{document.removeEventListener("mousedown",X),document.removeEventListener("keydown",D)}},[A,C]);const _=t.jsxs("button",{type:"button",disabled:d,onClick:()=>{d||T(X=>!X)},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 ${g}`,style:{background:"var(--bg-input)",borderColor:b?"var(--danger)":C?"var(--primary)":"var(--border)",color:k?"var(--text-main)":"var(--text-muted)",boxShadow:C?"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(W.HiClock,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:k||c})]}),A?t.jsx(W.HiChevronDown,{className:`h-4 w-4 shrink-0 text-[var(--text-muted)] transition-transform duration-150 ${C?"rotate-180":""}`}):null]}),q=t.jsx(oi,{variant:A?"popover":"panel",value:r||eb(l),onChange:n,use12Hour:M,showSeconds:l,title:i,onClose:()=>T(!1)});return t.jsx(jn,{label:e,required:h,error:b,helperText:f,helperDisplay:p,className:v,contentClassName:w,children:A?t.jsxs("div",{ref:H,className:"relative w-full",children:[_,C?t.jsx("div",{className:"absolute z-50",style:{...E.horizontal==="left"?{left:0}:{right:0},...E.vertical==="bottom"?{top:"calc(100% + 6px)"}:{bottom:"calc(100% + 6px)"}},children:q}):null]}):t.jsxs("div",{className:"space-y-2",children:[_,C?q:null]})})}const sb={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function lb({checked:e,disabled:r,onCheckedChange:n,size:a="sm",className:o="",...l}){const i=sb[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 si=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),ib=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function cb(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 li(e){return e.classList.contains("sidebar-scroll")||e.classList.contains("showcase-nav-scroll")}function ii(e){li(e)&&e.querySelectorAll(".os-scrollbar-horizontal").forEach(r=>{r.style.display="none",r.style.height="0",r.style.pointerEvents="none"})}function db(e){const r=e.querySelector(ib);return r instanceof HTMLElement?r:null}function ci(){return s.useEffect(()=>{const e=new WeakMap;let r=0;const n=()=>{r=0,document.querySelectorAll(si).forEach(l=>{if(!(l instanceof HTMLElement))return;if(Ba.OverlayScrollbars(l)){ii(l);return}if(!cb(l))return;const c={overflow:li(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},d=db(l),u=d?Ba.OverlayScrollbars({target:l,elements:{viewport:d}},c):Ba.OverlayScrollbars(l,c);ii(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(si).forEach(l=>{var i;l instanceof HTMLElement&&((i=e.get(l))==null||i.destroy())})}},[]),null}function or(e){const r=e.trim();return!r||r==="/"||r==="/."?"":(r.startsWith("/")?r:`/${r}`).replace(/\/+$/,"")}function di(e){try{const r=new URL(e);return or(r.pathname)}catch{return""}}function ub(e){const r=or(e);if(!r)return"";const n=r.match(/^\/apps\/[^/]+/i);if(n)return or(n[0]);const a=r.split("/").filter(Boolean);return a.length===0?"":a.length>=2&&a[0].toLowerCase()==="apps"?or(`/${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())?"":or(`/${a[0]}`)}const Bo="primeSuiteAppUrl",fb={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"}},ui={xs:20,sm:28,md:36,lg:48,xl:64},fi=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],bb={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},hb="bonsaif.bot",mb="Bonsaif Bot",pb={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function bi(e){return typeof e=="string"?e.trim():""}function gb(e){var o;if(e!==void 0)return or(e);const r=or(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(Bo)||"";i&&window.sessionStorage.setItem(Bo,i);const c=window.sessionStorage.getItem(Bo)||"",d=i||c;if(d){const u=di(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")?di(a):or(a);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return ub(window.location.pathname)}function vb(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 yb(e){let r=0;for(const n of e)r=r*31+n.charCodeAt(0)&65535;return fi[r%fi.length]}function xb(e,r){return e===hb||r===mb}function wb(e,r){return`${e.replace(/\/$/,"")}${r}`}function hi({userId:e,username:r,name:n,size:a="md",showName:o=!1,showTooltip:l,tooltipContent:i,fallbackLabel:c="Usuario",basePath:d,wrapperClassName:u="",labelClassName:h="",labelSize:b="xs",avatarVersion:f=0,className:p="",style:v}){const[w,g]=s.useState(!1),A=typeof e=="string"&&e.trim()&&e!=="undefined"&&e!=="null"?e.trim():"";s.useEffect(()=>{g(!1)},[A,f]);const{wh:C,text:T}=fb[a],H=bi(n)||bi(r)||c,E=vb(H),x=gb(d),M=xb(r,n),k=wb(x,"/favicon.svg"),_=s.useMemo(()=>{if(!A)return"";const j=new URLSearchParams;j.set("size",String(ui[a])),f&&j.set("v",String(f));const le=j.toString();return`${x}/api/user/avatar/${encodeURIComponent(A)}${le?`?${le}`:""}`},[f,x,A,a]),q=ui[a],X=M?t.jsx("span",{className:`${C} ${pb[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 ${p}`,style:v,children:t.jsx("img",{src:k,alt:H,width:q,height:q,className:"h-full w-full object-contain"})}):_&&!w?t.jsx("img",{src:_,alt:H,width:q,height:q,className:`${C} rounded-full object-cover flex-shrink-0 ${p}`,style:v,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>g(!0)},`${A}-${f}`):t.jsx("span",{className:`${C} ${yb(H)} ${T} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${p}`,style:v,title:H,children:E});if(o)return t.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${u}`,children:[X,t.jsx("span",{className:`min-w-0 truncate ${bb[b]} font-medium text-[var(--text-main)] ${h}`,title:H,children:H})]});const D=l??!0,K=i??H;return D&&K?t.jsx(_t,{as:"span",content:K,className:`inline-flex flex-shrink-0 ${u}`,children:X}):X}function Nb({href:e,className:r,children:n}){return t.jsx("a",{href:e,className:r,children:n})}function kb(e){return e.reduce((r,n)=>{const a=n.section??"Principal";return r[a]=[...r[a]??[],n],r},{})}function mi({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=Nb}){const[h,b]=s.useState(!1),f=kb(r);return t.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[t.jsx(ci,{}),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(W.HiBars3,{className:"h-5 w-5"})}),h&&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 ${h?"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(W.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:()=>b(!1),children:t.jsx(W.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(([p,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(W.HiChevronDown,{className:"h-3.5 w-3.5"}),p]}),t.jsx("div",{className:"space-y-1",children:v.map(w=>{const g=n===w.href||n.startsWith(`${w.href}/`);return t.jsxs(u,{href:w.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${g?"bg-white/10 text-white":"text-white/55 hover:bg-white/[0.06] hover:text-white/85"}`,children:[t.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:w.icon??t.jsx(W.HiHome,{className:"h-4 w-4"})}),t.jsx("span",{className:"truncate",children:w.label})]},w.href)})})]},p))})}),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(hi,{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(Ke,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:d,children:[t.jsx(W.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 pi="bonsaif-ui:prime-auth-sso",Sb={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"},Io={dashboard:t.jsx(W.HiChartBar,{className:"h-5 w-5"}),tickets:t.jsx(W.HiTicket,{className:"h-5 w-5"}),teams:t.jsx(W.HiUsers,{className:"h-5 w-5"}),projects:t.jsx(W.HiRectangleGroup,{className:"h-5 w-5"}),clients:t.jsx(W.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:t.jsx(W.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:t.jsx(W.HiUser,{className:"h-5 w-5"}),settings:t.jsx(W.HiCog6Tooth,{className:"h-5 w-5"}),notifications:t.jsx(W.HiBell,{className:"h-5 w-5"}),changelog:t.jsx(W.HiDocumentText,{className:"h-5 w-5"}),admin:t.jsx(W.HiShieldCheck,{className:"h-5 w-5"}),users:t.jsx(W.HiUsers,{className:"h-5 w-5"}),roles:t.jsx(W.HiShieldCheck,{className:"h-5 w-5"}),menus:t.jsx(W.HiCog6Tooth,{className:"h-5 w-5"}),guards:t.jsx(W.HiCalendarDays,{className:"h-5 w-5"}),vacations:t.jsx(W.HiCalendarDays,{className:"h-5 w-5"}),audit:t.jsx(W.HiListBullet,{className:"h-5 w-5"}),positions:t.jsx(W.HiBriefcase,{className:"h-5 w-5"}),ranks:t.jsx(W.HiListBullet,{className:"h-5 w-5"}),"email-inbox":t.jsx(W.HiInbox,{className:"h-5 w-5"}),"security-incidents":t.jsx(W.HiShieldCheck,{className:"h-5 w-5"})};function Cb(e){return e.split("-").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function Eb(e){return/^\d+$/.test(e)||/^[a-f0-9]{8,}$/i.test(e)}function Mb(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=Eb(n)&&a?a:n,l=Sb[o]??Cb(o);return[{label:"Inicio",href:"/"},{label:l}]}function Fo(e){return(e==null?void 0:e.querySelector(":scope > .os-viewport"))??(e==null?void 0:e.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function Tb(e){const r=e.split("/").filter(Boolean),n=r[r.length-1];if(!n)return t.jsx(W.HiHome,{className:"h-5 w-5"});if(Io[n])return Io[n];const a=r.length>1?r[r.length-2]:"";return Io[a]??t.jsx(W.HiHome,{className:"h-5 w-5"})}function $b(e){return e.includes("primeAuthOrigin")||e.includes("primeAuthProjectKey")}function gi(){if(typeof window>"u")return!1;if($b(window.location.href)){try{window.sessionStorage.setItem(pi,"true")}catch{}return!0}try{return window.sessionStorage.getItem(pi)==="true"}catch{return!1}}function Ab({title:e,subtitle:r,action:n,meta:a,icon:o,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:d,showBreadcrumbs:u=!0,contained:h=!1}){const b=s.useRef(null),[f,p]=s.useState(!1),[v,w]=s.useState(d??"/"),[g,A]=s.useState(()=>gi()),[C,T]=s.useState(null),H=d??v,E=c??Mb(H),x=o??Tb(H),M=u&&!g&&E.length>1,k=!M;s.useEffect(()=>{d||w(window.location.pathname)},[d]),s.useEffect(()=>{A(gi())},[]),s.useEffect(()=>{if(h){p(!1);return}let q=null,X=0,D=0;const K=()=>{const Q=b.current,fe=document.querySelector("[data-app-scroll='true']");return(Q==null?void 0:Q.closest(".os-viewport"))??(Q==null?void 0:Q.closest("[data-overlayscrollbars-viewport]"))??Fo(fe)??fe??window},j=()=>{const Q=q&&q!==window?q.scrollTop:window.scrollY;p(fe=>fe?Q>24:Q>72)},le=()=>{q==null||q.removeEventListener("scroll",j),q=K(),q.addEventListener("scroll",j,{passive:!0}),j()};return le(),X=window.requestAnimationFrame(le),D=window.setTimeout(le,120),()=>{window.cancelAnimationFrame(X),window.clearTimeout(D),q==null||q.removeEventListener("scroll",j)}},[h]),s.useEffect(()=>{if(h){T(null);return}let q=0;const X=[],D=()=>{const V=b.current,ae=V==null?void 0:V.parentElement,$=document.querySelector("[data-app-scroll='true']"),P=Fo($)??$;if(!V||!ae||!P){T(null);return}const ce=ae.getBoundingClientRect(),O=window.getComputedStyle(ae),oe=P.getBoundingClientRect(),G=P instanceof HTMLElement&&P.clientWidth>0?P.clientWidth:oe.width,U=ce.left+parseFloat(O.paddingLeft||"0"),se={marginLeft:Math.round(oe.left-U),width:Math.round(G)};T(S=>S&&S.marginLeft===se.marginLeft&&S.width===se.width?S:se)},K=()=>{window.cancelAnimationFrame(q),q=window.requestAnimationFrame(D)};K(),window.addEventListener("resize",K);const j=new ResizeObserver(K),le=b.current,Q=le==null?void 0:le.parentElement,fe=document.querySelector("[data-app-scroll='true']"),F=Fo(fe)??fe;return[Q,fe,F].forEach(V=>{V&&j.observe(V)}),X.push(window.setTimeout(K,120)),X.push(window.setTimeout(K,280)),()=>{window.cancelAnimationFrame(q),window.removeEventListener("resize",K),j.disconnect(),X.forEach(V=>window.clearTimeout(V))}},[h]);const _={...C?{marginLeft:C.marginLeft,width:C.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:h?"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:h||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 ${h?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${l}`,style:_,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":k?"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||k?"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||k?"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:M?"var(--text-secondary)":"var(--text-muted)"},children:x}),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(ls.Provider,{value:{compact:!0,headerAction:!0},children:n})})]})})}function Lb({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(mi,{currentPath:r,...a,children:e})}function vi(){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 Db(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 Ob({name:e,src:r,projectKey:n}){const[a,o]=s.useState("system"),l=s.useRef(null);s.useEffect(()=>{o(vi());const d=new MutationObserver(()=>o(vi()));return d.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>d.disconnect()},[]);const i=s.useMemo(()=>Db(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(h){var p,v,w;if(h.source!==((p=l.current)==null?void 0:p.contentWindow)||c&&h.origin!==c)return;if(((v=h.data)==null?void 0:v.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!h.data.active}}));return}if(((w=h.data)==null?void 0:w.type)!=="prime-microservice:navigation")return;const b=h.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 Hb(){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:yi(c.data.width,96,720),height:yi(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 yi(e,r,n){const a=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(r,Math.min(n,Math.ceil(a)))}function Bb(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 Ib(){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 Fb(){return"light"}function _b({position:e="bottom-center"}){const r=s.useSyncExternalStore(Bb,Ib,Fb);return t.jsx(Ia.Toaster,{position:e,theme:r,richColors:!0,closeButton:!0})}function Pb({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 bn=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function xi(e,r){return e.color??bn[r%bn.length]}function jt(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 _r(e){if(e==null||e==="")return null;const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?r:null}const _o={warning:70,danger:90};function oa(e,r=_o){const n=r.warning??_o.warning,a=r.danger??_o.danger;return e>=a?"danger":e>=n?"warning":e<=0?"primary":"success"}function hn(e,r){return jt(oa(e,r))}function Pr(e,r=0){return Number.isFinite(e)?`${e.toFixed(r)}%`:"—"}function zr(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 wi(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 Wr(e,r){var n;for(let a=e.length-1;a>=0;a-=1){const o=_r((n=e[a])==null?void 0:n[r]);if(o!==null)return o}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 sr=680,hr="ease-out",zb={top:18,right:8,bottom:12,left:0};function mn(e){return{...zb,...e}}function pn(e){return e.map((r,n)=>({...r,color:xi(r,n),label:r.label??r.key}))}function sa(e,r){return!e.length||!r.length||e.every(n=>r.every(a=>_r(n[a.key])===null))}function St(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function gn(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function Ni(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function la(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function Wb(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 ki(e){return`bonsaif-grad-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function jb({active:e,label:r,payload:n,valueFormat:a=wt}){var c,d,u,h,b,f;if(!e||!(n!=null&&n.length))return null;const o=n.filter(p=>p.dataKey!=="base"&&p.name!=="base"&&p.value!==null&&p.value!==void 0);if(!o.length)return null;const l=((d=(c=o[0])==null?void 0:c.payload)==null?void 0:d.fullName)??((h=(u=o[0])==null?void 0:u.payload)==null?void 0:h.tooltipLabel)??((f=(b=o[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:o.map((p,v)=>{const w=p.payload,g=w&&typeof w.display=="number"?w.display:p.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:p.color??"var(--primary)"}}),p.name??p.dataKey]}),t.jsx("span",{className:"bonsaif-chart-tooltip-value",children:Wb(g,a)})]},String(p.dataKey??p.name??v))})})]})}function jr({valueFormat:e,content:r,cursor:n,offset:a=12,wrapperStyle:o,allowEscapeViewBox:l,reverseDirection:i,...c}){return t.jsx(Te.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(jb,{valueFormat:e})})}function Si(e,r,n){return n==null?-1:e.findIndex(a=>String(a[r])===String(n))}function Ci(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 ia(e,r,n={}){const{zoomable:a=!1,zoomMode:o="both",brushHeight:l=28,onZoomChange:i}=n,[c,d]=s.useState(null),[u,h]=s.useState(null),b=!!a&&e.length>1,f=b&&(o==="brush"||o==="both"),p=b&&(o==="drag"||o==="both"),v=s.useCallback(X=>{d(X),i==null||i(X)},[i]),w=s.useCallback(()=>{h(null),v(null)},[v]),g=!!c,A=s.useMemo(()=>!c||f?e:e.slice(c.startIndex,c.endIndex+1),[e,f,c]),C=s.useCallback((X,D)=>{const K=Si(e,r,X),j=Si(e,r,D);K<0||j<0||v(Ci(K,j,e.length))},[v,e,r]),T=s.useCallback(X=>{p&&((X==null?void 0:X.activeLabel)===void 0||(X==null?void 0:X.activeLabel)===null||h({leftLabel:X.activeLabel,rightLabel:X.activeLabel}))},[p]),H=s.useCallback(X=>{!p||!u||(X==null?void 0:X.activeLabel)===void 0||(X==null?void 0:X.activeLabel)===null||h(D=>D&&{...D,rightLabel:X.activeLabel})},[u,p]),E=s.useCallback(()=>{if(p){if(!u||u.rightLabel===null||u.rightLabel===void 0){h(null);return}C(u.leftLabel,u.rightLabel),h(null)}},[C,u,p]),x=s.useCallback(X=>{if(f){if(!X){v(null);return}v(Ci(X.startIndex??0,X.endIndex??e.length-1,e.length))}},[v,e.length,f]),M=p?{onMouseDown:T,onMouseMove:H,onMouseUp:E,onMouseLeave:()=>{u&&E()}}:{},k=c??{startIndex:0,endIndex:Math.max(0,e.length-1)},_=t.jsxs(t.Fragment,{children:[p&&u&&u.rightLabel!==null&&u.rightLabel!==void 0?t.jsx(Te.ReferenceArea,{x1:u.leftLabel,x2:u.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,f?t.jsx(Te.Brush,{dataKey:r,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:k.startIndex,endIndex:k.endIndex,onChange:x,tickFormatter:X=>String(X)}):null]}),q=f?{bottom:Math.max(l+10,36)}:void 0;return{enabled:b,showBrush:f,showDrag:p,viewData:A,isZoomed:g,resetZoom:w,chartHandlers:M,zoomNodes:_,marginExtra:q}}function ca({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 qb({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:h,valueFormat:b=wt,yDomain:f,ariaLabel:p="Gráfico de líneas",curve:v=!0,strokeWidth:w=2.25,zoomable:g=!1,zoomMode:A="both",brushHeight:C,onZoomChange:T}){const H=sa(e,n),E=pn(n),x=ia(e,r,{zoomable:g,zoomMode:A,brushHeight:C,onZoomChange:T}),M=mn({...h,...x.marginExtra});return l?t.jsx(Nt,{height:a}):H?t.jsx(kt,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${o}`,role:"img","aria-label":p,style:{height:a},children:[t.jsx(ca,{visible:x.isZoomed,onReset:x.resetZoom}),t.jsx(Te.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Te.LineChart,{data:x.viewData,margin:M,...x.chartHandlers,children:[c?t.jsx(Te.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Te.XAxis,{dataKey:r,tick:St(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Te.YAxis,{tick:St(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:k=>b(Number(k)),dx:-2}),u?t.jsx(jr,{valueFormat:b,cursor:{stroke:Ni(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Te.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:la()}):null,E.map((k,_)=>t.jsx(Te.Line,{type:v?"monotone":"linear",dataKey:k.key,name:k.label,stroke:k.color,strokeWidth:_===0?w+.35:w,strokeOpacity:_===0?1:.88,isAnimationActive:!0,animationDuration:sr,animationEasing:hr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:k.color}},k.key)),x.zoomNodes]})})]})}function da({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:h,valueFormat:b=wt,yDomain:f,ariaLabel:p="Gráfico de área",stacked:v=!1,opacity:w=.22,zoomable:g=!1,zoomMode:A="both",brushHeight:C,onZoomChange:T}){const H=sa(e,n),E=pn(n),x=ia(e,r,{zoomable:g,zoomMode:A,brushHeight:C,onZoomChange:T}),M=mn({...h,...x.marginExtra});return l?t.jsx(Nt,{height:a}):H?t.jsx(kt,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${o}`,role:"img","aria-label":p,style:{height:a},children:[t.jsx(ca,{visible:x.isZoomed,onReset:x.resetZoom}),t.jsx(Te.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Te.AreaChart,{data:x.viewData,margin:M,...x.chartHandlers,children:[t.jsx("defs",{children:E.map(k=>t.jsxs("linearGradient",{id:ki(k.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:k.color,stopOpacity:Math.min(.55,w+.28)}),t.jsx("stop",{offset:"48%",stopColor:k.color,stopOpacity:w*.5}),t.jsx("stop",{offset:"100%",stopColor:k.color,stopOpacity:0})]},k.key))}),c?t.jsx(Te.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Te.XAxis,{dataKey:r,tick:St(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Te.YAxis,{tick:St(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:k=>b(Number(k)),dx:-2}),u?t.jsx(jr,{valueFormat:b,cursor:{stroke:Ni(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Te.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:la()}):null,E.map(k=>t.jsx(Te.Area,{type:"monotone",dataKey:k.key,name:k.label,stroke:k.color,fill:`url(#${ki(k.key)})`,strokeWidth:2.25,stackId:v?"stack":void 0,isAnimationActive:!0,animationDuration:sr,animationEasing:hr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:k.color}},k.key)),x.zoomNodes]})})]})}function Ub({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:h,valueFormat:b=wt,yDomain:f,ariaLabel:p="Gráfico de barras",layout:v="vertical",mode:w="grouped",barRadius:g=6,categoryAxisWidth:A=64,zoomable:C=!1,zoomMode:T="both",brushHeight:H,onZoomChange:E}){const x=sa(e,n),M=pn(n),k=v==="horizontal",_=ia(e,r,{zoomable:C&&!k,zoomMode:T,brushHeight:H,onZoomChange:E}),q=mn({...h,..._.marginExtra});return l?t.jsx(Nt,{height:a}):x?t.jsx(kt,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${o}`,role:"img","aria-label":p,style:{height:a},children:[t.jsx(ca,{visible:_.isZoomed,onReset:_.resetZoom}),t.jsx(Te.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Te.BarChart,{data:_.viewData,margin:q,layout:k?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,..._.chartHandlers,children:[c?t.jsx(Te.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),horizontal:!k,vertical:k}):null,k?t.jsxs(t.Fragment,{children:[t.jsx(Te.XAxis,{type:"number",tick:St(),tickLine:!1,axisLine:!1,tickFormatter:X=>b(Number(X)),domain:f??["auto","auto"]}),t.jsx(Te.YAxis,{type:"category",dataKey:r,tick:St(),tickLine:!1,axisLine:!1,width:A})]}):t.jsxs(t.Fragment,{children:[t.jsx(Te.XAxis,{dataKey:r,tick:St(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Te.YAxis,{tick:St(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:X=>b(Number(X)),dx:-2})]}),u?t.jsx(jr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,d?t.jsx(Te.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:la()}):null,M.map((X,D)=>t.jsx(Te.Bar,{dataKey:X.key,name:X.label,fill:X.color,fillOpacity:D===0?1:.82,radius:k?[0,g,g,0]:[g,g,2,2],maxBarSize:20,stackId:w==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:sr,animationEasing:hr},X.key)),_.zoomNodes]})})]})}function Vb(e){return t.jsx(Mi,{...e,variant:"pie"})}function Xb(e){return t.jsx(Mi,{...e,variant:"donut",innerRadius:e.innerRadius??.62,cornerRadius:e.cornerRadius??10,padAngle:e.padAngle??2})}function Ei(e,r){return e==null||!Number.isFinite(e)?r:e>0&&e<=1?e*100:e}function Mi({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=wt,ariaLabel:h,innerRadius:b,outerRadius:f,colors:p=[...bn],padAngle:v,cornerRadius:w,variant:g}){const A=e.map((D,K)=>({name:String(D[r]??""),value:_r(D[n])??0,fill:p[K%p.length],row:D})).filter(D=>D.value>0),C=!A.length,T=g==="donut",H=A.length,E=Ei(b,T?62:12),x=Ei(f,78),M=Math.min(v??(T?2:3),Math.max(.5,10/Math.max(1,H))),k=Math.min(w??(T?10:8),Math.max(2,36/Math.max(1,H)));if(l)return t.jsx(Nt,{height:a});if(C)return t.jsx(kt,{height:a,text:i});const _=A.reduce((D,K)=>D+K.value,0),q=c?Math.min(96,28+Math.ceil(H/3)*22):0,X=Math.max(140,a-q);return t.jsx("div",{className:`bonsaif-chart bonsaif-${g}-chart w-full ${o}`,role:"img","aria-label":h??(g==="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:X},children:t.jsx(Te.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Te.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[d?t.jsx(jr,{valueFormat:u,isAnimationActive:!1}):null,t.jsx(Te.Pie,{data:A,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${E}%`,outerRadius:`${x}%`,startAngle:90,endAngle:-270,paddingAngle:M,cornerRadius:k,minAngle:H>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:sr,animationEasing:hr,label:!1,activeShape:Yb,children:A.map(D=>t.jsx(Te.Cell,{fill:D.fill},D.name))}),T?t.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:u(_)}):null]})})}),c?t.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:A.map(D=>t.jsxs("li",{className:"bonsaif-pie-legend-item",children:[t.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:D.fill},"aria-hidden":!0}),t.jsx("span",{className:"bonsaif-pie-legend-label",title:D.name,children:D.name}),t.jsx("span",{className:"bonsaif-pie-legend-value",children:u(D.value)})]},D.name))}):null]})})}function Yb(e){const{outerRadius:r=0,...n}=e;return t.jsx(Te.Sector,{...n,outerRadius:Number(r)+4,stroke:"var(--bg-card)",strokeWidth:2})}function Kb({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??jt(o),h=e.map(x=>_r(x[r])).filter(x=>x!==null);if(h.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,p=3,v=1,w=Math.min(...h),A=Math.max(...h)-w||1,C=h.map((x,M)=>{const k=v+M/(h.length-1)*(b-v*2),_=f-p-(x-w)/A*(f-p*2);return{x:k,y:_}}),T=C.map((x,M)=>`${M===0?"M":"L"}${x.x.toFixed(2)} ${x.y.toFixed(2)}`).join(" "),H=`${T} L${C[C.length-1].x.toFixed(2)} ${f} L${C[0].x.toFixed(2)} ${f} Z`,E=`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 ${b} ${f}`,preserveAspectRatio:"none",focusable:"false",children:[i?t.jsx("defs",{children:t.jsxs("linearGradient",{id:E,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:H,fill:`url(#${E})`}):null,t.jsx("path",{d:T,fill:"none",stroke:u,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function Gb({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:h=!0,showTooltip:b=!0,margin:f,valueFormat:p=wt,yDomain:v,ariaLabel:w="Gráfico combinado",barRadius:g=6,zoomable:A=!1,zoomMode:C="both",brushHeight:T,onZoomChange:H}){const E=a??n.slice(0,Math.max(1,n.length-1)),x=o??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),M=[...E,...x.filter(j=>!E.some(le=>le.key===j.key))],k=sa(e,M),_=pn(E),q=pn(M),X=x.map(j=>{var Q;const le=q.find(fe=>fe.key===j.key);return{...j,label:j.label??j.key,color:j.color??(le==null?void 0:le.color)??((Q=q[0])==null?void 0:Q.color)}}),D=ia(e,r,{zoomable:A,zoomMode:C,brushHeight:T,onZoomChange:H}),K=mn({...f,...D.marginExtra});return c?t.jsx(Nt,{height:l}):k?t.jsx(kt,{height:l,text:d}):t.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":w,style:{height:l},children:[t.jsx(ca,{visible:D.isZoomed,onReset:D.resetZoom}),t.jsx(Te.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Te.ComposedChart,{data:D.viewData,margin:K,barCategoryGap:"34%",...D.chartHandlers,children:[u?t.jsx(Te.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Te.XAxis,{dataKey:r,tick:St(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Te.YAxis,{tick:St(),tickLine:!1,axisLine:!1,width:44,domain:v??["auto","auto"],tickFormatter:j=>p(Number(j)),dx:-2}),b?t.jsx(jr,{valueFormat:p,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,h?t.jsx(Te.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:la()}):null,_.map(j=>t.jsx(Te.Bar,{dataKey:j.key,name:j.label,fill:j.color,fillOpacity:.88,radius:[g,g,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:sr,animationEasing:hr},j.key)),X.map(j=>t.jsx(Te.Line,{type:"monotone",dataKey:j.key,name:j.label,stroke:j.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:sr,animationEasing:hr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:j.color}},j.key)),D.zoomNodes]})})]})}function Zb({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:h,valueFormat:b=wt,ariaLabel:f="Gráfico waterfall",increaseColor:p="#34d399",decreaseColor:v="#f87171",totalColor:w="var(--primary)"}){const g=s.useMemo(()=>Qb(e,{xKey:r,valueKey:n,typeKey:a,increaseColor:p,decreaseColor:v,totalColor:w}),[e,r,n,a,p,v,w]),A=!g.length,C=mn(h);return i?t.jsx(Nt,{height:o}):A?t.jsx(kt,{height:o,text:c}):t.jsx("div",{className:`bonsaif-chart bonsaif-waterfall-chart w-full ${l}`,role:"img","aria-label":f,style:{height:o},children:t.jsx(Te.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Te.BarChart,{data:g,margin:C,barCategoryGap:"42%",children:[d?t.jsx(Te.CartesianGrid,{strokeDasharray:"2 8",stroke:gn(),vertical:!1}):null,t.jsx(Te.XAxis,{dataKey:"label",tick:St(),tickLine:!1,axisLine:!1,interval:0,dy:6}),t.jsx(Te.YAxis,{tick:St(),tickLine:!1,axisLine:!1,width:44,tickFormatter:T=>b(Number(T)),dx:-2}),u?t.jsx(jr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,t.jsx(Te.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),t.jsx(Te.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:sr,animationEasing:hr,children:g.map(T=>t.jsx(Te.Cell,{fill:T.color},T.label))})]})})})}function Qb(e,r){let n=0;return e.map((a,o)=>{const l=_r(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,h=0,b=l;return c&&i==="total"?(d="total",u=0,h=Math.abs(l),b=l,n=l):c&&o===e.length-1&&!i?(d="total",u=0,h=Math.abs(n),b=n):(d=i==="decrease"||l<0?"decrease":"increase",d==="decrease"?(u=n+l,h=Math.abs(l),n=n+l):(u=n,h=Math.abs(l),n=n+l),b=l),{label:String(a[r.xKey]??""),base:u,delta:h,display:b,kind:d,color:d==="total"?r.totalColor:d==="decrease"?r.decreaseColor:r.increaseColor}})}const Ti="bonsaif-funnel-chart-keyframes",Jb=`
52
+ `}),H.map(R=>{const x=ab(R.colorIndex);return T===R.id?t.jsx("input",{ref:Q,value:_,disabled:o,onChange:k=>q(k.target.value),onKeyDown:k=>Z(k,R.id),onBlur:()=>ce(R.id,_),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(_.length+2,6)}ch`}},R.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:x.bg,color:x.text,border:`1px solid ${x.border}`},children:[t.jsx("span",{className:"truncate",children:R.value}),t.jsx("button",{type:"button","aria-label":`Editar "${R.value}"`,disabled:o,tabIndex:-1,onClick:k=>{k.stopPropagation(),B(R)},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 "${R.value}"`,disabled:o,tabIndex:-1,onClick:k=>{k.stopPropagation(),W(R.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"})})]},R.id)}),!ee&&t.jsx("input",{ref:ie,value:C,disabled:o,placeholder:H.length===0?a:"",onChange:R=>y(R.target.value),onKeyDown:oe,onPaste:se,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(Hr,{error:p,helperText:b,helperDisplay:f})]})}const cb=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;function rt(e){return String(e).padStart(2,"0")}function jo(e,r=Wr()){const n=e.trim();if(!n)return r;const a=n.match(cb);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 xn(e,r=!0){const n=`${rt(e.hour24)}:${rt(e.minute)}`;return r?`${n}:${rt(e.second)}`:n}function fa(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 wn(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 db(e,r){const n=(r==null?void 0:r.use12Hour)??!1,a=(r==null?void 0:r.showSeconds)??!0,o=jo(e);if(n){const l=fa(o),i=`${l.hour12}:${rt(l.minute)}`;return`${a?`${i}:${rt(l.second)}`:i} ${l.meridiem}`}return xn(o,a)}function Wr(){const e=new Date;return{hour24:e.getHours(),minute:e.getMinutes(),second:e.getSeconds()}}function ub(e=!0){return xn(Wr(),e)}function qo(e,r){const n=[];for(let a=e;a<=r;a+=1)n.push(a);return n}const kt=36,Uo=5,ui=Math.floor(Uo/2),fb=52,bb=48,Kt=18;function fi(e){return e*kt}function bi(e){return Math.round(e/kt)}function hb(e){return e.use12Hour??e.hour12??!1}function ba({values:e,selected:r,onSelect:n,syncEpochRef:a,forceSyncAt:o=0,width:l=fb,label:i,maxNumeric:c=59,isMeridiem:d=!1,isFocused:u=!1,onFocus:h,onAdvance:b,onBack:f,setColumnRef:p}){const g=s.useRef(null),w=s.useRef(null),v=s.useRef(null),L=s.useRef(""),M=s.useRef(0),S=s.useRef(!1),[H,C]=s.useState(r),[y,T]=s.useState(""),N=s.useCallback(B=>{L.current=B,T(B)},[]),_=s.useMemo(()=>[...Array(ui).fill(""),...e,...Array(ui).fill("")],[e]),q=s.useCallback(()=>{const B=g.current;if(!B)return r;const oe=bi(B.scrollTop),Z=Math.min(Math.max(oe,0),e.length-1);return e[Z]??r},[r,e]),U=s.useCallback((B,oe=!0)=>{const Z=Math.min(Math.max(B,0),e.length-1),X=e[Z],se=g.current;!se||!X||(w.current&&(window.clearTimeout(w.current),w.current=null),S.current=!0,M.current=Z,se.scrollTop=fi(Z),C(X),oe&&X!==r&&n(X))},[n,r,e]);s.useLayoutEffect(()=>{w.current&&(window.clearTimeout(w.current),w.current=null),v.current&&(window.clearTimeout(v.current),v.current=null),N(""),C(r);const B=e.indexOf(r);if(B>=0&&(M.current=B),B<0||!g.current)return;const oe=fi(B);g.current.scrollTop!==oe&&(g.current.scrollTop=oe)},[o,r,N,e]);const D=s.useCallback(()=>{v.current&&(window.clearTimeout(v.current),v.current=null)},[]),K=s.useCallback((B,oe=!1)=>{D(),N("");const Z=Number(B);if(!Number.isFinite(Z))return;const X=Math.min(c,Math.max(0,Z));let se=rt(X),E=e.indexOf(se);if(E<0){const J=Math.min(e.length-1,Math.max(0,X-(c===12?1:0)));se=e[J]??se,E=e.indexOf(se)}E>=0&&U(E),oe&&(b==null||b())},[D,c,b,U,N,e]),j=s.useCallback(B=>{const oe=Math.floor(c/10),Z=L.current;if(Z===""){if(B>oe){K(String(B),!0);return}const se=String(B);N(se),v.current=window.setTimeout(()=>{K(L.current,!0)},1200);return}D();const X=+`${Z}${B}`;X<=c?K(String(X),!0):K(String(B),!0)},[D,K,c,N]),ie=s.useCallback(B=>{D(),N(""),U(M.current+B)},[D,U,N]),Q=B=>{if(d){B.key==="a"||B.key==="A"?(B.preventDefault(),n("AM"),b==null||b()):B.key==="p"||B.key==="P"?(B.preventDefault(),n("PM"),b==null||b()):B.key==="ArrowUp"||B.key==="ArrowDown"?(B.preventDefault(),n(r==="AM"?"PM":"AM")):B.key==="Tab"&&(B.preventDefault(),B.shiftKey?f==null||f():b==null||b());return}if(/^\d$/.test(B.key)){B.preventDefault(),j(Number(B.key));return}B.key==="ArrowUp"?(B.preventDefault(),ie(-1)):B.key==="ArrowDown"?(B.preventDefault(),ie(1)):B.key==="Tab"&&(B.preventDefault(),D(),L.current!==""&&K(L.current,!1),B.shiftKey?f==null||f():b==null||b())},fe=s.useCallback(()=>{const B=a.current,oe=g.current;oe&&B===a.current&&U(bi(oe.scrollTop))},[U,a]),F=()=>{if(L.current!=="")return;if(S.current){S.current=!1;const oe=q();C(oe);const Z=e.indexOf(oe);Z>=0&&(M.current=Z);return}C(q()),w.current&&window.clearTimeout(w.current);const B=a.current;w.current=window.setTimeout(()=>{B===a.current&&fe()},100)},Y="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",ae=kt*Uo,$=ae+Kt*2,W=y!==""?y:null,ce=W!==null;return t.jsxs("div",{ref:p,role:"spinbutton",tabIndex:u?0:-1,"aria-label":i,"aria-valuetext":W??r,"aria-valuenow":d?void 0:Number(r),onFocus:h,onMouseDown:()=>h==null?void 0:h(),onKeyDown:Q,onBlur:()=>{D(),L.current!==""&&K(L.current,!1)},className:"relative shrink-0 rounded-lg outline-none",style:{width:l,height:$,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:Y,style:{top:0,height:Kt,color:"var(--text-muted)",opacity:.35},onClick:()=>ie(-1),children:t.jsx(z.HiChevronUp,{className:"h-3.5 w-3.5"})}),t.jsx("div",{ref:g,className:"absolute inset-x-0 overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",style:{top:Kt,height:ae,scrollSnapType:"y mandatory",scrollBehavior:"auto"},onScroll:F,onMouseUp:fe,onTouchEnd:fe,children:_.map((B,oe)=>{const Z=B!==""&&B===H;return t.jsx("button",{type:"button",tabIndex:-1,disabled:!B,onClick:()=>{if(!B)return;const X=e.indexOf(B);X>=0&&U(X)},className:"flex w-full items-center justify-center tabular-nums leading-none disabled:cursor-default",style:{height:kt,scrollSnapAlign:"center",color:Z?"var(--text-main)":"var(--text-muted)",fontSize:Z?16:14,fontWeight:Z?600:400,opacity:B?ce?Z?0:.35:Z?1:.35:0},children:B},`wheel-${oe}-${B}`)})}),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:Kt+ae/2-kt/2,height:kt,color:"var(--text-main)",fontSize:16,background:"var(--bg-card)"},children:W}):null,t.jsx("button",{type:"button","aria-label":"Valor siguiente",className:Y,style:{bottom:0,height:Kt,color:"var(--text-muted)",opacity:.35},onClick:()=>ie(1),children:t.jsx(z.HiChevronDown,{className:"h-3.5 w-3.5"})})]})}function hi(){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:kt,width:14,opacity:.45},"aria-hidden":!0,children:":"})}function mi({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 h=i==="popover",b=h||!d,f=hb({use12Hour:n,hour12:a}),p=s.useRef(e),g=jo(e,Wr()),w=fa(g),[v,L]=s.useState(rt(f?w.hour12:g.hour24)),[M,S]=s.useState(rt(g.minute)),[H,C]=s.useState(rt(g.second)),[y,T]=s.useState(w.meridiem),[N,_]=s.useState(0),q=s.useRef(0),U=s.useRef(!1),D=s.useRef({hour:null,minute:null,second:null,meridiem:null}),[K,j]=s.useState("hour"),ie=s.useMemo(()=>{const re=["hour","minute"];return o&&re.push("second"),f&&re.push("meridiem"),re},[f,o]),Q=s.useCallback(re=>{j(ge=>{const Ee=ie.indexOf(ge);return ie[(Ee+re+ie.length)%ie.length]})},[ie]);s.useEffect(()=>{var re;(re=D.current[K])==null||re.focus()},[K]),s.useEffect(()=>{var re;j("hour"),(re=D.current.hour)==null||re.focus()},[]),s.useEffect(()=>{if(e===p.current)return;p.current=e;const re=jo(e,Wr()),ge=fa(re);L(rt(f?ge.hour12:re.hour24)),S(rt(re.minute)),C(rt(re.second)),T(ge.meridiem)},[f,e]);const fe=s.useMemo(()=>(f?qo(1,12):qo(0,23)).map(re=>rt(re)),[f]),F=s.useMemo(()=>qo(0,59).map(re=>rt(re)),[]),Y=F,ae=s.useMemo(()=>["AM","PM"],[]),$=s.useCallback(()=>f?wn({hour12:Number(v),minute:Number(M),second:Number(H),meridiem:y}):{hour24:Number(v),minute:Number(M),second:Number(H)},[v,f,y,M,H]),W=s.useCallback(re=>{if(U.current)return;const ge=xn(re,o);p.current=ge,r(ge)},[r,o]),ce=s.useCallback(()=>{W($())},[$,W]),B=re=>{L(re),b&&W(f?wn({hour12:Number(re),minute:Number(M),second:Number(H),meridiem:y}):{hour24:Number(re),minute:Number(M),second:Number(H)})},oe=re=>{S(re),b&&W(f?wn({hour12:Number(v),minute:Number(re),second:Number(H),meridiem:y}):{hour24:Number(v),minute:Number(re),second:Number(H)})},Z=re=>{C(re),b&&W(f?wn({hour12:Number(v),minute:Number(M),second:Number(re),meridiem:y}):{hour24:Number(v),minute:Number(M),second:Number(re)})},X=re=>{T(re),b&&W(wn({hour12:Number(v),minute:Number(M),second:Number(H),meridiem:re}))},se=s.useCallback(()=>(q.current+=1,_(q.current),q.current),[]),E=s.useCallback(re=>{const ge=fa(re),Ee=xn(re,o);p.current=Ee,L(rt(f?ge.hour12:re.hour24)),S(rt(re.minute)),C(rt(re.second)),T(ge.meridiem),r(Ee)},[f,r,o]),J=()=>{U.current=!0,se(),E(Wr()),queueMicrotask(()=>{const re=Wr();xn(re,o)!==p.current&&(se(),E(re)),U.current=!1})},ee=()=>{ce(),d==null||d()},R=kt*Uo,x=R+Kt*2,k=Kt+R/2-kt/2,te=t.jsx("div",{className:"relative px-4 py-2",children:t.jsxs("div",{className:"relative mx-auto",style:{height:x,maxWidth:"100%"},children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-10 rounded-xl",style:{top:k,height:kt,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:Kt,height:kt*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:Kt,height:kt*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(ba,{syncEpochRef:q,forceSyncAt:N,values:fe,selected:v,onSelect:B,label:"Horas",maxNumeric:f?12:23,isFocused:K==="hour",onFocus:()=>j("hour"),onAdvance:()=>Q(1),onBack:()=>Q(-1),setColumnRef:re=>{D.current.hour=re}}),t.jsx(hi,{}),t.jsx(ba,{syncEpochRef:q,forceSyncAt:N,values:F,selected:M,onSelect:oe,label:"Minutos",maxNumeric:59,isFocused:K==="minute",onFocus:()=>j("minute"),onAdvance:()=>Q(1),onBack:()=>Q(-1),setColumnRef:re=>{D.current.minute=re}}),o?t.jsxs(t.Fragment,{children:[t.jsx(hi,{}),t.jsx(ba,{syncEpochRef:q,forceSyncAt:N,values:Y,selected:H,onSelect:Z,label:"Segundos",maxNumeric:59,isFocused:K==="second",onFocus:()=>j("second"),onAdvance:()=>Q(1),onBack:()=>Q(-1),setColumnRef:re=>{D.current.second=re}})]}):null,f?t.jsx("div",{className:"ml-3 shrink-0 pl-1",children:t.jsx(ba,{syncEpochRef:q,forceSyncAt:N,values:ae,selected:y,onSelect:re=>X(re),width:bb,label:"AM o PM",isMeridiem:!0,isFocused:K==="meridiem",onFocus:()=>j("meridiem"),onAdvance:()=>Q(1),onBack:()=>Q(-1),setColumnRef:re=>{D.current.meridiem=re}})}):null]})]})}),de=t.jsxs("div",{className:`flex items-center ${h?"justify-center px-3 py-2":"justify-between gap-2 px-3 py-2.5"}`,style:{borderTop:h?"none":"1px solid color-mix(in srgb, var(--border) 80%, transparent)"},children:[t.jsx(Xe,{variant:"ghost",size:"sm",onClick:J,className:h?"text-xs":void 0,children:"Ahora"}),!h&&(c||d)?t.jsxs("div",{className:"flex items-center gap-2",children:[c?t.jsx(Xe,{variant:"ghost",size:"sm",onClick:c,children:"Cancelar"}):null,d?t.jsx(Xe,{variant:"primary",size:"sm",onClick:ee,children:"Listo"}):null]}):null]});return t.jsxs("div",{className:`overflow-hidden ${u}`,style:{borderRadius:h?12:14,border:h?"1px solid color-mix(in srgb, var(--border) 85%, transparent)":"1px solid var(--border)",background:"var(--bg-card)",boxShadow:h?"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?o?300:260:o?252:212},children:[!h&&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,te,de]})}function mb(e){return e.use12Hour??e.hour12??!1}function pb({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:h,error:b,helperText:f,helperDisplay:p,className:g,contentClassName:w,className:v=""}){const L=u==="popover",[M,S]=s.useState(!1),H=s.useRef(null),[C,y]=s.useState({horizontal:"left",vertical:"bottom"}),T=mb({use12Hour:a,hour12:o}),N=s.useMemo(()=>r?db(r,{use12Hour:T,showSeconds:l}):"",[T,l,r]);s.useEffect(()=>{if(!L||!M||!H.current)return;const U=H.current.getBoundingClientRect(),D=8,K=T?l?300:260:l?252:212,j=276,ie=U.left+K>window.innerWidth-D,Q=U.right-K>=D,fe=U.bottom+8+j>window.innerHeight-D,F=U.top-8-j>=D;y({horizontal:ie&&Q?"right":"left",vertical:fe&&F?"top":"bottom"})},[T,L,M,l]),s.useEffect(()=>{if(!L||!M)return;function U(K){H.current&&(H.current.contains(K.target)||S(!1))}function D(K){K.key==="Escape"&&S(!1)}return document.addEventListener("mousedown",U),document.addEventListener("keydown",D),()=>{document.removeEventListener("mousedown",U),document.removeEventListener("keydown",D)}},[L,M]);const _=t.jsxs("button",{type:"button",disabled:d,onClick:()=>{d||S(U=>!U)},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 ${v}`,style:{background:"var(--bg-input)",borderColor:b?"var(--danger)":M?"var(--primary)":"var(--border)",color:N?"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:N||c})]}),L?t.jsx(z.HiChevronDown,{className:`h-4 w-4 shrink-0 text-[var(--text-muted)] transition-transform duration-150 ${M?"rotate-180":""}`}):null]}),q=t.jsx(mi,{variant:L?"popover":"panel",value:r||ub(l),onChange:n,use12Hour:T,showSeconds:l,title:i,onClose:()=>S(!1)});return t.jsx(Qn,{label:e,required:h,error:b,helperText:f,helperDisplay:p,className:g,contentClassName:w,children:L?t.jsxs("div",{ref:H,className:"relative w-full",children:[_,M?t.jsx("div",{className:"absolute z-50",style:{...C.horizontal==="left"?{left:0}:{right:0},...C.vertical==="bottom"?{top:"calc(100% + 6px)"}:{bottom:"calc(100% + 6px)"}},children:q}):null]}):t.jsxs("div",{className:"space-y-2",children:[_,M?q:null]})})}const gb={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function vb({checked:e,disabled:r,onCheckedChange:n,size:a="sm",className:o="",...l}){const i=gb[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 jr=360,or=10,ha=14,Vo=220;function yb(e){if(typeof document>"u")return null;const r=document.querySelector(e);if(!(r instanceof HTMLElement))return null;const n=r.getBoundingClientRect();return n.width===0&&n.height===0?null:{top:n.top,left:n.left,width:n.width,height:n.height}}function xb(e,r,n={width:window.innerWidth,height:window.innerHeight}){if(e&&e!=="auto")return e;const a=n.height-(r.top+r.height),o=r.top,l=n.width-(r.left+r.width);return a>=Vo?"bottom":o>=Vo?"top":l>=jr+24?"right":"left"}function wb(e){return{top:Math.max(8,e.top-or),left:Math.max(8,e.left-or),width:e.width+or*2,height:e.height+or*2}}function Nb(e,r,n={width:window.innerWidth,height:window.innerHeight}){const a=e.left+e.width/2,o=e.top+e.height/2,l=n.width-jr-16;return r==="bottom"?{top:e.top+e.height+or+ha,left:Math.min(Math.max(16,a-jr/2),l)}:r==="top"?{top:Math.max(16,e.top-or-ha-Vo),left:Math.min(Math.max(16,a-jr/2),l)}:r==="right"?{top:Math.min(Math.max(16,o-120),n.height-260),left:Math.min(e.left+e.width+or+ha,l)}:{top:Math.min(Math.max(16,o-120),n.height-260),left:Math.max(16,e.left-or-ha-jr)}}function kb(e){const r=document.querySelector(e);r instanceof HTMLElement&&r.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}function Cb({steps:e,open:r,onOpenChange:n,label:a="Guía",storageKey:o,onStepChange:l,backLabel:i="Atrás",skipLabel:c="Saltar",nextLabel:d="Siguiente",doneLabel:u="Listo",closeLabel:h="Cerrar guía",zIndex:b=1100}){const f=s.useId(),[p,g]=s.useState(0),[w,v]=s.useState(null),[L,M]=s.useState(!1),S=e[p]??e[0],H=e.length;s.useEffect(()=>{M(!0)},[]),s.useEffect(()=>{r&&g(0)},[r]),s.useEffect(()=>{!r||!S||l==null||l(S,p)},[r,S,p,l]);const C=s.useCallback(()=>{S&&v(yb(S.target))},[S]);s.useLayoutEffect(()=>{if(!r||!S)return;kb(S.target);const q=window.setTimeout(C,80),U=window.setTimeout(C,280);return()=>{window.clearTimeout(q),window.clearTimeout(U)}},[r,S,C]),s.useEffect(()=>{if(r)return C(),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[r,C]);const y=s.useCallback(()=>{if(n(!1),!!o)try{localStorage.setItem(o,"done")}catch{}},[n,o]);s.useEffect(()=>{if(!r)return;function q(U){if(U.key==="Escape"){U.preventDefault(),y();return}if(U.key==="ArrowRight"||U.key==="Enter"){U.preventDefault(),g(D=>Math.min(D+1,H-1));return}U.key==="ArrowLeft"&&(U.preventDefault(),g(D=>Math.max(D-1,0)))}return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[r,y,H]);const T=s.useMemo(()=>!w||!S?"bottom":xb(S.placement,w),[w,S]),N=s.useMemo(()=>w?wb(w):null,[w]),_=s.useMemo(()=>typeof window>"u"?{top:96,left:16}:N?Nb(N,T):{top:96,left:Math.max(16,(window.innerWidth-jr)/2)},[N,T]);return!L||!r||!S?null:pt.createPortal(t.jsxs("div",{className:"fixed inset-0",style:{zIndex:b},role:"dialog","aria-modal":"true","aria-labelledby":f,children:[t.jsx("button",{type:"button",className:"absolute inset-0 cursor-default bg-transparent","aria-label":h,onClick:y}),N?t.jsx("div",{className:"pointer-events-none absolute rounded-xl border-2 border-[var(--primary)] transition-all duration-200",style:{top:N.top,left:N.left,width:N.width,height:N.height,boxShadow:"0 0 0 9999px rgba(0, 0, 0, 0.58)"}}):t.jsx("div",{className:"pointer-events-none absolute inset-0 bg-black/58"}),t.jsxs("div",{className:"absolute w-[min(360px,calc(100vw-2rem))] rounded-2xl border border-[var(--border)] bg-[var(--bg-card)] p-4 shadow-2xl",style:{..._,zIndex:b+1},children:[t.jsxs("div",{className:"mb-3 flex items-start gap-2",children:[t.jsx("div",{className:"mt-0.5 rounded-lg p-1.5 text-[var(--primary)]",style:{background:"color-mix(in srgb, var(--primary) 15%, transparent)"},children:t.jsx(z.HiOutlineLightBulb,{className:"h-4 w-4"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"text-[10px] font-bold uppercase tracking-wider text-[var(--text-muted)]",children:[a," · ",p+1,"/",H]}),t.jsx("h2",{id:f,className:"mt-0.5 text-sm font-semibold text-[var(--text-main)]",children:S.title})]}),t.jsx(Xe,{variant:"icon",iconOnly:!0,"aria-label":h,tooltip:"Cerrar",onClick:y,children:t.jsx(z.HiXMark,{className:"h-4 w-4"})})]}),t.jsxs("div",{className:"space-y-3 text-sm leading-6 text-[var(--text-secondary)]",children:[S.body,S.caption?t.jsx("p",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] px-3 py-2 font-mono text-[11px] text-[var(--text-main)]",children:S.caption}):null]}),t.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2",children:[t.jsx(Xe,{variant:"secondary",size:"sm",disabled:p===0,onClick:()=>g(q=>Math.max(q-1,0)),children:i}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Xe,{variant:"secondary",size:"sm",onClick:y,children:c}),p<H-1?t.jsx(Xe,{size:"sm",onClick:()=>g(q=>Math.min(q+1,H-1)),children:d}):t.jsx(Xe,{size:"sm",onClick:y,children:u})]})]})]})]}),document.body)}function Sb(e){const[r,n]=s.useState(!1);s.useEffect(()=>{try{if(localStorage.getItem(e)==="done")return;n(!0)}catch{n(!0)}},[e]);const a=s.useCallback(()=>{try{localStorage.setItem(e,"done")}catch{}},[e]),o=s.useCallback(()=>n(!0),[]),l=s.useCallback((i=!0)=>{n(!1),i&&a()},[a]);return{open:r,setOpen:n,openTour:o,closeTour:l,markDone:a}}const pi=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),Eb=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function Mb(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 gi(e){return e.classList.contains("sidebar-scroll")||e.classList.contains("showcase-nav-scroll")}function vi(e){gi(e)&&e.querySelectorAll(".os-scrollbar-horizontal").forEach(r=>{r.style.display="none",r.style.height="0",r.style.pointerEvents="none"})}function Tb(e){const r=e.querySelector(Eb);return r instanceof HTMLElement?r:null}function yi(){return s.useEffect(()=>{const e=new WeakMap;let r=0;const n=()=>{r=0,document.querySelectorAll(pi).forEach(l=>{if(!(l instanceof HTMLElement))return;if(Va.OverlayScrollbars(l)){vi(l);return}if(!Mb(l))return;const c={overflow:gi(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},d=Tb(l),u=d?Va.OverlayScrollbars({target:l,elements:{viewport:d}},c):Va.OverlayScrollbars(l,c);vi(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(pi).forEach(l=>{var i;l instanceof HTMLElement&&((i=e.get(l))==null||i.destroy())})}},[]),null}function sr(e){const r=e.trim();return!r||r==="/"||r==="/."?"":(r.startsWith("/")?r:`/${r}`).replace(/\/+$/,"")}function xi(e){try{const r=new URL(e);return sr(r.pathname)}catch{return""}}function $b(e){const r=sr(e);if(!r)return"";const n=r.match(/^\/apps\/[^/]+/i);if(n)return sr(n[0]);const a=r.split("/").filter(Boolean);return a.length===0?"":a.length>=2&&a[0].toLowerCase()==="apps"?sr(`/${a[0]}/${a[1]}`):new Set(["admin","apps","apps-list","tickets","my-tickets","projects","projects-calendars","dashboard","teams","clients","services","settings","profile","messages","notifications","my-access","my-registers","my-pings","security-incidents","email-inbox","webhook-config","webphone-config","vobo","auth","api","login","forbidden","unauthorized","change-password","reset-password","chat-widget"]).has(a[0].toLowerCase())?"":sr(`/${a[0]}`)}const Xo="primeSuiteAppUrl",Ab={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"}},wi={xs:20,sm:28,md:36,lg:48,xl:64},Ni=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],Lb={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Db="bonsaif.bot",Ob="Bonsaif Bot",Hb={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function ki(e){return typeof e=="string"?e.trim():""}function Bb(e){var o;if(e!==void 0)return sr(e);const r=sr(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(Xo)||"";i&&window.sessionStorage.setItem(Xo,i);const c=window.sessionStorage.getItem(Xo)||"",d=i||c;if(d){const u=xi(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")?xi(a):sr(a);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return $b(window.location.pathname)}function Ib(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 Fb(e){let r=0;for(const n of e)r=r*31+n.charCodeAt(0)&65535;return Ni[r%Ni.length]}function _b(e,r){return e===Db||r===Ob}function Pb(e,r){return`${e.replace(/\/$/,"")}${r}`}function Ci({userId:e,username:r,name:n,size:a="md",showName:o=!1,showTooltip:l,tooltipContent:i,fallbackLabel:c="Usuario",basePath:d,wrapperClassName:u="",labelClassName:h="",labelSize:b="xs",avatarVersion:f=0,className:p="",style:g}){const[w,v]=s.useState(!1),L=typeof e=="string"&&e.trim()&&e!=="undefined"&&e!=="null"?e.trim():"";s.useEffect(()=>{v(!1)},[L,f]);const{wh:M,text:S}=Ab[a],H=ki(n)||ki(r)||c,C=Ib(H),y=Bb(d),T=_b(r,n),N=Pb(y,"/favicon.svg"),_=s.useMemo(()=>{if(!L)return"";const j=new URLSearchParams;j.set("size",String(wi[a])),f&&j.set("v",String(f));const ie=j.toString();return`${y}/api/user/avatar/${encodeURIComponent(L)}${ie?`?${ie}`:""}`},[f,y,L,a]),q=wi[a],U=T?t.jsx("span",{className:`${M} ${Hb[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 ${p}`,style:g,children:t.jsx("img",{src:N,alt:H,width:q,height:q,className:"h-full w-full object-contain"})}):_&&!w?t.jsx("img",{src:_,alt:H,width:q,height:q,className:`${M} rounded-full object-cover flex-shrink-0 ${p}`,style:g,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>v(!0)},`${L}-${f}`):t.jsx("span",{className:`${M} ${Fb(H)} ${S} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${p}`,style:g,title:H,children:C});if(o)return t.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${u}`,children:[U,t.jsx("span",{className:`min-w-0 truncate ${Lb[b]} font-medium text-[var(--text-main)] ${h}`,title:H,children:H})]});const D=l??!0,K=i??H;return D&&K?t.jsx(Pt,{as:"span",content:K,className:`inline-flex flex-shrink-0 ${u}`,children:U}):U}function zb({href:e,className:r,children:n}){return t.jsx("a",{href:e,className:r,children:n})}function Wb(e){return e.reduce((r,n)=>{const a=n.section??"Principal";return r[a]=[...r[a]??[],n],r},{})}function Si({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=zb}){const[h,b]=s.useState(!1),f=Wb(r);return t.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[t.jsx(yi,{}),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(z.HiBars3,{className:"h-5 w-5"})}),h&&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 ${h?"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:()=>b(!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(f).map(([p,g])=>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"}),p]}),t.jsx("div",{className:"space-y-1",children:g.map(w=>{const v=n===w.href||n.startsWith(`${w.href}/`);return t.jsxs(u,{href:w.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${v?"bg-white/10 text-white":"text-white/55 hover:bg-white/[0.06] hover:text-white/85"}`,children:[t.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:w.icon??t.jsx(z.HiHome,{className:"h-4 w-4"})}),t.jsx("span",{className:"truncate",children:w.label})]},w.href)})})]},p))})}),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(Ci,{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(Xe,{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 Ei="bonsaif-ui:prime-auth-sso",jb={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"},Yo={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 qb(e){return e.split("-").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function Ub(e){return/^\d+$/.test(e)||/^[a-f0-9]{8,}$/i.test(e)}function Vb(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=Ub(n)&&a?a:n,l=jb[o]??qb(o);return[{label:"Inicio",href:"/"},{label:l}]}function Go(e){return(e==null?void 0:e.querySelector(":scope > .os-viewport"))??(e==null?void 0:e.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function Xb(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(Yo[n])return Yo[n];const a=r.length>1?r[r.length-2]:"";return Yo[a]??t.jsx(z.HiHome,{className:"h-5 w-5"})}function Yb(e){return e.includes("primeAuthOrigin")||e.includes("primeAuthProjectKey")}function Mi(){if(typeof window>"u")return!1;if(Yb(window.location.href)){try{window.sessionStorage.setItem(Ei,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Ei)==="true"}catch{return!1}}function Gb({title:e,subtitle:r,action:n,meta:a,icon:o,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:d,showBreadcrumbs:u=!0,contained:h=!1}){const b=s.useRef(null),[f,p]=s.useState(!1),[g,w]=s.useState(d??"/"),[v,L]=s.useState(()=>Mi()),[M,S]=s.useState(null),H=d??g,C=c??Vb(H),y=o??Xb(H),T=u&&!v&&C.length>1,N=!T;s.useEffect(()=>{d||w(window.location.pathname)},[d]),s.useEffect(()=>{L(Mi())},[]),s.useEffect(()=>{if(h){p(!1);return}let q=null,U=0,D=0;const K=()=>{const Q=b.current,fe=document.querySelector("[data-app-scroll='true']");return(Q==null?void 0:Q.closest(".os-viewport"))??(Q==null?void 0:Q.closest("[data-overlayscrollbars-viewport]"))??Go(fe)??fe??window},j=()=>{const Q=q&&q!==window?q.scrollTop:window.scrollY;p(fe=>fe?Q>24:Q>72)},ie=()=>{q==null||q.removeEventListener("scroll",j),q=K(),q.addEventListener("scroll",j,{passive:!0}),j()};return ie(),U=window.requestAnimationFrame(ie),D=window.setTimeout(ie,120),()=>{window.cancelAnimationFrame(U),window.clearTimeout(D),q==null||q.removeEventListener("scroll",j)}},[h]),s.useEffect(()=>{if(h){S(null);return}let q=0;const U=[],D=()=>{const Y=b.current,ae=Y==null?void 0:Y.parentElement,$=document.querySelector("[data-app-scroll='true']"),W=Go($)??$;if(!Y||!ae||!W){S(null);return}const ce=ae.getBoundingClientRect(),B=window.getComputedStyle(ae),oe=W.getBoundingClientRect(),Z=W instanceof HTMLElement&&W.clientWidth>0?W.clientWidth:oe.width,X=ce.left+parseFloat(B.paddingLeft||"0"),se={marginLeft:Math.round(oe.left-X),width:Math.round(Z)};S(E=>E&&E.marginLeft===se.marginLeft&&E.width===se.width?E:se)},K=()=>{window.cancelAnimationFrame(q),q=window.requestAnimationFrame(D)};K(),window.addEventListener("resize",K);const j=new ResizeObserver(K),ie=b.current,Q=ie==null?void 0:ie.parentElement,fe=document.querySelector("[data-app-scroll='true']"),F=Go(fe)??fe;return[Q,fe,F].forEach(Y=>{Y&&j.observe(Y)}),U.push(window.setTimeout(K,120)),U.push(window.setTimeout(K,280)),()=>{window.cancelAnimationFrame(q),window.removeEventListener("resize",K),j.disconnect(),U.forEach(Y=>window.clearTimeout(Y))}},[h]);const _={...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:h?"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:h||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 ${h?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${l}`,style:_,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":N?"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||N?"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||N?"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:T?"var(--text-secondary)":"var(--text-muted)"},children:y}),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(gs.Provider,{value:{compact:!0,headerAction:!0},children:n})})]})})}function Kb({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(Si,{currentPath:r,...a,children:e})}function Ti(){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 Zb(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 Qb({name:e,src:r,projectKey:n}){const[a,o]=s.useState("system"),l=s.useRef(null);s.useEffect(()=>{o(Ti());const d=new MutationObserver(()=>o(Ti()));return d.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>d.disconnect()},[]);const i=s.useMemo(()=>Zb(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(h){var p,g,w;if(h.source!==((p=l.current)==null?void 0:p.contentWindow)||c&&h.origin!==c)return;if(((g=h.data)==null?void 0:g.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!h.data.active}}));return}if(((w=h.data)==null?void 0:w.type)!=="prime-microservice:navigation")return;const b=h.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 Jb(){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:$i(c.data.width,96,720),height:$i(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 $i(e,r,n){const a=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(r,Math.min(n,Math.ceil(a)))}function Rb(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 eh(){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 th(){return"light"}function rh({position:e="bottom-center"}){const r=s.useSyncExternalStore(Rb,eh,th);return t.jsx(Xa.Toaster,{position:e,theme:r,richColors:!0,closeButton:!0})}function nh({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 Nn=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function Ai(e,r){return e.color??Nn[r%Nn.length]}function qt(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 Ct=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 qr(e){if(e==null||e==="")return null;const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?r:null}const Ko={warning:70,danger:90};function ma(e,r=Ko){const n=r.warning??Ko.warning,a=r.danger??Ko.danger;return e>=a?"danger":e>=n?"warning":e<=0?"primary":"success"}function kn(e,r){return qt(ma(e,r))}function Ur(e,r=0){return Number.isFinite(e)?`${e.toFixed(r)}%`:"—"}function Vr(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 Li(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 Xr(e,r){var n;for(let a=e.length-1;a>=0;a-=1){const o=qr((n=e[a])==null?void 0:n[r]);if(o!==null)return o}return null}function St({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 Et({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 lr=680,mr="ease-out",ah={top:18,right:8,bottom:12,left:0};function Cn(e){return{...ah,...e}}function Sn(e){return e.map((r,n)=>({...r,color:Ai(r,n),label:r.label??r.key}))}function pa(e,r){return!e.length||!r.length||e.every(n=>r.every(a=>qr(n[a.key])===null))}function Mt(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function En(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function Di(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function ga(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function oh(e,r=Ct){if(e==null||e==="")return"—";const n=typeof e=="number"?e:Number(e);return Number.isFinite(n)?r(n):String(e)}function Oi(e){return`bonsaif-grad-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function sh({active:e,label:r,payload:n,valueFormat:a=Ct}){var c,d,u,h,b,f;if(!e||!(n!=null&&n.length))return null;const o=n.filter(p=>p.dataKey!=="base"&&p.name!=="base"&&p.value!==null&&p.value!==void 0);if(!o.length)return null;const l=((d=(c=o[0])==null?void 0:c.payload)==null?void 0:d.fullName)??((h=(u=o[0])==null?void 0:u.payload)==null?void 0:h.tooltipLabel)??((f=(b=o[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:o.map((p,g)=>{const w=p.payload,v=w&&typeof w.display=="number"?w.display:p.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:p.color??"var(--primary)"}}),p.name??p.dataKey]}),t.jsx("span",{className:"bonsaif-chart-tooltip-value",children:oh(v,a)})]},String(p.dataKey??p.name??g))})})]})}function Yr({valueFormat:e,content:r,cursor:n,offset:a=12,wrapperStyle:o,allowEscapeViewBox:l,reverseDirection:i,...c}){return t.jsx(Ae.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(sh,{valueFormat:e})})}function Hi(e,r,n){return n==null?-1:e.findIndex(a=>String(a[r])===String(n))}function Bi(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 va(e,r,n={}){const{zoomable:a=!1,zoomMode:o="both",brushHeight:l=28,onZoomChange:i}=n,[c,d]=s.useState(null),[u,h]=s.useState(null),b=!!a&&e.length>1,f=b&&(o==="brush"||o==="both"),p=b&&(o==="drag"||o==="both"),g=s.useCallback(U=>{d(U),i==null||i(U)},[i]),w=s.useCallback(()=>{h(null),g(null)},[g]),v=!!c,L=s.useMemo(()=>!c||f?e:e.slice(c.startIndex,c.endIndex+1),[e,f,c]),M=s.useCallback((U,D)=>{const K=Hi(e,r,U),j=Hi(e,r,D);K<0||j<0||g(Bi(K,j,e.length))},[g,e,r]),S=s.useCallback(U=>{p&&((U==null?void 0:U.activeLabel)===void 0||(U==null?void 0:U.activeLabel)===null||h({leftLabel:U.activeLabel,rightLabel:U.activeLabel}))},[p]),H=s.useCallback(U=>{!p||!u||(U==null?void 0:U.activeLabel)===void 0||(U==null?void 0:U.activeLabel)===null||h(D=>D&&{...D,rightLabel:U.activeLabel})},[u,p]),C=s.useCallback(()=>{if(p){if(!u||u.rightLabel===null||u.rightLabel===void 0){h(null);return}M(u.leftLabel,u.rightLabel),h(null)}},[M,u,p]),y=s.useCallback(U=>{if(f){if(!U){g(null);return}g(Bi(U.startIndex??0,U.endIndex??e.length-1,e.length))}},[g,e.length,f]),T=p?{onMouseDown:S,onMouseMove:H,onMouseUp:C,onMouseLeave:()=>{u&&C()}}:{},N=c??{startIndex:0,endIndex:Math.max(0,e.length-1)},_=t.jsxs(t.Fragment,{children:[p&&u&&u.rightLabel!==null&&u.rightLabel!==void 0?t.jsx(Ae.ReferenceArea,{x1:u.leftLabel,x2:u.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,f?t.jsx(Ae.Brush,{dataKey:r,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:N.startIndex,endIndex:N.endIndex,onChange:y,tickFormatter:U=>String(U)}):null]}),q=f?{bottom:Math.max(l+10,36)}:void 0;return{enabled:b,showBrush:f,showDrag:p,viewData:L,isZoomed:v,resetZoom:w,chartHandlers:T,zoomNodes:_,marginExtra:q}}function ya({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 lh({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:h,valueFormat:b=Ct,yDomain:f,ariaLabel:p="Gráfico de líneas",curve:g=!0,strokeWidth:w=2.25,zoomable:v=!1,zoomMode:L="both",brushHeight:M,onZoomChange:S}){const H=pa(e,n),C=Sn(n),y=va(e,r,{zoomable:v,zoomMode:L,brushHeight:M,onZoomChange:S}),T=Cn({...h,...y.marginExtra});return l?t.jsx(St,{height:a}):H?t.jsx(Et,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${o}`,role:"img","aria-label":p,style:{height:a},children:[t.jsx(ya,{visible:y.isZoomed,onReset:y.resetZoom}),t.jsx(Ae.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ae.LineChart,{data:y.viewData,margin:T,...y.chartHandlers,children:[c?t.jsx(Ae.CartesianGrid,{strokeDasharray:"2 8",stroke:En(),vertical:!1}):null,t.jsx(Ae.XAxis,{dataKey:r,tick:Mt(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Ae.YAxis,{tick:Mt(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:N=>b(Number(N)),dx:-2}),u?t.jsx(Yr,{valueFormat:b,cursor:{stroke:Di(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Ae.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ga()}):null,C.map((N,_)=>t.jsx(Ae.Line,{type:g?"monotone":"linear",dataKey:N.key,name:N.label,stroke:N.color,strokeWidth:_===0?w+.35:w,strokeOpacity:_===0?1:.88,isAnimationActive:!0,animationDuration:lr,animationEasing:mr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:N.color}},N.key)),y.zoomNodes]})})]})}function xa({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:h,valueFormat:b=Ct,yDomain:f,ariaLabel:p="Gráfico de área",stacked:g=!1,opacity:w=.22,zoomable:v=!1,zoomMode:L="both",brushHeight:M,onZoomChange:S}){const H=pa(e,n),C=Sn(n),y=va(e,r,{zoomable:v,zoomMode:L,brushHeight:M,onZoomChange:S}),T=Cn({...h,...y.marginExtra});return l?t.jsx(St,{height:a}):H?t.jsx(Et,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${o}`,role:"img","aria-label":p,style:{height:a},children:[t.jsx(ya,{visible:y.isZoomed,onReset:y.resetZoom}),t.jsx(Ae.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ae.AreaChart,{data:y.viewData,margin:T,...y.chartHandlers,children:[t.jsx("defs",{children:C.map(N=>t.jsxs("linearGradient",{id:Oi(N.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:N.color,stopOpacity:Math.min(.55,w+.28)}),t.jsx("stop",{offset:"48%",stopColor:N.color,stopOpacity:w*.5}),t.jsx("stop",{offset:"100%",stopColor:N.color,stopOpacity:0})]},N.key))}),c?t.jsx(Ae.CartesianGrid,{strokeDasharray:"2 8",stroke:En(),vertical:!1}):null,t.jsx(Ae.XAxis,{dataKey:r,tick:Mt(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Ae.YAxis,{tick:Mt(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:N=>b(Number(N)),dx:-2}),u?t.jsx(Yr,{valueFormat:b,cursor:{stroke:Di(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Ae.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ga()}):null,C.map(N=>t.jsx(Ae.Area,{type:"monotone",dataKey:N.key,name:N.label,stroke:N.color,fill:`url(#${Oi(N.key)})`,strokeWidth:2.25,stackId:g?"stack":void 0,isAnimationActive:!0,animationDuration:lr,animationEasing:mr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:N.color}},N.key)),y.zoomNodes]})})]})}function ih({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:h,valueFormat:b=Ct,yDomain:f,ariaLabel:p="Gráfico de barras",layout:g="vertical",mode:w="grouped",barRadius:v=6,categoryAxisWidth:L=64,zoomable:M=!1,zoomMode:S="both",brushHeight:H,onZoomChange:C}){const y=pa(e,n),T=Sn(n),N=g==="horizontal",_=va(e,r,{zoomable:M&&!N,zoomMode:S,brushHeight:H,onZoomChange:C}),q=Cn({...h,..._.marginExtra});return l?t.jsx(St,{height:a}):y?t.jsx(Et,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${o}`,role:"img","aria-label":p,style:{height:a},children:[t.jsx(ya,{visible:_.isZoomed,onReset:_.resetZoom}),t.jsx(Ae.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ae.BarChart,{data:_.viewData,margin:q,layout:N?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,..._.chartHandlers,children:[c?t.jsx(Ae.CartesianGrid,{strokeDasharray:"2 8",stroke:En(),horizontal:!N,vertical:N}):null,N?t.jsxs(t.Fragment,{children:[t.jsx(Ae.XAxis,{type:"number",tick:Mt(),tickLine:!1,axisLine:!1,tickFormatter:U=>b(Number(U)),domain:f??["auto","auto"]}),t.jsx(Ae.YAxis,{type:"category",dataKey:r,tick:Mt(),tickLine:!1,axisLine:!1,width:L})]}):t.jsxs(t.Fragment,{children:[t.jsx(Ae.XAxis,{dataKey:r,tick:Mt(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Ae.YAxis,{tick:Mt(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:U=>b(Number(U)),dx:-2})]}),u?t.jsx(Yr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,d?t.jsx(Ae.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ga()}):null,T.map((U,D)=>t.jsx(Ae.Bar,{dataKey:U.key,name:U.label,fill:U.color,fillOpacity:D===0?1:.82,radius:N?[0,v,v,0]:[v,v,2,2],maxBarSize:20,stackId:w==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:lr,animationEasing:mr},U.key)),_.zoomNodes]})})]})}function ch(e){return t.jsx(Fi,{...e,variant:"pie"})}function dh(e){return t.jsx(Fi,{...e,variant:"donut",innerRadius:e.innerRadius??.62,cornerRadius:e.cornerRadius??10,padAngle:e.padAngle??2})}function Ii(e,r){return e==null||!Number.isFinite(e)?r:e>0&&e<=1?e*100:e}function Fi({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=Ct,ariaLabel:h,innerRadius:b,outerRadius:f,colors:p=[...Nn],padAngle:g,cornerRadius:w,variant:v}){const L=e.map((D,K)=>({name:String(D[r]??""),value:qr(D[n])??0,fill:p[K%p.length],row:D})).filter(D=>D.value>0),M=!L.length,S=v==="donut",H=L.length,C=Ii(b,S?62:12),y=Ii(f,78),T=Math.min(g??(S?2:3),Math.max(.5,10/Math.max(1,H))),N=Math.min(w??(S?10:8),Math.max(2,36/Math.max(1,H)));if(l)return t.jsx(St,{height:a});if(M)return t.jsx(Et,{height:a,text:i});const _=L.reduce((D,K)=>D+K.value,0),q=c?Math.min(96,28+Math.ceil(H/3)*22):0,U=Math.max(140,a-q);return t.jsx("div",{className:`bonsaif-chart bonsaif-${v}-chart w-full ${o}`,role:"img","aria-label":h??(v==="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:U},children:t.jsx(Ae.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ae.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[d?t.jsx(Yr,{valueFormat:u,isAnimationActive:!1}):null,t.jsx(Ae.Pie,{data:L,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${C}%`,outerRadius:`${y}%`,startAngle:90,endAngle:-270,paddingAngle:T,cornerRadius:N,minAngle:H>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:lr,animationEasing:mr,label:!1,activeShape:uh,children:L.map(D=>t.jsx(Ae.Cell,{fill:D.fill},D.name))}),S?t.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:u(_)}):null]})})}),c?t.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:L.map(D=>t.jsxs("li",{className:"bonsaif-pie-legend-item",children:[t.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:D.fill},"aria-hidden":!0}),t.jsx("span",{className:"bonsaif-pie-legend-label",title:D.name,children:D.name}),t.jsx("span",{className:"bonsaif-pie-legend-value",children:u(D.value)})]},D.name))}):null]})})}function uh(e){const{outerRadius:r=0,...n}=e;return t.jsx(Ae.Sector,{...n,outerRadius:Number(r)+4,stroke:"var(--bg-card)",strokeWidth:2})}function fh({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??qt(o),h=e.map(y=>qr(y[r])).filter(y=>y!==null);if(h.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,p=3,g=1,w=Math.min(...h),L=Math.max(...h)-w||1,M=h.map((y,T)=>{const N=g+T/(h.length-1)*(b-g*2),_=f-p-(y-w)/L*(f-p*2);return{x:N,y:_}}),S=M.map((y,T)=>`${T===0?"M":"L"}${y.x.toFixed(2)} ${y.y.toFixed(2)}`).join(" "),H=`${S} L${M[M.length-1].x.toFixed(2)} ${f} L${M[0].x.toFixed(2)} ${f} Z`,C=`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 ${b} ${f}`,preserveAspectRatio:"none",focusable:"false",children:[i?t.jsx("defs",{children:t.jsxs("linearGradient",{id:C,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:H,fill:`url(#${C})`}):null,t.jsx("path",{d:S,fill:"none",stroke:u,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function bh({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:h=!0,showTooltip:b=!0,margin:f,valueFormat:p=Ct,yDomain:g,ariaLabel:w="Gráfico combinado",barRadius:v=6,zoomable:L=!1,zoomMode:M="both",brushHeight:S,onZoomChange:H}){const C=a??n.slice(0,Math.max(1,n.length-1)),y=o??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),T=[...C,...y.filter(j=>!C.some(ie=>ie.key===j.key))],N=pa(e,T),_=Sn(C),q=Sn(T),U=y.map(j=>{var Q;const ie=q.find(fe=>fe.key===j.key);return{...j,label:j.label??j.key,color:j.color??(ie==null?void 0:ie.color)??((Q=q[0])==null?void 0:Q.color)}}),D=va(e,r,{zoomable:L,zoomMode:M,brushHeight:S,onZoomChange:H}),K=Cn({...f,...D.marginExtra});return c?t.jsx(St,{height:l}):N?t.jsx(Et,{height:l,text:d}):t.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":w,style:{height:l},children:[t.jsx(ya,{visible:D.isZoomed,onReset:D.resetZoom}),t.jsx(Ae.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ae.ComposedChart,{data:D.viewData,margin:K,barCategoryGap:"34%",...D.chartHandlers,children:[u?t.jsx(Ae.CartesianGrid,{strokeDasharray:"2 8",stroke:En(),vertical:!1}):null,t.jsx(Ae.XAxis,{dataKey:r,tick:Mt(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Ae.YAxis,{tick:Mt(),tickLine:!1,axisLine:!1,width:44,domain:g??["auto","auto"],tickFormatter:j=>p(Number(j)),dx:-2}),b?t.jsx(Yr,{valueFormat:p,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,h?t.jsx(Ae.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ga()}):null,_.map(j=>t.jsx(Ae.Bar,{dataKey:j.key,name:j.label,fill:j.color,fillOpacity:.88,radius:[v,v,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:lr,animationEasing:mr},j.key)),U.map(j=>t.jsx(Ae.Line,{type:"monotone",dataKey:j.key,name:j.label,stroke:j.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:lr,animationEasing:mr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:j.color}},j.key)),D.zoomNodes]})})]})}function hh({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:h,valueFormat:b=Ct,ariaLabel:f="Gráfico waterfall",increaseColor:p="#34d399",decreaseColor:g="#f87171",totalColor:w="var(--primary)"}){const v=s.useMemo(()=>mh(e,{xKey:r,valueKey:n,typeKey:a,increaseColor:p,decreaseColor:g,totalColor:w}),[e,r,n,a,p,g,w]),L=!v.length,M=Cn(h);return i?t.jsx(St,{height:o}):L?t.jsx(Et,{height:o,text:c}):t.jsx("div",{className:`bonsaif-chart bonsaif-waterfall-chart w-full ${l}`,role:"img","aria-label":f,style:{height:o},children:t.jsx(Ae.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ae.BarChart,{data:v,margin:M,barCategoryGap:"42%",children:[d?t.jsx(Ae.CartesianGrid,{strokeDasharray:"2 8",stroke:En(),vertical:!1}):null,t.jsx(Ae.XAxis,{dataKey:"label",tick:Mt(),tickLine:!1,axisLine:!1,interval:0,dy:6}),t.jsx(Ae.YAxis,{tick:Mt(),tickLine:!1,axisLine:!1,width:44,tickFormatter:S=>b(Number(S)),dx:-2}),u?t.jsx(Yr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,t.jsx(Ae.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),t.jsx(Ae.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:lr,animationEasing:mr,children:v.map(S=>t.jsx(Ae.Cell,{fill:S.color},S.label))})]})})})}function mh(e,r){let n=0;return e.map((a,o)=>{const l=qr(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,h=0,b=l;return c&&i==="total"?(d="total",u=0,h=Math.abs(l),b=l,n=l):c&&o===e.length-1&&!i?(d="total",u=0,h=Math.abs(n),b=n):(d=i==="decrease"||l<0?"decrease":"increase",d==="decrease"?(u=n+l,h=Math.abs(l),n=n+l):(u=n,h=Math.abs(l),n=n+l),b=l),{label:String(a[r.xKey]??""),base:u,delta:h,display:b,kind:d,color:d==="total"?r.totalColor:d==="decrease"?r.decreaseColor:r.increaseColor}})}const _i="bonsaif-funnel-chart-keyframes",ph=`
53
53
  @keyframes bonsaif-funnel-stage-in {
54
54
  from {
55
55
  opacity: 0;
@@ -89,4 +89,4 @@ ${z}`,pe=new Blob(["\uFEFF"+ie],{type:"text/csv;charset=utf-8;"}),Me=URL.createO
89
89
  animation: none !important;
90
90
  }
91
91
  }
92
- `;function Rb(){if(typeof document>"u"||document.getElementById(Ti))return;const e=document.createElement("style");e.id=Ti,e.textContent=Jb,document.head.appendChild(e)}function $i(e,r,n){return Math.min(n,Math.max(r,e))}function ua(e,r,n){const a=$i(n,0,1);return`color-mix(in srgb, ${e} ${Math.round((1-a)*100)}%, ${r} ${Math.round(a*100)}%)`}function eh(e,r,n,a,o,l){const i=e.map((d,u)=>{const h=_r(d[n])??0,b=String(d[r]??""),f=a?String(d[a]??"").trim():"",p=o?String(d[o]??"").trim():"";return{name:b,value:h,color:l[u%l.length],...f?{title:f}:{},...p?{description:p}:{}}}).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 th(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,h=n===1?1:(d+1)/n,b=l+(i-l)*u,f=l+(i-l)*h;return{...c,index:d,y:r.topY+d*(o+r.gap),h:o,topW:b,bottomW:f,cx:r.cx}})}function rh({stage:e,hovered:r,onHover:n}){const{cx:a,y:o,h:l,topW:i,bottomW:c,color:d}=e,u=a-i/2,h=a+i/2,b=a-c/2,f=a+c/2,p=o+l,v=Math.max(4,Math.min(14,l*.18)),w=ua(d,"#000",r?.12:.22),g=ua(d,"#fff",r?.08:0),A=ua(d,"#fff",.22),C=[`M ${u} ${o}`,`L ${h} ${o}`,`L ${f} ${p}`,`L ${b} ${p}`,"Z"].join(" ");return t.jsxs("g",{onMouseEnter:()=>n(e.index),onMouseLeave:()=>n(null),style:{cursor:"default"},children:[t.jsx("path",{d:C,fill:w}),t.jsx("path",{d:[`M ${u} ${o}`,`L ${h} ${o}`,`L ${h} ${o+1}`,`L ${f} ${p}`,`L ${a} ${p}`,`L ${u} ${o}`,"Z"].join(" "),fill:g,opacity:.55}),t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:v,fill:A,stroke:ua(d,"#000",.15),strokeWidth:1}),r?t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:v,fill:"none",stroke:"var(--text-main)",strokeOpacity:.25,strokeWidth:1.5}):null]})}function nh({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:h=!0,showValues:b=!0,showBottomArrow:f=!0,taper:p=.42,colors:v=[...bn],animationDuration:w=sr,valueFormat:g=wt,ariaLabel:A="Gráfico embudo"}){const[C,T]=s.useState(null),[H,E]=s.useState(!1),x=s.useMemo(()=>eh(e,r,n,a,o,v),[e,r,n,a,o,v]),M=s.useMemo(()=>x.map(G=>`${G.name}:${G.value}`).join("|"),[x]);if(s.useEffect(()=>{if(Rb(),typeof window>"u")return;const G=window.matchMedia("(prefers-reduced-motion: reduce)");E(G.matches);const U=()=>E(G.matches);return G.addEventListener("change",U),()=>G.removeEventListener("change",U)},[]),c)return t.jsx(Nt,{height:l});if(!x.length)return t.jsx(kt,{height:l,text:d});const k=w>0&&!H,_=w,q=Math.min(90,Math.max(40,Math.round(w/8))),X=Math.round(_*.15),D=x.length*q+Math.round(_*.35),K=x.some(G=>G.title||G.description),j=h?160:24,le=K?168:24,Q=f?36:8,fe=j+220+le,F=l,V=18,ae=Math.max(120,F-V-Q-8),$=j+110,ce=th(x,{cx:$,topY:V,plotH:ae,maxTopW:200,taper:$i(p,.2,.95),gap:10}),O=C!=null?ce[C]:null,oe="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":A,style:{height:l},children:[t.jsxs("svg",{viewBox:`0 0 ${fe} ${F}`,width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",children:[h?t.jsx("line",{className:k?"bonsaif-funnel-label":void 0,style:k?{animation:`bonsaif-funnel-fade-in ${_}ms ${oe} both`}:void 0,x1:j-12,y1:V,x2:j-12,y2:V+ae,stroke:"var(--border)",strokeDasharray:"3 5",strokeWidth:1}):null,ce.map(G=>{const U=G.y+G.h/2,se=G.cx-G.topW/2,S=G.index*q,R=k?{animation:`bonsaif-funnel-stage-in ${_}ms ${oe} ${S}ms both`}:void 0,ee=k?{animation:`bonsaif-funnel-fade-in ${Math.round(_*.85)}ms ${oe} ${S+X}ms both`}:void 0;return t.jsxs("g",{children:[t.jsx("g",{className:"bonsaif-funnel-stage",style:R,children:t.jsx(rh,{stage:G,hovered:C===G.index,onHover:T})}),h?t.jsxs("g",{className:"bonsaif-funnel-label",style:ee,children:[t.jsx("line",{x1:24,y1:U,x2:j-12,y2:U,stroke:G.color,strokeOpacity:.55,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("line",{x1:j-12,y1:U,x2:se-6,y2:U,stroke:G.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("text",{x:20,y:U-(b?6:0),textAnchor:"end",fill:G.color,fontSize:12,fontWeight:600,children:G.name.length>18?`${G.name.slice(0,16)}…`:G.name}),b?t.jsx("text",{x:20,y:U+10,textAnchor:"end",fill:"var(--text-muted)",fontSize:11,children:g(G.value)}):null]}):null,(G.title||G.description)&&K?t.jsxs("g",{className:"bonsaif-funnel-anno",style:ee,children:[t.jsx("line",{x1:G.cx+G.bottomW/2+6,y1:U,x2:j+220+8,y2:U,stroke:G.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),G.title?t.jsx("text",{x:j+220+14,y:U-(G.description?6:0),fill:"var(--text-main)",fontSize:12,fontWeight:700,children:G.title.length>22?`${G.title.slice(0,20)}…`:G.title}):null,G.description?t.jsx("text",{x:j+220+14,y:U+(G.title?10:0),fill:"var(--text-muted)",fontSize:11,children:G.description.length>28?`${G.description.slice(0,26)}…`:G.description}):null]}):null]},`${G.name}-${G.index}`)}),f?t.jsx("g",{className:"bonsaif-funnel-arrow",transform:`translate(${$}, ${V+ae+8})`,fill:"var(--primary)",style:k?{animation:`bonsaif-funnel-arrow-in ${Math.round(_*.7)}ms ${oe} ${D}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]},M),u&&O?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:O.color},children:O.name}),t.jsx("span",{style:{color:"var(--text-muted)"},children:" · "}),g(O.value),t.jsxs("span",{style:{color:"var(--text-muted)"},children:[" ","(",Math.round(O.pct*100),"% del top)"]})]}):null]})}const qr=135*Math.PI/180,Po=270*Math.PI/180;function ah({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=wt,tone:h="primary",color:b,thresholds:f,ariaLabel:p="Gauge",animationDuration:v=700,thickness:w=9,showScale:g=!1}){const A=s.useId().replace(/:/g,""),C=n-r||1,T=Math.min(1,Math.max(0,(e-r)/C)),[H,E]=s.useState(v>0?0:T);if(s.useEffect(()=>{if(l||i)return;if(v<=0){E(T);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){E(T);return}let fe=0,F=0;E($=>(F=$,$));const V=performance.now(),ae=$=>{const P=Math.min(1,($-V)/v),ce=1-(1-P)**3;E(F+(T-F)*ce),P<1&&(fe=requestAnimationFrame(ae))};return fe=requestAnimationFrame(ae),()=>cancelAnimationFrame(fe)},[T,v,l,i]),l)return t.jsx(Nt,{height:a});if(i)return t.jsx(kt,{height:a,text:c});const x=100,M=108,k=72,_=b??oh(e,n,h,f),q=r+H*C,X=Ai(x,M,k,qr,qr+Po),D=qr+Math.max(.001,H)*Po,K=Ai(x,M,k,qr,D),j=fa(x,M,k,qr),le=fa(x,M,k,qr+Po);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":p,className:"overflow-visible",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:`bonsaif-gauge-${A}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[t.jsx("stop",{offset:"0%",stopColor:_,stopOpacity:.82}),t.jsx("stop",{offset:"100%",stopColor:_,stopOpacity:1})]})}),t.jsx("path",{d:X,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:w,strokeLinecap:"butt"}),t.jsx("path",{d:K,fill:"none",stroke:`url(#bonsaif-gauge-${A})`,strokeWidth:w,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),t.jsx("text",{x,y:M-(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(q)}),d?t.jsx("text",{x,y:M+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:d}):null,g?t.jsxs(t.Fragment,{children:[t.jsx("text",{x:j.x-2,y:j.y+w+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(r)}),t.jsx("text",{x:le.x+2,y:le.y+w+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(n)})]}):null]})})}function oh(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 jt(n);const o=e/(r||1);return o>=.8?jt("success"):o>=.5?jt("warning"):jt("danger")}function fa(e,r,n,a){return{x:e+n*Math.cos(a),y:r+n*Math.sin(a)}}function Ai(e,r,n,a,o){const l=fa(e,r,n,a),i=fa(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 sh({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:h,valueFormat:b=wt,tone:f="primary",showScale:p=!0,showStatus:v=!0,ariaLabel:w="Bullet chart"}){if(i)return t.jsx(Nt,{height:o});if(c)return t.jsx(kt,{height:o,text:d});const g=n??Math.max(e,r,...(a==null?void 0:a.map(_=>_.value))??[],1)*1.05,C=[...a??[{value:g*.5,color:"color-mix(in srgb, var(--border) 72%, transparent)"},{value:g*.75,color:"color-mix(in srgb, var(--border) 48%, transparent)"},{value:g,color:"color-mix(in srgb, var(--border) 28%, transparent)"}]].sort((_,q)=>_.value-q.value),T=jt(f),H=Math.min(100,Math.max(0,e/g*100)),E=Math.min(100,Math.max(0,r/g*100)),x=e>=r,M=[0,.25,.5,.75,1].map(_=>_*g),k=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":w,children:[t.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:C.map((_,q)=>{const X=q===0?0:C[q-1].value,D=Math.max(0,(_.value-X)/g*100);return t.jsx("div",{style:{width:`${D}%`,background:_.color??`color-mix(in srgb, var(--border) ${70-q*18}%, transparent)`}},q)})}),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:`${H}%`,background:T,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${T} 35%, transparent)`}})}),t.jsx("div",{className:"bonsaif-bullet-target absolute top-1/2 z-[1]",style:{left:`${E}%`,height:"72%",width:3,transform:"translate(-50%, -50%)",background:T,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${b(r)}`})]}),p?t.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:M.map((_,q)=>{const X=_/g*100,D=q===0,K=q===M.length-1;return t.jsxs("div",{className:"absolute top-0",style:{left:`${X}%`,transform:D?"none":K?"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:D?0:K?"auto":void 0,marginRight:K?0:void 0}}),t.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:D?"left":K?"right":"center"},children:b(_)})]},_)})}):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}),h?t.jsx("div",{className:"mt-0.5 text-[11px] leading-snug",style:{color:"var(--text-muted)"},children:h}):t.jsxs("div",{className:"mt-0.5 text-[11px] tabular-nums leading-snug",style:{color:"var(--text-muted)"},children:[t.jsx("span",{style:{color:T,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:jt(x?"success":"warning")},children:x?"En meta":"Bajo meta"}):null]}),k]}):k})}function lh({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:h=!1,showTooltip:b=!0,thresholds:f,label:p="CPU",ariaLabel:v="Uso de CPU"}){var E;const w=o??[{key:a,label:"Uso",color:hn(r??Wr(e,a)??0,f)}],g=r??Wr(e,a)??Wr(e,((E=w[0])==null?void 0:E.key)??a),A=!d&&(!e.length||g===null);if(d)return t.jsx(Nt,{height:i});if(A)return t.jsx(kt,{height:i,text:u});const C=Math.min(100,Math.max(0,g??0)),T=oa(C,f),H=hn(C,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:[p,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:H},children:Pr(C,C<10?1:0)})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:H,background:`color-mix(in srgb, ${H} 14%, transparent)`},children:T==="danger"?"Crítico":T==="warning"?"Alto":"Normal"})]}),t.jsx(da,{data:e,xKey:n,series:w.map(x=>({...x,color:x.color??H})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:h,showTooltip:b,valueFormat:x=>Pr(x,0),ariaLabel:v,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function ih({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:h=!0,showTooltip:b=!0,thresholds:f,label:p="RAM",ariaLabel:v="Uso de memoria"}){const w=r>0?r:1,g=Math.min(100,Math.max(0,e/w*100)),A=!d&&!(Number.isFinite(e)&&Number.isFinite(r)&&r>0);if(d)return t.jsx(Nt,{height:i});if(A)return t.jsx(kt,{height:i,text:u});const C=oa(g,f),T=hn(g,f),H=Math.max(0,r-e),E=a.length>0?Wr(a,l)??g:g,x=hn(E,f),M=h&&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:p}),t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("span",{className:"bonsaif-metric-value",style:{color:T},children:Pr(g,g<10?1:0)}),t.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[zr(e)," / ",zr(r)]})]})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:T,background:`color-mix(in srgb, ${T} 14%, transparent)`},children:C==="danger"?"Crítico":C==="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(g),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${p} ${Pr(g,0)}`,children:t.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${g}%`,background:`linear-gradient(90deg, ${T}, color-mix(in srgb, ${T} 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"})," ",zr(e)]}),n!=null&&Number.isFinite(n)?t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",zr(n)]}):null,t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",zr(H)]})]})]}),h&&a.length>1?t.jsx(da,{data:a,xKey:o,series:[{key:l,label:"Uso",color:x}],height:M,yDomain:[0,100],showLegend:!1,showTooltip:b,valueFormat:k=>Pr(k,0),ariaLabel:`${v} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const ch="color-mix(in srgb, var(--primary) 25%, #38bdf8)",dh="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function uh({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=ch,outboundColor:h=dh,height:b=240,className:f="",loading:p=!1,emptyText:v="Sin datos de red",showLegend:w=!1,showTooltip:g=!0,label:A="Network",ariaLabel:C="Tráfico de red"}){const T=o??Wr(e,n)??0,H=l??Wr(e,a)??0,E=!p&&e.length===0;if(p)return t.jsx(Nt,{height:b});if(E)return t.jsx(kt,{height:b,text:v});const x=_=>wi(_,i),k=Math.max(140,b-76);return t.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${f}`,role:"group","aria-label":C,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:A}),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:x(T),children:x(T)})]}),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:h},"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:h},title:x(H),children:x(H)})]})]})]})}),t.jsx("div",{className:"bonsaif-network-plot relative z-0",children:t.jsx(da,{data:e,xKey:r,series:[{key:n,label:c,color:u},{key:a,label:d,color:h}],height:k,showLegend:w,showTooltip:g,valueFormat:x,ariaLabel:C,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const Li=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],Di=["primeSuiteOrigin","primeSuiteProjectKey"];function fh(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const e=new URLSearchParams(window.location.search);for(const r of Li){const n=e.get(r);if(n){const a=ba(n);if(a)return a}}if(typeof sessionStorage<"u")for(const r of Di){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=ba(n);if(a)return a}}if(document.referrer){const r=ba(document.referrer);if(r&&r!==window.location.origin)return r}return"*"}catch{return"*"}}function bh(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const e=new URLSearchParams(window.location.search);for(const r of Li)if(e.get(r))return"query";if(typeof sessionStorage<"u"){for(const r of Di)if(sessionStorage.getItem(r))return"sessionStorage"}if(document.referrer){const r=ba(document.referrer);if(r&&r!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function ba(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 hh(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(h=>({...h,[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(I,"toast",{enumerable:!0,get:()=>Ia.toast}),I.Alert=Ac,I.AreaChart=da,I.AuthShell=mi,I.AutoGrowTextarea=Ql,I.AutoGrowTextareaField=Wf,I.BarChart=Ub,I.BonsaifButton=uc,I.BonsaifUIToaster=_b,I.BulletChart=sh,I.Button=Ke,I.CHART_PALETTE=bn,I.CalendarPicker=Bc,I.ChartCard=Pb,I.Checkbox=Tn,I.CodeBlock=pd,I.ComboChart=Gb,I.CompactFilterSelect=vd,I.CompactSearchInput=gd,I.ConfirmDialog=Nd,I.CopyButton=Ja,I.CopyLinkButton=Ed,I.CpuChart=lh,I.DataSheets=Od,I.DataTable=Xa,I.DateRangePicker=_d,I.DonutChart=Xb,I.Drawer=Kd,I.DropdownMenu=Xd,I.DynamicDetailTabs=Tc,I.EmailField=gu,I.EmptyState=Bn,I.EventCalendar=bd,I.FieldHelperFooter=Ar,I.FieldLabelInfo=$r,I.FieldLayoutEditor=ku,I.FileUpload=wu,I.FormField=jn,I.FunnelChart=nh,I.GaugeChart=ah,I.GlobalScrollbars=ci,I.ImageLightbox=rl,I.ImageLightboxHost=Du,I.InputField=io,I.LineChart=qb,I.LoadingState=us,I.MentionTextEditor=Kl,I.MicroserviceFrame=Ob,I.Modal=Ra,I.MouseTooltip=_t,I.MultiDateCalendar=Wd,I.MultiSelect=Hu,I.NetworkChart=uh,I.NumberField=Bu,I.PageHeader=Ab,I.PageSearchInput=ss,I.Pagination=Fu,I.PhoneField=Pu,I.PieChart=Vb,I.PrimeAuthRouteShell=Lb,I.PrimeSuiteChatFrame=Hb,I.RadioGroup=zu,I.RamChart=ih,I.RichTextEditor=Ef,I.SearchableSelect=fr,I.SectionPanel=Mf,I.Sparkline=Kb,I.StatusBadge=Af,I.StatusSelect=Bf,I.StepWizard=Ff,I.TableSkeleton=Mn,I.Tabs=If,I.TagInput=Qf,I.TextInput=Wn,I.Textarea=Jl,I.TextareaField=Xf,I.TimeField=ob,I.TimePicker=oi,I.Toggle=lb,I.TruncatedWithTooltip=Yt,I.UserAvatar=hi,I.WORKDAY_LABELS=Os,I.WaterfallChart=Zb,I.YearMultiDateCalendar=qd,I.buildMentionQueryRegex=Tl,I.chunkMonthWeeks=Ga,I.chunkMonthWorkWeeks=$s,I.clearMentionChipSelection=Ir,I.cn=Rt,I.computeWeekBars=Za,I.configureBonsaifUI=Wc,I.copyRichCodeBlockFromButton=cl,I.copyTextToClipboard=Qa,I.dedupeMentions=Ol,I.defaultValueFormat=wt,I.deleteEditorSelection=jl,I.describeParentTargetOrigin=bh,I.emailFormat=eu,I.ensureMentionChipTrailingSpaces=dn,I.extractMentionUsernames=So,I.filterSelfMentions=yf,I.filterWorkdays=In,I.findMentionChipAfterCaret=Ul,I.findMentionChipBeforeCaret=ql,I.findMentionChipsInSelection=$o,I.findMentionTriggerInEditor=No,I.formatBytes=zr,I.formatPercent=Pr,I.formatRate=wi,I.getBonsaifUIConfig=jc,I.getDataTablePreferencesEndpoint=qa,I.getEditorPlainText=To,I.getMonthGrid=Ka,I.getPlainTextOffset=Jn,I.getWeekDays=Ya,I.getWorkWeekDays=Ts,I.groupItemsByDay=As,I.highlightMentions=Hl,I.htmlToText=Ll,I.insertMentionInEditor=Il,I.isMentionTriggerBoundary=Al,I.isPlainOffsetInsideMentionChip=$l,I.isValidEmail=oo,I.isValidPhone=so,I.isWeekend=Ms,I.locateTextOffset=Br,I.makeRichCodeBlockHtml=ul,I.markRichCodeCopyButtonCopied=dl,I.matches=su,I.maxLength=nu,I.maxValue=ou,I.mentionDisplayLabel=Dl,I.minLength=ru,I.minValue=au,I.normalizeUsername=ko,I.openImageLightboxFromEvent=el,I.phoneCountryCodeOptions=ol,I.phoneFormat=tu,I.placeCaretAfterMentionChip=Eo,I.placeCaretAtTextOffset=Fl,I.preferredMentionSpacer=Co,I.removeMentionChip=ta,I.required=Rd,I.resetBonsaifUIConfig=qc,I.resolveMentions=vf,I.resolveParentTargetOrigin=fh,I.richCodeBlockPlainText=il,I.richCodeCopyButtonHtml=ll,I.selectAllEditorContents=zl,I.selectMentionChip=Pl,I.selectionIncludesNonChipText=Wl,I.seriesColor=xi,I.setBonsaifDataTablePreferencesEndpoint=Uc,I.syncMentionChipSelectionHighlight=ea,I.toDateKey=Pt,I.toNearestWorkday=od,I.toneColor=jt,I.usageColor=hn,I.usageTone=oa,I.useValidationVisibility=hh,I.validateForm=lu,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})}));
92
+ `;function gh(){if(typeof document>"u"||document.getElementById(_i))return;const e=document.createElement("style");e.id=_i,e.textContent=ph,document.head.appendChild(e)}function Pi(e,r,n){return Math.min(n,Math.max(r,e))}function wa(e,r,n){const a=Pi(n,0,1);return`color-mix(in srgb, ${e} ${Math.round((1-a)*100)}%, ${r} ${Math.round(a*100)}%)`}function vh(e,r,n,a,o,l){const i=e.map((d,u)=>{const h=qr(d[n])??0,b=String(d[r]??""),f=a?String(d[a]??"").trim():"",p=o?String(d[o]??"").trim():"";return{name:b,value:h,color:l[u%l.length],...f?{title:f}:{},...p?{description:p}:{}}}).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 yh(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,h=n===1?1:(d+1)/n,b=l+(i-l)*u,f=l+(i-l)*h;return{...c,index:d,y:r.topY+d*(o+r.gap),h:o,topW:b,bottomW:f,cx:r.cx}})}function xh({stage:e,hovered:r,onHover:n}){const{cx:a,y:o,h:l,topW:i,bottomW:c,color:d}=e,u=a-i/2,h=a+i/2,b=a-c/2,f=a+c/2,p=o+l,g=Math.max(4,Math.min(14,l*.18)),w=wa(d,"#000",r?.12:.22),v=wa(d,"#fff",r?.08:0),L=wa(d,"#fff",.22),M=[`M ${u} ${o}`,`L ${h} ${o}`,`L ${f} ${p}`,`L ${b} ${p}`,"Z"].join(" ");return t.jsxs("g",{onMouseEnter:()=>n(e.index),onMouseLeave:()=>n(null),style:{cursor:"default"},children:[t.jsx("path",{d:M,fill:w}),t.jsx("path",{d:[`M ${u} ${o}`,`L ${h} ${o}`,`L ${h} ${o+1}`,`L ${f} ${p}`,`L ${a} ${p}`,`L ${u} ${o}`,"Z"].join(" "),fill:v,opacity:.55}),t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:g,fill:L,stroke:wa(d,"#000",.15),strokeWidth:1}),r?t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:g,fill:"none",stroke:"var(--text-main)",strokeOpacity:.25,strokeWidth:1.5}):null]})}function wh({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:h=!0,showValues:b=!0,showBottomArrow:f=!0,taper:p=.42,colors:g=[...Nn],animationDuration:w=lr,valueFormat:v=Ct,ariaLabel:L="Gráfico embudo"}){const[M,S]=s.useState(null),[H,C]=s.useState(!1),y=s.useMemo(()=>vh(e,r,n,a,o,g),[e,r,n,a,o,g]),T=s.useMemo(()=>y.map(Z=>`${Z.name}:${Z.value}`).join("|"),[y]);if(s.useEffect(()=>{if(gh(),typeof window>"u")return;const Z=window.matchMedia("(prefers-reduced-motion: reduce)");C(Z.matches);const X=()=>C(Z.matches);return Z.addEventListener("change",X),()=>Z.removeEventListener("change",X)},[]),c)return t.jsx(St,{height:l});if(!y.length)return t.jsx(Et,{height:l,text:d});const N=w>0&&!H,_=w,q=Math.min(90,Math.max(40,Math.round(w/8))),U=Math.round(_*.15),D=y.length*q+Math.round(_*.35),K=y.some(Z=>Z.title||Z.description),j=h?160:24,ie=K?168:24,Q=f?36:8,fe=j+220+ie,F=l,Y=18,ae=Math.max(120,F-Y-Q-8),$=j+110,ce=yh(y,{cx:$,topY:Y,plotH:ae,maxTopW:200,taper:Pi(p,.2,.95),gap:10}),B=M!=null?ce[M]:null,oe="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":L,style:{height:l},children:[t.jsxs("svg",{viewBox:`0 0 ${fe} ${F}`,width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",children:[h?t.jsx("line",{className:N?"bonsaif-funnel-label":void 0,style:N?{animation:`bonsaif-funnel-fade-in ${_}ms ${oe} both`}:void 0,x1:j-12,y1:Y,x2:j-12,y2:Y+ae,stroke:"var(--border)",strokeDasharray:"3 5",strokeWidth:1}):null,ce.map(Z=>{const X=Z.y+Z.h/2,se=Z.cx-Z.topW/2,E=Z.index*q,J=N?{animation:`bonsaif-funnel-stage-in ${_}ms ${oe} ${E}ms both`}:void 0,ee=N?{animation:`bonsaif-funnel-fade-in ${Math.round(_*.85)}ms ${oe} ${E+U}ms both`}:void 0;return t.jsxs("g",{children:[t.jsx("g",{className:"bonsaif-funnel-stage",style:J,children:t.jsx(xh,{stage:Z,hovered:M===Z.index,onHover:S})}),h?t.jsxs("g",{className:"bonsaif-funnel-label",style:ee,children:[t.jsx("line",{x1:24,y1:X,x2:j-12,y2:X,stroke:Z.color,strokeOpacity:.55,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("line",{x1:j-12,y1:X,x2:se-6,y2:X,stroke:Z.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("text",{x:20,y:X-(b?6:0),textAnchor:"end",fill:Z.color,fontSize:12,fontWeight:600,children:Z.name.length>18?`${Z.name.slice(0,16)}…`:Z.name}),b?t.jsx("text",{x:20,y:X+10,textAnchor:"end",fill:"var(--text-muted)",fontSize:11,children:v(Z.value)}):null]}):null,(Z.title||Z.description)&&K?t.jsxs("g",{className:"bonsaif-funnel-anno",style:ee,children:[t.jsx("line",{x1:Z.cx+Z.bottomW/2+6,y1:X,x2:j+220+8,y2:X,stroke:Z.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),Z.title?t.jsx("text",{x:j+220+14,y:X-(Z.description?6:0),fill:"var(--text-main)",fontSize:12,fontWeight:700,children:Z.title.length>22?`${Z.title.slice(0,20)}…`:Z.title}):null,Z.description?t.jsx("text",{x:j+220+14,y:X+(Z.title?10:0),fill:"var(--text-muted)",fontSize:11,children:Z.description.length>28?`${Z.description.slice(0,26)}…`:Z.description}):null]}):null]},`${Z.name}-${Z.index}`)}),f?t.jsx("g",{className:"bonsaif-funnel-arrow",transform:`translate(${$}, ${Y+ae+8})`,fill:"var(--primary)",style:N?{animation:`bonsaif-funnel-arrow-in ${Math.round(_*.7)}ms ${oe} ${D}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]},T),u&&B?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:B.color},children:B.name}),t.jsx("span",{style:{color:"var(--text-muted)"},children:" · "}),v(B.value),t.jsxs("span",{style:{color:"var(--text-muted)"},children:[" ","(",Math.round(B.pct*100),"% del top)"]})]}):null]})}const Gr=135*Math.PI/180,Zo=270*Math.PI/180;function Nh({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=Ct,tone:h="primary",color:b,thresholds:f,ariaLabel:p="Gauge",animationDuration:g=700,thickness:w=9,showScale:v=!1}){const L=s.useId().replace(/:/g,""),M=n-r||1,S=Math.min(1,Math.max(0,(e-r)/M)),[H,C]=s.useState(g>0?0:S);if(s.useEffect(()=>{if(l||i)return;if(g<=0){C(S);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){C(S);return}let fe=0,F=0;C($=>(F=$,$));const Y=performance.now(),ae=$=>{const W=Math.min(1,($-Y)/g),ce=1-(1-W)**3;C(F+(S-F)*ce),W<1&&(fe=requestAnimationFrame(ae))};return fe=requestAnimationFrame(ae),()=>cancelAnimationFrame(fe)},[S,g,l,i]),l)return t.jsx(St,{height:a});if(i)return t.jsx(Et,{height:a,text:c});const y=100,T=108,N=72,_=b??kh(e,n,h,f),q=r+H*M,U=zi(y,T,N,Gr,Gr+Zo),D=Gr+Math.max(.001,H)*Zo,K=zi(y,T,N,Gr,D),j=Na(y,T,N,Gr),ie=Na(y,T,N,Gr+Zo);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":p,className:"overflow-visible",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:`bonsaif-gauge-${L}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[t.jsx("stop",{offset:"0%",stopColor:_,stopOpacity:.82}),t.jsx("stop",{offset:"100%",stopColor:_,stopOpacity:1})]})}),t.jsx("path",{d:U,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:w,strokeLinecap:"butt"}),t.jsx("path",{d:K,fill:"none",stroke:`url(#bonsaif-gauge-${L})`,strokeWidth:w,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),t.jsx("text",{x:y,y:T-(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(q)}),d?t.jsx("text",{x:y,y:T+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:d}):null,v?t.jsxs(t.Fragment,{children:[t.jsx("text",{x:j.x-2,y:j.y+w+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(r)}),t.jsx("text",{x:ie.x+2,y:ie.y+w+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(n)})]}):null]})})}function kh(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 qt(n);const o=e/(r||1);return o>=.8?qt("success"):o>=.5?qt("warning"):qt("danger")}function Na(e,r,n,a){return{x:e+n*Math.cos(a),y:r+n*Math.sin(a)}}function zi(e,r,n,a,o){const l=Na(e,r,n,a),i=Na(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 Ch({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:h,valueFormat:b=Ct,tone:f="primary",showScale:p=!0,showStatus:g=!0,ariaLabel:w="Bullet chart"}){if(i)return t.jsx(St,{height:o});if(c)return t.jsx(Et,{height:o,text:d});const v=n??Math.max(e,r,...(a==null?void 0:a.map(_=>_.value))??[],1)*1.05,M=[...a??[{value:v*.5,color:"color-mix(in srgb, var(--border) 72%, transparent)"},{value:v*.75,color:"color-mix(in srgb, var(--border) 48%, transparent)"},{value:v,color:"color-mix(in srgb, var(--border) 28%, transparent)"}]].sort((_,q)=>_.value-q.value),S=qt(f),H=Math.min(100,Math.max(0,e/v*100)),C=Math.min(100,Math.max(0,r/v*100)),y=e>=r,T=[0,.25,.5,.75,1].map(_=>_*v),N=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":w,children:[t.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:M.map((_,q)=>{const U=q===0?0:M[q-1].value,D=Math.max(0,(_.value-U)/v*100);return t.jsx("div",{style:{width:`${D}%`,background:_.color??`color-mix(in srgb, var(--border) ${70-q*18}%, transparent)`}},q)})}),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:`${H}%`,background:S,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${S} 35%, transparent)`}})}),t.jsx("div",{className:"bonsaif-bullet-target absolute top-1/2 z-[1]",style:{left:`${C}%`,height:"72%",width:3,transform:"translate(-50%, -50%)",background:S,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${b(r)}`})]}),p?t.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:T.map((_,q)=>{const U=_/v*100,D=q===0,K=q===T.length-1;return t.jsxs("div",{className:"absolute top-0",style:{left:`${U}%`,transform:D?"none":K?"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:D?0:K?"auto":void 0,marginRight:K?0:void 0}}),t.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:D?"left":K?"right":"center"},children:b(_)})]},_)})}):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}),h?t.jsx("div",{className:"mt-0.5 text-[11px] leading-snug",style:{color:"var(--text-muted)"},children:h}):t.jsxs("div",{className:"mt-0.5 text-[11px] tabular-nums leading-snug",style:{color:"var(--text-muted)"},children:[t.jsx("span",{style:{color:S,fontWeight:600},children:b(e)}),t.jsxs("span",{children:[" / meta ",b(r)]})]}),g?t.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:qt(y?"success":"warning")},children:y?"En meta":"Bajo meta"}):null]}),N]}):N})}function Sh({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:h=!1,showTooltip:b=!0,thresholds:f,label:p="CPU",ariaLabel:g="Uso de CPU"}){var C;const w=o??[{key:a,label:"Uso",color:kn(r??Xr(e,a)??0,f)}],v=r??Xr(e,a)??Xr(e,((C=w[0])==null?void 0:C.key)??a),L=!d&&(!e.length||v===null);if(d)return t.jsx(St,{height:i});if(L)return t.jsx(Et,{height:i,text:u});const M=Math.min(100,Math.max(0,v??0)),S=ma(M,f),H=kn(M,f);return t.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":g,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:[p,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:H},children:Ur(M,M<10?1:0)})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:H,background:`color-mix(in srgb, ${H} 14%, transparent)`},children:S==="danger"?"Crítico":S==="warning"?"Alto":"Normal"})]}),t.jsx(xa,{data:e,xKey:n,series:w.map(y=>({...y,color:y.color??H})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:h,showTooltip:b,valueFormat:y=>Ur(y,0),ariaLabel:g,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function Eh({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:h=!0,showTooltip:b=!0,thresholds:f,label:p="RAM",ariaLabel:g="Uso de memoria"}){const w=r>0?r:1,v=Math.min(100,Math.max(0,e/w*100)),L=!d&&!(Number.isFinite(e)&&Number.isFinite(r)&&r>0);if(d)return t.jsx(St,{height:i});if(L)return t.jsx(Et,{height:i,text:u});const M=ma(v,f),S=kn(v,f),H=Math.max(0,r-e),C=a.length>0?Xr(a,l)??v:v,y=kn(C,f),T=h&&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":g,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:p}),t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("span",{className:"bonsaif-metric-value",style:{color:S},children:Ur(v,v<10?1:0)}),t.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[Vr(e)," / ",Vr(r)]})]})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:S,background:`color-mix(in srgb, ${S} 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(v),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${p} ${Ur(v,0)}`,children:t.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${v}%`,background:`linear-gradient(90deg, ${S}, color-mix(in srgb, ${S} 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"})," ",Vr(e)]}),n!=null&&Number.isFinite(n)?t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",Vr(n)]}):null,t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",Vr(H)]})]})]}),h&&a.length>1?t.jsx(xa,{data:a,xKey:o,series:[{key:l,label:"Uso",color:y}],height:T,yDomain:[0,100],showLegend:!1,showTooltip:b,valueFormat:N=>Ur(N,0),ariaLabel:`${g} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const Mh="color-mix(in srgb, var(--primary) 25%, #38bdf8)",Th="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function $h({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=Mh,outboundColor:h=Th,height:b=240,className:f="",loading:p=!1,emptyText:g="Sin datos de red",showLegend:w=!1,showTooltip:v=!0,label:L="Network",ariaLabel:M="Tráfico de red"}){const S=o??Xr(e,n)??0,H=l??Xr(e,a)??0,C=!p&&e.length===0;if(p)return t.jsx(St,{height:b});if(C)return t.jsx(Et,{height:b,text:g});const y=_=>Li(_,i),N=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:L}),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:y(S),children:y(S)})]}),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:h},"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:h},title:y(H),children:y(H)})]})]})]})}),t.jsx("div",{className:"bonsaif-network-plot relative z-0",children:t.jsx(xa,{data:e,xKey:r,series:[{key:n,label:c,color:u},{key:a,label:d,color:h}],height:N,showLegend:w,showTooltip:v,valueFormat:y,ariaLabel:M,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const Wi=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],ji=["primeSuiteOrigin","primeSuiteProjectKey"];function Ah(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const e=new URLSearchParams(window.location.search);for(const r of Wi){const n=e.get(r);if(n){const a=ka(n);if(a)return a}}if(typeof sessionStorage<"u")for(const r of ji){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=ka(n);if(a)return a}}if(document.referrer){const r=ka(document.referrer);if(r&&r!==window.location.origin)return r}return"*"}catch{return"*"}}function Lh(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const e=new URLSearchParams(window.location.search);for(const r of Wi)if(e.get(r))return"query";if(typeof sessionStorage<"u"){for(const r of ji)if(sessionStorage.getItem(r))return"sessionStorage"}if(document.referrer){const r=ka(document.referrer);if(r&&r!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function ka(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 Dh(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(h=>({...h,[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(I,"toast",{enumerable:!0,get:()=>Xa.toast}),I.Alert=Pc,I.AreaChart=xa,I.AuthShell=Si,I.AutoGrowTextarea=li,I.AutoGrowTextareaField=Jf,I.BarChart=ih,I.BonsaifButton=xc,I.BonsaifUIToaster=rh,I.BulletChart=Ch,I.Button=Xe,I.CHART_PALETTE=Nn,I.CalendarPicker=Uc,I.ChartCard=nh,I.Checkbox=Fn,I.CodeBlock=Md,I.ComboChart=bh,I.CompactFilterSelect=$d,I.CompactSearchInput=Td,I.ConfirmDialog=Od,I.CopyButton=io,I.CopyLinkButton=Fd,I.CpuChart=Sh,I.DataSheets=Ud,I.DataTable=ro,I.DateRangePicker=Kd,I.DonutChart=dh,I.Drawer=ou,I.DropdownMenu=nu,I.DynamicDetailTabs=Fc,I.EmailField=Tu,I.EmptyState=Un,I.EventCalendar=Cd,I.FieldHelperFooter=Hr,I.FieldLabelInfo=Or,I.FieldLayoutEditor=Hu,I.FileUpload=Du,I.FormField=Qn,I.FunnelChart=wh,I.GaugeChart=Nh,I.GlobalScrollbars=yi,I.ImageLightbox=fl,I.ImageLightboxHost=qu,I.InputField=yo,I.LineChart=lh,I.LoadingState=ws,I.MentionTextEditor=ai,I.MicroserviceFrame=Qb,I.Modal=co,I.MouseTooltip=Pt,I.MultiDateCalendar=Jd,I.MultiSelect=Vu,I.NetworkChart=$h,I.NumberField=Xu,I.PageHeader=Gb,I.PageSearchInput=ps,I.Pagination=Gu,I.PhoneField=Zu,I.PieChart=ch,I.PrimeAuthRouteShell=Kb,I.PrimeSuiteChatFrame=Jb,I.RadioGroup=Qu,I.RamChart=Eh,I.RichTextEditor=Ff,I.SearchableSelect=br,I.SectionPanel=_f,I.Sparkline=fh,I.SpotlightTour=Cb,I.StatusBadge=Wf,I.StatusSelect=Xf,I.StepWizard=Gf,I.TableSkeleton=In,I.Tabs=Yf,I.TagInput=ib,I.TextInput=Zn,I.Textarea=ii,I.TextareaField=nb,I.TimeField=pb,I.TimePicker=mi,I.Toggle=vb,I.TruncatedWithTooltip=Yt,I.UserAvatar=Ci,I.WORKDAY_LABELS=qs,I.WaterfallChart=hh,I.YearMultiDateCalendar=eu,I.buildMentionQueryRegex=_l,I.chunkMonthWeeks=oo,I.chunkMonthWorkWeeks=Ps,I.clearMentionChipSelection=zr,I.cn=Rt,I.computeWeekBars=so,I.configureBonsaifUI=Zc,I.copyRichCodeBlockFromButton=yl,I.copyTextToClipboard=lo,I.dedupeMentions=ql,I.defaultValueFormat=Ct,I.deleteEditorSelection=Jl,I.describeParentTargetOrigin=Lh,I.emailFormat=uu,I.ensureMentionChipTrailingSpaces=yn,I.extractMentionUsernames=Ho,I.filterSelfMentions=Af,I.filterWorkdays=Vn,I.findMentionChipAfterCaret=ei,I.findMentionChipBeforeCaret=Rl,I.findMentionChipsInSelection=Po,I.findMentionTriggerInEditor=Do,I.formatBytes=Vr,I.formatPercent=Ur,I.formatRate=Li,I.getBonsaifUIConfig=Qc,I.getDataTablePreferencesEndpoint=Ra,I.getEditorPlainText=_o,I.getMonthGrid=ao,I.getPlainTextOffset=la,I.getWeekDays=no,I.getWorkWeekDays=_s,I.groupItemsByDay=zs,I.highlightMentions=Ul,I.htmlToText=Wl,I.insertMentionInEditor=Xl,I.isMentionTriggerBoundary=zl,I.isPlainOffsetInsideMentionChip=Pl,I.isValidEmail=po,I.isValidPhone=go,I.isWeekend=Fs,I.locateTextOffset=Pr,I.makeRichCodeBlockHtml=wl,I.markRichCodeCopyButtonCopied=xl,I.matches=gu,I.maxLength=hu,I.maxValue=pu,I.mentionDisplayLabel=jl,I.minLength=bu,I.minValue=mu,I.normalizeUsername=Oo,I.openImageLightboxFromEvent=dl,I.phoneCountryCodeOptions=ml,I.phoneFormat=fu,I.placeCaretAfterMentionChip=Io,I.placeCaretAtTextOffset=Yl,I.preferredMentionSpacer=Bo,I.removeMentionChip=da,I.required=du,I.resetBonsaifUIConfig=Jc,I.resolveMentions=$f,I.resolveParentTargetOrigin=Ah,I.richCodeBlockPlainText=vl,I.richCodeCopyButtonHtml=gl,I.selectAllEditorContents=Zl,I.selectMentionChip=Kl,I.selectionIncludesNonChipText=Ql,I.seriesColor=Ai,I.setBonsaifDataTablePreferencesEndpoint=Rc,I.syncMentionChipSelectionHighlight=ca,I.toDateKey=zt,I.toNearestWorkday=pd,I.toneColor=qt,I.usageColor=kn,I.usageTone=ma,I.useSpotlightTour=Sb,I.useValidationVisibility=Dh,I.validateForm=vu,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})}));