bonsaif-ui 0.1.119 → 0.1.121

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
- (function(G,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):(G=typeof globalThis<"u"?globalThis:G||self,s(G.BonsaifUI={},G.React,G.jsxRuntime,G.ReactIconsHi2,G.ReactDOM,G.Recharts,G.OverlayScrollbarsGlobal,G.Sonner,G.OverlayScrollbarsReact,G.ReactDayPicker,G.ReactDayPickerStyles,G.ReactIconsFi))})(this,(function(G,s,r,F,nr,Ne,ta,cs,ds,na,Zf,Pl){"use strict";"use client";function Tr(...e){return e.filter(Boolean).join(" ")}function zl({variant:e="primary",className:t,type:n="button",children:a,...o}){return r.jsx("button",{className:Tr("bonsaif-ui-button",`bonsaif-ui-button--${e}`,t),type:n,...o,children:a})}function us({value:e,onChange:t,placeholder:n,className:a="",autoFocus:o=!1,forceExpanded:l=!1,onEscape:i,size:c="default",inputTabIndex:d}){const u=s.useRef(null),[p,f]=s.useState(!1),m=l||p||e.trim().length>0,x=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",w=a||"w-48 max-w-full sm:w-64 lg:w-72";s.useEffect(()=>{var h;o&&((h=u.current)==null||h.focus())},[o]);const $=()=>{var h;f(!0),(h=u.current)==null||h.focus()};return r.jsxs("div",{className:`relative min-w-0 max-w-full flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${m?w:"w-24 sm:w-28"}`,onMouseDown:h=>{m||(h.preventDefault(),$())},children:[r.jsx(F.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)"}}),r.jsx("input",{ref:u,type:"text",tabIndex:d,"aria-label":n,value:e,onChange:h=>t(h.target.value),onKeyDown:h=>{h.key==="Escape"&&(i==null||i())},placeholder:m?n:"Buscar",className:`${x} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${m?"pl-9 pr-8":"cursor-pointer pl-9 pr-3"}`,style:{height:`var(--page-header-control-height, ${c==="sm"?"36px":"40px"})`,paddingLeft:"calc(var(--page-header-control-icon-left, 12px) + 24px)",paddingRight:m?"calc(var(--page-header-control-padding-x, 14px) + 18px)":"var(--page-header-control-padding-x, 14px)",background:"color-mix(in srgb, var(--bg-card) 86%, transparent)",border:"1px solid var(--border)",color:"var(--text-main)"},onFocus:h=>{f(!0),h.currentTarget.style.borderColor="var(--primary)",h.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:h=>{f(!1),h.currentTarget.style.borderColor="var(--border)",h.currentTarget.style.boxShadow="none"}}),e&&r.jsx("button",{type:"button",onClick:()=>t(""),className:"absolute right-2 top-1/2 flex !h-6 !w-6 -translate-y-1/2 items-center justify-center rounded-full !p-0 leading-none transition-colors hover:bg-black/5",style:{color:"var(--text-muted)",right:"var(--page-header-control-padding-x, 8px)"},"aria-label":"Limpiar búsqueda",children:r.jsx(F.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const fs=s.createContext({});let bs=0;const ms="bonsaif-ui:hide-tooltips";function an(e=700){bs=Date.now()+e}function _l(){return Date.now()>bs}function sn(e){if(typeof document>"u")return!1;const t=Array.from(document.querySelectorAll('[data-bonsaif-overlay="true"], [role="menu"], [role="dialog"][aria-modal="true"], [aria-hidden="false"] [aria-modal="true"]'));return e&&t.some(n=>n.contains(e))?!1:t.length>0}function jl(e){var a;const t=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||t.length>0)&&(((a=t[0])==null?void 0:a.textContent)??e.textContent??"").trim()||null}function zr({children:e,content:t,onlyWhenOverflow:n=!1,interactive:a=!1,followCursor:o=!0,placement:l="bottom",showArrow:i=!1,className:c="",tooltipClassName:d="",style:u,tooltipStyle:p,as:f="div"}){const m=s.useRef(null),x=s.useRef(null),w=s.useRef(null),$=s.useRef(!1),[h,E]=s.useState(null),[T,g]=s.useState("");s.useEffect(()=>{const M=m.current;M&&(M.querySelectorAll("[title]").forEach(Z=>{const H=Z.getAttribute("title");H&&(Z.getAttribute("aria-label")||Z.setAttribute("aria-label",H),Z.removeAttribute("title"))}),M.querySelectorAll("svg title").forEach(Z=>Z.remove()))}),s.useLayoutEffect(()=>{if(!h)return;const M=x.current;if(!M)return;const Z=12,H=14,ne=M.getBoundingClientRect(),U=window.innerWidth-ne.width-Z,q=window.innerHeight-ne.height-Z;let j=h.mouseX+H,D=h.mouseY+H,se,B;if(!o&&m.current){const O=m.current.getBoundingClientRect(),oe=O.left+O.width/2,v=O.top+O.height/2;l==="top"?(j=oe-ne.width/2,D=O.top-ne.height-H,B=ne.height-1):l==="left"?(j=O.left-ne.width-H,D=v-ne.height/2,se=ne.width-1):l==="right"?(j=O.right+H,D=v-ne.height/2,se=-7):(j=oe-ne.width/2,D=O.bottom+H,B=-7)}if(o&&(j>U&&(j=h.mouseX-ne.width-H),D>q&&(D=h.mouseY-ne.height-H)),j=Math.min(Math.max(Z,j),Math.max(Z,U)),D=Math.min(Math.max(Z,D),Math.max(Z,q)),!o&&m.current){const O=m.current.getBoundingClientRect(),oe=O.left+O.width/2,v=O.top+O.height/2;l==="top"||l==="bottom"?se=Math.min(Math.max(14,oe-j),ne.width-14):B=Math.min(Math.max(14,v-D),ne.height-14)}(Math.abs(j-h.x)>.5||Math.abs(D-h.y)>.5||se!==h.arrowX||B!==h.arrowY)&&E(O=>O&&{...O,x:j,y:D,arrowX:se,arrowY:B})},[o,l,h]);const y=()=>{w.current&&(window.clearTimeout(w.current),w.current=null)},k=(M,Z)=>{if(!_l()||$.current)return;const H=m.current;if(H&&!sn(H)){if(n){const ne=jl(H);if(!ne)return;g(ne)}!n&&!t||E({mouseX:M,mouseY:Z,x:M+14,y:Z+14})}},S=()=>{const M=m.current;if(!M)return;const Z=M.getBoundingClientRect();k(Z.left+Z.width/2,Z.bottom)},L=()=>{y(),E(null)},C=()=>{if(!a){L();return}y(),w.current=window.setTimeout(()=>E(null),120)},W=()=>{an(),$.current=!0,L()},_=()=>{$.current=!1};s.useEffect(()=>{if(!h)return;if(sn(m.current)){E(null);return}const M=()=>E(null),Z=()=>{an(),$.current=!0,E(null)};document.addEventListener("pointerdown",Z,!0),document.addEventListener("click",Z,!0),document.addEventListener("scroll",M,!0),window.addEventListener("blur",M),document.addEventListener("visibilitychange",M),document.addEventListener("keydown",M,!0);const H=new MutationObserver(()=>{sn(m.current)&&E(null)});return H.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","aria-hidden","class"]}),()=>{document.removeEventListener("pointerdown",Z,!0),document.removeEventListener("click",Z,!0),document.removeEventListener("scroll",M,!0),window.removeEventListener("blur",M),document.removeEventListener("visibilitychange",M),document.removeEventListener("keydown",M,!0),H.disconnect()}},[h]),s.useEffect(()=>{const M=()=>an(),Z=()=>{an(),$.current=!0,E(null)};return document.addEventListener("pointerdown",M,!0),document.addEventListener("click",M,!0),document.addEventListener("keydown",M,!0),window.addEventListener(ms,Z),()=>{document.removeEventListener("pointerdown",M,!0),document.removeEventListener("click",M,!0),document.removeEventListener("keydown",M,!0),window.removeEventListener(ms,Z)}},[]);const V=n?T:t;return r.jsxs(r.Fragment,{children:[r.jsx(f,{ref:M=>{m.current=M},className:c,style:u,onMouseEnter:M=>{y(),_(),o?k(M.clientX,M.clientY):S()},onMouseMove:M=>{h&&o&&k(M.clientX,M.clientY)},onMouseDown:W,onClick:W,onMouseLeave:()=>{_(),C()},onFocus:S,onBlur:L,children:e}),h&&V&&!sn(m.current)?nr.createPortal(r.jsxs("div",{ref:x,role:"tooltip",className:d,onMouseEnter:a?y:void 0,onMouseLeave:a?C:void 0,style:{position:"fixed",top:h.y,left:h.x,zIndex:9999,background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:6,padding:"5px 10px",fontSize:12,color:"var(--text-main)",boxShadow:"0 4px 16px rgba(0,0,0,0.35)",pointerEvents:a?"auto":"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere",...p},children:[i&&r.jsx("span",{"aria-hidden":"true",style:{position:"absolute",width:12,height:12,background:(p==null?void 0:p.background)??"var(--bg-card)",borderLeft:l==="right"?(p==null?void 0:p.border)??"1px solid var(--border)":void 0,borderTop:l==="bottom"||l==="right"?(p==null?void 0:p.border)??"1px solid var(--border)":void 0,borderRight:l==="left"?(p==null?void 0:p.border)??"1px solid var(--border)":void 0,borderBottom:l==="top"||l==="left"?(p==null?void 0:p.border)??"1px solid var(--border)":void 0,transform:"rotate(45deg)",left:h.arrowX===void 0?void 0:h.arrowX-6,top:h.arrowY===void 0?void 0:h.arrowY-6,zIndex:-1}}),V]}),document.body):null]})}function ps(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}const Wl="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",ql={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"},Ul="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",Vl={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"},Yl={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},Kl={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function aa(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(aa).join(" ").trim():s.isValidElement(e)?aa(e.props.children):""}function Xl(e){return s.Children.toArray(e).find(s.isValidElement)??null}function je({variant:e="primary",size:t="md",loading:n=!1,icon:a,tooltip:o,iconOnly:l,height:i,padding:c,children:d,className:u="",disabled:p,style:f,...m}){const x=s.useContext(fs),w=l??x.iconOnly??e==="icon",$=x.compact??!1,h=x.headerAction??!1,E=h&&t==="md"?"sm":$&&!h&&t==="md"?"xs":t,T=e==="icon"||w,g=h&&T,y=aa(d),k=o??m.title??m["aria-label"]??(w?y:void 0),S=k?void 0:m.title,L=m["aria-label"]??(typeof k=="string"?k:y||void 0),C=n?null:a??(w?Xl(d):null),W=r.jsxs("button",{...m,title:S,"aria-label":L,"data-variant":e,"data-size":E,"data-icon":T?"true":void 0,disabled:p||n,className:`${Wl} ${g?Ul:ql[e]} ${T?Yl[E]:Vl[E]} ${$&&!T?"px-2.5":""} ${u}`,style:{...Kl[e],height:ps(i),padding:ps(c),...f,...h&&!T?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...g?{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?r.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):C,!w&&d]});return k?r.jsx(zr,{as:"span",content:k,className:"inline-flex shrink-0",children:W}):W}const rr={background:"color-mix(in srgb, var(--text-muted) 26%, var(--bg-input))"};function on({rows:e=8,columns:t=7,showToolbar:n=!0,showPagination:a=!0,compact:o=!1,className:l=""}){const i=Math.max(3,Math.min(t,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 r.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&&r.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-3 py-2",children:[r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[r.jsx("div",{className:"h-7 w-14 shrink-0 animate-pulse rounded-md",style:rr}),r.jsx("div",{className:"h-7 max-w-md flex-1 animate-pulse rounded-md",style:rr})]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[r.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:rr}),r.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:rr})]})]}),r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("div",{className:"min-w-full",style:{display:"grid",gridTemplateColumns:`repeat(${i}, minmax(96px, 1fr))`},children:[Array.from({length:i}).map((p,f)=>r.jsx("div",{className:`${u} border-b border-[var(--border)]`,style:{background:"color-mix(in srgb, var(--bg-input) 55%, transparent)"},children:r.jsx("div",{className:"h-3 animate-pulse rounded-md",style:{...rr,width:`${48+f*17%40}%`}})},`h-${f}`)),Array.from({length:c}).map((p,f)=>Array.from({length:i}).map((m,x)=>r.jsx("div",{className:`${d} ${f<c-1?"border-b border-[var(--border)]":""}`,children:r.jsx("div",{className:"h-3.5 animate-pulse rounded-md",style:{...rr,width:`${46+(f*13+x*11)%42}%`,minWidth:28}})},`c-${f}-${x}`)))]})}),a&&r.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:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"h-3 w-28 animate-pulse rounded-md",style:rr}),r.jsx("div",{className:"h-7 w-14 animate-pulse rounded-md",style:rr})]}),r.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:4}).map((p,f)=>r.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:rr},f))}),r.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:rr})]})]})}function Gl({size:e="md"}){const t=e==="sm"?"h-7 w-7":"h-9 w-9";return r.jsx("div",{className:`${t} animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]`,"aria-hidden":!0})}function Zl({logoSrc:e,logoAlt:t}){return e?r.jsxs("span",{className:"relative flex h-16 w-16 items-center justify-center","aria-hidden":!1,children:[r.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%)"}}),r.jsx("img",{src:e,alt:t,className:"relative h-14 w-14 rounded-2xl object-contain shadow-sm shadow-black/10"})]}):null}function hs({variant:e="page",title:t="Cargando...",description:n,logoSrc:a,logoAlt:o,appearance:l="card",rows:i=6,columns:c=7,children:d,className:u=""}){if(e==="table")return r.jsx(on,{rows:i,columns:c,className:u});if(e==="sections")return r.jsx(Ql,{rows:i});if(e==="cards")return r.jsx(Jl,{rows:i});const p=o||(typeof t=="string"?t:"Aplicación"),f=l==="bare",m=r.jsxs("div",{className:`flex flex-col items-center text-center ${f?"gap-5":"gap-3"}`,children:[a?r.jsx(Zl,{logoSrc:a,logoAlt:p}):null,r.jsx(Gl,{size:f?"md":"sm"}),r.jsxs("div",{className:f?"space-y-1.5":"",children:[r.jsx("p",{className:f?"text-base font-semibold tracking-tight text-[var(--text-main)]":"text-sm font-semibold text-[var(--text-main)]",children:t}),n?r.jsx("p",{className:f?"text-sm font-medium text-[var(--text-muted)]":"mt-1 text-xs text-[var(--text-muted)]",children:n}):null,d&&r.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:d})]})]});return f?r.jsx("div",{className:`flex min-h-[240px] w-full items-center justify-center p-8 ${u}`,role:"status","aria-live":"polite","aria-busy":"true",children:m}):r.jsx("div",{className:`flex min-h-[240px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 ${u}`,role:"status","aria-live":"polite","aria-busy":"true",children:m})}function Ql({rows:e}){return r.jsx(on,{rows:e,columns:7})}function Jl({rows:e}){return r.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:Array.from({length:e}).map((t,n)=>r.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[r.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded-md",style:rr}),r.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded-md",style:rr}),r.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded-md",style:rr})]},n))})}function gs(e){const t=e.split("/").filter(Boolean);return(t[t.length-1]??e).replace(/^lv_/,"").split(/[-_]/).filter(Boolean).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}function vs(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function Rl(e){return[e.label,gs(e.service),e.description,e.service].filter(Boolean).join(" ")}function ei(e){return typeof e=="function"?e:e.default}function ri(e,t){return r.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:r.jsxs("div",{className:"max-w-md",children:[r.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:"No se pudo cargar este modulo"}),r.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:e.message}),r.jsx(je,{className:"mt-4",height:36,padding:"0 14px",onClick:t,children:"Reintentar"})]})})}function ti({parentPanel:e,parentPanelComponent:t,renderParentPanel:n,parent:a,context:o,links:l,moduleRegistry:i,loadModule:c,activeService:d,initialService:u,onActiveServiceChange:p,canAccess:f,keepAlive:m=!0,title:x,subtitle:w,emptyState:$,loadingState:h,errorState:E=ri,renderTabLabel:T,searchableTabs:g="auto",tabsSearchThreshold:y=6,tabsSearchPlaceholder:k="Buscar modulo...",tabsSearchValue:S,onTabsSearchChange:L,emptySearchState:C,showTabCount:W=!0,className:_="",parentClassName:V="",contentClassName:M="",tabsClassName:Z=""}){var er;const H=s.useMemo(()=>l.filter(me=>!me.hidden&&((f==null?void 0:f(me,o))??!0)),[f,o,l]),ne=(er=H.find(me=>!me.disabled))==null?void 0:er.service,[U,q]=s.useState(u??ne??""),[j,D]=s.useState({}),[se,B]=s.useState({}),[O,oe]=s.useState(""),[v,z]=s.useState(!1),ee=s.useRef(se),le=s.useRef(0),R=S??O,Q=vs(R),I=g===!0||g==="auto"&&H.length>=y,J=I&&R.trim().length>0,P=s.useMemo(()=>Q?H.filter(me=>vs(Rl(me)).includes(Q)):H,[Q,H]),ae=d??U,Y=H.find(me=>me.service===ae)??H.find(me=>!me.disabled);s.useEffect(()=>{!Y&&ne&&q(ne)},[ne,Y]),s.useEffect(()=>{ee.current=se},[se]);const de=me=>{me.disabled||(d||q(me.service),p==null||p(me.service,me))},Se=me=>{S===void 0&&oe(me),L==null||L(me)},ie=(me,K)=>{const re=P.filter(he=>!he.disabled),be=re.findIndex(he=>he.service===K.service);be<0||((me.key==="ArrowRight"||me.key==="ArrowDown")&&(me.preventDefault(),de(re[(be+1)%re.length])),(me.key==="ArrowLeft"||me.key==="ArrowUp")&&(me.preventDefault(),de(re[(be-1+re.length)%re.length])),me.key==="Home"&&(me.preventDefault(),de(re[0])),me.key==="End"&&(me.preventDefault(),de(re[re.length-1])))},pe=s.useCallback(()=>{if(!Y)return;const me=Y.service,K=ee.current[me];if(K!=null&&K.loading||K!=null&&K.component&&m)return;const re=(i==null?void 0:i[me])??c;if(!re){B(he=>({...he,[me]:{loading:!1,error:new Error(`No module loader found for service "${me}".`)}}));return}const be=++le.current;B(he=>({...he,[me]:{...he[me],loading:!0,error:void 0}})),re(Y,o).then(he=>{if(be!==le.current&&!m)return;const Be=ei(he);B(Te=>({...Te,[me]:{component:Be,loading:!1}}))}).catch(he=>{const Be=he instanceof Error?he:new Error(String(he));B(Te=>({...Te,[me]:{...Te[me],loading:!1,error:Be}}))})},[o,m,c,i,Y]);s.useEffect(pe,[pe]);const Ce=Y?j[Y.service]??null:null,De=Y?se[Y.service]:void 0,mr=De==null?void 0:De.component,xr=me=>{Y&&D(K=>({...K,[Y.service]:me}))},We=()=>{Y&&D(me=>({...me,[Y.service]:null}))},Le={context:o,parent:a,links:l,visibleLinks:H,filteredLinks:P,selectedLink:Y,selectedService:Y==null?void 0:Y.service,activeItemId:Ce,tabsSearch:R,onSelectService:de,onOpenDetail:xr,onBackToList:We},ke=n?n(Le):t?r.jsx(t,{...Le}):e;return r.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${_}`,children:[r.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${V}`,children:ke}),r.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${M}`,children:[(x||w||I||W)&&r.jsx("div",{className:"relative border-b border-[var(--border)] px-4 py-3",children:r.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[x&&r.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:x}),w&&r.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:w})]}),(I||W)&&r.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[W&&r.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[P.length," / ",H.length]}),I&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${v?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!v,children:r.jsx(us,{value:R,onChange:Se,placeholder:k,className:"w-full",autoFocus:v,forceExpanded:!0,onEscape:()=>z(!1),size:"sm",inputTabIndex:v?0:-1})}),r.jsx("button",{type:"button","aria-label":v?"Cerrar busqueda":"Buscar tabs","aria-expanded":v,onClick:()=>{v&&R&&Se(""),z(me=>!me)},className:`inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border transition-all duration-200 hover:scale-[1.03] active:scale-95 ${v||J?"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:r.jsx("span",{className:"grid h-4 w-4 place-items-center transition-transform duration-200",children:v||J?r.jsx(F.HiXMark,{className:"h-4 w-4"}):r.jsx(F.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),r.jsx("div",{role:"tablist","aria-label":x??"Modulos relacionados",className:`flex gap-1 overflow-x-auto border-b border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 transition-colors duration-200 ${Z}`,children:P.length>0?P.map(me=>{const K=me.service===(Y==null?void 0:Y.service);return r.jsx("button",{type:"button",role:"tab","aria-selected":K,disabled:me.disabled,onClick:()=>de(me),onKeyDown:re=>ie(re,me),className:`inline-flex h-9 min-w-max items-center gap-2 rounded-md border px-3 text-xs font-semibold transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-50 ${K?"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:T?T(me,K):r.jsxs(r.Fragment,{children:[me.icon,r.jsx("span",{children:me.label??gs(me.service)}),me.badge&&r.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:me.badge})]})},me.service)}):r.jsx("div",{className:"flex min-h-9 flex-1 items-center rounded-md border border-dashed border-[var(--border)] px-3 text-xs text-[var(--text-muted)]",children:C??"No hay modulos que coincidan con la busqueda."})}),(Y==null?void 0:Y.description)&&r.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:Y.description}),r.jsxs("div",{className:"min-h-[420px] p-4",children:[!Y&&($??r.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."})),Y&&(De==null?void 0:De.loading)&&(h??r.jsx(hs,{title:"Cargando modulo..."})),Y&&(De==null?void 0:De.error)&&E(De.error,pe),Y&&mr&&!(De!=null&&De.loading)&&!(De!=null&&De.error)&&r.jsx(mr,{context:o,parent:a,link:Y,activeItemId:Ce,onOpenDetail:xr,onBackToList:We})]})]})]})}const ni={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:r.jsx(F.HiInformationCircle,{className:"h-5 w-5"})},success:{color:"#047857",background:"rgba(16, 185, 129, 0.1)",border:"rgba(16, 185, 129, 0.24)",icon:r.jsx(F.HiCheckCircle,{className:"h-5 w-5"})},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)",border:"rgba(245, 158, 11, 0.26)",icon:r.jsx(F.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:r.jsx(F.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:r.jsx(F.HiInformationCircle,{className:"h-5 w-5"})}};function ai({variant:e="info",title:t,children:n,icon:a,action:o,onDismiss:l,className:i=""}){const c=ni[e];return r.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:[r.jsx("div",{className:"mt-0.5 shrink-0",style:{color:c.color},children:a??c.icon}),r.jsxs("div",{className:"min-w-0 flex-1",children:[t&&r.jsx("div",{className:"text-sm font-semibold text-[var(--text-main)]",children:t}),n&&r.jsx("div",{className:"mt-0.5 text-sm leading-5 text-[var(--text-secondary)]",children:n}),o&&r.jsx("div",{className:"mt-3",children:o})]}),l&&r.jsx(je,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:r.jsx(F.HiXMark,{className:"h-4 w-4"})})]})}const ys=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],si=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],oi=["lu","ma","mi","ju","vi","sá","do"],xs=6;function sa(e,t,n){return`${e}-${String(t).padStart(2,"0")}-${String(n).padStart(2,"0")}`}function li(){const e=new Date;return sa(e.getFullYear(),e.getMonth()+1,e.getDate())}function ws(e){const[t,n,a]=e.split("-").map(Number);return{year:t,month:n,day:a}}function ii(e){if(!e)return"Seleccionar fecha";const{year:t,month:n,day:a}=ws(e);return!t||!n||!a?"Seleccionar fecha":`${String(a).padStart(2,"0")} ${ys[n-1]} ${t}`}function ci({value:e,onChange:t,minDate:n,displayMode:a="inline",className:o=""}){const l=li(),c=ws(e||l),d=a==="popover",[u,p]=s.useState(!1),f=s.useRef(null),[m,x]=s.useState({horizontal:"left",vertical:"bottom"}),[w,$]=s.useState(c.year),[h,E]=s.useState(c.month),[T,g]=s.useState("days"),y=16,[k,S]=s.useState(0),L=w-7+k,C=Array.from({length:y},(q,j)=>L+j);s.useEffect(()=>{if(!d||!u||!f.current)return;const q=f.current.getBoundingClientRect(),j=8,D=280,se=340,B=q.left+D>window.innerWidth-j,O=q.right-D>=j,oe=q.bottom+8+se>window.innerHeight-j,v=q.top-8-se>=j;x({horizontal:B&&O?"right":"left",vertical:oe&&v?"top":"bottom"})},[d,u]),s.useEffect(()=>{if(!d||!u)return;function q(D){f.current&&(f.current.contains(D.target)||p(!1))}function j(D){D.key==="Escape"&&p(!1)}return document.addEventListener("mousedown",q),document.addEventListener("keydown",j),()=>{document.removeEventListener("mousedown",q),document.removeEventListener("keydown",j)}},[d,u]);function W(){h===1?($(q=>q-1),E(12)):E(q=>q-1)}function _(){h===12?($(q=>q+1),E(1)):E(q=>q+1)}const V=(new Date(w,h-1,1).getDay()+6)%7,M=new Date(w,h,0).getDate(),Z=[...Array(V).fill(null),...Array.from({length:M},(q,j)=>j+1)];for(;Z.length<xs*7;)Z.push(null);const H=Z.slice(0,xs*7);function ne(q){const j=sa(w,h,q);n&&j<n||(t(j),d&&p(!1))}const U=r.jsx("div",{className:`bonsaif-calendar bonsaif-calendar-picker ${o}`.trim(),children:r.jsxs("div",{className:"bonsaif-cal-shell",children:[r.jsx("div",{className:"bonsaif-cal-toolbar",children:T==="days"?r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:W,"aria-label":"Mes anterior",children:r.jsx(F.HiChevronLeft,{size:16})}),r.jsxs("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>{g("years"),S(0)},children:[r.jsxs("span",{className:"bonsaif-cal-title",children:[ys[h-1]," ",w]}),r.jsx(F.HiChevronDown,{size:13})]}),r.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:_,"aria-label":"Mes siguiente",children:r.jsx(F.HiChevronRight,{size:16})})]}):r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>S(q=>q-y),"aria-label":"Años anteriores",children:r.jsx(F.HiChevronLeft,{size:16})}),r.jsx("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>g("days"),children:r.jsxs("span",{className:"bonsaif-cal-title",children:[C[0]," – ",C[C.length-1]]})}),r.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>S(q=>q+y),"aria-label":"Años siguientes",children:r.jsx(F.HiChevronRight,{size:16})})]})}),T==="years"?r.jsxs("div",{className:"bonsaif-cal-picker-years",children:[r.jsx("div",{className:"bonsaif-cal-picker-months",children:si.map((q,j)=>{const D=j+1===h;return r.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${D?" is-active":""}`,onClick:()=>E(j+1),children:q},q)})}),r.jsx("div",{className:"bonsaif-cal-picker-year-grid",children:C.map(q=>{const j=q===w,D=q===new Date().getFullYear();return r.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${j?" is-active":""}${D&&!j?" is-today":""}`,onClick:()=>{$(q),g("days")},children:q},q)})})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"bonsaif-multi-weekdays bonsaif-cal-picker-weekdays",children:oi.map(q=>r.jsx("div",{className:"bonsaif-multi-weekday",children:q},q))}),r.jsx("div",{className:"bonsaif-cal-picker-days",children:H.map((q,j)=>{if(q===null)return r.jsx("div",{className:"bonsaif-multi-day bonsaif-multi-day-hidden"},j);const D=sa(w,h,q),se=D===e,B=D===l,O=!!(n&&D<n);return r.jsx("div",{className:`bonsaif-multi-day${se?" bonsaif-multi-day-selected":""}${B?" bonsaif-multi-day-today":""}${O?" bonsaif-multi-day-disabled":""}`,children:r.jsx("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:O,"aria-pressed":se,onClick:()=>!O&&ne(q),children:q})},j)})})]})]})});return d?r.jsxs("div",{ref:f,className:`relative w-full ${o}`.trim(),children:[r.jsxs("button",{type:"button",onClick:()=>p(q=>!q),className:"bonsaif-cal-trigger","data-open":u?"true":"false",children:[r.jsxs("span",{className:"inline-flex items-center gap-2 min-w-0",children:[r.jsx(F.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),r.jsx("span",{className:"truncate",children:ii(e)})]}),r.jsx(F.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${u?"rotate-180":""}`})]}),u&&r.jsx("div",{className:"absolute z-50",style:{...m.horizontal==="left"?{left:0}:{right:0},...m.vertical==="bottom"?{top:"calc(100% + 8px)"}:{bottom:"calc(100% + 8px)"}},children:U})]}):U}const di={sm:"h-4 w-4",md:"h-5 w-5"};function ui(e,t){if(typeof e=="function"){e(t);return}e&&(e.current=t)}const ln=s.forwardRef(function({label:t,description:n,error:a,size:o="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:d,...u},p){const f=s.useRef(null);return s.useEffect(()=>{f.current&&(f.current.indeterminate=l)},[l]),r.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${d?"cursor-not-allowed opacity-60":"cursor-pointer"} ${c}`,children:[r.jsxs("span",{className:"relative mt-0.5 inline-flex shrink-0",children:[r.jsx("input",{...u,ref:m=>{f.current=m,ui(p,m)},type:"checkbox",disabled:d,"aria-checked":l?"mixed":u["aria-checked"],"aria-invalid":!!a||u["aria-invalid"],className:`peer ${di[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}`}),r.jsx(F.HiCheck,{className:"pointer-events-none absolute left-1/2 top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 scale-75 text-[var(--primary-fg)] opacity-0 transition peer-checked:scale-100 peer-checked:opacity-100 peer-aria-checked:mixed:scale-100 peer-aria-checked:mixed:opacity-100"})]}),(t||n||a)&&r.jsxs("span",{className:"min-w-0",children:[t&&r.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:t}),n&&!a&&r.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:n}),a&&r.jsx("span",{className:"block text-xs leading-5 text-[var(--danger)]",children:a})]})]})});function ks(e){const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}async function fi(e){var t;if((t=navigator.clipboard)!=null&&t.writeText){await navigator.clipboard.writeText(e);return}ks(e)}function bi(e){return typeof e=="function"?e():e}function oa({value:e,resetDelay:t=2e3,title:n,copiedTitle:a="Copiado",copiedLabel:o,icon:l=r.jsx(F.HiClipboardDocument,{size:14}),copiedIcon:i=r.jsx(F.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:d,onCopyError:u,className:p="",style:f,children:m,onClick:x,type:w="button",...$}){const[h,E]=s.useState(!1),T=s.useRef(null);s.useEffect(()=>()=>{T.current&&window.clearTimeout(T.current)},[]);function g(k){E(!0),d==null||d(k),T.current&&window.clearTimeout(T.current),T.current=window.setTimeout(()=>{E(!1),T.current=null},t)}async function y(k){var L;if(c&&k.stopPropagation(),x==null||x(k),k.defaultPrevented)return;const S=bi(e);if(S)try{await fi(S),g(S)}catch(C){try{ks(S),g(S)}catch(W){u==null||u(W,S);return}(L=navigator.clipboard)!=null&&L.writeText||u==null||u(C,S)}}return r.jsxs("button",{...$,type:w,onClick:y,title:h?a:n,"aria-label":$["aria-label"]??(h?a:n),"data-copied":h?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${m?"min-w-7 px-2":"w-7"} ${p}`,style:{cursor:"pointer",background:h?"rgba(22,163,74,0.15)":"var(--bg-card)",border:h?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:h?"#16a34a":"var(--text-secondary)",boxShadow:h?"0 0 0 3px rgba(22,163,74,0.12)":"none",...f},children:[r.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:h?"scale(1.15)":"scale(1)"},children:h?i:l}),m&&r.jsx("span",{className:"text-xs font-semibold leading-none",children:h?o??m:m})]})}function mi({code:e,children:t,title:n="Codigo",language:a,copyLabel:o="Copiar",copiedLabel:l="Copiado",className:i="",style:c,onCopied:d}){const u=(e??t??"").trim();return r.jsxs("div",{className:`overflow-hidden rounded-lg border ${i}`,style:{borderColor:"rgba(148, 163, 184, 0.22)",background:"#0f172a",color:"#e2e8f0",...c},children:[r.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:[r.jsx("span",{className:"min-w-0 truncate text-[11px] font-black uppercase tracking-[0.08em]",children:n}),r.jsx(oa,{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})]}),r.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:r.jsx("code",{className:a?`language-${a}`:void 0,children:u})})]})}function la(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function ia(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function pi(e,t){if(!t.trim())return!0;const n=ia(t);return ia(e.label).includes(n)||!!(e.sublabel&&ia(e.sublabel).includes(n))}function _r({value:e,onChange:t,options:n,status:a="default",ariaLabel:o,triggerVariant:l="default",showSelectedSublabel:i=!0,placeholder:c="Seleccionar…",emptyLabel:d,disabled:u=!1,className:p="",style:f,dropdownMinWidth:m,height:x=40,padding:w="0 10px",searchable:$=!0,minOptionsForSearch:h=6}){const[E,T]=s.useState(!1),[g,y]=s.useState(""),[k,S]=s.useState(-1),[L,C]=s.useState(!1),[W,_]=s.useState({}),V=s.useRef(null),M=s.useRef(null),Z=s.useRef(null),H=s.useRef(null),ne=$&&n.length>=h,U=n.find(R=>R.value===e)??null,q=l==="ghost",j=a==="error"?"var(--danger)":E?"var(--primary)":"var(--border)",D=ne&&g.trim()?n.filter(R=>pi(R,g)):n,se=s.useCallback(()=>{const R=V.current;if(!R)return;const Q=R.getBoundingClientRect(),I=ne?272:212,J=window.innerHeight-Q.bottom,P=J<I&&Q.top>J;_({position:"fixed",left:Q.left,top:P?void 0:Q.bottom+4,bottom:P?window.innerHeight-Q.top+4:void 0,width:Q.width,minWidth:la(m),zIndex:9999})},[m,ne]);s.useEffect(()=>C(!0),[]),s.useEffect(()=>{if(!E)return;function R(Q){var J,P;const I=Q.target;!((J=V.current)!=null&&J.contains(I))&&!((P=M.current)!=null&&P.contains(I))&&(T(!1),y(""))}return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[E]),s.useEffect(()=>{E&&(S(-1),se(),ne&&setTimeout(()=>{var R;return(R=Z.current)==null?void 0:R.focus()},0))},[E,ne,se]),s.useEffect(()=>{if(E)return window.addEventListener("resize",se),window.addEventListener("scroll",se,!0),()=>{window.removeEventListener("resize",se),window.removeEventListener("scroll",se,!0)}},[E,se]),s.useEffect(()=>{if(k<0||!H.current)return;const R=H.current.children[k];R==null||R.scrollIntoView({block:"nearest"})},[k]);const B=s.useCallback(R=>{t(R),T(!1),y("")},[t]),O=s.useRef(E);O.current=E;const oe=s.useRef(D);oe.current=D;const v=s.useRef(k);v.current=k;const z=s.useRef(d);z.current=d;const ee=s.useRef(B);ee.current=B,s.useEffect(()=>{function R(Q){var ae,Y;const I=document.activeElement,J=((ae=V.current)==null?void 0:ae.contains(I))??!1,P=((Y=M.current)==null?void 0:Y.contains(I))??!1;if(!(!J&&!P)){if(!O.current){(Q.key==="Enter"||Q.key===" "||Q.key==="ArrowDown")&&(Q.preventDefault(),T(!0));return}switch(Q.key){case"ArrowDown":Q.preventDefault(),S(de=>Math.min(de+1,oe.current.length-1));break;case"ArrowUp":Q.preventDefault(),S(de=>Math.max(de-1,z.current?-1:0));break;case"Enter":{Q.preventDefault();const de=v.current,Se=oe.current;de===-1&&z.current?ee.current(""):Se[de]&&!Se[de].disabled&&ee.current(Se[de].value);break}case"Escape":Q.preventDefault(),Q.stopPropagation(),T(!1),y("");break}}}return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[]);const le=r.jsxs("div",{ref:M,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...W,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[ne&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[r.jsx(F.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),r.jsx("input",{ref:Z,value:g,onChange:R=>{y(R.target.value),S(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),g&&r.jsx("button",{type:"button",onMouseDown:R=>{R.preventDefault(),y("")},children:r.jsx(F.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),r.jsxs("ul",{ref:H,role:"listbox",className:"overflow-y-auto",style:{maxHeight:ne?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[d&&r.jsx("li",{role:"option","aria-selected":e==="",onMouseDown:R=>{R.preventDefault(),B("")},onMouseEnter:()=>S(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:k===-1&&!g.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:d}),D.map((R,Q)=>{const J=Q===k,P=R.value===e;return r.jsxs("li",{role:"option","aria-selected":P,onMouseDown:ae=>{ae.preventDefault(),R.disabled||B(R.value)},onMouseEnter:()=>!R.disabled&&S(Q),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:J?"var(--bg-hover)":P?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:R.disabled?"var(--text-muted)":"var(--text-main)",cursor:R.disabled?"not-allowed":"pointer",boxShadow:P?"inset 2px 0 0 var(--primary)":void 0},children:[R.color&&r.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:R.color}}),r.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[r.jsx("span",{className:"truncate",children:R.label}),R.sublabel&&r.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:R.sublabel})]}),R.badge&&r.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:R.badge})]},R.value)}),D.length===0&&r.jsx("li",{className:"px-3 py-4 text-sm text-center",style:{color:"var(--text-muted)"},children:"Sin resultados"})]})]});return r.jsxs("div",{ref:V,className:`relative ${p||"w-full"}`,style:f,children:[r.jsxs("button",{type:"button",disabled:u,onClick:()=>!u&&T(R=>!R),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:la(x),padding:la(w),background:q?"transparent":"var(--bg-input)",color:U?"var(--text-main)":"var(--text-muted)",border:q?"1px solid transparent":`1px solid ${j}`,opacity:u?.5:1,cursor:u?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":E,"aria-label":o,children:[(U==null?void 0:U.color)&&r.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:U.color}}),r.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:U?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"truncate",children:U.label}),i&&U.sublabel&&r.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:U.sublabel})]}):r.jsx("span",{className:"truncate",children:c})}),U&&d?r.jsx("span",{role:"button",tabIndex:-1,onMouseDown:R=>{R.preventDefault(),R.stopPropagation(),B("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:r.jsx(F.HiXMark,{className:"w-3 h-3"})}):r.jsx(F.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:E?"rotate(180deg)":"rotate(0deg)"}})]}),E&&L&&nr.createPortal(le,document.body)]})}function cn(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function hi({value:e,onChange:t,placeholder:n="Buscar...",className:a="",height:o=40,padding:l="0 10px 0 30px",iconLeft:i=10}){return r.jsxs("div",{className:`relative ${a}`,children:[r.jsx(F.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:cn(i)}}),r.jsx("input",{type:"text",value:e,onChange:c=>t(c.target.value),placeholder:n,className:"w-full rounded-lg border border-[var(--border)] [background:var(--bg-card)] text-sm text-[var(--text-main)] placeholder:text-[var(--text-muted)] outline-none transition-[border-color,box-shadow] focus:border-primary focus:ring-2 focus:ring-primary/20",style:{height:cn(o),padding:cn(l)}})]})}function gi({value:e,onChange:t,options:n,placeholder:a,icon:o,className:l="",height:i=40,padding:c,iconLeft:d=10,searchable:u=!0}){const p=o?n.map((f,m)=>m===0&&!f.color?{...f,sublabel:f.sublabel??void 0}:f):n;return r.jsxs("div",{className:`relative ${l}`,children:[o&&r.jsx("span",{className:"pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--text-muted)]",style:{left:cn(d)},children:o}),r.jsx(_r,{value:e,onChange:t,options:p,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 vi={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},dn=180,yi="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function ca({open:e,onClose:t,title:n,subtitle:a,leadingIcon:o,headerActions:l,footer:i,children:c,size:d="md",maxWidth:u,zIndex:p=1e3,closeOnBackdrop:f=!0,closeOnEscape:m=!0,showCloseButton:x=!0,placement:w="center",bodyClassName:$="px-6 py-5",panelClassName:h="",backdropClassName:E=yi,contentClassName:T="p-4",ariaLabel:g,frameless:y=!1,disabled:k=!1}){const[S,L]=s.useState(!1),[C,W]=s.useState(!1),_=s.useRef(null);if(s.useEffect(()=>(e?(_.current&&clearTimeout(_.current),L(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>W(!0)))):(W(!1),_.current=setTimeout(()=>L(!1),dn+40)),()=>{_.current&&clearTimeout(_.current)}),[e]),s.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),s.useEffect(()=>{if(!e||!m)return;const U=q=>{q.key==="Escape"&&t()};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[m,t,e]),!S)return null;const V=n||a||o||l||x,M=u??vi[d],Z=w==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",H=w==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",ne=C?"translateY(0) scale(1)":w==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return nr.createPortal(r.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":g??n,className:`fixed inset-0 flex ${Z} ${T}`,style:{zIndex:p},children:[r.jsx("div",{className:`absolute inset-0 ${E}`,onClick:f?t:void 0,style:{opacity:C?1:0,transition:`opacity ${dn}ms ease`}}),r.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${y?"shadow-none":"shadow-2xl"} ${H} ${h}`,style:{maxWidth:M,background:y?"transparent":"var(--bg-card)",border:y?"none":"1px solid var(--border)",opacity:C?1:0,transform:ne,transition:`opacity ${dn}ms ease, transform ${dn}ms ease`},onClick:U=>U.stopPropagation(),children:[k&&r.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)"}}),V&&r.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between gap-3 px-6 py-4",style:{borderBottom:"1px solid var(--border)"},children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[o&&r.jsx("div",{className:"flex-shrink-0",children:o}),(n||a)&&r.jsxs("div",{className:"min-w-0",children:[n&&r.jsx("h2",{className:"truncate text-base font-semibold",style:{color:"var(--text-main)"},children:n}),a&&r.jsx("p",{className:"truncate text-xs",style:{color:"var(--text-muted)"},children:a})]})]}),r.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[l,x&&r.jsx(je,{variant:"icon",onClick:t,title:"Cerrar",children:r.jsx(F.HiXMark,{className:"h-5 w-5"})})]})]}),r.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${$}`,children:c}),i&&r.jsx("div",{className:"flex flex-shrink-0 justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:i})]})]}),document.body)}const xi={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 wi({open:e,title:t,description:n,confirmLabel:a="Confirmar",cancelLabel:o="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:d}){const u=xi[l];return r.jsx(ca,{open:e,onClose:d,size:"md",zIndex:9998,showCloseButton:!1,bodyClassName:"p-0",panelClassName:"overflow-visible",ariaLabel:t,closeOnBackdrop:i,children:r.jsxs("div",{className:"relative px-6 pb-6 pt-6",children:[r.jsx(je,{variant:"icon",onClick:d,className:"absolute right-3 top-3 h-8 w-8 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:r.jsx(F.HiXMark,{className:"h-4 w-4"})}),r.jsxs("div",{className:"flex gap-3 pr-8",children:[r.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:r.jsx(F.HiExclamationTriangle,{className:"h-5 w-5",style:{color:u.iconColor}})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("h2",{className:"text-base font-semibold leading-snug",style:{color:"var(--text-main)"},children:t}),n?r.jsx("div",{className:"mt-1.5 text-sm leading-relaxed",style:{color:"var(--text-muted)"},children:n}):null]})]}),r.jsxs("div",{className:"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[r.jsx(je,{variant:"secondary",onClick:d,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:o}),r.jsx(je,{variant:"danger",onClick:c,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:u.btnBg,color:u.btnColor,borderColor:"transparent"},children:a})]})]})})}function ki(e){return e?typeof e=="function"?e():e:""}function Ni(e){return/^https?:\/\//i.test(e)}function Ns(e,t){try{return new URL(e,t).toString()}catch{return e}}function Si(e,t,n,a=!1){const o=typeof e=="function"?e():e,l=t?t(o):o;if(!l||Ni(l))return l;const i=ki(n);return i?Ns(l,i):a&&typeof window<"u"?Ns(l,window.location.origin):l}function Ci({url:e,resolveUrl:t,baseUrl:n,useWindowOriginForRelative:a=!1,title:o="Copiar link",copiedTitle:l="Link copiado",icon:i=r.jsx(F.HiLink,{className:"h-3.5 w-3.5"}),...c}){return r.jsx(oa,{...c,value:()=>Si(e,t,n,a),title:o,copiedTitle:l,icon:i})}const un=[25,50,100,200,500];let cr={dataTable:{pageSizeOptions:[...un]}};function Ei(){if(typeof window>"u")return;const t=window.__BONSAIF_DATA_TABLE_PREFERENCES_ENDPOINT__;return typeof t=="string"&&t.trim().length>0?t.trim().replace(/\/+$/,""):void 0}function da(){const e=cr.dataTable.preferencesEndpoint,t=Ei();return e&&e.trim().length>0?e.trim().replace(/\/+$/,""):t}function Mi(e){if(!Array.isArray(e))return[...un];const t=Array.from(new Set(e.map(n=>typeof n=="number"?Math.floor(n):Number.NaN).filter(n=>Number.isFinite(n)&&n>0)));return t.length>0?t:[...un]}function Ss(e){if(typeof e!="string")return;const t=e.trim();if(t)return t.replace(/\/+$/,"")}function $i(e){if(!e||typeof e!="object"||!e.dataTable)return;const t=Ss(e.dataTable.preferencesEndpoint);cr={...cr,dataTable:{...cr.dataTable,pageSizeOptions:Mi(e.dataTable.pageSizeOptions),preferencesEndpoint:t??cr.dataTable.preferencesEndpoint}}}function Ti(){return{dataTable:{pageSizeOptions:[...cr.dataTable.pageSizeOptions]}}}function At(){return[...cr.dataTable.pageSizeOptions]}function Li(){cr={dataTable:{pageSizeOptions:[...un]}}}function Ai(e){cr={...cr,dataTable:{...cr.dataTable,preferencesEndpoint:Ss(e)}}}const fn=[{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"}],Di=fn.map(e=>({value:e.value,label:e.label})),Ii=12,Oi={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},Cs={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},Hi="bonsaif-ui:datatable:",Bi="[&_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",Fi=[],Pi=52;function Sr(e){if(!e)return 150;const t=parseInt(e,10);return isNaN(t)||t<=0?150:t}function Es(e){return!!(e&&(Array.isArray(e.columnOrder)&&e.columnOrder.length>0||e.columnWidths&&Object.keys(e.columnWidths).length>0||Array.isArray(e.hiddenColumnKeys)&&e.hiddenColumnKeys.length>0||e.filters&&Object.keys(e.filters).length>0||e.conditionFilters&&Object.keys(e.conditionFilters).length>0||e.sort||typeof e.bql=="string"||Array.isArray(e.bqlHistory)&&e.bqlHistory.length>0||typeof e.pageSize=="number"))}function Ms(e){return`${Hi}${e}`}function bn(e){try{const t=window.localStorage.getItem(Ms(e));if(!t)return null;const n=JSON.parse(t);return n&&typeof n=="object"?n:null}catch{return null}}function zi(e,t){try{window.localStorage.setItem(Ms(e),JSON.stringify(t))}catch{}}function _i(e,t){if(e===!0)return{...Cs};if(e===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(t&&e==null)return{...Cs};const n={...Oi,...e??{}};return t&&(typeof e!="object"||e.pagination!==!1)&&(n.pagination=!0),n}function $s(...e){return e.reduce((t,n)=>({...t,...n??{}}),{})}function ua(e,t,n){return typeof e!="number"||e<=0?n:Bt(t).includes(e)?e:n}function Dt(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.key=="string"&&(t.dir==="asc"||t.dir==="desc")}function It(e,t){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=Object.entries(e).flatMap(([a,o])=>{if(!t.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 Ot(e,t){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=new Set(fn.map(o=>o.value)),a=Object.entries(e).flatMap(([o,l])=>{if(!t.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 ar(e,t){if(jr(e))return Pi;const n=e.minWidth??80,a=e.maxWidth??1/0;return Math.min(a,Math.max(n,t))}function ji(e){const t=window.getComputedStyle(e);return parseFloat(t.paddingLeft)+parseFloat(t.paddingRight)}function jr(e){return e.key==="actions"||e.key==="acciones"?!0:typeof e.header=="string"&&e.header.trim().toLowerCase()==="acciones"}function fa(e){return e.sticky===!0}function Ts(e){return!(e.reorderable===!1||e.sticky&&e.reorderable!==!0)}function Lr(e,t){const n=t.filter(fa).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 Wi(e,t){if(t<=7)return Array.from({length:t},(a,o)=>o+1);const n=[1];e>3&&n.push("...");for(let a=Math.max(2,e-1);a<=Math.min(t-1,e+1);a++)n.push(a);return e<t-2&&n.push("..."),n.push(t),n}function Ar(e,t){var i;const n=new Set(t.filter(c=>c.hideable!==!1).map(c=>c.key)),a=Array.from(new Set(e??[])).filter(c=>n.has(c));if(t.filter(c=>!a.includes(c.key)).length>0)return a;const l=(i=t.find(c=>c.hideable!==!1))==null?void 0:i.key;return l?a.filter(c=>c!==l):[]}function qi(e){return e==null||e===""?"(Vacio)":e instanceof Date?e.toLocaleDateString():String(e)}function nt(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(nt).join(" ").trim():s.isValidElement(e)?nt(e.props.children):""}function mn(e,t){const n=e.filterValue?e.filterValue(t):e.sortKey?t[e.sortKey]:e.cell(t);return typeof n=="string"||typeof n=="number"||typeof n=="boolean"||n===null||n===void 0||n instanceof Date?qi(n):nt(n).trim()}function Ht(e){const t=e.replace(/,/g,"").trim();if(!t)return null;const n=Number(t);return Number.isFinite(n)?n:null}function at(e,t){const n=Ht(e),a=Ht(t);return n!==null&&a!==null?n-a:e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function Bt(e){const t=Array.from(new Set(e.map(n=>Math.floor(n)).filter(n=>Number.isFinite(n)&&n>0)));return t.length>0?t:At()}function Ui(e,t,n){var i,c;const a=((i=t.value)==null?void 0:i.trim())??"",o=((c=t.valueTo)==null?void 0:c.trim())??"",l=fn.find(d=>d.value===t.operator);if((l==null?void 0:l.valueMode)==="single"&&!a||(l==null?void 0:l.valueMode)==="between"&&(!a||!o))return!0;switch(t.operator){case"equals":return e.toLowerCase()===a.toLowerCase();case"notEquals":return e.toLowerCase()!==a.toLowerCase();case"greaterThan":return at(e,a)>0;case"greaterThanOrEqual":return at(e,a)>=0;case"lessThan":return at(e,a)<0;case"lessThanOrEqual":return at(e,a)<=0;case"between":return at(e,a)>=0&&at(e,o)<=0;case"top10":case"bottom10":{const u=n.map(f=>({value:f,number:Ht(f)})).filter(f=>f.number!==null).sort((f,m)=>f.number-m.number).map(f=>f.value);return(t.operator==="top10"?u.slice(-10):u.slice(0,10)).includes(e)}case"aboveAverage":case"belowAverage":{const d=n.map(Ht).filter(f=>f!==null);if(d.length===0)return!1;const u=d.reduce((f,m)=>f+m,0)/d.length,p=Ht(e);return p===null?!1:t.operator==="aboveAverage"?p>u:p<u}default:return!0}}function Ls({children:e,className:t="",style:n}){return r.jsx(zr,{onlyWhenOverflow:!0,className:t,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,...n},children:e})}function As({columns:e,data:t,getRowId:n,loading:a=!1,skeletonRows:o=8,emptyIcon:l,emptyText:i="Sin resultados",initialEmptyDelay:c=450,onRowClick:d,renderExpandedRow:u,getRowCanExpand:p,expandedRowIds:f,defaultExpandedRowIds:m=[],onExpandedRowIdsChange:x,expandOnRowClick:w=!1,selected:$,onToggleOne:h,onToggleAll:E,getRowSelectable:T,highlightSelected:g=!0,rowClassName:y,getRowCategory:k,stickyHeader:S=!0,pageSize:L=25,pageSizeOptions:C,pageSizeSelectWidth:W=62,pageSizeSelectHeight:_=30,pageSizeSelectPadding:V="0 7px",totalRows:M,page:Z,onPageChange:H,onPageSizeChange:ne,storageKey:U,stickyFirstColumn:q=!1,bottomOffset:j=0,compact:D=!0,restrictHeight:se=!0,maxHeight:B,minTableWidth:O,enableColumnVisibility:oe=!0,enableColumnFilters:v=!0,hiddenColumnKeys:z,defaultHiddenColumnKeys:ee=Fi,onHiddenColumnKeysChange:le,columnVisibilityLabel:R="Columnas",enableBql:Q=!1,bqlValue:I,defaultBqlValue:J="",onBqlChange:P,bqlDescription:ae="Filtra registros con Bonsaif Query Language",bqlPlaceholder:Y=`status = activo
2
- rol IN (admin, employee)`,bqlQuickFilters:de=[],bqlExamples:Se=[],bqlSuggestions:ie=[],bqlActiveFilters:pe,bqlError:Ce,onQueryChange:De,persistState:mr,onPreferencesReady:xr,enableExport:We=!1,exportFilename:Le="datos"}){var Bl;const ke=_i(mr,U),er=Object.values(ke).some(Boolean),me=e.map(b=>b.key).join(","),K=ee.join(","),re=s.useRef(e),be=s.useRef(ee);re.current=e,be.current=ee;const[he,Be]=s.useState(!U||!er),Te=s.useRef(null),He=s.useRef(!U),Fe=s.useRef(!1),ce=s.useRef(xr);ce.current=xr;const ue=s.useRef(!U||!er?U??"__none__":null),Ee=z!==void 0,[Ie,Ae]=s.useState(()=>Ar(ee,e)),Pe=Ar(Ee?z:Ie,e),[Ge,Ze]=s.useState(!1),[Qe,Er]=s.useState("filter"),[Or,Ur]=s.useState(null),[tl,nl]=s.useState(""),[lr,gt]=s.useState({}),[wr,Gt]=s.useState({}),Va=f!==void 0,[al,cf]=s.useState(m),Vr=I!==void 0,[df,Zt]=s.useState(J),Mr=Vr?I:df,[Qt,Hn]=s.useState(Mr),[$r,Yr]=s.useState(!1),[sl,vt]=s.useState(!1),[ol,yt]=s.useState(!1),[Jt,xt]=s.useState([]),wt=s.useRef(null),Kr=s.useRef(null),kr=s.useRef(P);kr.current=P;const Bn=s.useRef(L);Bn.current=L;const Fn=s.useRef(C);Fn.current=C;const uf=Array.isArray(C)?C.join(","):"",Ya=s.useRef(null),ll=s.useRef(null),Ka=s.useRef(null),il=s.useRef(0),[ff,bf]=s.useState({}),[mf,pf]=s.useState({}),[Rt,Pn]=s.useState(!1),Xa=s.useRef(null),zn=s.useRef(null),[hf,gf]=s.useState({}),cl=s.useRef(null),_n=s.useRef(null),[Ga,dl]=s.useState(t.length>0||a||c===!1),ul=(b,N)=>50+(b*17+N*13+7)%40,Hr=s.useRef(null),[vf,yf]=s.useState(void 0),[fl,xf]=s.useState(0),[wf,kf]=s.useState(!1);s.useEffect(()=>{function b(){kf(window.innerWidth<640)}if(!se||B!==void 0)return b(),window.addEventListener("resize",b),()=>window.removeEventListener("resize",b);const X=L!==!1?48:0,A=12;function te(){if(b(),!Hr.current)return;const fe=Hr.current.getBoundingClientRect().top;yf(Math.max(120,window.innerHeight-fe-X-A-j))}return te(),window.addEventListener("resize",te),()=>window.removeEventListener("resize",te)},[a,L,j,se,B]);const bl=se?B??vf:void 0;s.useEffect(()=>{const b=Hr.current;if(!b)return;const N=()=>xf(b.clientWidth);if(N(),typeof ResizeObserver>"u")return window.addEventListener("resize",N),()=>window.removeEventListener("resize",N);const X=new ResizeObserver(N);return X.observe(b),()=>X.disconnect()},[a,he,t.length]),s.useEffect(()=>{if(c===!1||a||t.length>0){dl(!0);return}if(Ga)return;const b=window.setTimeout(()=>{dl(!0)},c);return()=>window.clearTimeout(b)},[t.length,c,Ga,a]);const[kt,Nt]=s.useState(()=>Lr(e.map(b=>b.key),e)),[Xr,St]=s.useState(()=>Object.fromEntries(e.map(b=>[b.key,ar(b,Sr(b.width))]))),[qe,Gr]=s.useState(null),[Nf,jn]=s.useState(1),[Wn,qn]=s.useState(L===!1?0:L);s.useEffect(()=>{var Me;const b=re.current,N=be.current,X=b.map(we=>we.key),A=new Set(X),te=()=>{var we;Fe.current||(Fe.current=!0,(we=ce.current)==null||we.call(ce))};if(!U||!er){ke.layout&&Nt(Lr(X,b)),Ee||Ae(Ar(N,b)),He.current=!1,Be(!0),te();return}let fe=!1;const ve=ue.current===U;ve||(He.current=!1,Be(!1),Fe.current=!1);const $e=bn(U);if(Es($e)&&!ve){const we=$e,ye=Bt(Fn.current??At()),xe=Bn.current,rt=xe===!1?0:xe,Br=ke.layout?we==null?void 0:we.columnOrder:void 0,Fr=Array.isArray(Br)?Br.filter(ze=>X.includes(ze)):[],Pr=X.filter(ze=>!Fr.includes(ze)),tt=Lr(Fr.length>0?[...Fr,...Pr]:X,b),Mt=Object.fromEntries(b.map(ze=>[ze.key,ar(ze,Sr(ze.width))])),$t=ke.layout?(we==null?void 0:we.columnWidths)??{}:{},nn=Object.fromEntries(b.map(ze=>[ze.key,ar(ze,$t[ze.key]??Mt[ze.key])])),Tt=Ar(ke.layout?(we==null?void 0:we.hiddenColumnKeys)??N:N,b);if(ke.layout&&(Nt(tt),St(nn)),Ee||Ae(Tt),ke.filters&&(gt(It(we==null?void 0:we.filters,A)),Gt(Ot(we==null?void 0:we.conditionFilters,A))),ke.sort){const ze=Dt(we==null?void 0:we.sort)?we.sort:null;Gr(ze&&A.has(ze.key)?ze:null)}if(ke.bql){if(wt.current!==U){wt.current=U;const ze=typeof(we==null?void 0:we.bql)=="string"?we.bql:J;Vr?(Me=kr.current)==null||Me.call(kr,ze):Zt(ze)}xt(Array.isArray(we==null?void 0:we.bqlHistory)?we.bqlHistory.filter(ze=>typeof ze=="string"):[])}ke.pagination&&Kr.current!==U&&(Kr.current=U,qn(ua(we==null?void 0:we.pageSize,ye,rt))),ue.current=U,Be(!0),te()}const tr=`${da()??"/api/user/preferences/datatables"}?key=${encodeURIComponent(U)}`,Ke=new AbortController,ge=window.setTimeout(()=>Ke.abort(),2500);return fetch(tr,{cache:"no-store",signal:Ke.signal}).then(we=>we.ok?we.json():null).then(we=>{var Fl;if(fe)return;const ye=bn(U),xe=$s(Es(we==null?void 0:we.settings)?we==null?void 0:we.settings:null,ye),rt=Bt(Fn.current??At()),Br=Bn.current,Fr=Br===!1?0:Br,Pr=ke.layout?xe==null?void 0:xe.columnOrder:void 0,tt=Array.isArray(Pr)?Pr.filter(Ve=>X.includes(Ve)):[],Mt=X.filter(Ve=>!tt.includes(Ve)),$t=Lr(tt.length>0?[...tt,...Mt]:X,b),nn=Object.fromEntries(b.map(Ve=>[Ve.key,ar(Ve,Sr(Ve.width))])),Tt=ke.layout?(xe==null?void 0:xe.columnWidths)??{}:{},ze=Object.fromEntries(b.map(Ve=>[Ve.key,ar(Ve,Tt[Ve.key]??nn[Ve.key])])),Lt=Ar(ke.layout?(xe==null?void 0:xe.hiddenColumnKeys)??N:N,b);if(ke.layout&&(Nt($t),St(ze)),Ee||Ae(Lt),ke.filters&&(gt(It(xe==null?void 0:xe.filters,A)),Gt(Ot(xe==null?void 0:xe.conditionFilters,A))),ke.sort){const Ve=Dt(xe==null?void 0:xe.sort)?xe.sort:null;Gr(Ve&&A.has(Ve.key)?Ve:null)}if(ke.bql){if(wt.current!==U){wt.current=U;const Ve=typeof(xe==null?void 0:xe.bql)=="string"?xe.bql:J;Vr?(Fl=kr.current)==null||Fl.call(kr,Ve):Zt(Ve)}xt(Array.isArray(xe==null?void 0:xe.bqlHistory)?xe.bqlHistory.filter(Ve=>typeof Ve=="string"):[])}let _e;ke.pagination&&(_e=ua(xe==null?void 0:xe.pageSize,rt,Fr),Kr.current!==U&&(Kr.current=U,qn(_e))),Te.current=JSON.stringify({columnOrder:$t,columnWidths:ze,hiddenColumnKeys:Lt,filters:It(xe==null?void 0:xe.filters,A),conditionFilters:Ot(xe==null?void 0:xe.conditionFilters,A),sort:Dt(xe==null?void 0:xe.sort)?xe.sort:null,bql:typeof(xe==null?void 0:xe.bql)=="string"?xe.bql:"",bqlHistory:Array.isArray(xe==null?void 0:xe.bqlHistory)?xe.bqlHistory:[],pageSize:ke.pagination&&Br!==!1?_e:void 0}),He.current=!0}).catch(()=>{var we;if(!fe){const ye=bn(U),xe=Bt(Fn.current??At()),rt=Bn.current,Br=rt===!1?0:rt,Fr=ke.layout?ye==null?void 0:ye.columnOrder:void 0,Pr=Array.isArray(Fr)?Fr.filter(_e=>X.includes(_e)):[],tt=X.filter(_e=>!Pr.includes(_e)),Mt=Lr(Pr.length>0?[...Pr,...tt]:X,b),$t=Object.fromEntries(b.map(_e=>[_e.key,ar(_e,Sr(_e.width))])),nn=ke.layout?(ye==null?void 0:ye.columnWidths)??{}:{},Tt=Object.fromEntries(b.map(_e=>[_e.key,ar(_e,nn[_e.key]??$t[_e.key])]));ke.layout&&(Nt(Mt),St(Tt));const ze=Ar(ke.layout?(ye==null?void 0:ye.hiddenColumnKeys)??N:N,b);if(Ee||Ae(ze),ke.filters&&(gt(It(ye==null?void 0:ye.filters,A)),Gt(Ot(ye==null?void 0:ye.conditionFilters,A))),ke.sort){const _e=Dt(ye==null?void 0:ye.sort)?ye.sort:null;Gr(_e&&A.has(_e.key)?_e:null)}if(ke.bql){if(wt.current!==U){wt.current=U;const _e=typeof(ye==null?void 0:ye.bql)=="string"?ye.bql:J;Vr?(we=kr.current)==null||we.call(kr,_e):Zt(_e)}xt(Array.isArray(ye==null?void 0:ye.bqlHistory)?ye.bqlHistory.filter(_e=>typeof _e=="string"):[])}let Lt;ke.pagination&&(Lt=ua(ye==null?void 0:ye.pageSize,xe,Br),Kr.current!==U&&(Kr.current=U,qn(Lt))),Te.current=JSON.stringify({columnOrder:Mt,columnWidths:Tt,hiddenColumnKeys:ze,filters:It(ye==null?void 0:ye.filters,A),conditionFilters:Ot(ye==null?void 0:ye.conditionFilters,A),sort:Dt(ye==null?void 0:ye.sort)?ye.sort:null,bql:typeof(ye==null?void 0:ye.bql)=="string"?ye.bql:"",bqlHistory:Array.isArray(ye==null?void 0:ye.bqlHistory)?ye.bqlHistory:[],pageSize:ke.pagination&&rt!==!1?Lt:void 0}),He.current=!0}}).finally(()=>{window.clearTimeout(ge),fe||(ue.current=U,Be(!0),te())}),()=>{fe=!0,Ke.abort(),window.clearTimeout(ge)}},[U,er,me,K,Ee,ke.layout,ke.filters,ke.sort,ke.bql,ke.pagination,Vr,J,uf]),s.useEffect(()=>{if(!U||!he||!er||!He.current)return;const b={};ke.layout&&(b.columnOrder=kt,b.columnWidths=Xr,b.hiddenColumnKeys=Pe),ke.filters&&(b.filters=lr,b.conditionFilters=wr),ke.sort&&(b.sort=qe),ke.bql&&(b.bql=Mr,b.bqlHistory=Jt),ke.pagination&&L!==!1&&(b.pageSize=Wn);const N=bn(U),X=$s(N,b),A=JSON.stringify(X);if(A===Te.current)return;zi(U,X),Te.current=A;const te=window.setTimeout(()=>{const fe=da()??"/api/user/preferences/datatables";fetch(fe,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:U,settings:X})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(te)},[kt,Xr,Pe,lr,wr,qe,Mr,Jt,Wn,L,U,he,er,ke.layout,ke.filters,ke.sort,ke.bql,ke.pagination]),s.useEffect(()=>{Nt(b=>{const N=e.map(te=>te.key),X=b.filter(te=>N.includes(te)),A=N.filter(te=>!X.includes(te));return Lr([...X,...A],e)})},[me,e]);const ml=Lr(kt,e).map(b=>e.find(N=>N.key===b)).filter(b=>!!b),ir=ml.filter(b=>!Pe.includes(b.key)),pl=e.some(fa),Sf=Object.keys(lr).length,Cf=Object.keys(wr).length,Za=Sf+Cf;function hl(b){const N=new Set;return t.reduce((X,A)=>{const te=mn(b,A);return!te||N.has(te)||(N.add(te),X.push({value:te,label:te})),X},[])}function Ef(){const b=e.find(N=>N.key===Or);return b?hl(b):[]}function Mf(b){return!!(v&&!jr(b)&&(b.filterValue||b.sortKey||hl(b).length>0))}function gl(b,N){gt(X=>{const A={...X};return A[b]=N,A})}function $f(b,N,X,A){const te=lr[b]??[],fe=A?te:X.filter($e=>$e!==N),ve=A?te.includes(N)?te.filter($e=>$e!==N):[...te,N]:fe;ve.length===X.length?Qa(b):gl(b,ve)}function Qa(b){gt(N=>{const X={...N};return delete X[b],X})}function Un(b,N){Gt(X=>{const A={...X};return N?A[b]=N:delete A[b],A})}function vl(b){Un(b,null)}function Tf(){gt({}),Gt({})}function Lf(b){Vr||Zt(b),P==null||P(b)}function yl(b){const N=b.trim();Hn(N),(P==null?void 0:P(N))!==!1&&(Vr||Zt(N),Yr(!1),vt(!1),yt(!1),N&&xt(A=>[N,...A.filter(te=>te!==N)].slice(0,Ii)))}function xl(){Hn(""),Lf(""),Yr(!1),vt(!1),yt(!1)}function Ja(b,N){Hn(b),N&&(N.style.height="auto",N.style.height=`${Math.min(N.scrollHeight,180)}px`)}function Vn(b){const N=b.trim();if(!N)return;il.current=Date.now()+500;const X=Qt.replace(/\s+$/u,""),A=X.length===0?N:X.split(`
3
- `).map(te=>te.trim()).includes(N)?X:`${X}
4
- ${N}`;Ja(A,Ka.current??void 0),requestAnimationFrame(()=>{const te=Ka.current;if(!te)return;te.focus();const fe=te.value.length;te.setSelectionRange(fe,fe),Ja(te.value,te)})}s.useEffect(()=>{Hn(Mr)},[Mr]);const Yn=s.useCallback(()=>{const b=Ya.current;if(!b)return;const N=b.getBoundingClientRect(),X=12,A=8,te=Math.min(780,Math.max(320,window.innerWidth-32)),fe=Math.max(X,window.innerWidth-te-X),ve=Math.min(Math.max(X,N.left),fe),$e=N.bottom+A,Xe=window.innerHeight-N.top+A,Ue=window.innerHeight-$e-X,tr=N.top-X-A,Ke=Ue<280&&tr>Ue,ge=Math.max(240,Ke?tr:Ue);bf({position:"fixed",zIndex:1e4,left:ve,top:Ke?void 0:$e,bottom:Ke?Xe:void 0,width:te,maxWidth:"calc(100vw - 24px)",maxHeight:ge,overflowY:"auto"})},[]);s.useEffect(()=>{if(!$r)return;function b(A){var fe,ve;if(Date.now()<il.current)return;const te=A.target;(fe=Ya.current)!=null&&fe.contains(te)||(ve=ll.current)!=null&&ve.contains(te)||(Yr(!1),vt(!1),yt(!1))}function N(A){A.key==="Escape"&&(Yr(!1),vt(!1),yt(!1))}function X(){Yn()}return Yn(),document.addEventListener("mousedown",b),window.addEventListener("keydown",N),window.addEventListener("resize",X),window.addEventListener("scroll",X,!0),()=>{document.removeEventListener("mousedown",b),window.removeEventListener("keydown",N),window.removeEventListener("resize",X),window.removeEventListener("scroll",X,!0)}},[$r,Yn]);function wl(b){const N=Ar(b,e);Ee||Ae(N),le==null||le(N)}function Af(b){wl(Pe.includes(b)?Pe.filter(N=>N!==b):[...Pe,b])}function Df(){wl([])}const Ra=s.useCallback((b=_n.current)=>{if(!b)return;const N=b.getBoundingClientRect(),X=Math.min(292,Math.max(240,window.innerWidth-16)),A=Math.max(8,window.innerWidth-X-8),te=Math.min(Math.max(8,N.right-X),A),fe=window.innerHeight-N.bottom,ve=N.bottom+6,$e=window.innerHeight-N.top+6,Ue=fe<360&&N.top>fe?void 0:ve,tr=Ue===void 0?$e:void 0,Ke=Math.max(220,Ue===void 0?N.top-16:window.innerHeight-ve-8),ge={position:"fixed",zIndex:9999,left:te,top:Ue,bottom:tr,width:X,maxWidth:"calc(100vw - 16px)",maxHeight:Ke,"--dt-column-menu-max-height":`${Ke}px`};pf(ge)},[]);function kl(b,N,X=null){b.preventDefault(),b.stopPropagation();const A=_n.current===b.currentTarget&&Qe===N&&Or===X;if(Ge&&A){Ze(!1),Ur(null);return}_n.current=b.currentTarget,Er(N),Ur(X),nl(""),Ra(b.currentTarget),Ze(!0)}function If(b){if(jr(b))return;const N=Hr.current;if(!N)return;const A=Array.from(N.querySelectorAll("[data-dt-column-key]")).filter(te=>te.dataset.dtColumnKey===b.key).reduce((te,fe)=>{const ve=fe.querySelector("[data-dt-autofit-content]"),$e=ve?ve.scrollWidth:Math.max(fe.scrollWidth,fe.offsetWidth);return Math.max(te,Math.ceil($e+ji(fe)))},0);A<=0||St(te=>({...te,[b.key]:ar(b,A+12)}))}s.useEffect(()=>{St(b=>{const N=Object.fromEntries(e.map(X=>[X.key,ar(X,Sr(X.width))]));return Object.fromEntries(e.map(X=>[X.key,ar(X,b[X.key]??N[X.key])]))})},[me,e]),s.useEffect(()=>{Ee||Ae(b=>Ar(b,e))},[me,e,Ee]),s.useEffect(()=>{function b(A){var ve,$e;const te=A.target,fe=A.target;fe!=null&&fe.closest("[data-bonsaif-select-dropdown='true']")||!((ve=cl.current)!=null&&ve.contains(te))&&!(($e=_n.current)!=null&&$e.contains(te))&&(Ze(!1),Ur(null))}function N(A){A.key==="Escape"&&(Ze(!1),Ur(null))}function X(){Ra()}return Ge&&(document.addEventListener("mousedown",b),window.addEventListener("keydown",N),window.addEventListener("resize",X),window.addEventListener("scroll",X,!0)),()=>{document.removeEventListener("mousedown",b),window.removeEventListener("keydown",N),window.removeEventListener("resize",X),window.removeEventListener("scroll",X,!0)}},[Ge,Ra]);const en=s.useRef(null);s.useEffect(()=>{function b(X){const A=en.current;if(!A)return;const te=X.clientX-A.startX,fe=e.find(ve=>ve.key===A.colKey);fe&&St(ve=>({...ve,[A.colKey]:ar(fe,A.startWidth+te)}))}function N(){en.current&&(en.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",b),document.addEventListener("pointerup",N),()=>{document.removeEventListener("pointermove",b),document.removeEventListener("pointerup",N)}},[e]);const rn=s.useRef(null),[Nl,es]=s.useState(null);function Of(b,N){const X=e.find(A=>A.key===b);if(!X||!Ts(X)){N.preventDefault();return}rn.current=kt.indexOf(b),N.dataTransfer.effectAllowed="move"}function Hf(b,N){N.preventDefault(),N.dataTransfer.dropEffect="move";const X=kt.indexOf(b);Nl!==X&&es(X)}function Bf(b,N){N.preventDefault();const X=rn.current,A=kt.indexOf(b);X!==null&&X!==A&&Nt(te=>{const fe=[...te],[ve]=fe.splice(X,1);return fe.splice(A,0,ve),Lr(fe,e)}),rn.current=null,es(null)}function Ff(){rn.current=null,es(null)}function Pf(b){b.sortKey&&Gr(N=>(N==null?void 0:N.key)===b.key?{key:b.key,dir:N.dir==="asc"?"desc":"asc"}:{key:b.key,dir:"asc"})}s.useEffect(()=>{jn(1)},[t]),s.useEffect(()=>{jn(1)},[wr,lr]);const Zr=!!(H&&ne),Qr=L!==!1,Sl=s.useMemo(()=>Bt(C??At()),[C]),Re=Zr?Z??1:Nf,Nr=Zr||Qr?Wn:t.length,pr=!!$&&!!h&&!!E,rs=s.useMemo(()=>T?t.filter(b=>T(b)):t,[t,T]),Ct=!!u,Cl=s.useMemo(()=>new Set(Va?Array.from(f??[]):al),[Va,f,al]),zf=(Ct?40:0)+(pr?40:0),ts=!wf&&(pl||q),Kn=(()=>{if(!ts)return{};let b=zf;const N={};return ir.forEach((X,A)=>{(fa(X)||!pl&&q&&A===0)&&(N[X.key]=b,b+=Xr[X.key]??ar(X,Sr(X.width)))}),N})(),ns=Object.keys(Kn),as=ns.length>0?ns[ns.length-1]:null,El=pr&&rs.length>0&&rs.every(b=>$.has(n(b))),_f=pr&&$.size>0&&rs.some(b=>$.has(n(b)))&&!El,Xn=s.useMemo(()=>{const b=Object.entries(lr),N=Object.entries(wr);return b.length===0&&N.length===0?t:t.filter(X=>b.every(([A,te])=>{const fe=e.find(ve=>ve.key===A);return fe?te.includes(mn(fe,X)):!0})&&N.every(([A,te])=>{const fe=e.find($e=>$e.key===A);if(!fe)return!0;const ve=t.map($e=>mn(fe,$e));return Ui(mn(fe,X),te,ve)}))},[wr,lr,e,t]),Jr=s.useMemo(()=>{if(!qe)return Xn;const b=e.find(N=>N.key===qe.key&&N.sortKey);return b!=null&&b.sortKey?[...Xn].sort((N,X)=>{const A=N[b.sortKey],te=X[b.sortKey],fe=A===te?0:A==null?1:te==null||A<te?-1:1;return qe.dir==="asc"?fe:-fe}):Xn},[Xn,qe,e]),Ml=s.useMemo(()=>{if(Zr||!Qr)return Jr;const b=(Re-1)*Nr;return Jr.slice(b,b+Nr)},[Jr,Zr,Qr,Re,Nr]),Rr=Zr?M??t.length:Jr.length,ss=Qr?Math.max(1,Math.ceil(Rr/Nr)):1,jf=Math.min(...Sl),Wf=Qr&&(Rr>Nr||Rr>jf),qf=Qr?(Re-1)*Nr+1:1,Uf=Qr?Math.min(Re*Nr,Rr):Rr;function os(b){if(a)return;const N=Math.max(1,Math.min(b,ss));Zr?H(N):jn(N)}function Vf(b){a||(U&&(Kr.current=U),qn(b),Zr?(ne(b),H(1)):(jn(1),ne==null||ne(b)))}function $l(b){const N=new Set(Cl);N.has(b)?N.delete(b):N.add(b);const X=Array.from(N);Va||cf(X),x==null||x(X)}s.useEffect(()=>{De==null||De({bql:Mr,filters:lr,conditionFilters:wr,sort:qe,page:Re,pageSize:Nr,hiddenColumnKeys:Pe})},[Mr,lr,wr,qe,Re,Nr,Pe,De]);const Tl=b=>b==="center"?"justify-center text-center":b==="right"?"justify-end text-right":"justify-start text-left",Yf="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",ls="linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 90%, var(--bg-card)) 0%, color-mix(in srgb, var(--bg-input) 70%, var(--bg-card)) 100%)",Oe="color-mix(in srgb, var(--border) 62%, var(--bg-card))",et="color-mix(in srgb, var(--primary) 24%, var(--border))",Gn=`inset 0 0 0 1px ${Oe}`,Ll=ir.reduce((b,N)=>b+(Xr[N.key]??Sr(N.width)),(Ct?40:0)+(pr?40:0)),Al=typeof O=="number"?O:typeof O=="string"?Number(((Bl=O.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:Bl[1])??NaN):NaN,tn=Number.isFinite(Al)?Math.max(Ll,Al,fl):Math.max(Ll,fl),Zn=O??tn,Et=`${Ct?"40px ":""}${pr?"40px ":""}${ir.map(b=>`${Xr[b.key]??Sr(b.width)}px`).join(" ")}`;s.useEffect(()=>{qe&&Pe.includes(qe.key)&&Gr(null)},[Pe,qe]);function Dl(b){return b?typeof b=="string"?{key:b,label:b}:b:null}const Qn=()=>r.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Et,background:ls,borderBottom:`1px solid ${et}`},children:[Ct&&r.jsx("div",{role:"columnheader",className:`${D?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${et}`,borderRight:`1px solid ${Oe}`}}),pr&&r.jsx("div",{role:"columnheader",className:`${D?"px-2 py-1.5":"px-3 py-2.5"} flex w-10 items-center justify-center`,style:ts?{position:"sticky",left:0,zIndex:12,background:ls,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${et}`,borderRight:`1px solid ${Oe}`}:{borderBottom:`1px solid ${et}`,borderRight:`1px solid ${Oe}`},children:r.jsx(ln,{size:"sm",checked:El,indeterminate:_f,onChange:E,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),ir.map((b,N)=>{const X=(qe==null?void 0:qe.key)===b.key,A=!!b.sortKey,te=jr(b),fe=Kn[b.key],ve=fe!==void 0,$e=b.key===as,Xe=Ts(b),Ue=Nl===N,Ke=(Xr[b.key]??Sr(b.width))<120,ge=Object.prototype.hasOwnProperty.call(lr,b.key)||Object.prototype.hasOwnProperty.call(wr,b.key);return r.jsxs("div",{role:"columnheader","data-dt-column-key":b.key,className:`group select-none ${Ke?"text-left":Tl(b.align)}`,style:{...ve?{position:"sticky",left:fe,zIndex:12,background:ls,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:$e?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${et}`:`inset 0 -1px 0 ${et}`,borderRight:`1px solid ${Oe}`}:{position:"relative",borderBottom:`1px solid ${et}`,borderRight:`1px solid ${Oe}`},color:X?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:Ue?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:te?D?"7px 6px":"9px 8px":D?"8px 6px 10px":"10px 8px 12px"},onDragOver:Me=>{(Xe||rn.current!==null)&&Hf(b.key,Me)},onDrop:Me=>Bf(b.key,Me),children:[r.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${te?"justify-center":Ke?"justify-start":b.align==="center"?"justify-center":b.align==="right"?"justify-end":"justify-start"}`,children:[Xe?r.jsx("span",{draggable:!0,onDragStart:Me=>{Me.stopPropagation(),Of(b.key,Me)},onDragEnd:Me=>{Me.stopPropagation(),Ff()},onClick:Me=>Me.stopPropagation(),title:"Arrastrar para mover columna","aria-label":"Arrastrar para mover columna",className:`absolute left-0 top-0 z-10 inline-flex h-full w-3 shrink-0 rounded-sm transition-colors duration-150 hover:bg-[var(--primary)]/15 ${Ue?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}):null,te?r.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:r.jsx(F.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):r.jsx(Ls,{className:"min-w-0 flex-1",children:r.jsx("span",{"data-dt-autofit-content":!0,className:`inline-flex max-w-full items-center font-semibold uppercase tracking-wider ${D?"text-[11px]":"text-xs"}`,children:r.jsx("span",{className:"min-w-0 truncate",children:b.header})})}),A&&r.jsx("button",{type:"button","aria-label":`Ordenar por ${String(b.header)}`,title:"Ordenar",onClick:Me=>{Me.stopPropagation(),Pf(b)},"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 ${X?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:X?qe.dir==="asc"?r.jsx(F.HiChevronUp,{className:"h-3 w-3"}):r.jsx(F.HiChevronDown,{className:"h-3 w-3"}):r.jsx(F.HiChevronUpDown,{className:"h-3 w-3"})}),v&&!te&&Mf(b)&&r.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ge&&Or===b.key,"aria-label":`Filtrar ${String(b.header)}`,title:"Filtrar",onClick:Me=>kl(Me,"filter",b.key),className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-sm bg-transparent text-[var(--text-muted)] opacity-0 transition-[opacity,color,background-color] duration-150 hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] focus:opacity-100 group-hover:opacity-100 ${Ge&&Qe==="filter"&&Or===b.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":ge?"text-[var(--primary)] opacity-100":""}`,children:ge?r.jsx(F.HiFunnel,{className:"h-3.5 w-3.5"}):r.jsx(F.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!te&&r.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:Me=>{Me.preventDefault(),Me.stopPropagation(),en.current={colKey:b.key,startX:Me.clientX,startWidth:Xr[b.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:Me=>{Me.preventDefault(),Me.stopPropagation(),en.current=null,document.body.style.cursor="",document.body.style.userSelect="",If(b)},onClick:Me=>Me.stopPropagation(),className:"absolute top-0 flex h-full items-center justify-center opacity-0 transition-opacity duration-200 hover:opacity-100",style:{right:0,width:12,cursor:"col-resize",zIndex:6,transform:"translateX(50%)"},children:r.jsxs("span",{style:{display:"flex",gap:4,alignItems:"center",height:"calc(100% - 8px)"},children:[r.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}}),r.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}})]})})]},b.key)})]}),Jn=()=>{if(!Ge||typeof document>"u"||Qe==="visibility"&&!oe||Qe==="filter"&&!v)return null;const b=e.find(ge=>ge.key===Or),N=Ef(),X=b?Object.prototype.hasOwnProperty.call(lr,b.key):!1,A=b?wr[b.key]:void 0,te=fn.find(ge=>ge.value===(A==null?void 0:A.operator)),fe=b?lr[b.key]??[]:[],ve=tl.trim().toLowerCase(),$e=ve?N.filter(ge=>ge.label.toLowerCase().includes(ve)):N,Xe=b&&N.length>0&&(!X||fe.length===N.length),Ue=b&&X&&fe.length>0&&fe.length<N.length,tr=Pe.length,Ke=()=>{b&&(Qa(b.key),vl(b.key))};return nr.createPortal(r.jsx("div",{ref:cl,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...mf,borderColor:"var(--border)",background:"var(--bg-card)"},children:Qe==="visibility"?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[r.jsx("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:tr>0?`${ir.length} de ${e.length} visibles`:`${e.length} visibles`}),r.jsx("button",{type:"button",onClick:Df,disabled:tr===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"})]}),r.jsx("div",{className:"max-h-72 overflow-auto py-1",children:ml.map(ge=>{const Me=!Pe.includes(ge.key),ye=!(ge.hideable!==!1)||Me&&ir.length<=1;return r.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Me,disabled:ye,onClick:()=>Af(ge.key),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--text-main)"},children:[r.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Me?"var(--primary)":"var(--border)",background:Me?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Me&&r.jsx(F.HiCheck,{className:"h-3 w-3"})}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ge.header})]},ge.key)})})]}):b?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[r.jsxs("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:["Filtrar ",b.header]}),r.jsx("button",{type:"button",onClick:Ke,disabled:!X&&!A,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"})]}),b.sortKey&&r.jsxs("div",{className:"grid grid-cols-2 gap-1 border-b border-[var(--border)] p-1",children:[r.jsxs("button",{type:"button",onClick:()=>Gr({key:b.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:[r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[r.jsx(F.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),r.jsx("span",{className:"truncate",children:"Ascendente"})]}),(qe==null?void 0:qe.key)===b.key&&qe.dir==="asc"&&r.jsx(F.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),r.jsxs("button",{type:"button",onClick:()=>Gr({key:b.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:[r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 truncate",children:[r.jsx(F.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),r.jsx("span",{className:"truncate",children:"Descendente"})]}),(qe==null?void 0:qe.key)===b.key&&qe.dir==="desc"&&r.jsx(F.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]})]}),r.jsxs("div",{className:"border-b border-[var(--border)] p-2",children:[r.jsxs("div",{className:"grid grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)] gap-2",children:[r.jsx(_r,{value:(A==null?void 0:A.operator)??"",onChange:ge=>{if(!ge){vl(b.key);return}Un(b.key,{operator:ge,value:(A==null?void 0:A.value)??"",valueTo:(A==null?void 0:A.valueTo)??""})},options:Di,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"}),(te==null?void 0:te.valueMode)!=="none"?r.jsx("input",{value:(A==null?void 0:A.value)??"",onChange:ge=>{A&&Un(b.key,{...A,value:ge.target.value})},disabled:!A,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)"}}):r.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"})]}),(te==null?void 0:te.valueMode)==="between"&&r.jsx("input",{value:(A==null?void 0:A.valueTo)??"",onChange:ge=>{A&&Un(b.key,{...A,valueTo:ge.target.value})},placeholder:"Valor final",className:"mt-2 w-full rounded-md border px-2 py-1.5 text-xs outline-none transition-colors placeholder:text-[var(--text-muted)] focus:border-[var(--primary)]",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"}})]}),r.jsx("div",{className:"border-b border-[var(--border)] p-2",children:r.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:[r.jsx(F.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),r.jsx("input",{value:tl,onChange:ge=>nl(ge.target.value),placeholder:"Buscar",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-[var(--text-muted)]",style:{color:"var(--text-main)"}})]})}),r.jsxs("div",{className:"overflow-auto py-1",style:{maxHeight:"max(96px, calc(var(--dt-column-menu-max-height, 520px) - 236px))"},children:[r.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ue?"mixed":!!Xe,onClick:()=>{b&&(Xe&&!X?gl(b.key,[]):Qa(b.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:[r.jsxs("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Xe||Ue?"var(--primary)":"var(--border)",background:Xe||Ue?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[Ue&&r.jsx(F.HiMinus,{className:"h-3 w-3"}),Xe&&!Ue&&r.jsx(F.HiCheck,{className:"h-3 w-3"})]}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),$e.map(ge=>{const Me=!X||fe.includes(ge.value);return r.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Me,onClick:()=>$f(b.key,ge.value,N.map(we=>we.value),X),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:[r.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Me?"var(--primary)":"var(--border)",background:Me?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Me&&r.jsx(F.HiCheck,{className:"h-3 w-3"})}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ge.label})]},ge.value)}),$e.length===0&&r.jsx("div",{className:"px-3 py-3 text-sm text-[var(--text-muted)]",children:"Sin valores"})]})]}):null}),document.body)};s.useEffect(()=>{if(!Rt)return;function b(N){Xa.current&&!Xa.current.contains(N.target)&&zn.current&&!zn.current.contains(N.target)&&Pn(!1)}return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[Rt]);function Il(b,N){if(b.filterValue){const X=b.filterValue(N);return X==null||X===""?"":String(X)}return nt(b.cell(N))}function Ol(b){return`"${b.replace(/"/g,'""')}"`}function Rn(b){return b.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Kf(){const b=ir.filter($e=>!jr($e)),N=b.map($e=>Ol(nt($e.header))).join(","),X=Jr.map($e=>b.map(Xe=>Ol(Il(Xe,$e))).join(",")).join(`
5
- `),A=`${N}
6
- ${X}`,te=new Blob(["\uFEFF"+A],{type:"text/csv;charset=utf-8;"}),fe=URL.createObjectURL(te),ve=document.createElement("a");ve.href=fe,ve.download=`${Le}.csv`,document.body.appendChild(ve),ve.click(),document.body.removeChild(ve),URL.revokeObjectURL(fe)}function Xf(){const b=ir.filter(ve=>!jr(ve)),N=b.map(ve=>Rn(nt(ve.header))),A=Jr.map(ve=>b.map($e=>Rn(Il($e,ve)))).map(ve=>`<tr>${ve.map($e=>`<td>${$e}</td>`).join("")}</tr>`).join(""),te=`<!DOCTYPE html>
7
- <html lang="es"><head><meta charset="utf-8"><title>${Rn(Le)}</title>
1
+ (function(V,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):(V=typeof globalThis<"u"?globalThis:V||self,s(V.BonsaifUI={},V.React,V.jsxRuntime,V.ReactIconsHi2,V.ReactDOM,V.Recharts,V.OverlayScrollbarsGlobal,V.Sonner,V.OverlayScrollbarsReact,V.ReactDayPicker,V.ReactDayPickerStyles,V.ReactIconsFi))})(this,(function(V,s,t,P,nt,Ne,sa,fs,bs,oa,ab,Xl){"use strict";"use client";function $t(...e){return e.filter(Boolean).join(" ")}function Yl({variant:e="primary",className:r,type:n="button",children:a,...o}){return t.jsx("button",{className:$t("bonsaif-ui-button",`bonsaif-ui-button--${e}`,r),type:n,...o,children:a})}function ms({value:e,onChange:r,placeholder:n,className:a="",autoFocus:o=!1,forceExpanded:l=!1,onEscape:i,size:c="default",inputTabIndex:d}){const u=s.useRef(null),[m,f]=s.useState(!1),p=l||m||e.trim().length>0,x=c==="sm"?"h-9 rounded-md":"h-10 rounded-lg",w=a||"w-48 max-w-full sm:w-64 lg:w-72";s.useEffect(()=>{var h;o&&((h=u.current)==null||h.focus())},[o]);const T=()=>{var h;f(!0),(h=u.current)==null||h.focus()};return t.jsxs("div",{className:`relative min-w-0 max-w-full flex-shrink-0 overflow-visible transition-[width] duration-200 ease-out ${p?w:"w-24 sm:w-28"}`,onMouseDown:h=>{p||(h.preventDefault(),T())},children:[t.jsx(P.HiMagnifyingGlass,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none transition-colors duration-200",style:{color:"var(--text-muted)",left:"var(--page-header-control-icon-left, 12px)"}}),t.jsx("input",{ref:u,type:"text",tabIndex:d,"aria-label":n,value:e,onChange:h=>r(h.target.value),onKeyDown:h=>{h.key==="Escape"&&(i==null||i())},placeholder:p?n:"Buscar",className:`${x} w-full py-0 text-sm leading-none placeholder:text-[var(--text-muted)] focus:outline-none transition-all duration-200 ${p?"pl-9 pr-8":"cursor-pointer pl-9 pr-3"}`,style:{height:`var(--page-header-control-height, ${c==="sm"?"36px":"40px"})`,paddingLeft:"calc(var(--page-header-control-icon-left, 12px) + 24px)",paddingRight:p?"calc(var(--page-header-control-padding-x, 14px) + 18px)":"var(--page-header-control-padding-x, 14px)",background:"color-mix(in srgb, var(--bg-card) 86%, transparent)",border:"1px solid var(--border)",color:"var(--text-main)"},onFocus:h=>{f(!0),h.currentTarget.style.borderColor="var(--primary)",h.currentTarget.style.boxShadow="0 0 0 3px rgba(59,130,246,0.12)"},onBlur:h=>{f(!1),h.currentTarget.style.borderColor="var(--border)",h.currentTarget.style.boxShadow="none"}}),e&&t.jsx("button",{type:"button",onClick:()=>r(""),className:"absolute right-2 top-1/2 flex !h-6 !w-6 -translate-y-1/2 items-center justify-center rounded-full !p-0 leading-none transition-colors hover:bg-black/5",style:{color:"var(--text-muted)",right:"var(--page-header-control-padding-x, 8px)"},"aria-label":"Limpiar búsqueda",children:t.jsx(P.HiXMark,{className:"h-3.5 w-3.5 flex-shrink-0"})})]})}const ps=s.createContext({});let hs=0;const gs="bonsaif-ui:hide-tooltips";function sn(e=700){hs=Date.now()+e}function Kl(){return Date.now()>hs}function on(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 Gl(e){var a;const r=Array.from(e.querySelectorAll("*")).filter(o=>{var l;return o.scrollWidth>o.clientWidth&&!!((l=o.textContent)!=null&&l.trim())&&o.tagName.toLowerCase()!=="svg"&&!o.closest("svg")});return(e.scrollWidth>e.clientWidth||r.length>0)&&(((a=r[0])==null?void 0:a.textContent)??e.textContent??"").trim()||null}function _t({children:e,content:r,onlyWhenOverflow:n=!1,interactive:a=!1,followCursor:o=!0,placement:l="bottom",showArrow:i=!1,className:c="",tooltipClassName:d="",style:u,tooltipStyle:m,as:f="div"}){const p=s.useRef(null),x=s.useRef(null),w=s.useRef(null),T=s.useRef(!1),[h,E]=s.useState(null),[$,v]=s.useState("");s.useEffect(()=>{const M=p.current;M&&(M.querySelectorAll("[title]").forEach(J=>{const H=J.getAttribute("title");H&&(J.getAttribute("aria-label")||J.setAttribute("aria-label",H),J.removeAttribute("title"))}),M.querySelectorAll("svg title").forEach(J=>J.remove()))}),s.useLayoutEffect(()=>{if(!h)return;const M=x.current;if(!M)return;const J=12,H=14,ne=M.getBoundingClientRect(),X=window.innerWidth-ne.width-J,W=window.innerHeight-ne.height-J;let q=h.mouseX+H,I=h.mouseY+H,oe,B;if(!o&&p.current){const O=p.current.getBoundingClientRect(),le=O.left+O.width/2,g=O.top+O.height/2;l==="top"?(q=le-ne.width/2,I=O.top-ne.height-H,B=ne.height-1):l==="left"?(q=O.left-ne.width-H,I=g-ne.height/2,oe=ne.width-1):l==="right"?(q=O.right+H,I=g-ne.height/2,oe=-7):(q=le-ne.width/2,I=O.bottom+H,B=-7)}if(o&&(q>X&&(q=h.mouseX-ne.width-H),I>W&&(I=h.mouseY-ne.height-H)),q=Math.min(Math.max(J,q),Math.max(J,X)),I=Math.min(Math.max(J,I),Math.max(J,W)),!o&&p.current){const O=p.current.getBoundingClientRect(),le=O.left+O.width/2,g=O.top+O.height/2;l==="top"||l==="bottom"?oe=Math.min(Math.max(14,le-q),ne.width-14):B=Math.min(Math.max(14,g-I),ne.height-14)}(Math.abs(q-h.x)>.5||Math.abs(I-h.y)>.5||oe!==h.arrowX||B!==h.arrowY)&&E(O=>O&&{...O,x:q,y:I,arrowX:oe,arrowY:B})},[o,l,h]);const y=()=>{w.current&&(window.clearTimeout(w.current),w.current=null)},k=(M,J)=>{if(!Kl()||T.current)return;const H=p.current;if(H&&!on(H)){if(n){const ne=Gl(H);if(!ne)return;v(ne)}!n&&!r||E({mouseX:M,mouseY:J,x:M+14,y:J+14})}},S=()=>{const M=p.current;if(!M)return;const J=M.getBoundingClientRect();k(J.left+J.width/2,J.bottom)},A=()=>{y(),E(null)},C=()=>{if(!a){A();return}y(),w.current=window.setTimeout(()=>E(null),120)},U=()=>{sn(),T.current=!0,A()},z=()=>{T.current=!1};s.useEffect(()=>{if(!h)return;if(on(p.current)){E(null);return}const M=()=>E(null),J=()=>{sn(),T.current=!0,E(null)};document.addEventListener("pointerdown",J,!0),document.addEventListener("click",J,!0),document.addEventListener("scroll",M,!0),window.addEventListener("blur",M),document.addEventListener("visibilitychange",M),document.addEventListener("keydown",M,!0);const H=new MutationObserver(()=>{on(p.current)&&E(null)});return H.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",M,!0),window.removeEventListener("blur",M),document.removeEventListener("visibilitychange",M),document.removeEventListener("keydown",M,!0),H.disconnect()}},[h]),s.useEffect(()=>{const M=()=>sn(),J=()=>{sn(),T.current=!0,E(null)};return document.addEventListener("pointerdown",M,!0),document.addEventListener("click",M,!0),document.addEventListener("keydown",M,!0),window.addEventListener(gs,J),()=>{document.removeEventListener("pointerdown",M,!0),document.removeEventListener("click",M,!0),document.removeEventListener("keydown",M,!0),window.removeEventListener(gs,J)}},[]);const Y=n?$:r;return t.jsxs(t.Fragment,{children:[t.jsx(f,{ref:M=>{p.current=M},className:c,style:u,onMouseEnter:M=>{y(),z(),o?k(M.clientX,M.clientY):S()},onMouseMove:M=>{h&&o&&k(M.clientX,M.clientY)},onMouseDown:U,onClick:U,onMouseLeave:()=>{z(),C()},onFocus:S,onBlur:A,children:e}),h&&Y&&!on(p.current)?nt.createPortal(t.jsxs("div",{ref:x,role:"tooltip",className:d,onMouseEnter:a?y:void 0,onMouseLeave:a?C:void 0,style:{position:"fixed",top:h.y,left:h.x,zIndex:9999,background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:6,padding:"5px 10px",fontSize:12,color:"var(--text-main)",boxShadow:"0 4px 16px rgba(0,0,0,0.35)",pointerEvents:a?"auto":"none",maxWidth:"min(420px, calc(100vw - 24px))",whiteSpace:"normal",lineHeight:1.6,overflowWrap:"anywhere",...m},children:[i&&t.jsx("span",{"aria-hidden":"true",style:{position:"absolute",width:12,height:12,background:(m==null?void 0:m.background)??"var(--bg-card)",borderLeft:l==="right"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderTop:l==="bottom"||l==="right"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderRight:l==="left"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,borderBottom:l==="top"||l==="left"?(m==null?void 0:m.border)??"1px solid var(--border)":void 0,transform:"rotate(45deg)",left:h.arrowX===void 0?void 0:h.arrowX-6,top:h.arrowY===void 0?void 0:h.arrowY-6,zIndex:-1}}),Y]}),document.body):null]})}function vs(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}const Zl="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",Ql={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"},Jl="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",Rl={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"},ei={xs:"h-8 w-8",sm:"h-9 w-9",md:"h-10 w-10",lg:"h-10 w-10"},ti={primary:{background:"var(--bg-card)"},secondary:{background:"var(--bg-card)"},danger:{background:"var(--bg-card)"},ghost:{},icon:{}};function la(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(la).join(" ").trim():s.isValidElement(e)?la(e.props.children):""}function ri(e){return s.Children.toArray(e).find(s.isValidElement)??null}function je({variant:e="primary",size:r="md",loading:n=!1,icon:a,tooltip:o,iconOnly:l,height:i,padding:c,children:d,className:u="",disabled:m,style:f,...p}){const x=s.useContext(ps),w=l??x.iconOnly??e==="icon",T=x.compact??!1,h=x.headerAction??!1,E=h&&r==="md"?"sm":T&&!h&&r==="md"?"xs":r,$=e==="icon"||w,v=h&&$,y=la(d),k=o??p.title??p["aria-label"]??(w?y:void 0),S=k?void 0:p.title,A=p["aria-label"]??(typeof k=="string"?k:y||void 0),C=n?null:a??(w?ri(d):null),U=t.jsxs("button",{...p,title:S,"aria-label":A,"data-variant":e,"data-size":E,"data-icon":$?"true":void 0,disabled:m||n,className:`${Zl} ${v?Jl:Ql[e]} ${$?ei[E]:Rl[E]} ${T&&!$?"px-2.5":""} ${u}`,style:{...ti[e],height:vs(i),padding:vs(c),...f,...h&&!$?{height:"var(--page-header-control-height, 34px)",padding:"0 var(--page-header-control-padding-x, 10px)",borderRadius:"8px"}:null,...v?{width:"var(--page-header-control-height, 40px)",height:"var(--page-header-control-height, 40px)",padding:0,background:"var(--bg-card)",borderRadius:"8px"}:null},children:[n?t.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):C,!w&&d]});return k?t.jsx(_t,{as:"span",content:k,className:"inline-flex shrink-0",children:U}):U}const tt={background:"color-mix(in srgb, var(--text-muted) 26%, var(--bg-input))"};function ln({rows:e=8,columns:r=7,showToolbar:n=!0,showPagination:a=!0,compact:o=!1,className:l=""}){const i=Math.max(3,Math.min(r,12)),c=Math.max(3,Math.min(e,20)),d=o?"px-2 py-2":"px-3 py-2.5",u=o?"px-2 py-2":"px-3 py-3";return t.jsxs("div",{className:`w-full min-w-0 overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${l}`,"aria-busy":"true","aria-label":"Cargando tabla",children:[n&&t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-3 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("div",{className:"h-7 w-14 shrink-0 animate-pulse rounded-md",style:tt}),t.jsx("div",{className:"h-7 max-w-md flex-1 animate-pulse rounded-md",style:tt})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:tt}),t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:tt})]})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("div",{className:"min-w-full",style:{display:"grid",gridTemplateColumns:`repeat(${i}, minmax(96px, 1fr))`},children:[Array.from({length:i}).map((m,f)=>t.jsx("div",{className:`${u} border-b border-[var(--border)]`,style:{background:"color-mix(in srgb, var(--bg-input) 55%, transparent)"},children:t.jsx("div",{className:"h-3 animate-pulse rounded-md",style:{...tt,width:`${48+f*17%40}%`}})},`h-${f}`)),Array.from({length:c}).map((m,f)=>Array.from({length:i}).map((p,x)=>t.jsx("div",{className:`${d} ${f<c-1?"border-b border-[var(--border)]":""}`,children:t.jsx("div",{className:"h-3.5 animate-pulse rounded-md",style:{...tt,width:`${46+(f*13+x*11)%42}%`,minWidth:28}})},`c-${f}-${x}`)))]})}),a&&t.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-[var(--border)] px-3 py-2",style:{background:"color-mix(in srgb, var(--bg-input) 40%, transparent)"},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"h-3 w-28 animate-pulse rounded-md",style:tt}),t.jsx("div",{className:"h-7 w-14 animate-pulse rounded-md",style:tt})]}),t.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:4}).map((m,f)=>t.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md",style:tt},f))}),t.jsx("div",{className:"h-3 w-16 animate-pulse rounded-md",style:tt})]})]})}function ni({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 ai({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 ys({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(ln,{rows:i,columns:c,className:u});if(e==="sections")return t.jsx(si,{rows:i});if(e==="cards")return t.jsx(oi,{rows:i});const m=o||(typeof r=="string"?r:"Aplicación"),f=l==="bare",p=t.jsxs("div",{className:`flex flex-col items-center text-center ${f?"gap-5":"gap-3"}`,children:[a?t.jsx(ai,{logoSrc:a,logoAlt:m}):null,t.jsx(ni,{size:f?"md":"sm"}),t.jsxs("div",{className:f?"space-y-1.5":"",children:[t.jsx("p",{className:f?"text-base font-semibold tracking-tight text-[var(--text-main)]":"text-sm font-semibold text-[var(--text-main)]",children:r}),n?t.jsx("p",{className:f?"text-sm font-medium text-[var(--text-muted)]":"mt-1 text-xs text-[var(--text-muted)]",children:n}):null,d&&t.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:d})]})]});return f?t.jsx("div",{className:`flex min-h-[240px] w-full items-center justify-center p-8 ${u}`,role:"status","aria-live":"polite","aria-busy":"true",children:p}):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:p})}function si({rows:e}){return t.jsx(ln,{rows:e,columns:7})}function oi({rows:e}){return t.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:Array.from({length:e}).map((r,n)=>t.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[t.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded-md",style:tt}),t.jsx("div",{className:"mt-3 h-3 w-full animate-pulse rounded-md",style:tt}),t.jsx("div",{className:"mt-2 h-3 w-4/5 animate-pulse rounded-md",style:tt})]},n))})}function xs(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 ws(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function li(e){return[e.label,xs(e.service),e.description,e.service].filter(Boolean).join(" ")}function ii(e){return typeof e=="function"?e:e.default}function ci(e,r){return t.jsx("div",{className:"flex min-h-[220px] items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-6 text-center",children:t.jsxs("div",{className:"max-w-md",children:[t.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:"No se pudo cargar este modulo"}),t.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:e.message}),t.jsx(je,{className:"mt-4",height:36,padding:"0 14px",onClick:r,children:"Reintentar"})]})})}function di({parentPanel:e,parentPanelComponent:r,renderParentPanel:n,parent:a,context:o,links:l,moduleRegistry:i,loadModule:c,activeService:d,initialService:u,onActiveServiceChange:m,canAccess:f,keepAlive:p=!0,title:x,subtitle:w,emptyState:T,loadingState:h,errorState:E=ci,renderTabLabel:$,searchableTabs:v="auto",tabsSearchThreshold:y=6,tabsSearchPlaceholder:k="Buscar modulo...",tabsSearchValue:S,onTabsSearchChange:A,emptySearchState:C,showTabCount:U=!0,className:z="",parentClassName:Y="",contentClassName:M="",tabsClassName:J=""}){var et;const H=s.useMemo(()=>l.filter(me=>!me.hidden&&((f==null?void 0:f(me,o))??!0)),[f,o,l]),ne=(et=H.find(me=>!me.disabled))==null?void 0:et.service,[X,W]=s.useState(u??ne??""),[q,I]=s.useState({}),[oe,B]=s.useState({}),[O,le]=s.useState(""),[g,_]=s.useState(!1),ee=s.useRef(oe),ae=s.useRef(0),j=S??O,K=ws(j),L=v===!0||v==="auto"&&H.length>=y,R=L&&j.trim().length>0,F=s.useMemo(()=>K?H.filter(me=>ws(li(me)).includes(K)):H,[K,H]),se=d??X,G=H.find(me=>me.service===se)??H.find(me=>!me.disabled);s.useEffect(()=>{!G&&ne&&W(ne)},[ne,G]),s.useEffect(()=>{ee.current=oe},[oe]);const de=me=>{me.disabled||(d||W(me.service),m==null||m(me.service,me))},Se=me=>{S===void 0&&le(me),A==null||A(me)},ie=(me,Z)=>{const te=F.filter(he=>!he.disabled),be=te.findIndex(he=>he.service===Z.service);be<0||((me.key==="ArrowRight"||me.key==="ArrowDown")&&(me.preventDefault(),de(te[(be+1)%te.length])),(me.key==="ArrowLeft"||me.key==="ArrowUp")&&(me.preventDefault(),de(te[(be-1+te.length)%te.length])),me.key==="Home"&&(me.preventDefault(),de(te[0])),me.key==="End"&&(me.preventDefault(),de(te[te.length-1])))},pe=s.useCallback(()=>{if(!G)return;const me=G.service,Z=ee.current[me];if(Z!=null&&Z.loading||Z!=null&&Z.component&&p)return;const te=(i==null?void 0:i[me])??c;if(!te){B(he=>({...he,[me]:{loading:!1,error:new Error(`No module loader found for service "${me}".`)}}));return}const be=++ae.current;B(he=>({...he,[me]:{...he[me],loading:!0,error:void 0}})),te(G,o).then(he=>{if(be!==ae.current&&!p)return;const Be=ii(he);B($e=>({...$e,[me]:{component:Be,loading:!1}}))}).catch(he=>{const Be=he instanceof Error?he:new Error(String(he));B($e=>({...$e,[me]:{...$e[me],loading:!1,error:Be}}))})},[o,p,c,i,G]);s.useEffect(pe,[pe]);const Ce=G?q[G.service]??null:null,De=G?oe[G.service]:void 0,mt=De==null?void 0:De.component,xt=me=>{G&&I(Z=>({...Z,[G.service]:me}))},We=()=>{G&&I(me=>({...me,[G.service]:null}))},Ae={context:o,parent:a,links:l,visibleLinks:H,filteredLinks:F,selectedLink:G,selectedService:G==null?void 0:G.service,activeItemId:Ce,tabsSearch:j,onSelectService:de,onOpenDetail:xt,onBackToList:We},ke=n?n(Ae):r?t.jsx(r,{...Ae}):e;return t.jsxs("section",{className:`grid min-h-[520px] gap-4 lg:grid-cols-[minmax(260px,360px)_minmax(0,1fr)] ${z}`,children:[t.jsx("aside",{className:`min-w-0 rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-4 ${Y}`,children:ke}),t.jsxs("div",{className:`relative min-w-0 overflow-visible rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${M}`,children:[(x||w||L||U)&&t.jsx("div",{className:"relative border-b border-[var(--border)] px-4 py-3",children:t.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[x&&t.jsx("h2",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:x}),w&&t.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-[var(--text-muted)]",children:w})]}),(L||U)&&t.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center justify-end gap-2",children:[U&&t.jsxs("span",{className:"hidden text-xs font-semibold text-[var(--text-muted)] transition-opacity duration-200 sm:inline",children:[F.length," / ",H.length]}),L&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`origin-right overflow-hidden transition-[width,opacity,transform] duration-200 ease-out ${g?"w-[min(20rem,44vw)] translate-x-0 opacity-100":"w-0 translate-x-2 opacity-0"}`,"aria-hidden":!g,children:t.jsx(ms,{value:j,onChange:Se,placeholder:k,className:"w-full",autoFocus:g,forceExpanded:!0,onEscape:()=>_(!1),size:"sm",inputTabIndex:g?0:-1})}),t.jsx("button",{type:"button","aria-label":g?"Cerrar busqueda":"Buscar tabs","aria-expanded":g,onClick:()=>{g&&j&&Se(""),_(me=>!me)},className:`inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border transition-all duration-200 hover:scale-[1.03] active:scale-95 ${g||R?"border-[var(--primary)] bg-[var(--bg-input)] text-[var(--text-main)] shadow-sm":"border-[var(--border)] text-[var(--text-muted)] hover:bg-[var(--bg-input)] hover:text-[var(--text-main)]"}`,children:t.jsx("span",{className:"grid h-4 w-4 place-items-center transition-transform duration-200",children:g||R?t.jsx(P.HiXMark,{className:"h-4 w-4"}):t.jsx(P.HiMagnifyingGlass,{className:"h-4 w-4"})})})]})]})]})}),t.jsx("div",{role:"tablist","aria-label":x??"Modulos relacionados",className:`flex gap-1 overflow-x-auto border-b border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 transition-colors duration-200 ${J}`,children:F.length>0?F.map(me=>{const Z=me.service===(G==null?void 0:G.service);return t.jsx("button",{type:"button",role:"tab","aria-selected":Z,disabled:me.disabled,onClick:()=>de(me),onKeyDown:te=>ie(te,me),className:`inline-flex h-9 min-w-max items-center gap-2 rounded-md border px-3 text-xs font-semibold transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-50 ${Z?"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:$?$(me,Z):t.jsxs(t.Fragment,{children:[me.icon,t.jsx("span",{children:me.label??xs(me.service)}),me.badge&&t.jsx("span",{className:"rounded-full bg-[var(--bg-input)] px-1.5 py-0.5 text-[10px] text-[var(--text-muted)]",children:me.badge})]})},me.service)}):t.jsx("div",{className:"flex min-h-9 flex-1 items-center rounded-md border border-dashed border-[var(--border)] px-3 text-xs text-[var(--text-muted)]",children:C??"No hay modulos que coincidan con la busqueda."})}),(G==null?void 0:G.description)&&t.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 text-xs text-[var(--text-muted)]",children:G.description}),t.jsxs("div",{className:"min-h-[420px] p-4",children:[!G&&(T??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."})),G&&(De==null?void 0:De.loading)&&(h??t.jsx(ys,{title:"Cargando modulo..."})),G&&(De==null?void 0:De.error)&&E(De.error,pe),G&&mt&&!(De!=null&&De.loading)&&!(De!=null&&De.error)&&t.jsx(mt,{context:o,parent:a,link:G,activeItemId:Ce,onOpenDetail:xt,onBackToList:We})]})]})]})}const ui={info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.1)",border:"rgba(59, 130, 246, 0.24)",icon:t.jsx(P.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(P.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(P.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(P.HiExclamationCircle,{className:"h-5 w-5"})},neutral:{color:"var(--text-secondary)",background:"var(--bg-input)",border:"var(--border)",icon:t.jsx(P.HiInformationCircle,{className:"h-5 w-5"})}};function fi({variant:e="info",title:r,children:n,icon:a,action:o,onDismiss:l,className:i=""}){const c=ui[e];return t.jsxs("div",{role:e==="danger"||e==="warning"?"alert":"status",className:`flex items-start gap-3 rounded-lg border px-3 py-3 ${i}`,style:{background:c.background,borderColor:c.border},children:[t.jsx("div",{className:"mt-0.5 shrink-0",style:{color:c.color},children:a??c.icon}),t.jsxs("div",{className:"min-w-0 flex-1",children:[r&&t.jsx("div",{className:"text-sm font-semibold text-[var(--text-main)]",children:r}),n&&t.jsx("div",{className:"mt-0.5 text-sm leading-5 text-[var(--text-secondary)]",children:n}),o&&t.jsx("div",{className:"mt-3",children:o})]}),l&&t.jsx(je,{variant:"icon",size:"xs","aria-label":"Cerrar alerta",onClick:l,className:"-mr-1 -mt-1",children:t.jsx(P.HiXMark,{className:"h-4 w-4"})})]})}const ks=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],bi=["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],mi=["lu","ma","mi","ju","vi","sá","do"],Ns=6;function ia(e,r,n){return`${e}-${String(r).padStart(2,"0")}-${String(n).padStart(2,"0")}`}function pi(){const e=new Date;return ia(e.getFullYear(),e.getMonth()+1,e.getDate())}function Ss(e){const[r,n,a]=e.split("-").map(Number);return{year:r,month:n,day:a}}function hi(e){if(!e)return"Seleccionar fecha";const{year:r,month:n,day:a}=Ss(e);return!r||!n||!a?"Seleccionar fecha":`${String(a).padStart(2,"0")} ${ks[n-1]} ${r}`}function gi({value:e,onChange:r,minDate:n,displayMode:a="inline",className:o=""}){const l=pi(),c=Ss(e||l),d=a==="popover",[u,m]=s.useState(!1),f=s.useRef(null),[p,x]=s.useState({horizontal:"left",vertical:"bottom"}),[w,T]=s.useState(c.year),[h,E]=s.useState(c.month),[$,v]=s.useState("days"),y=16,[k,S]=s.useState(0),A=w-7+k,C=Array.from({length:y},(W,q)=>A+q);s.useEffect(()=>{if(!d||!u||!f.current)return;const W=f.current.getBoundingClientRect(),q=8,I=280,oe=340,B=W.left+I>window.innerWidth-q,O=W.right-I>=q,le=W.bottom+8+oe>window.innerHeight-q,g=W.top-8-oe>=q;x({horizontal:B&&O?"right":"left",vertical:le&&g?"top":"bottom"})},[d,u]),s.useEffect(()=>{if(!d||!u)return;function W(I){f.current&&(f.current.contains(I.target)||m(!1))}function q(I){I.key==="Escape"&&m(!1)}return document.addEventListener("mousedown",W),document.addEventListener("keydown",q),()=>{document.removeEventListener("mousedown",W),document.removeEventListener("keydown",q)}},[d,u]);function U(){h===1?(T(W=>W-1),E(12)):E(W=>W-1)}function z(){h===12?(T(W=>W+1),E(1)):E(W=>W+1)}const Y=(new Date(w,h-1,1).getDay()+6)%7,M=new Date(w,h,0).getDate(),J=[...Array(Y).fill(null),...Array.from({length:M},(W,q)=>q+1)];for(;J.length<Ns*7;)J.push(null);const H=J.slice(0,Ns*7);function ne(W){const q=ia(w,h,W);n&&q<n||(r(q),d&&m(!1))}const X=t.jsx("div",{className:`bonsaif-calendar bonsaif-calendar-picker ${o}`.trim(),children:t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsx("div",{className:"bonsaif-cal-toolbar",children:$==="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(P.HiChevronLeft,{size:16})}),t.jsxs("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>{v("years"),S(0)},children:[t.jsxs("span",{className:"bonsaif-cal-title",children:[ks[h-1]," ",w]}),t.jsx(P.HiChevronDown,{size:13})]}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:z,"aria-label":"Mes siguiente",children:t.jsx(P.HiChevronRight,{size:16})})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>S(W=>W-y),"aria-label":"Años anteriores",children:t.jsx(P.HiChevronLeft,{size:16})}),t.jsx("button",{type:"button",className:"bonsaif-cal-title-btn",onClick:()=>v("days"),children:t.jsxs("span",{className:"bonsaif-cal-title",children:[C[0]," – ",C[C.length-1]]})}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn",onClick:()=>S(W=>W+y),"aria-label":"Años siguientes",children:t.jsx(P.HiChevronRight,{size:16})})]})}),$==="years"?t.jsxs("div",{className:"bonsaif-cal-picker-years",children:[t.jsx("div",{className:"bonsaif-cal-picker-months",children:bi.map((W,q)=>{const I=q+1===h;return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${I?" is-active":""}`,onClick:()=>E(q+1),children:W},W)})}),t.jsx("div",{className:"bonsaif-cal-picker-year-grid",children:C.map(W=>{const q=W===w,I=W===new Date().getFullYear();return t.jsx("button",{type:"button",className:`bonsaif-cal-pill-btn${q?" is-active":""}${I&&!q?" is-today":""}`,onClick:()=>{T(W),v("days")},children:W},W)})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bonsaif-multi-weekdays bonsaif-cal-picker-weekdays",children:mi.map(W=>t.jsx("div",{className:"bonsaif-multi-weekday",children:W},W))}),t.jsx("div",{className:"bonsaif-cal-picker-days",children:H.map((W,q)=>{if(W===null)return t.jsx("div",{className:"bonsaif-multi-day bonsaif-multi-day-hidden"},q);const I=ia(w,h,W),oe=I===e,B=I===l,O=!!(n&&I<n);return t.jsx("div",{className:`bonsaif-multi-day${oe?" bonsaif-multi-day-selected":""}${B?" bonsaif-multi-day-today":""}${O?" bonsaif-multi-day-disabled":""}`,children:t.jsx("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:O,"aria-pressed":oe,onClick:()=>!O&&ne(W),children:W})},q)})})]})]})});return d?t.jsxs("div",{ref:f,className:`relative w-full ${o}`.trim(),children:[t.jsxs("button",{type:"button",onClick:()=>m(W=>!W),className:"bonsaif-cal-trigger","data-open":u?"true":"false",children:[t.jsxs("span",{className:"inline-flex items-center gap-2 min-w-0",children:[t.jsx(P.HiCalendarDays,{className:"w-4 h-4 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:hi(e)})]}),t.jsx(P.HiChevronDown,{className:`w-4 h-4 text-[var(--text-muted)] transition-transform ${u?"rotate-180":""}`})]}),u&&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:X})]}):X}const vi={sm:"h-4 w-4",md:"h-5 w-5"};function yi(e,r){if(typeof e=="function"){e(r);return}e&&(e.current=r)}const cn=s.forwardRef(function({label:r,description:n,error:a,size:o="md",indeterminate:l=!1,className:i="",containerClassName:c="",disabled:d,...u},m){const f=s.useRef(null);return s.useEffect(()=>{f.current&&(f.current.indeterminate=l)},[l]),t.jsxs("label",{className:`group inline-flex items-start gap-2.5 ${d?"cursor-not-allowed opacity-60":"cursor-pointer"} ${c}`,children:[t.jsxs("span",{className:"relative mt-0.5 inline-flex shrink-0",children:[t.jsx("input",{...u,ref:p=>{f.current=p,yi(m,p)},type:"checkbox",disabled:d,"aria-checked":l?"mixed":u["aria-checked"],"aria-invalid":!!a||u["aria-invalid"],className:`peer ${vi[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(P.HiCheck,{className:"pointer-events-none absolute left-1/2 top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 scale-75 text-[var(--primary-fg)] opacity-0 transition peer-checked:scale-100 peer-checked:opacity-100 peer-aria-checked:mixed:scale-100 peer-aria-checked:mixed:opacity-100"})]}),(r||n||a)&&t.jsxs("span",{className:"min-w-0",children:[r&&t.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:r}),n&&!a&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:n}),a&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--danger)]",children:a})]})]})});function Cs(e){const r=document.createElement("textarea");r.value=e,r.style.position="fixed",r.style.opacity="0",r.style.pointerEvents="none",document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r)}async function xi(e){var r;if((r=navigator.clipboard)!=null&&r.writeText){await navigator.clipboard.writeText(e);return}Cs(e)}function wi(e){return typeof e=="function"?e():e}function ca({value:e,resetDelay:r=2e3,title:n,copiedTitle:a="Copiado",copiedLabel:o,icon:l=t.jsx(P.HiClipboardDocument,{size:14}),copiedIcon:i=t.jsx(P.HiCheck,{size:14}),stopPropagation:c=!0,onCopied:d,onCopyError:u,className:m="",style:f,children:p,onClick:x,type:w="button",...T}){const[h,E]=s.useState(!1),$=s.useRef(null);s.useEffect(()=>()=>{$.current&&window.clearTimeout($.current)},[]);function v(k){E(!0),d==null||d(k),$.current&&window.clearTimeout($.current),$.current=window.setTimeout(()=>{E(!1),$.current=null},r)}async function y(k){var A;if(c&&k.stopPropagation(),x==null||x(k),k.defaultPrevented)return;const S=wi(e);if(S)try{await xi(S),v(S)}catch(C){try{Cs(S),v(S)}catch(U){u==null||u(U,S);return}(A=navigator.clipboard)!=null&&A.writeText||u==null||u(C,S)}}return t.jsxs("button",{...T,type:w,onClick:y,title:h?a:n,"aria-label":T["aria-label"]??(h?a:n),"data-copied":h?"true":void 0,className:`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-md transition-all duration-200 ${p?"min-w-7 px-2":"w-7"} ${m}`,style:{cursor:"pointer",background:h?"rgba(22,163,74,0.15)":"var(--bg-card)",border:h?"1px solid rgba(22,163,74,0.4)":"1px solid var(--border)",color:h?"#16a34a":"var(--text-secondary)",boxShadow:h?"0 0 0 3px rgba(22,163,74,0.12)":"none",...f},children:[t.jsx("span",{className:"inline-flex items-center justify-center transition-all duration-150",style:{transform:h?"scale(1.15)":"scale(1)"},children:h?i:l}),p&&t.jsx("span",{className:"text-xs font-semibold leading-none",children:h?o??p:p})]})}function ki({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(ca,{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 da(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function ua(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Ni(e,r){if(!r.trim())return!0;const n=ua(r);return ua(e.label).includes(n)||!!(e.sublabel&&ua(e.sublabel).includes(n))}function zt({value:e,onChange:r,options:n,status:a="default",ariaLabel:o,triggerVariant:l="default",showSelectedSublabel:i=!0,placeholder:c="Seleccionar…",emptyLabel:d,disabled:u=!1,className:m="",style:f,dropdownMinWidth:p,height:x=40,padding:w="0 10px",searchable:T=!0,minOptionsForSearch:h=6}){const[E,$]=s.useState(!1),[v,y]=s.useState(""),[k,S]=s.useState(-1),[A,C]=s.useState(!1),[U,z]=s.useState({}),Y=s.useRef(null),M=s.useRef(null),J=s.useRef(null),H=s.useRef(null),ne=T&&n.length>=h,X=n.find(j=>j.value===e)??null,W=l==="ghost",q=a==="error"?"var(--danger)":E?"var(--primary)":"var(--border)",I=ne&&v.trim()?n.filter(j=>Ni(j,v)):n,oe=s.useCallback(()=>{const j=Y.current;if(!j)return;const K=j.getBoundingClientRect(),L=ne?272:212,R=window.innerHeight-K.bottom,F=R<L&&K.top>R;z({position:"fixed",left:K.left,top:F?void 0:K.bottom+4,bottom:F?window.innerHeight-K.top+4:void 0,width:K.width,minWidth:da(p),zIndex:9999})},[p,ne]);s.useEffect(()=>C(!0),[]),s.useEffect(()=>{if(!E)return;function j(K){var R,F;const L=K.target;!((R=Y.current)!=null&&R.contains(L))&&!((F=M.current)!=null&&F.contains(L))&&($(!1),y(""))}return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[E]),s.useEffect(()=>{E&&(S(-1),oe(),ne&&setTimeout(()=>{var j;return(j=J.current)==null?void 0:j.focus()},0))},[E,ne,oe]),s.useEffect(()=>{if(E)return window.addEventListener("resize",oe),window.addEventListener("scroll",oe,!0),()=>{window.removeEventListener("resize",oe),window.removeEventListener("scroll",oe,!0)}},[E,oe]),s.useEffect(()=>{if(k<0||!H.current)return;const j=H.current.children[k];j==null||j.scrollIntoView({block:"nearest"})},[k]);const B=s.useCallback(j=>{r(j),$(!1),y("")},[r]),O=s.useRef(E);O.current=E;const le=s.useRef(I);le.current=I;const g=s.useRef(k);g.current=k;const _=s.useRef(d);_.current=d;const ee=s.useRef(B);ee.current=B,s.useEffect(()=>{function j(K){var se,G;const L=document.activeElement,R=((se=Y.current)==null?void 0:se.contains(L))??!1,F=((G=M.current)==null?void 0:G.contains(L))??!1;if(!(!R&&!F)){if(!O.current){(K.key==="Enter"||K.key===" "||K.key==="ArrowDown")&&(K.preventDefault(),$(!0));return}switch(K.key){case"ArrowDown":K.preventDefault(),S(de=>Math.min(de+1,le.current.length-1));break;case"ArrowUp":K.preventDefault(),S(de=>Math.max(de-1,_.current?-1:0));break;case"Enter":{K.preventDefault();const de=g.current,Se=le.current;de===-1&&_.current?ee.current(""):Se[de]&&!Se[de].disabled&&ee.current(Se[de].value);break}case"Escape":K.preventDefault(),K.stopPropagation(),$(!1),y("");break}}}return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[]);const ae=t.jsxs("div",{ref:M,"data-bonsaif-select-dropdown":"true",className:"rounded-xl shadow-xl overflow-hidden",style:{...U,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[ne&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(P.HiMagnifyingGlass,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:J,value:v,onChange:j=>{y(j.target.value),S(-1)},placeholder:"Buscar…",className:"min-w-0 flex-1 text-sm bg-transparent outline-none",style:{color:"var(--text-main)"}}),v&&t.jsx("button",{type:"button",onMouseDown:j=>{j.preventDefault(),y("")},children:t.jsx(P.HiXMark,{className:"w-3.5 h-3.5",style:{color:"var(--text-muted)"}})})]}),t.jsxs("ul",{ref:H,role:"listbox",className:"overflow-y-auto",style:{maxHeight:ne?220:180,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[d&&t.jsx("li",{role:"option","aria-selected":e==="",onMouseDown:j=>{j.preventDefault(),B("")},onMouseEnter:()=>S(-1),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:k===-1&&!v.trim()?"var(--bg-hover)":"transparent",color:"var(--text-muted)",fontStyle:"italic"},children:d}),I.map((j,K)=>{const R=K===k,F=j.value===e;return t.jsxs("li",{role:"option","aria-selected":F,onMouseDown:se=>{se.preventDefault(),j.disabled||B(j.value)},onMouseEnter:()=>!j.disabled&&S(K),className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm transition-colors",style:{background:R?"var(--bg-hover)":F?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:j.disabled?"var(--text-muted)":"var(--text-main)",cursor:j.disabled?"not-allowed":"pointer",boxShadow:F?"inset 2px 0 0 var(--primary)":void 0},children:[j.color&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:j.color}}),t.jsxs("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx("span",{className:"truncate",children:j.label}),j.sublabel&&t.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:j.sublabel})]}),j.badge&&t.jsx("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:j.badge})]},j.value)}),I.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:Y,className:`relative ${m||"w-full"}`,style:f,children:[t.jsxs("button",{type:"button",disabled:u,onClick:()=>!u&&$(j=>!j),className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{height:da(x),padding:da(w),background:W?"transparent":"var(--bg-input)",color:X?"var(--text-main)":"var(--text-muted)",border:W?"1px solid transparent":`1px solid ${q}`,opacity:u?.5:1,cursor:u?"not-allowed":"pointer"},"aria-haspopup":"listbox","aria-expanded":E,"aria-label":o,children:[(X==null?void 0:X.color)&&t.jsx("span",{className:"flex-shrink-0 w-2.5 h-2.5 rounded-full",style:{background:X.color}}),t.jsx("span",{className:"min-w-0 flex flex-1 items-baseline gap-1 overflow-hidden",children:X?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"truncate",children:X.label}),i&&X.sublabel&&t.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:X.sublabel})]}):t.jsx("span",{className:"truncate",children:c})}),X&&d?t.jsx("span",{role:"button",tabIndex:-1,onMouseDown:j=>{j.preventDefault(),j.stopPropagation(),B("")},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(P.HiXMark,{className:"w-3 h-3"})}):t.jsx(P.HiChevronDown,{className:"flex-shrink-0 w-4 h-4 transition-transform",style:{color:"var(--text-muted)",transform:E?"rotate(180deg)":"rotate(0deg)"}})]}),E&&A&&nt.createPortal(ae,document.body)]})}function dn(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Si({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(P.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:dn(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:dn(o),padding:dn(l)}})]})}function Ci({value:e,onChange:r,options:n,placeholder:a,icon:o,className:l="",height:i=40,padding:c,iconLeft:d=10,searchable:u=!0}){const m=o?n.map((f,p)=>p===0&&!f.color?{...f,sublabel:f.sublabel??void 0}:f):n;return t.jsxs("div",{className:`relative ${l}`,children:[o&&t.jsx("span",{className:"pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--text-muted)]",style:{left:dn(d)},children:o}),t.jsx(zt,{value:e,onChange:r,options:m,placeholder:a,searchable:u,minOptionsForSearch:5,height:i,padding:c??(o?"0 10px 0 30px":"0 10px"),className:"[&>button]:text-sm [&>button]:[background:var(--bg-card)]"})]})}const Ei={sm:"24rem",md:"28rem",lg:"32rem",xl:"40rem","2xl":"48rem","4xl":"56rem","5xl":"64rem"},un=180,Mi="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function fa({open:e,onClose:r,title:n,subtitle:a,leadingIcon:o,headerActions:l,footer:i,children:c,size:d="md",maxWidth:u,zIndex:m=1e3,closeOnBackdrop:f=!0,closeOnEscape:p=!0,showCloseButton:x=!0,placement:w="center",bodyClassName:T="px-6 py-5",panelClassName:h="",backdropClassName:E=Mi,contentClassName:$="p-4",ariaLabel:v,frameless:y=!1,disabled:k=!1}){const[S,A]=s.useState(!1),[C,U]=s.useState(!1),z=s.useRef(null);if(s.useEffect(()=>(e?(z.current&&clearTimeout(z.current),A(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>U(!0)))):(U(!1),z.current=setTimeout(()=>A(!1),un+40)),()=>{z.current&&clearTimeout(z.current)}),[e]),s.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),s.useEffect(()=>{if(!e||!p)return;const X=W=>{W.key==="Escape"&&r()};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[p,r,e]),!S)return null;const Y=n||a||o||l||x,M=u??Ei[d],J=w==="bottom-mobile"?"items-end sm:items-center justify-center p-0 sm:p-4":"items-center justify-center",H=w==="bottom-mobile"?"rounded-t-2xl sm:rounded-2xl":"rounded-2xl",ne=C?"translateY(0) scale(1)":w==="bottom-mobile"?"translateY(16px) scale(0.98)":"translateY(10px) scale(0.96)";return nt.createPortal(t.jsxs("div",{role:"dialog","aria-modal":"true","data-bonsaif-overlay":"true","aria-label":v??n,className:`fixed inset-0 flex ${J} ${$}`,style:{zIndex:m},children:[t.jsx("div",{className:`absolute inset-0 ${E}`,onClick:f?r:void 0,style:{opacity:C?1:0,transition:`opacity ${un}ms ease`}}),t.jsxs("div",{className:`relative z-10 flex max-h-[92dvh] w-full flex-col overflow-hidden ${y?"shadow-none":"shadow-2xl"} ${H} ${h}`,style:{maxWidth:M,background:y?"transparent":"var(--bg-card)",border:y?"none":"1px solid var(--border)",opacity:C?1:0,transform:ne,transition:`opacity ${un}ms ease, transform ${un}ms ease`},onClick:X=>X.stopPropagation(),children:[k&&t.jsx("div",{className:"absolute inset-0 z-[1002] cursor-not-allowed rounded-2xl",style:{background:"color-mix(in srgb, var(--bg-card, #ffffff) 60%, transparent)",backdropFilter:"blur(2px)"}}),Y&&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,x&&t.jsx(je,{variant:"icon",onClick:r,title:"Cerrar",children:t.jsx(P.HiXMark,{className:"h-5 w-5"})})]})]}),t.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${T}`,children:c}),i&&t.jsx("div",{className:"flex flex-shrink-0 justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--border)"},children:i})]})]}),document.body)}const Ti={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 $i({open:e,title:r,description:n,confirmLabel:a="Confirmar",cancelLabel:o="Cancelar",variant:l="danger",closeOnBackdrop:i=!0,onConfirm:c,onCancel:d}){const u=Ti[l];return t.jsx(fa,{open:e,onClose:d,size:"md",zIndex:9998,showCloseButton:!1,bodyClassName:"p-0",panelClassName:"overflow-visible",ariaLabel:r,closeOnBackdrop:i,children:t.jsxs("div",{className:"relative px-6 pb-6 pt-6",children:[t.jsx(je,{variant:"icon",onClick:d,className:"absolute right-3 top-3 h-8 w-8 hover:opacity-70",style:{color:"var(--text-muted)"},"aria-label":"Cancelar",children:t.jsx(P.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(P.HiExclamationTriangle,{className:"h-5 w-5",style:{color:u.iconColor}})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h2",{className:"text-base font-semibold leading-snug",style:{color:"var(--text-main)"},children:r}),n?t.jsx("div",{className:"mt-1.5 text-sm leading-relaxed",style:{color:"var(--text-muted)"},children:n}):null]})]}),t.jsxs("div",{className:"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[t.jsx(je,{variant:"secondary",onClick:d,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:"var(--bg-input)"},children:o}),t.jsx(je,{variant:"danger",onClick:c,className:"w-full sm:w-auto sm:min-w-[7.5rem]",style:{background:u.btnBg,color:u.btnColor,borderColor:"transparent"},children:a})]})]})})}function Ai(e){return e?typeof e=="function"?e():e:""}function Li(e){return/^https?:\/\//i.test(e)}function Es(e,r){try{return new URL(e,r).toString()}catch{return e}}function Di(e,r,n,a=!1){const o=typeof e=="function"?e():e,l=r?r(o):o;if(!l||Li(l))return l;const i=Ai(n);return i?Es(l,i):a&&typeof window<"u"?Es(l,window.location.origin):l}function Ii({url:e,resolveUrl:r,baseUrl:n,useWindowOriginForRelative:a=!1,title:o="Copiar link",copiedTitle:l="Link copiado",icon:i=t.jsx(P.HiLink,{className:"h-3.5 w-3.5"}),...c}){return t.jsx(ca,{...c,value:()=>Di(e,r,n,a),title:o,copiedTitle:l,icon:i})}const fn=[25,50,100,200,500];let ct={dataTable:{pageSizeOptions:[...fn]}};function Oi(){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 ba(){const e=ct.dataTable.preferencesEndpoint,r=Oi();return e&&e.trim().length>0?e.trim().replace(/\/+$/,""):r}function Hi(e){if(!Array.isArray(e))return[...fn];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:[...fn]}function Ms(e){if(typeof e!="string")return;const r=e.trim();if(r)return r.replace(/\/+$/,"")}function Bi(e){if(!e||typeof e!="object"||!e.dataTable)return;const r=Ms(e.dataTable.preferencesEndpoint);ct={...ct,dataTable:{...ct.dataTable,pageSizeOptions:Hi(e.dataTable.pageSizeOptions),preferencesEndpoint:r??ct.dataTable.preferencesEndpoint}}}function Fi(){return{dataTable:{pageSizeOptions:[...ct.dataTable.pageSizeOptions]}}}function Dr(){return[...ct.dataTable.pageSizeOptions]}function Pi(){ct={dataTable:{pageSizeOptions:[...fn]}}}function _i(e){ct={...ct,dataTable:{...ct.dataTable,preferencesEndpoint:Ms(e)}}}const bn=[{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"}],zi=bn.map(e=>({value:e.value,label:e.label})),ji=12,Wi={layout:!0,filters:!1,sort:!1,bql:!1,pagination:!0},Ts={layout:!0,filters:!0,sort:!0,bql:!0,pagination:!0},qi="bonsaif-ui:datatable:",Ui="[&_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",Vi=[],Xi=52;function St(e){if(!e)return 150;const r=parseInt(e,10);return isNaN(r)||r<=0?150:r}function $s(e){return!!(e&&(Array.isArray(e.columnOrder)&&e.columnOrder.length>0||e.columnWidths&&Object.keys(e.columnWidths).length>0||Array.isArray(e.hiddenColumnKeys)&&e.hiddenColumnKeys.length>0||e.filters&&Object.keys(e.filters).length>0||e.conditionFilters&&Object.keys(e.conditionFilters).length>0||e.sort||typeof e.bql=="string"||Array.isArray(e.bqlHistory)&&e.bqlHistory.length>0||typeof e.pageSize=="number"))}function As(e){return`${qi}${e}`}function mn(e){try{const r=window.localStorage.getItem(As(e));if(!r)return null;const n=JSON.parse(r);return n&&typeof n=="object"?n:null}catch{return null}}function Yi(e,r){try{window.localStorage.setItem(As(e),JSON.stringify(r))}catch{}}function Ki(e,r){if(e===!0)return{...Ts};if(e===!1)return{layout:!1,filters:!1,sort:!1,bql:!1,pagination:!1};if(r&&e==null)return{...Ts};const n={...Wi,...e??{}};return r&&(typeof e!="object"||e.pagination!==!1)&&(n.pagination=!0),n}function Ls(...e){return e.reduce((r,n)=>({...r,...n??{}}),{})}function ma(e,r,n){return typeof e!="number"||e<=0?n:Fr(r).includes(e)?e:n}function Ir(e){if(!e||typeof e!="object")return!1;const r=e;return typeof r.key=="string"&&(r.dir==="asc"||r.dir==="desc")}function Or(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 Hr(e,r){if(!e||typeof e!="object"||Array.isArray(e))return{};const n=new Set(bn.map(o=>o.value)),a=Object.entries(e).flatMap(([o,l])=>{if(!r.has(o)||!l||typeof l!="object")return[];const i=l;return!i.operator||!n.has(i.operator)?[]:[[o,{operator:i.operator,value:typeof i.value=="string"?i.value:"",valueTo:typeof i.valueTo=="string"?i.valueTo:""}]]});return Object.fromEntries(a)}function at(e,r){if(jt(e))return Xi;const n=e.minWidth??80,a=e.maxWidth??1/0;return Math.min(a,Math.max(n,r))}function Gi(e){const r=window.getComputedStyle(e);return parseFloat(r.paddingLeft)+parseFloat(r.paddingRight)}function jt(e){return e.key==="actions"||e.key==="acciones"?!0:typeof e.header=="string"&&e.header.trim().toLowerCase()==="acciones"}function pa(e){return e.sticky===!0}function Ds(e){return!(e.reorderable===!1||e.sticky&&e.reorderable!==!0)}function At(e,r){const n=r.filter(pa).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 Zi(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 Lt(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 Qi(e){return e==null||e===""?"(Vacio)":e instanceof Date?e.toLocaleDateString():String(e)}function nr(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(nr).join(" ").trim():s.isValidElement(e)?nr(e.props.children):""}function pn(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?Qi(n):nr(n).trim()}function Br(e){const r=e.replace(/,/g,"").trim();if(!r)return null;const n=Number(r);return Number.isFinite(n)?n:null}function ar(e,r){const n=Br(e),a=Br(r);return n!==null&&a!==null?n-a:e.localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})}function Fr(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:Dr()}function Ji(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=bn.find(d=>d.value===r.operator);if((l==null?void 0:l.valueMode)==="single"&&!a||(l==null?void 0:l.valueMode)==="between"&&(!a||!o))return!0;switch(r.operator){case"equals":return e.toLowerCase()===a.toLowerCase();case"notEquals":return e.toLowerCase()!==a.toLowerCase();case"greaterThan":return ar(e,a)>0;case"greaterThanOrEqual":return ar(e,a)>=0;case"lessThan":return ar(e,a)<0;case"lessThanOrEqual":return ar(e,a)<=0;case"between":return ar(e,a)>=0&&ar(e,o)<=0;case"top10":case"bottom10":{const u=n.map(f=>({value:f,number:Br(f)})).filter(f=>f.number!==null).sort((f,p)=>f.number-p.number).map(f=>f.value);return(r.operator==="top10"?u.slice(-10):u.slice(0,10)).includes(e)}case"aboveAverage":case"belowAverage":{const d=n.map(Br).filter(f=>f!==null);if(d.length===0)return!1;const u=d.reduce((f,p)=>f+p,0)/d.length,m=Br(e);return m===null?!1:r.operator==="aboveAverage"?m>u:m<u}default:return!0}}function Is({children:e,className:r="",style:n}){return t.jsx(_t,{onlyWhenOverflow:!0,className:r,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100%",minWidth:0,...n},children:e})}function Os({columns:e,data:r,getRowId:n,loading:a=!1,skeletonRows:o=8,emptyIcon:l,emptyText:i="Sin resultados",initialEmptyDelay:c=450,onRowClick:d,renderExpandedRow:u,getRowCanExpand:m,expandedRowIds:f,defaultExpandedRowIds:p=[],onExpandedRowIdsChange:x,expandOnRowClick:w=!1,selected:T,onToggleOne:h,onToggleAll:E,getRowSelectable:$,highlightSelected:v=!0,rowClassName:y,getRowCategory:k,stickyHeader:S=!0,pageSize:A=25,pageSizeOptions:C,pageSizeSelectWidth:U=62,pageSizeSelectHeight:z=30,pageSizeSelectPadding:Y="0 7px",totalRows:M,page:J,onPageChange:H,onPageSizeChange:ne,storageKey:X,stickyFirstColumn:W=!1,bottomOffset:q=0,compact:I=!0,restrictHeight:oe=!0,maxHeight:B,minTableWidth:O,enableColumnVisibility:le=!0,enableColumnFilters:g=!0,hiddenColumnKeys:_,defaultHiddenColumnKeys:ee=Vi,onHiddenColumnKeysChange:ae,columnVisibilityLabel:j="Columnas",enableBql:K=!1,bqlValue:L,defaultBqlValue:R="",onBqlChange:F,bqlDescription:se="Filtra registros con Bonsaif Query Language",bqlPlaceholder:G=`status = activo
2
+ rol IN (admin, employee)`,bqlQuickFilters:de=[],bqlExamples:Se=[],bqlSuggestions:ie=[],bqlActiveFilters:pe,bqlError:Ce,onQueryChange:De,persistState:mt,onPreferencesReady:xt,enableExport:We=!1,exportFilename:Ae="datos"}){var Ul;const ke=Ki(mt,X),et=Object.values(ke).some(Boolean),me=e.map(b=>b.key).join(","),Z=ee.join(","),te=s.useRef(e),be=s.useRef(ee);te.current=e,be.current=ee;const[he,Be]=s.useState(!X||!et),$e=s.useRef(null),He=s.useRef(!X),Fe=s.useRef(!1),ce=s.useRef(xt);ce.current=xt;const ue=s.useRef(!X||!et?X??"__none__":null),Ee=_!==void 0,[Ie,Le]=s.useState(()=>Lt(ee,e)),Pe=Lt(Ee?_:Ie,e),[Ge,Ze]=s.useState(!1),[Qe,Et]=s.useState("filter"),[Ot,Ut]=s.useState(null),[dl,ul]=s.useState(""),[lt,vr]=s.useState({}),[wt,Zr]=s.useState({}),Ka=f!==void 0,[fl,gf]=s.useState(p),Vt=L!==void 0,[vf,Qr]=s.useState(R),Mt=Vt?L:vf,[Jr,Pn]=s.useState(Mt),[Tt,Xt]=s.useState(!1),[bl,yr]=s.useState(!1),[ml,xr]=s.useState(!1),[Rr,wr]=s.useState([]),kr=s.useRef(null),Yt=s.useRef(null),kt=s.useRef(F);kt.current=F;const _n=s.useRef(A);_n.current=A;const zn=s.useRef(C);zn.current=C;const yf=Array.isArray(C)?C.join(","):"",Ga=s.useRef(null),pl=s.useRef(null),Za=s.useRef(null),hl=s.useRef(0),[xf,wf]=s.useState({}),[kf,Nf]=s.useState({}),[en,jn]=s.useState(!1),Qa=s.useRef(null),Wn=s.useRef(null),[Sf,Cf]=s.useState({}),gl=s.useRef(null),qn=s.useRef(null),[Ja,vl]=s.useState(r.length>0||a||c===!1),yl=(b,N)=>50+(b*17+N*13+7)%40,Ht=s.useRef(null),[Ef,Mf]=s.useState(void 0),[xl,Tf]=s.useState(0),[$f,Af]=s.useState(!1);s.useEffect(()=>{function b(){Af(window.innerWidth<640)}if(!oe||B!==void 0)return b(),window.addEventListener("resize",b),()=>window.removeEventListener("resize",b);const Q=A!==!1?48:0,D=12;function re(){if(b(),!Ht.current)return;const fe=Ht.current.getBoundingClientRect().top;Mf(Math.max(120,window.innerHeight-fe-Q-D-q))}return re(),window.addEventListener("resize",re),()=>window.removeEventListener("resize",re)},[a,A,q,oe,B]);const wl=oe?B??Ef:void 0;s.useEffect(()=>{const b=Ht.current;if(!b)return;const N=()=>Tf(b.clientWidth);if(N(),typeof ResizeObserver>"u")return window.addEventListener("resize",N),()=>window.removeEventListener("resize",N);const Q=new ResizeObserver(N);return Q.observe(b),()=>Q.disconnect()},[a,he,r.length]),s.useEffect(()=>{if(c===!1||a||r.length>0){vl(!0);return}if(Ja)return;const b=window.setTimeout(()=>{vl(!0)},c);return()=>window.clearTimeout(b)},[r.length,c,Ja,a]);const[Nr,Sr]=s.useState(()=>At(e.map(b=>b.key),e)),[Kt,Cr]=s.useState(()=>Object.fromEntries(e.map(b=>[b.key,at(b,St(b.width))]))),[qe,Gt]=s.useState(null),[Lf,Un]=s.useState(1),[Vn,Xn]=s.useState(A===!1?0:A);s.useEffect(()=>{var Me;const b=te.current,N=be.current,Q=b.map(we=>we.key),D=new Set(Q),re=()=>{var we;Fe.current||(Fe.current=!0,(we=ce.current)==null||we.call(ce))};if(!X||!et){ke.layout&&Sr(At(Q,b)),Ee||Le(Lt(N,b)),He.current=!1,Be(!0),re();return}let fe=!1;const ve=ue.current===X;ve||(He.current=!1,Be(!1),Fe.current=!1);const Te=mn(X);if($s(Te)&&!ve){const we=Te,ye=Fr(zn.current??Dr()),xe=_n.current,tr=xe===!1?0:xe,Bt=ke.layout?we==null?void 0:we.columnOrder:void 0,Ft=Array.isArray(Bt)?Bt.filter(_e=>Q.includes(_e)):[],Pt=Q.filter(_e=>!Ft.includes(_e)),rr=At(Ft.length>0?[...Ft,...Pt]:Q,b),Tr=Object.fromEntries(b.map(_e=>[_e.key,at(_e,St(_e.width))])),$r=ke.layout?(we==null?void 0:we.columnWidths)??{}:{},an=Object.fromEntries(b.map(_e=>[_e.key,at(_e,$r[_e.key]??Tr[_e.key])])),Ar=Lt(ke.layout?(we==null?void 0:we.hiddenColumnKeys)??N:N,b);if(ke.layout&&(Sr(rr),Cr(an)),Ee||Le(Ar),ke.filters&&(vr(Or(we==null?void 0:we.filters,D)),Zr(Hr(we==null?void 0:we.conditionFilters,D))),ke.sort){const _e=Ir(we==null?void 0:we.sort)?we.sort:null;Gt(_e&&D.has(_e.key)?_e:null)}if(ke.bql){if(kr.current!==X){kr.current=X;const _e=typeof(we==null?void 0:we.bql)=="string"?we.bql:R;Vt?(Me=kt.current)==null||Me.call(kt,_e):Qr(_e)}wr(Array.isArray(we==null?void 0:we.bqlHistory)?we.bqlHistory.filter(_e=>typeof _e=="string"):[])}ke.pagination&&Yt.current!==X&&(Yt.current=X,Xn(ma(we==null?void 0:we.pageSize,ye,tr))),ue.current=X,Be(!0),re()}const rt=`${ba()??"/api/user/preferences/datatables"}?key=${encodeURIComponent(X)}`,Ye=new AbortController,ge=window.setTimeout(()=>Ye.abort(),2500);return fetch(rt,{cache:"no-store",signal:Ye.signal}).then(we=>we.ok?we.json():null).then(we=>{var Vl;if(fe)return;const ye=mn(X),xe=Ls($s(we==null?void 0:we.settings)?we==null?void 0:we.settings:null,ye),tr=Fr(zn.current??Dr()),Bt=_n.current,Ft=Bt===!1?0:Bt,Pt=ke.layout?xe==null?void 0:xe.columnOrder:void 0,rr=Array.isArray(Pt)?Pt.filter(Ve=>Q.includes(Ve)):[],Tr=Q.filter(Ve=>!rr.includes(Ve)),$r=At(rr.length>0?[...rr,...Tr]:Q,b),an=Object.fromEntries(b.map(Ve=>[Ve.key,at(Ve,St(Ve.width))])),Ar=ke.layout?(xe==null?void 0:xe.columnWidths)??{}:{},_e=Object.fromEntries(b.map(Ve=>[Ve.key,at(Ve,Ar[Ve.key]??an[Ve.key])])),Lr=Lt(ke.layout?(xe==null?void 0:xe.hiddenColumnKeys)??N:N,b);if(ke.layout&&(Sr($r),Cr(_e)),Ee||Le(Lr),ke.filters&&(vr(Or(xe==null?void 0:xe.filters,D)),Zr(Hr(xe==null?void 0:xe.conditionFilters,D))),ke.sort){const Ve=Ir(xe==null?void 0:xe.sort)?xe.sort:null;Gt(Ve&&D.has(Ve.key)?Ve:null)}if(ke.bql){if(kr.current!==X){kr.current=X;const Ve=typeof(xe==null?void 0:xe.bql)=="string"?xe.bql:R;Vt?(Vl=kt.current)==null||Vl.call(kt,Ve):Qr(Ve)}wr(Array.isArray(xe==null?void 0:xe.bqlHistory)?xe.bqlHistory.filter(Ve=>typeof Ve=="string"):[])}let ze;ke.pagination&&(ze=ma(xe==null?void 0:xe.pageSize,tr,Ft),Yt.current!==X&&(Yt.current=X,Xn(ze))),$e.current=JSON.stringify({columnOrder:$r,columnWidths:_e,hiddenColumnKeys:Lr,filters:Or(xe==null?void 0:xe.filters,D),conditionFilters:Hr(xe==null?void 0:xe.conditionFilters,D),sort:Ir(xe==null?void 0:xe.sort)?xe.sort:null,bql:typeof(xe==null?void 0:xe.bql)=="string"?xe.bql:"",bqlHistory:Array.isArray(xe==null?void 0:xe.bqlHistory)?xe.bqlHistory:[],pageSize:ke.pagination&&Bt!==!1?ze:void 0}),He.current=!0}).catch(()=>{var we;if(!fe){const ye=mn(X),xe=Fr(zn.current??Dr()),tr=_n.current,Bt=tr===!1?0:tr,Ft=ke.layout?ye==null?void 0:ye.columnOrder:void 0,Pt=Array.isArray(Ft)?Ft.filter(ze=>Q.includes(ze)):[],rr=Q.filter(ze=>!Pt.includes(ze)),Tr=At(Pt.length>0?[...Pt,...rr]:Q,b),$r=Object.fromEntries(b.map(ze=>[ze.key,at(ze,St(ze.width))])),an=ke.layout?(ye==null?void 0:ye.columnWidths)??{}:{},Ar=Object.fromEntries(b.map(ze=>[ze.key,at(ze,an[ze.key]??$r[ze.key])]));ke.layout&&(Sr(Tr),Cr(Ar));const _e=Lt(ke.layout?(ye==null?void 0:ye.hiddenColumnKeys)??N:N,b);if(Ee||Le(_e),ke.filters&&(vr(Or(ye==null?void 0:ye.filters,D)),Zr(Hr(ye==null?void 0:ye.conditionFilters,D))),ke.sort){const ze=Ir(ye==null?void 0:ye.sort)?ye.sort:null;Gt(ze&&D.has(ze.key)?ze:null)}if(ke.bql){if(kr.current!==X){kr.current=X;const ze=typeof(ye==null?void 0:ye.bql)=="string"?ye.bql:R;Vt?(we=kt.current)==null||we.call(kt,ze):Qr(ze)}wr(Array.isArray(ye==null?void 0:ye.bqlHistory)?ye.bqlHistory.filter(ze=>typeof ze=="string"):[])}let Lr;ke.pagination&&(Lr=ma(ye==null?void 0:ye.pageSize,xe,Bt),Yt.current!==X&&(Yt.current=X,Xn(Lr))),$e.current=JSON.stringify({columnOrder:Tr,columnWidths:Ar,hiddenColumnKeys:_e,filters:Or(ye==null?void 0:ye.filters,D),conditionFilters:Hr(ye==null?void 0:ye.conditionFilters,D),sort:Ir(ye==null?void 0:ye.sort)?ye.sort:null,bql:typeof(ye==null?void 0:ye.bql)=="string"?ye.bql:"",bqlHistory:Array.isArray(ye==null?void 0:ye.bqlHistory)?ye.bqlHistory:[],pageSize:ke.pagination&&tr!==!1?Lr:void 0}),He.current=!0}}).finally(()=>{window.clearTimeout(ge),fe||(ue.current=X,Be(!0),re())}),()=>{fe=!0,Ye.abort(),window.clearTimeout(ge)}},[X,et,me,Z,Ee,ke.layout,ke.filters,ke.sort,ke.bql,ke.pagination,Vt,R,yf]),s.useEffect(()=>{if(!X||!he||!et||!He.current)return;const b={};ke.layout&&(b.columnOrder=Nr,b.columnWidths=Kt,b.hiddenColumnKeys=Pe),ke.filters&&(b.filters=lt,b.conditionFilters=wt),ke.sort&&(b.sort=qe),ke.bql&&(b.bql=Mt,b.bqlHistory=Rr),ke.pagination&&A!==!1&&(b.pageSize=Vn);const N=mn(X),Q=Ls(N,b),D=JSON.stringify(Q);if(D===$e.current)return;Yi(X,Q),$e.current=D;const re=window.setTimeout(()=>{const fe=ba()??"/api/user/preferences/datatables";fetch(fe,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:X,settings:Q})}).then(()=>{}).catch(()=>{})},300);return()=>window.clearTimeout(re)},[Nr,Kt,Pe,lt,wt,qe,Mt,Rr,Vn,A,X,he,et,ke.layout,ke.filters,ke.sort,ke.bql,ke.pagination]),s.useEffect(()=>{Sr(b=>{const N=e.map(re=>re.key),Q=b.filter(re=>N.includes(re)),D=N.filter(re=>!Q.includes(re));return At([...Q,...D],e)})},[me,e]);const kl=At(Nr,e).map(b=>e.find(N=>N.key===b)).filter(b=>!!b),it=kl.filter(b=>!Pe.includes(b.key)),Nl=e.some(pa),Df=Object.keys(lt).length,If=Object.keys(wt).length,Ra=Df+If;function Sl(b){const N=new Set;return r.reduce((Q,D)=>{const re=pn(b,D);return!re||N.has(re)||(N.add(re),Q.push({value:re,label:re})),Q},[])}function Of(){const b=e.find(N=>N.key===Ot);return b?Sl(b):[]}function Hf(b){return!!(g&&!jt(b)&&(b.filterValue||b.sortKey||Sl(b).length>0))}function Cl(b,N){vr(Q=>{const D={...Q};return D[b]=N,D})}function Bf(b,N,Q,D){const re=lt[b]??[],fe=D?re:Q.filter(Te=>Te!==N),ve=D?re.includes(N)?re.filter(Te=>Te!==N):[...re,N]:fe;ve.length===Q.length?es(b):Cl(b,ve)}function es(b){vr(N=>{const Q={...N};return delete Q[b],Q})}function Yn(b,N){Zr(Q=>{const D={...Q};return N?D[b]=N:delete D[b],D})}function El(b){Yn(b,null)}function Ff(){vr({}),Zr({})}function Pf(b){Vt||Qr(b),F==null||F(b)}function Ml(b){const N=b.trim();Pn(N),(F==null?void 0:F(N))!==!1&&(Vt||Qr(N),Xt(!1),yr(!1),xr(!1),N&&wr(D=>[N,...D.filter(re=>re!==N)].slice(0,ji)))}function Tl(){Pn(""),Pf(""),Xt(!1),yr(!1),xr(!1)}function ts(b,N){Pn(b),N&&(N.style.height="auto",N.style.height=`${Math.min(N.scrollHeight,180)}px`)}function Kn(b){const N=b.trim();if(!N)return;hl.current=Date.now()+500;const Q=Jr.replace(/\s+$/u,""),D=Q.length===0?N:Q.split(`
3
+ `).map(re=>re.trim()).includes(N)?Q:`${Q}
4
+ ${N}`;ts(D,Za.current??void 0),requestAnimationFrame(()=>{const re=Za.current;if(!re)return;re.focus();const fe=re.value.length;re.setSelectionRange(fe,fe),ts(re.value,re)})}s.useEffect(()=>{Pn(Mt)},[Mt]);const Gn=s.useCallback(()=>{const b=Ga.current;if(!b)return;const N=b.getBoundingClientRect(),Q=12,D=8,re=Math.min(780,Math.max(320,window.innerWidth-32)),fe=Math.max(Q,window.innerWidth-re-Q),ve=Math.min(Math.max(Q,N.left),fe),Te=N.bottom+D,Ke=window.innerHeight-N.top+D,Ue=window.innerHeight-Te-Q,rt=N.top-Q-D,Ye=Ue<280&&rt>Ue,ge=Math.max(240,Ye?rt:Ue);wf({position:"fixed",zIndex:1e4,left:ve,top:Ye?void 0:Te,bottom:Ye?Ke:void 0,width:re,maxWidth:"calc(100vw - 24px)",maxHeight:ge,overflowY:"auto"})},[]);s.useEffect(()=>{if(!Tt)return;function b(D){var fe,ve;if(Date.now()<hl.current)return;const re=D.target;(fe=Ga.current)!=null&&fe.contains(re)||(ve=pl.current)!=null&&ve.contains(re)||(Xt(!1),yr(!1),xr(!1))}function N(D){D.key==="Escape"&&(Xt(!1),yr(!1),xr(!1))}function Q(){Gn()}return Gn(),document.addEventListener("mousedown",b),window.addEventListener("keydown",N),window.addEventListener("resize",Q),window.addEventListener("scroll",Q,!0),()=>{document.removeEventListener("mousedown",b),window.removeEventListener("keydown",N),window.removeEventListener("resize",Q),window.removeEventListener("scroll",Q,!0)}},[Tt,Gn]);function $l(b){const N=Lt(b,e);Ee||Le(N),ae==null||ae(N)}function _f(b){$l(Pe.includes(b)?Pe.filter(N=>N!==b):[...Pe,b])}function zf(){$l([])}const rs=s.useCallback((b=qn.current)=>{if(!b)return;const N=b.getBoundingClientRect(),Q=Math.min(292,Math.max(240,window.innerWidth-16)),D=Math.max(8,window.innerWidth-Q-8),re=Math.min(Math.max(8,N.right-Q),D),fe=window.innerHeight-N.bottom,ve=N.bottom+6,Te=window.innerHeight-N.top+6,Ue=fe<360&&N.top>fe?void 0:ve,rt=Ue===void 0?Te:void 0,Ye=Math.max(220,Ue===void 0?N.top-16:window.innerHeight-ve-8),ge={position:"fixed",zIndex:9999,left:re,top:Ue,bottom:rt,width:Q,maxWidth:"calc(100vw - 16px)",maxHeight:Ye,"--dt-column-menu-max-height":`${Ye}px`};Nf(ge)},[]);function Al(b,N,Q=null){b.preventDefault(),b.stopPropagation();const D=qn.current===b.currentTarget&&Qe===N&&Ot===Q;if(Ge&&D){Ze(!1),Ut(null);return}qn.current=b.currentTarget,Et(N),Ut(Q),ul(""),rs(b.currentTarget),Ze(!0)}function jf(b){if(jt(b))return;const N=Ht.current;if(!N)return;const D=Array.from(N.querySelectorAll("[data-dt-column-key]")).filter(re=>re.dataset.dtColumnKey===b.key).reduce((re,fe)=>{const ve=fe.querySelector("[data-dt-autofit-content]"),Te=ve?ve.scrollWidth:Math.max(fe.scrollWidth,fe.offsetWidth);return Math.max(re,Math.ceil(Te+Gi(fe)))},0);D<=0||Cr(re=>({...re,[b.key]:at(b,D+12)}))}s.useEffect(()=>{Cr(b=>{const N=Object.fromEntries(e.map(Q=>[Q.key,at(Q,St(Q.width))]));return Object.fromEntries(e.map(Q=>[Q.key,at(Q,b[Q.key]??N[Q.key])]))})},[me,e]),s.useEffect(()=>{Ee||Le(b=>Lt(b,e))},[me,e,Ee]),s.useEffect(()=>{function b(D){var ve,Te;const re=D.target,fe=D.target;fe!=null&&fe.closest("[data-bonsaif-select-dropdown='true']")||!((ve=gl.current)!=null&&ve.contains(re))&&!((Te=qn.current)!=null&&Te.contains(re))&&(Ze(!1),Ut(null))}function N(D){D.key==="Escape"&&(Ze(!1),Ut(null))}function Q(){rs()}return Ge&&(document.addEventListener("mousedown",b),window.addEventListener("keydown",N),window.addEventListener("resize",Q),window.addEventListener("scroll",Q,!0)),()=>{document.removeEventListener("mousedown",b),window.removeEventListener("keydown",N),window.removeEventListener("resize",Q),window.removeEventListener("scroll",Q,!0)}},[Ge,rs]);const tn=s.useRef(null);s.useEffect(()=>{function b(Q){const D=tn.current;if(!D)return;const re=Q.clientX-D.startX,fe=e.find(ve=>ve.key===D.colKey);fe&&Cr(ve=>({...ve,[D.colKey]:at(fe,D.startWidth+re)}))}function N(){tn.current&&(tn.current=null,document.body.style.cursor="",document.body.style.userSelect="")}return document.addEventListener("pointermove",b),document.addEventListener("pointerup",N),()=>{document.removeEventListener("pointermove",b),document.removeEventListener("pointerup",N)}},[e]);const rn=s.useRef(null),[Ll,ns]=s.useState(null);function Wf(b,N){const Q=e.find(D=>D.key===b);if(!Q||!Ds(Q)){N.preventDefault();return}rn.current=Nr.indexOf(b),N.dataTransfer.effectAllowed="move"}function qf(b,N){N.preventDefault(),N.dataTransfer.dropEffect="move";const Q=Nr.indexOf(b);Ll!==Q&&ns(Q)}function Uf(b,N){N.preventDefault();const Q=rn.current,D=Nr.indexOf(b);Q!==null&&Q!==D&&Sr(re=>{const fe=[...re],[ve]=fe.splice(Q,1);return fe.splice(D,0,ve),At(fe,e)}),rn.current=null,ns(null)}function Vf(){rn.current=null,ns(null)}function Xf(b){b.sortKey&&Gt(N=>(N==null?void 0:N.key)===b.key?{key:b.key,dir:N.dir==="asc"?"desc":"asc"}:{key:b.key,dir:"asc"})}s.useEffect(()=>{Un(1)},[r]),s.useEffect(()=>{Un(1)},[wt,lt]);const Zt=!!(H&&ne),Qt=A!==!1,Dl=s.useMemo(()=>Fr(C??Dr()),[C]),Re=Zt?J??1:Lf,Nt=Zt||Qt?Vn:r.length,pt=!!T&&!!h&&!!E,as=s.useMemo(()=>$?r.filter(b=>$(b)):r,[r,$]),Er=!!u,Il=s.useMemo(()=>new Set(Ka?Array.from(f??[]):fl),[Ka,f,fl]),Yf=(Er?40:0)+(pt?40:0),ss=!$f&&(Nl||W),Zn=(()=>{if(!ss)return{};let b=Yf;const N={};return it.forEach((Q,D)=>{(pa(Q)||!Nl&&W&&D===0)&&(N[Q.key]=b,b+=Kt[Q.key]??at(Q,St(Q.width)))}),N})(),os=Object.keys(Zn),ls=os.length>0?os[os.length-1]:null,Ol=pt&&as.length>0&&as.every(b=>T.has(n(b))),Kf=pt&&T.size>0&&as.some(b=>T.has(n(b)))&&!Ol,Qn=s.useMemo(()=>{const b=Object.entries(lt),N=Object.entries(wt);return b.length===0&&N.length===0?r:r.filter(Q=>b.every(([D,re])=>{const fe=e.find(ve=>ve.key===D);return fe?re.includes(pn(fe,Q)):!0})&&N.every(([D,re])=>{const fe=e.find(Te=>Te.key===D);if(!fe)return!0;const ve=r.map(Te=>pn(fe,Te));return Ji(pn(fe,Q),re,ve)}))},[wt,lt,e,r]),Jt=s.useMemo(()=>{if(!qe)return Qn;const b=e.find(N=>N.key===qe.key&&N.sortKey);return b!=null&&b.sortKey?[...Qn].sort((N,Q)=>{const D=N[b.sortKey],re=Q[b.sortKey],fe=D===re?0:D==null?1:re==null||D<re?-1:1;return qe.dir==="asc"?fe:-fe}):Qn},[Qn,qe,e]),Hl=s.useMemo(()=>{if(Zt||!Qt)return Jt;const b=(Re-1)*Nt;return Jt.slice(b,b+Nt)},[Jt,Zt,Qt,Re,Nt]),Rt=Zt?M??r.length:Jt.length,is=Qt?Math.max(1,Math.ceil(Rt/Nt)):1,Gf=Math.min(...Dl),Zf=Qt&&(Rt>Nt||Rt>Gf),Qf=Qt?(Re-1)*Nt+1:1,Jf=Qt?Math.min(Re*Nt,Rt):Rt;function cs(b){if(a)return;const N=Math.max(1,Math.min(b,is));Zt?H(N):Un(N)}function Rf(b){a||(X&&(Yt.current=X),Xn(b),Zt?(ne(b),H(1)):(Un(1),ne==null||ne(b)))}function Bl(b){const N=new Set(Il);N.has(b)?N.delete(b):N.add(b);const Q=Array.from(N);Ka||gf(Q),x==null||x(Q)}s.useEffect(()=>{De==null||De({bql:Mt,filters:lt,conditionFilters:wt,sort:qe,page:Re,pageSize:Nt,hiddenColumnKeys:Pe})},[Mt,lt,wt,qe,Re,Nt,Pe,De]);const Fl=b=>b==="center"?"justify-center text-center":b==="right"?"justify-end text-right":"justify-start text-left",eb="color-mix(in srgb, var(--primary) 6%, var(--bg-card))",ds="linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 90%, var(--bg-card)) 0%, color-mix(in srgb, var(--bg-input) 70%, var(--bg-card)) 100%)",Oe="color-mix(in srgb, var(--border) 62%, var(--bg-card))",er="color-mix(in srgb, var(--primary) 24%, var(--border))",Jn=`inset 0 0 0 1px ${Oe}`,Pl=it.reduce((b,N)=>b+(Kt[N.key]??St(N.width)),(Er?40:0)+(pt?40:0)),_l=typeof O=="number"?O:typeof O=="string"?Number(((Ul=O.match(/^(\d+(?:\.\d+)?)px$/))==null?void 0:Ul[1])??NaN):NaN,nn=Number.isFinite(_l)?Math.max(Pl,_l,xl):Math.max(Pl,xl),Rn=O??nn,Mr=`${Er?"40px ":""}${pt?"40px ":""}${it.map(b=>`${Kt[b.key]??St(b.width)}px`).join(" ")}`;s.useEffect(()=>{qe&&Pe.includes(qe.key)&&Gt(null)},[Pe,qe]);function zl(b){return b?typeof b=="string"?{key:b,label:b}:b:null}const ea=()=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Mr,background:ds,borderBottom:`1px solid ${er}`},children:[Er&&t.jsx("div",{role:"columnheader",className:`${I?"px-2 py-1.5":"px-3 py-2.5"} w-10`,style:{borderBottom:`1px solid ${er}`,borderRight:`1px solid ${Oe}`}}),pt&&t.jsx("div",{role:"columnheader",className:`${I?"px-2 py-1.5":"px-3 py-2.5"} flex w-10 items-center justify-center`,style:ss?{position:"sticky",left:0,zIndex:12,background:ds,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:`inset 0 -1px 0 ${er}`,borderRight:`1px solid ${Oe}`}:{borderBottom:`1px solid ${er}`,borderRight:`1px solid ${Oe}`},children:t.jsx(cn,{size:"sm",checked:Ol,indeterminate:Kf,onChange:E,"aria-label":"Seleccionar todos",containerClassName:"items-center",className:"cursor-pointer"})}),it.map((b,N)=>{const Q=(qe==null?void 0:qe.key)===b.key,D=!!b.sortKey,re=jt(b),fe=Zn[b.key],ve=fe!==void 0,Te=b.key===ls,Ke=Ds(b),Ue=Ll===N,Ye=(Kt[b.key]??St(b.width))<120,ge=Object.prototype.hasOwnProperty.call(lt,b.key)||Object.prototype.hasOwnProperty.call(wt,b.key);return t.jsxs("div",{role:"columnheader","data-dt-column-key":b.key,className:`group select-none ${Ye?"text-left":Fl(b.align)}`,style:{...ve?{position:"sticky",left:fe,zIndex:12,background:ds,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:Te?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${er}`:`inset 0 -1px 0 ${er}`,borderRight:`1px solid ${Oe}`}:{position:"relative",borderBottom:`1px solid ${er}`,borderRight:`1px solid ${Oe}`},color:Q?"var(--primary)":"var(--text-muted)",whiteSpace:"nowrap",transition:"color 0.15s",borderLeft:Ue?"2px solid var(--primary)":"2px solid transparent",cursor:"default",padding:re?I?"7px 6px":"9px 8px":I?"8px 6px 10px":"10px 8px 12px"},onDragOver:Me=>{(Ke||rn.current!==null)&&qf(b.key,Me)},onDrop:Me=>Uf(b.key,Me),children:[t.jsxs("div",{className:`flex min-w-0 items-center gap-1 ${re?"justify-center":Ye?"justify-start":b.align==="center"?"justify-center":b.align==="right"?"justify-end":"justify-start"}`,children:[Ke?t.jsx("span",{draggable:!0,onDragStart:Me=>{Me.stopPropagation(),Wf(b.key,Me)},onDragEnd:Me=>{Me.stopPropagation(),Vf()},onClick:Me=>Me.stopPropagation(),title:"Arrastrar para mover columna","aria-label":"Arrastrar para mover columna",className:`absolute left-0 top-0 z-10 inline-flex h-full w-3 shrink-0 rounded-sm transition-colors duration-150 hover:bg-[var(--primary)]/15 ${Ue?"bg-[var(--primary)]/20":""}`,style:{cursor:"grab"}}):null,re?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(P.HiCog6Tooth,{className:"h-3.5 w-3.5"})}):t.jsx(Is,{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 ${I?"text-[11px]":"text-xs"}`,children:t.jsx("span",{className:"min-w-0 truncate",children:b.header})})}),D&&t.jsx("button",{type:"button","aria-label":`Ordenar por ${String(b.header)}`,title:"Ordenar",onClick:Me=>{Me.stopPropagation(),Xf(b)},"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 ${Q?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,style:{bottom:"-0.5rem",top:"auto"},children:Q?qe.dir==="asc"?t.jsx(P.HiChevronUp,{className:"h-3 w-3"}):t.jsx(P.HiChevronDown,{className:"h-3 w-3"}):t.jsx(P.HiChevronUpDown,{className:"h-3 w-3"})}),g&&!re&&Hf(b)&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ge&&Ot===b.key,"aria-label":`Filtrar ${String(b.header)}`,title:"Filtrar",onClick:Me=>Al(Me,"filter",b.key),className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-sm bg-transparent text-[var(--text-muted)] opacity-0 transition-[opacity,color,background-color] duration-150 hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] focus:opacity-100 group-hover:opacity-100 ${Ge&&Qe==="filter"&&Ot===b.key?"bg-[var(--bg-card)] text-[var(--primary)] opacity-100":ge?"text-[var(--primary)] opacity-100":""}`,children:ge?t.jsx(P.HiFunnel,{className:"h-3.5 w-3.5"}):t.jsx(P.HiEllipsisVertical,{className:"h-3.5 w-3.5"})})]}),!re&&t.jsx("span",{role:"separator","aria-orientation":"vertical",title:"Arrastrar para redimensionar. Doble click para autoajustar",onPointerDown:Me=>{Me.preventDefault(),Me.stopPropagation(),tn.current={colKey:b.key,startX:Me.clientX,startWidth:Kt[b.key]??150},document.body.style.cursor="col-resize",document.body.style.userSelect="none"},onDoubleClick:Me=>{Me.preventDefault(),Me.stopPropagation(),tn.current=null,document.body.style.cursor="",document.body.style.userSelect="",jf(b)},onClick:Me=>Me.stopPropagation(),className:"absolute top-0 flex h-full items-center justify-center opacity-0 transition-opacity duration-200 hover:opacity-100",style:{right:0,width:12,cursor:"col-resize",zIndex:6,transform:"translateX(50%)"},children:t.jsxs("span",{style:{display:"flex",gap:4,alignItems:"center",height:"calc(100% - 8px)"},children:[t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}}),t.jsx("span",{style:{width:2,height:"100%",borderRadius:2,background:"var(--primary)",display:"block"}})]})})]},b.key)})]}),ta=()=>{if(!Ge||typeof document>"u"||Qe==="visibility"&&!le||Qe==="filter"&&!g)return null;const b=e.find(ge=>ge.key===Ot),N=Of(),Q=b?Object.prototype.hasOwnProperty.call(lt,b.key):!1,D=b?wt[b.key]:void 0,re=bn.find(ge=>ge.value===(D==null?void 0:D.operator)),fe=b?lt[b.key]??[]:[],ve=dl.trim().toLowerCase(),Te=ve?N.filter(ge=>ge.label.toLowerCase().includes(ve)):N,Ke=b&&N.length>0&&(!Q||fe.length===N.length),Ue=b&&Q&&fe.length>0&&fe.length<N.length,rt=Pe.length,Ye=()=>{b&&(es(b.key),El(b.key))};return nt.createPortal(t.jsx("div",{ref:gl,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...kf,borderColor:"var(--border)",background:"var(--bg-card)"},children:Qe==="visibility"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--border)] px-2 py-1.5",children:[t.jsx("span",{className:"min-w-0 truncate text-xs font-semibold uppercase text-[var(--text-muted)]",children:rt>0?`${it.length} de ${e.length} visibles`:`${e.length} visibles`}),t.jsx("button",{type:"button",onClick:zf,disabled:rt===0,className:"rounded px-1.5 py-0.5 text-xs font-medium text-[var(--primary)] transition-colors hover:bg-[var(--bg-input)] disabled:opacity-40",children:"Mostrar todas"})]}),t.jsx("div",{className:"max-h-72 overflow-auto py-1",children:kl.map(ge=>{const Me=!Pe.includes(ge.key),ye=!(ge.hideable!==!1)||Me&&it.length<=1;return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Me,disabled:ye,onClick:()=>_f(ge.key),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Me?"var(--primary)":"var(--border)",background:Me?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Me&&t.jsx(P.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ge.header})]},ge.key)})})]}):b?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 ",b.header]}),t.jsx("button",{type:"button",onClick:Ye,disabled:!Q&&!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"})]}),b.sortKey&&t.jsxs("div",{className:"grid grid-cols-2 gap-1 border-b border-[var(--border)] p-1",children:[t.jsxs("button",{type:"button",onClick:()=>Gt({key:b.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(P.HiChevronUp,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Ascendente"})]}),(qe==null?void 0:qe.key)===b.key&&qe.dir==="asc"&&t.jsx(P.HiCheck,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"})]}),t.jsxs("button",{type:"button",onClick:()=>Gt({key:b.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(P.HiChevronDown,{className:"h-4 w-4 shrink-0 text-[var(--primary)]"}),t.jsx("span",{className:"truncate",children:"Descendente"})]}),(qe==null?void 0:qe.key)===b.key&&qe.dir==="desc"&&t.jsx(P.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(zt,{value:(D==null?void 0:D.operator)??"",onChange:ge=>{if(!ge){El(b.key);return}Yn(b.key,{operator:ge,value:(D==null?void 0:D.value)??"",valueTo:(D==null?void 0:D.valueTo)??""})},options:zi,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"}),(re==null?void 0:re.valueMode)!=="none"?t.jsx("input",{value:(D==null?void 0:D.value)??"",onChange:ge=>{D&&Yn(b.key,{...D,value:ge.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"})]}),(re==null?void 0:re.valueMode)==="between"&&t.jsx("input",{value:(D==null?void 0:D.valueTo)??"",onChange:ge=>{D&&Yn(b.key,{...D,valueTo:ge.target.value})},placeholder:"Valor final",className:"mt-2 w-full rounded-md border px-2 py-1.5 text-xs outline-none transition-colors placeholder:text-[var(--text-muted)] focus:border-[var(--primary)]",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"}})]}),t.jsx("div",{className:"border-b border-[var(--border)] p-2",children:t.jsxs("div",{className:"flex items-center gap-1 rounded-md border px-2 py-1.5 text-sm",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsx(P.HiMagnifyingGlass,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("input",{value:dl,onChange:ge=>ul(ge.target.value),placeholder:"Buscar",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-[var(--text-muted)]",style:{color:"var(--text-main)"}})]})}),t.jsxs("div",{className:"overflow-auto py-1",style:{maxHeight:"max(96px, calc(var(--dt-column-menu-max-height, 520px) - 236px))"},children:[t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Ue?"mixed":!!Ke,onClick:()=>{b&&(Ke&&!Q?Cl(b.key,[]):es(b.key))},className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsxs("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Ke||Ue?"var(--primary)":"var(--border)",background:Ke||Ue?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:[Ue&&t.jsx(P.HiMinus,{className:"h-3 w-3"}),Ke&&!Ue&&t.jsx(P.HiCheck,{className:"h-3 w-3"})]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:"Seleccionar todo"})]}),Te.map(ge=>{const Me=!Q||fe.includes(ge.value);return t.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":Me,onClick:()=>Bf(b.key,ge.value,N.map(we=>we.value),Q),className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)]",style:{color:"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border",style:{borderColor:Me?"var(--primary)":"var(--border)",background:Me?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:Me&&t.jsx(P.HiCheck,{className:"h-3 w-3"})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:ge.label})]},ge.value)}),Te.length===0&&t.jsx("div",{className:"px-3 py-3 text-sm text-[var(--text-muted)]",children:"Sin valores"})]})]}):null}),document.body)};s.useEffect(()=>{if(!en)return;function b(N){Qa.current&&!Qa.current.contains(N.target)&&Wn.current&&!Wn.current.contains(N.target)&&jn(!1)}return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[en]);function jl(b,N){if(b.filterValue){const Q=b.filterValue(N);return Q==null||Q===""?"":String(Q)}return nr(b.cell(N))}function Wl(b){return`"${b.replace(/"/g,'""')}"`}function ra(b){return b.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function tb(){const b=it.filter(Te=>!jt(Te)),N=b.map(Te=>Wl(nr(Te.header))).join(","),Q=Jt.map(Te=>b.map(Ke=>Wl(jl(Ke,Te))).join(",")).join(`
5
+ `),D=`${N}
6
+ ${Q}`,re=new Blob(["\uFEFF"+D],{type:"text/csv;charset=utf-8;"}),fe=URL.createObjectURL(re),ve=document.createElement("a");ve.href=fe,ve.download=`${Ae}.csv`,document.body.appendChild(ve),ve.click(),document.body.removeChild(ve),URL.revokeObjectURL(fe)}function rb(){const b=it.filter(ve=>!jt(ve)),N=b.map(ve=>ra(nr(ve.header))),D=Jt.map(ve=>b.map(Te=>ra(jl(Te,ve)))).map(ve=>`<tr>${ve.map(Te=>`<td>${Te}</td>`).join("")}</tr>`).join(""),re=`<!DOCTYPE html>
7
+ <html lang="es"><head><meta charset="utf-8"><title>${ra(Ae)}</title>
8
8
  <style>
9
9
  body{font-family:system-ui,sans-serif;font-size:11px;margin:20px;color:#111}
10
10
  h3{margin:0 0 4px;font-size:14px}
@@ -15,23 +15,23 @@ ${X}`,te=new Blob(["\uFEFF"+A],{type:"text/csv;charset=utf-8;"}),fe=URL.createOb
15
15
  tr:nth-child(even) td{background:#f9f9f9}
16
16
  @media print{body{margin:0}@page{margin:1cm}}
17
17
  </style></head><body>
18
- <h3>${Rn(Le)}</h3>
19
- <p>${Jr.length} registros · ${new Date().toLocaleDateString("es")}</p>
18
+ <h3>${ra(Ae)}</h3>
19
+ <p>${Jt.length} registros · ${new Date().toLocaleDateString("es")}</p>
20
20
  <table><thead><tr>${N.map(ve=>`<th>${ve}</th>`).join("")}</tr></thead>
21
- <tbody>${A}</tbody></table>
21
+ <tbody>${D}</tbody></table>
22
22
  <script>window.onload=()=>{window.print()}<\/script>
23
- </body></html>`,fe=window.open("","_blank");fe&&(fe.document.write(te),fe.document.close())}const ea=()=>!We||!Rt?null:nr.createPortal(r.jsxs("div",{ref:Xa,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...hf,position:"fixed",zIndex:9999,minWidth:170,borderColor:"var(--border)",background:"var(--bg-card)"},children:[r.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:()=>{Kf(),Pn(!1)},children:[r.jsx(F.HiTableCells,{className:"h-4 w-4 shrink-0 text-emerald-500"}),"Descargar CSV / Excel"]}),r.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:()=>{Xf(),Pn(!1)},children:[r.jsx(F.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),ra=()=>{const b=Q&&Mr.trim().length>0,N=pe!=null&&pe.length?pe:b?[{key:"bql",label:"BQL",value:Mr}]:[],X=ie.filter(A=>{const te=A.trim();return te?!new Set(Qt.split(`
24
- `).map(ve=>ve.trim()).filter(Boolean)).has(te):!1}).slice(0,8);return!oe&&Za===0&&!Q&&!We?null:r.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:[r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[Za>0&&r.jsxs("button",{type:"button",onClick:Tf,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:[r.jsx(F.HiXMark,{className:"h-3.5 w-3.5"}),Za," filtros"]}),Q&&r.jsxs("div",{ref:Ya,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[r.jsxs("button",{type:"button",onClick:()=>{if($r){Yr(!1);return}Yn(),Yr(!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:$r?"var(--primary)":b?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:$r||b?"var(--primary)":"var(--border)",color:$r?"var(--primary-fg)":"var(--primary)"},"aria-expanded":$r,title:"Abrir filtros BQL",children:[r.jsx(F.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",b&&r.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),$r?r.jsx(F.HiChevronUp,{className:"h-3.5 w-3.5"}):r.jsx(F.HiChevronDown,{className:"h-3.5 w-3.5"})]}),r.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:ae}),N.length>0&&r.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[N.slice(0,3).map(A=>r.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:[r.jsxs("span",{className:"text-[var(--text-muted)]",children:[A.label,":"]}),r.jsx("span",{className:"truncate",children:A.value})]},A.key)),N.length>3&&r.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",N.length-3]})]}),b&&r.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:xl,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:r.jsx(F.HiXMark,{className:"h-4 w-4"})}),$r&&nr.createPortal(r.jsxs("div",{ref:ll,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...ff,background:"var(--bg-card)",border:"1px solid color-mix(in srgb, var(--primary) 35%, var(--border))"},children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[de.map(A=>r.jsxs("button",{type:"button",onMouseDown:te=>{te.preventDefault(),te.stopPropagation()},onClick:te=>{te.preventDefault(),te.stopPropagation(),Vn(A.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:[A.icon,A.label]},A.label)),Se.length>0&&r.jsxs("button",{type:"button",onClick:()=>vt(A=>!A),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":sl,children:[r.jsx(F.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),Jt.length>0&&r.jsxs("button",{type:"button",onClick:()=>yt(A=>!A),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":ol,children:[r.jsx(F.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]})]}),r.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-input)",border:`1.5px solid ${Ce?"var(--danger)":b?"var(--primary)":"var(--border)"}`},children:[r.jsx("textarea",{ref:Ka,value:Qt,rows:3,onChange:A=>Ja(A.target.value,A.target),onKeyDown:A=>{A.key==="Enter"&&!A.shiftKey&&(A.preventDefault(),yl(Qt)),A.key==="Escape"&&Yr(!1)},placeholder:Y,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"}}),X.length>0&&r.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:X.map(A=>r.jsx("button",{type:"button",onMouseDown:te=>{te.preventDefault(),te.stopPropagation()},onClick:te=>{te.preventDefault(),te.stopPropagation(),Vn(A)},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:A},A))})]}),r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[r.jsx("span",{className:"min-w-0 text-xs",style:{color:Ce?"var(--danger)":"var(--text-muted)"},children:Ce??(b?`${N.length||1} filtro${(N.length||1)===1?"":"s"} activo${(N.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),N.map(A=>r.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:[r.jsxs("span",{className:"text-[var(--text-muted)]",children:[A.label,":"]}),r.jsx("span",{className:"truncate",children:A.value})]},A.key))]}),ol&&Jt.length>0&&r.jsxs("div",{className:"overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-input)]",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-3 py-2",children:[r.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-semibold text-[var(--text-secondary)]",children:[r.jsx(F.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),r.jsxs("button",{type:"button",onClick:()=>{xt([]),yt(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[r.jsx(F.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),Jt.map(A=>r.jsxs("div",{className:"group flex items-center gap-2 border-b border-[var(--border)] px-3 py-2 last:border-b-0",children:[r.jsx("button",{type:"button",onMouseDown:te=>{te.preventDefault(),te.stopPropagation()},onClick:te=>{te.preventDefault(),te.stopPropagation(),Vn(A)},className:"min-w-0 flex-1 text-left",children:r.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:A})}),r.jsx("button",{type:"button",onClick:()=>xt(te=>te.filter(fe=>fe!==A)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:r.jsx(F.HiXMark,{className:"h-3.5 w-3.5"})})]},A))]}),sl&&Se.length>0&&r.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:Se.map(A=>r.jsxs("button",{type:"button",onMouseDown:te=>{te.preventDefault(),te.stopPropagation()},onClick:te=>{te.preventDefault(),te.stopPropagation(),Vn(A.bql),vt(!1)},className:"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-2 text-left transition-colors hover:border-[var(--primary)]",children:[r.jsx("code",{className:"block truncate text-xs text-[var(--primary)]",children:A.bql}),A.description&&r.jsx("span",{className:"mt-1 block text-xs text-[var(--text-muted)]",children:A.description})]},A.bql))}),r.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] pt-3",children:[b&&r.jsxs("button",{type:"button",onClick:xl,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:[r.jsx(F.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),r.jsxs("button",{type:"button",onClick:()=>yl(Qt),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:[r.jsx(F.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),We&&r.jsx("button",{ref:zn,type:"button","aria-haspopup":"menu","aria-expanded":Rt,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var te;const A=(te=zn.current)==null?void 0:te.getBoundingClientRect();A&&gf({top:A.bottom+4,right:window.innerWidth-A.right}),Pn(fe=>!fe)},className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] ${Rt?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:r.jsx(F.HiArrowDownTray,{className:"h-4 w-4"})}),oe&&r.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ge&&Qe==="visibility","aria-label":R,title:R,onClick:A=>kl(A,"visibility"),className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] ${Ge&&Qe==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:r.jsx(F.HiCog6Tooth,{className:"h-4 w-4"})})]})},Hl=()=>{if(!Wf)return null;const b=Wi(Re,ss);return r.jsxs("div",{"aria-busy":a,className:`grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 rounded-b-xl border-t text-xs select-none ${D?"px-2 py-0.5":"px-3 py-1"}`,style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("span",{style:{color:"var(--text-muted)"},children:Rr===0?"0 filas":`${qf}–${Uf} de ${Rr}`}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),r.jsx(_r,{value:String(Nr),onChange:N=>Vf(Number(N)),options:Sl.map(N=>({value:String(N),label:String(N)})),placeholder:"Filas",searchable:!1,disabled:a,height:_,padding:V,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:W}})]})]}),r.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[r.jsx("button",{disabled:a||Re<=1,onClick:()=>os(Re-1),onMouseEnter:N=>{N.currentTarget.disabled||(N.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",N.currentTarget.style.color="var(--primary)")},onMouseLeave:N=>{N.currentTarget.style.background="transparent",N.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:r.jsx(F.HiChevronLeft,{className:"h-3.5 w-3.5"})}),b.map((N,X)=>N==="..."?r.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${X}`):r.jsx("button",{disabled:a,onClick:()=>os(N),onMouseEnter:A=>{A.currentTarget.disabled||N===Re||(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=N===Re?"var(--primary)":"transparent",A.currentTarget.style.color=N===Re?"var(--primary-fg)":"var(--text-muted)"},className:"h-5 w-5 cursor-pointer rounded text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-60",style:{background:N===Re?"var(--primary)":"transparent",color:N===Re?"var(--primary-fg)":"var(--text-muted)"},children:N},N)),r.jsx("button",{disabled:a||Re>=ss,onClick:()=>os(Re+1),onMouseEnter:N=>{N.currentTarget.disabled||(N.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",N.currentTarget.style.color="var(--primary)")},onMouseLeave:N=>{N.currentTarget.style.background="transparent",N.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:r.jsx(F.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),r.jsx("div",{"aria-hidden":"true"})]})},Gf=()=>r.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Gn},children:[Jn(),ea(),ra(),r.jsx("div",{ref:Hr,className:"min-w-0 max-w-full overflow-hidden",children:r.jsxs("div",{role:"table",className:"text-sm",style:{width:tn,minWidth:Zn},children:[r.jsx("div",{role:"rowgroup",style:S?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Qn()}),r.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,o)}).map((b,N)=>r.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Et,borderBottom:`1px solid ${Oe}`},children:[pr&&r.jsx("div",{role:"cell",className:`${D?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`}},"select-cell"),ir.map((X,A)=>r.jsx("div",{role:"cell",className:D?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},children:r.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${ul(N,A)}%`,minWidth:32}})},X.key))]},N))})]})})]}),is="min-w-0 max-w-full overflow-hidden";return U&&er&&!he?r.jsx(on,{rows:o,columns:Math.max(4,ir.length||7)}):!a&&t.length===0&&!Ga?Gf():a&&t.length===0?r.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Gn},children:[Jn(),ea(),ra(),r.jsx("div",{ref:Hr,className:is,children:r.jsx(ds.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:bl,maxWidth:"100%"},defer:!0,children:r.jsxs("div",{role:"table",className:"text-sm",style:{width:tn,minWidth:Zn},children:[r.jsx("div",{role:"rowgroup",style:S?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Qn()}),r.jsx("div",{role:"rowgroup",children:Array.from({length:o}).map((b,N)=>r.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Et,borderBottom:`1px solid ${Oe}`},children:[pr&&r.jsx("div",{role:"cell",className:`${D?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`}},"select-cell"),ir.map((X,A)=>{const te=Kn[X.key],fe=te!==void 0,ve=X.key===as;return r.jsx("div",{role:"cell","data-dt-column-key":X.key,className:D?"px-2 py-1.5":"px-3 py-2",style:fe?{position:"sticky",left:te,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:ve?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Oe}`:`inset 0 -1px 0 ${Oe}`,borderRight:`1px solid ${Oe}`}:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},children:r.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${ul(N,A)}%`,minWidth:32}})},X.key)})]},N))})]})})}),Hl()]}):!a&&t.length===0?r.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Gn},children:[Jn(),ea(),ra(),r.jsx("div",{ref:Hr,className:is,children:r.jsx("div",{role:"table",className:"text-sm",style:{width:tn,minWidth:Zn},children:r.jsx("div",{role:"rowgroup",style:S?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Qn()})})}),r.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-3 border-t px-6 py-12 text-center",style:{borderColor:Oe,background:"linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 58%, transparent), var(--bg-card))"},children:[r.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??r.jsx(F.HiMagnifyingGlass,{className:"h-5 w-5"})}),r.jsx("p",{className:"max-w-sm text-sm font-medium",style:{color:"var(--text-main)"},children:i}),r.jsx("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Ajusta la busqueda o cambia los filtros para ver mas informacion."})]})]}):r.jsxs("div",{className:"w-full min-w-0 max-w-full flex flex-col rounded-lg overflow-hidden",style:{background:"var(--bg-card)",boxShadow:Gn},children:[Jn(),ea(),ra(),r.jsx("div",{ref:Hr,className:is,children:r.jsx(ds.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:bl,maxWidth:"100%"},defer:!0,children:r.jsxs("div",{role:"table",className:"text-sm",style:{width:tn,minWidth:Zn},children:[r.jsx("div",{role:"rowgroup",style:S?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:Qn()}),r.jsx("div",{role:"rowgroup",children:Ml.map((b,N)=>{const X=n(b),A=Dl(k==null?void 0:k(b)),te=N>0?Dl(k==null?void 0:k(Ml[N-1])):null,fe=A&&A.key!==(te==null?void 0:te.key),ve=pr&&$.has(X),$e=pr&&(!T||T(b)),Xe=Ct?(p==null?void 0:p(b))??!0:!1,Ue=Xe&&Cl.has(X),tr=!!d||w&&Xe,Ke=ve&&g?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":N%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return r.jsxs(s.Fragment,{children:[fe&&r.jsx("div",{role:"row",className:`grid ${A.className??""}`,style:{gridTemplateColumns:Et},children:r.jsx("div",{role:"cell",className:D?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-input))",borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},children:r.jsx("div",{className:"flex min-w-0 items-center justify-between gap-3",children:r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"truncate text-xs font-semibold uppercase tracking-wider text-[var(--text-main)]",children:A.label}),A.description&&r.jsx("div",{className:"mt-0.5 truncate text-xs text-[var(--text-muted)]",children:A.description})]})})})}),r.jsxs("div",{role:"row",onClick:tr?ge=>{const Me=ge.target;if(!(Me!=null&&Me.closest('[data-dt-disable-row-click="true"]'))){if(w&&Xe){$l(X);return}d==null||d(b)}}:void 0,className:`grid transition-colors ${tr?"cursor-pointer":""} ${y?y(b):""}`,style:{gridTemplateColumns:Et,"--dt-row-bg":Ke,"--dt-sticky-bg":Ke,background:"var(--dt-row-bg)",borderBottom:`1px solid ${Oe}`},onMouseEnter:ge=>{ve||(ge.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),ge.currentTarget.style.setProperty("--dt-sticky-bg",Yf))},onMouseLeave:ge=>{ge.currentTarget.style.setProperty("--dt-row-bg",Ke),ge.currentTarget.style.setProperty("--dt-sticky-bg",Ke)},children:[Ct&&r.jsx("div",{role:"cell",className:`${D?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},"data-dt-disable-row-click":"true",children:Xe&&r.jsx("button",{type:"button","aria-label":Ue?"Contraer fila":"Desplegar fila","aria-expanded":Ue,onClick:ge=>{ge.stopPropagation(),$l(X)},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]",children:Ue?r.jsx(F.HiChevronDown,{className:"h-4 w-4"}):r.jsx(F.HiChevronRight,{className:"h-4 w-4"})})}),pr&&r.jsx("div",{role:"cell",className:`${D?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:ts?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${Oe}`}:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},onClick:ge=>{ge.stopPropagation(),$e&&h(X)},children:r.jsx(ln,{size:"sm",checked:ve,disabled:!$e,"aria-label":$e?"Seleccionar fila":"Fila no seleccionable",containerClassName:"items-center",className:$e?"cursor-pointer":"cursor-not-allowed opacity-50",onClick:ge=>ge.stopPropagation(),onChange:()=>{$e&&h(X)}})}),ir.map(ge=>{const Me=Kn[ge.key],we=Me!==void 0,ye=ge.key===as,xe=jr(ge);return r.jsx("div",{role:"cell","data-dt-column-key":ge.key,"data-dt-disable-row-click":ge.disableRowClick||xe?"true":void 0,className:`${xe?"px-2 py-1.5 justify-center text-center":`${D?"px-2 py-1.5":"px-3 py-2"} ${Tl(ge.align)}`} flex min-w-0 items-center ${Bi} ${ge.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...we?{position:"sticky",left:Me,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:ye?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Oe}`:`inset 0 -1px 0 ${Oe}`,borderRight:`1px solid ${Oe}`}:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`}},children:r.jsx(Ls,{children:r.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:ge.cell(b)})})},ge.key)})]}),Ue&&u&&r.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:Et},children:r.jsx("div",{role:"cell",className:D?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--bg-input) 60%, var(--bg-card))",borderBottom:`1px solid ${Oe}`},children:u(b)})})]},X)})})]})})}),Hl()]})}const Vi={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 Yi(e,t){if(t.minLength!==void 0&&e.length<t.minLength)return t.message??`Mínimo ${t.minLength} caracteres`;if(t.maxLength!==void 0&&e.length>t.maxLength)return t.message??`Máximo ${t.maxLength} caracteres`;if(!e)return null;if(t.preset){const n=Vi[t.preset];if(!n.pattern.test(e))return t.message??n.message}return t.pattern&&!t.pattern.test(e)?t.message??"Formato inválido":null}const Ki=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function Xi({initialValue:e,type:t,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":t==="number"?"number":"text";return s.useEffect(()=>{var p,f;(p=c.current)==null||p.focus(),d||(f=c.current)==null||f.select()},[d]),r.jsx("input",{ref:c,type:u,value:l,maxLength:n==null?void 0:n.maxLength,onChange:p=>i(p.target.value),onBlur:()=>o(),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),a(l)),p.key==="Escape"&&(p.preventDefault(),o()),(n==null?void 0:n.preset)==="integer"&&!p.ctrlKey&&!p.metaKey&&!Ki.has(p.key)&&!/^[\d-]$/.test(p.key)&&p.preventDefault()},onClick:p=>p.stopPropagation(),className:"w-full min-w-0 border-0 bg-transparent p-0 text-sm text-[var(--text-main)] outline-none"})}function Gi({initialValue:e,options:t,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]),r.jsx("div",{ref:l,className:"w-full",tabIndex:-1,onKeyDown:i=>{i.key==="Escape"&&(i.stopPropagation(),o())},children:r.jsx(_r,{value:e,onChange:i=>{a(i)},options:t,disabled:n,placeholder:n?"Cargando…":"Seleccionar…",triggerVariant:"ghost",height:30,padding:"0 6px",minOptionsForSearch:1,className:"w-full"})})}const Zi={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},ba={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function Qi({columns:e,data:t,getRowId:n,onCellUpdate:a,readOnly:o=!1,...l}){const[i,c]=s.useState(t),d=s.useRef(null);s.useEffect(()=>{d.current||c(t)},[t]);const[u,p]=s.useState(null);d.current=u;const[f,m]=s.useState(null),x=s.useRef(null);x.current=f;const[w,$]=s.useState({}),[h,E]=s.useState(null),T=s.useRef(null);T.current=h;const[g,y]=s.useState({}),[k,S]=s.useState({}),L=s.useRef(new Set),C=s.useRef(null);s.useEffect(()=>{var O;const B=document.activeElement;(!B||B===document.body)&&((O=C.current)==null||O.focus({preventScroll:!0}))},[]);const W=e.map(B=>{var O,oe,v;return`${B.key}:${((v=(oe=(O=B.editable)==null?void 0:O.select)==null?void 0:oe.options)==null?void 0:v.length)??-1}`}).join("|");s.useEffect(()=>{e.forEach(B=>{var v,z;const O=(z=(v=B.editable)==null?void 0:v.select)==null?void 0:z.options;if(!O)return;const oe=g[B.key];(!L.current.has(B.key)||(oe==null?void 0:oe.length)===0&&O.length>0)&&(L.current.add(B.key),y(ee=>({...ee,[B.key]:O})))})},[W]);const _=s.useCallback(async(B,O)=>{if(L.current.has(B))return;L.current.add(B);const{url:oe,fetchOptions:v}=O.select??{};if(!(!oe&&!v)){S(z=>({...z,[B]:!0}));try{let z=[];if(v)z=await v();else if(oe){const ee=await fetch(oe);if(!ee.ok)throw new Error("fetch failed");z=await ee.json()}y(ee=>({...ee,[B]:z}))}catch{y(z=>({...z,[B]:[]}))}finally{S(z=>({...z,[B]:!1}))}}},[]),V=s.useRef(i);V.current=i;const M=s.useRef(a);M.current=a;const Z=s.useRef(n);Z.current=n;const H=s.useRef(e);H.current=e;const ne=s.useRef(o);ne.current=o,s.useEffect(()=>{if(e.length>0&&t.length>0){const B=e.find(O=>O.selectable!==!1);B&&m({rowId:n(t[0]),colKey:B.key})}},[]),s.useEffect(()=>{if(!f)return;const B=C.current;if(!B)return;const O=B.querySelector(`[data-cell-id="${f.rowId}:${f.colKey}"]`);if(!O)return;const oe=B.querySelector('[role="rowgroup"]');O.style.scrollMarginTop=`${(oe==null?void 0:oe.offsetHeight)??0}px`;const v=B.querySelector('[role="row"]');let z=0;v&&v.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(ee=>{ee.style.position==="sticky"&&ee.style.left!==""&&(z=Math.max(z,parseFloat(ee.style.left)+ee.offsetWidth))}),O.style.scrollMarginLeft=`${z}px`,O.scrollIntoView({block:"nearest",inline:"nearest"})},[f]);const U=s.useCallback(B=>{var z;const O=H.current,oe=new Set,v=[];(z=C.current)==null||z.querySelectorAll("[data-cell-id]").forEach(ee=>{const le=ee.dataset.cellId.split(":")[0];oe.has(le)||(oe.add(le),v.push(le))}),m(ee=>{if(!ee)return ee;const le=O.findIndex(J=>J.key===ee.colKey),R=v.indexOf(ee.rowId);let Q=le,I=R;if(B==="up")I=Math.max(0,R-1);else if(B==="down")I=Math.min(v.length-1,R+1);else if(B==="left"){let J=le-1;for(;J>=0&&O[J].selectable===!1;)J--;J>=0&&(Q=J)}else if(B==="right"){let J=le+1;for(;J<O.length&&O[J].selectable===!1;)J++;J<O.length&&(Q=J)}return Q===le&&I===R?ee:{rowId:v[I],colKey:O[Q].key}})},[]),q=s.useCallback((B=!0)=>{const O=d.current;p(null),O&&m(O),B&&setTimeout(()=>{var oe;return(oe=C.current)==null?void 0:oe.focus({preventScroll:!0})},0)},[]),j=s.useCallback(async(B,O,oe)=>{var ie;const v=H.current.find(pe=>pe.key===O);if(!(v!=null&&v.editable))return;const{field:z,type:ee,mask:le,validate:R}=v.editable,Q=ee==="number"?oe===""?null:Number(oe):oe;if(le){const pe=Yi(oe,le);if(pe){$(Ce=>({...Ce,[`${B}:${O}`]:pe}));return}}if(R){const pe=R(Q);if(pe){$(Ce=>({...Ce,[`${B}:${O}`]:pe}));return}}const I=Z.current,J=V.current.find(pe=>I(pe)===B);if(!J)return;const P=J[z];p(null),$(pe=>{const Ce={...pe};return delete Ce[`${B}:${O}`],Ce});const ae=V.current,Y=ae.findIndex(pe=>I(pe)===B),de=ae[Math.min(ae.length-1,Y+1)];if(m({rowId:I(de),colKey:O}),setTimeout(()=>{var Ce,De;const pe=document.activeElement;(!pe||pe===document.body||(Ce=C.current)!=null&&Ce.contains(pe))&&((De=C.current)==null||De.focus({preventScroll:!0}))},0),String(P??"")===String(Q??""))return;const Se={...J,[z]:Q};c(pe=>pe.map(Ce=>I(Ce)===B?Se:Ce)),E({rowId:B,colKey:O});try{await((ie=M.current)==null?void 0:ie.call(M,{row:J,rowId:B,field:z,oldValue:P,newValue:Q}))}catch{c(pe=>pe.map(Ce=>I(Ce)===B?J:Ce)),$(pe=>({...pe,[`${B}:${O}`]:"Error al guardar. Intenta de nuevo."}))}finally{E(null)}},[]),D=s.useCallback(B=>{if(T.current){B.preventDefault();return}if(d.current)return;const O=x.current;if(!(!O||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(B.key)))switch(B.preventDefault(),B.key){case"ArrowUp":U("up");break;case"ArrowDown":U("down");break;case"ArrowLeft":U("left");break;case"ArrowRight":U("right");break;case"Tab":U(B.shiftKey?"left":"right");break;case"Enter":{const v=H.current.find(z=>z.key===O.colKey);v!=null&&v.editable&&!ne.current?(p(O),v.editable.type==="select"&&!L.current.has(O.colKey)&&_(O.colKey,v.editable)):U("down");break}}},[U,_]),se=s.useMemo(()=>e.map(B=>{if(!B.editable||o){const oe={...B};if(delete oe.editable,delete oe.selectable,B.selectable===!1)return{...oe,disableRowClick:!0};const v=oe.cell;return{...oe,className:`relative ${oe.className??""}`.trim(),disableRowClick:!0,cell:z=>{const ee=n(z),le=(f==null?void 0:f.rowId)===ee&&(f==null?void 0:f.colKey)===B.key;return r.jsxs(r.Fragment,{children:[r.jsx("span",{"data-cell-id":`${ee}:${B.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var R;T.current||(m({rowId:ee,colKey:B.key}),(R=C.current)==null||R.focus({preventScroll:!0}))}}),le&&r.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:ba}),r.jsx("span",{className:"relative z-0 pointer-events-none",children:v(z)})]})}}}const O=B.editable;return{...B,className:`relative ${B.className??""}`.trim(),disableRowClick:!0,cell:oe=>{const v=n(oe),z=B.key,ee=(u==null?void 0:u.rowId)===v&&(u==null?void 0:u.colKey)===z,le=(f==null?void 0:f.rowId)===v&&(f==null?void 0:f.colKey)===z,R=w[`${v}:${z}`],Q=(h==null?void 0:h.rowId)===v&&(h==null?void 0:h.colKey)===z,I=oe[O.field],J=String(I??""),P=()=>{var Y;T.current||(m({rowId:v,colKey:z}),p({rowId:v,colKey:z}),(Y=C.current)==null||Y.focus({preventScroll:!0}),O.type==="select"&&!L.current.has(z)&&_(z,O))};if(ee){const Y=O.type==="select"?r.jsx(Gi,{initialValue:J,options:g[z]??[],loading:k[z]??!1,onCommit:de=>j(v,z,de),onCancel:q}):r.jsx(Xi,{initialValue:J,type:O.type??"text",mask:O.mask,onCommit:de=>j(v,z,de),onCancel:q});return r.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:Zi,onClick:de=>de.stopPropagation(),children:Y})}const ae=B.cell(oe);return r.jsxs(r.Fragment,{children:[r.jsx("span",{"data-cell-id":`${v}:${z}`,className:`peer absolute inset-0 z-10 ${Q?"cursor-wait":"cursor-pointer"}`,onClick:P}),le&&!Q&&r.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:ba}),Q&&r.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:ba,children:[r.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}),r.jsx("span",{className:"truncate text-xs text-[var(--text-muted)]",children:"Guardando…"})]}),r.jsx("span",{className:"relative z-0 inline-flex items-center gap-1 pointer-events-none",children:R?r.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[r.jsx(F.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),r.jsx("span",{className:"truncate text-xs",children:R})]}):r.jsx("span",{className:"truncate",children:ae})}),!Q&&r.jsx(F.HiPencil,{className:"pointer-events-none absolute right-1 top-1/2 z-0 h-3 w-3 -translate-y-1/2 shrink-0 text-[var(--text-muted)] opacity-0 transition-opacity peer-hover:opacity-40"})]})}}}),[e,o,u,f,h,w,g,k,n,j,q,_]);return r.jsx("div",{ref:C,tabIndex:0,onKeyDown:D,onBlur:B=>{var O;(O=C.current)!=null&&O.contains(B.relatedTarget)||setTimeout(()=>{var v,z;const oe=document.activeElement;oe&&((v=oe.closest)!=null&&v.call(oe,"[data-bonsaif-select-dropdown]"))||(z=C.current)!=null&&z.contains(oe)||q(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:r.jsx(As,{...l,columns:se,data:i,getRowId:n})})}function Je(e){if(e)return new Date(`${e}T12:00:00`)}function hr(e){const t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${a}`}function st(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ds(e){return e.map(t=>Je(t)).filter(t=>!!t)}function Ji(e){if(!(e!=null&&e.length))return[];const t=new Set(e.map(hr));return Array.from(t).sort()}function ma(e){return new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(e)}function Is(e){const t=Je(e);if(!t)return e;const n=ma(t).replace(/\.$/u,"").replace(/^\w/u,o=>o.toUpperCase()),a=new Intl.DateTimeFormat("es-MX",{month:"short"}).format(t).replace(/\.$/u,"").toLowerCase();return`${n} - ${t.getDate()} ${a} ${t.getFullYear()}`}const pa={weekend:{dayOfWeek:[0,6]}},ha={weekend:"bonsaif-weekend"};function ga({children:e,className:t="",...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 r.jsx("th",{...n,className:`${t} ${o?"bonsaif-weekday-weekend":""}`.trim(),children:e})}const Ri={background:"var(--primary)",color:"var(--primary-fg, #ffffff)",borderRadius:999},ec={background:"color-mix(in srgb, var(--primary) 22%, transparent)",color:"var(--text-main)",borderRadius:999};function rc({day:e,modifiers:t,...n}){const a=t.range_start||t.range_end||t.selected&&!t.range_middle,o=!!t.range_middle,l=!!t.weekend||e.date.getDay()===0||e.date.getDay()===6;return r.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?Ri:null,...o?ec:null,...l?{fontWeight:800}:null,...n.style}})}function tc({startDate:e,endDate:t,onChange:n,minDate:a,viewMonth:o,numberOfMonths:l=1,orientation:i="horizontal",showSummary:c=!0,startLabel:d="Inicio",endLabel:u="Regreso",className:p=""}){const f={from:Je(e),to:Je(t)},m=Je(a),[x,w]=s.useState(()=>Je(o||e)??new Date);s.useEffect(()=>{const g=Je(o||e);g&&w(g)},[o,e]);const $=s.useMemo(()=>{if(l<=1)return st(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(x));const g=new Date(x.getFullYear(),x.getMonth()+l-1,1),y=x.getFullYear()===g.getFullYear(),k=new Intl.DateTimeFormat("es-MX",{month:"short",...y?{}:{year:"numeric"}}).format(x),S=new Intl.DateTimeFormat("es-MX",{month:"short",year:"numeric"}).format(g);return`${st(k)} – ${st(S)}`},[x,l]);function h(){w(new Date(x.getFullYear(),x.getMonth()-1,1))}function E(){w(new Date(x.getFullYear(),x.getMonth()+1,1))}const T=l>1?`bonsaif-range-months bonsaif-range-months--multi bonsaif-range-months--${i}`:"bonsaif-range-months";return r.jsxs("div",{className:`bonsaif-calendar bonsaif-date-range-picker ${p}`.trim(),children:[r.jsxs("div",{className:"bonsaif-cal-shell",children:[r.jsxs("div",{className:"bonsaif-cal-toolbar",children:[r.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes anterior",onClick:h,children:r.jsx(F.HiChevronLeft,{size:16})}),r.jsx("span",{className:"bonsaif-cal-title",children:$}),r.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes siguiente",onClick:E,children:r.jsx(F.HiChevronRight,{size:16})})]}),r.jsx(na.DayPicker,{mode:"range",selected:f,month:x,onMonthChange:w,onSelect:g=>{const y=g!=null&&g.from?hr(g.from):e,k=g!=null&&g.to?hr(g.to):"";n({startDate:y,endDate:k})},numberOfMonths:l,hideNavigation:!0,weekStartsOn:1,disabled:m?{before:m}:void 0,showOutsideDays:!1,modifiers:pa,modifiersClassNames:ha,components:{DayButton:rc,Weekday:ga},classNames:{root:"bonsaif-range-daypicker w-full",months:T,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:g=>`${st(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(g))} ${g.getFullYear()}`,formatWeekdayName:ma}})]}),c?r.jsx("div",{className:"bonsaif-cal-summary",children:e?r.jsxs("div",{className:"bonsaif-cal-chips",children:[r.jsxs("span",{className:"bonsaif-cal-chip bonsaif-cal-chip--static",children:[d,": ",e]}),t?r.jsxs("span",{className:"bonsaif-cal-chip bonsaif-cal-chip--static",children:[u,": ",t]}):null]}):r.jsx("span",{children:"Sin rango seleccionado"})}):null]})}function Os({day:e,modifiers:t,onDayPointerDown:n,onDayPointerEnter:a,onDayClickSelect:o,...l}){const i=!!(t.disabled||t.hidden),c=!!t.weekend||e.date.getDay()===0||e.date.getDay()===6;return r.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 Hs(e,t){const n=Je(e),a=Je(t);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(hr(c)),c.setDate(c.getDate()+1);return i}function Bs(e,t=1){const n=e.getDay(),a=t===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 Ft(e,t,n){const a=new Set(e);for(const o of t)n==="add"?a.add(o):n==="remove"||a.has(o)?a.delete(o):a.add(o);return Array.from(a).sort()}function nc(e,t){return typeof t!="number"||t<=0||e.length<=t?e:e.slice(-t)}function pn(e,t,n){return!!(t&&e<t||n&&e>n)}function Fs({value:e,onChange:t,disabled:n=!1,minDate:a,maxDate:o,maxDates:l,retainOutsidePrefix:i}){const c=s.useRef(null),d=s.useRef(null),u=s.useRef(!1),p=s.useRef(e);p.current=e;const f=s.useCallback(g=>{let y=g;if(i){const k=p.current.filter(L=>!L.startsWith(i)),S=g.filter(L=>L.startsWith(i));y=[...k,...S].sort()}t==null||t(nc(y,l))},[l,t,i]),m=s.useCallback(g=>g.filter(y=>!pn(y,a,o)),[a,o]),x=s.useCallback(()=>{d.current=null},[]);s.useEffect(()=>{const g=()=>x();return window.addEventListener("pointerup",g),window.addEventListener("pointercancel",g),()=>{window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",g)}},[x]);const w=s.useCallback((g,y,k,S)=>{const L=m(Hs(g,y));f(k==="add"?Ft(S,L,"add"):Ft(S,L,"remove"))},[f,m]),$=s.useCallback((g,y)=>{if(n||y.button!==0)return;const k=hr(g);if(pn(k,a,o)||y.shiftKey)return;u.current=!0;const S=[...p.current],L=S.includes(k)?"remove":"add";d.current={active:!0,mode:L,anchor:k,latest:k,baseline:S},c.current=k,w(k,k,L,S),y.preventDefault()},[w,n,o,a]),h=s.useCallback(g=>{const y=d.current;if(!(y!=null&&y.active)||n)return;const k=hr(g);pn(k,a,o)||y.latest!==k&&(y.latest=k,w(y.anchor,k,y.mode,y.baseline))},[w,n,o,a]),E=s.useCallback((g,y)=>{if(n)return;const k=hr(g);if(!pn(k,a,o)){if(u.current&&!y.shiftKey){u.current=!1,y.preventDefault(),y.stopPropagation();return}if(u.current=!1,y.shiftKey&&c.current){y.preventDefault(),y.stopPropagation();const S=m(Hs(c.current,k));f(Ft(p.current,S,"add"));return}c.current=k,f(Ft(p.current,[k],"toggle"))}},[f,n,m,o,a]),T=s.useCallback(g=>{if(n)return;const y=m(Ji(g));if(!y.length)return;const k=y.every(S=>p.current.includes(S));f(Ft(p.current,y,k?"remove":"add")),c.current=y[0]??c.current},[f,n,m]);return{onDayPointerDown:$,onDayPointerEnter:h,onDayClick:E,toggleWeek:T,endDrag:x}}function Pt(e){return Bs(e,1)[0]}function Ps(e,t){const n=new Date(e);return n.setDate(n.getDate()+t),n}function ac({value:e=[],onChange:t,minDate:n,maxDate:a,viewMonth:o,maxDates:l,showWeekNumbers:i=!1,viewMode:c,defaultViewMode:d="month",onViewModeChange:u,showSummary:p=!0,className:f="",disabled:m=!1}){const x=s.useMemo(()=>Ds(e),[e]),w=s.useMemo(()=>new Set(e),[e]),$=Je(n),h=Je(a),[E,T]=s.useState(()=>Je(o||e[0])??new Date),[g,y]=s.useState(()=>Pt(Je(o||e[0])??new Date)),[k,S]=s.useState(d),L=c??k;function C(D){c===void 0&&S(D),u==null||u(D)}s.useEffect(()=>{const D=Je(o);D&&(T(D),y(Pt(D)))},[o]);const{onDayPointerDown:W,onDayPointerEnter:_,onDayClick:V,toggleWeek:M}=Fs({value:e,onChange:t,disabled:m,minDate:n,maxDate:a,maxDates:l}),Z=s.useCallback(D=>r.jsx(Os,{...D,className:`bonsaif-multi-day-btn ${D.className??""}`,onDayPointerDown:W,onDayPointerEnter:_,onDayClickSelect:V}),[V,W,_]),H=s.useMemo(()=>Bs(g,1),[g]),ne=H[6],U=L==="week"?`${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short"}).format(H[0])} – ${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short",year:"numeric"}).format(ne)}`:st(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(E));function q(){if(L==="week"){const D=Ps(g,-7);y(Pt(D)),T(D);return}T(new Date(E.getFullYear(),E.getMonth()-1,1))}function j(){if(L==="week"){const D=Ps(g,7);y(Pt(D)),T(D);return}T(new Date(E.getFullYear(),E.getMonth()+1,1))}return r.jsxs("div",{className:`bonsaif-calendar bonsaif-multi-date-calendar ${f}`,children:[r.jsxs("div",{className:"bonsaif-cal-shell",children:[r.jsxs("div",{className:"bonsaif-cal-view-toggle",role:"tablist","aria-label":"Vista",children:[r.jsx("button",{type:"button",role:"tab","aria-selected":L==="month",className:`bonsaif-cal-view-btn${L==="month"?" is-active":""}`,disabled:m,onClick:()=>{C("month"),T(g)},children:"Mes"}),r.jsx("button",{type:"button",role:"tab","aria-selected":L==="week",className:`bonsaif-cal-view-btn${L==="week"?" is-active":""}`,disabled:m,onClick:()=>{C("week"),y(Pt(E))},children:"Semana"})]}),r.jsxs("div",{className:"bonsaif-cal-toolbar",children:[r.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":L==="week"?"Semana anterior":"Mes anterior",disabled:m,onClick:q,children:r.jsx(F.HiChevronLeft,{size:16})}),r.jsx("span",{className:"bonsaif-cal-title",children:U}),r.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":L==="week"?"Semana siguiente":"Mes siguiente",disabled:m,onClick:j,children:r.jsx(F.HiChevronRight,{size:16})})]}),r.jsxs("p",{className:"bonsaif-cal-hint",children:["Click · Shift+click rango · Arrastra",i&&L==="month"?" · Semana (nº)":"",L==="week"?" · Botón semana completa":""]}),L==="month"?r.jsx(na.DayPicker,{mode:"multiple",required:!1,selected:x,month:E,onMonthChange:T,onSelect:()=>{},hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,showWeekNumber:i,onWeekNumberClick:(D,se)=>{M(se)},disabled:m?!0:[...$?[{before:$}]:[],...h?[{after:h}]:[]],className:"bonsaif-multi-daypicker",modifiers:pa,modifiersClassNames:ha,classNames:{root:"bonsaif-multi-daypicker",months:"bonsaif-multi-months",month:"bonsaif-multi-month",month_caption:"bonsaif-multi-caption-hidden",month_grid:"bonsaif-multi-month-grid",weekdays:i?"bonsaif-multi-weekdays bonsaif-multi-weekdays--with-week":"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:i?"bonsaif-multi-week bonsaif-multi-week--with-week":"bonsaif-multi-week",week_number:"bonsaif-week-number",week_number_header:"bonsaif-week-number-header",day:"bonsaif-multi-day",day_button:"bonsaif-multi-day-btn",selected:"bonsaif-multi-day-selected",today:"bonsaif-multi-day-today",disabled:"bonsaif-multi-day-disabled",hidden:"bonsaif-multi-day-hidden"},components:{DayButton:Z,Weekday:ga},formatters:{formatWeekdayName:ma}}):r.jsxs("div",{className:"bonsaif-week-view",children:[r.jsx("div",{className:"bonsaif-week-view-head",children:H.map(D=>r.jsx("div",{className:"bonsaif-multi-weekday",children:new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(D)},`h-${hr(D)}`))}),r.jsx("div",{className:"bonsaif-week-view-days",children:H.map(D=>{const se=hr(D),B=w.has(se),O=m||(n?se<n:!1)||(a?se>a:!1),oe=se===hr(new Date);return r.jsx("div",{className:`bonsaif-multi-day${B?" bonsaif-multi-day-selected":""}${oe?" bonsaif-multi-day-today":""}${O?" bonsaif-multi-day-disabled":""}`,children:r.jsxs("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:O,"aria-pressed":B,onPointerDown:v=>W(D,v),onPointerEnter:()=>_(D),onClick:v=>V(D,v),children:[r.jsx("span",{className:"bonsaif-week-day-num",children:D.getDate()}),r.jsx("span",{className:"bonsaif-week-day-month",children:new Intl.DateTimeFormat("es-MX",{month:"short"}).format(D)})]})},se)})}),r.jsx("button",{type:"button",className:"bonsaif-week-select-all",disabled:m,onClick:()=>M(H),children:"Marcar / desmarcar semana"})]})]}),p?r.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?r.jsx("span",{children:"Sin fechas seleccionadas"}):r.jsxs(r.Fragment,{children:[r.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"]}),r.jsx("div",{className:"bonsaif-cal-chips",children:e.map(D=>r.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:m,onClick:()=>t==null?void 0:t(e.filter(se=>se!==D)),title:`Quitar ${D}`,children:[Is(D),r.jsx("span",{"aria-hidden":!0,children:"×"})]},D))})]})}):null]})}const sc=Array.from({length:12},(e,t)=>t);function oc({value:e=[],onChange:t,year:n,onYearChange:a,minDate:o,maxDate:l,maxDates:i,showSummary:c=!0,className:d="",disabled:u=!1,readOnly:p=!1}){const f=s.useMemo(()=>Ds(e),[e]),m=Je(o),x=Je(l),w=n??(e[0]?Number(e[0].slice(0,4)):new Date().getFullYear()),[$,h]=s.useState(w);s.useEffect(()=>{typeof n=="number"&&h(n)},[n]);function E(C){h(C),a==null||a(C)}const{onDayPointerDown:T,onDayPointerEnter:g,onDayClick:y}=Fs({value:e,onChange:t,disabled:u||p,minDate:o,maxDate:l,maxDates:i,retainOutsidePrefix:`${$}-`}),k=s.useCallback(C=>r.jsx(Os,{...C,className:`bonsaif-year-day-btn ${C.className??""}`,onDayPointerDown:T,onDayPointerEnter:g,onDayClickSelect:y}),[y,T,g]),S=f.filter(C=>C.getFullYear()===$),L=u?!0:[...m?[{before:m}]:[],...x?[{after:x}]:[]];return r.jsxs("div",{className:`bonsaif-calendar bonsaif-year-multi-date-calendar${p?" bonsaif-year-multi-date-calendar--readonly":""} ${d}`,children:[r.jsxs("div",{className:"bonsaif-cal-shell bonsaif-year-cal-shell",children:[r.jsxs("div",{className:"bonsaif-cal-toolbar",children:[r.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año anterior",disabled:u,onClick:()=>E($-1),children:r.jsx(F.HiChevronLeft,{size:16})}),r.jsx("span",{className:"bonsaif-cal-title",children:$}),r.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año siguiente",disabled:u,onClick:()=>E($+1),children:r.jsx(F.HiChevronRight,{size:16})})]}),!p&&!u?r.jsx("p",{className:"bonsaif-cal-hint",children:"Click · Shift+click rango · Arrastra para marcar varias"}):null,r.jsx("div",{className:"bonsaif-year-cal-grid",children:sc.map(C=>{const W=new Date($,C,1);return r.jsxs("div",{className:"bonsaif-year-cal-month",children:[r.jsx("div",{className:"bonsaif-year-cal-month-title",children:st(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(W))}),r.jsx(na.DayPicker,{mode:"multiple",required:!1,selected:S,month:W,onMonthChange:()=>{},onSelect:()=>{},numberOfMonths:1,hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,disabled:L,className:"bonsaif-year-month-picker",modifiers:pa,modifiersClassNames:ha,classNames:{root:"bonsaif-year-month-picker",months:"bonsaif-year-month-months",month:"bonsaif-year-month-inner",month_caption:"bonsaif-year-month-caption-hidden",month_grid:"bonsaif-year-month-grid",weekdays:"bonsaif-year-weekdays",weekday:"bonsaif-year-weekday",week:"bonsaif-year-week",day:"bonsaif-year-day",day_button:"bonsaif-year-day-btn",selected:"bonsaif-year-day-selected",today:"bonsaif-year-day-today",disabled:"bonsaif-year-day-disabled",hidden:"bonsaif-year-day-hidden"},components:{DayButton:k,Weekday:ga},formatters:{formatWeekdayName:_=>new Intl.DateTimeFormat("es-MX",{weekday:"narrow"}).format(_)}})]},`${$}-${C}`)})})]}),c?r.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?r.jsx("span",{children:"Sin fechas seleccionadas"}):r.jsxs(r.Fragment,{children:[r.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"," ·"," ",$]}),r.jsx("div",{className:"bonsaif-cal-chips",children:e.map(C=>r.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:u||p,onClick:()=>t==null?void 0:t(e.filter(W=>W!==C)),title:`Quitar ${C}`,children:[Is(C),r.jsx("span",{"aria-hidden":!0,children:"×"})]},C))})]})}):null]})}const lc="bonsaif-ui:hide-tooltips";function zs(){window.dispatchEvent(new CustomEvent(lc))}function ic(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function cc({trigger:e,items:t,align:n="end",width:a=220,disabled:o=!1,className:l="",menuClassName:i="",onOpenChange:c}){const[d,u]=s.useState(!1),[p,f]=s.useState(!1),[m,x]=s.useState({}),w=s.useRef(null),$=s.useRef(null),h=s.useCallback(k=>{u(k),c==null||c(k)},[c]),E=s.useCallback(()=>{const k=w.current;if(!k)return;const S=k.getBoundingClientRect(),L=typeof a=="number"?a:S.width,C=typeof a=="number"?a:Math.max(S.width,180),W=n==="end"?Math.max(8,S.right-C):Math.min(S.left,window.innerWidth-C-8),_=window.innerHeight-S.bottom,V=_<240&&S.top>_?void 0:S.bottom+6,M=V===void 0?window.innerHeight-S.top+6:void 0;x({position:"fixed",zIndex:9999,left:W,top:V,bottom:M,width:ic(typeof a=="number"?L:a)})},[n,a]);s.useEffect(()=>f(!0),[]),s.useEffect(()=>{if(!d)return;E();const k=L=>{var W,_;const C=L.target;!((W=w.current)!=null&&W.contains(C))&&!((_=$.current)!=null&&_.contains(C))&&h(!1)},S=L=>{L.key==="Escape"&&h(!1)};return document.addEventListener("mousedown",k),window.addEventListener("keydown",S),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0),()=>{document.removeEventListener("mousedown",k),window.removeEventListener("keydown",S),window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[d,h,E]);const T=k=>{o||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),h(!d))},g=s.isValidElement(e)?s.cloneElement(e,{onClick:()=>{o||(zs(),h(!d))}}):e,y=d?r.jsx("div",{ref:$,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${i}`,style:m,children:t.map(k=>r.jsxs("div",{children:[k.separatorBefore&&r.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),r.jsxs("button",{type:"button",role:"menuitem",disabled:k.disabled,onClick:()=>{var S;k.disabled||(zs(),(S=k.onSelect)==null||S.call(k),h(!1))},className:"flex w-full min-w-0 items-start gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:k.danger?"var(--danger)":"var(--text-main)"},children:[k.icon&&r.jsx("span",{className:"mt-0.5 shrink-0",children:k.icon}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block truncate text-sm font-medium",children:k.label}),k.description&&r.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:k.description})]})]})]},k.id))}):null;return r.jsxs("span",{ref:w,role:"button",tabIndex:o?-1:0,"aria-haspopup":"menu","aria-expanded":d,onKeyDown:T,className:`inline-flex ${o?"pointer-events-none opacity-60":""} ${l}`,children:[g,p&&y?nr.createPortal(y,document.body):null]})}const dc=180,_s="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function uc({open:e,onClose:t,title:n,subtitle:a,leadingIcon:o,confirmLabel:l="Guardar",onConfirm:i,loading:c=!1,confirmDisabled:d=!1,headerActions:u,bodyClassName:p="flex-1 overflow-y-auto px-6 py-5",width:f=440,hasUnsavedChanges:m=!1,unsavedChangesTitle:x="Descartar cambios",unsavedChangesDescription:w="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:$="Descartar",unsavedChangesCancelLabel:h="Seguir editando",onDiscardChanges:E,disabled:T=!1,disabledMessage:g,children:y}){const[k,S]=s.useState(!1),[L,C]=s.useState(!1),[W,_]=s.useState(!1),V=s.useCallback(()=>{C(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>_(!0))})},[]),M=s.useCallback(()=>{_(!1),window.setTimeout(()=>C(!1),dc)},[]),Z=T||c,H=s.useCallback(()=>{if(!Z){if(m){V();return}t()}},[Z,m,t,V]),ne=s.useCallback(()=>{_(!1),C(!1),E==null||E(),t()},[t,E]);if(s.useEffect(()=>{S(!0)},[]),s.useEffect(()=>(document.body.style.overflow=e?"hidden":"",e||(_(!1),C(!1)),()=>{document.body.style.overflow=""}),[e]),s.useEffect(()=>{if(!e)return;const q=j=>{if(j.key==="Escape"&&!Z){if(L){M();return}H()}};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[M,Z,L,e,H]),!k)return null;const U=g!==void 0?g:c?"Guardando…":null;return nr.createPortal(r.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:[r.jsx("div",{className:`absolute inset-0 ${_s}`,onClick:H}),r.jsxs("div",{className:`absolute inset-y-0 right-0 flex flex-col shadow-2xl transition-transform duration-300 ${e?"translate-x-0":"translate-x-full"}`,style:{width:`min(100vw, ${f}px)`,background:"var(--bg-card)",borderLeft:"1px solid var(--border)"},children:[r.jsxs("div",{className:"flex items-center justify-between px-6 py-4 flex-shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[r.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[r.jsx(je,{variant:"icon",onClick:H,title:"Cerrar",disabled:Z,children:r.jsx(F.HiXMark,{className:"w-5 h-5"})}),o&&r.jsx("div",{className:"flex-shrink-0",children:o}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("h3",{className:"text-base font-semibold truncate",style:{color:"var(--text-main)"},children:n}),a&&r.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:a})]})]}),(u||i)&&r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[u,i&&r.jsxs(r.Fragment,{children:[r.jsx(je,{variant:"secondary",size:"sm",onClick:H,disabled:Z,style:{background:"var(--bg-input)"},children:"Cancelar"}),r.jsx(je,{variant:"primary",size:"sm",icon:r.jsx(Pl.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:d||Z,title:l})]})]})]}),r.jsx("div",{"data-drawer-scroll":"true",className:p,children:y}),Z&&r.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:U?r.jsxs("div",{className:"flex max-w-xs flex-col items-center gap-3 text-center",children:[r.jsx("div",{className:"h-9 w-9 animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]","aria-hidden":!0}),r.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:U})]}):null})]}),L&&r.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":x,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[r.jsx("div",{className:`absolute inset-0 ${_s} transition-opacity duration-200 ease-out ${W?"opacity-100":"opacity-0"}`,onClick:M}),r.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 ${W?"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:[r.jsx(je,{variant:"icon",onClick:M,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":h,children:r.jsx(F.HiXMark,{className:"h-4 w-4"})}),r.jsx("div",{className:"mb-4 flex h-11 w-11 items-center justify-center rounded-xl",style:{background:"var(--warning-bg, #fff7ed)"},children:r.jsx(F.HiExclamationTriangle,{className:"h-5 w-5",style:{color:"var(--warning, #d97706)"}})}),r.jsx("h2",{className:"mb-1 text-base font-semibold",style:{color:"var(--text-main, #0f2f2c)"},children:x}),r.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:w}),r.jsxs("div",{className:"mt-6 flex gap-2",children:[r.jsx(je,{variant:"secondary",onClick:M,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:h}),r.jsx(je,{variant:"secondary",onClick:ne,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:$})]})]})]})]}),document.body)}const fc=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,bc=/^\+?[0-9\s().-]+$/,mc=7,pc=15;function gr(e){return e==null||String(e).trim()===""}function js(e){return typeof e=="number"?e:typeof e=="string"&&e.trim()!==""?Number(e):Number.NaN}function va(e){return gr(e)?!1:fc.test(String(e))}function ya(e){if(gr(e))return!1;const t=String(e),n=t.replace(/\D/g,"");return bc.test(t)&&n.length>=mc&&n.length<=pc}function hc(e="Este campo es requerido."){return t=>gr(t)?e:void 0}function gc(e="Ingresa un correo valido."){return t=>gr(t)||va(t)?void 0:e}function vc(e="Ingresa un telefono valido."){return t=>gr(t)||ya(t)?void 0:e}function yc(e,t){return n=>gr(n)||String(n).length>=e?void 0:t??`Debe tener al menos ${e} caracteres.`}function xc(e,t){return n=>gr(n)||String(n).length<=e?void 0:t??`Debe tener ${e} caracteres o menos.`}function wc(e,t){return n=>{if(gr(n))return;const a=js(n);return Number.isFinite(a)&&a>=e?void 0:t??`Debe ser mayor o igual a ${e}.`}}function kc(e,t){return n=>{if(gr(n))return;const a=js(n);return Number.isFinite(a)&&a<=e?void 0:t??`Debe ser menor o igual a ${e}.`}}function Nc(e,t="El formato no es valido."){return n=>gr(n)||e.test(String(n))?void 0:t}function Sc(e,t){const n={};for(const a of Object.keys(t)){const o=t[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 Ws={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},qs=s.createContext&&s.createContext(Ws),Cc=["attr","size","title"];function Ec(e,t){if(e==null)return{};var n,a,o=Mc(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a<l.length;a++)n=l[a],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function Mc(e,t){if(e==null)return{};var n={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(t.indexOf(a)!==-1)continue;n[a]=e[a]}return n}function hn(){return hn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},hn.apply(null,arguments)}function Us(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,a)}return n}function gn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Us(Object(n),!0).forEach(function(a){$c(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Us(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function $c(e,t,n){return(t=Tc(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Tc(e){var t=Lc(e,"string");return typeof t=="symbol"?t:t+""}function Lc(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var a=n.call(e,t);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Vs(e){return e&&e.map((t,n)=>s.createElement(t.tag,gn({key:n},t.attr),Vs(t.child)))}function xa(e){return t=>s.createElement(Ac,hn({attr:gn({},e.attr)},t),Vs(e.child))}function Ac(e){var t=n=>{var{attr:a,size:o,title:l}=e,i=Ec(e,Cc),c=o||n.size||"1em",d;return n.className&&(d=n.className),e.className&&(d=(d?d+" ":"")+e.className),s.createElement("svg",hn({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,i,{className:d,style:gn(gn({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 qs!==void 0?s.createElement(qs.Consumer,null,n=>t(n)):t(Ws)}function Ys(e){return xa({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 Dc(e){return xa({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 Ic(e){return xa({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 ot({content:e,ariaLabel:t="Más información",className:n=""}){return r.jsx(zr,{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:r.jsx("span",{tabIndex:0,role:"img","aria-label":t,className:"inline-flex items-center justify-center outline-none",children:r.jsx(F.HiInformationCircle,{className:"h-3.5 w-3.5"})})})}function lt({error:e,helperText:t,helperDisplay:n="inline"}){return e?r.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:e}):t&&n!=="tooltip"?r.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:t}):null}function vn({className:e="",...t}){return r.jsx("input",{...t,className:`h-10 rounded-lg border border-[var(--border)] bg-[var(--bg-input)] px-2.5 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] ${e}`})}function wa({label:e,containerClassName:t="",helperText:n,helperDisplay:a="inline",error:o,errorDisplay:l="inline",errorTooltipLabel:i="Error de validacion",labelAction:c,floatingLabel:d=!1,showPasswordToggle:u=!0,nativeValidation:p=!1,className:f="",required:m,...x}){const[w,$]=s.useState(()=>!!x.autoFocus),[h,E]=s.useState(!1),T=x.type==="password"&&u,g=T&&h?"text":x.type,y=!!o,k=y&&l!=="tooltip",S=y&&l!=="inline",L=!!n&&a==="tooltip"&&!k,C=p?m:void 0,W=y?"border-[var(--danger)] focus:border-[var(--danger)]":"",_=S?T?"pr-20":"pr-10":T?"pr-10":"",V=x.value!==void 0?String(x.value).length>0:x.defaultValue!==void 0&&String(x.defaultValue).length>0,M=w||V,Z={top:M?7:12,color:w?"var(--primary)":"var(--text-muted)",fontSize:M?10:13,fontWeight:M?600:400,textTransform:M?"uppercase":"none"},H=D=>{var se;$(!0),(se=x.onFocus)==null||se.call(x,D)},ne=D=>{var se;$(!1),(se=x.onBlur)==null||se.call(x,D)},U=T?r.jsxs("button",{type:"button","aria-label":h?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":h,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors duration-200 hover:text-[var(--primary)] focus:outline-none",tabIndex:-1,onClick:()=>E(D=>!D),children:[r.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${h?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:r.jsx(Dc,{className:"h-[18px] w-[18px]"})}),r.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${h?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:r.jsx(Ic,{className:"h-[18px] w-[18px]"})})]}):null,q=S?r.jsx(zr,{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)] ${T?"right-10":"right-2.5"}`,children:r.jsx("span",{tabIndex:0,role:"img","aria-label":i,className:"flex h-full w-full items-center justify-center outline-none",children:r.jsx(Ys,{className:"h-[18px] w-[18px]"})})}):null,j=r.jsx(lt,{error:k?o:void 0,helperText:n,helperDisplay:a});return d?r.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[r.jsxs("span",{className:"relative block",children:[r.jsx(vn,{...x,type:g,required:C,placeholder:" ","aria-invalid":y||x["aria-invalid"],"data-has-value":V?"true":void 0,className:`h-11 w-full pt-5 ${_} ${W} ${f}`,onFocus:H,onBlur:ne}),r.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:Z,children:[e,m&&r.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),c&&r.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:M?7:12},children:c}),q,U]}),j]}):r.jsxs("label",{className:`flex flex-col gap-2 ${t}`,children:[r.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[r.jsx("span",{children:e}),m&&r.jsx("span",{className:"text-[var(--danger)]",children:"*"}),L?r.jsx(ot,{content:n}):null,c&&r.jsx("span",{className:"ml-auto normal-case",children:c})]}),T?r.jsxs("span",{className:"relative block",children:[r.jsx(vn,{...x,type:g,required:C,"aria-invalid":y||x["aria-invalid"],className:`w-full ${_} ${W} ${f}`,onFocus:H,onBlur:ne}),q,U]}):r.jsxs("span",{className:"relative block",children:[r.jsx(vn,{...x,required:C,"aria-invalid":y||x["aria-invalid"],className:`w-full ${_} ${W} ${f}`}),q]}),j]})}function Ks(e){return e==null?"":String(e)}function Oc({autoComplete:e="email",inputMode:t="email",validate:n=!0,invalidMessage:a="Ingresa un correo valido.",errorDisplay:o="tooltip",error:l,value:i,defaultValue:c,onChange:d,...u}){const[p,f]=s.useState(()=>Ks(c)),m=i!==void 0?Ks(i):p,x=n&&m.length>0&&!va(m)?a:void 0,w=$=>{i===void 0&&f($.currentTarget.value),d==null||d($)};return r.jsx(wa,{...u,value:i,defaultValue:c,type:"text",inputMode:t,autoComplete:e,error:l??x,errorDisplay:o,onChange:w})}const Hc={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function Bc({title:e="Sin resultados",description:t,icon:n=r.jsx(F.HiInbox,{className:"h-5 w-5"}),action:a,secondaryAction:o,size:l="md",className:i=""}){return r.jsx("div",{className:`flex items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] text-center ${Hc[l]} ${i}`,children:r.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[n&&r.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}),r.jsxs("div",{className:"space-y-1",children:[e&&r.jsx("h3",{className:"text-sm font-semibold text-[var(--text-main)]",children:e}),t&&r.jsx("div",{className:"text-sm leading-5 text-[var(--text-muted)]",children:t})]}),(a||o)&&r.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[o,a]})]})})}const Fc={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function Pc(e){if(e===0)return"0 B";const t=["B","KB","MB","GB"],n=Math.min(Math.floor(Math.log(e)/Math.log(1024)),t.length-1),a=e/1024**n;return`${a>=10||n===0?a.toFixed(0):a.toFixed(1)} ${t[n]}`}function Xs(e,t){return t?t.split(",").map(n=>n.trim().toLowerCase()).filter(Boolean).some(n=>{const a=e.name.toLowerCase(),o=e.type.toLowerCase();return n.startsWith(".")?a.endsWith(n):n.endsWith("/*")?o.startsWith(n.slice(0,-1)):o===n}):!0}function zc(e,t,n){return t?n===void 0?e:e.slice(0,Math.max(0,n)):e.slice(0,1)}function _c({label:e,helperText:t,helperDisplay:n="inline",error:a,labelAction:o,value:l,defaultValue:i=[],onFilesChange:c,onRejectedFiles:d,multiple:u=!1,maxFiles:p,appendFiles:f=!1,showFileList:m=!0,clearable:x=!0,browseLabel:w="Buscar archivos",dropLabel:$="Suelta los archivos aqui",emptyLabel:h="Arrastra y suelta archivos",emptyDescription:E="o haz click para buscarlos en tu equipo",selectedLabel:T="Archivos seleccionados",size:g="md",containerClassName:y="",dropzoneClassName:k="",fileListClassName:S="",className:L="",id:C,accept:W,disabled:_,required:V,...M}){const Z=s.useId(),H=C??Z,ne=s.useRef(null),[U,q]=s.useState(!1),[j,D]=s.useState(i),se=l??j,B=!!a,O=!!t&&n==="tooltip"&&!B,oe=x&&se.length>0&&!_,v=(Y,de)=>{l===void 0&&D(Y),c==null||c(Y,de)},z=(Y,de)=>{const Se=Y.filter(De=>Xs(De,W)),ie=Y.filter(De=>!Xs(De,W)),pe=f?[...se,...Se]:Se,Ce=zc(pe,u,p);ie.length>0&&(d==null||d(ie)),v(Ce,de)},ee=()=>{var Y;_||(Y=ne.current)==null||Y.click()},le=Y=>{z(Array.from(Y.target.files??[]),Y),Y.target.value=""},R=Y=>{Y.preventDefault(),_||q(!0)},Q=Y=>{Y.currentTarget.contains(Y.relatedTarget)||q(!1)},I=Y=>{Y.preventDefault(),q(!1),!_&&z(Array.from(Y.dataTransfer.files),Y)},J=Y=>{Y.key!=="Enter"&&Y.key!==" "||(Y.preventDefault(),ee())},P=Y=>{v(se.filter((de,Se)=>Se!==Y))},ae=()=>{v([])};return r.jsxs("div",{className:`flex flex-col gap-2 ${y}`,children:[(e||o||O)&&r.jsxs("div",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e&&r.jsx("span",{children:e}),V&&r.jsx("span",{className:"text-[var(--danger)]",children:"*"}),O?r.jsx(ot,{content:t}):null,o&&r.jsx("span",{className:"ml-auto normal-case",children:o})]}),r.jsx("input",{...M,ref:ne,id:H,type:"file",accept:W,multiple:u,disabled:_,required:V&&se.length===0,"aria-invalid":B||M["aria-invalid"],className:"sr-only",onChange:le}),r.jsxs("div",{role:"button",tabIndex:_?-1:0,"aria-controls":H,"aria-disabled":_||void 0,"aria-invalid":B||void 0,className:`flex cursor-pointer flex-col items-center justify-center gap-3 rounded-lg border border-dashed bg-[var(--bg-card)] text-center outline-none transition-colors focus:border-[var(--primary)] focus:bg-[var(--bg-input)] ${Fc[g]} ${U?"border-[var(--primary)] bg-[var(--bg-input)]":B?"border-[var(--danger)]":"border-[var(--border)]"} ${_?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${k} ${L}`,onClick:ee,onDragOver:R,onDragLeave:Q,onDrop:I,onKeyDown:J,children:[r.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:r.jsx(F.HiArrowUpTray,{className:"h-5 w-5"})}),r.jsxs("span",{className:"space-y-1",children:[r.jsx("span",{className:"block text-sm font-semibold text-[var(--text-main)]",children:U?$:h}),E&&r.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:E})]}),w&&r.jsx("span",{className:"inline-flex h-9 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-card)] px-3 text-xs font-semibold text-[var(--text-main)] shadow-sm shadow-black/5 transition-colors",children:w})]}),m&&se.length>0&&r.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${S}`,children:[r.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-2",children:[r.jsx("span",{className:"text-xs font-semibold uppercase text-[var(--text-muted)]",children:T}),oe&&r.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":"Quitar todos los archivos",onClick:ae,children:r.jsx(F.HiTrash,{className:"h-4 w-4"})})]}),r.jsx("ul",{className:"divide-y divide-[var(--border)]",children:se.map((Y,de)=>r.jsxs("li",{className:"flex items-center gap-3 px-3 py-2",children:[r.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:r.jsx(F.HiDocument,{className:"h-4 w-4"})}),r.jsxs("span",{className:"min-w-0 flex-1 text-left",children:[r.jsx("span",{className:"block truncate text-sm font-medium text-[var(--text-main)]",children:Y.name}),r.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:Pc(Y.size)})]}),!_&&r.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 ${Y.name}`,onClick:()=>P(de),children:r.jsx(F.HiXMark,{className:"h-4 w-4"})})]},`${Y.name}-${Y.lastModified}-${de}`))})]}),r.jsx(lt,{error:a,helperText:t,helperDisplay:n})]})}const jc=[{value:"texto",label:"texto"},{value:"numero",label:"número"},{value:"fecha",label:"fecha"},{value:"booleano",label:"booleano"},{value:"email",label:"email"},{value:"telefono",label:"teléfono"},{value:"select",label:"select"},{value:"textarea",label:"textarea"},{value:"archivo",label:"archivo"},{value:"imagen",label:"imagen"}];function Wc({fields:e,title:t="Layout",fieldTypes:n=jc,saveLabel:a="Guardar",allowAddField:o=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:d,onChange:u}){const[p,f]=s.useState(()=>e.map(g=>({key:!1,type:"",...g}))),[m,x]=s.useState(""),[w,$]=s.useState(""),h=s.useCallback((g,y)=>{f(k=>{const S=k.map((L,C)=>C===g?{...L,...y}:L);return u==null||u(S),S})},[u]),E=s.useCallback(()=>{d==null||d(p)},[p,d]),T=s.useCallback(()=>{var S;const g=m.trim();if(!g){$("Ingresa un nombre de campo.");return}if(p.some(L=>L.name.toLowerCase()===g.toLowerCase())){$("Ese campo ya existe en el arreglo.");return}const k={name:g,key:!1,type:((S=n[0])==null?void 0:S.value)??""};f(L=>{const C=[...L,k];return u==null||u(C),C}),x(""),$("")},[n,p,m,u]);return r.jsxs("div",{className:"flex flex-col rounded-xl border shadow-sm",style:{borderColor:"var(--border)",background:"var(--bg-card)",color:"var(--text-main)"},children:[r.jsx("div",{className:"border-b px-6 py-4",style:{borderColor:"var(--border)"},children:r.jsx("span",{className:"text-base font-semibold",style:{color:"var(--text-main)"},children:t})}),r.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:[r.jsx("span",{children:"Campo"}),r.jsx("span",{className:"text-center",children:"Llave"}),r.jsx("span",{children:"Tipo de Campo"})]}),r.jsxs("div",{className:"max-h-[420px] overflow-y-auto",children:[p.map((g,y)=>r.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:[r.jsx("span",{className:"text-sm font-medium",style:{color:"var(--text-main)"},children:g.name}),r.jsx("div",{className:"flex justify-center",children:r.jsx(ln,{size:"sm",checked:g.key??!1,onChange:k=>h(y,{key:k.target.checked}),"aria-label":`${g.name} es clave`})}),r.jsx(_r,{value:g.type??"",onChange:k=>h(y,{type:k}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${g.name}`})]},g.name)),p.length===0&&r.jsx("p",{className:"px-6 py-8 text-center text-sm",style:{color:"var(--text-muted)"},children:"No hay campos disponibles."})]}),r.jsx("div",{className:"flex justify-end border-t px-6 py-4",style:{borderColor:"var(--border)"},children:r.jsxs("div",{className:"w-full space-y-2",children:[o&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{type:"text",value:m,onChange:g=>{x(g.currentTarget.value),w&&$("")},onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),T())},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"}),r.jsx(je,{variant:"secondary",onClick:T,height:36,padding:"0 12px",children:i})]}),w&&r.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:w})]}),r.jsx("div",{className:"flex justify-end",children:r.jsx(je,{variant:"primary",onClick:E,disabled:c,loading:c,children:a})})]})})]})}function ka({label:e,children:t,helperText:n,helperDisplay:a="inline",error:o,labelAction:l,required:i=!1,className:c="",contentClassName:d=""}){const u=!!n&&a==="tooltip"&&!o;return r.jsxs("label",{className:`flex flex-col gap-2 ${c}`,children:[(e||l||u)&&r.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e&&r.jsx("span",{children:e}),i&&r.jsx("span",{className:"text-[var(--danger)]",children:"*"}),u?r.jsx(ot,{content:n}):null,l&&r.jsx("span",{className:"ml-auto normal-case",children:l})]}),r.jsx("span",{className:`block ${d}`,children:t}),r.jsx(lt,{error:o,helperText:n,helperDisplay:a})]})}function qc(e){return Array.from(e.querySelectorAll("img")).filter(t=>!!(t.currentSrc||t.src||"").trim())}function Gs(e,t){const n=e.target;if(!(n instanceof HTMLImageElement))return!1;const a=e.currentTarget,o=qc(a),l=o.indexOf(n);if(l<0)return!1;e.preventDefault(),e.stopPropagation();const i=n.getBoundingClientRect();return t(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 dr=260,it=420,Na=380,vr="cubic-bezier(0.22, 1, 0.36, 1)",Uc="cubic-bezier(0.16, 1, 0.3, 1)",Sa="cubic-bezier(0.22, 1, 0.36, 1)",Vc="cubic-bezier(0.22, 1, 0.36, 1)",Yc=8,Kc=1,Xc=1.25,Ca={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)"},Gc="color-mix(in srgb, var(--bg-card) 88%, var(--primary) 12%)",Ea=10;function zt(e,t,n){return Math.min(n,Math.max(t,e))}function Zc(e){return!e||e.width<1||e.height<1?null:{left:e.left,top:e.top,width:e.width,height:e.height}}function Zs(e,t){if(t.width<1||t.height<1)return{dx:0,dy:0,scale:1};const n=Math.min(e.width/t.width,e.height/t.height),a=e.left+e.width/2-(t.left+t.width/2),o=e.top+e.height/2-(t.top+t.height/2);return{dx:a,dy:o,scale:Number.isFinite(n)?n:1}}function ct({label:e,onClick:t,children:n,disabled:a,size:o="md"}){const l=o==="lg"?44:40;return r.jsx("button",{type:"button","aria-label":e,title:e,disabled:a,onClick:i=>{i.stopPropagation(),t()},className:"inline-flex items-center justify-center rounded-full disabled:cursor-not-allowed disabled:opacity-35",style:{...Ca,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=Gc,i.currentTarget.style.transform="scale(1.06)")},onMouseLeave:i=>{i.currentTarget.style.background=String(Ca.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 Qs({open:e,onClose:t,slides:n,index:a,onIndexChange:o,originRect:l=null,maxZoom:i=Yc,minZoom:c=Kc,zoomStep:d=Xc,closeOnBackdrop:u=!0,closeOnEscape:p=!0,showCounter:f=!0,showZoomControls:m=!0,loop:x=!0,showThumbnails:w=!0,zIndex:$=1100,ariaLabel:h="Visor de imagen"}){const[E,T]=s.useState(!1),[g,y]=s.useState(!1),[k,S]=s.useState(a??0),[L,C]=s.useState(1),[W,_]=s.useState({x:0,y:0}),[V,M]=s.useState({opacity:1,x:0,scale:1,blur:0,animate:!1}),[Z,H]=s.useState({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),[ne,U]=s.useState(!1),q=s.useRef(null),j=s.useRef(null),D=s.useRef(null),se=s.useRef(null),B=s.useRef(null),O=s.useRef(!1),oe=s.useRef(!1),v=s.useRef(null),z=s.useRef(null),ee=s.useRef(null),le=s.useRef(null),R=s.useRef(null),Q=s.useRef(a??0),I=a??k,J=n.length===0?0:zt(I,0,Math.max(0,n.length-1)),P=n[J],ae=n.length>1,Y=Math.max(c,i),de=w&&ae,Se=s.useCallback(ce=>{if(n.length===0)return;const ue=n.length-1,Ee=x?(ce%n.length+n.length)%n.length:zt(ce,0,ue);a===void 0&&S(Ee),o==null||o(Ee)},[a,x,o,n.length]),ie=s.useCallback(()=>{C(1),_({x:0,y:0})},[]),pe=s.useCallback((ce,ue)=>{if(ue<=c+.001)return{x:0,y:0};const Ee=le.current,Ie=R.current;if(!Ee||!Ie)return ce;const Ae=Ee.getBoundingClientRect(),Pe=Ie.offsetWidth*ue,Ge=Ie.offsetHeight*ue,Ze=Math.max(0,(Pe-Ae.width)/2+Ae.width*.15),Qe=Math.max(0,(Ge-Ae.height)/2+Ae.height*.15);return{x:zt(ce.x,-Ze,Ze),y:zt(ce.y,-Qe,Qe)}},[c]),Ce=s.useCallback(()=>{T(!1),H({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),se.current=null,B.current=null,O.current=!1,oe.current=!1,v.current&&(clearTimeout(v.current),v.current=null)},[]),De=s.useCallback(()=>{if(O.current)return;O.current=!0,y(!1),ie();const ce=se.current,ue=ce!=null&&B.current!=null&&B.current===J;if(ce&&ue){D.current!=null&&cancelAnimationFrame(D.current),D.current=requestAnimationFrame(()=>{D.current=requestAnimationFrame(()=>{const Ee=R.current;if(!Ee){D.current=null,q.current&&clearTimeout(q.current),q.current=setTimeout(Ce,dr+40);return}const Ie=Ee.getBoundingClientRect(),Ae=Zs(ce,Ie);H({enabled:!0,dx:0,dy:0,scale:1,animate:!1}),D.current=requestAnimationFrame(()=>{H({enabled:!0,dx:Ae.dx,dy:Ae.dy,scale:Ae.scale,animate:!0}),D.current=null})})}),q.current&&clearTimeout(q.current),q.current=setTimeout(Ce,it+80);return}H({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),q.current&&clearTimeout(q.current),q.current=setTimeout(Ce,dr+40)},[Ce,ie,J]);s.useEffect(()=>(e?(q.current&&clearTimeout(q.current),v.current&&(clearTimeout(v.current),v.current=null),O.current=!1,oe.current=!1,se.current=Zc(l),B.current=se.current!=null?a??k:null,T(!0),y(!1),se.current?H({dx:0,dy:0,scale:1,animate:!1,enabled:!0}):(B.current=null,requestAnimationFrame(()=>requestAnimationFrame(()=>{y(!0),H({dx:0,dy:0,scale:1,animate:!1,enabled:!1})})))):E&&De(),()=>{q.current&&clearTimeout(q.current),D.current!=null&&cancelAnimationFrame(D.current)}),[e]);const mr=s.useCallback(()=>{if(!e||O.current||oe.current)return;const ce=se.current,ue=R.current;if(!ce||!ue){ce||(y(!0),oe.current=!0);return}const Ee=ue.getBoundingClientRect();if(Ee.width<2||Ee.height<2)return;oe.current=!0;const Ie=Zs(ce,Ee);H({enabled:!0,dx:Ie.dx,dy:Ie.dy,scale:Ie.scale,animate:!1}),D.current!=null&&cancelAnimationFrame(D.current),D.current=requestAnimationFrame(()=>{D.current=requestAnimationFrame(()=>{H({enabled:!0,dx:0,dy:0,scale:1,animate:!0}),y(!0),D.current=null,v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{H({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),v.current=null},it+20)})})},[e]);s.useLayoutEffect(()=>{!E||!e||!se.current||oe.current||mr()},[E,e,mr]),s.useEffect(()=>{!e||O.current||B.current!=null&&B.current!==J&&H(ce=>ce.enabled?{dx:0,dy:0,scale:1,animate:!1,enabled:!1}:ce)},[e,J]),s.useEffect(()=>{if(!e)return;const ce=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=ce}},[e]),s.useEffect(()=>{e&&ie()},[e,J,ie]),s.useEffect(()=>{a!==void 0&&S(a)},[a]),s.useEffect(()=>{if(!e){Q.current=J,M({opacity:1,x:0,scale:1,blur:0,animate:!1});return}const ce=Q.current;if(ce===J)return;Q.current=J;const ue=n.length;let Ee=1;if(ue>1){const Ie=(ce+1)%ue===J,Ae=(ce-1+ue)%ue===J;Ae&&!Ie?Ee=-1:Ie&&!Ae?Ee=1:Ee=J>ce?1:-1}return j.current!=null&&(cancelAnimationFrame(j.current),j.current=null),M({opacity:0,x:Ee*56,scale:.94,blur:8,animate:!1}),j.current=requestAnimationFrame(()=>{j.current=requestAnimationFrame(()=>{M({opacity:1,x:0,scale:1,blur:0,animate:!0}),j.current=null})}),()=>{j.current!=null&&(cancelAnimationFrame(j.current),j.current=null)}},[e,J,n.length]);const xr=L<=c+.001&&Math.abs(W.x)<.5&&Math.abs(W.y)<.5,We=s.useCallback((ce,ue,Ee)=>{C(Ie=>{const Ae=zt(ce,c,Y);if(Math.abs(Ae-Ie)<1e-4)return Ie;const Pe=Ae/Ie,Ge=Ae<Ie;return Ae<=c+.001?(_({x:0,y:0}),c):(_(Ze=>{let Qe=Ze;if(typeof ue=="number"&&typeof Ee=="number"&&le.current&&!Ge){const Er=le.current.getBoundingClientRect(),Or=ue-Er.left-Er.width/2,Ur=Ee-Er.top-Er.height/2;Qe={x:Or-(Or-Ze.x)*Pe,y:Ur-(Ur-Ze.y)*Pe}}else if(Ge){Qe={x:Ze.x*Pe,y:Ze.y*Pe};const Er=Math.min(1,(Ie-Ae)/Math.max(.01,Ie-c));Qe={x:Qe.x*(1-Er*.65),y:Qe.y*(1-Er*.65)}}else Qe={x:Ze.x*Pe,y:Ze.y*Pe};return pe(Qe,Ae)}),Ae)})},[pe,c,Y]),Le=s.useCallback(()=>{We(L*d)},[We,L,d]),ke=s.useCallback(()=>{const ce=Math.max(c,L/d);if(ce<=c+.001){ie();return}C(ce),_({x:0,y:0})},[c,ie,L,d]);s.useEffect(()=>{if(!e)return;const ce=ue=>{if(ue.key==="Escape"&&p){ue.preventDefault(),t();return}ue.key==="ArrowLeft"&&ae?(ue.preventDefault(),Se(J-1)):ue.key==="ArrowRight"&&ae?(ue.preventDefault(),Se(J+1)):ue.key==="+"||ue.key==="="?(ue.preventDefault(),We(L*d)):ue.key==="-"||ue.key==="_"?(ue.preventDefault(),ke()):ue.key==="0"&&(ue.preventDefault(),ie())};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[We,p,ae,t,e,ie,J,L,Se,ke,d]);const er=ce=>{ce.preventDefault();const ue=ce.deltaY>0?1/d:d;We(L*ue,ce.clientX,ce.clientY)},me=ce=>{L<=c+.001||(ce.currentTarget.setPointerCapture(ce.pointerId),U(!0),z.current={pointerId:ce.pointerId,startX:ce.clientX,startY:ce.clientY,originX:W.x,originY:W.y})},K=ce=>{const ue=z.current;!ue||ue.pointerId!==ce.pointerId||_(pe({x:ue.originX+(ce.clientX-ue.startX),y:ue.originY+(ce.clientY-ue.startY)},L))},re=ce=>{var ue;((ue=z.current)==null?void 0:ue.pointerId)===ce.pointerId&&(z.current=null,U(!1))},be=ce=>{if(ce.stopPropagation(),L>c+.05){ie();return}We(Math.min(Y,3),ce.clientX,ce.clientY)},he=ce=>{if(ce.touches.length!==2)return;U(!0);const[ue,Ee]=[ce.touches[0],ce.touches[1]],Ie=Math.hypot(ue.clientX-Ee.clientX,ue.clientY-Ee.clientY);ee.current={distance:Ie,scale:L}},Be=ce=>{if(ce.touches.length!==2||!ee.current)return;ce.preventDefault();const[ue,Ee]=[ce.touches[0],ce.touches[1]],Ie=Math.hypot(ue.clientX-Ee.clientX,ue.clientY-Ee.clientY),Ae=(ue.clientX+Ee.clientX)/2,Pe=(ue.clientY+Ee.clientY)/2,Ge=ee.current.scale*(Ie/Math.max(1,ee.current.distance));We(Ge,Ae,Pe)},Te=()=>{ee.current=null,U(!1)};if(!E||!P)return null;const He=Z.enabled,Fe=Z.animate?`transform ${it}ms ${Vc}`:"none";return nr.createPortal(r.jsxs("div",{className:"fixed inset-0",style:{zIndex:$},role:"dialog","aria-modal":"true","aria-label":h,children:[r.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:g?1:0,transition:`opacity ${He?it:dr}ms ${vr}`,cursor:"default",zIndex:0},onClick:()=>{u&&t()}}),r.jsx("div",{ref:le,className:"absolute inset-0 flex items-center justify-center",style:{zIndex:1,padding:de?"4.5rem 3.5rem 6.5rem":"4.5rem 3.5rem 2.5rem",opacity:He||g?1:0,transform:He||g?"translateY(0) scale(1)":"translateY(10px) scale(0.96)",transition:He?"none":`opacity ${dr}ms ${vr}, transform ${dr}ms ${vr}`},onClick:ce=>{ce.target===ce.currentTarget&&u&&t()},onWheel:er,children:r.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{transform:Z.enabled?`translate3d(${Z.dx}px, ${Z.dy}px, 0) scale(${Z.scale})`:void 0,transformOrigin:"center center",transition:Z.enabled?Fe:void 0},children:r.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{opacity:V.opacity,filter:V.blur?`blur(${V.blur}px)`:"blur(0px)",transform:`translate3d(${V.x}px, 0, 0) scale(${V.scale})`,transition:V.animate?[`opacity ${Na}ms ${Sa}`,`transform ${Na}ms ${Sa}`,`filter ${Na}ms ${Sa}`].join(", "):"none"},children:r.jsx("div",{ref:R,className:"pointer-events-auto relative max-h-full max-w-full touch-none select-none will-change-transform",style:{cursor:L>c+.001?"grab":"zoom-in",transform:`translate3d(${W.x}px, ${W.y}px, 0) scale(${L})`,transformOrigin:"center center",transition:ne?"none":`transform 220ms ${Uc}`},onClick:ce=>ce.stopPropagation(),onDoubleClick:be,onPointerDown:me,onPointerMove:K,onPointerUp:re,onPointerCancel:re,onTouchStart:he,onTouchMove:Be,onTouchEnd:Te,children:r.jsx("img",{src:P.src,alt:P.alt||"",draggable:!1,className:"block max-h-[min(78vh,820px)] max-w-[min(86vw,1100px)] object-contain",style:{display:"block",borderRadius:Ea,imageRendering:L>2.5?"pixelated":"auto"},onLoad:()=>{mr()}},P.src+String(J))})})})}),r.jsxs("div",{className:"pointer-events-none absolute inset-0",style:{zIndex:2,opacity:g?1:0,transform:g?"translateY(0)":"translateY(-6px)",transition:`opacity ${He?it:dr}ms ${vr}, transform ${He?it:dr}ms ${vr}`},children:[r.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 flex items-center justify-between gap-3 px-4 pt-4",children:[r.jsx("div",{className:"pointer-events-auto flex items-center gap-2",children:f&&n.length>0?r.jsxs("span",{className:"rounded-full px-3 py-1.5 text-xs font-semibold tracking-wide",style:Ca,children:[J+1," / ",n.length]}):null}),r.jsxs("div",{className:"pointer-events-auto flex items-center gap-2",children:[m?r.jsxs(r.Fragment,{children:[r.jsx(ct,{label:"Alejar",onClick:ke,disabled:L<=c+.001,children:r.jsx(F.HiMinus,{className:"h-5 w-5"})}),r.jsx(ct,{label:"Restablecer tamaño",onClick:ie,disabled:xr,children:r.jsx(F.HiArrowsPointingIn,{className:"h-5 w-5"})}),r.jsx(ct,{label:"Acercar",onClick:Le,disabled:L>=Y-.001,children:r.jsx(F.HiPlus,{className:"h-5 w-5"})})]}):null,r.jsx(ct,{label:"Cerrar",onClick:t,children:r.jsx(F.HiXMark,{className:"h-5 w-5"})})]})]}),ae?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"pointer-events-auto absolute left-3 top-1/2",style:{opacity:g?1:0,transform:g?"translate(0, -50%)":"translate(-8px, -50%)",transition:`opacity ${dr}ms ${vr}, transform ${dr}ms ${vr}`},children:r.jsx(ct,{label:"Anterior",size:"lg",onClick:()=>Se(J-1),disabled:!x&&J<=0,children:r.jsx(F.HiChevronLeft,{className:"h-6 w-6"})})}),r.jsx("div",{className:"pointer-events-auto absolute right-3 top-1/2",style:{opacity:g?1:0,transform:g?"translate(0, -50%)":"translate(8px, -50%)",transition:`opacity ${dr}ms ${vr}, transform ${dr}ms ${vr}`},children:r.jsx(ct,{label:"Siguiente",size:"lg",onClick:()=>Se(J+1),disabled:!x&&J>=n.length-1,children:r.jsx(F.HiChevronRight,{className:"h-6 w-6"})})})]}):null,de?r.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:r.jsx("div",{className:"pointer-events-auto flex max-w-full items-end gap-2.5 overflow-x-auto rounded-2xl px-2 py-2",style:{background:"color-mix(in srgb, var(--bg-card) 55%, transparent)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",scrollbarWidth:"thin"},role:"tablist","aria-label":"Miniaturas",children:n.map((ce,ue)=>{const Ee=ue===J;return r.jsx("button",{type:"button",role:"tab","aria-selected":Ee,"aria-label":ce.alt||`Imagen ${ue+1}`,onClick:Ie=>{Ie.stopPropagation(),Se(ue)},className:"relative shrink-0 overflow-hidden transition-opacity",style:{width:56,height:42,borderRadius:Ea,opacity:Ee?1:.42,transition:`opacity 180ms ${vr}`},children:r.jsx("img",{src:ce.src,alt:"",draggable:!1,className:"h-full w-full object-cover",style:{borderRadius:Ea}})},`${ce.src}-${ue}`)})})}):null]})]}),document.body)}function Qc({children:e,className:t,style:n,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c}){const[d,u]=s.useState(!1),[p,f]=s.useState(0),[m,x]=s.useState([]),[w,$]=s.useState(null),h=s.useCallback((T,g,y)=>{x(T),$(y??null),f(g),u(!0)},[]),E=s.useCallback(T=>{Gs(T,h)},[h]);return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:`[&_img]:cursor-zoom-in ${t??""}`,style:n,onClick:E,children:e}),r.jsx(Qs,{open:d,onClose:()=>u(!1),index:p,onIndexChange:f,slides:m,originRect:w,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c})]})}function Js(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Rs(e,t){if(e.length!==t.length)return!1;const n=new Set(t);return e.every(a=>n.has(a))}function Ma(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function Jc(e,t){if(!t)return!0;const n=Ma(t);return Ma(e.label).includes(n)||!!(e.sublabel&&Ma(e.sublabel).includes(n))}function Rc({value:e,onChange:t,options:n,placeholder:a="Seleccionar…",disabled:o=!1,className:l="",style:i,height:c=40,padding:d="6px 10px",searchable:u=!0,minOptionsForSearch:p=6,maxVisibleValues:f=2,truncateSelectedValues:m=!0,emptyText:x="Sin resultados",clearLabel:w="Limpiar seleccion",pruneMissingValues:$=!0}){const[h,E]=s.useState(!1),[T,g]=s.useState(""),[y,k]=s.useState(0),[S,L]=s.useState(!1),[C,W]=s.useState({}),_=s.useRef(null),V=s.useRef(null),M=s.useRef(null),Z=s.useRef(null),H=u&&n.length>=p,ne=s.useMemo(()=>new Set(e),[e]),U=s.useMemo(()=>{const I=new Map;for(const J of n)I.set(J.value,J);return I},[n]),q=s.useMemo(()=>{const I=[];for(const J of e){const P=U.get(J);P&&I.push(P)}return I},[U,e]),j=f==="all"?q.length:f,D=q.slice(0,j),se=Math.max(0,q.length-D.length),B=s.useMemo(()=>{const I=T.trim();return!H||!I?n:n.filter(J=>Jc(J,I))},[n,T,H]),O=s.useCallback(()=>{const I=_.current;if(!I)return;const J=I.getBoundingClientRect(),P=H?304:244,ae=window.innerHeight-J.bottom,Y=ae<P&&J.top>ae;W({position:"fixed",left:J.left,top:Y?void 0:J.bottom+4,bottom:Y?window.innerHeight-J.top+4:void 0,width:Math.max(J.width,240),zIndex:9999})},[H]),oe=s.useCallback(I=>{Rs(e,I)||t(I)},[t,e]),v=s.useCallback(I=>{const J=U.get(I);if(J!=null&&J.disabled)return;const P=ne.has(I)?e.filter(ae=>ae!==I):[...e,I];oe(P)},[oe,U,e,ne]),z=s.useCallback(()=>oe([]),[oe]),ee=s.useCallback(()=>{E(!1),g(""),k(0)},[]);s.useEffect(()=>L(!0),[]);const le=s.useMemo(()=>n.map(I=>I.value).join("\0"),[n]);s.useEffect(()=>{if(!$||e.length===0||n.length===0)return;const I=new Set(n.map(P=>P.value)),J=e.filter(P=>I.has(P));Rs(e,J)||t(J)},[le]),s.useEffect(()=>{if(!h)return;function I(J){var ae,Y;const P=J.target;!((ae=_.current)!=null&&ae.contains(P))&&!((Y=V.current)!=null&&Y.contains(P))&&ee()}return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[ee,h]),s.useEffect(()=>{h&&(k(0),O(),H&&setTimeout(()=>{var I;return(I=M.current)==null?void 0:I.focus()},0))},[h,H,O]),s.useEffect(()=>{if(h)return window.addEventListener("resize",O),window.addEventListener("scroll",O,!0),()=>{window.removeEventListener("resize",O),window.removeEventListener("scroll",O,!0)}},[h,O]),s.useEffect(()=>{if(B.length===0){k(0);return}k(I=>Math.min(I,B.length-1))},[B.length]),s.useEffect(()=>{if(y<0||!Z.current)return;const I=Z.current.children[y];I==null||I.scrollIntoView({block:"nearest"})},[y]);function R(I){if(!o){if(!h){(I.key==="Enter"||I.key===" "||I.key==="ArrowDown")&&(I.preventDefault(),E(!0));return}if(I.key==="Escape"){I.preventDefault(),ee();return}if(I.key==="ArrowDown"){if(I.preventDefault(),B.length===0)return;k(J=>Math.min(J+1,B.length-1));return}if(I.key==="ArrowUp"){I.preventDefault(),k(J=>Math.max(J-1,0));return}if(I.key==="Enter"&&B[y]&&!B[y].disabled){I.preventDefault(),v(B[y].value);return}I.key==="Backspace"&&!T&&e.length&&(I.preventDefault(),oe(e.slice(0,-1)))}}const Q=r.jsxs("div",{ref:V,className:"overflow-hidden rounded-xl shadow-xl",style:{...C,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[H&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[r.jsx(F.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),r.jsx("input",{ref:M,value:T,onChange:I=>{g(I.target.value),k(0)},onKeyDown:I=>{(I.key==="ArrowDown"||I.key==="ArrowUp"||I.key==="Enter"||I.key==="Escape")&&(I.stopPropagation(),R(I))},placeholder:"Buscar…",className:"min-w-0 flex-1 bg-transparent text-sm outline-none",style:{color:"var(--text-main)"}}),T&&r.jsx("button",{type:"button","aria-label":"Limpiar búsqueda",onMouseDown:I=>{I.preventDefault(),g(""),k(0)},children:r.jsx(F.HiXMark,{className:"h-3.5 w-3.5",style:{color:"var(--text-muted)"}})})]}),e.length>0&&r.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:[r.jsxs("span",{children:[q.length," seleccionados",e.length>q.length?` (${e.length-q.length} no disponibles)`:""]}),r.jsx("button",{type:"button",onMouseDown:I=>{I.preventDefault(),z()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:w})]}),r.jsxs("ul",{ref:Z,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:H?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[B.map((I,J)=>{const P=J===y,ae=ne.has(I.value);return r.jsxs("li",{role:"option","aria-selected":ae,onMouseDown:Y=>{Y.preventDefault(),!I.disabled&&v(I.value)},onMouseEnter:()=>!I.disabled&&k(J),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:P?"var(--bg-hover)":ae?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:I.disabled?"var(--text-muted)":"var(--text-main)",cursor:I.disabled?"not-allowed":"pointer",opacity:I.disabled?.58:1},children:[r.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:ae?"var(--primary)":"var(--border)",background:ae?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:ae&&r.jsx(F.HiCheck,{className:"h-3 w-3"})}),I.color&&r.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:I.color}}),r.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[r.jsx("span",{className:"truncate",children:I.label}),I.sublabel&&r.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:I.sublabel})]}),I.badge&&r.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:I.badge})]},I.value)}),B.length===0&&r.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:x})]})]});return r.jsxs("div",{ref:_,className:`relative ${l||"w-full"}`,style:i,onKeyDown:R,children:[r.jsxs("button",{type:"button",disabled:o,onClick:()=>{o||(h?ee():E(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:Js(c),padding:Js(d),background:"var(--bg-input)",color:q.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:[r.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 overflow-hidden",children:D.length?r.jsxs(r.Fragment,{children:[D.map(I=>r.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${m?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[I.color&&r.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:I.color}}),r.jsx("span",{className:m?"truncate":"break-words",children:I.label}),r.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${I.label}`,onMouseDown:J=>{J.preventDefault(),J.stopPropagation(),v(I.value)},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:r.jsx(F.HiXMark,{className:"h-3 w-3"})})]},I.value)),se>0&&r.jsxs("span",{className:"inline-flex items-center rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{background:"color-mix(in srgb, var(--primary) 10%, transparent)",color:"var(--primary)"},children:["+",se]})]}):r.jsx("span",{className:"truncate",children:a})}),q.length?r.jsx("span",{role:"button",tabIndex:-1,"aria-label":w,onMouseDown:I=>{I.preventDefault(),I.stopPropagation(),z()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:r.jsx(F.HiXMark,{className:"h-3.5 w-3.5"})}):r.jsx(F.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:h?"rotate(180deg)":"rotate(0deg)"}})]}),h&&S&&nr.createPortal(Q,document.body)]})}function ed({inputMode:e="decimal",...t}){return r.jsx(wa,{...t,type:"number",inputMode:e})}function rd(e,t,n){const a=[],o=Math.max(2,e-n),l=Math.min(t-1,e+n);a.push(1),o>2&&a.push("...");for(let i=o;i<=l;i+=1)a.push(i);return l<t-1&&a.push("..."),t>1&&a.push(t),a}function td({page:e,totalPages:t,onPageChange:n,disabled:a=!1,siblingCount:o=1,className:l=""}){const i=Math.max(1,t),c=Math.min(Math.max(1,e),i),d=rd(c,i,o);return r.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[r.jsx(je,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:a||c<=1,onClick:()=>n(c-1),children:r.jsx(F.HiChevronLeft,{className:"h-4 w-4"})}),d.map((u,p)=>u==="..."?r.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${p}`):r.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)),r.jsx(je,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:a||c>=i,onClick:()=>n(c+1),children:r.jsx(F.HiChevronRight,{className:"h-4 w-4"})})]})}const eo=[{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 ro(e){return e==null?"":String(e)}function yn(e){return e?e.startsWith("+")?e:`+${e}`:"+1"}function nd(e){return typeof e=="number"?`${e}px`:e}function ad({autoComplete:e="tel",inputMode:t="tel",validate:n=!0,invalidMessage:a="Ingresa un telefono valido.",errorDisplay:o="tooltip",error:l,value:i,defaultValue:c,onChange:d,countryCode:u,defaultCountryCode:p="+1",onCountryCodeChange:f,allowedCountryCodes:m,countryCodeOptions:x,countryCodePlaceholder:w="Codigo",countryCodeClassName:$="",countryCodeWidth:h=84,onPhoneValueChange:E,label:T,containerClassName:g="",helperText:y,helperDisplay:k="inline",labelAction:S,className:L="",required:C,disabled:W,floatingLabel:_,showPasswordToggle:V,nativeValidation:M,errorTooltipLabel:Z="Error de validacion",...H}){var Y;const[ne,U]=s.useState(()=>ro(c)),[q,j]=s.useState(()=>yn(p)),D=s.useMemo(()=>{const de=x??eo,Se=m==null?void 0:m.map(yn);return Se!=null&&Se.length?de.filter(ie=>Se.includes(ie.value)):de},[m,x]),se=((Y=D[0])==null?void 0:Y.value)??"+1",B=D.some(de=>de.value===yn(u??q))?yn(u??q):se,O=i!==void 0?ro(i):ne,oe=`${B} ${O}`.trim(),v=n&&O.length>0&&!ya(oe)?a:void 0,z=l??v,ee=!!z,le=ee&&o!=="tooltip",R=ee&&o!=="inline",Q=!!y&&k==="tooltip"&&!le,I=ee?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",J=de=>{const Se=de.currentTarget.value;i===void 0&&U(Se),E==null||E(Se,{countryCode:B,nationalNumber:Se,fullNumber:`${B} ${Se}`.trim()}),d==null||d(de)},P=de=>{u===void 0&&j(de),f==null||f(de),E==null||E(O,{countryCode:de,nationalNumber:O,fullNumber:`${de} ${O}`.trim()})},ae=R?r.jsx(zr,{as:"span",content:z,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:r.jsx("span",{tabIndex:0,role:"img","aria-label":Z,className:"flex h-full w-full items-center justify-center outline-none",children:r.jsx(Ys,{className:"h-[18px] w-[18px]"})})}):null;return r.jsxs("div",{className:`flex flex-col gap-2 ${g}`,children:[r.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[r.jsx("span",{children:T}),C&&r.jsx("span",{className:"text-[var(--danger)]",children:"*"}),Q?r.jsx(ot,{content:y}):null,S&&r.jsx("span",{className:"ml-auto normal-case",children:S})]}),r.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${I}`,children:[r.jsx(_r,{value:B,onChange:P,options:D,placeholder:w,disabled:W,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${$}`,style:{width:nd(h)},height:38,padding:"0 8px 0 10px"}),r.jsx("span",{className:"h-5 w-px shrink-0 bg-[var(--border)]"}),r.jsxs("span",{className:"relative min-w-0 flex-1 self-stretch",children:[r.jsx("input",{...H,value:i,defaultValue:c,type:"tel",inputMode:t,autoComplete:e,disabled:W,required:void 0,"aria-label":H["aria-label"]??(typeof T=="string"?T:void 0),"aria-invalid":ee||H["aria-invalid"],className:`h-full w-full min-w-0 bg-transparent px-2 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed disabled:opacity-60 ${R?"pr-10":""} ${L}`,onChange:J}),ae]})]}),r.jsx(lt,{error:le?z:void 0,helperText:y,helperDisplay:k})]})}function sd({value:e,onChange:t,options:n,name:a,label:o,orientation:l="vertical",disabled:i=!1,className:c="",optionClassName:d=""}){return r.jsxs("fieldset",{className:`min-w-0 ${c}`,disabled:i,children:[o&&r.jsx("legend",{className:"mb-2 text-xs font-semibold uppercase text-[var(--text-muted)]",children:o}),r.jsx("div",{className:l==="horizontal"?"flex flex-wrap gap-2":"flex flex-col gap-2",children:n.map(u=>{const p=u.value===e,f=i||u.disabled;return r.jsxs("label",{className:`inline-flex min-w-0 items-start gap-2 rounded-lg border px-2.5 py-1.5 transition-colors ${f?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${d}`,style:{borderColor:p?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:p?"color-mix(in srgb, var(--primary) 8%, transparent)":"var(--bg-card)"},children:[r.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:[r.jsx("input",{type:"radio",name:a,value:u.value,checked:p,disabled:f,onChange:()=>t(u.value),className:"absolute inset-0 opacity-0"}),r.jsx("span",{className:`h-2 w-2 rounded-full transition ${p?"scale-100 opacity-100":"scale-50 opacity-0"}`,style:{background:"var(--primary)"}})]}),r.jsxs("span",{className:"min-w-0",children:[r.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:u.label}),u.description&&r.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:u.description})]})]},u.value)})})]})}const to=()=>'<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>',_t=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),no=e=>e.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(t,n,a)=>`${n}${a.toLocaleUpperCase()}`),od=e=>e.replace(/[<>]/g,"").toLowerCase(),ld=new Set(["p","br","div","span","b","strong","i","em","u","s","strike","ul","ol","li","h1","h2","h3","h4","blockquote","a","img","hr"]),id=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,cd=e=>{const t=e.indexOf("<!--StartFragment-->"),n=e.indexOf("<!--EndFragment-->");if(t!==-1&&n!==-1&&n>t)return e.slice(t+20,n);const a=e.match(/<body[^>]*>([\s\S]*)<\/body>/i);return a?a[1]:e},xn=(e,t)=>t.test(e),dd=e=>xn(e,/font-weight\s*:\s*(bold|[6-9]00)/i),ud=e=>xn(e,/font-style\s*:\s*italic/i),fd=e=>xn(e,/text-decoration(?:-line)?\s*:[^;]*underline/i),bd=e=>xn(e,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),wn=(e,t)=>{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()===t)return;const n=e.ownerDocument.createElement(t);for(;e.firstChild;)n.appendChild(e.firstChild);e.appendChild(n)},kn=e=>{const t=e.parentNode;if(!t){e.remove();return}for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)},md=e=>{const t=e.getAttribute("class")??"",n=e.getAttribute("style")??"";return/mso-list/i.test(n)||/MsoListParagraph/i.test(t)||/MsoList/i.test(t)},ao=e=>{const t=e.getAttribute("style")??"",n=e.textContent??"";return/mso-level-number-format\s*:\s*(decimal|arabic|roman|alpha)/i.test(t)||/^\s*\d+[.)]\s/.test(n)||/^\s*[a-zA-Z][.)]\s/.test(n)?"ol":"ul"},pd=e=>{const n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT).nextNode();if(!n||!n.textContent)return;const a=n.textContent.replace(id,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");a!==n.textContent&&(n.textContent=a)},hd=e=>{const t=Array.from(e.querySelectorAll("span, font, p, div, li, h1, h2, h3, h4"));t.sort((n,a)=>a.querySelectorAll("*").length-n.querySelectorAll("*").length),t.forEach(n=>{const a=n.getAttribute("style")??"";a&&(dd(a)&&wn(n,"strong"),ud(a)&&wn(n,"em"),fd(a)&&wn(n,"u"),bd(a)&&wn(n,"s"))})},gd=e=>{const t=Array.from(e.querySelectorAll("p, div")).filter(md);if(!t.length)return;let n=0;for(;n<t.length;){const a=t[n],o=ao(a),l=[a];let i=n+1;for(;i<t.length;){const u=t[i];if(ao(u)!==o)break;let p=l[l.length-1].nextSibling;for(;p&&p.nodeType===Node.TEXT_NODE&&!(p.textContent??"").trim();)p=p.nextSibling;if(p!==u)break;l.push(u),i++}const c=a.parentNode;if(!c){n=i;continue}const d=a.ownerDocument.createElement(o);c.insertBefore(d,a),l.forEach(u=>{pd(u);const p=u.ownerDocument.createElement("li");for(;u.firstChild;)p.appendChild(u.firstChild);d.appendChild(p),u.remove()}),n=i}},vd=e=>e==="h1"?"h2":e==="h4"||e==="h5"||e==="h6"?"h3":e==="div"?"p":e,yd=e=>{const t=cd(e.replace(/<!--\[if[\s\S]*?<!\[endif\]-->/gi,"").replace(/<xml[\s\S]*?<\/xml>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<\/?o:[^>]*>/gi,"").replace(/<\/?w:[^>]*>/gi,"").replace(/<\/?m:[^>]*>/gi,"")),o=new DOMParser().parseFromString(`<!DOCTYPE html><html><body>${t}</body></html>`,"text/html").body;o.querySelectorAll("script, style, meta, link, xml, title, head, iframe, object, embed, form, input, button, textarea, select, noscript").forEach(i=>i.remove()),hd(o),gd(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"){kn(d),c.forEach(l);return}if(!ld.has(u)){kn(d),c.forEach(l);return}const p=vd(u);if(p!==u){const f=d.ownerDocument.createElement(p);for(;d.firstChild;)f.appendChild(d.firstChild);d.replaceWith(f),l(f);return}if(Array.from(d.attributes).forEach(f=>{const m=f.name.toLowerCase(),x=f.value;if(m.startsWith("on")||m==="style"||m==="class"){d.removeAttribute(f.name);return}if(m==="lang"||m.startsWith("data-")||m.startsWith("mso-")){d.removeAttribute(f.name);return}if((m==="href"||m==="src")&&/^\s*javascript:/i.test(x)){d.removeAttribute(f.name);return}u!=="a"&&u!=="img"&&m!=="href"&&m!=="src"&&m!=="alt"&&(["href","src","alt","target","rel"].includes(m)||d.removeAttribute(f.name))}),u==="a"){const f=d.getAttribute("href");if(!f||/^\s*#/.test(f)&&f.length<2){kn(d),c.forEach(l);return}d.setAttribute("target","_blank"),d.setAttribute("rel","noopener noreferrer"),d.classList.add("rich-link")}if(u==="img"){const f=d.getAttribute("src")??"";if(!f||/^\s*javascript:/i.test(f)||/^file:/i.test(f)||/scheme\s*=\s*["']?file/i.test(f)){d.remove();return}d.classList.add("rich-img"),Array.from(d.attributes).forEach(m=>{["src","alt","class"].includes(m.name.toLowerCase())||d.removeAttribute(m.name)})}if(u==="span"){kn(d),c.forEach(l);return}}c.forEach(l)};return l(o),o.querySelectorAll("p, h2, h3, li").forEach(i=>{const c=(i.textContent??"").replace(/[\u00a0\s]+/g,"").trim(),d=i.querySelector("img, hr"),u=!c&&!d&&Array.from(i.childNodes).every(p=>p.nodeType===Node.TEXT_NODE||p.nodeType===Node.ELEMENT_NODE&&p.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()},$a=e=>_t(e).replace(/\r\n?/g,`
25
- `).split(/\n{2,}/).map(t=>`<p>${t.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),xd=e=>new RegExp("\\p{L}","u").test(e),Ta=(e,t)=>{const n=e.trim();return!n||!xd(n)?!1:t==="uppercase"?n===n.toLocaleUpperCase():t==="lowercase"?n===n.toLocaleLowerCase():n===no(n)},so=e=>{const t=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",to())}(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",()=>t(a),{once:!0}),a.addEventListener("load",()=>{a.naturalWidth===0&&t(a)},{once:!0});const o=a.src;a.src="",a.src=o}});const n=a=>{const o=a.target;o.tagName==="IMG"&&t(o)};return e.addEventListener("error",n,!0),()=>e.removeEventListener("error",n,!0)};function oo({value:e,onChange:t,placeholder:n="Escribe algo...",minHeight:a="80px",instanceId:o}){const l=s.useId(),i=o||l,c=s.useCallback(()=>document,[]),d=s.useRef(null),u=s.useRef(null),p=s.useRef(new Map),f=s.useRef(null),m=s.useRef(!1),x=s.useRef(e??""),w=s.useRef(t),$=s.useRef(!1),[h,E]=s.useState(()=>!e||e.trim()===""),[T,g]=s.useState(new Set),[y,k]=s.useState(null),[S,L]=s.useState(""),[C,W]=s.useState(""),[_,V]=s.useState(""),[M,Z]=s.useState(""),[H,ne]=s.useState(!1),U=s.useCallback(()=>m.current?u.current:d.current,[]);s.useEffect(()=>{w.current=t},[t]);const q=s.useCallback(()=>{const K=window.getSelection(),re=U();if(!K||!re||K.rangeCount===0||K.isCollapsed)return"";const be=K.getRangeAt(0);return!re.contains(be.startContainer)||!re.contains(be.endContainer)?"":K.toString()},[U]);s.useEffect(()=>{const K=e??"";if($.current&&K===x.current){$.current=!1,E(!K||K.trim()==="");return}$.current=!1,x.current=K;const re=[d.current,u.current].filter(he=>!!he);re.forEach(he=>{he.innerHTML!==K&&(he.innerHTML=K)}),E(!K||K.trim()==="");const be=re.map(he=>so(he));return()=>be.forEach(he=>he())},[e]),s.useEffect(()=>{var he,Be;m.current=H;let K,re=0,be;if(H){const Te=d.current;Te&&(x.current=Te.innerHTML);const He=()=>{var ce;const Fe=u.current;if(!Fe){re=requestAnimationFrame(He);return}Fe.innerHTML!==x.current&&(Fe.innerHTML=x.current),K=so(Fe),E(((ce=Fe.textContent)==null?void 0:ce.trim())===""),be=setTimeout(()=>Fe.focus(),60)};re=requestAnimationFrame(He)}else{const Te=u.current,He=d.current,Fe=(Te==null?void 0:Te.innerHTML)??x.current,ce=x.current;x.current=Fe,He&&He.innerHTML!==Fe&&(He.innerHTML=Fe),Fe!==ce&&w.current(Fe),E(((Be=(he=Te??He)==null?void 0:he.textContent)==null?void 0:Be.trim())==="")}return()=>{re&&cancelAnimationFrame(re),be&&clearTimeout(be),K==null||K()}},[H]);const j=s.useCallback(()=>{const K=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],re=new Set;K.forEach(he=>{try{c().queryCommandState(he)&&re.add(he)}catch{return}});try{const he=od(c().queryCommandValue("formatBlock"));he&&re.add(`formatBlock:${he}`)}catch{}const be=q();Ta(be,"uppercase")&&re.add("__upper"),Ta(be,"lowercase")&&re.add("__lower"),Ta(be,"capitalize")&&re.add("__cap"),g(re)},[q,c]),D=()=>{var re;const K=U();K&&(x.current=K.innerHTML,$.current=!0,w.current(x.current),E(((re=K.textContent)==null?void 0:re.trim())===""))},se=K=>{if(!K){const re=d.current;re&&(x.current=re.innerHTML)}ne(!K)},B=(K,re)=>{var be;(be=U())==null||be.focus(),c().execCommand(K,!1,re),D(),j()},O=K=>{B("formatBlock",K)},oe=()=>{var K;(K=U())==null||K.focus(),c().execCommand("insertHTML",!1,"<hr><p><br></p>"),D(),j()},v=()=>{const K=window.getSelection();K&&K.rangeCount>0&&(f.current=K.getRangeAt(0).cloneRange())},z=()=>{const K=window.getSelection();K&&f.current&&(K.removeAllRanges(),K.addRange(f.current))},ee=K=>{if(v(),K==="link"){const re=window.getSelection();W(re&&!re.isCollapsed?re.toString():""),L("")}K==="image"&&(V(""),Z("")),k(K)},le=()=>{var he;if(!S.trim())return;z(),(he=U())==null||he.focus();const K=window.getSelection(),be=(K&&!K.isCollapsed?K.toString():"")||C.trim()||S.trim();c().execCommand("insertHTML",!1,`<a href="${_t(S.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${_t(be)}</a>`),D(),k(null)},R=(K,re="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${_t(K)}" alt="${_t(re)}" class="rich-img" />${to()}</span>`,Q=()=>{var K;_.trim()&&(z(),(K=U())==null||K.focus(),c().execCommand("insertHTML",!1,R(_.trim(),M.trim())),D(),k(null))},I=(K,re=1200,be=1200,he=.72)=>new Promise((Be,Te)=>{const He=new FileReader;He.onerror=Te,He.onload=Fe=>{var Ee;const ce=(Ee=Fe.target)==null?void 0:Ee.result,ue=new Image;ue.onerror=Te,ue.onload=()=>{let{width:Ie,height:Ae}=ue;if(Ie>re||Ae>be){const Ze=Math.min(re/Ie,be/Ae);Ie=Math.round(Ie*Ze),Ae=Math.round(Ae*Ze)}const Pe=document.createElement("canvas");Pe.width=Ie,Pe.height=Ae;const Ge=Pe.getContext("2d");if(!Ge){Be(ce);return}Ge.drawImage(ue,0,0,Ie,Ae),Be(Pe.toDataURL("image/jpeg",he))},ue.src=ce},He.readAsDataURL(K)}),J=K=>{K.focus();const re=window.getSelection();if(!re||re.rangeCount===0||!K.contains(re.anchorNode)){const be=document.createRange();be.selectNodeContents(K),be.collapse(!1),re==null||re.removeAllRanges(),re==null||re.addRange(be)}},P=s.useRef(()=>{});P.current=K=>{const re=U();re&&(J(re),c().execCommand("insertHTML",!1,K),re.querySelectorAll("p").forEach(be=>{!(be.textContent??"").replace(/[\u00a0\s]+/g,"")&&!be.querySelector("img, hr")&&be.remove()}),D(),j())};const ae=s.useRef(I);ae.current=I;const Y=s.useRef(R);Y.current=R;const de=s.useCallback(K=>{if(!K||p.current.has(K))return;const re=be=>{const he=be.clipboardData;if(!he)return;const Be=he.getData("text/html"),Te=he.getData("text/plain");if(Be||Te){be.preventDefault(),be.stopPropagation();try{const ue=Be?yd(Be):$a(Te);if(!ue){Te&&P.current($a(Te));return}P.current(ue)}catch{Te&&P.current($a(Te))}return}const Fe=Array.from(he.items).find(ue=>ue.type.startsWith("image/"));if(!Fe)return;be.preventDefault(),be.stopPropagation();const ce=Fe.getAsFile();ce&&ae.current(ce).then(ue=>{P.current(Y.current(ue,"imagen"))})};K.addEventListener("paste",re,!0),p.current.set(K,()=>{K.removeEventListener("paste",re,!0),p.current.delete(K)})},[]),Se=s.useCallback(K=>{var be;const re=d.current;re&&re!==K&&((be=p.current.get(re))==null||be()),d.current=K,K&&de(K)},[de]),ie=s.useCallback(K=>{var be;const re=u.current;re&&re!==K&&((be=p.current.get(re))==null||be()),u.current=K,K&&de(K)},[de]);s.useEffect(()=>{const K=p.current;return()=>{K.forEach(re=>re()),K.clear()}},[]);const pe=K=>{const re=window.getSelection(),be=U();if(!re||!be||re.rangeCount===0||re.isCollapsed)return;const he=re.getRangeAt(0);if(!be.contains(he.startContainer)||!be.contains(he.endContainer))return;const Be=he.toString();if(!Be)return;let Te=Be;K==="uppercase"?Te=Be.toLocaleUpperCase():K==="lowercase"?Te=Be.toLocaleLowerCase():Te=no(Be),he.deleteContents();const He=document.createTextNode(Te);he.insertNode(He);const Fe=document.createRange();Fe.setStart(He,0),Fe.setEnd(He,Te.length),re.removeAllRanges(),re.addRange(Fe),f.current=Fe.cloneRange(),D(),j()},Ce=()=>{v(),j()},De=()=>{D(),j()},mr=()=>{requestAnimationFrame(()=>{var K;(K=U())==null||K.focus()})},xr=K=>{var re,be;if((K.metaKey||K.ctrlKey)&&K.key==="Enter"){if(K.preventDefault(),K.stopPropagation(),K.repeat)return;(re=U())==null||re.focus(),c().execCommand("insertLineBreak",!1)||c().execCommand("insertHTML",!1,"<br>"),D(),j();return}if(K.key==="Tab"){K.preventDefault(),(be=U())==null||be.focus(),c().execCommand("insertText",!1,"    "),D(),j();return}if(K.key==="Escape"){if(y){k(null);return}if(m.current){ne(!1);return}}y||(K.ctrlKey||K.metaKey)&&(K.key==="b"&&(K.preventDefault(),B("bold")),K.key==="i"&&(K.preventDefault(),B("italic")),K.key==="u"&&(K.preventDefault(),B("underline")),K.key==="k"&&(K.preventDefault(),ee("link")))},We=()=>r.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),Le=(K,re,be,he,Be)=>{const Te=Be??(T.has(be)||be==="__link"&&y==="link"||be==="__img"&&y==="image");return r.jsx("button",{type:"button",title:re,tabIndex:-1,onFocus:mr,onMouseDown:He=>{He.preventDefault(),he?he():B(be)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:Te?"var(--primary)":"var(--text-secondary)",background:Te?"rgba(59,130,246,0.12)":"transparent"},children:K},be)},ke=K=>{const re=K.target;if(re.closest("[data-action='delete-img']")){K.preventDefault();const be=re.closest(".rich-img-wrap");be&&(be.remove(),D())}},er=K=>r.jsxs(r.Fragment,{children:[y==="link"&&r.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:K},children:[r.jsx("input",{autoFocus:!0,type:"url",value:S,onChange:re=>L(re.target.value),onKeyDown:re=>{re.key==="Enter"&&(re.preventDefault(),le()),re.key==="Escape"&&k(null)},placeholder:"https://...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),r.jsx("input",{type:"text",value:C,onChange:re=>W(re.target.value),onKeyDown:re=>{re.key==="Enter"&&(re.preventDefault(),le()),re.key==="Escape"&&k(null)},placeholder:"Texto (opcional)",className:"w-32 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),r.jsx("button",{type:"button",onClick:le,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),r.jsx("button",{type:"button",onClick:()=>k(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),y==="image"&&r.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-2 border-t px-3 py-2",style:{borderColor:"var(--border)",background:K},children:[r.jsx("input",{autoFocus:!0,type:"url",value:_,onChange:re=>V(re.target.value),onKeyDown:re=>{re.key==="Enter"&&(re.preventDefault(),Q()),re.key==="Escape"&&k(null)},placeholder:"URL de la imagen...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),r.jsx("input",{type:"text",value:M,onChange:re=>Z(re.target.value),onKeyDown:re=>{re.key==="Enter"&&(re.preventDefault(),Q()),re.key==="Escape"&&k(null)},placeholder:"Texto alt",className:"w-28 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),r.jsx("button",{type:"button",onClick:Q,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),r.jsx("button",{type:"button",onClick:()=>k(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),me=(K,re)=>r.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center gap-0.5 border-t px-2 py-1",style:{borderColor:"var(--border)",background:re},children:[Le(r.jsx(F.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),Le(r.jsx(F.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),We(),Le(r.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>O("p"),T.has("formatBlock:p")||T.has("formatBlock:div")),Le(r.jsx(F.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>O("h2"),T.has("formatBlock:h2")),Le(r.jsx(F.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>O("h3"),T.has("formatBlock:h3")),Le(r.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>O("blockquote"),T.has("formatBlock:blockquote")),We(),Le(r.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),Le(r.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),Le(r.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),Le(r.jsx("s",{children:"S"}),"Tachado","strikeThrough"),We(),Le(r.jsx(F.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),Le(r.jsx(F.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),Le(r.jsx(F.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),Le(r.jsx(F.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),We(),Le(r.jsx(F.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),Le(r.jsx(F.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),Le(r.jsx(F.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),Le(r.jsx(F.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),We(),Le(r.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>pe("uppercase")),Le(r.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>pe("lowercase")),Le(r.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>pe("capitalize")),We(),Le(r.jsx(F.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>ee("link")),Le(r.jsx(F.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),Le(r.jsx(F.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>ee("image")),Le(r.jsx(F.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",oe),We(),Le(r.jsx(F.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),Le(r.jsx(F.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>O("p")),We(),r.jsx("button",{type:"button",title:K?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:mr,onMouseDown:be=>{be.preventDefault(),se(K)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:K?r.jsx(F.HiArrowsPointingIn,{className:"h-4 w-4"}):r.jsx(F.HiArrowsPointingOut,{className:"h-4 w-4"})})]});return r.jsxs(r.Fragment,{children:[r.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:[r.jsx("div",{ref:Se,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:De,onKeyDown:xr,onKeyUp:Ce,onSelect:Ce,onMouseUp:Ce,onMouseDown:ke,"data-placeholder":n,className:`rich-editor px-3 py-2 text-sm focus:outline-none${h?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:a,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),er("var(--bg-input)"),me(!1,"var(--bg-input)")]}),r.jsxs(ca,{open:H,onClose:()=>ne(!1),title:"Modo de enfoque",subtitle:"Esc para salir",maxWidth:"920px",bodyClassName:"flex min-h-0 flex-col p-0",panelClassName:"h-[88vh]",backdropClassName:"bg-black/50 backdrop-blur-[2px]",children:[r.jsx("div",{ref:ie,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:De,onKeyDown:xr,onKeyUp:Ce,onSelect:Ce,onMouseUp:Ce,onMouseDown:ke,"data-placeholder":n,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${h?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),er("var(--bg-input)"),me(!0,"var(--bg-input)")]})]})}const lo="[a-zA-Z0-9._@-]+",La=new RegExp(`@(${lo})`,"g"),wd=/[a-zA-Z0-9._@-]/,jt=new Set([" ",`
26
- `," ","\r"," ","(","[","{",".",",",";",":","!","?","¿","¡",")","]","}",'"',"'","«","»","/","\\","|","-","—","–"]);function io(e,t){if(t<=0)return!0;const n=e[t-1]??"";return jt.has(n)}function co(e,t,n){var a;if(t<0||t>e.length)return null;for(let o=t-1;o>=0;o-=1){if(e[o]!=="@"){const c=e[o]??"";if(jt.has(c)||!wd.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):io(e,o)))continue;const i=e.slice(o+1,t);return i.length>0&&!new RegExp(`^${lo}$`).test(i)?null:{query:i,triggerIndex:o,caretIndex:t}}return null}function uo(e,t){var a;const n=dt(e,t);return n?!!((a=n.node.parentElement)!=null&&a.closest(".mention-chip")):!1}function fo(e,t){if(t<=0)return!0;const n=dt(e,t);if(!n){const o=e.textContent??"";return io(o,t)}if(n.offset>0){const o=n.node.data[n.offset-1]??"";return jt.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 jt.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 jt.has(l[l.length-1]??"")}a=a.previousSibling}return!0}function Aa(e,t){const n=e.textContent??"";return co(n,t,{isTriggerBoundary:a=>fo(e,a),isInsideExistingMention:a=>uo(e,a)})}function Da(e){return e.toLowerCase().trim()}function bo(e){return e?e.replace(/<style[^>]*>[\s\S]*?<\/style>/gi," ").replace(/<script[^>]*>[\s\S]*?<\/script>/gi," ").replace(/<br\s*\/?>/gi,`
23
+ </body></html>`,fe=window.open("","_blank");fe&&(fe.document.write(re),fe.document.close())}const na=()=>!We||!en?null:nt.createPortal(t.jsxs("div",{ref:Qa,role:"menu",className:"overflow-hidden rounded-lg border p-1 shadow-xl",style:{...Sf,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:()=>{tb(),jn(!1)},children:[t.jsx(P.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:()=>{rb(),jn(!1)},children:[t.jsx(P.HiDocumentText,{className:"h-4 w-4 shrink-0 text-red-500"}),"Imprimir / PDF"]})]}),document.body),aa=()=>{const b=K&&Mt.trim().length>0,N=pe!=null&&pe.length?pe:b?[{key:"bql",label:"BQL",value:Mt}]:[],Q=ie.filter(D=>{const re=D.trim();return re?!new Set(Jr.split(`
24
+ `).map(ve=>ve.trim()).filter(Boolean)).has(re):!1}).slice(0,8);return!le&&Ra===0&&!K&&!We?null:t.jsxs("div",{className:"relative flex min-h-9 flex-wrap items-center justify-between gap-2 border-b rounded-t-lg px-2 py-1",style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[Ra>0&&t.jsxs("button",{type:"button",onClick:Ff,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(P.HiXMark,{className:"h-3.5 w-3.5"}),Ra," filtros"]}),K&&t.jsxs("div",{ref:Ga,className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>{if(Tt){Xt(!1);return}Gn(),Xt(!0)},className:"inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border px-2 text-xs font-bold transition-colors",style:{background:Tt?"var(--primary)":b?"color-mix(in srgb, var(--primary) 12%, transparent)":"var(--bg-card)",borderColor:Tt||b?"var(--primary)":"var(--border)",color:Tt?"var(--primary-fg)":"var(--primary)"},"aria-expanded":Tt,title:"Abrir filtros BQL",children:[t.jsx(P.HiCommandLine,{className:"h-3.5 w-3.5"}),"BQL",b&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),Tt?t.jsx(P.HiChevronUp,{className:"h-3.5 w-3.5"}):t.jsx(P.HiChevronDown,{className:"h-3.5 w-3.5"})]}),t.jsx("span",{className:"hidden truncate text-xs text-[var(--text-muted)] sm:inline",children:se}),N.length>0&&t.jsxs("div",{className:"hidden min-w-0 items-center gap-1.5 overflow-hidden lg:flex",children:[N.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)),N.length>3&&t.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["+",N.length-3]})]}),b&&t.jsx("button",{type:"button","aria-label":"Limpiar BQL",title:"Limpiar BQL",onClick:Tl,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(P.HiXMark,{className:"h-4 w-4"})}),Tt&&nt.createPortal(t.jsxs("div",{ref:pl,className:"flex flex-col gap-3 rounded-lg p-3 shadow-2xl",style:{...xf,background:"var(--bg-card)",border:"1px solid color-mix(in srgb, var(--primary) 35%, var(--border))"},children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[de.map(D=>t.jsxs("button",{type:"button",onMouseDown:re=>{re.preventDefault(),re.stopPropagation()},onClick:re=>{re.preventDefault(),re.stopPropagation(),Kn(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)),Se.length>0&&t.jsxs("button",{type:"button",onClick:()=>yr(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":bl,children:[t.jsx(P.HiInformationCircle,{className:"h-3.5 w-3.5"}),"Ejemplos"]}),Rr.length>0&&t.jsxs("button",{type:"button",onClick:()=>xr(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":ml,children:[t.jsx(P.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]})]}),t.jsxs("div",{className:"overflow-hidden rounded-lg",style:{background:"var(--bg-input)",border:`1.5px solid ${Ce?"var(--danger)":b?"var(--primary)":"var(--border)"}`},children:[t.jsx("textarea",{ref:Za,value:Jr,rows:3,onChange:D=>ts(D.target.value,D.target),onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),Ml(Jr)),D.key==="Escape"&&Xt(!1)},placeholder:G,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"}}),Q.length>0&&t.jsx("div",{className:"border-t border-[var(--border)] bg-[var(--bg-card)]",children:Q.map(D=>t.jsx("button",{type:"button",onMouseDown:re=>{re.preventDefault(),re.stopPropagation()},onClick:re=>{re.preventDefault(),re.stopPropagation(),Kn(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:Ce?"var(--danger)":"var(--text-muted)"},children:Ce??(b?`${N.length||1} filtro${(N.length||1)===1?"":"s"} activo${(N.length||1)===1?"":"s"}`:"Enter aplica la consulta. Shift + Enter agrega linea.")}),N.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))]}),ml&&Rr.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(P.HiClock,{className:"h-3.5 w-3.5"}),"Historial"]}),t.jsxs("button",{type:"button",onClick:()=>{wr([]),xr(!1)},className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs text-[var(--text-muted)]",children:[t.jsx(P.HiTrash,{className:"h-3 w-3"}),"Limpiar"]})]}),Rr.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:re=>{re.preventDefault(),re.stopPropagation()},onClick:re=>{re.preventDefault(),re.stopPropagation(),Kn(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:()=>wr(re=>re.filter(fe=>fe!==D)),className:"rounded p-1 text-[var(--text-muted)] opacity-0 transition-opacity group-hover:opacity-100",children:t.jsx(P.HiXMark,{className:"h-3.5 w-3.5"})})]},D))]}),bl&&Se.length>0&&t.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:Se.map(D=>t.jsxs("button",{type:"button",onMouseDown:re=>{re.preventDefault(),re.stopPropagation()},onClick:re=>{re.preventDefault(),re.stopPropagation(),Kn(D.bql),yr(!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:[b&&t.jsxs("button",{type:"button",onClick:Tl,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(P.HiXMark,{className:"h-3.5 w-3.5"}),"Limpiar"]}),t.jsxs("button",{type:"button",onClick:()=>Ml(Jr),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(P.HiCheck,{className:"h-3.5 w-3.5"}),"Aplicar"]})]})]}),document.body)]})]}),We&&t.jsx("button",{ref:Wn,type:"button","aria-haspopup":"menu","aria-expanded":en,"aria-label":"Exportar datos",title:"Exportar datos",onClick:()=>{var re;const D=(re=Wn.current)==null?void 0:re.getBoundingClientRect();D&&Cf({top:D.bottom+4,right:window.innerWidth-D.right}),jn(fe=>!fe)},className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-card)] hover:text-[var(--primary)] focus:bg-[var(--bg-card)] focus:text-[var(--primary)] ${en?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(P.HiArrowDownTray,{className:"h-4 w-4"})}),le&&t.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":Ge&&Qe==="visibility","aria-label":j,title:j,onClick:D=>Al(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)] ${Ge&&Qe==="visibility"?"bg-[var(--bg-card)] text-[var(--primary)]":""}`,children:t.jsx(P.HiCog6Tooth,{className:"h-4 w-4"})})]})},ql=()=>{if(!Zf)return null;const b=Zi(Re,is);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 ${I?"px-2 py-0.5":"px-3 py-1"}`,style:{borderColor:"var(--border)",background:"var(--bg-input)"},children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:Rt===0?"0 filas":`${Qf}–${Jf} de ${Rt}`}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{style:{color:"var(--text-muted)"},children:"Filas:"}),t.jsx(zt,{value:String(Nt),onChange:N=>Rf(Number(N)),options:Dl.map(N=>({value:String(N),label:String(N)})),placeholder:"Filas",searchable:!1,disabled:a,height:z,padding:Y,className:"shrink-0 [&>button]:rounded-md [&>button]:text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",style:{width:U}})]})]}),t.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[t.jsx("button",{disabled:a||Re<=1,onClick:()=>cs(Re-1),onMouseEnter:N=>{N.currentTarget.disabled||(N.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",N.currentTarget.style.color="var(--primary)")},onMouseLeave:N=>{N.currentTarget.style.background="transparent",N.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(P.HiChevronLeft,{className:"h-3.5 w-3.5"})}),b.map((N,Q)=>N==="..."?t.jsx("span",{className:"px-1",style:{color:"var(--text-muted)"},children:"…"},`e${Q}`):t.jsx("button",{disabled:a,onClick:()=>cs(N),onMouseEnter:D=>{D.currentTarget.disabled||N===Re||(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=N===Re?"var(--primary)":"transparent",D.currentTarget.style.color=N===Re?"var(--primary-fg)":"var(--text-muted)"},className:"h-5 w-5 cursor-pointer rounded text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-60",style:{background:N===Re?"var(--primary)":"transparent",color:N===Re?"var(--primary-fg)":"var(--text-muted)"},children:N},N)),t.jsx("button",{disabled:a||Re>=is,onClick:()=>cs(Re+1),onMouseEnter:N=>{N.currentTarget.disabled||(N.currentTarget.style.background="color-mix(in srgb, var(--primary) 14%, var(--bg-card))",N.currentTarget.style.color="var(--primary)")},onMouseLeave:N=>{N.currentTarget.style.background="transparent",N.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(P.HiChevronRight,{className:"h-3.5 w-3.5"})})]}),t.jsx("div",{"aria-hidden":"true"})]})},nb=()=>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:Jn},children:[ta(),na(),aa(),t.jsx("div",{ref:Ht,className:"min-w-0 max-w-full overflow-hidden",children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:nn,minWidth:Rn},children:[t.jsx("div",{role:"rowgroup",style:S?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ea()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:Math.min(6,o)}).map((b,N)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Mr,borderBottom:`1px solid ${Oe}`},children:[pt&&t.jsx("div",{role:"cell",className:`${I?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`}},"select-cell"),it.map((Q,D)=>t.jsx("div",{role:"cell",className:I?"px-2 py-1.5":"px-3 py-2",style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${yl(N,D)}%`,minWidth:32}})},Q.key))]},N))})]})})]}),us="min-w-0 max-w-full overflow-hidden";return X&&et&&!he?t.jsx(ln,{rows:o,columns:Math.max(4,it.length||7)}):!a&&r.length===0&&!Ja?nb():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:Jn},children:[ta(),na(),aa(),t.jsx("div",{ref:Ht,className:us,children:t.jsx(bs.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:wl,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:nn,minWidth:Rn},children:[t.jsx("div",{role:"rowgroup",style:S?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ea()}),t.jsx("div",{role:"rowgroup",children:Array.from({length:o}).map((b,N)=>t.jsxs("div",{role:"row",className:"grid",style:{gridTemplateColumns:Mr,borderBottom:`1px solid ${Oe}`},children:[pt&&t.jsx("div",{role:"cell",className:`${I?"px-2 py-1.5":"px-3 py-2"} w-10`,style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`}},"select-cell"),it.map((Q,D)=>{const re=Zn[Q.key],fe=re!==void 0,ve=Q.key===ls;return t.jsx("div",{role:"cell","data-dt-column-key":Q.key,className:I?"px-2 py-1.5":"px-3 py-2",style:fe?{position:"sticky",left:re,zIndex:1,background:"color-mix(in srgb, var(--bg-card) 72%, transparent)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",boxShadow:ve?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Oe}`:`inset 0 -1px 0 ${Oe}`,borderRight:`1px solid ${Oe}`}:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},children:t.jsx("div",{className:"h-3.5 rounded-full animate-pulse",style:{background:"var(--border)",width:`${yl(N,D)}%`,minWidth:32}})},Q.key)})]},N))})]})})}),ql()]}):!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:Jn},children:[ta(),na(),aa(),t.jsx("div",{ref:Ht,className:us,children:t.jsx("div",{role:"table",className:"text-sm",style:{width:nn,minWidth:Rn},children:t.jsx("div",{role:"rowgroup",style:S?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ea()})})}),t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-3 border-t px-6 py-12 text-center",style:{borderColor:Oe,background:"linear-gradient(180deg, color-mix(in srgb, var(--bg-input) 58%, transparent), var(--bg-card))"},children:[t.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full border",style:{borderColor:"color-mix(in srgb, var(--primary) 24%, var(--border))",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-card))",color:"var(--primary)"},children:l??t.jsx(P.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:Jn},children:[ta(),na(),aa(),t.jsx("div",{ref:Ht,className:us,children:t.jsx(bs.OverlayScrollbarsComponent,{options:{scrollbars:{autoHide:"leave",autoHideDelay:200}},className:"w-full",style:{maxHeight:wl,maxWidth:"100%"},defer:!0,children:t.jsxs("div",{role:"table",className:"text-sm",style:{width:nn,minWidth:Rn},children:[t.jsx("div",{role:"rowgroup",style:S?{position:"sticky",top:0,zIndex:10,backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"}:void 0,children:ea()}),t.jsx("div",{role:"rowgroup",children:Hl.map((b,N)=>{const Q=n(b),D=zl(k==null?void 0:k(b)),re=N>0?zl(k==null?void 0:k(Hl[N-1])):null,fe=D&&D.key!==(re==null?void 0:re.key),ve=pt&&T.has(Q),Te=pt&&(!$||$(b)),Ke=Er?(m==null?void 0:m(b))??!0:!1,Ue=Ke&&Il.has(Q),rt=!!d||w&&Ke,Ye=ve&&v?"color-mix(in srgb, var(--primary) 8%, var(--bg-card))":N%2===1?"color-mix(in srgb, var(--bg-input) 30%, var(--bg-card))":"var(--bg-card)";return t.jsxs(s.Fragment,{children:[fe&&t.jsx("div",{role:"row",className:`grid ${D.className??""}`,style:{gridTemplateColumns:Mr},children:t.jsx("div",{role:"cell",className:I?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--primary) 8%, var(--bg-input))",borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},children:t.jsx("div",{className:"flex min-w-0 items-center justify-between gap-3",children:t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"truncate text-xs font-semibold uppercase tracking-wider text-[var(--text-main)]",children: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:rt?ge=>{const Me=ge.target;if(!(Me!=null&&Me.closest('[data-dt-disable-row-click="true"]'))){if(w&&Ke){Bl(Q);return}d==null||d(b)}}:void 0,className:`grid transition-colors ${rt?"cursor-pointer":""} ${y?y(b):""}`,style:{gridTemplateColumns:Mr,"--dt-row-bg":Ye,"--dt-sticky-bg":Ye,background:"var(--dt-row-bg)",borderBottom:`1px solid ${Oe}`},onMouseEnter:ge=>{ve||(ge.currentTarget.style.setProperty("--dt-row-bg","var(--bg-hover)"),ge.currentTarget.style.setProperty("--dt-sticky-bg",eb))},onMouseLeave:ge=>{ge.currentTarget.style.setProperty("--dt-row-bg",Ye),ge.currentTarget.style.setProperty("--dt-sticky-bg",Ye)},children:[Er&&t.jsx("div",{role:"cell",className:`${I?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},"data-dt-disable-row-click":"true",children:Ke&&t.jsx("button",{type:"button","aria-label":Ue?"Contraer fila":"Desplegar fila","aria-expanded":Ue,onClick:ge=>{ge.stopPropagation(),Bl(Q)},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--primary)]",children:Ue?t.jsx(P.HiChevronDown,{className:"h-4 w-4"}):t.jsx(P.HiChevronRight,{className:"h-4 w-4"})})}),pt&&t.jsx("div",{role:"cell",className:`${I?"px-2 py-1.5":"px-3 py-2"} flex w-10 items-center justify-center`,style:ss?{position:"sticky",left:0,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:`inset 0 -1px 0 ${Oe}`}:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`},onClick:ge=>{ge.stopPropagation(),Te&&h(Q)},children:t.jsx(cn,{size:"sm",checked:ve,disabled:!Te,"aria-label":Te?"Seleccionar fila":"Fila no seleccionable",containerClassName:"items-center",className:Te?"cursor-pointer":"cursor-not-allowed opacity-50",onClick:ge=>ge.stopPropagation(),onChange:()=>{Te&&h(Q)}})}),it.map(ge=>{const Me=Zn[ge.key],we=Me!==void 0,ye=ge.key===ls,xe=jt(ge);return t.jsx("div",{role:"cell","data-dt-column-key":ge.key,"data-dt-disable-row-click":ge.disableRowClick||xe?"true":void 0,className:`${xe?"px-2 py-1.5 justify-center text-center":`${I?"px-2 py-1.5":"px-3 py-2"} ${Fl(ge.align)}`} flex min-w-0 items-center ${Ui} ${ge.className??""}`,style:{overflow:"hidden",whiteSpace:"nowrap",...we?{position:"sticky",left:Me,zIndex:3,background:"var(--dt-sticky-bg)",boxShadow:ye?`3px 0 6px -2px rgba(0,0,0,0.10), inset 0 -1px 0 ${Oe}`:`inset 0 -1px 0 ${Oe}`,borderRight:`1px solid ${Oe}`}:{borderBottom:`1px solid ${Oe}`,borderRight:`1px solid ${Oe}`}},children:t.jsx(Is,{children:t.jsx("div",{"data-dt-autofit-content":!0,className:"inline-block max-w-none align-middle",children:ge.cell(b)})})},ge.key)})]}),Ue&&u&&t.jsx("div",{role:"row",className:"grid",style:{gridTemplateColumns:Mr},children:t.jsx("div",{role:"cell",className:I?"px-2 py-2":"px-3 py-3",style:{gridColumn:"1 / -1",background:"color-mix(in srgb, var(--bg-input) 60%, var(--bg-card))",borderBottom:`1px solid ${Oe}`},children:u(b)})})]},Q)})})]})})}),ql()]})}const Ri={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 ec(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=Ri[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 tc=new Set(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Home","End","Enter","Escape"]);function rc({initialValue:e,type:r,mask:n,onCommit:a,onCancel:o}){const[l,i]=s.useState(e),c=s.useRef(null),d=(n==null?void 0:n.preset)==="date",u=d?"date":r==="number"?"number":"text";return s.useEffect(()=>{var m,f;(m=c.current)==null||m.focus(),d||(f=c.current)==null||f.select()},[d]),t.jsx("input",{ref:c,type:u,value:l,maxLength:n==null?void 0:n.maxLength,onChange:m=>i(m.target.value),onBlur:()=>o(),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),a(l)),m.key==="Escape"&&(m.preventDefault(),o()),(n==null?void 0:n.preset)==="integer"&&!m.ctrlKey&&!m.metaKey&&!tc.has(m.key)&&!/^[\d-]$/.test(m.key)&&m.preventDefault()},onClick:m=>m.stopPropagation(),className:"w-full min-w-0 border-0 bg-transparent p-0 text-sm text-[var(--text-main)] outline-none"})}function nc({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(zt,{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 ac={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px",background:"color-mix(in srgb, var(--primary) 5%, var(--bg-card))"},ha={outline:"2px solid var(--primary)",outlineOffset:"-2px",borderRadius:"4px"};function sc({columns:e,data:r,getRowId:n,onCellUpdate:a,readOnly:o=!1,...l}){const[i,c]=s.useState(r),d=s.useRef(null);s.useEffect(()=>{d.current||c(r)},[r]);const[u,m]=s.useState(null);d.current=u;const[f,p]=s.useState(null),x=s.useRef(null);x.current=f;const[w,T]=s.useState({}),[h,E]=s.useState(null),$=s.useRef(null);$.current=h;const[v,y]=s.useState({}),[k,S]=s.useState({}),A=s.useRef(new Set),C=s.useRef(null);s.useEffect(()=>{var O;const B=document.activeElement;(!B||B===document.body)&&((O=C.current)==null||O.focus({preventScroll:!0}))},[]);const U=e.map(B=>{var O,le,g;return`${B.key}:${((g=(le=(O=B.editable)==null?void 0:O.select)==null?void 0:le.options)==null?void 0:g.length)??-1}`}).join("|");s.useEffect(()=>{e.forEach(B=>{var g,_;const O=(_=(g=B.editable)==null?void 0:g.select)==null?void 0:_.options;if(!O)return;const le=v[B.key];(!A.current.has(B.key)||(le==null?void 0:le.length)===0&&O.length>0)&&(A.current.add(B.key),y(ee=>({...ee,[B.key]:O})))})},[U]);const z=s.useCallback(async(B,O)=>{if(A.current.has(B))return;A.current.add(B);const{url:le,fetchOptions:g}=O.select??{};if(!(!le&&!g)){S(_=>({..._,[B]:!0}));try{let _=[];if(g)_=await g();else if(le){const ee=await fetch(le);if(!ee.ok)throw new Error("fetch failed");_=await ee.json()}y(ee=>({...ee,[B]:_}))}catch{y(_=>({..._,[B]:[]}))}finally{S(_=>({..._,[B]:!1}))}}},[]),Y=s.useRef(i);Y.current=i;const M=s.useRef(a);M.current=a;const J=s.useRef(n);J.current=n;const H=s.useRef(e);H.current=e;const ne=s.useRef(o);ne.current=o,s.useEffect(()=>{if(e.length>0&&r.length>0){const B=e.find(O=>O.selectable!==!1);B&&p({rowId:n(r[0]),colKey:B.key})}},[]),s.useEffect(()=>{if(!f)return;const B=C.current;if(!B)return;const O=B.querySelector(`[data-cell-id="${f.rowId}:${f.colKey}"]`);if(!O)return;const le=B.querySelector('[role="rowgroup"]');O.style.scrollMarginTop=`${(le==null?void 0:le.offsetHeight)??0}px`;const g=B.querySelector('[role="row"]');let _=0;g&&g.querySelectorAll('[role="cell"], [role="columnheader"]').forEach(ee=>{ee.style.position==="sticky"&&ee.style.left!==""&&(_=Math.max(_,parseFloat(ee.style.left)+ee.offsetWidth))}),O.style.scrollMarginLeft=`${_}px`,O.scrollIntoView({block:"nearest",inline:"nearest"})},[f]);const X=s.useCallback(B=>{var _;const O=H.current,le=new Set,g=[];(_=C.current)==null||_.querySelectorAll("[data-cell-id]").forEach(ee=>{const ae=ee.dataset.cellId.split(":")[0];le.has(ae)||(le.add(ae),g.push(ae))}),p(ee=>{if(!ee)return ee;const ae=O.findIndex(R=>R.key===ee.colKey),j=g.indexOf(ee.rowId);let K=ae,L=j;if(B==="up")L=Math.max(0,j-1);else if(B==="down")L=Math.min(g.length-1,j+1);else if(B==="left"){let R=ae-1;for(;R>=0&&O[R].selectable===!1;)R--;R>=0&&(K=R)}else if(B==="right"){let R=ae+1;for(;R<O.length&&O[R].selectable===!1;)R++;R<O.length&&(K=R)}return K===ae&&L===j?ee:{rowId:g[L],colKey:O[K].key}})},[]),W=s.useCallback((B=!0)=>{const O=d.current;m(null),O&&p(O),B&&setTimeout(()=>{var le;return(le=C.current)==null?void 0:le.focus({preventScroll:!0})},0)},[]),q=s.useCallback(async(B,O,le)=>{var ie;const g=H.current.find(pe=>pe.key===O);if(!(g!=null&&g.editable))return;const{field:_,type:ee,mask:ae,validate:j}=g.editable,K=ee==="number"?le===""?null:Number(le):le;if(ae){const pe=ec(le,ae);if(pe){T(Ce=>({...Ce,[`${B}:${O}`]:pe}));return}}if(j){const pe=j(K);if(pe){T(Ce=>({...Ce,[`${B}:${O}`]:pe}));return}}const L=J.current,R=Y.current.find(pe=>L(pe)===B);if(!R)return;const F=R[_];m(null),T(pe=>{const Ce={...pe};return delete Ce[`${B}:${O}`],Ce});const se=Y.current,G=se.findIndex(pe=>L(pe)===B),de=se[Math.min(se.length-1,G+1)];if(p({rowId:L(de),colKey:O}),setTimeout(()=>{var Ce,De;const pe=document.activeElement;(!pe||pe===document.body||(Ce=C.current)!=null&&Ce.contains(pe))&&((De=C.current)==null||De.focus({preventScroll:!0}))},0),String(F??"")===String(K??""))return;const Se={...R,[_]:K};c(pe=>pe.map(Ce=>L(Ce)===B?Se:Ce)),E({rowId:B,colKey:O});try{await((ie=M.current)==null?void 0:ie.call(M,{row:R,rowId:B,field:_,oldValue:F,newValue:K}))}catch{c(pe=>pe.map(Ce=>L(Ce)===B?R:Ce)),T(pe=>({...pe,[`${B}:${O}`]:"Error al guardar. Intenta de nuevo."}))}finally{E(null)}},[]),I=s.useCallback(B=>{if($.current){B.preventDefault();return}if(d.current)return;const O=x.current;if(!(!O||!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter","Escape","Tab"].includes(B.key)))switch(B.preventDefault(),B.key){case"ArrowUp":X("up");break;case"ArrowDown":X("down");break;case"ArrowLeft":X("left");break;case"ArrowRight":X("right");break;case"Tab":X(B.shiftKey?"left":"right");break;case"Enter":{const g=H.current.find(_=>_.key===O.colKey);g!=null&&g.editable&&!ne.current?(m(O),g.editable.type==="select"&&!A.current.has(O.colKey)&&z(O.colKey,g.editable)):X("down");break}}},[X,z]),oe=s.useMemo(()=>e.map(B=>{if(!B.editable||o){const le={...B};if(delete le.editable,delete le.selectable,B.selectable===!1)return{...le,disableRowClick:!0};const g=le.cell;return{...le,className:`relative ${le.className??""}`.trim(),disableRowClick:!0,cell:_=>{const ee=n(_),ae=(f==null?void 0:f.rowId)===ee&&(f==null?void 0:f.colKey)===B.key;return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${ee}:${B.key}`,className:"absolute inset-0 z-10 cursor-default",onClick:()=>{var j;$.current||(p({rowId:ee,colKey:B.key}),(j=C.current)==null||j.focus({preventScroll:!0}))}}),ae&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:ha}),t.jsx("span",{className:"relative z-0 pointer-events-none",children:g(_)})]})}}}const O=B.editable;return{...B,className:`relative ${B.className??""}`.trim(),disableRowClick:!0,cell:le=>{const g=n(le),_=B.key,ee=(u==null?void 0:u.rowId)===g&&(u==null?void 0:u.colKey)===_,ae=(f==null?void 0:f.rowId)===g&&(f==null?void 0:f.colKey)===_,j=w[`${g}:${_}`],K=(h==null?void 0:h.rowId)===g&&(h==null?void 0:h.colKey)===_,L=le[O.field],R=String(L??""),F=()=>{var G;$.current||(p({rowId:g,colKey:_}),m({rowId:g,colKey:_}),(G=C.current)==null||G.focus({preventScroll:!0}),O.type==="select"&&!A.current.has(_)&&z(_,O))};if(ee){const G=O.type==="select"?t.jsx(nc,{initialValue:R,options:v[_]??[],loading:k[_]??!1,onCommit:de=>q(g,_,de),onCancel:W}):t.jsx(rc,{initialValue:R,type:O.type??"text",mask:O.mask,onCommit:de=>q(g,_,de),onCancel:W});return t.jsx("div",{className:"absolute inset-0 flex items-center px-2",style:ac,onClick:de=>de.stopPropagation(),children:G})}const se=B.cell(le);return t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-cell-id":`${g}:${_}`,className:`peer absolute inset-0 z-10 ${K?"cursor-wait":"cursor-pointer"}`,onClick:F}),ae&&!K&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",style:ha}),K&&t.jsxs("div",{className:"pointer-events-none absolute inset-0 z-20 flex items-center gap-1.5 bg-[var(--bg-card)]/80 px-2",style:ha,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:j?t.jsxs("span",{className:"flex items-center gap-1 text-red-500",children:[t.jsx(P.HiExclamationCircle,{className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"truncate text-xs",children:j})]}):t.jsx("span",{className:"truncate",children:se})}),!K&&t.jsx(P.HiPencil,{className:"pointer-events-none absolute right-1 top-1/2 z-0 h-3 w-3 -translate-y-1/2 shrink-0 text-[var(--text-muted)] opacity-0 transition-opacity peer-hover:opacity-40"})]})}}}),[e,o,u,f,h,w,v,k,n,q,W,z]);return t.jsx("div",{ref:C,tabIndex:0,onKeyDown:I,onBlur:B=>{var O;(O=C.current)!=null&&O.contains(B.relatedTarget)||setTimeout(()=>{var g,_;const le=document.activeElement;le&&((g=le.closest)!=null&&g.call(le,"[data-bonsaif-select-dropdown]"))||(_=C.current)!=null&&_.contains(le)||W(!1)},0)},style:{width:"100%",minWidth:0,outline:"none"},children:t.jsx(Os,{...l,columns:oe,data:i,getRowId:n})})}function Je(e){if(e)return new Date(`${e}T12:00:00`)}function ht(e){const r=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return`${r}-${n}-${a}`}function sr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Hs(e){return e.map(r=>Je(r)).filter(r=>!!r)}function oc(e){if(!(e!=null&&e.length))return[];const r=new Set(e.map(ht));return Array.from(r).sort()}function ga(e){return new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(e)}function Bs(e){const r=Je(e);if(!r)return e;const n=ga(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 va={weekend:{dayOfWeek:[0,6]}},ya={weekend:"bonsaif-weekend"};function xa({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 lc={background:"var(--primary)",color:"var(--primary-fg, #ffffff)",borderRadius:999},ic={background:"color-mix(in srgb, var(--primary) 22%, transparent)",color:"var(--text-main)",borderRadius:999};function cc({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?lc:null,...o?ic:null,...l?{fontWeight:800}:null,...n.style}})}function dc({startDate:e,endDate:r,onChange:n,minDate:a,viewMonth:o,numberOfMonths:l=1,orientation:i="horizontal",showSummary:c=!0,startLabel:d="Inicio",endLabel:u="Regreso",className:m=""}){const f={from:Je(e),to:Je(r)},p=Je(a),[x,w]=s.useState(()=>Je(o||e)??new Date);s.useEffect(()=>{const v=Je(o||e);v&&w(v)},[o,e]);const T=s.useMemo(()=>{if(l<=1)return sr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(x));const v=new Date(x.getFullYear(),x.getMonth()+l-1,1),y=x.getFullYear()===v.getFullYear(),k=new Intl.DateTimeFormat("es-MX",{month:"short",...y?{}:{year:"numeric"}}).format(x),S=new Intl.DateTimeFormat("es-MX",{month:"short",year:"numeric"}).format(v);return`${sr(k)} – ${sr(S)}`},[x,l]);function h(){w(new Date(x.getFullYear(),x.getMonth()-1,1))}function E(){w(new Date(x.getFullYear(),x.getMonth()+1,1))}const $=l>1?`bonsaif-range-months bonsaif-range-months--multi bonsaif-range-months--${i}`:"bonsaif-range-months";return t.jsxs("div",{className:`bonsaif-calendar bonsaif-date-range-picker ${m}`.trim(),children:[t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes anterior",onClick:h,children:t.jsx(P.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:T}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Mes siguiente",onClick:E,children:t.jsx(P.HiChevronRight,{size:16})})]}),t.jsx(oa.DayPicker,{mode:"range",selected:f,month:x,onMonthChange:w,onSelect:v=>{const y=v!=null&&v.from?ht(v.from):e,k=v!=null&&v.to?ht(v.to):"";n({startDate:y,endDate:k})},numberOfMonths:l,hideNavigation:!0,weekStartsOn:1,disabled:p?{before:p}:void 0,showOutsideDays:!1,modifiers:va,modifiersClassNames:ya,components:{DayButton:cc,Weekday:xa},classNames:{root:"bonsaif-range-daypicker w-full",months:$,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:v=>`${sr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(v))} ${v.getFullYear()}`,formatWeekdayName:ga}})]}),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 Fs({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 Ps(e,r){const n=Je(e),a=Je(r);if(!n||!a)return[];const o=n<=a?n:a,l=n<=a?a:n,i=[],c=new Date(o);for(;c<=l;)i.push(ht(c)),c.setDate(c.getDate()+1);return i}function _s(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 Pr(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 uc(e,r){return typeof r!="number"||r<=0||e.length<=r?e:e.slice(-r)}function hn(e,r,n){return!!(r&&e<r||n&&e>n)}function zs({value:e,onChange:r,disabled:n=!1,minDate:a,maxDate:o,maxDates:l,retainOutsidePrefix:i}){const c=s.useRef(null),d=s.useRef(null),u=s.useRef(!1),m=s.useRef(e);m.current=e;const f=s.useCallback(v=>{let y=v;if(i){const k=m.current.filter(A=>!A.startsWith(i)),S=v.filter(A=>A.startsWith(i));y=[...k,...S].sort()}r==null||r(uc(y,l))},[l,r,i]),p=s.useCallback(v=>v.filter(y=>!hn(y,a,o)),[a,o]),x=s.useCallback(()=>{d.current=null},[]);s.useEffect(()=>{const v=()=>x();return window.addEventListener("pointerup",v),window.addEventListener("pointercancel",v),()=>{window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v)}},[x]);const w=s.useCallback((v,y,k,S)=>{const A=p(Ps(v,y));f(k==="add"?Pr(S,A,"add"):Pr(S,A,"remove"))},[f,p]),T=s.useCallback((v,y)=>{if(n||y.button!==0)return;const k=ht(v);if(hn(k,a,o)||y.shiftKey)return;u.current=!0;const S=[...m.current],A=S.includes(k)?"remove":"add";d.current={active:!0,mode:A,anchor:k,latest:k,baseline:S},c.current=k,w(k,k,A,S),y.preventDefault()},[w,n,o,a]),h=s.useCallback(v=>{const y=d.current;if(!(y!=null&&y.active)||n)return;const k=ht(v);hn(k,a,o)||y.latest!==k&&(y.latest=k,w(y.anchor,k,y.mode,y.baseline))},[w,n,o,a]),E=s.useCallback((v,y)=>{if(n)return;const k=ht(v);if(!hn(k,a,o)){if(u.current&&!y.shiftKey){u.current=!1,y.preventDefault(),y.stopPropagation();return}if(u.current=!1,y.shiftKey&&c.current){y.preventDefault(),y.stopPropagation();const S=p(Ps(c.current,k));f(Pr(m.current,S,"add"));return}c.current=k,f(Pr(m.current,[k],"toggle"))}},[f,n,p,o,a]),$=s.useCallback(v=>{if(n)return;const y=p(oc(v));if(!y.length)return;const k=y.every(S=>m.current.includes(S));f(Pr(m.current,y,k?"remove":"add")),c.current=y[0]??c.current},[f,n,p]);return{onDayPointerDown:T,onDayPointerEnter:h,onDayClick:E,toggleWeek:$,endDrag:x}}function _r(e){return _s(e,1)[0]}function js(e,r){const n=new Date(e);return n.setDate(n.getDate()+r),n}function fc({value:e=[],onChange:r,minDate:n,maxDate:a,viewMonth:o,maxDates:l,showWeekNumbers:i=!1,viewMode:c,defaultViewMode:d="month",onViewModeChange:u,showSummary:m=!0,className:f="",disabled:p=!1}){const x=s.useMemo(()=>Hs(e),[e]),w=s.useMemo(()=>new Set(e),[e]),T=Je(n),h=Je(a),[E,$]=s.useState(()=>Je(o||e[0])??new Date),[v,y]=s.useState(()=>_r(Je(o||e[0])??new Date)),[k,S]=s.useState(d),A=c??k;function C(I){c===void 0&&S(I),u==null||u(I)}s.useEffect(()=>{const I=Je(o);I&&($(I),y(_r(I)))},[o]);const{onDayPointerDown:U,onDayPointerEnter:z,onDayClick:Y,toggleWeek:M}=zs({value:e,onChange:r,disabled:p,minDate:n,maxDate:a,maxDates:l}),J=s.useCallback(I=>t.jsx(Fs,{...I,className:`bonsaif-multi-day-btn ${I.className??""}`,onDayPointerDown:U,onDayPointerEnter:z,onDayClickSelect:Y}),[Y,U,z]),H=s.useMemo(()=>_s(v,1),[v]),ne=H[6],X=A==="week"?`${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short"}).format(H[0])} – ${new Intl.DateTimeFormat("es-MX",{day:"numeric",month:"short",year:"numeric"}).format(ne)}`:sr(new Intl.DateTimeFormat("es-MX",{month:"long",year:"numeric"}).format(E));function W(){if(A==="week"){const I=js(v,-7);y(_r(I)),$(I);return}$(new Date(E.getFullYear(),E.getMonth()-1,1))}function q(){if(A==="week"){const I=js(v,7);y(_r(I)),$(I);return}$(new Date(E.getFullYear(),E.getMonth()+1,1))}return t.jsxs("div",{className:`bonsaif-calendar bonsaif-multi-date-calendar ${f}`,children:[t.jsxs("div",{className:"bonsaif-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-view-toggle",role:"tablist","aria-label":"Vista",children:[t.jsx("button",{type:"button",role:"tab","aria-selected":A==="month",className:`bonsaif-cal-view-btn${A==="month"?" is-active":""}`,disabled:p,onClick:()=>{C("month"),$(v)},children:"Mes"}),t.jsx("button",{type:"button",role:"tab","aria-selected":A==="week",className:`bonsaif-cal-view-btn${A==="week"?" is-active":""}`,disabled:p,onClick:()=>{C("week"),y(_r(E))},children:"Semana"})]}),t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":A==="week"?"Semana anterior":"Mes anterior",disabled:p,onClick:W,children:t.jsx(P.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:X}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":A==="week"?"Semana siguiente":"Mes siguiente",disabled:p,onClick:q,children:t.jsx(P.HiChevronRight,{size:16})})]}),t.jsxs("p",{className:"bonsaif-cal-hint",children:["Click · Shift+click rango · Arrastra",i&&A==="month"?" · Semana (nº)":"",A==="week"?" · Botón semana completa":""]}),A==="month"?t.jsx(oa.DayPicker,{mode:"multiple",required:!1,selected:x,month:E,onMonthChange:$,onSelect:()=>{},hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,showWeekNumber:i,onWeekNumberClick:(I,oe)=>{M(oe)},disabled:p?!0:[...T?[{before:T}]:[],...h?[{after:h}]:[]],className:"bonsaif-multi-daypicker",modifiers:va,modifiersClassNames:ya,classNames:{root:"bonsaif-multi-daypicker",months:"bonsaif-multi-months",month:"bonsaif-multi-month",month_caption:"bonsaif-multi-caption-hidden",month_grid:"bonsaif-multi-month-grid",weekdays:i?"bonsaif-multi-weekdays bonsaif-multi-weekdays--with-week":"bonsaif-multi-weekdays",weekday:"bonsaif-multi-weekday",week:i?"bonsaif-multi-week bonsaif-multi-week--with-week":"bonsaif-multi-week",week_number:"bonsaif-week-number",week_number_header:"bonsaif-week-number-header",day:"bonsaif-multi-day",day_button:"bonsaif-multi-day-btn",selected:"bonsaif-multi-day-selected",today:"bonsaif-multi-day-today",disabled:"bonsaif-multi-day-disabled",hidden:"bonsaif-multi-day-hidden"},components:{DayButton:J,Weekday:xa},formatters:{formatWeekdayName:ga}}):t.jsxs("div",{className:"bonsaif-week-view",children:[t.jsx("div",{className:"bonsaif-week-view-head",children:H.map(I=>t.jsx("div",{className:"bonsaif-multi-weekday",children:new Intl.DateTimeFormat("es-MX",{weekday:"short"}).format(I)},`h-${ht(I)}`))}),t.jsx("div",{className:"bonsaif-week-view-days",children:H.map(I=>{const oe=ht(I),B=w.has(oe),O=p||(n?oe<n:!1)||(a?oe>a:!1),le=oe===ht(new Date);return t.jsx("div",{className:`bonsaif-multi-day${B?" bonsaif-multi-day-selected":""}${le?" bonsaif-multi-day-today":""}${O?" bonsaif-multi-day-disabled":""}`,children:t.jsxs("button",{type:"button",className:"bonsaif-multi-day-btn",disabled:O,"aria-pressed":B,onPointerDown:g=>U(I,g),onPointerEnter:()=>z(I),onClick:g=>Y(I,g),children:[t.jsx("span",{className:"bonsaif-week-day-num",children:I.getDate()}),t.jsx("span",{className:"bonsaif-week-day-month",children:new Intl.DateTimeFormat("es-MX",{month:"short"}).format(I)})]})},oe)})}),t.jsx("button",{type:"button",className:"bonsaif-week-select-all",disabled:p,onClick:()=>M(H),children:"Marcar / desmarcar semana"})]})]}),m?t.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?t.jsx("span",{children:"Sin fechas seleccionadas"}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(I=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:p,onClick:()=>r==null?void 0:r(e.filter(oe=>oe!==I)),title:`Quitar ${I}`,children:[Bs(I),t.jsx("span",{"aria-hidden":!0,children:"×"})]},I))})]})}):null]})}const bc=Array.from({length:12},(e,r)=>r);function mc({value:e=[],onChange:r,year:n,onYearChange:a,minDate:o,maxDate:l,maxDates:i,showSummary:c=!0,className:d="",disabled:u=!1,readOnly:m=!1}){const f=s.useMemo(()=>Hs(e),[e]),p=Je(o),x=Je(l),w=n??(e[0]?Number(e[0].slice(0,4)):new Date().getFullYear()),[T,h]=s.useState(w);s.useEffect(()=>{typeof n=="number"&&h(n)},[n]);function E(C){h(C),a==null||a(C)}const{onDayPointerDown:$,onDayPointerEnter:v,onDayClick:y}=zs({value:e,onChange:r,disabled:u||m,minDate:o,maxDate:l,maxDates:i,retainOutsidePrefix:`${T}-`}),k=s.useCallback(C=>t.jsx(Fs,{...C,className:`bonsaif-year-day-btn ${C.className??""}`,onDayPointerDown:$,onDayPointerEnter:v,onDayClickSelect:y}),[y,$,v]),S=f.filter(C=>C.getFullYear()===T),A=u?!0:[...p?[{before:p}]:[],...x?[{after:x}]:[]];return t.jsxs("div",{className:`bonsaif-calendar bonsaif-year-multi-date-calendar${m?" bonsaif-year-multi-date-calendar--readonly":""} ${d}`,children:[t.jsxs("div",{className:"bonsaif-cal-shell bonsaif-year-cal-shell",children:[t.jsxs("div",{className:"bonsaif-cal-toolbar",children:[t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año anterior",disabled:u,onClick:()=>E(T-1),children:t.jsx(P.HiChevronLeft,{size:16})}),t.jsx("span",{className:"bonsaif-cal-title",children:T}),t.jsx("button",{type:"button",className:"bonsaif-cal-nav-btn","aria-label":"Año siguiente",disabled:u,onClick:()=>E(T+1),children:t.jsx(P.HiChevronRight,{size:16})})]}),!m&&!u?t.jsx("p",{className:"bonsaif-cal-hint",children:"Click · Shift+click rango · Arrastra para marcar varias"}):null,t.jsx("div",{className:"bonsaif-year-cal-grid",children:bc.map(C=>{const U=new Date(T,C,1);return t.jsxs("div",{className:"bonsaif-year-cal-month",children:[t.jsx("div",{className:"bonsaif-year-cal-month-title",children:sr(new Intl.DateTimeFormat("es-MX",{month:"long"}).format(U))}),t.jsx(oa.DayPicker,{mode:"multiple",required:!1,selected:S,month:U,onMonthChange:()=>{},onSelect:()=>{},numberOfMonths:1,hideNavigation:!0,showOutsideDays:!1,weekStartsOn:1,disabled:A,className:"bonsaif-year-month-picker",modifiers:va,modifiersClassNames:ya,classNames:{root:"bonsaif-year-month-picker",months:"bonsaif-year-month-months",month:"bonsaif-year-month-inner",month_caption:"bonsaif-year-month-caption-hidden",month_grid:"bonsaif-year-month-grid",weekdays:"bonsaif-year-weekdays",weekday:"bonsaif-year-weekday",week:"bonsaif-year-week",day:"bonsaif-year-day",day_button:"bonsaif-year-day-btn",selected:"bonsaif-year-day-selected",today:"bonsaif-year-day-today",disabled:"bonsaif-year-day-disabled",hidden:"bonsaif-year-day-hidden"},components:{DayButton:k,Weekday:xa},formatters:{formatWeekdayName:z=>new Intl.DateTimeFormat("es-MX",{weekday:"narrow"}).format(z)}})]},`${T}-${C}`)})})]}),c?t.jsx("div",{className:"bonsaif-cal-summary",children:e.length===0?t.jsx("span",{children:"Sin fechas seleccionadas"}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:[e.length," ",e.length===1?"fecha":"fechas"," ·"," ",T]}),t.jsx("div",{className:"bonsaif-cal-chips",children:e.map(C=>t.jsxs("button",{type:"button",className:"bonsaif-cal-chip",disabled:u||m,onClick:()=>r==null?void 0:r(e.filter(U=>U!==C)),title:`Quitar ${C}`,children:[Bs(C),t.jsx("span",{"aria-hidden":!0,children:"×"})]},C))})]})}):null]})}const pc="bonsaif-ui:hide-tooltips";function Ws(){window.dispatchEvent(new CustomEvent(pc))}function hc(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function gc({trigger:e,items:r,align:n="end",width:a=220,disabled:o=!1,className:l="",menuClassName:i="",onOpenChange:c}){const[d,u]=s.useState(!1),[m,f]=s.useState(!1),[p,x]=s.useState({}),w=s.useRef(null),T=s.useRef(null),h=s.useCallback(k=>{u(k),c==null||c(k)},[c]),E=s.useCallback(()=>{const k=w.current;if(!k)return;const S=k.getBoundingClientRect(),A=typeof a=="number"?a:S.width,C=typeof a=="number"?a:Math.max(S.width,180),U=n==="end"?Math.max(8,S.right-C):Math.min(S.left,window.innerWidth-C-8),z=window.innerHeight-S.bottom,Y=z<240&&S.top>z?void 0:S.bottom+6,M=Y===void 0?window.innerHeight-S.top+6:void 0;x({position:"fixed",zIndex:9999,left:U,top:Y,bottom:M,width:hc(typeof a=="number"?A:a)})},[n,a]);s.useEffect(()=>f(!0),[]),s.useEffect(()=>{if(!d)return;E();const k=A=>{var U,z;const C=A.target;!((U=w.current)!=null&&U.contains(C))&&!((z=T.current)!=null&&z.contains(C))&&h(!1)},S=A=>{A.key==="Escape"&&h(!1)};return document.addEventListener("mousedown",k),window.addEventListener("keydown",S),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0),()=>{document.removeEventListener("mousedown",k),window.removeEventListener("keydown",S),window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[d,h,E]);const $=k=>{o||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),h(!d))},v=s.isValidElement(e)?s.cloneElement(e,{onClick:()=>{o||(Ws(),h(!d))}}):e,y=d?t.jsx("div",{ref:T,role:"menu","data-bonsaif-overlay":"true",className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] p-1 shadow-xl ${i}`,style:p,children:r.map(k=>t.jsxs("div",{children:[k.separatorBefore&&t.jsx("div",{className:"my-1 border-t border-[var(--border)]"}),t.jsxs("button",{type:"button",role:"menuitem",disabled:k.disabled,onClick:()=>{var S;k.disabled||(Ws(),(S=k.onSelect)==null||S.call(k),h(!1))},className:"flex w-full min-w-0 items-start gap-2 rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-[var(--bg-input)] disabled:cursor-not-allowed disabled:opacity-50",style:{color:k.danger?"var(--danger)":"var(--text-main)"},children:[k.icon&&t.jsx("span",{className:"mt-0.5 shrink-0",children:k.icon}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium",children:k.label}),k.description&&t.jsx("span",{className:"block truncate text-xs text-[var(--text-muted)]",children:k.description})]})]})]},k.id))}):null;return t.jsxs("span",{ref:w,role:"button",tabIndex:o?-1:0,"aria-haspopup":"menu","aria-expanded":d,onKeyDown:$,className:`inline-flex ${o?"pointer-events-none opacity-60":""} ${l}`,children:[v,m&&y?nt.createPortal(y,document.body):null]})}const vc=180,qs="bg-[color-mix(in_srgb,var(--bg-main)_72%,transparent)] backdrop-blur-sm";function yc({open:e,onClose:r,title:n,subtitle:a,leadingIcon:o,confirmLabel:l="Guardar",onConfirm:i,loading:c=!1,confirmDisabled:d=!1,headerActions:u,bodyClassName:m="flex-1 overflow-y-auto px-6 py-5",width:f=440,hasUnsavedChanges:p=!1,unsavedChangesTitle:x="Descartar cambios",unsavedChangesDescription:w="Hay cambios sin guardar. Si cierras el drawer se perderán.",unsavedChangesConfirmLabel:T="Descartar",unsavedChangesCancelLabel:h="Seguir editando",onDiscardChanges:E,disabled:$=!1,disabledMessage:v,children:y}){const[k,S]=s.useState(!1),[A,C]=s.useState(!1),[U,z]=s.useState(!1),Y=s.useCallback(()=>{C(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>z(!0))})},[]),M=s.useCallback(()=>{z(!1),window.setTimeout(()=>C(!1),vc)},[]),J=$||c,H=s.useCallback(()=>{if(!J){if(p){Y();return}r()}},[J,p,r,Y]),ne=s.useCallback(()=>{z(!1),C(!1),E==null||E(),r()},[r,E]);if(s.useEffect(()=>{S(!0)},[]),s.useEffect(()=>(document.body.style.overflow=e?"hidden":"",e||(z(!1),C(!1)),()=>{document.body.style.overflow=""}),[e]),s.useEffect(()=>{if(!e)return;const W=q=>{if(q.key==="Escape"&&!J){if(A){M();return}H()}};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[M,J,A,e,H]),!k)return null;const X=v!==void 0?v:c?"Guardando…":null;return nt.createPortal(t.jsxs("div",{"aria-hidden":!e,"data-bonsaif-overlay":e?"true":void 0,className:`fixed inset-0 z-[1000] flex transition-opacity duration-300 ${e?"opacity-100":"opacity-0 pointer-events-none"}`,children:[t.jsx("div",{className:`absolute inset-0 ${qs}`,onClick:H}),t.jsxs("div",{className:`absolute inset-y-0 right-0 flex flex-col shadow-2xl transition-transform duration-300 ${e?"translate-x-0":"translate-x-full"}`,style:{width:`min(100vw, ${f}px)`,background:"var(--bg-card)",borderLeft:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center justify-between px-6 py-4 flex-shrink-0",style:{borderBottom:"1px solid var(--border)"},children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx(je,{variant:"icon",onClick:H,title:"Cerrar",disabled:J,children:t.jsx(P.HiXMark,{className:"w-5 h-5"})}),o&&t.jsx("div",{className:"flex-shrink-0",children:o}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"text-base font-semibold truncate",style:{color:"var(--text-main)"},children:n}),a&&t.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:a})]})]}),(u||i)&&t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[u,i&&t.jsxs(t.Fragment,{children:[t.jsx(je,{variant:"secondary",size:"sm",onClick:H,disabled:J,style:{background:"var(--bg-input)"},children:"Cancelar"}),t.jsx(je,{variant:"primary",size:"sm",icon:t.jsx(Xl.FiSave,{className:"w-4 h-4"}),onClick:i,loading:c,disabled:d||J,title:l})]})]})]}),t.jsx("div",{"data-drawer-scroll":"true",className:m,children:y}),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:X?t.jsxs("div",{className:"flex max-w-xs flex-col items-center gap-3 text-center",children:[t.jsx("div",{className:"h-9 w-9 animate-spin rounded-full border-2 border-[var(--border)] border-t-[var(--primary)]","aria-hidden":!0}),t.jsx("p",{className:"text-sm font-semibold text-[var(--text-main)]",children:X})]}):null})]}),A&&t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":x,className:"fixed inset-0 z-[1001] flex items-center justify-center p-4",children:[t.jsx("div",{className:`absolute inset-0 ${qs} transition-opacity duration-200 ease-out ${U?"opacity-100":"opacity-0"}`,onClick:M}),t.jsxs("div",{className:`relative z-10 w-full max-w-sm rounded-2xl border p-6 shadow-2xl transition-[opacity,transform] duration-200 ease-out ${U?"translate-y-0 scale-100 opacity-100":"translate-y-2 scale-[0.96] opacity-0"}`,style:{background:"var(--bg-card, #ffffff)",borderColor:"var(--border, #d8e1dc)"},children:[t.jsx(je,{variant:"icon",onClick:M,className:"absolute right-3 top-3 h-7 w-7 hover:opacity-70",style:{color:"var(--text-muted, #6b7f78)"},"aria-label":h,children:t.jsx(P.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(P.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:x}),t.jsx("p",{className:"text-sm",style:{color:"var(--text-muted, #6b7f78)"},children:w}),t.jsxs("div",{className:"mt-6 flex gap-2",children:[t.jsx(je,{variant:"secondary",onClick:M,className:"flex-1 border",style:{background:"var(--bg-input, #f7faf8)",borderColor:"var(--border, #d8e1dc)",color:"var(--text-main, #0f2f2c)"},children:h}),t.jsx(je,{variant:"secondary",onClick:ne,className:"flex-1 border",style:{background:"var(--warning, #d97706)",borderColor:"transparent",color:"#fff",boxShadow:"0 10px 22px rgba(217, 119, 6, 0.22)"},children:T})]})]})]})]}),document.body)}const xc=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,wc=/^\+?[0-9\s().-]+$/,kc=7,Nc=15;function gt(e){return e==null||String(e).trim()===""}function Us(e){return typeof e=="number"?e:typeof e=="string"&&e.trim()!==""?Number(e):Number.NaN}function wa(e){return gt(e)?!1:xc.test(String(e))}function ka(e){if(gt(e))return!1;const r=String(e),n=r.replace(/\D/g,"");return wc.test(r)&&n.length>=kc&&n.length<=Nc}function Sc(e="Este campo es requerido."){return r=>gt(r)?e:void 0}function Cc(e="Ingresa un correo valido."){return r=>gt(r)||wa(r)?void 0:e}function Ec(e="Ingresa un telefono valido."){return r=>gt(r)||ka(r)?void 0:e}function Mc(e,r){return n=>gt(n)||String(n).length>=e?void 0:r??`Debe tener al menos ${e} caracteres.`}function Tc(e,r){return n=>gt(n)||String(n).length<=e?void 0:r??`Debe tener ${e} caracteres o menos.`}function $c(e,r){return n=>{if(gt(n))return;const a=Us(n);return Number.isFinite(a)&&a>=e?void 0:r??`Debe ser mayor o igual a ${e}.`}}function Ac(e,r){return n=>{if(gt(n))return;const a=Us(n);return Number.isFinite(a)&&a<=e?void 0:r??`Debe ser menor o igual a ${e}.`}}function Lc(e,r="El formato no es valido."){return n=>gt(n)||e.test(String(n))?void 0:r}function Dc(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 Vs={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Xs=s.createContext&&s.createContext(Vs),Ic=["attr","size","title"];function Oc(e,r){if(e==null)return{};var n,a,o=Hc(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 Hc(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 Ys(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 vn(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?Ys(Object(n),!0).forEach(function(a){Bc(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ys(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function Bc(e,r,n){return(r=Fc(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function Fc(e){var r=Pc(e,"string");return typeof r=="symbol"?r:r+""}function Pc(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 Ks(e){return e&&e.map((r,n)=>s.createElement(r.tag,vn({key:n},r.attr),Ks(r.child)))}function Na(e){return r=>s.createElement(_c,gn({attr:vn({},e.attr)},r),Ks(e.child))}function _c(e){var r=n=>{var{attr:a,size:o,title:l}=e,i=Oc(e,Ic),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:vn(vn({color:e.color||n.color},n.style),e.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),l&&s.createElement("title",null,l),e.children)};return Xs!==void 0?s.createElement(Xs.Consumer,null,n=>r(n)):r(Vs)}function Gs(e){return Na({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 zc(e){return Na({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 jc(e){return Na({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M228,175a8,8,0,0,1-10.92-3l-19-33.2A123.23,123.23,0,0,1,162,155.46l5.87,35.22a8,8,0,0,1-6.58,9.21A8.4,8.4,0,0,1,160,200a8,8,0,0,1-7.88-6.69l-5.77-34.58a133.06,133.06,0,0,1-36.68,0l-5.77,34.58A8,8,0,0,1,96,200a8.4,8.4,0,0,1-1.32-.11,8,8,0,0,1-6.58-9.21L94,155.46a123.23,123.23,0,0,1-36.06-16.69L39,172A8,8,0,1,1,25.06,164l20-35a153.47,153.47,0,0,1-19.3-20A8,8,0,1,1,38.22,99c16.6,20.54,45.64,45,89.78,45s73.18-24.49,89.78-45A8,8,0,1,1,230.22,109a153.47,153.47,0,0,1-19.3,20l20,35A8,8,0,0,1,228,175Z"},child:[]}]})(e)}function or({content:e,ariaLabel:r="Más información",className:n=""}){return t.jsx(_t,{as:"span",content:e,className:`inline-flex shrink-0 align-middle text-[var(--text-muted)] outline-none transition-colors hover:text-[var(--primary)] focus-visible:text-[var(--primary)] ${n}`,children:t.jsx("span",{tabIndex:0,role:"img","aria-label":r,className:"inline-flex items-center justify-center outline-none",children:t.jsx(P.HiInformationCircle,{className:"h-3.5 w-3.5"})})})}function lr({error:e,helperText:r,helperDisplay:n="inline"}){return e?t.jsx("span",{className:"text-xs font-medium normal-case text-[var(--danger)]",children:e}):r&&n!=="tooltip"?t.jsx("span",{className:"text-xs font-medium normal-case text-[var(--text-muted)]",children:r}):null}function yn({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 Sa({label:e,containerClassName:r="",helperText:n,helperDisplay:a="inline",error:o,errorDisplay:l="inline",errorTooltipLabel:i="Error de validacion",labelAction:c,floatingLabel:d=!1,showPasswordToggle:u=!0,nativeValidation:m=!1,className:f="",required:p,...x}){const[w,T]=s.useState(()=>!!x.autoFocus),[h,E]=s.useState(!1),$=x.type==="password"&&u,v=$&&h?"text":x.type,y=!!o,k=y&&l!=="tooltip",S=y&&l!=="inline",A=!!n&&a==="tooltip"&&!k,C=m?p:void 0,U=y?"border-[var(--danger)] focus:border-[var(--danger)]":"",z=S?$?"pr-20":"pr-10":$?"pr-10":"",Y=x.value!==void 0?String(x.value).length>0:x.defaultValue!==void 0&&String(x.defaultValue).length>0,M=w||Y,J={top:M?7:12,color:w?"var(--primary)":"var(--text-muted)",fontSize:M?10:13,fontWeight:M?600:400,textTransform:M?"uppercase":"none"},H=I=>{var oe;T(!0),(oe=x.onFocus)==null||oe.call(x,I)},ne=I=>{var oe;T(!1),(oe=x.onBlur)==null||oe.call(x,I)},X=$?t.jsxs("button",{type:"button","aria-label":h?"Ocultar contraseña":"Mostrar contraseña","aria-pressed":h,className:"absolute right-2.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors duration-200 hover:text-[var(--primary)] focus:outline-none",tabIndex:-1,onClick:()=>E(I=>!I),children:[t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${h?"scale-y-0 rotate-[-8deg] opacity-0":"scale-y-100 rotate-0 opacity-100"}`,children:t.jsx(zc,{className:"h-[18px] w-[18px]"})}),t.jsx("span",{"aria-hidden":"true",className:`absolute inset-0 flex items-center justify-center transition-[opacity,transform] duration-200 ease-out ${h?"scale-y-100 rotate-0 opacity-100":"scale-y-0 rotate-[8deg] opacity-0"}`,children:t.jsx(jc,{className:"h-[18px] w-[18px]"})})]}):null,W=S?t.jsx(_t,{as:"span",content:o,className:`absolute top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-[var(--danger)] outline-none transition-colors hover:bg-[var(--danger-bg)] focus-visible:bg-[var(--danger-bg)] ${$?"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(Gs,{className:"h-[18px] w-[18px]"})})}):null,q=t.jsx(lr,{error:k?o:void 0,helperText:n,helperDisplay:a});return d?t.jsxs("label",{className:`flex flex-col gap-2 ${r}`,children:[t.jsxs("span",{className:"relative block",children:[t.jsx(yn,{...x,type:v,required:C,placeholder:" ","aria-invalid":y||x["aria-invalid"],"data-has-value":Y?"true":void 0,className:`h-11 w-full pt-5 ${z} ${U} ${f}`,onFocus:H,onBlur:ne}),t.jsxs("span",{className:"pointer-events-none absolute left-3 transition-all duration-150",style:J,children:[e,p&&t.jsx("span",{className:"ml-1 text-[var(--danger)]",children:"*"})]}),c&&t.jsx("span",{className:"absolute right-2 transition-all duration-150",style:{top:M?7:12},children:c}),W,X]}),q]}):t.jsxs("label",{className:`flex flex-col gap-2 ${r}`,children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[t.jsx("span",{children:e}),p&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),A?t.jsx(or,{content:n}):null,c&&t.jsx("span",{className:"ml-auto normal-case",children:c})]}),$?t.jsxs("span",{className:"relative block",children:[t.jsx(yn,{...x,type:v,required:C,"aria-invalid":y||x["aria-invalid"],className:`w-full ${z} ${U} ${f}`,onFocus:H,onBlur:ne}),W,X]}):t.jsxs("span",{className:"relative block",children:[t.jsx(yn,{...x,required:C,"aria-invalid":y||x["aria-invalid"],className:`w-full ${z} ${U} ${f}`}),W]}),q]})}function Zs(e){return e==null?"":String(e)}function Wc({autoComplete:e="email",inputMode:r="email",validate:n=!0,invalidMessage:a="Ingresa un correo valido.",errorDisplay:o="tooltip",error:l,value:i,defaultValue:c,onChange:d,...u}){const[m,f]=s.useState(()=>Zs(c)),p=i!==void 0?Zs(i):m,x=n&&p.length>0&&!wa(p)?a:void 0,w=T=>{i===void 0&&f(T.currentTarget.value),d==null||d(T)};return t.jsx(Sa,{...u,value:i,defaultValue:c,type:"text",inputMode:r,autoComplete:e,error:l??x,errorDisplay:o,onChange:w})}const qc={sm:"min-h-[160px] p-4",md:"min-h-[220px] p-6",lg:"min-h-[300px] p-8"};function Uc({title:e="Sin resultados",description:r,icon:n=t.jsx(P.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 ${qc[l]} ${i}`,children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[n&&t.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg border border-[var(--border)] bg-[var(--bg-input)] text-[var(--text-muted)]",children:n}),t.jsxs("div",{className:"space-y-1",children:[e&&t.jsx("h3",{className:"text-sm font-semibold text-[var(--text-main)]",children:e}),r&&t.jsx("div",{className:"text-sm leading-5 text-[var(--text-muted)]",children:r})]}),(a||o)&&t.jsxs("div",{className:"mt-1 flex flex-wrap items-center justify-center gap-2",children:[o,a]})]})})}const Vc={sm:"min-h-[112px] p-4",md:"min-h-[148px] p-5",lg:"min-h-[184px] p-6"};function Xc(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 Qs(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 Yc(e,r,n){return r?n===void 0?e:e.slice(0,Math.max(0,n)):e.slice(0,1)}function Kc({label:e,helperText:r,helperDisplay:n="inline",error:a,labelAction:o,value:l,defaultValue:i=[],onFilesChange:c,onRejectedFiles:d,multiple:u=!1,maxFiles:m,appendFiles:f=!1,showFileList:p=!0,clearable:x=!0,browseLabel:w="Buscar archivos",dropLabel:T="Suelta los archivos aqui",emptyLabel:h="Arrastra y suelta archivos",emptyDescription:E="o haz click para buscarlos en tu equipo",selectedLabel:$="Archivos seleccionados",size:v="md",containerClassName:y="",dropzoneClassName:k="",fileListClassName:S="",className:A="",id:C,accept:U,disabled:z,required:Y,...M}){const J=s.useId(),H=C??J,ne=s.useRef(null),[X,W]=s.useState(!1),[q,I]=s.useState(i),oe=l??q,B=!!a,O=!!r&&n==="tooltip"&&!B,le=x&&oe.length>0&&!z,g=(G,de)=>{l===void 0&&I(G),c==null||c(G,de)},_=(G,de)=>{const Se=G.filter(De=>Qs(De,U)),ie=G.filter(De=>!Qs(De,U)),pe=f?[...oe,...Se]:Se,Ce=Yc(pe,u,m);ie.length>0&&(d==null||d(ie)),g(Ce,de)},ee=()=>{var G;z||(G=ne.current)==null||G.click()},ae=G=>{_(Array.from(G.target.files??[]),G),G.target.value=""},j=G=>{G.preventDefault(),z||W(!0)},K=G=>{G.currentTarget.contains(G.relatedTarget)||W(!1)},L=G=>{G.preventDefault(),W(!1),!z&&_(Array.from(G.dataTransfer.files),G)},R=G=>{G.key!=="Enter"&&G.key!==" "||(G.preventDefault(),ee())},F=G=>{g(oe.filter((de,Se)=>Se!==G))},se=()=>{g([])};return t.jsxs("div",{className:`flex flex-col gap-2 ${y}`,children:[(e||o||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}),Y&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),O?t.jsx(or,{content:r}):null,o&&t.jsx("span",{className:"ml-auto normal-case",children:o})]}),t.jsx("input",{...M,ref:ne,id:H,type:"file",accept:U,multiple:u,disabled:z,required:Y&&oe.length===0,"aria-invalid":B||M["aria-invalid"],className:"sr-only",onChange:ae}),t.jsxs("div",{role:"button",tabIndex:z?-1:0,"aria-controls":H,"aria-disabled":z||void 0,"aria-invalid":B||void 0,className:`flex cursor-pointer flex-col items-center justify-center gap-3 rounded-lg border border-dashed bg-[var(--bg-card)] text-center outline-none transition-colors focus:border-[var(--primary)] focus:bg-[var(--bg-input)] ${Vc[v]} ${X?"border-[var(--primary)] bg-[var(--bg-input)]":B?"border-[var(--danger)]":"border-[var(--border)]"} ${z?"cursor-not-allowed opacity-60":"hover:border-[var(--primary)] hover:bg-[var(--bg-input)]"} ${k} ${A}`,onClick:ee,onDragOver:j,onDragLeave:K,onDrop:L,onKeyDown:R,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(P.HiArrowUpTray,{className:"h-5 w-5"})}),t.jsxs("span",{className:"space-y-1",children:[t.jsx("span",{className:"block text-sm font-semibold text-[var(--text-main)]",children:X?T:h}),E&&t.jsx("span",{className:"block text-sm text-[var(--text-muted)]",children:E})]}),w&&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:w})]}),p&&oe.length>0&&t.jsxs("div",{className:`rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${S}`,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:$}),le&&t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover:bg-[var(--bg-input)] hover:text-[var(--danger)] focus:outline-none","aria-label":"Quitar todos los archivos",onClick:se,children:t.jsx(P.HiTrash,{className:"h-4 w-4"})})]}),t.jsx("ul",{className:"divide-y divide-[var(--border)]",children:oe.map((G,de)=>t.jsxs("li",{className:"flex items-center gap-3 px-3 py-2",children:[t.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-[var(--bg-input)] text-[var(--text-muted)]",children:t.jsx(P.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:G.name}),t.jsx("span",{className:"block text-xs text-[var(--text-muted)]",children:Xc(G.size)})]}),!z&&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 ${G.name}`,onClick:()=>F(de),children:t.jsx(P.HiXMark,{className:"h-4 w-4"})})]},`${G.name}-${G.lastModified}-${de}`))})]}),t.jsx(lr,{error:a,helperText:r,helperDisplay:n})]})}const Gc=[{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 Zc({fields:e,title:r="Layout",fieldTypes:n=Gc,saveLabel:a="Guardar",allowAddField:o=!1,addFieldPlaceholder:l="Nuevo campo",addFieldLabel:i="Anadir",loading:c=!1,onSave:d,onChange:u}){const[m,f]=s.useState(()=>e.map(v=>({key:!1,type:"",...v}))),[p,x]=s.useState(""),[w,T]=s.useState(""),h=s.useCallback((v,y)=>{f(k=>{const S=k.map((A,C)=>C===v?{...A,...y}:A);return u==null||u(S),S})},[u]),E=s.useCallback(()=>{d==null||d(m)},[m,d]),$=s.useCallback(()=>{var S;const v=p.trim();if(!v){T("Ingresa un nombre de campo.");return}if(m.some(A=>A.name.toLowerCase()===v.toLowerCase())){T("Ese campo ya existe en el arreglo.");return}const k={name:v,key:!1,type:((S=n[0])==null?void 0:S.value)??""};f(A=>{const C=[...A,k];return u==null||u(C),C}),x(""),T("")},[n,m,p,u]);return t.jsxs("div",{className:"flex flex-col rounded-xl border shadow-sm",style:{borderColor:"var(--border)",background:"var(--bg-card)",color:"var(--text-main)"},children:[t.jsx("div",{className:"border-b px-6 py-4",style:{borderColor:"var(--border)"},children:t.jsx("span",{className:"text-base font-semibold",style:{color:"var(--text-main)"},children:r})}),t.jsxs("div",{className:"grid grid-cols-[1fr_80px_1fr] gap-4 border-b px-6 py-2 text-xs font-medium uppercase tracking-wide",style:{borderColor:"var(--border)",color:"var(--text-muted)"},children:[t.jsx("span",{children:"Campo"}),t.jsx("span",{className:"text-center",children:"Llave"}),t.jsx("span",{children:"Tipo de Campo"})]}),t.jsxs("div",{className:"max-h-[420px] overflow-y-auto",children:[m.map((v,y)=>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:v.name}),t.jsx("div",{className:"flex justify-center",children:t.jsx(cn,{size:"sm",checked:v.key??!1,onChange:k=>h(y,{key:k.target.checked}),"aria-label":`${v.name} es clave`})}),t.jsx(zt,{value:v.type??"",onChange:k=>h(y,{type:k}),options:n,placeholder:"—",emptyLabel:"—",height:36,searchable:!1,ariaLabel:`Tipo de ${v.name}`})]},v.name)),m.length===0&&t.jsx("p",{className:"px-6 py-8 text-center text-sm",style:{color:"var(--text-muted)"},children:"No hay campos disponibles."})]}),t.jsx("div",{className:"flex justify-end border-t px-6 py-4",style:{borderColor:"var(--border)"},children:t.jsxs("div",{className:"w-full space-y-2",children:[o&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:p,onChange:v=>{x(v.currentTarget.value),w&&T("")},onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),$())},placeholder:l,className:"min-w-0 flex-1 rounded-lg border px-3 py-2 text-sm outline-none transition-colors",style:{borderColor:"var(--border)",background:"var(--bg-input)",color:"var(--text-main)"},"aria-label":"Nombre del nuevo campo"}),t.jsx(je,{variant:"secondary",onClick:$,height:36,padding:"0 12px",children:i})]}),w&&t.jsx("p",{className:"text-xs",style:{color:"var(--danger)"},children:w})]}),t.jsx("div",{className:"flex justify-end",children:t.jsx(je,{variant:"primary",onClick:E,disabled:c,loading:c,children:a})})]})})]})}function Ca({label:e,children:r,helperText:n,helperDisplay:a="inline",error:o,labelAction:l,required:i=!1,className:c="",contentClassName:d=""}){const u=!!n&&a==="tooltip"&&!o;return t.jsxs("label",{className:`flex flex-col gap-2 ${c}`,children:[(e||l||u)&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[e&&t.jsx("span",{children:e}),i&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),u?t.jsx(or,{content:n}):null,l&&t.jsx("span",{className:"ml-auto normal-case",children:l})]}),t.jsx("span",{className:`block ${d}`,children:r}),t.jsx(lr,{error:o,helperText:n,helperDisplay:a})]})}function Qc(e){return Array.from(e.querySelectorAll("img")).filter(r=>!!(r.currentSrc||r.src||"").trim())}function Js(e,r){const n=e.target;if(!(n instanceof HTMLImageElement))return!1;const a=e.currentTarget,o=Qc(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 dt=260,ir=420,Ea=380,vt="cubic-bezier(0.22, 1, 0.36, 1)",Jc="cubic-bezier(0.16, 1, 0.3, 1)",Ma="cubic-bezier(0.22, 1, 0.36, 1)",Rc="cubic-bezier(0.22, 1, 0.36, 1)",ed=8,td=1,rd=1.25,Ta={background:"color-mix(in srgb, var(--bg-card) 90%, transparent)",border:"1px solid var(--border)",boxShadow:"0 10px 28px color-mix(in srgb, var(--bg-main) 28%, transparent), inset 0 1px 0 color-mix(in srgb, var(--bg-card) 55%, transparent)",color:"var(--text-main)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)"},nd="color-mix(in srgb, var(--bg-card) 88%, var(--primary) 12%)",$a=10;function zr(e,r,n){return Math.min(n,Math.max(r,e))}function ad(e){return!e||e.width<1||e.height<1?null:{left:e.left,top:e.top,width:e.width,height:e.height}}function Rs(e,r){if(r.width<1||r.height<1)return{dx:0,dy:0,scale:1};const n=Math.min(e.width/r.width,e.height/r.height),a=e.left+e.width/2-(r.left+r.width/2),o=e.top+e.height/2-(r.top+r.height/2);return{dx:a,dy:o,scale:Number.isFinite(n)?n:1}}function cr({label:e,onClick:r,children:n,disabled:a,size:o="md"}){const l=o==="lg"?44:40;return t.jsx("button",{type:"button","aria-label":e,title:e,disabled:a,onClick:i=>{i.stopPropagation(),r()},className:"inline-flex items-center justify-center rounded-full disabled:cursor-not-allowed disabled:opacity-35",style:{...Ta,width:l,height:l,transition:"background 160ms ease, transform 160ms cubic-bezier(0.22, 1, 0.36, 1), opacity 160ms ease"},onMouseEnter:i=>{a||(i.currentTarget.style.background=nd,i.currentTarget.style.transform="scale(1.06)")},onMouseLeave:i=>{i.currentTarget.style.background=String(Ta.background??""),i.currentTarget.style.transform="scale(1)"},onMouseDown:i=>{a||(i.currentTarget.style.transform="scale(0.94)")},onMouseUp:i=>{a||(i.currentTarget.style.transform="scale(1.06)")},children:n})}function eo({open:e,onClose:r,slides:n,index:a,onIndexChange:o,originRect:l=null,maxZoom:i=ed,minZoom:c=td,zoomStep:d=rd,closeOnBackdrop:u=!0,closeOnEscape:m=!0,showCounter:f=!0,showZoomControls:p=!0,loop:x=!0,showThumbnails:w=!0,zIndex:T=1100,ariaLabel:h="Visor de imagen"}){const[E,$]=s.useState(!1),[v,y]=s.useState(!1),[k,S]=s.useState(a??0),[A,C]=s.useState(1),[U,z]=s.useState({x:0,y:0}),[Y,M]=s.useState({opacity:1,x:0,scale:1,blur:0,animate:!1}),[J,H]=s.useState({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),[ne,X]=s.useState(!1),W=s.useRef(null),q=s.useRef(null),I=s.useRef(null),oe=s.useRef(null),B=s.useRef(null),O=s.useRef(!1),le=s.useRef(!1),g=s.useRef(null),_=s.useRef(null),ee=s.useRef(null),ae=s.useRef(null),j=s.useRef(null),K=s.useRef(a??0),L=a??k,R=n.length===0?0:zr(L,0,Math.max(0,n.length-1)),F=n[R],se=n.length>1,G=Math.max(c,i),de=w&&se,Se=s.useCallback(ce=>{if(n.length===0)return;const ue=n.length-1,Ee=x?(ce%n.length+n.length)%n.length:zr(ce,0,ue);a===void 0&&S(Ee),o==null||o(Ee)},[a,x,o,n.length]),ie=s.useCallback(()=>{C(1),z({x:0,y:0})},[]),pe=s.useCallback((ce,ue)=>{if(ue<=c+.001)return{x:0,y:0};const Ee=ae.current,Ie=j.current;if(!Ee||!Ie)return ce;const Le=Ee.getBoundingClientRect(),Pe=Ie.offsetWidth*ue,Ge=Ie.offsetHeight*ue,Ze=Math.max(0,(Pe-Le.width)/2+Le.width*.15),Qe=Math.max(0,(Ge-Le.height)/2+Le.height*.15);return{x:zr(ce.x,-Ze,Ze),y:zr(ce.y,-Qe,Qe)}},[c]),Ce=s.useCallback(()=>{$(!1),H({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),oe.current=null,B.current=null,O.current=!1,le.current=!1,g.current&&(clearTimeout(g.current),g.current=null)},[]),De=s.useCallback(()=>{if(O.current)return;O.current=!0,y(!1),ie();const ce=oe.current,ue=ce!=null&&B.current!=null&&B.current===R;if(ce&&ue){I.current!=null&&cancelAnimationFrame(I.current),I.current=requestAnimationFrame(()=>{I.current=requestAnimationFrame(()=>{const Ee=j.current;if(!Ee){I.current=null,W.current&&clearTimeout(W.current),W.current=setTimeout(Ce,dt+40);return}const Ie=Ee.getBoundingClientRect(),Le=Rs(ce,Ie);H({enabled:!0,dx:0,dy:0,scale:1,animate:!1}),I.current=requestAnimationFrame(()=>{H({enabled:!0,dx:Le.dx,dy:Le.dy,scale:Le.scale,animate:!0}),I.current=null})})}),W.current&&clearTimeout(W.current),W.current=setTimeout(Ce,ir+80);return}H({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),W.current&&clearTimeout(W.current),W.current=setTimeout(Ce,dt+40)},[Ce,ie,R]);s.useEffect(()=>(e?(W.current&&clearTimeout(W.current),g.current&&(clearTimeout(g.current),g.current=null),O.current=!1,le.current=!1,oe.current=ad(l),B.current=oe.current!=null?a??k:null,$(!0),y(!1),oe.current?H({dx:0,dy:0,scale:1,animate:!1,enabled:!0}):(B.current=null,requestAnimationFrame(()=>requestAnimationFrame(()=>{y(!0),H({dx:0,dy:0,scale:1,animate:!1,enabled:!1})})))):E&&De(),()=>{W.current&&clearTimeout(W.current),I.current!=null&&cancelAnimationFrame(I.current)}),[e]);const mt=s.useCallback(()=>{if(!e||O.current||le.current)return;const ce=oe.current,ue=j.current;if(!ce||!ue){ce||(y(!0),le.current=!0);return}const Ee=ue.getBoundingClientRect();if(Ee.width<2||Ee.height<2)return;le.current=!0;const Ie=Rs(ce,Ee);H({enabled:!0,dx:Ie.dx,dy:Ie.dy,scale:Ie.scale,animate:!1}),I.current!=null&&cancelAnimationFrame(I.current),I.current=requestAnimationFrame(()=>{I.current=requestAnimationFrame(()=>{H({enabled:!0,dx:0,dy:0,scale:1,animate:!0}),y(!0),I.current=null,g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{H({dx:0,dy:0,scale:1,animate:!1,enabled:!1}),g.current=null},ir+20)})})},[e]);s.useLayoutEffect(()=>{!E||!e||!oe.current||le.current||mt()},[E,e,mt]),s.useEffect(()=>{!e||O.current||B.current!=null&&B.current!==R&&H(ce=>ce.enabled?{dx:0,dy:0,scale:1,animate:!1,enabled:!1}:ce)},[e,R]),s.useEffect(()=>{if(!e)return;const ce=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=ce}},[e]),s.useEffect(()=>{e&&ie()},[e,R,ie]),s.useEffect(()=>{a!==void 0&&S(a)},[a]),s.useEffect(()=>{if(!e){K.current=R,M({opacity:1,x:0,scale:1,blur:0,animate:!1});return}const ce=K.current;if(ce===R)return;K.current=R;const ue=n.length;let Ee=1;if(ue>1){const Ie=(ce+1)%ue===R,Le=(ce-1+ue)%ue===R;Le&&!Ie?Ee=-1:Ie&&!Le?Ee=1:Ee=R>ce?1:-1}return q.current!=null&&(cancelAnimationFrame(q.current),q.current=null),M({opacity:0,x:Ee*56,scale:.94,blur:8,animate:!1}),q.current=requestAnimationFrame(()=>{q.current=requestAnimationFrame(()=>{M({opacity:1,x:0,scale:1,blur:0,animate:!0}),q.current=null})}),()=>{q.current!=null&&(cancelAnimationFrame(q.current),q.current=null)}},[e,R,n.length]);const xt=A<=c+.001&&Math.abs(U.x)<.5&&Math.abs(U.y)<.5,We=s.useCallback((ce,ue,Ee)=>{C(Ie=>{const Le=zr(ce,c,G);if(Math.abs(Le-Ie)<1e-4)return Ie;const Pe=Le/Ie,Ge=Le<Ie;return Le<=c+.001?(z({x:0,y:0}),c):(z(Ze=>{let Qe=Ze;if(typeof ue=="number"&&typeof Ee=="number"&&ae.current&&!Ge){const Et=ae.current.getBoundingClientRect(),Ot=ue-Et.left-Et.width/2,Ut=Ee-Et.top-Et.height/2;Qe={x:Ot-(Ot-Ze.x)*Pe,y:Ut-(Ut-Ze.y)*Pe}}else if(Ge){Qe={x:Ze.x*Pe,y:Ze.y*Pe};const Et=Math.min(1,(Ie-Le)/Math.max(.01,Ie-c));Qe={x:Qe.x*(1-Et*.65),y:Qe.y*(1-Et*.65)}}else Qe={x:Ze.x*Pe,y:Ze.y*Pe};return pe(Qe,Le)}),Le)})},[pe,c,G]),Ae=s.useCallback(()=>{We(A*d)},[We,A,d]),ke=s.useCallback(()=>{const ce=Math.max(c,A/d);if(ce<=c+.001){ie();return}C(ce),z({x:0,y:0})},[c,ie,A,d]);s.useEffect(()=>{if(!e)return;const ce=ue=>{if(ue.key==="Escape"&&m){ue.preventDefault(),r();return}ue.key==="ArrowLeft"&&se?(ue.preventDefault(),Se(R-1)):ue.key==="ArrowRight"&&se?(ue.preventDefault(),Se(R+1)):ue.key==="+"||ue.key==="="?(ue.preventDefault(),We(A*d)):ue.key==="-"||ue.key==="_"?(ue.preventDefault(),ke()):ue.key==="0"&&(ue.preventDefault(),ie())};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[We,m,se,r,e,ie,R,A,Se,ke,d]);const et=ce=>{ce.preventDefault();const ue=ce.deltaY>0?1/d:d;We(A*ue,ce.clientX,ce.clientY)},me=ce=>{A<=c+.001||(ce.currentTarget.setPointerCapture(ce.pointerId),X(!0),_.current={pointerId:ce.pointerId,startX:ce.clientX,startY:ce.clientY,originX:U.x,originY:U.y})},Z=ce=>{const ue=_.current;!ue||ue.pointerId!==ce.pointerId||z(pe({x:ue.originX+(ce.clientX-ue.startX),y:ue.originY+(ce.clientY-ue.startY)},A))},te=ce=>{var ue;((ue=_.current)==null?void 0:ue.pointerId)===ce.pointerId&&(_.current=null,X(!1))},be=ce=>{if(ce.stopPropagation(),A>c+.05){ie();return}We(Math.min(G,3),ce.clientX,ce.clientY)},he=ce=>{if(ce.touches.length!==2)return;X(!0);const[ue,Ee]=[ce.touches[0],ce.touches[1]],Ie=Math.hypot(ue.clientX-Ee.clientX,ue.clientY-Ee.clientY);ee.current={distance:Ie,scale:A}},Be=ce=>{if(ce.touches.length!==2||!ee.current)return;ce.preventDefault();const[ue,Ee]=[ce.touches[0],ce.touches[1]],Ie=Math.hypot(ue.clientX-Ee.clientX,ue.clientY-Ee.clientY),Le=(ue.clientX+Ee.clientX)/2,Pe=(ue.clientY+Ee.clientY)/2,Ge=ee.current.scale*(Ie/Math.max(1,ee.current.distance));We(Ge,Le,Pe)},$e=()=>{ee.current=null,X(!1)};if(!E||!F)return null;const He=J.enabled,Fe=J.animate?`transform ${ir}ms ${Rc}`:"none";return nt.createPortal(t.jsxs("div",{className:"fixed inset-0",style:{zIndex:T},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:v?1:0,transition:`opacity ${He?ir:dt}ms ${vt}`,cursor:"default",zIndex:0},onClick:()=>{u&&r()}}),t.jsx("div",{ref:ae,className:"absolute inset-0 flex items-center justify-center",style:{zIndex:1,padding:de?"4.5rem 3.5rem 6.5rem":"4.5rem 3.5rem 2.5rem",opacity:He||v?1:0,transform:He||v?"translateY(0) scale(1)":"translateY(10px) scale(0.96)",transition:He?"none":`opacity ${dt}ms ${vt}, transform ${dt}ms ${vt}`},onClick:ce=>{ce.target===ce.currentTarget&&u&&r()},onWheel:et,children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{transform:J.enabled?`translate3d(${J.dx}px, ${J.dy}px, 0) scale(${J.scale})`:void 0,transformOrigin:"center center",transition:J.enabled?Fe:void 0},children:t.jsx("div",{className:"relative flex max-h-full max-w-full items-center justify-center will-change-transform",style:{opacity:Y.opacity,filter:Y.blur?`blur(${Y.blur}px)`:"blur(0px)",transform:`translate3d(${Y.x}px, 0, 0) scale(${Y.scale})`,transition:Y.animate?[`opacity ${Ea}ms ${Ma}`,`transform ${Ea}ms ${Ma}`,`filter ${Ea}ms ${Ma}`].join(", "):"none"},children:t.jsx("div",{ref:j,className:"pointer-events-auto relative max-h-full max-w-full touch-none select-none will-change-transform",style:{cursor:A>c+.001?"grab":"zoom-in",transform:`translate3d(${U.x}px, ${U.y}px, 0) scale(${A})`,transformOrigin:"center center",transition:ne?"none":`transform 220ms ${Jc}`},onClick:ce=>ce.stopPropagation(),onDoubleClick:be,onPointerDown:me,onPointerMove:Z,onPointerUp:te,onPointerCancel:te,onTouchStart:he,onTouchMove:Be,onTouchEnd:$e,children:t.jsx("img",{src:F.src,alt:F.alt||"",draggable:!1,className:"block max-h-[min(78vh,820px)] max-w-[min(86vw,1100px)] object-contain",style:{display:"block",borderRadius:$a,imageRendering:A>2.5?"pixelated":"auto"},onLoad:()=>{mt()}},F.src+String(R))})})})}),t.jsxs("div",{className:"pointer-events-none absolute inset-0",style:{zIndex:2,opacity:v?1:0,transform:v?"translateY(0)":"translateY(-6px)",transition:`opacity ${He?ir:dt}ms ${vt}, transform ${He?ir:dt}ms ${vt}`},children:[t.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 flex items-center justify-between gap-3 px-4 pt-4",children:[t.jsx("div",{className:"pointer-events-auto flex items-center gap-2",children:f&&n.length>0?t.jsxs("span",{className:"rounded-full px-3 py-1.5 text-xs font-semibold tracking-wide",style:Ta,children:[R+1," / ",n.length]}):null}),t.jsxs("div",{className:"pointer-events-auto flex items-center gap-2",children:[p?t.jsxs(t.Fragment,{children:[t.jsx(cr,{label:"Alejar",onClick:ke,disabled:A<=c+.001,children:t.jsx(P.HiMinus,{className:"h-5 w-5"})}),t.jsx(cr,{label:"Restablecer tamaño",onClick:ie,disabled:xt,children:t.jsx(P.HiArrowsPointingIn,{className:"h-5 w-5"})}),t.jsx(cr,{label:"Acercar",onClick:Ae,disabled:A>=G-.001,children:t.jsx(P.HiPlus,{className:"h-5 w-5"})})]}):null,t.jsx(cr,{label:"Cerrar",onClick:r,children:t.jsx(P.HiXMark,{className:"h-5 w-5"})})]})]}),se?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"pointer-events-auto absolute left-3 top-1/2",style:{opacity:v?1:0,transform:v?"translate(0, -50%)":"translate(-8px, -50%)",transition:`opacity ${dt}ms ${vt}, transform ${dt}ms ${vt}`},children:t.jsx(cr,{label:"Anterior",size:"lg",onClick:()=>Se(R-1),disabled:!x&&R<=0,children:t.jsx(P.HiChevronLeft,{className:"h-6 w-6"})})}),t.jsx("div",{className:"pointer-events-auto absolute right-3 top-1/2",style:{opacity:v?1:0,transform:v?"translate(0, -50%)":"translate(8px, -50%)",transition:`opacity ${dt}ms ${vt}, transform ${dt}ms ${vt}`},children:t.jsx(cr,{label:"Siguiente",size:"lg",onClick:()=>Se(R+1),disabled:!x&&R>=n.length-1,children:t.jsx(P.HiChevronRight,{className:"h-6 w-6"})})})]}):null,de?t.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex justify-center px-4 pb-4 pt-8",style:{background:"linear-gradient(to top, color-mix(in srgb, var(--bg-sidebar, var(--primary)) 72%, transparent), transparent)"},children:t.jsx("div",{className:"pointer-events-auto flex max-w-full items-end gap-2.5 overflow-x-auto rounded-2xl px-2 py-2",style:{background:"color-mix(in srgb, var(--bg-card) 55%, transparent)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",scrollbarWidth:"thin"},role:"tablist","aria-label":"Miniaturas",children:n.map((ce,ue)=>{const Ee=ue===R;return t.jsx("button",{type:"button",role:"tab","aria-selected":Ee,"aria-label":ce.alt||`Imagen ${ue+1}`,onClick:Ie=>{Ie.stopPropagation(),Se(ue)},className:"relative shrink-0 overflow-hidden transition-opacity",style:{width:56,height:42,borderRadius:$a,opacity:Ee?1:.42,transition:`opacity 180ms ${vt}`},children:t.jsx("img",{src:ce.src,alt:"",draggable:!1,className:"h-full w-full object-cover",style:{borderRadius:$a}})},`${ce.src}-${ue}`)})})}):null]})]}),document.body)}function sd({children:e,className:r,style:n,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c}){const[d,u]=s.useState(!1),[m,f]=s.useState(0),[p,x]=s.useState([]),[w,T]=s.useState(null),h=s.useCallback(($,v,y)=>{x($),T(y??null),f(v),u(!0)},[]),E=s.useCallback($=>{Js($,h)},[h]);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`[&_img]:cursor-zoom-in ${r??""}`,style:n,onClick:E,children:e}),t.jsx(eo,{open:d,onClose:()=>u(!1),index:m,onIndexChange:f,slides:p,originRect:w,maxZoom:a,minZoom:o,zoomStep:l,loop:i,showThumbnails:c})]})}function to(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function ro(e,r){if(e.length!==r.length)return!1;const n=new Set(r);return e.every(a=>n.has(a))}function Aa(e){return e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function od(e,r){if(!r)return!0;const n=Aa(r);return Aa(e.label).includes(n)||!!(e.sublabel&&Aa(e.sublabel).includes(n))}function ld({value:e,onChange:r,options:n,placeholder:a="Seleccionar…",disabled:o=!1,className:l="",style:i,height:c=40,padding:d="6px 10px",searchable:u=!0,minOptionsForSearch:m=6,maxVisibleValues:f=2,truncateSelectedValues:p=!0,emptyText:x="Sin resultados",clearLabel:w="Limpiar seleccion",pruneMissingValues:T=!0}){const[h,E]=s.useState(!1),[$,v]=s.useState(""),[y,k]=s.useState(0),[S,A]=s.useState(!1),[C,U]=s.useState({}),z=s.useRef(null),Y=s.useRef(null),M=s.useRef(null),J=s.useRef(null),H=u&&n.length>=m,ne=s.useMemo(()=>new Set(e),[e]),X=s.useMemo(()=>{const L=new Map;for(const R of n)L.set(R.value,R);return L},[n]),W=s.useMemo(()=>{const L=[];for(const R of e){const F=X.get(R);F&&L.push(F)}return L},[X,e]),q=f==="all"?W.length:f,I=W.slice(0,q),oe=Math.max(0,W.length-I.length),B=s.useMemo(()=>{const L=$.trim();return!H||!L?n:n.filter(R=>od(R,L))},[n,$,H]),O=s.useCallback(()=>{const L=z.current;if(!L)return;const R=L.getBoundingClientRect(),F=H?304:244,se=window.innerHeight-R.bottom,G=se<F&&R.top>se;U({position:"fixed",left:R.left,top:G?void 0:R.bottom+4,bottom:G?window.innerHeight-R.top+4:void 0,width:Math.max(R.width,240),zIndex:9999})},[H]),le=s.useCallback(L=>{ro(e,L)||r(L)},[r,e]),g=s.useCallback(L=>{const R=X.get(L);if(R!=null&&R.disabled)return;const F=ne.has(L)?e.filter(se=>se!==L):[...e,L];le(F)},[le,X,e,ne]),_=s.useCallback(()=>le([]),[le]),ee=s.useCallback(()=>{E(!1),v(""),k(0)},[]);s.useEffect(()=>A(!0),[]);const ae=s.useMemo(()=>n.map(L=>L.value).join("\0"),[n]);s.useEffect(()=>{if(!T||e.length===0||n.length===0)return;const L=new Set(n.map(F=>F.value)),R=e.filter(F=>L.has(F));ro(e,R)||r(R)},[ae]),s.useEffect(()=>{if(!h)return;function L(R){var se,G;const F=R.target;!((se=z.current)!=null&&se.contains(F))&&!((G=Y.current)!=null&&G.contains(F))&&ee()}return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[ee,h]),s.useEffect(()=>{h&&(k(0),O(),H&&setTimeout(()=>{var L;return(L=M.current)==null?void 0:L.focus()},0))},[h,H,O]),s.useEffect(()=>{if(h)return window.addEventListener("resize",O),window.addEventListener("scroll",O,!0),()=>{window.removeEventListener("resize",O),window.removeEventListener("scroll",O,!0)}},[h,O]),s.useEffect(()=>{if(B.length===0){k(0);return}k(L=>Math.min(L,B.length-1))},[B.length]),s.useEffect(()=>{if(y<0||!J.current)return;const L=J.current.children[y];L==null||L.scrollIntoView({block:"nearest"})},[y]);function j(L){if(!o){if(!h){(L.key==="Enter"||L.key===" "||L.key==="ArrowDown")&&(L.preventDefault(),E(!0));return}if(L.key==="Escape"){L.preventDefault(),ee();return}if(L.key==="ArrowDown"){if(L.preventDefault(),B.length===0)return;k(R=>Math.min(R+1,B.length-1));return}if(L.key==="ArrowUp"){L.preventDefault(),k(R=>Math.max(R-1,0));return}if(L.key==="Enter"&&B[y]&&!B[y].disabled){L.preventDefault(),g(B[y].value);return}L.key==="Backspace"&&!$&&e.length&&(L.preventDefault(),le(e.slice(0,-1)))}}const K=t.jsxs("div",{ref:Y,className:"overflow-hidden rounded-xl shadow-xl",style:{...C,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[H&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",style:{borderBottom:"1px solid var(--border)"},children:[t.jsx(P.HiMagnifyingGlass,{className:"h-3.5 w-3.5 flex-shrink-0",style:{color:"var(--text-muted)"}}),t.jsx("input",{ref:M,value:$,onChange:L=>{v(L.target.value),k(0)},onKeyDown:L=>{(L.key==="ArrowDown"||L.key==="ArrowUp"||L.key==="Enter"||L.key==="Escape")&&(L.stopPropagation(),j(L))},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:L=>{L.preventDefault(),v(""),k(0)},children:t.jsx(P.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:[W.length," seleccionados",e.length>W.length?` (${e.length-W.length} no disponibles)`:""]}),t.jsx("button",{type:"button",onMouseDown:L=>{L.preventDefault(),_()},className:"font-semibold transition-colors hover:text-[var(--primary)]",children:w})]}),t.jsxs("ul",{ref:J,role:"listbox","aria-multiselectable":"true",className:"overflow-y-auto",style:{maxHeight:H?220:200,scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:[B.map((L,R)=>{const F=R===y,se=ne.has(L.value);return t.jsxs("li",{role:"option","aria-selected":se,onMouseDown:G=>{G.preventDefault(),!L.disabled&&g(L.value)},onMouseEnter:()=>!L.disabled&&k(R),className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors",style:{background:F?"var(--bg-hover)":se?"color-mix(in srgb, var(--primary) 6%, transparent)":"transparent",color:L.disabled?"var(--text-muted)":"var(--text-main)",cursor:L.disabled?"not-allowed":"pointer",opacity:L.disabled?.58:1},children:[t.jsx("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border",style:{borderColor:se?"var(--primary)":"var(--border)",background:se?"var(--primary)":"var(--bg-input)",color:"var(--primary-fg)"},children:se&&t.jsx(P.HiCheck,{className:"h-3 w-3"})}),L.color&&t.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 rounded-full",style:{background:L.color}}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1 overflow-hidden",children:[t.jsx("span",{className:"truncate",children:L.label}),L.sublabel&&t.jsx("span",{className:"min-w-0 flex-shrink truncate",style:{color:"var(--text-muted)",fontSize:12},children:L.sublabel})]}),L.badge&&t.jsx("span",{className:"flex-shrink-0 text-xs",style:{color:"var(--text-muted)"},children:L.badge})]},L.value)}),B.length===0&&t.jsx("li",{className:"px-3 py-4 text-center text-sm",style:{color:"var(--text-muted)"},children:x})]})]});return t.jsxs("div",{ref:z,className:`relative ${l||"w-full"}`,style:i,onKeyDown:j,children:[t.jsxs("button",{type:"button",disabled:o,onClick:()=>{o||(h?ee():E(!0))},className:"flex w-full items-center gap-2 rounded-lg text-left text-sm transition-colors focus:outline-none",style:{minHeight:to(c),padding:to(d),background:"var(--bg-input)",color:W.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:I.length?t.jsxs(t.Fragment,{children:[I.map(L=>t.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs font-semibold ${p?"max-w-[160px]":"max-w-full whitespace-normal"}`,style:{background:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text-main)"},children:[L.color&&t.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 rounded-full",style:{background:L.color}}),t.jsx("span",{className:p?"truncate":"break-words",children:L.label}),t.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Quitar ${L.label}`,onMouseDown:R=>{R.preventDefault(),R.stopPropagation(),g(L.value)},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(P.HiXMark,{className:"h-3 w-3"})})]},L.value)),oe>0&&t.jsxs("span",{className:"inline-flex items-center rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{background:"color-mix(in srgb, var(--primary) 10%, transparent)",color:"var(--primary)"},children:["+",oe]})]}):t.jsx("span",{className:"truncate",children:a})}),W.length?t.jsx("span",{role:"button",tabIndex:-1,"aria-label":w,onMouseDown:L=>{L.preventDefault(),L.stopPropagation(),_()},className:"flex-shrink-0 rounded-full p-0.5 transition-colors hover:bg-black/10",style:{color:"var(--text-muted)"},children:t.jsx(P.HiXMark,{className:"h-3.5 w-3.5"})}):t.jsx(P.HiChevronDown,{className:"h-4 w-4 flex-shrink-0 transition-transform",style:{color:"var(--text-muted)",transform:h?"rotate(180deg)":"rotate(0deg)"}})]}),h&&S&&nt.createPortal(K,document.body)]})}function id({inputMode:e="decimal",...r}){return t.jsx(Sa,{...r,type:"number",inputMode:e})}function cd(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 dd({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=cd(c,i,o);return t.jsxs("nav",{"aria-label":"Paginacion",className:`inline-flex items-center gap-1 ${l}`,children:[t.jsx(je,{variant:"icon",size:"xs","aria-label":"Pagina anterior",disabled:a||c<=1,onClick:()=>n(c-1),children:t.jsx(P.HiChevronLeft,{className:"h-4 w-4"})}),d.map((u,m)=>u==="..."?t.jsx("span",{className:"flex h-8 min-w-8 items-center justify-center text-xs font-semibold text-[var(--text-muted)]",children:"..."},`ellipsis-${m}`):t.jsx("button",{type:"button","aria-current":u===c?"page":void 0,disabled:a,onClick:()=>n(u),className:"flex h-8 min-w-8 items-center justify-center rounded-md border px-2 text-xs font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-50",style:{borderColor:u===c?"var(--primary)":"var(--border)",background:u===c?"var(--primary)":"var(--bg-card)",color:u===c?"var(--primary-fg)":"var(--text-secondary)"},children:u},u)),t.jsx(je,{variant:"icon",size:"xs","aria-label":"Pagina siguiente",disabled:a||c>=i,onClick:()=>n(c+1),children:t.jsx(P.HiChevronRight,{className:"h-4 w-4"})})]})}const no=[{value:"+1",label:"+1",sublabel:"Estados Unidos, Canada, Caribe"},{value:"+7",label:"+7",sublabel:"Rusia, Kazajistan"},{value:"+20",label:"+20",sublabel:"Egipto"},{value:"+27",label:"+27",sublabel:"Sudafrica"},{value:"+30",label:"+30",sublabel:"Grecia"},{value:"+31",label:"+31",sublabel:"Paises Bajos"},{value:"+32",label:"+32",sublabel:"Belgica"},{value:"+33",label:"+33",sublabel:"Francia"},{value:"+34",label:"+34",sublabel:"Espana"},{value:"+36",label:"+36",sublabel:"Hungria"},{value:"+39",label:"+39",sublabel:"Italia, Vaticano"},{value:"+40",label:"+40",sublabel:"Rumania"},{value:"+41",label:"+41",sublabel:"Suiza"},{value:"+43",label:"+43",sublabel:"Austria"},{value:"+44",label:"+44",sublabel:"Reino Unido"},{value:"+45",label:"+45",sublabel:"Dinamarca"},{value:"+46",label:"+46",sublabel:"Suecia"},{value:"+47",label:"+47",sublabel:"Noruega"},{value:"+48",label:"+48",sublabel:"Polonia"},{value:"+49",label:"+49",sublabel:"Alemania"},{value:"+51",label:"+51",sublabel:"Peru"},{value:"+52",label:"+52",sublabel:"Mexico"},{value:"+53",label:"+53",sublabel:"Cuba"},{value:"+54",label:"+54",sublabel:"Argentina"},{value:"+55",label:"+55",sublabel:"Brasil"},{value:"+56",label:"+56",sublabel:"Chile"},{value:"+57",label:"+57",sublabel:"Colombia"},{value:"+58",label:"+58",sublabel:"Venezuela"},{value:"+60",label:"+60",sublabel:"Malasia"},{value:"+61",label:"+61",sublabel:"Australia"},{value:"+62",label:"+62",sublabel:"Indonesia"},{value:"+63",label:"+63",sublabel:"Filipinas"},{value:"+64",label:"+64",sublabel:"Nueva Zelanda"},{value:"+65",label:"+65",sublabel:"Singapur"},{value:"+66",label:"+66",sublabel:"Tailandia"},{value:"+81",label:"+81",sublabel:"Japon"},{value:"+82",label:"+82",sublabel:"Corea del Sur"},{value:"+84",label:"+84",sublabel:"Vietnam"},{value:"+86",label:"+86",sublabel:"China"},{value:"+90",label:"+90",sublabel:"Turquia"},{value:"+91",label:"+91",sublabel:"India"},{value:"+92",label:"+92",sublabel:"Pakistan"},{value:"+93",label:"+93",sublabel:"Afganistan"},{value:"+94",label:"+94",sublabel:"Sri Lanka"},{value:"+95",label:"+95",sublabel:"Myanmar"},{value:"+98",label:"+98",sublabel:"Iran"},{value:"+211",label:"+211",sublabel:"Sudan del Sur"},{value:"+212",label:"+212",sublabel:"Marruecos, Sahara Occidental"},{value:"+213",label:"+213",sublabel:"Argelia"},{value:"+216",label:"+216",sublabel:"Tunez"},{value:"+218",label:"+218",sublabel:"Libia"},{value:"+220",label:"+220",sublabel:"Gambia"},{value:"+221",label:"+221",sublabel:"Senegal"},{value:"+222",label:"+222",sublabel:"Mauritania"},{value:"+223",label:"+223",sublabel:"Mali"},{value:"+224",label:"+224",sublabel:"Guinea"},{value:"+225",label:"+225",sublabel:"Costa de Marfil"},{value:"+226",label:"+226",sublabel:"Burkina Faso"},{value:"+227",label:"+227",sublabel:"Niger"},{value:"+228",label:"+228",sublabel:"Togo"},{value:"+229",label:"+229",sublabel:"Benin"},{value:"+230",label:"+230",sublabel:"Mauricio"},{value:"+231",label:"+231",sublabel:"Liberia"},{value:"+232",label:"+232",sublabel:"Sierra Leona"},{value:"+233",label:"+233",sublabel:"Ghana"},{value:"+234",label:"+234",sublabel:"Nigeria"},{value:"+235",label:"+235",sublabel:"Chad"},{value:"+236",label:"+236",sublabel:"Republica Centroafricana"},{value:"+237",label:"+237",sublabel:"Camerun"},{value:"+238",label:"+238",sublabel:"Cabo Verde"},{value:"+239",label:"+239",sublabel:"Santo Tome y Principe"},{value:"+240",label:"+240",sublabel:"Guinea Ecuatorial"},{value:"+241",label:"+241",sublabel:"Gabon"},{value:"+242",label:"+242",sublabel:"Republica del Congo"},{value:"+243",label:"+243",sublabel:"Republica Democratica del Congo"},{value:"+244",label:"+244",sublabel:"Angola"},{value:"+245",label:"+245",sublabel:"Guinea-Bisau"},{value:"+246",label:"+246",sublabel:"Territorio Britanico del Oceano Indico"},{value:"+248",label:"+248",sublabel:"Seychelles"},{value:"+249",label:"+249",sublabel:"Sudan"},{value:"+250",label:"+250",sublabel:"Ruanda"},{value:"+251",label:"+251",sublabel:"Etiopia"},{value:"+252",label:"+252",sublabel:"Somalia"},{value:"+253",label:"+253",sublabel:"Yibuti"},{value:"+254",label:"+254",sublabel:"Kenia"},{value:"+255",label:"+255",sublabel:"Tanzania"},{value:"+256",label:"+256",sublabel:"Uganda"},{value:"+257",label:"+257",sublabel:"Burundi"},{value:"+258",label:"+258",sublabel:"Mozambique"},{value:"+260",label:"+260",sublabel:"Zambia"},{value:"+261",label:"+261",sublabel:"Madagascar"},{value:"+262",label:"+262",sublabel:"Reunion, Mayotte"},{value:"+263",label:"+263",sublabel:"Zimbabue"},{value:"+264",label:"+264",sublabel:"Namibia"},{value:"+265",label:"+265",sublabel:"Malaui"},{value:"+266",label:"+266",sublabel:"Lesoto"},{value:"+267",label:"+267",sublabel:"Botsuana"},{value:"+268",label:"+268",sublabel:"Esuatini"},{value:"+269",label:"+269",sublabel:"Comoras"},{value:"+290",label:"+290",sublabel:"Santa Elena"},{value:"+291",label:"+291",sublabel:"Eritrea"},{value:"+297",label:"+297",sublabel:"Aruba"},{value:"+298",label:"+298",sublabel:"Islas Feroe"},{value:"+299",label:"+299",sublabel:"Groenlandia"},{value:"+350",label:"+350",sublabel:"Gibraltar"},{value:"+351",label:"+351",sublabel:"Portugal"},{value:"+352",label:"+352",sublabel:"Luxemburgo"},{value:"+353",label:"+353",sublabel:"Irlanda"},{value:"+354",label:"+354",sublabel:"Islandia"},{value:"+355",label:"+355",sublabel:"Albania"},{value:"+356",label:"+356",sublabel:"Malta"},{value:"+357",label:"+357",sublabel:"Chipre"},{value:"+358",label:"+358",sublabel:"Finlandia, Aland"},{value:"+359",label:"+359",sublabel:"Bulgaria"},{value:"+370",label:"+370",sublabel:"Lituania"},{value:"+371",label:"+371",sublabel:"Letonia"},{value:"+372",label:"+372",sublabel:"Estonia"},{value:"+373",label:"+373",sublabel:"Moldavia"},{value:"+374",label:"+374",sublabel:"Armenia"},{value:"+375",label:"+375",sublabel:"Bielorrusia"},{value:"+376",label:"+376",sublabel:"Andorra"},{value:"+377",label:"+377",sublabel:"Monaco"},{value:"+378",label:"+378",sublabel:"San Marino"},{value:"+380",label:"+380",sublabel:"Ucrania"},{value:"+381",label:"+381",sublabel:"Serbia"},{value:"+382",label:"+382",sublabel:"Montenegro"},{value:"+383",label:"+383",sublabel:"Kosovo"},{value:"+385",label:"+385",sublabel:"Croacia"},{value:"+386",label:"+386",sublabel:"Eslovenia"},{value:"+387",label:"+387",sublabel:"Bosnia y Herzegovina"},{value:"+389",label:"+389",sublabel:"Macedonia del Norte"},{value:"+420",label:"+420",sublabel:"Chequia"},{value:"+421",label:"+421",sublabel:"Eslovaquia"},{value:"+423",label:"+423",sublabel:"Liechtenstein"},{value:"+500",label:"+500",sublabel:"Islas Malvinas"},{value:"+501",label:"+501",sublabel:"Belice"},{value:"+502",label:"+502",sublabel:"Guatemala"},{value:"+503",label:"+503",sublabel:"El Salvador"},{value:"+504",label:"+504",sublabel:"Honduras"},{value:"+505",label:"+505",sublabel:"Nicaragua"},{value:"+506",label:"+506",sublabel:"Costa Rica"},{value:"+507",label:"+507",sublabel:"Panama"},{value:"+508",label:"+508",sublabel:"San Pedro y Miquelon"},{value:"+509",label:"+509",sublabel:"Haiti"},{value:"+590",label:"+590",sublabel:"Guadalupe, San Bartolome"},{value:"+591",label:"+591",sublabel:"Bolivia"},{value:"+592",label:"+592",sublabel:"Guyana"},{value:"+593",label:"+593",sublabel:"Ecuador"},{value:"+594",label:"+594",sublabel:"Guayana Francesa"},{value:"+595",label:"+595",sublabel:"Paraguay"},{value:"+596",label:"+596",sublabel:"Martinica"},{value:"+597",label:"+597",sublabel:"Surinam"},{value:"+598",label:"+598",sublabel:"Uruguay"},{value:"+599",label:"+599",sublabel:"Caribe Neerlandes, Curazao"},{value:"+670",label:"+670",sublabel:"Timor Oriental"},{value:"+672",label:"+672",sublabel:"Antartida, Isla Norfolk"},{value:"+673",label:"+673",sublabel:"Brunei"},{value:"+674",label:"+674",sublabel:"Nauru"},{value:"+675",label:"+675",sublabel:"Papua Nueva Guinea"},{value:"+676",label:"+676",sublabel:"Tonga"},{value:"+677",label:"+677",sublabel:"Islas Salomon"},{value:"+678",label:"+678",sublabel:"Vanuatu"},{value:"+679",label:"+679",sublabel:"Fiyi"},{value:"+680",label:"+680",sublabel:"Palaos"},{value:"+681",label:"+681",sublabel:"Wallis y Futuna"},{value:"+682",label:"+682",sublabel:"Islas Cook"},{value:"+683",label:"+683",sublabel:"Niue"},{value:"+685",label:"+685",sublabel:"Samoa"},{value:"+686",label:"+686",sublabel:"Kiribati"},{value:"+687",label:"+687",sublabel:"Nueva Caledonia"},{value:"+688",label:"+688",sublabel:"Tuvalu"},{value:"+689",label:"+689",sublabel:"Polinesia Francesa"},{value:"+690",label:"+690",sublabel:"Tokelau"},{value:"+691",label:"+691",sublabel:"Micronesia"},{value:"+692",label:"+692",sublabel:"Islas Marshall"},{value:"+850",label:"+850",sublabel:"Corea del Norte"},{value:"+852",label:"+852",sublabel:"Hong Kong"},{value:"+853",label:"+853",sublabel:"Macao"},{value:"+855",label:"+855",sublabel:"Camboya"},{value:"+856",label:"+856",sublabel:"Laos"},{value:"+880",label:"+880",sublabel:"Banglades"},{value:"+886",label:"+886",sublabel:"Taiwan"},{value:"+960",label:"+960",sublabel:"Maldivas"},{value:"+961",label:"+961",sublabel:"Libano"},{value:"+962",label:"+962",sublabel:"Jordania"},{value:"+963",label:"+963",sublabel:"Siria"},{value:"+964",label:"+964",sublabel:"Irak"},{value:"+965",label:"+965",sublabel:"Kuwait"},{value:"+966",label:"+966",sublabel:"Arabia Saudita"},{value:"+967",label:"+967",sublabel:"Yemen"},{value:"+968",label:"+968",sublabel:"Oman"},{value:"+970",label:"+970",sublabel:"Palestina"},{value:"+971",label:"+971",sublabel:"Emiratos Arabes Unidos"},{value:"+972",label:"+972",sublabel:"Israel"},{value:"+973",label:"+973",sublabel:"Barein"},{value:"+974",label:"+974",sublabel:"Catar"},{value:"+975",label:"+975",sublabel:"Butan"},{value:"+976",label:"+976",sublabel:"Mongolia"},{value:"+977",label:"+977",sublabel:"Nepal"},{value:"+992",label:"+992",sublabel:"Tayikistan"},{value:"+993",label:"+993",sublabel:"Turkmenistan"},{value:"+994",label:"+994",sublabel:"Azerbaiyan"},{value:"+995",label:"+995",sublabel:"Georgia"},{value:"+996",label:"+996",sublabel:"Kirguistan"},{value:"+998",label:"+998",sublabel:"Uzbekistan"}];function ao(e){return e==null?"":String(e)}function xn(e){return e?e.startsWith("+")?e:`+${e}`:"+1"}function ud(e){return typeof e=="number"?`${e}px`:e}function fd({autoComplete:e="tel",inputMode:r="tel",validate:n=!0,invalidMessage:a="Ingresa un telefono valido.",errorDisplay:o="tooltip",error:l,value:i,defaultValue:c,onChange:d,countryCode:u,defaultCountryCode:m="+1",onCountryCodeChange:f,allowedCountryCodes:p,countryCodeOptions:x,countryCodePlaceholder:w="Codigo",countryCodeClassName:T="",countryCodeWidth:h=84,onPhoneValueChange:E,label:$,containerClassName:v="",helperText:y,helperDisplay:k="inline",labelAction:S,className:A="",required:C,disabled:U,floatingLabel:z,showPasswordToggle:Y,nativeValidation:M,errorTooltipLabel:J="Error de validacion",...H}){var G;const[ne,X]=s.useState(()=>ao(c)),[W,q]=s.useState(()=>xn(m)),I=s.useMemo(()=>{const de=x??no,Se=p==null?void 0:p.map(xn);return Se!=null&&Se.length?de.filter(ie=>Se.includes(ie.value)):de},[p,x]),oe=((G=I[0])==null?void 0:G.value)??"+1",B=I.some(de=>de.value===xn(u??W))?xn(u??W):oe,O=i!==void 0?ao(i):ne,le=`${B} ${O}`.trim(),g=n&&O.length>0&&!ka(le)?a:void 0,_=l??g,ee=!!_,ae=ee&&o!=="tooltip",j=ee&&o!=="inline",K=!!y&&k==="tooltip"&&!ae,L=ee?"border-[var(--danger)] focus-within:border-[var(--danger)]":"border-[var(--border)] focus-within:border-[var(--primary)]",R=de=>{const Se=de.currentTarget.value;i===void 0&&X(Se),E==null||E(Se,{countryCode:B,nationalNumber:Se,fullNumber:`${B} ${Se}`.trim()}),d==null||d(de)},F=de=>{u===void 0&&q(de),f==null||f(de),E==null||E(O,{countryCode:de,nationalNumber:O,fullNumber:`${de} ${O}`.trim()})},se=j?t.jsx(_t,{as:"span",content:_,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(Gs,{className:"h-[18px] w-[18px]"})})}):null;return t.jsxs("div",{className:`flex flex-col gap-2 ${v}`,children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[t.jsx("span",{children:$}),C&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),K?t.jsx(or,{content:y}):null,S&&t.jsx("span",{className:"ml-auto normal-case",children:S})]}),t.jsxs("span",{className:`flex h-10 min-w-0 items-center overflow-hidden rounded-lg border bg-[var(--bg-input)] transition-colors ${L}`,children:[t.jsx(zt,{value:B,onChange:F,options:I,placeholder:w,disabled:U,ariaLabel:"Codigo telefonico",triggerVariant:"ghost",showSelectedSublabel:!1,searchable:!0,minOptionsForSearch:0,dropdownMinWidth:300,className:`shrink-0 ${T}`,style:{width:ud(h)},height:38,padding:"0 8px 0 10px"}),t.jsx("span",{className:"h-5 w-px shrink-0 bg-[var(--border)]"}),t.jsxs("span",{className:"relative min-w-0 flex-1 self-stretch",children:[t.jsx("input",{...H,value:i,defaultValue:c,type:"tel",inputMode:r,autoComplete:e,disabled:U,required:void 0,"aria-label":H["aria-label"]??(typeof $=="string"?$:void 0),"aria-invalid":ee||H["aria-invalid"],className:`h-full w-full min-w-0 bg-transparent px-2 py-1.5 text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed disabled:opacity-60 ${j?"pr-10":""} ${A}`,onChange:R}),se]})]}),t.jsx(lr,{error:ae?_:void 0,helperText:y,helperDisplay:k})]})}function bd({value:e,onChange:r,options:n,name:a,label:o,orientation:l="vertical",disabled:i=!1,className:c="",optionClassName:d=""}){return t.jsxs("fieldset",{className:`min-w-0 ${c}`,disabled:i,children:[o&&t.jsx("legend",{className:"mb-2 text-xs font-semibold uppercase text-[var(--text-muted)]",children:o}),t.jsx("div",{className:l==="horizontal"?"flex flex-wrap gap-2":"flex flex-col gap-2",children:n.map(u=>{const m=u.value===e,f=i||u.disabled;return t.jsxs("label",{className:`inline-flex min-w-0 items-start gap-2 rounded-lg border px-2.5 py-1.5 transition-colors ${f?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-[var(--bg-input)]"} ${d}`,style:{borderColor:m?"color-mix(in srgb, var(--primary) 48%, var(--border))":"var(--border)",background:m?"color-mix(in srgb, var(--primary) 8%, transparent)":"var(--bg-card)"},children:[t.jsxs("span",{className:"relative mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-[var(--border)] bg-[var(--bg-input)]",children:[t.jsx("input",{type:"radio",name:a,value:u.value,checked:m,disabled:f,onChange:()=>r(u.value),className:"absolute inset-0 opacity-0"}),t.jsx("span",{className:`h-2 w-2 rounded-full transition ${m?"scale-100 opacity-100":"scale-50 opacity-0"}`,style:{background:"var(--primary)"}})]}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-sm font-medium leading-5 text-[var(--text-main)]",children:u.label}),u.description&&t.jsx("span",{className:"block text-xs leading-5 text-[var(--text-muted)]",children:u.description})]})]},u.value)})})]})}const so=()=>'<button type="button" class="rich-img-del" data-action="delete-img" title="Eliminar imagen"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M9 2a1 1 0 0 0-.894.553L7.382 4H4a1 1 0 0 0 0 2v10a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V6a1 1 0 0 0 0-2h-3.382l-.724-1.447A1 1 0 0 0 11 2H9zm-1 6a1 1 0 1 1 2 0v4a1 1 0 1 1-2 0V8zm4 0a1 1 0 1 1 2 0v4a1 1 0 1 1-2 0V8z" clip-rule="evenodd"/></svg></button>',jr=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),oo=e=>e.toLocaleLowerCase().replace(new RegExp("(^|[^\\p{L}\\p{N}])(\\p{L})","gu"),(r,n,a)=>`${n}${a.toLocaleUpperCase()}`),md=e=>e.replace(/[<>]/g,"").toLowerCase(),pd=new Set(["p","br","div","span","b","strong","i","em","u","s","strike","ul","ol","li","h1","h2","h3","h4","blockquote","a","img","hr"]),hd=/^[\s\u00a0]*([•●○■▪▫◆◇►▶➢❖✓✔\-–—*])[\s\u00a0]+/,gd=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},wn=(e,r)=>r.test(e),vd=e=>wn(e,/font-weight\s*:\s*(bold|[6-9]00)/i),yd=e=>wn(e,/font-style\s*:\s*italic/i),xd=e=>wn(e,/text-decoration(?:-line)?\s*:[^;]*underline/i),wd=e=>wn(e,/text-decoration(?:-line)?\s*:[^;]*(line-through|linethrough)/i),kn=(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)},Nn=e=>{const r=e.parentNode;if(!r){e.remove();return}for(;e.firstChild;)r.insertBefore(e.firstChild,e);r.removeChild(e)},kd=e=>{const r=e.getAttribute("class")??"",n=e.getAttribute("style")??"";return/mso-list/i.test(n)||/MsoListParagraph/i.test(r)||/MsoList/i.test(r)},lo=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"},Nd=e=>{const n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT).nextNode();if(!n||!n.textContent)return;const a=n.textContent.replace(hd,"").replace(/^\s*\d+[.)]\s+/,"").replace(/^\s*[a-zA-Z][.)]\s+/,"");a!==n.textContent&&(n.textContent=a)},Sd=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&&(vd(a)&&kn(n,"strong"),yd(a)&&kn(n,"em"),xd(a)&&kn(n,"u"),wd(a)&&kn(n,"s"))})},Cd=e=>{const r=Array.from(e.querySelectorAll("p, div")).filter(kd);if(!r.length)return;let n=0;for(;n<r.length;){const a=r[n],o=lo(a),l=[a];let i=n+1;for(;i<r.length;){const u=r[i];if(lo(u)!==o)break;let m=l[l.length-1].nextSibling;for(;m&&m.nodeType===Node.TEXT_NODE&&!(m.textContent??"").trim();)m=m.nextSibling;if(m!==u)break;l.push(u),i++}const c=a.parentNode;if(!c){n=i;continue}const d=a.ownerDocument.createElement(o);c.insertBefore(d,a),l.forEach(u=>{Nd(u);const m=u.ownerDocument.createElement("li");for(;u.firstChild;)m.appendChild(u.firstChild);d.appendChild(m),u.remove()}),n=i}},Ed=e=>e==="h1"?"h2":e==="h4"||e==="h5"||e==="h6"?"h3":e==="div"?"p":e,Md=e=>{const r=gd(e.replace(/<!--\[if[\s\S]*?<!\[endif\]-->/gi,"").replace(/<xml[\s\S]*?<\/xml>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<\/?o:[^>]*>/gi,"").replace(/<\/?w:[^>]*>/gi,"").replace(/<\/?m:[^>]*>/gi,"")),o=new DOMParser().parseFromString(`<!DOCTYPE html><html><body>${r}</body></html>`,"text/html").body;o.querySelectorAll("script, style, meta, link, xml, title, head, iframe, object, embed, form, input, button, textarea, select, noscript").forEach(i=>i.remove()),Sd(o),Cd(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"){Nn(d),c.forEach(l);return}if(!pd.has(u)){Nn(d),c.forEach(l);return}const m=Ed(u);if(m!==u){const f=d.ownerDocument.createElement(m);for(;d.firstChild;)f.appendChild(d.firstChild);d.replaceWith(f),l(f);return}if(Array.from(d.attributes).forEach(f=>{const p=f.name.toLowerCase(),x=f.value;if(p.startsWith("on")||p==="style"||p==="class"){d.removeAttribute(f.name);return}if(p==="lang"||p.startsWith("data-")||p.startsWith("mso-")){d.removeAttribute(f.name);return}if((p==="href"||p==="src")&&/^\s*javascript:/i.test(x)){d.removeAttribute(f.name);return}u!=="a"&&u!=="img"&&p!=="href"&&p!=="src"&&p!=="alt"&&(["href","src","alt","target","rel"].includes(p)||d.removeAttribute(f.name))}),u==="a"){const f=d.getAttribute("href");if(!f||/^\s*#/.test(f)&&f.length<2){Nn(d),c.forEach(l);return}d.setAttribute("target","_blank"),d.setAttribute("rel","noopener noreferrer"),d.classList.add("rich-link")}if(u==="img"){const f=d.getAttribute("src")??"";if(!f||/^\s*javascript:/i.test(f)||/^file:/i.test(f)||/scheme\s*=\s*["']?file/i.test(f)){d.remove();return}d.classList.add("rich-img"),Array.from(d.attributes).forEach(p=>{["src","alt","class"].includes(p.name.toLowerCase())||d.removeAttribute(p.name)})}if(u==="span"){Nn(d),c.forEach(l);return}}c.forEach(l)};return l(o),o.querySelectorAll("p, h2, h3, li").forEach(i=>{const c=(i.textContent??"").replace(/[\u00a0\s]+/g,"").trim(),d=i.querySelector("img, hr"),u=!c&&!d&&Array.from(i.childNodes).every(m=>m.nodeType===Node.TEXT_NODE||m.nodeType===Node.ELEMENT_NODE&&m.tagName.toLowerCase()==="br");(!c&&!d||u)&&i.remove()}),o.querySelectorAll("strong, b, em, i, u, s").forEach(i=>{let c=i.nextSibling;for(;c&&c.nodeType===Node.TEXT_NODE&&!(c.textContent??"").trim();)c=c.nextSibling;if(c&&c.nodeType===Node.ELEMENT_NODE&&c.tagName===i.tagName){const d=c;for(;d.firstChild;)i.appendChild(d.firstChild);d.remove()}}),o.innerHTML.replace(/<!--[\s\S]*?-->/g,"").replace(/&nbsp;/gi," ").replace(/(<br\s*\/?>\s*){3,}/gi,"<br><br>").replace(/<p>(?:\s|<br\s*\/?>)*<\/p>/gi,"").trim()},La=e=>jr(e).replace(/\r\n?/g,`
25
+ `).split(/\n{2,}/).map(r=>`<p>${r.replace(/\n/g,"<br>")||"<br>"}</p>`).join(""),Td=e=>new RegExp("\\p{L}","u").test(e),Da=(e,r)=>{const n=e.trim();return!n||!Td(n)?!1:r==="uppercase"?n===n.toLocaleUpperCase():r==="lowercase"?n===n.toLocaleLowerCase():n===oo(n)},io=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",so())}(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 co({value:e,onChange:r,placeholder:n="Escribe algo...",minHeight:a="80px",instanceId:o}){const l=s.useId(),i=o||l,c=s.useCallback(()=>document,[]),d=s.useRef(null),u=s.useRef(null),m=s.useRef(new Map),f=s.useRef(null),p=s.useRef(!1),x=s.useRef(e??""),w=s.useRef(r),T=s.useRef(!1),[h,E]=s.useState(()=>!e||e.trim()===""),[$,v]=s.useState(new Set),[y,k]=s.useState(null),[S,A]=s.useState(""),[C,U]=s.useState(""),[z,Y]=s.useState(""),[M,J]=s.useState(""),[H,ne]=s.useState(!1),X=s.useCallback(()=>p.current?u.current:d.current,[]);s.useEffect(()=>{w.current=r},[r]);const W=s.useCallback(()=>{const Z=window.getSelection(),te=X();if(!Z||!te||Z.rangeCount===0||Z.isCollapsed)return"";const be=Z.getRangeAt(0);return!te.contains(be.startContainer)||!te.contains(be.endContainer)?"":Z.toString()},[X]);s.useEffect(()=>{const Z=e??"";if(T.current&&Z===x.current){T.current=!1,E(!Z||Z.trim()==="");return}T.current=!1,x.current=Z;const te=[d.current,u.current].filter(he=>!!he);te.forEach(he=>{he.innerHTML!==Z&&(he.innerHTML=Z)}),E(!Z||Z.trim()==="");const be=te.map(he=>io(he));return()=>be.forEach(he=>he())},[e]),s.useEffect(()=>{var he,Be;p.current=H;let Z,te=0,be;if(H){const $e=d.current;$e&&(x.current=$e.innerHTML);const He=()=>{var ce;const Fe=u.current;if(!Fe){te=requestAnimationFrame(He);return}Fe.innerHTML!==x.current&&(Fe.innerHTML=x.current),Z=io(Fe),E(((ce=Fe.textContent)==null?void 0:ce.trim())===""),be=setTimeout(()=>Fe.focus(),60)};te=requestAnimationFrame(He)}else{const $e=u.current,He=d.current,Fe=($e==null?void 0:$e.innerHTML)??x.current,ce=x.current;x.current=Fe,He&&He.innerHTML!==Fe&&(He.innerHTML=Fe),Fe!==ce&&w.current(Fe),E(((Be=(he=$e??He)==null?void 0:he.textContent)==null?void 0:Be.trim())==="")}return()=>{te&&cancelAnimationFrame(te),be&&clearTimeout(be),Z==null||Z()}},[H]);const q=s.useCallback(()=>{const Z=["bold","italic","underline","strikeThrough","insertUnorderedList","insertOrderedList","justifyLeft","justifyCenter","justifyRight","justifyFull"],te=new Set;Z.forEach(he=>{try{c().queryCommandState(he)&&te.add(he)}catch{return}});try{const he=md(c().queryCommandValue("formatBlock"));he&&te.add(`formatBlock:${he}`)}catch{}const be=W();Da(be,"uppercase")&&te.add("__upper"),Da(be,"lowercase")&&te.add("__lower"),Da(be,"capitalize")&&te.add("__cap"),v(te)},[W,c]),I=()=>{var te;const Z=X();Z&&(x.current=Z.innerHTML,T.current=!0,w.current(x.current),E(((te=Z.textContent)==null?void 0:te.trim())===""))},oe=Z=>{if(!Z){const te=d.current;te&&(x.current=te.innerHTML)}ne(!Z)},B=(Z,te)=>{var be;(be=X())==null||be.focus(),c().execCommand(Z,!1,te),I(),q()},O=Z=>{B("formatBlock",Z)},le=()=>{var Z;(Z=X())==null||Z.focus(),c().execCommand("insertHTML",!1,"<hr><p><br></p>"),I(),q()},g=()=>{const Z=window.getSelection();Z&&Z.rangeCount>0&&(f.current=Z.getRangeAt(0).cloneRange())},_=()=>{const Z=window.getSelection();Z&&f.current&&(Z.removeAllRanges(),Z.addRange(f.current))},ee=Z=>{if(g(),Z==="link"){const te=window.getSelection();U(te&&!te.isCollapsed?te.toString():""),A("")}Z==="image"&&(Y(""),J("")),k(Z)},ae=()=>{var he;if(!S.trim())return;_(),(he=X())==null||he.focus();const Z=window.getSelection(),be=(Z&&!Z.isCollapsed?Z.toString():"")||C.trim()||S.trim();c().execCommand("insertHTML",!1,`<a href="${jr(S.trim())}" target="_blank" rel="noopener noreferrer" class="rich-link">${jr(be)}</a>`),I(),k(null)},j=(Z,te="")=>`<span class="rich-img-wrap" contenteditable="false"><img src="${jr(Z)}" alt="${jr(te)}" class="rich-img" />${so()}</span>`,K=()=>{var Z;z.trim()&&(_(),(Z=X())==null||Z.focus(),c().execCommand("insertHTML",!1,j(z.trim(),M.trim())),I(),k(null))},L=(Z,te=1200,be=1200,he=.72)=>new Promise((Be,$e)=>{const He=new FileReader;He.onerror=$e,He.onload=Fe=>{var Ee;const ce=(Ee=Fe.target)==null?void 0:Ee.result,ue=new Image;ue.onerror=$e,ue.onload=()=>{let{width:Ie,height:Le}=ue;if(Ie>te||Le>be){const Ze=Math.min(te/Ie,be/Le);Ie=Math.round(Ie*Ze),Le=Math.round(Le*Ze)}const Pe=document.createElement("canvas");Pe.width=Ie,Pe.height=Le;const Ge=Pe.getContext("2d");if(!Ge){Be(ce);return}Ge.drawImage(ue,0,0,Ie,Le),Be(Pe.toDataURL("image/jpeg",he))},ue.src=ce},He.readAsDataURL(Z)}),R=Z=>{Z.focus();const te=window.getSelection();if(!te||te.rangeCount===0||!Z.contains(te.anchorNode)){const be=document.createRange();be.selectNodeContents(Z),be.collapse(!1),te==null||te.removeAllRanges(),te==null||te.addRange(be)}},F=s.useRef(()=>{});F.current=Z=>{const te=X();te&&(R(te),c().execCommand("insertHTML",!1,Z),te.querySelectorAll("p").forEach(be=>{!(be.textContent??"").replace(/[\u00a0\s]+/g,"")&&!be.querySelector("img, hr")&&be.remove()}),I(),q())};const se=s.useRef(L);se.current=L;const G=s.useRef(j);G.current=j;const de=s.useCallback(Z=>{if(!Z||m.current.has(Z))return;const te=be=>{const he=be.clipboardData;if(!he)return;const Be=he.getData("text/html"),$e=he.getData("text/plain");if(Be||$e){be.preventDefault(),be.stopPropagation();try{const ue=Be?Md(Be):La($e);if(!ue){$e&&F.current(La($e));return}F.current(ue)}catch{$e&&F.current(La($e))}return}const Fe=Array.from(he.items).find(ue=>ue.type.startsWith("image/"));if(!Fe)return;be.preventDefault(),be.stopPropagation();const ce=Fe.getAsFile();ce&&se.current(ce).then(ue=>{F.current(G.current(ue,"imagen"))})};Z.addEventListener("paste",te,!0),m.current.set(Z,()=>{Z.removeEventListener("paste",te,!0),m.current.delete(Z)})},[]),Se=s.useCallback(Z=>{var be;const te=d.current;te&&te!==Z&&((be=m.current.get(te))==null||be()),d.current=Z,Z&&de(Z)},[de]),ie=s.useCallback(Z=>{var be;const te=u.current;te&&te!==Z&&((be=m.current.get(te))==null||be()),u.current=Z,Z&&de(Z)},[de]);s.useEffect(()=>{const Z=m.current;return()=>{Z.forEach(te=>te()),Z.clear()}},[]);const pe=Z=>{const te=window.getSelection(),be=X();if(!te||!be||te.rangeCount===0||te.isCollapsed)return;const he=te.getRangeAt(0);if(!be.contains(he.startContainer)||!be.contains(he.endContainer))return;const Be=he.toString();if(!Be)return;let $e=Be;Z==="uppercase"?$e=Be.toLocaleUpperCase():Z==="lowercase"?$e=Be.toLocaleLowerCase():$e=oo(Be),he.deleteContents();const He=document.createTextNode($e);he.insertNode(He);const Fe=document.createRange();Fe.setStart(He,0),Fe.setEnd(He,$e.length),te.removeAllRanges(),te.addRange(Fe),f.current=Fe.cloneRange(),I(),q()},Ce=()=>{g(),q()},De=()=>{I(),q()},mt=()=>{requestAnimationFrame(()=>{var Z;(Z=X())==null||Z.focus()})},xt=Z=>{var te,be;if((Z.metaKey||Z.ctrlKey)&&Z.key==="Enter"){if(Z.preventDefault(),Z.stopPropagation(),Z.repeat)return;(te=X())==null||te.focus(),c().execCommand("insertLineBreak",!1)||c().execCommand("insertHTML",!1,"<br>"),I(),q();return}if(Z.key==="Tab"){Z.preventDefault(),(be=X())==null||be.focus(),c().execCommand("insertText",!1,"    "),I(),q();return}if(Z.key==="Escape"){if(y){k(null);return}if(p.current){ne(!1);return}}y||(Z.ctrlKey||Z.metaKey)&&(Z.key==="b"&&(Z.preventDefault(),B("bold")),Z.key==="i"&&(Z.preventDefault(),B("italic")),Z.key==="u"&&(Z.preventDefault(),B("underline")),Z.key==="k"&&(Z.preventDefault(),ee("link")))},We=()=>t.jsx("div",{className:"h-4 w-px flex-shrink-0 mx-1",style:{background:"var(--border)"}}),Ae=(Z,te,be,he,Be)=>{const $e=Be??($.has(be)||be==="__link"&&y==="link"||be==="__img"&&y==="image");return t.jsx("button",{type:"button",title:te,tabIndex:-1,onFocus:mt,onMouseDown:He=>{He.preventDefault(),he?he():B(be)},className:"flex h-7 w-7 items-center justify-center rounded text-xs font-bold transition-colors",style:{color:$e?"var(--primary)":"var(--text-secondary)",background:$e?"rgba(59,130,246,0.12)":"transparent"},children:Z},be)},ke=Z=>{const te=Z.target;if(te.closest("[data-action='delete-img']")){Z.preventDefault();const be=te.closest(".rich-img-wrap");be&&(be.remove(),I())}},et=Z=>t.jsxs(t.Fragment,{children:[y==="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:Z},children:[t.jsx("input",{autoFocus:!0,type:"url",value:S,onChange:te=>A(te.target.value),onKeyDown:te=>{te.key==="Enter"&&(te.preventDefault(),ae()),te.key==="Escape"&&k(null)},placeholder:"https://...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("input",{type:"text",value:C,onChange:te=>U(te.target.value),onKeyDown:te=>{te.key==="Enter"&&(te.preventDefault(),ae()),te.key==="Escape"&&k(null)},placeholder:"Texto (opcional)",className:"w-32 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("button",{type:"button",onClick:ae,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>k(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]}),y==="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:Z},children:[t.jsx("input",{autoFocus:!0,type:"url",value:z,onChange:te=>Y(te.target.value),onKeyDown:te=>{te.key==="Enter"&&(te.preventDefault(),K()),te.key==="Escape"&&k(null)},placeholder:"URL de la imagen...",className:"min-w-0 flex-1 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("input",{type:"text",value:M,onChange:te=>J(te.target.value),onKeyDown:te=>{te.key==="Enter"&&(te.preventDefault(),K()),te.key==="Escape"&&k(null)},placeholder:"Texto alt",className:"w-28 rounded px-2 py-1 text-xs focus:outline-none",style:{background:"var(--bg-card)",border:"1px solid var(--border)",color:"var(--text-main)"}}),t.jsx("button",{type:"button",onClick:K,className:"rounded px-2.5 py-1 text-xs font-semibold text-white",style:{background:"var(--primary)"},children:"OK"}),t.jsx("button",{type:"button",onClick:()=>k(null),className:"rounded px-2 py-1 text-xs",style:{color:"var(--text-muted)"},children:"x"})]})]}),me=(Z,te)=>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:te},children:[Ae(t.jsx(P.HiArrowUturnLeft,{className:"h-4 w-4"}),"Deshacer","undo"),Ae(t.jsx(P.HiArrowUturnRight,{className:"h-4 w-4"}),"Rehacer","redo"),We(),Ae(t.jsx("span",{style:{fontSize:"10px"},children:"P"}),"Parrafo","__paragraph",()=>O("p"),$.has("formatBlock:p")||$.has("formatBlock:div")),Ae(t.jsx(P.HiH2,{className:"h-4 w-4"}),"Titulo 2","__h2",()=>O("h2"),$.has("formatBlock:h2")),Ae(t.jsx(P.HiH3,{className:"h-4 w-4"}),"Titulo 3","__h3",()=>O("h3"),$.has("formatBlock:h3")),Ae(t.jsx("span",{style:{fontSize:"13px",lineHeight:1},children:"“"}),"Cita","__quote",()=>O("blockquote"),$.has("formatBlock:blockquote")),We(),Ae(t.jsx("b",{children:"B"}),"Negrita (Ctrl+B)","bold"),Ae(t.jsx("i",{children:"I"}),"Cursiva (Ctrl+I)","italic"),Ae(t.jsx("u",{children:"U"}),"Subrayado (Ctrl+U)","underline"),Ae(t.jsx("s",{children:"S"}),"Tachado","strikeThrough"),We(),Ae(t.jsx(P.HiListBullet,{className:"h-4 w-4"}),"Lista sin orden","insertUnorderedList"),Ae(t.jsx(P.HiNumberedList,{className:"h-4 w-4"}),"Lista numerada","insertOrderedList"),Ae(t.jsx(P.HiArrowTurnUpLeft,{className:"h-4 w-4"}),"Disminuir sangria","outdent"),Ae(t.jsx(P.HiArrowTurnDownRight,{className:"h-4 w-4"}),"Aumentar sangria","indent"),We(),Ae(t.jsx(P.HiBars3BottomLeft,{className:"h-4 w-4"}),"Alinear izquierda","justifyLeft"),Ae(t.jsx(P.HiBars3CenterLeft,{className:"h-4 w-4"}),"Centrar","justifyCenter"),Ae(t.jsx(P.HiBars3BottomRight,{className:"h-4 w-4"}),"Alinear derecha","justifyRight"),Ae(t.jsx(P.HiBars3,{className:"h-4 w-4"}),"Justificar","justifyFull"),We(),Ae(t.jsx("span",{style:{fontSize:"10px"},children:"AA"}),"Mayusculas","__upper",()=>pe("uppercase")),Ae(t.jsx("span",{style:{fontSize:"10px"},children:"aa"}),"Minusculas","__lower",()=>pe("lowercase")),Ae(t.jsx("span",{style:{fontSize:"10px"},children:"Aa"}),"Capitalizar","__cap",()=>pe("capitalize")),We(),Ae(t.jsx(P.HiLink,{className:"h-4 w-4"}),"Insertar enlace (Ctrl+K)","__link",()=>ee("link")),Ae(t.jsx(P.HiLinkSlash,{className:"h-4 w-4"}),"Quitar enlace","unlink"),Ae(t.jsx(P.HiPhoto,{className:"h-4 w-4"}),"Insertar imagen","__img",()=>ee("image")),Ae(t.jsx(P.HiMinus,{className:"h-4 w-4"}),"Insertar separador","__divider",le),We(),Ae(t.jsx(P.HiOutlinePaintBrush,{className:"h-4 w-4"}),"Limpiar formato","removeFormat"),Ae(t.jsx(P.HiNoSymbol,{className:"h-4 w-4"}),"Quitar bloque","__clearBlock",()=>O("p")),We(),t.jsx("button",{type:"button",title:Z?"Salir del modo de enfoque (Esc)":"Modo de enfoque",tabIndex:-1,onFocus:mt,onMouseDown:be=>{be.preventDefault(),oe(Z)},className:"flex h-7 w-7 items-center justify-center rounded transition-colors",style:{color:"var(--text-secondary)"},children:Z?t.jsx(P.HiArrowsPointingIn,{className:"h-4 w-4"}):t.jsx(P.HiArrowsPointingOut,{className:"h-4 w-4"})})]});return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"overflow-hidden rounded-lg transition-all duration-150 ring-1 ring-transparent focus-within:ring-primary/30",style:{border:"1px solid var(--border)"},children:[t.jsx("div",{ref:Se,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:De,onKeyDown:xt,onKeyUp:Ce,onSelect:Ce,onMouseUp:Ce,onMouseDown:ke,"data-placeholder":n,className:`rich-editor px-3 py-2 text-sm focus:outline-none${h?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-input)",minHeight:a,maxHeight:"320px",overflowY:"auto",lineHeight:"1.6"}}),et("var(--bg-input)"),me(!1,"var(--bg-input)")]}),t.jsxs(fa,{open:H,onClose:()=>ne(!1),title:"Modo de enfoque",subtitle:"Esc para salir",maxWidth:"920px",bodyClassName:"flex min-h-0 flex-col p-0",panelClassName:"h-[88vh]",backdropClassName:"bg-black/50 backdrop-blur-[2px]",children:[t.jsx("div",{ref:ie,contentEditable:!0,suppressContentEditableWarning:!0,"data-bonsaif-rich-instance":i,onInput:De,onKeyDown:xt,onKeyUp:Ce,onSelect:Ce,onMouseUp:Ce,onMouseDown:ke,"data-placeholder":n,className:`rich-editor min-h-0 flex-1 overflow-y-auto px-8 py-6 text-sm focus:outline-none${h?" is-empty":""}`,style:{color:"var(--text-main)",background:"var(--bg-card)",lineHeight:"1.75"}}),et("var(--bg-input)"),me(!0,"var(--bg-input)")]})]})}const uo="[a-zA-Z0-9._@-]+",Ia=new RegExp(`@(${uo})`,"g"),$d=/[a-zA-Z0-9._@-]/,Wr=new Set([" ",`
26
+ `," ","\r"," ","(","[","{",".",",",";",":","!","?","¿","¡",")","]","}",'"',"'","«","»","/","\\","|","-","—","–"]);function fo(e,r){if(r<=0)return!0;const n=e[r-1]??"";return Wr.has(n)}function bo(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(Wr.has(c)||!$d.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):fo(e,o)))continue;const i=e.slice(o+1,r);return i.length>0&&!new RegExp(`^${uo}$`).test(i)?null:{query:i,triggerIndex:o,caretIndex:r}}return null}function mo(e,r){var a;const n=dr(e,r);return n?!!((a=n.node.parentElement)!=null&&a.closest(".mention-chip")):!1}function po(e,r){if(r<=0)return!0;const n=dr(e,r);if(!n){const o=e.textContent??"";return fo(o,r)}if(n.offset>0){const o=n.node.data[n.offset-1]??"";return Wr.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 Wr.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 Wr.has(l[l.length-1]??"")}a=a.previousSibling}return!0}function Oa(e,r){const n=e.textContent??"";return bo(n,r,{isTriggerBoundary:a=>po(e,a),isInsideExistingMention:a=>mo(e,a)})}function Ha(e){return e.toLowerCase().trim()}function ho(e){return e?e.replace(/<style[^>]*>[\s\S]*?<\/style>/gi," ").replace(/<script[^>]*>[\s\S]*?<\/script>/gi," ").replace(/<br\s*\/?>/gi,`
27
27
  `).replace(/<\/(p|div|li)>/gi,`
28
- `).replace(/<[^>]+>/g," ").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/\s+/g," ").trim():""}function Ia(e){if(!e)return[];const t=new Set,n=[],a=d=>{const u=Da(d);!u||t.has(u)||(t.add(u),n.push(u))},o=/data-username\s*=\s*["']([^"']+)["']/gi;let l;for(;(l=o.exec(e))!==null;)a(l[1]??"");const i=bo(e);La.lastIndex=0;let c;for(;(c=La.exec(i))!==null;)a(c[1]??"");return n}function mo(e){const t=String(e.name??"").trim();return t||String(e.username??"").trim()||"usuario"}function kd(e,t){const n=Ia(e);if(!n.length)return[];const a=new Map;t.forEach(i=>{i.username&&a.set(Da(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 po(e){const t=new Set,n=[];for(const a of e)t.has(a.userId)||(t.add(a.userId),n.push(a));return n}function Nd(e,t){return t?e.filter(n=>n.userId!==t):e}function ho(e){return!e||!/@/.test(e)?e:e.replace(La,(t,n,a,o)=>{const l=o.slice(0,a),i=l.lastIndexOf("<"),c=l.lastIndexOf(">");return i>c?t:`<span class="mention-chip" contenteditable="false" data-username="${(n??"").toLowerCase()}">${t}</span>`})}function dt(e,t){if(t<0)return null;const n=e.ownerDocument;if(!n)return null;const a=n.createTreeWalker(e,NodeFilter.SHOW_TEXT);let o=t,l=null,i=a.nextNode();for(;i;){l=i;const c=i.data.length;if(o<=c)return{node:i,offset:o};o-=c,i=a.nextNode()}return l&&o===0?{node:l,offset:l.data.length}:null}function Oa(e,t,n){var o;const a=e.ownerDocument;if(!a||e!==t&&!e.contains(t))return-1;try{const l=a.createRange();return l.selectNodeContents(e),l.setEnd(t,n),((o=l.cloneContents().textContent)==null?void 0:o.length)??0}catch{return-1}}function go(e,t){const{triggerIndex:n,caretIndex:a,username:o}=t;if(a<n)return null;const l=dt(e,n),i=dt(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=mo({name:t.display,username:o}),p=c.createElement("span");p.className="mention-chip",p.setAttribute("data-username",o.toLowerCase()),t.userId&&p.setAttribute("data-userid",String(t.userId)),p.contentEditable="false",p.textContent=u,p.title=`@${o}`;const f=c.createTextNode(" ");d.insertNode(f),d.insertNode(p);const m=c.defaultView,x=m==null?void 0:m.getSelection();if(x){const w=c.createRange();w.setStart(f,f.data.length),w.collapse(!0),x.removeAllRanges(),x.addRange(w)}return{caretPlainOffset:n+u.length+1}}function vo(e,t){const n=e.ownerDocument,a=n.defaultView;if(!a)return;const o=a.getSelection();if(!o)return;const l=n.createRange(),i=dt(e,t);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(e),l.collapse(!1)),o.removeAllRanges(),o.addRange(l)}const Ha=280,Nn=6,yo=260,Sd=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),Cd={position:"relative"},Ed={position:"fixed",zIndex:11050,minWidth:yo,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},xo={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function Md(e){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(e)}"]`))}function $d(e,t){const n=Math.max(8,Math.min(e.left,window.innerWidth-yo-8)),a=t==null?void 0:t.getBoundingClientRect(),o=a?Math.min(window.innerHeight-8,a.bottom):window.innerHeight-8,l=a?Math.max(8,a.top):8,i=o-e.bottom-Nn,c=e.top-l-Nn;return i<Math.min(Ha,160)&&c>i?{left:n,bottom:window.innerHeight-e.top+Nn,maxHeight:Math.max(120,Math.min(Ha,c))}:{left:n,top:e.bottom+Nn,maxHeight:Math.max(120,Math.min(Ha,i))}}function wo({value:e,onChange:t,onSearchUsers:n,onMentionsChange:a,minHeight:o,placeholder:l,className:i,maxSuggestions:c=8,searchDebounceMs:d=140,highlightInEditor:u=!1,searchCacheKey:p=""}){const f=s.useId().replace(/:/g,""),m=s.useRef(null),x=s.useRef(null),w=s.useRef(new Map),$=s.useRef(n);$.current=n;const h=s.useRef(null),E=s.useRef(0),T=s.useRef([]),[g,y]=s.useState(null),[k,S]=s.useState([]),[L,C]=s.useState(0),[W,_]=s.useState([]),[V,M]=s.useState(!1),[Z,H]=s.useState(!1);E.current=L,s.useEffect(()=>{H(!0)},[]);const ne=(g==null?void 0:g.query)??null;s.useEffect(()=>{if(ne===null){S([]);return}const v=ne.trim(),z=`${p}|${v.toLowerCase()||"*"}`,ee=w.current.get(z);if(ee){S(ee),M(!1),C(0);return}const le=new AbortController;M(!0);const R=window.setTimeout(()=>{(async()=>{try{const Q=await $.current(v,{signal:le.signal,limit:c});if(le.signal.aborted)return;const I=Array.isArray(Q)?Q:[];w.current.set(z,I),S(I),C(0)}catch{le.signal.aborted||S([])}finally{le.signal.aborted||M(!1)}})()},d);return()=>{le.abort(),window.clearTimeout(R)}},[ne,c,d,p]);const U=s.useRef(a);U.current=a,s.useEffect(()=>{var v;(v=U.current)==null||v.call(U,po(W))},[W]);const q=s.useCallback(()=>{const v=Md(f);if(v.length===0)return null;const z=window.getSelection();if(z!=null&&z.rangeCount){const le=z.getRangeAt(0).startContainer;for(const R of v)if(R.contains(le))return R}const ee=document.activeElement;for(const le of v)if(ee===le||ee&&le.contains(ee))return le;for(const le of v)if(le.closest('[role="dialog"]'))return le;return v[0]??null},[f]),j=s.useCallback(()=>{const v=q(),z=window.getSelection();if(!v||!z||z.rangeCount===0){y(null);return}const ee=z.getRangeAt(0);if(!v.contains(ee.startContainer)){y(null);return}const le=Oa(v,ee.startContainer,ee.startOffset);if(le<0){y(null);return}const R=Aa(v,le);if(!R){y(null);return}const Q=ee.getBoundingClientRect(),I=Q.width===0&&Q.height===0?(()=>{const P=document.createRange();return P.selectNodeContents(ee.startContainer),P.collapse(!0),P.getBoundingClientRect()})():Q;h.current={query:R.query,caretIndex:R.caretIndex,triggerIndex:R.triggerIndex};const J=$d(I,v);y(P=>{const ae={query:R.query,...J};return P&&P.query===ae.query&&P.top===ae.top&&P.bottom===ae.bottom&&P.left===ae.left&&P.maxHeight===ae.maxHeight?P:ae})},[q]),D=s.useCallback(v=>{t(v),j()},[t,j]);s.useEffect(()=>{const v=z=>{if(Sd.has(z.key))return;const ee=q(),le=z.target;!ee||!le||!ee.contains(le)||j()};return document.addEventListener("keyup",v,!0),()=>document.removeEventListener("keyup",v,!0)},[q,j]);const se=s.useCallback(v=>{const z=q();if(!z)return;let ee=-1;const le=window.getSelection();if(le&&le.rangeCount>0){const P=le.getRangeAt(0);z.contains(P.startContainer)&&(ee=Oa(z,P.startContainer,P.startOffset))}if(ee<0&&h.current&&(ee=h.current.caretIndex),ee<0)return;const R=Aa(z,ee);if(!R)return;const Q=go(z,{triggerIndex:R.triggerIndex,caretIndex:ee,username:v.username,display:v.name,userId:v.userId});if(!Q)return;t(z.innerHTML);const I={userId:v.userId,username:v.username,email:v.email??void 0,display:v.name??v.username};_(P=>{const ae=new Map(P.map(Y=>[Y.userId,Y]));return ae.set(I.userId,I),Array.from(ae.values())}),y(null),h.current=null;const J=Q.caretPlainOffset;requestAnimationFrame(()=>{requestAnimationFrame(()=>{var Se,ie;const P=q();if(!P)return;P.focus(),vo(P,J);const ae=window.getSelection(),Y=ae==null?void 0:ae.anchorNode,de=Y instanceof Element?Y.closest(".mention-chip"):(Se=Y==null?void 0:Y.parentElement)==null?void 0:Se.closest(".mention-chip");if(de!=null&&de.parentNode){const pe=document.createRange(),Ce=de.nextSibling;Ce&&Ce.nodeType===Node.TEXT_NODE?pe.setStart(Ce,((ie=Ce.textContent)==null?void 0:ie.length)??0):pe.setStartAfter(de),pe.collapse(!0),ae==null||ae.removeAllRanges(),ae==null||ae.addRange(pe)}})})},[q,t]);s.useEffect(()=>{const v=new Set(Ia(e).map(z=>z.toLowerCase()));_(z=>{const ee=z.filter(le=>v.has(le.username.toLowerCase()));return ee.length===z.length?z:ee})},[e]),s.useEffect(()=>{if(!g)return;const v=z=>{const ee=z.target;if(!ee||m.current&&m.current.contains(ee)||x.current&&x.current.contains(ee))return;const le=q();le&&le.contains(ee)||y(null)};return document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[g,q]);const B=s.useMemo(()=>k.slice(0,c),[k,c]);T.current=B,s.useEffect(()=>{if(!g)return;const v=z=>{const ee=q(),le=z.target;if(!ee||!le||!ee.contains(le))return;const R=T.current;if(!(R.length===0&&z.key!=="Escape"))if(z.key==="ArrowDown")z.preventDefault(),z.stopPropagation(),C(Q=>(Q+1)%Math.max(R.length,1));else if(z.key==="ArrowUp")z.preventDefault(),z.stopPropagation(),C(Q=>(Q-1+R.length)%Math.max(R.length,1));else if(z.key==="Enter"||z.key==="Tab"){const Q=R[E.current];Q&&(z.preventDefault(),z.stopPropagation(),se(Q))}else z.key==="Escape"&&(z.preventDefault(),z.stopPropagation(),y(null))};return document.addEventListener("keydown",v,!0),()=>document.removeEventListener("keydown",v,!0)},[q,se,g]),s.useEffect(()=>{if(!g||!x.current)return;const v=x.current.querySelector(`[data-mention-index="${L}"]`);v==null||v.scrollIntoView({block:"nearest"})},[L,g]);const O=u?ho(e):e,oe=g&&Z?nr.createPortal(r.jsxs("ul",{ref:x,style:{...Ed,left:g.left,top:g.top,bottom:g.bottom,maxHeight:g.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[V&&B.length===0&&r.jsx("li",{style:xo,children:"Buscando…"}),!V&&B.length===0&&r.jsx("li",{style:xo,children:g.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${g.query}”`}),B.map((v,z)=>{var ee,le;return r.jsx("li",{children:r.jsxs("button",{type:"button","data-mention-index":z,onMouseDown:R=>{R.preventDefault(),se(v)},onMouseEnter:()=>C(z),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:z===L?"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:[r.jsx("span",{style:{fontWeight:600,fontSize:13},children:((ee=v.name)==null?void 0:ee.trim())||`@${v.username}`}),r.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[(le=v.name)!=null&&le.trim()?`@${v.username}`:null,v.email].filter(Boolean).join(" · ")||`@${v.username}`})]})},v.userId)})]}),document.body):null;return r.jsxs("div",{ref:m,style:Cd,className:i,children:[r.jsx(oo,{value:O,onChange:D,placeholder:l,minHeight:o,instanceId:f}),oe]})}function Td({value:e,onChange:t,placeholder:n,minHeight:a,onSearchUsers:o,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:p}){return o?r.jsx(wo,{value:e,onChange:t,onSearchUsers:o,onMentionsChange:l,placeholder:n,minHeight:a,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:p}):r.jsx(oo,{value:e,onChange:t,placeholder:n,minHeight:a})}function Ld({title:e,subtitle:t,icon:n,actions:a,children:o,footer:l,className:i="",bodyClassName:c="p-4"}){const d=e||t||n||a;return r.jsxs("section",{className:`overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)] ${i}`,children:[d&&r.jsxs("header",{className:"flex items-center justify-between gap-3 border-b border-[var(--border)] px-4 py-3",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[n&&r.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}),r.jsxs("div",{className:"min-w-0",children:[e&&r.jsx("h3",{className:"truncate text-sm font-semibold text-[var(--text-main)]",children:e}),t&&r.jsx("div",{className:"truncate text-xs text-[var(--text-muted)]",children:t})]})]}),a&&r.jsx("div",{className:"shrink-0",children:a})]}),r.jsx("div",{className:c,children:o}),l&&r.jsx("footer",{className:"border-t border-[var(--border)] px-4 py-3",children:l})]})}const Ad={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)"}},Dd={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 Id({children:e,tone:t="neutral",size:n="sm",icon:a,dot:o=!1,className:l=""}){const i=Ad[t];return r.jsxs("span",{className:`inline-flex max-w-full shrink-0 items-center gap-1.5 rounded-full border font-semibold leading-none ${Dd[n]} ${l}`,style:{color:i.text,background:i.bg,borderColor:i.border},children:[o&&r.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:i.text}}),a&&r.jsx("span",{className:"shrink-0",children:a}),r.jsx("span",{className:"min-w-0 truncate",children:e})]})}const ko={neutral:{color:"var(--text-secondary)",background:"var(--bg-input)"},primary:{color:"var(--primary)",background:"color-mix(in srgb, var(--primary) 10%, transparent)"},success:{color:"#047857",background:"rgba(16, 185, 129, 0.11)"},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)"},danger:{color:"var(--danger)",background:"var(--danger-bg)"},info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.11)"}},Od={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"},Hd={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},Bd={xs:148,sm:164,md:184},Fd={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 Pd({value:e,options:t,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:p,menuClassName:f,optionClassName:m,spinnerClassName:x}){const[w,$]=s.useState(!1),[h,E]=s.useState(!1),[T,g]=s.useState(-1),[y,k]=s.useState({}),S=s.useRef(null),L=s.useRef(null),C=s.useRef(null),W=t.find(j=>j.value===e)??t[0],_={...W!=null&&W.tone?ko[W.tone]:void 0,...W==null?void 0:W.style},V=o||l||t.length===0,M=j=>{i&&j.stopPropagation()},Z=s.useCallback(()=>{$(!1),g(-1)},[]),H=s.useCallback(()=>{const j=S.current;if(!j)return;const D=j.getBoundingClientRect(),se=Math.max(D.width,Bd[a]),B=Math.min(Math.max(t.length,1)*38+12,260),O=window.innerHeight-D.bottom,oe=O<B&&D.top>O,v=Math.min(Math.max(8,D.left+D.width/2-se/2),window.innerWidth-se-8);k({position:"fixed",left:v,top:oe?void 0:D.bottom+6,bottom:oe?window.innerHeight-D.top+6:void 0,width:se,zIndex:9999})},[t.length,a]),ne=s.useCallback(j=>{j.disabled||(n(j.value),Z())},[Z,n]);s.useEffect(()=>E(!0),[]),s.useEffect(()=>{if(!w)return;H();const j=t.findIndex(D=>D.value===e);g(j>=0?j:0)},[w,t,H,e]),s.useEffect(()=>{if(!w)return;function j(D){var B,O;const se=D.target;!((B=S.current)!=null&&B.contains(se))&&!((O=L.current)!=null&&O.contains(se))&&Z()}return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[Z,w]),s.useEffect(()=>{if(w)return window.addEventListener("resize",H),window.addEventListener("scroll",H,!0),()=>{window.removeEventListener("resize",H),window.removeEventListener("scroll",H,!0)}},[w,H]),s.useEffect(()=>{if(T<0||!C.current)return;const j=C.current.children[T];j==null||j.scrollIntoView({block:"nearest"})},[T]);function U(j){if(!V){if(!w){["Enter"," ","ArrowDown","ArrowUp"].includes(j.key)&&(j.preventDefault(),$(!0));return}if(j.key==="Escape"){j.preventDefault(),Z();return}if(j.key==="ArrowDown"){j.preventDefault(),g(D=>Math.min(D+1,t.length-1));return}if(j.key==="ArrowUp"){j.preventDefault(),g(D=>Math.max(D-1,0));return}if(j.key==="Enter"||j.key===" "){j.preventDefault();const D=t[T];D&&ne(D)}}}const q=r.jsx("div",{ref:L,role:"listbox","aria-label":c,className:Tr("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",f),style:{...y,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:M,onMouseDown:M,onPointerDown:M,children:r.jsx("div",{ref:C,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:t.map((j,D)=>{const se=j.value===e,B=D===T,O={...j.tone?ko[j.tone]:void 0,...j.style};return r.jsxs("button",{type:"button",role:"option","aria-selected":se,disabled:j.disabled,onMouseEnter:()=>!j.disabled&&g(D),onMouseDown:oe=>{oe.preventDefault(),ne(j)},className:Tr("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",Fd[a],se?j.className:void 0,m),style:{...se?O:void 0,background:se?O.background??"color-mix(in srgb, var(--primary) 12%, transparent)":B?"var(--bg-hover)":"transparent",color:se?O.color??"var(--primary)":"var(--text-main)"},children:[r.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:se?r.jsx(F.HiCheck,{className:"h-4 w-4"}):null}),r.jsx("span",{className:"min-w-0 flex-1 truncate",children:j.label})]},j.value)})})});return r.jsxs("span",{ref:S,className:Tr("relative inline-flex shrink-0 items-center",u),onKeyDown:U,onClick:M,onPointerDown:M,children:[r.jsx("button",{type:"button",disabled:V,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":w,title:d,onClick:()=>!V&&$(j=>!j),className:Tr("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",Od[a],W==null?void 0:W.className,p),style:_,children:r.jsx("span",{className:"min-w-0 truncate",children:(W==null?void 0:W.label)??e})}),r.jsx(F.HiChevronDown,{"aria-hidden":"true",className:Tr("pointer-events-none absolute opacity-70 transition-transform",Hd[a],w?"rotate-180":"rotate-0")}),l&&r.jsx("span",{"aria-hidden":"true",className:Tr("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",x)}),w&&h&&nr.createPortal(q,document.body)]})}function zd({tabs:e,activeTabId:t,defaultActiveTabId:n,onTabChange:a,ariaLabel:o="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:d=""}){const u=e.find(w=>!w.disabled)??e[0],p=t??n??(u==null?void 0:u.id),f=e.find(w=>w.id===p)??u,m=w=>{w.disabled||a==null||a(w.id)},x=w=>{const $=e.filter(E=>!E.disabled);if(!$.length||!f)return;const h=$.findIndex(E=>E.id===f.id);(w.key==="ArrowRight"||w.key==="ArrowDown")&&(w.preventDefault(),m($[(h+1)%$.length])),(w.key==="ArrowLeft"||w.key==="ArrowUp")&&(w.preventDefault(),m($[(h-1+$.length)%$.length])),w.key==="Home"&&(w.preventDefault(),m($[0])),w.key==="End"&&(w.preventDefault(),m($[$.length-1]))};return r.jsxs("div",{className:i,children:[r.jsx("div",{role:"tablist","aria-label":o,onKeyDown:x,className:`flex min-w-0 gap-1 overflow-x-auto ${l==="underline"?"border-b border-[var(--border)]":"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-1"} ${c}`,children:e.map(w=>{const $=w.id===(f==null?void 0:f.id);return r.jsxs("button",{type:"button",role:"tab","aria-selected":$,"aria-controls":`${w.id}-panel`,id:`${w.id}-tab`,disabled:w.disabled,tabIndex:$?0:-1,onClick:()=>m(w),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:$?"var(--primary)":"var(--text-muted)",borderColor:$?"var(--primary)":"transparent",background:l==="pills"&&$?"var(--bg-card)":"transparent"},children:[w.icon&&r.jsx("span",{className:"shrink-0",children:w.icon}),r.jsx("span",{children:w.label}),w.badge&&r.jsx("span",{className:"shrink-0",children:w.badge})]},w.id)})}),(f==null?void 0:f.content)!==void 0&&r.jsx("div",{role:"tabpanel",id:`${f.id}-panel`,"aria-labelledby":`${f.id}-tab`,className:`pt-4 ${d}`,children:f.content})]})}function Dr(...e){return e.filter(Boolean).join(" ")}function _d({steps:e,activeStepId:t,initialStepId:n,completedStepIds:a,defaultCompletedStepIds:o=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:c,allowBackNavigation:d=!0,showFooter:u=!0,previousLabel:p="Anterior",nextLabel:f="Siguiente",blockedNextLabel:m="Completa este paso",className:x="",headerClassName:w="",contentClassName:$="",footerClassName:h=""}){var R;const E=((R=e[0])==null?void 0:R.id)??"",[T,g]=s.useState(n??E),[y,k]=s.useState(o),S=t??T,L=a??y,C=s.useMemo(()=>new Set(L),[L]),W=Math.max(0,e.findIndex(Q=>Q.id===S)),_=e[W]??e[0],V=e.length<=1?100:W/(e.length-1)*100,M=Q=>{a||k(Q),i==null||i(Q)},Z=Q=>{const I=e.find(J=>J.id===Q);I&&(t||g(Q),l==null||l(Q,I))},H=Q=>C.has(Q),ne=Q=>e.slice(0,Q).find(I=>!I.optional&&!C.has(I.id)),U=Q=>{const I=e[Q];return!I||I.disabled?!1:Q===W||d&&Q<W?!0:!ne(Q)},q=Q=>{const I=e.findIndex(J=>J.id===Q);return I>=0&&U(I)},j=Q=>{const I=e.findIndex(J=>J.id===Q);if(I<0)return!1;if(!U(I)){const J=ne(I);return J&&(c==null||c(e[I],J)),!1}return Z(Q),!0},D=(Q=_==null?void 0:_.id)=>{!Q||C.has(Q)||M([...L,Q])},se=(Q=_==null?void 0:_.id)=>{if(!Q)return;const I=e.findIndex(P=>P.id===Q),J=L.filter(P=>{const ae=e.findIndex(Y=>Y.id===P);return ae>=0&&ae<I});M(J),I>=0&&W>I&&Z(Q)},B=()=>W<=0?!1:j(e[W-1].id),O=()=>{const Q=e[W+1];return Q?j(Q.id):!1},oe={activeStep:_,activeIndex:W,completedStepIds:L,isCompleted:H,isUnlocked:q,completeStep:D,uncompleteStep:se,goToStep:j,goNext:O,goPrevious:B};if(!_)return null;const v=e[W+1],z=W>0,ee=v?q(v.id):!1,le=typeof _.content=="function"?_.content(oe):_.content;return r.jsxs("section",{className:Dr("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",x),children:[r.jsxs("div",{className:Dr("border-b border-[var(--border)] bg-[var(--bg-input)]",w),children:[r.jsx("div",{className:"relative h-1 overflow-hidden bg-[var(--border)]/55",children:r.jsx("div",{className:"h-full rounded-r-full bg-[var(--primary)] transition-[width] duration-500 ease-out",style:{width:`${V}%`}})}),r.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map((Q,I)=>{const J=Q.id===_.id,P=H(Q.id),ae=U(I),Y=ne(I);return r.jsxs("button",{type:"button",disabled:!ae,"aria-current":J?"step":void 0,"aria-disabled":!ae,title:!ae&&Y?`Completa ${Y.title}`:Q.title,onClick:()=>j(Q.id),className:Dr("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",J&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",P&&!J&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!J&&!P&&ae&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!ae&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[r.jsx("span",{className:Dr("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",J&&"scale-x-100")}),r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("span",{className:Dr("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",J&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",P&&!J&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!P&&!J&&ae&&"border-[var(--border)] text-[var(--text-muted)]",!ae&&"border-[var(--border)] text-[var(--text-muted)]"),children:P?r.jsx(F.HiCheck,{className:"h-4 w-4"}):ae?I+1:r.jsx(F.HiLockClosed,{className:"h-3.5 w-3.5"})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsxs("span",{className:Dr("block truncate text-xs font-semibold transition-colors duration-200",J?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[I+1,". ",Q.title]}),Q.description&&r.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:Q.description})]}),Q.badge&&r.jsx("span",{className:"shrink-0",children:Q.badge})]})]},Q.id)})})]}),r.jsx("div",{className:Dr("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",$),children:le},_.id),u&&r.jsxs("div",{className:Dr("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",h),children:[r.jsx(je,{variant:"secondary",height:38,padding:"0 14px",icon:r.jsx(F.HiChevronLeft,{}),disabled:!z,onClick:B,children:p}),r.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[r.jsxs("span",{children:["Paso ",W+1," de ",e.length]}),r.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),r.jsxs("span",{children:[L.length," completados"]})]}),r.jsx(je,{height:38,padding:"0 14px",icon:r.jsx(F.HiChevronRight,{}),disabled:!v||!ee,onClick:O,children:v&&!ee?m:f})]})]})}const jd={sm:"min-h-20 px-2.5 py-1.5 text-xs leading-5",md:"min-h-24 px-2.5 py-2 text-sm leading-5",lg:"min-h-32 px-3 py-2.5 text-sm leading-6"},Wd={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function qd(e,t){if(e){if(typeof e=="function"){e(t);return}e.current=t}}function Ud(e,t){return e!==void 0?String(e).length:t!==void 0?String(t).length:0}const No=s.forwardRef(function({className:t="",wrapperClassName:n="",size:a="md",resize:o="vertical",autoResize:l=!1,minRows:i,maxRows:c,showCount:d=!1,maxCount:u,status:p="default",icon:f,action:m,style:x,value:w,defaultValue:$,maxLength:h,onInput:E,...T},g){const y=s.useRef(null),k=Ud(w,$),S=u??h,L=!!(f||m||d),C=p==="error"?"var(--danger)":p==="success"?"#16a34a":"var(--border)",W={...x??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},_=()=>{const M=y.current;!M||!l||(M.style.height="auto",M.style.height=`${M.scrollHeight}px`)};s.useEffect(_,[l,w]);const V=r.jsx("textarea",{...T,ref:M=>{y.current=M,qd(g,M)},value:w,defaultValue:$,maxLength:h,"aria-invalid":p==="error"||T["aria-invalid"],onInput:M=>{_(),E==null||E(M)},style:{...W,borderColor:C},className:`w-full rounded-lg border bg-[var(--bg-input)] text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-60 ${jd[a]} ${Wd[l?"none":o]} ${f?"pl-8":""} ${m?"pr-10":""} ${t}`});return L?r.jsxs("span",{className:`relative block ${n}`,children:[f&&r.jsx("span",{className:"pointer-events-none absolute left-2.5 top-2.5 flex h-4 w-4 items-center justify-center text-[var(--text-muted)]",children:f}),V,m&&r.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:m}),d&&r.jsxs("span",{className:"absolute bottom-1.5 right-2 rounded bg-[var(--bg-input)] px-1.5 text-[10px] font-semibold text-[var(--text-muted)]",children:[k,S?`/${S}`:""]})]}):V});function Vd({label:e,containerClassName:t="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:d,...u}){return r.jsx(ka,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:t,children:r.jsx(No,{...u,required:i,status:o?"error":d,className:`w-full ${c}`})})}const So=[{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 Yd(e){return So[e%So.length]}let Kd=0;function Ba(){return++Kd}function Co(e,t){return t?t instanceof RegExp?t.test(e):t(e):!0}function Xd(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Gd(e,t){const n=t.filter(Boolean);if(n.length===0)return[e.trim()].filter(Boolean);const a=new RegExp(`${n.map(o=>Xd(o)).join("|")}|\\r?\\n`,"g");return e.split(a).map(o=>o.trim()).filter(Boolean)}function Zd({value:e,defaultValue:t,onChange:n,placeholder:a="Escribe y presiona Enter…",disabled:o=!1,className:l="",delimiters:i=[","],maxTags:c,allowDuplicates:d=!1,validate:u,label:p,helperText:f,helperDisplay:m="inline",error:x,required:w=!1}){const $=e!==void 0,h=!!x,E=!!f&&m==="tooltip"&&!h,[T,g]=s.useState(()=>(t??[]).map((P,ae)=>({id:Ba(),value:P.trim(),colorIndex:ae})));s.useEffect(()=>{$&&g(P=>{const ae=e??[],Y=new Map(P.map(de=>[de.value,de]));return ae.map((de,Se)=>Y.get(de)??{id:Ba(),value:de,colorIndex:Se})})},[$,e]);const y=T,[k,S]=s.useState(""),[L,C]=s.useState(null),[W,_]=s.useState(""),[V,M]=s.useState(!1),[Z,H]=s.useState(!1),ne=s.useRef(null),U=s.useRef(null),q=s.useRef(null);function j(){H(!0),setTimeout(()=>H(!1),400)}function D(P){g(P),n==null||n(P.map(ae=>ae.value))}function se(P){let ae=y,Y=!1,de=!1;for(const Se of P){const ie=Se.trim();if(ie){if(c!==void 0&&ae.length>=c){de=!0;break}if(!d&&ae.some(pe=>pe.value.toLowerCase()===ie.toLowerCase())){de=!0;continue}if(!Co(ie,u)){de=!0;continue}ae=[...ae,{id:Ba(),value:ie,colorIndex:ae.length}],Y=!0}}return Y&&D(ae),de&&j(),Y}function B(P){return se([P])}function O(P){const ae=y.filter(Y=>Y.id!==P);D(ae.map((Y,de)=>({...Y,colorIndex:de})))}function oe(P,ae){const Y=ae.trim();if(C(null),_(""),!Y){O(P);return}if(!(!d&&y.some(de=>de.id!==P&&de.value.toLowerCase()===Y.toLowerCase()))){if(!Co(Y,u)){j();return}D(y.map(de=>de.id===P?{...de,value:Y}:de))}}function v(P){o||(C(P.id),_(P.value),setTimeout(()=>{var ae;return(ae=U.current)==null?void 0:ae.select()},0))}function z(P){if(P.key==="Enter"||i.includes(P.key)){P.preventDefault(),B(k)&&S("");return}if(P.key==="Backspace"&&k===""&&y.length>0){P.preventDefault();const ae=y[y.length-1];O(ae.id)}}function ee(P,ae){if(P.key==="Enter"){P.preventDefault(),oe(ae,W),setTimeout(()=>{var Y;return(Y=ne.current)==null?void 0:Y.focus()},0);return}P.key==="Escape"&&(P.preventDefault(),C(null),_(""),setTimeout(()=>{var Y;return(Y=ne.current)==null?void 0:Y.focus()},0))}function le(){var P;o||(P=ne.current)==null||P.focus()}function R(P){if(o)return;const ae=P.clipboardData.getData("text");if(!ae||!(i.some(ie=>ie&&ae.includes(ie))||ae.includes(`
29
- `)))return;P.preventDefault();const de=Gd(ae,i);se(de)&&S("")}function Q(){const P=k.trim();P&&B(P)&&S("")}const I=h?"var(--danger)":V?"var(--primary)":"var(--border)",J=c!==void 0&&y.length>=c;return r.jsxs("div",{className:`flex flex-col gap-2 ${l}`,children:[(p||w||E)&&r.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[p&&r.jsx("span",{children:p}),w&&r.jsx("span",{className:"text-[var(--danger)]",children:"*"}),E?r.jsx(ot,{content:f}):null]}),r.jsxs("div",{ref:q,onClick:le,onFocus:()=>M(!0),onBlur:P=>{var ae;(ae=q.current)!=null&&ae.contains(P.relatedTarget)||(M(!1),L!==null&&oe(L,W),L===null&&Q())},style:{borderColor:I},className:`
28
+ `).replace(/<[^>]+>/g," ").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/\s+/g," ").trim():""}function Ba(e){if(!e)return[];const r=new Set,n=[],a=d=>{const u=Ha(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=ho(e);Ia.lastIndex=0;let c;for(;(c=Ia.exec(i))!==null;)a(c[1]??"");return n}function go(e){const r=String(e.name??"").trim();return r||String(e.username??"").trim()||"usuario"}function Ad(e,r){const n=Ba(e);if(!n.length)return[];const a=new Map;r.forEach(i=>{i.username&&a.set(Ha(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 vo(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 Ld(e,r){return r?e.filter(n=>n.userId!==r):e}function yo(e){return!e||!/@/.test(e)?e:e.replace(Ia,(r,n,a,o)=>{const l=o.slice(0,a),i=l.lastIndexOf("<"),c=l.lastIndexOf(">");return i>c?r:`<span class="mention-chip" contenteditable="false" data-username="${(n??"").toLowerCase()}">${r}</span>`})}function dr(e,r){if(r<0)return null;const n=e.ownerDocument;if(!n)return null;const a=n.createTreeWalker(e,NodeFilter.SHOW_TEXT);let o=r,l=null,i=a.nextNode();for(;i;){l=i;const c=i.data.length;if(o<=c)return{node:i,offset:o};o-=c,i=a.nextNode()}return l&&o===0?{node:l,offset:l.data.length}:null}function Fa(e,r,n){var o;const a=e.ownerDocument;if(!a||e!==r&&!e.contains(r))return-1;try{const l=a.createRange();return l.selectNodeContents(e),l.setEnd(r,n),((o=l.cloneContents().textContent)==null?void 0:o.length)??0}catch{return-1}}function xo(e,r){const{triggerIndex:n,caretIndex:a,username:o}=r;if(a<n)return null;const l=dr(e,n),i=dr(e,a);if(!l||!i)return null;const c=e.ownerDocument,d=c.createRange();d.setStart(l.node,l.offset),d.setEnd(i.node,i.offset),d.deleteContents();const u=go({name:r.display,username:o}),m=c.createElement("span");m.className="mention-chip",m.setAttribute("data-username",o.toLowerCase()),r.userId&&m.setAttribute("data-userid",String(r.userId)),m.contentEditable="false",m.textContent=u,m.title=`@${o}`;const f=c.createTextNode(" ");d.insertNode(f),d.insertNode(m);const p=c.defaultView,x=p==null?void 0:p.getSelection();if(x){const w=c.createRange();w.setStart(f,f.data.length),w.collapse(!0),x.removeAllRanges(),x.addRange(w)}return{caretPlainOffset:n+u.length+1}}function wo(e,r){const n=e.ownerDocument,a=n.defaultView;if(!a)return;const o=a.getSelection();if(!o)return;const l=n.createRange(),i=dr(e,r);i?(l.setStart(i.node,i.offset),l.collapse(!0)):(l.selectNodeContents(e),l.collapse(!1)),o.removeAllRanges(),o.addRange(l)}function Sn(e){return e instanceof HTMLElement&&e.classList.contains("mention-chip")}function ko(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 No(e){var o;const r=e.ownerDocument,n=(o=r.defaultView)==null?void 0:o.getSelection();if(!n)return;const a=r.createRange();a.selectNode(e),n.removeAllRanges(),n.addRange(a),e.classList.add("is-selected")}function ur(e=document){var r;(r=e.querySelectorAll)==null||r.call(e,".mention-chip.is-selected").forEach(n=>{n.classList.remove("is-selected")})}function Cn(e){var u,m;const r=e.ownerDocument,n=e.parentNode;if(!n)return;const a=e.nextSibling;if(a&&a.nodeType===Node.TEXT_NODE&&/^( |\u00a0)/.test(a.textContent??"")){const f=a;(f.data.length??0)<=1?f.remove():f.data=f.data.slice(1)}const o=e.previousSibling,l=n,i=Array.from(n.childNodes).indexOf(e);e.remove();const c=(u=r.defaultView)==null?void 0:u.getSelection();if(!c)return;const d=r.createRange();if(o)if(o.nodeType===Node.TEXT_NODE){const f=((m=o.textContent)==null?void 0:m.length)??0;d.setStart(o,f)}else d.setStartAfter(o);else l.childNodes[i]?d.setStart(l,i):(d.selectNodeContents(l),d.collapse(!1));d.collapse(!0),c.removeAllRanges(),c.addRange(d)}function So(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=ko(a.previousSibling,"prev");return Sn(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(Sn(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c-=1;continue}break}}return null}function Co(e){var l;const r=(l=e.ownerDocument.defaultView)==null?void 0:l.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return null;const n=r.getRangeAt(0);if(!e.contains(n.startContainer))return null;const{startContainer:a,startOffset:o}=n;if(a.nodeType===Node.TEXT_NODE){const i=a.textContent??"";if(o>=i.length){const c=ko(a.nextSibling,"next");if(Sn(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(Sn(d))return d;if(d.nodeType===Node.TEXT_NODE&&!(d.textContent??"").replace(/\u00a0/g," ").trim()){c+=1;continue}break}}return null}function Eo(e){var 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 Pa=280,En=6,Mo=260,Dd=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]),Id={position:"relative"},Od={position:"fixed",zIndex:11050,minWidth:Mo,overflowY:"auto",background:"var(--bg-card, var(--bonsaif-ui-surface, #fff))",border:"1px solid var(--border, var(--bonsaif-ui-border, #d0d7de))",borderRadius:10,boxShadow:"0 12px 32px rgba(0,0,0,0.18)",padding:4},To={padding:"10px 12px",fontSize:12,color:"var(--text-muted, #656d76)"};function Hd(e){return Array.from(document.querySelectorAll(`[data-bonsaif-rich-instance="${CSS.escape(e)}"]`))}function Bd(e,r){const n=Math.max(8,Math.min(e.left,window.innerWidth-Mo-8)),a=r==null?void 0:r.getBoundingClientRect(),o=a?Math.min(window.innerHeight-8,a.bottom):window.innerHeight-8,l=a?Math.max(8,a.top):8,i=o-e.bottom-En,c=e.top-l-En;return i<Math.min(Pa,160)&&c>i?{left:n,bottom:window.innerHeight-e.top+En,maxHeight:Math.max(120,Math.min(Pa,c))}:{left:n,top:e.bottom+En,maxHeight:Math.max(120,Math.min(Pa,i))}}function $o({value:e,onChange:r,onSearchUsers:n,onMentionsChange:a,minHeight:o,placeholder:l,className:i,maxSuggestions:c=8,searchDebounceMs:d=140,highlightInEditor:u=!1,searchCacheKey:m=""}){const f=s.useId().replace(/:/g,""),p=s.useRef(null),x=s.useRef(null),w=s.useRef(new Map),T=s.useRef(n);T.current=n;const h=s.useRef(null),E=s.useRef(0),$=s.useRef([]),[v,y]=s.useState(null),[k,S]=s.useState([]),[A,C]=s.useState(0),[U,z]=s.useState([]),[Y,M]=s.useState(!1),[J,H]=s.useState(!1);E.current=A,s.useEffect(()=>{H(!0)},[]);const ne=(v==null?void 0:v.query)??null;s.useEffect(()=>{if(ne===null){S([]);return}const g=ne.trim(),_=`${m}|${g.toLowerCase()||"*"}`,ee=w.current.get(_);if(ee){S(ee),M(!1),C(0);return}const ae=new AbortController;M(!0);const j=window.setTimeout(()=>{(async()=>{try{const K=await T.current(g,{signal:ae.signal,limit:c});if(ae.signal.aborted)return;const L=Array.isArray(K)?K:[];w.current.set(_,L),S(L),C(0)}catch{ae.signal.aborted||S([])}finally{ae.signal.aborted||M(!1)}})()},d);return()=>{ae.abort(),window.clearTimeout(j)}},[ne,c,d,m]);const X=s.useRef(a);X.current=a,s.useEffect(()=>{var g;(g=X.current)==null||g.call(X,vo(U))},[U]);const W=s.useCallback(()=>{const g=Hd(f);if(g.length===0)return null;const _=window.getSelection();if(_!=null&&_.rangeCount){const ae=_.getRangeAt(0).startContainer;for(const j of g)if(j.contains(ae))return j}const ee=document.activeElement;for(const ae of g)if(ee===ae||ee&&ae.contains(ee))return ae;for(const ae of g)if(ae.closest('[role="dialog"]'))return ae;return g[0]??null},[f]),q=s.useCallback(()=>{const g=W(),_=window.getSelection();if(!g||!_||_.rangeCount===0){y(null);return}const ee=_.getRangeAt(0);if(!g.contains(ee.startContainer)){y(null);return}const ae=Fa(g,ee.startContainer,ee.startOffset);if(ae<0){y(null);return}const j=Oa(g,ae);if(!j){y(null);return}const K=ee.getBoundingClientRect(),L=K.width===0&&K.height===0?(()=>{const F=document.createRange();return F.selectNodeContents(ee.startContainer),F.collapse(!0),F.getBoundingClientRect()})():K;h.current={query:j.query,caretIndex:j.caretIndex,triggerIndex:j.triggerIndex};const R=Bd(L,g);y(F=>{const se={query:j.query,...R};return F&&F.query===se.query&&F.top===se.top&&F.bottom===se.bottom&&F.left===se.left&&F.maxHeight===se.maxHeight?F:se})},[W]),I=s.useCallback(g=>{r(g),q()},[r,q]);s.useEffect(()=>{const g=_=>{if(Dd.has(_.key))return;const ee=W(),ae=_.target;!ee||!ae||!ee.contains(ae)||q()};return document.addEventListener("keyup",g,!0),()=>document.removeEventListener("keyup",g,!0)},[W,q]);const oe=s.useCallback(g=>{const _=W();if(!_)return;let ee=-1;const ae=window.getSelection();if(ae&&ae.rangeCount>0){const F=ae.getRangeAt(0);_.contains(F.startContainer)&&(ee=Fa(_,F.startContainer,F.startOffset))}if(ee<0&&h.current&&(ee=h.current.caretIndex),ee<0)return;const j=Oa(_,ee);if(!j)return;const K=xo(_,{triggerIndex:j.triggerIndex,caretIndex:ee,username:g.username,display:g.name,userId:g.userId});if(!K)return;r(_.innerHTML);const L={userId:g.userId,username:g.username,email:g.email??void 0,display:g.name??g.username};z(F=>{const se=new Map(F.map(G=>[G.userId,G]));return se.set(L.userId,L),Array.from(se.values())}),y(null),h.current=null;const R=K.caretPlainOffset;requestAnimationFrame(()=>{requestAnimationFrame(()=>{var Se,ie;const F=W();if(!F)return;F.focus(),wo(F,R);const se=window.getSelection(),G=se==null?void 0:se.anchorNode,de=G instanceof Element?G.closest(".mention-chip"):(Se=G==null?void 0:G.parentElement)==null?void 0:Se.closest(".mention-chip");if(de!=null&&de.parentNode){const pe=document.createRange(),Ce=de.nextSibling;Ce&&Ce.nodeType===Node.TEXT_NODE?pe.setStart(Ce,((ie=Ce.textContent)==null?void 0:ie.length)??0):pe.setStartAfter(de),pe.collapse(!0),se==null||se.removeAllRanges(),se==null||se.addRange(pe)}})})},[W,r]);s.useEffect(()=>{const g=new Set(Ba(e).map(_=>_.toLowerCase()));z(_=>{const ee=_.filter(ae=>g.has(ae.username.toLowerCase()));return ee.length===_.length?_:ee})},[e]),s.useEffect(()=>{if(!v)return;const g=_=>{const ee=_.target;if(!ee||p.current&&p.current.contains(ee)||x.current&&x.current.contains(ee))return;const ae=W();ae&&ae.contains(ee)||y(null)};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[v,W]);const B=s.useMemo(()=>k.slice(0,c),[k,c]);$.current=B,s.useEffect(()=>{if(!v)return;const g=_=>{const ee=W(),ae=_.target;if(!ee||!ae||!ee.contains(ae))return;const j=$.current;if(!(j.length===0&&_.key!=="Escape"))if(_.key==="ArrowDown")_.preventDefault(),_.stopPropagation(),C(K=>(K+1)%Math.max(j.length,1));else if(_.key==="ArrowUp")_.preventDefault(),_.stopPropagation(),C(K=>(K-1+j.length)%Math.max(j.length,1));else if(_.key==="Enter"||_.key==="Tab"){const K=j[E.current];K&&(_.preventDefault(),_.stopPropagation(),oe(K))}else _.key==="Escape"&&(_.preventDefault(),_.stopPropagation(),y(null))};return document.addEventListener("keydown",g,!0),()=>document.removeEventListener("keydown",g,!0)},[W,oe,v]),s.useEffect(()=>{const g=ae=>{r(ae.innerHTML)},_=ae=>{if(ae.key!=="Backspace"&&ae.key!=="Delete")return;const j=W(),K=ae.target;if(!j||!K||!j.contains(K))return;const L=Eo(j);if(L.length>0){ae.preventDefault(),ae.stopPropagation();for(const F of L)Cn(F);ur(j),g(j);return}if(ae.key==="Backspace"){const F=So(j);if(!F)return;ae.preventDefault(),ae.stopPropagation(),Cn(F),ur(j),g(j);return}const R=Co(j);R&&(ae.preventDefault(),ae.stopPropagation(),Cn(R),ur(j),g(j))},ee=ae=>{const j=W();if(!j)return;const K=ae.target;if(!(K instanceof Element)||!j.contains(K))return;const L=K.closest(".mention-chip");if(!(L instanceof HTMLElement)||!j.contains(L)){ur(j);return}ae.preventDefault(),j.focus(),ur(j),No(L)};return document.addEventListener("keydown",_,!0),document.addEventListener("mousedown",ee,!0),()=>{document.removeEventListener("keydown",_,!0),document.removeEventListener("mousedown",ee,!0)}},[W,r]),s.useEffect(()=>{if(!v||!x.current)return;const g=x.current.querySelector(`[data-mention-index="${A}"]`);g==null||g.scrollIntoView({block:"nearest"})},[A,v]);const O=u?yo(e):e,le=v&&J?nt.createPortal(t.jsxs("ul",{ref:x,style:{...Od,left:v.left,top:v.top,bottom:v.bottom,maxHeight:v.maxHeight},role:"listbox","aria-label":"Menciones sugeridas",children:[Y&&B.length===0&&t.jsx("li",{style:To,children:"Buscando…"}),!Y&&B.length===0&&t.jsx("li",{style:To,children:v.query.trim().length===0?"Escribe un nombre o usuario":`Sin coincidencias para “${v.query}”`}),B.map((g,_)=>{var ee,ae;return t.jsx("li",{children:t.jsxs("button",{type:"button","data-mention-index":_,onMouseDown:j=>{j.preventDefault(),oe(g)},onMouseEnter:()=>C(_),style:{width:"100%",textAlign:"left",padding:"8px 10px",border:"none",background:_===A?"color-mix(in srgb, var(--primary, var(--bonsaif-ui-primary, #1f6feb)) 14%, transparent)":"transparent",color:"var(--text-main, var(--bonsaif-ui-text, #24292f))",borderRadius:6,cursor:"pointer",display:"flex",flexDirection:"column",gap:2},children:[t.jsx("span",{style:{fontWeight:600,fontSize:13},children:((ee=g.name)==null?void 0:ee.trim())||`@${g.username}`}),t.jsx("span",{style:{fontSize:11,color:"var(--text-muted, #656d76)"},children:[(ae=g.name)!=null&&ae.trim()?`@${g.username}`:null,g.email].filter(Boolean).join(" · ")||`@${g.username}`})]})},g.userId)})]}),document.body):null;return t.jsxs("div",{ref:p,style:Id,className:i,children:[t.jsx(co,{value:O,onChange:I,placeholder:l,minHeight:o,instanceId:f}),le]})}function Fd({value:e,onChange:r,placeholder:n,minHeight:a,onSearchUsers:o,onMentionsChange:l,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m}){return o?t.jsx($o,{value:e,onChange:r,onSearchUsers:o,onMentionsChange:l,placeholder:n,minHeight:a,className:i,maxSuggestions:c,searchDebounceMs:d,highlightInEditor:u,searchCacheKey:m}):t.jsx(co,{value:e,onChange:r,placeholder:n,minHeight:a})}function Pd({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 _d={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)"}},zd={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 jd({children:e,tone:r="neutral",size:n="sm",icon:a,dot:o=!1,className:l=""}){const i=_d[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 ${zd[n]} ${l}`,style:{color:i.text,background:i.bg,borderColor:i.border},children:[o&&t.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:i.text}}),a&&t.jsx("span",{className:"shrink-0",children:a}),t.jsx("span",{className:"min-w-0 truncate",children:e})]})}const Ao={neutral:{color:"var(--text-secondary)",background:"var(--bg-input)"},primary:{color:"var(--primary)",background:"color-mix(in srgb, var(--primary) 10%, transparent)"},success:{color:"#047857",background:"rgba(16, 185, 129, 0.11)"},warning:{color:"#b45309",background:"rgba(245, 158, 11, 0.12)"},danger:{color:"var(--danger)",background:"var(--danger-bg)"},info:{color:"#2563eb",background:"rgba(59, 130, 246, 0.11)"}},Wd={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"},qd={xs:"right-1 h-3 w-3",sm:"right-1.5 h-3 w-3",md:"right-2 h-3.5 w-3.5"},Ud={xs:148,sm:164,md:184},Vd={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 Xd({value:e,options:r,onChange:n,size:a="sm",disabled:o=!1,loading:l=!1,stopPropagation:i=!1,ariaLabel:c="Cambiar estado",title:d="Cambiar estado",className:u,selectClassName:m,menuClassName:f,optionClassName:p,spinnerClassName:x}){const[w,T]=s.useState(!1),[h,E]=s.useState(!1),[$,v]=s.useState(-1),[y,k]=s.useState({}),S=s.useRef(null),A=s.useRef(null),C=s.useRef(null),U=r.find(q=>q.value===e)??r[0],z={...U!=null&&U.tone?Ao[U.tone]:void 0,...U==null?void 0:U.style},Y=o||l||r.length===0,M=q=>{i&&q.stopPropagation()},J=s.useCallback(()=>{T(!1),v(-1)},[]),H=s.useCallback(()=>{const q=S.current;if(!q)return;const I=q.getBoundingClientRect(),oe=Math.max(I.width,Ud[a]),B=Math.min(Math.max(r.length,1)*38+12,260),O=window.innerHeight-I.bottom,le=O<B&&I.top>O,g=Math.min(Math.max(8,I.left+I.width/2-oe/2),window.innerWidth-oe-8);k({position:"fixed",left:g,top:le?void 0:I.bottom+6,bottom:le?window.innerHeight-I.top+6:void 0,width:oe,zIndex:9999})},[r.length,a]),ne=s.useCallback(q=>{q.disabled||(n(q.value),J())},[J,n]);s.useEffect(()=>E(!0),[]),s.useEffect(()=>{if(!w)return;H();const q=r.findIndex(I=>I.value===e);v(q>=0?q:0)},[w,r,H,e]),s.useEffect(()=>{if(!w)return;function q(I){var B,O;const oe=I.target;!((B=S.current)!=null&&B.contains(oe))&&!((O=A.current)!=null&&O.contains(oe))&&J()}return document.addEventListener("mousedown",q),()=>document.removeEventListener("mousedown",q)},[J,w]),s.useEffect(()=>{if(w)return window.addEventListener("resize",H),window.addEventListener("scroll",H,!0),()=>{window.removeEventListener("resize",H),window.removeEventListener("scroll",H,!0)}},[w,H]),s.useEffect(()=>{if($<0||!C.current)return;const q=C.current.children[$];q==null||q.scrollIntoView({block:"nearest"})},[$]);function X(q){if(!Y){if(!w){["Enter"," ","ArrowDown","ArrowUp"].includes(q.key)&&(q.preventDefault(),T(!0));return}if(q.key==="Escape"){q.preventDefault(),J();return}if(q.key==="ArrowDown"){q.preventDefault(),v(I=>Math.min(I+1,r.length-1));return}if(q.key==="ArrowUp"){q.preventDefault(),v(I=>Math.max(I-1,0));return}if(q.key==="Enter"||q.key===" "){q.preventDefault();const I=r[$];I&&ne(I)}}}const W=t.jsx("div",{ref:A,role:"listbox","aria-label":c,className:$t("overflow-hidden rounded-xl border shadow-xl backdrop-blur-md",f),style:{...y,background:"color-mix(in srgb, var(--bg-card) 92%, transparent)",borderColor:"var(--border)",color:"var(--text-main)"},onClick:M,onMouseDown:M,onPointerDown:M,children:t.jsx("div",{ref:C,className:"max-h-64 overflow-y-auto p-1",style:{scrollbarWidth:"thin",scrollbarColor:"var(--border) transparent",overscrollBehavior:"contain"},children:r.map((q,I)=>{const oe=q.value===e,B=I===$,O={...q.tone?Ao[q.tone]:void 0,...q.style};return t.jsxs("button",{type:"button",role:"option","aria-selected":oe,disabled:q.disabled,onMouseEnter:()=>!q.disabled&&v(I),onMouseDown:le=>{le.preventDefault(),ne(q)},className:$t("flex w-full items-center gap-2 rounded-lg font-medium text-left transition-colors disabled:cursor-not-allowed disabled:opacity-45",Vd[a],oe?q.className:void 0,p),style:{...oe?O:void 0,background:oe?O.background??"color-mix(in srgb, var(--primary) 12%, transparent)":B?"var(--bg-hover)":"transparent",color:oe?O.color??"var(--primary)":"var(--text-main)"},children:[t.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:oe?t.jsx(P.HiCheck,{className:"h-4 w-4"}):null}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:q.label})]},q.value)})})});return t.jsxs("span",{ref:S,className:$t("relative inline-flex shrink-0 items-center",u),onKeyDown:X,onClick:M,onPointerDown:M,children:[t.jsx("button",{type:"button",disabled:Y,"aria-label":c,"aria-haspopup":"listbox","aria-expanded":w,title:d,onClick:()=>!Y&&T(q=>!q),className:$t("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",Wd[a],U==null?void 0:U.className,m),style:z,children:t.jsx("span",{className:"min-w-0 truncate",children:(U==null?void 0:U.label)??e})}),t.jsx(P.HiChevronDown,{"aria-hidden":"true",className:$t("pointer-events-none absolute opacity-70 transition-transform",qd[a],w?"rotate-180":"rotate-0")}),l&&t.jsx("span",{"aria-hidden":"true",className:$t("absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full border border-current border-t-transparent animate-spin",x)}),w&&h&&nt.createPortal(W,document.body)]})}function Yd({tabs:e,activeTabId:r,defaultActiveTabId:n,onTabChange:a,ariaLabel:o="Pestanas",variant:l="underline",className:i="",listClassName:c="",panelClassName:d=""}){const u=e.find(w=>!w.disabled)??e[0],m=r??n??(u==null?void 0:u.id),f=e.find(w=>w.id===m)??u,p=w=>{w.disabled||a==null||a(w.id)},x=w=>{const T=e.filter(E=>!E.disabled);if(!T.length||!f)return;const h=T.findIndex(E=>E.id===f.id);(w.key==="ArrowRight"||w.key==="ArrowDown")&&(w.preventDefault(),p(T[(h+1)%T.length])),(w.key==="ArrowLeft"||w.key==="ArrowUp")&&(w.preventDefault(),p(T[(h-1+T.length)%T.length])),w.key==="Home"&&(w.preventDefault(),p(T[0])),w.key==="End"&&(w.preventDefault(),p(T[T.length-1]))};return t.jsxs("div",{className:i,children:[t.jsx("div",{role:"tablist","aria-label":o,onKeyDown:x,className:`flex min-w-0 gap-1 overflow-x-auto ${l==="underline"?"border-b border-[var(--border)]":"rounded-lg border border-[var(--border)] bg-[var(--bg-input)] p-1"} ${c}`,children:e.map(w=>{const T=w.id===(f==null?void 0:f.id);return t.jsxs("button",{type:"button",role:"tab","aria-selected":T,"aria-controls":`${w.id}-panel`,id:`${w.id}-tab`,disabled:w.disabled,tabIndex:T?0:-1,onClick:()=>p(w),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:T?"var(--primary)":"var(--text-muted)",borderColor:T?"var(--primary)":"transparent",background:l==="pills"&&T?"var(--bg-card)":"transparent"},children:[w.icon&&t.jsx("span",{className:"shrink-0",children:w.icon}),t.jsx("span",{children:w.label}),w.badge&&t.jsx("span",{className:"shrink-0",children:w.badge})]},w.id)})}),(f==null?void 0:f.content)!==void 0&&t.jsx("div",{role:"tabpanel",id:`${f.id}-panel`,"aria-labelledby":`${f.id}-tab`,className:`pt-4 ${d}`,children:f.content})]})}function Dt(...e){return e.filter(Boolean).join(" ")}function Kd({steps:e,activeStepId:r,initialStepId:n,completedStepIds:a,defaultCompletedStepIds:o=[],onActiveStepChange:l,onCompletedStepIdsChange:i,onBlockedStep:c,allowBackNavigation:d=!0,showFooter:u=!0,previousLabel:m="Anterior",nextLabel:f="Siguiente",blockedNextLabel:p="Completa este paso",className:x="",headerClassName:w="",contentClassName:T="",footerClassName:h=""}){var j;const E=((j=e[0])==null?void 0:j.id)??"",[$,v]=s.useState(n??E),[y,k]=s.useState(o),S=r??$,A=a??y,C=s.useMemo(()=>new Set(A),[A]),U=Math.max(0,e.findIndex(K=>K.id===S)),z=e[U]??e[0],Y=e.length<=1?100:U/(e.length-1)*100,M=K=>{a||k(K),i==null||i(K)},J=K=>{const L=e.find(R=>R.id===K);L&&(r||v(K),l==null||l(K,L))},H=K=>C.has(K),ne=K=>e.slice(0,K).find(L=>!L.optional&&!C.has(L.id)),X=K=>{const L=e[K];return!L||L.disabled?!1:K===U||d&&K<U?!0:!ne(K)},W=K=>{const L=e.findIndex(R=>R.id===K);return L>=0&&X(L)},q=K=>{const L=e.findIndex(R=>R.id===K);if(L<0)return!1;if(!X(L)){const R=ne(L);return R&&(c==null||c(e[L],R)),!1}return J(K),!0},I=(K=z==null?void 0:z.id)=>{!K||C.has(K)||M([...A,K])},oe=(K=z==null?void 0:z.id)=>{if(!K)return;const L=e.findIndex(F=>F.id===K),R=A.filter(F=>{const se=e.findIndex(G=>G.id===F);return se>=0&&se<L});M(R),L>=0&&U>L&&J(K)},B=()=>U<=0?!1:q(e[U-1].id),O=()=>{const K=e[U+1];return K?q(K.id):!1},le={activeStep:z,activeIndex:U,completedStepIds:A,isCompleted:H,isUnlocked:W,completeStep:I,uncompleteStep:oe,goToStep:q,goNext:O,goPrevious:B};if(!z)return null;const g=e[U+1],_=U>0,ee=g?W(g.id):!1,ae=typeof z.content=="function"?z.content(le):z.content;return t.jsxs("section",{className:Dt("overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--bg-card)]",x),children:[t.jsxs("div",{className:Dt("border-b border-[var(--border)] bg-[var(--bg-input)]",w),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:`${Y}%`}})}),t.jsx("div",{className:"grid gap-2 p-2",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map((K,L)=>{const R=K.id===z.id,F=H(K.id),se=X(L),G=ne(L);return t.jsxs("button",{type:"button",disabled:!se,"aria-current":R?"step":void 0,"aria-disabled":!se,title:!se&&G?`Completa ${G.title}`:K.title,onClick:()=>q(K.id),className:Dt("group relative min-h-16 min-w-0 overflow-hidden rounded-md border p-3 text-left transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)]/35 disabled:cursor-not-allowed",R&&"border-[var(--primary)] bg-[var(--bg-card)] shadow-sm",F&&!R&&"border-[var(--primary)]/35 bg-[var(--bg-card)]",!R&&!F&&se&&"border-transparent bg-[var(--bg-card)]/45 hover:border-[var(--border)] hover:bg-[var(--bg-card)]",!se&&"border-transparent bg-[var(--bg-card)]/35 opacity-60"),children:[t.jsx("span",{className:Dt("absolute inset-x-0 top-0 h-0.5 origin-left scale-x-0 bg-[var(--primary)] transition-transform duration-300",R&&"scale-x-100")}),t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:Dt("grid h-7 w-7 shrink-0 place-items-center rounded-full border text-xs font-bold transition-all duration-200",R&&"border-[var(--primary)] bg-[var(--primary)] text-[var(--primary-fg)]",F&&!R&&"border-[var(--primary)] bg-[var(--primary)]/12 text-[var(--primary)]",!F&&!R&&se&&"border-[var(--border)] text-[var(--text-muted)]",!se&&"border-[var(--border)] text-[var(--text-muted)]"),children:F?t.jsx(P.HiCheck,{className:"h-4 w-4"}):se?L+1:t.jsx(P.HiLockClosed,{className:"h-3.5 w-3.5"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:Dt("block truncate text-xs font-semibold transition-colors duration-200",R?"text-[var(--text-main)]":"text-[var(--text-secondary)]"),children:[L+1,". ",K.title]}),K.description&&t.jsx("span",{className:"mt-1 block truncate text-[11px] text-[var(--text-muted)]",children:K.description})]}),K.badge&&t.jsx("span",{className:"shrink-0",children:K.badge})]})]},K.id)})})]}),t.jsx("div",{className:Dt("min-h-72 animate-[stepWizardIn_220ms_ease-out] p-5",T),children:ae},z.id),u&&t.jsxs("div",{className:Dt("flex flex-wrap items-center justify-between gap-3 border-t border-[var(--border)] bg-[var(--bg-input)] px-4 py-3",h),children:[t.jsx(je,{variant:"secondary",height:38,padding:"0 14px",icon:t.jsx(P.HiChevronLeft,{}),disabled:!_,onClick:B,children:m}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-muted)]",children:[t.jsxs("span",{children:["Paso ",U+1," de ",e.length]}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-[var(--border)]"}),t.jsxs("span",{children:[A.length," completados"]})]}),t.jsx(je,{height:38,padding:"0 14px",icon:t.jsx(P.HiChevronRight,{}),disabled:!g||!ee,onClick:O,children:g&&!ee?p:f})]})]})}const Gd={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"},Zd={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"};function Qd(e,r){if(e){if(typeof e=="function"){e(r);return}e.current=r}}function Jd(e,r){return e!==void 0?String(e).length:r!==void 0?String(r).length:0}const Lo=s.forwardRef(function({className:r="",wrapperClassName:n="",size:a="md",resize:o="vertical",autoResize:l=!1,minRows:i,maxRows:c,showCount:d=!1,maxCount:u,status:m="default",icon:f,action:p,style:x,value:w,defaultValue:T,maxLength:h,onInput:E,...$},v){const y=s.useRef(null),k=Jd(w,T),S=u??h,A=!!(f||p||d),C=m==="error"?"var(--danger)":m==="success"?"#16a34a":"var(--border)",U={...x??{},...i?{minHeight:`${i*24+18}px`}:null,...c?{maxHeight:`${c*24+18}px`}:null},z=()=>{const M=y.current;!M||!l||(M.style.height="auto",M.style.height=`${M.scrollHeight}px`)};s.useEffect(z,[l,w]);const Y=t.jsx("textarea",{...$,ref:M=>{y.current=M,Qd(v,M)},value:w,defaultValue:T,maxLength:h,"aria-invalid":m==="error"||$["aria-invalid"],onInput:M=>{z(),E==null||E(M)},style:{...U,borderColor:C},className:`w-full rounded-lg border bg-[var(--bg-input)] text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] transition-colors focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-60 ${Gd[a]} ${Zd[l?"none":o]} ${f?"pl-8":""} ${p?"pr-10":""} ${r}`});return A?t.jsxs("span",{className:`relative block ${n}`,children:[f&&t.jsx("span",{className:"pointer-events-none absolute left-2.5 top-2.5 flex h-4 w-4 items-center justify-center text-[var(--text-muted)]",children:f}),Y,p&&t.jsx("span",{className:"absolute right-2 top-2 flex items-center justify-center",children:p}),d&&t.jsxs("span",{className:"absolute bottom-1.5 right-2 rounded bg-[var(--bg-input)] px-1.5 text-[10px] font-semibold text-[var(--text-muted)]",children:[k,S?`/${S}`:""]})]}):Y});function Rd({label:e,containerClassName:r="",helperText:n,helperDisplay:a,error:o,labelAction:l,required:i,className:c="",status:d,...u}){return t.jsx(Ca,{label:e,required:i,helperText:n,helperDisplay:a,error:o,labelAction:l,className:r,children:t.jsx(Lo,{...u,required:i,status:o?"error":d,className:`w-full ${c}`})})}const Do=[{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 eu(e){return Do[e%Do.length]}let tu=0;function _a(){return++tu}function Io(e,r){return r?r instanceof RegExp?r.test(e):r(e):!0}function ru(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function nu(e,r){const n=r.filter(Boolean);if(n.length===0)return[e.trim()].filter(Boolean);const a=new RegExp(`${n.map(o=>ru(o)).join("|")}|\\r?\\n`,"g");return e.split(a).map(o=>o.trim()).filter(Boolean)}function au({value:e,defaultValue:r,onChange:n,placeholder:a="Escribe y presiona Enter…",disabled:o=!1,className:l="",delimiters:i=[","],maxTags:c,allowDuplicates:d=!1,validate:u,label:m,helperText:f,helperDisplay:p="inline",error:x,required:w=!1}){const T=e!==void 0,h=!!x,E=!!f&&p==="tooltip"&&!h,[$,v]=s.useState(()=>(r??[]).map((F,se)=>({id:_a(),value:F.trim(),colorIndex:se})));s.useEffect(()=>{T&&v(F=>{const se=e??[],G=new Map(F.map(de=>[de.value,de]));return se.map((de,Se)=>G.get(de)??{id:_a(),value:de,colorIndex:Se})})},[T,e]);const y=$,[k,S]=s.useState(""),[A,C]=s.useState(null),[U,z]=s.useState(""),[Y,M]=s.useState(!1),[J,H]=s.useState(!1),ne=s.useRef(null),X=s.useRef(null),W=s.useRef(null);function q(){H(!0),setTimeout(()=>H(!1),400)}function I(F){v(F),n==null||n(F.map(se=>se.value))}function oe(F){let se=y,G=!1,de=!1;for(const Se of F){const ie=Se.trim();if(ie){if(c!==void 0&&se.length>=c){de=!0;break}if(!d&&se.some(pe=>pe.value.toLowerCase()===ie.toLowerCase())){de=!0;continue}if(!Io(ie,u)){de=!0;continue}se=[...se,{id:_a(),value:ie,colorIndex:se.length}],G=!0}}return G&&I(se),de&&q(),G}function B(F){return oe([F])}function O(F){const se=y.filter(G=>G.id!==F);I(se.map((G,de)=>({...G,colorIndex:de})))}function le(F,se){const G=se.trim();if(C(null),z(""),!G){O(F);return}if(!(!d&&y.some(de=>de.id!==F&&de.value.toLowerCase()===G.toLowerCase()))){if(!Io(G,u)){q();return}I(y.map(de=>de.id===F?{...de,value:G}:de))}}function g(F){o||(C(F.id),z(F.value),setTimeout(()=>{var se;return(se=X.current)==null?void 0:se.select()},0))}function _(F){if(F.key==="Enter"||i.includes(F.key)){F.preventDefault(),B(k)&&S("");return}if(F.key==="Backspace"&&k===""&&y.length>0){F.preventDefault();const se=y[y.length-1];O(se.id)}}function ee(F,se){if(F.key==="Enter"){F.preventDefault(),le(se,U),setTimeout(()=>{var G;return(G=ne.current)==null?void 0:G.focus()},0);return}F.key==="Escape"&&(F.preventDefault(),C(null),z(""),setTimeout(()=>{var G;return(G=ne.current)==null?void 0:G.focus()},0))}function ae(){var F;o||(F=ne.current)==null||F.focus()}function j(F){if(o)return;const se=F.clipboardData.getData("text");if(!se||!(i.some(ie=>ie&&se.includes(ie))||se.includes(`
29
+ `)))return;F.preventDefault();const de=nu(se,i);oe(de)&&S("")}function K(){const F=k.trim();F&&B(F)&&S("")}const L=h?"var(--danger)":Y?"var(--primary)":"var(--border)",R=c!==void 0&&y.length>=c;return t.jsxs("div",{className:`flex flex-col gap-2 ${l}`,children:[(m||w||E)&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold uppercase text-[var(--text-muted)]",children:[m&&t.jsx("span",{children:m}),w&&t.jsx("span",{className:"text-[var(--danger)]",children:"*"}),E?t.jsx(or,{content:f}):null]}),t.jsxs("div",{ref:W,onClick:ae,onFocus:()=>M(!0),onBlur:F=>{var se;(se=W.current)!=null&&se.contains(F.relatedTarget)||(M(!1),A!==null&&le(A,U),A===null&&K())},style:{borderColor:L},className:`
30
30
  flex min-h-10 flex-wrap items-center gap-1.5 rounded-lg border
31
31
  bg-[var(--bg-input)] px-2.5 py-2 transition-colors
32
32
  ${o?"cursor-not-allowed opacity-60":"cursor-text"}
33
- ${Z?"animate-[tag-shake_0.4s_ease]":""}
34
- `,children:[r.jsx("style",{children:`
33
+ ${J?"animate-[tag-shake_0.4s_ease]":""}
34
+ `,children:[t.jsx("style",{children:`
35
35
  @keyframes tag-shake {
36
36
  0%,100% { transform: translateX(0); }
37
37
  20% { transform: translateX(-4px); }
@@ -39,4 +39,4 @@ ${X}`,te=new Blob(["\uFEFF"+A],{type:"text/csv;charset=utf-8;"}),fe=URL.createOb
39
39
  60% { transform: translateX(-3px); }
40
40
  80% { transform: translateX(3px); }
41
41
  }
42
- `}),y.map(P=>{const ae=Yd(P.colorIndex);return L===P.id?r.jsx("input",{ref:U,value:W,disabled:o,onChange:Y=>_(Y.target.value),onKeyDown:Y=>ee(Y,P.id),onBlur:()=>oe(P.id,W),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(W.length+2,6)}ch`}},P.id):r.jsxs("span",{className:"inline-flex max-w-[240px] items-center gap-1 rounded-md px-2 py-0.5 text-xs font-medium",style:{backgroundColor:ae.bg,color:ae.text,border:`1px solid ${ae.border}`},children:[r.jsx("span",{className:"truncate",children:P.value}),r.jsx("button",{type:"button","aria-label":`Editar "${P.value}"`,disabled:o,tabIndex:-1,onClick:Y=>{Y.stopPropagation(),v(P)},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:r.jsx(F.HiPencil,{className:"h-3 w-3"})}),r.jsx("button",{type:"button","aria-label":`Eliminar "${P.value}"`,disabled:o,tabIndex:-1,onClick:Y=>{Y.stopPropagation(),O(P.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:r.jsx(F.HiXMark,{className:"h-3.5 w-3.5"})})]},P.id)}),!J&&r.jsx("input",{ref:ne,value:k,disabled:o,placeholder:y.length===0?a:"",onChange:P=>S(P.target.value),onKeyDown:z,onPaste:R,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"})]}),r.jsx(lt,{error:x,helperText:f,helperDisplay:m})]})}const Qd=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;function Ye(e){return String(e).padStart(2,"0")}function Fa(e,t=ut()){const n=e.trim();if(!n)return t;const a=n.match(Qd);if(!a)return t;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?t:{hour24:o,minute:l,second:i}}function Wt(e,t=!0){const n=`${Ye(e.hour24)}:${Ye(e.minute)}`;return t?`${n}:${Ye(e.second)}`:n}function Sn(e){const t=e.hour24>=12?"PM":"AM";return{hour12:e.hour24%12===0?12:e.hour24%12,minute:e.minute,second:e.second,meridiem:t}}function qt(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 Jd(e,t){const n=(t==null?void 0:t.use12Hour)??!1,a=(t==null?void 0:t.showSeconds)??!0,o=Fa(e);if(n){const l=Sn(o),i=`${l.hour12}:${Ye(l.minute)}`;return`${a?`${i}:${Ye(l.second)}`:i} ${l.meridiem}`}return Wt(o,a)}function ut(){const e=new Date;return{hour24:e.getHours(),minute:e.getMinutes(),second:e.getSeconds()}}function Rd(e=!0){return Wt(ut(),e)}function Pa(e,t){const n=[];for(let a=e;a<=t;a+=1)n.push(a);return n}const sr=36,za=5,Eo=Math.floor(za/2),eu=52,ru=48,Cr=18;function Mo(e){return e*sr}function $o(e){return Math.round(e/sr)}function tu(e){return e.use12Hour??e.hour12??!1}function Cn({values:e,selected:t,onSelect:n,syncEpochRef:a,forceSyncAt:o=0,width:l=eu,label:i,maxNumeric:c=59,isMeridiem:d=!1,isFocused:u=!1,onFocus:p,onAdvance:f,onBack:m,setColumnRef:x}){const w=s.useRef(null),$=s.useRef(null),h=s.useRef(null),E=s.useRef(""),T=s.useRef(0),g=s.useRef(!1),[y,k]=s.useState(t),[S,L]=s.useState(""),C=s.useCallback(v=>{E.current=v,L(v)},[]),W=s.useMemo(()=>[...Array(Eo).fill(""),...e,...Array(Eo).fill("")],[e]),_=s.useCallback(()=>{const v=w.current;if(!v)return t;const z=$o(v.scrollTop),ee=Math.min(Math.max(z,0),e.length-1);return e[ee]??t},[t,e]),V=s.useCallback((v,z=!0)=>{const ee=Math.min(Math.max(v,0),e.length-1),le=e[ee],R=w.current;!R||!le||($.current&&(window.clearTimeout($.current),$.current=null),g.current=!0,T.current=ee,R.scrollTop=Mo(ee),k(le),z&&le!==t&&n(le))},[n,t,e]);s.useLayoutEffect(()=>{$.current&&(window.clearTimeout($.current),$.current=null),h.current&&(window.clearTimeout(h.current),h.current=null),C(""),k(t);const v=e.indexOf(t);if(v>=0&&(T.current=v),v<0||!w.current)return;const z=Mo(v);w.current.scrollTop!==z&&(w.current.scrollTop=z)},[o,t,C,e]);const M=s.useCallback(()=>{h.current&&(window.clearTimeout(h.current),h.current=null)},[]),Z=s.useCallback((v,z=!1)=>{M(),C("");const ee=Number(v);if(!Number.isFinite(ee))return;const le=Math.min(c,Math.max(0,ee));let R=Ye(le),Q=e.indexOf(R);if(Q<0){const I=Math.min(e.length-1,Math.max(0,le-(c===12?1:0)));R=e[I]??R,Q=e.indexOf(R)}Q>=0&&V(Q),z&&(f==null||f())},[M,c,f,V,C,e]),H=s.useCallback(v=>{const z=Math.floor(c/10),ee=E.current;if(ee===""){if(v>z){Z(String(v),!0);return}const R=String(v);C(R),h.current=window.setTimeout(()=>{Z(E.current,!0)},1200);return}M();const le=+`${ee}${v}`;le<=c?Z(String(le),!0):Z(String(v),!0)},[M,Z,c,C]),ne=s.useCallback(v=>{M(),C(""),V(T.current+v)},[M,V,C]),U=v=>{if(d){v.key==="a"||v.key==="A"?(v.preventDefault(),n("AM"),f==null||f()):v.key==="p"||v.key==="P"?(v.preventDefault(),n("PM"),f==null||f()):v.key==="ArrowUp"||v.key==="ArrowDown"?(v.preventDefault(),n(t==="AM"?"PM":"AM")):v.key==="Tab"&&(v.preventDefault(),v.shiftKey?m==null||m():f==null||f());return}if(/^\d$/.test(v.key)){v.preventDefault(),H(Number(v.key));return}v.key==="ArrowUp"?(v.preventDefault(),ne(-1)):v.key==="ArrowDown"?(v.preventDefault(),ne(1)):v.key==="Tab"&&(v.preventDefault(),M(),E.current!==""&&Z(E.current,!1),v.shiftKey?m==null||m():f==null||f())},q=s.useCallback(()=>{const v=a.current,z=w.current;z&&v===a.current&&V($o(z.scrollTop))},[V,a]),j=()=>{if(E.current!=="")return;if(g.current){g.current=!1;const z=_();k(z);const ee=e.indexOf(z);ee>=0&&(T.current=ee);return}k(_()),$.current&&window.clearTimeout($.current);const v=a.current;$.current=window.setTimeout(()=>{v===a.current&&q()},100)},D="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",se=sr*za,B=se+Cr*2,O=S!==""?S:null,oe=O!==null;return r.jsxs("div",{ref:x,role:"spinbutton",tabIndex:u?0:-1,"aria-label":i,"aria-valuetext":O??t,"aria-valuenow":d?void 0:Number(t),onFocus:p,onMouseDown:()=>p==null?void 0:p(),onKeyDown:U,onBlur:()=>{M(),E.current!==""&&Z(E.current,!1)},className:"relative shrink-0 rounded-lg outline-none",style:{width:l,height:B,boxShadow:u?"0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent)":"none"},children:[r.jsx("button",{type:"button","aria-label":"Valor anterior",className:D,style:{top:0,height:Cr,color:"var(--text-muted)",opacity:.35},onClick:()=>ne(-1),children:r.jsx(F.HiChevronUp,{className:"h-3.5 w-3.5"})}),r.jsx("div",{ref:w,className:"absolute inset-x-0 overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",style:{top:Cr,height:se,scrollSnapType:"y mandatory",scrollBehavior:"auto"},onScroll:j,onMouseUp:q,onTouchEnd:q,children:W.map((v,z)=>{const ee=v!==""&&v===y;return r.jsx("button",{type:"button",tabIndex:-1,disabled:!v,onClick:()=>{if(!v)return;const le=e.indexOf(v);le>=0&&V(le)},className:"flex w-full items-center justify-center tabular-nums leading-none disabled:cursor-default",style:{height:sr,scrollSnapAlign:"center",color:ee?"var(--text-main)":"var(--text-muted)",fontSize:ee?16:14,fontWeight:ee?600:400,opacity:v?oe?ee?0:.35:ee?1:.35:0},children:v},`wheel-${z}-${v}`)})}),O!==null?r.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:Cr+se/2-sr/2,height:sr,color:"var(--text-main)",fontSize:16,background:"var(--bg-card)"},children:O}):null,r.jsx("button",{type:"button","aria-label":"Valor siguiente",className:D,style:{bottom:0,height:Cr,color:"var(--text-muted)",opacity:.35},onClick:()=>ne(1),children:r.jsx(F.HiChevronDown,{className:"h-3.5 w-3.5"})})]})}function To(){return r.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:sr,width:14,opacity:.45},"aria-hidden":!0,children:":"})}function Lo({value:e,onChange:t,use12Hour:n,hour12:a,showSeconds:o=!1,title:l="Seleccionar hora",variant:i="panel",onCancel:c,onConfirm:d,className:u=""}){const p=i==="popover",f=p||!d,m=tu({use12Hour:n,hour12:a}),x=s.useRef(e),w=Fa(e,ut()),$=Sn(w),[h,E]=s.useState(Ye(m?$.hour12:w.hour24)),[T,g]=s.useState(Ye(w.minute)),[y,k]=s.useState(Ye(w.second)),[S,L]=s.useState($.meridiem),[C,W]=s.useState(0),_=s.useRef(0),V=s.useRef(!1),M=s.useRef({hour:null,minute:null,second:null,meridiem:null}),[Z,H]=s.useState("hour"),ne=s.useMemo(()=>{const ie=["hour","minute"];return o&&ie.push("second"),m&&ie.push("meridiem"),ie},[m,o]),U=s.useCallback(ie=>{H(pe=>{const Ce=ne.indexOf(pe);return ne[(Ce+ie+ne.length)%ne.length]})},[ne]);s.useEffect(()=>{var ie;(ie=M.current[Z])==null||ie.focus()},[Z]),s.useEffect(()=>{var ie;H("hour"),(ie=M.current.hour)==null||ie.focus()},[]),s.useEffect(()=>{if(e===x.current)return;x.current=e;const ie=Fa(e,ut()),pe=Sn(ie);E(Ye(m?pe.hour12:ie.hour24)),g(Ye(ie.minute)),k(Ye(ie.second)),L(pe.meridiem)},[m,e]);const q=s.useMemo(()=>(m?Pa(1,12):Pa(0,23)).map(ie=>Ye(ie)),[m]),j=s.useMemo(()=>Pa(0,59).map(ie=>Ye(ie)),[]),D=j,se=s.useMemo(()=>["AM","PM"],[]),B=s.useCallback(()=>m?qt({hour12:Number(h),minute:Number(T),second:Number(y),meridiem:S}):{hour24:Number(h),minute:Number(T),second:Number(y)},[h,m,S,T,y]),O=s.useCallback(ie=>{if(V.current)return;const pe=Wt(ie,o);x.current=pe,t(pe)},[t,o]),oe=s.useCallback(()=>{O(B())},[B,O]),v=ie=>{E(ie),f&&O(m?qt({hour12:Number(ie),minute:Number(T),second:Number(y),meridiem:S}):{hour24:Number(ie),minute:Number(T),second:Number(y)})},z=ie=>{g(ie),f&&O(m?qt({hour12:Number(h),minute:Number(ie),second:Number(y),meridiem:S}):{hour24:Number(h),minute:Number(ie),second:Number(y)})},ee=ie=>{k(ie),f&&O(m?qt({hour12:Number(h),minute:Number(T),second:Number(ie),meridiem:S}):{hour24:Number(h),minute:Number(T),second:Number(ie)})},le=ie=>{L(ie),f&&O(qt({hour12:Number(h),minute:Number(T),second:Number(y),meridiem:ie}))},R=s.useCallback(()=>(_.current+=1,W(_.current),_.current),[]),Q=s.useCallback(ie=>{const pe=Sn(ie),Ce=Wt(ie,o);x.current=Ce,E(Ye(m?pe.hour12:ie.hour24)),g(Ye(ie.minute)),k(Ye(ie.second)),L(pe.meridiem),t(Ce)},[m,t,o]),I=()=>{V.current=!0,R(),Q(ut()),queueMicrotask(()=>{const ie=ut();Wt(ie,o)!==x.current&&(R(),Q(ie)),V.current=!1})},J=()=>{oe(),d==null||d()},P=sr*za,ae=P+Cr*2,Y=Cr+P/2-sr/2,de=r.jsx("div",{className:"relative px-4 py-2",children:r.jsxs("div",{className:"relative mx-auto",style:{height:ae,maxWidth:"100%"},children:[r.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-10 rounded-xl",style:{top:Y,height:sr,background:"color-mix(in srgb, var(--primary) 10%, var(--bg-input))",border:"1px solid color-mix(in srgb, var(--primary) 22%, transparent)"}}),r.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-20",style:{top:Cr,height:sr*1.35,background:"linear-gradient(to bottom, var(--bg-card) 40%, transparent 100%)"}}),r.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-20",style:{bottom:Cr,height:sr*1.35,background:"linear-gradient(to top, var(--bg-card) 40%, transparent 100%)"}}),r.jsxs("div",{className:"relative z-30 flex h-full items-center justify-center gap-1",children:[r.jsx(Cn,{syncEpochRef:_,forceSyncAt:C,values:q,selected:h,onSelect:v,label:"Horas",maxNumeric:m?12:23,isFocused:Z==="hour",onFocus:()=>H("hour"),onAdvance:()=>U(1),onBack:()=>U(-1),setColumnRef:ie=>{M.current.hour=ie}}),r.jsx(To,{}),r.jsx(Cn,{syncEpochRef:_,forceSyncAt:C,values:j,selected:T,onSelect:z,label:"Minutos",maxNumeric:59,isFocused:Z==="minute",onFocus:()=>H("minute"),onAdvance:()=>U(1),onBack:()=>U(-1),setColumnRef:ie=>{M.current.minute=ie}}),o?r.jsxs(r.Fragment,{children:[r.jsx(To,{}),r.jsx(Cn,{syncEpochRef:_,forceSyncAt:C,values:D,selected:y,onSelect:ee,label:"Segundos",maxNumeric:59,isFocused:Z==="second",onFocus:()=>H("second"),onAdvance:()=>U(1),onBack:()=>U(-1),setColumnRef:ie=>{M.current.second=ie}})]}):null,m?r.jsx("div",{className:"ml-3 shrink-0 pl-1",children:r.jsx(Cn,{syncEpochRef:_,forceSyncAt:C,values:se,selected:S,onSelect:ie=>le(ie),width:ru,label:"AM o PM",isMeridiem:!0,isFocused:Z==="meridiem",onFocus:()=>H("meridiem"),onAdvance:()=>U(1),onBack:()=>U(-1),setColumnRef:ie=>{M.current.meridiem=ie}})}):null]})]})}),Se=r.jsxs("div",{className:`flex items-center ${p?"justify-center px-3 py-2":"justify-between gap-2 px-3 py-2.5"}`,style:{borderTop:p?"none":"1px solid color-mix(in srgb, var(--border) 80%, transparent)"},children:[r.jsx(je,{variant:"ghost",size:"sm",onClick:I,className:p?"text-xs":void 0,children:"Ahora"}),!p&&(c||d)?r.jsxs("div",{className:"flex items-center gap-2",children:[c?r.jsx(je,{variant:"ghost",size:"sm",onClick:c,children:"Cancelar"}):null,d?r.jsx(je,{variant:"primary",size:"sm",onClick:J,children:"Listo"}):null]}):null]});return r.jsxs("div",{className:`overflow-hidden ${u}`,style:{borderRadius:p?12:14,border:p?"1px solid color-mix(in srgb, var(--border) 85%, transparent)":"1px solid var(--border)",background:"var(--bg-card)",boxShadow:p?"0 12px 40px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06)":"0 1px 3px rgba(15, 23, 42, 0.06)",minWidth:m?o?300:260:o?252:212},children:[!p&&l?r.jsx("div",{className:"border-b px-3 py-2.5",style:{borderColor:"color-mix(in srgb, var(--border) 80%, transparent)"},children:r.jsx("h3",{className:"text-sm font-semibold",style:{color:"var(--text-main)"},children:l})}):null,de,Se]})}function nu(e){return e.use12Hour??e.hour12??!1}function au({label:e,value:t,onChange:n,use12Hour:a,hour12:o,showSeconds:l=!1,title:i="Seleccionar hora",placeholder:c="Seleccionar hora",disabled:d=!1,displayMode:u="popover",required:p,error:f,helperText:m,helperDisplay:x,className:w,contentClassName:$,className:h=""}){const E=u==="popover",[T,g]=s.useState(!1),y=s.useRef(null),[k,S]=s.useState({horizontal:"left",vertical:"bottom"}),L=nu({use12Hour:a,hour12:o}),C=s.useMemo(()=>t?Jd(t,{use12Hour:L,showSeconds:l}):"",[L,l,t]);s.useEffect(()=>{if(!E||!T||!y.current)return;const V=y.current.getBoundingClientRect(),M=8,Z=L?l?300:260:l?252:212,H=276,ne=V.left+Z>window.innerWidth-M,U=V.right-Z>=M,q=V.bottom+8+H>window.innerHeight-M,j=V.top-8-H>=M;S({horizontal:ne&&U?"right":"left",vertical:q&&j?"top":"bottom"})},[L,E,T,l]),s.useEffect(()=>{if(!E||!T)return;function V(Z){y.current&&(y.current.contains(Z.target)||g(!1))}function M(Z){Z.key==="Escape"&&g(!1)}return document.addEventListener("mousedown",V),document.addEventListener("keydown",M),()=>{document.removeEventListener("mousedown",V),document.removeEventListener("keydown",M)}},[E,T]);const W=r.jsxs("button",{type:"button",disabled:d,onClick:()=>{d||g(V=>!V)},className:`flex h-10 w-full items-center justify-between gap-2 rounded-lg border px-2.5 text-sm transition-all duration-150 focus:outline-none disabled:cursor-not-allowed disabled:opacity-60 ${h}`,style:{background:"var(--bg-input)",borderColor:f?"var(--danger)":T?"var(--primary)":"var(--border)",color:C?"var(--text-main)":"var(--text-muted)",boxShadow:T?"0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent)":"none"},children:[r.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2",children:[r.jsx(F.HiClock,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),r.jsx("span",{className:"truncate",children:C||c})]}),E?r.jsx(F.HiChevronDown,{className:`h-4 w-4 shrink-0 text-[var(--text-muted)] transition-transform duration-150 ${T?"rotate-180":""}`}):null]}),_=r.jsx(Lo,{variant:E?"popover":"panel",value:t||Rd(l),onChange:n,use12Hour:L,showSeconds:l,title:i,onClose:()=>g(!1)});return r.jsx(ka,{label:e,required:p,error:f,helperText:m,helperDisplay:x,className:w,contentClassName:$,children:E?r.jsxs("div",{ref:y,className:"relative w-full",children:[W,T?r.jsx("div",{className:"absolute z-50",style:{...k.horizontal==="left"?{left:0}:{right:0},...k.vertical==="bottom"?{top:"calc(100% + 6px)"}:{bottom:"calc(100% + 6px)"}},children:_}):null]}):r.jsxs("div",{className:"space-y-2",children:[W,T?_:null]})})}const su={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function ou({checked:e,disabled:t,onCheckedChange:n,size:a="sm",className:o="",...l}){const i=su[a],c=e?i.width-i.thumb-i.padding*2:0;return r.jsx("button",{...l,type:"button",role:"switch","aria-checked":e,disabled:t,onClick:()=>!t&&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:r.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 Ao=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),lu=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function iu(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 t=window.getComputedStyle(e);return!(![t.overflow,t.overflowX,t.overflowY].join(" ").match(/auto|scroll/)||e.clientWidth===0&&e.clientHeight===0)}function Do(e){return e.classList.contains("sidebar-scroll")||e.classList.contains("showcase-nav-scroll")}function Io(e){Do(e)&&e.querySelectorAll(".os-scrollbar-horizontal").forEach(t=>{t.style.display="none",t.style.height="0",t.style.pointerEvents="none"})}function cu(e){const t=e.querySelector(lu);return t instanceof HTMLElement?t:null}function Oo(){return s.useEffect(()=>{const e=new WeakMap;let t=0;const n=()=>{t=0,document.querySelectorAll(Ao).forEach(l=>{if(!(l instanceof HTMLElement))return;if(ta.OverlayScrollbars(l)){Io(l);return}if(!iu(l))return;const c={overflow:Do(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},d=cu(l),u=d?ta.OverlayScrollbars({target:l,elements:{viewport:d}},c):ta.OverlayScrollbars(l,c);Io(l),e.set(l,u)})},a=()=>{t||(t=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),()=>{t&&window.cancelAnimationFrame(t),o.disconnect(),window.removeEventListener("resize",a),document.querySelectorAll(Ao).forEach(l=>{var i;l instanceof HTMLElement&&((i=e.get(l))==null||i.destroy())})}},[]),null}function Ir(e){const t=e.trim();return!t||t==="/"||t==="/."?"":(t.startsWith("/")?t:`/${t}`).replace(/\/+$/,"")}function Ho(e){try{const t=new URL(e);return Ir(t.pathname)}catch{return""}}function du(e){const t=Ir(e);if(!t)return"";const n=t.match(/^\/apps\/[^/]+/i);if(n)return Ir(n[0]);const a=t.split("/").filter(Boolean);return a.length===0?"":a.length>=2&&a[0].toLowerCase()==="apps"?Ir(`/${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())?"":Ir(`/${a[0]}`)}const _a="primeSuiteAppUrl",uu={xs:{wh:"w-5 h-5",text:"text-[8px]"},sm:{wh:"w-7 h-7",text:"text-[11px]"},md:{wh:"w-9 h-9",text:"text-sm"},lg:{wh:"w-12 h-12",text:"text-base"},xl:{wh:"w-16 h-16",text:"text-xl"}},Bo={xs:20,sm:28,md:36,lg:48,xl:64},Fo=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],fu={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},bu="bonsaif.bot",mu="Bonsaif Bot",pu={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Po(e){return typeof e=="string"?e.trim():""}function hu(e){var o;if(e!==void 0)return Ir(e);const t=Ir(typeof process<"u"&&((o=process.env)==null?void 0:o.NEXT_PUBLIC_BASE_PATH)||"");if(t)return t;if(typeof window>"u")return"";try{const i=new URLSearchParams(window.location.search).get(_a)||"";i&&window.sessionStorage.setItem(_a,i);const c=window.sessionStorage.getItem(_a)||"",d=i||c;if(d){const u=Ho(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")?Ho(a):Ir(a);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return du(window.location.pathname)}function gu(e){const t=e.split(/\s+/).map(n=>n.trim()).filter(Boolean);return t.length===0?"?":t.length===1?t[0].slice(0,1).toUpperCase():`${t[0].slice(0,1)}${t[1].slice(0,1)}`.toUpperCase()}function vu(e){let t=0;for(const n of e)t=t*31+n.charCodeAt(0)&65535;return Fo[t%Fo.length]}function yu(e,t){return e===bu||t===mu}function xu(e,t){return`${e.replace(/\/$/,"")}${t}`}function zo({userId:e,username:t,name:n,size:a="md",showName:o=!1,showTooltip:l,tooltipContent:i,fallbackLabel:c="Usuario",basePath:d,wrapperClassName:u="",labelClassName:p="",labelSize:f="xs",avatarVersion:m=0,className:x="",style:w}){const[$,h]=s.useState(!1),E=typeof e=="string"&&e.trim()&&e!=="undefined"&&e!=="null"?e.trim():"";s.useEffect(()=>{h(!1)},[E,m]);const{wh:T,text:g}=uu[a],y=Po(n)||Po(t)||c,k=gu(y),S=hu(d),L=yu(t,n),C=xu(S,"/favicon.svg"),W=s.useMemo(()=>{if(!E)return"";const H=new URLSearchParams;H.set("size",String(Bo[a])),m&&H.set("v",String(m));const ne=H.toString();return`${S}/api/user/avatar/${encodeURIComponent(E)}${ne?`?${ne}`:""}`},[m,S,E,a]),_=Bo[a],V=L?r.jsx("span",{className:`${T} ${pu[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 ${x}`,style:w,children:r.jsx("img",{src:C,alt:y,width:_,height:_,className:"h-full w-full object-contain"})}):W&&!$?r.jsx("img",{src:W,alt:y,width:_,height:_,className:`${T} rounded-full object-cover flex-shrink-0 ${x}`,style:w,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>h(!0)},`${E}-${m}`):r.jsx("span",{className:`${T} ${vu(y)} ${g} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${x}`,style:w,title:y,children:k});if(o)return r.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${u}`,children:[V,r.jsx("span",{className:`min-w-0 truncate ${fu[f]} font-medium text-[var(--text-main)] ${p}`,title:y,children:y})]});const M=l??!0,Z=i??y;return M&&Z?r.jsx(zr,{as:"span",content:Z,className:`inline-flex flex-shrink-0 ${u}`,children:V}):V}function wu({href:e,className:t,children:n}){return r.jsx("a",{href:e,className:t,children:n})}function ku(e){return e.reduce((t,n)=>{const a=n.section??"Principal";return t[a]=[...t[a]??[],n],t},{})}function _o({children:e,navItems:t=[],currentPath:n=typeof window>"u"?"/":window.location.pathname,user:a,appName:o="Bonsaif",appLogo:l,header:i,footer:c,onLogout:d,LinkComponent:u=wu}){const[p,f]=s.useState(!1),m=ku(t);return r.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[r.jsx(Oo,{}),r.jsx("button",{type:"button","aria-label":"Abrir navegación",className:"fixed left-3 top-3 z-50 inline-flex h-9 w-9 items-center justify-center rounded-md border border-white/10 bg-black/70 text-white lg:hidden",onClick:()=>f(!0),children:r.jsx(F.HiBars3,{className:"h-5 w-5"})}),p&&r.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>f(!1)}),r.jsxs("aside",{className:`fixed inset-y-0 left-0 z-50 flex w-72 flex-col bg-[#071716] text-white shadow-2xl transition-transform duration-200 lg:translate-x-0 ${p?"translate-x-0":"-translate-x-full"}`,children:[r.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[r.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:l??r.jsx(F.HiHome,{className:"h-5 w-5"})}),r.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:o}),r.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-white/70 hover:bg-white/10 lg:hidden",onClick:()=>f(!1),children:r.jsx(F.HiXMark,{className:"h-5 w-5"})})]}),r.jsx("nav",{className:"sidebar-scroll min-h-0 flex-1 overflow-y-auto px-3 py-4","data-overlay-scroll":"true",children:r.jsx("div",{className:"sidebar-scroll-body",children:Object.entries(m).map(([x,w])=>r.jsxs("div",{className:"mb-5",children:[r.jsxs("div",{className:"mb-2 flex items-center gap-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-white/35",children:[r.jsx(F.HiChevronDown,{className:"h-3.5 w-3.5"}),x]}),r.jsx("div",{className:"space-y-1",children:w.map($=>{const h=n===$.href||n.startsWith(`${$.href}/`);return r.jsxs(u,{href:$.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${h?"bg-white/10 text-white":"text-white/55 hover:bg-white/[0.06] hover:text-white/85"}`,children:[r.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:$.icon??r.jsx(F.HiHome,{className:"h-4 w-4"})}),r.jsx("span",{className:"truncate",children:$.label})]},$.href)})})]},x))})}),r.jsxs("div",{className:"border-t border-white/10 p-3",children:[a&&r.jsxs("div",{className:"mb-3 flex min-w-0 items-center gap-3 rounded-lg bg-white/[0.04] p-2",children:[r.jsx(zo,{name:a.initials??a.name??a.email??"Usuario",size:"md"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"truncate text-sm font-medium text-white",children:a.name??"Usuario"}),a.email&&r.jsx("div",{className:"truncate text-xs text-white/45",children:a.email})]})]}),d&&r.jsxs(je,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:d,children:[r.jsx(F.HiArrowRightOnRectangle,{className:"h-4 w-4"})," Salir"]}),c]})]}),r.jsxs("div",{className:"min-h-screen lg:pl-72",children:[i,r.jsx("main",{className:"min-h-screen",children:e})]})]})}const jo="bonsaif-ui:prime-auth-sso",Nu={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"},ja={dashboard:r.jsx(F.HiChartBar,{className:"h-5 w-5"}),tickets:r.jsx(F.HiTicket,{className:"h-5 w-5"}),teams:r.jsx(F.HiUsers,{className:"h-5 w-5"}),projects:r.jsx(F.HiRectangleGroup,{className:"h-5 w-5"}),clients:r.jsx(F.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:r.jsx(F.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:r.jsx(F.HiUser,{className:"h-5 w-5"}),settings:r.jsx(F.HiCog6Tooth,{className:"h-5 w-5"}),notifications:r.jsx(F.HiBell,{className:"h-5 w-5"}),changelog:r.jsx(F.HiDocumentText,{className:"h-5 w-5"}),admin:r.jsx(F.HiShieldCheck,{className:"h-5 w-5"}),users:r.jsx(F.HiUsers,{className:"h-5 w-5"}),roles:r.jsx(F.HiShieldCheck,{className:"h-5 w-5"}),menus:r.jsx(F.HiCog6Tooth,{className:"h-5 w-5"}),guards:r.jsx(F.HiCalendarDays,{className:"h-5 w-5"}),vacations:r.jsx(F.HiCalendarDays,{className:"h-5 w-5"}),audit:r.jsx(F.HiListBullet,{className:"h-5 w-5"}),positions:r.jsx(F.HiBriefcase,{className:"h-5 w-5"}),ranks:r.jsx(F.HiListBullet,{className:"h-5 w-5"}),"email-inbox":r.jsx(F.HiInbox,{className:"h-5 w-5"}),"security-incidents":r.jsx(F.HiShieldCheck,{className:"h-5 w-5"})};function Su(e){return e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Cu(e){return/^\d+$/.test(e)||/^[a-f0-9]{8,}$/i.test(e)}function Eu(e){const t=e.split("/").filter(Boolean);if(t.length===0||t.length===1&&t[0]==="dashboard")return[];const n=decodeURIComponent(t[t.length-1]),a=t.length>1?decodeURIComponent(t[t.length-2]):void 0,o=Cu(n)&&a?a:n,l=Nu[o]??Su(o);return[{label:"Inicio",href:"/"},{label:l}]}function Wa(e){return(e==null?void 0:e.querySelector(":scope > .os-viewport"))??(e==null?void 0:e.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function Mu(e){const t=e.split("/").filter(Boolean),n=t[t.length-1];if(!n)return r.jsx(F.HiHome,{className:"h-5 w-5"});if(ja[n])return ja[n];const a=t.length>1?t[t.length-2]:"";return ja[a]??r.jsx(F.HiHome,{className:"h-5 w-5"})}function $u(e){return e.includes("primeAuthOrigin")||e.includes("primeAuthProjectKey")}function Wo(){if(typeof window>"u")return!1;if($u(window.location.href)){try{window.sessionStorage.setItem(jo,"true")}catch{}return!0}try{return window.sessionStorage.getItem(jo)==="true"}catch{return!1}}function Tu({title:e,subtitle:t,action:n,meta:a,icon:o,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:d,showBreadcrumbs:u=!0,contained:p=!1}){const f=s.useRef(null),[m,x]=s.useState(!1),[w,$]=s.useState(d??"/"),[h,E]=s.useState(()=>Wo()),[T,g]=s.useState(null),y=d??w,k=c??Eu(y),S=o??Mu(y),L=u&&!h&&k.length>1,C=!L;s.useEffect(()=>{d||$(window.location.pathname)},[d]),s.useEffect(()=>{E(Wo())},[]),s.useEffect(()=>{if(p){x(!1);return}let _=null,V=0,M=0;const Z=()=>{const U=f.current,q=document.querySelector("[data-app-scroll='true']");return(U==null?void 0:U.closest(".os-viewport"))??(U==null?void 0:U.closest("[data-overlayscrollbars-viewport]"))??Wa(q)??q??window},H=()=>{const U=_&&_!==window?_.scrollTop:window.scrollY;x(q=>q?U>24:U>72)},ne=()=>{_==null||_.removeEventListener("scroll",H),_=Z(),_.addEventListener("scroll",H,{passive:!0}),H()};return ne(),V=window.requestAnimationFrame(ne),M=window.setTimeout(ne,120),()=>{window.cancelAnimationFrame(V),window.clearTimeout(M),_==null||_.removeEventListener("scroll",H)}},[p]),s.useEffect(()=>{if(p){g(null);return}let _=0;const V=[],M=()=>{const D=f.current,se=D==null?void 0:D.parentElement,B=document.querySelector("[data-app-scroll='true']"),O=Wa(B)??B;if(!D||!se||!O){g(null);return}const oe=se.getBoundingClientRect(),v=window.getComputedStyle(se),z=O.getBoundingClientRect(),ee=O instanceof HTMLElement&&O.clientWidth>0?O.clientWidth:z.width,le=oe.left+parseFloat(v.paddingLeft||"0"),R={marginLeft:Math.round(z.left-le),width:Math.round(ee)};g(Q=>Q&&Q.marginLeft===R.marginLeft&&Q.width===R.width?Q:R)},Z=()=>{window.cancelAnimationFrame(_),_=window.requestAnimationFrame(M)};Z(),window.addEventListener("resize",Z);const H=new ResizeObserver(Z),ne=f.current,U=ne==null?void 0:ne.parentElement,q=document.querySelector("[data-app-scroll='true']"),j=Wa(q)??q;return[U,q,j].forEach(D=>{D&&H.observe(D)}),V.push(window.setTimeout(Z,120)),V.push(window.setTimeout(Z,280)),()=>{window.cancelAnimationFrame(_),window.removeEventListener("resize",Z),H.disconnect(),V.forEach(D=>window.clearTimeout(D))}},[p]);const W={...T?{marginLeft:T.marginLeft,width:T.width}:null,"--page-header-control-height":m?"34px":"40px","--page-header-control-padding-x":m?"10px":"14px","--page-header-control-icon-left":m?"10px":"12px",background:p?"var(--bg-card)":m?"color-mix(in srgb, var(--bg-main) 82%, transparent)":"color-mix(in srgb, var(--bg-main) 58%, transparent)",backdropFilter:"saturate(1.25) blur(18px)",WebkitBackdropFilter:"saturate(1.25) blur(18px)",borderBottom:p||m?"1px solid var(--border)":"1px solid transparent",boxShadow:m?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return r.jsx("div",{ref:f,"data-page-header":"true","data-compact":m?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${p?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${l}`,style:W,children:r.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${m?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":C?"min-h-9 gap-2 px-4 py-0 sm:min-h-10 sm:gap-2.5":"min-h-10 gap-2.5 px-4 pt-0.5 sm:min-h-11 sm:gap-3"} ${i}`,children:[r.jsx("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${m||C?"gap-1":"gap-1.5 sm:gap-2"}`,children:r.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${m||C?"gap-2":"gap-2.5 sm:gap-3"}`,children:[r.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${m?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:L?"var(--text-secondary)":"var(--text-muted)"},children:S}),r.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${m?"gap-x-2 gap-y-1":"gap-x-3 gap-y-2"}`,children:[r.jsxs("div",{className:"min-w-0 flex-shrink transition-[transform] duration-300 ease-out",children:[r.jsx("h1",{className:`truncate font-bold tracking-tight transition-[font-size,line-height,color] duration-300 ease-out ${m?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:e}),t&&r.jsx("div",{"aria-hidden":m,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${m?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-8 translate-y-0 opacity-100"}`,style:{color:"var(--text-muted)"},children:t})]}),a&&r.jsx("div",{className:`page-header-meta flex min-w-0 flex-1 basis-full items-center overflow-visible transition-[gap,opacity,transform] duration-300 ease-out sm:basis-auto ${m?"translate-y-0 gap-1.5 opacity-95":"gap-2 opacity-100"}`,children:a})]})]})}),n&&r.jsx("div",{className:`page-header-actions ml-auto flex max-w-full flex-shrink-0 flex-wrap items-center justify-end self-center overflow-visible transition-[gap,min-height,opacity,transform] duration-300 ease-out ${m?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:r.jsx(fs.Provider,{value:{compact:!0,headerAction:!0},children:n})})]})})}function Lu({children:e,currentPath:t=typeof window>"u"?"/":window.location.pathname,publicRoutes:n=["/","/login","/reset-password"],...a}){return n.includes(t)?r.jsx(r.Fragment,{children:e}):r.jsx(_o,{currentPath:t,...a,children:e})}function qo(){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 Au(e,t,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",t),n&&(l.searchParams.set("primeAuthOrigin",window.location.origin),l.searchParams.set("primeAuthProjectKey",n)),a.searchParams.set("callbackUrl",`${l.pathname}${l.search}${l.hash}`),a.toString()}return a.searchParams.set("theme",t),n&&(a.searchParams.set("primeAuthOrigin",window.location.origin),a.searchParams.set("primeAuthProjectKey",n)),a.toString()}catch{return e}}function Du({name:e,src:t,projectKey:n}){const[a,o]=s.useState("system"),l=s.useRef(null);s.useEffect(()=>{o(qo());const d=new MutationObserver(()=>o(qo()));return d.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>d.disconnect()},[]);const i=s.useMemo(()=>Au(t,a,n),[n,t,a]),c=s.useMemo(()=>{try{return new URL(i).origin}catch{return""}},[i]);return s.useEffect(()=>{if(!n)return;const d=n;function u(p){var x,w,$;if(p.source!==((x=l.current)==null?void 0:x.contentWindow)||c&&p.origin!==c)return;if(((w=p.data)==null?void 0:w.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!p.data.active}}));return}if((($=p.data)==null?void 0:$.type)!=="prime-microservice:navigation")return;const f=p.data.path;if(!f||!f.startsWith("/")||f.startsWith("//"))return;const m=`/apps/${encodeURIComponent(d)}${f}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==m&&(window.history.replaceState(window.history.state,"",m),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",u),()=>{window.removeEventListener("message",u),window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!1}}))}},[c,n]),r.jsx("div",{className:"flex h-full min-h-screen flex-col bg-[var(--bg-main)]",children:r.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 Iu(){const[e,t]=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)&&t(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:Uo(c.data.width,96,720),height:Uo(c.data.height,96,560)})};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[]),e?r.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 Uo(e,t,n){const a=typeof e=="number"&&Number.isFinite(e)?e:t;return Math.max(t,Math.min(n,Math.ceil(a)))}function Ou(e){const t=document.documentElement,n=new MutationObserver(e);n.observe(t,{attributes:!0,attributeFilter:["class"]});const a=window.matchMedia("(prefers-color-scheme: dark)");return a.addEventListener("change",e),()=>{n.disconnect(),a.removeEventListener("change",e)}}function Hu(){const e=localStorage.getItem("theme")||"system",t=window.matchMedia("(prefers-color-scheme: dark)").matches;return document.documentElement.classList.contains("dark")||e==="dark"||e==="system"&&t?"dark":"light"}function Bu(){return"light"}function Fu({position:e="bottom-center"}){const t=s.useSyncExternalStore(Ou,Hu,Bu);return r.jsx(cs.Toaster,{position:e,theme:t,richColors:!0,closeButton:!0})}function Pu({title:e,subtitle:t,actions:n,loading:a=!1,empty:o=!1,emptyText:l="Sin datos para mostrar",className:i="",children:c}){return r.jsxs("div",{className:`bonsaif-chart-card w-full overflow-visible ${i}`,children:[(e||t||n)&&r.jsxs("div",{className:"bonsaif-chart-card-head",children:[r.jsx("div",{className:"bonsaif-chart-card-accent","aria-hidden":!0}),r.jsxs("div",{className:"bonsaif-chart-card-copy min-w-0",children:[e?r.jsx("div",{className:"bonsaif-chart-card-title",children:e}):null,t?r.jsx("div",{className:"bonsaif-chart-card-subtitle",children:t}):null]}),n?r.jsx("div",{className:"bonsaif-chart-card-actions shrink-0",children:n}):null]}),r.jsx("div",{className:"bonsaif-chart-card-body",children:a?r.jsx("div",{className:"flex h-48 items-center justify-center",children:r.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?r.jsx("div",{className:"flex h-48 items-center justify-center text-sm",style:{color:"var(--text-muted)"},children:l}):c})]})}const En=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function Vo(e,t){return e.color??En[t%En.length]}function yr(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 ur=e=>{if(!Number.isFinite(e))return"—";const t=Math.abs(e);return t>=1e9?`${(e/1e9).toFixed(1).replace(/\.0$/,"")}B`:t>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,"")}M`:t>=1e4?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}k`:e.toLocaleString(void 0,{maximumFractionDigits:2})};function Ut(e){if(e==null||e==="")return null;const t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:null}const qa={warning:70,danger:90};function Mn(e,t=qa){const n=t.warning??qa.warning,a=t.danger??qa.danger;return e>=a?"danger":e>=n?"warning":e<=0?"primary":"success"}function Vt(e,t){return yr(Mn(e,t))}function ft(e,t=0){return Number.isFinite(e)?`${e.toFixed(t)}%`:"—"}function bt(e,t=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(t);return`${n}${c.replace(/\.0$/,"")} ${o[i]}`}function Yo(e,t="bytes",n=1){if(!Number.isFinite(e))return"—";const a=e<0?"-":"",o=Math.abs(e),l=t==="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 mt(e,t){var n;for(let a=e.length-1;a>=0;a-=1){const o=Ut((n=e[a])==null?void 0:n[t]);if(o!==null)return o}return null}function fr({height:e}){return r.jsx("div",{className:"flex items-center justify-center",style:{height:e},"aria-busy":!0,children:r.jsx("div",{className:"h-7 w-7 animate-spin rounded-full border-2",style:{borderColor:"var(--border)",borderTopColor:"var(--primary)"}})})}function br({height:e,text:t}){return r.jsx("div",{className:"flex items-center justify-center text-sm",style:{height:e,color:"var(--text-muted)"},children:t})}const Wr=680,qr="ease-out",zu={top:18,right:8,bottom:12,left:0};function Yt(e){return{...zu,...e}}function Kt(e){return e.map((t,n)=>({...t,color:Vo(t,n),label:t.label??t.key}))}function $n(e,t){return!e.length||!t.length||e.every(n=>t.every(a=>Ut(n[a.key])===null))}function or(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function Xt(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function Ko(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function Tn(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function _u(e,t=ur){if(e==null||e==="")return"—";const n=typeof e=="number"?e:Number(e);return Number.isFinite(n)?t(n):String(e)}function Xo(e){return`bonsaif-grad-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function ju({active:e,label:t,payload:n,valueFormat:a=ur}){var c,d,u,p,f,m;if(!e||!(n!=null&&n.length))return null;const o=n.filter(x=>x.dataKey!=="base"&&x.name!=="base"&&x.value!==null&&x.value!==void 0);if(!o.length)return null;const l=((d=(c=o[0])==null?void 0:c.payload)==null?void 0:d.fullName)??((p=(u=o[0])==null?void 0:u.payload)==null?void 0:p.tooltipLabel)??((m=(f=o[0])==null?void 0:f.payload)==null?void 0:m.display),i=typeof l=="string"&&l.length>0?l:t;return r.jsxs("div",{className:"bonsaif-chart-tooltip-panel",children:[i!=null&&i!==""?r.jsx("div",{className:"bonsaif-chart-tooltip-label",children:String(i)}):null,r.jsx("div",{className:"bonsaif-chart-tooltip-items",children:o.map((x,w)=>{const $=x.payload,h=$&&typeof $.display=="number"?$.display:x.value;return r.jsxs("div",{className:"bonsaif-chart-tooltip-row",children:[r.jsxs("span",{className:"bonsaif-chart-tooltip-name",children:[r.jsx("span",{className:"bonsaif-chart-tooltip-swatch",style:{background:x.color??"var(--primary)"}}),x.name??x.dataKey]}),r.jsx("span",{className:"bonsaif-chart-tooltip-value",children:_u(h,a)})]},String(x.dataKey??x.name??w))})})]})}function pt({valueFormat:e,content:t,cursor:n,offset:a=12,wrapperStyle:o,allowEscapeViewBox:l,reverseDirection:i,...c}){return r.jsx(Ne.Tooltip,{...c,cursor:n,offset:a,allowEscapeViewBox:l??{x:!1,y:!1},reverseDirection:i??{x:!1,y:!1},wrapperStyle:{outline:"none",zIndex:60,pointerEvents:"none",overflow:"visible",...o},content:t??r.jsx(ju,{valueFormat:e})})}function Go(e,t,n){return n==null?-1:e.findIndex(a=>String(a[t])===String(n))}function Zo(e,t,n){if(n<=1)return null;const a=Math.max(0,Math.min(e,t)),o=Math.min(n-1,Math.max(e,t));return o-a<1||a===0&&o>=n-1?null:{startIndex:a,endIndex:o}}function Ln(e,t,n={}){const{zoomable:a=!1,zoomMode:o="both",brushHeight:l=28,onZoomChange:i}=n,[c,d]=s.useState(null),[u,p]=s.useState(null),f=!!a&&e.length>1,m=f&&(o==="brush"||o==="both"),x=f&&(o==="drag"||o==="both"),w=s.useCallback(V=>{d(V),i==null||i(V)},[i]),$=s.useCallback(()=>{p(null),w(null)},[w]),h=!!c,E=s.useMemo(()=>!c||m?e:e.slice(c.startIndex,c.endIndex+1),[e,m,c]),T=s.useCallback((V,M)=>{const Z=Go(e,t,V),H=Go(e,t,M);Z<0||H<0||w(Zo(Z,H,e.length))},[w,e,t]),g=s.useCallback(V=>{x&&((V==null?void 0:V.activeLabel)===void 0||(V==null?void 0:V.activeLabel)===null||p({leftLabel:V.activeLabel,rightLabel:V.activeLabel}))},[x]),y=s.useCallback(V=>{!x||!u||(V==null?void 0:V.activeLabel)===void 0||(V==null?void 0:V.activeLabel)===null||p(M=>M&&{...M,rightLabel:V.activeLabel})},[u,x]),k=s.useCallback(()=>{if(x){if(!u||u.rightLabel===null||u.rightLabel===void 0){p(null);return}T(u.leftLabel,u.rightLabel),p(null)}},[T,u,x]),S=s.useCallback(V=>{if(m){if(!V){w(null);return}w(Zo(V.startIndex??0,V.endIndex??e.length-1,e.length))}},[w,e.length,m]),L=x?{onMouseDown:g,onMouseMove:y,onMouseUp:k,onMouseLeave:()=>{u&&k()}}:{},C=c??{startIndex:0,endIndex:Math.max(0,e.length-1)},W=r.jsxs(r.Fragment,{children:[x&&u&&u.rightLabel!==null&&u.rightLabel!==void 0?r.jsx(Ne.ReferenceArea,{x1:u.leftLabel,x2:u.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,m?r.jsx(Ne.Brush,{dataKey:t,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:C.startIndex,endIndex:C.endIndex,onChange:S,tickFormatter:V=>String(V)}):null]}),_=m?{bottom:Math.max(l+10,36)}:void 0;return{enabled:f,showBrush:m,showDrag:x,viewData:E,isZoomed:h,resetZoom:$,chartHandlers:L,zoomNodes:W,marginExtra:_}}function An({visible:e,onReset:t}){return e?r.jsx("button",{type:"button",className:"bonsaif-chart-zoom-reset",onClick:t,"aria-label":"Restablecer zoom",children:"Restablecer zoom"}):null}function Wu({data:e,xKey:t,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:p,valueFormat:f=ur,yDomain:m,ariaLabel:x="Gráfico de líneas",curve:w=!0,strokeWidth:$=2.25,zoomable:h=!1,zoomMode:E="both",brushHeight:T,onZoomChange:g}){const y=$n(e,n),k=Kt(n),S=Ln(e,t,{zoomable:h,zoomMode:E,brushHeight:T,onZoomChange:g}),L=Yt({...p,...S.marginExtra});return l?r.jsx(fr,{height:a}):y?r.jsx(br,{height:a,text:i}):r.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${o}`,role:"img","aria-label":x,style:{height:a},children:[r.jsx(An,{visible:S.isZoomed,onReset:S.resetZoom}),r.jsx(Ne.ResponsiveContainer,{width:"100%",height:"100%",children:r.jsxs(Ne.LineChart,{data:S.viewData,margin:L,...S.chartHandlers,children:[c?r.jsx(Ne.CartesianGrid,{strokeDasharray:"2 8",stroke:Xt(),vertical:!1}):null,r.jsx(Ne.XAxis,{dataKey:t,tick:or(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),r.jsx(Ne.YAxis,{tick:or(),tickLine:!1,axisLine:!1,width:44,domain:m??["auto","auto"],tickFormatter:C=>f(Number(C)),dx:-2}),u?r.jsx(pt,{valueFormat:f,cursor:{stroke:Ko(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?r.jsx(Ne.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Tn()}):null,k.map((C,W)=>r.jsx(Ne.Line,{type:w?"monotone":"linear",dataKey:C.key,name:C.label,stroke:C.color,strokeWidth:W===0?$+.35:$,strokeOpacity:W===0?1:.88,isAnimationActive:!0,animationDuration:Wr,animationEasing:qr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:C.color}},C.key)),S.zoomNodes]})})]})}function Dn({data:e,xKey:t,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:p,valueFormat:f=ur,yDomain:m,ariaLabel:x="Gráfico de área",stacked:w=!1,opacity:$=.22,zoomable:h=!1,zoomMode:E="both",brushHeight:T,onZoomChange:g}){const y=$n(e,n),k=Kt(n),S=Ln(e,t,{zoomable:h,zoomMode:E,brushHeight:T,onZoomChange:g}),L=Yt({...p,...S.marginExtra});return l?r.jsx(fr,{height:a}):y?r.jsx(br,{height:a,text:i}):r.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${o}`,role:"img","aria-label":x,style:{height:a},children:[r.jsx(An,{visible:S.isZoomed,onReset:S.resetZoom}),r.jsx(Ne.ResponsiveContainer,{width:"100%",height:"100%",children:r.jsxs(Ne.AreaChart,{data:S.viewData,margin:L,...S.chartHandlers,children:[r.jsx("defs",{children:k.map(C=>r.jsxs("linearGradient",{id:Xo(C.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[r.jsx("stop",{offset:"0%",stopColor:C.color,stopOpacity:Math.min(.55,$+.28)}),r.jsx("stop",{offset:"48%",stopColor:C.color,stopOpacity:$*.5}),r.jsx("stop",{offset:"100%",stopColor:C.color,stopOpacity:0})]},C.key))}),c?r.jsx(Ne.CartesianGrid,{strokeDasharray:"2 8",stroke:Xt(),vertical:!1}):null,r.jsx(Ne.XAxis,{dataKey:t,tick:or(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),r.jsx(Ne.YAxis,{tick:or(),tickLine:!1,axisLine:!1,width:44,domain:m??["auto","auto"],tickFormatter:C=>f(Number(C)),dx:-2}),u?r.jsx(pt,{valueFormat:f,cursor:{stroke:Ko(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?r.jsx(Ne.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Tn()}):null,k.map(C=>r.jsx(Ne.Area,{type:"monotone",dataKey:C.key,name:C.label,stroke:C.color,fill:`url(#${Xo(C.key)})`,strokeWidth:2.25,stackId:w?"stack":void 0,isAnimationActive:!0,animationDuration:Wr,animationEasing:qr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:C.color}},C.key)),S.zoomNodes]})})]})}function qu({data:e,xKey:t,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:p,valueFormat:f=ur,yDomain:m,ariaLabel:x="Gráfico de barras",layout:w="vertical",mode:$="grouped",barRadius:h=6,categoryAxisWidth:E=64,zoomable:T=!1,zoomMode:g="both",brushHeight:y,onZoomChange:k}){const S=$n(e,n),L=Kt(n),C=w==="horizontal",W=Ln(e,t,{zoomable:T&&!C,zoomMode:g,brushHeight:y,onZoomChange:k}),_=Yt({...p,...W.marginExtra});return l?r.jsx(fr,{height:a}):S?r.jsx(br,{height:a,text:i}):r.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${o}`,role:"img","aria-label":x,style:{height:a},children:[r.jsx(An,{visible:W.isZoomed,onReset:W.resetZoom}),r.jsx(Ne.ResponsiveContainer,{width:"100%",height:"100%",children:r.jsxs(Ne.BarChart,{data:W.viewData,margin:_,layout:C?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,...W.chartHandlers,children:[c?r.jsx(Ne.CartesianGrid,{strokeDasharray:"2 8",stroke:Xt(),horizontal:!C,vertical:C}):null,C?r.jsxs(r.Fragment,{children:[r.jsx(Ne.XAxis,{type:"number",tick:or(),tickLine:!1,axisLine:!1,tickFormatter:V=>f(Number(V)),domain:m??["auto","auto"]}),r.jsx(Ne.YAxis,{type:"category",dataKey:t,tick:or(),tickLine:!1,axisLine:!1,width:E})]}):r.jsxs(r.Fragment,{children:[r.jsx(Ne.XAxis,{dataKey:t,tick:or(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),r.jsx(Ne.YAxis,{tick:or(),tickLine:!1,axisLine:!1,width:44,domain:m??["auto","auto"],tickFormatter:V=>f(Number(V)),dx:-2})]}),u?r.jsx(pt,{valueFormat:f,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,d?r.jsx(Ne.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Tn()}):null,L.map((V,M)=>r.jsx(Ne.Bar,{dataKey:V.key,name:V.label,fill:V.color,fillOpacity:M===0?1:.82,radius:C?[0,h,h,0]:[h,h,2,2],maxBarSize:20,stackId:$==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:Wr,animationEasing:qr},V.key)),W.zoomNodes]})})]})}function Uu(e){return r.jsx(Jo,{...e,variant:"pie"})}function Vu(e){return r.jsx(Jo,{...e,variant:"donut",innerRadius:e.innerRadius??.62,cornerRadius:e.cornerRadius??10,padAngle:e.padAngle??2})}function Qo(e,t){return e==null||!Number.isFinite(e)?t:e>0&&e<=1?e*100:e}function Jo({data:e,nameKey:t,valueKey:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showLegend:c=!0,showTooltip:d=!0,valueFormat:u=ur,ariaLabel:p,innerRadius:f,outerRadius:m,colors:x=[...En],padAngle:w,cornerRadius:$,variant:h}){const E=e.map((M,Z)=>({name:String(M[t]??""),value:Ut(M[n])??0,fill:x[Z%x.length],row:M})).filter(M=>M.value>0),T=!E.length,g=h==="donut",y=E.length,k=Qo(f,g?62:12),S=Qo(m,78),L=Math.min(w??(g?2:3),Math.max(.5,10/Math.max(1,y))),C=Math.min($??(g?10:8),Math.max(2,36/Math.max(1,y)));if(l)return r.jsx(fr,{height:a});if(T)return r.jsx(br,{height:a,text:i});const W=E.reduce((M,Z)=>M+Z.value,0),_=c?Math.min(96,28+Math.ceil(y/3)*22):0,V=Math.max(140,a-_);return r.jsx("div",{className:`bonsaif-chart bonsaif-${h}-chart w-full ${o}`,role:"img","aria-label":p??(h==="donut"?"Donut chart":"Pie chart"),style:{height:a},children:r.jsxs("div",{className:"bonsaif-pie-layout",children:[r.jsx("div",{className:"bonsaif-pie-plot",style:{height:V},children:r.jsx(Ne.ResponsiveContainer,{width:"100%",height:"100%",children:r.jsxs(Ne.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[d?r.jsx(pt,{valueFormat:u,isAnimationActive:!1}):null,r.jsx(Ne.Pie,{data:E,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${k}%`,outerRadius:`${S}%`,startAngle:90,endAngle:-270,paddingAngle:L,cornerRadius:C,minAngle:y>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:Wr,animationEasing:qr,label:!1,activeShape:Yu,children:E.map(M=>r.jsx(Ne.Cell,{fill:M.fill},M.name))}),g?r.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:u(W)}):null]})})}),c?r.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:E.map(M=>r.jsxs("li",{className:"bonsaif-pie-legend-item",children:[r.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:M.fill},"aria-hidden":!0}),r.jsx("span",{className:"bonsaif-pie-legend-label",title:M.name,children:M.name}),r.jsx("span",{className:"bonsaif-pie-legend-value",children:u(M.value)})]},M.name))}):null]})})}function Yu(e){const{outerRadius:t=0,...n}=e;return r.jsx(Ne.Sector,{...n,outerRadius:Number(t)+4,stroke:"var(--bg-card)",strokeWidth:2})}function Ku({data:e,dataKey:t,width:n="100%",height:a=36,tone:o="primary",color:l,fill:i=!0,className:c="",ariaLabel:d="Sparkline"}){const u=l??yr(o),p=e.map(S=>Ut(S[t])).filter(S=>S!==null);if(p.length<2)return r.jsx("div",{className:c,style:{width:n,height:a,color:"var(--text-muted)"},"aria-label":d});const f=120,m=36,x=3,w=1,$=Math.min(...p),E=Math.max(...p)-$||1,T=p.map((S,L)=>{const C=w+L/(p.length-1)*(f-w*2),W=m-x-(S-$)/E*(m-x*2);return{x:C,y:W}}),g=T.map((S,L)=>`${L===0?"M":"L"}${S.x.toFixed(2)} ${S.y.toFixed(2)}`).join(" "),y=`${g} L${T[T.length-1].x.toFixed(2)} ${m} L${T[0].x.toFixed(2)} ${m} Z`,k=`bonsaif-spark-${t.replace(/[^a-zA-Z0-9_-]/g,"")}-${o}`;return r.jsx("div",{className:`bonsaif-sparkline ${c}`,style:{width:n,height:a},role:"img","aria-label":d,children:r.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${f} ${m}`,preserveAspectRatio:"none",focusable:"false",children:[i?r.jsx("defs",{children:r.jsxs("linearGradient",{id:k,x1:"0",y1:"0",x2:"0",y2:"1",children:[r.jsx("stop",{offset:"0%",stopColor:u,stopOpacity:.38}),r.jsx("stop",{offset:"100%",stopColor:u,stopOpacity:0})]})}):null,i?r.jsx("path",{d:y,fill:`url(#${k})`}):null,r.jsx("path",{d:g,fill:"none",stroke:u,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function Xu({data:e,xKey:t,series:n,barSeries:a,lineSeries:o,height:l=280,className:i="",loading:c=!1,emptyText:d="Sin datos para mostrar",showGrid:u=!0,showLegend:p=!0,showTooltip:f=!0,margin:m,valueFormat:x=ur,yDomain:w,ariaLabel:$="Gráfico combinado",barRadius:h=6,zoomable:E=!1,zoomMode:T="both",brushHeight:g,onZoomChange:y}){const k=a??n.slice(0,Math.max(1,n.length-1)),S=o??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),L=[...k,...S.filter(H=>!k.some(ne=>ne.key===H.key))],C=$n(e,L),W=Kt(k),_=Kt(L),V=S.map(H=>{var U;const ne=_.find(q=>q.key===H.key);return{...H,label:H.label??H.key,color:H.color??(ne==null?void 0:ne.color)??((U=_[0])==null?void 0:U.color)}}),M=Ln(e,t,{zoomable:E,zoomMode:T,brushHeight:g,onZoomChange:y}),Z=Yt({...m,...M.marginExtra});return c?r.jsx(fr,{height:l}):C?r.jsx(br,{height:l,text:d}):r.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":$,style:{height:l},children:[r.jsx(An,{visible:M.isZoomed,onReset:M.resetZoom}),r.jsx(Ne.ResponsiveContainer,{width:"100%",height:"100%",children:r.jsxs(Ne.ComposedChart,{data:M.viewData,margin:Z,barCategoryGap:"34%",...M.chartHandlers,children:[u?r.jsx(Ne.CartesianGrid,{strokeDasharray:"2 8",stroke:Xt(),vertical:!1}):null,r.jsx(Ne.XAxis,{dataKey:t,tick:or(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),r.jsx(Ne.YAxis,{tick:or(),tickLine:!1,axisLine:!1,width:44,domain:w??["auto","auto"],tickFormatter:H=>x(Number(H)),dx:-2}),f?r.jsx(pt,{valueFormat:x,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,p?r.jsx(Ne.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Tn()}):null,W.map(H=>r.jsx(Ne.Bar,{dataKey:H.key,name:H.label,fill:H.color,fillOpacity:.88,radius:[h,h,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:Wr,animationEasing:qr},H.key)),V.map(H=>r.jsx(Ne.Line,{type:"monotone",dataKey:H.key,name:H.label,stroke:H.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:Wr,animationEasing:qr,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:H.color}},H.key)),M.zoomNodes]})})]})}function Gu({data:e,xKey:t,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:p,valueFormat:f=ur,ariaLabel:m="Gráfico waterfall",increaseColor:x="#34d399",decreaseColor:w="#f87171",totalColor:$="var(--primary)"}){const h=s.useMemo(()=>Zu(e,{xKey:t,valueKey:n,typeKey:a,increaseColor:x,decreaseColor:w,totalColor:$}),[e,t,n,a,x,w,$]),E=!h.length,T=Yt(p);return i?r.jsx(fr,{height:o}):E?r.jsx(br,{height:o,text:c}):r.jsx("div",{className:`bonsaif-chart bonsaif-waterfall-chart w-full ${l}`,role:"img","aria-label":m,style:{height:o},children:r.jsx(Ne.ResponsiveContainer,{width:"100%",height:"100%",children:r.jsxs(Ne.BarChart,{data:h,margin:T,barCategoryGap:"42%",children:[d?r.jsx(Ne.CartesianGrid,{strokeDasharray:"2 8",stroke:Xt(),vertical:!1}):null,r.jsx(Ne.XAxis,{dataKey:"label",tick:or(),tickLine:!1,axisLine:!1,interval:0,dy:6}),r.jsx(Ne.YAxis,{tick:or(),tickLine:!1,axisLine:!1,width:44,tickFormatter:g=>f(Number(g)),dx:-2}),u?r.jsx(pt,{valueFormat:f,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,r.jsx(Ne.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),r.jsx(Ne.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:Wr,animationEasing:qr,children:h.map(g=>r.jsx(Ne.Cell,{fill:g.color},g.label))})]})})})}function Zu(e,t){let n=0;return e.map((a,o)=>{const l=Ut(a[t.valueKey])??0,i=t.typeKey?String(a[t.typeKey]??""):"",c=i==="total"||o===e.length-1&&i!=="increase"&&i!=="decrease";let d="increase",u=0,p=0,f=l;return c&&i==="total"?(d="total",u=0,p=Math.abs(l),f=l,n=l):c&&o===e.length-1&&!i?(d="total",u=0,p=Math.abs(n),f=n):(d=i==="decrease"||l<0?"decrease":"increase",d==="decrease"?(u=n+l,p=Math.abs(l),n=n+l):(u=n,p=Math.abs(l),n=n+l),f=l),{label:String(a[t.xKey]??""),base:u,delta:p,display:f,kind:d,color:d==="total"?t.totalColor:d==="decrease"?t.decreaseColor:t.increaseColor}})}const ht=135*Math.PI/180,Ua=270*Math.PI/180;function Qu({value:e,min:t=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=ur,tone:p="primary",color:f,thresholds:m,ariaLabel:x="Gauge",animationDuration:w=700,thickness:$=9,showScale:h=!1}){const E=s.useId().replace(/:/g,""),T=n-t||1,g=Math.min(1,Math.max(0,(e-t)/T)),[y,k]=s.useState(w>0?0:g);if(s.useEffect(()=>{if(l||i)return;if(w<=0){k(g);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){k(g);return}let q=0,j=0;k(B=>(j=B,B));const D=performance.now(),se=B=>{const O=Math.min(1,(B-D)/w),oe=1-(1-O)**3;k(j+(g-j)*oe),O<1&&(q=requestAnimationFrame(se))};return q=requestAnimationFrame(se),()=>cancelAnimationFrame(q)},[g,w,l,i]),l)return r.jsx(fr,{height:a});if(i)return r.jsx(br,{height:a,text:c});const S=100,L=108,C=72,W=f??Ju(e,n,p,m),_=t+y*T,V=Ro(S,L,C,ht,ht+Ua),M=ht+Math.max(.001,y)*Ua,Z=Ro(S,L,C,ht,M),H=In(S,L,C,ht),ne=In(S,L,C,ht+Ua);return r.jsx("div",{className:`bonsaif-chart bonsaif-gauge-chart flex flex-col items-center justify-center ${o}`,style:{height:a},children:r.jsxs("svg",{viewBox:"0 0 200 168",width:"100%",height:"100%",role:"img","aria-label":x,className:"overflow-visible",children:[r.jsx("defs",{children:r.jsxs("linearGradient",{id:`bonsaif-gauge-${E}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[r.jsx("stop",{offset:"0%",stopColor:W,stopOpacity:.82}),r.jsx("stop",{offset:"100%",stopColor:W,stopOpacity:1})]})}),r.jsx("path",{d:V,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:$,strokeLinecap:"butt"}),r.jsx("path",{d:Z,fill:"none",stroke:`url(#bonsaif-gauge-${E})`,strokeWidth:$,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),r.jsx("text",{x:S,y:L-(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(_)}),d?r.jsx("text",{x:S,y:L+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:d}):null,h?r.jsxs(r.Fragment,{children:[r.jsx("text",{x:H.x-2,y:H.y+$+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(t)}),r.jsx("text",{x:ne.x+2,y:ne.y+$+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(n)})]}):null]})})}function Ju(e,t,n,a){if(a!=null&&a.length){const l=[...a].sort((c,d)=>c.value-d.value);let i=l[0].color;for(const c of l)e>=c.value&&(i=c.color);return i}if(n)return yr(n);const o=e/(t||1);return o>=.8?yr("success"):o>=.5?yr("warning"):yr("danger")}function In(e,t,n,a){return{x:e+n*Math.cos(a),y:t+n*Math.sin(a)}}function Ro(e,t,n,a,o){const l=In(e,t,n,a),i=In(e,t,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 Ru({value:e,target:t,max:n,ranges:a,height:o=72,className:l="",loading:i=!1,empty:c=!1,emptyText:d="Sin datos para mostrar",label:u,subtitle:p,valueFormat:f=ur,tone:m="primary",showScale:x=!0,showStatus:w=!0,ariaLabel:$="Bullet chart"}){if(i)return r.jsx(fr,{height:o});if(c)return r.jsx(br,{height:o,text:d});const h=n??Math.max(e,t,...(a==null?void 0:a.map(W=>W.value))??[],1)*1.05,T=[...a??[{value:h*.5,color:"color-mix(in srgb, var(--border) 72%, transparent)"},{value:h*.75,color:"color-mix(in srgb, var(--border) 48%, transparent)"},{value:h,color:"color-mix(in srgb, var(--border) 28%, transparent)"}]].sort((W,_)=>W.value-_.value),g=yr(m),y=Math.min(100,Math.max(0,e/h*100)),k=Math.min(100,Math.max(0,t/h*100)),S=e>=t,L=[0,.25,.5,.75,1].map(W=>W*h),C=r.jsxs("div",{className:"bonsaif-bullet-plot min-w-0 flex-1",children:[r.jsxs("div",{className:"bonsaif-bullet-track relative w-full",style:{height:Math.max(22,u?28:o*.42)},role:"img","aria-label":$,children:[r.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:T.map((W,_)=>{const V=_===0?0:T[_-1].value,M=Math.max(0,(W.value-V)/h*100);return r.jsx("div",{style:{width:`${M}%`,background:W.color??`color-mix(in srgb, var(--border) ${70-_*18}%, transparent)`}},_)})}),r.jsx("div",{className:"absolute left-0 top-1/2 w-full",style:{height:"34%",transform:"translateY(-50%)"},children:r.jsx("div",{className:"bonsaif-bullet-value h-full",style:{width:`${y}%`,background:g,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${g} 35%, transparent)`}})}),r.jsx("div",{className:"bonsaif-bullet-target absolute top-1/2 z-[1]",style:{left:`${k}%`,height:"72%",width:3,transform:"translate(-50%, -50%)",background:g,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${f(t)}`})]}),x?r.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:L.map((W,_)=>{const V=W/h*100,M=_===0,Z=_===L.length-1;return r.jsxs("div",{className:"absolute top-0",style:{left:`${V}%`,transform:M?"none":Z?"translateX(-100%)":"translateX(-50%)"},children:[r.jsx("div",{className:"mx-auto h-1.5 w-px",style:{background:"color-mix(in srgb, var(--text-muted) 55%, transparent)",marginLeft:M?0:Z?"auto":void 0,marginRight:Z?0:void 0}}),r.jsx("div",{className:"bonsaif-bullet-scale-label mt-0.5 tabular-nums",style:{color:"var(--text-muted)",textAlign:M?"left":Z?"right":"center"},children:f(W)})]},W)})}):null]});return r.jsx("div",{className:`bonsaif-chart bonsaif-bullet-chart w-full ${l}`,children:u?r.jsxs("div",{className:"bonsaif-bullet-row flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-4",children:[r.jsxs("div",{className:"bonsaif-bullet-label shrink-0 sm:w-[7.5rem] sm:pt-1 sm:text-right",children:[r.jsx("div",{className:"text-sm font-semibold tracking-tight",style:{color:"var(--text-main)"},children:u}),p?r.jsx("div",{className:"mt-0.5 text-[11px] leading-snug",style:{color:"var(--text-muted)"},children:p}):r.jsxs("div",{className:"mt-0.5 text-[11px] tabular-nums leading-snug",style:{color:"var(--text-muted)"},children:[r.jsx("span",{style:{color:g,fontWeight:600},children:f(e)}),r.jsxs("span",{children:[" / meta ",f(t)]})]}),w?r.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:yr(S?"success":"warning")},children:S?"En meta":"Bajo meta"}):null]}),C]}):C})}function ef({data:e,value:t,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:p=!1,showTooltip:f=!0,thresholds:m,label:x="CPU",ariaLabel:w="Uso de CPU"}){var k;const $=o??[{key:a,label:"Uso",color:Vt(t??mt(e,a)??0,m)}],h=t??mt(e,a)??mt(e,((k=$[0])==null?void 0:k.key)??a),E=!d&&(!e.length||h===null);if(d)return r.jsx(fr,{height:i});if(E)return r.jsx(br,{height:i,text:u});const T=Math.min(100,Math.max(0,h??0)),g=Mn(T,m),y=Vt(T,m);return r.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":w,children:[r.jsxs("div",{className:"bonsaif-metric-head",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"bonsaif-metric-kicker",children:[x,l!=null?r.jsxs("span",{className:"ml-1.5 normal-case tracking-normal opacity-80",children:["· ",l," ",l===1?"core":"cores"]}):null]}),r.jsx("div",{className:"bonsaif-metric-value",style:{color:y},children:ft(T,T<10?1:0)})]}),r.jsx("div",{className:"bonsaif-metric-badge",style:{color:y,background:`color-mix(in srgb, ${y} 14%, transparent)`},children:g==="danger"?"Crítico":g==="warning"?"Alto":"Normal"})]}),r.jsx(Dn,{data:e,xKey:n,series:$.map(S=>({...S,color:S.color??y})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:p,showTooltip:f,valueFormat:S=>ft(S,0),ariaLabel:w,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function rf({used:e,total:t,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:p=!0,showTooltip:f=!0,thresholds:m,label:x="RAM",ariaLabel:w="Uso de memoria"}){const $=t>0?t:1,h=Math.min(100,Math.max(0,e/$*100)),E=!d&&!(Number.isFinite(e)&&Number.isFinite(t)&&t>0);if(d)return r.jsx(fr,{height:i});if(E)return r.jsx(br,{height:i,text:u});const T=Mn(h,m),g=Vt(h,m),y=Math.max(0,t-e),k=a.length>0?mt(a,l)??h:h,S=Vt(k,m),L=p&&a.length>1?Math.max(100,i-110):0;return r.jsxs("div",{className:`bonsaif-chart bonsaif-ram-chart w-full ${c}`,role:"group","aria-label":w,children:[r.jsxs("div",{className:"bonsaif-metric-head",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"bonsaif-metric-kicker",children:x}),r.jsxs("div",{className:"flex items-baseline gap-2",children:[r.jsx("span",{className:"bonsaif-metric-value",style:{color:g},children:ft(h,h<10?1:0)}),r.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[bt(e)," / ",bt(t)]})]})]}),r.jsx("div",{className:"bonsaif-metric-badge",style:{color:g,background:`color-mix(in srgb, ${g} 14%, transparent)`},children:T==="danger"?"Crítico":T==="warning"?"Alto":"Normal"})]}),r.jsxs("div",{className:"mb-2",children:[r.jsx("div",{className:"h-2 w-full overflow-hidden rounded-sm",style:{background:"color-mix(in srgb, var(--border) 55%, transparent)"},role:"progressbar","aria-valuenow":Math.round(h),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${x} ${ft(h,0)}`,children:r.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${h}%`,background:`linear-gradient(90deg, ${g}, color-mix(in srgb, ${g} 55%, #38bdf8))`}})}),r.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[11px] tabular-nums",style:{color:"var(--text-muted)"},children:[r.jsxs("span",{children:[r.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Usada"})," ",bt(e)]}),n!=null&&Number.isFinite(n)?r.jsxs("span",{children:[r.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",bt(n)]}):null,r.jsxs("span",{children:[r.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",bt(y)]})]})]}),p&&a.length>1?r.jsx(Dn,{data:a,xKey:o,series:[{key:l,label:"Uso",color:S}],height:L,yDomain:[0,100],showLegend:!1,showTooltip:f,valueFormat:C=>ft(C,0),ariaLabel:`${w} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const tf="color-mix(in srgb, var(--primary) 25%, #38bdf8)",nf="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function af({data:e,timeKey:t="t",inboundKey:n="in",outboundKey:a="out",inbound:o,outbound:l,unit:i="bytes",inboundLabel:c="Entrada",outboundLabel:d="Salida",inboundColor:u=tf,outboundColor:p=nf,height:f=240,className:m="",loading:x=!1,emptyText:w="Sin datos de red",showLegend:$=!1,showTooltip:h=!0,label:E="Network",ariaLabel:T="Tráfico de red"}){const g=o??mt(e,n)??0,y=l??mt(e,a)??0,k=!x&&e.length===0;if(x)return r.jsx(fr,{height:f});if(k)return r.jsx(br,{height:f,text:w});const S=W=>Yo(W,i),C=Math.max(140,f-76);return r.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${m}`,role:"group","aria-label":T,children:[r.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:r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"bonsaif-metric-kicker",children:E}),r.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-5 sm:max-w-lg",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[r.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:u},"aria-hidden":!0}),c]}),r.jsx("div",{className:"mt-1 truncate text-xl font-bold tabular-nums leading-tight tracking-tight",style:{color:u},title:S(g),children:S(g)})]}),r.jsxs("div",{className:"min-w-0 pl-1",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-muted)"},children:[r.jsx("span",{className:"h-3 w-1.5 shrink-0 rounded-sm",style:{background:p},"aria-hidden":!0}),d]}),r.jsx("div",{className:"mt-1 truncate text-lg font-semibold tabular-nums leading-tight tracking-tight opacity-95",style:{color:p},title:S(y),children:S(y)})]})]})]})}),r.jsx("div",{className:"bonsaif-network-plot relative z-0",children:r.jsx(Dn,{data:e,xKey:t,series:[{key:n,label:c,color:u},{key:a,label:d,color:p}],height:C,showLegend:$,showTooltip:h,valueFormat:S,ariaLabel:T,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const el=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],rl=["primeSuiteOrigin","primeSuiteProjectKey"];function sf(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const e=new URLSearchParams(window.location.search);for(const t of el){const n=e.get(t);if(n){const a=On(n);if(a)return a}}if(typeof sessionStorage<"u")for(const t of rl){const n=sessionStorage.getItem(t);if(n)try{const a=new URL(n);if(a.origin&&a.origin!==window.location.origin)return a.origin}catch{const a=On(n);if(a)return a}}if(document.referrer){const t=On(document.referrer);if(t&&t!==window.location.origin)return t}return"*"}catch{return"*"}}function of(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const e=new URLSearchParams(window.location.search);for(const t of el)if(e.get(t))return"query";if(typeof sessionStorage<"u"){for(const t of rl)if(sessionStorage.getItem(t))return"sessionStorage"}if(document.referrer){const t=On(document.referrer);if(t&&t!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function On(e){if(!e)return null;const t=e.trim().replace(/\/+$/,"");if(!t)return null;if(/^https?:\/\/[^/]+$/.test(t))return t;try{return new URL(t).origin}catch{return null}}function lf(e){const[t,n]=s.useState({}),[a,o]=s.useState(!1),l=s.useCallback(u=>a||t[u]?e[u]:void 0,[e,a,t]),i=s.useCallback(u=>{n(p=>({...p,[u]:!0}))},[]),c=s.useCallback(()=>{o(!0)},[]),d=s.useCallback(()=>{n({}),o(!1)},[]);return{submitted:a,touchedFields:t,getFieldError:l,touchField:i,submit:c,reset:d}}Object.defineProperty(G,"toast",{enumerable:!0,get:()=>cs.toast}),G.Alert=ai,G.AreaChart=Dn,G.AuthShell=_o,G.BarChart=qu,G.BonsaifButton=zl,G.BonsaifUIToaster=Fu,G.BulletChart=Ru,G.Button=je,G.CHART_PALETTE=En,G.CalendarPicker=ci,G.ChartCard=Pu,G.Checkbox=ln,G.CodeBlock=mi,G.ComboChart=Xu,G.CompactFilterSelect=gi,G.CompactSearchInput=hi,G.ConfirmDialog=wi,G.CopyButton=oa,G.CopyLinkButton=Ci,G.CpuChart=ef,G.DataSheets=Qi,G.DataTable=As,G.DateRangePicker=tc,G.DonutChart=Vu,G.Drawer=uc,G.DropdownMenu=cc,G.DynamicDetailTabs=ti,G.EmailField=Oc,G.EmptyState=Bc,G.FieldHelperFooter=lt,G.FieldLabelInfo=ot,G.FieldLayoutEditor=Wc,G.FileUpload=_c,G.FormField=ka,G.GaugeChart=Qu,G.GlobalScrollbars=Oo,G.ImageLightbox=Qs,G.ImageLightboxHost=Qc,G.InputField=wa,G.LineChart=Wu,G.LoadingState=hs,G.MentionTextEditor=wo,G.MicroserviceFrame=Du,G.Modal=ca,G.MouseTooltip=zr,G.MultiDateCalendar=ac,G.MultiSelect=Rc,G.NetworkChart=af,G.NumberField=ed,G.PageHeader=Tu,G.PageSearchInput=us,G.Pagination=td,G.PhoneField=ad,G.PieChart=Uu,G.PrimeAuthRouteShell=Lu,G.PrimeSuiteChatFrame=Iu,G.RadioGroup=sd,G.RamChart=rf,G.RichTextEditor=Td,G.SearchableSelect=_r,G.SectionPanel=Ld,G.Sparkline=Ku,G.StatusBadge=Id,G.StatusSelect=Pd,G.StepWizard=_d,G.TableSkeleton=on,G.Tabs=zd,G.TagInput=Zd,G.TextInput=vn,G.Textarea=No,G.TextareaField=Vd,G.TimeField=au,G.TimePicker=Lo,G.Toggle=ou,G.UserAvatar=zo,G.WaterfallChart=Gu,G.YearMultiDateCalendar=oc,G.buildMentionQueryRegex=co,G.cn=Tr,G.configureBonsaifUI=$i,G.dedupeMentions=po,G.defaultValueFormat=ur,G.describeParentTargetOrigin=of,G.emailFormat=gc,G.extractMentionUsernames=Ia,G.filterSelfMentions=Nd,G.findMentionTriggerInEditor=Aa,G.formatBytes=bt,G.formatPercent=ft,G.formatRate=Yo,G.getBonsaifUIConfig=Ti,G.getDataTablePreferencesEndpoint=da,G.getPlainTextOffset=Oa,G.highlightMentions=ho,G.htmlToText=bo,G.insertMentionInEditor=go,G.isMentionTriggerBoundary=fo,G.isPlainOffsetInsideMentionChip=uo,G.isValidEmail=va,G.isValidPhone=ya,G.locateTextOffset=dt,G.matches=Nc,G.maxLength=xc,G.maxValue=kc,G.mentionDisplayLabel=mo,G.minLength=yc,G.minValue=wc,G.normalizeUsername=Da,G.openImageLightboxFromEvent=Gs,G.phoneCountryCodeOptions=eo,G.phoneFormat=vc,G.placeCaretAtTextOffset=vo,G.required=hc,G.resetBonsaifUIConfig=Li,G.resolveMentions=kd,G.resolveParentTargetOrigin=sf,G.seriesColor=Vo,G.setBonsaifDataTablePreferencesEndpoint=Ai,G.toneColor=yr,G.usageColor=Vt,G.usageTone=Mn,G.useValidationVisibility=lf,G.validateForm=Sc,Object.defineProperty(G,Symbol.toStringTag,{value:"Module"})}));
42
+ `}),y.map(F=>{const se=eu(F.colorIndex);return A===F.id?t.jsx("input",{ref:X,value:U,disabled:o,onChange:G=>z(G.target.value),onKeyDown:G=>ee(G,F.id),onBlur:()=>le(F.id,U),className:"min-w-[4rem] rounded border border-[var(--primary)] bg-transparent px-1 py-0.5 text-sm text-[var(--text-main)] outline-none",style:{width:`${Math.max(U.length+2,6)}ch`}},F.id):t.jsxs("span",{className:"inline-flex max-w-[240px] items-center gap-1 rounded-md px-2 py-0.5 text-xs font-medium",style:{backgroundColor:se.bg,color:se.text,border:`1px solid ${se.border}`},children:[t.jsx("span",{className:"truncate",children:F.value}),t.jsx("button",{type:"button","aria-label":`Editar "${F.value}"`,disabled:o,tabIndex:-1,onClick:G=>{G.stopPropagation(),g(F)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:t.jsx(P.HiPencil,{className:"h-3 w-3"})}),t.jsx("button",{type:"button","aria-label":`Eliminar "${F.value}"`,disabled:o,tabIndex:-1,onClick:G=>{G.stopPropagation(),O(F.id)},className:"flex h-4 w-4 flex-shrink-0 items-center justify-center rounded opacity-60 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",children:t.jsx(P.HiXMark,{className:"h-3.5 w-3.5"})})]},F.id)}),!R&&t.jsx("input",{ref:ne,value:k,disabled:o,placeholder:y.length===0?a:"",onChange:F=>S(F.target.value),onKeyDown:_,onPaste:j,className:"min-w-[8rem] flex-1 bg-transparent text-sm text-[var(--text-main)] outline-none placeholder:text-[var(--text-muted)] disabled:cursor-not-allowed"})]}),t.jsx(lr,{error:x,helperText:f,helperDisplay:p})]})}const su=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;function Xe(e){return String(e).padStart(2,"0")}function za(e,r=fr()){const n=e.trim();if(!n)return r;const a=n.match(su);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 qr(e,r=!0){const n=`${Xe(e.hour24)}:${Xe(e.minute)}`;return r?`${n}:${Xe(e.second)}`:n}function Mn(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 Ur(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 ou(e,r){const n=(r==null?void 0:r.use12Hour)??!1,a=(r==null?void 0:r.showSeconds)??!0,o=za(e);if(n){const l=Mn(o),i=`${l.hour12}:${Xe(l.minute)}`;return`${a?`${i}:${Xe(l.second)}`:i} ${l.meridiem}`}return qr(o,a)}function fr(){const e=new Date;return{hour24:e.getHours(),minute:e.getMinutes(),second:e.getSeconds()}}function lu(e=!0){return qr(fr(),e)}function ja(e,r){const n=[];for(let a=e;a<=r;a+=1)n.push(a);return n}const st=36,Wa=5,Oo=Math.floor(Wa/2),iu=52,cu=48,Ct=18;function Ho(e){return e*st}function Bo(e){return Math.round(e/st)}function du(e){return e.use12Hour??e.hour12??!1}function Tn({values:e,selected:r,onSelect:n,syncEpochRef:a,forceSyncAt:o=0,width:l=iu,label:i,maxNumeric:c=59,isMeridiem:d=!1,isFocused:u=!1,onFocus:m,onAdvance:f,onBack:p,setColumnRef:x}){const w=s.useRef(null),T=s.useRef(null),h=s.useRef(null),E=s.useRef(""),$=s.useRef(0),v=s.useRef(!1),[y,k]=s.useState(r),[S,A]=s.useState(""),C=s.useCallback(g=>{E.current=g,A(g)},[]),U=s.useMemo(()=>[...Array(Oo).fill(""),...e,...Array(Oo).fill("")],[e]),z=s.useCallback(()=>{const g=w.current;if(!g)return r;const _=Bo(g.scrollTop),ee=Math.min(Math.max(_,0),e.length-1);return e[ee]??r},[r,e]),Y=s.useCallback((g,_=!0)=>{const ee=Math.min(Math.max(g,0),e.length-1),ae=e[ee],j=w.current;!j||!ae||(T.current&&(window.clearTimeout(T.current),T.current=null),v.current=!0,$.current=ee,j.scrollTop=Ho(ee),k(ae),_&&ae!==r&&n(ae))},[n,r,e]);s.useLayoutEffect(()=>{T.current&&(window.clearTimeout(T.current),T.current=null),h.current&&(window.clearTimeout(h.current),h.current=null),C(""),k(r);const g=e.indexOf(r);if(g>=0&&($.current=g),g<0||!w.current)return;const _=Ho(g);w.current.scrollTop!==_&&(w.current.scrollTop=_)},[o,r,C,e]);const M=s.useCallback(()=>{h.current&&(window.clearTimeout(h.current),h.current=null)},[]),J=s.useCallback((g,_=!1)=>{M(),C("");const ee=Number(g);if(!Number.isFinite(ee))return;const ae=Math.min(c,Math.max(0,ee));let j=Xe(ae),K=e.indexOf(j);if(K<0){const L=Math.min(e.length-1,Math.max(0,ae-(c===12?1:0)));j=e[L]??j,K=e.indexOf(j)}K>=0&&Y(K),_&&(f==null||f())},[M,c,f,Y,C,e]),H=s.useCallback(g=>{const _=Math.floor(c/10),ee=E.current;if(ee===""){if(g>_){J(String(g),!0);return}const j=String(g);C(j),h.current=window.setTimeout(()=>{J(E.current,!0)},1200);return}M();const ae=+`${ee}${g}`;ae<=c?J(String(ae),!0):J(String(g),!0)},[M,J,c,C]),ne=s.useCallback(g=>{M(),C(""),Y($.current+g)},[M,Y,C]),X=g=>{if(d){g.key==="a"||g.key==="A"?(g.preventDefault(),n("AM"),f==null||f()):g.key==="p"||g.key==="P"?(g.preventDefault(),n("PM"),f==null||f()):g.key==="ArrowUp"||g.key==="ArrowDown"?(g.preventDefault(),n(r==="AM"?"PM":"AM")):g.key==="Tab"&&(g.preventDefault(),g.shiftKey?p==null||p():f==null||f());return}if(/^\d$/.test(g.key)){g.preventDefault(),H(Number(g.key));return}g.key==="ArrowUp"?(g.preventDefault(),ne(-1)):g.key==="ArrowDown"?(g.preventDefault(),ne(1)):g.key==="Tab"&&(g.preventDefault(),M(),E.current!==""&&J(E.current,!1),g.shiftKey?p==null||p():f==null||f())},W=s.useCallback(()=>{const g=a.current,_=w.current;_&&g===a.current&&Y(Bo(_.scrollTop))},[Y,a]),q=()=>{if(E.current!=="")return;if(v.current){v.current=!1;const _=z();k(_);const ee=e.indexOf(_);ee>=0&&($.current=ee);return}k(z()),T.current&&window.clearTimeout(T.current);const g=a.current;T.current=window.setTimeout(()=>{g===a.current&&W()},100)},I="absolute left-0 right-0 z-40 flex items-center justify-center border-0 bg-transparent p-0 transition-opacity duration-150 hover:opacity-80 focus:outline-none",oe=st*Wa,B=oe+Ct*2,O=S!==""?S:null,le=O!==null;return t.jsxs("div",{ref:x,role:"spinbutton",tabIndex:u?0:-1,"aria-label":i,"aria-valuetext":O??r,"aria-valuenow":d?void 0:Number(r),onFocus:m,onMouseDown:()=>m==null?void 0:m(),onKeyDown:X,onBlur:()=>{M(),E.current!==""&&J(E.current,!1)},className:"relative shrink-0 rounded-lg outline-none",style:{width:l,height:B,boxShadow:u?"0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent)":"none"},children:[t.jsx("button",{type:"button","aria-label":"Valor anterior",className:I,style:{top:0,height:Ct,color:"var(--text-muted)",opacity:.35},onClick:()=>ne(-1),children:t.jsx(P.HiChevronUp,{className:"h-3.5 w-3.5"})}),t.jsx("div",{ref:w,className:"absolute inset-x-0 overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",style:{top:Ct,height:oe,scrollSnapType:"y mandatory",scrollBehavior:"auto"},onScroll:q,onMouseUp:W,onTouchEnd:W,children:U.map((g,_)=>{const ee=g!==""&&g===y;return t.jsx("button",{type:"button",tabIndex:-1,disabled:!g,onClick:()=>{if(!g)return;const ae=e.indexOf(g);ae>=0&&Y(ae)},className:"flex w-full items-center justify-center tabular-nums leading-none disabled:cursor-default",style:{height:st,scrollSnapAlign:"center",color:ee?"var(--text-main)":"var(--text-muted)",fontSize:ee?16:14,fontWeight:ee?600:400,opacity:g?le?ee?0:.35:ee?1:.35:0},children:g},`wheel-${_}-${g}`)})}),O!==null?t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-50 flex items-center justify-center tabular-nums font-semibold leading-none",style:{top:Ct+oe/2-st/2,height:st,color:"var(--text-main)",fontSize:16,background:"var(--bg-card)"},children:O}):null,t.jsx("button",{type:"button","aria-label":"Valor siguiente",className:I,style:{bottom:0,height:Ct,color:"var(--text-muted)",opacity:.35},onClick:()=>ne(1),children:t.jsx(P.HiChevronDown,{className:"h-3.5 w-3.5"})})]})}function Fo(){return t.jsx("span",{className:"flex shrink-0 items-center justify-center self-center text-base font-medium tabular-nums leading-none",style:{color:"var(--text-muted)",height:st,width:14,opacity:.45},"aria-hidden":!0,children:":"})}function Po({value:e,onChange:r,use12Hour:n,hour12:a,showSeconds:o=!1,title:l="Seleccionar hora",variant:i="panel",onCancel:c,onConfirm:d,className:u=""}){const m=i==="popover",f=m||!d,p=du({use12Hour:n,hour12:a}),x=s.useRef(e),w=za(e,fr()),T=Mn(w),[h,E]=s.useState(Xe(p?T.hour12:w.hour24)),[$,v]=s.useState(Xe(w.minute)),[y,k]=s.useState(Xe(w.second)),[S,A]=s.useState(T.meridiem),[C,U]=s.useState(0),z=s.useRef(0),Y=s.useRef(!1),M=s.useRef({hour:null,minute:null,second:null,meridiem:null}),[J,H]=s.useState("hour"),ne=s.useMemo(()=>{const ie=["hour","minute"];return o&&ie.push("second"),p&&ie.push("meridiem"),ie},[p,o]),X=s.useCallback(ie=>{H(pe=>{const Ce=ne.indexOf(pe);return ne[(Ce+ie+ne.length)%ne.length]})},[ne]);s.useEffect(()=>{var ie;(ie=M.current[J])==null||ie.focus()},[J]),s.useEffect(()=>{var ie;H("hour"),(ie=M.current.hour)==null||ie.focus()},[]),s.useEffect(()=>{if(e===x.current)return;x.current=e;const ie=za(e,fr()),pe=Mn(ie);E(Xe(p?pe.hour12:ie.hour24)),v(Xe(ie.minute)),k(Xe(ie.second)),A(pe.meridiem)},[p,e]);const W=s.useMemo(()=>(p?ja(1,12):ja(0,23)).map(ie=>Xe(ie)),[p]),q=s.useMemo(()=>ja(0,59).map(ie=>Xe(ie)),[]),I=q,oe=s.useMemo(()=>["AM","PM"],[]),B=s.useCallback(()=>p?Ur({hour12:Number(h),minute:Number($),second:Number(y),meridiem:S}):{hour24:Number(h),minute:Number($),second:Number(y)},[h,p,S,$,y]),O=s.useCallback(ie=>{if(Y.current)return;const pe=qr(ie,o);x.current=pe,r(pe)},[r,o]),le=s.useCallback(()=>{O(B())},[B,O]),g=ie=>{E(ie),f&&O(p?Ur({hour12:Number(ie),minute:Number($),second:Number(y),meridiem:S}):{hour24:Number(ie),minute:Number($),second:Number(y)})},_=ie=>{v(ie),f&&O(p?Ur({hour12:Number(h),minute:Number(ie),second:Number(y),meridiem:S}):{hour24:Number(h),minute:Number(ie),second:Number(y)})},ee=ie=>{k(ie),f&&O(p?Ur({hour12:Number(h),minute:Number($),second:Number(ie),meridiem:S}):{hour24:Number(h),minute:Number($),second:Number(ie)})},ae=ie=>{A(ie),f&&O(Ur({hour12:Number(h),minute:Number($),second:Number(y),meridiem:ie}))},j=s.useCallback(()=>(z.current+=1,U(z.current),z.current),[]),K=s.useCallback(ie=>{const pe=Mn(ie),Ce=qr(ie,o);x.current=Ce,E(Xe(p?pe.hour12:ie.hour24)),v(Xe(ie.minute)),k(Xe(ie.second)),A(pe.meridiem),r(Ce)},[p,r,o]),L=()=>{Y.current=!0,j(),K(fr()),queueMicrotask(()=>{const ie=fr();qr(ie,o)!==x.current&&(j(),K(ie)),Y.current=!1})},R=()=>{le(),d==null||d()},F=st*Wa,se=F+Ct*2,G=Ct+F/2-st/2,de=t.jsx("div",{className:"relative px-4 py-2",children:t.jsxs("div",{className:"relative mx-auto",style:{height:se,maxWidth:"100%"},children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-10 rounded-xl",style:{top:G,height:st,background:"color-mix(in srgb, var(--primary) 10%, var(--bg-input))",border:"1px solid color-mix(in srgb, var(--primary) 22%, transparent)"}}),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-20",style:{top:Ct,height:st*1.35,background:"linear-gradient(to bottom, var(--bg-card) 40%, transparent 100%)"}}),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-20",style:{bottom:Ct,height:st*1.35,background:"linear-gradient(to top, var(--bg-card) 40%, transparent 100%)"}}),t.jsxs("div",{className:"relative z-30 flex h-full items-center justify-center gap-1",children:[t.jsx(Tn,{syncEpochRef:z,forceSyncAt:C,values:W,selected:h,onSelect:g,label:"Horas",maxNumeric:p?12:23,isFocused:J==="hour",onFocus:()=>H("hour"),onAdvance:()=>X(1),onBack:()=>X(-1),setColumnRef:ie=>{M.current.hour=ie}}),t.jsx(Fo,{}),t.jsx(Tn,{syncEpochRef:z,forceSyncAt:C,values:q,selected:$,onSelect:_,label:"Minutos",maxNumeric:59,isFocused:J==="minute",onFocus:()=>H("minute"),onAdvance:()=>X(1),onBack:()=>X(-1),setColumnRef:ie=>{M.current.minute=ie}}),o?t.jsxs(t.Fragment,{children:[t.jsx(Fo,{}),t.jsx(Tn,{syncEpochRef:z,forceSyncAt:C,values:I,selected:y,onSelect:ee,label:"Segundos",maxNumeric:59,isFocused:J==="second",onFocus:()=>H("second"),onAdvance:()=>X(1),onBack:()=>X(-1),setColumnRef:ie=>{M.current.second=ie}})]}):null,p?t.jsx("div",{className:"ml-3 shrink-0 pl-1",children:t.jsx(Tn,{syncEpochRef:z,forceSyncAt:C,values:oe,selected:S,onSelect:ie=>ae(ie),width:cu,label:"AM o PM",isMeridiem:!0,isFocused:J==="meridiem",onFocus:()=>H("meridiem"),onAdvance:()=>X(1),onBack:()=>X(-1),setColumnRef:ie=>{M.current.meridiem=ie}})}):null]})]})}),Se=t.jsxs("div",{className:`flex items-center ${m?"justify-center px-3 py-2":"justify-between gap-2 px-3 py-2.5"}`,style:{borderTop:m?"none":"1px solid color-mix(in srgb, var(--border) 80%, transparent)"},children:[t.jsx(je,{variant:"ghost",size:"sm",onClick:L,className:m?"text-xs":void 0,children:"Ahora"}),!m&&(c||d)?t.jsxs("div",{className:"flex items-center gap-2",children:[c?t.jsx(je,{variant:"ghost",size:"sm",onClick:c,children:"Cancelar"}):null,d?t.jsx(je,{variant:"primary",size:"sm",onClick:R,children:"Listo"}):null]}):null]});return t.jsxs("div",{className:`overflow-hidden ${u}`,style:{borderRadius:m?12:14,border:m?"1px solid color-mix(in srgb, var(--border) 85%, transparent)":"1px solid var(--border)",background:"var(--bg-card)",boxShadow:m?"0 12px 40px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06)":"0 1px 3px rgba(15, 23, 42, 0.06)",minWidth:p?o?300:260:o?252:212},children:[!m&&l?t.jsx("div",{className:"border-b px-3 py-2.5",style:{borderColor:"color-mix(in srgb, var(--border) 80%, transparent)"},children:t.jsx("h3",{className:"text-sm font-semibold",style:{color:"var(--text-main)"},children:l})}):null,de,Se]})}function uu(e){return e.use12Hour??e.hour12??!1}function fu({label:e,value:r,onChange:n,use12Hour:a,hour12:o,showSeconds:l=!1,title:i="Seleccionar hora",placeholder:c="Seleccionar hora",disabled:d=!1,displayMode:u="popover",required:m,error:f,helperText:p,helperDisplay:x,className:w,contentClassName:T,className:h=""}){const E=u==="popover",[$,v]=s.useState(!1),y=s.useRef(null),[k,S]=s.useState({horizontal:"left",vertical:"bottom"}),A=uu({use12Hour:a,hour12:o}),C=s.useMemo(()=>r?ou(r,{use12Hour:A,showSeconds:l}):"",[A,l,r]);s.useEffect(()=>{if(!E||!$||!y.current)return;const Y=y.current.getBoundingClientRect(),M=8,J=A?l?300:260:l?252:212,H=276,ne=Y.left+J>window.innerWidth-M,X=Y.right-J>=M,W=Y.bottom+8+H>window.innerHeight-M,q=Y.top-8-H>=M;S({horizontal:ne&&X?"right":"left",vertical:W&&q?"top":"bottom"})},[A,E,$,l]),s.useEffect(()=>{if(!E||!$)return;function Y(J){y.current&&(y.current.contains(J.target)||v(!1))}function M(J){J.key==="Escape"&&v(!1)}return document.addEventListener("mousedown",Y),document.addEventListener("keydown",M),()=>{document.removeEventListener("mousedown",Y),document.removeEventListener("keydown",M)}},[E,$]);const U=t.jsxs("button",{type:"button",disabled:d,onClick:()=>{d||v(Y=>!Y)},className:`flex h-10 w-full items-center justify-between gap-2 rounded-lg border px-2.5 text-sm transition-all duration-150 focus:outline-none disabled:cursor-not-allowed disabled:opacity-60 ${h}`,style:{background:"var(--bg-input)",borderColor:f?"var(--danger)":$?"var(--primary)":"var(--border)",color:C?"var(--text-main)":"var(--text-muted)",boxShadow:$?"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(P.HiClock,{className:"h-4 w-4 shrink-0 text-[var(--text-muted)]"}),t.jsx("span",{className:"truncate",children:C||c})]}),E?t.jsx(P.HiChevronDown,{className:`h-4 w-4 shrink-0 text-[var(--text-muted)] transition-transform duration-150 ${$?"rotate-180":""}`}):null]}),z=t.jsx(Po,{variant:E?"popover":"panel",value:r||lu(l),onChange:n,use12Hour:A,showSeconds:l,title:i,onClose:()=>v(!1)});return t.jsx(Ca,{label:e,required:m,error:f,helperText:p,helperDisplay:x,className:w,contentClassName:T,children:E?t.jsxs("div",{ref:y,className:"relative w-full",children:[U,$?t.jsx("div",{className:"absolute z-50",style:{...k.horizontal==="left"?{left:0}:{right:0},...k.vertical==="bottom"?{top:"calc(100% + 6px)"}:{bottom:"calc(100% + 6px)"}},children:z}):null]}):t.jsxs("div",{className:"space-y-2",children:[U,$?z:null]})})}const bu={xs:{width:28,height:16,thumb:12,padding:2},sm:{width:36,height:20,thumb:16,padding:2}};function mu({checked:e,disabled:r,onCheckedChange:n,size:a="sm",className:o="",...l}){const i=bu[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 _o=[".sidebar-scroll",".app-scroll",".showcase-nav-scroll","[data-overlay-scroll='true']"].join(","),pu=[":scope > [data-overlayscrollbars-contents]",":scope > .sidebar-scroll-body",":scope > .showcase-nav-scroll-body",":scope > .app-scroll-body"].join(", ");function hu(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 zo(e){return e.classList.contains("sidebar-scroll")||e.classList.contains("showcase-nav-scroll")}function jo(e){zo(e)&&e.querySelectorAll(".os-scrollbar-horizontal").forEach(r=>{r.style.display="none",r.style.height="0",r.style.pointerEvents="none"})}function gu(e){const r=e.querySelector(pu);return r instanceof HTMLElement?r:null}function Wo(){return s.useEffect(()=>{const e=new WeakMap;let r=0;const n=()=>{r=0,document.querySelectorAll(_o).forEach(l=>{if(!(l instanceof HTMLElement))return;if(sa.OverlayScrollbars(l)){jo(l);return}if(!hu(l))return;const c={overflow:zo(l)?{x:"hidden",y:"scroll"}:void 0,scrollbars:{autoHide:"leave",autoHideDelay:180}},d=gu(l),u=d?sa.OverlayScrollbars({target:l,elements:{viewport:d}},c):sa.OverlayScrollbars(l,c);jo(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(_o).forEach(l=>{var i;l instanceof HTMLElement&&((i=e.get(l))==null||i.destroy())})}},[]),null}function It(e){const r=e.trim();return!r||r==="/"||r==="/."?"":(r.startsWith("/")?r:`/${r}`).replace(/\/+$/,"")}function qo(e){try{const r=new URL(e);return It(r.pathname)}catch{return""}}function vu(e){const r=It(e);if(!r)return"";const n=r.match(/^\/apps\/[^/]+/i);if(n)return It(n[0]);const a=r.split("/").filter(Boolean);return a.length===0?"":a.length>=2&&a[0].toLowerCase()==="apps"?It(`/${a[0]}/${a[1]}`):new Set(["admin","apps","apps-list","tickets","my-tickets","projects","projects-calendars","dashboard","teams","clients","services","settings","profile","messages","notifications","my-access","my-registers","my-pings","security-incidents","email-inbox","webhook-config","webphone-config","vobo","auth","api","login","forbidden","unauthorized","change-password","reset-password","chat-widget"]).has(a[0].toLowerCase())?"":It(`/${a[0]}`)}const qa="primeSuiteAppUrl",yu={xs:{wh:"w-5 h-5",text:"text-[8px]"},sm:{wh:"w-7 h-7",text:"text-[11px]"},md:{wh:"w-9 h-9",text:"text-sm"},lg:{wh:"w-12 h-12",text:"text-base"},xl:{wh:"w-16 h-16",text:"text-xl"}},Uo={xs:20,sm:28,md:36,lg:48,xl:64},Vo=["bg-indigo-500","bg-blue-500","bg-emerald-500","bg-violet-500","bg-amber-500","bg-teal-500","bg-rose-500","bg-cyan-500"],xu={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg"},wu="bonsaif.bot",ku="Bonsaif Bot",Nu={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2",xl:"p-2.5"};function Xo(e){return typeof e=="string"?e.trim():""}function Su(e){var o;if(e!==void 0)return It(e);const r=It(typeof process<"u"&&((o=process.env)==null?void 0:o.NEXT_PUBLIC_BASE_PATH)||"");if(r)return r;if(typeof window>"u")return"";try{const i=new URLSearchParams(window.location.search).get(qa)||"";i&&window.sessionStorage.setItem(qa,i);const c=window.sessionStorage.getItem(qa)||"",d=i||c;if(d){const u=qo(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")?qo(a):It(a);if(l&&!/^\/admin(\/|$)/i.test(l))return l}return vu(window.location.pathname)}function Cu(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 Eu(e){let r=0;for(const n of e)r=r*31+n.charCodeAt(0)&65535;return Vo[r%Vo.length]}function Mu(e,r){return e===wu||r===ku}function Tu(e,r){return`${e.replace(/\/$/,"")}${r}`}function Yo({userId:e,username:r,name:n,size:a="md",showName:o=!1,showTooltip:l,tooltipContent:i,fallbackLabel:c="Usuario",basePath:d,wrapperClassName:u="",labelClassName:m="",labelSize:f="xs",avatarVersion:p=0,className:x="",style:w}){const[T,h]=s.useState(!1),E=typeof e=="string"&&e.trim()&&e!=="undefined"&&e!=="null"?e.trim():"";s.useEffect(()=>{h(!1)},[E,p]);const{wh:$,text:v}=yu[a],y=Xo(n)||Xo(r)||c,k=Cu(y),S=Su(d),A=Mu(r,n),C=Tu(S,"/favicon.svg"),U=s.useMemo(()=>{if(!E)return"";const H=new URLSearchParams;H.set("size",String(Uo[a])),p&&H.set("v",String(p));const ne=H.toString();return`${S}/api/user/avatar/${encodeURIComponent(E)}${ne?`?${ne}`:""}`},[p,S,E,a]),z=Uo[a],Y=A?t.jsx("span",{className:`${$} ${Nu[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 ${x}`,style:w,children:t.jsx("img",{src:C,alt:y,width:z,height:z,className:"h-full w-full object-contain"})}):U&&!T?t.jsx("img",{src:U,alt:y,width:z,height:z,className:`${$} rounded-full object-cover flex-shrink-0 ${x}`,style:w,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>h(!0)},`${E}-${p}`):t.jsx("span",{className:`${$} ${Eu(y)} ${v} rounded-full flex items-center justify-center font-black text-white uppercase flex-shrink-0 ${x}`,style:w,title:y,children:k});if(o)return t.jsxs("span",{className:`inline-flex min-w-0 items-center gap-2 ${u}`,children:[Y,t.jsx("span",{className:`min-w-0 truncate ${xu[f]} font-medium text-[var(--text-main)] ${m}`,title:y,children:y})]});const M=l??!0,J=i??y;return M&&J?t.jsx(_t,{as:"span",content:J,className:`inline-flex flex-shrink-0 ${u}`,children:Y}):Y}function $u({href:e,className:r,children:n}){return t.jsx("a",{href:e,className:r,children:n})}function Au(e){return e.reduce((r,n)=>{const a=n.section??"Principal";return r[a]=[...r[a]??[],n],r},{})}function Ko({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=$u}){const[m,f]=s.useState(!1),p=Au(r);return t.jsxs("div",{className:"min-h-screen bg-[var(--bg-main)] text-[var(--text-main)]",children:[t.jsx(Wo,{}),t.jsx("button",{type:"button","aria-label":"Abrir navegación",className:"fixed left-3 top-3 z-50 inline-flex h-9 w-9 items-center justify-center rounded-md border border-white/10 bg-black/70 text-white lg:hidden",onClick:()=>f(!0),children:t.jsx(P.HiBars3,{className:"h-5 w-5"})}),m&&t.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"fixed inset-0 z-40 bg-black/45 lg:hidden",onClick:()=>f(!1)}),t.jsxs("aside",{className:`fixed inset-y-0 left-0 z-50 flex w-72 flex-col bg-[#071716] text-white shadow-2xl transition-transform duration-200 lg:translate-x-0 ${m?"translate-x-0":"-translate-x-full"}`,children:[t.jsxs("div",{className:"flex h-16 items-center gap-3 border-b border-white/10 px-4",children:[t.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-white/10 text-white",children:l??t.jsx(P.HiHome,{className:"h-5 w-5"})}),t.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:o}),t.jsx("button",{type:"button","aria-label":"Cerrar navegación",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-white/70 hover:bg-white/10 lg:hidden",onClick:()=>f(!1),children:t.jsx(P.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(p).map(([x,w])=>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(P.HiChevronDown,{className:"h-3.5 w-3.5"}),x]}),t.jsx("div",{className:"space-y-1",children:w.map(T=>{const h=n===T.href||n.startsWith(`${T.href}/`);return t.jsxs(u,{href:T.href,className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-2 text-sm transition-colors ${h?"bg-white/10 text-white":"text-white/55 hover:bg-white/[0.06] hover:text-white/85"}`,children:[t.jsx("span",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:T.icon??t.jsx(P.HiHome,{className:"h-4 w-4"})}),t.jsx("span",{className:"truncate",children:T.label})]},T.href)})})]},x))})}),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(Yo,{name:a.initials??a.name??a.email??"Usuario",size:"md"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-sm font-medium text-white",children:a.name??"Usuario"}),a.email&&t.jsx("div",{className:"truncate text-xs text-white/45",children:a.email})]})]}),d&&t.jsxs(je,{variant:"ghost",className:"w-full justify-start text-white hover:bg-white/10",onClick:d,children:[t.jsx(P.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 Go="bonsaif-ui:prime-auth-sso",Lu={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"},Ua={dashboard:t.jsx(P.HiChartBar,{className:"h-5 w-5"}),tickets:t.jsx(P.HiTicket,{className:"h-5 w-5"}),teams:t.jsx(P.HiUsers,{className:"h-5 w-5"}),projects:t.jsx(P.HiRectangleGroup,{className:"h-5 w-5"}),clients:t.jsx(P.HiBuildingOffice2,{className:"h-5 w-5"}),surveys:t.jsx(P.HiClipboardDocumentList,{className:"h-5 w-5"}),profile:t.jsx(P.HiUser,{className:"h-5 w-5"}),settings:t.jsx(P.HiCog6Tooth,{className:"h-5 w-5"}),notifications:t.jsx(P.HiBell,{className:"h-5 w-5"}),changelog:t.jsx(P.HiDocumentText,{className:"h-5 w-5"}),admin:t.jsx(P.HiShieldCheck,{className:"h-5 w-5"}),users:t.jsx(P.HiUsers,{className:"h-5 w-5"}),roles:t.jsx(P.HiShieldCheck,{className:"h-5 w-5"}),menus:t.jsx(P.HiCog6Tooth,{className:"h-5 w-5"}),guards:t.jsx(P.HiCalendarDays,{className:"h-5 w-5"}),vacations:t.jsx(P.HiCalendarDays,{className:"h-5 w-5"}),audit:t.jsx(P.HiListBullet,{className:"h-5 w-5"}),positions:t.jsx(P.HiBriefcase,{className:"h-5 w-5"}),ranks:t.jsx(P.HiListBullet,{className:"h-5 w-5"}),"email-inbox":t.jsx(P.HiInbox,{className:"h-5 w-5"}),"security-incidents":t.jsx(P.HiShieldCheck,{className:"h-5 w-5"})};function Du(e){return e.split("-").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function Iu(e){return/^\d+$/.test(e)||/^[a-f0-9]{8,}$/i.test(e)}function Ou(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=Iu(n)&&a?a:n,l=Lu[o]??Du(o);return[{label:"Inicio",href:"/"},{label:l}]}function Va(e){return(e==null?void 0:e.querySelector(":scope > .os-viewport"))??(e==null?void 0:e.querySelector(":scope > [data-overlayscrollbars-viewport]"))}function Hu(e){const r=e.split("/").filter(Boolean),n=r[r.length-1];if(!n)return t.jsx(P.HiHome,{className:"h-5 w-5"});if(Ua[n])return Ua[n];const a=r.length>1?r[r.length-2]:"";return Ua[a]??t.jsx(P.HiHome,{className:"h-5 w-5"})}function Bu(e){return e.includes("primeAuthOrigin")||e.includes("primeAuthProjectKey")}function Zo(){if(typeof window>"u")return!1;if(Bu(window.location.href)){try{window.sessionStorage.setItem(Go,"true")}catch{}return!0}try{return window.sessionStorage.getItem(Go)==="true"}catch{return!1}}function Fu({title:e,subtitle:r,action:n,meta:a,icon:o,className:l="",contentClassName:i="",breadcrumbs:c,currentPath:d,showBreadcrumbs:u=!0,contained:m=!1}){const f=s.useRef(null),[p,x]=s.useState(!1),[w,T]=s.useState(d??"/"),[h,E]=s.useState(()=>Zo()),[$,v]=s.useState(null),y=d??w,k=c??Ou(y),S=o??Hu(y),A=u&&!h&&k.length>1,C=!A;s.useEffect(()=>{d||T(window.location.pathname)},[d]),s.useEffect(()=>{E(Zo())},[]),s.useEffect(()=>{if(m){x(!1);return}let z=null,Y=0,M=0;const J=()=>{const X=f.current,W=document.querySelector("[data-app-scroll='true']");return(X==null?void 0:X.closest(".os-viewport"))??(X==null?void 0:X.closest("[data-overlayscrollbars-viewport]"))??Va(W)??W??window},H=()=>{const X=z&&z!==window?z.scrollTop:window.scrollY;x(W=>W?X>24:X>72)},ne=()=>{z==null||z.removeEventListener("scroll",H),z=J(),z.addEventListener("scroll",H,{passive:!0}),H()};return ne(),Y=window.requestAnimationFrame(ne),M=window.setTimeout(ne,120),()=>{window.cancelAnimationFrame(Y),window.clearTimeout(M),z==null||z.removeEventListener("scroll",H)}},[m]),s.useEffect(()=>{if(m){v(null);return}let z=0;const Y=[],M=()=>{const I=f.current,oe=I==null?void 0:I.parentElement,B=document.querySelector("[data-app-scroll='true']"),O=Va(B)??B;if(!I||!oe||!O){v(null);return}const le=oe.getBoundingClientRect(),g=window.getComputedStyle(oe),_=O.getBoundingClientRect(),ee=O instanceof HTMLElement&&O.clientWidth>0?O.clientWidth:_.width,ae=le.left+parseFloat(g.paddingLeft||"0"),j={marginLeft:Math.round(_.left-ae),width:Math.round(ee)};v(K=>K&&K.marginLeft===j.marginLeft&&K.width===j.width?K:j)},J=()=>{window.cancelAnimationFrame(z),z=window.requestAnimationFrame(M)};J(),window.addEventListener("resize",J);const H=new ResizeObserver(J),ne=f.current,X=ne==null?void 0:ne.parentElement,W=document.querySelector("[data-app-scroll='true']"),q=Va(W)??W;return[X,W,q].forEach(I=>{I&&H.observe(I)}),Y.push(window.setTimeout(J,120)),Y.push(window.setTimeout(J,280)),()=>{window.cancelAnimationFrame(z),window.removeEventListener("resize",J),H.disconnect(),Y.forEach(I=>window.clearTimeout(I))}},[m]);const U={...$?{marginLeft:$.marginLeft,width:$.width}:null,"--page-header-control-height":p?"34px":"40px","--page-header-control-padding-x":p?"10px":"14px","--page-header-control-icon-left":p?"10px":"12px",background:m?"var(--bg-card)":p?"color-mix(in srgb, var(--bg-main) 82%, transparent)":"color-mix(in srgb, var(--bg-main) 58%, transparent)",backdropFilter:"saturate(1.25) blur(18px)",WebkitBackdropFilter:"saturate(1.25) blur(18px)",borderBottom:m||p?"1px solid var(--border)":"1px solid transparent",boxShadow:p?"0 10px 28px rgba(12, 54, 53, 0.12)":"none"};return t.jsx("div",{ref:f,"data-page-header":"true","data-compact":p?"true":"false",className:`sticky top-0 z-30 overflow-visible py-0 transition-[background-color,box-shadow,border-color] duration-300 ease-out ${m?"mb-0 flex-shrink-0":"mb-4 sm:mb-0"} ${l}`,style:U,children:t.jsxs("div",{className:`flex flex-wrap items-center justify-between transition-[gap,min-height,padding] duration-300 ease-out ${p?"min-h-8 gap-1.5 px-3 py-0 sm:min-h-9 sm:gap-2":C?"min-h-9 gap-2 px-4 py-0 sm:min-h-10 sm:gap-2.5":"min-h-10 gap-2.5 px-4 pt-0.5 sm:min-h-11 sm:gap-3"} ${i}`,children:[t.jsx("div",{className:`min-w-0 flex flex-1 flex-col justify-center transition-[gap,transform] duration-300 ease-out ${p||C?"gap-1":"gap-1.5 sm:gap-2"}`,children:t.jsxs("div",{className:`flex min-w-0 items-center transition-[gap,transform] duration-300 ease-out ${p||C?"gap-2":"gap-2.5 sm:gap-3"}`,children:[t.jsx("span",{className:`flex-shrink-0 transition-[color,transform,opacity] duration-300 ease-out ${p?"scale-75 opacity-80":"scale-90 opacity-100"}`,style:{color:A?"var(--text-secondary)":"var(--text-muted)"},children:S}),t.jsxs("div",{className:`flex min-w-0 flex-1 flex-wrap items-center transition-[gap] duration-300 ease-out ${p?"gap-x-2 gap-y-1":"gap-x-3 gap-y-2"}`,children:[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 ${p?"text-sm sm:text-base":"text-lg sm:text-xl"}`,style:{color:"var(--text-main)"},children:e}),r&&t.jsx("div",{"aria-hidden":p,className:`overflow-hidden text-xs transition-[max-height,opacity,transform,margin] duration-300 ease-out ${p?"mt-0 max-h-0 -translate-y-1 opacity-0":"mt-0.5 max-h-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 ${p?"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 ${p?"min-h-9 gap-1 opacity-95":"min-h-9 gap-1.5 opacity-100"}`,children:t.jsx(ps.Provider,{value:{compact:!0,headerAction:!0},children:n})})]})})}function Pu({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(Ko,{currentPath:r,...a,children:e})}function Qo(){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 _u(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 zu({name:e,src:r,projectKey:n}){const[a,o]=s.useState("system"),l=s.useRef(null);s.useEffect(()=>{o(Qo());const d=new MutationObserver(()=>o(Qo()));return d.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>d.disconnect()},[]);const i=s.useMemo(()=>_u(r,a,n),[n,r,a]),c=s.useMemo(()=>{try{return new URL(i).origin}catch{return""}},[i]);return s.useEffect(()=>{if(!n)return;const d=n;function u(m){var x,w,T;if(m.source!==((x=l.current)==null?void 0:x.contentWindow)||c&&m.origin!==c)return;if(((w=m.data)==null?void 0:w.type)==="prime-microservice:overlay"){window.dispatchEvent(new CustomEvent("prime-auth:microservice-overlay",{detail:{active:!!m.data.active}}));return}if(((T=m.data)==null?void 0:T.type)!=="prime-microservice:navigation")return;const f=m.data.path;if(!f||!f.startsWith("/")||f.startsWith("//"))return;const p=`/apps/${encodeURIComponent(d)}${f}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==p&&(window.history.replaceState(window.history.state,"",p),window.dispatchEvent(new CustomEvent("prime-auth:microservice-navigation")))}return window.addEventListener("message",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 ju(){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:Jo(c.data.width,96,720),height:Jo(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 Jo(e,r,n){const a=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(r,Math.min(n,Math.ceil(a)))}function Wu(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 qu(){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 Uu(){return"light"}function Vu({position:e="bottom-center"}){const r=s.useSyncExternalStore(Wu,qu,Uu);return t.jsx(fs.Toaster,{position:e,theme:r,richColors:!0,closeButton:!0})}function Xu({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 $n=["var(--primary)","#38bdf8","#34d399","#a78bfa","#2dd4bf","#fbbf24","#60a5fa","#94a3b8"];function Ro(e,r){return e.color??$n[r%$n.length]}function yt(e="primary"){switch(e){case"success":return"#34d399";case"warning":return"#fbbf24";case"danger":return"#f87171";case"neutral":return"var(--text-muted)";default:return"var(--primary)"}}const ut=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 Vr(e){if(e==null||e==="")return null;const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?r:null}const Xa={warning:70,danger:90};function An(e,r=Xa){const n=r.warning??Xa.warning,a=r.danger??Xa.danger;return e>=a?"danger":e>=n?"warning":e<=0?"primary":"success"}function Xr(e,r){return yt(An(e,r))}function br(e,r=0){return Number.isFinite(e)?`${e.toFixed(r)}%`:"—"}function mr(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 el(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 pr(e,r){var n;for(let a=e.length-1;a>=0;a-=1){const o=Vr((n=e[a])==null?void 0:n[r]);if(o!==null)return o}return null}function ft({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 bt({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 Wt=680,qt="ease-out",Yu={top:18,right:8,bottom:12,left:0};function Yr(e){return{...Yu,...e}}function Kr(e){return e.map((r,n)=>({...r,color:Ro(r,n),label:r.label??r.key}))}function Ln(e,r){return!e.length||!r.length||e.every(n=>r.every(a=>Vr(n[a.key])===null))}function ot(){return{fill:"var(--text-muted)",fontSize:10,fontWeight:500,letterSpacing:"0.02em"}}function Gr(){return"color-mix(in srgb, var(--border) 55%, transparent)"}function tl(){return"color-mix(in srgb, var(--primary) 45%, var(--border))"}function Dn(){return{paddingBottom:12,paddingLeft:4,fontSize:11,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-muted)"}}function Ku(e,r=ut){if(e==null||e==="")return"—";const n=typeof e=="number"?e:Number(e);return Number.isFinite(n)?r(n):String(e)}function rl(e){return`bonsaif-grad-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function Gu({active:e,label:r,payload:n,valueFormat:a=ut}){var c,d,u,m,f,p;if(!e||!(n!=null&&n.length))return null;const o=n.filter(x=>x.dataKey!=="base"&&x.name!=="base"&&x.value!==null&&x.value!==void 0);if(!o.length)return null;const l=((d=(c=o[0])==null?void 0:c.payload)==null?void 0:d.fullName)??((m=(u=o[0])==null?void 0:u.payload)==null?void 0:m.tooltipLabel)??((p=(f=o[0])==null?void 0:f.payload)==null?void 0:p.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((x,w)=>{const T=x.payload,h=T&&typeof T.display=="number"?T.display:x.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:x.color??"var(--primary)"}}),x.name??x.dataKey]}),t.jsx("span",{className:"bonsaif-chart-tooltip-value",children:Ku(h,a)})]},String(x.dataKey??x.name??w))})})]})}function hr({valueFormat:e,content:r,cursor:n,offset:a=12,wrapperStyle:o,allowEscapeViewBox:l,reverseDirection:i,...c}){return t.jsx(Ne.Tooltip,{...c,cursor:n,offset:a,allowEscapeViewBox:l??{x:!1,y:!1},reverseDirection:i??{x:!1,y:!1},wrapperStyle:{outline:"none",zIndex:60,pointerEvents:"none",overflow:"visible",...o},content:r??t.jsx(Gu,{valueFormat:e})})}function nl(e,r,n){return n==null?-1:e.findIndex(a=>String(a[r])===String(n))}function al(e,r,n){if(n<=1)return null;const a=Math.max(0,Math.min(e,r)),o=Math.min(n-1,Math.max(e,r));return o-a<1||a===0&&o>=n-1?null:{startIndex:a,endIndex:o}}function In(e,r,n={}){const{zoomable:a=!1,zoomMode:o="both",brushHeight:l=28,onZoomChange:i}=n,[c,d]=s.useState(null),[u,m]=s.useState(null),f=!!a&&e.length>1,p=f&&(o==="brush"||o==="both"),x=f&&(o==="drag"||o==="both"),w=s.useCallback(Y=>{d(Y),i==null||i(Y)},[i]),T=s.useCallback(()=>{m(null),w(null)},[w]),h=!!c,E=s.useMemo(()=>!c||p?e:e.slice(c.startIndex,c.endIndex+1),[e,p,c]),$=s.useCallback((Y,M)=>{const J=nl(e,r,Y),H=nl(e,r,M);J<0||H<0||w(al(J,H,e.length))},[w,e,r]),v=s.useCallback(Y=>{x&&((Y==null?void 0:Y.activeLabel)===void 0||(Y==null?void 0:Y.activeLabel)===null||m({leftLabel:Y.activeLabel,rightLabel:Y.activeLabel}))},[x]),y=s.useCallback(Y=>{!x||!u||(Y==null?void 0:Y.activeLabel)===void 0||(Y==null?void 0:Y.activeLabel)===null||m(M=>M&&{...M,rightLabel:Y.activeLabel})},[u,x]),k=s.useCallback(()=>{if(x){if(!u||u.rightLabel===null||u.rightLabel===void 0){m(null);return}$(u.leftLabel,u.rightLabel),m(null)}},[$,u,x]),S=s.useCallback(Y=>{if(p){if(!Y){w(null);return}w(al(Y.startIndex??0,Y.endIndex??e.length-1,e.length))}},[w,e.length,p]),A=x?{onMouseDown:v,onMouseMove:y,onMouseUp:k,onMouseLeave:()=>{u&&k()}}:{},C=c??{startIndex:0,endIndex:Math.max(0,e.length-1)},U=t.jsxs(t.Fragment,{children:[x&&u&&u.rightLabel!==null&&u.rightLabel!==void 0?t.jsx(Ne.ReferenceArea,{x1:u.leftLabel,x2:u.rightLabel,strokeOpacity:.18,fill:"var(--primary)",fillOpacity:.12,stroke:"var(--primary)"}):null,p?t.jsx(Ne.Brush,{dataKey:r,height:l,stroke:"var(--primary)",fill:"color-mix(in srgb, var(--primary) 10%, var(--bg-card))",travellerWidth:8,startIndex:C.startIndex,endIndex:C.endIndex,onChange:S,tickFormatter:Y=>String(Y)}):null]}),z=p?{bottom:Math.max(l+10,36)}:void 0;return{enabled:f,showBrush:p,showDrag:x,viewData:E,isZoomed:h,resetZoom:T,chartHandlers:A,zoomNodes:U,marginExtra:z}}function On({visible:e,onReset:r}){return e?t.jsx("button",{type:"button",className:"bonsaif-chart-zoom-reset",onClick:r,"aria-label":"Restablecer zoom",children:"Restablecer zoom"}):null}function Zu({data:e,xKey:r,series:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:f=ut,yDomain:p,ariaLabel:x="Gráfico de líneas",curve:w=!0,strokeWidth:T=2.25,zoomable:h=!1,zoomMode:E="both",brushHeight:$,onZoomChange:v}){const y=Ln(e,n),k=Kr(n),S=In(e,r,{zoomable:h,zoomMode:E,brushHeight:$,onZoomChange:v}),A=Yr({...m,...S.marginExtra});return l?t.jsx(ft,{height:a}):y?t.jsx(bt,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-line-chart w-full ${o}`,role:"img","aria-label":x,style:{height:a},children:[t.jsx(On,{visible:S.isZoomed,onReset:S.resetZoom}),t.jsx(Ne.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ne.LineChart,{data:S.viewData,margin:A,...S.chartHandlers,children:[c?t.jsx(Ne.CartesianGrid,{strokeDasharray:"2 8",stroke:Gr(),vertical:!1}):null,t.jsx(Ne.XAxis,{dataKey:r,tick:ot(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Ne.YAxis,{tick:ot(),tickLine:!1,axisLine:!1,width:44,domain:p??["auto","auto"],tickFormatter:C=>f(Number(C)),dx:-2}),u?t.jsx(hr,{valueFormat:f,cursor:{stroke:tl(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Ne.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Dn()}):null,k.map((C,U)=>t.jsx(Ne.Line,{type:w?"monotone":"linear",dataKey:C.key,name:C.label,stroke:C.color,strokeWidth:U===0?T+.35:T,strokeOpacity:U===0?1:.88,isAnimationActive:!0,animationDuration:Wt,animationEasing:qt,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:C.color}},C.key)),S.zoomNodes]})})]})}function Hn({data:e,xKey:r,series:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:f=ut,yDomain:p,ariaLabel:x="Gráfico de área",stacked:w=!1,opacity:T=.22,zoomable:h=!1,zoomMode:E="both",brushHeight:$,onZoomChange:v}){const y=Ln(e,n),k=Kr(n),S=In(e,r,{zoomable:h,zoomMode:E,brushHeight:$,onZoomChange:v}),A=Yr({...m,...S.marginExtra});return l?t.jsx(ft,{height:a}):y?t.jsx(bt,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-area-chart w-full ${o}`,role:"img","aria-label":x,style:{height:a},children:[t.jsx(On,{visible:S.isZoomed,onReset:S.resetZoom}),t.jsx(Ne.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ne.AreaChart,{data:S.viewData,margin:A,...S.chartHandlers,children:[t.jsx("defs",{children:k.map(C=>t.jsxs("linearGradient",{id:rl(C.key),x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:C.color,stopOpacity:Math.min(.55,T+.28)}),t.jsx("stop",{offset:"48%",stopColor:C.color,stopOpacity:T*.5}),t.jsx("stop",{offset:"100%",stopColor:C.color,stopOpacity:0})]},C.key))}),c?t.jsx(Ne.CartesianGrid,{strokeDasharray:"2 8",stroke:Gr(),vertical:!1}):null,t.jsx(Ne.XAxis,{dataKey:r,tick:ot(),tickLine:!1,axisLine:!1,padding:{left:0,right:0},interval:"preserveStartEnd",minTickGap:52,dy:6}),t.jsx(Ne.YAxis,{tick:ot(),tickLine:!1,axisLine:!1,width:44,domain:p??["auto","auto"],tickFormatter:C=>f(Number(C)),dx:-2}),u?t.jsx(hr,{valueFormat:f,cursor:{stroke:tl(),strokeWidth:1.25,strokeDasharray:"4 4"}}):null,d?t.jsx(Ne.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Dn()}):null,k.map(C=>t.jsx(Ne.Area,{type:"monotone",dataKey:C.key,name:C.label,stroke:C.color,fill:`url(#${rl(C.key)})`,strokeWidth:2.25,stackId:w?"stack":void 0,isAnimationActive:!0,animationDuration:Wt,animationEasing:qt,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:C.color}},C.key)),S.zoomNodes]})})]})}function Qu({data:e,xKey:r,series:n,height:a=280,className:o="",loading:l=!1,emptyText:i="Sin datos para mostrar",showGrid:c=!0,showLegend:d=!0,showTooltip:u=!0,margin:m,valueFormat:f=ut,yDomain:p,ariaLabel:x="Gráfico de barras",layout:w="vertical",mode:T="grouped",barRadius:h=6,categoryAxisWidth:E=64,zoomable:$=!1,zoomMode:v="both",brushHeight:y,onZoomChange:k}){const S=Ln(e,n),A=Kr(n),C=w==="horizontal",U=In(e,r,{zoomable:$&&!C,zoomMode:v,brushHeight:y,onZoomChange:k}),z=Yr({...m,...U.marginExtra});return l?t.jsx(ft,{height:a}):S?t.jsx(bt,{height:a,text:i}):t.jsxs("div",{className:`bonsaif-chart bonsaif-bar-chart w-full ${o}`,role:"img","aria-label":x,style:{height:a},children:[t.jsx(On,{visible:U.isZoomed,onReset:U.resetZoom}),t.jsx(Ne.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ne.BarChart,{data:U.viewData,margin:z,layout:C?"vertical":"horizontal",barCategoryGap:"34%",barGap:3,...U.chartHandlers,children:[c?t.jsx(Ne.CartesianGrid,{strokeDasharray:"2 8",stroke:Gr(),horizontal:!C,vertical:C}):null,C?t.jsxs(t.Fragment,{children:[t.jsx(Ne.XAxis,{type:"number",tick:ot(),tickLine:!1,axisLine:!1,tickFormatter:Y=>f(Number(Y)),domain:p??["auto","auto"]}),t.jsx(Ne.YAxis,{type:"category",dataKey:r,tick:ot(),tickLine:!1,axisLine:!1,width:E})]}):t.jsxs(t.Fragment,{children:[t.jsx(Ne.XAxis,{dataKey:r,tick:ot(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Ne.YAxis,{tick:ot(),tickLine:!1,axisLine:!1,width:44,domain:p??["auto","auto"],tickFormatter:Y=>f(Number(Y)),dx:-2})]}),u?t.jsx(hr,{valueFormat:f,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,d?t.jsx(Ne.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Dn()}):null,A.map((Y,M)=>t.jsx(Ne.Bar,{dataKey:Y.key,name:Y.label,fill:Y.color,fillOpacity:M===0?1:.82,radius:C?[0,h,h,0]:[h,h,2,2],maxBarSize:20,stackId:T==="stacked"?"stack":void 0,isAnimationActive:!0,animationDuration:Wt,animationEasing:qt},Y.key)),U.zoomNodes]})})]})}function Ju(e){return t.jsx(ol,{...e,variant:"pie"})}function Ru(e){return t.jsx(ol,{...e,variant:"donut",innerRadius:e.innerRadius??.62,cornerRadius:e.cornerRadius??10,padAngle:e.padAngle??2})}function sl(e,r){return e==null||!Number.isFinite(e)?r:e>0&&e<=1?e*100:e}function ol({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=ut,ariaLabel:m,innerRadius:f,outerRadius:p,colors:x=[...$n],padAngle:w,cornerRadius:T,variant:h}){const E=e.map((M,J)=>({name:String(M[r]??""),value:Vr(M[n])??0,fill:x[J%x.length],row:M})).filter(M=>M.value>0),$=!E.length,v=h==="donut",y=E.length,k=sl(f,v?62:12),S=sl(p,78),A=Math.min(w??(v?2:3),Math.max(.5,10/Math.max(1,y))),C=Math.min(T??(v?10:8),Math.max(2,36/Math.max(1,y)));if(l)return t.jsx(ft,{height:a});if($)return t.jsx(bt,{height:a,text:i});const U=E.reduce((M,J)=>M+J.value,0),z=c?Math.min(96,28+Math.ceil(y/3)*22):0,Y=Math.max(140,a-z);return t.jsx("div",{className:`bonsaif-chart bonsaif-${h}-chart w-full ${o}`,role:"img","aria-label":m??(h==="donut"?"Donut chart":"Pie chart"),style:{height:a},children:t.jsxs("div",{className:"bonsaif-pie-layout",children:[t.jsx("div",{className:"bonsaif-pie-plot",style:{height:Y},children:t.jsx(Ne.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ne.PieChart,{margin:{top:4,right:4,bottom:4,left:4},children:[d?t.jsx(hr,{valueFormat:u,isAnimationActive:!1}):null,t.jsx(Ne.Pie,{data:E,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:`${k}%`,outerRadius:`${S}%`,startAngle:90,endAngle:-270,paddingAngle:A,cornerRadius:C,minAngle:y>6?3:2,stroke:"var(--bg-card)",strokeWidth:2,isAnimationActive:!0,animationDuration:Wt,animationEasing:qt,label:!1,activeShape:ef,children:E.map(M=>t.jsx(Ne.Cell,{fill:M.fill},M.name))}),v?t.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",children:u(U)}):null]})})}),c?t.jsx("ul",{className:"bonsaif-pie-legend","aria-label":"Leyenda",children:E.map(M=>t.jsxs("li",{className:"bonsaif-pie-legend-item",children:[t.jsx("span",{className:"bonsaif-pie-legend-swatch",style:{background:M.fill},"aria-hidden":!0}),t.jsx("span",{className:"bonsaif-pie-legend-label",title:M.name,children:M.name}),t.jsx("span",{className:"bonsaif-pie-legend-value",children:u(M.value)})]},M.name))}):null]})})}function ef(e){const{outerRadius:r=0,...n}=e;return t.jsx(Ne.Sector,{...n,outerRadius:Number(r)+4,stroke:"var(--bg-card)",strokeWidth:2})}function tf({data:e,dataKey:r,width:n="100%",height:a=36,tone:o="primary",color:l,fill:i=!0,className:c="",ariaLabel:d="Sparkline"}){const u=l??yt(o),m=e.map(S=>Vr(S[r])).filter(S=>S!==null);if(m.length<2)return t.jsx("div",{className:c,style:{width:n,height:a,color:"var(--text-muted)"},"aria-label":d});const f=120,p=36,x=3,w=1,T=Math.min(...m),E=Math.max(...m)-T||1,$=m.map((S,A)=>{const C=w+A/(m.length-1)*(f-w*2),U=p-x-(S-T)/E*(p-x*2);return{x:C,y:U}}),v=$.map((S,A)=>`${A===0?"M":"L"}${S.x.toFixed(2)} ${S.y.toFixed(2)}`).join(" "),y=`${v} L${$[$.length-1].x.toFixed(2)} ${p} L${$[0].x.toFixed(2)} ${p} Z`,k=`bonsaif-spark-${r.replace(/[^a-zA-Z0-9_-]/g,"")}-${o}`;return t.jsx("div",{className:`bonsaif-sparkline ${c}`,style:{width:n,height:a},role:"img","aria-label":d,children:t.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${f} ${p}`,preserveAspectRatio:"none",focusable:"false",children:[i?t.jsx("defs",{children:t.jsxs("linearGradient",{id:k,x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:u,stopOpacity:.38}),t.jsx("stop",{offset:"100%",stopColor:u,stopOpacity:0})]})}):null,i?t.jsx("path",{d:y,fill:`url(#${k})`}):null,t.jsx("path",{d:v,fill:"none",stroke:u,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})})}function rf({data:e,xKey:r,series:n,barSeries:a,lineSeries:o,height:l=280,className:i="",loading:c=!1,emptyText:d="Sin datos para mostrar",showGrid:u=!0,showLegend:m=!0,showTooltip:f=!0,margin:p,valueFormat:x=ut,yDomain:w,ariaLabel:T="Gráfico combinado",barRadius:h=6,zoomable:E=!1,zoomMode:$="both",brushHeight:v,onZoomChange:y}){const k=a??n.slice(0,Math.max(1,n.length-1)),S=o??(n.length>1?n.slice(-1):n.length?[n[0]]:[]),A=[...k,...S.filter(H=>!k.some(ne=>ne.key===H.key))],C=Ln(e,A),U=Kr(k),z=Kr(A),Y=S.map(H=>{var X;const ne=z.find(W=>W.key===H.key);return{...H,label:H.label??H.key,color:H.color??(ne==null?void 0:ne.color)??((X=z[0])==null?void 0:X.color)}}),M=In(e,r,{zoomable:E,zoomMode:$,brushHeight:v,onZoomChange:y}),J=Yr({...p,...M.marginExtra});return c?t.jsx(ft,{height:l}):C?t.jsx(bt,{height:l,text:d}):t.jsxs("div",{className:`bonsaif-chart bonsaif-combo-chart w-full ${i}`,role:"img","aria-label":T,style:{height:l},children:[t.jsx(On,{visible:M.isZoomed,onReset:M.resetZoom}),t.jsx(Ne.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ne.ComposedChart,{data:M.viewData,margin:J,barCategoryGap:"34%",...M.chartHandlers,children:[u?t.jsx(Ne.CartesianGrid,{strokeDasharray:"2 8",stroke:Gr(),vertical:!1}):null,t.jsx(Ne.XAxis,{dataKey:r,tick:ot(),tickLine:!1,axisLine:!1,interval:"preserveStartEnd",minTickGap:36,dy:6}),t.jsx(Ne.YAxis,{tick:ot(),tickLine:!1,axisLine:!1,width:44,domain:w??["auto","auto"],tickFormatter:H=>x(Number(H)),dx:-2}),f?t.jsx(hr,{valueFormat:x,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,m?t.jsx(Ne.Legend,{verticalAlign:"top",align:"right",iconType:"circle",iconSize:7,wrapperStyle:Dn()}):null,U.map(H=>t.jsx(Ne.Bar,{dataKey:H.key,name:H.label,fill:H.color,fillOpacity:.88,radius:[h,h,2,2],maxBarSize:18,isAnimationActive:!0,animationDuration:Wt,animationEasing:qt},H.key)),Y.map(H=>t.jsx(Ne.Line,{type:"monotone",dataKey:H.key,name:H.label,stroke:H.color,strokeWidth:2.5,isAnimationActive:!0,animationDuration:Wt,animationEasing:qt,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:"var(--bg-card)",fill:H.color}},H.key)),M.zoomNodes]})})]})}function nf({data:e,xKey:r,valueKey:n,typeKey:a,height:o=280,className:l="",loading:i=!1,emptyText:c="Sin datos para mostrar",showGrid:d=!0,showTooltip:u=!0,margin:m,valueFormat:f=ut,ariaLabel:p="Gráfico waterfall",increaseColor:x="#34d399",decreaseColor:w="#f87171",totalColor:T="var(--primary)"}){const h=s.useMemo(()=>af(e,{xKey:r,valueKey:n,typeKey:a,increaseColor:x,decreaseColor:w,totalColor:T}),[e,r,n,a,x,w,T]),E=!h.length,$=Yr(m);return i?t.jsx(ft,{height:o}):E?t.jsx(bt,{height:o,text:c}):t.jsx("div",{className:`bonsaif-chart bonsaif-waterfall-chart w-full ${l}`,role:"img","aria-label":p,style:{height:o},children:t.jsx(Ne.ResponsiveContainer,{width:"100%",height:"100%",children:t.jsxs(Ne.BarChart,{data:h,margin:$,barCategoryGap:"42%",children:[d?t.jsx(Ne.CartesianGrid,{strokeDasharray:"2 8",stroke:Gr(),vertical:!1}):null,t.jsx(Ne.XAxis,{dataKey:"label",tick:ot(),tickLine:!1,axisLine:!1,interval:0,dy:6}),t.jsx(Ne.YAxis,{tick:ot(),tickLine:!1,axisLine:!1,width:44,tickFormatter:v=>f(Number(v)),dx:-2}),u?t.jsx(hr,{valueFormat:f,cursor:{fill:"color-mix(in srgb, var(--primary) 8%, transparent)"}}):null,t.jsx(Ne.Bar,{dataKey:"base",stackId:"wf",fill:"transparent",isAnimationActive:!1,legendType:"none",maxBarSize:22}),t.jsx(Ne.Bar,{dataKey:"delta",name:"Valor",stackId:"wf",radius:[6,6,2,2],maxBarSize:22,isAnimationActive:!0,animationDuration:Wt,animationEasing:qt,children:h.map(v=>t.jsx(Ne.Cell,{fill:v.color},v.label))})]})})})}function af(e,r){let n=0;return e.map((a,o)=>{const l=Vr(a[r.valueKey])??0,i=r.typeKey?String(a[r.typeKey]??""):"",c=i==="total"||o===e.length-1&&i!=="increase"&&i!=="decrease";let d="increase",u=0,m=0,f=l;return c&&i==="total"?(d="total",u=0,m=Math.abs(l),f=l,n=l):c&&o===e.length-1&&!i?(d="total",u=0,m=Math.abs(n),f=n):(d=i==="decrease"||l<0?"decrease":"increase",d==="decrease"?(u=n+l,m=Math.abs(l),n=n+l):(u=n,m=Math.abs(l),n=n+l),f=l),{label:String(a[r.xKey]??""),base:u,delta:m,display:f,kind:d,color:d==="total"?r.totalColor:d==="decrease"?r.decreaseColor:r.increaseColor}})}const gr=135*Math.PI/180,Ya=270*Math.PI/180;function sf({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=ut,tone:m="primary",color:f,thresholds:p,ariaLabel:x="Gauge",animationDuration:w=700,thickness:T=9,showScale:h=!1}){const E=s.useId().replace(/:/g,""),$=n-r||1,v=Math.min(1,Math.max(0,(e-r)/$)),[y,k]=s.useState(w>0?0:v);if(s.useEffect(()=>{if(l||i)return;if(w<=0){k(v);return}if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){k(v);return}let W=0,q=0;k(B=>(q=B,B));const I=performance.now(),oe=B=>{const O=Math.min(1,(B-I)/w),le=1-(1-O)**3;k(q+(v-q)*le),O<1&&(W=requestAnimationFrame(oe))};return W=requestAnimationFrame(oe),()=>cancelAnimationFrame(W)},[v,w,l,i]),l)return t.jsx(ft,{height:a});if(i)return t.jsx(bt,{height:a,text:c});const S=100,A=108,C=72,U=f??of(e,n,m,p),z=r+y*$,Y=ll(S,A,C,gr,gr+Ya),M=gr+Math.max(.001,y)*Ya,J=ll(S,A,C,gr,M),H=Bn(S,A,C,gr),ne=Bn(S,A,C,gr+Ya);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":x,className:"overflow-visible",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:`bonsaif-gauge-${E}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[t.jsx("stop",{offset:"0%",stopColor:U,stopOpacity:.82}),t.jsx("stop",{offset:"100%",stopColor:U,stopOpacity:1})]})}),t.jsx("path",{d:Y,fill:"none",stroke:"color-mix(in srgb, var(--border) 70%, transparent)",strokeWidth:T,strokeLinecap:"butt"}),t.jsx("path",{d:J,fill:"none",stroke:`url(#bonsaif-gauge-${E})`,strokeWidth:T,strokeLinecap:"butt",className:"bonsaif-chart-gauge-value"}),t.jsx("text",{x:S,y:A-(d?4:0),textAnchor:"middle",dominantBaseline:"middle",fill:"var(--text-main)",fontSize:28,fontWeight:700,letterSpacing:"-0.04em",className:"bonsaif-chart-gauge-label",children:u(z)}),d?t.jsx("text",{x:S,y:A+18,textAnchor:"middle",fill:"var(--text-muted)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",children:d}):null,h?t.jsxs(t.Fragment,{children:[t.jsx("text",{x:H.x-2,y:H.y+T+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(r)}),t.jsx("text",{x:ne.x+2,y:ne.y+T+14,textAnchor:"middle",fill:"var(--text-muted)",fontSize:10,children:u(n)})]}):null]})})}function of(e,r,n,a){if(a!=null&&a.length){const l=[...a].sort((c,d)=>c.value-d.value);let i=l[0].color;for(const c of l)e>=c.value&&(i=c.color);return i}if(n)return yt(n);const o=e/(r||1);return o>=.8?yt("success"):o>=.5?yt("warning"):yt("danger")}function Bn(e,r,n,a){return{x:e+n*Math.cos(a),y:r+n*Math.sin(a)}}function ll(e,r,n,a,o){const l=Bn(e,r,n,a),i=Bn(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 lf({value:e,target:r,max:n,ranges:a,height:o=72,className:l="",loading:i=!1,empty:c=!1,emptyText:d="Sin datos para mostrar",label:u,subtitle:m,valueFormat:f=ut,tone:p="primary",showScale:x=!0,showStatus:w=!0,ariaLabel:T="Bullet chart"}){if(i)return t.jsx(ft,{height:o});if(c)return t.jsx(bt,{height:o,text:d});const h=n??Math.max(e,r,...(a==null?void 0:a.map(U=>U.value))??[],1)*1.05,$=[...a??[{value:h*.5,color:"color-mix(in srgb, var(--border) 72%, transparent)"},{value:h*.75,color:"color-mix(in srgb, var(--border) 48%, transparent)"},{value:h,color:"color-mix(in srgb, var(--border) 28%, transparent)"}]].sort((U,z)=>U.value-z.value),v=yt(p),y=Math.min(100,Math.max(0,e/h*100)),k=Math.min(100,Math.max(0,r/h*100)),S=e>=r,A=[0,.25,.5,.75,1].map(U=>U*h),C=t.jsxs("div",{className:"bonsaif-bullet-plot min-w-0 flex-1",children:[t.jsxs("div",{className:"bonsaif-bullet-track relative w-full",style:{height:Math.max(22,u?28:o*.42)},role:"img","aria-label":T,children:[t.jsx("div",{className:"bonsaif-bullet-ranges absolute inset-0 flex overflow-hidden",children:$.map((U,z)=>{const Y=z===0?0:$[z-1].value,M=Math.max(0,(U.value-Y)/h*100);return t.jsx("div",{style:{width:`${M}%`,background:U.color??`color-mix(in srgb, var(--border) ${70-z*18}%, transparent)`}},z)})}),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:`${y}%`,background:v,borderRadius:"0 999px 999px 0",boxShadow:`0 0 12px color-mix(in srgb, ${v} 35%, transparent)`}})}),t.jsx("div",{className:"bonsaif-bullet-target absolute top-1/2 z-[1]",style:{left:`${k}%`,height:"72%",width:3,transform:"translate(-50%, -50%)",background:v,borderRadius:1,boxShadow:"0 0 0 1px color-mix(in srgb, var(--bg-card) 70%, transparent)"},title:`Meta ${f(r)}`})]}),x?t.jsx("div",{className:"bonsaif-bullet-scale relative mt-1.5 h-4 w-full",children:A.map((U,z)=>{const Y=U/h*100,M=z===0,J=z===A.length-1;return t.jsxs("div",{className:"absolute top-0",style:{left:`${Y}%`,transform:M?"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:M?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:M?"left":J?"right":"center"},children:f(U)})]},U)})}):null]});return t.jsx("div",{className:`bonsaif-chart bonsaif-bullet-chart w-full ${l}`,children:u?t.jsxs("div",{className:"bonsaif-bullet-row flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-4",children:[t.jsxs("div",{className:"bonsaif-bullet-label shrink-0 sm:w-[7.5rem] sm:pt-1 sm:text-right",children:[t.jsx("div",{className:"text-sm font-semibold tracking-tight",style:{color:"var(--text-main)"},children:u}),m?t.jsx("div",{className:"mt-0.5 text-[11px] leading-snug",style:{color:"var(--text-muted)"},children:m}):t.jsxs("div",{className:"mt-0.5 text-[11px] tabular-nums leading-snug",style:{color:"var(--text-muted)"},children:[t.jsx("span",{style:{color:v,fontWeight:600},children:f(e)}),t.jsxs("span",{children:[" / meta ",f(r)]})]}),w?t.jsx("div",{className:"bonsaif-bullet-status mt-1.5 inline-flex text-[10px] font-bold uppercase tracking-wide",style:{color:yt(S?"success":"warning")},children:S?"En meta":"Bajo meta"}):null]}),C]}):C})}function cf({data:e,value:r,timeKey:n="t",usageKey:a="usage",series:o,cores:l,height:i=220,className:c="",loading:d=!1,emptyText:u="Sin datos de CPU",showLegend:m=!1,showTooltip:f=!0,thresholds:p,label:x="CPU",ariaLabel:w="Uso de CPU"}){var k;const T=o??[{key:a,label:"Uso",color:Xr(r??pr(e,a)??0,p)}],h=r??pr(e,a)??pr(e,((k=T[0])==null?void 0:k.key)??a),E=!d&&(!e.length||h===null);if(d)return t.jsx(ft,{height:i});if(E)return t.jsx(bt,{height:i,text:u});const $=Math.min(100,Math.max(0,h??0)),v=An($,p),y=Xr($,p);return t.jsxs("div",{className:`bonsaif-chart bonsaif-cpu-chart w-full ${c}`,role:"group","aria-label":w,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:[x,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:y},children:br($,$<10?1:0)})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:y,background:`color-mix(in srgb, ${y} 14%, transparent)`},children:v==="danger"?"Crítico":v==="warning"?"Alto":"Normal"})]}),t.jsx(Hn,{data:e,xKey:n,series:T.map(S=>({...S,color:S.color??y})),height:Math.max(120,i-56),yDomain:[0,100],showLegend:m,showTooltip:f,valueFormat:S=>br(S,0),ariaLabel:w,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}})]})}function df({used:e,total:r,cached:n,data:a=[],timeKey:o="t",usageKey:l="usage",height:i=220,className:c="",loading:d=!1,emptyText:u="Sin datos de memoria",showHistory:m=!0,showTooltip:f=!0,thresholds:p,label:x="RAM",ariaLabel:w="Uso de memoria"}){const T=r>0?r:1,h=Math.min(100,Math.max(0,e/T*100)),E=!d&&!(Number.isFinite(e)&&Number.isFinite(r)&&r>0);if(d)return t.jsx(ft,{height:i});if(E)return t.jsx(bt,{height:i,text:u});const $=An(h,p),v=Xr(h,p),y=Math.max(0,r-e),k=a.length>0?pr(a,l)??h:h,S=Xr(k,p),A=m&&a.length>1?Math.max(100,i-110):0;return t.jsxs("div",{className:`bonsaif-chart bonsaif-ram-chart w-full ${c}`,role:"group","aria-label":w,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:x}),t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("span",{className:"bonsaif-metric-value",style:{color:v},children:br(h,h<10?1:0)}),t.jsxs("span",{className:"text-sm tabular-nums",style:{color:"var(--text-secondary)"},children:[mr(e)," / ",mr(r)]})]})]}),t.jsx("div",{className:"bonsaif-metric-badge",style:{color:v,background:`color-mix(in srgb, ${v} 14%, transparent)`},children:$==="danger"?"Crítico":$==="warning"?"Alto":"Normal"})]}),t.jsxs("div",{className:"mb-2",children:[t.jsx("div",{className:"h-2 w-full overflow-hidden rounded-sm",style:{background:"color-mix(in srgb, var(--border) 55%, transparent)"},role:"progressbar","aria-valuenow":Math.round(h),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${x} ${br(h,0)}`,children:t.jsx("div",{className:"h-full rounded-sm transition-[width] duration-300",style:{width:`${h}%`,background:`linear-gradient(90deg, ${v}, color-mix(in srgb, ${v} 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"})," ",mr(e)]}),n!=null&&Number.isFinite(n)?t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Caché"})," ",mr(n)]}):null,t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--text-main)"},children:"Libre"})," ",mr(y)]})]})]}),m&&a.length>1?t.jsx(Hn,{data:a,xKey:o,series:[{key:l,label:"Uso",color:S}],height:A,yDomain:[0,100],showLegend:!1,showTooltip:f,valueFormat:C=>br(C,0),ariaLabel:`${w} — historial`,opacity:.22,margin:{top:8,right:8,bottom:4,left:0}}):null]})}const uf="color-mix(in srgb, var(--primary) 25%, #38bdf8)",ff="color-mix(in srgb, var(--primary) 20%, #2dd4bf)";function bf({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=uf,outboundColor:m=ff,height:f=240,className:p="",loading:x=!1,emptyText:w="Sin datos de red",showLegend:T=!1,showTooltip:h=!0,label:E="Network",ariaLabel:$="Tráfico de red"}){const v=o??pr(e,n)??0,y=l??pr(e,a)??0,k=!x&&e.length===0;if(x)return t.jsx(ft,{height:f});if(k)return t.jsx(bt,{height:f,text:w});const S=U=>el(U,i),C=Math.max(140,f-76);return t.jsxs("div",{className:`bonsaif-chart bonsaif-network-chart w-full ${p}`,role:"group","aria-label":$,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:E}),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:S(v),children:S(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:m},"aria-hidden":!0}),d]}),t.jsx("div",{className:"mt-1 truncate text-lg font-semibold tabular-nums leading-tight tracking-tight opacity-95",style:{color:m},title:S(y),children:S(y)})]})]})]})}),t.jsx("div",{className:"bonsaif-network-plot relative z-0",children:t.jsx(Hn,{data:e,xKey:r,series:[{key:n,label:c,color:u},{key:a,label:d,color:m}],height:C,showLegend:T,showTooltip:h,valueFormat:S,ariaLabel:$,opacity:.18,margin:{top:8,right:8,bottom:4,left:4}})})]})}const il=["primeSuiteOrigin","primeAuthOrigin","primeSuiteAppUrl"],cl=["primeSuiteOrigin","primeSuiteProjectKey"];function mf(){if(typeof window>"u")return"*";try{if(window.parent===window)return"*";const e=new URLSearchParams(window.location.search);for(const r of il){const n=e.get(r);if(n){const a=Fn(n);if(a)return a}}if(typeof sessionStorage<"u")for(const r of cl){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=Fn(n);if(a)return a}}if(document.referrer){const r=Fn(document.referrer);if(r&&r!==window.location.origin)return r}return"*"}catch{return"*"}}function pf(){if(typeof window>"u")return"self";try{if(window.parent===window)return"self";const e=new URLSearchParams(window.location.search);for(const r of il)if(e.get(r))return"query";if(typeof sessionStorage<"u"){for(const r of cl)if(sessionStorage.getItem(r))return"sessionStorage"}if(document.referrer){const r=Fn(document.referrer);if(r&&r!==window.location.origin)return"referrer"}return"wildcard"}catch{return"wildcard"}}function Fn(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 hf(e){const[r,n]=s.useState({}),[a,o]=s.useState(!1),l=s.useCallback(u=>a||r[u]?e[u]:void 0,[e,a,r]),i=s.useCallback(u=>{n(m=>({...m,[u]:!0}))},[]),c=s.useCallback(()=>{o(!0)},[]),d=s.useCallback(()=>{n({}),o(!1)},[]);return{submitted:a,touchedFields:r,getFieldError:l,touchField:i,submit:c,reset:d}}Object.defineProperty(V,"toast",{enumerable:!0,get:()=>fs.toast}),V.Alert=fi,V.AreaChart=Hn,V.AuthShell=Ko,V.BarChart=Qu,V.BonsaifButton=Yl,V.BonsaifUIToaster=Vu,V.BulletChart=lf,V.Button=je,V.CHART_PALETTE=$n,V.CalendarPicker=gi,V.ChartCard=Xu,V.Checkbox=cn,V.CodeBlock=ki,V.ComboChart=rf,V.CompactFilterSelect=Ci,V.CompactSearchInput=Si,V.ConfirmDialog=$i,V.CopyButton=ca,V.CopyLinkButton=Ii,V.CpuChart=cf,V.DataSheets=sc,V.DataTable=Os,V.DateRangePicker=dc,V.DonutChart=Ru,V.Drawer=yc,V.DropdownMenu=gc,V.DynamicDetailTabs=di,V.EmailField=Wc,V.EmptyState=Uc,V.FieldHelperFooter=lr,V.FieldLabelInfo=or,V.FieldLayoutEditor=Zc,V.FileUpload=Kc,V.FormField=Ca,V.GaugeChart=sf,V.GlobalScrollbars=Wo,V.ImageLightbox=eo,V.ImageLightboxHost=sd,V.InputField=Sa,V.LineChart=Zu,V.LoadingState=ys,V.MentionTextEditor=$o,V.MicroserviceFrame=zu,V.Modal=fa,V.MouseTooltip=_t,V.MultiDateCalendar=fc,V.MultiSelect=ld,V.NetworkChart=bf,V.NumberField=id,V.PageHeader=Fu,V.PageSearchInput=ms,V.Pagination=dd,V.PhoneField=fd,V.PieChart=Ju,V.PrimeAuthRouteShell=Pu,V.PrimeSuiteChatFrame=ju,V.RadioGroup=bd,V.RamChart=df,V.RichTextEditor=Fd,V.SearchableSelect=zt,V.SectionPanel=Pd,V.Sparkline=tf,V.StatusBadge=jd,V.StatusSelect=Xd,V.StepWizard=Kd,V.TableSkeleton=ln,V.Tabs=Yd,V.TagInput=au,V.TextInput=yn,V.Textarea=Lo,V.TextareaField=Rd,V.TimeField=fu,V.TimePicker=Po,V.Toggle=mu,V.UserAvatar=Yo,V.WaterfallChart=nf,V.YearMultiDateCalendar=mc,V.buildMentionQueryRegex=bo,V.clearMentionChipSelection=ur,V.cn=$t,V.configureBonsaifUI=Bi,V.dedupeMentions=vo,V.defaultValueFormat=ut,V.describeParentTargetOrigin=pf,V.emailFormat=Cc,V.extractMentionUsernames=Ba,V.filterSelfMentions=Ld,V.findMentionChipAfterCaret=Co,V.findMentionChipBeforeCaret=So,V.findMentionChipsInSelection=Eo,V.findMentionTriggerInEditor=Oa,V.formatBytes=mr,V.formatPercent=br,V.formatRate=el,V.getBonsaifUIConfig=Fi,V.getDataTablePreferencesEndpoint=ba,V.getPlainTextOffset=Fa,V.highlightMentions=yo,V.htmlToText=ho,V.insertMentionInEditor=xo,V.isMentionTriggerBoundary=po,V.isPlainOffsetInsideMentionChip=mo,V.isValidEmail=wa,V.isValidPhone=ka,V.locateTextOffset=dr,V.matches=Lc,V.maxLength=Tc,V.maxValue=Ac,V.mentionDisplayLabel=go,V.minLength=Mc,V.minValue=$c,V.normalizeUsername=Ha,V.openImageLightboxFromEvent=Js,V.phoneCountryCodeOptions=no,V.phoneFormat=Ec,V.placeCaretAtTextOffset=wo,V.removeMentionChip=Cn,V.required=Sc,V.resetBonsaifUIConfig=Pi,V.resolveMentions=Ad,V.resolveParentTargetOrigin=mf,V.selectMentionChip=No,V.seriesColor=Ro,V.setBonsaifDataTablePreferencesEndpoint=_i,V.toneColor=yt,V.usageColor=Xr,V.usageTone=An,V.useValidationVisibility=hf,V.validateForm=Dc,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"})}));