bonsaif-ui 0.1.159 → 0.1.161

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,9 +1,9 @@
1
- (function(F,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):(F=typeof globalThis<"u"?globalThis:F||self,s(F.BonsaifUI={},F.React,F.jsxRuntime,F.ReactIconsHi2,F.ReactDOM,F.Recharts,F.OverlayScrollbarsGlobal,F.Sonner,F.OverlayScrollbarsReact,F.ReactDayPicker,F.ReactDayPickerStyles,F.ReactIconsFi))})(this,(function(F,s,t,z,ht,Le,Va,Xa,ms,Ya,xm,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 N=()=>{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(),N())},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),N=s.useRef(!1),[v,H]=s.useState(null),[S,M]=s.useState("");s.useEffect(()=>{const L=f.current;L&&(L.querySelectorAll("[title]").forEach(J=>{const q=J.getAttribute("title");q&&(J.getAttribute("aria-label")||J.setAttribute("aria-label",q),J.removeAttribute("title"))}),L.querySelectorAll("svg title").forEach(J=>J.remove()))}),s.useLayoutEffect(()=>{if(!v)return;const L=p.current;if(!L)return;const J=12,q=14,ae=L.getBoundingClientRect(),R=window.innerWidth-ae.width-J,fe=window.innerHeight-ae.height-J;let I=v.mouseX+q,K=v.mouseY+q,ee,T;if(!o&&f.current){const W=f.current.getBoundingClientRect(),ie=W.left+W.width/2,B=W.top+W.height/2;l==="top"?(I=ie-ae.width/2,K=W.top-ae.height-q,T=ae.height-1):l==="left"?(I=W.left-ae.width-q,K=B-ae.height/2,ee=ae.width-1):l==="right"?(I=W.right+q,K=B-ae.height/2,ee=-7):(I=ie-ae.width/2,K=W.bottom+q,T=-7)}if(o&&(I>R&&(I=v.mouseX-ae.width-q),K>fe&&(K=v.mouseY-ae.height-q)),I=Math.min(Math.max(J,I),Math.max(J,R)),K=Math.min(Math.max(J,K),Math.max(J,fe)),!o&&f.current){const W=f.current.getBoundingClientRect(),ie=W.left+W.width/2,B=W.top+W.height/2;l==="top"||l==="bottom"?ee=Math.min(Math.max(14,ie-I),ae.width-14):T=Math.min(Math.max(14,B-K),ae.height-14)}(Math.abs(I-v.x)>.5||Math.abs(K-v.y)>.5||ee!==v.arrowX||T!==v.arrowY)&&H(W=>W&&{...W,x:I,y:K,arrowX:ee,arrowY:T})},[o,l,v]);const D=()=>{g.current&&(window.clearTimeout(g.current),g.current=null)},C=(L,J)=>{if(!wc()||N.current)return;const q=f.current;if(q&&!Bn(q)){if(n){const ae=Nc(q);if(!ae)return;M(ae)}!n&&!r||H({mouseX:L,mouseY:J,x:L+14,y:J+14})}},x=()=>{const L=f.current;if(!L)return;const J=L.getBoundingClientRect();C(J.left+J.width/2,J.bottom)},$=()=>{D(),H(null)},y=()=>{if(!a){$();return}D(),g.current=window.setTimeout(()=>H(null),120)},P=()=>{Hn(),N.current=!0,$()},j=()=>{N.current=!1};s.useEffect(()=>{if(!v)return;if(Bn(f.current)){H(null);return}const L=()=>H(null),J=()=>{Hn(),N.current=!0,H(null)};document.addEventListener("pointerdown",J,!0),document.addEventListener("click",J,!0),document.addEventListener("scroll",L,!0),window.addEventListener("blur",L),document.addEventListener("visibilitychange",L),document.addEventListener("keydown",L,!0);const q=new MutationObserver(()=>{Bn(f.current)&&H(null)});return q.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",J,!0),document.removeEventListener("click",J,!0),document.removeEventListener("scroll",L,!0),window.removeEventListener("blur",L),document.removeEventListener("visibilitychange",L),document.removeEventListener("keydown",L,!0),q.disconnect()}},[v]),s.useEffect(()=>{const L=()=>Hn(),J=()=>{Hn(),N.current=!0,H(null)};return document.addEventListener("pointerdown",L,!0),document.addEventListener("click",L,!0),document.addEventListener("keydown",L,!0),window.addEventListener(ys,J),()=>{document.removeEventListener("pointerdown",L,!0),document.removeEventListener("click",L,!0),document.removeEventListener("keydown",L,!0),window.removeEventListener(ys,J)}},[]);const U=n?S:r;return t.jsxs(t.Fragment,{children:[t.jsx(b,{ref:L=>{f.current=L},className:c,style:u,onMouseEnter:L=>{D(),j(),o?C(L.clientX,L.clientY):x()},onMouseMove:L=>{v&&o&&C(L.clientX,L.clientY)},onMouseDown:P,onClick:P,onMouseLeave:()=>{j(),y()},onFocus:x,onBlur:$,children:e}),v&&U&&!Bn(f.current)?ht.createPortal(t.jsxs("div",{ref:p,role:"tooltip",className:d,onMouseEnter:a?D:void 0,onMouseLeave:a?y: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 Ve({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",N=p.compact??!1,v=p.headerAction??!1,H=v&&r==="md"?"sm":N&&!v&&r==="md"?"xs":r,S=e==="icon"||g,M=v&&S,D=Ga(d),C=o??f.title??f["aria-label"]??(g?D:void 0),x=C?void 0:f.title,$=f["aria-label"]??(typeof C=="string"?C:D||void 0),y=n?null:a??(g?$c(d):null),P=t.jsxs("button",{...f,title:x,"aria-label":$,"data-variant":e,"data-size":H,"data-icon":S?"true":void 0,disabled:h||n,className:`${kc} ${M?Sc:Cc[e]} ${S?Mc[H]:Ec[H]} ${N&&!S?"px-2.5":""} ${u}`,style:{...Tc[e],height:xs(i),padding:xs(c),...b,...v&&!S?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...M?{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"}):y,!g&&d]});return C?t.jsx(Pt,{as:"span",content:C,className:"inline-flex shrink-0",children:P}):P}const pt={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: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 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: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 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(Ve,{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:N,loadingState:v,errorState:H=Ic,renderTabLabel:S,searchableTabs:M="auto",tabsSearchThreshold:D=6,tabsSearchPlaceholder:C="Buscar modulo...",tabsSearchValue:x,onTabsSearchChange:$,emptySearchState:y,showTabCount:P=!0,className:j="",parentClassName:U="",contentClassName:L="",tabsClassName:J=""}){var Te;const q=s.useMemo(()=>l.filter(ne=>!ne.hidden&&((b==null?void 0:b(ne,o))??!0)),[b,o,l]),ae=(Te=q.find(ne=>!ne.disabled))==null?void 0:Te.service,[R,fe]=s.useState(u??ae??""),[I,K]=s.useState({}),[ee,T]=s.useState({}),[W,ie]=s.useState(""),[B,re]=s.useState(!1),Z=s.useRef(ee),Y=s.useRef(0),se=x??W,E=ks(se),Q=M===!0||M==="auto"&&q.length>=D,ce=Q&&se.trim().length>0,X=s.useMemo(()=>E?q.filter(ne=>ks(Hc(ne)).includes(E)):q,[E,q]),w=d??R,k=q.find(ne=>ne.service===w)??q.find(ne=>!ne.disabled);s.useEffect(()=>{!k&&ae&&fe(ae)},[ae,k]),s.useEffect(()=>{Z.current=ee},[ee]);const te=ne=>{ne.disabled||(d||fe(ne.service),h==null||h(ne.service,ne))},ue=ne=>{x===void 0&&ie(ne),$==null||$(ne)},oe=(ne,He)=>{const ze=X.filter(Xe=>!Xe.disabled),Ye=ze.findIndex(Xe=>Xe.service===He.service);Ye<0||((ne.key==="ArrowRight"||ne.key==="ArrowDown")&&(ne.preventDefault(),te(ze[(Ye+1)%ze.length])),(ne.key==="ArrowLeft"||ne.key==="ArrowUp")&&(ne.preventDefault(),te(ze[(Ye-1+ze.length)%ze.length])),ne.key==="Home"&&(ne.preventDefault(),te(ze[0])),ne.key==="End"&&(ne.preventDefault(),te(ze[ze.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 ze=(i==null?void 0:i[ne])??c;if(!ze){T(Xe=>({...Xe,[ne]:{loading:!1,error:new Error(`No module loader found for service "${ne}".`)}}));return}const Ye=++Y.current;T(Xe=>({...Xe,[ne]:{...Xe[ne],loading:!0,error:void 0}})),ze(k,o).then(Xe=>{if(Ye!==Y.current&&!f)return;const We=Bc(Xe);T(Je=>({...Je,[ne]:{component:We,loading:!1}}))}).catch(Xe=>{const We=Xe instanceof Error?Xe:new Error(String(Xe));T(Je=>({...Je,[ne]:{...Je[ne],loading:!1,error:We}}))})},[o,f,c,i,k]);s.useEffect(ge,[ge]);const Me=k?I[k.service]??null:null,Ae=k?ee[k.service]:void 0,$t=Ae==null?void 0:Ae.component,mt=ne=>{k&&K(He=>({...He,[k.service]:ne}))},gt=()=>{k&&K(ne=>({...ne,[k.service]:null}))},Qe={context:o,parent:a,links:l,visibleLinks:q,filteredLinks:X,selectedLink:k,selectedService:k==null?void 0:k.service,activeItemId:Me,tabsSearch:se,onSelectService:te,onOpenDetail:mt,onBackToList:gt},de=n?n(Qe):r?t.jsx(r,{...Qe}):e;return t.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${j}`,children:[t.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${U}`,children:de}),t.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${L}`,children:[(p||g||Q||P)&&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})]}),(Q||P)&&t.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[P&&t.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[X.length," / ",q.length]}),Q&&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:ue,placeholder:C,className:"w-full",autoFocus:B,forceExpanded:!0,onEscape:()=>re(!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&&ue(""),re(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||ce?"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||ce?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 ${J}`,children:X.length>0?X.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:ze=>oe(ze,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:S?S(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:y??"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&&(N??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&&(Ae==null?void 0:Ae.loading)&&(v??t.jsx(ws,{title:"Cargando modulo..."})),k&&(Ae==null?void 0:Ae.error)&&H(Ae.error,ge),k&&$t&&!(Ae!=null&&Ae.loading)&&!(Ae!=null&&Ae.error)&&t.jsx($t,{context:o,parent:a,link:k,activeItemId:Me,onOpenDetail:mt,onBackToList:gt})]})]})]})}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(Ve,{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"}),[N,v]=s.useState(d.year),[H,S]=s.useState(d.month),[M,D]=s.useState("days"),C=16,[x,$]=s.useState(0),y=N-7+x,P=Array.from({length:C},(I,K)=>y+K);s.useEffect(()=>{if(!u||!h||!f.current)return;const I=f.current.getBoundingClientRect(),K=8,ee=280,T=340,W=I.left+ee>window.innerWidth-K,ie=I.right-ee>=K,B=I.bottom+8+T>window.innerHeight-K,re=I.top-8-T>=K;g({horizontal:W&&ie?"right":"left",vertical:B&&re?"top":"bottom"})},[u,h]),s.useEffect(()=>{if(!u||!h)return;function I(ee){f.current&&(f.current.contains(ee.target)||b(!1))}function K(ee){ee.key==="Escape"&&b(!1)}return document.addEventListener("mousedown",I),document.addEventListener("keydown",K),()=>{document.removeEventListener("mousedown",I),document.removeEventListener("keydown",K)}},[u,h]);function j(){H===1?(v(I=>I-1),S(12)):S(I=>I-1)}function U(){H===12?(v(I=>I+1),S(1)):S(I=>I+1)}const L=(new Date(N,H-1,1).getDay()+6)%7,J=new Date(N,H,0).getDate(),q=[...Array(L).fill(null),...Array.from({length:J},(I,K)=>K+1)];for(;q.length<Ss*7;)q.push(null);const ae=q.slice(0,Ss*7);function R(I){const K=Ka(N,H,I);n&&K<n||a&&Es(K)||(r(K),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:M==="days"?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:j,"aria-label":"Mes anterior",children:t.jsx(z.HiChevronLeft,{size:16})}),t.jsxs("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>{D("years"),$(0)},children:[t.jsxs("span",{className:"bonsaif-cal-title",children:[Cs[H-1]," ",N]}),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:()=>$(I=>I-C),"aria-label":"Años anteriores",children:t.jsx(z.HiChevronLeft,{size:16})}),t.jsx("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>D("days"),children:t.jsxs("span",{className:"bonsaif-cal-title",children:[P[0]," – ",P[P.length-1]]})}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>$(I=>I+C),"aria-label":"Años siguientes",children:t.jsx(z.HiChevronRight,{size:16})})]})}),M==="years"?t.jsxs("div",{className:"bonsaif-cal-picker-years",children:[t.jsx("div",{className:"bonsaif-cal-picker-months",children:zc.map((I,K)=>{const ee=K+1===H;return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${ee?" is-active":""}`,onClick:()=>S(K+1),children:I},I)})}),t.jsx("div",{className:"bonsaif-cal-picker-year-grid",children:P.map(I=>{const K=I===N,ee=I===new Date().getFullYear();return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${K?" is-active":""}${ee&&!K?" is-today":""}`,onClick:()=>{v(I),D("days")},children:I},I)})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bonsaif-multi-weekdays bonsaif-cal-picker-weekdays",children:Wc.map(I=>t.jsx("div",{className:"bonsaif-multi-weekday",children:I},I))}),t.jsx("div",{className:"bonsaif-cal-picker-days",children:ae.map((I,K)=>{if(I===null)return t.jsx("div",{className:"bonsaif-multi-day bonsaif-multi-day-hidden"},K);const ee=Ka(N,H,I),T=ee===e,W=ee===i,ie=!!(n&&ee<n)||a&&Es(ee);return t.jsx("div",{className:`bonsaif-multi-day${T?" bonsaif-multi-day-selected":""}${W?" bonsaif-multi-day-today":""}${ie?" bonsaif-multi-day-disabled":""}`,children:t.jsx("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:ie,"aria-pressed":T,onClick:()=>!ie&&R(I),children:I})},K)})})]})]})});return u?t.jsxs("div",{ref:f,className:`relative w-full ${l}`.trim(),children:[t.jsxs("button",{type:"button",onClick:()=>b(I=>!I),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:N="0 10px",searchable:v=!0,minOptionsForSearch:H=6}){const[S,M]=s.useState(!1),[D,C]=s.useState(""),[x,$]=s.useState(-1),[y,P]=s.useState(!1),[j,U]=s.useState({}),L=s.useRef(null),J=s.useRef(null),q=s.useRef(null),ae=s.useRef(null),R=v&&n.length>=H,fe=n.find(E=>E.value===e)??null,I=l==="ghost",K=a==="error"?"var(--danger)":S?"var(--primary)":"var(--border)",ee=R&&D.trim()?n.filter(E=>Vc(E,D)):n,T=s.useCallback(()=>{const E=L.current;if(!(E!=null&&E.isConnected))return;const Q=E.getBoundingClientRect();if(Q.width<1&&Q.height<1||Q.bottom<0||Q.top>window.innerHeight)return;const ce=R?272:212,X=window.innerHeight-Q.bottom,w=X<ce&&Q.top>X,k=8,te=Math.max(Q.width,0),ue=Math.max(k,window.innerWidth-te-k),oe=Math.min(Math.max(k,Q.left),ue);U({position:"fixed",left:oe,top:w?void 0:Q.bottom+4,bottom:w?window.innerHeight-Q.top+4:void 0,width:Q.width,minWidth:Qa(f),zIndex:p})},[f,p,R]);s.useEffect(()=>P(!0),[]),s.useEffect(()=>{if(!S)return;function E(Q){var X,w;const ce=Q.target;!((X=L.current)!=null&&X.contains(ce))&&!((w=J.current)!=null&&w.contains(ce))&&(M(!1),C(""))}return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[S]),s.useEffect(()=>{S&&($(-1),T(),R&&setTimeout(()=>{var E;return(E=q.current)==null?void 0:E.focus()},0))},[S,R,T]),s.useEffect(()=>{if(S)return window.addEventListener("resize",T),window.addEventListener("scroll",T,!0),()=>{window.removeEventListener("resize",T),window.removeEventListener("scroll",T,!0)}},[S,T]),s.useEffect(()=>{if(x<0||!ae.current)return;const E=ae.current.children[x];E==null||E.scrollIntoView({block:"nearest"})},[x]);const W=s.useCallback(E=>{r(E),M(!1),C("")},[r]),ie=s.useRef(S);ie.current=S;const B=s.useRef(ee);B.current=ee;const re=s.useRef(x);re.current=x;const Z=s.useRef(d);Z.current=d;const Y=s.useRef(W);Y.current=W,s.useEffect(()=>{function E(Q){var k,te;const ce=document.activeElement,X=((k=L.current)==null?void 0:k.contains(ce))??!1,w=((te=J.current)==null?void 0:te.contains(ce))??!1;if(!(!X&&!w)){if(!ie.current){(Q.key==="Enter"||Q.key===" "||Q.key==="ArrowDown")&&(Q.preventDefault(),M(!0));return}switch(Q.key){case"ArrowDown":Q.preventDefault(),$(ue=>Math.min(ue+1,B.current.length-1));break;case"ArrowUp":Q.preventDefault(),$(ue=>Math.max(ue-1,Z.current?-1:0));break;case"Enter":{Q.preventDefault();const ue=re.current,oe=B.current;ue===-1&&Z.current?Y.current(""):oe[ue]&&!oe[ue].disabled&&Y.current(oe[ue].value);break}case"Escape":Q.preventDefault(),Q.stopPropagation(),M(!1),C("");break}}}return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[]);const se=t.jsxs("div",{ref:J,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...j,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[R&&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:q,value:D,onChange:E=>{C(E.target.value),$(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),D&&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:ae,role:"listbox",className:"overflow-y-auto",style:{maxHeight:R?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:()=>$(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:x===-1&&!D.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:d}),ee.map((E,Q)=>{const X=Q===x,w=E.value===e;return t.jsxs("li",{role:"option","aria-selected":w,onMouseDown:k=>{k.preventDefault(),E.disabled||W(E.value)},onMouseEnter:()=>!E.disabled&&$(Q),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:X?"var(--bg-hover)":w?"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:w?"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)}),ee.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:L,className:`relative ${h||"w-full"}`,style:b,children:[t.jsxs("button",{type:"button",disabled:u,onClick:()=>!u&&M(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(N),background:I?"transparent":"var(--bg-input)",color:fe?"var(--text-main)":"var(--text-muted)",border:I?"1px solid transparent":`1px solid ${K}`,opacity:u?.5:1,cursor:u?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":S,"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:S?"rotate(180deg)":"rotate(0deg)"}})]}),S&&y&&ht.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 kt(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 Ar(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Ar).join(" ").trim():s.isValidElement(e)?Ar(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):Ar(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 Lr(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 Lr(e,a)>0;case"greaterThanOrEqual":return Lr(e,a)>=0;case"lessThan":return Lr(e,a)<0;case"lessThanOrEqual":return Lr(e,a)<=0;case"between":return Lr(e,a)>=0&&Lr(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:N,onToggleOne:v,onToggleAll:H,getRowSelectable:S,highlightSelected:M=!0,rowClassName:D,getRowCategory:C,stickyHeader:x=!0,pageSize:$=25,pageSizeOptions:y,pageSizeSelectWidth:P=62,pageSizeSelectHeight:j=30,pageSizeSelectPadding:U="0 7px",totalRows:L,page:J,onPageChange:q,onPageSizeChange:ae,storageKey:R,stickyFirstColumn:fe=!1,bottomOffset:I=0,compact:K=!0,restrictHeight:ee=!0,maxHeight:T,minTableWidth:W,enableColumnVisibility:ie=!0,enableColumnFilters:B=!0,hiddenColumnKeys:re,defaultHiddenColumnKeys:Z=od,onHiddenColumnKeysChange:Y,columnVisibilityLabel:se="Columnas",enableBql:E=!1,bqlValue:Q,defaultBqlValue:ce="",onBqlChange:X,bqlDescription:w="Filtra registros con Bonsaif Query Language",bqlPlaceholder:k=`status = activo
2
- rol IN (admin, employee)`,bqlQuickFilters:te=[],bqlExamples:ue=[],bqlSuggestions:oe=[],bqlActiveFilters:ge,bqlError:Me,onQueryChange:Ae,persistState:$t,onPreferencesReady:mt,enableExport:gt=!1,exportFilename:Qe="datos",onExportCsv:de,onExportPdf:Te}){var gc;const ne=id($t,R),He=Object.values(ne).some(Boolean),ze=e.map(m=>m.key).join(","),Ye=Z.join(","),Xe=s.useRef(e),We=s.useRef(Z);Xe.current=e,We.current=Z;const[Je,vt]=s.useState(!R||!He),ut=s.useRef(null),yt=s.useRef(!R),me=s.useRef(!1),ye=s.useRef(mt);ye.current=mt;const Be=s.useRef(!R||!He?R??"__none__":null),_e=re!==void 0,[Ge,rt]=s.useState(()=>tr(Z,e)),at=tr(_e?re:Ge,e),[Re,st]=s.useState(!1),[nt,gr]=s.useState("filter"),[it,vr]=s.useState(null),[At,qe]=s.useState(""),[ct,ir]=s.useState({}),[xt,Ft]=s.useState({}),yr=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&&(yr.current={...yr.current,...V}),Object.keys(O).length>0&&(cr.current={...cr.current,...O})}const _=b!==void 0,[G,pe]=s.useState(f),he=Q!==void 0,[Ee,ke]=s.useState(ce),Fe=he?Q:Ee,[Pe,dt]=s.useState(Fe),[Ke,wt]=s.useState(!1),[Zt,Nt]=s.useState(!1),[xr,Qt]=s.useState(!1),[dr,Zr]=s.useState([]),Qr=s.useRef(null),Jr=s.useRef(null),wr=s.useRef(null),Ut=s.useRef(X);Ut.current=X;const Ca=s.useRef($);Ca.current=$;const Sa=s.useRef(y);Sa.current=y;const Bh=Array.isArray(y)?y.join(","):"",Qo=s.useRef(null),qi=s.useRef(null),Jo=s.useRef(null),Ui=s.useRef(0),[Ih,Fh]=s.useState({}),[_h,Ph]=s.useState({}),[Mn,Ea]=s.useState(!1),Ro=s.useRef(null),Ma=s.useRef(null),[zh,Wh]=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),[jh,qh]=s.useState(void 0),[Gi,Uh]=s.useState(0),[Vh,Xh]=s.useState(!1);s.useEffect(()=>{function m(){Xh(window.innerWidth<640)}if(!ee||T!==void 0)return m(),window.addEventListener("resize",m),()=>window.removeEventListener("resize",m);const V=$!==!1?48:0,O=12;function le(){if(m(),!Lt.current)return;const we=Lt.current.getBoundingClientRect().top;qh(Math.max(120,window.innerHeight-we-V-O-I))}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,$,I,ee,T,Je,r.length]);const Ki=ee?T??jh:void 0;s.useEffect(()=>{const m=Lt.current;if(!m)return;const A=()=>Uh(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)),[Nr,tn]=s.useState(()=>Object.fromEntries(e.map(m=>[m.key,kt(m,Gt(m.width))]))),[et,kr]=s.useState(null),[Yh,Ta]=s.useState(1),[$a,Aa]=s.useState($===!1?0:$);s.useEffect(()=>{var Oe;const m=Xe.current,A=We.current,V=m.map(Ce=>Ce.key),O=new Set(V),le=()=>{var Ce;me.current||(me.current=!0,(Ce=ye.current)==null||Ce.call(ye))};if(!R||!He){ne.layout&&en(er(V,m)),_e||rt(tr(A,m)),yt.current=!1,vt(!0),le();return}let be=!1;const we=Be.current===R;we||(yt.current=!1,vt(!1),me.current=!1);const $e=Wn(R);if(As($e)&&!we){const Ce=$e,Ne=bn(Sa.current??ln()),Se=Ca.current,Er=Se===!1?0:Se,fr=ne.layout?Ce==null?void 0:Ce.columnOrder:void 0,Mr=Array.isArray(fr)?fr.filter(Ze=>V.includes(Ze)):[],Tr=er(Mr.length>0?jn(Mr,V):V,m),$r=Object.fromEntries(m.map(Ze=>[Ze.key,kt(Ze,Gt(Ze.width))])),an=ne.layout?(Ce==null?void 0:Ce.columnWidths)??{}:{},On=Object.fromEntries(m.map(Ze=>[Ze.key,kt(Ze,an[Ze.key]??$r[Ze.key])])),on=tr(ne.layout?(Ce==null?void 0:Ce.hiddenColumnKeys)??A:A,m);if(ne.layout&&(en(Tr),tn(On)),_e||rt(on),ne.filters&&Jr.current!==R&&(Jr.current=R,Kr(Ce,O),ir(dn(Ce==null?void 0:Ce.filters,O)),Ft(un(Ce==null?void 0:Ce.conditionFilters,O))),ne.sort){const Ze=cn(Ce==null?void 0:Ce.sort)?Ce.sort:null;kr(Ze&&O.has(Ze.key)?Ze:null)}if(ne.bql){if(Qr.current!==R){Qr.current=R;const Ze=typeof(Ce==null?void 0:Ce.bql)=="string"?Ce.bql:ce;he?(Oe=Ut.current)==null||Oe.call(Ut,Ze):ke(Ze)}Zr(Array.isArray(Ce==null?void 0:Ce.bqlHistory)?Ce.bqlHistory.filter(Ze=>typeof Ze=="string"):[])}ne.pagination&&wr.current!==R&&(wr.current=R,Aa(eo(Ce==null?void 0:Ce.pageSize,Ne,Er))),Be.current=R,vt(!0),le()}const De=`${Ra()??"/api/user/preferences/datatables"}?key=${encodeURIComponent(R)}`,Ue=new AbortController,xe=window.setTimeout(()=>Ue.abort(),2500);return fetch(De,{cache:"no-store",signal:Ue.signal}).then(Ce=>Ce.ok?Ce.json():null).then(Ce=>{var vc;if(be)return;const Ne=Wn(R),Se=Ds(As(Ce==null?void 0:Ce.settings)?Ce==null?void 0:Ce.settings:null,Ne),Er=bn(Sa.current??ln()),fr=Ca.current,Mr=fr===!1?0:fr,Tr=ne.layout?Se==null?void 0:Se.columnOrder:void 0,$r=Array.isArray(Tr)?Tr.filter(lt=>V.includes(lt)):[],an=er($r.length>0?jn($r,V):V,m),On=Object.fromEntries(m.map(lt=>[lt.key,kt(lt,Gt(lt.width))])),on=ne.layout?(Se==null?void 0:Se.columnWidths)??{}:{},Ze=Object.fromEntries(m.map(lt=>[lt.key,kt(lt,on[lt.key]??On[lt.key])])),sn=tr(ne.layout?(Se==null?void 0:Se.hiddenColumnKeys)??A:A,m);if(ne.layout&&(en(an),tn(Ze)),_e||rt(sn),ne.filters&&Jr.current!==R&&(Jr.current=R,Kr(Se,O),ir(dn(Se==null?void 0:Se.filters,O)),Ft(un(Se==null?void 0:Se.conditionFilters,O))),ne.sort){const lt=cn(Se==null?void 0:Se.sort)?Se.sort:null;kr(lt&&O.has(lt.key)?lt:null)}if(ne.bql){if(Qr.current!==R){Qr.current=R;const lt=typeof(Se==null?void 0:Se.bql)=="string"?Se.bql:ce;he?(vc=Ut.current)==null||vc.call(Ut,lt):ke(lt)}Zr(Array.isArray(Se==null?void 0:Se.bqlHistory)?Se.bqlHistory.filter(lt=>typeof lt=="string"):[])}let tt;ne.pagination&&(tt=eo(Se==null?void 0:Se.pageSize,Er,Mr),wr.current!==R&&(wr.current=R,Aa(tt))),ut.current=JSON.stringify({columnOrder:an,columnWidths:Ze,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}),yt.current=!0}).catch(()=>{var Ce;if(!be){const Ne=Wn(R),Se=bn(Sa.current??ln()),Er=Ca.current,fr=Er===!1?0:Er,Mr=ne.layout?Ne==null?void 0:Ne.columnOrder:void 0,Tr=Array.isArray(Mr)?Mr.filter(tt=>V.includes(tt)):[],$r=er(Tr.length>0?jn(Tr,V):V,m),an=Object.fromEntries(m.map(tt=>[tt.key,kt(tt,Gt(tt.width))])),On=ne.layout?(Ne==null?void 0:Ne.columnWidths)??{}:{},on=Object.fromEntries(m.map(tt=>[tt.key,kt(tt,On[tt.key]??an[tt.key])]));ne.layout&&(en($r),tn(on));const Ze=tr(ne.layout?(Ne==null?void 0:Ne.hiddenColumnKeys)??A:A,m);if(_e||rt(Ze),ne.filters&&Jr.current!==R&&(Jr.current=R,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;kr(tt&&O.has(tt.key)?tt:null)}if(ne.bql){if(Qr.current!==R){Qr.current=R;const tt=typeof(Ne==null?void 0:Ne.bql)=="string"?Ne.bql:ce;he?(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),wr.current!==R&&(wr.current=R,Aa(sn))),ut.current=JSON.stringify({columnOrder:$r,columnWidths:on,hiddenColumnKeys:Ze,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&&Er!==!1?sn:void 0}),yt.current=!0}}).finally(()=>{window.clearTimeout(xe),be||(Be.current=R,vt(!0),le())}),()=>{be=!0,Ue.abort(),window.clearTimeout(xe)}},[R,He,ze,Ye,_e,ne.layout,ne.filters,ne.sort,ne.bql,ne.pagination,he,ce,Bh]),s.useEffect(()=>{if(!R||!Je||!He||!yt.current)return;const m={};ne.layout&&(m.columnOrder=Rr,m.columnWidths=Nr,m.hiddenColumnKeys=at),ne.filters&&(m.filters=ct,m.conditionFilters=xt,m.filterOptionValues=yr.current,m.filterOptionLabels=cr.current),ne.sort&&(m.sort=et),ne.bql&&(m.bql=Fe,m.bqlHistory=dr),ne.pagination&&$!==!1&&(m.pageSize=$a);const A=Wn(R),V=Ds(A,m),O=JSON.stringify(V);if(O===ut.current)return;ld(R,V),ut.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:R,settings:V})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(le)},[Rr,Nr,at,ct,xt,et,Fe,dr,$a,$,R,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)})},[ze,e]);const Zi=er(Rr,e).map(m=>e.find(A=>A.key===m)).filter(m=>!!m),Dt=Zi.filter(m=>!at.includes(m.key)),Qi=e.some(to),Gh=Object.keys(ct).length,Kh=Object.keys(xt).length,ts=Gh+Kh;function rs(m){var $e;const A=!!(q&&ae),V=new Map,O=(ve,Ie)=>{const De=ve.trim();if(!De)return;const Ue=(Ie??De).trim()||De;V.has(De)?Ie!=null&&Ie.trim()&&V.get(De)===De&&V.set(De,Ue):V.set(De,Ue)};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 Ie of yr.current[m.key]??[])O(Ie,ve[Ie])}for(const ve of r){const Ie=qn(m,ve),De=(($e=m.filterOptionLabel)==null?void 0:$e.call(m,ve))??void 0;O(Ie,De??void 0)}for(const ve of ct[m.key]??[])O(ve);const le=ve=>/^[a-f\d]{24}$/i.test(ve.trim()),be=new Map;for(const[ve,Ie]of V){const De=Ie.trim().toLowerCase(),Ue=be.get(De)??[];Ue.push(ve),be.set(De,Ue)}for(const ve of be.values()){if(ve.length<2)continue;const Ie=ve.find(le)??ve.slice().sort((De,Ue)=>De.localeCompare(Ue))[0];for(const De of ve)De!==Ie&&V.delete(De)}const we=Array.from(V.keys()).sort((ve,Ie)=>{const De=V.get(ve)??ve,Ue=V.get(Ie)??Ie;return De.localeCompare(Ue,void 0,{numeric:!0,sensitivity:"base"})});return A&&(yr.current[m.key]=we,cr.current[m.key]=Object.fromEntries(V.entries())),we.map(ve=>({value:ve,label:V.get(ve)??ve}))}function Zh(){const m=e.find(A=>A.key===it);return m?rs(m):[]}function Qh(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 Jh(m,A,V,O){const le=ct[m]??[],be=O?le.includes(A)?le.filter($e=>$e!==A):[...le,A]:[A];V.length>0&&be.length===V.length&&V.every($e=>be.includes($e))?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 Rh(){ir({}),Ft({})}function em(m){he||ke(m),X==null||X(m)}function Ri(m){const A=m.trim();dt(A),(X==null?void 0:X(A))!==!1&&(he||ke(A),wt(!1),Nt(!1),Qt(!1),A&&Zr(O=>[A,...O.filter(le=>le!==A)].slice(0,td)))}function ec(){dt(""),em(""),wt(!1),Nt(!1),Qt(!1)}function as(m,A){dt(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(`
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,ht,Le,Va,Xa,ms,Ya,xm,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",y=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 k=()=>{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?y:"w-24 sm:w-28"}`,onMouseDown:g=>{f||(g.preventDefault(),k())},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: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(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),y=s.useRef(null),k=s.useRef(!1),[g,H]=s.useState(null),[S,$]=s.useState("");s.useEffect(()=>{const L=f.current;L&&(L.querySelectorAll("[title]").forEach(J=>{const q=J.getAttribute("title");q&&(J.getAttribute("aria-label")||J.setAttribute("aria-label",q),J.removeAttribute("title"))}),L.querySelectorAll("svg title").forEach(J=>J.remove()))}),s.useLayoutEffect(()=>{if(!g)return;const L=p.current;if(!L)return;const J=12,q=14,re=L.getBoundingClientRect(),R=window.innerWidth-re.width-J,fe=window.innerHeight-re.height-J;let ee=g.mouseX+q,j=g.mouseY+q,Z,M;if(!o&&f.current){const _=f.current.getBoundingClientRect(),ce=_.left+_.width/2,B=_.top+_.height/2;l==="top"?(ee=ce-re.width/2,j=_.top-re.height-q,M=re.height-1):l==="left"?(ee=_.left-re.width-q,j=B-re.height/2,Z=re.width-1):l==="right"?(ee=_.right+q,j=B-re.height/2,Z=-7):(ee=ce-re.width/2,j=_.bottom+q,M=-7)}if(o&&(ee>R&&(ee=g.mouseX-re.width-q),j>fe&&(j=g.mouseY-re.height-q)),ee=Math.min(Math.max(J,ee),Math.max(J,R)),j=Math.min(Math.max(J,j),Math.max(J,fe)),!o&&f.current){const _=f.current.getBoundingClientRect(),ce=_.left+_.width/2,B=_.top+_.height/2;l==="top"||l==="bottom"?Z=Math.min(Math.max(14,ce-ee),re.width-14):M=Math.min(Math.max(14,B-j),re.height-14)}(Math.abs(ee-g.x)>.5||Math.abs(j-g.y)>.5||Z!==g.arrowX||M!==g.arrowY)&&H(_=>_&&{..._,x:ee,y:j,arrowX:Z,arrowY:M})},[o,l,g]);const O=()=>{y.current&&(window.clearTimeout(y.current),y.current=null)},C=(L,J)=>{if(!wc()||k.current)return;const q=f.current;if(q&&!Bn(q)){if(n){const re=Nc(q);if(!re)return;$(re)}!n&&!r||H({mouseX:L,mouseY:J,x:L+14,y:J+14})}},v=()=>{const L=f.current;if(!L)return;const J=L.getBoundingClientRect();C(J.left+J.width/2,J.bottom)},T=()=>{O(),H(null)},x=()=>{if(!a){T();return}O(),y.current=window.setTimeout(()=>H(null),120)},P=()=>{Hn(),k.current=!0,T()},W=()=>{k.current=!1};s.useEffect(()=>{if(!g)return;if(Bn(f.current)){H(null);return}const L=()=>H(null),J=()=>{Hn(),k.current=!0,H(null)};document.addEventListener("pointerdown",J,!0),document.addEventListener("click",J,!0),document.addEventListener("scroll",L,!0),window.addEventListener("blur",L),document.addEventListener("visibilitychange",L),document.addEventListener("keydown",L,!0);const q=new MutationObserver(()=>{Bn(f.current)&&H(null)});return q.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",J,!0),document.removeEventListener("click",J,!0),document.removeEventListener("scroll",L,!0),window.removeEventListener("blur",L),document.removeEventListener("visibilitychange",L),document.removeEventListener("keydown",L,!0),q.disconnect()}},[g]),s.useEffect(()=>{const L=()=>Hn(),J=()=>{Hn(),k.current=!0,H(null)};return document.addEventListener("pointerdown",L,!0),document.addEventListener("click",L,!0),document.addEventListener("keydown",L,!0),window.addEventListener(ys,J),()=>{document.removeEventListener("pointerdown",L,!0),document.removeEventListener("click",L,!0),document.removeEventListener("keydown",L,!0),window.removeEventListener(ys,J)}},[]);const U=n?S:r;return t.jsxs(t.Fragment,{children:[t.jsx(b,{ref:L=>{f.current=L},className:c,style:u,onMouseEnter:L=>{O(),W(),o?C(L.clientX,L.clientY):v()},onMouseMove:L=>{g&&o&&C(L.clientX,L.clientY)},onMouseDown:P,onClick:P,onMouseLeave:()=>{W(),x()},onFocus:v,onBlur:T,children:e}),g&&U&&!Bn(f.current)?ht.createPortal(t.jsxs("div",{ref:p,role:"tooltip",className:d,onMouseEnter:a?O:void 0,onMouseLeave:a?x: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}}),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 Ve({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),y=l??p.iconOnly??e==="icon",k=p.compact??!1,g=p.headerAction??!1,H=g&&r==="md"?"sm":k&&!g&&r==="md"?"xs":r,S=e==="icon"||y,$=g&&S,O=Ga(d),C=o??f.title??f["aria-label"]??(y?O:void 0),v=C?void 0:f.title,T=f["aria-label"]??(typeof C=="string"?C:O||void 0),x=n?null:a??(y?$c(d):null),P=t.jsxs("button",{...f,title:v,"aria-label":T,"data-variant":e,"data-size":H,"data-icon":S?"true":void 0,disabled:h||n,className:`${kc} ${$?Sc:Cc[e]} ${S?Mc[H]:Ec[H]} ${k&&!S?"px-2.5":""} ${u}`,style:{...Tc[e],height:xs(i),padding:xs(c),...b,...g&&!S?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...$?{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"}):x,!y&&d]});return C?t.jsx(Pt,{as:"span",content:C,className:"inline-flex shrink-0",children:P}):P}const pt={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: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 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: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 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(Ve,{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:y,emptyState:k,loadingState:g,errorState:H=Ic,renderTabLabel:S,searchableTabs:$="auto",tabsSearchThreshold:O=6,tabsSearchPlaceholder:C="Buscar modulo...",tabsSearchValue:v,onTabsSearchChange:T,emptySearchState:x,showTabCount:P=!0,className:W="",parentClassName:U="",contentClassName:L="",tabsClassName:J=""}){var Te;const q=s.useMemo(()=>l.filter(ae=>!ae.hidden&&((b==null?void 0:b(ae,o))??!0)),[b,o,l]),re=(Te=q.find(ae=>!ae.disabled))==null?void 0:Te.service,[R,fe]=s.useState(u??re??""),[ee,j]=s.useState({}),[Z,M]=s.useState({}),[_,ce]=s.useState(""),[B,ne]=s.useState(!1),K=s.useRef(Z),Y=s.useRef(0),se=v??_,E=ks(se),Q=$===!0||$==="auto"&&q.length>=O,ie=Q&&se.trim().length>0,X=s.useMemo(()=>E?q.filter(ae=>ks(Hc(ae)).includes(E)):q,[E,q]),w=d??R,N=q.find(ae=>ae.service===w)??q.find(ae=>!ae.disabled);s.useEffect(()=>{!N&&re&&fe(re)},[re,N]),s.useEffect(()=>{K.current=Z},[Z]);const te=ae=>{ae.disabled||(d||fe(ae.service),h==null||h(ae.service,ae))},ue=ae=>{v===void 0&&ce(ae),T==null||T(ae)},oe=(ae,He)=>{const ze=X.filter(Xe=>!Xe.disabled),Ye=ze.findIndex(Xe=>Xe.service===He.service);Ye<0||((ae.key==="ArrowRight"||ae.key==="ArrowDown")&&(ae.preventDefault(),te(ze[(Ye+1)%ze.length])),(ae.key==="ArrowLeft"||ae.key==="ArrowUp")&&(ae.preventDefault(),te(ze[(Ye-1+ze.length)%ze.length])),ae.key==="Home"&&(ae.preventDefault(),te(ze[0])),ae.key==="End"&&(ae.preventDefault(),te(ze[ze.length-1])))},ge=s.useCallback(()=>{if(!N)return;const ae=N.service,He=K.current[ae];if(He!=null&&He.loading||He!=null&&He.component&&f)return;const ze=(i==null?void 0:i[ae])??c;if(!ze){M(Xe=>({...Xe,[ae]:{loading:!1,error:new Error(`No module loader found for service "${ae}".`)}}));return}const Ye=++Y.current;M(Xe=>({...Xe,[ae]:{...Xe[ae],loading:!0,error:void 0}})),ze(N,o).then(Xe=>{if(Ye!==Y.current&&!f)return;const We=Bc(Xe);M(Je=>({...Je,[ae]:{component:We,loading:!1}}))}).catch(Xe=>{const We=Xe instanceof Error?Xe:new Error(String(Xe));M(Je=>({...Je,[ae]:{...Je[ae],loading:!1,error:We}}))})},[o,f,c,i,N]);s.useEffect(ge,[ge]);const Me=N?ee[N.service]??null:null,Ae=N?Z[N.service]:void 0,$t=Ae==null?void 0:Ae.component,mt=ae=>{N&&j(He=>({...He,[N.service]:ae}))},gt=()=>{N&&j(ae=>({...ae,[N.service]:null}))},Qe={context:o,parent:a,links:l,visibleLinks:q,filteredLinks:X,selectedLink:N,selectedService:N==null?void 0:N.service,activeItemId:Me,tabsSearch:se,onSelectService:te,onOpenDetail:mt,onBackToList:gt},de=n?n(Qe):r?t.jsx(r,{...Qe}):e;return t.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${W}`,children:[t.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${U}`,children:de}),t.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${L}`,children:[(p||y||Q||P)&&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}),y&&t.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:y})]}),(Q||P)&&t.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[P&&t.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[X.length," / ",q.length]}),Q&&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:ue,placeholder:C,className:"w-full",autoFocus:B,forceExpanded:!0,onEscape:()=>ne(!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&&ue(""),ne(ae=>!ae)},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||ie?"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||ie?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 ${J}`,children:X.length>0?X.map(ae=>{const He=ae.service===(N==null?void 0:N.service);return t.jsx("button",{type:"button",role:"tab","aria-selected":He,disabled:ae.disabled,onClick:()=>te(ae),onKeyDown:ze=>oe(ze,ae),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:S?S(ae,He):t.jsxs(t.Fragment,{children:[ae.icon,t.jsx("span",{children:ae.label??Ns(ae.service)}),ae.badge&&t.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:ae.badge})]})},ae.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:x??"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&&(k??t.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-dashed border-[var(--border)] text-sm text-[var(--text-muted)]",children:"No hay modulos disponibles."})),N&&(Ae==null?void 0:Ae.loading)&&(g??t.jsx(ws,{title:"Cargando modulo..."})),N&&(Ae==null?void 0:Ae.error)&&H(Ae.error,ge),N&&$t&&!(Ae!=null&&Ae.loading)&&!(Ae!=null&&Ae.error)&&t.jsx($t,{context:o,parent:a,link:N,activeItemId:Me,onOpenDetail:mt,onBackToList:gt})]})]})]})}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(Ve,{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,maxDate:a,disableWeekends:o=!1,displayMode:l="inline",className:i=""}){const c=jc(),u=Za(e||c),h=l==="popover",[b,f]=s.useState(!1),p=s.useRef(null),[y,k]=s.useState({horizontal:"left",vertical:"bottom"}),[g,H]=s.useState(u.year),[S,$]=s.useState(u.month),[O,C]=s.useState("days"),v=16,[T,x]=s.useState(0),P=g-7+T,W=Array.from({length:v},(j,Z)=>P+Z);s.useEffect(()=>{if(!h||!b||!p.current)return;const j=p.current.getBoundingClientRect(),Z=8,M=280,_=340,ce=j.left+M>window.innerWidth-Z,B=j.right-M>=Z,ne=j.bottom+8+_>window.innerHeight-Z,K=j.top-8-_>=Z;k({horizontal:ce&&B?"right":"left",vertical:ne&&K?"top":"bottom"})},[h,b]),s.useEffect(()=>{if(!h||!b)return;function j(M){p.current&&(p.current.contains(M.target)||f(!1))}function Z(M){M.key==="Escape"&&f(!1)}return document.addEventListener("mousedown",j),document.addEventListener("keydown",Z),()=>{document.removeEventListener("mousedown",j),document.removeEventListener("keydown",Z)}},[h,b]);function U(){S===1?(H(j=>j-1),$(12)):$(j=>j-1)}function L(){S===12?(H(j=>j+1),$(1)):$(j=>j+1)}const J=(new Date(g,S-1,1).getDay()+6)%7,q=new Date(g,S,0).getDate(),re=[...Array(J).fill(null),...Array.from({length:q},(j,Z)=>Z+1)];for(;re.length<Ss*7;)re.push(null);const R=re.slice(0,Ss*7);function fe(j){const Z=Ka(g,S,j);n&&Z<n||a&&Z>a||o&&Es(Z)||(r(Z),h&&f(!1))}const ee=t.jsx("div",{className:`bonsaif-calendar bonsaif-calendar-picker ${i}`.trim(),children:t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsx("div",{className:"bonsaif-cal-toolbar",children:O==="days"?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:U,"aria-label":"Mes anterior",children:t.jsx(z.HiChevronLeft,{size:16})}),t.jsxs("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>{C("years"),x(0)},children:[t.jsxs("span",{className:"bonsaif-cal-title",children:[Cs[S-1]," ",g]}),t.jsx(z.HiChevronDown,{size:13})]}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:L,"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:()=>x(j=>j-v),"aria-label":"Años anteriores",children:t.jsx(z.HiChevronLeft,{size:16})}),t.jsx("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>C("days"),children:t.jsxs("span",{className:"bonsaif-cal-title",children:[W[0]," – ",W[W.length-1]]})}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>x(j=>j+v),"aria-label":"Años siguientes",children:t.jsx(z.HiChevronRight,{size:16})})]})}),O==="years"?t.jsxs("div",{className:"bonsaif-cal-picker-years",children:[t.jsx("div",{className:"bonsaif-cal-picker-months",children:zc.map((j,Z)=>{const M=Z+1===S;return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${M?" is-active":""}`,onClick:()=>$(Z+1),children:j},j)})}),t.jsx("div",{className:"bonsaif-cal-picker-year-grid",children:W.map(j=>{const Z=j===g,M=j===new Date().getFullYear();return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${Z?" is-active":""}${M&&!Z?" is-today":""}`,onClick:()=>{H(j),C("days")},children:j},j)})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bonsaif-multi-weekdays bonsaif-cal-picker-weekdays",children:Wc.map(j=>t.jsx("div",{className:"bonsaif-multi-weekday",children:j},j))}),t.jsx("div",{className:"bonsaif-cal-picker-days",children:R.map((j,Z)=>{if(j===null)return t.jsx("div",{className:"bonsaif-multi-day bonsaif-multi-day-hidden"},Z);const M=Ka(g,S,j),_=M===e,ce=M===c,B=!!(n&&M<n)||!!(a&&M>a)||o&&Es(M);return t.jsx("div",{className:`bonsaif-multi-day${_?" bonsaif-multi-day-selected":""}${ce?" bonsaif-multi-day-today":""}${B?" bonsaif-multi-day-disabled":""}`,children:t.jsx("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:B,"aria-pressed":_,onClick:()=>!B&&fe(j),children:j})},Z)})})]})]})});return h?t.jsxs("div",{ref:p,className:`relative w-full ${i}`.trim(),children:[t.jsxs("button",{type:"button",onClick:()=>f(j=>!j),className:"bonsaif-cal-trigger","data-open":b?"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 ${b?"rotate-180":""}`})]}),b&&t.jsx("div",{className:"absolute z-50",style:{...y.horizontal==="left"?{left:0}:{right:0},...y.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:ee})]}):ee}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:y=40,padding:k="0 10px",searchable:g=!0,minOptionsForSearch:H=6}){const[S,$]=s.useState(!1),[O,C]=s.useState(""),[v,T]=s.useState(-1),[x,P]=s.useState(!1),[W,U]=s.useState({}),L=s.useRef(null),J=s.useRef(null),q=s.useRef(null),re=s.useRef(null),R=g&&n.length>=H,fe=n.find(E=>E.value===e)??null,ee=l==="ghost",j=a==="error"?"var(--danger)":S?"var(--primary)":"var(--border)",Z=R&&O.trim()?n.filter(E=>Vc(E,O)):n,M=s.useCallback(()=>{const E=L.current;if(!(E!=null&&E.isConnected))return;const Q=E.getBoundingClientRect();if(Q.width<1&&Q.height<1||Q.bottom<0||Q.top>window.innerHeight)return;const ie=R?272:212,X=window.innerHeight-Q.bottom,w=X<ie&&Q.top>X,N=8,te=Math.max(Q.width,0),ue=Math.max(N,window.innerWidth-te-N),oe=Math.min(Math.max(N,Q.left),ue);U({position:"fixed",left:oe,top:w?void 0:Q.bottom+4,bottom:w?window.innerHeight-Q.top+4:void 0,width:Q.width,minWidth:Qa(f),zIndex:p})},[f,p,R]);s.useEffect(()=>P(!0),[]),s.useEffect(()=>{if(!S)return;function E(Q){var X,w;const ie=Q.target;!((X=L.current)!=null&&X.contains(ie))&&!((w=J.current)!=null&&w.contains(ie))&&($(!1),C(""))}return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[S]),s.useEffect(()=>{S&&(T(-1),M(),R&&setTimeout(()=>{var E;return(E=q.current)==null?void 0:E.focus()},0))},[S,R,M]),s.useEffect(()=>{if(S)return window.addEventListener("resize",M),window.addEventListener("scroll",M,!0),()=>{window.removeEventListener("resize",M),window.removeEventListener("scroll",M,!0)}},[S,M]),s.useEffect(()=>{if(v<0||!re.current)return;const E=re.current.children[v];E==null||E.scrollIntoView({block:"nearest"})},[v]);const _=s.useCallback(E=>{r(E),$(!1),C("")},[r]),ce=s.useRef(S);ce.current=S;const B=s.useRef(Z);B.current=Z;const ne=s.useRef(v);ne.current=v;const K=s.useRef(d);K.current=d;const Y=s.useRef(_);Y.current=_,s.useEffect(()=>{function E(Q){var N,te;const ie=document.activeElement,X=((N=L.current)==null?void 0:N.contains(ie))??!1,w=((te=J.current)==null?void 0:te.contains(ie))??!1;if(!(!X&&!w)){if(!ce.current){(Q.key==="Enter"||Q.key===" "||Q.key==="ArrowDown")&&(Q.preventDefault(),$(!0));return}switch(Q.key){case"ArrowDown":Q.preventDefault(),T(ue=>Math.min(ue+1,B.current.length-1));break;case"ArrowUp":Q.preventDefault(),T(ue=>Math.max(ue-1,K.current?-1:0));break;case"Enter":{Q.preventDefault();const ue=ne.current,oe=B.current;ue===-1&&K.current?Y.current(""):oe[ue]&&!oe[ue].disabled&&Y.current(oe[ue].value);break}case"Escape":Q.preventDefault(),Q.stopPropagation(),$(!1),C("");break}}}return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[]);const se=t.jsxs("div",{ref:J,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...W,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[R&&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:q,value:O,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)"}}),O&&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:re,role:"listbox",className:"overflow-y-auto",style:{maxHeight:R?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[d&&t.jsx("li",{role:"option","aria-selected":e==="",onMouseDown:E=>{E.preventDefault(),_("")},onMouseEnter:()=>T(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:v===-1&&!O.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:d}),Z.map((E,Q)=>{const X=Q===v,w=E.value===e;return t.jsxs("li",{role:"option","aria-selected":w,onMouseDown:N=>{N.preventDefault(),E.disabled||_(E.value)},onMouseEnter:()=>!E.disabled&&T(Q),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:X?"var(--bg-hover)":w?"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:w?"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)}),Z.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:L,className:`relative ${h||"w-full"}`,style:b,children:[t.jsxs("button",{type:"button",disabled:u,onClick:()=>!u&&$(E=>!E),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:Qa(y),padding:Qa(k),background:ee?"transparent":"var(--bg-input)",color:fe?"var(--text-main)":"var(--text-muted)",border:ee?"1px solid transparent":`1px solid ${j}`,opacity:u?.5:1,cursor:u?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":S,"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(),_("")},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:S?"rotate(180deg)":"rotate(0deg)"}})]}),S&&x&&ht.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 kt(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 Ar(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Ar).join(" ").trim():s.isValidElement(e)?Ar(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):Ar(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 Lr(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 Lr(e,a)>0;case"greaterThanOrEqual":return Lr(e,a)>=0;case"lessThan":return Lr(e,a)<0;case"lessThanOrEqual":return Lr(e,a)<=0;case"between":return Lr(e,a)>=0&&Lr(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:y=!1,selected:k,onToggleOne:g,onToggleAll:H,getRowSelectable:S,highlightSelected:$=!0,rowClassName:O,getRowCategory:C,stickyHeader:v=!0,pageSize:T=25,pageSizeOptions:x,pageSizeSelectWidth:P=62,pageSizeSelectHeight:W=30,pageSizeSelectPadding:U="0 7px",totalRows:L,page:J,onPageChange:q,onPageSizeChange:re,storageKey:R,stickyFirstColumn:fe=!1,bottomOffset:ee=0,compact:j=!0,restrictHeight:Z=!0,maxHeight:M,minTableWidth:_,enableColumnVisibility:ce=!0,enableColumnFilters:B=!0,hiddenColumnKeys:ne,defaultHiddenColumnKeys:K=od,onHiddenColumnKeysChange:Y,columnVisibilityLabel:se="Columnas",enableBql:E=!1,bqlValue:Q,defaultBqlValue:ie="",onBqlChange:X,bqlDescription:w="Filtra registros con Bonsaif Query Language",bqlPlaceholder:N=`status = activo
2
+ rol IN (admin, employee)`,bqlQuickFilters:te=[],bqlExamples:ue=[],bqlSuggestions:oe=[],bqlActiveFilters:ge,bqlError:Me,onQueryChange:Ae,persistState:$t,onPreferencesReady:mt,enableExport:gt=!1,exportFilename:Qe="datos",onExportCsv:de,onExportPdf:Te}){var gc;const ae=id($t,R),He=Object.values(ae).some(Boolean),ze=e.map(m=>m.key).join(","),Ye=K.join(","),Xe=s.useRef(e),We=s.useRef(K);Xe.current=e,We.current=K;const[Je,vt]=s.useState(!R||!He),ft=s.useRef(null),yt=s.useRef(!R),me=s.useRef(!1),ye=s.useRef(mt);ye.current=mt;const Be=s.useRef(!R||!He?R??"__none__":null),_e=ne!==void 0,[Ge,rt]=s.useState(()=>tr(K,e)),at=tr(_e?ne:Ge,e),[Re,st]=s.useState(!1),[nt,gr]=s.useState("filter"),[it,vr]=s.useState(null),[At,qe]=s.useState(""),[ct,ir]=s.useState({}),[xt,Ft]=s.useState({}),yr=s.useRef({}),cr=s.useRef({});function Kr(m,A){if(!m)return;const V=cd(m.filterOptionValues,A),D=dd(m.filterOptionLabels,A);Object.keys(V).length>0&&(yr.current={...yr.current,...V}),Object.keys(D).length>0&&(cr.current={...cr.current,...D})}const F=b!==void 0,[G,pe]=s.useState(f),he=Q!==void 0,[Ee,ke]=s.useState(ie),Fe=he?Q:Ee,[Pe,dt]=s.useState(Fe),[Ke,wt]=s.useState(!1),[Zt,Nt]=s.useState(!1),[xr,Qt]=s.useState(!1),[dr,Zr]=s.useState([]),Qr=s.useRef(null),Jr=s.useRef(null),wr=s.useRef(null),Ut=s.useRef(X);Ut.current=X;const Ca=s.useRef(T);Ca.current=T;const Sa=s.useRef(x);Sa.current=x;const Bh=Array.isArray(x)?x.join(","):"",Qo=s.useRef(null),qi=s.useRef(null),Jo=s.useRef(null),Ui=s.useRef(0),[Ih,Fh]=s.useState({}),[_h,Ph]=s.useState({}),[Mn,Ea]=s.useState(!1),Ro=s.useRef(null),Ma=s.useRef(null),[zh,Wh]=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),[jh,qh]=s.useState(void 0),[Gi,Uh]=s.useState(0),[Vh,Xh]=s.useState(!1);s.useEffect(()=>{function m(){Xh(window.innerWidth<640)}if(!Z||M!==void 0)return m(),window.addEventListener("resize",m),()=>window.removeEventListener("resize",m);const V=T!==!1?48:0,D=12;function le(){if(m(),!Lt.current)return;const we=Lt.current.getBoundingClientRect().top;qh(Math.max(120,window.innerHeight-we-V-D-ee))}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,ee,Z,M,Je,r.length]);const Ki=Z?M??jh:void 0;s.useEffect(()=>{const m=Lt.current;if(!m)return;const A=()=>Uh(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)),[Nr,tn]=s.useState(()=>Object.fromEntries(e.map(m=>[m.key,kt(m,Gt(m.width))]))),[et,kr]=s.useState(null),[Yh,Ta]=s.useState(1),[$a,Aa]=s.useState(T===!1?0:T);s.useEffect(()=>{var Oe;const m=Xe.current,A=We.current,V=m.map(Ce=>Ce.key),D=new Set(V),le=()=>{var Ce;me.current||(me.current=!0,(Ce=ye.current)==null||Ce.call(ye))};if(!R||!He){ae.layout&&en(er(V,m)),_e||rt(tr(A,m)),yt.current=!1,vt(!0),le();return}let be=!1;const we=Be.current===R;we||(yt.current=!1,vt(!1),me.current=!1);const $e=Wn(R);if(As($e)&&!we){const Ce=$e,Ne=bn(Sa.current??ln()),Se=Ca.current,Er=Se===!1?0:Se,fr=ae.layout?Ce==null?void 0:Ce.columnOrder:void 0,Mr=Array.isArray(fr)?fr.filter(Ze=>V.includes(Ze)):[],Tr=er(Mr.length>0?jn(Mr,V):V,m),$r=Object.fromEntries(m.map(Ze=>[Ze.key,kt(Ze,Gt(Ze.width))])),an=ae.layout?(Ce==null?void 0:Ce.columnWidths)??{}:{},On=Object.fromEntries(m.map(Ze=>[Ze.key,kt(Ze,an[Ze.key]??$r[Ze.key])])),on=tr(ae.layout?(Ce==null?void 0:Ce.hiddenColumnKeys)??A:A,m);if(ae.layout&&(en(Tr),tn(On)),_e||rt(on),ae.filters&&Jr.current!==R&&(Jr.current=R,Kr(Ce,D),ir(dn(Ce==null?void 0:Ce.filters,D)),Ft(un(Ce==null?void 0:Ce.conditionFilters,D))),ae.sort){const Ze=cn(Ce==null?void 0:Ce.sort)?Ce.sort:null;kr(Ze&&D.has(Ze.key)?Ze:null)}if(ae.bql){if(Qr.current!==R){Qr.current=R;const Ze=typeof(Ce==null?void 0:Ce.bql)=="string"?Ce.bql:ie;he?(Oe=Ut.current)==null||Oe.call(Ut,Ze):ke(Ze)}Zr(Array.isArray(Ce==null?void 0:Ce.bqlHistory)?Ce.bqlHistory.filter(Ze=>typeof Ze=="string"):[])}ae.pagination&&wr.current!==R&&(wr.current=R,Aa(eo(Ce==null?void 0:Ce.pageSize,Ne,Er))),Be.current=R,vt(!0),le()}const De=`${Ra()??"/api/user/preferences/datatables"}?key=${encodeURIComponent(R)}`,Ue=new AbortController,xe=window.setTimeout(()=>Ue.abort(),2500);return fetch(De,{cache:"no-store",signal:Ue.signal}).then(Ce=>Ce.ok?Ce.json():null).then(Ce=>{var vc;if(be)return;const Ne=Wn(R),Se=Ds(As(Ce==null?void 0:Ce.settings)?Ce==null?void 0:Ce.settings:null,Ne),Er=bn(Sa.current??ln()),fr=Ca.current,Mr=fr===!1?0:fr,Tr=ae.layout?Se==null?void 0:Se.columnOrder:void 0,$r=Array.isArray(Tr)?Tr.filter(lt=>V.includes(lt)):[],an=er($r.length>0?jn($r,V):V,m),On=Object.fromEntries(m.map(lt=>[lt.key,kt(lt,Gt(lt.width))])),on=ae.layout?(Se==null?void 0:Se.columnWidths)??{}:{},Ze=Object.fromEntries(m.map(lt=>[lt.key,kt(lt,on[lt.key]??On[lt.key])])),sn=tr(ae.layout?(Se==null?void 0:Se.hiddenColumnKeys)??A:A,m);if(ae.layout&&(en(an),tn(Ze)),_e||rt(sn),ae.filters&&Jr.current!==R&&(Jr.current=R,Kr(Se,D),ir(dn(Se==null?void 0:Se.filters,D)),Ft(un(Se==null?void 0:Se.conditionFilters,D))),ae.sort){const lt=cn(Se==null?void 0:Se.sort)?Se.sort:null;kr(lt&&D.has(lt.key)?lt:null)}if(ae.bql){if(Qr.current!==R){Qr.current=R;const lt=typeof(Se==null?void 0:Se.bql)=="string"?Se.bql:ie;he?(vc=Ut.current)==null||vc.call(Ut,lt):ke(lt)}Zr(Array.isArray(Se==null?void 0:Se.bqlHistory)?Se.bqlHistory.filter(lt=>typeof lt=="string"):[])}let tt;ae.pagination&&(tt=eo(Se==null?void 0:Se.pageSize,Er,Mr),wr.current!==R&&(wr.current=R,Aa(tt))),ft.current=JSON.stringify({columnOrder:an,columnWidths:Ze,hiddenColumnKeys:sn,filters:dn(Se==null?void 0:Se.filters,D),conditionFilters:un(Se==null?void 0:Se.conditionFilters,D),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:ae.pagination&&fr!==!1?tt:void 0}),yt.current=!0}).catch(()=>{var Ce;if(!be){const Ne=Wn(R),Se=bn(Sa.current??ln()),Er=Ca.current,fr=Er===!1?0:Er,Mr=ae.layout?Ne==null?void 0:Ne.columnOrder:void 0,Tr=Array.isArray(Mr)?Mr.filter(tt=>V.includes(tt)):[],$r=er(Tr.length>0?jn(Tr,V):V,m),an=Object.fromEntries(m.map(tt=>[tt.key,kt(tt,Gt(tt.width))])),On=ae.layout?(Ne==null?void 0:Ne.columnWidths)??{}:{},on=Object.fromEntries(m.map(tt=>[tt.key,kt(tt,On[tt.key]??an[tt.key])]));ae.layout&&(en($r),tn(on));const Ze=tr(ae.layout?(Ne==null?void 0:Ne.hiddenColumnKeys)??A:A,m);if(_e||rt(Ze),ae.filters&&Jr.current!==R&&(Jr.current=R,Kr(Ne,D),ir(dn(Ne==null?void 0:Ne.filters,D)),Ft(un(Ne==null?void 0:Ne.conditionFilters,D))),ae.sort){const tt=cn(Ne==null?void 0:Ne.sort)?Ne.sort:null;kr(tt&&D.has(tt.key)?tt:null)}if(ae.bql){if(Qr.current!==R){Qr.current=R;const tt=typeof(Ne==null?void 0:Ne.bql)=="string"?Ne.bql:ie;he?(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;ae.pagination&&(sn=eo(Ne==null?void 0:Ne.pageSize,Se,fr),wr.current!==R&&(wr.current=R,Aa(sn))),ft.current=JSON.stringify({columnOrder:$r,columnWidths:on,hiddenColumnKeys:Ze,filters:dn(Ne==null?void 0:Ne.filters,D),conditionFilters:un(Ne==null?void 0:Ne.conditionFilters,D),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:ae.pagination&&Er!==!1?sn:void 0}),yt.current=!0}}).finally(()=>{window.clearTimeout(xe),be||(Be.current=R,vt(!0),le())}),()=>{be=!0,Ue.abort(),window.clearTimeout(xe)}},[R,He,ze,Ye,_e,ae.layout,ae.filters,ae.sort,ae.bql,ae.pagination,he,ie,Bh]),s.useEffect(()=>{if(!R||!Je||!He||!yt.current)return;const m={};ae.layout&&(m.columnOrder=Rr,m.columnWidths=Nr,m.hiddenColumnKeys=at),ae.filters&&(m.filters=ct,m.conditionFilters=xt,m.filterOptionValues=yr.current,m.filterOptionLabels=cr.current),ae.sort&&(m.sort=et),ae.bql&&(m.bql=Fe,m.bqlHistory=dr),ae.pagination&&T!==!1&&(m.pageSize=$a);const A=Wn(R),V=Ds(A,m),D=JSON.stringify(V);if(D===ft.current)return;ld(R,V),ft.current=D;const le=window.setTimeout(()=>{const be=Ra()??"/api/user/preferences/datatables";fetch(be,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:R,settings:V})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(le)},[Rr,Nr,at,ct,xt,et,Fe,dr,$a,T,R,Je,He,ae.layout,ae.filters,ae.sort,ae.bql,ae.pagination,r]),s.useEffect(()=>{en(m=>{const A=e.map(V=>V.key);return er(jn(m,A),e)})},[ze,e]);const Zi=er(Rr,e).map(m=>e.find(A=>A.key===m)).filter(m=>!!m),Dt=Zi.filter(m=>!at.includes(m.key)),Qi=e.some(to),Gh=Object.keys(ct).length,Kh=Object.keys(xt).length,ts=Gh+Kh;function rs(m){var $e;const A=!!(q&&re),V=new Map,D=(ve,Ie)=>{const De=ve.trim();if(!De)return;const Ue=(Ie??De).trim()||De;V.has(De)?Ie!=null&&Ie.trim()&&V.get(De)===De&&V.set(De,Ue):V.set(De,Ue)};for(const ve of m.filterOptions??[])typeof ve=="string"?D(ve):ve!=null&&ve.value&&D(ve.value,ve.label);if(A){const ve=cr.current[m.key]??{};for(const Ie of yr.current[m.key]??[])D(Ie,ve[Ie])}for(const ve of r){const Ie=qn(m,ve),De=(($e=m.filterOptionLabel)==null?void 0:$e.call(m,ve))??void 0;D(Ie,De??void 0)}for(const ve of ct[m.key]??[])D(ve);const le=ve=>/^[a-f\d]{24}$/i.test(ve.trim()),be=new Map;for(const[ve,Ie]of V){const De=Ie.trim().toLowerCase(),Ue=be.get(De)??[];Ue.push(ve),be.set(De,Ue)}for(const ve of be.values()){if(ve.length<2)continue;const Ie=ve.find(le)??ve.slice().sort((De,Ue)=>De.localeCompare(Ue))[0];for(const De of ve)De!==Ie&&V.delete(De)}const we=Array.from(V.keys()).sort((ve,Ie)=>{const De=V.get(ve)??ve,Ue=V.get(Ie)??Ie;return De.localeCompare(Ue,void 0,{numeric:!0,sensitivity:"base"})});return A&&(yr.current[m.key]=we,cr.current[m.key]=Object.fromEntries(V.entries())),we.map(ve=>({value:ve,label:V.get(ve)??ve}))}function Zh(){const m=e.find(A=>A.key===it);return m?rs(m):[]}function Qh(m){return!!(B&&!hr(m)&&(m.filterValue||m.sortKey||rs(m).length>0))}function ns(m,A){ir(V=>{const D={...V};return D[m]=A,D})}function Jh(m,A,V,D){const le=ct[m]??[],be=D?le.includes(A)?le.filter($e=>$e!==A):[...le,A]:[A];V.length>0&&be.length===V.length&&V.every($e=>be.includes($e))?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 D={...V};return A?D[m]=A:delete D[m],D})}function Ji(m){Da(m,null)}function Rh(){ir({}),Ft({})}function em(m){he||ke(m),X==null||X(m)}function Ri(m){const A=m.trim();dt(A),(X==null?void 0:X(A))!==!1&&(he||ke(A),wt(!1),Nt(!1),Qt(!1),A&&Zr(D=>[A,...D.filter(le=>le!==A)].slice(0,td)))}function ec(){dt(""),em(""),wt(!1),Nt(!1),Qt(!1)}function as(m,A){dt(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,""),D=V.length===0?A:V.split(`
3
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(()=>{dt(Fe)},[Fe]);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),$e=A.bottom+O,ve=window.innerHeight-A.top+O,Ie=window.innerHeight-$e-V,De=A.top-V-O,Ue=Ie<280&&De>Ie,xe=Math.max(240,Ue?De:Ie);Fh({position:"fixed",zIndex:1e4,left:we,top:Ue?void 0:$e,bottom:Ue?ve:void 0,width:le,maxWidth:"calc(100vw - 24px)",maxHeight:xe,overflowY:"auto"})},[]);s.useEffect(()=>{if(!Ke)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)||(wt(!1),Nt(!1),Qt(!1))}function A(O){O.key==="Escape"&&(wt(!1),Nt(!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)}},[Ke,Ha]);function tc(m){const A=tr(m,e);_e||rt(A),Y==null||Y(A)}function tm(m){tc(at.includes(m)?at.filter(A=>A!==m):[...at,m])}function rm(){tc([])}const Ba=s.useCallback(m=>{var le;if(m!=null&&m.isConnected)return m;if(!it)return null;const V=`[role="columnheader"][data-dt-column-key="${typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(it):it.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},[it]),$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),$e=Math.min(Math.max(be,O.left),we),ve=window.innerHeight-O.bottom,Ie=O.bottom+6,De=window.innerHeight-O.top+6,xe=ve<360&&O.top>ve?void 0:Ie,Oe=xe===void 0?De:void 0,Ce=Math.max(220,xe===void 0?O.top-16:window.innerHeight-Ie-8),Ne={position:"fixed",zIndex:9999,left:$e,top:xe,bottom:Oe,width:le,maxWidth:"calc(100vw - 16px)",maxHeight:Ce,"--dt-column-menu-max-height":`${Ce}px`};Ph(Ne)},[Ba]);function rc(m,A,V=null){m.preventDefault(),m.stopPropagation();const O=Tn.current===m.currentTarget&&nt===A&&it===V;if(Re&&O){st(!1),vr(null);return}if(Tn.current=m.currentTarget,gr(A),vr(V),qe(""),A==="filter"&&V){const le=e.find(we=>we.key===V),be=ct[V];if(le&&(be!=null&&be.length)){const we=rs(le),$e=new Map(we.map(De=>[De.label.trim().toLowerCase(),De.value])),ve=[...new Set(be.map(De=>we.some(Ue=>Ue.value===De)?De:$e.get(De.trim().toLowerCase())??De))];(ve.length!==be.length||ve.some((De,Ue)=>De!==be[Ue]))&&(we.length>0&&ve.length===we.length&&we.every(De=>ve.includes(De.value))?La(V):ns(V,ve))}}$n(m.currentTarget),st(!0)}function nm(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]"),$e=we?we.scrollWidth:Math.max(be.scrollWidth,be.offsetWidth);return Math.max(le,Math.ceil($e+ud(be)))},0);O<=0||tn(le=>({...le,[m.key]:kt(m,O+12)}))}s.useEffect(()=>{tn(m=>{const A=Object.fromEntries(e.map(V=>[V.key,kt(V,Gt(V.width))]));return Object.fromEntries(e.map(V=>[V.key,kt(V,m[V.key]??A[V.key])]))})},[ze,e]),s.useEffect(()=>{_e||rt(m=>tr(m,e))},[ze,e,_e]),s.useEffect(()=>{function m(O){var $e;const le=O.target,be=O.target;if(be!=null&&be.closest("[data-bonsaif-select-dropdown='true']"))return;const we=Ba(Tn.current);!(($e=Vi.current)!=null&&$e.contains(le))&&!(we!=null&&we.contains(le))&&(st(!1),vr(null))}function A(O){O.key==="Escape"&&(st(!1),vr(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||!it||$n()},[Re,it,ct,xt,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]:kt(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 am(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 om(m,A){A.preventDefault(),A.dataTransfer.dropEffect="move";const V=Rr.indexOf(m);nc!==V&&os(V)}function sm(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 lm(){Ln.current=null,os(null)}function im(m){m.sortKey&&kr(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)},[xt,ct]);const Vt=!!(q&&ae),ur=$!==!1,ss=s.useMemo(()=>bn(y??ln()),[y]),bt=Vt?J??1:Yh,ac=ur&&$a<1?typeof $=="number"&&$>0?$:ss[0]??25:$a,Xt=Vt||ur?ac:r.length,_t=!!N&&!!v&&!!H,ls=s.useMemo(()=>S?r.filter(m=>S(m)):r,[r,S]),rn=!!u,oc=s.useMemo(()=>new Set(_?Array.from(b??[]):G),[_,b,G]),cm=(rn?40:0)+(_t?40:0),is=!Vh&&(Qi||fe),Ia=(()=>{if(!is)return{};let m=cm;const A={};return Dt.forEach((V,O)=>{(to(V)||!Qi&&fe&&O===0)&&(A[V.key]=m,m+=Nr[V.key]??kt(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=>N.has(n(m))),dm=_t&&N.size>0&&ls.some(m=>N.has(n(m)))&&!sc,Fa=s.useMemo(()=>{if(Vt)return r;const m=Object.entries(ct),A=Object.entries(xt);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($e=>$e.key===O);if(!be)return!0;const we=r.map($e=>qn(be,$e));return hd(qn(be,V),le,we)}))},[xt,ct,e,r,Vt]),Cr=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 Cr;const m=(bt-1)*Xt;return Cr.slice(m,m+Xt)},[Cr,Vt,ur,bt,Xt]),Jt=Vt?L??r.length:Cr.length,us=ur?Math.max(1,Math.ceil(Jt/Xt)):1,um=Math.min(...ss),fm=ur&&(Jt>Xt||Jt>um),bm=ur?(bt-1)*Xt+1:1,hm=ur?Math.min(bt*Xt,Jt):Jt;function fs(m){if(a)return;const A=Math.max(1,Math.min(m,us));Vt?q(A):Ta(A)}function mm(m){a||(R&&(wr.current=R),Aa(m),Vt?(ae(m),q(1)):(Ta(1),ae==null||ae(m)))}function ic(m){const A=new Set(oc);A.has(m)?A.delete(m):A.add(m);const V=Array.from(A);_||pe(V),p==null||p(V)}s.useEffect(()=>{Ae==null||Ae({bql:Fe,filters:ct,conditionFilters:xt,sort:et,page:bt,pageSize:Xt,hiddenColumnKeys:at})},[Fe,ct,xt,et,bt,Xt,at,Ae]);const cc=m=>m==="center"?"justify-center text-center":m==="right"?"justify-end text-right":"justify-start text-left",pm="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%)",je="color-mix(in srgb, var(--border) 62%, var(--bg-card))",Sr="color-mix(in srgb, var(--primary) 24%, var(--border))",_a=`inset 0 0 0 1px ${je}`,dc=Dt.reduce((m,A)=>m+(Nr[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=>`${Nr[m.key]??Gt(m.width)}px`).join(" ")}`;s.useEffect(()=>{et&&at.includes(et.key)&&kr(null)},[at,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 ${Sr}`},children:[rn&&t.jsx("div",{role:"columnheader",className:`${K?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${Sr}`,borderRight:`1px solid ${je}`}}),_t&&t.jsx("div",{role:"columnheader",className:`${K?"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 ${Sr}`,borderRight:`1px solid ${je}`}:{borderBottom:`1px solid ${Sr}`,borderRight:`1px solid ${je}`},children:t.jsx(Fn,{size:"sm",checked:sc,indeterminate:dm,onChange:H,"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,$e=m.key===ds,ve=Os(m),Ie=nc===A,Ue=(Nr[m.key]??Gt(m.width))<120,xe=Object.prototype.hasOwnProperty.call(ct,m.key)||Object.prototype.hasOwnProperty.call(xt,m.key);return t.jsxs("div",{role:"columnheader","data-dt-column-key":m.key,className:`group select-none ${Ue?"text-left":cc(m.align)}`,style:{...we?{position:"sticky",left:be,zIndex:12,background:bs,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:$e?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Sr}`:`inset 0 -1px 0 ${Sr}`,borderRight:`1px solid ${je}`}:{position:"relative",borderBottom:`1px solid ${Sr}`,borderRight:`1px solid ${je}`},color:V?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:Ie?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:le?K?"7px 6px":"9px 8px":K?"8px 6px 10px":"10px 8px 12px"},onDragOver:Oe=>{(ve||Ln.current!==null)&&om(m.key,Oe)},onDrop:Oe=>sm(m.key,Oe),children:[t.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${le?"justify-center":Ue?"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(),am(m.key,Oe)},onDragEnd:Oe=>{Oe.stopPropagation(),lm()},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 ${Ie?"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 ${K?"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(),im(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&&Qh(m)&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Re&&it===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&&nt==="filter"&&it===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:Nr[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="",nm(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"||nt==="visibility"&&!ie||nt==="filter"&&!B)return null;const m=e.find(xe=>xe.key===it),A=Zh(),V=m?Object.prototype.hasOwnProperty.call(ct,m.key):!1,O=m?xt[m.key]:void 0,le=zn.find(xe=>xe.value===(O==null?void 0:O.operator)),be=m?ct[m.key]??[]:[],we=At.trim().toLowerCase(),$e=we?A.filter(xe=>xe.label.toLowerCase().includes(we)):A,ve=m&&A.length>0&&(!V||be.length===A.length),Ie=m&&V&&be.length>0&&be.length<A.length,De=at.length,Ue=()=>{m&&(La(m.key),Ji(m.key))};return ht.createPortal(t.jsx("div",{ref:Vi,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{..._h,borderColor:"var(--border)",background:"var(--bg-card)"},children:nt==="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:rm,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=!at.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:()=>tm(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:Ue,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:()=>kr({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:()=>kr({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=>qe(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":Ie?"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||Ie?"var(--primary)":"var(--border)",background:ve||Ie?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[Ie&&t.jsx(z.HiMinus,{className:"h-3 w-3"}),ve&&!Ie&&t.jsx(z.HiCheck,{className:"h-3 w-3"})]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),$e.map(xe=>{const Oe=!V||be.includes(xe.value);return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Oe,onClick:()=>Jh(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)}),$e.length===0&&t.jsx("div",{className:"px-3 py-3 text-sm text-[var(--text-muted)]",children:"Sin valores"})]})]}):null}),document.body)};s.useEffect(()=>{if(!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(Ar(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>Cr.length&&Xa.toast.warning(`Exportando ${Cr.length.toLocaleString("es-MX")} de ${Jt.toLocaleString("es-MX")} (página actual). Usa exportación completa si está disponible.`),Cr}function gm(){const m=Dt.filter(ve=>!hr(ve)),A=mc(),V=m.map(ve=>hc(Ar(ve.header))).join(","),O=A.map(ve=>m.map(Ie=>hc(bc(Ie,ve))).join(",")).join(`
4
+ ${A}`;as(D,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(()=>{dt(Fe)},[Fe]);const Ha=s.useCallback(()=>{const m=Qo.current;if(!m)return;const A=m.getBoundingClientRect(),V=12,D=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),$e=A.bottom+D,ve=window.innerHeight-A.top+D,Ie=window.innerHeight-$e-V,De=A.top-V-D,Ue=Ie<280&&De>Ie,xe=Math.max(240,Ue?De:Ie);Fh({position:"fixed",zIndex:1e4,left:we,top:Ue?void 0:$e,bottom:Ue?ve:void 0,width:le,maxWidth:"calc(100vw - 24px)",maxHeight:xe,overflowY:"auto"})},[]);s.useEffect(()=>{if(!Ke)return;function m(D){var be,we;if(Date.now()<Ui.current)return;const le=D.target;(be=Qo.current)!=null&&be.contains(le)||(we=qi.current)!=null&&we.contains(le)||(wt(!1),Nt(!1),Qt(!1))}function A(D){D.key==="Escape"&&(wt(!1),Nt(!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)}},[Ke,Ha]);function tc(m){const A=tr(m,e);_e||rt(A),Y==null||Y(A)}function tm(m){tc(at.includes(m)?at.filter(A=>A!==m):[...at,m])}function rm(){tc([])}const Ba=s.useCallback(m=>{var le;if(m!=null&&m.isConnected)return m;if(!it)return null;const V=`[role="columnheader"][data-dt-column-key="${typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(it):it.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"] button[aria-haspopup="menu"]`,D=((le=Lt.current)==null?void 0:le.querySelector(V))??document.querySelector(V);return D&&(Tn.current=D),D},[it]),$n=s.useCallback((m=Tn.current)=>{const A=Ba(m);if(!A)return;const D=(A.closest("th")??A.closest("[role='columnheader']")??A.closest("[data-dt-column-key]")??A).getBoundingClientRect();if(D.width<1&&D.height<1||D.bottom<0||D.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),$e=Math.min(Math.max(be,D.left),we),ve=window.innerHeight-D.bottom,Ie=D.bottom+6,De=window.innerHeight-D.top+6,xe=ve<360&&D.top>ve?void 0:Ie,Oe=xe===void 0?De:void 0,Ce=Math.max(220,xe===void 0?D.top-16:window.innerHeight-Ie-8),Ne={position:"fixed",zIndex:9999,left:$e,top:xe,bottom:Oe,width:le,maxWidth:"calc(100vw - 16px)",maxHeight:Ce,"--dt-column-menu-max-height":`${Ce}px`};Ph(Ne)},[Ba]);function rc(m,A,V=null){m.preventDefault(),m.stopPropagation();const D=Tn.current===m.currentTarget&&nt===A&&it===V;if(Re&&D){st(!1),vr(null);return}if(Tn.current=m.currentTarget,gr(A),vr(V),qe(""),A==="filter"&&V){const le=e.find(we=>we.key===V),be=ct[V];if(le&&(be!=null&&be.length)){const we=rs(le),$e=new Map(we.map(De=>[De.label.trim().toLowerCase(),De.value])),ve=[...new Set(be.map(De=>we.some(Ue=>Ue.value===De)?De:$e.get(De.trim().toLowerCase())??De))];(ve.length!==be.length||ve.some((De,Ue)=>De!==be[Ue]))&&(we.length>0&&ve.length===we.length&&we.every(De=>ve.includes(De.value))?La(V):ns(V,ve))}}$n(m.currentTarget),st(!0)}function nm(m){if(hr(m))return;const A=Lt.current;if(!A)return;const D=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]"),$e=we?we.scrollWidth:Math.max(be.scrollWidth,be.offsetWidth);return Math.max(le,Math.ceil($e+ud(be)))},0);D<=0||tn(le=>({...le,[m.key]:kt(m,D+12)}))}s.useEffect(()=>{tn(m=>{const A=Object.fromEntries(e.map(V=>[V.key,kt(V,Gt(V.width))]));return Object.fromEntries(e.map(V=>[V.key,kt(V,m[V.key]??A[V.key])]))})},[ze,e]),s.useEffect(()=>{_e||rt(m=>tr(m,e))},[ze,e,_e]),s.useEffect(()=>{function m(D){var $e;const le=D.target,be=D.target;if(be!=null&&be.closest("[data-bonsaif-select-dropdown='true']"))return;const we=Ba(Tn.current);!(($e=Vi.current)!=null&&$e.contains(le))&&!(we!=null&&we.contains(le))&&(st(!1),vr(null))}function A(D){D.key==="Escape"&&(st(!1),vr(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||!it||$n()},[Re,it,ct,xt,r,$n]);const An=s.useRef(null);s.useEffect(()=>{function m(V){const D=An.current;if(!D)return;const le=V.clientX-D.startX,be=e.find(we=>we.key===D.colKey);be&&tn(we=>({...we,[D.colKey]:kt(be,D.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 am(m,A){const V=e.find(D=>D.key===m);if(!V||!Os(V)){A.preventDefault();return}Ln.current=Rr.indexOf(m),A.dataTransfer.effectAllowed="move"}function om(m,A){A.preventDefault(),A.dataTransfer.dropEffect="move";const V=Rr.indexOf(m);nc!==V&&os(V)}function sm(m,A){A.preventDefault();const V=Ln.current,D=Rr.indexOf(m);V!==null&&V!==D&&en(le=>{const be=[...le],[we]=be.splice(V,1);return be.splice(D,0,we),er(be,e)}),Ln.current=null,os(null)}function lm(){Ln.current=null,os(null)}function im(m){m.sortKey&&kr(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)},[xt,ct]);const Vt=!!(q&&re),ur=T!==!1,ss=s.useMemo(()=>bn(x??ln()),[x]),bt=Vt?J??1:Yh,ac=ur&&$a<1?typeof T=="number"&&T>0?T:ss[0]??25:$a,Xt=Vt||ur?ac:r.length,_t=!!k&&!!g&&!!H,ls=s.useMemo(()=>S?r.filter(m=>S(m)):r,[r,S]),rn=!!u,oc=s.useMemo(()=>new Set(F?Array.from(b??[]):G),[F,b,G]),cm=(rn?40:0)+(_t?40:0),is=!Vh&&(Qi||fe),Ia=(()=>{if(!is)return{};let m=cm;const A={};return Dt.forEach((V,D)=>{(to(V)||!Qi&&fe&&D===0)&&(A[V.key]=m,m+=Nr[V.key]??kt(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=>k.has(n(m))),dm=_t&&k.size>0&&ls.some(m=>k.has(n(m)))&&!sc,Fa=s.useMemo(()=>{if(Vt)return r;const m=Object.entries(ct),A=Object.entries(xt);return m.length===0&&A.length===0?r:r.filter(V=>m.every(([D,le])=>{const be=e.find(we=>we.key===D);return be?le.includes(qn(be,V)):!0})&&A.every(([D,le])=>{const be=e.find($e=>$e.key===D);if(!be)return!0;const we=r.map($e=>qn(be,$e));return hd(qn(be,V),le,we)}))},[xt,ct,e,r,Vt]),Cr=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 D=A[m.sortKey],le=V[m.sortKey],be=D===le?0:D==null?1:le==null||D<le?-1:1;return et.dir==="asc"?be:-be}):Fa},[Fa,et,e]),lc=s.useMemo(()=>{if(Vt||!ur)return Cr;const m=(bt-1)*Xt;return Cr.slice(m,m+Xt)},[Cr,Vt,ur,bt,Xt]),Jt=Vt?L??r.length:Cr.length,us=ur?Math.max(1,Math.ceil(Jt/Xt)):1,um=Math.min(...ss),fm=ur&&(Jt>Xt||Jt>um),bm=ur?(bt-1)*Xt+1:1,hm=ur?Math.min(bt*Xt,Jt):Jt;function fs(m){if(a)return;const A=Math.max(1,Math.min(m,us));Vt?q(A):Ta(A)}function mm(m){a||(R&&(wr.current=R),Aa(m),Vt?(re(m),q(1)):(Ta(1),re==null||re(m)))}function ic(m){const A=new Set(oc);A.has(m)?A.delete(m):A.add(m);const V=Array.from(A);F||pe(V),p==null||p(V)}s.useEffect(()=>{Ae==null||Ae({bql:Fe,filters:ct,conditionFilters:xt,sort:et,page:bt,pageSize:Xt,hiddenColumnKeys:at})},[Fe,ct,xt,et,bt,Xt,at,Ae]);const cc=m=>m==="center"?"justify-center text-center":m==="right"?"justify-end text-right":"justify-start text-left",pm="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%)",je="color-mix(in srgb, var(--border) 62%, var(--bg-card))",Sr="color-mix(in srgb, var(--primary) 24%, var(--border))",_a=`inset 0 0 0 1px ${je}`,dc=Dt.reduce((m,A)=>m+(Nr[A.key]??Gt(A.width)),(rn?40:0)+(_t?40:0)),uc=typeof _=="number"?_:typeof _=="string"?Number(((gc=_.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=_??Dn,nn=`${rn?"40px ":""}${_t?"40px ":""}${Dt.map(m=>`${Nr[m.key]??Gt(m.width)}px`).join(" ")}`;s.useEffect(()=>{et&&at.includes(et.key)&&kr(null)},[at,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 ${Sr}`},children:[rn&&t.jsx("div",{role:"columnheader",className:`${j?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${Sr}`,borderRight:`1px solid ${je}`}}),_t&&t.jsx("div",{role:"columnheader",className:`${j?"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 ${Sr}`,borderRight:`1px solid ${je}`}:{borderBottom:`1px solid ${Sr}`,borderRight:`1px solid ${je}`},children:t.jsx(Fn,{size:"sm",checked:sc,indeterminate:dm,onChange:H,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),Dt.map((m,A)=>{const V=(et==null?void 0:et.key)===m.key,D=!!m.sortKey,le=hr(m),be=Ia[m.key],we=be!==void 0,$e=m.key===ds,ve=Os(m),Ie=nc===A,Ue=(Nr[m.key]??Gt(m.width))<120,xe=Object.prototype.hasOwnProperty.call(ct,m.key)||Object.prototype.hasOwnProperty.call(xt,m.key);return t.jsxs("div",{role:"columnheader","data-dt-column-key":m.key,className:`group select-none ${Ue?"text-left":cc(m.align)}`,style:{...we?{position:"sticky",left:be,zIndex:12,background:bs,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:$e?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Sr}`:`inset 0 -1px 0 ${Sr}`,borderRight:`1px solid ${je}`}:{position:"relative",borderBottom:`1px solid ${Sr}`,borderRight:`1px solid ${je}`},color:V?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:Ie?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:le?j?"7px 6px":"9px 8px":j?"8px 6px 10px":"10px 8px 12px"},onDragOver:Oe=>{(ve||Ln.current!==null)&&om(m.key,Oe)},onDrop:Oe=>sm(m.key,Oe),children:[t.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${le?"justify-center":Ue?"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(),am(m.key,Oe)},onDragEnd:Oe=>{Oe.stopPropagation(),lm()},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 ${Ie?"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 ${j?"text-[11px]":"text-xs"}`,children:t.jsx("span",{className:"min-w-0 truncate",children:m.header})})}),D&&t.jsx("button",{type:"button","aria-label":`Ordenar por ${String(m.header)}`,title:"Ordenar",onClick:Oe=>{Oe.stopPropagation(),im(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&&Qh(m)&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Re&&it===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&&nt==="filter"&&it===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:Nr[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="",nm(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"||nt==="visibility"&&!ce||nt==="filter"&&!B)return null;const m=e.find(xe=>xe.key===it),A=Zh(),V=m?Object.prototype.hasOwnProperty.call(ct,m.key):!1,D=m?xt[m.key]:void 0,le=zn.find(xe=>xe.value===(D==null?void 0:D.operator)),be=m?ct[m.key]??[]:[],we=At.trim().toLowerCase(),$e=we?A.filter(xe=>xe.label.toLowerCase().includes(we)):A,ve=m&&A.length>0&&(!V||be.length===A.length),Ie=m&&V&&be.length>0&&be.length<A.length,De=at.length,Ue=()=>{m&&(La(m.key),Ji(m.key))};return ht.createPortal(t.jsx("div",{ref:Vi,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{..._h,borderColor:"var(--border)",background:"var(--bg-card)"},children:nt==="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:rm,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=!at.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:()=>tm(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:Ue,disabled:!V&&!D,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:()=>kr({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:()=>kr({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:(D==null?void 0:D.operator)??"",onChange:xe=>{if(!xe){Ji(m.key);return}Da(m.key,{operator:xe,value:(D==null?void 0:D.value)??"",valueTo:(D==null?void 0:D.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:(D==null?void 0:D.value)??"",onChange:xe=>{D&&Da(m.key,{...D,value:xe.target.value})},disabled:!D,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:(D==null?void 0:D.valueTo)??"",onChange:xe=>{D&&Da(m.key,{...D,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=>qe(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":Ie?"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||Ie?"var(--primary)":"var(--border)",background:ve||Ie?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[Ie&&t.jsx(z.HiMinus,{className:"h-3 w-3"}),ve&&!Ie&&t.jsx(z.HiCheck,{className:"h-3 w-3"})]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),$e.map(xe=>{const Oe=!V||be.includes(xe.value);return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Oe,onClick:()=>Jh(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)}),$e.length===0&&t.jsx("div",{className:"px-3 py-3 text-sm text-[var(--text-muted)]",children:"Sin valores"})]})]}):null}),document.body)};s.useEffect(()=>{if(!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(Ar(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>Cr.length&&Xa.toast.warning(`Exportando ${Cr.length.toLocaleString("es-MX")} de ${Jt.toLocaleString("es-MX")} (página actual). Usa exportación completa si está disponible.`),Cr}function gm(){const m=Dt.filter(ve=>!hr(ve)),A=mc(),V=m.map(ve=>hc(Ar(ve.header))).join(","),D=A.map(ve=>m.map(Ie=>hc(bc(Ie,ve))).join(",")).join(`
5
5
  `),le=`${V}
6
- ${O}`,be=new Blob(["\uFEFF"+le],{type:"text/csv;charset=utf-8;"}),we=URL.createObjectURL(be),$e=document.createElement("a");$e.href=we,$e.download=`${Qe}.csv`,document.body.appendChild($e),$e.click(),document.body.removeChild($e),URL.revokeObjectURL(we)}function vm(){const m=Dt.filter($e=>!hr($e)),A=mc(),V=m.map($e=>ja(Ar($e.header))),le=A.map($e=>m.map(ve=>ja(bc(ve,$e)))).map($e=>`<tr>${$e.map(ve=>`<td>${ve}</td>`).join("")}</tr>`).join(""),be=`<!DOCTYPE html>
6
+ ${D}`,be=new Blob(["\uFEFF"+le],{type:"text/csv;charset=utf-8;"}),we=URL.createObjectURL(be),$e=document.createElement("a");$e.href=we,$e.download=`${Qe}.csv`,document.body.appendChild($e),$e.click(),document.body.removeChild($e),URL.revokeObjectURL(we)}function vm(){const m=Dt.filter($e=>!hr($e)),A=mc(),V=m.map($e=>ja(Ar($e.header))),le=A.map($e=>m.map(ve=>ja(bc(ve,$e)))).map($e=>`<tr>${$e.map(ve=>`<td>${ve}</td>`).join("")}</tr>`).join(""),be=`<!DOCTYPE html>
7
7
  <html lang="es"><head><meta charset="utf-8"><title>${ja(Qe)}</title>
8
8
  <style>
9
9
  body{font-family:system-ui,sans-serif;font-size:11px;margin:20px;color:#111}
@@ -20,8 +20,8 @@ ${O}`,be=new Blob(["\uFEFF"+le],{type:"text/csv;charset=utf-8;"}),we=URL.createO
20
20
  <table><thead><tr>${V.map($e=>`<th>${$e}</th>`).join("")}</tr></thead>
21
21
  <tbody>${le}</tbody></table>
22
22
  <script>window.onload=()=>{window.print()}<\/script>
23
- </body></html>`,we=window.open("","_blank");we&&(we.document.write(be),we.document.close())}const qa=()=>!gt||!Mn?null:ht.createPortal(t.jsxs("div",{ref:Ro,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...zh,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():gm(),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()=>(Te?await Te():vm(),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&&Fe.trim().length>0,A=ge!=null&&ge.length?ge:m?[{key:"bql",label:"BQL",value:Fe}]:[],V=oe.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!ie&&ts===0&&!E&&!gt?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:Rh,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(Ke){wt(!1);return}Ha(),wt(!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:Ke?"var(--primary)":m?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:Ke||m?"var(--primary)":"var(--border)",color:Ke?"var(--primary-fg)":"var(--primary)"},"aria-expanded":Ke,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"}),Ke?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:w}),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"})}),Ke&&ht.createPortal(t.jsxs("div",{ref:qi,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...Ih,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)),ue.length>0&&t.jsxs("button",{type:"button",onClick:()=>Nt(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":xr,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 ${Me?"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"&&wt(!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:Me?"var(--danger)":"var(--text-muted)"},children:Me??(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))]}),xr&&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&&ue.length>0&&t.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:ue.map(O=>t.jsxs("button",{type:"button",onMouseDown:le=>{le.preventDefault(),le.stopPropagation()},onClick:le=>{le.preventDefault(),le.stopPropagation(),Oa(O.bql),Nt(!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)]})]}),gt&&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&&Wh({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"})}),ie&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Re&&nt==="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&&nt==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(z.HiCog6Tooth,{className:"h-4 w-4"})})]})},pc=()=>{if(!fm)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 ${K?"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":`${bm}–${hm} 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=>mm(Number(A)),options:ss.map(A=>({value:String(A),label:String(A)})),placeholder:"Filas",searchable:!1,disabled:a,height:j,padding:U,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:P}})]})]}),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"})]})},ym=()=>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:x?{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 ${je}`},children:[_t&&t.jsx("div",{role:"cell",className:`${K?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${je}`,borderRight:`1px solid ${je}`}},"select-cell"),Dt.map((V,O)=>t.jsx("div",{role:"cell",className:K?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${je}`,borderRight:`1px solid ${je}`},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 R&&He&&!Je?t.jsx(In,{rows:o,columns:Math.max(4,Dt.length||7)}):!a&&r.length===0&&!es?ym():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:x?{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 ${je}`},children:[_t&&t.jsx("div",{role:"cell",className:`${K?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${je}`,borderRight:`1px solid ${je}`}},"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:K?"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 ${je}`:`inset 0 -1px 0 ${je}`,borderRight:`1px solid ${je}`}:{borderBottom:`1px solid ${je}`,borderRight:`1px solid ${je}`},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:x?{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:je,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:x?{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&&N.has(V),$e=_t&&(!S||S(m)),ve=rn?(h==null?void 0:h(m))??!0:!1,Ie=ve&&oc.has(V),De=!!d||g&&ve,Ue=we&&M?"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:K?"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 ${je}`,borderRight:`1px solid ${je}`},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":""} ${D?D(m):""}`,style:{gridTemplateColumns:nn,"--dt-row-bg":Ue,"--dt-sticky-bg":Ue,background:"var(--dt-row-bg)",borderBottom:`1px solid ${je}`},onMouseEnter:xe=>{we||(xe.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),xe.currentTarget.style.setProperty("--dt-sticky-bg",pm))},onMouseLeave:xe=>{xe.currentTarget.style.setProperty("--dt-row-bg",Ue),xe.currentTarget.style.setProperty("--dt-sticky-bg",Ue)},children:[rn&&t.jsx("div",{role:"cell",className:`${K?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${je}`,borderRight:`1px solid ${je}`},"data-dt-disable-row-click":"true",children:ve&&t.jsx("button",{type:"button","aria-label":Ie?"Contraer fila":"Desplegar fila","aria-expanded":Ie,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:Ie?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:`${K?"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 ${je}`}:{borderBottom:`1px solid ${je}`,borderRight:`1px solid ${je}`},onClick:xe=>{xe.stopPropagation(),$e&&v(V)},children:t.jsx(Fn,{size:"sm",checked:we,disabled:!$e,"aria-label":$e?"Seleccionar fila":"Fila no seleccionable",containerClassName:"items-center",className:$e?"cursor-pointer":"cursor-not-allowed opacity-50",onClick:xe=>xe.stopPropagation(),onChange:()=>{$e&&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":`${K?"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 ${je}`:`inset 0 -1px 0 ${je}`,borderRight:`1px solid ${je}`}:{borderBottom:`1px solid ${je}`,borderRight:`1px solid ${je}`}},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)})]}),Ie&&u&&t.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:nn},children:t.jsx("div",{role:"cell",className:K?"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 ${je}`},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 Dr(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=Dr(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=Dr(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=Dr(o.start);const i=Dr(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=Dr(r[0]),o=Dr(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 N=l.findIndex(v=>v<f);N<0?(N=l.length,l.push(f+g-1)):l[N]=f+g-1,i.push({item:d,lane:N,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:N,tableColumns:v,tableProps:H,onItemClick:S,onDayClick:M,loading:D=!1,emptyTitle:C="Sin eventos",emptyDescription:x="No hay eventos para los filtros seleccionados.",legend:$,legendInteractive:y=!0,activeLegendKeys:P,defaultActiveLegendKeys:j,onActiveLegendKeysChange:U,getItemLegendKey:L,overloadLabel:J="Sobrecarga de eventos",notice:q,showOverload:ae=!0,layout:R="span",className:fe="",showToolbar:I=!0}){const K=h??(b?[...qs]:[...xd]),ee=b?5:7,T=b?"grid grid-cols-5":"grid grid-cols-7",W=s.useMemo(()=>($??[]).map(de=>de.label),[$]),[ie,B]=s.useState(()=>j??W),re=s.useMemo(()=>P??(W.length>0?ie:[]),[P,W.length,ie]),Z=s.useMemo(()=>new Set(re),[re]),Y=de=>{P===void 0&&B(de),U==null||U(de)},se=de=>{y&&(Z.has(de)?Y(re.filter(Te=>Te!==de)):Y([...re,de]))},E=s.useMemo(()=>{if(!y||W.length===0)return e;const de=new Set(W);return e.filter(Te=>{const ne=(L==null?void 0:L(Te))??Te.status;return!ne||!de.has(ne)?!0:Z.has(ne)})},[e,y,W,Z,L]),Q=s.useMemo(()=>zs(E,c),[E,c]),ce=s.useMemo(()=>{const de=ao(r);return b?Vn(de):de},[r,b]),X=s.useMemo(()=>{const de=ao(r);return b?Ps(de):oo(de)},[r,b]),w=s.useMemo(()=>b?_s(r):no(r),[r,b]),k=zt(r),te=Q[k]??[],ue=s.useMemo(()=>so(E,w,c),[E,w,c]),oe=s.useMemo(()=>ue.length===0?1:Math.max(...ue.map(de=>de.lane))+1,[ue]),ge=s.useMemo(()=>X.map(de=>{const Te=so(E,de,c),ne=Te.length===0?0:Math.max(...Te.map(He=>He.lane))+1;return{days:de,bars:Te,laneCount:ne}}),[X,E,c]),Me=36,Ae=38,$t=s.useMemo(()=>{const de=l==="month"?ce:l==="week"?w:[r],Te=[];for(const ne of de){const He=zt(ne),ze=Q[He]??[];ze.length>=u&&Te.push([ne,ze])}return Te},[l,ce,w,r,Q,u]),mt=l==="month"?vd(r):l==="week"?`${Ht(w[0])} – ${Ht(w[6])}`:yd(r),gt=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 Te=nr(de,c);return Te?`${Ht(Te.start)} → ${Ht(Te.end)}`:"—"}},{key:"subtitle",header:"Detalle",cell:de=>de.subtitle??"—"}],[c]),Qe=de=>{if(n(de),M){M(de);return}i("day")};return t.jsxs("div",{className:`bonsaif-event-calendar space-y-4 ${fe}`.trim(),children:[I?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:mt}),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,$&&$.length>0?t.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",role:y?"group":void 0,"aria-label":y?"Filtrar por estado":void 0,children:$.map(de=>{const Te=Z.has(de.label);return y?t.jsxs("button",{type:"button","aria-pressed":Te,onClick:()=>se(de.label),className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 transition-opacity",style:{color:Te?"var(--text-main)":"var(--text-muted)",background:Te?"color-mix(in srgb, var(--bg-card) 80%, transparent)":"transparent",border:Te?`1px solid color-mix(in srgb, ${de.color} 55%, var(--border))`:"1px solid var(--border)",opacity:Te?1:.45},title:Te?`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:Te?`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"&&q&&q.items.length>0?t.jsxs("div",{className:"rounded-lg px-4 py-3 text-sm",style:q.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:[q.label,":"]})," ",q.items.join(", ")]}):a==="calendar"&&ae&&$t.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:[J,":"]})," ",$t.map(([de,Te])=>`${Ht(de)} (${Te.length})`).join(", ")]}):null,a==="table"?D||E.length>0?t.jsx(ro,{columns:v??gt,data:E,getRowId:de=>de.id,loading:D,skeletonRows:8,emptyIcon:t.jsx(z.HiCalendarDays,{className:"h-10 w-10"}),emptyText:x,onRowClick:S,pageSize:25,compact:!0,...H}):t.jsx(Un,{icon:t.jsx(z.HiCalendarDays,{className:"h-5 w-5"}),title:C,description:x}):null,a==="calendar"&&l==="month"&&R==="daily"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{className:T,style:{borderBottom:"1px solid var(--border)"},children:K.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:T,children:ce.map(de=>{const Te=zt(de),ne=Q[Te]??[],He=de.getMonth()!==r.getMonth(),ze=Math.max(0,ne.length-d);return t.jsxs("div",{role:"button",tabIndex:0,"aria-label":`${de.getDate()}`,onClick:()=>Qe(de),onKeyDown:Ye=>{(Ye.key==="Enter"||Ye.key===" ")&&(Ye.preventDefault(),Qe(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:He?"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(Ye=>t.jsx(Us,{item:Ye,day:de,renderPill:p,onClick:()=>S==null?void 0:S(Ye)},Ye.id)),ze>0?t.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-muted)"},children:["+",ze," más"]}):null]})]},Te)})})]}):null,a==="calendar"&&l==="month"&&R==="span"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{className:T,style:{borderBottom:"1px solid var(--border)"},children:K.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:Te,laneCount:ne},He)=>{const ze=Math.min(ne,d),Ye=Math.max(0,ne-d),Xe=Me+Math.max(1,ze)*Ae+(Ye>0?20:8)+8;return t.jsxs("div",{className:"relative",style:{minHeight:Xe,borderBottom:He<ge.length-1?"1px solid var(--border)":void 0},children:[t.jsx("div",{className:T,style:{minHeight:Xe},children:de.map(We=>{const Je=zt(We),vt=Q[Je]??[],ut=We.getMonth()!==r.getMonth();return t.jsx("div",{role:"button",tabIndex:0,"aria-label":`${We.getDate()}`,onClick:()=>Qe(We),onKeyDown:yt=>{(yt.key==="Enter"||yt.key===" ")&&(yt.preventDefault(),Qe(We))},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:Xe},children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-sm font-semibold",style:{color:ut?"var(--text-muted)":"var(--text-main)"},children:We.getDate()}),vt.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:vt.length}):null]})},Je)})}),t.jsxs("div",{className:"pointer-events-none absolute inset-x-0",style:{top:Me,bottom:4},children:[Te.filter(We=>We.lane<d).map(We=>{const Je={left:`calc(${We.colStart/ee*100}% + 4px)`,width:`calc(${We.colSpan/ee*100}% - 8px)`,top:2+We.lane*Ae,height:Ae-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(We.item,{day:de[We.colStart]})})},`${We.item.id}-${We.colStart}-${He}`):N?t.jsx("div",{className:"absolute overflow-hidden",style:Je,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:N(We.item)})},`${We.item.id}-${We.colStart}-${He}`):t.jsx(wd,{item:We.item,style:Je,onClick:()=>S==null?void 0:S(We.item)},`${We.item.id}-${We.colStart}-${He}`)}),Ye>0?t.jsxs("span",{className:"absolute text-[11px] font-semibold",style:{left:8,top:2+ze*Ae,color:"var(--text-muted)"},children:["+",Ye," más"]}):null]})]},`week-${He}-${zt(de[0])}`)})]}):null,a==="calendar"&&l==="week"&&R==="daily"?t.jsx("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)"},children:t.jsx("div",{className:T,children:w.map(de=>{const Te=zt(de),ne=Q[Te]??[],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:()=>Qe(de),children:[Ws(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(ze=>t.jsx(Us,{item:ze,day:de,renderPill:p,onClick:()=>S==null?void 0:S(ze)},ze.id)),He>0?t.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-muted)"},children:["+",He," más"]}):null]})]},Te)})})}):null,a==="calendar"&&l==="week"&&R==="span"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)"},children:[t.jsx("div",{className:`${T} border-b`,style:{borderColor:"var(--border)"},children:w.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:()=>Qe(de),children:Ws(de)},zt(de)))}),t.jsxs("div",{className:`relative ${T}`,style:{minHeight:Math.max(220,oe*56+24)},children:[w.map(de=>t.jsx("div",{className:"min-h-full",style:{borderRight:"1px solid var(--border)"}},`lane-${zt(de)}`)),ue.map(de=>{const Te={left:`calc(${de.colStart/ee*100}% + 4px)`,width:`calc(${de.colSpan/ee*100}% - 8px)`,top:12+de.lane*56,height:48};return N?t.jsx("div",{className:"absolute overflow-hidden",style:Te,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:N(de.item)})},`${de.item.id}-${de.colStart}`):t.jsx(kd,{item:de.item,style:Te,onClick:()=>S==null?void 0:S(de.item)},`${de.item.id}-${de.colStart}`)}),ue.length===0&&!D?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||D?t.jsxs("div",{className:"space-y-3",children:[D&&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(de=>g?t.jsx("div",{children:g(de)},de.id):t.jsx(Nd,{item:de,onClick:()=>S==null?void 0:S(de)},de.id))]}):t.jsx(Un,{icon:t.jsx(z.HiCalendarDays,{className:"h-5 w-5"}),title:C,description:x}):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",...N}){const[v,H]=s.useState(!1),S=s.useRef(null);s.useEffect(()=>()=>{S.current&&window.clearTimeout(S.current)},[]);function M(C){H(!0),d==null||d(C),S.current&&window.clearTimeout(S.current),S.current=window.setTimeout(()=>{H(!1),S.current=null},r)}async function D(C){if(c&&C.stopPropagation(),p==null||p(C),C.defaultPrevented)return;const x=Ed(e);if(x)try{await lo(x),M(x)}catch($){u==null||u($,x)}}return t.jsxs("button",{...N,type:g,onClick:D,title:v?a:n,"aria-label":N["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:N="px-6 py-5",panelClassName:v="",backdropClassName:H=Ld,contentClassName:S="p-4",ariaLabel:M,frameless:D=!1,disabled:C=!1}){const[x,$]=s.useState(!1),[y,P]=s.useState(!1),j=s.useRef(null);if(s.useEffect(()=>(e?(j.current&&clearTimeout(j.current),$(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>P(!0)))):(P(!1),j.current=setTimeout(()=>$(!1),Yn+40)),()=>{j.current&&clearTimeout(j.current)}),[e]),s.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),s.useEffect(()=>{if(!e||!f)return;const R=fe=>{fe.key==="Escape"&&r()};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[f,r,e]),!x)return null;const U=n||a||o||l||p,L=u??Ad[d],J=g==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",q=g==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",ae=y?"translateY(0) scale(1)":g==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return ht.createPortal(t.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":M??n,className:`fixed inset-0 flex ${J} ${S}`,style:{zIndex:h},children:[t.jsx("div",{className:`absolute inset-0 ${H}`,onClick:b?r:void 0,style:{opacity:y?1:0,transition:`opacity ${Yn}ms ease`}}),t.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${D?"shadow-none":"shadow-2xl"} ${q} ${v}`,style:{maxWidth:L,background:D?"transparent":"var(--bg-card)",border:D?"none":"1px solid var(--border)",opacity:y?1:0,transform:ae,transition:`opacity ${Yn}ms ease, transform ${Yn}ms ease`},onClick:R=>R.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(Ve,{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 ${N}`,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(Ve,{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(Ve,{variant:"secondary",onClick:d,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:o}),t.jsx(Ve,{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,N]=s.useState({}),[v,H]=s.useState(null),S=s.useRef(null);S.current=v;const[M,D]=s.useState({}),[C,x]=s.useState({}),$=s.useRef(new Set),y=s.useRef(null);s.useEffect(()=>{var W;const T=document.activeElement;(!T||T===document.body)&&((W=y.current)==null||W.focus({preventScroll:!0}))},[]);const P=e.map(T=>{var W,ie,B;return`${T.key}:${((B=(ie=(W=T.editable)==null?void 0:W.select)==null?void 0:ie.options)==null?void 0:B.length)??-1}`}).join("|");s.useEffect(()=>{e.forEach(T=>{var B,re;const W=(re=(B=T.editable)==null?void 0:B.select)==null?void 0:re.options;if(!W)return;const ie=M[T.key];(!$.current.has(T.key)||(ie==null?void 0:ie.length)===0&&W.length>0)&&($.current.add(T.key),D(Z=>({...Z,[T.key]:W})))})},[P]);const j=s.useCallback(async(T,W)=>{if($.current.has(T))return;$.current.add(T);const{url:ie,fetchOptions:B}=W.select??{};if(!(!ie&&!B)){x(re=>({...re,[T]:!0}));try{let re=[];if(B)re=await B();else if(ie){const Z=await fetch(ie);if(!Z.ok)throw new Error("fetch failed");re=await Z.json()}D(Z=>({...Z,[T]:re}))}catch{D(re=>({...re,[T]:[]}))}finally{x(re=>({...re,[T]:!1}))}}},[]),U=s.useRef(i);U.current=i;const L=s.useRef(a);L.current=a;const J=s.useRef(n);J.current=n;const q=s.useRef(e);q.current=e;const ae=s.useRef(o);ae.current=o,s.useEffect(()=>{if(e.length>0&&r.length>0){const T=e.find(W=>W.selectable!==!1);T&&f({rowId:n(r[0]),colKey:T.key})}},[]),s.useEffect(()=>{if(!b)return;const T=y.current;if(!T)return;const W=T.querySelector(`[data-cell-id="${b.rowId}:${b.colKey}"]`);if(!W)return;const ie=T.querySelector('[role="rowgroup"]');W.style.scrollMarginTop=`${(ie==null?void 0:ie.offsetHeight)??0}px`;const B=T.querySelector('[role="row"]');let re=0;B&&B.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(Z=>{Z.style.position==="sticky"&&Z.style.left!==""&&(re=Math.max(re,parseFloat(Z.style.left)+Z.offsetWidth))}),W.style.scrollMarginLeft=`${re}px`,W.scrollIntoView({block:"nearest",inline:"nearest"})},[b]);const R=s.useCallback(T=>{var re;const W=q.current,ie=new Set,B=[];(re=y.current)==null||re.querySelectorAll("[data-cell-id]").forEach(Z=>{const Y=Z.dataset.cellId.split(":")[0];ie.has(Y)||(ie.add(Y),B.push(Y))}),f(Z=>{if(!Z)return Z;const Y=W.findIndex(ce=>ce.key===Z.colKey),se=B.indexOf(Z.rowId);let E=Y,Q=se;if(T==="up")Q=Math.max(0,se-1);else if(T==="down")Q=Math.min(B.length-1,se+1);else if(T==="left"){let ce=Y-1;for(;ce>=0&&W[ce].selectable===!1;)ce--;ce>=0&&(E=ce)}else if(T==="right"){let ce=Y+1;for(;ce<W.length&&W[ce].selectable===!1;)ce++;ce<W.length&&(E=ce)}return E===Y&&Q===se?Z:{rowId:B[Q],colKey:W[E].key}})},[]),fe=s.useCallback((T=!0)=>{const W=d.current;h(null),W&&f(W),T&&setTimeout(()=>{var ie;return(ie=y.current)==null?void 0:ie.focus({preventScroll:!0})},0)},[]),I=s.useCallback(async(T,W,ie)=>{var oe;const B=q.current.find(ge=>ge.key===W);if(!(B!=null&&B.editable))return;const{field:re,type:Z,mask:Y,validate:se}=B.editable,E=Z==="number"?ie===""?null:Number(ie):ie;if(Y){const ge=Pd(ie,Y);if(ge){N(Me=>({...Me,[`${T}:${W}`]:ge}));return}}if(se){const ge=se(E);if(ge){N(Me=>({...Me,[`${T}:${W}`]:ge}));return}}const Q=J.current,ce=U.current.find(ge=>Q(ge)===T);if(!ce)return;const X=ce[re];h(null),N(ge=>{const Me={...ge};return delete Me[`${T}:${W}`],Me});const w=U.current,k=w.findIndex(ge=>Q(ge)===T),te=w[Math.min(w.length-1,k+1)];if(f({rowId:Q(te),colKey:W}),setTimeout(()=>{var Me,Ae;const ge=document.activeElement;(!ge||ge===document.body||(Me=y.current)!=null&&Me.contains(ge))&&((Ae=y.current)==null||Ae.focus({preventScroll:!0}))},0),String(X??"")===String(E??""))return;const ue={...ce,[re]:E};c(ge=>ge.map(Me=>Q(Me)===T?ue:Me)),H({rowId:T,colKey:W});try{await((oe=L.current)==null?void 0:oe.call(L,{row:ce,rowId:T,field:re,oldValue:X,newValue:E}))}catch{c(ge=>ge.map(Me=>Q(Me)===T?ce:Me)),N(ge=>({...ge,[`${T}:${W}`]:"Error al guardar. Intenta de nuevo."}))}finally{H(null)}},[]),K=s.useCallback(T=>{if(S.current){T.preventDefault();return}if(d.current)return;const W=p.current;if(!(!W||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(T.key)))switch(T.preventDefault(),T.key){case"ArrowUp":R("up");break;case"ArrowDown":R("down");break;case"ArrowLeft":R("left");break;case"ArrowRight":R("right");break;case"Tab":R(T.shiftKey?"left":"right");break;case"Enter":{const B=q.current.find(re=>re.key===W.colKey);B!=null&&B.editable&&!ae.current?(h(W),B.editable.type==="select"&&!$.current.has(W.colKey)&&j(W.colKey,B.editable)):R("down");break}}},[R,j]),ee=s.useMemo(()=>e.map(T=>{if(!T.editable||o){const ie={...T};if(delete ie.editable,delete ie.selectable,T.selectable===!1)return{...ie,disableRowClick:!0};const B=ie.cell;return{...ie,className:`relative ${ie.className??""}`.trim(),disableRowClick:!0,cell:re=>{const Z=n(re),Y=(b==null?void 0:b.rowId)===Z&&(b==null?void 0:b.colKey)===T.key;return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${Z}:${T.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var se;S.current||(f({rowId:Z,colKey:T.key}),(se=y.current)==null||se.focus({preventScroll:!0}))}}),Y&&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(re)})]})}}}const W=T.editable;return{...T,className:`relative ${T.className??""}`.trim(),disableRowClick:!0,cell:ie=>{const B=n(ie),re=T.key,Z=(u==null?void 0:u.rowId)===B&&(u==null?void 0:u.colKey)===re,Y=(b==null?void 0:b.rowId)===B&&(b==null?void 0:b.colKey)===re,se=g[`${B}:${re}`],E=(v==null?void 0:v.rowId)===B&&(v==null?void 0:v.colKey)===re,Q=ie[W.field],ce=String(Q??""),X=()=>{var k;S.current||(f({rowId:B,colKey:re}),h({rowId:B,colKey:re}),(k=y.current)==null||k.focus({preventScroll:!0}),W.type==="select"&&!$.current.has(re)&&j(re,W))};if(Z){const k=W.type==="select"?t.jsx(jd,{initialValue:ce,options:M[re]??[],loading:C[re]??!1,onCommit:te=>I(B,re,te),onCancel:fe}):t.jsx(Wd,{initialValue:ce,type:W.type??"text",mask:W.mask,onCommit:te=>I(B,re,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 w=T.cell(ie);return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${B}:${re}`,className:`peer absolute inset-0 z-10 ${E?"cursor-wait":"cursor-pointer"}`,onClick:X}),Y&&!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:w})}),!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,M,C,n,I,fe,j]);return t.jsx("div",{ref:y,tabIndex:0,onKeyDown:K,onBlur:T=>{var W;(W=y.current)!=null&&W.contains(T.relatedTarget)||setTimeout(()=>{var B,re;const ie=document.activeElement;ie&&((B=ie.closest)!=null&&B.call(ie,"[data-bonsaif-select-dropdown]"))||(re=y.current)!=null&&re.contains(ie)||fe(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:t.jsx(ro,{...l,columns:ee,data:i,getRowId:n})})}function ft(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 Or(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ys(e){return e.map(r=>ft(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=ft(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:ft(e),to:ft(r)},f=ft(a),[p,g]=s.useState(()=>ft(o||e)??new Date);s.useEffect(()=>{const M=ft(o||e);M&&g(M)},[o,e]);const N=s.useMemo(()=>{if(l<=1)return Or(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(p));const M=new Date(p.getFullYear(),p.getMonth()+l-1,1),D=p.getFullYear()===M.getFullYear(),C=new Intl.DateTimeFormat("es-MX",{month:"short",...D?{}:{year:"numeric"}}).format(p),x=new Intl.DateTimeFormat("es-MX",{month:"short",year:"numeric"}).format(M);return`${Or(C)} – ${Or(x)}`},[p,l]);function v(){g(new Date(p.getFullYear(),p.getMonth()-1,1))}function H(){g(new Date(p.getFullYear(),p.getMonth()+1,1))}const S=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:N}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes siguiente",onClick:H,children:t.jsx(z.HiChevronRight,{size:16})})]}),t.jsx(Ya.DayPicker,{mode:"range",selected:b,month:p,onMonthChange:g,onSelect:M=>{const D=M!=null&&M.from?Bt(M.from):e,C=M!=null&&M.to?Bt(M.to):"";n({startDate:D,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:S,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:M=>`${Or(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(M))} ${M.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=ft(e),a=ft(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 x=C;if(c){const $=b.current.filter(P=>!P.startsWith(c)),y=C.filter(P=>P.startsWith(c));x=[...$,...y].sort()}r==null||r(Zd(x,l))},[l,r,c]),p=s.useCallback((C,x=!1)=>Qd(C,a,o)?!0:!(!(i!=null&&i(C))||x&&b.current.includes(C)),[i,o,a]),g=s.useCallback(C=>C.filter(x=>!p(x)),[p]),N=s.useCallback(()=>{u.current=null},[]);s.useEffect(()=>{const C=()=>N();return window.addEventListener("pointerup",C),window.addEventListener("pointercancel",C),()=>{window.removeEventListener("pointerup",C),window.removeEventListener("pointercancel",C)}},[N]);const v=s.useCallback((C,x,$,y)=>{const P=g(Zs(C,x));f($==="add"?hn(y,P,"add"):hn(y,P,"remove"))},[f,g]),H=s.useCallback((C,x)=>{if(n||x.button!==0)return;const $=Bt(C);if(p($,!0)||x.shiftKey)return;h.current=!0;const y=[...b.current],P=y.includes($)?"remove":"add";P==="add"&&p($)||(u.current={active:!0,mode:P,anchor:$,latest:$,baseline:y},d.current=$,v($,$,P,y),x.preventDefault())},[v,n,p]),S=s.useCallback(C=>{const x=u.current;if(!(x!=null&&x.active)||n)return;const $=Bt(C);x.mode==="add"&&p($)||x.latest!==$&&(x.latest=$,v(x.anchor,$,x.mode,x.baseline))},[v,n,p]),M=s.useCallback((C,x)=>{if(n)return;const $=Bt(C);if(!p($,!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 y=g(Zs(d.current,$));f(hn(b.current,y,"add"));return}!b.current.includes($)&&p($)||(d.current=$,f(hn(b.current,[$],"toggle")))}},[f,n,g,p]),D=s.useCallback(C=>{if(n)return;const x=g(Vd(C));if(!x.length)return;const $=x.every(y=>b.current.includes(y));f(hn(b.current,x,$?"remove":"add")),d.current=x[0]??d.current},[f,n,g]);return{onDayPointerDown:H,onDayPointerEnter:S,onDayClick:M,toggleWeek:D,endDrag:N}}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]),N=s.useMemo(()=>new Set(e),[e]),v=ft(n),H=ft(a),[S,M]=s.useState(()=>ft(l||e[0])??new Date),[D,C]=s.useState(()=>mn(ft(l||e[0])??new Date)),[x,$]=s.useState(u),y=d??x;function P(T){d===void 0&&$(T),h==null||h(T)}s.useEffect(()=>{const T=ft(l);T&&(M(T),C(mn(T)))},[l]);const{onDayPointerDown:j,onDayPointerEnter:U,onDayClick:L,toggleWeek:J}=Js({value:e,onChange:r,disabled:p,minDate:n,maxDate:a,maxDates:i,isDateDisabled:o}),q=s.useMemo(()=>{if(p)return!0;const T=[];return v&&T.push({before:v}),H&&T.push({after:H}),o&&T.push(W=>o(Bt(W))),T.length>0?T:void 0},[p,o,H,v]),ae=s.useCallback(T=>t.jsx(Ks,{...T,className:`bonsaif-multi-day-btn ${T.className??""}`,onDayPointerDown:j,onDayPointerEnter:U,onDayClickSelect:L}),[L,j,U]),R=s.useMemo(()=>Qs(D,1),[D]),fe=R[6],I=y==="week"?`${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short"}).format(R[0])} – ${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short",year:"numeric"}).format(fe)}`:Or(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(S));function K(){if(y==="week"){const T=Rs(D,-7);C(mn(T)),M(T);return}M(new Date(S.getFullYear(),S.getMonth()-1,1))}function ee(){if(y==="week"){const T=Rs(D,7);C(mn(T)),M(T);return}M(new Date(S.getFullYear(),S.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":y==="month",className:`bonsaif-cal-view-btn${y==="month"?" is-active":""}`,disabled:p,onClick:()=>{P("month"),M(D)},children:"Mes"}),t.jsx("button",{type:"button",role:"tab","aria-selected":y==="week",className:`bonsaif-cal-view-btn${y==="week"?" is-active":""}`,disabled:p,onClick:()=>{P("week"),C(mn(S))},children:"Semana"})]}),t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":y==="week"?"Semana anterior":"Mes anterior",disabled:p,onClick:K,children:t.jsx(z.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:I}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":y==="week"?"Semana siguiente":"Mes siguiente",disabled:p,onClick:ee,children:t.jsx(z.HiChevronRight,{size:16})})]}),t.jsxs("p",{className:"bonsaif-cal-hint",children:["Click · Shift+click rango · Arrastra",c&&y==="month"?" · Semana (nº)":"",y==="week"?" · Botón semana completa":""]}),y==="month"?t.jsx(Ya.DayPicker,{mode:"multiple",required:!1,selected:g,month:S,onMonthChange:M,onSelect:()=>{},hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,showWeekNumber:c,onWeekNumberClick:(T,W)=>{J(W)},disabled:q,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:ae,Weekday:mo},formatters:{formatWeekdayName:fo}}):t.jsxs("div",{className:"bonsaif-week-view",children:[t.jsx("div",{className:"bonsaif-week-view-head",children:R.map(T=>t.jsx("div",{className:"bonsaif-multi-weekday",children:new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(T)},`h-${Bt(T)}`))}),t.jsx("div",{className:"bonsaif-week-view-days",children:R.map(T=>{const W=Bt(T),ie=N.has(W),B=p||(n?W<n:!1)||(a?W>a:!1)||!!(o!=null&&o(W)),re=W===Bt(new Date);return t.jsx("div",{className:`bonsaif-multi-day${ie?" bonsaif-multi-day-selected":""}${re?" bonsaif-multi-day-today":""}${B?" bonsaif-multi-day-disabled":""}`,children:t.jsxs("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:B,"aria-pressed":ie,onPointerDown:Z=>j(T,Z),onPointerEnter:()=>U(T),onClick:Z=>L(T,Z),children:[t.jsx("span",{className:"bonsaif-week-day-num",children:T.getDate()}),t.jsx("span",{className:"bonsaif-week-day-month",children:new Intl.DateTimeFormat("es-MX",{month:"short"}).format(T)})]})},W)})}),t.jsx("button",{type:"button",className:"bonsaif-week-select-all",disabled:p,onClick:()=>J(R),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=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:p,onClick:()=>r==null?void 0:r(e.filter(W=>W!==T)),title:`Quitar ${T}`,children:[Gs(T),t.jsx("span",{"aria-hidden":!0,children:"×"})]},T))})]})}):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=ft(o),p=ft(l),g=n??(e[0]?Number(e[0].slice(0,4)):new Date().getFullYear()),[N,v]=s.useState(g);s.useEffect(()=>{typeof n=="number"&&v(n)},[n]);function H(y){v(y),a==null||a(y)}const{onDayPointerDown:S,onDayPointerEnter:M,onDayClick:D}=Js({value:e,onChange:r,disabled:u||h,minDate:o,maxDate:l,maxDates:i,retainOutsidePrefix:`${N}-`}),C=s.useCallback(y=>t.jsx(Ks,{...y,className:`bonsaif-year-day-btn ${y.className??""}`,onDayPointerDown:S,onDayPointerEnter:M,onDayClickSelect:D}),[D,S,M]),x=b.filter(y=>y.getFullYear()===N),$=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:()=>H(N-1),children:t.jsx(z.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:N}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año siguiente",disabled:u,onClick:()=>H(N+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(y=>{const P=new Date(N,y,1);return t.jsxs("div",{className:"bonsaif-year-cal-month",children:[t.jsx("div",{className:"bonsaif-year-cal-month-title",children:Or(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(P))}),t.jsx(Ya.DayPicker,{mode:"multiple",required:!1,selected:x,month:P,onMonthChange:()=>{},onSelect:()=>{},numberOfMonths:1,hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,disabled:$,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:j=>new Intl.DateTimeFormat("es-MX",{weekday:"narrow"}).format(j)}})]},`${N}-${y}`)})})]}),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"," ·"," ",N]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(y=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:u||h,onClick:()=>r==null?void 0:r(e.filter(P=>P!==y)),title:`Quitar ${y}`,children:[Gs(y),t.jsx("span",{"aria-hidden":!0,children:"×"})]},y))})]})}):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),N=s.useRef(null),v=s.useCallback(C=>{u(C),c==null||c(C)},[c]),H=s.useCallback(()=>{const C=g.current;if(!C)return;const x=C.getBoundingClientRect(),$=typeof a=="number"?a:x.width,y=typeof a=="number"?a:Math.max(x.width,180),P=n==="end"?Math.max(8,x.right-y):Math.min(x.left,window.innerWidth-y-8),j=window.innerHeight-x.bottom,U=j<240&&x.top>j?void 0:x.bottom+6,L=U===void 0?window.innerHeight-x.top+6:void 0;p({position:"fixed",zIndex:9999,left:P,top:U,bottom:L,width:ru(typeof a=="number"?$:a)})},[n,a]);s.useEffect(()=>b(!0),[]),s.useEffect(()=>{if(!d)return;H();const C=$=>{var P,j;const y=$.target;!((P=g.current)!=null&&P.contains(y))&&!((j=N.current)!=null&&j.contains(y))&&v(!1)},x=$=>{$.key==="Escape"&&v(!1)};return document.addEventListener("mousedown",C),window.addEventListener("keydown",x),window.addEventListener("resize",H),window.addEventListener("scroll",H,!0),()=>{document.removeEventListener("mousedown",C),window.removeEventListener("keydown",x),window.removeEventListener("resize",H),window.removeEventListener("scroll",H,!0)}},[d,v,H]);const S=C=>{o||(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),v(!d))},M=s.isValidElement(e)?s.cloneElement(e,{onClick:()=>{o||(el(),v(!d))}}):e,D=d?t.jsx("div",{ref:N,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 x;C.disabled||(el(),(x=C.onSelect)==null||x.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:S,className:`inline-flex ${o?"pointer-events-none opacity-60":""} ${l}`,children:[M,h&&D?ht.createPortal(D,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:N="Descartar",unsavedChangesCancelLabel:v="Seguir editando",onDiscardChanges:H,disabled:S=!1,disabledMessage:M,children:D}){const[C,x]=s.useState(!1),[$,y]=s.useState(!1),[P,j]=s.useState(!1),U=s.useCallback(()=>{y(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>j(!0))})},[]),L=s.useCallback(()=>{j(!1),window.setTimeout(()=>y(!1),au)},[]),J=S||c,q=s.useCallback(()=>{if(!J){if(f){U();return}r()}},[J,f,r,U]),ae=s.useCallback(()=>{j(!1),y(!1),H==null||H(),r()},[r,H]);if(s.useEffect(()=>{x(!0)},[]),s.useEffect(()=>(document.body.style.overflow=e?"hidden":"",e||(j(!1),y(!1)),()=>{document.body.style.overflow=""}),[e]),s.useEffect(()=>{if(!e)return;const fe=I=>{if(I.key==="Escape"&&!J){if($){L();return}q()}};return window.addEventListener("keydown",fe),()=>window.removeEventListener("keydown",fe)},[L,J,$,e,q]),!C)return null;const R=M!==void 0?M:c?"Guardando…":null;return ht.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:q}),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(Ve,{variant:"icon",onClick:q,title:"Cerrar",disabled:J,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(Ve,{variant:"secondary",size:"sm",onClick:q,disabled:J,style:{background:"var(--bg-input)"},children:"Cancelar"}),t.jsx(Ve,{variant:"primary",size:"sm",icon:t.jsx(yc.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:d||J,title:l})]})]})]}),t.jsx("div",{"data-drawer-scroll":"true",className:h,children:D}),J&&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:R?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:R})]}):null})]}),$&&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 ${P?"opacity-100":"opacity-0"}`,onClick:L}),t.jsxs("div",{className:`relative z-10 w-full max-w-sm rounded-2xl border p-6 shadow-2xl transition-[opacity,transform] duration-200 ease-out ${P?"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(Ve,{variant:"icon",onClick:L,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":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(Ve,{variant:"secondary",onClick:L,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:v}),t.jsx(Ve,{variant:"secondary",onClick:ae,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:N})]})]})]})]}),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 Hr({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 Br({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,N]=s.useState(()=>!!p.autoFocus),[v,H]=s.useState(!1),S=p.type==="password"&&u,M=S&&v?"text":p.type,D=!!o,C=D&&l!=="tooltip",x=D&&l!=="inline",$=!!n&&a==="tooltip"&&!C,y=h?f:void 0,P=D?"border-[var(--danger)] focus:border-[var(--danger)]":"",j=x?S?"pr-20":"pr-10":S?"pr-10":"",U=p.value!==void 0?String(p.value).length>0:p.defaultValue!==void 0&&String(p.defaultValue).length>0,L=g||U,J={top:L?7:12,color:g?"var(--primary)":"var(--text-muted)",fontSize:L?10:13,fontWeight:L?600:400,textTransform:L?"uppercase":"none"},q=K=>{var ee;N(!0),(ee=p.onFocus)==null||ee.call(p,K)},ae=K=>{var ee;N(!1),(ee=p.onBlur)==null||ee.call(p,K)},R=S?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:()=>H(K=>!K),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=x?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)] ${S?"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,I=t.jsx(Br,{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:M,required:y,placeholder:" ","aria-invalid":D||p["aria-invalid"],"data-has-value":U?"true":void 0,className:`h-11 w-full pt-5 ${j} ${P} ${b}`,onFocus:q,onBlur:ae}),t.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:J,children:[e,f&&t.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),c&&t.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:L?7:12},children:c}),fe,R]}),I]}):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.jsx(Hr,{content:n}):null,c&&t.jsx("span",{className:"ml-auto normal-case",children:c})]}),S?t.jsxs("span",{className:"relative block",children:[t.jsx(Zn,{...p,type:M,required:y,"aria-invalid":D||p["aria-invalid"],className:`w-full ${j} ${P} ${b}`,onFocus:q,onBlur:ae}),fe,R]}):t.jsxs("span",{className:"relative block",children:[t.jsx(Zn,{...p,required:y,"aria-invalid":D||p["aria-invalid"],className:`w-full ${j} ${P} ${b}`}),fe]}),I]})}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=N=>{i===void 0&&b(N.currentTarget.value),d==null||d(N)};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:N="Suelta los archivos aqui",emptyLabel:v="Arrastra y suelta archivos",emptyDescription:H="o haz click para buscarlos en tu equipo",selectedLabel:S="Archivos seleccionados",size:M="md",containerClassName:D="",dropzoneClassName:C="",fileListClassName:x="",className:$="",id:y,accept:P,disabled:j,required:U,...L}){const J=s.useId(),q=y??J,ae=s.useRef(null),[R,fe]=s.useState(!1),[I,K]=s.useState(i),ee=l??I,T=!!a,W=!!r&&n==="tooltip"&&!T,ie=p&&ee.length>0&&!j,B=(k,te)=>{l===void 0&&K(k),c==null||c(k,te)},re=(k,te)=>{const ue=k.filter(Ae=>cl(Ae,P)),oe=k.filter(Ae=>!cl(Ae,P)),ge=b?[...ee,...ue]:ue,Me=Lu(ge,u,h);oe.length>0&&(d==null||d(oe)),B(Me,te)},Z=()=>{var k;j||(k=ae.current)==null||k.click()},Y=k=>{re(Array.from(k.target.files??[]),k),k.target.value=""},se=k=>{k.preventDefault(),j||fe(!0)},E=k=>{k.currentTarget.contains(k.relatedTarget)||fe(!1)},Q=k=>{k.preventDefault(),fe(!1),!j&&re(Array.from(k.dataTransfer.files),k)},ce=k=>{k.key!=="Enter"&&k.key!==" "||(k.preventDefault(),Z())},X=k=>{B(ee.filter((te,ue)=>ue!==k))},w=()=>{B([])};return t.jsxs("div",{className:`flex flex-col gap-2 ${D}`,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(Hr,{content:r}):null,o&&t.jsx("span",{className:"ml-auto normal-case",children:o})]}),t.jsx("input",{...L,ref:ae,id:q,type:"file",accept:P,multiple:u,disabled:j,required:U&&ee.length===0,"aria-invalid":T||L["aria-invalid"],className:"sr-only",onChange:Y}),t.jsxs("div",{role:"button",tabIndex:j?-1:0,"aria-controls":q,"aria-disabled":j||void 0,"aria-invalid":T||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[M]} ${R?"border-[var(--primary)] bg-[var(--bg-input)]":T?"border-[var(--danger)]":"border-[var(--border)]"} ${j?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${C} ${$}`,onClick:Z,onDragOver:se,onDragLeave:E,onDrop:Q,onKeyDown:ce,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:R?N:v}),H&&t.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:H})]}),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&&ee.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:S}),ie&&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:w,children:t.jsx(z.HiTrash,{className:"h-4 w-4"})})]}),t.jsx("ul",{className:"divide-y divide-[var(--border)]",children:ee.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)})]}),!j&&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:()=>X(te),children:t.jsx(z.HiXMark,{className:"h-4 w-4"})})]},`${k.name}-${k.lastModified}-${te}`))})]}),t.jsx(Br,{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(M=>({key:!1,type:"",...M}))),[f,p]=s.useState(""),[g,N]=s.useState(""),v=s.useCallback((M,D)=>{b(C=>{const x=C.map(($,y)=>y===M?{...$,...D}:$);return u==null||u(x),x})},[u]),H=s.useCallback(()=>{d==null||d(h)},[h,d]),S=s.useCallback(()=>{var x;const M=f.trim();if(!M){N("Ingresa un nombre de campo.");return}if(h.some($=>$.name.toLowerCase()===M.toLowerCase())){N("Ese campo ya existe en el arreglo.");return}const C={name:M,key:!1,type:((x=n[0])==null?void 0:x.value)??""};b($=>{const y=[...$,C];return u==null||u(y),y}),p(""),N("")},[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((M,D)=>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:M.name}),t.jsx("div",{className:"flex justify-center",children:t.jsx(Fn,{size:"sm",checked:M.key??!1,onChange:C=>v(D,{key:C.target.checked}),"aria-label":`${M.name} es clave`})}),t.jsx(br,{value:M.type??"",onChange:C=>v(D,{type:C}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${M.name}`})]},M.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:M=>{p(M.currentTarget.value),g&&N("")},onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),S())},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(Ve,{variant:"secondary",onClick:S,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(Ve,{variant:"primary",onClick:H,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(Hr,{content:n}):null,l&&t.jsx("span",{className:"ml-auto normal-case",children:l})]}),t.jsx("span",{className:`block ${d}`,children:r}),t.jsx(Br,{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,Ir=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,r,n){const a=(n||"").trim();if(a)return a.replace(/[\r\n"]/g," ");const o=(r||"").trim();if(o&&/\.[a-z0-9]{2,5}$/i.test(o))return o.replace(/[\r\n"]/g," ");try{const i=new URL(e,"http://local.invalid").pathname.split("/").pop()||"";if(i&&/\.[a-z0-9]{2,5}$/i.test(i))return decodeURIComponent(i).replace(/[\r\n"]/g," ")}catch{}return o||"imagen"}async function qu(e){const r=ju(e.src,e.alt,e.downloadName);try{const n=await fetch(e.src,{credentials:"include",cache:"no-store"});if(!n.ok)throw new Error(`HTTP ${n.status}`);const a=await n.blob(),o=URL.createObjectURL(a),l=document.createElement("a");l.href=o,l.download=r,l.rel="noopener",document.body.appendChild(l),l.click(),l.remove(),window.setTimeout(()=>URL.revokeObjectURL(o),6e4)}catch{const n=document.createElement("a");n.href=e.src,n.download=r,n.target="_blank",n.rel="noopener",document.body.appendChild(n),n.click(),n.remove()}}function Uu(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 mr({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,showDownload:p=!0,loop:g=!0,showThumbnails:N=!0,zIndex:v=1100,ariaLabel:H="Visor de imagen"}){const[S,M]=s.useState(!1),[D,C]=s.useState(!1),[x,$]=s.useState(a??0),[y,P]=s.useState(1),[j,U]=s.useState({x:0,y:0}),[L,J]=s.useState({opacity:1,x:0,scale:1,blur:0,animate:!1}),[q,ae]=s.useState({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),[R,fe]=s.useState(!1),I=s.useRef(null),K=s.useRef(null),ee=s.useRef(null),T=s.useRef(null),W=s.useRef(null),ie=s.useRef(!1),B=s.useRef(!1),re=s.useRef(null),Z=s.useRef(null),Y=s.useRef(null),se=s.useRef(null),E=s.useRef(null),Q=s.useRef(a??0),ce=a??x,X=n.length===0?0:pn(ce,0,Math.max(0,n.length-1)),w=n[X],k=n.length>1,te=Math.max(c,i),ue=N&&k,oe=s.useCallback(me=>{if(n.length===0)return;const ye=n.length-1,Be=g?(me%n.length+n.length)%n.length:pn(me,0,ye);a===void 0&&$(Be),o==null||o(Be)},[a,g,o,n.length]),ge=s.useCallback(()=>{P(1),U({x:0,y:0})},[]),Me=s.useCallback((me,ye)=>{if(ye<=c+.001)return{x:0,y:0};const Be=se.current,_e=E.current;if(!Be||!_e)return me;const Ge=Be.getBoundingClientRect(),rt=_e.offsetWidth*ye,at=_e.offsetHeight*ye,Re=Math.max(0,(rt-Ge.width)/2+Ge.width*.15),st=Math.max(0,(at-Ge.height)/2+Ge.height*.15);return{x:pn(me.x,-Re,Re),y:pn(me.y,-st,st)}},[c]),Ae=s.useCallback(()=>{M(!1),ae({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),T.current=null,W.current=null,ie.current=!1,B.current=!1,re.current&&(clearTimeout(re.current),re.current=null)},[]),$t=s.useCallback(()=>{if(ie.current)return;ie.current=!0,C(!1),ge();const me=T.current,ye=me!=null&&W.current!=null&&W.current===X;if(me&&ye){ee.current!=null&&cancelAnimationFrame(ee.current),ee.current=requestAnimationFrame(()=>{ee.current=requestAnimationFrame(()=>{const Be=E.current;if(!Be){ee.current=null,I.current&&clearTimeout(I.current),I.current=setTimeout(Ae,It+40);return}const _e=Be.getBoundingClientRect(),Ge=ul(me,_e);ae({enabled:!0,dx:0,dy:0,scale:1,animate:!1}),ee.current=requestAnimationFrame(()=>{ae({enabled:!0,dx:Ge.dx,dy:Ge.dy,scale:Ge.scale,animate:!0}),ee.current=null})})}),I.current&&clearTimeout(I.current),I.current=setTimeout(Ae,Ir+80);return}ae({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),I.current&&clearTimeout(I.current),I.current=setTimeout(Ae,It+40)},[Ae,ge,X]);s.useEffect(()=>(e?(I.current&&clearTimeout(I.current),re.current&&(clearTimeout(re.current),re.current=null),ie.current=!1,B.current=!1,T.current=Uu(l),W.current=T.current!=null?a??x:null,M(!0),C(!1),T.current?ae({dx:0,dy:0,scale:1,animate:!1,enabled:!0}):(W.current=null,requestAnimationFrame(()=>requestAnimationFrame(()=>{C(!0),ae({dx:0,dy:0,scale:1,animate:!1,enabled:!1})})))):S&&$t(),()=>{I.current&&clearTimeout(I.current),ee.current!=null&&cancelAnimationFrame(ee.current)}),[e]);const mt=s.useCallback(()=>{if(!e||ie.current||B.current)return;const me=T.current,ye=E.current;if(!me||!ye){me||(C(!0),B.current=!0);return}const Be=ye.getBoundingClientRect();if(Be.width<2||Be.height<2)return;B.current=!0;const _e=ul(me,Be);ae({enabled:!0,dx:_e.dx,dy:_e.dy,scale:_e.scale,animate:!1}),ee.current!=null&&cancelAnimationFrame(ee.current),ee.current=requestAnimationFrame(()=>{ee.current=requestAnimationFrame(()=>{ae({enabled:!0,dx:0,dy:0,scale:1,animate:!0}),C(!0),ee.current=null,re.current&&clearTimeout(re.current),re.current=setTimeout(()=>{ae({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),re.current=null},Ir+20)})})},[e]);s.useLayoutEffect(()=>{!S||!e||!T.current||B.current||mt()},[S,e,mt]),s.useEffect(()=>{!e||ie.current||W.current!=null&&W.current!==X&&ae(me=>me.enabled?{dx:0,dy:0,scale:1,animate:!1,enabled:!1}:me)},[e,X]),s.useEffect(()=>{if(!e)return;const me=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=me}},[e]),s.useEffect(()=>{e&&ge()},[e,X,ge]),s.useEffect(()=>{a!==void 0&&$(a)},[a]),s.useEffect(()=>{if(!e){Q.current=X,J({opacity:1,x:0,scale:1,blur:0,animate:!1});return}const me=Q.current;if(me===X)return;Q.current=X;const ye=n.length;let Be=1;if(ye>1){const _e=(me+1)%ye===X,Ge=(me-1+ye)%ye===X;Ge&&!_e?Be=-1:_e&&!Ge?Be=1:Be=X>me?1:-1}return K.current!=null&&(cancelAnimationFrame(K.current),K.current=null),J({opacity:0,x:Be*56,scale:.94,blur:8,animate:!1}),K.current=requestAnimationFrame(()=>{K.current=requestAnimationFrame(()=>{J({opacity:1,x:0,scale:1,blur:0,animate:!0}),K.current=null})}),()=>{K.current!=null&&(cancelAnimationFrame(K.current),K.current=null)}},[e,X,n.length]);const gt=y<=c+.001&&Math.abs(j.x)<.5&&Math.abs(j.y)<.5,Qe=s.useCallback((me,ye,Be)=>{P(_e=>{const Ge=pn(me,c,te);if(Math.abs(Ge-_e)<1e-4)return _e;const rt=Ge/_e,at=Ge<_e;return Ge<=c+.001?(U({x:0,y:0}),c):(U(Re=>{let st=Re;if(typeof ye=="number"&&typeof Be=="number"&&se.current&&!at){const nt=se.current.getBoundingClientRect(),gr=ye-nt.left-nt.width/2,it=Be-nt.top-nt.height/2;st={x:gr-(gr-Re.x)*rt,y:it-(it-Re.y)*rt}}else if(at){st={x:Re.x*rt,y:Re.y*rt};const nt=Math.min(1,(_e-Ge)/Math.max(.01,_e-c));st={x:st.x*(1-nt*.65),y:st.y*(1-nt*.65)}}else st={x:Re.x*rt,y:Re.y*rt};return Me(st,Ge)}),Ge)})},[Me,c,te]),de=s.useCallback(()=>{Qe(y*d)},[Qe,y,d]),Te=s.useCallback(()=>{const me=Math.max(c,y/d);if(me<=c+.001){ge();return}P(me),U({x:0,y:0})},[c,ge,y,d]);s.useEffect(()=>{if(!e)return;const me=ye=>{if(ye.key==="Escape"&&h){ye.preventDefault(),r();return}ye.key==="ArrowLeft"&&k?(ye.preventDefault(),oe(X-1)):ye.key==="ArrowRight"&&k?(ye.preventDefault(),oe(X+1)):ye.key==="+"||ye.key==="="?(ye.preventDefault(),Qe(y*d)):ye.key==="-"||ye.key==="_"?(ye.preventDefault(),Te()):ye.key==="0"&&(ye.preventDefault(),ge())};return window.addEventListener("keydown",me),()=>window.removeEventListener("keydown",me)},[Qe,h,k,r,e,ge,X,y,oe,Te,d]);const ne=me=>{me.preventDefault();const ye=me.deltaY>0?1/d:d;Qe(y*ye,me.clientX,me.clientY)},He=me=>{y<=c+.001||(me.currentTarget.setPointerCapture(me.pointerId),fe(!0),Z.current={pointerId:me.pointerId,startX:me.clientX,startY:me.clientY,originX:j.x,originY:j.y})},ze=me=>{const ye=Z.current;!ye||ye.pointerId!==me.pointerId||U(Me({x:ye.originX+(me.clientX-ye.startX),y:ye.originY+(me.clientY-ye.startY)},y))},Ye=me=>{var ye;((ye=Z.current)==null?void 0:ye.pointerId)===me.pointerId&&(Z.current=null,fe(!1))},Xe=me=>{if(me.stopPropagation(),y>c+.05){ge();return}Qe(Math.min(te,3),me.clientX,me.clientY)},We=me=>{if(me.touches.length!==2)return;fe(!0);const[ye,Be]=[me.touches[0],me.touches[1]],_e=Math.hypot(ye.clientX-Be.clientX,ye.clientY-Be.clientY);Y.current={distance:_e,scale:y}},Je=me=>{if(me.touches.length!==2||!Y.current)return;me.preventDefault();const[ye,Be]=[me.touches[0],me.touches[1]],_e=Math.hypot(ye.clientX-Be.clientX,ye.clientY-Be.clientY),Ge=(ye.clientX+Be.clientX)/2,rt=(ye.clientY+Be.clientY)/2,at=Y.current.scale*(_e/Math.max(1,Y.current.distance));Qe(at,Ge,rt)},vt=()=>{Y.current=null,fe(!1)};if(!S||!w)return null;const ut=q.enabled,yt=q.animate?`transform ${Ir}ms ${Fu}`:"none";return ht.createPortal(t.jsxs("div",{className:"fixed inset-0",style:{zIndex:v},role:"dialog","aria-modal":"true","aria-label":H,children:[t.jsx("button",{type:"button","aria-label":"Cerrar",className:"absolute inset-0 border-0",style:{background:"color-mix(in srgb, var(--bg-sidebar, var(--primary)) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",opacity:D?1:0,transition:`opacity ${ut?Ir:It}ms ${jt}`,cursor:"default",zIndex:0},onClick:()=>{u&&r()}}),t.jsx("div",{ref:se,className:"absolute inset-0 flex items-center justify-center",style:{zIndex:1,padding:ue?"4.5rem 3.5rem 6.5rem":"4.5rem 3.5rem 2.5rem",opacity:ut||D?1:0,transform:ut||D?"translateY(0) scale(1)":"translateY(10px) scale(0.96)",transition:ut?"none":`opacity ${It}ms ${jt}, transform ${It}ms ${jt}`},onClick:me=>{me.target===me.currentTarget&&u&&r()},onWheel:ne,children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{transform:q.enabled?`translate3d(${q.dx}px, ${q.dy}px, 0) scale(${q.scale})`:void 0,transformOrigin:"center center",transition:q.enabled?yt:void 0},children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{opacity:L.opacity,filter:L.blur?`blur(${L.blur}px)`:"blur(0px)",transform:`translate3d(${L.x}px, 0, 0) scale(${L.scale})`,transition:L.animate?[`opacity ${xo}ms ${wo}`,`transform ${xo}ms ${wo}`,`filter ${xo}ms ${wo}`].join(", "):"none"},children:t.jsx("div",{ref:E,className:"pointer-events-auto relative max-h-full max-w-full touch-none select-none will-change-transform",style:{cursor:y>c+.001?"grab":"zoom-in",transform:`translate3d(${j.x}px, ${j.y}px, 0) scale(${y})`,transformOrigin:"center center",transition:R?"none":`transform 220ms ${Iu}`},onClick:me=>me.stopPropagation(),onDoubleClick:Xe,onPointerDown:He,onPointerMove:ze,onPointerUp:Ye,onPointerCancel:Ye,onTouchStart:We,onTouchMove:Je,onTouchEnd:vt,children:t.jsx("img",{src:w.src,alt:w.alt||"",draggable:!1,className:"block max-h-[min(78vh,820px)] max-w-[min(86vw,1100px)] object-contain",style:{display:"block",borderRadius:ko,imageRendering:y>2.5?"pixelated":"auto"},onLoad:()=>{mt()}},w.src+String(X))})})})}),t.jsxs("div",{className:"pointer-events-none absolute inset-0",style:{zIndex:2,opacity:D?1:0,transform:D?"translateY(0)":"translateY(-6px)",transition:`opacity ${ut?Ir:It}ms ${jt}, transform ${ut?Ir: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:[X+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(mr,{label:"Alejar",onClick:Te,disabled:y<=c+.001,children:t.jsx(z.HiMinus,{className:"h-5 w-5"})}),t.jsx(mr,{label:"Restablecer tamaño",onClick:ge,disabled:gt,children:t.jsx(z.HiArrowsPointingIn,{className:"h-5 w-5"})}),t.jsx(mr,{label:"Acercar",onClick:de,disabled:y>=te-.001,children:t.jsx(z.HiPlus,{className:"h-5 w-5"})})]}):null,p&&(w!=null&&w.src)?t.jsx(mr,{label:"Descargar",onClick:()=>{qu(w)},children:t.jsx(z.HiArrowDownTray,{className:"h-5 w-5"})}):null,t.jsx(mr,{label:"Cerrar",onClick:r,children:t.jsx(z.HiXMark,{className:"h-5 w-5"})})]})]}),k?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"pointer-events-auto absolute left-3 top-1/2",style:{opacity:D?1:0,transform:D?"translate(0, -50%)":"translate(-8px, -50%)",transition:`opacity ${It}ms ${jt}, transform ${It}ms ${jt}`},children:t.jsx(mr,{label:"Anterior",size:"lg",onClick:()=>oe(X-1),disabled:!g&&X<=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:D?1:0,transform:D?"translate(0, -50%)":"translate(8px, -50%)",transition:`opacity ${It}ms ${jt}, transform ${It}ms ${jt}`},children:t.jsx(mr,{label:"Siguiente",size:"lg",onClick:()=>oe(X+1),disabled:!g&&X>=n.length-1,children:t.jsx(z.HiChevronRight,{className:"h-6 w-6"})})})]}):null,ue?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((me,ye)=>{const Be=ye===X;return t.jsx("button",{type:"button",role:"tab","aria-selected":Be,"aria-label":me.alt||`Imagen ${ye+1}`,onClick:_e=>{_e.stopPropagation(),oe(ye)},className:"relative shrink-0 overflow-hidden transition-opacity",style:{width:56,height:42,borderRadius:ko,opacity:Be?1:.42,transition:`opacity 180ms ${jt}`},children:t.jsx("img",{src:me.src,alt:"",draggable:!1,className:"h-full w-full object-cover",style:{borderRadius:ko}})},`${me.src}-${ye}`)})})}):null]})]}),document.body)}function Vu({children:e,className:r,style:n,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c,showDownload:d,zIndex:u}){const[h,b]=s.useState(!1),[f,p]=s.useState(0),[g,N]=s.useState([]),[v,H]=s.useState(null),S=s.useCallback((D,C,x)=>{N(D),H(x??null),p(C),b(!0)},[]),M=s.useCallback(D=>{dl(D,S)},[S]);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:h,onClose:()=>b(!1),index:f,onIndexChange:p,slides:g,originRect:v,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c,showDownload:d,zIndex:u})]})}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 Xu(e,r){if(!r)return!0;const n=Co(r);return Co(e.label).includes(n)||!!(e.sublabel&&Co(e.sublabel).includes(n))}function Yu({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:N="Limpiar seleccion",pruneMissingValues:v=!0}){const[H,S]=s.useState(!1),[M,D]=s.useState(""),[C,x]=s.useState(0),[$,y]=s.useState(!1),[P,j]=s.useState({}),U=s.useRef(null),L=s.useRef(null),J=s.useRef(null),q=s.useRef(null),ae=u&&n.length>=h,R=s.useMemo(()=>new Set(e),[e]),fe=s.useMemo(()=>{const w=new Map;for(const k of n)w.set(k.value,k);return w},[n]),I=s.useMemo(()=>{const w=[];for(const k of e){const te=fe.get(k);te&&w.push(te)}return w},[fe,e]),K=b==="all"?I.length:b,ee=I.slice(0,K),T=Math.max(0,I.length-ee.length),W=p&&I.length>1,ie=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:[I.length," seleccionados"]}),t.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:I.map(w=>t.jsxs("li",{className:"flex min-w-0 items-baseline gap-1.5 text-xs",style:{color:"var(--text-main)"},children:[w.color&&t.jsx("span",{className:"mt-1 h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:w.color}}),t.jsx("span",{className:"min-w-0 break-words font-medium",children:w.label}),w.sublabel?t.jsx("span",{className:"min-w-0 break-words",style:{color:"var(--text-muted)"},children:w.sublabel}):null]},w.value))})]}),B=s.useMemo(()=>{const w=M.trim();return!ae||!w?n:n.filter(k=>Xu(k,w))},[n,M,ae]),re=s.useCallback(()=>{const w=U.current;if(!w)return;const k=w.getBoundingClientRect(),te=ae?304:244,ue=window.innerHeight-k.bottom,oe=ue<te&&k.top>ue;j({position:"fixed",left:k.left,top:oe?void 0:k.bottom+4,bottom:oe?window.innerHeight-k.top+4:void 0,width:Math.max(k.width,240),zIndex:9999})},[ae]),Z=s.useCallback(w=>{hl(e,w)||r(w)},[r,e]),Y=s.useCallback(w=>{const k=fe.get(w);if(k!=null&&k.disabled)return;const te=R.has(w)?e.filter(ue=>ue!==w):[...e,w];Z(te)},[Z,fe,e,R]),se=s.useCallback(()=>Z([]),[Z]),E=s.useCallback(()=>{S(!1),D(""),x(0)},[]);s.useEffect(()=>y(!0),[]);const Q=s.useMemo(()=>n.map(w=>w.value).join("\0"),[n]);s.useEffect(()=>{if(!v||e.length===0||n.length===0)return;const w=new Set(n.map(te=>te.value)),k=e.filter(te=>w.has(te));hl(e,k)||r(k)},[Q]),s.useEffect(()=>{if(!H)return;function w(k){var ue,oe;const te=k.target;!((ue=U.current)!=null&&ue.contains(te))&&!((oe=L.current)!=null&&oe.contains(te))&&E()}return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[E,H]),s.useEffect(()=>{H&&(x(0),re(),ae&&setTimeout(()=>{var w;return(w=J.current)==null?void 0:w.focus()},0))},[H,ae,re]),s.useEffect(()=>{if(H)return window.addEventListener("resize",re),window.addEventListener("scroll",re,!0),()=>{window.removeEventListener("resize",re),window.removeEventListener("scroll",re,!0)}},[H,re]),s.useEffect(()=>{if(B.length===0){x(0);return}x(w=>Math.min(w,B.length-1))},[B.length]),s.useEffect(()=>{if(C<0||!q.current)return;const w=q.current.children[C];w==null||w.scrollIntoView({block:"nearest"})},[C]);function ce(w){if(!o){if(!H){(w.key==="Enter"||w.key===" "||w.key==="ArrowDown")&&(w.preventDefault(),S(!0));return}if(w.key==="Escape"){w.preventDefault(),E();return}if(w.key==="ArrowDown"){if(w.preventDefault(),B.length===0)return;x(k=>Math.min(k+1,B.length-1));return}if(w.key==="ArrowUp"){w.preventDefault(),x(k=>Math.max(k-1,0));return}if(w.key==="Enter"&&B[C]&&!B[C].disabled){w.preventDefault(),Y(B[C].value);return}w.key==="Backspace"&&!M&&e.length&&(w.preventDefault(),Z(e.slice(0,-1)))}}const X=t.jsxs("div",{ref:L,className:"overflow-hidden rounded-xl shadow-xl",style:{...P,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[ae&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(z.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:J,value:M,onChange:w=>{D(w.target.value),x(0)},onKeyDown:w=>{(w.key==="ArrowDown"||w.key==="ArrowUp"||w.key==="Enter"||w.key==="Escape")&&(w.stopPropagation(),ce(w))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),M&&t.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:w=>{w.preventDefault(),D(""),x(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:[I.length," seleccionados",e.length>I.length?` (${e.length-I.length} no disponibles)`:""]}),t.jsx("button",{type:"button",onMouseDown:w=>{w.preventDefault(),se()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:N})]}),t.jsxs("ul",{ref:q,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:ae?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[B.map((w,k)=>{const te=k===C,ue=R.has(w.value);return t.jsxs("li",{role:"option","aria-selected":ue,onMouseDown:oe=>{oe.preventDefault(),!w.disabled&&Y(w.value)},onMouseEnter:()=>!w.disabled&&x(k),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:w.disabled?"var(--text-muted)":"var(--text-main)",cursor:w.disabled?"not-allowed":"pointer",opacity:w.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(z.HiCheck,{className:"h-3 w-3"})}),w.color&&t.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:w.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:w.label}),w.sublabel&&t.jsx(Yt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:w.sublabel})]}),w.badge&&t.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:w.badge})]},w.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:ce,children:[t.jsxs("button",{type:"button",disabled:o,onClick:()=>{o||(H?E():S(!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:I.length?"var(--text-main)":"var(--text-muted)",border:H?"1px solid var(--primary)":"1px solid var(--border)",opacity:o?.5:1,cursor:o?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":H,children:[t.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:ee.length?(()=>{const w=t.jsxs(t.Fragment,{children:[ee.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(),Y(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)),T>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":`${T} seleccionados más`,children:["+",T]})]});return W?t.jsx(Pt,{as:"span",content:ie,placement:"bottom",followCursor:!1,className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:w}):w})():t.jsx("span",{className:"truncate",children:a})}),I.length?t.jsx("span",{role:"button",tabIndex:-1,"aria-label":N,onMouseDown:w=>{w.preventDefault(),w.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:H?"rotate(180deg)":"rotate(0deg)"}})]}),H&&$&&ht.createPortal(X,document.body)]})}function Gu({inputMode:e="decimal",...r}){return t.jsx(yo,{...r,type:"number",inputMode:e})}function Ku(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 Zu({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=Ku(c,i,o);return t.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[t.jsx(Ve,{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(Ve,{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 Qu(e){return typeof e=="number"?`${e}px`:e}function Ju({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:N="",countryCodeWidth:v=84,onPhoneValueChange:H,label:S,containerClassName:M="",helperText:D,helperDisplay:C="inline",labelAction:x,className:$="",required:y,disabled:P,floatingLabel:j,showPasswordToggle:U,nativeValidation:L,errorTooltipLabel:J="Error de validacion",...q}){var k;const[ae,R]=s.useState(()=>pl(c)),[fe,I]=s.useState(()=>Jn(h)),K=s.useMemo(()=>{const te=p??ml,ue=f==null?void 0:f.map(Jn);return ue!=null&&ue.length?te.filter(oe=>ue.includes(oe.value)):te},[f,p]),ee=((k=K[0])==null?void 0:k.value)??"+1",T=K.some(te=>te.value===Jn(u??fe))?Jn(u??fe):ee,W=i!==void 0?pl(i):ae,ie=`${T} ${W}`.trim(),B=n&&W.length>0&&!go(ie)?a:void 0,re=l??B,Z=!!re,Y=Z&&o!=="tooltip",se=Z&&o!=="inline",E=!!D&&C==="tooltip"&&!Y,Q=Z?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",ce=te=>{const ue=te.currentTarget.value;i===void 0&&R(ue),H==null||H(ue,{countryCode:T,nationalNumber:ue,fullNumber:`${T} ${ue}`.trim()}),d==null||d(te)},X=te=>{u===void 0&&I(te),b==null||b(te),H==null||H(W,{countryCode:te,nationalNumber:W,fullNumber:`${te} ${W}`.trim()})},w=se?t.jsx(Pt,{as:"span",content:re,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":J,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 ${M}`,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:S}),y&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),E?t.jsx(Hr,{content:D}):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 ${Q}`,children:[t.jsx(br,{value:T,onChange:X,options:K,placeholder:g,disabled:P,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${N}`,style:{width:Qu(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",{...q,value:i,defaultValue:c,type:"tel",inputMode:r,autoComplete:e,disabled:P,required:void 0,"aria-label":q["aria-label"]??(typeof S=="string"?S:void 0),"aria-invalid":Z||q["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":""} ${$}`,onChange:ce}),w]})]}),t.jsx(Br,{error:Y?re:void 0,helperText:D,helperDisplay:C})]})}function Ru({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 ef='<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>',tf='<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">${ef}${tf}</button>`}const rf=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`
23
+ </body></html>`,we=window.open("","_blank");we&&(we.document.write(be),we.document.close())}const qa=()=>!gt||!Mn?null:ht.createPortal(t.jsxs("div",{ref:Ro,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...zh,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():gm(),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()=>(Te?await Te():vm(),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&&Fe.trim().length>0,A=ge!=null&&ge.length?ge:m?[{key:"bql",label:"BQL",value:Fe}]:[],V=oe.filter(D=>{const le=D.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&&!gt?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:Rh,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(Ke){wt(!1);return}Ha(),wt(!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:Ke?"var(--primary)":m?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:Ke||m?"var(--primary)":"var(--border)",color:Ke?"var(--primary-fg)":"var(--primary)"},"aria-expanded":Ke,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"}),Ke?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:w}),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(D=>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:[D.label,":"]}),t.jsx("span",{className:"truncate",children:D.value})]},D.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"})}),Ke&&ht.createPortal(t.jsxs("div",{ref:qi,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...Ih,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(D=>t.jsxs("button",{type:"button",onMouseDown:le=>{le.preventDefault(),le.stopPropagation()},onClick:le=>{le.preventDefault(),le.stopPropagation(),Oa(D.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:[D.icon,D.label]},D.label)),ue.length>0&&t.jsxs("button",{type:"button",onClick:()=>Nt(D=>!D),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(D=>!D),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":xr,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 ${Me?"var(--danger)":m?"var(--primary)":"var(--border)"}`},children:[t.jsx("textarea",{ref:Jo,value:Pe,rows:3,onChange:D=>as(D.target.value,D.target),onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),Ri(Pe)),D.key==="Escape"&&wt(!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"}}),V.length>0&&t.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:V.map(D=>t.jsx("button",{type:"button",onMouseDown:le=>{le.preventDefault(),le.stopPropagation()},onClick:le=>{le.preventDefault(),le.stopPropagation(),Oa(D)},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:D},D))})]}),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:Me?"var(--danger)":"var(--text-muted)"},children:Me??(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(D=>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:[D.label,":"]}),t.jsx("span",{className:"truncate",children:D.value})]},D.key))]}),xr&&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(D=>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(D)},className:"min-w-0 flex-1 text-left",children:t.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:D})}),t.jsx("button",{type:"button",onClick:()=>Zr(le=>le.filter(be=>be!==D)),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"})})]},D))]}),Zt&&ue.length>0&&t.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:ue.map(D=>t.jsxs("button",{type:"button",onMouseDown:le=>{le.preventDefault(),le.stopPropagation()},onClick:le=>{le.preventDefault(),le.stopPropagation(),Oa(D.bql),Nt(!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:D.bql}),D.description&&t.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:D.description})]},D.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)]})]}),gt&&t.jsx("button",{ref:Ma,type:"button","aria-haspopup":"menu","aria-expanded":Mn,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var le;const D=(le=Ma.current)==null?void 0:le.getBoundingClientRect();D&&Wh({top:D.bottom+4,right:window.innerWidth-D.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&&nt==="visibility","aria-label":se,title:se,onClick:D=>rc(D,"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&&nt==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(z.HiCog6Tooth,{className:"h-4 w-4"})})]})},pc=()=>{if(!fm)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 ${j?"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":`${bm}–${hm} 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=>mm(Number(A)),options:ss.map(A=>({value:String(A),label:String(A)})),placeholder:"Filas",searchable:!1,disabled:a,height:W,padding:U,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:P}})]})]}),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:D=>{D.currentTarget.disabled||A===bt||(D.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",D.currentTarget.style.color="var(--primary)")},onMouseLeave:D=>{D.currentTarget.style.background=A===bt?"var(--primary)":"transparent",D.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"})]})},ym=()=>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:v?{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 ${je}`},children:[_t&&t.jsx("div",{role:"cell",className:`${j?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${je}`,borderRight:`1px solid ${je}`}},"select-cell"),Dt.map((V,D)=>t.jsx("div",{role:"cell",className:j?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${je}`,borderRight:`1px solid ${je}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${Yi(A,D)}%`,minWidth:32}})},V.key))]},A))})]})})]}),hs="min-w-0 max-w-full overflow-hidden";return R&&He&&!Je?t.jsx(In,{rows:o,columns:Math.max(4,Dt.length||7)}):!a&&r.length===0&&!es?ym():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:v?{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 ${je}`},children:[_t&&t.jsx("div",{role:"cell",className:`${j?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${je}`,borderRight:`1px solid ${je}`}},"select-cell"),Dt.map((V,D)=>{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:j?"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 ${je}`:`inset 0 -1px 0 ${je}`,borderRight:`1px solid ${je}`}:{borderBottom:`1px solid ${je}`,borderRight:`1px solid ${je}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${Yi(A,D)}%`,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:v?{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:je,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:v?{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),D=fc(C==null?void 0:C(m)),le=A>0?fc(C==null?void 0:C(lc[A-1])):null,be=D&&D.key!==(le==null?void 0:le.key),we=_t&&k.has(V),$e=_t&&(!S||S(m)),ve=rn?(h==null?void 0:h(m))??!0:!1,Ie=ve&&oc.has(V),De=!!d||y&&ve,Ue=we&&$?"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 ${D.className??""}`,style:{gridTemplateColumns:nn},children:t.jsx("div",{role:"cell",className:j?"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 ${je}`,borderRight:`1px solid ${je}`},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:D.label}),D.description&&t.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:D.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(y&&ve){ic(V);return}d==null||d(m)}}:void 0,className:`grid transition-colors ${De?"cursor-pointer":""} ${O?O(m):""}`,style:{gridTemplateColumns:nn,"--dt-row-bg":Ue,"--dt-sticky-bg":Ue,background:"var(--dt-row-bg)",borderBottom:`1px solid ${je}`},onMouseEnter:xe=>{we||(xe.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),xe.currentTarget.style.setProperty("--dt-sticky-bg",pm))},onMouseLeave:xe=>{xe.currentTarget.style.setProperty("--dt-row-bg",Ue),xe.currentTarget.style.setProperty("--dt-sticky-bg",Ue)},children:[rn&&t.jsx("div",{role:"cell",className:`${j?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${je}`,borderRight:`1px solid ${je}`},"data-dt-disable-row-click":"true",children:ve&&t.jsx("button",{type:"button","aria-label":Ie?"Contraer fila":"Desplegar fila","aria-expanded":Ie,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:Ie?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:`${j?"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 ${je}`}:{borderBottom:`1px solid ${je}`,borderRight:`1px solid ${je}`},onClick:xe=>{xe.stopPropagation(),$e&&g(V)},children:t.jsx(Fn,{size:"sm",checked:we,disabled:!$e,"aria-label":$e?"Seleccionar fila":"Fila no seleccionable",containerClassName:"items-center",className:$e?"cursor-pointer":"cursor-not-allowed opacity-50",onClick:xe=>xe.stopPropagation(),onChange:()=>{$e&&g(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":`${j?"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 ${je}`:`inset 0 -1px 0 ${je}`,borderRight:`1px solid ${je}`}:{borderBottom:`1px solid ${je}`,borderRight:`1px solid ${je}`}},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)})]}),Ie&&u&&t.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:nn},children:t.jsx("div",{role:"cell",className:j?"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 ${je}`},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 Dr(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=Dr(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=Dr(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=Dr(o.start);const i=Dr(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=Dr(r[0]),o=Dr(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)),y=Math.max(1,p-f+1);let k=l.findIndex(g=>g<f);k<0?(k=l.length,l.push(f+y-1)):l[k]=f+y-1,i.push({item:d,lane:k,colStart:f,colSpan:y})}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:y,renderWeekBar:k,tableColumns:g,tableProps:H,onItemClick:S,onDayClick:$,loading:O=!1,emptyTitle:C="Sin eventos",emptyDescription:v="No hay eventos para los filtros seleccionados.",legend:T,legendInteractive:x=!0,activeLegendKeys:P,defaultActiveLegendKeys:W,onActiveLegendKeysChange:U,getItemLegendKey:L,overloadLabel:J="Sobrecarga de eventos",notice:q,showOverload:re=!0,layout:R="span",className:fe="",showToolbar:ee=!0}){const j=h??(b?[...qs]:[...xd]),Z=b?5:7,M=b?"grid grid-cols-5":"grid grid-cols-7",_=s.useMemo(()=>(T??[]).map(de=>de.label),[T]),[ce,B]=s.useState(()=>W??_),ne=s.useMemo(()=>P??(_.length>0?ce:[]),[P,_.length,ce]),K=s.useMemo(()=>new Set(ne),[ne]),Y=de=>{P===void 0&&B(de),U==null||U(de)},se=de=>{x&&(K.has(de)?Y(ne.filter(Te=>Te!==de)):Y([...ne,de]))},E=s.useMemo(()=>{if(!x||_.length===0)return e;const de=new Set(_);return e.filter(Te=>{const ae=(L==null?void 0:L(Te))??Te.status;return!ae||!de.has(ae)?!0:K.has(ae)})},[e,x,_,K,L]),Q=s.useMemo(()=>zs(E,c),[E,c]),ie=s.useMemo(()=>{const de=ao(r);return b?Vn(de):de},[r,b]),X=s.useMemo(()=>{const de=ao(r);return b?Ps(de):oo(de)},[r,b]),w=s.useMemo(()=>b?_s(r):no(r),[r,b]),N=zt(r),te=Q[N]??[],ue=s.useMemo(()=>so(E,w,c),[E,w,c]),oe=s.useMemo(()=>ue.length===0?1:Math.max(...ue.map(de=>de.lane))+1,[ue]),ge=s.useMemo(()=>X.map(de=>{const Te=so(E,de,c),ae=Te.length===0?0:Math.max(...Te.map(He=>He.lane))+1;return{days:de,bars:Te,laneCount:ae}}),[X,E,c]),Me=36,Ae=38,$t=s.useMemo(()=>{const de=l==="month"?ie:l==="week"?w:[r],Te=[];for(const ae of de){const He=zt(ae),ze=Q[He]??[];ze.length>=u&&Te.push([ae,ze])}return Te},[l,ie,w,r,Q,u]),mt=l==="month"?vd(r):l==="week"?`${Ht(w[0])} – ${Ht(w[6])}`:yd(r),gt=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 Te=nr(de,c);return Te?`${Ht(Te.start)} → ${Ht(Te.end)}`:"—"}},{key:"subtitle",header:"Detalle",cell:de=>de.subtitle??"—"}],[c]),Qe=de=>{if(n(de),$){$(de);return}i("day")};return t.jsxs("div",{className:`bonsaif-event-calendar space-y-4 ${fe}`.trim(),children:[ee?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:mt}),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:x?"group":void 0,"aria-label":x?"Filtrar por estado":void 0,children:T.map(de=>{const Te=K.has(de.label);return x?t.jsxs("button",{type:"button","aria-pressed":Te,onClick:()=>se(de.label),className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 transition-opacity",style:{color:Te?"var(--text-main)":"var(--text-muted)",background:Te?"color-mix(in srgb, var(--bg-card) 80%, transparent)":"transparent",border:Te?`1px solid color-mix(in srgb, ${de.color} 55%, var(--border))`:"1px solid var(--border)",opacity:Te?1:.45},title:Te?`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:Te?`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"&&q&&q.items.length>0?t.jsxs("div",{className:"rounded-lg px-4 py-3 text-sm",style:q.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:[q.label,":"]})," ",q.items.join(", ")]}):a==="calendar"&&re&&$t.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:[J,":"]})," ",$t.map(([de,Te])=>`${Ht(de)} (${Te.length})`).join(", ")]}):null,a==="table"?O||E.length>0?t.jsx(ro,{columns:g??gt,data:E,getRowId:de=>de.id,loading:O,skeletonRows:8,emptyIcon:t.jsx(z.HiCalendarDays,{className:"h-10 w-10"}),emptyText:v,onRowClick:S,pageSize:25,compact:!0,...H}):t.jsx(Un,{icon:t.jsx(z.HiCalendarDays,{className:"h-5 w-5"}),title:C,description:v}):null,a==="calendar"&&l==="month"&&R==="daily"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{className:M,style:{borderBottom:"1px solid var(--border)"},children:j.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:M,children:ie.map(de=>{const Te=zt(de),ae=Q[Te]??[],He=de.getMonth()!==r.getMonth(),ze=Math.max(0,ae.length-d);return t.jsxs("div",{role:"button",tabIndex:0,"aria-label":`${de.getDate()}`,onClick:()=>Qe(de),onKeyDown:Ye=>{(Ye.key==="Enter"||Ye.key===" ")&&(Ye.preventDefault(),Qe(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:He?"var(--text-muted)":"var(--text-main)"},children:de.getDate()}),ae.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:ae.length}):null]}),t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[ae.slice(0,d).map(Ye=>t.jsx(Us,{item:Ye,day:de,renderPill:p,onClick:()=>S==null?void 0:S(Ye)},Ye.id)),ze>0?t.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-muted)"},children:["+",ze," más"]}):null]})]},Te)})})]}):null,a==="calendar"&&l==="month"&&R==="span"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{className:M,style:{borderBottom:"1px solid var(--border)"},children:j.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:Te,laneCount:ae},He)=>{const ze=Math.min(ae,d),Ye=Math.max(0,ae-d),Xe=Me+Math.max(1,ze)*Ae+(Ye>0?20:8)+8;return t.jsxs("div",{className:"relative",style:{minHeight:Xe,borderBottom:He<ge.length-1?"1px solid var(--border)":void 0},children:[t.jsx("div",{className:M,style:{minHeight:Xe},children:de.map(We=>{const Je=zt(We),vt=Q[Je]??[],ft=We.getMonth()!==r.getMonth();return t.jsx("div",{role:"button",tabIndex:0,"aria-label":`${We.getDate()}`,onClick:()=>Qe(We),onKeyDown:yt=>{(yt.key==="Enter"||yt.key===" ")&&(yt.preventDefault(),Qe(We))},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:Xe},children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-sm font-semibold",style:{color:ft?"var(--text-muted)":"var(--text-main)"},children:We.getDate()}),vt.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:vt.length}):null]})},Je)})}),t.jsxs("div",{className:"pointer-events-none absolute inset-x-0",style:{top:Me,bottom:4},children:[Te.filter(We=>We.lane<d).map(We=>{const Je={left:`calc(${We.colStart/Z*100}% + 4px)`,width:`calc(${We.colSpan/Z*100}% - 8px)`,top:2+We.lane*Ae,height:Ae-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(We.item,{day:de[We.colStart]})})},`${We.item.id}-${We.colStart}-${He}`):k?t.jsx("div",{className:"absolute overflow-hidden",style:Je,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:k(We.item)})},`${We.item.id}-${We.colStart}-${He}`):t.jsx(wd,{item:We.item,style:Je,onClick:()=>S==null?void 0:S(We.item)},`${We.item.id}-${We.colStart}-${He}`)}),Ye>0?t.jsxs("span",{className:"absolute text-[11px] font-semibold",style:{left:8,top:2+ze*Ae,color:"var(--text-muted)"},children:["+",Ye," más"]}):null]})]},`week-${He}-${zt(de[0])}`)})]}):null,a==="calendar"&&l==="week"&&R==="daily"?t.jsx("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)"},children:t.jsx("div",{className:M,children:w.map(de=>{const Te=zt(de),ae=Q[Te]??[],He=Math.max(0,ae.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:()=>Qe(de),children:[Ws(de),t.jsx("span",{className:"mt-1 block text-sm",children:de.getDate()})]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[ae.slice(0,d).map(ze=>t.jsx(Us,{item:ze,day:de,renderPill:p,onClick:()=>S==null?void 0:S(ze)},ze.id)),He>0?t.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-muted)"},children:["+",He," más"]}):null]})]},Te)})})}):null,a==="calendar"&&l==="week"&&R==="span"?t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-card)",border:"1px solid var(--border)"},children:[t.jsx("div",{className:`${M} border-b`,style:{borderColor:"var(--border)"},children:w.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:()=>Qe(de),children:Ws(de)},zt(de)))}),t.jsxs("div",{className:`relative ${M}`,style:{minHeight:Math.max(220,oe*56+24)},children:[w.map(de=>t.jsx("div",{className:"min-h-full",style:{borderRight:"1px solid var(--border)"}},`lane-${zt(de)}`)),ue.map(de=>{const Te={left:`calc(${de.colStart/Z*100}% + 4px)`,width:`calc(${de.colSpan/Z*100}% - 8px)`,top:12+de.lane*56,height:48};return k?t.jsx("div",{className:"absolute overflow-hidden",style:Te,children:t.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:k(de.item)})},`${de.item.id}-${de.colStart}`):t.jsx(kd,{item:de.item,style:Te,onClick:()=>S==null?void 0:S(de.item)},`${de.item.id}-${de.colStart}`)}),ue.length===0&&!O?t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:v}):null]})]}):null,a==="calendar"&&l==="day"?te.length>0||O?t.jsxs("div",{className:"space-y-3",children:[O&&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(de=>y?t.jsx("div",{children:y(de)},de.id):t.jsx(Nd,{item:de,onClick:()=>S==null?void 0:S(de)},de.id))]}):t.jsx(Un,{icon:t.jsx(z.HiCalendarDays,{className:"h-5 w-5"}),title:C,description:v}):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:y="button",...k}){const[g,H]=s.useState(!1),S=s.useRef(null);s.useEffect(()=>()=>{S.current&&window.clearTimeout(S.current)},[]);function $(C){H(!0),d==null||d(C),S.current&&window.clearTimeout(S.current),S.current=window.setTimeout(()=>{H(!1),S.current=null},r)}async function O(C){if(c&&C.stopPropagation(),p==null||p(C),C.defaultPrevented)return;const v=Ed(e);if(v)try{await lo(v),$(v)}catch(T){u==null||u(T,v)}}return t.jsxs("button",{...k,type:y,onClick:O,title:g?a:n,"aria-label":k["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 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:y="center",bodyClassName:k="px-6 py-5",panelClassName:g="",backdropClassName:H=Ld,contentClassName:S="p-4",ariaLabel:$,frameless:O=!1,disabled:C=!1}){const[v,T]=s.useState(!1),[x,P]=s.useState(!1),W=s.useRef(null);if(s.useEffect(()=>(e?(W.current&&clearTimeout(W.current),T(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>P(!0)))):(P(!1),W.current=setTimeout(()=>T(!1),Yn+40)),()=>{W.current&&clearTimeout(W.current)}),[e]),s.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),s.useEffect(()=>{if(!e||!f)return;const R=fe=>{fe.key==="Escape"&&r()};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[f,r,e]),!v)return null;const U=n||a||o||l||p,L=u??Ad[d],J=y==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",q=y==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",re=x?"translateY(0) scale(1)":y==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return ht.createPortal(t.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":$??n,className:`fixed inset-0 flex ${J} ${S}`,style:{zIndex:h},children:[t.jsx("div",{className:`absolute inset-0 ${H}`,onClick:b?r:void 0,style:{opacity:x?1:0,transition:`opacity ${Yn}ms ease`}}),t.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${O?"shadow-none":"shadow-2xl"} ${q} ${g}`,style:{maxWidth:L,background:O?"transparent":"var(--bg-card)",border:O?"none":"1px solid var(--border)",opacity:x?1:0,transform:re,transition:`opacity ${Yn}ms ease, transform ${Yn}ms ease`},onClick:R=>R.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(Ve,{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 ${k}`,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(Ve,{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(Ve,{variant:"secondary",onClick:d,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:o}),t.jsx(Ve,{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[y,k]=s.useState({}),[g,H]=s.useState(null),S=s.useRef(null);S.current=g;const[$,O]=s.useState({}),[C,v]=s.useState({}),T=s.useRef(new Set),x=s.useRef(null);s.useEffect(()=>{var _;const M=document.activeElement;(!M||M===document.body)&&((_=x.current)==null||_.focus({preventScroll:!0}))},[]);const P=e.map(M=>{var _,ce,B;return`${M.key}:${((B=(ce=(_=M.editable)==null?void 0:_.select)==null?void 0:ce.options)==null?void 0:B.length)??-1}`}).join("|");s.useEffect(()=>{e.forEach(M=>{var B,ne;const _=(ne=(B=M.editable)==null?void 0:B.select)==null?void 0:ne.options;if(!_)return;const ce=$[M.key];(!T.current.has(M.key)||(ce==null?void 0:ce.length)===0&&_.length>0)&&(T.current.add(M.key),O(K=>({...K,[M.key]:_})))})},[P]);const W=s.useCallback(async(M,_)=>{if(T.current.has(M))return;T.current.add(M);const{url:ce,fetchOptions:B}=_.select??{};if(!(!ce&&!B)){v(ne=>({...ne,[M]:!0}));try{let ne=[];if(B)ne=await B();else if(ce){const K=await fetch(ce);if(!K.ok)throw new Error("fetch failed");ne=await K.json()}O(K=>({...K,[M]:ne}))}catch{O(ne=>({...ne,[M]:[]}))}finally{v(ne=>({...ne,[M]:!1}))}}},[]),U=s.useRef(i);U.current=i;const L=s.useRef(a);L.current=a;const J=s.useRef(n);J.current=n;const q=s.useRef(e);q.current=e;const re=s.useRef(o);re.current=o,s.useEffect(()=>{if(e.length>0&&r.length>0){const M=e.find(_=>_.selectable!==!1);M&&f({rowId:n(r[0]),colKey:M.key})}},[]),s.useEffect(()=>{if(!b)return;const M=x.current;if(!M)return;const _=M.querySelector(`[data-cell-id="${b.rowId}:${b.colKey}"]`);if(!_)return;const ce=M.querySelector('[role="rowgroup"]');_.style.scrollMarginTop=`${(ce==null?void 0:ce.offsetHeight)??0}px`;const B=M.querySelector('[role="row"]');let ne=0;B&&B.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(K=>{K.style.position==="sticky"&&K.style.left!==""&&(ne=Math.max(ne,parseFloat(K.style.left)+K.offsetWidth))}),_.style.scrollMarginLeft=`${ne}px`,_.scrollIntoView({block:"nearest",inline:"nearest"})},[b]);const R=s.useCallback(M=>{var ne;const _=q.current,ce=new Set,B=[];(ne=x.current)==null||ne.querySelectorAll("[data-cell-id]").forEach(K=>{const Y=K.dataset.cellId.split(":")[0];ce.has(Y)||(ce.add(Y),B.push(Y))}),f(K=>{if(!K)return K;const Y=_.findIndex(ie=>ie.key===K.colKey),se=B.indexOf(K.rowId);let E=Y,Q=se;if(M==="up")Q=Math.max(0,se-1);else if(M==="down")Q=Math.min(B.length-1,se+1);else if(M==="left"){let ie=Y-1;for(;ie>=0&&_[ie].selectable===!1;)ie--;ie>=0&&(E=ie)}else if(M==="right"){let ie=Y+1;for(;ie<_.length&&_[ie].selectable===!1;)ie++;ie<_.length&&(E=ie)}return E===Y&&Q===se?K:{rowId:B[Q],colKey:_[E].key}})},[]),fe=s.useCallback((M=!0)=>{const _=d.current;h(null),_&&f(_),M&&setTimeout(()=>{var ce;return(ce=x.current)==null?void 0:ce.focus({preventScroll:!0})},0)},[]),ee=s.useCallback(async(M,_,ce)=>{var oe;const B=q.current.find(ge=>ge.key===_);if(!(B!=null&&B.editable))return;const{field:ne,type:K,mask:Y,validate:se}=B.editable,E=K==="number"?ce===""?null:Number(ce):ce;if(Y){const ge=Pd(ce,Y);if(ge){k(Me=>({...Me,[`${M}:${_}`]:ge}));return}}if(se){const ge=se(E);if(ge){k(Me=>({...Me,[`${M}:${_}`]:ge}));return}}const Q=J.current,ie=U.current.find(ge=>Q(ge)===M);if(!ie)return;const X=ie[ne];h(null),k(ge=>{const Me={...ge};return delete Me[`${M}:${_}`],Me});const w=U.current,N=w.findIndex(ge=>Q(ge)===M),te=w[Math.min(w.length-1,N+1)];if(f({rowId:Q(te),colKey:_}),setTimeout(()=>{var Me,Ae;const ge=document.activeElement;(!ge||ge===document.body||(Me=x.current)!=null&&Me.contains(ge))&&((Ae=x.current)==null||Ae.focus({preventScroll:!0}))},0),String(X??"")===String(E??""))return;const ue={...ie,[ne]:E};c(ge=>ge.map(Me=>Q(Me)===M?ue:Me)),H({rowId:M,colKey:_});try{await((oe=L.current)==null?void 0:oe.call(L,{row:ie,rowId:M,field:ne,oldValue:X,newValue:E}))}catch{c(ge=>ge.map(Me=>Q(Me)===M?ie:Me)),k(ge=>({...ge,[`${M}:${_}`]:"Error al guardar. Intenta de nuevo."}))}finally{H(null)}},[]),j=s.useCallback(M=>{if(S.current){M.preventDefault();return}if(d.current)return;const _=p.current;if(!(!_||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(M.key)))switch(M.preventDefault(),M.key){case"ArrowUp":R("up");break;case"ArrowDown":R("down");break;case"ArrowLeft":R("left");break;case"ArrowRight":R("right");break;case"Tab":R(M.shiftKey?"left":"right");break;case"Enter":{const B=q.current.find(ne=>ne.key===_.colKey);B!=null&&B.editable&&!re.current?(h(_),B.editable.type==="select"&&!T.current.has(_.colKey)&&W(_.colKey,B.editable)):R("down");break}}},[R,W]),Z=s.useMemo(()=>e.map(M=>{if(!M.editable||o){const ce={...M};if(delete ce.editable,delete ce.selectable,M.selectable===!1)return{...ce,disableRowClick:!0};const B=ce.cell;return{...ce,className:`relative ${ce.className??""}`.trim(),disableRowClick:!0,cell:ne=>{const K=n(ne),Y=(b==null?void 0:b.rowId)===K&&(b==null?void 0:b.colKey)===M.key;return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${K}:${M.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var se;S.current||(f({rowId:K,colKey:M.key}),(se=x.current)==null||se.focus({preventScroll:!0}))}}),Y&&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(ne)})]})}}}const _=M.editable;return{...M,className:`relative ${M.className??""}`.trim(),disableRowClick:!0,cell:ce=>{const B=n(ce),ne=M.key,K=(u==null?void 0:u.rowId)===B&&(u==null?void 0:u.colKey)===ne,Y=(b==null?void 0:b.rowId)===B&&(b==null?void 0:b.colKey)===ne,se=y[`${B}:${ne}`],E=(g==null?void 0:g.rowId)===B&&(g==null?void 0:g.colKey)===ne,Q=ce[_.field],ie=String(Q??""),X=()=>{var N;S.current||(f({rowId:B,colKey:ne}),h({rowId:B,colKey:ne}),(N=x.current)==null||N.focus({preventScroll:!0}),_.type==="select"&&!T.current.has(ne)&&W(ne,_))};if(K){const N=_.type==="select"?t.jsx(jd,{initialValue:ie,options:$[ne]??[],loading:C[ne]??!1,onCommit:te=>ee(B,ne,te),onCancel:fe}):t.jsx(Wd,{initialValue:ie,type:_.type??"text",mask:_.mask,onCommit:te=>ee(B,ne,te),onCancel:fe});return t.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:qd,onClick:te=>te.stopPropagation(),children:N})}const w=M.cell(ce);return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${B}:${ne}`,className:`peer absolute inset-0 z-10 ${E?"cursor-wait":"cursor-pointer"}`,onClick:X}),Y&&!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:w})}),!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,g,y,$,C,n,ee,fe,W]);return t.jsx("div",{ref:x,tabIndex:0,onKeyDown:j,onBlur:M=>{var _;(_=x.current)!=null&&_.contains(M.relatedTarget)||setTimeout(()=>{var B,ne;const ce=document.activeElement;ce&&((B=ce.closest)!=null&&B.call(ce,"[data-bonsaif-select-dropdown]"))||(ne=x.current)!=null&&ne.contains(ce)||fe(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:t.jsx(ro,{...l,columns:Z,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 Or(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,maxDate:o,viewMonth:l,numberOfMonths:i=1,orientation:c="horizontal",showSummary:d=!0,startLabel:u="Inicio",endLabel:h="Regreso",className:b=""}){const f={from:ut(e),to:ut(r)},p=ut(a),y=ut(o),k=[...p?[{before:p}]:[],...y?[{after:y}]:[]],[g,H]=s.useState(()=>ut(l||e)??new Date);s.useEffect(()=>{const v=ut(l||e);v&&H(v)},[l,e]);const S=s.useMemo(()=>{if(i<=1)return Or(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(g));const v=new Date(g.getFullYear(),g.getMonth()+i-1,1),T=g.getFullYear()===v.getFullYear(),x=new Intl.DateTimeFormat("es-MX",{month:"short",...T?{}:{year:"numeric"}}).format(g),P=new Intl.DateTimeFormat("es-MX",{month:"short",year:"numeric"}).format(v);return`${Or(x)} – ${Or(P)}`},[g,i]);function $(){H(new Date(g.getFullYear(),g.getMonth()-1,1))}function O(){H(new Date(g.getFullYear(),g.getMonth()+1,1))}const C=i>1?`bonsaif-range-months bonsaif-range-months--multi bonsaif-range-months--${c}`:"bonsaif-range-months";return t.jsxs("div",{className:`bonsaif-calendar bonsaif-date-range-picker ${b}`.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:$,children:t.jsx(z.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:S}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes siguiente",onClick:O,children:t.jsx(z.HiChevronRight,{size:16})})]}),t.jsx(Ya.DayPicker,{mode:"range",selected:f,month:g,onMonthChange:H,onSelect:v=>{const T=v!=null&&v.from?Bt(v.from):e,x=v!=null&&v.to?Bt(v.to):"";n({startDate:T,endDate:x})},numberOfMonths:i,hideNavigation:!0,weekStartsOn:1,disabled:k.length>0?k:void 0,showOutsideDays:!1,modifiers:bo,modifiersClassNames:ho,components:{DayButton:Gd,Weekday:mo},classNames:{root:"bonsaif-range-daypicker w-full",months:C,month:i>1?"bonsaif-multi-month bonsaif-range-month-card":"bonsaif-multi-month",month_caption:i>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:v=>`${Or(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(v))} ${v.getFullYear()}`,formatWeekdayName:fo}})]}),d?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:[u,": ",e]}),r?t.jsxs("span",{className:"bonsaif-cal-chip bonsaif-cal-chip--static",children:[h,": ",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 v=C;if(c){const T=b.current.filter(P=>!P.startsWith(c)),x=C.filter(P=>P.startsWith(c));v=[...T,...x].sort()}r==null||r(Zd(v,l))},[l,r,c]),p=s.useCallback((C,v=!1)=>Qd(C,a,o)?!0:!(!(i!=null&&i(C))||v&&b.current.includes(C)),[i,o,a]),y=s.useCallback(C=>C.filter(v=>!p(v)),[p]),k=s.useCallback(()=>{u.current=null},[]);s.useEffect(()=>{const C=()=>k();return window.addEventListener("pointerup",C),window.addEventListener("pointercancel",C),()=>{window.removeEventListener("pointerup",C),window.removeEventListener("pointercancel",C)}},[k]);const g=s.useCallback((C,v,T,x)=>{const P=y(Zs(C,v));f(T==="add"?hn(x,P,"add"):hn(x,P,"remove"))},[f,y]),H=s.useCallback((C,v)=>{if(n||v.button!==0)return;const T=Bt(C);if(p(T,!0)||v.shiftKey)return;h.current=!0;const x=[...b.current],P=x.includes(T)?"remove":"add";P==="add"&&p(T)||(u.current={active:!0,mode:P,anchor:T,latest:T,baseline:x},d.current=T,g(T,T,P,x),v.preventDefault())},[g,n,p]),S=s.useCallback(C=>{const v=u.current;if(!(v!=null&&v.active)||n)return;const T=Bt(C);v.mode==="add"&&p(T)||v.latest!==T&&(v.latest=T,g(v.anchor,T,v.mode,v.baseline))},[g,n,p]),$=s.useCallback((C,v)=>{if(n)return;const T=Bt(C);if(!p(T,!0)){if(h.current&&!v.shiftKey){h.current=!1,v.preventDefault(),v.stopPropagation();return}if(h.current=!1,v.shiftKey&&d.current){v.preventDefault(),v.stopPropagation();const x=y(Zs(d.current,T));f(hn(b.current,x,"add"));return}!b.current.includes(T)&&p(T)||(d.current=T,f(hn(b.current,[T],"toggle")))}},[f,n,y,p]),O=s.useCallback(C=>{if(n)return;const v=y(Vd(C));if(!v.length)return;const T=v.every(x=>b.current.includes(x));f(hn(b.current,v,T?"remove":"add")),d.current=v[0]??d.current},[f,n,y]);return{onDayPointerDown:H,onDayPointerEnter:S,onDayClick:$,toggleWeek:O,endDrag:k}}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 y=s.useMemo(()=>Ys(e),[e]),k=s.useMemo(()=>new Set(e),[e]),g=ut(n),H=ut(a),[S,$]=s.useState(()=>ut(l||e[0])??new Date),[O,C]=s.useState(()=>mn(ut(l||e[0])??new Date)),[v,T]=s.useState(u),x=d??v;function P(M){d===void 0&&T(M),h==null||h(M)}s.useEffect(()=>{const M=ut(l);M&&($(M),C(mn(M)))},[l]);const{onDayPointerDown:W,onDayPointerEnter:U,onDayClick:L,toggleWeek:J}=Js({value:e,onChange:r,disabled:p,minDate:n,maxDate:a,maxDates:i,isDateDisabled:o}),q=s.useMemo(()=>{if(p)return!0;const M=[];return g&&M.push({before:g}),H&&M.push({after:H}),o&&M.push(_=>o(Bt(_))),M.length>0?M:void 0},[p,o,H,g]),re=s.useCallback(M=>t.jsx(Ks,{...M,className:`bonsaif-multi-day-btn ${M.className??""}`,onDayPointerDown:W,onDayPointerEnter:U,onDayClickSelect:L}),[L,W,U]),R=s.useMemo(()=>Qs(O,1),[O]),fe=R[6],ee=x==="week"?`${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short"}).format(R[0])} – ${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short",year:"numeric"}).format(fe)}`:Or(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(S));function j(){if(x==="week"){const M=Rs(O,-7);C(mn(M)),$(M);return}$(new Date(S.getFullYear(),S.getMonth()-1,1))}function Z(){if(x==="week"){const M=Rs(O,7);C(mn(M)),$(M);return}$(new Date(S.getFullYear(),S.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":x==="month",className:`bonsaif-cal-view-btn${x==="month"?" is-active":""}`,disabled:p,onClick:()=>{P("month"),$(O)},children:"Mes"}),t.jsx("button",{type:"button",role:"tab","aria-selected":x==="week",className:`bonsaif-cal-view-btn${x==="week"?" is-active":""}`,disabled:p,onClick:()=>{P("week"),C(mn(S))},children:"Semana"})]}),t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":x==="week"?"Semana anterior":"Mes anterior",disabled:p,onClick:j,children:t.jsx(z.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:ee}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":x==="week"?"Semana siguiente":"Mes siguiente",disabled:p,onClick:Z,children:t.jsx(z.HiChevronRight,{size:16})})]}),t.jsxs("p",{className:"bonsaif-cal-hint",children:["Click · Shift+click rango · Arrastra",c&&x==="month"?" · Semana (nº)":"",x==="week"?" · Botón semana completa":""]}),x==="month"?t.jsx(Ya.DayPicker,{mode:"multiple",required:!1,selected:y,month:S,onMonthChange:$,onSelect:()=>{},hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,showWeekNumber:c,onWeekNumberClick:(M,_)=>{J(_)},disabled:q,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:re,Weekday:mo},formatters:{formatWeekdayName:fo}}):t.jsxs("div",{className:"bonsaif-week-view",children:[t.jsx("div",{className:"bonsaif-week-view-head",children:R.map(M=>t.jsx("div",{className:"bonsaif-multi-weekday",children:new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(M)},`h-${Bt(M)}`))}),t.jsx("div",{className:"bonsaif-week-view-days",children:R.map(M=>{const _=Bt(M),ce=k.has(_),B=p||(n?_<n:!1)||(a?_>a:!1)||!!(o!=null&&o(_)),ne=_===Bt(new Date);return t.jsx("div",{className:`bonsaif-multi-day${ce?" bonsaif-multi-day-selected":""}${ne?" 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:K=>W(M,K),onPointerEnter:()=>U(M),onClick:K=>L(M,K),children:[t.jsx("span",{className:"bonsaif-week-day-num",children:M.getDate()}),t.jsx("span",{className:"bonsaif-week-day-month",children:new Intl.DateTimeFormat("es-MX",{month:"short"}).format(M)})]})},_)})}),t.jsx("button",{type:"button",className:"bonsaif-week-select-all",disabled:p,onClick:()=>J(R),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(M=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:p,onClick:()=>r==null?void 0:r(e.filter(_=>_!==M)),title:`Quitar ${M}`,children:[Gs(M),t.jsx("span",{"aria-hidden":!0,children:"×"})]},M))})]})}):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),y=n??(e[0]?Number(e[0].slice(0,4)):new Date().getFullYear()),[k,g]=s.useState(y);s.useEffect(()=>{typeof n=="number"&&g(n)},[n]);function H(x){g(x),a==null||a(x)}const{onDayPointerDown:S,onDayPointerEnter:$,onDayClick:O}=Js({value:e,onChange:r,disabled:u||h,minDate:o,maxDate:l,maxDates:i,retainOutsidePrefix:`${k}-`}),C=s.useCallback(x=>t.jsx(Ks,{...x,className:`bonsaif-year-day-btn ${x.className??""}`,onDayPointerDown:S,onDayPointerEnter:$,onDayClickSelect:O}),[O,S,$]),v=b.filter(x=>x.getFullYear()===k),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:()=>H(k-1),children:t.jsx(z.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:k}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año siguiente",disabled:u,onClick:()=>H(k+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(x=>{const P=new Date(k,x,1);return t.jsxs("div",{className:"bonsaif-year-cal-month",children:[t.jsx("div",{className:"bonsaif-year-cal-month-title",children:Or(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(P))}),t.jsx(Ya.DayPicker,{mode:"multiple",required:!1,selected:v,month:P,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:W=>new Intl.DateTimeFormat("es-MX",{weekday:"narrow"}).format(W)}})]},`${k}-${x}`)})})]}),c?t.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?t.jsx("span",{children:"Sin fechas seleccionadas"}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"," ·"," ",k]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(x=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:u||h,onClick:()=>r==null?void 0:r(e.filter(P=>P!==x)),title:`Quitar ${x}`,children:[Gs(x),t.jsx("span",{"aria-hidden":!0,children:"×"})]},x))})]})}):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({}),y=s.useRef(null),k=s.useRef(null),g=s.useCallback(C=>{u(C),c==null||c(C)},[c]),H=s.useCallback(()=>{const C=y.current;if(!C)return;const v=C.getBoundingClientRect(),T=typeof a=="number"?a:v.width,x=typeof a=="number"?a:Math.max(v.width,180),P=n==="end"?Math.max(8,v.right-x):Math.min(v.left,window.innerWidth-x-8),W=window.innerHeight-v.bottom,U=W<240&&v.top>W?void 0:v.bottom+6,L=U===void 0?window.innerHeight-v.top+6:void 0;p({position:"fixed",zIndex:9999,left:P,top:U,bottom:L,width:ru(typeof a=="number"?T:a)})},[n,a]);s.useEffect(()=>b(!0),[]),s.useEffect(()=>{if(!d)return;H();const C=T=>{var P,W;const x=T.target;!((P=y.current)!=null&&P.contains(x))&&!((W=k.current)!=null&&W.contains(x))&&g(!1)},v=T=>{T.key==="Escape"&&g(!1)};return document.addEventListener("mousedown",C),window.addEventListener("keydown",v),window.addEventListener("resize",H),window.addEventListener("scroll",H,!0),()=>{document.removeEventListener("mousedown",C),window.removeEventListener("keydown",v),window.removeEventListener("resize",H),window.removeEventListener("scroll",H,!0)}},[d,g,H]);const S=C=>{o||(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),g(!d))},$=s.isValidElement(e)?s.cloneElement(e,{onClick:()=>{o||(el(),g(!d))}}):e,O=d?t.jsx("div",{ref:k,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${i}`,style:f,children:r.map(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 v;C.disabled||(el(),(v=C.onSelect)==null||v.call(C),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: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:y,role:"button",tabIndex:o?-1:0,"aria-haspopup":"menu","aria-expanded":d,onKeyDown:S,className:`inline-flex ${o?"pointer-events-none opacity-60":""} ${l}`,children:[$,h&&O?ht.createPortal(O,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:y="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:k="Descartar",unsavedChangesCancelLabel:g="Seguir editando",onDiscardChanges:H,disabled:S=!1,disabledMessage:$,children:O}){const[C,v]=s.useState(!1),[T,x]=s.useState(!1),[P,W]=s.useState(!1),U=s.useCallback(()=>{x(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>W(!0))})},[]),L=s.useCallback(()=>{W(!1),window.setTimeout(()=>x(!1),au)},[]),J=S||c,q=s.useCallback(()=>{if(!J){if(f){U();return}r()}},[J,f,r,U]),re=s.useCallback(()=>{W(!1),x(!1),H==null||H(),r()},[r,H]);if(s.useEffect(()=>{v(!0)},[]),s.useEffect(()=>(document.body.style.overflow=e?"hidden":"",e||(W(!1),x(!1)),()=>{document.body.style.overflow=""}),[e]),s.useEffect(()=>{if(!e)return;const fe=ee=>{if(ee.key==="Escape"&&!J){if(T){L();return}q()}};return window.addEventListener("keydown",fe),()=>window.removeEventListener("keydown",fe)},[L,J,T,e,q]),!C)return null;const R=$!==void 0?$:c?"Guardando…":null;return ht.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:q}),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(Ve,{variant:"icon",onClick:q,title:"Cerrar",disabled:J,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(Ve,{variant:"secondary",size:"sm",onClick:q,disabled:J,style:{background:"var(--bg-input)"},children:"Cancelar"}),t.jsx(Ve,{variant:"primary",size:"sm",icon:t.jsx(yc.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:d||J,title:l})]})]})]}),t.jsx("div",{"data-drawer-scroll":"true",className:h,children:O}),J&&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:R?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:R})]}):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 ${P?"opacity-100":"opacity-0"}`,onClick:L}),t.jsxs("div",{className:`relative z-10 w-full max-w-sm rounded-2xl border p-6 shadow-2xl transition-[opacity,transform] duration-200 ease-out ${P?"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(Ve,{variant:"icon",onClick:L,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":g,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:y}),t.jsxs("div",{className:"mt-6 flex gap-2",children:[t.jsx(Ve,{variant:"secondary",onClick:L,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:g}),t.jsx(Ve,{variant:"secondary",onClick:re,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:k})]})]})]})]}),document.body)}const 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 Hr({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 Br({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[y,k]=s.useState(()=>!!p.autoFocus),[g,H]=s.useState(!1),S=p.type==="password"&&u,$=S&&g?"text":p.type,O=!!o,C=O&&l!=="tooltip",v=O&&l!=="inline",T=!!n&&a==="tooltip"&&!C,x=h?f:void 0,P=O?"border-[var(--danger)] focus:border-[var(--danger)]":"",W=v?S?"pr-20":"pr-10":S?"pr-10":"",U=p.value!==void 0?String(p.value).length>0:p.defaultValue!==void 0&&String(p.defaultValue).length>0,L=y||U,J={top:L?7:12,color:y?"var(--primary)":"var(--text-muted)",fontSize:L?10:13,fontWeight:L?600:400,textTransform:L?"uppercase":"none"},q=j=>{var Z;k(!0),(Z=p.onFocus)==null||Z.call(p,j)},re=j=>{var Z;k(!1),(Z=p.onBlur)==null||Z.call(p,j)},R=S?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:()=>H(j=>!j),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(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 ${g?"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=v?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)] ${S?"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,ee=t.jsx(Br,{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:$,required:x,placeholder:" ","aria-invalid":O||p["aria-invalid"],"data-has-value":U?"true":void 0,className:`h-11 w-full pt-5 ${W} ${P} ${b}`,onFocus:q,onBlur:re}),t.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:J,children:[e,f&&t.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),c&&t.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:L?7:12},children:c}),fe,R]}),ee]}):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(Hr,{content:n}):null,c&&t.jsx("span",{className:"ml-auto normal-case",children:c})]}),S?t.jsxs("span",{className:"relative block",children:[t.jsx(Zn,{...p,type:$,required:x,"aria-invalid":O||p["aria-invalid"],className:`w-full ${W} ${P} ${b}`,onFocus:q,onBlur:re}),fe,R]}):t.jsxs("span",{className:"relative block",children:[t.jsx(Zn,{...p,required:x,"aria-invalid":O||p["aria-invalid"],className:`w-full ${W} ${P} ${b}`}),fe]}),ee]})}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,y=k=>{i===void 0&&b(k.currentTarget.value),d==null||d(k)};return t.jsx(yo,{...u,value:i,defaultValue:c,type:"text",inputMode:r,autoComplete:e,error:l??p,errorDisplay:o,onChange:y})}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:y="Buscar archivos",dropLabel:k="Suelta los archivos aqui",emptyLabel:g="Arrastra y suelta archivos",emptyDescription:H="o haz click para buscarlos en tu equipo",selectedLabel:S="Archivos seleccionados",size:$="md",containerClassName:O="",dropzoneClassName:C="",fileListClassName:v="",className:T="",id:x,accept:P,disabled:W,required:U,...L}){const J=s.useId(),q=x??J,re=s.useRef(null),[R,fe]=s.useState(!1),[ee,j]=s.useState(i),Z=l??ee,M=!!a,_=!!r&&n==="tooltip"&&!M,ce=p&&Z.length>0&&!W,B=(N,te)=>{l===void 0&&j(N),c==null||c(N,te)},ne=(N,te)=>{const ue=N.filter(Ae=>cl(Ae,P)),oe=N.filter(Ae=>!cl(Ae,P)),ge=b?[...Z,...ue]:ue,Me=Lu(ge,u,h);oe.length>0&&(d==null||d(oe)),B(Me,te)},K=()=>{var N;W||(N=re.current)==null||N.click()},Y=N=>{ne(Array.from(N.target.files??[]),N),N.target.value=""},se=N=>{N.preventDefault(),W||fe(!0)},E=N=>{N.currentTarget.contains(N.relatedTarget)||fe(!1)},Q=N=>{N.preventDefault(),fe(!1),!W&&ne(Array.from(N.dataTransfer.files),N)},ie=N=>{N.key!=="Enter"&&N.key!==" "||(N.preventDefault(),K())},X=N=>{B(Z.filter((te,ue)=>ue!==N))},w=()=>{B([])};return t.jsxs("div",{className:`flex flex-col gap-2 ${O}`,children:[(e||o||_)&&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:"*"}),_?t.jsx(Hr,{content:r}):null,o&&t.jsx("span",{className:"ml-auto normal-case",children:o})]}),t.jsx("input",{...L,ref:re,id:q,type:"file",accept:P,multiple:u,disabled:W,required:U&&Z.length===0,"aria-invalid":M||L["aria-invalid"],className:"sr-only",onChange:Y}),t.jsxs("div",{role:"button",tabIndex:W?-1:0,"aria-controls":q,"aria-disabled":W||void 0,"aria-invalid":M||void 0,className:`flex cursor-pointer flex-col items-center justify-center gap-3 rounded-lg border border-dashed bg-[var(--bg-card)] text-center outline-none transition-colors focus:border-[var(--primary)] focus:bg-[var(--bg-input)] ${$u[$]} ${R?"border-[var(--primary)] bg-[var(--bg-input)]":M?"border-[var(--danger)]":"border-[var(--border)]"} ${W?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${C} ${T}`,onClick:K,onDragOver:se,onDragLeave:E,onDrop:Q,onKeyDown:ie,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:R?k:g}),H&&t.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:H})]}),y&&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:y})]}),f&&Z.length>0&&t.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${v}`,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:S}),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:w,children:t.jsx(z.HiTrash,{className:"h-4 w-4"})})]}),t.jsx("ul",{className:"divide-y divide-[var(--border)]",children:Z.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(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:N.name}),t.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:Au(N.size)})]}),!W&&t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":`Quitar ${N.name}`,onClick:()=>X(te),children:t.jsx(z.HiXMark,{className:"h-4 w-4"})})]},`${N.name}-${N.lastModified}-${te}`))})]}),t.jsx(Br,{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($=>({key:!1,type:"",...$}))),[f,p]=s.useState(""),[y,k]=s.useState(""),g=s.useCallback(($,O)=>{b(C=>{const v=C.map((T,x)=>x===$?{...T,...O}:T);return u==null||u(v),v})},[u]),H=s.useCallback(()=>{d==null||d(h)},[h,d]),S=s.useCallback(()=>{var v;const $=f.trim();if(!$){k("Ingresa un nombre de campo.");return}if(h.some(T=>T.name.toLowerCase()===$.toLowerCase())){k("Ese campo ya existe en el arreglo.");return}const C={name:$,key:!1,type:((v=n[0])==null?void 0:v.value)??""};b(T=>{const x=[...T,C];return u==null||u(x),x}),p(""),k("")},[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(($,O)=>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:$.name}),t.jsx("div",{className:"flex justify-center",children:t.jsx(Fn,{size:"sm",checked:$.key??!1,onChange:C=>g(O,{key:C.target.checked}),"aria-label":`${$.name} es clave`})}),t.jsx(br,{value:$.type??"",onChange:C=>g(O,{type:C}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${$.name}`})]},$.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:$=>{p($.currentTarget.value),y&&k("")},onKeyDown:$=>{$.key==="Enter"&&($.preventDefault(),S())},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(Ve,{variant:"secondary",onClick:S,height:36,padding:"0 12px",children:i})]}),y&&t.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:y})]}),t.jsx("div",{className:"flex justify-end",children:t.jsx(Ve,{variant:"primary",onClick:H,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(Hr,{content:n}):null,l&&t.jsx("span",{className:"ml-auto normal-case",children:l})]}),t.jsx("span",{className:`block ${d}`,children:r}),t.jsx(Br,{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,Ir=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,r,n){const a=(n||"").trim();if(a)return a.replace(/[\r\n"]/g," ");const o=(r||"").trim();if(o&&/\.[a-z0-9]{2,5}$/i.test(o))return o.replace(/[\r\n"]/g," ");try{const i=new URL(e,"http://local.invalid").pathname.split("/").pop()||"";if(i&&/\.[a-z0-9]{2,5}$/i.test(i))return decodeURIComponent(i).replace(/[\r\n"]/g," ")}catch{}return o||"imagen"}async function qu(e){const r=ju(e.src,e.alt,e.downloadName);try{const n=await fetch(e.src,{credentials:"include",cache:"no-store"});if(!n.ok)throw new Error(`HTTP ${n.status}`);const a=await n.blob(),o=URL.createObjectURL(a),l=document.createElement("a");l.href=o,l.download=r,l.rel="noopener",document.body.appendChild(l),l.click(),l.remove(),window.setTimeout(()=>URL.revokeObjectURL(o),6e4)}catch{const n=document.createElement("a");n.href=e.src,n.download=r,n.target="_blank",n.rel="noopener",document.body.appendChild(n),n.click(),n.remove()}}function Uu(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 mr({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,showDownload:p=!0,loop:y=!0,showThumbnails:k=!0,zIndex:g=1100,ariaLabel:H="Visor de imagen"}){const[S,$]=s.useState(!1),[O,C]=s.useState(!1),[v,T]=s.useState(a??0),[x,P]=s.useState(1),[W,U]=s.useState({x:0,y:0}),[L,J]=s.useState({opacity:1,x:0,scale:1,blur:0,animate:!1}),[q,re]=s.useState({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),[R,fe]=s.useState(!1),ee=s.useRef(null),j=s.useRef(null),Z=s.useRef(null),M=s.useRef(null),_=s.useRef(null),ce=s.useRef(!1),B=s.useRef(!1),ne=s.useRef(null),K=s.useRef(null),Y=s.useRef(null),se=s.useRef(null),E=s.useRef(null),Q=s.useRef(a??0),ie=a??v,X=n.length===0?0:pn(ie,0,Math.max(0,n.length-1)),w=n[X],N=n.length>1,te=Math.max(c,i),ue=k&&N,oe=s.useCallback(me=>{if(n.length===0)return;const ye=n.length-1,Be=y?(me%n.length+n.length)%n.length:pn(me,0,ye);a===void 0&&T(Be),o==null||o(Be)},[a,y,o,n.length]),ge=s.useCallback(()=>{P(1),U({x:0,y:0})},[]),Me=s.useCallback((me,ye)=>{if(ye<=c+.001)return{x:0,y:0};const Be=se.current,_e=E.current;if(!Be||!_e)return me;const Ge=Be.getBoundingClientRect(),rt=_e.offsetWidth*ye,at=_e.offsetHeight*ye,Re=Math.max(0,(rt-Ge.width)/2+Ge.width*.15),st=Math.max(0,(at-Ge.height)/2+Ge.height*.15);return{x:pn(me.x,-Re,Re),y:pn(me.y,-st,st)}},[c]),Ae=s.useCallback(()=>{$(!1),re({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),M.current=null,_.current=null,ce.current=!1,B.current=!1,ne.current&&(clearTimeout(ne.current),ne.current=null)},[]),$t=s.useCallback(()=>{if(ce.current)return;ce.current=!0,C(!1),ge();const me=M.current,ye=me!=null&&_.current!=null&&_.current===X;if(me&&ye){Z.current!=null&&cancelAnimationFrame(Z.current),Z.current=requestAnimationFrame(()=>{Z.current=requestAnimationFrame(()=>{const Be=E.current;if(!Be){Z.current=null,ee.current&&clearTimeout(ee.current),ee.current=setTimeout(Ae,It+40);return}const _e=Be.getBoundingClientRect(),Ge=ul(me,_e);re({enabled:!0,dx:0,dy:0,scale:1,animate:!1}),Z.current=requestAnimationFrame(()=>{re({enabled:!0,dx:Ge.dx,dy:Ge.dy,scale:Ge.scale,animate:!0}),Z.current=null})})}),ee.current&&clearTimeout(ee.current),ee.current=setTimeout(Ae,Ir+80);return}re({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),ee.current&&clearTimeout(ee.current),ee.current=setTimeout(Ae,It+40)},[Ae,ge,X]);s.useEffect(()=>(e?(ee.current&&clearTimeout(ee.current),ne.current&&(clearTimeout(ne.current),ne.current=null),ce.current=!1,B.current=!1,M.current=Uu(l),_.current=M.current!=null?a??v:null,$(!0),C(!1),M.current?re({dx:0,dy:0,scale:1,animate:!1,enabled:!0}):(_.current=null,requestAnimationFrame(()=>requestAnimationFrame(()=>{C(!0),re({dx:0,dy:0,scale:1,animate:!1,enabled:!1})})))):S&&$t(),()=>{ee.current&&clearTimeout(ee.current),Z.current!=null&&cancelAnimationFrame(Z.current)}),[e]);const mt=s.useCallback(()=>{if(!e||ce.current||B.current)return;const me=M.current,ye=E.current;if(!me||!ye){me||(C(!0),B.current=!0);return}const Be=ye.getBoundingClientRect();if(Be.width<2||Be.height<2)return;B.current=!0;const _e=ul(me,Be);re({enabled:!0,dx:_e.dx,dy:_e.dy,scale:_e.scale,animate:!1}),Z.current!=null&&cancelAnimationFrame(Z.current),Z.current=requestAnimationFrame(()=>{Z.current=requestAnimationFrame(()=>{re({enabled:!0,dx:0,dy:0,scale:1,animate:!0}),C(!0),Z.current=null,ne.current&&clearTimeout(ne.current),ne.current=setTimeout(()=>{re({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),ne.current=null},Ir+20)})})},[e]);s.useLayoutEffect(()=>{!S||!e||!M.current||B.current||mt()},[S,e,mt]),s.useEffect(()=>{!e||ce.current||_.current!=null&&_.current!==X&&re(me=>me.enabled?{dx:0,dy:0,scale:1,animate:!1,enabled:!1}:me)},[e,X]),s.useEffect(()=>{if(!e)return;const me=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=me}},[e]),s.useEffect(()=>{e&&ge()},[e,X,ge]),s.useEffect(()=>{a!==void 0&&T(a)},[a]),s.useEffect(()=>{if(!e){Q.current=X,J({opacity:1,x:0,scale:1,blur:0,animate:!1});return}const me=Q.current;if(me===X)return;Q.current=X;const ye=n.length;let Be=1;if(ye>1){const _e=(me+1)%ye===X,Ge=(me-1+ye)%ye===X;Ge&&!_e?Be=-1:_e&&!Ge?Be=1:Be=X>me?1:-1}return j.current!=null&&(cancelAnimationFrame(j.current),j.current=null),J({opacity:0,x:Be*56,scale:.94,blur:8,animate:!1}),j.current=requestAnimationFrame(()=>{j.current=requestAnimationFrame(()=>{J({opacity:1,x:0,scale:1,blur:0,animate:!0}),j.current=null})}),()=>{j.current!=null&&(cancelAnimationFrame(j.current),j.current=null)}},[e,X,n.length]);const gt=x<=c+.001&&Math.abs(W.x)<.5&&Math.abs(W.y)<.5,Qe=s.useCallback((me,ye,Be)=>{P(_e=>{const Ge=pn(me,c,te);if(Math.abs(Ge-_e)<1e-4)return _e;const rt=Ge/_e,at=Ge<_e;return Ge<=c+.001?(U({x:0,y:0}),c):(U(Re=>{let st=Re;if(typeof ye=="number"&&typeof Be=="number"&&se.current&&!at){const nt=se.current.getBoundingClientRect(),gr=ye-nt.left-nt.width/2,it=Be-nt.top-nt.height/2;st={x:gr-(gr-Re.x)*rt,y:it-(it-Re.y)*rt}}else if(at){st={x:Re.x*rt,y:Re.y*rt};const nt=Math.min(1,(_e-Ge)/Math.max(.01,_e-c));st={x:st.x*(1-nt*.65),y:st.y*(1-nt*.65)}}else st={x:Re.x*rt,y:Re.y*rt};return Me(st,Ge)}),Ge)})},[Me,c,te]),de=s.useCallback(()=>{Qe(x*d)},[Qe,x,d]),Te=s.useCallback(()=>{const me=Math.max(c,x/d);if(me<=c+.001){ge();return}P(me),U({x:0,y:0})},[c,ge,x,d]);s.useEffect(()=>{if(!e)return;const me=ye=>{if(ye.key==="Escape"&&h){ye.preventDefault(),r();return}ye.key==="ArrowLeft"&&N?(ye.preventDefault(),oe(X-1)):ye.key==="ArrowRight"&&N?(ye.preventDefault(),oe(X+1)):ye.key==="+"||ye.key==="="?(ye.preventDefault(),Qe(x*d)):ye.key==="-"||ye.key==="_"?(ye.preventDefault(),Te()):ye.key==="0"&&(ye.preventDefault(),ge())};return window.addEventListener("keydown",me),()=>window.removeEventListener("keydown",me)},[Qe,h,N,r,e,ge,X,x,oe,Te,d]);const ae=me=>{me.preventDefault();const ye=me.deltaY>0?1/d:d;Qe(x*ye,me.clientX,me.clientY)},He=me=>{x<=c+.001||(me.currentTarget.setPointerCapture(me.pointerId),fe(!0),K.current={pointerId:me.pointerId,startX:me.clientX,startY:me.clientY,originX:W.x,originY:W.y})},ze=me=>{const ye=K.current;!ye||ye.pointerId!==me.pointerId||U(Me({x:ye.originX+(me.clientX-ye.startX),y:ye.originY+(me.clientY-ye.startY)},x))},Ye=me=>{var ye;((ye=K.current)==null?void 0:ye.pointerId)===me.pointerId&&(K.current=null,fe(!1))},Xe=me=>{if(me.stopPropagation(),x>c+.05){ge();return}Qe(Math.min(te,3),me.clientX,me.clientY)},We=me=>{if(me.touches.length!==2)return;fe(!0);const[ye,Be]=[me.touches[0],me.touches[1]],_e=Math.hypot(ye.clientX-Be.clientX,ye.clientY-Be.clientY);Y.current={distance:_e,scale:x}},Je=me=>{if(me.touches.length!==2||!Y.current)return;me.preventDefault();const[ye,Be]=[me.touches[0],me.touches[1]],_e=Math.hypot(ye.clientX-Be.clientX,ye.clientY-Be.clientY),Ge=(ye.clientX+Be.clientX)/2,rt=(ye.clientY+Be.clientY)/2,at=Y.current.scale*(_e/Math.max(1,Y.current.distance));Qe(at,Ge,rt)},vt=()=>{Y.current=null,fe(!1)};if(!S||!w)return null;const ft=q.enabled,yt=q.animate?`transform ${Ir}ms ${Fu}`:"none";return ht.createPortal(t.jsxs("div",{className:"fixed inset-0",style:{zIndex:g},role:"dialog","aria-modal":"true","aria-label":H,children:[t.jsx("button",{type:"button","aria-label":"Cerrar",className:"absolute inset-0 border-0",style:{background:"color-mix(in srgb, var(--bg-sidebar, var(--primary)) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",opacity:O?1:0,transition:`opacity ${ft?Ir:It}ms ${jt}`,cursor:"default",zIndex:0},onClick:()=>{u&&r()}}),t.jsx("div",{ref:se,className:"absolute inset-0 flex items-center justify-center",style:{zIndex:1,padding:ue?"4.5rem 3.5rem 6.5rem":"4.5rem 3.5rem 2.5rem",opacity:ft||O?1:0,transform:ft||O?"translateY(0) scale(1)":"translateY(10px) scale(0.96)",transition:ft?"none":`opacity ${It}ms ${jt}, transform ${It}ms ${jt}`},onClick:me=>{me.target===me.currentTarget&&u&&r()},onWheel:ae,children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{transform:q.enabled?`translate3d(${q.dx}px, ${q.dy}px, 0) scale(${q.scale})`:void 0,transformOrigin:"center center",transition:q.enabled?yt:void 0},children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{opacity:L.opacity,filter:L.blur?`blur(${L.blur}px)`:"blur(0px)",transform:`translate3d(${L.x}px, 0, 0) scale(${L.scale})`,transition:L.animate?[`opacity ${xo}ms ${wo}`,`transform ${xo}ms ${wo}`,`filter ${xo}ms ${wo}`].join(", "):"none"},children:t.jsx("div",{ref:E,className:"pointer-events-auto relative max-h-full max-w-full touch-none select-none will-change-transform",style:{cursor:x>c+.001?"grab":"zoom-in",transform:`translate3d(${W.x}px, ${W.y}px, 0) scale(${x})`,transformOrigin:"center center",transition:R?"none":`transform 220ms ${Iu}`},onClick:me=>me.stopPropagation(),onDoubleClick:Xe,onPointerDown:He,onPointerMove:ze,onPointerUp:Ye,onPointerCancel:Ye,onTouchStart:We,onTouchMove:Je,onTouchEnd:vt,children:t.jsx("img",{src:w.src,alt:w.alt||"",draggable:!1,className:"block max-h-[min(78vh,820px)] max-w-[min(86vw,1100px)] object-contain",style:{display:"block",borderRadius:ko,imageRendering:x>2.5?"pixelated":"auto"},onLoad:()=>{mt()}},w.src+String(X))})})})}),t.jsxs("div",{className:"pointer-events-none absolute inset-0",style:{zIndex:2,opacity:O?1:0,transform:O?"translateY(0)":"translateY(-6px)",transition:`opacity ${ft?Ir:It}ms ${jt}, transform ${ft?Ir: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:[X+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(mr,{label:"Alejar",onClick:Te,disabled:x<=c+.001,children:t.jsx(z.HiMinus,{className:"h-5 w-5"})}),t.jsx(mr,{label:"Restablecer tamaño",onClick:ge,disabled:gt,children:t.jsx(z.HiArrowsPointingIn,{className:"h-5 w-5"})}),t.jsx(mr,{label:"Acercar",onClick:de,disabled:x>=te-.001,children:t.jsx(z.HiPlus,{className:"h-5 w-5"})})]}):null,p&&(w!=null&&w.src)?t.jsx(mr,{label:"Descargar",onClick:()=>{qu(w)},children:t.jsx(z.HiArrowDownTray,{className:"h-5 w-5"})}):null,t.jsx(mr,{label:"Cerrar",onClick:r,children:t.jsx(z.HiXMark,{className:"h-5 w-5"})})]})]}),N?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"pointer-events-auto absolute left-3 top-1/2",style:{opacity:O?1:0,transform:O?"translate(0, -50%)":"translate(-8px, -50%)",transition:`opacity ${It}ms ${jt}, transform ${It}ms ${jt}`},children:t.jsx(mr,{label:"Anterior",size:"lg",onClick:()=>oe(X-1),disabled:!y&&X<=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:O?1:0,transform:O?"translate(0, -50%)":"translate(8px, -50%)",transition:`opacity ${It}ms ${jt}, transform ${It}ms ${jt}`},children:t.jsx(mr,{label:"Siguiente",size:"lg",onClick:()=>oe(X+1),disabled:!y&&X>=n.length-1,children:t.jsx(z.HiChevronRight,{className:"h-6 w-6"})})})]}):null,ue?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((me,ye)=>{const Be=ye===X;return t.jsx("button",{type:"button",role:"tab","aria-selected":Be,"aria-label":me.alt||`Imagen ${ye+1}`,onClick:_e=>{_e.stopPropagation(),oe(ye)},className:"relative shrink-0 overflow-hidden transition-opacity",style:{width:56,height:42,borderRadius:ko,opacity:Be?1:.42,transition:`opacity 180ms ${jt}`},children:t.jsx("img",{src:me.src,alt:"",draggable:!1,className:"h-full w-full object-cover",style:{borderRadius:ko}})},`${me.src}-${ye}`)})})}):null]})]}),document.body)}function Vu({children:e,className:r,style:n,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c,showDownload:d,zIndex:u}){const[h,b]=s.useState(!1),[f,p]=s.useState(0),[y,k]=s.useState([]),[g,H]=s.useState(null),S=s.useCallback((O,C,v)=>{k(O),H(v??null),p(C),b(!0)},[]),$=s.useCallback(O=>{dl(O,S)},[S]);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`[&_img]:cursor-zoom-in ${r??""}`,style:n,onClick:$,children:e}),t.jsx(fl,{open:h,onClose:()=>b(!1),index:f,onIndexChange:p,slides:y,originRect:g,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c,showDownload:d,zIndex:u})]})}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 Xu(e,r){if(!r)return!0;const n=Co(r);return Co(e.label).includes(n)||!!(e.sublabel&&Co(e.sublabel).includes(n))}function Yu({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:y="Sin resultados",clearLabel:k="Limpiar seleccion",pruneMissingValues:g=!0}){const[H,S]=s.useState(!1),[$,O]=s.useState(""),[C,v]=s.useState(0),[T,x]=s.useState(!1),[P,W]=s.useState({}),U=s.useRef(null),L=s.useRef(null),J=s.useRef(null),q=s.useRef(null),re=u&&n.length>=h,R=s.useMemo(()=>new Set(e),[e]),fe=s.useMemo(()=>{const w=new Map;for(const N of n)w.set(N.value,N);return w},[n]),ee=s.useMemo(()=>{const w=[];for(const N of e){const te=fe.get(N);te&&w.push(te)}return w},[fe,e]),j=b==="all"?ee.length:b,Z=ee.slice(0,j),M=Math.max(0,ee.length-Z.length),_=p&&ee.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:[ee.length," seleccionados"]}),t.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:ee.map(w=>t.jsxs("li",{className:"flex min-w-0 items-baseline gap-1.5 text-xs",style:{color:"var(--text-main)"},children:[w.color&&t.jsx("span",{className:"mt-1 h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:w.color}}),t.jsx("span",{className:"min-w-0 break-words font-medium",children:w.label}),w.sublabel?t.jsx("span",{className:"min-w-0 break-words",style:{color:"var(--text-muted)"},children:w.sublabel}):null]},w.value))})]}),B=s.useMemo(()=>{const w=$.trim();return!re||!w?n:n.filter(N=>Xu(N,w))},[n,$,re]),ne=s.useCallback(()=>{const w=U.current;if(!w)return;const N=w.getBoundingClientRect(),te=re?304:244,ue=window.innerHeight-N.bottom,oe=ue<te&&N.top>ue;W({position:"fixed",left:N.left,top:oe?void 0:N.bottom+4,bottom:oe?window.innerHeight-N.top+4:void 0,width:Math.max(N.width,240),zIndex:9999})},[re]),K=s.useCallback(w=>{hl(e,w)||r(w)},[r,e]),Y=s.useCallback(w=>{const N=fe.get(w);if(N!=null&&N.disabled)return;const te=R.has(w)?e.filter(ue=>ue!==w):[...e,w];K(te)},[K,fe,e,R]),se=s.useCallback(()=>K([]),[K]),E=s.useCallback(()=>{S(!1),O(""),v(0)},[]);s.useEffect(()=>x(!0),[]);const Q=s.useMemo(()=>n.map(w=>w.value).join("\0"),[n]);s.useEffect(()=>{if(!g||e.length===0||n.length===0)return;const w=new Set(n.map(te=>te.value)),N=e.filter(te=>w.has(te));hl(e,N)||r(N)},[Q]),s.useEffect(()=>{if(!H)return;function w(N){var ue,oe;const te=N.target;!((ue=U.current)!=null&&ue.contains(te))&&!((oe=L.current)!=null&&oe.contains(te))&&E()}return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[E,H]),s.useEffect(()=>{H&&(v(0),ne(),re&&setTimeout(()=>{var w;return(w=J.current)==null?void 0:w.focus()},0))},[H,re,ne]),s.useEffect(()=>{if(H)return window.addEventListener("resize",ne),window.addEventListener("scroll",ne,!0),()=>{window.removeEventListener("resize",ne),window.removeEventListener("scroll",ne,!0)}},[H,ne]),s.useEffect(()=>{if(B.length===0){v(0);return}v(w=>Math.min(w,B.length-1))},[B.length]),s.useEffect(()=>{if(C<0||!q.current)return;const w=q.current.children[C];w==null||w.scrollIntoView({block:"nearest"})},[C]);function ie(w){if(!o){if(!H){(w.key==="Enter"||w.key===" "||w.key==="ArrowDown")&&(w.preventDefault(),S(!0));return}if(w.key==="Escape"){w.preventDefault(),E();return}if(w.key==="ArrowDown"){if(w.preventDefault(),B.length===0)return;v(N=>Math.min(N+1,B.length-1));return}if(w.key==="ArrowUp"){w.preventDefault(),v(N=>Math.max(N-1,0));return}if(w.key==="Enter"&&B[C]&&!B[C].disabled){w.preventDefault(),Y(B[C].value);return}w.key==="Backspace"&&!$&&e.length&&(w.preventDefault(),K(e.slice(0,-1)))}}const X=t.jsxs("div",{ref:L,className:"overflow-hidden rounded-xl shadow-xl",style:{...P,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[re&&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:J,value:$,onChange:w=>{O(w.target.value),v(0)},onKeyDown:w=>{(w.key==="ArrowDown"||w.key==="ArrowUp"||w.key==="Enter"||w.key==="Escape")&&(w.stopPropagation(),ie(w))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),$&&t.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:w=>{w.preventDefault(),O(""),v(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:[ee.length," seleccionados",e.length>ee.length?` (${e.length-ee.length} no disponibles)`:""]}),t.jsx("button",{type:"button",onMouseDown:w=>{w.preventDefault(),se()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:k})]}),t.jsxs("ul",{ref:q,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:re?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[B.map((w,N)=>{const te=N===C,ue=R.has(w.value);return t.jsxs("li",{role:"option","aria-selected":ue,onMouseDown:oe=>{oe.preventDefault(),!w.disabled&&Y(w.value)},onMouseEnter:()=>!w.disabled&&v(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:w.disabled?"var(--text-muted)":"var(--text-main)",cursor:w.disabled?"not-allowed":"pointer",opacity:w.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(z.HiCheck,{className:"h-3 w-3"})}),w.color&&t.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:w.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:w.label}),w.sublabel&&t.jsx(Yt,{className:"min-w-0 flex-shrink",style:{color:"var(--text-muted)",fontSize:12},children:w.sublabel})]}),w.badge&&t.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:w.badge})]},w.value)}),B.length===0&&t.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:y})]})]});return t.jsxs("div",{ref:U,className:`relative ${l||"w-full"}`,style:i,onKeyDown:ie,children:[t.jsxs("button",{type:"button",disabled:o,onClick:()=>{o||(H?E():S(!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:ee.length?"var(--text-main)":"var(--text-muted)",border:H?"1px solid var(--primary)":"1px solid var(--border)",opacity:o?.5:1,cursor:o?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":H,children:[t.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:Z.length?(()=>{const w=t.jsxs(t.Fragment,{children:[Z.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(),Y(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(z.HiXMark,{className:"h-3 w-3"})})]},N.value)),M>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":`${M} seleccionados más`,children:["+",M]})]});return _?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:w}):w})():t.jsx("span",{className:"truncate",children:a})}),ee.length?t.jsx("span",{role:"button",tabIndex:-1,"aria-label":k,onMouseDown:w=>{w.preventDefault(),w.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:H?"rotate(180deg)":"rotate(0deg)"}})]}),H&&T&&ht.createPortal(X,document.body)]})}function Gu({inputMode:e="decimal",...r}){return t.jsx(yo,{...r,type:"number",inputMode:e})}function Ku(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 Zu({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=Ku(c,i,o);return t.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[t.jsx(Ve,{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(Ve,{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 Qu(e){return typeof e=="number"?`${e}px`:e}function Ju({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:y="Codigo",countryCodeClassName:k="",countryCodeWidth:g=84,onPhoneValueChange:H,label:S,containerClassName:$="",helperText:O,helperDisplay:C="inline",labelAction:v,className:T="",required:x,disabled:P,floatingLabel:W,showPasswordToggle:U,nativeValidation:L,errorTooltipLabel:J="Error de validacion",...q}){var N;const[re,R]=s.useState(()=>pl(c)),[fe,ee]=s.useState(()=>Jn(h)),j=s.useMemo(()=>{const te=p??ml,ue=f==null?void 0:f.map(Jn);return ue!=null&&ue.length?te.filter(oe=>ue.includes(oe.value)):te},[f,p]),Z=((N=j[0])==null?void 0:N.value)??"+1",M=j.some(te=>te.value===Jn(u??fe))?Jn(u??fe):Z,_=i!==void 0?pl(i):re,ce=`${M} ${_}`.trim(),B=n&&_.length>0&&!go(ce)?a:void 0,ne=l??B,K=!!ne,Y=K&&o!=="tooltip",se=K&&o!=="inline",E=!!O&&C==="tooltip"&&!Y,Q=K?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",ie=te=>{const ue=te.currentTarget.value;i===void 0&&R(ue),H==null||H(ue,{countryCode:M,nationalNumber:ue,fullNumber:`${M} ${ue}`.trim()}),d==null||d(te)},X=te=>{u===void 0&&ee(te),b==null||b(te),H==null||H(_,{countryCode:te,nationalNumber:_,fullNumber:`${te} ${_}`.trim()})},w=se?t.jsx(Pt,{as:"span",content:ne,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":J,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 ${$}`,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:S}),x&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),E?t.jsx(Hr,{content:O}):null,v&&t.jsx("span",{className:"ml-auto normal-case",children:v})]}),t.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${Q}`,children:[t.jsx(br,{value:M,onChange:X,options:j,placeholder:y,disabled:P,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${k}`,style:{width:Qu(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",{...q,value:i,defaultValue:c,type:"tel",inputMode:r,autoComplete:e,disabled:P,required:void 0,"aria-label":q["aria-label"]??(typeof S=="string"?S:void 0),"aria-invalid":K||q["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:ie}),w]})]}),t.jsx(Br,{error:Y?ne:void 0,helperText:O,helperDisplay:C})]})}function Ru({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 ef='<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>',tf='<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">${ef}${tf}</button>`}const rf=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
25
  `;if(o==="script"||o==="style")return"";let l="";for(const i of Array.from(a.childNodes))l+=r(i);return rf.has(o)&&l.length>0&&!l.endsWith(`
26
26
  `)&&(l+=`
27
27
  `),l};return r(e).replace(/\r\n?/g,`
@@ -30,13 +30,13 @@ ${O}`,be=new Blob(["\uFEFF"+le],{type:"text/csv;charset=utf-8;"}),we=URL.createO
30
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
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 nf=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)},af=(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),of=(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")}))},sf=(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")})},lf=(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)?af(r,n):!1;case"table-col-add":return Number.isFinite(a)?kl(r,a):ff(r);case"table-col-del":return Number.isFinite(a)?of(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},cf=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},df=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]},uf=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=cf(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))},ff=e=>{const r=ra(e)-1;return r<0?!1:kl(e,r)},Mo=e=>{El(e)},bf=(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()}`),hf=e=>e.replace(/[<>]/g,"").toLowerCase(),mf=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"]),pf=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,gf=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),vf=e=>aa(e,/font-weight\s*:\s*(bold|[6-9]00)/i),yf=e=>aa(e,/font-style\s*:\s*italic/i),xf=e=>aa(e,/text-decoration(?:-line)?\s*:[^;]*underline/i),wf=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)},Nf=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"},kf=e=>{const n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT).nextNode();if(!n||!n.textContent)return;const a=n.textContent.replace(pf,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");a!==n.textContent&&(n.textContent=a)},Cf=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&&(vf(a)&&oa(n,"strong"),yf(a)&&oa(n,"em"),xf(a)&&oa(n,"u"),wf(a)&&oa(n,"s"))})},Sf=e=>{const r=Array.from(e.querySelectorAll("p, div")).filter(Nf);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=>{kf(u);const h=u.ownerDocument.createElement("li");for(;u.firstChild;)h.appendChild(u.firstChild);d.appendChild(h),u.remove()}),n=i}},Ef=e=>e==="h1"?"h2":e==="h4"||e==="h5"||e==="h6"?"h3":e==="div"?"p":e,Mf=e=>{const r=gf(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()),Cf(o),Sf(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(!mf.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=Ef(u);if(h!==u){const b=d.ownerDocument.createElement(h);for(;d.firstChild;)b.appendChild(d.firstChild);d.replaceWith(b),l(b);return}if(nf.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
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]+?```/,Tf=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},$f=e=>new RegExp("\\p{L}","u").test(e),Ao=(e,r)=>{const n=e.trim();return!n||!$f(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),N=s.useRef(e??""),v=s.useRef(r),H=s.useRef(()=>{}),S=s.useRef(!1),[M,D]=s.useState(()=>!e||e.trim()===""),[C,x]=s.useState(new Set),[$,y]=s.useState(null),[P,j]=s.useState(""),[U,L]=s.useState(""),[J,q]=s.useState(""),[ae,R]=s.useState(""),[fe,I]=s.useState(3),[K,ee]=s.useState(3),[T,W]=s.useState(!0),[ie,B]=s.useState(!1),[re,Z]=s.useState(l==="full"),[Y,se]=s.useState(null),[E,Q]=s.useState(null),ce=s.useRef(null),X=s.useRef(!1),w=s.useRef(null),k=s.useCallback(()=>g.current?b.current:h.current,[]);s.useEffect(()=>{v.current=r},[r]);const te=s.useCallback(()=>{const _=window.getSelection(),G=k();if(!_||!G||_.rangeCount===0||_.isCollapsed)return"";const pe=_.getRangeAt(0);return!G.contains(pe.startContainer)||!G.contains(pe.endContainer)?"":_.toString()},[k]);s.useEffect(()=>{const _=e??"";if(S.current&&_===N.current){S.current=!1,D(!_||_.trim()==="");return}S.current=!1,N.current=_;const G=[h.current,b.current].filter(he=>!!he);G.forEach(he=>{he.innerHTML!==_&&(he.innerHTML=_)}),D(!_||_.trim()===""),G.forEach(he=>Mo(he));const pe=G.map(he=>Hl(he));return()=>pe.forEach(he=>he())},[e]),s.useEffect(()=>{var he,Ee;g.current=ie;let _,G=0,pe;if(ie){const ke=h.current;ke&&(N.current=ta(ke));const Fe=()=>{var dt;const Pe=b.current;if(!Pe){G=requestAnimationFrame(Fe);return}Pe.innerHTML!==N.current&&(Pe.innerHTML=N.current),_=Hl(Pe),Mo(Pe),D(((dt=Pe.textContent)==null?void 0:dt.trim())===""),pe=setTimeout(()=>Pe.focus(),60)};G=requestAnimationFrame(Fe)}else{const ke=b.current,Fe=h.current,Pe=ke?ta(ke):N.current,dt=N.current;N.current=Pe,Fe&&Fe.innerHTML!==Pe&&(Fe.innerHTML=Pe),Pe!==dt&&v.current(Pe),D(((Ee=(he=ke??Fe)==null?void 0:he.textContent)==null?void 0:Ee.trim())==="")}return()=>{G&&cancelAnimationFrame(G),pe&&clearTimeout(pe),_==null||_()}},[ie]);const ue=s.useCallback(()=>{const _=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],G=new Set;_.forEach(he=>{try{u().queryCommandState(he)&&G.add(he)}catch{return}});try{const he=hf(u().queryCommandValue("formatBlock"));he&&G.add(`formatBlock:${he}`)}catch{}const pe=te();Ao(pe,"uppercase")&&G.add("__upper"),Ao(pe,"lowercase")&&G.add("__lower"),Ao(pe,"capitalize")&&G.add("__cap");try{const he=window.getSelection();let Ee=(he==null?void 0:he.anchorNode)??null;(Ee==null?void 0:Ee.nodeType)===Node.TEXT_NODE&&(Ee=Ee.parentElement),Ee instanceof Element&&Ee.closest(".rich-code-wrap")&&G.add("__code")}catch{}x(G)},[te,u]),oe=()=>{var G;const _=k();_&&(Tf(_),N.current=ta(_),S.current=!0,v.current(N.current),D(((G=_.textContent)==null?void 0:G.trim())===""))};H.current=oe;const ge=s.useCallback(()=>{w.current&&(clearTimeout(w.current),w.current=null),ce.current&&(Cl(ce.current),ce.current=null),X.current=!1,se(null),Q(null)},[]),Me=s.useCallback(()=>{w.current&&(clearTimeout(w.current),w.current=null)},[]),Ae=s.useCallback(()=>{Me(),w.current=setTimeout(()=>{X.current||ge()},280)},[Me,ge]);s.useEffect(()=>()=>{w.current&&clearTimeout(w.current)},[]);const $t=s.useCallback(_=>{const G=ce.current;if(!G||!G.isConnected){ge();return}const pe=(Y==null?void 0:Y.rowIndex)??(E==null?void 0:E.rowIndex)??-1,he=(Y==null?void 0:Y.colIndex)??(E==null?void 0:E.colIndex)??-1;lf(_,G,pe,he,k()),ge(),H.current(),ue()},[k,ge,ue,E,Y]),mt=s.useCallback(_=>{if(E)return;const G=_.currentTarget,pe=_.target;if(pe.closest(".rich-table-action-bar, .rich-table-context-menu")){Me();return}const he=pe.closest("td, th");if(!he||!G.contains(he)){Ae();return}const Ee=he.closest("tr"),ke=he.closest("table");if(!Ee||!ke||!G.contains(ke)){Ae();return}Me(),ke.classList.add("rich-table"),ce.current=ke,Sl(ke,Ee,he.cellIndex),se(sf(ke,Ee,he))},[Me,Ae,E]),gt=s.useCallback(_=>{const G=_.relatedTarget;if(G instanceof Element&&(G.closest(".rich-table-action-bar")||G.closest(".rich-table-context-menu"))){Me();return}Ae()},[Me,Ae]),Qe=s.useCallback(_=>{const G=_.currentTarget,he=_.target.closest("td, th");if(!he||!G.contains(he))return;const Ee=he.closest("tr"),ke=he.closest("table");if(!Ee||!ke||!G.contains(ke))return;_.preventDefault(),ke.classList.add("rich-table"),ce.current=ke;const Fe=Array.from(ke.rows).indexOf(Ee),Pe=he.cellIndex;Sl(ke,Ee,Pe),se(null),Q({x:_.clientX,y:_.clientY,rowIndex:Fe,colIndex:Pe})},[]);s.useEffect(()=>{if(!Y&&!E)return;const _=()=>Ae();return window.addEventListener("scroll",_,!0),window.addEventListener("resize",_),()=>{window.removeEventListener("scroll",_,!0),window.removeEventListener("resize",_)}},[Ae,E,Y]),s.useEffect(()=>{if(!E)return;const _=G=>{const pe=G.target;pe instanceof Element&&pe.closest(".rich-table-context-menu")||Q(null)};return window.addEventListener("mousedown",_),()=>window.removeEventListener("mousedown",_)},[E]);const de=_=>{if(!_){const G=h.current;G&&(N.current=ta(G))}B(!_)},Te=(_,G)=>{var pe;(pe=k())==null||pe.focus(),u().execCommand(_,!1,G),oe(),ue()},ne=_=>{Te("formatBlock",_)},He=()=>{var _;(_=k())==null||_.focus(),u().execCommand("insertHTML",!1,"<hr><p><br></p>"),oe(),ue()},ze=()=>{const _=window.getSelection();_&&_.rangeCount>0&&(p.current=_.getRangeAt(0).cloneRange())},Ye=()=>{const _=window.getSelection();_&&p.current&&(_.removeAllRanges(),_.addRange(p.current))},Xe=_=>{if(ze(),_==="link"){const G=window.getSelection();L(G&&!G.isCollapsed?G.toString():""),j("")}_==="image"&&(q(""),R("")),_==="table"&&(I(3),ee(3),W(!0)),y(_)},We=()=>{var he;if(!P.trim())return;Ye(),(he=k())==null||he.focus();const _=window.getSelection(),pe=(_&&!_.isCollapsed?_.toString():"")||U.trim()||P.trim();u().execCommand("insertHTML",!1,`<a href="${_r(P.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${_r(pe)}</a>`),oe(),y(null)},Je=(_,G="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${_r(_)}" alt="${_r(G)}" class="rich-img" />${Al()}</span>`,vt=()=>{var _;J.trim()&&(Ye(),(_=k())==null||_.focus(),u().execCommand("insertHTML",!1,Je(J.trim(),ae.trim())),oe(),y(null))},ut=()=>{var _;Ye(),(_=k())==null||_.focus(),u().execCommand("insertHTML",!1,bf(fe,K,T)),oe(),y(null)},yt=()=>{var pe;Ye(),(pe=k())==null||pe.focus();const _=window.getSelection(),G=_&&!_.isCollapsed?_.toString():"";u().execCommand("insertHTML",!1,$o(G)),oe()},me=(_,G=1200,pe=1200,he=.72)=>new Promise((Ee,ke)=>{const Fe=new FileReader;Fe.onerror=ke,Fe.onload=Pe=>{var wt;const dt=(wt=Pe.target)==null?void 0:wt.result,Ke=new Image;Ke.onerror=ke,Ke.onload=()=>{let{width:Zt,height:Nt}=Ke;if(Zt>G||Nt>pe){const dr=Math.min(G/Zt,pe/Nt);Zt=Math.round(Zt*dr),Nt=Math.round(Nt*dr)}const xr=document.createElement("canvas");xr.width=Zt,xr.height=Nt;const Qt=xr.getContext("2d");if(!Qt){Ee(dt);return}Qt.drawImage(Ke,0,0,Zt,Nt),Ee(xr.toDataURL("image/jpeg",he))},Ke.src=dt},Fe.readAsDataURL(_)}),ye=_=>{_.focus();const G=window.getSelection();if(!G||G.rangeCount===0||!_.contains(G.anchorNode)){const pe=document.createRange();pe.selectNodeContents(_),pe.collapse(!1),G==null||G.removeAllRanges(),G==null||G.addRange(pe)}},Be=s.useRef(()=>{});Be.current=_=>{const G=k();G&&(ye(G),u().execCommand("insertHTML",!1,_),Mo(G),G.querySelectorAll("p").forEach(pe=>{!(pe.textContent??"").replace(/[\u00a0\s]+/g,"")&&!pe.querySelector("img, hr, table")&&pe.remove()}),oe(),ue())};const _e=s.useRef(me);_e.current=me;const Ge=s.useRef(Je);Ge.current=Je;const rt=s.useCallback(_=>{if(!_||f.current.has(_))return;const G=pe=>{const he=pe.clipboardData;if(!he)return;const Ee=he.getData("text/html"),ke=he.getData("text/plain");if(Ee||ke){pe.preventDefault(),pe.stopPropagation();try{const Ke=Ee?Mf(Ee):gn(ke);if(!Ke){ke&&Be.current(gn(ke));return}Be.current(Ke)}catch{ke&&Be.current(gn(ke))}return}const Pe=Array.from(he.items).find(Ke=>Ke.type.startsWith("image/"));if(!Pe)return;pe.preventDefault(),pe.stopPropagation();const dt=Pe.getAsFile();dt&&_e.current(dt).then(Ke=>{Be.current(Ge.current(Ke,"imagen"))})};_.addEventListener("paste",G,!0),f.current.set(_,()=>{_.removeEventListener("paste",G,!0),f.current.delete(_)})},[]),at=s.useCallback(_=>{var pe;const G=h.current;G&&G!==_&&((pe=f.current.get(G))==null||pe()),h.current=_,_&&rt(_)},[rt]),Re=s.useCallback(_=>{var pe;const G=b.current;G&&G!==_&&((pe=f.current.get(G))==null||pe()),b.current=_,_&&rt(_)},[rt]);s.useEffect(()=>{const _=f.current;return()=>{_.forEach(G=>G()),_.clear()}},[]);const st=_=>{const G=window.getSelection(),pe=k();if(!G||!pe||G.rangeCount===0||G.isCollapsed)return;const he=G.getRangeAt(0);if(!pe.contains(he.startContainer)||!pe.contains(he.endContainer))return;const Ee=he.toString();if(!Ee)return;let ke=Ee;_==="uppercase"?ke=Ee.toLocaleUpperCase():_==="lowercase"?ke=Ee.toLocaleLowerCase():ke=Ll(Ee),he.deleteContents();const Fe=document.createTextNode(ke);he.insertNode(Fe);const Pe=document.createRange();Pe.setStart(Fe,0),Pe.setEnd(Fe,ke.length),G.removeAllRanges(),G.addRange(Pe),p.current=Pe.cloneRange(),oe(),ue()},nt=()=>{ze(),ue()},gr=()=>{const _=k();_&&El(_),oe(),ue()},it=()=>{requestAnimationFrame(()=>{var _;(_=k())==null||_.focus()})},vr=_=>{var G,pe;if((_.metaKey||_.ctrlKey)&&_.key==="Enter"){if(_.preventDefault(),_.stopPropagation(),_.repeat)return;(G=k())==null||G.focus(),u().execCommand("insertLineBreak",!1)||u().execCommand("insertHTML",!1,"<br>"),oe(),ue();return}if(_.key==="Tab"){const he=window.getSelection(),Ee=Tl((he==null?void 0:he.anchorNode)??null),ke=k(),Fe=Ml(Ee);if(Ee&&Fe&&(ke!=null&&ke.contains(Ee))){_.preventDefault();const Pe=df(Fe),dt=Pe.indexOf(Ee),Ke=dt>=0?Pe[dt+1]:null;if(Ke)na(Ke,ke,!0);else if($l(Ee,Fe)){const wt=Eo(Fe);wt&&na(wt,ke,!0)}oe(),ue();return}_.preventDefault(),(pe=k())==null||pe.focus(),u().execCommand("insertText",!1,"    "),oe(),ue();return}if(_.key==="Enter"&&!_.shiftKey&&!(_.metaKey||_.ctrlKey)){const he=window.getSelection(),Ee=Tl((he==null?void 0:he.anchorNode)??null),ke=k(),Fe=Ml(Ee);if(Ee&&Fe&&(ke!=null&&ke.contains(Ee))&&$l(Ee,Fe)&&uf(Ee)){_.preventDefault();const Pe=Eo(Fe);Pe&&na(Pe,ke,!0),oe(),ue();return}}if(_.key==="Escape"){if(E){Q(null);return}if($){y(null);return}if(g.current){B(!1);return}}$||(_.ctrlKey||_.metaKey)&&(_.key==="b"&&(_.preventDefault(),Te("bold")),_.key==="i"&&(_.preventDefault(),Te("italic")),_.key==="u"&&(_.preventDefault(),Te("underline")),_.key==="k"&&(_.preventDefault(),Xe("link")))},At=()=>t.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),qe=(_,G,pe,he,Ee)=>{const ke=Ee??(C.has(pe)||pe==="__link"&&$==="link"||pe==="__img"&&$==="image"||pe==="__table"&&$==="table");return t.jsx("button",{type:"button",title:G,tabIndex:-1,onFocus:it,onMouseDown:Fe=>{Fe.preventDefault(),he?he():Te(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:_},pe)},ct=_=>{const G=_.target;if(G.closest("[data-action='delete-img']")){_.preventDefault();const he=G.closest(".rich-img-wrap");he&&(he.remove(),oe());return}const pe=G.closest("[data-action='copy-code']");pe instanceof HTMLButtonElement&&(_.preventDefault(),yl(pe).catch(()=>{}))},ir=()=>{Me(),X.current=!0},xt=()=>{X.current=!1,Ae()},Ft=(_,G,pe,he=!1)=>t.jsx("button",{type:"button",className:`rich-table-action-btn${he?" rich-table-action-btn--danger":""}`,title:_,"aria-label":_,onMouseDown:Ee=>{Ee.preventDefault(),Ee.stopPropagation(),$t(pe)},children:G}),yr=()=>typeof document>"u"||!Y&&!E?null:ht.createPortal(t.jsxs(t.Fragment,{children:[Y&&!E&&t.jsxs("div",{className:"rich-table-action-bar",style:{left:Y.bar.x,top:Y.bar.y},onMouseEnter:ir,onMouseLeave:xt,children:[t.jsxs("span",{className:"rich-table-action-hint",children:["Fila ",Y.rowIndex+1," · Col ",Y.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:_=>_.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(([_,G])=>t.jsx("button",{type:"button",onMouseDown:pe=>{pe.preventDefault(),$t(G)},children:_},G))})]}),document.body),cr=_=>t.jsxs(t.Fragment,{children:[$==="link"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:_},children:[t.jsx("input",{autoFocus:!0,type:"url",value:P,onChange:G=>j(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),We()),G.key==="Escape"&&y(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=>L(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),We()),G.key==="Escape"&&y(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:We,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:()=>y(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),$==="table"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:_},children:[t.jsxs("label",{className:"flex items-center gap-1 text-xs",style:{color:"var(--text-secondary)"},children:["Filas",t.jsx("input",{autoFocus:!0,type:"number",min:1,max:Fr,value:fe,onChange:G=>I(Rn(Number(G.target.value),1,Fr)),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),ut()),G.key==="Escape"&&y(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:K,onChange:G=>ee(Rn(Number(G.target.value),1,ea)),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),ut()),G.key==="Escape"&&y(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:T,onChange:G=>W(G.target.checked)}),"Encabezado"]}),t.jsx("button",{type:"button",onClick:ut,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:()=>y(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),$==="image"&&t.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:_},children:[t.jsx("input",{autoFocus:!0,type:"url",value:J,onChange:G=>q(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),vt()),G.key==="Escape"&&y(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:ae,onChange:G=>R(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),vt()),G.key==="Escape"&&y(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:vt,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:()=>y(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),Kr=(_,G)=>{const pe=l==="compact",he=!pe||re||_;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&&!_&&t.jsxs("button",{type:"button",title:re?"Ocultar herramientas":"Mostrar herramientas de formato",tabIndex:-1,onFocus:it,onMouseDown:Ee=>{Ee.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:re?"color-mix(in srgb, var(--primary) 12%, transparent)":"transparent"},children:[re?t.jsx(z.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(z.HiChevronDown,{className:"h-3.5 w-3.5"}),re?"Ocultar herramientas":"Herramientas"]}),he&&t.jsxs(t.Fragment,{children:[qe(t.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),qe(t.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),qe(t.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),qe(t.jsx(z.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),qe(t.jsx(z.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),qe(t.jsx(z.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>Xe("link")),At(),qe(t.jsx(z.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),qe(t.jsx(z.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),At(),qe(t.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>ne("p"),C.has("formatBlock:p")||C.has("formatBlock:div")),qe(t.jsx(z.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>ne("h2"),C.has("formatBlock:h2")),qe(t.jsx(z.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>ne("h3"),C.has("formatBlock:h3")),qe(t.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>ne("blockquote"),C.has("formatBlock:blockquote")),qe(t.jsx("span",{style:{fontFamily:"ui-monospace, monospace",fontSize:"10px"},children:"</>"}),"Bloque de código","__code",()=>yt(),C.has("__code")),At(),qe(t.jsx("s",{children:"S"}),"Tachado","strikeThrough"),At(),qe(t.jsx(z.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),qe(t.jsx(z.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),At(),qe(t.jsx(z.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),qe(t.jsx(z.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),qe(t.jsx(z.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),qe(t.jsx(z.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),At(),qe(t.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>st("uppercase")),qe(t.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>st("lowercase")),qe(t.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>st("capitalize")),At(),qe(t.jsx(z.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),qe(t.jsx(z.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>Xe("image")),qe(t.jsx(z.HiTableCells,{className:"h-4 w-4"}),"Insertar tabla","__table",()=>Xe("table")),qe(t.jsx(z.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",He),At(),qe(t.jsx(z.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),qe(t.jsx(z.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>ne("p"))]}),At(),t.jsx("button",{type:"button",title:_?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:it,onMouseDown:Ee=>{Ee.preventDefault(),de(_)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:_?t.jsx(z.HiArrowsPointingIn,{className:"h-4 w-4"}):t.jsx(z.HiArrowsPointingOut,{className:"h-4 w-4"})})]})};return t.jsxs(t.Fragment,{children:[yr(),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:at,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":d,onInput:gr,onKeyDown:vr,onKeyUp:nt,onSelect:nt,onMouseUp:nt,onMouseMove:mt,onMouseLeave:gt,onContextMenu:Qe,onMouseDown:ct,"data-placeholder":n,className:`rich-editor px-3 py-2 text-sm focus:outline-none${M?" 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:ie,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:gr,onKeyDown:vr,onKeyUp:nt,onSelect:nt,onMouseUp:nt,onMouseMove:mt,onMouseLeave:gt,onContextMenu:Qe,onMouseDown:ct,"data-placeholder":n,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${M?" 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"),Af=/[a-zA-Z0-9._@-]/,vn=new Set([" ",`
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]+?```/,Tf=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},$f=e=>new RegExp("\\p{L}","u").test(e),Ao=(e,r)=>{const n=e.trim();return!n||!$f(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),y=s.useRef(!1),k=s.useRef(e??""),g=s.useRef(r),H=s.useRef(()=>{}),S=s.useRef(!1),[$,O]=s.useState(()=>!e||e.trim()===""),[C,v]=s.useState(new Set),[T,x]=s.useState(null),[P,W]=s.useState(""),[U,L]=s.useState(""),[J,q]=s.useState(""),[re,R]=s.useState(""),[fe,ee]=s.useState(3),[j,Z]=s.useState(3),[M,_]=s.useState(!0),[ce,B]=s.useState(!1),[ne,K]=s.useState(l==="full"),[Y,se]=s.useState(null),[E,Q]=s.useState(null),ie=s.useRef(null),X=s.useRef(!1),w=s.useRef(null),N=s.useCallback(()=>y.current?b.current:h.current,[]);s.useEffect(()=>{g.current=r},[r]);const te=s.useCallback(()=>{const F=window.getSelection(),G=N();if(!F||!G||F.rangeCount===0||F.isCollapsed)return"";const pe=F.getRangeAt(0);return!G.contains(pe.startContainer)||!G.contains(pe.endContainer)?"":F.toString()},[N]);s.useEffect(()=>{const F=e??"";if(S.current&&F===k.current){S.current=!1,O(!F||F.trim()==="");return}S.current=!1,k.current=F;const G=[h.current,b.current].filter(he=>!!he);G.forEach(he=>{he.innerHTML!==F&&(he.innerHTML=F)}),O(!F||F.trim()===""),G.forEach(he=>Mo(he));const pe=G.map(he=>Hl(he));return()=>pe.forEach(he=>he())},[e]),s.useEffect(()=>{var he,Ee;y.current=ce;let F,G=0,pe;if(ce){const ke=h.current;ke&&(k.current=ta(ke));const Fe=()=>{var dt;const Pe=b.current;if(!Pe){G=requestAnimationFrame(Fe);return}Pe.innerHTML!==k.current&&(Pe.innerHTML=k.current),F=Hl(Pe),Mo(Pe),O(((dt=Pe.textContent)==null?void 0:dt.trim())===""),pe=setTimeout(()=>Pe.focus(),60)};G=requestAnimationFrame(Fe)}else{const ke=b.current,Fe=h.current,Pe=ke?ta(ke):k.current,dt=k.current;k.current=Pe,Fe&&Fe.innerHTML!==Pe&&(Fe.innerHTML=Pe),Pe!==dt&&g.current(Pe),O(((Ee=(he=ke??Fe)==null?void 0:he.textContent)==null?void 0:Ee.trim())==="")}return()=>{G&&cancelAnimationFrame(G),pe&&clearTimeout(pe),F==null||F()}},[ce]);const ue=s.useCallback(()=>{const F=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],G=new Set;F.forEach(he=>{try{u().queryCommandState(he)&&G.add(he)}catch{return}});try{const he=hf(u().queryCommandValue("formatBlock"));he&&G.add(`formatBlock:${he}`)}catch{}const pe=te();Ao(pe,"uppercase")&&G.add("__upper"),Ao(pe,"lowercase")&&G.add("__lower"),Ao(pe,"capitalize")&&G.add("__cap");try{const he=window.getSelection();let Ee=(he==null?void 0:he.anchorNode)??null;(Ee==null?void 0:Ee.nodeType)===Node.TEXT_NODE&&(Ee=Ee.parentElement),Ee instanceof Element&&Ee.closest(".rich-code-wrap")&&G.add("__code")}catch{}v(G)},[te,u]),oe=()=>{var G;const F=N();F&&(Tf(F),k.current=ta(F),S.current=!0,g.current(k.current),O(((G=F.textContent)==null?void 0:G.trim())===""))};H.current=oe;const ge=s.useCallback(()=>{w.current&&(clearTimeout(w.current),w.current=null),ie.current&&(Cl(ie.current),ie.current=null),X.current=!1,se(null),Q(null)},[]),Me=s.useCallback(()=>{w.current&&(clearTimeout(w.current),w.current=null)},[]),Ae=s.useCallback(()=>{Me(),w.current=setTimeout(()=>{X.current||ge()},280)},[Me,ge]);s.useEffect(()=>()=>{w.current&&clearTimeout(w.current)},[]);const $t=s.useCallback(F=>{const G=ie.current;if(!G||!G.isConnected){ge();return}const pe=(Y==null?void 0:Y.rowIndex)??(E==null?void 0:E.rowIndex)??-1,he=(Y==null?void 0:Y.colIndex)??(E==null?void 0:E.colIndex)??-1;lf(F,G,pe,he,N()),ge(),H.current(),ue()},[N,ge,ue,E,Y]),mt=s.useCallback(F=>{if(E)return;const G=F.currentTarget,pe=F.target;if(pe.closest(".rich-table-action-bar, .rich-table-context-menu")){Me();return}const he=pe.closest("td, th");if(!he||!G.contains(he)){Ae();return}const Ee=he.closest("tr"),ke=he.closest("table");if(!Ee||!ke||!G.contains(ke)){Ae();return}Me(),ke.classList.add("rich-table"),ie.current=ke,Sl(ke,Ee,he.cellIndex),se(sf(ke,Ee,he))},[Me,Ae,E]),gt=s.useCallback(F=>{const G=F.relatedTarget;if(G instanceof Element&&(G.closest(".rich-table-action-bar")||G.closest(".rich-table-context-menu"))){Me();return}Ae()},[Me,Ae]),Qe=s.useCallback(F=>{const G=F.currentTarget,he=F.target.closest("td, th");if(!he||!G.contains(he))return;const Ee=he.closest("tr"),ke=he.closest("table");if(!Ee||!ke||!G.contains(ke))return;F.preventDefault(),ke.classList.add("rich-table"),ie.current=ke;const Fe=Array.from(ke.rows).indexOf(Ee),Pe=he.cellIndex;Sl(ke,Ee,Pe),se(null),Q({x:F.clientX,y:F.clientY,rowIndex:Fe,colIndex:Pe})},[]);s.useEffect(()=>{if(!Y&&!E)return;const F=()=>Ae();return window.addEventListener("scroll",F,!0),window.addEventListener("resize",F),()=>{window.removeEventListener("scroll",F,!0),window.removeEventListener("resize",F)}},[Ae,E,Y]),s.useEffect(()=>{if(!E)return;const F=G=>{const pe=G.target;pe instanceof Element&&pe.closest(".rich-table-context-menu")||Q(null)};return window.addEventListener("mousedown",F),()=>window.removeEventListener("mousedown",F)},[E]);const de=F=>{if(!F){const G=h.current;G&&(k.current=ta(G))}B(!F)},Te=(F,G)=>{var pe;(pe=N())==null||pe.focus(),u().execCommand(F,!1,G),oe(),ue()},ae=F=>{Te("formatBlock",F)},He=()=>{var F;(F=N())==null||F.focus(),u().execCommand("insertHTML",!1,"<hr><p><br></p>"),oe(),ue()},ze=()=>{const F=window.getSelection();F&&F.rangeCount>0&&(p.current=F.getRangeAt(0).cloneRange())},Ye=()=>{const F=window.getSelection();F&&p.current&&(F.removeAllRanges(),F.addRange(p.current))},Xe=F=>{if(ze(),F==="link"){const G=window.getSelection();L(G&&!G.isCollapsed?G.toString():""),W("")}F==="image"&&(q(""),R("")),F==="table"&&(ee(3),Z(3),_(!0)),x(F)},We=()=>{var he;if(!P.trim())return;Ye(),(he=N())==null||he.focus();const F=window.getSelection(),pe=(F&&!F.isCollapsed?F.toString():"")||U.trim()||P.trim();u().execCommand("insertHTML",!1,`<a href="${_r(P.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${_r(pe)}</a>`),oe(),x(null)},Je=(F,G="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${_r(F)}" alt="${_r(G)}" class="rich-img" />${Al()}</span>`,vt=()=>{var F;J.trim()&&(Ye(),(F=N())==null||F.focus(),u().execCommand("insertHTML",!1,Je(J.trim(),re.trim())),oe(),x(null))},ft=()=>{var F;Ye(),(F=N())==null||F.focus(),u().execCommand("insertHTML",!1,bf(fe,j,M)),oe(),x(null)},yt=()=>{var pe;Ye(),(pe=N())==null||pe.focus();const F=window.getSelection(),G=F&&!F.isCollapsed?F.toString():"";u().execCommand("insertHTML",!1,$o(G)),oe()},me=(F,G=1200,pe=1200,he=.72)=>new Promise((Ee,ke)=>{const Fe=new FileReader;Fe.onerror=ke,Fe.onload=Pe=>{var wt;const dt=(wt=Pe.target)==null?void 0:wt.result,Ke=new Image;Ke.onerror=ke,Ke.onload=()=>{let{width:Zt,height:Nt}=Ke;if(Zt>G||Nt>pe){const dr=Math.min(G/Zt,pe/Nt);Zt=Math.round(Zt*dr),Nt=Math.round(Nt*dr)}const xr=document.createElement("canvas");xr.width=Zt,xr.height=Nt;const Qt=xr.getContext("2d");if(!Qt){Ee(dt);return}Qt.drawImage(Ke,0,0,Zt,Nt),Ee(xr.toDataURL("image/jpeg",he))},Ke.src=dt},Fe.readAsDataURL(F)}),ye=F=>{F.focus();const G=window.getSelection();if(!G||G.rangeCount===0||!F.contains(G.anchorNode)){const pe=document.createRange();pe.selectNodeContents(F),pe.collapse(!1),G==null||G.removeAllRanges(),G==null||G.addRange(pe)}},Be=s.useRef(()=>{});Be.current=F=>{const G=N();G&&(ye(G),u().execCommand("insertHTML",!1,F),Mo(G),G.querySelectorAll("p").forEach(pe=>{!(pe.textContent??"").replace(/[\u00a0\s]+/g,"")&&!pe.querySelector("img, hr, table")&&pe.remove()}),oe(),ue())};const _e=s.useRef(me);_e.current=me;const Ge=s.useRef(Je);Ge.current=Je;const rt=s.useCallback(F=>{if(!F||f.current.has(F))return;const G=pe=>{const he=pe.clipboardData;if(!he)return;const Ee=he.getData("text/html"),ke=he.getData("text/plain");if(Ee||ke){pe.preventDefault(),pe.stopPropagation();try{const Ke=Ee?Mf(Ee):gn(ke);if(!Ke){ke&&Be.current(gn(ke));return}Be.current(Ke)}catch{ke&&Be.current(gn(ke))}return}const Pe=Array.from(he.items).find(Ke=>Ke.type.startsWith("image/"));if(!Pe)return;pe.preventDefault(),pe.stopPropagation();const dt=Pe.getAsFile();dt&&_e.current(dt).then(Ke=>{Be.current(Ge.current(Ke,"imagen"))})};F.addEventListener("paste",G,!0),f.current.set(F,()=>{F.removeEventListener("paste",G,!0),f.current.delete(F)})},[]),at=s.useCallback(F=>{var pe;const G=h.current;G&&G!==F&&((pe=f.current.get(G))==null||pe()),h.current=F,F&&rt(F)},[rt]),Re=s.useCallback(F=>{var pe;const G=b.current;G&&G!==F&&((pe=f.current.get(G))==null||pe()),b.current=F,F&&rt(F)},[rt]);s.useEffect(()=>{const F=f.current;return()=>{F.forEach(G=>G()),F.clear()}},[]);const st=F=>{const G=window.getSelection(),pe=N();if(!G||!pe||G.rangeCount===0||G.isCollapsed)return;const he=G.getRangeAt(0);if(!pe.contains(he.startContainer)||!pe.contains(he.endContainer))return;const Ee=he.toString();if(!Ee)return;let ke=Ee;F==="uppercase"?ke=Ee.toLocaleUpperCase():F==="lowercase"?ke=Ee.toLocaleLowerCase():ke=Ll(Ee),he.deleteContents();const Fe=document.createTextNode(ke);he.insertNode(Fe);const Pe=document.createRange();Pe.setStart(Fe,0),Pe.setEnd(Fe,ke.length),G.removeAllRanges(),G.addRange(Pe),p.current=Pe.cloneRange(),oe(),ue()},nt=()=>{ze(),ue()},gr=()=>{const F=N();F&&El(F),oe(),ue()},it=()=>{requestAnimationFrame(()=>{var F;(F=N())==null||F.focus()})},vr=F=>{var G,pe;if((F.metaKey||F.ctrlKey)&&F.key==="Enter"){if(F.preventDefault(),F.stopPropagation(),F.repeat)return;(G=N())==null||G.focus(),u().execCommand("insertLineBreak",!1)||u().execCommand("insertHTML",!1,"<br>"),oe(),ue();return}if(F.key==="Tab"){const he=window.getSelection(),Ee=Tl((he==null?void 0:he.anchorNode)??null),ke=N(),Fe=Ml(Ee);if(Ee&&Fe&&(ke!=null&&ke.contains(Ee))){F.preventDefault();const Pe=df(Fe),dt=Pe.indexOf(Ee),Ke=dt>=0?Pe[dt+1]:null;if(Ke)na(Ke,ke,!0);else if($l(Ee,Fe)){const wt=Eo(Fe);wt&&na(wt,ke,!0)}oe(),ue();return}F.preventDefault(),(pe=N())==null||pe.focus(),u().execCommand("insertText",!1,"    "),oe(),ue();return}if(F.key==="Enter"&&!F.shiftKey&&!(F.metaKey||F.ctrlKey)){const he=window.getSelection(),Ee=Tl((he==null?void 0:he.anchorNode)??null),ke=N(),Fe=Ml(Ee);if(Ee&&Fe&&(ke!=null&&ke.contains(Ee))&&$l(Ee,Fe)&&uf(Ee)){F.preventDefault();const Pe=Eo(Fe);Pe&&na(Pe,ke,!0),oe(),ue();return}}if(F.key==="Escape"){if(E){Q(null);return}if(T){x(null);return}if(y.current){B(!1);return}}T||(F.ctrlKey||F.metaKey)&&(F.key==="b"&&(F.preventDefault(),Te("bold")),F.key==="i"&&(F.preventDefault(),Te("italic")),F.key==="u"&&(F.preventDefault(),Te("underline")),F.key==="k"&&(F.preventDefault(),Xe("link")))},At=()=>t.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),qe=(F,G,pe,he,Ee)=>{const ke=Ee??(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:it,onMouseDown:Fe=>{Fe.preventDefault(),he?he():Te(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:F},pe)},ct=F=>{const G=F.target;if(G.closest("[data-action='delete-img']")){F.preventDefault();const he=G.closest(".rich-img-wrap");he&&(he.remove(),oe());return}const pe=G.closest("[data-action='copy-code']");pe instanceof HTMLButtonElement&&(F.preventDefault(),yl(pe).catch(()=>{}))},ir=()=>{Me(),X.current=!0},xt=()=>{X.current=!1,Ae()},Ft=(F,G,pe,he=!1)=>t.jsx("button",{type:"button",className:`rich-table-action-btn${he?" rich-table-action-btn--danger":""}`,title:F,"aria-label":F,onMouseDown:Ee=>{Ee.preventDefault(),Ee.stopPropagation(),$t(pe)},children:G}),yr=()=>typeof document>"u"||!Y&&!E?null:ht.createPortal(t.jsxs(t.Fragment,{children:[Y&&!E&&t.jsxs("div",{className:"rich-table-action-bar",style:{left:Y.bar.x,top:Y.bar.y},onMouseEnter:ir,onMouseLeave:xt,children:[t.jsxs("span",{className:"rich-table-action-hint",children:["Fila ",Y.rowIndex+1," · Col ",Y.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:F=>F.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(([F,G])=>t.jsx("button",{type:"button",onMouseDown:pe=>{pe.preventDefault(),$t(G)},children:F},G))})]}),document.body),cr=F=>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:F},children:[t.jsx("input",{autoFocus:!0,type:"url",value:P,onChange:G=>W(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),We()),G.key==="Escape"&&x(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=>L(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),We()),G.key==="Escape"&&x(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:We,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:()=>x(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:F},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=>ee(Rn(Number(G.target.value),1,Fr)),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),ft()),G.key==="Escape"&&x(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:j,onChange:G=>Z(Rn(Number(G.target.value),1,ea)),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),ft()),G.key==="Escape"&&x(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:M,onChange:G=>_(G.target.checked)}),"Encabezado"]}),t.jsx("button",{type:"button",onClick:ft,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:()=>x(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:F},children:[t.jsx("input",{autoFocus:!0,type:"url",value:J,onChange:G=>q(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),vt()),G.key==="Escape"&&x(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:re,onChange:G=>R(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),vt()),G.key==="Escape"&&x(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:vt,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:()=>x(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),Kr=(F,G)=>{const pe=l==="compact",he=!pe||ne||F;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&&!F&&t.jsxs("button",{type:"button",title:ne?"Ocultar herramientas":"Mostrar herramientas de formato",tabIndex:-1,onFocus:it,onMouseDown:Ee=>{Ee.preventDefault(),K(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:ne?"color-mix(in srgb, var(--primary) 12%, transparent)":"transparent"},children:[ne?t.jsx(z.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(z.HiChevronDown,{className:"h-3.5 w-3.5"}),ne?"Ocultar herramientas":"Herramientas"]}),he&&t.jsxs(t.Fragment,{children:[qe(t.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),qe(t.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),qe(t.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),qe(t.jsx(z.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),qe(t.jsx(z.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),qe(t.jsx(z.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>Xe("link")),At(),qe(t.jsx(z.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),qe(t.jsx(z.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),At(),qe(t.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>ae("p"),C.has("formatBlock:p")||C.has("formatBlock:div")),qe(t.jsx(z.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>ae("h2"),C.has("formatBlock:h2")),qe(t.jsx(z.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>ae("h3"),C.has("formatBlock:h3")),qe(t.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>ae("blockquote"),C.has("formatBlock:blockquote")),qe(t.jsx("span",{style:{fontFamily:"ui-monospace, monospace",fontSize:"10px"},children:"</>"}),"Bloque de código","__code",()=>yt(),C.has("__code")),At(),qe(t.jsx("s",{children:"S"}),"Tachado","strikeThrough"),At(),qe(t.jsx(z.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),qe(t.jsx(z.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),At(),qe(t.jsx(z.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),qe(t.jsx(z.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),qe(t.jsx(z.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),qe(t.jsx(z.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),At(),qe(t.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>st("uppercase")),qe(t.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>st("lowercase")),qe(t.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>st("capitalize")),At(),qe(t.jsx(z.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),qe(t.jsx(z.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>Xe("image")),qe(t.jsx(z.HiTableCells,{className:"h-4 w-4"}),"Insertar tabla","__table",()=>Xe("table")),qe(t.jsx(z.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",He),At(),qe(t.jsx(z.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),qe(t.jsx(z.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>ae("p"))]}),At(),t.jsx("button",{type:"button",title:F?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:it,onMouseDown:Ee=>{Ee.preventDefault(),de(F)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:F?t.jsx(z.HiArrowsPointingIn,{className:"h-4 w-4"}):t.jsx(z.HiArrowsPointingOut,{className:"h-4 w-4"})})]})};return t.jsxs(t.Fragment,{children:[yr(),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:at,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":d,onInput:gr,onKeyDown:vr,onKeyUp:nt,onSelect:nt,onMouseUp:nt,onMouseMove:mt,onMouseLeave:gt,onContextMenu:Qe,onMouseDown:ct,"data-placeholder":n,className:`rich-editor px-3 py-2 text-sm focus:outline-none${$?" 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:gr,onKeyDown:vr,onKeyUp:nt,onSelect:nt,onMouseUp:nt,onMouseMove:mt,onMouseLeave:gt,onContextMenu:Qe,onMouseDown:ct,"data-placeholder":n,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${$?" 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"),Af=/[a-zA-Z0-9._@-]/,vn=new Set([" ",`
34
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)||!Af.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 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 Lf(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 Df(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 Of=new Set(["P","DIV","LI","H1","H2","H3","H4","H5","H6","BLOCKQUOTE"]);function Vl(e,r){return Of.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:N}=r.domPoint;g===f&&N===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 N=Array.from(f.childNodes);for(let v=0;v<N.length;v+=1){const H=N[v],S=v>0&&H.nodeType===Node.ELEMENT_NODE&&Vl(H,e);if(h(H,S))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(),N=g!=null&&g.rangeCount?la(e,g.getRangeAt(0).startContainer,g.getRangeAt(0).startOffset):n+u.length+1;return{caretPlainOffset:N>=0?N: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 N=g;g=g[p],N.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,Hf=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),ri=4,Bf={position:"relative"},If={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 Ff(e){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(e)}"]`))}function _f(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),N=s.useRef(null),v=s.useRef(new Map),H=s.useRef(n);H.current=n;const S=s.useRef(null),M=s.useRef(0),D=s.useRef([]),C=s.useRef(null),[x,$]=s.useState(null),[y,P]=s.useState([]),[j,U]=s.useState(0),[L,J]=s.useState([]),[q,ae]=s.useState(!1),[R,fe]=s.useState(!1);M.current=j,s.useEffect(()=>{fe(!0)},[]);const I=(x==null?void 0:x.query)??null;s.useEffect(()=>{if(I===null){P([]);return}const Y=I.trim(),se=`${h}|${Y.toLowerCase()||"*"}`,E=v.current.get(se);if(E){P(E),ae(!1),U(0);return}const Q=new AbortController;ae(!0);const ce=window.setTimeout(()=>{(async()=>{try{const X=await H.current(Y,{signal:Q.signal,limit:c});if(Q.signal.aborted)return;const w=Array.isArray(X)?X:[];v.current.set(se,w),P(w),U(0)}catch{Q.signal.aborted||P([])}finally{Q.signal.aborted||ae(!1)}})()},d);return()=>{Q.abort(),window.clearTimeout(ce)}},[I,c,d,h]);const K=s.useRef(a);K.current=a,s.useEffect(()=>{var Y;(Y=K.current)==null||Y.call(K,ql(L))},[L]);const ee=s.useCallback(()=>{const Y=Ff(p);if(Y.length===0)return null;const se=window.getSelection();if(se!=null&&se.rangeCount){const Q=se.getRangeAt(0).startContainer;for(const ce of Y)if(ce.contains(Q))return ce}const E=document.activeElement;for(const Q of Y)if(E===Q||E&&Q.contains(E))return Q;for(const Q of Y)if(Q.closest('[role="dialog"]'))return Q;return Y[0]??null},[p]),T=s.useCallback(()=>{const Y=ee(),se=window.getSelection();if(!Y||!se||se.rangeCount===0){$(null);return}const E=se.getRangeAt(0);if(!Y.contains(E.startContainer)){$(null);return}const Q=la(Y,E.startContainer,E.startOffset);if(Q<0){$(null);return}const ce=Do(Y,Q);if(!ce){$(null);return}const X=E.getBoundingClientRect(),w=X.width===0&&X.height===0?(()=>{const te=document.createRange();return te.selectNodeContents(E.startContainer),te.collapse(!0),te.getBoundingClientRect()})():X;S.current={query:ce.query,caretIndex:ce.caretIndex,triggerIndex:ce.triggerIndex};const k=_f(w);$(te=>{const ue={query:ce.query,...k};return te&&te.query===ue.query&&te.top===ue.top&&te.bottom===ue.bottom&&te.left===ue.left&&te.maxHeight===ue.maxHeight?te:ue})},[ee]),W=s.useCallback(Y=>{r(Y),T()},[r,T]);s.useEffect(()=>{const Y=se=>{if(Hf.has(se.key))return;const E=ee(),Q=se.target;!E||!Q||!E.contains(Q)||T()};return document.addEventListener("keyup",Y,!0),()=>document.removeEventListener("keyup",Y,!0)},[ee,T]);const ie=s.useCallback(Y=>{const se=ee();if(!se)return;let E=-1;const Q=window.getSelection();if(Q&&Q.rangeCount>0){const te=Q.getRangeAt(0);se.contains(te.startContainer)&&(E=la(se,te.startContainer,te.startOffset))}if(E<0&&S.current&&(E=S.current.caretIndex),E<0)return;const ce=Do(se,E);if(!ce)return;const X=Xl(se,{triggerIndex:ce.triggerIndex,caretIndex:E,username:Y.username,display:Y.name,userId:Y.userId});if(!X)return;yn(se),se.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}));const w={userId:Y.userId,username:Y.username,email:Y.email??void 0,display:Y.name??Y.username};J(te=>{const ue=new Map(te.map(oe=>[oe.userId,oe]));return ue.set(w.userId,w),Array.from(ue.values())}),$(null),S.current=null;const k=Y.username.toLowerCase();requestAnimationFrame(()=>{requestAnimationFrame(()=>{const te=ee();if(!te)return;te.focus(),yn(te);const ue=Array.from(te.querySelectorAll(".mention-chip")),oe=[...ue].reverse().find(ge=>ge.getAttribute("data-username")===k)??ue[ue.length-1];if(oe){Io(oe);return}Yl(te,X.caretPlainOffset)})})},[ee]);s.useEffect(()=>{const Y=new Set(Ho(e).map(se=>se.toLowerCase()));J(se=>{const E=se.filter(Q=>Y.has(Q.username.toLowerCase()));return E.length===se.length?se:E})},[e]),s.useEffect(()=>{if(!x)return;const Y=se=>{const E=se.target;if(!E||g.current&&g.current.contains(E)||N.current&&N.current.contains(E))return;const Q=ee();Q&&Q.contains(E)||$(null)};return document.addEventListener("mousedown",Y),()=>{document.removeEventListener("mousedown",Y)}},[x,ee]);const B=s.useMemo(()=>y.slice(0,c),[y,c]);D.current=B,s.useEffect(()=>{if(!x)return;const Y=se=>{const E=ee(),Q=se.target;if(!E||!Q||!E.contains(Q))return;const ce=D.current;if(!(ce.length===0&&se.key!=="Escape"))if(se.key==="ArrowDown")se.preventDefault(),se.stopPropagation(),U(X=>(X+1)%Math.max(ce.length,1));else if(se.key==="ArrowUp")se.preventDefault(),se.stopPropagation(),U(X=>(X-1+ce.length)%Math.max(ce.length,1));else if(se.key==="Enter"||se.key==="Tab"){const X=ce[M.current];X&&(se.preventDefault(),se.stopPropagation(),ie(X))}else se.key==="Escape"&&(se.preventDefault(),se.stopPropagation(),$(null))};return document.addEventListener("keydown",Y,!0),()=>document.removeEventListener("keydown",Y,!0)},[ee,ie,x]),s.useEffect(()=>{const Y=w=>{w.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}))},se=w=>{const k=ee(),te=w.target;if(!k||!te||!k.contains(te))return;if((w.metaKey||w.ctrlKey)&&w.key.toLowerCase()==="a"){w.preventDefault(),w.stopPropagation(),k.focus(),Zl(k);return}if(w.key!=="Backspace"&&w.key!=="Delete")return;const ue=window.getSelection();if(ue&&!ue.isCollapsed&&ue.rangeCount>0){const Me=ue.getRangeAt(0);if(k.contains(Me.commonAncestorContainer)&&Po(k).length>0&&Ql(Me)){w.preventDefault(),w.stopPropagation(),Jl(k)&&Y(k);return}}const oe=Po(k);if(oe.length>0){w.preventDefault(),w.stopPropagation();for(const Me of oe)da(Me);zr(k),Y(k);return}if(w.key==="Backspace"){const Me=Rl(k);if(!Me)return;w.preventDefault(),w.stopPropagation(),da(Me),zr(k),Y(k);return}const ge=ei(k);ge&&(w.preventDefault(),w.stopPropagation(),da(ge),zr(k),Y(k))},E=w=>{const k=ee();if(!k)return;const te=w.target;if(!(te instanceof Element)||!k.contains(te))return;const ue=te.closest(".mention-chip");if(!(ue instanceof HTMLElement)||!k.contains(ue)){C.current=null,zr(k);return}w.shiftKey||w.button!==0||(C.current={chip:ue,x:w.clientX,y:w.clientY})},Q=w=>{const k=C.current;if(!k)return;const te=Math.abs(w.clientX-k.x),ue=Math.abs(w.clientY-k.y);(te>ri||ue>ri)&&(C.current=null)},ce=w=>{var ge;const k=ee(),te=C.current;if(C.current=null,!k||!te)return;const ue=w.target;if(!(ue instanceof Element)||!k.contains(ue)||!((ge=ue.closest(".mention-chip"))!=null&&ge.isSameNode(te.chip)))return;const oe=window.getSelection();if(oe){if(!oe.isCollapsed){ca(k);return}k.focus(),Kl(te.chip)}},X=()=>{const w=ee();if(!w)return;const k=window.getSelection();!k||k.rangeCount===0||!k.anchorNode||!w.contains(k.anchorNode)||!k.focusNode||!w.contains(k.focusNode)||ca(w)};return document.addEventListener("keydown",se,!0),document.addEventListener("mousedown",E,!0),document.addEventListener("mousemove",Q,!0),document.addEventListener("mouseup",ce,!0),document.addEventListener("selectionchange",X),()=>{document.removeEventListener("keydown",se,!0),document.removeEventListener("mousedown",E,!0),document.removeEventListener("mousemove",Q,!0),document.removeEventListener("mouseup",ce,!0),document.removeEventListener("selectionchange",X)}},[ee]),s.useEffect(()=>{if(!x||!N.current)return;const Y=N.current.querySelector(`[data-mention-index="${j}"]`);Y==null||Y.scrollIntoView({block:"nearest"})},[j,x]);const re=u?Ul(e):e,Z=x&&R?ht.createPortal(t.jsxs("ul",{ref:N,style:{...If,left:x.left,top:x.top,bottom:x.bottom,maxHeight:x.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[q&&B.length===0&&t.jsx("li",{style:ni,children:"Buscando…"}),!q&&B.length===0&&t.jsx("li",{style:ni,children:x.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${x.query}”`}),B.map((Y,se)=>{var E,Q;return t.jsx("li",{children:t.jsxs("button",{type:"button","data-mention-index":se,onMouseDown:ce=>{ce.preventDefault(),ie(Y)},onMouseEnter:()=>U(se),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:se===j?"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=Y.name)==null?void 0:E.trim())||`@${Y.username}`}),t.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[(Q=Y.name)!=null&&Q.trim()?`@${Y.username}`:null,Y.email].filter(Boolean).join(" · ")||`@${Y.username}`})]})},Y.userId)})]}),document.body):null;return t.jsxs("div",{ref:g,style:Bf,className:i,children:[t.jsx(Bl,{value:re,onChange:W,placeholder:l,minHeight:o,instanceId:p,toolbarVariant:b,focusModalZIndex:f}),Z]})}function Pf({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 zf({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 Wf={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)"}},jf={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 qf({children:e,tone:r="neutral",size:n="sm",icon:a,dot:o=!1,className:l=""}){const i=Wf[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 ${jf[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)"}},Uf={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"},Vf={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},Xf={xs:148,sm:164,md:184},Yf={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 Gf({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,N]=s.useState(!1),[v,H]=s.useState(!1),[S,M]=s.useState(-1),[D,C]=s.useState({}),x=s.useRef(null),$=s.useRef(null),y=s.useRef(null),P=r.find(I=>I.value===e)??r[0],j={...P!=null&&P.tone?oi[P.tone]:void 0,...P==null?void 0:P.style},U=o||l||r.length===0,L=I=>{i&&I.stopPropagation()},J=s.useCallback(()=>{N(!1),M(-1)},[]),q=s.useCallback(()=>{const I=x.current;if(!I)return;const K=I.getBoundingClientRect(),ee=Math.max(K.width,Xf[a]),T=Math.min(Math.max(r.length,1)*38+12,260),W=window.innerHeight-K.bottom,ie=W<T&&K.top>W,B=Math.min(Math.max(8,K.left+K.width/2-ee/2),window.innerWidth-ee-8);C({position:"fixed",left:B,top:ie?void 0:K.bottom+6,bottom:ie?window.innerHeight-K.top+6:void 0,width:ee,zIndex:9999})},[r.length,a]),ae=s.useCallback(I=>{I.disabled||(n(I.value),J())},[J,n]);s.useEffect(()=>H(!0),[]),s.useEffect(()=>{if(!g)return;q();const I=r.findIndex(K=>K.value===e);M(I>=0?I:0)},[g,r,q,e]),s.useEffect(()=>{if(!g)return;function I(K){var T,W;const ee=K.target;!((T=x.current)!=null&&T.contains(ee))&&!((W=$.current)!=null&&W.contains(ee))&&J()}return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[J,g]),s.useEffect(()=>{if(g)return window.addEventListener("resize",q),window.addEventListener("scroll",q,!0),()=>{window.removeEventListener("resize",q),window.removeEventListener("scroll",q,!0)}},[g,q]),s.useEffect(()=>{if(S<0||!y.current)return;const I=y.current.children[S];I==null||I.scrollIntoView({block:"nearest"})},[S]);function R(I){if(!U){if(!g){["Enter"," ","ArrowDown","ArrowUp"].includes(I.key)&&(I.preventDefault(),N(!0));return}if(I.key==="Escape"){I.preventDefault(),J();return}if(I.key==="ArrowDown"){I.preventDefault(),M(K=>Math.min(K+1,r.length-1));return}if(I.key==="ArrowUp"){I.preventDefault(),M(K=>Math.max(K-1,0));return}if(I.key==="Enter"||I.key===" "){I.preventDefault();const K=r[S];K&&ae(K)}}}const fe=t.jsx("div",{ref:$,role:"listbox","aria-label":c,className:Rt("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",b),style:{...D,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:L,onMouseDown:L,onPointerDown:L,children:t.jsx("div",{ref:y,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:r.map((I,K)=>{const ee=I.value===e,T=K===S,W={...I.tone?oi[I.tone]:void 0,...I.style};return t.jsxs("button",{type:"button",role:"option","aria-selected":ee,disabled:I.disabled,onMouseEnter:()=>!I.disabled&&M(K),onMouseDown:ie=>{ie.preventDefault(),ae(I)},className:Rt("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",Yf[a],ee?I.className:void 0,f),style:{...ee?W:void 0,background:ee?W.background??"color-mix(in srgb, var(--primary) 12%, transparent)":T?"var(--bg-hover)":"transparent",color:ee?W.color??"var(--primary)":"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:ee?t.jsx(z.HiCheck,{className:"h-4 w-4"}):null}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:I.label})]},I.value)})})});return t.jsxs("span",{ref:x,className:Rt("relative inline-flex shrink-0 items-center",u),onKeyDown:R,onClick:L,onPointerDown:L,children:[t.jsx("button",{type:"button",disabled:U,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":g,title:d,onClick:()=>!U&&N(I=>!I),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",Uf[a],P==null?void 0:P.className,h),style:j,children:t.jsx("span",{className:"min-w-0 truncate",children:(P==null?void 0:P.label)??e})}),t.jsx(z.HiChevronDown,{"aria-hidden":"true",className:Rt("pointer-events-none absolute opacity-70 transition-transform",Vf[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&&ht.createPortal(fe,document.body)]})}function Kf({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 N=e.filter(H=>!H.disabled);if(!N.length||!b)return;const v=N.findIndex(H=>H.id===b.id);(g.key==="ArrowRight"||g.key==="ArrowDown")&&(g.preventDefault(),f(N[(v+1)%N.length])),(g.key==="ArrowLeft"||g.key==="ArrowUp")&&(g.preventDefault(),f(N[(v-1+N.length)%N.length])),g.key==="Home"&&(g.preventDefault(),f(N[0])),g.key==="End"&&(g.preventDefault(),f(N[N.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 N=g.id===(b==null?void 0:b.id);return t.jsxs("button",{type:"button",role:"tab","aria-selected":N,"aria-controls":`${g.id}-panel`,id:`${g.id}-tab`,disabled:g.disabled,tabIndex:N?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:N?"var(--primary)":"var(--text-muted)",borderColor:N?"var(--primary)":"transparent",background:l==="pills"&&N?"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 Zf({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:N="",footerClassName:v=""}){var se;const H=((se=e[0])==null?void 0:se.id)??"",[S,M]=s.useState(n??H),[D,C]=s.useState(o),x=r??S,$=a??D,y=s.useMemo(()=>new Set($),[$]),P=Math.max(0,e.findIndex(E=>E.id===x)),j=e[P]??e[0],U=e.length<=1?100:P/(e.length-1)*100,L=E=>{a||C(E),i==null||i(E)},J=E=>{const Q=e.find(ce=>ce.id===E);Q&&(r||M(E),l==null||l(E,Q))},q=E=>y.has(E),ae=E=>e.slice(0,E).find(Q=>!Q.optional&&!y.has(Q.id)),R=E=>{const Q=e[E];return!Q||Q.disabled?!1:E===P||d&&E<P?!0:!ae(E)},fe=E=>{const Q=e.findIndex(ce=>ce.id===E);return Q>=0&&R(Q)},I=E=>{const Q=e.findIndex(ce=>ce.id===E);if(Q<0)return!1;if(!R(Q)){const ce=ae(Q);return ce&&(c==null||c(e[Q],ce)),!1}return J(E),!0},K=(E=j==null?void 0:j.id)=>{!E||y.has(E)||L([...$,E])},ee=(E=j==null?void 0:j.id)=>{if(!E)return;const Q=e.findIndex(X=>X.id===E),ce=$.filter(X=>{const w=e.findIndex(k=>k.id===X);return w>=0&&w<Q});L(ce),Q>=0&&P>Q&&J(E)},T=()=>P<=0?!1:I(e[P-1].id),W=()=>{const E=e[P+1];return E?I(E.id):!1},ie={activeStep:j,activeIndex:P,completedStepIds:$,isCompleted:q,isUnlocked:fe,completeStep:K,uncompleteStep:ee,goToStep:I,goNext:W,goPrevious:T};if(!j)return null;const B=e[P+1],re=P>0,Z=B?fe(B.id):!1,Y=typeof j.content=="function"?j.content(ie):j.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,Q)=>{const ce=E.id===j.id,X=q(E.id),w=R(Q),k=ae(Q);return t.jsxs("button",{type:"button",disabled:!w,"aria-current":ce?"step":void 0,"aria-disabled":!w,title:!w&&k?`Completa ${k.title}`:E.title,onClick:()=>I(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",ce&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",X&&!ce&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!ce&&!X&&w&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!w&&"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",ce&&"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",ce&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",X&&!ce&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!X&&!ce&&w&&"border-[var(--border)] text-[var(--text-muted)]",!w&&"border-[var(--border)] text-[var(--text-muted)]"),children:X?t.jsx(z.HiCheck,{className:"h-4 w-4"}):w?Q+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",ce?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[Q+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",N),children:Y},j.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(Ve,{variant:"secondary",height:38,padding:"0 14px",icon:t.jsx(z.HiChevronLeft,{}),disabled:!re,onClick:T,children:h}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[t.jsxs("span",{children:["Paso ",P+1," de ",e.length]}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),t.jsxs("span",{children:[$.length," completados"]})]}),t.jsx(Ve,{height:38,padding:"0 14px",icon:t.jsx(z.HiChevronRight,{}),disabled:!B||!Z,onClick:W,children:B&&!Z?f:b})]})]})}const Qf={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 Jf(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Rf(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}=Rf(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)",N=s.useCallback(()=>{const v=p.current;if(!v)return;v.style.height="auto";const H=v.scrollHeight,S=si(v,i),M=o??(l!==void 0?si(v,l):void 0),D=M!==void 0?Math.min(Math.max(H,S),M):Math.max(H,S);v.style.height=`${D}px`,v.style.overflowY=M!==void 0&&H>M?"auto":"hidden"},[o,l,i]);return s.useLayoutEffect(()=>{N()},[N,d,u]),s.useEffect(()=>{const v=p.current;if(!v||typeof ResizeObserver>"u")return;const H=new ResizeObserver(()=>N());return H.observe(v),()=>H.disconnect()},[N]),t.jsx("textarea",{...b,ref:v=>{p.current=v,Jf(f,v)},rows:i,value:d,defaultValue:u,"aria-invalid":a==="error"||b["aria-invalid"],onInput:v=>{N(),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 ${Qf[n]} ${r}`})});function eb({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 tb={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"},rb={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function nb(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function ab(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:N,maxLength:v,onInput:H,...S},M){const D=s.useRef(null),C=ab(g,N),x=u??v,$=!!(b||f||d),y=h==="error"?"var(--danger)":h==="success"?"#16a34a":"var(--border)",P={...p??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},j=()=>{const L=D.current;!L||!l||(L.style.height="auto",L.style.height=`${L.scrollHeight}px`)};s.useEffect(j,[l,g]);const U=t.jsx("textarea",{...S,ref:L=>{D.current=L,nb(M,L)},value:g,defaultValue:N,maxLength:v,"aria-invalid":h==="error"||S["aria-invalid"],onInput:L=>{j(),H==null||H(L)},style:{...P,borderColor:y},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 ${tb[a]} ${rb[l?"none":o]} ${b?"pl-8":""} ${f?"pr-10":""} ${r}`});return $?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,x?`/${x}`:""]})]}):U});function ob({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 sb(e){return ci[e%ci.length]}let lb=0;function Wo(){return++lb}function di(e,r){return r?r instanceof RegExp?r.test(e):r(e):!0}function ib(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function cb(e,r){const n=r.filter(Boolean);if(n.length===0)return[e.trim()].filter(Boolean);const a=new RegExp(`${n.map(o=>ib(o)).join("|")}|\\r?\\n`,"g");return e.split(a).map(o=>o.trim()).filter(Boolean)}function db({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 N=e!==void 0,v=!!p,H=!!b&&f==="tooltip"&&!v,[S,M]=s.useState(()=>(r??[]).map((X,w)=>({id:Wo(),value:X.trim(),colorIndex:w})));s.useEffect(()=>{N&&M(X=>{const w=e??[],k=new Map(X.map(te=>[te.value,te]));return w.map((te,ue)=>k.get(te)??{id:Wo(),value:te,colorIndex:ue})})},[N,e]);const D=S,[C,x]=s.useState(""),[$,y]=s.useState(null),[P,j]=s.useState(""),[U,L]=s.useState(!1),[J,q]=s.useState(!1),ae=s.useRef(null),R=s.useRef(null),fe=s.useRef(null);function I(){q(!0),setTimeout(()=>q(!1),400)}function K(X){M(X),n==null||n(X.map(w=>w.value))}function ee(X){let w=D,k=!1,te=!1;for(const ue of X){const oe=ue.trim();if(oe){if(c!==void 0&&w.length>=c){te=!0;break}if(!d&&w.some(ge=>ge.value.toLowerCase()===oe.toLowerCase())){te=!0;continue}if(!di(oe,u)){te=!0;continue}w=[...w,{id:Wo(),value:oe,colorIndex:w.length}],k=!0}}return k&&K(w),te&&I(),k}function T(X){return ee([X])}function W(X){const w=D.filter(k=>k.id!==X);K(w.map((k,te)=>({...k,colorIndex:te})))}function ie(X,w){const k=w.trim();if(y(null),j(""),!k){W(X);return}if(!(!d&&D.some(te=>te.id!==X&&te.value.toLowerCase()===k.toLowerCase()))){if(!di(k,u)){I();return}K(D.map(te=>te.id===X?{...te,value:k}:te))}}function B(X){o||(y(X.id),j(X.value),setTimeout(()=>{var w;return(w=R.current)==null?void 0:w.select()},0))}function re(X){if(X.key==="Enter"||i.includes(X.key)){X.preventDefault(),T(C)&&x("");return}if(X.key==="Backspace"&&C===""&&D.length>0){X.preventDefault();const w=D[D.length-1];W(w.id)}}function Z(X,w){if(X.key==="Enter"){X.preventDefault(),ie(w,P),setTimeout(()=>{var k;return(k=ae.current)==null?void 0:k.focus()},0);return}X.key==="Escape"&&(X.preventDefault(),y(null),j(""),setTimeout(()=>{var k;return(k=ae.current)==null?void 0:k.focus()},0))}function Y(){var X;o||(X=ae.current)==null||X.focus()}function se(X){if(o)return;const w=X.clipboardData.getData("text");if(!w||!(i.some(oe=>oe&&w.includes(oe))||w.includes(`
39
- `)))return;X.preventDefault();const te=cb(w,i);ee(te)&&x("")}function E(){const X=C.trim();X&&T(X)&&x("")}const Q=v?"var(--danger)":U?"var(--primary)":"var(--border)",ce=c!==void 0&&D.length>=c;return t.jsxs("div",{className:`flex flex-col gap-2 ${l}`,children:[(h||g||H)&&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:"*"}),H?t.jsx(Hr,{content:b}):null]}),t.jsxs("div",{ref:fe,onClick:Y,onFocus:()=>L(!0),onBlur:X=>{var w;(w=fe.current)!=null&&w.contains(X.relatedTarget)||(L(!1),$!==null&&ie($,P),$===null&&E())},style:{borderColor:Q},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 Lf(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 Df(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 Of=new Set(["P","DIV","LI","H1","H2","H3","H4","H5","H6","BLOCKQUOTE"]);function Vl(e,r){return Of.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:y,offset:k}=r.domPoint;y===f&&k===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 y=0;y<=p.length;y+=1){if(i(f,y),c(f,y))return!0;y<p.length&&(n+=p[y])}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 y=f;if(y.tagName==="BR")return i(y,0),d(y.nextSibling??void 0)==="matched";const k=Array.from(f.childNodes);for(let g=0;g<k.length;g+=1){const H=k[g],S=g>0&&H.nodeType===Node.ELEMENT_NODE&&Vl(H,e);if(h(H,S))return!0}return!1},b=Array.from(e.childNodes);for(let f=0;f<b.length;f+=1){const p=b[f],y=f>0&&p.nodeType===Node.ELEMENT_NODE&&Vl(p,e);if(h(p,y))break}if((r==null?void 0:r.locatePlain)===n.length&&!a){const f=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);let p=f.nextNode(),y=p;for(;y;)p=y,y=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,y=p==null?void 0:p.getSelection(),k=y!=null&&y.rangeCount?la(e,y.getRangeAt(0).startContainer,y.getRangeAt(0).startOffset):n+u.length+1;return{caretPlainOffset:k>=0?k: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 y=f;for(;y&&y.nodeType===Node.TEXT_NODE&&(y.textContent??"")==="";){const k=y;y=y[p],k.remove()}return y},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,Hf=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),ri=4,Bf={position:"relative"},If={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 Ff(e){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(e)}"]`))}function _f(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,""),y=s.useRef(null),k=s.useRef(null),g=s.useRef(new Map),H=s.useRef(n);H.current=n;const S=s.useRef(null),$=s.useRef(0),O=s.useRef([]),C=s.useRef(null),[v,T]=s.useState(null),[x,P]=s.useState([]),[W,U]=s.useState(0),[L,J]=s.useState([]),[q,re]=s.useState(!1),[R,fe]=s.useState(!1);$.current=W,s.useEffect(()=>{fe(!0)},[]);const ee=(v==null?void 0:v.query)??null;s.useEffect(()=>{if(ee===null){P([]);return}const Y=ee.trim(),se=`${h}|${Y.toLowerCase()||"*"}`,E=g.current.get(se);if(E){P(E),re(!1),U(0);return}const Q=new AbortController;re(!0);const ie=window.setTimeout(()=>{(async()=>{try{const X=await H.current(Y,{signal:Q.signal,limit:c});if(Q.signal.aborted)return;const w=Array.isArray(X)?X:[];g.current.set(se,w),P(w),U(0)}catch{Q.signal.aborted||P([])}finally{Q.signal.aborted||re(!1)}})()},d);return()=>{Q.abort(),window.clearTimeout(ie)}},[ee,c,d,h]);const j=s.useRef(a);j.current=a,s.useEffect(()=>{var Y;(Y=j.current)==null||Y.call(j,ql(L))},[L]);const Z=s.useCallback(()=>{const Y=Ff(p);if(Y.length===0)return null;const se=window.getSelection();if(se!=null&&se.rangeCount){const Q=se.getRangeAt(0).startContainer;for(const ie of Y)if(ie.contains(Q))return ie}const E=document.activeElement;for(const Q of Y)if(E===Q||E&&Q.contains(E))return Q;for(const Q of Y)if(Q.closest('[role="dialog"]'))return Q;return Y[0]??null},[p]),M=s.useCallback(()=>{const Y=Z(),se=window.getSelection();if(!Y||!se||se.rangeCount===0){T(null);return}const E=se.getRangeAt(0);if(!Y.contains(E.startContainer)){T(null);return}const Q=la(Y,E.startContainer,E.startOffset);if(Q<0){T(null);return}const ie=Do(Y,Q);if(!ie){T(null);return}const X=E.getBoundingClientRect(),w=X.width===0&&X.height===0?(()=>{const te=document.createRange();return te.selectNodeContents(E.startContainer),te.collapse(!0),te.getBoundingClientRect()})():X;S.current={query:ie.query,caretIndex:ie.caretIndex,triggerIndex:ie.triggerIndex};const N=_f(w);T(te=>{const ue={query:ie.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})},[Z]),_=s.useCallback(Y=>{r(Y),M()},[r,M]);s.useEffect(()=>{const Y=se=>{if(Hf.has(se.key))return;const E=Z(),Q=se.target;!E||!Q||!E.contains(Q)||M()};return document.addEventListener("keyup",Y,!0),()=>document.removeEventListener("keyup",Y,!0)},[Z,M]);const ce=s.useCallback(Y=>{const se=Z();if(!se)return;let E=-1;const Q=window.getSelection();if(Q&&Q.rangeCount>0){const te=Q.getRangeAt(0);se.contains(te.startContainer)&&(E=la(se,te.startContainer,te.startOffset))}if(E<0&&S.current&&(E=S.current.caretIndex),E<0)return;const ie=Do(se,E);if(!ie)return;const X=Xl(se,{triggerIndex:ie.triggerIndex,caretIndex:E,username:Y.username,display:Y.name,userId:Y.userId});if(!X)return;yn(se),se.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}));const w={userId:Y.userId,username:Y.username,email:Y.email??void 0,display:Y.name??Y.username};J(te=>{const ue=new Map(te.map(oe=>[oe.userId,oe]));return ue.set(w.userId,w),Array.from(ue.values())}),T(null),S.current=null;const N=Y.username.toLowerCase();requestAnimationFrame(()=>{requestAnimationFrame(()=>{const te=Z();if(!te)return;te.focus(),yn(te);const ue=Array.from(te.querySelectorAll(".mention-chip")),oe=[...ue].reverse().find(ge=>ge.getAttribute("data-username")===N)??ue[ue.length-1];if(oe){Io(oe);return}Yl(te,X.caretPlainOffset)})})},[Z]);s.useEffect(()=>{const Y=new Set(Ho(e).map(se=>se.toLowerCase()));J(se=>{const E=se.filter(Q=>Y.has(Q.username.toLowerCase()));return E.length===se.length?se:E})},[e]),s.useEffect(()=>{if(!v)return;const Y=se=>{const E=se.target;if(!E||y.current&&y.current.contains(E)||k.current&&k.current.contains(E))return;const Q=Z();Q&&Q.contains(E)||T(null)};return document.addEventListener("mousedown",Y),()=>{document.removeEventListener("mousedown",Y)}},[v,Z]);const B=s.useMemo(()=>x.slice(0,c),[x,c]);O.current=B,s.useEffect(()=>{if(!v)return;const Y=se=>{const E=Z(),Q=se.target;if(!E||!Q||!E.contains(Q))return;const ie=O.current;if(!(ie.length===0&&se.key!=="Escape"))if(se.key==="ArrowDown")se.preventDefault(),se.stopPropagation(),U(X=>(X+1)%Math.max(ie.length,1));else if(se.key==="ArrowUp")se.preventDefault(),se.stopPropagation(),U(X=>(X-1+ie.length)%Math.max(ie.length,1));else if(se.key==="Enter"||se.key==="Tab"){const X=ie[$.current];X&&(se.preventDefault(),se.stopPropagation(),ce(X))}else se.key==="Escape"&&(se.preventDefault(),se.stopPropagation(),T(null))};return document.addEventListener("keydown",Y,!0),()=>document.removeEventListener("keydown",Y,!0)},[Z,ce,v]),s.useEffect(()=>{const Y=w=>{w.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}))},se=w=>{const N=Z(),te=w.target;if(!N||!te||!N.contains(te))return;if((w.metaKey||w.ctrlKey)&&w.key.toLowerCase()==="a"){w.preventDefault(),w.stopPropagation(),N.focus(),Zl(N);return}if(w.key!=="Backspace"&&w.key!=="Delete")return;const ue=window.getSelection();if(ue&&!ue.isCollapsed&&ue.rangeCount>0){const Me=ue.getRangeAt(0);if(N.contains(Me.commonAncestorContainer)&&Po(N).length>0&&Ql(Me)){w.preventDefault(),w.stopPropagation(),Jl(N)&&Y(N);return}}const oe=Po(N);if(oe.length>0){w.preventDefault(),w.stopPropagation();for(const Me of oe)da(Me);zr(N),Y(N);return}if(w.key==="Backspace"){const Me=Rl(N);if(!Me)return;w.preventDefault(),w.stopPropagation(),da(Me),zr(N),Y(N);return}const ge=ei(N);ge&&(w.preventDefault(),w.stopPropagation(),da(ge),zr(N),Y(N))},E=w=>{const N=Z();if(!N)return;const te=w.target;if(!(te instanceof Element)||!N.contains(te))return;const ue=te.closest(".mention-chip");if(!(ue instanceof HTMLElement)||!N.contains(ue)){C.current=null,zr(N);return}w.shiftKey||w.button!==0||(C.current={chip:ue,x:w.clientX,y:w.clientY})},Q=w=>{const N=C.current;if(!N)return;const te=Math.abs(w.clientX-N.x),ue=Math.abs(w.clientY-N.y);(te>ri||ue>ri)&&(C.current=null)},ie=w=>{var ge;const N=Z(),te=C.current;if(C.current=null,!N||!te)return;const ue=w.target;if(!(ue instanceof Element)||!N.contains(ue)||!((ge=ue.closest(".mention-chip"))!=null&&ge.isSameNode(te.chip)))return;const oe=window.getSelection();if(oe){if(!oe.isCollapsed){ca(N);return}N.focus(),Kl(te.chip)}},X=()=>{const w=Z();if(!w)return;const N=window.getSelection();!N||N.rangeCount===0||!N.anchorNode||!w.contains(N.anchorNode)||!N.focusNode||!w.contains(N.focusNode)||ca(w)};return document.addEventListener("keydown",se,!0),document.addEventListener("mousedown",E,!0),document.addEventListener("mousemove",Q,!0),document.addEventListener("mouseup",ie,!0),document.addEventListener("selectionchange",X),()=>{document.removeEventListener("keydown",se,!0),document.removeEventListener("mousedown",E,!0),document.removeEventListener("mousemove",Q,!0),document.removeEventListener("mouseup",ie,!0),document.removeEventListener("selectionchange",X)}},[Z]),s.useEffect(()=>{if(!v||!k.current)return;const Y=k.current.querySelector(`[data-mention-index="${W}"]`);Y==null||Y.scrollIntoView({block:"nearest"})},[W,v]);const ne=u?Ul(e):e,K=v&&R?ht.createPortal(t.jsxs("ul",{ref:k,style:{...If,left:v.left,top:v.top,bottom:v.bottom,maxHeight:v.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[q&&B.length===0&&t.jsx("li",{style:ni,children:"Buscando…"}),!q&&B.length===0&&t.jsx("li",{style:ni,children:v.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${v.query}”`}),B.map((Y,se)=>{var E,Q;return t.jsx("li",{children:t.jsxs("button",{type:"button","data-mention-index":se,onMouseDown:ie=>{ie.preventDefault(),ce(Y)},onMouseEnter:()=>U(se),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:se===W?"color-mix(in srgb, var(--primary, var(--bonsaif-ui-primary, #1f6feb)) 14%, transparent)":"transparent",color:"var(--text-main, var(--bonsaif-ui-text, #24292f))",borderRadius:6,cursor:"pointer",display:"flex",flexDirection:"column",gap:2},children:[t.jsx("span",{style:{fontWeight:600,fontSize:13},children:((E=Y.name)==null?void 0:E.trim())||`@${Y.username}`}),t.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[(Q=Y.name)!=null&&Q.trim()?`@${Y.username}`:null,Y.email].filter(Boolean).join(" · ")||`@${Y.username}`})]})},Y.userId)})]}),document.body):null;return t.jsxs("div",{ref:y,style:Bf,className:i,children:[t.jsx(Bl,{value:ne,onChange:_,placeholder:l,minHeight:o,instanceId:p,toolbarVariant:b,focusModalZIndex:f}),K]})}function Pf({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 zf({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 Wf={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)"}},jf={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 qf({children:e,tone:r="neutral",size:n="sm",icon:a,dot:o=!1,className:l=""}){const i=Wf[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 ${jf[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)"}},Uf={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"},Vf={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},Xf={xs:148,sm:164,md:184},Yf={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 Gf({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[y,k]=s.useState(!1),[g,H]=s.useState(!1),[S,$]=s.useState(-1),[O,C]=s.useState({}),v=s.useRef(null),T=s.useRef(null),x=s.useRef(null),P=r.find(ee=>ee.value===e)??r[0],W={...P!=null&&P.tone?oi[P.tone]:void 0,...P==null?void 0:P.style},U=o||l||r.length===0,L=ee=>{i&&ee.stopPropagation()},J=s.useCallback(()=>{k(!1),$(-1)},[]),q=s.useCallback(()=>{const ee=v.current;if(!ee)return;const j=ee.getBoundingClientRect(),Z=Math.max(j.width,Xf[a]),M=Math.min(Math.max(r.length,1)*38+12,260),_=window.innerHeight-j.bottom,ce=_<M&&j.top>_,B=Math.min(Math.max(8,j.left+j.width/2-Z/2),window.innerWidth-Z-8);C({position:"fixed",left:B,top:ce?void 0:j.bottom+6,bottom:ce?window.innerHeight-j.top+6:void 0,width:Z,zIndex:9999})},[r.length,a]),re=s.useCallback(ee=>{ee.disabled||(n(ee.value),J())},[J,n]);s.useEffect(()=>H(!0),[]),s.useEffect(()=>{if(!y)return;q();const ee=r.findIndex(j=>j.value===e);$(ee>=0?ee:0)},[y,r,q,e]),s.useEffect(()=>{if(!y)return;function ee(j){var M,_;const Z=j.target;!((M=v.current)!=null&&M.contains(Z))&&!((_=T.current)!=null&&_.contains(Z))&&J()}return document.addEventListener("mousedown",ee),()=>document.removeEventListener("mousedown",ee)},[J,y]),s.useEffect(()=>{if(y)return window.addEventListener("resize",q),window.addEventListener("scroll",q,!0),()=>{window.removeEventListener("resize",q),window.removeEventListener("scroll",q,!0)}},[y,q]),s.useEffect(()=>{if(S<0||!x.current)return;const ee=x.current.children[S];ee==null||ee.scrollIntoView({block:"nearest"})},[S]);function R(ee){if(!U){if(!y){["Enter"," ","ArrowDown","ArrowUp"].includes(ee.key)&&(ee.preventDefault(),k(!0));return}if(ee.key==="Escape"){ee.preventDefault(),J();return}if(ee.key==="ArrowDown"){ee.preventDefault(),$(j=>Math.min(j+1,r.length-1));return}if(ee.key==="ArrowUp"){ee.preventDefault(),$(j=>Math.max(j-1,0));return}if(ee.key==="Enter"||ee.key===" "){ee.preventDefault();const j=r[S];j&&re(j)}}}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:{...O,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:L,onMouseDown:L,onPointerDown:L,children:t.jsx("div",{ref:x,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:r.map((ee,j)=>{const Z=ee.value===e,M=j===S,_={...ee.tone?oi[ee.tone]:void 0,...ee.style};return t.jsxs("button",{type:"button",role:"option","aria-selected":Z,disabled:ee.disabled,onMouseEnter:()=>!ee.disabled&&$(j),onMouseDown:ce=>{ce.preventDefault(),re(ee)},className:Rt("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",Yf[a],Z?ee.className:void 0,f),style:{...Z?_:void 0,background:Z?_.background??"color-mix(in srgb, var(--primary) 12%, transparent)":M?"var(--bg-hover)":"transparent",color:Z?_.color??"var(--primary)":"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:Z?t.jsx(z.HiCheck,{className:"h-4 w-4"}):null}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:ee.label})]},ee.value)})})});return t.jsxs("span",{ref:v,className:Rt("relative inline-flex shrink-0 items-center",u),onKeyDown:R,onClick:L,onPointerDown:L,children:[t.jsx("button",{type:"button",disabled:U,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":y,title:d,onClick:()=>!U&&k(ee=>!ee),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",Uf[a],P==null?void 0:P.className,h),style:W,children:t.jsx("span",{className:"min-w-0 truncate",children:(P==null?void 0:P.label)??e})}),t.jsx(z.HiChevronDown,{"aria-hidden":"true",className:Rt("pointer-events-none absolute opacity-70 transition-transform",Vf[a],y?"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)}),y&&g&&ht.createPortal(fe,document.body)]})}function Kf({tabs:e,activeTabId:r,defaultActiveTabId:n,onTabChange:a,ariaLabel:o="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:d=""}){const u=e.find(y=>!y.disabled)??e[0],h=r??n??(u==null?void 0:u.id),b=e.find(y=>y.id===h)??u,f=y=>{y.disabled||a==null||a(y.id)},p=y=>{const k=e.filter(H=>!H.disabled);if(!k.length||!b)return;const g=k.findIndex(H=>H.id===b.id);(y.key==="ArrowRight"||y.key==="ArrowDown")&&(y.preventDefault(),f(k[(g+1)%k.length])),(y.key==="ArrowLeft"||y.key==="ArrowUp")&&(y.preventDefault(),f(k[(g-1+k.length)%k.length])),y.key==="Home"&&(y.preventDefault(),f(k[0])),y.key==="End"&&(y.preventDefault(),f(k[k.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(y=>{const k=y.id===(b==null?void 0:b.id);return t.jsxs("button",{type:"button",role:"tab","aria-selected":k,"aria-controls":`${y.id}-panel`,id:`${y.id}-tab`,disabled:y.disabled,tabIndex:k?0:-1,onClick:()=>f(y),className:`inline-flex min-h-8 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap px-2.5 text-sm font-semibold transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 ${l==="underline"?"border-b-2":"rounded-md border"}`,style:{color:k?"var(--primary)":"var(--text-muted)",borderColor:k?"var(--primary)":"transparent",background:l==="pills"&&k?"var(--bg-card)":"transparent"},children:[y.icon&&t.jsx("span",{className:"shrink-0",children:y.icon}),t.jsx("span",{children:y.label}),y.badge&&t.jsx("span",{className:"shrink-0",children:y.badge})]},y.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 Zf({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:y="",contentClassName:k="",footerClassName:g=""}){var se;const H=((se=e[0])==null?void 0:se.id)??"",[S,$]=s.useState(n??H),[O,C]=s.useState(o),v=r??S,T=a??O,x=s.useMemo(()=>new Set(T),[T]),P=Math.max(0,e.findIndex(E=>E.id===v)),W=e[P]??e[0],U=e.length<=1?100:P/(e.length-1)*100,L=E=>{a||C(E),i==null||i(E)},J=E=>{const Q=e.find(ie=>ie.id===E);Q&&(r||$(E),l==null||l(E,Q))},q=E=>x.has(E),re=E=>e.slice(0,E).find(Q=>!Q.optional&&!x.has(Q.id)),R=E=>{const Q=e[E];return!Q||Q.disabled?!1:E===P||d&&E<P?!0:!re(E)},fe=E=>{const Q=e.findIndex(ie=>ie.id===E);return Q>=0&&R(Q)},ee=E=>{const Q=e.findIndex(ie=>ie.id===E);if(Q<0)return!1;if(!R(Q)){const ie=re(Q);return ie&&(c==null||c(e[Q],ie)),!1}return J(E),!0},j=(E=W==null?void 0:W.id)=>{!E||x.has(E)||L([...T,E])},Z=(E=W==null?void 0:W.id)=>{if(!E)return;const Q=e.findIndex(X=>X.id===E),ie=T.filter(X=>{const w=e.findIndex(N=>N.id===X);return w>=0&&w<Q});L(ie),Q>=0&&P>Q&&J(E)},M=()=>P<=0?!1:ee(e[P-1].id),_=()=>{const E=e[P+1];return E?ee(E.id):!1},ce={activeStep:W,activeIndex:P,completedStepIds:T,isCompleted:q,isUnlocked:fe,completeStep:j,uncompleteStep:Z,goToStep:ee,goNext:_,goPrevious:M};if(!W)return null;const B=e[P+1],ne=P>0,K=B?fe(B.id):!1,Y=typeof W.content=="function"?W.content(ce):W.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)]",y),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,Q)=>{const ie=E.id===W.id,X=q(E.id),w=R(Q),N=re(Q);return t.jsxs("button",{type:"button",disabled:!w,"aria-current":ie?"step":void 0,"aria-disabled":!w,title:!w&&N?`Completa ${N.title}`:E.title,onClick:()=>ee(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",ie&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",X&&!ie&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!ie&&!X&&w&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!w&&"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",ie&&"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",ie&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",X&&!ie&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!X&&!ie&&w&&"border-[var(--border)] text-[var(--text-muted)]",!w&&"border-[var(--border)] text-[var(--text-muted)]"),children:X?t.jsx(z.HiCheck,{className:"h-4 w-4"}):w?Q+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",ie?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[Q+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",k),children:Y},W.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(Ve,{variant:"secondary",height:38,padding:"0 14px",icon:t.jsx(z.HiChevronLeft,{}),disabled:!ne,onClick:M,children:h}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[t.jsxs("span",{children:["Paso ",P+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(Ve,{height:38,padding:"0 14px",icon:t.jsx(z.HiChevronRight,{}),disabled:!B||!K,onClick:_,children:B&&!K?f:b})]})]})}const Qf={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 Jf(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Rf(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}=Rf(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),y=a==="error"?"var(--danger)":a==="success"?"#16a34a":"var(--border)",k=s.useCallback(()=>{const g=p.current;if(!g)return;g.style.height="auto";const H=g.scrollHeight,S=si(g,i),$=o??(l!==void 0?si(g,l):void 0),O=$!==void 0?Math.min(Math.max(H,S),$):Math.max(H,S);g.style.height=`${O}px`,g.style.overflowY=$!==void 0&&H>$?"auto":"hidden"},[o,l,i]);return s.useLayoutEffect(()=>{k()},[k,d,u]),s.useEffect(()=>{const g=p.current;if(!g||typeof ResizeObserver>"u")return;const H=new ResizeObserver(()=>k());return H.observe(g),()=>H.disconnect()},[k]),t.jsx("textarea",{...b,ref:g=>{p.current=g,Jf(f,g)},rows:i,value:d,defaultValue:u,"aria-invalid":a==="error"||b["aria-invalid"],onInput:g=>{k(),h==null||h(g)},style:{...c,borderColor:y,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 ${Qf[n]} ${r}`})});function eb({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 tb={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"},rb={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function nb(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function ab(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:y,defaultValue:k,maxLength:g,onInput:H,...S},$){const O=s.useRef(null),C=ab(y,k),v=u??g,T=!!(b||f||d),x=h==="error"?"var(--danger)":h==="success"?"#16a34a":"var(--border)",P={...p??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},W=()=>{const L=O.current;!L||!l||(L.style.height="auto",L.style.height=`${L.scrollHeight}px`)};s.useEffect(W,[l,y]);const U=t.jsx("textarea",{...S,ref:L=>{O.current=L,nb($,L)},value:y,defaultValue:k,maxLength:g,"aria-invalid":h==="error"||S["aria-invalid"],onInput:L=>{W(),H==null||H(L)},style:{...P,borderColor:x},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 ${tb[a]} ${rb[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,v?`/${v}`:""]})]}):U});function ob({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 sb(e){return ci[e%ci.length]}let lb=0;function Wo(){return++lb}function di(e,r){return r?r instanceof RegExp?r.test(e):r(e):!0}function ib(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function cb(e,r){const n=r.filter(Boolean);if(n.length===0)return[e.trim()].filter(Boolean);const a=new RegExp(`${n.map(o=>ib(o)).join("|")}|\\r?\\n`,"g");return e.split(a).map(o=>o.trim()).filter(Boolean)}function db({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:y=!1}){const k=e!==void 0,g=!!p,H=!!b&&f==="tooltip"&&!g,[S,$]=s.useState(()=>(r??[]).map((X,w)=>({id:Wo(),value:X.trim(),colorIndex:w})));s.useEffect(()=>{k&&$(X=>{const w=e??[],N=new Map(X.map(te=>[te.value,te]));return w.map((te,ue)=>N.get(te)??{id:Wo(),value:te,colorIndex:ue})})},[k,e]);const O=S,[C,v]=s.useState(""),[T,x]=s.useState(null),[P,W]=s.useState(""),[U,L]=s.useState(!1),[J,q]=s.useState(!1),re=s.useRef(null),R=s.useRef(null),fe=s.useRef(null);function ee(){q(!0),setTimeout(()=>q(!1),400)}function j(X){$(X),n==null||n(X.map(w=>w.value))}function Z(X){let w=O,N=!1,te=!1;for(const ue of X){const oe=ue.trim();if(oe){if(c!==void 0&&w.length>=c){te=!0;break}if(!d&&w.some(ge=>ge.value.toLowerCase()===oe.toLowerCase())){te=!0;continue}if(!di(oe,u)){te=!0;continue}w=[...w,{id:Wo(),value:oe,colorIndex:w.length}],N=!0}}return N&&j(w),te&&ee(),N}function M(X){return Z([X])}function _(X){const w=O.filter(N=>N.id!==X);j(w.map((N,te)=>({...N,colorIndex:te})))}function ce(X,w){const N=w.trim();if(x(null),W(""),!N){_(X);return}if(!(!d&&O.some(te=>te.id!==X&&te.value.toLowerCase()===N.toLowerCase()))){if(!di(N,u)){ee();return}j(O.map(te=>te.id===X?{...te,value:N}:te))}}function B(X){o||(x(X.id),W(X.value),setTimeout(()=>{var w;return(w=R.current)==null?void 0:w.select()},0))}function ne(X){if(X.key==="Enter"||i.includes(X.key)){X.preventDefault(),M(C)&&v("");return}if(X.key==="Backspace"&&C===""&&O.length>0){X.preventDefault();const w=O[O.length-1];_(w.id)}}function K(X,w){if(X.key==="Enter"){X.preventDefault(),ce(w,P),setTimeout(()=>{var N;return(N=re.current)==null?void 0:N.focus()},0);return}X.key==="Escape"&&(X.preventDefault(),x(null),W(""),setTimeout(()=>{var N;return(N=re.current)==null?void 0:N.focus()},0))}function Y(){var X;o||(X=re.current)==null||X.focus()}function se(X){if(o)return;const w=X.clipboardData.getData("text");if(!w||!(i.some(oe=>oe&&w.includes(oe))||w.includes(`
39
+ `)))return;X.preventDefault();const te=cb(w,i);Z(te)&&v("")}function E(){const X=C.trim();X&&M(X)&&v("")}const Q=g?"var(--danger)":U?"var(--primary)":"var(--border)",ie=c!==void 0&&O.length>=c;return t.jsxs("div",{className:`flex flex-col gap-2 ${l}`,children:[(h||y||H)&&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}),y&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),H?t.jsx(Hr,{content:b}):null]}),t.jsxs("div",{ref:fe,onClick:Y,onFocus:()=>L(!0),onBlur:X=>{var w;(w=fe.current)!=null&&w.contains(X.relatedTarget)||(L(!1),T!==null&&ce(T,P),T===null&&E())},style:{borderColor:Q},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 @@ ${O}`,be=new Blob(["\uFEFF"+le],{type:"text/csv;charset=utf-8;"}),we=URL.createO
49
49
  60% { transform: translateX(-3px); }
50
50
  80% { transform: translateX(3px); }
51
51
  }
52
- `}),D.map(X=>{const w=sb(X.colorIndex);return $===X.id?t.jsx("input",{ref:R,value:P,disabled:o,onChange:k=>j(k.target.value),onKeyDown:k=>Z(k,X.id),onBlur:()=>ie(X.id,P),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(P.length+2,6)}ch`}},X.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:w.bg,color:w.text,border:`1px solid ${w.border}`},children:[t.jsx("span",{className:"truncate",children:X.value}),t.jsx("button",{type:"button","aria-label":`Editar "${X.value}"`,disabled:o,tabIndex:-1,onClick:k=>{k.stopPropagation(),B(X)},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 "${X.value}"`,disabled:o,tabIndex:-1,onClick:k=>{k.stopPropagation(),W(X.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"})})]},X.id)}),!ce&&t.jsx("input",{ref:ae,value:C,disabled:o,placeholder:D.length===0?a:"",onChange:X=>x(X.target.value),onKeyDown:re,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(Br,{error:p,helperText:b,helperDisplay:f})]})}const ub=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;function ot(e){return String(e).padStart(2,"0")}function jo(e,r=Wr()){const n=e.trim();if(!n)return r;const a=n.match(ub);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=`${ot(e.hour24)}:${ot(e.minute)}`;return r?`${n}:${ot(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 fb(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}:${ot(l.minute)}`;return`${a?`${i}:${ot(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 bb(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 Ct=36,Uo=5,ui=Math.floor(Uo/2),hb=52,mb=48,Kt=18;function fi(e){return e*Ct}function bi(e){return Math.round(e/Ct)}function pb(e){return e.use12Hour??e.hour12??!1}function ba({values:e,selected:r,onSelect:n,syncEpochRef:a,forceSyncAt:o=0,width:l=hb,label:i,maxNumeric:c=59,isMeridiem:d=!1,isFocused:u=!1,onFocus:h,onAdvance:b,onBack:f,setColumnRef:p}){const g=s.useRef(null),N=s.useRef(null),v=s.useRef(null),H=s.useRef(""),S=s.useRef(0),M=s.useRef(!1),[D,C]=s.useState(r),[x,$]=s.useState(""),y=s.useCallback(B=>{H.current=B,$(B)},[]),P=s.useMemo(()=>[...Array(ui).fill(""),...e,...Array(ui).fill("")],[e]),j=s.useCallback(()=>{const B=g.current;if(!B)return r;const re=bi(B.scrollTop),Z=Math.min(Math.max(re,0),e.length-1);return e[Z]??r},[r,e]),U=s.useCallback((B,re=!0)=>{const Z=Math.min(Math.max(B,0),e.length-1),Y=e[Z],se=g.current;!se||!Y||(N.current&&(window.clearTimeout(N.current),N.current=null),M.current=!0,S.current=Z,se.scrollTop=fi(Z),C(Y),re&&Y!==r&&n(Y))},[n,r,e]);s.useLayoutEffect(()=>{N.current&&(window.clearTimeout(N.current),N.current=null),v.current&&(window.clearTimeout(v.current),v.current=null),y(""),C(r);const B=e.indexOf(r);if(B>=0&&(S.current=B),B<0||!g.current)return;const re=fi(B);g.current.scrollTop!==re&&(g.current.scrollTop=re)},[o,r,y,e]);const L=s.useCallback(()=>{v.current&&(window.clearTimeout(v.current),v.current=null)},[]),J=s.useCallback((B,re=!1)=>{L(),y("");const Z=Number(B);if(!Number.isFinite(Z))return;const Y=Math.min(c,Math.max(0,Z));let se=ot(Y),E=e.indexOf(se);if(E<0){const Q=Math.min(e.length-1,Math.max(0,Y-(c===12?1:0)));se=e[Q]??se,E=e.indexOf(se)}E>=0&&U(E),re&&(b==null||b())},[L,c,b,U,y,e]),q=s.useCallback(B=>{const re=Math.floor(c/10),Z=H.current;if(Z===""){if(B>re){J(String(B),!0);return}const se=String(B);y(se),v.current=window.setTimeout(()=>{J(H.current,!0)},1200);return}L();const Y=+`${Z}${B}`;Y<=c?J(String(Y),!0):J(String(B),!0)},[L,J,c,y]),ae=s.useCallback(B=>{L(),y(""),U(S.current+B)},[L,U,y]),R=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(),q(Number(B.key));return}B.key==="ArrowUp"?(B.preventDefault(),ae(-1)):B.key==="ArrowDown"?(B.preventDefault(),ae(1)):B.key==="Tab"&&(B.preventDefault(),L(),H.current!==""&&J(H.current,!1),B.shiftKey?f==null||f():b==null||b())},fe=s.useCallback(()=>{const B=a.current,re=g.current;re&&B===a.current&&U(bi(re.scrollTop))},[U,a]),I=()=>{if(H.current!=="")return;if(M.current){M.current=!1;const re=j();C(re);const Z=e.indexOf(re);Z>=0&&(S.current=Z);return}C(j()),N.current&&window.clearTimeout(N.current);const B=a.current;N.current=window.setTimeout(()=>{B===a.current&&fe()},100)},K="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",ee=Ct*Uo,T=ee+Kt*2,W=x!==""?x:null,ie=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:R,onBlur:()=>{L(),H.current!==""&&J(H.current,!1)},className:"relative shrink-0 rounded-lg outline-none",style:{width:l,height:T,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:K,style:{top:0,height:Kt,color:"var(--text-muted)",opacity:.35},onClick:()=>ae(-1),children:t.jsx(z.HiChevronUp,{className:"h-3.5 w-3.5"})}),t.jsx("div",{ref:g,className:"absolute inset-x-0 overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",style:{top:Kt,height:ee,scrollSnapType:"y mandatory",scrollBehavior:"auto"},onScroll:I,onMouseUp:fe,onTouchEnd:fe,children:P.map((B,re)=>{const Z=B!==""&&B===D;return t.jsx("button",{type:"button",tabIndex:-1,disabled:!B,onClick:()=>{if(!B)return;const Y=e.indexOf(B);Y>=0&&U(Y)},className:"flex w-full items-center justify-center tabular-nums leading-none disabled:cursor-default",style:{height:Ct,scrollSnapAlign:"center",color:Z?"var(--text-main)":"var(--text-muted)",fontSize:Z?16:14,fontWeight:Z?600:400,opacity:B?ie?Z?0:.35:Z?1:.35:0},children:B},`wheel-${re}-${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+ee/2-Ct/2,height:Ct,color:"var(--text-main)",fontSize:16,background:"var(--bg-card)"},children:W}):null,t.jsx("button",{type:"button","aria-label":"Valor siguiente",className:K,style:{bottom:0,height:Kt,color:"var(--text-muted)",opacity:.35},onClick:()=>ae(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:Ct,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=pb({use12Hour:n,hour12:a}),p=s.useRef(e),g=jo(e,Wr()),N=fa(g),[v,H]=s.useState(ot(f?N.hour12:g.hour24)),[S,M]=s.useState(ot(g.minute)),[D,C]=s.useState(ot(g.second)),[x,$]=s.useState(N.meridiem),[y,P]=s.useState(0),j=s.useRef(0),U=s.useRef(!1),L=s.useRef({hour:null,minute:null,second:null,meridiem:null}),[J,q]=s.useState("hour"),ae=s.useMemo(()=>{const oe=["hour","minute"];return o&&oe.push("second"),f&&oe.push("meridiem"),oe},[f,o]),R=s.useCallback(oe=>{q(ge=>{const Me=ae.indexOf(ge);return ae[(Me+oe+ae.length)%ae.length]})},[ae]);s.useEffect(()=>{var oe;(oe=L.current[J])==null||oe.focus()},[J]),s.useEffect(()=>{var oe;q("hour"),(oe=L.current.hour)==null||oe.focus()},[]),s.useEffect(()=>{if(e===p.current)return;p.current=e;const oe=jo(e,Wr()),ge=fa(oe);H(ot(f?ge.hour12:oe.hour24)),M(ot(oe.minute)),C(ot(oe.second)),$(ge.meridiem)},[f,e]);const fe=s.useMemo(()=>(f?qo(1,12):qo(0,23)).map(oe=>ot(oe)),[f]),I=s.useMemo(()=>qo(0,59).map(oe=>ot(oe)),[]),K=I,ee=s.useMemo(()=>["AM","PM"],[]),T=s.useCallback(()=>f?wn({hour12:Number(v),minute:Number(S),second:Number(D),meridiem:x}):{hour24:Number(v),minute:Number(S),second:Number(D)},[v,f,x,S,D]),W=s.useCallback(oe=>{if(U.current)return;const ge=xn(oe,o);p.current=ge,r(ge)},[r,o]),ie=s.useCallback(()=>{W(T())},[T,W]),B=oe=>{H(oe),b&&W(f?wn({hour12:Number(oe),minute:Number(S),second:Number(D),meridiem:x}):{hour24:Number(oe),minute:Number(S),second:Number(D)})},re=oe=>{M(oe),b&&W(f?wn({hour12:Number(v),minute:Number(oe),second:Number(D),meridiem:x}):{hour24:Number(v),minute:Number(oe),second:Number(D)})},Z=oe=>{C(oe),b&&W(f?wn({hour12:Number(v),minute:Number(S),second:Number(oe),meridiem:x}):{hour24:Number(v),minute:Number(S),second:Number(oe)})},Y=oe=>{$(oe),b&&W(wn({hour12:Number(v),minute:Number(S),second:Number(D),meridiem:oe}))},se=s.useCallback(()=>(j.current+=1,P(j.current),j.current),[]),E=s.useCallback(oe=>{const ge=fa(oe),Me=xn(oe,o);p.current=Me,H(ot(f?ge.hour12:oe.hour24)),M(ot(oe.minute)),C(ot(oe.second)),$(ge.meridiem),r(Me)},[f,r,o]),Q=()=>{U.current=!0,se(),E(Wr()),queueMicrotask(()=>{const oe=Wr();xn(oe,o)!==p.current&&(se(),E(oe)),U.current=!1})},ce=()=>{ie(),d==null||d()},X=Ct*Uo,w=X+Kt*2,k=Kt+X/2-Ct/2,te=t.jsx("div",{className:"relative px-4 py-2",children:t.jsxs("div",{className:"relative mx-auto",style:{height:w,maxWidth:"100%"},children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-10 rounded-xl",style:{top:k,height:Ct,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:Ct*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:Ct*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:j,forceSyncAt:y,values:fe,selected:v,onSelect:B,label:"Horas",maxNumeric:f?12:23,isFocused:J==="hour",onFocus:()=>q("hour"),onAdvance:()=>R(1),onBack:()=>R(-1),setColumnRef:oe=>{L.current.hour=oe}}),t.jsx(hi,{}),t.jsx(ba,{syncEpochRef:j,forceSyncAt:y,values:I,selected:S,onSelect:re,label:"Minutos",maxNumeric:59,isFocused:J==="minute",onFocus:()=>q("minute"),onAdvance:()=>R(1),onBack:()=>R(-1),setColumnRef:oe=>{L.current.minute=oe}}),o?t.jsxs(t.Fragment,{children:[t.jsx(hi,{}),t.jsx(ba,{syncEpochRef:j,forceSyncAt:y,values:K,selected:D,onSelect:Z,label:"Segundos",maxNumeric:59,isFocused:J==="second",onFocus:()=>q("second"),onAdvance:()=>R(1),onBack:()=>R(-1),setColumnRef:oe=>{L.current.second=oe}})]}):null,f?t.jsx("div",{className:"ml-3 shrink-0 pl-1",children:t.jsx(ba,{syncEpochRef:j,forceSyncAt:y,values:ee,selected:x,onSelect:oe=>Y(oe),width:mb,label:"AM o PM",isMeridiem:!0,isFocused:J==="meridiem",onFocus:()=>q("meridiem"),onAdvance:()=>R(1),onBack:()=>R(-1),setColumnRef:oe=>{L.current.meridiem=oe}})}):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(Ve,{variant:"ghost",size:"sm",onClick:Q,className:h?"text-xs":void 0,children:"Ahora"}),!h&&(c||d)?t.jsxs("div",{className:"flex items-center gap-2",children:[c?t.jsx(Ve,{variant:"ghost",size:"sm",onClick:c,children:"Cancelar"}):null,d?t.jsx(Ve,{variant:"primary",size:"sm",onClick:ce,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 gb(e){return e.use12Hour??e.hour12??!1}function vb({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:N,className:v=""}){const H=u==="popover",[S,M]=s.useState(!1),D=s.useRef(null),[C,x]=s.useState({horizontal:"left",vertical:"bottom"}),$=gb({use12Hour:a,hour12:o}),y=s.useMemo(()=>r?fb(r,{use12Hour:$,showSeconds:l}):"",[$,l,r]);s.useEffect(()=>{if(!H||!S||!D.current)return;const U=D.current.getBoundingClientRect(),L=8,J=$?l?300:260:l?252:212,q=276,ae=U.left+J>window.innerWidth-L,R=U.right-J>=L,fe=U.bottom+8+q>window.innerHeight-L,I=U.top-8-q>=L;x({horizontal:ae&&R?"right":"left",vertical:fe&&I?"top":"bottom"})},[$,H,S,l]),s.useEffect(()=>{if(!H||!S)return;function U(J){D.current&&(D.current.contains(J.target)||M(!1))}function L(J){J.key==="Escape"&&M(!1)}return document.addEventListener("mousedown",U),document.addEventListener("keydown",L),()=>{document.removeEventListener("mousedown",U),document.removeEventListener("keydown",L)}},[H,S]);const P=t.jsxs("button",{type:"button",disabled:d,onClick:()=>{d||M(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)":S?"var(--primary)":"var(--border)",color:y?"var(--text-main)":"var(--text-muted)",boxShadow:S?"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:y||c})]}),H?t.jsx(z.HiChevronDown,{className:`h-4 w-4 shrink-0 text-[var(--text-muted)] transition-transform duration-150 ${S?"rotate-180":""}`}):null]}),j=t.jsx(mi,{variant:H?"popover":"panel",value:r||bb(l),onChange:n,use12Hour:$,showSeconds:l,title:i,onClose:()=>M(!1)});return t.jsx(Qn,{label:e,required:h,error:b,helperText:f,helperDisplay:p,className:g,contentClassName:N,children:H?t.jsxs("div",{ref:D,className:"relative w-full",children:[P,S?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:j}):null]}):t.jsxs("div",{className:"space-y-2",children:[P,S?j:null]})})}const yb={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function xb({checked:e,disabled:r,onCheckedChange:n,size:a="sm",className:o="",...l}){const i=yb[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 wb(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 Nb(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 kb(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 Cb(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 Sb(e){const r=document.querySelector(e);r instanceof HTMLElement&&r.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}function Eb({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),[N,v]=s.useState(null),[H,S]=s.useState(!1),M=e[p]??e[0],D=e.length;s.useEffect(()=>{S(!0)},[]),s.useEffect(()=>{r&&g(0)},[r]),s.useEffect(()=>{!r||!M||l==null||l(M,p)},[r,M,p,l]);const C=s.useCallback(()=>{M&&v(wb(M.target))},[M]);s.useLayoutEffect(()=>{if(!r||!M)return;Sb(M.target);const j=window.setTimeout(C,80),U=window.setTimeout(C,280);return()=>{window.clearTimeout(j),window.clearTimeout(U)}},[r,M,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 x=s.useCallback(()=>{if(n(!1),!!o)try{localStorage.setItem(o,"done")}catch{}},[n,o]);s.useEffect(()=>{if(!r)return;function j(U){if(U.key==="Escape"){U.preventDefault(),x();return}if(U.key==="ArrowRight"||U.key==="Enter"){U.preventDefault(),g(L=>Math.min(L+1,D-1));return}U.key==="ArrowLeft"&&(U.preventDefault(),g(L=>Math.max(L-1,0)))}return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[r,x,D]);const $=s.useMemo(()=>!N||!M?"bottom":Nb(M.placement,N),[N,M]),y=s.useMemo(()=>N?kb(N):null,[N]),P=s.useMemo(()=>typeof window>"u"?{top:96,left:16}:y?Cb(y,$):{top:96,left:Math.max(16,(window.innerWidth-jr)/2)},[y,$]);return!H||!r||!M?null:ht.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:x}),y?t.jsx("div",{className:"pointer-events-none absolute rounded-xl border-2 border-[var(--primary)] transition-all duration-200",style:{top:y.top,left:y.left,width:y.width,height:y.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:{...P,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,"/",D]}),t.jsx("h2",{id:f,className:"mt-0.5 text-sm font-semibold text-[var(--text-main)]",children:M.title})]}),t.jsx(Ve,{variant:"icon",iconOnly:!0,"aria-label":h,tooltip:"Cerrar",onClick:x,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:[M.body,M.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:M.caption}):null]}),t.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2",children:[t.jsx(Ve,{variant:"secondary",size:"sm",disabled:p===0,onClick:()=>g(j=>Math.max(j-1,0)),children:i}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ve,{variant:"secondary",size:"sm",onClick:x,children:c}),p<D-1?t.jsx(Ve,{size:"sm",onClick:()=>g(j=>Math.min(j+1,D-1)),children:d}):t.jsx(Ve,{size:"sm",onClick:x,children:u})]})]})]})]}),document.body)}function Mb(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(","),Tb=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function $b(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 Ab(e){const r=e.querySelector(Tb);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(!$b(l))return;const c={overflow:gi(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},d=Ab(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 Lb(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",Db={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"],Ob={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Hb="bonsaif.bot",Bb="Bonsaif Bot",Ib={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 Fb(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 Lb(window.location.pathname)}function _b(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 Pb(e){let r=0;for(const n of e)r=r*31+n.charCodeAt(0)&65535;return Ni[r%Ni.length]}function zb(e,r){return e===Hb||r===Bb}function Wb(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[N,v]=s.useState(!1),H=typeof e=="string"&&e.trim()&&e!=="undefined"&&e!=="null"?e.trim():"";s.useEffect(()=>{v(!1)},[H,f]);const{wh:S,text:M}=Db[a],D=ki(n)||ki(r)||c,C=_b(D),x=Fb(d),$=zb(r,n),y=Wb(x,"/favicon.svg"),P=s.useMemo(()=>{if(!H)return"";const q=new URLSearchParams;q.set("size",String(wi[a])),f&&q.set("v",String(f));const ae=q.toString();return`${x}/api/user/avatar/${encodeURIComponent(H)}${ae?`?${ae}`:""}`},[f,x,H,a]),j=wi[a],U=$?t.jsx("span",{className:`${S} ${Ib[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:y,alt:D,width:j,height:j,className:"h-full w-full object-contain"})}):P&&!N?t.jsx("img",{src:P,alt:D,width:j,height:j,className:`${S} rounded-full object-cover flex-shrink-0 ${p}`,style:g,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>v(!0)},`${H}-${f}`):t.jsx("span",{className:`${S} ${Pb(D)} ${M} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${p}`,style:g,title:D,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 ${Ob[b]} font-medium text-[var(--text-main)] ${h}`,title:D,children:D})]});const L=l??!0,J=i??D;return L&&J?t.jsx(Pt,{as:"span",content:J,className:`inline-flex flex-shrink-0 ${u}`,children:U}):U}function jb({href:e,className:r,children:n}){return t.jsx("a",{href:e,className:r,children:n})}function qb(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=jb}){const[h,b]=s.useState(!1),f=qb(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(N=>{const v=n===N.href||n.startsWith(`${N.href}/`);return t.jsxs(u,{href:N.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:N.icon??t.jsx(z.HiHome,{className:"h-4 w-4"})}),t.jsx("span",{className:"truncate",children:N.label})]},N.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(Ve,{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",Ub={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 Vb(e){return e.split("-").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function Xb(e){return/^\d+$/.test(e)||/^[a-f0-9]{8,}$/i.test(e)}function Yb(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=Xb(n)&&a?a:n,l=Ub[o]??Vb(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 Gb(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 Kb(e){return e.includes("primeAuthOrigin")||e.includes("primeAuthProjectKey")}function Mi(){if(typeof window>"u")return!1;if(Kb(window.location.href)){try{window.sessionStorage.setItem(Ei,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Ei)==="true"}catch{return!1}}function Zb({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,N]=s.useState(d??"/"),[v,H]=s.useState(()=>Mi()),[S,M]=s.useState(null),D=d??g,C=c??Yb(D),x=o??Gb(D),$=u&&!v&&C.length>1,y=!$;s.useEffect(()=>{d||N(window.location.pathname)},[d]),s.useEffect(()=>{H(Mi())},[]),s.useEffect(()=>{if(h){p(!1);return}let j=null,U=0,L=0;const J=()=>{const R=b.current,fe=document.querySelector("[data-app-scroll='true']");return(R==null?void 0:R.closest(".os-viewport"))??(R==null?void 0:R.closest("[data-overlayscrollbars-viewport]"))??Go(fe)??fe??window},q=()=>{const R=j&&j!==window?j.scrollTop:window.scrollY;p(fe=>fe?R>24:R>72)},ae=()=>{j==null||j.removeEventListener("scroll",q),j=J(),j.addEventListener("scroll",q,{passive:!0}),q()};return ae(),U=window.requestAnimationFrame(ae),L=window.setTimeout(ae,120),()=>{window.cancelAnimationFrame(U),window.clearTimeout(L),j==null||j.removeEventListener("scroll",q)}},[h]),s.useEffect(()=>{if(h){M(null);return}let j=0;const U=[],L=()=>{const K=b.current,ee=K==null?void 0:K.parentElement,T=document.querySelector("[data-app-scroll='true']"),W=Go(T)??T;if(!K||!ee||!W){M(null);return}const ie=ee.getBoundingClientRect(),B=window.getComputedStyle(ee),re=W.getBoundingClientRect(),Z=W instanceof HTMLElement&&W.clientWidth>0?W.clientWidth:re.width,Y=ie.left+parseFloat(B.paddingLeft||"0"),se={marginLeft:Math.round(re.left-Y),width:Math.round(Z)};M(E=>E&&E.marginLeft===se.marginLeft&&E.width===se.width?E:se)},J=()=>{window.cancelAnimationFrame(j),j=window.requestAnimationFrame(L)};J(),window.addEventListener("resize",J);const q=new ResizeObserver(J),ae=b.current,R=ae==null?void 0:ae.parentElement,fe=document.querySelector("[data-app-scroll='true']"),I=Go(fe)??fe;return[R,fe,I].forEach(K=>{K&&q.observe(K)}),U.push(window.setTimeout(J,120)),U.push(window.setTimeout(J,280)),()=>{window.cancelAnimationFrame(j),window.removeEventListener("resize",J),q.disconnect(),U.forEach(K=>window.clearTimeout(K))}},[h]);const P={...S?{marginLeft:S.marginLeft,width:S.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:P,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":y?"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||y?"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||y?"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:$?"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(gs.Provider,{value:{compact:!0,headerAction:!0},children:n})})]})})}function Qb({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 Jb(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 Rb({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(()=>Jb(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,N;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(((N=h.data)==null?void 0:N.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 eh(){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 th(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 rh(){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 nh(){return"light"}function ah({position:e="bottom-center"}){const r=s.useSyncExternalStore(th,rh,nh);return t.jsx(Xa.Toaster,{position:e,theme:r,richColors:!0,closeButton:!0})}function oh({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 St=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 Et({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 Mt({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,pr="ease-out",sh={top:18,right:8,bottom:12,left:0};function Cn(e){return{...sh,...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 Tt(){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 lh(e,r=St){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 ih({active:e,label:r,payload:n,valueFormat:a=St}){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 N=p.payload,v=N&&typeof N.display=="number"?N.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:lh(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(Le.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(ih,{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]),N=s.useCallback(()=>{h(null),g(null)},[g]),v=!!c,H=s.useMemo(()=>!c||f?e:e.slice(c.startIndex,c.endIndex+1),[e,f,c]),S=s.useCallback((U,L)=>{const J=Hi(e,r,U),q=Hi(e,r,L);J<0||q<0||g(Bi(J,q,e.length))},[g,e,r]),M=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]),D=s.useCallback(U=>{!p||!u||(U==null?void 0:U.activeLabel)===void 0||(U==null?void 0:U.activeLabel)===null||h(L=>L&&{...L,rightLabel:U.activeLabel})},[u,p]),C=s.useCallback(()=>{if(p){if(!u||u.rightLabel===null||u.rightLabel===void 0){h(null);return}S(u.leftLabel,u.rightLabel),h(null)}},[S,u,p]),x=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]),$=p?{onMouseDown:M,onMouseMove:D,onMouseUp:C,onMouseLeave:()=>{u&&C()}}:{},y=c??{startIndex:0,endIndex:Math.max(0,e.length-1)},P=t.jsxs(t.Fragment,{children:[p&&u&&u.rightLabel!==null&&u.rightLabel!==void 0?t.jsx(Le.ReferenceArea,{x1:u.leftLabel,x2:u.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,f?t.jsx(Le.Brush,{dataKey:r,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:y.startIndex,endIndex:y.endIndex,onChange:x,tickFormatter:U=>String(U)}):null]}),j=f?{bottom:Math.max(l+10,36)}:void 0;return{enabled:b,showBrush:f,showDrag:p,viewData:H,isZoomed:v,resetZoom:N,chartHandlers:$,zoomNodes:P,marginExtra:j}}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 ch({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=St,yDomain:f,ariaLabel:p="Gráfico de líneas",curve:g=!0,strokeWidth:N=2.25,zoomable:v=!1,zoomMode:H="both",brushHeight:S,onZoomChange:M}){const D=pa(e,n),C=Sn(n),x=va(e,r,{zoomable:v,zoomMode:H,brushHeight:S,onZoomChange:M}),$=Cn({...h,...x.marginExtra});return l?t.jsx(Et,{height:a}):D?t.jsx(Mt,{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:x.isZoomed,onReset:x.resetZoom}),t.jsx(Le.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Le.LineChart,{data:x.viewData,margin:$,...x.chartHandlers,children:[c?t.jsx(Le.CartesianGrid,{strokeDasharray:"2 8",stroke:En(),vertical:!1}):null,t.jsx(Le.XAxis,{dataKey:r,tick:Tt(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Le.YAxis,{tick:Tt(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:y=>b(Number(y)),dx:-2}),u?t.jsx(Yr,{valueFormat:b,cursor:{stroke:Di(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Le.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ga()}):null,C.map((y,P)=>t.jsx(Le.Line,{type:g?"monotone":"linear",dataKey:y.key,name:y.label,stroke:y.color,strokeWidth:P===0?N+.35:N,strokeOpacity:P===0?1:.88,isAnimationActive:!0,animationDuration:lr,animationEasing:pr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:y.color}},y.key)),x.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=St,yDomain:f,ariaLabel:p="Gráfico de área",stacked:g=!1,opacity:N=.22,zoomable:v=!1,zoomMode:H="both",brushHeight:S,onZoomChange:M}){const D=pa(e,n),C=Sn(n),x=va(e,r,{zoomable:v,zoomMode:H,brushHeight:S,onZoomChange:M}),$=Cn({...h,...x.marginExtra});return l?t.jsx(Et,{height:a}):D?t.jsx(Mt,{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:x.isZoomed,onReset:x.resetZoom}),t.jsx(Le.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Le.AreaChart,{data:x.viewData,margin:$,...x.chartHandlers,children:[t.jsx("defs",{children:C.map(y=>t.jsxs("linearGradient",{id:Oi(y.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:y.color,stopOpacity:Math.min(.55,N+.28)}),t.jsx("stop",{offset:"48%",stopColor:y.color,stopOpacity:N*.5}),t.jsx("stop",{offset:"100%",stopColor:y.color,stopOpacity:0})]},y.key))}),c?t.jsx(Le.CartesianGrid,{strokeDasharray:"2 8",stroke:En(),vertical:!1}):null,t.jsx(Le.XAxis,{dataKey:r,tick:Tt(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Le.YAxis,{tick:Tt(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:y=>b(Number(y)),dx:-2}),u?t.jsx(Yr,{valueFormat:b,cursor:{stroke:Di(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Le.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ga()}):null,C.map(y=>t.jsx(Le.Area,{type:"monotone",dataKey:y.key,name:y.label,stroke:y.color,fill:`url(#${Oi(y.key)})`,strokeWidth:2.25,stackId:g?"stack":void 0,isAnimationActive:!0,animationDuration:lr,animationEasing:pr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:y.color}},y.key)),x.zoomNodes]})})]})}function dh({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=St,yDomain:f,ariaLabel:p="Gráfico de barras",layout:g="vertical",mode:N="grouped",barRadius:v=6,categoryAxisWidth:H=64,zoomable:S=!1,zoomMode:M="both",brushHeight:D,onZoomChange:C}){const x=pa(e,n),$=Sn(n),y=g==="horizontal",P=va(e,r,{zoomable:S&&!y,zoomMode:M,brushHeight:D,onZoomChange:C}),j=Cn({...h,...P.marginExtra});return l?t.jsx(Et,{height:a}):x?t.jsx(Mt,{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:P.isZoomed,onReset:P.resetZoom}),t.jsx(Le.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Le.BarChart,{data:P.viewData,margin:j,layout:y?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,...P.chartHandlers,children:[c?t.jsx(Le.CartesianGrid,{strokeDasharray:"2 8",stroke:En(),horizontal:!y,vertical:y}):null,y?t.jsxs(t.Fragment,{children:[t.jsx(Le.XAxis,{type:"number",tick:Tt(),tickLine:!1,axisLine:!1,tickFormatter:U=>b(Number(U)),domain:f??["auto","auto"]}),t.jsx(Le.YAxis,{type:"category",dataKey:r,tick:Tt(),tickLine:!1,axisLine:!1,width:H})]}):t.jsxs(t.Fragment,{children:[t.jsx(Le.XAxis,{dataKey:r,tick:Tt(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Le.YAxis,{tick:Tt(),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(Le.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ga()}):null,$.map((U,L)=>t.jsx(Le.Bar,{dataKey:U.key,name:U.label,fill:U.color,fillOpacity:L===0?1:.82,radius:y?[0,v,v,0]:[v,v,2,2],maxBarSize:20,stackId:N==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:lr,animationEasing:pr},U.key)),P.zoomNodes]})})]})}function uh(e){return t.jsx(Fi,{...e,variant:"pie"})}function fh(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=St,ariaLabel:h,innerRadius:b,outerRadius:f,colors:p=[...Nn],padAngle:g,cornerRadius:N,variant:v}){const H=e.map((L,J)=>({name:String(L[r]??""),value:qr(L[n])??0,fill:p[J%p.length],row:L})).filter(L=>L.value>0),S=!H.length,M=v==="donut",D=H.length,C=Ii(b,M?62:12),x=Ii(f,78),$=Math.min(g??(M?2:3),Math.max(.5,10/Math.max(1,D))),y=Math.min(N??(M?10:8),Math.max(2,36/Math.max(1,D)));if(l)return t.jsx(Et,{height:a});if(S)return t.jsx(Mt,{height:a,text:i});const P=H.reduce((L,J)=>L+J.value,0),j=c?Math.min(96,28+Math.ceil(D/3)*22):0,U=Math.max(140,a-j);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(Le.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Le.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[d?t.jsx(Yr,{valueFormat:u,isAnimationActive:!1}):null,t.jsx(Le.Pie,{data:H,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${C}%`,outerRadius:`${x}%`,startAngle:90,endAngle:-270,paddingAngle:$,cornerRadius:y,minAngle:D>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:lr,animationEasing:pr,label:!1,activeShape:bh,children:H.map(L=>t.jsx(Le.Cell,{fill:L.fill},L.name))}),M?t.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:u(P)}):null]})})}),c?t.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:H.map(L=>t.jsxs("li",{className:"bonsaif-pie-legend-item",children:[t.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:L.fill},"aria-hidden":!0}),t.jsx("span",{className:"bonsaif-pie-legend-label",title:L.name,children:L.name}),t.jsx("span",{className:"bonsaif-pie-legend-value",children:u(L.value)})]},L.name))}):null]})})}function bh(e){const{outerRadius:r=0,...n}=e;return t.jsx(Le.Sector,{...n,outerRadius:Number(r)+4,stroke:"var(--bg-card)",strokeWidth:2})}function hh({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(x=>qr(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,g=1,N=Math.min(...h),H=Math.max(...h)-N||1,S=h.map((x,$)=>{const y=g+$/(h.length-1)*(b-g*2),P=f-p-(x-N)/H*(f-p*2);return{x:y,y:P}}),M=S.map((x,$)=>`${$===0?"M":"L"}${x.x.toFixed(2)} ${x.y.toFixed(2)}`).join(" "),D=`${M} L${S[S.length-1].x.toFixed(2)} ${f} L${S[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:D,fill:`url(#${C})`}):null,t.jsx("path",{d:M,fill:"none",stroke:u,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function mh({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=St,yDomain:g,ariaLabel:N="Gráfico combinado",barRadius:v=6,zoomable:H=!1,zoomMode:S="both",brushHeight:M,onZoomChange:D}){const C=a??n.slice(0,Math.max(1,n.length-1)),x=o??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),$=[...C,...x.filter(q=>!C.some(ae=>ae.key===q.key))],y=pa(e,$),P=Sn(C),j=Sn($),U=x.map(q=>{var R;const ae=j.find(fe=>fe.key===q.key);return{...q,label:q.label??q.key,color:q.color??(ae==null?void 0:ae.color)??((R=j[0])==null?void 0:R.color)}}),L=va(e,r,{zoomable:H,zoomMode:S,brushHeight:M,onZoomChange:D}),J=Cn({...f,...L.marginExtra});return c?t.jsx(Et,{height:l}):y?t.jsx(Mt,{height:l,text:d}):t.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":N,style:{height:l},children:[t.jsx(ya,{visible:L.isZoomed,onReset:L.resetZoom}),t.jsx(Le.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Le.ComposedChart,{data:L.viewData,margin:J,barCategoryGap:"34%",...L.chartHandlers,children:[u?t.jsx(Le.CartesianGrid,{strokeDasharray:"2 8",stroke:En(),vertical:!1}):null,t.jsx(Le.XAxis,{dataKey:r,tick:Tt(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Le.YAxis,{tick:Tt(),tickLine:!1,axisLine:!1,width:44,domain:g??["auto","auto"],tickFormatter:q=>p(Number(q)),dx:-2}),b?t.jsx(Yr,{valueFormat:p,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,h?t.jsx(Le.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ga()}):null,P.map(q=>t.jsx(Le.Bar,{dataKey:q.key,name:q.label,fill:q.color,fillOpacity:.88,radius:[v,v,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:lr,animationEasing:pr},q.key)),U.map(q=>t.jsx(Le.Line,{type:"monotone",dataKey:q.key,name:q.label,stroke:q.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:lr,animationEasing:pr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:q.color}},q.key)),L.zoomNodes]})})]})}function ph({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=St,ariaLabel:f="Gráfico waterfall",increaseColor:p="#34d399",decreaseColor:g="#f87171",totalColor:N="var(--primary)"}){const v=s.useMemo(()=>gh(e,{xKey:r,valueKey:n,typeKey:a,increaseColor:p,decreaseColor:g,totalColor:N}),[e,r,n,a,p,g,N]),H=!v.length,S=Cn(h);return i?t.jsx(Et,{height:o}):H?t.jsx(Mt,{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(Le.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Le.BarChart,{data:v,margin:S,barCategoryGap:"42%",children:[d?t.jsx(Le.CartesianGrid,{strokeDasharray:"2 8",stroke:En(),vertical:!1}):null,t.jsx(Le.XAxis,{dataKey:"label",tick:Tt(),tickLine:!1,axisLine:!1,interval:0,dy:6}),t.jsx(Le.YAxis,{tick:Tt(),tickLine:!1,axisLine:!1,width:44,tickFormatter:M=>b(Number(M)),dx:-2}),u?t.jsx(Yr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,t.jsx(Le.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),t.jsx(Le.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:lr,animationEasing:pr,children:v.map(M=>t.jsx(Le.Cell,{fill:M.color},M.label))})]})})})}function gh(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",vh=`
52
+ `}),O.map(X=>{const w=sb(X.colorIndex);return T===X.id?t.jsx("input",{ref:R,value:P,disabled:o,onChange:N=>W(N.target.value),onKeyDown:N=>K(N,X.id),onBlur:()=>ce(X.id,P),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(P.length+2,6)}ch`}},X.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:w.bg,color:w.text,border:`1px solid ${w.border}`},children:[t.jsx("span",{className:"truncate",children:X.value}),t.jsx("button",{type:"button","aria-label":`Editar "${X.value}"`,disabled:o,tabIndex:-1,onClick:N=>{N.stopPropagation(),B(X)},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 "${X.value}"`,disabled:o,tabIndex:-1,onClick:N=>{N.stopPropagation(),_(X.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"})})]},X.id)}),!ie&&t.jsx("input",{ref:re,value:C,disabled:o,placeholder:O.length===0?a:"",onChange:X=>v(X.target.value),onKeyDown:ne,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(Br,{error:p,helperText:b,helperDisplay:f})]})}const ub=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;function ot(e){return String(e).padStart(2,"0")}function jo(e,r=Wr()){const n=e.trim();if(!n)return r;const a=n.match(ub);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=`${ot(e.hour24)}:${ot(e.minute)}`;return r?`${n}:${ot(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 fb(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}:${ot(l.minute)}`;return`${a?`${i}:${ot(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 bb(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 Ct=36,Uo=5,ui=Math.floor(Uo/2),hb=52,mb=48,Kt=18;function fi(e){return e*Ct}function bi(e){return Math.round(e/Ct)}function pb(e){return e.use12Hour??e.hour12??!1}function ba({values:e,selected:r,onSelect:n,syncEpochRef:a,forceSyncAt:o=0,width:l=hb,label:i,maxNumeric:c=59,isMeridiem:d=!1,isFocused:u=!1,onFocus:h,onAdvance:b,onBack:f,setColumnRef:p}){const y=s.useRef(null),k=s.useRef(null),g=s.useRef(null),H=s.useRef(""),S=s.useRef(0),$=s.useRef(!1),[O,C]=s.useState(r),[v,T]=s.useState(""),x=s.useCallback(B=>{H.current=B,T(B)},[]),P=s.useMemo(()=>[...Array(ui).fill(""),...e,...Array(ui).fill("")],[e]),W=s.useCallback(()=>{const B=y.current;if(!B)return r;const ne=bi(B.scrollTop),K=Math.min(Math.max(ne,0),e.length-1);return e[K]??r},[r,e]),U=s.useCallback((B,ne=!0)=>{const K=Math.min(Math.max(B,0),e.length-1),Y=e[K],se=y.current;!se||!Y||(k.current&&(window.clearTimeout(k.current),k.current=null),$.current=!0,S.current=K,se.scrollTop=fi(K),C(Y),ne&&Y!==r&&n(Y))},[n,r,e]);s.useLayoutEffect(()=>{k.current&&(window.clearTimeout(k.current),k.current=null),g.current&&(window.clearTimeout(g.current),g.current=null),x(""),C(r);const B=e.indexOf(r);if(B>=0&&(S.current=B),B<0||!y.current)return;const ne=fi(B);y.current.scrollTop!==ne&&(y.current.scrollTop=ne)},[o,r,x,e]);const L=s.useCallback(()=>{g.current&&(window.clearTimeout(g.current),g.current=null)},[]),J=s.useCallback((B,ne=!1)=>{L(),x("");const K=Number(B);if(!Number.isFinite(K))return;const Y=Math.min(c,Math.max(0,K));let se=ot(Y),E=e.indexOf(se);if(E<0){const Q=Math.min(e.length-1,Math.max(0,Y-(c===12?1:0)));se=e[Q]??se,E=e.indexOf(se)}E>=0&&U(E),ne&&(b==null||b())},[L,c,b,U,x,e]),q=s.useCallback(B=>{const ne=Math.floor(c/10),K=H.current;if(K===""){if(B>ne){J(String(B),!0);return}const se=String(B);x(se),g.current=window.setTimeout(()=>{J(H.current,!0)},1200);return}L();const Y=+`${K}${B}`;Y<=c?J(String(Y),!0):J(String(B),!0)},[L,J,c,x]),re=s.useCallback(B=>{L(),x(""),U(S.current+B)},[L,U,x]),R=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(),q(Number(B.key));return}B.key==="ArrowUp"?(B.preventDefault(),re(-1)):B.key==="ArrowDown"?(B.preventDefault(),re(1)):B.key==="Tab"&&(B.preventDefault(),L(),H.current!==""&&J(H.current,!1),B.shiftKey?f==null||f():b==null||b())},fe=s.useCallback(()=>{const B=a.current,ne=y.current;ne&&B===a.current&&U(bi(ne.scrollTop))},[U,a]),ee=()=>{if(H.current!=="")return;if($.current){$.current=!1;const ne=W();C(ne);const K=e.indexOf(ne);K>=0&&(S.current=K);return}C(W()),k.current&&window.clearTimeout(k.current);const B=a.current;k.current=window.setTimeout(()=>{B===a.current&&fe()},100)},j="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",Z=Ct*Uo,M=Z+Kt*2,_=v!==""?v:null,ce=_!==null;return t.jsxs("div",{ref:p,role:"spinbutton",tabIndex:u?0:-1,"aria-label":i,"aria-valuetext":_??r,"aria-valuenow":d?void 0:Number(r),onFocus:h,onMouseDown:()=>h==null?void 0:h(),onKeyDown:R,onBlur:()=>{L(),H.current!==""&&J(H.current,!1)},className:"relative shrink-0 rounded-lg outline-none",style:{width:l,height:M,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:j,style:{top:0,height:Kt,color:"var(--text-muted)",opacity:.35},onClick:()=>re(-1),children:t.jsx(z.HiChevronUp,{className:"h-3.5 w-3.5"})}),t.jsx("div",{ref:y,className:"absolute inset-x-0 overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",style:{top:Kt,height:Z,scrollSnapType:"y mandatory",scrollBehavior:"auto"},onScroll:ee,onMouseUp:fe,onTouchEnd:fe,children:P.map((B,ne)=>{const K=B!==""&&B===O;return t.jsx("button",{type:"button",tabIndex:-1,disabled:!B,onClick:()=>{if(!B)return;const Y=e.indexOf(B);Y>=0&&U(Y)},className:"flex w-full items-center justify-center tabular-nums leading-none disabled:cursor-default",style:{height:Ct,scrollSnapAlign:"center",color:K?"var(--text-main)":"var(--text-muted)",fontSize:K?16:14,fontWeight:K?600:400,opacity:B?ce?K?0:.35:K?1:.35:0},children:B},`wheel-${ne}-${B}`)})}),_!==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+Z/2-Ct/2,height:Ct,color:"var(--text-main)",fontSize:16,background:"var(--bg-card)"},children:_}):null,t.jsx("button",{type:"button","aria-label":"Valor siguiente",className:j,style:{bottom:0,height:Kt,color:"var(--text-muted)",opacity:.35},onClick:()=>re(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:Ct,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=pb({use12Hour:n,hour12:a}),p=s.useRef(e),y=jo(e,Wr()),k=fa(y),[g,H]=s.useState(ot(f?k.hour12:y.hour24)),[S,$]=s.useState(ot(y.minute)),[O,C]=s.useState(ot(y.second)),[v,T]=s.useState(k.meridiem),[x,P]=s.useState(0),W=s.useRef(0),U=s.useRef(!1),L=s.useRef({hour:null,minute:null,second:null,meridiem:null}),[J,q]=s.useState("hour"),re=s.useMemo(()=>{const oe=["hour","minute"];return o&&oe.push("second"),f&&oe.push("meridiem"),oe},[f,o]),R=s.useCallback(oe=>{q(ge=>{const Me=re.indexOf(ge);return re[(Me+oe+re.length)%re.length]})},[re]);s.useEffect(()=>{var oe;(oe=L.current[J])==null||oe.focus()},[J]),s.useEffect(()=>{var oe;q("hour"),(oe=L.current.hour)==null||oe.focus()},[]),s.useEffect(()=>{if(e===p.current)return;p.current=e;const oe=jo(e,Wr()),ge=fa(oe);H(ot(f?ge.hour12:oe.hour24)),$(ot(oe.minute)),C(ot(oe.second)),T(ge.meridiem)},[f,e]);const fe=s.useMemo(()=>(f?qo(1,12):qo(0,23)).map(oe=>ot(oe)),[f]),ee=s.useMemo(()=>qo(0,59).map(oe=>ot(oe)),[]),j=ee,Z=s.useMemo(()=>["AM","PM"],[]),M=s.useCallback(()=>f?wn({hour12:Number(g),minute:Number(S),second:Number(O),meridiem:v}):{hour24:Number(g),minute:Number(S),second:Number(O)},[g,f,v,S,O]),_=s.useCallback(oe=>{if(U.current)return;const ge=xn(oe,o);p.current=ge,r(ge)},[r,o]),ce=s.useCallback(()=>{_(M())},[M,_]),B=oe=>{H(oe),b&&_(f?wn({hour12:Number(oe),minute:Number(S),second:Number(O),meridiem:v}):{hour24:Number(oe),minute:Number(S),second:Number(O)})},ne=oe=>{$(oe),b&&_(f?wn({hour12:Number(g),minute:Number(oe),second:Number(O),meridiem:v}):{hour24:Number(g),minute:Number(oe),second:Number(O)})},K=oe=>{C(oe),b&&_(f?wn({hour12:Number(g),minute:Number(S),second:Number(oe),meridiem:v}):{hour24:Number(g),minute:Number(S),second:Number(oe)})},Y=oe=>{T(oe),b&&_(wn({hour12:Number(g),minute:Number(S),second:Number(O),meridiem:oe}))},se=s.useCallback(()=>(W.current+=1,P(W.current),W.current),[]),E=s.useCallback(oe=>{const ge=fa(oe),Me=xn(oe,o);p.current=Me,H(ot(f?ge.hour12:oe.hour24)),$(ot(oe.minute)),C(ot(oe.second)),T(ge.meridiem),r(Me)},[f,r,o]),Q=()=>{U.current=!0,se(),E(Wr()),queueMicrotask(()=>{const oe=Wr();xn(oe,o)!==p.current&&(se(),E(oe)),U.current=!1})},ie=()=>{ce(),d==null||d()},X=Ct*Uo,w=X+Kt*2,N=Kt+X/2-Ct/2,te=t.jsx("div",{className:"relative px-4 py-2",children:t.jsxs("div",{className:"relative mx-auto",style:{height:w,maxWidth:"100%"},children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-10 rounded-xl",style:{top:N,height:Ct,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:Ct*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:Ct*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:W,forceSyncAt:x,values:fe,selected:g,onSelect:B,label:"Horas",maxNumeric:f?12:23,isFocused:J==="hour",onFocus:()=>q("hour"),onAdvance:()=>R(1),onBack:()=>R(-1),setColumnRef:oe=>{L.current.hour=oe}}),t.jsx(hi,{}),t.jsx(ba,{syncEpochRef:W,forceSyncAt:x,values:ee,selected:S,onSelect:ne,label:"Minutos",maxNumeric:59,isFocused:J==="minute",onFocus:()=>q("minute"),onAdvance:()=>R(1),onBack:()=>R(-1),setColumnRef:oe=>{L.current.minute=oe}}),o?t.jsxs(t.Fragment,{children:[t.jsx(hi,{}),t.jsx(ba,{syncEpochRef:W,forceSyncAt:x,values:j,selected:O,onSelect:K,label:"Segundos",maxNumeric:59,isFocused:J==="second",onFocus:()=>q("second"),onAdvance:()=>R(1),onBack:()=>R(-1),setColumnRef:oe=>{L.current.second=oe}})]}):null,f?t.jsx("div",{className:"ml-3 shrink-0 pl-1",children:t.jsx(ba,{syncEpochRef:W,forceSyncAt:x,values:Z,selected:v,onSelect:oe=>Y(oe),width:mb,label:"AM o PM",isMeridiem:!0,isFocused:J==="meridiem",onFocus:()=>q("meridiem"),onAdvance:()=>R(1),onBack:()=>R(-1),setColumnRef:oe=>{L.current.meridiem=oe}})}):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(Ve,{variant:"ghost",size:"sm",onClick:Q,className:h?"text-xs":void 0,children:"Ahora"}),!h&&(c||d)?t.jsxs("div",{className:"flex items-center gap-2",children:[c?t.jsx(Ve,{variant:"ghost",size:"sm",onClick:c,children:"Cancelar"}):null,d?t.jsx(Ve,{variant:"primary",size:"sm",onClick:ie,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 gb(e){return e.use12Hour??e.hour12??!1}function vb({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:y,contentClassName:k,className:g=""}){const H=u==="popover",[S,$]=s.useState(!1),O=s.useRef(null),[C,v]=s.useState({horizontal:"left",vertical:"bottom"}),T=gb({use12Hour:a,hour12:o}),x=s.useMemo(()=>r?fb(r,{use12Hour:T,showSeconds:l}):"",[T,l,r]);s.useEffect(()=>{if(!H||!S||!O.current)return;const U=O.current.getBoundingClientRect(),L=8,J=T?l?300:260:l?252:212,q=276,re=U.left+J>window.innerWidth-L,R=U.right-J>=L,fe=U.bottom+8+q>window.innerHeight-L,ee=U.top-8-q>=L;v({horizontal:re&&R?"right":"left",vertical:fe&&ee?"top":"bottom"})},[T,H,S,l]),s.useEffect(()=>{if(!H||!S)return;function U(J){O.current&&(O.current.contains(J.target)||$(!1))}function L(J){J.key==="Escape"&&$(!1)}return document.addEventListener("mousedown",U),document.addEventListener("keydown",L),()=>{document.removeEventListener("mousedown",U),document.removeEventListener("keydown",L)}},[H,S]);const P=t.jsxs("button",{type:"button",disabled:d,onClick:()=>{d||$(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 ${g}`,style:{background:"var(--bg-input)",borderColor:b?"var(--danger)":S?"var(--primary)":"var(--border)",color:x?"var(--text-main)":"var(--text-muted)",boxShadow:S?"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:x||c})]}),H?t.jsx(z.HiChevronDown,{className:`h-4 w-4 shrink-0 text-[var(--text-muted)] transition-transform duration-150 ${S?"rotate-180":""}`}):null]}),W=t.jsx(mi,{variant:H?"popover":"panel",value:r||bb(l),onChange:n,use12Hour:T,showSeconds:l,title:i,onClose:()=>$(!1)});return t.jsx(Qn,{label:e,required:h,error:b,helperText:f,helperDisplay:p,className:y,contentClassName:k,children:H?t.jsxs("div",{ref:O,className:"relative w-full",children:[P,S?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:W}):null]}):t.jsxs("div",{className:"space-y-2",children:[P,S?W:null]})})}const yb={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function xb({checked:e,disabled:r,onCheckedChange:n,size:a="sm",className:o="",...l}){const i=yb[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 wb(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 Nb(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 kb(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 Cb(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 Sb(e){const r=document.querySelector(e);r instanceof HTMLElement&&r.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}function Eb({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,y]=s.useState(0),[k,g]=s.useState(null),[H,S]=s.useState(!1),$=e[p]??e[0],O=e.length;s.useEffect(()=>{S(!0)},[]),s.useEffect(()=>{r&&y(0)},[r]),s.useEffect(()=>{!r||!$||l==null||l($,p)},[r,$,p,l]);const C=s.useCallback(()=>{$&&g(wb($.target))},[$]);s.useLayoutEffect(()=>{if(!r||!$)return;Sb($.target);const W=window.setTimeout(C,80),U=window.setTimeout(C,280);return()=>{window.clearTimeout(W),window.clearTimeout(U)}},[r,$,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 v=s.useCallback(()=>{if(n(!1),!!o)try{localStorage.setItem(o,"done")}catch{}},[n,o]);s.useEffect(()=>{if(!r)return;function W(U){if(U.key==="Escape"){U.preventDefault(),v();return}if(U.key==="ArrowRight"||U.key==="Enter"){U.preventDefault(),y(L=>Math.min(L+1,O-1));return}U.key==="ArrowLeft"&&(U.preventDefault(),y(L=>Math.max(L-1,0)))}return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[r,v,O]);const T=s.useMemo(()=>!k||!$?"bottom":Nb($.placement,k),[k,$]),x=s.useMemo(()=>k?kb(k):null,[k]),P=s.useMemo(()=>typeof window>"u"?{top:96,left:16}:x?Cb(x,T):{top:96,left:Math.max(16,(window.innerWidth-jr)/2)},[x,T]);return!H||!r||!$?null:ht.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:v}),x?t.jsx("div",{className:"pointer-events-none absolute rounded-xl border-2 border-[var(--primary)] transition-all duration-200",style:{top:x.top,left:x.left,width:x.width,height:x.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:{...P,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,"/",O]}),t.jsx("h2",{id:f,className:"mt-0.5 text-sm font-semibold text-[var(--text-main)]",children:$.title})]}),t.jsx(Ve,{variant:"icon",iconOnly:!0,"aria-label":h,tooltip:"Cerrar",onClick:v,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:[$.body,$.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:$.caption}):null]}),t.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2",children:[t.jsx(Ve,{variant:"secondary",size:"sm",disabled:p===0,onClick:()=>y(W=>Math.max(W-1,0)),children:i}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ve,{variant:"secondary",size:"sm",onClick:v,children:c}),p<O-1?t.jsx(Ve,{size:"sm",onClick:()=>y(W=>Math.min(W+1,O-1)),children:d}):t.jsx(Ve,{size:"sm",onClick:v,children:u})]})]})]})]}),document.body)}function Mb(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(","),Tb=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function $b(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 Ab(e){const r=e.querySelector(Tb);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(!$b(l))return;const c={overflow:gi(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},d=Ab(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 Lb(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",Db={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"],Ob={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},Hb="bonsaif.bot",Bb="Bonsaif Bot",Ib={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 Fb(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 Lb(window.location.pathname)}function _b(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 Pb(e){let r=0;for(const n of e)r=r*31+n.charCodeAt(0)&65535;return Ni[r%Ni.length]}function zb(e,r){return e===Hb||r===Bb}function Wb(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:y}){const[k,g]=s.useState(!1),H=typeof e=="string"&&e.trim()&&e!=="undefined"&&e!=="null"?e.trim():"";s.useEffect(()=>{g(!1)},[H,f]);const{wh:S,text:$}=Db[a],O=ki(n)||ki(r)||c,C=_b(O),v=Fb(d),T=zb(r,n),x=Wb(v,"/favicon.svg"),P=s.useMemo(()=>{if(!H)return"";const q=new URLSearchParams;q.set("size",String(wi[a])),f&&q.set("v",String(f));const re=q.toString();return`${v}/api/user/avatar/${encodeURIComponent(H)}${re?`?${re}`:""}`},[f,v,H,a]),W=wi[a],U=T?t.jsx("span",{className:`${S} ${Ib[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:y,children:t.jsx("img",{src:x,alt:O,width:W,height:W,className:"h-full w-full object-contain"})}):P&&!k?t.jsx("img",{src:P,alt:O,width:W,height:W,className:`${S} rounded-full object-cover flex-shrink-0 ${p}`,style:y,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>g(!0)},`${H}-${f}`):t.jsx("span",{className:`${S} ${Pb(O)} ${$} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${p}`,style:y,title:O,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 ${Ob[b]} font-medium text-[var(--text-main)] ${h}`,title:O,children:O})]});const L=l??!0,J=i??O;return L&&J?t.jsx(Pt,{as:"span",content:J,className:`inline-flex flex-shrink-0 ${u}`,children:U}):U}function jb({href:e,className:r,children:n}){return t.jsx("a",{href:e,className:r,children:n})}function qb(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=jb}){const[h,b]=s.useState(!1),f=qb(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,y])=>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:y.map(k=>{const g=n===k.href||n.startsWith(`${k.href}/`);return t.jsxs(u,{href:k.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${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:k.icon??t.jsx(z.HiHome,{className:"h-4 w-4"})}),t.jsx("span",{className:"truncate",children:k.label})]},k.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(Ve,{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",Ub={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 Vb(e){return e.split("-").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function Xb(e){return/^\d+$/.test(e)||/^[a-f0-9]{8,}$/i.test(e)}function Yb(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=Xb(n)&&a?a:n,l=Ub[o]??Vb(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 Gb(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 Kb(e){return e.includes("primeAuthOrigin")||e.includes("primeAuthProjectKey")}function Mi(){if(typeof window>"u")return!1;if(Kb(window.location.href)){try{window.sessionStorage.setItem(Ei,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Ei)==="true"}catch{return!1}}function Zb({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),[y,k]=s.useState(d??"/"),[g,H]=s.useState(()=>Mi()),[S,$]=s.useState(null),O=d??y,C=c??Yb(O),v=o??Gb(O),T=u&&!g&&C.length>1,x=!T;s.useEffect(()=>{d||k(window.location.pathname)},[d]),s.useEffect(()=>{H(Mi())},[]),s.useEffect(()=>{if(h){p(!1);return}let W=null,U=0,L=0;const J=()=>{const R=b.current,fe=document.querySelector("[data-app-scroll='true']");return(R==null?void 0:R.closest(".os-viewport"))??(R==null?void 0:R.closest("[data-overlayscrollbars-viewport]"))??Go(fe)??fe??window},q=()=>{const R=W&&W!==window?W.scrollTop:window.scrollY;p(fe=>fe?R>24:R>72)},re=()=>{W==null||W.removeEventListener("scroll",q),W=J(),W.addEventListener("scroll",q,{passive:!0}),q()};return re(),U=window.requestAnimationFrame(re),L=window.setTimeout(re,120),()=>{window.cancelAnimationFrame(U),window.clearTimeout(L),W==null||W.removeEventListener("scroll",q)}},[h]),s.useEffect(()=>{if(h){$(null);return}let W=0;const U=[],L=()=>{const j=b.current,Z=j==null?void 0:j.parentElement,M=document.querySelector("[data-app-scroll='true']"),_=Go(M)??M;if(!j||!Z||!_){$(null);return}const ce=Z.getBoundingClientRect(),B=window.getComputedStyle(Z),ne=_.getBoundingClientRect(),K=_ instanceof HTMLElement&&_.clientWidth>0?_.clientWidth:ne.width,Y=ce.left+parseFloat(B.paddingLeft||"0"),se={marginLeft:Math.round(ne.left-Y),width:Math.round(K)};$(E=>E&&E.marginLeft===se.marginLeft&&E.width===se.width?E:se)},J=()=>{window.cancelAnimationFrame(W),W=window.requestAnimationFrame(L)};J(),window.addEventListener("resize",J);const q=new ResizeObserver(J),re=b.current,R=re==null?void 0:re.parentElement,fe=document.querySelector("[data-app-scroll='true']"),ee=Go(fe)??fe;return[R,fe,ee].forEach(j=>{j&&q.observe(j)}),U.push(window.setTimeout(J,120)),U.push(window.setTimeout(J,280)),()=>{window.cancelAnimationFrame(W),window.removeEventListener("resize",J),q.disconnect(),U.forEach(j=>window.clearTimeout(j))}},[h]);const P={...S?{marginLeft:S.marginLeft,width:S.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:P,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":x?"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||x?"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||x?"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:v}),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 Qb({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 Jb(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 Rb({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(()=>Jb(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,y,k;if(h.source!==((p=l.current)==null?void 0:p.contentWindow)||c&&h.origin!==c)return;if(((y=h.data)==null?void 0:y.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!h.data.active}}));return}if(((k=h.data)==null?void 0:k.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 eh(){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 th(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 rh(){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 nh(){return"light"}function ah({position:e="bottom-center"}){const r=s.useSyncExternalStore(th,rh,nh);return t.jsx(Xa.Toaster,{position:e,theme:r,richColors:!0,closeButton:!0})}function oh({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 St=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 Et({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 Mt({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,pr="ease-out",sh={top:18,right:8,bottom:12,left:0};function Cn(e){return{...sh,...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 Tt(){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 lh(e,r=St){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 ih({active:e,label:r,payload:n,valueFormat:a=St}){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,y)=>{const k=p.payload,g=k&&typeof k.display=="number"?k.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:lh(g,a)})]},String(p.dataKey??p.name??y))})})]})}function Yr({valueFormat:e,content:r,cursor:n,offset:a=12,wrapperStyle:o,allowEscapeViewBox:l,reverseDirection:i,...c}){return t.jsx(Le.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(ih,{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"),y=s.useCallback(U=>{d(U),i==null||i(U)},[i]),k=s.useCallback(()=>{h(null),y(null)},[y]),g=!!c,H=s.useMemo(()=>!c||f?e:e.slice(c.startIndex,c.endIndex+1),[e,f,c]),S=s.useCallback((U,L)=>{const J=Hi(e,r,U),q=Hi(e,r,L);J<0||q<0||y(Bi(J,q,e.length))},[y,e,r]),$=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]),O=s.useCallback(U=>{!p||!u||(U==null?void 0:U.activeLabel)===void 0||(U==null?void 0:U.activeLabel)===null||h(L=>L&&{...L,rightLabel:U.activeLabel})},[u,p]),C=s.useCallback(()=>{if(p){if(!u||u.rightLabel===null||u.rightLabel===void 0){h(null);return}S(u.leftLabel,u.rightLabel),h(null)}},[S,u,p]),v=s.useCallback(U=>{if(f){if(!U){y(null);return}y(Bi(U.startIndex??0,U.endIndex??e.length-1,e.length))}},[y,e.length,f]),T=p?{onMouseDown:$,onMouseMove:O,onMouseUp:C,onMouseLeave:()=>{u&&C()}}:{},x=c??{startIndex:0,endIndex:Math.max(0,e.length-1)},P=t.jsxs(t.Fragment,{children:[p&&u&&u.rightLabel!==null&&u.rightLabel!==void 0?t.jsx(Le.ReferenceArea,{x1:u.leftLabel,x2:u.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,f?t.jsx(Le.Brush,{dataKey:r,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:x.startIndex,endIndex:x.endIndex,onChange:v,tickFormatter:U=>String(U)}):null]}),W=f?{bottom:Math.max(l+10,36)}:void 0;return{enabled:b,showBrush:f,showDrag:p,viewData:H,isZoomed:g,resetZoom:k,chartHandlers:T,zoomNodes:P,marginExtra:W}}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 ch({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=St,yDomain:f,ariaLabel:p="Gráfico de líneas",curve:y=!0,strokeWidth:k=2.25,zoomable:g=!1,zoomMode:H="both",brushHeight:S,onZoomChange:$}){const O=pa(e,n),C=Sn(n),v=va(e,r,{zoomable:g,zoomMode:H,brushHeight:S,onZoomChange:$}),T=Cn({...h,...v.marginExtra});return l?t.jsx(Et,{height:a}):O?t.jsx(Mt,{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:v.isZoomed,onReset:v.resetZoom}),t.jsx(Le.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Le.LineChart,{data:v.viewData,margin:T,...v.chartHandlers,children:[c?t.jsx(Le.CartesianGrid,{strokeDasharray:"2 8",stroke:En(),vertical:!1}):null,t.jsx(Le.XAxis,{dataKey:r,tick:Tt(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Le.YAxis,{tick:Tt(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:x=>b(Number(x)),dx:-2}),u?t.jsx(Yr,{valueFormat:b,cursor:{stroke:Di(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Le.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ga()}):null,C.map((x,P)=>t.jsx(Le.Line,{type:y?"monotone":"linear",dataKey:x.key,name:x.label,stroke:x.color,strokeWidth:P===0?k+.35:k,strokeOpacity:P===0?1:.88,isAnimationActive:!0,animationDuration:lr,animationEasing:pr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:x.color}},x.key)),v.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=St,yDomain:f,ariaLabel:p="Gráfico de área",stacked:y=!1,opacity:k=.22,zoomable:g=!1,zoomMode:H="both",brushHeight:S,onZoomChange:$}){const O=pa(e,n),C=Sn(n),v=va(e,r,{zoomable:g,zoomMode:H,brushHeight:S,onZoomChange:$}),T=Cn({...h,...v.marginExtra});return l?t.jsx(Et,{height:a}):O?t.jsx(Mt,{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:v.isZoomed,onReset:v.resetZoom}),t.jsx(Le.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Le.AreaChart,{data:v.viewData,margin:T,...v.chartHandlers,children:[t.jsx("defs",{children:C.map(x=>t.jsxs("linearGradient",{id:Oi(x.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:x.color,stopOpacity:Math.min(.55,k+.28)}),t.jsx("stop",{offset:"48%",stopColor:x.color,stopOpacity:k*.5}),t.jsx("stop",{offset:"100%",stopColor:x.color,stopOpacity:0})]},x.key))}),c?t.jsx(Le.CartesianGrid,{strokeDasharray:"2 8",stroke:En(),vertical:!1}):null,t.jsx(Le.XAxis,{dataKey:r,tick:Tt(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Le.YAxis,{tick:Tt(),tickLine:!1,axisLine:!1,width:44,domain:f??["auto","auto"],tickFormatter:x=>b(Number(x)),dx:-2}),u?t.jsx(Yr,{valueFormat:b,cursor:{stroke:Di(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Le.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ga()}):null,C.map(x=>t.jsx(Le.Area,{type:"monotone",dataKey:x.key,name:x.label,stroke:x.color,fill:`url(#${Oi(x.key)})`,strokeWidth:2.25,stackId:y?"stack":void 0,isAnimationActive:!0,animationDuration:lr,animationEasing:pr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:x.color}},x.key)),v.zoomNodes]})})]})}function dh({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=St,yDomain:f,ariaLabel:p="Gráfico de barras",layout:y="vertical",mode:k="grouped",barRadius:g=6,categoryAxisWidth:H=64,zoomable:S=!1,zoomMode:$="both",brushHeight:O,onZoomChange:C}){const v=pa(e,n),T=Sn(n),x=y==="horizontal",P=va(e,r,{zoomable:S&&!x,zoomMode:$,brushHeight:O,onZoomChange:C}),W=Cn({...h,...P.marginExtra});return l?t.jsx(Et,{height:a}):v?t.jsx(Mt,{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:P.isZoomed,onReset:P.resetZoom}),t.jsx(Le.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Le.BarChart,{data:P.viewData,margin:W,layout:x?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,...P.chartHandlers,children:[c?t.jsx(Le.CartesianGrid,{strokeDasharray:"2 8",stroke:En(),horizontal:!x,vertical:x}):null,x?t.jsxs(t.Fragment,{children:[t.jsx(Le.XAxis,{type:"number",tick:Tt(),tickLine:!1,axisLine:!1,tickFormatter:U=>b(Number(U)),domain:f??["auto","auto"]}),t.jsx(Le.YAxis,{type:"category",dataKey:r,tick:Tt(),tickLine:!1,axisLine:!1,width:H})]}):t.jsxs(t.Fragment,{children:[t.jsx(Le.XAxis,{dataKey:r,tick:Tt(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Le.YAxis,{tick:Tt(),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(Le.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ga()}):null,T.map((U,L)=>t.jsx(Le.Bar,{dataKey:U.key,name:U.label,fill:U.color,fillOpacity:L===0?1:.82,radius:x?[0,g,g,0]:[g,g,2,2],maxBarSize:20,stackId:k==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:lr,animationEasing:pr},U.key)),P.zoomNodes]})})]})}function uh(e){return t.jsx(Fi,{...e,variant:"pie"})}function fh(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=St,ariaLabel:h,innerRadius:b,outerRadius:f,colors:p=[...Nn],padAngle:y,cornerRadius:k,variant:g}){const H=e.map((L,J)=>({name:String(L[r]??""),value:qr(L[n])??0,fill:p[J%p.length],row:L})).filter(L=>L.value>0),S=!H.length,$=g==="donut",O=H.length,C=Ii(b,$?62:12),v=Ii(f,78),T=Math.min(y??($?2:3),Math.max(.5,10/Math.max(1,O))),x=Math.min(k??($?10:8),Math.max(2,36/Math.max(1,O)));if(l)return t.jsx(Et,{height:a});if(S)return t.jsx(Mt,{height:a,text:i});const P=H.reduce((L,J)=>L+J.value,0),W=c?Math.min(96,28+Math.ceil(O/3)*22):0,U=Math.max(140,a-W);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:U},children:t.jsx(Le.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Le.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[d?t.jsx(Yr,{valueFormat:u,isAnimationActive:!1}):null,t.jsx(Le.Pie,{data:H,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${C}%`,outerRadius:`${v}%`,startAngle:90,endAngle:-270,paddingAngle:T,cornerRadius:x,minAngle:O>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:lr,animationEasing:pr,label:!1,activeShape:bh,children:H.map(L=>t.jsx(Le.Cell,{fill:L.fill},L.name))}),$?t.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:u(P)}):null]})})}),c?t.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:H.map(L=>t.jsxs("li",{className:"bonsaif-pie-legend-item",children:[t.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:L.fill},"aria-hidden":!0}),t.jsx("span",{className:"bonsaif-pie-legend-label",title:L.name,children:L.name}),t.jsx("span",{className:"bonsaif-pie-legend-value",children:u(L.value)})]},L.name))}):null]})})}function bh(e){const{outerRadius:r=0,...n}=e;return t.jsx(Le.Sector,{...n,outerRadius:Number(r)+4,stroke:"var(--bg-card)",strokeWidth:2})}function hh({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(v=>qr(v[r])).filter(v=>v!==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,y=1,k=Math.min(...h),H=Math.max(...h)-k||1,S=h.map((v,T)=>{const x=y+T/(h.length-1)*(b-y*2),P=f-p-(v-k)/H*(f-p*2);return{x,y:P}}),$=S.map((v,T)=>`${T===0?"M":"L"}${v.x.toFixed(2)} ${v.y.toFixed(2)}`).join(" "),O=`${$} L${S[S.length-1].x.toFixed(2)} ${f} L${S[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:O,fill:`url(#${C})`}):null,t.jsx("path",{d:$,fill:"none",stroke:u,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function mh({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=St,yDomain:y,ariaLabel:k="Gráfico combinado",barRadius:g=6,zoomable:H=!1,zoomMode:S="both",brushHeight:$,onZoomChange:O}){const C=a??n.slice(0,Math.max(1,n.length-1)),v=o??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),T=[...C,...v.filter(q=>!C.some(re=>re.key===q.key))],x=pa(e,T),P=Sn(C),W=Sn(T),U=v.map(q=>{var R;const re=W.find(fe=>fe.key===q.key);return{...q,label:q.label??q.key,color:q.color??(re==null?void 0:re.color)??((R=W[0])==null?void 0:R.color)}}),L=va(e,r,{zoomable:H,zoomMode:S,brushHeight:$,onZoomChange:O}),J=Cn({...f,...L.marginExtra});return c?t.jsx(Et,{height:l}):x?t.jsx(Mt,{height:l,text:d}):t.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":k,style:{height:l},children:[t.jsx(ya,{visible:L.isZoomed,onReset:L.resetZoom}),t.jsx(Le.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Le.ComposedChart,{data:L.viewData,margin:J,barCategoryGap:"34%",...L.chartHandlers,children:[u?t.jsx(Le.CartesianGrid,{strokeDasharray:"2 8",stroke:En(),vertical:!1}):null,t.jsx(Le.XAxis,{dataKey:r,tick:Tt(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Le.YAxis,{tick:Tt(),tickLine:!1,axisLine:!1,width:44,domain:y??["auto","auto"],tickFormatter:q=>p(Number(q)),dx:-2}),b?t.jsx(Yr,{valueFormat:p,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,h?t.jsx(Le.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:ga()}):null,P.map(q=>t.jsx(Le.Bar,{dataKey:q.key,name:q.label,fill:q.color,fillOpacity:.88,radius:[g,g,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:lr,animationEasing:pr},q.key)),U.map(q=>t.jsx(Le.Line,{type:"monotone",dataKey:q.key,name:q.label,stroke:q.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:lr,animationEasing:pr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:q.color}},q.key)),L.zoomNodes]})})]})}function ph({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=St,ariaLabel:f="Gráfico waterfall",increaseColor:p="#34d399",decreaseColor:y="#f87171",totalColor:k="var(--primary)"}){const g=s.useMemo(()=>gh(e,{xKey:r,valueKey:n,typeKey:a,increaseColor:p,decreaseColor:y,totalColor:k}),[e,r,n,a,p,y,k]),H=!g.length,S=Cn(h);return i?t.jsx(Et,{height:o}):H?t.jsx(Mt,{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(Le.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Le.BarChart,{data:g,margin:S,barCategoryGap:"42%",children:[d?t.jsx(Le.CartesianGrid,{strokeDasharray:"2 8",stroke:En(),vertical:!1}):null,t.jsx(Le.XAxis,{dataKey:"label",tick:Tt(),tickLine:!1,axisLine:!1,interval:0,dy:6}),t.jsx(Le.YAxis,{tick:Tt(),tickLine:!1,axisLine:!1,width:44,tickFormatter:$=>b(Number($)),dx:-2}),u?t.jsx(Yr,{valueFormat:b,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,t.jsx(Le.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),t.jsx(Le.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:lr,animationEasing:pr,children:g.map($=>t.jsx(Le.Cell,{fill:$.color},$.label))})]})})})}function gh(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",vh=`
53
53
  @keyframes bonsaif-funnel-stage-in {
54
54
  from {
55
55
  opacity: 0;
@@ -89,4 +89,4 @@ ${O}`,be=new Blob(["\uFEFF"+le],{type:"text/csv;charset=utf-8;"}),we=URL.createO
89
89
  animation: none !important;
90
90
  }
91
91
  }
92
- `;function yh(){if(typeof document>"u"||document.getElementById(_i))return;const e=document.createElement("style");e.id=_i,e.textContent=vh,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 xh(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 wh(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 Nh({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)),N=wa(d,"#000",r?.12:.22),v=wa(d,"#fff",r?.08:0),H=wa(d,"#fff",.22),S=[`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:S,fill:N}),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:H,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 kh({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:N=lr,valueFormat:v=St,ariaLabel:H="Gráfico embudo"}){const[S,M]=s.useState(null),[D,C]=s.useState(!1),x=s.useMemo(()=>xh(e,r,n,a,o,g),[e,r,n,a,o,g]),$=s.useMemo(()=>x.map(Z=>`${Z.name}:${Z.value}`).join("|"),[x]);if(s.useEffect(()=>{if(yh(),typeof window>"u")return;const Z=window.matchMedia("(prefers-reduced-motion: reduce)");C(Z.matches);const Y=()=>C(Z.matches);return Z.addEventListener("change",Y),()=>Z.removeEventListener("change",Y)},[]),c)return t.jsx(Et,{height:l});if(!x.length)return t.jsx(Mt,{height:l,text:d});const y=N>0&&!D,P=N,j=Math.min(90,Math.max(40,Math.round(N/8))),U=Math.round(P*.15),L=x.length*j+Math.round(P*.35),J=x.some(Z=>Z.title||Z.description),q=h?160:24,ae=J?168:24,R=f?36:8,fe=q+220+ae,I=l,K=18,ee=Math.max(120,I-K-R-8),T=q+110,ie=wh(x,{cx:T,topY:K,plotH:ee,maxTopW:200,taper:Pi(p,.2,.95),gap:10}),B=S!=null?ie[S]:null,re="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":H,style:{height:l},children:[t.jsxs("svg",{viewBox:`0 0 ${fe} ${I}`,width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",children:[h?t.jsx("line",{className:y?"bonsaif-funnel-label":void 0,style:y?{animation:`bonsaif-funnel-fade-in ${P}ms ${re} both`}:void 0,x1:q-12,y1:K,x2:q-12,y2:K+ee,stroke:"var(--border)",strokeDasharray:"3 5",strokeWidth:1}):null,ie.map(Z=>{const Y=Z.y+Z.h/2,se=Z.cx-Z.topW/2,E=Z.index*j,Q=y?{animation:`bonsaif-funnel-stage-in ${P}ms ${re} ${E}ms both`}:void 0,ce=y?{animation:`bonsaif-funnel-fade-in ${Math.round(P*.85)}ms ${re} ${E+U}ms both`}:void 0;return t.jsxs("g",{children:[t.jsx("g",{className:"bonsaif-funnel-stage",style:Q,children:t.jsx(Nh,{stage:Z,hovered:S===Z.index,onHover:M})}),h?t.jsxs("g",{className:"bonsaif-funnel-label",style:ce,children:[t.jsx("line",{x1:24,y1:Y,x2:q-12,y2:Y,stroke:Z.color,strokeOpacity:.55,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("line",{x1:q-12,y1:Y,x2:se-6,y2:Y,stroke:Z.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("text",{x:20,y:Y-(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:Y+10,textAnchor:"end",fill:"var(--text-muted)",fontSize:11,children:v(Z.value)}):null]}):null,(Z.title||Z.description)&&J?t.jsxs("g",{className:"bonsaif-funnel-anno",style:ce,children:[t.jsx("line",{x1:Z.cx+Z.bottomW/2+6,y1:Y,x2:q+220+8,y2:Y,stroke:Z.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),Z.title?t.jsx("text",{x:q+220+14,y:Y-(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:q+220+14,y:Y+(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(${T}, ${K+ee+8})`,fill:"var(--primary)",style:y?{animation:`bonsaif-funnel-arrow-in ${Math.round(P*.7)}ms ${re} ${L}ms both`}:void 0,children:t.jsx("path",{d:"M0,22 L10,8 L4,8 L4,0 L-4,0 L-4,8 L-10,8 Z"})}):null]},$),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 Ch({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=St,tone:h="primary",color:b,thresholds:f,ariaLabel:p="Gauge",animationDuration:g=700,thickness:N=9,showScale:v=!1}){const H=s.useId().replace(/:/g,""),S=n-r||1,M=Math.min(1,Math.max(0,(e-r)/S)),[D,C]=s.useState(g>0?0:M);if(s.useEffect(()=>{if(l||i)return;if(g<=0){C(M);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){C(M);return}let fe=0,I=0;C(T=>(I=T,T));const K=performance.now(),ee=T=>{const W=Math.min(1,(T-K)/g),ie=1-(1-W)**3;C(I+(M-I)*ie),W<1&&(fe=requestAnimationFrame(ee))};return fe=requestAnimationFrame(ee),()=>cancelAnimationFrame(fe)},[M,g,l,i]),l)return t.jsx(Et,{height:a});if(i)return t.jsx(Mt,{height:a,text:c});const x=100,$=108,y=72,P=b??Sh(e,n,h,f),j=r+D*S,U=zi(x,$,y,Gr,Gr+Zo),L=Gr+Math.max(.001,D)*Zo,J=zi(x,$,y,Gr,L),q=Na(x,$,y,Gr),ae=Na(x,$,y,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-${H}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[t.jsx("stop",{offset:"0%",stopColor:P,stopOpacity:.82}),t.jsx("stop",{offset:"100%",stopColor:P,stopOpacity:1})]})}),t.jsx("path",{d:U,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:N,strokeLinecap:"butt"}),t.jsx("path",{d:J,fill:"none",stroke:`url(#bonsaif-gauge-${H})`,strokeWidth:N,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),t.jsx("text",{x,y:$-(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(j)}),d?t.jsx("text",{x,y:$+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:q.x-2,y:q.y+N+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(r)}),t.jsx("text",{x:ae.x+2,y:ae.y+N+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(n)})]}):null]})})}function Sh(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 Eh({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=St,tone:f="primary",showScale:p=!0,showStatus:g=!0,ariaLabel:N="Bullet chart"}){if(i)return t.jsx(Et,{height:o});if(c)return t.jsx(Mt,{height:o,text:d});const v=n??Math.max(e,r,...(a==null?void 0:a.map(P=>P.value))??[],1)*1.05,S=[...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((P,j)=>P.value-j.value),M=qt(f),D=Math.min(100,Math.max(0,e/v*100)),C=Math.min(100,Math.max(0,r/v*100)),x=e>=r,$=[0,.25,.5,.75,1].map(P=>P*v),y=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":N,children:[t.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:S.map((P,j)=>{const U=j===0?0:S[j-1].value,L=Math.max(0,(P.value-U)/v*100);return t.jsx("div",{style:{width:`${L}%`,background:P.color??`color-mix(in srgb, var(--border) ${70-j*18}%, transparent)`}},j)})}),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:`${D}%`,background:M,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${M} 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:M,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:$.map((P,j)=>{const U=P/v*100,L=j===0,J=j===$.length-1;return t.jsxs("div",{className:"absolute top-0",style:{left:`${U}%`,transform:L?"none":J?"translateX(-100%)":"translateX(-50%)"},children:[t.jsx("div",{className:"mx-auto h-1.5 w-px",style:{background:"color-mix(in srgb, var(--text-muted) 55%, transparent)",marginLeft:L?0:J?"auto":void 0,marginRight:J?0:void 0}}),t.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:L?"left":J?"right":"center"},children:b(P)})]},P)})}):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:M,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(x?"success":"warning")},children:x?"En meta":"Bajo meta"}):null]}),y]}):y})}function Mh({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 N=o??[{key:a,label:"Uso",color:kn(r??Xr(e,a)??0,f)}],v=r??Xr(e,a)??Xr(e,((C=N[0])==null?void 0:C.key)??a),H=!d&&(!e.length||v===null);if(d)return t.jsx(Et,{height:i});if(H)return t.jsx(Mt,{height:i,text:u});const S=Math.min(100,Math.max(0,v??0)),M=ma(S,f),D=kn(S,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:D},children:Ur(S,S<10?1:0)})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:D,background:`color-mix(in srgb, ${D} 14%, transparent)`},children:M==="danger"?"Crítico":M==="warning"?"Alto":"Normal"})]}),t.jsx(xa,{data:e,xKey:n,series:N.map(x=>({...x,color:x.color??D})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:h,showTooltip:b,valueFormat:x=>Ur(x,0),ariaLabel:g,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function Th({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 N=r>0?r:1,v=Math.min(100,Math.max(0,e/N*100)),H=!d&&!(Number.isFinite(e)&&Number.isFinite(r)&&r>0);if(d)return t.jsx(Et,{height:i});if(H)return t.jsx(Mt,{height:i,text:u});const S=ma(v,f),M=kn(v,f),D=Math.max(0,r-e),C=a.length>0?Xr(a,l)??v:v,x=kn(C,f),$=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:M},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:M,background:`color-mix(in srgb, ${M} 14%, transparent)`},children:S==="danger"?"Crítico":S==="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, ${M}, color-mix(in srgb, ${M} 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(D)]})]})]}),h&&a.length>1?t.jsx(xa,{data:a,xKey:o,series:[{key:l,label:"Uso",color:x}],height:$,yDomain:[0,100],showLegend:!1,showTooltip:b,valueFormat:y=>Ur(y,0),ariaLabel:`${g} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const $h="color-mix(in srgb, var(--primary) 25%, #38bdf8)",Ah="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function Lh({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=$h,outboundColor:h=Ah,height:b=240,className:f="",loading:p=!1,emptyText:g="Sin datos de red",showLegend:N=!1,showTooltip:v=!0,label:H="Network",ariaLabel:S="Tráfico de red"}){const M=o??Xr(e,n)??0,D=l??Xr(e,a)??0,C=!p&&e.length===0;if(p)return t.jsx(Et,{height:b});if(C)return t.jsx(Mt,{height:b,text:g});const x=P=>Li(P,i),y=Math.max(140,b-76);return t.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${f}`,role:"group","aria-label":S,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:H}),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(M),children:x(M)})]}),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(D),children:x(D)})]})]})]})}),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:y,showLegend:N,showTooltip:v,valueFormat:x,ariaLabel:S,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const Wi=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],ji=["primeSuiteOrigin","primeSuiteProjectKey"];function Dh(){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 Oh(){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 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(F,"toast",{enumerable:!0,get:()=>Xa.toast}),F.Alert=Pc,F.AreaChart=xa,F.AuthShell=Si,F.AutoGrowTextarea=li,F.AutoGrowTextareaField=eb,F.BarChart=dh,F.BonsaifButton=xc,F.BonsaifUIToaster=ah,F.BulletChart=Eh,F.Button=Ve,F.CHART_PALETTE=Nn,F.CalendarPicker=Uc,F.ChartCard=oh,F.Checkbox=Fn,F.CodeBlock=Md,F.ComboChart=mh,F.CompactFilterSelect=$d,F.CompactSearchInput=Td,F.ConfirmDialog=Od,F.CopyButton=io,F.CopyLinkButton=Fd,F.CpuChart=Mh,F.DataSheets=Ud,F.DataTable=ro,F.DateRangePicker=Kd,F.DonutChart=fh,F.Drawer=ou,F.DropdownMenu=nu,F.DynamicDetailTabs=Fc,F.EmailField=Tu,F.EmptyState=Un,F.EventCalendar=Cd,F.FieldHelperFooter=Br,F.FieldLabelInfo=Hr,F.FieldLayoutEditor=Hu,F.FileUpload=Du,F.FormField=Qn,F.FunnelChart=kh,F.GaugeChart=Ch,F.GlobalScrollbars=yi,F.ImageLightbox=fl,F.ImageLightboxHost=Vu,F.InputField=yo,F.LineChart=ch,F.LoadingState=ws,F.MentionTextEditor=ai,F.MicroserviceFrame=Rb,F.Modal=co,F.MouseTooltip=Pt,F.MultiDateCalendar=Jd,F.MultiSelect=Yu,F.NetworkChart=Lh,F.NumberField=Gu,F.PageHeader=Zb,F.PageSearchInput=ps,F.Pagination=Zu,F.PhoneField=Ju,F.PieChart=uh,F.PrimeAuthRouteShell=Qb,F.PrimeSuiteChatFrame=eh,F.RadioGroup=Ru,F.RamChart=Th,F.RichTextEditor=Pf,F.SearchableSelect=br,F.SectionPanel=zf,F.Sparkline=hh,F.SpotlightTour=Eb,F.StatusBadge=qf,F.StatusSelect=Gf,F.StepWizard=Zf,F.TableSkeleton=In,F.Tabs=Kf,F.TagInput=db,F.TextInput=Zn,F.Textarea=ii,F.TextareaField=ob,F.TimeField=vb,F.TimePicker=mi,F.Toggle=xb,F.TruncatedWithTooltip=Yt,F.UserAvatar=Ci,F.WORKDAY_LABELS=qs,F.WaterfallChart=ph,F.YearMultiDateCalendar=eu,F.buildMentionQueryRegex=_l,F.chunkMonthWeeks=oo,F.chunkMonthWorkWeeks=Ps,F.clearMentionChipSelection=zr,F.cn=Rt,F.computeWeekBars=so,F.configureBonsaifUI=Zc,F.copyRichCodeBlockFromButton=yl,F.copyTextToClipboard=lo,F.dedupeMentions=ql,F.defaultValueFormat=St,F.deleteEditorSelection=Jl,F.describeParentTargetOrigin=Oh,F.emailFormat=uu,F.ensureMentionChipTrailingSpaces=yn,F.extractMentionUsernames=Ho,F.filterSelfMentions=Df,F.filterWorkdays=Vn,F.findMentionChipAfterCaret=ei,F.findMentionChipBeforeCaret=Rl,F.findMentionChipsInSelection=Po,F.findMentionTriggerInEditor=Do,F.formatBytes=Vr,F.formatPercent=Ur,F.formatRate=Li,F.getBonsaifUIConfig=Qc,F.getDataTablePreferencesEndpoint=Ra,F.getEditorPlainText=_o,F.getMonthGrid=ao,F.getPlainTextOffset=la,F.getWeekDays=no,F.getWorkWeekDays=_s,F.groupItemsByDay=zs,F.highlightMentions=Ul,F.htmlToText=Wl,F.insertMentionInEditor=Xl,F.isMentionTriggerBoundary=zl,F.isPlainOffsetInsideMentionChip=Pl,F.isValidEmail=po,F.isValidPhone=go,F.isWeekend=Fs,F.locateTextOffset=Pr,F.makeRichCodeBlockHtml=wl,F.markRichCodeCopyButtonCopied=xl,F.matches=gu,F.maxLength=hu,F.maxValue=pu,F.mentionDisplayLabel=jl,F.minLength=bu,F.minValue=mu,F.normalizeUsername=Oo,F.openImageLightboxFromEvent=dl,F.phoneCountryCodeOptions=ml,F.phoneFormat=fu,F.placeCaretAfterMentionChip=Io,F.placeCaretAtTextOffset=Yl,F.preferredMentionSpacer=Bo,F.removeMentionChip=da,F.required=du,F.resetBonsaifUIConfig=Jc,F.resolveMentions=Lf,F.resolveParentTargetOrigin=Dh,F.richCodeBlockPlainText=vl,F.richCodeCopyButtonHtml=gl,F.selectAllEditorContents=Zl,F.selectMentionChip=Kl,F.selectionIncludesNonChipText=Ql,F.seriesColor=Ai,F.setBonsaifDataTablePreferencesEndpoint=Rc,F.syncMentionChipSelectionHighlight=ca,F.toDateKey=zt,F.toNearestWorkday=pd,F.toneColor=qt,F.usageColor=kn,F.usageTone=ma,F.useSpotlightTour=Mb,F.useValidationVisibility=Hh,F.validateForm=vu,Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})}));
92
+ `;function yh(){if(typeof document>"u"||document.getElementById(_i))return;const e=document.createElement("style");e.id=_i,e.textContent=vh,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 xh(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 wh(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 Nh({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,y=Math.max(4,Math.min(14,l*.18)),k=wa(d,"#000",r?.12:.22),g=wa(d,"#fff",r?.08:0),H=wa(d,"#fff",.22),S=[`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:S,fill:k}),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:y,fill:H,stroke:wa(d,"#000",.15),strokeWidth:1}),r?t.jsx("ellipse",{cx:a,cy:o,rx:i/2,ry:y,fill:"none",stroke:"var(--text-main)",strokeOpacity:.25,strokeWidth:1.5}):null]})}function kh({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:y=[...Nn],animationDuration:k=lr,valueFormat:g=St,ariaLabel:H="Gráfico embudo"}){const[S,$]=s.useState(null),[O,C]=s.useState(!1),v=s.useMemo(()=>xh(e,r,n,a,o,y),[e,r,n,a,o,y]),T=s.useMemo(()=>v.map(K=>`${K.name}:${K.value}`).join("|"),[v]);if(s.useEffect(()=>{if(yh(),typeof window>"u")return;const K=window.matchMedia("(prefers-reduced-motion: reduce)");C(K.matches);const Y=()=>C(K.matches);return K.addEventListener("change",Y),()=>K.removeEventListener("change",Y)},[]),c)return t.jsx(Et,{height:l});if(!v.length)return t.jsx(Mt,{height:l,text:d});const x=k>0&&!O,P=k,W=Math.min(90,Math.max(40,Math.round(k/8))),U=Math.round(P*.15),L=v.length*W+Math.round(P*.35),J=v.some(K=>K.title||K.description),q=h?160:24,re=J?168:24,R=f?36:8,fe=q+220+re,ee=l,j=18,Z=Math.max(120,ee-j-R-8),M=q+110,ce=wh(v,{cx:M,topY:j,plotH:Z,maxTopW:200,taper:Pi(p,.2,.95),gap:10}),B=S!=null?ce[S]:null,ne="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":H,style:{height:l},children:[t.jsxs("svg",{viewBox:`0 0 ${fe} ${ee}`,width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",children:[h?t.jsx("line",{className:x?"bonsaif-funnel-label":void 0,style:x?{animation:`bonsaif-funnel-fade-in ${P}ms ${ne} both`}:void 0,x1:q-12,y1:j,x2:q-12,y2:j+Z,stroke:"var(--border)",strokeDasharray:"3 5",strokeWidth:1}):null,ce.map(K=>{const Y=K.y+K.h/2,se=K.cx-K.topW/2,E=K.index*W,Q=x?{animation:`bonsaif-funnel-stage-in ${P}ms ${ne} ${E}ms both`}:void 0,ie=x?{animation:`bonsaif-funnel-fade-in ${Math.round(P*.85)}ms ${ne} ${E+U}ms both`}:void 0;return t.jsxs("g",{children:[t.jsx("g",{className:"bonsaif-funnel-stage",style:Q,children:t.jsx(Nh,{stage:K,hovered:S===K.index,onHover:$})}),h?t.jsxs("g",{className:"bonsaif-funnel-label",style:ie,children:[t.jsx("line",{x1:24,y1:Y,x2:q-12,y2:Y,stroke:K.color,strokeOpacity:.55,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("line",{x1:q-12,y1:Y,x2:se-6,y2:Y,stroke:K.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),t.jsx("text",{x:20,y:Y-(b?6:0),textAnchor:"end",fill:K.color,fontSize:12,fontWeight:600,children:K.name.length>18?`${K.name.slice(0,16)}…`:K.name}),b?t.jsx("text",{x:20,y:Y+10,textAnchor:"end",fill:"var(--text-muted)",fontSize:11,children:g(K.value)}):null]}):null,(K.title||K.description)&&J?t.jsxs("g",{className:"bonsaif-funnel-anno",style:ie,children:[t.jsx("line",{x1:K.cx+K.bottomW/2+6,y1:Y,x2:q+220+8,y2:Y,stroke:K.color,strokeOpacity:.35,strokeDasharray:"3 4",strokeWidth:1}),K.title?t.jsx("text",{x:q+220+14,y:Y-(K.description?6:0),fill:"var(--text-main)",fontSize:12,fontWeight:700,children:K.title.length>22?`${K.title.slice(0,20)}…`:K.title}):null,K.description?t.jsx("text",{x:q+220+14,y:Y+(K.title?10:0),fill:"var(--text-muted)",fontSize:11,children:K.description.length>28?`${K.description.slice(0,26)}…`:K.description}):null]}):null]},`${K.name}-${K.index}`)}),f?t.jsx("g",{className:"bonsaif-funnel-arrow",transform:`translate(${M}, ${j+Z+8})`,fill:"var(--primary)",style:x?{animation:`bonsaif-funnel-arrow-in ${Math.round(P*.7)}ms ${ne} ${L}ms both`}:void 0,children:t.jsx("path",{d:"M0,22 L10,8 L4,8 L4,0 L-4,0 L-4,8 L-10,8 Z"})}):null]},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:" · "}),g(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 Ch({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=St,tone:h="primary",color:b,thresholds:f,ariaLabel:p="Gauge",animationDuration:y=700,thickness:k=9,showScale:g=!1}){const H=s.useId().replace(/:/g,""),S=n-r||1,$=Math.min(1,Math.max(0,(e-r)/S)),[O,C]=s.useState(y>0?0:$);if(s.useEffect(()=>{if(l||i)return;if(y<=0){C($);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){C($);return}let fe=0,ee=0;C(M=>(ee=M,M));const j=performance.now(),Z=M=>{const _=Math.min(1,(M-j)/y),ce=1-(1-_)**3;C(ee+($-ee)*ce),_<1&&(fe=requestAnimationFrame(Z))};return fe=requestAnimationFrame(Z),()=>cancelAnimationFrame(fe)},[$,y,l,i]),l)return t.jsx(Et,{height:a});if(i)return t.jsx(Mt,{height:a,text:c});const v=100,T=108,x=72,P=b??Sh(e,n,h,f),W=r+O*S,U=zi(v,T,x,Gr,Gr+Zo),L=Gr+Math.max(.001,O)*Zo,J=zi(v,T,x,Gr,L),q=Na(v,T,x,Gr),re=Na(v,T,x,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-${H}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[t.jsx("stop",{offset:"0%",stopColor:P,stopOpacity:.82}),t.jsx("stop",{offset:"100%",stopColor:P,stopOpacity:1})]})}),t.jsx("path",{d:U,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:k,strokeLinecap:"butt"}),t.jsx("path",{d:J,fill:"none",stroke:`url(#bonsaif-gauge-${H})`,strokeWidth:k,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),t.jsx("text",{x:v,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(W)}),d?t.jsx("text",{x:v,y:T+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:q.x-2,y:q.y+k+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(r)}),t.jsx("text",{x:re.x+2,y:re.y+k+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(n)})]}):null]})})}function Sh(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 Eh({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=St,tone:f="primary",showScale:p=!0,showStatus:y=!0,ariaLabel:k="Bullet chart"}){if(i)return t.jsx(Et,{height:o});if(c)return t.jsx(Mt,{height:o,text:d});const g=n??Math.max(e,r,...(a==null?void 0:a.map(P=>P.value))??[],1)*1.05,S=[...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((P,W)=>P.value-W.value),$=qt(f),O=Math.min(100,Math.max(0,e/g*100)),C=Math.min(100,Math.max(0,r/g*100)),v=e>=r,T=[0,.25,.5,.75,1].map(P=>P*g),x=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":k,children:[t.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:S.map((P,W)=>{const U=W===0?0:S[W-1].value,L=Math.max(0,(P.value-U)/g*100);return t.jsx("div",{style:{width:`${L}%`,background:P.color??`color-mix(in srgb, var(--border) ${70-W*18}%, transparent)`}},W)})}),t.jsx("div",{className:"absolute left-0 top-1/2 w-full",style:{height:"34%",transform:"translateY(-50%)"},children:t.jsx("div",{className:"bonsaif-bullet-value h-full",style:{width:`${O}%`,background:$,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${$} 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:$,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((P,W)=>{const U=P/g*100,L=W===0,J=W===T.length-1;return t.jsxs("div",{className:"absolute top-0",style:{left:`${U}%`,transform:L?"none":J?"translateX(-100%)":"translateX(-50%)"},children:[t.jsx("div",{className:"mx-auto h-1.5 w-px",style:{background:"color-mix(in srgb, var(--text-muted) 55%, transparent)",marginLeft:L?0:J?"auto":void 0,marginRight:J?0:void 0}}),t.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:L?"left":J?"right":"center"},children:b(P)})]},P)})}):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:$,fontWeight:600},children:b(e)}),t.jsxs("span",{children:[" / meta ",b(r)]})]}),y?t.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:qt(v?"success":"warning")},children:v?"En meta":"Bajo meta"}):null]}),x]}):x})}function Mh({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:y="Uso de CPU"}){var C;const k=o??[{key:a,label:"Uso",color:kn(r??Xr(e,a)??0,f)}],g=r??Xr(e,a)??Xr(e,((C=k[0])==null?void 0:C.key)??a),H=!d&&(!e.length||g===null);if(d)return t.jsx(Et,{height:i});if(H)return t.jsx(Mt,{height:i,text:u});const S=Math.min(100,Math.max(0,g??0)),$=ma(S,f),O=kn(S,f);return t.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":y,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:O},children:Ur(S,S<10?1:0)})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:O,background:`color-mix(in srgb, ${O} 14%, transparent)`},children:$==="danger"?"Crítico":$==="warning"?"Alto":"Normal"})]}),t.jsx(xa,{data:e,xKey:n,series:k.map(v=>({...v,color:v.color??O})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:h,showTooltip:b,valueFormat:v=>Ur(v,0),ariaLabel:y,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function Th({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:y="Uso de memoria"}){const k=r>0?r:1,g=Math.min(100,Math.max(0,e/k*100)),H=!d&&!(Number.isFinite(e)&&Number.isFinite(r)&&r>0);if(d)return t.jsx(Et,{height:i});if(H)return t.jsx(Mt,{height:i,text:u});const S=ma(g,f),$=kn(g,f),O=Math.max(0,r-e),C=a.length>0?Xr(a,l)??g:g,v=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":y,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:$},children:Ur(g,g<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:$,background:`color-mix(in srgb, ${$} 14%, transparent)`},children:S==="danger"?"Crítico":S==="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} ${Ur(g,0)}`,children:t.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${g}%`,background:`linear-gradient(90deg, ${$}, color-mix(in srgb, ${$} 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(O)]})]})]}),h&&a.length>1?t.jsx(xa,{data:a,xKey:o,series:[{key:l,label:"Uso",color:v}],height:T,yDomain:[0,100],showLegend:!1,showTooltip:b,valueFormat:x=>Ur(x,0),ariaLabel:`${y} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const $h="color-mix(in srgb, var(--primary) 25%, #38bdf8)",Ah="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function Lh({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=$h,outboundColor:h=Ah,height:b=240,className:f="",loading:p=!1,emptyText:y="Sin datos de red",showLegend:k=!1,showTooltip:g=!0,label:H="Network",ariaLabel:S="Tráfico de red"}){const $=o??Xr(e,n)??0,O=l??Xr(e,a)??0,C=!p&&e.length===0;if(p)return t.jsx(Et,{height:b});if(C)return t.jsx(Mt,{height:b,text:y});const v=P=>Li(P,i),x=Math.max(140,b-76);return t.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${f}`,role:"group","aria-label":S,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:H}),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:v($),children:v($)})]}),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:v(O),children:v(O)})]})]})]})}),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:x,showLegend:k,showTooltip:g,valueFormat:v,ariaLabel:S,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const Wi=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],ji=["primeSuiteOrigin","primeSuiteProjectKey"];function Dh(){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 Oh(){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 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:()=>Xa.toast}),I.Alert=Pc,I.AreaChart=xa,I.AuthShell=Si,I.AutoGrowTextarea=li,I.AutoGrowTextareaField=eb,I.BarChart=dh,I.BonsaifButton=xc,I.BonsaifUIToaster=ah,I.BulletChart=Eh,I.Button=Ve,I.CHART_PALETTE=Nn,I.CalendarPicker=Uc,I.ChartCard=oh,I.Checkbox=Fn,I.CodeBlock=Md,I.ComboChart=mh,I.CompactFilterSelect=$d,I.CompactSearchInput=Td,I.ConfirmDialog=Od,I.CopyButton=io,I.CopyLinkButton=Fd,I.CpuChart=Mh,I.DataSheets=Ud,I.DataTable=ro,I.DateRangePicker=Kd,I.DonutChart=fh,I.Drawer=ou,I.DropdownMenu=nu,I.DynamicDetailTabs=Fc,I.EmailField=Tu,I.EmptyState=Un,I.EventCalendar=Cd,I.FieldHelperFooter=Br,I.FieldLabelInfo=Hr,I.FieldLayoutEditor=Hu,I.FileUpload=Du,I.FormField=Qn,I.FunnelChart=kh,I.GaugeChart=Ch,I.GlobalScrollbars=yi,I.ImageLightbox=fl,I.ImageLightboxHost=Vu,I.InputField=yo,I.LineChart=ch,I.LoadingState=ws,I.MentionTextEditor=ai,I.MicroserviceFrame=Rb,I.Modal=co,I.MouseTooltip=Pt,I.MultiDateCalendar=Jd,I.MultiSelect=Yu,I.NetworkChart=Lh,I.NumberField=Gu,I.PageHeader=Zb,I.PageSearchInput=ps,I.Pagination=Zu,I.PhoneField=Ju,I.PieChart=uh,I.PrimeAuthRouteShell=Qb,I.PrimeSuiteChatFrame=eh,I.RadioGroup=Ru,I.RamChart=Th,I.RichTextEditor=Pf,I.SearchableSelect=br,I.SectionPanel=zf,I.Sparkline=hh,I.SpotlightTour=Eb,I.StatusBadge=qf,I.StatusSelect=Gf,I.StepWizard=Zf,I.TableSkeleton=In,I.Tabs=Kf,I.TagInput=db,I.TextInput=Zn,I.Textarea=ii,I.TextareaField=ob,I.TimeField=vb,I.TimePicker=mi,I.Toggle=xb,I.TruncatedWithTooltip=Yt,I.UserAvatar=Ci,I.WORKDAY_LABELS=qs,I.WaterfallChart=ph,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=St,I.deleteEditorSelection=Jl,I.describeParentTargetOrigin=Oh,I.emailFormat=uu,I.ensureMentionChipTrailingSpaces=yn,I.extractMentionUsernames=Ho,I.filterSelfMentions=Df,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=Lf,I.resolveParentTargetOrigin=Dh,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=Mb,I.useValidationVisibility=Hh,I.validateForm=vu,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})}));